csvexportdialog.cpp
00001 /* 00002 * Copyright (C) 2004 Mark Bucciarelli <mark@hubcapconsulting.com> 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License along 00015 * with this program; if not, write to the 00016 * Free Software Foundation, Inc. 00017 * 51 Franklin Street, Fifth Floor 00018 * Boston, MA 02110-1301 USA. 00019 * 00020 */ 00021 #include <kdateedit.h> 00022 #include <kdebug.h> 00023 #include <kglobal.h> 00024 #include <klineedit.h> 00025 #include <klocale.h> 00026 #include <kpushbutton.h> 00027 #include <kurlrequester.h> 00028 #include <tqbuttongroup.h> 00029 #include <tqcombobox.h> 00030 #include <tqradiobutton.h> 00031 00032 #include "csvexportdialog.h" 00033 #include "reportcriteria.h" 00034 00035 CSVExportDialog::CSVExportDialog( ReportCriteria::REPORTTYPE rt, 00036 TQWidget *parent, 00037 const char *name 00038 ) 00039 : CSVExportDialogBase( parent, name ) 00040 { 00041 switch ( rt ) { 00042 case ReportCriteria::CSVTotalsExport: 00043 grpDateRange->setEnabled( false ); 00044 grpDateRange->hide(); 00045 rc.reportType = rt; 00046 break; 00047 case ReportCriteria::CSVHistoryExport: 00048 grpDateRange->setEnabled( true ); 00049 rc.reportType = rt; 00050 break; 00051 default: 00052 break; 00053 00054 } 00055 00056 // If decimal symbol is a comma, then default field seperator to semi-colon. 00057 // In France and Germany, one-and-a-half is written as 1,5 not 1.5 00058 TQString d = KGlobal::locale()->decimalSymbol(); 00059 if ( "," == d ) CSVExportDialogBase::radioSemicolon->setChecked(true); 00060 else CSVExportDialogBase::radioComma->setChecked(true); 00061 00062 } 00063 00064 void CSVExportDialog::enableExportButton() 00065 { 00066 btnExport->setEnabled( !urlExportTo->lineEdit()->text().isEmpty() ); 00067 } 00068 00069 void CSVExportDialog::enableTasksToExportQuestion() 00070 { 00071 return; 00072 //grpTasksToExport->setEnabled( true ); 00073 } 00074 00075 ReportCriteria CSVExportDialog::reportCriteria() 00076 { 00077 rc.url = urlExportTo->url(); 00078 rc.from = dtFrom->date(); 00079 rc.to = dtTo->date(); 00080 00081 // Hard code to true for now as the CSV export of totals does not support 00082 // this choice currenly and I'm trying to minimize pre-3.3 hacking at the 00083 // moment. 00084 rc.allTasks = true; 00085 00086 TQString t = grpTimeFormat->selected()->name(); 00087 rc.decimalMinutes = ( t == i18n( "radioDecimal" ) ); 00088 00089 TQString d = grpDelimiter->selected()->name(); 00090 if ( d == "radioComma" ) rc.delimiter = ","; 00091 else if ( d == "radioTab" ) rc.delimiter = "\t"; 00092 else if ( d == "radioSemicolon" ) rc.delimiter = ";"; 00093 else if ( d == "radioSpace" ) rc.delimiter = " "; 00094 else if ( d == "radioOther" ) rc.delimiter = txtOther->text(); 00095 else { 00096 kdDebug(5970) 00097 << "*** CSVExportDialog::reportCriteria: Unexpected delimiter choice '" 00098 << d << "'--defaulting to a tab" << endl; 00099 rc.delimiter = "\t"; 00100 } 00101 00102 rc.quote = cboQuote->currentText(); 00103 00104 return rc; 00105 } 00106 00107 #include "csvexportdialog.moc"