~showard314/ubuntu/natty/qtiplot/Python2.7_fix

« back to all changes in this revision

Viewing changes to qtiplot/src/FindDialog.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Gudjon I. Gudjonsson
  • Date: 2007-03-25 12:06:27 UTC
  • Revision ID: james.westby@ubuntu.com-20070325120627-5pvdufddr7i0r74x
Tags: upstream-0.9~rc2
ImportĀ upstreamĀ versionĀ 0.9~rc2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
    File                 : FindDialog.cpp
 
3
    Project              : QtiPlot
 
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
 
8
                           
 
9
 ***************************************************************************/
 
10
 
 
11
/***************************************************************************
 
12
 *                                                                         *
 
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.                                    *
 
17
 *                                                                         *
 
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.                           *
 
22
 *                                                                         *
 
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                                           *
 
27
 *                                                                         *
 
28
 ***************************************************************************/
 
29
#include "FindDialog.h"
 
30
#include "ApplicationWindow.h"
 
31
#include "Folder.h"
 
32
 
 
33
#include <QPushButton>
 
34
#include <QCheckBox>
 
35
#include <QComboBox>
 
36
#include <QGridLayout>
 
37
#include <QRegExp>
 
38
#include <QLabel>
 
39
#include <QVBoxLayout>
 
40
#include <QFrame>
 
41
#include <QGroupBox>
 
42
 
 
43
FindDialog::FindDialog( QWidget* parent, Qt::WFlags fl )
 
44
    : QDialog( parent, fl )
 
45
{
 
46
        setWindowTitle (tr("QtiPlot") + " - " + tr("Find"));
 
47
        setSizeGripEnabled( true );
 
48
 
 
49
        QGridLayout * topLayout = new QGridLayout();
 
50
        QGridLayout * bottomLayout = new QGridLayout();
 
51
        
 
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 );
 
57
 
 
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 );
 
68
 
 
69
 
 
70
        QGroupBox * groupBox = new QGroupBox(tr("Search in"));
 
71
        QVBoxLayout * groupBoxLayout = new QVBoxLayout( groupBox );
 
72
 
 
73
        boxWindowNames = new QCheckBox(tr("&Window Names"));
 
74
    boxWindowNames->setChecked(true);
 
75
        groupBoxLayout->addWidget(boxWindowNames);
 
76
        
 
77
    boxWindowLabels = new QCheckBox(tr("Window &Labels"));
 
78
    boxWindowLabels->setChecked( false );
 
79
        groupBoxLayout->addWidget(boxWindowLabels);
 
80
        
 
81
    boxFolderNames = new QCheckBox(tr("Folder &Names"));
 
82
    boxFolderNames->setChecked( false );
 
83
        groupBoxLayout->addWidget(boxFolderNames);
 
84
        
 
85
        bottomLayout->addWidget( groupBox, 0, 0, 3, 1 );
 
86
 
 
87
        boxCaseSensitive = new QCheckBox(tr("Case &Sensitive"));
 
88
    boxCaseSensitive->setChecked(false);
 
89
        bottomLayout->addWidget( boxCaseSensitive, 0, 1 );
 
90
 
 
91
    boxPartialMatch = new QCheckBox(tr("&Partial Match Allowed"));
 
92
    boxPartialMatch->setChecked(true);
 
93
        bottomLayout->addWidget( boxPartialMatch, 1, 1 );
 
94
        
 
95
        boxSubfolders = new QCheckBox(tr("&Include Subfolders"));
 
96
    boxSubfolders->setChecked(true);
 
97
        bottomLayout->addWidget( boxSubfolders, 2, 1 );
 
98
        
 
99
        buttonFind = new QPushButton(tr("&Find"));
 
100
    buttonFind->setDefault( true );
 
101
        bottomLayout->addWidget( buttonFind, 0, 2 );
 
102
   
 
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 );
 
107
 
 
108
        QVBoxLayout* mainLayout = new QVBoxLayout(this);
 
109
        mainLayout->addLayout(topLayout);
 
110
        mainLayout->addLayout(bottomLayout);
 
111
 
 
112
        setStartPath();
 
113
   
 
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() ) );
 
118
}
 
119
 
 
120
void FindDialog::setStartPath()
 
121
{
 
122
        ApplicationWindow *app = (ApplicationWindow *)this->parent();
 
123
        labelStart->setText(app->current_folder->path());
 
124
}
 
125
 
 
126
void FindDialog::accept()
 
127
{
 
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();
 
134
        if(!text.isEmpty()) 
 
135
        {
 
136
                if(boxFind->findText(text) == -1) // no duplicates
 
137
                {
 
138
                        boxFind->insertItem(0, text);
 
139
                        boxFind->setCurrentIndex(0);
 
140
                }
 
141
        }
 
142
}
 
143
 
 
144
FindDialog::~FindDialog()
 
145
{
 
146
}