-rw-r--r-- | kaddressbook/kabcore.cpp | 10 | ||||
-rw-r--r-- | microkde/kdeui/ktoolbar.cpp | 6 | ||||
-rw-r--r-- | microkde/kdeui/ktoolbar.h | 3 |
3 files changed, 15 insertions, 4 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 76f9ab6..15cab73 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,1137 +1,1141 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook. | 2 | This file is part of KAddressbook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /*s | 24 | /*s |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "kabcore.h" | 31 | #include "kabcore.h" |
32 | 32 | ||
33 | #include <stdaddressbook.h> | 33 | #include <stdaddressbook.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kfiledialog.h> | 35 | #include <kfiledialog.h> |
36 | #include <qtimer.h> | 36 | #include <qtimer.h> |
37 | #include <qlabel.h> | 37 | #include <qlabel.h> |
38 | #include <qregexp.h> | 38 | #include <qregexp.h> |
39 | #include <qlineedit.h> | 39 | #include <qlineedit.h> |
40 | #include <qcheckbox.h> | 40 | #include <qcheckbox.h> |
41 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
42 | #include <qprogressbar.h> | 42 | #include <qprogressbar.h> |
43 | #include <libkdepim/phoneaccess.h> | 43 | #include <libkdepim/phoneaccess.h> |
44 | 44 | ||
45 | #ifndef KAB_EMBEDDED | 45 | #ifndef KAB_EMBEDDED |
46 | #include <qclipboard.h> | 46 | #include <qclipboard.h> |
47 | #include <qdir.h> | 47 | #include <qdir.h> |
48 | #include <qfile.h> | 48 | #include <qfile.h> |
49 | #include <qapplicaton.h> | 49 | #include <qapplicaton.h> |
50 | #include <qprogressbar.h> | 50 | #include <qprogressbar.h> |
51 | #include <qlayout.h> | 51 | #include <qlayout.h> |
52 | #include <qregexp.h> | 52 | #include <qregexp.h> |
53 | #include <qvbox.h> | 53 | #include <qvbox.h> |
54 | #include <kabc/addresseelist.h> | 54 | #include <kabc/addresseelist.h> |
55 | #include <kabc/errorhandler.h> | 55 | #include <kabc/errorhandler.h> |
56 | #include <kabc/resource.h> | 56 | #include <kabc/resource.h> |
57 | #include <kabc/vcardconverter.h> | 57 | #include <kabc/vcardconverter.h> |
58 | #include <kapplication.h> | 58 | #include <kapplication.h> |
59 | #include <kactionclasses.h> | 59 | #include <kactionclasses.h> |
60 | #include <kcmultidialog.h> | 60 | #include <kcmultidialog.h> |
61 | #include <kdebug.h> | 61 | #include <kdebug.h> |
62 | #include <kdeversion.h> | 62 | #include <kdeversion.h> |
63 | #include <kkeydialog.h> | 63 | #include <kkeydialog.h> |
64 | #include <kmessagebox.h> | 64 | #include <kmessagebox.h> |
65 | #include <kprinter.h> | 65 | #include <kprinter.h> |
66 | #include <kprotocolinfo.h> | 66 | #include <kprotocolinfo.h> |
67 | #include <kresources/selectdialog.h> | 67 | #include <kresources/selectdialog.h> |
68 | #include <kstandarddirs.h> | 68 | #include <kstandarddirs.h> |
69 | #include <ktempfile.h> | 69 | #include <ktempfile.h> |
70 | #include <kxmlguiclient.h> | 70 | #include <kxmlguiclient.h> |
71 | #include <kaboutdata.h> | 71 | #include <kaboutdata.h> |
72 | #include <libkdepim/categoryselectdialog.h> | 72 | #include <libkdepim/categoryselectdialog.h> |
73 | 73 | ||
74 | #include "addresseeutil.h" | 74 | #include "addresseeutil.h" |
75 | #include "addresseeeditordialog.h" | 75 | #include "addresseeeditordialog.h" |
76 | #include "extensionmanager.h" | 76 | #include "extensionmanager.h" |
77 | #include "kstdaction.h" | 77 | #include "kstdaction.h" |
78 | #include "kaddressbookservice.h" | 78 | #include "kaddressbookservice.h" |
79 | #include "ldapsearchdialog.h" | 79 | #include "ldapsearchdialog.h" |
80 | #include "printing/printingwizard.h" | 80 | #include "printing/printingwizard.h" |
81 | #else // KAB_EMBEDDED | 81 | #else // KAB_EMBEDDED |
82 | 82 | ||
83 | #include <kapplication.h> | 83 | #include <kapplication.h> |
84 | #include "KDGanttMinimizeSplitter.h" | 84 | #include "KDGanttMinimizeSplitter.h" |
85 | #include "kaddressbookmain.h" | 85 | #include "kaddressbookmain.h" |
86 | #include "kactioncollection.h" | 86 | #include "kactioncollection.h" |
87 | #include "addresseedialog.h" | 87 | #include "addresseedialog.h" |
88 | //US | 88 | //US |
89 | #include <addresseeview.h> | 89 | #include <addresseeview.h> |
90 | 90 | ||
91 | #include <qapp.h> | 91 | #include <qapp.h> |
92 | #include <qmenubar.h> | 92 | #include <qmenubar.h> |
93 | //#include <qtoolbar.h> | 93 | //#include <qtoolbar.h> |
94 | #include <qmessagebox.h> | 94 | #include <qmessagebox.h> |
95 | #include <kdebug.h> | 95 | #include <kdebug.h> |
96 | #include <kiconloader.h> // needed for SmallIcon | 96 | #include <kiconloader.h> // needed for SmallIcon |
97 | #include <kresources/kcmkresources.h> | 97 | #include <kresources/kcmkresources.h> |
98 | #include <ktoolbar.h> | 98 | #include <ktoolbar.h> |
99 | 99 | ||
100 | 100 | ||
101 | //#include <qlabel.h> | 101 | //#include <qlabel.h> |
102 | 102 | ||
103 | 103 | ||
104 | #ifndef DESKTOP_VERSION | 104 | #ifndef DESKTOP_VERSION |
105 | #include <qpe/ir.h> | 105 | #include <qpe/ir.h> |
106 | #include <qpe/qpemenubar.h> | 106 | #include <qpe/qpemenubar.h> |
107 | #include <qtopia/qcopenvelope_qws.h> | 107 | #include <qtopia/qcopenvelope_qws.h> |
108 | #else | 108 | #else |
109 | 109 | ||
110 | #include <qmenubar.h> | 110 | #include <qmenubar.h> |
111 | #endif | 111 | #endif |
112 | 112 | ||
113 | #endif // KAB_EMBEDDED | 113 | #endif // KAB_EMBEDDED |
114 | #include "kcmconfigs/kcmkabconfig.h" | 114 | #include "kcmconfigs/kcmkabconfig.h" |
115 | #include "kcmconfigs/kcmkdepimconfig.h" | 115 | #include "kcmconfigs/kcmkdepimconfig.h" |
116 | #include "kpimglobalprefs.h" | 116 | #include "kpimglobalprefs.h" |
117 | #include "externalapphandler.h" | 117 | #include "externalapphandler.h" |
118 | #include "xxportselectdialog.h" | 118 | #include "xxportselectdialog.h" |
119 | 119 | ||
120 | 120 | ||
121 | #include <kresources/selectdialog.h> | 121 | #include <kresources/selectdialog.h> |
122 | #include <kmessagebox.h> | 122 | #include <kmessagebox.h> |
123 | 123 | ||
124 | #include <picture.h> | 124 | #include <picture.h> |
125 | #include <resource.h> | 125 | #include <resource.h> |
126 | 126 | ||
127 | //US#include <qsplitter.h> | 127 | //US#include <qsplitter.h> |
128 | #include <qmap.h> | 128 | #include <qmap.h> |
129 | #include <qdir.h> | 129 | #include <qdir.h> |
130 | #include <qfile.h> | 130 | #include <qfile.h> |
131 | #include <qvbox.h> | 131 | #include <qvbox.h> |
132 | #include <qlayout.h> | 132 | #include <qlayout.h> |
133 | #include <qclipboard.h> | 133 | #include <qclipboard.h> |
134 | #include <qtextstream.h> | 134 | #include <qtextstream.h> |
135 | #include <qradiobutton.h> | 135 | #include <qradiobutton.h> |
136 | #include <qbuttongroup.h> | 136 | #include <qbuttongroup.h> |
137 | 137 | ||
138 | #include <libkdepim/categoryselectdialog.h> | 138 | #include <libkdepim/categoryselectdialog.h> |
139 | #include <libkdepim/categoryeditdialog.h> | 139 | #include <libkdepim/categoryeditdialog.h> |
140 | #include <kabc/vcardconverter.h> | 140 | #include <kabc/vcardconverter.h> |
141 | 141 | ||
142 | 142 | ||
143 | #include "addresseeutil.h" | 143 | #include "addresseeutil.h" |
144 | #include "undocmds.h" | 144 | #include "undocmds.h" |
145 | #include "addresseeeditordialog.h" | 145 | #include "addresseeeditordialog.h" |
146 | #include "viewmanager.h" | 146 | #include "viewmanager.h" |
147 | #include "details/detailsviewcontainer.h" | 147 | #include "details/detailsviewcontainer.h" |
148 | #include "kabprefs.h" | 148 | #include "kabprefs.h" |
149 | #include "xxportmanager.h" | 149 | #include "xxportmanager.h" |
150 | #include "incsearchwidget.h" | 150 | #include "incsearchwidget.h" |
151 | #include "jumpbuttonbar.h" | 151 | #include "jumpbuttonbar.h" |
152 | #include "extensionmanager.h" | 152 | #include "extensionmanager.h" |
153 | #include "addresseeconfig.h" | 153 | #include "addresseeconfig.h" |
154 | #include <kcmultidialog.h> | 154 | #include <kcmultidialog.h> |
155 | 155 | ||
156 | #ifdef _WIN32_ | 156 | #ifdef _WIN32_ |
157 | 157 | ||
158 | #include "kaimportoldialog.h" | 158 | #include "kaimportoldialog.h" |
159 | #else | 159 | #else |
160 | #include <unistd.h> | 160 | #include <unistd.h> |
161 | #endif | 161 | #endif |
162 | // sync includes | 162 | // sync includes |
163 | #include <libkdepim/ksyncprofile.h> | 163 | #include <libkdepim/ksyncprofile.h> |
164 | #include <libkdepim/ksyncprefsdialog.h> | 164 | #include <libkdepim/ksyncprefsdialog.h> |
165 | 165 | ||
166 | 166 | ||
167 | class KABCatPrefs : public QDialog | 167 | class KABCatPrefs : public QDialog |
168 | { | 168 | { |
169 | public: | 169 | public: |
170 | KABCatPrefs( QWidget *parent=0, const char *name=0 ) : | 170 | KABCatPrefs( QWidget *parent=0, const char *name=0 ) : |
171 | QDialog( parent, name, true ) | 171 | QDialog( parent, name, true ) |
172 | { | 172 | { |
173 | setCaption( i18n("Manage new Categories") ); | 173 | setCaption( i18n("Manage new Categories") ); |
174 | QVBoxLayout* lay = new QVBoxLayout( this ); | 174 | QVBoxLayout* lay = new QVBoxLayout( this ); |
175 | lay->setSpacing( 3 ); | 175 | lay->setSpacing( 3 ); |
176 | lay->setMargin( 3 ); | 176 | lay->setMargin( 3 ); |
177 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 177 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
178 | lay->addWidget( lab ); | 178 | lay->addWidget( lab ); |
179 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 179 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
180 | lay->addWidget( format ); | 180 | lay->addWidget( format ); |
181 | format->setExclusive ( true ) ; | 181 | format->setExclusive ( true ) ; |
182 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 182 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
183 | new QRadioButton(i18n("Remove from addressees"), format ); | 183 | new QRadioButton(i18n("Remove from addressees"), format ); |
184 | addCatBut->setChecked( true ); | 184 | addCatBut->setChecked( true ); |
185 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 185 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
186 | lay->addWidget( ok ); | 186 | lay->addWidget( ok ); |
187 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 187 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
188 | lay->addWidget( cancel ); | 188 | lay->addWidget( cancel ); |
189 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 189 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
190 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 190 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
191 | resize( 200, 200 ); | 191 | resize( 200, 200 ); |
192 | } | 192 | } |
193 | 193 | ||
194 | bool addCat() { return addCatBut->isChecked(); } | 194 | bool addCat() { return addCatBut->isChecked(); } |
195 | private: | 195 | private: |
196 | QRadioButton* addCatBut; | 196 | QRadioButton* addCatBut; |
197 | }; | 197 | }; |
198 | 198 | ||
199 | 199 | ||
200 | 200 | ||
201 | class KAex2phonePrefs : public QDialog | 201 | class KAex2phonePrefs : public QDialog |
202 | { | 202 | { |
203 | public: | 203 | public: |
204 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 204 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
205 | QDialog( parent, name, true ) | 205 | QDialog( parent, name, true ) |
206 | { | 206 | { |
207 | setCaption( i18n("Export to phone options") ); | 207 | setCaption( i18n("Export to phone options") ); |
208 | QVBoxLayout* lay = new QVBoxLayout( this ); | 208 | QVBoxLayout* lay = new QVBoxLayout( this ); |
209 | lay->setSpacing( 3 ); | 209 | lay->setSpacing( 3 ); |
210 | lay->setMargin( 3 ); | 210 | lay->setMargin( 3 ); |
211 | QLabel *lab; | 211 | QLabel *lab; |
212 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 212 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
213 | lab->setAlignment (AlignHCenter ); | 213 | lab->setAlignment (AlignHCenter ); |
214 | QHBox* temphb; | 214 | QHBox* temphb; |
215 | temphb = new QHBox( this ); | 215 | temphb = new QHBox( this ); |
216 | new QLabel( i18n("I/O device: "), temphb ); | 216 | new QLabel( i18n("I/O device: "), temphb ); |
217 | mPhoneDevice = new QLineEdit( temphb); | 217 | mPhoneDevice = new QLineEdit( temphb); |
218 | lay->addWidget( temphb ); | 218 | lay->addWidget( temphb ); |
219 | temphb = new QHBox( this ); | 219 | temphb = new QHBox( this ); |
220 | new QLabel( i18n("Connection: "), temphb ); | 220 | new QLabel( i18n("Connection: "), temphb ); |
221 | mPhoneConnection = new QLineEdit( temphb); | 221 | mPhoneConnection = new QLineEdit( temphb); |
222 | lay->addWidget( temphb ); | 222 | lay->addWidget( temphb ); |
223 | temphb = new QHBox( this ); | 223 | temphb = new QHBox( this ); |
224 | new QLabel( i18n("Model(opt.): "), temphb ); | 224 | new QLabel( i18n("Model(opt.): "), temphb ); |
225 | mPhoneModel = new QLineEdit( temphb); | 225 | mPhoneModel = new QLineEdit( temphb); |
226 | lay->addWidget( temphb ); | 226 | lay->addWidget( temphb ); |
227 | // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); | 227 | // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); |
228 | // lay->addWidget( mWriteToSim ); | 228 | // lay->addWidget( mWriteToSim ); |
229 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); | 229 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); |
230 | lab->setAlignment (AlignHCenter ); | 230 | lab->setAlignment (AlignHCenter ); |
231 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 231 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
232 | lay->addWidget( ok ); | 232 | lay->addWidget( ok ); |
233 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 233 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
234 | lay->addWidget( cancel ); | 234 | lay->addWidget( cancel ); |
235 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 235 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
236 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 236 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
237 | resize( 220, 240 ); | 237 | resize( 220, 240 ); |
238 | 238 | ||
239 | } | 239 | } |
240 | 240 | ||
241 | public: | 241 | public: |
242 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 242 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
243 | QCheckBox* mWriteToSim; | 243 | QCheckBox* mWriteToSim; |
244 | }; | 244 | }; |
245 | 245 | ||
246 | 246 | ||
247 | bool pasteWithNewUid = true; | 247 | bool pasteWithNewUid = true; |
248 | 248 | ||
249 | #ifdef KAB_EMBEDDED | 249 | #ifdef KAB_EMBEDDED |
250 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 250 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
251 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 251 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
252 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 252 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
253 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 253 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
254 | #else //KAB_EMBEDDED | 254 | #else //KAB_EMBEDDED |
255 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 255 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
256 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 256 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
257 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 257 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
258 | mReadWrite( readWrite ), mModified( false ) | 258 | mReadWrite( readWrite ), mModified( false ) |
259 | #endif //KAB_EMBEDDED | 259 | #endif //KAB_EMBEDDED |
260 | { | 260 | { |
261 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 261 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
262 | // syncManager->setBlockSave(false); | 262 | // syncManager->setBlockSave(false); |
263 | mMiniSplitter = 0; | 263 | mMiniSplitter = 0; |
264 | mExtensionBarSplitter = 0; | 264 | mExtensionBarSplitter = 0; |
265 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 265 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
266 | mAddressBook = KABC::StdAddressBook::self(); | 266 | mAddressBook = KABC::StdAddressBook::self(); |
267 | KABC::StdAddressBook::setAutomaticSave( false ); | 267 | KABC::StdAddressBook::setAutomaticSave( false ); |
268 | 268 | ||
269 | #ifndef KAB_EMBEDDED | 269 | #ifndef KAB_EMBEDDED |
270 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 270 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
271 | #endif //KAB_EMBEDDED | 271 | #endif //KAB_EMBEDDED |
272 | 272 | ||
273 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 273 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
274 | SLOT( addressBookChanged() ) ); | 274 | SLOT( addressBookChanged() ) ); |
275 | 275 | ||
276 | #if 0 | 276 | #if 0 |
277 | // LP moved to addressbook init method | 277 | // LP moved to addressbook init method |
278 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 278 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
279 | "X-Department", "KADDRESSBOOK" ); | 279 | "X-Department", "KADDRESSBOOK" ); |
280 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 280 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
281 | "X-Profession", "KADDRESSBOOK" ); | 281 | "X-Profession", "KADDRESSBOOK" ); |
282 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 282 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
283 | "X-AssistantsName", "KADDRESSBOOK" ); | 283 | "X-AssistantsName", "KADDRESSBOOK" ); |
284 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 284 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
285 | "X-ManagersName", "KADDRESSBOOK" ); | 285 | "X-ManagersName", "KADDRESSBOOK" ); |
286 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 286 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
287 | "X-SpousesName", "KADDRESSBOOK" ); | 287 | "X-SpousesName", "KADDRESSBOOK" ); |
288 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 288 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
289 | "X-Office", "KADDRESSBOOK" ); | 289 | "X-Office", "KADDRESSBOOK" ); |
290 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 290 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
291 | "X-IMAddress", "KADDRESSBOOK" ); | 291 | "X-IMAddress", "KADDRESSBOOK" ); |
292 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 292 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
293 | "X-Anniversary", "KADDRESSBOOK" ); | 293 | "X-Anniversary", "KADDRESSBOOK" ); |
294 | 294 | ||
295 | //US added this field to become compatible with Opie/qtopia addressbook | 295 | //US added this field to become compatible with Opie/qtopia addressbook |
296 | // values can be "female" or "male" or "". An empty field represents undefined. | 296 | // values can be "female" or "male" or "". An empty field represents undefined. |
297 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 297 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
298 | "X-Gender", "KADDRESSBOOK" ); | 298 | "X-Gender", "KADDRESSBOOK" ); |
299 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 299 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
300 | "X-Children", "KADDRESSBOOK" ); | 300 | "X-Children", "KADDRESSBOOK" ); |
301 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 301 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
302 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 302 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
303 | #endif | 303 | #endif |
304 | initGUI(); | 304 | initGUI(); |
305 | 305 | ||
306 | mIncSearchWidget->setFocus(); | 306 | mIncSearchWidget->setFocus(); |
307 | 307 | ||
308 | 308 | ||
309 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 309 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
310 | SLOT( setContactSelected( const QString& ) ) ); | 310 | SLOT( setContactSelected( const QString& ) ) ); |
311 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 311 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
312 | SLOT( executeContact( const QString& ) ) ); | 312 | SLOT( executeContact( const QString& ) ) ); |
313 | 313 | ||
314 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 314 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
315 | SLOT( deleteContacts( ) ) ); | 315 | SLOT( deleteContacts( ) ) ); |
316 | connect( mViewManager, SIGNAL( modified() ), | 316 | connect( mViewManager, SIGNAL( modified() ), |
317 | SLOT( setModified() ) ); | 317 | SLOT( setModified() ) ); |
318 | 318 | ||
319 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 319 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
320 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); | 320 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); |
321 | 321 | ||
322 | connect( mXXPortManager, SIGNAL( modified() ), | 322 | connect( mXXPortManager, SIGNAL( modified() ), |
323 | SLOT( setModified() ) ); | 323 | SLOT( setModified() ) ); |
324 | 324 | ||
325 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 325 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
326 | SLOT( incrementalSearch( const QString& ) ) ); | 326 | SLOT( incrementalSearch( const QString& ) ) ); |
327 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 327 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
328 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 328 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
329 | 329 | ||
330 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 330 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
331 | SLOT( sendMail( const QString& ) ) ); | 331 | SLOT( sendMail( const QString& ) ) ); |
332 | 332 | ||
333 | 333 | ||
334 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); | 334 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); |
335 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); | 335 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); |
336 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); | 336 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); |
337 | connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); | 337 | connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); |
338 | 338 | ||
339 | 339 | ||
340 | #ifndef KAB_EMBEDDED | 340 | #ifndef KAB_EMBEDDED |
341 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 341 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
342 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 342 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
343 | 343 | ||
344 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 344 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
345 | SLOT( browse( const QString& ) ) ); | 345 | SLOT( browse( const QString& ) ) ); |
346 | 346 | ||
347 | 347 | ||
348 | mAddressBookService = new KAddressBookService( this ); | 348 | mAddressBookService = new KAddressBookService( this ); |
349 | 349 | ||
350 | #endif //KAB_EMBEDDED | 350 | #endif //KAB_EMBEDDED |
351 | 351 | ||
352 | mMessageTimer = new QTimer( this ); | 352 | mMessageTimer = new QTimer( this ); |
353 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); | 353 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); |
354 | mEditorDialog = 0; | 354 | mEditorDialog = 0; |
355 | createAddresseeEditorDialog( this ); | 355 | createAddresseeEditorDialog( this ); |
356 | setModified( false ); | 356 | setModified( false ); |
357 | mBRdisabled = false; | 357 | mBRdisabled = false; |
358 | #ifndef DESKTOP_VERSION | 358 | #ifndef DESKTOP_VERSION |
359 | infrared = 0; | 359 | infrared = 0; |
360 | #endif | 360 | #endif |
361 | //toggleBeamReceive( ); | 361 | //toggleBeamReceive( ); |
362 | 362 | //mMainWindow->toolBar()->show(); | |
363 | // we have a toolbar repainting error on the Zaurus when starting KA/Pi | 363 | // we have a toolbar repainting error on the Zaurus when starting KA/Pi |
364 | QTimer::singleShot( 10000, this , SLOT ( updateToolBar())); | 364 | QTimer::singleShot( 10, this , SLOT ( updateToolBar())); |
365 | } | 365 | } |
366 | 366 | ||
367 | void KABCore::updateToolBar() | 367 | void KABCore::updateToolBar() |
368 | { | 368 | { |
369 | mMainWindow->toolBar()->update(); | 369 | static int iii = 0; |
370 | ++iii; | ||
371 | mMainWindow->toolBar()->repaintMe(); | ||
372 | if ( iii < 5 ) | ||
373 | QTimer::singleShot( 10, this , SLOT ( updateToolBar())); | ||
370 | } | 374 | } |
371 | KABCore::~KABCore() | 375 | KABCore::~KABCore() |
372 | { | 376 | { |
373 | // save(); | 377 | // save(); |
374 | //saveSettings(); | 378 | //saveSettings(); |
375 | //KABPrefs::instance()->writeConfig(); | 379 | //KABPrefs::instance()->writeConfig(); |
376 | delete AddresseeConfig::instance(); | 380 | delete AddresseeConfig::instance(); |
377 | mAddressBook = 0; | 381 | mAddressBook = 0; |
378 | KABC::StdAddressBook::close(); | 382 | KABC::StdAddressBook::close(); |
379 | 383 | ||
380 | delete syncManager; | 384 | delete syncManager; |
381 | #ifndef DESKTOP_VERSION | 385 | #ifndef DESKTOP_VERSION |
382 | if ( infrared ) | 386 | if ( infrared ) |
383 | delete infrared; | 387 | delete infrared; |
384 | #endif | 388 | #endif |
385 | } | 389 | } |
386 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) | 390 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) |
387 | { | 391 | { |
388 | qDebug("KA: QCOP message received: %s ", cmsg.data() ); | 392 | qDebug("KA: QCOP message received: %s ", cmsg.data() ); |
389 | if ( cmsg == "setDocument(QString)" ) { | 393 | if ( cmsg == "setDocument(QString)" ) { |
390 | QDataStream stream( data, IO_ReadOnly ); | 394 | QDataStream stream( data, IO_ReadOnly ); |
391 | QString fileName; | 395 | QString fileName; |
392 | stream >> fileName; | 396 | stream >> fileName; |
393 | recieve( fileName ); | 397 | recieve( fileName ); |
394 | return; | 398 | return; |
395 | } | 399 | } |
396 | } | 400 | } |
397 | void KABCore::toggleBeamReceive( ) | 401 | void KABCore::toggleBeamReceive( ) |
398 | { | 402 | { |
399 | if ( mBRdisabled ) | 403 | if ( mBRdisabled ) |
400 | return; | 404 | return; |
401 | #ifndef DESKTOP_VERSION | 405 | #ifndef DESKTOP_VERSION |
402 | if ( infrared ) { | 406 | if ( infrared ) { |
403 | qDebug("AB disable BeamReceive "); | 407 | qDebug("AB disable BeamReceive "); |
404 | delete infrared; | 408 | delete infrared; |
405 | infrared = 0; | 409 | infrared = 0; |
406 | mActionBR->setChecked(false); | 410 | mActionBR->setChecked(false); |
407 | return; | 411 | return; |
408 | } | 412 | } |
409 | qDebug("AB enable BeamReceive "); | 413 | qDebug("AB enable BeamReceive "); |
410 | mActionBR->setChecked(true); | 414 | mActionBR->setChecked(true); |
411 | 415 | ||
412 | infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; | 416 | infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; |
413 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); | 417 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); |
414 | #endif | 418 | #endif |
415 | } | 419 | } |
416 | 420 | ||
417 | 421 | ||
418 | void KABCore::disableBR(bool b) | 422 | void KABCore::disableBR(bool b) |
419 | { | 423 | { |
420 | #ifndef DESKTOP_VERSION | 424 | #ifndef DESKTOP_VERSION |
421 | if ( b ) { | 425 | if ( b ) { |
422 | if ( infrared ) { | 426 | if ( infrared ) { |
423 | toggleBeamReceive( ); | 427 | toggleBeamReceive( ); |
424 | } | 428 | } |
425 | mBRdisabled = true; | 429 | mBRdisabled = true; |
426 | } else { | 430 | } else { |
427 | if ( mBRdisabled ) { | 431 | if ( mBRdisabled ) { |
428 | mBRdisabled = false; | 432 | mBRdisabled = false; |
429 | //toggleBeamReceive( ); | 433 | //toggleBeamReceive( ); |
430 | } | 434 | } |
431 | } | 435 | } |
432 | #endif | 436 | #endif |
433 | 437 | ||
434 | } | 438 | } |
435 | void KABCore::recieve( QString fn ) | 439 | void KABCore::recieve( QString fn ) |
436 | { | 440 | { |
437 | //qDebug("KABCore::recieve "); | 441 | //qDebug("KABCore::recieve "); |
438 | int count = mAddressBook->importFromFile( fn, true ); | 442 | int count = mAddressBook->importFromFile( fn, true ); |
439 | if ( count ) | 443 | if ( count ) |
440 | setModified( true ); | 444 | setModified( true ); |
441 | mViewManager->refreshView(); | 445 | mViewManager->refreshView(); |
442 | message(i18n("%1 contact(s) received!").arg( count )); | 446 | message(i18n("%1 contact(s) received!").arg( count )); |
443 | topLevelWidget()->showMaximized(); | 447 | topLevelWidget()->showMaximized(); |
444 | topLevelWidget()->raise(); | 448 | topLevelWidget()->raise(); |
445 | } | 449 | } |
446 | void KABCore::restoreSettings() | 450 | void KABCore::restoreSettings() |
447 | { | 451 | { |
448 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 452 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
449 | 453 | ||
450 | bool state; | 454 | bool state; |
451 | 455 | ||
452 | if (mMultipleViewsAtOnce) | 456 | if (mMultipleViewsAtOnce) |
453 | state = KABPrefs::instance()->mDetailsPageVisible; | 457 | state = KABPrefs::instance()->mDetailsPageVisible; |
454 | else | 458 | else |
455 | state = false; | 459 | state = false; |
456 | 460 | ||
457 | mActionDetails->setChecked( state ); | 461 | mActionDetails->setChecked( state ); |
458 | setDetailsVisible( state ); | 462 | setDetailsVisible( state ); |
459 | 463 | ||
460 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 464 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
461 | 465 | ||
462 | mActionJumpBar->setChecked( state ); | 466 | mActionJumpBar->setChecked( state ); |
463 | setJumpButtonBarVisible( state ); | 467 | setJumpButtonBarVisible( state ); |
464 | /*US | 468 | /*US |
465 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 469 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
466 | if ( splitterSize.count() == 0 ) { | 470 | if ( splitterSize.count() == 0 ) { |
467 | splitterSize.append( width() / 2 ); | 471 | splitterSize.append( width() / 2 ); |
468 | splitterSize.append( width() / 2 ); | 472 | splitterSize.append( width() / 2 ); |
469 | } | 473 | } |
470 | mMiniSplitter->setSizes( splitterSize ); | 474 | mMiniSplitter->setSizes( splitterSize ); |
471 | if ( mExtensionBarSplitter ) { | 475 | if ( mExtensionBarSplitter ) { |
472 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 476 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
473 | if ( splitterSize.count() == 0 ) { | 477 | if ( splitterSize.count() == 0 ) { |
474 | splitterSize.append( width() / 2 ); | 478 | splitterSize.append( width() / 2 ); |
475 | splitterSize.append( width() / 2 ); | 479 | splitterSize.append( width() / 2 ); |
476 | } | 480 | } |
477 | mExtensionBarSplitter->setSizes( splitterSize ); | 481 | mExtensionBarSplitter->setSizes( splitterSize ); |
478 | 482 | ||
479 | } | 483 | } |
480 | */ | 484 | */ |
481 | mViewManager->restoreSettings(); | 485 | mViewManager->restoreSettings(); |
482 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 486 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
483 | mExtensionManager->restoreSettings(); | 487 | mExtensionManager->restoreSettings(); |
484 | #ifdef DESKTOP_VERSION | 488 | #ifdef DESKTOP_VERSION |
485 | int wid = width(); | 489 | int wid = width(); |
486 | if ( wid < 10 ) | 490 | if ( wid < 10 ) |
487 | wid = 400; | 491 | wid = 400; |
488 | #else | 492 | #else |
489 | int wid = QApplication::desktop()->width(); | 493 | int wid = QApplication::desktop()->width(); |
490 | if ( wid < 640 ) | 494 | if ( wid < 640 ) |
491 | wid = QApplication::desktop()->height(); | 495 | wid = QApplication::desktop()->height(); |
492 | #endif | 496 | #endif |
493 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 497 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
494 | if ( true /*splitterSize.count() == 0*/ ) { | 498 | if ( true /*splitterSize.count() == 0*/ ) { |
495 | splitterSize.append( wid / 2 ); | 499 | splitterSize.append( wid / 2 ); |
496 | splitterSize.append( wid / 2 ); | 500 | splitterSize.append( wid / 2 ); |
497 | } | 501 | } |
498 | mMiniSplitter->setSizes( splitterSize ); | 502 | mMiniSplitter->setSizes( splitterSize ); |
499 | if ( mExtensionBarSplitter ) { | 503 | if ( mExtensionBarSplitter ) { |
500 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 504 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
501 | if ( true /*splitterSize.count() == 0*/ ) { | 505 | if ( true /*splitterSize.count() == 0*/ ) { |
502 | splitterSize.append( wid / 2 ); | 506 | splitterSize.append( wid / 2 ); |
503 | splitterSize.append( wid / 2 ); | 507 | splitterSize.append( wid / 2 ); |
504 | } | 508 | } |
505 | mExtensionBarSplitter->setSizes( splitterSize ); | 509 | mExtensionBarSplitter->setSizes( splitterSize ); |
506 | 510 | ||
507 | } | 511 | } |
508 | 512 | ||
509 | 513 | ||
510 | } | 514 | } |
511 | 515 | ||
512 | void KABCore::saveSettings() | 516 | void KABCore::saveSettings() |
513 | { | 517 | { |
514 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 518 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
515 | if ( mExtensionBarSplitter ) | 519 | if ( mExtensionBarSplitter ) |
516 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 520 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
517 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 521 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
518 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 522 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
519 | #ifndef KAB_EMBEDDED | 523 | #ifndef KAB_EMBEDDED |
520 | 524 | ||
521 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 525 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
522 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 526 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
523 | #endif //KAB_EMBEDDED | 527 | #endif //KAB_EMBEDDED |
524 | mExtensionManager->saveSettings(); | 528 | mExtensionManager->saveSettings(); |
525 | mViewManager->saveSettings(); | 529 | mViewManager->saveSettings(); |
526 | 530 | ||
527 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 531 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
528 | } | 532 | } |
529 | 533 | ||
530 | KABC::AddressBook *KABCore::addressBook() const | 534 | KABC::AddressBook *KABCore::addressBook() const |
531 | { | 535 | { |
532 | return mAddressBook; | 536 | return mAddressBook; |
533 | } | 537 | } |
534 | 538 | ||
535 | KConfig *KABCore::config() | 539 | KConfig *KABCore::config() |
536 | { | 540 | { |
537 | #ifndef KAB_EMBEDDED | 541 | #ifndef KAB_EMBEDDED |
538 | return KABPrefs::instance()->config(); | 542 | return KABPrefs::instance()->config(); |
539 | #else //KAB_EMBEDDED | 543 | #else //KAB_EMBEDDED |
540 | return KABPrefs::instance()->getConfig(); | 544 | return KABPrefs::instance()->getConfig(); |
541 | #endif //KAB_EMBEDDED | 545 | #endif //KAB_EMBEDDED |
542 | } | 546 | } |
543 | 547 | ||
544 | KActionCollection *KABCore::actionCollection() const | 548 | KActionCollection *KABCore::actionCollection() const |
545 | { | 549 | { |
546 | return mGUIClient->actionCollection(); | 550 | return mGUIClient->actionCollection(); |
547 | } | 551 | } |
548 | 552 | ||
549 | KABC::Field *KABCore::currentSearchField() const | 553 | KABC::Field *KABCore::currentSearchField() const |
550 | { | 554 | { |
551 | if (mIncSearchWidget) | 555 | if (mIncSearchWidget) |
552 | return mIncSearchWidget->currentField(); | 556 | return mIncSearchWidget->currentField(); |
553 | else | 557 | else |
554 | return 0; | 558 | return 0; |
555 | } | 559 | } |
556 | 560 | ||
557 | QStringList KABCore::selectedUIDs() const | 561 | QStringList KABCore::selectedUIDs() const |
558 | { | 562 | { |
559 | return mViewManager->selectedUids(); | 563 | return mViewManager->selectedUids(); |
560 | } | 564 | } |
561 | 565 | ||
562 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 566 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
563 | { | 567 | { |
564 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 568 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
565 | 569 | ||
566 | QPtrList<KRES::Resource> kresResources; | 570 | QPtrList<KRES::Resource> kresResources; |
567 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 571 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
568 | KABC::Resource *resource; | 572 | KABC::Resource *resource; |
569 | while ( ( resource = resIt.current() ) != 0 ) { | 573 | while ( ( resource = resIt.current() ) != 0 ) { |
570 | ++resIt; | 574 | ++resIt; |
571 | if ( !resource->readOnly() ) { | 575 | if ( !resource->readOnly() ) { |
572 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 576 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
573 | if ( res ) | 577 | if ( res ) |
574 | kresResources.append( res ); | 578 | kresResources.append( res ); |
575 | } | 579 | } |
576 | } | 580 | } |
577 | 581 | ||
578 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 582 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
579 | return static_cast<KABC::Resource*>( res ); | 583 | return static_cast<KABC::Resource*>( res ); |
580 | } | 584 | } |
581 | 585 | ||
582 | #ifndef KAB_EMBEDDED | 586 | #ifndef KAB_EMBEDDED |
583 | KAboutData *KABCore::createAboutData() | 587 | KAboutData *KABCore::createAboutData() |
584 | #else //KAB_EMBEDDED | 588 | #else //KAB_EMBEDDED |
585 | void KABCore::createAboutData() | 589 | void KABCore::createAboutData() |
586 | #endif //KAB_EMBEDDED | 590 | #endif //KAB_EMBEDDED |
587 | { | 591 | { |
588 | #ifndef KAB_EMBEDDED | 592 | #ifndef KAB_EMBEDDED |
589 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 593 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
590 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 594 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
591 | KAboutData::License_GPL_V2, | 595 | KAboutData::License_GPL_V2, |
592 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 596 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
593 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 597 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
594 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 598 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
595 | about->addAuthor( "Cornelius Schumacher", | 599 | about->addAuthor( "Cornelius Schumacher", |
596 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 600 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
597 | "schumacher@kde.org" ); | 601 | "schumacher@kde.org" ); |
598 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 602 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
599 | "mpilone@slac.com" ); | 603 | "mpilone@slac.com" ); |
600 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 604 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
601 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 605 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
602 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 606 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
603 | "michel@klaralvdalens-datakonsult.se" ); | 607 | "michel@klaralvdalens-datakonsult.se" ); |
604 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 608 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
605 | "hansen@kde.org" ); | 609 | "hansen@kde.org" ); |
606 | 610 | ||
607 | return about; | 611 | return about; |
608 | #endif //KAB_EMBEDDED | 612 | #endif //KAB_EMBEDDED |
609 | 613 | ||
610 | QString version; | 614 | QString version; |
611 | #include <../version> | 615 | #include <../version> |
612 | QMessageBox::about( this, "About KAddressbook/Pi", | 616 | QMessageBox::about( this, "About KAddressbook/Pi", |
613 | "KAddressbook/Platform-independent\n" | 617 | "KAddressbook/Platform-independent\n" |
614 | "(KA/Pi) " +version + " - " + | 618 | "(KA/Pi) " +version + " - " + |
615 | #ifdef DESKTOP_VERSION | 619 | #ifdef DESKTOP_VERSION |
616 | "Desktop Edition\n" | 620 | "Desktop Edition\n" |
617 | #else | 621 | #else |
618 | "PDA-Edition\n" | 622 | "PDA-Edition\n" |
619 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 623 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
620 | #endif | 624 | #endif |
621 | 625 | ||
622 | "(c) 2004 Ulf Schenk\n" | 626 | "(c) 2004 Ulf Schenk\n" |
623 | "(c) 2004 Lutz Rogowski\n" | 627 | "(c) 2004 Lutz Rogowski\n" |
624 | "(c) 1997-2003, The KDE PIM Team\n" | 628 | "(c) 1997-2003, The KDE PIM Team\n" |
625 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 629 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" |
626 | "Don Sanders Original author\n" | 630 | "Don Sanders Original author\n" |
627 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 631 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" |
628 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 632 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" |
629 | "Greg Stern DCOP interface\n" | 633 | "Greg Stern DCOP interface\n" |
630 | "Mark Westcot Contact pinning\n" | 634 | "Mark Westcot Contact pinning\n" |
631 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 635 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
632 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 636 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" |
633 | #ifdef _WIN32_ | 637 | #ifdef _WIN32_ |
634 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 638 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
635 | #endif | 639 | #endif |
636 | ); | 640 | ); |
637 | } | 641 | } |
638 | 642 | ||
639 | void KABCore::setContactSelected( const QString &uid ) | 643 | void KABCore::setContactSelected( const QString &uid ) |
640 | { | 644 | { |
641 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 645 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
642 | if ( !mDetails->isHidden() ) | 646 | if ( !mDetails->isHidden() ) |
643 | mDetails->setAddressee( addr ); | 647 | mDetails->setAddressee( addr ); |
644 | 648 | ||
645 | if ( !addr.isEmpty() ) { | 649 | if ( !addr.isEmpty() ) { |
646 | emit contactSelected( addr.formattedName() ); | 650 | emit contactSelected( addr.formattedName() ); |
647 | KABC::Picture pic = addr.photo(); | 651 | KABC::Picture pic = addr.photo(); |
648 | if ( pic.isIntern() ) { | 652 | if ( pic.isIntern() ) { |
649 | //US emit contactSelected( pic.data() ); | 653 | //US emit contactSelected( pic.data() ); |
650 | //US instead use: | 654 | //US instead use: |
651 | QPixmap px; | 655 | QPixmap px; |
652 | if (pic.data().isNull() != true) | 656 | if (pic.data().isNull() != true) |
653 | { | 657 | { |
654 | px.convertFromImage(pic.data()); | 658 | px.convertFromImage(pic.data()); |
655 | } | 659 | } |
656 | 660 | ||
657 | emit contactSelected( px ); | 661 | emit contactSelected( px ); |
658 | } | 662 | } |
659 | } | 663 | } |
660 | 664 | ||
661 | 665 | ||
662 | mExtensionManager->setSelectionChanged(); | 666 | mExtensionManager->setSelectionChanged(); |
663 | 667 | ||
664 | // update the actions | 668 | // update the actions |
665 | bool selected = !uid.isEmpty(); | 669 | bool selected = !uid.isEmpty(); |
666 | 670 | ||
667 | if ( mReadWrite ) { | 671 | if ( mReadWrite ) { |
668 | mActionCut->setEnabled( selected ); | 672 | mActionCut->setEnabled( selected ); |
669 | mActionPaste->setEnabled( selected ); | 673 | mActionPaste->setEnabled( selected ); |
670 | } | 674 | } |
671 | 675 | ||
672 | mActionCopy->setEnabled( selected ); | 676 | mActionCopy->setEnabled( selected ); |
673 | mActionDelete->setEnabled( selected ); | 677 | mActionDelete->setEnabled( selected ); |
674 | mActionEditAddressee->setEnabled( selected ); | 678 | mActionEditAddressee->setEnabled( selected ); |
675 | mActionMail->setEnabled( selected ); | 679 | mActionMail->setEnabled( selected ); |
676 | mActionMailVCard->setEnabled( selected ); | 680 | mActionMailVCard->setEnabled( selected ); |
677 | //if (mActionBeam) | 681 | //if (mActionBeam) |
678 | //mActionBeam->setEnabled( selected ); | 682 | //mActionBeam->setEnabled( selected ); |
679 | mActionWhoAmI->setEnabled( selected ); | 683 | mActionWhoAmI->setEnabled( selected ); |
680 | } | 684 | } |
681 | 685 | ||
682 | void KABCore::sendMail() | 686 | void KABCore::sendMail() |
683 | { | 687 | { |
684 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 688 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
685 | } | 689 | } |
686 | 690 | ||
687 | void KABCore::sendMail( const QString& emaillist ) | 691 | void KABCore::sendMail( const QString& emaillist ) |
688 | { | 692 | { |
689 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 693 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
690 | if (emaillist.contains(",") > 0) | 694 | if (emaillist.contains(",") > 0) |
691 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 695 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
692 | else | 696 | else |
693 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 697 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
694 | } | 698 | } |
695 | 699 | ||
696 | 700 | ||
697 | 701 | ||
698 | void KABCore::mailVCard() | 702 | void KABCore::mailVCard() |
699 | { | 703 | { |
700 | QStringList uids = mViewManager->selectedUids(); | 704 | QStringList uids = mViewManager->selectedUids(); |
701 | if ( !uids.isEmpty() ) | 705 | if ( !uids.isEmpty() ) |
702 | mailVCard( uids ); | 706 | mailVCard( uids ); |
703 | } | 707 | } |
704 | 708 | ||
705 | void KABCore::mailVCard( const QStringList& uids ) | 709 | void KABCore::mailVCard( const QStringList& uids ) |
706 | { | 710 | { |
707 | QStringList urls; | 711 | QStringList urls; |
708 | 712 | ||
709 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 713 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
710 | 714 | ||
711 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 715 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
712 | 716 | ||
713 | 717 | ||
714 | 718 | ||
715 | QDir().mkdir( dirName, true ); | 719 | QDir().mkdir( dirName, true ); |
716 | 720 | ||
717 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 721 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
718 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 722 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
719 | 723 | ||
720 | if ( a.isEmpty() ) | 724 | if ( a.isEmpty() ) |
721 | continue; | 725 | continue; |
722 | 726 | ||
723 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 727 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
724 | 728 | ||
725 | QString fileName = dirName + "/" + name; | 729 | QString fileName = dirName + "/" + name; |
726 | 730 | ||
727 | QFile outFile(fileName); | 731 | QFile outFile(fileName); |
728 | 732 | ||
729 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 733 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
730 | KABC::VCardConverter converter; | 734 | KABC::VCardConverter converter; |
731 | QString vcard; | 735 | QString vcard; |
732 | 736 | ||
733 | converter.addresseeToVCard( a, vcard ); | 737 | converter.addresseeToVCard( a, vcard ); |
734 | 738 | ||
735 | QTextStream t( &outFile ); // use a text stream | 739 | QTextStream t( &outFile ); // use a text stream |
736 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 740 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
737 | t << vcard; | 741 | t << vcard; |
738 | 742 | ||
739 | outFile.close(); | 743 | outFile.close(); |
740 | 744 | ||
741 | urls.append( fileName ); | 745 | urls.append( fileName ); |
742 | } | 746 | } |
743 | } | 747 | } |
744 | 748 | ||
745 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 749 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
746 | 750 | ||
747 | 751 | ||
748 | /*US | 752 | /*US |
749 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 753 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
750 | QString::null, // subject | 754 | QString::null, // subject |
751 | QString::null, // body | 755 | QString::null, // body |
752 | QString::null, | 756 | QString::null, |
753 | urls ); // attachments | 757 | urls ); // attachments |
754 | */ | 758 | */ |
755 | 759 | ||
756 | } | 760 | } |
757 | 761 | ||
758 | /** | 762 | /** |
759 | Beams the "WhoAmI contact. | 763 | Beams the "WhoAmI contact. |
760 | */ | 764 | */ |
761 | void KABCore::beamMySelf() | 765 | void KABCore::beamMySelf() |
762 | { | 766 | { |
763 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 767 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
764 | if (!a.isEmpty()) | 768 | if (!a.isEmpty()) |
765 | { | 769 | { |
766 | QStringList uids; | 770 | QStringList uids; |
767 | uids << a.uid(); | 771 | uids << a.uid(); |
768 | 772 | ||
769 | beamVCard(uids); | 773 | beamVCard(uids); |
770 | } else { | 774 | } else { |
771 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 775 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
772 | 776 | ||
773 | 777 | ||
774 | } | 778 | } |
775 | } | 779 | } |
776 | void KABCore::updateMainWindow() | 780 | void KABCore::updateMainWindow() |
777 | { | 781 | { |
778 | 782 | ||
779 | mMainWindow->showMaximized(); | 783 | mMainWindow->showMaximized(); |
780 | mMainWindow->update(); | 784 | mMainWindow->update(); |
781 | } | 785 | } |
782 | void KABCore::resizeEvent(QResizeEvent* e ) | 786 | void KABCore::resizeEvent(QResizeEvent* e ) |
783 | { | 787 | { |
784 | if ( !mMiniSplitter ) | 788 | if ( !mMiniSplitter ) |
785 | return; | 789 | return; |
786 | if ( QApplication::desktop()->width() >= 480 ) { | 790 | if ( QApplication::desktop()->width() >= 480 ) { |
787 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 | 791 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 |
788 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { | 792 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { |
789 | mMiniSplitter->setOrientation( Qt::Horizontal); | 793 | mMiniSplitter->setOrientation( Qt::Horizontal); |
790 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 794 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
791 | if ( QApplication::desktop()->width() <= 640 ) { | 795 | if ( QApplication::desktop()->width() <= 640 ) { |
792 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | 796 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); |
793 | mViewManager->getFilterAction()->setComboWidth( 150 ); | 797 | mViewManager->getFilterAction()->setComboWidth( 150 ); |
794 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | 798 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); |
795 | } | 799 | } |
796 | } | 800 | } |
797 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 | 801 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 |
798 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { | 802 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { |
799 | mMiniSplitter->setOrientation( Qt::Vertical ); | 803 | mMiniSplitter->setOrientation( Qt::Vertical ); |
800 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 804 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
801 | if ( QApplication::desktop()->width() <= 640 ) { | 805 | if ( QApplication::desktop()->width() <= 640 ) { |
802 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | 806 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); |
803 | mMainWindow->showMinimized(); | 807 | mMainWindow->showMinimized(); |
804 | mViewManager->getFilterAction()->setComboWidth( 0 ); | 808 | mViewManager->getFilterAction()->setComboWidth( 0 ); |
805 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | 809 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); |
806 | } | 810 | } |
807 | } | 811 | } |
808 | } | 812 | } |
809 | } | 813 | } |
810 | 814 | ||
811 | } | 815 | } |
812 | void KABCore::export2phone() | 816 | void KABCore::export2phone() |
813 | { | 817 | { |
814 | 818 | ||
815 | QStringList uids; | 819 | QStringList uids; |
816 | XXPortSelectDialog dlg( this, false, this ); | 820 | XXPortSelectDialog dlg( this, false, this ); |
817 | if ( dlg.exec() ) | 821 | if ( dlg.exec() ) |
818 | uids = dlg.uids(); | 822 | uids = dlg.uids(); |
819 | else | 823 | else |
820 | return; | 824 | return; |
821 | if ( uids.isEmpty() ) | 825 | if ( uids.isEmpty() ) |
822 | return; | 826 | return; |
823 | // qDebug("count %d ", uids.count()); | 827 | // qDebug("count %d ", uids.count()); |
824 | 828 | ||
825 | KAex2phonePrefs ex2phone; | 829 | KAex2phonePrefs ex2phone; |
826 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 830 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
827 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 831 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
828 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 832 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
829 | 833 | ||
830 | if ( !ex2phone.exec() ) { | 834 | if ( !ex2phone.exec() ) { |
831 | return; | 835 | return; |
832 | } | 836 | } |
833 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 837 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
834 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 838 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
835 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 839 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
836 | 840 | ||
837 | 841 | ||
838 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 842 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
839 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 843 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
840 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 844 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
841 | 845 | ||
842 | QString fileName = getPhoneFile(); | 846 | QString fileName = getPhoneFile(); |
843 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) | 847 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) |
844 | return; | 848 | return; |
845 | 849 | ||
846 | message(i18n("Exporting to phone...")); | 850 | message(i18n("Exporting to phone...")); |
847 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); | 851 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); |
848 | 852 | ||
849 | } | 853 | } |
850 | QString KABCore::getPhoneFile() | 854 | QString KABCore::getPhoneFile() |
851 | { | 855 | { |
852 | #ifdef DESKTOP_VERSION | 856 | #ifdef DESKTOP_VERSION |
853 | return locateLocal("tmp", "phonefile.vcf"); | 857 | return locateLocal("tmp", "phonefile.vcf"); |
854 | #else | 858 | #else |
855 | return "/tmp/phonefile.vcf"; | 859 | return "/tmp/phonefile.vcf"; |
856 | #endif | 860 | #endif |
857 | 861 | ||
858 | } | 862 | } |
859 | void KABCore::writeToPhone( ) | 863 | void KABCore::writeToPhone( ) |
860 | { | 864 | { |
861 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) | 865 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) |
862 | message(i18n("Export to phone finished!")); | 866 | message(i18n("Export to phone finished!")); |
863 | else | 867 | else |
864 | qDebug(i18n("Error exporting to phone")); | 868 | qDebug(i18n("Error exporting to phone")); |
865 | } | 869 | } |
866 | void KABCore::beamVCard() | 870 | void KABCore::beamVCard() |
867 | { | 871 | { |
868 | QStringList uids; | 872 | QStringList uids; |
869 | XXPortSelectDialog dlg( this, false, this ); | 873 | XXPortSelectDialog dlg( this, false, this ); |
870 | if ( dlg.exec() ) | 874 | if ( dlg.exec() ) |
871 | uids = dlg.uids(); | 875 | uids = dlg.uids(); |
872 | else | 876 | else |
873 | return; | 877 | return; |
874 | if ( uids.isEmpty() ) | 878 | if ( uids.isEmpty() ) |
875 | return; | 879 | return; |
876 | beamVCard( uids ); | 880 | beamVCard( uids ); |
877 | } | 881 | } |
878 | 882 | ||
879 | 883 | ||
880 | void KABCore::beamVCard(const QStringList& uids) | 884 | void KABCore::beamVCard(const QStringList& uids) |
881 | { | 885 | { |
882 | 886 | ||
883 | // LR: we should use the /tmp dir on the Zaurus, | 887 | // LR: we should use the /tmp dir on the Zaurus, |
884 | // because: /tmp = RAM, (HOME)/kdepim = flash memory | 888 | // because: /tmp = RAM, (HOME)/kdepim = flash memory |
885 | 889 | ||
886 | #ifdef DESKTOP_VERSION | 890 | #ifdef DESKTOP_VERSION |
887 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); | 891 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); |
888 | #else | 892 | #else |
889 | QString fileName = "/tmp/kapibeamfile.vcf"; | 893 | QString fileName = "/tmp/kapibeamfile.vcf"; |
890 | #endif | 894 | #endif |
891 | 895 | ||
892 | KABC::VCardConverter converter; | 896 | KABC::VCardConverter converter; |
893 | QString description; | 897 | QString description; |
894 | QString datastream; | 898 | QString datastream; |
895 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 899 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
896 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 900 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
897 | 901 | ||
898 | if ( a.isEmpty() ) | 902 | if ( a.isEmpty() ) |
899 | continue; | 903 | continue; |
900 | 904 | ||
901 | if (description.isEmpty()) | 905 | if (description.isEmpty()) |
902 | description = a.formattedName(); | 906 | description = a.formattedName(); |
903 | 907 | ||
904 | QString vcard; | 908 | QString vcard; |
905 | converter.addresseeToVCard( a, vcard ); | 909 | converter.addresseeToVCard( a, vcard ); |
906 | int start = 0; | 910 | int start = 0; |
907 | int next; | 911 | int next; |
908 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 912 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
909 | int semi = vcard.find(";", next); | 913 | int semi = vcard.find(";", next); |
910 | int dopp = vcard.find(":", next); | 914 | int dopp = vcard.find(":", next); |
911 | int sep; | 915 | int sep; |
912 | if ( semi < dopp && semi >= 0 ) | 916 | if ( semi < dopp && semi >= 0 ) |
913 | sep = semi ; | 917 | sep = semi ; |
914 | else | 918 | else |
915 | sep = dopp; | 919 | sep = dopp; |
916 | datastream +=vcard.mid( start, next - start); | 920 | datastream +=vcard.mid( start, next - start); |
917 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 921 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
918 | start = sep; | 922 | start = sep; |
919 | } | 923 | } |
920 | datastream += vcard.mid( start,vcard.length() ); | 924 | datastream += vcard.mid( start,vcard.length() ); |
921 | } | 925 | } |
922 | #ifndef DESKTOP_VERSION | 926 | #ifndef DESKTOP_VERSION |
923 | QFile outFile(fileName); | 927 | QFile outFile(fileName); |
924 | if ( outFile.open(IO_WriteOnly) ) { | 928 | if ( outFile.open(IO_WriteOnly) ) { |
925 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 929 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
926 | QTextStream t( &outFile ); // use a text stream | 930 | QTextStream t( &outFile ); // use a text stream |
927 | //t.setEncoding( QTextStream::UnicodeUTF8 ); | 931 | //t.setEncoding( QTextStream::UnicodeUTF8 ); |
928 | t.setEncoding( QTextStream::Latin1 ); | 932 | t.setEncoding( QTextStream::Latin1 ); |
929 | t <<datastream.latin1(); | 933 | t <<datastream.latin1(); |
930 | outFile.close(); | 934 | outFile.close(); |
931 | Ir *ir = new Ir( this ); | 935 | Ir *ir = new Ir( this ); |
932 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 936 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
933 | ir->send( fileName, description, "text/x-vCard" ); | 937 | ir->send( fileName, description, "text/x-vCard" ); |
934 | } else { | 938 | } else { |
935 | qDebug("Error open temp beam file "); | 939 | qDebug("Error open temp beam file "); |
936 | return; | 940 | return; |
937 | } | 941 | } |
938 | #endif | 942 | #endif |
939 | 943 | ||
940 | } | 944 | } |
941 | 945 | ||
942 | void KABCore::beamDone( Ir *ir ) | 946 | void KABCore::beamDone( Ir *ir ) |
943 | { | 947 | { |
944 | #ifndef DESKTOP_VERSION | 948 | #ifndef DESKTOP_VERSION |
945 | delete ir; | 949 | delete ir; |
946 | #endif | 950 | #endif |
947 | topLevelWidget()->raise(); | 951 | topLevelWidget()->raise(); |
948 | message( i18n("Beaming finished!") ); | 952 | message( i18n("Beaming finished!") ); |
949 | } | 953 | } |
950 | 954 | ||
951 | 955 | ||
952 | void KABCore::browse( const QString& url ) | 956 | void KABCore::browse( const QString& url ) |
953 | { | 957 | { |
954 | #ifndef KAB_EMBEDDED | 958 | #ifndef KAB_EMBEDDED |
955 | kapp->invokeBrowser( url ); | 959 | kapp->invokeBrowser( url ); |
956 | #else //KAB_EMBEDDED | 960 | #else //KAB_EMBEDDED |
957 | qDebug("KABCore::browse must be fixed"); | 961 | qDebug("KABCore::browse must be fixed"); |
958 | #endif //KAB_EMBEDDED | 962 | #endif //KAB_EMBEDDED |
959 | } | 963 | } |
960 | 964 | ||
961 | void KABCore::selectAllContacts() | 965 | void KABCore::selectAllContacts() |
962 | { | 966 | { |
963 | mViewManager->setSelected( QString::null, true ); | 967 | mViewManager->setSelected( QString::null, true ); |
964 | } | 968 | } |
965 | 969 | ||
966 | void KABCore::deleteContacts() | 970 | void KABCore::deleteContacts() |
967 | { | 971 | { |
968 | QStringList uidList = mViewManager->selectedUids(); | 972 | QStringList uidList = mViewManager->selectedUids(); |
969 | deleteContacts( uidList ); | 973 | deleteContacts( uidList ); |
970 | } | 974 | } |
971 | 975 | ||
972 | void KABCore::deleteContacts( const QStringList &uids ) | 976 | void KABCore::deleteContacts( const QStringList &uids ) |
973 | { | 977 | { |
974 | if ( uids.count() > 0 ) { | 978 | if ( uids.count() > 0 ) { |
975 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 979 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
976 | UndoStack::instance()->push( command ); | 980 | UndoStack::instance()->push( command ); |
977 | RedoStack::instance()->clear(); | 981 | RedoStack::instance()->clear(); |
978 | 982 | ||
979 | // now if we deleted anything, refresh | 983 | // now if we deleted anything, refresh |
980 | setContactSelected( QString::null ); | 984 | setContactSelected( QString::null ); |
981 | setModified( true ); | 985 | setModified( true ); |
982 | } | 986 | } |
983 | } | 987 | } |
984 | 988 | ||
985 | void KABCore::copyContacts() | 989 | void KABCore::copyContacts() |
986 | { | 990 | { |
987 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 991 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
988 | 992 | ||
989 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 993 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
990 | 994 | ||
991 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 995 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
992 | 996 | ||
993 | QClipboard *cb = QApplication::clipboard(); | 997 | QClipboard *cb = QApplication::clipboard(); |
994 | cb->setText( clipText ); | 998 | cb->setText( clipText ); |
995 | } | 999 | } |
996 | 1000 | ||
997 | void KABCore::cutContacts() | 1001 | void KABCore::cutContacts() |
998 | { | 1002 | { |
999 | QStringList uidList = mViewManager->selectedUids(); | 1003 | QStringList uidList = mViewManager->selectedUids(); |
1000 | 1004 | ||
1001 | //US if ( uidList.size() > 0 ) { | 1005 | //US if ( uidList.size() > 0 ) { |
1002 | if ( uidList.count() > 0 ) { | 1006 | if ( uidList.count() > 0 ) { |
1003 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 1007 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
1004 | UndoStack::instance()->push( command ); | 1008 | UndoStack::instance()->push( command ); |
1005 | RedoStack::instance()->clear(); | 1009 | RedoStack::instance()->clear(); |
1006 | 1010 | ||
1007 | setModified( true ); | 1011 | setModified( true ); |
1008 | } | 1012 | } |
1009 | } | 1013 | } |
1010 | 1014 | ||
1011 | void KABCore::pasteContacts() | 1015 | void KABCore::pasteContacts() |
1012 | { | 1016 | { |
1013 | QClipboard *cb = QApplication::clipboard(); | 1017 | QClipboard *cb = QApplication::clipboard(); |
1014 | 1018 | ||
1015 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 1019 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
1016 | 1020 | ||
1017 | pasteContacts( list ); | 1021 | pasteContacts( list ); |
1018 | } | 1022 | } |
1019 | 1023 | ||
1020 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 1024 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
1021 | { | 1025 | { |
1022 | KABC::Resource *resource = requestResource( this ); | 1026 | KABC::Resource *resource = requestResource( this ); |
1023 | KABC::Addressee::List::Iterator it; | 1027 | KABC::Addressee::List::Iterator it; |
1024 | for ( it = list.begin(); it != list.end(); ++it ) | 1028 | for ( it = list.begin(); it != list.end(); ++it ) |
1025 | (*it).setResource( resource ); | 1029 | (*it).setResource( resource ); |
1026 | 1030 | ||
1027 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 1031 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
1028 | UndoStack::instance()->push( command ); | 1032 | UndoStack::instance()->push( command ); |
1029 | RedoStack::instance()->clear(); | 1033 | RedoStack::instance()->clear(); |
1030 | 1034 | ||
1031 | setModified( true ); | 1035 | setModified( true ); |
1032 | } | 1036 | } |
1033 | 1037 | ||
1034 | void KABCore::setWhoAmI() | 1038 | void KABCore::setWhoAmI() |
1035 | { | 1039 | { |
1036 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1040 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1037 | 1041 | ||
1038 | if ( addrList.count() > 1 ) { | 1042 | if ( addrList.count() > 1 ) { |
1039 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 1043 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
1040 | return; | 1044 | return; |
1041 | } | 1045 | } |
1042 | 1046 | ||
1043 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 1047 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
1044 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 1048 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
1045 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 1049 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
1046 | } | 1050 | } |
1047 | void KABCore::editCategories() | 1051 | void KABCore::editCategories() |
1048 | { | 1052 | { |
1049 | KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); | 1053 | KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); |
1050 | dlg.exec(); | 1054 | dlg.exec(); |
1051 | } | 1055 | } |
1052 | void KABCore::setCategories() | 1056 | void KABCore::setCategories() |
1053 | { | 1057 | { |
1054 | 1058 | ||
1055 | QStringList uids; | 1059 | QStringList uids; |
1056 | XXPortSelectDialog dlgx( this, false, this ); | 1060 | XXPortSelectDialog dlgx( this, false, this ); |
1057 | if ( dlgx.exec() ) | 1061 | if ( dlgx.exec() ) |
1058 | uids = dlgx.uids(); | 1062 | uids = dlgx.uids(); |
1059 | else | 1063 | else |
1060 | return; | 1064 | return; |
1061 | if ( uids.isEmpty() ) | 1065 | if ( uids.isEmpty() ) |
1062 | return; | 1066 | return; |
1063 | // qDebug("count %d ", uids.count()); | 1067 | // qDebug("count %d ", uids.count()); |
1064 | 1068 | ||
1065 | 1069 | ||
1066 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 1070 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
1067 | if ( !dlg.exec() ) { | 1071 | if ( !dlg.exec() ) { |
1068 | message( i18n("Setting categories cancelled") ); | 1072 | message( i18n("Setting categories cancelled") ); |
1069 | return; | 1073 | return; |
1070 | } | 1074 | } |
1071 | bool merge = false; | 1075 | bool merge = false; |
1072 | QString msg = i18n( "Merge with existing categories?" ); | 1076 | QString msg = i18n( "Merge with existing categories?" ); |
1073 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 1077 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
1074 | merge = true; | 1078 | merge = true; |
1075 | 1079 | ||
1076 | message( i18n("Setting categories ... please wait!") ); | 1080 | message( i18n("Setting categories ... please wait!") ); |
1077 | QStringList categories = dlg.selectedCategories(); | 1081 | QStringList categories = dlg.selectedCategories(); |
1078 | 1082 | ||
1079 | //QStringList uids = mViewManager->selectedUids(); | 1083 | //QStringList uids = mViewManager->selectedUids(); |
1080 | QStringList::Iterator it; | 1084 | QStringList::Iterator it; |
1081 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 1085 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
1082 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 1086 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
1083 | if ( !addr.isEmpty() ) { | 1087 | if ( !addr.isEmpty() ) { |
1084 | if ( !merge ) | 1088 | if ( !merge ) |
1085 | addr.setCategories( categories ); | 1089 | addr.setCategories( categories ); |
1086 | else { | 1090 | else { |
1087 | QStringList addrCategories = addr.categories(); | 1091 | QStringList addrCategories = addr.categories(); |
1088 | QStringList::Iterator catIt; | 1092 | QStringList::Iterator catIt; |
1089 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 1093 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
1090 | if ( !addrCategories.contains( *catIt ) ) | 1094 | if ( !addrCategories.contains( *catIt ) ) |
1091 | addrCategories.append( *catIt ); | 1095 | addrCategories.append( *catIt ); |
1092 | } | 1096 | } |
1093 | addr.setCategories( addrCategories ); | 1097 | addr.setCategories( addrCategories ); |
1094 | } | 1098 | } |
1095 | mAddressBook->insertAddressee( addr ); | 1099 | mAddressBook->insertAddressee( addr ); |
1096 | } | 1100 | } |
1097 | } | 1101 | } |
1098 | 1102 | ||
1099 | if ( uids.count() > 0 ) | 1103 | if ( uids.count() > 0 ) |
1100 | setModified( true ); | 1104 | setModified( true ); |
1101 | message( i18n("Setting categories completed!") ); | 1105 | message( i18n("Setting categories completed!") ); |
1102 | } | 1106 | } |
1103 | 1107 | ||
1104 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 1108 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
1105 | { | 1109 | { |
1106 | mIncSearchWidget->setFields( fields ); | 1110 | mIncSearchWidget->setFields( fields ); |
1107 | } | 1111 | } |
1108 | 1112 | ||
1109 | void KABCore::incrementalSearch( const QString& text ) | 1113 | void KABCore::incrementalSearch( const QString& text ) |
1110 | { | 1114 | { |
1111 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 1115 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
1112 | } | 1116 | } |
1113 | 1117 | ||
1114 | void KABCore::setModified() | 1118 | void KABCore::setModified() |
1115 | { | 1119 | { |
1116 | setModified( true ); | 1120 | setModified( true ); |
1117 | } | 1121 | } |
1118 | 1122 | ||
1119 | void KABCore::setModifiedWOrefresh() | 1123 | void KABCore::setModifiedWOrefresh() |
1120 | { | 1124 | { |
1121 | // qDebug("KABCore::setModifiedWOrefresh() "); | 1125 | // qDebug("KABCore::setModifiedWOrefresh() "); |
1122 | mModified = true; | 1126 | mModified = true; |
1123 | mActionSave->setEnabled( mModified ); | 1127 | mActionSave->setEnabled( mModified ); |
1124 | #ifdef DESKTOP_VERSION | 1128 | #ifdef DESKTOP_VERSION |
1125 | mDetails->refreshView(); | 1129 | mDetails->refreshView(); |
1126 | #endif | 1130 | #endif |
1127 | 1131 | ||
1128 | } | 1132 | } |
1129 | void KABCore::setModified( bool modified ) | 1133 | void KABCore::setModified( bool modified ) |
1130 | { | 1134 | { |
1131 | mModified = modified; | 1135 | mModified = modified; |
1132 | mActionSave->setEnabled( mModified ); | 1136 | mActionSave->setEnabled( mModified ); |
1133 | 1137 | ||
1134 | if ( modified ) | 1138 | if ( modified ) |
1135 | mJumpButtonBar->recreateButtons(); | 1139 | mJumpButtonBar->recreateButtons(); |
1136 | 1140 | ||
1137 | mViewManager->refreshView(); | 1141 | mViewManager->refreshView(); |
diff --git a/microkde/kdeui/ktoolbar.cpp b/microkde/kdeui/ktoolbar.cpp index 79b0f9d..e9226c0 100644 --- a/microkde/kdeui/ktoolbar.cpp +++ b/microkde/kdeui/ktoolbar.cpp | |||
@@ -645,1536 +645,1542 @@ QString KToolBar::getLinedText (int id) const | |||
645 | 645 | ||
646 | 646 | ||
647 | void KToolBar::insertComboItem (int id, const QString& text, int index) | 647 | void KToolBar::insertComboItem (int id, const QString& text, int index) |
648 | { | 648 | { |
649 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 649 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
650 | if ( it == id2widget.end() ) | 650 | if ( it == id2widget.end() ) |
651 | return; | 651 | return; |
652 | //US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); | 652 | //US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); |
653 | QComboBox * comboBox = (QComboBox *)( *it ); | 653 | QComboBox * comboBox = (QComboBox *)( *it ); |
654 | if (comboBox) | 654 | if (comboBox) |
655 | comboBox->insertItem( text, index ); | 655 | comboBox->insertItem( text, index ); |
656 | } | 656 | } |
657 | 657 | ||
658 | void KToolBar::insertComboList (int id, const QStringList &list, int index) | 658 | void KToolBar::insertComboList (int id, const QStringList &list, int index) |
659 | { | 659 | { |
660 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 660 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
661 | if ( it == id2widget.end() ) | 661 | if ( it == id2widget.end() ) |
662 | return; | 662 | return; |
663 | //US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); | 663 | //US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); |
664 | QComboBox * comboBox = (QComboBox *)( *it ); | 664 | QComboBox * comboBox = (QComboBox *)( *it ); |
665 | if (comboBox) | 665 | if (comboBox) |
666 | comboBox->insertStringList( list, index ); | 666 | comboBox->insertStringList( list, index ); |
667 | } | 667 | } |
668 | 668 | ||
669 | 669 | ||
670 | void KToolBar::removeComboItem (int id, int index) | 670 | void KToolBar::removeComboItem (int id, int index) |
671 | { | 671 | { |
672 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 672 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
673 | if ( it == id2widget.end() ) | 673 | if ( it == id2widget.end() ) |
674 | return; | 674 | return; |
675 | //US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); | 675 | //US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); |
676 | QComboBox * comboBox = (QComboBox *)( *it ); | 676 | QComboBox * comboBox = (QComboBox *)( *it ); |
677 | if (comboBox) | 677 | if (comboBox) |
678 | comboBox->removeItem( index ); | 678 | comboBox->removeItem( index ); |
679 | } | 679 | } |
680 | 680 | ||
681 | 681 | ||
682 | void KToolBar::setCurrentComboItem (int id, int index) | 682 | void KToolBar::setCurrentComboItem (int id, int index) |
683 | { | 683 | { |
684 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 684 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
685 | if ( it == id2widget.end() ) | 685 | if ( it == id2widget.end() ) |
686 | return; | 686 | return; |
687 | //US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); | 687 | //US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); |
688 | QComboBox * comboBox = (QComboBox *)( *it ); | 688 | QComboBox * comboBox = (QComboBox *)( *it ); |
689 | if (comboBox) | 689 | if (comboBox) |
690 | comboBox->setCurrentItem( index ); | 690 | comboBox->setCurrentItem( index ); |
691 | } | 691 | } |
692 | 692 | ||
693 | 693 | ||
694 | void KToolBar::changeComboItem (int id, const QString& text, int index) | 694 | void KToolBar::changeComboItem (int id, const QString& text, int index) |
695 | { | 695 | { |
696 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 696 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
697 | if ( it == id2widget.end() ) | 697 | if ( it == id2widget.end() ) |
698 | return; | 698 | return; |
699 | //US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); | 699 | //US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); |
700 | QComboBox * comboBox = (QComboBox *)( *it ); | 700 | QComboBox * comboBox = (QComboBox *)( *it ); |
701 | if (comboBox) | 701 | if (comboBox) |
702 | comboBox->changeItem( text, index ); | 702 | comboBox->changeItem( text, index ); |
703 | } | 703 | } |
704 | 704 | ||
705 | 705 | ||
706 | void KToolBar::clearCombo (int id) | 706 | void KToolBar::clearCombo (int id) |
707 | { | 707 | { |
708 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 708 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
709 | if ( it == id2widget.end() ) | 709 | if ( it == id2widget.end() ) |
710 | return; | 710 | return; |
711 | //US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); | 711 | //US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); |
712 | QComboBox * comboBox = (QComboBox *)( *it ); | 712 | QComboBox * comboBox = (QComboBox *)( *it ); |
713 | if (comboBox) | 713 | if (comboBox) |
714 | comboBox->clear(); | 714 | comboBox->clear(); |
715 | } | 715 | } |
716 | 716 | ||
717 | 717 | ||
718 | QString KToolBar::getComboItem (int id, int index) const | 718 | QString KToolBar::getComboItem (int id, int index) const |
719 | { | 719 | { |
720 | Id2WidgetMap::ConstIterator it = id2widget.find( id ); | 720 | Id2WidgetMap::ConstIterator it = id2widget.find( id ); |
721 | if ( it == id2widget.end() ) | 721 | if ( it == id2widget.end() ) |
722 | return QString::null; | 722 | return QString::null; |
723 | //US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); | 723 | //US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); |
724 | QComboBox * comboBox = (QComboBox *)( *it ); | 724 | QComboBox * comboBox = (QComboBox *)( *it ); |
725 | return comboBox ? comboBox->text( index ) : QString::null; | 725 | return comboBox ? comboBox->text( index ) : QString::null; |
726 | } | 726 | } |
727 | 727 | ||
728 | 728 | ||
729 | KComboBox * KToolBar::getCombo(int id) | 729 | KComboBox * KToolBar::getCombo(int id) |
730 | { | 730 | { |
731 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 731 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
732 | if ( it == id2widget.end() ) | 732 | if ( it == id2widget.end() ) |
733 | return 0; | 733 | return 0; |
734 | //US return dynamic_cast<KComboBox *>( *it ); | 734 | //US return dynamic_cast<KComboBox *>( *it ); |
735 | return (KComboBox *)( *it ); | 735 | return (KComboBox *)( *it ); |
736 | } | 736 | } |
737 | 737 | ||
738 | 738 | ||
739 | KLineEdit * KToolBar::getLined (int id) | 739 | KLineEdit * KToolBar::getLined (int id) |
740 | { | 740 | { |
741 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 741 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
742 | if ( it == id2widget.end() ) | 742 | if ( it == id2widget.end() ) |
743 | return 0; | 743 | return 0; |
744 | //US return dynamic_cast<KLineEdit *>( *it ); | 744 | //US return dynamic_cast<KLineEdit *>( *it ); |
745 | return (KLineEdit *)( *it ); | 745 | return (KLineEdit *)( *it ); |
746 | } | 746 | } |
747 | 747 | ||
748 | 748 | ||
749 | KToolBarButton * KToolBar::getButton (int id) | 749 | KToolBarButton * KToolBar::getButton (int id) |
750 | { | 750 | { |
751 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 751 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
752 | if ( it == id2widget.end() ) | 752 | if ( it == id2widget.end() ) |
753 | return 0; | 753 | return 0; |
754 | //US return dynamic_cast<KToolBarButton *>( *it ); | 754 | //US return dynamic_cast<KToolBarButton *>( *it ); |
755 | return (KToolBarButton *)( *it ); | 755 | return (KToolBarButton *)( *it ); |
756 | } | 756 | } |
757 | 757 | ||
758 | 758 | ||
759 | void KToolBar::alignItemRight (int id, bool right ) | 759 | void KToolBar::alignItemRight (int id, bool right ) |
760 | { | 760 | { |
761 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 761 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
762 | if ( it == id2widget.end() ) | 762 | if ( it == id2widget.end() ) |
763 | return; | 763 | return; |
764 | if ( rightAligned && !right && (*it) == rightAligned ) | 764 | if ( rightAligned && !right && (*it) == rightAligned ) |
765 | rightAligned = 0; | 765 | rightAligned = 0; |
766 | if ( (*it) && right ) | 766 | if ( (*it) && right ) |
767 | rightAligned = (*it); | 767 | rightAligned = (*it); |
768 | } | 768 | } |
769 | 769 | ||
770 | 770 | ||
771 | QWidget *KToolBar::getWidget (int id) | 771 | QWidget *KToolBar::getWidget (int id) |
772 | { | 772 | { |
773 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 773 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
774 | return ( it == id2widget.end() ) ? 0 : (*it); | 774 | return ( it == id2widget.end() ) ? 0 : (*it); |
775 | } | 775 | } |
776 | 776 | ||
777 | 777 | ||
778 | void KToolBar::setItemAutoSized (int id, bool yes ) | 778 | void KToolBar::setItemAutoSized (int id, bool yes ) |
779 | { | 779 | { |
780 | QWidget *w = getWidget(id); | 780 | QWidget *w = getWidget(id); |
781 | if ( w && yes ) | 781 | if ( w && yes ) |
782 | setStretchableWidget( w ); | 782 | setStretchableWidget( w ); |
783 | } | 783 | } |
784 | 784 | ||
785 | 785 | ||
786 | void KToolBar::clear () | 786 | void KToolBar::clear () |
787 | { | 787 | { |
788 | QToolBar::clear(); | 788 | QToolBar::clear(); |
789 | widget2id.clear(); | 789 | widget2id.clear(); |
790 | id2widget.clear(); | 790 | id2widget.clear(); |
791 | } | 791 | } |
792 | 792 | ||
793 | 793 | ||
794 | void KToolBar::removeItem(int id) | 794 | void KToolBar::removeItem(int id) |
795 | { | 795 | { |
796 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 796 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
797 | if ( it == id2widget.end() ) | 797 | if ( it == id2widget.end() ) |
798 | { | 798 | { |
799 | kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl; | 799 | kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl; |
800 | return; | 800 | return; |
801 | } | 801 | } |
802 | QWidget * w = (*it); | 802 | QWidget * w = (*it); |
803 | id2widget.remove( id ); | 803 | id2widget.remove( id ); |
804 | widget2id.remove( w ); | 804 | widget2id.remove( w ); |
805 | widgets.removeRef( w ); | 805 | widgets.removeRef( w ); |
806 | delete w; | 806 | delete w; |
807 | } | 807 | } |
808 | 808 | ||
809 | 809 | ||
810 | void KToolBar::removeItemDelayed(int id) | 810 | void KToolBar::removeItemDelayed(int id) |
811 | { | 811 | { |
812 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 812 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
813 | if ( it == id2widget.end() ) | 813 | if ( it == id2widget.end() ) |
814 | { | 814 | { |
815 | kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl; | 815 | kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl; |
816 | return; | 816 | return; |
817 | } | 817 | } |
818 | QWidget * w = (*it); | 818 | QWidget * w = (*it); |
819 | id2widget.remove( id ); | 819 | id2widget.remove( id ); |
820 | widget2id.remove( w ); | 820 | widget2id.remove( w ); |
821 | widgets.removeRef( w ); | 821 | widgets.removeRef( w ); |
822 | 822 | ||
823 | w->blockSignals(true); | 823 | w->blockSignals(true); |
824 | d->idleButtons.append(w); | 824 | d->idleButtons.append(w); |
825 | layoutTimer->start( 50, TRUE ); | 825 | layoutTimer->start( 50, TRUE ); |
826 | } | 826 | } |
827 | 827 | ||
828 | 828 | ||
829 | void KToolBar::hideItem (int id) | 829 | void KToolBar::hideItem (int id) |
830 | { | 830 | { |
831 | QWidget *w = getWidget(id); | 831 | QWidget *w = getWidget(id); |
832 | if ( w ) | 832 | if ( w ) |
833 | w->hide(); | 833 | w->hide(); |
834 | } | 834 | } |
835 | 835 | ||
836 | 836 | ||
837 | void KToolBar::showItem (int id) | 837 | void KToolBar::showItem (int id) |
838 | { | 838 | { |
839 | QWidget *w = getWidget(id); | 839 | QWidget *w = getWidget(id); |
840 | if ( w ) | 840 | if ( w ) |
841 | w->show(); | 841 | w->show(); |
842 | } | 842 | } |
843 | 843 | ||
844 | 844 | ||
845 | int KToolBar::itemIndex (int id) | 845 | int KToolBar::itemIndex (int id) |
846 | { | 846 | { |
847 | QWidget *w = getWidget(id); | 847 | QWidget *w = getWidget(id); |
848 | return w ? widgets.findRef(w) : -1; | 848 | return w ? widgets.findRef(w) : -1; |
849 | } | 849 | } |
850 | 850 | ||
851 | 851 | ||
852 | void KToolBar::setFullSize(bool flag ) | 852 | void KToolBar::setFullSize(bool flag ) |
853 | { | 853 | { |
854 | setHorizontalStretchable( flag ); | 854 | setHorizontalStretchable( flag ); |
855 | setVerticalStretchable( flag ); | 855 | setVerticalStretchable( flag ); |
856 | } | 856 | } |
857 | 857 | ||
858 | 858 | ||
859 | bool KToolBar::fullSize() const | 859 | bool KToolBar::fullSize() const |
860 | { | 860 | { |
861 | return isHorizontalStretchable() || isVerticalStretchable(); | 861 | return isHorizontalStretchable() || isVerticalStretchable(); |
862 | } | 862 | } |
863 | 863 | ||
864 | 864 | ||
865 | void KToolBar::enableMoving(bool flag ) | 865 | void KToolBar::enableMoving(bool flag ) |
866 | { | 866 | { |
867 | //US setMovingEnabled(flag); | 867 | //US setMovingEnabled(flag); |
868 | this->mainWindow()->setToolBarsMovable(flag); | 868 | this->mainWindow()->setToolBarsMovable(flag); |
869 | } | 869 | } |
870 | 870 | ||
871 | 871 | ||
872 | void KToolBar::setBarPos (BarPosition bpos) | 872 | void KToolBar::setBarPos (BarPosition bpos) |
873 | { | 873 | { |
874 | if ( !mainWindow() ) | 874 | if ( !mainWindow() ) |
875 | return; | 875 | return; |
876 | //US mainWindow()->moveDockWindow( this, (Dock)bpos ); | 876 | //US mainWindow()->moveDockWindow( this, (Dock)bpos ); |
877 | mainWindow()->moveToolBar( this, (QMainWindow::ToolBarDock)bpos ); | 877 | mainWindow()->moveToolBar( this, (QMainWindow::ToolBarDock)bpos ); |
878 | } | 878 | } |
879 | 879 | ||
880 | 880 | ||
881 | KToolBar::BarPosition KToolBar::barPos() | 881 | KToolBar::BarPosition KToolBar::barPos() |
882 | { | 882 | { |
883 | if ( !(QMainWindow*)mainWindow() ) | 883 | if ( !(QMainWindow*)mainWindow() ) |
884 | return KToolBar::Top; | 884 | return KToolBar::Top; |
885 | //US Dock dock; | 885 | //US Dock dock; |
886 | QMainWindow::ToolBarDock dock; | 886 | QMainWindow::ToolBarDock dock; |
887 | int dm1, dm2; | 887 | int dm1, dm2; |
888 | bool dm3; | 888 | bool dm3; |
889 | ((QMainWindow*)mainWindow())->getLocation( (QToolBar*)this, dock, dm1, dm3, dm2 ); | 889 | ((QMainWindow*)mainWindow())->getLocation( (QToolBar*)this, dock, dm1, dm3, dm2 ); |
890 | //US if ( dock == DockUnmanaged ) { | 890 | //US if ( dock == DockUnmanaged ) { |
891 | if ( dock == QMainWindow::Unmanaged ) { | 891 | if ( dock == QMainWindow::Unmanaged ) { |
892 | return (KToolBar::BarPosition)Top; | 892 | return (KToolBar::BarPosition)Top; |
893 | } | 893 | } |
894 | return (BarPosition)dock; | 894 | return (BarPosition)dock; |
895 | } | 895 | } |
896 | 896 | ||
897 | 897 | ||
898 | bool KToolBar::enable(BarStatus stat) | 898 | bool KToolBar::enable(BarStatus stat) |
899 | { | 899 | { |
900 | bool mystat = isVisible(); | 900 | bool mystat = isVisible(); |
901 | 901 | ||
902 | if ( (stat == Toggle && mystat) || stat == Hide ) | 902 | if ( (stat == Toggle && mystat) || stat == Hide ) |
903 | hide(); | 903 | hide(); |
904 | else | 904 | else |
905 | show(); | 905 | show(); |
906 | 906 | ||
907 | return isVisible() == mystat; | 907 | return isVisible() == mystat; |
908 | } | 908 | } |
909 | 909 | ||
910 | 910 | ||
911 | void KToolBar::setMaxHeight ( int h ) | 911 | void KToolBar::setMaxHeight ( int h ) |
912 | { | 912 | { |
913 | setMaximumHeight( h ); | 913 | setMaximumHeight( h ); |
914 | } | 914 | } |
915 | 915 | ||
916 | int KToolBar::maxHeight() | 916 | int KToolBar::maxHeight() |
917 | { | 917 | { |
918 | return maximumHeight(); | 918 | return maximumHeight(); |
919 | } | 919 | } |
920 | 920 | ||
921 | 921 | ||
922 | void KToolBar::setMaxWidth (int dw) | 922 | void KToolBar::setMaxWidth (int dw) |
923 | { | 923 | { |
924 | setMaximumWidth( dw ); | 924 | setMaximumWidth( dw ); |
925 | } | 925 | } |
926 | 926 | ||
927 | 927 | ||
928 | int KToolBar::maxWidth() | 928 | int KToolBar::maxWidth() |
929 | { | 929 | { |
930 | return maximumWidth(); | 930 | return maximumWidth(); |
931 | } | 931 | } |
932 | 932 | ||
933 | 933 | ||
934 | void KToolBar::setTitle (const QString& _title) | 934 | void KToolBar::setTitle (const QString& _title) |
935 | { | 935 | { |
936 | setLabel( _title ); | 936 | setLabel( _title ); |
937 | } | 937 | } |
938 | 938 | ||
939 | 939 | ||
940 | void KToolBar::enableFloating (bool ) | 940 | void KToolBar::enableFloating (bool ) |
941 | { | 941 | { |
942 | } | 942 | } |
943 | 943 | ||
944 | 944 | ||
945 | void KToolBar::setIconText(IconText it) | 945 | void KToolBar::setIconText(IconText it) |
946 | { | 946 | { |
947 | setIconText( it, true ); | 947 | setIconText( it, true ); |
948 | } | 948 | } |
949 | 949 | ||
950 | 950 | ||
951 | void KToolBar::setIconText(IconText icontext, bool update) | 951 | void KToolBar::setIconText(IconText icontext, bool update) |
952 | { | 952 | { |
953 | bool doUpdate=false; | 953 | bool doUpdate=false; |
954 | 954 | ||
955 | if (icontext != d->m_iconText) { | 955 | if (icontext != d->m_iconText) { |
956 | d->m_iconText = icontext; | 956 | d->m_iconText = icontext; |
957 | doUpdate=true; | 957 | doUpdate=true; |
958 | } | 958 | } |
959 | 959 | ||
960 | if (update == false) | 960 | if (update == false) |
961 | return; | 961 | return; |
962 | 962 | ||
963 | if (doUpdate) | 963 | if (doUpdate) |
964 | emit modechange(); // tell buttons what happened | 964 | emit modechange(); // tell buttons what happened |
965 | 965 | ||
966 | // ugly hack to force a QMainWindow::triggerLayout( TRUE ) | 966 | // ugly hack to force a QMainWindow::triggerLayout( TRUE ) |
967 | if ( mainWindow() ) { | 967 | if ( mainWindow() ) { |
968 | QMainWindow *mw = mainWindow(); | 968 | QMainWindow *mw = mainWindow(); |
969 | mw->setUpdatesEnabled( FALSE ); | 969 | mw->setUpdatesEnabled( FALSE ); |
970 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); | 970 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); |
971 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); | 971 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); |
972 | mw->setUpdatesEnabled( TRUE ); | 972 | mw->setUpdatesEnabled( TRUE ); |
973 | } | 973 | } |
974 | } | 974 | } |
975 | 975 | ||
976 | 976 | ||
977 | KToolBar::IconText KToolBar::iconText() const | 977 | KToolBar::IconText KToolBar::iconText() const |
978 | { | 978 | { |
979 | return d->m_iconText; | 979 | return d->m_iconText; |
980 | } | 980 | } |
981 | 981 | ||
982 | 982 | ||
983 | void KToolBar::setIconSize(int size) | 983 | void KToolBar::setIconSize(int size) |
984 | { | 984 | { |
985 | setIconSize( size, true ); | 985 | setIconSize( size, true ); |
986 | } | 986 | } |
987 | 987 | ||
988 | void KToolBar::setIconSize(int size, bool update) | 988 | void KToolBar::setIconSize(int size, bool update) |
989 | { | 989 | { |
990 | bool doUpdate=false; | 990 | bool doUpdate=false; |
991 | 991 | ||
992 | if ( size != d->m_iconSize ) { | 992 | if ( size != d->m_iconSize ) { |
993 | d->m_iconSize = size; | 993 | d->m_iconSize = size; |
994 | doUpdate=true; | 994 | doUpdate=true; |
995 | } | 995 | } |
996 | 996 | ||
997 | if (update == false) | 997 | if (update == false) |
998 | return; | 998 | return; |
999 | 999 | ||
1000 | if (doUpdate) | 1000 | if (doUpdate) |
1001 | emit modechange(); // tell buttons what happened | 1001 | emit modechange(); // tell buttons what happened |
1002 | 1002 | ||
1003 | // ugly hack to force a QMainWindow::triggerLayout( TRUE ) | 1003 | // ugly hack to force a QMainWindow::triggerLayout( TRUE ) |
1004 | if ( mainWindow() ) { | 1004 | if ( mainWindow() ) { |
1005 | QMainWindow *mw = mainWindow(); | 1005 | QMainWindow *mw = mainWindow(); |
1006 | mw->setUpdatesEnabled( FALSE ); | 1006 | mw->setUpdatesEnabled( FALSE ); |
1007 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); | 1007 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); |
1008 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); | 1008 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); |
1009 | mw->setUpdatesEnabled( TRUE ); | 1009 | mw->setUpdatesEnabled( TRUE ); |
1010 | } | 1010 | } |
1011 | } | 1011 | } |
1012 | 1012 | ||
1013 | 1013 | ||
1014 | int KToolBar::iconSize() const | 1014 | int KToolBar::iconSize() const |
1015 | { | 1015 | { |
1016 | /*US | 1016 | /*US |
1017 | if ( !d->m_iconSize ) // default value? | 1017 | if ( !d->m_iconSize ) // default value? |
1018 | { | 1018 | { |
1019 | if (!::qstrcmp(QObject::name(), "mainToolBar")) | 1019 | if (!::qstrcmp(QObject::name(), "mainToolBar")) |
1020 | return KGlobal::iconLoader()->currentSize(KIcon::MainToolbar); | 1020 | return KGlobal::iconLoader()->currentSize(KIcon::MainToolbar); |
1021 | else | 1021 | else |
1022 | return KGlobal::iconLoader()->currentSize(KIcon::Toolbar); | 1022 | return KGlobal::iconLoader()->currentSize(KIcon::Toolbar); |
1023 | } | 1023 | } |
1024 | return d->m_iconSize; | 1024 | return d->m_iconSize; |
1025 | */ | 1025 | */ |
1026 | int ret = 18; | 1026 | int ret = 18; |
1027 | if ( QApplication::desktop()->width() > 320 ) | 1027 | if ( QApplication::desktop()->width() > 320 ) |
1028 | ret = 30; | 1028 | ret = 30; |
1029 | return ret; | 1029 | return ret; |
1030 | } | 1030 | } |
1031 | 1031 | ||
1032 | 1032 | ||
1033 | void KToolBar::setEnableContextMenu(bool enable ) | 1033 | void KToolBar::setEnableContextMenu(bool enable ) |
1034 | { | 1034 | { |
1035 | d->m_enableContext = enable; | 1035 | d->m_enableContext = enable; |
1036 | } | 1036 | } |
1037 | 1037 | ||
1038 | 1038 | ||
1039 | bool KToolBar::contextMenuEnabled() const | 1039 | bool KToolBar::contextMenuEnabled() const |
1040 | { | 1040 | { |
1041 | return d->m_enableContext; | 1041 | return d->m_enableContext; |
1042 | } | 1042 | } |
1043 | 1043 | ||
1044 | 1044 | ||
1045 | void KToolBar::setItemNoStyle(int id, bool no_style ) | 1045 | void KToolBar::setItemNoStyle(int id, bool no_style ) |
1046 | { | 1046 | { |
1047 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 1047 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
1048 | if ( it == id2widget.end() ) | 1048 | if ( it == id2widget.end() ) |
1049 | return; | 1049 | return; |
1050 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); | 1050 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); |
1051 | KToolBarButton * button = (KToolBarButton *)( *it ); | 1051 | KToolBarButton * button = (KToolBarButton *)( *it ); |
1052 | if (button) | 1052 | if (button) |
1053 | button->setNoStyle( no_style ); | 1053 | button->setNoStyle( no_style ); |
1054 | } | 1054 | } |
1055 | 1055 | ||
1056 | 1056 | ||
1057 | void KToolBar::setFlat (bool flag) | 1057 | void KToolBar::setFlat (bool flag) |
1058 | { | 1058 | { |
1059 | if ( !mainWindow() ) | 1059 | if ( !mainWindow() ) |
1060 | return; | 1060 | return; |
1061 | if ( flag ) | 1061 | if ( flag ) |
1062 | //US mainWindow()->moveDockWindow( this, DockMinimized ); | 1062 | //US mainWindow()->moveDockWindow( this, DockMinimized ); |
1063 | mainWindow()->moveToolBar( this, QMainWindow::Minimized ); | 1063 | mainWindow()->moveToolBar( this, QMainWindow::Minimized ); |
1064 | else | 1064 | else |
1065 | //US mainWindow()->moveDockWindow( this, DockTop ); | 1065 | //US mainWindow()->moveDockWindow( this, DockTop ); |
1066 | mainWindow()->moveToolBar( this, QMainWindow::Top ); | 1066 | mainWindow()->moveToolBar( this, QMainWindow::Top ); |
1067 | // And remember to save the new look later | 1067 | // And remember to save the new look later |
1068 | /*US | 1068 | /*US |
1069 | if ( mainWindow()->inherits( "KMainWindow" ) ) | 1069 | if ( mainWindow()->inherits( "KMainWindow" ) ) |
1070 | static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); | 1070 | static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); |
1071 | */ | 1071 | */ |
1072 | } | 1072 | } |
1073 | 1073 | ||
1074 | 1074 | ||
1075 | int KToolBar::count() const | 1075 | int KToolBar::count() const |
1076 | { | 1076 | { |
1077 | return id2widget.count(); | 1077 | return id2widget.count(); |
1078 | } | 1078 | } |
1079 | 1079 | ||
1080 | 1080 | ||
1081 | void KToolBar::saveState() | 1081 | void KToolBar::saveState() |
1082 | { | 1082 | { |
1083 | /*US | 1083 | /*US |
1084 | // first, try to save to the xml file | 1084 | // first, try to save to the xml file |
1085 | if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() ) { | 1085 | if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() ) { |
1086 | // go down one level to get to the right tags | 1086 | // go down one level to get to the right tags |
1087 | QDomElement elem = d->m_xmlguiClient->domDocument().documentElement().toElement(); | 1087 | QDomElement elem = d->m_xmlguiClient->domDocument().documentElement().toElement(); |
1088 | elem = elem.firstChild().toElement(); | 1088 | elem = elem.firstChild().toElement(); |
1089 | QString barname(!::qstrcmp(name(), "unnamed") ? "mainToolBar" : name()); | 1089 | QString barname(!::qstrcmp(name(), "unnamed") ? "mainToolBar" : name()); |
1090 | QDomElement current; | 1090 | QDomElement current; |
1091 | // now try to find our toolbar | 1091 | // now try to find our toolbar |
1092 | d->modified = false; | 1092 | d->modified = false; |
1093 | for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) { | 1093 | for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) { |
1094 | current = elem; | 1094 | current = elem; |
1095 | 1095 | ||
1096 | if ( current.tagName().lower() != "toolbar" ) | 1096 | if ( current.tagName().lower() != "toolbar" ) |
1097 | continue; | 1097 | continue; |
1098 | 1098 | ||
1099 | QString curname(current.attribute( "name" )); | 1099 | QString curname(current.attribute( "name" )); |
1100 | 1100 | ||
1101 | if ( curname == barname ) { | 1101 | if ( curname == barname ) { |
1102 | saveState( current ); | 1102 | saveState( current ); |
1103 | break; | 1103 | break; |
1104 | } | 1104 | } |
1105 | } | 1105 | } |
1106 | // if we didn't make changes, then just return | 1106 | // if we didn't make changes, then just return |
1107 | if ( !d->modified ) | 1107 | if ( !d->modified ) |
1108 | return; | 1108 | return; |
1109 | 1109 | ||
1110 | // now we load in the (non-merged) local file | 1110 | // now we load in the (non-merged) local file |
1111 | QString local_xml(KXMLGUIFactory::readConfigFile(d->m_xmlguiClient->xmlFile(), true, d->m_xmlguiClient->instance())); | 1111 | QString local_xml(KXMLGUIFactory::readConfigFile(d->m_xmlguiClient->xmlFile(), true, d->m_xmlguiClient->instance())); |
1112 | QDomDocument local; | 1112 | QDomDocument local; |
1113 | local.setContent(local_xml); | 1113 | local.setContent(local_xml); |
1114 | 1114 | ||
1115 | // make sure we don't append if this toolbar already exists locally | 1115 | // make sure we don't append if this toolbar already exists locally |
1116 | bool just_append = true; | 1116 | bool just_append = true; |
1117 | elem = local.documentElement().toElement(); | 1117 | elem = local.documentElement().toElement(); |
1118 | KXMLGUIFactory::removeDOMComments( elem ); | 1118 | KXMLGUIFactory::removeDOMComments( elem ); |
1119 | elem = elem.firstChild().toElement(); | 1119 | elem = elem.firstChild().toElement(); |
1120 | for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) { | 1120 | for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) { |
1121 | if ( elem.tagName().lower() != "toolbar" ) | 1121 | if ( elem.tagName().lower() != "toolbar" ) |
1122 | continue; | 1122 | continue; |
1123 | 1123 | ||
1124 | QString curname(elem.attribute( "name" )); | 1124 | QString curname(elem.attribute( "name" )); |
1125 | 1125 | ||
1126 | if ( curname == barname ) { | 1126 | if ( curname == barname ) { |
1127 | just_append = false; | 1127 | just_append = false; |
1128 | local.documentElement().replaceChild( current, elem ); | 1128 | local.documentElement().replaceChild( current, elem ); |
1129 | break; | 1129 | break; |
1130 | } | 1130 | } |
1131 | } | 1131 | } |
1132 | 1132 | ||
1133 | if (just_append) | 1133 | if (just_append) |
1134 | local.documentElement().appendChild( current ); | 1134 | local.documentElement().appendChild( current ); |
1135 | 1135 | ||
1136 | KXMLGUIFactory::saveConfigFile(local, d->m_xmlguiClient->localXMLFile(), d->m_xmlguiClient->instance() ); | 1136 | KXMLGUIFactory::saveConfigFile(local, d->m_xmlguiClient->localXMLFile(), d->m_xmlguiClient->instance() ); |
1137 | 1137 | ||
1138 | return; | 1138 | return; |
1139 | } | 1139 | } |
1140 | */ | 1140 | */ |
1141 | // if that didn't work, we save to the config file | 1141 | // if that didn't work, we save to the config file |
1142 | KConfig *config = KGlobal::config(); | 1142 | KConfig *config = KGlobal::config(); |
1143 | saveSettings(config, QString::null); | 1143 | saveSettings(config, QString::null); |
1144 | config->sync(); | 1144 | config->sync(); |
1145 | } | 1145 | } |
1146 | 1146 | ||
1147 | QString KToolBar::settingsGroup() | 1147 | QString KToolBar::settingsGroup() |
1148 | { | 1148 | { |
1149 | QString configGroup; | 1149 | QString configGroup; |
1150 | if (!::qstrcmp(name(), "unnamed") || !::qstrcmp(name(), "mainToolBar")) | 1150 | if (!::qstrcmp(name(), "unnamed") || !::qstrcmp(name(), "mainToolBar")) |
1151 | configGroup = "Toolbar style"; | 1151 | configGroup = "Toolbar style"; |
1152 | else | 1152 | else |
1153 | configGroup = QString(name()) + " Toolbar style"; | 1153 | configGroup = QString(name()) + " Toolbar style"; |
1154 | if ( this->mainWindow() ) | 1154 | if ( this->mainWindow() ) |
1155 | { | 1155 | { |
1156 | configGroup.prepend(" "); | 1156 | configGroup.prepend(" "); |
1157 | configGroup.prepend( this->mainWindow()->name() ); | 1157 | configGroup.prepend( this->mainWindow()->name() ); |
1158 | } | 1158 | } |
1159 | return configGroup; | 1159 | return configGroup; |
1160 | } | 1160 | } |
1161 | 1161 | ||
1162 | void KToolBar::saveSettings(KConfig *config, const QString &_configGroup) | 1162 | void KToolBar::saveSettings(KConfig *config, const QString &_configGroup) |
1163 | { | 1163 | { |
1164 | QString configGroup = _configGroup; | 1164 | QString configGroup = _configGroup; |
1165 | if (configGroup.isEmpty()) | 1165 | if (configGroup.isEmpty()) |
1166 | configGroup = settingsGroup(); | 1166 | configGroup = settingsGroup(); |
1167 | //kdDebug(220) << "KToolBar::saveSettings group=" << _configGroup << " -> " << configGroup << endl; | 1167 | //kdDebug(220) << "KToolBar::saveSettings group=" << _configGroup << " -> " << configGroup << endl; |
1168 | 1168 | ||
1169 | QString position, icontext; | 1169 | QString position, icontext; |
1170 | int index; | 1170 | int index; |
1171 | getAttributes( position, icontext, index ); | 1171 | getAttributes( position, icontext, index ); |
1172 | 1172 | ||
1173 | //kdDebug(220) << "KToolBar::saveSettings " << name() << " newLine=" << newLine << endl; | 1173 | //kdDebug(220) << "KToolBar::saveSettings " << name() << " newLine=" << newLine << endl; |
1174 | 1174 | ||
1175 | KConfigGroupSaver saver(config, configGroup); | 1175 | KConfigGroupSaver saver(config, configGroup); |
1176 | 1176 | ||
1177 | if ( position != d->PositionDefault ) | 1177 | if ( position != d->PositionDefault ) |
1178 | config->writeEntry("Position", position); | 1178 | config->writeEntry("Position", position); |
1179 | else | 1179 | else |
1180 | config->deleteEntry("Position"); | 1180 | config->deleteEntry("Position"); |
1181 | 1181 | ||
1182 | if ( icontext != d->IconTextDefault ) | 1182 | if ( icontext != d->IconTextDefault ) |
1183 | config->writeEntry("IconText", icontext); | 1183 | config->writeEntry("IconText", icontext); |
1184 | else | 1184 | else |
1185 | config->deleteEntry("IconText"); | 1185 | config->deleteEntry("IconText"); |
1186 | 1186 | ||
1187 | if ( iconSize() != d->IconSizeDefault ) | 1187 | if ( iconSize() != d->IconSizeDefault ) |
1188 | config->writeEntry("IconSize", iconSize()); | 1188 | config->writeEntry("IconSize", iconSize()); |
1189 | else | 1189 | else |
1190 | config->deleteEntry("IconSize"); | 1190 | config->deleteEntry("IconSize"); |
1191 | 1191 | ||
1192 | if ( isHidden() != d->HiddenDefault ) | 1192 | if ( isHidden() != d->HiddenDefault ) |
1193 | config->writeEntry("Hidden", isHidden()); | 1193 | config->writeEntry("Hidden", isHidden()); |
1194 | else | 1194 | else |
1195 | config->deleteEntry("Hidden"); | 1195 | config->deleteEntry("Hidden"); |
1196 | 1196 | ||
1197 | if ( index != d->IndexDefault ) | 1197 | if ( index != d->IndexDefault ) |
1198 | config->writeEntry( "Index", index ); | 1198 | config->writeEntry( "Index", index ); |
1199 | else | 1199 | else |
1200 | config->deleteEntry("Index"); | 1200 | config->deleteEntry("Index"); |
1201 | //US the older version of KDE (used on the Zaurus) has no Offset property | 1201 | //US the older version of KDE (used on the Zaurus) has no Offset property |
1202 | /* if ( offset() != d->OffsetDefault ) | 1202 | /* if ( offset() != d->OffsetDefault ) |
1203 | config->writeEntry( "Offset", offset() ); | 1203 | config->writeEntry( "Offset", offset() ); |
1204 | else | 1204 | else |
1205 | */ | 1205 | */ |
1206 | config->deleteEntry("Offset"); | 1206 | config->deleteEntry("Offset"); |
1207 | 1207 | ||
1208 | //US the older version of KDE (used on the Zaurus) has no NewLine property | 1208 | //US the older version of KDE (used on the Zaurus) has no NewLine property |
1209 | /* | 1209 | /* |
1210 | if ( newLine() != d->NewLineDefault ) | 1210 | if ( newLine() != d->NewLineDefault ) |
1211 | config->writeEntry( "NewLine", newLine() ); | 1211 | config->writeEntry( "NewLine", newLine() ); |
1212 | else | 1212 | else |
1213 | */ | 1213 | */ |
1214 | config->deleteEntry("NewLine"); | 1214 | config->deleteEntry("NewLine"); |
1215 | } | 1215 | } |
1216 | 1216 | ||
1217 | void KToolBar::setXMLGUIClient( KXMLGUIClient *client ) | 1217 | void KToolBar::setXMLGUIClient( KXMLGUIClient *client ) |
1218 | { | 1218 | { |
1219 | d->m_xmlguiClient = client; | 1219 | d->m_xmlguiClient = client; |
1220 | } | 1220 | } |
1221 | 1221 | ||
1222 | void KToolBar::setText( const QString & txt ) | 1222 | void KToolBar::setText( const QString & txt ) |
1223 | { | 1223 | { |
1224 | //US setLabel( txt + " ( " + kapp->caption() + " ) " ); | 1224 | //US setLabel( txt + " ( " + kapp->caption() + " ) " ); |
1225 | setLabel( txt + " ( " + KGlobal::getAppName() + " ) " ); | 1225 | setLabel( txt + " ( " + KGlobal::getAppName() + " ) " ); |
1226 | } | 1226 | } |
1227 | 1227 | ||
1228 | 1228 | ||
1229 | QString KToolBar::text() const | 1229 | QString KToolBar::text() const |
1230 | { | 1230 | { |
1231 | return label(); | 1231 | return label(); |
1232 | } | 1232 | } |
1233 | 1233 | ||
1234 | 1234 | ||
1235 | void KToolBar::doConnections( KToolBarButton *button ) | 1235 | void KToolBar::doConnections( KToolBarButton *button ) |
1236 | { | 1236 | { |
1237 | connect(button, SIGNAL(clicked(int)), this, SIGNAL( clicked( int ) ) ); | 1237 | connect(button, SIGNAL(clicked(int)), this, SIGNAL( clicked( int ) ) ); |
1238 | connect(button, SIGNAL(doubleClicked(int)), this, SIGNAL( doubleClicked( int ) ) ); | 1238 | connect(button, SIGNAL(doubleClicked(int)), this, SIGNAL( doubleClicked( int ) ) ); |
1239 | connect(button, SIGNAL(released(int)), this, SIGNAL( released( int ) ) ); | 1239 | connect(button, SIGNAL(released(int)), this, SIGNAL( released( int ) ) ); |
1240 | connect(button, SIGNAL(pressed(int)), this, SIGNAL( pressed( int ) ) ); | 1240 | connect(button, SIGNAL(pressed(int)), this, SIGNAL( pressed( int ) ) ); |
1241 | connect(button, SIGNAL(toggled(int)), this, SIGNAL( toggled( int ) ) ); | 1241 | connect(button, SIGNAL(toggled(int)), this, SIGNAL( toggled( int ) ) ); |
1242 | connect(button, SIGNAL(highlighted(int, bool)), this, SIGNAL( highlighted( int, bool ) ) ); | 1242 | connect(button, SIGNAL(highlighted(int, bool)), this, SIGNAL( highlighted( int, bool ) ) ); |
1243 | } | 1243 | } |
1244 | 1244 | ||
1245 | void KToolBar::mousePressEvent ( QMouseEvent *m ) | 1245 | void KToolBar::mousePressEvent ( QMouseEvent *m ) |
1246 | { | 1246 | { |
1247 | if ( !mainWindow() ) | 1247 | if ( !mainWindow() ) |
1248 | return; | 1248 | return; |
1249 | QMainWindow *mw = mainWindow(); | 1249 | QMainWindow *mw = mainWindow(); |
1250 | if ( mw->toolBarsMovable() && d->m_enableContext ) { | 1250 | if ( mw->toolBarsMovable() && d->m_enableContext ) { |
1251 | if ( m->button() == RightButton ) { | 1251 | if ( m->button() == RightButton ) { |
1252 | int i = contextMenu()->exec( m->globalPos(), 0 ); | 1252 | int i = contextMenu()->exec( m->globalPos(), 0 ); |
1253 | switch ( i ) { | 1253 | switch ( i ) { |
1254 | case -1: | 1254 | case -1: |
1255 | return; // popup cancelled | 1255 | return; // popup cancelled |
1256 | case CONTEXT_LEFT: | 1256 | case CONTEXT_LEFT: |
1257 | //US mw->moveDockWindow( this, DockLeft ); | 1257 | //US mw->moveDockWindow( this, DockLeft ); |
1258 | mw->moveToolBar( this, QMainWindow::Left ); | 1258 | mw->moveToolBar( this, QMainWindow::Left ); |
1259 | break; | 1259 | break; |
1260 | case CONTEXT_RIGHT: | 1260 | case CONTEXT_RIGHT: |
1261 | //US mw->moveDockWindow( this, DockRight ); | 1261 | //US mw->moveDockWindow( this, DockRight ); |
1262 | mw->moveToolBar( this, QMainWindow::Right ); | 1262 | mw->moveToolBar( this, QMainWindow::Right ); |
1263 | break; | 1263 | break; |
1264 | case CONTEXT_TOP: | 1264 | case CONTEXT_TOP: |
1265 | //US mw->moveDockWindow( this, DockTop ); | 1265 | //US mw->moveDockWindow( this, DockTop ); |
1266 | mw->moveToolBar( this, QMainWindow::Top ); | 1266 | mw->moveToolBar( this, QMainWindow::Top ); |
1267 | break; | 1267 | break; |
1268 | case CONTEXT_BOTTOM: | 1268 | case CONTEXT_BOTTOM: |
1269 | //US mw->moveDockWindow( this, DockBottom ); | 1269 | //US mw->moveDockWindow( this, DockBottom ); |
1270 | mw->moveToolBar( this, QMainWindow::Bottom ); | 1270 | mw->moveToolBar( this, QMainWindow::Bottom ); |
1271 | break; | 1271 | break; |
1272 | case CONTEXT_FLOAT: | 1272 | case CONTEXT_FLOAT: |
1273 | break; | 1273 | break; |
1274 | case CONTEXT_FLAT: | 1274 | case CONTEXT_FLAT: |
1275 | //US mw->moveDockWindow( this, DockMinimized ); | 1275 | //US mw->moveDockWindow( this, DockMinimized ); |
1276 | mw->moveToolBar( this, QMainWindow::Minimized ); | 1276 | mw->moveToolBar( this, QMainWindow::Minimized ); |
1277 | break; | 1277 | break; |
1278 | case CONTEXT_ICONS: | 1278 | case CONTEXT_ICONS: |
1279 | setIconText( IconOnly ); | 1279 | setIconText( IconOnly ); |
1280 | break; | 1280 | break; |
1281 | case CONTEXT_TEXTRIGHT: | 1281 | case CONTEXT_TEXTRIGHT: |
1282 | setIconText( IconTextRight ); | 1282 | setIconText( IconTextRight ); |
1283 | break; | 1283 | break; |
1284 | case CONTEXT_TEXT: | 1284 | case CONTEXT_TEXT: |
1285 | setIconText( TextOnly ); | 1285 | setIconText( TextOnly ); |
1286 | break; | 1286 | break; |
1287 | case CONTEXT_TEXTUNDER: | 1287 | case CONTEXT_TEXTUNDER: |
1288 | setIconText( IconTextBottom ); | 1288 | setIconText( IconTextBottom ); |
1289 | break; | 1289 | break; |
1290 | default: | 1290 | default: |
1291 | if ( i >= CONTEXT_ICONSIZES ) | 1291 | if ( i >= CONTEXT_ICONSIZES ) |
1292 | setIconSize( i - CONTEXT_ICONSIZES ); | 1292 | setIconSize( i - CONTEXT_ICONSIZES ); |
1293 | else | 1293 | else |
1294 | return; // assume this was an action handled elsewhere, no need for setSettingsDirty() | 1294 | return; // assume this was an action handled elsewhere, no need for setSettingsDirty() |
1295 | } | 1295 | } |
1296 | /*US | 1296 | /*US |
1297 | if ( mw->inherits("KMainWindow") ) | 1297 | if ( mw->inherits("KMainWindow") ) |
1298 | static_cast<KMainWindow *>(mw)->setSettingsDirty(); | 1298 | static_cast<KMainWindow *>(mw)->setSettingsDirty(); |
1299 | */ | 1299 | */ |
1300 | } | 1300 | } |
1301 | } | 1301 | } |
1302 | } | 1302 | } |
1303 | 1303 | ||
1304 | 1304 | ||
1305 | void KToolBar::rebuildLayout() | 1305 | void KToolBar::rebuildLayout() |
1306 | { | 1306 | { |
1307 | 1307 | ||
1308 | for(QWidget *w=d->idleButtons.first(); w; w=d->idleButtons.next()) | 1308 | for(QWidget *w=d->idleButtons.first(); w; w=d->idleButtons.next()) |
1309 | w->blockSignals(false); | 1309 | w->blockSignals(false); |
1310 | d->idleButtons.clear(); | 1310 | d->idleButtons.clear(); |
1311 | 1311 | ||
1312 | layoutTimer->stop(); | 1312 | layoutTimer->stop(); |
1313 | QApplication::sendPostedEvents( this, QEvent::ChildInserted ); | 1313 | QApplication::sendPostedEvents( this, QEvent::ChildInserted ); |
1314 | QBoxLayout *l = boxLayout(); | 1314 | QBoxLayout *l = boxLayout(); |
1315 | l->setMargin( 1 ); | 1315 | l->setMargin( 1 ); |
1316 | // clear the old layout | 1316 | // clear the old layout |
1317 | QLayoutIterator it = l->iterator(); | 1317 | QLayoutIterator it = l->iterator(); |
1318 | 1318 | ||
1319 | while ( it.current() ) { | 1319 | while ( it.current() ) { |
1320 | it.deleteCurrent(); | 1320 | it.deleteCurrent(); |
1321 | } | 1321 | } |
1322 | for ( QWidget *w = widgets.first(); w; w = widgets.next() ) { | 1322 | for ( QWidget *w = widgets.first(); w; w = widgets.next() ) { |
1323 | if ( w == rightAligned ) { | 1323 | if ( w == rightAligned ) { |
1324 | continue; | 1324 | continue; |
1325 | } | 1325 | } |
1326 | if ( w->inherits( "KToolBarSeparator" ) && | 1326 | if ( w->inherits( "KToolBarSeparator" ) && |
1327 | !( (KToolBarSeparator*)w )->showLine() ) { | 1327 | !( (KToolBarSeparator*)w )->showLine() ) { |
1328 | l->addSpacing( 6 ); | 1328 | l->addSpacing( 6 ); |
1329 | w->hide(); | 1329 | w->hide(); |
1330 | continue; | 1330 | continue; |
1331 | } | 1331 | } |
1332 | if ( w->inherits( "QPopupMenu" ) ) | 1332 | if ( w->inherits( "QPopupMenu" ) ) |
1333 | continue; | 1333 | continue; |
1334 | l->addWidget( w ); | 1334 | l->addWidget( w ); |
1335 | w->show(); | 1335 | w->show(); |
1336 | } | 1336 | } |
1337 | if ( rightAligned ) { | 1337 | if ( rightAligned ) { |
1338 | l->addStretch(); | 1338 | l->addStretch(); |
1339 | l->addWidget( rightAligned ); | 1339 | l->addWidget( rightAligned ); |
1340 | rightAligned->show(); | 1340 | rightAligned->show(); |
1341 | } | 1341 | } |
1342 | 1342 | ||
1343 | if ( fullSize() ) { | 1343 | if ( fullSize() ) { |
1344 | // This code sucks. It makes the last combo in a toolbar VERY big (e.g. zoom combo in kword). | 1344 | // This code sucks. It makes the last combo in a toolbar VERY big (e.g. zoom combo in kword). |
1345 | //if ( !stretchableWidget && widgets.last() && | 1345 | //if ( !stretchableWidget && widgets.last() && |
1346 | // !widgets.last()->inherits( "QButton" ) && !widgets.last()->inherits( "KAnimWidget" ) ) | 1346 | // !widgets.last()->inherits( "QButton" ) && !widgets.last()->inherits( "KAnimWidget" ) ) |
1347 | // setStretchableWidget( widgets.last() ); | 1347 | // setStretchableWidget( widgets.last() ); |
1348 | if ( !rightAligned ) | 1348 | if ( !rightAligned ) |
1349 | l->addStretch(); | 1349 | l->addStretch(); |
1350 | if ( stretchableWidget ) | 1350 | if ( stretchableWidget ) |
1351 | l->setStretchFactor( stretchableWidget, 10 ); | 1351 | l->setStretchFactor( stretchableWidget, 10 ); |
1352 | } | 1352 | } |
1353 | l->invalidate(); | 1353 | l->invalidate(); |
1354 | QApplication::postEvent( this, new QEvent( QEvent::LayoutHint ) ); | 1354 | QApplication::postEvent( this, new QEvent( QEvent::LayoutHint ) ); |
1355 | //#endif //DESKTOP_VERSION | 1355 | //#endif //DESKTOP_VERSION |
1356 | } | 1356 | } |
1357 | 1357 | ||
1358 | void KToolBar::childEvent( QChildEvent *e ) | 1358 | void KToolBar::childEvent( QChildEvent *e ) |
1359 | { | 1359 | { |
1360 | 1360 | ||
1361 | if ( e->child()->isWidgetType() ) { | 1361 | if ( e->child()->isWidgetType() ) { |
1362 | QWidget * w = (QWidget*)e->child(); | 1362 | QWidget * w = (QWidget*)e->child(); |
1363 | if ( e->type() == QEvent::ChildInserted ) { | 1363 | if ( e->type() == QEvent::ChildInserted ) { |
1364 | if ( !e->child()->inherits( "QPopupMenu" ) && | 1364 | if ( !e->child()->inherits( "QPopupMenu" ) && |
1365 | ::qstrcmp( "qt_dockwidget_internal", e->child()->name() ) != 0 ) { | 1365 | ::qstrcmp( "qt_dockwidget_internal", e->child()->name() ) != 0 ) { |
1366 | 1366 | ||
1367 | // prevent items that have been explicitly inserted by insert*() from | 1367 | // prevent items that have been explicitly inserted by insert*() from |
1368 | // being inserted again | 1368 | // being inserted again |
1369 | if ( !widget2id.contains( w ) ) | 1369 | if ( !widget2id.contains( w ) ) |
1370 | { | 1370 | { |
1371 | int dummy = -1; | 1371 | int dummy = -1; |
1372 | insertWidgetInternal( w, dummy, -1 ); | 1372 | insertWidgetInternal( w, dummy, -1 ); |
1373 | } | 1373 | } |
1374 | } | 1374 | } |
1375 | } else { | 1375 | } else { |
1376 | removeWidgetInternal( w ); | 1376 | removeWidgetInternal( w ); |
1377 | } | 1377 | } |
1378 | if ( isVisibleTo( 0 ) ) | 1378 | if ( isVisibleTo( 0 ) ) |
1379 | { | 1379 | { |
1380 | QBoxLayout *l = boxLayout(); | 1380 | QBoxLayout *l = boxLayout(); |
1381 | // QLayout *l = layout(); | 1381 | // QLayout *l = layout(); |
1382 | 1382 | ||
1383 | // clear the old layout so that we don't get unnecassery layout | 1383 | // clear the old layout so that we don't get unnecassery layout |
1384 | // changes till we have rebuild the thing | 1384 | // changes till we have rebuild the thing |
1385 | QLayoutIterator it = l->iterator(); | 1385 | QLayoutIterator it = l->iterator(); |
1386 | while ( it.current() ) { | 1386 | while ( it.current() ) { |
1387 | it.deleteCurrent(); | 1387 | it.deleteCurrent(); |
1388 | } | 1388 | } |
1389 | layoutTimer->start( 50, TRUE ); | 1389 | layoutTimer->start( 50, TRUE ); |
1390 | } | 1390 | } |
1391 | } | 1391 | } |
1392 | QToolBar::childEvent( e ); | 1392 | QToolBar::childEvent( e ); |
1393 | } | 1393 | } |
1394 | 1394 | ||
1395 | void KToolBar::insertWidgetInternal( QWidget *w, int &index, int id ) | 1395 | void KToolBar::insertWidgetInternal( QWidget *w, int &index, int id ) |
1396 | { | 1396 | { |
1397 | // we can't have it in widgets, or something is really wrong | 1397 | // we can't have it in widgets, or something is really wrong |
1398 | //widgets.removeRef( w ); | 1398 | //widgets.removeRef( w ); |
1399 | 1399 | ||
1400 | connect( w, SIGNAL( destroyed() ), | 1400 | connect( w, SIGNAL( destroyed() ), |
1401 | this, SLOT( widgetDestroyed() ) ); | 1401 | this, SLOT( widgetDestroyed() ) ); |
1402 | if ( index == -1 || index > (int)widgets.count() ) { | 1402 | if ( index == -1 || index > (int)widgets.count() ) { |
1403 | widgets.append( w ); | 1403 | widgets.append( w ); |
1404 | index = (int)widgets.count(); | 1404 | index = (int)widgets.count(); |
1405 | } | 1405 | } |
1406 | else | 1406 | else |
1407 | widgets.insert( index, w ); | 1407 | widgets.insert( index, w ); |
1408 | if ( id == -1 ) | 1408 | if ( id == -1 ) |
1409 | id = id2widget.count(); | 1409 | id = id2widget.count(); |
1410 | id2widget.insert( id, w ); | 1410 | id2widget.insert( id, w ); |
1411 | widget2id.insert( w, id ); | 1411 | widget2id.insert( w, id ); |
1412 | } | 1412 | } |
1413 | void KToolBar::repaintMe() | ||
1414 | { | ||
1415 | setUpdatesEnabled( true ); | ||
1416 | QToolBar::repaint( true ); | ||
1417 | qDebug(" KToolBar::repaintMe() "); | ||
1418 | } | ||
1413 | 1419 | ||
1414 | void KToolBar::showEvent( QShowEvent *e ) | 1420 | void KToolBar::showEvent( QShowEvent *e ) |
1415 | { | 1421 | { |
1416 | QToolBar::showEvent( e ); | 1422 | QToolBar::showEvent( e ); |
1417 | rebuildLayout(); | 1423 | rebuildLayout(); |
1418 | } | 1424 | } |
1419 | 1425 | ||
1420 | void KToolBar::setStretchableWidget( QWidget *w ) | 1426 | void KToolBar::setStretchableWidget( QWidget *w ) |
1421 | { | 1427 | { |
1422 | QToolBar::setStretchableWidget( w ); | 1428 | QToolBar::setStretchableWidget( w ); |
1423 | stretchableWidget = w; | 1429 | stretchableWidget = w; |
1424 | } | 1430 | } |
1425 | 1431 | ||
1426 | QSizePolicy KToolBar::sizePolicy() const | 1432 | QSizePolicy KToolBar::sizePolicy() const |
1427 | { | 1433 | { |
1428 | if ( orientation() == Horizontal ) | 1434 | if ( orientation() == Horizontal ) |
1429 | return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); | 1435 | return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); |
1430 | else | 1436 | else |
1431 | return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ); | 1437 | return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ); |
1432 | } | 1438 | } |
1433 | 1439 | ||
1434 | QSize KToolBar::sizeHint() const | 1440 | QSize KToolBar::sizeHint() const |
1435 | { | 1441 | { |
1436 | return QToolBar::sizeHint(); | 1442 | return QToolBar::sizeHint(); |
1437 | #if 0 | 1443 | #if 0 |
1438 | QWidget::polish(); | 1444 | QWidget::polish(); |
1439 | static int iii = 0; | 1445 | static int iii = 0; |
1440 | ++iii; | 1446 | ++iii; |
1441 | qDebug("++++++++ KToolBar::sizeHint() %d ", iii ); | 1447 | qDebug("++++++++ KToolBar::sizeHint() %d ", iii ); |
1442 | int margin = static_cast<QWidget*>(ncThis)->layout()->margin(); | 1448 | int margin = static_cast<QWidget*>(ncThis)->layout()->margin(); |
1443 | switch( barPos() ) | 1449 | switch( barPos() ) |
1444 | { | 1450 | { |
1445 | case KToolBar::Top: | 1451 | case KToolBar::Top: |
1446 | case KToolBar::Bottom: | 1452 | case KToolBar::Bottom: |
1447 | for ( QWidget *w = widgets.first(); w; w =widgets.next() ) | 1453 | for ( QWidget *w = widgets.first(); w; w =widgets.next() ) |
1448 | { | 1454 | { |
1449 | if ( w->inherits( "KToolBarSeparator" ) && | 1455 | if ( w->inherits( "KToolBarSeparator" ) && |
1450 | !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) | 1456 | !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) |
1451 | { | 1457 | { |
1452 | minSize += QSize(6, 0); | 1458 | minSize += QSize(6, 0); |
1453 | } | 1459 | } |
1454 | else | 1460 | else |
1455 | { | 1461 | { |
1456 | QSize sh = w->sizeHint(); | 1462 | QSize sh = w->sizeHint(); |
1457 | if (!sh.isValid()) | 1463 | if (!sh.isValid()) |
1458 | sh = w->minimumSize(); | 1464 | sh = w->minimumSize(); |
1459 | minSize = minSize.expandedTo(QSize(0, sh.height())); | 1465 | minSize = minSize.expandedTo(QSize(0, sh.height())); |
1460 | minSize += QSize(sh.width()+1, 0); | 1466 | minSize += QSize(sh.width()+1, 0); |
1461 | } | 1467 | } |
1462 | } | 1468 | } |
1463 | /*US | 1469 | /*US |
1464 | minSize += QSize(QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ), 0); | 1470 | minSize += QSize(QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ), 0); |
1465 | */ | 1471 | */ |
1466 | minSize += QSize(margin*2, margin*2); | 1472 | minSize += QSize(margin*2, margin*2); |
1467 | break; | 1473 | break; |
1468 | 1474 | ||
1469 | case KToolBar::Left: | 1475 | case KToolBar::Left: |
1470 | case KToolBar::Right: | 1476 | case KToolBar::Right: |
1471 | for ( QWidget *w = widgets.first(); w; w = widgets.next() ) | 1477 | for ( QWidget *w = widgets.first(); w; w = widgets.next() ) |
1472 | { | 1478 | { |
1473 | if ( w->inherits( "KToolBarSeparator" ) && | 1479 | if ( w->inherits( "KToolBarSeparator" ) && |
1474 | !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) | 1480 | !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) |
1475 | { | 1481 | { |
1476 | minSize += QSize(0, 6); | 1482 | minSize += QSize(0, 6); |
1477 | } | 1483 | } |
1478 | else | 1484 | else |
1479 | { | 1485 | { |
1480 | QSize sh = w->sizeHint(); | 1486 | QSize sh = w->sizeHint(); |
1481 | if (!sh.isValid()) | 1487 | if (!sh.isValid()) |
1482 | sh = w->minimumSize(); | 1488 | sh = w->minimumSize(); |
1483 | minSize = minSize.expandedTo(QSize(sh.width(), 0)); | 1489 | minSize = minSize.expandedTo(QSize(sh.width(), 0)); |
1484 | minSize += QSize(0, sh.height()+1); | 1490 | minSize += QSize(0, sh.height()+1); |
1485 | } | 1491 | } |
1486 | } | 1492 | } |
1487 | /*US | 1493 | /*US |
1488 | minSize += QSize(0, QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent )); | 1494 | minSize += QSize(0, QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent )); |
1489 | */ | 1495 | */ |
1490 | minSize += QSize(margin*2, margin*2); | 1496 | minSize += QSize(margin*2, margin*2); |
1491 | break; | 1497 | break; |
1492 | 1498 | ||
1493 | default: | 1499 | default: |
1494 | minSize = QToolBar::sizeHint(); | 1500 | minSize = QToolBar::sizeHint(); |
1495 | break; | 1501 | break; |
1496 | } | 1502 | } |
1497 | return minSize; | 1503 | return minSize; |
1498 | #endif | 1504 | #endif |
1499 | } | 1505 | } |
1500 | 1506 | ||
1501 | QSize KToolBar::minimumSize() const | 1507 | QSize KToolBar::minimumSize() const |
1502 | { | 1508 | { |
1503 | return minimumSizeHint(); | 1509 | return minimumSizeHint(); |
1504 | } | 1510 | } |
1505 | 1511 | ||
1506 | QSize KToolBar::minimumSizeHint() const | 1512 | QSize KToolBar::minimumSizeHint() const |
1507 | { | 1513 | { |
1508 | return sizeHint(); | 1514 | return sizeHint(); |
1509 | } | 1515 | } |
1510 | 1516 | ||
1511 | bool KToolBar::highlight() const | 1517 | bool KToolBar::highlight() const |
1512 | { | 1518 | { |
1513 | return d->m_highlight; | 1519 | return d->m_highlight; |
1514 | } | 1520 | } |
1515 | 1521 | ||
1516 | void KToolBar::hide() | 1522 | void KToolBar::hide() |
1517 | { | 1523 | { |
1518 | QToolBar::hide(); | 1524 | QToolBar::hide(); |
1519 | } | 1525 | } |
1520 | 1526 | ||
1521 | void KToolBar::show() | 1527 | void KToolBar::show() |
1522 | { | 1528 | { |
1523 | QToolBar::show(); | 1529 | QToolBar::show(); |
1524 | } | 1530 | } |
1525 | 1531 | ||
1526 | void KToolBar::resizeEvent( QResizeEvent *e ) | 1532 | void KToolBar::resizeEvent( QResizeEvent *e ) |
1527 | { | 1533 | { |
1528 | bool b = isUpdatesEnabled(); | 1534 | bool b = isUpdatesEnabled(); |
1529 | setUpdatesEnabled( FALSE ); | 1535 | setUpdatesEnabled( FALSE ); |
1530 | QToolBar::resizeEvent( e ); | 1536 | QToolBar::resizeEvent( e ); |
1531 | if (b) | 1537 | if (b) |
1532 | d->repaintTimer.start( 100, true ); | 1538 | d->repaintTimer.start( 100, true ); |
1533 | } | 1539 | } |
1534 | 1540 | ||
1535 | void KToolBar::slotIconChanged(int group) | 1541 | void KToolBar::slotIconChanged(int group) |
1536 | { | 1542 | { |
1537 | if ((group != KIcon::Toolbar) && (group != KIcon::MainToolbar)) | 1543 | if ((group != KIcon::Toolbar) && (group != KIcon::MainToolbar)) |
1538 | return; | 1544 | return; |
1539 | if ((group == KIcon::MainToolbar) != !::qstrcmp(name(), "mainToolBar")) | 1545 | if ((group == KIcon::MainToolbar) != !::qstrcmp(name(), "mainToolBar")) |
1540 | return; | 1546 | return; |
1541 | 1547 | ||
1542 | emit modechange(); | 1548 | emit modechange(); |
1543 | if (isVisible()) | 1549 | if (isVisible()) |
1544 | updateGeometry(); | 1550 | updateGeometry(); |
1545 | } | 1551 | } |
1546 | 1552 | ||
1547 | void KToolBar::slotReadConfig() | 1553 | void KToolBar::slotReadConfig() |
1548 | { | 1554 | { |
1549 | //kdDebug(220) << "KToolBar::slotReadConfig" << endl; | 1555 | //kdDebug(220) << "KToolBar::slotReadConfig" << endl; |
1550 | // Read appearance settings (hmm, we used to do both here, | 1556 | // Read appearance settings (hmm, we used to do both here, |
1551 | // but a well behaved application will call applyMainWindowSettings | 1557 | // but a well behaved application will call applyMainWindowSettings |
1552 | // anyway, right ?) | 1558 | // anyway, right ?) |
1553 | applyAppearanceSettings(KGlobal::config(), QString::null ); | 1559 | applyAppearanceSettings(KGlobal::config(), QString::null ); |
1554 | } | 1560 | } |
1555 | 1561 | ||
1556 | void KToolBar::slotAppearanceChanged() | 1562 | void KToolBar::slotAppearanceChanged() |
1557 | { | 1563 | { |
1558 | // Read appearance settings from global file. | 1564 | // Read appearance settings from global file. |
1559 | applyAppearanceSettings(KGlobal::config(), QString::null, true /* lose local settings */ ); | 1565 | applyAppearanceSettings(KGlobal::config(), QString::null, true /* lose local settings */ ); |
1560 | // And remember to save the new look later | 1566 | // And remember to save the new look later |
1561 | /*US | 1567 | /*US |
1562 | if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) | 1568 | if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) |
1563 | static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); | 1569 | static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); |
1564 | */ | 1570 | */ |
1565 | } | 1571 | } |
1566 | 1572 | ||
1567 | //static | 1573 | //static |
1568 | bool KToolBar::highlightSetting() | 1574 | bool KToolBar::highlightSetting() |
1569 | { | 1575 | { |
1570 | QString grpToolbar(QString::fromLatin1("Toolbar style")); | 1576 | QString grpToolbar(QString::fromLatin1("Toolbar style")); |
1571 | KConfigGroupSaver saver(KGlobal::config(), grpToolbar); | 1577 | KConfigGroupSaver saver(KGlobal::config(), grpToolbar); |
1572 | return KGlobal::config()->readBoolEntry(QString::fromLatin1("Highlighting"),true); | 1578 | return KGlobal::config()->readBoolEntry(QString::fromLatin1("Highlighting"),true); |
1573 | } | 1579 | } |
1574 | 1580 | ||
1575 | //static | 1581 | //static |
1576 | bool KToolBar::transparentSetting() | 1582 | bool KToolBar::transparentSetting() |
1577 | { | 1583 | { |
1578 | QString grpToolbar(QString::fromLatin1("Toolbar style")); | 1584 | QString grpToolbar(QString::fromLatin1("Toolbar style")); |
1579 | KConfigGroupSaver saver(KGlobal::config(), grpToolbar); | 1585 | KConfigGroupSaver saver(KGlobal::config(), grpToolbar); |
1580 | return KGlobal::config()->readBoolEntry(QString::fromLatin1("TransparentMoving"),true); | 1586 | return KGlobal::config()->readBoolEntry(QString::fromLatin1("TransparentMoving"),true); |
1581 | } | 1587 | } |
1582 | 1588 | ||
1583 | //static | 1589 | //static |
1584 | KToolBar::IconText KToolBar::iconTextSetting() | 1590 | KToolBar::IconText KToolBar::iconTextSetting() |
1585 | { | 1591 | { |
1586 | QString grpToolbar(QString::fromLatin1("Toolbar style")); | 1592 | QString grpToolbar(QString::fromLatin1("Toolbar style")); |
1587 | KConfigGroupSaver saver(KGlobal::config(), grpToolbar); | 1593 | KConfigGroupSaver saver(KGlobal::config(), grpToolbar); |
1588 | QString icontext = KGlobal::config()->readEntry(QString::fromLatin1("IconText"),QString::fromLatin1("IconOnly")); | 1594 | QString icontext = KGlobal::config()->readEntry(QString::fromLatin1("IconText"),QString::fromLatin1("IconOnly")); |
1589 | if ( icontext == "IconTextRight" ) | 1595 | if ( icontext == "IconTextRight" ) |
1590 | return IconTextRight; | 1596 | return IconTextRight; |
1591 | else if ( icontext == "IconTextBottom" ) | 1597 | else if ( icontext == "IconTextBottom" ) |
1592 | return IconTextBottom; | 1598 | return IconTextBottom; |
1593 | else if ( icontext == "TextOnly" ) | 1599 | else if ( icontext == "TextOnly" ) |
1594 | return TextOnly; | 1600 | return TextOnly; |
1595 | else | 1601 | else |
1596 | return IconOnly; | 1602 | return IconOnly; |
1597 | } | 1603 | } |
1598 | 1604 | ||
1599 | void KToolBar::applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal) | 1605 | void KToolBar::applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal) |
1600 | { | 1606 | { |
1601 | QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup; | 1607 | QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup; |
1602 | //kdDebug(220) << "KToolBar::applyAppearanceSettings: configGroup=" << configGroup << endl; | 1608 | //kdDebug(220) << "KToolBar::applyAppearanceSettings: configGroup=" << configGroup << endl; |
1603 | // We have application-specific settings in the XML file, | 1609 | // We have application-specific settings in the XML file, |
1604 | // and nothing in the application's config file | 1610 | // and nothing in the application's config file |
1605 | // -> don't apply the global defaults, the XML ones are preferred | 1611 | // -> don't apply the global defaults, the XML ones are preferred |
1606 | // See applySettings for a full explanation | 1612 | // See applySettings for a full explanation |
1607 | /*US :we do not support xml files | 1613 | /*US :we do not support xml files |
1608 | if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() && | 1614 | if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() && |
1609 | !config->hasGroup(configGroup) ) | 1615 | !config->hasGroup(configGroup) ) |
1610 | { | 1616 | { |
1611 | //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl; | 1617 | //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl; |
1612 | return; | 1618 | return; |
1613 | } | 1619 | } |
1614 | */ | 1620 | */ |
1615 | if ( !config->hasGroup(configGroup) ) | 1621 | if ( !config->hasGroup(configGroup) ) |
1616 | { | 1622 | { |
1617 | //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl; | 1623 | //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl; |
1618 | return; | 1624 | return; |
1619 | } | 1625 | } |
1620 | 1626 | ||
1621 | 1627 | ||
1622 | KConfig *gconfig = KGlobal::config(); | 1628 | KConfig *gconfig = KGlobal::config(); |
1623 | /*US | 1629 | /*US |
1624 | static const QString &attrIconText = KGlobal::staticQString("IconText"); | 1630 | static const QString &attrIconText = KGlobal::staticQString("IconText"); |
1625 | static const QString &attrHighlight = KGlobal::staticQString("Highlighting"); | 1631 | static const QString &attrHighlight = KGlobal::staticQString("Highlighting"); |
1626 | static const QString &attrTrans = KGlobal::staticQString("TransparentMoving"); | 1632 | static const QString &attrTrans = KGlobal::staticQString("TransparentMoving"); |
1627 | static const QString &attrSize = KGlobal::staticQString("IconSize"); | 1633 | static const QString &attrSize = KGlobal::staticQString("IconSize"); |
1628 | */ | 1634 | */ |
1629 | // we actually do this in two steps. | 1635 | // we actually do this in two steps. |
1630 | // First, we read in the global styles [Toolbar style] (from the KControl module). | 1636 | // First, we read in the global styles [Toolbar style] (from the KControl module). |
1631 | // Then, if the toolbar is NOT 'mainToolBar', we will also try to read in [barname Toolbar style] | 1637 | // Then, if the toolbar is NOT 'mainToolBar', we will also try to read in [barname Toolbar style] |
1632 | bool highlight; | 1638 | bool highlight; |
1633 | int transparent; | 1639 | int transparent; |
1634 | QString icontext; | 1640 | QString icontext; |
1635 | int iconsize = 0; | 1641 | int iconsize = 0; |
1636 | 1642 | ||
1637 | // this is the first iteration | 1643 | // this is the first iteration |
1638 | QString grpToolbar(QString::fromLatin1("Toolbar style")); | 1644 | QString grpToolbar(QString::fromLatin1("Toolbar style")); |
1639 | { // start block for KConfigGroupSaver | 1645 | { // start block for KConfigGroupSaver |
1640 | KConfigGroupSaver saver(gconfig, grpToolbar); | 1646 | KConfigGroupSaver saver(gconfig, grpToolbar); |
1641 | 1647 | ||
1642 | // first, get the generic settings | 1648 | // first, get the generic settings |
1643 | //US highlight = gconfig->readBoolEntry(attrHighlight, true); | 1649 | //US highlight = gconfig->readBoolEntry(attrHighlight, true); |
1644 | highlight = gconfig->readBoolEntry("Highlighting", true); | 1650 | highlight = gconfig->readBoolEntry("Highlighting", true); |
1645 | //US transparent = gconfig->readBoolEntry(attrTrans, true); | 1651 | //US transparent = gconfig->readBoolEntry(attrTrans, true); |
1646 | transparent = gconfig->readBoolEntry("TransparentMoving", true); | 1652 | transparent = gconfig->readBoolEntry("TransparentMoving", true); |
1647 | 1653 | ||
1648 | // we read in the IconText property *only* if we intend on actually | 1654 | // we read in the IconText property *only* if we intend on actually |
1649 | // honoring it | 1655 | // honoring it |
1650 | if (d->m_honorStyle) | 1656 | if (d->m_honorStyle) |
1651 | //US d->IconTextDefault = gconfig->readEntry(attrIconText, d->IconTextDefault); | 1657 | //US d->IconTextDefault = gconfig->readEntry(attrIconText, d->IconTextDefault); |
1652 | d->IconTextDefault = gconfig->readEntry("IconText", d->IconTextDefault); | 1658 | d->IconTextDefault = gconfig->readEntry("IconText", d->IconTextDefault); |
1653 | else | 1659 | else |
1654 | d->IconTextDefault = "IconOnly"; | 1660 | d->IconTextDefault = "IconOnly"; |
1655 | 1661 | ||
1656 | // Use the default icon size for toolbar icons. | 1662 | // Use the default icon size for toolbar icons. |
1657 | //US d->IconSizeDefault = gconfig->readNumEntry(attrSize, d->IconSizeDefault); | 1663 | //US d->IconSizeDefault = gconfig->readNumEntry(attrSize, d->IconSizeDefault); |
1658 | d->IconSizeDefault = gconfig->readNumEntry("IconSize", d->IconSizeDefault); | 1664 | d->IconSizeDefault = gconfig->readNumEntry("IconSize", d->IconSizeDefault); |
1659 | 1665 | ||
1660 | if ( !forceGlobal && config->hasGroup(configGroup) ) | 1666 | if ( !forceGlobal && config->hasGroup(configGroup) ) |
1661 | { | 1667 | { |
1662 | config->setGroup(configGroup); | 1668 | config->setGroup(configGroup); |
1663 | 1669 | ||
1664 | // first, get the generic settings | 1670 | // first, get the generic settings |
1665 | //US highlight = config->readBoolEntry(attrHighlight, highlight); | 1671 | //US highlight = config->readBoolEntry(attrHighlight, highlight); |
1666 | highlight = config->readBoolEntry("Highlighting", highlight); | 1672 | highlight = config->readBoolEntry("Highlighting", highlight); |
1667 | //US transparent = config->readBoolEntry(attrTrans, transparent); | 1673 | //US transparent = config->readBoolEntry(attrTrans, transparent); |
1668 | transparent = config->readBoolEntry("TransparentMoving", transparent); | 1674 | transparent = config->readBoolEntry("TransparentMoving", transparent); |
1669 | // now we always read in the IconText property | 1675 | // now we always read in the IconText property |
1670 | //US icontext = config->readEntry(attrIconText, d->IconTextDefault); | 1676 | //US icontext = config->readEntry(attrIconText, d->IconTextDefault); |
1671 | icontext = config->readEntry("IconText", d->IconTextDefault); | 1677 | icontext = config->readEntry("IconText", d->IconTextDefault); |
1672 | 1678 | ||
1673 | // now get the size | 1679 | // now get the size |
1674 | //US iconsize = config->readNumEntry(attrSize, d->IconSizeDefault); | 1680 | //US iconsize = config->readNumEntry(attrSize, d->IconSizeDefault); |
1675 | iconsize = config->readNumEntry("IconSize", d->IconSizeDefault); | 1681 | iconsize = config->readNumEntry("IconSize", d->IconSizeDefault); |
1676 | } | 1682 | } |
1677 | else | 1683 | else |
1678 | { | 1684 | { |
1679 | iconsize = d->IconSizeDefault; | 1685 | iconsize = d->IconSizeDefault; |
1680 | icontext = d->IconTextDefault; | 1686 | icontext = d->IconTextDefault; |
1681 | } | 1687 | } |
1682 | 1688 | ||
1683 | // revert back to the old group | 1689 | // revert back to the old group |
1684 | } // end block for KConfigGroupSaver | 1690 | } // end block for KConfigGroupSaver |
1685 | 1691 | ||
1686 | bool doUpdate = false; | 1692 | bool doUpdate = false; |
1687 | 1693 | ||
1688 | IconText icon_text; | 1694 | IconText icon_text; |
1689 | if ( icontext == "IconTextRight" ) | 1695 | if ( icontext == "IconTextRight" ) |
1690 | icon_text = IconTextRight; | 1696 | icon_text = IconTextRight; |
1691 | else if ( icontext == "IconTextBottom" ) | 1697 | else if ( icontext == "IconTextBottom" ) |
1692 | icon_text = IconTextBottom; | 1698 | icon_text = IconTextBottom; |
1693 | else if ( icontext == "TextOnly" ) | 1699 | else if ( icontext == "TextOnly" ) |
1694 | icon_text = TextOnly; | 1700 | icon_text = TextOnly; |
1695 | else | 1701 | else |
1696 | icon_text = IconOnly; | 1702 | icon_text = IconOnly; |
1697 | 1703 | ||
1698 | // check if the icon/text has changed | 1704 | // check if the icon/text has changed |
1699 | if (icon_text != d->m_iconText) { | 1705 | if (icon_text != d->m_iconText) { |
1700 | //kdDebug(220) << "KToolBar::applyAppearanceSettings setIconText " << icon_text << endl; | 1706 | //kdDebug(220) << "KToolBar::applyAppearanceSettings setIconText " << icon_text << endl; |
1701 | setIconText(icon_text, false); | 1707 | setIconText(icon_text, false); |
1702 | doUpdate = true; | 1708 | doUpdate = true; |
1703 | } | 1709 | } |
1704 | 1710 | ||
1705 | // ...and check if the icon size has changed | 1711 | // ...and check if the icon size has changed |
1706 | if (iconsize != d->m_iconSize) { | 1712 | if (iconsize != d->m_iconSize) { |
1707 | setIconSize(iconsize, false); | 1713 | setIconSize(iconsize, false); |
1708 | doUpdate = true; | 1714 | doUpdate = true; |
1709 | } | 1715 | } |
1710 | 1716 | ||
1711 | QMainWindow *mw = mainWindow(); | 1717 | QMainWindow *mw = mainWindow(); |
1712 | 1718 | ||
1713 | // ...and if we should highlight | 1719 | // ...and if we should highlight |
1714 | if ( highlight != d->m_highlight ) { | 1720 | if ( highlight != d->m_highlight ) { |
1715 | d->m_highlight = highlight; | 1721 | d->m_highlight = highlight; |
1716 | doUpdate = true; | 1722 | doUpdate = true; |
1717 | } | 1723 | } |
1718 | 1724 | ||
1719 | // ...and if we should move transparently | 1725 | // ...and if we should move transparently |
1720 | if ( mw && transparent != (!mw->opaqueMoving()) ) { | 1726 | if ( mw && transparent != (!mw->opaqueMoving()) ) { |
1721 | mw->setOpaqueMoving( !transparent ); | 1727 | mw->setOpaqueMoving( !transparent ); |
1722 | } | 1728 | } |
1723 | 1729 | ||
1724 | if (doUpdate) | 1730 | if (doUpdate) |
1725 | emit modechange(); // tell buttons what happened | 1731 | emit modechange(); // tell buttons what happened |
1726 | if (isVisible ()) | 1732 | if (isVisible ()) |
1727 | updateGeometry(); | 1733 | updateGeometry(); |
1728 | } | 1734 | } |
1729 | 1735 | ||
1730 | void KToolBar::applySettings(KConfig *config, const QString &_configGroup) | 1736 | void KToolBar::applySettings(KConfig *config, const QString &_configGroup) |
1731 | { | 1737 | { |
1732 | //kdDebug(220) << "KToolBar::applySettings group=" << _configGroup << endl; | 1738 | //kdDebug(220) << "KToolBar::applySettings group=" << _configGroup << endl; |
1733 | 1739 | ||
1734 | QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup; | 1740 | QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup; |
1735 | 1741 | ||
1736 | /* | 1742 | /* |
1737 | Let's explain this a bit more in details. | 1743 | Let's explain this a bit more in details. |
1738 | The order in which we apply settings is : | 1744 | The order in which we apply settings is : |
1739 | Global config / <appnamerc> user settings if no XMLGUI is used | 1745 | Global config / <appnamerc> user settings if no XMLGUI is used |
1740 | Global config / App-XML attributes / <appnamerc> user settings if XMLGUI is used | 1746 | Global config / App-XML attributes / <appnamerc> user settings if XMLGUI is used |
1741 | 1747 | ||
1742 | So in the first case, we simply read everything from KConfig as below, | 1748 | So in the first case, we simply read everything from KConfig as below, |
1743 | but in the second case we don't do anything here if there is no app-specific config, | 1749 | but in the second case we don't do anything here if there is no app-specific config, |
1744 | and the XMLGUI uses the static methods of this class to get the global defaults. | 1750 | and the XMLGUI uses the static methods of this class to get the global defaults. |
1745 | 1751 | ||
1746 | Global config doesn't include position (index, offset, newline and hidden/shown). | 1752 | Global config doesn't include position (index, offset, newline and hidden/shown). |
1747 | */ | 1753 | */ |
1748 | 1754 | ||
1749 | // First the appearance stuff - the one which has a global config | 1755 | // First the appearance stuff - the one which has a global config |
1750 | applyAppearanceSettings( config, _configGroup ); | 1756 | applyAppearanceSettings( config, _configGroup ); |
1751 | 1757 | ||
1752 | // ...and now the position stuff | 1758 | // ...and now the position stuff |
1753 | if ( config->hasGroup(configGroup) ) | 1759 | if ( config->hasGroup(configGroup) ) |
1754 | { | 1760 | { |
1755 | KConfigGroupSaver cgs(config, configGroup); | 1761 | KConfigGroupSaver cgs(config, configGroup); |
1756 | /*US | 1762 | /*US |
1757 | static const QString &attrPosition = KGlobal::staticQString("Position"); | 1763 | static const QString &attrPosition = KGlobal::staticQString("Position"); |
1758 | static const QString &attrIndex = KGlobal::staticQString("Index"); | 1764 | static const QString &attrIndex = KGlobal::staticQString("Index"); |
1759 | static const QString &attrOffset = KGlobal::staticQString("Offset"); | 1765 | static const QString &attrOffset = KGlobal::staticQString("Offset"); |
1760 | static const QString &attrNewLine = KGlobal::staticQString("NewLine"); | 1766 | static const QString &attrNewLine = KGlobal::staticQString("NewLine"); |
1761 | static const QString &attrHidden = KGlobal::staticQString("Hidden"); | 1767 | static const QString &attrHidden = KGlobal::staticQString("Hidden"); |
1762 | 1768 | ||
1763 | QString position = config->readEntry(attrPosition, d->PositionDefault); | 1769 | QString position = config->readEntry(attrPosition, d->PositionDefault); |
1764 | int index = config->readNumEntry(attrIndex, d->IndexDefault); | 1770 | int index = config->readNumEntry(attrIndex, d->IndexDefault); |
1765 | int offset = config->readNumEntry(attrOffset, d->OffsetDefault); | 1771 | int offset = config->readNumEntry(attrOffset, d->OffsetDefault); |
1766 | bool newLine = config->readBoolEntry(attrNewLine, d->NewLineDefault); | 1772 | bool newLine = config->readBoolEntry(attrNewLine, d->NewLineDefault); |
1767 | bool hidden = config->readBoolEntry(attrHidden, d->HiddenDefault); | 1773 | bool hidden = config->readBoolEntry(attrHidden, d->HiddenDefault); |
1768 | */ | 1774 | */ |
1769 | 1775 | ||
1770 | QString position = config->readEntry("Position", d->PositionDefault); | 1776 | QString position = config->readEntry("Position", d->PositionDefault); |
1771 | int index = config->readNumEntry("Index", d->IndexDefault); | 1777 | int index = config->readNumEntry("Index", d->IndexDefault); |
1772 | int offset = config->readNumEntry("Offset", d->OffsetDefault); | 1778 | int offset = config->readNumEntry("Offset", d->OffsetDefault); |
1773 | bool newLine = config->readBoolEntry("NewLine", d->NewLineDefault); | 1779 | bool newLine = config->readBoolEntry("NewLine", d->NewLineDefault); |
1774 | bool hidden = config->readBoolEntry("Hidden", d->HiddenDefault); | 1780 | bool hidden = config->readBoolEntry("Hidden", d->HiddenDefault); |
1775 | 1781 | ||
1776 | /*US Dock pos(DockTop); | 1782 | /*US Dock pos(DockTop); |
1777 | if ( position == "Top" ) | 1783 | if ( position == "Top" ) |
1778 | pos = DockTop; | 1784 | pos = DockTop; |
1779 | else if ( position == "Bottom" ) | 1785 | else if ( position == "Bottom" ) |
1780 | pos = DockBottom; | 1786 | pos = DockBottom; |
1781 | else if ( position == "Left" ) | 1787 | else if ( position == "Left" ) |
1782 | pos = DockLeft; | 1788 | pos = DockLeft; |
1783 | else if ( position == "Right" ) | 1789 | else if ( position == "Right" ) |
1784 | pos = DockRight; | 1790 | pos = DockRight; |
1785 | else if ( position == "Floating" ) | 1791 | else if ( position == "Floating" ) |
1786 | pos = DockTornOff; | 1792 | pos = DockTornOff; |
1787 | else if ( position == "Flat" ) | 1793 | else if ( position == "Flat" ) |
1788 | pos = DockMinimized; | 1794 | pos = DockMinimized; |
1789 | */ | 1795 | */ |
1790 | QMainWindow::ToolBarDock pos(QMainWindow::Top); | 1796 | QMainWindow::ToolBarDock pos(QMainWindow::Top); |
1791 | if ( position == "Top" ) | 1797 | if ( position == "Top" ) |
1792 | pos = QMainWindow::Top; | 1798 | pos = QMainWindow::Top; |
1793 | else if ( position == "Bottom" ) | 1799 | else if ( position == "Bottom" ) |
1794 | pos = QMainWindow::Bottom; | 1800 | pos = QMainWindow::Bottom; |
1795 | else if ( position == "Left" ) | 1801 | else if ( position == "Left" ) |
1796 | pos = QMainWindow::Left; | 1802 | pos = QMainWindow::Left; |
1797 | else if ( position == "Right" ) | 1803 | else if ( position == "Right" ) |
1798 | pos = QMainWindow::Right; | 1804 | pos = QMainWindow::Right; |
1799 | else if ( position == "Floating" ) | 1805 | else if ( position == "Floating" ) |
1800 | pos = QMainWindow::TornOff; | 1806 | pos = QMainWindow::TornOff; |
1801 | else if ( position == "Flat" ) | 1807 | else if ( position == "Flat" ) |
1802 | pos = QMainWindow::Minimized; | 1808 | pos = QMainWindow::Minimized; |
1803 | 1809 | ||
1804 | //kdDebug(220) << "KToolBar::applySettings hidden=" << hidden << endl; | 1810 | //kdDebug(220) << "KToolBar::applySettings hidden=" << hidden << endl; |
1805 | if (hidden) | 1811 | if (hidden) |
1806 | hide(); | 1812 | hide(); |
1807 | else | 1813 | else |
1808 | show(); | 1814 | show(); |
1809 | 1815 | ||
1810 | if ( mainWindow() ) | 1816 | if ( mainWindow() ) |
1811 | { | 1817 | { |
1812 | QMainWindow *mw = mainWindow(); | 1818 | QMainWindow *mw = mainWindow(); |
1813 | 1819 | ||
1814 | //kdDebug(220) << "KToolBar::applySettings updating ToolbarInfo" << endl; | 1820 | //kdDebug(220) << "KToolBar::applySettings updating ToolbarInfo" << endl; |
1815 | d->toolBarInfo = KToolBarPrivate::ToolBarInfo( pos, index, newLine, offset ); | 1821 | d->toolBarInfo = KToolBarPrivate::ToolBarInfo( pos, index, newLine, offset ); |
1816 | 1822 | ||
1817 | // moveDockWindow calls QDockArea which does a reparent() on us with | 1823 | // moveDockWindow calls QDockArea which does a reparent() on us with |
1818 | // showIt = true, so we loose our visibility status | 1824 | // showIt = true, so we loose our visibility status |
1819 | bool doHide = isHidden(); | 1825 | bool doHide = isHidden(); |
1820 | 1826 | ||
1821 | //US mw->moveDockWindow( this, pos, newLine, index, offset ); | 1827 | //US mw->moveDockWindow( this, pos, newLine, index, offset ); |
1822 | mw->moveToolBar( this, pos, newLine, index, offset ); | 1828 | mw->moveToolBar( this, pos, newLine, index, offset ); |
1823 | 1829 | ||
1824 | //kdDebug(220) << "KToolBar::applySettings " << name() << " moveDockWindow with pos=" << pos << " newLine=" << newLine << " idx=" << index << " offs=" << offset << endl; | 1830 | //kdDebug(220) << "KToolBar::applySettings " << name() << " moveDockWindow with pos=" << pos << " newLine=" << newLine << " idx=" << index << " offs=" << offset << endl; |
1825 | if ( doHide ) | 1831 | if ( doHide ) |
1826 | hide(); | 1832 | hide(); |
1827 | } | 1833 | } |
1828 | if (isVisible ()) | 1834 | if (isVisible ()) |
1829 | updateGeometry(); | 1835 | updateGeometry(); |
1830 | } | 1836 | } |
1831 | } | 1837 | } |
1832 | 1838 | ||
1833 | bool KToolBar::event( QEvent *e ) | 1839 | bool KToolBar::event( QEvent *e ) |
1834 | { | 1840 | { |
1835 | if ( (e->type() == QEvent::LayoutHint) && isUpdatesEnabled() ) | 1841 | if ( (e->type() == QEvent::LayoutHint) && isUpdatesEnabled() ) |
1836 | d->repaintTimer.start( 100, true ); | 1842 | d->repaintTimer.start( 100, true ); |
1837 | 1843 | ||
1838 | if (e->type() == QEvent::ChildInserted ) | 1844 | if (e->type() == QEvent::ChildInserted ) |
1839 | { | 1845 | { |
1840 | // By pass QToolBar::event, | 1846 | // By pass QToolBar::event, |
1841 | // it will show() the inserted child and we don't want to | 1847 | // it will show() the inserted child and we don't want to |
1842 | // do that until we have rebuild the layout. | 1848 | // do that until we have rebuild the layout. |
1843 | childEvent((QChildEvent *)e); | 1849 | childEvent((QChildEvent *)e); |
1844 | return true; | 1850 | return true; |
1845 | } | 1851 | } |
1846 | 1852 | ||
1847 | return QToolBar::event( e ); | 1853 | return QToolBar::event( e ); |
1848 | } | 1854 | } |
1849 | 1855 | ||
1850 | void KToolBar::slotRepaint() | 1856 | void KToolBar::slotRepaint() |
1851 | { | 1857 | { |
1852 | setUpdatesEnabled( FALSE ); | 1858 | setUpdatesEnabled( FALSE ); |
1853 | // Send a resizeEvent to update the "toolbar extension arrow" | 1859 | // Send a resizeEvent to update the "toolbar extension arrow" |
1854 | // (The button you get when your toolbar-items don't fit in | 1860 | // (The button you get when your toolbar-items don't fit in |
1855 | // the available space) | 1861 | // the available space) |
1856 | QResizeEvent ev(size(), size()); | 1862 | QResizeEvent ev(size(), size()); |
1857 | resizeEvent(&ev); | 1863 | resizeEvent(&ev); |
1858 | //#ifdef DESKTOP_VERSION | 1864 | //#ifdef DESKTOP_VERSION |
1859 | QApplication::sendPostedEvents( this, QEvent::LayoutHint ); | 1865 | QApplication::sendPostedEvents( this, QEvent::LayoutHint ); |
1860 | //#endif //DESKTOP_VERSION | 1866 | //#endif //DESKTOP_VERSION |
1861 | setUpdatesEnabled( TRUE ); | 1867 | setUpdatesEnabled( TRUE ); |
1862 | repaint( TRUE ); | 1868 | repaint( TRUE ); |
1863 | } | 1869 | } |
1864 | 1870 | ||
1865 | void KToolBar::toolBarPosChanged( QToolBar *tb ) | 1871 | void KToolBar::toolBarPosChanged( QToolBar *tb ) |
1866 | { | 1872 | { |
1867 | if ( tb != this ) | 1873 | if ( tb != this ) |
1868 | return; | 1874 | return; |
1869 | //US if ( d->oldPos == DockMinimized ) | 1875 | //US if ( d->oldPos == DockMinimized ) |
1870 | if ( d->oldPos == QMainWindow::Minimized ) | 1876 | if ( d->oldPos == QMainWindow::Minimized ) |
1871 | rebuildLayout(); | 1877 | rebuildLayout(); |
1872 | d->oldPos = (QMainWindow::ToolBarDock)barPos(); | 1878 | d->oldPos = (QMainWindow::ToolBarDock)barPos(); |
1873 | /*US | 1879 | /*US |
1874 | if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) | 1880 | if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) |
1875 | static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); | 1881 | static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); |
1876 | */ | 1882 | */ |
1877 | } | 1883 | } |
1878 | 1884 | ||
1879 | /*US | 1885 | /*US |
1880 | void KToolBar::loadState( const QDomElement &element ) | 1886 | void KToolBar::loadState( const QDomElement &element ) |
1881 | { | 1887 | { |
1882 | //kdDebug(220) << "KToolBar::loadState " << this << endl; | 1888 | //kdDebug(220) << "KToolBar::loadState " << this << endl; |
1883 | if ( !mainWindow() ) | 1889 | if ( !mainWindow() ) |
1884 | return; | 1890 | return; |
1885 | 1891 | ||
1886 | { | 1892 | { |
1887 | QCString text = element.namedItem( "text" ).toElement().text().utf8(); | 1893 | QCString text = element.namedItem( "text" ).toElement().text().utf8(); |
1888 | if ( text.isEmpty() ) | 1894 | if ( text.isEmpty() ) |
1889 | text = element.namedItem( "Text" ).toElement().text().utf8(); | 1895 | text = element.namedItem( "Text" ).toElement().text().utf8(); |
1890 | if ( !text.isEmpty() ) | 1896 | if ( !text.isEmpty() ) |
1891 | setText( i18n( text ) ); | 1897 | setText( i18n( text ) ); |
1892 | } | 1898 | } |
1893 | 1899 | ||
1894 | { | 1900 | { |
1895 | QCString attrFullWidth = element.attribute( "fullWidth" ).lower().latin1(); | 1901 | QCString attrFullWidth = element.attribute( "fullWidth" ).lower().latin1(); |
1896 | if ( !attrFullWidth.isEmpty() ) | 1902 | if ( !attrFullWidth.isEmpty() ) |
1897 | setFullSize( attrFullWidth == "true" ); | 1903 | setFullSize( attrFullWidth == "true" ); |
1898 | } | 1904 | } |
1899 | 1905 | ||
1900 | Dock dock = DockTop; | 1906 | Dock dock = DockTop; |
1901 | { | 1907 | { |
1902 | QCString attrPosition = element.attribute( "position" ).lower().latin1(); | 1908 | QCString attrPosition = element.attribute( "position" ).lower().latin1(); |
1903 | //kdDebug(220) << "KToolBar::loadState attrPosition=" << attrPosition << endl; | 1909 | //kdDebug(220) << "KToolBar::loadState attrPosition=" << attrPosition << endl; |
1904 | if ( !attrPosition.isEmpty() ) { | 1910 | if ( !attrPosition.isEmpty() ) { |
1905 | if ( attrPosition == "top" ) | 1911 | if ( attrPosition == "top" ) |
1906 | dock = DockTop; | 1912 | dock = DockTop; |
1907 | else if ( attrPosition == "left" ) | 1913 | else if ( attrPosition == "left" ) |
1908 | dock = DockLeft; | 1914 | dock = DockLeft; |
1909 | else if ( attrPosition == "right" ) | 1915 | else if ( attrPosition == "right" ) |
1910 | dock = DockRight; | 1916 | dock = DockRight; |
1911 | else if ( attrPosition == "bottom" ) | 1917 | else if ( attrPosition == "bottom" ) |
1912 | dock = DockBottom; | 1918 | dock = DockBottom; |
1913 | else if ( attrPosition == "floating" ) | 1919 | else if ( attrPosition == "floating" ) |
1914 | dock = DockTornOff; | 1920 | dock = DockTornOff; |
1915 | else if ( attrPosition == "flat" ) | 1921 | else if ( attrPosition == "flat" ) |
1916 | dock = DockMinimized; | 1922 | dock = DockMinimized; |
1917 | } | 1923 | } |
1918 | } | 1924 | } |
1919 | 1925 | ||
1920 | { | 1926 | { |
1921 | QCString attrIconText = element.attribute( "iconText" ).lower().latin1(); | 1927 | QCString attrIconText = element.attribute( "iconText" ).lower().latin1(); |
1922 | if ( !attrIconText.isEmpty() ) { | 1928 | if ( !attrIconText.isEmpty() ) { |
1923 | //kdDebug(220) << "KToolBar::loadState attrIconText=" << attrIconText << endl; | 1929 | //kdDebug(220) << "KToolBar::loadState attrIconText=" << attrIconText << endl; |
1924 | if ( attrIconText == "icontextright" ) | 1930 | if ( attrIconText == "icontextright" ) |
1925 | setIconText( KToolBar::IconTextRight ); | 1931 | setIconText( KToolBar::IconTextRight ); |
1926 | else if ( attrIconText == "textonly" ) | 1932 | else if ( attrIconText == "textonly" ) |
1927 | setIconText( KToolBar::TextOnly ); | 1933 | setIconText( KToolBar::TextOnly ); |
1928 | else if ( attrIconText == "icontextbottom" ) | 1934 | else if ( attrIconText == "icontextbottom" ) |
1929 | setIconText( KToolBar::IconTextBottom ); | 1935 | setIconText( KToolBar::IconTextBottom ); |
1930 | else if ( attrIconText == "icononly" ) | 1936 | else if ( attrIconText == "icononly" ) |
1931 | setIconText( KToolBar::IconOnly ); | 1937 | setIconText( KToolBar::IconOnly ); |
1932 | } else | 1938 | } else |
1933 | // Use global setting | 1939 | // Use global setting |
1934 | setIconText( iconTextSetting() ); | 1940 | setIconText( iconTextSetting() ); |
1935 | } | 1941 | } |
1936 | 1942 | ||
1937 | { | 1943 | { |
1938 | QString attrIconSize = element.attribute( "iconSize" ).lower(); | 1944 | QString attrIconSize = element.attribute( "iconSize" ).lower(); |
1939 | if ( !attrIconSize.isEmpty() ) | 1945 | if ( !attrIconSize.isEmpty() ) |
1940 | d->IconSizeDefault = attrIconSize.toInt(); | 1946 | d->IconSizeDefault = attrIconSize.toInt(); |
1941 | setIconSize( d->IconSizeDefault ); | 1947 | setIconSize( d->IconSizeDefault ); |
1942 | } | 1948 | } |
1943 | 1949 | ||
1944 | { | 1950 | { |
1945 | QString attrIndex = element.attribute( "index" ).lower(); | 1951 | QString attrIndex = element.attribute( "index" ).lower(); |
1946 | if ( !attrIndex.isEmpty() ) | 1952 | if ( !attrIndex.isEmpty() ) |
1947 | d->IndexDefault = attrIndex.toInt(); | 1953 | d->IndexDefault = attrIndex.toInt(); |
1948 | } | 1954 | } |
1949 | 1955 | ||
1950 | { | 1956 | { |
1951 | QString attrOffset = element.attribute( "offset" ).lower(); | 1957 | QString attrOffset = element.attribute( "offset" ).lower(); |
1952 | if ( !attrOffset.isEmpty() ) | 1958 | if ( !attrOffset.isEmpty() ) |
1953 | d->OffsetDefault = attrOffset.toInt(); | 1959 | d->OffsetDefault = attrOffset.toInt(); |
1954 | } | 1960 | } |
1955 | 1961 | ||
1956 | { | 1962 | { |
1957 | QString attrNewLine = element.attribute( "newline" ).lower(); | 1963 | QString attrNewLine = element.attribute( "newline" ).lower(); |
1958 | if ( !attrNewLine.isEmpty() ) | 1964 | if ( !attrNewLine.isEmpty() ) |
1959 | d->NewLineDefault = attrNewLine == "true"; | 1965 | d->NewLineDefault = attrNewLine == "true"; |
1960 | } | 1966 | } |
1961 | 1967 | ||
1962 | { | 1968 | { |
1963 | QString attrHidden = element.attribute( "hidden" ).lower(); | 1969 | QString attrHidden = element.attribute( "hidden" ).lower(); |
1964 | if ( !attrHidden.isEmpty() ) | 1970 | if ( !attrHidden.isEmpty() ) |
1965 | d->HiddenDefault = attrHidden == "true"; | 1971 | d->HiddenDefault = attrHidden == "true"; |
1966 | } | 1972 | } |
1967 | 1973 | ||
1968 | d->toolBarInfo = KToolBarPrivate::ToolBarInfo( dock, d->IndexDefault, d->NewLineDefault, d->OffsetDefault ); | 1974 | d->toolBarInfo = KToolBarPrivate::ToolBarInfo( dock, d->IndexDefault, d->NewLineDefault, d->OffsetDefault ); |
1969 | mainWindow()->addDockWindow( this, dock, d->NewLineDefault ); | 1975 | mainWindow()->addDockWindow( this, dock, d->NewLineDefault ); |
1970 | //US mainWindow()->moveDockWindow( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); | 1976 | //US mainWindow()->moveDockWindow( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); |
1971 | mainWindow()->moveToolBar( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); | 1977 | mainWindow()->moveToolBar( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); |
1972 | 1978 | ||
1973 | // Apply the highlight button setting | 1979 | // Apply the highlight button setting |
1974 | d->m_highlight = highlightSetting(); | 1980 | d->m_highlight = highlightSetting(); |
1975 | 1981 | ||
1976 | // Apply transparent-toolbar-moving setting (ok, this is global to the mainwindow, | 1982 | // Apply transparent-toolbar-moving setting (ok, this is global to the mainwindow, |
1977 | // but we do it only if there are toolbars...) | 1983 | // but we do it only if there are toolbars...) |
1978 | if ( transparentSetting() != !mainWindow()->opaqueMoving() ) | 1984 | if ( transparentSetting() != !mainWindow()->opaqueMoving() ) |
1979 | mainWindow()->setOpaqueMoving( !transparentSetting() ); | 1985 | mainWindow()->setOpaqueMoving( !transparentSetting() ); |
1980 | 1986 | ||
1981 | if ( d->HiddenDefault ) | 1987 | if ( d->HiddenDefault ) |
1982 | hide(); | 1988 | hide(); |
1983 | else | 1989 | else |
1984 | show(); | 1990 | show(); |
1985 | 1991 | ||
1986 | getAttributes( d->PositionDefault, d->IconTextDefault, d->IndexDefault ); | 1992 | getAttributes( d->PositionDefault, d->IconTextDefault, d->IndexDefault ); |
1987 | } | 1993 | } |
1988 | */ | 1994 | */ |
1989 | 1995 | ||
1990 | void KToolBar::getAttributes( QString &position, QString &icontext, int &index ) | 1996 | void KToolBar::getAttributes( QString &position, QString &icontext, int &index ) |
1991 | { | 1997 | { |
1992 | // get all of the stuff to save | 1998 | // get all of the stuff to save |
1993 | switch ( barPos() ) { | 1999 | switch ( barPos() ) { |
1994 | case KToolBar::Flat: | 2000 | case KToolBar::Flat: |
1995 | position = "Flat"; | 2001 | position = "Flat"; |
1996 | break; | 2002 | break; |
1997 | case KToolBar::Bottom: | 2003 | case KToolBar::Bottom: |
1998 | position = "Bottom"; | 2004 | position = "Bottom"; |
1999 | break; | 2005 | break; |
2000 | case KToolBar::Left: | 2006 | case KToolBar::Left: |
2001 | position = "Left"; | 2007 | position = "Left"; |
2002 | break; | 2008 | break; |
2003 | case KToolBar::Right: | 2009 | case KToolBar::Right: |
2004 | position = "Right"; | 2010 | position = "Right"; |
2005 | break; | 2011 | break; |
2006 | case KToolBar::Floating: | 2012 | case KToolBar::Floating: |
2007 | position = "Floating"; | 2013 | position = "Floating"; |
2008 | break; | 2014 | break; |
2009 | case KToolBar::Top: | 2015 | case KToolBar::Top: |
2010 | default: | 2016 | default: |
2011 | position = "Top"; | 2017 | position = "Top"; |
2012 | break; | 2018 | break; |
2013 | } | 2019 | } |
2014 | 2020 | ||
2015 | if ( mainWindow() ) { | 2021 | if ( mainWindow() ) { |
2016 | QMainWindow::ToolBarDock dock; | 2022 | QMainWindow::ToolBarDock dock; |
2017 | bool newLine; | 2023 | bool newLine; |
2018 | int offset; | 2024 | int offset; |
2019 | mainWindow()->getLocation( this, dock, index, newLine, offset ); | 2025 | mainWindow()->getLocation( this, dock, index, newLine, offset ); |
2020 | } | 2026 | } |
2021 | 2027 | ||
2022 | switch (d->m_iconText) { | 2028 | switch (d->m_iconText) { |
2023 | case KToolBar::IconTextRight: | 2029 | case KToolBar::IconTextRight: |
2024 | icontext = "IconTextRight"; | 2030 | icontext = "IconTextRight"; |
2025 | break; | 2031 | break; |
2026 | case KToolBar::IconTextBottom: | 2032 | case KToolBar::IconTextBottom: |
2027 | icontext = "IconTextBottom"; | 2033 | icontext = "IconTextBottom"; |
2028 | break; | 2034 | break; |
2029 | case KToolBar::TextOnly: | 2035 | case KToolBar::TextOnly: |
2030 | icontext = "TextOnly"; | 2036 | icontext = "TextOnly"; |
2031 | break; | 2037 | break; |
2032 | case KToolBar::IconOnly: | 2038 | case KToolBar::IconOnly: |
2033 | default: | 2039 | default: |
2034 | icontext = "IconOnly"; | 2040 | icontext = "IconOnly"; |
2035 | break; | 2041 | break; |
2036 | } | 2042 | } |
2037 | } | 2043 | } |
2038 | /*US | 2044 | /*US |
2039 | void KToolBar::saveState( QDomElement ¤t ) | 2045 | void KToolBar::saveState( QDomElement ¤t ) |
2040 | { | 2046 | { |
2041 | QString position, icontext; | 2047 | QString position, icontext; |
2042 | int index = -1; | 2048 | int index = -1; |
2043 | getAttributes( position, icontext, index ); | 2049 | getAttributes( position, icontext, index ); |
2044 | 2050 | ||
2045 | current.setAttribute( "noMerge", "1" ); | 2051 | current.setAttribute( "noMerge", "1" ); |
2046 | current.setAttribute( "position", position ); | 2052 | current.setAttribute( "position", position ); |
2047 | current.setAttribute( "iconText", icontext ); | 2053 | current.setAttribute( "iconText", icontext ); |
2048 | current.setAttribute( "index", index ); | 2054 | current.setAttribute( "index", index ); |
2049 | current.setAttribute( "offset", offset() ); | 2055 | current.setAttribute( "offset", offset() ); |
2050 | current.setAttribute( "newline", newLine() ); | 2056 | current.setAttribute( "newline", newLine() ); |
2051 | if ( isHidden() ) | 2057 | if ( isHidden() ) |
2052 | current.setAttribute( "hidden", "true" ); | 2058 | current.setAttribute( "hidden", "true" ); |
2053 | d->modified = true; | 2059 | d->modified = true; |
2054 | } | 2060 | } |
2055 | */ | 2061 | */ |
2056 | 2062 | ||
2057 | void KToolBar::positionYourself( bool force ) | 2063 | void KToolBar::positionYourself( bool force ) |
2058 | { | 2064 | { |
2059 | if (force) | 2065 | if (force) |
2060 | d->positioned = false; | 2066 | d->positioned = false; |
2061 | 2067 | ||
2062 | if ( d->positioned || !mainWindow() ) | 2068 | if ( d->positioned || !mainWindow() ) |
2063 | { | 2069 | { |
2064 | //kdDebug(220) << "KToolBar::positionYourself d->positioned=true ALREADY DONE" << endl; | 2070 | //kdDebug(220) << "KToolBar::positionYourself d->positioned=true ALREADY DONE" << endl; |
2065 | return; | 2071 | return; |
2066 | } | 2072 | } |
2067 | // we can't test for ForceHide after moveDockWindow because QDockArea | 2073 | // we can't test for ForceHide after moveDockWindow because QDockArea |
2068 | // does a reparent() with showIt == true | 2074 | // does a reparent() with showIt == true |
2069 | bool doHide = isHidden(); | 2075 | bool doHide = isHidden(); |
2070 | //kdDebug(220) << "positionYourself " << name() << " dock=" << d->toolBarInfo.dock << " newLine=" << d->toolBarInfo.newline << " offset=" << d->toolBarInfo.offset << endl; | 2076 | //kdDebug(220) << "positionYourself " << name() << " dock=" << d->toolBarInfo.dock << " newLine=" << d->toolBarInfo.newline << " offset=" << d->toolBarInfo.offset << endl; |
2071 | /*US mainWindow()->moveDockWindow( this, d->toolBarInfo.dock, | 2077 | /*US mainWindow()->moveDockWindow( this, d->toolBarInfo.dock, |
2072 | d->toolBarInfo.newline, | 2078 | d->toolBarInfo.newline, |
2073 | d->toolBarInfo.index, | 2079 | d->toolBarInfo.index, |
2074 | d->toolBarInfo.offset ); | 2080 | d->toolBarInfo.offset ); |
2075 | */ | 2081 | */ |
2076 | mainWindow()->moveToolBar( this, d->toolBarInfo.dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); | 2082 | mainWindow()->moveToolBar( this, d->toolBarInfo.dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); |
2077 | 2083 | ||
2078 | if ( doHide ) | 2084 | if ( doHide ) |
2079 | hide(); | 2085 | hide(); |
2080 | // This method can only have an effect once - unless force is set | 2086 | // This method can only have an effect once - unless force is set |
2081 | d->positioned = TRUE; | 2087 | d->positioned = TRUE; |
2082 | } | 2088 | } |
2083 | 2089 | ||
2084 | //US KPopupMenu *KToolBar::contextMenu() | 2090 | //US KPopupMenu *KToolBar::contextMenu() |
2085 | QPopupMenu *KToolBar::contextMenu() | 2091 | QPopupMenu *KToolBar::contextMenu() |
2086 | { | 2092 | { |
2087 | if ( context ) | 2093 | if ( context ) |
2088 | return context; | 2094 | return context; |
2089 | 2095 | ||
2090 | // Construct our context popup menu. Name it qt_dockwidget_internal so it | 2096 | // Construct our context popup menu. Name it qt_dockwidget_internal so it |
2091 | // won't be deleted by QToolBar::clear(). | 2097 | // won't be deleted by QToolBar::clear(). |
2092 | //US context = new KPopupMenu( this, "qt_dockwidget_internal" ); | 2098 | //US context = new KPopupMenu( this, "qt_dockwidget_internal" ); |
2093 | context = new QPopupMenu( this, "qt_dockwidget_internal" ); | 2099 | context = new QPopupMenu( this, "qt_dockwidget_internal" ); |
2094 | //US context->insertTitle(i18n("Toolbar Menu")); | 2100 | //US context->insertTitle(i18n("Toolbar Menu")); |
2095 | 2101 | ||
2096 | //US KPopupMenu *orient = new KPopupMenu( context, "orient" ); | 2102 | //US KPopupMenu *orient = new KPopupMenu( context, "orient" ); |
2097 | QPopupMenu *orient = new QPopupMenu( context, "orient" ); | 2103 | QPopupMenu *orient = new QPopupMenu( context, "orient" ); |
2098 | orient->insertItem( i18n("toolbar position string","Top"), CONTEXT_TOP ); | 2104 | orient->insertItem( i18n("toolbar position string","Top"), CONTEXT_TOP ); |
2099 | orient->insertItem( i18n("toolbar position string","Left"), CONTEXT_LEFT ); | 2105 | orient->insertItem( i18n("toolbar position string","Left"), CONTEXT_LEFT ); |
2100 | orient->insertItem( i18n("toolbar position string","Right"), CONTEXT_RIGHT ); | 2106 | orient->insertItem( i18n("toolbar position string","Right"), CONTEXT_RIGHT ); |
2101 | orient->insertItem( i18n("toolbar position string","Bottom"), CONTEXT_BOTTOM ); | 2107 | orient->insertItem( i18n("toolbar position string","Bottom"), CONTEXT_BOTTOM ); |
2102 | orient->insertSeparator(-1); | 2108 | orient->insertSeparator(-1); |
2103 | //orient->insertItem( i18n("toolbar position string","Floating"), CONTEXT_FLOAT ); | 2109 | //orient->insertItem( i18n("toolbar position string","Floating"), CONTEXT_FLOAT ); |
2104 | orient->insertItem( i18n("min toolbar", "Flat"), CONTEXT_FLAT ); | 2110 | orient->insertItem( i18n("min toolbar", "Flat"), CONTEXT_FLAT ); |
2105 | 2111 | ||
2106 | //US KPopupMenu *mode = new KPopupMenu( context, "mode" ); | 2112 | //US KPopupMenu *mode = new KPopupMenu( context, "mode" ); |
2107 | QPopupMenu *mode = new QPopupMenu( context, "mode" ); | 2113 | QPopupMenu *mode = new QPopupMenu( context, "mode" ); |
2108 | mode->insertItem( i18n("Icons Only"), CONTEXT_ICONS ); | 2114 | mode->insertItem( i18n("Icons Only"), CONTEXT_ICONS ); |
2109 | mode->insertItem( i18n("Text Only"), CONTEXT_TEXT ); | 2115 | mode->insertItem( i18n("Text Only"), CONTEXT_TEXT ); |
2110 | mode->insertItem( i18n("Text Alongside Icons"), CONTEXT_TEXTRIGHT ); | 2116 | mode->insertItem( i18n("Text Alongside Icons"), CONTEXT_TEXTRIGHT ); |
2111 | mode->insertItem( i18n("Text Under Icons"), CONTEXT_TEXTUNDER ); | 2117 | mode->insertItem( i18n("Text Under Icons"), CONTEXT_TEXTUNDER ); |
2112 | 2118 | ||
2113 | //US KPopupMenu *size = new KPopupMenu( context, "size" ); | 2119 | //US KPopupMenu *size = new KPopupMenu( context, "size" ); |
2114 | QPopupMenu *size = new QPopupMenu( context, "size" ); | 2120 | QPopupMenu *size = new QPopupMenu( context, "size" ); |
2115 | size->insertItem( i18n("Default"), CONTEXT_ICONSIZES ); | 2121 | size->insertItem( i18n("Default"), CONTEXT_ICONSIZES ); |
2116 | // Query the current theme for available sizes | 2122 | // Query the current theme for available sizes |
2117 | QValueList<int> avSizes; | 2123 | QValueList<int> avSizes; |
2118 | /*US | 2124 | /*US |
2119 | KIconTheme *theme = KGlobal::instance()->iconLoader()->theme(); | 2125 | KIconTheme *theme = KGlobal::instance()->iconLoader()->theme(); |
2120 | if (!::qstrcmp(QObject::name(), "mainToolBar")) | 2126 | if (!::qstrcmp(QObject::name(), "mainToolBar")) |
2121 | avSizes = theme->querySizes( KIcon::MainToolbar); | 2127 | avSizes = theme->querySizes( KIcon::MainToolbar); |
2122 | else | 2128 | else |
2123 | avSizes = theme->querySizes( KIcon::Toolbar); | 2129 | avSizes = theme->querySizes( KIcon::Toolbar); |
2124 | */ | 2130 | */ |
2125 | avSizes << 16; | 2131 | avSizes << 16; |
2126 | avSizes << 32; | 2132 | avSizes << 32; |
2127 | 2133 | ||
2128 | d->iconSizes = avSizes; | 2134 | d->iconSizes = avSizes; |
2129 | 2135 | ||
2130 | QValueList<int>::Iterator it; | 2136 | QValueList<int>::Iterator it; |
2131 | for (it=avSizes.begin(); it!=avSizes.end(); it++) { | 2137 | for (it=avSizes.begin(); it!=avSizes.end(); it++) { |
2132 | QString text; | 2138 | QString text; |
2133 | if ( *it < 19 ) | 2139 | if ( *it < 19 ) |
2134 | text = i18n("Small (%1x%2)").arg(*it).arg(*it); | 2140 | text = i18n("Small (%1x%2)").arg(*it).arg(*it); |
2135 | else if (*it < 25) | 2141 | else if (*it < 25) |
2136 | text = i18n("Medium (%1x%2)").arg(*it).arg(*it); | 2142 | text = i18n("Medium (%1x%2)").arg(*it).arg(*it); |
2137 | else | 2143 | else |
2138 | text = i18n("Large (%1x%2)").arg(*it).arg(*it); | 2144 | text = i18n("Large (%1x%2)").arg(*it).arg(*it); |
2139 | //we use the size as an id, with an offset | 2145 | //we use the size as an id, with an offset |
2140 | size->insertItem( text, CONTEXT_ICONSIZES + *it ); | 2146 | size->insertItem( text, CONTEXT_ICONSIZES + *it ); |
2141 | } | 2147 | } |
2142 | 2148 | ||
2143 | context->insertItem( i18n("Orientation"), orient ); | 2149 | context->insertItem( i18n("Orientation"), orient ); |
2144 | orient->setItemChecked(CONTEXT_TOP, true); | 2150 | orient->setItemChecked(CONTEXT_TOP, true); |
2145 | context->insertItem( i18n("Text Position"), mode ); | 2151 | context->insertItem( i18n("Text Position"), mode ); |
2146 | context->setItemChecked(CONTEXT_ICONS, true); | 2152 | context->setItemChecked(CONTEXT_ICONS, true); |
2147 | context->insertItem( i18n("Icon Size"), size ); | 2153 | context->insertItem( i18n("Icon Size"), size ); |
2148 | 2154 | ||
2149 | /*US | 2155 | /*US |
2150 | if (mainWindow()->inherits("KMainWindow")) | 2156 | if (mainWindow()->inherits("KMainWindow")) |
2151 | { | 2157 | { |
2152 | if ( (static_cast<KMainWindow*>(mainWindow())->toolBarMenuAction()) && | 2158 | if ( (static_cast<KMainWindow*>(mainWindow())->toolBarMenuAction()) && |
2153 | (static_cast<KMainWindow*>(mainWindow())->hasMenuBar()) ) | 2159 | (static_cast<KMainWindow*>(mainWindow())->hasMenuBar()) ) |
2154 | 2160 | ||
2155 | (static_cast<KMainWindow*>(mainWindow()))->toolBarMenuAction()->plug(context); | 2161 | (static_cast<KMainWindow*>(mainWindow()))->toolBarMenuAction()->plug(context); |
2156 | } | 2162 | } |
2157 | */ | 2163 | */ |
2158 | 2164 | ||
2159 | connect( context, SIGNAL( aboutToShow() ), this, SLOT( slotContextAboutToShow() ) ); | 2165 | connect( context, SIGNAL( aboutToShow() ), this, SLOT( slotContextAboutToShow() ) ); |
2160 | return context; | 2166 | return context; |
2161 | } | 2167 | } |
2162 | 2168 | ||
2163 | void KToolBar::slotContextAboutToShow() | 2169 | void KToolBar::slotContextAboutToShow() |
2164 | { | 2170 | { |
2165 | if (!d->m_configurePlugged) | 2171 | if (!d->m_configurePlugged) |
2166 | { | 2172 | { |
2167 | // try to find "configure toolbars" action | 2173 | // try to find "configure toolbars" action |
2168 | 2174 | ||
2169 | KXMLGUIClient *xmlGuiClient = d->m_xmlguiClient; | 2175 | KXMLGUIClient *xmlGuiClient = d->m_xmlguiClient; |
2170 | if ( !xmlGuiClient && mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) | 2176 | if ( !xmlGuiClient && mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) |
2171 | xmlGuiClient = (KXMLGUIClient *)mainWindow(); | 2177 | xmlGuiClient = (KXMLGUIClient *)mainWindow(); |
2172 | if ( xmlGuiClient ) | 2178 | if ( xmlGuiClient ) |
2173 | { | 2179 | { |
2174 | KAction *configureAction = xmlGuiClient->actionCollection()->action(KStdAction::stdName(KStdAction::ConfigureToolbars)); | 2180 | KAction *configureAction = xmlGuiClient->actionCollection()->action(KStdAction::stdName(KStdAction::ConfigureToolbars)); |
2175 | if ( configureAction ) | 2181 | if ( configureAction ) |
2176 | { | 2182 | { |
2177 | configureAction->plug(context); | 2183 | configureAction->plug(context); |
2178 | d->m_configurePlugged = true; | 2184 | d->m_configurePlugged = true; |
2179 | } | 2185 | } |
2180 | } | 2186 | } |
diff --git a/microkde/kdeui/ktoolbar.h b/microkde/kdeui/ktoolbar.h index 2c061b5..61b5ea3 100644 --- a/microkde/kdeui/ktoolbar.h +++ b/microkde/kdeui/ktoolbar.h | |||
@@ -280,828 +280,829 @@ public: | |||
280 | * @param id The id of this button | 280 | * @param id The id of this button |
281 | * @param signal The signal to connect to | 281 | * @param signal The signal to connect to |
282 | * @param receiver The slot's parent | 282 | * @param receiver The slot's parent |
283 | * @param enabled Enable or disable the button at startup | 283 | * @param enabled Enable or disable the button at startup |
284 | * @param text The tooltip or toolbar text (depending on state) | 284 | * @param text The tooltip or toolbar text (depending on state) |
285 | * @param index The position of the button. (-1 = at end). | 285 | * @param index The position of the button. (-1 = at end). |
286 | * | 286 | * |
287 | * @return The item index. | 287 | * @return The item index. |
288 | */ | 288 | */ |
289 | int insertButton(const QPixmap& pixmap, int id, const char *signal, | 289 | int insertButton(const QPixmap& pixmap, int id, const char *signal, |
290 | const QObject *receiver, const char *slot, | 290 | const QObject *receiver, const char *slot, |
291 | bool enabled = true, const QString& text = QString::null, | 291 | bool enabled = true, const QString& text = QString::null, |
292 | int index=-1 ); | 292 | int index=-1 ); |
293 | 293 | ||
294 | /** | 294 | /** |
295 | * Inserts a button with popupmenu. | 295 | * Inserts a button with popupmenu. |
296 | * | 296 | * |
297 | * Button will have small | 297 | * Button will have small |
298 | * triangle. You have to connect to popup's signals. The | 298 | * triangle. You have to connect to popup's signals. The |
299 | * signals @ref KButton::pressed(), @ref KButton::released(), | 299 | * signals @ref KButton::pressed(), @ref KButton::released(), |
300 | * @ref KButton::clicked() or @ref KButton::doubleClicked() are @p not | 300 | * @ref KButton::clicked() or @ref KButton::doubleClicked() are @p not |
301 | * emmited by | 301 | * emmited by |
302 | * this button (see @ref setDelayedPopup() for that). | 302 | * this button (see @ref setDelayedPopup() for that). |
303 | * You can add custom popups which inherit @ref QPopupMenu to get popups | 303 | * You can add custom popups which inherit @ref QPopupMenu to get popups |
304 | * with tables, drawings etc. Just don't fiddle with events there. | 304 | * with tables, drawings etc. Just don't fiddle with events there. |
305 | */ | 305 | */ |
306 | int insertButton(const QString& icon, int id, QPopupMenu *popup, | 306 | int insertButton(const QString& icon, int id, QPopupMenu *popup, |
307 | bool enabled, const QString&_text, int index=-1); | 307 | bool enabled, const QString&_text, int index=-1); |
308 | 308 | ||
309 | /** | 309 | /** |
310 | * Inserts a button with popupmenu. | 310 | * Inserts a button with popupmenu. |
311 | * | 311 | * |
312 | * Button will have small | 312 | * Button will have small |
313 | * triangle. You have to connect to popup's signals. The | 313 | * triangle. You have to connect to popup's signals. The |
314 | * signals @ref KButton::pressed(), @ref KButton::released(), | 314 | * signals @ref KButton::pressed(), @ref KButton::released(), |
315 | * @ref KButton::clicked() or @ref KButton::doubleClicked() are @p not | 315 | * @ref KButton::clicked() or @ref KButton::doubleClicked() are @p not |
316 | * emmited by | 316 | * emmited by |
317 | * this button (see @ref setDelayedPopup() for that). | 317 | * this button (see @ref setDelayedPopup() for that). |
318 | * You can add custom popups which inherit @ref QPopupMenu to get popups | 318 | * You can add custom popups which inherit @ref QPopupMenu to get popups |
319 | * with tables, drawings etc. Just don't fiddle with events there. | 319 | * with tables, drawings etc. Just don't fiddle with events there. |
320 | */ | 320 | */ |
321 | int insertButton(const QPixmap& pixmap, int id, QPopupMenu *popup, | 321 | int insertButton(const QPixmap& pixmap, int id, QPopupMenu *popup, |
322 | bool enabled, const QString&_text, int index=-1); | 322 | bool enabled, const QString&_text, int index=-1); |
323 | 323 | ||
324 | /** | 324 | /** |
325 | * Inserts a @ref KLineEdit. You have to specify signals and slots to | 325 | * Inserts a @ref KLineEdit. You have to specify signals and slots to |
326 | * which KLineEdit will be connected. KLineEdit has all slots QLineEdit | 326 | * which KLineEdit will be connected. KLineEdit has all slots QLineEdit |
327 | * has, plus signals @ref KLineEdit::completion and @ref KLineEdit::textRotation | 327 | * has, plus signals @ref KLineEdit::completion and @ref KLineEdit::textRotation |
328 | * KLineEdit can be set to autoresize itself to full free width | 328 | * KLineEdit can be set to autoresize itself to full free width |
329 | * in toolbar, that is to last right aligned item. For that, | 329 | * in toolbar, that is to last right aligned item. For that, |
330 | * toolbar must be set to full width (which it is by default). | 330 | * toolbar must be set to full width (which it is by default). |
331 | * @see setFullWidth() | 331 | * @see setFullWidth() |
332 | * @see setItemAutoSized() | 332 | * @see setItemAutoSized() |
333 | * @see KLineEdit | 333 | * @see KLineEdit |
334 | * @return Item index. | 334 | * @return Item index. |
335 | */ | 335 | */ |
336 | int insertLined (const QString& text, int id, | 336 | int insertLined (const QString& text, int id, |
337 | const char *signal, | 337 | const char *signal, |
338 | const QObject *receiver, const char *slot, | 338 | const QObject *receiver, const char *slot, |
339 | bool enabled = true, | 339 | bool enabled = true, |
340 | const QString& toolTipText = QString::null, | 340 | const QString& toolTipText = QString::null, |
341 | int size = 70, int index =-1); | 341 | int size = 70, int index =-1); |
342 | 342 | ||
343 | /** | 343 | /** |
344 | * Inserts a @ref KComboBox with list. | 344 | * Inserts a @ref KComboBox with list. |
345 | * | 345 | * |
346 | * Can be writable, but cannot contain | 346 | * Can be writable, but cannot contain |
347 | * pixmaps. By default inserting policy is AtBottom, i.e. typed items | 347 | * pixmaps. By default inserting policy is AtBottom, i.e. typed items |
348 | * are placed at the bottom of the list. Can be autosized. If the size | 348 | * are placed at the bottom of the list. Can be autosized. If the size |
349 | * argument is specified as -1, the width of the combobox is automatically | 349 | * argument is specified as -1, the width of the combobox is automatically |
350 | * computed. | 350 | * computed. |
351 | * | 351 | * |
352 | * @see setFullWidth() | 352 | * @see setFullWidth() |
353 | * @see setItemAutoSized() | 353 | * @see setItemAutoSized() |
354 | * @see KComboBox | 354 | * @see KComboBox |
355 | * @return Item index. | 355 | * @return Item index. |
356 | */ | 356 | */ |
357 | int insertCombo (const QStringList &list, int id, bool writable, | 357 | int insertCombo (const QStringList &list, int id, bool writable, |
358 | const char *signal, const QObject *receiver, | 358 | const char *signal, const QObject *receiver, |
359 | const char *slot, bool enabled=true, | 359 | const char *slot, bool enabled=true, |
360 | const QString& tooltiptext=QString::null, | 360 | const QString& tooltiptext=QString::null, |
361 | int size=70, int index=-1, | 361 | int size=70, int index=-1, |
362 | QComboBox::Policy policy = QComboBox::AtBottom); | 362 | QComboBox::Policy policy = QComboBox::AtBottom); |
363 | 363 | ||
364 | /** | 364 | /** |
365 | * Insert a @ref KComboBox with text. | 365 | * Insert a @ref KComboBox with text. |
366 | * | 366 | * |
367 | * The rest is the same as above. | 367 | * The rest is the same as above. |
368 | * @see setItemAutoSized() | 368 | * @see setItemAutoSized() |
369 | * | 369 | * |
370 | * @see KComboBox | 370 | * @see KComboBox |
371 | * @return Item index. | 371 | * @return Item index. |
372 | */ | 372 | */ |
373 | int insertCombo (const QString& text, int id, bool writable, | 373 | int insertCombo (const QString& text, int id, bool writable, |
374 | const char *signal, QObject *recevier, | 374 | const char *signal, QObject *recevier, |
375 | const char *slot, bool enabled=true, | 375 | const char *slot, bool enabled=true, |
376 | const QString& tooltiptext=QString::null, | 376 | const QString& tooltiptext=QString::null, |
377 | int size=70, int index=-1, | 377 | int size=70, int index=-1, |
378 | QComboBox::Policy policy = QComboBox::AtBottom); | 378 | QComboBox::Policy policy = QComboBox::AtBottom); |
379 | 379 | ||
380 | /** | 380 | /** |
381 | * Inserts a separator into the toolbar with the given id. | 381 | * Inserts a separator into the toolbar with the given id. |
382 | * Returns the separator's index | 382 | * Returns the separator's index |
383 | */ | 383 | */ |
384 | int insertSeparator( int index = -1, int id = -1 ); | 384 | int insertSeparator( int index = -1, int id = -1 ); |
385 | 385 | ||
386 | /** | 386 | /** |
387 | * Inserts a line separator into the toolbar with the given id. | 387 | * Inserts a line separator into the toolbar with the given id. |
388 | * Returns the separator's index | 388 | * Returns the separator's index |
389 | */ | 389 | */ |
390 | int insertLineSeparator( int index = -1, int id = -1 ); | 390 | int insertLineSeparator( int index = -1, int id = -1 ); |
391 | 391 | ||
392 | /** | 392 | /** |
393 | * Inserts a user-defined widget. The widget @p must have this | 393 | * Inserts a user-defined widget. The widget @p must have this |
394 | * toolbar as its parent. | 394 | * toolbar as its parent. |
395 | * | 395 | * |
396 | * Widget must have a QWidget for base class. Widget can be | 396 | * Widget must have a QWidget for base class. Widget can be |
397 | * autosized to full width. If you forget about it, you can get a | 397 | * autosized to full width. If you forget about it, you can get a |
398 | * pointer to this widget with @ref getWidget(). | 398 | * pointer to this widget with @ref getWidget(). |
399 | * @see setItemAutoSized() | 399 | * @see setItemAutoSized() |
400 | * @return Item index. | 400 | * @return Item index. |
401 | */ | 401 | */ |
402 | int insertWidget(int id, int width, QWidget *_widget, int index=-1); | 402 | int insertWidget(int id, int width, QWidget *_widget, int index=-1); |
403 | 403 | ||
404 | /** | 404 | /** |
405 | * Inserts an animated widget. A @ref KAnimWidget will be created | 405 | * Inserts an animated widget. A @ref KAnimWidget will be created |
406 | * internally using the icon name you provide. | 406 | * internally using the icon name you provide. |
407 | * This will emit a signal (clicked()) whenever the | 407 | * This will emit a signal (clicked()) whenever the |
408 | * animation widget is clicked. | 408 | * animation widget is clicked. |
409 | * | 409 | * |
410 | * @see animatedWidget() | 410 | * @see animatedWidget() |
411 | * | 411 | * |
412 | * @param id The id for this toolbar item | 412 | * @param id The id for this toolbar item |
413 | * @param receiver The parent of your slot | 413 | * @param receiver The parent of your slot |
414 | * @param slot The slot to receive the clicked() signal | 414 | * @param slot The slot to receive the clicked() signal |
415 | * @param icons The name of the animation icon group to use | 415 | * @param icons The name of the animation icon group to use |
416 | * @param index The item index | 416 | * @param index The item index |
417 | * | 417 | * |
418 | * @return The item index | 418 | * @return The item index |
419 | */ | 419 | */ |
420 | /*US | 420 | /*US |
421 | int insertAnimatedWidget(int id, QObject *receiver, const char *slot, | 421 | int insertAnimatedWidget(int id, QObject *receiver, const char *slot, |
422 | const QString& icons, int index = -1); | 422 | const QString& icons, int index = -1); |
423 | */ | 423 | */ |
424 | /** | 424 | /** |
425 | * This will return a pointer to the given animated widget, if it | 425 | * This will return a pointer to the given animated widget, if it |
426 | * exists. | 426 | * exists. |
427 | * | 427 | * |
428 | * @see insertAnimatedWidget | 428 | * @see insertAnimatedWidget |
429 | * | 429 | * |
430 | * @param id The id for the widget you want to get a pointer to | 430 | * @param id The id for the widget you want to get a pointer to |
431 | * | 431 | * |
432 | * @return A pointer to the current animated widget or 0L | 432 | * @return A pointer to the current animated widget or 0L |
433 | */ | 433 | */ |
434 | //US KAnimWidget *animatedWidget( int id ); | 434 | //US KAnimWidget *animatedWidget( int id ); |
435 | 435 | ||
436 | /** | 436 | /** |
437 | * Adds connections to items. | 437 | * Adds connections to items. |
438 | * | 438 | * |
439 | * It is important that you | 439 | * It is important that you |
440 | * know the @p id of particular item. Nothing happens if you forget @p id. | 440 | * know the @p id of particular item. Nothing happens if you forget @p id. |
441 | */ | 441 | */ |
442 | void addConnection (int id, const char *signal, | 442 | void addConnection (int id, const char *signal, |
443 | const QObject *receiver, const char *slot); | 443 | const QObject *receiver, const char *slot); |
444 | /** | 444 | /** |
445 | * Enables/disables item. | 445 | * Enables/disables item. |
446 | */ | 446 | */ |
447 | void setItemEnabled( int id, bool enabled ); | 447 | void setItemEnabled( int id, bool enabled ); |
448 | 448 | ||
449 | /** | 449 | /** |
450 | * Sets the icon for a button. | 450 | * Sets the icon for a button. |
451 | * | 451 | * |
452 | * Can be used while button is visible. | 452 | * Can be used while button is visible. |
453 | */ | 453 | */ |
454 | void setButtonIcon( int id, const QString& _icon ); | 454 | void setButtonIcon( int id, const QString& _icon ); |
455 | 455 | ||
456 | /** | 456 | /** |
457 | * Sets button pixmap. | 457 | * Sets button pixmap. |
458 | * | 458 | * |
459 | * Can be used while button is visible. | 459 | * Can be used while button is visible. |
460 | */ | 460 | */ |
461 | void setButtonPixmap( int id, const QPixmap& _pixmap ); | 461 | void setButtonPixmap( int id, const QPixmap& _pixmap ); |
462 | 462 | ||
463 | /** | 463 | /** |
464 | * Sets a button icon from a QIconSet. | 464 | * Sets a button icon from a QIconSet. |
465 | * | 465 | * |
466 | * Can be used while button is visible. | 466 | * Can be used while button is visible. |
467 | */ | 467 | */ |
468 | void setButtonIconSet( int id, const QIconSet& iconset ); | 468 | void setButtonIconSet( int id, const QIconSet& iconset ); |
469 | 469 | ||
470 | /** | 470 | /** |
471 | * Sets a delayed popup for a button. | 471 | * Sets a delayed popup for a button. |
472 | * | 472 | * |
473 | * Delayed popup is what you see in | 473 | * Delayed popup is what you see in |
474 | * Netscape Navigator's Previous and Next buttons: If you click them you | 474 | * Netscape Navigator's Previous and Next buttons: If you click them you |
475 | * go back | 475 | * go back |
476 | * or forth. If you press them long enough, you get a history-menu. | 476 | * or forth. If you press them long enough, you get a history-menu. |
477 | * This is exactly what we do here. | 477 | * This is exactly what we do here. |
478 | * | 478 | * |
479 | * You will insert normal a button with connection (or use signals from | 479 | * You will insert normal a button with connection (or use signals from |
480 | * toolbar): | 480 | * toolbar): |
481 | * <pre> | 481 | * <pre> |
482 | * bar->insertButton(icon, id, SIGNAL(clicked ()), this, | 482 | * bar->insertButton(icon, id, SIGNAL(clicked ()), this, |
483 | * SLOT (slotClick()), true, "click or wait for popup"); | 483 | * SLOT (slotClick()), true, "click or wait for popup"); |
484 | * </pre> And then add a delayed popup: | 484 | * </pre> And then add a delayed popup: |
485 | * <pre> | 485 | * <pre> |
486 | * bar->setDelayedPopup (id, historyPopup); </pre> | 486 | * bar->setDelayedPopup (id, historyPopup); </pre> |
487 | * | 487 | * |
488 | * Don't add delayed popups to buttons which have normal popups. | 488 | * Don't add delayed popups to buttons which have normal popups. |
489 | * | 489 | * |
490 | * You may add popups which are derived from @ref QPopupMenu. You may | 490 | * You may add popups which are derived from @ref QPopupMenu. You may |
491 | * add popups that are already in the menu bar or are submenus of | 491 | * add popups that are already in the menu bar or are submenus of |
492 | * other popups. | 492 | * other popups. |
493 | */ | 493 | */ |
494 | void setDelayedPopup (int id , QPopupMenu *_popup, bool toggle = false); | 494 | void setDelayedPopup (int id , QPopupMenu *_popup, bool toggle = false); |
495 | 495 | ||
496 | /** | 496 | /** |
497 | * Turns a button into an autorepeat button. | 497 | * Turns a button into an autorepeat button. |
498 | * | 498 | * |
499 | * Toggle buttons, buttons with menus, or | 499 | * Toggle buttons, buttons with menus, or |
500 | * buttons with delayed menus cannot be made into autorepeat buttons. | 500 | * buttons with delayed menus cannot be made into autorepeat buttons. |
501 | * Moreover, you can and will receive | 501 | * Moreover, you can and will receive |
502 | * only the signal clicked(), but not pressed() or released(). | 502 | * only the signal clicked(), but not pressed() or released(). |
503 | * When the user presses this button, you will receive the signal clicked(), | 503 | * When the user presses this button, you will receive the signal clicked(), |
504 | * and if the button is still pressed after some time, | 504 | * and if the button is still pressed after some time, |
505 | * you will receive more clicked() signals separated by regular | 505 | * you will receive more clicked() signals separated by regular |
506 | * intervals. Since this uses @ref QButton::setAutoRepeat() , | 506 | * intervals. Since this uses @ref QButton::setAutoRepeat() , |
507 | * I can't quantify 'some'. | 507 | * I can't quantify 'some'. |
508 | */ | 508 | */ |
509 | void setAutoRepeat (int id, bool flag=true); | 509 | void setAutoRepeat (int id, bool flag=true); |
510 | 510 | ||
511 | 511 | ||
512 | /** | 512 | /** |
513 | * Turns button into a toggle button if @p flag is true. | 513 | * Turns button into a toggle button if @p flag is true. |
514 | */ | 514 | */ |
515 | void setToggle (int id, bool flag = true); | 515 | void setToggle (int id, bool flag = true); |
516 | 516 | ||
517 | /** | 517 | /** |
518 | * Toggles a togglebutton. | 518 | * Toggles a togglebutton. |
519 | * | 519 | * |
520 | * If the button is a toggle button (see @ref setToggle()) | 520 | * If the button is a toggle button (see @ref setToggle()) |
521 | * the button state will be toggled. This will also cause the toolbar to | 521 | * the button state will be toggled. This will also cause the toolbar to |
522 | * emit the signal @ref KButton::toggled() with parameter @p id. You must connect to | 522 | * emit the signal @ref KButton::toggled() with parameter @p id. You must connect to |
523 | * this signal, or use @ref addConnection() to connect directly to the | 523 | * this signal, or use @ref addConnection() to connect directly to the |
524 | * button signal @ref KButton::toggled(). | 524 | * button signal @ref KButton::toggled(). |
525 | */ | 525 | */ |
526 | void toggleButton (int id); | 526 | void toggleButton (int id); |
527 | 527 | ||
528 | /** | 528 | /** |
529 | * Sets a toggle button state. | 529 | * Sets a toggle button state. |
530 | * | 530 | * |
531 | * If the button is a toggle button (see @ref setToggle()) | 531 | * If the button is a toggle button (see @ref setToggle()) |
532 | * this will set its state flag. This will also emit the signal | 532 | * this will set its state flag. This will also emit the signal |
533 | * @ref KButton::toggled(). | 533 | * @ref KButton::toggled(). |
534 | * | 534 | * |
535 | * @see setToggle() | 535 | * @see setToggle() |
536 | */ | 536 | */ |
537 | void setButton (int id, bool flag); | 537 | void setButton (int id, bool flag); |
538 | 538 | ||
539 | /** | 539 | /** |
540 | * @return @p true if button is on, @p false if button is off or if the | 540 | * @return @p true if button is on, @p false if button is off or if the |
541 | * button is not a toggle button. | 541 | * button is not a toggle button. |
542 | * @see setToggle() | 542 | * @see setToggle() |
543 | */ | 543 | */ |
544 | bool isButtonOn (int id) const; | 544 | bool isButtonOn (int id) const; |
545 | 545 | ||
546 | /** | 546 | /** |
547 | * Sets the text of a line editor. | 547 | * Sets the text of a line editor. |
548 | * | 548 | * |
549 | * Cursor is set at end of text. | 549 | * Cursor is set at end of text. |
550 | */ | 550 | */ |
551 | void setLinedText (int id, const QString& text); | 551 | void setLinedText (int id, const QString& text); |
552 | 552 | ||
553 | /** | 553 | /** |
554 | * Returns a line editor text. | 554 | * Returns a line editor text. |
555 | */ | 555 | */ |
556 | QString getLinedText (int id) const; | 556 | QString getLinedText (int id) const; |
557 | 557 | ||
558 | /** | 558 | /** |
559 | * Inserts @p text in combobox @p id at position @p index. | 559 | * Inserts @p text in combobox @p id at position @p index. |
560 | */ | 560 | */ |
561 | void insertComboItem (int id, const QString& text, int index); | 561 | void insertComboItem (int id, const QString& text, int index); |
562 | 562 | ||
563 | /** | 563 | /** |
564 | * Inserts @p list in combobox @p id at position @p index. | 564 | * Inserts @p list in combobox @p id at position @p index. |
565 | */ | 565 | */ |
566 | void insertComboList (int id, const QStringList &list, int index); | 566 | void insertComboList (int id, const QStringList &list, int index); |
567 | 567 | ||
568 | /** | 568 | /** |
569 | * Removes item @p index from combobox @p id. | 569 | * Removes item @p index from combobox @p id. |
570 | */ | 570 | */ |
571 | void removeComboItem (int id, int index); | 571 | void removeComboItem (int id, int index); |
572 | 572 | ||
573 | /** | 573 | /** |
574 | * Sets item @p index to be current item in combobox @p id. | 574 | * Sets item @p index to be current item in combobox @p id. |
575 | */ | 575 | */ |
576 | void setCurrentComboItem (int id, int index); | 576 | void setCurrentComboItem (int id, int index); |
577 | 577 | ||
578 | /** | 578 | /** |
579 | * Changes item @p index in combobox @p id to text. | 579 | * Changes item @p index in combobox @p id to text. |
580 | * | 580 | * |
581 | * @p index = -1 refers current item (one displayed in the button). | 581 | * @p index = -1 refers current item (one displayed in the button). |
582 | */ | 582 | */ |
583 | void changeComboItem (int id, const QString& text, int index=-1); | 583 | void changeComboItem (int id, const QString& text, int index=-1); |
584 | 584 | ||
585 | /** | 585 | /** |
586 | * Clears the combobox @p id. | 586 | * Clears the combobox @p id. |
587 | * | 587 | * |
588 | * Does not delete it or hide it. | 588 | * Does not delete it or hide it. |
589 | */ | 589 | */ |
590 | void clearCombo (int id); | 590 | void clearCombo (int id); |
591 | 591 | ||
592 | /** | 592 | /** |
593 | * Returns text of item @p index from combobox @p id. | 593 | * Returns text of item @p index from combobox @p id. |
594 | * | 594 | * |
595 | * @p index = -1 refers to current item. | 595 | * @p index = -1 refers to current item. |
596 | */ | 596 | */ |
597 | 597 | ||
598 | QString getComboItem (int id, int index=-1) const; | 598 | QString getComboItem (int id, int index=-1) const; |
599 | 599 | ||
600 | /** | 600 | /** |
601 | * Returns a pointer to the combobox. | 601 | * Returns a pointer to the combobox. |
602 | * | 602 | * |
603 | * Example: | 603 | * Example: |
604 | * <pre> | 604 | * <pre> |
605 | * KComboBox *combo = toolbar->getCombo(combo_id); | 605 | * KComboBox *combo = toolbar->getCombo(combo_id); |
606 | * </pre> | 606 | * </pre> |
607 | * That way you can get access to other public methods | 607 | * That way you can get access to other public methods |
608 | * that @ref KComboBox provides. | 608 | * that @ref KComboBox provides. |
609 | */ | 609 | */ |
610 | KComboBox * getCombo(int id); | 610 | KComboBox * getCombo(int id); |
611 | 611 | ||
612 | /** | 612 | /** |
613 | * Returns a pointer to KToolBarLined. | 613 | * Returns a pointer to KToolBarLined. |
614 | * | 614 | * |
615 | * Example: | 615 | * Example: |
616 | * <pre> | 616 | * <pre> |
617 | * KLineEdit * lined = toolbar->getKToolBarLined(lined_id); | 617 | * KLineEdit * lined = toolbar->getKToolBarLined(lined_id); |
618 | * </pre> | 618 | * </pre> |
619 | * That way you can get access to other public methods | 619 | * That way you can get access to other public methods |
620 | * that @ref KLineEdit provides. @ref KLineEdit is the same thing | 620 | * that @ref KLineEdit provides. @ref KLineEdit is the same thing |
621 | * as @ref QLineEdit plus completion signals. | 621 | * as @ref QLineEdit plus completion signals. |
622 | */ | 622 | */ |
623 | KLineEdit * getLined (int id); | 623 | KLineEdit * getLined (int id); |
624 | 624 | ||
625 | /** | 625 | /** |
626 | * Returns a pointer to KToolBarButton. | 626 | * Returns a pointer to KToolBarButton. |
627 | * | 627 | * |
628 | * Example: | 628 | * Example: |
629 | * <pre> | 629 | * <pre> |
630 | * KToolBarButton * button = toolbar->getButton(button_id); | 630 | * KToolBarButton * button = toolbar->getButton(button_id); |
631 | * </pre> | 631 | * </pre> |
632 | * That way you can get access to other public methods | 632 | * That way you can get access to other public methods |
633 | * that @ref KToolBarButton provides. | 633 | * that @ref KToolBarButton provides. |
634 | * | 634 | * |
635 | * Using this method is not recommended. | 635 | * Using this method is not recommended. |
636 | */ | 636 | */ |
637 | KToolBarButton * getButton (int id); | 637 | KToolBarButton * getButton (int id); |
638 | 638 | ||
639 | /** | 639 | /** |
640 | * Align item to the right. | 640 | * Align item to the right. |
641 | * | 641 | * |
642 | * This works only if toolbar is set to full width. | 642 | * This works only if toolbar is set to full width. |
643 | * @see setFullWidth() | 643 | * @see setFullWidth() |
644 | */ | 644 | */ |
645 | void alignItemRight (int id, bool right = true); | 645 | void alignItemRight (int id, bool right = true); |
646 | 646 | ||
647 | /** | 647 | /** |
648 | * Returns a pointer to an inserted widget. | 648 | * Returns a pointer to an inserted widget. |
649 | * | 649 | * |
650 | * Wrong ids are not tested. | 650 | * Wrong ids are not tested. |
651 | * You can do with this whatever you want, | 651 | * You can do with this whatever you want, |
652 | * except change its height (hardcoded). If you change its width | 652 | * except change its height (hardcoded). If you change its width |
653 | * you will probably have to call QToolBar::updateRects(true) | 653 | * you will probably have to call QToolBar::updateRects(true) |
654 | * @see QWidget | 654 | * @see QWidget |
655 | * @see updateRects() | 655 | * @see updateRects() |
656 | * | 656 | * |
657 | * KDE4: make this const! | 657 | * KDE4: make this const! |
658 | */ | 658 | */ |
659 | QWidget *getWidget (int id); | 659 | QWidget *getWidget (int id); |
660 | 660 | ||
661 | /** | 661 | /** |
662 | * Set item autosized. | 662 | * Set item autosized. |
663 | * | 663 | * |
664 | * This works only if the toolbar is set to full width. | 664 | * This works only if the toolbar is set to full width. |
665 | * Only @p one item can be autosized, and it has to be | 665 | * Only @p one item can be autosized, and it has to be |
666 | * the last left-aligned item. Items that come after this must be right | 666 | * the last left-aligned item. Items that come after this must be right |
667 | * aligned. Items that can be right aligned are Lineds, Frames, Widgets and | 667 | * aligned. Items that can be right aligned are Lineds, Frames, Widgets and |
668 | * Combos. An autosized item will resize itself whenever the toolbar geometry | 668 | * Combos. An autosized item will resize itself whenever the toolbar geometry |
669 | * changes to the last right-aligned item (or to end of toolbar if there | 669 | * changes to the last right-aligned item (or to end of toolbar if there |
670 | * are no right-aligned items.) | 670 | * are no right-aligned items.) |
671 | * @see setFullWidth() | 671 | * @see setFullWidth() |
672 | * @see alignItemRight() | 672 | * @see alignItemRight() |
673 | */ | 673 | */ |
674 | void setItemAutoSized (int id, bool yes = true); | 674 | void setItemAutoSized (int id, bool yes = true); |
675 | 675 | ||
676 | /** | 676 | /** |
677 | * Remove all items. | 677 | * Remove all items. |
678 | * | 678 | * |
679 | * The toolbar is redrawn after it. | 679 | * The toolbar is redrawn after it. |
680 | */ | 680 | */ |
681 | void clear (); | 681 | void clear (); |
682 | 682 | ||
683 | /** | 683 | /** |
684 | * Remove item @p id. | 684 | * Remove item @p id. |
685 | * | 685 | * |
686 | * Item is deleted. Toolbar is redrawn after it. | 686 | * Item is deleted. Toolbar is redrawn after it. |
687 | */ | 687 | */ |
688 | void removeItem (int id); | 688 | void removeItem (int id); |
689 | 689 | ||
690 | /** | 690 | /** |
691 | * Remove item @p id. | 691 | * Remove item @p id. |
692 | * | 692 | * |
693 | * Item is deleted when toolbar is redrawn. | 693 | * Item is deleted when toolbar is redrawn. |
694 | */ | 694 | */ |
695 | void removeItemDelayed (int id); | 695 | void removeItemDelayed (int id); |
696 | 696 | ||
697 | /** | 697 | /** |
698 | * Hide item. | 698 | * Hide item. |
699 | */ | 699 | */ |
700 | void hideItem (int id); | 700 | void hideItem (int id); |
701 | 701 | ||
702 | /** | 702 | /** |
703 | * Show item. | 703 | * Show item. |
704 | */ | 704 | */ |
705 | void showItem (int id); | 705 | void showItem (int id); |
706 | 706 | ||
707 | /** | 707 | /** |
708 | * Returns the index of the given item. | 708 | * Returns the index of the given item. |
709 | * | 709 | * |
710 | * KDE4: make this const! | 710 | * KDE4: make this const! |
711 | */ | 711 | */ |
712 | int itemIndex (int id); | 712 | int itemIndex (int id); |
713 | 713 | ||
714 | /** | 714 | /** |
715 | * Set toolbar to full parent size (default). | 715 | * Set toolbar to full parent size (default). |
716 | * | 716 | * |
717 | * In full size mode the bar | 717 | * In full size mode the bar |
718 | * extends over the parent's full width or height. If the mode is disabled | 718 | * extends over the parent's full width or height. If the mode is disabled |
719 | * the toolbar tries to take as much space as it needs without wrapping, but | 719 | * the toolbar tries to take as much space as it needs without wrapping, but |
720 | * it does not exceed the parent box. You can force a certain width or | 720 | * it does not exceed the parent box. You can force a certain width or |
721 | * height with @ref setMaxWidth() or @ref setMaxHeight(). | 721 | * height with @ref setMaxWidth() or @ref setMaxHeight(). |
722 | * | 722 | * |
723 | * If you want to use right-aligned items or auto-sized items you must use | 723 | * If you want to use right-aligned items or auto-sized items you must use |
724 | * full size mode. | 724 | * full size mode. |
725 | */ | 725 | */ |
726 | void setFullSize(bool flag = true); | 726 | void setFullSize(bool flag = true); |
727 | 727 | ||
728 | /** | 728 | /** |
729 | * @return @p true if the full-size mode is enabled. Otherwise | 729 | * @return @p true if the full-size mode is enabled. Otherwise |
730 | * it returns @false. | 730 | * it returns @false. |
731 | */ | 731 | */ |
732 | bool fullSize() const; | 732 | bool fullSize() const; |
733 | 733 | ||
734 | /** | 734 | /** |
735 | * @deprecated use setMovingEnabled(bool) instead. | 735 | * @deprecated use setMovingEnabled(bool) instead. |
736 | * Enable or disable moving of toolbar. | 736 | * Enable or disable moving of toolbar. |
737 | */ | 737 | */ |
738 | void enableMoving(bool flag = true); | 738 | void enableMoving(bool flag = true); |
739 | 739 | ||
740 | /** | 740 | /** |
741 | * Set position of toolbar. | 741 | * Set position of toolbar. |
742 | * @see BarPosition() | 742 | * @see BarPosition() |
743 | */ | 743 | */ |
744 | void setBarPos (BarPosition bpos); | 744 | void setBarPos (BarPosition bpos); |
745 | 745 | ||
746 | /** | 746 | /** |
747 | * Returns position of toolbar. | 747 | * Returns position of toolbar. |
748 | */ | 748 | */ |
749 | BarPosition barPos(); | 749 | BarPosition barPos(); |
750 | 750 | ||
751 | /** | 751 | /** |
752 | * @deprecated | 752 | * @deprecated |
753 | * Show, hide, or toggle toolbar. | 753 | * Show, hide, or toggle toolbar. |
754 | * | 754 | * |
755 | * This method is provided for compatibility only, | 755 | * This method is provided for compatibility only, |
756 | * please use show() and/or hide() instead. | 756 | * please use show() and/or hide() instead. |
757 | * @see BarStatus | 757 | * @see BarStatus |
758 | */ | 758 | */ |
759 | bool enable(BarStatus stat); | 759 | bool enable(BarStatus stat); |
760 | 760 | ||
761 | /** | 761 | /** |
762 | * @deprecated | 762 | * @deprecated |
763 | * Use setMaximumHeight() instead. | 763 | * Use setMaximumHeight() instead. |
764 | */ | 764 | */ |
765 | void setMaxHeight (int h); // Set max height for vertical toolbars | 765 | void setMaxHeight (int h); // Set max height for vertical toolbars |
766 | 766 | ||
767 | /** | 767 | /** |
768 | * @deprecated | 768 | * @deprecated |
769 | * Use maximumHeight() instead. | 769 | * Use maximumHeight() instead. |
770 | * Returns the value that was set with @ref setMaxHeight(). | 770 | * Returns the value that was set with @ref setMaxHeight(). |
771 | */ | 771 | */ |
772 | int maxHeight(); | 772 | int maxHeight(); |
773 | 773 | ||
774 | /** | 774 | /** |
775 | * @deprecated | 775 | * @deprecated |
776 | * Use setMaximumWidth() instead. | 776 | * Use setMaximumWidth() instead. |
777 | * Set maximal width of horizontal (top or bottom) toolbar. | 777 | * Set maximal width of horizontal (top or bottom) toolbar. |
778 | */ | 778 | */ |
779 | void setMaxWidth (int dw); | 779 | void setMaxWidth (int dw); |
780 | 780 | ||
781 | /** | 781 | /** |
782 | * @deprecated | 782 | * @deprecated |
783 | * Use maximumWidth() instead. | 783 | * Use maximumWidth() instead. |
784 | * Returns the value that was set with @ref setMaxWidth(). | 784 | * Returns the value that was set with @ref setMaxWidth(). |
785 | */ | 785 | */ |
786 | int maxWidth(); | 786 | int maxWidth(); |
787 | 787 | ||
788 | /** | 788 | /** |
789 | * Set title for toolbar when it floats. | 789 | * Set title for toolbar when it floats. |
790 | * | 790 | * |
791 | * Titles are however not (yet) | 791 | * Titles are however not (yet) |
792 | * visible. You can't change toolbar's title while it's floating. | 792 | * visible. You can't change toolbar's title while it's floating. |
793 | */ | 793 | */ |
794 | void setTitle (const QString& _title); | 794 | void setTitle (const QString& _title); |
795 | 795 | ||
796 | /** | 796 | /** |
797 | * @deprecated | 797 | * @deprecated |
798 | * Use enableMoving() instead. | 798 | * Use enableMoving() instead. |
799 | */ | 799 | */ |
800 | void enableFloating (bool arrrrrrgh); | 800 | void enableFloating (bool arrrrrrgh); |
801 | 801 | ||
802 | /** | 802 | /** |
803 | * Set the kind of painting for buttons. | 803 | * Set the kind of painting for buttons. |
804 | * | 804 | * |
805 | * Choose from: | 805 | * Choose from: |
806 | * @li IconOnly (only icons), | 806 | * @li IconOnly (only icons), |
807 | * @li IconTextRight (icon and text, text is left from icons), | 807 | * @li IconTextRight (icon and text, text is left from icons), |
808 | * @li TextOnly (only text), | 808 | * @li TextOnly (only text), |
809 | * @li IconTextBottom (icons and text, text is under icons). | 809 | * @li IconTextBottom (icons and text, text is under icons). |
810 | * @see IconText | 810 | * @see IconText |
811 | * | 811 | * |
812 | */ | 812 | */ |
813 | void setIconText(IconText it); | 813 | void setIconText(IconText it); |
814 | // Note: don't merge with the next one, it breaks Qt properties | 814 | // Note: don't merge with the next one, it breaks Qt properties |
815 | 815 | ||
816 | /** | 816 | /** |
817 | * Similar to @ref setIconText(IconText it) but allows you to | 817 | * Similar to @ref setIconText(IconText it) but allows you to |
818 | * disable or enable updating. If @p update is false, then the | 818 | * disable or enable updating. If @p update is false, then the |
819 | * buttons will not be updated. This is useful only if you know | 819 | * buttons will not be updated. This is useful only if you know |
820 | * that you will be forcing an update later. | 820 | * that you will be forcing an update later. |
821 | */ | 821 | */ |
822 | void setIconText(IconText it, bool update); | 822 | void setIconText(IconText it, bool update); |
823 | 823 | ||
824 | /** | 824 | /** |
825 | * @return The current text style for buttons. | 825 | * @return The current text style for buttons. |
826 | */ | 826 | */ |
827 | IconText iconText() const; | 827 | IconText iconText() const; |
828 | 828 | ||
829 | /** | 829 | /** |
830 | * Set the icon size to load. Usually you should not call | 830 | * Set the icon size to load. Usually you should not call |
831 | * this, the icon size is taken care of by KIconLoader | 831 | * this, the icon size is taken care of by KIconLoader |
832 | * and globally configured. | 832 | * and globally configured. |
833 | * By default, the toolbar will load icons of size 32 for main | 833 | * By default, the toolbar will load icons of size 32 for main |
834 | * toolbars and 22 for other toolbars | 834 | * toolbars and 22 for other toolbars |
835 | * @see KIconLoader. | 835 | * @see KIconLoader. |
836 | * | 836 | * |
837 | * @param size The size to use | 837 | * @param size The size to use |
838 | */ | 838 | */ |
839 | void setIconSize(int size); | 839 | void setIconSize(int size); |
840 | // Note: don't merge with the next one, it breaks Qt properties | 840 | // Note: don't merge with the next one, it breaks Qt properties |
841 | 841 | ||
842 | /** | 842 | /** |
843 | * Same as @ref setIconText(int size) but allows you | 843 | * Same as @ref setIconText(int size) but allows you |
844 | * to disable the toolbar update. | 844 | * to disable the toolbar update. |
845 | * | 845 | * |
846 | * @param size The size to use | 846 | * @param size The size to use |
847 | * @param update If true, then the toolbar will be updated after | 847 | * @param update If true, then the toolbar will be updated after |
848 | * this | 848 | * this |
849 | */ | 849 | */ |
850 | void setIconSize(int size, bool update); | 850 | void setIconSize(int size, bool update); |
851 | 851 | ||
852 | /** | 852 | /** |
853 | * @return The current icon size for buttons. | 853 | * @return The current icon size for buttons. |
854 | */ | 854 | */ |
855 | int iconSize() const; | 855 | int iconSize() const; |
856 | 856 | ||
857 | /** | 857 | /** |
858 | * This allows you to enable or disable the context menu. | 858 | * This allows you to enable or disable the context menu. |
859 | * | 859 | * |
860 | * @param enable If false, then the context menu will be disabled | 860 | * @param enable If false, then the context menu will be disabled |
861 | */ | 861 | */ |
862 | void setEnableContextMenu(bool enable = true); | 862 | void setEnableContextMenu(bool enable = true); |
863 | 863 | ||
864 | /** | 864 | /** |
865 | * Returns whether or not the context menu is disabled | 865 | * Returns whether or not the context menu is disabled |
866 | * | 866 | * |
867 | * @return The context menu state | 867 | * @return The context menu state |
868 | */ | 868 | */ |
869 | bool contextMenuEnabled() const; | 869 | bool contextMenuEnabled() const; |
870 | 870 | ||
871 | /** | 871 | /** |
872 | * This will inform a toolbar button to ignore certain style | 872 | * This will inform a toolbar button to ignore certain style |
873 | * changes. Specifically, it will ignore IconText (always IconOnly) | 873 | * changes. Specifically, it will ignore IconText (always IconOnly) |
874 | * and will not allow image effects to apply. | 874 | * and will not allow image effects to apply. |
875 | * | 875 | * |
876 | * @param id The button to exclude from styles | 876 | * @param id The button to exclude from styles |
877 | * @param no_style If true, then it is excluded (default: true). | 877 | * @param no_style If true, then it is excluded (default: true). |
878 | */ | 878 | */ |
879 | void setItemNoStyle(int id, bool no_style = true); | 879 | void setItemNoStyle(int id, bool no_style = true); |
880 | 880 | ||
881 | void setFlat (bool flag); | 881 | void setFlat (bool flag); |
882 | 882 | ||
883 | /** | 883 | /** |
884 | * @return the number of items in the toolbar | 884 | * @return the number of items in the toolbar |
885 | */ | 885 | */ |
886 | int count() const; | 886 | int count() const; |
887 | 887 | ||
888 | /** | 888 | /** |
889 | * Instruct the toolbar to save it's current state to either the app | 889 | * Instruct the toolbar to save it's current state to either the app |
890 | * config file or to the XML-GUI resource file (whichever has | 890 | * config file or to the XML-GUI resource file (whichever has |
891 | * precedence). | 891 | * precedence). |
892 | */ | 892 | */ |
893 | void saveState(); | 893 | void saveState(); |
894 | 894 | ||
895 | /** | 895 | /** |
896 | * Save the toolbar settings to group @p configGroup in @p config. | 896 | * Save the toolbar settings to group @p configGroup in @p config. |
897 | */ | 897 | */ |
898 | void saveSettings(KConfig *config, const QString &configGroup); | 898 | void saveSettings(KConfig *config, const QString &configGroup); |
899 | 899 | ||
900 | /** | 900 | /** |
901 | * Read the toolbar settings from group @p configGroup in @p config | 901 | * Read the toolbar settings from group @p configGroup in @p config |
902 | * and apply them. | 902 | * and apply them. |
903 | */ | 903 | */ |
904 | void applySettings(KConfig *config, const QString &configGroup); | 904 | void applySettings(KConfig *config, const QString &configGroup); |
905 | 905 | ||
906 | /** | 906 | /** |
907 | * Tell the toolbar what XML-GUI resource file it should use to save | 907 | * Tell the toolbar what XML-GUI resource file it should use to save |
908 | * it's state. The state of the toolbar (position, size, etc) is | 908 | * it's state. The state of the toolbar (position, size, etc) is |
909 | * saved in KConfig files if the application does not use XML-GUI.. | 909 | * saved in KConfig files if the application does not use XML-GUI.. |
910 | * but if the app does, then it's saved the XML file. This function | 910 | * but if the app does, then it's saved the XML file. This function |
911 | * allows this to happen. | 911 | * allows this to happen. |
912 | * | 912 | * |
913 | * @param xmlfile The XML-GUI resource file to write to | 913 | * @param xmlfile The XML-GUI resource file to write to |
914 | * @param xml The DOM document for the XML-GUI building | 914 | * @param xml The DOM document for the XML-GUI building |
915 | */ | 915 | */ |
916 | // void setXML(const QString& xmlfile, const QDomDocument& xml); | 916 | // void setXML(const QString& xmlfile, const QDomDocument& xml); |
917 | /* @internal */ | 917 | /* @internal */ |
918 | void setXMLGUIClient( KXMLGUIClient *client ); | 918 | void setXMLGUIClient( KXMLGUIClient *client ); |
919 | 919 | ||
920 | /** | 920 | /** |
921 | * Assign a (translated) text to this toolbar. This is used | 921 | * Assign a (translated) text to this toolbar. This is used |
922 | * for the tooltip on the handle, and when listing the toolbars. | 922 | * for the tooltip on the handle, and when listing the toolbars. |
923 | */ | 923 | */ |
924 | void setText( const QString & txt ); | 924 | void setText( const QString & txt ); |
925 | 925 | ||
926 | /** | 926 | /** |
927 | * @return the toolbar's text. | 927 | * @return the toolbar's text. |
928 | */ | 928 | */ |
929 | QString text() const; | 929 | QString text() const; |
930 | 930 | ||
931 | void setStretchableWidget( QWidget *w ); | 931 | void setStretchableWidget( QWidget *w ); |
932 | QSizePolicy sizePolicy() const; | 932 | QSizePolicy sizePolicy() const; |
933 | bool highlight() const; | 933 | bool highlight() const; |
934 | QSize sizeHint() const; | 934 | QSize sizeHint() const; |
935 | QSize minimumSizeHint() const; | 935 | QSize minimumSizeHint() const; |
936 | QSize minimumSize() const; | 936 | QSize minimumSize() const; |
937 | 937 | ||
938 | void hide(); | 938 | void hide(); |
939 | void show(); | 939 | void show(); |
940 | 940 | ||
941 | void updateRects( bool = FALSE ) {} | 941 | void updateRects( bool = FALSE ) {} |
942 | 942 | ||
943 | //US void loadState( const QDomElement &e ); | 943 | //US void loadState( const QDomElement &e ); |
944 | //US void saveState( QDomElement &e ); | 944 | //US void saveState( QDomElement &e ); |
945 | 945 | ||
946 | /** | 946 | /** |
947 | * @internal | 947 | * @internal |
948 | */ | 948 | */ |
949 | void positionYourself( bool force = false); | 949 | void positionYourself( bool force = false); |
950 | 950 | ||
951 | signals: | 951 | signals: |
952 | /** | 952 | /** |
953 | * Emitted when button @p id is clicked. | 953 | * Emitted when button @p id is clicked. |
954 | */ | 954 | */ |
955 | void clicked(int id); | 955 | void clicked(int id); |
956 | 956 | ||
957 | /** | 957 | /** |
958 | * Emitted when button @p id is double-clicked. | 958 | * Emitted when button @p id is double-clicked. |
959 | * | 959 | * |
960 | * Note: you will always | 960 | * Note: you will always |
961 | * recive two @ref clicked() , @ref pressed() and @ref released() signals. | 961 | * recive two @ref clicked() , @ref pressed() and @ref released() signals. |
962 | * There is no way to avoid it - at least no easy way. | 962 | * There is no way to avoid it - at least no easy way. |
963 | * If you need to resolve this all you can do is set up timers | 963 | * If you need to resolve this all you can do is set up timers |
964 | * which wait for @ref QApplication::doubleClickInterval() to expire. | 964 | * which wait for @ref QApplication::doubleClickInterval() to expire. |
965 | * If in that time you don't get this signal, you may belive that | 965 | * If in that time you don't get this signal, you may belive that |
966 | * button was only clicked and not double-clicked. | 966 | * button was only clicked and not double-clicked. |
967 | * And please note that butons with popup menus do not emit this signal, | 967 | * And please note that butons with popup menus do not emit this signal, |
968 | * but those with delayed popup do. | 968 | * but those with delayed popup do. |
969 | */ | 969 | */ |
970 | void doubleClicked (int id); | 970 | void doubleClicked (int id); |
971 | 971 | ||
972 | /** | 972 | /** |
973 | * Emitted when button @p id is pressed. | 973 | * Emitted when button @p id is pressed. |
974 | */ | 974 | */ |
975 | void pressed(int); | 975 | void pressed(int); |
976 | 976 | ||
977 | /** | 977 | /** |
978 | * Emits when button @p id is released. | 978 | * Emits when button @p id is released. |
979 | */ | 979 | */ |
980 | void released(int); | 980 | void released(int); |
981 | 981 | ||
982 | /** | 982 | /** |
983 | * Emitted when a toggle button changes state. | 983 | * Emitted when a toggle button changes state. |
984 | * | 984 | * |
985 | * Emitted also if you change state | 985 | * Emitted also if you change state |
986 | * with @ref setButton() or @ref toggleButton() | 986 | * with @ref setButton() or @ref toggleButton() |
987 | * If you make a button normal again, with | 987 | * If you make a button normal again, with |
988 | * setToggle(false), this signal won't | 988 | * setToggle(false), this signal won't |
989 | * be emitted. | 989 | * be emitted. |
990 | */ | 990 | */ |
991 | void toggled(int); | 991 | void toggled(int); |
992 | 992 | ||
993 | /** | 993 | /** |
994 | * This signal is emitted when item id gets highlighted/unhighlighted | 994 | * This signal is emitted when item id gets highlighted/unhighlighted |
995 | * (i.e when mouse enters/exits). | 995 | * (i.e when mouse enters/exits). |
996 | * | 996 | * |
997 | * Note that this signal is emitted from | 997 | * Note that this signal is emitted from |
998 | * all buttons (normal, disabled and toggle) even when there is no visible | 998 | * all buttons (normal, disabled and toggle) even when there is no visible |
999 | * change in buttons (i.e., buttons do not raise when mouse enters). | 999 | * change in buttons (i.e., buttons do not raise when mouse enters). |
1000 | * The parameter @p isHighlighted is @p true when mouse enters and @p false when | 1000 | * The parameter @p isHighlighted is @p true when mouse enters and @p false when |
1001 | * mouse exits. | 1001 | * mouse exits. |
1002 | */ | 1002 | */ |
1003 | void highlighted(int id, bool isHighlighted); | 1003 | void highlighted(int id, bool isHighlighted); |
1004 | 1004 | ||
1005 | /** | 1005 | /** |
1006 | * This signal is emitted when item id gets highlighted/unhighlighted | 1006 | * This signal is emitted when item id gets highlighted/unhighlighted |
1007 | * (i.e when mouse enters/exits). | 1007 | * (i.e when mouse enters/exits). |
1008 | * | 1008 | * |
1009 | * Note that this signal is emitted from | 1009 | * Note that this signal is emitted from |
1010 | * all buttons (normal, disabled and toggle) even when there is no visible | 1010 | * all buttons (normal, disabled and toggle) even when there is no visible |
1011 | * change in buttons (i.e., buttons do not raise when mouse enters). | 1011 | * change in buttons (i.e., buttons do not raise when mouse enters). |
1012 | */ | 1012 | */ |
1013 | void highlighted(int id ); | 1013 | void highlighted(int id ); |
1014 | 1014 | ||
1015 | /** | 1015 | /** |
1016 | * Emitted when toolbar changes position, or when | 1016 | * Emitted when toolbar changes position, or when |
1017 | * an item is removed from toolbar. | 1017 | * an item is removed from toolbar. |
1018 | * | 1018 | * |
1019 | * If you subclass @ref KMainWindow and reimplement | 1019 | * If you subclass @ref KMainWindow and reimplement |
1020 | * @ref KMainWindow::resizeEvent() be sure to connect to | 1020 | * @ref KMainWindow::resizeEvent() be sure to connect to |
1021 | * this signal. Note: You can connect this signal to a slot that | 1021 | * this signal. Note: You can connect this signal to a slot that |
1022 | * doesn't take parameter. | 1022 | * doesn't take parameter. |
1023 | */ | 1023 | */ |
1024 | void moved( BarPosition ); | 1024 | void moved( BarPosition ); |
1025 | 1025 | ||
1026 | /** | 1026 | /** |
1027 | * @internal | 1027 | * @internal |
1028 | * This signal is emitted when toolbar detects changing of | 1028 | * This signal is emitted when toolbar detects changing of |
1029 | * following parameters: | 1029 | * following parameters: |
1030 | * highlighting, button-size, button-mode. This signal is | 1030 | * highlighting, button-size, button-mode. This signal is |
1031 | * internal, aimed to buttons. | 1031 | * internal, aimed to buttons. |
1032 | */ | 1032 | */ |
1033 | void modechange (); | 1033 | void modechange (); |
1034 | 1034 | ||
1035 | /** | 1035 | /** |
1036 | * This signal is emitted when the toolbar is getting deleted, | 1036 | * This signal is emitted when the toolbar is getting deleted, |
1037 | * and before ~KToolbar finishes (so it's still time to remove | 1037 | * and before ~KToolbar finishes (so it's still time to remove |
1038 | * widgets from the toolbar). | 1038 | * widgets from the toolbar). |
1039 | * Used by KWidgetAction. | 1039 | * Used by KWidgetAction. |
1040 | * @since 3.2 | 1040 | * @since 3.2 |
1041 | */ | 1041 | */ |
1042 | void toolbarDestroyed(); | 1042 | void toolbarDestroyed(); |
1043 | 1043 | ||
1044 | public: | 1044 | public: |
1045 | /** | 1045 | /** |
1046 | * @return global setting for "Highlight buttons under mouse" | 1046 | * @return global setting for "Highlight buttons under mouse" |
1047 | */ | 1047 | */ |
1048 | void repaintMe(); | ||
1048 | static bool highlightSetting(); | 1049 | static bool highlightSetting(); |
1049 | 1050 | ||
1050 | /** | 1051 | /** |
1051 | * @return global setting for "Toolbars transparent when moving" | 1052 | * @return global setting for "Toolbars transparent when moving" |
1052 | */ | 1053 | */ |
1053 | static bool transparentSetting(); | 1054 | static bool transparentSetting(); |
1054 | 1055 | ||
1055 | /** | 1056 | /** |
1056 | * @return global setting for "Icon Text" | 1057 | * @return global setting for "Icon Text" |
1057 | */ | 1058 | */ |
1058 | static IconText iconTextSetting(); | 1059 | static IconText iconTextSetting(); |
1059 | 1060 | ||
1060 | public slots: | 1061 | public slots: |
1061 | virtual void setIconText( const QString &txt ) | 1062 | virtual void setIconText( const QString &txt ) |
1062 | { QToolBar::setIconText( txt ); } | 1063 | { QToolBar::setIconText( txt ); } |
1064 | void slotRepaint(); | ||
1063 | 1065 | ||
1064 | protected: | 1066 | protected: |
1065 | void mousePressEvent( QMouseEvent * ); | 1067 | void mousePressEvent( QMouseEvent * ); |
1066 | void childEvent( QChildEvent *e ); | 1068 | void childEvent( QChildEvent *e ); |
1067 | void showEvent( QShowEvent *e ); | 1069 | void showEvent( QShowEvent *e ); |
1068 | void resizeEvent( QResizeEvent *e ); | 1070 | void resizeEvent( QResizeEvent *e ); |
1069 | bool event( QEvent *e ); | 1071 | bool event( QEvent *e ); |
1070 | void applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal = false); | 1072 | void applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal = false); |
1071 | QString settingsGroup(); | 1073 | QString settingsGroup(); |
1072 | 1074 | ||
1073 | private slots: | 1075 | private slots: |
1074 | void rebuildLayout(); | 1076 | void rebuildLayout(); |
1075 | void slotReadConfig (); | 1077 | void slotReadConfig (); |
1076 | void slotAppearanceChanged(); | 1078 | void slotAppearanceChanged(); |
1077 | void slotIconChanged(int); | 1079 | void slotIconChanged(int); |
1078 | void slotRepaint(); | ||
1079 | void toolBarPosChanged( QToolBar *tb ); | 1080 | void toolBarPosChanged( QToolBar *tb ); |
1080 | void slotContextAboutToShow(); | 1081 | void slotContextAboutToShow(); |
1081 | void widgetDestroyed(); | 1082 | void widgetDestroyed(); |
1082 | 1083 | ||
1083 | private: | 1084 | private: |
1084 | void init( bool readConfig = true, bool honorStyle = false ); | 1085 | void init( bool readConfig = true, bool honorStyle = false ); |
1085 | void doConnections( KToolBarButton *button ); | 1086 | void doConnections( KToolBarButton *button ); |
1086 | void insertWidgetInternal( QWidget *w, int &index, int id ); | 1087 | void insertWidgetInternal( QWidget *w, int &index, int id ); |
1087 | void removeWidgetInternal( QWidget *w ); | 1088 | void removeWidgetInternal( QWidget *w ); |
1088 | void getAttributes( QString &position, QString &icontext, int &index ); | 1089 | void getAttributes( QString &position, QString &icontext, int &index ); |
1089 | //US KPopupMenu *contextMenu(); | 1090 | //US KPopupMenu *contextMenu(); |
1090 | QPopupMenu *contextMenu(); | 1091 | QPopupMenu *contextMenu(); |
1091 | 1092 | ||
1092 | QMap<QWidget*, int > widget2id; | 1093 | QMap<QWidget*, int > widget2id; |
1093 | typedef QMap<int, QWidget* > Id2WidgetMap; | 1094 | typedef QMap<int, QWidget* > Id2WidgetMap; |
1094 | Id2WidgetMap id2widget; | 1095 | Id2WidgetMap id2widget; |
1095 | //US KPopupMenu *context; | 1096 | //US KPopupMenu *context; |
1096 | QPopupMenu *context; | 1097 | QPopupMenu *context; |
1097 | QPtrList<QWidget> widgets; | 1098 | QPtrList<QWidget> widgets; |
1098 | QTimer *layoutTimer; | 1099 | QTimer *layoutTimer; |
1099 | QGuardedPtr<QWidget> stretchableWidget, rightAligned; | 1100 | QGuardedPtr<QWidget> stretchableWidget, rightAligned; |
1100 | protected: | 1101 | protected: |
1101 | virtual void virtual_hook( int id, void* data ); | 1102 | virtual void virtual_hook( int id, void* data ); |
1102 | private: | 1103 | private: |
1103 | KToolBarPrivate *d; | 1104 | KToolBarPrivate *d; |
1104 | bool inshutdownprocess; | 1105 | bool inshutdownprocess; |
1105 | }; | 1106 | }; |
1106 | 1107 | ||
1107 | #endif | 1108 | #endif |