Merge branch 'qt-treectrl'
Closes https://github.com/wxWidgets/wxWidgets/pull/1225
This commit is contained in:
commit
e67223e6c4
43
Makefile.in
43
Makefile.in
@ -3597,7 +3597,8 @@ COND_TOOLKIT_QT_GUI_HDR = \
|
||||
wx/generic/activityindicator.h \
|
||||
wx/qt/dataview.h \
|
||||
wx/qt/dvrenderers.h \
|
||||
$(QT_PLATFORM_HDR)
|
||||
$(QT_PLATFORM_HDR) \
|
||||
wx/qt/treectrl.h
|
||||
@COND_TOOLKIT_QT@GUI_HDR = $(COND_TOOLKIT_QT_GUI_HDR)
|
||||
@COND_TOOLKIT_COCOA@MEDIA_PLATFORM_HDR =
|
||||
@COND_TOOLKIT_GTK@MEDIA_PLATFORM_HDR =
|
||||
@ -5566,7 +5567,7 @@ COND_TOOLKIT_MSW___GUI_SRC_OBJECTS = \
|
||||
monodll_msw_textctrl.o \
|
||||
monodll_msw_textentry.o \
|
||||
monodll_msw_tglbtn.o \
|
||||
monodll_treectrl.o \
|
||||
monodll_msw_treectrl.o \
|
||||
monodll_systhemectrl.o \
|
||||
monodll_customdraw.o \
|
||||
monodll_animateg.o \
|
||||
@ -5760,7 +5761,8 @@ COND_TOOLKIT_QT___GUI_SRC_OBJECTS = \
|
||||
monodll_qt_uiaction.o \
|
||||
monodll_qt_utils.o \
|
||||
monodll_qt_window.o \
|
||||
$(__QT_PLATFORM_SRC_OBJECTS)
|
||||
$(__QT_PLATFORM_SRC_OBJECTS) \
|
||||
monodll_qt_treectrl.o
|
||||
@COND_TOOLKIT_QT@__GUI_SRC_OBJECTS = $(COND_TOOLKIT_QT___GUI_SRC_OBJECTS)
|
||||
COND_PLATFORM_WIN32_1___QT_PLATFORM_SRC_OBJECTS = \
|
||||
monodll_comimpl.o \
|
||||
@ -7551,7 +7553,7 @@ COND_TOOLKIT_MSW___GUI_SRC_OBJECTS_1 = \
|
||||
monolib_msw_textctrl.o \
|
||||
monolib_msw_textentry.o \
|
||||
monolib_msw_tglbtn.o \
|
||||
monolib_treectrl.o \
|
||||
monolib_msw_treectrl.o \
|
||||
monolib_systhemectrl.o \
|
||||
monolib_customdraw.o \
|
||||
monolib_animateg.o \
|
||||
@ -7745,7 +7747,8 @@ COND_TOOLKIT_QT___GUI_SRC_OBJECTS_1 = \
|
||||
monolib_qt_uiaction.o \
|
||||
monolib_qt_utils.o \
|
||||
monolib_qt_window.o \
|
||||
$(__QT_PLATFORM_SRC_OBJECTS_1)
|
||||
$(__QT_PLATFORM_SRC_OBJECTS_1) \
|
||||
monolib_qt_treectrl.o
|
||||
@COND_TOOLKIT_QT@__GUI_SRC_OBJECTS_1 = $(COND_TOOLKIT_QT___GUI_SRC_OBJECTS_1)
|
||||
COND_PLATFORM_WIN32_1___QT_PLATFORM_SRC_OBJECTS_1 = \
|
||||
monolib_comimpl.o \
|
||||
@ -9683,7 +9686,7 @@ COND_TOOLKIT_MSW___GUI_SRC_OBJECTS_2 = \
|
||||
coredll_msw_textctrl.o \
|
||||
coredll_msw_textentry.o \
|
||||
coredll_msw_tglbtn.o \
|
||||
coredll_treectrl.o \
|
||||
coredll_msw_treectrl.o \
|
||||
coredll_systhemectrl.o \
|
||||
coredll_customdraw.o \
|
||||
coredll_animateg.o \
|
||||
@ -9877,7 +9880,8 @@ COND_TOOLKIT_QT___GUI_SRC_OBJECTS_2 = \
|
||||
coredll_qt_uiaction.o \
|
||||
coredll_qt_utils.o \
|
||||
coredll_qt_window.o \
|
||||
$(__QT_PLATFORM_SRC_OBJECTS_2)
|
||||
$(__QT_PLATFORM_SRC_OBJECTS_2) \
|
||||
coredll_qt_treectrl.o
|
||||
@COND_TOOLKIT_QT@__GUI_SRC_OBJECTS_2 = $(COND_TOOLKIT_QT___GUI_SRC_OBJECTS_2)
|
||||
COND_PLATFORM_WIN32_1___QT_PLATFORM_SRC_OBJECTS_2 = \
|
||||
coredll_comimpl.o \
|
||||
@ -11404,7 +11408,7 @@ COND_TOOLKIT_MSW___GUI_SRC_OBJECTS_3 = \
|
||||
corelib_msw_textctrl.o \
|
||||
corelib_msw_textentry.o \
|
||||
corelib_msw_tglbtn.o \
|
||||
corelib_treectrl.o \
|
||||
corelib_msw_treectrl.o \
|
||||
corelib_systhemectrl.o \
|
||||
corelib_customdraw.o \
|
||||
corelib_animateg.o \
|
||||
@ -11598,7 +11602,8 @@ COND_TOOLKIT_QT___GUI_SRC_OBJECTS_3 = \
|
||||
corelib_qt_uiaction.o \
|
||||
corelib_qt_utils.o \
|
||||
corelib_qt_window.o \
|
||||
$(__QT_PLATFORM_SRC_OBJECTS_3)
|
||||
$(__QT_PLATFORM_SRC_OBJECTS_3) \
|
||||
corelib_qt_treectrl.o
|
||||
@COND_TOOLKIT_QT@__GUI_SRC_OBJECTS_3 = $(COND_TOOLKIT_QT___GUI_SRC_OBJECTS_3)
|
||||
COND_PLATFORM_WIN32_1___QT_PLATFORM_SRC_OBJECTS_3 = \
|
||||
corelib_comimpl.o \
|
||||
@ -16376,7 +16381,7 @@ monodll_msw_textentry.o: $(srcdir)/src/msw/textentry.cpp $(MONODLL_ODEP)
|
||||
monodll_msw_tglbtn.o: $(srcdir)/src/msw/tglbtn.cpp $(MONODLL_ODEP)
|
||||
$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/tglbtn.cpp
|
||||
|
||||
monodll_treectrl.o: $(srcdir)/src/msw/treectrl.cpp $(MONODLL_ODEP)
|
||||
monodll_msw_treectrl.o: $(srcdir)/src/msw/treectrl.cpp $(MONODLL_ODEP)
|
||||
$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/msw/treectrl.cpp
|
||||
|
||||
monodll_systhemectrl.o: $(srcdir)/src/msw/systhemectrl.cpp $(MONODLL_ODEP)
|
||||
@ -16871,6 +16876,9 @@ monodll_qt_window.o: $(srcdir)/src/qt/window.cpp $(MONODLL_ODEP)
|
||||
monodll_qt_graphics.o: $(srcdir)/src/qt/graphics.cpp $(MONODLL_ODEP)
|
||||
$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/qt/graphics.cpp
|
||||
|
||||
monodll_qt_treectrl.o: $(srcdir)/src/qt/treectrl.cpp $(MONODLL_ODEP)
|
||||
$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/qt/treectrl.cpp
|
||||
|
||||
monodll_univ_anybutton.o: $(srcdir)/src/univ/anybutton.cpp $(MONODLL_ODEP)
|
||||
$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/univ/anybutton.cpp
|
||||
|
||||
@ -21641,7 +21649,7 @@ monolib_msw_textentry.o: $(srcdir)/src/msw/textentry.cpp $(MONOLIB_ODEP)
|
||||
monolib_msw_tglbtn.o: $(srcdir)/src/msw/tglbtn.cpp $(MONOLIB_ODEP)
|
||||
$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/tglbtn.cpp
|
||||
|
||||
monolib_treectrl.o: $(srcdir)/src/msw/treectrl.cpp $(MONOLIB_ODEP)
|
||||
monolib_msw_treectrl.o: $(srcdir)/src/msw/treectrl.cpp $(MONOLIB_ODEP)
|
||||
$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/msw/treectrl.cpp
|
||||
|
||||
monolib_systhemectrl.o: $(srcdir)/src/msw/systhemectrl.cpp $(MONOLIB_ODEP)
|
||||
@ -22136,6 +22144,9 @@ monolib_qt_window.o: $(srcdir)/src/qt/window.cpp $(MONOLIB_ODEP)
|
||||
monolib_qt_graphics.o: $(srcdir)/src/qt/graphics.cpp $(MONOLIB_ODEP)
|
||||
$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/qt/graphics.cpp
|
||||
|
||||
monolib_qt_treectrl.o: $(srcdir)/src/qt/treectrl.cpp $(MONOLIB_ODEP)
|
||||
$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/qt/treectrl.cpp
|
||||
|
||||
monolib_univ_anybutton.o: $(srcdir)/src/univ/anybutton.cpp $(MONOLIB_ODEP)
|
||||
$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/univ/anybutton.cpp
|
||||
|
||||
@ -27566,7 +27577,7 @@ coredll_msw_textentry.o: $(srcdir)/src/msw/textentry.cpp $(COREDLL_ODEP)
|
||||
coredll_msw_tglbtn.o: $(srcdir)/src/msw/tglbtn.cpp $(COREDLL_ODEP)
|
||||
$(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/msw/tglbtn.cpp
|
||||
|
||||
coredll_treectrl.o: $(srcdir)/src/msw/treectrl.cpp $(COREDLL_ODEP)
|
||||
coredll_msw_treectrl.o: $(srcdir)/src/msw/treectrl.cpp $(COREDLL_ODEP)
|
||||
$(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/msw/treectrl.cpp
|
||||
|
||||
coredll_systhemectrl.o: $(srcdir)/src/msw/systhemectrl.cpp $(COREDLL_ODEP)
|
||||
@ -28061,6 +28072,9 @@ coredll_qt_window.o: $(srcdir)/src/qt/window.cpp $(COREDLL_ODEP)
|
||||
coredll_qt_graphics.o: $(srcdir)/src/qt/graphics.cpp $(COREDLL_ODEP)
|
||||
$(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/qt/graphics.cpp
|
||||
|
||||
coredll_qt_treectrl.o: $(srcdir)/src/qt/treectrl.cpp $(COREDLL_ODEP)
|
||||
$(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/qt/treectrl.cpp
|
||||
|
||||
coredll_univ_anybutton.o: $(srcdir)/src/univ/anybutton.cpp $(COREDLL_ODEP)
|
||||
$(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/univ/anybutton.cpp
|
||||
|
||||
@ -31820,7 +31834,7 @@ corelib_msw_textentry.o: $(srcdir)/src/msw/textentry.cpp $(CORELIB_ODEP)
|
||||
corelib_msw_tglbtn.o: $(srcdir)/src/msw/tglbtn.cpp $(CORELIB_ODEP)
|
||||
$(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/msw/tglbtn.cpp
|
||||
|
||||
corelib_treectrl.o: $(srcdir)/src/msw/treectrl.cpp $(CORELIB_ODEP)
|
||||
corelib_msw_treectrl.o: $(srcdir)/src/msw/treectrl.cpp $(CORELIB_ODEP)
|
||||
$(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/msw/treectrl.cpp
|
||||
|
||||
corelib_systhemectrl.o: $(srcdir)/src/msw/systhemectrl.cpp $(CORELIB_ODEP)
|
||||
@ -32315,6 +32329,9 @@ corelib_qt_window.o: $(srcdir)/src/qt/window.cpp $(CORELIB_ODEP)
|
||||
corelib_qt_graphics.o: $(srcdir)/src/qt/graphics.cpp $(CORELIB_ODEP)
|
||||
$(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/qt/graphics.cpp
|
||||
|
||||
corelib_qt_treectrl.o: $(srcdir)/src/qt/treectrl.cpp $(CORELIB_ODEP)
|
||||
$(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/qt/treectrl.cpp
|
||||
|
||||
corelib_univ_anybutton.o: $(srcdir)/src/univ/anybutton.cpp $(CORELIB_ODEP)
|
||||
$(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/univ/anybutton.cpp
|
||||
|
||||
|
@ -347,7 +347,6 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
|
||||
wx/qt/toolbar.h
|
||||
wx/qt/tooltip.h
|
||||
wx/qt/toplevel.h
|
||||
<!-- wx/qt/treectrl.h -->
|
||||
wx/qt/window.h
|
||||
wx/generic/fdrepdlg.h
|
||||
wx/generic/filepickerg.h
|
||||
@ -362,6 +361,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
|
||||
wx/qt/dataview.h
|
||||
wx/qt/dvrenderers.h
|
||||
$(QT_PLATFORM_HDR)
|
||||
wx/qt/treectrl.h
|
||||
</set>
|
||||
|
||||
<set var="QT_SRC" hints="files">
|
||||
@ -460,6 +460,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
|
||||
src/qt/utils.cpp
|
||||
src/qt/window.cpp
|
||||
$(QT_PLATFORM_SRC)
|
||||
src/qt/treectrl.cpp
|
||||
</set>
|
||||
|
||||
<set var="MEDIA_QT_SRC" hints="files">
|
||||
|
@ -276,6 +276,7 @@ set(QT_HDR
|
||||
wx/qt/dataview.h
|
||||
wx/generic/activityindicator.h
|
||||
${QT_PLATFORM_HDR}
|
||||
wx/qt/treectrl.h
|
||||
)
|
||||
|
||||
set(QT_SRC
|
||||
@ -374,6 +375,7 @@ set(QT_SRC
|
||||
src/qt/dataview.cpp
|
||||
src/qt/taskbar.cpp
|
||||
${QT_PLATFORM_SRC}
|
||||
src/qt/treectrl.cpp
|
||||
)
|
||||
|
||||
set(MEDIA_QT_SRC
|
||||
|
@ -297,6 +297,7 @@ QT_HDR =
|
||||
wx/qt/toolbar.h
|
||||
wx/qt/tooltip.h
|
||||
wx/qt/toplevel.h
|
||||
wx/qt/treectrl.h
|
||||
wx/qt/window.h
|
||||
|
||||
QT_SRC=
|
||||
@ -392,6 +393,7 @@ QT_SRC=
|
||||
src/qt/toolbar.cpp
|
||||
src/qt/tooltip.cpp
|
||||
src/qt/toplevel.cpp
|
||||
src/qt/treectrl.cpp
|
||||
src/qt/uiaction.cpp
|
||||
src/qt/utils.cpp
|
||||
src/qt/window.cpp
|
||||
|
@ -360,7 +360,9 @@ private:
|
||||
wxDECLARE_NO_COPY_CLASS(wxGenericTreeCtrl);
|
||||
};
|
||||
|
||||
#if !defined(__WXMSW__) || defined(__WXUNIVERSAL__)
|
||||
// Also define wxTreeCtrl to be wxGenericTreeCtrl on all platforms without a
|
||||
// native version, i.e. all but MSW and Qt.
|
||||
#if !(defined(__WXMSW__) || defined(__WXQT__)) || defined(__WXUNIVERSAL__)
|
||||
/*
|
||||
* wxTreeCtrl has to be a real class or we have problems with
|
||||
* the run-time information.
|
||||
@ -383,7 +385,7 @@ public:
|
||||
{
|
||||
}
|
||||
};
|
||||
#endif // !__WXMSW__ || __WXUNIVERSAL__
|
||||
#endif // !(__WXMSW__ || __WXQT__) || __WXUNIVERSAL__
|
||||
|
||||
#endif // wxUSE_TREECTRL
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#include "wx/textctrl.h"
|
||||
|
||||
class wxQtTreeWidget;
|
||||
class wxQtListTreeWidget;
|
||||
class QTreeWidgetItem;
|
||||
|
||||
class WXDLLIMPEXP_FWD_CORE wxImageList;
|
||||
@ -282,7 +282,7 @@ protected:
|
||||
m_ownsImageListSmall,
|
||||
m_ownsImageListState;
|
||||
private:
|
||||
wxQtTreeWidget *m_qtTreeWidget;
|
||||
wxQtListTreeWidget *m_qtTreeWidget;
|
||||
|
||||
wxDECLARE_DYNAMIC_CLASS( wxListCtrl );
|
||||
};
|
||||
|
@ -15,10 +15,12 @@
|
||||
|
||||
#include "wx/kbdstate.h"
|
||||
#include "wx/gdicmn.h"
|
||||
#include "wx/colour.h"
|
||||
|
||||
#include <QtCore/QRect>
|
||||
#include <QtCore/QSize>
|
||||
#include <QtCore/QString>
|
||||
#include <QtGui/QColor>
|
||||
|
||||
// Rely on overloading and let the compiler pick the correct version, which makes
|
||||
// them easier to use then to write wxQtConvertQtRectToWxRect() or wxQtConvertWxRectToQtRect()
|
||||
@ -54,6 +56,16 @@ inline QString wxQtConvertString( const wxString &str )
|
||||
return QString( str.utf8_str() );
|
||||
}
|
||||
|
||||
inline wxColour wxQtConvertColour(const QColor &colour)
|
||||
{
|
||||
return wxColour(colour.red(), colour.green(), colour.blue(), colour.alpha());
|
||||
}
|
||||
|
||||
inline QColor wxQtConvertColour(const wxColour &colour)
|
||||
{
|
||||
return QColor(colour.Red(), colour.Green(), colour.Blue(), colour.Alpha());
|
||||
}
|
||||
|
||||
#if wxUSE_DATETIME
|
||||
|
||||
class WXDLLIMPEXP_FWD_BASE wxDateTime;
|
||||
|
76
include/wx/qt/private/treeitemdelegate.h
Normal file
76
include/wx/qt/private/treeitemdelegate.h
Normal file
@ -0,0 +1,76 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/qt/private/treeitemdelegate.h
|
||||
// Purpose: Delegate to create text edit controls for the tree items
|
||||
// Author: Matthew Griffin
|
||||
// Created: 2019-05-29
|
||||
// Copyright: Matthew Griffin
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_QT_PRIVATE_TREEITEM_DELEGATE_H
|
||||
#define _WX_QT_PRIVATE_TREEITEM_DELEGATE_H
|
||||
|
||||
#include <QtWidgets/QStyledItemDelegate>
|
||||
|
||||
#include "wx/app.h"
|
||||
#include "wx/textctrl.h"
|
||||
|
||||
#include "treeitemfactory.h"
|
||||
|
||||
class wxQTTreeItemDelegate : public QStyledItemDelegate
|
||||
{
|
||||
public:
|
||||
explicit wxQTTreeItemDelegate(wxWindow* parent)
|
||||
: m_parent(parent),
|
||||
m_textCtrl(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &WXUNUSED(option), const QModelIndex &index) const wxOVERRIDE
|
||||
{
|
||||
if ( m_textCtrl != NULL )
|
||||
destroyEditor(m_textCtrl->GetHandle(), m_currentModelIndex);
|
||||
|
||||
m_currentModelIndex = index;
|
||||
m_textCtrl = new wxQtListTextCtrl(m_parent, parent);
|
||||
m_textCtrl->SetFocus();
|
||||
return m_textCtrl->GetHandle();
|
||||
}
|
||||
|
||||
void destroyEditor(QWidget *WXUNUSED(editor), const QModelIndex &WXUNUSED(index)) const wxOVERRIDE
|
||||
{
|
||||
if ( m_textCtrl != NULL )
|
||||
{
|
||||
m_currentModelIndex = QModelIndex(); // invalidate the index
|
||||
wxTheApp->ScheduleForDestruction(m_textCtrl);
|
||||
m_textCtrl = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void setModelData(QWidget *WXUNUSED(editor), QAbstractItemModel *WXUNUSED(model), const QModelIndex &WXUNUSED(index)) const wxOVERRIDE
|
||||
{
|
||||
// Don't set model data until wx has had a chance to send out events
|
||||
}
|
||||
|
||||
wxTextCtrl* GetEditControl() const
|
||||
{
|
||||
return m_textCtrl;
|
||||
}
|
||||
|
||||
QModelIndex GetCurrentModelIndex() const
|
||||
{
|
||||
return m_currentModelIndex;
|
||||
}
|
||||
|
||||
void AcceptModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
|
||||
{
|
||||
QStyledItemDelegate::setModelData(editor, model, index);
|
||||
}
|
||||
|
||||
private:
|
||||
wxWindow* m_parent;
|
||||
mutable wxTextCtrl* m_textCtrl;
|
||||
mutable QModelIndex m_currentModelIndex;
|
||||
};
|
||||
|
||||
#endif // _WX_QT_PRIVATE_TREEITEM_DELEGATE_H
|
122
include/wx/qt/private/treeitemfactory.h
Normal file
122
include/wx/qt/private/treeitemfactory.h
Normal file
@ -0,0 +1,122 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/qt/private/treeitemfactory.h
|
||||
// Purpose: Factory to create text edit controls for the tree items
|
||||
// Author: Graham Dawes
|
||||
// Created: 2019-02-07
|
||||
// Copyright: Graham Dawes
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_QT_PRIVATE_TREEITEM_FACTORY_H_
|
||||
#define _WX_QT_PRIVATE_TREEITEM_FACTORY_H_
|
||||
|
||||
#include <QtWidgets/QItemEditorFactory>
|
||||
#include <QtWidgets/QTreeWidget>
|
||||
#include <QtWidgets/QItemDelegate>
|
||||
|
||||
#include "wx/recguard.h"
|
||||
#include "wx/textctrl.h"
|
||||
|
||||
// wxQT Doesn't have a mechanism for "adopting" external widgets so we have to
|
||||
// create an instance of wxTextCtrl rather than adopting the control QT would
|
||||
// create.
|
||||
//
|
||||
// Unfortunately the factory is given an internal widget as the parent for
|
||||
// editor.
|
||||
//
|
||||
// To work around these issues we create a wxTextCtl parented by the wxListCtrl
|
||||
// then recalculate its position relative to the internal widget.
|
||||
|
||||
class wxQtListTextCtrl : public wxTextCtrl
|
||||
{
|
||||
public:
|
||||
wxQtListTextCtrl(wxWindow* parent, QWidget* actualParent)
|
||||
: wxTextCtrl(parent, wxID_ANY, wxEmptyString,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxNO_BORDER),
|
||||
m_actualParent(actualParent),
|
||||
m_moving(0)
|
||||
{
|
||||
Bind(wxEVT_MOVE, &wxQtListTextCtrl::OnMove, this);
|
||||
}
|
||||
|
||||
void OnMove(wxMoveEvent &event)
|
||||
{
|
||||
// QWidget::move generates a QMoveEvent so we need to guard against
|
||||
// reentrant calls.
|
||||
wxRecursionGuard guard(m_moving);
|
||||
|
||||
if ( guard.IsInside() )
|
||||
{
|
||||
event.Skip();
|
||||
return;
|
||||
}
|
||||
|
||||
const QPoint eventPos = wxQtConvertPoint(event.GetPosition());
|
||||
const QPoint globalPos = m_actualParent->mapToGlobal(eventPos);
|
||||
|
||||
// For some reason this always gives us the offset from the header info
|
||||
// the internal control. So we need to treat this as an offset rather
|
||||
// than a position.
|
||||
QWidget* widget = GetHandle();
|
||||
const QPoint offset = widget->mapFromGlobal(globalPos);
|
||||
|
||||
widget->move(eventPos + offset);
|
||||
}
|
||||
|
||||
private:
|
||||
QWidget* m_actualParent;
|
||||
wxRecursionGuardFlag m_moving;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxQtListTextCtrl);
|
||||
};
|
||||
|
||||
// QT doesn't give us direct access to the editor within the QTreeWidget.
|
||||
// Instead, we'll supply a factory to create the widget for QT and keep track
|
||||
// of it ourselves.
|
||||
|
||||
class wxQtTreeItemEditorFactory : public QItemEditorFactory
|
||||
{
|
||||
public:
|
||||
explicit wxQtTreeItemEditorFactory(wxWindow* parent)
|
||||
: m_parent(parent),
|
||||
m_textCtrl(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
void AttachTo(QTreeWidget *tree)
|
||||
{
|
||||
QAbstractItemDelegate* delegate = tree->itemDelegate();
|
||||
QItemDelegate *qItemDelegate = static_cast<QItemDelegate*>(delegate);
|
||||
qItemDelegate->setItemEditorFactory(this);
|
||||
}
|
||||
|
||||
QWidget* createEditor(int WXUNUSED(userType), QWidget* parent) const wxOVERRIDE
|
||||
{
|
||||
if (m_textCtrl != NULL)
|
||||
ClearEditor();
|
||||
|
||||
m_textCtrl = new wxQtListTextCtrl(m_parent, parent);
|
||||
m_textCtrl->SetFocus();
|
||||
return m_textCtrl->GetHandle();
|
||||
}
|
||||
|
||||
wxTextCtrl* GetEditControl() const
|
||||
{
|
||||
return m_textCtrl;
|
||||
}
|
||||
|
||||
void ClearEditor() const
|
||||
{
|
||||
delete m_textCtrl;
|
||||
m_textCtrl = NULL;
|
||||
}
|
||||
|
||||
private:
|
||||
wxWindow* m_parent;
|
||||
mutable wxTextCtrl* m_textCtrl;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxQtTreeItemEditorFactory);
|
||||
};
|
||||
|
||||
#endif //_WX_QT_PRIVATE_TREEITEM_FACTORY_H_
|
@ -8,7 +8,7 @@
|
||||
#ifndef _WX_QT_TREECTRL_H_
|
||||
#define _WX_QT_TREECTRL_H_
|
||||
|
||||
class QTreeWidget;
|
||||
class wxQTreeWidget;
|
||||
|
||||
class WXDLLIMPEXP_CORE wxTreeCtrl : public wxTreeCtrlBase
|
||||
{
|
||||
@ -21,6 +21,8 @@ public:
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxTreeCtrlNameStr);
|
||||
|
||||
virtual ~wxTreeCtrl();
|
||||
|
||||
bool Create(wxWindow *parent, wxWindowID id = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
@ -28,113 +30,116 @@ public:
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxTreeCtrlNameStr);
|
||||
|
||||
virtual unsigned int GetCount() const;
|
||||
virtual unsigned int GetCount() const wxOVERRIDE;
|
||||
|
||||
virtual unsigned int GetIndent() const;
|
||||
virtual void SetIndent(unsigned int indent);
|
||||
virtual unsigned int GetIndent() const wxOVERRIDE;
|
||||
virtual void SetIndent(unsigned int indent) wxOVERRIDE;
|
||||
|
||||
virtual void SetImageList(wxImageList *imageList);
|
||||
virtual void SetStateImageList(wxImageList *imageList);
|
||||
virtual void SetImageList(wxImageList *imageList) wxOVERRIDE;
|
||||
virtual void SetStateImageList(wxImageList *imageList) wxOVERRIDE;
|
||||
|
||||
virtual wxString GetItemText(const wxTreeItemId& item) const;
|
||||
virtual wxString GetItemText(const wxTreeItemId& item) const wxOVERRIDE;
|
||||
virtual int GetItemImage(const wxTreeItemId& item,
|
||||
wxTreeItemIcon which = wxTreeItemIcon_Normal) const;
|
||||
virtual wxTreeItemData *GetItemData(const wxTreeItemId& item) const;
|
||||
virtual wxColour GetItemTextColour(const wxTreeItemId& item) const;
|
||||
virtual wxColour GetItemBackgroundColour(const wxTreeItemId& item) const;
|
||||
virtual wxFont GetItemFont(const wxTreeItemId& item) const;
|
||||
wxTreeItemIcon which = wxTreeItemIcon_Normal) const wxOVERRIDE;
|
||||
virtual wxTreeItemData *GetItemData(const wxTreeItemId& item) const wxOVERRIDE;
|
||||
virtual wxColour GetItemTextColour(const wxTreeItemId& item) const wxOVERRIDE;
|
||||
virtual wxColour GetItemBackgroundColour(const wxTreeItemId& item) const wxOVERRIDE;
|
||||
virtual wxFont GetItemFont(const wxTreeItemId& item) const wxOVERRIDE;
|
||||
|
||||
virtual void SetItemText(const wxTreeItemId& item, const wxString& text);
|
||||
virtual void SetItemText(const wxTreeItemId& item, const wxString& text) wxOVERRIDE;
|
||||
virtual void SetItemImage(const wxTreeItemId& item,
|
||||
int image,
|
||||
wxTreeItemIcon which = wxTreeItemIcon_Normal);
|
||||
virtual void SetItemData(const wxTreeItemId& item, wxTreeItemData *data);
|
||||
virtual void SetItemHasChildren(const wxTreeItemId& item, bool has = true);
|
||||
virtual void SetItemBold(const wxTreeItemId& item, bool bold = true);
|
||||
virtual void SetItemDropHighlight(const wxTreeItemId& item, bool highlight = true);
|
||||
virtual void SetItemTextColour(const wxTreeItemId& item, const wxColour& col);
|
||||
virtual void SetItemBackgroundColour(const wxTreeItemId& item, const wxColour& col);
|
||||
virtual void SetItemFont(const wxTreeItemId& item, const wxFont& font);
|
||||
wxTreeItemIcon which = wxTreeItemIcon_Normal) wxOVERRIDE;
|
||||
virtual void SetItemData(const wxTreeItemId& item, wxTreeItemData *data) wxOVERRIDE;
|
||||
virtual void SetItemHasChildren(const wxTreeItemId& item, bool has = true) wxOVERRIDE;
|
||||
virtual void SetItemBold(const wxTreeItemId& item, bool bold = true) wxOVERRIDE;
|
||||
virtual void SetItemDropHighlight(const wxTreeItemId& item, bool highlight = true) wxOVERRIDE;
|
||||
virtual void SetItemTextColour(const wxTreeItemId& item, const wxColour& col) wxOVERRIDE;
|
||||
virtual void SetItemBackgroundColour(const wxTreeItemId& item, const wxColour& col) wxOVERRIDE;
|
||||
virtual void SetItemFont(const wxTreeItemId& item, const wxFont& font) wxOVERRIDE;
|
||||
|
||||
virtual bool IsVisible(const wxTreeItemId& item) const;
|
||||
virtual bool ItemHasChildren(const wxTreeItemId& item) const;
|
||||
virtual bool IsExpanded(const wxTreeItemId& item) const;
|
||||
virtual bool IsSelected(const wxTreeItemId& item) const;
|
||||
virtual bool IsBold(const wxTreeItemId& item) const;
|
||||
virtual bool IsVisible(const wxTreeItemId& item) const wxOVERRIDE;
|
||||
virtual bool ItemHasChildren(const wxTreeItemId& item) const wxOVERRIDE;
|
||||
virtual bool IsExpanded(const wxTreeItemId& item) const wxOVERRIDE;
|
||||
virtual bool IsSelected(const wxTreeItemId& item) const wxOVERRIDE;
|
||||
virtual bool IsBold(const wxTreeItemId& item) const wxOVERRIDE;
|
||||
|
||||
virtual size_t GetChildrenCount(const wxTreeItemId& item, bool recursively = true) const;
|
||||
virtual size_t GetChildrenCount(const wxTreeItemId& item, bool recursively = true) const wxOVERRIDE;
|
||||
|
||||
virtual wxTreeItemId GetRootItem() const;
|
||||
virtual wxTreeItemId GetSelection() const;
|
||||
virtual size_t GetSelections(wxArrayTreeItemIds& selections) const;
|
||||
virtual wxTreeItemId GetRootItem() const wxOVERRIDE;
|
||||
virtual wxTreeItemId GetSelection() const wxOVERRIDE;
|
||||
virtual size_t GetSelections(wxArrayTreeItemIds& selections) const wxOVERRIDE;
|
||||
|
||||
virtual void SetFocusedItem(const wxTreeItemId& item);
|
||||
virtual void ClearFocusedItem();
|
||||
virtual wxTreeItemId GetFocusedItem() const;
|
||||
virtual void SetFocusedItem(const wxTreeItemId& item) wxOVERRIDE;
|
||||
virtual void ClearFocusedItem() wxOVERRIDE;
|
||||
virtual wxTreeItemId GetFocusedItem() const wxOVERRIDE;
|
||||
|
||||
virtual wxTreeItemId GetItemParent(const wxTreeItemId& item) const;
|
||||
|
||||
virtual wxTreeItemId GetFirstChild(const wxTreeItemId& item, wxTreeItemIdValue& cookie) const;
|
||||
virtual wxTreeItemId GetNextChild(const wxTreeItemId& item, wxTreeItemIdValue& cookie) const;
|
||||
virtual wxTreeItemId GetLastChild(const wxTreeItemId& item) const;
|
||||
virtual wxTreeItemId GetNextSibling(const wxTreeItemId& item) const;
|
||||
virtual wxTreeItemId GetPrevSibling(const wxTreeItemId& item) const;
|
||||
virtual wxTreeItemId GetFirstVisibleItem() const;
|
||||
virtual wxTreeItemId GetNextVisible(const wxTreeItemId& item) const;
|
||||
virtual wxTreeItemId GetPrevVisible(const wxTreeItemId& item) const;
|
||||
virtual wxTreeItemId GetItemParent(const wxTreeItemId& item) const wxOVERRIDE;
|
||||
virtual wxTreeItemId GetFirstChild(const wxTreeItemId& item, wxTreeItemIdValue& cookie) const wxOVERRIDE;
|
||||
virtual wxTreeItemId GetNextChild(const wxTreeItemId& item, wxTreeItemIdValue& cookie) const wxOVERRIDE;
|
||||
virtual wxTreeItemId GetLastChild(const wxTreeItemId& item) const wxOVERRIDE;
|
||||
virtual wxTreeItemId GetNextSibling(const wxTreeItemId& item) const wxOVERRIDE;
|
||||
virtual wxTreeItemId GetPrevSibling(const wxTreeItemId& item) const wxOVERRIDE;
|
||||
virtual wxTreeItemId GetFirstVisibleItem() const wxOVERRIDE;
|
||||
virtual wxTreeItemId GetNextVisible(const wxTreeItemId& item) const wxOVERRIDE;
|
||||
virtual wxTreeItemId GetPrevVisible(const wxTreeItemId& item) const wxOVERRIDE;
|
||||
|
||||
virtual wxTreeItemId AddRoot(const wxString& text,
|
||||
int image = -1, int selImage = -1,
|
||||
wxTreeItemData *data = NULL);
|
||||
wxTreeItemData *data = NULL) wxOVERRIDE;
|
||||
|
||||
virtual void Delete(const wxTreeItemId& item);
|
||||
virtual void DeleteChildren(const wxTreeItemId& item);
|
||||
virtual void DeleteAllItems();
|
||||
virtual void Delete(const wxTreeItemId& item) wxOVERRIDE;
|
||||
virtual void DeleteChildren(const wxTreeItemId& item) wxOVERRIDE;
|
||||
virtual void DeleteAllItems() wxOVERRIDE;
|
||||
|
||||
virtual void Expand(const wxTreeItemId& item);
|
||||
virtual void Collapse(const wxTreeItemId& item);
|
||||
virtual void CollapseAndReset(const wxTreeItemId& item);
|
||||
virtual void Toggle(const wxTreeItemId& item);
|
||||
virtual void Expand(const wxTreeItemId& item) wxOVERRIDE;
|
||||
virtual void Collapse(const wxTreeItemId& item) wxOVERRIDE;
|
||||
virtual void CollapseAndReset(const wxTreeItemId& item) wxOVERRIDE;
|
||||
virtual void Toggle(const wxTreeItemId& item) wxOVERRIDE;
|
||||
|
||||
virtual void Unselect();
|
||||
virtual void UnselectAll();
|
||||
virtual void SelectItem(const wxTreeItemId& item, bool select = true);
|
||||
virtual void SelectChildren(const wxTreeItemId& parent);
|
||||
virtual void Unselect() wxOVERRIDE;
|
||||
virtual void UnselectAll() wxOVERRIDE;
|
||||
virtual void SelectItem(const wxTreeItemId& item, bool select = true) wxOVERRIDE;
|
||||
virtual void SelectChildren(const wxTreeItemId& parent) wxOVERRIDE;
|
||||
|
||||
virtual void EnsureVisible(const wxTreeItemId& item);
|
||||
virtual void ScrollTo(const wxTreeItemId& item);
|
||||
virtual void EnsureVisible(const wxTreeItemId& item) wxOVERRIDE;
|
||||
virtual void ScrollTo(const wxTreeItemId& item) wxOVERRIDE;
|
||||
|
||||
virtual wxTextCtrl *EditLabel(const wxTreeItemId& item, wxClassInfo* textCtrlClass = CLASSINFO(wxTextCtrl));
|
||||
virtual wxTextCtrl *GetEditControl() const;
|
||||
virtual void EndEditLabel(const wxTreeItemId& item, bool discardChanges = false);
|
||||
virtual wxTextCtrl *EditLabel(const wxTreeItemId& item, wxClassInfo* textCtrlClass = CLASSINFO(wxTextCtrl)) wxOVERRIDE;
|
||||
virtual wxTextCtrl *GetEditControl() const wxOVERRIDE;
|
||||
virtual void EndEditLabel(const wxTreeItemId& item, bool discardChanges = false) wxOVERRIDE;
|
||||
|
||||
virtual void SortChildren(const wxTreeItemId& item);
|
||||
virtual void SortChildren(const wxTreeItemId& item) wxOVERRIDE;
|
||||
|
||||
virtual bool GetBoundingRect(const wxTreeItemId& item, wxRect& rect, bool textOnly = false) const;
|
||||
virtual bool GetBoundingRect(const wxTreeItemId& item, wxRect& rect, bool textOnly = false) const wxOVERRIDE;
|
||||
|
||||
virtual void SetWindowStyleFlag(long styles) wxOVERRIDE;
|
||||
|
||||
virtual QWidget *GetHandle() const wxOVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual int DoGetItemState(const wxTreeItemId& item) const;
|
||||
virtual void DoSetItemState(const wxTreeItemId& item, int state);
|
||||
virtual int DoGetItemState(const wxTreeItemId& item) const wxOVERRIDE;
|
||||
virtual void DoSetItemState(const wxTreeItemId& item, int state) wxOVERRIDE;
|
||||
|
||||
virtual wxTreeItemId DoInsertItem(const wxTreeItemId& parent,
|
||||
size_t pos,
|
||||
const wxString& text,
|
||||
int image, int selImage,
|
||||
wxTreeItemData *data);
|
||||
wxTreeItemData *data) wxOVERRIDE;
|
||||
|
||||
virtual wxTreeItemId DoInsertAfter(const wxTreeItemId& parent,
|
||||
const wxTreeItemId& idPrevious,
|
||||
const wxString& text,
|
||||
int image = -1, int selImage = -1,
|
||||
wxTreeItemData *data = NULL);
|
||||
wxTreeItemData *data = NULL) wxOVERRIDE;
|
||||
|
||||
virtual wxTreeItemId DoTreeHitTest(const wxPoint& point, int& flags) const;
|
||||
virtual wxTreeItemId DoTreeHitTest(const wxPoint& point, int& flags) const wxOVERRIDE;
|
||||
|
||||
private:
|
||||
QTreeWidget *m_qtTreeWidget;
|
||||
void SendDeleteEvent(const wxTreeItemId &item);
|
||||
wxTreeItemId GetNext(const wxTreeItemId &item) const;
|
||||
|
||||
wxQTreeWidget *m_qtTreeWidget;
|
||||
wxDECLARE_DYNAMIC_CLASS(wxTreeCtrl);
|
||||
};
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
class WXDLLIMPEXP_FWD_CORE wxImageList;
|
||||
|
||||
#if !defined(__WXMSW__) || defined(__WXUNIVERSAL__)
|
||||
#if !defined(__WXMSW__) && !defined(__WXQT__) || defined(__WXUNIVERSAL__)
|
||||
#define wxHAS_GENERIC_TREECTRL
|
||||
#endif
|
||||
|
||||
@ -465,6 +465,8 @@ private:
|
||||
#include "wx/generic/treectlg.h"
|
||||
#elif defined(__WXMSW__)
|
||||
#include "wx/msw/treectrl.h"
|
||||
#elif defined(__WXQT__)
|
||||
#include "wx/qt/treectrl.h"
|
||||
#else
|
||||
#error "unknown native wxTreeCtrl implementation"
|
||||
#endif
|
||||
|
@ -1055,7 +1055,7 @@ void MyTreeCtrl::CreateStateImageList(bool del)
|
||||
AssignStateImageList(states);
|
||||
}
|
||||
|
||||
#if USE_GENERIC_TREECTRL || !defined(__WXMSW__)
|
||||
#if USE_GENERIC_TREECTRL || (!defined(__WXMSW__) && !defined(__WXQT__))
|
||||
void MyTreeCtrl::CreateButtonsImageList(int size)
|
||||
{
|
||||
if ( size == -1 )
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include <QtWidgets/QHeaderView>
|
||||
#include <QtWidgets/QTreeWidget>
|
||||
#include <QtWidgets/QItemDelegate>
|
||||
#include <QtWidgets/QItemEditorFactory>
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/bitmap.h"
|
||||
@ -23,110 +22,14 @@
|
||||
|
||||
#include "wx/listctrl.h"
|
||||
#include "wx/imaglist.h"
|
||||
#include "wx/recguard.h"
|
||||
|
||||
#include "wx/qt/private/winevent.h"
|
||||
#include "wx/qt/private/treeitemfactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
// wxQT Doesn't have a mechanism for "adopting" external widgets so we have to
|
||||
// create an instance of wxTextCtrl rather than adopting the control QT would
|
||||
// create.
|
||||
//
|
||||
// Unfortunately the factory is given an internal widget as the parent for
|
||||
// editor.
|
||||
//
|
||||
// To work around these issues we create a wxTextCtl parented by the wxListCtrl
|
||||
// then recalculate its position relative to the internal widget.
|
||||
class wxQtListTextCtrl : public wxTextCtrl
|
||||
class wxQtListTreeWidget : public wxQtEventSignalHandler< QTreeWidget, wxListCtrl >
|
||||
{
|
||||
public:
|
||||
wxQtListTextCtrl(wxWindow* parent, QWidget* actualParent)
|
||||
: wxTextCtrl(parent, wxID_ANY, wxEmptyString,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxNO_BORDER),
|
||||
m_actualParent(actualParent),
|
||||
m_moving(0)
|
||||
{
|
||||
|
||||
Bind(wxEVT_MOVE, &wxQtListTextCtrl::onMove, this);
|
||||
}
|
||||
|
||||
void onMove(wxMoveEvent &event)
|
||||
{
|
||||
// QWidget::move generates a QMoveEvent so we need to guard against
|
||||
// reentrant calls.
|
||||
wxRecursionGuard guard(m_moving);
|
||||
if ( guard.IsInside() )
|
||||
{
|
||||
event.Skip();
|
||||
return;
|
||||
}
|
||||
|
||||
const QPoint eventPosition = wxQtConvertPoint(event.GetPosition());
|
||||
const QPoint globalPosition = m_actualParent->mapToGlobal(eventPosition);
|
||||
|
||||
// For some reason this always gives us the offset from the header info
|
||||
// the internal control. So we need to treat this as an offset rather
|
||||
// than a position.
|
||||
QWidget* widget = GetHandle();
|
||||
const QPoint offset = widget->mapFromGlobal(globalPosition);
|
||||
|
||||
widget->move(eventPosition + offset);
|
||||
}
|
||||
|
||||
private:
|
||||
QWidget* m_actualParent;
|
||||
wxRecursionGuardFlag m_moving;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxQtListTextCtrl);
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
|
||||
// QT doesn't give us direct access to the editor within the QTreeWidget.
|
||||
// Instead, we'll supply a factory to create the widget for QT and keep track
|
||||
// of it ourselves.
|
||||
class wxQtItemEditorFactory : public QItemEditorFactory
|
||||
{
|
||||
public:
|
||||
explicit wxQtItemEditorFactory(wxWindow* parent)
|
||||
: m_parent(parent),
|
||||
m_textCtrl(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
QWidget* createEditor(int WXUNUSED(userType), QWidget* parent) const wxOVERRIDE
|
||||
{
|
||||
m_textCtrl = new wxQtListTextCtrl(m_parent, parent);
|
||||
m_textCtrl->SetFocus();
|
||||
return m_textCtrl->GetHandle();
|
||||
}
|
||||
|
||||
wxTextCtrl* GetEditControl()
|
||||
{
|
||||
return m_textCtrl;
|
||||
}
|
||||
|
||||
void ClearEditor()
|
||||
{
|
||||
delete m_textCtrl;
|
||||
m_textCtrl = NULL;
|
||||
}
|
||||
|
||||
private:
|
||||
wxWindow* m_parent;
|
||||
mutable wxTextCtrl* m_textCtrl;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxQtItemEditorFactory);
|
||||
};
|
||||
|
||||
class wxQtTreeWidget : public wxQtEventSignalHandler< QTreeWidget, wxListCtrl >
|
||||
{
|
||||
public:
|
||||
wxQtTreeWidget( wxWindow *parent, wxListCtrl *handler );
|
||||
wxQtListTreeWidget( wxWindow *parent, wxListCtrl *handler );
|
||||
|
||||
void EmitListEvent(wxEventType typ, QTreeWidgetItem *qitem, int column) const;
|
||||
|
||||
@ -153,21 +56,21 @@ private:
|
||||
qItemDelegate->setItemEditorFactory(&m_editorFactory);
|
||||
}
|
||||
|
||||
wxQtItemEditorFactory m_editorFactory;
|
||||
wxQtTreeItemEditorFactory m_editorFactory;
|
||||
};
|
||||
|
||||
wxQtTreeWidget::wxQtTreeWidget( wxWindow *parent, wxListCtrl *handler )
|
||||
wxQtListTreeWidget::wxQtListTreeWidget( wxWindow *parent, wxListCtrl *handler )
|
||||
: wxQtEventSignalHandler< QTreeWidget, wxListCtrl >( parent, handler ),
|
||||
m_editorFactory(handler)
|
||||
{
|
||||
connect(this, &QTreeWidget::itemClicked, this, &wxQtTreeWidget::itemClicked);
|
||||
connect(this, &QTreeWidget::itemPressed, this, &wxQtTreeWidget::itemPressed);
|
||||
connect(this, &QTreeWidget::itemActivated, this, &wxQtTreeWidget::itemActivated);
|
||||
connect(this, &QTreeWidget::itemClicked, this, &wxQtListTreeWidget::itemClicked);
|
||||
connect(this, &QTreeWidget::itemPressed, this, &wxQtListTreeWidget::itemPressed);
|
||||
connect(this, &QTreeWidget::itemActivated, this, &wxQtListTreeWidget::itemActivated);
|
||||
|
||||
ChangeEditorFactory();
|
||||
}
|
||||
|
||||
void wxQtTreeWidget::EmitListEvent(wxEventType typ, QTreeWidgetItem *qitem, int column) const
|
||||
void wxQtListTreeWidget::EmitListEvent(wxEventType typ, QTreeWidgetItem *qitem, int column) const
|
||||
{
|
||||
wxListCtrl *handler = GetHandler();
|
||||
if ( handler )
|
||||
@ -187,17 +90,17 @@ void wxQtTreeWidget::EmitListEvent(wxEventType typ, QTreeWidgetItem *qitem, int
|
||||
}
|
||||
}
|
||||
|
||||
void wxQtTreeWidget::itemClicked(QTreeWidgetItem *qitem, int column)
|
||||
void wxQtListTreeWidget::itemClicked(QTreeWidgetItem *qitem, int column)
|
||||
{
|
||||
EmitListEvent(wxEVT_LIST_ITEM_SELECTED, qitem, column);
|
||||
}
|
||||
|
||||
void wxQtTreeWidget::itemPressed(QTreeWidgetItem *qitem, int column)
|
||||
void wxQtListTreeWidget::itemPressed(QTreeWidgetItem *qitem, int column)
|
||||
{
|
||||
EmitListEvent(wxEVT_LIST_ITEM_SELECTED, qitem, column);
|
||||
}
|
||||
|
||||
void wxQtTreeWidget::itemActivated(QTreeWidgetItem *qitem, int column)
|
||||
void wxQtListTreeWidget::itemActivated(QTreeWidgetItem *qitem, int column)
|
||||
{
|
||||
EmitListEvent(wxEVT_LIST_ITEM_ACTIVATED, qitem, column);
|
||||
}
|
||||
@ -258,7 +161,7 @@ bool wxListCtrl::Create(wxWindow *parent,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
m_qtTreeWidget = new wxQtTreeWidget( parent, this );
|
||||
m_qtTreeWidget = new wxQtListTreeWidget( parent, this );
|
||||
|
||||
if (style & wxLC_NO_HEADER)
|
||||
m_qtTreeWidget->setHeaderHidden(true);
|
||||
|
1123
src/qt/treectrl.cpp
1123
src/qt/treectrl.cpp
File diff suppressed because it is too large
Load Diff
@ -70,6 +70,7 @@ private:
|
||||
CPPUNIT_TEST( SelectItemMulti );
|
||||
CPPUNIT_TEST( PseudoTest_SetHiddenRoot );
|
||||
CPPUNIT_TEST( HasChildren );
|
||||
CPPUNIT_TEST( GetCount );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void ItemClick();
|
||||
@ -94,6 +95,7 @@ private:
|
||||
void Sort();
|
||||
void KeyNavigation();
|
||||
void HasChildren();
|
||||
void GetCount();
|
||||
void SelectItemSingle();
|
||||
void SelectItemMulti();
|
||||
void PseudoTest_MultiSelect() { ms_multiSelect = true; }
|
||||
@ -175,6 +177,11 @@ void TreeCtrlTestCase::HasChildren()
|
||||
CPPUNIT_ASSERT( !m_tree->HasChildren(m_grandchild) );
|
||||
}
|
||||
|
||||
void TreeCtrlTestCase::GetCount()
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL(3, m_tree->GetCount());
|
||||
}
|
||||
|
||||
void TreeCtrlTestCase::SelectItemSingle()
|
||||
{
|
||||
// this test should be only ran in single-selection control
|
||||
@ -272,9 +279,10 @@ void TreeCtrlTestCase::DeleteItem()
|
||||
EventCounter deleteitem(m_tree, wxEVT_TREE_DELETE_ITEM);
|
||||
|
||||
wxTreeItemId todelete = m_tree->AppendItem(m_root, "deleteme");
|
||||
m_tree->AppendItem(todelete, "deleteme2");
|
||||
m_tree->Delete(todelete);
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(1, deleteitem.GetCount());
|
||||
CPPUNIT_ASSERT_EQUAL(2, deleteitem.GetCount());
|
||||
}
|
||||
|
||||
void TreeCtrlTestCase::DeleteChildren()
|
||||
|
Loading…
Reference in New Issue
Block a user