#ifndef CLASSBROWSER_H #define CLASSBROWSER_H #include #include "parser/cppparser.h" struct ClassBrowserNode { ClassBrowserNode* parent; PStatement statement; QVector children; // bool childrenFetched; }; using PClassBrowserNode = std::shared_ptr; class ClassBrowserModel : public QAbstractItemModel{ Q_OBJECT // QAbstractItemModel interface public: explicit ClassBrowserModel(QObject* parent=nullptr); ~ClassBrowserModel(); ClassBrowserModel& operator=(const ClassBrowserModel& model) = delete; QModelIndex index(int row, int column, const QModelIndex &parent) const override; QModelIndex parent(const QModelIndex &child) const override; bool hasChildren(const QModelIndex &parent) const override; int rowCount(const QModelIndex &parent) const override; int columnCount(const QModelIndex &parent) const override; // void fetchMore(const QModelIndex &parent) override; // bool canFetchMore(const QModelIndex &parent) const override; QVariant data(const QModelIndex &index, int role) const override; const PCppParser &parser() const; void setParser(const PCppParser &newCppParser); void clear(); const QString ¤tFile() const; void setCurrentFile(const QString &newCurrentFile); void beginUpdate(); void endUpdate(); const std::shared_ptr > &colors() const; void setColors(const std::shared_ptr > &newColors); public slots: void fillStatements(); private: void addChild(ClassBrowserNode* node, PStatement statement); void addMembers(const QSet& includedFiles); void filterChildren(ClassBrowserNode * node, const StatementMap& statements); PStatement createDummy(PStatement statement); private: ClassBrowserNode * mRoot; QHash mDummyStatements; QVector mNodes; PCppParser mParser; bool mUpdating; int mUpdateCount; QRecursiveMutex mMutex; QString mCurrentFile; std::shared_ptr> mColors; }; #endif // CLASSBROWSER_H