"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/widgets/ImportsWidget.cpp" between
cutter-1.8.3.tar.gz and cutter-1.9.0.tar.gz

About: cutter is a Qt and C++ GUI for radare2 reverse engineering framework.

ImportsWidget.cpp  (cutter-1.8.3):ImportsWidget.cpp  (cutter-1.9.0)
#include "ImportsWidget.h" #include "ImportsWidget.h"
#include "ui_ImportsWidget.h" #include "ui_ListDockWidget.h"
#include "WidgetShortcuts.h" #include "WidgetShortcuts.h"
#include "core/MainWindow.h" #include "core/MainWindow.h"
#include "common/Helpers.h" #include "common/Helpers.h"
#include <QPainter> #include <QPainter>
#include <QPen> #include <QPen>
#include <QShortcut> #include <QShortcut>
#include <QTreeWidget> #include <QTreeWidget>
ImportsModel::ImportsModel(QList<ImportDescription> *imports, QObject *parent) : ImportsModel::ImportsModel(QList<ImportDescription> *imports, QObject *parent) :
QAbstractTableModel(parent), AddressableItemModel(parent),
imports(imports) imports(imports)
{} {}
int ImportsModel::rowCount(const QModelIndex &parent) const int ImportsModel::rowCount(const QModelIndex &parent) const
{ {
return parent.isValid() ? 0 : imports->count(); return parent.isValid() ? 0 : imports->count();
} }
int ImportsModel::columnCount(const QModelIndex &) const int ImportsModel::columnCount(const QModelIndex &) const
{ {
skipping to change at line 84 skipping to change at line 84
return tr("Safety"); return tr("Safety");
case ImportsModel::NameColumn: case ImportsModel::NameColumn:
return tr("Name"); return tr("Name");
default: default:
break; break;
} }
} }
return QVariant(); return QVariant();
} }
RVA ImportsModel::address(const QModelIndex &index) const
{
const ImportDescription &import = imports->at(index.row());
return import.plt;
}
QString ImportsModel::name(const QModelIndex &index) const
{
const ImportDescription &import = imports->at(index.row());
return import.name;
}
ImportsProxyModel::ImportsProxyModel(ImportsModel *sourceModel, QObject *parent) ImportsProxyModel::ImportsProxyModel(ImportsModel *sourceModel, QObject *parent)
: QSortFilterProxyModel(parent) : AddressableFilterProxyModel(sourceModel, parent)
{ {
setSourceModel(sourceModel);
setFilterCaseSensitivity(Qt::CaseInsensitive); setFilterCaseSensitivity(Qt::CaseInsensitive);
setSortCaseSensitivity(Qt::CaseInsensitive); setSortCaseSensitivity(Qt::CaseInsensitive);
} }
bool ImportsProxyModel::filterAcceptsRow(int row, const QModelIndex &parent) con st bool ImportsProxyModel::filterAcceptsRow(int row, const QModelIndex &parent) con st
{ {
QModelIndex index = sourceModel()->index(row, 0, parent); QModelIndex index = sourceModel()->index(row, 0, parent);
auto import = index.data(ImportsModel::ImportDescriptionRole).value<ImportDe scription>(); auto import = index.data(ImportsModel::ImportDescriptionRole).value<ImportDe scription>();
return import.name.contains(filterRegExp()); return import.name.contains(filterRegExp());
skipping to change at line 132 skipping to change at line 143
} }
return false; return false;
} }
/* /*
* Imports Widget * Imports Widget
*/ */
ImportsWidget::ImportsWidget(MainWindow *main, QAction *action) : ImportsWidget::ImportsWidget(MainWindow *main, QAction *action) :
CutterDockWidget(main, action), ListDockWidget(main, action),
ui(new Ui::ImportsWidget),
importsModel(new ImportsModel(&imports, this)), importsModel(new ImportsModel(&imports, this)),
importsProxyModel(new ImportsProxyModel(importsModel, this)), importsProxyModel(new ImportsProxyModel(importsModel, this))
tree(new CutterTreeWidget(this))
{ {
ui->setupUi(this); setWindowTitle(tr("Imports"));
setObjectName("ImportsWidget");
// Add Status Bar footer
tree->addStatusBar(ui->verticalLayout);
ui->importsTreeView->setModel(importsProxyModel);
ui->importsTreeView->sortByColumn(ImportsModel::NameColumn, Qt::AscendingOrd
er);
setModels(importsProxyModel);
ui->treeView->sortByColumn(ImportsModel::NameColumn, Qt::AscendingOrder);
QShortcut *toggle_shortcut = new QShortcut(widgetShortcuts["ImportsWidget"], main); QShortcut *toggle_shortcut = new QShortcut(widgetShortcuts["ImportsWidget"], main);
connect(toggle_shortcut, &QShortcut::activated, this, [=] (){ connect(toggle_shortcut, &QShortcut::activated, this, [=] (){
toggleDockWidget(true); toggleDockWidget(true);
main->updateDockActionChecked(action); main->updateDockActionChecked(action);
} ); } );
// Ctrl-F to show/hide the filter entry
QShortcut *searchShortcut = new QShortcut(QKeySequence::Find, this);
connect(searchShortcut, &QShortcut::activated, ui->quickFilterView, &QuickFi
lterView::showFilter);
searchShortcut->setContext(Qt::WidgetWithChildrenShortcut);
// Esc to clear the filter entry
QShortcut *clearShortcut = new QShortcut(QKeySequence(Qt::Key_Escape), this)
;
connect(clearShortcut, &QShortcut::activated, ui->quickFilterView, &QuickFil
terView::clearFilter);
clearShortcut->setContext(Qt::WidgetWithChildrenShortcut);
connect(ui->quickFilterView, SIGNAL(filterTextChanged(const QString &)),
importsProxyModel, SLOT(setFilterWildcard(const QString &)));
connect(ui->quickFilterView, SIGNAL(filterClosed()), ui->importsTreeView, SL
OT(setFocus()));
connect(ui->quickFilterView, &QuickFilterView::filterTextChanged, this, [thi
s] {
tree->showItemsNumber(importsProxyModel->rowCount());
});
setScrollMode();
connect(Core(), SIGNAL(refreshAll()), this, SLOT(refreshImports())); connect(Core(), SIGNAL(refreshAll()), this, SLOT(refreshImports()));
} }
ImportsWidget::~ImportsWidget() {} ImportsWidget::~ImportsWidget() {}
void ImportsWidget::refreshImports() void ImportsWidget::refreshImports()
{ {
importsModel->beginResetModel(); importsModel->beginResetModel();
imports = Core()->getAllImports(); imports = Core()->getAllImports();
importsModel->endResetModel(); importsModel->endResetModel();
qhelpers::adjustColumns(ui->importsTreeView, 4, 0); qhelpers::adjustColumns(ui->treeView, 4, 0);
tree->showItemsNumber(importsProxyModel->rowCount());
}
void ImportsWidget::setScrollMode()
{
qhelpers::setVerticalScrollMode(ui->importsTreeView);
}
void ImportsWidget::on_importsTreeView_doubleClicked(const QModelIndex &index)
{
if (!index.isValid())
return;
Core()->seek(index.data(ImportsModel::AddressRole).toLongLong());
} }
 End of changes. 11 change blocks. 
57 lines changed or deleted 22 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)