Skip to content

Commit

Permalink
ProcessesWidget: make ColumnIndex a class member
Browse files Browse the repository at this point in the history
The same name with a differing definition clashes with ColumnIndex from
ThreadsWidget, which violates C++ ODR (-Werror=odr). This brings
ProcessesWidget in line with other widgets that define the column
index enums within their respective classes.

Signed-off-by: John Helmert III <[email protected]>
  • Loading branch information
ajakk authored and karliss committed Mar 11, 2024
1 parent bffe193 commit 1a09a5c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
31 changes: 14 additions & 17 deletions src/widgets/ProcessesWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,21 @@

#define DEBUGGED_PID (-1)

enum ColumnIndex {
COLUMN_PID = 0,
COLUMN_UID,
COLUMN_STATUS,
COLUMN_PATH,
};

ProcessesWidget::ProcessesWidget(MainWindow *main)
: CutterDockWidget(main), ui(new Ui::ProcessesWidget)
{
ui->setupUi(this);

// Setup processes model
modelProcesses = new QStandardItemModel(1, 4, this);
modelProcesses->setHorizontalHeaderItem(COLUMN_PID, new QStandardItem(tr("PID")));
modelProcesses->setHorizontalHeaderItem(COLUMN_UID, new QStandardItem(tr("UID")));
modelProcesses->setHorizontalHeaderItem(COLUMN_STATUS, new QStandardItem(tr("Status")));
modelProcesses->setHorizontalHeaderItem(COLUMN_PATH, new QStandardItem(tr("Path")));
modelProcesses->setHorizontalHeaderItem(ProcessesWidget::COLUMN_PID,
new QStandardItem(tr("PID")));
modelProcesses->setHorizontalHeaderItem(ProcessesWidget::COLUMN_UID,
new QStandardItem(tr("UID")));
modelProcesses->setHorizontalHeaderItem(ProcessesWidget::COLUMN_STATUS,
new QStandardItem(tr("Status")));
modelProcesses->setHorizontalHeaderItem(ProcessesWidget::COLUMN_PATH,
new QStandardItem(tr("Path")));
ui->viewProcesses->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter);
ui->viewProcesses->verticalHeader()->setVisible(false);
ui->viewProcesses->setFont(Config()->getFont());
Expand Down Expand Up @@ -129,10 +126,10 @@ void ProcessesWidget::setProcessesGrid()
rowStatus->setFont(font);
rowPath->setFont(font);

modelProcesses->setItem(i, COLUMN_PID, rowPid);
modelProcesses->setItem(i, COLUMN_UID, rowUid);
modelProcesses->setItem(i, COLUMN_STATUS, rowStatus);
modelProcesses->setItem(i, COLUMN_PATH, rowPath);
modelProcesses->setItem(i, ProcessesWidget::COLUMN_PID, rowPid);
modelProcesses->setItem(i, ProcessesWidget::COLUMN_UID, rowUid);
modelProcesses->setItem(i, ProcessesWidget::COLUMN_STATUS, rowStatus);
modelProcesses->setItem(i, ProcessesWidget::COLUMN_PATH, rowPath);
i++;
}

Expand All @@ -155,7 +152,7 @@ void ProcessesWidget::onActivated(const QModelIndex &index)
if (!index.isValid())
return;

int pid = modelFilter->data(index.sibling(index.row(), COLUMN_PID)).toInt();
int pid = modelFilter->data(index.sibling(index.row(), ProcessesWidget::COLUMN_PID)).toInt();
// Verify that the selected pid is still in the processes list since dp= will
// attach to any given id. If it isn't found simply update the UI.
for (const auto &value : Core()->getAllProcesses()) {
Expand Down Expand Up @@ -185,7 +182,7 @@ ProcessesFilterModel::ProcessesFilterModel(QObject *parent) : QSortFilterProxyMo
bool ProcessesFilterModel::filterAcceptsRow(int row, const QModelIndex &parent) const
{
// All columns are checked for a match
for (int i = COLUMN_PID; i <= COLUMN_PATH; ++i) {
for (int i = ProcessesWidget::COLUMN_PID; i <= ProcessesWidget::COLUMN_PATH; ++i) {
QModelIndex index = sourceModel()->index(row, i, parent);
if (qhelpers::filterStringContains(sourceModel()->data(index).toString(), this)) {
return true;
Expand Down
7 changes: 7 additions & 0 deletions src/widgets/ProcessesWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ class ProcessesWidget : public CutterDockWidget
Q_OBJECT

public:
enum ColumnIndex {
COLUMN_PID = 0,
COLUMN_UID,
COLUMN_STATUS,
COLUMN_PATH,
};

explicit ProcessesWidget(MainWindow *main);
~ProcessesWidget();

Expand Down

0 comments on commit 1a09a5c

Please sign in to comment.