Commit 0f7a6a20 authored by hjk's avatar hjk
Browse files

debugger: Sort process ID column numerically in "Attach to process" dialog

parent 9033976a
......@@ -71,6 +71,8 @@ public:
void populate(QList<ProcData> processes, const QString &excludePid = QString());
private:
bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
QStandardItemModel *m_model;
};
......@@ -88,6 +90,16 @@ ProcessListFilterModel::ProcessListFilterModel(QObject *parent)
setFilterKeyColumn(1);
}
bool ProcessListFilterModel::lessThan(const QModelIndex &left,
const QModelIndex &right) const
{
const QString l = sourceModel()->data(left).toString();
const QString r = sourceModel()->data(right).toString();
if (left.column() == 0)
return l.toInt() < r.toInt();
return l < r;
}
QString ProcessListFilterModel::processIdAt(const QModelIndex &index) const
{
if (index.isValid()) {
......@@ -267,6 +279,8 @@ static QList<ProcData> processList()
return unixProcessList();
#endif
}
///////////////////////////////////////////////////////////////////////
//
// AttachExternalDialog
......@@ -300,12 +314,14 @@ AttachExternalDialog::AttachExternalDialog(QWidget *parent)
// Do not use activated, will be single click in Oxygen
connect(m_ui->procView, SIGNAL(doubleClicked(QModelIndex)),
this, SLOT(procSelected(QModelIndex)));
connect(m_ui->procView, SIGNAL(clicked(QModelIndex)),
this, SLOT(procClicked(QModelIndex)));
connect(m_ui->pidLineEdit, SIGNAL(textChanged(QString)),
this, SLOT(pidChanged(QString)));
connect(m_ui->filterWidget, SIGNAL(filterChanged(QString)),
this, SLOT(setFilterString(QString)));
setMinimumHeight(500);
rebuildProcessList();
}
......@@ -341,7 +357,7 @@ void AttachExternalDialog::rebuildProcessList()
void AttachExternalDialog::procSelected(const QModelIndex &proxyIndex)
{
const QString processId = m_model->processIdAt(proxyIndex);
const QString processId = m_model->processIdAt(proxyIndex);
if (!processId.isEmpty()) {
m_ui->pidLineEdit->setText(processId);
if (okButton()->isEnabled())
......@@ -349,6 +365,13 @@ void AttachExternalDialog::procSelected(const QModelIndex &proxyIndex)
}
}
void AttachExternalDialog::procClicked(const QModelIndex &proxyIndex)
{
const QString processId = m_model->processIdAt(proxyIndex);
if (!processId.isEmpty())
m_ui->pidLineEdit->setText(processId);
}
qint64 AttachExternalDialog::attachPID() const
{
return m_ui->pidLineEdit->text().toLongLong();
......
......@@ -92,8 +92,9 @@ public:
private slots:
void rebuildProcessList();
void procSelected(const QModelIndex &);
void pidChanged(const QString &);
void procSelected(const QModelIndex &index);
void procClicked(const QModelIndex &index);
void pidChanged(const QString &index);
void setFilterString(const QString &filter);
private:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment