kspread

kspread_dlg_find.cpp
1/* This file is part of the KDE project
2 Copyright (C) 1999-2005 Laurent Montel <montel@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20
21#include "kspread_dlg_find.h"
22#include <tqcheckbox.h>
23#include <tqlayout.h>
24#include <tdelocale.h>
25#include <tqpushbutton.h>
26#include <tqlabel.h>
27#include <tqcombobox.h>
28
29using namespace KSpread;
30
31FindOption::FindOption( TQWidget *parent)
32{
33 TQVBoxLayout *layout = new TQVBoxLayout(parent);
34 m_moreOptions = new TQPushButton( i18n( "More Options" ), parent );
35 layout->addWidget( m_moreOptions );
36
37 connect( m_moreOptions, TQ_SIGNAL( clicked () ), this, TQ_SLOT( slotMoreOptions() ) );
38
39 m_findExtension = new TQWidget( parent );
40 layout->addWidget( m_findExtension );
41 TQVBoxLayout *layout1 = new TQVBoxLayout( m_findExtension );
42 m_searchInAllSheet = new TQCheckBox( i18n( "Search entire sheet" ),m_findExtension );
43 layout1->addWidget( m_searchInAllSheet );
44
45 TQHBoxLayout *comboLayout = new TQHBoxLayout( m_findExtension );
46 TQLabel *label = new TQLabel( i18n( "Search in:" ), m_findExtension );
47 comboLayout->addWidget( label );
48
49 m_searchIn = new TQComboBox( m_findExtension );
50 comboLayout->addWidget( m_searchIn );
51 layout1->addLayout( comboLayout );
52
53 TQStringList lst;
54 lst << i18n( "Cell Values" );
55 lst << i18n( "Comments" );
56 m_searchIn->insertStringList( lst );
57
58 comboLayout = new TQHBoxLayout( m_findExtension );
59 label = new TQLabel( i18n( "Search direction:" ), m_findExtension );
60 comboLayout->addWidget( label );
61
62 m_searchDirection = new TQComboBox( m_findExtension );
63 comboLayout->addWidget( m_searchDirection );
64 layout1->addLayout( comboLayout );
65
66 lst.clear();
67 lst << i18n( "Across then Down" );
68 lst << i18n( "Down then Across" );
69 m_searchDirection->insertStringList( lst );
70
71 m_findExtension->hide();
72 emit adjustSize();
73}
74
75FindOption::searchTypeValue FindOption::searchType() const
76{
77 int pos = m_searchIn->currentItem();
78 if ( pos == 0 )
79 return Value;
80 else if ( pos == 1 )
81 return Note;
82 else
83 return Value;
84}
85
86FindOption::searchDirectionValue FindOption::searchDirection() const
87{
88 int pos = m_searchDirection->currentItem();
89 if ( pos == 0 )
90 return Row;
91 else if ( pos == 1 )
92 return Column;
93 else
94 return Row;
95}
96
97
98void FindOption::slotMoreOptions()
99{
100 if ( m_findExtension->isHidden() )
101 {
102 m_findExtension->show();
103 m_moreOptions->setText( i18n( "Fewer Options" ));
104 }
105 else
106 {
107 m_findExtension->hide();
108 m_moreOptions->setText( i18n( "More Options" ));
109 }
110 emit adjustSize();
111}
112
113bool FindOption::searchInAllSheet() const
114{
115 return m_searchInAllSheet->isChecked();
116}
117
118FindDlg::FindDlg(TQWidget *parent, const char *name, long options, const TQStringList &findStrings, bool hasSelection )
119 : KFindDialog(parent,name,options,findStrings,hasSelection )
120{
121 m_findOptions = new FindOption( findExtension() );
122 connect( m_findOptions, TQ_SIGNAL( adjustSize() ), TQ_SLOT( slotAjustSize() ) );
123 setSizePolicy(TQSizePolicy(TQSizePolicy::Minimum, TQSizePolicy::Minimum));
124}
125
126FindDlg::~FindDlg()
127{
128 // no need to delete child widgets, TQt does it all for us
129}
130
131void FindDlg::slotAjustSize()
132{
133 adjustSize();
134}
135
136bool FindDlg::searchInAllSheet() const
137{
138 return m_findOptions->searchInAllSheet();
139}
140
141
142SearchDlg::SearchDlg(TQWidget *parent, const char *name, long options, const TQStringList &findStrings, const TQStringList &replaceStrings, bool hasSelection )
143 : KReplaceDialog(parent,name,options,findStrings,replaceStrings,hasSelection )
144{
145 m_findOptions = new FindOption( findExtension() );
146 connect( m_findOptions, TQ_SIGNAL( adjustSize() ), TQ_SLOT( slotAjustSize() ) );
147 setSizePolicy(TQSizePolicy(TQSizePolicy::Minimum, TQSizePolicy::Minimum));
148}
149
150SearchDlg::~SearchDlg()
151{
152 // no need to delete child widgets, TQt does it all for us
153}
154
155void SearchDlg::slotAjustSize()
156{
157 adjustSize();
158 setFixedSize(size());
159}
160
161bool SearchDlg::searchInAllSheet() const
162{
163 return m_findOptions->searchInAllSheet();
164}
165
166
167#include "kspread_dlg_find.moc"
The KSpread namespace.
Definition commands.h:39