Update KDescendantsProxyModel code from KF5 kitemmodels, tag v5.24.0-rc3

parent 05250753
This diff is collapsed.
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
02110-1301, USA. 02110-1301, USA.
*/ */
#ifndef KDESCENDANTSPROXYMODEL_P_H #ifndef KDESCENDANTSPROXYMODEL_P_H
#define KDESCENDANTSPROXYMODEL_P_H #define KDESCENDANTSPROXYMODEL_P_H
...@@ -51,11 +50,12 @@ KDescendantEntitiesProxyModel can also display the ancestors of the index in the ...@@ -51,11 +50,12 @@ KDescendantEntitiesProxyModel can also display the ancestors of the index in the
@code @code
// ... Create an entityTreeModel // ... Create an entityTreeModel
KDescendantsProxyModel *descProxy = new KDescendantesProxyModel(this); KDescendantsProxyModel *descProxy = new KDescendantsProxyModel(this);
descProxy->setSourceModel(entityTree); descProxy->setSourceModel(entityTree);
// #### This is new // #### This is new
descProxy->setDisplayAncestorData(true, QString( " / " )); descProxy->setDisplayAncestorData(true);
descProxy->setDisplayAncestorSeparator(QString(" / "));
view->setModel(descProxy); view->setModel(descProxy);
...@@ -68,16 +68,16 @@ view->setModel(descProxy); ...@@ -68,16 +68,16 @@ view->setModel(descProxy);
*/ */
class MARBLE_EXPORT KDescendantsProxyModel : public QAbstractProxyModel class MARBLE_EXPORT KDescendantsProxyModel : public QAbstractProxyModel
{ {
Q_OBJECT Q_OBJECT
public: public:
/** /**
* Creates a new descendant entities proxy model. * Creates a new descendant entities proxy model.
* *
* @param parent The parent object. * @param parent The parent object.
*/ */
explicit KDescendantsProxyModel( QObject *parent = 0 ); explicit KDescendantsProxyModel(QObject *parent = 0);
/** /**
* Destroys the descendant entities proxy model. * Destroys the descendant entities proxy model.
...@@ -87,7 +87,16 @@ class MARBLE_EXPORT KDescendantsProxyModel : public QAbstractProxyModel ...@@ -87,7 +87,16 @@ class MARBLE_EXPORT KDescendantsProxyModel : public QAbstractProxyModel
/** /**
* Sets the source @p model of the proxy. * Sets the source @p model of the proxy.
*/ */
virtual void setSourceModel( QAbstractItemModel *model ); void setSourceModel(QAbstractItemModel *model) Q_DECL_OVERRIDE;
#if 0
/**
* @deprecated
*
* This method does nothing.
*/
void setRootIndex(const QModelIndex &index);
#endif
/** /**
* Set whether to show ancestor data in the model. If @p display is true, then * Set whether to show ancestor data in the model. If @p display is true, then
...@@ -126,7 +135,7 @@ class MARBLE_EXPORT KDescendantsProxyModel : public QAbstractProxyModel ...@@ -126,7 +135,7 @@ class MARBLE_EXPORT KDescendantsProxyModel : public QAbstractProxyModel
* *
* Default is false. * Default is false.
*/ */
void setDisplayAncestorData( bool display ); void setDisplayAncestorData(bool display);
/** /**
* Whether ancestor data will be displayed. * Whether ancestor data will be displayed.
...@@ -136,72 +145,64 @@ class MARBLE_EXPORT KDescendantsProxyModel : public QAbstractProxyModel ...@@ -136,72 +145,64 @@ class MARBLE_EXPORT KDescendantsProxyModel : public QAbstractProxyModel
/** /**
* Sets the ancestor @p separator used between data of ancestors. * Sets the ancestor @p separator used between data of ancestors.
*/ */
void setAncestorSeparator( const QString &separator ); void setAncestorSeparator(const QString &separator);
/** /**
* Separator used between data of ancestors. * Separator used between data of ancestors.
*/ */
QString ancestorSeparator() const; QString ancestorSeparator() const;
/** QModelIndex mapFromSource(const QModelIndex &sourceIndex) const Q_DECL_OVERRIDE;
* Returns the number of descendant entries for the given model @p index. QModelIndex mapToSource(const QModelIndex &proxyIndex) const Q_DECL_OVERRIDE;
*/
int descendantCount( const QModelIndex &index ) const;
QModelIndex mapFromSource ( const QModelIndex & sourceIndex ) const;
QModelIndex mapToSource ( const QModelIndex & proxyIndex ) const;
virtual Qt::ItemFlags flags( const QModelIndex &index ) const; Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE;
QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
virtual int rowCount( const QModelIndex & parent = QModelIndex() ) const; int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const; QVariant headerData(int section, Qt::Orientation orientation, int role) const Q_DECL_OVERRIDE;
virtual QMimeData* mimeData( const QModelIndexList & indexes ) const; QMimeData *mimeData(const QModelIndexList &indexes) const Q_DECL_OVERRIDE;
virtual QStringList mimeTypes() const; QStringList mimeTypes() const Q_DECL_OVERRIDE;
virtual bool hasChildren ( const QModelIndex & parent = QModelIndex() ) const; bool hasChildren(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
virtual QModelIndex index(int, int, const QModelIndex &parent = QModelIndex() ) const; QModelIndex index(int, int, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
virtual QModelIndex parent(const QModelIndex&) const; QModelIndex parent(const QModelIndex &) const Q_DECL_OVERRIDE;
virtual int columnCount(const QModelIndex& index = QModelIndex()) const; int columnCount(const QModelIndex &index = QModelIndex()) const Q_DECL_OVERRIDE;
virtual Qt::DropActions supportedDropActions() const; Qt::DropActions supportedDropActions() const Q_DECL_OVERRIDE;
/** /**
Reimplemented to match all descendants. Reimplemented to match all descendants.
*/ */
virtual QModelIndexList match(const QModelIndex& start, int role, const QVariant& value, virtual QModelIndexList match(const QModelIndex &start, int role, const QVariant &value,
int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags( Qt::MatchStartsWith | Qt::MatchWrap ) ) const; int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags(Qt::MatchStartsWith | Qt::MatchWrap)) const Q_DECL_OVERRIDE;
private: private:
Q_DECLARE_PRIVATE( KDescendantsProxyModel ) Q_DECLARE_PRIVATE(KDescendantsProxyModel)
//@cond PRIVATE //@cond PRIVATE
KDescendantsProxyModelPrivate *d_ptr; KDescendantsProxyModelPrivate *d_ptr;
Q_PRIVATE_SLOT(d_func(), void sourceRowsAboutToBeInserted(const QModelIndex &, int, int)) Q_PRIVATE_SLOT(d_func(), void sourceRowsAboutToBeInserted(const QModelIndex &, int, int))
Q_PRIVATE_SLOT(d_func(), void sourceRowsInserted(const QModelIndex &, int, int)) Q_PRIVATE_SLOT(d_func(), void sourceRowsInserted(const QModelIndex &, int, int))
Q_PRIVATE_SLOT(d_func(), void sourceRowsAboutToBeRemoved(const QModelIndex &, int, int)) Q_PRIVATE_SLOT(d_func(), void sourceRowsAboutToBeRemoved(const QModelIndex &, int, int))
Q_PRIVATE_SLOT(d_func(), void sourceRowsRemoved(const QModelIndex &, int, int)) Q_PRIVATE_SLOT(d_func(), void sourceRowsRemoved(const QModelIndex &, int, int))
Q_PRIVATE_SLOT(d_func(), void sourceRowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int)) Q_PRIVATE_SLOT(d_func(), void sourceRowsAboutToBeMoved(const QModelIndex &, int, int, const QModelIndex &, int))
Q_PRIVATE_SLOT(d_func(), void sourceRowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)) Q_PRIVATE_SLOT(d_func(), void sourceRowsMoved(const QModelIndex &, int, int, const QModelIndex &, int))
Q_PRIVATE_SLOT(d_func(), void sourceModelAboutToBeReset()) Q_PRIVATE_SLOT(d_func(), void sourceModelAboutToBeReset())
Q_PRIVATE_SLOT(d_func(), void sourceModelReset()) Q_PRIVATE_SLOT(d_func(), void sourceModelReset())
Q_PRIVATE_SLOT(d_func(), void sourceLayoutAboutToBeChanged()) Q_PRIVATE_SLOT(d_func(), void sourceLayoutAboutToBeChanged())
Q_PRIVATE_SLOT(d_func(), void sourceLayoutChanged()) Q_PRIVATE_SLOT(d_func(), void sourceLayoutChanged())
Q_PRIVATE_SLOT(d_func(), void sourceDataChanged(const QModelIndex &, const QModelIndex &)) Q_PRIVATE_SLOT(d_func(), void sourceDataChanged(const QModelIndex &, const QModelIndex &))
Q_PRIVATE_SLOT(d_func(), void sourceModelDestroyed()) Q_PRIVATE_SLOT(d_func(), void sourceModelDestroyed())
Q_PRIVATE_SLOT(d_func(), void processPendingParents()) Q_PRIVATE_SLOT(d_func(), void processPendingParents())
// Make these private, they shouldn't be called by applications
// Make these private, they shouldn't be called by applications
// virtual bool insertRows(int , int, const QModelIndex & = QModelIndex()); // virtual bool insertRows(int , int, const QModelIndex & = QModelIndex());
// virtual bool insertColumns(int, int, const QModelIndex & = QModelIndex()); // virtual bool insertColumns(int, int, const QModelIndex & = QModelIndex());
// virtual bool removeRows(int, int, const QModelIndex & = QModelIndex()); // virtual bool removeRows(int, int, const QModelIndex & = QModelIndex());
// virtual bool removeColumns(int, int, const QModelIndex & = QModelIndex()); // virtual bool removeColumns(int, int, const QModelIndex & = QModelIndex());
//@endcond
//@endcond
}; };
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment