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,301 +1,305 @@ | |||
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, |
37 | const QString &user1, | 41 | const QString &user1, |
38 | const QString &user2, | 42 | const QString &user2, |
39 | const QString &user3) : | 43 | const QString &user3) : |
40 | KDialog( parent, name, modal ) | 44 | KDialog( parent, name, modal ) |
41 | { | 45 | { |
42 | init( caption, buttonMask, user1, user2 ); | 46 | init( caption, buttonMask, user1, user2 ); |
43 | if (findButton( defaultButton ) ) { | 47 | if (findButton( defaultButton ) ) { |
44 | (findButton( defaultButton ) )->setFocus(); | 48 | (findButton( defaultButton ) )->setFocus(); |
45 | (findButton( defaultButton ) )->setDefault( true ); | 49 | (findButton( defaultButton ) )->setDefault( true ); |
46 | } | 50 | } |
47 | 51 | ||
48 | } | 52 | } |
49 | 53 | ||
50 | KDialogBase::~KDialogBase() | 54 | KDialogBase::~KDialogBase() |
51 | { | 55 | { |
52 | } | 56 | } |
53 | 57 | ||
54 | void KDialogBase::init( const QString &caption, int buttonMask, | 58 | void KDialogBase::init( const QString &caption, int buttonMask, |
55 | const QString &user1 ,const QString &user2 ) | 59 | const QString &user1 ,const QString &user2 ) |
56 | { | 60 | { |
57 | mMainWidget = 0; | 61 | mMainWidget = 0; |
58 | mTabWidget = 0; | 62 | mTabWidget = 0; |
59 | mPlainPage = 0; | 63 | mPlainPage = 0; |
60 | mTopLayout = 0; | 64 | mTopLayout = 0; |
61 | if ( !caption.isEmpty() ) { | 65 | if ( !caption.isEmpty() ) { |
62 | setCaption( caption ); | 66 | setCaption( caption ); |
63 | } | 67 | } |
64 | 68 | ||
65 | if ( buttonMask & User1 ) { | 69 | if ( buttonMask & User1 ) { |
66 | mUser1Button = new QPushButton( user1, this ); | 70 | mUser1Button = new QPushButton( user1, this ); |
67 | connect( mUser1Button, SIGNAL( clicked() ), SLOT( slotUser1() ) ); | 71 | connect( mUser1Button, SIGNAL( clicked() ), SLOT( slotUser1() ) ); |
68 | } else { | 72 | } else { |
69 | mUser1Button = 0; | 73 | mUser1Button = 0; |
70 | } | 74 | } |
71 | if ( buttonMask & User2 ) { | 75 | if ( buttonMask & User2 ) { |
72 | mUser2Button = new QPushButton( user2, this ); | 76 | mUser2Button = new QPushButton( user2, this ); |
73 | connect( mUser2Button, SIGNAL( clicked() ), SLOT( slotUser2() ) ); | 77 | connect( mUser2Button, SIGNAL( clicked() ), SLOT( slotUser2() ) ); |
74 | } else { | 78 | } else { |
75 | mUser2Button = 0; | 79 | mUser2Button = 0; |
76 | } | 80 | } |
77 | 81 | ||
78 | if ( buttonMask & Ok ) { | 82 | if ( buttonMask & Ok ) { |
79 | mOkButton = new QPushButton( i18n("Ok"), this ); | 83 | mOkButton = new QPushButton( i18n("Ok"), this ); |
80 | connect( mOkButton, SIGNAL( clicked() ), SLOT( slotOk() ) ); | 84 | connect( mOkButton, SIGNAL( clicked() ), SLOT( slotOk() ) ); |
81 | //mOkButton->setDefault( true ); | 85 | //mOkButton->setDefault( true ); |
82 | } else { | 86 | } else { |
83 | mOkButton = 0; | 87 | mOkButton = 0; |
84 | } | 88 | } |
85 | if ( buttonMask & Default ) { | 89 | if ( buttonMask & Default ) { |
86 | mDefaultButton = new QPushButton( i18n("Default"), this ); | 90 | mDefaultButton = new QPushButton( i18n("Default"), this ); |
87 | connect( mDefaultButton, SIGNAL( clicked() ), SIGNAL( defaultClicked() ) ); | 91 | connect( mDefaultButton, SIGNAL( clicked() ), SIGNAL( defaultClicked() ) ); |
88 | } else { | 92 | } else { |
89 | mDefaultButton = 0; | 93 | mDefaultButton = 0; |
90 | } | 94 | } |
91 | 95 | ||
92 | if ( buttonMask & Apply ) { | 96 | if ( buttonMask & Apply ) { |
93 | mApplyButton = new QPushButton( i18n("Apply"), this ); | 97 | mApplyButton = new QPushButton( i18n("Apply"), this ); |
94 | connect( mApplyButton, SIGNAL( clicked() ), SLOT( slotApply() ) ); | 98 | connect( mApplyButton, SIGNAL( clicked() ), SLOT( slotApply() ) ); |
95 | } else { | 99 | } else { |
96 | mApplyButton = 0; | 100 | mApplyButton = 0; |
97 | } | 101 | } |
98 | 102 | ||
99 | if ( buttonMask & Cancel ) { | 103 | if ( buttonMask & Cancel ) { |
100 | mCancelButton = new QPushButton( i18n("Cancel"), this ); | 104 | mCancelButton = new QPushButton( i18n("Cancel"), this ); |
101 | connect( mCancelButton, SIGNAL( clicked() ), SLOT( slotCancel() ) ); | 105 | connect( mCancelButton, SIGNAL( clicked() ), SLOT( slotCancel() ) ); |
102 | } else { | 106 | } else { |
103 | mCancelButton = 0; | 107 | mCancelButton = 0; |
104 | } | 108 | } |
105 | 109 | ||
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; |
199 | switch ( id ) { | 203 | switch ( id ) { |
200 | case Ok: | 204 | case Ok: |
201 | button = mOkButton; | 205 | button = mOkButton; |
202 | break; | 206 | break; |
203 | case Apply: | 207 | case Apply: |
204 | button = mApplyButton; | 208 | button = mApplyButton; |
205 | break; | 209 | break; |
206 | case User1: | 210 | case User1: |
207 | button = mUser1Button; | 211 | button = mUser1Button; |
208 | break; | 212 | break; |
209 | case User2: | 213 | case User2: |
210 | button = mUser2Button; | 214 | button = mUser2Button; |
211 | break; | 215 | break; |
212 | case Cancel: | 216 | case Cancel: |
213 | button = mCancelButton; | 217 | button = mCancelButton; |
214 | break; | 218 | break; |
215 | case Default: | 219 | case Default: |
216 | button = mDefaultButton; | 220 | button = mDefaultButton; |
217 | break; | 221 | break; |
218 | case Close: | 222 | case Close: |
219 | button = mCloseButton; | 223 | button = mCloseButton; |
220 | break; | 224 | break; |
221 | default: | 225 | default: |
222 | break; | 226 | break; |
223 | } | 227 | } |
224 | return button; | 228 | return button; |
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(); |
293 | } | 297 | } |
294 | void KDialogBase::slotUser1() | 298 | void KDialogBase::slotUser1() |
295 | { | 299 | { |
296 | emit user1Clicked(); | 300 | emit user1Clicked(); |
297 | } | 301 | } |
298 | void KDialogBase::slotUser2() | 302 | void KDialogBase::slotUser2() |
299 | { | 303 | { |
300 | emit user2Clicked(); | 304 | emit user2Clicked(); |
301 | } | 305 | } |