forked from qt-creator/qt-creator
debugger: Sort process ID column numerically in "Attach to process" dialog
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user