Git commit 5226e56f18df55a2a52d04c9b74b1cbc0f3a46a1 by Simon Edwards. Committed on 19/01/2014 at 15:41. Pushed by sedwards into branch 'master'. Added kitemviews. M +18 -4 CMakeLists.txt A +45 -0 sip/kitemviews/kcategorizedsortfilterproxymodel.sip A +65 -0 sip/kitemviews/kcategorizedview.sip A +43 -0 sip/kitemviews/kcategorydrawer.sip A +49 -0 sip/kitemviews/kextendableitemdelegate.sip A +32 -0 sip/kitemviews/kfilterproxysearchline.sip A +37 -0 sip/kitemviews/kitemviewsmod.sip A +38 -0 sip/kitemviews/klistwidgetsearchline.sip A +69 -0 sip/kitemviews/ktreewidgetsearchline.sip A +36 -0 sip/kitemviews/kwidgetitemdelegate.sip http://commits.kde.org/pykde5/5226e56f18df55a2a52d04c9b74b1cbc0f3a46a1 diff --git a/CMakeLists.txt b/CMakeLists.txt index a761b5e..bfe3aad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ find_package(ECM 0.0.9 REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cma= ke) = -find_package(Qt5 5.2.0 CONFIG REQUIRED Widgets DBus) +find_package(Qt5 5.2.0 CONFIG REQUIRED Core Widgets DBus Gui) include(KDEInstallDirs) include(KDEFrameworkCompilerSettings) include(KDECMakeSettings) @@ -20,7 +20,7 @@ include(PythonMacros) include(FeatureSummary) include(ECMSetupVersion) = -find_package(KF5 CONFIG REQUIRED Auth ItemModels) +find_package(KF5 CONFIG REQUIRED Auth ItemModels ItemViews) = #option(PYKDEUIC4_ALTINSTALL "Enable parallel-installation of the PyKDE4 t= ools" FALSE) = @@ -81,8 +81,16 @@ else (PYTHON_VERSION_MAJOR GREATER 2) endif() endif () = +get_property(qt5core_include TARGET Qt5::Core PROPERTY INTERFACE_INCLUDE_D= IRECTORIES) +get_property(qt5gui_include TARGET Qt5::Gui PROPERTY INTERFACE_INCLUDE_DIR= ECTORIES) +get_property(qt5widgets_include TARGET Qt5::Widgets PROPERTY INTERFACE_INC= LUDE_DIRECTORIES) + include_directories( - ${SIP_INCLUDE_DIR}) + ${SIP_INCLUDE_DIR} + ${qt5core_include} + ${qt5gui_include} + ${qt5widgets_include} +) = add_definitions(-D_REENTRANT -DSIP_PROTECTED_IS_PUBLIC -Dprotected=3Dpubli= c) = @@ -100,7 +108,13 @@ file(GLOB kitemmodels_files_sip sip/kitemmodels/*.sip) set(SIP_EXTRA_FILES_DEPEND ${kitemmodels_files_sip}) add_sip_python_module(PyKDE5.kitemmodels sip/kitemmodels/kitemmodelsmod.si= p KF5::ItemModels) = -set(PYKDE_MODULES "kauth") +# kitemviews +file(GLOB kitemviews_files_sip sip/kitemviews/*.sip) +set(SIP_EXTRA_FILES_DEPEND ${kitemviews_files_sip}) +add_sip_python_module(PyKDE5.kitemviews sip/kitemviews/kitemviewsmod.sip K= F5::ItemViews) + +set(PYKDE_MODULES "kitemmodels kitemviews") + ##########################################################################= ##### = python_install(__init__.py ${PYTHON_SITE_PACKAGES_INSTALL_DIR}/PyKDE5) diff --git a/sip/kitemviews/kcategorizedsortfilterproxymodel.sip b/sip/kite= mviews/kcategorizedsortfilterproxymodel.sip new file mode 100644 index 0000000..b47c0ae --- /dev/null +++ b/sip/kitemviews/kcategorizedsortfilterproxymodel.sip @@ -0,0 +1,45 @@ +// Copyright 2014 Simon Edwards + +// Generated by twine2 + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License as +// published by the Free Software Foundation; either version 2, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details + +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class KCategorizedSortFilterProxyModel : QSortFilterProxyModel +{ +%TypeHeaderCode +#include +%End + +public: + enum AdditionalRoles + { + CategoryDisplayRole, + CategorySortRole + }; + KCategorizedSortFilterProxyModel (QObject* par= ent =3D 0); + virtual ~KCategorizedSortFilterProxyModel (); + virtual void sort (int column, Qt::SortOrder order =3D Qt::= AscendingOrder); + bool isCategorizedModel () const; + void setCategorizedModel (bool categorizedModel); + int sortColumn () const; + Qt::SortOrder sortOrder () const; + void setSortCategoriesByNaturalComparison (bool sor= tCategoriesByNaturalComparison); + bool sortCategoriesByNaturalComparison () const; +protected: + virtual bool lessThan (const QModelIndex& left, const QMode= lIndex& right) const; + virtual bool subSortLessThan (const QModelIndex& left, cons= t QModelIndex& right) const; + virtual int compareCategories (const QModelIndex& left, co= nst QModelIndex& right) const; +}; diff --git a/sip/kitemviews/kcategorizedview.sip b/sip/kitemviews/kcategori= zedview.sip new file mode 100644 index 0000000..9c08eae --- /dev/null +++ b/sip/kitemviews/kcategorizedview.sip @@ -0,0 +1,65 @@ +// Copyright 2014 Simon Edwards + +// Generated by twine2 + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License as +// published by the Free Software Foundation; either version 2, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details + +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class KCategorizedView : QListView +{ +%TypeHeaderCode +#include +%End + +public: + KCategorizedView (QWidget* parent =3D 0); + ~KCategorizedView (); + virtual void setModel (QAbstractItemModel* model); + void setGridSize (const QSize& size); + void setGridSizeOwn (const QSize& size); + virtual QRect visualRect (const QModelIndex& index) const; + KCategoryDrawer* categoryDrawer () const; + void setCategoryDrawer (KCategoryDrawer* categoryDr= awer); + int categorySpacing () const; + void setCategorySpacing (int categorySpacing); + bool alternatingBlockColors () const; + void setAlternatingBlockColors (bool enable); + bool collapsibleBlocks () const; + void setCollapsibleBlocks (bool enable); + QModelIndexList block (const QString& category); + QModelIndexList block (const QModelIndex& representative); + virtual QModelIndex indexAt (const QPoint& point) const; + virtual void reset (); +protected: + virtual void paintEvent (QPaintEvent* event); + virtual void resizeEvent (QResizeEvent* event); + virtual void setSelection (const QRect& rect, QItemSelectio= nModel::SelectionFlags flags); + virtual void mouseMoveEvent (QMouseEvent* event); + virtual void mousePressEvent (QMouseEvent* event); + virtual void mouseReleaseEvent (QMouseEvent* event); + virtual void leaveEvent (QEvent* event); + virtual void startDrag (Qt::DropActions supportedActions); + virtual void dragMoveEvent (QDragMoveEvent* event); + virtual void dragEnterEvent (QDragEnterEvent* event); + virtual void dragLeaveEvent (QDragLeaveEvent* event); + virtual void dropEvent (QDropEvent* event); + virtual QModelIndex moveCursor (QAbstractItemView::CursorAction cu= rsorAction, Qt::KeyboardModifiers modifiers); + virtual void rowsAboutToBeRemoved (const QModelIndex& paren= t, int start, int end); + virtual void updateGeometries (); + virtual void currentChanged (const QModelIndex& current, co= nst QModelIndex& previous); + virtual void dataChanged (const QModelIndex& topLeft, const= QModelIndex& bottomRight, const QVector& roles =3D QVector()); + virtual void rowsInserted (const QModelIndex& parent, int s= tart, int end); + virtual void slotLayoutChanged (); +}; diff --git a/sip/kitemviews/kcategorydrawer.sip b/sip/kitemviews/kcategoryd= rawer.sip new file mode 100644 index 0000000..257b145 --- /dev/null +++ b/sip/kitemviews/kcategorydrawer.sip @@ -0,0 +1,43 @@ +// Copyright 2014 Simon Edwards + +// Generated by twine2 + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License as +// published by the Free Software Foundation; either version 2, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details + +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class KCategoryDrawer : QObject +{ +%TypeHeaderCode +#include +%End + +public: + KCategoryDrawer (KCategorizedView* view); + virtual ~KCategoryDrawer (); + KCategorizedView* view () const; + virtual void drawCategory (const QModelIndex& index, int so= rtRole, const QStyleOption& option, QPainter* painter) const; + virtual int categoryHeight (const QModelIndex& index, cons= t QStyleOption& option) const; + virtual int leftMargin () const; + virtual int rightMargin () const; +signals: + void collapseOrExpandClicked (const QModelIndex& in= dex); + void actionRequested (int action, const QModelIndex= & index); +protected: + virtual void mouseButtonPressed (const QModelIndex& index, = const QRect& blockRect, QMouseEvent* event); + virtual void mouseButtonReleased (const QModelIndex& index,= const QRect& blockRect, QMouseEvent* event); + virtual void mouseMoved (const QModelIndex& index, const QR= ect& blockRect, QMouseEvent* event); + virtual void mouseButtonDoubleClicked (const QModelIndex& i= ndex, const QRect& blockRect, QMouseEvent* event); + virtual void mouseLeft (const QModelIndex& index, const QRe= ct& blockRect); +}; diff --git a/sip/kitemviews/kextendableitemdelegate.sip b/sip/kitemviews/ke= xtendableitemdelegate.sip new file mode 100644 index 0000000..26cf80d --- /dev/null +++ b/sip/kitemviews/kextendableitemdelegate.sip @@ -0,0 +1,49 @@ +// Copyright 2014 Simon Edwards + +// Generated by twine2 + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License as +// published by the Free Software Foundation; either version 2, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details + +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class KExtendableItemDelegate : QStyledItemDelegate +{ +%TypeHeaderCode +#include +%End + +public: + enum auxDataRoles + { + ShowExtensionIndicatorRole + }; + KExtendableItemDelegate (QAbstractItemView* pa= rent); + virtual ~KExtendableItemDelegate (); + virtual QSize sizeHint (const QStyleOptionViewItem& option, = const QModelIndex& index) const; + virtual void paint (QPainter* painter, const QStyleOptionVi= ewItem& option, const QModelIndex& index) const; + void extendItem (QWidget* extender, const QModelInd= ex& index); + void contractItem (const QModelIndex& index); + void contractAll (); + bool isExtended (const QModelIndex& index) const; + virtual void updateExtenderGeometry (QWidget* extender, con= st QStyleOptionViewItem& option, const QModelIndex& index) const; +signals: + void extenderCreated (QWidget* extender, const QMod= elIndex& index); + void extenderDestroyed (QWidget* extender, const QM= odelIndex& index); +protected: + QRect extenderRect (QWidget* extender, const QStyleO= ptionViewItem& option, const QModelIndex& index) const; + void setExtendPixmap (const QPixmap& pixmap); + void setContractPixmap (const QPixmap& pixmap); + QPixmap extendPixmap (); + QPixmap contractPixmap (); +}; diff --git a/sip/kitemviews/kfilterproxysearchline.sip b/sip/kitemviews/kfi= lterproxysearchline.sip new file mode 100644 index 0000000..bbbe378 --- /dev/null +++ b/sip/kitemviews/kfilterproxysearchline.sip @@ -0,0 +1,32 @@ +// Copyright 2014 Simon Edwards + +// Generated by twine2 + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License as +// published by the Free Software Foundation; either version 2, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details + +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class KFilterProxySearchLine : QWidget +{ +%TypeHeaderCode +#include +%End + +public: + explicit KFilterProxySearchLine (QWidget* parent =3D 0); + ~KFilterProxySearchLine (); + void setProxy (QSortFilterProxyModel* proxy); + void setText (const QString& text); + QLineEdit* lineEdit () const; +}; diff --git a/sip/kitemviews/kitemviewsmod.sip b/sip/kitemviews/kitemviewsmo= d.sip new file mode 100644 index 0000000..e668065 --- /dev/null +++ b/sip/kitemviews/kitemviewsmod.sip @@ -0,0 +1,37 @@ +// Copyright 2014 Simon Edwards + +// Generated by twine2 + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License as +// published by the Free Software Foundation; either version 2, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details + +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +%Module PyKDE5.kitemviews + +%ModuleHeaderCode +#pragma GCC visibility push(default) +%End + +%Import QtCore/QtCoremod.sip +%Import QtGui/QtGuimod.sip +%Import QtWidgets/QtWidgetsmod.sip + +%Include kcategorizedsortfilterproxymodel.sip +%Include kcategorizedview.sip +%Include kcategorydrawer.sip +%Include kextendableitemdelegate.sip +%Include kfilterproxysearchline.sip +%Include klistwidgetsearchline.sip +%Include ktreewidgetsearchline.sip +%Include kwidgetitemdelegate.sip diff --git a/sip/kitemviews/klistwidgetsearchline.sip b/sip/kitemviews/klis= twidgetsearchline.sip new file mode 100644 index 0000000..d6e07fa --- /dev/null +++ b/sip/kitemviews/klistwidgetsearchline.sip @@ -0,0 +1,38 @@ +// Copyright 2014 Simon Edwards + +// Generated by twine2 + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License as +// published by the Free Software Foundation; either version 2, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details + +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class KListWidgetSearchLine : QLineEdit +{ +%TypeHeaderCode +#include +%End + +public: + explicit KListWidgetSearchLine (QWidget* parent =3D 0, = QListWidget* listWidget =3D 0); + virtual ~KListWidgetSearchLine (); + Qt::CaseSensitivity caseSensitive () const; + QListWidget* listWidget () const; + virtual void updateSearch (const QString& s =3D QString()); + void setCaseSensitivity (Qt::CaseSensitivity cs); + void setListWidget (QListWidget* lv); + void clear (); +protected: + virtual bool itemMatches (const QListWidgetItem* item, cons= t QString& s) const; + virtual bool event (QEvent* event); +}; diff --git a/sip/kitemviews/ktreewidgetsearchline.sip b/sip/kitemviews/ktre= ewidgetsearchline.sip new file mode 100644 index 0000000..86f41be --- /dev/null +++ b/sip/kitemviews/ktreewidgetsearchline.sip @@ -0,0 +1,69 @@ +// Copyright 2014 Simon Edwards + +// Generated by twine2 + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License as +// published by the Free Software Foundation; either version 2, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details + +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class KTreeWidgetSearchLine : QLineEdit +{ +%TypeHeaderCode +#include +%End + +public: + explicit KTreeWidgetSearchLine (QWidget* parent =3D 0, = QTreeWidget* treeWidget =3D 0); + KTreeWidgetSearchLine (QWidget* parent, const = QList& treeWidgets); + virtual ~KTreeWidgetSearchLine (); + Qt::CaseSensitivity caseSensitivity () const; + QList searchColumns () const; + bool keepParentsVisible () const; + QTreeWidget* treeWidget () const; + QList treeWidgets () const; +signals: + void hiddenChanged (QTreeWidgetItem*, bool); + void searchUpdated (const QString& searchString); +public: + void addTreeWidget (QTreeWidget* treeWidget); + void removeTreeWidget (QTreeWidget* treeWidget); + virtual void updateSearch (const QString& pattern =3D QStri= ng()); + void setCaseSensitivity (Qt::CaseSensitivity caseSe= nsitivity); + void setKeepParentsVisible (bool value); + void setSearchColumns (const QList& columns); + void setTreeWidget (QTreeWidget* treeWidget); + void setTreeWidgets (const QList& tre= eWidgets); +protected: + virtual bool itemMatches (const QTreeWidgetItem* item, cons= t QString& pattern) const; + virtual void contextMenuEvent (QContextMenuEvent*); + virtual void updateSearch (QTreeWidget* treeWidget); + virtual void connectTreeWidget (QTreeWidget*); + virtual void disconnectTreeWidget (QTreeWidget*); + virtual bool canChooseColumnsCheck (); + virtual bool event (QEvent* event); +}; +class KTreeWidgetSearchLineWidget : QWidget +{ +%TypeHeaderCode +#include +%End + +public: + explicit KTreeWidgetSearchLineWidget (QWidget* parent = =3D 0, QTreeWidget* treeWidget =3D 0); + ~KTreeWidgetSearchLineWidget (); + KTreeWidgetSearchLine* searchLine () const; +protected: + virtual void createWidgets (); + virtual KTreeWidgetSearchLine* createSearchLine (QTreeWidget* treeWid= get) const; +}; diff --git a/sip/kitemviews/kwidgetitemdelegate.sip b/sip/kitemviews/kwidge= titemdelegate.sip new file mode 100644 index 0000000..a8ddb37 --- /dev/null +++ b/sip/kitemviews/kwidgetitemdelegate.sip @@ -0,0 +1,36 @@ +// Copyright 2014 Simon Edwards + +// Generated by twine2 + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License as +// published by the Free Software Foundation; either version 2, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details + +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class KWidgetItemDelegate : QAbstractItemDelegate +{ +%TypeHeaderCode +#include +%End + +public: + explicit KWidgetItemDelegate (QAbstractItemView* itemVi= ew, QObject* parent =3D 0); + virtual ~KWidgetItemDelegate (); + QAbstractItemView* itemView () const; + QPersistentModelIndex focusedIndex () const; +protected: + virtual QList createItemWidgets (const QModelIndex& index) = const=3D0; + virtual void updateItemWidgets (const QList widge= ts, const QStyleOptionViewItem& option, const QPersistentModelIndex& index)= const=3D0; + void setBlockedEventTypes (QWidget* widget, QList types) const; + QList blockedEventTypes (QWidget* widget) const; +};