annotate src/findwidget.cpp @ 556:04f18b2a32e8 find

Add forgotten files. So busy looking at the test search results, I totally forget to read what the program is actually telling me!
author Chris Cannam
date Thu, 23 Feb 2012 11:44:50 +0000
parents
children 57a7f95ef400
rev   line source
Chris@556 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@556 2
Chris@556 3 /*
Chris@556 4 EasyMercurial
Chris@556 5
Chris@556 6 Based on HgExplorer by Jari Korhonen
Chris@556 7 Copyright (c) 2010 Jari Korhonen
Chris@556 8 Copyright (c) 2011 Chris Cannam
Chris@556 9 Copyright (c) 2011 Queen Mary, University of London
Chris@556 10
Chris@556 11 This program is free software; you can redistribute it and/or
Chris@556 12 modify it under the terms of the GNU General Public License as
Chris@556 13 published by the Free Software Foundation; either version 2 of the
Chris@556 14 License, or (at your option) any later version. See the file
Chris@556 15 COPYING included with this distribution for more information.
Chris@556 16 */
Chris@556 17
Chris@556 18 #include "findwidget.h"
Chris@556 19
Chris@556 20 #include <QGridLayout>
Chris@556 21 #include <QLabel>
Chris@556 22 #include <QLineEdit>
Chris@556 23 #include <QToolButton>
Chris@556 24
Chris@556 25 FindWidget::FindWidget(QWidget *parent) :
Chris@556 26 QWidget(parent)
Chris@556 27 {
Chris@556 28 QGridLayout *layout = new QGridLayout;
Chris@556 29 setLayout(layout);
Chris@556 30
Chris@556 31 QToolButton *button = new QToolButton();
Chris@556 32 layout->addWidget(button, 0, 0);
Chris@556 33 button->setText(tr("Find..."));
Chris@556 34 button->setToolButtonStyle(Qt::ToolButtonTextOnly);
Chris@556 35 button->setAutoRaise(true);
Chris@556 36 connect(button, SIGNAL(clicked()), this, SLOT(buttonPressed()));
Chris@556 37
Chris@556 38 /*
Chris@556 39 QLabel *label = new QLabel(tr("Find:"));
Chris@556 40 layout->addWidget(label, 0, 0);
Chris@556 41 */
Chris@556 42 m_lineEdit = new QLineEdit();
Chris@556 43 layout->addWidget(m_lineEdit, 0, 1);
Chris@556 44
Chris@556 45 m_lineEdit->setFixedWidth(100);
Chris@556 46 m_lineEdit->hide();
Chris@556 47
Chris@556 48 connect(m_lineEdit, SIGNAL(textChanged(const QString &)),
Chris@556 49 this, SIGNAL(findTextChanged(QString)));
Chris@556 50 }
Chris@556 51
Chris@556 52 FindWidget::~FindWidget()
Chris@556 53 {
Chris@556 54 }
Chris@556 55
Chris@556 56 void
Chris@556 57 FindWidget::buttonPressed()
Chris@556 58 {
Chris@556 59 QAbstractButton *button = qobject_cast<QAbstractButton *>(sender());
Chris@556 60 if (!button) return;
Chris@556 61 if (m_lineEdit->isVisible()) {
Chris@556 62 m_lineEdit->hide();
Chris@556 63 button->setText(tr("Find..."));
Chris@556 64 } else {
Chris@556 65 m_lineEdit->show();
Chris@556 66 button->setText(tr("Find:"));
Chris@556 67 }
Chris@556 68 }
Chris@556 69