kspread

kspread_dlg_find.cc

00001 /* This file is part of the KDE project
00002    Copyright (C) 1999-2005 Laurent Montel <montel@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 
00021 #include "kspread_dlg_find.h"
00022 #include <qcheckbox.h>
00023 #include <qlayout.h>
00024 #include <klocale.h>
00025 #include <qpushbutton.h>
00026 #include <qlabel.h>
00027 #include <qcombobox.h>
00028 
00029 using namespace KSpread;
00030 
00031 FindOption::FindOption( QWidget *parent)
00032 {
00033     QVBoxLayout *layout = new QVBoxLayout(parent);
00034     m_moreOptions = new QPushButton( i18n( "More Options" ), parent );
00035     layout->addWidget(  m_moreOptions );
00036 
00037     connect( m_moreOptions, SIGNAL( clicked () ), this, SLOT( slotMoreOptions() ) );
00038 
00039     m_findExtension = new QWidget( parent );
00040     layout->addWidget( m_findExtension );
00041     QVBoxLayout *layout1 = new QVBoxLayout( m_findExtension );
00042     m_searchInAllSheet = new QCheckBox( i18n( "Search entire sheet" ),m_findExtension );
00043     layout1->addWidget( m_searchInAllSheet );
00044 
00045     QHBoxLayout *comboLayout = new QHBoxLayout( m_findExtension );
00046     QLabel *label = new QLabel( i18n( "Search in:" ), m_findExtension );
00047     comboLayout->addWidget( label );
00048 
00049     m_searchIn = new QComboBox( m_findExtension );
00050     comboLayout->addWidget( m_searchIn );
00051     layout1->addLayout( comboLayout );
00052 
00053     QStringList lst;
00054     lst << i18n( "Cell Values" );
00055     lst << i18n( "Comments" );
00056     m_searchIn->insertStringList( lst );
00057 
00058     comboLayout = new QHBoxLayout( m_findExtension );
00059     label = new QLabel( i18n( "Search direction:" ), m_findExtension );
00060     comboLayout->addWidget( label );
00061 
00062     m_searchDirection = new QComboBox( m_findExtension );
00063     comboLayout->addWidget( m_searchDirection );
00064     layout1->addLayout( comboLayout );
00065 
00066     lst.clear();
00067     lst << i18n( "Across then Down" );
00068     lst << i18n( "Down then Across" );
00069     m_searchDirection->insertStringList( lst );
00070 
00071     m_findExtension->hide();
00072     emit adjustSize();
00073 }
00074 
00075 FindOption::searchTypeValue FindOption::searchType() const
00076 {
00077     int pos = m_searchIn->currentItem();
00078     if ( pos == 0 )
00079         return Value;
00080     else if ( pos == 1 )
00081         return Note;
00082     else
00083         return Value;
00084 }
00085 
00086 FindOption::searchDirectionValue FindOption::searchDirection() const
00087 {
00088     int pos = m_searchDirection->currentItem();
00089     if ( pos == 0 )
00090         return Row;
00091     else if ( pos == 1 )
00092         return Column;
00093     else
00094         return Row;
00095 }
00096 
00097 
00098 void FindOption::slotMoreOptions()
00099 {
00100     if ( m_findExtension->isHidden() )
00101     {
00102         m_findExtension->show();
00103         m_moreOptions->setText( i18n( "Fewer Options" ));
00104     }
00105     else
00106     {
00107         m_findExtension->hide();
00108         m_moreOptions->setText( i18n( "More Options" ));
00109     }
00110     emit adjustSize();
00111 }
00112 
00113 bool FindOption::searchInAllSheet() const
00114 {
00115     return m_searchInAllSheet->isChecked();
00116 }
00117 
00118 FindDlg::FindDlg(QWidget *parent, const char *name, long options, const QStringList &findStrings, bool hasSelection )
00119     : KFindDialog(parent,name,options,findStrings,hasSelection  )
00120 {
00121     m_findOptions = new FindOption( findExtension() );
00122     connect( m_findOptions, SIGNAL( adjustSize() ), SLOT( slotAjustSize() ) );
00123     setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
00124 }
00125 
00126 FindDlg::~FindDlg()
00127 {
00128   // no need to delete child widgets, Qt does it all for us
00129 }
00130 
00131 void FindDlg::slotAjustSize()
00132 {
00133     adjustSize();
00134 }
00135 
00136 bool FindDlg::searchInAllSheet() const
00137 {
00138     return m_findOptions->searchInAllSheet();
00139 }
00140 
00141 
00142 SearchDlg::SearchDlg(QWidget *parent, const char *name, long options, const QStringList &findStrings, const QStringList &replaceStrings, bool hasSelection )
00143     : KReplaceDialog(parent,name,options,findStrings,replaceStrings,hasSelection  )
00144 {
00145     m_findOptions = new FindOption( findExtension() );
00146     connect( m_findOptions, SIGNAL( adjustSize() ), SLOT( slotAjustSize() ) );
00147     setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
00148 }
00149 
00150 SearchDlg::~SearchDlg()
00151 {
00152   // no need to delete child widgets, Qt does it all for us
00153 }
00154 
00155 void SearchDlg::slotAjustSize()
00156 {
00157     adjustSize();
00158     setFixedSize(size());
00159 }
00160 
00161 bool SearchDlg::searchInAllSheet() const
00162 {
00163     return m_findOptions->searchInAllSheet();
00164 }
00165 
00166 
00167 #include "kspread_dlg_find.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys