X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fflatproxymodel.h;fp=src%2Fuisupport%2Fflatproxymodel.h;h=ebb423d3f52d0f1a56d04b684685723efe233b8a;hp=84fb77972728301d754ec15a77563739c6985864;hb=c1cf157116de7fc3da96203aa6f03c38c7ebb650;hpb=30b159cb876a9495de42e9a3e70ca050516f0805 diff --git a/src/uisupport/flatproxymodel.h b/src/uisupport/flatproxymodel.h index 84fb7797..ebb423d3 100644 --- a/src/uisupport/flatproxymodel.h +++ b/src/uisupport/flatproxymodel.h @@ -29,96 +29,99 @@ class UISUPPORT_EXPORT FlatProxyModel : public QAbstractProxyModel Q_OBJECT public: - FlatProxyModel(QObject *parent = nullptr); + FlatProxyModel(QObject* parent = nullptr); - QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override; - QModelIndex mapToSource(const QModelIndex &proxyIndex) const override; + QModelIndex mapFromSource(const QModelIndex& sourceIndex) const override; + QModelIndex mapToSource(const QModelIndex& proxyIndex) const override; - QItemSelection mapSelectionFromSource(const QItemSelection &sourceSelection) const override; - QItemSelection mapSelectionToSource(const QItemSelection &proxySelection) const override; + QItemSelection mapSelectionFromSource(const QItemSelection& sourceSelection) const override; + QItemSelection mapSelectionToSource(const QItemSelection& proxySelection) const override; - void setSourceModel(QAbstractItemModel *sourceModel) override; + void setSourceModel(QAbstractItemModel* sourceModel) override; - QModelIndex index(int row, int column, const QModelIndex &parent) const override; - QModelIndex parent(const QModelIndex &index) const override; + QModelIndex index(int row, int column, const QModelIndex& parent) const override; + QModelIndex parent(const QModelIndex& index) const override; - int rowCount(const QModelIndex &index) const override; - int columnCount(const QModelIndex &index) const override; + int rowCount(const QModelIndex& index) const override; + int columnCount(const QModelIndex& index) const override; public slots: void linkTest() const; void completenessTest() const; private slots: - void on_columnsAboutToBeInserted(const QModelIndex &parent, int start, int end); - void on_columnsAboutToBeRemoved(const QModelIndex &parent, int start, int end); - void on_columnsInserted(const QModelIndex &parent, int start, int end); - void on_columnsRemoved(const QModelIndex &parent, int start, int end); + void on_columnsAboutToBeInserted(const QModelIndex& parent, int start, int end); + void on_columnsAboutToBeRemoved(const QModelIndex& parent, int start, int end); + void on_columnsInserted(const QModelIndex& parent, int start, int end); + void on_columnsRemoved(const QModelIndex& parent, int start, int end); - void on_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); -// void on_headerDataChanged(Qt::Orientation orientation, int first, int last); + void on_dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight); + // void on_headerDataChanged(Qt::Orientation orientation, int first, int last); void on_layoutAboutToBeChanged(); void on_layoutChanged(); - inline void on_modelAboutToBeReset() { beginResetModel(); endResetModel(); } + inline void on_modelAboutToBeReset() + { + beginResetModel(); + endResetModel(); + } // void on_modelReset(); - void on_rowsAboutToBeInserted(const QModelIndex &parent, int start, int end); - void on_rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end); - void on_rowsInserted(const QModelIndex &parent, int start, int end); - void on_rowsRemoved(const QModelIndex &parent, int start, int end); + void on_rowsAboutToBeInserted(const QModelIndex& parent, int start, int end); + void on_rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end); + void on_rowsInserted(const QModelIndex& parent, int start, int end); + void on_rowsRemoved(const QModelIndex& parent, int start, int end); private: QList _childCount; class SourceItem; - SourceItem *_rootSourceItem{nullptr}; + SourceItem* _rootSourceItem{nullptr}; - void insertSubTree(const QModelIndex &source_idx, bool emitInsert = true); - SourceItem *insertSubTreeHelper(SourceItem *parentItem, SourceItem *lastItem_, const QModelIndex &source_idx); + void insertSubTree(const QModelIndex& source_idx, bool emitInsert = true); + SourceItem* insertSubTreeHelper(SourceItem* parentItem, SourceItem* lastItem_, const QModelIndex& source_idx); - void removeSubTree(const QModelIndex &source_idx, bool emitRemove = true); + void removeSubTree(const QModelIndex& source_idx, bool emitRemove = true); - SourceItem *sourceToInternal(const QModelIndex &sourceIndex) const; + SourceItem* sourceToInternal(const QModelIndex& sourceIndex) const; - void checkChildCount(const QModelIndex &index, const SourceItem *item, int &pos) const; + void checkChildCount(const QModelIndex& index, const SourceItem* item, int& pos) const; class _RangeRect { -public: + public: int left, right, top, bottom; SourceItem *topItem, *bottomItem; - bool operator<(const _RangeRect &other) const; + bool operator<(const _RangeRect& other) const; }; }; - class FlatProxyModel::SourceItem { public: - SourceItem(int row = 0, SourceItem *parent = nullptr); + SourceItem(int row = 0, SourceItem* parent = nullptr); ~SourceItem(); - inline SourceItem *parent() const { return _parent; } - inline SourceItem *child(int i) const { return _childs[i]; } + inline SourceItem* parent() const { return _parent; } + inline SourceItem* child(int i) const { return _childs[i]; } inline int childCount() const { return _childs.count(); } inline int pos() const { return _pos; } - inline SourceItem *next() const { return _next; } + inline SourceItem* next() const { return _next; } int sourceRow() const; - SourceItem *findChild(int proxyPos) const; + SourceItem* findChild(int proxyPos) const; private: - inline void removeChild(SourceItem *item) { _childs.removeAt(_childs.indexOf(item)); } + inline void removeChild(SourceItem* item) { _childs.removeAt(_childs.indexOf(item)); } inline void setPos(int i) { _pos = i; } - inline void setNext(SourceItem *next) { _next = next; } + inline void setNext(SourceItem* next) { _next = next; } - SourceItem *_parent; - QList _childs; + SourceItem* _parent; + QList _childs; int _pos{-1}; - SourceItem *_next{nullptr}; + SourceItem* _next{nullptr}; friend class FlatProxyModel; };