# HG changeset patch
# User Chris Cannam
# Date 1227106517 0
# Node ID 2b5d04b21d87af8c14c7040e940b70906be1619d
# Parent 84ada1c89510491fb28a22232034dc7c8f7a2288
* Add some informative labels to transform finder
diff -r 84ada1c89510 -r 2b5d04b21d87 widgets/TransformFinder.cpp
--- a/widgets/TransformFinder.cpp Wed Nov 12 16:39:29 2008 +0000
+++ b/widgets/TransformFinder.cpp Wed Nov 19 14:55:17 2008 +0000
@@ -48,30 +48,38 @@
connect(searchField, SIGNAL(textChanged(const QString &)),
this, SLOT(searchTextChanged(const QString &)));
+ m_infoLabel = new QLabel(tr("Type in the box above to search descriptions of available and known transforms"));
+ mainGrid->addWidget(m_infoLabel, 1, 1);
+
m_resultsScroll = new QScrollArea;
-// m_resultsScroll->setWidgetResizable(true);
- mainGrid->addWidget(m_resultsScroll, 1, 0, 1, 2);
- mainGrid->setRowStretch(1, 10);
+ mainGrid->addWidget(m_resultsScroll, 2, 0, 1, 2);
+ mainGrid->setRowStretch(2, 10);
QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok |
QDialogButtonBox::Cancel);
- mainGrid->addWidget(bb, 2, 0, 1, 2);
+ mainGrid->addWidget(bb, 3, 0, 1, 2);
connect(bb, SIGNAL(accepted()), this, SLOT(accept()));
connect(bb, SIGNAL(rejected()), this, SLOT(reject()));
- if (!m_resultsLayout) {
- std::cerr << "creating frame & layout" << std::endl;
- m_resultsFrame = new QWidget;
- QPalette palette = m_resultsFrame->palette();
- palette.setColor(QPalette::Window, palette.color(QPalette::Base));
- m_resultsFrame->setPalette(palette);
- m_resultsScroll->setPalette(palette);
- m_resultsLayout = new QVBoxLayout;
- m_resultsLayout->setSpacing(0);
- m_resultsLayout->setContentsMargins(0, 0, 0, 0);
- m_resultsFrame->setLayout(m_resultsLayout);
- m_resultsScroll->setWidget(m_resultsFrame);
- m_resultsFrame->show();
- }
+
+ m_resultsFrame = new QWidget;
+ QPalette palette = m_resultsFrame->palette();
+ palette.setColor(QPalette::Window, palette.color(QPalette::Base));
+ m_resultsFrame->setPalette(palette);
+ m_resultsScroll->setPalette(palette);
+ m_resultsLayout = new QVBoxLayout;
+ m_resultsLayout->setSpacing(0);
+ m_resultsLayout->setContentsMargins(0, 0, 0, 0);
+ m_resultsFrame->setLayout(m_resultsLayout);
+ m_resultsScroll->setWidget(m_resultsFrame);
+ m_resultsFrame->show();
+
+ m_noResultsLabel = new QLabel(tr("
No results found"));
+ m_resultsLayout->addWidget(m_noResultsLabel);
+ m_noResultsLabel->hide();
+
+ m_beforeSearchLabel = new QLabel;
+ m_resultsLayout->addWidget(m_beforeSearchLabel);
+ m_beforeSearchLabel->hide();
QAction *up = new QAction(tr("Up"), this);
up->setShortcut(tr("Up"));
@@ -111,14 +119,14 @@
void
TransformFinder::searchTextChanged(const QString &text)
{
- std::cerr << "text is " << text.toStdString() << std::endl;
+// std::cerr << "text is " << text.toStdString() << std::endl;
m_newSearchText = text;
}
void
TransformFinder::timeout()
{
- int maxResults = 40;
+ int maxResults = 60;
if (m_newSearchText != "") {
@@ -129,7 +137,7 @@
TransformFactory::SearchResults results =
TransformFactory::getInstance()->search(keywords);
- std::cerr << results.size() << " result(s)..." << std::endl;
+// std::cerr << results.size() << " result(s)..." << std::endl;
std::set sorted;
sorted.clear();
@@ -137,7 +145,7 @@
j != results.end(); ++j) {
sorted.insert(j->second);
}
-
+
m_sortedResults.clear();
for (std::set::const_iterator j = sorted.end();
j != sorted.begin(); ) {
@@ -155,6 +163,23 @@
m_labels[--j]->hide();
}
+ if (m_sortedResults.empty()) {
+ m_noResultsLabel->show();
+ m_resultsFrame->resize(m_resultsFrame->sizeHint());
+ } else {
+ m_noResultsLabel->hide();
+ }
+
+ if (m_sortedResults.size() < sorted.size()) {
+ m_infoLabel->setText
+ (tr("Found %n description(s) containing %1, showing the first %2 only",
+ 0, sorted.size()).arg(text).arg(m_sortedResults.size()));
+ } else {
+ m_infoLabel->setText
+ (tr("Found %n description(s) containing %1",
+ 0, sorted.size()).arg(text));
+ }
+
return;
}
@@ -231,7 +256,7 @@
connect(label, SIGNAL(selectionChanged()), this,
SLOT(selectedLabelChanged()));
connect(label, SIGNAL(doubleClicked()), this,
- SLOT(accept()));
+ SLOT(labelDoubleClicked()));
QPalette palette = label->palette();
label->setPalette(palette);
m_labels.push_back(label);
@@ -277,6 +302,17 @@
<< m_selectedTransform.toStdString() << "\"" << std::endl;
}
+void
+TransformFinder::labelDoubleClicked()
+{
+ // The first click should have selected the label already
+ if (TransformFactory::getInstance()->getTransformInstallStatus
+ (m_selectedTransform) ==
+ TransformFactory::TransformInstalled) {
+ accept();
+ }
+}
+
TransformId
TransformFinder::getTransform() const
{
diff -r 84ada1c89510 -r 2b5d04b21d87 widgets/TransformFinder.h
--- a/widgets/TransformFinder.h Wed Nov 12 16:39:29 2008 +0000
+++ b/widgets/TransformFinder.h Wed Nov 19 14:55:17 2008 +0000
@@ -43,11 +43,16 @@
protected slots:
void searchTextChanged(const QString &);
void selectedLabelChanged();
+ void labelDoubleClicked();
void timeout();
void up();
void down();
protected:
+ QLabel *m_infoLabel;
+ QLabel *m_beforeSearchLabel;
+ QLabel *m_noResultsLabel;
+
QScrollArea *m_resultsScroll;
QWidget *m_resultsFrame;
QVBoxLayout *m_resultsLayout;