mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-12 07:36:16 +00:00
Show comment column in each panel that have "add comment" option in the context menu (#2441)
This commit is contained in:
parent
e236f6b0fc
commit
ca3d8ce78f
@ -269,5 +269,15 @@ void selectIndexByData(QComboBox *widget, QVariant data, int defaultIndex)
|
||||
widget->setCurrentIndex(defaultIndex);
|
||||
}
|
||||
|
||||
void emitColumnChanged(QAbstractItemModel *model, int column)
|
||||
{
|
||||
if (model && model->rowCount()) {
|
||||
emit model->dataChanged(
|
||||
model->index(0, column),
|
||||
model->index(model->rowCount() - 1, column),
|
||||
{ Qt::DisplayRole }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
|
@ -15,6 +15,7 @@ class QString;
|
||||
class QTreeWidget;
|
||||
class QTreeWidgetItem;
|
||||
class QAbstractItemView;
|
||||
class QAbstractItemModel;
|
||||
class QAbstractButton;
|
||||
class QWidget;
|
||||
class QTreeView;
|
||||
@ -71,6 +72,12 @@ CUTTER_EXPORT qreal devicePixelRatio(const QPaintDevice *p);
|
||||
* @param defaultIndex - item to select in case no match
|
||||
*/
|
||||
CUTTER_EXPORT void selectIndexByData(QComboBox *comboBox, QVariant data, int defaultIndex = -1);
|
||||
/**
|
||||
* @brief Emit data change signal in a model's column (DisplayRole)
|
||||
* @param model - model containing data with changes
|
||||
* @param column - column in the model
|
||||
*/
|
||||
CUTTER_EXPORT void emitColumnChanged(QAbstractItemModel *model, int column);
|
||||
|
||||
} // qhelpers
|
||||
|
||||
|
@ -53,6 +53,11 @@ XrefsDialog::XrefsDialog(MainWindow *main, QWidget *parent, bool hideXrefFrom) :
|
||||
connect(ui->toTreeWidget, &QAbstractItemView::doubleClicked, this, &QWidget::close);
|
||||
connect(ui->fromTreeWidget, &QAbstractItemView::doubleClicked, this, &QWidget::close);
|
||||
|
||||
connect(Core(), &CutterCore::commentsChanged, this, [this]() {
|
||||
qhelpers::emitColumnChanged(&toModel, XrefModel::COMMENT);
|
||||
qhelpers::emitColumnChanged(&fromModel, XrefModel::COMMENT);
|
||||
});
|
||||
|
||||
if (hideXrefFrom) {
|
||||
hideXrefFromSection();
|
||||
}
|
||||
@ -263,6 +268,8 @@ QVariant XrefModel::data(const QModelIndex &index, int role) const
|
||||
} else {
|
||||
return QString();
|
||||
}
|
||||
case COMMENT:
|
||||
return to ? Core()->getCommentAt(xref.from) : Core()->getCommentAt(xref.to);
|
||||
}
|
||||
return QVariant();
|
||||
case FlagDescriptionRole:
|
||||
@ -286,6 +293,8 @@ QVariant XrefModel::headerData(int section, Qt::Orientation orientation, int rol
|
||||
return tr("Type");
|
||||
case CODE:
|
||||
return tr("Code");
|
||||
case COMMENT:
|
||||
return tr("Comment");
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ private:
|
||||
QList<XrefDescription> xrefs;
|
||||
bool to;
|
||||
public:
|
||||
enum Columns { OFFSET = 0, TYPE, CODE, COUNT };
|
||||
enum Columns { OFFSET = 0, TYPE, CODE, COMMENT, COUNT };
|
||||
static const int FlagDescriptionRole = Qt::UserRole;
|
||||
|
||||
XrefModel(QObject *parent = nullptr);
|
||||
|
@ -69,6 +69,8 @@ QVariant BreakpointModel::data(const QModelIndex &index, int role) const
|
||||
return breakpoint.trace;
|
||||
case EnabledColumn:
|
||||
return breakpoint.enabled;
|
||||
case CommentColumn:
|
||||
return Core()->getCommentAt(breakpoint.addr);
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -105,6 +107,8 @@ QVariant BreakpointModel::headerData(int section, Qt::Orientation, int role) con
|
||||
return tr("Tracing");
|
||||
case EnabledColumn:
|
||||
return tr("Enabled");
|
||||
case CommentColumn:
|
||||
return tr("Comment");
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -216,6 +220,9 @@ BreakpointWidget::BreakpointWidget(MainWindow *main) :
|
||||
connect(Core(), &CutterCore::breakpointsChanged, this, &BreakpointWidget::refreshBreakpoint);
|
||||
connect(Core(), &CutterCore::codeRebased, this, &BreakpointWidget::refreshBreakpoint);
|
||||
connect(Core(), &CutterCore::refreshCodeViews, this, &BreakpointWidget::refreshBreakpoint);
|
||||
connect(Core(), &CutterCore::commentsChanged, this, [this]() {
|
||||
qhelpers::emitColumnChanged(breakpointModel, BreakpointModel::CommentColumn);
|
||||
});
|
||||
connect(ui->addBreakpoint, &QAbstractButton::clicked, this, &BreakpointWidget::addBreakpointDialog);
|
||||
connect(ui->delBreakpoint, &QAbstractButton::clicked, this, &BreakpointWidget::delBreakpoint);
|
||||
connect(ui->delAllBreakpoints, &QAbstractButton::clicked, Core(), &CutterCore::delAllBreakpoints);
|
||||
|
@ -31,7 +31,7 @@ private:
|
||||
QList<BreakpointDescription> breakpoints;
|
||||
|
||||
public:
|
||||
enum Column { AddrColumn = 0, NameColumn, TypeColumn, TraceColumn, EnabledColumn, ColumnCount };
|
||||
enum Column { AddrColumn = 0, NameColumn, TypeColumn, TraceColumn, EnabledColumn, CommentColumn, ColumnCount };
|
||||
enum Role { BreakpointDescriptionRole = Qt::UserRole };
|
||||
|
||||
BreakpointModel(QObject *parent = nullptr);
|
||||
|
@ -40,6 +40,8 @@ QVariant ExportsModel::data(const QModelIndex &index, int role) const
|
||||
return exp.type;
|
||||
case ExportsModel::NameColumn:
|
||||
return exp.name;
|
||||
case ExportsModel::CommentColumn:
|
||||
return Core()->getCommentAt(exp.vaddr);
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -63,6 +65,8 @@ QVariant ExportsModel::headerData(int section, Qt::Orientation, int role) const
|
||||
return tr("Type");
|
||||
case ExportsModel::NameColumn:
|
||||
return tr("Name");
|
||||
case ExportsModel::CommentColumn:
|
||||
return tr("Comment");
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -117,6 +121,8 @@ bool ExportsProxyModel::lessThan(const QModelIndex &left, const QModelIndex &rig
|
||||
case ExportsModel::TypeColumn:
|
||||
if (leftExp.type != rightExp.type)
|
||||
return leftExp.type < rightExp.type;
|
||||
case ExportsModel::CommentColumn:
|
||||
return Core()->getCommentAt(leftExp.vaddr) < Core()->getCommentAt(rightExp.vaddr);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -143,6 +149,9 @@ ExportsWidget::ExportsWidget(MainWindow *main) :
|
||||
|
||||
connect(Core(), &CutterCore::codeRebased, this, &ExportsWidget::refreshExports);
|
||||
connect(Core(), &CutterCore::refreshAll, this, &ExportsWidget::refreshExports);
|
||||
connect(Core(), &CutterCore::commentsChanged, this, [this]() {
|
||||
qhelpers::emitColumnChanged(exportsModel, ExportsModel::CommentColumn);
|
||||
});
|
||||
}
|
||||
|
||||
ExportsWidget::~ExportsWidget() {}
|
||||
|
@ -28,7 +28,7 @@ private:
|
||||
QList<ExportDescription> *exports;
|
||||
|
||||
public:
|
||||
enum Column { OffsetColumn = 0, SizeColumn, TypeColumn, NameColumn, ColumnCount };
|
||||
enum Column { OffsetColumn = 0, SizeColumn, TypeColumn, NameColumn, CommentColumn, ColumnCount };
|
||||
enum Role { ExportDescriptionRole = Qt::UserRole };
|
||||
|
||||
ExportsModel(QList<ExportDescription> *exports, QObject *parent = nullptr);
|
||||
|
@ -44,6 +44,8 @@ QVariant FlagsModel::data(const QModelIndex &index, int role) const
|
||||
return flag.name;
|
||||
case REALNAME:
|
||||
return flag.realname;
|
||||
case COMMENT:
|
||||
return Core()->getCommentAt(flag.offset);
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -67,6 +69,8 @@ QVariant FlagsModel::headerData(int section, Qt::Orientation, int role) const
|
||||
return tr("Name");
|
||||
case REALNAME:
|
||||
return tr("Real Name");
|
||||
case COMMENT:
|
||||
return tr("Comment");
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -128,6 +132,9 @@ bool FlagsSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIn
|
||||
case FlagsModel::REALNAME:
|
||||
return left_flag->realname < right_flag->realname;
|
||||
|
||||
case FlagsModel::COMMENT:
|
||||
return Core()->getCommentAt(left_flag->offset) < Core()->getCommentAt(right_flag->offset);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -181,6 +188,9 @@ FlagsWidget::FlagsWidget(MainWindow *main) :
|
||||
connect(Core(), &CutterCore::flagsChanged, this, &FlagsWidget::flagsChanged);
|
||||
connect(Core(), &CutterCore::codeRebased, this, &FlagsWidget::flagsChanged);
|
||||
connect(Core(), &CutterCore::refreshAll, this, &FlagsWidget::refreshFlagspaces);
|
||||
connect(Core(), &CutterCore::commentsChanged, this, [this]() {
|
||||
qhelpers::emitColumnChanged(flags_model, FlagsModel::COMMENT);
|
||||
});
|
||||
|
||||
auto menu = ui->flagsTreeView->getItemContextMenu();
|
||||
menu->addSeparator();
|
||||
|
@ -26,7 +26,7 @@ private:
|
||||
QList<FlagDescription> *flags;
|
||||
|
||||
public:
|
||||
enum Columns { OFFSET = 0, SIZE, NAME, REALNAME, COUNT };
|
||||
enum Columns { OFFSET = 0, SIZE, NAME, REALNAME, COMMENT, COUNT };
|
||||
static const int FlagDescriptionRole = Qt::UserRole;
|
||||
|
||||
FlagsModel(QList<FlagDescription> *flags, QObject *parent = nullptr);
|
||||
|
@ -136,6 +136,8 @@ QVariant FunctionModel::data(const QModelIndex &index, int role) const
|
||||
return tr("Edges: %1").arg(function.edges);
|
||||
case 8:
|
||||
return tr("StackFrame: %1").arg(function.stackframe);
|
||||
case 9:
|
||||
return tr("Comment: %1").arg(Core()->getCommentAt(function.offset));
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -161,6 +163,8 @@ QVariant FunctionModel::data(const QModelIndex &index, int role) const
|
||||
return QString::number(function.edges);
|
||||
case FrameColumn:
|
||||
return QString::number(function.stackframe);
|
||||
case CommentColumn:
|
||||
return Core()->getCommentAt(function.offset);
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -268,6 +272,8 @@ QVariant FunctionModel::headerData(int section, Qt::Orientation orientation, int
|
||||
return tr("Edges");
|
||||
case FrameColumn:
|
||||
return tr("StackFrame");
|
||||
case CommentColumn:
|
||||
return tr("Comment");
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -416,6 +422,8 @@ bool FunctionSortFilterProxyModel::lessThan(const QModelIndex &left, const QMode
|
||||
if (left_function.stackframe != right_function.stackframe)
|
||||
return left_function.stackframe < right_function.stackframe;
|
||||
break;
|
||||
case FunctionModel::CommentColumn:
|
||||
return Core()->getCommentAt(left_function.offset) < Core()->getCommentAt(right_function.offset);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@ -482,6 +490,9 @@ FunctionsWidget::FunctionsWidget(MainWindow *main) :
|
||||
connect(Core(), &CutterCore::functionsChanged, this, &FunctionsWidget::refreshTree);
|
||||
connect(Core(), &CutterCore::codeRebased, this, &FunctionsWidget::refreshTree);
|
||||
connect(Core(), &CutterCore::refreshAll, this, &FunctionsWidget::refreshTree);
|
||||
connect(Core(), &CutterCore::commentsChanged, this, [this]() {
|
||||
qhelpers::emitColumnChanged(functionModel, FunctionModel::CommentColumn);
|
||||
});
|
||||
}
|
||||
|
||||
FunctionsWidget::~FunctionsWidget() {}
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
static const int IsImportRole = Qt::UserRole + 1;
|
||||
|
||||
enum Column { NameColumn = 0, SizeColumn, ImportColumn, OffsetColumn, NargsColumn, NlocalsColumn,
|
||||
NbbsColumn, CalltypeColumn, EdgesColumn, FrameColumn, ColumnCount
|
||||
NbbsColumn, CalltypeColumn, EdgesColumn, FrameColumn, CommentColumn, ColumnCount
|
||||
};
|
||||
|
||||
FunctionModel(QList<FunctionDescription> *functions, QSet<RVA> *importAddresses, ut64 *mainAdress,
|
||||
|
@ -35,6 +35,8 @@ QVariant HeadersModel::data(const QModelIndex &index, int role) const
|
||||
return header.name;
|
||||
case ValueColumn:
|
||||
return header.value;
|
||||
case CommentColumn:
|
||||
return Core()->getCommentAt(header.vaddr);
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -56,6 +58,8 @@ QVariant HeadersModel::headerData(int section, Qt::Orientation, int role) const
|
||||
return tr("Name");
|
||||
case ValueColumn:
|
||||
return tr("Value");
|
||||
case CommentColumn:
|
||||
return tr("Comment");
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -102,6 +106,8 @@ bool HeadersProxyModel::lessThan(const QModelIndex &left, const QModelIndex &rig
|
||||
return leftHeader.name < rightHeader.name;
|
||||
case HeadersModel::ValueColumn:
|
||||
return leftHeader.value < rightHeader.value;
|
||||
case HeadersModel::CommentColumn:
|
||||
return Core()->getCommentAt(leftHeader.vaddr) < Core()->getCommentAt(rightHeader.vaddr);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -125,6 +131,9 @@ HeadersWidget::HeadersWidget(MainWindow *main) :
|
||||
|
||||
connect(Core(), &CutterCore::codeRebased, this, &HeadersWidget::refreshHeaders);
|
||||
connect(Core(), &CutterCore::refreshAll, this, &HeadersWidget::refreshHeaders);
|
||||
connect(Core(), &CutterCore::commentsChanged, this, [this]() {
|
||||
qhelpers::emitColumnChanged(headersModel, HeadersModel::CommentColumn);
|
||||
});
|
||||
}
|
||||
|
||||
HeadersWidget::~HeadersWidget() {}
|
||||
|
@ -32,7 +32,7 @@ private:
|
||||
QList<HeaderDescription> *headers;
|
||||
|
||||
public:
|
||||
enum Column { OffsetColumn = 0, NameColumn, ValueColumn, ColumnCount };
|
||||
enum Column { OffsetColumn = 0, NameColumn, ValueColumn, CommentColumn, ColumnCount };
|
||||
enum Role { HeaderDescriptionRole = Qt::UserRole };
|
||||
|
||||
HeadersModel(QList<HeaderDescription> *headers, QObject *parent = nullptr);
|
||||
|
@ -50,6 +50,8 @@ QVariant ImportsModel::data(const QModelIndex &index, int role) const
|
||||
return import.libname;
|
||||
case ImportsModel::NameColumn:
|
||||
return import.name;
|
||||
case ImportsModel::CommentColumn:
|
||||
return Core()->getCommentAt(import.plt);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -78,6 +80,8 @@ QVariant ImportsModel::headerData(int section, Qt::Orientation, int role) const
|
||||
return tr("Library");
|
||||
case ImportsModel::NameColumn:
|
||||
return tr("Name");
|
||||
case ImportsModel::CommentColumn:
|
||||
return tr("Comment");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -142,7 +146,9 @@ bool ImportsProxyModel::lessThan(const QModelIndex &left, const QModelIndex &rig
|
||||
// Fallthrough. Sort by Library and then by import name
|
||||
case ImportsModel::NameColumn:
|
||||
return leftImport.name < rightImport.name;
|
||||
|
||||
case ImportsModel::CommentColumn:
|
||||
return Core()->getCommentAt(leftImport.plt) < Core()->getCommentAt(rightImport.plt);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -172,6 +178,9 @@ ImportsWidget::ImportsWidget(MainWindow *main) :
|
||||
|
||||
connect(Core(), &CutterCore::codeRebased, this, &ImportsWidget::refreshImports);
|
||||
connect(Core(), &CutterCore::refreshAll, this, &ImportsWidget::refreshImports);
|
||||
connect(Core(), &CutterCore::commentsChanged, this, [this]() {
|
||||
qhelpers::emitColumnChanged(importsModel, ImportsModel::CommentColumn);
|
||||
});
|
||||
}
|
||||
|
||||
ImportsWidget::~ImportsWidget() {}
|
||||
|
@ -43,7 +43,7 @@ private:
|
||||
QList<ImportDescription> *imports;
|
||||
|
||||
public:
|
||||
enum Column { AddressColumn = 0, TypeColumn, LibraryColumn, NameColumn, SafetyColumn, ColumnCount };
|
||||
enum Column { AddressColumn = 0, TypeColumn, LibraryColumn, NameColumn, SafetyColumn, CommentColumn, ColumnCount };
|
||||
enum Role { ImportDescriptionRole = Qt::UserRole, AddressRole };
|
||||
|
||||
ImportsModel(QList<ImportDescription> *imports, QObject *parent = nullptr);
|
||||
|
@ -38,6 +38,8 @@ QVariant MemoryMapModel::data(const QModelIndex &index, int role) const
|
||||
return memoryMap.name;
|
||||
case PermColumn:
|
||||
return memoryMap.permission;
|
||||
case CommentColumn:
|
||||
return Core()->getCommentAt(memoryMap.addrStart);
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -61,6 +63,8 @@ QVariant MemoryMapModel::headerData(int section, Qt::Orientation, int role) cons
|
||||
return tr("Name");
|
||||
case PermColumn:
|
||||
return tr("Permissions");
|
||||
case CommentColumn:
|
||||
return tr("Comment");
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -104,6 +108,8 @@ bool MemoryProxyModel::lessThan(const QModelIndex &left, const QModelIndex &righ
|
||||
return leftMemMap.name < rightMemMap.name;
|
||||
case MemoryMapModel::PermColumn:
|
||||
return leftMemMap.permission < rightMemMap.permission;
|
||||
case MemoryMapModel::CommentColumn:
|
||||
return Core()->getCommentAt(leftMemMap.addrStart) < Core()->getCommentAt(rightMemMap.addrStart);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -128,6 +134,9 @@ MemoryMapWidget::MemoryMapWidget(MainWindow *main) :
|
||||
|
||||
connect(Core(), &CutterCore::refreshAll, this, &MemoryMapWidget::refreshMemoryMap);
|
||||
connect(Core(), &CutterCore::registersChanged, this, &MemoryMapWidget::refreshMemoryMap);
|
||||
connect(Core(), &CutterCore::commentsChanged, this, [this]() {
|
||||
qhelpers::emitColumnChanged(memoryModel, MemoryMapModel::CommentColumn);
|
||||
});
|
||||
|
||||
showCount(false);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ private:
|
||||
QList<MemoryMapDescription> *memoryMaps;
|
||||
|
||||
public:
|
||||
enum Column { AddrStartColumn = 0, AddrEndColumn, NameColumn, PermColumn, ColumnCount };
|
||||
enum Column { AddrStartColumn = 0, AddrEndColumn, NameColumn, PermColumn, CommentColumn, ColumnCount };
|
||||
enum Role { MemoryDescriptionRole = Qt::UserRole };
|
||||
|
||||
MemoryMapModel(QList<MemoryMapDescription> *memoryMaps, QObject *parent = nullptr);
|
||||
|
@ -40,6 +40,8 @@ QVariant RegisterRefModel::data(const QModelIndex &index, int role) const
|
||||
return registerRef.value;
|
||||
case RefColumn:
|
||||
return registerRef.refDesc.ref;
|
||||
case CommentColumn:
|
||||
return Core()->getCommentAt(Core()->math(registerRef.value));
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -68,6 +70,8 @@ QVariant RegisterRefModel::headerData(int section, Qt::Orientation, int role) co
|
||||
return tr("Value");
|
||||
case RefColumn:
|
||||
return tr("Reference");
|
||||
case CommentColumn:
|
||||
return tr("Comment");
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -104,6 +108,8 @@ bool RegisterRefProxyModel::lessThan(const QModelIndex &left, const QModelIndex
|
||||
return leftRegRef.refDesc.ref < rightRegRef.refDesc.ref;
|
||||
case RegisterRefModel::ValueColumn:
|
||||
return leftRegRef.value < rightRegRef.value;
|
||||
case RegisterRefModel::CommentColumn:
|
||||
return Core()->getCommentAt(Core()->math(leftRegRef.value)) < Core()->getCommentAt(Core()->math(rightRegRef.value));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -155,6 +161,9 @@ RegisterRefsWidget::RegisterRefsWidget(MainWindow *main) :
|
||||
setScrollMode();
|
||||
connect(Core(), &CutterCore::refreshAll, this, &RegisterRefsWidget::refreshRegisterRef);
|
||||
connect(Core(), &CutterCore::registersChanged, this, &RegisterRefsWidget::refreshRegisterRef);
|
||||
connect(Core(), &CutterCore::commentsChanged, this, [this]() {
|
||||
qhelpers::emitColumnChanged(registerRefModel, RegisterRefModel::CommentColumn);
|
||||
});
|
||||
connect(actionCopyValue, &QAction::triggered, this, [this] () {
|
||||
copyClip(RegisterRefModel::ValueColumn);
|
||||
});
|
||||
|
@ -39,7 +39,7 @@ private:
|
||||
QList<RegisterRefDescription> *registerRefs;
|
||||
|
||||
public:
|
||||
enum Column { RegColumn = 0, ValueColumn, RefColumn, ColumnCount };
|
||||
enum Column { RegColumn = 0, ValueColumn, RefColumn, CommentColumn, ColumnCount };
|
||||
enum Role { RegisterRefDescriptionRole = Qt::UserRole };
|
||||
|
||||
RegisterRefModel(QList<RegisterRefDescription> *registerRefs, QObject *parent = 0);
|
||||
|
@ -33,6 +33,8 @@ QVariant RelocsModel::data(const QModelIndex &index, int role) const
|
||||
return reloc.type;
|
||||
case RelocsModel::NameColumn:
|
||||
return reloc.name;
|
||||
case RelocsModel::CommentColumn:
|
||||
return Core()->getCommentAt(reloc.vaddr);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -57,6 +59,8 @@ QVariant RelocsModel::headerData(int section, Qt::Orientation, int role) const
|
||||
return tr("Type");
|
||||
case RelocsModel::NameColumn:
|
||||
return tr("Name");
|
||||
case RelocsModel::CommentColumn:
|
||||
return tr("Comment");
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
@ -106,6 +110,8 @@ bool RelocsProxyModel::lessThan(const QModelIndex &left, const QModelIndex &righ
|
||||
return leftReloc.type < rightReloc.type;
|
||||
case RelocsModel::NameColumn:
|
||||
return leftReloc.name < rightReloc.name;
|
||||
case RelocsModel::CommentColumn:
|
||||
return Core()->getCommentAt(leftReloc.vaddr) < Core()->getCommentAt(rightReloc.vaddr);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -126,6 +132,9 @@ RelocsWidget::RelocsWidget(MainWindow *main) :
|
||||
|
||||
connect(Core(), &CutterCore::codeRebased, this, &RelocsWidget::refreshRelocs);
|
||||
connect(Core(), &CutterCore::refreshAll, this, &RelocsWidget::refreshRelocs);
|
||||
connect(Core(), &CutterCore::commentsChanged, this, [this]() {
|
||||
qhelpers::emitColumnChanged(relocsModel, RelocsModel::CommentColumn);
|
||||
});
|
||||
}
|
||||
|
||||
RelocsWidget::~RelocsWidget() {}
|
||||
|
@ -22,7 +22,7 @@ private:
|
||||
QList<RelocDescription> *relocs;
|
||||
|
||||
public:
|
||||
enum Column { VAddrColumn = 0, TypeColumn, NameColumn, ColumnCount };
|
||||
enum Column { VAddrColumn = 0, TypeColumn, NameColumn, CommentColumn, ColumnCount };
|
||||
enum Role { RelocDescriptionRole = Qt::UserRole, AddressRole };
|
||||
|
||||
RelocsModel(QList<RelocDescription> *relocs, QObject *parent = nullptr);
|
||||
|
@ -39,6 +39,8 @@ QVariant ResourcesModel::data(const QModelIndex &index, int role) const
|
||||
return qhelpers::formatBytecount(res.size);
|
||||
case LANG:
|
||||
return res.lang;
|
||||
case COMMENT:
|
||||
return Core()->getCommentAt(res.vaddr);
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -83,6 +85,8 @@ QVariant ResourcesModel::headerData(int section, Qt::Orientation, int role) cons
|
||||
return tr("Size");
|
||||
case LANG:
|
||||
return tr("Lang");
|
||||
case COMMENT:
|
||||
return tr("Comment");
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -115,6 +119,9 @@ ResourcesWidget::ResourcesWidget(MainWindow *main) :
|
||||
this->setWindowTitle(tr("Resources"));
|
||||
|
||||
connect(Core(), &CutterCore::refreshAll, this, &ResourcesWidget::refreshResources);
|
||||
connect(Core(), &CutterCore::commentsChanged, this, [this]() {
|
||||
qhelpers::emitColumnChanged(model, ResourcesModel::COMMENT);
|
||||
});
|
||||
}
|
||||
|
||||
void ResourcesWidget::refreshResources()
|
||||
|
@ -21,7 +21,7 @@ private:
|
||||
QList<ResourcesDescription> *resources;
|
||||
|
||||
public:
|
||||
enum Columns { INDEX = 0, NAME, VADDR, TYPE, SIZE, LANG, COUNT };
|
||||
enum Columns { INDEX = 0, NAME, VADDR, TYPE, SIZE, LANG, COMMENT, COUNT };
|
||||
explicit ResourcesModel(QList<ResourcesDescription> *resources, QObject *parent = nullptr);
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
@ -67,6 +67,8 @@ QVariant SearchModel::data(const QModelIndex &index, int role) const
|
||||
return exp.code;
|
||||
case DATA:
|
||||
return exp.data;
|
||||
case COMMENT:
|
||||
return Core()->getCommentAt(exp.offset);
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -115,6 +117,8 @@ QVariant SearchModel::headerData(int section, Qt::Orientation, int role) const
|
||||
return tr("Code");
|
||||
case DATA:
|
||||
return tr("Data");
|
||||
case COMMENT:
|
||||
return tr("Comment");
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -159,6 +163,8 @@ bool SearchSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelI
|
||||
return left_search.code < right_search.code;
|
||||
case SearchModel::DATA:
|
||||
return left_search.data < right_search.data;
|
||||
case SearchModel::COMMENT:
|
||||
return Core()->getCommentAt(left_search.offset) < Core()->getCommentAt(right_search.offset);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -186,6 +192,9 @@ SearchWidget::SearchWidget(MainWindow *main) :
|
||||
|
||||
connect(Core(), &CutterCore::toggleDebugView, this, &SearchWidget::updateSearchBoundaries);
|
||||
connect(Core(), &CutterCore::refreshAll, this, &SearchWidget::refreshSearchspaces);
|
||||
connect(Core(), &CutterCore::commentsChanged, this, [this]() {
|
||||
qhelpers::emitColumnChanged(search_model, SearchModel::COMMENT);
|
||||
});
|
||||
|
||||
QShortcut *enter_press = new QShortcut(QKeySequence(Qt::Key_Return), this);
|
||||
connect(enter_press, &QShortcut::activated, this, [this]() {
|
||||
@ -305,7 +314,6 @@ void SearchWidget::updatePlaceholderText(int index)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SearchWidget::on_searchInCombo_currentIndexChanged(int index)
|
||||
{
|
||||
Config()->setConfig("search.in",
|
||||
|
@ -25,7 +25,7 @@ private:
|
||||
QList<SearchDescription> *search;
|
||||
|
||||
public:
|
||||
enum Columns { OFFSET = 0, SIZE, CODE, DATA, COUNT };
|
||||
enum Columns { OFFSET = 0, SIZE, CODE, DATA, COMMENT, COUNT };
|
||||
static const int SearchDescriptionRole = Qt::UserRole;
|
||||
|
||||
SearchModel(QList<SearchDescription> *search, QObject *parent = nullptr);
|
||||
|
@ -68,6 +68,8 @@ QVariant SectionsModel::data(const QModelIndex &index, int role) const
|
||||
return section.perm;
|
||||
case SectionsModel::EntropyColumn:
|
||||
return section.entropy;
|
||||
case SectionsModel::CommentColumn:
|
||||
return Core()->getCommentAt(section.vaddr);
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -101,6 +103,8 @@ QVariant SectionsModel::headerData(int section, Qt::Orientation, int role) const
|
||||
return tr("Permissions");
|
||||
case SectionsModel::EntropyColumn:
|
||||
return tr("Entropy");
|
||||
case SectionsModel::CommentColumn:
|
||||
return tr("Comment");
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -151,6 +155,8 @@ bool SectionsProxyModel::lessThan(const QModelIndex &left, const QModelIndex &ri
|
||||
return leftSection.perm < rightSection.perm;
|
||||
case SectionsModel::EntropyColumn:
|
||||
return leftSection.entropy < rightSection.entropy;
|
||||
case SectionsModel::CommentColumn:
|
||||
return Core()->getCommentAt(leftSection.vaddr) < Core()->getCommentAt(rightSection.vaddr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -239,6 +245,9 @@ void SectionsWidget::initConnects()
|
||||
updateToggle();
|
||||
}
|
||||
});
|
||||
connect(Core(), &CutterCore::commentsChanged, this, [this]() {
|
||||
qhelpers::emitColumnChanged(sectionsModel, SectionsModel::CommentColumn);
|
||||
});
|
||||
}
|
||||
|
||||
void SectionsWidget::refreshSections()
|
||||
|
@ -36,7 +36,7 @@ private:
|
||||
QList<SectionDescription> *sections;
|
||||
|
||||
public:
|
||||
enum Column { NameColumn = 0, SizeColumn, AddressColumn, EndAddressColumn, VirtualSizeColumn, PermissionsColumn, EntropyColumn, ColumnCount };
|
||||
enum Column { NameColumn = 0, SizeColumn, AddressColumn, EndAddressColumn, VirtualSizeColumn, PermissionsColumn, EntropyColumn, CommentColumn, ColumnCount };
|
||||
enum Role { SectionDescriptionRole = Qt::UserRole };
|
||||
|
||||
SectionsModel(QList<SectionDescription> *sections, QObject *parent = nullptr);
|
||||
|
@ -56,6 +56,8 @@ QVariant SegmentsModel::data(const QModelIndex &index, int role) const
|
||||
return RAddressString(segment.vaddr + segment.size);
|
||||
case SegmentsModel::PermColumn:
|
||||
return segment.perm;
|
||||
case SegmentsModel::CommentColumn:
|
||||
return Core()->getCommentAt(segment.vaddr);
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -85,6 +87,8 @@ QVariant SegmentsModel::headerData(int segment, Qt::Orientation, int role) const
|
||||
return tr("End Address");
|
||||
case SegmentsModel::PermColumn:
|
||||
return tr("Permissions");
|
||||
case SegmentsModel::CommentColumn:
|
||||
return tr("Comment");
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -124,6 +128,8 @@ bool SegmentsProxyModel::lessThan(const QModelIndex &left, const QModelIndex &ri
|
||||
case SegmentsModel::AddressColumn:
|
||||
case SegmentsModel::EndAddressColumn:
|
||||
return leftSegment.vaddr < rightSegment.vaddr;
|
||||
case SegmentsModel::CommentColumn:
|
||||
return Core()->getCommentAt(leftSegment.vaddr) < Core()->getCommentAt(rightSegment.vaddr);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -147,6 +153,9 @@ SegmentsWidget::SegmentsWidget(MainWindow *main) :
|
||||
|
||||
connect(Core(), &CutterCore::refreshAll, this, &SegmentsWidget::refreshSegments);
|
||||
connect(Core(), &CutterCore::codeRebased, this, &SegmentsWidget::refreshSegments);
|
||||
connect(Core(), &CutterCore::commentsChanged, this, [this]() {
|
||||
qhelpers::emitColumnChanged(segmentsModel, SegmentsModel::CommentColumn);
|
||||
});
|
||||
}
|
||||
|
||||
SegmentsWidget::~SegmentsWidget() {}
|
||||
|
@ -22,7 +22,7 @@ private:
|
||||
QList<SegmentDescription> *segments;
|
||||
|
||||
public:
|
||||
enum Column { NameColumn = 0, SizeColumn, AddressColumn, EndAddressColumn, PermColumn, ColumnCount };
|
||||
enum Column { NameColumn = 0, SizeColumn, AddressColumn, EndAddressColumn, PermColumn, CommentColumn, ColumnCount };
|
||||
enum Role { SegmentDescriptionRole = Qt::UserRole };
|
||||
|
||||
SegmentsModel(QList<SegmentDescription> *segments, QObject *parent = nullptr);
|
||||
|
@ -39,6 +39,9 @@ StackWidget::StackWidget(MainWindow *main) :
|
||||
connect(Core(), &CutterCore::refreshAll, this, &StackWidget::updateContents);
|
||||
connect(Core(), &CutterCore::registersChanged, this, &StackWidget::updateContents);
|
||||
connect(Core(), &CutterCore::stackChanged, this, &StackWidget::updateContents);
|
||||
connect(Core(), &CutterCore::commentsChanged, this, [this]() {
|
||||
qhelpers::emitColumnChanged(modelStack, StackModel::CommentColumn);
|
||||
});
|
||||
connect(Config(), &Configuration::fontsUpdated, this, &StackWidget::fontsUpdatedSlot);
|
||||
connect(viewStack, &QAbstractItemView::doubleClicked, this, &StackWidget::onDoubleClicked);
|
||||
connect(viewStack, &QWidget::customContextMenuRequested, this, &StackWidget::customMenuRequested);
|
||||
@ -187,6 +190,8 @@ QVariant StackModel::data(const QModelIndex &index, int role) const
|
||||
return item.value;
|
||||
case DescriptionColumn:
|
||||
return item.refDesc.ref;
|
||||
case CommentColumn:
|
||||
return Core()->getCommentAt(item.offset);
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -216,6 +221,8 @@ QVariant StackModel::headerData(int section, Qt::Orientation orientation, int ro
|
||||
return tr("Value");
|
||||
case DescriptionColumn:
|
||||
return tr("Reference");
|
||||
case CommentColumn:
|
||||
return tr("Comment");
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
RefDescription refDesc;
|
||||
};
|
||||
|
||||
enum Column { OffsetColumn = 0, ValueColumn, DescriptionColumn, ColumnCount};
|
||||
enum Column { OffsetColumn = 0, ValueColumn, DescriptionColumn, CommentColumn, ColumnCount};
|
||||
enum Role { StackDescriptionRole = Qt::UserRole };
|
||||
|
||||
StackModel(QObject *parent = nullptr);
|
||||
|
@ -47,6 +47,8 @@ QVariant StringsModel::data(const QModelIndex &index, int role) const
|
||||
return QString::number(str.size);
|
||||
case StringsModel::SectionColumn:
|
||||
return str.section;
|
||||
case StringsModel::CommentColumn:
|
||||
return Core()->getCommentAt(str.vaddr);
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -74,6 +76,8 @@ QVariant StringsModel::headerData(int section, Qt::Orientation, int role) const
|
||||
return tr("Size");
|
||||
case StringsModel::SectionColumn:
|
||||
return tr("Section");
|
||||
case StringsModel::CommentColumn:
|
||||
return tr("Comment");
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -129,6 +133,8 @@ bool StringsProxyModel::lessThan(const QModelIndex &left, const QModelIndex &rig
|
||||
return leftStr->length < rightStr->length;
|
||||
case StringsModel::SectionColumn:
|
||||
return leftStr->section < rightStr->section;
|
||||
case StringsModel::CommentColumn:
|
||||
return Core()->getCommentAt(leftStr->vaddr) < Core()->getCommentAt(rightStr->vaddr);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -193,6 +199,9 @@ StringsWidget::StringsWidget(MainWindow *main) :
|
||||
|
||||
connect(Core(), &CutterCore::refreshAll, this, &StringsWidget::refreshStrings);
|
||||
connect(Core(), &CutterCore::codeRebased, this, &StringsWidget::refreshStrings);
|
||||
connect(Core(), &CutterCore::commentsChanged, this, [this]() {
|
||||
qhelpers::emitColumnChanged(model, StringsModel::CommentColumn);
|
||||
});
|
||||
|
||||
connect(
|
||||
ui->quickFilterView->comboBox(), &QComboBox::currentTextChanged, this,
|
||||
|
@ -30,7 +30,7 @@ private:
|
||||
QList<StringDescription> *strings;
|
||||
|
||||
public:
|
||||
enum Column { OffsetColumn = 0, StringColumn, TypeColumn, LengthColumn, SizeColumn, SectionColumn, ColumnCount };
|
||||
enum Column { OffsetColumn = 0, StringColumn, TypeColumn, LengthColumn, SizeColumn, SectionColumn, CommentColumn, ColumnCount };
|
||||
static const int StringDescriptionRole = Qt::UserRole;
|
||||
|
||||
StringsModel(QList<StringDescription> *strings, QObject *parent = nullptr);
|
||||
@ -88,7 +88,8 @@ private:
|
||||
StringsModel *model;
|
||||
StringsProxyModel *proxyModel;
|
||||
QList<StringDescription> strings;
|
||||
CutterTreeWidget *tree;
|
||||
CutterTreeWidget* tree;
|
||||
|
||||
};
|
||||
|
||||
#endif // STRINGSWIDGET_H
|
||||
|
@ -38,6 +38,8 @@ QVariant SymbolsModel::data(const QModelIndex &index, int role) const
|
||||
return QString("%1 %2").arg(symbol.bind, symbol.type).trimmed();
|
||||
case SymbolsModel::NameColumn:
|
||||
return symbol.name;
|
||||
case SymbolsModel::CommentColumn:
|
||||
return Core()->getCommentAt(symbol.vaddr);
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -59,6 +61,8 @@ QVariant SymbolsModel::headerData(int section, Qt::Orientation, int role) const
|
||||
return tr("Type");
|
||||
case SymbolsModel::NameColumn:
|
||||
return tr("Name");
|
||||
case SymbolsModel::CommentColumn:
|
||||
return tr("Comment");
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@ -106,6 +110,8 @@ bool SymbolsProxyModel::lessThan(const QModelIndex &left, const QModelIndex &rig
|
||||
return leftSymbol.type < rightSymbol.type;
|
||||
case SymbolsModel::NameColumn:
|
||||
return leftSymbol.name < rightSymbol.name;
|
||||
case SymbolsModel::CommentColumn:
|
||||
return Core()->getCommentAt(leftSymbol.vaddr) < Core()->getCommentAt(rightSymbol.vaddr);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -126,6 +132,9 @@ SymbolsWidget::SymbolsWidget(MainWindow *main) :
|
||||
|
||||
connect(Core(), &CutterCore::codeRebased, this, &SymbolsWidget::refreshSymbols);
|
||||
connect(Core(), &CutterCore::refreshAll, this, &SymbolsWidget::refreshSymbols);
|
||||
connect(Core(), &CutterCore::commentsChanged, this, [this]() {
|
||||
qhelpers::emitColumnChanged(symbolsModel, SymbolsModel::CommentColumn);
|
||||
});
|
||||
}
|
||||
|
||||
SymbolsWidget::~SymbolsWidget() {}
|
||||
|
@ -25,7 +25,7 @@ private:
|
||||
QList<SymbolDescription> *symbols;
|
||||
|
||||
public:
|
||||
enum Column { AddressColumn = 0, TypeColumn, NameColumn, ColumnCount };
|
||||
enum Column { AddressColumn = 0, TypeColumn, NameColumn, CommentColumn, ColumnCount };
|
||||
enum Role { SymbolDescriptionRole = Qt::UserRole };
|
||||
|
||||
SymbolsModel(QList<SymbolDescription> *exports, QObject *parent = nullptr);
|
||||
@ -68,6 +68,7 @@ private:
|
||||
QList<SymbolDescription> symbols;
|
||||
SymbolsModel *symbolsModel;
|
||||
SymbolsProxyModel *symbolsProxyModel;
|
||||
|
||||
};
|
||||
|
||||
#endif // SYMBOLSWIDGET_H
|
||||
|
Loading…
Reference in New Issue
Block a user