summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-07-01 01:38:43 (UTC)
committer ulf69 <ulf69>2004-07-01 01:38:43 (UTC)
commitc381e615f02b1bc0241719701725a65be46b6326 (patch) (unidiff)
tree01ec97849667e96b952803aab08a79272bae5640
parentd419ee83db7d2549c701fe89b678be619a7ce4d3 (diff)
downloadkdepimpi-c381e615f02b1bc0241719701725a65be46b6326.zip
kdepimpi-c381e615f02b1bc0241719701725a65be46b6326.tar.gz
kdepimpi-c381e615f02b1bc0241719701725a65be46b6326.tar.bz2
*** empty log message ***
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/xxport/opie/opie_xxport.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/kaddressbook/xxport/opie/opie_xxport.cpp b/kaddressbook/xxport/opie/opie_xxport.cpp
index 616eec1..90d05cd 100644
--- a/kaddressbook/xxport/opie/opie_xxport.cpp
+++ b/kaddressbook/xxport/opie/opie_xxport.cpp
@@ -47,129 +47,129 @@ $Id$
47 47
48#include <klocale.h> 48#include <klocale.h>
49#include <kmessagebox.h> 49#include <kmessagebox.h>
50#include <ktempfile.h> 50#include <ktempfile.h>
51#include <kurl.h> 51#include <kurl.h>
52*/ 52*/
53 53
54#include "xxportmanager.h" 54#include "xxportmanager.h"
55#include "opieconverter.h" 55#include "opieconverter.h"
56 56
57#include "opie_xxport.h" 57#include "opie_xxport.h"
58 58
59 59
60class OpieXXPortFactory : public XXPortFactory 60class OpieXXPortFactory : public XXPortFactory
61{ 61{
62 public: 62 public:
63 XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name ) 63 XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name )
64 { 64 {
65 return new OpieXXPort( ab, parent, name ); 65 return new OpieXXPort( ab, parent, name );
66 } 66 }
67}; 67};
68 68
69 69
70extern "C" 70extern "C"
71{ 71{
72 void *init_kaddrbk_opie_xxport() 72 void *init_kaddrbk_opie_xxport()
73 { 73 {
74 return ( new OpieXXPortFactory() ); 74 return ( new OpieXXPortFactory() );
75 } 75 }
76} 76}
77 77
78 78
79OpieXXPort::OpieXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name ) 79OpieXXPort::OpieXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name )
80 : XXPortObject( ab, parent, name ) 80 : XXPortObject( ab, parent, name )
81{ 81{
82 createImportAction( i18n( "Import Opie..." ) ); 82 createImportAction( i18n( "Import Opie..." ) );
83 createExportAction( i18n( "Export Opie..." ) ); 83 createExportAction( i18n( "Export Opie..." ) );
84} 84}
85 85
86bool OpieXXPort::exportContacts( const KABC::AddresseeList &list, const QString &data ) 86bool OpieXXPort::exportContacts( const KABC::AddresseeList &list, const QString &data )
87{ 87{
88 QString name = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; 88 QString name = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml";
89 89
90#ifndef KAB_EMBEDDED 90#ifndef KAB_EMBEDDED
91 QString fileName = KFileDialog::getSaveFileName( name ); 91 QString fileName = KFileDialog::getSaveFileName( name );
92#else //KAB_EMBEDDED 92#else //KAB_EMBEDDED
93 QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() ); 93 QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() );
94#endif //KAB_EMBEDDED 94#endif //KAB_EMBEDDED
95 95
96 if ( fileName.isEmpty() ) 96 if ( fileName.isEmpty() )
97 return true; 97 return true;
98 98
99 OContactAccess* access = new OContactAccess("KA/Pi", fileName, 0l, false); 99 OContactAccess* access = new OContactAccess("KA/Pi", fileName, 0l, false);
100 100
101 if ( !access ) { 101 if ( !access ) {
102 qDebug("Unable to access file() %s", fileName.latin1()); 102 qDebug("Unable to access file() %s", fileName.latin1());
103 addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) ); 103 addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) );
104 return false; 104 return false;
105 } 105 }
106 106
107 //Now check if the file has already entries, and ask the user if he wants to delete them first. 107 //Now check if the file has already entries, and ask the user if he wants to delete them first.
108 OContactAccess::List contactList = access->allRecords(); 108 OContactAccess::List contactList = access->allRecords();
109 if (contactList.count() > 0) 109 if (contactList.count() > 0)
110 { 110 {
111 QString text( i18n( "<qt>Do you want to remove all existing entries from <b>%1</b> before exporting.?</qt>" ) ); 111 QString text( i18n( "Do you want to remove<br>all existing entries from<br>%1<br>before exporting.?" ) );
112 if ( KMessageBox::questionYesNo( parentWidget(), text.arg( fileName ) ) == KMessageBox::Yes ) { 112 if ( KMessageBox::questionYesNo( parentWidget(), text.arg( fileName ) ) == KMessageBox::Yes ) {
113 // Clean the database.. 113 // Clean the database..
114 access->clear(); 114 access->clear();
115 } 115 }
116 } 116 }
117 117
118 KABC::OpieConverter mConverter; 118 KABC::OpieConverter mConverter;
119 bool res; 119 bool res;
120 120
121 KABC::Addressee::List::ConstIterator it; 121 KABC::Addressee::List::ConstIterator it;
122 for ( it = list.begin(); it != list.end(); ++it ) { 122 for ( it = list.begin(); it != list.end(); ++it ) {
123 OContact c; 123 OContact c;
124 KABC::Addressee addressee = (*it); 124 KABC::Addressee addressee = (*it);
125 125
126 res = mConverter.addresseeToOpie( *it, c ); 126 res = mConverter.addresseeToOpie( *it, c );
127 if (res == true) 127 if (res == true)
128 { 128 {
129 res = access->add(c); 129 res = access->add(c);
130 if (res == false) 130 if (res == false)
131 qDebug("Unable to append Contact %s", c.fullName().latin1()); 131 qDebug("Unable to append Contact %s", c.fullName().latin1());
132 } 132 }
133 else 133 else
134 { 134 {
135 qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1()); 135 qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1());
136 } 136 }
137 } 137 }
138 138
139 access->save(); 139 access->save();
140 140
141 delete access; 141 delete access;
142 142
143 return true; 143 return true;
144} 144}
145 145
146KABC::AddresseeList OpieXXPort::importContacts( const QString& ) const 146KABC::AddresseeList OpieXXPort::importContacts( const QString& ) const
147{ 147{
148 KABC::AddresseeList adrlst; 148 KABC::AddresseeList adrlst;
149 149
150 QString name = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; 150 QString name = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml";
151 151
152#ifndef KAB_EMBEDDED 152#ifndef KAB_EMBEDDED
153 QString fileName = KFileDialog::getOpenFileName( name ); 153 QString fileName = KFileDialog::getOpenFileName( name );
154#else //KAB_EMBEDDED 154#else //KAB_EMBEDDED
155 QString fileName = KFileDialog::getOpenFileName( name, i18n("Load file"), parentWidget() ); 155 QString fileName = KFileDialog::getOpenFileName( name, i18n("Load file"), parentWidget() );
156#endif //KAB_EMBEDDED 156#endif //KAB_EMBEDDED
157 157
158 if ( fileName.isEmpty() ) 158 if ( fileName.isEmpty() )
159 return KABC::AddresseeList(); 159 return KABC::AddresseeList();
160 160
161 OContactAccess* access = new OContactAccess("KA/Pi", fileName, 0l, false); 161 OContactAccess* access = new OContactAccess("KA/Pi", fileName, 0l, false);
162 162
163 if ( !access ) { 163 if ( !access ) {
164 qDebug("Unable to access file() %s", fileName.latin1()); 164 qDebug("Unable to access file() %s", fileName.latin1());
165 addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) ); 165 addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) );
166 return KABC::AddresseeList(); 166 return KABC::AddresseeList();
167 } 167 }
168 168
169 access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available 169 access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available
170 170
171 KABC::OpieConverter mConverter; 171 KABC::OpieConverter mConverter;
172 bool res = false; 172 bool res = false;
173 173
174 174
175 OContactAccess::List::Iterator it; 175 OContactAccess::List::Iterator it;