author | zautrix <zautrix> | 2004-10-23 14:56:10 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-23 14:56:10 (UTC) |
commit | a682b1d39c63cff8d709c67460569c70b661d889 (patch) (unidiff) | |
tree | dd5cb4052b07927b63bafa68b2fd6d40bce6a6dc | |
parent | 73c0cb5307a8276f628765c651ef0284b85d64de (diff) | |
download | kdepimpi-a682b1d39c63cff8d709c67460569c70b661d889.zip kdepimpi-a682b1d39c63cff8d709c67460569c70b661d889.tar.gz kdepimpi-a682b1d39c63cff8d709c67460569c70b661d889.tar.bz2 |
fixed several memory leaks
-rw-r--r-- | kaddressbook/mainembedded.cpp | 7 | ||||
-rw-r--r-- | kmicromail/main.cpp | 3 | ||||
-rw-r--r-- | korganizer/kolistview.cpp | 1 | ||||
-rw-r--r-- | korganizer/koprefs.cpp | 10 | ||||
-rw-r--r-- | korganizer/main.cpp | 3 | ||||
-rw-r--r-- | libkdepim/externalapphandler.cpp | 12 | ||||
-rw-r--r-- | libkdepim/externalapphandler.h | 2 | ||||
-rw-r--r-- | libkdepim/kpimglobalprefs.cpp | 3 | ||||
-rw-r--r-- | microkde/kdeui/klistview.cpp | 5 | ||||
-rw-r--r-- | pwmanager/pwmanager/main.cpp | 2 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwm.cpp | 2 |
11 files changed, 28 insertions, 22 deletions
diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp index a8816f9..547d208 100644 --- a/kaddressbook/mainembedded.cpp +++ b/kaddressbook/mainembedded.cpp | |||
@@ -1,99 +1,100 @@ | |||
1 | #ifndef DESKTOP_VERSION | 1 | #ifndef DESKTOP_VERSION |
2 | #include <qpe/qpeapplication.h> | 2 | #include <qpe/qpeapplication.h> |
3 | #include <qcopchannel_qws.h> | 3 | #include <qcopchannel_qws.h> |
4 | #include <stdlib.h> | 4 | #include <stdlib.h> |
5 | #else | 5 | #else |
6 | #include <qapplication.h> | 6 | #include <qapplication.h> |
7 | #include <qwindowsstyle.h> | 7 | #include <qwindowsstyle.h> |
8 | #include <qplatinumstyle.h> | 8 | #include <qplatinumstyle.h> |
9 | #include <qmainwindow.h> | 9 | #include <qmainwindow.h> |
10 | #endif | 10 | #endif |
11 | 11 | ||
12 | #include <qtextcodec.h> | 12 | #include <qtextcodec.h> |
13 | #include <kstandarddirs.h> | 13 | #include <kstandarddirs.h> |
14 | #include <qregexp.h> | 14 | #include <qregexp.h> |
15 | #include <kglobal.h> | 15 | #include <kglobal.h> |
16 | #include <stdio.h> | 16 | #include <stdio.h> |
17 | #include <qdir.h> | 17 | #include <qdir.h> |
18 | #include "kabprefs.h" | 18 | #include "kabprefs.h" |
19 | #include "kaddressbookmain.h" | 19 | #include "kaddressbookmain.h" |
20 | #include "externalapphandler.h" | 20 | #include "externalapphandler.h" |
21 | #include <libkdepim/kpimglobalprefs.h> | 21 | #include <libkdepim/kpimglobalprefs.h> |
22 | void dumpMissing(); | 22 | void dumpMissing(); |
23 | int main( int argc, char **argv ) | 23 | int main( int argc, char **argv ) |
24 | { | 24 | { |
25 | #ifndef DESKTOP_VERSION | 25 | #ifndef DESKTOP_VERSION |
26 | QPEApplication a( argc, argv ); | 26 | QPEApplication a( argc, argv ); |
27 | a.setKeepRunning (); | 27 | a.setKeepRunning (); |
28 | #else | 28 | #else |
29 | QApplication a( argc, argv ); | 29 | QApplication a( argc, argv ); |
30 | QApplication::setStyle( new QPlatinumStyle ()); | 30 | QApplication::setStyle( new QPlatinumStyle ()); |
31 | QString hdir = QDir::homeDirPath(); | 31 | QString hdir = QDir::homeDirPath(); |
32 | // there is a bug when creating dirs for WIN 98 | 32 | // there is a bug when creating dirs for WIN 98 |
33 | // it is difficult to fix, because we have no WIN 98 runnung | 33 | // it is difficult to fix, because we have no WIN 98 runnung |
34 | // such that we try it to create the dirs at startup here | 34 | // such that we try it to create the dirs at startup here |
35 | if ( hdir == "C:\\" ) { // win 98 or ME | 35 | if ( hdir == "C:\\" ) { // win 98 or ME |
36 | QDir app_dir; | 36 | QDir app_dir; |
37 | if ( !app_dir.exists("C:\\kdepim") ) | 37 | if ( !app_dir.exists("C:\\kdepim") ) |
38 | app_dir.mkdir ("C:\\kdepim"); | 38 | app_dir.mkdir ("C:\\kdepim"); |
39 | if ( !app_dir.exists("C:\\kdepim\\apps") ) | 39 | if ( !app_dir.exists("C:\\kdepim\\apps") ) |
40 | app_dir.mkdir ("C:\\kdepim\\apps"); | 40 | app_dir.mkdir ("C:\\kdepim\\apps"); |
41 | if ( !app_dir.exists("C:\\kdepim\\config") ) | 41 | if ( !app_dir.exists("C:\\kdepim\\config") ) |
42 | app_dir.mkdir ("C:\\kdepim\\config"); | 42 | app_dir.mkdir ("C:\\kdepim\\config"); |
43 | if ( !app_dir.exists("C:\\kdepim\\apps\\kaddressbook") ) | 43 | if ( !app_dir.exists("C:\\kdepim\\apps\\kaddressbook") ) |
44 | app_dir.mkdir ("C:\\kdepim\\apps\\kaddressbook"); | 44 | app_dir.mkdir ("C:\\kdepim\\apps\\kaddressbook"); |
45 | } | 45 | } |
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | bool exitHelp = false; | 48 | bool exitHelp = false; |
49 | if ( argc > 1 ) { | 49 | if ( argc > 1 ) { |
50 | QString command = argv[1]; | 50 | QString command = argv[1]; |
51 | if ( command == "-help" ){ | 51 | if ( command == "-help" ){ |
52 | printf("KA/E command line commands:\n"); | 52 | printf("KA/E command line commands:\n"); |
53 | printf(" no command: Start KA/E in usual way\n"); | 53 | printf(" no command: Start KA/E in usual way\n"); |
54 | printf(" -help: This output\n"); | 54 | printf(" -help: This output\n"); |
55 | printf(" KA/E is exiting now. Bye!\n"); | 55 | printf(" KA/E is exiting now. Bye!\n"); |
56 | exitHelp = true; | 56 | exitHelp = true; |
57 | } | 57 | } |
58 | } | 58 | } |
59 | if ( ! exitHelp ) { | 59 | if ( ! exitHelp ) { |
60 | 60 | ||
61 | KGlobal::setAppName( "kaddressbook" ); | 61 | KGlobal::setAppName( "kaddressbook" ); |
62 | #ifndef DESKTOP_VERSION | 62 | #ifndef DESKTOP_VERSION |
63 | if ( QApplication::desktop()->width() > 320 ) | 63 | if ( QApplication::desktop()->width() > 320 ) |
64 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/"); | 64 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/"); |
65 | else | 65 | else |
66 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); | 66 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); |
67 | #else | 67 | #else |
68 | QString fileName ; | 68 | QString fileName ; |
69 | fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/"; | 69 | fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/"; |
70 | KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); | 70 | KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); |
71 | QApplication::addLibraryPath ( qApp->applicationDirPath () ); | 71 | QApplication::addLibraryPath ( qApp->applicationDirPath () ); |
72 | 72 | ||
73 | #endif | 73 | #endif |
74 | KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); | 74 | KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); |
75 | // init language | 75 | // init language |
76 | KABPrefs::instance(); | 76 | KABPrefs::instance(); |
77 | KAddressBookMain m ; | 77 | KAddressBookMain m ; |
78 | //US MainWindow m; | 78 | //US MainWindow m; |
79 | QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 79 | QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
80 | 80 | ||
81 | { | 81 | |
82 | KPimGlobalPrefs::instance()->setGlobalConfig(); | 82 | KPimGlobalPrefs::instance()->setGlobalConfig(); |
83 | } | 83 | |
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | a.showMainWidget( &m ); | 85 | a.showMainWidget( &m ); |
86 | 86 | ||
87 | #else | 87 | #else |
88 | a.setMainWidget( &m ); | 88 | a.setMainWidget( &m ); |
89 | m.resize (640, 480 ); | 89 | m.resize (640, 480 ); |
90 | m.show(); | 90 | m.show(); |
91 | #endif | 91 | #endif |
92 | a.exec(); | 92 | a.exec(); |
93 | 93 | ||
94 | dumpMissing(); | 94 | dumpMissing(); |
95 | 95 | ||
96 | KPimGlobalPrefs::instance()->writeConfig(); | ||
96 | } | 97 | } |
97 | qDebug("KA: Bye! "); | 98 | qDebug("KA: Bye! "); |
98 | } | 99 | } |
99 | 100 | ||
diff --git a/kmicromail/main.cpp b/kmicromail/main.cpp index 8947ff8..8341c5a 100644 --- a/kmicromail/main.cpp +++ b/kmicromail/main.cpp | |||
@@ -1,63 +1,66 @@ | |||
1 | // CHANGED 2004-08-06 Lutz Rogowski | 1 | // CHANGED 2004-08-06 Lutz Rogowski |
2 | 2 | ||
3 | 3 | ||
4 | #ifndef DESKTOP_VERSION | 4 | #ifndef DESKTOP_VERSION |
5 | #include <qpe/qpeapplication.h> | 5 | #include <qpe/qpeapplication.h> |
6 | #include <libkdepim/externalapphandler.h> | 6 | #include <libkdepim/externalapphandler.h> |
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | #else | 8 | #else |
9 | #include <qapplication.h> | 9 | #include <qapplication.h> |
10 | #include <qstring.h> | 10 | #include <qstring.h> |
11 | #include <qwindowsstyle.h> | 11 | #include <qwindowsstyle.h> |
12 | #include <qplatinumstyle.h> | 12 | #include <qplatinumstyle.h> |
13 | #include <qsgistyle.h> | 13 | #include <qsgistyle.h> |
14 | #endif | 14 | #endif |
15 | #include "opiemail.h" | 15 | #include "opiemail.h" |
16 | #include <qdir.h> | 16 | #include <qdir.h> |
17 | #include <kstandarddirs.h> | 17 | #include <kstandarddirs.h> |
18 | #include <kglobal.h> | 18 | #include <kglobal.h> |
19 | #include <stdio.h> | 19 | #include <stdio.h> |
20 | #include "mainwindow.h" | 20 | #include "mainwindow.h" |
21 | #include "koprefs.h" | 21 | #include "koprefs.h" |
22 | #include <libkdepim/kpimglobalprefs.h> | ||
22 | void dumpMissing(); | 23 | void dumpMissing(); |
23 | //using namespace Opie::Core; | 24 | //using namespace Opie::Core; |
24 | int main( int argc, char **argv ) { | 25 | int main( int argc, char **argv ) { |
25 | 26 | ||
26 | #ifndef DESKTOP_VERSION | 27 | #ifndef DESKTOP_VERSION |
27 | QPEApplication a( argc, argv ); | 28 | QPEApplication a( argc, argv ); |
28 | a.setKeepRunning (); | 29 | a.setKeepRunning (); |
29 | #else | 30 | #else |
30 | QApplication a( argc, argv ); | 31 | QApplication a( argc, argv ); |
31 | QApplication::setStyle( new QPlatinumStyle ()); | 32 | QApplication::setStyle( new QPlatinumStyle ()); |
32 | #endif | 33 | #endif |
33 | a.setFont( KOPrefs::instance()->mAppFont ); | 34 | a.setFont( KOPrefs::instance()->mAppFont ); |
34 | KGlobal::setAppName( "kopiemail" ); | 35 | KGlobal::setAppName( "kopiemail" ); |
35 | QString fileName ; | 36 | QString fileName ; |
36 | #ifndef DESKTOP_VERSION | 37 | #ifndef DESKTOP_VERSION |
37 | fileName = getenv("QPEDIR"); | 38 | fileName = getenv("QPEDIR"); |
38 | if ( QApplication::desktop()->width() > 320 ) | 39 | if ( QApplication::desktop()->width() > 320 ) |
39 | KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/kopiemail/icons22/"); | 40 | KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/kopiemail/icons22/"); |
40 | else | 41 | else |
41 | KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/kopiemail/"); | 42 | KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/kopiemail/"); |
42 | #else | 43 | #else |
43 | fileName = qApp->applicationDirPath () + "/kdepim/kopiemail/"; | 44 | fileName = qApp->applicationDirPath () + "/kdepim/kopiemail/"; |
44 | KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); | 45 | KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); |
45 | #endif | 46 | #endif |
46 | KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kopiemail"))); | 47 | KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kopiemail"))); |
47 | OpieMail mw; | 48 | OpieMail mw; |
48 | #ifndef DESKTOP_VERSION | 49 | #ifndef DESKTOP_VERSION |
49 | //qDebug("CONNECT "); | 50 | //qDebug("CONNECT "); |
50 | QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&mw, SLOT(message( const QCString&, const QByteArray& ))); | 51 | QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&mw, SLOT(message( const QCString&, const QByteArray& ))); |
51 | // QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 52 | // QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
52 | a.showMainWidget(&mw ); | 53 | a.showMainWidget(&mw ); |
53 | #else | 54 | #else |
54 | a.setMainWidget(&mw ); | 55 | a.setMainWidget(&mw ); |
55 | mw.show(); | 56 | mw.show(); |
56 | //m.resize( 800, 600 ); | 57 | //m.resize( 800, 600 ); |
57 | QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); | 58 | QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); |
58 | #endif | 59 | #endif |
59 | int rv = a.exec(); | 60 | int rv = a.exec(); |
60 | dumpMissing(); | 61 | dumpMissing(); |
62 | |||
63 | KPimGlobalPrefs::instance()->writeConfig(); | ||
61 | return rv; | 64 | return rv; |
62 | 65 | ||
63 | } | 66 | } |
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index d3aa650..3d4acb7 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp | |||
@@ -1,1073 +1,1074 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 1999 Preston Brown | 3 | Copyright (c) 1999 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 program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program 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 | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qlistview.h> | 25 | #include <qlistview.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qpopupmenu.h> | 28 | #include <qpopupmenu.h> |
29 | #include <qprogressbar.h> | 29 | #include <qprogressbar.h> |
30 | #include <qfileinfo.h> | 30 | #include <qfileinfo.h> |
31 | #include <qmessagebox.h> | 31 | #include <qmessagebox.h> |
32 | #include <qdialog.h> | 32 | #include <qdialog.h> |
33 | #include <qtextstream.h> | 33 | #include <qtextstream.h> |
34 | #include <qdir.h> | 34 | #include <qdir.h> |
35 | #include <qregexp.h> | 35 | #include <qregexp.h> |
36 | 36 | ||
37 | #include <klocale.h> | 37 | #include <klocale.h> |
38 | #include <kdebug.h> | 38 | #include <kdebug.h> |
39 | #include <kiconloader.h> | 39 | #include <kiconloader.h> |
40 | #include <kglobal.h> | 40 | #include <kglobal.h> |
41 | 41 | ||
42 | #include <libkdepim/kpimglobalprefs.h> | 42 | #include <libkdepim/kpimglobalprefs.h> |
43 | #include <libkcal/calendar.h> | 43 | #include <libkcal/calendar.h> |
44 | #include <libkcal/calendarlocal.h> | 44 | #include <libkcal/calendarlocal.h> |
45 | #include <libkcal/icalformat.h> | 45 | #include <libkcal/icalformat.h> |
46 | #include <libkcal/vcalformat.h> | 46 | #include <libkcal/vcalformat.h> |
47 | #include <libkcal/recurrence.h> | 47 | #include <libkcal/recurrence.h> |
48 | #include <libkcal/filestorage.h> | 48 | #include <libkcal/filestorage.h> |
49 | #include <libkdepim/categoryselectdialog.h> | 49 | #include <libkdepim/categoryselectdialog.h> |
50 | #ifndef DESKTOP_VERSION | 50 | #ifndef DESKTOP_VERSION |
51 | #include <qpe/qpeapplication.h> | 51 | #include <qpe/qpeapplication.h> |
52 | #else | 52 | #else |
53 | #include <qapplication.h> | 53 | #include <qapplication.h> |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | #ifndef KORG_NOPRINTER | 56 | #ifndef KORG_NOPRINTER |
57 | #include "calprinter.h" | 57 | #include "calprinter.h" |
58 | #endif | 58 | #endif |
59 | #include "koglobals.h" | 59 | #include "koglobals.h" |
60 | #include "koprefs.h" | 60 | #include "koprefs.h" |
61 | #include "kfiledialog.h" | 61 | #include "kfiledialog.h" |
62 | 62 | ||
63 | #include "kolistview.h" | 63 | #include "kolistview.h" |
64 | 64 | ||
65 | ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) | 65 | ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) |
66 | { | 66 | { |
67 | mItem = item; | 67 | mItem = item; |
68 | mDate = date; | 68 | mDate = date; |
69 | } | 69 | } |
70 | 70 | ||
71 | ListItemVisitor::~ListItemVisitor() | 71 | ListItemVisitor::~ListItemVisitor() |
72 | { | 72 | { |
73 | } | 73 | } |
74 | 74 | ||
75 | bool ListItemVisitor::visit(Event *e) | 75 | bool ListItemVisitor::visit(Event *e) |
76 | { | 76 | { |
77 | 77 | ||
78 | bool ok = false; | 78 | bool ok = false; |
79 | QString start, end; | 79 | QString start, end; |
80 | if ( e->doesRecur() ) { | 80 | if ( e->doesRecur() ) { |
81 | QDate d = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); | 81 | QDate d = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); |
82 | if ( ok ) { | 82 | if ( ok ) { |
83 | int days = e->dtStart().date().daysTo(e->dtEnd().date() ); | 83 | int days = e->dtStart().date().daysTo(e->dtEnd().date() ); |
84 | start = KGlobal::locale()->formatDate(d,true); | 84 | start = KGlobal::locale()->formatDate(d,true); |
85 | end = KGlobal::locale()->formatDate(d.addDays( days),true); | 85 | end = KGlobal::locale()->formatDate(d.addDays( days),true); |
86 | } | 86 | } |
87 | 87 | ||
88 | } | 88 | } |
89 | if ( ! ok ) { | 89 | if ( ! ok ) { |
90 | start =e->dtStartDateStr(); | 90 | start =e->dtStartDateStr(); |
91 | end = e->dtEndDateStr(); | 91 | end = e->dtEndDateStr(); |
92 | } | 92 | } |
93 | mItem->setText(0,e->summary()); | 93 | mItem->setText(0,e->summary()); |
94 | mItem->setText(1,start); | 94 | mItem->setText(1,start); |
95 | mItem->setText(2,e->dtStartTimeStr()); | 95 | mItem->setText(2,e->dtStartTimeStr()); |
96 | mItem->setText(3,end); | 96 | mItem->setText(3,end); |
97 | mItem->setText(4,e->dtEndTimeStr()); | 97 | mItem->setText(4,e->dtEndTimeStr()); |
98 | mItem->setText(5,e->isAlarmEnabled() ? i18n("Yes") : i18n("No")); | 98 | mItem->setText(5,e->isAlarmEnabled() ? i18n("Yes") : i18n("No")); |
99 | mItem->setText(6, e->recurrence()->recurrenceText()); | 99 | mItem->setText(6, e->recurrence()->recurrenceText()); |
100 | mItem->setText(7,"---"); | 100 | mItem->setText(7,"---"); |
101 | mItem->setText(8,"---"); | 101 | mItem->setText(8,"---"); |
102 | mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); | 102 | mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); |
103 | mItem->setText(10,e->categoriesStr()); | 103 | mItem->setText(10,e->categoriesStr()); |
104 | 104 | ||
105 | QString key; | 105 | QString key; |
106 | QDate d = e->dtStart().date(); | 106 | QDate d = e->dtStart().date(); |
107 | QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); | 107 | QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); |
108 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute()); | 108 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute()); |
109 | mItem->setSortKey(1,key); | 109 | mItem->setSortKey(1,key); |
110 | 110 | ||
111 | d = e->dtEnd().date(); | 111 | d = e->dtEnd().date(); |
112 | t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); | 112 | t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); |
113 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute()); | 113 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute()); |
114 | mItem->setSortKey(3,key); | 114 | mItem->setSortKey(3,key); |
115 | 115 | ||
116 | return true; | 116 | return true; |
117 | } | 117 | } |
118 | 118 | ||
119 | bool ListItemVisitor::visit(Todo *t) | 119 | bool ListItemVisitor::visit(Todo *t) |
120 | { | 120 | { |
121 | mItem->setText(0,i18n("To-Do: %1").arg(t->summary())); | 121 | mItem->setText(0,i18n("To-Do: %1").arg(t->summary())); |
122 | if (t->hasStartDate()) { | 122 | if (t->hasStartDate()) { |
123 | mItem->setText(1,t->dtStartDateStr()); | 123 | mItem->setText(1,t->dtStartDateStr()); |
124 | if (t->doesFloat()) { | 124 | if (t->doesFloat()) { |
125 | mItem->setText(2,"---"); | 125 | mItem->setText(2,"---"); |
126 | } else { | 126 | } else { |
127 | mItem->setText(2,t->dtStartTimeStr()); | 127 | mItem->setText(2,t->dtStartTimeStr()); |
128 | } | 128 | } |
129 | } else { | 129 | } else { |
130 | mItem->setText(1,"---"); | 130 | mItem->setText(1,"---"); |
131 | mItem->setText(2,"---"); | 131 | mItem->setText(2,"---"); |
132 | } | 132 | } |
133 | mItem->setText(3,"---"); | 133 | mItem->setText(3,"---"); |
134 | mItem->setText(4,"---"); | 134 | mItem->setText(4,"---"); |
135 | mItem->setText(5,"---"); | 135 | mItem->setText(5,"---"); |
136 | mItem->setText(6,"---"); | 136 | mItem->setText(6,"---"); |
137 | if (t->hasDueDate()) { | 137 | if (t->hasDueDate()) { |
138 | mItem->setText(7,t->dtDueDateStr()); | 138 | mItem->setText(7,t->dtDueDateStr()); |
139 | if (t->doesFloat()) { | 139 | if (t->doesFloat()) { |
140 | mItem->setText(8,"---"); | 140 | mItem->setText(8,"---"); |
141 | } else { | 141 | } else { |
142 | mItem->setText(8,t->dtDueTimeStr()); | 142 | mItem->setText(8,t->dtDueTimeStr()); |
143 | } | 143 | } |
144 | } else { | 144 | } else { |
145 | mItem->setText(7,"---"); | 145 | mItem->setText(7,"---"); |
146 | mItem->setText(8,"---"); | 146 | mItem->setText(8,"---"); |
147 | } | 147 | } |
148 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); | 148 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); |
149 | mItem->setText(10,t->categoriesStr()); | 149 | mItem->setText(10,t->categoriesStr()); |
150 | 150 | ||
151 | QString key; | 151 | QString key; |
152 | QDate d; | 152 | QDate d; |
153 | if (t->hasDueDate()) { | 153 | if (t->hasDueDate()) { |
154 | d = t->dtDue().date(); | 154 | d = t->dtDue().date(); |
155 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); | 155 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); |
156 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); | 156 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
157 | mItem->setSortKey(7,key); | 157 | mItem->setSortKey(7,key); |
158 | } | 158 | } |
159 | if ( t->hasStartDate() ) { | 159 | if ( t->hasStartDate() ) { |
160 | d = t->dtStart().date(); | 160 | d = t->dtStart().date(); |
161 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); | 161 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); |
162 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); | 162 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
163 | mItem->setSortKey(1,key); | 163 | mItem->setSortKey(1,key); |
164 | } | 164 | } |
165 | return true; | 165 | return true; |
166 | } | 166 | } |
167 | 167 | ||
168 | bool ListItemVisitor::visit(Journal * j) | 168 | bool ListItemVisitor::visit(Journal * j) |
169 | { | 169 | { |
170 | QString des = j->description().left(50); | 170 | QString des = j->description().left(50); |
171 | des = des.simplifyWhiteSpace (); | 171 | des = des.simplifyWhiteSpace (); |
172 | des.replace (QRegExp ("\\n"),"" ); | 172 | des.replace (QRegExp ("\\n"),"" ); |
173 | des.replace (QRegExp ("\\r"),"" ); | 173 | des.replace (QRegExp ("\\r"),"" ); |
174 | mItem->setText(0,i18n("Journal")+": "+des.left(25)); | 174 | mItem->setText(0,i18n("Journal")+": "+des.left(25)); |
175 | mItem->setText(1,j->dtStartDateStr()); | 175 | mItem->setText(1,j->dtStartDateStr()); |
176 | mItem->setText(2,"---"); | 176 | mItem->setText(2,"---"); |
177 | mItem->setText(3,"---"); | 177 | mItem->setText(3,"---"); |
178 | mItem->setText(4,"---"); | 178 | mItem->setText(4,"---"); |
179 | mItem->setText(5,"---"); | 179 | mItem->setText(5,"---"); |
180 | mItem->setText(6,"---"); | 180 | mItem->setText(6,"---"); |
181 | mItem->setText(7,j->dtStartDateStr()); | 181 | mItem->setText(7,j->dtStartDateStr()); |
182 | mItem->setText(8,"---"); | 182 | mItem->setText(8,"---"); |
183 | mItem->setText(9,"---"); | 183 | mItem->setText(9,"---"); |
184 | mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); | 184 | mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); |
185 | 185 | ||
186 | QString key; | 186 | QString key; |
187 | QDate d = j->dtStart().date(); | 187 | QDate d = j->dtStart().date(); |
188 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 188 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
189 | mItem->setSortKey(1,key); | 189 | mItem->setSortKey(1,key); |
190 | mItem->setSortKey(7,key); | 190 | mItem->setSortKey(7,key); |
191 | 191 | ||
192 | return true; | 192 | return true; |
193 | } | 193 | } |
194 | 194 | ||
195 | KOListView::KOListView(Calendar *calendar, QWidget *parent, | 195 | KOListView::KOListView(Calendar *calendar, QWidget *parent, |
196 | const char *name) | 196 | const char *name) |
197 | : KOEventView(calendar, parent, name) | 197 | : KOEventView(calendar, parent, name) |
198 | { | 198 | { |
199 | mActiveItem = 0; | 199 | mActiveItem = 0; |
200 | mListView = new KOListViewListView(this); | 200 | mListView = new KOListViewListView(this); |
201 | mListView->addColumn(i18n("Summary")); | 201 | mListView->addColumn(i18n("Summary")); |
202 | mListView->addColumn(i18n("Start Date")); | 202 | mListView->addColumn(i18n("Start Date")); |
203 | mListView->addColumn(i18n("Start Time")); | 203 | mListView->addColumn(i18n("Start Time")); |
204 | mListView->addColumn(i18n("End Date")); | 204 | mListView->addColumn(i18n("End Date")); |
205 | mListView->addColumn(i18n("End Time")); | 205 | mListView->addColumn(i18n("End Time")); |
206 | mListView->addColumn(i18n("Alarm")); // alarm set? | 206 | mListView->addColumn(i18n("Alarm")); // alarm set? |
207 | mListView->addColumn(i18n("Recurs")); // recurs? | 207 | mListView->addColumn(i18n("Recurs")); // recurs? |
208 | mListView->addColumn(i18n("Due Date")); | 208 | mListView->addColumn(i18n("Due Date")); |
209 | mListView->addColumn(i18n("Due Time")); | 209 | mListView->addColumn(i18n("Due Time")); |
210 | mListView->addColumn(i18n("Cancelled")); | 210 | mListView->addColumn(i18n("Cancelled")); |
211 | mListView->addColumn(i18n("Categories")); | 211 | mListView->addColumn(i18n("Categories")); |
212 | 212 | ||
213 | mListView->setColumnAlignment(0,AlignLeft); | 213 | mListView->setColumnAlignment(0,AlignLeft); |
214 | mListView->setColumnAlignment(1,AlignLeft); | 214 | mListView->setColumnAlignment(1,AlignLeft); |
215 | mListView->setColumnAlignment(2,AlignHCenter); | 215 | mListView->setColumnAlignment(2,AlignHCenter); |
216 | mListView->setColumnAlignment(3,AlignLeft); | 216 | mListView->setColumnAlignment(3,AlignLeft); |
217 | mListView->setColumnAlignment(4,AlignHCenter); | 217 | mListView->setColumnAlignment(4,AlignHCenter); |
218 | mListView->setColumnAlignment(5,AlignLeft); | 218 | mListView->setColumnAlignment(5,AlignLeft); |
219 | mListView->setColumnAlignment(6,AlignLeft); | 219 | mListView->setColumnAlignment(6,AlignLeft); |
220 | mListView->setColumnAlignment(7,AlignLeft); | 220 | mListView->setColumnAlignment(7,AlignLeft); |
221 | mListView->setColumnAlignment(8,AlignLeft); | 221 | mListView->setColumnAlignment(8,AlignLeft); |
222 | mListView->setColumnAlignment(9,AlignLeft); | 222 | mListView->setColumnAlignment(9,AlignLeft); |
223 | mListView->setColumnAlignment(10,AlignLeft); | 223 | mListView->setColumnAlignment(10,AlignLeft); |
224 | 224 | ||
225 | int iii = 0; | 225 | int iii = 0; |
226 | for ( iii = 0; iii< 10 ; ++iii ) | 226 | for ( iii = 0; iii< 10 ; ++iii ) |
227 | mListView->setColumnWidthMode( iii, QListView::Manual ); | 227 | mListView->setColumnWidthMode( iii, QListView::Manual ); |
228 | 228 | ||
229 | QBoxLayout *layoutTop = new QVBoxLayout(this); | 229 | QBoxLayout *layoutTop = new QVBoxLayout(this); |
230 | layoutTop->addWidget(mListView); | 230 | layoutTop->addWidget(mListView); |
231 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 231 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
232 | mPopupMenu = eventPopup(); | 232 | mPopupMenu = eventPopup(); |
233 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 233 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
234 | i18n("Select all"),this, | 234 | i18n("Select all"),this, |
235 | SLOT(allSelection()),true); | 235 | SLOT(allSelection()),true); |
236 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 236 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
237 | i18n("Deselect All"),this, | 237 | i18n("Deselect All"),this, |
238 | SLOT(clearSelection()),true); | 238 | SLOT(clearSelection()),true); |
239 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 239 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
240 | i18n("Delete all selected"),this, | 240 | i18n("Delete all selected"),this, |
241 | SLOT(deleteAll()),true); | 241 | SLOT(deleteAll()),true); |
242 | mPopupMenu->insertSeparator(); | 242 | mPopupMenu->insertSeparator(); |
243 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 243 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
244 | i18n("Save selected to file..."),this, | 244 | i18n("Save selected to file..."),this, |
245 | SLOT(saveToFile()),true); | 245 | SLOT(saveToFile()),true); |
246 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 246 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
247 | i18n("Save Journal/Description..."),this, | 247 | i18n("Save Journal/Description..."),this, |
248 | SLOT(saveDescriptionToFile()),true); | 248 | SLOT(saveDescriptionToFile()),true); |
249 | mPopupMenu->insertSeparator(); | 249 | mPopupMenu->insertSeparator(); |
250 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 250 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
251 | i18n("Add Categ. to selected..."),this, | 251 | i18n("Add Categ. to selected..."),this, |
252 | SLOT(addCat()),true); | 252 | SLOT(addCat()),true); |
253 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 253 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
254 | i18n("Set Categ. for selected..."),this, | 254 | i18n("Set Categ. for selected..."),this, |
255 | SLOT(setCat()),true); | 255 | SLOT(setCat()),true); |
256 | mPopupMenu->insertSeparator(); | 256 | mPopupMenu->insertSeparator(); |
257 | 257 | ||
258 | 258 | ||
259 | #ifndef DESKTOP_VERSION | 259 | #ifndef DESKTOP_VERSION |
260 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 260 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
261 | i18n("Beam selected via IR"),this, | 261 | i18n("Beam selected via IR"),this, |
262 | SLOT(beamSelected()),true); | 262 | SLOT(beamSelected()),true); |
263 | #endif | 263 | #endif |
264 | /* | 264 | /* |
265 | mPopupMenu = new QPopupMenu; | 265 | mPopupMenu = new QPopupMenu; |
266 | mPopupMenu->insertItem(i18n("Edit Event"), this, | 266 | mPopupMenu->insertItem(i18n("Edit Event"), this, |
267 | SLOT (editEvent())); | 267 | SLOT (editEvent())); |
268 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, | 268 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, |
269 | SLOT (deleteEvent())); | 269 | SLOT (deleteEvent())); |
270 | mPopupMenu->insertSeparator(); | 270 | mPopupMenu->insertSeparator(); |
271 | mPopupMenu->insertItem(i18n("Show Dates"), this, | 271 | mPopupMenu->insertItem(i18n("Show Dates"), this, |
272 | SLOT(showDates())); | 272 | SLOT(showDates())); |
273 | mPopupMenu->insertItem(i18n("Hide Dates"), this, | 273 | mPopupMenu->insertItem(i18n("Hide Dates"), this, |
274 | SLOT(hideDates())); | 274 | SLOT(hideDates())); |
275 | */ | 275 | */ |
276 | QObject::connect(mListView,SIGNAL( newEvent()), | 276 | QObject::connect(mListView,SIGNAL( newEvent()), |
277 | this,SIGNAL(signalNewEvent())); | 277 | this,SIGNAL(signalNewEvent())); |
278 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), | 278 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), |
279 | this,SLOT(defaultItemAction(QListViewItem *))); | 279 | this,SLOT(defaultItemAction(QListViewItem *))); |
280 | QObject::connect(mListView,SIGNAL(rightButtonClicked ( QListViewItem *, | 280 | QObject::connect(mListView,SIGNAL(rightButtonClicked ( QListViewItem *, |
281 | const QPoint &, int )), | 281 | const QPoint &, int )), |
282 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); | 282 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); |
283 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), | 283 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), |
284 | SLOT(processSelectionChange(QListViewItem *))); | 284 | SLOT(processSelectionChange(QListViewItem *))); |
285 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), | 285 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), |
286 | SIGNAL(showIncidenceSignal(Incidence *)) ); | 286 | SIGNAL(showIncidenceSignal(Incidence *)) ); |
287 | 287 | ||
288 | readSettings(KOGlobals::config(),"KOListView Layout"); | 288 | readSettings(KOGlobals::config(),"KOListView Layout"); |
289 | } | 289 | } |
290 | 290 | ||
291 | KOListView::~KOListView() | 291 | KOListView::~KOListView() |
292 | { | 292 | { |
293 | delete mPopupMenu; | 293 | delete mPopupMenu; |
294 | } | 294 | } |
295 | 295 | ||
296 | void KOListView::updateList() | 296 | void KOListView::updateList() |
297 | { | 297 | { |
298 | // qDebug(" KOListView::updateList() "); | 298 | // qDebug(" KOListView::updateList() "); |
299 | 299 | ||
300 | } | 300 | } |
301 | 301 | ||
302 | void KOListView::addCat( ) | 302 | void KOListView::addCat( ) |
303 | { | 303 | { |
304 | setCategories( false ); | 304 | setCategories( false ); |
305 | } | 305 | } |
306 | void KOListView::setCat() | 306 | void KOListView::setCat() |
307 | { | 307 | { |
308 | setCategories( true ); | 308 | setCategories( true ); |
309 | } | 309 | } |
310 | void KOListView::setCategories( bool removeOld ) | 310 | void KOListView::setCategories( bool removeOld ) |
311 | { | 311 | { |
312 | 312 | ||
313 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); | 313 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); |
314 | if (! csd->exec()) { | 314 | if (! csd->exec()) { |
315 | delete csd; | 315 | delete csd; |
316 | return; | 316 | return; |
317 | } | 317 | } |
318 | QStringList catList = csd->selectedCategories(); | 318 | QStringList catList = csd->selectedCategories(); |
319 | delete csd; | 319 | delete csd; |
320 | // if ( catList.count() == 0 ) | 320 | // if ( catList.count() == 0 ) |
321 | // return; | 321 | // return; |
322 | catList.sort(); | 322 | catList.sort(); |
323 | QString categoriesStr = catList.join(","); | 323 | QString categoriesStr = catList.join(","); |
324 | int i; | 324 | int i; |
325 | QStringList itemList; | 325 | QStringList itemList; |
326 | QPtrList<KOListViewItem> sel ; | 326 | QPtrList<KOListViewItem> sel ; |
327 | QListViewItem *qitem = mListView->firstChild (); | 327 | QListViewItem *qitem = mListView->firstChild (); |
328 | while ( qitem ) { | 328 | while ( qitem ) { |
329 | if ( qitem->isSelected() ) { | 329 | if ( qitem->isSelected() ) { |
330 | sel.append(((KOListViewItem *)qitem)); | 330 | sel.append(((KOListViewItem *)qitem)); |
331 | } | 331 | } |
332 | qitem = qitem->nextSibling(); | 332 | qitem = qitem->nextSibling(); |
333 | } | 333 | } |
334 | KOListViewItem * item, *temp; | 334 | KOListViewItem * item, *temp; |
335 | item = sel.first(); | 335 | item = sel.first(); |
336 | Incidence* inc; | 336 | Incidence* inc; |
337 | while ( item ) { | 337 | while ( item ) { |
338 | inc = item->data(); | 338 | inc = item->data(); |
339 | if ( removeOld ) { | 339 | if ( removeOld ) { |
340 | inc->setCategories( categoriesStr ); | 340 | inc->setCategories( categoriesStr ); |
341 | } else { | 341 | } else { |
342 | itemList = QStringList::split (",", inc->categoriesStr() ); | 342 | itemList = QStringList::split (",", inc->categoriesStr() ); |
343 | for( i = 0; i< catList.count(); ++i ) { | 343 | for( i = 0; i< catList.count(); ++i ) { |
344 | if ( !itemList.contains (catList[i])) | 344 | if ( !itemList.contains (catList[i])) |
345 | itemList.append( catList[i] ); | 345 | itemList.append( catList[i] ); |
346 | } | 346 | } |
347 | itemList.sort(); | 347 | itemList.sort(); |
348 | inc->setCategories( itemList.join(",") ); | 348 | inc->setCategories( itemList.join(",") ); |
349 | } | 349 | } |
350 | temp = item; | 350 | temp = item; |
351 | item = sel.next(); | 351 | item = sel.next(); |
352 | mUidDict.remove( inc->uid() ); | 352 | mUidDict.remove( inc->uid() ); |
353 | delete temp;; | 353 | delete temp;; |
354 | addIncidence( inc ); | 354 | addIncidence( inc ); |
355 | } | 355 | } |
356 | } | 356 | } |
357 | 357 | ||
358 | void KOListView::beamSelected() | 358 | void KOListView::beamSelected() |
359 | { | 359 | { |
360 | int icount = 0; | 360 | int icount = 0; |
361 | QPtrList<Incidence> delSel ; | 361 | QPtrList<Incidence> delSel ; |
362 | QListViewItem *item = mListView->firstChild (); | 362 | QListViewItem *item = mListView->firstChild (); |
363 | while ( item ) { | 363 | while ( item ) { |
364 | if ( item->isSelected() ) { | 364 | if ( item->isSelected() ) { |
365 | delSel.append(((KOListViewItem *)item)->data()); | 365 | delSel.append(((KOListViewItem *)item)->data()); |
366 | ++icount; | 366 | ++icount; |
367 | } | 367 | } |
368 | 368 | ||
369 | item = item->nextSibling(); | 369 | item = item->nextSibling(); |
370 | } | 370 | } |
371 | if ( icount ) { | 371 | if ( icount ) { |
372 | emit beamIncidenceList( delSel ); | 372 | emit beamIncidenceList( delSel ); |
373 | return; | 373 | return; |
374 | QString fn ; | 374 | QString fn ; |
375 | fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; | 375 | fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; |
376 | QString mes; | 376 | QString mes; |
377 | bool createbup = true; | 377 | bool createbup = true; |
378 | if ( createbup ) { | 378 | if ( createbup ) { |
379 | QString description = "\n"; | 379 | QString description = "\n"; |
380 | CalendarLocal* cal = new CalendarLocal(); | 380 | CalendarLocal* cal = new CalendarLocal(); |
381 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 381 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
382 | Incidence *incidence = delSel.first(); | 382 | Incidence *incidence = delSel.first(); |
383 | while ( incidence ) { | 383 | while ( incidence ) { |
384 | Incidence *in = incidence->clone(); | 384 | Incidence *in = incidence->clone(); |
385 | description += in->summary() + "\n"; | 385 | description += in->summary() + "\n"; |
386 | cal->addIncidence( in ); | 386 | cal->addIncidence( in ); |
387 | incidence = delSel.next(); | 387 | incidence = delSel.next(); |
388 | } | 388 | } |
389 | FileStorage storage( cal, fn, new VCalFormat ); | 389 | FileStorage storage( cal, fn, new VCalFormat ); |
390 | storage.save(); | 390 | storage.save(); |
391 | delete cal; | 391 | delete cal; |
392 | mes = i18n("KO/Pi: Ready for beaming"); | 392 | mes = i18n("KO/Pi: Ready for beaming"); |
393 | topLevelWidget()->setCaption(mes); | 393 | topLevelWidget()->setCaption(mes); |
394 | 394 | ||
395 | #ifndef DESKTOP_VERSION | 395 | #ifndef DESKTOP_VERSION |
396 | Ir *ir = new Ir( this ); | 396 | Ir *ir = new Ir( this ); |
397 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 397 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
398 | ir->send( fn, description, "text/x-vCalendar" ); | 398 | ir->send( fn, description, "text/x-vCalendar" ); |
399 | #endif | 399 | #endif |
400 | } | 400 | } |
401 | } | 401 | } |
402 | } | 402 | } |
403 | void KOListView::beamDone( Ir *ir ) | 403 | void KOListView::beamDone( Ir *ir ) |
404 | { | 404 | { |
405 | #ifndef DESKTOP_VERSION | 405 | #ifndef DESKTOP_VERSION |
406 | delete ir; | 406 | delete ir; |
407 | #endif | 407 | #endif |
408 | topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); | 408 | topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); |
409 | } | 409 | } |
410 | 410 | ||
411 | void KOListView::saveDescriptionToFile() | 411 | void KOListView::saveDescriptionToFile() |
412 | { | 412 | { |
413 | 413 | ||
414 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 414 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
415 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), | 415 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), |
416 | i18n("Continue"), i18n("Cancel"), 0, | 416 | i18n("Continue"), i18n("Cancel"), 0, |
417 | 0, 1 ); | 417 | 0, 1 ); |
418 | if ( result != 0 ) { | 418 | if ( result != 0 ) { |
419 | return; | 419 | return; |
420 | } | 420 | } |
421 | int icount = 0; | 421 | int icount = 0; |
422 | QPtrList<Incidence> delSel ; | 422 | QPtrList<Incidence> delSel ; |
423 | QListViewItem *item = mListView->firstChild (); | 423 | QListViewItem *item = mListView->firstChild (); |
424 | while ( item ) { | 424 | while ( item ) { |
425 | if ( item->isSelected() ) { | 425 | if ( item->isSelected() ) { |
426 | delSel.append(((KOListViewItem *)item)->data()); | 426 | delSel.append(((KOListViewItem *)item)->data()); |
427 | ++icount; | 427 | ++icount; |
428 | } | 428 | } |
429 | 429 | ||
430 | item = item->nextSibling(); | 430 | item = item->nextSibling(); |
431 | } | 431 | } |
432 | if ( icount ) { | 432 | if ( icount ) { |
433 | QString fn = KOPrefs::instance()->mLastSaveFile; | 433 | QString fn = KOPrefs::instance()->mLastSaveFile; |
434 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 434 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
435 | 435 | ||
436 | if ( fn == "" ) | 436 | if ( fn == "" ) |
437 | return; | 437 | return; |
438 | QFileInfo info; | 438 | QFileInfo info; |
439 | info.setFile( fn ); | 439 | info.setFile( fn ); |
440 | QString mes; | 440 | QString mes; |
441 | bool createbup = true; | 441 | bool createbup = true; |
442 | if ( info. exists() ) { | 442 | if ( info. exists() ) { |
443 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 443 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
444 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 444 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
445 | i18n("Overwrite!"), i18n("Cancel"), 0, | 445 | i18n("Overwrite!"), i18n("Cancel"), 0, |
446 | 0, 1 ); | 446 | 0, 1 ); |
447 | if ( result != 0 ) { | 447 | if ( result != 0 ) { |
448 | createbup = false; | 448 | createbup = false; |
449 | } | 449 | } |
450 | } | 450 | } |
451 | if ( createbup ) { | 451 | if ( createbup ) { |
452 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + | 452 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + |
453 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); | 453 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); |
454 | Incidence *incidence = delSel.first(); | 454 | Incidence *incidence = delSel.first(); |
455 | icount = 0; | 455 | icount = 0; |
456 | while ( incidence ) { | 456 | while ( incidence ) { |
457 | if ( incidence->type() == "Journal" ) { | 457 | if ( incidence->type() == "Journal" ) { |
458 | text += "\n************************************\n"; | 458 | text += "\n************************************\n"; |
459 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); | 459 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); |
460 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); | 460 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); |
461 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); | 461 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); |
462 | ++icount; | 462 | ++icount; |
463 | 463 | ||
464 | } else { | 464 | } else { |
465 | if ( !incidence->description().isEmpty() ) { | 465 | if ( !incidence->description().isEmpty() ) { |
466 | text += "\n************************************\n"; | 466 | text += "\n************************************\n"; |
467 | if ( incidence->type() == "Todo" ) | 467 | if ( incidence->type() == "Todo" ) |
468 | text += i18n("To-Do: "); | 468 | text += i18n("To-Do: "); |
469 | text += incidence->summary(); | 469 | text += incidence->summary(); |
470 | if ( incidence->hasStartDate() ) | 470 | if ( incidence->hasStartDate() ) |
471 | text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); | 471 | text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); |
472 | text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); | 472 | text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); |
473 | if ( !incidence->location().isEmpty() ) | 473 | if ( !incidence->location().isEmpty() ) |
474 | text += "\n" +i18n("Location: ") + incidence->location(); | 474 | text += "\n" +i18n("Location: ") + incidence->location(); |
475 | text += "\n" + i18n("Description: ") + "\n" + incidence->description(); | 475 | text += "\n" + i18n("Description: ") + "\n" + incidence->description(); |
476 | ++icount; | 476 | ++icount; |
477 | 477 | ||
478 | } | 478 | } |
479 | } | 479 | } |
480 | incidence = delSel.next(); | 480 | incidence = delSel.next(); |
481 | } | 481 | } |
482 | QFile file( fn ); | 482 | QFile file( fn ); |
483 | if (!file.open( IO_WriteOnly ) ) { | 483 | if (!file.open( IO_WriteOnly ) ) { |
484 | topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); | 484 | topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); |
485 | return; | 485 | return; |
486 | } | 486 | } |
487 | QTextStream ts( &file ); | 487 | QTextStream ts( &file ); |
488 | ts << text; | 488 | ts << text; |
489 | file.close(); | 489 | file.close(); |
490 | //qDebug("%s ", text.latin1()); | 490 | //qDebug("%s ", text.latin1()); |
491 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); | 491 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); |
492 | KOPrefs::instance()->mLastSaveFile = fn; | 492 | KOPrefs::instance()->mLastSaveFile = fn; |
493 | topLevelWidget()->setCaption(mes); | 493 | topLevelWidget()->setCaption(mes); |
494 | } | 494 | } |
495 | } | 495 | } |
496 | } | 496 | } |
497 | void KOListView::saveToFile() | 497 | void KOListView::saveToFile() |
498 | { | 498 | { |
499 | 499 | ||
500 | int icount = 0; | 500 | int icount = 0; |
501 | QPtrList<Incidence> delSel ; | 501 | QPtrList<Incidence> delSel ; |
502 | QListViewItem *item = mListView->firstChild (); | 502 | QListViewItem *item = mListView->firstChild (); |
503 | while ( item ) { | 503 | while ( item ) { |
504 | if ( item->isSelected() ) { | 504 | if ( item->isSelected() ) { |
505 | delSel.append(((KOListViewItem *)item)->data()); | 505 | delSel.append(((KOListViewItem *)item)->data()); |
506 | ++icount; | 506 | ++icount; |
507 | } | 507 | } |
508 | 508 | ||
509 | item = item->nextSibling(); | 509 | item = item->nextSibling(); |
510 | } | 510 | } |
511 | if ( icount ) { | 511 | if ( icount ) { |
512 | QString fn = KOPrefs::instance()->mLastSaveFile; | 512 | QString fn = KOPrefs::instance()->mLastSaveFile; |
513 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 513 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
514 | 514 | ||
515 | if ( fn == "" ) | 515 | if ( fn == "" ) |
516 | return; | 516 | return; |
517 | QFileInfo info; | 517 | QFileInfo info; |
518 | info.setFile( fn ); | 518 | info.setFile( fn ); |
519 | QString mes; | 519 | QString mes; |
520 | bool createbup = true; | 520 | bool createbup = true; |
521 | if ( info. exists() ) { | 521 | if ( info. exists() ) { |
522 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 522 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
523 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 523 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
524 | i18n("Overwrite!"), i18n("Cancel"), 0, | 524 | i18n("Overwrite!"), i18n("Cancel"), 0, |
525 | 0, 1 ); | 525 | 0, 1 ); |
526 | if ( result != 0 ) { | 526 | if ( result != 0 ) { |
527 | createbup = false; | 527 | createbup = false; |
528 | } | 528 | } |
529 | } | 529 | } |
530 | if ( createbup ) { | 530 | if ( createbup ) { |
531 | CalendarLocal cal; | 531 | CalendarLocal cal; |
532 | cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 532 | cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
533 | Incidence *incidence = delSel.first(); | 533 | Incidence *incidence = delSel.first(); |
534 | while ( incidence ) { | 534 | while ( incidence ) { |
535 | cal.addIncidence( incidence->clone() ); | 535 | cal.addIncidence( incidence->clone() ); |
536 | incidence = delSel.next(); | 536 | incidence = delSel.next(); |
537 | } | 537 | } |
538 | ICalFormat format; | 538 | ICalFormat format; |
539 | format.save( &cal, fn ); | 539 | format.save( &cal, fn ); |
540 | mes = i18n("KO/Pi:Saved %1").arg(fn ); | 540 | mes = i18n("KO/Pi:Saved %1").arg(fn ); |
541 | KOPrefs::instance()->mLastSaveFile = fn; | 541 | KOPrefs::instance()->mLastSaveFile = fn; |
542 | topLevelWidget()->setCaption(mes); | 542 | topLevelWidget()->setCaption(mes); |
543 | } | 543 | } |
544 | } | 544 | } |
545 | } | 545 | } |
546 | void KOListView::deleteAll() | 546 | void KOListView::deleteAll() |
547 | { | 547 | { |
548 | int icount = 0; | 548 | int icount = 0; |
549 | QPtrList<Incidence> delSel ; | 549 | QPtrList<Incidence> delSel ; |
550 | QListViewItem *item = mListView->firstChild (); | 550 | QListViewItem *item = mListView->firstChild (); |
551 | while ( item ) { | 551 | while ( item ) { |
552 | if ( item->isSelected() ) { | 552 | if ( item->isSelected() ) { |
553 | delSel.append(((KOListViewItem *)item)->data()); | 553 | delSel.append(((KOListViewItem *)item)->data()); |
554 | ++icount; | 554 | ++icount; |
555 | } | 555 | } |
556 | 556 | ||
557 | item = item->nextSibling(); | 557 | item = item->nextSibling(); |
558 | } | 558 | } |
559 | if ( icount ) { | 559 | if ( icount ) { |
560 | Incidence *incidence = delSel.first(); | 560 | Incidence *incidence = delSel.first(); |
561 | Incidence *toDelete; | 561 | Incidence *toDelete; |
562 | KOPrefs *p = KOPrefs::instance(); | 562 | KOPrefs *p = KOPrefs::instance(); |
563 | bool confirm = p->mConfirm; | 563 | bool confirm = p->mConfirm; |
564 | QString mess; | 564 | QString mess; |
565 | mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); | 565 | mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); |
566 | if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { | 566 | if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { |
567 | p->mConfirm = false; | 567 | p->mConfirm = false; |
568 | int delCounter = 0; | 568 | int delCounter = 0; |
569 | QDialog dia ( this, "p-dialog", true ); | 569 | QDialog dia ( this, "p-dialog", true ); |
570 | QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); | 570 | QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); |
571 | QVBoxLayout lay( &dia ); | 571 | QVBoxLayout lay( &dia ); |
572 | lay.setMargin(7); | 572 | lay.setMargin(7); |
573 | lay.setSpacing(7); | 573 | lay.setSpacing(7); |
574 | lay.addWidget( &lab); | 574 | lay.addWidget( &lab); |
575 | QProgressBar bar( icount, &dia ); | 575 | QProgressBar bar( icount, &dia ); |
576 | lay.addWidget( &bar); | 576 | lay.addWidget( &bar); |
577 | int w = 220; | 577 | int w = 220; |
578 | int h = 50; | 578 | int h = 50; |
579 | int dw = QApplication::desktop()->width(); | 579 | int dw = QApplication::desktop()->width(); |
580 | int dh = QApplication::desktop()->height(); | 580 | int dh = QApplication::desktop()->height(); |
581 | dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 581 | dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
582 | //dia.resize( 240,50 ); | 582 | //dia.resize( 240,50 ); |
583 | dia.show(); | 583 | dia.show(); |
584 | 584 | ||
585 | while ( incidence ) { | 585 | while ( incidence ) { |
586 | bar.setProgress( delCounter ); | 586 | bar.setProgress( delCounter ); |
587 | mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); | 587 | mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); |
588 | dia.setCaption( mess ); | 588 | dia.setCaption( mess ); |
589 | qApp->processEvents(); | 589 | qApp->processEvents(); |
590 | toDelete = (incidence); | 590 | toDelete = (incidence); |
591 | incidence = delSel.next(); | 591 | incidence = delSel.next(); |
592 | emit deleteIncidenceSignal(toDelete ); | 592 | emit deleteIncidenceSignal(toDelete ); |
593 | if ( dia.result() != 0 ) | 593 | if ( dia.result() != 0 ) |
594 | break; | 594 | break; |
595 | 595 | ||
596 | } | 596 | } |
597 | mess = mess.sprintf( i18n("%d items remaining in list."), count() ); | 597 | mess = mess.sprintf( i18n("%d items remaining in list."), count() ); |
598 | topLevelWidget ()->setCaption( mess ); | 598 | topLevelWidget ()->setCaption( mess ); |
599 | p->mConfirm = confirm; | 599 | p->mConfirm = confirm; |
600 | } | 600 | } |
601 | } | 601 | } |
602 | 602 | ||
603 | 603 | ||
604 | } | 604 | } |
605 | int KOListView::maxDatesHint() | 605 | int KOListView::maxDatesHint() |
606 | { | 606 | { |
607 | return 0; | 607 | return 0; |
608 | } | 608 | } |
609 | 609 | ||
610 | int KOListView::currentDateCount() | 610 | int KOListView::currentDateCount() |
611 | { | 611 | { |
612 | return 0; | 612 | return 0; |
613 | } | 613 | } |
614 | 614 | ||
615 | QPtrList<Incidence> KOListView::selectedIncidences() | 615 | QPtrList<Incidence> KOListView::selectedIncidences() |
616 | { | 616 | { |
617 | QPtrList<Incidence> eventList; | 617 | QPtrList<Incidence> eventList; |
618 | QListViewItem *item = mListView->firstChild (); | 618 | QListViewItem *item = mListView->firstChild (); |
619 | while ( item ) { | 619 | while ( item ) { |
620 | if ( item->isSelected() ) { | 620 | if ( item->isSelected() ) { |
621 | eventList.append(((KOListViewItem *)item)->data()); | 621 | eventList.append(((KOListViewItem *)item)->data()); |
622 | } | 622 | } |
623 | 623 | ||
624 | item = item->nextSibling(); | 624 | item = item->nextSibling(); |
625 | } | 625 | } |
626 | 626 | ||
627 | // // QListViewItem *item = mListView->selectedItem(); | 627 | // // QListViewItem *item = mListView->selectedItem(); |
628 | //if (item) eventList.append(((KOListViewItem *)item)->data()); | 628 | //if (item) eventList.append(((KOListViewItem *)item)->data()); |
629 | 629 | ||
630 | return eventList; | 630 | return eventList; |
631 | } | 631 | } |
632 | 632 | ||
633 | DateList KOListView::selectedDates() | 633 | DateList KOListView::selectedDates() |
634 | { | 634 | { |
635 | DateList eventList; | 635 | DateList eventList; |
636 | return eventList; | 636 | return eventList; |
637 | } | 637 | } |
638 | 638 | ||
639 | void KOListView::showDates(bool show) | 639 | void KOListView::showDates(bool show) |
640 | { | 640 | { |
641 | // Shouldn't we set it to a value greater 0? When showDates is called with | 641 | // Shouldn't we set it to a value greater 0? When showDates is called with |
642 | // show == true at first, then the columnwidths are set to zero. | 642 | // show == true at first, then the columnwidths are set to zero. |
643 | static int oldColWidth1 = 0; | 643 | static int oldColWidth1 = 0; |
644 | static int oldColWidth3 = 0; | 644 | static int oldColWidth3 = 0; |
645 | 645 | ||
646 | if (!show) { | 646 | if (!show) { |
647 | oldColWidth1 = mListView->columnWidth(1); | 647 | oldColWidth1 = mListView->columnWidth(1); |
648 | oldColWidth3 = mListView->columnWidth(3); | 648 | oldColWidth3 = mListView->columnWidth(3); |
649 | mListView->setColumnWidth(1, 0); | 649 | mListView->setColumnWidth(1, 0); |
650 | mListView->setColumnWidth(3, 0); | 650 | mListView->setColumnWidth(3, 0); |
651 | } else { | 651 | } else { |
652 | mListView->setColumnWidth(1, oldColWidth1); | 652 | mListView->setColumnWidth(1, oldColWidth1); |
653 | mListView->setColumnWidth(3, oldColWidth3); | 653 | mListView->setColumnWidth(3, oldColWidth3); |
654 | } | 654 | } |
655 | mListView->repaint(); | 655 | mListView->repaint(); |
656 | } | 656 | } |
657 | 657 | ||
658 | void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 658 | void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
659 | const QDate &td) | 659 | const QDate &td) |
660 | { | 660 | { |
661 | #ifndef KORG_NOPRINTER | 661 | #ifndef KORG_NOPRINTER |
662 | calPrinter->preview(CalPrinter::Day, fd, td); | 662 | calPrinter->preview(CalPrinter::Day, fd, td); |
663 | #endif | 663 | #endif |
664 | } | 664 | } |
665 | 665 | ||
666 | void KOListView::showDates() | 666 | void KOListView::showDates() |
667 | { | 667 | { |
668 | showDates(true); | 668 | showDates(true); |
669 | } | 669 | } |
670 | 670 | ||
671 | void KOListView::hideDates() | 671 | void KOListView::hideDates() |
672 | { | 672 | { |
673 | showDates(false); | 673 | showDates(false); |
674 | } | 674 | } |
675 | 675 | ||
676 | void KOListView::updateView() | 676 | void KOListView::updateView() |
677 | { | 677 | { |
678 | mListView->setFocus(); | 678 | mListView->setFocus(); |
679 | if ( mListView->firstChild () ) | 679 | if ( mListView->firstChild () ) |
680 | mListView->setCurrentItem( mListView->firstChild () ); | 680 | mListView->setCurrentItem( mListView->firstChild () ); |
681 | } | 681 | } |
682 | void KOListView::updateConfig() | 682 | void KOListView::updateConfig() |
683 | { | 683 | { |
684 | 684 | ||
685 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 685 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
686 | updateView(); | 686 | updateView(); |
687 | 687 | ||
688 | } | 688 | } |
689 | void KOListView::setStartDate(const QDate &start) | 689 | void KOListView::setStartDate(const QDate &start) |
690 | { | 690 | { |
691 | mStartDate = start; | 691 | mStartDate = start; |
692 | } | 692 | } |
693 | 693 | ||
694 | void KOListView::showDates(const QDate &start, const QDate &end) | 694 | void KOListView::showDates(const QDate &start, const QDate &end) |
695 | { | 695 | { |
696 | clear(); | 696 | clear(); |
697 | mStartDate = start; | 697 | mStartDate = start; |
698 | QDate date = start; | 698 | QDate date = start; |
699 | QPtrList<Journal> j_list; | 699 | QPtrList<Journal> j_list; |
700 | while( date <= end ) { | 700 | while( date <= end ) { |
701 | addEvents(calendar()->events(date)); | 701 | addEvents(calendar()->events(date)); |
702 | addTodos(calendar()->todos(date)); | 702 | addTodos(calendar()->todos(date)); |
703 | Journal* jo = calendar()->journal(date); | 703 | Journal* jo = calendar()->journal(date); |
704 | if ( jo ) | 704 | if ( jo ) |
705 | j_list.append( jo ); | 705 | j_list.append( jo ); |
706 | date = date.addDays( 1 ); | 706 | date = date.addDays( 1 ); |
707 | } | 707 | } |
708 | addJournals(j_list); | 708 | addJournals(j_list); |
709 | emit incidenceSelected( 0 ); | 709 | emit incidenceSelected( 0 ); |
710 | updateView(); | 710 | updateView(); |
711 | 711 | ||
712 | } | 712 | } |
713 | 713 | ||
714 | void KOListView::addEvents(QPtrList<Event> eventList) | 714 | void KOListView::addEvents(QPtrList<Event> eventList) |
715 | { | 715 | { |
716 | Event *ev; | 716 | Event *ev; |
717 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 717 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
718 | addIncidence(ev); | 718 | addIncidence(ev); |
719 | } | 719 | } |
720 | if ( !mListView->currentItem() ){ | 720 | if ( !mListView->currentItem() ){ |
721 | updateView(); | 721 | updateView(); |
722 | } | 722 | } |
723 | } | 723 | } |
724 | 724 | ||
725 | void KOListView::addTodos(QPtrList<Todo> eventList) | 725 | void KOListView::addTodos(QPtrList<Todo> eventList) |
726 | { | 726 | { |
727 | Todo *ev; | 727 | Todo *ev; |
728 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 728 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
729 | addIncidence(ev); | 729 | addIncidence(ev); |
730 | } | 730 | } |
731 | if ( !mListView->currentItem() ){ | 731 | if ( !mListView->currentItem() ){ |
732 | updateView(); | 732 | updateView(); |
733 | } | 733 | } |
734 | } | 734 | } |
735 | void KOListView::addJournals(QPtrList<Journal> eventList) | 735 | void KOListView::addJournals(QPtrList<Journal> eventList) |
736 | { | 736 | { |
737 | Journal *ev; | 737 | Journal *ev; |
738 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 738 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
739 | addIncidence(ev); | 739 | addIncidence(ev); |
740 | } | 740 | } |
741 | if ( !mListView->currentItem() ){ | 741 | if ( !mListView->currentItem() ){ |
742 | updateView(); | 742 | updateView(); |
743 | } | 743 | } |
744 | } | 744 | } |
745 | 745 | ||
746 | void KOListView::addIncidence(Incidence *incidence) | 746 | void KOListView::addIncidence(Incidence *incidence) |
747 | { | 747 | { |
748 | if ( mUidDict.find( incidence->uid() ) ) return; | 748 | if ( mUidDict.find( incidence->uid() ) ) return; |
749 | 749 | ||
750 | // mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 750 | // mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
751 | mUidDict.insert( incidence->uid(), incidence ); | 751 | mUidDict.insert( incidence->uid(), incidence ); |
752 | 752 | ||
753 | KOListViewItem *item = new KOListViewItem( incidence, mListView ); | 753 | KOListViewItem *item = new KOListViewItem( incidence, mListView ); |
754 | ListItemVisitor v(item, mStartDate ); | 754 | ListItemVisitor v(item, mStartDate ); |
755 | if (incidence->accept(v)) return; | 755 | if (incidence->accept(v)) return; |
756 | else delete item; | 756 | else delete item; |
757 | //qDebug("delete item "); | 757 | //qDebug("delete item "); |
758 | } | 758 | } |
759 | 759 | ||
760 | void KOListView::showEvents(QPtrList<Event> eventList) | 760 | void KOListView::showEvents(QPtrList<Event> eventList) |
761 | { | 761 | { |
762 | clear(); | 762 | clear(); |
763 | 763 | ||
764 | addEvents(eventList); | 764 | addEvents(eventList); |
765 | 765 | ||
766 | // After new creation of list view no events are selected. | 766 | // After new creation of list view no events are selected. |
767 | emit incidenceSelected( 0 ); | 767 | emit incidenceSelected( 0 ); |
768 | } | 768 | } |
769 | int KOListView::count() | 769 | int KOListView::count() |
770 | { | 770 | { |
771 | return mListView->childCount(); | 771 | return mListView->childCount(); |
772 | } | 772 | } |
773 | 773 | ||
774 | void KOListView::changeEventDisplay(Event *event, int action) | 774 | void KOListView::changeEventDisplay(Event *event, int action) |
775 | { | 775 | { |
776 | KOListViewItem *item; | 776 | KOListViewItem *item; |
777 | 777 | ||
778 | switch(action) { | 778 | switch(action) { |
779 | case KOGlobals::EVENTADDED: | 779 | case KOGlobals::EVENTADDED: |
780 | addIncidence( event ); | 780 | addIncidence( event ); |
781 | break; | 781 | break; |
782 | case KOGlobals::EVENTEDITED: | 782 | case KOGlobals::EVENTEDITED: |
783 | item = getItemForEvent(event); | 783 | item = getItemForEvent(event); |
784 | if (item) { | 784 | if (item) { |
785 | mUidDict.remove( event->uid() ); | 785 | mUidDict.remove( event->uid() ); |
786 | delete item; | 786 | delete item; |
787 | addIncidence( event ); | 787 | addIncidence( event ); |
788 | } | 788 | } |
789 | break; | 789 | break; |
790 | case KOGlobals::EVENTDELETED: | 790 | case KOGlobals::EVENTDELETED: |
791 | item = getItemForEvent(event); | 791 | item = getItemForEvent(event); |
792 | if (item) { | 792 | if (item) { |
793 | mUidDict.remove( event->uid() ); | 793 | mUidDict.remove( event->uid() ); |
794 | delete item; | 794 | delete item; |
795 | } | 795 | } |
796 | break; | 796 | break; |
797 | default: | 797 | default: |
798 | ; | 798 | ; |
799 | } | 799 | } |
800 | } | 800 | } |
801 | 801 | ||
802 | KOListViewItem *KOListView::getItemForEvent(Event *event) | 802 | KOListViewItem *KOListView::getItemForEvent(Event *event) |
803 | { | 803 | { |
804 | KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); | 804 | KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); |
805 | while (item) { | 805 | while (item) { |
806 | if (item->data() == event) return item; | 806 | if (item->data() == event) return item; |
807 | item = (KOListViewItem *)item->nextSibling(); | 807 | item = (KOListViewItem *)item->nextSibling(); |
808 | } | 808 | } |
809 | return 0; | 809 | return 0; |
810 | } | 810 | } |
811 | 811 | ||
812 | void KOListView::defaultItemAction(QListViewItem *i) | 812 | void KOListView::defaultItemAction(QListViewItem *i) |
813 | { | 813 | { |
814 | KOListViewItem *item = static_cast<KOListViewItem *>( i ); | 814 | KOListViewItem *item = static_cast<KOListViewItem *>( i ); |
815 | if ( item ) defaultAction( item->data() ); | 815 | if ( item ) defaultAction( item->data() ); |
816 | 816 | ||
817 | } | 817 | } |
818 | 818 | ||
819 | void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) | 819 | void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) |
820 | { | 820 | { |
821 | mActiveItem = (KOListViewItem *)item; | 821 | mActiveItem = (KOListViewItem *)item; |
822 | if (mActiveItem) { | 822 | if (mActiveItem) { |
823 | Incidence *incidence = mActiveItem->data(); | 823 | Incidence *incidence = mActiveItem->data(); |
824 | mPopupMenu->showIncidencePopup(incidence); | 824 | mPopupMenu->showIncidencePopup(incidence); |
825 | 825 | ||
826 | /* | 826 | /* |
827 | if ( incidence && incidence->type() == "Event" ) { | 827 | if ( incidence && incidence->type() == "Event" ) { |
828 | Event *event = static_cast<Event *>( incidence ); | 828 | Event *event = static_cast<Event *>( incidence ); |
829 | mPopupMenu->showEventPopup(event); | 829 | mPopupMenu->showEventPopup(event); |
830 | } | 830 | } |
831 | */ | 831 | */ |
832 | } | 832 | } |
833 | } | 833 | } |
834 | 834 | ||
835 | void KOListView::readSettings(KConfig *config, QString setting) | 835 | void KOListView::readSettings(KConfig *config, QString setting) |
836 | { | 836 | { |
837 | // qDebug("KOListView::readSettings "); | 837 | // qDebug("KOListView::readSettings "); |
838 | mListView->restoreLayout(config,setting); | 838 | mListView->restoreLayout(config,setting); |
839 | } | 839 | } |
840 | 840 | ||
841 | void KOListView::writeSettings(KConfig *config, QString setting) | 841 | void KOListView::writeSettings(KConfig *config, QString setting) |
842 | { | 842 | { |
843 | // qDebug("KOListView::writeSettings "); | 843 | // qDebug("KOListView::writeSettings "); |
844 | mListView->saveLayout(config, setting); | 844 | mListView->saveLayout(config, setting); |
845 | } | 845 | } |
846 | 846 | ||
847 | void KOListView::processSelectionChange(QListViewItem *) | 847 | void KOListView::processSelectionChange(QListViewItem *) |
848 | { | 848 | { |
849 | 849 | ||
850 | KOListViewItem *item = | 850 | KOListViewItem *item = |
851 | static_cast<KOListViewItem *>( mListView->currentItem() ); | 851 | static_cast<KOListViewItem *>( mListView->currentItem() ); |
852 | 852 | ||
853 | if ( !item ) { | 853 | if ( !item ) { |
854 | emit incidenceSelected( 0 ); | 854 | emit incidenceSelected( 0 ); |
855 | } else { | 855 | } else { |
856 | emit incidenceSelected( item->data() ); | 856 | emit incidenceSelected( item->data() ); |
857 | } | 857 | } |
858 | } | 858 | } |
859 | 859 | ||
860 | void KOListView::clearSelection() | 860 | void KOListView::clearSelection() |
861 | { | 861 | { |
862 | mListView->selectAll( false ); | 862 | mListView->selectAll( false ); |
863 | } | 863 | } |
864 | void KOListView::allSelection() | 864 | void KOListView::allSelection() |
865 | { | 865 | { |
866 | mListView->selectAll( true ); | 866 | mListView->selectAll( true ); |
867 | } | 867 | } |
868 | 868 | ||
869 | void KOListView::clear() | 869 | void KOListView::clear() |
870 | { | 870 | { |
871 | mListView->clear(); | 871 | mListView->clear(); |
872 | mUidDict.clear(); | 872 | mUidDict.clear(); |
873 | } | 873 | } |
874 | 874 | ||
875 | Incidence* KOListView::currentItem() | 875 | Incidence* KOListView::currentItem() |
876 | { | 876 | { |
877 | if ( mListView->currentItem() ) | 877 | if ( mListView->currentItem() ) |
878 | return ((KOListViewItem*) mListView->currentItem())->data(); | 878 | return ((KOListViewItem*) mListView->currentItem())->data(); |
879 | return 0; | 879 | return 0; |
880 | } | 880 | } |
881 | void KOListView::keyPressEvent ( QKeyEvent *e) | 881 | void KOListView::keyPressEvent ( QKeyEvent *e) |
882 | { | 882 | { |
883 | 883 | ||
884 | if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { | 884 | if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { |
885 | deleteAll(); | 885 | deleteAll(); |
886 | return; | 886 | return; |
887 | } | 887 | } |
888 | 888 | ||
889 | e->ignore(); | 889 | e->ignore(); |
890 | } | 890 | } |
891 | void KOListViewListView::keyPressEvent ( QKeyEvent *e) | 891 | void KOListViewListView::keyPressEvent ( QKeyEvent *e) |
892 | { | 892 | { |
893 | 893 | ||
894 | switch ( e->key() ) { | 894 | switch ( e->key() ) { |
895 | case Qt::Key_Down: | 895 | case Qt::Key_Down: |
896 | if ( e->state() == ShiftButton ) { | 896 | if ( e->state() == ShiftButton ) { |
897 | QListViewItem* cn = currentItem(); | 897 | QListViewItem* cn = currentItem(); |
898 | if ( !cn ) | 898 | if ( !cn ) |
899 | cn = firstChild(); | 899 | cn = firstChild(); |
900 | if ( !cn ) | 900 | if ( !cn ) |
901 | return; | 901 | return; |
902 | while ( cn->nextSibling() ) | 902 | while ( cn->nextSibling() ) |
903 | cn = cn->nextSibling(); | 903 | cn = cn->nextSibling(); |
904 | setCurrentItem ( cn ); | 904 | setCurrentItem ( cn ); |
905 | ensureItemVisible ( cn ); | 905 | ensureItemVisible ( cn ); |
906 | 906 | ||
907 | e->accept(); | 907 | e->accept(); |
908 | return; | 908 | return; |
909 | } | 909 | } |
910 | if ( e->state() == ControlButton ) { | 910 | if ( e->state() == ControlButton ) { |
911 | int count = childCount (); | 911 | int count = childCount (); |
912 | int jump = count / 5; | 912 | int jump = count / 5; |
913 | QListViewItem* cn; | 913 | QListViewItem* cn; |
914 | cn = currentItem(); | 914 | cn = currentItem(); |
915 | if ( ! cn ) | 915 | if ( ! cn ) |
916 | return; | 916 | return; |
917 | if ( jump == 0 ) | 917 | if ( jump == 0 ) |
918 | jump = 1; | 918 | jump = 1; |
919 | while ( jump && cn->nextSibling() ) { | 919 | while ( jump && cn->nextSibling() ) { |
920 | cn = cn->nextSibling(); | 920 | cn = cn->nextSibling(); |
921 | --jump; | 921 | --jump; |
922 | } | 922 | } |
923 | setCurrentItem ( cn ); | 923 | setCurrentItem ( cn ); |
924 | ensureItemVisible ( cn ); | 924 | ensureItemVisible ( cn ); |
925 | 925 | ||
926 | } else | 926 | } else |
927 | QListView::keyPressEvent ( e ) ; | 927 | QListView::keyPressEvent ( e ) ; |
928 | e->accept(); | 928 | e->accept(); |
929 | break; | 929 | break; |
930 | 930 | ||
931 | case Qt::Key_Up: | 931 | case Qt::Key_Up: |
932 | if ( e->state() == ShiftButton ) { | 932 | if ( e->state() == ShiftButton ) { |
933 | QListViewItem* cn = firstChild(); | 933 | QListViewItem* cn = firstChild(); |
934 | if ( cn ) { | 934 | if ( cn ) { |
935 | setCurrentItem ( cn ); | 935 | setCurrentItem ( cn ); |
936 | ensureItemVisible ( cn ); | 936 | ensureItemVisible ( cn ); |
937 | } | 937 | } |
938 | e->accept(); | 938 | e->accept(); |
939 | return; | 939 | return; |
940 | } | 940 | } |
941 | if ( e->state() == ControlButton ) { | 941 | if ( e->state() == ControlButton ) { |
942 | int count = childCount (); | 942 | int count = childCount (); |
943 | int jump = count / 5; | 943 | int jump = count / 5; |
944 | QListViewItem* cn; | 944 | QListViewItem* cn; |
945 | cn = currentItem(); | 945 | cn = currentItem(); |
946 | if ( ! cn ) | 946 | if ( ! cn ) |
947 | return; | 947 | return; |
948 | if ( jump == 0 ) | 948 | if ( jump == 0 ) |
949 | jump = 1; | 949 | jump = 1; |
950 | while ( jump && cn->itemAbove ()) { | 950 | while ( jump && cn->itemAbove ()) { |
951 | cn = cn->itemAbove (); | 951 | cn = cn->itemAbove (); |
952 | --jump; | 952 | --jump; |
953 | } | 953 | } |
954 | setCurrentItem ( cn ); | 954 | setCurrentItem ( cn ); |
955 | ensureItemVisible ( cn ); | 955 | ensureItemVisible ( cn ); |
956 | } else | 956 | } else |
957 | QListView::keyPressEvent ( e ) ; | 957 | QListView::keyPressEvent ( e ) ; |
958 | e->accept(); | 958 | e->accept(); |
959 | break; | 959 | break; |
960 | case Qt::Key_I: { | 960 | case Qt::Key_I: { |
961 | QListViewItem* cn; | 961 | QListViewItem* cn; |
962 | cn = currentItem(); | 962 | cn = currentItem(); |
963 | if ( cn ) { | 963 | if ( cn ) { |
964 | KOListViewItem* ci = (KOListViewItem*)( cn ); | 964 | KOListViewItem* ci = (KOListViewItem*)( cn ); |
965 | if ( ci ){ | 965 | if ( ci ){ |
966 | emit showIncidence( ci->data()); | 966 | emit showIncidence( ci->data()); |
967 | cn = cn->nextSibling(); | 967 | cn = cn->nextSibling(); |
968 | if ( cn ) { | 968 | if ( cn ) { |
969 | setCurrentItem ( cn ); | 969 | setCurrentItem ( cn ); |
970 | ensureItemVisible ( cn ); | 970 | ensureItemVisible ( cn ); |
971 | } | 971 | } |
972 | } | 972 | } |
973 | } | 973 | } |
974 | e->accept(); | 974 | e->accept(); |
975 | } | 975 | } |
976 | break; | 976 | break; |
977 | case Qt::Key_Return: | 977 | case Qt::Key_Return: |
978 | case Qt::Key_Enter: | 978 | case Qt::Key_Enter: |
979 | { | 979 | { |
980 | QListViewItem* cn; | 980 | QListViewItem* cn; |
981 | cn = currentItem(); | 981 | cn = currentItem(); |
982 | if ( cn ) { | 982 | if ( cn ) { |
983 | KOListViewItem* ci = (KOListViewItem*)( cn ); | 983 | KOListViewItem* ci = (KOListViewItem*)( cn ); |
984 | if ( ci ){ | 984 | if ( ci ){ |
985 | if ( e->state() == ShiftButton ) | 985 | if ( e->state() == ShiftButton ) |
986 | ci->setSelected( false ); | 986 | ci->setSelected( false ); |
987 | else | 987 | else |
988 | ci->setSelected( true ); | 988 | ci->setSelected( true ); |
989 | cn = cn->nextSibling(); | 989 | cn = cn->nextSibling(); |
990 | if ( cn ) { | 990 | if ( cn ) { |
991 | setCurrentItem ( cn ); | 991 | setCurrentItem ( cn ); |
992 | ensureItemVisible ( cn ); | 992 | ensureItemVisible ( cn ); |
993 | } | 993 | } |
994 | } | 994 | } |
995 | } | 995 | } |
996 | e->accept(); | 996 | e->accept(); |
997 | } | 997 | } |
998 | break; | 998 | break; |
999 | default: | 999 | default: |
1000 | e->ignore(); | 1000 | e->ignore(); |
1001 | } | 1001 | } |
1002 | } | 1002 | } |
1003 | KOListViewListView::KOListViewListView(KOListView * lv ) | 1003 | KOListViewListView::KOListViewListView(KOListView * lv ) |
1004 | : KListView( lv ) | 1004 | : KListView( lv ) |
1005 | { | 1005 | { |
1006 | #ifndef DESKTOP_VERSION | 1006 | #ifndef DESKTOP_VERSION |
1007 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); | 1007 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); |
1008 | #endif | 1008 | #endif |
1009 | mYMousePos = -1000; | ||
1009 | setSelectionMode( QListView::Multi ); | 1010 | setSelectionMode( QListView::Multi ); |
1010 | setMultiSelection( true); | 1011 | setMultiSelection( true); |
1011 | mAllowPopupMenu = true; | 1012 | mAllowPopupMenu = true; |
1012 | mMouseDown = false; | 1013 | mMouseDown = false; |
1013 | 1014 | ||
1014 | } | 1015 | } |
1015 | void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 1016 | void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
1016 | { | 1017 | { |
1017 | if (!e) return; | 1018 | if (!e) return; |
1018 | QPoint vp = contentsToViewport(e->pos()); | 1019 | QPoint vp = contentsToViewport(e->pos()); |
1019 | QListViewItem *item = itemAt(vp); | 1020 | QListViewItem *item = itemAt(vp); |
1020 | if (!item) { | 1021 | if (!item) { |
1021 | emit newEvent(); | 1022 | emit newEvent(); |
1022 | return; | 1023 | return; |
1023 | } | 1024 | } |
1024 | KListView::contentsMouseDoubleClickEvent(e); | 1025 | KListView::contentsMouseDoubleClickEvent(e); |
1025 | } | 1026 | } |
1026 | 1027 | ||
1027 | 1028 | ||
1028 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) | 1029 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) |
1029 | { | 1030 | { |
1030 | //qDebug("contentsMousePressEvent++++ "); | 1031 | //qDebug("contentsMousePressEvent++++ "); |
1031 | if (! mMouseDown ) { | 1032 | if (! mMouseDown ) { |
1032 | mAllowPopupMenu = true; | 1033 | mAllowPopupMenu = true; |
1033 | mYMousePos = mapToGlobal( (e->pos())).y(); | 1034 | mYMousePos = mapToGlobal( (e->pos())).y(); |
1034 | } | 1035 | } |
1035 | if ( e->button() == RightButton && mMouseDown ) | 1036 | if ( e->button() == RightButton && mMouseDown ) |
1036 | return; | 1037 | return; |
1037 | if ( e->button() == LeftButton ) | 1038 | if ( e->button() == LeftButton ) |
1038 | mMouseDown = true; | 1039 | mMouseDown = true; |
1039 | KListView::contentsMousePressEvent( e ); | 1040 | KListView::contentsMousePressEvent( e ); |
1040 | } | 1041 | } |
1041 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) | 1042 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) |
1042 | { | 1043 | { |
1043 | //qDebug("contentsMouseReleaseEv---- "); | 1044 | //qDebug("contentsMouseReleaseEv---- "); |
1044 | if ( ! mMouseDown ) { | 1045 | if ( ! mMouseDown ) { |
1045 | if ( e->button() == RightButton && ! mAllowPopupMenu ) | 1046 | if ( e->button() == RightButton && ! mAllowPopupMenu ) |
1046 | return; | 1047 | return; |
1047 | QListViewItem* ci = currentItem(); | 1048 | QListViewItem* ci = currentItem(); |
1048 | if ( ci ) | 1049 | if ( ci ) |
1049 | ci->setSelected( true ); | 1050 | ci->setSelected( true ); |
1050 | KListView::contentsMouseReleaseEvent(e); | 1051 | KListView::contentsMouseReleaseEvent(e); |
1051 | return; | 1052 | return; |
1052 | } | 1053 | } |
1053 | if ( e->button() == LeftButton ) | 1054 | if ( e->button() == LeftButton ) |
1054 | mMouseDown = false; | 1055 | mMouseDown = false; |
1055 | if ( e->button() == RightButton && ! mAllowPopupMenu ) | 1056 | if ( e->button() == RightButton && ! mAllowPopupMenu ) |
1056 | return; | 1057 | return; |
1057 | if ( e->button() == RightButton ) { | 1058 | if ( e->button() == RightButton ) { |
1058 | QListViewItem* ci = currentItem(); | 1059 | QListViewItem* ci = currentItem(); |
1059 | if ( ci ) | 1060 | if ( ci ) |
1060 | ci->setSelected( true ); | 1061 | ci->setSelected( true ); |
1061 | } | 1062 | } |
1062 | KListView::contentsMouseReleaseEvent(e); | 1063 | KListView::contentsMouseReleaseEvent(e); |
1063 | } | 1064 | } |
1064 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) | 1065 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) |
1065 | { | 1066 | { |
1066 | // qDebug("contentsMouseMoveEv....... "); | 1067 | // qDebug("contentsMouseMoveEv....... "); |
1067 | // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); | 1068 | // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); |
1068 | int diff = mYMousePos - mapToGlobal( (e->pos())).y(); | 1069 | int diff = mYMousePos - mapToGlobal( (e->pos())).y(); |
1069 | if ( diff < 0 ) diff = -diff; | 1070 | if ( diff < 0 ) diff = -diff; |
1070 | if ( diff > 20 ) | 1071 | if ( diff > 20 ) |
1071 | mAllowPopupMenu = false; | 1072 | mAllowPopupMenu = false; |
1072 | KListView::contentsMouseMoveEvent(e); | 1073 | KListView::contentsMouseMoveEvent(e); |
1073 | } | 1074 | } |
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index f44debc..8dca3ae 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp | |||
@@ -1,477 +1,467 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 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 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <time.h> | 24 | #include <time.h> |
25 | #ifndef _WIN32_ | 25 | #ifndef _WIN32_ |
26 | #include <unistd.h> | 26 | #include <unistd.h> |
27 | #endif | 27 | #endif |
28 | #include <qdir.h> | 28 | #include <qdir.h> |
29 | #include <qtextstream.h> | 29 | #include <qtextstream.h> |
30 | #include <qtextcodec.h> | 30 | #include <qtextcodec.h> |
31 | #include <qstring.h> | 31 | #include <qstring.h> |
32 | #include <qregexp.h> | 32 | #include <qregexp.h> |
33 | #include <qfont.h> | 33 | #include <qfont.h> |
34 | #include <qcolor.h> | 34 | #include <qcolor.h> |
35 | #include <qstringlist.h> | 35 | #include <qstringlist.h> |
36 | #include <stdlib.h> | 36 | #include <stdlib.h> |
37 | 37 | ||
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <kconfig.h> | 39 | #include <kconfig.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kdebug.h> | 41 | #include <kdebug.h> |
42 | #include <kemailsettings.h> | 42 | #include <kemailsettings.h> |
43 | #include <kstaticdeleter.h> | 43 | #include <kstaticdeleter.h> |
44 | #include <libkdepim/kpimglobalprefs.h> | 44 | #include <libkdepim/kpimglobalprefs.h> |
45 | 45 | ||
46 | #include "koprefs.h" | 46 | #include "koprefs.h" |
47 | #include "mainwindow.h" | 47 | #include "mainwindow.h" |
48 | 48 | ||
49 | KOPrefs *KOPrefs::mInstance = 0; | 49 | KOPrefs *KOPrefs::mInstance = 0; |
50 | static KStaticDeleter<KOPrefs> insd; | 50 | static KStaticDeleter<KOPrefs> insd; |
51 | 51 | ||
52 | KOPrefs::KOPrefs() : | 52 | KOPrefs::KOPrefs() : |
53 | KPimPrefs("korganizerrc") | 53 | KPimPrefs("korganizerrc") |
54 | { | 54 | { |
55 | mCategoryColors.setAutoDelete(true); | 55 | mCategoryColors.setAutoDelete(true); |
56 | fillMailDefaults(); | 56 | fillMailDefaults(); |
57 | mDefaultCategoryColor = QColor(175,210,255);//196,196,196); | 57 | mDefaultCategoryColor = QColor(175,210,255);//196,196,196); |
58 | QColor defaultHolidayColor = QColor(255,0,0); | 58 | QColor defaultHolidayColor = QColor(255,0,0); |
59 | QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); | 59 | QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); |
60 | QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); | 60 | QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); |
61 | QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); | 61 | QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); |
62 | QColor defaultTodoDueTodayColor = QColor(255,220,100); | 62 | QColor defaultTodoDueTodayColor = QColor(255,220,100); |
63 | QColor defaultTodoOverdueColor = QColor(255,153,125); | 63 | QColor defaultTodoOverdueColor = QColor(255,153,125); |
64 | 64 | ||
65 | mTimeBarFont = QFont("helvetica",10);//,QFont::Bold); | 65 | mTimeBarFont = QFont("helvetica",10);//,QFont::Bold); |
66 | mDefaultViewFont = QFont("helvetica",10); | 66 | mDefaultViewFont = QFont("helvetica",10); |
67 | mDefaultMonthViewFont = QFont("helvetica",8); | 67 | mDefaultMonthViewFont = QFont("helvetica",8); |
68 | mMarcusBainsFont= QFont("helvetica",10); | 68 | mMarcusBainsFont= QFont("helvetica",10); |
69 | mDateNavigatorFont= QFont("helvetica",10, QFont::Bold); | 69 | mDateNavigatorFont= QFont("helvetica",10, QFont::Bold); |
70 | mEditBoxFont = QFont("helvetica",12); | 70 | mEditBoxFont = QFont("helvetica",12); |
71 | mJornalViewFont = QFont("helvetica",12); | 71 | mJornalViewFont = QFont("helvetica",12); |
72 | 72 | ||
73 | KPrefs::setCurrentGroup("General"); | 73 | KPrefs::setCurrentGroup("General"); |
74 | 74 | ||
75 | 75 | ||
76 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | 76 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); |
77 | 77 | ||
78 | addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); | 78 | addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); |
79 | addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); | 79 | addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); |
80 | addItemBool("ShowIconSearch",&mShowIconSearch,true); | 80 | addItemBool("ShowIconSearch",&mShowIconSearch,true); |
81 | addItemBool("ShowIconList",&mShowIconList,true); | 81 | addItemBool("ShowIconList",&mShowIconList,true); |
82 | addItemBool("ShowIconDay1",&mShowIconDay1,true); | 82 | addItemBool("ShowIconDay1",&mShowIconDay1,true); |
83 | addItemBool("ShowIconDay5",&mShowIconDay5,true); | 83 | addItemBool("ShowIconDay5",&mShowIconDay5,true); |
84 | addItemBool("ShowIconDay7",&mShowIconDay7,true); | 84 | addItemBool("ShowIconDay7",&mShowIconDay7,true); |
85 | addItemBool("ShowIconMonth",&mShowIconMonth,true); | 85 | addItemBool("ShowIconMonth",&mShowIconMonth,true); |
86 | addItemBool("ShowIconTodoview",&mShowIconTodoview,true); | 86 | addItemBool("ShowIconTodoview",&mShowIconTodoview,true); |
87 | addItemBool("ShowIconBackFast",&mShowIconBackFast,true); | 87 | addItemBool("ShowIconBackFast",&mShowIconBackFast,true); |
88 | addItemBool("ShowIconBack",&mShowIconBack,true); | 88 | addItemBool("ShowIconBack",&mShowIconBack,true); |
89 | addItemBool("ShowIconToday",&mShowIconToday,true); | 89 | addItemBool("ShowIconToday",&mShowIconToday,true); |
90 | addItemBool("ShowIconForward",&mShowIconForward,true); | 90 | addItemBool("ShowIconForward",&mShowIconForward,true); |
91 | addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); | 91 | addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); |
92 | addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false); | 92 | addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false); |
93 | addItemBool("ShowIconNextDays",&mShowIconNextDays,true); | 93 | addItemBool("ShowIconNextDays",&mShowIconNextDays,true); |
94 | addItemBool("ShowIconNext",&mShowIconNext,true); | 94 | addItemBool("ShowIconNext",&mShowIconNext,true); |
95 | addItemBool("ShowIconJournal",&mShowIconJournal,true); | 95 | addItemBool("ShowIconJournal",&mShowIconJournal,true); |
96 | addItemBool("ShowIconStretch",&mShowIconStretch,true); | 96 | addItemBool("ShowIconStretch",&mShowIconStretch,true); |
97 | addItemInt("LastLoadedLanguage",&mOldLanguage,0); | 97 | addItemInt("LastLoadedLanguage",&mOldLanguage,0); |
98 | 98 | ||
99 | addItemBool("AskForQuit",&mAskForQuit,false); | 99 | addItemBool("AskForQuit",&mAskForQuit,false); |
100 | 100 | ||
101 | #ifndef DESKTOP_VERSION | 101 | #ifndef DESKTOP_VERSION |
102 | addItemBool("ShowFullMenu",&mShowFullMenu,false); | 102 | addItemBool("ShowFullMenu",&mShowFullMenu,false); |
103 | #else | 103 | #else |
104 | addItemBool("ShowFullMenu",&mShowFullMenu,true); | 104 | addItemBool("ShowFullMenu",&mShowFullMenu,true); |
105 | #endif | 105 | #endif |
106 | addItemBool("ToolBarHor",&mToolBarHor, true ); | 106 | addItemBool("ToolBarHor",&mToolBarHor, true ); |
107 | addItemBool("ToolBarUp",&mToolBarUp, false ); | 107 | addItemBool("ToolBarUp",&mToolBarUp, false ); |
108 | addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); | 108 | addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); |
109 | addItemInt("Whats Next Days",&mWhatsNextDays,3); | 109 | addItemInt("Whats Next Days",&mWhatsNextDays,3); |
110 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); | 110 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); |
111 | 111 | ||
112 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); | 112 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); |
113 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); | 113 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); |
114 | addItemInt("AllDay Size",&mAllDaySize,28); | 114 | addItemInt("AllDay Size",&mAllDaySize,28); |
115 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; | 115 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; |
116 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); | 116 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); |
117 | 117 | ||
118 | addItemStringList("LocationDefaults",&mLocationDefaults ); | 118 | addItemStringList("LocationDefaults",&mLocationDefaults ); |
119 | addItemStringList("EventSummary User",&mEventSummaryUser); | 119 | addItemStringList("EventSummary User",&mEventSummaryUser); |
120 | addItemStringList("TodoSummary User",&mTodoSummaryUser); | 120 | addItemStringList("TodoSummary User",&mTodoSummaryUser); |
121 | 121 | ||
122 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | 122 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); |
123 | addItemBool("Enable Project View",&mEnableProjectView,false); | 123 | addItemBool("Enable Project View",&mEnableProjectView,false); |
124 | addItemBool("Auto Save",&mAutoSave,false); | 124 | addItemBool("Auto Save",&mAutoSave,false); |
125 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); | 125 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); |
126 | addItemBool("Confirm Deletes",&mConfirm,true); | 126 | addItemBool("Confirm Deletes",&mConfirm,true); |
127 | addItemString("Archive File",&mArchiveFile); | 127 | addItemString("Archive File",&mArchiveFile); |
128 | addItemString("Html Export File",&mHtmlExportFile, | 128 | addItemString("Html Export File",&mHtmlExportFile, |
129 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); | 129 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); |
130 | addItemBool("Html With Save",&mHtmlWithSave,false); | 130 | addItemBool("Html With Save",&mHtmlWithSave,false); |
131 | 131 | ||
132 | KPrefs::setCurrentGroup("Personal Settings"); | 132 | KPrefs::setCurrentGroup("Personal Settings"); |
133 | 133 | ||
134 | addItemInt("Mail Client",&mMailClient,MailClientKMail); | 134 | addItemInt("Mail Client",&mMailClient,MailClientKMail); |
135 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); | 135 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); |
136 | addItemBool("Bcc",&mBcc,false); | 136 | addItemBool("Bcc",&mBcc,false); |
137 | 137 | ||
138 | KPrefs::setCurrentGroup("Time & Date"); | 138 | KPrefs::setCurrentGroup("Time & Date"); |
139 | 139 | ||
140 | 140 | ||
141 | addItemInt("Default Start Time",&mStartTime,10); | 141 | addItemInt("Default Start Time",&mStartTime,10); |
142 | addItemInt("Default Duration",&mDefaultDuration,2); | 142 | addItemInt("Default Duration",&mDefaultDuration,2); |
143 | addItemInt("Default Alarm Time",&mAlarmTime,3); | 143 | addItemInt("Default Alarm Time",&mAlarmTime,3); |
144 | KPrefs::setCurrentGroup("AlarmSettings"); | 144 | KPrefs::setCurrentGroup("AlarmSettings"); |
145 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); | 145 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); |
146 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); | 146 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); |
147 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); | 147 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); |
148 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); | 148 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); |
149 | 149 | ||
150 | 150 | ||
151 | KPrefs::setCurrentGroup("Calendar"); | 151 | KPrefs::setCurrentGroup("Calendar"); |
152 | 152 | ||
153 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); | 153 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); |
154 | 154 | ||
155 | KPrefs::setCurrentGroup("Fonts"); | 155 | KPrefs::setCurrentGroup("Fonts"); |
156 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); | 156 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); |
157 | addItemFont("TimeBar Font",&mTimeBarFont); | 157 | addItemFont("TimeBar Font",&mTimeBarFont); |
158 | addItemFont("MonthView Font",&mMonthViewFont); | 158 | addItemFont("MonthView Font",&mMonthViewFont); |
159 | addItemFont("AgendaView Font",&mAgendaViewFont); | 159 | addItemFont("AgendaView Font",&mAgendaViewFont); |
160 | addItemFont("MarcusBains Font",&mMarcusBainsFont); | 160 | addItemFont("MarcusBains Font",&mMarcusBainsFont); |
161 | addItemFont("TimeLabels Font",&mTimeLabelsFont); | 161 | addItemFont("TimeLabels Font",&mTimeLabelsFont); |
162 | addItemFont("TodoView Font",&mTodoViewFont); | 162 | addItemFont("TodoView Font",&mTodoViewFont); |
163 | addItemFont("ListView Font",&mListViewFont); | 163 | addItemFont("ListView Font",&mListViewFont); |
164 | addItemFont("DateNavigator Font",&mDateNavigatorFont); | 164 | addItemFont("DateNavigator Font",&mDateNavigatorFont); |
165 | addItemFont("EditBox Font",&mEditBoxFont); | 165 | addItemFont("EditBox Font",&mEditBoxFont); |
166 | addItemFont("JournalView Font",&mJornalViewFont); | 166 | addItemFont("JournalView Font",&mJornalViewFont); |
167 | addItemFont("WhatsNextView Font",&mWhatsNextFont); | 167 | addItemFont("WhatsNextView Font",&mWhatsNextFont); |
168 | addItemFont("EventView Font",&mEventViewFont); | 168 | addItemFont("EventView Font",&mEventViewFont); |
169 | 169 | ||
170 | // KPrefs::setCurrentGroup("SyncProfiles"); | ||
171 | // addItemString("LocalMachineName",&mLocalMachineName, "undefined"); | ||
172 | // addItemStringList("SyncProfileNames",&mSyncProfileNames); | ||
173 | // addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames); | ||
174 | |||
175 | KPrefs::setCurrentGroup("RemoteSyncing"); | 170 | KPrefs::setCurrentGroup("RemoteSyncing"); |
176 | // addItemBool("UsePasswd",&mUsePassWd,false); | ||
177 | // addItemBool("WriteBackFile",&mWriteBackFile,true); | ||
178 | // addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false); | ||
179 | // addItemBool("AskForPreferences",&mAskForPreferences,true); | ||
180 | // addItemBool("ShowSyncSummary",&mShowSyncSummary,true); | ||
181 | addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); | 171 | addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); |
182 | addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); | 172 | addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); |
183 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); | 173 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); |
184 | addItemInt("LastSyncTime",&mLastSyncTime,0); | 174 | addItemInt("LastSyncTime",&mLastSyncTime,0); |
185 | 175 | ||
186 | #ifdef _WIN32_ | 176 | #ifdef _WIN32_ |
187 | QString hdp= locateLocal("data","korganizer")+"\\\\"; | 177 | QString hdp= locateLocal("data","korganizer")+"\\\\"; |
188 | #else | 178 | #else |
189 | QString hdp= locateLocal("data","korganizer")+"/"; | 179 | QString hdp= locateLocal("data","korganizer")+"/"; |
190 | #endif | 180 | #endif |
191 | 181 | ||
192 | KPrefs::setCurrentGroup("LoadSaveFileNames"); | 182 | KPrefs::setCurrentGroup("LoadSaveFileNames"); |
193 | 183 | ||
194 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); | 184 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); |
195 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); | 185 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); |
196 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); | 186 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); |
197 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); | 187 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); |
198 | 188 | ||
199 | 189 | ||
200 | KPrefs::setCurrentGroup("Locale"); | 190 | KPrefs::setCurrentGroup("Locale"); |
201 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); | 191 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); |
202 | 192 | ||
203 | 193 | ||
204 | KPrefs::setCurrentGroup("Colors"); | 194 | KPrefs::setCurrentGroup("Colors"); |
205 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); | 195 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); |
206 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); | 196 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); |
207 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); | 197 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); |
208 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); | 198 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); |
209 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); | 199 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); |
210 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); | 200 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); |
211 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); | 201 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); |
212 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); | 202 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); |
213 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); | 203 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); |
214 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); | 204 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); |
215 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); | 205 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); |
216 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); | 206 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); |
217 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); | 207 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); |
218 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); | 208 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); |
219 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); | 209 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); |
220 | addItemBool("UseAppColors",&mUseAppColors,false); | 210 | addItemBool("UseAppColors",&mUseAppColors,false); |
221 | 211 | ||
222 | 212 | ||
223 | 213 | ||
224 | KPrefs::setCurrentGroup("Views"); | 214 | KPrefs::setCurrentGroup("Views"); |
225 | addItemInt("Hour Size",&mHourSize,8); | 215 | addItemInt("Hour Size",&mHourSize,8); |
226 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); | 216 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); |
227 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); | 217 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); |
228 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); | 218 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); |
229 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); | 219 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); |
230 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); | 220 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); |
231 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); | 221 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); |
232 | addItemBool("Enable ToolTips",&mEnableToolTips,false); | 222 | addItemBool("Enable ToolTips",&mEnableToolTips,false); |
233 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); | 223 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); |
234 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); | 224 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); |
235 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); | 225 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); |
236 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); | 226 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); |
237 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false); | 227 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false); |
238 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); | 228 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); |
239 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); | 229 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); |
240 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); | 230 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); |
241 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); | 231 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); |
242 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true); | 232 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true); |
243 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); | 233 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); |
244 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); | 234 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); |
245 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); | 235 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); |
246 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); | 236 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); |
247 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); | 237 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); |
248 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false); | 238 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false); |
249 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); | 239 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); |
250 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); | 240 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); |
251 | #ifdef DESKTOP_VERSION | 241 | #ifdef DESKTOP_VERSION |
252 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); | 242 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); |
253 | #else | 243 | #else |
254 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); | 244 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); |
255 | #endif | 245 | #endif |
256 | addItemInt("Day Begins",&mDayBegins,7); | 246 | addItemInt("Day Begins",&mDayBegins,7); |
257 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); | 247 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); |
258 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); | 248 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); |
259 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); | 249 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); |
260 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); | 250 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); |
261 | 251 | ||
262 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); | 252 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); |
263 | addItemBool("Full View Month",&mFullViewMonth,true); | 253 | addItemBool("Full View Month",&mFullViewMonth,true); |
264 | addItemBool("Full View Todo",&mFullViewTodo,true); | 254 | addItemBool("Full View Todo",&mFullViewTodo,true); |
265 | addItemBool("Quick Todo",&mEnableQuickTodo,false); | 255 | addItemBool("Quick Todo",&mEnableQuickTodo,false); |
266 | 256 | ||
267 | addItemInt("Next X Days",&mNextXDays,3); | 257 | addItemInt("Next X Days",&mNextXDays,3); |
268 | 258 | ||
269 | KPrefs::setCurrentGroup("Printer"); | 259 | KPrefs::setCurrentGroup("Printer"); |
270 | 260 | ||
271 | KPrefs::setCurrentGroup("Layout"); | 261 | KPrefs::setCurrentGroup("Layout"); |
272 | 262 | ||
273 | addItemBool("CompactDialogs",&mCompactDialogs,false); | 263 | addItemBool("CompactDialogs",&mCompactDialogs,false); |
274 | addItemBool("VerticalScreen",&mVerticalScreen,true); | 264 | addItemBool("VerticalScreen",&mVerticalScreen,true); |
275 | 265 | ||
276 | KPrefs::setCurrentGroup("KOrganizer Plugins"); | 266 | KPrefs::setCurrentGroup("KOrganizer Plugins"); |
277 | 267 | ||
278 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); | 268 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); |
279 | 269 | ||
280 | KPrefs::setCurrentGroup("Group Scheduling"); | 270 | KPrefs::setCurrentGroup("Group Scheduling"); |
281 | 271 | ||
282 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); | 272 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); |
283 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); | 273 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); |
284 | addItemStringList("AdditionalMails",&mAdditionalMails,""); | 274 | addItemStringList("AdditionalMails",&mAdditionalMails,""); |
285 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); | 275 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); |
286 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); | 276 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); |
287 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); | 277 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); |
288 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); | 278 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); |
289 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); | 279 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); |
290 | 280 | ||
291 | KPrefs::setCurrentGroup( "Editors" ); | 281 | KPrefs::setCurrentGroup( "Editors" ); |
292 | 282 | ||
293 | addItemStringList( "EventTemplates", &mEventTemplates ); | 283 | addItemStringList( "EventTemplates", &mEventTemplates ); |
294 | addItemStringList( "TodoTemplates", &mTodoTemplates ); | 284 | addItemStringList( "TodoTemplates", &mTodoTemplates ); |
295 | 285 | ||
296 | addItemInt("DestinationPolicy",&mDestination,standardDestination); | 286 | addItemInt("DestinationPolicy",&mDestination,standardDestination); |
297 | 287 | ||
298 | 288 | ||
299 | 289 | ||
300 | } | 290 | } |
301 | 291 | ||
302 | 292 | ||
303 | KOPrefs::~KOPrefs() | 293 | KOPrefs::~KOPrefs() |
304 | { | 294 | { |
305 | if (mInstance == this) | 295 | if (mInstance == this) |
306 | mInstance = insd.setObject(0); | 296 | mInstance = insd.setObject(0); |
307 | 297 | ||
308 | //qDebug("KOPrefs::~KOPrefs() "); | 298 | //qDebug("KOPrefs::~KOPrefs() "); |
309 | } | 299 | } |
310 | 300 | ||
311 | 301 | ||
312 | KOPrefs *KOPrefs::instance() | 302 | KOPrefs *KOPrefs::instance() |
313 | { | 303 | { |
314 | if (!mInstance) { | 304 | if (!mInstance) { |
315 | mInstance = insd.setObject(new KOPrefs()); | 305 | mInstance = insd.setObject(new KOPrefs()); |
316 | mInstance->readConfig(); | 306 | mInstance->readConfig(); |
317 | } | 307 | } |
318 | 308 | ||
319 | return mInstance; | 309 | return mInstance; |
320 | } | 310 | } |
321 | 311 | ||
322 | void KOPrefs::usrSetDefaults() | 312 | void KOPrefs::usrSetDefaults() |
323 | { | 313 | { |
324 | 314 | ||
325 | } | 315 | } |
326 | 316 | ||
327 | void KOPrefs::fillMailDefaults() | 317 | void KOPrefs::fillMailDefaults() |
328 | { | 318 | { |
329 | if (mName.isEmpty()) mName = i18n("Anonymous"); | 319 | if (mName.isEmpty()) mName = i18n("Anonymous"); |
330 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); | 320 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); |
331 | } | 321 | } |
332 | 322 | ||
333 | void KOPrefs::setTimeZoneIdDefault() | 323 | void KOPrefs::setTimeZoneIdDefault() |
334 | { | 324 | { |
335 | ; | 325 | ; |
336 | } | 326 | } |
337 | 327 | ||
338 | void KOPrefs::setCategoryDefaults() | 328 | void KOPrefs::setCategoryDefaults() |
339 | { | 329 | { |
340 | mCustomCategories.clear(); | 330 | mCustomCategories.clear(); |
341 | mCustomCategories = getDefaultList(); | 331 | mCustomCategories = getDefaultList(); |
342 | 332 | ||
343 | QStringList::Iterator it; | 333 | QStringList::Iterator it; |
344 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 334 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
345 | setCategoryColor(*it,mDefaultCategoryColor); | 335 | setCategoryColor(*it,mDefaultCategoryColor); |
346 | } | 336 | } |
347 | } | 337 | } |
348 | 338 | ||
349 | QStringList KOPrefs::getDefaultList() | 339 | QStringList KOPrefs::getDefaultList() |
350 | { | 340 | { |
351 | QStringList retval ; | 341 | QStringList retval ; |
352 | retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") | 342 | retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") |
353 | << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") | 343 | << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") |
354 | << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") | 344 | << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") |
355 | << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") | 345 | << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") |
356 | << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") | 346 | << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") |
357 | << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") | 347 | << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") |
358 | << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") | 348 | << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") |
359 | << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; | 349 | << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; |
360 | retval.sort(); | 350 | retval.sort(); |
361 | return retval; | 351 | return retval; |
362 | } | 352 | } |
363 | 353 | ||
364 | void KOPrefs::usrReadConfig() | 354 | void KOPrefs::usrReadConfig() |
365 | { | 355 | { |
366 | config()->setGroup("General"); | 356 | config()->setGroup("General"); |
367 | 357 | ||
368 | mCustomCategories = config()->readListEntry("Custom Categories"); | 358 | mCustomCategories = config()->readListEntry("Custom Categories"); |
369 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != mOldLanguage ) { | 359 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != mOldLanguage ) { |
370 | mLocationDefaults.clear(); | 360 | mLocationDefaults.clear(); |
371 | mEventSummaryUser.clear(); | 361 | mEventSummaryUser.clear(); |
372 | mTodoSummaryUser.clear(); | 362 | mTodoSummaryUser.clear(); |
373 | } | 363 | } |
374 | mOldLoadedLanguage = mOldLanguage ; | 364 | mOldLoadedLanguage = mOldLanguage ; |
375 | mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; | 365 | mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; |
376 | if (mLocationDefaults.isEmpty()) { | 366 | if (mLocationDefaults.isEmpty()) { |
377 | mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") | 367 | mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") |
378 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") | 368 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") |
379 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; | 369 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; |
380 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") | 370 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") |
381 | mLocationDefaults.sort(); | 371 | mLocationDefaults.sort(); |
382 | } | 372 | } |
383 | 373 | ||
384 | if (mEventSummaryUser.isEmpty()) { | 374 | if (mEventSummaryUser.isEmpty()) { |
385 | mEventSummaryUser = getDefaultList() ; | 375 | mEventSummaryUser = getDefaultList() ; |
386 | } | 376 | } |
387 | if (mTodoSummaryUser.isEmpty()) { | 377 | if (mTodoSummaryUser.isEmpty()) { |
388 | mTodoSummaryUser = getDefaultList() ; | 378 | mTodoSummaryUser = getDefaultList() ; |
389 | } | 379 | } |
390 | 380 | ||
391 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); | 381 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); |
392 | 382 | ||
393 | config()->setGroup("Personal Settings"); | 383 | config()->setGroup("Personal Settings"); |
394 | mName = config()->readEntry("user_name",""); | 384 | mName = config()->readEntry("user_name",""); |
395 | mEmail = config()->readEntry("user_email",""); | 385 | mEmail = config()->readEntry("user_email",""); |
396 | fillMailDefaults(); | 386 | fillMailDefaults(); |
397 | 387 | ||
398 | config()->setGroup("Category Colors"); | 388 | config()->setGroup("Category Colors"); |
399 | QStringList::Iterator it; | 389 | QStringList::Iterator it; |
400 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 390 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
401 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); | 391 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); |
402 | 392 | ||
403 | } | 393 | } |
404 | 394 | ||
405 | KPimPrefs::usrReadConfig(); | 395 | KPimPrefs::usrReadConfig(); |
406 | } | 396 | } |
407 | 397 | ||
408 | 398 | ||
409 | void KOPrefs::usrWriteConfig() | 399 | void KOPrefs::usrWriteConfig() |
410 | { | 400 | { |
411 | config()->setGroup("General"); | 401 | config()->setGroup("General"); |
412 | config()->writeEntry("Custom Categories",mCustomCategories); | 402 | config()->writeEntry("Custom Categories",mCustomCategories); |
413 | 403 | ||
414 | config()->setGroup("Personal Settings"); | 404 | config()->setGroup("Personal Settings"); |
415 | config()->writeEntry("user_name",mName); | 405 | config()->writeEntry("user_name",mName); |
416 | config()->writeEntry("user_email",mEmail); | 406 | config()->writeEntry("user_email",mEmail); |
417 | 407 | ||
418 | config()->setGroup("Category Colors"); | 408 | config()->setGroup("Category Colors"); |
419 | QDictIterator<QColor> it(mCategoryColors); | 409 | QDictIterator<QColor> it(mCategoryColors); |
420 | while (it.current()) { | 410 | while (it.current()) { |
421 | config()->writeEntry(it.currentKey(),*(it.current())); | 411 | config()->writeEntry(it.currentKey(),*(it.current())); |
422 | ++it; | 412 | ++it; |
423 | } | 413 | } |
424 | 414 | ||
425 | 415 | ||
426 | KPimPrefs::usrWriteConfig(); | 416 | KPimPrefs::usrWriteConfig(); |
427 | } | 417 | } |
428 | 418 | ||
429 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) | 419 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) |
430 | { | 420 | { |
431 | mCategoryColors.replace(cat,new QColor(color)); | 421 | mCategoryColors.replace(cat,new QColor(color)); |
432 | } | 422 | } |
433 | 423 | ||
434 | QColor *KOPrefs::categoryColor(QString cat) | 424 | QColor *KOPrefs::categoryColor(QString cat) |
435 | { | 425 | { |
436 | QColor *color = 0; | 426 | QColor *color = 0; |
437 | 427 | ||
438 | if (!cat.isEmpty()) color = mCategoryColors[cat]; | 428 | if (!cat.isEmpty()) color = mCategoryColors[cat]; |
439 | 429 | ||
440 | if (color) return color; | 430 | if (color) return color; |
441 | else return &mDefaultCategoryColor; | 431 | else return &mDefaultCategoryColor; |
442 | } | 432 | } |
443 | 433 | ||
444 | void KOPrefs::setFullName(const QString &name) | 434 | void KOPrefs::setFullName(const QString &name) |
445 | { | 435 | { |
446 | mName = name; | 436 | mName = name; |
447 | } | 437 | } |
448 | 438 | ||
449 | void KOPrefs::setEmail(const QString &email) | 439 | void KOPrefs::setEmail(const QString &email) |
450 | { | 440 | { |
451 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); | 441 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); |
452 | mEmail = email; | 442 | mEmail = email; |
453 | } | 443 | } |
454 | 444 | ||
455 | QString KOPrefs::fullName() | 445 | QString KOPrefs::fullName() |
456 | { | 446 | { |
457 | if (mEmailControlCenter) { | 447 | if (mEmailControlCenter) { |
458 | KEMailSettings settings; | 448 | KEMailSettings settings; |
459 | return settings.getSetting(KEMailSettings::RealName); | 449 | return settings.getSetting(KEMailSettings::RealName); |
460 | } else { | 450 | } else { |
461 | return mName; | 451 | return mName; |
462 | } | 452 | } |
463 | } | 453 | } |
464 | 454 | ||
465 | QString KOPrefs::email() | 455 | QString KOPrefs::email() |
466 | { | 456 | { |
467 | if (mEmailControlCenter) { | 457 | if (mEmailControlCenter) { |
468 | KEMailSettings settings; | 458 | KEMailSettings settings; |
469 | return settings.getSetting(KEMailSettings::EmailAddress); | 459 | return settings.getSetting(KEMailSettings::EmailAddress); |
470 | } else { | 460 | } else { |
471 | return mEmail; | 461 | return mEmail; |
472 | } | 462 | } |
473 | } | 463 | } |
474 | KConfig* KOPrefs::getConfig() | 464 | KConfig* KOPrefs::getConfig() |
475 | { | 465 | { |
476 | return config(); | 466 | return config(); |
477 | } | 467 | } |
diff --git a/korganizer/main.cpp b/korganizer/main.cpp index 4194d12..2481ca4 100644 --- a/korganizer/main.cpp +++ b/korganizer/main.cpp | |||
@@ -1,106 +1,109 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #ifndef DESKTOP_VERSION | 3 | #ifndef DESKTOP_VERSION |
4 | #include <qpe/qpeapplication.h> | 4 | #include <qpe/qpeapplication.h> |
5 | #include <qcopchannel_qws.h> | 5 | #include <qcopchannel_qws.h> |
6 | #include <qpe/global.h> | 6 | #include <qpe/global.h> |
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | #else | 8 | #else |
9 | #include <qapplication.h> | 9 | #include <qapplication.h> |
10 | #include <qstring.h> | 10 | #include <qstring.h> |
11 | #include <qwindowsstyle.h> | 11 | #include <qwindowsstyle.h> |
12 | #include <qplatinumstyle.h> | 12 | #include <qplatinumstyle.h> |
13 | #include <qsgistyle.h> | 13 | #include <qsgistyle.h> |
14 | #endif | 14 | #endif |
15 | #include <qtextcodec.h> | 15 | #include <qtextcodec.h> |
16 | 16 | ||
17 | #include <qdir.h> | 17 | #include <qdir.h> |
18 | #include <kstandarddirs.h> | 18 | #include <kstandarddirs.h> |
19 | #include <kglobal.h> | 19 | #include <kglobal.h> |
20 | #include <stdio.h> | 20 | #include <stdio.h> |
21 | #include "mainwindow.h" | 21 | #include "mainwindow.h" |
22 | #include <libkdepim/kpimglobalprefs.h> | ||
22 | void dumpMissing(); | 23 | void dumpMissing(); |
23 | int main( int argc, char **argv ) | 24 | int main( int argc, char **argv ) |
24 | { | 25 | { |
25 | #ifndef DESKTOP_VERSION | 26 | #ifndef DESKTOP_VERSION |
26 | QPEApplication a( argc, argv ); | 27 | QPEApplication a( argc, argv ); |
27 | a.setKeepRunning (); | 28 | a.setKeepRunning (); |
28 | #else | 29 | #else |
29 | QApplication a( argc, argv ); | 30 | QApplication a( argc, argv ); |
30 | QApplication::setStyle( new QPlatinumStyle ()); | 31 | QApplication::setStyle( new QPlatinumStyle ()); |
31 | QString hdir = QDir::homeDirPath(); | 32 | QString hdir = QDir::homeDirPath(); |
32 | // there is a bug when creating dirs for WIN 98 | 33 | // there is a bug when creating dirs for WIN 98 |
33 | // it is difficult to fix, because we have no WIN 98 runnung | 34 | // it is difficult to fix, because we have no WIN 98 runnung |
34 | // such that we try it to create the dirs at startup here | 35 | // such that we try it to create the dirs at startup here |
35 | if ( hdir == "C:\\" ) { // win 98 or ME | 36 | if ( hdir == "C:\\" ) { // win 98 or ME |
36 | QDir app_dir; | 37 | QDir app_dir; |
37 | if ( !app_dir.exists("C:\\kdepim") ) | 38 | if ( !app_dir.exists("C:\\kdepim") ) |
38 | app_dir.mkdir ("C:\\kdepim"); | 39 | app_dir.mkdir ("C:\\kdepim"); |
39 | if ( !app_dir.exists("C:\\kdepim\\apps") ) | 40 | if ( !app_dir.exists("C:\\kdepim\\apps") ) |
40 | app_dir.mkdir ("C:\\kdepim\\apps"); | 41 | app_dir.mkdir ("C:\\kdepim\\apps"); |
41 | if ( !app_dir.exists("C:\\kdepim\\config") ) | 42 | if ( !app_dir.exists("C:\\kdepim\\config") ) |
42 | app_dir.mkdir ("C:\\kdepim\\config"); | 43 | app_dir.mkdir ("C:\\kdepim\\config"); |
43 | if ( !app_dir.exists("C:\\kdepim\\apps\\korganizer") ) | 44 | if ( !app_dir.exists("C:\\kdepim\\apps\\korganizer") ) |
44 | app_dir.mkdir ("C:\\kdepim\\apps\\korganizer"); | 45 | app_dir.mkdir ("C:\\kdepim\\apps\\korganizer"); |
45 | } | 46 | } |
46 | #endif | 47 | #endif |
47 | bool exitHelp = false; | 48 | bool exitHelp = false; |
48 | if ( argc > 1 ) { | 49 | if ( argc > 1 ) { |
49 | QString command = argv[1]; | 50 | QString command = argv[1]; |
50 | if ( command == "-help" ){ | 51 | if ( command == "-help" ){ |
51 | printf("KO/Pi command line commands:\n"); | 52 | printf("KO/Pi command line commands:\n"); |
52 | printf(" no command: Start KO/Pi in usual way\n"); | 53 | printf(" no command: Start KO/Pi in usual way\n"); |
53 | printf(" -help: This output\n"); | 54 | printf(" -help: This output\n"); |
54 | printf("Next Option: Open or Show after start:\n"); | 55 | printf("Next Option: Open or Show after start:\n"); |
55 | printf(" -newTodo: New Todo dialog\n"); | 56 | printf(" -newTodo: New Todo dialog\n"); |
56 | printf(" -newEvent: New Event dialog\n"); | 57 | printf(" -newEvent: New Event dialog\n"); |
57 | printf(" -showList: List view\n"); | 58 | printf(" -showList: List view\n"); |
58 | printf(" -showDay: Day view\n"); | 59 | printf(" -showDay: Day view\n"); |
59 | printf(" -showWWeek: Work Week view\n"); | 60 | printf(" -showWWeek: Work Week view\n"); |
60 | printf(" -showWeek: Week view\n"); | 61 | printf(" -showWeek: Week view\n"); |
61 | printf(" -showTodo: Todo view\n"); | 62 | printf(" -showTodo: Todo view\n"); |
62 | printf(" -showJournal: Journal view\n"); | 63 | printf(" -showJournal: Journal view\n"); |
63 | printf(" -showKO: Next Days view\n"); | 64 | printf(" -showKO: Next Days view\n"); |
64 | printf(" -showWNext: What's Next view\n"); | 65 | printf(" -showWNext: What's Next view\n"); |
65 | printf(" -showNextXView: Next X View\n"); | 66 | printf(" -showNextXView: Next X View\n"); |
66 | printf(" -new[Y] and -show[X] may be used togehther\n"); | 67 | printf(" -new[Y] and -show[X] may be used togehther\n"); |
67 | printf(" KO/Pi is exiting now. Bye!\n"); | 68 | printf(" KO/Pi is exiting now. Bye!\n"); |
68 | exitHelp = true; | 69 | exitHelp = true; |
69 | } | 70 | } |
70 | } | 71 | } |
71 | if ( ! exitHelp ) { | 72 | if ( ! exitHelp ) { |
72 | KGlobal::setAppName( "korganizer" ); | 73 | KGlobal::setAppName( "korganizer" ); |
73 | QString fileName ; | 74 | QString fileName ; |
74 | #ifndef DESKTOP_VERSION | 75 | #ifndef DESKTOP_VERSION |
75 | fileName = getenv("QPEDIR"); | 76 | fileName = getenv("QPEDIR"); |
76 | KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/korganizer/"); | 77 | KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/korganizer/"); |
77 | #else | 78 | #else |
78 | fileName = qApp->applicationDirPath () + "/kdepim/korganizer/"; | 79 | fileName = qApp->applicationDirPath () + "/kdepim/korganizer/"; |
79 | KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); | 80 | KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); |
80 | #endif | 81 | #endif |
81 | KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "korganizer"))); | 82 | KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "korganizer"))); |
82 | MainWindow m; | 83 | MainWindow m; |
83 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
84 | 85 | ||
85 | QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& ))); | 86 | QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& ))); |
86 | a.showMainWidget(&m ); | 87 | a.showMainWidget(&m ); |
87 | #else | 88 | #else |
88 | a.setMainWidget(&m ); | 89 | a.setMainWidget(&m ); |
89 | m.show(); | 90 | m.show(); |
90 | //m.resize( 800, 600 ); | 91 | //m.resize( 800, 600 ); |
91 | QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); | 92 | QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); |
92 | #endif | 93 | #endif |
93 | if ( argc > 1 ) { | 94 | if ( argc > 1 ) { |
94 | QCString command = argv[1]; | 95 | QCString command = argv[1]; |
95 | if ( argc > 2 ) | 96 | if ( argc > 2 ) |
96 | command += argv[2]; | 97 | command += argv[2]; |
97 | qApp->processEvents(); | 98 | qApp->processEvents(); |
98 | m.recieve(command, QByteArray() ); | 99 | m.recieve(command, QByteArray() ); |
99 | 100 | ||
100 | } | 101 | } |
101 | 102 | ||
102 | a.exec(); | 103 | a.exec(); |
103 | dumpMissing(); | 104 | dumpMissing(); |
105 | |||
106 | KPimGlobalPrefs::instance()->writeConfig(); | ||
104 | } | 107 | } |
105 | qDebug("KO: Bye! "); | 108 | qDebug("KO: Bye! "); |
106 | } | 109 | } |
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp index 779b20e..9085673 100644 --- a/libkdepim/externalapphandler.cpp +++ b/libkdepim/externalapphandler.cpp | |||
@@ -1,1173 +1,1181 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2002 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 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | #include <stdlib.h> | 30 | #include <stdlib.h> |
31 | 31 | ||
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qmap.h> | 33 | #include <qmap.h> |
34 | #include <qregexp.h> | 34 | #include <qregexp.h> |
35 | 35 | ||
36 | #ifndef DESKTOP_VERSION | 36 | #ifndef DESKTOP_VERSION |
37 | #include <qpe/qpeapplication.h> | 37 | #include <qpe/qpeapplication.h> |
38 | #include <qtopia/qcopenvelope_qws.h> | 38 | #include <qtopia/qcopenvelope_qws.h> |
39 | #else | 39 | #else |
40 | #include <qapplication.h> | 40 | #include <qapplication.h> |
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | #include <kstaticdeleter.h> | 43 | #include <kstaticdeleter.h> |
44 | #include <kmessagebox.h> | 44 | #include <kmessagebox.h> |
45 | 45 | ||
46 | 46 | ||
47 | #include "externalapphandler.h" | 47 | #include "externalapphandler.h" |
48 | 48 | ||
49 | #include "kpimglobalprefs.h" | 49 | #include "kpimglobalprefs.h" |
50 | 50 | ||
51 | //uncomment line to get debug output | 51 | //uncomment line to get debug output |
52 | //#define DEBUG_EXT_APP_HANDLER | 52 | //#define DEBUG_EXT_APP_HANDLER |
53 | 53 | ||
54 | /********************************************************************************* | 54 | /********************************************************************************* |
55 | * | 55 | * |
56 | ********************************************************************************/ | 56 | ********************************************************************************/ |
57 | 57 | ||
58 | 58 | ||
59 | QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) | 59 | QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) |
60 | : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage) | 60 | : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage) |
61 | { | 61 | { |
62 | //sourceMessage passes later three parameters: sourceChannel, uid, param1 | 62 | //sourceMessage passes later three parameters: sourceChannel, uid, param1 |
63 | if (_usedSourceParameters == 0) | 63 | if (_usedSourceParameters == 0) |
64 | _sourceMessageParameters = "(QString,QString)"; | 64 | _sourceMessageParameters = "QString,QString)"; |
65 | else if (_usedSourceParameters == 1) | 65 | else if (_usedSourceParameters == 1) |
66 | _sourceMessageParameters = "(QString,QString,QString)"; | 66 | _sourceMessageParameters = "(QString,QString,QString)"; |
67 | else if (_usedSourceParameters == 2) | 67 | else if (_usedSourceParameters == 2) |
68 | _sourceMessageParameters = "(QString,QString,QString,QString)"; | 68 | _sourceMessageParameters = "(QString,QString,QString,QString)"; |
69 | else if (_usedSourceParameters == 3) | 69 | else if (_usedSourceParameters == 3) |
70 | _sourceMessageParameters = "(QString,QString,QString,QString,QString)"; | 70 | _sourceMessageParameters = "(QString,QString,QString,QString,QString)"; |
71 | } | 71 | } |
72 | 72 | ||
73 | /*********************************************************************************/ | 73 | /*********************************************************************************/ |
74 | 74 | ||
75 | QCopTransferItem::QCopTransferItem() | 75 | QCopTransferItem::QCopTransferItem() |
76 | { | 76 | { |
77 | } | 77 | } |
78 | 78 | ||
79 | /*********************************************************************************/ | 79 | /*********************************************************************************/ |
80 | bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3) | 80 | bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3) |
81 | { | 81 | { |
82 | 82 | ||
83 | #ifndef DESKTOP_VERSION | 83 | #ifndef DESKTOP_VERSION |
84 | //sourceMessage passes two parameters: sourceChannel, uid | 84 | //sourceMessage passes two parameters: sourceChannel, uid |
85 | QString sourceMessage = _sourceMessage + _sourceMessageParameters; | 85 | QString sourceMessage = _sourceMessage + _sourceMessageParameters; |
86 | #ifdef DEBUG_EXT_APP_HANDLER | 86 | #ifdef DEBUG_EXT_APP_HANDLER |
87 | qDebug("1Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.latin1()); | 87 | qDebug("1Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.latin1()); |
88 | qDebug("passing sourcechannel(%s), uid(%s), param1(%s), param2(%s), param3(%s) as parameter to QCopEnvelope", _sourceChannel.latin1(), uid.latin1(), param1.latin1(), param2.latin1(), param3.latin1()); | 88 | qDebug("passing sourcechannel(%s), uid(%s), param1(%s), param2(%s), param3(%s) as parameter to QCopEnvelope", _sourceChannel.latin1(), uid.latin1(), param1.latin1(), param2.latin1(), param3.latin1()); |
89 | #endif | 89 | #endif |
90 | 90 | ||
91 | QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1()); | 91 | QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1()); |
92 | 92 | ||
93 | e << _sourceChannel << uid; | 93 | e << _sourceChannel << uid; |
94 | 94 | ||
95 | if (_usedSourceParameters == 1) | 95 | if (_usedSourceParameters == 1) |
96 | e << param1; | 96 | e << param1; |
97 | else if (_usedSourceParameters == 2) | 97 | else if (_usedSourceParameters == 2) |
98 | e << param1 << param2; | 98 | e << param1 << param2; |
99 | else if (_usedSourceParameters == 3) | 99 | else if (_usedSourceParameters == 3) |
100 | e << param1 << param2 << param3; | 100 | e << param1 << param2 << param3; |
101 | 101 | ||
102 | qApp->processEvents(); | 102 | qApp->processEvents(); |
103 | 103 | ||
104 | return true; | 104 | return true; |
105 | 105 | ||
106 | #else | 106 | #else |
107 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); | 107 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); |
108 | return false; | 108 | return false; |
109 | #endif | 109 | #endif |
110 | 110 | ||
111 | } | 111 | } |
112 | 112 | ||
113 | 113 | ||
114 | /*********************************************************************************/ | 114 | /*********************************************************************************/ |
115 | void QCopTransferItem::setSourceChannel(const QString& sourceChannel) | 115 | void QCopTransferItem::setSourceChannel(const QString& sourceChannel) |
116 | { | 116 | { |
117 | 117 | ||
118 | if ( !sourceChannel.isEmpty()) | 118 | if ( !sourceChannel.isEmpty()) |
119 | _sourceChannel = sourceChannel; | 119 | _sourceChannel = sourceChannel; |
120 | } | 120 | } |
121 | 121 | ||
122 | 122 | ||
123 | /*********************************************************************************/ | 123 | /*********************************************************************************/ |
124 | bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) | 124 | bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) |
125 | { | 125 | { |
126 | 126 | ||
127 | // copied from old mail2 | 127 | // copied from old mail2 |
128 | /* | 128 | /* |
129 | static int ii = 0; | 129 | static int ii = 0; |
130 | 130 | ||
131 | // block second call | 131 | // block second call |
132 | if ( ii < 2 ) { | 132 | if ( ii < 2 ) { |
133 | ++ii; | 133 | ++ii; |
134 | if ( ii > 1 ) { | 134 | if ( ii > 1 ) { |
135 | qDebug("qcop call blocked "); | 135 | qDebug("qcop call blocked "); |
136 | return true; | 136 | return true; |
137 | } | 137 | } |
138 | } | 138 | } |
139 | */ | 139 | */ |
140 | 140 | ||
141 | // qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() ); | 141 | // qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() ); |
142 | 142 | ||
143 | //we are in the target and get a request from the source | 143 | //we are in the target and get a request from the source |
144 | if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data()) | 144 | if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data()) |
145 | { | 145 | { |
146 | 146 | ||
147 | QDataStream stream( data, IO_ReadOnly ); | 147 | QDataStream stream( data, IO_ReadOnly ); |
148 | 148 | ||
149 | 149 | ||
150 | QString sourceChannel; | 150 | QString sourceChannel; |
151 | QString uid; | 151 | QString uid; |
152 | QString param1; | 152 | QString param1; |
153 | QString param2; | 153 | QString param2; |
154 | QString param3; | 154 | QString param3; |
155 | 155 | ||
156 | stream >> sourceChannel >> uid; | 156 | stream >> sourceChannel >> uid; |
157 | 157 | ||
158 | if (_usedSourceParameters == 0) | 158 | if (_usedSourceParameters == 0) |
159 | { | 159 | { |
160 | emit receivedMessageFromSource(sourceChannel, uid); | 160 | emit receivedMessageFromSource(sourceChannel, uid); |
161 | } | 161 | } |
162 | else if (_usedSourceParameters == 1) | 162 | else if (_usedSourceParameters == 1) |
163 | { | 163 | { |
164 | stream >> param1; | 164 | stream >> param1; |
165 | emit receivedMessageFromSource(sourceChannel, uid, param1); | 165 | emit receivedMessageFromSource(sourceChannel, uid, param1); |
166 | } | 166 | } |
167 | else if (_usedSourceParameters == 2) | 167 | else if (_usedSourceParameters == 2) |
168 | { | 168 | { |
169 | stream >> param1 >> param2; | 169 | stream >> param1 >> param2; |
170 | emit receivedMessageFromSource(sourceChannel, uid, param1, param2); | 170 | emit receivedMessageFromSource(sourceChannel, uid, param1, param2); |
171 | } | 171 | } |
172 | else if (_usedSourceParameters == 3) | 172 | else if (_usedSourceParameters == 3) |
173 | { | 173 | { |
174 | stream >> param1 >> param2 >> param3; | 174 | stream >> param1 >> param2 >> param3; |
175 | emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3); | 175 | emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3); |
176 | } | 176 | } |
177 | 177 | ||
178 | return true; | 178 | return true; |
179 | } | 179 | } |
180 | 180 | ||
181 | return false; | 181 | return false; |
182 | } | 182 | } |
183 | 183 | ||
184 | 184 | ||
185 | /********************************************************************************* | 185 | /********************************************************************************* |
186 | * | 186 | * |
187 | ********************************************************************************/ | 187 | ********************************************************************************/ |
188 | 188 | ||
189 | 189 | ||
190 | QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) | 190 | QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) |
191 | : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) | 191 | : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) |
192 | { | 192 | { |
193 | //targetMessage returns later two parameters: uid, and map<qstring,qstring> | 193 | //targetMessage returns later two parameters: uid, and map<qstring,qstring> |
194 | _targetMessageParameters = "(QString,QMAP<QString,QString>)"; | 194 | _targetMessageParameters = "(QString,QMAP<QString,QString>)"; |
195 | } | 195 | } |
196 | 196 | ||
197 | /*********************************************************************************/ | 197 | /*********************************************************************************/ |
198 | bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap) | 198 | bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap) |
199 | { | 199 | { |
200 | #ifndef DESKTOP_VERSION | 200 | #ifndef DESKTOP_VERSION |
201 | //targetMessage passes two parameters: uid, map | 201 | //targetMessage passes two parameters: uid, map |
202 | QString targetMessage = _targetMessage + _targetMessageParameters; | 202 | QString targetMessage = _targetMessage + _targetMessageParameters; |
203 | 203 | ||
204 | #ifdef DEBUG_EXT_APP_HANDLER | 204 | #ifdef DEBUG_EXT_APP_HANDLER |
205 | qDebug("2Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); | 205 | qDebug("2Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); |
206 | qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1()); | 206 | qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1()); |
207 | #endif | 207 | #endif |
208 | 208 | ||
209 | QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); | 209 | QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); |
210 | //US we need no names in the To field. The emailadresses are enough | 210 | //US we need no names in the To field. The emailadresses are enough |
211 | 211 | ||
212 | e << uid << nameEmailMap; | 212 | e << uid << nameEmailMap; |
213 | 213 | ||
214 | qApp->processEvents(); | 214 | qApp->processEvents(); |
215 | 215 | ||
216 | return true; | 216 | return true; |
217 | 217 | ||
218 | #else | 218 | #else |
219 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); | 219 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); |
220 | return false; | 220 | return false; |
221 | #endif | 221 | #endif |
222 | 222 | ||
223 | } | 223 | } |
224 | 224 | ||
225 | 225 | ||
226 | /*********************************************************************************/ | 226 | /*********************************************************************************/ |
227 | bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) | 227 | bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) |
228 | { | 228 | { |
229 | bool res = QCopTransferItem::appMessage( cmsg, data ); | 229 | bool res = QCopTransferItem::appMessage( cmsg, data ); |
230 | 230 | ||
231 | if (res == false) | 231 | if (res == false) |
232 | { | 232 | { |
233 | QDataStream stream( data, IO_ReadOnly ); | 233 | QDataStream stream( data, IO_ReadOnly ); |
234 | 234 | ||
235 | // qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() ); | 235 | // qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() ); |
236 | 236 | ||
237 | //we are in the source and get an answer from the target | 237 | //we are in the source and get an answer from the target |
238 | if ((_targetMessage + _targetMessageParameters) == cmsg.data()) | 238 | if ((_targetMessage + _targetMessageParameters) == cmsg.data()) |
239 | { | 239 | { |
240 | QMap<QString,QString> adrMap; | 240 | QMap<QString,QString> adrMap; |
241 | QString uid; | 241 | QString uid; |
242 | 242 | ||
243 | stream >> uid >> adrMap; | 243 | stream >> uid >> adrMap; |
244 | 244 | ||
245 | emit receivedMessageFromTarget(uid, adrMap); | 245 | emit receivedMessageFromTarget(uid, adrMap); |
246 | 246 | ||
247 | 247 | ||
248 | return true; | 248 | return true; |
249 | } | 249 | } |
250 | } | 250 | } |
251 | 251 | ||
252 | return false; | 252 | return false; |
253 | } | 253 | } |
254 | 254 | ||
255 | 255 | ||
256 | /********************************************************************************* | 256 | /********************************************************************************* |
257 | * | 257 | * |
258 | ********************************************************************************/ | 258 | ********************************************************************************/ |
259 | 259 | ||
260 | QCopListTransferItem::~QCopListTransferItem() | ||
261 | { | ||
262 | |||
263 | } | ||
260 | 264 | ||
261 | QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) | 265 | QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) |
262 | : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) | 266 | : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) |
263 | { | 267 | { |
264 | //targetMessage returns later two parameters: uid, and three lists | 268 | //targetMessage returns later two parameters: uid, and three lists |
265 | _targetMessageParameters = "(QString,QStringList,QStringList,QStringList,QStringList,QStringList,QStringList)"; | 269 | _targetMessageParameters = "(QString,QStringList,QStringList,QStringList,QStringList,QStringList,QStringList)"; |
266 | } | 270 | } |
267 | 271 | ||
268 | /*********************************************************************************/ | 272 | /*********************************************************************************/ |
269 | bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6) | 273 | bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6) |
270 | { | 274 | { |
271 | #ifndef DESKTOP_VERSION | 275 | #ifndef DESKTOP_VERSION |
272 | //targetMessage passes two parameters: uid, map | 276 | //targetMessage passes two parameters: uid, map |
273 | QString targetMessage = _targetMessage + _targetMessageParameters; | 277 | QString targetMessage = _targetMessage + _targetMessageParameters; |
274 | 278 | ||
275 | #ifdef DEBUG_EXT_APP_HANDLER | 279 | #ifdef DEBUG_EXT_APP_HANDLER |
276 | qDebug("3Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); | 280 | qDebug("3Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); |
277 | qDebug("passing uid(%s) and list1, list2, list3, list4, list5, list6 as parameter to QCopEnvelope", uid.latin1()); | 281 | qDebug("passing uid(%s) and list1, list2, list3, list4, list5, list6 as parameter to QCopEnvelope", uid.latin1()); |
278 | 282 | ||
279 | 283 | ||
280 | for ( int i = 0; i < list3.count(); i++) | 284 | for ( int i = 0; i < list3.count(); i++) |
281 | qDebug("listentry list3: %s",list3[i].latin1()); | 285 | qDebug("listentry list3: %s",list3[i].latin1()); |
282 | #endif | 286 | #endif |
283 | 287 | ||
284 | QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); | 288 | QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); |
285 | //US we need no names in the To field. The emailadresses are enough | 289 | //US we need no names in the To field. The emailadresses are enough |
286 | 290 | ||
287 | e << uid << list1 << list2 << list3 << list4 << list5 << list6; | 291 | e << uid << list1 << list2 << list3 << list4 << list5 << list6; |
288 | 292 | ||
289 | qApp->processEvents(); | 293 | qApp->processEvents(); |
290 | 294 | ||
291 | return true; | 295 | return true; |
292 | 296 | ||
293 | #else | 297 | #else |
294 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); | 298 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); |
295 | return false; | 299 | return false; |
296 | #endif | 300 | #endif |
297 | 301 | ||
298 | } | 302 | } |
299 | 303 | ||
300 | 304 | ||
301 | /*********************************************************************************/ | 305 | /*********************************************************************************/ |
302 | bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) | 306 | bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) |
303 | { | 307 | { |
304 | bool res = QCopTransferItem::appMessage( cmsg, data ); | 308 | bool res = QCopTransferItem::appMessage( cmsg, data ); |
305 | #ifdef DEBUG_EXT_APP_HANDLER | 309 | #ifdef DEBUG_EXT_APP_HANDLER |
306 | qDebug("1QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); | 310 | qDebug("1QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); |
307 | #endif | 311 | #endif |
308 | 312 | ||
309 | if (res == false) | 313 | if (res == false) |
310 | { | 314 | { |
311 | QDataStream stream( data, IO_ReadOnly ); | 315 | QDataStream stream( data, IO_ReadOnly ); |
312 | 316 | ||
313 | #ifdef DEBUG_EXT_APP_HANDLER | 317 | #ifdef DEBUG_EXT_APP_HANDLER |
314 | qDebug("2QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); | 318 | qDebug("2QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); |
315 | #endif | 319 | #endif |
316 | 320 | ||
317 | //we are in the source and get an answer from the target | 321 | //we are in the source and get an answer from the target |
318 | if ((_targetMessage + _targetMessageParameters) == cmsg.data()) | 322 | if ((_targetMessage + _targetMessageParameters) == cmsg.data()) |
319 | { | 323 | { |
320 | QStringList list1; | 324 | QStringList list1; |
321 | QStringList list2; | 325 | QStringList list2; |
322 | QStringList list3; | 326 | QStringList list3; |
323 | QStringList list4; | 327 | QStringList list4; |
324 | QStringList list5; | 328 | QStringList list5; |
325 | QStringList list6; | 329 | QStringList list6; |
326 | QString uid; | 330 | QString uid; |
327 | 331 | ||
328 | #ifdef DEBUG_EXT_APP_HANDLER | 332 | #ifdef DEBUG_EXT_APP_HANDLER |
329 | qDebug("3QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); | 333 | qDebug("3QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); |
330 | #endif | 334 | #endif |
331 | 335 | ||
332 | stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6; | 336 | stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6; |
333 | emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6); | 337 | emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6); |
334 | 338 | ||
335 | 339 | ||
336 | return true; | 340 | return true; |
337 | } | 341 | } |
338 | } | 342 | } |
339 | 343 | ||
340 | return false; | 344 | return false; |
341 | } | 345 | } |
342 | 346 | ||
343 | 347 | ||
344 | 348 | ||
345 | /********************************************************************************* | 349 | /********************************************************************************* |
346 | * | 350 | * |
347 | ********************************************************************************/ | 351 | ********************************************************************************/ |
348 | 352 | ||
349 | 353 | ||
350 | ExternalAppHandler *ExternalAppHandler::sInstance = 0; | 354 | ExternalAppHandler *ExternalAppHandler::sInstance = 0; |
351 | static KStaticDeleter<ExternalAppHandler> staticDeleter; | 355 | static KStaticDeleter<ExternalAppHandler> staticDeleter; |
352 | 356 | ||
353 | ExternalAppHandler::ExternalAppHandler() | 357 | ExternalAppHandler::ExternalAppHandler() |
354 | { | 358 | { |
355 | mDefaultItems.setAutoDelete(true); | 359 | mDefaultItems.setAutoDelete(true); |
356 | 360 | ||
357 | mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList"); | 361 | mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList"); |
358 | connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&))); | 362 | connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&))); |
359 | connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SLOT (receivedNameEmailUidList_Slot(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 363 | connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SLOT (receivedNameEmailUidList_Slot(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
360 | 364 | ||
361 | //US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList"); | 365 | //US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList"); |
362 | //US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&))); | 366 | //US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&))); |
363 | //US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); | 367 | //US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); |
364 | 368 | ||
365 | mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", ""); | 369 | mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", ""); |
366 | connect(mDisplayDetails, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&, const QString&, const QString&)), this, SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); | 370 | connect(mDisplayDetails, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&, const QString&, const QString&)), this, SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); |
367 | 371 | ||
368 | 372 | ||
369 | 373 | ||
370 | mBirthdayListFromKAPITransfer = new QCopListTransferItem(0, "requestBirthdayListFromKAPI", "QPE/Application/kapi", "receiveBirthdayList"); | 374 | mBirthdayListFromKAPITransfer = new QCopListTransferItem(0, "requestBirthdayListFromKAPI", "QPE/Application/kapi", "receiveBirthdayList"); |
371 | connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForBirthdayList(const QString&, const QString&))); | 375 | connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForBirthdayList(const QString&, const QString&))); |
372 | connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 376 | connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
373 | 377 | ||
374 | 378 | ||
375 | } | 379 | } |
376 | 380 | ||
377 | ExternalAppHandler::~ExternalAppHandler() | 381 | ExternalAppHandler::~ExternalAppHandler() |
378 | { | 382 | { |
383 | delete mNameEmailUidListFromKAPITransfer; | ||
384 | //delete mFindByEmailFromKAPITransfer; | ||
385 | delete mDisplayDetails; | ||
386 | delete mBirthdayListFromKAPITransfer; | ||
379 | } | 387 | } |
380 | 388 | ||
381 | void ExternalAppHandler::receivedNameEmailUidList_Slot(const QString& uid, | 389 | void ExternalAppHandler::receivedNameEmailUidList_Slot(const QString& uid, |
382 | const QStringList& nameList, | 390 | const QStringList& nameList, |
383 | const QStringList& emailList, | 391 | const QStringList& emailList, |
384 | const QStringList& uidList, | 392 | const QStringList& uidList, |
385 | const QStringList&, | 393 | const QStringList&, |
386 | const QStringList&, | 394 | const QStringList&, |
387 | const QStringList& ) | 395 | const QStringList& ) |
388 | { | 396 | { |
389 | // this method is a conevnient way to reduce the number of parameters I have to pass | 397 | // this method is a conevnient way to reduce the number of parameters I have to pass |
390 | emit receivedNameEmailUidListEvent(uid, nameList, emailList, uidList); | 398 | emit receivedNameEmailUidListEvent(uid, nameList, emailList, uidList); |
391 | } | 399 | } |
392 | 400 | ||
393 | 401 | ||
394 | void ExternalAppHandler::loadConfig() | 402 | void ExternalAppHandler::loadConfig() |
395 | { | 403 | { |
396 | 404 | ||
397 | mDefaultItems.clear(); | 405 | mDefaultItems.clear(); |
398 | mEmailAppAvailable = UNDEFINED; | 406 | mEmailAppAvailable = UNDEFINED; |
399 | mPhoneAppAvailable = UNDEFINED; | 407 | mPhoneAppAvailable = UNDEFINED; |
400 | mFaxAppAvailable = UNDEFINED; | 408 | mFaxAppAvailable = UNDEFINED; |
401 | mSMSAppAvailable = UNDEFINED; | 409 | mSMSAppAvailable = UNDEFINED; |
402 | mPagerAppAvailable = UNDEFINED; | 410 | mPagerAppAvailable = UNDEFINED; |
403 | mSIPAppAvailable = UNDEFINED; | 411 | mSIPAppAvailable = UNDEFINED; |
404 | 412 | ||
405 | QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); | 413 | QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); |
406 | QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); | 414 | QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); |
407 | 415 | ||
408 | if (opiepath.isEmpty()) | 416 | if (opiepath.isEmpty()) |
409 | opiepath = qtopiapath; | 417 | opiepath = qtopiapath; |
410 | 418 | ||
411 | //mailclients | 419 | //mailclients |
412 | QString mailmsg1 = "writeMail(QString,QString)"; | 420 | QString mailmsg1 = "writeMail(QString,QString)"; |
413 | QString mailmsg2 = "writeMail(QMap(QString,QString))"; | 421 | QString mailmsg2 = "writeMail(QMap(QString,QString))"; |
414 | 422 | ||
415 | QString undefined = ""; | 423 | QString undefined = ""; |
416 | 424 | ||
417 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); | 425 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); |
418 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); | 426 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); |
419 | 427 | ||
420 | if (( QFile::exists( qtopiapath + "/bin/ompi" )) || | 428 | if (( QFile::exists( qtopiapath + "/bin/ompi" )) || |
421 | ( QFile::exists( opiepath + "/bin/ompi" ))) | 429 | ( QFile::exists( opiepath + "/bin/ompi" ))) |
422 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 430 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
423 | 431 | ||
424 | if ( QFile::exists( qtopiapath + "/bin/qtmail" )) | 432 | if ( QFile::exists( qtopiapath + "/bin/qtmail" )) |
425 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 433 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
426 | 434 | ||
427 | if ( QFile::exists( opiepath + "/bin/opiemail" )) | 435 | if ( QFile::exists( opiepath + "/bin/opiemail" )) |
428 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 436 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
429 | 437 | ||
430 | 438 | ||
431 | 439 | ||
432 | //phoneclients | 440 | //phoneclients |
433 | 441 | ||
434 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); | 442 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); |
435 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); | 443 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); |
436 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || | 444 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || |
437 | ( QFile::exists( opiepath + "/bin/kppi" ))) | 445 | ( QFile::exists( opiepath + "/bin/kppi" ))) |
438 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); | 446 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); |
439 | 447 | ||
440 | //faxclients | 448 | //faxclients |
441 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); | 449 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); |
442 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); | 450 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); |
443 | 451 | ||
444 | //smsclients | 452 | //smsclients |
445 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); | 453 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); |
446 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); | 454 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); |
447 | 455 | ||
448 | //pagerclients | 456 | //pagerclients |
449 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); | 457 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); |
450 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); | 458 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); |
451 | 459 | ||
452 | //sipclients | 460 | //sipclients |
453 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No SIP client installed", undefined, undefined, undefined, undefined, undefined); | 461 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No SIP client installed", undefined, undefined, undefined, undefined, undefined); |
454 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other SIP client", undefined, undefined, undefined, undefined, undefined); | 462 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other SIP client", undefined, undefined, undefined, undefined, undefined); |
455 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || | 463 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || |
456 | ( QFile::exists( opiepath + "/bin/kppi" ))) | 464 | ( QFile::exists( opiepath + "/bin/kppi" ))) |
457 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::KPPI_SIC, "KP/Pi SIP client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); | 465 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::KPPI_SIC, "KP/Pi SIP client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); |
458 | 466 | ||
459 | } | 467 | } |
460 | 468 | ||
461 | ExternalAppHandler *ExternalAppHandler::instance() | 469 | ExternalAppHandler *ExternalAppHandler::instance() |
462 | { | 470 | { |
463 | if ( !sInstance ) { | 471 | if ( !sInstance ) { |
464 | sInstance = staticDeleter.setObject( new ExternalAppHandler() ); | 472 | sInstance = staticDeleter.setObject( new ExternalAppHandler() ); |
465 | sInstance->loadConfig(); | 473 | sInstance->loadConfig(); |
466 | } | 474 | } |
467 | 475 | ||
468 | return sInstance; | 476 | return sInstance; |
469 | } | 477 | } |
470 | 478 | ||
471 | void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2) | 479 | void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2) |
472 | { | 480 | { |
473 | DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); | 481 | DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); |
474 | // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() ); | 482 | // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() ); |
475 | mDefaultItems.append(dai); | 483 | mDefaultItems.append(dai); |
476 | } | 484 | } |
477 | 485 | ||
478 | 486 | ||
479 | QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) | 487 | QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) |
480 | { | 488 | { |
481 | QList<DefaultAppItem> list; | 489 | QList<DefaultAppItem> list; |
482 | 490 | ||
483 | DefaultAppItem* dai; | 491 | DefaultAppItem* dai; |
484 | 492 | ||
485 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) | 493 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) |
486 | { | 494 | { |
487 | if (dai->_type == type) | 495 | if (dai->_type == type) |
488 | list.append(dai); | 496 | list.append(dai); |
489 | } | 497 | } |
490 | 498 | ||
491 | return list; | 499 | return list; |
492 | } | 500 | } |
493 | 501 | ||
494 | DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) | 502 | DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) |
495 | { | 503 | { |
496 | DefaultAppItem* dai; | 504 | DefaultAppItem* dai; |
497 | 505 | ||
498 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) | 506 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) |
499 | { | 507 | { |
500 | if (dai->_type == type && dai->_id == clientid) | 508 | if (dai->_type == type && dai->_id == clientid) |
501 | return dai; | 509 | return dai; |
502 | } | 510 | } |
503 | 511 | ||
504 | return 0; | 512 | return 0; |
505 | } | 513 | } |
506 | 514 | ||
507 | bool ExternalAppHandler::isEmailAppAvailable() | 515 | bool ExternalAppHandler::isEmailAppAvailable() |
508 | { | 516 | { |
509 | #ifndef DESKTOP_VERSION | 517 | #ifndef DESKTOP_VERSION |
510 | if (mEmailAppAvailable == UNDEFINED) | 518 | if (mEmailAppAvailable == UNDEFINED) |
511 | { | 519 | { |
512 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 520 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
513 | if (client == KPimGlobalPrefs::NONE_EMC) | 521 | if (client == KPimGlobalPrefs::NONE_EMC) |
514 | mEmailAppAvailable = UNAVAILABLE; | 522 | mEmailAppAvailable = UNAVAILABLE; |
515 | else | 523 | else |
516 | mEmailAppAvailable = AVAILABLE; | 524 | mEmailAppAvailable = AVAILABLE; |
517 | } | 525 | } |
518 | return (mEmailAppAvailable == AVAILABLE); | 526 | return (mEmailAppAvailable == AVAILABLE); |
519 | 527 | ||
520 | #else //DESKTOP_VERSION | 528 | #else //DESKTOP_VERSION |
521 | return false; | 529 | return false; |
522 | #endif //DESKTOP_VERSION | 530 | #endif //DESKTOP_VERSION |
523 | } | 531 | } |
524 | 532 | ||
525 | bool ExternalAppHandler::isSMSAppAvailable() | 533 | bool ExternalAppHandler::isSMSAppAvailable() |
526 | { | 534 | { |
527 | #ifndef DESKTOP_VERSION | 535 | #ifndef DESKTOP_VERSION |
528 | if (mSMSAppAvailable == UNDEFINED) | 536 | if (mSMSAppAvailable == UNDEFINED) |
529 | { | 537 | { |
530 | int client = KPimGlobalPrefs::instance()->mSMSClient; | 538 | int client = KPimGlobalPrefs::instance()->mSMSClient; |
531 | if (client == KPimGlobalPrefs::NONE_SMC) | 539 | if (client == KPimGlobalPrefs::NONE_SMC) |
532 | mSMSAppAvailable = UNAVAILABLE; | 540 | mSMSAppAvailable = UNAVAILABLE; |
533 | else | 541 | else |
534 | mSMSAppAvailable = AVAILABLE; | 542 | mSMSAppAvailable = AVAILABLE; |
535 | } | 543 | } |
536 | 544 | ||
537 | return (mSMSAppAvailable == AVAILABLE); | 545 | return (mSMSAppAvailable == AVAILABLE); |
538 | #else //DESKTOP_VERSION | 546 | #else //DESKTOP_VERSION |
539 | return false; | 547 | return false; |
540 | #endif //DESKTOP_VERSION | 548 | #endif //DESKTOP_VERSION |
541 | } | 549 | } |
542 | 550 | ||
543 | bool ExternalAppHandler::isPhoneAppAvailable() | 551 | bool ExternalAppHandler::isPhoneAppAvailable() |
544 | { | 552 | { |
545 | #ifndef DESKTOP_VERSION | 553 | #ifndef DESKTOP_VERSION |
546 | if (mPhoneAppAvailable == UNDEFINED) | 554 | if (mPhoneAppAvailable == UNDEFINED) |
547 | { | 555 | { |
548 | int client = KPimGlobalPrefs::instance()->mPhoneClient; | 556 | int client = KPimGlobalPrefs::instance()->mPhoneClient; |
549 | if (client == KPimGlobalPrefs::NONE_PHC) | 557 | if (client == KPimGlobalPrefs::NONE_PHC) |
550 | mPhoneAppAvailable = UNAVAILABLE; | 558 | mPhoneAppAvailable = UNAVAILABLE; |
551 | else | 559 | else |
552 | mPhoneAppAvailable = AVAILABLE; | 560 | mPhoneAppAvailable = AVAILABLE; |
553 | } | 561 | } |
554 | 562 | ||
555 | return (mPhoneAppAvailable == AVAILABLE); | 563 | return (mPhoneAppAvailable == AVAILABLE); |
556 | #else //DESKTOP_VERSION | 564 | #else //DESKTOP_VERSION |
557 | return false; | 565 | return false; |
558 | #endif //DESKTOP_VERSION | 566 | #endif //DESKTOP_VERSION |
559 | } | 567 | } |
560 | 568 | ||
561 | bool ExternalAppHandler::isFaxAppAvailable() | 569 | bool ExternalAppHandler::isFaxAppAvailable() |
562 | { | 570 | { |
563 | #ifndef DESKTOP_VERSION | 571 | #ifndef DESKTOP_VERSION |
564 | if (mFaxAppAvailable == UNDEFINED) | 572 | if (mFaxAppAvailable == UNDEFINED) |
565 | { | 573 | { |
566 | int client = KPimGlobalPrefs::instance()->mFaxClient; | 574 | int client = KPimGlobalPrefs::instance()->mFaxClient; |
567 | if (client == KPimGlobalPrefs::NONE_FAC) | 575 | if (client == KPimGlobalPrefs::NONE_FAC) |
568 | mFaxAppAvailable = UNAVAILABLE; | 576 | mFaxAppAvailable = UNAVAILABLE; |
569 | else | 577 | else |
570 | mFaxAppAvailable = AVAILABLE; | 578 | mFaxAppAvailable = AVAILABLE; |
571 | } | 579 | } |
572 | 580 | ||
573 | return (mFaxAppAvailable == AVAILABLE); | 581 | return (mFaxAppAvailable == AVAILABLE); |
574 | #else //DESKTOP_VERSION | 582 | #else //DESKTOP_VERSION |
575 | return false; | 583 | return false; |
576 | #endif //DESKTOP_VERSION | 584 | #endif //DESKTOP_VERSION |
577 | } | 585 | } |
578 | 586 | ||
579 | bool ExternalAppHandler::isPagerAppAvailable() | 587 | bool ExternalAppHandler::isPagerAppAvailable() |
580 | { | 588 | { |
581 | #ifndef DESKTOP_VERSION | 589 | #ifndef DESKTOP_VERSION |
582 | if (mPagerAppAvailable == UNDEFINED) | 590 | if (mPagerAppAvailable == UNDEFINED) |
583 | { | 591 | { |
584 | int client = KPimGlobalPrefs::instance()->mPagerClient; | 592 | int client = KPimGlobalPrefs::instance()->mPagerClient; |
585 | if (client == KPimGlobalPrefs::NONE_PAC) | 593 | if (client == KPimGlobalPrefs::NONE_PAC) |
586 | mPagerAppAvailable = UNAVAILABLE; | 594 | mPagerAppAvailable = UNAVAILABLE; |
587 | else | 595 | else |
588 | mPagerAppAvailable = AVAILABLE; | 596 | mPagerAppAvailable = AVAILABLE; |
589 | } | 597 | } |
590 | 598 | ||
591 | return (mPagerAppAvailable == AVAILABLE); | 599 | return (mPagerAppAvailable == AVAILABLE); |
592 | #else //DESKTOP_VERSION | 600 | #else //DESKTOP_VERSION |
593 | return false; | 601 | return false; |
594 | #endif //DESKTOP_VERSION | 602 | #endif //DESKTOP_VERSION |
595 | } | 603 | } |
596 | 604 | ||
597 | 605 | ||
598 | bool ExternalAppHandler::isSIPAppAvailable() | 606 | bool ExternalAppHandler::isSIPAppAvailable() |
599 | { | 607 | { |
600 | #ifndef DESKTOP_VERSION | 608 | #ifndef DESKTOP_VERSION |
601 | if (mSIPAppAvailable == UNDEFINED) | 609 | if (mSIPAppAvailable == UNDEFINED) |
602 | { | 610 | { |
603 | int client = KPimGlobalPrefs::instance()->mSipClient; | 611 | int client = KPimGlobalPrefs::instance()->mSipClient; |
604 | if (client == KPimGlobalPrefs::NONE_SIC) | 612 | if (client == KPimGlobalPrefs::NONE_SIC) |
605 | mSIPAppAvailable = UNAVAILABLE; | 613 | mSIPAppAvailable = UNAVAILABLE; |
606 | else | 614 | else |
607 | mSIPAppAvailable = AVAILABLE; | 615 | mSIPAppAvailable = AVAILABLE; |
608 | } | 616 | } |
609 | 617 | ||
610 | return (mSIPAppAvailable == AVAILABLE); | 618 | return (mSIPAppAvailable == AVAILABLE); |
611 | #else //DESKTOP_VERSION | 619 | #else //DESKTOP_VERSION |
612 | return false; | 620 | return false; |
613 | #endif //DESKTOP_VERSION | 621 | #endif //DESKTOP_VERSION |
614 | } | 622 | } |
615 | 623 | ||
616 | /************************************************************************** | 624 | /************************************************************************** |
617 | * | 625 | * |
618 | **************************************************************************/ | 626 | **************************************************************************/ |
619 | 627 | ||
620 | 628 | ||
621 | //calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) | 629 | //calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) |
622 | bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) | 630 | bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) |
623 | { | 631 | { |
624 | 632 | ||
625 | #ifndef DESKTOP_VERSION | 633 | #ifndef DESKTOP_VERSION |
626 | QString channel; | 634 | QString channel; |
627 | QString message2; | 635 | QString message2; |
628 | QString parameters2; | 636 | QString parameters2; |
629 | 637 | ||
630 | 638 | ||
631 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 639 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
632 | if (client == KPimGlobalPrefs::OTHER_EMC) | 640 | if (client == KPimGlobalPrefs::OTHER_EMC) |
633 | { | 641 | { |
634 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; | 642 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; |
635 | message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; | 643 | message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; |
636 | parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | 644 | parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; |
637 | } | 645 | } |
638 | else | 646 | else |
639 | { | 647 | { |
640 | DefaultAppItem* dai = getDefaultItem(EMAIL, client); | 648 | DefaultAppItem* dai = getDefaultItem(EMAIL, client); |
641 | if (!dai) | 649 | if (!dai) |
642 | { | 650 | { |
643 | qDebug("could not find configured email application."); | 651 | qDebug("could not find configured email application."); |
644 | return false; | 652 | return false; |
645 | } | 653 | } |
646 | channel = dai->_channel; | 654 | channel = dai->_channel; |
647 | message2 = dai->_message2; | 655 | message2 = dai->_message2; |
648 | parameters2 = dai->_parameters2; | 656 | parameters2 = dai->_parameters2; |
649 | } | 657 | } |
650 | 658 | ||
651 | //first check if one of the mailers need the emails right in the message. | 659 | //first check if one of the mailers need the emails right in the message. |
652 | message2 = translateMessage(message2, emails, urls); | 660 | message2 = translateMessage(message2, emails, urls); |
653 | 661 | ||
654 | 662 | ||
655 | #ifdef DEBUG_EXT_APP_HANDLER | 663 | #ifdef DEBUG_EXT_APP_HANDLER |
656 | qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); | 664 | qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); |
657 | qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); | 665 | qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); |
658 | #endif | 666 | #endif |
659 | 667 | ||
660 | 668 | ||
661 | QCopEnvelope e(channel.latin1(), message2.latin1()); | 669 | QCopEnvelope e(channel.latin1(), message2.latin1()); |
662 | //US we need no names in the To field. The emailadresses are enough | 670 | //US we need no names in the To field. The emailadresses are enough |
663 | 671 | ||
664 | passParameters(&e, parameters2, emails, urls); | 672 | passParameters(&e, parameters2, emails, urls); |
665 | 673 | ||
666 | 674 | ||
667 | 675 | ||
668 | #else | 676 | #else |
669 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); | 677 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); |
670 | #endif | 678 | #endif |
671 | 679 | ||
672 | return true; | 680 | return true; |
673 | } | 681 | } |
674 | 682 | ||
675 | /************************************************************************** | 683 | /************************************************************************** |
676 | * | 684 | * |
677 | **************************************************************************/ | 685 | **************************************************************************/ |
678 | 686 | ||
679 | 687 | ||
680 | //calls the emailapplication and creates a mail with parameter emails as recipients | 688 | //calls the emailapplication and creates a mail with parameter emails as recipients |
681 | bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) | 689 | bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) |
682 | { | 690 | { |
683 | #ifndef DESKTOP_VERSION | 691 | #ifndef DESKTOP_VERSION |
684 | QString channel; | 692 | QString channel; |
685 | QString message; | 693 | QString message; |
686 | QString parameters; | 694 | QString parameters; |
687 | 695 | ||
688 | 696 | ||
689 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 697 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
690 | if (client == KPimGlobalPrefs::OTHER_EMC) | 698 | if (client == KPimGlobalPrefs::OTHER_EMC) |
691 | { | 699 | { |
692 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; | 700 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; |
693 | message = KPimGlobalPrefs::instance()->mEmailOtherMessage; | 701 | message = KPimGlobalPrefs::instance()->mEmailOtherMessage; |
694 | parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | 702 | parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; |
695 | } | 703 | } |
696 | else | 704 | else |
697 | { | 705 | { |
698 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); | 706 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); |
699 | if (!dai) | 707 | if (!dai) |
700 | { | 708 | { |
701 | qDebug("could not find configured email application."); | 709 | qDebug("could not find configured email application."); |
702 | return false; | 710 | return false; |
703 | } | 711 | } |
704 | channel = dai->_channel; | 712 | channel = dai->_channel; |
705 | message = dai->_message; | 713 | message = dai->_message; |
706 | parameters = dai->_parameters; | 714 | parameters = dai->_parameters; |
707 | } | 715 | } |
708 | 716 | ||
709 | 717 | ||
710 | //first check if one of the mailers need the emails right in the message. | 718 | //first check if one of the mailers need the emails right in the message. |
711 | message = translateMessage(message, name, emailadress); | 719 | message = translateMessage(message, name, emailadress); |
712 | 720 | ||
713 | 721 | ||
714 | #ifdef DEBUG_EXT_APP_HANDLER | 722 | #ifdef DEBUG_EXT_APP_HANDLER |
715 | qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 723 | qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
716 | qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); | 724 | qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); |
717 | #endif | 725 | #endif |
718 | 726 | ||
719 | QCopEnvelope e(channel.latin1(), message.latin1()); | 727 | QCopEnvelope e(channel.latin1(), message.latin1()); |
720 | //US we need no names in the To field. The emailadresses are enough | 728 | //US we need no names in the To field. The emailadresses are enough |
721 | 729 | ||
722 | passParameters(&e, parameters, name, emailadress); | 730 | passParameters(&e, parameters, name, emailadress); |
723 | 731 | ||
724 | 732 | ||
725 | #else | 733 | #else |
726 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); | 734 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); |
727 | #endif | 735 | #endif |
728 | 736 | ||
729 | 737 | ||
730 | return true; | 738 | return true; |
731 | } | 739 | } |
732 | 740 | ||
733 | /************************************************************************** | 741 | /************************************************************************** |
734 | * | 742 | * |
735 | **************************************************************************/ | 743 | **************************************************************************/ |
736 | 744 | ||
737 | //calls the emailapplication and creates a mail with parameter as recipients | 745 | //calls the emailapplication and creates a mail with parameter as recipients |
738 | // parameters format is | 746 | // parameters format is |
739 | // NAME <EMAIL>:SUBJECT | 747 | // NAME <EMAIL>:SUBJECT |
740 | bool ExternalAppHandler::mailToOneContact( const QString& adressline ) | 748 | bool ExternalAppHandler::mailToOneContact( const QString& adressline ) |
741 | { | 749 | { |
742 | QString line = adressline; | 750 | QString line = adressline; |
743 | 751 | ||
744 | int first = line.find( "<"); | 752 | int first = line.find( "<"); |
745 | int last = line.find( ">"); | 753 | int last = line.find( ">"); |
746 | QString name = line.left(first); | 754 | QString name = line.left(first); |
747 | QString emailadress = line.mid(first+1, last-first-1); | 755 | QString emailadress = line.mid(first+1, last-first-1); |
748 | 756 | ||
749 | //Subject can not be handled right now. | 757 | //Subject can not be handled right now. |
750 | return mailToOneContact( name, emailadress ); | 758 | return mailToOneContact( name, emailadress ); |
751 | 759 | ||
752 | } | 760 | } |
753 | 761 | ||
754 | 762 | ||
755 | /************************************************************************** | 763 | /************************************************************************** |
756 | * | 764 | * |
757 | **************************************************************************/ | 765 | **************************************************************************/ |
758 | 766 | ||
759 | //calls the phoneapplication with the number | 767 | //calls the phoneapplication with the number |
760 | bool ExternalAppHandler::callByPhone( const QString& phonenumber ) | 768 | bool ExternalAppHandler::callByPhone( const QString& phonenumber ) |
761 | { | 769 | { |
762 | #ifndef DESKTOP_VERSION | 770 | #ifndef DESKTOP_VERSION |
763 | QString channel; | 771 | QString channel; |
764 | QString message; | 772 | QString message; |
765 | QString parameters; | 773 | QString parameters; |
766 | 774 | ||
767 | 775 | ||
768 | int client = KPimGlobalPrefs::instance()->mPhoneClient; | 776 | int client = KPimGlobalPrefs::instance()->mPhoneClient; |
769 | if (client == KPimGlobalPrefs::OTHER_PHC) | 777 | if (client == KPimGlobalPrefs::OTHER_PHC) |
770 | { | 778 | { |
771 | channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; | 779 | channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; |
772 | message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; | 780 | message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; |
773 | parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; | 781 | parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; |
774 | } | 782 | } |
775 | else | 783 | else |
776 | { | 784 | { |
777 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); | 785 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); |
778 | if (!dai) | 786 | if (!dai) |
779 | { | 787 | { |
780 | qDebug("could not find configured phone application."); | 788 | qDebug("could not find configured phone application."); |
781 | return false; | 789 | return false; |
782 | } | 790 | } |
783 | channel = dai->_channel; | 791 | channel = dai->_channel; |
784 | message = dai->_message; | 792 | message = dai->_message; |
785 | parameters = dai->_parameters; | 793 | parameters = dai->_parameters; |
786 | } | 794 | } |
787 | 795 | ||
788 | 796 | ||
789 | //first check if one of the mailers need the emails right in the message. | 797 | //first check if one of the mailers need the emails right in the message. |
790 | message = translateMessage(message, phonenumber, ""); | 798 | message = translateMessage(message, phonenumber, ""); |
791 | 799 | ||
792 | 800 | ||
793 | #ifdef DEBUG_EXT_APP_HANDLER | 801 | #ifdef DEBUG_EXT_APP_HANDLER |
794 | qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 802 | qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
795 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); | 803 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); |
796 | #endif | 804 | #endif |
797 | 805 | ||
798 | QCopEnvelope e(channel.latin1(), message.latin1()); | 806 | QCopEnvelope e(channel.latin1(), message.latin1()); |
799 | //US we need no names in the To field. The emailadresses are enough | 807 | //US we need no names in the To field. The emailadresses are enough |
800 | 808 | ||
801 | passParameters(&e, parameters, phonenumber, ""); | 809 | passParameters(&e, parameters, phonenumber, ""); |
802 | 810 | ||
803 | 811 | ||
804 | #else | 812 | #else |
805 | KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); | 813 | KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); |
806 | #endif | 814 | #endif |
807 | 815 | ||
808 | 816 | ||
809 | return true; | 817 | return true; |
810 | } | 818 | } |
811 | 819 | ||
812 | /************************************************************************** | 820 | /************************************************************************** |
813 | * | 821 | * |
814 | **************************************************************************/ | 822 | **************************************************************************/ |
815 | 823 | ||
816 | //calls the smsapplication with the number | 824 | //calls the smsapplication with the number |
817 | bool ExternalAppHandler::callBySMS( const QString& phonenumber ) | 825 | bool ExternalAppHandler::callBySMS( const QString& phonenumber ) |
818 | { | 826 | { |
819 | #ifndef DESKTOP_VERSION | 827 | #ifndef DESKTOP_VERSION |
820 | QString channel; | 828 | QString channel; |
821 | QString message; | 829 | QString message; |
822 | QString parameters; | 830 | QString parameters; |
823 | 831 | ||
824 | 832 | ||
825 | int client = KPimGlobalPrefs::instance()->mSMSClient; | 833 | int client = KPimGlobalPrefs::instance()->mSMSClient; |
826 | if (client == KPimGlobalPrefs::OTHER_SMC) | 834 | if (client == KPimGlobalPrefs::OTHER_SMC) |
827 | { | 835 | { |
828 | channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; | 836 | channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; |
829 | message = KPimGlobalPrefs::instance()->mSMSOtherMessage; | 837 | message = KPimGlobalPrefs::instance()->mSMSOtherMessage; |
830 | parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; | 838 | parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; |
831 | } | 839 | } |
832 | else | 840 | else |
833 | { | 841 | { |
834 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); | 842 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); |
835 | if (!dai) | 843 | if (!dai) |
836 | { | 844 | { |
837 | qDebug("could not find configured sms application."); | 845 | qDebug("could not find configured sms application."); |
838 | return false; | 846 | return false; |
839 | } | 847 | } |
840 | channel = dai->_channel; | 848 | channel = dai->_channel; |
841 | message = dai->_message; | 849 | message = dai->_message; |
842 | parameters = dai->_parameters; | 850 | parameters = dai->_parameters; |
843 | } | 851 | } |
844 | 852 | ||
845 | 853 | ||
846 | //first check if one of the mailers need the emails right in the message. | 854 | //first check if one of the mailers need the emails right in the message. |
847 | message = translateMessage(message, phonenumber, ""); | 855 | message = translateMessage(message, phonenumber, ""); |
848 | 856 | ||
849 | 857 | ||
850 | #ifdef DEBUG_EXT_APP_HANDLER | 858 | #ifdef DEBUG_EXT_APP_HANDLER |
851 | qDebug("7Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 859 | qDebug("7Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
852 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); | 860 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); |
853 | #endif | 861 | #endif |
854 | 862 | ||
855 | QCopEnvelope e(channel.latin1(), message.latin1()); | 863 | QCopEnvelope e(channel.latin1(), message.latin1()); |
856 | //US we need no names in the To field. The emailadresses are enough | 864 | //US we need no names in the To field. The emailadresses are enough |
857 | 865 | ||
858 | passParameters(&e, parameters, phonenumber, ""); | 866 | passParameters(&e, parameters, phonenumber, ""); |
859 | 867 | ||
860 | 868 | ||
861 | #else | 869 | #else |
862 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); | 870 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); |
863 | #endif | 871 | #endif |
864 | 872 | ||
865 | 873 | ||
866 | return true; | 874 | return true; |
867 | } | 875 | } |
868 | 876 | ||
869 | /************************************************************************** | 877 | /************************************************************************** |
870 | * | 878 | * |
871 | **************************************************************************/ | 879 | **************************************************************************/ |
872 | 880 | ||
873 | //calls the pagerapplication with the number | 881 | //calls the pagerapplication with the number |
874 | bool ExternalAppHandler::callByPager( const QString& pagernumber ) | 882 | bool ExternalAppHandler::callByPager( const QString& pagernumber ) |
875 | { | 883 | { |
876 | #ifndef DESKTOP_VERSION | 884 | #ifndef DESKTOP_VERSION |
877 | QString channel; | 885 | QString channel; |
878 | QString message; | 886 | QString message; |
879 | QString parameters; | 887 | QString parameters; |
880 | 888 | ||
881 | 889 | ||
882 | int client = KPimGlobalPrefs::instance()->mPagerClient; | 890 | int client = KPimGlobalPrefs::instance()->mPagerClient; |
883 | if (client == KPimGlobalPrefs::OTHER_PAC) | 891 | if (client == KPimGlobalPrefs::OTHER_PAC) |
884 | { | 892 | { |
885 | channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; | 893 | channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; |
886 | message = KPimGlobalPrefs::instance()->mPagerOtherMessage; | 894 | message = KPimGlobalPrefs::instance()->mPagerOtherMessage; |
887 | parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; | 895 | parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; |
888 | } | 896 | } |
889 | else | 897 | else |
890 | { | 898 | { |
891 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); | 899 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); |
892 | if (!dai) | 900 | if (!dai) |
893 | { | 901 | { |
894 | qDebug("could not find configured pager application."); | 902 | qDebug("could not find configured pager application."); |
895 | return false; | 903 | return false; |
896 | } | 904 | } |
897 | channel = dai->_channel; | 905 | channel = dai->_channel; |
898 | message = dai->_message; | 906 | message = dai->_message; |
899 | parameters = dai->_parameters; | 907 | parameters = dai->_parameters; |
900 | } | 908 | } |
901 | 909 | ||
902 | 910 | ||
903 | //first check if one of the mailers need the emails right in the message. | 911 | //first check if one of the mailers need the emails right in the message. |
904 | message = translateMessage(message, pagernumber, ""); | 912 | message = translateMessage(message, pagernumber, ""); |
905 | 913 | ||
906 | 914 | ||
907 | #ifdef DEBUG_EXT_APP_HANDLER | 915 | #ifdef DEBUG_EXT_APP_HANDLER |
908 | qDebug("8Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 916 | qDebug("8Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
909 | qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); | 917 | qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); |
910 | #endif | 918 | #endif |
911 | 919 | ||
912 | QCopEnvelope e(channel.latin1(), message.latin1()); | 920 | QCopEnvelope e(channel.latin1(), message.latin1()); |
913 | //US we need no names in the To field. The emailadresses are enough | 921 | //US we need no names in the To field. The emailadresses are enough |
914 | 922 | ||
915 | passParameters(&e, parameters, pagernumber, ""); | 923 | passParameters(&e, parameters, pagernumber, ""); |
916 | 924 | ||
917 | 925 | ||
918 | #else | 926 | #else |
919 | KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); | 927 | KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); |
920 | #endif | 928 | #endif |
921 | 929 | ||
922 | 930 | ||
923 | return true; | 931 | return true; |
924 | } | 932 | } |
925 | 933 | ||
926 | /************************************************************************** | 934 | /************************************************************************** |
927 | * | 935 | * |
928 | **************************************************************************/ | 936 | **************************************************************************/ |
929 | 937 | ||
930 | //calls the faxapplication with the number | 938 | //calls the faxapplication with the number |
931 | bool ExternalAppHandler::callByFax( const QString& faxnumber ) | 939 | bool ExternalAppHandler::callByFax( const QString& faxnumber ) |
932 | { | 940 | { |
933 | #ifndef DESKTOP_VERSION | 941 | #ifndef DESKTOP_VERSION |
934 | QString channel; | 942 | QString channel; |
935 | QString message; | 943 | QString message; |
936 | QString parameters; | 944 | QString parameters; |
937 | 945 | ||
938 | 946 | ||
939 | int client = KPimGlobalPrefs::instance()->mFaxClient; | 947 | int client = KPimGlobalPrefs::instance()->mFaxClient; |
940 | if (client == KPimGlobalPrefs::OTHER_FAC) | 948 | if (client == KPimGlobalPrefs::OTHER_FAC) |
941 | { | 949 | { |
942 | channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; | 950 | channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; |
943 | message = KPimGlobalPrefs::instance()->mFaxOtherMessage; | 951 | message = KPimGlobalPrefs::instance()->mFaxOtherMessage; |
944 | parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; | 952 | parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; |
945 | } | 953 | } |
946 | else | 954 | else |
947 | { | 955 | { |
948 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); | 956 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); |
949 | if (!dai) | 957 | if (!dai) |
950 | { | 958 | { |
951 | qDebug("could not find configured fax application."); | 959 | qDebug("could not find configured fax application."); |
952 | return false; | 960 | return false; |
953 | } | 961 | } |
954 | channel = dai->_channel; | 962 | channel = dai->_channel; |
955 | message = dai->_message; | 963 | message = dai->_message; |
956 | parameters = dai->_parameters; | 964 | parameters = dai->_parameters; |
957 | } | 965 | } |
958 | 966 | ||
959 | 967 | ||
960 | //first check if one of the mailers need the emails right in the message. | 968 | //first check if one of the mailers need the emails right in the message. |
961 | message = translateMessage(message, faxnumber, ""); | 969 | message = translateMessage(message, faxnumber, ""); |
962 | 970 | ||
963 | 971 | ||
964 | #ifdef DEBUG_EXT_APP_HANDLER | 972 | #ifdef DEBUG_EXT_APP_HANDLER |
965 | qDebug("9Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 973 | qDebug("9Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
966 | qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); | 974 | qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); |
967 | #endif | 975 | #endif |
968 | 976 | ||
969 | QCopEnvelope e(channel.latin1(), message.latin1()); | 977 | QCopEnvelope e(channel.latin1(), message.latin1()); |
970 | //US we need no names in the To field. The emailadresses are enough | 978 | //US we need no names in the To field. The emailadresses are enough |
971 | 979 | ||
972 | passParameters(&e, parameters, faxnumber, ""); | 980 | passParameters(&e, parameters, faxnumber, ""); |
973 | 981 | ||
974 | 982 | ||
975 | #else | 983 | #else |
976 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); | 984 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); |
977 | #endif | 985 | #endif |
978 | 986 | ||
979 | 987 | ||
980 | return true; | 988 | return true; |
981 | } | 989 | } |
982 | 990 | ||
983 | /************************************************************************** | 991 | /************************************************************************** |
984 | * | 992 | * |
985 | **************************************************************************/ | 993 | **************************************************************************/ |
986 | 994 | ||
987 | //calls the sipapplication with the number | 995 | //calls the sipapplication with the number |
988 | bool ExternalAppHandler::callBySIP( const QString& sipnumber ) | 996 | bool ExternalAppHandler::callBySIP( const QString& sipnumber ) |
989 | { | 997 | { |
990 | #ifndef DESKTOP_VERSION | 998 | #ifndef DESKTOP_VERSION |
991 | QString channel; | 999 | QString channel; |
992 | QString message; | 1000 | QString message; |
993 | QString parameters; | 1001 | QString parameters; |
994 | 1002 | ||
995 | 1003 | ||
996 | int client = KPimGlobalPrefs::instance()->mSipClient; | 1004 | int client = KPimGlobalPrefs::instance()->mSipClient; |
997 | if (client == KPimGlobalPrefs::OTHER_SIC) | 1005 | if (client == KPimGlobalPrefs::OTHER_SIC) |
998 | { | 1006 | { |
999 | channel = KPimGlobalPrefs::instance()->mSipOtherChannel; | 1007 | channel = KPimGlobalPrefs::instance()->mSipOtherChannel; |
1000 | message = KPimGlobalPrefs::instance()->mSipOtherMessage; | 1008 | message = KPimGlobalPrefs::instance()->mSipOtherMessage; |
1001 | parameters = KPimGlobalPrefs::instance()->mSipOtherMessageParameters; | 1009 | parameters = KPimGlobalPrefs::instance()->mSipOtherMessageParameters; |
1002 | } | 1010 | } |
1003 | else | 1011 | else |
1004 | { | 1012 | { |
1005 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SIP, client); | 1013 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SIP, client); |
1006 | if (!dai) | 1014 | if (!dai) |
1007 | { | 1015 | { |
1008 | qDebug("could not find configured sip application."); | 1016 | qDebug("could not find configured sip application."); |
1009 | return false; | 1017 | return false; |
1010 | } | 1018 | } |
1011 | channel = dai->_channel; | 1019 | channel = dai->_channel; |
1012 | message = dai->_message; | 1020 | message = dai->_message; |
1013 | parameters = dai->_parameters; | 1021 | parameters = dai->_parameters; |
1014 | } | 1022 | } |
1015 | 1023 | ||
1016 | 1024 | ||
1017 | //first check if one of the sip apps need the emails right in the message. | 1025 | //first check if one of the sip apps need the emails right in the message. |
1018 | message = translateMessage(message, sipnumber, ""); | 1026 | message = translateMessage(message, sipnumber, ""); |
1019 | 1027 | ||
1020 | 1028 | ||
1021 | #ifdef DEBUG_EXT_APP_HANDLER | 1029 | #ifdef DEBUG_EXT_APP_HANDLER |
1022 | qDebug("10Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 1030 | qDebug("10Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
1023 | qDebug("passing sipnumber(%s) as parameter in the form %s to QCopEnvelope", sipnumber.latin1(), parameters.latin1()); | 1031 | qDebug("passing sipnumber(%s) as parameter in the form %s to QCopEnvelope", sipnumber.latin1(), parameters.latin1()); |
1024 | #endif | 1032 | #endif |
1025 | 1033 | ||
1026 | QCopEnvelope e(channel.latin1(), message.latin1()); | 1034 | QCopEnvelope e(channel.latin1(), message.latin1()); |
1027 | //US we need no names in the To field. The emailadresses are enough | 1035 | //US we need no names in the To field. The emailadresses are enough |
1028 | 1036 | ||
1029 | passParameters(&e, parameters, sipnumber, ""); | 1037 | passParameters(&e, parameters, sipnumber, ""); |
1030 | 1038 | ||
1031 | 1039 | ||
1032 | #else | 1040 | #else |
1033 | KMessageBox::sorry( 0, i18n( "This version does not support sip." ) ); | 1041 | KMessageBox::sorry( 0, i18n( "This version does not support sip." ) ); |
1034 | #endif | 1042 | #endif |
1035 | 1043 | ||
1036 | 1044 | ||
1037 | return true; | 1045 | return true; |
1038 | } | 1046 | } |
1039 | 1047 | ||
1040 | 1048 | ||
1041 | /************************************************************************** | 1049 | /************************************************************************** |
1042 | * | 1050 | * |
1043 | **************************************************************************/ | 1051 | **************************************************************************/ |
1044 | 1052 | ||
1045 | 1053 | ||
1046 | QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const | 1054 | QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const |
1047 | { | 1055 | { |
1048 | message = message.replace( QRegExp("%1"), param1 ); | 1056 | message = message.replace( QRegExp("%1"), param1 ); |
1049 | return message.replace( QRegExp("%2"), param2 ); | 1057 | return message.replace( QRegExp("%2"), param2 ); |
1050 | } | 1058 | } |
1051 | 1059 | ||
1052 | /************************************************************************** | 1060 | /************************************************************************** |
1053 | * | 1061 | * |
1054 | **************************************************************************/ | 1062 | **************************************************************************/ |
1055 | 1063 | ||
1056 | void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const | 1064 | void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const |
1057 | { | 1065 | { |
1058 | #ifndef DESKTOP_VERSION | 1066 | #ifndef DESKTOP_VERSION |
1059 | QMap<QString, QString> valmap; | 1067 | QMap<QString, QString> valmap; |
1060 | bool useValMap = false; | 1068 | bool useValMap = false; |
1061 | 1069 | ||
1062 | // first extract all parts of the parameters. | 1070 | // first extract all parts of the parameters. |
1063 | QStringList paramlist = QStringList::split(";", parameters); | 1071 | QStringList paramlist = QStringList::split(";", parameters); |
1064 | 1072 | ||
1065 | //Now check how many parts we have. | 1073 | //Now check how many parts we have. |
1066 | //=0 :no params to pass | 1074 | //=0 :no params to pass |
1067 | //>0 :parameters to pass | 1075 | //>0 :parameters to pass |
1068 | for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) | 1076 | for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) |
1069 | { | 1077 | { |
1070 | QString param = (*it); | 1078 | QString param = (*it); |
1071 | QStringList keyvallist = QStringList::split("=", param); | 1079 | QStringList keyvallist = QStringList::split("=", param); |
1072 | 1080 | ||
1073 | //if we have keyvalue pairs, we assume that we pass a map to the envelope | 1081 | //if we have keyvalue pairs, we assume that we pass a map to the envelope |
1074 | QStringList::Iterator it2 = keyvallist.begin(); | 1082 | QStringList::Iterator it2 = keyvallist.begin(); |
1075 | QString key = (*it2); | 1083 | QString key = (*it2); |
1076 | key = key.replace( QRegExp("%1"), param1 ); | 1084 | key = key.replace( QRegExp("%1"), param1 ); |
1077 | key = key.replace( QRegExp("%2"), param2 ); | 1085 | key = key.replace( QRegExp("%2"), param2 ); |
1078 | ++it2; | 1086 | ++it2; |
1079 | 1087 | ||
1080 | if(it2 != keyvallist.end()) | 1088 | if(it2 != keyvallist.end()) |
1081 | { | 1089 | { |
1082 | QString value = (*it2); | 1090 | QString value = (*it2); |
1083 | value = value.replace( QRegExp("%1"), param1 ); | 1091 | value = value.replace( QRegExp("%1"), param1 ); |
1084 | value = value.replace( QRegExp("%2"), param2 ); | 1092 | value = value.replace( QRegExp("%2"), param2 ); |
1085 | 1093 | ||
1086 | valmap.insert(key, value); | 1094 | valmap.insert(key, value); |
1087 | useValMap = true; | 1095 | useValMap = true; |
1088 | } | 1096 | } |
1089 | else | 1097 | else |
1090 | { | 1098 | { |
1091 | // qDebug("pass parameter << %s", key.latin1()); | 1099 | // qDebug("pass parameter << %s", key.latin1()); |
1092 | (*e) << key; | 1100 | (*e) << key; |
1093 | } | 1101 | } |
1094 | } | 1102 | } |
1095 | 1103 | ||
1096 | if (useValMap == true) | 1104 | if (useValMap == true) |
1097 | (*e) << valmap; | 1105 | (*e) << valmap; |
1098 | 1106 | ||
1099 | #endif | 1107 | #endif |
1100 | 1108 | ||
1101 | } | 1109 | } |
1102 | 1110 | ||
1103 | 1111 | ||
1104 | 1112 | ||
1105 | /************************************************************************** | 1113 | /************************************************************************** |
1106 | * | 1114 | * |
1107 | **************************************************************************/ | 1115 | **************************************************************************/ |
1108 | 1116 | ||
1109 | void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data ) | 1117 | void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data ) |
1110 | { | 1118 | { |
1111 | bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); | 1119 | bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); |
1112 | if (!res) | 1120 | if (!res) |
1113 | res = mBirthdayListFromKAPITransfer->appMessage( cmsg, data ); | 1121 | res = mBirthdayListFromKAPITransfer->appMessage( cmsg, data ); |
1114 | 1122 | ||
1115 | if (!res) | 1123 | if (!res) |
1116 | res = mDisplayDetails->appMessage( cmsg, data ); | 1124 | res = mDisplayDetails->appMessage( cmsg, data ); |
1117 | 1125 | ||
1118 | // if (!res) | 1126 | // if (!res) |
1119 | // res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); | 1127 | // res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); |
1120 | } | 1128 | } |
1121 | 1129 | ||
1122 | 1130 | ||
1123 | 1131 | ||
1124 | bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid) | 1132 | bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid) |
1125 | { | 1133 | { |
1126 | mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); | 1134 | mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); |
1127 | return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid); | 1135 | return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid); |
1128 | } | 1136 | } |
1129 | 1137 | ||
1130 | bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) | 1138 | bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) |
1131 | { | 1139 | { |
1132 | QStringList list4, list5, list6; | 1140 | QStringList list4, list5, list6; |
1133 | 1141 | ||
1134 | mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); | 1142 | mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); |
1135 | return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); | 1143 | return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); |
1136 | } | 1144 | } |
1137 | 1145 | ||
1138 | bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email) | 1146 | bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email) |
1139 | { | 1147 | { |
1140 | mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); | 1148 | mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); |
1141 | return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email); | 1149 | return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email); |
1142 | } | 1150 | } |
1143 | 1151 | ||
1144 | bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) | 1152 | bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) |
1145 | { | 1153 | { |
1146 | QStringList list4, list5, list6; | 1154 | QStringList list4, list5, list6; |
1147 | 1155 | ||
1148 | mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); | 1156 | mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); |
1149 | return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); | 1157 | return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); |
1150 | } | 1158 | } |
1151 | 1159 | ||
1152 | bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid) | 1160 | bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid) |
1153 | { | 1161 | { |
1154 | mDisplayDetails->setSourceChannel(""); | 1162 | mDisplayDetails->setSourceChannel(""); |
1155 | return mDisplayDetails->sendMessageToTarget("", name, email, uid); | 1163 | return mDisplayDetails->sendMessageToTarget("", name, email, uid); |
1156 | } | 1164 | } |
1157 | 1165 | ||
1158 | bool ExternalAppHandler::requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid) | 1166 | bool ExternalAppHandler::requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid) |
1159 | { | 1167 | { |
1160 | mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); | 1168 | mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); |
1161 | return mBirthdayListFromKAPITransfer->sendMessageToTarget(sessionuid); | 1169 | return mBirthdayListFromKAPITransfer->sendMessageToTarget(sessionuid); |
1162 | } | 1170 | } |
1163 | 1171 | ||
1164 | bool ExternalAppHandler::returnBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6) | 1172 | bool ExternalAppHandler::returnBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6) |
1165 | { | 1173 | { |
1166 | mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); | 1174 | mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); |
1167 | return mBirthdayListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); | 1175 | return mBirthdayListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); |
1168 | } | 1176 | } |
1169 | 1177 | ||
1170 | 1178 | ||
1171 | 1179 | ||
1172 | 1180 | ||
1173 | 1181 | ||
diff --git a/libkdepim/externalapphandler.h b/libkdepim/externalapphandler.h index 4c6f1ea..6f5d345 100644 --- a/libkdepim/externalapphandler.h +++ b/libkdepim/externalapphandler.h | |||
@@ -1,291 +1,291 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #ifndef EXTERNALAPPHANDLER_H | 31 | #ifndef EXTERNALAPPHANDLER_H |
32 | #define EXTERNALAPPHANDLER_H | 32 | #define EXTERNALAPPHANDLER_H |
33 | 33 | ||
34 | #include <qobject.h> | 34 | #include <qobject.h> |
35 | #include <qlist.h> | 35 | #include <qlist.h> |
36 | #include <qmap.h> | 36 | #include <qmap.h> |
37 | 37 | ||
38 | class QCopEnvelope; | 38 | class QCopEnvelope; |
39 | 39 | ||
40 | 40 | ||
41 | class ExternalAppHandler; | 41 | class ExternalAppHandler; |
42 | class QCopTransferItem : public QObject | 42 | class QCopTransferItem : public QObject |
43 | { | 43 | { |
44 | Q_OBJECT | 44 | Q_OBJECT |
45 | public: | 45 | public: |
46 | QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); | 46 | QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); |
47 | QCopTransferItem(); | 47 | QCopTransferItem(); |
48 | 48 | ||
49 | bool sendMessageToTarget(const QString& uid, const QString& param1 = QString::null, const QString& param2 = QString::null, const QString& param3 = QString::null); | 49 | bool sendMessageToTarget(const QString& uid, const QString& param1 = QString::null, const QString& param2 = QString::null, const QString& param3 = QString::null); |
50 | 50 | ||
51 | void setSourceChannel(const QString& sourceChannel); | 51 | void setSourceChannel(const QString& sourceChannel); |
52 | 52 | ||
53 | virtual bool appMessage( const QCString& msg, const QByteArray& data ); | 53 | virtual bool appMessage( const QCString& msg, const QByteArray& data ); |
54 | 54 | ||
55 | 55 | ||
56 | signals: | 56 | signals: |
57 | void receivedMessageFromSource(const QString& sourceChannel, const QString& uid); | 57 | void receivedMessageFromSource(const QString& sourceChannel, const QString& uid); |
58 | void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1); | 58 | void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1); |
59 | void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1, const QString& param2); | 59 | void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1, const QString& param2); |
60 | void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1, const QString& param2, const QString& param3); | 60 | void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1, const QString& param2, const QString& param3); |
61 | 61 | ||
62 | public: | 62 | public: |
63 | int _usedSourceParameters; | 63 | int _usedSourceParameters; |
64 | QString _sourceChannel; | 64 | QString _sourceChannel; |
65 | QString _sourceMessage; | 65 | QString _sourceMessage; |
66 | QString _sourceMessageParameters; | 66 | QString _sourceMessageParameters; |
67 | QString _targetChannel; | 67 | QString _targetChannel; |
68 | QString _targetMessage; | 68 | QString _targetMessage; |
69 | QString _targetMessageParameters; | 69 | QString _targetMessageParameters; |
70 | 70 | ||
71 | }; | 71 | }; |
72 | 72 | ||
73 | /********************************************************************************* | 73 | /********************************************************************************* |
74 | * | 74 | * |
75 | ********************************************************************************/ | 75 | ********************************************************************************/ |
76 | 76 | ||
77 | class QCopMapTransferItem : public QCopTransferItem | 77 | class QCopMapTransferItem : public QCopTransferItem |
78 | { | 78 | { |
79 | Q_OBJECT | 79 | Q_OBJECT |
80 | public: | 80 | public: |
81 | QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); | 81 | QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); |
82 | 82 | ||
83 | bool sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap); | 83 | bool sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap); |
84 | 84 | ||
85 | 85 | ||
86 | virtual bool appMessage( const QCString& msg, const QByteArray& data ); | 86 | virtual bool appMessage( const QCString& msg, const QByteArray& data ); |
87 | 87 | ||
88 | 88 | ||
89 | signals: | 89 | signals: |
90 | void receivedMessageFromTarget(const QString& uid, const QMap<QString,QString>& nameEmailMap); | 90 | void receivedMessageFromTarget(const QString& uid, const QMap<QString,QString>& nameEmailMap); |
91 | 91 | ||
92 | }; | 92 | }; |
93 | 93 | ||
94 | /********************************************************************************* | 94 | /********************************************************************************* |
95 | * | 95 | * |
96 | ********************************************************************************/ | 96 | ********************************************************************************/ |
97 | 97 | ||
98 | class QCopListTransferItem : public QCopTransferItem | 98 | class QCopListTransferItem : public QCopTransferItem |
99 | { | 99 | { |
100 | Q_OBJECT | 100 | Q_OBJECT |
101 | public: | 101 | public: |
102 | QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); | 102 | QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); |
103 | 103 | ~QCopListTransferItem(); | |
104 | bool sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6); | 104 | bool sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6); |
105 | 105 | ||
106 | 106 | ||
107 | virtual bool appMessage( const QCString& msg, const QByteArray& data ); | 107 | virtual bool appMessage( const QCString& msg, const QByteArray& data ); |
108 | 108 | ||
109 | 109 | ||
110 | signals: | 110 | signals: |
111 | void receivedMessageFromTarget(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4 , const QStringList& list5, const QStringList& list6); | 111 | void receivedMessageFromTarget(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4 , const QStringList& list5, const QStringList& list6); |
112 | 112 | ||
113 | }; | 113 | }; |
114 | 114 | ||
115 | /********************************************************************************* | 115 | /********************************************************************************* |
116 | * | 116 | * |
117 | ********************************************************************************/ | 117 | ********************************************************************************/ |
118 | 118 | ||
119 | 119 | ||
120 | class DefaultAppItem | 120 | class DefaultAppItem |
121 | { | 121 | { |
122 | public: | 122 | public: |
123 | DefaultAppItem(int type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2) | 123 | DefaultAppItem(int type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2) |
124 | : _type(type), _id(id), _label(label), _channel(channel), _message(message), _parameters(parameters), _message2(message2), _parameters2(parameters2) | 124 | : _type(type), _id(id), _label(label), _channel(channel), _message(message), _parameters(parameters), _message2(message2), _parameters2(parameters2) |
125 | {} | 125 | {} |
126 | 126 | ||
127 | DefaultAppItem() | 127 | DefaultAppItem() |
128 | { } | 128 | { } |
129 | 129 | ||
130 | public: | 130 | public: |
131 | int _type; | 131 | int _type; |
132 | int _id; | 132 | int _id; |
133 | QString _label; | 133 | QString _label; |
134 | QString _channel; | 134 | QString _channel; |
135 | QString _message; | 135 | QString _message; |
136 | QString _parameters;// a list of parameters in stringrepresentation. Delimiter is ; | 136 | QString _parameters;// a list of parameters in stringrepresentation. Delimiter is ; |
137 | QString _message2; | 137 | QString _message2; |
138 | QString _parameters2; // a list of parameters in stringrepresentation. Delimiter is ; | 138 | QString _parameters2; // a list of parameters in stringrepresentation. Delimiter is ; |
139 | 139 | ||
140 | }; | 140 | }; |
141 | 141 | ||
142 | /********************************************************************************* | 142 | /********************************************************************************* |
143 | * | 143 | * |
144 | ********************************************************************************/ | 144 | ********************************************************************************/ |
145 | 145 | ||
146 | class ExternalAppHandler : public QObject | 146 | class ExternalAppHandler : public QObject |
147 | { | 147 | { |
148 | Q_OBJECT | 148 | Q_OBJECT |
149 | public: | 149 | public: |
150 | virtual ~ExternalAppHandler(); | 150 | virtual ~ExternalAppHandler(); |
151 | 151 | ||
152 | static ExternalAppHandler *instance(); | 152 | static ExternalAppHandler *instance(); |
153 | 153 | ||
154 | enum Types { | 154 | enum Types { |
155 | EMAIL = 0, | 155 | EMAIL = 0, |
156 | PHONE = 1, | 156 | PHONE = 1, |
157 | SMS = 2, | 157 | SMS = 2, |
158 | FAX = 3, | 158 | FAX = 3, |
159 | PAGER = 4, | 159 | PAGER = 4, |
160 | SIP = 5 | 160 | SIP = 5 |
161 | }; | 161 | }; |
162 | 162 | ||
163 | enum Availability { | 163 | enum Availability { |
164 | UNDEFINED = -1, | 164 | UNDEFINED = -1, |
165 | UNAVAILABLE = 0, | 165 | UNAVAILABLE = 0, |
166 | AVAILABLE = 1 | 166 | AVAILABLE = 1 |
167 | }; | 167 | }; |
168 | 168 | ||
169 | //calls the emailapplication with a number of attachments that need to be send. | 169 | //calls the emailapplication with a number of attachments that need to be send. |
170 | //either parameter can be left empty. | 170 | //either parameter can be left empty. |
171 | bool mailToMultipleContacts( const QString& recipients, const QString& attachmenturls ); | 171 | bool mailToMultipleContacts( const QString& recipients, const QString& attachmenturls ); |
172 | 172 | ||
173 | //calls the emailapplication and creates a mail with parameter emailadress as recipients | 173 | //calls the emailapplication and creates a mail with parameter emailadress as recipients |
174 | bool mailToOneContact( const QString& name, const QString& emailadress ); | 174 | bool mailToOneContact( const QString& name, const QString& emailadress ); |
175 | 175 | ||
176 | //calls the emailapplication and creates a mail with parameter as recipients | 176 | //calls the emailapplication and creates a mail with parameter as recipients |
177 | // parameters format is | 177 | // parameters format is |
178 | // NAME <EMAIL>:SUBJECT | 178 | // NAME <EMAIL>:SUBJECT |
179 | bool mailToOneContact( const QString& adressline ); | 179 | bool mailToOneContact( const QString& adressline ); |
180 | 180 | ||
181 | //calls the phoneapplication with the number | 181 | //calls the phoneapplication with the number |
182 | bool callByPhone( const QString& phonenumber ); | 182 | bool callByPhone( const QString& phonenumber ); |
183 | 183 | ||
184 | //calls the smsapplication with the number | 184 | //calls the smsapplication with the number |
185 | bool callBySMS( const QString& phonenumber ); | 185 | bool callBySMS( const QString& phonenumber ); |
186 | 186 | ||
187 | //calls the pagerapplication with the number | 187 | //calls the pagerapplication with the number |
188 | bool callByPager( const QString& pagernumber ); | 188 | bool callByPager( const QString& pagernumber ); |
189 | 189 | ||
190 | //calls the faxapplication with the number | 190 | //calls the faxapplication with the number |
191 | bool callByFax( const QString& faxnumber ); | 191 | bool callByFax( const QString& faxnumber ); |
192 | 192 | ||
193 | //calls the sipapplication with the number | 193 | //calls the sipapplication with the number |
194 | bool callBySIP( const QString& sipnumber ); | 194 | bool callBySIP( const QString& sipnumber ); |
195 | 195 | ||
196 | bool isEmailAppAvailable(); | 196 | bool isEmailAppAvailable(); |
197 | bool isSMSAppAvailable(); | 197 | bool isSMSAppAvailable(); |
198 | bool isPhoneAppAvailable(); | 198 | bool isPhoneAppAvailable(); |
199 | bool isFaxAppAvailable(); | 199 | bool isFaxAppAvailable(); |
200 | bool isPagerAppAvailable(); | 200 | bool isPagerAppAvailable(); |
201 | bool isSIPAppAvailable(); | 201 | bool isSIPAppAvailable(); |
202 | 202 | ||
203 | 203 | ||
204 | //Call this method on the source when you want to select names from the addressbook by using QCop | 204 | //Call this method on the source when you want to select names from the addressbook by using QCop |
205 | bool requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid); | 205 | bool requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid); |
206 | //Call this method on the target when you want to return the name/email map to the source (client). | 206 | //Call this method on the target when you want to return the name/email map to the source (client). |
207 | bool returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& name, const QStringList& email, const QStringList& uid); | 207 | bool returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& name, const QStringList& email, const QStringList& uid); |
208 | 208 | ||
209 | 209 | ||
210 | 210 | ||
211 | bool requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email); | 211 | bool requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email); |
212 | bool returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& name, const QStringList& email, const QStringList& uid); | 212 | bool returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& name, const QStringList& email, const QStringList& uid); |
213 | 213 | ||
214 | bool requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid); | 214 | bool requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid); |
215 | 215 | ||
216 | 216 | ||
217 | 217 | ||
218 | bool requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid); | 218 | bool requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid); |
219 | bool returnBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid, | 219 | bool returnBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid, |
220 | const QStringList& birthdayList, const QStringList& anniversaryList, | 220 | const QStringList& birthdayList, const QStringList& anniversaryList, |
221 | const QStringList& realNameList, const QStringList& emailList, | 221 | const QStringList& realNameList, const QStringList& emailList, |
222 | const QStringList& assembledNameList, const QStringList& uidList); | 222 | const QStringList& assembledNameList, const QStringList& uidList); |
223 | 223 | ||
224 | 224 | ||
225 | //loadConfig clears the cache and checks again if the applications are available or not | 225 | //loadConfig clears the cache and checks again if the applications are available or not |
226 | void loadConfig(); | 226 | void loadConfig(); |
227 | 227 | ||
228 | QList<DefaultAppItem> getAvailableDefaultItems(Types); | 228 | QList<DefaultAppItem> getAvailableDefaultItems(Types); |
229 | DefaultAppItem* getDefaultItem(Types, int); | 229 | DefaultAppItem* getDefaultItem(Types, int); |
230 | 230 | ||
231 | public slots: | 231 | public slots: |
232 | void appMessage( const QCString& msg, const QByteArray& data ); | 232 | void appMessage( const QCString& msg, const QByteArray& data ); |
233 | 233 | ||
234 | 234 | ||
235 | signals: | 235 | signals: |
236 | // Emmitted when the target app receives a request from the source app | 236 | // Emmitted when the target app receives a request from the source app |
237 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& uid); | 237 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& uid); |
238 | 238 | ||
239 | // Emitted when the source app recieves a list of name/email pairs (=addresses) from another target app. Usually Ka/Pi | 239 | // Emitted when the source app recieves a list of name/email pairs (=addresses) from another target app. Usually Ka/Pi |
240 | // The first parameter is a uniqueid. It can be used to identify the event | 240 | // The first parameter is a uniqueid. It can be used to identify the event |
241 | void receivedNameEmailUidListEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList); | 241 | void receivedNameEmailUidListEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList); |
242 | 242 | ||
243 | void requestFindByEmail(const QString& sourceChannel, const QString& uid, const QString& email); | 243 | void requestFindByEmail(const QString& sourceChannel, const QString& uid, const QString& email); |
244 | void receivedFindByEmailEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList); | 244 | void receivedFindByEmailEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList); |
245 | 245 | ||
246 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); | 246 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); |
247 | 247 | ||
248 | 248 | ||
249 | // Emmitted when the target app receives a request from the source app | 249 | // Emmitted when the target app receives a request from the source app |
250 | void requestForBirthdayList(const QString& sourceChannel, const QString& uid); | 250 | void requestForBirthdayList(const QString& sourceChannel, const QString& uid); |
251 | 251 | ||
252 | // Emitted when the source app recieves a list of name/email pairs (=addresses) from another target app. Usually Ka/Pi | 252 | // Emitted when the source app recieves a list of name/email pairs (=addresses) from another target app. Usually Ka/Pi |
253 | // The first parameter is a uniqueid. It can be used to identify the event | 253 | // The first parameter is a uniqueid. It can be used to identify the event |
254 | void receivedBirthdayListEvent(const QString& uid, const QStringList& birthdayList, | 254 | void receivedBirthdayListEvent(const QString& uid, const QStringList& birthdayList, |
255 | const QStringList& anniversaryList, const QStringList& realNameList, | 255 | const QStringList& anniversaryList, const QStringList& realNameList, |
256 | const QStringList& emailList, const QStringList& assembledNameList, | 256 | const QStringList& emailList, const QStringList& assembledNameList, |
257 | const QStringList& uidList); | 257 | const QStringList& uidList); |
258 | 258 | ||
259 | 259 | ||
260 | private: | 260 | private: |
261 | ExternalAppHandler(); | 261 | ExternalAppHandler(); |
262 | QList<DefaultAppItem> mDefaultItems; | 262 | QList<DefaultAppItem> mDefaultItems; |
263 | 263 | ||
264 | Availability mEmailAppAvailable; | 264 | Availability mEmailAppAvailable; |
265 | Availability mPhoneAppAvailable; | 265 | Availability mPhoneAppAvailable; |
266 | Availability mFaxAppAvailable; | 266 | Availability mFaxAppAvailable; |
267 | Availability mSMSAppAvailable; | 267 | Availability mSMSAppAvailable; |
268 | Availability mPagerAppAvailable; | 268 | Availability mPagerAppAvailable; |
269 | Availability mSIPAppAvailable; | 269 | Availability mSIPAppAvailable; |
270 | 270 | ||
271 | QCopListTransferItem* mNameEmailUidListFromKAPITransfer; | 271 | QCopListTransferItem* mNameEmailUidListFromKAPITransfer; |
272 | QCopListTransferItem* mFindByEmailFromKAPITransfer; | 272 | QCopListTransferItem* mFindByEmailFromKAPITransfer; |
273 | QCopTransferItem* mDisplayDetails; | 273 | QCopTransferItem* mDisplayDetails; |
274 | QCopListTransferItem* mBirthdayListFromKAPITransfer; | 274 | QCopListTransferItem* mBirthdayListFromKAPITransfer; |
275 | 275 | ||
276 | 276 | ||
277 | void addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2); | 277 | void addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2); |
278 | 278 | ||
279 | QString& translateMessage(QString& message, const QString& param1, const QString& param2) const; | 279 | QString& translateMessage(QString& message, const QString& param1, const QString& param2) const; |
280 | void passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1, const QString& param2) const; | 280 | void passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1, const QString& param2) const; |
281 | 281 | ||
282 | 282 | ||
283 | static ExternalAppHandler *sInstance; | 283 | static ExternalAppHandler *sInstance; |
284 | 284 | ||
285 | private slots: | 285 | private slots: |
286 | void receivedNameEmailUidList_Slot(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList, const QStringList&, const QStringList&, const QStringList& ); | 286 | void receivedNameEmailUidList_Slot(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList, const QStringList&, const QStringList&, const QStringList& ); |
287 | 287 | ||
288 | }; | 288 | }; |
289 | 289 | ||
290 | 290 | ||
291 | #endif | 291 | #endif |
diff --git a/libkdepim/kpimglobalprefs.cpp b/libkdepim/kpimglobalprefs.cpp index 3771569..0fdc3e4 100644 --- a/libkdepim/kpimglobalprefs.cpp +++ b/libkdepim/kpimglobalprefs.cpp | |||
@@ -1,205 +1,204 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2002 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 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <kglobal.h> | 31 | #include <kglobal.h> |
32 | #include <kconfig.h> | 32 | #include <kconfig.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #include <kdebug.h> | 34 | #include <kdebug.h> |
35 | #include <kstaticdeleter.h> | 35 | #include <kstaticdeleter.h> |
36 | 36 | ||
37 | #include <qregexp.h> | 37 | #include <qregexp.h> |
38 | #include <qfile.h> | 38 | #include <qfile.h> |
39 | #include <qtextstream.h> | 39 | #include <qtextstream.h> |
40 | #include <qapplication.h> | 40 | #include <qapplication.h> |
41 | #include "kpimglobalprefs.h" | 41 | #include "kpimglobalprefs.h" |
42 | 42 | ||
43 | KPimGlobalPrefs *KPimGlobalPrefs::sInstance = 0; | 43 | KPimGlobalPrefs *KPimGlobalPrefs::sInstance = 0; |
44 | static KStaticDeleter<KPimGlobalPrefs> staticDeleterGP; | 44 | static KStaticDeleter<KPimGlobalPrefs> staticDeleterGP; |
45 | 45 | ||
46 | 46 | ||
47 | KPimGlobalPrefs::KPimGlobalPrefs( const QString &name ) | 47 | KPimGlobalPrefs::KPimGlobalPrefs( const QString &name ) |
48 | : KPrefs("microkdeglobalrc") | 48 | : KPrefs("microkdeglobalrc") |
49 | { | 49 | { |
50 | mLocaleDict = 0; | 50 | mLocaleDict = 0; |
51 | KPrefs::setCurrentGroup("Locale"); | 51 | KPrefs::setCurrentGroup("Locale"); |
52 | addItemInt("PreferredLanguage",&mPreferredLanguage,0); | 52 | addItemInt("PreferredLanguage",&mPreferredLanguage,0); |
53 | addItemInt("PreferredTime",&mPreferredTime,0); | 53 | addItemInt("PreferredTime",&mPreferredTime,0); |
54 | addItemInt("PreferredDate",&mPreferredDate,0); | 54 | addItemInt("PreferredDate",&mPreferredDate,0); |
55 | addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); | 55 | addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); |
56 | addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); | 56 | addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); |
57 | addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); | 57 | addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); |
58 | 58 | ||
59 | KPrefs::setCurrentGroup("Time & Date"); | 59 | KPrefs::setCurrentGroup("Time & Date"); |
60 | 60 | ||
61 | addItemString("TimeZoneName",&mTimeZoneId, ("+01:00 Europe/Oslo(CET)") ); | 61 | addItemString("TimeZoneName",&mTimeZoneId, ("+01:00 Europe/Oslo(CET)") ); |
62 | addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); | 62 | addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); |
63 | addItemBool("TimeZoneAdd30min",&mTimeZoneAdd30min,false); | 63 | addItemBool("TimeZoneAdd30min",&mTimeZoneAdd30min,false); |
64 | addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); | 64 | addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); |
65 | addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); | 65 | addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); |
66 | 66 | ||
67 | KPrefs::setCurrentGroup( "ExternalApplications" ); | 67 | KPrefs::setCurrentGroup( "ExternalApplications" ); |
68 | 68 | ||
69 | addItemInt( "EmailChannelType", &mEmailClient, OMPI_EMC ); | 69 | addItemInt( "EmailChannelType", &mEmailClient, OMPI_EMC ); |
70 | addItemString( "EmailChannel", &mEmailOtherChannel, "" ); | 70 | addItemString( "EmailChannel", &mEmailOtherChannel, "" ); |
71 | addItemString( "EmailChannelMessage", &mEmailOtherMessage, "" ); | 71 | addItemString( "EmailChannelMessage", &mEmailOtherMessage, "" ); |
72 | addItemString( "EmailChannelParameters", &mEmailOtherMessageParameters, "" ); | 72 | addItemString( "EmailChannelParameters", &mEmailOtherMessageParameters, "" ); |
73 | addItemString( "EmailChannelMessage2", &mEmailOtherMessage2, "" ); | 73 | addItemString( "EmailChannelMessage2", &mEmailOtherMessage2, "" ); |
74 | addItemString( "EmailChannelParameters2", &mEmailOtherMessageParameters2, "" ); | 74 | addItemString( "EmailChannelParameters2", &mEmailOtherMessageParameters2, "" ); |
75 | 75 | ||
76 | addItemInt( "PhoneChannelType", &mPhoneClient, KPPI_PHC ); | 76 | addItemInt( "PhoneChannelType", &mPhoneClient, KPPI_PHC ); |
77 | addItemString( "PhoneChannel", &mPhoneOtherChannel, "" ); | 77 | addItemString( "PhoneChannel", &mPhoneOtherChannel, "" ); |
78 | addItemString( "PhoneChannelMessage", &mPhoneOtherMessage, "" ); | 78 | addItemString( "PhoneChannelMessage", &mPhoneOtherMessage, "" ); |
79 | addItemString( "PhoneChannelParameters", &mPhoneOtherMessageParameters, "" ); | 79 | addItemString( "PhoneChannelParameters", &mPhoneOtherMessageParameters, "" ); |
80 | 80 | ||
81 | addItemInt( "FaxChannelType", &mFaxClient, NONE_FAC ); | 81 | addItemInt( "FaxChannelType", &mFaxClient, NONE_FAC ); |
82 | addItemString( "FaxChannel", &mFaxOtherChannel, "" ); | 82 | addItemString( "FaxChannel", &mFaxOtherChannel, "" ); |
83 | addItemString( "FaxChannelMessage", &mFaxOtherMessage, "" ); | 83 | addItemString( "FaxChannelMessage", &mFaxOtherMessage, "" ); |
84 | addItemString( "FaxChannelParameters", &mFaxOtherMessageParameters, "" ); | 84 | addItemString( "FaxChannelParameters", &mFaxOtherMessageParameters, "" ); |
85 | 85 | ||
86 | addItemInt( "SMSChannelType", &mSMSClient, NONE_SMC ); | 86 | addItemInt( "SMSChannelType", &mSMSClient, NONE_SMC ); |
87 | addItemString( "SMSChannel", &mSMSOtherChannel, "" ); | 87 | addItemString( "SMSChannel", &mSMSOtherChannel, "" ); |
88 | addItemString( "SMSChannelMessage", &mSMSOtherMessage, "" ); | 88 | addItemString( "SMSChannelMessage", &mSMSOtherMessage, "" ); |
89 | addItemString( "SMSChannelParameters", &mSMSOtherMessageParameters, "" ); | 89 | addItemString( "SMSChannelParameters", &mSMSOtherMessageParameters, "" ); |
90 | 90 | ||
91 | addItemInt( "PagerChannelType", &mPagerClient, NONE_PAC ); | 91 | addItemInt( "PagerChannelType", &mPagerClient, NONE_PAC ); |
92 | addItemString( "PagerChannel", &mPagerOtherChannel, "" ); | 92 | addItemString( "PagerChannel", &mPagerOtherChannel, "" ); |
93 | addItemString( "PagerChannelMessage", &mPagerOtherMessage, "" ); | 93 | addItemString( "PagerChannelMessage", &mPagerOtherMessage, "" ); |
94 | addItemString( "PagerChannelParameters", &mPagerOtherMessageParameters, "" ); | 94 | addItemString( "PagerChannelParameters", &mPagerOtherMessageParameters, "" ); |
95 | 95 | ||
96 | addItemInt( "SIPChannelType", &mSipClient, KPPI_SIC ); | 96 | addItemInt( "SIPChannelType", &mSipClient, KPPI_SIC ); |
97 | addItemString( "SIPChannel", &mSipOtherChannel, "" ); | 97 | addItemString( "SIPChannel", &mSipOtherChannel, "" ); |
98 | addItemString( "SIPChannelMessage", &mSipOtherMessage, "" ); | 98 | addItemString( "SIPChannelMessage", &mSipOtherMessage, "" ); |
99 | addItemString( "SIPChannelParameters", &mSipOtherMessageParameters, "" ); | 99 | addItemString( "SIPChannelParameters", &mSipOtherMessageParameters, "" ); |
100 | 100 | ||
101 | KPrefs::setCurrentGroup( "PhoneAccess" ); | 101 | KPrefs::setCurrentGroup( "PhoneAccess" ); |
102 | addItemString("Ex2PhoneDevice",&mEx2PhoneDevice,"/dev/ircomm"); | 102 | addItemString("Ex2PhoneDevice",&mEx2PhoneDevice,"/dev/ircomm"); |
103 | addItemString("Ex2PhoneConnection",&mEx2PhoneConnection,"irda"); | 103 | addItemString("Ex2PhoneConnection",&mEx2PhoneConnection,"irda"); |
104 | addItemString("Ex2PhoneModel",&mEx2PhoneModel,"6310i"); | 104 | addItemString("Ex2PhoneModel",&mEx2PhoneModel,"6310i"); |
105 | 105 | ||
106 | } | 106 | } |
107 | 107 | ||
108 | void KPimGlobalPrefs::setGlobalConfig() | 108 | void KPimGlobalPrefs::setGlobalConfig() |
109 | { | 109 | { |
110 | if ( mLocaleDict == 0 ) { | 110 | if ( mLocaleDict == 0 ) { |
111 | QString fileName ; | 111 | QString fileName ; |
112 | QString name = KGlobal::getAppName() +"/"; | 112 | QString name = KGlobal::getAppName() +"/"; |
113 | #ifndef DESKTOP_VERSION | 113 | #ifndef DESKTOP_VERSION |
114 | fileName= QString(getenv("QPEDIR"))+"/pics/kdepim/"+name | 114 | fileName= QString(getenv("QPEDIR"))+"/pics/kdepim/"+name |
115 | #else | 115 | #else |
116 | fileName = qApp->applicationDirPath () + "/kdepim/"+ name; | 116 | fileName = qApp->applicationDirPath () + "/kdepim/"+ name; |
117 | #endif | 117 | #endif |
118 | mLocaleDict = 0; | 118 | mLocaleDict = 0; |
119 | if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) { | 119 | if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) { |
120 | 120 | ||
121 | if ( mPreferredLanguage == 1 ) | 121 | if ( mPreferredLanguage == 1 ) |
122 | fileName = fileName+"germantranslation.txt"; | 122 | fileName = fileName+"germantranslation.txt"; |
123 | else if ( mPreferredLanguage == 4 ) | 123 | else if ( mPreferredLanguage == 4 ) |
124 | fileName = fileName+"usertranslation.txt"; | 124 | fileName = fileName+"usertranslation.txt"; |
125 | else if ( mPreferredLanguage == 2 ) | 125 | else if ( mPreferredLanguage == 2 ) |
126 | fileName = fileName+"frenchtranslation.txt"; | 126 | fileName = fileName+"frenchtranslation.txt"; |
127 | else if ( mPreferredLanguage == 3 ) | 127 | else if ( mPreferredLanguage == 3 ) |
128 | fileName = fileName+"italiantranslation.txt"; | 128 | fileName = fileName+"italiantranslation.txt"; |
129 | QFile file( fileName ); | 129 | QFile file( fileName ); |
130 | if (file.open( IO_ReadOnly ) ) { | 130 | if (file.open( IO_ReadOnly ) ) { |
131 | QTextStream ts( &file ); | 131 | QTextStream ts( &file ); |
132 | ts.setEncoding( QTextStream::Latin1 ); | 132 | ts.setEncoding( QTextStream::Latin1 ); |
133 | //ts.setCodec( QTextCodec::latin1 ); | 133 | //ts.setCodec( QTextCodec::latin1 ); |
134 | QString text = ts.read(); | 134 | QString text = ts.read(); |
135 | file.close(); | 135 | file.close(); |
136 | text.replace( QRegExp("\\\\n"), "\n" ); | 136 | text.replace( QRegExp("\\\\n"), "\n" ); |
137 | QString line; | 137 | QString line; |
138 | QString we; | 138 | QString we; |
139 | QString wt; | 139 | QString wt; |
140 | int br = 0; | 140 | int br = 0; |
141 | int nbr; | 141 | int nbr; |
142 | nbr = text.find ( "},", br ); | 142 | nbr = text.find ( "},", br ); |
143 | line = text.mid( br, nbr - br ); | 143 | line = text.mid( br, nbr - br ); |
144 | br = nbr+1; | 144 | br = nbr+1; |
145 | int se, ee, st, et; | 145 | int se, ee, st, et; |
146 | mLocaleDict = new QDict<QString>; | 146 | mLocaleDict = new QDict<QString>; |
147 | mLocaleDict->setAutoDelete( true ); | ||
147 | QString end = "{ \"\",\"\" }"; | 148 | QString end = "{ \"\",\"\" }"; |
148 | while ( (line != end) && (br > 1) ) { | 149 | while ( (line != end) && (br > 1) ) { |
149 | //qDebug("%d *%s* ", br, line.latin1()); | 150 | //qDebug("%d *%s* ", br, line.latin1()); |
150 | se = line.find("\"")+1; | 151 | se = line.find("\"")+1; |
151 | et = line.findRev("\"",-1); | 152 | et = line.findRev("\"",-1); |
152 | ee = line.find("\",\""); | 153 | ee = line.find("\",\""); |
153 | st = ee+3; | 154 | st = ee+3; |
154 | we = line.mid( se, ee-se ); | 155 | we = line.mid( se, ee-se ); |
155 | wt = line.mid( st, et-st ); | 156 | wt = line.mid( st, et-st ); |
156 | //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); | 157 | //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); |
157 | mLocaleDict->insert( we, new QString (wt) ); | 158 | mLocaleDict->insert( we, new QString (wt) ); |
158 | nbr = text.find ( "}", br ); | 159 | nbr = text.find ( "}", br ); |
159 | line = text.mid( br, nbr - br ); | 160 | line = text.mid( br, nbr - br ); |
160 | br = nbr+1; | 161 | br = nbr+1; |
161 | } | 162 | } |
162 | //qDebug("end *%s* ", end.latin1()); | 163 | //qDebug("end *%s* ", end.latin1()); |
163 | 164 | ||
164 | setLocaleDict( mLocaleDict ); | 165 | setLocaleDict( mLocaleDict ); |
165 | } else { | 166 | } else { |
166 | qDebug("KO: Cannot find translation file %s",fileName.latin1() ); | 167 | qDebug("KO: Cannot find translation file %s",fileName.latin1() ); |
167 | } | 168 | } |
168 | } | 169 | } |
169 | } | 170 | } |
170 | 171 | ||
171 | KGlobal::locale()->setHore24Format( !mPreferredTime ); | 172 | KGlobal::locale()->setHore24Format( !mPreferredTime ); |
172 | KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday ); | 173 | KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday ); |
173 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)mPreferredDate ); | 174 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)mPreferredDate ); |
174 | KGlobal::locale()->setLanguage( mPreferredLanguage ); | 175 | KGlobal::locale()->setLanguage( mPreferredLanguage ); |
175 | QString dummy = mUserDateFormatLong; | 176 | QString dummy = mUserDateFormatLong; |
176 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 177 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
177 | dummy = mUserDateFormatShort; | 178 | dummy = mUserDateFormatShort; |
178 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 179 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
179 | KGlobal::locale()->setDaylightSaving( mUseDaylightsaving, | 180 | KGlobal::locale()->setDaylightSaving( mUseDaylightsaving, |
180 | mDaylightsavingStart, | 181 | mDaylightsavingStart, |
181 | mDaylightsavingEnd ); | 182 | mDaylightsavingEnd ); |
182 | KGlobal::locale()->setTimezone( mTimeZoneId, mTimeZoneAdd30min ); | 183 | KGlobal::locale()->setTimezone( mTimeZoneId, mTimeZoneAdd30min ); |
183 | 184 | ||
184 | } | 185 | } |
185 | KPimGlobalPrefs::~KPimGlobalPrefs() | 186 | KPimGlobalPrefs::~KPimGlobalPrefs() |
186 | { | 187 | { |
187 | if (sInstance == this) | 188 | if (sInstance == this) |
188 | sInstance = staticDeleterGP.setObject(0); | 189 | sInstance = staticDeleterGP.setObject(0); |
189 | else | 190 | else |
190 | qDebug("Whats this? Error in KPimGlobalPrefs::~KPimGlobalPrefs() ?"); | 191 | qDebug("Whats this? Error in KPimGlobalPrefs::~KPimGlobalPrefs() ?"); |
191 | //qDebug("KPimGlobalPrefs::~KPimGlobalPrefs() "); | ||
192 | writeConfig(); | ||
193 | if ( mLocaleDict ) | 192 | if ( mLocaleDict ) |
194 | delete mLocaleDict; | 193 | delete mLocaleDict; |
195 | } | 194 | } |
196 | 195 | ||
197 | KPimGlobalPrefs *KPimGlobalPrefs::instance() | 196 | KPimGlobalPrefs *KPimGlobalPrefs::instance() |
198 | { | 197 | { |
199 | if ( !sInstance ) { | 198 | if ( !sInstance ) { |
200 | sInstance = staticDeleterGP.setObject( new KPimGlobalPrefs() ); | 199 | sInstance = staticDeleterGP.setObject( new KPimGlobalPrefs() ); |
201 | sInstance->readConfig(); | 200 | sInstance->readConfig(); |
202 | } | 201 | } |
203 | 202 | ||
204 | return sInstance; | 203 | return sInstance; |
205 | } | 204 | } |
diff --git a/microkde/kdeui/klistview.cpp b/microkde/kdeui/klistview.cpp index 5b50ba9..3c809b4 100644 --- a/microkde/kdeui/klistview.cpp +++ b/microkde/kdeui/klistview.cpp | |||
@@ -1,2192 +1,2191 @@ | |||
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 | Copyright (C) 2000 Charles Samuels <charles@kde.org> | 3 | Copyright (C) 2000 Charles Samuels <charles@kde.org> |
4 | Copyright (C) 2000 Peter Putzer | 4 | Copyright (C) 2000 Peter Putzer |
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 version 2 as published by the Free Software Foundation. | 8 | License version 2 as published by the Free Software Foundation. |
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 <qdragobject.h> | 21 | #include <qdragobject.h> |
22 | #include <qtimer.h> | 22 | #include <qtimer.h> |
23 | #include <qheader.h> | 23 | #include <qheader.h> |
24 | #include <qcursor.h> | 24 | #include <qcursor.h> |
25 | #include <qtooltip.h> | 25 | #include <qtooltip.h> |
26 | #include <qstyle.h> | 26 | #include <qstyle.h> |
27 | #include <qpainter.h> | 27 | #include <qpainter.h> |
28 | 28 | ||
29 | #include <kglobalsettings.h> | 29 | #include <kglobalsettings.h> |
30 | #include <kconfig.h> | 30 | #include <kconfig.h> |
31 | #include <kconfigbase.h> | 31 | #include <kconfigbase.h> |
32 | //US #include <kcursor.h> | 32 | //US #include <kcursor.h> |
33 | #include <kapplication.h> | 33 | #include <kapplication.h> |
34 | //US #include <kipc.h> | 34 | //US #include <kipc.h> |
35 | #include <kdebug.h> | 35 | #include <kdebug.h> |
36 | #ifdef _WIN32_ | 36 | #ifdef _WIN32_ |
37 | #define Q_WS_QWS | 37 | #define Q_WS_QWS |
38 | #endif | 38 | #endif |
39 | #ifndef _WIN32_ | 39 | #ifndef _WIN32_ |
40 | #define private public | 40 | #define private public |
41 | #include <qlistview.h> | 41 | #include <qlistview.h> |
42 | #undef private | 42 | #undef private |
43 | #endif | 43 | #endif |
44 | #include "klistview.h" | 44 | #include "klistview.h" |
45 | //US #include "klistviewlineedit.h" | 45 | //US #include "klistviewlineedit.h" |
46 | #ifndef DESKTOP_VERSION | 46 | #ifndef DESKTOP_VERSION |
47 | #include <qpe/qpeapplication.h> | 47 | #include <qpe/qpeapplication.h> |
48 | #endif | 48 | #endif |
49 | 49 | ||
50 | // /*US | 50 | // /*US |
51 | class KListView::Tooltip : public QToolTip | 51 | class KListView::Tooltip : public QToolTip |
52 | { | 52 | { |
53 | public: | 53 | public: |
54 | Tooltip (KListView* parent, QToolTipGroup* group = 0L); | 54 | Tooltip (KListView* parent, QToolTipGroup* group = 0L); |
55 | virtual ~Tooltip () {} | 55 | virtual ~Tooltip () {} |
56 | 56 | ||
57 | protected: | 57 | protected: |
58 | // */ | 58 | // */ |
59 | /** | 59 | /** |
60 | * Reimplemented from QToolTip for internal reasons. | 60 | * Reimplemented from QToolTip for internal reasons. |
61 | */ | 61 | */ |
62 | // /*US | 62 | // /*US |
63 | virtual void maybeTip (const QPoint&); | 63 | virtual void maybeTip (const QPoint&); |
64 | 64 | ||
65 | private: | 65 | private: |
66 | KListView* mParent; | 66 | KListView* mParent; |
67 | }; | 67 | }; |
68 | 68 | ||
69 | KListView::Tooltip::Tooltip (KListView* parent, QToolTipGroup* group) | 69 | KListView::Tooltip::Tooltip (KListView* parent, QToolTipGroup* group) |
70 | : QToolTip (parent, group), | 70 | : QToolTip (parent, group), |
71 | mParent (parent) | 71 | mParent (parent) |
72 | { | 72 | { |
73 | } | 73 | } |
74 | 74 | ||
75 | void KListView::Tooltip::maybeTip (const QPoint&) | 75 | void KListView::Tooltip::maybeTip (const QPoint&) |
76 | { | 76 | { |
77 | // FIXME | 77 | // FIXME |
78 | } | 78 | } |
79 | // */ | 79 | // */ |
80 | 80 | ||
81 | class KListView::KListViewPrivate | 81 | class KListView::KListViewPrivate |
82 | { | 82 | { |
83 | public: | 83 | public: |
84 | KListViewPrivate (KListView* listview) | 84 | KListViewPrivate (KListView* listview) |
85 | : pCurrentItem (0L), | 85 | : pCurrentItem (0L), |
86 | autoSelectDelay(1), | 86 | autoSelectDelay(1), |
87 | //US dragDelay (KGlobalSettings::dndEventDelay()), | 87 | //US dragDelay (KGlobalSettings::dndEventDelay()), |
88 | 88 | ||
89 | dragDelay (10), | 89 | dragDelay (10), |
90 | //US editor (new KListViewLineEdit (listview)), | 90 | //US editor (new KListViewLineEdit (listview)), |
91 | cursorInExecuteArea(false), | 91 | cursorInExecuteArea(false), |
92 | bUseSingle(false), | 92 | bUseSingle(false), |
93 | bChangeCursorOverItem(false), | 93 | bChangeCursorOverItem(false), |
94 | itemsMovable (true), | 94 | itemsMovable (true), |
95 | selectedBySimpleMove(false), | 95 | selectedBySimpleMove(false), |
96 | selectedUsingMouse(false), | 96 | selectedUsingMouse(false), |
97 | showContextMenusOnPress(true), | ||
98 | itemsRenameable (false), | 97 | itemsRenameable (false), |
99 | validDrag (false), | 98 | validDrag (false), |
100 | dragEnabled (false), | 99 | dragEnabled (false), |
101 | autoOpen (true), | 100 | autoOpen (true), |
102 | dropVisualizer (true), | 101 | dropVisualizer (true), |
103 | dropHighlighter (false), | 102 | dropHighlighter (false), |
104 | createChildren (true), | 103 | createChildren (true), |
105 | pressedOnSelected (false), | 104 | pressedOnSelected (false), |
106 | wasShiftEvent (false), | 105 | wasShiftEvent (false), |
107 | fullWidth (false), | 106 | fullWidth (false), |
108 | sortAscending(true), | 107 | sortAscending(true), |
109 | tabRename(true), | 108 | tabRename(true), |
110 | sortColumn(0), | 109 | sortColumn(0), |
111 | selectionDirection(0), | 110 | selectionDirection(0), |
112 | tooltipColumn (0), | 111 | tooltipColumn (0), |
113 | selectionMode (Single), | 112 | selectionMode (Single), |
114 | //US contextMenuKey (KGlobalSettings::contextMenuKey()), | 113 | contextMenuKey ( Qt::Key_Menu ),//KGlobalSettings::contextMenuKey()), |
115 | //US showContextMenusOnPress (KGlobalSettings::showContextMenusOnPress()), | 114 | showContextMenusOnPress (true),//showContextMenusOnPress (KGlobalSettings::showContextMenusOnPress()), |
116 | mDropVisualizerWidth (4) | 115 | mDropVisualizerWidth (4) |
117 | { | 116 | { |
118 | renameable += 0; | 117 | renameable += 0; |
119 | //US connect(editor, SIGNAL(done(QListViewItem*,int)), listview, SLOT(doneEditing(QListViewItem*,int))); | 118 | //US connect(editor, SIGNAL(done(QListViewItem*,int)), listview, SLOT(doneEditing(QListViewItem*,int))); |
120 | } | 119 | } |
121 | 120 | ||
122 | ~KListViewPrivate () | 121 | ~KListViewPrivate () |
123 | { | 122 | { |
124 | //US delete editor; | 123 | //US delete editor; |
125 | } | 124 | } |
126 | 125 | ||
127 | QListViewItem* pCurrentItem; | 126 | QListViewItem* pCurrentItem; |
128 | 127 | ||
129 | QTimer autoSelect; | 128 | QTimer autoSelect; |
130 | int autoSelectDelay; | 129 | int autoSelectDelay; |
131 | 130 | ||
132 | QTimer dragExpand; | 131 | QTimer dragExpand; |
133 | QListViewItem* dragOverItem; | 132 | QListViewItem* dragOverItem; |
134 | QPoint dragOverPoint; | 133 | QPoint dragOverPoint; |
135 | 134 | ||
136 | QPoint startDragPos; | 135 | QPoint startDragPos; |
137 | int dragDelay; | 136 | int dragDelay; |
138 | 137 | ||
139 | //US KListViewLineEdit *editor; | 138 | //US KListViewLineEdit *editor; |
140 | QValueList<int> renameable; | 139 | QValueList<int> renameable; |
141 | 140 | ||
142 | bool cursorInExecuteArea:1; | 141 | bool cursorInExecuteArea:1; |
143 | bool bUseSingle:1; | 142 | bool bUseSingle:1; |
144 | bool bChangeCursorOverItem:1; | 143 | bool bChangeCursorOverItem:1; |
145 | bool itemsMovable:1; | 144 | bool itemsMovable:1; |
146 | bool selectedBySimpleMove : 1; | 145 | bool selectedBySimpleMove : 1; |
147 | bool selectedUsingMouse:1; | 146 | bool selectedUsingMouse:1; |
148 | bool itemsRenameable:1; | 147 | bool itemsRenameable:1; |
149 | bool validDrag:1; | 148 | bool validDrag:1; |
150 | bool dragEnabled:1; | 149 | bool dragEnabled:1; |
151 | bool autoOpen:1; | 150 | bool autoOpen:1; |
152 | bool dropVisualizer:1; | 151 | bool dropVisualizer:1; |
153 | bool dropHighlighter:1; | 152 | bool dropHighlighter:1; |
154 | bool createChildren:1; | 153 | bool createChildren:1; |
155 | bool pressedOnSelected:1; | 154 | bool pressedOnSelected:1; |
156 | bool wasShiftEvent:1; | 155 | bool wasShiftEvent:1; |
157 | bool fullWidth:1; | 156 | bool fullWidth:1; |
158 | bool sortAscending:1; | 157 | bool sortAscending:1; |
159 | bool tabRename:1; | 158 | bool tabRename:1; |
160 | 159 | ||
161 | int sortColumn; | 160 | int sortColumn; |
162 | 161 | ||
163 | //+1 means downwards (y increases, -1 means upwards, 0 means not selected), aleXXX | 162 | //+1 means downwards (y increases, -1 means upwards, 0 means not selected), aleXXX |
164 | int selectionDirection; | 163 | int selectionDirection; |
165 | int tooltipColumn; | 164 | int tooltipColumn; |
166 | 165 | ||
167 | SelectionModeExt selectionMode; | 166 | SelectionModeExt selectionMode; |
168 | int contextMenuKey; | 167 | int contextMenuKey; |
169 | bool showContextMenusOnPress; | 168 | bool showContextMenusOnPress; |
170 | 169 | ||
171 | QRect mOldDropVisualizer; | 170 | QRect mOldDropVisualizer; |
172 | int mDropVisualizerWidth; | 171 | int mDropVisualizerWidth; |
173 | QRect mOldDropHighlighter; | 172 | QRect mOldDropHighlighter; |
174 | QListViewItem *afterItemDrop; | 173 | QListViewItem *afterItemDrop; |
175 | QListViewItem *parentItemDrop; | 174 | QListViewItem *parentItemDrop; |
176 | 175 | ||
177 | QColor alternateBackground; | 176 | QColor alternateBackground; |
178 | }; | 177 | }; |
179 | 178 | ||
180 | /*US | 179 | /*US |
181 | KListViewLineEdit::KListViewLineEdit(KListView *parent) | 180 | KListViewLineEdit::KListViewLineEdit(KListView *parent) |
182 | : KLineEdit(parent->viewport()), item(0), col(0), p(parent) | 181 | : KLineEdit(parent->viewport()), item(0), col(0), p(parent) |
183 | { | 182 | { |
184 | setFrame( false ); | 183 | setFrame( false ); |
185 | hide(); | 184 | hide(); |
186 | connect( parent, SIGNAL( selectionChanged() ), SLOT( slotSelectionChanged() )); | 185 | connect( parent, SIGNAL( selectionChanged() ), SLOT( slotSelectionChanged() )); |
187 | } | 186 | } |
188 | 187 | ||
189 | KListViewLineEdit::~KListViewLineEdit() | 188 | KListViewLineEdit::~KListViewLineEdit() |
190 | { | 189 | { |
191 | } | 190 | } |
192 | 191 | ||
193 | void KListViewLineEdit::load(QListViewItem *i, int c) | 192 | void KListViewLineEdit::load(QListViewItem *i, int c) |
194 | { | 193 | { |
195 | item=i; | 194 | item=i; |
196 | col=c; | 195 | col=c; |
197 | 196 | ||
198 | QRect rect(p->itemRect(i)); | 197 | QRect rect(p->itemRect(i)); |
199 | setText(item->text(c)); | 198 | setText(item->text(c)); |
200 | 199 | ||
201 | int fieldX = rect.x() - 1; | 200 | int fieldX = rect.x() - 1; |
202 | int fieldW = p->columnWidth(col) + 2; | 201 | int fieldW = p->columnWidth(col) + 2; |
203 | 202 | ||
204 | int pos = p->header()->mapToIndex(col); | 203 | int pos = p->header()->mapToIndex(col); |
205 | for ( int index = 0; index < pos; index++ ) | 204 | for ( int index = 0; index < pos; index++ ) |
206 | fieldX += p->columnWidth( p->header()->mapToSection( index )); | 205 | fieldX += p->columnWidth( p->header()->mapToSection( index )); |
207 | 206 | ||
208 | if ( col == 0 ) { | 207 | if ( col == 0 ) { |
209 | int d = i->depth() + (p->rootIsDecorated() ? 1 : 0); | 208 | int d = i->depth() + (p->rootIsDecorated() ? 1 : 0); |
210 | d *= p->treeStepSize(); | 209 | d *= p->treeStepSize(); |
211 | fieldX += d; | 210 | fieldX += d; |
212 | fieldW -= d; | 211 | fieldW -= d; |
213 | } | 212 | } |
214 | 213 | ||
215 | if ( i->pixmap( col ) ) {// add width of pixmap | 214 | if ( i->pixmap( col ) ) {// add width of pixmap |
216 | int d = i->pixmap( col )->width(); | 215 | int d = i->pixmap( col )->width(); |
217 | fieldX += d; | 216 | fieldX += d; |
218 | fieldW -= d; | 217 | fieldW -= d; |
219 | } | 218 | } |
220 | 219 | ||
221 | setGeometry(fieldX, rect.y() - 1, fieldW, rect.height() + 2); | 220 | setGeometry(fieldX, rect.y() - 1, fieldW, rect.height() + 2); |
222 | show(); | 221 | show(); |
223 | setFocus(); | 222 | setFocus(); |
224 | } | 223 | } |
225 | */ | 224 | */ |
226 | /*Helper functions to for | 225 | /*Helper functions to for |
227 | *tabOrderedRename functionality. | 226 | *tabOrderedRename functionality. |
228 | */ | 227 | */ |
229 | 228 | ||
230 | static int nextCol (KListView *pl, QListViewItem *pi, int start, int dir) | 229 | static int nextCol (KListView *pl, QListViewItem *pi, int start, int dir) |
231 | { | 230 | { |
232 | if (pi) | 231 | if (pi) |
233 | { | 232 | { |
234 | //Find the next renameable column in the current row | 233 | //Find the next renameable column in the current row |
235 | for (; ((dir == +1) ? (start < pl->columns()) : (start >= 0)); start += dir) | 234 | for (; ((dir == +1) ? (start < pl->columns()) : (start >= 0)); start += dir) |
236 | if (pl->isRenameable(start)) | 235 | if (pl->isRenameable(start)) |
237 | return start; | 236 | return start; |
238 | } | 237 | } |
239 | 238 | ||
240 | return -1; | 239 | return -1; |
241 | } | 240 | } |
242 | 241 | ||
243 | static QListViewItem *prevItem (QListViewItem *pi) | 242 | static QListViewItem *prevItem (QListViewItem *pi) |
244 | { | 243 | { |
245 | QListViewItem *pa = pi->itemAbove(); | 244 | QListViewItem *pa = pi->itemAbove(); |
246 | 245 | ||
247 | /*Does what the QListViewItem::previousSibling() | 246 | /*Does what the QListViewItem::previousSibling() |
248 | *of my dreams would do. | 247 | *of my dreams would do. |
249 | */ | 248 | */ |
250 | if (pa && pa->parent() == pi->parent()) | 249 | if (pa && pa->parent() == pi->parent()) |
251 | return pa; | 250 | return pa; |
252 | 251 | ||
253 | return NULL; | 252 | return NULL; |
254 | } | 253 | } |
255 | 254 | ||
256 | static QListViewItem *lastQChild (QListViewItem *pi) | 255 | static QListViewItem *lastQChild (QListViewItem *pi) |
257 | { | 256 | { |
258 | if (pi) | 257 | if (pi) |
259 | { | 258 | { |
260 | /*Since there's no QListViewItem::lastChild(). | 259 | /*Since there's no QListViewItem::lastChild(). |
261 | *This finds the last sibling for the given | 260 | *This finds the last sibling for the given |
262 | *item. | 261 | *item. |
263 | */ | 262 | */ |
264 | for (QListViewItem *pt = pi->nextSibling(); pt; pt = pt->nextSibling()) | 263 | for (QListViewItem *pt = pi->nextSibling(); pt; pt = pt->nextSibling()) |
265 | pi = pt; | 264 | pi = pt; |
266 | } | 265 | } |
267 | 266 | ||
268 | return pi; | 267 | return pi; |
269 | } | 268 | } |
270 | /*US | 269 | /*US |
271 | void KListViewLineEdit::selectNextCell (QListViewItem *pitem, int column, bool forward) | 270 | void KListViewLineEdit::selectNextCell (QListViewItem *pitem, int column, bool forward) |
272 | { | 271 | { |
273 | const int ncols = p->columns(); | 272 | const int ncols = p->columns(); |
274 | const int dir = forward ? +1 : -1; | 273 | const int dir = forward ? +1 : -1; |
275 | const int restart = forward ? 0 : (ncols - 1); | 274 | const int restart = forward ? 0 : (ncols - 1); |
276 | QListViewItem *top = (pitem && pitem->parent()) | 275 | QListViewItem *top = (pitem && pitem->parent()) |
277 | ? pitem->parent()->firstChild() | 276 | ? pitem->parent()->firstChild() |
278 | : p->firstChild(); | 277 | : p->firstChild(); |
279 | QListViewItem *pi = pitem; | 278 | QListViewItem *pi = pitem; |
280 | 279 | ||
281 | terminate(); //Save current changes | 280 | terminate(); //Save current changes |
282 | 281 | ||
283 | do | 282 | do |
284 | { | 283 | { |
285 | */ | 284 | */ |
286 | /*Check the rest of the current row for an editable column, | 285 | /*Check the rest of the current row for an editable column, |
287 | *if that fails, check the entire next/previous row. The | 286 | *if that fails, check the entire next/previous row. The |
288 | *last case goes back to the first item in the current branch | 287 | *last case goes back to the first item in the current branch |
289 | *or the last item in the current branch depending on the | 288 | *or the last item in the current branch depending on the |
290 | *direction. | 289 | *direction. |
291 | */ | 290 | */ |
292 | /*US | 291 | /*US |
293 | if ((column = nextCol(p, pi, column + dir, dir)) != -1 || | 292 | if ((column = nextCol(p, pi, column + dir, dir)) != -1 || |
294 | (column = nextCol(p, (pi = (forward ? pi->nextSibling() : prevItem(pi))), restart, dir)) != -1 || | 293 | (column = nextCol(p, (pi = (forward ? pi->nextSibling() : prevItem(pi))), restart, dir)) != -1 || |
295 | (column = nextCol(p, (pi = (forward ? top : lastQChild(pitem))), restart, dir)) != -1) | 294 | (column = nextCol(p, (pi = (forward ? top : lastQChild(pitem))), restart, dir)) != -1) |
296 | { | 295 | { |
297 | if (pi) | 296 | if (pi) |
298 | { | 297 | { |
299 | p->setCurrentItem(pi); //Calls terminate | 298 | p->setCurrentItem(pi); //Calls terminate |
300 | p->rename(pi, column); | 299 | p->rename(pi, column); |
301 | */ | 300 | */ |
302 | /*Some listviews may override rename() to | 301 | /*Some listviews may override rename() to |
303 | *prevent certain items from being renamed, | 302 | *prevent certain items from being renamed, |
304 | *if this is done, [m_]item will be NULL | 303 | *if this is done, [m_]item will be NULL |
305 | *after the rename() call... try again. | 304 | *after the rename() call... try again. |
306 | */ | 305 | */ |
307 | /*US | 306 | /*US |
308 | if (!item) | 307 | if (!item) |
309 | continue; | 308 | continue; |
310 | 309 | ||
311 | break; | 310 | break; |
312 | } | 311 | } |
313 | } | 312 | } |
314 | } | 313 | } |
315 | while (pi && !item); | 314 | while (pi && !item); |
316 | } | 315 | } |
317 | */ | 316 | */ |
318 | 317 | ||
319 | /*US | 318 | /*US |
320 | #ifdef KeyPress | 319 | #ifdef KeyPress |
321 | #undef KeyPress | 320 | #undef KeyPress |
322 | #endif | 321 | #endif |
323 | 322 | ||
324 | bool KListViewLineEdit::event (QEvent *pe) | 323 | bool KListViewLineEdit::event (QEvent *pe) |
325 | { | 324 | { |
326 | if (pe->type() == QEvent::KeyPress) | 325 | if (pe->type() == QEvent::KeyPress) |
327 | { | 326 | { |
328 | QKeyEvent *k = (QKeyEvent *) pe; | 327 | QKeyEvent *k = (QKeyEvent *) pe; |
329 | 328 | ||
330 | if ((k->key() == Qt::Key_Backtab || k->key() == Qt::Key_Tab) && | 329 | if ((k->key() == Qt::Key_Backtab || k->key() == Qt::Key_Tab) && |
331 | p->tabOrderedRenaming() && p->itemsRenameable() && | 330 | p->tabOrderedRenaming() && p->itemsRenameable() && |
332 | !(k->state() & ControlButton || k->state() & AltButton)) | 331 | !(k->state() & ControlButton || k->state() & AltButton)) |
333 | { | 332 | { |
334 | selectNextCell(item, col, | 333 | selectNextCell(item, col, |
335 | (k->key() == Key_Tab && !(k->state() & ShiftButton))); | 334 | (k->key() == Key_Tab && !(k->state() & ShiftButton))); |
336 | return true; | 335 | return true; |
337 | } | 336 | } |
338 | } | 337 | } |
339 | 338 | ||
340 | return KLineEdit::event(pe); | 339 | return KLineEdit::event(pe); |
341 | } | 340 | } |
342 | 341 | ||
343 | void KListViewLineEdit::keyPressEvent(QKeyEvent *e) | 342 | void KListViewLineEdit::keyPressEvent(QKeyEvent *e) |
344 | { | 343 | { |
345 | if(e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) | 344 | if(e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) |
346 | terminate(true); | 345 | terminate(true); |
347 | else if(e->key() == Qt::Key_Escape) | 346 | else if(e->key() == Qt::Key_Escape) |
348 | terminate(false); | 347 | terminate(false); |
349 | else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Up) | 348 | else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Up) |
350 | { | 349 | { |
351 | terminate(true); | 350 | terminate(true); |
352 | KLineEdit::keyPressEvent(e); | 351 | KLineEdit::keyPressEvent(e); |
353 | } | 352 | } |
354 | else | 353 | else |
355 | KLineEdit::keyPressEvent(e); | 354 | KLineEdit::keyPressEvent(e); |
356 | } | 355 | } |
357 | 356 | ||
358 | void KListViewLineEdit::terminate() | 357 | void KListViewLineEdit::terminate() |
359 | { | 358 | { |
360 | terminate(true); | 359 | terminate(true); |
361 | } | 360 | } |
362 | 361 | ||
363 | void KListViewLineEdit::terminate(bool commit) | 362 | void KListViewLineEdit::terminate(bool commit) |
364 | { | 363 | { |
365 | if ( item ) | 364 | if ( item ) |
366 | { | 365 | { |
367 | //kdDebug() << "KListViewLineEdit::terminate " << commit << endl; | 366 | //kdDebug() << "KListViewLineEdit::terminate " << commit << endl; |
368 | if (commit) | 367 | if (commit) |
369 | item->setText(col, text()); | 368 | item->setText(col, text()); |
370 | int c=col; | 369 | int c=col; |
371 | QListViewItem *i=item; | 370 | QListViewItem *i=item; |
372 | col=0; | 371 | col=0; |
373 | item=0; | 372 | item=0; |
374 | hide(); // will call focusOutEvent, that's why we set item=0 before | 373 | hide(); // will call focusOutEvent, that's why we set item=0 before |
375 | emit done(i,c); | 374 | emit done(i,c); |
376 | } | 375 | } |
377 | } | 376 | } |
378 | 377 | ||
379 | void KListViewLineEdit::focusOutEvent(QFocusEvent *ev) | 378 | void KListViewLineEdit::focusOutEvent(QFocusEvent *ev) |
380 | { | 379 | { |
381 | QFocusEvent * focusEv = static_cast<QFocusEvent*>(ev); | 380 | QFocusEvent * focusEv = static_cast<QFocusEvent*>(ev); |
382 | // Don't let a RMB close the editor | 381 | // Don't let a RMB close the editor |
383 | if (focusEv->reason() != QFocusEvent::Popup && focusEv->reason() != QFocusEvent::ActiveWindow) | 382 | if (focusEv->reason() != QFocusEvent::Popup && focusEv->reason() != QFocusEvent::ActiveWindow) |
384 | terminate(true); | 383 | terminate(true); |
385 | } | 384 | } |
386 | 385 | ||
387 | void KListViewLineEdit::paintEvent( QPaintEvent *e ) | 386 | void KListViewLineEdit::paintEvent( QPaintEvent *e ) |
388 | { | 387 | { |
389 | KLineEdit::paintEvent( e ); | 388 | KLineEdit::paintEvent( e ); |
390 | 389 | ||
391 | if ( !frame() ) { | 390 | if ( !frame() ) { |
392 | QPainter p( this ); | 391 | QPainter p( this ); |
393 | p.setClipRegion( e->region() ); | 392 | p.setClipRegion( e->region() ); |
394 | p.drawRect( rect() ); | 393 | p.drawRect( rect() ); |
395 | } | 394 | } |
396 | } | 395 | } |
397 | 396 | ||
398 | // selection changed -> terminate. As our "item" can be already deleted, | 397 | // selection changed -> terminate. As our "item" can be already deleted, |
399 | // we can't call terminate(false), because that would emit done() with | 398 | // we can't call terminate(false), because that would emit done() with |
400 | // a dangling pointer to "item". | 399 | // a dangling pointer to "item". |
401 | void KListViewLineEdit::slotSelectionChanged() | 400 | void KListViewLineEdit::slotSelectionChanged() |
402 | { | 401 | { |
403 | item = 0; | 402 | item = 0; |
404 | col = 0; | 403 | col = 0; |
405 | hide(); | 404 | hide(); |
406 | } | 405 | } |
407 | */ | 406 | */ |
408 | 407 | ||
409 | KListView::KListView( QWidget *parent, const char *name ) | 408 | KListView::KListView( QWidget *parent, const char *name ) |
410 | : QListView( parent, name ), | 409 | : QListView( parent, name ), |
411 | d (new KListViewPrivate (this)) | 410 | d (new KListViewPrivate (this)) |
412 | { | 411 | { |
413 | #ifndef DESKTOP_VERSION | 412 | #ifndef DESKTOP_VERSION |
414 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 413 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
415 | #endif | 414 | #endif |
416 | //US setDragAutoScroll(true); | 415 | //US setDragAutoScroll(true); |
417 | 416 | ||
418 | connect( this, SIGNAL( onViewport() ), | 417 | connect( this, SIGNAL( onViewport() ), |
419 | this, SLOT( slotOnViewport() ) ); | 418 | this, SLOT( slotOnViewport() ) ); |
420 | connect( this, SIGNAL( onItem( QListViewItem * ) ), | 419 | connect( this, SIGNAL( onItem( QListViewItem * ) ), |
421 | this, SLOT( slotOnItem( QListViewItem * ) ) ); | 420 | this, SLOT( slotOnItem( QListViewItem * ) ) ); |
422 | 421 | ||
423 | connect (this, SIGNAL(contentsMoving(int,int)), | 422 | connect (this, SIGNAL(contentsMoving(int,int)), |
424 | this, SLOT(cleanDropVisualizer())); | 423 | this, SLOT(cleanDropVisualizer())); |
425 | connect (this, SIGNAL(contentsMoving(int,int)), | 424 | connect (this, SIGNAL(contentsMoving(int,int)), |
426 | this, SLOT(cleanItemHighlighter())); | 425 | this, SLOT(cleanItemHighlighter())); |
427 | 426 | ||
428 | /*US | 427 | /*US |
429 | slotSettingsChanged(KApplication::SETTINGS_MOUSE); | 428 | slotSettingsChanged(KApplication::SETTINGS_MOUSE); |
430 | 429 | ||
431 | if (kapp) | 430 | if (kapp) |
432 | { | 431 | { |
433 | connect( kapp, SIGNAL( settingsChanged(int) ), SLOT( slotSettingsChanged(int) ) ); | 432 | connect( kapp, SIGNAL( settingsChanged(int) ), SLOT( slotSettingsChanged(int) ) ); |
434 | kapp->addKipcEventMask( KIPC::SettingsChanged ); | 433 | kapp->addKipcEventMask( KIPC::SettingsChanged ); |
435 | } | 434 | } |
436 | */ | 435 | */ |
437 | slotSettingsChanged(1); //US do this to initialize the connections | 436 | slotSettingsChanged(1); //US do this to initialize the connections |
438 | 437 | ||
439 | 438 | ||
440 | connect(&d->autoSelect, SIGNAL( timeout() ), | 439 | connect(&d->autoSelect, SIGNAL( timeout() ), |
441 | this, SLOT( slotAutoSelect() ) ); | 440 | this, SLOT( slotAutoSelect() ) ); |
442 | connect(&d->dragExpand, SIGNAL( timeout() ), | 441 | connect(&d->dragExpand, SIGNAL( timeout() ), |
443 | this, SLOT( slotDragExpand() ) ); | 442 | this, SLOT( slotDragExpand() ) ); |
444 | 443 | ||
445 | // context menu handling | 444 | // context menu handling |
446 | if (d->showContextMenusOnPress) | 445 | if (d->showContextMenusOnPress) |
447 | { | 446 | { |
448 | connect (this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), | 447 | connect (this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), |
449 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 448 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
450 | } | 449 | } |
451 | else | 450 | else |
452 | { | 451 | { |
453 | connect (this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), | 452 | connect (this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), |
454 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 453 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
455 | } | 454 | } |
456 | 455 | ||
457 | connect (this, SIGNAL (menuShortCutPressed (KListView*, QListViewItem*)), | 456 | connect (this, SIGNAL (menuShortCutPressed (KListView*, QListViewItem*)), |
458 | this, SLOT (emitContextMenu (KListView*, QListViewItem*))); | 457 | this, SLOT (emitContextMenu (KListView*, QListViewItem*))); |
459 | 458 | ||
460 | 459 | ||
461 | //qDebug("KListView::KListView make alternate color configurable"); | 460 | //qDebug("KListView::KListView make alternate color configurable"); |
462 | //US d->alternateBackground = KGlobalSettings::alternateBackgroundColor(); | 461 | //US d->alternateBackground = KGlobalSettings::alternateBackgroundColor(); |
463 | d->alternateBackground = QColor(240, 240, 240); | 462 | d->alternateBackground = QColor(240, 240, 240); |
464 | } | 463 | } |
465 | 464 | ||
466 | 465 | ||
467 | 466 | ||
468 | KListView::~KListView() | 467 | KListView::~KListView() |
469 | { | 468 | { |
470 | delete d; | 469 | delete d; |
471 | } | 470 | } |
472 | 471 | ||
473 | bool KListView::isExecuteArea( const QPoint& point ) | 472 | bool KListView::isExecuteArea( const QPoint& point ) |
474 | { | 473 | { |
475 | if ( itemAt( point ) ) | 474 | if ( itemAt( point ) ) |
476 | return isExecuteArea( point.x() ); | 475 | return isExecuteArea( point.x() ); |
477 | 476 | ||
478 | return false; | 477 | return false; |
479 | } | 478 | } |
480 | 479 | ||
481 | bool KListView::isExecuteArea( int x ) | 480 | bool KListView::isExecuteArea( int x ) |
482 | { | 481 | { |
483 | if( allColumnsShowFocus() ) | 482 | if( allColumnsShowFocus() ) |
484 | return true; | 483 | return true; |
485 | else { | 484 | else { |
486 | int offset = 0; | 485 | int offset = 0; |
487 | int width = columnWidth( 0 ); | 486 | int width = columnWidth( 0 ); |
488 | int pos = header()->mapToIndex( 0 ); | 487 | int pos = header()->mapToIndex( 0 ); |
489 | 488 | ||
490 | for ( int index = 0; index < pos; index++ ) | 489 | for ( int index = 0; index < pos; index++ ) |
491 | offset += columnWidth( header()->mapToSection( index ) ); | 490 | offset += columnWidth( header()->mapToSection( index ) ); |
492 | 491 | ||
493 | x += contentsX(); // in case of a horizontal scrollbar | 492 | x += contentsX(); // in case of a horizontal scrollbar |
494 | return ( x > offset && x < ( offset + width ) ); | 493 | return ( x > offset && x < ( offset + width ) ); |
495 | } | 494 | } |
496 | } | 495 | } |
497 | 496 | ||
498 | void KListView::slotOnItem( QListViewItem *item ) | 497 | void KListView::slotOnItem( QListViewItem *item ) |
499 | { | 498 | { |
500 | QPoint vp = viewport()->mapFromGlobal( QCursor::pos() ); | 499 | QPoint vp = viewport()->mapFromGlobal( QCursor::pos() ); |
501 | if ( item && isExecuteArea( vp.x() ) && (d->autoSelectDelay > -1) && d->bUseSingle ) { | 500 | if ( item && isExecuteArea( vp.x() ) && (d->autoSelectDelay > -1) && d->bUseSingle ) { |
502 | d->autoSelect.start( d->autoSelectDelay, true ); | 501 | d->autoSelect.start( d->autoSelectDelay, true ); |
503 | d->pCurrentItem = item; | 502 | d->pCurrentItem = item; |
504 | } | 503 | } |
505 | } | 504 | } |
506 | 505 | ||
507 | void KListView::slotOnViewport() | 506 | void KListView::slotOnViewport() |
508 | { | 507 | { |
509 | if ( d->bChangeCursorOverItem ) | 508 | if ( d->bChangeCursorOverItem ) |
510 | viewport()->unsetCursor(); | 509 | viewport()->unsetCursor(); |
511 | 510 | ||
512 | d->autoSelect.stop(); | 511 | d->autoSelect.stop(); |
513 | d->pCurrentItem = 0L; | 512 | d->pCurrentItem = 0L; |
514 | } | 513 | } |
515 | 514 | ||
516 | void KListView::slotSettingsChanged(int category) | 515 | void KListView::slotSettingsChanged(int category) |
517 | { | 516 | { |
518 | //qDebug("KListView::slotSettingsChanged has to be verified"); | 517 | //qDebug("KListView::slotSettingsChanged has to be verified"); |
519 | /*US | 518 | /*US |
520 | 519 | ||
521 | switch (category) | 520 | switch (category) |
522 | { | 521 | { |
523 | case KApplication::SETTINGS_MOUSE: | 522 | case KApplication::SETTINGS_MOUSE: |
524 | d->dragDelay = KGlobalSettings::dndEventDelay(); | 523 | d->dragDelay = KGlobalSettings::dndEventDelay(); |
525 | d->bUseSingle = KGlobalSettings::singleClick(); | 524 | d->bUseSingle = KGlobalSettings::singleClick(); |
526 | 525 | ||
527 | disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), | 526 | disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), |
528 | this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); | 527 | this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); |
529 | 528 | ||
530 | if( d->bUseSingle ) | 529 | if( d->bUseSingle ) |
531 | connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), | 530 | connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), |
532 | this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); | 531 | this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); |
533 | 532 | ||
534 | d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); | 533 | d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); |
535 | d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); | 534 | d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); |
536 | 535 | ||
537 | if( !d->bUseSingle || !d->bChangeCursorOverItem ) | 536 | if( !d->bUseSingle || !d->bChangeCursorOverItem ) |
538 | viewport()->unsetCursor(); | 537 | viewport()->unsetCursor(); |
539 | 538 | ||
540 | break; | 539 | break; |
541 | 540 | ||
542 | case KApplication::SETTINGS_POPUPMENU: | 541 | case KApplication::SETTINGS_POPUPMENU: |
543 | d->contextMenuKey = KGlobalSettings::contextMenuKey (); | 542 | d->contextMenuKey = KGlobalSettings::contextMenuKey (); |
544 | d->showContextMenusOnPress = KGlobalSettings::showContextMenusOnPress (); | 543 | d->showContextMenusOnPress = KGlobalSettings::showContextMenusOnPress (); |
545 | 544 | ||
546 | if (d->showContextMenusOnPress) | 545 | if (d->showContextMenusOnPress) |
547 | { | 546 | { |
548 | disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 547 | disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
549 | 548 | ||
550 | connect(this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), | 549 | connect(this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), |
551 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 550 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
552 | } | 551 | } |
553 | else | 552 | else |
554 | { | 553 | { |
555 | disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 554 | disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
556 | 555 | ||
557 | connect(this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), | 556 | connect(this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), |
558 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); | 557 | this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); |
559 | } | 558 | } |
560 | break; | 559 | break; |
561 | 560 | ||
562 | default: | 561 | default: |
563 | break; | 562 | break; |
564 | } | 563 | } |
565 | */ | 564 | */ |
566 | 565 | ||
567 | if( d->bUseSingle ) | 566 | if( d->bUseSingle ) |
568 | connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), | 567 | connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), |
569 | this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); | 568 | this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); |
570 | 569 | ||
571 | } | 570 | } |
572 | 571 | ||
573 | void KListView::slotAutoSelect() | 572 | void KListView::slotAutoSelect() |
574 | { | 573 | { |
575 | // check that the item still exists | 574 | // check that the item still exists |
576 | if( itemIndex( d->pCurrentItem ) == -1 ) | 575 | if( itemIndex( d->pCurrentItem ) == -1 ) |
577 | return; | 576 | return; |
578 | 577 | ||
579 | if (!isActiveWindow()) | 578 | if (!isActiveWindow()) |
580 | { | 579 | { |
581 | d->autoSelect.stop(); | 580 | d->autoSelect.stop(); |
582 | return; | 581 | return; |
583 | } | 582 | } |
584 | 583 | ||
585 | //Give this widget the keyboard focus. | 584 | //Give this widget the keyboard focus. |
586 | if( !hasFocus() ) | 585 | if( !hasFocus() ) |
587 | setFocus(); | 586 | setFocus(); |
588 | 587 | ||
589 | QListViewItem* previousItem = currentItem(); | 588 | QListViewItem* previousItem = currentItem(); |
590 | setCurrentItem( d->pCurrentItem ); | 589 | setCurrentItem( d->pCurrentItem ); |
591 | 590 | ||
592 | #if 0 | 591 | #if 0 |
593 | #ifndef Q_WS_QWS | 592 | #ifndef Q_WS_QWS |
594 | // FIXME(E): Implement for Qt Embedded | 593 | // FIXME(E): Implement for Qt Embedded |
595 | if( d->pCurrentItem ) { | 594 | if( d->pCurrentItem ) { |
596 | //Shift pressed? | 595 | //Shift pressed? |
597 | if( (keybstate & ShiftMask) ) { | 596 | if( (keybstate & ShiftMask) ) { |
598 | bool block = signalsBlocked(); | 597 | bool block = signalsBlocked(); |
599 | blockSignals( true ); | 598 | blockSignals( true ); |
600 | 599 | ||
601 | //No Ctrl? Then clear before! | 600 | //No Ctrl? Then clear before! |
602 | if( !(keybstate & ControlMask) ) | 601 | if( !(keybstate & ControlMask) ) |
603 | clearSelection(); | 602 | clearSelection(); |
604 | 603 | ||
605 | bool select = !d->pCurrentItem->isSelected(); | 604 | bool select = !d->pCurrentItem->isSelected(); |
606 | bool update = viewport()->isUpdatesEnabled(); | 605 | bool update = viewport()->isUpdatesEnabled(); |
607 | viewport()->setUpdatesEnabled( false ); | 606 | viewport()->setUpdatesEnabled( false ); |
608 | 607 | ||
609 | bool down = previousItem->itemPos() < d->pCurrentItem->itemPos(); | 608 | bool down = previousItem->itemPos() < d->pCurrentItem->itemPos(); |
610 | QListViewItemIterator lit( down ? previousItem : d->pCurrentItem ); | 609 | QListViewItemIterator lit( down ? previousItem : d->pCurrentItem ); |
611 | for ( ; lit.current(); ++lit ) { | 610 | for ( ; lit.current(); ++lit ) { |
612 | if ( down && lit.current() == d->pCurrentItem ) { | 611 | if ( down && lit.current() == d->pCurrentItem ) { |
613 | d->pCurrentItem->setSelected( select ); | 612 | d->pCurrentItem->setSelected( select ); |
614 | break; | 613 | break; |
615 | } | 614 | } |
616 | if ( !down && lit.current() == previousItem ) { | 615 | if ( !down && lit.current() == previousItem ) { |
617 | previousItem->setSelected( select ); | 616 | previousItem->setSelected( select ); |
618 | break; | 617 | break; |
619 | } | 618 | } |
620 | lit.current()->setSelected( select ); | 619 | lit.current()->setSelected( select ); |
621 | } | 620 | } |
622 | 621 | ||
623 | blockSignals( block ); | 622 | blockSignals( block ); |
624 | viewport()->setUpdatesEnabled( update ); | 623 | viewport()->setUpdatesEnabled( update ); |
625 | triggerUpdate(); | 624 | triggerUpdate(); |
626 | 625 | ||
627 | emit selectionChanged(); | 626 | emit selectionChanged(); |
628 | 627 | ||
629 | if( selectionMode() == QListView::Single ) | 628 | if( selectionMode() == QListView::Single ) |
630 | emit selectionChanged( d->pCurrentItem ); | 629 | emit selectionChanged( d->pCurrentItem ); |
631 | } | 630 | } |
632 | else if( (keybstate & ControlMask) ) | 631 | else if( (keybstate & ControlMask) ) |
633 | setSelected( d->pCurrentItem, !d->pCurrentItem->isSelected() ); | 632 | setSelected( d->pCurrentItem, !d->pCurrentItem->isSelected() ); |
634 | else { | 633 | else { |
635 | bool block = signalsBlocked(); | 634 | bool block = signalsBlocked(); |
636 | blockSignals( true ); | 635 | blockSignals( true ); |
637 | 636 | ||
638 | if( !d->pCurrentItem->isSelected() ) | 637 | if( !d->pCurrentItem->isSelected() ) |
639 | clearSelection(); | 638 | clearSelection(); |
640 | 639 | ||
641 | blockSignals( block ); | 640 | blockSignals( block ); |
642 | 641 | ||
643 | setSelected( d->pCurrentItem, true ); | 642 | setSelected( d->pCurrentItem, true ); |
644 | } | 643 | } |
645 | } | 644 | } |
646 | else | 645 | else |
647 | kdDebug() << "KListView::slotAutoSelect: Thats not supposed to happen!!!!" << endl; | 646 | kdDebug() << "KListView::slotAutoSelect: Thats not supposed to happen!!!!" << endl; |
648 | #endif | 647 | #endif |
649 | #endif | 648 | #endif |
650 | } | 649 | } |
651 | 650 | ||
652 | void KListView::slotHeaderChanged() | 651 | void KListView::slotHeaderChanged() |
653 | { | 652 | { |
654 | if (d->fullWidth && columns()) | 653 | if (d->fullWidth && columns()) |
655 | { | 654 | { |
656 | int w = 0; | 655 | int w = 0; |
657 | for (int i = 0; i < columns() - 1; ++i) w += columnWidth(i); | 656 | for (int i = 0; i < columns() - 1; ++i) w += columnWidth(i); |
658 | setColumnWidth( columns() - 1, viewport()->width() - w - 1 ); | 657 | setColumnWidth( columns() - 1, viewport()->width() - w - 1 ); |
659 | } | 658 | } |
660 | } | 659 | } |
661 | 660 | ||
662 | void KListView::emitExecute( QListViewItem *item, const QPoint &pos, int c ) | 661 | void KListView::emitExecute( QListViewItem *item, const QPoint &pos, int c ) |
663 | { | 662 | { |
664 | if( isExecuteArea( viewport()->mapFromGlobal(pos) ) ) { | 663 | if( isExecuteArea( viewport()->mapFromGlobal(pos) ) ) { |
665 | 664 | ||
666 | // Double click mode ? | 665 | // Double click mode ? |
667 | if ( !d->bUseSingle ) | 666 | if ( !d->bUseSingle ) |
668 | { | 667 | { |
669 | emit executed( item ); | 668 | emit executed( item ); |
670 | emit executed( item, pos, c ); | 669 | emit executed( item, pos, c ); |
671 | } | 670 | } |
672 | else | 671 | else |
673 | { | 672 | { |
674 | #if 0 | 673 | #if 0 |
675 | #ifndef Q_WS_QWS | 674 | #ifndef Q_WS_QWS |
676 | // FIXME(E): Implement for Qt Embedded | 675 | // FIXME(E): Implement for Qt Embedded |
677 | Window root; | 676 | Window root; |
678 | Window child; | 677 | Window child; |
679 | int root_x, root_y, win_x, win_y; | 678 | int root_x, root_y, win_x, win_y; |
680 | uint keybstate; | 679 | uint keybstate; |
681 | XQueryPointer( qt_xdisplay(), qt_xrootwin(), &root, &child, | 680 | XQueryPointer( qt_xdisplay(), qt_xrootwin(), &root, &child, |
682 | &root_x, &root_y, &win_x, &win_y, &keybstate ); | 681 | &root_x, &root_y, &win_x, &win_y, &keybstate ); |
683 | 682 | ||
684 | d->autoSelect.stop(); | 683 | d->autoSelect.stop(); |
685 | 684 | ||
686 | //Dont emit executed if in SC mode and Shift or Ctrl are pressed | 685 | //Dont emit executed if in SC mode and Shift or Ctrl are pressed |
687 | if( !( ((keybstate & ShiftMask) || (keybstate & ControlMask)) ) ) { | 686 | if( !( ((keybstate & ShiftMask) || (keybstate & ControlMask)) ) ) { |
688 | emit executed( item ); | 687 | emit executed( item ); |
689 | emit executed( item, pos, c ); | 688 | emit executed( item, pos, c ); |
690 | } | 689 | } |
691 | #endif | 690 | #endif |
692 | #endif | 691 | #endif |
693 | } | 692 | } |
694 | } | 693 | } |
695 | } | 694 | } |
696 | 695 | ||
697 | void KListView::focusInEvent( QFocusEvent *fe ) | 696 | void KListView::focusInEvent( QFocusEvent *fe ) |
698 | { | 697 | { |
699 | // kdDebug()<<"KListView::focusInEvent()"<<endl; | 698 | // kdDebug()<<"KListView::focusInEvent()"<<endl; |
700 | QListView::focusInEvent( fe ); | 699 | QListView::focusInEvent( fe ); |
701 | if ((d->selectedBySimpleMove) | 700 | if ((d->selectedBySimpleMove) |
702 | && (d->selectionMode == FileManager) | 701 | && (d->selectionMode == FileManager) |
703 | && (fe->reason()!=QFocusEvent::Popup) | 702 | && (fe->reason()!=QFocusEvent::Popup) |
704 | && (fe->reason()!=QFocusEvent::ActiveWindow) | 703 | && (fe->reason()!=QFocusEvent::ActiveWindow) |
705 | && (currentItem()!=0)) | 704 | && (currentItem()!=0)) |
706 | { | 705 | { |
707 | currentItem()->setSelected(true); | 706 | currentItem()->setSelected(true); |
708 | currentItem()->repaint(); | 707 | currentItem()->repaint(); |
709 | emit selectionChanged(); | 708 | emit selectionChanged(); |
710 | }; | 709 | }; |
711 | } | 710 | } |
712 | 711 | ||
713 | void KListView::focusOutEvent( QFocusEvent *fe ) | 712 | void KListView::focusOutEvent( QFocusEvent *fe ) |
714 | { | 713 | { |
715 | cleanDropVisualizer(); | 714 | cleanDropVisualizer(); |
716 | cleanItemHighlighter(); | 715 | cleanItemHighlighter(); |
717 | 716 | ||
718 | d->autoSelect.stop(); | 717 | d->autoSelect.stop(); |
719 | 718 | ||
720 | if ((d->selectedBySimpleMove) | 719 | if ((d->selectedBySimpleMove) |
721 | && (d->selectionMode == FileManager) | 720 | && (d->selectionMode == FileManager) |
722 | && (fe->reason()!=QFocusEvent::Popup) | 721 | && (fe->reason()!=QFocusEvent::Popup) |
723 | && (fe->reason()!=QFocusEvent::ActiveWindow) | 722 | && (fe->reason()!=QFocusEvent::ActiveWindow) |
724 | && (currentItem()!=0) | 723 | && (currentItem()!=0) |
725 | /*US && (!d->editor->isVisible()) */ | 724 | /*US && (!d->editor->isVisible()) */ |
726 | ) | 725 | ) |
727 | { | 726 | { |
728 | currentItem()->setSelected(false); | 727 | currentItem()->setSelected(false); |
729 | currentItem()->repaint(); | 728 | currentItem()->repaint(); |
730 | emit selectionChanged(); | 729 | emit selectionChanged(); |
731 | }; | 730 | }; |
732 | 731 | ||
733 | QListView::focusOutEvent( fe ); | 732 | QListView::focusOutEvent( fe ); |
734 | } | 733 | } |
735 | 734 | ||
736 | void KListView::leaveEvent( QEvent *e ) | 735 | void KListView::leaveEvent( QEvent *e ) |
737 | { | 736 | { |
738 | d->autoSelect.stop(); | 737 | d->autoSelect.stop(); |
739 | 738 | ||
740 | QListView::leaveEvent( e ); | 739 | QListView::leaveEvent( e ); |
741 | } | 740 | } |
742 | 741 | ||
743 | bool KListView::event( QEvent *e ) | 742 | bool KListView::event( QEvent *e ) |
744 | { | 743 | { |
745 | if (e->type() == QEvent::ApplicationPaletteChange) { | 744 | if (e->type() == QEvent::ApplicationPaletteChange) { |
746 | qDebug("KListView::event make alternate color configurable"); | 745 | qDebug("KListView::event make alternate color configurable"); |
747 | //US d->alternateBackground=KGlobalSettings::alternateBackgroundColor(); | 746 | //US d->alternateBackground=KGlobalSettings::alternateBackgroundColor(); |
748 | d->alternateBackground = QColor(240, 240, 240); | 747 | d->alternateBackground = QColor(240, 240, 240); |
749 | } | 748 | } |
750 | 749 | ||
751 | return QListView::event(e); | 750 | return QListView::event(e); |
752 | } | 751 | } |
753 | 752 | ||
754 | void KListView::contentsMousePressEvent( QMouseEvent *e ) | 753 | void KListView::contentsMousePressEvent( QMouseEvent *e ) |
755 | { | 754 | { |
756 | if( (selectionModeExt() == Extended) && (e->state() & ShiftButton) && !(e->state() & ControlButton) ) | 755 | if( (selectionModeExt() == Extended) && (e->state() & ShiftButton) && !(e->state() & ControlButton) ) |
757 | { | 756 | { |
758 | bool block = signalsBlocked(); | 757 | bool block = signalsBlocked(); |
759 | blockSignals( true ); | 758 | blockSignals( true ); |
760 | 759 | ||
761 | clearSelection(); | 760 | clearSelection(); |
762 | 761 | ||
763 | blockSignals( block ); | 762 | blockSignals( block ); |
764 | } | 763 | } |
765 | else if ((selectionModeExt()==FileManager) && (d->selectedBySimpleMove)) | 764 | else if ((selectionModeExt()==FileManager) && (d->selectedBySimpleMove)) |
766 | { | 765 | { |
767 | d->selectedBySimpleMove=false; | 766 | d->selectedBySimpleMove=false; |
768 | d->selectedUsingMouse=true; | 767 | d->selectedUsingMouse=true; |
769 | if (currentItem()!=0) | 768 | if (currentItem()!=0) |
770 | { | 769 | { |
771 | currentItem()->setSelected(false); | 770 | currentItem()->setSelected(false); |
772 | currentItem()->repaint(); | 771 | currentItem()->repaint(); |
773 | // emit selectionChanged(); | 772 | // emit selectionChanged(); |
774 | }; | 773 | }; |
775 | }; | 774 | }; |
776 | 775 | ||
777 | QPoint p( contentsToViewport( e->pos() ) ); | 776 | QPoint p( contentsToViewport( e->pos() ) ); |
778 | QListViewItem *at = itemAt (p); | 777 | QListViewItem *at = itemAt (p); |
779 | 778 | ||
780 | // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) | 779 | // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) |
781 | bool rootDecoClicked = at | 780 | bool rootDecoClicked = at |
782 | && ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + | 781 | && ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + |
783 | treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) | 782 | treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) |
784 | && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); | 783 | && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); |
785 | 784 | ||
786 | if (e->button() == LeftButton && !rootDecoClicked) | 785 | if (e->button() == LeftButton && !rootDecoClicked) |
787 | { | 786 | { |
788 | //Start a drag | 787 | //Start a drag |
789 | d->startDragPos = e->pos(); | 788 | d->startDragPos = e->pos(); |
790 | 789 | ||
791 | if (at) | 790 | if (at) |
792 | { | 791 | { |
793 | d->validDrag = true; | 792 | d->validDrag = true; |
794 | d->pressedOnSelected = at->isSelected(); | 793 | d->pressedOnSelected = at->isSelected(); |
795 | } | 794 | } |
796 | } | 795 | } |
797 | 796 | ||
798 | QListView::contentsMousePressEvent( e ); | 797 | QListView::contentsMousePressEvent( e ); |
799 | } | 798 | } |
800 | 799 | ||
801 | void KListView::contentsMouseMoveEvent( QMouseEvent *e ) | 800 | void KListView::contentsMouseMoveEvent( QMouseEvent *e ) |
802 | { | 801 | { |
803 | if (!dragEnabled() || d->startDragPos.isNull() || !d->validDrag) { | 802 | if (!dragEnabled() || d->startDragPos.isNull() || !d->validDrag) { |
804 | QListView::contentsMouseMoveEvent (e); | 803 | QListView::contentsMouseMoveEvent (e); |
805 | return; | 804 | return; |
806 | } | 805 | } |
807 | 806 | ||
808 | QPoint vp = contentsToViewport(e->pos()); | 807 | QPoint vp = contentsToViewport(e->pos()); |
809 | QListViewItem *item = itemAt( vp ); | 808 | QListViewItem *item = itemAt( vp ); |
810 | 809 | ||
811 | //do we process cursor changes at all? | 810 | //do we process cursor changes at all? |
812 | if ( item && d->bChangeCursorOverItem && d->bUseSingle ) | 811 | if ( item && d->bChangeCursorOverItem && d->bUseSingle ) |
813 | { | 812 | { |
814 | //Cursor moved on a new item or in/out the execute area | 813 | //Cursor moved on a new item or in/out the execute area |
815 | if( (item != d->pCurrentItem) || | 814 | if( (item != d->pCurrentItem) || |
816 | (isExecuteArea(vp) != d->cursorInExecuteArea) ) | 815 | (isExecuteArea(vp) != d->cursorInExecuteArea) ) |
817 | { | 816 | { |
818 | d->cursorInExecuteArea = isExecuteArea(vp); | 817 | d->cursorInExecuteArea = isExecuteArea(vp); |
819 | qDebug("KListView::contentsMouseMoveEvent drag&drop not supported yet"); | 818 | qDebug("KListView::contentsMouseMoveEvent drag&drop not supported yet"); |
820 | /*US | 819 | /*US |
821 | if( d->cursorInExecuteArea ) //cursor moved in execute area | 820 | if( d->cursorInExecuteArea ) //cursor moved in execute area |
822 | viewport()->setCursor( KCursor::handCursor() ); | 821 | viewport()->setCursor( KCursor::handCursor() ); |
823 | else //cursor moved out of execute area | 822 | else //cursor moved out of execute area |
824 | viewport()->unsetCursor(); | 823 | viewport()->unsetCursor(); |
825 | */ | 824 | */ |
826 | } | 825 | } |
827 | } | 826 | } |
828 | 827 | ||
829 | bool dragOn = dragEnabled(); | 828 | bool dragOn = dragEnabled(); |
830 | QPoint newPos = e->pos(); | 829 | QPoint newPos = e->pos(); |
831 | if (dragOn && d->validDrag && | 830 | if (dragOn && d->validDrag && |
832 | (newPos.x() > d->startDragPos.x()+d->dragDelay || | 831 | (newPos.x() > d->startDragPos.x()+d->dragDelay || |
833 | newPos.x() < d->startDragPos.x()-d->dragDelay || | 832 | newPos.x() < d->startDragPos.x()-d->dragDelay || |
834 | newPos.y() > d->startDragPos.y()+d->dragDelay || | 833 | newPos.y() > d->startDragPos.y()+d->dragDelay || |
835 | newPos.y() < d->startDragPos.y()-d->dragDelay)) | 834 | newPos.y() < d->startDragPos.y()-d->dragDelay)) |
836 | //(d->startDragPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) | 835 | //(d->startDragPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) |
837 | { | 836 | { |
838 | QListView::contentsMouseReleaseEvent( 0 ); | 837 | QListView::contentsMouseReleaseEvent( 0 ); |
839 | startDrag(); | 838 | startDrag(); |
840 | d->startDragPos = QPoint(); | 839 | d->startDragPos = QPoint(); |
841 | d->validDrag = false; | 840 | d->validDrag = false; |
842 | } | 841 | } |
843 | } | 842 | } |
844 | 843 | ||
845 | void KListView::contentsMouseReleaseEvent( QMouseEvent *e ) | 844 | void KListView::contentsMouseReleaseEvent( QMouseEvent *e ) |
846 | { | 845 | { |
847 | if (e->button() == LeftButton) | 846 | if (e->button() == LeftButton) |
848 | { | 847 | { |
849 | // If the row was already selected, maybe we want to start an in-place editing | 848 | // If the row was already selected, maybe we want to start an in-place editing |
850 | if ( d->pressedOnSelected && itemsRenameable() ) | 849 | if ( d->pressedOnSelected && itemsRenameable() ) |
851 | { | 850 | { |
852 | QPoint p( contentsToViewport( e->pos() ) ); | 851 | QPoint p( contentsToViewport( e->pos() ) ); |
853 | QListViewItem *at = itemAt (p); | 852 | QListViewItem *at = itemAt (p); |
854 | if ( at ) | 853 | if ( at ) |
855 | { | 854 | { |
856 | // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) | 855 | // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) |
857 | bool rootDecoClicked = | 856 | bool rootDecoClicked = |
858 | ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + | 857 | ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + |
859 | treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) | 858 | treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) |
860 | && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); | 859 | && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); |
861 | 860 | ||
862 | if (!rootDecoClicked) | 861 | if (!rootDecoClicked) |
863 | { | 862 | { |
864 | int col = header()->mapToLogical( header()->cellAt( p.x() ) ); | 863 | int col = header()->mapToLogical( header()->cellAt( p.x() ) ); |
865 | if ( d->renameable.contains(col) ) | 864 | if ( d->renameable.contains(col) ) |
866 | rename(at, col); | 865 | rename(at, col); |
867 | } | 866 | } |
868 | } | 867 | } |
869 | } | 868 | } |
870 | 869 | ||
871 | d->pressedOnSelected = false; | 870 | d->pressedOnSelected = false; |
872 | d->validDrag = false; | 871 | d->validDrag = false; |
873 | d->startDragPos = QPoint(); | 872 | d->startDragPos = QPoint(); |
874 | } | 873 | } |
875 | QListView::contentsMouseReleaseEvent( e ); | 874 | QListView::contentsMouseReleaseEvent( e ); |
876 | } | 875 | } |
877 | 876 | ||
878 | void KListView::contentsMouseDoubleClickEvent ( QMouseEvent *e ) | 877 | void KListView::contentsMouseDoubleClickEvent ( QMouseEvent *e ) |
879 | { | 878 | { |
880 | // We don't want to call the parent method because it does setOpen, | 879 | // We don't want to call the parent method because it does setOpen, |
881 | // whereas we don't do it in single click mode... (David) | 880 | // whereas we don't do it in single click mode... (David) |
882 | //QListView::contentsMouseDoubleClickEvent( e ); | 881 | //QListView::contentsMouseDoubleClickEvent( e ); |
883 | 882 | ||
884 | QPoint vp = contentsToViewport(e->pos()); | 883 | QPoint vp = contentsToViewport(e->pos()); |
885 | QListViewItem *item = itemAt( vp ); | 884 | QListViewItem *item = itemAt( vp ); |
886 | emit QListView::doubleClicked( item ); // we do it now | 885 | emit QListView::doubleClicked( item ); // we do it now |
887 | 886 | ||
888 | int col = item ? header()->mapToLogical( header()->cellAt( vp.x() ) ) : -1; | 887 | int col = item ? header()->mapToLogical( header()->cellAt( vp.x() ) ) : -1; |
889 | 888 | ||
890 | if( item ) { | 889 | if( item ) { |
891 | emit doubleClicked( item, e->globalPos(), col ); | 890 | emit doubleClicked( item, e->globalPos(), col ); |
892 | 891 | ||
893 | if( (e->button() == LeftButton) && !d->bUseSingle ) | 892 | if( (e->button() == LeftButton) && !d->bUseSingle ) |
894 | emitExecute( item, e->globalPos(), col ); | 893 | emitExecute( item, e->globalPos(), col ); |
895 | } | 894 | } |
896 | } | 895 | } |
897 | 896 | ||
898 | void KListView::slotMouseButtonClicked( int btn, QListViewItem *item, const QPoint &pos, int c ) | 897 | void KListView::slotMouseButtonClicked( int btn, QListViewItem *item, const QPoint &pos, int c ) |
899 | { | 898 | { |
900 | if( (btn == LeftButton) && item ) | 899 | if( (btn == LeftButton) && item ) |
901 | emitExecute(item, pos, c); | 900 | emitExecute(item, pos, c); |
902 | } | 901 | } |
903 | 902 | ||
904 | void KListView::contentsDropEvent(QDropEvent* e) | 903 | void KListView::contentsDropEvent(QDropEvent* e) |
905 | { | 904 | { |
906 | qDebug("KListView::contentsDropEvent drag&drop not supported yet"); | 905 | qDebug("KListView::contentsDropEvent drag&drop not supported yet"); |
907 | /*US | 906 | /*US |
908 | cleanDropVisualizer(); | 907 | cleanDropVisualizer(); |
909 | cleanItemHighlighter(); | 908 | cleanItemHighlighter(); |
910 | d->dragExpand.stop(); | 909 | d->dragExpand.stop(); |
911 | 910 | ||
912 | if (acceptDrag (e)) | 911 | if (acceptDrag (e)) |
913 | { | 912 | { |
914 | e->acceptAction(); | 913 | e->acceptAction(); |
915 | QListViewItem *afterme; | 914 | QListViewItem *afterme; |
916 | QListViewItem *parent; | 915 | QListViewItem *parent; |
917 | findDrop(e->pos(), parent, afterme); | 916 | findDrop(e->pos(), parent, afterme); |
918 | 917 | ||
919 | if (e->source() == viewport() && itemsMovable()) | 918 | if (e->source() == viewport() && itemsMovable()) |
920 | movableDropEvent(parent, afterme); | 919 | movableDropEvent(parent, afterme); |
921 | else | 920 | else |
922 | { | 921 | { |
923 | 922 | ||
924 | emit dropped(e, afterme); | 923 | emit dropped(e, afterme); |
925 | emit dropped(this, e, afterme); | 924 | emit dropped(this, e, afterme); |
926 | emit dropped(e, parent, afterme); | 925 | emit dropped(e, parent, afterme); |
927 | emit dropped(this, e, parent, afterme); | 926 | emit dropped(this, e, parent, afterme); |
928 | 927 | ||
929 | } | 928 | } |
930 | } | 929 | } |
931 | */ | 930 | */ |
932 | 931 | ||
933 | } | 932 | } |
934 | 933 | ||
935 | void KListView::movableDropEvent (QListViewItem* parent, QListViewItem* afterme) | 934 | void KListView::movableDropEvent (QListViewItem* parent, QListViewItem* afterme) |
936 | { | 935 | { |
937 | QPtrList<QListViewItem> items, afterFirsts, afterNows; | 936 | QPtrList<QListViewItem> items, afterFirsts, afterNows; |
938 | QListViewItem *current=currentItem(); | 937 | QListViewItem *current=currentItem(); |
939 | bool hasMoved=false; | 938 | bool hasMoved=false; |
940 | for (QListViewItem *i = firstChild(), *iNext=0; i != 0; i = iNext) | 939 | for (QListViewItem *i = firstChild(), *iNext=0; i != 0; i = iNext) |
941 | { | 940 | { |
942 | iNext=i->itemBelow(); | 941 | iNext=i->itemBelow(); |
943 | if (!i->isSelected()) | 942 | if (!i->isSelected()) |
944 | continue; | 943 | continue; |
945 | 944 | ||
946 | // don't drop an item after itself, or else | 945 | // don't drop an item after itself, or else |
947 | // it moves to the top of the list | 946 | // it moves to the top of the list |
948 | if (i==afterme) | 947 | if (i==afterme) |
949 | continue; | 948 | continue; |
950 | 949 | ||
951 | i->setSelected(false); | 950 | i->setSelected(false); |
952 | 951 | ||
953 | QListViewItem *afterFirst = i->itemAbove(); | 952 | QListViewItem *afterFirst = i->itemAbove(); |
954 | 953 | ||
955 | if (!hasMoved) | 954 | if (!hasMoved) |
956 | { | 955 | { |
957 | emit aboutToMove(); | 956 | emit aboutToMove(); |
958 | hasMoved=true; | 957 | hasMoved=true; |
959 | } | 958 | } |
960 | 959 | ||
961 | moveItem(i, parent, afterme); | 960 | moveItem(i, parent, afterme); |
962 | 961 | ||
963 | // ###### This should include the new parent !!! -> KDE 3.0 | 962 | // ###### This should include the new parent !!! -> KDE 3.0 |
964 | // If you need this right now, have a look at keditbookmarks. | 963 | // If you need this right now, have a look at keditbookmarks. |
965 | emit moved(i, afterFirst, afterme); | 964 | emit moved(i, afterFirst, afterme); |
966 | 965 | ||
967 | items.append (i); | 966 | items.append (i); |
968 | afterFirsts.append (afterFirst); | 967 | afterFirsts.append (afterFirst); |
969 | afterNows.append (afterme); | 968 | afterNows.append (afterme); |
970 | 969 | ||
971 | afterme = i; | 970 | afterme = i; |
972 | } | 971 | } |
973 | clearSelection(); | 972 | clearSelection(); |
974 | for (QListViewItem *i=items.first(); i != 0; i=items.next() ) | 973 | for (QListViewItem *i=items.first(); i != 0; i=items.next() ) |
975 | i->setSelected(true); | 974 | i->setSelected(true); |
976 | if (current) | 975 | if (current) |
977 | setCurrentItem(current); | 976 | setCurrentItem(current); |
978 | 977 | ||
979 | emit moved(items,afterFirsts,afterNows); | 978 | emit moved(items,afterFirsts,afterNows); |
980 | 979 | ||
981 | if (firstChild()) | 980 | if (firstChild()) |
982 | emit moved(); | 981 | emit moved(); |
983 | } | 982 | } |
984 | 983 | ||
985 | void KListView::contentsDragMoveEvent(QDragMoveEvent *event) | 984 | void KListView::contentsDragMoveEvent(QDragMoveEvent *event) |
986 | { | 985 | { |
987 | qDebug("KListView::contentsDropEvent drag&drop not supported yet"); | 986 | qDebug("KListView::contentsDropEvent drag&drop not supported yet"); |
988 | /*US | 987 | /*US |
989 | if (acceptDrag(event)) | 988 | if (acceptDrag(event)) |
990 | { | 989 | { |
991 | event->acceptAction(); | 990 | event->acceptAction(); |
992 | //Clean up the view | 991 | //Clean up the view |
993 | 992 | ||
994 | findDrop(event->pos(), d->parentItemDrop, d->afterItemDrop); | 993 | findDrop(event->pos(), d->parentItemDrop, d->afterItemDrop); |
995 | QPoint vp = contentsToViewport( event->pos() ); | 994 | QPoint vp = contentsToViewport( event->pos() ); |
996 | QListViewItem *item = isExecuteArea( vp ) ? itemAt( vp ) : 0L; | 995 | QListViewItem *item = isExecuteArea( vp ) ? itemAt( vp ) : 0L; |
997 | 996 | ||
998 | if ( item != d->dragOverItem ) | 997 | if ( item != d->dragOverItem ) |
999 | { | 998 | { |
1000 | d->dragExpand.stop(); | 999 | d->dragExpand.stop(); |
1001 | d->dragOverItem = item; | 1000 | d->dragOverItem = item; |
1002 | d->dragOverPoint = vp; | 1001 | d->dragOverPoint = vp; |
1003 | if ( d->dragOverItem && d->dragOverItem->isExpandable() && !d->dragOverItem->isOpen() ) | 1002 | if ( d->dragOverItem && d->dragOverItem->isExpandable() && !d->dragOverItem->isOpen() ) |
1004 | d->dragExpand.start( QApplication::startDragTime(), true ); | 1003 | d->dragExpand.start( QApplication::startDragTime(), true ); |
1005 | } | 1004 | } |
1006 | if (dropVisualizer()) | 1005 | if (dropVisualizer()) |
1007 | { | 1006 | { |
1008 | QRect tmpRect = drawDropVisualizer(0, d->parentItemDrop, d->afterItemDrop); | 1007 | QRect tmpRect = drawDropVisualizer(0, d->parentItemDrop, d->afterItemDrop); |
1009 | if (tmpRect != d->mOldDropVisualizer) | 1008 | if (tmpRect != d->mOldDropVisualizer) |
1010 | { | 1009 | { |
1011 | cleanDropVisualizer(); | 1010 | cleanDropVisualizer(); |
1012 | d->mOldDropVisualizer=tmpRect; | 1011 | d->mOldDropVisualizer=tmpRect; |
1013 | viewport()->repaint(tmpRect); | 1012 | viewport()->repaint(tmpRect); |
1014 | } | 1013 | } |
1015 | } | 1014 | } |
1016 | if (dropHighlighter()) | 1015 | if (dropHighlighter()) |
1017 | { | 1016 | { |
1018 | QRect tmpRect = drawItemHighlighter(0, d->afterItemDrop); | 1017 | QRect tmpRect = drawItemHighlighter(0, d->afterItemDrop); |
1019 | if (tmpRect != d->mOldDropHighlighter) | 1018 | if (tmpRect != d->mOldDropHighlighter) |
1020 | { | 1019 | { |
1021 | cleanItemHighlighter(); | 1020 | cleanItemHighlighter(); |
1022 | d->mOldDropHighlighter=tmpRect; | 1021 | d->mOldDropHighlighter=tmpRect; |
1023 | viewport()->repaint(tmpRect); | 1022 | viewport()->repaint(tmpRect); |
1024 | } | 1023 | } |
1025 | } | 1024 | } |
1026 | } | 1025 | } |
1027 | else | 1026 | else |
1028 | event->ignore(); | 1027 | event->ignore(); |
1029 | */ | 1028 | */ |
1030 | } | 1029 | } |
1031 | 1030 | ||
1032 | void KListView::slotDragExpand() | 1031 | void KListView::slotDragExpand() |
1033 | { | 1032 | { |
1034 | if ( itemAt( d->dragOverPoint ) == d->dragOverItem ) | 1033 | if ( itemAt( d->dragOverPoint ) == d->dragOverItem ) |
1035 | d->dragOverItem->setOpen( true ); | 1034 | d->dragOverItem->setOpen( true ); |
1036 | } | 1035 | } |
1037 | 1036 | ||
1038 | void KListView::contentsDragLeaveEvent (QDragLeaveEvent*) | 1037 | void KListView::contentsDragLeaveEvent (QDragLeaveEvent*) |
1039 | { | 1038 | { |
1040 | d->dragExpand.stop(); | 1039 | d->dragExpand.stop(); |
1041 | cleanDropVisualizer(); | 1040 | cleanDropVisualizer(); |
1042 | cleanItemHighlighter(); | 1041 | cleanItemHighlighter(); |
1043 | } | 1042 | } |
1044 | 1043 | ||
1045 | void KListView::cleanDropVisualizer() | 1044 | void KListView::cleanDropVisualizer() |
1046 | { | 1045 | { |
1047 | if (d->mOldDropVisualizer.isValid()) | 1046 | if (d->mOldDropVisualizer.isValid()) |
1048 | { | 1047 | { |
1049 | QRect rect=d->mOldDropVisualizer; | 1048 | QRect rect=d->mOldDropVisualizer; |
1050 | d->mOldDropVisualizer = QRect(); | 1049 | d->mOldDropVisualizer = QRect(); |
1051 | viewport()->repaint(rect, true); | 1050 | viewport()->repaint(rect, true); |
1052 | } | 1051 | } |
1053 | } | 1052 | } |
1054 | 1053 | ||
1055 | int KListView::depthToPixels( int depth ) | 1054 | int KListView::depthToPixels( int depth ) |
1056 | { | 1055 | { |
1057 | return treeStepSize() * ( depth + (rootIsDecorated() ? 1 : 0) ) + itemMargin(); | 1056 | return treeStepSize() * ( depth + (rootIsDecorated() ? 1 : 0) ) + itemMargin(); |
1058 | } | 1057 | } |
1059 | 1058 | ||
1060 | void KListView::findDrop(const QPoint &pos, QListViewItem *&parent, QListViewItem *&after) | 1059 | void KListView::findDrop(const QPoint &pos, QListViewItem *&parent, QListViewItem *&after) |
1061 | { | 1060 | { |
1062 | QPoint p (contentsToViewport(pos)); | 1061 | QPoint p (contentsToViewport(pos)); |
1063 | 1062 | ||
1064 | // Get the position to put it in | 1063 | // Get the position to put it in |
1065 | QListViewItem *atpos = itemAt(p); | 1064 | QListViewItem *atpos = itemAt(p); |
1066 | 1065 | ||
1067 | QListViewItem *above; | 1066 | QListViewItem *above; |
1068 | if (!atpos) // put it at the end | 1067 | if (!atpos) // put it at the end |
1069 | above = lastItem(); | 1068 | above = lastItem(); |
1070 | else | 1069 | else |
1071 | { | 1070 | { |
1072 | // Get the closest item before us ('atpos' or the one above, if any) | 1071 | // Get the closest item before us ('atpos' or the one above, if any) |
1073 | if (p.y() - itemRect(atpos).topLeft().y() < (atpos->height()/2)) | 1072 | if (p.y() - itemRect(atpos).topLeft().y() < (atpos->height()/2)) |
1074 | above = atpos->itemAbove(); | 1073 | above = atpos->itemAbove(); |
1075 | else | 1074 | else |
1076 | above = atpos; | 1075 | above = atpos; |
1077 | } | 1076 | } |
1078 | 1077 | ||
1079 | if (above) | 1078 | if (above) |
1080 | { | 1079 | { |
1081 | // Now, we know we want to go after "above". But as a child or as a sibling ? | 1080 | // Now, we know we want to go after "above". But as a child or as a sibling ? |
1082 | // We have to ask the "above" item if it accepts children. | 1081 | // We have to ask the "above" item if it accepts children. |
1083 | if (above->isExpandable()) | 1082 | if (above->isExpandable()) |
1084 | { | 1083 | { |
1085 | // The mouse is sufficiently on the right ? - doesn't matter if 'above' has visible children | 1084 | // The mouse is sufficiently on the right ? - doesn't matter if 'above' has visible children |
1086 | if (p.x() >= depthToPixels( above->depth() + 1 ) || | 1085 | if (p.x() >= depthToPixels( above->depth() + 1 ) || |
1087 | (above->isOpen() && above->childCount() > 0) ) | 1086 | (above->isOpen() && above->childCount() > 0) ) |
1088 | { | 1087 | { |
1089 | parent = above; | 1088 | parent = above; |
1090 | after = 0L; | 1089 | after = 0L; |
1091 | return; | 1090 | return; |
1092 | } | 1091 | } |
1093 | } | 1092 | } |
1094 | 1093 | ||
1095 | // Ok, there's one more level of complexity. We may want to become a new | 1094 | // Ok, there's one more level of complexity. We may want to become a new |
1096 | // sibling, but of an upper-level group, rather than the "above" item | 1095 | // sibling, but of an upper-level group, rather than the "above" item |
1097 | QListViewItem * betterAbove = above->parent(); | 1096 | QListViewItem * betterAbove = above->parent(); |
1098 | QListViewItem * last = above; | 1097 | QListViewItem * last = above; |
1099 | while ( betterAbove ) | 1098 | while ( betterAbove ) |
1100 | { | 1099 | { |
1101 | // We are allowed to become a sibling of "betterAbove" only if we are | 1100 | // We are allowed to become a sibling of "betterAbove" only if we are |
1102 | // after its last child | 1101 | // after its last child |
1103 | if ( last->nextSibling() == 0 ) | 1102 | if ( last->nextSibling() == 0 ) |
1104 | { | 1103 | { |
1105 | if (p.x() < depthToPixels ( betterAbove->depth() + 1 )) | 1104 | if (p.x() < depthToPixels ( betterAbove->depth() + 1 )) |
1106 | above = betterAbove; // store this one, but don't stop yet, there may be a better one | 1105 | above = betterAbove; // store this one, but don't stop yet, there may be a better one |
1107 | else | 1106 | else |
1108 | break; // not enough on the left, so stop | 1107 | break; // not enough on the left, so stop |
1109 | last = betterAbove; | 1108 | last = betterAbove; |
1110 | betterAbove = betterAbove->parent(); // up one level | 1109 | betterAbove = betterAbove->parent(); // up one level |
1111 | } else | 1110 | } else |
1112 | break; // we're among the child of betterAbove, not after the last one | 1111 | break; // we're among the child of betterAbove, not after the last one |
1113 | } | 1112 | } |
1114 | } | 1113 | } |
1115 | // set as sibling | 1114 | // set as sibling |
1116 | after = above; | 1115 | after = above; |
1117 | parent = after ? after->parent() : 0L ; | 1116 | parent = after ? after->parent() : 0L ; |
1118 | } | 1117 | } |
1119 | 1118 | ||
1120 | QListViewItem* KListView::lastChild () const | 1119 | QListViewItem* KListView::lastChild () const |
1121 | { | 1120 | { |
1122 | QListViewItem* lastchild = firstChild(); | 1121 | QListViewItem* lastchild = firstChild(); |
1123 | 1122 | ||
1124 | if (lastchild) | 1123 | if (lastchild) |
1125 | for (; lastchild->nextSibling(); lastchild = lastchild->nextSibling()); | 1124 | for (; lastchild->nextSibling(); lastchild = lastchild->nextSibling()); |
1126 | 1125 | ||
1127 | return lastchild; | 1126 | return lastchild; |
1128 | } | 1127 | } |
1129 | 1128 | ||
1130 | QListViewItem *KListView::lastItem() const | 1129 | QListViewItem *KListView::lastItem() const |
1131 | { | 1130 | { |
1132 | QListViewItem* last = lastChild(); | 1131 | QListViewItem* last = lastChild(); |
1133 | 1132 | ||
1134 | for (QListViewItemIterator it (last); it.current(); ++it) | 1133 | for (QListViewItemIterator it (last); it.current(); ++it) |
1135 | last = it.current(); | 1134 | last = it.current(); |
1136 | 1135 | ||
1137 | return last; | 1136 | return last; |
1138 | } | 1137 | } |
1139 | 1138 | ||
1140 | KLineEdit *KListView::renameLineEdit() const | 1139 | KLineEdit *KListView::renameLineEdit() const |
1141 | { | 1140 | { |
1142 | //US return d->editor; | 1141 | //US return d->editor; |
1143 | qDebug("KListView::renameLineEdit returns 0. Might crash"); | 1142 | qDebug("KListView::renameLineEdit returns 0. Might crash"); |
1144 | return 0; | 1143 | return 0; |
1145 | } | 1144 | } |
1146 | 1145 | ||
1147 | void KListView::startDrag() | 1146 | void KListView::startDrag() |
1148 | { | 1147 | { |
1149 | qDebug("KListView::startDrag drag&drop not supported yet."); | 1148 | qDebug("KListView::startDrag drag&drop not supported yet."); |
1150 | /*US | 1149 | /*US |
1151 | QDragObject *drag = dragObject(); | 1150 | QDragObject *drag = dragObject(); |
1152 | 1151 | ||
1153 | if (!drag) | 1152 | if (!drag) |
1154 | return; | 1153 | return; |
1155 | 1154 | ||
1156 | if (drag->drag() && drag->target() != viewport()) | 1155 | if (drag->drag() && drag->target() != viewport()) |
1157 | emit moved(); | 1156 | emit moved(); |
1158 | */ | 1157 | */ |
1159 | } | 1158 | } |
1160 | 1159 | ||
1161 | QDragObject *KListView::dragObject() | 1160 | QDragObject *KListView::dragObject() |
1162 | { | 1161 | { |
1163 | if (!currentItem()) | 1162 | if (!currentItem()) |
1164 | return 0; | 1163 | return 0; |
1165 | 1164 | ||
1166 | return new QStoredDrag("application/x-qlistviewitem", viewport()); | 1165 | return new QStoredDrag("application/x-qlistviewitem", viewport()); |
1167 | } | 1166 | } |
1168 | 1167 | ||
1169 | void KListView::setItemsMovable(bool b) | 1168 | void KListView::setItemsMovable(bool b) |
1170 | { | 1169 | { |
1171 | d->itemsMovable=b; | 1170 | d->itemsMovable=b; |
1172 | } | 1171 | } |
1173 | 1172 | ||
1174 | bool KListView::itemsMovable() const | 1173 | bool KListView::itemsMovable() const |
1175 | { | 1174 | { |
1176 | return d->itemsMovable; | 1175 | return d->itemsMovable; |
1177 | } | 1176 | } |
1178 | 1177 | ||
1179 | void KListView::setItemsRenameable(bool b) | 1178 | void KListView::setItemsRenameable(bool b) |
1180 | { | 1179 | { |
1181 | d->itemsRenameable=b; | 1180 | d->itemsRenameable=b; |
1182 | } | 1181 | } |
1183 | 1182 | ||
1184 | bool KListView::itemsRenameable() const | 1183 | bool KListView::itemsRenameable() const |
1185 | { | 1184 | { |
1186 | return d->itemsRenameable; | 1185 | return d->itemsRenameable; |
1187 | } | 1186 | } |
1188 | 1187 | ||
1189 | 1188 | ||
1190 | void KListView::setDragEnabled(bool b) | 1189 | void KListView::setDragEnabled(bool b) |
1191 | { | 1190 | { |
1192 | d->dragEnabled=b; | 1191 | d->dragEnabled=b; |
1193 | } | 1192 | } |
1194 | 1193 | ||
1195 | bool KListView::dragEnabled() const | 1194 | bool KListView::dragEnabled() const |
1196 | { | 1195 | { |
1197 | return d->dragEnabled; | 1196 | return d->dragEnabled; |
1198 | } | 1197 | } |
1199 | 1198 | ||
1200 | void KListView::setAutoOpen(bool b) | 1199 | void KListView::setAutoOpen(bool b) |
1201 | { | 1200 | { |
1202 | d->autoOpen=b; | 1201 | d->autoOpen=b; |
1203 | } | 1202 | } |
1204 | 1203 | ||
1205 | bool KListView::autoOpen() const | 1204 | bool KListView::autoOpen() const |
1206 | { | 1205 | { |
1207 | return d->autoOpen; | 1206 | return d->autoOpen; |
1208 | } | 1207 | } |
1209 | 1208 | ||
1210 | bool KListView::dropVisualizer() const | 1209 | bool KListView::dropVisualizer() const |
1211 | { | 1210 | { |
1212 | return d->dropVisualizer; | 1211 | return d->dropVisualizer; |
1213 | } | 1212 | } |
1214 | 1213 | ||
1215 | void KListView::setDropVisualizer(bool b) | 1214 | void KListView::setDropVisualizer(bool b) |
1216 | { | 1215 | { |
1217 | d->dropVisualizer=b; | 1216 | d->dropVisualizer=b; |
1218 | } | 1217 | } |
1219 | 1218 | ||
1220 | QPtrList<QListViewItem> KListView::selectedItems() const | 1219 | QPtrList<QListViewItem> KListView::selectedItems() const |
1221 | { | 1220 | { |
1222 | QPtrList<QListViewItem> list; | 1221 | QPtrList<QListViewItem> list; |
1223 | for (QListViewItem *i=firstChild(); i!=0; i=i->itemBelow()) | 1222 | for (QListViewItem *i=firstChild(); i!=0; i=i->itemBelow()) |
1224 | if (i->isSelected()) list.append(i); | 1223 | if (i->isSelected()) list.append(i); |
1225 | return list; | 1224 | return list; |
1226 | } | 1225 | } |
1227 | 1226 | ||
1228 | 1227 | ||
1229 | void KListView::moveItem(QListViewItem *item, QListViewItem *parent, QListViewItem *after) | 1228 | void KListView::moveItem(QListViewItem *item, QListViewItem *parent, QListViewItem *after) |
1230 | { | 1229 | { |
1231 | // sanity check - don't move a item into it's own child structure | 1230 | // sanity check - don't move a item into it's own child structure |
1232 | QListViewItem *i = parent; | 1231 | QListViewItem *i = parent; |
1233 | while(i) | 1232 | while(i) |
1234 | { | 1233 | { |
1235 | if(i == item) | 1234 | if(i == item) |
1236 | return; | 1235 | return; |
1237 | i = i->parent(); | 1236 | i = i->parent(); |
1238 | } | 1237 | } |
1239 | 1238 | ||
1240 | // Basically reimplementing the QListViewItem(QListViewItem*, QListViewItem*) constructor | 1239 | // Basically reimplementing the QListViewItem(QListViewItem*, QListViewItem*) constructor |
1241 | // in here, without ever deleting the item. | 1240 | // in here, without ever deleting the item. |
1242 | if (item->parent()) | 1241 | if (item->parent()) |
1243 | item->parent()->takeItem(item); | 1242 | item->parent()->takeItem(item); |
1244 | else | 1243 | else |
1245 | takeItem(item); | 1244 | takeItem(item); |
1246 | 1245 | ||
1247 | if (parent) | 1246 | if (parent) |
1248 | parent->insertItem(item); | 1247 | parent->insertItem(item); |
1249 | else | 1248 | else |
1250 | insertItem(item); | 1249 | insertItem(item); |
1251 | 1250 | ||
1252 | if (after) | 1251 | if (after) |
1253 | ;//item->moveToJustAfter(after); | 1252 | ;//item->moveToJustAfter(after); |
1254 | } | 1253 | } |
1255 | 1254 | ||
1256 | void KListView::contentsDragEnterEvent(QDragEnterEvent *event) | 1255 | void KListView::contentsDragEnterEvent(QDragEnterEvent *event) |
1257 | { | 1256 | { |
1258 | qDebug("KListView::contentsDragEnterEvent drag&drop not supported yet."); | 1257 | qDebug("KListView::contentsDragEnterEvent drag&drop not supported yet."); |
1259 | /*US | 1258 | /*US |
1260 | if (acceptDrag (event)) | 1259 | if (acceptDrag (event)) |
1261 | event->accept(); | 1260 | event->accept(); |
1262 | */ | 1261 | */ |
1263 | } | 1262 | } |
1264 | 1263 | ||
1265 | void KListView::setDropVisualizerWidth (int w) | 1264 | void KListView::setDropVisualizerWidth (int w) |
1266 | { | 1265 | { |
1267 | d->mDropVisualizerWidth = w > 0 ? w : 1; | 1266 | d->mDropVisualizerWidth = w > 0 ? w : 1; |
1268 | } | 1267 | } |
1269 | 1268 | ||
1270 | QRect KListView::drawDropVisualizer(QPainter *p, QListViewItem *parent, | 1269 | QRect KListView::drawDropVisualizer(QPainter *p, QListViewItem *parent, |
1271 | QListViewItem *after) | 1270 | QListViewItem *after) |
1272 | { | 1271 | { |
1273 | QRect insertmarker; | 1272 | QRect insertmarker; |
1274 | 1273 | ||
1275 | if (!after && !parent) | 1274 | if (!after && !parent) |
1276 | insertmarker = QRect (0, 0, viewport()->width(), d->mDropVisualizerWidth/2); | 1275 | insertmarker = QRect (0, 0, viewport()->width(), d->mDropVisualizerWidth/2); |
1277 | else | 1276 | else |
1278 | { | 1277 | { |
1279 | int level = 0; | 1278 | int level = 0; |
1280 | if (after) | 1279 | if (after) |
1281 | { | 1280 | { |
1282 | QListViewItem* it = 0L; | 1281 | QListViewItem* it = 0L; |
1283 | if (after->isOpen()) | 1282 | if (after->isOpen()) |
1284 | { | 1283 | { |
1285 | // Look for the last child (recursively) | 1284 | // Look for the last child (recursively) |
1286 | it = after->firstChild(); | 1285 | it = after->firstChild(); |
1287 | if (it) | 1286 | if (it) |
1288 | while (it->nextSibling() || it->firstChild()) | 1287 | while (it->nextSibling() || it->firstChild()) |
1289 | if ( it->nextSibling() ) | 1288 | if ( it->nextSibling() ) |
1290 | it = it->nextSibling(); | 1289 | it = it->nextSibling(); |
1291 | else | 1290 | else |
1292 | it = it->firstChild(); | 1291 | it = it->firstChild(); |
1293 | } | 1292 | } |
1294 | 1293 | ||
1295 | insertmarker = itemRect (it ? it : after); | 1294 | insertmarker = itemRect (it ? it : after); |
1296 | level = after->depth(); | 1295 | level = after->depth(); |
1297 | } | 1296 | } |
1298 | else if (parent) | 1297 | else if (parent) |
1299 | { | 1298 | { |
1300 | insertmarker = itemRect (parent); | 1299 | insertmarker = itemRect (parent); |
1301 | level = parent->depth() + 1; | 1300 | level = parent->depth() + 1; |
1302 | } | 1301 | } |
1303 | insertmarker.setLeft( treeStepSize() * ( level + (rootIsDecorated() ? 1 : 0) ) + itemMargin() ); | 1302 | insertmarker.setLeft( treeStepSize() * ( level + (rootIsDecorated() ? 1 : 0) ) + itemMargin() ); |
1304 | insertmarker.setRight (viewport()->width()); | 1303 | insertmarker.setRight (viewport()->width()); |
1305 | insertmarker.setTop (insertmarker.bottom() - d->mDropVisualizerWidth/2 + 1); | 1304 | insertmarker.setTop (insertmarker.bottom() - d->mDropVisualizerWidth/2 + 1); |
1306 | insertmarker.setBottom (insertmarker.bottom() + d->mDropVisualizerWidth/2); | 1305 | insertmarker.setBottom (insertmarker.bottom() + d->mDropVisualizerWidth/2); |
1307 | } | 1306 | } |
1308 | 1307 | ||
1309 | // This is not used anymore, at least by KListView itself (see viewportPaintEvent) | 1308 | // This is not used anymore, at least by KListView itself (see viewportPaintEvent) |
1310 | // Remove for KDE 3.0. | 1309 | // Remove for KDE 3.0. |
1311 | if (p) | 1310 | if (p) |
1312 | p->fillRect(insertmarker, Dense4Pattern); | 1311 | p->fillRect(insertmarker, Dense4Pattern); |
1313 | 1312 | ||
1314 | return insertmarker; | 1313 | return insertmarker; |
1315 | } | 1314 | } |
1316 | 1315 | ||
1317 | QRect KListView::drawItemHighlighter(QPainter *painter, QListViewItem *item) | 1316 | QRect KListView::drawItemHighlighter(QPainter *painter, QListViewItem *item) |
1318 | { | 1317 | { |
1319 | QRect r; | 1318 | QRect r; |
1320 | 1319 | ||
1321 | if (item) | 1320 | if (item) |
1322 | { | 1321 | { |
1323 | r = itemRect(item); | 1322 | r = itemRect(item); |
1324 | r.setLeft(r.left()+(item->depth()+1)*treeStepSize()); | 1323 | r.setLeft(r.left()+(item->depth()+1)*treeStepSize()); |
1325 | if (painter) { | 1324 | if (painter) { |
1326 | //US style().drawPrimitive(QStyle::PE_FocusRect, painter, r, colorGroup(), | 1325 | //US style().drawPrimitive(QStyle::PE_FocusRect, painter, r, colorGroup(), |
1327 | //US QStyle::Style_FocusAtBorder, colorGroup().highlight()); | 1326 | //US QStyle::Style_FocusAtBorder, colorGroup().highlight()); |
1328 | const QColor* pHighl = &(colorGroup().highlight()); | 1327 | const QColor* pHighl = &(colorGroup().highlight()); |
1329 | //LR style().drawFocusRect(painter, r, colorGroup(), pHighl, true); | 1328 | //LR style().drawFocusRect(painter, r, colorGroup(), pHighl, true); |
1330 | 1329 | ||
1331 | qDebug("KListView::drawItemHighlighter has to be verified"); | 1330 | qDebug("KListView::drawItemHighlighter has to be verified"); |
1332 | 1331 | ||
1333 | } | 1332 | } |
1334 | 1333 | ||
1335 | } | 1334 | } |
1336 | 1335 | ||
1337 | return r; | 1336 | return r; |
1338 | } | 1337 | } |
1339 | 1338 | ||
1340 | void KListView::cleanItemHighlighter () | 1339 | void KListView::cleanItemHighlighter () |
1341 | { | 1340 | { |
1342 | if (d->mOldDropHighlighter.isValid()) | 1341 | if (d->mOldDropHighlighter.isValid()) |
1343 | { | 1342 | { |
1344 | QRect rect=d->mOldDropHighlighter; | 1343 | QRect rect=d->mOldDropHighlighter; |
1345 | d->mOldDropHighlighter = QRect(); | 1344 | d->mOldDropHighlighter = QRect(); |
1346 | viewport()->repaint(rect, true); | 1345 | viewport()->repaint(rect, true); |
1347 | } | 1346 | } |
1348 | } | 1347 | } |
1349 | 1348 | ||
1350 | void KListView::rename(QListViewItem *item, int c) | 1349 | void KListView::rename(QListViewItem *item, int c) |
1351 | { | 1350 | { |
1352 | if (d->renameable.contains(c)) | 1351 | if (d->renameable.contains(c)) |
1353 | { | 1352 | { |
1354 | ensureItemVisible(item); | 1353 | ensureItemVisible(item); |
1355 | //US d->editor->load(item,c); | 1354 | //US d->editor->load(item,c); |
1356 | qDebug("KListView::rename has to be verified"); | 1355 | qDebug("KListView::rename has to be verified"); |
1357 | 1356 | ||
1358 | } | 1357 | } |
1359 | } | 1358 | } |
1360 | 1359 | ||
1361 | bool KListView::isRenameable (int col) const | 1360 | bool KListView::isRenameable (int col) const |
1362 | { | 1361 | { |
1363 | return d->renameable.contains(col); | 1362 | return d->renameable.contains(col); |
1364 | } | 1363 | } |
1365 | 1364 | ||
1366 | void KListView::setRenameable (int col, bool yesno) | 1365 | void KListView::setRenameable (int col, bool yesno) |
1367 | { | 1366 | { |
1368 | if (col>=header()->count()) return; | 1367 | if (col>=header()->count()) return; |
1369 | 1368 | ||
1370 | d->renameable.remove(col); | 1369 | d->renameable.remove(col); |
1371 | if (yesno && d->renameable.find(col)==d->renameable.end()) | 1370 | if (yesno && d->renameable.find(col)==d->renameable.end()) |
1372 | d->renameable+=col; | 1371 | d->renameable+=col; |
1373 | else if (!yesno && d->renameable.find(col)!=d->renameable.end()) | 1372 | else if (!yesno && d->renameable.find(col)!=d->renameable.end()) |
1374 | d->renameable.remove(col); | 1373 | d->renameable.remove(col); |
1375 | } | 1374 | } |
1376 | 1375 | ||
1377 | void KListView::doneEditing(QListViewItem *item, int row) | 1376 | void KListView::doneEditing(QListViewItem *item, int row) |
1378 | { | 1377 | { |
1379 | emit itemRenamed(item, item->text(row), row); | 1378 | emit itemRenamed(item, item->text(row), row); |
1380 | emit itemRenamed(item); | 1379 | emit itemRenamed(item); |
1381 | } | 1380 | } |
1382 | 1381 | ||
1383 | bool KListView::acceptDrag(QDropEvent* e) const | 1382 | bool KListView::acceptDrag(QDropEvent* e) const |
1384 | { | 1383 | { |
1385 | qDebug("KListView::acceptDrag drag&drop not supported yet"); | 1384 | qDebug("KListView::acceptDrag drag&drop not supported yet"); |
1386 | //US return acceptDrops() && itemsMovable() && (e->source()==viewport()); | 1385 | //US return acceptDrops() && itemsMovable() && (e->source()==viewport()); |
1387 | return false; | 1386 | return false; |
1388 | } | 1387 | } |
1389 | 1388 | ||
1390 | void KListView::setCreateChildren(bool b) | 1389 | void KListView::setCreateChildren(bool b) |
1391 | { | 1390 | { |
1392 | d->createChildren=b; | 1391 | d->createChildren=b; |
1393 | } | 1392 | } |
1394 | 1393 | ||
1395 | bool KListView::createChildren() const | 1394 | bool KListView::createChildren() const |
1396 | { | 1395 | { |
1397 | return d->createChildren; | 1396 | return d->createChildren; |
1398 | } | 1397 | } |
1399 | 1398 | ||
1400 | 1399 | ||
1401 | int KListView::tooltipColumn() const | 1400 | int KListView::tooltipColumn() const |
1402 | { | 1401 | { |
1403 | return d->tooltipColumn; | 1402 | return d->tooltipColumn; |
1404 | } | 1403 | } |
1405 | 1404 | ||
1406 | void KListView::setTooltipColumn(int column) | 1405 | void KListView::setTooltipColumn(int column) |
1407 | { | 1406 | { |
1408 | d->tooltipColumn=column; | 1407 | d->tooltipColumn=column; |
1409 | } | 1408 | } |
1410 | 1409 | ||
1411 | void KListView::setDropHighlighter(bool b) | 1410 | void KListView::setDropHighlighter(bool b) |
1412 | { | 1411 | { |
1413 | d->dropHighlighter=b; | 1412 | d->dropHighlighter=b; |
1414 | } | 1413 | } |
1415 | 1414 | ||
1416 | bool KListView::dropHighlighter() const | 1415 | bool KListView::dropHighlighter() const |
1417 | { | 1416 | { |
1418 | return d->dropHighlighter; | 1417 | return d->dropHighlighter; |
1419 | } | 1418 | } |
1420 | 1419 | ||
1421 | bool KListView::showTooltip(QListViewItem *item, const QPoint &, int column) const | 1420 | bool KListView::showTooltip(QListViewItem *item, const QPoint &, int column) const |
1422 | { | 1421 | { |
1423 | return ((tooltip(item, column).length()>0) && (column==tooltipColumn())); | 1422 | return ((tooltip(item, column).length()>0) && (column==tooltipColumn())); |
1424 | } | 1423 | } |
1425 | 1424 | ||
1426 | QString KListView::tooltip(QListViewItem *item, int column) const | 1425 | QString KListView::tooltip(QListViewItem *item, int column) const |
1427 | { | 1426 | { |
1428 | return item->text(column); | 1427 | return item->text(column); |
1429 | } | 1428 | } |
1430 | 1429 | ||
1431 | void KListView::setTabOrderedRenaming(bool b) | 1430 | void KListView::setTabOrderedRenaming(bool b) |
1432 | { | 1431 | { |
1433 | d->tabRename = b; | 1432 | d->tabRename = b; |
1434 | } | 1433 | } |
1435 | 1434 | ||
1436 | bool KListView::tabOrderedRenaming() const | 1435 | bool KListView::tabOrderedRenaming() const |
1437 | { | 1436 | { |
1438 | return d->tabRename; | 1437 | return d->tabRename; |
1439 | } | 1438 | } |
1440 | 1439 | ||
1441 | void KListView::keyPressEvent (QKeyEvent* e) | 1440 | void KListView::keyPressEvent (QKeyEvent* e) |
1442 | { | 1441 | { |
1443 | //don't we need a contextMenuModifier too ? (aleXXX) | 1442 | //don't we need a contextMenuModifier too ? (aleXXX) |
1444 | if (e->key() == d->contextMenuKey) | 1443 | if (e->key() == d->contextMenuKey) |
1445 | { | 1444 | { |
1446 | emit menuShortCutPressed (this, currentItem()); | 1445 | emit menuShortCutPressed (this, currentItem()); |
1447 | return; | 1446 | return; |
1448 | } | 1447 | } |
1449 | if (e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace) | 1448 | if (e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace) |
1450 | { | 1449 | { |
1451 | emit signalDelete ( ); | 1450 | emit signalDelete ( ); |
1452 | return; | 1451 | return; |
1453 | } | 1452 | } |
1454 | 1453 | ||
1455 | if (d->selectionMode != FileManager) | 1454 | if (d->selectionMode != FileManager) |
1456 | QListView::keyPressEvent (e); | 1455 | QListView::keyPressEvent (e); |
1457 | else | 1456 | else |
1458 | fileManagerKeyPressEvent (e); | 1457 | fileManagerKeyPressEvent (e); |
1459 | } | 1458 | } |
1460 | 1459 | ||
1461 | void KListView::activateAutomaticSelection() | 1460 | void KListView::activateAutomaticSelection() |
1462 | { | 1461 | { |
1463 | d->selectedBySimpleMove=true; | 1462 | d->selectedBySimpleMove=true; |
1464 | d->selectedUsingMouse=false; | 1463 | d->selectedUsingMouse=false; |
1465 | if (currentItem()!=0) | 1464 | if (currentItem()!=0) |
1466 | { | 1465 | { |
1467 | selectAll(false); | 1466 | selectAll(false); |
1468 | currentItem()->setSelected(true); | 1467 | currentItem()->setSelected(true); |
1469 | currentItem()->repaint(); | 1468 | currentItem()->repaint(); |
1470 | emit selectionChanged(); | 1469 | emit selectionChanged(); |
1471 | }; | 1470 | }; |
1472 | } | 1471 | } |
1473 | 1472 | ||
1474 | void KListView::deactivateAutomaticSelection() | 1473 | void KListView::deactivateAutomaticSelection() |
1475 | { | 1474 | { |
1476 | d->selectedBySimpleMove=false; | 1475 | d->selectedBySimpleMove=false; |
1477 | } | 1476 | } |
1478 | 1477 | ||
1479 | bool KListView::automaticSelection() const | 1478 | bool KListView::automaticSelection() const |
1480 | { | 1479 | { |
1481 | return d->selectedBySimpleMove; | 1480 | return d->selectedBySimpleMove; |
1482 | } | 1481 | } |
1483 | 1482 | ||
1484 | void KListView::fileManagerKeyPressEvent (QKeyEvent* e) | 1483 | void KListView::fileManagerKeyPressEvent (QKeyEvent* e) |
1485 | { | 1484 | { |
1486 | //don't care whether it's on the keypad or not | 1485 | //don't care whether it's on the keypad or not |
1487 | int e_state=(e->state() & ~Keypad); | 1486 | int e_state=(e->state() & ~Keypad); |
1488 | 1487 | ||
1489 | int oldSelectionDirection(d->selectionDirection); | 1488 | int oldSelectionDirection(d->selectionDirection); |
1490 | 1489 | ||
1491 | if ((e->key()!=Key_Shift) && (e->key()!=Key_Control) | 1490 | if ((e->key()!=Key_Shift) && (e->key()!=Key_Control) |
1492 | && (e->key()!=Key_Meta) && (e->key()!=Key_Alt)) | 1491 | && (e->key()!=Key_Meta) && (e->key()!=Key_Alt)) |
1493 | { | 1492 | { |
1494 | if ((e_state==ShiftButton) && (!d->wasShiftEvent) && (!d->selectedBySimpleMove)) | 1493 | if ((e_state==ShiftButton) && (!d->wasShiftEvent) && (!d->selectedBySimpleMove)) |
1495 | selectAll(FALSE); | 1494 | selectAll(FALSE); |
1496 | d->selectionDirection=0; | 1495 | d->selectionDirection=0; |
1497 | d->wasShiftEvent = (e_state == ShiftButton); | 1496 | d->wasShiftEvent = (e_state == ShiftButton); |
1498 | }; | 1497 | }; |
1499 | 1498 | ||
1500 | //d->wasShiftEvent = (e_state == ShiftButton); | 1499 | //d->wasShiftEvent = (e_state == ShiftButton); |
1501 | 1500 | ||
1502 | 1501 | ||
1503 | QListViewItem* item = currentItem(); | 1502 | QListViewItem* item = currentItem(); |
1504 | if (item==0) return; | 1503 | if (item==0) return; |
1505 | 1504 | ||
1506 | QListViewItem* repaintItem1 = item; | 1505 | QListViewItem* repaintItem1 = item; |
1507 | QListViewItem* repaintItem2 = 0L; | 1506 | QListViewItem* repaintItem2 = 0L; |
1508 | QListViewItem* visItem = 0L; | 1507 | QListViewItem* visItem = 0L; |
1509 | 1508 | ||
1510 | QListViewItem* nextItem = 0L; | 1509 | QListViewItem* nextItem = 0L; |
1511 | int items = 0; | 1510 | int items = 0; |
1512 | 1511 | ||
1513 | bool shiftOrCtrl((e_state==ControlButton) || (e_state==ShiftButton)); | 1512 | bool shiftOrCtrl((e_state==ControlButton) || (e_state==ShiftButton)); |
1514 | int selectedItems(0); | 1513 | int selectedItems(0); |
1515 | for (QListViewItem *tmpItem=firstChild(); tmpItem!=0; tmpItem=tmpItem->nextSibling()) | 1514 | for (QListViewItem *tmpItem=firstChild(); tmpItem!=0; tmpItem=tmpItem->nextSibling()) |
1516 | if (tmpItem->isSelected()) selectedItems++; | 1515 | if (tmpItem->isSelected()) selectedItems++; |
1517 | 1516 | ||
1518 | if (((selectedItems==0) || ((selectedItems==1) && (d->selectedUsingMouse))) | 1517 | if (((selectedItems==0) || ((selectedItems==1) && (d->selectedUsingMouse))) |
1519 | && (e_state==NoButton) | 1518 | && (e_state==NoButton) |
1520 | && ((e->key()==Key_Down) | 1519 | && ((e->key()==Key_Down) |
1521 | || (e->key()==Key_Up) | 1520 | || (e->key()==Key_Up) |
1522 | || (e->key()==Key_Next) | 1521 | || (e->key()==Key_Next) |
1523 | || (e->key()==Key_Prior) | 1522 | || (e->key()==Key_Prior) |
1524 | || (e->key()==Key_Home) | 1523 | || (e->key()==Key_Home) |
1525 | || (e->key()==Key_End))) | 1524 | || (e->key()==Key_End))) |
1526 | { | 1525 | { |
1527 | d->selectedBySimpleMove=true; | 1526 | d->selectedBySimpleMove=true; |
1528 | d->selectedUsingMouse=false; | 1527 | d->selectedUsingMouse=false; |
1529 | } | 1528 | } |
1530 | else if (selectedItems>1) | 1529 | else if (selectedItems>1) |
1531 | d->selectedBySimpleMove=false; | 1530 | d->selectedBySimpleMove=false; |
1532 | 1531 | ||
1533 | bool emitSelectionChanged(false); | 1532 | bool emitSelectionChanged(false); |
1534 | 1533 | ||
1535 | switch (e->key()) | 1534 | switch (e->key()) |
1536 | { | 1535 | { |
1537 | case Key_Escape: | 1536 | case Key_Escape: |
1538 | selectAll(FALSE); | 1537 | selectAll(FALSE); |
1539 | emitSelectionChanged=TRUE; | 1538 | emitSelectionChanged=TRUE; |
1540 | break; | 1539 | break; |
1541 | 1540 | ||
1542 | case Key_Space: | 1541 | case Key_Space: |
1543 | //toggle selection of current item | 1542 | //toggle selection of current item |
1544 | if (d->selectedBySimpleMove) | 1543 | if (d->selectedBySimpleMove) |
1545 | d->selectedBySimpleMove=false; | 1544 | d->selectedBySimpleMove=false; |
1546 | item->setSelected(!item->isSelected()); | 1545 | item->setSelected(!item->isSelected()); |
1547 | emitSelectionChanged=TRUE; | 1546 | emitSelectionChanged=TRUE; |
1548 | break; | 1547 | break; |
1549 | 1548 | ||
1550 | case Key_Insert: | 1549 | case Key_Insert: |
1551 | //toggle selection of current item and move to the next item | 1550 | //toggle selection of current item and move to the next item |
1552 | if (d->selectedBySimpleMove) | 1551 | if (d->selectedBySimpleMove) |
1553 | { | 1552 | { |
1554 | d->selectedBySimpleMove=false; | 1553 | d->selectedBySimpleMove=false; |
1555 | if (!item->isSelected()) item->setSelected(TRUE); | 1554 | if (!item->isSelected()) item->setSelected(TRUE); |
1556 | } | 1555 | } |
1557 | else | 1556 | else |
1558 | { | 1557 | { |
1559 | item->setSelected(!item->isSelected()); | 1558 | item->setSelected(!item->isSelected()); |
1560 | }; | 1559 | }; |
1561 | 1560 | ||
1562 | nextItem=item->itemBelow(); | 1561 | nextItem=item->itemBelow(); |
1563 | 1562 | ||
1564 | if (nextItem!=0) | 1563 | if (nextItem!=0) |
1565 | { | 1564 | { |
1566 | repaintItem2=nextItem; | 1565 | repaintItem2=nextItem; |
1567 | visItem=nextItem; | 1566 | visItem=nextItem; |
1568 | setCurrentItem(nextItem); | 1567 | setCurrentItem(nextItem); |
1569 | }; | 1568 | }; |
1570 | d->selectionDirection=1; | 1569 | d->selectionDirection=1; |
1571 | emitSelectionChanged=TRUE; | 1570 | emitSelectionChanged=TRUE; |
1572 | break; | 1571 | break; |
1573 | 1572 | ||
1574 | case Key_Down: | 1573 | case Key_Down: |
1575 | nextItem=item->itemBelow(); | 1574 | nextItem=item->itemBelow(); |
1576 | //toggle selection of current item and move to the next item | 1575 | //toggle selection of current item and move to the next item |
1577 | if (shiftOrCtrl) | 1576 | if (shiftOrCtrl) |
1578 | { | 1577 | { |
1579 | d->selectionDirection=1; | 1578 | d->selectionDirection=1; |
1580 | if (d->selectedBySimpleMove) | 1579 | if (d->selectedBySimpleMove) |
1581 | d->selectedBySimpleMove=false; | 1580 | d->selectedBySimpleMove=false; |
1582 | else | 1581 | else |
1583 | { | 1582 | { |
1584 | if (oldSelectionDirection!=-1) | 1583 | if (oldSelectionDirection!=-1) |
1585 | { | 1584 | { |
1586 | item->setSelected(!item->isSelected()); | 1585 | item->setSelected(!item->isSelected()); |
1587 | emitSelectionChanged=TRUE; | 1586 | emitSelectionChanged=TRUE; |
1588 | }; | 1587 | }; |
1589 | }; | 1588 | }; |
1590 | } | 1589 | } |
1591 | else if ((d->selectedBySimpleMove) && (nextItem!=0)) | 1590 | else if ((d->selectedBySimpleMove) && (nextItem!=0)) |
1592 | { | 1591 | { |
1593 | item->setSelected(false); | 1592 | item->setSelected(false); |
1594 | emitSelectionChanged=TRUE; | 1593 | emitSelectionChanged=TRUE; |
1595 | }; | 1594 | }; |
1596 | 1595 | ||
1597 | if (nextItem!=0) | 1596 | if (nextItem!=0) |
1598 | { | 1597 | { |
1599 | if (d->selectedBySimpleMove) | 1598 | if (d->selectedBySimpleMove) |
1600 | nextItem->setSelected(true); | 1599 | nextItem->setSelected(true); |
1601 | repaintItem2=nextItem; | 1600 | repaintItem2=nextItem; |
1602 | visItem=nextItem; | 1601 | visItem=nextItem; |
1603 | setCurrentItem(nextItem); | 1602 | setCurrentItem(nextItem); |
1604 | }; | 1603 | }; |
1605 | break; | 1604 | break; |
1606 | 1605 | ||
1607 | case Key_Up: | 1606 | case Key_Up: |
1608 | nextItem=item->itemAbove(); | 1607 | nextItem=item->itemAbove(); |
1609 | d->selectionDirection=-1; | 1608 | d->selectionDirection=-1; |
1610 | //move to the prev. item and toggle selection of this one | 1609 | //move to the prev. item and toggle selection of this one |
1611 | // => No, can't select the last item, with this. For symmetry, let's | 1610 | // => No, can't select the last item, with this. For symmetry, let's |
1612 | // toggle selection and THEN move up, just like we do in down (David) | 1611 | // toggle selection and THEN move up, just like we do in down (David) |
1613 | if (shiftOrCtrl) | 1612 | if (shiftOrCtrl) |
1614 | { | 1613 | { |
1615 | if (d->selectedBySimpleMove) | 1614 | if (d->selectedBySimpleMove) |
1616 | d->selectedBySimpleMove=false; | 1615 | d->selectedBySimpleMove=false; |
1617 | else | 1616 | else |
1618 | { | 1617 | { |
1619 | if (oldSelectionDirection!=1) | 1618 | if (oldSelectionDirection!=1) |
1620 | { | 1619 | { |
1621 | item->setSelected(!item->isSelected()); | 1620 | item->setSelected(!item->isSelected()); |
1622 | emitSelectionChanged=TRUE; | 1621 | emitSelectionChanged=TRUE; |
1623 | }; | 1622 | }; |
1624 | } | 1623 | } |
1625 | } | 1624 | } |
1626 | else if ((d->selectedBySimpleMove) && (nextItem!=0)) | 1625 | else if ((d->selectedBySimpleMove) && (nextItem!=0)) |
1627 | { | 1626 | { |
1628 | item->setSelected(false); | 1627 | item->setSelected(false); |
1629 | emitSelectionChanged=TRUE; | 1628 | emitSelectionChanged=TRUE; |
1630 | }; | 1629 | }; |
1631 | 1630 | ||
1632 | if (nextItem!=0) | 1631 | if (nextItem!=0) |
1633 | { | 1632 | { |
1634 | if (d->selectedBySimpleMove) | 1633 | if (d->selectedBySimpleMove) |
1635 | nextItem->setSelected(true); | 1634 | nextItem->setSelected(true); |
1636 | repaintItem2=nextItem; | 1635 | repaintItem2=nextItem; |
1637 | visItem=nextItem; | 1636 | visItem=nextItem; |
1638 | setCurrentItem(nextItem); | 1637 | setCurrentItem(nextItem); |
1639 | }; | 1638 | }; |
1640 | break; | 1639 | break; |
1641 | 1640 | ||
1642 | case Key_End: | 1641 | case Key_End: |
1643 | //move to the last item and toggle selection of all items inbetween | 1642 | //move to the last item and toggle selection of all items inbetween |
1644 | nextItem=item; | 1643 | nextItem=item; |
1645 | if (d->selectedBySimpleMove) | 1644 | if (d->selectedBySimpleMove) |
1646 | item->setSelected(false); | 1645 | item->setSelected(false); |
1647 | if (shiftOrCtrl) | 1646 | if (shiftOrCtrl) |
1648 | d->selectedBySimpleMove=false; | 1647 | d->selectedBySimpleMove=false; |
1649 | 1648 | ||
1650 | while(nextItem!=0) | 1649 | while(nextItem!=0) |
1651 | { | 1650 | { |
1652 | if (shiftOrCtrl) | 1651 | if (shiftOrCtrl) |
1653 | nextItem->setSelected(!nextItem->isSelected()); | 1652 | nextItem->setSelected(!nextItem->isSelected()); |
1654 | if (nextItem->itemBelow()==0) | 1653 | if (nextItem->itemBelow()==0) |
1655 | { | 1654 | { |
1656 | if (d->selectedBySimpleMove) | 1655 | if (d->selectedBySimpleMove) |
1657 | nextItem->setSelected(true); | 1656 | nextItem->setSelected(true); |
1658 | repaintItem2=nextItem; | 1657 | repaintItem2=nextItem; |
1659 | visItem=nextItem; | 1658 | visItem=nextItem; |
1660 | setCurrentItem(nextItem); | 1659 | setCurrentItem(nextItem); |
1661 | } | 1660 | } |
1662 | nextItem=nextItem->itemBelow(); | 1661 | nextItem=nextItem->itemBelow(); |
1663 | } | 1662 | } |
1664 | emitSelectionChanged=TRUE; | 1663 | emitSelectionChanged=TRUE; |
1665 | break; | 1664 | break; |
1666 | 1665 | ||
1667 | case Key_Home: | 1666 | case Key_Home: |
1668 | // move to the first item and toggle selection of all items inbetween | 1667 | // move to the first item and toggle selection of all items inbetween |
1669 | nextItem = firstChild(); | 1668 | nextItem = firstChild(); |
1670 | visItem = nextItem; | 1669 | visItem = nextItem; |
1671 | repaintItem2 = visItem; | 1670 | repaintItem2 = visItem; |
1672 | if (d->selectedBySimpleMove) | 1671 | if (d->selectedBySimpleMove) |
1673 | item->setSelected(false); | 1672 | item->setSelected(false); |
1674 | if (shiftOrCtrl) | 1673 | if (shiftOrCtrl) |
1675 | { | 1674 | { |
1676 | d->selectedBySimpleMove=false; | 1675 | d->selectedBySimpleMove=false; |
1677 | 1676 | ||
1678 | while ( nextItem != item ) | 1677 | while ( nextItem != item ) |
1679 | { | 1678 | { |
1680 | nextItem->setSelected( !nextItem->isSelected() ); | 1679 | nextItem->setSelected( !nextItem->isSelected() ); |
1681 | nextItem = nextItem->itemBelow(); | 1680 | nextItem = nextItem->itemBelow(); |
1682 | } | 1681 | } |
1683 | item->setSelected( !item->isSelected() ); | 1682 | item->setSelected( !item->isSelected() ); |
1684 | } | 1683 | } |
1685 | setCurrentItem( firstChild() ); | 1684 | setCurrentItem( firstChild() ); |
1686 | emitSelectionChanged=TRUE; | 1685 | emitSelectionChanged=TRUE; |
1687 | break; | 1686 | break; |
1688 | 1687 | ||
1689 | case Key_Next: | 1688 | case Key_Next: |
1690 | items=visibleHeight()/item->height(); | 1689 | items=visibleHeight()/item->height(); |
1691 | nextItem=item; | 1690 | nextItem=item; |
1692 | if (d->selectedBySimpleMove) | 1691 | if (d->selectedBySimpleMove) |
1693 | item->setSelected(false); | 1692 | item->setSelected(false); |
1694 | if (shiftOrCtrl) | 1693 | if (shiftOrCtrl) |
1695 | { | 1694 | { |
1696 | d->selectedBySimpleMove=false; | 1695 | d->selectedBySimpleMove=false; |
1697 | d->selectionDirection=1; | 1696 | d->selectionDirection=1; |
1698 | }; | 1697 | }; |
1699 | 1698 | ||
1700 | for (int i=0; i<items; i++) | 1699 | for (int i=0; i<items; i++) |
1701 | { | 1700 | { |
1702 | if (shiftOrCtrl) | 1701 | if (shiftOrCtrl) |
1703 | nextItem->setSelected(!nextItem->isSelected()); | 1702 | nextItem->setSelected(!nextItem->isSelected()); |
1704 | //the end | 1703 | //the end |
1705 | if ((i==items-1) || (nextItem->itemBelow()==0)) | 1704 | if ((i==items-1) || (nextItem->itemBelow()==0)) |
1706 | 1705 | ||
1707 | { | 1706 | { |
1708 | if (shiftOrCtrl) | 1707 | if (shiftOrCtrl) |
1709 | nextItem->setSelected(!nextItem->isSelected()); | 1708 | nextItem->setSelected(!nextItem->isSelected()); |
1710 | if (d->selectedBySimpleMove) | 1709 | if (d->selectedBySimpleMove) |
1711 | nextItem->setSelected(true); | 1710 | nextItem->setSelected(true); |
1712 | ensureItemVisible(nextItem); | 1711 | ensureItemVisible(nextItem); |
1713 | setCurrentItem(nextItem); | 1712 | setCurrentItem(nextItem); |
1714 | update(); | 1713 | update(); |
1715 | if ((shiftOrCtrl) || (d->selectedBySimpleMove)) | 1714 | if ((shiftOrCtrl) || (d->selectedBySimpleMove)) |
1716 | { | 1715 | { |
1717 | emit selectionChanged(); | 1716 | emit selectionChanged(); |
1718 | } | 1717 | } |
1719 | return; | 1718 | return; |
1720 | } | 1719 | } |
1721 | nextItem=nextItem->itemBelow(); | 1720 | nextItem=nextItem->itemBelow(); |
1722 | } | 1721 | } |
1723 | break; | 1722 | break; |
1724 | 1723 | ||
1725 | case Key_Prior: | 1724 | case Key_Prior: |
1726 | items=visibleHeight()/item->height(); | 1725 | items=visibleHeight()/item->height(); |
1727 | nextItem=item; | 1726 | nextItem=item; |
1728 | if (d->selectedBySimpleMove) | 1727 | if (d->selectedBySimpleMove) |
1729 | item->setSelected(false); | 1728 | item->setSelected(false); |
1730 | if (shiftOrCtrl) | 1729 | if (shiftOrCtrl) |
1731 | { | 1730 | { |
1732 | d->selectionDirection=-1; | 1731 | d->selectionDirection=-1; |
1733 | d->selectedBySimpleMove=false; | 1732 | d->selectedBySimpleMove=false; |
1734 | }; | 1733 | }; |
1735 | 1734 | ||
1736 | for (int i=0; i<items; i++) | 1735 | for (int i=0; i<items; i++) |
1737 | { | 1736 | { |
1738 | if ((nextItem!=item) &&(shiftOrCtrl)) | 1737 | if ((nextItem!=item) &&(shiftOrCtrl)) |
1739 | nextItem->setSelected(!nextItem->isSelected()); | 1738 | nextItem->setSelected(!nextItem->isSelected()); |
1740 | //the end | 1739 | //the end |
1741 | if ((i==items-1) || (nextItem->itemAbove()==0)) | 1740 | if ((i==items-1) || (nextItem->itemAbove()==0)) |
1742 | 1741 | ||
1743 | { | 1742 | { |
1744 | if (d->selectedBySimpleMove) | 1743 | if (d->selectedBySimpleMove) |
1745 | nextItem->setSelected(true); | 1744 | nextItem->setSelected(true); |
1746 | ensureItemVisible(nextItem); | 1745 | ensureItemVisible(nextItem); |
1747 | setCurrentItem(nextItem); | 1746 | setCurrentItem(nextItem); |
1748 | update(); | 1747 | update(); |
1749 | if ((shiftOrCtrl) || (d->selectedBySimpleMove)) | 1748 | if ((shiftOrCtrl) || (d->selectedBySimpleMove)) |
1750 | { | 1749 | { |
1751 | emit selectionChanged(); | 1750 | emit selectionChanged(); |
1752 | } | 1751 | } |
1753 | return; | 1752 | return; |
1754 | } | 1753 | } |
1755 | nextItem=nextItem->itemAbove(); | 1754 | nextItem=nextItem->itemAbove(); |
1756 | } | 1755 | } |
1757 | break; | 1756 | break; |
1758 | 1757 | ||
1759 | case Key_Minus: | 1758 | case Key_Minus: |
1760 | if ( item->isOpen() ) | 1759 | if ( item->isOpen() ) |
1761 | setOpen( item, FALSE ); | 1760 | setOpen( item, FALSE ); |
1762 | break; | 1761 | break; |
1763 | case Key_Plus: | 1762 | case Key_Plus: |
1764 | if ( !item->isOpen() && (item->isExpandable() || item->childCount()) ) | 1763 | if ( !item->isOpen() && (item->isExpandable() || item->childCount()) ) |
1765 | setOpen( item, TRUE ); | 1764 | setOpen( item, TRUE ); |
1766 | break; | 1765 | break; |
1767 | default: | 1766 | default: |
1768 | bool realKey = ((e->key()!=Key_Shift) && (e->key()!=Key_Control) | 1767 | bool realKey = ((e->key()!=Key_Shift) && (e->key()!=Key_Control) |
1769 | && (e->key()!=Key_Meta) && (e->key()!=Key_Alt)); | 1768 | && (e->key()!=Key_Meta) && (e->key()!=Key_Alt)); |
1770 | 1769 | ||
1771 | bool selectCurrentItem = (d->selectedBySimpleMove) && (item->isSelected()); | 1770 | bool selectCurrentItem = (d->selectedBySimpleMove) && (item->isSelected()); |
1772 | if (realKey && selectCurrentItem) | 1771 | if (realKey && selectCurrentItem) |
1773 | item->setSelected(false); | 1772 | item->setSelected(false); |
1774 | //this is mainly for the "goto filename beginning with pressed char" feature (aleXXX) | 1773 | //this is mainly for the "goto filename beginning with pressed char" feature (aleXXX) |
1775 | QListView::SelectionMode oldSelectionMode = selectionMode(); | 1774 | QListView::SelectionMode oldSelectionMode = selectionMode(); |
1776 | setSelectionMode (QListView::Multi); | 1775 | setSelectionMode (QListView::Multi); |
1777 | QListView::keyPressEvent (e); | 1776 | QListView::keyPressEvent (e); |
1778 | setSelectionMode (oldSelectionMode); | 1777 | setSelectionMode (oldSelectionMode); |
1779 | if (realKey && selectCurrentItem) | 1778 | if (realKey && selectCurrentItem) |
1780 | { | 1779 | { |
1781 | currentItem()->setSelected(true); | 1780 | currentItem()->setSelected(true); |
1782 | emitSelectionChanged=TRUE; | 1781 | emitSelectionChanged=TRUE; |
1783 | } | 1782 | } |
1784 | repaintItem2=currentItem(); | 1783 | repaintItem2=currentItem(); |
1785 | if (realKey) | 1784 | if (realKey) |
1786 | visItem=currentItem(); | 1785 | visItem=currentItem(); |
1787 | break; | 1786 | break; |
1788 | } | 1787 | } |
1789 | 1788 | ||
1790 | if (visItem) | 1789 | if (visItem) |
1791 | ensureItemVisible(visItem); | 1790 | ensureItemVisible(visItem); |
1792 | 1791 | ||
1793 | QRect ir; | 1792 | QRect ir; |
1794 | if (repaintItem1) | 1793 | if (repaintItem1) |
1795 | ir = ir.unite( itemRect(repaintItem1) ); | 1794 | ir = ir.unite( itemRect(repaintItem1) ); |
1796 | if (repaintItem2) | 1795 | if (repaintItem2) |
1797 | ir = ir.unite( itemRect(repaintItem2) ); | 1796 | ir = ir.unite( itemRect(repaintItem2) ); |
1798 | 1797 | ||
1799 | if ( !ir.isEmpty() ) | 1798 | if ( !ir.isEmpty() ) |
1800 | { // rectangle to be repainted | 1799 | { // rectangle to be repainted |
1801 | if ( ir.x() < 0 ) | 1800 | if ( ir.x() < 0 ) |
1802 | ir.moveBy( -ir.x(), 0 ); | 1801 | ir.moveBy( -ir.x(), 0 ); |
1803 | viewport()->repaint( ir, FALSE ); | 1802 | viewport()->repaint( ir, FALSE ); |
1804 | } | 1803 | } |
1805 | /*if (repaintItem1) | 1804 | /*if (repaintItem1) |
1806 | repaintItem1->repaint(); | 1805 | repaintItem1->repaint(); |
1807 | if (repaintItem2) | 1806 | if (repaintItem2) |
1808 | repaintItem2->repaint();*/ | 1807 | repaintItem2->repaint();*/ |
1809 | update(); | 1808 | update(); |
1810 | if (emitSelectionChanged) | 1809 | if (emitSelectionChanged) |
1811 | emit selectionChanged(); | 1810 | emit selectionChanged(); |
1812 | } | 1811 | } |
1813 | 1812 | ||
1814 | void KListView::setSelectionModeExt (SelectionModeExt mode) | 1813 | void KListView::setSelectionModeExt (SelectionModeExt mode) |
1815 | { | 1814 | { |
1816 | d->selectionMode = mode; | 1815 | d->selectionMode = mode; |
1817 | 1816 | ||
1818 | switch (mode) | 1817 | switch (mode) |
1819 | { | 1818 | { |
1820 | case Single: | 1819 | case Single: |
1821 | case Multi: | 1820 | case Multi: |
1822 | case Extended: | 1821 | case Extended: |
1823 | case NoSelection: | 1822 | case NoSelection: |
1824 | setSelectionMode (static_cast<QListView::SelectionMode>(static_cast<int>(mode))); | 1823 | setSelectionMode (static_cast<QListView::SelectionMode>(static_cast<int>(mode))); |
1825 | break; | 1824 | break; |
1826 | 1825 | ||
1827 | case FileManager: | 1826 | case FileManager: |
1828 | setSelectionMode (QListView::Extended); | 1827 | setSelectionMode (QListView::Extended); |
1829 | break; | 1828 | break; |
1830 | 1829 | ||
1831 | default: | 1830 | default: |
1832 | kdWarning () << "Warning: illegal selection mode " << int(mode) << " set!" << endl; | 1831 | kdWarning () << "Warning: illegal selection mode " << int(mode) << " set!" << endl; |
1833 | break; | 1832 | break; |
1834 | } | 1833 | } |
1835 | } | 1834 | } |
1836 | 1835 | ||
1837 | KListView::SelectionModeExt KListView::selectionModeExt () const | 1836 | KListView::SelectionModeExt KListView::selectionModeExt () const |
1838 | { | 1837 | { |
1839 | return d->selectionMode; | 1838 | return d->selectionMode; |
1840 | } | 1839 | } |
1841 | 1840 | ||
1842 | int KListView::itemIndex( const QListViewItem *item ) const | 1841 | int KListView::itemIndex( const QListViewItem *item ) const |
1843 | { | 1842 | { |
1844 | if ( !item ) | 1843 | if ( !item ) |
1845 | return -1; | 1844 | return -1; |
1846 | 1845 | ||
1847 | if ( item == firstChild() ) | 1846 | if ( item == firstChild() ) |
1848 | return 0; | 1847 | return 0; |
1849 | else { | 1848 | else { |
1850 | QListViewItemIterator it(firstChild()); | 1849 | QListViewItemIterator it(firstChild()); |
1851 | uint j = 0; | 1850 | uint j = 0; |
1852 | for (; it.current() && it.current() != item; ++it, ++j ); | 1851 | for (; it.current() && it.current() != item; ++it, ++j ); |
1853 | 1852 | ||
1854 | if( !it.current() ) | 1853 | if( !it.current() ) |
1855 | return -1; | 1854 | return -1; |
1856 | 1855 | ||
1857 | return j; | 1856 | return j; |
1858 | } | 1857 | } |
1859 | } | 1858 | } |
1860 | 1859 | ||
1861 | QListViewItem* KListView::itemAtIndex(int index) | 1860 | QListViewItem* KListView::itemAtIndex(int index) |
1862 | { | 1861 | { |
1863 | if (index<0) | 1862 | if (index<0) |
1864 | return 0; | 1863 | return 0; |
1865 | 1864 | ||
1866 | int j(0); | 1865 | int j(0); |
1867 | for (QListViewItemIterator it=firstChild(); it.current(); it++) | 1866 | for (QListViewItemIterator it=firstChild(); it.current(); it++) |
1868 | { | 1867 | { |
1869 | if (j==index) | 1868 | if (j==index) |
1870 | return it.current(); | 1869 | return it.current(); |
1871 | j++; | 1870 | j++; |
1872 | }; | 1871 | }; |
1873 | return 0; | 1872 | return 0; |
1874 | } | 1873 | } |
1875 | 1874 | ||
1876 | 1875 | ||
1877 | void KListView::emitContextMenu (KListView*, QListViewItem* i) | 1876 | void KListView::emitContextMenu (KListView*, QListViewItem* i) |
1878 | { | 1877 | { |
1879 | QPoint p; | 1878 | QPoint p; |
1880 | // qDebug("KListView::emitContextMenu "); | 1879 | // qDebug("KListView::emitContextMenu "); |
1881 | 1880 | ||
1882 | if (i) | 1881 | if (i) |
1883 | p = viewport()->mapToGlobal(itemRect(i).center()); | 1882 | p = viewport()->mapToGlobal(itemRect(i).center()); |
1884 | else | 1883 | else |
1885 | p = mapToGlobal(rect().center()); | 1884 | p = mapToGlobal(rect().center()); |
1886 | 1885 | ||
1887 | emit contextMenu (this, i, p); | 1886 | emit contextMenu (this, i, p); |
1888 | } | 1887 | } |
1889 | 1888 | ||
1890 | void KListView::emitContextMenu (QListViewItem* i, const QPoint& p, int col) | 1889 | void KListView::emitContextMenu (QListViewItem* i, const QPoint& p, int col) |
1891 | { | 1890 | { |
1892 | qDebug("KListView::emitContextMenu col"); | 1891 | qDebug("KListView::emitContextMenu col"); |
1893 | emit contextRequest( i, p, col ); | 1892 | emit contextRequest( i, p, col ); |
1894 | emit contextMenu (this, i, p); | 1893 | emit contextMenu (this, i, p); |
1895 | } | 1894 | } |
1896 | 1895 | ||
1897 | void KListView::setAcceptDrops (bool val) | 1896 | void KListView::setAcceptDrops (bool val) |
1898 | { | 1897 | { |
1899 | QListView::setAcceptDrops (val); | 1898 | QListView::setAcceptDrops (val); |
1900 | viewport()->setAcceptDrops (val); | 1899 | viewport()->setAcceptDrops (val); |
1901 | } | 1900 | } |
1902 | 1901 | ||
1903 | int KListView::dropVisualizerWidth () const | 1902 | int KListView::dropVisualizerWidth () const |
1904 | { | 1903 | { |
1905 | return d->mDropVisualizerWidth; | 1904 | return d->mDropVisualizerWidth; |
1906 | } | 1905 | } |
1907 | 1906 | ||
1908 | 1907 | ||
1909 | void KListView::viewportPaintEvent(QPaintEvent *e) | 1908 | void KListView::viewportPaintEvent(QPaintEvent *e) |
1910 | { | 1909 | { |
1911 | QListView::viewportPaintEvent(e); | 1910 | QListView::viewportPaintEvent(e); |
1912 | 1911 | ||
1913 | if (d->mOldDropVisualizer.isValid() && e->rect().intersects(d->mOldDropVisualizer)) | 1912 | if (d->mOldDropVisualizer.isValid() && e->rect().intersects(d->mOldDropVisualizer)) |
1914 | { | 1913 | { |
1915 | QPainter painter(viewport()); | 1914 | QPainter painter(viewport()); |
1916 | 1915 | ||
1917 | // This is where we actually draw the drop-visualizer | 1916 | // This is where we actually draw the drop-visualizer |
1918 | painter.fillRect(d->mOldDropVisualizer, Dense4Pattern); | 1917 | painter.fillRect(d->mOldDropVisualizer, Dense4Pattern); |
1919 | } | 1918 | } |
1920 | if (d->mOldDropHighlighter.isValid() && e->rect().intersects(d->mOldDropHighlighter)) | 1919 | if (d->mOldDropHighlighter.isValid() && e->rect().intersects(d->mOldDropHighlighter)) |
1921 | { | 1920 | { |
1922 | QPainter painter(viewport()); | 1921 | QPainter painter(viewport()); |
1923 | 1922 | ||
1924 | qDebug("KListView::viewportPaintEvent has to be verified"); | 1923 | qDebug("KListView::viewportPaintEvent has to be verified"); |
1925 | 1924 | ||
1926 | // This is where we actually draw the drop-highlighter | 1925 | // This is where we actually draw the drop-highlighter |
1927 | //US style().drawPrimitive(QStyle::PE_FocusRect, &painter, d->mOldDropHighlighter, colorGroup(), | 1926 | //US style().drawPrimitive(QStyle::PE_FocusRect, &painter, d->mOldDropHighlighter, colorGroup(), |
1928 | //US QStyle::Style_FocusAtBorder); | 1927 | //US QStyle::Style_FocusAtBorder); |
1929 | 1928 | ||
1930 | //LR style().drawFocusRect(&painter, d->mOldDropHighlighter, colorGroup(), (const QColor*)0, true); | 1929 | //LR style().drawFocusRect(&painter, d->mOldDropHighlighter, colorGroup(), (const QColor*)0, true); |
1931 | 1930 | ||
1932 | 1931 | ||
1933 | } | 1932 | } |
1934 | } | 1933 | } |
1935 | 1934 | ||
1936 | void KListView::setFullWidth() | 1935 | void KListView::setFullWidth() |
1937 | { | 1936 | { |
1938 | setFullWidth(true); | 1937 | setFullWidth(true); |
1939 | } | 1938 | } |
1940 | 1939 | ||
1941 | void KListView::setFullWidth(bool fullWidth) | 1940 | void KListView::setFullWidth(bool fullWidth) |
1942 | { | 1941 | { |
1943 | d->fullWidth = fullWidth; | 1942 | d->fullWidth = fullWidth; |
1944 | //US header()->setStretchEnabled(fullWidth, columns()-1); | 1943 | //US header()->setStretchEnabled(fullWidth, columns()-1); |
1945 | } | 1944 | } |
1946 | 1945 | ||
1947 | bool KListView::fullWidth() const | 1946 | bool KListView::fullWidth() const |
1948 | { | 1947 | { |
1949 | return d->fullWidth; | 1948 | return d->fullWidth; |
1950 | } | 1949 | } |
1951 | 1950 | ||
1952 | int KListView::addColumn(const QString& label, int width) | 1951 | int KListView::addColumn(const QString& label, int width) |
1953 | { | 1952 | { |
1954 | int result = QListView::addColumn(label, width); | 1953 | int result = QListView::addColumn(label, width); |
1955 | if (d->fullWidth) { | 1954 | if (d->fullWidth) { |
1956 | //US header()->setStretchEnabled(false, columns()-2); | 1955 | //US header()->setStretchEnabled(false, columns()-2); |
1957 | //US header()->setStretchEnabled(true, columns()-1); | 1956 | //US header()->setStretchEnabled(true, columns()-1); |
1958 | } | 1957 | } |
1959 | return result; | 1958 | return result; |
1960 | } | 1959 | } |
1961 | 1960 | ||
1962 | int KListView::addColumn(const QIconSet& iconset, const QString& label, int width) | 1961 | int KListView::addColumn(const QIconSet& iconset, const QString& label, int width) |
1963 | { | 1962 | { |
1964 | int result = QListView::addColumn(iconset, label, width); | 1963 | int result = QListView::addColumn(iconset, label, width); |
1965 | if (d->fullWidth) { | 1964 | if (d->fullWidth) { |
1966 | //US header()->setStretchEnabled(false, columns()-2); | 1965 | //US header()->setStretchEnabled(false, columns()-2); |
1967 | //US header()->setStretchEnabled(true, columns()-1); | 1966 | //US header()->setStretchEnabled(true, columns()-1); |
1968 | } | 1967 | } |
1969 | return result; | 1968 | return result; |
1970 | } | 1969 | } |
1971 | 1970 | ||
1972 | void KListView::removeColumn(int index) | 1971 | void KListView::removeColumn(int index) |
1973 | { | 1972 | { |
1974 | QListView::removeColumn(index); | 1973 | QListView::removeColumn(index); |
1975 | //US if (d->fullWidth && index == columns()) header()->setStretchEnabled(true, columns()-1); | 1974 | //US if (d->fullWidth && index == columns()) header()->setStretchEnabled(true, columns()-1); |
1976 | } | 1975 | } |
1977 | 1976 | ||
1978 | void KListView::viewportResizeEvent(QResizeEvent* e) | 1977 | void KListView::viewportResizeEvent(QResizeEvent* e) |
1979 | { | 1978 | { |
1980 | QListView::viewportResizeEvent(e); | 1979 | QListView::viewportResizeEvent(e); |
1981 | } | 1980 | } |
1982 | 1981 | ||
1983 | const QColor &KListView::alternateBackground() const | 1982 | const QColor &KListView::alternateBackground() const |
1984 | { | 1983 | { |
1985 | return d->alternateBackground; | 1984 | return d->alternateBackground; |
1986 | } | 1985 | } |
1987 | 1986 | ||
1988 | void KListView::setAlternateBackground(const QColor &c) | 1987 | void KListView::setAlternateBackground(const QColor &c) |
1989 | { | 1988 | { |
1990 | d->alternateBackground = c; | 1989 | d->alternateBackground = c; |
1991 | repaint(); | 1990 | repaint(); |
1992 | } | 1991 | } |
1993 | 1992 | ||
1994 | void KListView::saveLayout(KConfig *config, const QString &group) const | 1993 | void KListView::saveLayout(KConfig *config, const QString &group) const |
1995 | { | 1994 | { |
1996 | KConfigGroupSaver saver(config, group); | 1995 | KConfigGroupSaver saver(config, group); |
1997 | QStringList widths, order; | 1996 | QStringList widths, order; |
1998 | for (int i = 0; i < columns(); ++i) | 1997 | for (int i = 0; i < columns(); ++i) |
1999 | { | 1998 | { |
2000 | widths << QString::number(columnWidth(i)); | 1999 | widths << QString::number(columnWidth(i)); |
2001 | order << QString::number(header()->mapToIndex(i)); | 2000 | order << QString::number(header()->mapToIndex(i)); |
2002 | } | 2001 | } |
2003 | config->writeEntry("ColumnWidths", widths); | 2002 | config->writeEntry("ColumnWidths", widths); |
2004 | config->writeEntry("ColumnOrder", order); | 2003 | config->writeEntry("ColumnOrder", order); |
2005 | config->writeEntry("SortColumn", d->sortColumn); | 2004 | config->writeEntry("SortColumn", d->sortColumn); |
2006 | config->writeEntry("SortAscending", d->sortAscending); | 2005 | config->writeEntry("SortAscending", d->sortAscending); |
2007 | } | 2006 | } |
2008 | 2007 | ||
2009 | void KListView::restoreLayout(KConfig *config, const QString &group) | 2008 | void KListView::restoreLayout(KConfig *config, const QString &group) |
2010 | { | 2009 | { |
2011 | KConfigGroupSaver saver(config, group); | 2010 | KConfigGroupSaver saver(config, group); |
2012 | QStringList cols = config->readListEntry("ColumnWidths"); | 2011 | QStringList cols = config->readListEntry("ColumnWidths"); |
2013 | int i = 0; | 2012 | int i = 0; |
2014 | for (QStringList::ConstIterator it = cols.begin(); it != cols.end(); ++it) | 2013 | for (QStringList::ConstIterator it = cols.begin(); it != cols.end(); ++it) |
2015 | setColumnWidth(i++, (*it).toInt()); | 2014 | setColumnWidth(i++, (*it).toInt()); |
2016 | 2015 | ||
2017 | cols = config->readListEntry("ColumnOrder"); | 2016 | cols = config->readListEntry("ColumnOrder"); |
2018 | i = 0; | 2017 | i = 0; |
2019 | for (QStringList::ConstIterator it = cols.begin(); it != cols.end(); ++it) | 2018 | for (QStringList::ConstIterator it = cols.begin(); it != cols.end(); ++it) |
2020 | header()->moveSection(i++, (*it).toInt()); | 2019 | header()->moveSection(i++, (*it).toInt()); |
2021 | 2020 | ||
2022 | /*US I changed the following code, because hasKey is not available. | 2021 | /*US I changed the following code, because hasKey is not available. |
2023 | !!! check if my version is correct | 2022 | !!! check if my version is correct |
2024 | if (config->hasKey("SortColumn")) | 2023 | if (config->hasKey("SortColumn")) |
2025 | setSorting(config->readNumEntry("SortColumn"), config->readBoolEntry("SortAscending", true)); | 2024 | setSorting(config->readNumEntry("SortColumn"), config->readBoolEntry("SortAscending", true)); |
2026 | */ | 2025 | */ |
2027 | QStringList langLst = config->readListEntry( "SortColumn" ); | 2026 | QStringList langLst = config->readListEntry( "SortColumn" ); |
2028 | if (!langLst.isEmpty()) | 2027 | if (!langLst.isEmpty()) |
2029 | setSorting(config->readNumEntry("SortColumn"), config->readBoolEntry("SortAscending", true)); | 2028 | setSorting(config->readNumEntry("SortColumn"), config->readBoolEntry("SortAscending", true)); |
2030 | } | 2029 | } |
2031 | 2030 | ||
2032 | void KListView::setSorting(int column, bool ascending) | 2031 | void KListView::setSorting(int column, bool ascending) |
2033 | { | 2032 | { |
2034 | d->sortColumn = column; | 2033 | d->sortColumn = column; |
2035 | d->sortAscending = ascending; | 2034 | d->sortAscending = ascending; |
2036 | QListView::setSorting(column, ascending); | 2035 | QListView::setSorting(column, ascending); |
2037 | } | 2036 | } |
2038 | 2037 | ||
2039 | int KListView::columnSorted(void) const | 2038 | int KListView::columnSorted(void) const |
2040 | { | 2039 | { |
2041 | return d->sortColumn; | 2040 | return d->sortColumn; |
2042 | } | 2041 | } |
2043 | 2042 | ||
2044 | bool KListView::ascendingSort(void) const | 2043 | bool KListView::ascendingSort(void) const |
2045 | { | 2044 | { |
2046 | return d->sortAscending; | 2045 | return d->sortAscending; |
2047 | } | 2046 | } |
2048 | 2047 | ||
2049 | KListViewItem::KListViewItem(QListView *parent) | 2048 | KListViewItem::KListViewItem(QListView *parent) |
2050 | : QListViewItem(parent) | 2049 | : QListViewItem(parent) |
2051 | { | 2050 | { |
2052 | init(); | 2051 | init(); |
2053 | } | 2052 | } |
2054 | 2053 | ||
2055 | KListViewItem::KListViewItem(QListViewItem *parent) | 2054 | KListViewItem::KListViewItem(QListViewItem *parent) |
2056 | : QListViewItem(parent) | 2055 | : QListViewItem(parent) |
2057 | { | 2056 | { |
2058 | init(); | 2057 | init(); |
2059 | } | 2058 | } |
2060 | 2059 | ||
2061 | KListViewItem::KListViewItem(QListView *parent, QListViewItem *after) | 2060 | KListViewItem::KListViewItem(QListView *parent, QListViewItem *after) |
2062 | : QListViewItem(parent, after) | 2061 | : QListViewItem(parent, after) |
2063 | { | 2062 | { |
2064 | init(); | 2063 | init(); |
2065 | } | 2064 | } |
2066 | 2065 | ||
2067 | KListViewItem::KListViewItem(QListViewItem *parent, QListViewItem *after) | 2066 | KListViewItem::KListViewItem(QListViewItem *parent, QListViewItem *after) |
2068 | : QListViewItem(parent, after) | 2067 | : QListViewItem(parent, after) |
2069 | { | 2068 | { |
2070 | init(); | 2069 | init(); |
2071 | } | 2070 | } |
2072 | 2071 | ||
2073 | KListViewItem::KListViewItem(QListView *parent, | 2072 | KListViewItem::KListViewItem(QListView *parent, |
2074 | QString label1, QString label2, QString label3, QString label4, | 2073 | QString label1, QString label2, QString label3, QString label4, |
2075 | QString label5, QString label6, QString label7, QString label8) | 2074 | QString label5, QString label6, QString label7, QString label8) |
2076 | : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) | 2075 | : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) |
2077 | { | 2076 | { |
2078 | init(); | 2077 | init(); |
2079 | } | 2078 | } |
2080 | 2079 | ||
2081 | KListViewItem::KListViewItem(QListViewItem *parent, | 2080 | KListViewItem::KListViewItem(QListViewItem *parent, |
2082 | QString label1, QString label2, QString label3, QString label4, | 2081 | QString label1, QString label2, QString label3, QString label4, |
2083 | QString label5, QString label6, QString label7, QString label8) | 2082 | QString label5, QString label6, QString label7, QString label8) |
2084 | : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) | 2083 | : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) |
2085 | { | 2084 | { |
2086 | init(); | 2085 | init(); |
2087 | } | 2086 | } |
2088 | 2087 | ||
2089 | KListViewItem::KListViewItem(QListView *parent, QListViewItem *after, | 2088 | KListViewItem::KListViewItem(QListView *parent, QListViewItem *after, |
2090 | QString label1, QString label2, QString label3, QString label4, | 2089 | QString label1, QString label2, QString label3, QString label4, |
2091 | QString label5, QString label6, QString label7, QString label8) | 2090 | QString label5, QString label6, QString label7, QString label8) |
2092 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) | 2091 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) |
2093 | { | 2092 | { |
2094 | init(); | 2093 | init(); |
2095 | } | 2094 | } |
2096 | 2095 | ||
2097 | KListViewItem::KListViewItem(QListViewItem *parent, QListViewItem *after, | 2096 | KListViewItem::KListViewItem(QListViewItem *parent, QListViewItem *after, |
2098 | QString label1, QString label2, QString label3, QString label4, | 2097 | QString label1, QString label2, QString label3, QString label4, |
2099 | QString label5, QString label6, QString label7, QString label8) | 2098 | QString label5, QString label6, QString label7, QString label8) |
2100 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) | 2099 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) |
2101 | { | 2100 | { |
2102 | init(); | 2101 | init(); |
2103 | } | 2102 | } |
2104 | 2103 | ||
2105 | KListViewItem::~KListViewItem() | 2104 | KListViewItem::~KListViewItem() |
2106 | { | 2105 | { |
2107 | } | 2106 | } |
2108 | 2107 | ||
2109 | void KListViewItem::init() | 2108 | void KListViewItem::init() |
2110 | { | 2109 | { |
2111 | m_known = false; | 2110 | m_known = false; |
2112 | } | 2111 | } |
2113 | 2112 | ||
2114 | const QColor &KListViewItem::backgroundColor() | 2113 | const QColor &KListViewItem::backgroundColor() |
2115 | { | 2114 | { |
2116 | if (isAlternate()) | 2115 | if (isAlternate()) |
2117 | return static_cast< KListView* >(listView())->alternateBackground(); | 2116 | return static_cast< KListView* >(listView())->alternateBackground(); |
2118 | return listView()->viewport()->colorGroup().base(); | 2117 | return listView()->viewport()->colorGroup().base(); |
2119 | } | 2118 | } |
2120 | 2119 | ||
2121 | bool KListViewItem::isAlternate() | 2120 | bool KListViewItem::isAlternate() |
2122 | { | 2121 | { |
2123 | KListView *lv = static_cast<KListView *>(listView()); | 2122 | KListView *lv = static_cast<KListView *>(listView()); |
2124 | if (lv && lv->alternateBackground().isValid()) | 2123 | if (lv && lv->alternateBackground().isValid()) |
2125 | { | 2124 | { |
2126 | KListViewItem *above = 0; | 2125 | KListViewItem *above = 0; |
2127 | //US above = dynamic_cast<KListViewItem *>(itemAbove()); | 2126 | //US above = dynamic_cast<KListViewItem *>(itemAbove()); |
2128 | above = (KListViewItem *)(itemAbove()); | 2127 | above = (KListViewItem *)(itemAbove()); |
2129 | m_known = above ? above->m_known : true; | 2128 | m_known = above ? above->m_known : true; |
2130 | if (m_known) | 2129 | if (m_known) |
2131 | { | 2130 | { |
2132 | m_odd = above ? !above->m_odd : false; | 2131 | m_odd = above ? !above->m_odd : false; |
2133 | } | 2132 | } |
2134 | else | 2133 | else |
2135 | { | 2134 | { |
2136 | KListViewItem *item; | 2135 | KListViewItem *item; |
2137 | bool previous = true; | 2136 | bool previous = true; |
2138 | if (parent()) | 2137 | if (parent()) |
2139 | { | 2138 | { |
2140 | //US item = dynamic_cast<KListViewItem *>(parent()); | 2139 | //US item = dynamic_cast<KListViewItem *>(parent()); |
2141 | item = (KListViewItem *)(parent()); | 2140 | item = (KListViewItem *)(parent()); |
2142 | if (item) | 2141 | if (item) |
2143 | previous = item->m_odd; | 2142 | previous = item->m_odd; |
2144 | //US item = dynamic_cast<KListViewItem *>(parent()->firstChild()); | 2143 | //US item = dynamic_cast<KListViewItem *>(parent()->firstChild()); |
2145 | item = (KListViewItem *)(parent()->firstChild()); | 2144 | item = (KListViewItem *)(parent()->firstChild()); |
2146 | } | 2145 | } |
2147 | else | 2146 | else |
2148 | { | 2147 | { |
2149 | //US item = dynamic_cast<KListViewItem *>(lv->firstChild()); | 2148 | //US item = dynamic_cast<KListViewItem *>(lv->firstChild()); |
2150 | item = (KListViewItem *)(lv->firstChild()); | 2149 | item = (KListViewItem *)(lv->firstChild()); |
2151 | } | 2150 | } |
2152 | 2151 | ||
2153 | while(item) | 2152 | while(item) |
2154 | { | 2153 | { |
2155 | item->m_odd = previous = !previous; | 2154 | item->m_odd = previous = !previous; |
2156 | item->m_known = true; | 2155 | item->m_known = true; |
2157 | //US item = dynamic_cast<KListViewItem *>(item->nextSibling()); | 2156 | //US item = dynamic_cast<KListViewItem *>(item->nextSibling()); |
2158 | item = (KListViewItem *)(item->nextSibling()); | 2157 | item = (KListViewItem *)(item->nextSibling()); |
2159 | } | 2158 | } |
2160 | } | 2159 | } |
2161 | return m_odd; | 2160 | return m_odd; |
2162 | } | 2161 | } |
2163 | return false; | 2162 | return false; |
2164 | } | 2163 | } |
2165 | 2164 | ||
2166 | void KListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) | 2165 | void KListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) |
2167 | { | 2166 | { |
2168 | QColorGroup _cg = cg; | 2167 | QColorGroup _cg = cg; |
2169 | const QPixmap *pm = listView()->viewport()->backgroundPixmap(); | 2168 | const QPixmap *pm = listView()->viewport()->backgroundPixmap(); |
2170 | if (pm && !pm->isNull()) | 2169 | if (pm && !pm->isNull()) |
2171 | { | 2170 | { |
2172 | _cg.setBrush(QColorGroup::Base, QBrush(backgroundColor(), *pm)); | 2171 | _cg.setBrush(QColorGroup::Base, QBrush(backgroundColor(), *pm)); |
2173 | QPoint o = p->brushOrigin(); | 2172 | QPoint o = p->brushOrigin(); |
2174 | p->setBrushOrigin( o.x()-listView()->contentsX(), o.y()-listView()->contentsY() ); | 2173 | p->setBrushOrigin( o.x()-listView()->contentsX(), o.y()-listView()->contentsY() ); |
2175 | } | 2174 | } |
2176 | else if (isAlternate()) { | 2175 | else if (isAlternate()) { |
2177 | //US if (listView()->viewport()->backgroundMode()==Qt::FixedColor) | 2176 | //US if (listView()->viewport()->backgroundMode()==Qt::FixedColor) |
2178 | if (listView()->viewport()->backgroundMode()==QWidget::PaletteBackground) | 2177 | if (listView()->viewport()->backgroundMode()==QWidget::PaletteBackground) |
2179 | _cg.setColor(QColorGroup::Background, static_cast< KListView* >(listView())->alternateBackground()); | 2178 | _cg.setColor(QColorGroup::Background, static_cast< KListView* >(listView())->alternateBackground()); |
2180 | else | 2179 | else |
2181 | _cg.setColor(QColorGroup::Base, static_cast< KListView* >(listView())->alternateBackground()); | 2180 | _cg.setColor(QColorGroup::Base, static_cast< KListView* >(listView())->alternateBackground()); |
2182 | } | 2181 | } |
2183 | QListViewItem::paintCell(p, _cg, column, width, alignment); | 2182 | QListViewItem::paintCell(p, _cg, column, width, alignment); |
2184 | } | 2183 | } |
2185 | 2184 | ||
2186 | void KListView::virtual_hook( int, void* ) | 2185 | void KListView::virtual_hook( int, void* ) |
2187 | { /*BASE::virtual_hook( id, data );*/ } | 2186 | { /*BASE::virtual_hook( id, data );*/ } |
2188 | 2187 | ||
2189 | //US #include "klistview.moc" | 2188 | //US #include "klistview.moc" |
2190 | //US #include "klistviewlineedit.moc" | 2189 | //US #include "klistviewlineedit.moc" |
2191 | 2190 | ||
2192 | // vim: ts=2 sw=2 et | 2191 | // vim: ts=2 sw=2 et |
diff --git a/pwmanager/pwmanager/main.cpp b/pwmanager/pwmanager/main.cpp index 3f2d055..81e257f 100644 --- a/pwmanager/pwmanager/main.cpp +++ b/pwmanager/pwmanager/main.cpp | |||
@@ -1,213 +1,213 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * copyright (C) 2003, 2004 by Michael Buesch * | 3 | * copyright (C) 2003, 2004 by Michael Buesch * |
4 | * email: mbuesch@freenet.de * | 4 | * email: mbuesch@freenet.de * |
5 | * * | 5 | * * |
6 | * This program is free software; you can redistribute it and/or modify * | 6 | * This program is free software; you can redistribute it and/or modify * |
7 | * it under the terms of the GNU General Public License version 2 * | 7 | * it under the terms of the GNU General Public License version 2 * |
8 | * as published by the Free Software Foundation. * | 8 | * as published by the Free Software Foundation. * |
9 | * * | 9 | * * |
10 | ***************************************************************************/ | 10 | ***************************************************************************/ |
11 | 11 | ||
12 | /*************************************************************************** | 12 | /*************************************************************************** |
13 | * copyright (C) 2004 by Ulf Schenk | 13 | * copyright (C) 2004 by Ulf Schenk |
14 | * This file is originaly based on version 1.0.1 of pwmanager | 14 | * This file is originaly based on version 1.0.1 of pwmanager |
15 | * and was modified to run on embedded devices that run microkde | 15 | * and was modified to run on embedded devices that run microkde |
16 | * | 16 | * |
17 | * $Id$ | 17 | * $Id$ |
18 | **************************************************************************/ | 18 | **************************************************************************/ |
19 | 19 | ||
20 | #ifndef PWM_EMBEDDED | 20 | #ifndef PWM_EMBEDDED |
21 | #include <kcmdlineargs.h> | 21 | #include <kcmdlineargs.h> |
22 | #include <kaboutdata.h> | 22 | #include <kaboutdata.h> |
23 | #else | 23 | #else |
24 | #include <qdir.h> | 24 | #include <qdir.h> |
25 | #include <kpimglobalprefs.h> | 25 | #include <kpimglobalprefs.h> |
26 | #endif | 26 | #endif |
27 | 27 | ||
28 | #include <klocale.h> | 28 | #include <klocale.h> |
29 | #include <kstandarddirs.h> | 29 | #include <kstandarddirs.h> |
30 | 30 | ||
31 | #include "pwmexception.h" | 31 | #include "pwmexception.h" |
32 | #include "pwminit.h" | 32 | #include "pwminit.h" |
33 | 33 | ||
34 | #define LICENSE_FILE(::locate("data", "pwmanager/pwmanager_license_text")) | 34 | #define LICENSE_FILE(::locate("data", "pwmanager/pwmanager_license_text")) |
35 | 35 | ||
36 | int PwMApplication::newInstance() | 36 | int PwMApplication::newInstance() |
37 | { | 37 | { |
38 | static bool initial = true; | 38 | static bool initial = true; |
39 | if (initial) { | 39 | if (initial) { |
40 | initial = false; | 40 | initial = false; |
41 | init = new PwMInit(this); | 41 | init = new PwMInit(this); |
42 | init->initializeApp(); | 42 | init->initializeApp(); |
43 | } else { | 43 | } else { |
44 | BUG_ON(!init); | 44 | BUG_ON(!init); |
45 | printInfo("passing parameters to old instance."); | 45 | printInfo("passing parameters to old instance."); |
46 | init->handleCmdLineArgs(false); | 46 | init->handleCmdLineArgs(false); |
47 | } | 47 | } |
48 | return EXIT_SUCCESS; | 48 | return EXIT_SUCCESS; |
49 | } | 49 | } |
50 | 50 | ||
51 | 51 | ||
52 | static const char *description = I18N_NOOP("PwManager\n" | 52 | static const char *description = I18N_NOOP("PwManager\n" |
53 | "The convenient way of managing passwords"); | 53 | "The convenient way of managing passwords"); |
54 | 54 | ||
55 | #ifndef PWM_EMBEDDED | 55 | #ifndef PWM_EMBEDDED |
56 | static KCmdLineOptions options[] = | 56 | static KCmdLineOptions options[] = |
57 | { | 57 | { |
58 | { "minimized", I18N_NOOP("Windows minimized"), 0 }, | 58 | { "minimized", I18N_NOOP("Windows minimized"), 0 }, |
59 | { "mintray", I18N_NOOP("Windows minimized to tray"),0 }, | 59 | { "mintray", I18N_NOOP("Windows minimized to tray"),0 }, |
60 | { "open-deeplocked", I18N_NOOP("Open all \"files\" deeplocked"),0 }, | 60 | { "open-deeplocked", I18N_NOOP("Open all \"files\" deeplocked"),0 }, |
61 | { "skip-self-test", I18N_NOOP("Don't run a self-test on startup"),0 }, | 61 | { "skip-self-test", I18N_NOOP("Don't run a self-test on startup"),0 }, |
62 | { "+[files...]", I18N_NOOP("Files to open on startup"), 0 }, | 62 | { "+[files...]", I18N_NOOP("Files to open on startup"), 0 }, |
63 | { 0, 0, 0 } | 63 | { 0, 0, 0 } |
64 | }; | 64 | }; |
65 | #endif | 65 | #endif |
66 | 66 | ||
67 | #ifdef PWM_DEBUG | 67 | #ifdef PWM_DEBUG |
68 | static void printDebugConfigureInfo() | 68 | static void printDebugConfigureInfo() |
69 | { | 69 | { |
70 | cout << "================================" << endl; | 70 | cout << "================================" << endl; |
71 | cout << PROG_NAME " version " PACKAGE_VER << endl; | 71 | cout << PROG_NAME " version " PACKAGE_VER << endl; |
72 | #ifdef CONFIG_KEYCARD | 72 | #ifdef CONFIG_KEYCARD |
73 | cout << "CONFIG_KEYCARD: enabled" << endl; | 73 | cout << "CONFIG_KEYCARD: enabled" << endl; |
74 | #else | 74 | #else |
75 | cout << "CONFIG_KEYCARD: disabled" << endl; | 75 | cout << "CONFIG_KEYCARD: disabled" << endl; |
76 | #endif | 76 | #endif |
77 | #ifdef CONFIG_KWALLETIF | 77 | #ifdef CONFIG_KWALLETIF |
78 | cout << "CONFIG_KWALLETIF: enabled" << endl; | 78 | cout << "CONFIG_KWALLETIF: enabled" << endl; |
79 | #else | 79 | #else |
80 | cout << "CONFIG_KWALLETIF: disabled" << endl; | 80 | cout << "CONFIG_KWALLETIF: disabled" << endl; |
81 | #endif | 81 | #endif |
82 | #ifdef BIG_ENDIAN_HOST | 82 | #ifdef BIG_ENDIAN_HOST |
83 | cout << "Endianess: big-endian" << endl; | 83 | cout << "Endianess: big-endian" << endl; |
84 | #else | 84 | #else |
85 | cout << "Endianess: little-endian" << endl; | 85 | cout << "Endianess: little-endian" << endl; |
86 | #endif | 86 | #endif |
87 | cout << "sizeof(long): " << sizeof(long) << endl; | 87 | cout << "sizeof(long): " << sizeof(long) << endl; |
88 | cout << "================================" << endl; | 88 | cout << "================================" << endl; |
89 | } | 89 | } |
90 | #else // PWM_DEBUG | 90 | #else // PWM_DEBUG |
91 | static inline void printDebugConfigureInfo() { /* nothing */ } | 91 | static inline void printDebugConfigureInfo() { /* nothing */ } |
92 | #endif // PWM_DEBUG | 92 | #endif // PWM_DEBUG |
93 | 93 | ||
94 | #ifndef PWM_EMBEDDED | 94 | #ifndef PWM_EMBEDDED |
95 | static void addAuthors(KAboutData *aboutData) | 95 | static void addAuthors(KAboutData *aboutData) |
96 | { | 96 | { |
97 | aboutData->addAuthor("Michael Buesch", | 97 | aboutData->addAuthor("Michael Buesch", |
98 | I18N_NOOP( | 98 | I18N_NOOP( |
99 | "main programming and current maintainer"), | 99 | "main programming and current maintainer"), |
100 | "mbuesch@freenet.de"); | 100 | "mbuesch@freenet.de"); |
101 | aboutData->addAuthor("Matt Scifo", | 101 | aboutData->addAuthor("Matt Scifo", |
102 | I18N_NOOP( | 102 | I18N_NOOP( |
103 | "original implementaion of \n" | 103 | "original implementaion of \n" |
104 | "\"categories\" and the password-tree \n" | 104 | "\"categories\" and the password-tree \n" |
105 | "in the system-tray. Original implementations of \n" | 105 | "in the system-tray. Original implementations of \n" |
106 | "numerous view-improvements."), | 106 | "numerous view-improvements."), |
107 | "mscifo@o1.com"); | 107 | "mscifo@o1.com"); |
108 | aboutData->addCredit("Elias Probst", | 108 | aboutData->addCredit("Elias Probst", |
109 | I18N_NOOP( | 109 | I18N_NOOP( |
110 | "Gentoo ebuild maintainer."), | 110 | "Gentoo ebuild maintainer."), |
111 | "elias.probst@gmx.de"); | 111 | "elias.probst@gmx.de"); |
112 | aboutData->addCredit("George Staikos", | 112 | aboutData->addCredit("George Staikos", |
113 | I18N_NOOP("KWallet"), | 113 | I18N_NOOP("KWallet"), |
114 | "staikos@kde.org"); | 114 | "staikos@kde.org"); |
115 | aboutData->addCredit("Matthew Palmer", | 115 | aboutData->addCredit("Matthew Palmer", |
116 | I18N_NOOP("rc2 code"), | 116 | I18N_NOOP("rc2 code"), |
117 | "mjp16@uow.edu.au"); | 117 | "mjp16@uow.edu.au"); |
118 | aboutData->addCredit("Olivier Sessink", | 118 | aboutData->addCredit("Olivier Sessink", |
119 | I18N_NOOP("gpasman"), | 119 | I18N_NOOP("gpasman"), |
120 | "gpasman@nl.linux.org"); | 120 | "gpasman@nl.linux.org"); |
121 | aboutData->addCredit("The libgcrypt developers", | 121 | aboutData->addCredit("The libgcrypt developers", |
122 | I18N_NOOP("Blowfish and SHA1 algorithms"), | 122 | I18N_NOOP("Blowfish and SHA1 algorithms"), |
123 | 0, "ftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/"); | 123 | 0, "ftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/"); |
124 | aboutData->addCredit("Troy Engel", | 124 | aboutData->addCredit("Troy Engel", |
125 | I18N_NOOP("kpasman"), | 125 | I18N_NOOP("kpasman"), |
126 | "tengel@sonic.net"); | 126 | "tengel@sonic.net"); |
127 | aboutData->addCredit("Wickey", | 127 | aboutData->addCredit("Wickey", |
128 | I18N_NOOP("graphics-design in older versions."), | 128 | I18N_NOOP("graphics-design in older versions."), |
129 | "wickey@gmx.at"); | 129 | "wickey@gmx.at"); |
130 | aboutData->addCredit("Ian MacGregor", | 130 | aboutData->addCredit("Ian MacGregor", |
131 | I18N_NOOP( | 131 | I18N_NOOP( |
132 | "original documentation author.")); | 132 | "original documentation author.")); |
133 | } | 133 | } |
134 | #endif | 134 | #endif |
135 | 135 | ||
136 | int main(int argc, char *argv[]) | 136 | int main(int argc, char *argv[]) |
137 | { | 137 | { |
138 | printDebugConfigureInfo(); | 138 | printDebugConfigureInfo(); |
139 | #ifndef PWM_EMBEDDED | 139 | #ifndef PWM_EMBEDDED |
140 | KAboutData aboutData(PACKAGE_NAME, PROG_NAME, | 140 | KAboutData aboutData(PACKAGE_NAME, PROG_NAME, |
141 | PACKAGE_VER, description, KAboutData::License_File, | 141 | PACKAGE_VER, description, KAboutData::License_File, |
142 | "(c) 2003, 2004 Michael Buesch and the PwManager Team", 0, | 142 | "(c) 2003, 2004 Michael Buesch and the PwManager Team", 0, |
143 | "http://passwordmanager.sourceforge.net/", | 143 | "http://passwordmanager.sourceforge.net/", |
144 | "mbuesch@freenet.de"); | 144 | "mbuesch@freenet.de"); |
145 | addAuthors(&aboutData); | 145 | addAuthors(&aboutData); |
146 | 146 | ||
147 | KCmdLineArgs::init(argc, argv, &aboutData); | 147 | KCmdLineArgs::init(argc, argv, &aboutData); |
148 | KCmdLineArgs::addCmdLineOptions(options); | 148 | KCmdLineArgs::addCmdLineOptions(options); |
149 | 149 | ||
150 | KUniqueApplication::addCmdLineOptions(); | 150 | KUniqueApplication::addCmdLineOptions(); |
151 | if (!KUniqueApplication::start()) { | 151 | if (!KUniqueApplication::start()) { |
152 | printInfo("already running."); | 152 | printInfo("already running."); |
153 | return EXIT_SUCCESS; | 153 | return EXIT_SUCCESS; |
154 | } | 154 | } |
155 | PwMApplication a; | 155 | PwMApplication a; |
156 | aboutData.setLicenseTextFile(LICENSE_FILE); | 156 | aboutData.setLicenseTextFile(LICENSE_FILE); |
157 | return a.exec(); | 157 | return a.exec(); |
158 | #else | 158 | #else |
159 | 159 | ||
160 | bool exitHelp = false; | 160 | bool exitHelp = false; |
161 | if ( argc > 1 ) { | 161 | if ( argc > 1 ) { |
162 | QString command = argv[1]; | 162 | QString command = argv[1]; |
163 | if ( command == "-help" ){ | 163 | if ( command == "-help" ){ |
164 | printf("PWM/PI command line commands:\n"); | 164 | printf("PWM/PI command line commands:\n"); |
165 | printf(" no command: Start PWM/PI in usual way\n"); | 165 | printf(" no command: Start PWM/PI in usual way\n"); |
166 | printf(" -help: This output\n"); | 166 | printf(" -help: This output\n"); |
167 | printf(" PWM/PI is exiting now. Bye!\n"); | 167 | printf(" PWM/PI is exiting now. Bye!\n"); |
168 | exitHelp = true; | 168 | exitHelp = true; |
169 | } | 169 | } |
170 | } | 170 | } |
171 | if ( ! exitHelp ) { | 171 | if ( ! exitHelp ) { |
172 | 172 | ||
173 | PwMApplication a(argc, argv); | 173 | PwMApplication a(argc, argv); |
174 | 174 | ||
175 | KGlobal::setAppName( "pwmanager" ); | 175 | KGlobal::setAppName( "pwmanager" ); |
176 | #ifndef DESKTOP_VERSION | 176 | #ifndef DESKTOP_VERSION |
177 | //qDebug("width %d ",QApplication::desktop()->width() ); | 177 | //qDebug("width %d ",QApplication::desktop()->width() ); |
178 | if ( QApplication::desktop()->width() > 320 ) | 178 | if ( QApplication::desktop()->width() > 320 ) |
179 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons22/"); | 179 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons22/"); |
180 | else | 180 | else |
181 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons16/"); | 181 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons16/"); |
182 | #else | 182 | #else |
183 | QString fileName ; | 183 | QString fileName ; |
184 | fileName = qApp->applicationDirPath () + "/kdepim/pwmanager/icons22/"; | 184 | fileName = qApp->applicationDirPath () + "/kdepim/pwmanager/icons22/"; |
185 | KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); | 185 | KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); |
186 | QApplication::addLibraryPath ( qApp->applicationDirPath () ); | 186 | QApplication::addLibraryPath ( qApp->applicationDirPath () ); |
187 | 187 | ||
188 | #endif | 188 | #endif |
189 | KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "pwmanager"))); | 189 | KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "pwmanager"))); |
190 | KPimGlobalPrefs::instance()->setGlobalConfig(); | 190 | KPimGlobalPrefs::instance()->setGlobalConfig(); |
191 | 191 | ||
192 | a.newInstance(); | 192 | a.newInstance(); |
193 | 193 | ||
194 | //US KAddressBookMain m ; | 194 | //US KAddressBookMain m ; |
195 | 195 | ||
196 | //US QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 196 | //US QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
197 | /*US | 197 | /*US |
198 | #ifndef DESKTOP_VERSION | 198 | #ifndef DESKTOP_VERSION |
199 | a.showMainWidget( &m ); | 199 | a.showMainWidget( &m ); |
200 | #else | 200 | #else |
201 | a.setMainWidget( &m ); | 201 | a.setMainWidget( &m ); |
202 | m.resize (640, 480 ); | 202 | m.resize (640, 480 ); |
203 | m.show(); | 203 | m.show(); |
204 | #endif | 204 | #endif |
205 | */ | 205 | */ |
206 | a.exec(); | 206 | a.exec(); |
207 | 207 | KPimGlobalPrefs::instance()->writeConfig(); | |
208 | } | 208 | } |
209 | qDebug("PWMPI: Bye! "); | 209 | qDebug("PWMPI: Bye! "); |
210 | 210 | ||
211 | #endif | 211 | #endif |
212 | 212 | ||
213 | } | 213 | } |
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp index b7b5307..d92c90d 100644 --- a/pwmanager/pwmanager/pwm.cpp +++ b/pwmanager/pwmanager/pwm.cpp | |||
@@ -1,1463 +1,1465 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * copyright (C) 2003, 2004 by Michael Buesch * | 3 | * copyright (C) 2003, 2004 by Michael Buesch * |
4 | * email: mbuesch@freenet.de * | 4 | * email: mbuesch@freenet.de * |
5 | * * | 5 | * * |
6 | * This program is free software; you can redistribute it and/or modify * | 6 | * This program is free software; you can redistribute it and/or modify * |
7 | * it under the terms of the GNU General Public License version 2 * | 7 | * it under the terms of the GNU General Public License version 2 * |
8 | * as published by the Free Software Foundation. * | 8 | * as published by the Free Software Foundation. * |
9 | * * | 9 | * * |
10 | ***************************************************************************/ | 10 | ***************************************************************************/ |
11 | 11 | ||
12 | /*************************************************************************** | 12 | /*************************************************************************** |
13 | * copyright (C) 2004 by Ulf Schenk | 13 | * copyright (C) 2004 by Ulf Schenk |
14 | * This file is originaly based on version 1.0.1 of pwmanager | 14 | * This file is originaly based on version 1.0.1 of pwmanager |
15 | * and was modified to run on embedded devices that run microkde | 15 | * and was modified to run on embedded devices that run microkde |
16 | * | 16 | * |
17 | * $Id$ | 17 | * $Id$ |
18 | **************************************************************************/ | 18 | **************************************************************************/ |
19 | 19 | ||
20 | #include <klocale.h> | 20 | #include <klocale.h> |
21 | #include <klistview.h> | 21 | #include <klistview.h> |
22 | #include <ktoolbar.h> | 22 | #include <ktoolbar.h> |
23 | #include <kfiledialog.h> | 23 | #include <kfiledialog.h> |
24 | #include <kiconloader.h> | 24 | #include <kiconloader.h> |
25 | #include <kmessagebox.h> | 25 | #include <kmessagebox.h> |
26 | 26 | ||
27 | #include <qstatusbar.h> | 27 | #include <qstatusbar.h> |
28 | 28 | ||
29 | #ifndef PWM_EMBEDDED | 29 | #ifndef PWM_EMBEDDED |
30 | #include <kmenubar.h> | 30 | #include <kmenubar.h> |
31 | #include <kstatusbar.h> | 31 | #include <kstatusbar.h> |
32 | #include <dcopclient.h> | 32 | #include <dcopclient.h> |
33 | #include "configwndimpl.h" | 33 | #include "configwndimpl.h" |
34 | #include "configuration.h" | 34 | #include "configuration.h" |
35 | #else | 35 | #else |
36 | #include <qmenubar.h> | 36 | #include <qmenubar.h> |
37 | #include <qmessagebox.h> | 37 | #include <qmessagebox.h> |
38 | #include <pwmprefs.h> | 38 | #include <pwmprefs.h> |
39 | #include <kpimglobalprefs.h> | 39 | #include <kpimglobalprefs.h> |
40 | #include <kcmconfigs/kcmpwmconfig.h> | 40 | #include <kcmconfigs/kcmpwmconfig.h> |
41 | #include <kcmconfigs/kcmkdepimconfig.h> | 41 | #include <kcmconfigs/kcmkdepimconfig.h> |
42 | #include <kcmultidialog.h> | 42 | #include <kcmultidialog.h> |
43 | #endif | 43 | #endif |
44 | 44 | ||
45 | 45 | ||
46 | #ifndef DESKTOP_VERSION | 46 | #ifndef DESKTOP_VERSION |
47 | #include <qpe/global.h> | 47 | #include <qpe/global.h> |
48 | #endif | 48 | #endif |
49 | 49 | ||
50 | #include <qpixmap.h> | 50 | #include <qpixmap.h> |
51 | #include <qcheckbox.h> | 51 | #include <qcheckbox.h> |
52 | #include <qspinbox.h> | 52 | #include <qspinbox.h> |
53 | #include <qlineedit.h> | 53 | #include <qlineedit.h> |
54 | #include <qfileinfo.h> | 54 | #include <qfileinfo.h> |
55 | #include <qclipboard.h> | 55 | #include <qclipboard.h> |
56 | 56 | ||
57 | 57 | ||
58 | #include <stdio.h> | 58 | #include <stdio.h> |
59 | 59 | ||
60 | #include "pwm.h" | 60 | #include "pwm.h" |
61 | #include "pwminit.h" | 61 | #include "pwminit.h" |
62 | #include "pwmprint.h" | 62 | #include "pwmprint.h" |
63 | #include "addentrywndimpl.h" | 63 | #include "addentrywndimpl.h" |
64 | #include "globalstuff.h" | 64 | #include "globalstuff.h" |
65 | #include "findwndimpl.h" | 65 | #include "findwndimpl.h" |
66 | #include "csv.h" | 66 | #include "csv.h" |
67 | 67 | ||
68 | #ifdef CONFIG_KWALLETIF | 68 | #ifdef CONFIG_KWALLETIF |
69 | # include "kwalletif.h" | 69 | # include "kwalletif.h" |
70 | # include "kwalletemu.h" | 70 | # include "kwalletemu.h" |
71 | #endif | 71 | #endif |
72 | #ifdef CONFIG_KEYCARD | 72 | #ifdef CONFIG_KEYCARD |
73 | # include "pwmkeycard.h" | 73 | # include "pwmkeycard.h" |
74 | #endif | 74 | #endif |
75 | 75 | ||
76 | 76 | ||
77 | #define DEFAULT_SIZE (QSize(700, 400)) | 77 | #define DEFAULT_SIZE (QSize(700, 400)) |
78 | 78 | ||
79 | // Button IDs for "file" popup menu | 79 | // Button IDs for "file" popup menu |
80 | enum { | 80 | enum { |
81 | BUTTON_POPUP_FILE_NEW = 0, | 81 | BUTTON_POPUP_FILE_NEW = 0, |
82 | BUTTON_POPUP_FILE_OPEN, | 82 | BUTTON_POPUP_FILE_OPEN, |
83 | BUTTON_POPUP_FILE_CLOSE, | 83 | BUTTON_POPUP_FILE_CLOSE, |
84 | BUTTON_POPUP_FILE_SAVE, | 84 | BUTTON_POPUP_FILE_SAVE, |
85 | BUTTON_POPUP_FILE_SAVEAS, | 85 | BUTTON_POPUP_FILE_SAVEAS, |
86 | BUTTON_POPUP_FILE_EXPORT, | 86 | BUTTON_POPUP_FILE_EXPORT, |
87 | BUTTON_POPUP_FILE_IMPORT, | 87 | BUTTON_POPUP_FILE_IMPORT, |
88 | BUTTON_POPUP_FILE_PRINT, | 88 | BUTTON_POPUP_FILE_PRINT, |
89 | BUTTON_POPUP_FILE_QUIT | 89 | BUTTON_POPUP_FILE_QUIT |
90 | }; | 90 | }; |
91 | // Button IDs for "manage" popup menu | 91 | // Button IDs for "manage" popup menu |
92 | enum { | 92 | enum { |
93 | BUTTON_POPUP_MANAGE_ADD = 0, | 93 | BUTTON_POPUP_MANAGE_ADD = 0, |
94 | BUTTON_POPUP_MANAGE_EDIT, | 94 | BUTTON_POPUP_MANAGE_EDIT, |
95 | BUTTON_POPUP_MANAGE_DEL, | 95 | BUTTON_POPUP_MANAGE_DEL, |
96 | BUTTON_POPUP_MANAGE_CHANGEMP | 96 | BUTTON_POPUP_MANAGE_CHANGEMP |
97 | }; | 97 | }; |
98 | // Button IDs for chipcard popup menu | 98 | // Button IDs for chipcard popup menu |
99 | enum { | 99 | enum { |
100 | #ifdef CONFIG_KEYCARD | 100 | #ifdef CONFIG_KEYCARD |
101 | BUTTON_POPUP_CHIPCARD_GENNEW = 0, | 101 | BUTTON_POPUP_CHIPCARD_GENNEW = 0, |
102 | BUTTON_POPUP_CHIPCARD_DEL, | 102 | BUTTON_POPUP_CHIPCARD_DEL, |
103 | BUTTON_POPUP_CHIPCARD_READID, | 103 | BUTTON_POPUP_CHIPCARD_READID, |
104 | BUTTON_POPUP_CHIPCARD_SAVEBACKUP, | 104 | BUTTON_POPUP_CHIPCARD_SAVEBACKUP, |
105 | BUTTON_POPUP_CHIPCARD_REPLAYBACKUP | 105 | BUTTON_POPUP_CHIPCARD_REPLAYBACKUP |
106 | #else // CONFIG_KEYCARD | 106 | #else // CONFIG_KEYCARD |
107 | BUTTON_POPUP_CHIPCARD_NO = 0 | 107 | BUTTON_POPUP_CHIPCARD_NO = 0 |
108 | #endif // CONFIG_KEYCARD | 108 | #endif // CONFIG_KEYCARD |
109 | }; | 109 | }; |
110 | // Button IDs for "view" popup menu | 110 | // Button IDs for "view" popup menu |
111 | enum { | 111 | enum { |
112 | BUTTON_POPUP_VIEW_FIND = 0, | 112 | BUTTON_POPUP_VIEW_FIND = 0, |
113 | BUTTON_POPUP_VIEW_LOCK, | 113 | BUTTON_POPUP_VIEW_LOCK, |
114 | BUTTON_POPUP_VIEW_DEEPLOCK, | 114 | BUTTON_POPUP_VIEW_DEEPLOCK, |
115 | BUTTON_POPUP_VIEW_UNLOCK | 115 | BUTTON_POPUP_VIEW_UNLOCK |
116 | }; | 116 | }; |
117 | // Button IDs for "options" popup menu | 117 | // Button IDs for "options" popup menu |
118 | enum { | 118 | enum { |
119 | BUTTON_POPUP_OPTIONS_CONFIG = 0 | 119 | BUTTON_POPUP_OPTIONS_CONFIG = 0 |
120 | }; | 120 | }; |
121 | // Button IDs for "export" popup menu (in "file" popup menu) | 121 | // Button IDs for "export" popup menu (in "file" popup menu) |
122 | enum { | 122 | enum { |
123 | BUTTON_POPUP_EXPORT_TEXT = 0, | 123 | BUTTON_POPUP_EXPORT_TEXT = 0, |
124 | BUTTON_POPUP_EXPORT_GPASMAN, | 124 | BUTTON_POPUP_EXPORT_GPASMAN, |
125 | BUTTON_POPUP_EXPORT_CSV | 125 | BUTTON_POPUP_EXPORT_CSV |
126 | #ifdef CONFIG_KWALLETIF | 126 | #ifdef CONFIG_KWALLETIF |
127 | ,BUTTON_POPUP_EXPORT_KWALLET | 127 | ,BUTTON_POPUP_EXPORT_KWALLET |
128 | #endif | 128 | #endif |
129 | }; | 129 | }; |
130 | // Button IDs for "import" popup menu (in "file" popup menu) | 130 | // Button IDs for "import" popup menu (in "file" popup menu) |
131 | enum { | 131 | enum { |
132 | BUTTON_POPUP_IMPORT_TEXT = 0, | 132 | BUTTON_POPUP_IMPORT_TEXT = 0, |
133 | BUTTON_POPUP_IMPORT_GPASMAN, | 133 | BUTTON_POPUP_IMPORT_GPASMAN, |
134 | BUTTON_POPUP_IMPORT_CSV | 134 | BUTTON_POPUP_IMPORT_CSV |
135 | #ifdef CONFIG_KWALLETIF | 135 | #ifdef CONFIG_KWALLETIF |
136 | ,BUTTON_POPUP_IMPORT_KWALLET | 136 | ,BUTTON_POPUP_IMPORT_KWALLET |
137 | #endif | 137 | #endif |
138 | }; | 138 | }; |
139 | 139 | ||
140 | #ifdef PWM_EMBEDDED | 140 | #ifdef PWM_EMBEDDED |
141 | // Button IDs for "help" popup menu | 141 | // Button IDs for "help" popup menu |
142 | enum { | 142 | enum { |
143 | BUTTON_POPUP_HELP_LICENSE = 0, | 143 | BUTTON_POPUP_HELP_LICENSE = 0, |
144 | BUTTON_POPUP_HELP_FAQ, | 144 | BUTTON_POPUP_HELP_FAQ, |
145 | BUTTON_POPUP_HELP_ABOUT, | 145 | BUTTON_POPUP_HELP_ABOUT, |
146 | BUTTON_POPUP_HELP_SYNC, | 146 | BUTTON_POPUP_HELP_SYNC, |
147 | BUTTON_POPUP_HELP_WHATSNEW | 147 | BUTTON_POPUP_HELP_WHATSNEW |
148 | }; | 148 | }; |
149 | #endif | 149 | #endif |
150 | 150 | ||
151 | // Button IDs for toolbar | 151 | // Button IDs for toolbar |
152 | enum { | 152 | enum { |
153 | BUTTON_TOOL_NEW = 0, | 153 | BUTTON_TOOL_NEW = 0, |
154 | BUTTON_TOOL_OPEN, | 154 | BUTTON_TOOL_OPEN, |
155 | BUTTON_TOOL_SAVE, | 155 | BUTTON_TOOL_SAVE, |
156 | BUTTON_TOOL_SAVEAS, | 156 | BUTTON_TOOL_SAVEAS, |
157 | BUTTON_TOOL_PRINT, | 157 | BUTTON_TOOL_PRINT, |
158 | BUTTON_TOOL_ADD, | 158 | BUTTON_TOOL_ADD, |
159 | BUTTON_TOOL_EDIT, | 159 | BUTTON_TOOL_EDIT, |
160 | BUTTON_TOOL_DEL, | 160 | BUTTON_TOOL_DEL, |
161 | BUTTON_TOOL_FIND, | 161 | BUTTON_TOOL_FIND, |
162 | BUTTON_TOOL_LOCK, | 162 | BUTTON_TOOL_LOCK, |
163 | BUTTON_TOOL_DEEPLOCK, | 163 | BUTTON_TOOL_DEEPLOCK, |
164 | BUTTON_TOOL_UNLOCK | 164 | BUTTON_TOOL_UNLOCK |
165 | }; | 165 | }; |
166 | 166 | ||
167 | 167 | ||
168 | PwM::PwM(PwMInit *_init, PwMDoc *doc, | 168 | PwM::PwM(PwMInit *_init, PwMDoc *doc, |
169 | bool virginity, | 169 | bool virginity, |
170 | QWidget *parent, const char *name) | 170 | QWidget *parent, const char *name) |
171 | : KMainWindow(parent, "HALLO") | 171 | : KMainWindow(parent, "HALLO") |
172 | , forceQuit (false) | 172 | , forceQuit (false) |
173 | , forceMinimizeToTray (false) | 173 | , forceMinimizeToTray (false) |
174 | { | 174 | { |
175 | syncManager = 0; | ||
175 | virgin = !virginity; | 176 | virgin = !virginity; |
176 | init = _init; | 177 | init = _init; |
177 | connect(doc, SIGNAL(docClosed(PwMDoc *)), | 178 | connect(doc, SIGNAL(docClosed(PwMDoc *)), |
178 | this, SLOT(docClosed(PwMDoc *))); | 179 | this, SLOT(docClosed(PwMDoc *))); |
179 | initMenubar(); | 180 | initMenubar(); |
180 | initToolbar(); | 181 | initToolbar(); |
181 | initMetrics(); | 182 | initMetrics(); |
182 | setVirgin(virginity); | 183 | setVirgin(virginity); |
183 | setFocusPolicy(QWidget::WheelFocus); | 184 | setFocusPolicy(QWidget::WheelFocus); |
184 | #ifndef PWM_EMBEDDED | 185 | #ifndef PWM_EMBEDDED |
185 | statusBar()->show(); | 186 | statusBar()->show(); |
186 | #endif | 187 | #endif |
187 | view = makeNewListView(doc); | 188 | view = makeNewListView(doc); |
188 | setCentralWidget(view); | 189 | setCentralWidget(view); |
189 | updateCaption(); | 190 | updateCaption(); |
190 | showStatMsg(i18n("Ready.")); | 191 | showStatMsg(i18n("Ready.")); |
191 | } | 192 | } |
192 | 193 | ||
193 | PwM::~PwM() | 194 | PwM::~PwM() |
194 | { | 195 | { |
195 | //qDebug("PwM::~PwM()"); | 196 | //qDebug("PwM::~PwM()"); |
196 | disconnect(curDoc(), SIGNAL(docClosed(PwMDoc *)), | 197 | disconnect(curDoc(), SIGNAL(docClosed(PwMDoc *)), |
197 | this, SLOT(docClosed(PwMDoc *))); | 198 | this, SLOT(docClosed(PwMDoc *))); |
198 | conf()->confWndMainWndSize(size()); | 199 | conf()->confWndMainWndSize(size()); |
199 | emit closed(this); | 200 | emit closed(this); |
200 | //qDebug("PwM::~PwM() emited closed(this)"); | 201 | //qDebug("PwM::~PwM() emited closed(this)"); |
201 | delete view; | 202 | delete view; |
203 | delete syncManager; | ||
202 | } | 204 | } |
203 | 205 | ||
204 | void PwM::initMenubar() | 206 | void PwM::initMenubar() |
205 | { | 207 | { |
206 | KIconLoader* picons; | 208 | KIconLoader* picons; |
207 | #ifndef PWM_EMBEDDED | 209 | #ifndef PWM_EMBEDDED |
208 | KIconLoader icons; | 210 | KIconLoader icons; |
209 | picons = &icons; | 211 | picons = &icons; |
210 | #else | 212 | #else |
211 | picons = KGlobal::iconLoader(); | 213 | picons = KGlobal::iconLoader(); |
212 | 214 | ||
213 | 215 | ||
214 | syncPopup = new KPopupMenu(this); | 216 | syncPopup = new KPopupMenu(this); |
215 | 217 | ||
216 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::PWMPI, PWMPrefs::instance(), syncPopup); | 218 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::PWMPI, PWMPrefs::instance(), syncPopup); |
217 | syncManager->setBlockSave(false); | 219 | syncManager->setBlockSave(false); |
218 | 220 | ||
219 | connect ( syncPopup, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 221 | connect ( syncPopup, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
220 | syncManager->fillSyncMenu(); | 222 | syncManager->fillSyncMenu(); |
221 | 223 | ||
222 | #endif | 224 | #endif |
223 | filePopup = new KPopupMenu(this); | 225 | filePopup = new KPopupMenu(this); |
224 | importPopup = new KPopupMenu(filePopup); | 226 | importPopup = new KPopupMenu(filePopup); |
225 | exportPopup = new KPopupMenu(filePopup); | 227 | exportPopup = new KPopupMenu(filePopup); |
226 | managePopup = new KPopupMenu(this); | 228 | managePopup = new KPopupMenu(this); |
227 | #ifdef CONFIG_KEYCARD | 229 | #ifdef CONFIG_KEYCARD |
228 | chipcardPopup = new KPopupMenu(this); | 230 | chipcardPopup = new KPopupMenu(this); |
229 | #endif // CONFIG_KEYCARD | 231 | #endif // CONFIG_KEYCARD |
230 | viewPopup = new KPopupMenu(this); | 232 | viewPopup = new KPopupMenu(this); |
231 | optionsPopup = new KPopupMenu(this); | 233 | optionsPopup = new KPopupMenu(this); |
232 | 234 | ||
233 | // "file" popup menu | 235 | // "file" popup menu |
234 | filePopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), | 236 | filePopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), |
235 | i18n("&New"), this, | 237 | i18n("&New"), this, |
236 | SLOT(new_slot()), 0, BUTTON_POPUP_FILE_NEW); | 238 | SLOT(new_slot()), 0, BUTTON_POPUP_FILE_NEW); |
237 | filePopup->insertItem(QIconSet(picons->loadIcon("fileopen", KIcon::Small)), | 239 | filePopup->insertItem(QIconSet(picons->loadIcon("fileopen", KIcon::Small)), |
238 | i18n("&Open"), this, | 240 | i18n("&Open"), this, |
239 | SLOT(open_slot()), 0, BUTTON_POPUP_FILE_OPEN); | 241 | SLOT(open_slot()), 0, BUTTON_POPUP_FILE_OPEN); |
240 | filePopup->insertItem(QIconSet(picons->loadIcon("fileclose", KIcon::Small)), | 242 | filePopup->insertItem(QIconSet(picons->loadIcon("fileclose", KIcon::Small)), |
241 | i18n("&Close"), this, | 243 | i18n("&Close"), this, |
242 | SLOT(close_slot()), 0, BUTTON_POPUP_FILE_CLOSE); | 244 | SLOT(close_slot()), 0, BUTTON_POPUP_FILE_CLOSE); |
243 | filePopup->insertSeparator(); | 245 | filePopup->insertSeparator(); |
244 | filePopup->insertItem(QIconSet(picons->loadIcon("filesave", KIcon::Small)), | 246 | filePopup->insertItem(QIconSet(picons->loadIcon("filesave", KIcon::Small)), |
245 | i18n("&Save"), this, | 247 | i18n("&Save"), this, |
246 | SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE); | 248 | SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE); |
247 | filePopup->insertItem(QIconSet(picons->loadIcon("filesaveas", KIcon::Small)), | 249 | filePopup->insertItem(QIconSet(picons->loadIcon("filesaveas", KIcon::Small)), |
248 | i18n("Save &as..."), | 250 | i18n("Save &as..."), |
249 | this, SLOT(saveAs_slot()), 0, | 251 | this, SLOT(saveAs_slot()), 0, |
250 | BUTTON_POPUP_FILE_SAVEAS); | 252 | BUTTON_POPUP_FILE_SAVEAS); |
251 | filePopup->insertSeparator(); | 253 | filePopup->insertSeparator(); |
252 | // "file/export" popup menu | 254 | // "file/export" popup menu |
253 | exportPopup->insertItem(i18n("&Text-file..."), this, | 255 | exportPopup->insertItem(i18n("&Text-file..."), this, |
254 | SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT); | 256 | SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT); |
255 | exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, | 257 | exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, |
256 | SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN); | 258 | SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN); |
257 | exportPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this, | 259 | exportPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this, |
258 | SLOT(exportToCsv()), 0, BUTTON_POPUP_EXPORT_CSV); | 260 | SLOT(exportToCsv()), 0, BUTTON_POPUP_EXPORT_CSV); |
259 | #ifdef CONFIG_KWALLETIF | 261 | #ifdef CONFIG_KWALLETIF |
260 | exportPopup->insertItem(i18n("&KWallet..."), this, | 262 | exportPopup->insertItem(i18n("&KWallet..."), this, |
261 | SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET); | 263 | SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET); |
262 | #endif | 264 | #endif |
263 | filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)), | 265 | filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)), |
264 | i18n("E&xport"), exportPopup, | 266 | i18n("E&xport"), exportPopup, |
265 | BUTTON_POPUP_FILE_EXPORT); | 267 | BUTTON_POPUP_FILE_EXPORT); |
266 | // "file/import" popup menu | 268 | // "file/import" popup menu |
267 | importPopup->insertItem(i18n("&Text-file..."), this, | 269 | importPopup->insertItem(i18n("&Text-file..."), this, |
268 | SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT); | 270 | SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT); |
269 | importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, | 271 | importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, |
270 | SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN); | 272 | SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN); |
271 | importPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this, | 273 | importPopup->insertItem(i18n("&CSV (Comma Separated Value) ..."), this, |
272 | SLOT(importCsv()), 0, BUTTON_POPUP_IMPORT_CSV); | 274 | SLOT(importCsv()), 0, BUTTON_POPUP_IMPORT_CSV); |
273 | #ifdef CONFIG_KWALLETIF | 275 | #ifdef CONFIG_KWALLETIF |
274 | importPopup->insertItem(i18n("&KWallet..."), this, | 276 | importPopup->insertItem(i18n("&KWallet..."), this, |
275 | SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET); | 277 | SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET); |
276 | #endif | 278 | #endif |
277 | filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)), | 279 | filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)), |
278 | i18n("I&mport"), importPopup, | 280 | i18n("I&mport"), importPopup, |
279 | BUTTON_POPUP_FILE_IMPORT); | 281 | BUTTON_POPUP_FILE_IMPORT); |
280 | filePopup->insertSeparator(); | 282 | filePopup->insertSeparator(); |
281 | filePopup->insertItem(QIconSet(picons->loadIcon("fileprint", KIcon::Small)), | 283 | filePopup->insertItem(QIconSet(picons->loadIcon("fileprint", KIcon::Small)), |
282 | i18n("&Print..."), this, | 284 | i18n("&Print..."), this, |
283 | SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT); | 285 | SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT); |
284 | filePopup->insertSeparator(); | 286 | filePopup->insertSeparator(); |
285 | filePopup->insertItem(QIconSet(picons->loadIcon("exit", KIcon::Small)), | 287 | filePopup->insertItem(QIconSet(picons->loadIcon("exit", KIcon::Small)), |
286 | i18n("&Quit"), this, | 288 | i18n("&Quit"), this, |
287 | SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT); | 289 | SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT); |
288 | menuBar()->insertItem(i18n("&File"), filePopup); | 290 | menuBar()->insertItem(i18n("&File"), filePopup); |
289 | // "manage" popup menu | 291 | // "manage" popup menu |
290 | managePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)), | 292 | managePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)), |
291 | i18n("&Add password"), this, | 293 | i18n("&Add password"), this, |
292 | SLOT(addPwd_slot()), 0, | 294 | SLOT(addPwd_slot()), 0, |
293 | BUTTON_POPUP_MANAGE_ADD); | 295 | BUTTON_POPUP_MANAGE_ADD); |
294 | managePopup->insertItem(QIconSet(picons->loadIcon("edit", KIcon::Small)), | 296 | managePopup->insertItem(QIconSet(picons->loadIcon("edit", KIcon::Small)), |
295 | i18n("&Edit"), this, SLOT(editPwd_slot()), 0, | 297 | i18n("&Edit"), this, SLOT(editPwd_slot()), 0, |
296 | BUTTON_POPUP_MANAGE_EDIT); | 298 | BUTTON_POPUP_MANAGE_EDIT); |
297 | managePopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), | 299 | managePopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), |
298 | i18n("&Delete"), this, SLOT(deletePwd_slot()), | 300 | i18n("&Delete"), this, SLOT(deletePwd_slot()), |
299 | 0, BUTTON_POPUP_MANAGE_DEL); | 301 | 0, BUTTON_POPUP_MANAGE_DEL); |
300 | managePopup->insertSeparator(); | 302 | managePopup->insertSeparator(); |
301 | managePopup->insertItem(QIconSet(picons->loadIcon("rotate", KIcon::Small)), | 303 | managePopup->insertItem(QIconSet(picons->loadIcon("rotate", KIcon::Small)), |
302 | i18n("Change &Master Password"), this, | 304 | i18n("Change &Master Password"), this, |
303 | SLOT(changeMasterPwd_slot()), 0, | 305 | SLOT(changeMasterPwd_slot()), 0, |
304 | BUTTON_POPUP_MANAGE_CHANGEMP); | 306 | BUTTON_POPUP_MANAGE_CHANGEMP); |
305 | menuBar()->insertItem(i18n("&Manage"), managePopup); | 307 | menuBar()->insertItem(i18n("&Manage"), managePopup); |
306 | // "chipcard" popup menu | 308 | // "chipcard" popup menu |
307 | #ifdef CONFIG_KEYCARD | 309 | #ifdef CONFIG_KEYCARD |
308 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), | 310 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), |
309 | i18n("&Generate new key-card"), this, | 311 | i18n("&Generate new key-card"), this, |
310 | SLOT(genNewCard_slot()), 0, | 312 | SLOT(genNewCard_slot()), 0, |
311 | BUTTON_POPUP_CHIPCARD_GENNEW); | 313 | BUTTON_POPUP_CHIPCARD_GENNEW); |
312 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), | 314 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), |
313 | i18n("&Erase key-card"), this, | 315 | i18n("&Erase key-card"), this, |
314 | SLOT(eraseCard_slot()), 0, | 316 | SLOT(eraseCard_slot()), 0, |
315 | BUTTON_POPUP_CHIPCARD_DEL); | 317 | BUTTON_POPUP_CHIPCARD_DEL); |
316 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("", KIcon::Small)), | 318 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("", KIcon::Small)), |
317 | i18n("Read card-&ID"), this, | 319 | i18n("Read card-&ID"), this, |
318 | SLOT(readCardId_slot()), 0, | 320 | SLOT(readCardId_slot()), 0, |
319 | BUTTON_POPUP_CHIPCARD_READID); | 321 | BUTTON_POPUP_CHIPCARD_READID); |
320 | chipcardPopup->insertSeparator(); | 322 | chipcardPopup->insertSeparator(); |
321 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("2rightarrow", KIcon::Small)), | 323 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("2rightarrow", KIcon::Small)), |
322 | i18n("&Make card backup-image"), this, | 324 | i18n("&Make card backup-image"), this, |
323 | SLOT(makeCardBackup_slot()), 0, | 325 | SLOT(makeCardBackup_slot()), 0, |
324 | BUTTON_POPUP_CHIPCARD_SAVEBACKUP); | 326 | BUTTON_POPUP_CHIPCARD_SAVEBACKUP); |
325 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("2leftarrow", KIcon::Small)), | 327 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("2leftarrow", KIcon::Small)), |
326 | i18n("&Replay card backup-image"), this, | 328 | i18n("&Replay card backup-image"), this, |
327 | SLOT(replayCardBackup_slot()), 0, | 329 | SLOT(replayCardBackup_slot()), 0, |
328 | BUTTON_POPUP_CHIPCARD_REPLAYBACKUP); | 330 | BUTTON_POPUP_CHIPCARD_REPLAYBACKUP); |
329 | menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup); | 331 | menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup); |
330 | #endif // CONFIG_KEYCARD | 332 | #endif // CONFIG_KEYCARD |
331 | // "view" popup menu | 333 | // "view" popup menu |
332 | viewPopup->insertItem(QIconSet(picons->loadIcon("find", KIcon::Small)), | 334 | viewPopup->insertItem(QIconSet(picons->loadIcon("find", KIcon::Small)), |
333 | i18n("&Find"), this, | 335 | i18n("&Find"), this, |
334 | SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND); | 336 | SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND); |
335 | viewPopup->insertSeparator(); | 337 | viewPopup->insertSeparator(); |
336 | viewPopup->insertItem(QIconSet(picons->loadIcon("halfencrypted", KIcon::Small)), | 338 | viewPopup->insertItem(QIconSet(picons->loadIcon("halfencrypted", KIcon::Small)), |
337 | i18n("&Lock all entries"), this, | 339 | i18n("&Lock all entries"), this, |
338 | SLOT(lockWnd_slot()), 0, | 340 | SLOT(lockWnd_slot()), 0, |
339 | BUTTON_POPUP_VIEW_LOCK); | 341 | BUTTON_POPUP_VIEW_LOCK); |
340 | viewPopup->insertItem(QIconSet(picons->loadIcon("encrypted", KIcon::Small)), | 342 | viewPopup->insertItem(QIconSet(picons->loadIcon("encrypted", KIcon::Small)), |
341 | i18n("&Deep-lock all entries"), this, | 343 | i18n("&Deep-lock all entries"), this, |
342 | SLOT(deepLockWnd_slot()), 0, | 344 | SLOT(deepLockWnd_slot()), 0, |
343 | BUTTON_POPUP_VIEW_DEEPLOCK); | 345 | BUTTON_POPUP_VIEW_DEEPLOCK); |
344 | viewPopup->insertItem(QIconSet(picons->loadIcon("decrypted", KIcon::Small)), | 346 | viewPopup->insertItem(QIconSet(picons->loadIcon("decrypted", KIcon::Small)), |
345 | i18n("&Unlock all entries"), this, | 347 | i18n("&Unlock all entries"), this, |
346 | SLOT(unlockWnd_slot()), 0, | 348 | SLOT(unlockWnd_slot()), 0, |
347 | BUTTON_POPUP_VIEW_UNLOCK); | 349 | BUTTON_POPUP_VIEW_UNLOCK); |
348 | menuBar()->insertItem(i18n("&View"), viewPopup); | 350 | menuBar()->insertItem(i18n("&View"), viewPopup); |
349 | // "options" popup menu | 351 | // "options" popup menu |
350 | optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)), | 352 | optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)), |
351 | i18n("&Configure..."), this, | 353 | i18n("&Configure..."), this, |
352 | SLOT(config_slot()), | 354 | SLOT(config_slot()), |
353 | BUTTON_POPUP_OPTIONS_CONFIG); | 355 | BUTTON_POPUP_OPTIONS_CONFIG); |
354 | menuBar()->insertItem(i18n("&Options"), optionsPopup); | 356 | menuBar()->insertItem(i18n("&Options"), optionsPopup); |
355 | // "help" popup menu | 357 | // "help" popup menu |
356 | #ifndef PWM_EMBEDDED | 358 | #ifndef PWM_EMBEDDED |
357 | helpPopup = helpMenu(QString::null, false); | 359 | helpPopup = helpMenu(QString::null, false); |
358 | #else | 360 | #else |
359 | menuBar()->insertItem(i18n("&Sync"), syncPopup); | 361 | menuBar()->insertItem(i18n("&Sync"), syncPopup); |
360 | 362 | ||
361 | 363 | ||
362 | 364 | ||
363 | 365 | ||
364 | 366 | ||
365 | helpPopup = new KPopupMenu(this); | 367 | helpPopup = new KPopupMenu(this); |
366 | 368 | ||
367 | 369 | ||
368 | helpPopup->insertItem(i18n("&License"), this, | 370 | helpPopup->insertItem(i18n("&License"), this, |
369 | SLOT(showLicense_slot()), 0, | 371 | SLOT(showLicense_slot()), 0, |
370 | BUTTON_POPUP_HELP_LICENSE); | 372 | BUTTON_POPUP_HELP_LICENSE); |
371 | 373 | ||
372 | helpPopup->insertItem(i18n("&Faq"), this, | 374 | helpPopup->insertItem(i18n("&Faq"), this, |
373 | SLOT(faq_slot()), 0, | 375 | SLOT(faq_slot()), 0, |
374 | BUTTON_POPUP_HELP_FAQ); | 376 | BUTTON_POPUP_HELP_FAQ); |
375 | 377 | ||
376 | helpPopup->insertItem(i18n("&About PwManager"), this, | 378 | helpPopup->insertItem(i18n("&About PwManager"), this, |
377 | SLOT(createAboutData_slot()), 0, | 379 | SLOT(createAboutData_slot()), 0, |
378 | BUTTON_POPUP_HELP_ABOUT); | 380 | BUTTON_POPUP_HELP_ABOUT); |
379 | 381 | ||
380 | helpPopup->insertItem(i18n("&Sync HowTo"), this, | 382 | helpPopup->insertItem(i18n("&Sync HowTo"), this, |
381 | SLOT(syncHowTo_slot()), 0, | 383 | SLOT(syncHowTo_slot()), 0, |
382 | BUTTON_POPUP_HELP_SYNC); | 384 | BUTTON_POPUP_HELP_SYNC); |
383 | 385 | ||
384 | helpPopup->insertItem(i18n("&What's New"), this, | 386 | helpPopup->insertItem(i18n("&What's New"), this, |
385 | SLOT(whatsnew_slot()), 0, | 387 | SLOT(whatsnew_slot()), 0, |
386 | BUTTON_POPUP_HELP_WHATSNEW); | 388 | BUTTON_POPUP_HELP_WHATSNEW); |
387 | 389 | ||
388 | #endif | 390 | #endif |
389 | menuBar()->insertItem(i18n("&Help"), helpPopup); | 391 | menuBar()->insertItem(i18n("&Help"), helpPopup); |
390 | 392 | ||
391 | } | 393 | } |
392 | 394 | ||
393 | void PwM::initToolbar() | 395 | void PwM::initToolbar() |
394 | { | 396 | { |
395 | KIconLoader* picons; | 397 | KIconLoader* picons; |
396 | #ifndef PWM_EMBEDDED | 398 | #ifndef PWM_EMBEDDED |
397 | KIconLoader icons; | 399 | KIconLoader icons; |
398 | picons = &icons; | 400 | picons = &icons; |
399 | #else | 401 | #else |
400 | picons = KGlobal::iconLoader(); | 402 | picons = KGlobal::iconLoader(); |
401 | #endif | 403 | #endif |
402 | 404 | ||
403 | #ifdef PWM_EMBEDDED | 405 | #ifdef PWM_EMBEDDED |
404 | if ( QApplication::desktop()->width() > 320 ) | 406 | if ( QApplication::desktop()->width() > 320 ) |
405 | #endif | 407 | #endif |
406 | { | 408 | { |
407 | toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar), | 409 | toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar), |
408 | BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this, | 410 | BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this, |
409 | SLOT(new_slot()), true, i18n("New")); | 411 | SLOT(new_slot()), true, i18n("New")); |
410 | toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar), | 412 | toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar), |
411 | BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this, | 413 | BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this, |
412 | SLOT(open_slot()), true, i18n("Open")); | 414 | SLOT(open_slot()), true, i18n("Open")); |
413 | toolBar()->insertSeparator(); | 415 | toolBar()->insertSeparator(); |
414 | } | 416 | } |
415 | toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar), | 417 | toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar), |
416 | BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this, | 418 | BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this, |
417 | SLOT(save_slot()), true, i18n("Save")); | 419 | SLOT(save_slot()), true, i18n("Save")); |
418 | toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar), | 420 | toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar), |
419 | BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this, | 421 | BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this, |
420 | SLOT(saveAs_slot()), true, i18n("Save as")); | 422 | SLOT(saveAs_slot()), true, i18n("Save as")); |
421 | toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar), | 423 | toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar), |
422 | BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this, | 424 | BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this, |
423 | SLOT(print_slot()), true, i18n("Print...")); | 425 | SLOT(print_slot()), true, i18n("Print...")); |
424 | toolBar()->insertSeparator(); | 426 | toolBar()->insertSeparator(); |
425 | toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar), | 427 | toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar), |
426 | BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this, | 428 | BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this, |
427 | SLOT(addPwd_slot()), true, | 429 | SLOT(addPwd_slot()), true, |
428 | i18n("Add password")); | 430 | i18n("Add password")); |
429 | toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar), | 431 | toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar), |
430 | BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this, | 432 | BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this, |
431 | SLOT(editPwd_slot()), true, | 433 | SLOT(editPwd_slot()), true, |
432 | i18n("Edit password")); | 434 | i18n("Edit password")); |
433 | toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar), | 435 | toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar), |
434 | BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this, | 436 | BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this, |
435 | SLOT(deletePwd_slot()), true, | 437 | SLOT(deletePwd_slot()), true, |
436 | i18n("Delete password")); | 438 | i18n("Delete password")); |
437 | toolBar()->insertSeparator(); | 439 | toolBar()->insertSeparator(); |
438 | toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar), | 440 | toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar), |
439 | BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this, | 441 | BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this, |
440 | SLOT(find_slot()), true, i18n("Find entry")); | 442 | SLOT(find_slot()), true, i18n("Find entry")); |
441 | toolBar()->insertSeparator(); | 443 | toolBar()->insertSeparator(); |
442 | toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar), | 444 | toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar), |
443 | BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this, | 445 | BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this, |
444 | SLOT(lockWnd_slot()), true, | 446 | SLOT(lockWnd_slot()), true, |
445 | i18n("Lock all entries")); | 447 | i18n("Lock all entries")); |
446 | toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar), | 448 | toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar), |
447 | BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this, | 449 | BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this, |
448 | SLOT(deepLockWnd_slot()), true, | 450 | SLOT(deepLockWnd_slot()), true, |
449 | i18n("Deep-Lock all entries")); | 451 | i18n("Deep-Lock all entries")); |
450 | toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar), | 452 | toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar), |
451 | BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this, | 453 | BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this, |
452 | SLOT(unlockWnd_slot()), true, | 454 | SLOT(unlockWnd_slot()), true, |
453 | i18n("Unlock all entries")); | 455 | i18n("Unlock all entries")); |
454 | } | 456 | } |
455 | 457 | ||
456 | void PwM::initMetrics() | 458 | void PwM::initMetrics() |
457 | { | 459 | { |
458 | QSize s = conf()->confWndMainWndSize(); | 460 | QSize s = conf()->confWndMainWndSize(); |
459 | if (s.isValid()) | 461 | if (s.isValid()) |
460 | resize(s); | 462 | resize(s); |
461 | else | 463 | else |
462 | resize(DEFAULT_SIZE); | 464 | resize(DEFAULT_SIZE); |
463 | } | 465 | } |
464 | 466 | ||
465 | void PwM::updateCaption() | 467 | void PwM::updateCaption() |
466 | { | 468 | { |
467 | setPlainCaption(curDoc()->getTitle() + " - " PROG_NAME " " PACKAGE_VER); | 469 | setPlainCaption(curDoc()->getTitle() + " - " PROG_NAME " " PACKAGE_VER); |
468 | } | 470 | } |
469 | 471 | ||
470 | void PwM::hideEvent(QHideEvent *) | 472 | void PwM::hideEvent(QHideEvent *) |
471 | { | 473 | { |
472 | if (isMinimized()) { | 474 | if (isMinimized()) { |
473 | if (init->tray()) { | 475 | if (init->tray()) { |
474 | forceMinimizeToTray = true; | 476 | forceMinimizeToTray = true; |
475 | close(); | 477 | close(); |
476 | } | 478 | } |
477 | int mmlock = conf()->confGlobMinimizeLock(); | 479 | int mmlock = conf()->confGlobMinimizeLock(); |
478 | switch (mmlock) { | 480 | switch (mmlock) { |
479 | case 0: // don't lock anything | 481 | case 0: // don't lock anything |
480 | break; | 482 | break; |
481 | case 1: {// normal lock | 483 | case 1: {// normal lock |
482 | curDoc()->lockAll(true); | 484 | curDoc()->lockAll(true); |
483 | break; | 485 | break; |
484 | } case 2: {// deep-lock | 486 | } case 2: {// deep-lock |
485 | curDoc()->deepLock(); | 487 | curDoc()->deepLock(); |
486 | break; | 488 | break; |
487 | } default: | 489 | } default: |
488 | WARN(); | 490 | WARN(); |
489 | } | 491 | } |
490 | } | 492 | } |
491 | } | 493 | } |
492 | 494 | ||
493 | void PwM::setVirgin(bool v) | 495 | void PwM::setVirgin(bool v) |
494 | { | 496 | { |
495 | if (virgin == v) | 497 | if (virgin == v) |
496 | return; | 498 | return; |
497 | virgin = v; | 499 | virgin = v; |
498 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVE, !v); | 500 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVE, !v); |
499 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVEAS, !v); | 501 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVEAS, !v); |
500 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_EXPORT, !v); | 502 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_EXPORT, !v); |
501 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_PRINT, !v); | 503 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_PRINT, !v); |
502 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_EDIT, !v); | 504 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_EDIT, !v); |
503 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_DEL, !v); | 505 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_DEL, !v); |
504 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, !v); | 506 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, !v); |
505 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_LOCK, !v); | 507 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_LOCK, !v); |
506 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_DEEPLOCK, !v); | 508 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_DEEPLOCK, !v); |
507 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_UNLOCK, !v); | 509 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_UNLOCK, !v); |
508 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_FIND, !v); | 510 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_FIND, !v); |
509 | toolBar()->setItemEnabled(BUTTON_TOOL_SAVE, !v); | 511 | toolBar()->setItemEnabled(BUTTON_TOOL_SAVE, !v); |
510 | toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v); | 512 | toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v); |
511 | toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v); | 513 | toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v); |
512 | toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v); | 514 | toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v); |
513 | toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v); | 515 | toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v); |
514 | toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v); | 516 | toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v); |
515 | toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v); | 517 | toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v); |
516 | toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v); | 518 | toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v); |
517 | toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v); | 519 | toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v); |
518 | } | 520 | } |
519 | 521 | ||
520 | void PwM::new_slot() | 522 | void PwM::new_slot() |
521 | { | 523 | { |
522 | init->createMainWnd(); | 524 | init->createMainWnd(); |
523 | } | 525 | } |
524 | 526 | ||
525 | //US ENH | 527 | //US ENH |
526 | void PwM::open_slot() | 528 | void PwM::open_slot() |
527 | { | 529 | { |
528 | open_slot(""); | 530 | open_slot(""); |
529 | } | 531 | } |
530 | 532 | ||
531 | void PwM::open_slot(QString fn) | 533 | void PwM::open_slot(QString fn) |
532 | { | 534 | { |
533 | openDoc(fn); | 535 | openDoc(fn); |
534 | } | 536 | } |
535 | 537 | ||
536 | PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked) | 538 | PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked) |
537 | { | 539 | { |
538 | if (!isVirgin()) { | 540 | if (!isVirgin()) { |
539 | // open the document in a new window. | 541 | // open the document in a new window. |
540 | PwM *newInstance = init->createMainWnd(); | 542 | PwM *newInstance = init->createMainWnd(); |
541 | PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked); | 543 | PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked); |
542 | if (!newDoc) { | 544 | if (!newDoc) { |
543 | newInstance->setForceQuit(true); | 545 | newInstance->setForceQuit(true); |
544 | delete_and_null(newInstance); | 546 | delete_and_null(newInstance); |
545 | } | 547 | } |
546 | return newDoc; | 548 | return newDoc; |
547 | } | 549 | } |
548 | 550 | ||
549 | if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked)) | 551 | if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked)) |
550 | return 0; | 552 | return 0; |
551 | showStatMsg(i18n("Successfully opened file.")); | 553 | showStatMsg(i18n("Successfully opened file.")); |
552 | updateCaption(); | 554 | updateCaption(); |
553 | setVirgin(false); | 555 | setVirgin(false); |
554 | return curDoc(); | 556 | return curDoc(); |
555 | } | 557 | } |
556 | 558 | ||
557 | PwMView * PwM::makeNewListView(PwMDoc *doc) | 559 | PwMView * PwM::makeNewListView(PwMDoc *doc) |
558 | { | 560 | { |
559 | PwMView *ret = new PwMView(this, this, doc); | 561 | PwMView *ret = new PwMView(this, this, doc); |
560 | ret->setFont(conf()->confGlobEntryFont()); | 562 | ret->setFont(conf()->confGlobEntryFont()); |
561 | ret->show(); | 563 | ret->show(); |
562 | return ret; | 564 | return ret; |
563 | } | 565 | } |
564 | 566 | ||
565 | void PwM::close_slot() | 567 | void PwM::close_slot() |
566 | { | 568 | { |
567 | close(); | 569 | close(); |
568 | } | 570 | } |
569 | 571 | ||
570 | void PwM::quitButton_slot() | 572 | void PwM::quitButton_slot() |
571 | { | 573 | { |
572 | init->shutdownApp(0); | 574 | init->shutdownApp(0); |
573 | } | 575 | } |
574 | 576 | ||
575 | void PwM::save_slot() | 577 | void PwM::save_slot() |
576 | { | 578 | { |
577 | save(); | 579 | save(); |
578 | } | 580 | } |
579 | 581 | ||
580 | bool PwM::save() | 582 | bool PwM::save() |
581 | { | 583 | { |
582 | if (!curDoc()->saveDocUi(curDoc())) | 584 | if (!curDoc()->saveDocUi(curDoc())) |
583 | return false; | 585 | return false; |
584 | showStatMsg(i18n("Successfully saved data.")); | 586 | showStatMsg(i18n("Successfully saved data.")); |
585 | updateCaption(); | 587 | updateCaption(); |
586 | return true; | 588 | return true; |
587 | } | 589 | } |
588 | 590 | ||
589 | void PwM::saveAs_slot() | 591 | void PwM::saveAs_slot() |
590 | { | 592 | { |
591 | saveAs(); | 593 | saveAs(); |
592 | } | 594 | } |
593 | 595 | ||
594 | bool PwM::saveAs() | 596 | bool PwM::saveAs() |
595 | { | 597 | { |
596 | if (!curDoc()->saveAsDocUi(curDoc())) | 598 | if (!curDoc()->saveAsDocUi(curDoc())) |
597 | return false; | 599 | return false; |
598 | showStatMsg(i18n("Successfully saved data.")); | 600 | showStatMsg(i18n("Successfully saved data.")); |
599 | updateCaption(); | 601 | updateCaption(); |
600 | return true; | 602 | return true; |
601 | } | 603 | } |
602 | 604 | ||
603 | //US ENH : changed code to run with older MOC | 605 | //US ENH : changed code to run with older MOC |
604 | void PwM::addPwd_slot() | 606 | void PwM::addPwd_slot() |
605 | { | 607 | { |
606 | addPwd_slot1(0, 0); | 608 | addPwd_slot1(0, 0); |
607 | } | 609 | } |
608 | 610 | ||
609 | void PwM::addPwd_slot1(QString *pw, PwMDoc *_doc) | 611 | void PwM::addPwd_slot1(QString *pw, PwMDoc *_doc) |
610 | { | 612 | { |
611 | PwMDoc *doc; | 613 | PwMDoc *doc; |
612 | if (_doc) { | 614 | if (_doc) { |
613 | doc = _doc; | 615 | doc = _doc; |
614 | } else { | 616 | } else { |
615 | doc = curDoc(); | 617 | doc = curDoc(); |
616 | } | 618 | } |
617 | PWM_ASSERT(doc); | 619 | PWM_ASSERT(doc); |
618 | doc->timer()->getLock(DocTimer::id_autoLockTimer); | 620 | doc->timer()->getLock(DocTimer::id_autoLockTimer); |
619 | #ifndef PWM_EMBEDDED | 621 | #ifndef PWM_EMBEDDED |
620 | AddEntryWndImpl w; | 622 | AddEntryWndImpl w; |
621 | #else | 623 | #else |
622 | AddEntryWndImpl w(this, "addentrywndimpl"); | 624 | AddEntryWndImpl w(this, "addentrywndimpl"); |
623 | #endif | 625 | #endif |
624 | 626 | ||
625 | vector<string> catList; | 627 | vector<string> catList; |
626 | doc->getCategoryList(&catList); | 628 | doc->getCategoryList(&catList); |
627 | unsigned i, size = catList.size(); | 629 | unsigned i, size = catList.size(); |
628 | for (i = 0; i < size; ++i) { | 630 | for (i = 0; i < size; ++i) { |
629 | w.addCategory(catList[i].c_str()); | 631 | w.addCategory(catList[i].c_str()); |
630 | } | 632 | } |
631 | w.setCurrCategory(view->getCurrentCategory()); | 633 | w.setCurrCategory(view->getCurrentCategory()); |
632 | if (pw) | 634 | if (pw) |
633 | w.pwLineEdit->setText(*pw); | 635 | w.pwLineEdit->setText(*pw); |
634 | 636 | ||
635 | tryAgain: | 637 | tryAgain: |
636 | if (w.exec() == 1) | 638 | if (w.exec() == 1) |
637 | { | 639 | { |
638 | PwMDataItem d; | 640 | PwMDataItem d; |
639 | 641 | ||
640 | //US BUG: to initialize all values of curEntr with meaningfulldata, | 642 | //US BUG: to initialize all values of curEntr with meaningfulldata, |
641 | // we call clear on it. Reason: Metadata will be uninitialized otherwise. | 643 | // we call clear on it. Reason: Metadata will be uninitialized otherwise. |
642 | // another option would be to create a constructor for PwMDataItem | 644 | // another option would be to create a constructor for PwMDataItem |
643 | d.clear(true); | 645 | d.clear(true); |
644 | 646 | ||
645 | d.desc = w.getDescription().latin1(); | 647 | d.desc = w.getDescription().latin1(); |
646 | d.name = w.getUsername().latin1(); | 648 | d.name = w.getUsername().latin1(); |
647 | d.pw = w.getPassword().latin1(); | 649 | d.pw = w.getPassword().latin1(); |
648 | d.comment = w.getComment().latin1(); | 650 | d.comment = w.getComment().latin1(); |
649 | d.url = w.getUrl().latin1(); | 651 | d.url = w.getUrl().latin1(); |
650 | d.launcher = w.getLauncher().latin1(); | 652 | d.launcher = w.getLauncher().latin1(); |
651 | PwMerror ret = doc->addEntry(w.getCategory(), &d); | 653 | PwMerror ret = doc->addEntry(w.getCategory(), &d); |
652 | if (ret == e_entryExists) { | 654 | if (ret == e_entryExists) { |
653 | KMessageBox::error(this, | 655 | KMessageBox::error(this, |
654 | i18n | 656 | i18n |
655 | ("An entry with this \"Description\",\n" | 657 | ("An entry with this \"Description\",\n" |
656 | "does already exist.\n" | 658 | "does already exist.\n" |
657 | "Please select another description."), | 659 | "Please select another description."), |
658 | i18n("entry already exists.")); | 660 | i18n("entry already exists.")); |
659 | goto tryAgain; | 661 | goto tryAgain; |
660 | } else if (ret == e_maxAllowedEntr) { | 662 | } else if (ret == e_maxAllowedEntr) { |
661 | KMessageBox::error(this, i18n("The maximum possible number of\nentries" | 663 | KMessageBox::error(this, i18n("The maximum possible number of\nentries" |
662 | "has been reached.\nYou can't add more entries."), | 664 | "has been reached.\nYou can't add more entries."), |
663 | i18n("maximum number of entries")); | 665 | i18n("maximum number of entries")); |
664 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 666 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
665 | return; | 667 | return; |
666 | } | 668 | } |
667 | } | 669 | } |
668 | setVirgin(false); | 670 | setVirgin(false); |
669 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 671 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
670 | } | 672 | } |
671 | 673 | ||
672 | //US ENH : changed code to run with older MOC | 674 | //US ENH : changed code to run with older MOC |
673 | void PwM::editPwd_slot() | 675 | void PwM::editPwd_slot() |
674 | { | 676 | { |
675 | editPwd_slot3(0,0,0); | 677 | editPwd_slot3(0,0,0); |
676 | } | 678 | } |
677 | 679 | ||
678 | void PwM::editPwd_slot1(const QString *category) | 680 | void PwM::editPwd_slot1(const QString *category) |
679 | { | 681 | { |
680 | editPwd_slot3(category, 0, 0); | 682 | editPwd_slot3(category, 0, 0); |
681 | } | 683 | } |
682 | 684 | ||
683 | void PwM::editPwd_slot3(const QString *category, const int *index, | 685 | void PwM::editPwd_slot3(const QString *category, const int *index, |
684 | PwMDoc *_doc) | 686 | PwMDoc *_doc) |
685 | { | 687 | { |
686 | PwMDoc *doc; | 688 | PwMDoc *doc; |
687 | if (_doc) { | 689 | if (_doc) { |
688 | doc = _doc; | 690 | doc = _doc; |
689 | } else { | 691 | } else { |
690 | doc = curDoc(); | 692 | doc = curDoc(); |
691 | } | 693 | } |
692 | PWM_ASSERT(doc); | 694 | PWM_ASSERT(doc); |
693 | if (doc->isDocEmpty()) | 695 | if (doc->isDocEmpty()) |
694 | return; | 696 | return; |
695 | if (doc->isDeepLocked()) | 697 | if (doc->isDeepLocked()) |
696 | return; | 698 | return; |
697 | doc->timer()->getLock(DocTimer::id_autoLockTimer); | 699 | doc->timer()->getLock(DocTimer::id_autoLockTimer); |
698 | unsigned int curEntryIndex; | 700 | unsigned int curEntryIndex; |
699 | if (index) { | 701 | if (index) { |
700 | curEntryIndex = *index; | 702 | curEntryIndex = *index; |
701 | } else { | 703 | } else { |
702 | if (!(view->getCurEntryIndex(&curEntryIndex))) { | 704 | if (!(view->getCurEntryIndex(&curEntryIndex))) { |
703 | printDebug("couldn't get index. Maybe we have a binary entry here."); | 705 | printDebug("couldn't get index. Maybe we have a binary entry here."); |
704 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 706 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
705 | return; | 707 | return; |
706 | } | 708 | } |
707 | } | 709 | } |
708 | QString curCategory; | 710 | QString curCategory; |
709 | if (category) { | 711 | if (category) { |
710 | curCategory = *category; | 712 | curCategory = *category; |
711 | } else { | 713 | } else { |
712 | curCategory = view->getCurrentCategory(); | 714 | curCategory = view->getCurrentCategory(); |
713 | } | 715 | } |
714 | PwMDataItem currItem; | 716 | PwMDataItem currItem; |
715 | if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) { | 717 | if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) { |
716 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 718 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
717 | return; | 719 | return; |
718 | } | 720 | } |
719 | BUG_ON(currItem.binary); | 721 | BUG_ON(currItem.binary); |
720 | 722 | ||
721 | AddEntryWndImpl w; | 723 | AddEntryWndImpl w; |
722 | vector<string> catList; | 724 | vector<string> catList; |
723 | doc->getCategoryList(&catList); | 725 | doc->getCategoryList(&catList); |
724 | unsigned i, size = catList.size(); | 726 | unsigned i, size = catList.size(); |
725 | for (i = 0; i < size; ++i) { | 727 | for (i = 0; i < size; ++i) { |
726 | w.addCategory(catList[i].c_str()); | 728 | w.addCategory(catList[i].c_str()); |
727 | } | 729 | } |
728 | w.setCurrCategory(curCategory); | 730 | w.setCurrCategory(curCategory); |
729 | w.setDescription(currItem.desc.c_str()); | 731 | w.setDescription(currItem.desc.c_str()); |
730 | w.setUsername(currItem.name.c_str()); | 732 | w.setUsername(currItem.name.c_str()); |
731 | w.setPassword(currItem.pw.c_str()); | 733 | w.setPassword(currItem.pw.c_str()); |
732 | w.setUrl(currItem.url.c_str()); | 734 | w.setUrl(currItem.url.c_str()); |
733 | w.setLauncher(currItem.launcher.c_str()); | 735 | w.setLauncher(currItem.launcher.c_str()); |
734 | w.setComment(currItem.comment.c_str()); | 736 | w.setComment(currItem.comment.c_str()); |
735 | if (w.exec() == 1) { | 737 | if (w.exec() == 1) { |
736 | currItem.desc = w.getDescription().latin1(); | 738 | currItem.desc = w.getDescription().latin1(); |
737 | currItem.name = w.getUsername().latin1(); | 739 | currItem.name = w.getUsername().latin1(); |
738 | currItem.pw = w.getPassword().latin1(); | 740 | currItem.pw = w.getPassword().latin1(); |
739 | currItem.comment = w.getComment().latin1(); | 741 | currItem.comment = w.getComment().latin1(); |
740 | currItem.url = w.getUrl().latin1(); | 742 | currItem.url = w.getUrl().latin1(); |
741 | currItem.launcher = w.getLauncher().latin1(); | 743 | currItem.launcher = w.getLauncher().latin1(); |
742 | if (!doc->editEntry(curCategory, w.getCategory(), | 744 | if (!doc->editEntry(curCategory, w.getCategory(), |
743 | curEntryIndex, &currItem)) { | 745 | curEntryIndex, &currItem)) { |
744 | KMessageBox::error(this, | 746 | KMessageBox::error(this, |
745 | i18n("Couldn't edit the entry.\n" | 747 | i18n("Couldn't edit the entry.\n" |
746 | "Maybe you changed the category and\n" | 748 | "Maybe you changed the category and\n" |
747 | "this entry is already present\nin the new " | 749 | "this entry is already present\nin the new " |
748 | "category?"), | 750 | "category?"), |
749 | i18n("couldn't edit entry.")); | 751 | i18n("couldn't edit entry.")); |
750 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 752 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
751 | return; | 753 | return; |
752 | } | 754 | } |
753 | } | 755 | } |
754 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 756 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
755 | } | 757 | } |
756 | 758 | ||
757 | void PwM::deletePwd_slot() | 759 | void PwM::deletePwd_slot() |
758 | { | 760 | { |
759 | PWM_ASSERT(curDoc()); | 761 | PWM_ASSERT(curDoc()); |
760 | if (curDoc()->isDocEmpty()) | 762 | if (curDoc()->isDocEmpty()) |
761 | return; | 763 | return; |
762 | if (curDoc()->isDeepLocked()) | 764 | if (curDoc()->isDeepLocked()) |
763 | return; | 765 | return; |
764 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 766 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
765 | unsigned int curEntryIndex = 0; | 767 | unsigned int curEntryIndex = 0; |
766 | if (!(view->getCurEntryIndex(&curEntryIndex))) { | 768 | if (!(view->getCurEntryIndex(&curEntryIndex))) { |
767 | printDebug("couldn't get index"); | 769 | printDebug("couldn't get index"); |
768 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 770 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
769 | return; | 771 | return; |
770 | } | 772 | } |
771 | 773 | ||
772 | PwMDataItem currItem; | 774 | PwMDataItem currItem; |
773 | QString curCategory = view->getCurrentCategory(); | 775 | QString curCategory = view->getCurrentCategory(); |
774 | if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) { | 776 | if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) { |
775 | printDebug("couldn't get entry"); | 777 | printDebug("couldn't get entry"); |
776 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 778 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
777 | return; | 779 | return; |
778 | } | 780 | } |
779 | if (KMessageBox:: | 781 | if (KMessageBox:: |
780 | questionYesNo(this, | 782 | questionYesNo(this, |
781 | i18n | 783 | i18n |
782 | ("Do you really want to delete\nthe selected entry") + | 784 | ("Do you really want to delete\nthe selected entry") + |
783 | " \n\"" + QString(currItem.desc.c_str()) | 785 | " \n\"" + QString(currItem.desc.c_str()) |
784 | + "\" ?", i18n("delete?")) | 786 | + "\" ?", i18n("delete?")) |
785 | == KMessageBox::Yes) { | 787 | == KMessageBox::Yes) { |
786 | 788 | ||
787 | curDoc()->delEntry(curCategory, curEntryIndex); | 789 | curDoc()->delEntry(curCategory, curEntryIndex); |
788 | } | 790 | } |
789 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 791 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
790 | } | 792 | } |
791 | 793 | ||
792 | void PwM::changeMasterPwd_slot() | 794 | void PwM::changeMasterPwd_slot() |
793 | { | 795 | { |
794 | PWM_ASSERT(curDoc()); | 796 | PWM_ASSERT(curDoc()); |
795 | curDoc()->changeCurrentPw(); | 797 | curDoc()->changeCurrentPw(); |
796 | } | 798 | } |
797 | 799 | ||
798 | void PwM::lockWnd_slot() | 800 | void PwM::lockWnd_slot() |
799 | { | 801 | { |
800 | PWM_ASSERT(curDoc()); | 802 | PWM_ASSERT(curDoc()); |
801 | curDoc()->lockAll(true); | 803 | curDoc()->lockAll(true); |
802 | } | 804 | } |
803 | 805 | ||
804 | void PwM::deepLockWnd_slot() | 806 | void PwM::deepLockWnd_slot() |
805 | { | 807 | { |
806 | PWM_ASSERT(curDoc()); | 808 | PWM_ASSERT(curDoc()); |
807 | curDoc()->deepLock(); | 809 | curDoc()->deepLock(); |
808 | } | 810 | } |
809 | 811 | ||
810 | void PwM::unlockWnd_slot() | 812 | void PwM::unlockWnd_slot() |
811 | { | 813 | { |
812 | PWM_ASSERT(curDoc()); | 814 | PWM_ASSERT(curDoc()); |
813 | curDoc()->lockAll(false); | 815 | curDoc()->lockAll(false); |
814 | } | 816 | } |
815 | 817 | ||
816 | void PwM::config_slot() | 818 | void PwM::config_slot() |
817 | { | 819 | { |
818 | int oldStyle = conf()->confWndMainViewStyle(); | 820 | int oldStyle = conf()->confWndMainViewStyle(); |
819 | #ifdef PWM_EMBEDDED | 821 | #ifdef PWM_EMBEDDED |
820 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"pwmconfigdialog", true ); | 822 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"pwmconfigdialog", true ); |
821 | 823 | ||
822 | KCMPwmConfig* pwmcfg = new KCMPwmConfig( ConfigureDialog->getNewVBoxPage(i18n( "PwManager")) , "KCMPwmConfig" ); | 824 | KCMPwmConfig* pwmcfg = new KCMPwmConfig( ConfigureDialog->getNewVBoxPage(i18n( "PwManager")) , "KCMPwmConfig" ); |
823 | ConfigureDialog->addModule(pwmcfg ); | 825 | ConfigureDialog->addModule(pwmcfg ); |
824 | 826 | ||
825 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 827 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
826 | ConfigureDialog->addModule(kdelibcfg ); | 828 | ConfigureDialog->addModule(kdelibcfg ); |
827 | 829 | ||
828 | #ifndef DESKTOP_VERSION | 830 | #ifndef DESKTOP_VERSION |
829 | ConfigureDialog->showMaximized(); | 831 | ConfigureDialog->showMaximized(); |
830 | #endif | 832 | #endif |
831 | if ( ConfigureDialog->exec() ) | 833 | if ( ConfigureDialog->exec() ) |
832 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 834 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
833 | delete ConfigureDialog; | 835 | delete ConfigureDialog; |
834 | 836 | ||
835 | #else //PWM_EMBEDDED | 837 | #else //PWM_EMBEDDED |
836 | // display the configuration window (modal mode) | 838 | // display the configuration window (modal mode) |
837 | if (!conf()->showConfWnd(this)) | 839 | if (!conf()->showConfWnd(this)) |
838 | return; | 840 | return; |
839 | #endif | 841 | #endif |
840 | 842 | ||
841 | int newStyle = conf()->confWndMainViewStyle(); | 843 | int newStyle = conf()->confWndMainViewStyle(); |
842 | // reinitialize tray | 844 | // reinitialize tray |
843 | init->initTray(); | 845 | init->initTray(); |
844 | // reinitialize KWallet emulation | 846 | // reinitialize KWallet emulation |
845 | init->initKWalletEmu(); | 847 | init->initKWalletEmu(); |
846 | 848 | ||
847 | PwMDocList *_dl = PwMDoc::getOpenDocList(); | 849 | PwMDocList *_dl = PwMDoc::getOpenDocList(); |
848 | const vector<PwMDocList::listItem> *dl = _dl->getList(); | 850 | const vector<PwMDocList::listItem> *dl = _dl->getList(); |
849 | vector<PwMDocList::listItem>::const_iterator i = dl->begin(), | 851 | vector<PwMDocList::listItem>::const_iterator i = dl->begin(), |
850 | end = dl->end(); | 852 | end = dl->end(); |
851 | PwMDoc *doc; | 853 | PwMDoc *doc; |
852 | while (i != end) { | 854 | while (i != end) { |
853 | doc = (*i).doc; | 855 | doc = (*i).doc; |
854 | // unlock-without-mpw timeout | 856 | // unlock-without-mpw timeout |
855 | doc->timer()->start(DocTimer::id_mpwTimer); | 857 | doc->timer()->start(DocTimer::id_mpwTimer); |
856 | // auto-lock timeout | 858 | // auto-lock timeout |
857 | doc->timer()->start(DocTimer::id_autoLockTimer); | 859 | doc->timer()->start(DocTimer::id_autoLockTimer); |
858 | ++i; | 860 | ++i; |
859 | } | 861 | } |
860 | 862 | ||
861 | const QValueList<PwM *> *ml = init->mainWndList(); | 863 | const QValueList<PwM *> *ml = init->mainWndList(); |
862 | #ifndef PWM_EMBEDDED | 864 | #ifndef PWM_EMBEDDED |
863 | QValueList<PwM *>::const_iterator i2 = ml->begin(), | 865 | QValueList<PwM *>::const_iterator i2 = ml->begin(), |
864 | end2 = ml->end(); | 866 | end2 = ml->end(); |
865 | #else | 867 | #else |
866 | QValueList<PwM *>::ConstIterator i2 = ml->begin(), | 868 | QValueList<PwM *>::ConstIterator i2 = ml->begin(), |
867 | end2 = ml->end(); | 869 | end2 = ml->end(); |
868 | #endif | 870 | #endif |
869 | PwM *pwm; | 871 | PwM *pwm; |
870 | while (i2 != end2) { | 872 | while (i2 != end2) { |
871 | pwm = *i2; | 873 | pwm = *i2; |
872 | // reinitialize the window style. | 874 | // reinitialize the window style. |
873 | if (oldStyle != newStyle) | 875 | if (oldStyle != newStyle) |
874 | pwm->curView()->initStyle(newStyle); | 876 | pwm->curView()->initStyle(newStyle); |
875 | // set the new font | 877 | // set the new font |
876 | pwm->curView()->setFont(conf()->confGlobEntryFont()); | 878 | pwm->curView()->setFont(conf()->confGlobEntryFont()); |
877 | ++i2; | 879 | ++i2; |
878 | } | 880 | } |
879 | } | 881 | } |
880 | 882 | ||
881 | void PwM::activateMpButton(bool activate) | 883 | void PwM::activateMpButton(bool activate) |
882 | { | 884 | { |
883 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate); | 885 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate); |
884 | } | 886 | } |
885 | 887 | ||
886 | void PwM::closeEvent(QCloseEvent *e) | 888 | void PwM::closeEvent(QCloseEvent *e) |
887 | { | 889 | { |
888 | e->accept(); | 890 | e->accept(); |
889 | } | 891 | } |
890 | 892 | ||
891 | void PwM::docClosed(PwMDoc *doc) | 893 | void PwM::docClosed(PwMDoc *doc) |
892 | { | 894 | { |
893 | PARAM_UNUSED(doc); | 895 | PARAM_UNUSED(doc); |
894 | PWM_ASSERT(doc == curDoc()); | 896 | PWM_ASSERT(doc == curDoc()); |
895 | close(); | 897 | close(); |
896 | } | 898 | } |
897 | 899 | ||
898 | void PwM::find_slot() | 900 | void PwM::find_slot() |
899 | { | 901 | { |
900 | PWM_ASSERT(curDoc()); | 902 | PWM_ASSERT(curDoc()); |
901 | if (curDoc()->isDocEmpty()) | 903 | if (curDoc()->isDocEmpty()) |
902 | return; | 904 | return; |
903 | if (curDoc()->isDeepLocked()) | 905 | if (curDoc()->isDeepLocked()) |
904 | return; | 906 | return; |
905 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 907 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
906 | FindWndImpl findWnd(view); | 908 | FindWndImpl findWnd(view); |
907 | findWnd.exec(); | 909 | findWnd.exec(); |
908 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 910 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
909 | } | 911 | } |
910 | 912 | ||
911 | void PwM::exportToText() | 913 | void PwM::exportToText() |
912 | { | 914 | { |
913 | PWM_ASSERT(curDoc()); | 915 | PWM_ASSERT(curDoc()); |
914 | if (curDoc()->isDocEmpty()) { | 916 | if (curDoc()->isDocEmpty()) { |
915 | KMessageBox::information(this, | 917 | KMessageBox::information(this, |
916 | i18n | 918 | i18n |
917 | ("Sorry, there's nothing to export.\n" | 919 | ("Sorry, there's nothing to export.\n" |
918 | "Please first add some passwords."), | 920 | "Please first add some passwords."), |
919 | i18n("nothing to do")); | 921 | i18n("nothing to do")); |
920 | return; | 922 | return; |
921 | } | 923 | } |
922 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 924 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
923 | QString fn(KFileDialog::getSaveFileName(QString::null, | 925 | QString fn(KFileDialog::getSaveFileName(QString::null, |
924 | i18n("*|plain-text file"), | 926 | i18n("*|plain-text file"), |
925 | this)); | 927 | this)); |
926 | if (fn == "") { | 928 | if (fn == "") { |
927 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 929 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
928 | return; | 930 | return; |
929 | } | 931 | } |
930 | 932 | ||
931 | PwMerror ret = curDoc()->exportToText(&fn); | 933 | PwMerror ret = curDoc()->exportToText(&fn); |
932 | if (ret != e_success) { | 934 | if (ret != e_success) { |
933 | KMessageBox::error(this, | 935 | KMessageBox::error(this, |
934 | i18n("Error: Couldn't write to file.\n" | 936 | i18n("Error: Couldn't write to file.\n" |
935 | "Please check if you have permission to write\n" | 937 | "Please check if you have permission to write\n" |
936 | "to the file in that directory."), | 938 | "to the file in that directory."), |
937 | i18n("error while writing")); | 939 | i18n("error while writing")); |
938 | } else | 940 | } else |
939 | showStatMsg(i18n("Successfully exported data.")); | 941 | showStatMsg(i18n("Successfully exported data.")); |
940 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 942 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
941 | } | 943 | } |
942 | 944 | ||
943 | bool PwM::importFromText() | 945 | bool PwM::importFromText() |
944 | { | 946 | { |
945 | if (!isVirgin()) { | 947 | if (!isVirgin()) { |
946 | if (KMessageBox::questionYesNo(this, | 948 | if (KMessageBox::questionYesNo(this, |
947 | i18n("Do you want to import the data\n" | 949 | i18n("Do you want to import the data\n" |
948 | "into the current document? (If you\n" | 950 | "into the current document? (If you\n" |
949 | "select \"no\", a new document will be\n" | 951 | "select \"no\", a new document will be\n" |
950 | "opened.)"), | 952 | "opened.)"), |
951 | i18n("import into this document?")) | 953 | i18n("import into this document?")) |
952 | == KMessageBox::No) { | 954 | == KMessageBox::No) { |
953 | // import the data to a new window. | 955 | // import the data to a new window. |
954 | PwM *newInstance = init->createMainWnd(); | 956 | PwM *newInstance = init->createMainWnd(); |
955 | bool ok = newInstance->importFromText(); | 957 | bool ok = newInstance->importFromText(); |
956 | if (!ok) { | 958 | if (!ok) { |
957 | newInstance->setForceQuit(true); | 959 | newInstance->setForceQuit(true); |
958 | delete_and_null(newInstance); | 960 | delete_and_null(newInstance); |
959 | } | 961 | } |
960 | return ok; | 962 | return ok; |
961 | } | 963 | } |
962 | } | 964 | } |
963 | 965 | ||
964 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 966 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
965 | PwMerror ret; | 967 | PwMerror ret; |
966 | QString path(KFileDialog::getOpenFileName(QString::null, | 968 | QString path(KFileDialog::getOpenFileName(QString::null, |
967 | i18n("*|PWM-exported text file"), | 969 | i18n("*|PWM-exported text file"), |
968 | this)); | 970 | this)); |
969 | if (path == "") | 971 | if (path == "") |
970 | goto cancelImport; | 972 | goto cancelImport; |
971 | 973 | ||
972 | ret = curDoc()->importFromText(&path, 0); | 974 | ret = curDoc()->importFromText(&path, 0); |
973 | if (ret == e_fileFormat) { | 975 | if (ret == e_fileFormat) { |
974 | KMessageBox::error(this, | 976 | KMessageBox::error(this, |
975 | i18n("Could not read file-format.\n" | 977 | i18n("Could not read file-format.\n" |
976 | "This seems to be _not_ a valid file\n" | 978 | "This seems to be _not_ a valid file\n" |
977 | "exported by PwM."), | 979 | "exported by PwM."), |
978 | i18n("invalid file-format")); | 980 | i18n("invalid file-format")); |
979 | goto cancelImport; | 981 | goto cancelImport; |
980 | } else if (ret == e_invalidArg) { | 982 | } else if (ret == e_invalidArg) { |
981 | BUG(); | 983 | BUG(); |
982 | goto cancelImport; | 984 | goto cancelImport; |
983 | } else if (ret != e_success) { | 985 | } else if (ret != e_success) { |
984 | KMessageBox::error(this, | 986 | KMessageBox::error(this, |
985 | i18n("Could not import file!\n" | 987 | i18n("Could not import file!\n" |
986 | "Do you have permission to read this file?\n" | 988 | "Do you have permission to read this file?\n" |
987 | "Do you have enough free memory?"), | 989 | "Do you have enough free memory?"), |
988 | i18n("import failed")); | 990 | i18n("import failed")); |
989 | goto cancelImport; | 991 | goto cancelImport; |
990 | } | 992 | } |
991 | setVirgin(false); | 993 | setVirgin(false); |
992 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 994 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
993 | return true; | 995 | return true; |
994 | 996 | ||
995 | cancelImport: | 997 | cancelImport: |
996 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 998 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
997 | return false; | 999 | return false; |
998 | } | 1000 | } |
999 | 1001 | ||
1000 | void PwM::exportToGpasman() | 1002 | void PwM::exportToGpasman() |
1001 | { | 1003 | { |
1002 | PWM_ASSERT(curDoc()); | 1004 | PWM_ASSERT(curDoc()); |
1003 | if (curDoc()->isDocEmpty()) { | 1005 | if (curDoc()->isDocEmpty()) { |
1004 | KMessageBox::information(this, | 1006 | KMessageBox::information(this, |
1005 | i18n | 1007 | i18n |
1006 | ("Sorry, there's nothing to export.\n" | 1008 | ("Sorry, there's nothing to export.\n" |
1007 | "Please first add some passwords."), | 1009 | "Please first add some passwords."), |
1008 | i18n("nothing to do")); | 1010 | i18n("nothing to do")); |
1009 | return; | 1011 | return; |
1010 | } | 1012 | } |
1011 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1013 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1012 | QString fn(KFileDialog::getSaveFileName(QString::null, | 1014 | QString fn(KFileDialog::getSaveFileName(QString::null, |
1013 | i18n("*|Gpasman or Kpasman file"), | 1015 | i18n("*|Gpasman or Kpasman file"), |
1014 | this)); | 1016 | this)); |
1015 | if (fn == "") { | 1017 | if (fn == "") { |
1016 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1018 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1017 | return; | 1019 | return; |
1018 | } | 1020 | } |
1019 | 1021 | ||
1020 | PwMerror ret = curDoc()->exportToGpasman(&fn); | 1022 | PwMerror ret = curDoc()->exportToGpasman(&fn); |
1021 | if (ret != e_success) { | 1023 | if (ret != e_success) { |
1022 | if (ret == e_noPw) { | 1024 | if (ret == e_noPw) { |
1023 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1025 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1024 | return; | 1026 | return; |
1025 | } | 1027 | } |
1026 | KMessageBox::error(this, | 1028 | KMessageBox::error(this, |
1027 | i18n("Error: Couldn't write to file.\n" | 1029 | i18n("Error: Couldn't write to file.\n" |
1028 | "Please check if you have permission to write " | 1030 | "Please check if you have permission to write " |
1029 | "to the file in that directory."), | 1031 | "to the file in that directory."), |
1030 | i18n("error while writing")); | 1032 | i18n("error while writing")); |
1031 | } else | 1033 | } else |
1032 | showStatMsg(i18n("Successfully exported data.")); | 1034 | showStatMsg(i18n("Successfully exported data.")); |
1033 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1035 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1034 | } | 1036 | } |
1035 | 1037 | ||
1036 | 1038 | ||
1037 | 1039 | ||
1038 | void PwM::exportToCsv() | 1040 | void PwM::exportToCsv() |
1039 | { | 1041 | { |
1040 | PWM_ASSERT(curDoc()); | 1042 | PWM_ASSERT(curDoc()); |
1041 | if (curDoc()->isDocEmpty()) { | 1043 | if (curDoc()->isDocEmpty()) { |
1042 | KMessageBox::information(this, | 1044 | KMessageBox::information(this, |
1043 | i18n | 1045 | i18n |
1044 | ("Sorry, there is nothing to export;\n" | 1046 | ("Sorry, there is nothing to export;\n" |
1045 | "please add some passwords first."), | 1047 | "please add some passwords first."), |
1046 | i18n("Nothing to Do")); | 1048 | i18n("Nothing to Do")); |
1047 | return; | 1049 | return; |
1048 | } | 1050 | } |
1049 | 1051 | ||
1050 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1052 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1051 | QString fn(KFileDialog::getSaveFileName("*.csv", i18n("*|CSV Text File"), this)); | 1053 | QString fn(KFileDialog::getSaveFileName("*.csv", i18n("*|CSV Text File"), this)); |
1052 | if (fn.isEmpty()) { | 1054 | if (fn.isEmpty()) { |
1053 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1055 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1054 | return; | 1056 | return; |
1055 | } | 1057 | } |
1056 | 1058 | ||
1057 | Csv csv(this); | 1059 | Csv csv(this); |
1058 | if (!csv.exportData(fn, curDoc())) { | 1060 | if (!csv.exportData(fn, curDoc())) { |
1059 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1061 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1060 | showStatMsg(i18n("CSV file export failed.")); | 1062 | showStatMsg(i18n("CSV file export failed.")); |
1061 | return; | 1063 | return; |
1062 | } | 1064 | } |
1063 | showStatMsg(i18n("Successfully exported data.")); | 1065 | showStatMsg(i18n("Successfully exported data.")); |
1064 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1066 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1065 | } | 1067 | } |
1066 | 1068 | ||
1067 | bool PwM::importCsv() | 1069 | bool PwM::importCsv() |
1068 | { | 1070 | { |
1069 | Csv csv(this); | 1071 | Csv csv(this); |
1070 | if (!isVirgin()) { | 1072 | if (!isVirgin()) { |
1071 | if (KMessageBox::questionYesNo(this, | 1073 | if (KMessageBox::questionYesNo(this, |
1072 | i18n("Do you want to import the data\n" | 1074 | i18n("Do you want to import the data\n" |
1073 | "into the current document? (If you\n" | 1075 | "into the current document? (If you\n" |
1074 | "select \"no\", a new document will be\n" | 1076 | "select \"no\", a new document will be\n" |
1075 | "opened.)"), | 1077 | "opened.)"), |
1076 | i18n("Import into This Document?")) | 1078 | i18n("Import into This Document?")) |
1077 | == KMessageBox::No) { | 1079 | == KMessageBox::No) { |
1078 | // import the data to a new window. | 1080 | // import the data to a new window. |
1079 | PwM *newInstance = init->createMainWnd(); | 1081 | PwM *newInstance = init->createMainWnd(); |
1080 | bool ok = newInstance->importCsv(); | 1082 | bool ok = newInstance->importCsv(); |
1081 | if (!ok) { | 1083 | if (!ok) { |
1082 | newInstance->setForceQuit(true); | 1084 | newInstance->setForceQuit(true); |
1083 | delete_and_null(newInstance); | 1085 | delete_and_null(newInstance); |
1084 | } | 1086 | } |
1085 | return ok; | 1087 | return ok; |
1086 | } | 1088 | } |
1087 | } | 1089 | } |
1088 | 1090 | ||
1089 | QString filename = KFileDialog::getOpenFileName("*.csv", i18n("*|CSV Text File"), this); | 1091 | QString filename = KFileDialog::getOpenFileName("*.csv", i18n("*|CSV Text File"), this); |
1090 | if (filename.isEmpty()) | 1092 | if (filename.isEmpty()) |
1091 | return false; | 1093 | return false; |
1092 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1094 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1093 | if (!csv.importData(filename, curDoc())) { | 1095 | if (!csv.importData(filename, curDoc())) { |
1094 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1096 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1095 | showStatMsg(i18n("CSV file import failed.")); | 1097 | showStatMsg(i18n("CSV file import failed.")); |
1096 | return false; | 1098 | return false; |
1097 | } | 1099 | } |
1098 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1100 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1099 | KMessageBox::information(this, | 1101 | KMessageBox::information(this, |
1100 | i18n("Successfully imported the CSV data\n" | 1102 | i18n("Successfully imported the CSV data\n" |
1101 | "into the current document."), i18n("Successfully Imported")); | 1103 | "into the current document."), i18n("Successfully Imported")); |
1102 | showStatMsg(i18n("Successfully imported")); | 1104 | showStatMsg(i18n("Successfully imported")); |
1103 | setVirgin(false); | 1105 | setVirgin(false); |
1104 | return true; | 1106 | return true; |
1105 | } | 1107 | } |
1106 | 1108 | ||
1107 | 1109 | ||
1108 | void PwM::exportToKWallet() | 1110 | void PwM::exportToKWallet() |
1109 | { | 1111 | { |
1110 | #ifdef CONFIG_KWALLETIF | 1112 | #ifdef CONFIG_KWALLETIF |
1111 | if (!checkAndAskForKWalletEmu()) | 1113 | if (!checkAndAskForKWalletEmu()) |
1112 | return; | 1114 | return; |
1113 | PWM_ASSERT(curDoc()); | 1115 | PWM_ASSERT(curDoc()); |
1114 | if (curDoc()->isDocEmpty()) { | 1116 | if (curDoc()->isDocEmpty()) { |
1115 | KMessageBox::information(this, | 1117 | KMessageBox::information(this, |
1116 | i18n | 1118 | i18n |
1117 | ("Sorry, there's nothing to export.\n" | 1119 | ("Sorry, there's nothing to export.\n" |
1118 | "Please first add some passwords."), | 1120 | "Please first add some passwords."), |
1119 | i18n("nothing to do")); | 1121 | i18n("nothing to do")); |
1120 | init->initKWalletEmu(); | 1122 | init->initKWalletEmu(); |
1121 | return; | 1123 | return; |
1122 | } | 1124 | } |
1123 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1125 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1124 | KWalletIf walletIf(this); | 1126 | KWalletIf walletIf(this); |
1125 | if (walletIf.kwalletExport(curDoc())) { | 1127 | if (walletIf.kwalletExport(curDoc())) { |
1126 | KMessageBox::information(this, | 1128 | KMessageBox::information(this, |
1127 | i18n("Successfully exported the data of the current " | 1129 | i18n("Successfully exported the data of the current " |
1128 | "document to KWallet."), | 1130 | "document to KWallet."), |
1129 | i18n("Successfully exported data.")); | 1131 | i18n("Successfully exported data.")); |
1130 | showStatMsg(i18n("Successfully exported data.")); | 1132 | showStatMsg(i18n("Successfully exported data.")); |
1131 | } | 1133 | } |
1132 | init->initKWalletEmu(); | 1134 | init->initKWalletEmu(); |
1133 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1135 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1134 | #endif // CONFIG_KWALLETIF | 1136 | #endif // CONFIG_KWALLETIF |
1135 | } | 1137 | } |
1136 | 1138 | ||
1137 | bool PwM::importFromGpasman() | 1139 | bool PwM::importFromGpasman() |
1138 | { | 1140 | { |
1139 | if (!isVirgin()) { | 1141 | if (!isVirgin()) { |
1140 | if (KMessageBox::questionYesNo(this, | 1142 | if (KMessageBox::questionYesNo(this, |
1141 | i18n("Do you want to import the data\n" | 1143 | i18n("Do you want to import the data\n" |
1142 | "into the current document? (If you\n" | 1144 | "into the current document? (If you\n" |
1143 | "select \"no\", a new document will be\n" | 1145 | "select \"no\", a new document will be\n" |
1144 | "opened.)"), | 1146 | "opened.)"), |
1145 | i18n("import into this document?")) | 1147 | i18n("import into this document?")) |
1146 | == KMessageBox::No) { | 1148 | == KMessageBox::No) { |
1147 | // import the data to a new window. | 1149 | // import the data to a new window. |
1148 | PwM *newInstance = init->createMainWnd(); | 1150 | PwM *newInstance = init->createMainWnd(); |
1149 | bool ok = newInstance->importFromGpasman(); | 1151 | bool ok = newInstance->importFromGpasman(); |
1150 | if (!ok) { | 1152 | if (!ok) { |
1151 | newInstance->setForceQuit(true); | 1153 | newInstance->setForceQuit(true); |
1152 | delete_and_null(newInstance); | 1154 | delete_and_null(newInstance); |
1153 | } | 1155 | } |
1154 | return ok; | 1156 | return ok; |
1155 | } | 1157 | } |
1156 | } | 1158 | } |
1157 | 1159 | ||
1158 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1160 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1159 | PwMerror ret; | 1161 | PwMerror ret; |
1160 | QString path(KFileDialog::getOpenFileName(QString::null, | 1162 | QString path(KFileDialog::getOpenFileName(QString::null, |
1161 | i18n("*|Gpasman or Kpasman file"), this)); | 1163 | i18n("*|Gpasman or Kpasman file"), this)); |
1162 | if (path == "") | 1164 | if (path == "") |
1163 | goto cancelImport; | 1165 | goto cancelImport; |
1164 | ret = curDoc()->importFromGpasman(&path); | 1166 | ret = curDoc()->importFromGpasman(&path); |
1165 | if (ret == e_wrongPw) { | 1167 | if (ret == e_wrongPw) { |
1166 | if (KMessageBox::questionYesNo(this, | 1168 | if (KMessageBox::questionYesNo(this, |
1167 | i18n | 1169 | i18n |
1168 | ("This is probably the wrong master-password\n" | 1170 | ("This is probably the wrong master-password\n" |
1169 | "you have typed in.\n" | 1171 | "you have typed in.\n" |
1170 | "There is no real way to determine the\n" | 1172 | "There is no real way to determine the\n" |
1171 | "correctness of the password in the Gpasman\n" | 1173 | "correctness of the password in the Gpasman\n" |
1172 | "file-format. But I think this\n" | 1174 | "file-format. But I think this\n" |
1173 | "password ist wrong.\n" | 1175 | "password ist wrong.\n" |
1174 | "Do you want to continue nevertheless?"), | 1176 | "Do you want to continue nevertheless?"), |
1175 | i18n("password error")) | 1177 | i18n("password error")) |
1176 | == KMessageBox::No) { | 1178 | == KMessageBox::No) { |
1177 | goto cancelImport; | 1179 | goto cancelImport; |
1178 | } | 1180 | } |
1179 | } else if (ret != e_success) { | 1181 | } else if (ret != e_success) { |
1180 | KMessageBox::error(this, | 1182 | KMessageBox::error(this, |
1181 | i18n("Could not import file!\n" | 1183 | i18n("Could not import file!\n" |
1182 | "Do you have permission to read this file?"), | 1184 | "Do you have permission to read this file?"), |
1183 | i18n("import failed")); | 1185 | i18n("import failed")); |
1184 | goto cancelImport; | 1186 | goto cancelImport; |
1185 | } | 1187 | } |
1186 | setVirgin(false); | 1188 | setVirgin(false); |
1187 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1189 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1188 | return true; | 1190 | return true; |
1189 | 1191 | ||
1190 | cancelImport: | 1192 | cancelImport: |
1191 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1193 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1192 | return false; | 1194 | return false; |
1193 | } | 1195 | } |
1194 | 1196 | ||
1195 | #ifdef CONFIG_KWALLETIF | 1197 | #ifdef CONFIG_KWALLETIF |
1196 | bool PwM::checkAndAskForKWalletEmu() | 1198 | bool PwM::checkAndAskForKWalletEmu() |
1197 | { | 1199 | { |
1198 | if (init->kwalletEmu()) { | 1200 | if (init->kwalletEmu()) { |
1199 | /* KWallet emulation is enabled. We can't import/export | 1201 | /* KWallet emulation is enabled. We can't import/export |
1200 | * data from/to it, while emulation is active. | 1202 | * data from/to it, while emulation is active. |
1201 | */ | 1203 | */ |
1202 | if (KMessageBox::questionYesNo(this, | 1204 | if (KMessageBox::questionYesNo(this, |
1203 | i18n("KWallet emulation is enabled.\n" | 1205 | i18n("KWallet emulation is enabled.\n" |
1204 | "You can't import or export data from/to " | 1206 | "You can't import or export data from/to " |
1205 | "the original KWallet, while the emulation " | 1207 | "the original KWallet, while the emulation " |
1206 | "is active.\n" | 1208 | "is active.\n" |
1207 | "Do you want to tempoarly disable the KWallet emulation?"), | 1209 | "Do you want to tempoarly disable the KWallet emulation?"), |
1208 | i18n("Tempoarly disable KWallet emulation?")) | 1210 | i18n("Tempoarly disable KWallet emulation?")) |
1209 | == KMessageBox::Yes) { | 1211 | == KMessageBox::Yes) { |
1210 | init->initKWalletEmu(true); | 1212 | init->initKWalletEmu(true); |
1211 | PWM_ASSERT(!init->kwalletEmu()); | 1213 | PWM_ASSERT(!init->kwalletEmu()); |
1212 | return true; | 1214 | return true; |
1213 | } | 1215 | } |
1214 | return false; | 1216 | return false; |
1215 | } | 1217 | } |
1216 | return true; | 1218 | return true; |
1217 | } | 1219 | } |
1218 | #endif // CONFIG_KWALLETIF | 1220 | #endif // CONFIG_KWALLETIF |
1219 | 1221 | ||
1220 | bool PwM::importKWallet() | 1222 | bool PwM::importKWallet() |
1221 | { | 1223 | { |
1222 | #ifdef CONFIG_KWALLETIF | 1224 | #ifdef CONFIG_KWALLETIF |
1223 | if (!checkAndAskForKWalletEmu()) | 1225 | if (!checkAndAskForKWalletEmu()) |
1224 | return false; | 1226 | return false; |
1225 | KWalletIf walletIf(this); | 1227 | KWalletIf walletIf(this); |
1226 | if (!isVirgin()) { | 1228 | if (!isVirgin()) { |
1227 | if (KMessageBox::questionYesNo(this, | 1229 | if (KMessageBox::questionYesNo(this, |
1228 | i18n("Do you want to import the data " | 1230 | i18n("Do you want to import the data " |
1229 | "into the current document? (If you " | 1231 | "into the current document? (If you " |
1230 | "select \"no\", a new document will be " | 1232 | "select \"no\", a new document will be " |
1231 | "opened.)"), | 1233 | "opened.)"), |
1232 | i18n("import into this document?")) | 1234 | i18n("import into this document?")) |
1233 | == KMessageBox::No) { | 1235 | == KMessageBox::No) { |
1234 | // import the data to a new window. | 1236 | // import the data to a new window. |
1235 | PwM *newInstance = init->createMainWnd(); | 1237 | PwM *newInstance = init->createMainWnd(); |
1236 | bool ok = newInstance->importKWallet(); | 1238 | bool ok = newInstance->importKWallet(); |
1237 | if (!ok) { | 1239 | if (!ok) { |
1238 | newInstance->setForceQuit(true); | 1240 | newInstance->setForceQuit(true); |
1239 | delete_and_null(newInstance); | 1241 | delete_and_null(newInstance); |
1240 | goto exit_fail; | 1242 | goto exit_fail; |
1241 | } else { | 1243 | } else { |
1242 | goto exit_ok; | 1244 | goto exit_ok; |
1243 | } | 1245 | } |
1244 | } | 1246 | } |
1245 | } | 1247 | } |
1246 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1248 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1247 | if (!walletIf.kwalletImport(curDoc())) { | 1249 | if (!walletIf.kwalletImport(curDoc())) { |
1248 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1250 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1249 | showStatMsg(i18n("KWallet import failed")); | 1251 | showStatMsg(i18n("KWallet import failed")); |
1250 | goto exit_fail; | 1252 | goto exit_fail; |
1251 | } | 1253 | } |
1252 | KMessageBox::information(this, | 1254 | KMessageBox::information(this, |
1253 | i18n("Successfully imported the KWallet data " | 1255 | i18n("Successfully imported the KWallet data " |
1254 | "into the current document."), | 1256 | "into the current document."), |
1255 | i18n("successfully imported")); | 1257 | i18n("successfully imported")); |
1256 | showStatMsg(i18n("successfully imported")); | 1258 | showStatMsg(i18n("successfully imported")); |
1257 | setVirgin(false); | 1259 | setVirgin(false); |
1258 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1260 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1259 | 1261 | ||
1260 | exit_ok: | 1262 | exit_ok: |
1261 | init->initKWalletEmu(); | 1263 | init->initKWalletEmu(); |
1262 | return true; | 1264 | return true; |
1263 | 1265 | ||
1264 | exit_fail: | 1266 | exit_fail: |
1265 | init->initKWalletEmu(); | 1267 | init->initKWalletEmu(); |
1266 | #endif // CONFIG_KWALLETIF | 1268 | #endif // CONFIG_KWALLETIF |
1267 | return false; | 1269 | return false; |
1268 | } | 1270 | } |
1269 | 1271 | ||
1270 | void PwM::print_slot() | 1272 | void PwM::print_slot() |
1271 | { | 1273 | { |
1272 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1274 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1273 | #ifndef PWM_EMBEDDED | 1275 | #ifndef PWM_EMBEDDED |
1274 | PwMPrint p(curDoc(), this); | 1276 | PwMPrint p(curDoc(), this); |
1275 | p.printNow(); | 1277 | p.printNow(); |
1276 | #else | 1278 | #else |
1277 | qDebug("PwM::print_slot , PRINTING IS NOT IMPLEMENTED"); | 1279 | qDebug("PwM::print_slot , PRINTING IS NOT IMPLEMENTED"); |
1278 | #endif | 1280 | #endif |
1279 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1281 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1280 | } | 1282 | } |
1281 | 1283 | ||
1282 | void PwM::genNewCard_slot() | 1284 | void PwM::genNewCard_slot() |
1283 | { | 1285 | { |
1284 | #ifdef CONFIG_KEYCARD | 1286 | #ifdef CONFIG_KEYCARD |
1285 | init->keycard()->genNewCard(); | 1287 | init->keycard()->genNewCard(); |
1286 | #endif | 1288 | #endif |
1287 | } | 1289 | } |
1288 | 1290 | ||
1289 | void PwM::eraseCard_slot() | 1291 | void PwM::eraseCard_slot() |
1290 | { | 1292 | { |
1291 | #ifdef CONFIG_KEYCARD | 1293 | #ifdef CONFIG_KEYCARD |
1292 | init->keycard()->eraseCard(); | 1294 | init->keycard()->eraseCard(); |
1293 | #endif | 1295 | #endif |
1294 | } | 1296 | } |
1295 | 1297 | ||
1296 | void PwM::readCardId_slot() | 1298 | void PwM::readCardId_slot() |
1297 | { | 1299 | { |
1298 | #ifdef CONFIG_KEYCARD | 1300 | #ifdef CONFIG_KEYCARD |
1299 | init->keycard()->displayKey(); | 1301 | init->keycard()->displayKey(); |
1300 | #endif | 1302 | #endif |
1301 | } | 1303 | } |
1302 | 1304 | ||
1303 | void PwM::makeCardBackup_slot() | 1305 | void PwM::makeCardBackup_slot() |
1304 | { | 1306 | { |
1305 | #ifdef CONFIG_KEYCARD | 1307 | #ifdef CONFIG_KEYCARD |
1306 | init->keycard()->makeBackupImage(); | 1308 | init->keycard()->makeBackupImage(); |
1307 | #endif | 1309 | #endif |
1308 | } | 1310 | } |
1309 | 1311 | ||
1310 | void PwM::replayCardBackup_slot() | 1312 | void PwM::replayCardBackup_slot() |
1311 | { | 1313 | { |
1312 | #ifdef CONFIG_KEYCARD | 1314 | #ifdef CONFIG_KEYCARD |
1313 | init->keycard()->replayBackupImage(); | 1315 | init->keycard()->replayBackupImage(); |
1314 | #endif | 1316 | #endif |
1315 | } | 1317 | } |
1316 | 1318 | ||
1317 | void PwM::execLauncher_slot() | 1319 | void PwM::execLauncher_slot() |
1318 | { | 1320 | { |
1319 | PWM_ASSERT(curDoc()); | 1321 | PWM_ASSERT(curDoc()); |
1320 | if (curDoc()->isDeepLocked()) | 1322 | if (curDoc()->isDeepLocked()) |
1321 | return; | 1323 | return; |
1322 | unsigned int curEntryIndex; | 1324 | unsigned int curEntryIndex; |
1323 | if (!view->getCurEntryIndex(&curEntryIndex)) | 1325 | if (!view->getCurEntryIndex(&curEntryIndex)) |
1324 | return; | 1326 | return; |
1325 | bool ret = curDoc()->execLauncher(view->getCurrentCategory(), | 1327 | bool ret = curDoc()->execLauncher(view->getCurrentCategory(), |
1326 | curEntryIndex); | 1328 | curEntryIndex); |
1327 | if (ret) | 1329 | if (ret) |
1328 | showStatMsg(i18n("Executed the \"Launcher\".")); | 1330 | showStatMsg(i18n("Executed the \"Launcher\".")); |
1329 | else | 1331 | else |
1330 | showStatMsg(i18n("ERROR: Couldn't execute the \"Launcher\"!")); | 1332 | showStatMsg(i18n("ERROR: Couldn't execute the \"Launcher\"!")); |
1331 | } | 1333 | } |
1332 | 1334 | ||
1333 | void PwM::goToURL_slot() | 1335 | void PwM::goToURL_slot() |
1334 | { | 1336 | { |
1335 | PWM_ASSERT(curDoc()); | 1337 | PWM_ASSERT(curDoc()); |
1336 | if (curDoc()->isDeepLocked()) | 1338 | if (curDoc()->isDeepLocked()) |
1337 | return; | 1339 | return; |
1338 | unsigned int curEntryIndex; | 1340 | unsigned int curEntryIndex; |
1339 | if (!view->getCurEntryIndex(&curEntryIndex)) | 1341 | if (!view->getCurEntryIndex(&curEntryIndex)) |
1340 | return; | 1342 | return; |
1341 | bool ret = curDoc()->goToURL(view->getCurrentCategory(), | 1343 | bool ret = curDoc()->goToURL(view->getCurrentCategory(), |
1342 | curEntryIndex); | 1344 | curEntryIndex); |
1343 | if (ret) | 1345 | if (ret) |
1344 | showStatMsg(i18n("started browser with current URL.")); | 1346 | showStatMsg(i18n("started browser with current URL.")); |
1345 | else | 1347 | else |
1346 | showStatMsg(i18n("ERROR: Couldn't start browser! Maybe invalid URL?")); | 1348 | showStatMsg(i18n("ERROR: Couldn't start browser! Maybe invalid URL?")); |
1347 | } | 1349 | } |
1348 | 1350 | ||
1349 | void PwM::copyToClipboard(const QString &s) | 1351 | void PwM::copyToClipboard(const QString &s) |
1350 | { | 1352 | { |
1351 | QClipboard *cb = QApplication::clipboard(); | 1353 | QClipboard *cb = QApplication::clipboard(); |
1352 | #ifndef PWM_EMBEDDED | 1354 | #ifndef PWM_EMBEDDED |
1353 | if (cb->supportsSelection()) | 1355 | if (cb->supportsSelection()) |
1354 | cb->setText(s, QClipboard::Selection); | 1356 | cb->setText(s, QClipboard::Selection); |
1355 | cb->setText(s, QClipboard::Clipboard); | 1357 | cb->setText(s, QClipboard::Clipboard); |
1356 | #else | 1358 | #else |
1357 | cb->setText(s); | 1359 | cb->setText(s); |
1358 | 1360 | ||
1359 | #endif | 1361 | #endif |
1360 | 1362 | ||
1361 | } | 1363 | } |
1362 | 1364 | ||
1363 | 1365 | ||
1364 | void PwM::showStatMsg(const QString &msg) | 1366 | void PwM::showStatMsg(const QString &msg) |
1365 | { | 1367 | { |
1366 | #ifdef DESKTOP_VERSION | 1368 | #ifdef DESKTOP_VERSION |
1367 | statusBar()->message(msg, STATUSBAR_MSG_TIMEOUT * 1000); | 1369 | statusBar()->message(msg, STATUSBAR_MSG_TIMEOUT * 1000); |
1368 | #else | 1370 | #else |
1369 | qDebug("Statusbar : %s",msg.latin1()); | 1371 | qDebug("Statusbar : %s",msg.latin1()); |
1370 | Global::statusMessage(msg); | 1372 | Global::statusMessage(msg); |
1371 | #endif | 1373 | #endif |
1372 | } | 1374 | } |
1373 | 1375 | ||
1374 | void PwM::focusInEvent(QFocusEvent *e) | 1376 | void PwM::focusInEvent(QFocusEvent *e) |
1375 | { | 1377 | { |
1376 | if (e->gotFocus()) { | 1378 | if (e->gotFocus()) { |
1377 | emit gotFocus(this); | 1379 | emit gotFocus(this); |
1378 | } else if (e->lostFocus()) { | 1380 | } else if (e->lostFocus()) { |
1379 | emit lostFocus(this); | 1381 | emit lostFocus(this); |
1380 | } | 1382 | } |
1381 | } | 1383 | } |
1382 | 1384 | ||
1383 | 1385 | ||
1384 | #ifdef PWM_EMBEDDED | 1386 | #ifdef PWM_EMBEDDED |
1385 | 1387 | ||
1386 | void PwM::whatsnew_slot() | 1388 | void PwM::whatsnew_slot() |
1387 | { | 1389 | { |
1388 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 1390 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
1389 | } | 1391 | } |
1390 | 1392 | ||
1391 | void PwM::showLicense_slot() | 1393 | void PwM::showLicense_slot() |
1392 | { | 1394 | { |
1393 | KApplication::showLicence(); | 1395 | KApplication::showLicence(); |
1394 | } | 1396 | } |
1395 | 1397 | ||
1396 | void PwM::faq_slot() | 1398 | void PwM::faq_slot() |
1397 | { | 1399 | { |
1398 | KApplication::showFile( "PWM/Pi FAQ", "kdepim/pwmanager/pwmanagerFAQ.txt" ); | 1400 | KApplication::showFile( "PWM/Pi FAQ", "kdepim/pwmanager/pwmanagerFAQ.txt" ); |
1399 | } | 1401 | } |
1400 | 1402 | ||
1401 | void PwM::syncHowTo_slot() | 1403 | void PwM::syncHowTo_slot() |
1402 | { | 1404 | { |
1403 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 1405 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
1404 | } | 1406 | } |
1405 | 1407 | ||
1406 | 1408 | ||
1407 | void PwM::createAboutData_slot() | 1409 | void PwM::createAboutData_slot() |
1408 | { | 1410 | { |
1409 | QString version; | 1411 | QString version; |
1410 | #include <../version> | 1412 | #include <../version> |
1411 | QMessageBox::about( this, "About PwManager/Pi", | 1413 | QMessageBox::about( this, "About PwManager/Pi", |
1412 | "PwManager/Platform-independent\n" | 1414 | "PwManager/Platform-independent\n" |
1413 | "(PWM/Pi) " +version + " - " + | 1415 | "(PWM/Pi) " +version + " - " + |
1414 | #ifdef DESKTOP_VERSION | 1416 | #ifdef DESKTOP_VERSION |
1415 | "Desktop Edition\n" | 1417 | "Desktop Edition\n" |
1416 | #else | 1418 | #else |
1417 | "PDA-Edition\n" | 1419 | "PDA-Edition\n" |
1418 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 1420 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
1419 | #endif | 1421 | #endif |
1420 | 1422 | ||
1421 | "(c) 2004 Ulf Schenk\n" | 1423 | "(c) 2004 Ulf Schenk\n" |
1422 | "(c) 2004 Lutz Rogowski\n" | 1424 | "(c) 2004 Lutz Rogowski\n" |
1423 | "(c) 1997-2004, The KDE PIM Team\n" | 1425 | "(c) 1997-2004, The KDE PIM Team\n" |
1424 | 1426 | ||
1425 | "(c) Michael Buesch - main programming\nand current maintainer\nmbuesch@freenet.de\n" | 1427 | "(c) Michael Buesch - main programming\nand current maintainer\nmbuesch@freenet.de\n" |
1426 | "Matt Scifo - mscifo@o1.com\n" | 1428 | "Matt Scifo - mscifo@o1.com\n" |
1427 | "Elias Probst - elias.probst@gmx.de\n" | 1429 | "Elias Probst - elias.probst@gmx.de\n" |
1428 | "George Staikos - staikos@kde.org\n" | 1430 | "George Staikos - staikos@kde.org\n" |
1429 | "Matthew Palmer - mjp16@uow.edu.au\n" | 1431 | "Matthew Palmer - mjp16@uow.edu.au\n" |
1430 | "Olivier Sessink - gpasman@nl.linux.org\n" | 1432 | "Olivier Sessink - gpasman@nl.linux.org\n" |
1431 | "The libgcrypt developers -\nBlowfish and SHA1 algorithms\nftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/\n" | 1433 | "The libgcrypt developers -\nBlowfish and SHA1 algorithms\nftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/\n" |
1432 | "Troy Engel - tengel@sonic.net\n" | 1434 | "Troy Engel - tengel@sonic.net\n" |
1433 | "Wickey - wickey@gmx.at\n" | 1435 | "Wickey - wickey@gmx.at\n" |
1434 | "Ian MacGregor - original documentation author.\n" | 1436 | "Ian MacGregor - original documentation author.\n" |
1435 | ); | 1437 | ); |
1436 | } | 1438 | } |
1437 | 1439 | ||
1438 | 1440 | ||
1439 | //this are the overwritten callbackmethods from the syncinterface | 1441 | //this are the overwritten callbackmethods from the syncinterface |
1440 | bool PwM::sync(KSyncManager* manager, QString filename, int mode) | 1442 | bool PwM::sync(KSyncManager* manager, QString filename, int mode) |
1441 | { | 1443 | { |
1442 | PWM_ASSERT(curDoc()); | 1444 | PWM_ASSERT(curDoc()); |
1443 | 1445 | ||
1444 | bool ret = curDoc()->sync(manager, filename, mode); | 1446 | bool ret = curDoc()->sync(manager, filename, mode); |
1445 | 1447 | ||
1446 | qDebug("PwM::sync save now: ret=%i", ret); | 1448 | qDebug("PwM::sync save now: ret=%i", ret); |
1447 | 1449 | ||
1448 | if (ret == true) { | 1450 | if (ret == true) { |
1449 | //US BUG: what can we call here to update the view of the current doc? | 1451 | //US BUG: what can we call here to update the view of the current doc? |
1450 | //mViewManager->refreshView(); | 1452 | //mViewManager->refreshView(); |
1451 | 1453 | ||
1452 | //US curDoc()->sync sets the dirtyFlag in case the sync was successfull. | 1454 | //US curDoc()->sync sets the dirtyFlag in case the sync was successfull. |
1453 | save(); | 1455 | save(); |
1454 | } | 1456 | } |
1455 | 1457 | ||
1456 | return ret; | 1458 | return ret; |
1457 | } | 1459 | } |
1458 | #endif | 1460 | #endif |
1459 | 1461 | ||
1460 | 1462 | ||
1461 | #ifndef PWM_EMBEDDED | 1463 | #ifndef PWM_EMBEDDED |
1462 | #include "pwm.moc" | 1464 | #include "pwm.moc" |
1463 | #endif | 1465 | #endif |