31 #include <KPushButton>
35 #include <QtGui/QCheckBox>
36 #include <QtGui/QLabel>
37 #include <QtGui/QLayout>
47 QHBoxLayout* baseLayout =
new QHBoxLayout(
this );
48 baseLayout->setMargin( 0 );
51 QHBoxLayout* offsetLayout =
new QHBoxLayout();
52 offsetLayout->setMargin( 0 );
54 QLabel* label =
new QLabel( i18nc(
"@label:listbox",
"O&ffset:"),
this );
58 connect( mAddressEdit, SIGNAL(formatChanged(
int)),
59 SLOT(onFormatChanged(
int)) );
60 connect( mAddressEdit, SIGNAL(addressTypeChanged(
int)),
61 SLOT(onAddressTypeChanged(
int)) );
62 label->setBuddy( mAddressEdit );
63 const QString inputWhatsThis =
64 i18nc(
"@info:whatsthis",
"Enter an offset to go to, or select a previous offset from the list." );
65 label->setWhatsThis( inputWhatsThis );
66 mAddressEdit->setWhatsThis( inputWhatsThis );
68 offsetLayout->addWidget( label );
69 offsetLayout->addWidget( mAddressEdit, 1 );
71 baseLayout->addLayout( offsetLayout, 1 );
72 baseLayout->setAlignment( offsetLayout, Qt::AlignTop );
74 setFocusProxy( mAddressEdit );
77 QVBoxLayout* optionsLayout =
new QVBoxLayout();
78 optionsLayout->setMargin( 0 );
80 mAtCursorCheckBox =
new QCheckBox( i18nc(
"@option:check",
"From c&ursor"),
this );
81 mAtCursorCheckBox->setWhatsThis(
82 i18nc(
"@info:whatsthis",
"Go relative from the current cursor location and not absolute.") );
83 connect( mAtCursorCheckBox, SIGNAL(toggled(
bool)),
84 mTool, SLOT(setIsRelative(
bool)) );
85 mExtendSelectionCheckBox =
new QCheckBox( i18nc(
"@option:check",
"&Extend selection"),
this );
86 mExtendSelectionCheckBox->setWhatsThis(
87 i18nc(
"@info:whatsthis",
"Extend the selection by the cursor move.") );
88 connect( mExtendSelectionCheckBox, SIGNAL(toggled(
bool)),
89 mTool, SLOT(setIsSelectionToExtent(
bool)) );
90 mBackwardsCheckBox =
new QCheckBox( i18nc(
"@option:check",
"&Backwards"),
this );
91 mBackwardsCheckBox->setWhatsThis(
92 i18nc(
"@info:whatsthis",
"Go backwards from the end or the current cursor location.") );
93 connect( mBackwardsCheckBox, SIGNAL(toggled(
bool)), mTool, SLOT(setIsBackwards(
bool)) );
95 QHBoxLayout* upperOptionsLayout =
new QHBoxLayout();
96 upperOptionsLayout->setMargin( 0 );
97 upperOptionsLayout->addWidget( mAtCursorCheckBox );
98 upperOptionsLayout->addWidget( mBackwardsCheckBox );
100 optionsLayout->addLayout( upperOptionsLayout );
101 optionsLayout->addWidget( mExtendSelectionCheckBox );
103 baseLayout->addLayout( optionsLayout );
106 const KGuiItem gotoGuiItem =
107 KGuiItem( i18nc(
"@action:button",
"&Go"),
108 QLatin1String(
"go-jump"),
109 i18nc(
"@info:tooltip",
111 i18nc(
"@info:whatsthis",
112 "If you press the <interface>Go</interface> "
113 "button, the cursor will be moved in the document to or, "
114 "on your option, by the offset you entered above.") );
115 mGotoButton =
new KPushButton( gotoGuiItem,
this );
116 connect( mGotoButton, SIGNAL(clicked(
bool)), SLOT(onGotoButtonClicked()) );
118 baseLayout->addWidget( mGotoButton );
119 baseLayout->setAlignment( mGotoButton, Qt::AlignTop );
121 setTabOrder( mAddressEdit, mAtCursorCheckBox );
122 setTabOrder( mAtCursorCheckBox, mBackwardsCheckBox );
123 setTabOrder( mBackwardsCheckBox, mExtendSelectionCheckBox );
124 setTabOrder( mExtendSelectionCheckBox, mGotoButton );
126 connect( mTool, SIGNAL(isApplyableChanged(
bool)),
127 SLOT(onApplyableChanged(
bool)) );
133 void GotoOffsetView::onApplyableChanged(
bool isApplyable )
137 mGotoButton->setEnabled( isApplyable );
141 void GotoOffsetView::onGotoButtonClicked()
150 void GotoOffsetView::onAddressTypeChanged(
int addressType )
152 const bool isNotExpression = (mAddressEdit->
format() != 2);
157 bool fromCursor =
false;
158 bool backwards =
false;
176 mAtCursorCheckBox->setChecked( fromCursor );
178 mBackwardsCheckBox->setChecked( backwards );
182 void GotoOffsetView::onFormatChanged(
int formatIndex )
185 const bool isNotExpression = (formatIndex != 2);
187 mAtCursorCheckBox->setEnabled( isNotExpression );
188 mBackwardsCheckBox->setEnabled( isNotExpression );
virtual ~GotoOffsetView()
GotoOffsetView(GotoOffsetTool *tool, QWidget *parent=0)
void rememberCurrentAddress()