author | ulf69 <ulf69> | 2004-07-17 00:37:00 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-07-17 00:37:00 (UTC) |
commit | 2439711b1ac7ee38269baff704293eb37a27f6c9 (patch) (unidiff) | |
tree | 706d4a329b557b28db14442b41229d11fede854b | |
parent | b306ee8c93dd563f42a32a1ee2c63eacc6050604 (diff) | |
download | kdepimpi-2439711b1ac7ee38269baff704293eb37a27f6c9.zip kdepimpi-2439711b1ac7ee38269baff704293eb37a27f6c9.tar.gz kdepimpi-2439711b1ac7ee38269baff704293eb37a27f6c9.tar.bz2 |
implementation of sharp import and export
-rw-r--r-- | kaddressbook/xxport/sharpdtm/sharpdtmE.pro | 2 | ||||
-rw-r--r-- | kaddressbook/xxport/sharpdtm/sharpdtm_xxport.cpp | 51 |
2 files changed, 23 insertions, 30 deletions
diff --git a/kaddressbook/xxport/sharpdtm/sharpdtmE.pro b/kaddressbook/xxport/sharpdtm/sharpdtmE.pro index 6e83853..0425c42 100644 --- a/kaddressbook/xxport/sharpdtm/sharpdtmE.pro +++ b/kaddressbook/xxport/sharpdtm/sharpdtmE.pro | |||
@@ -8,7 +8,7 @@ DESTDIR = $(QPEDIR)/lib | |||
8 | 8 | ||
9 | DEFINES += KAB_EMBEDDED | 9 | DEFINES += KAB_EMBEDDED |
10 | 10 | ||
11 | INCLUDEPATH += ../.. ../../../external/sharpdtm/include ../../.. ../../../kabc ../../../kabc/converter/qtopia ../../../microkde ../../../microkde/kdeui ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat $(QPEDIR)/include | 11 | INCLUDEPATH += ../.. ../../../external/sharpdtm/include ../../.. ../../../kabc ../../../kabc/converter/sharpdtm ../../../microkde ../../../microkde/kdeui ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat $(QPEDIR)/include |
12 | LIBS += -L$(QPEDIR)/lib | 12 | LIBS += -L$(QPEDIR)/lib |
13 | LIBS += -lmicrokde | 13 | LIBS += -lmicrokde |
14 | LIBS += -lmicrokabc | 14 | LIBS += -lmicrokabc |
diff --git a/kaddressbook/xxport/sharpdtm/sharpdtm_xxport.cpp b/kaddressbook/xxport/sharpdtm/sharpdtm_xxport.cpp index 4e6a504..8593814 100644 --- a/kaddressbook/xxport/sharpdtm/sharpdtm_xxport.cpp +++ b/kaddressbook/xxport/sharpdtm/sharpdtm_xxport.cpp | |||
@@ -53,7 +53,7 @@ $Id$ | |||
53 | */ | 53 | */ |
54 | 54 | ||
55 | #include "xxportmanager.h" | 55 | #include "xxportmanager.h" |
56 | //#include "qtopiaconverter.h" | 56 | #include "sharpdtmconverter.h" |
57 | 57 | ||
58 | #include "sharpdtm_xxport.h" | 58 | #include "sharpdtm_xxport.h" |
59 | 59 | ||
@@ -100,10 +100,9 @@ bool SharpDTMXXPort::exportContacts( const KABC::AddresseeList &list, const QStr | |||
100 | return false; | 100 | return false; |
101 | } | 101 | } |
102 | 102 | ||
103 | // KABC::QtopiaConverter mConverter; | 103 | KABC::SharpDTMConverter mConverter; |
104 | 104 | ||
105 | // bool res = mConverter.init(); | 105 | bool res = mConverter.init(); |
106 | bool res = true; | ||
107 | if (!res) | 106 | if (!res) |
108 | { | 107 | { |
109 | QString text( i18n( "Unable to initialize sharpdtm converter.<br>Most likely a problem with the category file." ) ); | 108 | QString text( i18n( "Unable to initialize sharpdtm converter.<br>Most likely a problem with the category file." ) ); |
@@ -114,36 +113,31 @@ bool SharpDTMXXPort::exportContacts( const KABC::AddresseeList &list, const QStr | |||
114 | } | 113 | } |
115 | 114 | ||
116 | //Now check if the file has already entries, and ask the user if he wants to delete them first. | 115 | //Now check if the file has already entries, and ask the user if he wants to delete them first. |
117 | /*US | 116 | if (access->count() > 0) |
118 | { //create a new scope | ||
119 | AddressBookIterator it(*access); | ||
120 | const PimContact* firstcontact = it.toFirst(); | ||
121 | if (firstcontact) | ||
122 | { | 117 | { |
123 | QString text( i18n( "Do you want to remove<br>all existing entries from<br>%1<br>before exporting.?" ) ); | 118 | QString text( i18n( "Do you want to remove<br>all existing entries from<br>%1<br>before exporting.?" ) ); |
124 | if ( KMessageBox::questionYesNo( parentWidget(), text.arg( fileName ) ) == KMessageBox::Yes ) { | 119 | if ( KMessageBox::questionYesNo( parentWidget(), text.arg( fileName ) ) == KMessageBox::Yes ) { |
125 | // Clean the database.. | 120 | // Clean the database.. |
126 | 121 | access->deleteCard(0, SlZDataBase::AllCard ); | |
127 | AddressBookIterator it2(*access); | ||
128 | for (it2.toFirst(); it2.current(); ++it2) { | ||
129 | access->removeContact(*it2.current()); | ||
130 | } | ||
131 | } | ||
132 | } | 122 | } |
133 | } | 123 | } |
134 | 124 | ||
135 | KABC::Addressee::List::ConstIterator it; | 125 | KABC::Addressee::List::ConstIterator it; |
136 | for ( it = list.begin(); it != list.end(); ++it ) { | 126 | for ( it = list.begin(); it != list.end(); ++it ) { |
137 | PimContact c; | 127 | CardId c; |
138 | KABC::Addressee addressee = (*it); | 128 | res = access->editNewCard(); |
139 | 129 | ||
140 | res = mConverter.addresseeToQtopia( *it, c ); | ||
141 | if (res == true) | 130 | if (res == true) |
142 | { | 131 | { |
143 | access->addContact(c); | 132 | res = mConverter.addresseeToSharp( *it, access, c ); |
133 | |||
134 | if (res == true) | ||
135 | access->finishEditCard(&c); | ||
136 | else | ||
137 | access->cancelEditCard(); | ||
144 | } | 138 | } |
145 | } | 139 | } |
146 | */ | 140 | |
147 | delete access; | 141 | delete access; |
148 | 142 | ||
149 | return true; | 143 | return true; |
@@ -155,8 +149,9 @@ KABC::AddresseeList SharpDTMXXPort::importContacts( const QString& ) const | |||
155 | 149 | ||
156 | QString fileName = SlZDataBase::addressbookFileName(); | 150 | QString fileName = SlZDataBase::addressbookFileName(); |
157 | 151 | ||
152 | // the last parameter in the SlZDataBase constructor means "readonly" | ||
158 | SlZDataBase* access = new SlZDataBase(fileName, | 153 | SlZDataBase* access = new SlZDataBase(fileName, |
159 | SlZDataBase::addressbookItems()); | 154 | SlZDataBase::addressbookItems(), NULL, true); |
160 | 155 | ||
161 | 156 | ||
162 | if ( !access ) { | 157 | if ( !access ) { |
@@ -166,8 +161,8 @@ KABC::AddresseeList SharpDTMXXPort::importContacts( const QString& ) const | |||
166 | KMessageBox::error( parentWidget(), text ); | 161 | KMessageBox::error( parentWidget(), text ); |
167 | return KABC::AddresseeList(); | 162 | return KABC::AddresseeList(); |
168 | } | 163 | } |
169 | /*US | 164 | |
170 | KABC::QtopiaConverter mConverter; | 165 | KABC::SharpDTMConverter mConverter; |
171 | 166 | ||
172 | bool res = mConverter.init(); | 167 | bool res = mConverter.init(); |
173 | if (!res) | 168 | if (!res) |
@@ -180,16 +175,15 @@ KABC::AddresseeList SharpDTMXXPort::importContacts( const QString& ) const | |||
180 | } | 175 | } |
181 | 176 | ||
182 | 177 | ||
183 | |||
184 | { //create a new scope | 178 | { //create a new scope |
185 | AddressBookIterator it(*access); | 179 | CardId id; |
186 | 180 | ||
187 | for (it.toFirst(); it.current(); ++it) { | 181 | for (bool res=access->first(); res == true; res=access->next()) { |
188 | const PimContact*contact = it.current(); | 182 | id = access->cardId(); |
189 | 183 | ||
190 | KABC::Addressee addressee; | 184 | KABC::Addressee addressee; |
191 | 185 | ||
192 | res = mConverter.qtopiaToAddressee( (*contact), addressee ); | 186 | res = mConverter.sharpToAddressee( id, access, addressee ); |
193 | 187 | ||
194 | if ( !addressee.isEmpty() && res ) | 188 | if ( !addressee.isEmpty() && res ) |
195 | { | 189 | { |
@@ -197,7 +191,6 @@ KABC::AddresseeList SharpDTMXXPort::importContacts( const QString& ) const | |||
197 | } | 191 | } |
198 | } | 192 | } |
199 | } | 193 | } |
200 | */ | ||
201 | 194 | ||
202 | delete access; | 195 | delete access; |
203 | 196 | ||