2017-03-29 10:18:37 +00:00
|
|
|
#ifndef COMMENTSWIDGET_H
|
|
|
|
#define COMMENTSWIDGET_H
|
|
|
|
|
2017-10-02 09:41:28 +00:00
|
|
|
#include <memory>
|
2018-05-01 18:54:34 +00:00
|
|
|
#include <QAbstractItemModel>
|
|
|
|
#include <QSortFilterProxyModel>
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2019-02-22 16:50:45 +00:00
|
|
|
#include "core/Cutter.h"
|
2019-08-19 13:35:25 +00:00
|
|
|
#include "common/AddressableItemModel.h"
|
2018-03-16 21:46:57 +00:00
|
|
|
#include "CutterDockWidget.h"
|
2018-10-10 12:34:46 +00:00
|
|
|
#include "CutterTreeWidget.h"
|
2019-08-19 13:35:25 +00:00
|
|
|
#include "widgets/ListDockWidget.h"
|
2017-11-19 12:56:10 +00:00
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
class MainWindow;
|
2017-04-13 15:14:02 +00:00
|
|
|
class QTreeWidgetItem;
|
2018-10-10 11:33:55 +00:00
|
|
|
class CommentsWidget;
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2019-08-19 13:35:25 +00:00
|
|
|
struct CommentGroup
|
|
|
|
{
|
|
|
|
QString name;
|
|
|
|
RVA offset;
|
|
|
|
QList<CommentDescription> comments;
|
|
|
|
};
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2019-08-19 13:35:25 +00:00
|
|
|
class CommentsModel : public AddressableItemModel<>
|
2018-05-01 18:54:34 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2018-10-10 11:33:55 +00:00
|
|
|
friend CommentsWidget;
|
|
|
|
|
2018-05-01 18:54:34 +00:00
|
|
|
private:
|
|
|
|
QList<CommentDescription> *comments;
|
2019-08-19 13:35:25 +00:00
|
|
|
QList<CommentGroup> *nestedComments;
|
2018-05-01 18:54:34 +00:00
|
|
|
bool nested;
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum Column { OffsetColumn = 0, FunctionColumn, CommentColumn, ColumnCount };
|
|
|
|
enum NestedColumn { OffsetNestedColumn = 0, CommentNestedColumn, NestedColumnCount };
|
|
|
|
enum Role { CommentDescriptionRole = Qt::UserRole, FunctionRole };
|
|
|
|
|
2018-09-30 20:00:53 +00:00
|
|
|
CommentsModel(QList<CommentDescription> *comments,
|
2019-08-19 13:35:25 +00:00
|
|
|
QList<CommentGroup> *nestedComments,
|
2018-05-04 07:58:32 +00:00
|
|
|
QObject *parent = nullptr);
|
2018-05-01 18:54:34 +00:00
|
|
|
|
2019-08-19 13:35:25 +00:00
|
|
|
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
QModelIndex parent(const QModelIndex &index) const override;
|
2018-05-01 18:54:34 +00:00
|
|
|
|
2019-08-19 13:35:25 +00:00
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
2018-05-01 18:54:34 +00:00
|
|
|
|
2019-08-19 13:35:25 +00:00
|
|
|
QVariant data(const QModelIndex &index, int role) const override;
|
|
|
|
QVariant headerData(int section, Qt::Orientation orientation,
|
|
|
|
int role = Qt::DisplayRole) const override;
|
2018-05-01 18:54:34 +00:00
|
|
|
|
|
|
|
bool isNested() const;
|
|
|
|
void setNested(bool nested);
|
2019-08-19 13:35:25 +00:00
|
|
|
|
|
|
|
RVA address(const QModelIndex &index) const override;
|
2018-05-01 18:54:34 +00:00
|
|
|
};
|
|
|
|
|
2019-08-19 13:35:25 +00:00
|
|
|
class CommentsProxyModel : public AddressableFilterProxyModel
|
2018-05-01 18:54:34 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2018-05-04 07:58:32 +00:00
|
|
|
CommentsProxyModel(CommentsModel *sourceModel, QObject *parent = nullptr);
|
2018-05-01 18:54:34 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
|
|
|
|
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
|
|
|
|
};
|
|
|
|
|
2019-08-19 13:35:25 +00:00
|
|
|
class CommentsWidget : public ListDockWidget
|
2017-03-29 10:18:37 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2018-03-16 21:46:57 +00:00
|
|
|
explicit CommentsWidget(MainWindow *main, QAction *action = nullptr);
|
2019-08-19 13:35:25 +00:00
|
|
|
~CommentsWidget() override;
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
private slots:
|
2019-08-19 13:35:25 +00:00
|
|
|
void onActionHorizontalToggled(bool checked);
|
|
|
|
void onActionVerticalToggled(bool checked);
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2017-11-19 12:56:10 +00:00
|
|
|
void showTitleContextMenu(const QPoint &pt);
|
|
|
|
|
2017-09-02 08:46:48 +00:00
|
|
|
void refreshTree();
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
private:
|
2018-05-01 18:54:34 +00:00
|
|
|
CommentsModel *commentsModel;
|
|
|
|
CommentsProxyModel *commentsProxyModel;
|
2019-08-19 13:35:25 +00:00
|
|
|
QAction actionHorizontal;
|
|
|
|
QAction actionVertical;
|
2018-05-01 18:54:34 +00:00
|
|
|
|
|
|
|
QList<CommentDescription> comments;
|
2019-08-19 13:35:25 +00:00
|
|
|
QList<CommentGroup> nestedComments;
|
2018-05-01 18:54:34 +00:00
|
|
|
|
2019-08-19 13:35:25 +00:00
|
|
|
QMenu *titleContextMenu;
|
2017-03-29 10:18:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // COMMENTSWIDGET_H
|