[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdepim/kpilot/kpilot
From: Adriaan de Groot <groot () kde ! org>
Date: 2005-01-20 1:44:07
Message-ID: 20050120014407.CBC161C1B3 () office ! kde ! org
[Download RAW message or body]
CVS commit by adridg:
One from the feature plan: export to CSV. This change adds a new button to the \
viewer. It's uncomfortable. This suggests that the viewers need a menu for actions, \
not buttons in the viewer pane.
A pilot-addresses.c 1.1 [no copyright GPL (v2+)]
M +72 -1 addressWidget.cc 1.74
M +1 -0 addressWidget.h 1.31
--- kdepim/kpilot/kpilot/addressWidget.cc #1.73:1.74
@@ -285,4 +285,10 @@ void AddressWidget::setupWidget()
i18n("<qt><i>Deleting is disabled by the 'internal editors' \
setting.</i></qt>") ;
+ button = new QPushButton(i18n("Export..."), this);
+ grid->addWidget(button, 3,1);
+ connect(button, SIGNAL(clicked()), this, SLOT(slotExport()));
+ QWhatsThis::add(button,
+ i18n("<qt>Export all addresses in the selected category to CSV \
format.</qt>") ); +
QWhatsThis::add(fDeleteButton,wt);
}
@@ -665,2 +671,67 @@ void AddressWidget::writeAddress(PilotAd
}
+#define plu_quiet 1
+#include "pilot-addresses.c"
+
+void AddressWidget::slotExport()
+{
+ FUNCTIONSETUP;
+
+ int currentCatID = findSelectedCategory(fCatList,
+ &(fAddressAppInfo.category));
+
+ QString saveFile = KFileDialog::getSaveFileName(
+ QString::null,
+ CSL1("*.csv|Comma Separated Values"),
+ this,
+ ( (currentCatID==-1) ?
+ i18n("Export All Addresses") :
+ i18n("Export Address Category \
%1").arg(PilotAppCategory::codec()->toUnicode(fAddressAppInfo.category.name[currentCatID]))));
+
+ if (saveFile.isEmpty())
+ {
+#ifdef DEBUG
+ DEBUGKPILOT << fname << ": No save file selected." << endl;
+#endif
+ return;
+ }
+ if (QFile::exists(saveFile) &&
+ KMessageBox::warningContinueCancel(this,
+ i18n("The file <i>%1</i> exists. Overwrite?").arg(saveFile),
+ i18n("Overwrite File?"),
+ i18n("Overwrite"))!=KMessageBox::Continue)
+ {
+#ifdef DEBUG
+ DEBUGKPILOT << fname << ": Overwrite file canceled." << endl;
+#endif
+ return;
+ }
+
+ FILE *f = fopen(QFile::encodeName(saveFile),"w");
+ if (!f)
+ {
+ KMessageBox::sorry(this,
+ i18n("The file <i>%1</i> could not be opened for \
writing.").arg(saveFile)); + return;
+ }
+ fAddressList.first();
+
+#ifdef DEBUG
+ DEBUGKPILOT << fname << ": Adding records..." << endl;
+#endif
+
+ while (fAddressList.current())
+ {
+ const PilotAddress *a = fAddressList.current();
+ if ((currentCatID == -1) ||
+ (a->getCat() == currentCatID))
+ {
+ write_record_CSV(f, &fAddressAppInfo, a->address(),
+ a->getAttrib(), a->getCat(), 0);
+ }
+ fAddressList.next();
+ }
+
+ fclose(f);
+}
+
--- kdepim/kpilot/kpilot/addressWidget.h #1.30:1.31
@@ -66,4 +66,5 @@ public slots:
void slotDeleteRecord();
void slotEditCancelled();
+ void slotExport();
void slotUpdateButtons(); // Enable/disable buttons
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic