• 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
  • replace
kreplacedialog.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-2009 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 "kreplacedialog.h"
24 
25 // controller
26 #include "replacetool.h"
27 // lib
28 #include <bytearraycombobox.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 KReplaceDialog::KReplaceDialog( ReplaceTool* tool, QWidget* parent )
42  : KAbstractFindDialog( parent ),
43  mTool( tool )
44 {
45  setCaption( i18nc("@title:window","Replace Bytes") );
46  setButtonGuiItem( Ok, KGuiItem( i18nc("@action;button", "&Replace"),
47  QLatin1String("edit-find-replace"),
48  i18nc("@info:tooltip","Start replace"),
49  i18nc("@info:whatsthis",
50  "If you press the <interface>Replace</interface> button, "
51  "the bytes you entered above are searched for within "
52  "the byte array and any occurrence is replaced with "
53  "the replacement bytes.")) );
54 
55  setupFindBox();
56 
57  // replace term
58  QGroupBox *ReplaceBox = new QGroupBox( i18nc("@title:group","Replace With"), mainWidget() );
59 
60  QVBoxLayout *ReplaceBoxLayout = new QVBoxLayout;
61 
62  ReplaceDataEdit = new Okteta::ByteArrayComboBox( ReplaceBox );
63  const QString toolTip =
64  i18nc("@info:tooltip",
65  "Enter the bytes to replace with, or select bytes previously replaced with from the list.");
66  ReplaceDataEdit->setToolTip( toolTip );
67 
68  ReplaceBoxLayout->addWidget( ReplaceDataEdit );
69 
70  ReplaceBox->setLayout( ReplaceBoxLayout );
71  setupOperationBox( ReplaceBox );
72 
73  //
74  PromptCheckBox = new QCheckBox( i18nc("@option:check","&Prompt on replace") );
75  PromptCheckBox->setWhatsThis( i18nc("@info:whatsthis","Ask before replacing each match found.") );
76 
77  setupCheckBoxes( PromptCheckBox );
78 
79  enableButtonOk( false );
80  setModal( true );
81 }
82 
83 
84 QByteArray KReplaceDialog::replaceData() const
85 {
86  return ReplaceDataEdit->byteArray();
87 }
88 
89 bool KReplaceDialog::prompt() const
90 {
91  return PromptCheckBox->isChecked();
92 }
93 
94 void KReplaceDialog::setCharCodec( const QString &codecName )
95 {
96  ReplaceDataEdit->setCharCodec( codecName );
97  KAbstractFindDialog::setCharCodec( codecName );
98 }
99 
100 
101 void KReplaceDialog::slotButtonClicked( int button )
102 {
103  if( button != KDialog::Ok )
104  KAbstractFindDialog::slotButtonClicked( button );
105  else
106  {
107  hide();
108 
109  rememberCurrentSettings();
110 
111  mTool->setSearchData( data() );
112  mTool->setReplaceData( replaceData() );
113  mTool->setCaseSensitivity( caseSensitivity() );
114  mTool->setDoPrompt( prompt() );
115 
116  mTool->replace( direction(), fromCursor(), inSelection() );
117  }
118 }
119 
120 void KReplaceDialog::showEvent( QShowEvent* showEvent )
121 {
122  KAbstractFindDialog::showEvent( showEvent );
123 
124  setInSelection( mTool->hasSelectedData() );
125  setCharCodec( mTool->charCodingName() );
126 }
127 
128 void KReplaceDialog::rememberCurrentSettings()
129 {
130  KAbstractFindDialog::rememberCurrentSettings();
131 
132  ReplaceDataEdit->rememberCurrentByteArray();
133 }
134 
135 KReplaceDialog::~KReplaceDialog() {}
136 
137 }
Kasten2::KAbstractFindDialog::fromCursor
bool fromCursor() const
Definition: kabstractfinddialog.cpp:131
Kasten2::KReplaceDialog::replaceData
QByteArray replaceData() const
Definition: kreplacedialog.cpp:84
bytearraycombobox.h
Kasten2::ReplaceTool::replace
void replace(KFindDirection direction, bool fromCursor, bool inSelection)
Definition: replacetool.cpp:136
Kasten2::KReplaceDialog::KReplaceDialog
KReplaceDialog(ReplaceTool *tool, QWidget *parent=0)
Definition: kreplacedialog.cpp:41
Kasten2::KAbstractFindDialog::showEvent
virtual void showEvent(QShowEvent *e)
Definition: kabstractfinddialog.cpp:181
QWidget
kreplacedialog.h
Kasten2::KReplaceDialog::setCharCodec
void setCharCodec(const QString &codecName)
Definition: kreplacedialog.cpp:94
Kasten2::KAbstractFindDialog::setInSelection
void setInSelection(bool InSelection)
Definition: kabstractfinddialog.cpp:153
Kasten2::KAbstractFindDialog::inSelection
bool inSelection() const
Definition: kabstractfinddialog.cpp:132
Kasten2::KReplaceDialog::~KReplaceDialog
virtual ~KReplaceDialog()
Definition: kreplacedialog.cpp:135
Kasten2::KAbstractFindDialog::setCharCodec
void setCharCodec(const QString &codecName)
Definition: kabstractfinddialog.cpp:158
Okteta::ByteArrayComboBox::byteArray
QByteArray byteArray() const
Definition: bytearraycombobox.cpp:76
Kasten2::KReplaceDialog::showEvent
virtual void showEvent(QShowEvent *showEvent)
Definition: kreplacedialog.cpp:120
Kasten2::ReplaceTool
Definition: replacetool.h:48
Kasten2::ReplaceTool::setReplaceData
void setReplaceData(const QByteArray &replaceData)
Definition: replacetool.cpp:109
Kasten2::KReplaceDialog::rememberCurrentSettings
virtual void rememberCurrentSettings()
Definition: kreplacedialog.cpp:128
Kasten2::ReplaceTool::hasSelectedData
bool hasSelectedData() const
Definition: replacetool.cpp:64
Kasten2::ReplaceTool::setSearchData
void setSearchData(const QByteArray &searchData)
Definition: replacetool.cpp:98
Kasten2::KAbstractFindDialog::setupOperationBox
void setupOperationBox(QGroupBox *operationBox=0)
Definition: kabstractfinddialog.cpp:80
Kasten2::KAbstractFindDialog
Definition: kabstractfinddialog.h:45
Kasten2::KAbstractFindDialog::data
QByteArray data() const
Definition: kabstractfinddialog.cpp:143
Kasten2::Ok
Definition: kastencore.h:61
replacetool.h
Okteta::ByteArrayComboBox
Definition: bytearraycombobox.h:40
Kasten2::KAbstractFindDialog::rememberCurrentSettings
virtual void rememberCurrentSettings()
Definition: kabstractfinddialog.cpp:163
Kasten2::ReplaceTool::setCaseSensitivity
void setCaseSensitivity(Qt::CaseSensitivity caseSensitivity)
Definition: replacetool.cpp:120
Kasten2::KAbstractFindDialog::caseSensitivity
Qt::CaseSensitivity caseSensitivity() const
Definition: kabstractfinddialog.cpp:137
Okteta::ByteArrayComboBox::rememberCurrentByteArray
void rememberCurrentByteArray()
Definition: bytearraycombobox.cpp:68
Kasten2::ReplaceTool::charCodingName
QString charCodingName() const
Definition: replacetool.cpp:65
Kasten2::KAbstractFindDialog::direction
KFindDirection direction() const
Definition: kabstractfinddialog.cpp:133
Kasten2::KAbstractFindDialog::setupCheckBoxes
void setupCheckBoxes(QCheckBox *optionCheckBox=0)
Definition: kabstractfinddialog.cpp:89
Okteta::ByteArrayComboBox::setCharCodec
void setCharCodec(const QString &charCodecName)
Definition: bytearraycombobox.cpp:47
Kasten2::KReplaceDialog::slotButtonClicked
virtual void slotButtonClicked(int button)
Definition: kreplacedialog.cpp:101
Kasten2::ReplaceTool::setDoPrompt
void setDoPrompt(int doPrompt)
Definition: replacetool.cpp:131
Kasten2::KAbstractFindDialog::setupFindBox
void setupFindBox()
Definition: kabstractfinddialog.cpp:52
Kasten2::KReplaceDialog::prompt
bool prompt() const
Definition: kreplacedialog.cpp:89
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