• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdesdk API Reference
  • KDE Home
  • Contact Us
 

okteta

  • sources
  • kde-4.12
  • kdesdk
  • okteta
  • kasten
  • controllers
  • view
  • libfinddialog
kabstractfinddialog.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the Okteta Kasten module, made within the KDE community.
3 
4  Copyright 2006-2007 Friedrich W. H. Kossebau <kossebau@kde.org>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (at your option) version 3, or any
10  later version accepted by the membership of KDE e.V. (or its
11  successor approved by the membership of KDE e.V.), which shall
12  act as a proxy defined in Section 6 of version 3 of the license.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library. If not, see <http://www.gnu.org/licenses/>.
21 */
22 
23 #include "kabstractfinddialog.h"
24 
25 // lib
26 #include <bytearraycombobox.h>
27 // Okteta core
28 #include <oktetacore.h>
29 // KDE
30 #include <KGlobal>
31 #include <KLocale>
32 // Qt
33 #include <QtGui/QCheckBox>
34 #include <QtGui/QGroupBox>
35 #include <QtGui/QLayout>
36 
37 
38 namespace Kasten2
39 {
40 
41 KAbstractFindDialog::KAbstractFindDialog( QWidget* parent )
42  : KDialog( parent )
43 {
44  setButtons( Ok | Cancel );
45  setDefaultButton( Ok );
46 
47  // TODO: setting ok button to disabled as before done gets overwritten to true
48  // if setting the button gui with an inline KGuiItem in the subclass,
49  // which has no parameter for enabled and defaults to true
50 }
51 
52 void KAbstractFindDialog::setupFindBox()
53 {
54  QWidget* page = new QWidget( this );
55  setMainWidget( page );
56 
57  QVBoxLayout *pageLayout = new QVBoxLayout( page );
58  pageLayout->setMargin( 0 );
59 
60  // find term
61  QGroupBox *findBox = new QGroupBox( i18nc("@title:window","Find"), page );
62  pageLayout->addWidget( findBox );
63 
64  QVBoxLayout *findBoxLayout = new QVBoxLayout;
65 
66  SearchDataEdit = new Okteta::ByteArrayComboBox( findBox );
67  connect( SearchDataEdit, SIGNAL(byteArrayChanged(QByteArray)),
68  SLOT(onSearchDataChanged(QByteArray)) );
69  connect( SearchDataEdit, SIGNAL(formatChanged(int)),
70  SLOT(onSearchDataFormatChanged(int)) );
71  const QString toolTip =
72  i18nc("@info:tooltip",
73  "Enter the bytes to search for, or select bytes previously searched for from the list.");
74  SearchDataEdit->setToolTip( toolTip );
75 
76  findBoxLayout->addWidget( SearchDataEdit );
77  findBox->setLayout( findBoxLayout );
78 }
79 
80 void KAbstractFindDialog::setupOperationBox( QGroupBox *operationBox )
81 {
82  QVBoxLayout *pageLayout = static_cast<QVBoxLayout *>( mainWidget()->layout() );
83 
84  // operation box
85  if( operationBox )
86  pageLayout->addWidget( operationBox );
87 }
88 
89 void KAbstractFindDialog::setupCheckBoxes( QCheckBox *optionCheckBox )
90 {
91  QWidget* page = mainWidget();
92  QVBoxLayout *pageLayout = static_cast<QVBoxLayout *>( mainWidget()->layout() );
93 
94  // options
95  QGroupBox *optionsBox = new QGroupBox( i18nc("@title:group","Options"), page );
96  pageLayout->addWidget( optionsBox );
97 
98  QGridLayout *optionsBoxLayout = new QGridLayout( optionsBox );
99 
100  CaseSensitiveCheckBox = new QCheckBox( i18nc("@option:check","C&ase sensitive"),optionsBox);
101  CaseSensitiveCheckBox->setWhatsThis( i18nc("@info:whatsthis","Perform a case sensitive search: "
102  "entering the pattern 'Joe' will not match 'joe' or 'JOE', only 'Joe'.") );
103  WholeWordsCheckBox = new QCheckBox( i18nc("@option:check","&Whole words only"),optionsBox );
104  WholeWordsCheckBox->setWhatsThis( i18nc("@info:whatsthis","Require word boundaries in both ends of a match to succeed.") );
105  AtCursorCheckBox = new QCheckBox( i18nc("@option:check","From c&ursor"), optionsBox );
106  AtCursorCheckBox->setWhatsThis( i18nc("@info:whatsthis","Start searching at the current cursor location rather than at the top.") );
107 
108  BackwardsCheckBox = new QCheckBox( i18nc("@option:check","&Backwards"), optionsBox );
109  BackwardsCheckBox->setWhatsThis(i18nc("@info:whatsthis","Replace backwards.") );
110  SelectedCheckBox = new QCheckBox( i18nc("@option:check","&Selected bytes"), optionsBox );
111  SelectedCheckBox->setWhatsThis( i18nc("@info:whatsthis","Only search within the current selection.") );
112 
113  optionsBoxLayout->addWidget( CaseSensitiveCheckBox, 0, 0 );
114  optionsBoxLayout->addWidget( WholeWordsCheckBox, 1, 0 );
115  optionsBoxLayout->addWidget( AtCursorCheckBox, 2, 0 );
116  optionsBoxLayout->addWidget( BackwardsCheckBox, 0, 1 );
117  optionsBoxLayout->addWidget( SelectedCheckBox, 1, 1 );
118  if( optionCheckBox )
119  optionsBoxLayout->addWidget( optionCheckBox, 2, 1 );
120 
121  setTabOrder( CaseSensitiveCheckBox, WholeWordsCheckBox );
122  setTabOrder( WholeWordsCheckBox, AtCursorCheckBox );
123  setTabOrder( AtCursorCheckBox, BackwardsCheckBox );
124  setTabOrder( BackwardsCheckBox, SelectedCheckBox );
125 // if( optionCheckBox )
126 // setTabOrder( SelectedCheckBox, optionCheckBox );
127 
128  onSearchDataFormatChanged( SearchDataEdit->format() );
129 }
130 
131 bool KAbstractFindDialog::fromCursor() const { return AtCursorCheckBox->isChecked(); }
132 bool KAbstractFindDialog::inSelection() const { return SelectedCheckBox->isChecked(); }
133 KFindDirection KAbstractFindDialog::direction() const
134 {
135  return BackwardsCheckBox->isChecked() ? FindBackward : FindForward;
136 }
137 Qt::CaseSensitivity KAbstractFindDialog::caseSensitivity() const
138 {
139  return ( SearchDataEdit->format() == Okteta::ByteArrayComboBox::CharCoding )
140  && ! CaseSensitiveCheckBox->isChecked() ? Qt::CaseInsensitive : Qt::CaseSensitive;
141 }
142 
143 QByteArray KAbstractFindDialog::data() const
144 {
145  return SearchDataEdit->byteArray();
146 }
147 
148 void KAbstractFindDialog::setDirection( KFindDirection Direction )
149 {
150  BackwardsCheckBox->setChecked( Direction == FindBackward );
151 }
152 
153 void KAbstractFindDialog::setInSelection( bool InSelection )
154 {
155  SelectedCheckBox->setChecked( InSelection );
156 }
157 
158 void KAbstractFindDialog::setCharCodec( const QString &codecName )
159 {
160  SearchDataEdit->setCharCodec( codecName );
161 }
162 
163 void KAbstractFindDialog::rememberCurrentSettings()
164 {
165  SearchDataEdit->rememberCurrentByteArray();
166 }
167 
168 void KAbstractFindDialog::onSearchDataFormatChanged( int index )
169 {
170  const bool isCharCoding = ( index == Okteta::ByteArrayComboBox::CharCoding );
171  CaseSensitiveCheckBox->setEnabled( isCharCoding );
172  WholeWordsCheckBox->setEnabled( false );//isCharCoding ); TODO: not implemented!
173 }
174 
175 void KAbstractFindDialog::onSearchDataChanged( const QByteArray &data )
176 {
177  enableButtonOk( !data.isEmpty() );
178 }
179 
180 
181 void KAbstractFindDialog::showEvent( QShowEvent *showEvent )
182 {
183  KDialog::showEvent(showEvent);
184  SearchDataEdit->setFocus();
185 }
186 
187 
188 KAbstractFindDialog::~KAbstractFindDialog() {}
189 
190 }
Kasten2::KAbstractFindDialog::fromCursor
bool fromCursor() const
Definition: kabstractfinddialog.cpp:131
bytearraycombobox.h
Kasten2::KAbstractFindDialog::showEvent
virtual void showEvent(QShowEvent *e)
Definition: kabstractfinddialog.cpp:181
Okteta::ByteArrayComboBox::format
int format() const
Definition: bytearraycombobox.cpp:83
QWidget
KDialog
Kasten2::FindForward
Definition: kfinddirection.h:30
Kasten2::KAbstractFindDialog::setInSelection
void setInSelection(bool InSelection)
Definition: kabstractfinddialog.cpp:153
Kasten2::KAbstractFindDialog::inSelection
bool inSelection() const
Definition: kabstractfinddialog.cpp:132
Kasten2::KAbstractFindDialog::setCharCodec
void setCharCodec(const QString &codecName)
Definition: kabstractfinddialog.cpp:158
oktetacore.h
Okteta::ByteArrayComboBox::byteArray
QByteArray byteArray() const
Definition: bytearraycombobox.cpp:76
kabstractfinddialog.h
Kasten2::KAbstractFindDialog::setDirection
void setDirection(KFindDirection Direction)
Definition: kabstractfinddialog.cpp:148
Kasten2::KAbstractFindDialog::setupOperationBox
void setupOperationBox(QGroupBox *operationBox=0)
Definition: kabstractfinddialog.cpp:80
Okteta::ByteArrayComboBox::CharCoding
Definition: bytearraycombobox.h:47
Kasten2::KAbstractFindDialog::data
QByteArray data() const
Definition: kabstractfinddialog.cpp:143
Kasten2::Ok
Definition: kastencore.h:61
Kasten2::Cancel
Definition: kastencore.h:60
Kasten2::KFindDirection
KFindDirection
Definition: kfinddirection.h:29
Kasten2::KAbstractFindDialog::~KAbstractFindDialog
virtual ~KAbstractFindDialog()
Definition: kabstractfinddialog.cpp:188
Okteta::ByteArrayComboBox
Definition: bytearraycombobox.h:40
Kasten2::KAbstractFindDialog::rememberCurrentSettings
virtual void rememberCurrentSettings()
Definition: kabstractfinddialog.cpp:163
Kasten2::KAbstractFindDialog::caseSensitivity
Qt::CaseSensitivity caseSensitivity() const
Definition: kabstractfinddialog.cpp:137
Okteta::ByteArrayComboBox::rememberCurrentByteArray
void rememberCurrentByteArray()
Definition: bytearraycombobox.cpp:68
Kasten2::KAbstractFindDialog::direction
KFindDirection direction() const
Definition: kabstractfinddialog.cpp:133
Kasten2::KAbstractFindDialog::setupCheckBoxes
void setupCheckBoxes(QCheckBox *optionCheckBox=0)
Definition: kabstractfinddialog.cpp:89
Kasten2::FindBackward
Definition: kfinddirection.h:31
Kasten2::KAbstractFindDialog::KAbstractFindDialog
KAbstractFindDialog(QWidget *parent=0)
Definition: kabstractfinddialog.cpp:41
Okteta::ByteArrayComboBox::setCharCodec
void setCharCodec(const QString &charCodecName)
Definition: bytearraycombobox.cpp:47
Kasten2::KAbstractFindDialog::setupFindBox
void setupFindBox()
Definition: kabstractfinddialog.cpp:52
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:04:08 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

okteta

Skip menu "okteta"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • okteta
  • umbrello
  •   umbrello

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal