comparison src/findwidget.cpp @ 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 533519ebc0cb
comparison
equal deleted inserted replaced
557:57a7f95ef400 558:d932ce55c364
24 24
25 FindWidget::FindWidget(QWidget *parent) : 25 FindWidget::FindWidget(QWidget *parent) :
26 QWidget(parent) 26 QWidget(parent)
27 { 27 {
28 QGridLayout *layout = new QGridLayout; 28 QGridLayout *layout = new QGridLayout;
29 layout->setMargin(0);
29 setLayout(layout); 30 setLayout(layout);
30 31
31 QToolButton *button = new QToolButton(); 32 QToolButton *button = new QToolButton();
32 layout->addWidget(button, 0, 0); 33 layout->addWidget(button, 0, 0);
33 button->setText(tr("Find...")); 34 button->setText(tr("Find..."));
34 button->setToolButtonStyle(Qt::ToolButtonTextOnly); 35 button->setToolButtonStyle(Qt::ToolButtonTextOnly);
35 button->setAutoRaise(true); 36 // button->setAutoRaise(true);
36 connect(button, SIGNAL(clicked()), this, SLOT(buttonPressed())); 37 connect(button, SIGNAL(clicked()), this, SLOT(buttonPressed()));
37 38
38 /*
39 QLabel *label = new QLabel(tr("Find:"));
40 layout->addWidget(label, 0, 0);
41 */
42 m_lineEdit = new QLineEdit(); 39 m_lineEdit = new QLineEdit();
43 layout->addWidget(m_lineEdit, 0, 1); 40 layout->addWidget(m_lineEdit, 0, 1);
44 41
45 m_lineEdit->setFixedWidth(100); 42 m_lineEdit->setFixedWidth(100);
46 m_lineEdit->hide(); 43 m_lineEdit->hide();
44
45 int h = m_lineEdit->sizeHint().height();
46 int h0 = button->sizeHint().height();
47 if (h > h0) button->setFixedHeight(h);
47 48
48 connect(m_lineEdit, SIGNAL(textChanged(const QString &)), 49 connect(m_lineEdit, SIGNAL(textChanged(const QString &)),
49 this, SIGNAL(findTextChanged(QString))); 50 this, SIGNAL(findTextChanged(QString)));
50 } 51 }
51 52
64 if (m_lineEdit->text() != "") { 65 if (m_lineEdit->text() != "") {
65 emit findTextChanged(""); 66 emit findTextChanged("");
66 } 67 }
67 } else { 68 } else {
68 m_lineEdit->show(); 69 m_lineEdit->show();
70 m_lineEdit->setFocus(Qt::OtherFocusReason);
69 button->setText(tr("Find:")); 71 button->setText(tr("Find:"));
70 if (m_lineEdit->text() != "") { 72 if (m_lineEdit->text() != "") {
71 emit findTextChanged(m_lineEdit->text()); 73 emit findTextChanged(m_lineEdit->text());
72 } 74 }
73 } 75 }