Merge branch 'qt-listctrl'

New version of wxListCtrl for wxQt, supporting virtual list controls,
checkboxes, sorting and with other fixes.

See https://github.com/wxWidgets/wxWidgets/pull/1551
This commit is contained in:
Vadim Zeitlin
2019-09-27 19:16:56 +02:00
4 changed files with 1311 additions and 386 deletions

View File

@@ -11,7 +11,8 @@
#include "wx/textctrl.h" #include "wx/textctrl.h"
class wxQtListTreeWidget; class wxQtListTreeWidget;
class QTreeWidgetItem; class wxQtListModel;
class wxQtVirtualListModel;
class WXDLLIMPEXP_FWD_CORE wxImageList; class WXDLLIMPEXP_FWD_CORE wxImageList;
@@ -159,6 +160,11 @@ public:
// list or report view // list or report view
long GetTopItem() const; long GetTopItem() const;
virtual bool HasCheckBoxes() const wxOVERRIDE;
virtual bool EnableCheckBoxes(bool enable = true) wxOVERRIDE;
virtual bool IsItemChecked(long item) const wxOVERRIDE;
virtual void CheckItem(long item, bool check) wxOVERRIDE;
// Add or remove a single window style // Add or remove a single window style
void SetSingleStyle(long style, bool add = true); void SetSingleStyle(long style, bool add = true);
@@ -273,16 +279,21 @@ protected:
// Implement base class pure virtual methods. // Implement base class pure virtual methods.
virtual long DoInsertColumn(long col, const wxListItem& info) wxOVERRIDE; virtual long DoInsertColumn(long col, const wxListItem& info) wxOVERRIDE;
QTreeWidgetItem *QtGetItem(int id) const;
wxImageList * m_imageListNormal; // The image list for normal icons wxImageList * m_imageListNormal; // The image list for normal icons
wxImageList * m_imageListSmall; // The image list for small icons wxImageList * m_imageListSmall; // The image list for small icons
wxImageList * m_imageListState; // The image list state icons (not implemented yet) wxImageList * m_imageListState; // The image list state icons (not implemented yet)
bool m_ownsImageListNormal, bool m_ownsImageListNormal,
m_ownsImageListSmall, m_ownsImageListSmall,
m_ownsImageListState; m_ownsImageListState;
bool m_hasCheckBoxes;
private: private:
// Allow access to OnGetItemXXX() method from the virtual model class.
friend class wxQtVirtualListModel;
wxQtListTreeWidget *m_qtTreeWidget; wxQtListTreeWidget *m_qtTreeWidget;
wxQtListModel *m_model;
wxDECLARE_DYNAMIC_CLASS( wxListCtrl ); wxDECLARE_DYNAMIC_CLASS( wxListCtrl );
}; };

View File

@@ -1543,7 +1543,8 @@ void MyListCtrl::OnContextMenu(wxContextMenuEvent& event)
{ {
point = ScreenToClient(point); point = ScreenToClient(point);
} }
ShowContextMenu(point); int flags;
ShowContextMenu(point, HitTest(point, flags));
} }
else else
{ {
@@ -1555,10 +1556,10 @@ void MyListCtrl::OnContextMenu(wxContextMenuEvent& event)
} }
#endif #endif
void MyListCtrl::ShowContextMenu(const wxPoint& pos) void MyListCtrl::ShowContextMenu(const wxPoint& pos, long item)
{ {
wxMenu menu; wxMenu menu;
menu.Append(wxID_ANY, wxString::Format("Menu for item %ld", item));
menu.Append(wxID_ABOUT, "&About"); menu.Append(wxID_ABOUT, "&About");
menu.AppendSeparator(); menu.AppendSeparator();
menu.Append(wxID_EXIT, "E&xit"); menu.Append(wxID_EXIT, "E&xit");

View File

@@ -78,7 +78,7 @@ public:
virtual bool IsItemChecked(long item) const wxOVERRIDE; virtual bool IsItemChecked(long item) const wxOVERRIDE;
private: private:
void ShowContextMenu(const wxPoint& pos); void ShowContextMenu(const wxPoint& pos, long item);
wxLog *m_logOld; wxLog *m_logOld;
void SetColumnImage(int col, int image); void SetColumnImage(int col, int image);

File diff suppressed because it is too large Load Diff