summaryrefslogtreecommitdiffabout
path: root/kaddressbook/xxport/csv_xxport.cpp
Side-by-side diff
Diffstat (limited to 'kaddressbook/xxport/csv_xxport.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/xxport/csv_xxport.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/kaddressbook/xxport/csv_xxport.cpp b/kaddressbook/xxport/csv_xxport.cpp
index ce35053..caee66d 100644
--- a/kaddressbook/xxport/csv_xxport.cpp
+++ b/kaddressbook/xxport/csv_xxport.cpp
@@ -13,105 +13,110 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
/*
Enhanced Version of the file for platform independent KDE tools.
Copyright (c) 2004 Ulf Schenk
$Id$
*/
#include <qfile.h>
#include <qregexp.h>
#include <qtextstream.h>
#include <kfiledialog.h>
#ifndef KAB_EMBEDDED
#include <kio/netaccess.h>
#endif //KAB_EMBEDDED
#include <klocale.h>
#include <kmessagebox.h>
#include <ktempfile.h>
#include <kurl.h>
#include "csvimportdialog.h"
#include "csv_xxport.h"
#ifndef KAB_EMBEDDED
class CSVXXPortFactory : public XXPortFactory
{
public:
XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name )
{
return new CSVXXPort( ab, parent, name );
}
};
+#endif //KAB_EMBEDDED
+
extern "C"
{
+#ifndef KAB_EMBEDDED
void *init_libkaddrbk_csv_xxport()
+#else //KAB_EMBEDDED
+ void *init_kaddrbk_csv_xxport()
+#endif //KAB_EMBEDDED
{
return ( new CSVXXPortFactory() );
}
}
-#endif //KAB_EMBEDDED
CSVXXPort::CSVXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name )
: XXPortObject( ab, parent, name )
{
createImportAction( i18n( "Import CSV List..." ) );
createExportAction( i18n( "Export CSV List..." ) );
}
bool CSVXXPort::exportContacts( const KABC::AddresseeList &list, const QString& )
{
#ifndef KAB_EMBEDDED
KURL url = KFileDialog::getSaveURL( "addressbook.csv" );
if ( url.isEmpty() )
return true;
if ( !url.isLocalFile() ) {
KTempFile tmpFile;
if ( tmpFile.status() != 0 ) {
QString txt = i18n( "<qt>Unable to open file <b>%1</b>.%2.</qt>" );
KMessageBox::error( parentWidget(), txt.arg( url.url() )
.arg( strerror( tmpFile.status() ) ) );
return false;
}
doExport( tmpFile.file(), list );
tmpFile.close();
return KIO::NetAccess::upload( tmpFile.name(), url, parentWidget() );
} else {
QFile file( url.path() );
if ( !file.open( IO_WriteOnly ) ) {
QString txt = i18n( "<qt>Unable to open file <b>%1</b>.</qt>" );
KMessageBox::error( parentWidget(), txt.arg( url.path() ) );
return false;
}
doExport( &file, list );
file.close();
return true;
}
#else //KAB_EMBEDDED
QString fileName = KFileDialog::getSaveFileName( "addressbook.csv", i18n("Save file"), parentWidget() );
if ( fileName.isEmpty() )