changeset 558:d932ce55c364 find

Remove the single find widget from top, add one to each tab at the bottom instead. (Turns out you don't usually want to search for the same text in both types of widget.) Also provide sensible no-results text.
author Chris Cannam
date Mon, 27 Feb 2012 17:08:26 +0000
parents 57a7f95ef400
children 95877ad67d3e
files src/filestatuswidget.cpp src/filestatuswidget.h src/findwidget.cpp src/historywidget.cpp src/historywidget.h src/mainwindow.cpp src/mainwindow.h
diffstat 7 files changed, 47 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/src/filestatuswidget.cpp	Thu Feb 23 15:28:29 2012 +0000
+++ b/src/filestatuswidget.cpp	Mon Feb 27 17:08:26 2012 +0000
@@ -18,6 +18,7 @@
 #include "filestatuswidget.h"
 #include "debug.h"
 #include "multichoicedialog.h"
+#include "findwidget.h"
 
 #include <QLabel>
 #include <QListWidget>
@@ -154,9 +155,19 @@
 
     layout->addItem(new QSpacerItem(8, 8), ++row, 0);
 
-    m_showAllFiles = new QCheckBox(tr("Show all files"), this);
+    QWidget *opts = new QWidget;
+    QGridLayout *optLayout = new QGridLayout(opts);
+    optLayout->setMargin(0);
+    layout->addWidget(opts, ++row, 0);
+
+    m_findWidget = new FindWidget(this);
+    optLayout->addWidget(m_findWidget, 0, 0, Qt::AlignLeft);
+    connect(m_findWidget, SIGNAL(findTextChanged(QString)),
+            this, SLOT(setSearchText(QString)));
+
+    m_showAllFiles = new QCheckBox(tr("Show all file states"), this);
     m_showAllFiles->setEnabled(false);
-    layout->addWidget(m_showAllFiles, ++row, 0, Qt::AlignLeft);
+    optLayout->addWidget(m_showAllFiles, 0, 1, Qt::AlignRight);
 
     QSettings settings;
     m_showAllFiles->setChecked(settings.value("showall", false).toBool());
@@ -209,7 +220,16 @@
 {
     QSettings settings;
     settings.beginGroup("Presentation");
-    if (settings.value("showhelpfultext", true).toBool()) {
+
+    if (m_searchText != "") {
+        if (!m_showAllFiles->isChecked()) {
+            m_noModificationsLabel->setText
+                (tr("<qt><b>Nothing found</b><br>None of the modified files have matching filenames.<br>Select <b>Show all file states</b> to find matches among unmodified and untracked files as well.</qt>"));
+        } else {
+            m_noModificationsLabel->setText
+                (tr("<qt><b>Nothing found</b><br>No files have matching filenames.</qt>"));
+        }
+    } else if (settings.value("showhelpfultext", true).toBool()) {
         m_noModificationsLabel->setText
             (tr("<qt>This area will list files in your working folder that you have changed.<br><br>At the moment you have no uncommitted changes.<br><br>To see changes previously made to the repository,<br>switch to the History tab.<br><br>%1</qt>")
 #if defined Q_OS_MAC
--- a/src/filestatuswidget.h	Thu Feb 23 15:28:29 2012 +0000
+++ b/src/filestatuswidget.h	Mon Feb 27 17:08:26 2012 +0000
@@ -29,6 +29,7 @@
 class QPushButton;
 class QFileInfo;
 class QCheckBox;
+class FindWidget;
 
 class FileStatusWidget : public QWidget
 {
@@ -89,6 +90,7 @@
     QString m_localPath;
     QLabel *m_noModificationsLabel;
 
+    FindWidget *m_findWidget;
     QCheckBox *m_showAllFiles;
     
     FileStates m_fileStates;
--- a/src/findwidget.cpp	Thu Feb 23 15:28:29 2012 +0000
+++ b/src/findwidget.cpp	Mon Feb 27 17:08:26 2012 +0000
@@ -26,25 +26,26 @@
     QWidget(parent)
 {
     QGridLayout *layout = new QGridLayout;
+    layout->setMargin(0);
     setLayout(layout);
 
     QToolButton *button = new QToolButton();
     layout->addWidget(button, 0, 0);
     button->setText(tr("Find..."));
     button->setToolButtonStyle(Qt::ToolButtonTextOnly);
-    button->setAutoRaise(true);
+//    button->setAutoRaise(true);
     connect(button, SIGNAL(clicked()), this, SLOT(buttonPressed()));
 
-/*
-    QLabel *label = new QLabel(tr("Find:"));
-    layout->addWidget(label, 0, 0);
-*/
     m_lineEdit = new QLineEdit();
     layout->addWidget(m_lineEdit, 0, 1);
 
     m_lineEdit->setFixedWidth(100);
     m_lineEdit->hide();
 
+    int h = m_lineEdit->sizeHint().height();
+    int h0 = button->sizeHint().height();
+    if (h > h0) button->setFixedHeight(h);
+
     connect(m_lineEdit, SIGNAL(textChanged(const QString &)),
 	    this, SIGNAL(findTextChanged(QString)));
 }
@@ -66,6 +67,7 @@
         }
     } else {
 	m_lineEdit->show();
+        m_lineEdit->setFocus(Qt::OtherFocusReason);
 	button->setText(tr("Find:"));
         if (m_lineEdit->text() != "") {
             emit findTextChanged(m_lineEdit->text());
--- a/src/historywidget.cpp	Thu Feb 23 15:28:29 2012 +0000
+++ b/src/historywidget.cpp	Mon Feb 27 17:08:26 2012 +0000
@@ -23,6 +23,7 @@
 #include "grapher.h"
 #include "debug.h"
 #include "uncommitteditem.h"
+#include "findwidget.h"
 
 #include <iostream>
 
@@ -55,11 +56,21 @@
     settings.beginGroup("Presentation");
     bool showClosed = (settings.value("showclosedbranches", false).toBool());
 
+    QWidget *opts = new QWidget;
+    QGridLayout *optLayout = new QGridLayout(opts);
+    optLayout->setMargin(0);
+    layout->addWidget(opts, ++row, 0, 1, 2);
+
+    m_findWidget = new FindWidget(this);
+    optLayout->addWidget(m_findWidget, 0, 0, Qt::AlignLeft);
+    connect(m_findWidget, SIGNAL(findTextChanged(QString)),
+            this, SLOT(setSearchText(QString)));
+
     m_showClosedBranches = new QCheckBox(tr("Show closed branches"), this);
     m_showClosedBranches->setChecked(showClosed);
     connect(m_showClosedBranches, SIGNAL(toggled(bool)), 
             this, SLOT(showClosedChanged(bool)));
-    layout->addWidget(m_showClosedBranches, ++row, 0, Qt::AlignLeft);
+    optLayout->addWidget(m_showClosedBranches, 0, 1, Qt::AlignRight);
     m_showClosedBranches->hide();
 
     setLayout(layout);
--- a/src/historywidget.h	Thu Feb 23 15:28:29 2012 +0000
+++ b/src/historywidget.h	Mon Feb 27 17:08:26 2012 +0000
@@ -28,6 +28,7 @@
 class Panner;
 class UncommittedItem;
 class QGraphicsScene;
+class FindWidget;
 
 class HistoryWidget : public QWidget
 {
@@ -81,6 +82,7 @@
     bool m_showUncommitted;
     bool m_refreshNeeded;
 
+    FindWidget *m_findWidget;
     Panned *m_panned;
     Panner *m_panner;
     QCheckBox *m_showClosedBranches;
--- a/src/mainwindow.cpp	Thu Feb 23 15:28:29 2012 +0000
+++ b/src/mainwindow.cpp	Mon Feb 27 17:08:26 2012 +0000
@@ -53,7 +53,6 @@
 #include "hgignoredialog.h"
 #include "versiontester.h"
 #include "fswatcher.h"
-#include "findwidget.h"
 
 
 MainWindow::MainWindow(QString myDirPath) :
@@ -108,12 +107,7 @@
 #endif
 
     m_workStatus = new WorkStatusWidget(this);
-    cl->addWidget(m_workStatus, row, 0);
-
-    m_findWidget = new FindWidget(this);
-    cl->addWidget(m_findWidget, row++, 1, Qt::AlignRight | Qt::AlignTop);
-    connect(m_findWidget, SIGNAL(findTextChanged(QString)),
-            this, SLOT(findTextChanged(QString)));
+    cl->addWidget(m_workStatus, row++, 0);
 
     m_hgTabs = new HgTabWidget(central, m_workFolderPath);
     connectTabsSignals();
@@ -232,12 +226,6 @@
     hgQueryPaths();
 }
 
-void MainWindow::findTextChanged(QString text)
-{
-    std::cerr << "find: " << text << std::endl;
-    m_hgTabs->setSearchText(text);
-}
-
 void MainWindow::hgRefresh()
 {
     clearState();
--- a/src/mainwindow.h	Thu Feb 23 15:28:29 2012 +0000
+++ b/src/mainwindow.h	Mon Feb 27 17:08:26 2012 +0000
@@ -36,7 +36,6 @@
 
 class WorkStatusWidget;
 class FsWatcher;
-class FindWidget;
 
 class MainWindow : public QMainWindow
 {
@@ -69,7 +68,6 @@
     void startupDialog();
     void clearSelections();
     void showAllChanged();
-    void findTextChanged(QString);
 
     void hgTest();
     void hgTestExtension();
@@ -183,7 +181,6 @@
 
     WorkStatusWidget *m_workStatus;
     HgTabWidget *m_hgTabs;
-    FindWidget *m_findWidget;
 
     QString m_remoteRepoPath;
     QString m_workFolderPath;