Git commit 8bf0ad729d458c69612086ab01c8babcd108d882 by Simon Edwards. Committed on 18/01/2014 at 15:08. Pushed by sedwards into branch 'master'. Added kitemmodels. M +12 -6 CMakeLists.txt A +41 -0 sip/kitemmodels/kbreadcrumbselectionmodel.sip A +37 -0 sip/kitemmodels/kcheckableproxymodel.sip A +49 -0 sip/kitemmodels/kdescendantsproxymodel.sip A +34 -0 sip/kitemmodels/kitemmodelsmod.sip A +31 -0 sip/kitemmodels/klinkitemselectionmodel.sip A +33 -0 sip/kitemmodels/kmodelindexproxymapper.sip A +34 -0 sip/kitemmodels/krecursivefilterproxymodel.sip A +60 -0 sip/kitemmodels/kselectionproxymodel.sip http://commits.kde.org/pykde5/8bf0ad729d458c69612086ab01c8babcd108d882 diff --git a/CMakeLists.txt b/CMakeLists.txt index abb7782..a761b5e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ include(PythonMacros) include(FeatureSummary) include(ECMSetupVersion) = -find_package(KF5 CONFIG REQUIRED Auth) +find_package(KF5 CONFIG REQUIRED Auth ItemModels) = #option(PYKDEUIC4_ALTINSTALL "Enable parallel-installation of the PyKDE4 t= ools" FALSE) = @@ -35,8 +35,6 @@ set_package_properties(PythonInterp PROPERTIES URL "http://www.python.org" TYPE REQUIRED PURPOSE "Required to build PyKDE4") = -#include_directories(${KDE4_INCLUDES}) - find_package(SIP) set_package_properties(SIP PROPERTIES DESCRIPTION "The SIP binding generat= or" URL "http://riverbankcomputing.com" TYPE REQUIRED @@ -83,6 +81,9 @@ else (PYTHON_VERSION_MAJOR GREATER 2) endif() endif () = +include_directories( + ${SIP_INCLUDE_DIR}) + add_definitions(-D_REENTRANT -DSIP_PROTECTED_IS_PUBLIC -Dprotected=3Dpubli= c) = ##########################################################################= ##### @@ -90,9 +91,14 @@ add_definitions(-D_REENTRANT -DSIP_PROTECTED_IS_PUBLIC -= Dprotected=3Dpublic) ##########################################################################= ##### = # kauth -file(GLOB kauth_files_sip sip/kauth/*.sip) -set(SIP_EXTRA_FILES_DEPEND ${kauth_files_sip}) -add_sip_python_module(PyKDE5.kauth sip/kauth/kauthmod.sip KF5::Auth) +#file(GLOB kauth_files_sip sip/kauth/*.sip) +#set(SIP_EXTRA_FILES_DEPEND ${kauth_files_sip}) +#add_sip_python_module(PyKDE5.kauth sip/kauth/kauthmod.sip KF5::Auth) + +# kitemmodels +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") ##########################################################################= ##### diff --git a/sip/kitemmodels/kbreadcrumbselectionmodel.sip b/sip/kitemmodel= s/kbreadcrumbselectionmodel.sip new file mode 100644 index 0000000..e0ab18c --- /dev/null +++ b/sip/kitemmodels/kbreadcrumbselectionmodel.sip @@ -0,0 +1,41 @@ +// 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 KBreadcrumbSelectionModel : QItemSelectionModel +{ +%TypeHeaderCode +#include +%End + +public: + enum BreadcrumbTarget + { + MakeBreadcrumbSelectionInOther, + MakeBreadcrumbSelectionInSelf + }; + explicit KBreadcrumbSelectionModel (QItemSelectionModel= * selectionModel, QObject* parent =3D 0); + KBreadcrumbSelectionModel (QItemSelectionModel= * selectionModel, KBreadcrumbSelectionModel::BreadcrumbTarget target, QObje= ct* parent =3D 0); + virtual ~KBreadcrumbSelectionModel (); + bool isActualSelectionIncluded () const; + void setActualSelectionIncluded (bool isActualSelec= tionIncluded); + int breadcrumbLength () const; + void setBreadcrumbLength (int breadcrumbLength); + void select (const QModelIndex& index, QItemSelecti= onModel::SelectionFlags command); + void select (const QItemSelection& selection, QItem= SelectionModel::SelectionFlags command); +}; diff --git a/sip/kitemmodels/kcheckableproxymodel.sip b/sip/kitemmodels/kch= eckableproxymodel.sip new file mode 100644 index 0000000..c4d3e04 --- /dev/null +++ b/sip/kitemmodels/kcheckableproxymodel.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. + +class KCheckableProxyModel : QIdentityProxyModel +{ +%TypeHeaderCode +#include +%End + +public: + KCheckableProxyModel (QObject* parent =3D 0); + ~KCheckableProxyModel (); + void setSelectionModel (QItemSelectionModel* itemSe= lectionModel); + QItemSelectionModel* selectionModel () const; + Qt::ItemFlags flags (const QModelIndex& index) const; + QVariant data (const QModelIndex& index, int role =3D Q= t::DisplayRole) const; + bool setData (const QModelIndex& index, const QVari= ant& value, int role =3D Qt::EditRole); + void setSourceModel (QAbstractItemModel* sourceMode= l); +protected: + virtual bool select (const QItemSelection& selection, QItem= SelectionModel::SelectionFlags command); +}; diff --git a/sip/kitemmodels/kdescendantsproxymodel.sip b/sip/kitemmodels/k= descendantsproxymodel.sip new file mode 100644 index 0000000..1cd1320 --- /dev/null +++ b/sip/kitemmodels/kdescendantsproxymodel.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 KDescendantsProxyModel : QAbstractProxyModel +{ +%TypeHeaderCode +#include +%End + +public: + explicit KDescendantsProxyModel (QObject* parent =3D 0); + virtual ~KDescendantsProxyModel (); + virtual void setSourceModel (QAbstractItemModel* model); + void setRootIndex (const QModelIndex& index); + void setDisplayAncestorData (bool display); + bool displayAncestorData () const; + void setAncestorSeparator (const QString& separator= ); + QString ancestorSeparator () const; + QModelIndex mapFromSource (const QModelIndex& sourceIndex)= const; + QModelIndex mapToSource (const QModelIndex& proxyIndex) co= nst; + virtual Qt::ItemFlags flags (const QModelIndex& index) const; + QVariant data (const QModelIndex& index, int role =3D Q= t::DisplayRole) const; + virtual int rowCount (const QModelIndex& parent =3D QModel= Index()) const; + virtual QVariant headerData (int section, Qt::Orientation orien= tation, int role) const; + virtual QMimeData* mimeData (const QModelIndexList& indexes) cons= t; + virtual QStringList mimeTypes () const; + virtual bool hasChildren (const QModelIndex& parent =3D QMo= delIndex()) const; + virtual QModelIndex index (int, int, const QModelIndex& parent =3D= QModelIndex()) const; + virtual QModelIndex parent (const QModelIndex&) const; + virtual int columnCount (const QModelIndex& index =3D QMod= elIndex()) const; + virtual Qt::DropActions supportedDropActions () const; + virtual QModelIndexList match (const QModelIndex& start, int role, co= nst QVariant& value, int hits =3D 1, Qt::MatchFlags flags =3D Qt::MatchFlag= s(Qt::MatchStartsWith|Qt::MatchWrap)) const; +}; diff --git a/sip/kitemmodels/kitemmodelsmod.sip b/sip/kitemmodels/kitemmode= lsmod.sip new file mode 100644 index 0000000..8de4d5c --- /dev/null +++ b/sip/kitemmodels/kitemmodelsmod.sip @@ -0,0 +1,34 @@ +// 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.kitemmodels + +%ModuleHeaderCode +#pragma GCC visibility push(default) +%End + +%Import QtCore/QtCoremod.sip + +%Include kbreadcrumbselectionmodel.sip +%Include kcheckableproxymodel.sip +%Include kdescendantsproxymodel.sip +%Include klinkitemselectionmodel.sip +%Include kmodelindexproxymapper.sip +%Include krecursivefilterproxymodel.sip +%Include kselectionproxymodel.sip diff --git a/sip/kitemmodels/klinkitemselectionmodel.sip b/sip/kitemmodels/= klinkitemselectionmodel.sip new file mode 100644 index 0000000..dd4c763 --- /dev/null +++ b/sip/kitemmodels/klinkitemselectionmodel.sip @@ -0,0 +1,31 @@ +// 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 KLinkItemSelectionModel : QItemSelectionModel +{ +%TypeHeaderCode +#include +%End + +public: + KLinkItemSelectionModel (QAbstractItemModel* t= argetModel, QItemSelectionModel* linkedItemSelectionModel, QObject* parent = =3D 0); + ~KLinkItemSelectionModel (); + void select (const QModelIndex& index, QItemSelecti= onModel::SelectionFlags command); + void select (const QItemSelection& selection, QItem= SelectionModel::SelectionFlags command); +}; diff --git a/sip/kitemmodels/kmodelindexproxymapper.sip b/sip/kitemmodels/k= modelindexproxymapper.sip new file mode 100644 index 0000000..d871c3d --- /dev/null +++ b/sip/kitemmodels/kmodelindexproxymapper.sip @@ -0,0 +1,33 @@ +// 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 KModelIndexProxyMapper : QObject +{ +%TypeHeaderCode +#include +%End + +public: + KModelIndexProxyMapper (const QAbstractItemMod= el* leftModel, const QAbstractItemModel* rightModel, QObject* parent =3D 0); + ~KModelIndexProxyMapper (); + QModelIndex mapLeftToRight (const QModelIndex& index) cons= t; + QModelIndex mapRightToLeft (const QModelIndex& index) cons= t; + QItemSelection mapSelectionLeftToRight (const QItemSelection&= selection) const; + QItemSelection mapSelectionRightToLeft (const QItemSelection&= selection) const; +}; diff --git a/sip/kitemmodels/krecursivefilterproxymodel.sip b/sip/kitemmode= ls/krecursivefilterproxymodel.sip new file mode 100644 index 0000000..584edd1 --- /dev/null +++ b/sip/kitemmodels/krecursivefilterproxymodel.sip @@ -0,0 +1,34 @@ +// 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 KRecursiveFilterProxyModel : QSortFilterProxyModel +{ +%TypeHeaderCode +#include +%End + +public: + explicit KRecursiveFilterProxyModel (QObject* parent = =3D 0); + virtual ~KRecursiveFilterProxyModel (); + void setSourceModel (QAbstractItemModel* model); + virtual QModelIndexList match (const QModelIndex& start, int role, co= nst QVariant& value, int hits =3D 1, Qt::MatchFlags flags =3D Qt::MatchFlag= s(Qt::MatchStartsWith|Qt::MatchWrap)) const; +protected: + virtual bool acceptRow (int sourceRow, const QModelIndex& s= ourceParent) const; + virtual bool filterAcceptsRow (int sourceRow, const QModelI= ndex& sourceParent) const; +}; diff --git a/sip/kitemmodels/kselectionproxymodel.sip b/sip/kitemmodels/kse= lectionproxymodel.sip new file mode 100644 index 0000000..a0daf4d --- /dev/null +++ b/sip/kitemmodels/kselectionproxymodel.sip @@ -0,0 +1,60 @@ +// 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 KSelectionProxyModel : QAbstractProxyModel +{ +%TypeHeaderCode +#include +%End + +public: + explicit KSelectionProxyModel (QItemSelectionModel* sel= ectionModel, QObject* parent =3D 0); + virtual ~KSelectionProxyModel (); + virtual void setSourceModel (QAbstractItemModel* sourceMode= l); + QItemSelectionModel* selectionModel () const; + enum FilterBehavior + { + SubTrees, + SubTreeRoots, + SubTreesWithoutRoots, + ExactSelection, + ChildrenOfExactSelection + }; + void setFilterBehavior (KSelectionProxyModel::Filte= rBehavior behavior); + KSelectionProxyModel::FilterBehavior filterBehavior () const; + QModelIndex mapFromSource (const QModelIndex& sourceIndex)= const; + QModelIndex mapToSource (const QModelIndex& proxyIndex) co= nst; + QItemSelection mapSelectionFromSource (const QItemSelection& = selection) const; + QItemSelection mapSelectionToSource (const QItemSelection& se= lection) const; + virtual Qt::ItemFlags flags (const QModelIndex& index) const; + QVariant data (const QModelIndex& index, int role =3D Q= t::DisplayRole) const; + virtual int rowCount (const QModelIndex& parent =3D QModel= Index()) const; + virtual QVariant headerData (int section, Qt::Orientation orien= tation, int role =3D Qt::DisplayRole) const; + virtual QMimeData* mimeData (const QModelIndexList& indexes) cons= t; + virtual QStringList mimeTypes () const; + virtual Qt::DropActions supportedDropActions () const; + virtual bool dropMimeData (const QMimeData* data, Qt::DropA= ction action, int row, int column, const QModelIndex& parent); + virtual bool hasChildren (const QModelIndex& parent =3D QMo= delIndex()) const; + virtual QModelIndex index (int, int, const QModelIndex& =3D QModel= Index()) const; + virtual QModelIndex parent (const QModelIndex&) const; + virtual int columnCount (const QModelIndex& =3D QModelInde= x()) const; + virtual QModelIndexList match (const QModelIndex& start, int role, co= nst QVariant& value, int hits =3D 1, Qt::MatchFlags flags =3D Qt::MatchFlag= s(Qt::MatchStartsWith|Qt::MatchWrap)) const; +protected: + QList sourceRootIndexes () const; +};