2017-03-29 10:18:37 +00:00
|
|
|
#ifndef FUNCTIONSWIDGET_H
|
|
|
|
#define FUNCTIONSWIDGET_H
|
|
|
|
|
2017-11-19 12:56:10 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2017-05-14 16:21:54 +00:00
|
|
|
#include <QSortFilterProxyModel>
|
|
|
|
#include <QTreeView>
|
2017-11-19 12:56:10 +00:00
|
|
|
#include <QDockWidget>
|
|
|
|
|
2017-09-25 12:55:41 +00:00
|
|
|
#include "cutter.h"
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
class MainWindow;
|
2017-04-13 15:14:02 +00:00
|
|
|
class QTreeWidgetItem;
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2017-04-09 19:55:06 +00:00
|
|
|
namespace Ui
|
|
|
|
{
|
|
|
|
class FunctionsWidget;
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
2017-04-28 13:09:40 +00:00
|
|
|
|
|
|
|
class FunctionModel : public QAbstractItemModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private:
|
|
|
|
QList<FunctionDescription> *functions;
|
2018-02-09 14:03:03 +00:00
|
|
|
QSet<RVA> *importAddresses;
|
2018-02-12 08:59:45 +00:00
|
|
|
ut64 *mainAdress;
|
2017-04-28 13:09:40 +00:00
|
|
|
|
|
|
|
|
2018-02-09 14:03:03 +00:00
|
|
|
QFont highlightFont;
|
|
|
|
QFont defaultFont;
|
2017-04-28 13:09:40 +00:00
|
|
|
bool nested;
|
|
|
|
|
2018-02-09 14:03:03 +00:00
|
|
|
int currentIndex;
|
2017-04-28 13:09:40 +00:00
|
|
|
|
2017-12-20 15:40:46 +00:00
|
|
|
bool functionIsImport(ut64 addr) const;
|
|
|
|
|
2018-02-12 08:59:45 +00:00
|
|
|
bool functionIsMain(ut64 addr) const;
|
|
|
|
|
2017-04-28 13:09:40 +00:00
|
|
|
public:
|
|
|
|
static const int FunctionDescriptionRole = Qt::UserRole;
|
|
|
|
static const int IsImportRole = Qt::UserRole + 1;
|
|
|
|
|
2017-11-04 15:28:02 +00:00
|
|
|
enum Column { NameColumn = 0, SizeColumn, ImportColumn, OffsetColumn, ColumnCount };
|
|
|
|
|
2018-02-12 08:59:45 +00:00
|
|
|
FunctionModel(QList<FunctionDescription> *functions, QSet<RVA> *importAddresses, ut64 *mainAdress, bool nested, QFont defaultFont, QFont highlightFont, QObject *parent = 0);
|
2017-04-28 13:09:40 +00:00
|
|
|
|
|
|
|
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
|
|
|
|
QModelIndex parent(const QModelIndex &index) const;
|
|
|
|
|
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
|
|
|
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
|
|
|
|
|
|
|
QVariant data(const QModelIndex &index, int role) const;
|
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
|
|
|
|
|
|
|
void beginReloadFunctions();
|
|
|
|
void endReloadFunctions();
|
|
|
|
|
2017-11-07 13:11:33 +00:00
|
|
|
/*!
|
|
|
|
* @return true if the index changed
|
|
|
|
*/
|
|
|
|
bool updateCurrentIndex();
|
2017-04-28 13:09:40 +00:00
|
|
|
|
2017-12-21 19:51:19 +00:00
|
|
|
void setNested(bool nested);
|
|
|
|
bool isNested() { return nested; }
|
2017-04-28 13:09:40 +00:00
|
|
|
|
|
|
|
private slots:
|
2017-11-07 13:11:33 +00:00
|
|
|
void seekChanged(RVA addr);
|
2017-04-28 13:38:01 +00:00
|
|
|
void functionRenamed(const QString &prev_name, const QString &new_name);
|
2017-04-28 13:09:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class FunctionSortFilterProxyModel : public QSortFilterProxyModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
FunctionSortFilterProxyModel(FunctionModel *source_model, QObject *parent = 0);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
|
|
|
|
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-19 12:56:10 +00:00
|
|
|
class FunctionsWidget : public QDockWidget
|
2017-03-29 10:18:37 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit FunctionsWidget(MainWindow *main, QWidget *parent = 0);
|
|
|
|
~FunctionsWidget();
|
|
|
|
|
|
|
|
private slots:
|
2018-02-02 15:56:39 +00:00
|
|
|
void onFunctionsDoubleClicked(const QModelIndex &index);
|
2017-03-29 10:18:37 +00:00
|
|
|
void showFunctionsContextMenu(const QPoint &pt);
|
|
|
|
|
|
|
|
void on_actionDisasAdd_comment_triggered();
|
|
|
|
void on_actionFunctionsRename_triggered();
|
|
|
|
void on_action_References_triggered();
|
2017-12-14 21:54:57 +00:00
|
|
|
void on_actionFunctionsUndefine_triggered();
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
void on_actionHorizontal_triggered();
|
|
|
|
void on_actionVertical_triggered();
|
|
|
|
|
2017-05-19 07:45:26 +00:00
|
|
|
void showTitleContextMenu(const QPoint &pt);
|
|
|
|
|
2017-11-19 12:56:10 +00:00
|
|
|
void refreshTree();
|
|
|
|
|
2017-04-10 10:25:33 +00:00
|
|
|
protected:
|
|
|
|
void resizeEvent(QResizeEvent *event) override;
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
private:
|
2017-10-02 09:41:28 +00:00
|
|
|
std::unique_ptr<Ui::FunctionsWidget> ui;
|
2017-03-29 10:18:37 +00:00
|
|
|
MainWindow *main;
|
2017-04-13 15:14:02 +00:00
|
|
|
|
2017-04-28 13:09:40 +00:00
|
|
|
QList<FunctionDescription> functions;
|
2018-02-09 14:03:03 +00:00
|
|
|
QSet<RVA> importAddresses;
|
2018-02-12 08:59:45 +00:00
|
|
|
ut64 mainAdress;
|
2017-04-28 13:09:40 +00:00
|
|
|
|
2018-02-09 14:03:03 +00:00
|
|
|
FunctionModel *functionModel;
|
|
|
|
FunctionSortFilterProxyModel *functionProxyModel;
|
2017-04-28 13:09:40 +00:00
|
|
|
|
2017-04-13 15:14:02 +00:00
|
|
|
void setScrollMode();
|
2017-03-29 10:18:37 +00:00
|
|
|
};
|
|
|
|
|
2017-04-28 13:09:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
#endif // FUNCTIONSWIDGET_H
|