Add status bar and display items count (#779)

* Add status bar and display items count
This commit is contained in:
smhaziq 2018-10-10 20:34:46 +08:00 committed by xarkes
parent 8d3e8a65e1
commit 7c7cb4083c
23 changed files with 189 additions and 14 deletions

View File

@ -173,6 +173,7 @@ SOURCES += \
dialogs/R2PluginsDialog.cpp \
widgets/CutterDockWidget.cpp \
widgets/CutterSeekableWidget.cpp \
widgets/CutterTreeWidget.cpp \
widgets/GraphWidget.cpp \
utils/JsonTreeItem.cpp \
utils/JsonModel.cpp \
@ -266,6 +267,7 @@ HEADERS += \
utils/NestedIPyKernel.h \
dialogs/R2PluginsDialog.h \
widgets/CutterDockWidget.h \
widgets/CutterTreeWidget.h \
widgets/CutterSeekableWidget.h \
widgets/GraphWidget.h \
utils/JsonTreeItem.h \

View File

@ -217,10 +217,14 @@ bool CommentsProxyModel::lessThan(const QModelIndex &left, const QModelIndex &ri
CommentsWidget::CommentsWidget(MainWindow *main, QAction *action) :
CutterDockWidget(main, action),
ui(new Ui::CommentsWidget),
main(main)
main(main),
tree(new CutterTreeWidget(this))
{
ui->setupUi(this);
// Add Status Bar footer
tree->addStatusBar(ui->verticalLayout);
commentsModel = new CommentsModel(&comments, &nestedComments, this);
commentsProxyModel = new CommentsProxyModel(commentsModel, this);
ui->commentsTreeView->setModel(commentsProxyModel);
@ -240,6 +244,10 @@ CommentsWidget::CommentsWidget(MainWindow *main, QAction *action) :
commentsProxyModel, SLOT(setFilterWildcard(const QString &)));
connect(ui->quickFilterView, SIGNAL(filterClosed()), ui->commentsTreeView, SLOT(setFocus()));
connect(ui->quickFilterView, &QuickFilterView::filterTextChanged, this, [this] {
tree->showItemsNumber(commentsProxyModel->rowCount());
});
setScrollMode();
ui->actionHorizontal->setChecked(true);
@ -327,6 +335,8 @@ void CommentsWidget::refreshTree()
commentsModel->endResetModel();
qhelpers::adjustColumns(ui->commentsTreeView, 3, 0);
tree->showItemsNumber(commentsProxyModel->rowCount());
}
void CommentsWidget::setScrollMode()

View File

@ -7,6 +7,7 @@
#include "Cutter.h"
#include "CutterDockWidget.h"
#include "CutterTreeWidget.h"
class MainWindow;
class QTreeWidgetItem;
@ -88,6 +89,7 @@ private:
CommentsModel *commentsModel;
CommentsProxyModel *commentsProxyModel;
CutterTreeWidget *tree;
QList<CommentDescription> comments;
QMap<QString, QList<CommentDescription>> nestedComments;

View File

@ -0,0 +1,26 @@
#include "CutterTreeWidget.h"
#include "MainWindow.h"
CutterTreeWidget::CutterTreeWidget(QObject *parent) :
QObject(parent),
bar(nullptr)
{}
void CutterTreeWidget::addStatusBar(QVBoxLayout *pos)
{
if(!bar) {
bar = new QStatusBar;
QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
bar->setSizePolicy(sizePolicy);
pos->addWidget(bar);
}
}
void CutterTreeWidget::showItemsNumber(int count)
{
if(bar){
bar->showMessage(tr("%1 Items").arg(count));
}
}
CutterTreeWidget::~CutterTreeWidget() {}

View File

@ -0,0 +1,24 @@
#ifndef CUTTERTREEWIDGET_H
#define CUTTERTREEWIDGET_H
#include <QStatusBar>
#include <QVBoxLayout>
class MainWindow;
class CutterTreeWidget : public QObject
{
Q_OBJECT
public:
explicit CutterTreeWidget(QObject *parent = nullptr);
~CutterTreeWidget();
void addStatusBar(QVBoxLayout *pos);
void showItemsNumber(int count);
private:
QStatusBar *bar;
};
#endif // CUTTERTREEWIDGET_H

View File

@ -113,10 +113,14 @@ bool ExportsProxyModel::lessThan(const QModelIndex &left, const QModelIndex &rig
ExportsWidget::ExportsWidget(MainWindow *main, QAction *action) :
CutterDockWidget(main, action),
ui(new Ui::ExportsWidget)
ui(new Ui::ExportsWidget),
tree(new CutterTreeWidget(this))
{
ui->setupUi(this);
// Add Status Bar footer
tree->addStatusBar(ui->verticalLayout);
exportsModel = new ExportsModel(&exports, this);
exportsProxyModel = new ExportsProxyModel(exportsModel, this);
ui->exportsTreeView->setModel(exportsProxyModel);
@ -136,6 +140,10 @@ ExportsWidget::ExportsWidget(MainWindow *main, QAction *action) :
exportsProxyModel, SLOT(setFilterWildcard(const QString &)));
connect(ui->quickFilterView, SIGNAL(filterClosed()), ui->exportsTreeView, SLOT(setFocus()));
connect(ui->quickFilterView, &QuickFilterView::filterTextChanged, this, [this] {
tree->showItemsNumber(exportsProxyModel->rowCount());
});
setScrollMode();
connect(Core(), SIGNAL(refreshAll()), this, SLOT(refreshExports()));
@ -150,6 +158,8 @@ void ExportsWidget::refreshExports()
exportsModel->endResetModel();
qhelpers::adjustColumns(ui->exportsTreeView, 3, 0);
tree->showItemsNumber(exportsProxyModel->rowCount());
}

View File

@ -5,6 +5,7 @@
#include "Cutter.h"
#include "CutterDockWidget.h"
#include "CutterTreeWidget.h"
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
@ -70,6 +71,7 @@ private:
ExportsModel *exportsModel;
ExportsProxyModel *exportsProxyModel;
QList<ExportDescription> exports;
CutterTreeWidget *tree;
void setScrollMode();
};

View File

@ -114,10 +114,14 @@ bool FlagsSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIn
FlagsWidget::FlagsWidget(MainWindow *main, QAction *action) :
CutterDockWidget(main, action),
ui(new Ui::FlagsWidget),
main(main)
main(main),
tree(new CutterTreeWidget(this))
{
ui->setupUi(this);
// Add Status Bar footer
tree->addStatusBar(ui->verticalLayout);
flags_model = new FlagsModel(&flags, this);
flags_proxy_model = new FlagsSortFilterProxyModel(flags_model, this);
connect(ui->filterLineEdit, SIGNAL(textChanged(const QString &)), flags_proxy_model,
@ -141,6 +145,10 @@ FlagsWidget::FlagsWidget(MainWindow *main, QAction *action) :
});
clearShortcut->setContext(Qt::WidgetWithChildrenShortcut);
connect(ui->filterLineEdit, &QLineEdit::textChanged, this, [this] {
tree->showItemsNumber(flags_proxy_model->rowCount());
});
setScrollMode();
ui->flagsTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
@ -238,6 +246,7 @@ void FlagsWidget::refreshFlags()
qhelpers::adjustColumns(ui->flagsTreeView, 2, 0);
tree->showItemsNumber(flags_proxy_model->rowCount());
// TODO: this is not a very good place for the following:
QStringList flagNames;

View File

@ -8,6 +8,7 @@
#include "Cutter.h"
#include "CutterDockWidget.h"
#include "CutterTreeWidget.h"
class MainWindow;
class QTreeWidgetItem;
@ -78,11 +79,12 @@ private slots:
private:
std::unique_ptr<Ui::FlagsWidget> ui;
MainWindow *main;
MainWindow *main;
FlagsModel *flags_model;
FlagsSortFilterProxyModel *flags_proxy_model;
QList<FlagDescription> flags;
CutterTreeWidget *tree;
void refreshFlags();
void setScrollMode();

View File

@ -411,10 +411,14 @@ bool FunctionSortFilterProxyModel::lessThan(const QModelIndex &left, const QMode
FunctionsWidget::FunctionsWidget(MainWindow *main, QAction *action) :
CutterDockWidget(main, action),
ui(new Ui::FunctionsWidget)
ui(new Ui::FunctionsWidget),
tree(new CutterTreeWidget(this))
{
ui->setupUi(this);
// Add Status Bar footer
tree->addStatusBar(ui->verticalLayout);
// Radare core found in:
this->main = main;
@ -445,6 +449,10 @@ FunctionsWidget::FunctionsWidget(MainWindow *main, QAction *action) :
SLOT(setFilterWildcard(const QString &)));
connect(ui->quickFilterView, SIGNAL(filterClosed()), ui->functionsTreeView, SLOT(setFocus()));
connect(ui->quickFilterView, &QuickFilterView::filterTextChanged, this, [this] {
tree->showItemsNumber(functionProxyModel->rowCount());
});
setScrollMode();
// Set Functions context menu
@ -492,6 +500,8 @@ void FunctionsWidget::refreshTree()
// resize offset and size columns
qhelpers::adjustColumns(ui->functionsTreeView, 3, 0);
tree->showItemsNumber(functionProxyModel->rowCount());
});
Core()->getAsyncTaskManager()->start(task);
}

View File

@ -8,6 +8,7 @@
#include "Cutter.h"
#include "CutterDockWidget.h"
#include "CutterTreeWidget.h"
class MainWindow;
class QTreeWidgetItem;
@ -122,7 +123,7 @@ protected:
private:
std::unique_ptr<Ui::FunctionsWidget> ui;
MainWindow *main;
MainWindow *main;
QSharedPointer<FunctionsTask> task;
@ -133,6 +134,8 @@ private:
FunctionModel *functionModel;
FunctionSortFilterProxyModel *functionProxyModel;
CutterTreeWidget *tree;
void setScrollMode();
};

View File

@ -127,10 +127,14 @@ ImportsWidget::ImportsWidget(MainWindow *main, QAction *action) :
CutterDockWidget(main, action),
ui(new Ui::ImportsWidget),
importsModel(new ImportsModel(&imports, this)),
importsProxyModel(new ImportsProxyModel(importsModel, this))
importsProxyModel(new ImportsProxyModel(importsModel, this)),
tree(new CutterTreeWidget(this))
{
ui->setupUi(this);
// Add Status Bar footer
tree->addStatusBar(ui->verticalLayout);
ui->importsTreeView->setModel(importsProxyModel);
ui->importsTreeView->sortByColumn(ImportsModel::NameColumn, Qt::AscendingOrder);
@ -148,6 +152,10 @@ ImportsWidget::ImportsWidget(MainWindow *main, QAction *action) :
importsProxyModel, SLOT(setFilterWildcard(const QString &)));
connect(ui->quickFilterView, SIGNAL(filterClosed()), ui->importsTreeView, SLOT(setFocus()));
connect(ui->quickFilterView, &QuickFilterView::filterTextChanged, this, [this] {
tree->showItemsNumber(importsProxyModel->rowCount());
});
setScrollMode();
connect(Core(), SIGNAL(refreshAll()), this, SLOT(refreshImports()));
@ -161,6 +169,8 @@ void ImportsWidget::refreshImports()
imports = Core()->getAllImports();
importsModel->endResetModel();
qhelpers::adjustColumns(ui->importsTreeView, 4, 0);
tree->showItemsNumber(importsProxyModel->rowCount());
}
void ImportsWidget::setScrollMode()

View File

@ -11,6 +11,7 @@
#include "CutterDockWidget.h"
#include "Cutter.h"
#include "CutterTreeWidget.h"
class MainWindow;
class QTreeWidget;
@ -84,9 +85,11 @@ private slots:
private:
std::unique_ptr<Ui::ImportsWidget> ui;
ImportsModel *importsModel;
ImportsProxyModel *importsProxyModel;
QList<ImportDescription> imports;
CutterTreeWidget *tree;
void highlightUnsafe();
void setScrollMode();

View File

@ -103,10 +103,14 @@ bool RegisterRefProxyModel::lessThan(const QModelIndex &left, const QModelIndex
RegisterRefsWidget::RegisterRefsWidget(MainWindow *main, QAction *action) :
CutterDockWidget(main, action),
ui(new Ui::RegisterRefsWidget)
ui(new Ui::RegisterRefsWidget),
tree(new CutterTreeWidget(this))
{
ui->setupUi(this);
// Add Status Bar footer
tree->addStatusBar(ui->verticalLayout);
registerRefModel = new RegisterRefModel(&registerRefs, this);
registerRefProxyModel = new RegisterRefProxyModel(registerRefModel, this);
ui->registerRefTreeView->setModel(registerRefProxyModel);
@ -135,6 +139,10 @@ RegisterRefsWidget::RegisterRefsWidget(MainWindow *main, QAction *action) :
ui->registerRefTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->registerRefTreeView, SIGNAL(customContextMenuRequested(const QPoint &)),
this, SLOT(showRegRefContextMenu(const QPoint &)));
connect(ui->quickFilterView, &QuickFilterView::filterTextChanged, this, [this] {
tree->showItemsNumber(registerRefProxyModel->rowCount());
});
}
RegisterRefsWidget::~RegisterRefsWidget() {}
@ -148,6 +156,8 @@ void RegisterRefsWidget::refreshRegisterRef()
ui->registerRefTreeView->resizeColumnToContents(0);
ui->registerRefTreeView->resizeColumnToContents(1);
ui->registerRefTreeView->resizeColumnToContents(2);
tree->showItemsNumber(registerRefProxyModel->rowCount());
}
void RegisterRefsWidget::setScrollMode()

View File

@ -4,6 +4,7 @@
#include "Cutter.h"
#include "CutterDockWidget.h"
#include "CutterTreeWidget.h"
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
@ -80,5 +81,6 @@ private:
QList<RegisterRefDescription> registerRefs;
QAction *actionCopyValue;
QAction *actionCopyRef;
CutterTreeWidget *tree;
void setScrollMode();
};

View File

@ -104,10 +104,14 @@ RelocsWidget::RelocsWidget(MainWindow *main, QAction *action) :
CutterDockWidget(main, action),
ui(new Ui::RelocsWidget),
relocsModel(new RelocsModel(&relocs, this)),
relocsProxyModel(new RelocsProxyModel(relocsModel, this))
relocsProxyModel(new RelocsProxyModel(relocsModel, this)),
tree(new CutterTreeWidget(this))
{
ui->setupUi(this);
// Add Status Bar footer
tree->addStatusBar(ui->verticalLayout);
ui->relocsTreeView->setModel(relocsProxyModel);
ui->relocsTreeView->sortByColumn(RelocsModel::NameColumn, Qt::AscendingOrder);
@ -125,6 +129,10 @@ RelocsWidget::RelocsWidget(MainWindow *main, QAction *action) :
relocsProxyModel, SLOT(setFilterWildcard(const QString &)));
connect(ui->quickFilterView, SIGNAL(filterClosed()), ui->relocsTreeView, SLOT(setFocus()));
connect(ui->quickFilterView, &QuickFilterView::filterTextChanged, this, [this] {
tree->showItemsNumber(relocsProxyModel->rowCount());
});
setScrollMode();
connect(Core(), SIGNAL(refreshAll()), this, SLOT(refreshRelocs()));
@ -146,6 +154,8 @@ void RelocsWidget::refreshRelocs()
relocs = Core()->getAllRelocs();
relocsModel->endResetModel();
qhelpers::adjustColumns(ui->relocsTreeView, 3, 0);
tree->showItemsNumber(relocsProxyModel->rowCount());
}
void RelocsWidget::setScrollMode()

View File

@ -7,6 +7,7 @@
#include "CutterDockWidget.h"
#include "Cutter.h"
#include "CutterTreeWidget.h"
class MainWindow;
class RelocsWidget;
@ -63,9 +64,11 @@ private slots:
private:
std::unique_ptr<Ui::RelocsWidget> ui;
RelocsModel *relocsModel;
RelocsProxyModel *relocsProxyModel;
QList<RelocDescription> relocs;
CutterTreeWidget *tree;
void setScrollMode();
};

View File

@ -122,10 +122,14 @@ bool StringsSortFilterProxyModel::lessThan(const QModelIndex &left, const QModel
StringsWidget::StringsWidget(MainWindow *main, QAction *action) :
CutterDockWidget(main, action),
ui(new Ui::StringsWidget)
ui(new Ui::StringsWidget),
tree(new CutterTreeWidget(this))
{
ui->setupUi(this);
// Add Status Bar footer
tree->addStatusBar(ui->verticalLayout);
qhelpers::setVerticalScrollMode(ui->stringsTreeView);
// Ctrl-F to show/hide the filter entry
@ -147,6 +151,10 @@ StringsWidget::StringsWidget(MainWindow *main, QAction *action) :
SLOT(setFilterWildcard(const QString &)));
connect(ui->quickFilterView, SIGNAL(filterClosed()), ui->stringsTreeView, SLOT(setFocus()));
connect(ui->quickFilterView, &QuickFilterView::filterTextChanged, this, [this] {
tree->showItemsNumber(proxy_model->rowCount());
});
connect(Core(), SIGNAL(refreshAll()), this, SLOT(refreshStrings()));
}
@ -183,5 +191,7 @@ void StringsWidget::stringSearchFinished(const QList<StringDescription> &strings
if (ui->stringsTreeView->columnWidth(1) > 300)
ui->stringsTreeView->setColumnWidth(1, 300);
tree->showItemsNumber(proxy_model->rowCount());
task = nullptr;
}

View File

@ -6,6 +6,7 @@
#include "Cutter.h"
#include "CutterDockWidget.h"
#include "utils/StringsTask.h"
#include "CutterTreeWidget.h"
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
@ -77,6 +78,7 @@ private:
StringsModel *model;
StringsSortFilterProxyModel *proxy_model;
QList<StringDescription> strings;
CutterTreeWidget *tree;
};
#endif // STRINGSWIDGET_H

View File

@ -102,10 +102,14 @@ bool SymbolsProxyModel::lessThan(const QModelIndex &left, const QModelIndex &rig
SymbolsWidget::SymbolsWidget(MainWindow *main, QAction *action) :
CutterDockWidget(main, action),
ui(new Ui::SymbolsWidget)
ui(new Ui::SymbolsWidget),
tree(new CutterTreeWidget(this))
{
ui->setupUi(this);
// Add Status Bar footer
tree->addStatusBar(ui->verticalLayout);
symbolsModel = new SymbolsModel(&symbols, this);
symbolsProxyModel = new SymbolsProxyModel(symbolsModel, this);
ui->symbolsTreeView->setModel(symbolsProxyModel);
@ -125,6 +129,10 @@ SymbolsWidget::SymbolsWidget(MainWindow *main, QAction *action) :
symbolsProxyModel, SLOT(setFilterWildcard(const QString &)));
connect(ui->quickFilterView, SIGNAL(filterClosed()), ui->symbolsTreeView, SLOT(setFocus()));
connect(ui->quickFilterView, &QuickFilterView::filterTextChanged, this, [this] {
tree->showItemsNumber(symbolsProxyModel->rowCount());
});
setScrollMode();
connect(Core(), SIGNAL(refreshAll()), this, SLOT(refreshSymbols()));
@ -149,6 +157,8 @@ void SymbolsWidget::refreshSymbols()
symbolsModel->endResetModel();
qhelpers::adjustColumns(ui->symbolsTreeView, SymbolsModel::ColumnCount, 0);
tree->showItemsNumber(symbolsProxyModel->rowCount());
}
void SymbolsWidget::setScrollMode()

View File

@ -7,6 +7,7 @@
#include "Cutter.h"
#include "CutterDockWidget.h"
#include "CutterTreeWidget.h"
class MainWindow;
class QTreeWidgetItem;
@ -66,9 +67,11 @@ private slots:
private:
std::unique_ptr<Ui::SymbolsWidget> ui;
QList<SymbolDescription> symbols;
SymbolsModel *symbolsModel;
SymbolsProxyModel *symbolsProxyModel;
CutterTreeWidget *tree;
void setScrollMode();
};

View File

@ -128,10 +128,14 @@ bool VTableSortFilterProxyModel::filterAcceptsRow(int source_row,
VTablesWidget::VTablesWidget(MainWindow *main, QAction *action) :
CutterDockWidget(main, action),
ui(new Ui::VTablesWidget)
ui(new Ui::VTablesWidget),
tree(new CutterTreeWidget(this))
{
ui->setupUi(this);
// Add Status Bar footer
tree->addStatusBar(ui->verticalLayout);
model = new VTableModel(&vtables, this);
proxy = new VTableSortFilterProxyModel(model);
@ -151,6 +155,10 @@ VTablesWidget::VTablesWidget(MainWindow *main, QAction *action) :
SLOT(setFilterWildcard(const QString &)));
connect(ui->quickFilterView, SIGNAL(filterClosed()), ui->vTableTreeView, SLOT(setFocus()));
connect(ui->quickFilterView, &QuickFilterView::filterTextChanged, this, [this] {
tree->showItemsNumber(proxy->rowCount());
});
connect(Core(), SIGNAL(refreshAll()), this, SLOT(refreshVTables()));
}
@ -167,6 +175,8 @@ void VTablesWidget::refreshVTables()
qhelpers::adjustColumns(ui->vTableTreeView, 3, 0);
ui->vTableTreeView->setColumnWidth(0, 200);
tree->showItemsNumber(proxy->rowCount());
}
void VTablesWidget::on_vTableTreeView_doubleClicked(const QModelIndex &index)

View File

@ -8,6 +8,7 @@
#include "Cutter.h"
#include "CutterDockWidget.h"
#include "CutterTreeWidget.h"
namespace Ui {
class VTablesWidget;
@ -68,6 +69,7 @@ private:
VTableModel *model;
QSortFilterProxyModel *proxy;
QList<VTableDescription> vtables;
CutterTreeWidget *tree;
};
#endif // VTABLESWIDGET_H