mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-24 05:45:27 +00:00
Readded SectionWidget with RefreshDeferrer
This commit is contained in:
parent
0ebe1cf728
commit
06da378362
@ -177,13 +177,13 @@ void MainWindow::initUI()
|
||||
|
||||
disassemblyDock = new DisassemblyWidget(this, ui->actionDisassembly);
|
||||
hexdumpDock = new HexdumpWidget(this, ui->actionHexdump);
|
||||
//pseudocodeDock = new PseudocodeWidget(this, ui->actionPseudocode);
|
||||
pseudocodeDock = new PseudocodeWidget(this, ui->actionPseudocode);
|
||||
consoleDock = new ConsoleWidget(this, ui->actionConsole);
|
||||
|
||||
// Add graph view as dockable
|
||||
graphDock = new GraphWidget(this, ui->actionGraph);
|
||||
|
||||
//sectionsDock = new SectionsWidget(this, ui->actionSections);
|
||||
sectionsDock = new SectionsWidget(this, ui->actionSections);
|
||||
//segmentsDock = new SegmentsWidget(this, ui->actionSegments);
|
||||
//entrypointDock = new EntrypointWidget(this, ui->actionEntrypoints);
|
||||
functionsDock = new FunctionsWidget(this, ui->actionFunctions);
|
||||
@ -195,7 +195,7 @@ void MainWindow::initUI()
|
||||
//searchDock = new SearchWidget(this, ui->actionSearch);
|
||||
//symbolsDock = new SymbolsWidget(this, ui->actionSymbols);
|
||||
//relocsDock = new RelocsWidget(this, ui->actionRelocs);
|
||||
//commentsDock = new CommentsWidget(this, ui->actionComments);
|
||||
commentsDock = new CommentsWidget(this, ui->actionComments);
|
||||
//stringsDock = new StringsWidget(this, ui->actionStrings);
|
||||
//flagsDock = new FlagsWidget(this, ui->actionFlags);
|
||||
//stackDock = new StackWidget(this, ui->actionStack);
|
||||
|
@ -29,17 +29,18 @@ void CommentsModel::setNested(bool nested)
|
||||
|
||||
QModelIndex CommentsModel::index(int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
if (!parent.isValid())
|
||||
if (!parent.isValid()) {
|
||||
return createIndex(row, column, (quintptr) 0);
|
||||
}
|
||||
|
||||
return createIndex(row, column, (quintptr)(parent.row() + 1));
|
||||
}
|
||||
|
||||
QModelIndex CommentsModel::parent(const QModelIndex &index) const
|
||||
{
|
||||
QModelIndex CommentsModel::parent(const QModelIndex &index) const {
|
||||
/* Ignore invalid indexes and root nodes */
|
||||
if (!index.isValid() || index.internalId() == 0)
|
||||
if (!index.isValid() || index.internalId() == 0) {
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
return this->index((int)(index.internalId() - 1), 0);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ CutterDockWidget::CutterDockWidget(MainWindow *main, QAction *action) :
|
||||
updateIsVisibleToUser();
|
||||
}
|
||||
|
||||
CutterDockWidget::~CutterDockWidget() {}
|
||||
CutterDockWidget::~CutterDockWidget() = default;
|
||||
|
||||
bool CutterDockWidget::eventFilter(QObject *object, QEvent *event)
|
||||
{
|
||||
|
@ -30,6 +30,7 @@ PseudocodeWidget::PseudocodeWidget(MainWindow *main, QAction *action) :
|
||||
}
|
||||
});
|
||||
|
||||
// TODO Use RefreshDeferrer and remove the refresh button
|
||||
connect(ui->refreshButton, &QAbstractButton::clicked, this, [this]() {
|
||||
doRefresh(Core()->getOffset());
|
||||
});
|
||||
@ -45,7 +46,7 @@ PseudocodeWidget::PseudocodeWidget(MainWindow *main, QAction *action) :
|
||||
doRefresh(RVA_INVALID);
|
||||
}
|
||||
|
||||
PseudocodeWidget::~PseudocodeWidget() {}
|
||||
PseudocodeWidget::~PseudocodeWidget() = default;
|
||||
|
||||
|
||||
void PseudocodeWidget::doRefresh(RVA addr)
|
||||
|
@ -45,8 +45,9 @@ QVariant SectionsModel::data(const QModelIndex &index, int role) const
|
||||
QColor("#95A5A6") //COBCRETE
|
||||
};
|
||||
|
||||
if (index.row() >= sections->count())
|
||||
if (index.row() >= sections->count()) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
const SectionDescription §ion = sections->at(index.row());
|
||||
|
||||
@ -142,13 +143,17 @@ SectionsWidget::SectionsWidget(MainWindow *main, QAction *action) :
|
||||
setWindowTitle(QStringLiteral("Sections"));
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
|
||||
refreshDeferrer = createRefreshDeferrer([this]() {
|
||||
drawIndicatorOnAddrDocks();
|
||||
});
|
||||
|
||||
initSectionsTable();
|
||||
initQuickFilter();
|
||||
initAddrMapDocks();
|
||||
initConnects();
|
||||
}
|
||||
|
||||
SectionsWidget::~SectionsWidget() {}
|
||||
SectionsWidget::~SectionsWidget() = default;
|
||||
|
||||
void SectionsWidget::initSectionsTable()
|
||||
{
|
||||
@ -260,8 +265,9 @@ void SectionsWidget::refreshSections()
|
||||
|
||||
void SectionsWidget::onSectionsDoubleClicked(const QModelIndex &index)
|
||||
{
|
||||
if (!index.isValid())
|
||||
if (!index.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto section = index.data(SectionsModel::SectionDescriptionRole).value<SectionDescription>();
|
||||
Core()->seek(section.vaddr);
|
||||
@ -277,6 +283,10 @@ void SectionsWidget::onSectionsSeekChanged(RVA addr)
|
||||
|
||||
void SectionsWidget::drawIndicatorOnAddrDocks()
|
||||
{
|
||||
if (!refreshDeferrer->attemptRefresh(nullptr)) {
|
||||
return;
|
||||
}
|
||||
|
||||
RVA offset = Core()->getOffset();
|
||||
for (int i = 0; i != virtualAddrDock->proxyModel->rowCount(); i++) {
|
||||
QModelIndex idx = virtualAddrDock->proxyModel->index(i, 0);
|
||||
|
@ -82,6 +82,8 @@ private:
|
||||
QWidget *dockWidgetContents;
|
||||
QuickFilterView *quickFilterView;
|
||||
|
||||
RefreshDeferrer *refreshDeferrer;
|
||||
|
||||
QWidget *addrDockWidget;
|
||||
RawAddrDock *rawAddrDock;
|
||||
VirtualAddrDock *virtualAddrDock;
|
||||
|
Loading…
Reference in New Issue
Block a user