30 #include <KPushButton>
34 #include <QtGui/QCheckBox>
35 #include <QtGui/QLabel>
36 #include <QtGui/QLayout>
46 QHBoxLayout* baseLayout =
new QHBoxLayout(
this );
47 baseLayout->setMargin( 0 );
50 QVBoxLayout* offsetLayout =
new QVBoxLayout();
51 offsetLayout->setMargin( 0 );
54 QHBoxLayout* startOffsetLayout =
new QHBoxLayout();
55 startOffsetLayout->setMargin( 0 );
57 QLabel* label =
new QLabel( i18nc(
"@label:listbox",
"Start offset:"),
this );
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 );
67 startOffsetLayout->addWidget( label );
68 startOffsetLayout->addWidget( mStartEdit );
69 setFocusProxy( mStartEdit );
71 offsetLayout->addLayout( startOffsetLayout );
74 QHBoxLayout* endOffsetLayout =
new QHBoxLayout();
75 endOffsetLayout->setMargin( 0 );
77 label =
new QLabel( i18nc(
"@label:listbox",
"End offset:"),
this );
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 );
87 endOffsetLayout->addWidget( label );
88 endOffsetLayout->addWidget( mEndEdit );
90 offsetLayout->addLayout( endOffsetLayout );
91 baseLayout->addLayout( offsetLayout );
94 QVBoxLayout* optionsLayout =
new QVBoxLayout();
95 optionsLayout->setMargin( 0 );
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)) );
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)) );
110 connect( mRelativeCheckBox, SIGNAL(toggled(
bool)), mBackwardsCheckBox, SLOT(setEnabled(
bool)) );
111 mBackwardsCheckBox->setEnabled( mRelativeCheckBox->isChecked() );
113 optionsLayout->addWidget( mRelativeCheckBox );
114 optionsLayout->addWidget( mBackwardsCheckBox );
116 baseLayout->addLayout( optionsLayout );
119 const KGuiItem selectGuiItem =
120 KGuiItem( i18nc(
"@action:button",
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()) );
132 baseLayout->addWidget( mSelectButton );
133 baseLayout->setAlignment( mSelectButton, Qt::AlignTop );
135 baseLayout->addStretch();
137 setTabOrder( mStartEdit, mEndEdit );
138 setTabOrder( mEndEdit, mRelativeCheckBox );
139 setTabOrder( mRelativeCheckBox, mBackwardsCheckBox );
140 setTabOrder( mBackwardsCheckBox, mSelectButton );
142 connect( mTool, SIGNAL(isApplyableChanged(
bool)), SLOT(onApplyableChanged(
bool)) );
148 void SelectRangeView::onApplyableChanged(
bool isApplyable )
152 mSelectButton->setEnabled( isApplyable );
155 void SelectRangeView::onSelectButtonClicked()
virtual ~SelectRangeView()
void rememberCurrentAddress()
SelectRangeView(SelectRangeTool *tool, QWidget *parent=0)