author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /microkde/kdialogbase.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2 |
initial public commit of qt4 portp1
-rw-r--r-- | microkde/kdialogbase.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/microkde/kdialogbase.cpp b/microkde/kdialogbase.cpp index d5c7e61..a40bad6 100644 --- a/microkde/kdialogbase.cpp +++ b/microkde/kdialogbase.cpp | |||
@@ -1,36 +1,40 @@ | |||
1 | #include <qtabwidget.h> | 1 | #include <qtabwidget.h> |
2 | #include <qpushbutton.h> | 2 | #include <qpushbutton.h> |
3 | #include <qlayout.h> | 3 | #include <qlayout.h> |
4 | #include <qframe.h> | 4 | #include <q3frame.h> |
5 | //Added by qt3to4: | ||
6 | #include <QPixmap> | ||
7 | #include <Q3HBoxLayout> | ||
8 | #include <Q3VBoxLayout> | ||
5 | 9 | ||
6 | 10 | ||
7 | #include "klocale.h" | 11 | #include "klocale.h" |
8 | #include "kdebug.h" | 12 | #include "kdebug.h" |
9 | 13 | ||
10 | #include "kdialogbase.h" | 14 | #include "kdialogbase.h" |
11 | 15 | ||
12 | KDialogBase::KDialogBase() | 16 | KDialogBase::KDialogBase() |
13 | { | 17 | { |
14 | } | 18 | } |
15 | 19 | ||
16 | KDialogBase::KDialogBase( QWidget *parent, const char *name, bool modal, | 20 | KDialogBase::KDialogBase( QWidget *parent, const char *name, bool modal, |
17 | const QString &caption, | 21 | const QString &caption, |
18 | int buttonMask, ButtonCode defaultButton, | 22 | int buttonMask, ButtonCode defaultButton, |
19 | bool separator, | 23 | bool separator, |
20 | const QString &user1, | 24 | const QString &user1, |
21 | const QString &user2, | 25 | const QString &user2, |
22 | const QString &user3) : | 26 | const QString &user3) : |
23 | KDialog( parent, name, modal ) | 27 | KDialog( parent, name, modal ) |
24 | { | 28 | { |
25 | init( caption, buttonMask, user1, user2 ); | 29 | init( caption, buttonMask, user1, user2 ); |
26 | if (findButton( defaultButton ) ) { | 30 | if (findButton( defaultButton ) ) { |
27 | (findButton( defaultButton ) )->setFocus(); | 31 | (findButton( defaultButton ) )->setFocus(); |
28 | (findButton( defaultButton ) )->setDefault( true ); | 32 | (findButton( defaultButton ) )->setDefault( true ); |
29 | } | 33 | } |
30 | 34 | ||
31 | } | 35 | } |
32 | 36 | ||
33 | KDialogBase::KDialogBase( int dialogFace, const QString &caption, | 37 | KDialogBase::KDialogBase( int dialogFace, const QString &caption, |
34 | int buttonMask, ButtonCode defaultButton, | 38 | int buttonMask, ButtonCode defaultButton, |
35 | QWidget *parent, const char *name, bool modal, | 39 | QWidget *parent, const char *name, bool modal, |
36 | bool separator, | 40 | bool separator, |
@@ -106,93 +110,93 @@ void KDialogBase::init( const QString &caption, int buttonMask, | |||
106 | if ( buttonMask & Close ) { | 110 | if ( buttonMask & Close ) { |
107 | mCloseButton = new QPushButton( i18n("Close"), this ); | 111 | mCloseButton = new QPushButton( i18n("Close"), this ); |
108 | connect( mCloseButton, SIGNAL( clicked() ), SLOT( slotClose() ) ); | 112 | connect( mCloseButton, SIGNAL( clicked() ), SLOT( slotClose() ) ); |
109 | } else { | 113 | } else { |
110 | mCloseButton = 0; | 114 | mCloseButton = 0; |
111 | } | 115 | } |
112 | } | 116 | } |
113 | 117 | ||
114 | QTabWidget *KDialogBase::tabWidget() | 118 | QTabWidget *KDialogBase::tabWidget() |
115 | { | 119 | { |
116 | if ( !mTabWidget ) { | 120 | if ( !mTabWidget ) { |
117 | mTabWidget = new QTabWidget( this ); | 121 | mTabWidget = new QTabWidget( this ); |
118 | setMainWidget( mTabWidget ); | 122 | setMainWidget( mTabWidget ); |
119 | } | 123 | } |
120 | return mTabWidget; | 124 | return mTabWidget; |
121 | } | 125 | } |
122 | 126 | ||
123 | void KDialogBase::hideButtons() | 127 | void KDialogBase::hideButtons() |
124 | { | 128 | { |
125 | if ( mUser1Button ) mUser1Button->hide() ; | 129 | if ( mUser1Button ) mUser1Button->hide() ; |
126 | if ( mUser2Button ) mUser2Button->hide() ; | 130 | if ( mUser2Button ) mUser2Button->hide() ; |
127 | if ( mOkButton ) mOkButton->hide() ; | 131 | if ( mOkButton ) mOkButton->hide() ; |
128 | if ( mApplyButton ) mApplyButton->hide() ; | 132 | if ( mApplyButton ) mApplyButton->hide() ; |
129 | if ( mDefaultButton ) mDefaultButton->hide(); | 133 | if ( mDefaultButton ) mDefaultButton->hide(); |
130 | if ( mCancelButton ) mCancelButton->hide() ; | 134 | if ( mCancelButton ) mCancelButton->hide() ; |
131 | if ( mCloseButton ) mCloseButton->hide() ; | 135 | if ( mCloseButton ) mCloseButton->hide() ; |
132 | 136 | ||
133 | } | 137 | } |
134 | void KDialogBase::initLayout() | 138 | void KDialogBase::initLayout() |
135 | { | 139 | { |
136 | 140 | ||
137 | delete mTopLayout; | 141 | delete mTopLayout; |
138 | mTopLayout = new QVBoxLayout( this ); | 142 | mTopLayout = new Q3VBoxLayout( this ); |
139 | mTopLayout->setMargin( marginHintSmall() ); | 143 | mTopLayout->setMargin( marginHintSmall() ); |
140 | mTopLayout->setSpacing( spacingHintSmall() ); | 144 | mTopLayout->setSpacing( spacingHintSmall() ); |
141 | 145 | ||
142 | mTopLayout->addWidget( mMainWidget ); | 146 | mTopLayout->addWidget( mMainWidget ); |
143 | 147 | ||
144 | QBoxLayout *buttonLayout = new QHBoxLayout; | 148 | Q3BoxLayout *buttonLayout = new Q3HBoxLayout; |
145 | mTopLayout->addLayout( buttonLayout ); | 149 | mTopLayout->addLayout( buttonLayout ); |
146 | 150 | ||
147 | if ( mUser1Button ) buttonLayout->addWidget( mUser1Button ); | 151 | if ( mUser1Button ) buttonLayout->addWidget( mUser1Button ); |
148 | if ( mUser2Button ) buttonLayout->addWidget( mUser2Button ); | 152 | if ( mUser2Button ) buttonLayout->addWidget( mUser2Button ); |
149 | if ( mOkButton ) buttonLayout->addWidget( mOkButton ); | 153 | if ( mOkButton ) buttonLayout->addWidget( mOkButton ); |
150 | if ( mApplyButton ) buttonLayout->addWidget( mApplyButton ); | 154 | if ( mApplyButton ) buttonLayout->addWidget( mApplyButton ); |
151 | if ( mDefaultButton ) buttonLayout->addWidget( mDefaultButton ); | 155 | if ( mDefaultButton ) buttonLayout->addWidget( mDefaultButton ); |
152 | if ( mCancelButton ) buttonLayout->addWidget( mCancelButton ); | 156 | if ( mCancelButton ) buttonLayout->addWidget( mCancelButton ); |
153 | if ( mCloseButton ) buttonLayout->addWidget( mCloseButton ); | 157 | if ( mCloseButton ) buttonLayout->addWidget( mCloseButton ); |
154 | buttonLayout->setMargin( marginHintSmall() ); | 158 | buttonLayout->setMargin( marginHintSmall() ); |
155 | buttonLayout->setSpacing( spacingHintSmall() ); | 159 | buttonLayout->setSpacing( spacingHintSmall() ); |
156 | } | 160 | } |
157 | 161 | ||
158 | QFrame *KDialogBase::addPage( const QString &name ) | 162 | Q3Frame *KDialogBase::addPage( const QString &name ) |
159 | { | 163 | { |
160 | // kdDebug() << "KDialogBase::addPage(): " << name << endl; | 164 | // kdDebug() << "KDialogBase::addPage(): " << name << endl; |
161 | QFrame *frame = new QFrame( tabWidget() ); | 165 | Q3Frame *frame = new Q3Frame( tabWidget() ); |
162 | tabWidget()->addTab( frame, name ); | 166 | tabWidget()->addTab( frame, name ); |
163 | return frame; | 167 | return frame; |
164 | } | 168 | } |
165 | 169 | ||
166 | QFrame *KDialogBase::addPage( const QString &name, int, const QPixmap & ) | 170 | Q3Frame *KDialogBase::addPage( const QString &name, int, const QPixmap & ) |
167 | { | 171 | { |
168 | return addPage( name ); | 172 | return addPage( name ); |
169 | } | 173 | } |
170 | 174 | ||
171 | 175 | ||
172 | void KDialogBase::setMainWidget( QWidget *widget ) | 176 | void KDialogBase::setMainWidget( QWidget *widget ) |
173 | { | 177 | { |
174 | kdDebug() << "KDialogBase::setMainWidget()" << endl; | 178 | kdDebug() << "KDialogBase::setMainWidget()" << endl; |
175 | 179 | ||
176 | mMainWidget = widget; | 180 | mMainWidget = widget; |
177 | initLayout(); | 181 | initLayout(); |
178 | } | 182 | } |
179 | 183 | ||
180 | void KDialogBase::setButtonText( ButtonCode id, const QString &text ) | 184 | void KDialogBase::setButtonText( ButtonCode id, const QString &text ) |
181 | { | 185 | { |
182 | QPushButton *button = findButton( id ); | 186 | QPushButton *button = findButton( id ); |
183 | if ( button ) { | 187 | if ( button ) { |
184 | button->setText( text ); | 188 | button->setText( text ); |
185 | } | 189 | } |
186 | } | 190 | } |
187 | 191 | ||
188 | void KDialogBase::enableButton( ButtonCode id, bool state ) | 192 | void KDialogBase::enableButton( ButtonCode id, bool state ) |
189 | { | 193 | { |
190 | QPushButton *button = findButton( id ); | 194 | QPushButton *button = findButton( id ); |
191 | if ( button ) { | 195 | if ( button ) { |
192 | button->setEnabled( state ); | 196 | button->setEnabled( state ); |
193 | } | 197 | } |
194 | } | 198 | } |
195 | 199 | ||
196 | QPushButton *KDialogBase::findButton( ButtonCode id ) | 200 | QPushButton *KDialogBase::findButton( ButtonCode id ) |
197 | { | 201 | { |
198 | QPushButton *button = 0; | 202 | QPushButton *button = 0; |
@@ -225,68 +229,68 @@ QPushButton *KDialogBase::findButton( ButtonCode id ) | |||
225 | } | 229 | } |
226 | 230 | ||
227 | void KDialogBase::enableButtonOK( bool state ) | 231 | void KDialogBase::enableButtonOK( bool state ) |
228 | { | 232 | { |
229 | enableButton( Ok, state ); | 233 | enableButton( Ok, state ); |
230 | } | 234 | } |
231 | 235 | ||
232 | void KDialogBase::enableButtonApply( bool state ) | 236 | void KDialogBase::enableButtonApply( bool state ) |
233 | { | 237 | { |
234 | enableButton( Apply, state ); | 238 | enableButton( Apply, state ); |
235 | } | 239 | } |
236 | 240 | ||
237 | void KDialogBase::showButton( ButtonCode id, bool show ) | 241 | void KDialogBase::showButton( ButtonCode id, bool show ) |
238 | { | 242 | { |
239 | QPushButton *button = findButton( id ); | 243 | QPushButton *button = findButton( id ); |
240 | if ( button ) { | 244 | if ( button ) { |
241 | if ( show ) button->show(); | 245 | if ( show ) button->show(); |
242 | else button->hide(); | 246 | else button->hide(); |
243 | } | 247 | } |
244 | } | 248 | } |
245 | 249 | ||
246 | int KDialogBase::pageIndex( QWidget *widget ) const | 250 | int KDialogBase::pageIndex( QWidget *widget ) const |
247 | { | 251 | { |
248 | return 0; | 252 | return 0; |
249 | } | 253 | } |
250 | 254 | ||
251 | 255 | ||
252 | bool KDialogBase::showPage( int index ) | 256 | bool KDialogBase::showPage( int index ) |
253 | { | 257 | { |
254 | tabWidget()->setCurrentPage( index );return false; | 258 | tabWidget()->setCurrentPage( index );return false; |
255 | } | 259 | } |
256 | 260 | ||
257 | QFrame *KDialogBase::plainPage() | 261 | Q3Frame *KDialogBase::plainPage() |
258 | { | 262 | { |
259 | if ( !mPlainPage ) { | 263 | if ( !mPlainPage ) { |
260 | mPlainPage = new QFrame( this ); | 264 | mPlainPage = new Q3Frame( this ); |
261 | setMainWidget( mPlainPage ); | 265 | setMainWidget( mPlainPage ); |
262 | } | 266 | } |
263 | return mPlainPage; | 267 | return mPlainPage; |
264 | } | 268 | } |
265 | 269 | ||
266 | void KDialogBase::slotOk() | 270 | void KDialogBase::slotOk() |
267 | { | 271 | { |
268 | emit okClicked(); | 272 | emit okClicked(); |
269 | accept(); | 273 | accept(); |
270 | } | 274 | } |
271 | 275 | ||
272 | void KDialogBase::slotApply() | 276 | void KDialogBase::slotApply() |
273 | { | 277 | { |
274 | emit applyClicked(); | 278 | emit applyClicked(); |
275 | } | 279 | } |
276 | 280 | ||
277 | void KDialogBase::slotCancel() | 281 | void KDialogBase::slotCancel() |
278 | { | 282 | { |
279 | emit cancelClicked(); | 283 | emit cancelClicked(); |
280 | reject(); | 284 | reject(); |
281 | } | 285 | } |
282 | 286 | ||
283 | void KDialogBase::slotClose() | 287 | void KDialogBase::slotClose() |
284 | { | 288 | { |
285 | emit closeClicked(); | 289 | emit closeClicked(); |
286 | reject(); | 290 | reject(); |
287 | } | 291 | } |
288 | 292 | ||
289 | void KDialogBase::accept () | 293 | void KDialogBase::accept () |
290 | { | 294 | { |
291 | emit acceptClicked(); | 295 | emit acceptClicked(); |
292 | KDialog::accept(); | 296 | KDialog::accept(); |