From d03f4f621caf654f5bbd26916c4c4e4ae9d7f213 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Sat, 6 May 2006 17:17:47 +0200 Subject: [PATCH] Improve the usability of the Attach to Process dialog. A filter edit box is added so that the list of processes can be reduced. The PID edit box is gone. A process must be selected. --- ChangeLog | 3 + kdbg/procattach.cpp | 51 ++++++++++++----- kdbg/procattach.h | 6 +- kdbg/procattachbase.ui | 150 ++++++++++++++++++++++++------------------------- 4 files changed, 114 insertions(+), 96 deletions(-) diff --git a/ChangeLog b/ChangeLog index a422cc9..c94e3d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,9 @@ Version 2.0.4 receives the focus when the debuggee stops at a breakpoint, when this option is on (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=171845). + Added a filter edit box to the Attach to Process dialog to improve + usability. + Version 2.0.3 Fixed parsing of gdb output that mentions "operator<<", "operator>>", diff --git a/kdbg/procattach.cpp b/kdbg/procattach.cpp index 496b006..25806ef 100644 --- a/kdbg/procattach.cpp +++ b/kdbg/procattach.cpp @@ -5,9 +5,12 @@ #include "procattach.h" #include +#include +#include #include #include #include +#include #include /* i18n */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -23,6 +26,9 @@ ProcAttachPS::ProcAttachPS(QWidget* parent) : connect(m_ps, SIGNAL(receivedStdout(KProcess*, char*, int)), this, SLOT(slotTextReceived(KProcess*, char*, int))); + QIconSet icon = SmallIconSet("clear_left"); + filterClear->setIconSet(icon); + processList->setColumnWidth(0, 300); processList->setColumnWidthMode(0, QListView::Manual); processList->setColumnAlignment(1, Qt::AlignRight); @@ -184,12 +190,14 @@ void ProcAttachPS::pushLine() } } -void ProcAttachPS::processSelected(QListViewItem* item) +QString ProcAttachPS::text() const { - if (item != 0) { - pidEdit->setText(item->text(1)); - processText->setText(item->text(0)); - } + QListViewItem* item = processList->selectedItem(); + + if (item == 0) + return QString(); + + return item->text(1); } void ProcAttachPS::refresh() @@ -201,19 +209,32 @@ void ProcAttachPS::refresh() } } -void ProcAttachPS::pidEdited(const QString& text) +void ProcAttachPS::filterEdited(const QString& text) { - if (text.isEmpty()) - return; + QListViewItem* i = processList->firstChild(); + setVisibility(i, text); +} - // get the process and select it - QListViewItem* item = processList->findItem(text, 1); - if (item == 0) { - processList->clearSelection(); - } else { - processList->setSelected(item, true); - processList->ensureItemVisible(item); +/** + * Sets the visibility of \a i and + * returns whether it was made visible. + */ +bool ProcAttachPS::setVisibility(QListViewItem* i, const QString& text) +{ + bool visible = false; + for (QListViewItem* j = i->firstChild(); j; j = j->nextSibling()) + { + if (setVisibility(j, text)) + visible = true; } + // look for text in the process name and in the PID + visible = visible || text.isEmpty() || + i->text(0).find(text, 0, false) >= 0 || + i->text(1).find(text) >= 0; + + i->setVisible(visible); + + return visible; } diff --git a/kdbg/procattach.h b/kdbg/procattach.h index 9d6b4b1..7d25571 100644 --- a/kdbg/procattach.h +++ b/kdbg/procattach.h @@ -29,19 +29,19 @@ public: ProcAttachPS(QWidget* parent); ~ProcAttachPS(); - QString text() const { return pidEdit->text(); } + QString text() const; protected: void runPS(); - virtual void processSelected(QListViewItem*); virtual void refresh(); - virtual void pidEdited(const QString& text); + virtual void filterEdited(const QString& text); protected slots: void slotTextReceived(KProcess* proc, char* buffer, int buflen); protected: void pushLine(); + bool setVisibility(QListViewItem* i, const QString& text); KProcess* m_ps; // parse state diff --git a/kdbg/procattachbase.ui b/kdbg/procattachbase.ui index 8e534b3..833fb19 100644 --- a/kdbg/procattachbase.ui +++ b/kdbg/procattachbase.ui @@ -1,4 +1,4 @@ - + ProcAttachBase Johannes Sixt @@ -25,30 +25,65 @@ - layout1 + layout7 unnamed - + - textLabel3 - - - - 7 - 5 - 0 - 0 - - - - &Currently running processes: - - - processList + layout6 + + + unnamed + + + + filterLabel + + + &Filter or PID: + + + filterEdit + + + + + filterEdit + + + + 7 + 5 + 0 + 0 + + + + 20 + + + Type the name of the process or its process ID (PID) here to reduce the number of entries in the list. + + + + + filterClear + + + ... + + + Clear filter + + + Use this button to clear the filter text so that all processes are displayed. + + + @@ -96,56 +131,9 @@ true - - - - layout2 + + <p>This list displays all processes that are currently running. You must select the process that you want KDbg to attach to. Use the <b>Filter or PID</b> edit box to reduce the number of entries in this list.<p>The text in the <i>Command</i> column is usually, but not always, the command that was used to start the process. The <i>PID</i> column shows the process ID. The <i>PPID</i> column shows the process ID of the parent process. Additional columns show more information about the processes that is also available via the system's <i>ps</i> comand.</p><p>The list is not updated automatically. Use the <b>Refresh</b> button to update it.</p> - - - unnamed - - - - pidLabel - - - &Process number: - - - pidEdit - - - - - pidEdit - - - - 0 - 5 - 0 - 0 - - - - 20 - - - - - processText - - - - 2 - 5 - 1 - 0 - - - - @@ -170,6 +158,12 @@ &Refresh + + Alt+R + + + This button updates the list of processes. + @@ -239,34 +233,34 @@ reject() - processList - selectionChanged(QListViewItem*) - ProcAttachBase - processSelected(QListViewItem*) - - buttonRefresh clicked() ProcAttachBase refresh() - pidEdit + filterEdit textChanged(const QString&) ProcAttachBase - pidEdited(const QString&) + filterEdited(const QString&) + + + filterClear + clicked() + filterEdit + clear() + filterEdit processList - pidEdit + buttonRefresh buttonOk buttonCancel - processSelected(QListViewItem*) refresh() - pidEdited(const QString&) + filterEdited(const QString&) -- 2.11.4.GIT