Diffstat (limited to 'kaddressbook/xxportobject.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/xxportobject.cpp | 152 |
1 files changed, 152 insertions, 0 deletions
diff --git a/kaddressbook/xxportobject.cpp b/kaddressbook/xxportobject.cpp new file mode 100644 index 0000000..42ab0fb --- a/dev/null +++ b/kaddressbook/xxportobject.cpp | |||
@@ -0,0 +1,152 @@ | |||
1 | /* | ||
2 | This file is part of KAddressbook. | ||
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | ||
4 | |||
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 | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
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 | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | |||
24 | /* | ||
25 | Enhanced Version of the file for platform independent KDE tools. | ||
26 | Copyright (c) 2004 Ulf Schenk | ||
27 | |||
28 | $Id$ | ||
29 | */ | ||
30 | |||
31 | #include <qmap.h> | ||
32 | #include <qsignalmapper.h> | ||
33 | |||
34 | #include <kaction.h> | ||
35 | #include <kmessagebox.h> | ||
36 | |||
37 | #include "kabcore.h" | ||
38 | |||
39 | #include "xxportobject.h" | ||
40 | |||
41 | class XXPortObject::XXPortObjectPrivate | ||
42 | { | ||
43 | public: | ||
44 | QSignalMapper *mExportMapper; | ||
45 | QSignalMapper *mImportMapper; | ||
46 | }; | ||
47 | |||
48 | XXPortObject::XXPortObject( KABC::AddressBook *ab, QWidget *parent, | ||
49 | const char *name ) | ||
50 | : QObject( parent, name ), mAddressBook( ab ), mParentWidget( parent ), | ||
51 | d( new XXPortObjectPrivate ) | ||
52 | { | ||
53 | d->mExportMapper = new QSignalMapper( this ); | ||
54 | d->mImportMapper = new QSignalMapper( this ); | ||
55 | |||
56 | connect( d->mExportMapper, SIGNAL( mapped( const QString& ) ), | ||
57 | SLOT( slotExportActivated( const QString& ) ) ); | ||
58 | connect( d->mImportMapper, SIGNAL( mapped( const QString& ) ), | ||
59 | SLOT( slotImportActivated( const QString& ) ) ); | ||
60 | } | ||
61 | |||
62 | XXPortObject::~XXPortObject() | ||
63 | { | ||
64 | delete d; | ||
65 | d = 0; | ||
66 | } | ||
67 | |||
68 | bool XXPortObject::exportContacts( const KABC::AddresseeList&, const QString& ) | ||
69 | { | ||
70 | // do nothing | ||
71 | return false; | ||
72 | } | ||
73 | |||
74 | KABC::AddresseeList XXPortObject::importContacts( const QString& ) const | ||
75 | { | ||
76 | // do nothing | ||
77 | return KABC::AddresseeList(); | ||
78 | } | ||
79 | |||
80 | void XXPortObject::createImportAction( const QString &label, const QString &data ) | ||
81 | { | ||
82 | #ifdef KAB_EMBEDDED | ||
83 | KABCore* kabcore = (KABCore*)mParentWidget; | ||
84 | #endif //KAB_EMBEDDED | ||
85 | |||
86 | QString id = "file_import_" + identifier() + ( data.isEmpty() ? QString( "" ) : "_" + data ); | ||
87 | #ifndef KAB_EMBEDDED | ||
88 | KAction *action = new KAction( label, 0, d->mImportMapper, SLOT( map() ), actionCollection(), id.latin1() ); | ||
89 | #else //KAB_EMBEDDED | ||
90 | KAction *action = new KAction( label, 0, d->mImportMapper, SLOT( map() ), kabcore->actionCollection(), id.latin1() ); | ||
91 | #endif //KAB_EMBEDDED | ||
92 | |||
93 | d->mImportMapper->setMapping( action, ( data.isEmpty() ? QString( "<empty>" ) : data ) ); | ||
94 | |||
95 | #ifndef KAB_EMBEDDED | ||
96 | setXMLFile( identifier() + "_xxportui.rc" ); | ||
97 | #endif //KAB_EMBEDDED | ||
98 | |||
99 | #ifdef KAB_EMBEDDED | ||
100 | action->plug((QWidget*)kabcore->getImportMenu()); | ||
101 | #endif //KAB_EMBEDDED | ||
102 | |||
103 | } | ||
104 | |||
105 | void XXPortObject::createExportAction( const QString &label, const QString &data ) | ||
106 | { | ||
107 | #ifdef KAB_EMBEDDED | ||
108 | KABCore* kabcore = (KABCore*)mParentWidget; | ||
109 | #endif //KAB_EMBEDDED | ||
110 | |||
111 | QString id = "file_export_" + identifier() + ( data.isEmpty() ? QString( "" ) : "_" + data ); | ||
112 | #ifndef KAB_EMBEDDED | ||
113 | KAction *action = new KAction( label, 0, d->mExportMapper, SLOT( map() ), actionCollection(), id.latin1() ); | ||
114 | #else //KAB_EMBEDDED | ||
115 | KAction *action = new KAction( label, 0, d->mExportMapper, SLOT( map() ), kabcore->actionCollection(), id.latin1() ); | ||
116 | #endif //KAB_EMBEDDED | ||
117 | |||
118 | d->mExportMapper->setMapping( action, ( data.isEmpty() ? QString( "<empty>" ) : data ) ); | ||
119 | |||
120 | #ifndef KAB_EMBEDDED | ||
121 | setXMLFile( identifier() + "_xxportui.rc" ); | ||
122 | #endif //KAB_EMBEDDED | ||
123 | |||
124 | #ifdef KAB_EMBEDDED | ||
125 | action->plug((QWidget*)kabcore->getExportMenu()); | ||
126 | #endif //KAB_EMBEDDED | ||
127 | |||
128 | } | ||
129 | |||
130 | KABC::AddressBook *XXPortObject::addressBook() const | ||
131 | { | ||
132 | return mAddressBook; | ||
133 | } | ||
134 | |||
135 | QWidget *XXPortObject::parentWidget() const | ||
136 | { | ||
137 | return mParentWidget; | ||
138 | } | ||
139 | |||
140 | void XXPortObject::slotExportActivated( const QString &data ) | ||
141 | { | ||
142 | emit exportActivated( identifier(), ( data == "<empty>" ? QString::null : data ) ); | ||
143 | } | ||
144 | |||
145 | void XXPortObject::slotImportActivated( const QString &data ) | ||
146 | { | ||
147 | emit importActivated( identifier(), ( data == "<empty>" ? QString::null : data ) ); | ||
148 | } | ||
149 | |||
150 | #ifndef KAB_EMBEDDED | ||
151 | #include "xxportobject.moc" | ||
152 | #endif //KAB_EMBEDDED | ||