author | zautrix <zautrix> | 2004-12-05 12:12:10 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-12-05 12:12:10 (UTC) |
commit | 5ab47964d8b52897bb0662ef4a5fcf9604acaf6c (patch) (unidiff) | |
tree | 0f80433206ddd6b4ef901cb346d0f06caf76b20f | |
parent | 196365e533c6fd1a8f47aa9579763ef5afcebcda (diff) | |
download | kdepimpi-5ab47964d8b52897bb0662ef4a5fcf9604acaf6c.zip kdepimpi-5ab47964d8b52897bb0662ef4a5fcf9604acaf6c.tar.gz kdepimpi-5ab47964d8b52897bb0662ef4a5fcf9604acaf6c.tar.bz2 |
fixed kapi toolbar repaint problem
-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,2417 +1,2421 @@ | |||
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(); |
1138 | mDetails->refreshView(); | 1142 | mDetails->refreshView(); |
1139 | 1143 | ||
1140 | } | 1144 | } |
1141 | 1145 | ||
1142 | bool KABCore::modified() const | 1146 | bool KABCore::modified() const |
1143 | { | 1147 | { |
1144 | return mModified; | 1148 | return mModified; |
1145 | } | 1149 | } |
1146 | 1150 | ||
1147 | void KABCore::contactModified( const KABC::Addressee &addr ) | 1151 | void KABCore::contactModified( const KABC::Addressee &addr ) |
1148 | { | 1152 | { |
1149 | 1153 | ||
1150 | Command *command = 0; | 1154 | Command *command = 0; |
1151 | QString uid; | 1155 | QString uid; |
1152 | 1156 | ||
1153 | // check if it exists already | 1157 | // check if it exists already |
1154 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1158 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1155 | if ( origAddr.isEmpty() ) | 1159 | if ( origAddr.isEmpty() ) |
1156 | command = new PwNewCommand( mAddressBook, addr ); | 1160 | command = new PwNewCommand( mAddressBook, addr ); |
1157 | else { | 1161 | else { |
1158 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1162 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1159 | uid = addr.uid(); | 1163 | uid = addr.uid(); |
1160 | } | 1164 | } |
1161 | 1165 | ||
1162 | UndoStack::instance()->push( command ); | 1166 | UndoStack::instance()->push( command ); |
1163 | RedoStack::instance()->clear(); | 1167 | RedoStack::instance()->clear(); |
1164 | 1168 | ||
1165 | setModified( true ); | 1169 | setModified( true ); |
1166 | } | 1170 | } |
1167 | 1171 | ||
1168 | void KABCore::newContact() | 1172 | void KABCore::newContact() |
1169 | { | 1173 | { |
1170 | 1174 | ||
1171 | 1175 | ||
1172 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1176 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1173 | 1177 | ||
1174 | QPtrList<KRES::Resource> kresResources; | 1178 | QPtrList<KRES::Resource> kresResources; |
1175 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1179 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1176 | KABC::Resource *resource; | 1180 | KABC::Resource *resource; |
1177 | while ( ( resource = it.current() ) != 0 ) { | 1181 | while ( ( resource = it.current() ) != 0 ) { |
1178 | ++it; | 1182 | ++it; |
1179 | if ( !resource->readOnly() ) { | 1183 | if ( !resource->readOnly() ) { |
1180 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1184 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1181 | if ( res ) | 1185 | if ( res ) |
1182 | kresResources.append( res ); | 1186 | kresResources.append( res ); |
1183 | } | 1187 | } |
1184 | } | 1188 | } |
1185 | 1189 | ||
1186 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1190 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1187 | resource = static_cast<KABC::Resource*>( res ); | 1191 | resource = static_cast<KABC::Resource*>( res ); |
1188 | 1192 | ||
1189 | if ( resource ) { | 1193 | if ( resource ) { |
1190 | KABC::Addressee addr; | 1194 | KABC::Addressee addr; |
1191 | addr.setResource( resource ); | 1195 | addr.setResource( resource ); |
1192 | mEditorDialog->setAddressee( addr ); | 1196 | mEditorDialog->setAddressee( addr ); |
1193 | KApplication::execDialog ( mEditorDialog ); | 1197 | KApplication::execDialog ( mEditorDialog ); |
1194 | 1198 | ||
1195 | } else | 1199 | } else |
1196 | return; | 1200 | return; |
1197 | 1201 | ||
1198 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1202 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1199 | 1203 | ||
1200 | 1204 | ||
1201 | } | 1205 | } |
1202 | 1206 | ||
1203 | void KABCore::addEmail( QString aStr ) | 1207 | void KABCore::addEmail( QString aStr ) |
1204 | { | 1208 | { |
1205 | #ifndef KAB_EMBEDDED | 1209 | #ifndef KAB_EMBEDDED |
1206 | QString fullName, email; | 1210 | QString fullName, email; |
1207 | 1211 | ||
1208 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1212 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1209 | 1213 | ||
1210 | // Try to lookup the addressee matching the email address | 1214 | // Try to lookup the addressee matching the email address |
1211 | bool found = false; | 1215 | bool found = false; |
1212 | QStringList emailList; | 1216 | QStringList emailList; |
1213 | KABC::AddressBook::Iterator it; | 1217 | KABC::AddressBook::Iterator it; |
1214 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1218 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1215 | emailList = (*it).emails(); | 1219 | emailList = (*it).emails(); |
1216 | if ( emailList.contains( email ) > 0 ) { | 1220 | if ( emailList.contains( email ) > 0 ) { |
1217 | found = true; | 1221 | found = true; |
1218 | (*it).setNameFromString( fullName ); | 1222 | (*it).setNameFromString( fullName ); |
1219 | editContact( (*it).uid() ); | 1223 | editContact( (*it).uid() ); |
1220 | } | 1224 | } |
1221 | } | 1225 | } |
1222 | 1226 | ||
1223 | if ( !found ) { | 1227 | if ( !found ) { |
1224 | KABC::Addressee addr; | 1228 | KABC::Addressee addr; |
1225 | addr.setNameFromString( fullName ); | 1229 | addr.setNameFromString( fullName ); |
1226 | addr.insertEmail( email, true ); | 1230 | addr.insertEmail( email, true ); |
1227 | 1231 | ||
1228 | mAddressBook->insertAddressee( addr ); | 1232 | mAddressBook->insertAddressee( addr ); |
1229 | mViewManager->refreshView( addr.uid() ); | 1233 | mViewManager->refreshView( addr.uid() ); |
1230 | editContact( addr.uid() ); | 1234 | editContact( addr.uid() ); |
1231 | } | 1235 | } |
1232 | #else //KAB_EMBEDDED | 1236 | #else //KAB_EMBEDDED |
1233 | qDebug("KABCore::addEmail finsih method"); | 1237 | qDebug("KABCore::addEmail finsih method"); |
1234 | #endif //KAB_EMBEDDED | 1238 | #endif //KAB_EMBEDDED |
1235 | } | 1239 | } |
1236 | 1240 | ||
1237 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1241 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1238 | { | 1242 | { |
1239 | mXXPortManager->importVCard( url, showPreview ); | 1243 | mXXPortManager->importVCard( url, showPreview ); |
1240 | } | 1244 | } |
1241 | void KABCore::importFromOL() | 1245 | void KABCore::importFromOL() |
1242 | { | 1246 | { |
1243 | #ifdef _WIN32_ | 1247 | #ifdef _WIN32_ |
1244 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1248 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1245 | idgl->exec(); | 1249 | idgl->exec(); |
1246 | KABC::Addressee::List list = idgl->getAddressList(); | 1250 | KABC::Addressee::List list = idgl->getAddressList(); |
1247 | if ( list.count() > 0 ) { | 1251 | if ( list.count() > 0 ) { |
1248 | KABC::Addressee::List listNew; | 1252 | KABC::Addressee::List listNew; |
1249 | KABC::Addressee::List listExisting; | 1253 | KABC::Addressee::List listExisting; |
1250 | KABC::Addressee::List::Iterator it; | 1254 | KABC::Addressee::List::Iterator it; |
1251 | KABC::AddressBook::Iterator iter; | 1255 | KABC::AddressBook::Iterator iter; |
1252 | for ( it = list.begin(); it != list.end(); ++it ) { | 1256 | for ( it = list.begin(); it != list.end(); ++it ) { |
1253 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1257 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1254 | listNew.append( (*it) ); | 1258 | listNew.append( (*it) ); |
1255 | else | 1259 | else |
1256 | listExisting.append( (*it) ); | 1260 | listExisting.append( (*it) ); |
1257 | } | 1261 | } |
1258 | if ( listExisting.count() > 0 ) | 1262 | if ( listExisting.count() > 0 ) |
1259 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1263 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1260 | if ( listNew.count() > 0 ) { | 1264 | if ( listNew.count() > 0 ) { |
1261 | pasteWithNewUid = false; | 1265 | pasteWithNewUid = false; |
1262 | pasteContacts( listNew ); | 1266 | pasteContacts( listNew ); |
1263 | pasteWithNewUid = true; | 1267 | pasteWithNewUid = true; |
1264 | } | 1268 | } |
1265 | } | 1269 | } |
1266 | delete idgl; | 1270 | delete idgl; |
1267 | #endif | 1271 | #endif |
1268 | } | 1272 | } |
1269 | 1273 | ||
1270 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1274 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1271 | { | 1275 | { |
1272 | mXXPortManager->importVCard( vCard, showPreview ); | 1276 | mXXPortManager->importVCard( vCard, showPreview ); |
1273 | } | 1277 | } |
1274 | 1278 | ||
1275 | //US added a second method without defaultparameter | 1279 | //US added a second method without defaultparameter |
1276 | void KABCore::editContact2() { | 1280 | void KABCore::editContact2() { |
1277 | editContact( QString::null ); | 1281 | editContact( QString::null ); |
1278 | } | 1282 | } |
1279 | 1283 | ||
1280 | void KABCore::editContact( const QString &uid ) | 1284 | void KABCore::editContact( const QString &uid ) |
1281 | { | 1285 | { |
1282 | 1286 | ||
1283 | if ( mExtensionManager->isQuickEditVisible() ) | 1287 | if ( mExtensionManager->isQuickEditVisible() ) |
1284 | return; | 1288 | return; |
1285 | 1289 | ||
1286 | // First, locate the contact entry | 1290 | // First, locate the contact entry |
1287 | QString localUID = uid; | 1291 | QString localUID = uid; |
1288 | if ( localUID.isNull() ) { | 1292 | if ( localUID.isNull() ) { |
1289 | QStringList uidList = mViewManager->selectedUids(); | 1293 | QStringList uidList = mViewManager->selectedUids(); |
1290 | if ( uidList.count() > 0 ) | 1294 | if ( uidList.count() > 0 ) |
1291 | localUID = *( uidList.at( 0 ) ); | 1295 | localUID = *( uidList.at( 0 ) ); |
1292 | } | 1296 | } |
1293 | 1297 | ||
1294 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1298 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1295 | if ( !addr.isEmpty() ) { | 1299 | if ( !addr.isEmpty() ) { |
1296 | mEditorDialog->setAddressee( addr ); | 1300 | mEditorDialog->setAddressee( addr ); |
1297 | KApplication::execDialog ( mEditorDialog ); | 1301 | KApplication::execDialog ( mEditorDialog ); |
1298 | } | 1302 | } |
1299 | } | 1303 | } |
1300 | 1304 | ||
1301 | /** | 1305 | /** |
1302 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1306 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1303 | the method will try to find a selected addressee in the view. | 1307 | the method will try to find a selected addressee in the view. |
1304 | */ | 1308 | */ |
1305 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1309 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1306 | { | 1310 | { |
1307 | if ( mMultipleViewsAtOnce ) | 1311 | if ( mMultipleViewsAtOnce ) |
1308 | { | 1312 | { |
1309 | editContact( uid ); | 1313 | editContact( uid ); |
1310 | } | 1314 | } |
1311 | else | 1315 | else |
1312 | { | 1316 | { |
1313 | setDetailsVisible( true ); | 1317 | setDetailsVisible( true ); |
1314 | mActionDetails->setChecked(true); | 1318 | mActionDetails->setChecked(true); |
1315 | } | 1319 | } |
1316 | 1320 | ||
1317 | } | 1321 | } |
1318 | 1322 | ||
1319 | void KABCore::save() | 1323 | void KABCore::save() |
1320 | { | 1324 | { |
1321 | if (syncManager->blockSave()) | 1325 | if (syncManager->blockSave()) |
1322 | return; | 1326 | return; |
1323 | if ( !mModified ) | 1327 | if ( !mModified ) |
1324 | return; | 1328 | return; |
1325 | 1329 | ||
1326 | syncManager->setBlockSave(true); | 1330 | syncManager->setBlockSave(true); |
1327 | QString text = i18n( "There was an error while attempting to save\n the " | 1331 | QString text = i18n( "There was an error while attempting to save\n the " |
1328 | "address book. Please check that some \nother application is " | 1332 | "address book. Please check that some \nother application is " |
1329 | "not using it. " ); | 1333 | "not using it. " ); |
1330 | message(i18n("Saving addressbook ... ")); | 1334 | message(i18n("Saving addressbook ... ")); |
1331 | #ifndef KAB_EMBEDDED | 1335 | #ifndef KAB_EMBEDDED |
1332 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1336 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1333 | if ( !b || !b->save() ) { | 1337 | if ( !b || !b->save() ) { |
1334 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1338 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1335 | } | 1339 | } |
1336 | #else //KAB_EMBEDDED | 1340 | #else //KAB_EMBEDDED |
1337 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1341 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1338 | if ( !b || !b->save() ) { | 1342 | if ( !b || !b->save() ) { |
1339 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1343 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1340 | } | 1344 | } |
1341 | #endif //KAB_EMBEDDED | 1345 | #endif //KAB_EMBEDDED |
1342 | 1346 | ||
1343 | message(i18n("Addressbook saved!")); | 1347 | message(i18n("Addressbook saved!")); |
1344 | setModified( false ); | 1348 | setModified( false ); |
1345 | syncManager->setBlockSave(false); | 1349 | syncManager->setBlockSave(false); |
1346 | } | 1350 | } |
1347 | 1351 | ||
1348 | 1352 | ||
1349 | void KABCore::undo() | 1353 | void KABCore::undo() |
1350 | { | 1354 | { |
1351 | UndoStack::instance()->undo(); | 1355 | UndoStack::instance()->undo(); |
1352 | 1356 | ||
1353 | // Refresh the view | 1357 | // Refresh the view |
1354 | mViewManager->refreshView(); | 1358 | mViewManager->refreshView(); |
1355 | } | 1359 | } |
1356 | 1360 | ||
1357 | void KABCore::redo() | 1361 | void KABCore::redo() |
1358 | { | 1362 | { |
1359 | RedoStack::instance()->redo(); | 1363 | RedoStack::instance()->redo(); |
1360 | 1364 | ||
1361 | // Refresh the view | 1365 | // Refresh the view |
1362 | mViewManager->refreshView(); | 1366 | mViewManager->refreshView(); |
1363 | } | 1367 | } |
1364 | 1368 | ||
1365 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1369 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1366 | { | 1370 | { |
1367 | if (mMultipleViewsAtOnce) | 1371 | if (mMultipleViewsAtOnce) |
1368 | { | 1372 | { |
1369 | if ( visible ) | 1373 | if ( visible ) |
1370 | mJumpButtonBar->show(); | 1374 | mJumpButtonBar->show(); |
1371 | else | 1375 | else |
1372 | mJumpButtonBar->hide(); | 1376 | mJumpButtonBar->hide(); |
1373 | } | 1377 | } |
1374 | else | 1378 | else |
1375 | { | 1379 | { |
1376 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1380 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1377 | if (mViewManager->isVisible()) | 1381 | if (mViewManager->isVisible()) |
1378 | { | 1382 | { |
1379 | if ( visible ) | 1383 | if ( visible ) |
1380 | mJumpButtonBar->show(); | 1384 | mJumpButtonBar->show(); |
1381 | else | 1385 | else |
1382 | mJumpButtonBar->hide(); | 1386 | mJumpButtonBar->hide(); |
1383 | } | 1387 | } |
1384 | else | 1388 | else |
1385 | { | 1389 | { |
1386 | mJumpButtonBar->hide(); | 1390 | mJumpButtonBar->hide(); |
1387 | } | 1391 | } |
1388 | } | 1392 | } |
1389 | } | 1393 | } |
1390 | 1394 | ||
1391 | 1395 | ||
1392 | void KABCore::setDetailsToState() | 1396 | void KABCore::setDetailsToState() |
1393 | { | 1397 | { |
1394 | setDetailsVisible( mActionDetails->isChecked() ); | 1398 | setDetailsVisible( mActionDetails->isChecked() ); |
1395 | } | 1399 | } |
1396 | void KABCore::setDetailsToggle() | 1400 | void KABCore::setDetailsToggle() |
1397 | { | 1401 | { |
1398 | mActionDetails->setChecked( !mActionDetails->isChecked() ); | 1402 | mActionDetails->setChecked( !mActionDetails->isChecked() ); |
1399 | setDetailsToState(); | 1403 | setDetailsToState(); |
1400 | } | 1404 | } |
1401 | 1405 | ||
1402 | 1406 | ||
1403 | 1407 | ||
1404 | void KABCore::setDetailsVisible( bool visible ) | 1408 | void KABCore::setDetailsVisible( bool visible ) |
1405 | { | 1409 | { |
1406 | if (visible && mDetails->isHidden()) | 1410 | if (visible && mDetails->isHidden()) |
1407 | { | 1411 | { |
1408 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1412 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1409 | if ( addrList.count() > 0 ) | 1413 | if ( addrList.count() > 0 ) |
1410 | mDetails->setAddressee( addrList[ 0 ] ); | 1414 | mDetails->setAddressee( addrList[ 0 ] ); |
1411 | } | 1415 | } |
1412 | 1416 | ||
1413 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1417 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1414 | // the listview and the detailview. We do that by changing the splitbar size. | 1418 | // the listview and the detailview. We do that by changing the splitbar size. |
1415 | if (mMultipleViewsAtOnce) | 1419 | if (mMultipleViewsAtOnce) |
1416 | { | 1420 | { |
1417 | if ( visible ) | 1421 | if ( visible ) |
1418 | mDetails->show(); | 1422 | mDetails->show(); |
1419 | else | 1423 | else |
1420 | mDetails->hide(); | 1424 | mDetails->hide(); |
1421 | } | 1425 | } |
1422 | else | 1426 | else |
1423 | { | 1427 | { |
1424 | if ( visible ) { | 1428 | if ( visible ) { |
1425 | mViewManager->hide(); | 1429 | mViewManager->hide(); |
1426 | mDetails->show(); | 1430 | mDetails->show(); |
1427 | mIncSearchWidget->setFocus(); | 1431 | mIncSearchWidget->setFocus(); |
1428 | } | 1432 | } |
1429 | else { | 1433 | else { |
1430 | mViewManager->show(); | 1434 | mViewManager->show(); |
1431 | mDetails->hide(); | 1435 | mDetails->hide(); |
1432 | mViewManager->setFocusAV(); | 1436 | mViewManager->setFocusAV(); |
1433 | } | 1437 | } |
1434 | setJumpButtonBarVisible( !visible ); | 1438 | setJumpButtonBarVisible( !visible ); |
1435 | } | 1439 | } |
1436 | 1440 | ||
1437 | } | 1441 | } |
1438 | 1442 | ||
1439 | void KABCore::extensionChanged( int id ) | 1443 | void KABCore::extensionChanged( int id ) |
1440 | { | 1444 | { |
1441 | //change the details view only for non desktop systems | 1445 | //change the details view only for non desktop systems |
1442 | #ifndef DESKTOP_VERSION | 1446 | #ifndef DESKTOP_VERSION |
1443 | 1447 | ||
1444 | if (id == 0) | 1448 | if (id == 0) |
1445 | { | 1449 | { |
1446 | //the user disabled the extension. | 1450 | //the user disabled the extension. |
1447 | 1451 | ||
1448 | if (mMultipleViewsAtOnce) | 1452 | if (mMultipleViewsAtOnce) |
1449 | { // enable detailsview again | 1453 | { // enable detailsview again |
1450 | setDetailsVisible( true ); | 1454 | setDetailsVisible( true ); |
1451 | mActionDetails->setChecked( true ); | 1455 | mActionDetails->setChecked( true ); |
1452 | } | 1456 | } |
1453 | else | 1457 | else |
1454 | { //go back to the listview | 1458 | { //go back to the listview |
1455 | setDetailsVisible( false ); | 1459 | setDetailsVisible( false ); |
1456 | mActionDetails->setChecked( false ); | 1460 | mActionDetails->setChecked( false ); |
1457 | mActionDetails->setEnabled(true); | 1461 | mActionDetails->setEnabled(true); |
1458 | } | 1462 | } |
1459 | 1463 | ||
1460 | } | 1464 | } |
1461 | else | 1465 | else |
1462 | { | 1466 | { |
1463 | //the user enabled the extension. | 1467 | //the user enabled the extension. |
1464 | setDetailsVisible( false ); | 1468 | setDetailsVisible( false ); |
1465 | mActionDetails->setChecked( false ); | 1469 | mActionDetails->setChecked( false ); |
1466 | 1470 | ||
1467 | if (!mMultipleViewsAtOnce) | 1471 | if (!mMultipleViewsAtOnce) |
1468 | { | 1472 | { |
1469 | mActionDetails->setEnabled(false); | 1473 | mActionDetails->setEnabled(false); |
1470 | } | 1474 | } |
1471 | 1475 | ||
1472 | mExtensionManager->setSelectionChanged(); | 1476 | mExtensionManager->setSelectionChanged(); |
1473 | 1477 | ||
1474 | } | 1478 | } |
1475 | 1479 | ||
1476 | #endif// DESKTOP_VERSION | 1480 | #endif// DESKTOP_VERSION |
1477 | 1481 | ||
1478 | } | 1482 | } |
1479 | 1483 | ||
1480 | 1484 | ||
1481 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1485 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1482 | { | 1486 | { |
1483 | 1487 | ||
1484 | if ( list.count() != 0 ) { | 1488 | if ( list.count() != 0 ) { |
1485 | KABC::Addressee::List::ConstIterator it; | 1489 | KABC::Addressee::List::ConstIterator it; |
1486 | for ( it = list.begin(); it != list.end(); ++it ) | 1490 | for ( it = list.begin(); it != list.end(); ++it ) |
1487 | mAddressBook->insertAddressee( *it ); | 1491 | mAddressBook->insertAddressee( *it ); |
1488 | if ( list.count() > 1 ) | 1492 | if ( list.count() > 1 ) |
1489 | setModified(); | 1493 | setModified(); |
1490 | else | 1494 | else |
1491 | setModifiedWOrefresh(); | 1495 | setModifiedWOrefresh(); |
1492 | } | 1496 | } |
1493 | if ( list.count() == 0 ) | 1497 | if ( list.count() == 0 ) |
1494 | mViewManager->refreshView(); | 1498 | mViewManager->refreshView(); |
1495 | else | 1499 | else |
1496 | mViewManager->refreshView( list[ 0 ].uid() ); | 1500 | mViewManager->refreshView( list[ 0 ].uid() ); |
1497 | 1501 | ||
1498 | 1502 | ||
1499 | 1503 | ||
1500 | } | 1504 | } |
1501 | 1505 | ||
1502 | QString KABCore::getNameByPhone( const QString &phone ) | 1506 | QString KABCore::getNameByPhone( const QString &phone ) |
1503 | { | 1507 | { |
1504 | #ifndef KAB_EMBEDDED | 1508 | #ifndef KAB_EMBEDDED |
1505 | QRegExp r( "[/*/-/ ]" ); | 1509 | QRegExp r( "[/*/-/ ]" ); |
1506 | QString localPhone( phone ); | 1510 | QString localPhone( phone ); |
1507 | 1511 | ||
1508 | bool found = false; | 1512 | bool found = false; |
1509 | QString ownerName = ""; | 1513 | QString ownerName = ""; |
1510 | KABC::AddressBook::Iterator iter; | 1514 | KABC::AddressBook::Iterator iter; |
1511 | KABC::PhoneNumber::List::Iterator phoneIter; | 1515 | KABC::PhoneNumber::List::Iterator phoneIter; |
1512 | KABC::PhoneNumber::List phoneList; | 1516 | KABC::PhoneNumber::List phoneList; |
1513 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1517 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1514 | phoneList = (*iter).phoneNumbers(); | 1518 | phoneList = (*iter).phoneNumbers(); |
1515 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1519 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1516 | ++phoneIter) { | 1520 | ++phoneIter) { |
1517 | // Get rid of separator chars so just the numbers are compared. | 1521 | // Get rid of separator chars so just the numbers are compared. |
1518 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1522 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1519 | ownerName = (*iter).formattedName(); | 1523 | ownerName = (*iter).formattedName(); |
1520 | found = true; | 1524 | found = true; |
1521 | } | 1525 | } |
1522 | } | 1526 | } |
1523 | } | 1527 | } |
1524 | 1528 | ||
1525 | return ownerName; | 1529 | return ownerName; |
1526 | #else //KAB_EMBEDDED | 1530 | #else //KAB_EMBEDDED |
1527 | qDebug("KABCore::getNameByPhone finsih method"); | 1531 | qDebug("KABCore::getNameByPhone finsih method"); |
1528 | return ""; | 1532 | return ""; |
1529 | #endif //KAB_EMBEDDED | 1533 | #endif //KAB_EMBEDDED |
1530 | 1534 | ||
1531 | } | 1535 | } |
1532 | 1536 | ||
1533 | void KABCore::openConfigDialog() | 1537 | void KABCore::openConfigDialog() |
1534 | { | 1538 | { |
1535 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1539 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1536 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1540 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1537 | ConfigureDialog->addModule(kabcfg ); | 1541 | ConfigureDialog->addModule(kabcfg ); |
1538 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1542 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1539 | ConfigureDialog->addModule(kdelibcfg ); | 1543 | ConfigureDialog->addModule(kdelibcfg ); |
1540 | 1544 | ||
1541 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1545 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1542 | this, SLOT( configurationChanged() ) ); | 1546 | this, SLOT( configurationChanged() ) ); |
1543 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1547 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1544 | this, SLOT( configurationChanged() ) ); | 1548 | this, SLOT( configurationChanged() ) ); |
1545 | saveSettings(); | 1549 | saveSettings(); |
1546 | #ifndef DESKTOP_VERSION | 1550 | #ifndef DESKTOP_VERSION |
1547 | ConfigureDialog->showMaximized(); | 1551 | ConfigureDialog->showMaximized(); |
1548 | #endif | 1552 | #endif |
1549 | if ( ConfigureDialog->exec() ) | 1553 | if ( ConfigureDialog->exec() ) |
1550 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1554 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1551 | delete ConfigureDialog; | 1555 | delete ConfigureDialog; |
1552 | } | 1556 | } |
1553 | 1557 | ||
1554 | void KABCore::openLDAPDialog() | 1558 | void KABCore::openLDAPDialog() |
1555 | { | 1559 | { |
1556 | #ifndef KAB_EMBEDDED | 1560 | #ifndef KAB_EMBEDDED |
1557 | if ( !mLdapSearchDialog ) { | 1561 | if ( !mLdapSearchDialog ) { |
1558 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1562 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1559 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1563 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1560 | SLOT( refreshView() ) ); | 1564 | SLOT( refreshView() ) ); |
1561 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1565 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1562 | SLOT( setModified() ) ); | 1566 | SLOT( setModified() ) ); |
1563 | } else | 1567 | } else |
1564 | mLdapSearchDialog->restoreSettings(); | 1568 | mLdapSearchDialog->restoreSettings(); |
1565 | 1569 | ||
1566 | if ( mLdapSearchDialog->isOK() ) | 1570 | if ( mLdapSearchDialog->isOK() ) |
1567 | mLdapSearchDialog->exec(); | 1571 | mLdapSearchDialog->exec(); |
1568 | #else //KAB_EMBEDDED | 1572 | #else //KAB_EMBEDDED |
1569 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1573 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1570 | #endif //KAB_EMBEDDED | 1574 | #endif //KAB_EMBEDDED |
1571 | } | 1575 | } |
1572 | 1576 | ||
1573 | void KABCore::print() | 1577 | void KABCore::print() |
1574 | { | 1578 | { |
1575 | #ifndef KAB_EMBEDDED | 1579 | #ifndef KAB_EMBEDDED |
1576 | KPrinter printer; | 1580 | KPrinter printer; |
1577 | if ( !printer.setup( this ) ) | 1581 | if ( !printer.setup( this ) ) |
1578 | return; | 1582 | return; |
1579 | 1583 | ||
1580 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1584 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1581 | mViewManager->selectedUids(), this ); | 1585 | mViewManager->selectedUids(), this ); |
1582 | 1586 | ||
1583 | wizard.exec(); | 1587 | wizard.exec(); |
1584 | #else //KAB_EMBEDDED | 1588 | #else //KAB_EMBEDDED |
1585 | qDebug("KABCore::print() finsih method"); | 1589 | qDebug("KABCore::print() finsih method"); |
1586 | #endif //KAB_EMBEDDED | 1590 | #endif //KAB_EMBEDDED |
1587 | 1591 | ||
1588 | } | 1592 | } |
1589 | 1593 | ||
1590 | 1594 | ||
1591 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1595 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1592 | { | 1596 | { |
1593 | if ( mGUIClient ) | 1597 | if ( mGUIClient ) |
1594 | mGUIClient->insertChildClient( client ); | 1598 | mGUIClient->insertChildClient( client ); |
1595 | else | 1599 | else |
1596 | KMessageBox::error( this, "no KXMLGUICLient"); | 1600 | KMessageBox::error( this, "no KXMLGUICLient"); |
1597 | } | 1601 | } |
1598 | 1602 | ||
1599 | 1603 | ||
1600 | void KABCore::configurationChanged() | 1604 | void KABCore::configurationChanged() |
1601 | { | 1605 | { |
1602 | mExtensionManager->reconfigure(); | 1606 | mExtensionManager->reconfigure(); |
1603 | } | 1607 | } |
1604 | 1608 | ||
1605 | void KABCore::addressBookChanged() | 1609 | void KABCore::addressBookChanged() |
1606 | { | 1610 | { |
1607 | /*US | 1611 | /*US |
1608 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1612 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1609 | while ( it.current() ) { | 1613 | while ( it.current() ) { |
1610 | if ( it.current()->dirty() ) { | 1614 | if ( it.current()->dirty() ) { |
1611 | QString text = i18n( "Data has been changed externally. Unsaved " | 1615 | QString text = i18n( "Data has been changed externally. Unsaved " |
1612 | "changes will be lost." ); | 1616 | "changes will be lost." ); |
1613 | KMessageBox::information( this, text ); | 1617 | KMessageBox::information( this, text ); |
1614 | } | 1618 | } |
1615 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1619 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1616 | ++it; | 1620 | ++it; |
1617 | } | 1621 | } |
1618 | */ | 1622 | */ |
1619 | if (mEditorDialog) | 1623 | if (mEditorDialog) |
1620 | { | 1624 | { |
1621 | if (mEditorDialog->dirty()) | 1625 | if (mEditorDialog->dirty()) |
1622 | { | 1626 | { |
1623 | QString text = i18n( "Data has been changed externally. Unsaved " | 1627 | QString text = i18n( "Data has been changed externally. Unsaved " |
1624 | "changes will be lost." ); | 1628 | "changes will be lost." ); |
1625 | KMessageBox::information( this, text ); | 1629 | KMessageBox::information( this, text ); |
1626 | } | 1630 | } |
1627 | QString currentuid = mEditorDialog->addressee().uid(); | 1631 | QString currentuid = mEditorDialog->addressee().uid(); |
1628 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1632 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1629 | } | 1633 | } |
1630 | mViewManager->refreshView(); | 1634 | mViewManager->refreshView(); |
1631 | // mDetails->refreshView(); | 1635 | // mDetails->refreshView(); |
1632 | 1636 | ||
1633 | 1637 | ||
1634 | } | 1638 | } |
1635 | 1639 | ||
1636 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1640 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1637 | const char *name ) | 1641 | const char *name ) |
1638 | { | 1642 | { |
1639 | 1643 | ||
1640 | if ( mEditorDialog == 0 ) { | 1644 | if ( mEditorDialog == 0 ) { |
1641 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1645 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1642 | name ? name : "editorDialog" ); | 1646 | name ? name : "editorDialog" ); |
1643 | 1647 | ||
1644 | 1648 | ||
1645 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1649 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1646 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1650 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1647 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1651 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1648 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1652 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1649 | } | 1653 | } |
1650 | 1654 | ||
1651 | return mEditorDialog; | 1655 | return mEditorDialog; |
1652 | } | 1656 | } |
1653 | 1657 | ||
1654 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1658 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1655 | { | 1659 | { |
1656 | //mEditorDict.remove( uid ); | 1660 | //mEditorDict.remove( uid ); |
1657 | } | 1661 | } |
1658 | 1662 | ||
1659 | void KABCore::initGUI() | 1663 | void KABCore::initGUI() |
1660 | { | 1664 | { |
1661 | #ifndef KAB_EMBEDDED | 1665 | #ifndef KAB_EMBEDDED |
1662 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1666 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1663 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1667 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1664 | 1668 | ||
1665 | mExtensionBarSplitter = new QSplitter( this ); | 1669 | mExtensionBarSplitter = new QSplitter( this ); |
1666 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1670 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1667 | 1671 | ||
1668 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1672 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1669 | 1673 | ||
1670 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1674 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1671 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1675 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1672 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1676 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1673 | SLOT( incrementalSearch( const QString& ) ) ); | 1677 | SLOT( incrementalSearch( const QString& ) ) ); |
1674 | 1678 | ||
1675 | mViewManager = new ViewManager( this, viewSpace ); | 1679 | mViewManager = new ViewManager( this, viewSpace ); |
1676 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1680 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1677 | 1681 | ||
1678 | mDetails = new ViewContainer( mDetailsSplitter ); | 1682 | mDetails = new ViewContainer( mDetailsSplitter ); |
1679 | 1683 | ||
1680 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1684 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1681 | 1685 | ||
1682 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1686 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1683 | 1687 | ||
1684 | topLayout->addWidget( mExtensionBarSplitter ); | 1688 | topLayout->addWidget( mExtensionBarSplitter ); |
1685 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1689 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1686 | topLayout->addWidget( mJumpButtonBar ); | 1690 | topLayout->addWidget( mJumpButtonBar ); |
1687 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1691 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1688 | 1692 | ||
1689 | mXXPortManager = new XXPortManager( this, this ); | 1693 | mXXPortManager = new XXPortManager( this, this ); |
1690 | 1694 | ||
1691 | #else //KAB_EMBEDDED | 1695 | #else //KAB_EMBEDDED |
1692 | //US initialize viewMenu before settingup viewmanager. | 1696 | //US initialize viewMenu before settingup viewmanager. |
1693 | // Viewmanager needs this menu to plugin submenues. | 1697 | // Viewmanager needs this menu to plugin submenues. |
1694 | viewMenu = new QPopupMenu( this ); | 1698 | viewMenu = new QPopupMenu( this ); |
1695 | settingsMenu = new QPopupMenu( this ); | 1699 | settingsMenu = new QPopupMenu( this ); |
1696 | //filterMenu = new QPopupMenu( this ); | 1700 | //filterMenu = new QPopupMenu( this ); |
1697 | ImportMenu = new QPopupMenu( this ); | 1701 | ImportMenu = new QPopupMenu( this ); |
1698 | ExportMenu = new QPopupMenu( this ); | 1702 | ExportMenu = new QPopupMenu( this ); |
1699 | syncMenu = new QPopupMenu( this ); | 1703 | syncMenu = new QPopupMenu( this ); |
1700 | changeMenu= new QPopupMenu( this ); | 1704 | changeMenu= new QPopupMenu( this ); |
1701 | beamMenu= new QPopupMenu( this ); | 1705 | beamMenu= new QPopupMenu( this ); |
1702 | 1706 | ||
1703 | //US since we have no splitter for the embedded system, setup | 1707 | //US since we have no splitter for the embedded system, setup |
1704 | // a layout with two frames. One left and one right. | 1708 | // a layout with two frames. One left and one right. |
1705 | 1709 | ||
1706 | QBoxLayout *topLayout; | 1710 | QBoxLayout *topLayout; |
1707 | 1711 | ||
1708 | // = new QHBoxLayout( this ); | 1712 | // = new QHBoxLayout( this ); |
1709 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1713 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1710 | 1714 | ||
1711 | // QWidget *mainBox = new QWidget( this ); | 1715 | // QWidget *mainBox = new QWidget( this ); |
1712 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1716 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1713 | 1717 | ||
1714 | #ifdef DESKTOP_VERSION | 1718 | #ifdef DESKTOP_VERSION |
1715 | topLayout = new QHBoxLayout( this ); | 1719 | topLayout = new QHBoxLayout( this ); |
1716 | 1720 | ||
1717 | 1721 | ||
1718 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1722 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1719 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1723 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1720 | 1724 | ||
1721 | topLayout->addWidget(mMiniSplitter ); | 1725 | topLayout->addWidget(mMiniSplitter ); |
1722 | 1726 | ||
1723 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1727 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1724 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1728 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1725 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1729 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1726 | mDetails = new ViewContainer( mMiniSplitter ); | 1730 | mDetails = new ViewContainer( mMiniSplitter ); |
1727 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1731 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1728 | #else | 1732 | #else |
1729 | if ( QApplication::desktop()->width() > 480 ) { | 1733 | if ( QApplication::desktop()->width() > 480 ) { |
1730 | topLayout = new QHBoxLayout( this ); | 1734 | topLayout = new QHBoxLayout( this ); |
1731 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1735 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1732 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1736 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1733 | } else { | 1737 | } else { |
1734 | 1738 | ||
1735 | topLayout = new QHBoxLayout( this ); | 1739 | topLayout = new QHBoxLayout( this ); |
1736 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1740 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1737 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1741 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1738 | } | 1742 | } |
1739 | 1743 | ||
1740 | topLayout->addWidget(mMiniSplitter ); | 1744 | topLayout->addWidget(mMiniSplitter ); |
1741 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1745 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1742 | mDetails = new ViewContainer( mMiniSplitter ); | 1746 | mDetails = new ViewContainer( mMiniSplitter ); |
1743 | 1747 | ||
1744 | 1748 | ||
1745 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1749 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1746 | #endif | 1750 | #endif |
1747 | //eh->hide(); | 1751 | //eh->hide(); |
1748 | // topLayout->addWidget(mExtensionManager ); | 1752 | // topLayout->addWidget(mExtensionManager ); |
1749 | 1753 | ||
1750 | 1754 | ||
1751 | /*US | 1755 | /*US |
1752 | #ifndef KAB_NOSPLITTER | 1756 | #ifndef KAB_NOSPLITTER |
1753 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1757 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1754 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1758 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1755 | topLayout->setSpacing( 10 ); | 1759 | topLayout->setSpacing( 10 ); |
1756 | 1760 | ||
1757 | mDetailsSplitter = new QSplitter( this ); | 1761 | mDetailsSplitter = new QSplitter( this ); |
1758 | 1762 | ||
1759 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1763 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1760 | 1764 | ||
1761 | mViewManager = new ViewManager( this, viewSpace ); | 1765 | mViewManager = new ViewManager( this, viewSpace ); |
1762 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1766 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1763 | 1767 | ||
1764 | mDetails = new ViewContainer( mDetailsSplitter ); | 1768 | mDetails = new ViewContainer( mDetailsSplitter ); |
1765 | 1769 | ||
1766 | topLayout->addWidget( mDetailsSplitter ); | 1770 | topLayout->addWidget( mDetailsSplitter ); |
1767 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1771 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1768 | #else //KAB_NOSPLITTER | 1772 | #else //KAB_NOSPLITTER |
1769 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1773 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1770 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1774 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1771 | topLayout->setSpacing( 10 ); | 1775 | topLayout->setSpacing( 10 ); |
1772 | 1776 | ||
1773 | // mDetailsSplitter = new QSplitter( this ); | 1777 | // mDetailsSplitter = new QSplitter( this ); |
1774 | 1778 | ||
1775 | QVBox *viewSpace = new QVBox( this ); | 1779 | QVBox *viewSpace = new QVBox( this ); |
1776 | 1780 | ||
1777 | mViewManager = new ViewManager( this, viewSpace ); | 1781 | mViewManager = new ViewManager( this, viewSpace ); |
1778 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1782 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1779 | 1783 | ||
1780 | mDetails = new ViewContainer( this ); | 1784 | mDetails = new ViewContainer( this ); |
1781 | 1785 | ||
1782 | topLayout->addWidget( viewSpace ); | 1786 | topLayout->addWidget( viewSpace ); |
1783 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1787 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1784 | topLayout->addWidget( mDetails ); | 1788 | topLayout->addWidget( mDetails ); |
1785 | #endif //KAB_NOSPLITTER | 1789 | #endif //KAB_NOSPLITTER |
1786 | */ | 1790 | */ |
1787 | 1791 | ||
1788 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1792 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1789 | syncManager->setBlockSave(false); | 1793 | syncManager->setBlockSave(false); |
1790 | 1794 | ||
1791 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 1795 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
1792 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 1796 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
1793 | syncManager->setDefaultFileName( sentSyncFile()); | 1797 | syncManager->setDefaultFileName( sentSyncFile()); |
1794 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); | 1798 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); |
1795 | 1799 | ||
1796 | #endif //KAB_EMBEDDED | 1800 | #endif //KAB_EMBEDDED |
1797 | initActions(); | 1801 | initActions(); |
1798 | 1802 | ||
1799 | #ifdef KAB_EMBEDDED | 1803 | #ifdef KAB_EMBEDDED |
1800 | addActionsManually(); | 1804 | addActionsManually(); |
1801 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1805 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1802 | mXXPortManager = new XXPortManager( this, this ); | 1806 | mXXPortManager = new XXPortManager( this, this ); |
1803 | 1807 | ||
1804 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1808 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1805 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1809 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1806 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1810 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1807 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1811 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1808 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1812 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1809 | // mIncSearchWidget->hide(); | 1813 | // mIncSearchWidget->hide(); |
1810 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1814 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1811 | SLOT( incrementalSearch( const QString& ) ) ); | 1815 | SLOT( incrementalSearch( const QString& ) ) ); |
1812 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); | 1816 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); |
1813 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); | 1817 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); |
1814 | 1818 | ||
1815 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1819 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1816 | 1820 | ||
1817 | topLayout->addWidget( mJumpButtonBar ); | 1821 | topLayout->addWidget( mJumpButtonBar ); |
1818 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1822 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1819 | 1823 | ||
1820 | // mMainWindow->getIconToolBar()->raise(); | 1824 | // mMainWindow->getIconToolBar()->raise(); |
1821 | 1825 | ||
1822 | #endif //KAB_EMBEDDED | 1826 | #endif //KAB_EMBEDDED |
1823 | 1827 | ||
1824 | } | 1828 | } |
1825 | void KABCore::initActions() | 1829 | void KABCore::initActions() |
1826 | { | 1830 | { |
1827 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1831 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1828 | 1832 | ||
1829 | #ifndef KAB_EMBEDDED | 1833 | #ifndef KAB_EMBEDDED |
1830 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1834 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1831 | SLOT( clipboardDataChanged() ) ); | 1835 | SLOT( clipboardDataChanged() ) ); |
1832 | #endif //KAB_EMBEDDED | 1836 | #endif //KAB_EMBEDDED |
1833 | 1837 | ||
1834 | // file menu | 1838 | // file menu |
1835 | if ( mIsPart ) { | 1839 | if ( mIsPart ) { |
1836 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1840 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1837 | SLOT( sendMail() ), actionCollection(), | 1841 | SLOT( sendMail() ), actionCollection(), |
1838 | "kaddressbook_mail" ); | 1842 | "kaddressbook_mail" ); |
1839 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1843 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1840 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1844 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1841 | 1845 | ||
1842 | } else { | 1846 | } else { |
1843 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1847 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1844 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1848 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1845 | } | 1849 | } |
1846 | 1850 | ||
1847 | 1851 | ||
1848 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1852 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1849 | SLOT( save() ), actionCollection(), "file_sync" ); | 1853 | SLOT( save() ), actionCollection(), "file_sync" ); |
1850 | 1854 | ||
1851 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1855 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1852 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1856 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1853 | 1857 | ||
1854 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1858 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1855 | this, SLOT( mailVCard() ), | 1859 | this, SLOT( mailVCard() ), |
1856 | actionCollection(), "file_mail_vcard"); | 1860 | actionCollection(), "file_mail_vcard"); |
1857 | 1861 | ||
1858 | mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, | 1862 | mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, |
1859 | SLOT( export2phone() ), actionCollection(), | 1863 | SLOT( export2phone() ), actionCollection(), |
1860 | "kaddressbook_ex2phone" ); | 1864 | "kaddressbook_ex2phone" ); |
1861 | 1865 | ||
1862 | mActionBeamVCard = 0; | 1866 | mActionBeamVCard = 0; |
1863 | mActionBeam = 0; | 1867 | mActionBeam = 0; |
1864 | 1868 | ||
1865 | #ifndef DESKTOP_VERSION | 1869 | #ifndef DESKTOP_VERSION |
1866 | if ( Ir::supported() ) { | 1870 | if ( Ir::supported() ) { |
1867 | mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, | 1871 | mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, |
1868 | SLOT( beamVCard() ), actionCollection(), | 1872 | SLOT( beamVCard() ), actionCollection(), |
1869 | "kaddressbook_beam_vcard" ); | 1873 | "kaddressbook_beam_vcard" ); |
1870 | 1874 | ||
1871 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1875 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1872 | SLOT( beamMySelf() ), actionCollection(), | 1876 | SLOT( beamMySelf() ), actionCollection(), |
1873 | "kaddressbook_beam_myself" ); | 1877 | "kaddressbook_beam_myself" ); |
1874 | } | 1878 | } |
1875 | #endif | 1879 | #endif |
1876 | 1880 | ||
1877 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1881 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1878 | this, SLOT( editContact2() ), | 1882 | this, SLOT( editContact2() ), |
1879 | actionCollection(), "file_properties" ); | 1883 | actionCollection(), "file_properties" ); |
1880 | 1884 | ||
1881 | #ifdef KAB_EMBEDDED | 1885 | #ifdef KAB_EMBEDDED |
1882 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1886 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1883 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1887 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1884 | mMainWindow, SLOT( exit() ), | 1888 | mMainWindow, SLOT( exit() ), |
1885 | actionCollection(), "quit" ); | 1889 | actionCollection(), "quit" ); |
1886 | #endif //KAB_EMBEDDED | 1890 | #endif //KAB_EMBEDDED |
1887 | 1891 | ||
1888 | // edit menu | 1892 | // edit menu |
1889 | if ( mIsPart ) { | 1893 | if ( mIsPart ) { |
1890 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1894 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1891 | SLOT( copyContacts() ), actionCollection(), | 1895 | SLOT( copyContacts() ), actionCollection(), |
1892 | "kaddressbook_copy" ); | 1896 | "kaddressbook_copy" ); |
1893 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1897 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1894 | SLOT( cutContacts() ), actionCollection(), | 1898 | SLOT( cutContacts() ), actionCollection(), |
1895 | "kaddressbook_cut" ); | 1899 | "kaddressbook_cut" ); |
1896 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1900 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1897 | SLOT( pasteContacts() ), actionCollection(), | 1901 | SLOT( pasteContacts() ), actionCollection(), |
1898 | "kaddressbook_paste" ); | 1902 | "kaddressbook_paste" ); |
1899 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1903 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1900 | SLOT( selectAllContacts() ), actionCollection(), | 1904 | SLOT( selectAllContacts() ), actionCollection(), |
1901 | "kaddressbook_select_all" ); | 1905 | "kaddressbook_select_all" ); |
1902 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1906 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1903 | SLOT( undo() ), actionCollection(), | 1907 | SLOT( undo() ), actionCollection(), |
1904 | "kaddressbook_undo" ); | 1908 | "kaddressbook_undo" ); |
1905 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1909 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1906 | this, SLOT( redo() ), actionCollection(), | 1910 | this, SLOT( redo() ), actionCollection(), |
1907 | "kaddressbook_redo" ); | 1911 | "kaddressbook_redo" ); |
1908 | } else { | 1912 | } else { |
1909 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1913 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1910 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1914 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1911 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1915 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1912 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1916 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1913 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1917 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1914 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1918 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1915 | } | 1919 | } |
1916 | 1920 | ||
1917 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1921 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1918 | Key_Delete, this, SLOT( deleteContacts() ), | 1922 | Key_Delete, this, SLOT( deleteContacts() ), |
1919 | actionCollection(), "edit_delete" ); | 1923 | actionCollection(), "edit_delete" ); |
1920 | 1924 | ||
1921 | mActionUndo->setEnabled( false ); | 1925 | mActionUndo->setEnabled( false ); |
1922 | mActionRedo->setEnabled( false ); | 1926 | mActionRedo->setEnabled( false ); |
1923 | 1927 | ||
1924 | // settings menu | 1928 | // settings menu |
1925 | #ifdef KAB_EMBEDDED | 1929 | #ifdef KAB_EMBEDDED |
1926 | //US special menuentry to configure the addressbook resources. On KDE | 1930 | //US special menuentry to configure the addressbook resources. On KDE |
1927 | // you do that through the control center !!! | 1931 | // you do that through the control center !!! |
1928 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1932 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1929 | SLOT( configureResources() ), actionCollection(), | 1933 | SLOT( configureResources() ), actionCollection(), |
1930 | "kaddressbook_configure_resources" ); | 1934 | "kaddressbook_configure_resources" ); |
1931 | #endif //KAB_EMBEDDED | 1935 | #endif //KAB_EMBEDDED |
1932 | 1936 | ||
1933 | if ( mIsPart ) { | 1937 | if ( mIsPart ) { |
1934 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1938 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1935 | SLOT( openConfigDialog() ), actionCollection(), | 1939 | SLOT( openConfigDialog() ), actionCollection(), |
1936 | "kaddressbook_configure" ); | 1940 | "kaddressbook_configure" ); |
1937 | 1941 | ||
1938 | //US not implemented yet | 1942 | //US not implemented yet |
1939 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1943 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1940 | // this, SLOT( configureKeyBindings() ), actionCollection(), | 1944 | // this, SLOT( configureKeyBindings() ), actionCollection(), |
1941 | // "kaddressbook_configure_shortcuts" ); | 1945 | // "kaddressbook_configure_shortcuts" ); |
1942 | #ifdef KAB_EMBEDDED | 1946 | #ifdef KAB_EMBEDDED |
1943 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1947 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1944 | mActionConfigureToolbars->setEnabled( false ); | 1948 | mActionConfigureToolbars->setEnabled( false ); |
1945 | #endif //KAB_EMBEDDED | 1949 | #endif //KAB_EMBEDDED |
1946 | 1950 | ||
1947 | } else { | 1951 | } else { |
1948 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1952 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1949 | 1953 | ||
1950 | //US not implemented yet | 1954 | //US not implemented yet |
1951 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1955 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1952 | } | 1956 | } |
1953 | 1957 | ||
1954 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1958 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1955 | actionCollection(), "options_show_jump_bar" ); | 1959 | actionCollection(), "options_show_jump_bar" ); |
1956 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1960 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1957 | 1961 | ||
1958 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 1962 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1959 | actionCollection(), "options_show_details" ); | 1963 | actionCollection(), "options_show_details" ); |
1960 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1964 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1961 | 1965 | ||
1962 | 1966 | ||
1963 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, | 1967 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, |
1964 | SLOT( toggleBeamReceive() ), actionCollection(), | 1968 | SLOT( toggleBeamReceive() ), actionCollection(), |
1965 | "kaddressbook_beam_rec" ); | 1969 | "kaddressbook_beam_rec" ); |
1966 | 1970 | ||
1967 | 1971 | ||
1968 | // misc | 1972 | // misc |
1969 | // only enable LDAP lookup if we can handle the protocol | 1973 | // only enable LDAP lookup if we can handle the protocol |
1970 | #ifndef KAB_EMBEDDED | 1974 | #ifndef KAB_EMBEDDED |
1971 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1975 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1972 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1976 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1973 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1977 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1974 | "ldap_lookup" ); | 1978 | "ldap_lookup" ); |
1975 | } | 1979 | } |
1976 | #else //KAB_EMBEDDED | 1980 | #else //KAB_EMBEDDED |
1977 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1981 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1978 | #endif //KAB_EMBEDDED | 1982 | #endif //KAB_EMBEDDED |
1979 | 1983 | ||
1980 | 1984 | ||
1981 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1985 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1982 | SLOT( setWhoAmI() ), actionCollection(), | 1986 | SLOT( setWhoAmI() ), actionCollection(), |
1983 | "set_personal" ); | 1987 | "set_personal" ); |
1984 | 1988 | ||
1985 | 1989 | ||
1986 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1990 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1987 | SLOT( setCategories() ), actionCollection(), | 1991 | SLOT( setCategories() ), actionCollection(), |
1988 | "edit_set_categories" ); | 1992 | "edit_set_categories" ); |
1989 | mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this, | 1993 | mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this, |
1990 | SLOT( editCategories() ), actionCollection(), | 1994 | SLOT( editCategories() ), actionCollection(), |
1991 | "edit__categories" ); | 1995 | "edit__categories" ); |
1992 | 1996 | ||
1993 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1997 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1994 | SLOT( removeVoice() ), actionCollection(), | 1998 | SLOT( removeVoice() ), actionCollection(), |
1995 | "remove_voice" ); | 1999 | "remove_voice" ); |
1996 | 2000 | ||
1997 | mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, | 2001 | mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, |
1998 | SLOT( manageCategories() ), actionCollection(), | 2002 | SLOT( manageCategories() ), actionCollection(), |
1999 | "remove_voice" ); | 2003 | "remove_voice" ); |
2000 | 2004 | ||
2001 | 2005 | ||
2002 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 2006 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
2003 | SLOT( importFromOL() ), actionCollection(), | 2007 | SLOT( importFromOL() ), actionCollection(), |
2004 | "import_OL" ); | 2008 | "import_OL" ); |
2005 | #ifdef KAB_EMBEDDED | 2009 | #ifdef KAB_EMBEDDED |
2006 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 2010 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
2007 | this, SLOT( showLicence() ), actionCollection(), | 2011 | this, SLOT( showLicence() ), actionCollection(), |
2008 | "licence_about_data" ); | 2012 | "licence_about_data" ); |
2009 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 2013 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
2010 | this, SLOT( faq() ), actionCollection(), | 2014 | this, SLOT( faq() ), actionCollection(), |
2011 | "faq_about_data" ); | 2015 | "faq_about_data" ); |
2012 | mActionWN = new KAction( i18n( "What's New?" ), 0, | 2016 | mActionWN = new KAction( i18n( "What's New?" ), 0, |
2013 | this, SLOT( whatsnew() ), actionCollection(), | 2017 | this, SLOT( whatsnew() ), actionCollection(), |
2014 | "wn" ); | 2018 | "wn" ); |
2015 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, | 2019 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, |
2016 | this, SLOT( synchowto() ), actionCollection(), | 2020 | this, SLOT( synchowto() ), actionCollection(), |
2017 | "sync" ); | 2021 | "sync" ); |
2018 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, | 2022 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, |
2019 | this, SLOT( kdesynchowto() ), actionCollection(), | 2023 | this, SLOT( kdesynchowto() ), actionCollection(), |
2020 | "kdesync" ); | 2024 | "kdesync" ); |
2021 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, | 2025 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, |
2022 | this, SLOT( multisynchowto() ), actionCollection(), | 2026 | this, SLOT( multisynchowto() ), actionCollection(), |
2023 | "multisync" ); | 2027 | "multisync" ); |
2024 | 2028 | ||
2025 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 2029 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
2026 | this, SLOT( createAboutData() ), actionCollection(), | 2030 | this, SLOT( createAboutData() ), actionCollection(), |
2027 | "kaddressbook_about_data" ); | 2031 | "kaddressbook_about_data" ); |
2028 | #endif //KAB_EMBEDDED | 2032 | #endif //KAB_EMBEDDED |
2029 | 2033 | ||
2030 | clipboardDataChanged(); | 2034 | clipboardDataChanged(); |
2031 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 2035 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
2032 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 2036 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
2033 | } | 2037 | } |
2034 | 2038 | ||
2035 | //US we need this function, to plug all actions into the correct menues. | 2039 | //US we need this function, to plug all actions into the correct menues. |
2036 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 2040 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
2037 | void KABCore::addActionsManually() | 2041 | void KABCore::addActionsManually() |
2038 | { | 2042 | { |
2039 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 2043 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
2040 | 2044 | ||
2041 | #ifdef KAB_EMBEDDED | 2045 | #ifdef KAB_EMBEDDED |
2042 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 2046 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
2043 | QPopupMenu *editMenu = new QPopupMenu( this ); | 2047 | QPopupMenu *editMenu = new QPopupMenu( this ); |
2044 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 2048 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
2045 | 2049 | ||
2046 | KToolBar* tb = mMainWindow->toolBar(); | 2050 | KToolBar* tb = mMainWindow->toolBar(); |
2047 | 2051 | ||
2048 | #ifndef DESKTOP_VERSION | 2052 | #ifndef DESKTOP_VERSION |
2049 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { | 2053 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { |
2050 | #endif | 2054 | #endif |
2051 | QMenuBar* mb = mMainWindow->menuBar(); | 2055 | QMenuBar* mb = mMainWindow->menuBar(); |
2052 | 2056 | ||
2053 | //US setup menubar. | 2057 | //US setup menubar. |
2054 | //Disable the following block if you do not want to have a menubar. | 2058 | //Disable the following block if you do not want to have a menubar. |
2055 | mb->insertItem( i18n("&File"), fileMenu ); | 2059 | mb->insertItem( i18n("&File"), fileMenu ); |
2056 | mb->insertItem( i18n("&Edit"), editMenu ); | 2060 | mb->insertItem( i18n("&Edit"), editMenu ); |
2057 | mb->insertItem( i18n("&View"), viewMenu ); | 2061 | mb->insertItem( i18n("&View"), viewMenu ); |
2058 | mb->insertItem( i18n("&Settings"), settingsMenu ); | 2062 | mb->insertItem( i18n("&Settings"), settingsMenu ); |
2059 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 2063 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
2060 | //mb->insertItem( i18n("&Change"), changeMenu ); | 2064 | //mb->insertItem( i18n("&Change"), changeMenu ); |
2061 | mb->insertItem( i18n("&Help"), helpMenu ); | 2065 | mb->insertItem( i18n("&Help"), helpMenu ); |
2062 | mIncSearchWidget = new IncSearchWidget( tb ); | 2066 | mIncSearchWidget = new IncSearchWidget( tb ); |
2063 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 2067 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
2064 | #ifndef DESKTOP_VERSION | 2068 | #ifndef DESKTOP_VERSION |
2065 | } else { | 2069 | } else { |
2066 | //US setup toolbar | 2070 | //US setup toolbar |
2067 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 2071 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
2068 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 2072 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
2069 | menuBarTB->insertItem( "ME", popupBarTB); | 2073 | menuBarTB->insertItem( "ME", popupBarTB); |
2070 | tb->insertWidget(-1, 0, menuBarTB); | 2074 | tb->insertWidget(-1, 0, menuBarTB); |
2071 | mIncSearchWidget = new IncSearchWidget( tb ); | 2075 | mIncSearchWidget = new IncSearchWidget( tb ); |
2072 | 2076 | ||
2073 | tb->enableMoving(false); | 2077 | tb->enableMoving(false); |
2074 | popupBarTB->insertItem( i18n("&File"), fileMenu ); | 2078 | popupBarTB->insertItem( i18n("&File"), fileMenu ); |
2075 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); | 2079 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); |
2076 | popupBarTB->insertItem( i18n("&View"), viewMenu ); | 2080 | popupBarTB->insertItem( i18n("&View"), viewMenu ); |
2077 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); | 2081 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); |
2078 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 2082 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
2079 | mViewManager->getFilterAction()->plug ( popupBarTB); | 2083 | mViewManager->getFilterAction()->plug ( popupBarTB); |
2080 | //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); | 2084 | //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); |
2081 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); | 2085 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); |
2082 | if (QApplication::desktop()->width() > 320 ) { | 2086 | if (QApplication::desktop()->width() > 320 ) { |
2083 | // mViewManager->getFilterAction()->plug ( tb); | 2087 | // mViewManager->getFilterAction()->plug ( tb); |
2084 | } | 2088 | } |
2085 | } | 2089 | } |
2086 | #endif | 2090 | #endif |
2087 | // mActionQuit->plug ( mMainWindow->toolBar()); | 2091 | // mActionQuit->plug ( mMainWindow->toolBar()); |
2088 | 2092 | ||
2089 | 2093 | ||
2090 | 2094 | ||
2091 | //US Now connect the actions with the menue entries. | 2095 | //US Now connect the actions with the menue entries. |
2092 | mActionPrint->plug( fileMenu ); | 2096 | mActionPrint->plug( fileMenu ); |
2093 | mActionMail->plug( fileMenu ); | 2097 | mActionMail->plug( fileMenu ); |
2094 | fileMenu->insertSeparator(); | 2098 | fileMenu->insertSeparator(); |
2095 | 2099 | ||
2096 | mActionNewContact->plug( fileMenu ); | 2100 | mActionNewContact->plug( fileMenu ); |
2097 | mActionNewContact->plug( tb ); | 2101 | mActionNewContact->plug( tb ); |
2098 | 2102 | ||
2099 | mActionEditAddressee->plug( fileMenu ); | 2103 | mActionEditAddressee->plug( fileMenu ); |
2100 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 2104 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
2101 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 2105 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
2102 | mActionEditAddressee->plug( tb ); | 2106 | mActionEditAddressee->plug( tb ); |
2103 | 2107 | ||
2104 | fileMenu->insertSeparator(); | 2108 | fileMenu->insertSeparator(); |
2105 | mActionSave->plug( fileMenu ); | 2109 | mActionSave->plug( fileMenu ); |
2106 | fileMenu->insertItem( "&Import", ImportMenu ); | 2110 | fileMenu->insertItem( "&Import", ImportMenu ); |
2107 | fileMenu->insertItem( "&Export", ExportMenu ); | 2111 | fileMenu->insertItem( "&Export", ExportMenu ); |
2108 | fileMenu->insertItem( i18n("&Change"), changeMenu ); | 2112 | fileMenu->insertItem( i18n("&Change"), changeMenu ); |
2109 | #ifndef DESKTOP_VERSION | 2113 | #ifndef DESKTOP_VERSION |
2110 | if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); | 2114 | if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); |
2111 | #endif | 2115 | #endif |
2112 | 2116 | ||
2113 | fileMenu->insertSeparator(); | 2117 | fileMenu->insertSeparator(); |
2114 | mActionMailVCard->plug( fileMenu ); | 2118 | mActionMailVCard->plug( fileMenu ); |
2115 | #ifndef DESKTOP_VERSION | 2119 | #ifndef DESKTOP_VERSION |
2116 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); | 2120 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); |
2117 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); | 2121 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); |
2118 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); | 2122 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); |
2119 | #endif | 2123 | #endif |
2120 | fileMenu->insertSeparator(); | 2124 | fileMenu->insertSeparator(); |
2121 | mActionQuit->plug( fileMenu ); | 2125 | mActionQuit->plug( fileMenu ); |
2122 | #ifdef _WIN32_ | 2126 | #ifdef _WIN32_ |
2123 | mActionImportOL->plug( ImportMenu ); | 2127 | mActionImportOL->plug( ImportMenu ); |
2124 | #endif | 2128 | #endif |
2125 | // edit menu | 2129 | // edit menu |
2126 | mActionUndo->plug( editMenu ); | 2130 | mActionUndo->plug( editMenu ); |
2127 | mActionRedo->plug( editMenu ); | 2131 | mActionRedo->plug( editMenu ); |
2128 | editMenu->insertSeparator(); | 2132 | editMenu->insertSeparator(); |
2129 | mActionCut->plug( editMenu ); | 2133 | mActionCut->plug( editMenu ); |
2130 | mActionCopy->plug( editMenu ); | 2134 | mActionCopy->plug( editMenu ); |
2131 | mActionPaste->plug( editMenu ); | 2135 | mActionPaste->plug( editMenu ); |
2132 | mActionDelete->plug( editMenu ); | 2136 | mActionDelete->plug( editMenu ); |
2133 | editMenu->insertSeparator(); | 2137 | editMenu->insertSeparator(); |
2134 | mActionSelectAll->plug( editMenu ); | 2138 | mActionSelectAll->plug( editMenu ); |
2135 | 2139 | ||
2136 | mActionRemoveVoice->plug( changeMenu ); | 2140 | mActionRemoveVoice->plug( changeMenu ); |
2137 | // settings menu | 2141 | // settings menu |
2138 | //US special menuentry to configure the addressbook resources. On KDE | 2142 | //US special menuentry to configure the addressbook resources. On KDE |
2139 | // you do that through the control center !!! | 2143 | // you do that through the control center !!! |
2140 | mActionConfigResources->plug( settingsMenu ); | 2144 | mActionConfigResources->plug( settingsMenu ); |
2141 | settingsMenu->insertSeparator(); | 2145 | settingsMenu->insertSeparator(); |
2142 | 2146 | ||
2143 | mActionConfigKAddressbook->plug( settingsMenu ); | 2147 | mActionConfigKAddressbook->plug( settingsMenu ); |
2144 | 2148 | ||
2145 | if ( mIsPart ) { | 2149 | if ( mIsPart ) { |
2146 | //US not implemented yet | 2150 | //US not implemented yet |
2147 | //mActionConfigShortcuts->plug( settingsMenu ); | 2151 | //mActionConfigShortcuts->plug( settingsMenu ); |
2148 | //mActionConfigureToolbars->plug( settingsMenu ); | 2152 | //mActionConfigureToolbars->plug( settingsMenu ); |
2149 | 2153 | ||
2150 | } else { | 2154 | } else { |
2151 | //US not implemented yet | 2155 | //US not implemented yet |
2152 | //mActionKeyBindings->plug( settingsMenu ); | 2156 | //mActionKeyBindings->plug( settingsMenu ); |
2153 | } | 2157 | } |
2154 | 2158 | ||
2155 | settingsMenu->insertSeparator(); | 2159 | settingsMenu->insertSeparator(); |
2156 | 2160 | ||
2157 | mActionJumpBar->plug( settingsMenu ); | 2161 | mActionJumpBar->plug( settingsMenu ); |
2158 | mActionDetails->plug( settingsMenu ); | 2162 | mActionDetails->plug( settingsMenu ); |
2159 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2163 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2160 | mActionDetails->plug( tb ); | 2164 | mActionDetails->plug( tb ); |
2161 | settingsMenu->insertSeparator(); | 2165 | settingsMenu->insertSeparator(); |
2162 | #ifndef DESKTOP_VERSION | 2166 | #ifndef DESKTOP_VERSION |
2163 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); | 2167 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); |
2164 | #endif | 2168 | #endif |
2165 | settingsMenu->insertSeparator(); | 2169 | settingsMenu->insertSeparator(); |
2166 | 2170 | ||
2167 | mActionWhoAmI->plug( settingsMenu ); | 2171 | mActionWhoAmI->plug( settingsMenu ); |
2168 | mActionEditCategories->plug( settingsMenu ); | 2172 | mActionEditCategories->plug( settingsMenu ); |
2169 | mActionEditCategories->plug( changeMenu ); | 2173 | mActionEditCategories->plug( changeMenu ); |
2170 | mActionCategories->plug( changeMenu ); | 2174 | mActionCategories->plug( changeMenu ); |
2171 | mActionManageCategories->plug( changeMenu ); | 2175 | mActionManageCategories->plug( changeMenu ); |
2172 | 2176 | ||
2173 | mActionCategories->plug( settingsMenu ); | 2177 | mActionCategories->plug( settingsMenu ); |
2174 | mActionManageCategories->plug( settingsMenu ); | 2178 | mActionManageCategories->plug( settingsMenu ); |
2175 | 2179 | ||
2176 | 2180 | ||
2177 | mActionWN->plug( helpMenu ); | 2181 | mActionWN->plug( helpMenu ); |
2178 | mActionSyncHowto->plug( helpMenu ); | 2182 | mActionSyncHowto->plug( helpMenu ); |
2179 | mActionKdeSyncHowto->plug( helpMenu ); | 2183 | mActionKdeSyncHowto->plug( helpMenu ); |
2180 | mActionMultiSyncHowto->plug( helpMenu ); | 2184 | mActionMultiSyncHowto->plug( helpMenu ); |
2181 | mActionFaq->plug( helpMenu ); | 2185 | mActionFaq->plug( helpMenu ); |
2182 | mActionLicence->plug( helpMenu ); | 2186 | mActionLicence->plug( helpMenu ); |
2183 | mActionAboutKAddressbook->plug( helpMenu ); | 2187 | mActionAboutKAddressbook->plug( helpMenu ); |
2184 | 2188 | ||
2185 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2189 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2186 | 2190 | ||
2187 | mActionSave->plug( tb ); | 2191 | mActionSave->plug( tb ); |
2188 | mViewManager->getFilterAction()->plug ( tb); | 2192 | mViewManager->getFilterAction()->plug ( tb); |
2189 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 2193 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
2190 | mActionUndo->plug( tb ); | 2194 | mActionUndo->plug( tb ); |
2191 | mActionDelete->plug( tb ); | 2195 | mActionDelete->plug( tb ); |
2192 | mActionRedo->plug( tb ); | 2196 | mActionRedo->plug( tb ); |
2193 | } | 2197 | } |
2194 | } else { | 2198 | } else { |
2195 | mActionSave->plug( tb ); | 2199 | mActionSave->plug( tb ); |
2196 | tb->enableMoving(false); | 2200 | tb->enableMoving(false); |
2197 | } | 2201 | } |
2198 | //mActionQuit->plug ( tb ); | 2202 | //mActionQuit->plug ( tb ); |
2199 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2203 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2200 | 2204 | ||
2201 | //US link the searchwidget first to this. | 2205 | //US link the searchwidget first to this. |
2202 | // The real linkage to the toolbar happens later. | 2206 | // The real linkage to the toolbar happens later. |
2203 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2207 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2204 | //US tb->insertItem( mIncSearchWidget ); | 2208 | //US tb->insertItem( mIncSearchWidget ); |
2205 | /*US | 2209 | /*US |
2206 | mIncSearchWidget = new IncSearchWidget( tb ); | 2210 | mIncSearchWidget = new IncSearchWidget( tb ); |
2207 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2211 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2208 | SLOT( incrementalSearch( const QString& ) ) ); | 2212 | SLOT( incrementalSearch( const QString& ) ) ); |
2209 | 2213 | ||
2210 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2214 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2211 | 2215 | ||
2212 | //US topLayout->addWidget( mJumpButtonBar ); | 2216 | //US topLayout->addWidget( mJumpButtonBar ); |
2213 | this->layout()->add( mJumpButtonBar ); | 2217 | this->layout()->add( mJumpButtonBar ); |
2214 | */ | 2218 | */ |
2215 | 2219 | ||
2216 | #endif //KAB_EMBEDDED | 2220 | #endif //KAB_EMBEDDED |
2217 | 2221 | ||
2218 | mActionExport2phone->plug( ExportMenu ); | 2222 | mActionExport2phone->plug( ExportMenu ); |
2219 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2223 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2220 | syncManager->fillSyncMenu(); | 2224 | syncManager->fillSyncMenu(); |
2221 | 2225 | ||
2222 | } | 2226 | } |
2223 | void KABCore::showLicence() | 2227 | void KABCore::showLicence() |
2224 | { | 2228 | { |
2225 | KApplication::showLicence(); | 2229 | KApplication::showLicence(); |
2226 | } | 2230 | } |
2227 | 2231 | ||
2228 | void KABCore::manageCategories( ) | 2232 | void KABCore::manageCategories( ) |
2229 | { | 2233 | { |
2230 | KABCatPrefs* cp = new KABCatPrefs(); | 2234 | KABCatPrefs* cp = new KABCatPrefs(); |
2231 | cp->show(); | 2235 | cp->show(); |
2232 | int w =cp->sizeHint().width() ; | 2236 | int w =cp->sizeHint().width() ; |
2233 | int h = cp->sizeHint().height() ; | 2237 | int h = cp->sizeHint().height() ; |
2234 | int dw = QApplication::desktop()->width(); | 2238 | int dw = QApplication::desktop()->width(); |
2235 | int dh = QApplication::desktop()->height(); | 2239 | int dh = QApplication::desktop()->height(); |
2236 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2240 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2237 | if ( !cp->exec() ) { | 2241 | if ( !cp->exec() ) { |
2238 | delete cp; | 2242 | delete cp; |
2239 | return; | 2243 | return; |
2240 | } | 2244 | } |
2241 | int count = 0; | 2245 | int count = 0; |
2242 | message( i18n("Please wait, processing categories...")); | 2246 | message( i18n("Please wait, processing categories...")); |
2243 | if ( cp->addCat() ) { | 2247 | if ( cp->addCat() ) { |
2244 | KABC::AddressBook::Iterator it; | 2248 | KABC::AddressBook::Iterator it; |
2245 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2249 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2246 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2250 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2247 | QStringList catIncList = (*it).categories(); | 2251 | QStringList catIncList = (*it).categories(); |
2248 | int i; | 2252 | int i; |
2249 | for( i = 0; i< catIncList.count(); ++i ) { | 2253 | for( i = 0; i< catIncList.count(); ++i ) { |
2250 | if ( !catList.contains (catIncList[i])) { | 2254 | if ( !catList.contains (catIncList[i])) { |
2251 | catList.append( catIncList[i] ); | 2255 | catList.append( catIncList[i] ); |
2252 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2256 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2253 | ++count; | 2257 | ++count; |
2254 | } | 2258 | } |
2255 | } | 2259 | } |
2256 | } | 2260 | } |
2257 | catList.sort(); | 2261 | catList.sort(); |
2258 | KABPrefs::instance()->mCustomCategories = catList; | 2262 | KABPrefs::instance()->mCustomCategories = catList; |
2259 | KABPrefs::instance()->writeConfig(); | 2263 | KABPrefs::instance()->writeConfig(); |
2260 | message(QString::number( count )+ i18n(" categories added to list! ")); | 2264 | message(QString::number( count )+ i18n(" categories added to list! ")); |
2261 | } else { | 2265 | } else { |
2262 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2266 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2263 | QStringList catIncList; | 2267 | QStringList catIncList; |
2264 | QStringList newCatList; | 2268 | QStringList newCatList; |
2265 | KABC::AddressBook::Iterator it; | 2269 | KABC::AddressBook::Iterator it; |
2266 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2270 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2267 | QStringList catIncList = (*it).categories(); | 2271 | QStringList catIncList = (*it).categories(); |
2268 | int i; | 2272 | int i; |
2269 | if ( catIncList.count() ) { | 2273 | if ( catIncList.count() ) { |
2270 | newCatList.clear(); | 2274 | newCatList.clear(); |
2271 | for( i = 0; i< catIncList.count(); ++i ) { | 2275 | for( i = 0; i< catIncList.count(); ++i ) { |
2272 | if ( catList.contains (catIncList[i])) { | 2276 | if ( catList.contains (catIncList[i])) { |
2273 | newCatList.append( catIncList[i] ); | 2277 | newCatList.append( catIncList[i] ); |
2274 | } | 2278 | } |
2275 | } | 2279 | } |
2276 | newCatList.sort(); | 2280 | newCatList.sort(); |
2277 | (*it).setCategories( newCatList ); | 2281 | (*it).setCategories( newCatList ); |
2278 | mAddressBook->insertAddressee( (*it) ); | 2282 | mAddressBook->insertAddressee( (*it) ); |
2279 | } | 2283 | } |
2280 | } | 2284 | } |
2281 | setModified( true ); | 2285 | setModified( true ); |
2282 | mViewManager->refreshView(); | 2286 | mViewManager->refreshView(); |
2283 | mDetails->refreshView(); | 2287 | mDetails->refreshView(); |
2284 | message( i18n("Removing categories done!")); | 2288 | message( i18n("Removing categories done!")); |
2285 | } | 2289 | } |
2286 | delete cp; | 2290 | delete cp; |
2287 | } | 2291 | } |
2288 | void KABCore::removeVoice() | 2292 | void KABCore::removeVoice() |
2289 | { | 2293 | { |
2290 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) | 2294 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) |
2291 | return; | 2295 | return; |
2292 | KABC::Addressee::List list; | 2296 | KABC::Addressee::List list; |
2293 | XXPortSelectDialog dlg( this, false, this ); | 2297 | XXPortSelectDialog dlg( this, false, this ); |
2294 | if ( dlg.exec() ) | 2298 | if ( dlg.exec() ) |
2295 | list = dlg.contacts(); | 2299 | list = dlg.contacts(); |
2296 | else | 2300 | else |
2297 | return; | 2301 | return; |
2298 | KABC::Addressee::List::Iterator it; | 2302 | KABC::Addressee::List::Iterator it; |
2299 | for ( it = list.begin(); it != list.end(); ++it ) { | 2303 | for ( it = list.begin(); it != list.end(); ++it ) { |
2300 | if ( (*it).removeVoice() ) | 2304 | if ( (*it).removeVoice() ) |
2301 | contactModified((*it) ); | 2305 | contactModified((*it) ); |
2302 | } | 2306 | } |
2303 | } | 2307 | } |
2304 | 2308 | ||
2305 | 2309 | ||
2306 | 2310 | ||
2307 | void KABCore::clipboardDataChanged() | 2311 | void KABCore::clipboardDataChanged() |
2308 | { | 2312 | { |
2309 | 2313 | ||
2310 | if ( mReadWrite ) | 2314 | if ( mReadWrite ) |
2311 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2315 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2312 | 2316 | ||
2313 | } | 2317 | } |
2314 | 2318 | ||
2315 | void KABCore::updateActionMenu() | 2319 | void KABCore::updateActionMenu() |
2316 | { | 2320 | { |
2317 | UndoStack *undo = UndoStack::instance(); | 2321 | UndoStack *undo = UndoStack::instance(); |
2318 | RedoStack *redo = RedoStack::instance(); | 2322 | RedoStack *redo = RedoStack::instance(); |
2319 | 2323 | ||
2320 | if ( undo->isEmpty() ) | 2324 | if ( undo->isEmpty() ) |
2321 | mActionUndo->setText( i18n( "Undo" ) ); | 2325 | mActionUndo->setText( i18n( "Undo" ) ); |
2322 | else | 2326 | else |
2323 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2327 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2324 | 2328 | ||
2325 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2329 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2326 | 2330 | ||
2327 | if ( !redo->top() ) | 2331 | if ( !redo->top() ) |
2328 | mActionRedo->setText( i18n( "Redo" ) ); | 2332 | mActionRedo->setText( i18n( "Redo" ) ); |
2329 | else | 2333 | else |
2330 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2334 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2331 | 2335 | ||
2332 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2336 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2333 | } | 2337 | } |
2334 | 2338 | ||
2335 | void KABCore::configureKeyBindings() | 2339 | void KABCore::configureKeyBindings() |
2336 | { | 2340 | { |
2337 | #ifndef KAB_EMBEDDED | 2341 | #ifndef KAB_EMBEDDED |
2338 | KKeyDialog::configure( actionCollection(), true ); | 2342 | KKeyDialog::configure( actionCollection(), true ); |
2339 | #else //KAB_EMBEDDED | 2343 | #else //KAB_EMBEDDED |
2340 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2344 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2341 | #endif //KAB_EMBEDDED | 2345 | #endif //KAB_EMBEDDED |
2342 | } | 2346 | } |
2343 | 2347 | ||
2344 | #ifdef KAB_EMBEDDED | 2348 | #ifdef KAB_EMBEDDED |
2345 | void KABCore::configureResources() | 2349 | void KABCore::configureResources() |
2346 | { | 2350 | { |
2347 | KRES::KCMKResources dlg( this, "" , 0 ); | 2351 | KRES::KCMKResources dlg( this, "" , 0 ); |
2348 | 2352 | ||
2349 | if ( !dlg.exec() ) | 2353 | if ( !dlg.exec() ) |
2350 | return; | 2354 | return; |
2351 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2355 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2352 | } | 2356 | } |
2353 | #endif //KAB_EMBEDDED | 2357 | #endif //KAB_EMBEDDED |
2354 | 2358 | ||
2355 | 2359 | ||
2356 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2360 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2357 | * for the attendees list of an event. | 2361 | * for the attendees list of an event. |
2358 | */ | 2362 | */ |
2359 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2363 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2360 | { | 2364 | { |
2361 | QStringList nameList; | 2365 | QStringList nameList; |
2362 | QStringList emailList; | 2366 | QStringList emailList; |
2363 | QStringList uidList; | 2367 | QStringList uidList; |
2364 | 2368 | ||
2365 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2369 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2366 | uint i=0; | 2370 | uint i=0; |
2367 | for (i=0; i < list.count(); i++) | 2371 | for (i=0; i < list.count(); i++) |
2368 | { | 2372 | { |
2369 | nameList.append(list[i].realName()); | 2373 | nameList.append(list[i].realName()); |
2370 | emailList.append(list[i].preferredEmail()); | 2374 | emailList.append(list[i].preferredEmail()); |
2371 | uidList.append(list[i].uid()); | 2375 | uidList.append(list[i].uid()); |
2372 | } | 2376 | } |
2373 | 2377 | ||
2374 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2378 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2375 | 2379 | ||
2376 | } | 2380 | } |
2377 | 2381 | ||
2378 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2382 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2379 | * to put them into the calendar. | 2383 | * to put them into the calendar. |
2380 | */ | 2384 | */ |
2381 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2385 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2382 | { | 2386 | { |
2383 | // qDebug("KABCore::requestForBirthdayList"); | 2387 | // qDebug("KABCore::requestForBirthdayList"); |
2384 | QStringList birthdayList; | 2388 | QStringList birthdayList; |
2385 | QStringList anniversaryList; | 2389 | QStringList anniversaryList; |
2386 | QStringList realNameList; | 2390 | QStringList realNameList; |
2387 | QStringList preferredEmailList; | 2391 | QStringList preferredEmailList; |
2388 | QStringList assembledNameList; | 2392 | QStringList assembledNameList; |
2389 | QStringList uidList; | 2393 | QStringList uidList; |
2390 | 2394 | ||
2391 | KABC::AddressBook::Iterator it; | 2395 | KABC::AddressBook::Iterator it; |
2392 | 2396 | ||
2393 | int count = 0; | 2397 | int count = 0; |
2394 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2398 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2395 | ++count; | 2399 | ++count; |
2396 | } | 2400 | } |
2397 | QProgressBar bar(count,0 ); | 2401 | QProgressBar bar(count,0 ); |
2398 | int w = 300; | 2402 | int w = 300; |
2399 | if ( QApplication::desktop()->width() < 320 ) | 2403 | if ( QApplication::desktop()->width() < 320 ) |
2400 | w = 220; | 2404 | w = 220; |
2401 | int h = bar.sizeHint().height() ; | 2405 | int h = bar.sizeHint().height() ; |
2402 | int dw = QApplication::desktop()->width(); | 2406 | int dw = QApplication::desktop()->width(); |
2403 | int dh = QApplication::desktop()->height(); | 2407 | int dh = QApplication::desktop()->height(); |
2404 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2408 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2405 | bar.show(); | 2409 | bar.show(); |
2406 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); | 2410 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); |
2407 | qApp->processEvents(); | 2411 | qApp->processEvents(); |
2408 | 2412 | ||
2409 | QDate bday; | 2413 | QDate bday; |
2410 | QString anni; | 2414 | QString anni; |
2411 | QString formattedbday; | 2415 | QString formattedbday; |
2412 | 2416 | ||
2413 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2417 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2414 | { | 2418 | { |
2415 | if ( ! bar.isVisible() ) | 2419 | if ( ! bar.isVisible() ) |
2416 | return; | 2420 | return; |
2417 | bar.setProgress( count++ ); | 2421 | bar.setProgress( count++ ); |
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 | |||
@@ -1,2260 +1,2266 @@ | |||
1 | /* This file is part of the KDE libraries | 1 | /* This file is part of the KDE libraries |
2 | Copyright | 2 | Copyright |
3 | (C) 2000 Reginald Stadlbauer (reggie@kde.org) | 3 | (C) 2000 Reginald Stadlbauer (reggie@kde.org) |
4 | (C) 1997, 1998 Stephan Kulow (coolo@kde.org) | 4 | (C) 1997, 1998 Stephan Kulow (coolo@kde.org) |
5 | (C) 1997, 1998 Mark Donohoe (donohoe@kde.org) | 5 | (C) 1997, 1998 Mark Donohoe (donohoe@kde.org) |
6 | (C) 1997, 1998 Sven Radej (radej@kde.org) | 6 | (C) 1997, 1998 Sven Radej (radej@kde.org) |
7 | (C) 1997, 1998 Matthias Ettrich (ettrich@kde.org) | 7 | (C) 1997, 1998 Matthias Ettrich (ettrich@kde.org) |
8 | (C) 1999 Chris Schlaeger (cs@kde.org) | 8 | (C) 1999 Chris Schlaeger (cs@kde.org) |
9 | (C) 1999 Kurt Granroth (granroth@kde.org) | 9 | (C) 1999 Kurt Granroth (granroth@kde.org) |
10 | 10 | ||
11 | This library is free software; you can redistribute it and/or | 11 | This library is free software; you can redistribute it and/or |
12 | modify it under the terms of the GNU Library General Public | 12 | modify it under the terms of the GNU Library General Public |
13 | License version 2 as published by the Free Software Foundation. | 13 | License version 2 as published by the Free Software Foundation. |
14 | 14 | ||
15 | This library is distributed in the hope that it will be useful, | 15 | This library is distributed in the hope that it will be useful, |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
18 | Library General Public License for more details. | 18 | Library General Public License for more details. |
19 | 19 | ||
20 | You should have received a copy of the GNU Library General Public License | 20 | You should have received a copy of the GNU Library General Public License |
21 | along with this library; see the file COPYING.LIB. If not, write to | 21 | along with this library; see the file COPYING.LIB. If not, write to |
22 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 22 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
23 | Boston, MA 02111-1307, USA. | 23 | Boston, MA 02111-1307, USA. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #ifdef KDE_USE_FINAL | 26 | #ifdef KDE_USE_FINAL |
27 | #undef Always | 27 | #undef Always |
28 | #include <qdockwindow.h> | 28 | #include <qdockwindow.h> |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | 31 | ||
32 | 32 | ||
33 | #include "ktoolbar.h" | 33 | #include "ktoolbar.h" |
34 | #include "kmainwindow.h" | 34 | #include "kmainwindow.h" |
35 | 35 | ||
36 | #include <string.h> | 36 | #include <string.h> |
37 | 37 | ||
38 | #include <qpainter.h> | 38 | #include <qpainter.h> |
39 | #include <qtooltip.h> | 39 | #include <qtooltip.h> |
40 | #include <qdrawutil.h> | 40 | #include <qdrawutil.h> |
41 | #include <qstring.h> | 41 | #include <qstring.h> |
42 | #include <qrect.h> | 42 | #include <qrect.h> |
43 | #include <qobjectlist.h> | 43 | #include <qobjectlist.h> |
44 | #include <qtimer.h> | 44 | #include <qtimer.h> |
45 | #include <qstyle.h> | 45 | #include <qstyle.h> |
46 | #include <qapplication.h> | 46 | #include <qapplication.h> |
47 | 47 | ||
48 | //US #include <config.h> | 48 | //US #include <config.h> |
49 | 49 | ||
50 | #include "klineedit.h" | 50 | #include "klineedit.h" |
51 | #include "kseparator.h" | 51 | #include "kseparator.h" |
52 | #include <klocale.h> | 52 | #include <klocale.h> |
53 | #include <kapplication.h> | 53 | #include <kapplication.h> |
54 | #include <kaction.h> | 54 | #include <kaction.h> |
55 | #include <kstdaction.h> | 55 | #include <kstdaction.h> |
56 | #include <kglobal.h> | 56 | #include <kglobal.h> |
57 | #include <kconfig.h> | 57 | #include <kconfig.h> |
58 | #include <kiconloader.h> | 58 | #include <kiconloader.h> |
59 | #include <kcombobox.h> | 59 | #include <kcombobox.h> |
60 | //US #include <kpopupmenu.h> | 60 | //US #include <kpopupmenu.h> |
61 | //US #include <kanimwidget.h> | 61 | //US #include <kanimwidget.h> |
62 | //US #include <kipc.h> | 62 | //US #include <kipc.h> |
63 | //US #include <kwin.h> | 63 | //US #include <kwin.h> |
64 | #include <kdebug.h> | 64 | #include <kdebug.h> |
65 | #include <qlayout.h> | 65 | #include <qlayout.h> |
66 | 66 | ||
67 | #include "ktoolbarbutton.h" | 67 | #include "ktoolbarbutton.h" |
68 | 68 | ||
69 | //US | 69 | //US |
70 | #include "kconfigbase.h" | 70 | #include "kconfigbase.h" |
71 | 71 | ||
72 | #include <qpopupmenu.h> | 72 | #include <qpopupmenu.h> |
73 | #include <qmainwindow.h> | 73 | #include <qmainwindow.h> |
74 | 74 | ||
75 | enum { | 75 | enum { |
76 | CONTEXT_TOP = 0, | 76 | CONTEXT_TOP = 0, |
77 | CONTEXT_LEFT = 1, | 77 | CONTEXT_LEFT = 1, |
78 | CONTEXT_RIGHT = 2, | 78 | CONTEXT_RIGHT = 2, |
79 | CONTEXT_BOTTOM = 3, | 79 | CONTEXT_BOTTOM = 3, |
80 | CONTEXT_FLOAT = 4, | 80 | CONTEXT_FLOAT = 4, |
81 | CONTEXT_FLAT = 5, | 81 | CONTEXT_FLAT = 5, |
82 | CONTEXT_ICONS = 6, | 82 | CONTEXT_ICONS = 6, |
83 | CONTEXT_TEXT = 7, | 83 | CONTEXT_TEXT = 7, |
84 | CONTEXT_TEXTRIGHT = 8, | 84 | CONTEXT_TEXTRIGHT = 8, |
85 | CONTEXT_TEXTUNDER = 9, | 85 | CONTEXT_TEXTUNDER = 9, |
86 | CONTEXT_ICONSIZES = 50 // starting point for the icon size list, put everything else before | 86 | CONTEXT_ICONSIZES = 50 // starting point for the icon size list, put everything else before |
87 | }; | 87 | }; |
88 | 88 | ||
89 | class KToolBarPrivate | 89 | class KToolBarPrivate |
90 | { | 90 | { |
91 | public: | 91 | public: |
92 | KToolBarPrivate() { | 92 | KToolBarPrivate() { |
93 | m_iconSize = 0; | 93 | m_iconSize = 0; |
94 | m_iconText = KToolBar::IconOnly; | 94 | m_iconText = KToolBar::IconOnly; |
95 | m_highlight = true; | 95 | m_highlight = true; |
96 | m_transparent = true; | 96 | m_transparent = true; |
97 | m_honorStyle = false; | 97 | m_honorStyle = false; |
98 | 98 | ||
99 | m_enableContext = true; | 99 | m_enableContext = true; |
100 | 100 | ||
101 | m_xmlguiClient = 0; | 101 | m_xmlguiClient = 0; |
102 | m_configurePlugged = false; | 102 | m_configurePlugged = false; |
103 | 103 | ||
104 | //US oldPos = Qt::DockUnmanaged; | 104 | //US oldPos = Qt::DockUnmanaged; |
105 | oldPos = QMainWindow::Unmanaged; | 105 | oldPos = QMainWindow::Unmanaged; |
106 | 106 | ||
107 | modified = m_isHorizontal = positioned = FALSE; | 107 | modified = m_isHorizontal = positioned = FALSE; |
108 | 108 | ||
109 | HiddenDefault = false; | 109 | HiddenDefault = false; |
110 | IconSizeDefault = 0; | 110 | IconSizeDefault = 0; |
111 | IconTextDefault = "IconOnly"; | 111 | IconTextDefault = "IconOnly"; |
112 | IndexDefault = -1; | 112 | IndexDefault = -1; |
113 | NewLineDefault = false; | 113 | NewLineDefault = false; |
114 | OffsetDefault = -1; | 114 | OffsetDefault = -1; |
115 | PositionDefault = "Top"; | 115 | PositionDefault = "Top"; |
116 | idleButtons.setAutoDelete(true); | 116 | idleButtons.setAutoDelete(true); |
117 | } | 117 | } |
118 | 118 | ||
119 | int m_iconSize; | 119 | int m_iconSize; |
120 | KToolBar::IconText m_iconText; | 120 | KToolBar::IconText m_iconText; |
121 | bool m_highlight : 1; | 121 | bool m_highlight : 1; |
122 | bool m_transparent : 1; | 122 | bool m_transparent : 1; |
123 | bool m_honorStyle : 1; | 123 | bool m_honorStyle : 1; |
124 | bool m_isHorizontal : 1; | 124 | bool m_isHorizontal : 1; |
125 | bool m_enableContext : 1; | 125 | bool m_enableContext : 1; |
126 | bool m_configurePlugged : 1; | 126 | bool m_configurePlugged : 1; |
127 | bool modified : 1; | 127 | bool modified : 1; |
128 | bool positioned : 1; | 128 | bool positioned : 1; |
129 | 129 | ||
130 | QWidget *m_parent; | 130 | QWidget *m_parent; |
131 | 131 | ||
132 | QMainWindow::ToolBarDock oldPos; | 132 | QMainWindow::ToolBarDock oldPos; |
133 | 133 | ||
134 | KXMLGUIClient *m_xmlguiClient; | 134 | KXMLGUIClient *m_xmlguiClient; |
135 | 135 | ||
136 | struct ToolBarInfo | 136 | struct ToolBarInfo |
137 | { | 137 | { |
138 | //US ToolBarInfo() : index( 0 ), offset( -1 ), newline( FALSE ), dock( Qt::DockTop ) {} | 138 | //US ToolBarInfo() : index( 0 ), offset( -1 ), newline( FALSE ), dock( Qt::DockTop ) {} |
139 | ToolBarInfo() : index( 0 ), offset( -1 ), newline( FALSE ), dock( QMainWindow::Top ) {} | 139 | ToolBarInfo() : index( 0 ), offset( -1 ), newline( FALSE ), dock( QMainWindow::Top ) {} |
140 | //US ToolBarInfo( Qt::Dock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {} | 140 | //US ToolBarInfo( Qt::Dock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {} |
141 | ToolBarInfo( QMainWindow::ToolBarDock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {} | 141 | ToolBarInfo( QMainWindow::ToolBarDock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {} |
142 | int index, offset; | 142 | int index, offset; |
143 | bool newline; | 143 | bool newline; |
144 | //US Qt::Dock dock; | 144 | //US Qt::Dock dock; |
145 | QMainWindow::ToolBarDock dock; | 145 | QMainWindow::ToolBarDock dock; |
146 | }; | 146 | }; |
147 | 147 | ||
148 | ToolBarInfo toolBarInfo; | 148 | ToolBarInfo toolBarInfo; |
149 | QValueList<int> iconSizes; | 149 | QValueList<int> iconSizes; |
150 | QTimer repaintTimer; | 150 | QTimer repaintTimer; |
151 | 151 | ||
152 | // Default Values. | 152 | // Default Values. |
153 | bool HiddenDefault; | 153 | bool HiddenDefault; |
154 | int IconSizeDefault; | 154 | int IconSizeDefault; |
155 | QString IconTextDefault; | 155 | QString IconTextDefault; |
156 | int IndexDefault; | 156 | int IndexDefault; |
157 | bool NewLineDefault; | 157 | bool NewLineDefault; |
158 | int OffsetDefault; | 158 | int OffsetDefault; |
159 | QString PositionDefault; | 159 | QString PositionDefault; |
160 | 160 | ||
161 | QPtrList<QWidget> idleButtons; | 161 | QPtrList<QWidget> idleButtons; |
162 | }; | 162 | }; |
163 | 163 | ||
164 | KToolBarSeparator::KToolBarSeparator(Orientation o , bool l, QToolBar *parent, | 164 | KToolBarSeparator::KToolBarSeparator(Orientation o , bool l, QToolBar *parent, |
165 | const char* name ) | 165 | const char* name ) |
166 | :QFrame( parent, name ), line( l ) | 166 | :QFrame( parent, name ), line( l ) |
167 | { | 167 | { |
168 | connect( parent, SIGNAL(orientationChanged(Orientation)), | 168 | connect( parent, SIGNAL(orientationChanged(Orientation)), |
169 | this, SLOT(setOrientation(Orientation)) ); | 169 | this, SLOT(setOrientation(Orientation)) ); |
170 | setOrientation( o ); | 170 | setOrientation( o ); |
171 | setBackgroundMode( parent->backgroundMode() ); | 171 | setBackgroundMode( parent->backgroundMode() ); |
172 | setBackgroundOrigin( ParentOrigin ); | 172 | setBackgroundOrigin( ParentOrigin ); |
173 | } | 173 | } |
174 | 174 | ||
175 | void KToolBarSeparator::setOrientation( Orientation o ) | 175 | void KToolBarSeparator::setOrientation( Orientation o ) |
176 | { | 176 | { |
177 | orient = o; | 177 | orient = o; |
178 | if ( line ) { | 178 | if ( line ) { |
179 | if ( orientation() == Vertical ) | 179 | if ( orientation() == Vertical ) |
180 | setFrameStyle( HLine + Sunken ); | 180 | setFrameStyle( HLine + Sunken ); |
181 | else | 181 | else |
182 | setFrameStyle( VLine + Sunken ); | 182 | setFrameStyle( VLine + Sunken ); |
183 | } else { | 183 | } else { |
184 | setFrameStyle( NoFrame ); | 184 | setFrameStyle( NoFrame ); |
185 | } | 185 | } |
186 | } | 186 | } |
187 | 187 | ||
188 | void KToolBarSeparator::styleChange( QStyle& ) | 188 | void KToolBarSeparator::styleChange( QStyle& ) |
189 | { | 189 | { |
190 | setOrientation( orient ); | 190 | setOrientation( orient ); |
191 | } | 191 | } |
192 | 192 | ||
193 | QSize KToolBarSeparator::sizeHint() const | 193 | QSize KToolBarSeparator::sizeHint() const |
194 | { | 194 | { |
195 | return orientation() == Vertical ? QSize( 0, 6 ) : QSize( 6, 0 ); | 195 | return orientation() == Vertical ? QSize( 0, 6 ) : QSize( 6, 0 ); |
196 | } | 196 | } |
197 | 197 | ||
198 | QSizePolicy KToolBarSeparator::sizePolicy() const | 198 | QSizePolicy KToolBarSeparator::sizePolicy() const |
199 | { | 199 | { |
200 | return QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); | 200 | return QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); |
201 | } | 201 | } |
202 | 202 | ||
203 | KToolBar::KToolBar( QWidget *parent, const char *name, bool honorStyle, bool readConfig ) | 203 | KToolBar::KToolBar( QWidget *parent, const char *name, bool honorStyle, bool readConfig ) |
204 | #ifdef DESKTOP_VERSION | 204 | #ifdef DESKTOP_VERSION |
205 | : QToolBar( QString::fromLatin1( name ), | 205 | : QToolBar( QString::fromLatin1( name ), |
206 | parent && parent->inherits( "QMainWindow" ) ? static_cast<QMainWindow*>(parent) : 0, | 206 | parent && parent->inherits( "QMainWindow" ) ? static_cast<QMainWindow*>(parent) : 0, |
207 | parent, FALSE, | 207 | parent, FALSE, |
208 | name ? name : "mainToolBar") | 208 | name ? name : "mainToolBar") |
209 | #else | 209 | #else |
210 | : QPEToolBar( parent && parent->inherits( "QMainWindow" ) ? static_cast<QMainWindow*>(parent) : 0, | 210 | : QPEToolBar( parent && parent->inherits( "QMainWindow" ) ? static_cast<QMainWindow*>(parent) : 0, |
211 | QString::fromLatin1( name )) | 211 | QString::fromLatin1( name )) |
212 | 212 | ||
213 | 213 | ||
214 | #endif | 214 | #endif |
215 | { | 215 | { |
216 | init( readConfig, honorStyle ); | 216 | init( readConfig, honorStyle ); |
217 | } | 217 | } |
218 | 218 | ||
219 | KToolBar::KToolBar( QMainWindow *parentWindow, QMainWindow::ToolBarDock dock, bool newLine, const char *name, bool honorStyle, bool readConfig ) | 219 | KToolBar::KToolBar( QMainWindow *parentWindow, QMainWindow::ToolBarDock dock, bool newLine, const char *name, bool honorStyle, bool readConfig ) |
220 | #ifdef DESKTOP_VERSION | 220 | #ifdef DESKTOP_VERSION |
221 | : QToolBar( QString::fromLatin1( name ), | 221 | : QToolBar( QString::fromLatin1( name ), |
222 | parentWindow, dock, newLine, | 222 | parentWindow, dock, newLine, |
223 | name ? name : "mainToolBar") | 223 | name ? name : "mainToolBar") |
224 | #else | 224 | #else |
225 | : QPEToolBar( parentWindow,QString::fromLatin1( name )) | 225 | : QPEToolBar( parentWindow,QString::fromLatin1( name )) |
226 | 226 | ||
227 | 227 | ||
228 | #endif | 228 | #endif |
229 | 229 | ||
230 | { | 230 | { |
231 | init( readConfig, honorStyle ); | 231 | init( readConfig, honorStyle ); |
232 | } | 232 | } |
233 | 233 | ||
234 | KToolBar::KToolBar( QMainWindow *parentWindow, QWidget *dock, bool newLine, const char *name, bool honorStyle, bool readConfig ) | 234 | KToolBar::KToolBar( QMainWindow *parentWindow, QWidget *dock, bool newLine, const char *name, bool honorStyle, bool readConfig ) |
235 | #ifdef DESKTOP_VERSION | 235 | #ifdef DESKTOP_VERSION |
236 | : QToolBar( QString::fromLatin1( name ), | 236 | : QToolBar( QString::fromLatin1( name ), |
237 | parentWindow, dock, newLine, | 237 | parentWindow, dock, newLine, |
238 | name ? name : "mainToolBar") | 238 | name ? name : "mainToolBar") |
239 | #else | 239 | #else |
240 | : QPEToolBar( parentWindow,QString::fromLatin1( name )) | 240 | : QPEToolBar( parentWindow,QString::fromLatin1( name )) |
241 | 241 | ||
242 | 242 | ||
243 | #endif | 243 | #endif |
244 | 244 | ||
245 | { | 245 | { |
246 | init( readConfig, honorStyle ); | 246 | init( readConfig, honorStyle ); |
247 | } | 247 | } |
248 | 248 | ||
249 | KToolBar::~KToolBar() | 249 | KToolBar::~KToolBar() |
250 | { | 250 | { |
251 | inshutdownprocess = true; | 251 | inshutdownprocess = true; |
252 | emit toolbarDestroyed(); | 252 | emit toolbarDestroyed(); |
253 | delete d; | 253 | delete d; |
254 | } | 254 | } |
255 | 255 | ||
256 | void KToolBar::init( bool readConfig, bool honorStyle ) | 256 | void KToolBar::init( bool readConfig, bool honorStyle ) |
257 | { | 257 | { |
258 | inshutdownprocess = false; | 258 | inshutdownprocess = false; |
259 | d = new KToolBarPrivate; | 259 | d = new KToolBarPrivate; |
260 | setFullSize( TRUE ); | 260 | setFullSize( TRUE ); |
261 | d->m_honorStyle = honorStyle; | 261 | d->m_honorStyle = honorStyle; |
262 | context = 0; | 262 | context = 0; |
263 | layoutTimer = new QTimer( this ); | 263 | layoutTimer = new QTimer( this ); |
264 | connect( layoutTimer, SIGNAL( timeout() ), | 264 | connect( layoutTimer, SIGNAL( timeout() ), |
265 | this, SLOT( rebuildLayout() ) ); | 265 | this, SLOT( rebuildLayout() ) ); |
266 | connect( &(d->repaintTimer), SIGNAL( timeout() ), | 266 | connect( &(d->repaintTimer), SIGNAL( timeout() ), |
267 | this, SLOT( slotRepaint() ) ); | 267 | this, SLOT( slotRepaint() ) ); |
268 | /*US | 268 | /*US |
269 | if ( kapp ) { // may be null when started inside designer | 269 | if ( kapp ) { // may be null when started inside designer |
270 | connect(kapp, SIGNAL(toolbarAppearanceChanged(int)), this, SLOT(slotAppearanceChanged())); | 270 | connect(kapp, SIGNAL(toolbarAppearanceChanged(int)), this, SLOT(slotAppearanceChanged())); |
271 | // request notification of changes in icon style | 271 | // request notification of changes in icon style |
272 | kapp->addKipcEventMask(KIPC::IconChanged); | 272 | kapp->addKipcEventMask(KIPC::IconChanged); |
273 | connect(kapp, SIGNAL(iconChanged(int)), this, SLOT(slotIconChanged(int))); | 273 | connect(kapp, SIGNAL(iconChanged(int)), this, SLOT(slotIconChanged(int))); |
274 | } | 274 | } |
275 | */ | 275 | */ |
276 | // finally, read in our configurable settings | 276 | // finally, read in our configurable settings |
277 | if ( readConfig ) | 277 | if ( readConfig ) |
278 | slotReadConfig(); | 278 | slotReadConfig(); |
279 | 279 | ||
280 | if ( mainWindow() ) | 280 | if ( mainWindow() ) |
281 | connect( mainWindow(), SIGNAL( toolBarPositionChanged( QToolBar * ) ), | 281 | connect( mainWindow(), SIGNAL( toolBarPositionChanged( QToolBar * ) ), |
282 | this, SLOT( toolBarPosChanged( QToolBar * ) ) ); | 282 | this, SLOT( toolBarPosChanged( QToolBar * ) ) ); |
283 | 283 | ||
284 | // Hack to make sure we recalculate our size when we dock. | 284 | // Hack to make sure we recalculate our size when we dock. |
285 | //US connect( this, SIGNAL(placeChanged(QDockWindow::Place)), SLOT(rebuildLayout()) ); | 285 | //US connect( this, SIGNAL(placeChanged(QDockWindow::Place)), SLOT(rebuildLayout()) ); |
286 | } | 286 | } |
287 | 287 | ||
288 | int KToolBar::insertButton(const QString& icon, int id, bool enabled, | 288 | int KToolBar::insertButton(const QString& icon, int id, bool enabled, |
289 | const QString& text, int index/*US, KInstance *_instance*/ ) | 289 | const QString& text, int index/*US, KInstance *_instance*/ ) |
290 | { | 290 | { |
291 | KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/ ); | 291 | KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/ ); |
292 | 292 | ||
293 | insertWidgetInternal( button, index, id ); | 293 | insertWidgetInternal( button, index, id ); |
294 | button->setEnabled( enabled ); | 294 | button->setEnabled( enabled ); |
295 | doConnections( button ); | 295 | doConnections( button ); |
296 | return index; | 296 | return index; |
297 | } | 297 | } |
298 | 298 | ||
299 | 299 | ||
300 | int KToolBar::insertButton(const QString& icon, int id, const char *signal, | 300 | int KToolBar::insertButton(const QString& icon, int id, const char *signal, |
301 | const QObject *receiver, const char *slot, | 301 | const QObject *receiver, const char *slot, |
302 | bool enabled, const QString& text, int index/*US, KInstance *_instance*/ ) | 302 | bool enabled, const QString& text, int index/*US, KInstance *_instance*/ ) |
303 | { | 303 | { |
304 | KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/); | 304 | KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/); |
305 | insertWidgetInternal( button, index, id ); | 305 | insertWidgetInternal( button, index, id ); |
306 | button->setEnabled( enabled ); | 306 | button->setEnabled( enabled ); |
307 | connect( button, signal, receiver, slot ); | 307 | connect( button, signal, receiver, slot ); |
308 | doConnections( button ); | 308 | doConnections( button ); |
309 | return index; | 309 | return index; |
310 | } | 310 | } |
311 | 311 | ||
312 | 312 | ||
313 | int KToolBar::insertButton(const QPixmap& pixmap, int id, bool enabled, | 313 | int KToolBar::insertButton(const QPixmap& pixmap, int id, bool enabled, |
314 | const QString& text, int index ) | 314 | const QString& text, int index ) |
315 | { | 315 | { |
316 | KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text); | 316 | KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text); |
317 | insertWidgetInternal( button, index, id ); | 317 | insertWidgetInternal( button, index, id ); |
318 | button->setEnabled( enabled ); | 318 | button->setEnabled( enabled ); |
319 | doConnections( button ); | 319 | doConnections( button ); |
320 | return index; | 320 | return index; |
321 | } | 321 | } |
322 | #if 0 | 322 | #if 0 |
323 | bar->insertButton( icon, id_, SIGNAL( clicked() ), this, | 323 | bar->insertButton( icon, id_, SIGNAL( clicked() ), this, |
324 | SLOT( slotActivated() ), | 324 | SLOT( slotActivated() ), |
325 | d->isEnabled(), d->plainText(), index/*US, instance*/ ); | 325 | d->isEnabled(), d->plainText(), index/*US, instance*/ ); |
326 | #endif | 326 | #endif |
327 | 327 | ||
328 | int KToolBar::insertButton(const QPixmap& pixmap, int id, const char *signal, | 328 | int KToolBar::insertButton(const QPixmap& pixmap, int id, const char *signal, |
329 | const QObject *receiver, const char *slot, | 329 | const QObject *receiver, const char *slot, |
330 | bool enabled, const QString& text, | 330 | bool enabled, const QString& text, |
331 | int index ) | 331 | int index ) |
332 | { | 332 | { |
333 | KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text); | 333 | KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text); |
334 | insertWidgetInternal( button, index, id ); | 334 | insertWidgetInternal( button, index, id ); |
335 | button->setEnabled( enabled ); | 335 | button->setEnabled( enabled ); |
336 | connect( button, signal, receiver, slot ); | 336 | connect( button, signal, receiver, slot ); |
337 | doConnections( button ); | 337 | doConnections( button ); |
338 | return index; | 338 | return index; |
339 | } | 339 | } |
340 | 340 | ||
341 | 341 | ||
342 | int KToolBar::insertButton(const QString& icon, int id, QPopupMenu *popup, | 342 | int KToolBar::insertButton(const QString& icon, int id, QPopupMenu *popup, |
343 | bool enabled, const QString &text, int index ) | 343 | bool enabled, const QString &text, int index ) |
344 | { | 344 | { |
345 | KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text ); | 345 | KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text ); |
346 | insertWidgetInternal( button, index, id ); | 346 | insertWidgetInternal( button, index, id ); |
347 | button->setEnabled( enabled ); | 347 | button->setEnabled( enabled ); |
348 | button->setPopup( popup ); | 348 | button->setPopup( popup ); |
349 | doConnections( button ); | 349 | doConnections( button ); |
350 | return index; | 350 | return index; |
351 | } | 351 | } |
352 | 352 | ||
353 | 353 | ||
354 | int KToolBar::insertButton(const QPixmap& pixmap, int id, QPopupMenu *popup, | 354 | int KToolBar::insertButton(const QPixmap& pixmap, int id, QPopupMenu *popup, |
355 | bool enabled, const QString &text, int index ) | 355 | bool enabled, const QString &text, int index ) |
356 | { | 356 | { |
357 | KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text ); | 357 | KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text ); |
358 | insertWidgetInternal( button, index, id ); | 358 | insertWidgetInternal( button, index, id ); |
359 | button->setEnabled( enabled ); | 359 | button->setEnabled( enabled ); |
360 | button->setPopup( popup ); | 360 | button->setPopup( popup ); |
361 | doConnections( button ); | 361 | doConnections( button ); |
362 | return index; | 362 | return index; |
363 | } | 363 | } |
364 | 364 | ||
365 | 365 | ||
366 | int KToolBar::insertLined (const QString& text, int id, | 366 | int KToolBar::insertLined (const QString& text, int id, |
367 | const char *signal, | 367 | const char *signal, |
368 | const QObject *receiver, const char *slot, | 368 | const QObject *receiver, const char *slot, |
369 | bool enabled , | 369 | bool enabled , |
370 | const QString& toolTipText, | 370 | const QString& toolTipText, |
371 | int size, int index ) | 371 | int size, int index ) |
372 | { | 372 | { |
373 | KLineEdit *lined = new KLineEdit ( this, 0 ); | 373 | KLineEdit *lined = new KLineEdit ( this, 0 ); |
374 | if ( !toolTipText.isEmpty() ) | 374 | if ( !toolTipText.isEmpty() ) |
375 | QToolTip::add( lined, toolTipText ); | 375 | QToolTip::add( lined, toolTipText ); |
376 | if ( size > 0 ) | 376 | if ( size > 0 ) |
377 | lined->setMinimumWidth( size ); | 377 | lined->setMinimumWidth( size ); |
378 | insertWidgetInternal( lined, index, id ); | 378 | insertWidgetInternal( lined, index, id ); |
379 | connect( lined, signal, receiver, slot ); | 379 | connect( lined, signal, receiver, slot ); |
380 | lined->setText(text); | 380 | lined->setText(text); |
381 | lined->setEnabled( enabled ); | 381 | lined->setEnabled( enabled ); |
382 | return index; | 382 | return index; |
383 | } | 383 | } |
384 | 384 | ||
385 | int KToolBar::insertCombo (const QStringList &list, int id, bool writable, | 385 | int KToolBar::insertCombo (const QStringList &list, int id, bool writable, |
386 | const char *signal, const QObject *receiver, | 386 | const char *signal, const QObject *receiver, |
387 | const char *slot, bool enabled, | 387 | const char *slot, bool enabled, |
388 | const QString& tooltiptext, | 388 | const QString& tooltiptext, |
389 | int size, int index, | 389 | int size, int index, |
390 | QComboBox::Policy policy ) | 390 | QComboBox::Policy policy ) |
391 | { | 391 | { |
392 | //US KComboBox *combo = new KComboBox ( writable, this ); | 392 | //US KComboBox *combo = new KComboBox ( writable, this ); |
393 | KComboBox *combo = new KComboBox ( this ); | 393 | KComboBox *combo = new KComboBox ( this ); |
394 | combo->setEditable(writable); | 394 | combo->setEditable(writable); |
395 | 395 | ||
396 | insertWidgetInternal( combo, index, id ); | 396 | insertWidgetInternal( combo, index, id ); |
397 | combo->insertStringList (list); | 397 | combo->insertStringList (list); |
398 | combo->setInsertionPolicy(policy); | 398 | combo->setInsertionPolicy(policy); |
399 | combo->setEnabled( enabled ); | 399 | combo->setEnabled( enabled ); |
400 | if ( !tooltiptext.isEmpty() ) | 400 | if ( !tooltiptext.isEmpty() ) |
401 | QToolTip::add( combo, tooltiptext ); | 401 | QToolTip::add( combo, tooltiptext ); |
402 | if ( size > 0 ) | 402 | if ( size > 0 ) |
403 | combo->setMinimumWidth( size ); | 403 | combo->setMinimumWidth( size ); |
404 | if (!tooltiptext.isNull()) | 404 | if (!tooltiptext.isNull()) |
405 | QToolTip::add( combo, tooltiptext ); | 405 | QToolTip::add( combo, tooltiptext ); |
406 | 406 | ||
407 | if ( signal && receiver && slot ) | 407 | if ( signal && receiver && slot ) |
408 | connect ( combo, signal, receiver, slot ); | 408 | connect ( combo, signal, receiver, slot ); |
409 | return index; | 409 | return index; |
410 | } | 410 | } |
411 | 411 | ||
412 | 412 | ||
413 | int KToolBar::insertCombo (const QString& text, int id, bool writable, | 413 | int KToolBar::insertCombo (const QString& text, int id, bool writable, |
414 | const char *signal, QObject *receiver, | 414 | const char *signal, QObject *receiver, |
415 | const char *slot, bool enabled, | 415 | const char *slot, bool enabled, |
416 | const QString& tooltiptext, | 416 | const QString& tooltiptext, |
417 | int size, int index, | 417 | int size, int index, |
418 | QComboBox::Policy policy ) | 418 | QComboBox::Policy policy ) |
419 | { | 419 | { |
420 | //US KComboBox *combo = new KComboBox ( writable, this ); | 420 | //US KComboBox *combo = new KComboBox ( writable, this ); |
421 | KComboBox *combo = new KComboBox ( this ); | 421 | KComboBox *combo = new KComboBox ( this ); |
422 | combo->setEditable(writable); | 422 | combo->setEditable(writable); |
423 | 423 | ||
424 | insertWidgetInternal( combo, index, id ); | 424 | insertWidgetInternal( combo, index, id ); |
425 | combo->insertItem (text); | 425 | combo->insertItem (text); |
426 | combo->setInsertionPolicy(policy); | 426 | combo->setInsertionPolicy(policy); |
427 | combo->setEnabled( enabled ); | 427 | combo->setEnabled( enabled ); |
428 | if ( !tooltiptext.isEmpty() ) | 428 | if ( !tooltiptext.isEmpty() ) |
429 | QToolTip::add( combo, tooltiptext ); | 429 | QToolTip::add( combo, tooltiptext ); |
430 | if ( size > 0 ) | 430 | if ( size > 0 ) |
431 | combo->setMinimumWidth( size ); | 431 | combo->setMinimumWidth( size ); |
432 | if (!tooltiptext.isNull()) | 432 | if (!tooltiptext.isNull()) |
433 | QToolTip::add( combo, tooltiptext ); | 433 | QToolTip::add( combo, tooltiptext ); |
434 | connect (combo, signal, receiver, slot); | 434 | connect (combo, signal, receiver, slot); |
435 | return index; | 435 | return index; |
436 | } | 436 | } |
437 | 437 | ||
438 | int KToolBar::insertSeparator(int index, int id) | 438 | int KToolBar::insertSeparator(int index, int id) |
439 | { | 439 | { |
440 | QWidget *w = new KToolBarSeparator( orientation(), FALSE, this, "tool bar separator" ); | 440 | QWidget *w = new KToolBarSeparator( orientation(), FALSE, this, "tool bar separator" ); |
441 | insertWidgetInternal( w, index, id ); | 441 | insertWidgetInternal( w, index, id ); |
442 | return index; | 442 | return index; |
443 | } | 443 | } |
444 | 444 | ||
445 | int KToolBar::insertLineSeparator(int index, int id) | 445 | int KToolBar::insertLineSeparator(int index, int id) |
446 | { | 446 | { |
447 | QWidget *w = new KToolBarSeparator( orientation(), TRUE, this, "tool bar separator" ); | 447 | QWidget *w = new KToolBarSeparator( orientation(), TRUE, this, "tool bar separator" ); |
448 | insertWidgetInternal( w, index, id ); | 448 | insertWidgetInternal( w, index, id ); |
449 | return index; | 449 | return index; |
450 | } | 450 | } |
451 | 451 | ||
452 | 452 | ||
453 | int KToolBar::insertWidget(int id, int /*width*/, QWidget *widget, int index) | 453 | int KToolBar::insertWidget(int id, int /*width*/, QWidget *widget, int index) |
454 | { | 454 | { |
455 | // removeWidgetInternal( widget ); // in case we already have it ? | 455 | // removeWidgetInternal( widget ); // in case we already have it ? |
456 | insertWidgetInternal( widget, index, id ); | 456 | insertWidgetInternal( widget, index, id ); |
457 | return index; | 457 | return index; |
458 | } | 458 | } |
459 | /*US | 459 | /*US |
460 | int KToolBar::insertAnimatedWidget(int id, QObject *receiver, const char *slot, | 460 | int KToolBar::insertAnimatedWidget(int id, QObject *receiver, const char *slot, |
461 | const QString& icons, int index ) | 461 | const QString& icons, int index ) |
462 | { | 462 | { |
463 | KAnimWidget *anim = new KAnimWidget( icons, d->m_iconSize, this ); | 463 | KAnimWidget *anim = new KAnimWidget( icons, d->m_iconSize, this ); |
464 | insertWidgetInternal( anim, index, id ); | 464 | insertWidgetInternal( anim, index, id ); |
465 | 465 | ||
466 | if ( receiver ) | 466 | if ( receiver ) |
467 | connect( anim, SIGNAL(clicked()), receiver, slot); | 467 | connect( anim, SIGNAL(clicked()), receiver, slot); |
468 | 468 | ||
469 | return index; | 469 | return index; |
470 | } | 470 | } |
471 | 471 | ||
472 | KAnimWidget *KToolBar::animatedWidget( int id ) | 472 | KAnimWidget *KToolBar::animatedWidget( int id ) |
473 | { | 473 | { |
474 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 474 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
475 | if ( it == id2widget.end() ) | 475 | if ( it == id2widget.end() ) |
476 | return 0; | 476 | return 0; |
477 | if ( (*it) && (*it)->inherits( "KAnimWidget" ) ) | 477 | if ( (*it) && (*it)->inherits( "KAnimWidget" ) ) |
478 | return (KAnimWidget*)(*it); | 478 | return (KAnimWidget*)(*it); |
479 | QObjectList *l = queryList( "KAnimWidget" ); | 479 | QObjectList *l = queryList( "KAnimWidget" ); |
480 | if ( !l || !l->first() ) { | 480 | if ( !l || !l->first() ) { |
481 | delete l; | 481 | delete l; |
482 | return 0; | 482 | return 0; |
483 | } | 483 | } |
484 | 484 | ||
485 | for ( QObject *o = l->first(); o; o = l->next() ) { | 485 | for ( QObject *o = l->first(); o; o = l->next() ) { |
486 | if ( o->inherits( "KAnimWidget" ) ) | 486 | if ( o->inherits( "KAnimWidget" ) ) |
487 | { | 487 | { |
488 | delete l; | 488 | delete l; |
489 | return (KAnimWidget*)o; | 489 | return (KAnimWidget*)o; |
490 | } | 490 | } |
491 | } | 491 | } |
492 | 492 | ||
493 | delete l; | 493 | delete l; |
494 | return 0; | 494 | return 0; |
495 | } | 495 | } |
496 | */ | 496 | */ |
497 | 497 | ||
498 | void KToolBar::addConnection (int id, const char *signal, | 498 | void KToolBar::addConnection (int id, const char *signal, |
499 | const QObject *receiver, const char *slot) | 499 | const QObject *receiver, const char *slot) |
500 | { | 500 | { |
501 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 501 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
502 | if ( it == id2widget.end() ) | 502 | if ( it == id2widget.end() ) |
503 | return; | 503 | return; |
504 | if ( (*it) ) | 504 | if ( (*it) ) |
505 | connect( (*it), signal, receiver, slot ); | 505 | connect( (*it), signal, receiver, slot ); |
506 | } | 506 | } |
507 | 507 | ||
508 | void KToolBar::setItemEnabled( int id, bool enabled ) | 508 | void KToolBar::setItemEnabled( int id, bool enabled ) |
509 | { | 509 | { |
510 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 510 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
511 | if ( it == id2widget.end() ) | 511 | if ( it == id2widget.end() ) |
512 | return; | 512 | return; |
513 | if ( (*it) ) | 513 | if ( (*it) ) |
514 | (*it)->setEnabled( enabled ); | 514 | (*it)->setEnabled( enabled ); |
515 | } | 515 | } |
516 | 516 | ||
517 | 517 | ||
518 | void KToolBar::setButtonPixmap( int id, const QPixmap& _pixmap ) | 518 | void KToolBar::setButtonPixmap( int id, const QPixmap& _pixmap ) |
519 | { | 519 | { |
520 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 520 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
521 | if ( it == id2widget.end() ) | 521 | if ( it == id2widget.end() ) |
522 | return; | 522 | return; |
523 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); | 523 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); |
524 | KToolBarButton * button = (KToolBarButton *)( *it ); | 524 | KToolBarButton * button = (KToolBarButton *)( *it ); |
525 | if ( button ) | 525 | if ( button ) |
526 | button->setPixmap( _pixmap ); | 526 | button->setPixmap( _pixmap ); |
527 | } | 527 | } |
528 | 528 | ||
529 | 529 | ||
530 | void KToolBar::setButtonIcon( int id, const QString& _icon ) | 530 | void KToolBar::setButtonIcon( int id, const QString& _icon ) |
531 | { | 531 | { |
532 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 532 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
533 | if ( it == id2widget.end() ) | 533 | if ( it == id2widget.end() ) |
534 | return; | 534 | return; |
535 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); | 535 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); |
536 | KToolBarButton * button = (KToolBarButton *)( *it ); | 536 | KToolBarButton * button = (KToolBarButton *)( *it ); |
537 | if ( button ) | 537 | if ( button ) |
538 | button->setIcon( _icon ); | 538 | button->setIcon( _icon ); |
539 | } | 539 | } |
540 | 540 | ||
541 | void KToolBar::setButtonIconSet( int id, const QIconSet& iconset ) | 541 | void KToolBar::setButtonIconSet( int id, const QIconSet& iconset ) |
542 | { | 542 | { |
543 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 543 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
544 | if ( it == id2widget.end() ) | 544 | if ( it == id2widget.end() ) |
545 | return; | 545 | return; |
546 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); | 546 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); |
547 | KToolBarButton * button = (KToolBarButton *)( *it ); | 547 | KToolBarButton * button = (KToolBarButton *)( *it ); |
548 | if ( button ) | 548 | if ( button ) |
549 | button->setIconSet( iconset ); | 549 | button->setIconSet( iconset ); |
550 | } | 550 | } |
551 | 551 | ||
552 | 552 | ||
553 | void KToolBar::setDelayedPopup (int id , QPopupMenu *_popup, bool toggle ) | 553 | void KToolBar::setDelayedPopup (int id , QPopupMenu *_popup, bool toggle ) |
554 | { | 554 | { |
555 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 555 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
556 | if ( it == id2widget.end() ) | 556 | if ( it == id2widget.end() ) |
557 | return; | 557 | return; |
558 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); | 558 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); |
559 | KToolBarButton * button = (KToolBarButton *)( *it ); | 559 | KToolBarButton * button = (KToolBarButton *)( *it ); |
560 | if ( button ) | 560 | if ( button ) |
561 | button->setDelayedPopup( _popup, toggle ); | 561 | button->setDelayedPopup( _popup, toggle ); |
562 | } | 562 | } |
563 | 563 | ||
564 | 564 | ||
565 | void KToolBar::setAutoRepeat (int id, bool flag) | 565 | void KToolBar::setAutoRepeat (int id, bool flag) |
566 | { | 566 | { |
567 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 567 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
568 | if ( it == id2widget.end() ) | 568 | if ( it == id2widget.end() ) |
569 | return; | 569 | return; |
570 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); | 570 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); |
571 | KToolBarButton * button = (KToolBarButton *)( *it ); | 571 | KToolBarButton * button = (KToolBarButton *)( *it ); |
572 | if ( button ) | 572 | if ( button ) |
573 | button->setAutoRepeat( flag ); | 573 | button->setAutoRepeat( flag ); |
574 | } | 574 | } |
575 | 575 | ||
576 | 576 | ||
577 | void KToolBar::setToggle (int id, bool flag ) | 577 | void KToolBar::setToggle (int id, bool flag ) |
578 | { | 578 | { |
579 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 579 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
580 | if ( it == id2widget.end() ) | 580 | if ( it == id2widget.end() ) |
581 | return; | 581 | return; |
582 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); | 582 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); |
583 | KToolBarButton * button = (KToolBarButton *)( *it ); | 583 | KToolBarButton * button = (KToolBarButton *)( *it ); |
584 | if ( button ) | 584 | if ( button ) |
585 | button->setToggle( flag ); | 585 | button->setToggle( flag ); |
586 | } | 586 | } |
587 | 587 | ||
588 | 588 | ||
589 | void KToolBar::toggleButton (int id) | 589 | void KToolBar::toggleButton (int id) |
590 | { | 590 | { |
591 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 591 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
592 | if ( it == id2widget.end() ) | 592 | if ( it == id2widget.end() ) |
593 | return; | 593 | return; |
594 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); | 594 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); |
595 | KToolBarButton * button = (KToolBarButton *)( *it ); | 595 | KToolBarButton * button = (KToolBarButton *)( *it ); |
596 | if ( button ) | 596 | if ( button ) |
597 | button->toggle(); | 597 | button->toggle(); |
598 | } | 598 | } |
599 | 599 | ||
600 | 600 | ||
601 | void KToolBar::setButton (int id, bool flag) | 601 | void KToolBar::setButton (int id, bool flag) |
602 | { | 602 | { |
603 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 603 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
604 | if ( it == id2widget.end() ) | 604 | if ( it == id2widget.end() ) |
605 | return; | 605 | return; |
606 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); | 606 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); |
607 | KToolBarButton * button = (KToolBarButton *)( *it ); | 607 | KToolBarButton * button = (KToolBarButton *)( *it ); |
608 | if ( button ) | 608 | if ( button ) |
609 | button->on( flag ); | 609 | button->on( flag ); |
610 | } | 610 | } |
611 | 611 | ||
612 | 612 | ||
613 | bool KToolBar::isButtonOn (int id) const | 613 | bool KToolBar::isButtonOn (int id) const |
614 | { | 614 | { |
615 | Id2WidgetMap::ConstIterator it = id2widget.find( id ); | 615 | Id2WidgetMap::ConstIterator it = id2widget.find( id ); |
616 | if ( it == id2widget.end() ) | 616 | if ( it == id2widget.end() ) |
617 | return false; | 617 | return false; |
618 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); | 618 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); |
619 | KToolBarButton * button = (KToolBarButton *)( *it ); | 619 | KToolBarButton * button = (KToolBarButton *)( *it ); |
620 | return button ? button->isOn() : false; | 620 | return button ? button->isOn() : false; |
621 | } | 621 | } |
622 | 622 | ||
623 | 623 | ||
624 | void KToolBar::setLinedText (int id, const QString& text) | 624 | void KToolBar::setLinedText (int id, const QString& text) |
625 | { | 625 | { |
626 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 626 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
627 | if ( it == id2widget.end() ) | 627 | if ( it == id2widget.end() ) |
628 | return; | 628 | return; |
629 | //US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it ); | 629 | //US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it ); |
630 | QLineEdit * lineEdit = (QLineEdit *)( *it ); | 630 | QLineEdit * lineEdit = (QLineEdit *)( *it ); |
631 | if ( lineEdit ) | 631 | if ( lineEdit ) |
632 | lineEdit->setText( text ); | 632 | lineEdit->setText( text ); |
633 | } | 633 | } |
634 | 634 | ||
635 | 635 | ||
636 | QString KToolBar::getLinedText (int id) const | 636 | QString KToolBar::getLinedText (int id) const |
637 | { | 637 | { |
638 | Id2WidgetMap::ConstIterator it = id2widget.find( id ); | 638 | Id2WidgetMap::ConstIterator it = id2widget.find( id ); |
639 | if ( it == id2widget.end() ) | 639 | if ( it == id2widget.end() ) |
640 | return QString::null; | 640 | return QString::null; |
641 | //US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it ); | 641 | //US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it ); |
642 | QLineEdit * lineEdit = (QLineEdit *)( *it ); | 642 | QLineEdit * lineEdit = (QLineEdit *)( *it ); |
643 | return lineEdit ? lineEdit->text() : QString::null; | 643 | return lineEdit ? lineEdit->text() : QString::null; |
644 | } | 644 | } |
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 | } |
2181 | } | 2187 | } |
2182 | 2188 | ||
2183 | for(int i = CONTEXT_ICONS; i <= CONTEXT_TEXTUNDER; ++i) | 2189 | for(int i = CONTEXT_ICONS; i <= CONTEXT_TEXTUNDER; ++i) |
2184 | context->setItemChecked(i, false); | 2190 | context->setItemChecked(i, false); |
2185 | 2191 | ||
2186 | switch( d->m_iconText ) | 2192 | switch( d->m_iconText ) |
2187 | { | 2193 | { |
2188 | case IconOnly: | 2194 | case IconOnly: |
2189 | default: | 2195 | default: |
2190 | context->setItemChecked(CONTEXT_ICONS, true); | 2196 | context->setItemChecked(CONTEXT_ICONS, true); |
2191 | break; | 2197 | break; |
2192 | case IconTextRight: | 2198 | case IconTextRight: |
2193 | context->setItemChecked(CONTEXT_TEXTRIGHT, true); | 2199 | context->setItemChecked(CONTEXT_TEXTRIGHT, true); |
2194 | break; | 2200 | break; |
2195 | case TextOnly: | 2201 | case TextOnly: |
2196 | context->setItemChecked(CONTEXT_TEXT, true); | 2202 | context->setItemChecked(CONTEXT_TEXT, true); |
2197 | break; | 2203 | break; |
2198 | case IconTextBottom: | 2204 | case IconTextBottom: |
2199 | context->setItemChecked(CONTEXT_TEXTUNDER, true); | 2205 | context->setItemChecked(CONTEXT_TEXTUNDER, true); |
2200 | break; | 2206 | break; |
2201 | } | 2207 | } |
2202 | 2208 | ||
2203 | QValueList<int>::ConstIterator iIt = d->iconSizes.begin(); | 2209 | QValueList<int>::ConstIterator iIt = d->iconSizes.begin(); |
2204 | QValueList<int>::ConstIterator iEnd = d->iconSizes.end(); | 2210 | QValueList<int>::ConstIterator iEnd = d->iconSizes.end(); |
2205 | for (; iIt != iEnd; ++iIt ) | 2211 | for (; iIt != iEnd; ++iIt ) |
2206 | context->setItemChecked( CONTEXT_ICONSIZES + *iIt, false ); | 2212 | context->setItemChecked( CONTEXT_ICONSIZES + *iIt, false ); |
2207 | 2213 | ||
2208 | context->setItemChecked( CONTEXT_ICONSIZES, false ); | 2214 | context->setItemChecked( CONTEXT_ICONSIZES, false ); |
2209 | 2215 | ||
2210 | context->setItemChecked( CONTEXT_ICONSIZES + d->m_iconSize, true ); | 2216 | context->setItemChecked( CONTEXT_ICONSIZES + d->m_iconSize, true ); |
2211 | 2217 | ||
2212 | for ( int i = CONTEXT_TOP; i <= CONTEXT_FLAT; ++i ) | 2218 | for ( int i = CONTEXT_TOP; i <= CONTEXT_FLAT; ++i ) |
2213 | context->setItemChecked( i, false ); | 2219 | context->setItemChecked( i, false ); |
2214 | 2220 | ||
2215 | switch ( barPos() ) | 2221 | switch ( barPos() ) |
2216 | { | 2222 | { |
2217 | case KToolBar::Flat: | 2223 | case KToolBar::Flat: |
2218 | context->setItemChecked( CONTEXT_FLAT, true ); | 2224 | context->setItemChecked( CONTEXT_FLAT, true ); |
2219 | break; | 2225 | break; |
2220 | case KToolBar::Bottom: | 2226 | case KToolBar::Bottom: |
2221 | context->setItemChecked( CONTEXT_BOTTOM, true ); | 2227 | context->setItemChecked( CONTEXT_BOTTOM, true ); |
2222 | break; | 2228 | break; |
2223 | case KToolBar::Left: | 2229 | case KToolBar::Left: |
2224 | context->setItemChecked( CONTEXT_LEFT, true ); | 2230 | context->setItemChecked( CONTEXT_LEFT, true ); |
2225 | break; | 2231 | break; |
2226 | case KToolBar::Right: | 2232 | case KToolBar::Right: |
2227 | context->setItemChecked( CONTEXT_RIGHT, true ); | 2233 | context->setItemChecked( CONTEXT_RIGHT, true ); |
2228 | break; | 2234 | break; |
2229 | case KToolBar::Floating: | 2235 | case KToolBar::Floating: |
2230 | context->setItemChecked( CONTEXT_FLOAT, true ); | 2236 | context->setItemChecked( CONTEXT_FLOAT, true ); |
2231 | break; | 2237 | break; |
2232 | case KToolBar::Top: | 2238 | case KToolBar::Top: |
2233 | context->setItemChecked( CONTEXT_TOP, true ); | 2239 | context->setItemChecked( CONTEXT_TOP, true ); |
2234 | break; | 2240 | break; |
2235 | default: break; | 2241 | default: break; |
2236 | } | 2242 | } |
2237 | } | 2243 | } |
2238 | 2244 | ||
2239 | void KToolBar::widgetDestroyed() | 2245 | void KToolBar::widgetDestroyed() |
2240 | { | 2246 | { |
2241 | removeWidgetInternal( (QWidget*)sender() ); | 2247 | removeWidgetInternal( (QWidget*)sender() ); |
2242 | } | 2248 | } |
2243 | 2249 | ||
2244 | void KToolBar::removeWidgetInternal( QWidget * w ) | 2250 | void KToolBar::removeWidgetInternal( QWidget * w ) |
2245 | { | 2251 | { |
2246 | if ( inshutdownprocess ) | 2252 | if ( inshutdownprocess ) |
2247 | return; | 2253 | return; |
2248 | widgets.removeRef( w ); | 2254 | widgets.removeRef( w ); |
2249 | QMap< QWidget*, int >::Iterator it = widget2id.find( w ); | 2255 | QMap< QWidget*, int >::Iterator it = widget2id.find( w ); |
2250 | if ( it == widget2id.end() ) | 2256 | if ( it == widget2id.end() ) |
2251 | return; | 2257 | return; |
2252 | id2widget.remove( *it ); | 2258 | id2widget.remove( *it ); |
2253 | widget2id.remove( it ); | 2259 | widget2id.remove( it ); |
2254 | } | 2260 | } |
2255 | 2261 | ||
2256 | void KToolBar::virtual_hook( int, void* ) | 2262 | void KToolBar::virtual_hook( int, void* ) |
2257 | { /*BASE::virtual_hook( id, data );*/ } | 2263 | { /*BASE::virtual_hook( id, data );*/ } |
2258 | 2264 | ||
2259 | //US #include "ktoolbar.moc" | 2265 | //US #include "ktoolbar.moc" |
2260 | 2266 | ||
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 | |||
@@ -1,1107 +1,1108 @@ | |||
1 | /* This file is part of the KDE libraries | 1 | /* This file is part of the KDE libraries |
2 | Copyright (C) 2000 Reginald Stadlbauer (reggie@kde.org) | 2 | Copyright (C) 2000 Reginald Stadlbauer (reggie@kde.org) |
3 | (C) 1997, 1998 Stephan Kulow (coolo@kde.org) | 3 | (C) 1997, 1998 Stephan Kulow (coolo@kde.org) |
4 | (C) 1997, 1998 Sven Radej (radej@kde.org) | 4 | (C) 1997, 1998 Sven Radej (radej@kde.org) |
5 | (C) 1997, 1998 Mark Donohoe (donohoe@kde.org) | 5 | (C) 1997, 1998 Mark Donohoe (donohoe@kde.org) |
6 | (C) 1997, 1998 Matthias Ettrich (ettrich@kde.org) | 6 | (C) 1997, 1998 Matthias Ettrich (ettrich@kde.org) |
7 | (C) 1999, 2000 Kurt Granroth (granroth@kde.org) | 7 | (C) 1999, 2000 Kurt Granroth (granroth@kde.org) |
8 | 8 | ||
9 | This library is free software; you can redistribute it and/or | 9 | This library is free software; you can redistribute it and/or |
10 | modify it under the terms of the GNU Library General Public | 10 | modify it under the terms of the GNU Library General Public |
11 | License version 2 as published by the Free Software Foundation. | 11 | License version 2 as published by the Free Software Foundation. |
12 | 12 | ||
13 | This library is distributed in the hope that it will be useful, | 13 | This library is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | Library General Public License for more details. | 16 | Library General Public License for more details. |
17 | 17 | ||
18 | You should have received a copy of the GNU Library General Public License | 18 | You should have received a copy of the GNU Library General Public License |
19 | along with this library; see the file COPYING.LIB. If not, write to | 19 | along with this library; see the file COPYING.LIB. If not, write to |
20 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 20 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
21 | Boston, MA 02111-1307, USA. | 21 | Boston, MA 02111-1307, USA. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #ifndef KTOOLBAR_H | 24 | #ifndef KTOOLBAR_H |
25 | #define KTOOLBAR_H | 25 | #define KTOOLBAR_H |
26 | 26 | ||
27 | #ifndef DESKTOP_VERSION | 27 | #ifndef DESKTOP_VERSION |
28 | #define private public | 28 | #define private public |
29 | #include <qtoolbar.h> | 29 | #include <qtoolbar.h> |
30 | #undef private | 30 | #undef private |
31 | #include <qpe/qpetoolbar.h> | 31 | #include <qpe/qpetoolbar.h> |
32 | #else | 32 | #else |
33 | #include <qtoolbar.h> | 33 | #include <qtoolbar.h> |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | 36 | ||
37 | #include <qmainwindow.h> | 37 | #include <qmainwindow.h> |
38 | #include <qcombobox.h> | 38 | #include <qcombobox.h> |
39 | #include <qmap.h> | 39 | #include <qmap.h> |
40 | #include <qptrlist.h> | 40 | #include <qptrlist.h> |
41 | #include <kglobal.h> | 41 | #include <kglobal.h> |
42 | #include <qguardedptr.h> | 42 | #include <qguardedptr.h> |
43 | #include <qframe.h> | 43 | #include <qframe.h> |
44 | #include <qiconset.h> | 44 | #include <qiconset.h> |
45 | 45 | ||
46 | class QDomElement; | 46 | class QDomElement; |
47 | class QSize; | 47 | class QSize; |
48 | class QPixmap; | 48 | class QPixmap; |
49 | class QPopupMenu; | 49 | class QPopupMenu; |
50 | class QStringList; | 50 | class QStringList; |
51 | class QDomDocument; | 51 | class QDomDocument; |
52 | class QTimer; | 52 | class QTimer; |
53 | 53 | ||
54 | class KLineEdit; | 54 | class KLineEdit; |
55 | class KToolBar; | 55 | class KToolBar; |
56 | class KToolBarButton; | 56 | class KToolBarButton; |
57 | class KToolBoxManager; | 57 | class KToolBoxManager; |
58 | //US class KAnimWidget; | 58 | //US class KAnimWidget; |
59 | //US class KPopupMenu; | 59 | //US class KPopupMenu; |
60 | //US class KInstance; | 60 | //US class KInstance; |
61 | class KComboBox; | 61 | class KComboBox; |
62 | class KXMLGUIClient; | 62 | class KXMLGUIClient; |
63 | 63 | ||
64 | class KToolBarPrivate; | 64 | class KToolBarPrivate; |
65 | 65 | ||
66 | class KToolBarSeparator : public QFrame | 66 | class KToolBarSeparator : public QFrame |
67 | { | 67 | { |
68 | Q_OBJECT | 68 | Q_OBJECT |
69 | public: | 69 | public: |
70 | KToolBarSeparator( Orientation, bool l, QToolBar *parent, const char* name=0 ); | 70 | KToolBarSeparator( Orientation, bool l, QToolBar *parent, const char* name=0 ); |
71 | 71 | ||
72 | QSize sizeHint() const; | 72 | QSize sizeHint() const; |
73 | Orientation orientation() const { return orient; } | 73 | Orientation orientation() const { return orient; } |
74 | QSizePolicy sizePolicy() const; | 74 | QSizePolicy sizePolicy() const; |
75 | bool showLine() const { return line; } | 75 | bool showLine() const { return line; } |
76 | public slots: | 76 | public slots: |
77 | void setOrientation( Orientation ); | 77 | void setOrientation( Orientation ); |
78 | protected: | 78 | protected: |
79 | void styleChange( QStyle& ); | 79 | void styleChange( QStyle& ); |
80 | private: | 80 | private: |
81 | Orientation orient; | 81 | Orientation orient; |
82 | bool line; | 82 | bool line; |
83 | }; | 83 | }; |
84 | 84 | ||
85 | 85 | ||
86 | /** | 86 | /** |
87 | * A KDE-style toolbar. | 87 | * A KDE-style toolbar. |
88 | * | 88 | * |
89 | * KToolBar can be dragged around in and between different docks. | 89 | * KToolBar can be dragged around in and between different docks. |
90 | * | 90 | * |
91 | * A KToolBar can contain all sorts of widgets. | 91 | * A KToolBar can contain all sorts of widgets. |
92 | * | 92 | * |
93 | * KToolBar can be used as a standalone widget, but @ref KMainWindow | 93 | * KToolBar can be used as a standalone widget, but @ref KMainWindow |
94 | * provides easy factories and management of one or more toolbars. | 94 | * provides easy factories and management of one or more toolbars. |
95 | * Once you have a KToolBar object, you can insert items into it with the | 95 | * Once you have a KToolBar object, you can insert items into it with the |
96 | * insert... methods, or remove them with the @ref removeItem() method. This | 96 | * insert... methods, or remove them with the @ref removeItem() method. This |
97 | * can be done at any time; the toolbar will be automatically updated. | 97 | * can be done at any time; the toolbar will be automatically updated. |
98 | * There are also many methods to set per-child properties like alignment | 98 | * There are also many methods to set per-child properties like alignment |
99 | * and toggle behaviour. | 99 | * and toggle behaviour. |
100 | * | 100 | * |
101 | * KToolBar uses a global config group to load toolbar settings on | 101 | * KToolBar uses a global config group to load toolbar settings on |
102 | * construction. It will reread this config group on a | 102 | * construction. It will reread this config group on a |
103 | * @ref KApplication::appearanceChanged() signal. | 103 | * @ref KApplication::appearanceChanged() signal. |
104 | * | 104 | * |
105 | * @short Floatable toolbar with auto resize. | 105 | * @short Floatable toolbar with auto resize. |
106 | * @version $Id$ | 106 | * @version $Id$ |
107 | * @author Reginald Stadlbauer <reggie@kde.org>, Stephan Kulow <coolo@kde.org>, Sven Radej <radej@kde.org>. | 107 | * @author Reginald Stadlbauer <reggie@kde.org>, Stephan Kulow <coolo@kde.org>, Sven Radej <radej@kde.org>. |
108 | */ | 108 | */ |
109 | 109 | ||
110 | // strange things are happening ... so I have to use strange define methods ... | 110 | // strange things are happening ... so I have to use strange define methods ... |
111 | // porting KToolBar back to Qt2 really needs some strange hacks | 111 | // porting KToolBar back to Qt2 really needs some strange hacks |
112 | 112 | ||
113 | #ifndef DESKTOP_VERSION | 113 | #ifndef DESKTOP_VERSION |
114 | #define QToolBar QPEToolBar | 114 | #define QToolBar QPEToolBar |
115 | #endif | 115 | #endif |
116 | 116 | ||
117 | class KToolBar : public QToolBar | 117 | class KToolBar : public QToolBar |
118 | { | 118 | { |
119 | Q_OBJECT | 119 | Q_OBJECT |
120 | 120 | ||
121 | 121 | ||
122 | Q_ENUMS( IconText BarPosition ) | 122 | Q_ENUMS( IconText BarPosition ) |
123 | 123 | ||
124 | Q_PROPERTY( IconText iconText READ iconText WRITE setIconText ) | 124 | Q_PROPERTY( IconText iconText READ iconText WRITE setIconText ) |
125 | Q_PROPERTY( BarPosition barPos READ barPos WRITE setBarPos ) | 125 | Q_PROPERTY( BarPosition barPos READ barPos WRITE setBarPos ) |
126 | Q_PROPERTY( bool fullSize READ fullSize WRITE setFullSize ) | 126 | Q_PROPERTY( bool fullSize READ fullSize WRITE setFullSize ) |
127 | Q_PROPERTY( int iconSize READ iconSize WRITE setIconSize ) | 127 | Q_PROPERTY( int iconSize READ iconSize WRITE setIconSize ) |
128 | Q_PROPERTY( QString text READ text WRITE setText ) | 128 | Q_PROPERTY( QString text READ text WRITE setText ) |
129 | #ifndef DESKTOP_VERSION | 129 | #ifndef DESKTOP_VERSION |
130 | #undef QToolBar | 130 | #undef QToolBar |
131 | #endif | 131 | #endif |
132 | public: | 132 | public: |
133 | enum IconText{IconOnly = 0, IconTextRight, TextOnly, IconTextBottom}; | 133 | enum IconText{IconOnly = 0, IconTextRight, TextOnly, IconTextBottom}; |
134 | /** | 134 | /** |
135 | * The state of the status bar. | 135 | * The state of the status bar. |
136 | * @deprecated | 136 | * @deprecated |
137 | **/ | 137 | **/ |
138 | enum BarStatus{Toggle, Show, Hide}; | 138 | enum BarStatus{Toggle, Show, Hide}; |
139 | /** | 139 | /** |
140 | * Possible bar positions. | 140 | * Possible bar positions. |
141 | **/ | 141 | **/ |
142 | enum BarPosition{ Unmanaged, Floating, Top, Bottom, Right, Left, Flat}; | 142 | enum BarPosition{ Unmanaged, Floating, Top, Bottom, Right, Left, Flat}; |
143 | 143 | ||
144 | /** | 144 | /** |
145 | * Constructor. | 145 | * Constructor. |
146 | * This constructor is used by the XML-GUI. If you use it, you need | 146 | * This constructor is used by the XML-GUI. If you use it, you need |
147 | * to call QMainWindow::addToolBar to specify the position of the toolbar. | 147 | * to call QMainWindow::addToolBar to specify the position of the toolbar. |
148 | * So it's simpler to use the other constructor. | 148 | * So it's simpler to use the other constructor. |
149 | * | 149 | * |
150 | * The toolbar will read in various global config settings for | 150 | * The toolbar will read in various global config settings for |
151 | * things like icon size and text position, etc. However, some of | 151 | * things like icon size and text position, etc. However, some of |
152 | * the settings will be honored only if @ref #_honor_mode is set to | 152 | * the settings will be honored only if @ref #_honor_mode is set to |
153 | * true. All other toolbars will be IconOnly and use Medium icons. | 153 | * true. All other toolbars will be IconOnly and use Medium icons. |
154 | * | 154 | * |
155 | * @param parent The standard toolbar parent (usually a | 155 | * @param parent The standard toolbar parent (usually a |
156 | * @ref KMainWindow) | 156 | * @ref KMainWindow) |
157 | * @param name The standard internal name | 157 | * @param name The standard internal name |
158 | * @param honor_style If true, then global settings for IconSize and IconText will be honored | 158 | * @param honor_style If true, then global settings for IconSize and IconText will be honored |
159 | * @param readConfig whether to apply the configuration (global and application-specific) | 159 | * @param readConfig whether to apply the configuration (global and application-specific) |
160 | */ | 160 | */ |
161 | KToolBar( QWidget *parent, const char *name = 0, bool honor_style = FALSE, bool readConfig = TRUE ); | 161 | KToolBar( QWidget *parent, const char *name = 0, bool honor_style = FALSE, bool readConfig = TRUE ); |
162 | 162 | ||
163 | /** | 163 | /** |
164 | * Constructor for non-XML-GUI applications. | 164 | * Constructor for non-XML-GUI applications. |
165 | * | 165 | * |
166 | * The toolbar will read in various global config settings for | 166 | * The toolbar will read in various global config settings for |
167 | * things like icon size and text position, etc. However, some of | 167 | * things like icon size and text position, etc. However, some of |
168 | * the settings will be honored only if @ref #_honor_mode is set to | 168 | * the settings will be honored only if @ref #_honor_mode is set to |
169 | * true. All other toolbars will be IconOnly and use Medium icons. | 169 | * true. All other toolbars will be IconOnly and use Medium icons. |
170 | * | 170 | * |
171 | * @param parentWindow The window that should be the parent of this toolbar | 171 | * @param parentWindow The window that should be the parent of this toolbar |
172 | * @param dock The position of the toolbar. Usually QMainWindow::Top. | 172 | * @param dock The position of the toolbar. Usually QMainWindow::Top. |
173 | * @param newLine If true, start a new line in the dock for this toolbar. | 173 | * @param newLine If true, start a new line in the dock for this toolbar. |
174 | * @param name The standard internal name | 174 | * @param name The standard internal name |
175 | * @param honor_style If true, then global settings for IconSize and IconText will be honored | 175 | * @param honor_style If true, then global settings for IconSize and IconText will be honored |
176 | * @param readConfig whether to apply the configuration (global and application-specific) | 176 | * @param readConfig whether to apply the configuration (global and application-specific) |
177 | */ | 177 | */ |
178 | KToolBar( QMainWindow *parentWindow, QMainWindow::ToolBarDock dock /*= QMainWindow::Top*/, bool newLine = false, | 178 | KToolBar( QMainWindow *parentWindow, QMainWindow::ToolBarDock dock /*= QMainWindow::Top*/, bool newLine = false, |
179 | const char *name = 0, bool honor_style = FALSE, bool readConfig = TRUE ); | 179 | const char *name = 0, bool honor_style = FALSE, bool readConfig = TRUE ); |
180 | 180 | ||
181 | /** | 181 | /** |
182 | * Constructor for non-XML-GUI applications. | 182 | * Constructor for non-XML-GUI applications. |
183 | * | 183 | * |
184 | * The toolbar will read in various global config settings for | 184 | * The toolbar will read in various global config settings for |
185 | * things like icon size and text position, etc. However, some of | 185 | * things like icon size and text position, etc. However, some of |
186 | * the settings will be honored only if @ref #_honor_mode is set to | 186 | * the settings will be honored only if @ref #_honor_mode is set to |
187 | * true. All other toolbars will be IconOnly and use Medium icons. | 187 | * true. All other toolbars will be IconOnly and use Medium icons. |
188 | * | 188 | * |
189 | * @param parentWindow The window that should be the parent of this toolbar | 189 | * @param parentWindow The window that should be the parent of this toolbar |
190 | * @param dock Another widget than the mainwindow to dock toolbar to. | 190 | * @param dock Another widget than the mainwindow to dock toolbar to. |
191 | * @param newLine If true, start a new line in the dock for this toolbar. | 191 | * @param newLine If true, start a new line in the dock for this toolbar. |
192 | * @param name The standard internal name | 192 | * @param name The standard internal name |
193 | * @param honor_style If true, then global settings for IconSize and IconText will be honored | 193 | * @param honor_style If true, then global settings for IconSize and IconText will be honored |
194 | * @param readConfig whether to apply the configuration (global and application-specific) | 194 | * @param readConfig whether to apply the configuration (global and application-specific) |
195 | */ | 195 | */ |
196 | KToolBar( QMainWindow *parentWindow, QWidget *dock, bool newLine = false, | 196 | KToolBar( QMainWindow *parentWindow, QWidget *dock, bool newLine = false, |
197 | const char *name = 0, bool honor_style = FALSE, bool readConfig = TRUE ); | 197 | const char *name = 0, bool honor_style = FALSE, bool readConfig = TRUE ); |
198 | 198 | ||
199 | virtual ~KToolBar(); | 199 | virtual ~KToolBar(); |
200 | 200 | ||
201 | /** | 201 | /** |
202 | * Insert a button (a @ref KToolBarButton) with a pixmap. The | 202 | * Insert a button (a @ref KToolBarButton) with a pixmap. The |
203 | * pixmap is loaded by the button itself based on the global icon | 203 | * pixmap is loaded by the button itself based on the global icon |
204 | * settings. | 204 | * settings. |
205 | * | 205 | * |
206 | * You should connect to one or more signals in KToolBar: | 206 | * You should connect to one or more signals in KToolBar: |
207 | * @ref clicked() , @ref pressed() , @ref released() , or | 207 | * @ref clicked() , @ref pressed() , @ref released() , or |
208 | * @ref highlighted() and if the button is a toggle button | 208 | * @ref highlighted() and if the button is a toggle button |
209 | * (@ref setToggle() ) @ref toggled() . Those signals have @p id | 209 | * (@ref setToggle() ) @ref toggled() . Those signals have @p id |
210 | * of a button that caused the signal. If you want to bind a popup | 210 | * of a button that caused the signal. If you want to bind a popup |
211 | * to button, see @ref setButton(). | 211 | * to button, see @ref setButton(). |
212 | * | 212 | * |
213 | * @param icon The name of the icon to use as the active pixmap | 213 | * @param icon The name of the icon to use as the active pixmap |
214 | * @param id The id of this button | 214 | * @param id The id of this button |
215 | * @param enabled Enable or disable the button at startup | 215 | * @param enabled Enable or disable the button at startup |
216 | * @param text The tooltip or toolbar text (depending on state) | 216 | * @param text The tooltip or toolbar text (depending on state) |
217 | * @param index The position of the button. (-1 = at end). | 217 | * @param index The position of the button. (-1 = at end). |
218 | * | 218 | * |
219 | * @return The item index. | 219 | * @return The item index. |
220 | */ | 220 | */ |
221 | int insertButton(const QString& icon, int id, bool enabled = true, | 221 | int insertButton(const QString& icon, int id, bool enabled = true, |
222 | const QString& text = QString::null, int index=-1/*US , | 222 | const QString& text = QString::null, int index=-1/*US , |
223 | KInstance *_instance = KGlobal::instance()*/); | 223 | KInstance *_instance = KGlobal::instance()*/); |
224 | 224 | ||
225 | /** | 225 | /** |
226 | * This is the same as above, but with specified signals and | 226 | * This is the same as above, but with specified signals and |
227 | * slots to which this button will be connected. | 227 | * slots to which this button will be connected. |
228 | * | 228 | * |
229 | * You can add more signals with @ref addConnection(). | 229 | * You can add more signals with @ref addConnection(). |
230 | * | 230 | * |
231 | * @param icon The name of the icon to use as the active pixmap | 231 | * @param icon The name of the icon to use as the active pixmap |
232 | * @param id The id of this button | 232 | * @param id The id of this button |
233 | * @param signal The signal to connect to | 233 | * @param signal The signal to connect to |
234 | * @param receiver The slot's parent | 234 | * @param receiver The slot's parent |
235 | * @param enabled Enable or disable the button at startup | 235 | * @param enabled Enable or disable the button at startup |
236 | * @param text The tooltip or toolbar text (depending on state) | 236 | * @param text The tooltip or toolbar text (depending on state) |
237 | * @param index The position of the button. (-1 = at end). | 237 | * @param index The position of the button. (-1 = at end). |
238 | * | 238 | * |
239 | * @return The item index. | 239 | * @return The item index. |
240 | */ | 240 | */ |
241 | int insertButton(const QString& icon, int id, const char *signal, | 241 | int insertButton(const QString& icon, int id, const char *signal, |
242 | const QObject *receiver, const char *slot, | 242 | const QObject *receiver, const char *slot, |
243 | bool enabled = true, const QString& text = QString::null, | 243 | bool enabled = true, const QString& text = QString::null, |
244 | int index=-1/*US, KInstance *_instance = KGlobal::instance()*/ ); | 244 | int index=-1/*US, KInstance *_instance = KGlobal::instance()*/ ); |
245 | 245 | ||
246 | /** | 246 | /** |
247 | * Inserts a button (a @ref KToolBarButton) with the specified | 247 | * Inserts a button (a @ref KToolBarButton) with the specified |
248 | * pixmap. This pixmap will be used as the "active" one and the | 248 | * pixmap. This pixmap will be used as the "active" one and the |
249 | * disabled and default ones will be autogenerated. | 249 | * disabled and default ones will be autogenerated. |
250 | * | 250 | * |
251 | * It is recommended that you use the insertButton function that | 251 | * It is recommended that you use the insertButton function that |
252 | * allows you to specify the icon name rather then the pixmap | 252 | * allows you to specify the icon name rather then the pixmap |
253 | * itself. Specifying the icon name is much more flexible. | 253 | * itself. Specifying the icon name is much more flexible. |
254 | * | 254 | * |
255 | * You should connect to one or more signals in KToolBar: | 255 | * You should connect to one or more signals in KToolBar: |
256 | * @ref clicked() , @ref pressed() , @ref released() , or | 256 | * @ref clicked() , @ref pressed() , @ref released() , or |
257 | * @ref highlighted() and if the button is a toggle button | 257 | * @ref highlighted() and if the button is a toggle button |
258 | * (@ref setToggle() ) @ref toggled() . Those signals have @p id | 258 | * (@ref setToggle() ) @ref toggled() . Those signals have @p id |
259 | * of a button that caused the signal. If you want to bind a popup | 259 | * of a button that caused the signal. If you want to bind a popup |
260 | * to button, see @ref setButton(). | 260 | * to button, see @ref setButton(). |
261 | * | 261 | * |
262 | * @param pixmap The active pixmap | 262 | * @param pixmap The active pixmap |
263 | * @param id The id of this button | 263 | * @param id The id of this button |
264 | * @param enabled Enable or disable the button at startup | 264 | * @param enabled Enable or disable the button at startup |
265 | * @param text The tooltip or toolbar text (depending on state) | 265 | * @param text The tooltip or toolbar text (depending on state) |
266 | * @param index The position of the button. (-1 = at end). | 266 | * @param index The position of the button. (-1 = at end). |
267 | * | 267 | * |
268 | * @return The item index. | 268 | * @return The item index. |
269 | */ | 269 | */ |
270 | int insertButton(const QPixmap& pixmap, int id, bool enabled = true, | 270 | int insertButton(const QPixmap& pixmap, int id, bool enabled = true, |
271 | const QString& text = QString::null, int index=-1 ); | 271 | const QString& text = QString::null, int index=-1 ); |
272 | 272 | ||
273 | /** | 273 | /** |
274 | * This is the same as above, but with specified signals and | 274 | * This is the same as above, but with specified signals and |
275 | * slots to which this button will be connected. | 275 | * slots to which this button will be connected. |
276 | * | 276 | * |
277 | * You can add more signals with @ref addConnection(). | 277 | * You can add more signals with @ref addConnection(). |
278 | * | 278 | * |
279 | * @param icon The name of the icon to use as the active pixmap | 279 | * @param icon The name of the icon to use as the active pixmap |
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 |