Diffstat (limited to 'kaddressbook/xxport/sharpdtm') (more/less context) (ignore whitespace changes)
-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 | |||
@@ -9,5 +9,5 @@ DESTDIR = $(QPEDIR)/lib | |||
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 |
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 | |||
@@ -54,5 +54,5 @@ $Id$ | |||
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" |
@@ -91,6 +91,6 @@ bool SharpDTMXXPort::exportContacts( const KABC::AddresseeList &list, const QStr | |||
91 | 91 | ||
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 ) { |
96 | QString text( i18n( "Unable to access file '%1'." ).arg( fileName ) ); | 96 | QString text( i18n( "Unable to access file '%1'." ).arg( fileName ) ); |
@@ -101,8 +101,7 @@ bool SharpDTMXXPort::exportContacts( const KABC::AddresseeList &list, const QStr | |||
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 | { |
@@ -111,40 +110,35 @@ bool SharpDTMXXPort::exportContacts( const KABC::AddresseeList &list, const QStr | |||
111 | KMessageBox::error( parentWidget(), text ); | 110 | KMessageBox::error( parentWidget(), text ); |
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; |
150 | } | 144 | } |
@@ -153,11 +147,12 @@ KABC::AddresseeList SharpDTMXXPort::importContacts( const QString& ) const | |||
153 | { | 147 | { |
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 ) { |
163 | QString text( i18n( "Unable to access file '%1'." ).arg( fileName ) ); | 158 | QString text( i18n( "Unable to access file '%1'." ).arg( fileName ) ); |
@@ -167,6 +162,6 @@ KABC::AddresseeList SharpDTMXXPort::importContacts( const QString& ) const | |||
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(); |
@@ -179,17 +174,16 @@ KABC::AddresseeList SharpDTMXXPort::importContacts( const QString& ) const | |||
179 | return KABC::AddresseeList(); | 174 | return KABC::AddresseeList(); |
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 ) |
195 | { | 189 | { |
@@ -198,9 +192,8 @@ KABC::AddresseeList SharpDTMXXPort::importContacts( const QString& ) const | |||
198 | } | 192 | } |
199 | } | 193 | } |
200 | */ | 194 | |
201 | |||
202 | delete access; | 195 | delete access; |
203 | 196 | ||
204 | return adrlst; | 197 | return adrlst; |
205 | 198 | ||
206 | } | 199 | } |