1
/***************************************************************************
4
--------------------------------------------------------------------
5
Copyright : (C) 2006 by Ion Vasilief, Tilman Hoener zu Siederdissen
6
Email (use @ for *) : ion_vasilief*yahoo.fr, thzs*gmx.net
7
Description : Find dialog
9
***************************************************************************/
11
/***************************************************************************
13
* This program is free software; you can redistribute it and/or modify *
14
* it under the terms of the GNU General Public License as published by *
15
* the Free Software Foundation; either version 2 of the License, or *
16
* (at your option) any later version. *
18
* This program is distributed in the hope that it will be useful, *
19
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
20
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21
* GNU General Public License for more details. *
23
* You should have received a copy of the GNU General Public License *
24
* along with this program; if not, write to the Free Software *
25
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
26
* Boston, MA 02110-1301 USA *
28
***************************************************************************/
29
#include "FindDialog.h"
30
#include "ApplicationWindow.h"
33
#include <QPushButton>
36
#include <QGridLayout>
39
#include <QVBoxLayout>
43
FindDialog::FindDialog( QWidget* parent, Qt::WFlags fl )
44
: QDialog( parent, fl )
46
setWindowTitle (tr("QtiPlot") + " - " + tr("Find"));
47
setSizeGripEnabled( true );
49
QGridLayout * topLayout = new QGridLayout();
50
QGridLayout * bottomLayout = new QGridLayout();
52
topLayout->addWidget( new QLabel(tr( "Start From" )), 0, 0 );
53
labelStart = new QLabel();
54
labelStart->setFrameStyle(QFrame::Panel | QFrame::Sunken);
55
labelStart->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
56
topLayout->addWidget( labelStart, 0, 1, 1, 4 );
58
topLayout->addWidget( new QLabel(tr( "Find" )), 1, 0 );
59
boxFind = new QComboBox();
60
boxFind->setEditable(true);
61
boxFind->setDuplicatesEnabled(false);
62
boxFind->setInsertPolicy( QComboBox::InsertAtTop );
63
boxFind->setAutoCompletion(true);
64
boxFind->setMaxCount ( 10 );
65
boxFind->setMaxVisibleItems ( 10 );
66
boxFind->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
67
topLayout->addWidget( boxFind, 1, 1, 1, 4 );
70
QGroupBox * groupBox = new QGroupBox(tr("Search in"));
71
QVBoxLayout * groupBoxLayout = new QVBoxLayout( groupBox );
73
boxWindowNames = new QCheckBox(tr("&Window Names"));
74
boxWindowNames->setChecked(true);
75
groupBoxLayout->addWidget(boxWindowNames);
77
boxWindowLabels = new QCheckBox(tr("Window &Labels"));
78
boxWindowLabels->setChecked( false );
79
groupBoxLayout->addWidget(boxWindowLabels);
81
boxFolderNames = new QCheckBox(tr("Folder &Names"));
82
boxFolderNames->setChecked( false );
83
groupBoxLayout->addWidget(boxFolderNames);
85
bottomLayout->addWidget( groupBox, 0, 0, 3, 1 );
87
boxCaseSensitive = new QCheckBox(tr("Case &Sensitive"));
88
boxCaseSensitive->setChecked(false);
89
bottomLayout->addWidget( boxCaseSensitive, 0, 1 );
91
boxPartialMatch = new QCheckBox(tr("&Partial Match Allowed"));
92
boxPartialMatch->setChecked(true);
93
bottomLayout->addWidget( boxPartialMatch, 1, 1 );
95
boxSubfolders = new QCheckBox(tr("&Include Subfolders"));
96
boxSubfolders->setChecked(true);
97
bottomLayout->addWidget( boxSubfolders, 2, 1 );
99
buttonFind = new QPushButton(tr("&Find"));
100
buttonFind->setDefault( true );
101
bottomLayout->addWidget( buttonFind, 0, 2 );
103
buttonReset = new QPushButton(tr("&Update Start Path"));
104
bottomLayout->addWidget( buttonReset, 1, 2 );
105
buttonCancel = new QPushButton(tr("&Close"));
106
bottomLayout->addWidget( buttonCancel, 2, 2 );
108
QVBoxLayout* mainLayout = new QVBoxLayout(this);
109
mainLayout->addLayout(topLayout);
110
mainLayout->addLayout(bottomLayout);
114
// signals and slots connections
115
connect( buttonFind, SIGNAL( clicked() ), this, SLOT( accept() ) );
116
connect( buttonReset, SIGNAL( clicked() ), this, SLOT( setStartPath() ) );
117
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
120
void FindDialog::setStartPath()
122
ApplicationWindow *app = (ApplicationWindow *)this->parent();
123
labelStart->setText(app->current_folder->path());
126
void FindDialog::accept()
128
ApplicationWindow *app = (ApplicationWindow *)this->parent();
129
app->find(boxFind->currentText(), boxWindowNames->isChecked(), boxWindowLabels->isChecked(),
130
boxFolderNames->isChecked(), boxCaseSensitive->isChecked(), boxPartialMatch->isChecked(),
131
boxSubfolders->isChecked());
132
// add the combo box's current text to the list when the find button is pressed
133
QString text = boxFind->currentText();
136
if(boxFind->findText(text) == -1) // no duplicates
138
boxFind->insertItem(0, text);
139
boxFind->setCurrentIndex(0);
144
FindDialog::~FindDialog()