-rw-r--r-- | kaddressbook/xxport/sharpdtm/sharpdtmE.pro | 2 | ||||
-rw-r--r-- | kaddressbook/xxport/sharpdtm/sharpdtm_xxport.cpp | 103 |
2 files changed, 49 insertions, 56 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 | |||
@@ -10,3 +10,3 @@ 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 |
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 | |||
@@ -55,3 +55,3 @@ $Id$ | |||
55 | #include "xxportmanager.h" | 55 | #include "xxportmanager.h" |
56 | //#include "qtopiaconverter.h" | 56 | #include "sharpdtmconverter.h" |
57 | 57 | ||
@@ -92,4 +92,4 @@ bool SharpDTMXXPort::exportContacts( const KABC::AddresseeList &list, const QStr | |||
92 | SlZDataBase* access = new SlZDataBase(fileName, | 92 | SlZDataBase* access = new SlZDataBase(fileName, |
93 | SlZDataBase::addressbookItems()); | 93 | SlZDataBase::addressbookItems()); |
94 | 94 | ||
95 | if ( !access ) { | 95 | if ( !access ) { |
@@ -102,6 +102,5 @@ bool SharpDTMXXPort::exportContacts( const KABC::AddresseeList &list, const QStr | |||
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) |
@@ -112,38 +111,33 @@ bool SharpDTMXXPort::exportContacts( const KABC::AddresseeList &list, const QStr | |||
112 | delete access; | 111 | delete access; |
113 | return false; | 112 | return false; |
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 | 117 | { |
119 | AddressBookIterator it(*access); | 118 | QString text( i18n( "Do you want to remove<br>all existing entries from<br>%1<br>before exporting.?" ) ); |
120 | const PimContact* firstcontact = it.toFirst(); | 119 | if ( KMessageBox::questionYesNo( parentWidget(), text.arg( fileName ) ) == KMessageBox::Yes ) { |
121 | if (firstcontact) | 120 | // Clean the database.. |
122 | { | 121 | access->deleteCard(0, SlZDataBase::AllCard ); |
123 | 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 ) { | ||
125 | // Clean the database.. | ||
126 | |||
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 ); |
144 | } | 133 | |
134 | if (res == true) | ||
135 | access->finishEditCard(&c); | ||
136 | else | ||
137 | access->cancelEditCard(); | ||
138 | } | ||
145 | } | 139 | } |
146 | */ | 140 | |
147 | delete access; | 141 | delete access; |
148 | 142 | ||
149 | return true; | 143 | return true; |
@@ -154,9 +148,10 @@ KABC::AddresseeList SharpDTMXXPort::importContacts( const QString& ) const | |||
154 | KABC::AddresseeList adrlst; | 148 | KABC::AddresseeList adrlst; |
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); |
155 | |||
160 | 156 | ||
161 | |||
162 | if ( !access ) { | 157 | if ( !access ) { |
@@ -168,4 +163,4 @@ KABC::AddresseeList SharpDTMXXPort::importContacts( const QString& ) const | |||
168 | } | 163 | } |
169 | /*US | 164 | |
170 | KABC::QtopiaConverter mConverter; | 165 | KABC::SharpDTMConverter mConverter; |
171 | 166 | ||
@@ -180,15 +175,14 @@ KABC::AddresseeList SharpDTMXXPort::importContacts( const QString& ) const | |||
180 | } | 175 | } |
181 | 176 | ||
182 | 177 | ||
183 | 178 | { //create a new scope | |
184 | { //create a new scope | 179 | CardId id; |
185 | AddressBookIterator it(*access); | 180 | |
186 | 181 | for (bool res=access->first(); res == true; res=access->next()) { | |
187 | for (it.toFirst(); it.current(); ++it) { | 182 | id = access->cardId(); |
188 | const PimContact*contact = it.current(); | 183 | |
189 | |||
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 ) |
@@ -199,8 +193,7 @@ KABC::AddresseeList SharpDTMXXPort::importContacts( const QString& ) const | |||
199 | } | 193 | } |
200 | */ | 194 | |
201 | |||
202 | delete access; | 195 | delete access; |
203 | 196 | ||
204 | return adrlst; | 197 | return adrlst; |
205 | 198 | ||
206 | } | 199 | } |