Remove column of active thread in ThreadsWidget

This commit is contained in:
itayc0hen 2019-12-06 17:07:05 +02:00 committed by Itay Cohen
parent 44e68146db
commit ccd8e86052

View File

@ -10,8 +10,7 @@
#define DEBUGGED_PID (-1) #define DEBUGGED_PID (-1)
enum ColumnIndex { enum ColumnIndex {
COLUMN_CURRENT = 0, COLUMN_PID = 0,
COLUMN_PID,
COLUMN_STATUS, COLUMN_STATUS,
COLUMN_PATH, COLUMN_PATH,
}; };
@ -23,8 +22,7 @@ ThreadsWidget::ThreadsWidget(MainWindow *main, QAction *action) :
ui->setupUi(this); ui->setupUi(this);
// Setup threads model // Setup threads model
modelThreads = new QStandardItemModel(1, 4, this); modelThreads = new QStandardItemModel(1, 3, this);
modelThreads->setHorizontalHeaderItem(COLUMN_CURRENT, new QStandardItem(tr("Current")));
modelThreads->setHorizontalHeaderItem(COLUMN_PID, new QStandardItem(tr("PID"))); modelThreads->setHorizontalHeaderItem(COLUMN_PID, new QStandardItem(tr("PID")));
modelThreads->setHorizontalHeaderItem(COLUMN_STATUS, new QStandardItem(tr("Status"))); modelThreads->setHorizontalHeaderItem(COLUMN_STATUS, new QStandardItem(tr("Status")));
modelThreads->setHorizontalHeaderItem(COLUMN_PATH, new QStandardItem(tr("Path"))); modelThreads->setHorizontalHeaderItem(COLUMN_PATH, new QStandardItem(tr("Path")));
@ -100,19 +98,22 @@ void ThreadsWidget::setThreadsGrid()
{ {
QJsonArray threadsValues = Core()->getProcessThreads(DEBUGGED_PID).array(); QJsonArray threadsValues = Core()->getProcessThreads(DEBUGGED_PID).array();
int i = 0; int i = 0;
QFont font;
for (const QJsonValue &value : threadsValues) { for (const QJsonValue &value : threadsValues) {
QJsonObject threadsItem = value.toObject(); QJsonObject threadsItem = value.toObject();
int pid = threadsItem["pid"].toVariant().toInt(); int pid = threadsItem["pid"].toVariant().toInt();
QString status = translateStatus(threadsItem["status"].toString()); QString status = translateStatus(threadsItem["status"].toString());
QString path = threadsItem["path"].toString(); QString path = threadsItem["path"].toString();
bool current = threadsItem["current"].toBool(); bool current = threadsItem["current"].toBool();
// Use bold font to highlight active thread
QStandardItem *rowCurrent = new QStandardItem(QString(current ? "True" : "False")); font.setBold(current);
QStandardItem *rowPid = new QStandardItem(QString::number(pid)); QStandardItem *rowPid = new QStandardItem(QString::number(pid));
rowPid->setFont(font);
QStandardItem *rowStatus = new QStandardItem(status); QStandardItem *rowStatus = new QStandardItem(status);
rowStatus->setFont(font);
QStandardItem *rowPath = new QStandardItem(path); QStandardItem *rowPath = new QStandardItem(path);
rowPath->setFont(font);
modelThreads->setItem(i, COLUMN_CURRENT, rowCurrent);
modelThreads->setItem(i, COLUMN_PID, rowPid); modelThreads->setItem(i, COLUMN_PID, rowPid);
modelThreads->setItem(i, COLUMN_STATUS, rowStatus); modelThreads->setItem(i, COLUMN_STATUS, rowStatus);
modelThreads->setItem(i, COLUMN_PATH, rowPath); modelThreads->setItem(i, COLUMN_PATH, rowPath);
@ -163,7 +164,7 @@ ThreadsFilterModel::ThreadsFilterModel(QObject *parent)
bool ThreadsFilterModel::filterAcceptsRow(int row, const QModelIndex &parent) const bool ThreadsFilterModel::filterAcceptsRow(int row, const QModelIndex &parent) const
{ {
// All columns are checked for a match // All columns are checked for a match
for (int i = COLUMN_CURRENT; i <= COLUMN_PATH; ++i) { for (int i = COLUMN_PID; i <= COLUMN_PATH; ++i) {
QModelIndex index = sourceModel()->index(row, i, parent); QModelIndex index = sourceModel()->index(row, i, parent);
if (sourceModel()->data(index).toString().contains(filterRegExp())) { if (sourceModel()->data(index).toString().contains(filterRegExp())) {
return true; return true;