[kmobiletools] KDE/kdepim/kmobiletools/kmobiletools/libkmobiletools
Marco Gulino
marco at kmobiletools.org
Fri Jun 15 19:55:05 CEST 2007
SVN commit 676012 by gulino:
Forwardporting changes in sms.cpp and smslist.cpp
M +7 -12 sms.cpp
M +2 -2 sms.h
M +15 -35 smslist.cpp
M +2 -2 smslist.h
--- trunk/KDE/kdepim/kmobiletools/kmobiletools/libkmobiletools/sms.cpp #676011:676012
@@ -240,29 +240,25 @@
/*!
\fn SMS::exportCSV(const QString &dir)
*/
-bool SMS::exportCSV(const QString &dir, const QString &filename)
+bool SMS::exportCSV(const QString &filename)
{
- kDebug() << "SMS::exportCSV(): " << endl;
+ kDebug() << k_funcinfo << endl;
bool retval=false;
if (d->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)
{
- kDebug() << "SMS::writeToSlotCSV(): " << endl;
+ kDebug() << k_funcinfo << endl;
QString text;
- QString filenameOut;
- filenameOut = dir + QDir::separator() + filename;
-
if((d->i_type & Unsent) || (d->i_type & Sent) )
{
text="\"OUTGOING\",";
for(QStringList::Iterator it=d->sl_numbers.begin(); it!=d->sl_numbers.end(); ++it)
text+="\"" + KMobileTools::KMobiletoolsHelper::translateNumber(*it) + "\",\"" + *it + "\",";
- //filenameOut = dir + QDir::separator() + "outbox_" + filename;
}
else
{
@@ -272,7 +268,6 @@
//text="\"INCOMING\",\"" + KMobileTools::KMobiletoolsHelper::translateNumber( getFrom() ) + "\",\"" + getFrom() + "\",";
text="\"INCOMING\",\"" + transNumber + "\",\"" + getFrom() + "\",";
- //filenameOut = dir + QDir::separator() + "inbox_" + filename;
}
text+="\"" + d->dt_datetime.toString( "%1, d %2 yyyy hh:mm:ss" )
@@ -282,8 +277,8 @@
//text+="\"" + KCodecs::quotedPrintableEncode( getText().utf8() ) + "\"";
//text+="\"" + getText().utf8() + "\"";
text+="\"" + getText() + "\"";
- kDebug() << "Writing sms to " << filenameOut << endl;
- QFile file(filenameOut);
+ kDebug() << "Writing sms to " << filename << endl;
+ QFile file(filename);
QString lastFile = file.readAll();
if(! file.open( QIODevice::WriteOnly | QIODevice::Append ) ) return false;
QTextStream stream( &file );
--- trunk/KDE/kdepim/kmobiletools/kmobiletools/libkmobiletools/sms.h #676011:676012
@@ -104,8 +104,8 @@
public Q_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);
Q_SIGNALS:
void updated();
};
--- trunk/KDE/kdepim/kmobiletools/kmobiletools/libkmobiletools/smslist.cpp #676011:676012
@@ -227,15 +227,18 @@
/*!
\fn SMSList::saveToCSV(const QString &engineName)
*/
-int SMSList::saveToCSV(const QString &engineName)
+int SMSList::saveToCSV(const QString &filename)
{
- int result;
-
- setEngineName(engineName);
- result = saveToCSV();
- kDebug() << "SMSList::saveToCSV(): " << endl;
-
- return result;
+ kDebug() << k_funcinfo << endl;
+ SMS *sms;
+ kdDebug() << "SMSList::saveToCSV(): saving CSV file to: " << filename << endl;
+ QListIterator<SMS*> it(*this);
+ bool ok=true;
+ while( (it.hasNext()) )
+ {
+ sms=it.next();
+ ok&=sms->writeToSlotCSV(filename);
+ }
}
/*!
@@ -243,22 +246,13 @@
*/
/// @TODO Check if we can remove dialog windows out of this class, emitting insteada signal.
-int SMSList::saveToCSV() const
+int SMSList::saveToCSV()
{
- QString dir=QDir::homePath();
- QListIterator<SMS*> it(*this);
QString saveFile;
saveFile = KFileDialog::getSaveFileName (QDir::homePath(), "*.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)) {
kDebug() << "SMSList::saveToCSV(): FILE ALREADY EXISTS " << endl;
int retval;
@@ -267,28 +261,14 @@
"KMobileTools" );
if(retval == KMessageBox::Continue) {
- d.remove(saveFile);
+ QFile::remove(saveFile);
}
else {
return -1;
}
}
-
- dir = savePath;
-
- if (dir.isEmpty() ) {
- dir = QDir::homePath();
- }
-
- kDebug() << "SMSList::saveToCSV(): saving CSV file to: " << dir << endl;
-
- while( it.hasNext() )
- {
- it.next()->exportCSV(dir, fileName);
- }
-
- return 1;
+ return saveToCSV(saveFile);
}
void SMSList::append( SMS *item )
--- trunk/KDE/kdepim/kmobiletools/kmobiletools/libkmobiletools/smslist.h #676011:676012
@@ -63,8 +63,8 @@
public Q_SLOTS:
void saveToMailBox(const QString &engineName);
void saveToMailBox() const;
- int saveToCSV(const QString &engineName);
- int saveToCSV() const;
+ int saveToCSV(const QString &filename);
+ int saveToCSV();
};
#endif
More information about the kmobiletools
mailing list