changeset 426:6bf3c906b7a5

* Connect up Up and Down arrows in the transform finder
author Chris Cannam
date Tue, 30 Sep 2008 10:33:28 +0000
parents 4a5fe5471282
children 1304dbe4542e
files widgets/TransformFinder.cpp widgets/TransformFinder.h
diffstat 2 files changed, 51 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/widgets/TransformFinder.cpp	Mon Sep 29 16:31:49 2008 +0000
+++ b/widgets/TransformFinder.cpp	Tue Sep 30 10:33:28 2008 +0000
@@ -28,6 +28,7 @@
 #include <QApplication>
 #include <QDesktopWidget>
 #include <QTimer>
+#include <QAction>
 
 TransformFinder::TransformFinder(QWidget *parent) :
     QDialog(parent),
@@ -72,6 +73,16 @@
         m_resultsFrame->show();
     }
 
+    QAction *up = new QAction(tr("Up"), this);
+    up->setShortcut(tr("Up"));
+    connect(up, SIGNAL(triggered()), this, SLOT(up()));
+    addAction(up);
+
+    QAction *down = new QAction(tr("Down"), this);
+    down->setShortcut(tr("Down"));
+    connect(down, SIGNAL(triggered()), this, SLOT(down()));
+    addAction(down);
+
     QDesktopWidget *desktop = QApplication::desktop();
     QRect available = desktop->availableGeometry();
 
@@ -178,14 +189,14 @@
         selectedText += tr("<small>%1</small>")
             .arg(XmlExportable::encodeEntities(desc.longDescription));
 
-        selectedText += tr("<ul><small>");
-        selectedText += tr("<li>Plugin type: %1</li>")
+        selectedText += tr("<br><small>");
+        selectedText += tr("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&mdash; Plugin type: %1<br>")
             .arg(XmlExportable::encodeEntities(desc.type));
-        selectedText += tr("<li>Category: %1</li>")
+        selectedText += tr("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&mdash; Category: %1<br>")
             .arg(XmlExportable::encodeEntities(desc.category));
-        selectedText += tr("<li>System identifier: %1</li>")
+        selectedText += tr("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&mdash; System identifier: %1")
             .arg(XmlExportable::encodeEntities(desc.identifier));
-        selectedText += tr("</small></ul>");
+        selectedText += tr("</small>");
 
         if (i >= m_labels.size()) {
             SelectableLabel *label = new SelectableLabel(m_resultsFrame);
@@ -245,3 +256,36 @@
     return m_selectedTransform;
 }
 
+void
+TransformFinder::up()
+{
+    for (int i = 0; i < m_labels.size(); ++i) {
+        if (!m_labels[i]->isVisible()) continue;
+        if (m_labels[i]->objectName() == m_selectedTransform) {
+            if (i > 0) {
+                m_labels[i]->setSelected(false);
+                m_labels[i-1]->setSelected(true);
+                m_selectedTransform = m_labels[i-1]->objectName();
+            }
+            return;
+        }
+    }
+}
+
+void
+TransformFinder::down()
+{
+    for (int i = 0; i < m_labels.size(); ++i) {
+        if (!m_labels[i]->isVisible()) continue;
+        if (m_labels[i]->objectName() == m_selectedTransform) {
+            if (i+1 < m_labels.size() &&
+                m_labels[i+1]->isVisible()) {
+                m_labels[i]->setSelected(false);
+                m_labels[i+1]->setSelected(true);
+                m_selectedTransform = m_labels[i+1]->objectName();
+            }
+            return;
+        }
+    }
+}
+
--- a/widgets/TransformFinder.h	Mon Sep 29 16:31:49 2008 +0000
+++ b/widgets/TransformFinder.h	Tue Sep 30 10:33:28 2008 +0000
@@ -44,6 +44,8 @@
     void searchTextChanged(const QString &);
     void selectedLabelChanged();
     void timeout();
+    void up();
+    void down();
 
 protected:
     QScrollArea *m_resultsScroll;