author | zautrix <zautrix> | 2005-08-17 19:23:08 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-08-17 19:23:08 (UTC) |
commit | dfb9cdc7d39b988e23e5491e1c8f0e8c5713dae5 (patch) (unidiff) | |
tree | f2c58bbb72294d1a7d1d3fac8c11e15087a01460 /kaddressbook/xxportmanager.cpp | |
parent | fefa169958abb9c487205d92b54c79532b6f924a (diff) | |
download | kdepimpi-dfb9cdc7d39b988e23e5491e1c8f0e8c5713dae5.zip kdepimpi-dfb9cdc7d39b988e23e5491e1c8f0e8c5713dae5.tar.gz kdepimpi-dfb9cdc7d39b988e23e5491e1c8f0e8c5713dae5.tar.bz2 |
import fix
Diffstat (limited to 'kaddressbook/xxportmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/xxportmanager.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/kaddressbook/xxportmanager.cpp b/kaddressbook/xxportmanager.cpp index 7cb67ed..405f7ec 100644 --- a/kaddressbook/xxportmanager.cpp +++ b/kaddressbook/xxportmanager.cpp | |||
@@ -38,48 +38,49 @@ $Id$ | |||
38 | #include <klocale.h> | 38 | #include <klocale.h> |
39 | #include <kmessagebox.h> | 39 | #include <kmessagebox.h> |
40 | 40 | ||
41 | #ifndef KAB_EMBEDDED | 41 | #ifndef KAB_EMBEDDED |
42 | #include <ktrader.h> | 42 | #include <ktrader.h> |
43 | #else //KAB_EMBEDDED | 43 | #else //KAB_EMBEDDED |
44 | extern "C" | 44 | extern "C" |
45 | { | 45 | { |
46 | void* init_microkaddrbk_csv_xxport(); | 46 | void* init_microkaddrbk_csv_xxport(); |
47 | void* init_microkaddrbk_kde2_xxport(); | 47 | void* init_microkaddrbk_kde2_xxport(); |
48 | void* init_microkaddrbk_vcard_xxport(); | 48 | void* init_microkaddrbk_vcard_xxport(); |
49 | // void* init_microkaddrbk_opie_xxport(); | 49 | // void* init_microkaddrbk_opie_xxport(); |
50 | void* init_microkaddrbk_qtopia_xxport(); | 50 | void* init_microkaddrbk_qtopia_xxport(); |
51 | void* init_microkaddrbk_sharpdtm_xxport(); | 51 | void* init_microkaddrbk_sharpdtm_xxport(); |
52 | } | 52 | } |
53 | #endif //KAB_EMBEDDED | 53 | #endif //KAB_EMBEDDED |
54 | 54 | ||
55 | #include <addresseeview.h> | 55 | #include <addresseeview.h> |
56 | 56 | ||
57 | #include "kabcore.h" | 57 | #include "kabcore.h" |
58 | #include "undocmds.h" | 58 | #include "undocmds.h" |
59 | #include "xxportselectdialog.h" | 59 | #include "xxportselectdialog.h" |
60 | 60 | ||
61 | #include "xxportmanager.h" | 61 | #include "xxportmanager.h" |
62 | #include "nameeditdialog.h" | ||
62 | 63 | ||
63 | KURL XXPortManager::importURL = KURL(); | 64 | KURL XXPortManager::importURL = KURL(); |
64 | QString XXPortManager::importData = QString::null; | 65 | QString XXPortManager::importData = QString::null; |
65 | 66 | ||
66 | class PreviewDialog : public KDialogBase | 67 | class PreviewDialog : public KDialogBase |
67 | { | 68 | { |
68 | public: | 69 | public: |
69 | PreviewDialog( const KABC::Addressee &addr, | 70 | PreviewDialog( const KABC::Addressee &addr, |
70 | QWidget *parent, const char *name = 0 ); | 71 | QWidget *parent, const char *name = 0 ); |
71 | }; | 72 | }; |
72 | 73 | ||
73 | XXPortManager::XXPortManager( KABCore *core, QObject *parent, const char *name ) | 74 | XXPortManager::XXPortManager( KABCore *core, QObject *parent, const char *name ) |
74 | : QObject( parent, name ), mCore( core ), mShowPreview( false ) | 75 | : QObject( parent, name ), mCore( core ), mShowPreview( false ) |
75 | { | 76 | { |
76 | loadPlugins(); | 77 | loadPlugins(); |
77 | } | 78 | } |
78 | 79 | ||
79 | XXPortManager::~XXPortManager() | 80 | XXPortManager::~XXPortManager() |
80 | { | 81 | { |
81 | } | 82 | } |
82 | 83 | ||
83 | void XXPortManager::restoreSettings() | 84 | void XXPortManager::restoreSettings() |
84 | { | 85 | { |
85 | } | 86 | } |
@@ -111,74 +112,80 @@ void XXPortManager::importVCard( const QString &vCard, bool showPreview ) | |||
111 | importData = ""; | 112 | importData = ""; |
112 | } | 113 | } |
113 | 114 | ||
114 | void XXPortManager::slotImport( const QString &identifier, const QString &data ) | 115 | void XXPortManager::slotImport( const QString &identifier, const QString &data ) |
115 | { | 116 | { |
116 | XXPortObject *obj = mXXPortObjects[ identifier ]; | 117 | XXPortObject *obj = mXXPortObjects[ identifier ]; |
117 | if ( !obj ) { | 118 | if ( !obj ) { |
118 | KMessageBox::error( mCore, i18n( "<qt>No import plugin available for <b>%1</b>.</qt>" ).arg( identifier ) ); | 119 | KMessageBox::error( mCore, i18n( "<qt>No import plugin available for <b>%1</b>.</qt>" ).arg( identifier ) ); |
119 | return; | 120 | return; |
120 | } | 121 | } |
121 | 122 | ||
122 | KABC::Resource *resource = mCore->requestResource( mCore ); | 123 | KABC::Resource *resource = mCore->requestResource( mCore ); |
123 | if ( !resource ) | 124 | if ( !resource ) |
124 | return; | 125 | return; |
125 | 126 | ||
126 | KABC::AddresseeList list = obj->importContacts( data ); | 127 | KABC::AddresseeList list = obj->importContacts( data ); |
127 | bool useUndo = ( list.count() < 25 ); | 128 | bool useUndo = ( list.count() < 25 ); |
128 | #ifdef DESKTOP_VERSION | 129 | #ifdef DESKTOP_VERSION |
129 | useUndo = true; | 130 | useUndo = true; |
130 | #endif | 131 | #endif |
131 | mShowPreview = true; | 132 | mShowPreview = true; |
132 | KABC::AddresseeList::Iterator it; | 133 | KABC::AddresseeList::Iterator it; |
133 | bool imported = false; | 134 | bool imported = false; |
134 | int count = 0; | 135 | int count = 0; |
136 | |||
137 | KConfig config( locateLocal("config", "kabcrc") ); | ||
138 | config.setGroup( "General" ); | ||
139 | int FormattedNameType = config.readNumEntry( "FormattedNameType", 1 ); | ||
140 | |||
141 | |||
135 | for ( it = list.begin(); it != list.end(); ++it ) { | 142 | for ( it = list.begin(); it != list.end(); ++it ) { |
136 | if ( mShowPreview ) { | 143 | if ( mShowPreview ) { |
137 | PreviewDialog dlg( *it, mCore ); | 144 | PreviewDialog dlg( *it, mCore ); |
138 | connect( &dlg, SIGNAL( closeClicked() ), this, SLOT ( noPreview()) ); | 145 | connect( &dlg, SIGNAL( closeClicked() ), this, SLOT ( noPreview()) ); |
139 | if ( !dlg.exec() ) { | 146 | if ( !dlg.exec() ) { |
140 | if ( mShowPreview ) | 147 | if ( mShowPreview ) |
141 | continue; | 148 | continue; |
142 | } | 149 | } |
143 | } | 150 | } |
144 | |||
145 | (*it).setResource( resource ); | 151 | (*it).setResource( resource ); |
152 | if ( (*it).formattedName().isEmpty() ) | ||
153 | (*it).setFormattedName( NameEditDialog::formattedName( (*it), FormattedNameType ) ); | ||
146 | if ( useUndo ) { | 154 | if ( useUndo ) { |
155 | ++count; | ||
147 | // We use a PwNewCommand so the user can undo it. | 156 | // We use a PwNewCommand so the user can undo it. |
148 | PwNewCommand *command = new PwNewCommand( mCore->addressBook(), *it ); | 157 | PwNewCommand *command = new PwNewCommand( mCore->addressBook(), *it ); |
149 | UndoStack::instance()->push( command ); | 158 | UndoStack::instance()->push( command ); |
150 | RedoStack::instance()->clear(); | 159 | RedoStack::instance()->clear(); |
151 | } else { | 160 | } else { |
152 | ++count; | 161 | ++count; |
153 | mCore->addressBook()->insertAddressee( (*it), true, true ); | 162 | mCore->addressBook()->insertAddressee( (*it), true, true ); |
154 | } | 163 | } |
155 | imported = true; | 164 | imported = true; |
156 | } | 165 | } |
157 | |||
158 | if ( imported ) { | 166 | if ( imported ) { |
159 | KMessageBox::information( mCore, i18n( "%1 contacts\nsuccessfully\nimported.").arg( count) ); | 167 | KMessageBox::information( mCore, i18n( "%1 contacts\nsuccessfully\nimported.").arg( count) ); |
160 | |||
161 | emit modified(); | 168 | emit modified(); |
162 | } | 169 | } |
163 | } | 170 | } |
164 | void XXPortManager::noPreview() | 171 | void XXPortManager::noPreview() |
165 | { | 172 | { |
166 | mShowPreview = false; | 173 | mShowPreview = false; |
167 | } | 174 | } |
168 | void XXPortManager::slotExport( const QString &identifier, const QString &data ) | 175 | void XXPortManager::slotExport( const QString &identifier, const QString &data ) |
169 | { | 176 | { |
170 | XXPortObject *obj = mXXPortObjects[ identifier ]; | 177 | XXPortObject *obj = mXXPortObjects[ identifier ]; |
171 | if ( !obj ) { | 178 | if ( !obj ) { |
172 | KMessageBox::error( mCore, i18n( "<qt>No export plugin available for <b>%1</b>.</qt>" ).arg( identifier ) ); | 179 | KMessageBox::error( mCore, i18n( "<qt>No export plugin available for <b>%1</b>.</qt>" ).arg( identifier ) ); |
173 | return; | 180 | return; |
174 | } | 181 | } |
175 | 182 | ||
176 | KABC::AddresseeList addrList; | 183 | KABC::AddresseeList addrList; |
177 | XXPortSelectDialog dlg( mCore, obj->requiresSorting(), mCore ); | 184 | XXPortSelectDialog dlg( mCore, obj->requiresSorting(), mCore ); |
178 | if ( dlg.exec() ) | 185 | if ( dlg.exec() ) |
179 | addrList = dlg.contacts(); | 186 | addrList = dlg.contacts(); |
180 | else | 187 | else |
181 | return; | 188 | return; |
182 | if ( !obj->exportContacts( addrList, data ) ) | 189 | if ( !obj->exportContacts( addrList, data ) ) |
183 | KMessageBox::error( mCore, i18n( "Unable to export contacts." ) ); | 190 | KMessageBox::error( mCore, i18n( "Unable to export contacts." ) ); |
184 | else | 191 | else |