"Fossies" - the Fresh Open Source Software Archive

Member "cutter-1.9.0/src/widgets/CommentsWidget.h" (6 Sep 2019, 2786 Bytes) of package /linux/privat/cutter-1.9.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "CommentsWidget.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.8.3_vs_1.9.0.

    1 #ifndef COMMENTSWIDGET_H
    2 #define COMMENTSWIDGET_H
    3 
    4 #include <memory>
    5 #include <QAbstractItemModel>
    6 #include <QSortFilterProxyModel>
    7 
    8 #include "core/Cutter.h"
    9 #include "common/AddressableItemModel.h"
   10 #include "CutterDockWidget.h"
   11 #include "CutterTreeWidget.h"
   12 #include "widgets/ListDockWidget.h"
   13 
   14 class MainWindow;
   15 class QTreeWidgetItem;
   16 class CommentsWidget;
   17 
   18 struct CommentGroup
   19 {
   20     QString name;
   21     RVA offset;
   22     QList<CommentDescription> comments;
   23 };
   24 
   25 class CommentsModel : public AddressableItemModel<>
   26 {
   27     Q_OBJECT
   28 
   29     friend CommentsWidget;
   30 
   31 private:
   32     QList<CommentDescription> *comments;
   33     QList<CommentGroup> *nestedComments;
   34     bool nested;
   35 
   36 public:
   37     enum Column { OffsetColumn = 0, FunctionColumn, CommentColumn, ColumnCount };
   38     enum NestedColumn { OffsetNestedColumn = 0, CommentNestedColumn, NestedColumnCount };
   39     enum Role { CommentDescriptionRole = Qt::UserRole, FunctionRole };
   40 
   41     CommentsModel(QList<CommentDescription> *comments,
   42                   QList<CommentGroup> *nestedComments,
   43                   QObject *parent = nullptr);
   44 
   45     QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
   46     QModelIndex parent(const QModelIndex &index) const override;
   47 
   48     int rowCount(const QModelIndex &parent = QModelIndex()) const override;
   49     int columnCount(const QModelIndex &parent = QModelIndex()) const override;
   50 
   51     QVariant data(const QModelIndex &index, int role) const override;
   52     QVariant headerData(int section, Qt::Orientation orientation,
   53                         int role = Qt::DisplayRole) const override;
   54 
   55     bool isNested() const;
   56     void setNested(bool nested);
   57 
   58     RVA address(const QModelIndex &index) const override;
   59 };
   60 
   61 class CommentsProxyModel : public AddressableFilterProxyModel
   62 {
   63     Q_OBJECT
   64 
   65 public:
   66     CommentsProxyModel(CommentsModel *sourceModel, QObject *parent = nullptr);
   67 
   68 protected:
   69     bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
   70     bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
   71 };
   72 
   73 class CommentsWidget : public ListDockWidget
   74 {
   75     Q_OBJECT
   76 
   77 public:
   78     explicit CommentsWidget(MainWindow *main, QAction *action = nullptr);
   79     ~CommentsWidget() override;
   80 
   81 protected:
   82     void resizeEvent(QResizeEvent *event) override;
   83 
   84 private slots:
   85     void onActionHorizontalToggled(bool checked);
   86     void onActionVerticalToggled(bool checked);
   87 
   88     void showTitleContextMenu(const QPoint &pt);
   89 
   90     void refreshTree();
   91 
   92 private:
   93     CommentsModel *commentsModel;
   94     CommentsProxyModel *commentsProxyModel;
   95     QAction actionHorizontal;
   96     QAction actionVertical;
   97 
   98     QList<CommentDescription> comments;
   99     QList<CommentGroup> nestedComments;
  100 
  101     QMenu *titleContextMenu;
  102 };
  103 
  104 #endif // COMMENTSWIDGET_H