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>
|
2017-11-19 12:56:10 +00:00
|
|
|
|
2019-02-22 16:50:45 +00:00
|
|
|
#include "core/Cutter.h"
|
2018-03-16 21:46:57 +00:00
|
|
|
#include "CutterDockWidget.h"
|
2018-10-10 12:34:46 +00:00
|
|
|
#include "CutterTreeWidget.h"
|
2018-11-10 09:17:52 +00:00
|
|
|
#include "CutterTreeView.h"
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
class MainWindow;
|
2017-04-13 15:14:02 +00:00
|
|
|
class QTreeWidgetItem;
|
2018-06-25 19:28:34 +00:00
|
|
|
class FunctionsTask;
|
2018-10-10 11:33:55 +00:00
|
|
|
class FunctionsWidget;
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2018-03-21 20:32:32 +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
|
|
|
|
|
2018-10-10 11:33:55 +00:00
|
|
|
friend FunctionsWidget;
|
|
|
|
|
2017-04-28 13:09:40 +00:00
|
|
|
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;
|
|
|
|
|
2018-04-10 18:34:11 +00:00
|
|
|
enum Column { NameColumn = 0, SizeColumn, ImportColumn, OffsetColumn, NargsColumn, NbbsColumn,
|
2018-10-10 06:41:16 +00:00
|
|
|
NlocalsColumn, CcColumn, CalltypeColumn, EdgesColumn, CostColumn, CallsColumn,
|
|
|
|
FrameColumn, ColumnCount
|
2018-09-30 20:00:53 +00:00
|
|
|
};
|
2017-11-04 15:28:02 +00:00
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
FunctionModel(QList<FunctionDescription> *functions, QSet<RVA> *importAddresses, ut64 *mainAdress,
|
2018-05-04 07:58:32 +00:00
|
|
|
bool nested, QFont defaultFont, QFont highlightFont, QObject *parent = nullptr);
|
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;
|
|
|
|
|
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);
|
2018-03-21 20:32:32 +00:00
|
|
|
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:
|
2018-05-04 07:58:32 +00:00
|
|
|
FunctionSortFilterProxyModel(FunctionModel *source_model, QObject *parent = nullptr);
|
2017-04-28 13:09:40 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool filterAcceptsRow(int row, const QModelIndex &parent) const override;
|
|
|
|
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-03-16 21:46:57 +00:00
|
|
|
class FunctionsWidget : public CutterDockWidget
|
2017-03-29 10:18:37 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2018-03-16 21:46:57 +00:00
|
|
|
explicit FunctionsWidget(MainWindow *main, QAction *action = nullptr);
|
2017-03-29 10:18:37 +00:00
|
|
|
~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;
|
2018-10-10 12:34:46 +00:00
|
|
|
MainWindow *main;
|
2017-04-13 15:14:02 +00:00
|
|
|
|
2018-06-25 19:28:34 +00:00
|
|
|
QSharedPointer<FunctionsTask> task;
|
|
|
|
|
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
|
|
|
|
2018-10-10 12:34:46 +00:00
|
|
|
CutterTreeWidget *tree;
|
|
|
|
|
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
|