[kmobiletools] branches/extragear/kde3/pim/kmobiletools/kmobiletools
Marco Gulino
marco at kmobiletools.org
Tue Jun 12 15:53:13 CEST 2007
SVN commit 674512 by gulino:
Fixing export to CSV list.
Also making the above one a dcop call.
M +4 -0 deviceparts/kmobiletools_devicepart.cpp
M +1 -0 deviceparts/kmobiletools_devicepart.h
M +1 -0 libkmobiletools/deviceIFace.h
M +6 -11 libkmobiletools/sms.cpp
M +2 -2 libkmobiletools/sms.h
M +15 -36 libkmobiletools/smslist.cpp
M +1 -1 libkmobiletools/smslist.h
--- branches/extragear/kde3/pim/kmobiletools/kmobiletools/deviceparts/kmobiletools_devicepart.cpp #674511:674512
@@ -1046,6 +1046,10 @@
}
}
+void kmobiletoolsDevicePart::slotExportSMSListToCSV(const QString &filename)
+{
+ engine->smsList()->saveToCSV(filename);
+}
/*!
\fn kmobiletoolsDevicePart::setupStatusBar()
--- branches/extragear/kde3/pim/kmobiletools/kmobiletools/deviceparts/kmobiletools_devicepart.h #674511:674512
@@ -233,6 +233,7 @@
void slotCalendarFetched();
void slotExportSMSList();
void slotExportSMSListToCSV();
+ void slotExportSMSListToCSV(const QString &filename);
void slotStatusBar();
void slotSaveAddressBook();
void slotSendStoredSMS(SMS*);
--- branches/extragear/kde3/pim/kmobiletools/kmobiletools/libkmobiletools/deviceIFace.h #674511:674512
@@ -49,6 +49,7 @@
virtual void slotFetchPhonebook()=0;
virtual void slotFetchCalendar()=0;
virtual void slotExportSMSList()=0;
+ virtual void slotExportSMSListToCSV(const QString &filename)=0;
virtual void slotNewSMS()=0;
virtual void slotNewSMS(const QString &)=0;
virtual void slotDialNumber(const QString &)=0;
--- branches/extragear/kde3/pim/kmobiletools/kmobiletools/libkmobiletools/sms.cpp #674511:674512
@@ -212,29 +212,25 @@
/*!
\fn SMS::exportCSV(const QString &dir)
*/
-bool SMS::exportCSV(const QString &dir, const QString &filename)
+bool SMS::exportCSV(const QString &filename)
{
- kdDebug() << "SMS::exportCSV(): " << endl;
+ kdDebug() << k_funcinfo << endl;
bool retval=false;
if (i_slot & Phone )
- retval = retval | writeToSlotCSV( dir, filename );
+ retval = retval | writeToSlotCSV( filename );
return retval;
}
-bool SMS::writeToSlotCSV(const QString &dir, const QString &filename)
+bool SMS::writeToSlotCSV(const QString &filename)
{
kdDebug() << "SMS::writeToSlotCSV(): " << endl;
QString text;
- QString filenameOut;
- filenameOut = dir + QDir::separator() + filename;
-
if((i_type & Unsent) || (i_type & Sent) )
{
text="\"OUTGOING\",";
for(QStringList::Iterator it=sl_numbers.begin(); it!=sl_numbers.end(); ++it)
text+="\"" + KMobileTools::KMobiletoolsHelper::translateNumber(*it) + "\",\"" + *it + "\",";
- //filenameOut = dir + QDir::separator() + "outbox_" + filename;
}
else
{
@@ -244,7 +240,6 @@
//text="\"INCOMING\",\"" + KMobileTools::KMobiletoolsHelper::translateNumber( getFrom() ) + "\",\"" + getFrom() + "\",";
text="\"INCOMING\",\"" + transNumber + "\",\"" + getFrom() + "\",";
- //filenameOut = dir + QDir::separator() + "inbox_" + filename;
}
text+="\"" + dt_datetime.toString( "%1, d %2 yyyy hh:mm:ss" )
@@ -254,8 +249,8 @@
//text+="\"" + KCodecs::quotedPrintableEncode( getText().utf8() ) + "\"";
//text+="\"" + getText().utf8() + "\"";
text+="\"" + getText() + "\"";
- kdDebug() << "Writing sms to " << filenameOut << endl;
- QFile file(filenameOut);
+ kdDebug() << "Writing sms to " << filename << endl;
+ QFile file(filename);
QString lastFile = file.readAll();
if(! file.open( IO_WriteOnly | IO_Append ) ) return false;
QTextStream stream( &file );
--- branches/extragear/kde3/pim/kmobiletools/kmobiletools/libkmobiletools/sms.h #674511:674512
@@ -116,8 +116,8 @@
public slots:
bool exportMD(const QString &dir);
bool writeToSlot( const QString &slotDir);
- bool exportCSV(const QString &dir, const QString &filename);
- bool writeToSlotCSV( const QString &slotDir, const QString &filename);
+ bool exportCSV( const QString &filename );
+ bool writeToSlotCSV( const QString &filename );
signals:
void updated();
};
--- branches/extragear/kde3/pim/kmobiletools/kmobiletools/libkmobiletools/smslist.cpp #674511:674512
@@ -214,39 +214,33 @@
/*!
\fn SMSList::saveToCSV(const QString &engineName)
*/
-int SMSList::saveToCSV(const QString &engineName)
+int SMSList::saveToCSV(const QString &filename)
{
- int result;
+ SMS *sms;
+ kdDebug() << "SMSList::saveToCSV(): saving CSV file to: " << filename << endl;
+ QPtrListIterator<SMS> it(*this);
+ bool ok=true;
+ while( (sms=it.current()) )
+ {
+ ++it;
+ ok&=sms->writeToSlotCSV(filename);
+ }
- setEngineName(engineName);
- result = saveToCSV();
- kdDebug() << "SMSList::saveToCSV(): " << endl;
-
- return result;
+ return ok;
}
/*!
\fn SMSList::saveToCSV()
*/
-/// @TODO Check if we can remove dialog windows out of this class, emitting insteada signal.
+/// @TODO Check if we can remove dialog windows out of this class, emitting instead a signal.
int SMSList::saveToCSV()
{
- QString dir=QDir::homeDirPath();
- QPtrListIterator<SMS> it(*this);
- SMS *sms;
QString saveFile;
saveFile = KFileDialog::getSaveFileName (QDir::homeDirPath(), "*.csv", 0, i18n("Save file to disk"));
- QString savePath = saveFile;
- QString fileName = saveFile.section( QDir::separator(),-1);
- if ( ! fileName.isEmpty() )
- savePath = saveFile.left(saveFile.length() - (fileName.length() + 1));
- else return 0;
-
- QDir d = QDir::root();
- if (d.exists(saveFile)) {
+ if (QFile::exists(saveFile)) {
kdDebug() << "SMSList::saveToCSV(): FILE ALREADY EXISTS " << endl;
int retval;
@@ -255,29 +249,14 @@
"KMobileTools" );
if(retval == KMessageBox::Continue) {
- d.remove(saveFile);
+ QFile::remove(saveFile);
}
else {
return -1;
}
}
-
- dir = savePath;
-
- if (dir == "") {
- dir = QDir::homeDirPath();
- }
-
- kdDebug() << "SMSList::saveToCSV(): saving CSV file to: " << dir << endl;
-
- while( (sms=it.current()) )
- {
- ++it;
- sms->exportCSV(dir, fileName);
- }
-
- return 1;
+ return saveToCSV(saveFile);
}
void SMSList::append( SMS *item )
--- branches/extragear/kde3/pim/kmobiletools/kmobiletools/libkmobiletools/smslist.h #674511:674512
@@ -63,7 +63,7 @@
public slots:
void saveToMailBox(const QString &engineName);
void saveToMailBox();
- int saveToCSV(const QString &engineName);
+ int saveToCSV(const QString &filename);
int saveToCSV();
};
More information about the kmobiletools
mailing list