File indexing completed on 2024-05-12 16:35:18
0001 /* This file is part of the KDE project 0002 Copyright (C) 1999-2005 Laurent Montel <montel@kde.org> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License as published by the Free Software Foundation; either 0007 version 2 of the License, or (at your option) any later version. 0008 0009 This library is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 Library General Public License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this library; see the file COPYING.LIB. If not, write to 0016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #include "FindDialog.h" 0021 0022 #include <QCheckBox> 0023 #include <QHBoxLayout> 0024 #include <QLabel> 0025 #include <QPushButton> 0026 #include <QVBoxLayout> 0027 0028 #include <kcombobox.h> 0029 #include <KLocalizedString> 0030 0031 using namespace Calligra::Sheets; 0032 0033 FindOption::FindOption(QWidget *parent) 0034 { 0035 QVBoxLayout *layout = new QVBoxLayout(parent); 0036 m_moreOptions = new QPushButton(i18n("More Options"), parent); 0037 layout->addWidget(m_moreOptions); 0038 0039 connect(m_moreOptions, SIGNAL(clicked()), this, SLOT(slotMoreOptions())); 0040 0041 m_findExtension = new QWidget(parent); 0042 layout->addWidget(m_findExtension); 0043 QVBoxLayout *layout1 = new QVBoxLayout(m_findExtension); 0044 m_searchInAllSheet = new QCheckBox(i18n("Search entire sheet"), m_findExtension); 0045 layout1->addWidget(m_searchInAllSheet); 0046 0047 QHBoxLayout *comboLayout = new QHBoxLayout(); 0048 QLabel *label = new QLabel(i18n("Search in:"), m_findExtension); 0049 comboLayout->addWidget(label); 0050 0051 m_searchIn = new KComboBox(m_findExtension); 0052 comboLayout->addWidget(m_searchIn); 0053 layout1->addLayout(comboLayout); 0054 0055 QStringList lst; 0056 lst << i18n("Cell Values"); 0057 lst << i18n("Comments"); 0058 m_searchIn->insertItems(0, lst); 0059 0060 comboLayout = new QHBoxLayout(); 0061 label = new QLabel(i18n("Search direction:"), m_findExtension); 0062 comboLayout->addWidget(label); 0063 0064 m_searchDirection = new KComboBox(m_findExtension); 0065 comboLayout->addWidget(m_searchDirection); 0066 layout1->addLayout(comboLayout); 0067 0068 lst.clear(); 0069 lst << i18n("Across then Down"); 0070 lst << i18n("Down then Across"); 0071 m_searchDirection->insertItems(0, lst); 0072 0073 m_findExtension->hide(); 0074 emit adjustSize(); 0075 } 0076 0077 FindOption::searchTypeValue FindOption::searchType() const 0078 { 0079 int pos = m_searchIn->currentIndex(); 0080 if (pos == 0) 0081 return Value; 0082 else if (pos == 1) 0083 return Note; 0084 else 0085 return Value; 0086 } 0087 0088 FindOption::searchDirectionValue FindOption::searchDirection() const 0089 { 0090 int pos = m_searchDirection->currentIndex(); 0091 if (pos == 0) 0092 return Row; 0093 else if (pos == 1) 0094 return Column; 0095 else 0096 return Row; 0097 } 0098 0099 0100 void FindOption::slotMoreOptions() 0101 { 0102 if (m_findExtension->isHidden()) { 0103 m_findExtension->show(); 0104 m_moreOptions->setText(i18n("Fewer Options")); 0105 } else { 0106 m_findExtension->hide(); 0107 m_moreOptions->setText(i18n("More Options")); 0108 } 0109 emit adjustSize(); 0110 } 0111 0112 bool FindOption::searchInAllSheet() const 0113 { 0114 return m_searchInAllSheet->isChecked(); 0115 } 0116 0117 FindDlg::FindDlg(QWidget *parent, const QString &name, long options, const QStringList &findStrings, bool hasSelection) 0118 : KFindDialog(parent, options, findStrings, hasSelection) 0119 { 0120 setObjectName(name); 0121 m_findOptions = new FindOption(findExtension()); 0122 connect(m_findOptions, SIGNAL(adjustSize()), SLOT(slotAjustSize())); 0123 setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); 0124 } 0125 0126 FindDlg::~FindDlg() 0127 { 0128 // no need to delete child widgets, Qt does it all for us 0129 } 0130 0131 void FindDlg::slotAjustSize() 0132 { 0133 adjustSize(); 0134 } 0135 0136 bool FindDlg::searchInAllSheet() const 0137 { 0138 return m_findOptions->searchInAllSheet(); 0139 } 0140 0141 0142 SearchDlg::SearchDlg(QWidget *parent, const QString &name, long options, const QStringList &findStrings, const QStringList &replaceStrings, bool hasSelection) 0143 : KReplaceDialog(parent, options, findStrings, replaceStrings, hasSelection) 0144 { 0145 setObjectName(name); 0146 m_findOptions = new FindOption(findExtension()); 0147 connect(m_findOptions, SIGNAL(adjustSize()), SLOT(slotAjustSize())); 0148 setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); 0149 } 0150 0151 SearchDlg::~SearchDlg() 0152 { 0153 // no need to delete child widgets, Qt does it all for us 0154 } 0155 0156 void SearchDlg::slotAjustSize() 0157 { 0158 adjustSize(); 0159 setFixedSize(size()); 0160 } 0161 0162 bool SearchDlg::searchInAllSheet() const 0163 { 0164 return m_findOptions->searchInAllSheet(); 0165 }