author | ulf69 <ulf69> | 2004-07-06 04:04:56 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-07-06 04:04:56 (UTC) |
commit | c4bd138c16e8d34294502c9da5706e21337ba53d (patch) (unidiff) | |
tree | 08f15d9575264b04bcb0135077918175e2cd1650 | |
parent | 6a826e654102e78abb6d14f80a3679575e5d3c9a (diff) | |
download | kdepimpi-c4bd138c16e8d34294502c9da5706e21337ba53d.zip kdepimpi-c4bd138c16e8d34294502c9da5706e21337ba53d.tar.gz kdepimpi-c4bd138c16e8d34294502c9da5706e21337ba53d.tar.bz2 |
ok button of dialog works now. import of vcards works now, export of opie resources too.
-rw-r--r-- | kaddressbook/xxport/opie/opie_xxport.cpp | 4 | ||||
-rw-r--r-- | kaddressbook/xxport/vcard_xxport.cpp | 8 | ||||
-rw-r--r-- | libkdepim/libkdepimE.pro | 2 | ||||
-rw-r--r-- | microkde/kdialogbase.cpp | 3 |
4 files changed, 11 insertions, 6 deletions
diff --git a/kaddressbook/xxport/opie/opie_xxport.cpp b/kaddressbook/xxport/opie/opie_xxport.cpp index f30a205..d1def18 100644 --- a/kaddressbook/xxport/opie/opie_xxport.cpp +++ b/kaddressbook/xxport/opie/opie_xxport.cpp | |||
@@ -1,202 +1,202 @@ | |||
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 | /* | 24 | /* |
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 <qdir.h> | 31 | #include <qdir.h> |
32 | 32 | ||
33 | #include <kfiledialog.h> | 33 | #include <kfiledialog.h> |
34 | #include <kmessagebox.h> | 34 | #include <kmessagebox.h> |
35 | 35 | ||
36 | #include <opie/ocontactaccess.h> | 36 | #include <opie/ocontactaccess.h> |
37 | #include <opie/ocontactaccessbackend_xml.h> | 37 | #include <opie/ocontactaccessbackend_xml.h> |
38 | 38 | ||
39 | #include "stdaddressbook.h" | 39 | #include "stdaddressbook.h" |
40 | 40 | ||
41 | /*US | 41 | /*US |
42 | #include <qfile.h> | 42 | #include <qfile.h> |
43 | #include <qtextstream.h> | 43 | #include <qtextstream.h> |
44 | 44 | ||
45 | #include <kabc/vcardconverter.h> | 45 | #include <kabc/vcardconverter.h> |
46 | #ifndef KAB_EMBEDDED | 46 | #ifndef KAB_EMBEDDED |
47 | #include <kio/netaccess.h> | 47 | #include <kio/netaccess.h> |
48 | #endif //KAB_EMBEDDED | 48 | #endif //KAB_EMBEDDED |
49 | 49 | ||
50 | #include <klocale.h> | 50 | #include <klocale.h> |
51 | #include <kmessagebox.h> | 51 | #include <kmessagebox.h> |
52 | #include <ktempfile.h> | 52 | #include <ktempfile.h> |
53 | #include <kurl.h> | 53 | #include <kurl.h> |
54 | */ | 54 | */ |
55 | 55 | ||
56 | #include "xxportmanager.h" | 56 | #include "xxportmanager.h" |
57 | #include "opieconverter.h" | 57 | #include "opieconverter.h" |
58 | 58 | ||
59 | #include "opie_xxport.h" | 59 | #include "opie_xxport.h" |
60 | 60 | ||
61 | 61 | ||
62 | class OpieXXPortFactory : public XXPortFactory | 62 | class OpieXXPortFactory : public XXPortFactory |
63 | { | 63 | { |
64 | public: | 64 | public: |
65 | XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name ) | 65 | XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name ) |
66 | { | 66 | { |
67 | return new OpieXXPort( ab, parent, name ); | 67 | return new OpieXXPort( ab, parent, name ); |
68 | } | 68 | } |
69 | }; | 69 | }; |
70 | 70 | ||
71 | 71 | ||
72 | extern "C" | 72 | extern "C" |
73 | { | 73 | { |
74 | void *init_kaddrbk_opie_xxport() | 74 | void *init_kaddrbk_opie_xxport() |
75 | { | 75 | { |
76 | return ( new OpieXXPortFactory() ); | 76 | return ( new OpieXXPortFactory() ); |
77 | } | 77 | } |
78 | } | 78 | } |
79 | 79 | ||
80 | 80 | ||
81 | OpieXXPort::OpieXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name ) | 81 | OpieXXPort::OpieXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name ) |
82 | : XXPortObject( ab, parent, name ) | 82 | : XXPortObject( ab, parent, name ) |
83 | { | 83 | { |
84 | createImportAction( i18n( "Import Opie..." ) ); | 84 | createImportAction( i18n( "Import Opie..." ) ); |
85 | createExportAction( i18n( "Export Opie..." ) ); | 85 | createExportAction( i18n( "Export Opie..." ) ); |
86 | } | 86 | } |
87 | 87 | ||
88 | bool OpieXXPort::exportContacts( const KABC::AddresseeList &list, const QString &data ) | 88 | bool OpieXXPort::exportContacts( const KABC::AddresseeList &list, const QString &data ) |
89 | { | 89 | { |
90 | QString name = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; | 90 | QString name = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; |
91 | 91 | ||
92 | #ifndef KAB_EMBEDDED | 92 | #ifndef KAB_EMBEDDED |
93 | QString fileName = KFileDialog::getSaveFileName( name ); | 93 | QString fileName = KFileDialog::getSaveFileName( name ); |
94 | #else //KAB_EMBEDDED | 94 | #else //KAB_EMBEDDED |
95 | QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() ); | 95 | QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() ); |
96 | #endif //KAB_EMBEDDED | 96 | #endif //KAB_EMBEDDED |
97 | 97 | ||
98 | if ( fileName.isEmpty() ) | 98 | if ( fileName.isEmpty() ) |
99 | return true; | 99 | return true; |
100 | 100 | ||
101 | OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KA/Pi", fileName ); | 101 | OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KA/Pi", fileName ); |
102 | OContactAccess* access = new OContactAccess("KA/Pi", 0l, backend, false); | 102 | OContactAccess* access = new OContactAccess("KA/Pi", 0l, backend, false); |
103 | 103 | ||
104 | if ( !access ) { | 104 | if ( !access ) { |
105 | qDebug("Unable to access file() %s", fileName.latin1()); | 105 | qDebug("Unable to access file() %s", fileName.latin1()); |
106 | addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) ); | 106 | addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) ); |
107 | return false; | 107 | return false; |
108 | } | 108 | } |
109 | 109 | ||
110 | //Now check if the file has already entries, and ask the user if he wants to delete them first. | 110 | //Now check if the file has already entries, and ask the user if he wants to delete them first. |
111 | OContactAccess::List contactList = access->allRecords(); | 111 | OContactAccess::List contactList = access->allRecords(); |
112 | if (contactList.count() > 0) | 112 | if (contactList.count() > 0) |
113 | { | 113 | { |
114 | QString text( i18n( "Do you want to remove<br>all existing entries from<br>%1<br>before exporting.?" ) ); | 114 | QString text( i18n( "Do you want to remove<br>all existing entries from<br>%1<br>before exporting.?" ) ); |
115 | if ( KMessageBox::questionYesNo( parentWidget(), text.arg( fileName ) ) == KMessageBox::Yes ) { | 115 | if ( KMessageBox::questionYesNo( parentWidget(), text.arg( fileName ) ) == KMessageBox::Yes ) { |
116 | // Clean the database.. | 116 | // Clean the database.. |
117 | access->clear(); | 117 | access->clear(); |
118 | } | 118 | } |
119 | } | 119 | } |
120 | 120 | ||
121 | KABC::OpieConverter mConverter; | 121 | KABC::OpieConverter mConverter; |
122 | bool res; | 122 | bool res; |
123 | 123 | ||
124 | KABC::Addressee::List::ConstIterator it; | 124 | KABC::Addressee::List::ConstIterator it; |
125 | for ( it = list.begin(); it != list.end(); ++it ) { | 125 | for ( it = list.begin(); it != list.end(); ++it ) { |
126 | OContact c; | 126 | OContact c; |
127 | KABC::Addressee addressee = (*it); | 127 | KABC::Addressee addressee = (*it); |
128 | 128 | ||
129 | res = mConverter.addresseeToOpie( *it, c ); | 129 | res = mConverter.addresseeToOpie( *it, c ); |
130 | if (res == true) | 130 | if (res == true) |
131 | { | 131 | { |
132 | res = access->add(c); | 132 | res = access->add(c); |
133 | if (res == false) | 133 | if (res == false) |
134 | qDebug("Unable to append Contact %s", c.fullName().latin1()); | 134 | qDebug("Unable to append Contact %s", c.fullName().latin1()); |
135 | } | 135 | } |
136 | else | 136 | else |
137 | { | 137 | { |
138 | qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1()); | 138 | qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1()); |
139 | } | 139 | } |
140 | } | 140 | } |
141 | 141 | ||
142 | access->save(); | 142 | access->save(); |
143 | 143 | ||
144 | delete access; | 144 | delete access; |
145 | delete backend; | 145 | //US the deletion of the access object deletes the backend object as well. |
146 | 146 | ||
147 | return true; | 147 | return true; |
148 | } | 148 | } |
149 | 149 | ||
150 | KABC::AddresseeList OpieXXPort::importContacts( const QString& ) const | 150 | KABC::AddresseeList OpieXXPort::importContacts( const QString& ) const |
151 | { | 151 | { |
152 | KABC::AddresseeList adrlst; | 152 | KABC::AddresseeList adrlst; |
153 | 153 | ||
154 | QString name = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; | 154 | QString name = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; |
155 | 155 | ||
156 | #ifndef KAB_EMBEDDED | 156 | #ifndef KAB_EMBEDDED |
157 | QString fileName = KFileDialog::getOpenFileName( name ); | 157 | QString fileName = KFileDialog::getOpenFileName( name ); |
158 | #else //KAB_EMBEDDED | 158 | #else //KAB_EMBEDDED |
159 | QString fileName = KFileDialog::getOpenFileName( name, i18n("Load file"), parentWidget() ); | 159 | QString fileName = KFileDialog::getOpenFileName( name, i18n("Load file"), parentWidget() ); |
160 | #endif //KAB_EMBEDDED | 160 | #endif //KAB_EMBEDDED |
161 | 161 | ||
162 | if ( fileName.isEmpty() ) | 162 | if ( fileName.isEmpty() ) |
163 | return KABC::AddresseeList(); | 163 | return KABC::AddresseeList(); |
164 | 164 | ||
165 | OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KA/Pi", fileName ); | 165 | OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KA/Pi", fileName ); |
166 | OContactAccess* access = new OContactAccess("KA/Pi", 0l, backend, false); | 166 | OContactAccess* access = new OContactAccess("KA/Pi", 0l, backend, false); |
167 | 167 | ||
168 | if ( !access ) { | 168 | if ( !access ) { |
169 | qDebug("Unable to access file() %s", fileName.latin1()); | 169 | qDebug("Unable to access file() %s", fileName.latin1()); |
170 | addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) ); | 170 | addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) ); |
171 | return KABC::AddresseeList(); | 171 | return KABC::AddresseeList(); |
172 | } | 172 | } |
173 | 173 | ||
174 | access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available | 174 | access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available |
175 | 175 | ||
176 | KABC::OpieConverter mConverter; | 176 | KABC::OpieConverter mConverter; |
177 | bool res = false; | 177 | bool res = false; |
178 | 178 | ||
179 | 179 | ||
180 | OContactAccess::List::Iterator it; | 180 | OContactAccess::List::Iterator it; |
181 | OContactAccess::List allList = access->allRecords(); | 181 | OContactAccess::List allList = access->allRecords(); |
182 | for ( it = allList.begin(); it != allList.end(); ++it ) | 182 | for ( it = allList.begin(); it != allList.end(); ++it ) |
183 | { | 183 | { |
184 | OContact c = (*it); | 184 | OContact c = (*it); |
185 | 185 | ||
186 | KABC::Addressee addressee; | 186 | KABC::Addressee addressee; |
187 | 187 | ||
188 | res = mConverter.opieToAddressee( c, addressee ); | 188 | res = mConverter.opieToAddressee( c, addressee ); |
189 | 189 | ||
190 | if ( !addressee.isEmpty() && res ) { | 190 | if ( !addressee.isEmpty() && res ) { |
191 | adrlst.append( addressee ); | 191 | adrlst.append( addressee ); |
192 | } | 192 | } |
193 | 193 | ||
194 | // qDebug("found %s", c.fullName().latin1()); | 194 | // qDebug("found %s", c.fullName().latin1()); |
195 | } | 195 | } |
196 | 196 | ||
197 | delete access; | 197 | delete access; |
198 | delete backend; | 198 | //US the deletion of the access object deletes the backend object as well. |
199 | 199 | ||
200 | return adrlst; | 200 | return adrlst; |
201 | 201 | ||
202 | } | 202 | } |
diff --git a/kaddressbook/xxport/vcard_xxport.cpp b/kaddressbook/xxport/vcard_xxport.cpp index c017f5b..54d0cbd 100644 --- a/kaddressbook/xxport/vcard_xxport.cpp +++ b/kaddressbook/xxport/vcard_xxport.cpp | |||
@@ -1,242 +1,246 @@ | |||
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 | /* | 24 | /* |
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 <qfile.h> | 31 | #include <qfile.h> |
32 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
33 | 33 | ||
34 | #include <kabc/vcardconverter.h> | 34 | #include <kabc/vcardconverter.h> |
35 | #include <kfiledialog.h> | 35 | #include <kfiledialog.h> |
36 | #ifndef KAB_EMBEDDED | 36 | #ifndef KAB_EMBEDDED |
37 | #include <kio/netaccess.h> | 37 | #include <kio/netaccess.h> |
38 | #endif //KAB_EMBEDDED | 38 | #endif //KAB_EMBEDDED |
39 | 39 | ||
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kmessagebox.h> | 41 | #include <kmessagebox.h> |
42 | #include <ktempfile.h> | 42 | #include <ktempfile.h> |
43 | #include <kurl.h> | 43 | #include <kurl.h> |
44 | 44 | ||
45 | #include "xxportmanager.h" | 45 | #include "xxportmanager.h" |
46 | 46 | ||
47 | #include "vcard_xxport.h" | 47 | #include "vcard_xxport.h" |
48 | 48 | ||
49 | #ifndef KAB_EMBEDDED | 49 | #ifndef KAB_EMBEDDED |
50 | 50 | ||
51 | class VCardXXPortFactory : public XXPortFactory | 51 | class VCardXXPortFactory : public XXPortFactory |
52 | { | 52 | { |
53 | public: | 53 | public: |
54 | XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name ) | 54 | XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name ) |
55 | { | 55 | { |
56 | return new VCardXXPort( ab, parent, name ); | 56 | return new VCardXXPort( ab, parent, name ); |
57 | } | 57 | } |
58 | }; | 58 | }; |
59 | #endif //KAB_EMBEDDED | 59 | #endif //KAB_EMBEDDED |
60 | 60 | ||
61 | 61 | ||
62 | extern "C" | 62 | extern "C" |
63 | { | 63 | { |
64 | #ifndef KAB_EMBEDDED | 64 | #ifndef KAB_EMBEDDED |
65 | void *init_libkaddrbk_vcard_xxport() | 65 | void *init_libkaddrbk_vcard_xxport() |
66 | #else //KAB_EMBEDDED | 66 | #else //KAB_EMBEDDED |
67 | void *init_kaddrbk_vcard_xxport() | 67 | void *init_kaddrbk_vcard_xxport() |
68 | #endif //KAB_EMBEDDED | 68 | #endif //KAB_EMBEDDED |
69 | { | 69 | { |
70 | return ( new VCardXXPortFactory() ); | 70 | return ( new VCardXXPortFactory() ); |
71 | } | 71 | } |
72 | } | 72 | } |
73 | 73 | ||
74 | 74 | ||
75 | VCardXXPort::VCardXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name ) | 75 | VCardXXPort::VCardXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name ) |
76 | : XXPortObject( ab, parent, name ) | 76 | : XXPortObject( ab, parent, name ) |
77 | { | 77 | { |
78 | createImportAction( i18n( "Import vCard..." ) ); | 78 | createImportAction( i18n( "Import vCard..." ) ); |
79 | createExportAction( i18n( "Export vCard 2.1..." ), "v21" ); | 79 | createExportAction( i18n( "Export vCard 2.1..." ), "v21" ); |
80 | createExportAction( i18n( "Export vCard 3.0..." ), "v30" ); | 80 | createExportAction( i18n( "Export vCard 3.0..." ), "v30" ); |
81 | } | 81 | } |
82 | 82 | ||
83 | bool VCardXXPort::exportContacts( const KABC::AddresseeList &list, const QString &data ) | 83 | bool VCardXXPort::exportContacts( const KABC::AddresseeList &list, const QString &data ) |
84 | { | 84 | { |
85 | QString name; | 85 | QString name; |
86 | 86 | ||
87 | if ( list.count() == 1 ) | 87 | if ( list.count() == 1 ) |
88 | name = list[ 0 ].givenName() + "_" + list[ 0 ].familyName() + ".vcf"; | 88 | name = list[ 0 ].givenName() + "_" + list[ 0 ].familyName() + ".vcf"; |
89 | else | 89 | else |
90 | name = "addressbook.vcf"; | 90 | name = "addressbook.vcf"; |
91 | 91 | ||
92 | #ifndef KAB_EMBEDDED | 92 | #ifndef KAB_EMBEDDED |
93 | QString fileName = KFileDialog::getSaveFileName( name ); | 93 | QString fileName = KFileDialog::getSaveFileName( name ); |
94 | #else //KAB_EMBEDDED | 94 | #else //KAB_EMBEDDED |
95 | QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() ); | 95 | QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() ); |
96 | #endif //KAB_EMBEDDED | 96 | #endif //KAB_EMBEDDED |
97 | 97 | ||
98 | if ( fileName.isEmpty() ) | 98 | if ( fileName.isEmpty() ) |
99 | return true; | 99 | return true; |
100 | 100 | ||
101 | QFile outFile( fileName ); | 101 | QFile outFile( fileName ); |
102 | if ( !outFile.open( IO_WriteOnly ) ) { | 102 | if ( !outFile.open( IO_WriteOnly ) ) { |
103 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); | 103 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); |
104 | KMessageBox::error( parentWidget(), text.arg( fileName ) ); | 104 | KMessageBox::error( parentWidget(), text.arg( fileName ) ); |
105 | return false; | 105 | return false; |
106 | } | 106 | } |
107 | 107 | ||
108 | QTextStream t( &outFile ); | 108 | QTextStream t( &outFile ); |
109 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 109 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
110 | 110 | ||
111 | KABC::Addressee::List::ConstIterator it; | 111 | KABC::Addressee::List::ConstIterator it; |
112 | for ( it = list.begin(); it != list.end(); ++it ) { | 112 | for ( it = list.begin(); it != list.end(); ++it ) { |
113 | KABC::VCardConverter converter; | 113 | KABC::VCardConverter converter; |
114 | QString vcard; | 114 | QString vcard; |
115 | 115 | ||
116 | KABC::VCardConverter::Version version; | 116 | KABC::VCardConverter::Version version; |
117 | if ( data == "v21" ) | 117 | if ( data == "v21" ) |
118 | version = KABC::VCardConverter::v2_1; | 118 | version = KABC::VCardConverter::v2_1; |
119 | else | 119 | else |
120 | version = KABC::VCardConverter::v3_0; | 120 | version = KABC::VCardConverter::v3_0; |
121 | 121 | ||
122 | converter.addresseeToVCard( *it, vcard, version ); | 122 | converter.addresseeToVCard( *it, vcard, version ); |
123 | t << vcard << "\r\n\r\n"; | 123 | t << vcard << "\r\n\r\n"; |
124 | } | 124 | } |
125 | 125 | ||
126 | outFile.close(); | 126 | outFile.close(); |
127 | 127 | ||
128 | return true; | 128 | return true; |
129 | } | 129 | } |
130 | 130 | ||
131 | KABC::AddresseeList VCardXXPort::importContacts( const QString& ) const | 131 | KABC::AddresseeList VCardXXPort::importContacts( const QString& ) const |
132 | { | 132 | { |
133 | QString fileName; | 133 | QString fileName; |
134 | KABC::AddresseeList addrList; | 134 | KABC::AddresseeList addrList; |
135 | KURL url; | 135 | KURL url; |
136 | 136 | ||
137 | #ifndef KAB_EMBEDDED | 137 | #ifndef KAB_EMBEDDED |
138 | if ( !XXPortManager::importData.isEmpty() ) | 138 | if ( !XXPortManager::importData.isEmpty() ) |
139 | addrList = parseVCard( XXPortManager::importData ); | 139 | addrList = parseVCard( XXPortManager::importData ); |
140 | else { | 140 | else { |
141 | if ( XXPortManager::importURL.isEmpty() ) | 141 | if ( XXPortManager::importURL.isEmpty() ) |
142 | { | 142 | { |
143 | url = KFileDialog::getLoadFileName( QString::null, i18n("Select vCard to Import"), parentWidget() ); | 143 | url = KFileDialog::getLoadFileName( QString::null, i18n("Select vCard to Import"), parentWidget() ); |
144 | } | 144 | } |
145 | else | 145 | else |
146 | url = XXPortManager::importURL; | 146 | url = XXPortManager::importURL; |
147 | 147 | ||
148 | if ( url.isEmpty() ) | 148 | if ( url.isEmpty() ) |
149 | return addrList; | 149 | return addrList; |
150 | 150 | ||
151 | QString caption( i18n( "vCard Import Failed" ) ); | 151 | QString caption( i18n( "vCard Import Failed" ) ); |
152 | if ( KIO::NetAccess::download( url, fileName ) ) { | 152 | if ( KIO::NetAccess::download( url, fileName ) ) { |
153 | QFile file( fileName ); | 153 | QFile file( fileName ); |
154 | 154 | ||
155 | file.open( IO_ReadOnly ); | 155 | file.open( IO_ReadOnly ); |
156 | QByteArray rawData = file.readAll(); | 156 | QByteArray rawData = file.readAll(); |
157 | file.close(); | 157 | file.close(); |
158 | 158 | ||
159 | QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | 159 | QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); |
160 | addrList = parseVCard( data ); | 160 | addrList = parseVCard( data ); |
161 | 161 | ||
162 | if ( !url.isLocalFile() ) | 162 | if ( !url.isLocalFile() ) |
163 | KIO::NetAccess::removeTempFile( fileName ); | 163 | KIO::NetAccess::removeTempFile( fileName ); |
164 | 164 | ||
165 | } else { | 165 | } else { |
166 | QString text = i18n( "<qt>Unable to access <b>%1</b>.</qt>" ); | 166 | QString text = i18n( "<qt>Unable to access <b>%1</b>.</qt>" ); |
167 | KMessageBox::error( parentWidget(), text.arg( url.url() ), caption ); | 167 | KMessageBox::error( parentWidget(), text.arg( url.url() ), caption ); |
168 | } | 168 | } |
169 | 169 | ||
170 | } | 170 | } |
171 | 171 | ||
172 | 172 | ||
173 | #else //KAB_EMBEDDED | 173 | #else //KAB_EMBEDDED |
174 | 174 | ||
175 | 175 | ||
176 | if ( !XXPortManager::importData.isEmpty() ) | 176 | if ( !XXPortManager::importData.isEmpty() ) |
177 | addrList = parseVCard( XXPortManager::importData ); | 177 | addrList = parseVCard( XXPortManager::importData ); |
178 | else { | 178 | else { |
179 | if ( XXPortManager::importURL.isEmpty() ) | 179 | if ( XXPortManager::importURL.isEmpty() ) |
180 | { | 180 | { |
181 | fileName = KFileDialog::getOpenFileName( QString::null, i18n("Select vCard to Import"), parentWidget() ); | 181 | fileName = KFileDialog::getOpenFileName( QString::null, i18n("Select vCard to Import"), parentWidget() ); |
182 | if ( fileName.isEmpty() ) | ||
183 | return addrList; | ||
184 | |||
182 | } | 185 | } |
183 | else | 186 | else |
184 | { | 187 | { |
185 | //US url = XXPortManager::importURL; | 188 | //US url = XXPortManager::importURL; |
186 | qDebug("VCardXXPort::importContacts Urls at the moment not supported"); | 189 | qDebug("VCardXXPort::importContacts Urls at the moment not supported"); |
190 | if ( url.isEmpty() ) | ||
191 | return addrList; | ||
192 | |||
187 | } | 193 | } |
188 | 194 | ||
189 | if ( url.isEmpty() ) | ||
190 | return addrList; | ||
191 | 195 | ||
192 | QFile file( fileName ); | 196 | QFile file( fileName ); |
193 | 197 | ||
194 | file.open( IO_ReadOnly ); | 198 | file.open( IO_ReadOnly ); |
195 | QByteArray rawData = file.readAll(); | 199 | QByteArray rawData = file.readAll(); |
196 | file.close(); | 200 | file.close(); |
197 | 201 | ||
198 | QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | 202 | QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); |
199 | addrList = parseVCard( data ); | 203 | addrList = parseVCard( data ); |
200 | 204 | ||
201 | } | 205 | } |
202 | #endif //KAB_EMBEDDED | 206 | #endif //KAB_EMBEDDED |
203 | 207 | ||
204 | return addrList; | 208 | return addrList; |
205 | } | 209 | } |
206 | 210 | ||
207 | KABC::AddresseeList VCardXXPort::parseVCard( const QString &data ) const | 211 | KABC::AddresseeList VCardXXPort::parseVCard( const QString &data ) const |
208 | { | 212 | { |
209 | KABC::VCardConverter converter; | 213 | KABC::VCardConverter converter; |
210 | KABC::AddresseeList addrList; | 214 | KABC::AddresseeList addrList; |
211 | 215 | ||
212 | uint numVCards = data.contains( "BEGIN:VCARD", false ); | 216 | uint numVCards = data.contains( "BEGIN:VCARD", false ); |
213 | QStringList dataList = QStringList::split( "\r\n\r\n", data ); | 217 | QStringList dataList = QStringList::split( "\r\n\r\n", data ); |
214 | 218 | ||
215 | for ( uint i = 0; i < numVCards && i < dataList.count(); ++i ) { | 219 | for ( uint i = 0; i < numVCards && i < dataList.count(); ++i ) { |
216 | KABC::Addressee addr; | 220 | KABC::Addressee addr; |
217 | bool ok = false; | 221 | bool ok = false; |
218 | 222 | ||
219 | if ( dataList[ i ].contains( "VERSION:3.0" ) ) | 223 | if ( dataList[ i ].contains( "VERSION:3.0" ) ) |
220 | ok = converter.vCardToAddressee( dataList[ i ], addr, KABC::VCardConverter::v3_0 ); | 224 | ok = converter.vCardToAddressee( dataList[ i ], addr, KABC::VCardConverter::v3_0 ); |
221 | else if ( dataList[ i ].contains( "VERSION:2.1" ) ) | 225 | else if ( dataList[ i ].contains( "VERSION:2.1" ) ) |
222 | ok = converter.vCardToAddressee( dataList[ i ], addr, KABC::VCardConverter::v2_1 ); | 226 | ok = converter.vCardToAddressee( dataList[ i ], addr, KABC::VCardConverter::v2_1 ); |
223 | else { | 227 | else { |
224 | KMessageBox::sorry( parentWidget(), i18n( "Not supported vCard version." ) ); | 228 | KMessageBox::sorry( parentWidget(), i18n( "Not supported vCard version." ) ); |
225 | continue; | 229 | continue; |
226 | } | 230 | } |
227 | 231 | ||
228 | if ( !addr.isEmpty() && ok ) | 232 | if ( !addr.isEmpty() && ok ) |
229 | addrList.append( addr ); | 233 | addrList.append( addr ); |
230 | else { | 234 | else { |
231 | QString text = i18n( "The selected file does not include a valid vCard. " | 235 | QString text = i18n( "The selected file does not include a valid vCard. " |
232 | "Please check the file and try again." ); | 236 | "Please check the file and try again." ); |
233 | KMessageBox::sorry( parentWidget(), text ); | 237 | KMessageBox::sorry( parentWidget(), text ); |
234 | } | 238 | } |
235 | } | 239 | } |
236 | 240 | ||
237 | return addrList; | 241 | return addrList; |
238 | } | 242 | } |
239 | 243 | ||
240 | #ifndef KAB_EMBEDDED | 244 | #ifndef KAB_EMBEDDED |
241 | #include "vcard_xxport.moc" | 245 | #include "vcard_xxport.moc" |
242 | #endif //KAB_EMBEDDED | 246 | #endif //KAB_EMBEDDED |
diff --git a/libkdepim/libkdepimE.pro b/libkdepim/libkdepimE.pro index 414ac2b..b267d22 100644 --- a/libkdepim/libkdepimE.pro +++ b/libkdepim/libkdepimE.pro | |||
@@ -1,44 +1,44 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt warn_on | 2 | CONFIG += qt warn_on |
3 | TARGET = microkdepim | 3 | TARGET = microkdepim |
4 | INCLUDEPATH += ../microkde ../qtcompat ../libkabcwrap ../microkde/kdecore | 4 | INCLUDEPATH += ../microkde ../qtcompat ../libkabcwrap ../microkde/kdecore $(QPEDIR)/include |
5 | INCLUDEPATH += . .. | 5 | INCLUDEPATH += . .. |
6 | LIBS += -lmicrokde | 6 | LIBS += -lmicrokde |
7 | LIBS += -L$(QPEDIR)/lib | 7 | LIBS += -L$(QPEDIR)/lib |
8 | OBJECTS_DIR = obj/$(PLATFORM) | 8 | OBJECTS_DIR = obj/$(PLATFORM) |
9 | MOC_DIR = moc/$(PLATFORM) | 9 | MOC_DIR = moc/$(PLATFORM) |
10 | DESTDIR=$(QPEDIR)/lib | 10 | DESTDIR=$(QPEDIR)/lib |
11 | 11 | ||
12 | 12 | ||
13 | INTERFACES = \ | 13 | INTERFACES = \ |
14 | 14 | ||
15 | HEADERS = \ | 15 | HEADERS = \ |
16 | categoryeditdialog.h \ | 16 | categoryeditdialog.h \ |
17 | categoryeditdialog_base.h \ | 17 | categoryeditdialog_base.h \ |
18 | categoryselectdialog.h \ | 18 | categoryselectdialog.h \ |
19 | categoryselectdialog_base.h \ | 19 | categoryselectdialog_base.h \ |
20 | kdateedit.h \ | 20 | kdateedit.h \ |
21 | kdatepicker.h \ | 21 | kdatepicker.h \ |
22 | kinputdialog.h \ | 22 | kinputdialog.h \ |
23 | kincidenceformatter.h \ | 23 | kincidenceformatter.h \ |
24 | kpimprefs.h \ | 24 | kpimprefs.h \ |
25 | kprefs.h \ | 25 | kprefs.h \ |
26 | kprefsdialog.h \ | 26 | kprefsdialog.h \ |
27 | addresseeview.h \ | 27 | addresseeview.h \ |
28 | ksyncprofile.h | 28 | ksyncprofile.h |
29 | 29 | ||
30 | 30 | ||
31 | SOURCES = \ | 31 | SOURCES = \ |
32 | categoryeditdialog.cpp \ | 32 | categoryeditdialog.cpp \ |
33 | categoryeditdialog_base.cpp \ | 33 | categoryeditdialog_base.cpp \ |
34 | categoryselectdialog.cpp \ | 34 | categoryselectdialog.cpp \ |
35 | categoryselectdialog_base.cpp \ | 35 | categoryselectdialog_base.cpp \ |
36 | kdateedit.cpp \ | 36 | kdateedit.cpp \ |
37 | kinputdialog.cpp \ | 37 | kinputdialog.cpp \ |
38 | kdatepicker.cpp \ | 38 | kdatepicker.cpp \ |
39 | kincidenceformatter.cpp \ | 39 | kincidenceformatter.cpp \ |
40 | kpimprefs.cpp \ | 40 | kpimprefs.cpp \ |
41 | kprefs.cpp \ | 41 | kprefs.cpp \ |
42 | kprefsdialog.cpp \ | 42 | kprefsdialog.cpp \ |
43 | addresseeview.cpp \ | 43 | addresseeview.cpp \ |
44 | ksyncprofile.cpp | 44 | ksyncprofile.cpp |
diff --git a/microkde/kdialogbase.cpp b/microkde/kdialogbase.cpp index 2251207..489474a 100644 --- a/microkde/kdialogbase.cpp +++ b/microkde/kdialogbase.cpp | |||
@@ -1,290 +1,291 @@ | |||
1 | #include <qtabwidget.h> | 1 | #include <qtabwidget.h> |
2 | #include <qpushbutton.h> | 2 | #include <qpushbutton.h> |
3 | #include <qlayout.h> | 3 | #include <qlayout.h> |
4 | #include <qframe.h> | 4 | #include <qframe.h> |
5 | 5 | ||
6 | 6 | ||
7 | #include "klocale.h" | 7 | #include "klocale.h" |
8 | #include "kdebug.h" | 8 | #include "kdebug.h" |
9 | 9 | ||
10 | #include "kdialogbase.h" | 10 | #include "kdialogbase.h" |
11 | 11 | ||
12 | KDialogBase::KDialogBase() | 12 | KDialogBase::KDialogBase() |
13 | { | 13 | { |
14 | } | 14 | } |
15 | 15 | ||
16 | KDialogBase::KDialogBase( QWidget *parent, const char *name, bool modal, | 16 | KDialogBase::KDialogBase( QWidget *parent, const char *name, bool modal, |
17 | const QString &caption, | 17 | const QString &caption, |
18 | int buttonMask, ButtonCode defaultButton, | 18 | int buttonMask, ButtonCode defaultButton, |
19 | bool separator, | 19 | bool separator, |
20 | const QString &user1, | 20 | const QString &user1, |
21 | const QString &user2, | 21 | const QString &user2, |
22 | const QString &user3) : | 22 | const QString &user3) : |
23 | KDialog( parent, name, modal ) | 23 | KDialog( parent, name, modal ) |
24 | { | 24 | { |
25 | init( caption, buttonMask, user1, user2 ); | 25 | init( caption, buttonMask, user1, user2 ); |
26 | if (findButton( defaultButton ) ) | 26 | if (findButton( defaultButton ) ) |
27 | (findButton( defaultButton ) )->setFocus(); | 27 | (findButton( defaultButton ) )->setFocus(); |
28 | 28 | ||
29 | } | 29 | } |
30 | 30 | ||
31 | KDialogBase::KDialogBase( int dialogFace, const QString &caption, | 31 | KDialogBase::KDialogBase( int dialogFace, const QString &caption, |
32 | int buttonMask, ButtonCode defaultButton, | 32 | int buttonMask, ButtonCode defaultButton, |
33 | QWidget *parent, const char *name, bool modal, | 33 | QWidget *parent, const char *name, bool modal, |
34 | bool separator, | 34 | bool separator, |
35 | const QString &user1, | 35 | const QString &user1, |
36 | const QString &user2, | 36 | const QString &user2, |
37 | const QString &user3) : | 37 | const QString &user3) : |
38 | KDialog( parent, name, modal ) | 38 | KDialog( parent, name, modal ) |
39 | { | 39 | { |
40 | init( caption, buttonMask, user1, user2 ); | 40 | init( caption, buttonMask, user1, user2 ); |
41 | if (findButton( defaultButton ) ) | 41 | if (findButton( defaultButton ) ) |
42 | (findButton( defaultButton ) )->setFocus(); | 42 | (findButton( defaultButton ) )->setFocus(); |
43 | 43 | ||
44 | } | 44 | } |
45 | 45 | ||
46 | KDialogBase::~KDialogBase() | 46 | KDialogBase::~KDialogBase() |
47 | { | 47 | { |
48 | } | 48 | } |
49 | 49 | ||
50 | void KDialogBase::init( const QString &caption, int buttonMask, | 50 | void KDialogBase::init( const QString &caption, int buttonMask, |
51 | const QString &user1 ,const QString &user2 ) | 51 | const QString &user1 ,const QString &user2 ) |
52 | { | 52 | { |
53 | mMainWidget = 0; | 53 | mMainWidget = 0; |
54 | mTabWidget = 0; | 54 | mTabWidget = 0; |
55 | mPlainPage = 0; | 55 | mPlainPage = 0; |
56 | mTopLayout = 0; | 56 | mTopLayout = 0; |
57 | if ( !caption.isEmpty() ) { | 57 | if ( !caption.isEmpty() ) { |
58 | setCaption( caption ); | 58 | setCaption( caption ); |
59 | } | 59 | } |
60 | 60 | ||
61 | if ( buttonMask & User1 ) { | 61 | if ( buttonMask & User1 ) { |
62 | mUser1Button = new QPushButton( user1, this ); | 62 | mUser1Button = new QPushButton( user1, this ); |
63 | connect( mUser1Button, SIGNAL( clicked() ), SLOT( slotUser1() ) ); | 63 | connect( mUser1Button, SIGNAL( clicked() ), SLOT( slotUser1() ) ); |
64 | } else { | 64 | } else { |
65 | mUser1Button = 0; | 65 | mUser1Button = 0; |
66 | } | 66 | } |
67 | if ( buttonMask & User2 ) { | 67 | if ( buttonMask & User2 ) { |
68 | mUser2Button = new QPushButton( user2, this ); | 68 | mUser2Button = new QPushButton( user2, this ); |
69 | connect( mUser2Button, SIGNAL( clicked() ), SLOT( slotUser2() ) ); | 69 | connect( mUser2Button, SIGNAL( clicked() ), SLOT( slotUser2() ) ); |
70 | } else { | 70 | } else { |
71 | mUser2Button = 0; | 71 | mUser2Button = 0; |
72 | } | 72 | } |
73 | 73 | ||
74 | if ( buttonMask & Ok ) { | 74 | if ( buttonMask & Ok ) { |
75 | mOkButton = new QPushButton( i18n("Ok"), this ); | 75 | mOkButton = new QPushButton( i18n("Ok"), this ); |
76 | connect( mOkButton, SIGNAL( clicked() ), SLOT( slotOk() ) ); | 76 | connect( mOkButton, SIGNAL( clicked() ), SLOT( slotOk() ) ); |
77 | } else { | 77 | } else { |
78 | mOkButton = 0; | 78 | mOkButton = 0; |
79 | } | 79 | } |
80 | if ( buttonMask & Default ) { | 80 | if ( buttonMask & Default ) { |
81 | qDebug("buttonMask & Default "); | 81 | qDebug("buttonMask & Default "); |
82 | mDefaultButton = new QPushButton( i18n("Default"), this ); | 82 | mDefaultButton = new QPushButton( i18n("Default"), this ); |
83 | connect( mDefaultButton, SIGNAL( clicked() ), SIGNAL( defaultClicked() ) ); | 83 | connect( mDefaultButton, SIGNAL( clicked() ), SIGNAL( defaultClicked() ) ); |
84 | } else { | 84 | } else { |
85 | mDefaultButton = 0; | 85 | mDefaultButton = 0; |
86 | } | 86 | } |
87 | 87 | ||
88 | if ( buttonMask & Apply ) { | 88 | if ( buttonMask & Apply ) { |
89 | mApplyButton = new QPushButton( i18n("Apply"), this ); | 89 | mApplyButton = new QPushButton( i18n("Apply"), this ); |
90 | connect( mApplyButton, SIGNAL( clicked() ), SLOT( slotApply() ) ); | 90 | connect( mApplyButton, SIGNAL( clicked() ), SLOT( slotApply() ) ); |
91 | } else { | 91 | } else { |
92 | mApplyButton = 0; | 92 | mApplyButton = 0; |
93 | } | 93 | } |
94 | 94 | ||
95 | if ( buttonMask & Cancel ) { | 95 | if ( buttonMask & Cancel ) { |
96 | mCancelButton = new QPushButton( i18n("Cancel"), this ); | 96 | mCancelButton = new QPushButton( i18n("Cancel"), this ); |
97 | connect( mCancelButton, SIGNAL( clicked() ), SLOT( slotCancel() ) ); | 97 | connect( mCancelButton, SIGNAL( clicked() ), SLOT( slotCancel() ) ); |
98 | } else { | 98 | } else { |
99 | mCancelButton = 0; | 99 | mCancelButton = 0; |
100 | } | 100 | } |
101 | 101 | ||
102 | if ( buttonMask & Close ) { | 102 | if ( buttonMask & Close ) { |
103 | mCloseButton = new QPushButton( i18n("Close"), this ); | 103 | mCloseButton = new QPushButton( i18n("Close"), this ); |
104 | connect( mCloseButton, SIGNAL( clicked() ), SLOT( slotClose() ) ); | 104 | connect( mCloseButton, SIGNAL( clicked() ), SLOT( slotClose() ) ); |
105 | } else { | 105 | } else { |
106 | mCloseButton = 0; | 106 | mCloseButton = 0; |
107 | } | 107 | } |
108 | } | 108 | } |
109 | 109 | ||
110 | QTabWidget *KDialogBase::tabWidget() | 110 | QTabWidget *KDialogBase::tabWidget() |
111 | { | 111 | { |
112 | if ( !mTabWidget ) { | 112 | if ( !mTabWidget ) { |
113 | mTabWidget = new QTabWidget( this ); | 113 | mTabWidget = new QTabWidget( this ); |
114 | setMainWidget( mTabWidget ); | 114 | setMainWidget( mTabWidget ); |
115 | } | 115 | } |
116 | return mTabWidget; | 116 | return mTabWidget; |
117 | } | 117 | } |
118 | 118 | ||
119 | void KDialogBase::hideButtons() | 119 | void KDialogBase::hideButtons() |
120 | { | 120 | { |
121 | if ( mUser1Button ) mUser1Button->hide() ; | 121 | if ( mUser1Button ) mUser1Button->hide() ; |
122 | if ( mUser2Button ) mUser2Button->hide() ; | 122 | if ( mUser2Button ) mUser2Button->hide() ; |
123 | if ( mOkButton ) mOkButton->hide() ; | 123 | if ( mOkButton ) mOkButton->hide() ; |
124 | if ( mApplyButton ) mApplyButton->hide() ; | 124 | if ( mApplyButton ) mApplyButton->hide() ; |
125 | if ( mDefaultButton ) mDefaultButton->hide(); | 125 | if ( mDefaultButton ) mDefaultButton->hide(); |
126 | if ( mCancelButton ) mCancelButton->hide() ; | 126 | if ( mCancelButton ) mCancelButton->hide() ; |
127 | if ( mCloseButton ) mCloseButton->hide() ; | 127 | if ( mCloseButton ) mCloseButton->hide() ; |
128 | 128 | ||
129 | } | 129 | } |
130 | void KDialogBase::initLayout() | 130 | void KDialogBase::initLayout() |
131 | { | 131 | { |
132 | 132 | ||
133 | delete mTopLayout; | 133 | delete mTopLayout; |
134 | mTopLayout = new QVBoxLayout( this ); | 134 | mTopLayout = new QVBoxLayout( this ); |
135 | mTopLayout->setMargin( marginHint() ); | 135 | mTopLayout->setMargin( marginHint() ); |
136 | mTopLayout->setSpacing( spacingHint() ); | 136 | mTopLayout->setSpacing( spacingHint() ); |
137 | 137 | ||
138 | mTopLayout->addWidget( mMainWidget ); | 138 | mTopLayout->addWidget( mMainWidget ); |
139 | 139 | ||
140 | QBoxLayout *buttonLayout = new QHBoxLayout; | 140 | QBoxLayout *buttonLayout = new QHBoxLayout; |
141 | mTopLayout->addLayout( buttonLayout ); | 141 | mTopLayout->addLayout( buttonLayout ); |
142 | 142 | ||
143 | if ( mUser1Button ) buttonLayout->addWidget( mUser1Button ); | 143 | if ( mUser1Button ) buttonLayout->addWidget( mUser1Button ); |
144 | if ( mUser2Button ) buttonLayout->addWidget( mUser2Button ); | 144 | if ( mUser2Button ) buttonLayout->addWidget( mUser2Button ); |
145 | if ( mOkButton ) buttonLayout->addWidget( mOkButton ); | 145 | if ( mOkButton ) buttonLayout->addWidget( mOkButton ); |
146 | if ( mApplyButton ) buttonLayout->addWidget( mApplyButton ); | 146 | if ( mApplyButton ) buttonLayout->addWidget( mApplyButton ); |
147 | if ( mDefaultButton ) buttonLayout->addWidget( mDefaultButton ); | 147 | if ( mDefaultButton ) buttonLayout->addWidget( mDefaultButton ); |
148 | if ( mCancelButton ) buttonLayout->addWidget( mCancelButton ); | 148 | if ( mCancelButton ) buttonLayout->addWidget( mCancelButton ); |
149 | if ( mCloseButton ) buttonLayout->addWidget( mCloseButton ); | 149 | if ( mCloseButton ) buttonLayout->addWidget( mCloseButton ); |
150 | } | 150 | } |
151 | 151 | ||
152 | QFrame *KDialogBase::addPage( const QString &name ) | 152 | QFrame *KDialogBase::addPage( const QString &name ) |
153 | { | 153 | { |
154 | // kdDebug() << "KDialogBase::addPage(): " << name << endl; | 154 | // kdDebug() << "KDialogBase::addPage(): " << name << endl; |
155 | QFrame *frame = new QFrame( tabWidget() ); | 155 | QFrame *frame = new QFrame( tabWidget() ); |
156 | tabWidget()->addTab( frame, name ); | 156 | tabWidget()->addTab( frame, name ); |
157 | return frame; | 157 | return frame; |
158 | } | 158 | } |
159 | 159 | ||
160 | QFrame *KDialogBase::addPage( const QString &name, int, const QPixmap & ) | 160 | QFrame *KDialogBase::addPage( const QString &name, int, const QPixmap & ) |
161 | { | 161 | { |
162 | return addPage( name ); | 162 | return addPage( name ); |
163 | } | 163 | } |
164 | 164 | ||
165 | 165 | ||
166 | void KDialogBase::setMainWidget( QWidget *widget ) | 166 | void KDialogBase::setMainWidget( QWidget *widget ) |
167 | { | 167 | { |
168 | kdDebug() << "KDialogBase::setMainWidget()" << endl; | 168 | kdDebug() << "KDialogBase::setMainWidget()" << endl; |
169 | 169 | ||
170 | mMainWidget = widget; | 170 | mMainWidget = widget; |
171 | initLayout(); | 171 | initLayout(); |
172 | } | 172 | } |
173 | 173 | ||
174 | void KDialogBase::setButtonText( ButtonCode id, const QString &text ) | 174 | void KDialogBase::setButtonText( ButtonCode id, const QString &text ) |
175 | { | 175 | { |
176 | QPushButton *button = findButton( id ); | 176 | QPushButton *button = findButton( id ); |
177 | if ( button ) { | 177 | if ( button ) { |
178 | button->setText( text ); | 178 | button->setText( text ); |
179 | } | 179 | } |
180 | } | 180 | } |
181 | 181 | ||
182 | void KDialogBase::enableButton( ButtonCode id, bool state ) | 182 | void KDialogBase::enableButton( ButtonCode id, bool state ) |
183 | { | 183 | { |
184 | QPushButton *button = findButton( id ); | 184 | QPushButton *button = findButton( id ); |
185 | if ( button ) { | 185 | if ( button ) { |
186 | button->setEnabled( state ); | 186 | button->setEnabled( state ); |
187 | } | 187 | } |
188 | } | 188 | } |
189 | 189 | ||
190 | QPushButton *KDialogBase::findButton( ButtonCode id ) | 190 | QPushButton *KDialogBase::findButton( ButtonCode id ) |
191 | { | 191 | { |
192 | QPushButton *button = 0; | 192 | QPushButton *button = 0; |
193 | switch ( id ) { | 193 | switch ( id ) { |
194 | case Ok: | 194 | case Ok: |
195 | button = mOkButton; | 195 | button = mOkButton; |
196 | break; | 196 | break; |
197 | case Apply: | 197 | case Apply: |
198 | button = mApplyButton; | 198 | button = mApplyButton; |
199 | break; | 199 | break; |
200 | case User1: | 200 | case User1: |
201 | button = mUser1Button; | 201 | button = mUser1Button; |
202 | break; | 202 | break; |
203 | case User2: | 203 | case User2: |
204 | button = mUser2Button; | 204 | button = mUser2Button; |
205 | break; | 205 | break; |
206 | case Cancel: | 206 | case Cancel: |
207 | button = mCancelButton; | 207 | button = mCancelButton; |
208 | break; | 208 | break; |
209 | case Default: | 209 | case Default: |
210 | button = mDefaultButton; | 210 | button = mDefaultButton; |
211 | break; | 211 | break; |
212 | case Close: | 212 | case Close: |
213 | button = mCloseButton; | 213 | button = mCloseButton; |
214 | break; | 214 | break; |
215 | default: | 215 | default: |
216 | break; | 216 | break; |
217 | } | 217 | } |
218 | return button; | 218 | return button; |
219 | } | 219 | } |
220 | 220 | ||
221 | void KDialogBase::enableButtonOK( bool state ) | 221 | void KDialogBase::enableButtonOK( bool state ) |
222 | { | 222 | { |
223 | enableButton( Ok, state ); | 223 | enableButton( Ok, state ); |
224 | } | 224 | } |
225 | 225 | ||
226 | void KDialogBase::enableButtonApply( bool state ) | 226 | void KDialogBase::enableButtonApply( bool state ) |
227 | { | 227 | { |
228 | enableButton( Apply, state ); | 228 | enableButton( Apply, state ); |
229 | } | 229 | } |
230 | 230 | ||
231 | void KDialogBase::showButton( ButtonCode id, bool show ) | 231 | void KDialogBase::showButton( ButtonCode id, bool show ) |
232 | { | 232 | { |
233 | QPushButton *button = findButton( id ); | 233 | QPushButton *button = findButton( id ); |
234 | if ( button ) { | 234 | if ( button ) { |
235 | if ( show ) button->show(); | 235 | if ( show ) button->show(); |
236 | else button->hide(); | 236 | else button->hide(); |
237 | } | 237 | } |
238 | } | 238 | } |
239 | 239 | ||
240 | int KDialogBase::pageIndex( QWidget *widget ) const | 240 | int KDialogBase::pageIndex( QWidget *widget ) const |
241 | { | 241 | { |
242 | return 0; | 242 | return 0; |
243 | } | 243 | } |
244 | 244 | ||
245 | 245 | ||
246 | bool KDialogBase::showPage( int index ) | 246 | bool KDialogBase::showPage( int index ) |
247 | { | 247 | { |
248 | tabWidget()->setCurrentPage( index );return false; | 248 | tabWidget()->setCurrentPage( index );return false; |
249 | } | 249 | } |
250 | 250 | ||
251 | QFrame *KDialogBase::plainPage() | 251 | QFrame *KDialogBase::plainPage() |
252 | { | 252 | { |
253 | if ( !mPlainPage ) { | 253 | if ( !mPlainPage ) { |
254 | mPlainPage = new QFrame( this ); | 254 | mPlainPage = new QFrame( this ); |
255 | setMainWidget( mPlainPage ); | 255 | setMainWidget( mPlainPage ); |
256 | } | 256 | } |
257 | return mPlainPage; | 257 | return mPlainPage; |
258 | } | 258 | } |
259 | 259 | ||
260 | void KDialogBase::slotOk() | 260 | void KDialogBase::slotOk() |
261 | { | 261 | { |
262 | qDebug("KDialogBase::slotOk"); | ||
262 | emit okClicked(); | 263 | emit okClicked(); |
263 | QDialog::accept(); | 264 | accept(); |
264 | } | 265 | } |
265 | 266 | ||
266 | void KDialogBase::slotApply() | 267 | void KDialogBase::slotApply() |
267 | { | 268 | { |
268 | emit applyClicked(); | 269 | emit applyClicked(); |
269 | } | 270 | } |
270 | 271 | ||
271 | void KDialogBase::slotCancel() | 272 | void KDialogBase::slotCancel() |
272 | { | 273 | { |
273 | emit cancelClicked(); | 274 | emit cancelClicked(); |
274 | reject(); | 275 | reject(); |
275 | } | 276 | } |
276 | 277 | ||
277 | void KDialogBase::slotClose() | 278 | void KDialogBase::slotClose() |
278 | { | 279 | { |
279 | emit closeClicked(); | 280 | emit closeClicked(); |
280 | reject(); | 281 | reject(); |
281 | } | 282 | } |
282 | 283 | ||
283 | void KDialogBase::slotUser1() | 284 | void KDialogBase::slotUser1() |
284 | { | 285 | { |
285 | emit user1Clicked(); | 286 | emit user1Clicked(); |
286 | } | 287 | } |
287 | void KDialogBase::slotUser2() | 288 | void KDialogBase::slotUser2() |
288 | { | 289 | { |
289 | emit user2Clicked(); | 290 | emit user2Clicked(); |
290 | } | 291 | } |