mirror of
https://github.com/rizinorg/cutter.git
synced 2025-02-20 13:46:06 +00:00
Remove cursorAddress, Fix current function display (#103)
This commit is contained in:
parent
da68aa9889
commit
adef80e9e8
@ -697,12 +697,6 @@ void MainWindow::toggleDockWidget(QDockWidget *dock_widget)
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::setCursorAddress(RVA addr)
|
||||
{
|
||||
this->cursorAddress = addr;
|
||||
emit cursorAddressChanged(core->getOffset());
|
||||
}
|
||||
|
||||
void MainWindow::backButton_clicked()
|
||||
{
|
||||
core->seekPrev();
|
||||
|
@ -88,9 +88,6 @@ public:
|
||||
void toggleSideBarTheme();
|
||||
void refreshOmniBar(const QStringList &flags);
|
||||
|
||||
signals:
|
||||
void cursorAddressChanged(RVA offset); // TODO cursor should be handled by its own widget
|
||||
|
||||
public slots:
|
||||
|
||||
void dark();
|
||||
@ -197,7 +194,6 @@ private:
|
||||
void refreshMem();
|
||||
ut64 hexdumpTopOffset;
|
||||
ut64 hexdumpBottomOffset;
|
||||
RVA cursorAddress;
|
||||
QString filename;
|
||||
QList<QDockWidget *> dockWidgets;
|
||||
std::unique_ptr<Ui::MainWindow> ui;
|
||||
@ -229,9 +225,7 @@ private:
|
||||
void showDefaultDocks();
|
||||
|
||||
public:
|
||||
RVA getCursorAddress() const { return cursorAddress; }
|
||||
QString getFilename() const { return filename; }
|
||||
void setCursorAddress(RVA addr);
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
@ -14,9 +14,8 @@
|
||||
#include <QResource>
|
||||
#include <QShortcut>
|
||||
|
||||
FunctionModel::FunctionModel(QList<FunctionDescription> *functions, QSet<RVA> *import_addresses, bool nested, QFont default_font, QFont highlight_font, MainWindow *main, QObject *parent)
|
||||
FunctionModel::FunctionModel(QList<FunctionDescription> *functions, QSet<RVA> *import_addresses, bool nested, QFont default_font, QFont highlight_font, QObject *parent)
|
||||
: QAbstractItemModel(parent),
|
||||
main(main),
|
||||
functions(functions),
|
||||
import_addresses(import_addresses),
|
||||
highlight_font(highlight_font),
|
||||
@ -25,8 +24,8 @@ FunctionModel::FunctionModel(QList<FunctionDescription> *functions, QSet<RVA> *i
|
||||
current_index(-1)
|
||||
|
||||
{
|
||||
connect(main, SIGNAL(cursorAddressChanged(RVA)), this, SLOT(cursorAddressChanged(RVA)));
|
||||
connect(CutterCore::getInstance(), SIGNAL(functionRenamed(QString, QString)), this, SLOT(functionRenamed(QString, QString)));
|
||||
connect(Core(), SIGNAL(seekChanged(RVA)), this, SLOT(seekChanged(RVA)));
|
||||
connect(Core(), SIGNAL(functionRenamed(QString, QString)), this, SLOT(functionRenamed(QString, QString)));
|
||||
}
|
||||
|
||||
QModelIndex FunctionModel::index(int row, int column, const QModelIndex &parent) const
|
||||
@ -211,22 +210,26 @@ void FunctionModel::endReloadFunctions()
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void FunctionModel::cursorAddressChanged(RVA)
|
||||
void FunctionModel::seekChanged(RVA)
|
||||
{
|
||||
updateCurrentIndex();
|
||||
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
|
||||
if (updateCurrentIndex())
|
||||
{
|
||||
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
|
||||
}
|
||||
}
|
||||
|
||||
void FunctionModel::updateCurrentIndex()
|
||||
bool FunctionModel::updateCurrentIndex()
|
||||
{
|
||||
int index = -1;
|
||||
RVA offset = 0;
|
||||
|
||||
RVA seek = Core()->getOffset();
|
||||
|
||||
for (int i = 0; i < functions->count(); i++)
|
||||
{
|
||||
const FunctionDescription &function = functions->at(i);
|
||||
|
||||
if (function.contains(CutterCore::getInstance()->getOffset())
|
||||
if (function.contains(seek)
|
||||
&& function.offset >= offset)
|
||||
{
|
||||
offset = function.offset;
|
||||
@ -234,7 +237,11 @@ void FunctionModel::updateCurrentIndex()
|
||||
}
|
||||
}
|
||||
|
||||
bool changed = current_index != index;
|
||||
|
||||
current_index = index;
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
void FunctionModel::functionRenamed(const QString &prev_name, const QString &new_name)
|
||||
@ -345,12 +352,12 @@ FunctionsWidget::FunctionsWidget(MainWindow *main, QWidget *parent) :
|
||||
QFont default_font = QFont(font_info.family(), font_info.pointSize());
|
||||
QFont highlight_font = QFont(font_info.family(), font_info.pointSize(), QFont::Bold);
|
||||
|
||||
function_model = new FunctionModel(&functions, &import_addresses, false, default_font, highlight_font, main, this);
|
||||
function_model = new FunctionModel(&functions, &import_addresses, false, default_font, highlight_font, this);
|
||||
function_proxy_model = new FunctionSortFilterProxyModel(function_model, this);
|
||||
connect(ui->filterLineEdit, SIGNAL(textChanged(const QString &)), function_proxy_model, SLOT(setFilterWildcard(const QString &)));
|
||||
ui->functionsTreeView->setModel(function_proxy_model);
|
||||
|
||||
nested_function_model = new FunctionModel(&functions, &import_addresses, true, default_font, highlight_font, main, this);
|
||||
nested_function_model = new FunctionModel(&functions, &import_addresses, true, default_font, highlight_font, this);
|
||||
nested_function_proxy_model = new FunctionSortFilterProxyModel(nested_function_model, this);
|
||||
connect(ui->filterLineEdit, SIGNAL(textChanged(const QString &)), nested_function_proxy_model, SLOT(setFilterWildcard(const QString &)));
|
||||
ui->nestedFunctionsTreeView->setModel(nested_function_proxy_model);
|
||||
|
@ -21,8 +21,6 @@ class FunctionModel : public QAbstractItemModel
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
MainWindow *main;
|
||||
|
||||
QList<FunctionDescription> *functions;
|
||||
QSet<RVA> *import_addresses;
|
||||
|
||||
@ -39,7 +37,7 @@ public:
|
||||
|
||||
enum Column { NameColumn = 0, SizeColumn, ImportColumn, OffsetColumn, ColumnCount };
|
||||
|
||||
FunctionModel(QList<FunctionDescription> *functions, QSet<RVA> *import_addresses, bool nested, QFont default_font, QFont highlight_font, MainWindow *main, QObject *parent = 0);
|
||||
FunctionModel(QList<FunctionDescription> *functions, QSet<RVA> *import_addresses, bool nested, QFont default_font, QFont highlight_font, QObject *parent = 0);
|
||||
|
||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
|
||||
QModelIndex parent(const QModelIndex &index) const;
|
||||
@ -53,12 +51,15 @@ public:
|
||||
void beginReloadFunctions();
|
||||
void endReloadFunctions();
|
||||
|
||||
void updateCurrentIndex();
|
||||
/*!
|
||||
* @return true if the index changed
|
||||
*/
|
||||
bool updateCurrentIndex();
|
||||
|
||||
bool isNested() { return nested; }
|
||||
|
||||
private slots:
|
||||
void cursorAddressChanged(RVA addr);
|
||||
void seekChanged(RVA addr);
|
||||
void functionRenamed(const QString &prev_name, const QString &new_name);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user