author | zautrix <zautrix> | 2005-02-07 20:05:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-07 20:05:18 (UTC) |
commit | da5e47069d88fa9aa656423ce4c60bf505728e1c (patch) (unidiff) | |
tree | fdbaf29835a028f1204a19fc10dea97d469c0b29 | |
parent | 456b0246521847635fe98471691ceecae211e0c3 (diff) | |
download | kdepimpi-da5e47069d88fa9aa656423ce4c60bf505728e1c.zip kdepimpi-da5e47069d88fa9aa656423ce4c60bf505728e1c.tar.gz kdepimpi-da5e47069d88fa9aa656423ce4c60bf505728e1c.tar.bz2 |
fixes
-rw-r--r-- | kabc/formatfactory.cpp | 5 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/settings.cpp | 1 | ||||
-rw-r--r-- | korganizer/koagendaitem.cpp | 2 | ||||
-rw-r--r-- | korganizer/korganizer.pro | 2 | ||||
-rw-r--r-- | libkcal/calendar.cpp | 1 | ||||
-rw-r--r-- | libkcal/event.cpp | 6 | ||||
-rw-r--r-- | libkcal/todo.cpp | 4 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 7 | ||||
-rw-r--r-- | libkdepim/phoneaccess.cpp | 2 | ||||
-rw-r--r-- | microkde/kapplication.cpp | 3 | ||||
-rw-r--r-- | microkde/kdecore/klibloader.cpp | 14 | ||||
-rw-r--r-- | microkde/kdeui/ktoolbar.cpp | 2 | ||||
-rw-r--r-- | microkde/kdeui/ktoolbar.h | 2 |
13 files changed, 21 insertions, 30 deletions
diff --git a/kabc/formatfactory.cpp b/kabc/formatfactory.cpp index f2f03c6..3ae1c27 100644 --- a/kabc/formatfactory.cpp +++ b/kabc/formatfactory.cpp | |||
@@ -1,180 +1,181 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library 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 GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <kdebug.h> | 21 | #include <kdebug.h> |
22 | #include <klocale.h> | 22 | #include <klocale.h> |
23 | #include <ksimpleconfig.h> | 23 | #include <ksimpleconfig.h> |
24 | #include <kstandarddirs.h> | 24 | #include <kstandarddirs.h> |
25 | #include <kstaticdeleter.h> | 25 | #include <kstaticdeleter.h> |
26 | 26 | ||
27 | #include <qfile.h> | 27 | #include <qfile.h> |
28 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
29 | 29 | ||
30 | #include "vcardformatplugin.h" | 30 | #include "vcardformatplugin.h" |
31 | 31 | ||
32 | #include "formatfactory.h" | 32 | #include "formatfactory.h" |
33 | 33 | ||
34 | using namespace KABC; | 34 | using namespace KABC; |
35 | 35 | ||
36 | FormatFactory *FormatFactory::mSelf = 0; | 36 | FormatFactory *FormatFactory::mSelf = 0; |
37 | static KStaticDeleter<FormatFactory> factoryDeleter; | 37 | static KStaticDeleter<FormatFactory> factoryDeleter; |
38 | 38 | ||
39 | FormatFactory *FormatFactory::self() | 39 | FormatFactory *FormatFactory::self() |
40 | { | 40 | { |
41 | if ( !mSelf ) { | 41 | if ( !mSelf ) { |
42 | //US factoryDeleter.setObject( mSelf, new FormatFactory ); | 42 | //US factoryDeleter.setObject( mSelf, new FormatFactory ); |
43 | mSelf = factoryDeleter.setObject( new FormatFactory ); | 43 | mSelf = factoryDeleter.setObject( new FormatFactory ); |
44 | } | 44 | } |
45 | return mSelf; | 45 | return mSelf; |
46 | } | 46 | } |
47 | 47 | ||
48 | FormatFactory::FormatFactory() | 48 | FormatFactory::FormatFactory() |
49 | { | 49 | { |
50 | mFormatList.setAutoDelete( true ); | 50 | mFormatList.setAutoDelete( true ); |
51 | 51 | ||
52 | // dummy entry for default format | 52 | // dummy entry for default format |
53 | FormatInfo *info = new FormatInfo; | 53 | FormatInfo *info = new FormatInfo; |
54 | info->library = "<NoLibrary>"; | 54 | info->library = "<NoLibrary>"; |
55 | info->nameLabel = i18n( "vCard" ); | 55 | info->nameLabel = i18n( "vCard" ); |
56 | info->descriptionLabel = i18n( "vCard Format" ); | 56 | info->descriptionLabel = i18n( "vCard Format" ); |
57 | mFormatList.insert( "vcard", info ); | 57 | mFormatList.insert( "vcard", info ); |
58 | 58 | ||
59 | /*US lets enter all resources directly instead of using teh desktopfiles. | 59 | #if 0 |
60 | US lets enter all resources directly instead of using teh desktopfiles. | ||
60 | 61 | ||
61 | QStringList list = KGlobal::dirs()->findAllResources( "data" ,"kabc/formats/*.desktop", true, true ); | 62 | QStringList list = KGlobal::dirs()->findAllResources( "data" ,"kabc/formats/*.desktop", true, true ); |
62 | for ( QStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) | 63 | for ( QStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) |
63 | { | 64 | { |
64 | //US KSimpleConfig config( *it, true ); | 65 | //US KSimpleConfig config( *it, true ); |
65 | KConfig config( *it ); | 66 | KConfig config( *it ); |
66 | 67 | ||
67 | if ( !config.hasGroup( "Misc" ) || !config.hasGroup( "Plugin" ) ) | 68 | if ( !config.hasGroup( "Misc" ) || !config.hasGroup( "Plugin" ) ) |
68 | continue; | 69 | continue; |
69 | 70 | ||
70 | info = new FormatInfo; | 71 | info = new FormatInfo; |
71 | 72 | ||
72 | config.setGroup( "Plugin" ); | 73 | config.setGroup( "Plugin" ); |
73 | QString type = config.readEntry( "Type" ); | 74 | QString type = config.readEntry( "Type" ); |
74 | info->library = config.readEntry( "X-KDE-Library" ); | 75 | info->library = config.readEntry( "X-KDE-Library" ); |
75 | 76 | ||
76 | config.setGroup( "Misc" ); | 77 | config.setGroup( "Misc" ); |
77 | info->nameLabel = config.readEntry( "Name" ); | 78 | info->nameLabel = config.readEntry( "Name" ); |
78 | info->descriptionLabel = config.readEntry( "Comment", i18n( "No description available." ) ); | 79 | info->descriptionLabel = config.readEntry( "Comment", i18n( "No description available." ) ); |
79 | 80 | ||
80 | mFormatList.insert( type, info ); | 81 | mFormatList.insert( type, info ); |
81 | } | 82 | } |
82 | */ | 83 | #endif |
83 | //US we already have vcard as default format. | 84 | //US we already have vcard as default format. |
84 | info = new FormatInfo; | 85 | info = new FormatInfo; |
85 | info->library = i18n("microkabcformat_binary"); | 86 | info->library = i18n("microkabcformat_binary"); |
86 | info->nameLabel = i18n( "Binary" ); | 87 | info->nameLabel = i18n( "Binary" ); |
87 | info->descriptionLabel = i18n( "No description available." ); | 88 | info->descriptionLabel = i18n( "No description available." ); |
88 | mFormatList.insert( "binary", info ); | 89 | mFormatList.insert( "binary", info ); |
89 | 90 | ||
90 | } | 91 | } |
91 | 92 | ||
92 | FormatFactory::~FormatFactory() | 93 | FormatFactory::~FormatFactory() |
93 | { | 94 | { |
94 | mFormatList.clear(); | 95 | mFormatList.clear(); |
95 | } | 96 | } |
96 | 97 | ||
97 | QStringList FormatFactory::formats() | 98 | QStringList FormatFactory::formats() |
98 | { | 99 | { |
99 | QStringList retval; | 100 | QStringList retval; |
100 | 101 | ||
101 | // make sure 'vcard' is the first entry | 102 | // make sure 'vcard' is the first entry |
102 | retval << "vcard"; | 103 | retval << "vcard"; |
103 | 104 | ||
104 | QDictIterator<FormatInfo> it( mFormatList ); | 105 | QDictIterator<FormatInfo> it( mFormatList ); |
105 | for ( ; it.current(); ++it ) | 106 | for ( ; it.current(); ++it ) |
106 | if ( it.currentKey() != "vcard" ) | 107 | if ( it.currentKey() != "vcard" ) |
107 | retval << it.currentKey(); | 108 | retval << it.currentKey(); |
108 | 109 | ||
109 | return retval; | 110 | return retval; |
110 | } | 111 | } |
111 | 112 | ||
112 | FormatInfo *FormatFactory::info( const QString &type ) | 113 | FormatInfo *FormatFactory::info( const QString &type ) |
113 | { | 114 | { |
114 | if ( type.isEmpty() ) | 115 | if ( type.isEmpty() ) |
115 | return 0; | 116 | return 0; |
116 | else | 117 | else |
117 | return mFormatList[ type ]; | 118 | return mFormatList[ type ]; |
118 | } | 119 | } |
119 | 120 | ||
120 | FormatPlugin *FormatFactory::format( const QString& type ) | 121 | FormatPlugin *FormatFactory::format( const QString& type ) |
121 | { | 122 | { |
122 | FormatPlugin *format = 0; | 123 | FormatPlugin *format = 0; |
123 | 124 | ||
124 | if ( type.isEmpty() ) | 125 | if ( type.isEmpty() ) |
125 | return 0; | 126 | return 0; |
126 | 127 | ||
127 | if ( type == "vcard" ) { | 128 | if ( type == "vcard" ) { |
128 | format = new VCardFormatPlugin; | 129 | format = new VCardFormatPlugin; |
129 | format->setType( type ); | 130 | format->setType( type ); |
130 | format->setNameLabel( i18n( "vCard" ) ); | 131 | format->setNameLabel( i18n( "vCard" ) ); |
131 | format->setDescriptionLabel( i18n( "vCard Format" ) ); | 132 | format->setDescriptionLabel( i18n( "vCard Format" ) ); |
132 | return format; | 133 | return format; |
133 | } | 134 | } |
134 | 135 | ||
135 | FormatInfo *fi = mFormatList[ type ]; | 136 | FormatInfo *fi = mFormatList[ type ]; |
136 | if (!fi) | 137 | if (!fi) |
137 | return 0; | 138 | return 0; |
138 | QString libName = fi->library; | 139 | QString libName = fi->library; |
139 | #ifndef DESKTOP_VERSION | 140 | #ifndef DESKTOP_VERSION |
140 | KLibrary *library = openLibrary( libName ); | 141 | KLibrary *library = openLibrary( libName ); |
141 | if ( !library ) | 142 | if ( !library ) |
142 | return 0; | 143 | return 0; |
143 | 144 | ||
144 | void *format_func = library->symbol( "format"); | 145 | void *format_func = library->symbol( "format"); |
145 | 146 | ||
146 | if ( format_func ) { | 147 | if ( format_func ) { |
147 | format = ((FormatPlugin* (*)())format_func)(); | 148 | format = ((FormatPlugin* (*)())format_func)(); |
148 | format->setType( type ); | 149 | format->setType( type ); |
149 | format->setNameLabel( fi->nameLabel ); | 150 | format->setNameLabel( fi->nameLabel ); |
150 | format->setDescriptionLabel( fi->descriptionLabel ); | 151 | format->setDescriptionLabel( fi->descriptionLabel ); |
151 | } else { | 152 | } else { |
152 | kdDebug( 5700 ) << "'" << libName << "' is not a format plugin." << endl; | 153 | kdDebug( 5700 ) << "'" << libName << "' is not a format plugin." << endl; |
153 | return 0; | 154 | return 0; |
154 | } | 155 | } |
155 | #endif | 156 | #endif |
156 | return format; | 157 | return format; |
157 | } | 158 | } |
158 | 159 | ||
159 | #ifndef DESKTOP_VERSION | 160 | #ifndef DESKTOP_VERSION |
160 | KLibrary *FormatFactory::openLibrary( const QString& libName ) | 161 | KLibrary *FormatFactory::openLibrary( const QString& libName ) |
161 | { | 162 | { |
162 | KLibrary *library = 0; | 163 | KLibrary *library = 0; |
163 | 164 | ||
164 | QString path = KLibLoader::findLibrary( QFile::encodeName( libName ) ); | 165 | QString path = KLibLoader::findLibrary( QFile::encodeName( libName ) ); |
165 | 166 | ||
166 | if ( path.isEmpty() ) { | 167 | if ( path.isEmpty() ) { |
167 | kdDebug( 5700 ) << "No format plugin library was found!" << endl; | 168 | kdDebug( 5700 ) << "No format plugin library was found!" << endl; |
168 | return 0; | 169 | return 0; |
169 | } | 170 | } |
170 | 171 | ||
171 | library = KLibLoader::self()->library( QFile::encodeName( path ) ); | 172 | library = KLibLoader::self()->library( QFile::encodeName( path ) ); |
172 | 173 | ||
173 | if ( !library ) { | 174 | if ( !library ) { |
174 | kdDebug( 5700 ) << "Could not load library '" << libName << "'" << endl; | 175 | kdDebug( 5700 ) << "Could not load library '" << libName << "'" << endl; |
175 | return 0; | 176 | return 0; |
176 | } | 177 | } |
177 | 178 | ||
178 | return library; | 179 | return library; |
179 | } | 180 | } |
180 | #endif | 181 | #endif |
diff --git a/kmicromail/libmailwrapper/settings.cpp b/kmicromail/libmailwrapper/settings.cpp index 8f909f9..9436d43 100644 --- a/kmicromail/libmailwrapper/settings.cpp +++ b/kmicromail/libmailwrapper/settings.cpp | |||
@@ -1,545 +1,544 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <qdir.h> | 2 | #include <qdir.h> |
3 | 3 | ||
4 | #include <qtextcodec.h> | 4 | #include <qtextcodec.h> |
5 | #include <qtextstream.h> | 5 | #include <qtextstream.h> |
6 | #include <qfile.h> | 6 | #include <qfile.h> |
7 | 7 | ||
8 | //#include <opie2/odebug.h> | 8 | //#include <opie2/odebug.h> |
9 | #include <kconfig.h> | 9 | #include <kconfig.h> |
10 | 10 | ||
11 | #include <kstandarddirs.h> | 11 | #include <kstandarddirs.h> |
12 | #include "settings.h" | 12 | #include "settings.h" |
13 | //#include "defines.h" | 13 | //#include "defines.h" |
14 | 14 | ||
15 | #define IMAP_PORT "143" | 15 | #define IMAP_PORT "143" |
16 | #define IMAP_SSL_PORT "993" | 16 | #define IMAP_SSL_PORT "993" |
17 | #define SMTP_PORT "25" | 17 | #define SMTP_PORT "25" |
18 | #define SMTP_SSL_PORT "465" | 18 | #define SMTP_SSL_PORT "465" |
19 | #define POP3_PORT "110" | 19 | #define POP3_PORT "110" |
20 | #define POP3_SSL_PORT "995" | 20 | #define POP3_SSL_PORT "995" |
21 | #define NNTP_PORT "119" | 21 | #define NNTP_PORT "119" |
22 | #define NNTP_SSL_PORT "563" | 22 | #define NNTP_SSL_PORT "563" |
23 | 23 | ||
24 | 24 | ||
25 | Settings::Settings() | 25 | Settings::Settings() |
26 | : QObject() | 26 | : QObject() |
27 | { | 27 | { |
28 | accounts.setAutoDelete( true ); ; | 28 | accounts.setAutoDelete( true ); ; |
29 | updateAccounts(); | 29 | updateAccounts(); |
30 | //qDebug("++++++++++++++++++new settings "); | 30 | //qDebug("++++++++++++++++++new settings "); |
31 | } | 31 | } |
32 | 32 | ||
33 | void Settings::checkDirectory() | 33 | void Settings::checkDirectory() |
34 | { | 34 | { |
35 | return; | 35 | return; |
36 | locateLocal("data", "kopiemail" ); | 36 | locateLocal("data", "kopiemail" ); |
37 | /* | 37 | /* |
38 | if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { | 38 | if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { |
39 | system( "mkdir -p $HOME/Applications/opiemail" ); | 39 | system( "mkdir -p $HOME/Applications/opiemail" ); |
40 | qDebug("$HOME/Applications/opiemail created "); | 40 | qDebug("$HOME/Applications/opiemail created "); |
41 | } | 41 | } |
42 | */ | 42 | */ |
43 | } | 43 | } |
44 | 44 | ||
45 | QList<Account> Settings::getAccounts() | 45 | QList<Account> Settings::getAccounts() |
46 | { | 46 | { |
47 | return accounts; | 47 | return accounts; |
48 | } | 48 | } |
49 | 49 | ||
50 | void Settings::addAccount( Account *account ) | 50 | void Settings::addAccount( Account *account ) |
51 | { | 51 | { |
52 | accounts.append( account ); | 52 | accounts.append( account ); |
53 | } | 53 | } |
54 | 54 | ||
55 | void Settings::delAccount( Account *account ) | 55 | void Settings::delAccount( Account *account ) |
56 | { | 56 | { |
57 | account->remove(); | 57 | account->remove(); |
58 | accounts.remove( account ); | 58 | accounts.remove( account ); |
59 | } | 59 | } |
60 | 60 | ||
61 | void Settings::updateAccounts() | 61 | void Settings::updateAccounts() |
62 | { | 62 | { |
63 | accounts.clear(); | 63 | accounts.clear(); |
64 | QDir dir( locateLocal("data", "kopiemail" ) ); | 64 | QDir dir( locateLocal("data", "kopiemail" ) ); |
65 | QStringList::Iterator it; | 65 | QStringList::Iterator it; |
66 | 66 | ||
67 | QStringList imap = dir.entryList( "imap-*" ); | 67 | QStringList imap = dir.entryList( "imap-*" ); |
68 | for ( it = imap.begin(); it != imap.end(); it++ ) { | 68 | for ( it = imap.begin(); it != imap.end(); it++ ) { |
69 | IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); | 69 | IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); |
70 | accounts.append( account ); | 70 | accounts.append( account ); |
71 | } | 71 | } |
72 | 72 | ||
73 | QStringList pop3 = dir.entryList( "pop3-*" ); | 73 | QStringList pop3 = dir.entryList( "pop3-*" ); |
74 | for ( it = pop3.begin(); it != pop3.end(); it++ ) { | 74 | for ( it = pop3.begin(); it != pop3.end(); it++ ) { |
75 | POP3account *account = new POP3account( (*it).replace(0, 5, "") ); | 75 | POP3account *account = new POP3account( (*it).replace(0, 5, "") ); |
76 | accounts.append( account ); | 76 | accounts.append( account ); |
77 | } | 77 | } |
78 | 78 | ||
79 | QStringList smtp = dir.entryList( "smtp-*" ); | 79 | QStringList smtp = dir.entryList( "smtp-*" ); |
80 | for ( it = smtp.begin(); it != smtp.end(); it++ ) { | 80 | for ( it = smtp.begin(); it != smtp.end(); it++ ) { |
81 | SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); | 81 | SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); |
82 | accounts.append( account ); | 82 | accounts.append( account ); |
83 | } | 83 | } |
84 | 84 | ||
85 | QStringList nntp = dir.entryList( "nntp-*" ); | 85 | QStringList nntp = dir.entryList( "nntp-*" ); |
86 | for ( it = nntp.begin(); it != nntp.end(); it++ ) { | 86 | for ( it = nntp.begin(); it != nntp.end(); it++ ) { |
87 | NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); | 87 | NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); |
88 | accounts.append( account ); | 88 | accounts.append( account ); |
89 | } | 89 | } |
90 | 90 | ||
91 | readAccounts(); | 91 | readAccounts(); |
92 | } | 92 | } |
93 | 93 | ||
94 | void Settings::saveAccounts() | 94 | void Settings::saveAccounts() |
95 | { | 95 | { |
96 | checkDirectory(); | 96 | checkDirectory(); |
97 | Account *it; | 97 | Account *it; |
98 | 98 | ||
99 | for ( it = accounts.first(); it; it = accounts.next() ) { | 99 | for ( it = accounts.first(); it; it = accounts.next() ) { |
100 | it->save(); | 100 | it->save(); |
101 | } | 101 | } |
102 | } | 102 | } |
103 | 103 | ||
104 | void Settings::readAccounts() | 104 | void Settings::readAccounts() |
105 | { | 105 | { |
106 | checkDirectory(); | 106 | checkDirectory(); |
107 | Account *it; | 107 | Account *it; |
108 | 108 | ||
109 | for ( it = accounts.first(); it; it = accounts.next() ) { | 109 | for ( it = accounts.first(); it; it = accounts.next() ) { |
110 | it->read(); | 110 | it->read(); |
111 | } | 111 | } |
112 | } | 112 | } |
113 | 113 | ||
114 | Account::Account() | 114 | Account::Account() |
115 | { | 115 | { |
116 | accountName = "changeMe"; | 116 | accountName = "changeMe"; |
117 | type = MAILLIB::A_UNDEFINED; | 117 | type = MAILLIB::A_UNDEFINED; |
118 | ssl = false; | 118 | ssl = false; |
119 | connectionType = 1; | 119 | connectionType = 1; |
120 | offline = false; | 120 | offline = false; |
121 | maxMailSize = 0; | 121 | maxMailSize = 0; |
122 | lastFetch; | ||
123 | leaveOnServer = false; | 122 | leaveOnServer = false; |
124 | } | 123 | } |
125 | 124 | ||
126 | void Account::remove() | 125 | void Account::remove() |
127 | { | 126 | { |
128 | QFile file( getFileName() ); | 127 | QFile file( getFileName() ); |
129 | file.remove(); | 128 | file.remove(); |
130 | } | 129 | } |
131 | 130 | ||
132 | void Account::setPasswordList(const QStringList &str) | 131 | void Account::setPasswordList(const QStringList &str) |
133 | { | 132 | { |
134 | password = ""; | 133 | password = ""; |
135 | int i; | 134 | int i; |
136 | for ( i = 0; i < str.count() ; ++i ) { | 135 | for ( i = 0; i < str.count() ; ++i ) { |
137 | QChar c ( (str[i].toUInt()-131)/(str.count()- (i%3))); | 136 | QChar c ( (str[i].toUInt()-131)/(str.count()- (i%3))); |
138 | password.append( c ); | 137 | password.append( c ); |
139 | } | 138 | } |
140 | //qDebug("password %s ", password.latin1()); | 139 | //qDebug("password %s ", password.latin1()); |
141 | } | 140 | } |
142 | QStringList Account::getPasswordList() | 141 | QStringList Account::getPasswordList() |
143 | { | 142 | { |
144 | int i; | 143 | int i; |
145 | int len = password.length(); | 144 | int len = password.length(); |
146 | QStringList str; | 145 | QStringList str; |
147 | 146 | ||
148 | for ( i = 0; i < len ; ++i ) { | 147 | for ( i = 0; i < len ; ++i ) { |
149 | int val = password.at(i).unicode()*(len-(i%3))+131; | 148 | int val = password.at(i).unicode()*(len-(i%3))+131; |
150 | str.append( QString::number( val ) ); | 149 | str.append( QString::number( val ) ); |
151 | // qDebug("append %s ", str[i].latin1()); | 150 | // qDebug("append %s ", str[i].latin1()); |
152 | } | 151 | } |
153 | return str; | 152 | return str; |
154 | } | 153 | } |
155 | 154 | ||
156 | IMAPaccount::IMAPaccount() | 155 | IMAPaccount::IMAPaccount() |
157 | : Account() | 156 | : Account() |
158 | { | 157 | { |
159 | file = IMAPaccount::getUniqueFileName(); | 158 | file = IMAPaccount::getUniqueFileName(); |
160 | accountName = "New IMAP Account"; | 159 | accountName = "New IMAP Account"; |
161 | ssl = false; | 160 | ssl = false; |
162 | connectionType = 1; | 161 | connectionType = 1; |
163 | type = MAILLIB::A_IMAP; | 162 | type = MAILLIB::A_IMAP; |
164 | port = IMAP_PORT; | 163 | port = IMAP_PORT; |
165 | } | 164 | } |
166 | 165 | ||
167 | IMAPaccount::IMAPaccount( QString filename ) | 166 | IMAPaccount::IMAPaccount( QString filename ) |
168 | : Account() | 167 | : Account() |
169 | { | 168 | { |
170 | file = filename; | 169 | file = filename; |
171 | accountName = "New IMAP Account"; | 170 | accountName = "New IMAP Account"; |
172 | ssl = false; | 171 | ssl = false; |
173 | connectionType = 1; | 172 | connectionType = 1; |
174 | type = MAILLIB::A_IMAP; | 173 | type = MAILLIB::A_IMAP; |
175 | port = IMAP_PORT; | 174 | port = IMAP_PORT; |
176 | } | 175 | } |
177 | 176 | ||
178 | QString IMAPaccount::getUniqueFileName() | 177 | QString IMAPaccount::getUniqueFileName() |
179 | { | 178 | { |
180 | int num = 0; | 179 | int num = 0; |
181 | QString unique; | 180 | QString unique; |
182 | 181 | ||
183 | QDir dir( locateLocal("data", "kopiemail" ) ); | 182 | QDir dir( locateLocal("data", "kopiemail" ) ); |
184 | 183 | ||
185 | QStringList imap = dir.entryList( "imap-*" ); | 184 | QStringList imap = dir.entryList( "imap-*" ); |
186 | do { | 185 | do { |
187 | unique.setNum( num++ ); | 186 | unique.setNum( num++ ); |
188 | } while ( imap.contains( "imap-" + unique ) > 0 ); | 187 | } while ( imap.contains( "imap-" + unique ) > 0 ); |
189 | 188 | ||
190 | return unique; | 189 | return unique; |
191 | } | 190 | } |
192 | 191 | ||
193 | void IMAPaccount::read() | 192 | void IMAPaccount::read() |
194 | { | 193 | { |
195 | KConfig *conf = new KConfig( getFileName() ); | 194 | KConfig *conf = new KConfig( getFileName() ); |
196 | conf->setGroup( "IMAP Account" ); | 195 | conf->setGroup( "IMAP Account" ); |
197 | accountName = conf->readEntry( "Account","" ); | 196 | accountName = conf->readEntry( "Account","" ); |
198 | if (accountName.isNull()) accountName = ""; | 197 | if (accountName.isNull()) accountName = ""; |
199 | server = conf->readEntry( "Server","" ); | 198 | server = conf->readEntry( "Server","" ); |
200 | if (server.isNull()) server=""; | 199 | if (server.isNull()) server=""; |
201 | port = conf->readEntry( "Port","" ); | 200 | port = conf->readEntry( "Port","" ); |
202 | if (port.isNull()) port="143"; | 201 | if (port.isNull()) port="143"; |
203 | connectionType = conf->readNumEntry( "ConnectionType" ); | 202 | connectionType = conf->readNumEntry( "ConnectionType" ); |
204 | ssl = conf->readBoolEntry( "SSL",false ); | 203 | ssl = conf->readBoolEntry( "SSL",false ); |
205 | user = conf->readEntry( "User","" ); | 204 | user = conf->readEntry( "User","" ); |
206 | if (user.isNull()) user = ""; | 205 | if (user.isNull()) user = ""; |
207 | //password = conf->readEntryCrypt( "Password","" ); | 206 | //password = conf->readEntryCrypt( "Password","" ); |
208 | setPasswordList( conf->readListEntry( "FolderHistory")); | 207 | setPasswordList( conf->readListEntry( "FolderHistory")); |
209 | if (password.isNull()) password = ""; | 208 | if (password.isNull()) password = ""; |
210 | prefix = conf->readEntry("MailPrefix",""); | 209 | prefix = conf->readEntry("MailPrefix",""); |
211 | if (prefix.isNull()) prefix = ""; | 210 | if (prefix.isNull()) prefix = ""; |
212 | offline = conf->readBoolEntry("Offline",false); | 211 | offline = conf->readBoolEntry("Offline",false); |
213 | localFolder = conf->readEntry( "LocalFolder" ); | 212 | localFolder = conf->readEntry( "LocalFolder" ); |
214 | maxMailSize = conf->readNumEntry( "MaxSize",0 ); | 213 | maxMailSize = conf->readNumEntry( "MaxSize",0 ); |
215 | int lf = conf->readNumEntry( "LastFetch",0 ); | 214 | int lf = conf->readNumEntry( "LastFetch",0 ); |
216 | QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); | 215 | QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); |
217 | leaveOnServer = conf->readBoolEntry("LeaveOnServer",false); | 216 | leaveOnServer = conf->readBoolEntry("LeaveOnServer",false); |
218 | if ( lf < 0 ) lf = 0; | 217 | if ( lf < 0 ) lf = 0; |
219 | lastFetch = dt.addSecs( lf ); | 218 | lastFetch = dt.addSecs( lf ); |
220 | delete conf; | 219 | delete conf; |
221 | } | 220 | } |
222 | 221 | ||
223 | void IMAPaccount::save() | 222 | void IMAPaccount::save() |
224 | { | 223 | { |
225 | 224 | ||
226 | Settings::checkDirectory(); | 225 | Settings::checkDirectory(); |
227 | 226 | ||
228 | KConfig *conf = new KConfig( getFileName() ); | 227 | KConfig *conf = new KConfig( getFileName() ); |
229 | conf->setGroup( "IMAP Account" ); | 228 | conf->setGroup( "IMAP Account" ); |
230 | conf->writeEntry( "Account", accountName ); | 229 | conf->writeEntry( "Account", accountName ); |
231 | conf->writeEntry( "Server", server ); | 230 | conf->writeEntry( "Server", server ); |
232 | conf->writeEntry( "Port", port ); | 231 | conf->writeEntry( "Port", port ); |
233 | conf->writeEntry( "SSL", ssl ); | 232 | conf->writeEntry( "SSL", ssl ); |
234 | conf->writeEntry( "ConnectionType", connectionType ); | 233 | conf->writeEntry( "ConnectionType", connectionType ); |
235 | conf->writeEntry( "User", user ); | 234 | conf->writeEntry( "User", user ); |
236 | //conf->writeEntryCrypt( "Password", password ); | 235 | //conf->writeEntryCrypt( "Password", password ); |
237 | conf->writeEntry( "FolderHistory",getPasswordList() ); | 236 | conf->writeEntry( "FolderHistory",getPasswordList() ); |
238 | conf->writeEntry( "MailPrefix",prefix); | 237 | conf->writeEntry( "MailPrefix",prefix); |
239 | conf->writeEntry( "Offline",offline); | 238 | conf->writeEntry( "Offline",offline); |
240 | conf->writeEntry( "LocalFolder", localFolder ); | 239 | conf->writeEntry( "LocalFolder", localFolder ); |
241 | conf->writeEntry( "MaxSize", maxMailSize ); | 240 | conf->writeEntry( "MaxSize", maxMailSize ); |
242 | QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); | 241 | QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); |
243 | int lf = dt.secsTo ( lastFetch ); | 242 | int lf = dt.secsTo ( lastFetch ); |
244 | conf->writeEntry( "LastFetch", lf ); | 243 | conf->writeEntry( "LastFetch", lf ); |
245 | conf->writeEntry( "LeaveOnServer", leaveOnServer); | 244 | conf->writeEntry( "LeaveOnServer", leaveOnServer); |
246 | conf->sync(); | 245 | conf->sync(); |
247 | delete conf; | 246 | delete conf; |
248 | } | 247 | } |
249 | 248 | ||
250 | 249 | ||
251 | QString IMAPaccount::getFileName() | 250 | QString IMAPaccount::getFileName() |
252 | { | 251 | { |
253 | return locateLocal("data", "kopiemail" ) +"/imap-" + file; | 252 | return locateLocal("data", "kopiemail" ) +"/imap-" + file; |
254 | } | 253 | } |
255 | 254 | ||
256 | POP3account::POP3account() | 255 | POP3account::POP3account() |
257 | : Account() | 256 | : Account() |
258 | { | 257 | { |
259 | file = POP3account::getUniqueFileName(); | 258 | file = POP3account::getUniqueFileName(); |
260 | accountName = "New POP3 Account"; | 259 | accountName = "New POP3 Account"; |
261 | ssl = false; | 260 | ssl = false; |
262 | connectionType = 1; | 261 | connectionType = 1; |
263 | type = MAILLIB::A_POP3; | 262 | type = MAILLIB::A_POP3; |
264 | port = POP3_PORT; | 263 | port = POP3_PORT; |
265 | } | 264 | } |
266 | 265 | ||
267 | POP3account::POP3account( QString filename ) | 266 | POP3account::POP3account( QString filename ) |
268 | : Account() | 267 | : Account() |
269 | { | 268 | { |
270 | file = filename; | 269 | file = filename; |
271 | accountName = "New POP3 Account"; | 270 | accountName = "New POP3 Account"; |
272 | ssl = false; | 271 | ssl = false; |
273 | connectionType = 1; | 272 | connectionType = 1; |
274 | type = MAILLIB::A_POP3; | 273 | type = MAILLIB::A_POP3; |
275 | port = POP3_PORT; | 274 | port = POP3_PORT; |
276 | } | 275 | } |
277 | 276 | ||
278 | QString POP3account::getUniqueFileName() | 277 | QString POP3account::getUniqueFileName() |
279 | { | 278 | { |
280 | int num = 0; | 279 | int num = 0; |
281 | QString unique; | 280 | QString unique; |
282 | 281 | ||
283 | QDir dir( locateLocal("data", "kopiemail" ) ); | 282 | QDir dir( locateLocal("data", "kopiemail" ) ); |
284 | 283 | ||
285 | QStringList imap = dir.entryList( "pop3-*" ); | 284 | QStringList imap = dir.entryList( "pop3-*" ); |
286 | do { | 285 | do { |
287 | unique.setNum( num++ ); | 286 | unique.setNum( num++ ); |
288 | } while ( imap.contains( "pop3-" + unique ) > 0 ); | 287 | } while ( imap.contains( "pop3-" + unique ) > 0 ); |
289 | 288 | ||
290 | return unique; | 289 | return unique; |
291 | } | 290 | } |
292 | 291 | ||
293 | void POP3account::read() | 292 | void POP3account::read() |
294 | { | 293 | { |
295 | KConfig *conf = new KConfig( getFileName()); | 294 | KConfig *conf = new KConfig( getFileName()); |
296 | conf->setGroup( "POP3 Account" ); | 295 | conf->setGroup( "POP3 Account" ); |
297 | accountName = conf->readEntry( "Account" ); | 296 | accountName = conf->readEntry( "Account" ); |
298 | server = conf->readEntry( "Server" ); | 297 | server = conf->readEntry( "Server" ); |
299 | port = conf->readEntry( "Port" ); | 298 | port = conf->readEntry( "Port" ); |
300 | ssl = conf->readBoolEntry( "SSL" ); | 299 | ssl = conf->readBoolEntry( "SSL" ); |
301 | connectionType = conf->readNumEntry( "ConnectionType" ); | 300 | connectionType = conf->readNumEntry( "ConnectionType" ); |
302 | user = conf->readEntry( "User" ); | 301 | user = conf->readEntry( "User" ); |
303 | //password = conf->readEntryCrypt( "Password" ); | 302 | //password = conf->readEntryCrypt( "Password" ); |
304 | setPasswordList( conf->readListEntry( "FolderHistory")); | 303 | setPasswordList( conf->readListEntry( "FolderHistory")); |
305 | offline = conf->readBoolEntry("Offline",false); | 304 | offline = conf->readBoolEntry("Offline",false); |
306 | localFolder = conf->readEntry( "LocalFolder" ); | 305 | localFolder = conf->readEntry( "LocalFolder" ); |
307 | maxMailSize = conf->readNumEntry( "MaxSize",0 ); | 306 | maxMailSize = conf->readNumEntry( "MaxSize",0 ); |
308 | int lf = conf->readNumEntry( "LastFetch",0 ); | 307 | int lf = conf->readNumEntry( "LastFetch",0 ); |
309 | QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); | 308 | QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); |
310 | leaveOnServer = conf->readBoolEntry("LeaveOnServer",false); | 309 | leaveOnServer = conf->readBoolEntry("LeaveOnServer",false); |
311 | lastFetch = dt.addSecs( lf ); | 310 | lastFetch = dt.addSecs( lf ); |
312 | delete conf; | 311 | delete conf; |
313 | } | 312 | } |
314 | 313 | ||
315 | void POP3account::save() | 314 | void POP3account::save() |
316 | { | 315 | { |
317 | Settings::checkDirectory(); | 316 | Settings::checkDirectory(); |
318 | 317 | ||
319 | KConfig *conf = new KConfig( getFileName() ); | 318 | KConfig *conf = new KConfig( getFileName() ); |
320 | conf->setGroup( "POP3 Account" ); | 319 | conf->setGroup( "POP3 Account" ); |
321 | conf->writeEntry( "Account", accountName ); | 320 | conf->writeEntry( "Account", accountName ); |
322 | conf->writeEntry( "Server", server ); | 321 | conf->writeEntry( "Server", server ); |
323 | conf->writeEntry( "Port", port ); | 322 | conf->writeEntry( "Port", port ); |
324 | conf->writeEntry( "SSL", ssl ); | 323 | conf->writeEntry( "SSL", ssl ); |
325 | conf->writeEntry( "ConnectionType", connectionType ); | 324 | conf->writeEntry( "ConnectionType", connectionType ); |
326 | conf->writeEntry( "User", user ); | 325 | conf->writeEntry( "User", user ); |
327 | //conf->writeEntryCrypt( "Password", password ); | 326 | //conf->writeEntryCrypt( "Password", password ); |
328 | conf->writeEntry( "FolderHistory",getPasswordList() ); | 327 | conf->writeEntry( "FolderHistory",getPasswordList() ); |
329 | conf->writeEntry( "Offline",offline); | 328 | conf->writeEntry( "Offline",offline); |
330 | conf->writeEntry( "LocalFolder", localFolder ); | 329 | conf->writeEntry( "LocalFolder", localFolder ); |
331 | conf->writeEntry( "MaxSize", maxMailSize ); | 330 | conf->writeEntry( "MaxSize", maxMailSize ); |
332 | QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); | 331 | QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); |
333 | int lf = dt.secsTo ( lastFetch ); | 332 | int lf = dt.secsTo ( lastFetch ); |
334 | conf->writeEntry( "LastFetch", lf ); | 333 | conf->writeEntry( "LastFetch", lf ); |
335 | conf->writeEntry( "LeaveOnServer", leaveOnServer); | 334 | conf->writeEntry( "LeaveOnServer", leaveOnServer); |
336 | conf->sync(); | 335 | conf->sync(); |
337 | delete conf; | 336 | delete conf; |
338 | } | 337 | } |
339 | 338 | ||
340 | 339 | ||
341 | QString POP3account::getFileName() | 340 | QString POP3account::getFileName() |
342 | { | 341 | { |
343 | return locateLocal("data", "kopiemail" ) +"/pop3-" + file; | 342 | return locateLocal("data", "kopiemail" ) +"/pop3-" + file; |
344 | } | 343 | } |
345 | 344 | ||
346 | SMTPaccount::SMTPaccount() | 345 | SMTPaccount::SMTPaccount() |
347 | : Account() | 346 | : Account() |
348 | { | 347 | { |
349 | file = SMTPaccount::getUniqueFileName(); | 348 | file = SMTPaccount::getUniqueFileName(); |
350 | accountName = "New SMTP Account"; | 349 | accountName = "New SMTP Account"; |
351 | ssl = false; | 350 | ssl = false; |
352 | connectionType = 1; | 351 | connectionType = 1; |
353 | login = false; | 352 | login = false; |
354 | useCC = false; | 353 | useCC = false; |
355 | useBCC = false; | 354 | useBCC = false; |
356 | useReply = false; | 355 | useReply = false; |
357 | type = MAILLIB::A_SMTP; | 356 | type = MAILLIB::A_SMTP; |
358 | port = SMTP_PORT; | 357 | port = SMTP_PORT; |
359 | } | 358 | } |
360 | 359 | ||
361 | SMTPaccount::SMTPaccount( QString filename ) | 360 | SMTPaccount::SMTPaccount( QString filename ) |
362 | : Account() | 361 | : Account() |
363 | { | 362 | { |
364 | file = filename; | 363 | file = filename; |
365 | accountName = "New SMTP Account"; | 364 | accountName = "New SMTP Account"; |
366 | ssl = false; | 365 | ssl = false; |
367 | connectionType = 1; | 366 | connectionType = 1; |
368 | login = false; | 367 | login = false; |
369 | type = MAILLIB::A_SMTP; | 368 | type = MAILLIB::A_SMTP; |
370 | port = SMTP_PORT; | 369 | port = SMTP_PORT; |
371 | } | 370 | } |
372 | 371 | ||
373 | QString SMTPaccount::getSignature() | 372 | QString SMTPaccount::getSignature() |
374 | { | 373 | { |
375 | QFileInfo fi ( signature ); | 374 | QFileInfo fi ( signature ); |
376 | if ( ! fi.exists() ) | 375 | if ( ! fi.exists() ) |
377 | return QString(); | 376 | return QString(); |
378 | 377 | ||
379 | QFile file( signature ); | 378 | QFile file( signature ); |
380 | if (!file.open( IO_ReadOnly ) ) { | 379 | if (!file.open( IO_ReadOnly ) ) { |
381 | return QString(); | 380 | return QString(); |
382 | 381 | ||
383 | } | 382 | } |
384 | QTextStream ts( &file ); | 383 | QTextStream ts( &file ); |
385 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 384 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
386 | QString text = ts.read(); | 385 | QString text = ts.read(); |
387 | file.close(); | 386 | file.close(); |
388 | 387 | ||
389 | return text; | 388 | return text; |
390 | 389 | ||
391 | } | 390 | } |
392 | void SMTPaccount::setSignature( QString b ) | 391 | void SMTPaccount::setSignature( QString b ) |
393 | { | 392 | { |
394 | 393 | ||
395 | QFileInfo fi ( signature ); | 394 | QFileInfo fi ( signature ); |
396 | if ( ! fi.exists() ) { | 395 | if ( ! fi.exists() ) { |
397 | QString filedir( locateLocal("data", "kopiemail" ) ); | 396 | QString filedir( locateLocal("data", "kopiemail" ) ); |
398 | signature = filedir+ "/" + getAccountName() +".sig"; | 397 | signature = filedir+ "/" + getAccountName() +".sig"; |
399 | qDebug("new sig %s ", signature.latin1()); | 398 | qDebug("new sig %s ", signature.latin1()); |
400 | save(); | 399 | save(); |
401 | } | 400 | } |
402 | QFile fileIn( signature ); | 401 | QFile fileIn( signature ); |
403 | if (!fileIn.open( IO_WriteOnly ) ) { | 402 | if (!fileIn.open( IO_WriteOnly ) ) { |
404 | qDebug("OM: Cannot write signature file %s ", signature.latin1() ); | 403 | qDebug("OM: Cannot write signature file %s ", signature.latin1() ); |
405 | return ; | 404 | return ; |
406 | } | 405 | } |
407 | QTextStream tsIn( &fileIn ); | 406 | QTextStream tsIn( &fileIn ); |
408 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 407 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
409 | tsIn << b ; | 408 | tsIn << b ; |
410 | fileIn.close(); | 409 | fileIn.close(); |
411 | } | 410 | } |
412 | QString SMTPaccount::getUniqueFileName() | 411 | QString SMTPaccount::getUniqueFileName() |
413 | { | 412 | { |
414 | int num = 0; | 413 | int num = 0; |
415 | QString unique; | 414 | QString unique; |
416 | 415 | ||
417 | QDir dir( locateLocal("data", "kopiemail" ) ); | 416 | QDir dir( locateLocal("data", "kopiemail" ) ); |
418 | 417 | ||
419 | QStringList imap = dir.entryList( "smtp-*" ); | 418 | QStringList imap = dir.entryList( "smtp-*" ); |
420 | do { | 419 | do { |
421 | unique.setNum( num++ ); | 420 | unique.setNum( num++ ); |
422 | } while ( imap.contains( "smtp-" + unique ) > 0 ); | 421 | } while ( imap.contains( "smtp-" + unique ) > 0 ); |
423 | 422 | ||
424 | return unique; | 423 | return unique; |
425 | } | 424 | } |
426 | 425 | ||
427 | void SMTPaccount::read() | 426 | void SMTPaccount::read() |
428 | { | 427 | { |
429 | KConfig *conf = new KConfig( getFileName() ); | 428 | KConfig *conf = new KConfig( getFileName() ); |
430 | conf->setGroup( "SMTP Account" ); | 429 | conf->setGroup( "SMTP Account" ); |
431 | accountName = conf->readEntry( "Account" ); | 430 | accountName = conf->readEntry( "Account" ); |
432 | server = conf->readEntry( "Server" ); | 431 | server = conf->readEntry( "Server" ); |
433 | port = conf->readEntry( "Port" ); | 432 | port = conf->readEntry( "Port" ); |
434 | ssl = conf->readBoolEntry( "SSL" ); | 433 | ssl = conf->readBoolEntry( "SSL" ); |
435 | connectionType = conf->readNumEntry( "ConnectionType" ); | 434 | connectionType = conf->readNumEntry( "ConnectionType" ); |
436 | login = conf->readBoolEntry( "Login" ); | 435 | login = conf->readBoolEntry( "Login" ); |
437 | user = conf->readEntry( "User" ); | 436 | user = conf->readEntry( "User" ); |
438 | signature = conf->readEntry( "SigFile" ); | 437 | signature = conf->readEntry( "SigFile" ); |
439 | setPasswordList( conf->readListEntry( "FolderHistory")); | 438 | setPasswordList( conf->readListEntry( "FolderHistory")); |
440 | delete conf; | 439 | delete conf; |
441 | } | 440 | } |
442 | 441 | ||
443 | void SMTPaccount::save() | 442 | void SMTPaccount::save() |
444 | { | 443 | { |
445 | Settings::checkDirectory(); | 444 | Settings::checkDirectory(); |
446 | 445 | ||
447 | KConfig *conf = new KConfig( getFileName() ); | 446 | KConfig *conf = new KConfig( getFileName() ); |
448 | conf->setGroup( "SMTP Account" ); | 447 | conf->setGroup( "SMTP Account" ); |
449 | conf->writeEntry( "Account", accountName ); | 448 | conf->writeEntry( "Account", accountName ); |
450 | conf->writeEntry( "Server", server ); | 449 | conf->writeEntry( "Server", server ); |
451 | conf->writeEntry( "Port", port ); | 450 | conf->writeEntry( "Port", port ); |
452 | conf->writeEntry( "SSL", ssl ); | 451 | conf->writeEntry( "SSL", ssl ); |
453 | conf->writeEntry( "ConnectionType", connectionType ); | 452 | conf->writeEntry( "ConnectionType", connectionType ); |
454 | conf->writeEntry( "Login", login ); | 453 | conf->writeEntry( "Login", login ); |
455 | conf->writeEntry( "User", user ); | 454 | conf->writeEntry( "User", user ); |
456 | conf->writeEntry( "SigFile", signature ); | 455 | conf->writeEntry( "SigFile", signature ); |
457 | //conf->writeEntryCrypt( "Password", password ); | 456 | //conf->writeEntryCrypt( "Password", password ); |
458 | conf->writeEntry( "FolderHistory",getPasswordList() ); | 457 | conf->writeEntry( "FolderHistory",getPasswordList() ); |
459 | conf->sync(); | 458 | conf->sync(); |
460 | delete conf; | 459 | delete conf; |
461 | } | 460 | } |
462 | 461 | ||
463 | 462 | ||
464 | QString SMTPaccount::getFileName() | 463 | QString SMTPaccount::getFileName() |
465 | { | 464 | { |
466 | return locateLocal("data", "kopiemail" ) +"/smtp-" + file; | 465 | return locateLocal("data", "kopiemail" ) +"/smtp-" + file; |
467 | } | 466 | } |
468 | 467 | ||
469 | NNTPaccount::NNTPaccount() | 468 | NNTPaccount::NNTPaccount() |
470 | : Account() | 469 | : Account() |
471 | { | 470 | { |
472 | file = NNTPaccount::getUniqueFileName(); | 471 | file = NNTPaccount::getUniqueFileName(); |
473 | accountName = "New NNTP Account"; | 472 | accountName = "New NNTP Account"; |
474 | ssl = false; | 473 | ssl = false; |
475 | login = false; | 474 | login = false; |
476 | type = MAILLIB::A_NNTP; | 475 | type = MAILLIB::A_NNTP; |
477 | port = NNTP_PORT; | 476 | port = NNTP_PORT; |
478 | } | 477 | } |
479 | 478 | ||
480 | NNTPaccount::NNTPaccount( QString filename ) | 479 | NNTPaccount::NNTPaccount( QString filename ) |
481 | : Account() | 480 | : Account() |
482 | { | 481 | { |
483 | file = filename; | 482 | file = filename; |
484 | accountName = "New NNTP Account"; | 483 | accountName = "New NNTP Account"; |
485 | ssl = false; | 484 | ssl = false; |
486 | login = false; | 485 | login = false; |
487 | type = MAILLIB::A_NNTP; | 486 | type = MAILLIB::A_NNTP; |
488 | port = NNTP_PORT; | 487 | port = NNTP_PORT; |
489 | } | 488 | } |
490 | 489 | ||
491 | QString NNTPaccount::getUniqueFileName() | 490 | QString NNTPaccount::getUniqueFileName() |
492 | { | 491 | { |
493 | int num = 0; | 492 | int num = 0; |
494 | QString unique; | 493 | QString unique; |
495 | 494 | ||
496 | QDir dir( locateLocal("data", "kopiemail" ) ); | 495 | QDir dir( locateLocal("data", "kopiemail" ) ); |
497 | 496 | ||
498 | QStringList imap = dir.entryList( "nntp-*" ); | 497 | QStringList imap = dir.entryList( "nntp-*" ); |
499 | do { | 498 | do { |
500 | unique.setNum( num++ ); | 499 | unique.setNum( num++ ); |
501 | } while ( imap.contains( "nntp-" + unique ) > 0 ); | 500 | } while ( imap.contains( "nntp-" + unique ) > 0 ); |
502 | 501 | ||
503 | return unique; | 502 | return unique; |
504 | } | 503 | } |
505 | 504 | ||
506 | void NNTPaccount::read() | 505 | void NNTPaccount::read() |
507 | { | 506 | { |
508 | KConfig *conf = new KConfig( getFileName() ); | 507 | KConfig *conf = new KConfig( getFileName() ); |
509 | conf->setGroup( "NNTP Account" ); | 508 | conf->setGroup( "NNTP Account" ); |
510 | accountName = conf->readEntry( "Account" ); | 509 | accountName = conf->readEntry( "Account" ); |
511 | server = conf->readEntry( "Server" ); | 510 | server = conf->readEntry( "Server" ); |
512 | port = conf->readEntry( "Port" ); | 511 | port = conf->readEntry( "Port" ); |
513 | ssl = conf->readBoolEntry( "SSL" ); | 512 | ssl = conf->readBoolEntry( "SSL" ); |
514 | login = conf->readBoolEntry( "Login" ); | 513 | login = conf->readBoolEntry( "Login" ); |
515 | user = conf->readEntry( "User" ); | 514 | user = conf->readEntry( "User" ); |
516 | //password = conf->readEntryCrypt( "Password" ); | 515 | //password = conf->readEntryCrypt( "Password" ); |
517 | setPasswordList( conf->readListEntry( "FolderHistory")); | 516 | setPasswordList( conf->readListEntry( "FolderHistory")); |
518 | subscribedGroups = conf->readListEntry( "Subscribed"); | 517 | subscribedGroups = conf->readListEntry( "Subscribed"); |
519 | delete conf; | 518 | delete conf; |
520 | } | 519 | } |
521 | 520 | ||
522 | void NNTPaccount::save() | 521 | void NNTPaccount::save() |
523 | { | 522 | { |
524 | Settings::checkDirectory(); | 523 | Settings::checkDirectory(); |
525 | 524 | ||
526 | KConfig *conf = new KConfig( getFileName() ); | 525 | KConfig *conf = new KConfig( getFileName() ); |
527 | conf->setGroup( "NNTP Account" ); | 526 | conf->setGroup( "NNTP Account" ); |
528 | conf->writeEntry( "Account", accountName ); | 527 | conf->writeEntry( "Account", accountName ); |
529 | conf->writeEntry( "Server", server ); | 528 | conf->writeEntry( "Server", server ); |
530 | conf->writeEntry( "Port", port ); | 529 | conf->writeEntry( "Port", port ); |
531 | conf->writeEntry( "SSL", ssl ); | 530 | conf->writeEntry( "SSL", ssl ); |
532 | conf->writeEntry( "Login", login ); | 531 | conf->writeEntry( "Login", login ); |
533 | conf->writeEntry( "User", user ); | 532 | conf->writeEntry( "User", user ); |
534 | //conf->writeEntryCrypt( "Password", password ); | 533 | //conf->writeEntryCrypt( "Password", password ); |
535 | conf->writeEntry( "FolderHistory",getPasswordList() ); | 534 | conf->writeEntry( "FolderHistory",getPasswordList() ); |
536 | conf->writeEntry( "Subscribed" , subscribedGroups ); | 535 | conf->writeEntry( "Subscribed" , subscribedGroups ); |
537 | conf->sync(); | 536 | conf->sync(); |
538 | delete conf; | 537 | delete conf; |
539 | } | 538 | } |
540 | 539 | ||
541 | 540 | ||
542 | QString NNTPaccount::getFileName() | 541 | QString NNTPaccount::getFileName() |
543 | { | 542 | { |
544 | return locateLocal("data", "kopiemail" ) +"/nntp-" + file; | 543 | return locateLocal("data", "kopiemail" ) +"/nntp-" + file; |
545 | } | 544 | } |
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index df7d612..6a312b3 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp | |||
@@ -1,759 +1,759 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@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 | 19 | ||
20 | #include <qlabel.h> | 20 | #include <qlabel.h> |
21 | #include <qlayout.h> | 21 | #include <qlayout.h> |
22 | #include <qhbox.h> | 22 | #include <qhbox.h> |
23 | #include <qvbox.h> | 23 | #include <qvbox.h> |
24 | #include <qtooltip.h> | 24 | #include <qtooltip.h> |
25 | #include <qwhatsthis.h> | 25 | #include <qwhatsthis.h> |
26 | #include <qdragobject.h> | 26 | #include <qdragobject.h> |
27 | #include <qdrawutil.h> | 27 | #include <qdrawutil.h> |
28 | #include <qpainter.h> | 28 | #include <qpainter.h> |
29 | 29 | ||
30 | #include <kiconloader.h> | 30 | #include <kiconloader.h> |
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <kglobal.h> | 32 | #include <kglobal.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #ifndef DESKTOP_VERSION | 34 | #ifndef DESKTOP_VERSION |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #define AGENDA_ICON_SIZE 5 | 36 | #define AGENDA_ICON_SIZE 5 |
37 | #else | 37 | #else |
38 | #define AGENDA_ICON_SIZE 7 | 38 | #define AGENDA_ICON_SIZE 7 |
39 | #endif | 39 | #endif |
40 | #include <libkcal/icaldrag.h> | 40 | #include <libkcal/icaldrag.h> |
41 | #include <libkcal/vcaldrag.h> | 41 | #include <libkcal/vcaldrag.h> |
42 | #include <libkcal/kincidenceformatter.h> | 42 | #include <libkcal/kincidenceformatter.h> |
43 | extern int globalFlagBlockAgenda; | 43 | extern int globalFlagBlockAgenda; |
44 | extern int globalFlagBlockAgendaItemPaint; | 44 | extern int globalFlagBlockAgendaItemPaint; |
45 | extern int globalFlagBlockAgendaItemUpdate; | 45 | extern int globalFlagBlockAgendaItemUpdate; |
46 | 46 | ||
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | 48 | ||
49 | #include "koagendaitem.h" | 49 | #include "koagendaitem.h" |
50 | //#include "koagendaitem.moc" | 50 | //#include "koagendaitem.moc" |
51 | 51 | ||
52 | 52 | ||
53 | //-------------------------------------------------------------------------- | 53 | //-------------------------------------------------------------------------- |
54 | 54 | ||
55 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; | 55 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; |
56 | 56 | ||
57 | //-------------------------------------------------------------------------- | 57 | //-------------------------------------------------------------------------- |
58 | 58 | ||
59 | class KOAgendaItemWhatsThis :public QWhatsThis | 59 | class KOAgendaItemWhatsThis :public QWhatsThis |
60 | { | 60 | { |
61 | public: | 61 | public: |
62 | KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; | 62 | KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; |
63 | 63 | ||
64 | protected: | 64 | protected: |
65 | virtual QString text( const QPoint& ) | 65 | virtual QString text( const QPoint& ) |
66 | { | 66 | { |
67 | return _view->getWhatsThisText() ; | 67 | return _view->getWhatsThisText() ; |
68 | } | 68 | } |
69 | private: | 69 | private: |
70 | KOAgendaItem * _view; | 70 | KOAgendaItem * _view; |
71 | }; | 71 | }; |
72 | 72 | ||
73 | KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, | 73 | KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, |
74 | const char *name,WFlags) : | 74 | const char *name,WFlags) : |
75 | QWidget(parent, name), mIncidence(incidence), mDate(qd) | 75 | QWidget(parent, name), mIncidence(incidence), mDate(qd) |
76 | { | 76 | { |
77 | #ifndef DESKTOP_VERSION | 77 | #ifndef DESKTOP_VERSION |
78 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); | 78 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); |
79 | #endif | 79 | #endif |
80 | new KOAgendaItemWhatsThis(this); | 80 | new KOAgendaItemWhatsThis(this); |
81 | int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase | 81 | int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase |
82 | setWFlags ( wflags); | 82 | setWFlags ( wflags); |
83 | mAllDay = allday; | 83 | mAllDay = allday; |
84 | init ( incidence, qd ); | 84 | init ( incidence, qd ); |
85 | setMouseTracking(true); | 85 | setMouseTracking(true); |
86 | //setAcceptDrops(true); | 86 | //setAcceptDrops(true); |
87 | xPaintCoord = -1; | 87 | xPaintCoord = -1; |
88 | yPaintCoord = -1; | 88 | yPaintCoord = -1; |
89 | } | 89 | } |
90 | QString KOAgendaItem::getWhatsThisText() | 90 | QString KOAgendaItem::getWhatsThisText() |
91 | { | 91 | { |
92 | if ( mIncidence ) | 92 | if ( mIncidence ) |
93 | return KIncidenceFormatter::instance()->getFormattedText( mIncidence ); | 93 | return KIncidenceFormatter::instance()->getFormattedText( mIncidence ); |
94 | return "KOAgendaItem::getWhatsThisText()::internal error"; | 94 | return "KOAgendaItem::getWhatsThisText()::internal error"; |
95 | } | 95 | } |
96 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) | 96 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) |
97 | { | 97 | { |
98 | mIncidence = incidence; | 98 | mIncidence = incidence; |
99 | mDate = qd; | 99 | mDate = qd; |
100 | mFirstMultiItem = 0; | 100 | mFirstMultiItem = 0; |
101 | mNextMultiItem = 0; | 101 | mNextMultiItem = 0; |
102 | mLastMultiItem = 0; | 102 | mLastMultiItem = 0; |
103 | computeText(); | 103 | computeText(); |
104 | 104 | ||
105 | if ( (incidence->type() == "Todo") && | 105 | if ( (incidence->type() == "Todo") && |
106 | ( !((static_cast<Todo*>(incidence))->isCompleted()) && | 106 | ( !((static_cast<Todo*>(incidence))->isCompleted()) && |
107 | ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { | 107 | ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { |
108 | if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) | 108 | if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) |
109 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; | 109 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; |
110 | else | 110 | else |
111 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; | 111 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; |
112 | } | 112 | } |
113 | else { | 113 | else { |
114 | QStringList categories = mIncidence->categories(); | 114 | QStringList categories = mIncidence->categories(); |
115 | QString cat = categories.first(); | 115 | QString cat = categories.first(); |
116 | if (cat.isEmpty()) { | 116 | if (cat.isEmpty()) { |
117 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) | 117 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) |
118 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; | 118 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; |
119 | else | 119 | else |
120 | mBackgroundColor =KOPrefs::instance()->mEventColor; | 120 | mBackgroundColor =KOPrefs::instance()->mEventColor; |
121 | } else { | 121 | } else { |
122 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); | 122 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); |
123 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) { | 123 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) { |
124 | if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) | 124 | if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) |
125 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; | 125 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; |
126 | } | 126 | } |
127 | } | 127 | } |
128 | 128 | ||
129 | } | 129 | } |
130 | mColorGroup = QColorGroup( mBackgroundColor.light(), | 130 | mColorGroup = QColorGroup( mBackgroundColor.light(), |
131 | mBackgroundColor.dark(),mBackgroundColor.light(), | 131 | mBackgroundColor.dark(),mBackgroundColor.light(), |
132 | mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; | 132 | mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; |
133 | setBackgroundColor( mBackgroundColor ); | 133 | setBackgroundColor( mBackgroundColor ); |
134 | 134 | ||
135 | setCellXY(0,0,1); | 135 | setCellXY(0,0,1); |
136 | setCellXWidth(0); | 136 | setCellXWidth(0); |
137 | setSubCell(0); | 137 | setSubCell(0); |
138 | setSubCells(1); | 138 | setSubCells(1); |
139 | setMultiItem(0,0,0); | 139 | setMultiItem(0,0,0); |
140 | startMove(); | 140 | startMove(); |
141 | mSelected = true; | 141 | mSelected = true; |
142 | select(false); | 142 | select(false); |
143 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); | 143 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); |
144 | mFontPixelSize = fontinf.height();; | 144 | mFontPixelSize = fontinf.height();; |
145 | hide(); | 145 | hide(); |
146 | xPaintCoord = -1; | 146 | xPaintCoord = -1; |
147 | yPaintCoord = -1; | 147 | yPaintCoord = -1; |
148 | } | 148 | } |
149 | 149 | ||
150 | 150 | ||
151 | KOAgendaItem::~KOAgendaItem() | 151 | KOAgendaItem::~KOAgendaItem() |
152 | { | 152 | { |
153 | // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); | 153 | // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); |
154 | 154 | ||
155 | } | 155 | } |
156 | 156 | ||
157 | void KOAgendaItem::recreateIncidence() | 157 | void KOAgendaItem::recreateIncidence() |
158 | { | 158 | { |
159 | #if 0 | 159 | #if 0 |
160 | Incidence* newInc = mIncidence->clone(); | 160 | Incidence* newInc = mIncidence->clone(); |
161 | newInc->recreate(); | 161 | newInc->recreate(); |
162 | if ( mIncidence->doesRecur() ) { | 162 | if ( mIncidence->doesRecur() ) { |
163 | mIncidence->addExDate( mDate ); | 163 | mIncidence->addExDate( mDate ); |
164 | newInc->recurrence()->unsetRecurs(); | 164 | newInc->recurrence()->unsetRecurs(); |
165 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); | 165 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); |
166 | QTime tim = mIncidence->dtStart().time(); | 166 | QTime tim = mIncidence->dtStart().time(); |
167 | newInc->setDtStart( QDateTime(mDate, tim) ); | 167 | newInc->setDtStart( QDateTime(mDate, tim) ); |
168 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | 168 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); |
169 | } | 169 | } |
170 | #endif | 170 | #endif |
171 | mIncidence = mIncidence->recreateCloneException( mDate ); | 171 | mIncidence = mIncidence->recreateCloneException( mDate ); |
172 | } | 172 | } |
173 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) | 173 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) |
174 | { | 174 | { |
175 | int size = AGENDA_ICON_SIZE; | 175 | int size = AGENDA_ICON_SIZE; |
176 | 176 | ||
177 | int yOff = 0; | 177 | int yOff = 0; |
178 | int xOff = 0; | 178 | int xOff = 0; |
179 | int x = pos().x() +3; | 179 | int x = pos().x() +3; |
180 | int y; | 180 | int y; |
181 | if ( mAllDay ) | 181 | if ( mAllDay ) |
182 | y = pos().y()+3; | 182 | y = pos().y()+3; |
183 | else | 183 | else |
184 | y = mCellYTop * ( height() / cellHeight() ) +3; | 184 | y = mCellYTop * ( height() / cellHeight() ) +3; |
185 | if (mIncidence->cancelled()) { | 185 | if (mIncidence->cancelled()) { |
186 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; | 186 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; |
187 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; | 187 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; |
188 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); | 188 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); |
189 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); | 189 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); |
190 | if ( horLayout ) | 190 | if ( horLayout ) |
191 | ++xOff; | 191 | ++xOff; |
192 | else | 192 | else |
193 | ++yOff; | 193 | ++yOff; |
194 | } | 194 | } |
195 | if (mIncidence->isAlarmEnabled()) { | 195 | if (mIncidence->isAlarmEnabled()) { |
196 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); | 196 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); |
197 | if ( horLayout ) | 197 | if ( horLayout ) |
198 | ++xOff; | 198 | ++xOff; |
199 | else | 199 | else |
200 | ++yOff; | 200 | ++yOff; |
201 | } | 201 | } |
202 | if (mIncidence->recurrence()->doesRecur()) { | 202 | if (mIncidence->recurrence()->doesRecur()) { |
203 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); | 203 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); |
204 | if ( horLayout ) | 204 | if ( horLayout ) |
205 | ++xOff; | 205 | ++xOff; |
206 | else | 206 | else |
207 | ++yOff; | 207 | ++yOff; |
208 | } | 208 | } |
209 | if (mIncidence->description().length() > 0) { | 209 | if (mIncidence->description().length() > 0) { |
210 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); | 210 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); |
211 | if ( horLayout ) | 211 | if ( horLayout ) |
212 | ++xOff; | 212 | ++xOff; |
213 | else | 213 | else |
214 | ++yOff; | 214 | ++yOff; |
215 | } | 215 | } |
216 | if (mIncidence->isReadOnly()) { | 216 | if (mIncidence->isReadOnly()) { |
217 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); | 217 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); |
218 | if ( horLayout ) | 218 | if ( horLayout ) |
219 | ++xOff; | 219 | ++xOff; |
220 | else | 220 | else |
221 | ++yOff; | 221 | ++yOff; |
222 | } | 222 | } |
223 | 223 | ||
224 | if (mIncidence->attendeeCount()>0) { | 224 | if (mIncidence->attendeeCount()>0) { |
225 | 225 | ||
226 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { | 226 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { |
227 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); | 227 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); |
228 | if ( horLayout ) | 228 | if ( horLayout ) |
229 | ++xOff; | 229 | ++xOff; |
230 | else | 230 | else |
231 | ++yOff; | 231 | ++yOff; |
232 | } else { | 232 | } else { |
233 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 233 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
234 | if (me!=0) { | 234 | if (me!=0) { |
235 | 235 | ||
236 | 236 | ||
237 | } else { | 237 | } else { |
238 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); | 238 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); |
239 | if ( horLayout ) | 239 | if ( horLayout ) |
240 | ++xOff; | 240 | ++xOff; |
241 | else | 241 | else |
242 | ++yOff; | 242 | ++yOff; |
243 | 243 | ||
244 | } | 244 | } |
245 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); | 245 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); |
246 | if ( horLayout ) | 246 | if ( horLayout ) |
247 | ++xOff; | 247 | ++xOff; |
248 | else | 248 | else |
249 | ++yOff; | 249 | ++yOff; |
250 | 250 | ||
251 | } | 251 | } |
252 | 252 | ||
253 | } | 253 | } |
254 | return ( yOff || xOff ); | 254 | return ( yOff || xOff ); |
255 | } | 255 | } |
256 | 256 | ||
257 | 257 | ||
258 | void KOAgendaItem::select(bool selected) | 258 | void KOAgendaItem::select(bool selected) |
259 | { | 259 | { |
260 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); | 260 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); |
261 | if (mSelected == selected) return; | 261 | if (mSelected == selected) return; |
262 | mSelected = selected; | 262 | mSelected = selected; |
263 | if ( ! isVisible() ) | 263 | if ( ! isVisible() ) |
264 | return; | 264 | return; |
265 | if ( firstMultiItem() ) | 265 | if ( firstMultiItem() ) |
266 | firstMultiItem()->select( selected ); | 266 | firstMultiItem()->select( selected ); |
267 | if ( !firstMultiItem() && nextMultiItem() ) { | 267 | if ( !firstMultiItem() && nextMultiItem() ) { |
268 | KOAgendaItem * placeItem = nextMultiItem(); | 268 | KOAgendaItem * placeItem = nextMultiItem(); |
269 | while ( placeItem ) { | 269 | while ( placeItem ) { |
270 | placeItem->select( selected ); | 270 | placeItem->select( selected ); |
271 | placeItem = placeItem->nextMultiItem(); | 271 | placeItem = placeItem->nextMultiItem(); |
272 | } | 272 | } |
273 | } | 273 | } |
274 | globalFlagBlockAgendaItemUpdate = 0; | 274 | globalFlagBlockAgendaItemUpdate = 0; |
275 | paintMe( selected ); | 275 | paintMe( selected ); |
276 | globalFlagBlockAgendaItemUpdate = 1; | 276 | globalFlagBlockAgendaItemUpdate = 1; |
277 | repaint( false ); | 277 | repaint( false ); |
278 | } | 278 | } |
279 | 279 | ||
280 | 280 | ||
281 | /* | 281 | /* |
282 | The eventFilter has to filter the mouse events of the agenda item childs. The | 282 | The eventFilter has to filter the mouse events of the agenda item childs. The |
283 | events are fed into the event handling method of KOAgendaItem. This allows the | 283 | events are fed into the event handling method of KOAgendaItem. This allows the |
284 | KOAgenda to handle the KOAgendaItems by using an eventFilter. | 284 | KOAgenda to handle the KOAgendaItems by using an eventFilter. |
285 | */ | 285 | */ |
286 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) | 286 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) |
287 | { | 287 | { |
288 | if (e->type() == QEvent::MouseButtonPress || | 288 | if (e->type() == QEvent::MouseButtonPress || |
289 | e->type() == QEvent::MouseButtonDblClick || | 289 | e->type() == QEvent::MouseButtonDblClick || |
290 | e->type() == QEvent::MouseButtonRelease || | 290 | e->type() == QEvent::MouseButtonRelease || |
291 | e->type() == QEvent::MouseMove) { | 291 | e->type() == QEvent::MouseMove) { |
292 | QMouseEvent *me = (QMouseEvent *)e; | 292 | QMouseEvent *me = (QMouseEvent *)e; |
293 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> | 293 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> |
294 | mapToGlobal(me->pos())); | 294 | mapToGlobal(me->pos())); |
295 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); | 295 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); |
296 | return event(&returnEvent); | 296 | return event(&returnEvent); |
297 | } else { | 297 | } else { |
298 | return false; | 298 | return false; |
299 | } | 299 | } |
300 | } | 300 | } |
301 | void KOAgendaItem::repaintMe( ) | 301 | void KOAgendaItem::repaintMe( ) |
302 | { | 302 | { |
303 | paintMe ( mSelected ); | 303 | paintMe ( mSelected ); |
304 | } | 304 | } |
305 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) | 305 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) |
306 | { | 306 | { |
307 | if ( globalFlagBlockAgendaItemUpdate && ! selected) | 307 | if ( globalFlagBlockAgendaItemUpdate && ! selected) |
308 | return; | 308 | return; |
309 | QPainter pa; | 309 | QPainter pa; |
310 | 310 | ||
311 | if ( mSelected ) { | 311 | if ( mSelected ) { |
312 | pa.begin( paintPixSel() ); | 312 | pa.begin( paintPixSel() ); |
313 | } else { | 313 | } else { |
314 | if ( mAllDay ) | 314 | if ( mAllDay ) |
315 | pa.begin( paintPixAllday() ); | 315 | pa.begin( paintPixAllday() ); |
316 | else | 316 | else |
317 | pa.begin( paintPix() ); | 317 | pa.begin( paintPix() ); |
318 | } | 318 | } |
319 | int x, yy, w, h; | 319 | int x, yy, w, h; |
320 | float nfh; | 320 | float nfh = 7.0; |
321 | x = pos().x(); w = width(); h = height (); | 321 | x = pos().x(); w = width(); h = height (); |
322 | if ( mAllDay ) | 322 | if ( mAllDay ) |
323 | yy = y(); | 323 | yy = y(); |
324 | else | 324 | else |
325 | yy = mCellYTop * ( height() / cellHeight() ); | 325 | yy = mCellYTop * ( height() / cellHeight() ); |
326 | xPaintCoord= x; | 326 | xPaintCoord= x; |
327 | yPaintCoord = yy; | 327 | yPaintCoord = yy; |
328 | wPaintCoord = width(); | 328 | wPaintCoord = width(); |
329 | hPaintCoord = height(); | 329 | hPaintCoord = height(); |
330 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); | 330 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); |
331 | if ( paint == 0 ) | 331 | if ( paint == 0 ) |
332 | paint = &pa; | 332 | paint = &pa; |
333 | bool horLayout = ( w < h ); | 333 | bool horLayout = ( w < h ); |
334 | int maxhei = mFontPixelSize+4; | 334 | int maxhei = mFontPixelSize+4; |
335 | if ( horLayout ) | 335 | if ( horLayout ) |
336 | maxhei += AGENDA_ICON_SIZE -4; | 336 | maxhei += AGENDA_ICON_SIZE -4; |
337 | bool small = ( h < maxhei ); | 337 | bool small = ( h < maxhei ); |
338 | if ( ! small ) | 338 | if ( ! small ) |
339 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); | 339 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); |
340 | else { | 340 | else { |
341 | QFont f = KOPrefs::instance()->mAgendaViewFont; | 341 | QFont f = KOPrefs::instance()->mAgendaViewFont; |
342 | f.setBold( false ); | 342 | f.setBold( false ); |
343 | int fh = f.pointSize(); | 343 | int fh = f.pointSize(); |
344 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; | 344 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; |
345 | if ( nfh < 6 ) | 345 | if ( nfh < 6 ) |
346 | nfh = 6; | 346 | nfh = 6; |
347 | f.setPointSize( nfh ); | 347 | f.setPointSize( nfh ); |
348 | paint->setFont(f); | 348 | paint->setFont(f); |
349 | } | 349 | } |
350 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); | 350 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); |
351 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); | 351 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); |
352 | static const QPixmap overduePxmp = SmallIcon("redcross16"); | 352 | static const QPixmap overduePxmp = SmallIcon("redcross16"); |
353 | if ( mIncidence->type() == "Todo" ) { | 353 | if ( mIncidence->type() == "Todo" ) { |
354 | Todo* tempTodo = static_cast<Todo*>(mIncidence); | 354 | Todo* tempTodo = static_cast<Todo*>(mIncidence); |
355 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); | 355 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); |
356 | int yyy = yy+3; | 356 | int yyy = yy+3; |
357 | if ( tempTodo->isCompleted() ) | 357 | if ( tempTodo->isCompleted() ) |
358 | paint->drawPixmap ( xx, yyy, completedPxmp ); | 358 | paint->drawPixmap ( xx, yyy, completedPxmp ); |
359 | else { | 359 | else { |
360 | paint->drawPixmap ( xx, yyy, overduePxmp ); | 360 | paint->drawPixmap ( xx, yyy, overduePxmp ); |
361 | 361 | ||
362 | } | 362 | } |
363 | } | 363 | } |
364 | bool addIcon = false; | 364 | bool addIcon = false; |
365 | if ( ! small || w > 3 * h || h > 3* w ) | 365 | if ( ! small || w > 3 * h || h > 3* w ) |
366 | addIcon = updateIcons( paint, horLayout ); | 366 | addIcon = updateIcons( paint, horLayout ); |
367 | 367 | ||
368 | qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); | 368 | qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); |
369 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); | 369 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); |
370 | if ( ! small ) { | 370 | if ( ! small ) { |
371 | x += 3; yy += 3;w -= 6; h-= 5; | 371 | x += 3; yy += 3;w -= 6; h-= 5; |
372 | } else { | 372 | } else { |
373 | x += 2; yy += 1;w -= 4; h-= 4; | 373 | x += 2; yy += 1;w -= 4; h-= 4; |
374 | if ( nfh < 6.01 ) { | 374 | if ( nfh < 6.01 ) { |
375 | yy -= 2; | 375 | yy -= 2; |
376 | h += 4; | 376 | h += 4; |
377 | } | 377 | } |
378 | else | 378 | else |
379 | if ( nfh < h -2 ) | 379 | if ( nfh < h -2 ) |
380 | ++yy; | 380 | ++yy; |
381 | } | 381 | } |
382 | int align; | 382 | int align; |
383 | #ifndef DESKTOP_VERSION | 383 | #ifndef DESKTOP_VERSION |
384 | align = ( AlignLeft|WordBreak|AlignTop); | 384 | align = ( AlignLeft|WordBreak|AlignTop); |
385 | #else | 385 | #else |
386 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); | 386 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); |
387 | #endif | 387 | #endif |
388 | if ( addIcon ) { | 388 | if ( addIcon ) { |
389 | if ( ! horLayout ) { | 389 | if ( ! horLayout ) { |
390 | x += AGENDA_ICON_SIZE+3; | 390 | x += AGENDA_ICON_SIZE+3; |
391 | w -= (AGENDA_ICON_SIZE+3); | 391 | w -= (AGENDA_ICON_SIZE+3); |
392 | } | 392 | } |
393 | else { | 393 | else { |
394 | yy+= AGENDA_ICON_SIZE+2; | 394 | yy+= AGENDA_ICON_SIZE+2; |
395 | h -=(AGENDA_ICON_SIZE+3); | 395 | h -=(AGENDA_ICON_SIZE+3); |
396 | } | 396 | } |
397 | } | 397 | } |
398 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); | 398 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); |
399 | if ( colsum < 250 ) | 399 | if ( colsum < 250 ) |
400 | paint->setPen ( white); | 400 | paint->setPen ( white); |
401 | if ( x < 0 ) { | 401 | if ( x < 0 ) { |
402 | w = w+x-3; | 402 | w = w+x-3; |
403 | x = 3; | 403 | x = 3; |
404 | if ( w > parentWidget()->width() ){ | 404 | if ( w > parentWidget()->width() ){ |
405 | w = parentWidget()->width() - 6; | 405 | w = parentWidget()->width() - 6; |
406 | #ifndef DESKTOP_VERSION | 406 | #ifndef DESKTOP_VERSION |
407 | align = ( AlignCenter|WordBreak); | 407 | align = ( AlignCenter|WordBreak); |
408 | #else | 408 | #else |
409 | align = ( AlignCenter|BreakAnywhere|WordBreak); | 409 | align = ( AlignCenter|BreakAnywhere|WordBreak); |
410 | #endif | 410 | #endif |
411 | 411 | ||
412 | } | 412 | } |
413 | } | 413 | } |
414 | QRect dr; | 414 | QRect dr; |
415 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); | 415 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); |
416 | if ( mIncidence->cancelled() ){ | 416 | if ( mIncidence->cancelled() ){ |
417 | if ( ! small ) { | 417 | if ( ! small ) { |
418 | QFontMetrics fm ( paint->font() ); | 418 | QFontMetrics fm ( paint->font() ); |
419 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); | 419 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); |
420 | } | 420 | } |
421 | 421 | ||
422 | } | 422 | } |
423 | pa.end(); | 423 | pa.end(); |
424 | 424 | ||
425 | } | 425 | } |
426 | void KOAgendaItem::resizePixmap( int w , int h ) | 426 | void KOAgendaItem::resizePixmap( int w , int h ) |
427 | { | 427 | { |
428 | paintPix()->resize( w, h ); | 428 | paintPix()->resize( w, h ); |
429 | paintPixSel()->resize( w, h ); | 429 | paintPixSel()->resize( w, h ); |
430 | 430 | ||
431 | } | 431 | } |
432 | QPixmap * KOAgendaItem::paintPix() | 432 | QPixmap * KOAgendaItem::paintPix() |
433 | { | 433 | { |
434 | static QPixmap* mPaintPix = 0; | 434 | static QPixmap* mPaintPix = 0; |
435 | if ( ! mPaintPix ) | 435 | if ( ! mPaintPix ) |
436 | mPaintPix = new QPixmap(1,1); | 436 | mPaintPix = new QPixmap(1,1); |
437 | return mPaintPix ; | 437 | return mPaintPix ; |
438 | } | 438 | } |
439 | QPixmap * KOAgendaItem::paintPixAllday() | 439 | QPixmap * KOAgendaItem::paintPixAllday() |
440 | { | 440 | { |
441 | static QPixmap* mPaintPixA = 0; | 441 | static QPixmap* mPaintPixA = 0; |
442 | if ( ! mPaintPixA ) | 442 | if ( ! mPaintPixA ) |
443 | mPaintPixA = new QPixmap(1,1); | 443 | mPaintPixA = new QPixmap(1,1); |
444 | return mPaintPixA ; | 444 | return mPaintPixA ; |
445 | } | 445 | } |
446 | QPixmap * KOAgendaItem::paintPixSel() | 446 | QPixmap * KOAgendaItem::paintPixSel() |
447 | { | 447 | { |
448 | static QPixmap* mPaintPixSel = 0; | 448 | static QPixmap* mPaintPixSel = 0; |
449 | if ( ! mPaintPixSel ) | 449 | if ( ! mPaintPixSel ) |
450 | mPaintPixSel = new QPixmap(1,1); | 450 | mPaintPixSel = new QPixmap(1,1); |
451 | return mPaintPixSel ; | 451 | return mPaintPixSel ; |
452 | } | 452 | } |
453 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) | 453 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) |
454 | { | 454 | { |
455 | 455 | ||
456 | if ( globalFlagBlockAgendaItemPaint ) | 456 | if ( globalFlagBlockAgendaItemPaint ) |
457 | return; | 457 | return; |
458 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) | 458 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) |
459 | return; | 459 | return; |
460 | int yy; | 460 | int yy; |
461 | if ( mAllDay ) | 461 | if ( mAllDay ) |
462 | yy = y(); | 462 | yy = y(); |
463 | else | 463 | else |
464 | yy = mCellYTop * ( height() / cellHeight() ); | 464 | yy = mCellYTop * ( height() / cellHeight() ); |
465 | int xx = x(); | 465 | int xx = x(); |
466 | if ( xPaintCoord != xx || yPaintCoord != yy || | 466 | if ( xPaintCoord != xx || yPaintCoord != yy || |
467 | wPaintCoord != width() || hPaintCoord != height()) { | 467 | wPaintCoord != width() || hPaintCoord != height()) { |
468 | xPaintCoord= xx; | 468 | xPaintCoord= xx; |
469 | yPaintCoord = yy; | 469 | yPaintCoord = yy; |
470 | wPaintCoord = width(); | 470 | wPaintCoord = width(); |
471 | hPaintCoord = height(); | 471 | hPaintCoord = height(); |
472 | globalFlagBlockAgendaItemUpdate = 0; | 472 | globalFlagBlockAgendaItemUpdate = 0; |
473 | paintMe( mSelected ); | 473 | paintMe( mSelected ); |
474 | //qDebug("calling paintMe "); | 474 | //qDebug("calling paintMe "); |
475 | globalFlagBlockAgendaItemUpdate = 1; | 475 | globalFlagBlockAgendaItemUpdate = 1; |
476 | } | 476 | } |
477 | int rx, ry, rw, rh; | 477 | int rx, ry, rw, rh; |
478 | rx = e->rect().x(); | 478 | rx = e->rect().x(); |
479 | ry = e->rect().y(); | 479 | ry = e->rect().y(); |
480 | rw = e->rect().width(); | 480 | rw = e->rect().width(); |
481 | rh = e->rect().height(); | 481 | rh = e->rect().height(); |
482 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); | 482 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); |
483 | 483 | ||
484 | QPixmap* paintFrom ; | 484 | QPixmap* paintFrom ; |
485 | if ( mSelected ) { | 485 | if ( mSelected ) { |
486 | paintFrom = paintPixSel(); | 486 | paintFrom = paintPixSel(); |
487 | } else { | 487 | } else { |
488 | if ( mAllDay ) | 488 | if ( mAllDay ) |
489 | paintFrom = paintPixAllday(); | 489 | paintFrom = paintPixAllday(); |
490 | else | 490 | else |
491 | paintFrom = paintPix(); | 491 | paintFrom = paintPix(); |
492 | } | 492 | } |
493 | bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP); | 493 | bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP); |
494 | } | 494 | } |
495 | void KOAgendaItem::computeText() | 495 | void KOAgendaItem::computeText() |
496 | { | 496 | { |
497 | 497 | ||
498 | mDisplayedText = mIncidence->summary(); | 498 | mDisplayedText = mIncidence->summary(); |
499 | if ( (mIncidence->type() == "Todo") ) { | 499 | if ( (mIncidence->type() == "Todo") ) { |
500 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { | 500 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { |
501 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) | 501 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) |
502 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; | 502 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; |
503 | else if ( !(mIncidence->doesFloat())) | 503 | else if ( !(mIncidence->doesFloat())) |
504 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; | 504 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; |
505 | } | 505 | } |
506 | } else { | 506 | } else { |
507 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) | 507 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) |
508 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; | 508 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; |
509 | 509 | ||
510 | if ( mAllDay ) { | 510 | if ( mAllDay ) { |
511 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { | 511 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { |
512 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; | 512 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; |
513 | } | 513 | } |
514 | } | 514 | } |
515 | 515 | ||
516 | } | 516 | } |
517 | 517 | ||
518 | if ( !mIncidence->location().isEmpty() ) { | 518 | if ( !mIncidence->location().isEmpty() ) { |
519 | if ( mAllDay ) | 519 | if ( mAllDay ) |
520 | mDisplayedText += " ("; | 520 | mDisplayedText += " ("; |
521 | else | 521 | else |
522 | mDisplayedText += "\n("; | 522 | mDisplayedText += "\n("; |
523 | mDisplayedText += mIncidence->location() +")"; | 523 | mDisplayedText += mIncidence->location() +")"; |
524 | } | 524 | } |
525 | 525 | ||
526 | QString tipText = mIncidence->summary(); | 526 | QString tipText = mIncidence->summary(); |
527 | if ( !mIncidence->doesFloat() ) { | 527 | if ( !mIncidence->doesFloat() ) { |
528 | if ( mIncidence->type() == "Event" ) { | 528 | if ( mIncidence->type() == "Event" ) { |
529 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { | 529 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { |
530 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); | 530 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); |
531 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); | 531 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); |
532 | } | 532 | } |
533 | else { | 533 | else { |
534 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); | 534 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); |
535 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); | 535 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); |
536 | } | 536 | } |
537 | } | 537 | } |
538 | else if ( mIncidence->type() == "Todo" ) { | 538 | else if ( mIncidence->type() == "Todo" ) { |
539 | if (mIncidence->hasStartDate()) | 539 | if (mIncidence->hasStartDate()) |
540 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); | 540 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); |
541 | if (((Todo*)mIncidence)->hasDueDate()) | 541 | if (((Todo*)mIncidence)->hasDueDate()) |
542 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); | 542 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); |
543 | } | 543 | } |
544 | } else if ( mIncidence->type() == "Todo" ) { | 544 | } else if ( mIncidence->type() == "Todo" ) { |
545 | if (mIncidence->hasStartDate()) | 545 | if (mIncidence->hasStartDate()) |
546 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); | 546 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); |
547 | if (((Todo*)mIncidence)->hasDueDate()) | 547 | if (((Todo*)mIncidence)->hasDueDate()) |
548 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); | 548 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); |
549 | } | 549 | } |
550 | 550 | ||
551 | if (!mIncidence->location().isEmpty()) { | 551 | if (!mIncidence->location().isEmpty()) { |
552 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); | 552 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); |
553 | } | 553 | } |
554 | QToolTip::add(this,tipText,toolTipGroup(),""); | 554 | QToolTip::add(this,tipText,toolTipGroup(),""); |
555 | 555 | ||
556 | } | 556 | } |
557 | void KOAgendaItem::updateItem() | 557 | void KOAgendaItem::updateItem() |
558 | { | 558 | { |
559 | computeText(); | 559 | computeText(); |
560 | 560 | ||
561 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); | 561 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); |
562 | paintMe( mSelected ); | 562 | paintMe( mSelected ); |
563 | repaint( false); | 563 | repaint( false); |
564 | } | 564 | } |
565 | 565 | ||
566 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) | 566 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) |
567 | { | 567 | { |
568 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); | 568 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); |
569 | paintMe( mSelected ); | 569 | paintMe( mSelected ); |
570 | repaint( false ); | 570 | repaint( false ); |
571 | } | 571 | } |
572 | 572 | ||
573 | /* | 573 | /* |
574 | Return height of item in units of agenda cells | 574 | Return height of item in units of agenda cells |
575 | */ | 575 | */ |
576 | int KOAgendaItem::cellHeight() | 576 | int KOAgendaItem::cellHeight() |
577 | { | 577 | { |
578 | int ret = mCellYBottom - mCellYTop + 1; | 578 | int ret = mCellYBottom - mCellYTop + 1; |
579 | if ( ret <= 0 ) { | 579 | if ( ret <= 0 ) { |
580 | ret = 1; | 580 | ret = 1; |
581 | mCellYBottom = 0; | 581 | mCellYBottom = 0; |
582 | mCellYTop = 0; | 582 | mCellYTop = 0; |
583 | } | 583 | } |
584 | return ret; | 584 | return ret; |
585 | } | 585 | } |
586 | 586 | ||
587 | /* | 587 | /* |
588 | Return height of item in units of agenda cells | 588 | Return height of item in units of agenda cells |
589 | */ | 589 | */ |
590 | int KOAgendaItem::cellWidth() | 590 | int KOAgendaItem::cellWidth() |
591 | { | 591 | { |
592 | return mCellXWidth - mCellX + 1; | 592 | return mCellXWidth - mCellX + 1; |
593 | } | 593 | } |
594 | 594 | ||
595 | void KOAgendaItem::setItemDate(QDate qd) | 595 | void KOAgendaItem::setItemDate(QDate qd) |
596 | { | 596 | { |
597 | mDate = qd; | 597 | mDate = qd; |
598 | } | 598 | } |
599 | 599 | ||
600 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) | 600 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) |
601 | { | 601 | { |
602 | mCellX = X; | 602 | mCellX = X; |
603 | mCellYTop = YTop; | 603 | mCellYTop = YTop; |
604 | mCellYBottom = YBottom; | 604 | mCellYBottom = YBottom; |
605 | } | 605 | } |
606 | 606 | ||
607 | void KOAgendaItem::setCellXWidth(int xwidth) | 607 | void KOAgendaItem::setCellXWidth(int xwidth) |
608 | { | 608 | { |
609 | mCellXWidth = xwidth; | 609 | mCellXWidth = xwidth; |
610 | } | 610 | } |
611 | 611 | ||
612 | void KOAgendaItem::setCellX(int XLeft, int XRight) | 612 | void KOAgendaItem::setCellX(int XLeft, int XRight) |
613 | { | 613 | { |
614 | mCellX = XLeft; | 614 | mCellX = XLeft; |
615 | mCellXWidth = XRight; | 615 | mCellXWidth = XRight; |
616 | } | 616 | } |
617 | 617 | ||
618 | void KOAgendaItem::setCellY(int YTop, int YBottom) | 618 | void KOAgendaItem::setCellY(int YTop, int YBottom) |
619 | { | 619 | { |
620 | mCellYTop = YTop; | 620 | mCellYTop = YTop; |
621 | mCellYBottom = YBottom; | 621 | mCellYBottom = YBottom; |
622 | } | 622 | } |
623 | 623 | ||
624 | void KOAgendaItem::setSubCell(int subCell) | 624 | void KOAgendaItem::setSubCell(int subCell) |
625 | { | 625 | { |
626 | mSubCell = subCell; | 626 | mSubCell = subCell; |
627 | } | 627 | } |
628 | 628 | ||
629 | void KOAgendaItem::setSubCells(int subCells) | 629 | void KOAgendaItem::setSubCells(int subCells) |
630 | { | 630 | { |
631 | mSubCells = subCells; | 631 | mSubCells = subCells; |
632 | } | 632 | } |
633 | 633 | ||
634 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, | 634 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, |
635 | KOAgendaItem *last) | 635 | KOAgendaItem *last) |
636 | { | 636 | { |
637 | mFirstMultiItem = first; | 637 | mFirstMultiItem = first; |
638 | mNextMultiItem = next; | 638 | mNextMultiItem = next; |
639 | mLastMultiItem = last; | 639 | mLastMultiItem = last; |
640 | } | 640 | } |
641 | 641 | ||
642 | void KOAgendaItem::startMove() | 642 | void KOAgendaItem::startMove() |
643 | { | 643 | { |
644 | mStartCellX = mCellX; | 644 | mStartCellX = mCellX; |
645 | mStartCellXWidth = mCellXWidth; | 645 | mStartCellXWidth = mCellXWidth; |
646 | mStartCellYTop = mCellYTop; | 646 | mStartCellYTop = mCellYTop; |
647 | mStartCellYBottom = mCellYBottom; | 647 | mStartCellYBottom = mCellYBottom; |
648 | } | 648 | } |
649 | 649 | ||
650 | void KOAgendaItem::resetMove() | 650 | void KOAgendaItem::resetMove() |
651 | { | 651 | { |
652 | mCellX = mStartCellX; | 652 | mCellX = mStartCellX; |
653 | mCellXWidth = mStartCellXWidth; | 653 | mCellXWidth = mStartCellXWidth; |
654 | mCellYTop = mStartCellYTop; | 654 | mCellYTop = mStartCellYTop; |
655 | mCellYBottom = mStartCellYBottom; | 655 | mCellYBottom = mStartCellYBottom; |
656 | } | 656 | } |
657 | 657 | ||
658 | void KOAgendaItem::moveRelative(int dx, int dy) | 658 | void KOAgendaItem::moveRelative(int dx, int dy) |
659 | { | 659 | { |
660 | int newX = cellX() + dx; | 660 | int newX = cellX() + dx; |
661 | int newXWidth = cellXWidth() + dx; | 661 | int newXWidth = cellXWidth() + dx; |
662 | int newYTop = cellYTop() + dy; | 662 | int newYTop = cellYTop() + dy; |
663 | int newYBottom = cellYBottom() + dy; | 663 | int newYBottom = cellYBottom() + dy; |
664 | setCellXY(newX,newYTop,newYBottom); | 664 | setCellXY(newX,newYTop,newYBottom); |
665 | setCellXWidth(newXWidth); | 665 | setCellXWidth(newXWidth); |
666 | } | 666 | } |
667 | 667 | ||
668 | void KOAgendaItem::expandTop(int dy) | 668 | void KOAgendaItem::expandTop(int dy) |
669 | { | 669 | { |
670 | int newYTop = cellYTop() + dy; | 670 | int newYTop = cellYTop() + dy; |
671 | int newYBottom = cellYBottom(); | 671 | int newYBottom = cellYBottom(); |
672 | if (newYTop > newYBottom) newYTop = newYBottom; | 672 | if (newYTop > newYBottom) newYTop = newYBottom; |
673 | setCellY(newYTop, newYBottom); | 673 | setCellY(newYTop, newYBottom); |
674 | } | 674 | } |
675 | 675 | ||
676 | void KOAgendaItem::expandBottom(int dy) | 676 | void KOAgendaItem::expandBottom(int dy) |
677 | { | 677 | { |
678 | int newYTop = cellYTop(); | 678 | int newYTop = cellYTop(); |
679 | int newYBottom = cellYBottom() + dy; | 679 | int newYBottom = cellYBottom() + dy; |
680 | if (newYBottom < newYTop) newYBottom = newYTop; | 680 | if (newYBottom < newYTop) newYBottom = newYTop; |
681 | setCellY(newYTop, newYBottom); | 681 | setCellY(newYTop, newYBottom); |
682 | } | 682 | } |
683 | 683 | ||
684 | void KOAgendaItem::expandLeft(int dx) | 684 | void KOAgendaItem::expandLeft(int dx) |
685 | { | 685 | { |
686 | int newX = cellX() + dx; | 686 | int newX = cellX() + dx; |
687 | int newXWidth = cellXWidth(); | 687 | int newXWidth = cellXWidth(); |
688 | if (newX > newXWidth) newX = newXWidth; | 688 | if (newX > newXWidth) newX = newXWidth; |
689 | setCellX(newX,newXWidth); | 689 | setCellX(newX,newXWidth); |
690 | } | 690 | } |
691 | 691 | ||
692 | void KOAgendaItem::expandRight(int dx) | 692 | void KOAgendaItem::expandRight(int dx) |
693 | { | 693 | { |
694 | int newX = cellX(); | 694 | int newX = cellX(); |
695 | int newXWidth = cellXWidth() + dx; | 695 | int newXWidth = cellXWidth() + dx; |
696 | if (newXWidth < newX) newXWidth = newX; | 696 | if (newXWidth < newX) newXWidth = newX; |
697 | setCellX(newX,newXWidth); | 697 | setCellX(newX,newXWidth); |
698 | } | 698 | } |
699 | 699 | ||
700 | QToolTipGroup *KOAgendaItem::toolTipGroup() | 700 | QToolTipGroup *KOAgendaItem::toolTipGroup() |
701 | { | 701 | { |
702 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 702 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
703 | return mToolTipGroup; | 703 | return mToolTipGroup; |
704 | } | 704 | } |
705 | 705 | ||
706 | void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) | 706 | void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) |
707 | { | 707 | { |
708 | #ifndef KORG_NODND | 708 | #ifndef KORG_NODND |
709 | if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || | 709 | if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || |
710 | !QTextDrag::canDecode( e ) ) { | 710 | !QTextDrag::canDecode( e ) ) { |
711 | e->ignore(); | 711 | e->ignore(); |
712 | return; | 712 | return; |
713 | } | 713 | } |
714 | e->accept(); | 714 | e->accept(); |
715 | #endif | 715 | #endif |
716 | } | 716 | } |
717 | 717 | ||
718 | void KOAgendaItem::dropEvent( QDropEvent *e ) | 718 | void KOAgendaItem::dropEvent( QDropEvent *e ) |
719 | { | 719 | { |
720 | #ifndef KORG_NODND | 720 | #ifndef KORG_NODND |
721 | QString text; | 721 | QString text; |
722 | if(QTextDrag::decode(e,text)) | 722 | if(QTextDrag::decode(e,text)) |
723 | { | 723 | { |
724 | kdDebug() << "Dropped : " << text << endl; | 724 | kdDebug() << "Dropped : " << text << endl; |
725 | QStringList emails = QStringList::split(",",text); | 725 | QStringList emails = QStringList::split(",",text); |
726 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 726 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
727 | kdDebug() << " Email: " << (*it) << endl; | 727 | kdDebug() << " Email: " << (*it) << endl; |
728 | int pos = (*it).find("<"); | 728 | int pos = (*it).find("<"); |
729 | QString name = (*it).left(pos); | 729 | QString name = (*it).left(pos); |
730 | QString email = (*it).mid(pos); | 730 | QString email = (*it).mid(pos); |
731 | if (!email.isEmpty()) { | 731 | if (!email.isEmpty()) { |
732 | mIncidence->addAttendee(new Attendee(name,email)); | 732 | mIncidence->addAttendee(new Attendee(name,email)); |
733 | } | 733 | } |
734 | } | 734 | } |
735 | } | 735 | } |
736 | #endif | 736 | #endif |
737 | } | 737 | } |
738 | 738 | ||
739 | 739 | ||
740 | QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() | 740 | QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() |
741 | { | 741 | { |
742 | return mConflictItems; | 742 | return mConflictItems; |
743 | } | 743 | } |
744 | 744 | ||
745 | void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) | 745 | void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) |
746 | { | 746 | { |
747 | mConflictItems = ci; | 747 | mConflictItems = ci; |
748 | KOAgendaItem *item; | 748 | KOAgendaItem *item; |
749 | for ( item=mConflictItems.first(); item != 0; | 749 | for ( item=mConflictItems.first(); item != 0; |
750 | item=mConflictItems.next() ) { | 750 | item=mConflictItems.next() ) { |
751 | item->addConflictItem(this); | 751 | item->addConflictItem(this); |
752 | } | 752 | } |
753 | } | 753 | } |
754 | 754 | ||
755 | void KOAgendaItem::addConflictItem(KOAgendaItem *ci) | 755 | void KOAgendaItem::addConflictItem(KOAgendaItem *ci) |
756 | { | 756 | { |
757 | if (mConflictItems.find(ci)<0) | 757 | if (mConflictItems.find(ci)<0) |
758 | mConflictItems.append(ci); | 758 | mConflictItems.append(ci); |
759 | } | 759 | } |
diff --git a/korganizer/korganizer.pro b/korganizer/korganizer.pro index 3c7a1fb..5e82721 100644 --- a/korganizer/korganizer.pro +++ b/korganizer/korganizer.pro | |||
@@ -1,191 +1,191 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | CONFIG += qt warn_off | 2 | CONFIG += qt warn_on |
3 | TARGET = kopi | 3 | TARGET = kopi |
4 | OBJECTS_DIR = _obj/ | 4 | OBJECTS_DIR = _obj/ |
5 | MOC_DIR = _moc | 5 | MOC_DIR = _moc |
6 | DESTDIR= ../bin | 6 | DESTDIR= ../bin |
7 | 7 | ||
8 | include( ../variables.pri ) | 8 | include( ../variables.pri ) |
9 | 9 | ||
10 | INCLUDEPATH += ../microkde ../ interfaces ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim | 10 | INCLUDEPATH += ../microkde ../ interfaces ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim |
11 | #../qtcompat | 11 | #../qtcompat |
12 | DEFINES += KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL | 12 | DEFINES += KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL |
13 | DEFINES += KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER | 13 | DEFINES += KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER |
14 | #KORG_NOPRINTER KORG_NOKABC KORG_NODND | 14 | #KORG_NOPRINTER KORG_NOKABC KORG_NODND |
15 | DEFINES += KORG_NOLVALTERNATION | 15 | DEFINES += KORG_NOLVALTERNATION |
16 | DEFINES += DESKTOP_VERSION | 16 | DEFINES += DESKTOP_VERSION |
17 | unix : { | 17 | unix : { |
18 | LIBS += ../bin/libmicrokdepim.so | 18 | LIBS += ../bin/libmicrokdepim.so |
19 | LIBS += ../bin/libmicrokcal.so | 19 | LIBS += ../bin/libmicrokcal.so |
20 | LIBS += ../bin/libmicrokde.so | 20 | LIBS += ../bin/libmicrokde.so |
21 | LIBS += ../bin/libmicrokabc.so | 21 | LIBS += ../bin/libmicrokabc.so |
22 | #LIBS += -lbluetooth | 22 | #LIBS += -lbluetooth |
23 | #LIBS += -lsdp | 23 | #LIBS += -lsdp |
24 | 24 | ||
25 | #LIBS += -lldap | 25 | #LIBS += -lldap |
26 | OBJECTS_DIR = obj/unix | 26 | OBJECTS_DIR = obj/unix |
27 | MOC_DIR = moc/unix | 27 | MOC_DIR = moc/unix |
28 | } | 28 | } |
29 | win32: { | 29 | win32: { |
30 | RC_FILE = winicons.rc | 30 | RC_FILE = winicons.rc |
31 | DEFINES += _WIN32_ | 31 | DEFINES += _WIN32_ |
32 | LIBS += ../bin/microkdepim.lib | 32 | LIBS += ../bin/microkdepim.lib |
33 | LIBS += ../bin/microkcal.lib | 33 | LIBS += ../bin/microkcal.lib |
34 | LIBS += ../bin/microkde.lib | 34 | LIBS += ../bin/microkde.lib |
35 | LIBS += ../bin/microkabc.lib | 35 | LIBS += ../bin/microkabc.lib |
36 | LIBS += ../libical/lib/ical.lib | 36 | LIBS += ../libical/lib/ical.lib |
37 | LIBS += ../libical/lib/icalss.lib | 37 | LIBS += ../libical/lib/icalss.lib |
38 | #LIBS += atls.lib | 38 | #LIBS += atls.lib |
39 | QMAKE_LINK += /NODEFAULTLIB:LIBC | 39 | QMAKE_LINK += /NODEFAULTLIB:LIBC |
40 | #QMAKE_LINK += /NODEFAULTLIB:MSVCRT | 40 | #QMAKE_LINK += /NODEFAULTLIB:MSVCRT |
41 | #QMAKE_LINK += /NODEFAULTLIB:uafxcw.lib | 41 | #QMAKE_LINK += /NODEFAULTLIB:uafxcw.lib |
42 | OBJECTS_DIR = obj/win | 42 | OBJECTS_DIR = obj/win |
43 | MOC_DIR = moc/win | 43 | MOC_DIR = moc/win |
44 | #olimport section | 44 | #olimport section |
45 | #blabla: { | 45 | #blabla: { |
46 | LIBS += mfc71u.lib | 46 | LIBS += mfc71u.lib |
47 | DEFINES += _OL_IMPORT_ | 47 | DEFINES += _OL_IMPORT_ |
48 | 48 | ||
49 | HEADERS += ../outport/msoutl9.h \ | 49 | HEADERS += ../outport/msoutl9.h \ |
50 | koimportoldialog.h | 50 | koimportoldialog.h |
51 | SOURCES += ../outport/msoutl9.cpp \ | 51 | SOURCES += ../outport/msoutl9.cpp \ |
52 | koimportoldialog.cpp | 52 | koimportoldialog.cpp |
53 | #} | 53 | #} |
54 | #olimport section end | 54 | #olimport section end |
55 | 55 | ||
56 | } | 56 | } |
57 | 57 | ||
58 | 58 | ||
59 | INTERFACES = kofilterview_base.ui | 59 | INTERFACES = kofilterview_base.ui |
60 | #filteredit_base.ui | 60 | #filteredit_base.ui |
61 | 61 | ||
62 | # kdateedit.h \ | 62 | # kdateedit.h \ |
63 | 63 | ||
64 | HEADERS += \ | 64 | HEADERS += \ |
65 | filteredit_base.h \ | 65 | filteredit_base.h \ |
66 | alarmclient.h \ | 66 | alarmclient.h \ |
67 | calendarview.h \ | 67 | calendarview.h \ |
68 | customlistviewitem.h \ | 68 | customlistviewitem.h \ |
69 | datenavigator.h \ | 69 | datenavigator.h \ |
70 | docprefs.h \ | 70 | docprefs.h \ |
71 | filtereditdialog.h \ | 71 | filtereditdialog.h \ |
72 | incomingdialog.h \ | 72 | incomingdialog.h \ |
73 | incomingdialog_base.h \ | 73 | incomingdialog_base.h \ |
74 | interfaces/korganizer/baseview.h \ | 74 | interfaces/korganizer/baseview.h \ |
75 | interfaces/korganizer/calendarviewbase.h \ | 75 | interfaces/korganizer/calendarviewbase.h \ |
76 | journalentry.h \ | 76 | journalentry.h \ |
77 | kdatenavigator.h \ | 77 | kdatenavigator.h \ |
78 | koagenda.h \ | 78 | koagenda.h \ |
79 | koagendaitem.h \ | 79 | koagendaitem.h \ |
80 | koagendaview.h \ | 80 | koagendaview.h \ |
81 | kocounterdialog.h \ | 81 | kocounterdialog.h \ |
82 | kodaymatrix.h \ | 82 | kodaymatrix.h \ |
83 | kodialogmanager.h \ | 83 | kodialogmanager.h \ |
84 | koeditordetails.h \ | 84 | koeditordetails.h \ |
85 | koeditorgeneral.h \ | 85 | koeditorgeneral.h \ |
86 | koeditorgeneralevent.h \ | 86 | koeditorgeneralevent.h \ |
87 | koeditorgeneraltodo.h \ | 87 | koeditorgeneraltodo.h \ |
88 | koeditorrecurrence.h \ | 88 | koeditorrecurrence.h \ |
89 | koeventeditor.h \ | 89 | koeventeditor.h \ |
90 | koeventpopupmenu.h \ | 90 | koeventpopupmenu.h \ |
91 | koeventview.h \ | 91 | koeventview.h \ |
92 | koeventviewer.h \ | 92 | koeventviewer.h \ |
93 | koeventviewerdialog.h \ | 93 | koeventviewerdialog.h \ |
94 | kofilterview.h \ | 94 | kofilterview.h \ |
95 | koglobals.h \ | 95 | koglobals.h \ |
96 | koincidenceeditor.h \ | 96 | koincidenceeditor.h \ |
97 | kojournalview.h \ | 97 | kojournalview.h \ |
98 | kolistview.h \ | 98 | kolistview.h \ |
99 | kolocationbox.h \ | 99 | kolocationbox.h \ |
100 | komonthview.h \ | 100 | komonthview.h \ |
101 | koprefs.h \ | 101 | koprefs.h \ |
102 | koprefsdialog.h \ | 102 | koprefsdialog.h \ |
103 | kotimespanview.h \ | 103 | kotimespanview.h \ |
104 | kotodoeditor.h \ | 104 | kotodoeditor.h \ |
105 | kotodoview.h \ | 105 | kotodoview.h \ |
106 | kotodoviewitem.h \ | 106 | kotodoviewitem.h \ |
107 | koviewmanager.h \ | 107 | koviewmanager.h \ |
108 | kowhatsnextview.h \ | 108 | kowhatsnextview.h \ |
109 | ktimeedit.h \ | 109 | ktimeedit.h \ |
110 | lineview.h \ | 110 | lineview.h \ |
111 | mainwindow.h \ | 111 | mainwindow.h \ |
112 | navigatorbar.h \ | 112 | navigatorbar.h \ |
113 | outgoingdialog.h \ | 113 | outgoingdialog.h \ |
114 | outgoingdialog_base.h \ | 114 | outgoingdialog_base.h \ |
115 | publishdialog.h \ | 115 | publishdialog.h \ |
116 | publishdialog_base.h \ | 116 | publishdialog_base.h \ |
117 | savetemplatedialog.h \ | 117 | savetemplatedialog.h \ |
118 | searchdialog.h \ | 118 | searchdialog.h \ |
119 | simplealarmclient.h \ | 119 | simplealarmclient.h \ |
120 | statusdialog.h \ | 120 | statusdialog.h \ |
121 | timeline.h \ | 121 | timeline.h \ |
122 | timespanview.h \ | 122 | timespanview.h \ |
123 | version.h \ | 123 | version.h \ |
124 | ../kalarmd/alarmdialog.h \ | 124 | ../kalarmd/alarmdialog.h \ |
125 | 125 | ||
126 | 126 | ||
127 | SOURCES += \ | 127 | SOURCES += \ |
128 | filteredit_base.cpp \ | 128 | filteredit_base.cpp \ |
129 | calendarview.cpp \ | 129 | calendarview.cpp \ |
130 | datenavigator.cpp \ | 130 | datenavigator.cpp \ |
131 | docprefs.cpp \ | 131 | docprefs.cpp \ |
132 | filtereditdialog.cpp \ | 132 | filtereditdialog.cpp \ |
133 | incomingdialog.cpp \ | 133 | incomingdialog.cpp \ |
134 | incomingdialog_base.cpp \ | 134 | incomingdialog_base.cpp \ |
135 | journalentry.cpp \ | 135 | journalentry.cpp \ |
136 | kdatenavigator.cpp \ | 136 | kdatenavigator.cpp \ |
137 | koagenda.cpp \ | 137 | koagenda.cpp \ |
138 | koagendaitem.cpp \ | 138 | koagendaitem.cpp \ |
139 | koagendaview.cpp \ | 139 | koagendaview.cpp \ |
140 | kocounterdialog.cpp \ | 140 | kocounterdialog.cpp \ |
141 | kodaymatrix.cpp \ | 141 | kodaymatrix.cpp \ |
142 | kodialogmanager.cpp \ | 142 | kodialogmanager.cpp \ |
143 | koeditordetails.cpp \ | 143 | koeditordetails.cpp \ |
144 | koeditorgeneral.cpp \ | 144 | koeditorgeneral.cpp \ |
145 | koeditorgeneralevent.cpp \ | 145 | koeditorgeneralevent.cpp \ |
146 | koeditorgeneraltodo.cpp \ | 146 | koeditorgeneraltodo.cpp \ |
147 | koeditorrecurrence.cpp \ | 147 | koeditorrecurrence.cpp \ |
148 | koeventeditor.cpp \ | 148 | koeventeditor.cpp \ |
149 | koeventpopupmenu.cpp \ | 149 | koeventpopupmenu.cpp \ |
150 | koeventview.cpp \ | 150 | koeventview.cpp \ |
151 | koeventviewer.cpp \ | 151 | koeventviewer.cpp \ |
152 | koeventviewerdialog.cpp \ | 152 | koeventviewerdialog.cpp \ |
153 | kofilterview.cpp \ | 153 | kofilterview.cpp \ |
154 | koglobals.cpp \ | 154 | koglobals.cpp \ |
155 | koincidenceeditor.cpp \ | 155 | koincidenceeditor.cpp \ |
156 | kojournalview.cpp \ | 156 | kojournalview.cpp \ |
157 | kolistview.cpp \ | 157 | kolistview.cpp \ |
158 | kolocationbox.cpp \ | 158 | kolocationbox.cpp \ |
159 | komonthview.cpp \ | 159 | komonthview.cpp \ |
160 | koprefs.cpp \ | 160 | koprefs.cpp \ |
161 | koprefsdialog.cpp \ | 161 | koprefsdialog.cpp \ |
162 | kotimespanview.cpp \ | 162 | kotimespanview.cpp \ |
163 | kotodoeditor.cpp \ | 163 | kotodoeditor.cpp \ |
164 | kotodoview.cpp \ | 164 | kotodoview.cpp \ |
165 | kotodoviewitem.cpp \ | 165 | kotodoviewitem.cpp \ |
166 | koviewmanager.cpp \ | 166 | koviewmanager.cpp \ |
167 | kowhatsnextview.cpp \ | 167 | kowhatsnextview.cpp \ |
168 | ktimeedit.cpp \ | 168 | ktimeedit.cpp \ |
169 | lineview.cpp \ | 169 | lineview.cpp \ |
170 | main.cpp \ | 170 | main.cpp \ |
171 | mainwindow.cpp \ | 171 | mainwindow.cpp \ |
172 | navigatorbar.cpp \ | 172 | navigatorbar.cpp \ |
173 | outgoingdialog.cpp \ | 173 | outgoingdialog.cpp \ |
174 | outgoingdialog_base.cpp \ | 174 | outgoingdialog_base.cpp \ |
175 | publishdialog.cpp \ | 175 | publishdialog.cpp \ |
176 | publishdialog_base.cpp \ | 176 | publishdialog_base.cpp \ |
177 | savetemplatedialog.cpp \ | 177 | savetemplatedialog.cpp \ |
178 | searchdialog.cpp \ | 178 | searchdialog.cpp \ |
179 | simplealarmclient.cpp \ | 179 | simplealarmclient.cpp \ |
180 | statusdialog.cpp \ | 180 | statusdialog.cpp \ |
181 | timeline.cpp \ | 181 | timeline.cpp \ |
182 | timespanview.cpp \ | 182 | timespanview.cpp \ |
183 | ../kalarmd/alarmdialog.cpp | 183 | ../kalarmd/alarmdialog.cpp |
184 | 184 | ||
185 | HEADERS += calprintbase.h calprinter.h calprintplugins.h cellitem.h | 185 | HEADERS += calprintbase.h calprinter.h calprintplugins.h cellitem.h |
186 | INTERFACES += calprintdayconfig_base.ui \ | 186 | INTERFACES += calprintdayconfig_base.ui \ |
187 | calprintmonthconfig_base.ui \ | 187 | calprintmonthconfig_base.ui \ |
188 | calprinttodoconfig_base.ui \ | 188 | calprinttodoconfig_base.ui \ |
189 | calprintweekconfig_base.ui | 189 | calprintweekconfig_base.ui |
190 | SOURCES += calprintbase.cpp calprinter.cpp calprintplugins.cpp cellitem.cpp | 190 | SOURCES += calprintbase.cpp calprinter.cpp calprintplugins.cpp cellitem.cpp |
191 | 191 | ||
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index 88351eb..dcfee5d 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp | |||
@@ -1,466 +1,467 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 1998 Preston Brown | 3 | Copyright (c) 1998 Preston Brown |
4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <stdlib.h> | 22 | #include <stdlib.h> |
23 | #include <time.h> | 23 | #include <time.h> |
24 | 24 | ||
25 | #include <kdebug.h> | 25 | #include <kdebug.h> |
26 | #include <kglobal.h> | 26 | #include <kglobal.h> |
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | 28 | ||
29 | #include "exceptions.h" | 29 | #include "exceptions.h" |
30 | #include "calfilter.h" | 30 | #include "calfilter.h" |
31 | 31 | ||
32 | #include "calendar.h" | 32 | #include "calendar.h" |
33 | #include "syncdefines.h" | 33 | #include "syncdefines.h" |
34 | 34 | ||
35 | using namespace KCal; | 35 | using namespace KCal; |
36 | 36 | ||
37 | Calendar::Calendar() | 37 | Calendar::Calendar() |
38 | { | 38 | { |
39 | 39 | ||
40 | init(); | 40 | init(); |
41 | setTimeZoneId( i18n (" 00:00 Europe/London(UTC)") ); | 41 | setTimeZoneId( i18n (" 00:00 Europe/London(UTC)") ); |
42 | } | 42 | } |
43 | 43 | ||
44 | Calendar::Calendar( const QString &timeZoneId ) | 44 | Calendar::Calendar( const QString &timeZoneId ) |
45 | { | 45 | { |
46 | 46 | ||
47 | init(); | 47 | init(); |
48 | setTimeZoneId(timeZoneId); | 48 | setTimeZoneId(timeZoneId); |
49 | } | 49 | } |
50 | 50 | ||
51 | void Calendar::init() | 51 | void Calendar::init() |
52 | { | 52 | { |
53 | mObserver = 0; | 53 | mObserver = 0; |
54 | mNewObserver = false; | 54 | mNewObserver = false; |
55 | mUndoIncidence = 0; | 55 | mUndoIncidence = 0; |
56 | mModified = false; | 56 | mModified = false; |
57 | 57 | ||
58 | // Setup default filter, which does nothing | 58 | // Setup default filter, which does nothing |
59 | mDefaultFilter = new CalFilter; | 59 | mDefaultFilter = new CalFilter; |
60 | mFilter = mDefaultFilter; | 60 | mFilter = mDefaultFilter; |
61 | mFilter->setEnabled(false); | 61 | mFilter->setEnabled(false); |
62 | 62 | ||
63 | // initialize random numbers. This is a hack, and not | 63 | // initialize random numbers. This is a hack, and not |
64 | // even that good of one at that. | 64 | // even that good of one at that. |
65 | // srandom(time(0)); | 65 | // srandom(time(0)); |
66 | 66 | ||
67 | // user information... | 67 | // user information... |
68 | setOwner(i18n("Unknown Name")); | 68 | setOwner(i18n("Unknown Name")); |
69 | setEmail(i18n("unknown@nowhere")); | 69 | setEmail(i18n("unknown@nowhere")); |
70 | 70 | ||
71 | #if 0 | 71 | #if 0 |
72 | tmpStr = KOPrefs::instance()->mTimeZone; | 72 | tmpStr = KOPrefs::instance()->mTimeZone; |
73 | // kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl; | 73 | // kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl; |
74 | int dstSetting = KOPrefs::instance()->mDaylightSavings; | 74 | int dstSetting = KOPrefs::instance()->mDaylightSavings; |
75 | extern long int timezone; | 75 | extern long int timezone; |
76 | struct tm *now; | 76 | struct tm *now; |
77 | time_t curtime; | 77 | time_t curtime; |
78 | curtime = time(0); | 78 | curtime = time(0); |
79 | now = localtime(&curtime); | 79 | now = localtime(&curtime); |
80 | int hourOff = - ((timezone / 60) / 60); | 80 | int hourOff = - ((timezone / 60) / 60); |
81 | if (now->tm_isdst) | 81 | if (now->tm_isdst) |
82 | hourOff += 1; | 82 | hourOff += 1; |
83 | QString tzStr; | 83 | QString tzStr; |
84 | tzStr.sprintf("%.2d%.2d", | 84 | tzStr.sprintf("%.2d%.2d", |
85 | hourOff, | 85 | hourOff, |
86 | abs((timezone / 60) % 60)); | 86 | abs((timezone / 60) % 60)); |
87 | 87 | ||
88 | // if no time zone was in the config file, write what we just discovered. | 88 | // if no time zone was in the config file, write what we just discovered. |
89 | if (tmpStr.isEmpty()) { | 89 | if (tmpStr.isEmpty()) { |
90 | // KOPrefs::instance()->mTimeZone = tzStr; | 90 | // KOPrefs::instance()->mTimeZone = tzStr; |
91 | } else { | 91 | } else { |
92 | tzStr = tmpStr; | 92 | tzStr = tmpStr; |
93 | } | 93 | } |
94 | 94 | ||
95 | // if daylight savings has changed since last load time, we need | 95 | // if daylight savings has changed since last load time, we need |
96 | // to rewrite these settings to the config file. | 96 | // to rewrite these settings to the config file. |
97 | if ((now->tm_isdst && !dstSetting) || | 97 | if ((now->tm_isdst && !dstSetting) || |
98 | (!now->tm_isdst && dstSetting)) { | 98 | (!now->tm_isdst && dstSetting)) { |
99 | KOPrefs::instance()->mTimeZone = tzStr; | 99 | KOPrefs::instance()->mTimeZone = tzStr; |
100 | KOPrefs::instance()->mDaylightSavings = now->tm_isdst; | 100 | KOPrefs::instance()->mDaylightSavings = now->tm_isdst; |
101 | } | 101 | } |
102 | 102 | ||
103 | setTimeZone(tzStr); | 103 | setTimeZone(tzStr); |
104 | #endif | 104 | #endif |
105 | 105 | ||
106 | // KOPrefs::instance()->writeConfig(); | 106 | // KOPrefs::instance()->writeConfig(); |
107 | } | 107 | } |
108 | 108 | ||
109 | Calendar::~Calendar() | 109 | Calendar::~Calendar() |
110 | { | 110 | { |
111 | delete mDefaultFilter; | 111 | delete mDefaultFilter; |
112 | if ( mUndoIncidence ) | 112 | if ( mUndoIncidence ) |
113 | delete mUndoIncidence; | 113 | delete mUndoIncidence; |
114 | } | 114 | } |
115 | 115 | ||
116 | const QString &Calendar::getOwner() const | 116 | const QString &Calendar::getOwner() const |
117 | { | 117 | { |
118 | return mOwner; | 118 | return mOwner; |
119 | } | 119 | } |
120 | 120 | ||
121 | bool Calendar::undoDeleteIncidence() | 121 | bool Calendar::undoDeleteIncidence() |
122 | { | 122 | { |
123 | if (!mUndoIncidence) | 123 | if (!mUndoIncidence) |
124 | return false; | 124 | return false; |
125 | addIncidence(mUndoIncidence); | 125 | addIncidence(mUndoIncidence); |
126 | mUndoIncidence = 0; | 126 | mUndoIncidence = 0; |
127 | return true; | ||
127 | } | 128 | } |
128 | void Calendar::setOwner(const QString &os) | 129 | void Calendar::setOwner(const QString &os) |
129 | { | 130 | { |
130 | int i; | 131 | int i; |
131 | mOwner = os; | 132 | mOwner = os; |
132 | i = mOwner.find(','); | 133 | i = mOwner.find(','); |
133 | if (i != -1) | 134 | if (i != -1) |
134 | mOwner = mOwner.left(i); | 135 | mOwner = mOwner.left(i); |
135 | 136 | ||
136 | setModified( true ); | 137 | setModified( true ); |
137 | } | 138 | } |
138 | 139 | ||
139 | void Calendar::setTimeZone(const QString & tz) | 140 | void Calendar::setTimeZone(const QString & tz) |
140 | { | 141 | { |
141 | bool neg = FALSE; | 142 | bool neg = FALSE; |
142 | int hours, minutes; | 143 | int hours, minutes; |
143 | QString tmpStr(tz); | 144 | QString tmpStr(tz); |
144 | 145 | ||
145 | if (tmpStr.left(1) == "-") | 146 | if (tmpStr.left(1) == "-") |
146 | neg = TRUE; | 147 | neg = TRUE; |
147 | if (tmpStr.left(1) == "-" || tmpStr.left(1) == "+") | 148 | if (tmpStr.left(1) == "-" || tmpStr.left(1) == "+") |
148 | tmpStr.remove(0, 1); | 149 | tmpStr.remove(0, 1); |
149 | hours = tmpStr.left(2).toInt(); | 150 | hours = tmpStr.left(2).toInt(); |
150 | if (tmpStr.length() > 2) | 151 | if (tmpStr.length() > 2) |
151 | minutes = tmpStr.right(2).toInt(); | 152 | minutes = tmpStr.right(2).toInt(); |
152 | else | 153 | else |
153 | minutes = 0; | 154 | minutes = 0; |
154 | mTimeZone = (60*hours+minutes); | 155 | mTimeZone = (60*hours+minutes); |
155 | if (neg) | 156 | if (neg) |
156 | mTimeZone = -mTimeZone; | 157 | mTimeZone = -mTimeZone; |
157 | mLocalTime = false; | 158 | mLocalTime = false; |
158 | 159 | ||
159 | setModified( true ); | 160 | setModified( true ); |
160 | } | 161 | } |
161 | 162 | ||
162 | QString Calendar::getTimeZoneStr() const | 163 | QString Calendar::getTimeZoneStr() const |
163 | { | 164 | { |
164 | if (mLocalTime) | 165 | if (mLocalTime) |
165 | return ""; | 166 | return ""; |
166 | QString tmpStr; | 167 | QString tmpStr; |
167 | int hours = abs(mTimeZone / 60); | 168 | int hours = abs(mTimeZone / 60); |
168 | int minutes = abs(mTimeZone % 60); | 169 | int minutes = abs(mTimeZone % 60); |
169 | bool neg = mTimeZone < 0; | 170 | bool neg = mTimeZone < 0; |
170 | 171 | ||
171 | tmpStr.sprintf("%c%.2d%.2d", | 172 | tmpStr.sprintf("%c%.2d%.2d", |
172 | (neg ? '-' : '+'), | 173 | (neg ? '-' : '+'), |
173 | hours, minutes); | 174 | hours, minutes); |
174 | return tmpStr; | 175 | return tmpStr; |
175 | } | 176 | } |
176 | 177 | ||
177 | void Calendar::setTimeZone(int tz) | 178 | void Calendar::setTimeZone(int tz) |
178 | { | 179 | { |
179 | mTimeZone = tz; | 180 | mTimeZone = tz; |
180 | mLocalTime = false; | 181 | mLocalTime = false; |
181 | 182 | ||
182 | setModified( true ); | 183 | setModified( true ); |
183 | } | 184 | } |
184 | 185 | ||
185 | int Calendar::getTimeZone() const | 186 | int Calendar::getTimeZone() const |
186 | { | 187 | { |
187 | return mTimeZone; | 188 | return mTimeZone; |
188 | } | 189 | } |
189 | 190 | ||
190 | void Calendar::setTimeZoneId(const QString &id) | 191 | void Calendar::setTimeZoneId(const QString &id) |
191 | { | 192 | { |
192 | mTimeZoneId = id; | 193 | mTimeZoneId = id; |
193 | mLocalTime = false; | 194 | mLocalTime = false; |
194 | mTimeZone = KGlobal::locale()->timezoneOffset(mTimeZoneId); | 195 | mTimeZone = KGlobal::locale()->timezoneOffset(mTimeZoneId); |
195 | if ( mTimeZone > 1000) | 196 | if ( mTimeZone > 1000) |
196 | setLocalTime(); | 197 | setLocalTime(); |
197 | //qDebug("Calendar::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), mTimeZone); | 198 | //qDebug("Calendar::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), mTimeZone); |
198 | setModified( true ); | 199 | setModified( true ); |
199 | } | 200 | } |
200 | 201 | ||
201 | QString Calendar::timeZoneId() const | 202 | QString Calendar::timeZoneId() const |
202 | { | 203 | { |
203 | return mTimeZoneId; | 204 | return mTimeZoneId; |
204 | } | 205 | } |
205 | 206 | ||
206 | void Calendar::setLocalTime() | 207 | void Calendar::setLocalTime() |
207 | { | 208 | { |
208 | //qDebug("Calendar::setLocalTime() "); | 209 | //qDebug("Calendar::setLocalTime() "); |
209 | mLocalTime = true; | 210 | mLocalTime = true; |
210 | mTimeZone = 0; | 211 | mTimeZone = 0; |
211 | mTimeZoneId = ""; | 212 | mTimeZoneId = ""; |
212 | 213 | ||
213 | setModified( true ); | 214 | setModified( true ); |
214 | } | 215 | } |
215 | 216 | ||
216 | bool Calendar::isLocalTime() const | 217 | bool Calendar::isLocalTime() const |
217 | { | 218 | { |
218 | return mLocalTime; | 219 | return mLocalTime; |
219 | } | 220 | } |
220 | 221 | ||
221 | const QString &Calendar::getEmail() | 222 | const QString &Calendar::getEmail() |
222 | { | 223 | { |
223 | return mOwnerEmail; | 224 | return mOwnerEmail; |
224 | } | 225 | } |
225 | 226 | ||
226 | void Calendar::setEmail(const QString &e) | 227 | void Calendar::setEmail(const QString &e) |
227 | { | 228 | { |
228 | mOwnerEmail = e; | 229 | mOwnerEmail = e; |
229 | 230 | ||
230 | setModified( true ); | 231 | setModified( true ); |
231 | } | 232 | } |
232 | 233 | ||
233 | void Calendar::setFilter(CalFilter *filter) | 234 | void Calendar::setFilter(CalFilter *filter) |
234 | { | 235 | { |
235 | mFilter = filter; | 236 | mFilter = filter; |
236 | } | 237 | } |
237 | 238 | ||
238 | CalFilter *Calendar::filter() | 239 | CalFilter *Calendar::filter() |
239 | { | 240 | { |
240 | return mFilter; | 241 | return mFilter; |
241 | } | 242 | } |
242 | 243 | ||
243 | QPtrList<Incidence> Calendar::incidences() | 244 | QPtrList<Incidence> Calendar::incidences() |
244 | { | 245 | { |
245 | QPtrList<Incidence> incidences; | 246 | QPtrList<Incidence> incidences; |
246 | 247 | ||
247 | Incidence *i; | 248 | Incidence *i; |
248 | 249 | ||
249 | QPtrList<Event> e = events(); | 250 | QPtrList<Event> e = events(); |
250 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); | 251 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); |
251 | 252 | ||
252 | QPtrList<Todo> t = todos(); | 253 | QPtrList<Todo> t = todos(); |
253 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); | 254 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); |
254 | 255 | ||
255 | QPtrList<Journal> j = journals(); | 256 | QPtrList<Journal> j = journals(); |
256 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); | 257 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); |
257 | 258 | ||
258 | return incidences; | 259 | return incidences; |
259 | } | 260 | } |
260 | 261 | ||
261 | void Calendar::resetPilotStat(int id ) | 262 | void Calendar::resetPilotStat(int id ) |
262 | { | 263 | { |
263 | QPtrList<Incidence> incidences; | 264 | QPtrList<Incidence> incidences; |
264 | 265 | ||
265 | Incidence *i; | 266 | Incidence *i; |
266 | 267 | ||
267 | QPtrList<Event> e = rawEvents(); | 268 | QPtrList<Event> e = rawEvents(); |
268 | for( i = e.first(); i; i = e.next() ) i->setPilotId( id ); | 269 | for( i = e.first(); i; i = e.next() ) i->setPilotId( id ); |
269 | 270 | ||
270 | QPtrList<Todo> t = rawTodos(); | 271 | QPtrList<Todo> t = rawTodos(); |
271 | for( i = t.first(); i; i = t.next() ) i->setPilotId( id ); | 272 | for( i = t.first(); i; i = t.next() ) i->setPilotId( id ); |
272 | 273 | ||
273 | QPtrList<Journal> j = journals(); | 274 | QPtrList<Journal> j = journals(); |
274 | for( i = j.first(); i; i = j.next() ) i->setPilotId( id ); | 275 | for( i = j.first(); i; i = j.next() ) i->setPilotId( id ); |
275 | } | 276 | } |
276 | void Calendar::resetTempSyncStat() | 277 | void Calendar::resetTempSyncStat() |
277 | { | 278 | { |
278 | QPtrList<Incidence> incidences; | 279 | QPtrList<Incidence> incidences; |
279 | 280 | ||
280 | Incidence *i; | 281 | Incidence *i; |
281 | 282 | ||
282 | QPtrList<Event> e = rawEvents(); | 283 | QPtrList<Event> e = rawEvents(); |
283 | for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 284 | for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
284 | 285 | ||
285 | QPtrList<Todo> t = rawTodos(); | 286 | QPtrList<Todo> t = rawTodos(); |
286 | for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 287 | for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
287 | 288 | ||
288 | QPtrList<Journal> j = journals(); | 289 | QPtrList<Journal> j = journals(); |
289 | for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 290 | for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
290 | } | 291 | } |
291 | QPtrList<Incidence> Calendar::rawIncidences() | 292 | QPtrList<Incidence> Calendar::rawIncidences() |
292 | { | 293 | { |
293 | QPtrList<Incidence> incidences; | 294 | QPtrList<Incidence> incidences; |
294 | 295 | ||
295 | Incidence *i; | 296 | Incidence *i; |
296 | 297 | ||
297 | QPtrList<Event> e = rawEvents(); | 298 | QPtrList<Event> e = rawEvents(); |
298 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); | 299 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); |
299 | 300 | ||
300 | QPtrList<Todo> t = rawTodos(); | 301 | QPtrList<Todo> t = rawTodos(); |
301 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); | 302 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); |
302 | 303 | ||
303 | QPtrList<Journal> j = journals(); | 304 | QPtrList<Journal> j = journals(); |
304 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); | 305 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); |
305 | 306 | ||
306 | return incidences; | 307 | return incidences; |
307 | } | 308 | } |
308 | 309 | ||
309 | QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) | 310 | QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) |
310 | { | 311 | { |
311 | QPtrList<Event> el = rawEventsForDate(date,sorted); | 312 | QPtrList<Event> el = rawEventsForDate(date,sorted); |
312 | mFilter->apply(&el); | 313 | mFilter->apply(&el); |
313 | return el; | 314 | return el; |
314 | } | 315 | } |
315 | 316 | ||
316 | QPtrList<Event> Calendar::events( const QDateTime &qdt ) | 317 | QPtrList<Event> Calendar::events( const QDateTime &qdt ) |
317 | { | 318 | { |
318 | QPtrList<Event> el = rawEventsForDate(qdt); | 319 | QPtrList<Event> el = rawEventsForDate(qdt); |
319 | mFilter->apply(&el); | 320 | mFilter->apply(&el); |
320 | return el; | 321 | return el; |
321 | } | 322 | } |
322 | 323 | ||
323 | QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, | 324 | QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, |
324 | bool inclusive) | 325 | bool inclusive) |
325 | { | 326 | { |
326 | QPtrList<Event> el = rawEvents(start,end,inclusive); | 327 | QPtrList<Event> el = rawEvents(start,end,inclusive); |
327 | mFilter->apply(&el); | 328 | mFilter->apply(&el); |
328 | return el; | 329 | return el; |
329 | } | 330 | } |
330 | 331 | ||
331 | QPtrList<Event> Calendar::events() | 332 | QPtrList<Event> Calendar::events() |
332 | { | 333 | { |
333 | QPtrList<Event> el = rawEvents(); | 334 | QPtrList<Event> el = rawEvents(); |
334 | mFilter->apply(&el); | 335 | mFilter->apply(&el); |
335 | return el; | 336 | return el; |
336 | } | 337 | } |
337 | 338 | ||
338 | 339 | ||
339 | bool Calendar::addIncidence(Incidence *i) | 340 | bool Calendar::addIncidence(Incidence *i) |
340 | { | 341 | { |
341 | Incidence::AddVisitor<Calendar> v(this); | 342 | Incidence::AddVisitor<Calendar> v(this); |
342 | 343 | ||
343 | return i->accept(v); | 344 | return i->accept(v); |
344 | } | 345 | } |
345 | void Calendar::deleteIncidence(Incidence *in) | 346 | void Calendar::deleteIncidence(Incidence *in) |
346 | { | 347 | { |
347 | if ( in->type() == "Event" ) | 348 | if ( in->type() == "Event" ) |
348 | deleteEvent( (Event*) in ); | 349 | deleteEvent( (Event*) in ); |
349 | else if ( in->type() =="Todo" ) | 350 | else if ( in->type() =="Todo" ) |
350 | deleteTodo( (Todo*) in); | 351 | deleteTodo( (Todo*) in); |
351 | else if ( in->type() =="Journal" ) | 352 | else if ( in->type() =="Journal" ) |
352 | deleteJournal( (Journal*) in ); | 353 | deleteJournal( (Journal*) in ); |
353 | } | 354 | } |
354 | 355 | ||
355 | Incidence* Calendar::incidence( const QString& uid ) | 356 | Incidence* Calendar::incidence( const QString& uid ) |
356 | { | 357 | { |
357 | Incidence* i; | 358 | Incidence* i; |
358 | 359 | ||
359 | if( (i = todo( uid )) != 0 ) | 360 | if( (i = todo( uid )) != 0 ) |
360 | return i; | 361 | return i; |
361 | if( (i = event( uid )) != 0 ) | 362 | if( (i = event( uid )) != 0 ) |
362 | return i; | 363 | return i; |
363 | if( (i = journal( uid )) != 0 ) | 364 | if( (i = journal( uid )) != 0 ) |
364 | return i; | 365 | return i; |
365 | 366 | ||
366 | return 0; | 367 | return 0; |
367 | } | 368 | } |
368 | 369 | ||
369 | QPtrList<Todo> Calendar::todos() | 370 | QPtrList<Todo> Calendar::todos() |
370 | { | 371 | { |
371 | QPtrList<Todo> tl = rawTodos(); | 372 | QPtrList<Todo> tl = rawTodos(); |
372 | mFilter->apply( &tl ); | 373 | mFilter->apply( &tl ); |
373 | return tl; | 374 | return tl; |
374 | } | 375 | } |
375 | 376 | ||
376 | // When this is called, the todo have already been added to the calendar. | 377 | // When this is called, the todo have already been added to the calendar. |
377 | // This method is only about linking related todos | 378 | // This method is only about linking related todos |
378 | void Calendar::setupRelations( Incidence *incidence ) | 379 | void Calendar::setupRelations( Incidence *incidence ) |
379 | { | 380 | { |
380 | QString uid = incidence->uid(); | 381 | QString uid = incidence->uid(); |
381 | //qDebug("Calendar::setupRelations "); | 382 | //qDebug("Calendar::setupRelations "); |
382 | // First, go over the list of orphans and see if this is their parent | 383 | // First, go over the list of orphans and see if this is their parent |
383 | while( Incidence* i = mOrphans[ uid ] ) { | 384 | while( Incidence* i = mOrphans[ uid ] ) { |
384 | mOrphans.remove( uid ); | 385 | mOrphans.remove( uid ); |
385 | i->setRelatedTo( incidence ); | 386 | i->setRelatedTo( incidence ); |
386 | incidence->addRelation( i ); | 387 | incidence->addRelation( i ); |
387 | mOrphanUids.remove( i->uid() ); | 388 | mOrphanUids.remove( i->uid() ); |
388 | } | 389 | } |
389 | 390 | ||
390 | // Now see about this incidences parent | 391 | // Now see about this incidences parent |
391 | if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { | 392 | if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { |
392 | // This incidence has a uid it is related to, but is not registered to it yet | 393 | // This incidence has a uid it is related to, but is not registered to it yet |
393 | // Try to find it | 394 | // Try to find it |
394 | Incidence* parent = this->incidence( incidence->relatedToUid() ); | 395 | Incidence* parent = this->incidence( incidence->relatedToUid() ); |
395 | if( parent ) { | 396 | if( parent ) { |
396 | // Found it | 397 | // Found it |
397 | incidence->setRelatedTo( parent ); | 398 | incidence->setRelatedTo( parent ); |
398 | parent->addRelation( incidence ); | 399 | parent->addRelation( incidence ); |
399 | } else { | 400 | } else { |
400 | // Not found, put this in the mOrphans list | 401 | // Not found, put this in the mOrphans list |
401 | mOrphans.insert( incidence->relatedToUid(), incidence ); | 402 | mOrphans.insert( incidence->relatedToUid(), incidence ); |
402 | mOrphanUids.insert( incidence->uid(), incidence ); | 403 | mOrphanUids.insert( incidence->uid(), incidence ); |
403 | } | 404 | } |
404 | } | 405 | } |
405 | } | 406 | } |
406 | 407 | ||
407 | // If a task with subtasks is deleted, move it's subtasks to the orphans list | 408 | // If a task with subtasks is deleted, move it's subtasks to the orphans list |
408 | void Calendar::removeRelations( Incidence *incidence ) | 409 | void Calendar::removeRelations( Incidence *incidence ) |
409 | { | 410 | { |
410 | // qDebug("Calendar::removeRelations "); | 411 | // qDebug("Calendar::removeRelations "); |
411 | QString uid = incidence->uid(); | 412 | QString uid = incidence->uid(); |
412 | 413 | ||
413 | QPtrList<Incidence> relations = incidence->relations(); | 414 | QPtrList<Incidence> relations = incidence->relations(); |
414 | for( Incidence* i = relations.first(); i; i = relations.next() ) | 415 | for( Incidence* i = relations.first(); i; i = relations.next() ) |
415 | if( !mOrphanUids.find( i->uid() ) ) { | 416 | if( !mOrphanUids.find( i->uid() ) ) { |
416 | mOrphans.insert( uid, i ); | 417 | mOrphans.insert( uid, i ); |
417 | mOrphanUids.insert( i->uid(), i ); | 418 | mOrphanUids.insert( i->uid(), i ); |
418 | i->setRelatedTo( 0 ); | 419 | i->setRelatedTo( 0 ); |
419 | i->setRelatedToUid( uid ); | 420 | i->setRelatedToUid( uid ); |
420 | } | 421 | } |
421 | 422 | ||
422 | // If this incidence is related to something else, tell that about it | 423 | // If this incidence is related to something else, tell that about it |
423 | if( incidence->relatedTo() ) | 424 | if( incidence->relatedTo() ) |
424 | incidence->relatedTo()->removeRelation( incidence ); | 425 | incidence->relatedTo()->removeRelation( incidence ); |
425 | 426 | ||
426 | // Remove this one from the orphans list | 427 | // Remove this one from the orphans list |
427 | if( mOrphanUids.remove( uid ) ) | 428 | if( mOrphanUids.remove( uid ) ) |
428 | // This incidence is located in the orphans list - it should be removed | 429 | // This incidence is located in the orphans list - it should be removed |
429 | if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { | 430 | if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { |
430 | // Removing wasn't that easy | 431 | // Removing wasn't that easy |
431 | for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { | 432 | for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { |
432 | if( it.current()->uid() == uid ) { | 433 | if( it.current()->uid() == uid ) { |
433 | mOrphans.remove( it.currentKey() ); | 434 | mOrphans.remove( it.currentKey() ); |
434 | break; | 435 | break; |
435 | } | 436 | } |
436 | } | 437 | } |
437 | } | 438 | } |
438 | } | 439 | } |
439 | 440 | ||
440 | void Calendar::registerObserver( Observer *observer ) | 441 | void Calendar::registerObserver( Observer *observer ) |
441 | { | 442 | { |
442 | mObserver = observer; | 443 | mObserver = observer; |
443 | mNewObserver = true; | 444 | mNewObserver = true; |
444 | } | 445 | } |
445 | 446 | ||
446 | void Calendar::setModified( bool modified ) | 447 | void Calendar::setModified( bool modified ) |
447 | { | 448 | { |
448 | if ( mObserver ) mObserver->calendarModified( modified, this ); | 449 | if ( mObserver ) mObserver->calendarModified( modified, this ); |
449 | if ( modified != mModified || mNewObserver ) { | 450 | if ( modified != mModified || mNewObserver ) { |
450 | mNewObserver = false; | 451 | mNewObserver = false; |
451 | // if ( mObserver ) mObserver->calendarModified( modified, this ); | 452 | // if ( mObserver ) mObserver->calendarModified( modified, this ); |
452 | mModified = modified; | 453 | mModified = modified; |
453 | } | 454 | } |
454 | } | 455 | } |
455 | 456 | ||
456 | void Calendar::setLoadedProductId( const QString &id ) | 457 | void Calendar::setLoadedProductId( const QString &id ) |
457 | { | 458 | { |
458 | mLoadedProductId = id; | 459 | mLoadedProductId = id; |
459 | } | 460 | } |
460 | 461 | ||
461 | QString Calendar::loadedProductId() | 462 | QString Calendar::loadedProductId() |
462 | { | 463 | { |
463 | return mLoadedProductId; | 464 | return mLoadedProductId; |
464 | } | 465 | } |
465 | 466 | ||
466 | //#include "calendar.moc" | 467 | //#include "calendar.moc" |
diff --git a/libkcal/event.cpp b/libkcal/event.cpp index 7256f05..de8dceb 100644 --- a/libkcal/event.cpp +++ b/libkcal/event.cpp | |||
@@ -1,223 +1,221 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library 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 GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <kglobal.h> | 21 | #include <kglobal.h> |
22 | #include <klocale.h> | 22 | #include <klocale.h> |
23 | #include <kdebug.h> | 23 | #include <kdebug.h> |
24 | 24 | ||
25 | #include "event.h" | 25 | #include "event.h" |
26 | 26 | ||
27 | using namespace KCal; | 27 | using namespace KCal; |
28 | 28 | ||
29 | Event::Event() : | 29 | Event::Event() : |
30 | mHasEndDate( false ), mTransparency( Opaque ) | 30 | mHasEndDate( false ), mTransparency( Opaque ) |
31 | { | 31 | { |
32 | } | 32 | } |
33 | 33 | ||
34 | Event::Event(const Event &e) : Incidence(e) | 34 | Event::Event(const Event &e) : Incidence(e) |
35 | { | 35 | { |
36 | mDtEnd = e.mDtEnd; | 36 | mDtEnd = e.mDtEnd; |
37 | mHasEndDate = e.mHasEndDate; | 37 | mHasEndDate = e.mHasEndDate; |
38 | mTransparency = e.mTransparency; | 38 | mTransparency = e.mTransparency; |
39 | } | 39 | } |
40 | 40 | ||
41 | Event::~Event() | 41 | Event::~Event() |
42 | { | 42 | { |
43 | } | 43 | } |
44 | 44 | ||
45 | Incidence *Event::clone() | 45 | Incidence *Event::clone() |
46 | { | 46 | { |
47 | return new Event(*this); | 47 | return new Event(*this); |
48 | } | 48 | } |
49 | 49 | ||
50 | bool KCal::operator==( const Event& e1, const Event& e2 ) | 50 | bool KCal::operator==( const Event& e1, const Event& e2 ) |
51 | { | 51 | { |
52 | return operator==( (const Incidence&)e1, (const Incidence&)e2 ) && | 52 | return operator==( (const Incidence&)e1, (const Incidence&)e2 ) && |
53 | e1.dtEnd() == e2.dtEnd() && | 53 | e1.dtEnd() == e2.dtEnd() && |
54 | e1.hasEndDate() == e2.hasEndDate() && | 54 | e1.hasEndDate() == e2.hasEndDate() && |
55 | e1.transparency() == e2.transparency(); | 55 | e1.transparency() == e2.transparency(); |
56 | } | 56 | } |
57 | 57 | ||
58 | 58 | ||
59 | bool Event::contains ( Event* from ) | 59 | bool Event::contains ( Event* from ) |
60 | { | 60 | { |
61 | 61 | ||
62 | if ( !from->summary().isEmpty() ) | 62 | if ( !from->summary().isEmpty() ) |
63 | if ( !summary().startsWith( from->summary() )) | 63 | if ( !summary().startsWith( from->summary() )) |
64 | return false; | 64 | return false; |
65 | if ( from->dtStart().isValid() ) | 65 | if ( from->dtStart().isValid() ) |
66 | if (dtStart() != from->dtStart() ) | 66 | if (dtStart() != from->dtStart() ) |
67 | return false; | 67 | return false; |
68 | if ( from->dtEnd().isValid() ) | 68 | if ( from->dtEnd().isValid() ) |
69 | if ( dtEnd() != from->dtEnd() ) | 69 | if ( dtEnd() != from->dtEnd() ) |
70 | return false; | 70 | return false; |
71 | if ( !from->location().isEmpty() ) | 71 | if ( !from->location().isEmpty() ) |
72 | if ( !location().startsWith( from->location() ) ) | 72 | if ( !location().startsWith( from->location() ) ) |
73 | return false; | 73 | return false; |
74 | if ( !from->description().isEmpty() ) | 74 | if ( !from->description().isEmpty() ) |
75 | if ( !description().startsWith( from->description() )) | 75 | if ( !description().startsWith( from->description() )) |
76 | return false; | 76 | return false; |
77 | if ( from->alarms().count() ) { | 77 | if ( from->alarms().count() ) { |
78 | Alarm *a = from->alarms().first(); | 78 | Alarm *a = from->alarms().first(); |
79 | if ( a->enabled() ){ | 79 | if ( a->enabled() ){ |
80 | if ( !alarms().count() ) | 80 | if ( !alarms().count() ) |
81 | return false; | 81 | return false; |
82 | Alarm *b = alarms().first(); | 82 | Alarm *b = alarms().first(); |
83 | if( ! b->enabled() ) | 83 | if( ! b->enabled() ) |
84 | return false; | 84 | return false; |
85 | if ( ! (a->offset() == b->offset() )) | 85 | if ( ! (a->offset() == b->offset() )) |
86 | return false; | 86 | return false; |
87 | } | 87 | } |
88 | } | 88 | } |
89 | QStringList cat = categories(); | 89 | QStringList cat = categories(); |
90 | QStringList catFrom = from->categories(); | 90 | QStringList catFrom = from->categories(); |
91 | QString nCat; | 91 | QString nCat; |
92 | int iii; | 92 | unsigned int iii; |
93 | for ( iii = 0; iii < catFrom.count();++iii ) { | 93 | for ( iii = 0; iii < catFrom.count();++iii ) { |
94 | nCat = catFrom[iii]; | 94 | nCat = catFrom[iii]; |
95 | if ( !nCat.isEmpty() ) | 95 | if ( !nCat.isEmpty() ) |
96 | if ( !cat.contains( nCat )) { | 96 | if ( !cat.contains( nCat )) { |
97 | return false; | 97 | return false; |
98 | } | 98 | } |
99 | } | 99 | } |
100 | if ( from->doesRecur() ) | 100 | if ( from->doesRecur() ) |
101 | if ( from->doesRecur() != doesRecur() && ! (from->doesRecur()== Recurrence::rYearlyMonth && doesRecur()== Recurrence::rYearlyDay) ) | 101 | if ( from->doesRecur() != doesRecur() && ! (from->doesRecur()== Recurrence::rYearlyMonth && doesRecur()== Recurrence::rYearlyDay) ) |
102 | return false; | 102 | return false; |
103 | return true; | 103 | return true; |
104 | } | 104 | } |
105 | 105 | ||
106 | void Event::setDtEnd(const QDateTime &dtEnd) | 106 | void Event::setDtEnd(const QDateTime &dtEnd) |
107 | { | 107 | { |
108 | if (mReadOnly) return; | 108 | if (mReadOnly) return; |
109 | 109 | ||
110 | mDtEnd = getEvenTime( dtEnd ); | 110 | mDtEnd = getEvenTime( dtEnd ); |
111 | 111 | ||
112 | setHasEndDate(true); | 112 | setHasEndDate(true); |
113 | setHasDuration(false); | 113 | setHasDuration(false); |
114 | 114 | ||
115 | updated(); | 115 | updated(); |
116 | } | 116 | } |
117 | 117 | ||
118 | QDateTime Event::dtEnd() const | 118 | QDateTime Event::dtEnd() const |
119 | { | 119 | { |
120 | if (hasEndDate()) return mDtEnd; | 120 | if (hasEndDate()) return mDtEnd; |
121 | if (hasDuration()) return dtStart().addSecs(duration()); | 121 | if (hasDuration()) return dtStart().addSecs(duration()); |
122 | 122 | ||
123 | kdDebug(5800) << "Warning! Event '" << summary() | ||
124 | << "' does have neither end date nor duration." << endl; | ||
125 | return dtStart(); | 123 | return dtStart(); |
126 | } | 124 | } |
127 | 125 | ||
128 | QString Event::dtEndTimeStr() const | 126 | QString Event::dtEndTimeStr() const |
129 | { | 127 | { |
130 | return KGlobal::locale()->formatTime(mDtEnd.time()); | 128 | return KGlobal::locale()->formatTime(mDtEnd.time()); |
131 | } | 129 | } |
132 | 130 | ||
133 | QString Event::dtEndDateStr(bool shortfmt) const | 131 | QString Event::dtEndDateStr(bool shortfmt) const |
134 | { | 132 | { |
135 | return KGlobal::locale()->formatDate(mDtEnd.date(),shortfmt); | 133 | return KGlobal::locale()->formatDate(mDtEnd.date(),shortfmt); |
136 | } | 134 | } |
137 | 135 | ||
138 | QString Event::dtEndStr(bool shortfmt) const | 136 | QString Event::dtEndStr(bool shortfmt) const |
139 | { | 137 | { |
140 | return KGlobal::locale()->formatDateTime(mDtEnd, shortfmt); | 138 | return KGlobal::locale()->formatDateTime(mDtEnd, shortfmt); |
141 | } | 139 | } |
142 | 140 | ||
143 | void Event::setHasEndDate(bool b) | 141 | void Event::setHasEndDate(bool b) |
144 | { | 142 | { |
145 | mHasEndDate = b; | 143 | mHasEndDate = b; |
146 | } | 144 | } |
147 | 145 | ||
148 | bool Event::hasEndDate() const | 146 | bool Event::hasEndDate() const |
149 | { | 147 | { |
150 | return mHasEndDate; | 148 | return mHasEndDate; |
151 | } | 149 | } |
152 | 150 | ||
153 | bool Event::isMultiDay() const | 151 | bool Event::isMultiDay() const |
154 | { | 152 | { |
155 | bool multi = !(dtStart().date() == dtEnd().date()); | 153 | bool multi = !(dtStart().date() == dtEnd().date()); |
156 | return multi; | 154 | return multi; |
157 | } | 155 | } |
158 | 156 | ||
159 | void Event::setTransparency(Event::Transparency transparency) | 157 | void Event::setTransparency(Event::Transparency transparency) |
160 | { | 158 | { |
161 | if (mReadOnly) return; | 159 | if (mReadOnly) return; |
162 | mTransparency = transparency; | 160 | mTransparency = transparency; |
163 | updated(); | 161 | updated(); |
164 | } | 162 | } |
165 | 163 | ||
166 | Event::Transparency Event::transparency() const | 164 | Event::Transparency Event::transparency() const |
167 | { | 165 | { |
168 | return mTransparency; | 166 | return mTransparency; |
169 | } | 167 | } |
170 | 168 | ||
171 | void Event::setDuration(int seconds) | 169 | void Event::setDuration(int seconds) |
172 | { | 170 | { |
173 | setHasEndDate(false); | 171 | setHasEndDate(false); |
174 | Incidence::setDuration(seconds); | 172 | Incidence::setDuration(seconds); |
175 | } | 173 | } |
176 | QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset ) const | 174 | QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset ) const |
177 | { | 175 | { |
178 | 176 | ||
179 | bool yes; | 177 | bool yes; |
180 | QDateTime incidenceStart = getNextOccurence( QDateTime::currentDateTime(), &yes ); | 178 | QDateTime incidenceStart = getNextOccurence( QDateTime::currentDateTime(), &yes ); |
181 | if ( ! yes || cancelled() ) { | 179 | if ( ! yes || cancelled() ) { |
182 | *ok = false; | 180 | *ok = false; |
183 | return QDateTime (); | 181 | return QDateTime (); |
184 | } | 182 | } |
185 | 183 | ||
186 | bool enabled = false; | 184 | bool enabled = false; |
187 | Alarm* alarm; | 185 | Alarm* alarm; |
188 | int off; | 186 | int off = 0; |
189 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; | 187 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; |
190 | // if ( QDateTime::currentDateTime() > incidenceStart ){ | 188 | // if ( QDateTime::currentDateTime() > incidenceStart ){ |
191 | // *ok = false; | 189 | // *ok = false; |
192 | // return incidenceStart; | 190 | // return incidenceStart; |
193 | // } | 191 | // } |
194 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 192 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
195 | if (alarm->enabled()) { | 193 | if (alarm->enabled()) { |
196 | if ( alarm->hasTime () ) { | 194 | if ( alarm->hasTime () ) { |
197 | if ( alarm->time() < alarmStart ) { | 195 | if ( alarm->time() < alarmStart ) { |
198 | alarmStart = alarm->time(); | 196 | alarmStart = alarm->time(); |
199 | enabled = true; | 197 | enabled = true; |
200 | off = alarmStart.secsTo( incidenceStart ); | 198 | off = alarmStart.secsTo( incidenceStart ); |
201 | } | 199 | } |
202 | 200 | ||
203 | } else { | 201 | } else { |
204 | int secs = alarm->startOffset().asSeconds(); | 202 | int secs = alarm->startOffset().asSeconds(); |
205 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { | 203 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { |
206 | alarmStart = incidenceStart.addSecs( secs ); | 204 | alarmStart = incidenceStart.addSecs( secs ); |
207 | enabled = true; | 205 | enabled = true; |
208 | off = -secs; | 206 | off = -secs; |
209 | } | 207 | } |
210 | } | 208 | } |
211 | } | 209 | } |
212 | } | 210 | } |
213 | if ( enabled ) { | 211 | if ( enabled ) { |
214 | if ( alarmStart > QDateTime::currentDateTime() ) { | 212 | if ( alarmStart > QDateTime::currentDateTime() ) { |
215 | *ok = true; | 213 | *ok = true; |
216 | * offset = off; | 214 | * offset = off; |
217 | return alarmStart; | 215 | return alarmStart; |
218 | } | 216 | } |
219 | } | 217 | } |
220 | *ok = false; | 218 | *ok = false; |
221 | return QDateTime (); | 219 | return QDateTime (); |
222 | 220 | ||
223 | } | 221 | } |
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index d81a68f..9c04a7e 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -1,414 +1,414 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library 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 GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <kglobal.h> | 21 | #include <kglobal.h> |
22 | #include <klocale.h> | 22 | #include <klocale.h> |
23 | #include <kdebug.h> | 23 | #include <kdebug.h> |
24 | 24 | ||
25 | #include "todo.h" | 25 | #include "todo.h" |
26 | 26 | ||
27 | using namespace KCal; | 27 | using namespace KCal; |
28 | 28 | ||
29 | Todo::Todo(): Incidence() | 29 | Todo::Todo(): Incidence() |
30 | { | 30 | { |
31 | // mStatus = TENTATIVE; | 31 | // mStatus = TENTATIVE; |
32 | 32 | ||
33 | mHasDueDate = false; | 33 | mHasDueDate = false; |
34 | setHasStartDate( false ); | 34 | setHasStartDate( false ); |
35 | mCompleted = getEvenTime(QDateTime::currentDateTime()); | 35 | mCompleted = getEvenTime(QDateTime::currentDateTime()); |
36 | mHasCompletedDate = false; | 36 | mHasCompletedDate = false; |
37 | mPercentComplete = 0; | 37 | mPercentComplete = 0; |
38 | } | 38 | } |
39 | 39 | ||
40 | Todo::Todo(const Todo &t) : Incidence(t) | 40 | Todo::Todo(const Todo &t) : Incidence(t) |
41 | { | 41 | { |
42 | mDtDue = t.mDtDue; | 42 | mDtDue = t.mDtDue; |
43 | mHasDueDate = t.mHasDueDate; | 43 | mHasDueDate = t.mHasDueDate; |
44 | mCompleted = t.mCompleted; | 44 | mCompleted = t.mCompleted; |
45 | mHasCompletedDate = t.mHasCompletedDate; | 45 | mHasCompletedDate = t.mHasCompletedDate; |
46 | mPercentComplete = t.mPercentComplete; | 46 | mPercentComplete = t.mPercentComplete; |
47 | } | 47 | } |
48 | 48 | ||
49 | Todo::~Todo() | 49 | Todo::~Todo() |
50 | { | 50 | { |
51 | 51 | ||
52 | } | 52 | } |
53 | 53 | ||
54 | Incidence *Todo::clone() | 54 | Incidence *Todo::clone() |
55 | { | 55 | { |
56 | return new Todo(*this); | 56 | return new Todo(*this); |
57 | } | 57 | } |
58 | 58 | ||
59 | bool Todo::contains ( Todo* from ) | 59 | bool Todo::contains ( Todo* from ) |
60 | { | 60 | { |
61 | 61 | ||
62 | if ( !from->summary().isEmpty() ) | 62 | if ( !from->summary().isEmpty() ) |
63 | if ( !summary().startsWith( from->summary() )) | 63 | if ( !summary().startsWith( from->summary() )) |
64 | return false; | 64 | return false; |
65 | if ( from->hasStartDate() ) { | 65 | if ( from->hasStartDate() ) { |
66 | if ( !hasStartDate() ) | 66 | if ( !hasStartDate() ) |
67 | return false; | 67 | return false; |
68 | if ( from->dtStart() != dtStart()) | 68 | if ( from->dtStart() != dtStart()) |
69 | return false; | 69 | return false; |
70 | } | 70 | } |
71 | if ( from->hasDueDate() ){ | 71 | if ( from->hasDueDate() ){ |
72 | if ( !hasDueDate() ) | 72 | if ( !hasDueDate() ) |
73 | return false; | 73 | return false; |
74 | if ( from->dtDue() != dtDue()) | 74 | if ( from->dtDue() != dtDue()) |
75 | return false; | 75 | return false; |
76 | } | 76 | } |
77 | if ( !from->location().isEmpty() ) | 77 | if ( !from->location().isEmpty() ) |
78 | if ( !location().startsWith( from->location() ) ) | 78 | if ( !location().startsWith( from->location() ) ) |
79 | return false; | 79 | return false; |
80 | if ( !from->description().isEmpty() ) | 80 | if ( !from->description().isEmpty() ) |
81 | if ( !description().startsWith( from->description() )) | 81 | if ( !description().startsWith( from->description() )) |
82 | return false; | 82 | return false; |
83 | if ( from->alarms().count() ) { | 83 | if ( from->alarms().count() ) { |
84 | Alarm *a = from->alarms().first(); | 84 | Alarm *a = from->alarms().first(); |
85 | if ( a->enabled() ){ | 85 | if ( a->enabled() ){ |
86 | if ( !alarms().count() ) | 86 | if ( !alarms().count() ) |
87 | return false; | 87 | return false; |
88 | Alarm *b = alarms().first(); | 88 | Alarm *b = alarms().first(); |
89 | if( ! b->enabled() ) | 89 | if( ! b->enabled() ) |
90 | return false; | 90 | return false; |
91 | if ( ! (a->offset() == b->offset() )) | 91 | if ( ! (a->offset() == b->offset() )) |
92 | return false; | 92 | return false; |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | QStringList cat = categories(); | 96 | QStringList cat = categories(); |
97 | QStringList catFrom = from->categories(); | 97 | QStringList catFrom = from->categories(); |
98 | QString nCat; | 98 | QString nCat; |
99 | int iii; | 99 | unsigned int iii; |
100 | for ( iii = 0; iii < catFrom.count();++iii ) { | 100 | for ( iii = 0; iii < catFrom.count();++iii ) { |
101 | nCat = catFrom[iii]; | 101 | nCat = catFrom[iii]; |
102 | if ( !nCat.isEmpty() ) | 102 | if ( !nCat.isEmpty() ) |
103 | if ( !cat.contains( nCat )) { | 103 | if ( !cat.contains( nCat )) { |
104 | return false; | 104 | return false; |
105 | } | 105 | } |
106 | } | 106 | } |
107 | if ( from->isCompleted() ) { | 107 | if ( from->isCompleted() ) { |
108 | if ( !isCompleted() ) | 108 | if ( !isCompleted() ) |
109 | return false; | 109 | return false; |
110 | } | 110 | } |
111 | if( priority() != from->priority() ) | 111 | if( priority() != from->priority() ) |
112 | return false; | 112 | return false; |
113 | 113 | ||
114 | 114 | ||
115 | return true; | 115 | return true; |
116 | 116 | ||
117 | } | 117 | } |
118 | bool KCal::operator==( const Todo& t1, const Todo& t2 ) | 118 | bool KCal::operator==( const Todo& t1, const Todo& t2 ) |
119 | { | 119 | { |
120 | 120 | ||
121 | bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); | 121 | bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); |
122 | if ( ! ret ) | 122 | if ( ! ret ) |
123 | return false; | 123 | return false; |
124 | if ( t1.hasDueDate() == t2.hasDueDate() ) { | 124 | if ( t1.hasDueDate() == t2.hasDueDate() ) { |
125 | if ( t1.hasDueDate() ) { | 125 | if ( t1.hasDueDate() ) { |
126 | if ( t1.doesFloat() == t2.doesFloat() ) { | 126 | if ( t1.doesFloat() == t2.doesFloat() ) { |
127 | if ( t1.doesFloat() ) { | 127 | if ( t1.doesFloat() ) { |
128 | if ( t1.dtDue().date() != t2.dtDue().date() ) | 128 | if ( t1.dtDue().date() != t2.dtDue().date() ) |
129 | return false; | 129 | return false; |
130 | } else | 130 | } else |
131 | if ( t1.dtDue() != t2.dtDue() ) | 131 | if ( t1.dtDue() != t2.dtDue() ) |
132 | return false; | 132 | return false; |
133 | } else | 133 | } else |
134 | return false;// float != | 134 | return false;// float != |
135 | } | 135 | } |
136 | 136 | ||
137 | } else | 137 | } else |
138 | return false; | 138 | return false; |
139 | if ( t1.percentComplete() != t2.percentComplete() ) | 139 | if ( t1.percentComplete() != t2.percentComplete() ) |
140 | return false; | 140 | return false; |
141 | if ( t1.isCompleted() ) { | 141 | if ( t1.isCompleted() ) { |
142 | if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { | 142 | if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { |
143 | if ( t1.hasCompletedDate() ) { | 143 | if ( t1.hasCompletedDate() ) { |
144 | if ( t1.completed() != t2.completed() ) | 144 | if ( t1.completed() != t2.completed() ) |
145 | return false; | 145 | return false; |
146 | } | 146 | } |
147 | 147 | ||
148 | } else | 148 | } else |
149 | return false; | 149 | return false; |
150 | } | 150 | } |
151 | return true; | 151 | return true; |
152 | 152 | ||
153 | } | 153 | } |
154 | 154 | ||
155 | void Todo::setDtDue(const QDateTime &dtDue) | 155 | void Todo::setDtDue(const QDateTime &dtDue) |
156 | { | 156 | { |
157 | //int diffsecs = mDtDue.secsTo(dtDue); | 157 | //int diffsecs = mDtDue.secsTo(dtDue); |
158 | 158 | ||
159 | /*if (mReadOnly) return; | 159 | /*if (mReadOnly) return; |
160 | const QPtrList<Alarm>& alarms = alarms(); | 160 | const QPtrList<Alarm>& alarms = alarms(); |
161 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { | 161 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { |
162 | if (alarm->enabled()) { | 162 | if (alarm->enabled()) { |
163 | alarm->setTime(alarm->time().addSecs(diffsecs)); | 163 | alarm->setTime(alarm->time().addSecs(diffsecs)); |
164 | } | 164 | } |
165 | }*/ | 165 | }*/ |
166 | mDtDue = getEvenTime(dtDue); | 166 | mDtDue = getEvenTime(dtDue); |
167 | 167 | ||
168 | //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl; | 168 | //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl; |
169 | 169 | ||
170 | /*const QPtrList<Alarm>& alarms = alarms(); | 170 | /*const QPtrList<Alarm>& alarms = alarms(); |
171 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) | 171 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) |
172 | alarm->setAlarmStart(mDtDue);*/ | 172 | alarm->setAlarmStart(mDtDue);*/ |
173 | 173 | ||
174 | updated(); | 174 | updated(); |
175 | } | 175 | } |
176 | 176 | ||
177 | QDateTime Todo::dtDue() const | 177 | QDateTime Todo::dtDue() const |
178 | { | 178 | { |
179 | return mDtDue; | 179 | return mDtDue; |
180 | } | 180 | } |
181 | 181 | ||
182 | QString Todo::dtDueTimeStr() const | 182 | QString Todo::dtDueTimeStr() const |
183 | { | 183 | { |
184 | return KGlobal::locale()->formatTime(mDtDue.time()); | 184 | return KGlobal::locale()->formatTime(mDtDue.time()); |
185 | } | 185 | } |
186 | 186 | ||
187 | QString Todo::dtDueDateStr(bool shortfmt) const | 187 | QString Todo::dtDueDateStr(bool shortfmt) const |
188 | { | 188 | { |
189 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); | 189 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); |
190 | } | 190 | } |
191 | 191 | ||
192 | QString Todo::dtDueStr(bool shortfmt) const | 192 | QString Todo::dtDueStr(bool shortfmt) const |
193 | { | 193 | { |
194 | return KGlobal::locale()->formatDateTime(mDtDue, shortfmt); | 194 | return KGlobal::locale()->formatDateTime(mDtDue, shortfmt); |
195 | } | 195 | } |
196 | // retval 0 : no found | 196 | // retval 0 : no found |
197 | // 1 : due for date found | 197 | // 1 : due for date found |
198 | // 2 : overdue for date found | 198 | // 2 : overdue for date found |
199 | int Todo::hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ) | 199 | int Todo::hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ) |
200 | { | 200 | { |
201 | int retval = 0; | 201 | int retval = 0; |
202 | if ( isCompleted() ) | 202 | if ( isCompleted() ) |
203 | return 0; | 203 | return 0; |
204 | if ( hasDueDate() ) { | 204 | if ( hasDueDate() ) { |
205 | if ( dtDue().date() < date ) | 205 | if ( dtDue().date() < date ) |
206 | return 2; | 206 | return 2; |
207 | // we do not return, because we may find an overdue sub todo | 207 | // we do not return, because we may find an overdue sub todo |
208 | if ( dtDue().date() == date ) | 208 | if ( dtDue().date() == date ) |
209 | retval = 1; | 209 | retval = 1; |
210 | } | 210 | } |
211 | if ( checkSubtodos ) { | 211 | if ( checkSubtodos ) { |
212 | Incidence *aTodo; | 212 | Incidence *aTodo; |
213 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { | 213 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { |
214 | int ret = ((Todo*)aTodo)->hasDueSubTodoForDate( date ,checkSubtodos ); | 214 | int ret = ((Todo*)aTodo)->hasDueSubTodoForDate( date ,checkSubtodos ); |
215 | if ( ret == 2 ) | 215 | if ( ret == 2 ) |
216 | return 2; | 216 | return 2; |
217 | if ( ret == 1) | 217 | if ( ret == 1) |
218 | retval = 1; | 218 | retval = 1; |
219 | } | 219 | } |
220 | } | 220 | } |
221 | return retval; | 221 | return retval; |
222 | } | 222 | } |
223 | int Todo::hasDueSubTodo( bool checkSubtodos ) //= true | 223 | int Todo::hasDueSubTodo( bool checkSubtodos ) //= true |
224 | { | 224 | { |
225 | return hasDueSubTodoForDate(QDate::currentDate(), checkSubtodos ); | 225 | return hasDueSubTodoForDate(QDate::currentDate(), checkSubtodos ); |
226 | } | 226 | } |
227 | bool Todo::hasDueDate() const | 227 | bool Todo::hasDueDate() const |
228 | { | 228 | { |
229 | return mHasDueDate; | 229 | return mHasDueDate; |
230 | } | 230 | } |
231 | 231 | ||
232 | void Todo::setHasDueDate(bool f) | 232 | void Todo::setHasDueDate(bool f) |
233 | { | 233 | { |
234 | if (mReadOnly) return; | 234 | if (mReadOnly) return; |
235 | mHasDueDate = f; | 235 | mHasDueDate = f; |
236 | updated(); | 236 | updated(); |
237 | } | 237 | } |
238 | 238 | ||
239 | 239 | ||
240 | #if 0 | 240 | #if 0 |
241 | void Todo::setStatus(const QString &statStr) | 241 | void Todo::setStatus(const QString &statStr) |
242 | { | 242 | { |
243 | if (mReadOnly) return; | 243 | if (mReadOnly) return; |
244 | QString ss(statStr.upper()); | 244 | QString ss(statStr.upper()); |
245 | 245 | ||
246 | if (ss == "X-ACTION") | 246 | if (ss == "X-ACTION") |
247 | mStatus = NEEDS_ACTION; | 247 | mStatus = NEEDS_ACTION; |
248 | else if (ss == "NEEDS ACTION") | 248 | else if (ss == "NEEDS ACTION") |
249 | mStatus = NEEDS_ACTION; | 249 | mStatus = NEEDS_ACTION; |
250 | else if (ss == "ACCEPTED") | 250 | else if (ss == "ACCEPTED") |
251 | mStatus = ACCEPTED; | 251 | mStatus = ACCEPTED; |
252 | else if (ss == "SENT") | 252 | else if (ss == "SENT") |
253 | mStatus = SENT; | 253 | mStatus = SENT; |
254 | else if (ss == "TENTATIVE") | 254 | else if (ss == "TENTATIVE") |
255 | mStatus = TENTATIVE; | 255 | mStatus = TENTATIVE; |
256 | else if (ss == "CONFIRMED") | 256 | else if (ss == "CONFIRMED") |
257 | mStatus = CONFIRMED; | 257 | mStatus = CONFIRMED; |
258 | else if (ss == "DECLINED") | 258 | else if (ss == "DECLINED") |
259 | mStatus = DECLINED; | 259 | mStatus = DECLINED; |
260 | else if (ss == "COMPLETED") | 260 | else if (ss == "COMPLETED") |
261 | mStatus = COMPLETED; | 261 | mStatus = COMPLETED; |
262 | else if (ss == "DELEGATED") | 262 | else if (ss == "DELEGATED") |
263 | mStatus = DELEGATED; | 263 | mStatus = DELEGATED; |
264 | 264 | ||
265 | updated(); | 265 | updated(); |
266 | } | 266 | } |
267 | 267 | ||
268 | void Todo::setStatus(int status) | 268 | void Todo::setStatus(int status) |
269 | { | 269 | { |
270 | if (mReadOnly) return; | 270 | if (mReadOnly) return; |
271 | mStatus = status; | 271 | mStatus = status; |
272 | updated(); | 272 | updated(); |
273 | } | 273 | } |
274 | 274 | ||
275 | int Todo::status() const | 275 | int Todo::status() const |
276 | { | 276 | { |
277 | return mStatus; | 277 | return mStatus; |
278 | } | 278 | } |
279 | 279 | ||
280 | QString Todo::statusStr() const | 280 | QString Todo::statusStr() const |
281 | { | 281 | { |
282 | switch(mStatus) { | 282 | switch(mStatus) { |
283 | case NEEDS_ACTION: | 283 | case NEEDS_ACTION: |
284 | return QString("NEEDS ACTION"); | 284 | return QString("NEEDS ACTION"); |
285 | break; | 285 | break; |
286 | case ACCEPTED: | 286 | case ACCEPTED: |
287 | return QString("ACCEPTED"); | 287 | return QString("ACCEPTED"); |
288 | break; | 288 | break; |
289 | case SENT: | 289 | case SENT: |
290 | return QString("SENT"); | 290 | return QString("SENT"); |
291 | break; | 291 | break; |
292 | case TENTATIVE: | 292 | case TENTATIVE: |
293 | return QString("TENTATIVE"); | 293 | return QString("TENTATIVE"); |
294 | break; | 294 | break; |
295 | case CONFIRMED: | 295 | case CONFIRMED: |
296 | return QString("CONFIRMED"); | 296 | return QString("CONFIRMED"); |
297 | break; | 297 | break; |
298 | case DECLINED: | 298 | case DECLINED: |
299 | return QString("DECLINED"); | 299 | return QString("DECLINED"); |
300 | break; | 300 | break; |
301 | case COMPLETED: | 301 | case COMPLETED: |
302 | return QString("COMPLETED"); | 302 | return QString("COMPLETED"); |
303 | break; | 303 | break; |
304 | case DELEGATED: | 304 | case DELEGATED: |
305 | return QString("DELEGATED"); | 305 | return QString("DELEGATED"); |
306 | break; | 306 | break; |
307 | } | 307 | } |
308 | return QString(""); | 308 | return QString(""); |
309 | } | 309 | } |
310 | #endif | 310 | #endif |
311 | 311 | ||
312 | bool Todo::isCompleted() const | 312 | bool Todo::isCompleted() const |
313 | { | 313 | { |
314 | if (mPercentComplete == 100) return true; | 314 | if (mPercentComplete == 100) return true; |
315 | else return false; | 315 | else return false; |
316 | } | 316 | } |
317 | 317 | ||
318 | void Todo::setCompleted(bool completed) | 318 | void Todo::setCompleted(bool completed) |
319 | { | 319 | { |
320 | if (completed) mPercentComplete = 100; | 320 | if (completed) mPercentComplete = 100; |
321 | else { | 321 | else { |
322 | mPercentComplete = 0; | 322 | mPercentComplete = 0; |
323 | mHasCompletedDate = false; | 323 | mHasCompletedDate = false; |
324 | } | 324 | } |
325 | updated(); | 325 | updated(); |
326 | } | 326 | } |
327 | 327 | ||
328 | QDateTime Todo::completed() const | 328 | QDateTime Todo::completed() const |
329 | { | 329 | { |
330 | return mCompleted; | 330 | return mCompleted; |
331 | } | 331 | } |
332 | 332 | ||
333 | QString Todo::completedStr( bool shortF ) const | 333 | QString Todo::completedStr( bool shortF ) const |
334 | { | 334 | { |
335 | return KGlobal::locale()->formatDateTime(mCompleted, shortF); | 335 | return KGlobal::locale()->formatDateTime(mCompleted, shortF); |
336 | } | 336 | } |
337 | 337 | ||
338 | void Todo::setCompleted(const QDateTime &completed) | 338 | void Todo::setCompleted(const QDateTime &completed) |
339 | { | 339 | { |
340 | //qDebug("Todo::setCompleted "); | 340 | //qDebug("Todo::setCompleted "); |
341 | if ( mHasCompletedDate ) { | 341 | if ( mHasCompletedDate ) { |
342 | // qDebug("has completed data - return "); | 342 | // qDebug("has completed data - return "); |
343 | return; | 343 | return; |
344 | } | 344 | } |
345 | mHasCompletedDate = true; | 345 | mHasCompletedDate = true; |
346 | mPercentComplete = 100; | 346 | mPercentComplete = 100; |
347 | mCompleted = getEvenTime(completed); | 347 | mCompleted = getEvenTime(completed); |
348 | updated(); | 348 | updated(); |
349 | } | 349 | } |
350 | 350 | ||
351 | bool Todo::hasCompletedDate() const | 351 | bool Todo::hasCompletedDate() const |
352 | { | 352 | { |
353 | return mHasCompletedDate; | 353 | return mHasCompletedDate; |
354 | } | 354 | } |
355 | 355 | ||
356 | int Todo::percentComplete() const | 356 | int Todo::percentComplete() const |
357 | { | 357 | { |
358 | return mPercentComplete; | 358 | return mPercentComplete; |
359 | } | 359 | } |
360 | 360 | ||
361 | void Todo::setPercentComplete(int v) | 361 | void Todo::setPercentComplete(int v) |
362 | { | 362 | { |
363 | mPercentComplete = v; | 363 | mPercentComplete = v; |
364 | if ( v != 100 ) | 364 | if ( v != 100 ) |
365 | mHasCompletedDate = false; | 365 | mHasCompletedDate = false; |
366 | updated(); | 366 | updated(); |
367 | } | 367 | } |
368 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const | 368 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const |
369 | { | 369 | { |
370 | if ( isCompleted() || ! hasDueDate() || cancelled() ) { | 370 | if ( isCompleted() || ! hasDueDate() || cancelled() ) { |
371 | *ok = false; | 371 | *ok = false; |
372 | return QDateTime (); | 372 | return QDateTime (); |
373 | } | 373 | } |
374 | QDateTime incidenceStart; | 374 | QDateTime incidenceStart; |
375 | incidenceStart = dtDue(); | 375 | incidenceStart = dtDue(); |
376 | bool enabled = false; | 376 | bool enabled = false; |
377 | Alarm* alarm; | 377 | Alarm* alarm; |
378 | int off; | 378 | int off = 0; |
379 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; | 379 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; |
380 | // if ( QDateTime::currentDateTime() > incidenceStart ){ | 380 | // if ( QDateTime::currentDateTime() > incidenceStart ){ |
381 | // *ok = false; | 381 | // *ok = false; |
382 | // return incidenceStart; | 382 | // return incidenceStart; |
383 | // } | 383 | // } |
384 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 384 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
385 | if (alarm->enabled()) { | 385 | if (alarm->enabled()) { |
386 | if ( alarm->hasTime () ) { | 386 | if ( alarm->hasTime () ) { |
387 | if ( alarm->time() < alarmStart ) { | 387 | if ( alarm->time() < alarmStart ) { |
388 | alarmStart = alarm->time(); | 388 | alarmStart = alarm->time(); |
389 | enabled = true; | 389 | enabled = true; |
390 | off = alarmStart.secsTo( incidenceStart ); | 390 | off = alarmStart.secsTo( incidenceStart ); |
391 | } | 391 | } |
392 | 392 | ||
393 | } else { | 393 | } else { |
394 | int secs = alarm->startOffset().asSeconds(); | 394 | int secs = alarm->startOffset().asSeconds(); |
395 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { | 395 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { |
396 | alarmStart = incidenceStart.addSecs( secs ); | 396 | alarmStart = incidenceStart.addSecs( secs ); |
397 | enabled = true; | 397 | enabled = true; |
398 | off = -secs; | 398 | off = -secs; |
399 | } | 399 | } |
400 | } | 400 | } |
401 | } | 401 | } |
402 | } | 402 | } |
403 | if ( enabled ) { | 403 | if ( enabled ) { |
404 | if ( alarmStart > QDateTime::currentDateTime() ) { | 404 | if ( alarmStart > QDateTime::currentDateTime() ) { |
405 | *ok = true; | 405 | *ok = true; |
406 | * offset = off; | 406 | * offset = off; |
407 | return alarmStart; | 407 | return alarmStart; |
408 | } | 408 | } |
409 | } | 409 | } |
410 | *ok = false; | 410 | *ok = false; |
411 | return QDateTime (); | 411 | return QDateTime (); |
412 | 412 | ||
413 | } | 413 | } |
414 | 414 | ||
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 3adbf61..df5a0d9 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -1,1485 +1,1484 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KDE-Pim/Pi. | 2 | This file is part of KDE-Pim/Pi. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library 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 GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | // $Id$ | 21 | // $Id$ |
22 | 22 | ||
23 | #include "ksyncmanager.h" | 23 | #include "ksyncmanager.h" |
24 | 24 | ||
25 | #include <stdlib.h> | 25 | #include <stdlib.h> |
26 | 26 | ||
27 | #ifndef _WIN32_ | 27 | #ifndef _WIN32_ |
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | 31 | ||
32 | #include "ksyncprofile.h" | 32 | #include "ksyncprofile.h" |
33 | #include "ksyncprefsdialog.h" | 33 | #include "ksyncprefsdialog.h" |
34 | #include "kpimprefs.h" | 34 | #include "kpimprefs.h" |
35 | #include <kmessagebox.h> | 35 | #include <kmessagebox.h> |
36 | 36 | ||
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | #include <qprogressbar.h> | 38 | #include <qprogressbar.h> |
39 | #include <qpopupmenu.h> | 39 | #include <qpopupmenu.h> |
40 | #include <qpushbutton.h> | 40 | #include <qpushbutton.h> |
41 | #include <qradiobutton.h> | 41 | #include <qradiobutton.h> |
42 | #include <qbuttongroup.h> | 42 | #include <qbuttongroup.h> |
43 | #include <qtimer.h> | 43 | #include <qtimer.h> |
44 | #include <qmessagebox.h> | 44 | #include <qmessagebox.h> |
45 | #include <qapplication.h> | 45 | #include <qapplication.h> |
46 | #include <qlineedit.h> | 46 | #include <qlineedit.h> |
47 | #include <qdialog.h> | 47 | #include <qdialog.h> |
48 | #include <qlayout.h> | 48 | #include <qlayout.h> |
49 | #include <qtextcodec.h> | 49 | #include <qtextcodec.h> |
50 | #include <qlabel.h> | 50 | #include <qlabel.h> |
51 | #include <qcheckbox.h> | 51 | #include <qcheckbox.h> |
52 | 52 | ||
53 | #include <klocale.h> | 53 | #include <klocale.h> |
54 | #include <kglobal.h> | 54 | #include <kglobal.h> |
55 | #include <kconfig.h> | 55 | #include <kconfig.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | 57 | ||
58 | QDateTime KSyncManager::mRequestedSyncEvent; | 58 | QDateTime KSyncManager::mRequestedSyncEvent; |
59 | 59 | ||
60 | 60 | ||
61 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) | 61 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) |
62 | : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu) | 62 | : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) |
63 | { | 63 | { |
64 | mServerSocket = 0; | 64 | mServerSocket = 0; |
65 | bar = new QProgressBar ( 1, 0 ); | 65 | bar = new QProgressBar ( 1, 0 ); |
66 | bar->setCaption (""); | 66 | bar->setCaption (""); |
67 | mWriteBackInPast = 2; | 67 | mWriteBackInPast = 2; |
68 | int w = 300; | 68 | int w = 300; |
69 | if ( QApplication::desktop()->width() < 320 ) | 69 | if ( QApplication::desktop()->width() < 320 ) |
70 | w = 220; | 70 | w = 220; |
71 | int h = bar->sizeHint().height() ; | 71 | int h = bar->sizeHint().height() ; |
72 | int dw = QApplication::desktop()->width(); | 72 | int dw = QApplication::desktop()->width(); |
73 | int dh = QApplication::desktop()->height(); | 73 | int dh = QApplication::desktop()->height(); |
74 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 74 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
75 | if ( mPrefs->mPassiveSyncAutoStart ) | 75 | if ( mPrefs->mPassiveSyncAutoStart ) |
76 | enableQuick( false ); | 76 | enableQuick( false ); |
77 | 77 | ||
78 | } | 78 | } |
79 | 79 | ||
80 | KSyncManager::~KSyncManager() | 80 | KSyncManager::~KSyncManager() |
81 | { | 81 | { |
82 | delete bar; | 82 | delete bar; |
83 | } | 83 | } |
84 | 84 | ||
85 | 85 | ||
86 | void KSyncManager::fillSyncMenu() | 86 | void KSyncManager::fillSyncMenu() |
87 | { | 87 | { |
88 | if ( mSyncMenu->count() ) | 88 | if ( mSyncMenu->count() ) |
89 | mSyncMenu->clear(); | 89 | mSyncMenu->clear(); |
90 | 90 | ||
91 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); | 91 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); |
92 | mSyncMenu->insertSeparator(); | 92 | mSyncMenu->insertSeparator(); |
93 | QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); | 93 | QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); |
94 | mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); | 94 | mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); |
95 | clearMenu->insertItem( i18n("For all profiles"), 1 ); | 95 | clearMenu->insertItem( i18n("For all profiles"), 1 ); |
96 | clearMenu->insertSeparator(); | 96 | clearMenu->insertSeparator(); |
97 | connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); | 97 | connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); |
98 | mSyncMenu->insertSeparator(); | 98 | mSyncMenu->insertSeparator(); |
99 | if ( mServerSocket == 0 ) { | 99 | if ( mServerSocket == 0 ) { |
100 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); | 100 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); |
101 | } else { | 101 | } else { |
102 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); | 102 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); |
103 | } | 103 | } |
104 | mSyncMenu->insertSeparator(); | 104 | mSyncMenu->insertSeparator(); |
105 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); | 105 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); |
106 | mSyncMenu->insertSeparator(); | 106 | mSyncMenu->insertSeparator(); |
107 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 107 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
108 | config.setGroup("General"); | 108 | config.setGroup("General"); |
109 | QStringList prof = config.readListEntry("SyncProfileNames"); | 109 | QStringList prof = config.readListEntry("SyncProfileNames"); |
110 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 110 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
111 | if ( prof.count() < 2 ) { | 111 | if ( prof.count() < 2 ) { |
112 | prof.clear(); | 112 | prof.clear(); |
113 | QString externalName; | 113 | QString externalName; |
114 | #ifdef DESKTOP_VERSION | 114 | #ifdef DESKTOP_VERSION |
115 | #ifdef _WIN32_ | 115 | #ifdef _WIN32_ |
116 | externalName = "OutLook(not_implemented)"; | 116 | externalName = "OutLook(not_implemented)"; |
117 | #else | 117 | #else |
118 | externalName = "KDE_Desktop"; | 118 | externalName = "KDE_Desktop"; |
119 | #endif | 119 | #endif |
120 | #else | 120 | #else |
121 | externalName = "Sharp_DTM"; | 121 | externalName = "Sharp_DTM"; |
122 | #endif | 122 | #endif |
123 | prof << externalName; | 123 | prof << externalName; |
124 | prof << i18n("Local_file"); | 124 | prof << i18n("Local_file"); |
125 | prof << i18n("Last_file"); | 125 | prof << i18n("Last_file"); |
126 | KSyncProfile* temp = new KSyncProfile (); | 126 | KSyncProfile* temp = new KSyncProfile (); |
127 | temp->setName( prof[0] ); | 127 | temp->setName( prof[0] ); |
128 | temp->writeConfig(&config); | 128 | temp->writeConfig(&config); |
129 | temp->setName( prof[1] ); | 129 | temp->setName( prof[1] ); |
130 | temp->writeConfig(&config); | 130 | temp->writeConfig(&config); |
131 | temp->setName( prof[2] ); | 131 | temp->setName( prof[2] ); |
132 | temp->writeConfig(&config); | 132 | temp->writeConfig(&config); |
133 | config.setGroup("General"); | 133 | config.setGroup("General"); |
134 | config.writeEntry("SyncProfileNames",prof); | 134 | config.writeEntry("SyncProfileNames",prof); |
135 | config.writeEntry("ExternSyncProfiles",externalName); | 135 | config.writeEntry("ExternSyncProfiles",externalName); |
136 | config.sync(); | 136 | config.sync(); |
137 | delete temp; | 137 | delete temp; |
138 | } | 138 | } |
139 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 139 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
140 | mSyncProfileNames = prof; | 140 | mSyncProfileNames = prof; |
141 | unsigned int i; | 141 | unsigned int i; |
142 | for ( i = 0; i < prof.count(); ++i ) { | 142 | for ( i = 0; i < prof.count(); ++i ) { |
143 | mSyncMenu->insertItem( prof[i], 1000+i ); | 143 | mSyncMenu->insertItem( prof[i], 1000+i ); |
144 | clearMenu->insertItem( prof[i], 1000+i ); | 144 | clearMenu->insertItem( prof[i], 1000+i ); |
145 | if ( i == 2 ) | 145 | if ( i == 2 ) |
146 | mSyncMenu->insertSeparator(); | 146 | mSyncMenu->insertSeparator(); |
147 | } | 147 | } |
148 | QDir app_dir; | 148 | QDir app_dir; |
149 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available | 149 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available |
150 | if ( mTargetApp == PWMPI) { | 150 | if ( mTargetApp == PWMPI) { |
151 | mSyncMenu->removeItem( 1000 ); | 151 | mSyncMenu->removeItem( 1000 ); |
152 | clearMenu->removeItem( 1000 ); | 152 | clearMenu->removeItem( 1000 ); |
153 | } | 153 | } |
154 | #ifndef DESKTOP_VERSION | 154 | #ifndef DESKTOP_VERSION |
155 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 155 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
156 | mSyncMenu->removeItem( 1000 ); | 156 | mSyncMenu->removeItem( 1000 ); |
157 | clearMenu->removeItem( 1000 ); | 157 | clearMenu->removeItem( 1000 ); |
158 | } | 158 | } |
159 | #endif | 159 | #endif |
160 | mSyncMenu->removeItem( 1002 ); | 160 | mSyncMenu->removeItem( 1002 ); |
161 | clearMenu->removeItem( 1002 ); | 161 | clearMenu->removeItem( 1002 ); |
162 | } | 162 | } |
163 | void KSyncManager::slotClearMenu( int action ) | 163 | void KSyncManager::slotClearMenu( int action ) |
164 | { | 164 | { |
165 | QString syncDevice; | 165 | QString syncDevice; |
166 | if ( action > 999 ) { | 166 | if ( action > 999 ) { |
167 | syncDevice = mSyncProfileNames[action - 1000] ; | 167 | syncDevice = mSyncProfileNames[action - 1000] ; |
168 | } | 168 | } |
169 | 169 | ||
170 | 170 | ||
171 | 171 | ||
172 | int result = 0; | 172 | int result = 0; |
173 | QString sd; | 173 | QString sd; |
174 | if ( syncDevice.isEmpty() ) | 174 | if ( syncDevice.isEmpty() ) |
175 | sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); | 175 | sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); |
176 | else | 176 | else |
177 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); | 177 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); |
178 | 178 | ||
179 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, | 179 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, |
180 | 0, 1 ); | 180 | 0, 1 ); |
181 | if ( result ) | 181 | if ( result ) |
182 | return; | 182 | return; |
183 | mImplementation->removeSyncInfo( syncDevice ); | 183 | mImplementation->removeSyncInfo( syncDevice ); |
184 | } | 184 | } |
185 | void KSyncManager::slotSyncMenu( int action ) | 185 | void KSyncManager::slotSyncMenu( int action ) |
186 | { | 186 | { |
187 | qDebug("KSM::syncaction %d ", action); | 187 | qDebug("KSM::syncaction %d ", action); |
188 | if ( action == 5000 ) | 188 | if ( action == 5000 ) |
189 | return; | 189 | return; |
190 | mSyncWithDesktop = false; | 190 | mSyncWithDesktop = false; |
191 | if ( action == 0 ) { | 191 | if ( action == 0 ) { |
192 | 192 | ||
193 | // seems to be a Qt2 event handling bug | 193 | // seems to be a Qt2 event handling bug |
194 | // syncmenu.clear causes a segfault at first time | 194 | // syncmenu.clear causes a segfault at first time |
195 | // when we call it after the main event loop, it is ok | 195 | // when we call it after the main event loop, it is ok |
196 | // same behaviour when calling OM/Pi via QCOP for the first time | 196 | // same behaviour when calling OM/Pi via QCOP for the first time |
197 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 197 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
198 | //confSync(); | 198 | //confSync(); |
199 | 199 | ||
200 | return; | 200 | return; |
201 | } | 201 | } |
202 | if ( action == 1 ) { | 202 | if ( action == 1 ) { |
203 | multiSync( true ); | 203 | multiSync( true ); |
204 | return; | 204 | return; |
205 | } | 205 | } |
206 | if ( action == 2 ) { | 206 | if ( action == 2 ) { |
207 | enableQuick(); | 207 | enableQuick(); |
208 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 208 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
209 | return; | 209 | return; |
210 | } | 210 | } |
211 | if ( action == 3 ) { | 211 | if ( action == 3 ) { |
212 | delete mServerSocket; | 212 | delete mServerSocket; |
213 | mServerSocket = 0; | 213 | mServerSocket = 0; |
214 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 214 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
215 | return; | 215 | return; |
216 | } | 216 | } |
217 | 217 | ||
218 | if (blockSave()) | 218 | if (blockSave()) |
219 | return; | 219 | return; |
220 | 220 | ||
221 | setBlockSave(true); | 221 | setBlockSave(true); |
222 | bool silent = false; | 222 | bool silent = false; |
223 | if ( action == 999 ) { | 223 | if ( action == 999 ) { |
224 | //special mode for silent syncing | 224 | //special mode for silent syncing |
225 | action = 1000; | 225 | action = 1000; |
226 | silent = true; | 226 | silent = true; |
227 | } | 227 | } |
228 | 228 | ||
229 | mCurrentSyncProfile = action - 1000 ; | 229 | mCurrentSyncProfile = action - 1000 ; |
230 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; | 230 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; |
231 | mCurrentSyncName = mLocalMachineName ; | 231 | mCurrentSyncName = mLocalMachineName ; |
232 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 232 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
233 | KSyncProfile* temp = new KSyncProfile (); | 233 | KSyncProfile* temp = new KSyncProfile (); |
234 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); | 234 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); |
235 | temp->readConfig(&config); | 235 | temp->readConfig(&config); |
236 | if (silent) { | 236 | if (silent) { |
237 | mAskForPreferences = false; | 237 | mAskForPreferences = false; |
238 | mShowSyncSummary = false; | 238 | mShowSyncSummary = false; |
239 | mWriteBackFile = true; | 239 | mWriteBackFile = true; |
240 | mSyncAlgoPrefs = 2;// take newest | 240 | mSyncAlgoPrefs = 2;// take newest |
241 | } | 241 | } |
242 | else { | 242 | else { |
243 | mAskForPreferences = temp->getAskForPreferences(); | 243 | mAskForPreferences = temp->getAskForPreferences(); |
244 | mShowSyncSummary = temp->getShowSummaryAfterSync(); | 244 | mShowSyncSummary = temp->getShowSummaryAfterSync(); |
245 | mWriteBackFile = temp->getWriteBackFile(); | 245 | mWriteBackFile = temp->getWriteBackFile(); |
246 | mSyncAlgoPrefs = temp->getSyncPrefs(); | 246 | mSyncAlgoPrefs = temp->getSyncPrefs(); |
247 | } | 247 | } |
248 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 248 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
249 | mIsKapiFile = temp->getIsKapiFile(); | 249 | mIsKapiFile = temp->getIsKapiFile(); |
250 | mWriteBackInFuture = 0; | 250 | mWriteBackInFuture = 0; |
251 | if ( temp->getWriteBackFuture() ) { | 251 | if ( temp->getWriteBackFuture() ) { |
252 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 252 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
253 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); | 253 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); |
254 | } | 254 | } |
255 | mFilterInCal = temp->getFilterInCal(); | 255 | mFilterInCal = temp->getFilterInCal(); |
256 | mFilterOutCal = temp->getFilterOutCal(); | 256 | mFilterOutCal = temp->getFilterOutCal(); |
257 | mFilterInAB = temp->getFilterInAB(); | 257 | mFilterInAB = temp->getFilterInAB(); |
258 | mFilterOutAB = temp->getFilterOutAB(); | 258 | mFilterOutAB = temp->getFilterOutAB(); |
259 | 259 | ||
260 | if ( action == 1000 ) { | 260 | if ( action == 1000 ) { |
261 | mIsKapiFile = false; | 261 | mIsKapiFile = false; |
262 | #ifdef DESKTOP_VERSION | 262 | #ifdef DESKTOP_VERSION |
263 | syncKDE(); | 263 | syncKDE(); |
264 | #else | 264 | #else |
265 | syncSharp(); | 265 | syncSharp(); |
266 | #endif | 266 | #endif |
267 | 267 | ||
268 | } else if ( action == 1001 ) { | 268 | } else if ( action == 1001 ) { |
269 | syncLocalFile(); | 269 | syncLocalFile(); |
270 | 270 | ||
271 | } else if ( action == 1002 ) { | 271 | } else if ( action == 1002 ) { |
272 | mWriteBackFile = false; | 272 | mWriteBackFile = false; |
273 | mAskForPreferences = false; | 273 | mAskForPreferences = false; |
274 | mShowSyncSummary = false; | 274 | mShowSyncSummary = false; |
275 | mSyncAlgoPrefs = 3; | 275 | mSyncAlgoPrefs = 3; |
276 | quickSyncLocalFile(); | 276 | quickSyncLocalFile(); |
277 | 277 | ||
278 | } else if ( action >= 1003 ) { | 278 | } else if ( action >= 1003 ) { |
279 | if ( temp->getIsLocalFileSync() ) { | 279 | if ( temp->getIsLocalFileSync() ) { |
280 | switch(mTargetApp) | 280 | switch(mTargetApp) |
281 | { | 281 | { |
282 | case (KAPI): | 282 | case (KAPI): |
283 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 283 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
284 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 284 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
285 | break; | 285 | break; |
286 | case (KOPI): | 286 | case (KOPI): |
287 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 287 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
288 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 288 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
289 | break; | 289 | break; |
290 | case (PWMPI): | 290 | case (PWMPI): |
291 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 291 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
292 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 292 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
293 | break; | 293 | break; |
294 | default: | 294 | default: |
295 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); | 295 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); |
296 | break; | 296 | break; |
297 | 297 | ||
298 | } | 298 | } |
299 | } else { | 299 | } else { |
300 | if ( temp->getIsPhoneSync() ) { | 300 | if ( temp->getIsPhoneSync() ) { |
301 | mPhoneDevice = temp->getPhoneDevice( ) ; | 301 | mPhoneDevice = temp->getPhoneDevice( ) ; |
302 | mPhoneConnection = temp->getPhoneConnection( ); | 302 | mPhoneConnection = temp->getPhoneConnection( ); |
303 | mPhoneModel = temp->getPhoneModel( ); | 303 | mPhoneModel = temp->getPhoneModel( ); |
304 | syncPhone(); | 304 | syncPhone(); |
305 | } else if ( temp->getIsPiSync() ) { | 305 | } else if ( temp->getIsPiSync() ) { |
306 | if ( mTargetApp == KAPI ) { | 306 | if ( mTargetApp == KAPI ) { |
307 | mPassWordPiSync = temp->getRemotePwAB(); | 307 | mPassWordPiSync = temp->getRemotePwAB(); |
308 | mActiveSyncPort = temp->getRemotePortAB(); | 308 | mActiveSyncPort = temp->getRemotePortAB(); |
309 | mActiveSyncIP = temp->getRemoteIPAB(); | 309 | mActiveSyncIP = temp->getRemoteIPAB(); |
310 | } else if ( mTargetApp == KOPI ) { | 310 | } else if ( mTargetApp == KOPI ) { |
311 | mPassWordPiSync = temp->getRemotePw(); | 311 | mPassWordPiSync = temp->getRemotePw(); |
312 | mActiveSyncPort = temp->getRemotePort(); | 312 | mActiveSyncPort = temp->getRemotePort(); |
313 | mActiveSyncIP = temp->getRemoteIP(); | 313 | mActiveSyncIP = temp->getRemoteIP(); |
314 | } else { | 314 | } else { |
315 | mPassWordPiSync = temp->getRemotePwPWM(); | 315 | mPassWordPiSync = temp->getRemotePwPWM(); |
316 | mActiveSyncPort = temp->getRemotePortPWM(); | 316 | mActiveSyncPort = temp->getRemotePortPWM(); |
317 | mActiveSyncIP = temp->getRemoteIPPWM(); | 317 | mActiveSyncIP = temp->getRemoteIPPWM(); |
318 | } | 318 | } |
319 | syncPi(); | 319 | syncPi(); |
320 | while ( !mPisyncFinished ) { | 320 | while ( !mPisyncFinished ) { |
321 | //qDebug("waiting "); | 321 | //qDebug("waiting "); |
322 | qApp->processEvents(); | 322 | qApp->processEvents(); |
323 | } | 323 | } |
324 | } else | 324 | } else |
325 | syncRemote( temp ); | 325 | syncRemote( temp ); |
326 | 326 | ||
327 | } | 327 | } |
328 | } | 328 | } |
329 | delete temp; | 329 | delete temp; |
330 | setBlockSave(false); | 330 | setBlockSave(false); |
331 | } | 331 | } |
332 | 332 | ||
333 | void KSyncManager::enableQuick( bool ask ) | 333 | void KSyncManager::enableQuick( bool ask ) |
334 | { | 334 | { |
335 | bool autoStart; | 335 | bool autoStart; |
336 | bool changed = false; | 336 | bool changed = false; |
337 | if ( ask ) { | 337 | if ( ask ) { |
338 | QDialog dia ( 0, "input-dialog", true ); | 338 | QDialog dia ( 0, "input-dialog", true ); |
339 | QLineEdit lab ( &dia ); | 339 | QLineEdit lab ( &dia ); |
340 | QVBoxLayout lay( &dia ); | 340 | QVBoxLayout lay( &dia ); |
341 | lab.setText( mPrefs->mPassiveSyncPort ); | 341 | lab.setText( mPrefs->mPassiveSyncPort ); |
342 | lay.setMargin(7); | 342 | lay.setMargin(7); |
343 | lay.setSpacing(7); | 343 | lay.setSpacing(7); |
344 | int po = 9197+mTargetApp; | 344 | int po = 9197+mTargetApp; |
345 | QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); | 345 | QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); |
346 | lay.addWidget( &label); | 346 | lay.addWidget( &label); |
347 | lay.addWidget( &lab); | 347 | lay.addWidget( &lab); |
348 | 348 | ||
349 | QLineEdit lepw ( &dia ); | 349 | QLineEdit lepw ( &dia ); |
350 | lepw.setText( mPrefs->mPassiveSyncPw ); | 350 | lepw.setText( mPrefs->mPassiveSyncPw ); |
351 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); | 351 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); |
352 | lay.addWidget( &label2); | 352 | lay.addWidget( &label2); |
353 | lay.addWidget( &lepw); | 353 | lay.addWidget( &lepw); |
354 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); | 354 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); |
355 | lay.addWidget( &autostart); | 355 | lay.addWidget( &autostart); |
356 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); | 356 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); |
357 | #ifdef DESKTOP_VERSION | 357 | #ifdef DESKTOP_VERSION |
358 | #ifdef _WIN32_ | 358 | #ifdef _WIN32_ |
359 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); | 359 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); |
360 | syncdesktop.hide();// not implemented! | 360 | syncdesktop.hide();// not implemented! |
361 | #else | 361 | #else |
362 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); | 362 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); |
363 | #endif | 363 | #endif |
364 | lay.addWidget( &syncdesktop); | 364 | lay.addWidget( &syncdesktop); |
365 | #else | 365 | #else |
366 | mPrefs->mPassiveSyncWithDesktop = false; | 366 | mPrefs->mPassiveSyncWithDesktop = false; |
367 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); | 367 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); |
368 | syncdesktop.hide(); | 368 | syncdesktop.hide(); |
369 | #endif | 369 | #endif |
370 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); | 370 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); |
371 | 371 | ||
372 | dia.setFixedSize( 230,120 ); | 372 | dia.setFixedSize( 230,120 ); |
373 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | 373 | dia.setCaption( i18n("Enter port for Pi-Sync") ); |
374 | QPushButton pb ( "OK", &dia); | 374 | QPushButton pb ( "OK", &dia); |
375 | lay.addWidget( &pb ); | 375 | lay.addWidget( &pb ); |
376 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 376 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
377 | dia.show(); | 377 | dia.show(); |
378 | if ( ! dia.exec() ) | 378 | if ( ! dia.exec() ) |
379 | return; | 379 | return; |
380 | dia.hide(); | 380 | dia.hide(); |
381 | qApp->processEvents(); | 381 | qApp->processEvents(); |
382 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { | 382 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { |
383 | changed = true; | 383 | changed = true; |
384 | mPrefs->mPassiveSyncPw = lepw.text(); | 384 | mPrefs->mPassiveSyncPw = lepw.text(); |
385 | } | 385 | } |
386 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { | 386 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { |
387 | mPrefs->mPassiveSyncPort = lab.text(); | 387 | mPrefs->mPassiveSyncPort = lab.text(); |
388 | changed = true; | 388 | changed = true; |
389 | } | 389 | } |
390 | autoStart = autostart.isChecked(); | 390 | autoStart = autostart.isChecked(); |
391 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { | 391 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { |
392 | changed = true; | 392 | changed = true; |
393 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); | 393 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); |
394 | } | 394 | } |
395 | } | 395 | } |
396 | else | 396 | else |
397 | autoStart = mPrefs->mPassiveSyncAutoStart; | 397 | autoStart = mPrefs->mPassiveSyncAutoStart; |
398 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) | 398 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) |
399 | changed = true; | 399 | changed = true; |
400 | bool ok; | 400 | bool ok; |
401 | mPrefs->mPassiveSyncAutoStart = false; | 401 | mPrefs->mPassiveSyncAutoStart = false; |
402 | Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); | 402 | Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); |
403 | if ( ! ok ) { | 403 | if ( ! ok ) { |
404 | KMessageBox::information( 0, i18n("No valid port")); | 404 | KMessageBox::information( 0, i18n("No valid port")); |
405 | return; | 405 | return; |
406 | } | 406 | } |
407 | //qDebug("port %d ", port); | 407 | //qDebug("port %d ", port); |
408 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); | 408 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); |
409 | mServerSocket->setFileName( defaultFileName() );//bbb | 409 | mServerSocket->setFileName( defaultFileName() );//bbb |
410 | //qDebug("connected "); | 410 | //qDebug("connected "); |
411 | if ( !mServerSocket->ok() ) { | 411 | if ( !mServerSocket->ok() ) { |
412 | KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); | 412 | KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); |
413 | delete mServerSocket; | 413 | delete mServerSocket; |
414 | mServerSocket = 0; | 414 | mServerSocket = 0; |
415 | return; | 415 | return; |
416 | } | 416 | } |
417 | mPrefs->mPassiveSyncAutoStart = autoStart; | 417 | mPrefs->mPassiveSyncAutoStart = autoStart; |
418 | if ( changed ) { | 418 | if ( changed ) { |
419 | mPrefs->writeConfig(); | 419 | mPrefs->writeConfig(); |
420 | } | 420 | } |
421 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); | 421 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); |
422 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); | 422 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); |
423 | } | 423 | } |
424 | 424 | ||
425 | void KSyncManager::syncLocalFile() | 425 | void KSyncManager::syncLocalFile() |
426 | { | 426 | { |
427 | 427 | ||
428 | QString fn =mPrefs->mLastSyncedLocalFile; | 428 | QString fn =mPrefs->mLastSyncedLocalFile; |
429 | QString ext; | 429 | QString ext; |
430 | 430 | ||
431 | switch(mTargetApp) | 431 | switch(mTargetApp) |
432 | { | 432 | { |
433 | case (KAPI): | 433 | case (KAPI): |
434 | ext = "(*.vcf)"; | 434 | ext = "(*.vcf)"; |
435 | break; | 435 | break; |
436 | case (KOPI): | 436 | case (KOPI): |
437 | ext = "(*.ics/*.vcs)"; | 437 | ext = "(*.ics/*.vcs)"; |
438 | break; | 438 | break; |
439 | case (PWMPI): | 439 | case (PWMPI): |
440 | ext = "(*.pwm)"; | 440 | ext = "(*.pwm)"; |
441 | break; | 441 | break; |
442 | default: | 442 | default: |
443 | qDebug("KSM::syncLocalFile: invalid apptype selected"); | 443 | qDebug("KSM::syncLocalFile: invalid apptype selected"); |
444 | break; | 444 | break; |
445 | 445 | ||
446 | } | 446 | } |
447 | 447 | ||
448 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); | 448 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); |
449 | if ( fn == "" ) | 449 | if ( fn == "" ) |
450 | return; | 450 | return; |
451 | if ( syncWithFile( fn, false ) ) { | 451 | if ( syncWithFile( fn, false ) ) { |
452 | qDebug("KSM::syncLocalFile() successful "); | 452 | qDebug("KSM::syncLocalFile() successful "); |
453 | } | 453 | } |
454 | 454 | ||
455 | } | 455 | } |
456 | 456 | ||
457 | bool KSyncManager::syncWithFile( QString fn , bool quick ) | 457 | bool KSyncManager::syncWithFile( QString fn , bool quick ) |
458 | { | 458 | { |
459 | bool ret = false; | 459 | bool ret = false; |
460 | QFileInfo info; | 460 | QFileInfo info; |
461 | info.setFile( fn ); | 461 | info.setFile( fn ); |
462 | QString mess; | 462 | QString mess; |
463 | bool loadbup = true; | ||
464 | if ( !info. exists() ) { | 463 | if ( !info. exists() ) { |
465 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 464 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
466 | int result = QMessageBox::warning( mParent, i18n("Warning!"), | 465 | QMessageBox::warning( mParent, i18n("Warning!"), |
467 | mess ); | 466 | mess ); |
468 | return ret; | 467 | return ret; |
469 | } | 468 | } |
470 | int result = 0; | 469 | int result = 0; |
471 | if ( !quick ) { | 470 | if ( !quick ) { |
472 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 471 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
473 | result = QMessageBox::warning( mParent, i18n("Warning!"), | 472 | result = QMessageBox::warning( mParent, i18n("Warning!"), |
474 | mess, | 473 | mess, |
475 | i18n("Sync"), i18n("Cancel"), 0, | 474 | i18n("Sync"), i18n("Cancel"), 0, |
476 | 0, 1 ); | 475 | 0, 1 ); |
477 | if ( result ) | 476 | if ( result ) |
478 | return false; | 477 | return false; |
479 | } | 478 | } |
480 | if ( mAskForPreferences ) | 479 | if ( mAskForPreferences ) |
481 | if ( !edit_sync_options()) { | 480 | if ( !edit_sync_options()) { |
482 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 481 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
483 | return false; | 482 | return false; |
484 | } | 483 | } |
485 | if ( result == 0 ) { | 484 | if ( result == 0 ) { |
486 | //qDebug("Now sycing ... "); | 485 | //qDebug("Now sycing ... "); |
487 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) | 486 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) |
488 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); | 487 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); |
489 | else | 488 | else |
490 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 489 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
491 | if ( ! quick ) | 490 | if ( ! quick ) |
492 | mPrefs->mLastSyncedLocalFile = fn; | 491 | mPrefs->mLastSyncedLocalFile = fn; |
493 | } | 492 | } |
494 | return ret; | 493 | return ret; |
495 | } | 494 | } |
496 | 495 | ||
497 | void KSyncManager::quickSyncLocalFile() | 496 | void KSyncManager::quickSyncLocalFile() |
498 | { | 497 | { |
499 | 498 | ||
500 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { | 499 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { |
501 | qDebug("KSM::quick syncLocalFile() successful "); | 500 | qDebug("KSM::quick syncLocalFile() successful "); |
502 | 501 | ||
503 | } | 502 | } |
504 | } | 503 | } |
505 | 504 | ||
506 | void KSyncManager::multiSync( bool askforPrefs ) | 505 | void KSyncManager::multiSync( bool askforPrefs ) |
507 | { | 506 | { |
508 | if (blockSave()) | 507 | if (blockSave()) |
509 | return; | 508 | return; |
510 | setBlockSave(true); | 509 | setBlockSave(true); |
511 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 510 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
512 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), | 511 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), |
513 | question, | 512 | question, |
514 | i18n("Yes"), i18n("No"), | 513 | i18n("Yes"), i18n("No"), |
515 | 0, 0 ) != 0 ) { | 514 | 0, 0 ) != 0 ) { |
516 | setBlockSave(false); | 515 | setBlockSave(false); |
517 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); | 516 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); |
518 | return; | 517 | return; |
519 | } | 518 | } |
520 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 519 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
521 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; | 520 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; |
522 | if ( askforPrefs ) { | 521 | if ( askforPrefs ) { |
523 | if ( !edit_sync_options()) { | 522 | if ( !edit_sync_options()) { |
524 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); | 523 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); |
525 | return; | 524 | return; |
526 | } | 525 | } |
527 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; | 526 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; |
528 | } | 527 | } |
529 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); | 528 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); |
530 | qApp->processEvents(); | 529 | qApp->processEvents(); |
531 | int num = ringSync() ; | 530 | int num = ringSync() ; |
532 | if ( num > 1 ) | 531 | if ( num > 1 ) |
533 | ringSync(); | 532 | ringSync(); |
534 | setBlockSave(false); | 533 | setBlockSave(false); |
535 | if ( num ) | 534 | if ( num ) |
536 | emit save(); | 535 | emit save(); |
537 | if ( num ) | 536 | if ( num ) |
538 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); | 537 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); |
539 | else | 538 | else |
540 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 539 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
541 | return; | 540 | return; |
542 | } | 541 | } |
543 | 542 | ||
544 | int KSyncManager::ringSync() | 543 | int KSyncManager::ringSync() |
545 | { | 544 | { |
546 | 545 | ||
547 | int syncedProfiles = 0; | 546 | int syncedProfiles = 0; |
548 | unsigned int i; | 547 | unsigned int i; |
549 | QTime timer; | 548 | QTime timer; |
550 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 549 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
551 | QStringList syncProfileNames = mSyncProfileNames; | 550 | QStringList syncProfileNames = mSyncProfileNames; |
552 | KSyncProfile* temp = new KSyncProfile (); | 551 | KSyncProfile* temp = new KSyncProfile (); |
553 | mAskForPreferences = false; | 552 | mAskForPreferences = false; |
554 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 553 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
555 | mCurrentSyncProfile = i; | 554 | mCurrentSyncProfile = i; |
556 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 555 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
557 | temp->readConfig(&config); | 556 | temp->readConfig(&config); |
558 | 557 | ||
559 | bool includeInRingSync; | 558 | bool includeInRingSync = false; |
560 | switch(mTargetApp) | 559 | switch(mTargetApp) |
561 | { | 560 | { |
562 | case (KAPI): | 561 | case (KAPI): |
563 | includeInRingSync = temp->getIncludeInRingSyncAB(); | 562 | includeInRingSync = temp->getIncludeInRingSyncAB(); |
564 | break; | 563 | break; |
565 | case (KOPI): | 564 | case (KOPI): |
566 | includeInRingSync = temp->getIncludeInRingSync(); | 565 | includeInRingSync = temp->getIncludeInRingSync(); |
567 | break; | 566 | break; |
568 | case (PWMPI): | 567 | case (PWMPI): |
569 | includeInRingSync = temp->getIncludeInRingSyncPWM(); | 568 | includeInRingSync = temp->getIncludeInRingSyncPWM(); |
570 | break; | 569 | break; |
571 | default: | 570 | default: |
572 | qDebug("KSM::ringSync: invalid apptype selected"); | 571 | qDebug("KSM::ringSync: invalid apptype selected"); |
573 | break; | 572 | break; |
574 | 573 | ||
575 | } | 574 | } |
576 | 575 | ||
577 | 576 | ||
578 | if ( includeInRingSync && ( i < 1 || i > 2 )) { | 577 | if ( includeInRingSync && ( i < 1 || i > 2 )) { |
579 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 578 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
580 | ++syncedProfiles; | 579 | ++syncedProfiles; |
581 | mSyncWithDesktop = false; | 580 | mSyncWithDesktop = false; |
582 | // mAskForPreferences = temp->getAskForPreferences(); | 581 | // mAskForPreferences = temp->getAskForPreferences(); |
583 | mWriteBackFile = temp->getWriteBackFile(); | 582 | mWriteBackFile = temp->getWriteBackFile(); |
584 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 583 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
585 | mIsKapiFile = temp->getIsKapiFile(); | 584 | mIsKapiFile = temp->getIsKapiFile(); |
586 | mWriteBackInFuture = 0; | 585 | mWriteBackInFuture = 0; |
587 | if ( temp->getWriteBackFuture() ) { | 586 | if ( temp->getWriteBackFuture() ) { |
588 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 587 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
589 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); | 588 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); |
590 | } | 589 | } |
591 | mFilterInCal = temp->getFilterInCal(); | 590 | mFilterInCal = temp->getFilterInCal(); |
592 | mFilterOutCal = temp->getFilterOutCal(); | 591 | mFilterOutCal = temp->getFilterOutCal(); |
593 | mFilterInAB = temp->getFilterInAB(); | 592 | mFilterInAB = temp->getFilterInAB(); |
594 | mFilterOutAB = temp->getFilterOutAB(); | 593 | mFilterOutAB = temp->getFilterOutAB(); |
595 | mShowSyncSummary = false; | 594 | mShowSyncSummary = false; |
596 | mCurrentSyncDevice = syncProfileNames[i] ; | 595 | mCurrentSyncDevice = syncProfileNames[i] ; |
597 | mCurrentSyncName = mLocalMachineName; | 596 | mCurrentSyncName = mLocalMachineName; |
598 | if ( i == 0 ) { | 597 | if ( i == 0 ) { |
599 | mIsKapiFile = false; | 598 | mIsKapiFile = false; |
600 | #ifdef DESKTOP_VERSION | 599 | #ifdef DESKTOP_VERSION |
601 | syncKDE(); | 600 | syncKDE(); |
602 | #else | 601 | #else |
603 | syncSharp(); | 602 | syncSharp(); |
604 | #endif | 603 | #endif |
605 | } else { | 604 | } else { |
606 | if ( temp->getIsLocalFileSync() ) { | 605 | if ( temp->getIsLocalFileSync() ) { |
607 | switch(mTargetApp) | 606 | switch(mTargetApp) |
608 | { | 607 | { |
609 | case (KAPI): | 608 | case (KAPI): |
610 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 609 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
611 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 610 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
612 | break; | 611 | break; |
613 | case (KOPI): | 612 | case (KOPI): |
614 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 613 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
615 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 614 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
616 | break; | 615 | break; |
617 | case (PWMPI): | 616 | case (PWMPI): |
618 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 617 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
619 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 618 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
620 | break; | 619 | break; |
621 | default: | 620 | default: |
622 | qDebug("KSM: invalid apptype selected"); | 621 | qDebug("KSM: invalid apptype selected"); |
623 | break; | 622 | break; |
624 | } | 623 | } |
625 | } else { | 624 | } else { |
626 | if ( temp->getIsPhoneSync() ) { | 625 | if ( temp->getIsPhoneSync() ) { |
627 | mPhoneDevice = temp->getPhoneDevice( ) ; | 626 | mPhoneDevice = temp->getPhoneDevice( ) ; |
628 | mPhoneConnection = temp->getPhoneConnection( ); | 627 | mPhoneConnection = temp->getPhoneConnection( ); |
629 | mPhoneModel = temp->getPhoneModel( ); | 628 | mPhoneModel = temp->getPhoneModel( ); |
630 | syncPhone(); | 629 | syncPhone(); |
631 | } else if ( temp->getIsPiSync() ) { | 630 | } else if ( temp->getIsPiSync() ) { |
632 | if ( mTargetApp == KAPI ) { | 631 | if ( mTargetApp == KAPI ) { |
633 | mPassWordPiSync = temp->getRemotePwAB(); | 632 | mPassWordPiSync = temp->getRemotePwAB(); |
634 | mActiveSyncPort = temp->getRemotePortAB(); | 633 | mActiveSyncPort = temp->getRemotePortAB(); |
635 | mActiveSyncIP = temp->getRemoteIPAB(); | 634 | mActiveSyncIP = temp->getRemoteIPAB(); |
636 | } else if ( mTargetApp == KOPI ) { | 635 | } else if ( mTargetApp == KOPI ) { |
637 | mPassWordPiSync = temp->getRemotePw(); | 636 | mPassWordPiSync = temp->getRemotePw(); |
638 | mActiveSyncPort = temp->getRemotePort(); | 637 | mActiveSyncPort = temp->getRemotePort(); |
639 | mActiveSyncIP = temp->getRemoteIP(); | 638 | mActiveSyncIP = temp->getRemoteIP(); |
640 | } else { | 639 | } else { |
641 | mPassWordPiSync = temp->getRemotePwPWM(); | 640 | mPassWordPiSync = temp->getRemotePwPWM(); |
642 | mActiveSyncPort = temp->getRemotePortPWM(); | 641 | mActiveSyncPort = temp->getRemotePortPWM(); |
643 | mActiveSyncIP = temp->getRemoteIPPWM(); | 642 | mActiveSyncIP = temp->getRemoteIPPWM(); |
644 | } | 643 | } |
645 | syncPi(); | 644 | syncPi(); |
646 | while ( !mPisyncFinished ) { | 645 | while ( !mPisyncFinished ) { |
647 | //qDebug("waiting "); | 646 | //qDebug("waiting "); |
648 | qApp->processEvents(); | 647 | qApp->processEvents(); |
649 | } | 648 | } |
650 | timer.start(); | 649 | timer.start(); |
651 | while ( timer.elapsed () < 2000 ) { | 650 | while ( timer.elapsed () < 2000 ) { |
652 | qApp->processEvents(); | 651 | qApp->processEvents(); |
653 | } | 652 | } |
654 | } else | 653 | } else |
655 | syncRemote( temp, false ); | 654 | syncRemote( temp, false ); |
656 | 655 | ||
657 | } | 656 | } |
658 | } | 657 | } |
659 | timer.start(); | 658 | timer.start(); |
660 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); | 659 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); |
661 | while ( timer.elapsed () < 2000 ) { | 660 | while ( timer.elapsed () < 2000 ) { |
662 | qApp->processEvents(); | 661 | qApp->processEvents(); |
663 | #ifndef _WIN32_ | 662 | #ifndef _WIN32_ |
664 | sleep (1); | 663 | sleep (1); |
665 | #endif | 664 | #endif |
666 | } | 665 | } |
667 | 666 | ||
668 | } | 667 | } |
669 | 668 | ||
670 | } | 669 | } |
671 | delete temp; | 670 | delete temp; |
672 | return syncedProfiles; | 671 | return syncedProfiles; |
673 | } | 672 | } |
674 | 673 | ||
675 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) | 674 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) |
676 | { | 675 | { |
677 | QString question; | 676 | QString question; |
678 | if ( ask ) { | 677 | if ( ask ) { |
679 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 678 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
680 | if ( QMessageBox::information( mParent, i18n("Sync"), | 679 | if ( QMessageBox::information( mParent, i18n("Sync"), |
681 | question, | 680 | question, |
682 | i18n("Yes"), i18n("No"), | 681 | i18n("Yes"), i18n("No"), |
683 | 0, 0 ) != 0 ) | 682 | 0, 0 ) != 0 ) |
684 | return; | 683 | return; |
685 | } | 684 | } |
686 | 685 | ||
687 | QString preCommand; | 686 | QString preCommand; |
688 | QString localTempFile; | 687 | QString localTempFile; |
689 | QString postCommand; | 688 | QString postCommand; |
690 | 689 | ||
691 | switch(mTargetApp) | 690 | switch(mTargetApp) |
692 | { | 691 | { |
693 | case (KAPI): | 692 | case (KAPI): |
694 | preCommand = prof->getPreSyncCommandAB(); | 693 | preCommand = prof->getPreSyncCommandAB(); |
695 | postCommand = prof->getPostSyncCommandAB(); | 694 | postCommand = prof->getPostSyncCommandAB(); |
696 | localTempFile = prof->getLocalTempFileAB(); | 695 | localTempFile = prof->getLocalTempFileAB(); |
697 | break; | 696 | break; |
698 | case (KOPI): | 697 | case (KOPI): |
699 | preCommand = prof->getPreSyncCommand(); | 698 | preCommand = prof->getPreSyncCommand(); |
700 | postCommand = prof->getPostSyncCommand(); | 699 | postCommand = prof->getPostSyncCommand(); |
701 | localTempFile = prof->getLocalTempFile(); | 700 | localTempFile = prof->getLocalTempFile(); |
702 | break; | 701 | break; |
703 | case (PWMPI): | 702 | case (PWMPI): |
704 | preCommand = prof->getPreSyncCommandPWM(); | 703 | preCommand = prof->getPreSyncCommandPWM(); |
705 | postCommand = prof->getPostSyncCommandPWM(); | 704 | postCommand = prof->getPostSyncCommandPWM(); |
706 | localTempFile = prof->getLocalTempFilePWM(); | 705 | localTempFile = prof->getLocalTempFilePWM(); |
707 | break; | 706 | break; |
708 | default: | 707 | default: |
709 | qDebug("KSM::syncRemote: invalid apptype selected"); | 708 | qDebug("KSM::syncRemote: invalid apptype selected"); |
710 | break; | 709 | break; |
711 | } | 710 | } |
712 | 711 | ||
713 | 712 | ||
714 | int fi; | 713 | int fi; |
715 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { | 714 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { |
716 | QString pwd = getPassword(); | 715 | QString pwd = getPassword(); |
717 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); | 716 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); |
718 | 717 | ||
719 | } | 718 | } |
720 | int maxlen = 30; | 719 | int maxlen = 30; |
721 | if ( QApplication::desktop()->width() > 320 ) | 720 | if ( QApplication::desktop()->width() > 320 ) |
722 | maxlen += 25; | 721 | maxlen += 25; |
723 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); | 722 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); |
724 | int fileSize = 0; | 723 | int fileSize = 0; |
725 | int result = system ( preCommand ); | 724 | int result = system ( preCommand ); |
726 | // 0 : okay | 725 | // 0 : okay |
727 | // 256: no such file or dir | 726 | // 256: no such file or dir |
728 | // | 727 | // |
729 | qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result ); | 728 | qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result ); |
730 | if ( result != 0 ) { | 729 | if ( result != 0 ) { |
731 | unsigned int len = maxlen; | 730 | unsigned int len = maxlen; |
732 | while ( len < preCommand.length() ) { | 731 | while ( len < preCommand.length() ) { |
733 | preCommand.insert( len , "\n" ); | 732 | preCommand.insert( len , "\n" ); |
734 | len += maxlen +2; | 733 | len += maxlen +2; |
735 | } | 734 | } |
736 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; | 735 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; |
737 | QMessageBox::information( mParent, i18n("Sync - ERROR"), | 736 | QMessageBox::information( mParent, i18n("Sync - ERROR"), |
738 | question, | 737 | question, |
739 | i18n("Okay!")) ; | 738 | i18n("Okay!")) ; |
740 | mParent->topLevelWidget()->setCaption ("KDE-Pim"); | 739 | mParent->topLevelWidget()->setCaption ("KDE-Pim"); |
741 | return; | 740 | return; |
742 | } | 741 | } |
743 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); | 742 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); |
744 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 743 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
745 | 744 | ||
746 | if ( syncWithFile( localTempFile, true ) ) { | 745 | if ( syncWithFile( localTempFile, true ) ) { |
747 | 746 | ||
748 | if ( mWriteBackFile ) { | 747 | if ( mWriteBackFile ) { |
749 | int fi; | 748 | int fi; |
750 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { | 749 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { |
751 | QString pwd = getPassword(); | 750 | QString pwd = getPassword(); |
752 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); | 751 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); |
753 | 752 | ||
754 | } | 753 | } |
755 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); | 754 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); |
756 | result = system ( postCommand ); | 755 | result = system ( postCommand ); |
757 | qDebug("KSM::Sync:Writing back file result: %d ", result); | 756 | qDebug("KSM::Sync:Writing back file result: %d ", result); |
758 | if ( result != 0 ) { | 757 | if ( result != 0 ) { |
759 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 758 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
760 | return; | 759 | return; |
761 | } else { | 760 | } else { |
762 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 761 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
763 | } | 762 | } |
764 | } | 763 | } |
765 | } | 764 | } |
766 | return; | 765 | return; |
767 | } | 766 | } |
768 | bool KSyncManager::edit_pisync_options() | 767 | bool KSyncManager::edit_pisync_options() |
769 | { | 768 | { |
770 | QDialog dia( mParent, "dia", true ); | 769 | QDialog dia( mParent, "dia", true ); |
771 | dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); | 770 | dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); |
772 | QVBoxLayout lay ( &dia ); | 771 | QVBoxLayout lay ( &dia ); |
773 | lay.setSpacing( 5 ); | 772 | lay.setSpacing( 5 ); |
774 | lay.setMargin( 3 ); | 773 | lay.setMargin( 3 ); |
775 | QLabel lab1 ( i18n("Password for remote access:"), &dia); | 774 | QLabel lab1 ( i18n("Password for remote access:"), &dia); |
776 | lay.addWidget( &lab1 ); | 775 | lay.addWidget( &lab1 ); |
777 | QLineEdit le1 (&dia ); | 776 | QLineEdit le1 (&dia ); |
778 | lay.addWidget( &le1 ); | 777 | lay.addWidget( &le1 ); |
779 | QLabel lab2 ( i18n("Remote IP address:"), &dia); | 778 | QLabel lab2 ( i18n("Remote IP address:"), &dia); |
780 | lay.addWidget( &lab2 ); | 779 | lay.addWidget( &lab2 ); |
781 | QLineEdit le2 (&dia ); | 780 | QLineEdit le2 (&dia ); |
782 | lay.addWidget( &le2 ); | 781 | lay.addWidget( &le2 ); |
783 | QLabel lab3 ( i18n("Remote port number:"), &dia); | 782 | QLabel lab3 ( i18n("Remote port number:"), &dia); |
784 | lay.addWidget( &lab3 ); | 783 | lay.addWidget( &lab3 ); |
785 | QLineEdit le3 (&dia ); | 784 | QLineEdit le3 (&dia ); |
786 | lay.addWidget( &le3 ); | 785 | lay.addWidget( &le3 ); |
787 | QPushButton pb ( "OK", &dia); | 786 | QPushButton pb ( "OK", &dia); |
788 | lay.addWidget( &pb ); | 787 | lay.addWidget( &pb ); |
789 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 788 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
790 | le1.setText( mPassWordPiSync ); | 789 | le1.setText( mPassWordPiSync ); |
791 | le2.setText( mActiveSyncIP ); | 790 | le2.setText( mActiveSyncIP ); |
792 | le3.setText( mActiveSyncPort ); | 791 | le3.setText( mActiveSyncPort ); |
793 | if ( dia.exec() ) { | 792 | if ( dia.exec() ) { |
794 | mPassWordPiSync = le1.text(); | 793 | mPassWordPiSync = le1.text(); |
795 | mActiveSyncPort = le3.text(); | 794 | mActiveSyncPort = le3.text(); |
796 | mActiveSyncIP = le2.text(); | 795 | mActiveSyncIP = le2.text(); |
797 | return true; | 796 | return true; |
798 | } | 797 | } |
799 | return false; | 798 | return false; |
800 | } | 799 | } |
801 | bool KSyncManager::edit_sync_options() | 800 | bool KSyncManager::edit_sync_options() |
802 | { | 801 | { |
803 | 802 | ||
804 | QDialog dia( mParent, "dia", true ); | 803 | QDialog dia( mParent, "dia", true ); |
805 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 804 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
806 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 805 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
807 | QVBoxLayout lay ( &dia ); | 806 | QVBoxLayout lay ( &dia ); |
808 | lay.setSpacing( 2 ); | 807 | lay.setSpacing( 2 ); |
809 | lay.setMargin( 3 ); | 808 | lay.setMargin( 3 ); |
810 | lay.addWidget(&gr); | 809 | lay.addWidget(&gr); |
811 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 810 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
812 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 811 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
813 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 812 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
814 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 813 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
815 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 814 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
816 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 815 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
817 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 816 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
818 | QPushButton pb ( "OK", &dia); | 817 | QPushButton pb ( "OK", &dia); |
819 | lay.addWidget( &pb ); | 818 | lay.addWidget( &pb ); |
820 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 819 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
821 | switch ( mSyncAlgoPrefs ) { | 820 | switch ( mSyncAlgoPrefs ) { |
822 | case 0: | 821 | case 0: |
823 | loc.setChecked( true); | 822 | loc.setChecked( true); |
824 | break; | 823 | break; |
825 | case 1: | 824 | case 1: |
826 | rem.setChecked( true ); | 825 | rem.setChecked( true ); |
827 | break; | 826 | break; |
828 | case 2: | 827 | case 2: |
829 | newest.setChecked( true); | 828 | newest.setChecked( true); |
830 | break; | 829 | break; |
831 | case 3: | 830 | case 3: |
832 | ask.setChecked( true); | 831 | ask.setChecked( true); |
833 | break; | 832 | break; |
834 | case 4: | 833 | case 4: |
835 | f_loc.setChecked( true); | 834 | f_loc.setChecked( true); |
836 | break; | 835 | break; |
837 | case 5: | 836 | case 5: |
838 | f_rem.setChecked( true); | 837 | f_rem.setChecked( true); |
839 | break; | 838 | break; |
840 | case 6: | 839 | case 6: |
841 | // both.setChecked( true); | 840 | // both.setChecked( true); |
842 | break; | 841 | break; |
843 | default: | 842 | default: |
844 | break; | 843 | break; |
845 | } | 844 | } |
846 | if ( dia.exec() ) { | 845 | if ( dia.exec() ) { |
847 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 846 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
848 | return true; | 847 | return true; |
849 | } | 848 | } |
850 | return false; | 849 | return false; |
851 | } | 850 | } |
852 | 851 | ||
853 | QString KSyncManager::getPassword( ) | 852 | QString KSyncManager::getPassword( ) |
854 | { | 853 | { |
855 | QString retfile = ""; | 854 | QString retfile = ""; |
856 | QDialog dia ( mParent, "input-dialog", true ); | 855 | QDialog dia ( mParent, "input-dialog", true ); |
857 | QLineEdit lab ( &dia ); | 856 | QLineEdit lab ( &dia ); |
858 | lab.setEchoMode( QLineEdit::Password ); | 857 | lab.setEchoMode( QLineEdit::Password ); |
859 | QVBoxLayout lay( &dia ); | 858 | QVBoxLayout lay( &dia ); |
860 | lay.setMargin(7); | 859 | lay.setMargin(7); |
861 | lay.setSpacing(7); | 860 | lay.setSpacing(7); |
862 | lay.addWidget( &lab); | 861 | lay.addWidget( &lab); |
863 | dia.setFixedSize( 230,50 ); | 862 | dia.setFixedSize( 230,50 ); |
864 | dia.setCaption( i18n("Enter password") ); | 863 | dia.setCaption( i18n("Enter password") ); |
865 | QPushButton pb ( "OK", &dia); | 864 | QPushButton pb ( "OK", &dia); |
866 | lay.addWidget( &pb ); | 865 | lay.addWidget( &pb ); |
867 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 866 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
868 | dia.show(); | 867 | dia.show(); |
869 | int res = dia.exec(); | 868 | int res = dia.exec(); |
870 | if ( res ) | 869 | if ( res ) |
871 | retfile = lab.text(); | 870 | retfile = lab.text(); |
872 | dia.hide(); | 871 | dia.hide(); |
873 | qApp->processEvents(); | 872 | qApp->processEvents(); |
874 | return retfile; | 873 | return retfile; |
875 | 874 | ||
876 | } | 875 | } |
877 | 876 | ||
878 | 877 | ||
879 | void KSyncManager::confSync() | 878 | void KSyncManager::confSync() |
880 | { | 879 | { |
881 | static KSyncPrefsDialog* sp = 0; | 880 | static KSyncPrefsDialog* sp = 0; |
882 | if ( ! sp ) { | 881 | if ( ! sp ) { |
883 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); | 882 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); |
884 | } | 883 | } |
885 | sp->usrReadConfig(); | 884 | sp->usrReadConfig(); |
886 | #ifndef DESKTOP_VERSION | 885 | #ifndef DESKTOP_VERSION |
887 | sp->showMaximized(); | 886 | sp->showMaximized(); |
888 | #else | 887 | #else |
889 | sp->show(); | 888 | sp->show(); |
890 | #endif | 889 | #endif |
891 | sp->exec(); | 890 | sp->exec(); |
892 | QStringList oldSyncProfileNames = mSyncProfileNames; | 891 | QStringList oldSyncProfileNames = mSyncProfileNames; |
893 | mSyncProfileNames = sp->getSyncProfileNames(); | 892 | mSyncProfileNames = sp->getSyncProfileNames(); |
894 | mLocalMachineName = sp->getLocalMachineName (); | 893 | mLocalMachineName = sp->getLocalMachineName (); |
895 | int ii; | 894 | int ii; |
896 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { | 895 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { |
897 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) | 896 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) |
898 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); | 897 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); |
899 | } | 898 | } |
900 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 899 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
901 | } | 900 | } |
902 | void KSyncManager::syncKDE() | 901 | void KSyncManager::syncKDE() |
903 | { | 902 | { |
904 | mSyncWithDesktop = true; | 903 | mSyncWithDesktop = true; |
905 | emit save(); | 904 | emit save(); |
906 | switch(mTargetApp) | 905 | switch(mTargetApp) |
907 | { | 906 | { |
908 | case (KAPI): | 907 | case (KAPI): |
909 | { | 908 | { |
910 | #ifdef DESKTOP_VERSION | 909 | #ifdef DESKTOP_VERSION |
911 | QString command = qApp->applicationDirPath () + "/kdeabdump"; | 910 | QString command = qApp->applicationDirPath () + "/kdeabdump"; |
912 | #else | 911 | #else |
913 | QString command = "kdeabdump"; | 912 | QString command = "kdeabdump"; |
914 | #endif | 913 | #endif |
915 | if ( ! QFile::exists ( command ) ) | 914 | if ( ! QFile::exists ( command ) ) |
916 | command = "kdeabdump"; | 915 | command = "kdeabdump"; |
917 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; | 916 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; |
918 | system ( command.latin1()); | 917 | system ( command.latin1()); |
919 | if ( syncWithFile( fileName,true ) ) { | 918 | if ( syncWithFile( fileName,true ) ) { |
920 | if ( mWriteBackFile ) { | 919 | if ( mWriteBackFile ) { |
921 | command += " --read"; | 920 | command += " --read"; |
922 | system ( command.latin1()); | 921 | system ( command.latin1()); |
923 | } | 922 | } |
924 | } | 923 | } |
925 | 924 | ||
926 | } | 925 | } |
927 | break; | 926 | break; |
928 | case (KOPI): | 927 | case (KOPI): |
929 | { | 928 | { |
930 | #ifdef DESKTOP_VERSION | 929 | #ifdef DESKTOP_VERSION |
931 | QString command = qApp->applicationDirPath () + "/kdecaldump"; | 930 | QString command = qApp->applicationDirPath () + "/kdecaldump"; |
932 | #else | 931 | #else |
933 | QString command = "kdecaldump"; | 932 | QString command = "kdecaldump"; |
934 | #endif | 933 | #endif |
935 | if ( ! QFile::exists ( command ) ) | 934 | if ( ! QFile::exists ( command ) ) |
936 | command = "kdecaldump"; | 935 | command = "kdecaldump"; |
937 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; | 936 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; |
938 | system ( command.latin1()); | 937 | system ( command.latin1()); |
939 | if ( syncWithFile( fileName,true ) ) { | 938 | if ( syncWithFile( fileName,true ) ) { |
940 | if ( mWriteBackFile ) { | 939 | if ( mWriteBackFile ) { |
941 | command += " --read"; | 940 | command += " --read"; |
942 | system ( command.latin1()); | 941 | system ( command.latin1()); |
943 | } | 942 | } |
944 | } | 943 | } |
945 | 944 | ||
946 | } | 945 | } |
947 | break; | 946 | break; |
948 | case (PWMPI): | 947 | case (PWMPI): |
949 | 948 | ||
950 | break; | 949 | break; |
951 | default: | 950 | default: |
952 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); | 951 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); |
953 | break; | 952 | break; |
954 | 953 | ||
955 | } | 954 | } |
956 | } | 955 | } |
957 | 956 | ||
958 | void KSyncManager::syncSharp() | 957 | void KSyncManager::syncSharp() |
959 | { | 958 | { |
960 | 959 | ||
961 | if ( ! syncExternalApplication("sharp") ) | 960 | if ( ! syncExternalApplication("sharp") ) |
962 | qDebug("KSM::ERROR sync sharp "); | 961 | qDebug("KSM::ERROR sync sharp "); |
963 | } | 962 | } |
964 | 963 | ||
965 | bool KSyncManager::syncExternalApplication(QString resource) | 964 | bool KSyncManager::syncExternalApplication(QString resource) |
966 | { | 965 | { |
967 | 966 | ||
968 | emit save(); | 967 | emit save(); |
969 | 968 | ||
970 | if ( mAskForPreferences ) | 969 | if ( mAskForPreferences ) |
971 | if ( !edit_sync_options()) { | 970 | if ( !edit_sync_options()) { |
972 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 971 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
973 | return false; | 972 | return false; |
974 | } | 973 | } |
975 | 974 | ||
976 | qDebug("KSM::Sync extern %s", resource.latin1()); | 975 | qDebug("KSM::Sync extern %s", resource.latin1()); |
977 | 976 | ||
978 | bool syncOK = mImplementation->syncExternal(this, resource); | 977 | bool syncOK = mImplementation->syncExternal(this, resource); |
979 | 978 | ||
980 | return syncOK; | 979 | return syncOK; |
981 | 980 | ||
982 | } | 981 | } |
983 | 982 | ||
984 | void KSyncManager::syncPhone() | 983 | void KSyncManager::syncPhone() |
985 | { | 984 | { |
986 | 985 | ||
987 | syncExternalApplication("phone"); | 986 | syncExternalApplication("phone"); |
988 | 987 | ||
989 | } | 988 | } |
990 | 989 | ||
991 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) | 990 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) |
992 | { | 991 | { |
993 | if (!bar->isVisible()) | 992 | if (!bar->isVisible()) |
994 | { | 993 | { |
995 | bar->setCaption (caption); | 994 | bar->setCaption (caption); |
996 | bar->setTotalSteps ( total ) ; | 995 | bar->setTotalSteps ( total ) ; |
997 | bar->show(); | 996 | bar->show(); |
998 | } | 997 | } |
999 | bar->raise(); | 998 | bar->raise(); |
1000 | bar->setProgress( percentage ); | 999 | bar->setProgress( percentage ); |
1001 | qApp->processEvents(); | 1000 | qApp->processEvents(); |
1002 | } | 1001 | } |
1003 | 1002 | ||
1004 | void KSyncManager::hideProgressBar() | 1003 | void KSyncManager::hideProgressBar() |
1005 | { | 1004 | { |
1006 | bar->hide(); | 1005 | bar->hide(); |
1007 | qApp->processEvents(); | 1006 | qApp->processEvents(); |
1008 | } | 1007 | } |
1009 | 1008 | ||
1010 | bool KSyncManager::isProgressBarCanceled() | 1009 | bool KSyncManager::isProgressBarCanceled() |
1011 | { | 1010 | { |
1012 | return !bar->isVisible(); | 1011 | return !bar->isVisible(); |
1013 | } | 1012 | } |
1014 | 1013 | ||
1015 | QString KSyncManager::syncFileName() | 1014 | QString KSyncManager::syncFileName() |
1016 | { | 1015 | { |
1017 | 1016 | ||
1018 | QString fn = "tempfile"; | 1017 | QString fn = "tempfile"; |
1019 | switch(mTargetApp) | 1018 | switch(mTargetApp) |
1020 | { | 1019 | { |
1021 | case (KAPI): | 1020 | case (KAPI): |
1022 | fn = "tempsyncab.vcf"; | 1021 | fn = "tempsyncab.vcf"; |
1023 | break; | 1022 | break; |
1024 | case (KOPI): | 1023 | case (KOPI): |
1025 | fn = "tempsynccal.ics"; | 1024 | fn = "tempsynccal.ics"; |
1026 | break; | 1025 | break; |
1027 | case (PWMPI): | 1026 | case (PWMPI): |
1028 | fn = "tempsyncpw.pwm"; | 1027 | fn = "tempsyncpw.pwm"; |
1029 | break; | 1028 | break; |
1030 | default: | 1029 | default: |
1031 | break; | 1030 | break; |
1032 | } | 1031 | } |
1033 | #ifdef _WIN32_ | 1032 | #ifdef _WIN32_ |
1034 | return locateLocal( "tmp", fn ); | 1033 | return locateLocal( "tmp", fn ); |
1035 | #else | 1034 | #else |
1036 | return (QString( "/tmp/" )+ fn ); | 1035 | return (QString( "/tmp/" )+ fn ); |
1037 | #endif | 1036 | #endif |
1038 | } | 1037 | } |
1039 | 1038 | ||
1040 | void KSyncManager::syncPi() | 1039 | void KSyncManager::syncPi() |
1041 | { | 1040 | { |
1042 | mIsKapiFile = true; | 1041 | mIsKapiFile = true; |
1043 | mPisyncFinished = false; | 1042 | mPisyncFinished = false; |
1044 | qApp->processEvents(); | 1043 | qApp->processEvents(); |
1045 | if ( mAskForPreferences ) | 1044 | if ( mAskForPreferences ) |
1046 | if ( !edit_pisync_options()) { | 1045 | if ( !edit_pisync_options()) { |
1047 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 1046 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
1048 | return; | 1047 | return; |
1049 | } | 1048 | } |
1050 | bool ok; | 1049 | bool ok; |
1051 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); | 1050 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); |
1052 | if ( ! ok ) { | 1051 | if ( ! ok ) { |
1053 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 1052 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
1054 | return; | 1053 | return; |
1055 | } | 1054 | } |
1056 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); | 1055 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); |
1057 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 1056 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
1058 | mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); | 1057 | mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); |
1059 | commandSocket->readFile( syncFileName() ); | 1058 | commandSocket->readFile( syncFileName() ); |
1060 | } | 1059 | } |
1061 | 1060 | ||
1062 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) | 1061 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) |
1063 | { | 1062 | { |
1064 | //enum { success, errorW, errorR, quiet }; | 1063 | //enum { success, errorW, errorR, quiet }; |
1065 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { | 1064 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { |
1066 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); | 1065 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); |
1067 | delete s; | 1066 | delete s; |
1068 | if ( state == KCommandSocket::errorR ) { | 1067 | if ( state == KCommandSocket::errorR ) { |
1069 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | 1068 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); |
1070 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 1069 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
1071 | commandSocket->sendStop(); | 1070 | commandSocket->sendStop(); |
1072 | } | 1071 | } |
1073 | mPisyncFinished = true; | 1072 | mPisyncFinished = true; |
1074 | return; | 1073 | return; |
1075 | 1074 | ||
1076 | } else if ( state == KCommandSocket::errorW ) { | 1075 | } else if ( state == KCommandSocket::errorW ) { |
1077 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); | 1076 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); |
1078 | mPisyncFinished = true; | 1077 | mPisyncFinished = true; |
1079 | 1078 | ||
1080 | } else if ( state == KCommandSocket::successR ) { | 1079 | } else if ( state == KCommandSocket::successR ) { |
1081 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | 1080 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); |
1082 | 1081 | ||
1083 | } else if ( state == KCommandSocket::successW ) { | 1082 | } else if ( state == KCommandSocket::successW ) { |
1084 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 1083 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
1085 | mPisyncFinished = true; | 1084 | mPisyncFinished = true; |
1086 | } | 1085 | } |
1087 | 1086 | ||
1088 | delete s; | 1087 | delete s; |
1089 | } | 1088 | } |
1090 | 1089 | ||
1091 | void KSyncManager::readFileFromSocket() | 1090 | void KSyncManager::readFileFromSocket() |
1092 | { | 1091 | { |
1093 | QString fileName = syncFileName(); | 1092 | QString fileName = syncFileName(); |
1094 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); | 1093 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); |
1095 | if ( ! syncWithFile( fileName , true ) ) { | 1094 | if ( ! syncWithFile( fileName , true ) ) { |
1096 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); | 1095 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); |
1097 | mPisyncFinished = true; | 1096 | mPisyncFinished = true; |
1098 | return; | 1097 | return; |
1099 | } | 1098 | } |
1100 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | 1099 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); |
1101 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 1100 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
1102 | if ( mWriteBackFile ) | 1101 | if ( mWriteBackFile ) |
1103 | commandSocket->writeFile( fileName ); | 1102 | commandSocket->writeFile( fileName ); |
1104 | else { | 1103 | else { |
1105 | commandSocket->sendStop(); | 1104 | commandSocket->sendStop(); |
1106 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 1105 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
1107 | mPisyncFinished = true; | 1106 | mPisyncFinished = true; |
1108 | } | 1107 | } |
1109 | } | 1108 | } |
1110 | 1109 | ||
1111 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) | 1110 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) |
1112 | { | 1111 | { |
1113 | mPassWord = pw; | 1112 | mPassWord = pw; |
1114 | mSocket = 0; | 1113 | mSocket = 0; |
1115 | mSyncActionDialog = 0; | 1114 | mSyncActionDialog = 0; |
1116 | blockRC = false; | 1115 | blockRC = false; |
1117 | }; | 1116 | }; |
1118 | 1117 | ||
1119 | void KServerSocket::newConnection ( int socket ) | 1118 | void KServerSocket::newConnection ( int socket ) |
1120 | { | 1119 | { |
1121 | // qDebug("KServerSocket:New connection %d ", socket); | 1120 | // qDebug("KServerSocket:New connection %d ", socket); |
1122 | if ( mSocket ) { | 1121 | if ( mSocket ) { |
1123 | qDebug("KSS::newConnection Socket deleted! "); | 1122 | qDebug("KSS::newConnection Socket deleted! "); |
1124 | delete mSocket; | 1123 | delete mSocket; |
1125 | mSocket = 0; | 1124 | mSocket = 0; |
1126 | } | 1125 | } |
1127 | mSocket = new QSocket( this ); | 1126 | mSocket = new QSocket( this ); |
1128 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | 1127 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); |
1129 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | 1128 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); |
1130 | mSocket->setSocket( socket ); | 1129 | mSocket->setSocket( socket ); |
1131 | } | 1130 | } |
1132 | 1131 | ||
1133 | void KServerSocket::discardClient() | 1132 | void KServerSocket::discardClient() |
1134 | { | 1133 | { |
1135 | //qDebug(" KServerSocket::discardClient()"); | 1134 | //qDebug(" KServerSocket::discardClient()"); |
1136 | if ( mSocket ) { | 1135 | if ( mSocket ) { |
1137 | delete mSocket; | 1136 | delete mSocket; |
1138 | mSocket = 0; | 1137 | mSocket = 0; |
1139 | } | 1138 | } |
1140 | //emit endConnect(); | 1139 | //emit endConnect(); |
1141 | } | 1140 | } |
1142 | void KServerSocket::readClient() | 1141 | void KServerSocket::readClient() |
1143 | { | 1142 | { |
1144 | if ( blockRC ) | 1143 | if ( blockRC ) |
1145 | return; | 1144 | return; |
1146 | if ( mSocket == 0 ) { | 1145 | if ( mSocket == 0 ) { |
1147 | qDebug("ERROR::KSS::readClient(): mSocket == 0 "); | 1146 | qDebug("ERROR::KSS::readClient(): mSocket == 0 "); |
1148 | return; | 1147 | return; |
1149 | } | 1148 | } |
1150 | //qDebug("KServerSocket::readClient()"); | 1149 | //qDebug("KServerSocket::readClient()"); |
1151 | if ( mSocket->canReadLine() ) { | 1150 | if ( mSocket->canReadLine() ) { |
1152 | QString line = mSocket->readLine(); | 1151 | QString line = mSocket->readLine(); |
1153 | //qDebug("KServerSocket readline: %s ", line.latin1()); | 1152 | //qDebug("KServerSocket readline: %s ", line.latin1()); |
1154 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); | 1153 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); |
1155 | if ( tokens[0] == "GET" ) { | 1154 | if ( tokens[0] == "GET" ) { |
1156 | if ( tokens[1] == mPassWord ) { | 1155 | if ( tokens[1] == mPassWord ) { |
1157 | //emit sendFile( mSocket ); | 1156 | //emit sendFile( mSocket ); |
1158 | bool ok = false; | 1157 | bool ok = false; |
1159 | QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); | 1158 | QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); |
1160 | if ( ok ) { | 1159 | if ( ok ) { |
1161 | KSyncManager::mRequestedSyncEvent = dt; | 1160 | KSyncManager::mRequestedSyncEvent = dt; |
1162 | } | 1161 | } |
1163 | else | 1162 | else |
1164 | KSyncManager::mRequestedSyncEvent = QDateTime(); | 1163 | KSyncManager::mRequestedSyncEvent = QDateTime(); |
1165 | send_file(); | 1164 | send_file(); |
1166 | } | 1165 | } |
1167 | else { | 1166 | else { |
1168 | KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); | 1167 | KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); |
1169 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 1168 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
1170 | } | 1169 | } |
1171 | } | 1170 | } |
1172 | if ( tokens[0] == "PUT" ) { | 1171 | if ( tokens[0] == "PUT" ) { |
1173 | if ( tokens[1] == mPassWord ) { | 1172 | if ( tokens[1] == mPassWord ) { |
1174 | //emit getFile( mSocket ); | 1173 | //emit getFile( mSocket ); |
1175 | blockRC = true; | 1174 | blockRC = true; |
1176 | get_file(); | 1175 | get_file(); |
1177 | } | 1176 | } |
1178 | else { | 1177 | else { |
1179 | KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); | 1178 | KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); |
1180 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 1179 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
1181 | } | 1180 | } |
1182 | } | 1181 | } |
1183 | if ( tokens[0] == "STOP" ) { | 1182 | if ( tokens[0] == "STOP" ) { |
1184 | //emit endConnect(); | 1183 | //emit endConnect(); |
1185 | end_connect(); | 1184 | end_connect(); |
1186 | } | 1185 | } |
1187 | } | 1186 | } |
1188 | } | 1187 | } |
1189 | void KServerSocket::end_connect() | 1188 | void KServerSocket::end_connect() |
1190 | { | 1189 | { |
1191 | delete mSyncActionDialog; | 1190 | delete mSyncActionDialog; |
1192 | mSyncActionDialog = 0; | 1191 | mSyncActionDialog = 0; |
1193 | } | 1192 | } |
1194 | void KServerSocket::send_file() | 1193 | void KServerSocket::send_file() |
1195 | { | 1194 | { |
1196 | //qDebug("MainWindow::sendFile(QSocket* s) "); | 1195 | //qDebug("MainWindow::sendFile(QSocket* s) "); |
1197 | if ( mSyncActionDialog ) | 1196 | if ( mSyncActionDialog ) |
1198 | delete mSyncActionDialog; | 1197 | delete mSyncActionDialog; |
1199 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); | 1198 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); |
1200 | mSyncActionDialog->setCaption(i18n("Received sync request")); | 1199 | mSyncActionDialog->setCaption(i18n("Received sync request")); |
1201 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); | 1200 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); |
1202 | label->setAlignment ( Qt::AlignHCenter ); | 1201 | label->setAlignment ( Qt::AlignHCenter ); |
1203 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); | 1202 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); |
1204 | lay->addWidget( label); | 1203 | lay->addWidget( label); |
1205 | lay->setMargin(7); | 1204 | lay->setMargin(7); |
1206 | lay->setSpacing(7); | 1205 | lay->setSpacing(7); |
1207 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1206 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1208 | int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); | 1207 | int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); |
1209 | if ( secs < 0 ) | 1208 | if ( secs < 0 ) |
1210 | secs = secs * (-1); | 1209 | secs = secs * (-1); |
1211 | if ( secs > 30 ) | 1210 | if ( secs > 30 ) |
1212 | //if ( true ) | 1211 | //if ( true ) |
1213 | { | 1212 | { |
1214 | QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); | 1213 | QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); |
1215 | QLabel* label = new QLabel( warning, mSyncActionDialog ); | 1214 | QLabel* label = new QLabel( warning, mSyncActionDialog ); |
1216 | label->setAlignment ( Qt::AlignHCenter ); | 1215 | label->setAlignment ( Qt::AlignHCenter ); |
1217 | lay->addWidget( label); | 1216 | lay->addWidget( label); |
1218 | if ( secs > 180 ) | 1217 | if ( secs > 180 ) |
1219 | { | 1218 | { |
1220 | if ( secs > 300 ) { | 1219 | if ( secs > 300 ) { |
1221 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\n of more than 5 minutes.\nPlease adjust your clocks.\n<b>You may get wrong syncing results!<\b>\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { | 1220 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\n of more than 5 minutes.\nPlease adjust your clocks.\n<b>You may get wrong syncing results!<\b>\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { |
1222 | qDebug("KSS::Sync cancelled ,cs"); | 1221 | qDebug("KSS::Sync cancelled ,cs"); |
1223 | return ; | 1222 | return ; |
1224 | } | 1223 | } |
1225 | } | 1224 | } |
1226 | QFont f = label->font(); | 1225 | QFont f = label->font(); |
1227 | f.setPointSize ( f.pointSize() *2 ); | 1226 | f.setPointSize ( f.pointSize() *2 ); |
1228 | f. setBold (true ); | 1227 | f. setBold (true ); |
1229 | QLabel* label = new QLabel( warning, mSyncActionDialog ); | 1228 | QLabel* label = new QLabel( warning, mSyncActionDialog ); |
1230 | label->setFont( f ); | 1229 | label->setFont( f ); |
1231 | warning = i18n("ADJUST\nYOUR\nCLOCKS!"); | 1230 | warning = i18n("ADJUST\nYOUR\nCLOCKS!"); |
1232 | label->setText( warning ); | 1231 | label->setText( warning ); |
1233 | label->setAlignment ( Qt::AlignHCenter ); | 1232 | label->setAlignment ( Qt::AlignHCenter ); |
1234 | lay->addWidget( label); | 1233 | lay->addWidget( label); |
1235 | mSyncActionDialog->setFixedSize( 230, 300); | 1234 | mSyncActionDialog->setFixedSize( 230, 300); |
1236 | } else { | 1235 | } else { |
1237 | mSyncActionDialog->setFixedSize( 230, 200); | 1236 | mSyncActionDialog->setFixedSize( 230, 200); |
1238 | } | 1237 | } |
1239 | } else { | 1238 | } else { |
1240 | mSyncActionDialog->setFixedSize( 230, 120); | 1239 | mSyncActionDialog->setFixedSize( 230, 120); |
1241 | } | 1240 | } |
1242 | } else | 1241 | } else |
1243 | mSyncActionDialog->setFixedSize( 230, 120); | 1242 | mSyncActionDialog->setFixedSize( 230, 120); |
1244 | mSyncActionDialog->show(); | 1243 | mSyncActionDialog->show(); |
1245 | mSyncActionDialog->raise(); | 1244 | mSyncActionDialog->raise(); |
1246 | emit request_file(); | 1245 | emit request_file(); |
1247 | qApp->processEvents(); | 1246 | qApp->processEvents(); |
1248 | QString fileName = mFileName; | 1247 | QString fileName = mFileName; |
1249 | QFile file( fileName ); | 1248 | QFile file( fileName ); |
1250 | if (!file.open( IO_ReadOnly ) ) { | 1249 | if (!file.open( IO_ReadOnly ) ) { |
1251 | delete mSyncActionDialog; | 1250 | delete mSyncActionDialog; |
1252 | mSyncActionDialog = 0; | 1251 | mSyncActionDialog = 0; |
1253 | qDebug("KSS::error open sync file: %s ", fileName.latin1()); | 1252 | qDebug("KSS::error open sync file: %s ", fileName.latin1()); |
1254 | mSocket->close(); | 1253 | mSocket->close(); |
1255 | if ( mSocket->state() == QSocket::Idle ) | 1254 | if ( mSocket->state() == QSocket::Idle ) |
1256 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1255 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1257 | return ; | 1256 | return ; |
1258 | 1257 | ||
1259 | } | 1258 | } |
1260 | mSyncActionDialog->setCaption( i18n("Sending file...") ); | 1259 | mSyncActionDialog->setCaption( i18n("Sending file...") ); |
1261 | QTextStream ts( &file ); | 1260 | QTextStream ts( &file ); |
1262 | ts.setEncoding( QTextStream::Latin1 ); | 1261 | ts.setEncoding( QTextStream::Latin1 ); |
1263 | 1262 | ||
1264 | QTextStream os( mSocket ); | 1263 | QTextStream os( mSocket ); |
1265 | os.setEncoding( QTextStream::Latin1 ); | 1264 | os.setEncoding( QTextStream::Latin1 ); |
1266 | while ( ! ts.atEnd() ) { | 1265 | while ( ! ts.atEnd() ) { |
1267 | os << ts.readLine() << "\r\n"; | 1266 | os << ts.readLine() << "\r\n"; |
1268 | } | 1267 | } |
1269 | //os << ts.read(); | 1268 | //os << ts.read(); |
1270 | file.close(); | 1269 | file.close(); |
1271 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); | 1270 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); |
1272 | mSocket->close(); | 1271 | mSocket->close(); |
1273 | if ( mSocket->state() == QSocket::Idle ) | 1272 | if ( mSocket->state() == QSocket::Idle ) |
1274 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1273 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1275 | } | 1274 | } |
1276 | void KServerSocket::get_file() | 1275 | void KServerSocket::get_file() |
1277 | { | 1276 | { |
1278 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); | 1277 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); |
1279 | 1278 | ||
1280 | piTime.start(); | 1279 | piTime.start(); |
1281 | piFileString = ""; | 1280 | piFileString = ""; |
1282 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); | 1281 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); |
1283 | } | 1282 | } |
1284 | 1283 | ||
1285 | 1284 | ||
1286 | void KServerSocket::readBackFileFromSocket() | 1285 | void KServerSocket::readBackFileFromSocket() |
1287 | { | 1286 | { |
1288 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); | 1287 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); |
1289 | while ( mSocket->canReadLine () ) { | 1288 | while ( mSocket->canReadLine () ) { |
1290 | piTime.restart(); | 1289 | piTime.restart(); |
1291 | QString line = mSocket->readLine (); | 1290 | QString line = mSocket->readLine (); |
1292 | piFileString += line; | 1291 | piFileString += line; |
1293 | //qDebug("readline: %s ", line.latin1()); | 1292 | //qDebug("readline: %s ", line.latin1()); |
1294 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); | 1293 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); |
1295 | 1294 | ||
1296 | } | 1295 | } |
1297 | if ( piTime.elapsed () < 3000 ) { | 1296 | if ( piTime.elapsed () < 3000 ) { |
1298 | // wait for more | 1297 | // wait for more |
1299 | //qDebug("waitformore "); | 1298 | //qDebug("waitformore "); |
1300 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); | 1299 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); |
1301 | return; | 1300 | return; |
1302 | } | 1301 | } |
1303 | QString fileName = mFileName; | 1302 | QString fileName = mFileName; |
1304 | QFile file ( fileName ); | 1303 | QFile file ( fileName ); |
1305 | if (!file.open( IO_WriteOnly ) ) { | 1304 | if (!file.open( IO_WriteOnly ) ) { |
1306 | delete mSyncActionDialog; | 1305 | delete mSyncActionDialog; |
1307 | mSyncActionDialog = 0; | 1306 | mSyncActionDialog = 0; |
1308 | qDebug("KSS:Error open read back file "); | 1307 | qDebug("KSS:Error open read back file "); |
1309 | piFileString = ""; | 1308 | piFileString = ""; |
1310 | emit file_received( false ); | 1309 | emit file_received( false ); |
1311 | blockRC = false; | 1310 | blockRC = false; |
1312 | return ; | 1311 | return ; |
1313 | 1312 | ||
1314 | } | 1313 | } |
1315 | 1314 | ||
1316 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1315 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1317 | QTextStream ts ( &file ); | 1316 | QTextStream ts ( &file ); |
1318 | ts.setEncoding( QTextStream::Latin1 ); | 1317 | ts.setEncoding( QTextStream::Latin1 ); |
1319 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); | 1318 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); |
1320 | ts << piFileString; | 1319 | ts << piFileString; |
1321 | mSocket->close(); | 1320 | mSocket->close(); |
1322 | if ( mSocket->state() == QSocket::Idle ) | 1321 | if ( mSocket->state() == QSocket::Idle ) |
1323 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1322 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1324 | file.close(); | 1323 | file.close(); |
1325 | piFileString = ""; | 1324 | piFileString = ""; |
1326 | emit file_received( true ); | 1325 | emit file_received( true ); |
1327 | delete mSyncActionDialog; | 1326 | delete mSyncActionDialog; |
1328 | mSyncActionDialog = 0; | 1327 | mSyncActionDialog = 0; |
1329 | blockRC = false; | 1328 | blockRC = false; |
1330 | 1329 | ||
1331 | } | 1330 | } |
1332 | 1331 | ||
1333 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) | 1332 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) |
1334 | { | 1333 | { |
1335 | mPassWord = password; | 1334 | mPassWord = password; |
1336 | mSocket = 0; | 1335 | mSocket = 0; |
1337 | mPort = port; | 1336 | mPort = port; |
1338 | mHost = host; | 1337 | mHost = host; |
1339 | 1338 | ||
1340 | mRetVal = quiet; | 1339 | mRetVal = quiet; |
1341 | mTimerSocket = new QTimer ( this ); | 1340 | mTimerSocket = new QTimer ( this ); |
1342 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); | 1341 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); |
1343 | } | 1342 | } |
1344 | void KCommandSocket::readFile( QString fn ) | 1343 | void KCommandSocket::readFile( QString fn ) |
1345 | { | 1344 | { |
1346 | if ( !mSocket ) { | 1345 | if ( !mSocket ) { |
1347 | mSocket = new QSocket( this ); | 1346 | mSocket = new QSocket( this ); |
1348 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); | 1347 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); |
1349 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1348 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1350 | } | 1349 | } |
1351 | mFileString = ""; | 1350 | mFileString = ""; |
1352 | mFileName = fn; | 1351 | mFileName = fn; |
1353 | mFirst = true; | 1352 | mFirst = true; |
1354 | mSocket->connectToHost( mHost, mPort ); | 1353 | mSocket->connectToHost( mHost, mPort ); |
1355 | QTextStream os( mSocket ); | 1354 | QTextStream os( mSocket ); |
1356 | os.setEncoding( QTextStream::Latin1 ); | 1355 | os.setEncoding( QTextStream::Latin1 ); |
1357 | 1356 | ||
1358 | QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); | 1357 | QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); |
1359 | os << "GET " << mPassWord << curDt <<"\r\n"; | 1358 | os << "GET " << mPassWord << curDt <<"\r\n"; |
1360 | mTimerSocket->start( 300000 ); | 1359 | mTimerSocket->start( 300000 ); |
1361 | } | 1360 | } |
1362 | 1361 | ||
1363 | void KCommandSocket::writeFile( QString fileName ) | 1362 | void KCommandSocket::writeFile( QString fileName ) |
1364 | { | 1363 | { |
1365 | if ( !mSocket ) { | 1364 | if ( !mSocket ) { |
1366 | mSocket = new QSocket( this ); | 1365 | mSocket = new QSocket( this ); |
1367 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1366 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1368 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); | 1367 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); |
1369 | } | 1368 | } |
1370 | mFileName = fileName ; | 1369 | mFileName = fileName ; |
1371 | mSocket->connectToHost( mHost, mPort ); | 1370 | mSocket->connectToHost( mHost, mPort ); |
1372 | } | 1371 | } |
1373 | void KCommandSocket::writeFileToSocket() | 1372 | void KCommandSocket::writeFileToSocket() |
1374 | { | 1373 | { |
1375 | QFile file2( mFileName ); | 1374 | QFile file2( mFileName ); |
1376 | if (!file2.open( IO_ReadOnly ) ) { | 1375 | if (!file2.open( IO_ReadOnly ) ) { |
1377 | mRetVal= errorW; | 1376 | mRetVal= errorW; |
1378 | mSocket->close(); | 1377 | mSocket->close(); |
1379 | if ( mSocket->state() == QSocket::Idle ) | 1378 | if ( mSocket->state() == QSocket::Idle ) |
1380 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1379 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1381 | return ; | 1380 | return ; |
1382 | } | 1381 | } |
1383 | QTextStream ts2( &file2 ); | 1382 | QTextStream ts2( &file2 ); |
1384 | ts2.setEncoding( QTextStream::Latin1 ); | 1383 | ts2.setEncoding( QTextStream::Latin1 ); |
1385 | QTextStream os2( mSocket ); | 1384 | QTextStream os2( mSocket ); |
1386 | os2.setEncoding( QTextStream::Latin1 ); | 1385 | os2.setEncoding( QTextStream::Latin1 ); |
1387 | os2 << "PUT " << mPassWord << "\r\n";; | 1386 | os2 << "PUT " << mPassWord << "\r\n";; |
1388 | while ( ! ts2.atEnd() ) { | 1387 | while ( ! ts2.atEnd() ) { |
1389 | os2 << ts2.readLine() << "\r\n"; | 1388 | os2 << ts2.readLine() << "\r\n"; |
1390 | } | 1389 | } |
1391 | mRetVal= successW; | 1390 | mRetVal= successW; |
1392 | file2.close(); | 1391 | file2.close(); |
1393 | mSocket->close(); | 1392 | mSocket->close(); |
1394 | if ( mSocket->state() == QSocket::Idle ) | 1393 | if ( mSocket->state() == QSocket::Idle ) |
1395 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1394 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1396 | } | 1395 | } |
1397 | void KCommandSocket::sendStop() | 1396 | void KCommandSocket::sendStop() |
1398 | { | 1397 | { |
1399 | if ( !mSocket ) { | 1398 | if ( !mSocket ) { |
1400 | mSocket = new QSocket( this ); | 1399 | mSocket = new QSocket( this ); |
1401 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1400 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1402 | } | 1401 | } |
1403 | mSocket->connectToHost( mHost, mPort ); | 1402 | mSocket->connectToHost( mHost, mPort ); |
1404 | QTextStream os2( mSocket ); | 1403 | QTextStream os2( mSocket ); |
1405 | os2.setEncoding( QTextStream::Latin1 ); | 1404 | os2.setEncoding( QTextStream::Latin1 ); |
1406 | os2 << "STOP\r\n"; | 1405 | os2 << "STOP\r\n"; |
1407 | mSocket->close(); | 1406 | mSocket->close(); |
1408 | if ( mSocket->state() == QSocket::Idle ) | 1407 | if ( mSocket->state() == QSocket::Idle ) |
1409 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1408 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1410 | } | 1409 | } |
1411 | 1410 | ||
1412 | void KCommandSocket::startReadFileFromSocket() | 1411 | void KCommandSocket::startReadFileFromSocket() |
1413 | { | 1412 | { |
1414 | if ( ! mFirst ) | 1413 | if ( ! mFirst ) |
1415 | return; | 1414 | return; |
1416 | mFirst = false; | 1415 | mFirst = false; |
1417 | mTimerSocket->stop(); | 1416 | mTimerSocket->stop(); |
1418 | mFileString = ""; | 1417 | mFileString = ""; |
1419 | mTime.start(); | 1418 | mTime.start(); |
1420 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); | 1419 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); |
1421 | 1420 | ||
1422 | } | 1421 | } |
1423 | void KCommandSocket::readFileFromSocket() | 1422 | void KCommandSocket::readFileFromSocket() |
1424 | { | 1423 | { |
1425 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); | 1424 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); |
1426 | while ( mSocket->canReadLine () ) { | 1425 | while ( mSocket->canReadLine () ) { |
1427 | mTime.restart(); | 1426 | mTime.restart(); |
1428 | QString line = mSocket->readLine (); | 1427 | QString line = mSocket->readLine (); |
1429 | mFileString += line; | 1428 | mFileString += line; |
1430 | //qDebug("readline: %s ", line.latin1()); | 1429 | //qDebug("readline: %s ", line.latin1()); |
1431 | } | 1430 | } |
1432 | if ( mTime.elapsed () < 3000 ) { | 1431 | if ( mTime.elapsed () < 3000 ) { |
1433 | // wait for more | 1432 | // wait for more |
1434 | //qDebug("waitformore "); | 1433 | //qDebug("waitformore "); |
1435 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); | 1434 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); |
1436 | return; | 1435 | return; |
1437 | } | 1436 | } |
1438 | QString fileName = mFileName; | 1437 | QString fileName = mFileName; |
1439 | QFile file ( fileName ); | 1438 | QFile file ( fileName ); |
1440 | if (!file.open( IO_WriteOnly ) ) { | 1439 | if (!file.open( IO_WriteOnly ) ) { |
1441 | mFileString = ""; | 1440 | mFileString = ""; |
1442 | mRetVal = errorR; | 1441 | mRetVal = errorR; |
1443 | qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); | 1442 | qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); |
1444 | deleteSocket(); | 1443 | deleteSocket(); |
1445 | return ; | 1444 | return ; |
1446 | 1445 | ||
1447 | } | 1446 | } |
1448 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1447 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1449 | QTextStream ts ( &file ); | 1448 | QTextStream ts ( &file ); |
1450 | ts.setEncoding( QTextStream::Latin1 ); | 1449 | ts.setEncoding( QTextStream::Latin1 ); |
1451 | ts << mFileString; | 1450 | ts << mFileString; |
1452 | file.close(); | 1451 | file.close(); |
1453 | mFileString = ""; | 1452 | mFileString = ""; |
1454 | mRetVal = successR; | 1453 | mRetVal = successR; |
1455 | mSocket->close(); | 1454 | mSocket->close(); |
1456 | // if state is not idle, deleteSocket(); is called via | 1455 | // if state is not idle, deleteSocket(); is called via |
1457 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1456 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1458 | if ( mSocket->state() == QSocket::Idle ) | 1457 | if ( mSocket->state() == QSocket::Idle ) |
1459 | deleteSocket(); | 1458 | deleteSocket(); |
1460 | } | 1459 | } |
1461 | 1460 | ||
1462 | void KCommandSocket::deleteSocket() | 1461 | void KCommandSocket::deleteSocket() |
1463 | { | 1462 | { |
1464 | //qDebug("KCommandSocket::deleteSocket() "); | 1463 | //qDebug("KCommandSocket::deleteSocket() "); |
1465 | if ( mTimerSocket->isActive () ) { | 1464 | if ( mTimerSocket->isActive () ) { |
1466 | mTimerSocket->stop(); | 1465 | mTimerSocket->stop(); |
1467 | mRetVal = errorTO; | 1466 | mRetVal = errorTO; |
1468 | qDebug("KCS::Connection to remote host timed out"); | 1467 | qDebug("KCS::Connection to remote host timed out"); |
1469 | if ( mSocket ) { | 1468 | if ( mSocket ) { |
1470 | mSocket->close(); | 1469 | mSocket->close(); |
1471 | //if ( mSocket->state() == QSocket::Idle ) | 1470 | //if ( mSocket->state() == QSocket::Idle ) |
1472 | // deleteSocket(); | 1471 | // deleteSocket(); |
1473 | delete mSocket; | 1472 | delete mSocket; |
1474 | mSocket = 0; | 1473 | mSocket = 0; |
1475 | } | 1474 | } |
1476 | KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? ")); | 1475 | KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? ")); |
1477 | emit commandFinished( this, mRetVal ); | 1476 | emit commandFinished( this, mRetVal ); |
1478 | return; | 1477 | return; |
1479 | } | 1478 | } |
1480 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); | 1479 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); |
1481 | if ( mSocket) | 1480 | if ( mSocket) |
1482 | delete mSocket; | 1481 | delete mSocket; |
1483 | mSocket = 0; | 1482 | mSocket = 0; |
1484 | emit commandFinished( this, mRetVal ); | 1483 | emit commandFinished( this, mRetVal ); |
1485 | } | 1484 | } |
diff --git a/libkdepim/phoneaccess.cpp b/libkdepim/phoneaccess.cpp index e24ad9e..89db22b 100644 --- a/libkdepim/phoneaccess.cpp +++ b/libkdepim/phoneaccess.cpp | |||
@@ -1,216 +1,216 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | 3 | ||
4 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> | 4 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | 22 | ||
23 | #include <qstring.h> | 23 | #include <qstring.h> |
24 | #include <qapplication.h> | 24 | #include <qapplication.h> |
25 | #include <qptrlist.h> | 25 | #include <qptrlist.h> |
26 | #include <qregexp.h> | 26 | #include <qregexp.h> |
27 | #include <qfile.h> | 27 | #include <qfile.h> |
28 | #include <qlabel.h> | 28 | #include <qlabel.h> |
29 | #include <qtextstream.h> | 29 | #include <qtextstream.h> |
30 | #include <qtextcodec.h> | 30 | #include <qtextcodec.h> |
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | #include <kmessagebox.h> | 32 | #include <kmessagebox.h> |
33 | #include <stdlib.h> | 33 | #include <stdlib.h> |
34 | #include "phoneaccess.h" | 34 | #include "phoneaccess.h" |
35 | 35 | ||
36 | void PhoneAccess::writeConfig( QString device, QString connection, QString model ) | 36 | void PhoneAccess::writeConfig( QString device, QString connection, QString model ) |
37 | { | 37 | { |
38 | #ifdef _WIN32_ | 38 | #ifdef _WIN32_ |
39 | QString fileName = qApp->applicationDirPath () +"\\gammurc"; | 39 | QString fileName = qApp->applicationDirPath () +"\\gammurc"; |
40 | #else | 40 | #else |
41 | QString fileName = QDir::homeDirPath() +"/.gammurc"; | 41 | QString fileName = QDir::homeDirPath() +"/.gammurc"; |
42 | #endif | 42 | #endif |
43 | //qDebug("save %d ", load ); | 43 | //qDebug("save %d ", load ); |
44 | QString content = "[gammu]\n";; | 44 | QString content = "[gammu]\n";; |
45 | bool write = false; | 45 | bool write = false; |
46 | bool addPort = true, addConnection = true, addModel = true; | 46 | bool addPort = true, addConnection = true, addModel = true; |
47 | QFile file( fileName ); | 47 | QFile file( fileName ); |
48 | if ( QFile::exists( fileName) ) { | 48 | if ( QFile::exists( fileName) ) { |
49 | if (!file.open( IO_ReadOnly ) ) { | 49 | if (!file.open( IO_ReadOnly ) ) { |
50 | qDebug("Error: cannot open %s ", fileName.latin1() ); | 50 | qDebug("Error: cannot open %s ", fileName.latin1() ); |
51 | return; | 51 | return; |
52 | } | 52 | } |
53 | QString line; | 53 | QString line; |
54 | while ( file.readLine( line, 1024 ) > 0 ) { | 54 | while ( file.readLine( line, 1024 ) > 0 ) { |
55 | //qDebug("*%s* ", line.latin1() ); | 55 | //qDebug("*%s* ", line.latin1() ); |
56 | if ( line.left(7 ) == "[gammu]" ) { | 56 | if ( line.left(7 ) == "[gammu]" ) { |
57 | ; | 57 | ; |
58 | } else | 58 | } else |
59 | if ( line.left(4 ) == "port" ) { | 59 | if ( line.left(4 ) == "port" ) { |
60 | if ( line == "port = " + device+"\n" ) { | 60 | if ( line == "port = " + device+"\n" ) { |
61 | content += line ; | 61 | content += line ; |
62 | addPort = false; | 62 | addPort = false; |
63 | //qDebug("port found" ); | 63 | //qDebug("port found" ); |
64 | } | 64 | } |
65 | 65 | ||
66 | } else if ( line.left(5 ) == "model" ) { | 66 | } else if ( line.left(5 ) == "model" ) { |
67 | if ( line == "model = " + model +"\n") { | 67 | if ( line == "model = " + model +"\n") { |
68 | content += line ; | 68 | content += line ; |
69 | addModel = false; | 69 | addModel = false; |
70 | //qDebug("model found" ); | 70 | //qDebug("model found" ); |
71 | } | 71 | } |
72 | 72 | ||
73 | } else if ( line.left( 10 ) == "connection" ) { | 73 | } else if ( line.left( 10 ) == "connection" ) { |
74 | if ( line == "connection = " + connection +"\n") { | 74 | if ( line == "connection = " + connection +"\n") { |
75 | addConnection = false; | 75 | addConnection = false; |
76 | content += line ; | 76 | content += line ; |
77 | //qDebug("con found" ); | 77 | //qDebug("con found" ); |
78 | } | 78 | } |
79 | 79 | ||
80 | } else { | 80 | } else { |
81 | content += line ; | 81 | content += line ; |
82 | } | 82 | } |
83 | } | 83 | } |
84 | file.close(); | 84 | file.close(); |
85 | } else { | 85 | } else { |
86 | if ( ! connection.isEmpty() ) { | 86 | if ( ! connection.isEmpty() ) { |
87 | addConnection = true; | 87 | addConnection = true; |
88 | } | 88 | } |
89 | if ( ! device.isEmpty() ) { | 89 | if ( ! device.isEmpty() ) { |
90 | addPort = true; | 90 | addPort = true; |
91 | 91 | ||
92 | } | 92 | } |
93 | if ( ! model.isEmpty() ) { | 93 | if ( ! model.isEmpty() ) { |
94 | addModel = true; | 94 | addModel = true; |
95 | } | 95 | } |
96 | } | 96 | } |
97 | 97 | ||
98 | if ( addConnection ) { | 98 | if ( addConnection ) { |
99 | write = true; | 99 | write = true; |
100 | content += "connection = "; | 100 | content += "connection = "; |
101 | content += connection; | 101 | content += connection; |
102 | content += "\n"; | 102 | content += "\n"; |
103 | } | 103 | } |
104 | if ( addPort ) { | 104 | if ( addPort ) { |
105 | write = true; | 105 | write = true; |
106 | content += "port = "; | 106 | content += "port = "; |
107 | content += device; | 107 | content += device; |
108 | content += "\n"; | 108 | content += "\n"; |
109 | 109 | ||
110 | } | 110 | } |
111 | if ( addModel ) { | 111 | if ( addModel ) { |
112 | write = true; | 112 | write = true; |
113 | content += "model = "; | 113 | content += "model = "; |
114 | content += model; | 114 | content += model; |
115 | content += "\n"; | 115 | content += "\n"; |
116 | } | 116 | } |
117 | if ( write ) { | 117 | if ( write ) { |
118 | if (!file.open( IO_WriteOnly ) ) { | 118 | if (!file.open( IO_WriteOnly ) ) { |
119 | qDebug("Error: cannot write file %s ", fileName.latin1() ); | 119 | qDebug("Error: cannot write file %s ", fileName.latin1() ); |
120 | return; | 120 | return; |
121 | } | 121 | } |
122 | qDebug("Writing file %s ", fileName.latin1() ); | 122 | qDebug("Writing file %s ", fileName.latin1() ); |
123 | QTextStream ts( &file ); | 123 | QTextStream ts( &file ); |
124 | ts << content ; | 124 | ts << content ; |
125 | file.close(); | 125 | file.close(); |
126 | } | 126 | } |
127 | 127 | ||
128 | } | 128 | } |
129 | 129 | ||
130 | 130 | ||
131 | bool PhoneAccess::writeToPhone( QString fileName) | 131 | bool PhoneAccess::writeToPhone( QString fileName) |
132 | { | 132 | { |
133 | 133 | ||
134 | #ifdef DESKTOP_VERSION | 134 | #ifdef DESKTOP_VERSION |
135 | #ifdef _WIN32_ | 135 | #ifdef _WIN32_ |
136 | QString command ="kammu --restore " + fileName ; | 136 | QString command ="kammu --restore " + fileName ; |
137 | #else | 137 | #else |
138 | QString command ="./kammu --restore " + fileName ; | 138 | QString command ="./kammu --restore " + fileName ; |
139 | #endif | 139 | #endif |
140 | #else | 140 | #else |
141 | QString command ="kammu --restore " + fileName ; | 141 | QString command ="kammu --restore " + fileName ; |
142 | #endif | 142 | #endif |
143 | int ret = 1; | 143 | int ret = 1; |
144 | while ( ret != 0 ) { | 144 | while ( ret != 0 ) { |
145 | QLabel* status = new QLabel( i18n(" This may take 1-3 minutes!"), 0 ); | 145 | QLabel* status = new QLabel( i18n(" This may take 1-3 minutes!"), 0 ); |
146 | int w = 235; | 146 | int w = 235; |
147 | int h = status->sizeHint().height()+20 ; | 147 | int h = status->sizeHint().height()+20 ; |
148 | int dw = QApplication::desktop()->width(); | 148 | int dw = QApplication::desktop()->width(); |
149 | int dh = QApplication::desktop()->height(); | 149 | int dh = QApplication::desktop()->height(); |
150 | if ( dw > 310 ) | 150 | if ( dw > 310 ) |
151 | w = 310; | 151 | w = 310; |
152 | status->setCaption(i18n("Writing to phone...") ); | 152 | status->setCaption(i18n("Writing to phone...") ); |
153 | status->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 153 | status->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
154 | status->show(); | 154 | status->show(); |
155 | status->raise(); | 155 | status->raise(); |
156 | status->update(); | 156 | status->update(); |
157 | qApp->processEvents(); | 157 | qApp->processEvents(); |
158 | status->update(); | 158 | status->update(); |
159 | qApp->processEvents(); | 159 | qApp->processEvents(); |
160 | ret = system ( command.latin1()); | 160 | ret = system ( command.latin1()); |
161 | delete status; | 161 | delete status; |
162 | qApp->processEvents(); | 162 | qApp->processEvents(); |
163 | if ( ret ) { | 163 | if ( ret ) { |
164 | qDebug("Error S::command returned %d.", ret); | 164 | qDebug("Error S::command returned %d.", ret); |
165 | int retval = KMessageBox::warningContinueCancel(0, | 165 | int retval = KMessageBox::warningContinueCancel(0, |
166 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); | 166 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); |
167 | if ( retval != KMessageBox::Continue ) | 167 | if ( retval != KMessageBox::Continue ) |
168 | return false; | 168 | return false; |
169 | } | 169 | } |
170 | } | 170 | } |
171 | return true; | 171 | return true; |
172 | } | 172 | } |
173 | bool PhoneAccess::readFromPhone( QString fileName) | 173 | bool PhoneAccess::readFromPhone( QString fileName) |
174 | { | 174 | { |
175 | 175 | ||
176 | #ifdef DESKTOP_VERSION | 176 | #ifdef DESKTOP_VERSION |
177 | #ifdef _WIN32_ | 177 | #ifdef _WIN32_ |
178 | QString command ="kammu --backup " + fileName + " -yes" ; | 178 | QString command ="kammu --backup " + fileName + " -yes" ; |
179 | #else | 179 | #else |
180 | QString command ="./kammu --backup " + fileName + " -yes" ; | 180 | QString command ="./kammu --backup " + fileName + " -yes" ; |
181 | #endif | 181 | #endif |
182 | #else | 182 | #else |
183 | QString command ="kammu --backup " + fileName + " -yes" ; | 183 | QString command ="kammu --backup " + fileName + " -yes" ; |
184 | #endif | 184 | #endif |
185 | int ret; | 185 | int ret = 1; |
186 | while ( ret != 0 ) { | 186 | while ( ret != 0 ) { |
187 | QLabel* status = new QLabel( i18n(" This may take 1-3 minutes!"), 0 ); | 187 | QLabel* status = new QLabel( i18n(" This may take 1-3 minutes!"), 0 ); |
188 | int w = 235; | 188 | int w = 235; |
189 | int h = status->sizeHint().height()+20 ; | 189 | int h = status->sizeHint().height()+20 ; |
190 | int dw = QApplication::desktop()->width(); | 190 | int dw = QApplication::desktop()->width(); |
191 | int dh = QApplication::desktop()->height(); | 191 | int dh = QApplication::desktop()->height(); |
192 | if ( dw > 310 ) | 192 | if ( dw > 310 ) |
193 | w = 310; | 193 | w = 310; |
194 | status->setCaption(i18n("Reading from phone...") ); | 194 | status->setCaption(i18n("Reading from phone...") ); |
195 | status->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 195 | status->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
196 | status->show(); | 196 | status->show(); |
197 | status->raise(); | 197 | status->raise(); |
198 | status->update(); | 198 | status->update(); |
199 | qApp->processEvents(); | 199 | qApp->processEvents(); |
200 | status->update(); | 200 | status->update(); |
201 | qApp->processEvents(); | 201 | qApp->processEvents(); |
202 | ret = system ( command.latin1() ); | 202 | ret = system ( command.latin1() ); |
203 | delete status; | 203 | delete status; |
204 | qApp->processEvents(); | 204 | qApp->processEvents(); |
205 | if ( ret ) { | 205 | if ( ret ) { |
206 | qDebug("Error reading from phone:Command returned %d", ret); | 206 | qDebug("Error reading from phone:Command returned %d", ret); |
207 | int retval = KMessageBox::warningContinueCancel(0, | 207 | int retval = KMessageBox::warningContinueCancel(0, |
208 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); | 208 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); |
209 | if ( retval != KMessageBox::Continue ) | 209 | if ( retval != KMessageBox::Continue ) |
210 | return false; | 210 | return false; |
211 | 211 | ||
212 | } | 212 | } |
213 | } | 213 | } |
214 | qApp->processEvents(); | 214 | qApp->processEvents(); |
215 | return true; | 215 | return true; |
216 | } | 216 | } |
diff --git a/microkde/kapplication.cpp b/microkde/kapplication.cpp index 21aa0a4..f05b91b 100644 --- a/microkde/kapplication.cpp +++ b/microkde/kapplication.cpp | |||
@@ -1,110 +1,111 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | 3 | ||
4 | #include "kapplication.h" | 4 | #include "kapplication.h" |
5 | #include "ktextedit.h" | 5 | #include "ktextedit.h" |
6 | #include <qapplication.h> | 6 | #include <qapplication.h> |
7 | #include <qstring.h> | 7 | #include <qstring.h> |
8 | #include <qfile.h> | 8 | #include <qfile.h> |
9 | #include <qtextstream.h> | 9 | #include <qtextstream.h> |
10 | #include <qdialog.h> | 10 | #include <qdialog.h> |
11 | #include <qlayout.h> | 11 | #include <qlayout.h> |
12 | #include <qtextbrowser.h> | 12 | #include <qtextbrowser.h> |
13 | 13 | ||
14 | int KApplication::random() | 14 | int KApplication::random() |
15 | { | 15 | { |
16 | return rand(); | 16 | return rand(); |
17 | } | 17 | } |
18 | 18 | ||
19 | //US | 19 | //US |
20 | QString KApplication::randomString(int length) | 20 | QString KApplication::randomString(int length) |
21 | { | 21 | { |
22 | if (length <=0 ) return QString::null; | 22 | if (length <=0 ) return QString::null; |
23 | 23 | ||
24 | QString str; | 24 | QString str; |
25 | while (length--) | 25 | while (length--) |
26 | { | 26 | { |
27 | int r=random() % 62; | 27 | int r=random() % 62; |
28 | r+=48; | 28 | r+=48; |
29 | if (r>57) r+=7; | 29 | if (r>57) r+=7; |
30 | if (r>90) r+=6; | 30 | if (r>90) r+=6; |
31 | str += char(r); | 31 | str += char(r); |
32 | // so what if I work backwards? | 32 | // so what if I work backwards? |
33 | } | 33 | } |
34 | return str; | 34 | return str; |
35 | } | 35 | } |
36 | int KApplication::execDialog( QDialog* d ) | 36 | int KApplication::execDialog( QDialog* d ) |
37 | { | 37 | { |
38 | if (QApplication::desktop()->width() <= 640 ) | 38 | if (QApplication::desktop()->width() <= 640 ) |
39 | d->showMaximized(); | 39 | d->showMaximized(); |
40 | else | 40 | else |
41 | ;//d->resize( 800, 600 ); | 41 | ;//d->resize( 800, 600 ); |
42 | return d->exec(); | 42 | return d->exec(); |
43 | } | 43 | } |
44 | void KApplication::showLicence() | 44 | void KApplication::showLicence() |
45 | { | 45 | { |
46 | KApplication::showFile( "KDE-Pim/Pi licence", "kdepim/licence.txt" ); | 46 | KApplication::showFile( "KDE-Pim/Pi licence", "kdepim/licence.txt" ); |
47 | } | 47 | } |
48 | 48 | ||
49 | void KApplication::showFile(QString caption, QString fn) | 49 | void KApplication::showFile(QString caption, QString fn) |
50 | { | 50 | { |
51 | QString text; | 51 | QString text; |
52 | QString fileName; | 52 | QString fileName; |
53 | #ifndef DESKTOP_VERSION | 53 | #ifndef DESKTOP_VERSION |
54 | fileName = getenv("QPEDIR"); | 54 | fileName = getenv("QPEDIR"); |
55 | fileName += "/pics/" + fn ; | 55 | fileName += "/pics/" + fn ; |
56 | #else | 56 | #else |
57 | fileName = qApp->applicationDirPath () + "/" + fn; | 57 | fileName = qApp->applicationDirPath () + "/" + fn; |
58 | #endif | 58 | #endif |
59 | QFile file( fileName ); | 59 | QFile file( fileName ); |
60 | if (!file.open( IO_ReadOnly ) ) { | 60 | if (!file.open( IO_ReadOnly ) ) { |
61 | return ; | 61 | return ; |
62 | } | 62 | } |
63 | QTextStream ts( &file ); | 63 | QTextStream ts( &file ); |
64 | text = ts.read(); | 64 | text = ts.read(); |
65 | file.close(); | 65 | file.close(); |
66 | KApplication::showText( caption, text ); | 66 | KApplication::showText( caption, text ); |
67 | 67 | ||
68 | } | 68 | } |
69 | 69 | ||
70 | bool KApplication::convert2latin1(QString fileName) | 70 | bool KApplication::convert2latin1(QString fileName) |
71 | { | 71 | { |
72 | QString text; | 72 | QString text; |
73 | QFile file( fileName ); | 73 | QFile file( fileName ); |
74 | if (!file.open( IO_ReadOnly ) ) { | 74 | if (!file.open( IO_ReadOnly ) ) { |
75 | return false; | 75 | return false; |
76 | 76 | ||
77 | } | 77 | } |
78 | QTextStream ts( &file ); | 78 | QTextStream ts( &file ); |
79 | ts.setEncoding( QTextStream::UnicodeUTF8 ); | 79 | ts.setEncoding( QTextStream::UnicodeUTF8 ); |
80 | text = ts.read(); | 80 | text = ts.read(); |
81 | file.close(); | 81 | file.close(); |
82 | if (!file.open( IO_WriteOnly ) ) { | 82 | if (!file.open( IO_WriteOnly ) ) { |
83 | return false; | 83 | return false; |
84 | } | 84 | } |
85 | QTextStream tsIn( &file ); | 85 | QTextStream tsIn( &file ); |
86 | tsIn.setEncoding( QTextStream::Latin1 ); | 86 | tsIn.setEncoding( QTextStream::Latin1 ); |
87 | tsIn << text.latin1(); | 87 | tsIn << text.latin1(); |
88 | file.close(); | 88 | file.close(); |
89 | return true; | ||
89 | 90 | ||
90 | 91 | ||
91 | } | 92 | } |
92 | void KApplication::showText(QString caption, QString text) | 93 | void KApplication::showText(QString caption, QString text) |
93 | { | 94 | { |
94 | QDialog dia( 0, "name", true ); ; | 95 | QDialog dia( 0, "name", true ); ; |
95 | dia.setCaption( caption ); | 96 | dia.setCaption( caption ); |
96 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 97 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
97 | lay->setSpacing( 3 ); | 98 | lay->setSpacing( 3 ); |
98 | lay->setMargin( 3 ); | 99 | lay->setMargin( 3 ); |
99 | KTextEdit tb ( &dia ); | 100 | KTextEdit tb ( &dia ); |
100 | tb.setWordWrap( QMultiLineEdit::WidgetWidth ); | 101 | tb.setWordWrap( QMultiLineEdit::WidgetWidth ); |
101 | lay->addWidget( &tb ); | 102 | lay->addWidget( &tb ); |
102 | tb.setText( text ); | 103 | tb.setText( text ); |
103 | #ifdef DESKTOP_VERSION | 104 | #ifdef DESKTOP_VERSION |
104 | dia.resize( 640, 480); | 105 | dia.resize( 640, 480); |
105 | #else | 106 | #else |
106 | dia.showMaximized(); | 107 | dia.showMaximized(); |
107 | #endif | 108 | #endif |
108 | dia.exec(); | 109 | dia.exec(); |
109 | 110 | ||
110 | } | 111 | } |
diff --git a/microkde/kdecore/klibloader.cpp b/microkde/kdecore/klibloader.cpp index 1394154..6d0475a 100644 --- a/microkde/kdecore/klibloader.cpp +++ b/microkde/kdecore/klibloader.cpp | |||
@@ -1,661 +1,653 @@ | |||
1 | /* This file is part of the KDE libraries | 1 | /* This file is part of the KDE libraries |
2 | Copyright (C) 1999 Torben Weis <weis@kde.org> | 2 | Copyright (C) 1999 Torben Weis <weis@kde.org> |
3 | Copyright (C) 2000 Michael Matz <matz@kde.org> | 3 | Copyright (C) 2000 Michael Matz <matz@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License version 2 as published by the Free Software Foundation. | 7 | License version 2 as published by the Free Software Foundation. |
8 | 8 | ||
9 | This library is distributed in the hope that it will be useful, | 9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. | 12 | Library General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | //US #include <config.h> | 19 | //US #include <config.h> |
20 | #include <qclipboard.h> | 20 | #include <qclipboard.h> |
21 | #include <qfile.h> | 21 | #include <qfile.h> |
22 | #include <qtimer.h> | 22 | #include <qtimer.h> |
23 | #include <qobjectdict.h> | 23 | #include <qobjectdict.h> |
24 | #include <qwidgetlist.h> | 24 | #include <qwidgetlist.h> |
25 | #include <qwidget.h> | 25 | #include <qwidget.h> |
26 | 26 | ||
27 | #include "kapplication.h" | 27 | #include "kapplication.h" |
28 | #include "klibloader.h" | 28 | #include "klibloader.h" |
29 | #include "kstandarddirs.h" | 29 | #include "kstandarddirs.h" |
30 | #include "kdebug.h" | 30 | #include "kdebug.h" |
31 | #include "klocale.h" | 31 | #include "klocale.h" |
32 | 32 | ||
33 | /*US | 33 | /*US |
34 | #ifndef NDEBUG | 34 | #ifndef NDEBUG |
35 | #include "ltdl.h" | 35 | #include "ltdl.h" |
36 | #endif | 36 | #endif |
37 | */ | 37 | */ |
38 | 38 | ||
39 | //US do everything through qlibrary | 39 | //US do everything through qlibrary |
40 | #ifndef DESKTOP_VERSION | 40 | #ifndef DESKTOP_VERSION |
41 | #include <qpe/qpeapplication.h> | 41 | #include <qpe/qpeapplication.h> |
42 | #include <qtopia/qlibrary.h> | 42 | #include <qtopia/qlibrary.h> |
43 | #else | 43 | #else |
44 | #include <qlibrary.h> | 44 | #include <qlibrary.h> |
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | 47 | ||
48 | template class QAsciiDict<KLibrary>; | 48 | template class QAsciiDict<KLibrary>; |
49 | 49 | ||
50 | #include <stdlib.h> //getenv | 50 | #include <stdlib.h> //getenv |
51 | 51 | ||
52 | /*US | 52 | /*US |
53 | #if HAVE_DLFCN_H | 53 | #if HAVE_DLFCN_H |
54 | # include <dlfcn.h> | 54 | # include <dlfcn.h> |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | #ifdef RTLD_GLOBAL | 57 | #ifdef RTLD_GLOBAL |
58 | # define LT_GLOBAL RTLD_GLOBAL | 58 | # define LT_GLOBAL RTLD_GLOBAL |
59 | #else | 59 | #else |
60 | # ifdef DL_GLOBAL | 60 | # ifdef DL_GLOBAL |
61 | # define LT_GLOBAL DL_GLOBAL | 61 | # define LT_GLOBAL DL_GLOBAL |
62 | # endif | 62 | # endif |
63 | #endif | 63 | #endif |
64 | #ifndef LT_GLOBAL | 64 | #ifndef LT_GLOBAL |
65 | # define LT_GLOBAL 0 | 65 | # define LT_GLOBAL 0 |
66 | #endif | 66 | #endif |
67 | */ | 67 | */ |
68 | 68 | ||
69 | /*US | 69 | /*US |
70 | extern "C" { | 70 | extern "C" { |
71 | extern int lt_dlopen_flag; | 71 | extern int lt_dlopen_flag; |
72 | } | 72 | } |
73 | */ | 73 | */ |
74 | 74 | ||
75 | KLibFactory::KLibFactory( QObject* parent, const char* name ) | 75 | KLibFactory::KLibFactory( QObject* parent, const char* name ) |
76 | : QObject( parent, name ) | 76 | : QObject( parent, name ) |
77 | { | 77 | { |
78 | } | 78 | } |
79 | 79 | ||
80 | KLibFactory::~KLibFactory() | 80 | KLibFactory::~KLibFactory() |
81 | { | 81 | { |
82 | // kdDebug(150) << "Deleting KLibFactory " << this << endl; | 82 | // kdDebug(150) << "Deleting KLibFactory " << this << endl; |
83 | } | 83 | } |
84 | 84 | ||
85 | QObject* KLibFactory::create( QObject* parent, const char* name, const char* classname, const QStringList &args ) | 85 | QObject* KLibFactory::create( QObject* parent, const char* name, const char* classname, const QStringList &args ) |
86 | { | 86 | { |
87 | QObject* obj = createObject( parent, name, classname, args ); | 87 | QObject* obj = createObject( parent, name, classname, args ); |
88 | if ( obj ) | 88 | if ( obj ) |
89 | emit objectCreated( obj ); | 89 | emit objectCreated( obj ); |
90 | return obj; | 90 | return obj; |
91 | } | 91 | } |
92 | 92 | ||
93 | 93 | ||
94 | QObject* KLibFactory::createObject( QObject*, const char*, const char*, const QStringList &) | 94 | QObject* KLibFactory::createObject( QObject*, const char*, const char*, const QStringList &) |
95 | { | 95 | { |
96 | return 0; | 96 | return 0; |
97 | } | 97 | } |
98 | 98 | ||
99 | 99 | ||
100 | // ----------------------------------------------- | 100 | // ----------------------------------------------- |
101 | 101 | ||
102 | //US KLibrary::KLibrary( const QString& libname, const QString& filename, void * handle ) | 102 | //US KLibrary::KLibrary( const QString& libname, const QString& filename, void * handle ) |
103 | KLibrary::KLibrary( const QString& libname, const QString& filename, QLibrary* handle ) | 103 | KLibrary::KLibrary( const QString& libname, const QString& filename, QLibrary* handle ) |
104 | { | 104 | { |
105 | /* Make sure, we have a KLibLoader */ | 105 | /* Make sure, we have a KLibLoader */ |
106 | (void) KLibLoader::self(); | 106 | (void) KLibLoader::self(); |
107 | m_libname = libname; | 107 | m_libname = libname; |
108 | m_filename = filename; | 108 | m_filename = filename; |
109 | m_handle = handle; | 109 | m_handle = handle; |
110 | m_factory = 0; | 110 | m_factory = 0; |
111 | m_timer = 0; | 111 | m_timer = 0; |
112 | } | 112 | } |
113 | 113 | ||
114 | KLibrary::~KLibrary() | 114 | KLibrary::~KLibrary() |
115 | { | 115 | { |
116 | // kdDebug(150) << "Deleting KLibrary " << this << " " << m_libname << endl; | 116 | // kdDebug(150) << "Deleting KLibrary " << this << " " << m_libname << endl; |
117 | if ( m_timer && m_timer->isActive() ) | 117 | if ( m_timer && m_timer->isActive() ) |
118 | m_timer->stop(); | 118 | m_timer->stop(); |
119 | 119 | ||
120 | // If any object is remaining, delete | 120 | // If any object is remaining, delete |
121 | if ( m_objs.count() > 0 ) | 121 | if ( m_objs.count() > 0 ) |
122 | { | 122 | { |
123 | QPtrListIterator<QObject> it( m_objs ); | 123 | QPtrListIterator<QObject> it( m_objs ); |
124 | for ( ; it.current() ; ++it ) | 124 | for ( ; it.current() ; ++it ) |
125 | { | 125 | { |
126 | kdDebug(150) << "Factory still has object " << it.current() << " " << it.current()->name () << " Library = " << m_libname << endl; | 126 | kdDebug(150) << "Factory still has object " << it.current() << " " << it.current()->name () << " Library = " << m_libname << endl; |
127 | disconnect( it.current(), SIGNAL( destroyed() ), | 127 | disconnect( it.current(), SIGNAL( destroyed() ), |
128 | this, SLOT( slotObjectDestroyed() ) ); | 128 | this, SLOT( slotObjectDestroyed() ) ); |
129 | } | 129 | } |
130 | m_objs.setAutoDelete(true); | 130 | m_objs.setAutoDelete(true); |
131 | m_objs.clear(); | 131 | m_objs.clear(); |
132 | } | 132 | } |
133 | 133 | ||
134 | if ( m_factory ) { | 134 | if ( m_factory ) { |
135 | //kdDebug(150) << " ... deleting the factory " << m_factory << endl; | 135 | //kdDebug(150) << " ... deleting the factory " << m_factory << endl; |
136 | delete m_factory; | 136 | delete m_factory; |
137 | } | 137 | } |
138 | } | 138 | } |
139 | 139 | ||
140 | QString KLibrary::name() const | 140 | QString KLibrary::name() const |
141 | { | 141 | { |
142 | return m_libname; | 142 | return m_libname; |
143 | } | 143 | } |
144 | 144 | ||
145 | QString KLibrary::fileName() const | 145 | QString KLibrary::fileName() const |
146 | { | 146 | { |
147 | return m_filename; | 147 | return m_filename; |
148 | } | 148 | } |
149 | 149 | ||
150 | KLibFactory* KLibrary::factory() | 150 | KLibFactory* KLibrary::factory() |
151 | { | 151 | { |
152 | if ( m_factory ) | 152 | if ( m_factory ) |
153 | return m_factory; | 153 | return m_factory; |
154 | 154 | ||
155 | QCString symname; | 155 | QCString symname; |
156 | symname.sprintf("init_%s", name().latin1() ); | 156 | symname.sprintf("init_%s", name().latin1() ); |
157 | 157 | ||
158 | void* sym = symbol( symname ); | 158 | void* sym = symbol( symname ); |
159 | if ( !sym ) | 159 | if ( !sym ) |
160 | { | 160 | { |
161 | qDebug("KLibrary: The library %s does not offer an %s function", name().latin1(), symname.data()); | 161 | qDebug("KLibrary: The library %s does not offer an %s function", name().latin1(), symname.data()); |
162 | #ifndef NDEBUG | 162 | #ifndef NDEBUG |
163 | //US qDebug("KLibrary: errorcode: %s", lt_dlerror()); | 163 | //US qDebug("KLibrary: errorcode: %s", lt_dlerror()); |
164 | #endif | 164 | #endif |
165 | kdWarning(150) << "KLibrary: The library " << name().latin1() << " does not offer an init_" << name().latin1() << " function" << endl; | 165 | kdWarning(150) << "KLibrary: The library " << name().latin1() << " does not offer an init_" << name().latin1() << " function" << endl; |
166 | return 0; | 166 | return 0; |
167 | } | 167 | } |
168 | 168 | ||
169 | typedef KLibFactory* (*t_func)(); | 169 | typedef KLibFactory* (*t_func)(); |
170 | t_func func = (t_func)sym; | 170 | t_func func = (t_func)sym; |
171 | m_factory = func(); | 171 | m_factory = func(); |
172 | 172 | ||
173 | if( !m_factory ) | 173 | if( !m_factory ) |
174 | { | 174 | { |
175 | kdWarning(150) << "KLibrary: The library " << name() << " does not offer a KDE compatible factory" << endl; | 175 | kdWarning(150) << "KLibrary: The library " << name() << " does not offer a KDE compatible factory" << endl; |
176 | return 0; | 176 | return 0; |
177 | } | 177 | } |
178 | 178 | ||
179 | connect( m_factory, SIGNAL( objectCreated( QObject * ) ), | 179 | connect( m_factory, SIGNAL( objectCreated( QObject * ) ), |
180 | this, SLOT( slotObjectCreated( QObject * ) ) ); | 180 | this, SLOT( slotObjectCreated( QObject * ) ) ); |
181 | 181 | ||
182 | return m_factory; | 182 | return m_factory; |
183 | } | 183 | } |
184 | 184 | ||
185 | void* KLibrary::symbol( const char* symname ) const | 185 | void* KLibrary::symbol( const char* symname ) const |
186 | { | 186 | { |
187 | //US void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname ); | 187 | //US void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname ); |
188 | void* sym = m_handle->resolve( symname ); | 188 | void* sym = m_handle->resolve( symname ); |
189 | if ( !sym ) | 189 | if ( !sym ) |
190 | { | 190 | { |
191 | //US kdWarning(150) << "KLibrary: " << lt_dlerror() << endl; | 191 | //US kdWarning(150) << "KLibrary: " << lt_dlerror() << endl; |
192 | return 0; | 192 | return 0; |
193 | } | 193 | } |
194 | 194 | ||
195 | return sym; | 195 | return sym; |
196 | } | 196 | } |
197 | 197 | ||
198 | bool KLibrary::hasSymbol( const char* symname ) const | 198 | bool KLibrary::hasSymbol( const char* symname ) const |
199 | { | 199 | { |
200 | //US void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname ); | 200 | //US void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname ); |
201 | void* sym = m_handle->resolve( symname ); | 201 | void* sym = m_handle->resolve( symname ); |
202 | return (sym != 0L ); | 202 | return (sym != 0L ); |
203 | } | 203 | } |
204 | 204 | ||
205 | void KLibrary::unload() const | 205 | void KLibrary::unload() const |
206 | { | 206 | { |
207 | if (KLibLoader::s_self) | 207 | if (KLibLoader::s_self) |
208 | KLibLoader::s_self->unloadLibrary(QFile::encodeName(name())); | 208 | KLibLoader::s_self->unloadLibrary(QFile::encodeName(name())); |
209 | } | 209 | } |
210 | 210 | ||
211 | void KLibrary::slotObjectCreated( QObject *obj ) | 211 | void KLibrary::slotObjectCreated( QObject *obj ) |
212 | { | 212 | { |
213 | if ( !obj ) | 213 | if ( !obj ) |
214 | return; | 214 | return; |
215 | 215 | ||
216 | if ( m_timer && m_timer->isActive() ) | 216 | if ( m_timer && m_timer->isActive() ) |
217 | m_timer->stop(); | 217 | m_timer->stop(); |
218 | 218 | ||
219 | if ( m_objs.containsRef( obj ) ) | 219 | if ( m_objs.containsRef( obj ) ) |
220 | return; // we know this object already | 220 | return; // we know this object already |
221 | 221 | ||
222 | connect( obj, SIGNAL( destroyed() ), | 222 | connect( obj, SIGNAL( destroyed() ), |
223 | this, SLOT( slotObjectDestroyed() ) ); | 223 | this, SLOT( slotObjectDestroyed() ) ); |
224 | 224 | ||
225 | m_objs.append( obj ); | 225 | m_objs.append( obj ); |
226 | } | 226 | } |
227 | 227 | ||
228 | void KLibrary::slotObjectDestroyed() | 228 | void KLibrary::slotObjectDestroyed() |
229 | { | 229 | { |
230 | m_objs.removeRef( sender() ); | 230 | m_objs.removeRef( sender() ); |
231 | 231 | ||
232 | if ( m_objs.count() == 0 ) | 232 | if ( m_objs.count() == 0 ) |
233 | { | 233 | { |
234 | // kdDebug(150) << "KLibrary: shutdown timer for " << name() << " started!" | 234 | // kdDebug(150) << "KLibrary: shutdown timer for " << name() << " started!" |
235 | // << endl; | 235 | // << endl; |
236 | 236 | ||
237 | if ( !m_timer ) | 237 | if ( !m_timer ) |
238 | { | 238 | { |
239 | m_timer = new QTimer( this, "klibrary_shutdown_timer" ); | 239 | m_timer = new QTimer( this, "klibrary_shutdown_timer" ); |
240 | connect( m_timer, SIGNAL( timeout() ), | 240 | connect( m_timer, SIGNAL( timeout() ), |
241 | this, SLOT( slotTimeout() ) ); | 241 | this, SLOT( slotTimeout() ) ); |
242 | } | 242 | } |
243 | 243 | ||
244 | // as long as it's not stable make the timeout short, for debugging | 244 | // as long as it's not stable make the timeout short, for debugging |
245 | // pleasure (matz) | 245 | // pleasure (matz) |
246 | //m_timer->start( 1000*60, true ); | 246 | //m_timer->start( 1000*60, true ); |
247 | m_timer->start( 1000*10, true ); | 247 | m_timer->start( 1000*10, true ); |
248 | } | 248 | } |
249 | } | 249 | } |
250 | 250 | ||
251 | void KLibrary::slotTimeout() | 251 | void KLibrary::slotTimeout() |
252 | { | 252 | { |
253 | if ( m_objs.count() != 0 ) | 253 | if ( m_objs.count() != 0 ) |
254 | return; | 254 | return; |
255 | 255 | ||
256 | /* Don't go through KLibLoader::unloadLibrary(), because that uses the | 256 | /* Don't go through KLibLoader::unloadLibrary(), because that uses the |
257 | ref counter, but this timeout means to unconditionally close this library | 257 | ref counter, but this timeout means to unconditionally close this library |
258 | The destroyed() signal will take care to remove us from all lists. | 258 | The destroyed() signal will take care to remove us from all lists. |
259 | */ | 259 | */ |
260 | delete this; | 260 | delete this; |
261 | } | 261 | } |
262 | 262 | ||
263 | // ------------------------------------------------- | 263 | // ------------------------------------------------- |
264 | 264 | ||
265 | /* This helper class is needed, because KLibraries can go away without | 265 | /* This helper class is needed, because KLibraries can go away without |
266 | being unloaded. So we need some info about KLibraries even after its | 266 | being unloaded. So we need some info about KLibraries even after its |
267 | death. */ | 267 | death. */ |
268 | class KLibWrapPrivate | 268 | class KLibWrapPrivate |
269 | { | 269 | { |
270 | public: | 270 | public: |
271 | //US KLibWrapPrivate(KLibrary *l, lt_dlhandle h); | 271 | //US KLibWrapPrivate(KLibrary *l, lt_dlhandle h); |
272 | KLibWrapPrivate(KLibrary *l, QLibrary* h); | 272 | KLibWrapPrivate(KLibrary *l, QLibrary* h); |
273 | 273 | ||
274 | KLibrary *lib; | 274 | KLibrary *lib; |
275 | enum {UNKNOWN, UNLOAD, DONT_UNLOAD} unload_mode; | 275 | enum {UNKNOWN, UNLOAD, DONT_UNLOAD} unload_mode; |
276 | int ref_count; | 276 | int ref_count; |
277 | //US lt_dlhandle handle; | 277 | //US lt_dlhandle handle; |
278 | QLibrary *handle; | 278 | QLibrary *handle; |
279 | QString name; | 279 | QString name; |
280 | QString filename; | 280 | QString filename; |
281 | }; | 281 | }; |
282 | 282 | ||
283 | //US KLibWrapPrivate::KLibWrapPrivate(KLibrary *l, lt_dlhandle h) | 283 | //US KLibWrapPrivate::KLibWrapPrivate(KLibrary *l, lt_dlhandle h) |
284 | KLibWrapPrivate::KLibWrapPrivate(KLibrary *l, QLibrary* h) | 284 | KLibWrapPrivate::KLibWrapPrivate(KLibrary *l, QLibrary* h) |
285 | : lib(l), ref_count(1), handle(h), name(l->name()), filename(l->fileName()) | 285 | : lib(l), ref_count(1), handle(h), name(l->name()), filename(l->fileName()) |
286 | { | 286 | { |
287 | unload_mode = UNKNOWN; | 287 | unload_mode = UNKNOWN; |
288 | /*US | 288 | /*US |
289 | if (lt_dlsym(handle, "__kde_do_not_unload") != 0) { | 289 | if (lt_dlsym(handle, "__kde_do_not_unload") != 0) { |
290 | // kdDebug(150) << "Will not unload " << name << endl; | 290 | // kdDebug(150) << "Will not unload " << name << endl; |
291 | unload_mode = DONT_UNLOAD; | 291 | unload_mode = DONT_UNLOAD; |
292 | } else if (lt_dlsym(handle, "__kde_do_unload") != 0) { | 292 | } else if (lt_dlsym(handle, "__kde_do_unload") != 0) { |
293 | unload_mode = UNLOAD; | 293 | unload_mode = UNLOAD; |
294 | } | 294 | } |
295 | */ | 295 | */ |
296 | //US use instead: | 296 | //US use instead: |
297 | if (h->resolve("__kde_do_not_unload") != 0) { | 297 | if (h->resolve("__kde_do_not_unload") != 0) { |
298 | // kdDebug(150) << "Will not unload " << name << endl; | 298 | // kdDebug(150) << "Will not unload " << name << endl; |
299 | unload_mode = DONT_UNLOAD; | 299 | unload_mode = DONT_UNLOAD; |
300 | } else if (h->resolve("__kde_do_unload") != 0) { | 300 | } else if (h->resolve("__kde_do_unload") != 0) { |
301 | unload_mode = UNLOAD; | 301 | unload_mode = UNLOAD; |
302 | } | 302 | } |
303 | } | 303 | } |
304 | 304 | ||
305 | class KLibLoaderPrivate | 305 | class KLibLoaderPrivate |
306 | { | 306 | { |
307 | public: | 307 | public: |
308 | QPtrList<KLibWrapPrivate> loaded_stack; | 308 | QPtrList<KLibWrapPrivate> loaded_stack; |
309 | QPtrList<KLibWrapPrivate> pending_close; | 309 | QPtrList<KLibWrapPrivate> pending_close; |
310 | enum {UNKNOWN, UNLOAD, DONT_UNLOAD} unload_mode; | 310 | enum {UNKNOWN, UNLOAD, DONT_UNLOAD} unload_mode; |
311 | 311 | ||
312 | QString errorMessage; | 312 | QString errorMessage; |
313 | }; | 313 | }; |
314 | 314 | ||
315 | KLibLoader* KLibLoader::s_self = 0; | 315 | KLibLoader* KLibLoader::s_self = 0; |
316 | 316 | ||
317 | KLibLoader* KLibLoader::self() | 317 | KLibLoader* KLibLoader::self() |
318 | { | 318 | { |
319 | if ( !s_self ) | 319 | if ( !s_self ) |
320 | s_self = new KLibLoader; | 320 | s_self = new KLibLoader; |
321 | return s_self; | 321 | return s_self; |
322 | } | 322 | } |
323 | 323 | ||
324 | void KLibLoader::cleanUp() | 324 | void KLibLoader::cleanUp() |
325 | { | 325 | { |
326 | if ( !s_self ) | 326 | if ( !s_self ) |
327 | return; | 327 | return; |
328 | 328 | ||
329 | delete s_self; | 329 | delete s_self; |
330 | s_self = 0; | 330 | s_self = 0; |
331 | } | 331 | } |
332 | 332 | ||
333 | KLibLoader::KLibLoader( QObject* parent, const char* name ) | 333 | KLibLoader::KLibLoader( QObject* parent, const char* name ) |
334 | : QObject( parent, name ) | 334 | : QObject( parent, name ) |
335 | { | 335 | { |
336 | s_self = this; | 336 | s_self = this; |
337 | d = new KLibLoaderPrivate; | 337 | d = new KLibLoaderPrivate; |
338 | //US lt_dlinit(); | 338 | //US lt_dlinit(); |
339 | d->unload_mode = KLibLoaderPrivate::UNKNOWN; | 339 | d->unload_mode = KLibLoaderPrivate::UNKNOWN; |
340 | if (getenv("KDE_NOUNLOAD") != 0) | 340 | if (getenv("KDE_NOUNLOAD") != 0) |
341 | d->unload_mode = KLibLoaderPrivate::DONT_UNLOAD; | 341 | d->unload_mode = KLibLoaderPrivate::DONT_UNLOAD; |
342 | else if (getenv("KDE_DOUNLOAD") != 0) | 342 | else if (getenv("KDE_DOUNLOAD") != 0) |
343 | d->unload_mode = KLibLoaderPrivate::UNLOAD; | 343 | d->unload_mode = KLibLoaderPrivate::UNLOAD; |
344 | d->loaded_stack.setAutoDelete( true ); | 344 | d->loaded_stack.setAutoDelete( true ); |
345 | } | 345 | } |
346 | 346 | ||
347 | KLibLoader::~KLibLoader() | 347 | KLibLoader::~KLibLoader() |
348 | { | 348 | { |
349 | // kdDebug(150) << "Deleting KLibLoader " << this << " " << name() << endl; | 349 | // kdDebug(150) << "Deleting KLibLoader " << this << " " << name() << endl; |
350 | 350 | ||
351 | QAsciiDictIterator<KLibWrapPrivate> it( m_libs ); | 351 | QAsciiDictIterator<KLibWrapPrivate> it( m_libs ); |
352 | for (; it.current(); ++it ) | 352 | for (; it.current(); ++it ) |
353 | { | 353 | { |
354 | kdDebug(150) << "The KLibLoader contains the library " << it.current()->name | 354 | kdDebug(150) << "The KLibLoader contains the library " << it.current()->name |
355 | << " (" << it.current()->lib << ")" << endl; | 355 | << " (" << it.current()->lib << ")" << endl; |
356 | d->pending_close.append(it.current()); | 356 | d->pending_close.append(it.current()); |
357 | } | 357 | } |
358 | 358 | ||
359 | close_pending(0); | 359 | close_pending(0); |
360 | 360 | ||
361 | delete d; | 361 | delete d; |
362 | } | 362 | } |
363 | 363 | ||
364 | //static | 364 | //static |
365 | QString KLibLoader::findLibrary( const char * name/*US , const KInstance * instance*/ ) | 365 | QString KLibLoader::findLibrary( const char * name/*US , const KInstance * instance*/ ) |
366 | { | 366 | { |
367 | QCString libname( name ); | 367 | QCString libname( name ); |
368 | 368 | ||
369 | // only append ".la" if there is no extension | 369 | // only append ".la" if there is no extension |
370 | // this allows to load non-libtool libraries as well | 370 | // this allows to load non-libtool libraries as well |
371 | // (mhk, 20000228) | 371 | // (mhk, 20000228) |
372 | int pos = libname.findRev('/'); | 372 | int pos = libname.findRev('/'); |
373 | if (pos < 0) | 373 | if (pos < 0) |
374 | pos = 0; | 374 | pos = 0; |
375 | /*US | 375 | /*US |
376 | if (libname.find('.', pos) < 0) { | 376 | if (libname.find('.', pos) < 0) { |
377 | libname += ".la"; | 377 | libname += ".la"; |
378 | } | 378 | } |
379 | */ | 379 | */ |
380 | //US in the microedition we work only with shared libraries. | 380 | //US in the microedition we work only with shared libraries. |
381 | 381 | ||
382 | if (libname.find('.', pos) < 0) { | 382 | if (libname.find('.', pos) < 0) { |
383 | #ifdef _WIN32_ | 383 | #ifdef _WIN32_ |
384 | libname += ".dll"; | 384 | libname += ".dll"; |
385 | #else | 385 | #else |
386 | libname += ".so"; | 386 | libname += ".so"; |
387 | #endif | 387 | #endif |
388 | } | 388 | } |
389 | 389 | ||
390 | // only look up the file if it is not an absolute filename | 390 | // only look up the file if it is not an absolute filename |
391 | // (mhk, 20000228) | 391 | // (mhk, 20000228) |
392 | QString libfile; | 392 | QString libfile; |
393 | if (libname[0] == '/') | 393 | if (libname[0] == '/') |
394 | libfile = libname; | 394 | libfile = libname; |
395 | else | 395 | else |
396 | { | 396 | { |
397 | //US at this point the libname must exist as real filesname. No expansions will be made later | 397 | //US at this point the libname must exist as real filesname. No expansions will be made later |
398 | // in findResources. Because of that we prepend the lib prefix here to the name | 398 | // in findResources. Because of that we prepend the lib prefix here to the name |
399 | //US I add also the "lib" prefix. I do not how could this could have worked before without it? | 399 | //US I add also the "lib" prefix. I do not how could this could have worked before without it? |
400 | #ifndef _WIN32_ | 400 | #ifndef _WIN32_ |
401 | libname.insert(pos, "lib"); | 401 | libname.insert(pos, "lib"); |
402 | #endif | 402 | #endif |
403 | 403 | ||
404 | 404 | ||
405 | //US libfile = instance->dirs()->findResource( "module", libname ); | 405 | //US libfile = instance->dirs()->findResource( "module", libname ); |
406 | //qDebug("libname = %s ",libname.data() ); | 406 | //qDebug("libname = %s ",libname.data() ); |
407 | libfile = KGlobal::dirs()->findResource( "module", libname ); | 407 | libfile = KGlobal::dirs()->findResource( "module", libname ); |
408 | //qDebug("libfile = %s ",libfile.latin1() ); | 408 | //qDebug("libfile = %s ",libfile.latin1() ); |
409 | 409 | ||
410 | if ( libfile.isEmpty() ) | 410 | if ( libfile.isEmpty() ) |
411 | { | 411 | { |
412 | //US libfile = instance->dirs()->findResource( "lib", libname ); | 412 | //US libfile = instance->dirs()->findResource( "lib", libname ); |
413 | libfile = KGlobal::dirs()->findResource( "lib", libname ); | 413 | libfile = KGlobal::dirs()->findResource( "lib", libname ); |
414 | //qDebug("libfile2 = %s ",libfile.latin1() ); | 414 | //qDebug("libfile2 = %s ",libfile.latin1() ); |
415 | #ifndef NDEBUG | 415 | #ifndef NDEBUG |
416 | if ( !libfile.isEmpty() && libname.left(3) == "lib" ) // don't warn for kdeinit modules | 416 | if ( !libfile.isEmpty() && libname.left(3) == "lib" ) // don't warn for kdeinit modules |
417 | kdDebug(150) << "library " << libname << " not found under 'module' but under 'lib'" << endl; | 417 | kdDebug(150) << "library " << libname << " not found under 'module' but under 'lib'" << endl; |
418 | #endif | 418 | #endif |
419 | } | 419 | } |
420 | if ( libfile.isEmpty() ) | 420 | if ( libfile.isEmpty() ) |
421 | { | 421 | { |
422 | #ifndef NDEBUG | 422 | #ifndef NDEBUG |
423 | kdDebug(150) << "library=" << libname << ": No file names " << libname.data() << " found in paths." << endl; | 423 | kdDebug(150) << "library=" << libname << ": No file names " << libname.data() << " found in paths." << endl; |
424 | self()->d->errorMessage = i18n("Library files for \"%1\" not found in paths").arg(libname); | 424 | self()->d->errorMessage = i18n("Library files for \"%1\" not found in paths").arg(libname); |
425 | 425 | ||
426 | qDebug("KLibLoader::library could not find library: %s", libname.data()); | 426 | qDebug("KLibLoader::library could not find library: %s", libname.data()); |
427 | #endif | 427 | #endif |
428 | 428 | ||
429 | } | 429 | } |
430 | else | 430 | else |
431 | self()->d->errorMessage = QString::null; | 431 | self()->d->errorMessage = QString::null; |
432 | } | 432 | } |
433 | 433 | ||
434 | //qDebug("return libfile = %s ",libfile.latin1() ); | 434 | //qDebug("return libfile = %s ",libfile.latin1() ); |
435 | return libfile; | 435 | return libfile; |
436 | } | 436 | } |
437 | 437 | ||
438 | 438 | ||
439 | KLibrary* KLibLoader::globalLibrary( const char *name ) | 439 | KLibrary* KLibLoader::globalLibrary( const char *name ) |
440 | { | 440 | { |
441 | KLibrary *tmp; | 441 | KLibrary *tmp; |
442 | /*US | 442 | /*US |
443 | int olt_dlopen_flag = lt_dlopen_flag; | 443 | int olt_dlopen_flag = lt_dlopen_flag; |
444 | 444 | ||
445 | lt_dlopen_flag |= LT_GLOBAL; | 445 | lt_dlopen_flag |= LT_GLOBAL; |
446 | kdDebug(150) << "Loading the next library global with flag " | 446 | kdDebug(150) << "Loading the next library global with flag " |
447 | << lt_dlopen_flag | 447 | << lt_dlopen_flag |
448 | << "." << endl; | 448 | << "." << endl; |
449 | */ | 449 | */ |
450 | tmp = library(name); | 450 | tmp = library(name); |
451 | /*US | 451 | /*US |
452 | lt_dlopen_flag = olt_dlopen_flag; | 452 | lt_dlopen_flag = olt_dlopen_flag; |
453 | */ | 453 | */ |
454 | return tmp; | 454 | return tmp; |
455 | } | 455 | } |
456 | 456 | ||
457 | 457 | ||
458 | KLibrary* KLibLoader::library( const char *name ) | 458 | KLibrary* KLibLoader::library( const char *name ) |
459 | { | 459 | { |
460 | if (!name) | 460 | if (!name) |
461 | return 0; | 461 | return 0; |
462 | 462 | ||
463 | KLibWrapPrivate* wrap = m_libs[name]; | 463 | KLibWrapPrivate* wrap = m_libs[name]; |
464 | if (wrap) { | 464 | if (wrap) { |
465 | /* Nothing to do to load the library. */ | 465 | /* Nothing to do to load the library. */ |
466 | wrap->ref_count++; | 466 | wrap->ref_count++; |
467 | return wrap->lib; | 467 | return wrap->lib; |
468 | } | 468 | } |
469 | 469 | ||
470 | /* Test if this library was loaded at some time, but got | 470 | /* Test if this library was loaded at some time, but got |
471 | unloaded meanwhile, whithout being dlclose()'ed. */ | 471 | unloaded meanwhile, whithout being dlclose()'ed. */ |
472 | QPtrListIterator<KLibWrapPrivate> it(d->loaded_stack); | 472 | QPtrListIterator<KLibWrapPrivate> it(d->loaded_stack); |
473 | for (; it.current(); ++it) { | 473 | for (; it.current(); ++it) { |
474 | if (it.current()->name == name) | 474 | if (it.current()->name == name) |
475 | wrap = it.current(); | 475 | wrap = it.current(); |
476 | } | 476 | } |
477 | 477 | ||
478 | if (wrap) { | 478 | if (wrap) { |
479 | d->pending_close.removeRef(wrap); | 479 | d->pending_close.removeRef(wrap); |
480 | if (!wrap->lib) { | 480 | if (!wrap->lib) { |
481 | /* This lib only was in loaded_stack, but not in m_libs. */ | 481 | /* This lib only was in loaded_stack, but not in m_libs. */ |
482 | wrap->lib = new KLibrary( name, wrap->filename, wrap->handle ); | 482 | wrap->lib = new KLibrary( name, wrap->filename, wrap->handle ); |
483 | } | 483 | } |
484 | wrap->ref_count++; | 484 | wrap->ref_count++; |
485 | } else { | 485 | } else { |
486 | QString libfile = findLibrary( name ); | 486 | QString libfile = findLibrary( name ); |
487 | if ( libfile.isEmpty() ) | 487 | if ( libfile.isEmpty() ) |
488 | return 0; | 488 | return 0; |
489 | #ifdef DESKTOP_VERSION | 489 | #ifdef DESKTOP_VERSION |
490 | QLibrary *qlib = new QLibrary( libfile.latin1() ); | 490 | QLibrary *qlib = new QLibrary( libfile.latin1() ); |
491 | #else | 491 | #else |
492 | QLibrary *qlib = new QLibrary( libfile.latin1(), QLibrary::Immediately ); | 492 | QLibrary *qlib = new QLibrary( libfile.latin1(), QLibrary::Immediately ); |
493 | #endif | 493 | #endif |
494 | 494 | ||
495 | //US lt_dlhandle handle = lt_dlopen( libfile.latin1() ); | 495 | //US lt_dlhandle handle = lt_dlopen( libfile.latin1() ); |
496 | //US if ( !handle ) | 496 | //US if ( !handle ) |
497 | if ( !qlib ) | 497 | if ( !qlib ) |
498 | { | 498 | { |
499 | //US const char* errmsg = lt_dlerror(); | 499 | qDebug( "KLibLoader::library could not load library: %s", libfile.latin1()); |
500 | char* errmsg; | 500 | d->errorMessage = QString::null; |
501 | sprintf(errmsg, "KLibLoader::library could not load library: %s", libfile.latin1()); | 501 | return 0; |
502 | qDebug(errmsg); | ||
503 | |||
504 | if(errmsg) | ||
505 | d->errorMessage = QString::fromLatin1(errmsg); | ||
506 | else | ||
507 | d->errorMessage = QString::null; | ||
508 | kdWarning(150) << "library=" << name << ": file=" << libfile << ": " << d->errorMessage << endl; | ||
509 | return 0; | ||
510 | } | 502 | } |
511 | else | 503 | else |
512 | d->errorMessage = QString::null; | 504 | d->errorMessage = QString::null; |
513 | 505 | ||
514 | KLibrary *lib = new KLibrary( name, libfile, qlib ); | 506 | KLibrary *lib = new KLibrary( name, libfile, qlib ); |
515 | wrap = new KLibWrapPrivate(lib, qlib); | 507 | wrap = new KLibWrapPrivate(lib, qlib); |
516 | d->loaded_stack.prepend(wrap); | 508 | d->loaded_stack.prepend(wrap); |
517 | } | 509 | } |
518 | m_libs.insert( name, wrap ); | 510 | m_libs.insert( name, wrap ); |
519 | 511 | ||
520 | connect( wrap->lib, SIGNAL( destroyed() ), | 512 | connect( wrap->lib, SIGNAL( destroyed() ), |
521 | this, SLOT( slotLibraryDestroyed() ) ); | 513 | this, SLOT( slotLibraryDestroyed() ) ); |
522 | 514 | ||
523 | return wrap->lib; | 515 | return wrap->lib; |
524 | } | 516 | } |
525 | 517 | ||
526 | QString KLibLoader::lastErrorMessage() const | 518 | QString KLibLoader::lastErrorMessage() const |
527 | { | 519 | { |
528 | return d->errorMessage; | 520 | return d->errorMessage; |
529 | } | 521 | } |
530 | 522 | ||
531 | void KLibLoader::unloadLibrary( const char *libname ) | 523 | void KLibLoader::unloadLibrary( const char *libname ) |
532 | { | 524 | { |
533 | KLibWrapPrivate *wrap = m_libs[ libname ]; | 525 | KLibWrapPrivate *wrap = m_libs[ libname ]; |
534 | if (!wrap) | 526 | if (!wrap) |
535 | return; | 527 | return; |
536 | if (--wrap->ref_count) | 528 | if (--wrap->ref_count) |
537 | return; | 529 | return; |
538 | 530 | ||
539 | // kdDebug(150) << "closing library " << libname << endl; | 531 | // kdDebug(150) << "closing library " << libname << endl; |
540 | 532 | ||
541 | m_libs.remove( libname ); | 533 | m_libs.remove( libname ); |
542 | 534 | ||
543 | disconnect( wrap->lib, SIGNAL( destroyed() ), | 535 | disconnect( wrap->lib, SIGNAL( destroyed() ), |
544 | this, SLOT( slotLibraryDestroyed() ) ); | 536 | this, SLOT( slotLibraryDestroyed() ) ); |
545 | close_pending( wrap ); | 537 | close_pending( wrap ); |
546 | } | 538 | } |
547 | 539 | ||
548 | KLibFactory* KLibLoader::factory( const char* name ) | 540 | KLibFactory* KLibLoader::factory( const char* name ) |
549 | { | 541 | { |
550 | KLibrary* lib = library( name ); | 542 | KLibrary* lib = library( name ); |
551 | if ( !lib ) | 543 | if ( !lib ) |
552 | return 0; | 544 | return 0; |
553 | 545 | ||
554 | return lib->factory(); | 546 | return lib->factory(); |
555 | } | 547 | } |
556 | 548 | ||
557 | void KLibLoader::slotLibraryDestroyed() | 549 | void KLibLoader::slotLibraryDestroyed() |
558 | { | 550 | { |
559 | const KLibrary *lib = static_cast<const KLibrary *>( sender() ); | 551 | const KLibrary *lib = static_cast<const KLibrary *>( sender() ); |
560 | 552 | ||
561 | QAsciiDictIterator<KLibWrapPrivate> it( m_libs ); | 553 | QAsciiDictIterator<KLibWrapPrivate> it( m_libs ); |
562 | for (; it.current(); ++it ) | 554 | for (; it.current(); ++it ) |
563 | if ( it.current()->lib == lib ) | 555 | if ( it.current()->lib == lib ) |
564 | { | 556 | { |
565 | KLibWrapPrivate *wrap = it.current(); | 557 | KLibWrapPrivate *wrap = it.current(); |
566 | wrap->lib = 0; /* the KLibrary object is already away */ | 558 | wrap->lib = 0; /* the KLibrary object is already away */ |
567 | m_libs.remove( it.currentKey() ); | 559 | m_libs.remove( it.currentKey() ); |
568 | close_pending( wrap ); | 560 | close_pending( wrap ); |
569 | return; | 561 | return; |
570 | } | 562 | } |
571 | } | 563 | } |
572 | 564 | ||
573 | void KLibLoader::close_pending(KLibWrapPrivate *wrap) | 565 | void KLibLoader::close_pending(KLibWrapPrivate *wrap) |
574 | { | 566 | { |
575 | if (wrap && !d->pending_close.containsRef( wrap )) | 567 | if (wrap && !d->pending_close.containsRef( wrap )) |
576 | d->pending_close.append( wrap ); | 568 | d->pending_close.append( wrap ); |
577 | 569 | ||
578 | /* First delete all KLibrary objects in pending_close, but _don't_ unload | 570 | /* First delete all KLibrary objects in pending_close, but _don't_ unload |
579 | the DSO behind it. */ | 571 | the DSO behind it. */ |
580 | QPtrListIterator<KLibWrapPrivate> it(d->pending_close); | 572 | QPtrListIterator<KLibWrapPrivate> it(d->pending_close); |
581 | for (; it.current(); ++it) { | 573 | for (; it.current(); ++it) { |
582 | wrap = it.current(); | 574 | wrap = it.current(); |
583 | if (wrap->lib) { | 575 | if (wrap->lib) { |
584 | disconnect( wrap->lib, SIGNAL( destroyed() ), | 576 | disconnect( wrap->lib, SIGNAL( destroyed() ), |
585 | this, SLOT( slotLibraryDestroyed() ) ); | 577 | this, SLOT( slotLibraryDestroyed() ) ); |
586 | delete wrap->lib; | 578 | delete wrap->lib; |
587 | wrap->lib = 0; | 579 | wrap->lib = 0; |
588 | } | 580 | } |
589 | } | 581 | } |
590 | 582 | ||
591 | if (d->unload_mode == KLibLoaderPrivate::DONT_UNLOAD) return; | 583 | if (d->unload_mode == KLibLoaderPrivate::DONT_UNLOAD) return; |
592 | 584 | ||
593 | bool deleted_one = false; | 585 | bool deleted_one = false; |
594 | while ((wrap = d->loaded_stack.first())) { | 586 | while ((wrap = d->loaded_stack.first())) { |
595 | /* Let's first see, if we want to try to unload this lib. | 587 | /* Let's first see, if we want to try to unload this lib. |
596 | If the env. var KDE_DOUNLOAD is set, we try to unload every lib. | 588 | If the env. var KDE_DOUNLOAD is set, we try to unload every lib. |
597 | If not, we look at the lib itself, and unload it only, if it exports | 589 | If not, we look at the lib itself, and unload it only, if it exports |
598 | the symbol __kde_do_unload. */ | 590 | the symbol __kde_do_unload. */ |
599 | if (d->unload_mode != KLibLoaderPrivate::UNLOAD | 591 | if (d->unload_mode != KLibLoaderPrivate::UNLOAD |
600 | && wrap->unload_mode != KLibWrapPrivate::UNLOAD) | 592 | && wrap->unload_mode != KLibWrapPrivate::UNLOAD) |
601 | break; | 593 | break; |
602 | 594 | ||
603 | /* Now ensure, that the libs are only unloaded in the reverse direction | 595 | /* Now ensure, that the libs are only unloaded in the reverse direction |
604 | they were loaded. */ | 596 | they were loaded. */ |
605 | if (!d->pending_close.containsRef( wrap )) { | 597 | if (!d->pending_close.containsRef( wrap )) { |
606 | if (!deleted_one) | 598 | if (!deleted_one) |
607 | /* Only diagnose, if we really haven't deleted anything. */ | 599 | /* Only diagnose, if we really haven't deleted anything. */ |
608 | // kdDebug(150) << "try to dlclose " << wrap->name << ": not yet" << endl; | 600 | // kdDebug(150) << "try to dlclose " << wrap->name << ": not yet" << endl; |
609 | break; | 601 | break; |
610 | } | 602 | } |
611 | 603 | ||
612 | // kdDebug(150) << "try to dlclose " << wrap->name << ": yes, done." << endl; | 604 | // kdDebug(150) << "try to dlclose " << wrap->name << ": yes, done." << endl; |
613 | 605 | ||
614 | #if 0 | 606 | #if 0 |
615 | #ifndef Q_WS_QWS | 607 | #ifndef Q_WS_QWS |
616 | if ( !deleted_one ) { | 608 | if ( !deleted_one ) { |
617 | /* Only do the hack once in this loop. | 609 | /* Only do the hack once in this loop. |
618 | WABA: *HACK* | 610 | WABA: *HACK* |
619 | We need to make sure to clear the clipboard before unloading a DSO | 611 | We need to make sure to clear the clipboard before unloading a DSO |
620 | because the DSO could have defined an object derived from QMimeSource | 612 | because the DSO could have defined an object derived from QMimeSource |
621 | and placed that on the clipboard. */ | 613 | and placed that on the clipboard. */ |
622 | /*kapp->clipboard()->clear();*/ | 614 | /*kapp->clipboard()->clear();*/ |
623 | 615 | ||
624 | /* Well.. let's do something more subtle... convert the clipboard context | 616 | /* Well.. let's do something more subtle... convert the clipboard context |
625 | to text. That should be safe as it only uses objects defined by Qt. */ | 617 | to text. That should be safe as it only uses objects defined by Qt. */ |
626 | 618 | ||
627 | QWidgetList *widgetlist = QApplication::topLevelWidgets(); | 619 | QWidgetList *widgetlist = QApplication::topLevelWidgets(); |
628 | QWidget *co = widgetlist->first(); | 620 | QWidget *co = widgetlist->first(); |
629 | while (co) { | 621 | while (co) { |
630 | if (qstrcmp(co->name(), "internal clipboard owner") == 0) { | 622 | if (qstrcmp(co->name(), "internal clipboard owner") == 0) { |
631 | if (XGetSelectionOwner(co->x11Display(), XA_PRIMARY) == co->winId()) | 623 | if (XGetSelectionOwner(co->x11Display(), XA_PRIMARY) == co->winId()) |
632 | kapp->clipboard()->setText(kapp->clipboard()->text()); | 624 | kapp->clipboard()->setText(kapp->clipboard()->text()); |
633 | 625 | ||
634 | break; | 626 | break; |
635 | } | 627 | } |
636 | co = widgetlist->next(); | 628 | co = widgetlist->next(); |
637 | } | 629 | } |
638 | delete widgetlist; | 630 | delete widgetlist; |
639 | } | 631 | } |
640 | #else | 632 | #else |
641 | // FIXME(E): Implement in Qt Embedded | 633 | // FIXME(E): Implement in Qt Embedded |
642 | #endif | 634 | #endif |
643 | 635 | ||
644 | #endif // 0 | 636 | #endif // 0 |
645 | deleted_one = true; | 637 | deleted_one = true; |
646 | //US lt_dlclose(wrap->handle); | 638 | //US lt_dlclose(wrap->handle); |
647 | wrap->handle->unload(); | 639 | wrap->handle->unload(); |
648 | 640 | ||
649 | d->pending_close.removeRef(wrap); | 641 | d->pending_close.removeRef(wrap); |
650 | /* loaded_stack is AutoDelete, so wrap is freed */ | 642 | /* loaded_stack is AutoDelete, so wrap is freed */ |
651 | d->loaded_stack.remove(); | 643 | d->loaded_stack.remove(); |
652 | } | 644 | } |
653 | } | 645 | } |
654 | 646 | ||
655 | void KLibLoader::virtual_hook( int, void* ) | 647 | void KLibLoader::virtual_hook( int, void* ) |
656 | { /*BASE::virtual_hook( id, data );*/ } | 648 | { /*BASE::virtual_hook( id, data );*/ } |
657 | 649 | ||
658 | void KLibFactory::virtual_hook( int, void* ) | 650 | void KLibFactory::virtual_hook( int, void* ) |
659 | { /*BASE::virtual_hook( id, data );*/ } | 651 | { /*BASE::virtual_hook( id, data );*/ } |
660 | 652 | ||
661 | //US #include "klibloader.moc" | 653 | //US #include "klibloader.moc" |
diff --git a/microkde/kdeui/ktoolbar.cpp b/microkde/kdeui/ktoolbar.cpp index 1ad1728..09ad0c8 100644 --- a/microkde/kdeui/ktoolbar.cpp +++ b/microkde/kdeui/ktoolbar.cpp | |||
@@ -1,2266 +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() const |
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() | 1413 | void KToolBar::repaintMe() |
1414 | { | 1414 | { |
1415 | setUpdatesEnabled( true ); | 1415 | setUpdatesEnabled( true ); |
1416 | QToolBar::repaint( true ); | 1416 | QToolBar::repaint( true ); |
1417 | //qDebug(" KToolBar::repaintMe() "); | 1417 | //qDebug(" KToolBar::repaintMe() "); |
1418 | } | 1418 | } |
1419 | 1419 | ||
1420 | void KToolBar::showEvent( QShowEvent *e ) | 1420 | void KToolBar::showEvent( QShowEvent *e ) |
1421 | { | 1421 | { |
1422 | QToolBar::showEvent( e ); | 1422 | QToolBar::showEvent( e ); |
1423 | rebuildLayout(); | 1423 | rebuildLayout(); |
1424 | } | 1424 | } |
1425 | 1425 | ||
1426 | void KToolBar::setStretchableWidget( QWidget *w ) | 1426 | void KToolBar::setStretchableWidget( QWidget *w ) |
1427 | { | 1427 | { |
1428 | QToolBar::setStretchableWidget( w ); | 1428 | QToolBar::setStretchableWidget( w ); |
1429 | stretchableWidget = w; | 1429 | stretchableWidget = w; |
1430 | } | 1430 | } |
1431 | 1431 | ||
1432 | QSizePolicy KToolBar::sizePolicy() const | 1432 | QSizePolicy KToolBar::sizePolicy() const |
1433 | { | 1433 | { |
1434 | if ( orientation() == Horizontal ) | 1434 | if ( orientation() == Horizontal ) |
1435 | return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); | 1435 | return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); |
1436 | else | 1436 | else |
1437 | return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ); | 1437 | return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ); |
1438 | } | 1438 | } |
1439 | 1439 | ||
1440 | QSize KToolBar::sizeHint() const | 1440 | QSize KToolBar::sizeHint() const |
1441 | { | 1441 | { |
1442 | return QToolBar::sizeHint(); | 1442 | return QToolBar::sizeHint(); |
1443 | #if 0 | 1443 | #if 0 |
1444 | QWidget::polish(); | 1444 | QWidget::polish(); |
1445 | static int iii = 0; | 1445 | static int iii = 0; |
1446 | ++iii; | 1446 | ++iii; |
1447 | qDebug("++++++++ KToolBar::sizeHint() %d ", iii ); | 1447 | qDebug("++++++++ KToolBar::sizeHint() %d ", iii ); |
1448 | int margin = static_cast<QWidget*>(ncThis)->layout()->margin(); | 1448 | int margin = static_cast<QWidget*>(ncThis)->layout()->margin(); |
1449 | switch( barPos() ) | 1449 | switch( barPos() ) |
1450 | { | 1450 | { |
1451 | case KToolBar::Top: | 1451 | case KToolBar::Top: |
1452 | case KToolBar::Bottom: | 1452 | case KToolBar::Bottom: |
1453 | for ( QWidget *w = widgets.first(); w; w =widgets.next() ) | 1453 | for ( QWidget *w = widgets.first(); w; w =widgets.next() ) |
1454 | { | 1454 | { |
1455 | if ( w->inherits( "KToolBarSeparator" ) && | 1455 | if ( w->inherits( "KToolBarSeparator" ) && |
1456 | !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) | 1456 | !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) |
1457 | { | 1457 | { |
1458 | minSize += QSize(6, 0); | 1458 | minSize += QSize(6, 0); |
1459 | } | 1459 | } |
1460 | else | 1460 | else |
1461 | { | 1461 | { |
1462 | QSize sh = w->sizeHint(); | 1462 | QSize sh = w->sizeHint(); |
1463 | if (!sh.isValid()) | 1463 | if (!sh.isValid()) |
1464 | sh = w->minimumSize(); | 1464 | sh = w->minimumSize(); |
1465 | minSize = minSize.expandedTo(QSize(0, sh.height())); | 1465 | minSize = minSize.expandedTo(QSize(0, sh.height())); |
1466 | minSize += QSize(sh.width()+1, 0); | 1466 | minSize += QSize(sh.width()+1, 0); |
1467 | } | 1467 | } |
1468 | } | 1468 | } |
1469 | /*US | 1469 | /*US |
1470 | minSize += QSize(QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ), 0); | 1470 | minSize += QSize(QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ), 0); |
1471 | */ | 1471 | */ |
1472 | minSize += QSize(margin*2, margin*2); | 1472 | minSize += QSize(margin*2, margin*2); |
1473 | break; | 1473 | break; |
1474 | 1474 | ||
1475 | case KToolBar::Left: | 1475 | case KToolBar::Left: |
1476 | case KToolBar::Right: | 1476 | case KToolBar::Right: |
1477 | for ( QWidget *w = widgets.first(); w; w = widgets.next() ) | 1477 | for ( QWidget *w = widgets.first(); w; w = widgets.next() ) |
1478 | { | 1478 | { |
1479 | if ( w->inherits( "KToolBarSeparator" ) && | 1479 | if ( w->inherits( "KToolBarSeparator" ) && |
1480 | !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) | 1480 | !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) |
1481 | { | 1481 | { |
1482 | minSize += QSize(0, 6); | 1482 | minSize += QSize(0, 6); |
1483 | } | 1483 | } |
1484 | else | 1484 | else |
1485 | { | 1485 | { |
1486 | QSize sh = w->sizeHint(); | 1486 | QSize sh = w->sizeHint(); |
1487 | if (!sh.isValid()) | 1487 | if (!sh.isValid()) |
1488 | sh = w->minimumSize(); | 1488 | sh = w->minimumSize(); |
1489 | minSize = minSize.expandedTo(QSize(sh.width(), 0)); | 1489 | minSize = minSize.expandedTo(QSize(sh.width(), 0)); |
1490 | minSize += QSize(0, sh.height()+1); | 1490 | minSize += QSize(0, sh.height()+1); |
1491 | } | 1491 | } |
1492 | } | 1492 | } |
1493 | /*US | 1493 | /*US |
1494 | minSize += QSize(0, QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent )); | 1494 | minSize += QSize(0, QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent )); |
1495 | */ | 1495 | */ |
1496 | minSize += QSize(margin*2, margin*2); | 1496 | minSize += QSize(margin*2, margin*2); |
1497 | break; | 1497 | break; |
1498 | 1498 | ||
1499 | default: | 1499 | default: |
1500 | minSize = QToolBar::sizeHint(); | 1500 | minSize = QToolBar::sizeHint(); |
1501 | break; | 1501 | break; |
1502 | } | 1502 | } |
1503 | return minSize; | 1503 | return minSize; |
1504 | #endif | 1504 | #endif |
1505 | } | 1505 | } |
1506 | 1506 | ||
1507 | QSize KToolBar::minimumSize() const | 1507 | QSize KToolBar::minimumSize() const |
1508 | { | 1508 | { |
1509 | return minimumSizeHint(); | 1509 | return minimumSizeHint(); |
1510 | } | 1510 | } |
1511 | 1511 | ||
1512 | QSize KToolBar::minimumSizeHint() const | 1512 | QSize KToolBar::minimumSizeHint() const |
1513 | { | 1513 | { |
1514 | return sizeHint(); | 1514 | return sizeHint(); |
1515 | } | 1515 | } |
1516 | 1516 | ||
1517 | bool KToolBar::highlight() const | 1517 | bool KToolBar::highlight() const |
1518 | { | 1518 | { |
1519 | return d->m_highlight; | 1519 | return d->m_highlight; |
1520 | } | 1520 | } |
1521 | 1521 | ||
1522 | void KToolBar::hide() | 1522 | void KToolBar::hide() |
1523 | { | 1523 | { |
1524 | QToolBar::hide(); | 1524 | QToolBar::hide(); |
1525 | } | 1525 | } |
1526 | 1526 | ||
1527 | void KToolBar::show() | 1527 | void KToolBar::show() |
1528 | { | 1528 | { |
1529 | QToolBar::show(); | 1529 | QToolBar::show(); |
1530 | } | 1530 | } |
1531 | 1531 | ||
1532 | void KToolBar::resizeEvent( QResizeEvent *e ) | 1532 | void KToolBar::resizeEvent( QResizeEvent *e ) |
1533 | { | 1533 | { |
1534 | bool b = isUpdatesEnabled(); | 1534 | bool b = isUpdatesEnabled(); |
1535 | setUpdatesEnabled( FALSE ); | 1535 | setUpdatesEnabled( FALSE ); |
1536 | QToolBar::resizeEvent( e ); | 1536 | QToolBar::resizeEvent( e ); |
1537 | if (b) | 1537 | if (b) |
1538 | d->repaintTimer.start( 100, true ); | 1538 | d->repaintTimer.start( 100, true ); |
1539 | } | 1539 | } |
1540 | 1540 | ||
1541 | void KToolBar::slotIconChanged(int group) | 1541 | void KToolBar::slotIconChanged(int group) |
1542 | { | 1542 | { |
1543 | if ((group != KIcon::Toolbar) && (group != KIcon::MainToolbar)) | 1543 | if ((group != KIcon::Toolbar) && (group != KIcon::MainToolbar)) |
1544 | return; | 1544 | return; |
1545 | if ((group == KIcon::MainToolbar) != !::qstrcmp(name(), "mainToolBar")) | 1545 | if ((group == KIcon::MainToolbar) != !::qstrcmp(name(), "mainToolBar")) |
1546 | return; | 1546 | return; |
1547 | 1547 | ||
1548 | emit modechange(); | 1548 | emit modechange(); |
1549 | if (isVisible()) | 1549 | if (isVisible()) |
1550 | updateGeometry(); | 1550 | updateGeometry(); |
1551 | } | 1551 | } |
1552 | 1552 | ||
1553 | void KToolBar::slotReadConfig() | 1553 | void KToolBar::slotReadConfig() |
1554 | { | 1554 | { |
1555 | //kdDebug(220) << "KToolBar::slotReadConfig" << endl; | 1555 | //kdDebug(220) << "KToolBar::slotReadConfig" << endl; |
1556 | // Read appearance settings (hmm, we used to do both here, | 1556 | // Read appearance settings (hmm, we used to do both here, |
1557 | // but a well behaved application will call applyMainWindowSettings | 1557 | // but a well behaved application will call applyMainWindowSettings |
1558 | // anyway, right ?) | 1558 | // anyway, right ?) |
1559 | applyAppearanceSettings(KGlobal::config(), QString::null ); | 1559 | applyAppearanceSettings(KGlobal::config(), QString::null ); |
1560 | } | 1560 | } |
1561 | 1561 | ||
1562 | void KToolBar::slotAppearanceChanged() | 1562 | void KToolBar::slotAppearanceChanged() |
1563 | { | 1563 | { |
1564 | // Read appearance settings from global file. | 1564 | // Read appearance settings from global file. |
1565 | applyAppearanceSettings(KGlobal::config(), QString::null, true /* lose local settings */ ); | 1565 | applyAppearanceSettings(KGlobal::config(), QString::null, true /* lose local settings */ ); |
1566 | // And remember to save the new look later | 1566 | // And remember to save the new look later |
1567 | /*US | 1567 | /*US |
1568 | if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) | 1568 | if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) |
1569 | static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); | 1569 | static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); |
1570 | */ | 1570 | */ |
1571 | } | 1571 | } |
1572 | 1572 | ||
1573 | //static | 1573 | //static |
1574 | bool KToolBar::highlightSetting() | 1574 | bool KToolBar::highlightSetting() |
1575 | { | 1575 | { |
1576 | QString grpToolbar(QString::fromLatin1("Toolbar style")); | 1576 | QString grpToolbar(QString::fromLatin1("Toolbar style")); |
1577 | KConfigGroupSaver saver(KGlobal::config(), grpToolbar); | 1577 | KConfigGroupSaver saver(KGlobal::config(), grpToolbar); |
1578 | return KGlobal::config()->readBoolEntry(QString::fromLatin1("Highlighting"),true); | 1578 | return KGlobal::config()->readBoolEntry(QString::fromLatin1("Highlighting"),true); |
1579 | } | 1579 | } |
1580 | 1580 | ||
1581 | //static | 1581 | //static |
1582 | bool KToolBar::transparentSetting() | 1582 | bool KToolBar::transparentSetting() |
1583 | { | 1583 | { |
1584 | QString grpToolbar(QString::fromLatin1("Toolbar style")); | 1584 | QString grpToolbar(QString::fromLatin1("Toolbar style")); |
1585 | KConfigGroupSaver saver(KGlobal::config(), grpToolbar); | 1585 | KConfigGroupSaver saver(KGlobal::config(), grpToolbar); |
1586 | return KGlobal::config()->readBoolEntry(QString::fromLatin1("TransparentMoving"),true); | 1586 | return KGlobal::config()->readBoolEntry(QString::fromLatin1("TransparentMoving"),true); |
1587 | } | 1587 | } |
1588 | 1588 | ||
1589 | //static | 1589 | //static |
1590 | KToolBar::IconText KToolBar::iconTextSetting() | 1590 | KToolBar::IconText KToolBar::iconTextSetting() |
1591 | { | 1591 | { |
1592 | QString grpToolbar(QString::fromLatin1("Toolbar style")); | 1592 | QString grpToolbar(QString::fromLatin1("Toolbar style")); |
1593 | KConfigGroupSaver saver(KGlobal::config(), grpToolbar); | 1593 | KConfigGroupSaver saver(KGlobal::config(), grpToolbar); |
1594 | QString icontext = KGlobal::config()->readEntry(QString::fromLatin1("IconText"),QString::fromLatin1("IconOnly")); | 1594 | QString icontext = KGlobal::config()->readEntry(QString::fromLatin1("IconText"),QString::fromLatin1("IconOnly")); |
1595 | if ( icontext == "IconTextRight" ) | 1595 | if ( icontext == "IconTextRight" ) |
1596 | return IconTextRight; | 1596 | return IconTextRight; |
1597 | else if ( icontext == "IconTextBottom" ) | 1597 | else if ( icontext == "IconTextBottom" ) |
1598 | return IconTextBottom; | 1598 | return IconTextBottom; |
1599 | else if ( icontext == "TextOnly" ) | 1599 | else if ( icontext == "TextOnly" ) |
1600 | return TextOnly; | 1600 | return TextOnly; |
1601 | else | 1601 | else |
1602 | return IconOnly; | 1602 | return IconOnly; |
1603 | } | 1603 | } |
1604 | 1604 | ||
1605 | void KToolBar::applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal) | 1605 | void KToolBar::applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal) |
1606 | { | 1606 | { |
1607 | QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup; | 1607 | QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup; |
1608 | //kdDebug(220) << "KToolBar::applyAppearanceSettings: configGroup=" << configGroup << endl; | 1608 | //kdDebug(220) << "KToolBar::applyAppearanceSettings: configGroup=" << configGroup << endl; |
1609 | // We have application-specific settings in the XML file, | 1609 | // We have application-specific settings in the XML file, |
1610 | // and nothing in the application's config file | 1610 | // and nothing in the application's config file |
1611 | // -> don't apply the global defaults, the XML ones are preferred | 1611 | // -> don't apply the global defaults, the XML ones are preferred |
1612 | // See applySettings for a full explanation | 1612 | // See applySettings for a full explanation |
1613 | /*US :we do not support xml files | 1613 | /*US :we do not support xml files |
1614 | if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() && | 1614 | if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() && |
1615 | !config->hasGroup(configGroup) ) | 1615 | !config->hasGroup(configGroup) ) |
1616 | { | 1616 | { |
1617 | //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl; | 1617 | //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl; |
1618 | return; | 1618 | return; |
1619 | } | 1619 | } |
1620 | */ | 1620 | */ |
1621 | if ( !config->hasGroup(configGroup) ) | 1621 | if ( !config->hasGroup(configGroup) ) |
1622 | { | 1622 | { |
1623 | //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl; | 1623 | //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl; |
1624 | return; | 1624 | return; |
1625 | } | 1625 | } |
1626 | 1626 | ||
1627 | 1627 | ||
1628 | KConfig *gconfig = KGlobal::config(); | 1628 | KConfig *gconfig = KGlobal::config(); |
1629 | /*US | 1629 | /*US |
1630 | static const QString &attrIconText = KGlobal::staticQString("IconText"); | 1630 | static const QString &attrIconText = KGlobal::staticQString("IconText"); |
1631 | static const QString &attrHighlight = KGlobal::staticQString("Highlighting"); | 1631 | static const QString &attrHighlight = KGlobal::staticQString("Highlighting"); |
1632 | static const QString &attrTrans = KGlobal::staticQString("TransparentMoving"); | 1632 | static const QString &attrTrans = KGlobal::staticQString("TransparentMoving"); |
1633 | static const QString &attrSize = KGlobal::staticQString("IconSize"); | 1633 | static const QString &attrSize = KGlobal::staticQString("IconSize"); |
1634 | */ | 1634 | */ |
1635 | // we actually do this in two steps. | 1635 | // we actually do this in two steps. |
1636 | // 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). |
1637 | // 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] |
1638 | bool highlight; | 1638 | bool highlight; |
1639 | int transparent; | 1639 | int transparent; |
1640 | QString icontext; | 1640 | QString icontext; |
1641 | int iconsize = 0; | 1641 | int iconsize = 0; |
1642 | 1642 | ||
1643 | // this is the first iteration | 1643 | // this is the first iteration |
1644 | QString grpToolbar(QString::fromLatin1("Toolbar style")); | 1644 | QString grpToolbar(QString::fromLatin1("Toolbar style")); |
1645 | { // start block for KConfigGroupSaver | 1645 | { // start block for KConfigGroupSaver |
1646 | KConfigGroupSaver saver(gconfig, grpToolbar); | 1646 | KConfigGroupSaver saver(gconfig, grpToolbar); |
1647 | 1647 | ||
1648 | // first, get the generic settings | 1648 | // first, get the generic settings |
1649 | //US highlight = gconfig->readBoolEntry(attrHighlight, true); | 1649 | //US highlight = gconfig->readBoolEntry(attrHighlight, true); |
1650 | highlight = gconfig->readBoolEntry("Highlighting", true); | 1650 | highlight = gconfig->readBoolEntry("Highlighting", true); |
1651 | //US transparent = gconfig->readBoolEntry(attrTrans, true); | 1651 | //US transparent = gconfig->readBoolEntry(attrTrans, true); |
1652 | transparent = gconfig->readBoolEntry("TransparentMoving", true); | 1652 | transparent = gconfig->readBoolEntry("TransparentMoving", true); |
1653 | 1653 | ||
1654 | // 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 |
1655 | // honoring it | 1655 | // honoring it |
1656 | if (d->m_honorStyle) | 1656 | if (d->m_honorStyle) |
1657 | //US d->IconTextDefault = gconfig->readEntry(attrIconText, d->IconTextDefault); | 1657 | //US d->IconTextDefault = gconfig->readEntry(attrIconText, d->IconTextDefault); |
1658 | d->IconTextDefault = gconfig->readEntry("IconText", d->IconTextDefault); | 1658 | d->IconTextDefault = gconfig->readEntry("IconText", d->IconTextDefault); |
1659 | else | 1659 | else |
1660 | d->IconTextDefault = "IconOnly"; | 1660 | d->IconTextDefault = "IconOnly"; |
1661 | 1661 | ||
1662 | // Use the default icon size for toolbar icons. | 1662 | // Use the default icon size for toolbar icons. |
1663 | //US d->IconSizeDefault = gconfig->readNumEntry(attrSize, d->IconSizeDefault); | 1663 | //US d->IconSizeDefault = gconfig->readNumEntry(attrSize, d->IconSizeDefault); |
1664 | d->IconSizeDefault = gconfig->readNumEntry("IconSize", d->IconSizeDefault); | 1664 | d->IconSizeDefault = gconfig->readNumEntry("IconSize", d->IconSizeDefault); |
1665 | 1665 | ||
1666 | if ( !forceGlobal && config->hasGroup(configGroup) ) | 1666 | if ( !forceGlobal && config->hasGroup(configGroup) ) |
1667 | { | 1667 | { |
1668 | config->setGroup(configGroup); | 1668 | config->setGroup(configGroup); |
1669 | 1669 | ||
1670 | // first, get the generic settings | 1670 | // first, get the generic settings |
1671 | //US highlight = config->readBoolEntry(attrHighlight, highlight); | 1671 | //US highlight = config->readBoolEntry(attrHighlight, highlight); |
1672 | highlight = config->readBoolEntry("Highlighting", highlight); | 1672 | highlight = config->readBoolEntry("Highlighting", highlight); |
1673 | //US transparent = config->readBoolEntry(attrTrans, transparent); | 1673 | //US transparent = config->readBoolEntry(attrTrans, transparent); |
1674 | transparent = config->readBoolEntry("TransparentMoving", transparent); | 1674 | transparent = config->readBoolEntry("TransparentMoving", transparent); |
1675 | // now we always read in the IconText property | 1675 | // now we always read in the IconText property |
1676 | //US icontext = config->readEntry(attrIconText, d->IconTextDefault); | 1676 | //US icontext = config->readEntry(attrIconText, d->IconTextDefault); |
1677 | icontext = config->readEntry("IconText", d->IconTextDefault); | 1677 | icontext = config->readEntry("IconText", d->IconTextDefault); |
1678 | 1678 | ||
1679 | // now get the size | 1679 | // now get the size |
1680 | //US iconsize = config->readNumEntry(attrSize, d->IconSizeDefault); | 1680 | //US iconsize = config->readNumEntry(attrSize, d->IconSizeDefault); |
1681 | iconsize = config->readNumEntry("IconSize", d->IconSizeDefault); | 1681 | iconsize = config->readNumEntry("IconSize", d->IconSizeDefault); |
1682 | } | 1682 | } |
1683 | else | 1683 | else |
1684 | { | 1684 | { |
1685 | iconsize = d->IconSizeDefault; | 1685 | iconsize = d->IconSizeDefault; |
1686 | icontext = d->IconTextDefault; | 1686 | icontext = d->IconTextDefault; |
1687 | } | 1687 | } |
1688 | 1688 | ||
1689 | // revert back to the old group | 1689 | // revert back to the old group |
1690 | } // end block for KConfigGroupSaver | 1690 | } // end block for KConfigGroupSaver |
1691 | 1691 | ||
1692 | bool doUpdate = false; | 1692 | bool doUpdate = false; |
1693 | 1693 | ||
1694 | IconText icon_text; | 1694 | IconText icon_text; |
1695 | if ( icontext == "IconTextRight" ) | 1695 | if ( icontext == "IconTextRight" ) |
1696 | icon_text = IconTextRight; | 1696 | icon_text = IconTextRight; |
1697 | else if ( icontext == "IconTextBottom" ) | 1697 | else if ( icontext == "IconTextBottom" ) |
1698 | icon_text = IconTextBottom; | 1698 | icon_text = IconTextBottom; |
1699 | else if ( icontext == "TextOnly" ) | 1699 | else if ( icontext == "TextOnly" ) |
1700 | icon_text = TextOnly; | 1700 | icon_text = TextOnly; |
1701 | else | 1701 | else |
1702 | icon_text = IconOnly; | 1702 | icon_text = IconOnly; |
1703 | 1703 | ||
1704 | // check if the icon/text has changed | 1704 | // check if the icon/text has changed |
1705 | if (icon_text != d->m_iconText) { | 1705 | if (icon_text != d->m_iconText) { |
1706 | //kdDebug(220) << "KToolBar::applyAppearanceSettings setIconText " << icon_text << endl; | 1706 | //kdDebug(220) << "KToolBar::applyAppearanceSettings setIconText " << icon_text << endl; |
1707 | setIconText(icon_text, false); | 1707 | setIconText(icon_text, false); |
1708 | doUpdate = true; | 1708 | doUpdate = true; |
1709 | } | 1709 | } |
1710 | 1710 | ||
1711 | // ...and check if the icon size has changed | 1711 | // ...and check if the icon size has changed |
1712 | if (iconsize != d->m_iconSize) { | 1712 | if (iconsize != d->m_iconSize) { |
1713 | setIconSize(iconsize, false); | 1713 | setIconSize(iconsize, false); |
1714 | doUpdate = true; | 1714 | doUpdate = true; |
1715 | } | 1715 | } |
1716 | 1716 | ||
1717 | QMainWindow *mw = mainWindow(); | 1717 | QMainWindow *mw = mainWindow(); |
1718 | 1718 | ||
1719 | // ...and if we should highlight | 1719 | // ...and if we should highlight |
1720 | if ( highlight != d->m_highlight ) { | 1720 | if ( highlight != d->m_highlight ) { |
1721 | d->m_highlight = highlight; | 1721 | d->m_highlight = highlight; |
1722 | doUpdate = true; | 1722 | doUpdate = true; |
1723 | } | 1723 | } |
1724 | 1724 | ||
1725 | // ...and if we should move transparently | 1725 | // ...and if we should move transparently |
1726 | if ( mw && transparent != (!mw->opaqueMoving()) ) { | 1726 | if ( mw && transparent != (!mw->opaqueMoving()) ) { |
1727 | mw->setOpaqueMoving( !transparent ); | 1727 | mw->setOpaqueMoving( !transparent ); |
1728 | } | 1728 | } |
1729 | 1729 | ||
1730 | if (doUpdate) | 1730 | if (doUpdate) |
1731 | emit modechange(); // tell buttons what happened | 1731 | emit modechange(); // tell buttons what happened |
1732 | if (isVisible ()) | 1732 | if (isVisible ()) |
1733 | updateGeometry(); | 1733 | updateGeometry(); |
1734 | } | 1734 | } |
1735 | 1735 | ||
1736 | void KToolBar::applySettings(KConfig *config, const QString &_configGroup) | 1736 | void KToolBar::applySettings(KConfig *config, const QString &_configGroup) |
1737 | { | 1737 | { |
1738 | //kdDebug(220) << "KToolBar::applySettings group=" << _configGroup << endl; | 1738 | //kdDebug(220) << "KToolBar::applySettings group=" << _configGroup << endl; |
1739 | 1739 | ||
1740 | QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup; | 1740 | QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup; |
1741 | 1741 | ||
1742 | /* | 1742 | /* |
1743 | Let's explain this a bit more in details. | 1743 | Let's explain this a bit more in details. |
1744 | The order in which we apply settings is : | 1744 | The order in which we apply settings is : |
1745 | Global config / <appnamerc> user settings if no XMLGUI is used | 1745 | Global config / <appnamerc> user settings if no XMLGUI is used |
1746 | 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 |
1747 | 1747 | ||
1748 | 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, |
1749 | 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, |
1750 | 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. |
1751 | 1751 | ||
1752 | 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). |
1753 | */ | 1753 | */ |
1754 | 1754 | ||
1755 | // First the appearance stuff - the one which has a global config | 1755 | // First the appearance stuff - the one which has a global config |
1756 | applyAppearanceSettings( config, _configGroup ); | 1756 | applyAppearanceSettings( config, _configGroup ); |
1757 | 1757 | ||
1758 | // ...and now the position stuff | 1758 | // ...and now the position stuff |
1759 | if ( config->hasGroup(configGroup) ) | 1759 | if ( config->hasGroup(configGroup) ) |
1760 | { | 1760 | { |
1761 | KConfigGroupSaver cgs(config, configGroup); | 1761 | KConfigGroupSaver cgs(config, configGroup); |
1762 | /*US | 1762 | /*US |
1763 | static const QString &attrPosition = KGlobal::staticQString("Position"); | 1763 | static const QString &attrPosition = KGlobal::staticQString("Position"); |
1764 | static const QString &attrIndex = KGlobal::staticQString("Index"); | 1764 | static const QString &attrIndex = KGlobal::staticQString("Index"); |
1765 | static const QString &attrOffset = KGlobal::staticQString("Offset"); | 1765 | static const QString &attrOffset = KGlobal::staticQString("Offset"); |
1766 | static const QString &attrNewLine = KGlobal::staticQString("NewLine"); | 1766 | static const QString &attrNewLine = KGlobal::staticQString("NewLine"); |
1767 | static const QString &attrHidden = KGlobal::staticQString("Hidden"); | 1767 | static const QString &attrHidden = KGlobal::staticQString("Hidden"); |
1768 | 1768 | ||
1769 | QString position = config->readEntry(attrPosition, d->PositionDefault); | 1769 | QString position = config->readEntry(attrPosition, d->PositionDefault); |
1770 | int index = config->readNumEntry(attrIndex, d->IndexDefault); | 1770 | int index = config->readNumEntry(attrIndex, d->IndexDefault); |
1771 | int offset = config->readNumEntry(attrOffset, d->OffsetDefault); | 1771 | int offset = config->readNumEntry(attrOffset, d->OffsetDefault); |
1772 | bool newLine = config->readBoolEntry(attrNewLine, d->NewLineDefault); | 1772 | bool newLine = config->readBoolEntry(attrNewLine, d->NewLineDefault); |
1773 | bool hidden = config->readBoolEntry(attrHidden, d->HiddenDefault); | 1773 | bool hidden = config->readBoolEntry(attrHidden, d->HiddenDefault); |
1774 | */ | 1774 | */ |
1775 | 1775 | ||
1776 | QString position = config->readEntry("Position", d->PositionDefault); | 1776 | QString position = config->readEntry("Position", d->PositionDefault); |
1777 | int index = config->readNumEntry("Index", d->IndexDefault); | 1777 | int index = config->readNumEntry("Index", d->IndexDefault); |
1778 | int offset = config->readNumEntry("Offset", d->OffsetDefault); | 1778 | int offset = config->readNumEntry("Offset", d->OffsetDefault); |
1779 | bool newLine = config->readBoolEntry("NewLine", d->NewLineDefault); | 1779 | bool newLine = config->readBoolEntry("NewLine", d->NewLineDefault); |
1780 | bool hidden = config->readBoolEntry("Hidden", d->HiddenDefault); | 1780 | bool hidden = config->readBoolEntry("Hidden", d->HiddenDefault); |
1781 | 1781 | ||
1782 | /*US Dock pos(DockTop); | 1782 | /*US Dock pos(DockTop); |
1783 | if ( position == "Top" ) | 1783 | if ( position == "Top" ) |
1784 | pos = DockTop; | 1784 | pos = DockTop; |
1785 | else if ( position == "Bottom" ) | 1785 | else if ( position == "Bottom" ) |
1786 | pos = DockBottom; | 1786 | pos = DockBottom; |
1787 | else if ( position == "Left" ) | 1787 | else if ( position == "Left" ) |
1788 | pos = DockLeft; | 1788 | pos = DockLeft; |
1789 | else if ( position == "Right" ) | 1789 | else if ( position == "Right" ) |
1790 | pos = DockRight; | 1790 | pos = DockRight; |
1791 | else if ( position == "Floating" ) | 1791 | else if ( position == "Floating" ) |
1792 | pos = DockTornOff; | 1792 | pos = DockTornOff; |
1793 | else if ( position == "Flat" ) | 1793 | else if ( position == "Flat" ) |
1794 | pos = DockMinimized; | 1794 | pos = DockMinimized; |
1795 | */ | 1795 | */ |
1796 | QMainWindow::ToolBarDock pos(QMainWindow::Top); | 1796 | QMainWindow::ToolBarDock pos(QMainWindow::Top); |
1797 | if ( position == "Top" ) | 1797 | if ( position == "Top" ) |
1798 | pos = QMainWindow::Top; | 1798 | pos = QMainWindow::Top; |
1799 | else if ( position == "Bottom" ) | 1799 | else if ( position == "Bottom" ) |
1800 | pos = QMainWindow::Bottom; | 1800 | pos = QMainWindow::Bottom; |
1801 | else if ( position == "Left" ) | 1801 | else if ( position == "Left" ) |
1802 | pos = QMainWindow::Left; | 1802 | pos = QMainWindow::Left; |
1803 | else if ( position == "Right" ) | 1803 | else if ( position == "Right" ) |
1804 | pos = QMainWindow::Right; | 1804 | pos = QMainWindow::Right; |
1805 | else if ( position == "Floating" ) | 1805 | else if ( position == "Floating" ) |
1806 | pos = QMainWindow::TornOff; | 1806 | pos = QMainWindow::TornOff; |
1807 | else if ( position == "Flat" ) | 1807 | else if ( position == "Flat" ) |
1808 | pos = QMainWindow::Minimized; | 1808 | pos = QMainWindow::Minimized; |
1809 | 1809 | ||
1810 | //kdDebug(220) << "KToolBar::applySettings hidden=" << hidden << endl; | 1810 | //kdDebug(220) << "KToolBar::applySettings hidden=" << hidden << endl; |
1811 | if (hidden) | 1811 | if (hidden) |
1812 | hide(); | 1812 | hide(); |
1813 | else | 1813 | else |
1814 | show(); | 1814 | show(); |
1815 | 1815 | ||
1816 | if ( mainWindow() ) | 1816 | if ( mainWindow() ) |
1817 | { | 1817 | { |
1818 | QMainWindow *mw = mainWindow(); | 1818 | QMainWindow *mw = mainWindow(); |
1819 | 1819 | ||
1820 | //kdDebug(220) << "KToolBar::applySettings updating ToolbarInfo" << endl; | 1820 | //kdDebug(220) << "KToolBar::applySettings updating ToolbarInfo" << endl; |
1821 | d->toolBarInfo = KToolBarPrivate::ToolBarInfo( pos, index, newLine, offset ); | 1821 | d->toolBarInfo = KToolBarPrivate::ToolBarInfo( pos, index, newLine, offset ); |
1822 | 1822 | ||
1823 | // moveDockWindow calls QDockArea which does a reparent() on us with | 1823 | // moveDockWindow calls QDockArea which does a reparent() on us with |
1824 | // showIt = true, so we loose our visibility status | 1824 | // showIt = true, so we loose our visibility status |
1825 | bool doHide = isHidden(); | 1825 | bool doHide = isHidden(); |
1826 | 1826 | ||
1827 | //US mw->moveDockWindow( this, pos, newLine, index, offset ); | 1827 | //US mw->moveDockWindow( this, pos, newLine, index, offset ); |
1828 | mw->moveToolBar( this, pos, newLine, index, offset ); | 1828 | mw->moveToolBar( this, pos, newLine, index, offset ); |
1829 | 1829 | ||
1830 | //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; |
1831 | if ( doHide ) | 1831 | if ( doHide ) |
1832 | hide(); | 1832 | hide(); |
1833 | } | 1833 | } |
1834 | if (isVisible ()) | 1834 | if (isVisible ()) |
1835 | updateGeometry(); | 1835 | updateGeometry(); |
1836 | } | 1836 | } |
1837 | } | 1837 | } |
1838 | 1838 | ||
1839 | bool KToolBar::event( QEvent *e ) | 1839 | bool KToolBar::event( QEvent *e ) |
1840 | { | 1840 | { |
1841 | if ( (e->type() == QEvent::LayoutHint) && isUpdatesEnabled() ) | 1841 | if ( (e->type() == QEvent::LayoutHint) && isUpdatesEnabled() ) |
1842 | d->repaintTimer.start( 100, true ); | 1842 | d->repaintTimer.start( 100, true ); |
1843 | 1843 | ||
1844 | if (e->type() == QEvent::ChildInserted ) | 1844 | if (e->type() == QEvent::ChildInserted ) |
1845 | { | 1845 | { |
1846 | // By pass QToolBar::event, | 1846 | // By pass QToolBar::event, |
1847 | // 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 |
1848 | // do that until we have rebuild the layout. | 1848 | // do that until we have rebuild the layout. |
1849 | childEvent((QChildEvent *)e); | 1849 | childEvent((QChildEvent *)e); |
1850 | return true; | 1850 | return true; |
1851 | } | 1851 | } |
1852 | 1852 | ||
1853 | return QToolBar::event( e ); | 1853 | return QToolBar::event( e ); |
1854 | } | 1854 | } |
1855 | 1855 | ||
1856 | void KToolBar::slotRepaint() | 1856 | void KToolBar::slotRepaint() |
1857 | { | 1857 | { |
1858 | setUpdatesEnabled( FALSE ); | 1858 | setUpdatesEnabled( FALSE ); |
1859 | // Send a resizeEvent to update the "toolbar extension arrow" | 1859 | // Send a resizeEvent to update the "toolbar extension arrow" |
1860 | // (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 |
1861 | // the available space) | 1861 | // the available space) |
1862 | QResizeEvent ev(size(), size()); | 1862 | QResizeEvent ev(size(), size()); |
1863 | resizeEvent(&ev); | 1863 | resizeEvent(&ev); |
1864 | //#ifdef DESKTOP_VERSION | 1864 | //#ifdef DESKTOP_VERSION |
1865 | QApplication::sendPostedEvents( this, QEvent::LayoutHint ); | 1865 | QApplication::sendPostedEvents( this, QEvent::LayoutHint ); |
1866 | //#endif //DESKTOP_VERSION | 1866 | //#endif //DESKTOP_VERSION |
1867 | setUpdatesEnabled( TRUE ); | 1867 | setUpdatesEnabled( TRUE ); |
1868 | repaint( TRUE ); | 1868 | repaint( TRUE ); |
1869 | } | 1869 | } |
1870 | 1870 | ||
1871 | void KToolBar::toolBarPosChanged( QToolBar *tb ) | 1871 | void KToolBar::toolBarPosChanged( QToolBar *tb ) |
1872 | { | 1872 | { |
1873 | if ( tb != this ) | 1873 | if ( tb != this ) |
1874 | return; | 1874 | return; |
1875 | //US if ( d->oldPos == DockMinimized ) | 1875 | //US if ( d->oldPos == DockMinimized ) |
1876 | if ( d->oldPos == QMainWindow::Minimized ) | 1876 | if ( d->oldPos == QMainWindow::Minimized ) |
1877 | rebuildLayout(); | 1877 | rebuildLayout(); |
1878 | d->oldPos = (QMainWindow::ToolBarDock)barPos(); | 1878 | d->oldPos = (QMainWindow::ToolBarDock)barPos(); |
1879 | /*US | 1879 | /*US |
1880 | if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) | 1880 | if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) |
1881 | static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); | 1881 | static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); |
1882 | */ | 1882 | */ |
1883 | } | 1883 | } |
1884 | 1884 | ||
1885 | /*US | 1885 | /*US |
1886 | void KToolBar::loadState( const QDomElement &element ) | 1886 | void KToolBar::loadState( const QDomElement &element ) |
1887 | { | 1887 | { |
1888 | //kdDebug(220) << "KToolBar::loadState " << this << endl; | 1888 | //kdDebug(220) << "KToolBar::loadState " << this << endl; |
1889 | if ( !mainWindow() ) | 1889 | if ( !mainWindow() ) |
1890 | return; | 1890 | return; |
1891 | 1891 | ||
1892 | { | 1892 | { |
1893 | QCString text = element.namedItem( "text" ).toElement().text().utf8(); | 1893 | QCString text = element.namedItem( "text" ).toElement().text().utf8(); |
1894 | if ( text.isEmpty() ) | 1894 | if ( text.isEmpty() ) |
1895 | text = element.namedItem( "Text" ).toElement().text().utf8(); | 1895 | text = element.namedItem( "Text" ).toElement().text().utf8(); |
1896 | if ( !text.isEmpty() ) | 1896 | if ( !text.isEmpty() ) |
1897 | setText( i18n( text ) ); | 1897 | setText( i18n( text ) ); |
1898 | } | 1898 | } |
1899 | 1899 | ||
1900 | { | 1900 | { |
1901 | QCString attrFullWidth = element.attribute( "fullWidth" ).lower().latin1(); | 1901 | QCString attrFullWidth = element.attribute( "fullWidth" ).lower().latin1(); |
1902 | if ( !attrFullWidth.isEmpty() ) | 1902 | if ( !attrFullWidth.isEmpty() ) |
1903 | setFullSize( attrFullWidth == "true" ); | 1903 | setFullSize( attrFullWidth == "true" ); |
1904 | } | 1904 | } |
1905 | 1905 | ||
1906 | Dock dock = DockTop; | 1906 | Dock dock = DockTop; |
1907 | { | 1907 | { |
1908 | QCString attrPosition = element.attribute( "position" ).lower().latin1(); | 1908 | QCString attrPosition = element.attribute( "position" ).lower().latin1(); |
1909 | //kdDebug(220) << "KToolBar::loadState attrPosition=" << attrPosition << endl; | 1909 | //kdDebug(220) << "KToolBar::loadState attrPosition=" << attrPosition << endl; |
1910 | if ( !attrPosition.isEmpty() ) { | 1910 | if ( !attrPosition.isEmpty() ) { |
1911 | if ( attrPosition == "top" ) | 1911 | if ( attrPosition == "top" ) |
1912 | dock = DockTop; | 1912 | dock = DockTop; |
1913 | else if ( attrPosition == "left" ) | 1913 | else if ( attrPosition == "left" ) |
1914 | dock = DockLeft; | 1914 | dock = DockLeft; |
1915 | else if ( attrPosition == "right" ) | 1915 | else if ( attrPosition == "right" ) |
1916 | dock = DockRight; | 1916 | dock = DockRight; |
1917 | else if ( attrPosition == "bottom" ) | 1917 | else if ( attrPosition == "bottom" ) |
1918 | dock = DockBottom; | 1918 | dock = DockBottom; |
1919 | else if ( attrPosition == "floating" ) | 1919 | else if ( attrPosition == "floating" ) |
1920 | dock = DockTornOff; | 1920 | dock = DockTornOff; |
1921 | else if ( attrPosition == "flat" ) | 1921 | else if ( attrPosition == "flat" ) |
1922 | dock = DockMinimized; | 1922 | dock = DockMinimized; |
1923 | } | 1923 | } |
1924 | } | 1924 | } |
1925 | 1925 | ||
1926 | { | 1926 | { |
1927 | QCString attrIconText = element.attribute( "iconText" ).lower().latin1(); | 1927 | QCString attrIconText = element.attribute( "iconText" ).lower().latin1(); |
1928 | if ( !attrIconText.isEmpty() ) { | 1928 | if ( !attrIconText.isEmpty() ) { |
1929 | //kdDebug(220) << "KToolBar::loadState attrIconText=" << attrIconText << endl; | 1929 | //kdDebug(220) << "KToolBar::loadState attrIconText=" << attrIconText << endl; |
1930 | if ( attrIconText == "icontextright" ) | 1930 | if ( attrIconText == "icontextright" ) |
1931 | setIconText( KToolBar::IconTextRight ); | 1931 | setIconText( KToolBar::IconTextRight ); |
1932 | else if ( attrIconText == "textonly" ) | 1932 | else if ( attrIconText == "textonly" ) |
1933 | setIconText( KToolBar::TextOnly ); | 1933 | setIconText( KToolBar::TextOnly ); |
1934 | else if ( attrIconText == "icontextbottom" ) | 1934 | else if ( attrIconText == "icontextbottom" ) |
1935 | setIconText( KToolBar::IconTextBottom ); | 1935 | setIconText( KToolBar::IconTextBottom ); |
1936 | else if ( attrIconText == "icononly" ) | 1936 | else if ( attrIconText == "icononly" ) |
1937 | setIconText( KToolBar::IconOnly ); | 1937 | setIconText( KToolBar::IconOnly ); |
1938 | } else | 1938 | } else |
1939 | // Use global setting | 1939 | // Use global setting |
1940 | setIconText( iconTextSetting() ); | 1940 | setIconText( iconTextSetting() ); |
1941 | } | 1941 | } |
1942 | 1942 | ||
1943 | { | 1943 | { |
1944 | QString attrIconSize = element.attribute( "iconSize" ).lower(); | 1944 | QString attrIconSize = element.attribute( "iconSize" ).lower(); |
1945 | if ( !attrIconSize.isEmpty() ) | 1945 | if ( !attrIconSize.isEmpty() ) |
1946 | d->IconSizeDefault = attrIconSize.toInt(); | 1946 | d->IconSizeDefault = attrIconSize.toInt(); |
1947 | setIconSize( d->IconSizeDefault ); | 1947 | setIconSize( d->IconSizeDefault ); |
1948 | } | 1948 | } |
1949 | 1949 | ||
1950 | { | 1950 | { |
1951 | QString attrIndex = element.attribute( "index" ).lower(); | 1951 | QString attrIndex = element.attribute( "index" ).lower(); |
1952 | if ( !attrIndex.isEmpty() ) | 1952 | if ( !attrIndex.isEmpty() ) |
1953 | d->IndexDefault = attrIndex.toInt(); | 1953 | d->IndexDefault = attrIndex.toInt(); |
1954 | } | 1954 | } |
1955 | 1955 | ||
1956 | { | 1956 | { |
1957 | QString attrOffset = element.attribute( "offset" ).lower(); | 1957 | QString attrOffset = element.attribute( "offset" ).lower(); |
1958 | if ( !attrOffset.isEmpty() ) | 1958 | if ( !attrOffset.isEmpty() ) |
1959 | d->OffsetDefault = attrOffset.toInt(); | 1959 | d->OffsetDefault = attrOffset.toInt(); |
1960 | } | 1960 | } |
1961 | 1961 | ||
1962 | { | 1962 | { |
1963 | QString attrNewLine = element.attribute( "newline" ).lower(); | 1963 | QString attrNewLine = element.attribute( "newline" ).lower(); |
1964 | if ( !attrNewLine.isEmpty() ) | 1964 | if ( !attrNewLine.isEmpty() ) |
1965 | d->NewLineDefault = attrNewLine == "true"; | 1965 | d->NewLineDefault = attrNewLine == "true"; |
1966 | } | 1966 | } |
1967 | 1967 | ||
1968 | { | 1968 | { |
1969 | QString attrHidden = element.attribute( "hidden" ).lower(); | 1969 | QString attrHidden = element.attribute( "hidden" ).lower(); |
1970 | if ( !attrHidden.isEmpty() ) | 1970 | if ( !attrHidden.isEmpty() ) |
1971 | d->HiddenDefault = attrHidden == "true"; | 1971 | d->HiddenDefault = attrHidden == "true"; |
1972 | } | 1972 | } |
1973 | 1973 | ||
1974 | d->toolBarInfo = KToolBarPrivate::ToolBarInfo( dock, d->IndexDefault, d->NewLineDefault, d->OffsetDefault ); | 1974 | d->toolBarInfo = KToolBarPrivate::ToolBarInfo( dock, d->IndexDefault, d->NewLineDefault, d->OffsetDefault ); |
1975 | mainWindow()->addDockWindow( this, dock, d->NewLineDefault ); | 1975 | mainWindow()->addDockWindow( this, dock, d->NewLineDefault ); |
1976 | //US mainWindow()->moveDockWindow( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); | 1976 | //US mainWindow()->moveDockWindow( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); |
1977 | mainWindow()->moveToolBar( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); | 1977 | mainWindow()->moveToolBar( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); |
1978 | 1978 | ||
1979 | // Apply the highlight button setting | 1979 | // Apply the highlight button setting |
1980 | d->m_highlight = highlightSetting(); | 1980 | d->m_highlight = highlightSetting(); |
1981 | 1981 | ||
1982 | // 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, |
1983 | // but we do it only if there are toolbars...) | 1983 | // but we do it only if there are toolbars...) |
1984 | if ( transparentSetting() != !mainWindow()->opaqueMoving() ) | 1984 | if ( transparentSetting() != !mainWindow()->opaqueMoving() ) |
1985 | mainWindow()->setOpaqueMoving( !transparentSetting() ); | 1985 | mainWindow()->setOpaqueMoving( !transparentSetting() ); |
1986 | 1986 | ||
1987 | if ( d->HiddenDefault ) | 1987 | if ( d->HiddenDefault ) |
1988 | hide(); | 1988 | hide(); |
1989 | else | 1989 | else |
1990 | show(); | 1990 | show(); |
1991 | 1991 | ||
1992 | getAttributes( d->PositionDefault, d->IconTextDefault, d->IndexDefault ); | 1992 | getAttributes( d->PositionDefault, d->IconTextDefault, d->IndexDefault ); |
1993 | } | 1993 | } |
1994 | */ | 1994 | */ |
1995 | 1995 | ||
1996 | void KToolBar::getAttributes( QString &position, QString &icontext, int &index ) | 1996 | void KToolBar::getAttributes( QString &position, QString &icontext, int &index ) |
1997 | { | 1997 | { |
1998 | // get all of the stuff to save | 1998 | // get all of the stuff to save |
1999 | switch ( barPos() ) { | 1999 | switch ( barPos() ) { |
2000 | case KToolBar::Flat: | 2000 | case KToolBar::Flat: |
2001 | position = "Flat"; | 2001 | position = "Flat"; |
2002 | break; | 2002 | break; |
2003 | case KToolBar::Bottom: | 2003 | case KToolBar::Bottom: |
2004 | position = "Bottom"; | 2004 | position = "Bottom"; |
2005 | break; | 2005 | break; |
2006 | case KToolBar::Left: | 2006 | case KToolBar::Left: |
2007 | position = "Left"; | 2007 | position = "Left"; |
2008 | break; | 2008 | break; |
2009 | case KToolBar::Right: | 2009 | case KToolBar::Right: |
2010 | position = "Right"; | 2010 | position = "Right"; |
2011 | break; | 2011 | break; |
2012 | case KToolBar::Floating: | 2012 | case KToolBar::Floating: |
2013 | position = "Floating"; | 2013 | position = "Floating"; |
2014 | break; | 2014 | break; |
2015 | case KToolBar::Top: | 2015 | case KToolBar::Top: |
2016 | default: | 2016 | default: |
2017 | position = "Top"; | 2017 | position = "Top"; |
2018 | break; | 2018 | break; |
2019 | } | 2019 | } |
2020 | 2020 | ||
2021 | if ( mainWindow() ) { | 2021 | if ( mainWindow() ) { |
2022 | QMainWindow::ToolBarDock dock; | 2022 | QMainWindow::ToolBarDock dock; |
2023 | bool newLine; | 2023 | bool newLine; |
2024 | int offset; | 2024 | int offset; |
2025 | mainWindow()->getLocation( this, dock, index, newLine, offset ); | 2025 | mainWindow()->getLocation( this, dock, index, newLine, offset ); |
2026 | } | 2026 | } |
2027 | 2027 | ||
2028 | switch (d->m_iconText) { | 2028 | switch (d->m_iconText) { |
2029 | case KToolBar::IconTextRight: | 2029 | case KToolBar::IconTextRight: |
2030 | icontext = "IconTextRight"; | 2030 | icontext = "IconTextRight"; |
2031 | break; | 2031 | break; |
2032 | case KToolBar::IconTextBottom: | 2032 | case KToolBar::IconTextBottom: |
2033 | icontext = "IconTextBottom"; | 2033 | icontext = "IconTextBottom"; |
2034 | break; | 2034 | break; |
2035 | case KToolBar::TextOnly: | 2035 | case KToolBar::TextOnly: |
2036 | icontext = "TextOnly"; | 2036 | icontext = "TextOnly"; |
2037 | break; | 2037 | break; |
2038 | case KToolBar::IconOnly: | 2038 | case KToolBar::IconOnly: |
2039 | default: | 2039 | default: |
2040 | icontext = "IconOnly"; | 2040 | icontext = "IconOnly"; |
2041 | break; | 2041 | break; |
2042 | } | 2042 | } |
2043 | } | 2043 | } |
2044 | /*US | 2044 | /*US |
2045 | void KToolBar::saveState( QDomElement ¤t ) | 2045 | void KToolBar::saveState( QDomElement ¤t ) |
2046 | { | 2046 | { |
2047 | QString position, icontext; | 2047 | QString position, icontext; |
2048 | int index = -1; | 2048 | int index = -1; |
2049 | getAttributes( position, icontext, index ); | 2049 | getAttributes( position, icontext, index ); |
2050 | 2050 | ||
2051 | current.setAttribute( "noMerge", "1" ); | 2051 | current.setAttribute( "noMerge", "1" ); |
2052 | current.setAttribute( "position", position ); | 2052 | current.setAttribute( "position", position ); |
2053 | current.setAttribute( "iconText", icontext ); | 2053 | current.setAttribute( "iconText", icontext ); |
2054 | current.setAttribute( "index", index ); | 2054 | current.setAttribute( "index", index ); |
2055 | current.setAttribute( "offset", offset() ); | 2055 | current.setAttribute( "offset", offset() ); |
2056 | current.setAttribute( "newline", newLine() ); | 2056 | current.setAttribute( "newline", newLine() ); |
2057 | if ( isHidden() ) | 2057 | if ( isHidden() ) |
2058 | current.setAttribute( "hidden", "true" ); | 2058 | current.setAttribute( "hidden", "true" ); |
2059 | d->modified = true; | 2059 | d->modified = true; |
2060 | } | 2060 | } |
2061 | */ | 2061 | */ |
2062 | 2062 | ||
2063 | void KToolBar::positionYourself( bool force ) | 2063 | void KToolBar::positionYourself( bool force ) |
2064 | { | 2064 | { |
2065 | if (force) | 2065 | if (force) |
2066 | d->positioned = false; | 2066 | d->positioned = false; |
2067 | 2067 | ||
2068 | if ( d->positioned || !mainWindow() ) | 2068 | if ( d->positioned || !mainWindow() ) |
2069 | { | 2069 | { |
2070 | //kdDebug(220) << "KToolBar::positionYourself d->positioned=true ALREADY DONE" << endl; | 2070 | //kdDebug(220) << "KToolBar::positionYourself d->positioned=true ALREADY DONE" << endl; |
2071 | return; | 2071 | return; |
2072 | } | 2072 | } |
2073 | // we can't test for ForceHide after moveDockWindow because QDockArea | 2073 | // we can't test for ForceHide after moveDockWindow because QDockArea |
2074 | // does a reparent() with showIt == true | 2074 | // does a reparent() with showIt == true |
2075 | bool doHide = isHidden(); | 2075 | bool doHide = isHidden(); |
2076 | //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; |
2077 | /*US mainWindow()->moveDockWindow( this, d->toolBarInfo.dock, | 2077 | /*US mainWindow()->moveDockWindow( this, d->toolBarInfo.dock, |
2078 | d->toolBarInfo.newline, | 2078 | d->toolBarInfo.newline, |
2079 | d->toolBarInfo.index, | 2079 | d->toolBarInfo.index, |
2080 | d->toolBarInfo.offset ); | 2080 | d->toolBarInfo.offset ); |
2081 | */ | 2081 | */ |
2082 | 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 ); |
2083 | 2083 | ||
2084 | if ( doHide ) | 2084 | if ( doHide ) |
2085 | hide(); | 2085 | hide(); |
2086 | // 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 |
2087 | d->positioned = TRUE; | 2087 | d->positioned = TRUE; |
2088 | } | 2088 | } |
2089 | 2089 | ||
2090 | //US KPopupMenu *KToolBar::contextMenu() | 2090 | //US KPopupMenu *KToolBar::contextMenu() |
2091 | QPopupMenu *KToolBar::contextMenu() | 2091 | QPopupMenu *KToolBar::contextMenu() |
2092 | { | 2092 | { |
2093 | if ( context ) | 2093 | if ( context ) |
2094 | return context; | 2094 | return context; |
2095 | 2095 | ||
2096 | // 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 |
2097 | // won't be deleted by QToolBar::clear(). | 2097 | // won't be deleted by QToolBar::clear(). |
2098 | //US context = new KPopupMenu( this, "qt_dockwidget_internal" ); | 2098 | //US context = new KPopupMenu( this, "qt_dockwidget_internal" ); |
2099 | context = new QPopupMenu( this, "qt_dockwidget_internal" ); | 2099 | context = new QPopupMenu( this, "qt_dockwidget_internal" ); |
2100 | //US context->insertTitle(i18n("Toolbar Menu")); | 2100 | //US context->insertTitle(i18n("Toolbar Menu")); |
2101 | 2101 | ||
2102 | //US KPopupMenu *orient = new KPopupMenu( context, "orient" ); | 2102 | //US KPopupMenu *orient = new KPopupMenu( context, "orient" ); |
2103 | QPopupMenu *orient = new QPopupMenu( context, "orient" ); | 2103 | QPopupMenu *orient = new QPopupMenu( context, "orient" ); |
2104 | orient->insertItem( i18n("toolbar position string","Top"), CONTEXT_TOP ); | 2104 | orient->insertItem( i18n("toolbar position string","Top"), CONTEXT_TOP ); |
2105 | orient->insertItem( i18n("toolbar position string","Left"), CONTEXT_LEFT ); | 2105 | orient->insertItem( i18n("toolbar position string","Left"), CONTEXT_LEFT ); |
2106 | orient->insertItem( i18n("toolbar position string","Right"), CONTEXT_RIGHT ); | 2106 | orient->insertItem( i18n("toolbar position string","Right"), CONTEXT_RIGHT ); |
2107 | orient->insertItem( i18n("toolbar position string","Bottom"), CONTEXT_BOTTOM ); | 2107 | orient->insertItem( i18n("toolbar position string","Bottom"), CONTEXT_BOTTOM ); |
2108 | orient->insertSeparator(-1); | 2108 | orient->insertSeparator(-1); |
2109 | //orient->insertItem( i18n("toolbar position string","Floating"), CONTEXT_FLOAT ); | 2109 | //orient->insertItem( i18n("toolbar position string","Floating"), CONTEXT_FLOAT ); |
2110 | orient->insertItem( i18n("min toolbar", "Flat"), CONTEXT_FLAT ); | 2110 | orient->insertItem( i18n("min toolbar", "Flat"), CONTEXT_FLAT ); |
2111 | 2111 | ||
2112 | //US KPopupMenu *mode = new KPopupMenu( context, "mode" ); | 2112 | //US KPopupMenu *mode = new KPopupMenu( context, "mode" ); |
2113 | QPopupMenu *mode = new QPopupMenu( context, "mode" ); | 2113 | QPopupMenu *mode = new QPopupMenu( context, "mode" ); |
2114 | mode->insertItem( i18n("Icons Only"), CONTEXT_ICONS ); | 2114 | mode->insertItem( i18n("Icons Only"), CONTEXT_ICONS ); |
2115 | mode->insertItem( i18n("Text Only"), CONTEXT_TEXT ); | 2115 | mode->insertItem( i18n("Text Only"), CONTEXT_TEXT ); |
2116 | mode->insertItem( i18n("Text Alongside Icons"), CONTEXT_TEXTRIGHT ); | 2116 | mode->insertItem( i18n("Text Alongside Icons"), CONTEXT_TEXTRIGHT ); |
2117 | mode->insertItem( i18n("Text Under Icons"), CONTEXT_TEXTUNDER ); | 2117 | mode->insertItem( i18n("Text Under Icons"), CONTEXT_TEXTUNDER ); |
2118 | 2118 | ||
2119 | //US KPopupMenu *size = new KPopupMenu( context, "size" ); | 2119 | //US KPopupMenu *size = new KPopupMenu( context, "size" ); |
2120 | QPopupMenu *size = new QPopupMenu( context, "size" ); | 2120 | QPopupMenu *size = new QPopupMenu( context, "size" ); |
2121 | size->insertItem( i18n("Default"), CONTEXT_ICONSIZES ); | 2121 | size->insertItem( i18n("Default"), CONTEXT_ICONSIZES ); |
2122 | // Query the current theme for available sizes | 2122 | // Query the current theme for available sizes |
2123 | QValueList<int> avSizes; | 2123 | QValueList<int> avSizes; |
2124 | /*US | 2124 | /*US |
2125 | KIconTheme *theme = KGlobal::instance()->iconLoader()->theme(); | 2125 | KIconTheme *theme = KGlobal::instance()->iconLoader()->theme(); |
2126 | if (!::qstrcmp(QObject::name(), "mainToolBar")) | 2126 | if (!::qstrcmp(QObject::name(), "mainToolBar")) |
2127 | avSizes = theme->querySizes( KIcon::MainToolbar); | 2127 | avSizes = theme->querySizes( KIcon::MainToolbar); |
2128 | else | 2128 | else |
2129 | avSizes = theme->querySizes( KIcon::Toolbar); | 2129 | avSizes = theme->querySizes( KIcon::Toolbar); |
2130 | */ | 2130 | */ |
2131 | avSizes << 16; | 2131 | avSizes << 16; |
2132 | avSizes << 32; | 2132 | avSizes << 32; |
2133 | 2133 | ||
2134 | d->iconSizes = avSizes; | 2134 | d->iconSizes = avSizes; |
2135 | 2135 | ||
2136 | QValueList<int>::Iterator it; | 2136 | QValueList<int>::Iterator it; |
2137 | for (it=avSizes.begin(); it!=avSizes.end(); it++) { | 2137 | for (it=avSizes.begin(); it!=avSizes.end(); it++) { |
2138 | QString text; | 2138 | QString text; |
2139 | if ( *it < 19 ) | 2139 | if ( *it < 19 ) |
2140 | text = i18n("Small (%1x%2)").arg(*it).arg(*it); | 2140 | text = i18n("Small (%1x%2)").arg(*it).arg(*it); |
2141 | else if (*it < 25) | 2141 | else if (*it < 25) |
2142 | text = i18n("Medium (%1x%2)").arg(*it).arg(*it); | 2142 | text = i18n("Medium (%1x%2)").arg(*it).arg(*it); |
2143 | else | 2143 | else |
2144 | text = i18n("Large (%1x%2)").arg(*it).arg(*it); | 2144 | text = i18n("Large (%1x%2)").arg(*it).arg(*it); |
2145 | //we use the size as an id, with an offset | 2145 | //we use the size as an id, with an offset |
2146 | size->insertItem( text, CONTEXT_ICONSIZES + *it ); | 2146 | size->insertItem( text, CONTEXT_ICONSIZES + *it ); |
2147 | } | 2147 | } |
2148 | 2148 | ||
2149 | context->insertItem( i18n("Orientation"), orient ); | 2149 | context->insertItem( i18n("Orientation"), orient ); |
2150 | orient->setItemChecked(CONTEXT_TOP, true); | 2150 | orient->setItemChecked(CONTEXT_TOP, true); |
2151 | context->insertItem( i18n("Text Position"), mode ); | 2151 | context->insertItem( i18n("Text Position"), mode ); |
2152 | context->setItemChecked(CONTEXT_ICONS, true); | 2152 | context->setItemChecked(CONTEXT_ICONS, true); |
2153 | context->insertItem( i18n("Icon Size"), size ); | 2153 | context->insertItem( i18n("Icon Size"), size ); |
2154 | 2154 | ||
2155 | /*US | 2155 | /*US |
2156 | if (mainWindow()->inherits("KMainWindow")) | 2156 | if (mainWindow()->inherits("KMainWindow")) |
2157 | { | 2157 | { |
2158 | if ( (static_cast<KMainWindow*>(mainWindow())->toolBarMenuAction()) && | 2158 | if ( (static_cast<KMainWindow*>(mainWindow())->toolBarMenuAction()) && |
2159 | (static_cast<KMainWindow*>(mainWindow())->hasMenuBar()) ) | 2159 | (static_cast<KMainWindow*>(mainWindow())->hasMenuBar()) ) |
2160 | 2160 | ||
2161 | (static_cast<KMainWindow*>(mainWindow()))->toolBarMenuAction()->plug(context); | 2161 | (static_cast<KMainWindow*>(mainWindow()))->toolBarMenuAction()->plug(context); |
2162 | } | 2162 | } |
2163 | */ | 2163 | */ |
2164 | 2164 | ||
2165 | connect( context, SIGNAL( aboutToShow() ), this, SLOT( slotContextAboutToShow() ) ); | 2165 | connect( context, SIGNAL( aboutToShow() ), this, SLOT( slotContextAboutToShow() ) ); |
2166 | return context; | 2166 | return context; |
2167 | } | 2167 | } |
2168 | 2168 | ||
2169 | void KToolBar::slotContextAboutToShow() | 2169 | void KToolBar::slotContextAboutToShow() |
2170 | { | 2170 | { |
2171 | if (!d->m_configurePlugged) | 2171 | if (!d->m_configurePlugged) |
2172 | { | 2172 | { |
2173 | // try to find "configure toolbars" action | 2173 | // try to find "configure toolbars" action |
2174 | 2174 | ||
2175 | KXMLGUIClient *xmlGuiClient = d->m_xmlguiClient; | 2175 | KXMLGUIClient *xmlGuiClient = d->m_xmlguiClient; |
2176 | if ( !xmlGuiClient && mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) | 2176 | if ( !xmlGuiClient && mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) |
2177 | xmlGuiClient = (KXMLGUIClient *)mainWindow(); | 2177 | xmlGuiClient = (KXMLGUIClient *)mainWindow(); |
2178 | if ( xmlGuiClient ) | 2178 | if ( xmlGuiClient ) |
2179 | { | 2179 | { |
2180 | KAction *configureAction = xmlGuiClient->actionCollection()->action(KStdAction::stdName(KStdAction::ConfigureToolbars)); | 2180 | KAction *configureAction = xmlGuiClient->actionCollection()->action(KStdAction::stdName(KStdAction::ConfigureToolbars)); |
2181 | if ( configureAction ) | 2181 | if ( configureAction ) |
2182 | { | 2182 | { |
2183 | configureAction->plug(context); | 2183 | configureAction->plug(context); |
2184 | d->m_configurePlugged = true; | 2184 | d->m_configurePlugged = true; |
2185 | } | 2185 | } |
2186 | } | 2186 | } |
2187 | } | 2187 | } |
2188 | 2188 | ||
2189 | for(int i = CONTEXT_ICONS; i <= CONTEXT_TEXTUNDER; ++i) | 2189 | for(int i = CONTEXT_ICONS; i <= CONTEXT_TEXTUNDER; ++i) |
2190 | context->setItemChecked(i, false); | 2190 | context->setItemChecked(i, false); |
2191 | 2191 | ||
2192 | switch( d->m_iconText ) | 2192 | switch( d->m_iconText ) |
2193 | { | 2193 | { |
2194 | case IconOnly: | 2194 | case IconOnly: |
2195 | default: | 2195 | default: |
2196 | context->setItemChecked(CONTEXT_ICONS, true); | 2196 | context->setItemChecked(CONTEXT_ICONS, true); |
2197 | break; | 2197 | break; |
2198 | case IconTextRight: | 2198 | case IconTextRight: |
2199 | context->setItemChecked(CONTEXT_TEXTRIGHT, true); | 2199 | context->setItemChecked(CONTEXT_TEXTRIGHT, true); |
2200 | break; | 2200 | break; |
2201 | case TextOnly: | 2201 | case TextOnly: |
2202 | context->setItemChecked(CONTEXT_TEXT, true); | 2202 | context->setItemChecked(CONTEXT_TEXT, true); |
2203 | break; | 2203 | break; |
2204 | case IconTextBottom: | 2204 | case IconTextBottom: |
2205 | context->setItemChecked(CONTEXT_TEXTUNDER, true); | 2205 | context->setItemChecked(CONTEXT_TEXTUNDER, true); |
2206 | break; | 2206 | break; |
2207 | } | 2207 | } |
2208 | 2208 | ||
2209 | QValueList<int>::ConstIterator iIt = d->iconSizes.begin(); | 2209 | QValueList<int>::ConstIterator iIt = d->iconSizes.begin(); |
2210 | QValueList<int>::ConstIterator iEnd = d->iconSizes.end(); | 2210 | QValueList<int>::ConstIterator iEnd = d->iconSizes.end(); |
2211 | for (; iIt != iEnd; ++iIt ) | 2211 | for (; iIt != iEnd; ++iIt ) |
2212 | context->setItemChecked( CONTEXT_ICONSIZES + *iIt, false ); | 2212 | context->setItemChecked( CONTEXT_ICONSIZES + *iIt, false ); |
2213 | 2213 | ||
2214 | context->setItemChecked( CONTEXT_ICONSIZES, false ); | 2214 | context->setItemChecked( CONTEXT_ICONSIZES, false ); |
2215 | 2215 | ||
2216 | context->setItemChecked( CONTEXT_ICONSIZES + d->m_iconSize, true ); | 2216 | context->setItemChecked( CONTEXT_ICONSIZES + d->m_iconSize, true ); |
2217 | 2217 | ||
2218 | for ( int i = CONTEXT_TOP; i <= CONTEXT_FLAT; ++i ) | 2218 | for ( int i = CONTEXT_TOP; i <= CONTEXT_FLAT; ++i ) |
2219 | context->setItemChecked( i, false ); | 2219 | context->setItemChecked( i, false ); |
2220 | 2220 | ||
2221 | switch ( barPos() ) | 2221 | switch ( barPos() ) |
2222 | { | 2222 | { |
2223 | case KToolBar::Flat: | 2223 | case KToolBar::Flat: |
2224 | context->setItemChecked( CONTEXT_FLAT, true ); | 2224 | context->setItemChecked( CONTEXT_FLAT, true ); |
2225 | break; | 2225 | break; |
2226 | case KToolBar::Bottom: | 2226 | case KToolBar::Bottom: |
2227 | context->setItemChecked( CONTEXT_BOTTOM, true ); | 2227 | context->setItemChecked( CONTEXT_BOTTOM, true ); |
2228 | break; | 2228 | break; |
2229 | case KToolBar::Left: | 2229 | case KToolBar::Left: |
2230 | context->setItemChecked( CONTEXT_LEFT, true ); | 2230 | context->setItemChecked( CONTEXT_LEFT, true ); |
2231 | break; | 2231 | break; |
2232 | case KToolBar::Right: | 2232 | case KToolBar::Right: |
2233 | context->setItemChecked( CONTEXT_RIGHT, true ); | 2233 | context->setItemChecked( CONTEXT_RIGHT, true ); |
2234 | break; | 2234 | break; |
2235 | case KToolBar::Floating: | 2235 | case KToolBar::Floating: |
2236 | context->setItemChecked( CONTEXT_FLOAT, true ); | 2236 | context->setItemChecked( CONTEXT_FLOAT, true ); |
2237 | break; | 2237 | break; |
2238 | case KToolBar::Top: | 2238 | case KToolBar::Top: |
2239 | context->setItemChecked( CONTEXT_TOP, true ); | 2239 | context->setItemChecked( CONTEXT_TOP, true ); |
2240 | break; | 2240 | break; |
2241 | default: break; | 2241 | default: break; |
2242 | } | 2242 | } |
2243 | } | 2243 | } |
2244 | 2244 | ||
2245 | void KToolBar::widgetDestroyed() | 2245 | void KToolBar::widgetDestroyed() |
2246 | { | 2246 | { |
2247 | removeWidgetInternal( (QWidget*)sender() ); | 2247 | removeWidgetInternal( (QWidget*)sender() ); |
2248 | } | 2248 | } |
2249 | 2249 | ||
2250 | void KToolBar::removeWidgetInternal( QWidget * w ) | 2250 | void KToolBar::removeWidgetInternal( QWidget * w ) |
2251 | { | 2251 | { |
2252 | if ( inshutdownprocess ) | 2252 | if ( inshutdownprocess ) |
2253 | return; | 2253 | return; |
2254 | widgets.removeRef( w ); | 2254 | widgets.removeRef( w ); |
2255 | QMap< QWidget*, int >::Iterator it = widget2id.find( w ); | 2255 | QMap< QWidget*, int >::Iterator it = widget2id.find( w ); |
2256 | if ( it == widget2id.end() ) | 2256 | if ( it == widget2id.end() ) |
2257 | return; | 2257 | return; |
2258 | id2widget.remove( *it ); | 2258 | id2widget.remove( *it ); |
2259 | widget2id.remove( it ); | 2259 | widget2id.remove( it ); |
2260 | } | 2260 | } |
2261 | 2261 | ||
2262 | void KToolBar::virtual_hook( int, void* ) | 2262 | void KToolBar::virtual_hook( int, void* ) |
2263 | { /*BASE::virtual_hook( id, data );*/ } | 2263 | { /*BASE::virtual_hook( id, data );*/ } |
2264 | 2264 | ||
2265 | //US #include "ktoolbar.moc" | 2265 | //US #include "ktoolbar.moc" |
2266 | 2266 | ||
diff --git a/microkde/kdeui/ktoolbar.h b/microkde/kdeui/ktoolbar.h index 61b5ea3..49ff856 100644 --- a/microkde/kdeui/ktoolbar.h +++ b/microkde/kdeui/ktoolbar.h | |||
@@ -1,1108 +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() const; |
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 | void repaintMe(); |
1049 | static bool highlightSetting(); | 1049 | static bool highlightSetting(); |
1050 | 1050 | ||
1051 | /** | 1051 | /** |
1052 | * @return global setting for "Toolbars transparent when moving" | 1052 | * @return global setting for "Toolbars transparent when moving" |
1053 | */ | 1053 | */ |
1054 | static bool transparentSetting(); | 1054 | static bool transparentSetting(); |
1055 | 1055 | ||
1056 | /** | 1056 | /** |
1057 | * @return global setting for "Icon Text" | 1057 | * @return global setting for "Icon Text" |
1058 | */ | 1058 | */ |
1059 | static IconText iconTextSetting(); | 1059 | static IconText iconTextSetting(); |
1060 | 1060 | ||
1061 | public slots: | 1061 | public slots: |
1062 | virtual void setIconText( const QString &txt ) | 1062 | virtual void setIconText( const QString &txt ) |
1063 | { QToolBar::setIconText( txt ); } | 1063 | { QToolBar::setIconText( txt ); } |
1064 | void slotRepaint(); | 1064 | void slotRepaint(); |
1065 | 1065 | ||
1066 | protected: | 1066 | protected: |
1067 | void mousePressEvent( QMouseEvent * ); | 1067 | void mousePressEvent( QMouseEvent * ); |
1068 | void childEvent( QChildEvent *e ); | 1068 | void childEvent( QChildEvent *e ); |
1069 | void showEvent( QShowEvent *e ); | 1069 | void showEvent( QShowEvent *e ); |
1070 | void resizeEvent( QResizeEvent *e ); | 1070 | void resizeEvent( QResizeEvent *e ); |
1071 | bool event( QEvent *e ); | 1071 | bool event( QEvent *e ); |
1072 | void applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal = false); | 1072 | void applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal = false); |
1073 | QString settingsGroup(); | 1073 | QString settingsGroup(); |
1074 | 1074 | ||
1075 | private slots: | 1075 | private slots: |
1076 | void rebuildLayout(); | 1076 | void rebuildLayout(); |
1077 | void slotReadConfig (); | 1077 | void slotReadConfig (); |
1078 | void slotAppearanceChanged(); | 1078 | void slotAppearanceChanged(); |
1079 | void slotIconChanged(int); | 1079 | void slotIconChanged(int); |
1080 | void toolBarPosChanged( QToolBar *tb ); | 1080 | void toolBarPosChanged( QToolBar *tb ); |
1081 | void slotContextAboutToShow(); | 1081 | void slotContextAboutToShow(); |
1082 | void widgetDestroyed(); | 1082 | void widgetDestroyed(); |
1083 | 1083 | ||
1084 | private: | 1084 | private: |
1085 | void init( bool readConfig = true, bool honorStyle = false ); | 1085 | void init( bool readConfig = true, bool honorStyle = false ); |
1086 | void doConnections( KToolBarButton *button ); | 1086 | void doConnections( KToolBarButton *button ); |
1087 | void insertWidgetInternal( QWidget *w, int &index, int id ); | 1087 | void insertWidgetInternal( QWidget *w, int &index, int id ); |
1088 | void removeWidgetInternal( QWidget *w ); | 1088 | void removeWidgetInternal( QWidget *w ); |
1089 | void getAttributes( QString &position, QString &icontext, int &index ); | 1089 | void getAttributes( QString &position, QString &icontext, int &index ); |
1090 | //US KPopupMenu *contextMenu(); | 1090 | //US KPopupMenu *contextMenu(); |
1091 | QPopupMenu *contextMenu(); | 1091 | QPopupMenu *contextMenu(); |
1092 | 1092 | ||
1093 | QMap<QWidget*, int > widget2id; | 1093 | QMap<QWidget*, int > widget2id; |
1094 | typedef QMap<int, QWidget* > Id2WidgetMap; | 1094 | typedef QMap<int, QWidget* > Id2WidgetMap; |
1095 | Id2WidgetMap id2widget; | 1095 | Id2WidgetMap id2widget; |
1096 | //US KPopupMenu *context; | 1096 | //US KPopupMenu *context; |
1097 | QPopupMenu *context; | 1097 | QPopupMenu *context; |
1098 | QPtrList<QWidget> widgets; | 1098 | QPtrList<QWidget> widgets; |
1099 | QTimer *layoutTimer; | 1099 | QTimer *layoutTimer; |
1100 | QGuardedPtr<QWidget> stretchableWidget, rightAligned; | 1100 | QGuardedPtr<QWidget> stretchableWidget, rightAligned; |
1101 | protected: | 1101 | protected: |
1102 | virtual void virtual_hook( int id, void* data ); | 1102 | virtual void virtual_hook( int id, void* data ); |
1103 | private: | 1103 | private: |
1104 | KToolBarPrivate *d; | 1104 | KToolBarPrivate *d; |
1105 | bool inshutdownprocess; | 1105 | bool inshutdownprocess; |
1106 | }; | 1106 | }; |
1107 | 1107 | ||
1108 | #endif | 1108 | #endif |