# HG changeset patch # User Chris Cannam # Date 1222770808 0 # Node ID 6bf3c906b7a5d4f901bf6265f88b9735b57a65ae # Parent 4a5fe547128266647290ff7653146298e17e6a81 * Connect up Up and Down arrows in the transform finder diff -r 4a5fe5471282 -r 6bf3c906b7a5 widgets/TransformFinder.cpp --- 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 #include #include +#include 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("%1") .arg(XmlExportable::encodeEntities(desc.longDescription)); - selectedText += tr("
    "); - selectedText += tr("
  • Plugin type: %1
  • ") + selectedText += tr("
    "); + selectedText += tr("      — Plugin type: %1
    ") .arg(XmlExportable::encodeEntities(desc.type)); - selectedText += tr("
  • Category: %1
  • ") + selectedText += tr("      — Category: %1
    ") .arg(XmlExportable::encodeEntities(desc.category)); - selectedText += tr("
  • System identifier: %1
  • ") + selectedText += tr("      — System identifier: %1") .arg(XmlExportable::encodeEntities(desc.identifier)); - selectedText += tr("
"); + selectedText += tr(""); 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; + } + } +} + diff -r 4a5fe5471282 -r 6bf3c906b7a5 widgets/TransformFinder.h --- 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;