# HG changeset patch # User Chris Cannam # Date 1222346663 0 # Node ID b0c8e0def62ecd1ff5d66701c6942024a4119379 # Parent bd1e4ff5091d41f14d28177cd30bccda04b54e54 * some work on transform finder diff -r bd1e4ff5091d -r b0c8e0def62e widgets/TransformFinder.cpp --- a/widgets/TransformFinder.cpp Tue Sep 23 16:53:26 2008 +0000 +++ b/widgets/TransformFinder.cpp Thu Sep 25 12:44:23 2008 +0000 @@ -17,13 +17,32 @@ #include "transform/TransformFactory.h" -#include +#include #include #include #include +//#include #include #include +void +SelectableLabel::setUnselectedText(QString text) +{ + setText(text); +} + +void +SelectableLabel::setSelectedText(QString text) +{ + setText(text); +} + +void +SelectableLabel::mousePressEvent(QMouseEvent *e) +{ + +} + TransformFinder::TransformFinder(QWidget *parent) : QDialog(parent), m_resultsFrame(0), @@ -94,7 +113,7 @@ std::cerr << "creating frame & layout" << std::endl; m_resultsFrame = new QWidget; // resultsFrame->setFrameStyle(QFrame::Sunken | QFrame::Box); - m_resultsLayout = new QVBoxLayout; + m_resultsLayout = new QGridLayout; m_resultsFrame->setLayout(m_resultsLayout); m_resultsScroll->setWidget(m_resultsFrame); m_resultsFrame->show(); @@ -109,9 +128,10 @@ j != sorted.begin(); ) { --j; - QString labelText; TransformDescription desc = TransformFactory::getInstance()->getTransformDescription(j->transform); + + QString labelText; labelText += tr("%2
").arg(desc.name); labelText += "..."; for (TransformFactory::Match::FragmentMap::const_iterator k = @@ -122,17 +142,37 @@ } labelText += tr(""); + QString selectedText; + selectedText += tr("%1
").arg(desc.name); + selectedText += tr("%1").arg(desc.longDescription); +/* + for (TransformFactory::Match::FragmentMap::const_iterator k = + j->fragments.begin(); + k != j->fragments.end(); ++k) { + selectedText += tr("
%1: %2").arg(k->first).arg(k->second); + } +*/ + + selectedText += tr("
Plugin type: %1").arg(desc.type); + selectedText += tr("
Category: %1").arg(desc.category); + selectedText += tr("
System identifier: %1").arg(desc.identifier); + if (i >= m_labels.size()) { - QLabel *label = new QLabel(m_resultsFrame); - label->setTextFormat(Qt::RichText); - m_resultsLayout->addWidget(label); + SelectableLabel *label = new SelectableLabel(m_resultsFrame); + m_resultsLayout->addWidget(label, i, 0); m_labels.push_back(label); } - m_labels[i]->setText(labelText); + m_labels[i]->setUnselectedText(labelText); + m_labels[i]->setSelectedText(selectedText); + +/* QSize sh = m_labels[i]->sizeHint(); std::cerr << "size hint for text \"" << labelText.toStdString() << "\" has height " << sh.height() << std::endl; height += sh.height(); if (sh.width() > width) width = sh.width(); +*/ +// m_labels[i]->resize(m_labels[i]->sizeHint()); +// m_labels[i]->updateGeometry(); m_labels[i]->show(); if (++i == maxResults) break; @@ -140,9 +180,10 @@ std::cerr << "m_labels.size() = " << m_labels.size() << ", i = " << i << ", height = " << height << std::endl; - while (i < m_labels.size()) m_labels[i++]->hide(); + for (int j = m_labels.size(); j > i; ) m_labels[--j]->hide(); - m_resultsFrame->resize(height, width); + m_resultsFrame->resize(m_resultsFrame->sizeHint()); +// m_resultsFrame->resize(height, width); } TransformId diff -r bd1e4ff5091d -r b0c8e0def62e widgets/TransformFinder.h --- a/widgets/TransformFinder.h Tue Sep 23 16:53:26 2008 +0000 +++ b/widgets/TransformFinder.h Thu Sep 25 12:44:23 2008 +0000 @@ -22,11 +22,31 @@ #include "transform/Transform.h" -class QVBoxLayout; +class QGridLayout; class QScrollArea; class QLabel; +class SelectableLabel; class QWidget; + +#include +class SelectableLabel : public QLabel +{ + Q_OBJECT + +public: + SelectableLabel(QWidget *parent = 0) : QLabel(parent) { + setTextFormat(Qt::RichText); + } + virtual ~SelectableLabel() { } + + void setSelectedText(QString); + void setUnselectedText(QString); + +protected: + virtual void mousePressEvent(QMouseEvent *e); +}; + class TransformFinder : public QDialog { Q_OBJECT @@ -43,8 +63,8 @@ protected: QScrollArea *m_resultsScroll; QWidget *m_resultsFrame; - QVBoxLayout *m_resultsLayout; - std::vector m_labels; + QGridLayout *m_resultsLayout; + std::vector m_labels; }; #endif