• 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
  • selectrange
selectrangeview.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 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 "selectrangeview.h"
24 
25 // tool
26 #include "selectrangetool.h"
27 // lib
28 #include <addresscombobox.h>
29 // KDE
30 #include <KPushButton>
31 #include <KGuiItem>
32 #include <KLocale>
33 // Qt
34 #include <QtGui/QCheckBox>
35 #include <QtGui/QLabel>
36 #include <QtGui/QLayout>
37 
38 
39 namespace Kasten2
40 {
41 
42 SelectRangeView::SelectRangeView( SelectRangeTool* tool, QWidget* parent )
43  : AbstractToolWidget( parent ),
44  mTool( tool )
45 {
46  QHBoxLayout* baseLayout = new QHBoxLayout( this );
47  baseLayout->setMargin( 0 );
48 
49  // offsets
50  QVBoxLayout* offsetLayout = new QVBoxLayout();
51  offsetLayout->setMargin( 0 );
52 
53  // start offset
54  QHBoxLayout* startOffsetLayout = new QHBoxLayout();
55  startOffsetLayout->setMargin( 0 );
56 
57  QLabel* label = new QLabel( i18nc("@label:listbox","Start offset:"), this );
58  mStartEdit = new Okteta::AddressComboBox( this );
59  connect( mStartEdit, SIGNAL(addressChanged(Okteta::Address)),
60  mTool, SLOT(setTargetStart(Okteta::Address)) );
61  label->setBuddy( mStartEdit );
62  const QString startInputWhatsThis =
63  i18nc( "@info:whatsthis","Enter an offset to go to, or select a previous offset from the list." );
64  label->setWhatsThis( startInputWhatsThis );
65  mStartEdit->setWhatsThis( startInputWhatsThis );
66 
67  startOffsetLayout->addWidget( label );
68  startOffsetLayout->addWidget( mStartEdit );
69  setFocusProxy( mStartEdit ); // TODO: see how KDialog does it, e.g. see if there is already a focuswidget as child
70 
71  offsetLayout->addLayout( startOffsetLayout );
72 
73  // end offset
74  QHBoxLayout* endOffsetLayout = new QHBoxLayout();
75  endOffsetLayout->setMargin( 0 );
76 
77  label = new QLabel( i18nc("@label:listbox","End offset:"), this );
78  mEndEdit = new Okteta::AddressComboBox( this );
79  connect( mEndEdit, SIGNAL(addressChanged(Okteta::Address)),
80  mTool, SLOT(setTargetEnd(Okteta::Address)) );
81  label->setBuddy( mEndEdit );
82  const QString endInputWhatsThis =
83  i18nc( "@info:whatsthis","Enter an offset to go to, or select a previous offset from the list." );
84  label->setWhatsThis( endInputWhatsThis );
85  mEndEdit->setWhatsThis( endInputWhatsThis );
86 
87  endOffsetLayout->addWidget( label );
88  endOffsetLayout->addWidget( mEndEdit );
89 
90  offsetLayout->addLayout( endOffsetLayout );
91  baseLayout->addLayout( offsetLayout );
92 
93  // options
94  QVBoxLayout* optionsLayout = new QVBoxLayout();
95  optionsLayout->setMargin( 0 );
96 
97  mRelativeCheckBox = new QCheckBox( i18nc("@option:check","End relative"), this );
98  mRelativeCheckBox->setWhatsThis(
99  i18nc("@info:whatsthis","Extend the selection by the cursor move.") );
100  connect( mRelativeCheckBox, SIGNAL(toggled(bool)),
101  mTool, SLOT(setIsEndRelative(bool)) );
102  mRelativeCheckBox->setChecked( mTool->isEndRelative() );
103  mBackwardsCheckBox = new QCheckBox( i18nc("@option:check","&Backwards"), this );
104  mBackwardsCheckBox->setWhatsThis(
105  i18nc("@info:whatsthis","Go backwards from the end or the current cursor location.") );
106  connect( mBackwardsCheckBox, SIGNAL(toggled(bool)),
107  mTool, SLOT(setIsEndBackwards(bool)) );
108  mBackwardsCheckBox->setChecked( mTool->isEndBackwards() );
109 
110  connect( mRelativeCheckBox, SIGNAL(toggled(bool)), mBackwardsCheckBox, SLOT(setEnabled(bool)) );
111  mBackwardsCheckBox->setEnabled( mRelativeCheckBox->isChecked() );
112 
113  optionsLayout->addWidget( mRelativeCheckBox );
114  optionsLayout->addWidget( mBackwardsCheckBox );
115 
116  baseLayout->addLayout( optionsLayout );
117 
118  // Select button
119  const KGuiItem selectGuiItem =
120  KGuiItem( i18nc("@action:button",
121  "&Select"),
122  QString(),
123  i18nc("@info:tooltip",
124  "Select the range."),
125  i18nc("@info:whatsthis",
126  "If you press the <interface>Select</interface> "
127  "button, the cursor will be moved in the document to or, "
128  "on your option, by the offset you entered above.") );
129  mSelectButton = new KPushButton( selectGuiItem, this );
130  connect( mSelectButton, SIGNAL(clicked(bool)), SLOT(onSelectButtonClicked()) );
131  addButton( mSelectButton, AbstractToolWidget::Default );
132  baseLayout->addWidget( mSelectButton );
133  baseLayout->setAlignment( mSelectButton, Qt::AlignTop );
134 
135  baseLayout->addStretch();
136 
137  setTabOrder( mStartEdit, mEndEdit );
138  setTabOrder( mEndEdit, mRelativeCheckBox );
139  setTabOrder( mRelativeCheckBox, mBackwardsCheckBox );
140  setTabOrder( mBackwardsCheckBox, mSelectButton );
141 
142  connect( mTool, SIGNAL(isApplyableChanged(bool)), SLOT(onApplyableChanged(bool)) );
143 
144  onApplyableChanged( mTool->isApplyable() );
145 }
146 
147 
148 void SelectRangeView::onApplyableChanged( bool isApplyable )
149 {
150  // TODO: set error tooltip, like offset out of range or no document
151  // TODO: set color flag to offset input
152  mSelectButton->setEnabled( isApplyable );
153 }
154 
155 void SelectRangeView::onSelectButtonClicked()
156 {
157  // TODO: collect recently used offsets in tool instead?
158  mStartEdit->rememberCurrentAddress();
159  mEndEdit->rememberCurrentAddress();
160 
161  mTool->select();
162 // emit toolUsed();
163 }
164 
165 
166 SelectRangeView::~SelectRangeView() {}
167 
168 }
Kasten2::SelectRangeTool
Definition: selectrangetool.h:44
Okteta::Address
qint32 Address
Definition: address.h:34
Kasten2::AbstractToolWidget::addButton
void addButton(QPushButton *button, DefaultType defaultType=AutoDefault)
Definition: abstracttoolwidget.cpp:37
selectrangetool.h
Kasten2::SelectRangeTool::isEndRelative
bool isEndRelative() const
Definition: selectrangetool.h:104
QWidget
Kasten2::AbstractToolWidget
Definition: abstracttoolwidget.h:41
Kasten2::SelectRangeTool::isApplyable
bool isApplyable() const
Definition: selectrangetool.cpp:66
Kasten2::SelectRangeView::~SelectRangeView
virtual ~SelectRangeView()
Definition: selectrangeview.cpp:166
Kasten2::AbstractToolWidget::Default
Definition: abstracttoolwidget.h:46
Okteta::AddressComboBox
Definition: addresscombobox.h:42
selectrangeview.h
addresscombobox.h
Okteta::AddressComboBox::rememberCurrentAddress
void rememberCurrentAddress()
Definition: addresscombobox.cpp:63
Kasten2::SelectRangeView::SelectRangeView
SelectRangeView(SelectRangeTool *tool, QWidget *parent=0)
Definition: selectrangeview.cpp:42
Kasten2::SelectRangeTool::select
void select()
Definition: selectrangetool.cpp:153
Kasten2::SelectRangeTool::isEndBackwards
bool isEndBackwards() const
Definition: selectrangetool.h:105
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:04:09 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