Fix assert when Mail-Followup-To contains two emails, as Ossi's Mutt does
[kdepim.git] / ktimetracker / csvexportdialog.cpp
blob962185488d4987dc463389ef32bdb41bf0b355f3
1 /*
2 * Copyright (C) 2004 by Mark Bucciarelli <mark@hubcapconsulting.com>
3 * 2007 the ktimetracker developers
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the
17 * Free Software Foundation, Inc.
18 * 51 Franklin Street, Fifth Floor
19 * Boston, MA 02110-1301 USA.
23 #include "csvexportdialog.h"
25 #include <KDebug>
26 #include <KDateComboBox>
27 #include <KGlobal>
28 #include <KLocale>
29 #include <KPushButton>
30 #include <KLineEdit>
32 CSVExportDialog::CSVExportDialog( ReportCriteria::REPORTTYPE rt,
33 QWidget *parent
34 ) : CSVExportDialogBase( parent )
36 connect( button( User1 ), SIGNAL(clicked()),
37 this, SLOT(exPortToClipBoard()) );
38 connect( button( Ok ), SIGNAL(clicked()),
39 this, SLOT(exPortToCSVFile()) );
40 connect(urlExportTo,SIGNAL(textChanged(QString)), this, SLOT(enableExportButton()));
41 switch ( rt )
43 case ReportCriteria::CSVTotalsExport:
44 grpDateRange->setEnabled( false );
45 grpDateRange->hide();
46 rc.reportType = rt;
47 break;
48 case ReportCriteria::CSVHistoryExport:
49 grpDateRange->setEnabled( true );
50 rc.reportType = rt;
51 break;
52 default:
53 break;
56 // If decimal symbol is a comma, then default field separator to semi-colon.
57 // In France and Germany, one-and-a-half is written as 1,5 not 1.5
58 QString d = KGlobal::locale()->decimalSymbol();
59 if ( "," == d ) CSVExportDialogBase::radioSemicolon->setChecked(true);
60 else CSVExportDialogBase::radioComma->setChecked(true);
63 void CSVExportDialog::enableExportButton()
65 enableButton( Ok, !urlExportTo->lineEdit()->text().isEmpty() );
68 void CSVExportDialog::enableTasksToExportQuestion()
70 return;
71 //grpTasksToExport->setEnabled( true );
74 void CSVExportDialog::exPortToClipBoard()
76 rc.bExPortToClipBoard=true;
77 accept();
80 void CSVExportDialog::exPortToCSVFile()
82 rc.bExPortToClipBoard=false;
83 accept();
86 ReportCriteria CSVExportDialog::reportCriteria()
88 rc.url = urlExportTo->url();
89 rc.from = dtFrom->date();
90 rc.to = dtTo->date();
91 rc.decimalMinutes = ( combodecimalminutes->currentText() == i18nc( "format to display times", "Decimal" ) );
92 kDebug(5970) <<"rc.decimalMinutes is" << rc.decimalMinutes;
94 if ( radioComma->isChecked() ) rc.delimiter = ",";
95 else if ( radioTab->isChecked() ) rc.delimiter = "\t";
96 else if ( radioSemicolon->isChecked() ) rc.delimiter = ";";
97 else if ( radioSpace->isChecked() ) rc.delimiter = " ";
98 else if ( radioOther->isChecked() ) rc.delimiter = txtOther->text();
99 else
101 kDebug(5970) << "*** CSVExportDialog::reportCriteria: Unexpected delimiter choice '";
102 rc.delimiter = "\t";
105 rc.quote = cboQuote->currentText();
106 rc.sessionTimes = (i18n("Session Times") == combosessiontimes->currentText());
107 rc.allTasks = (i18n("All Tasks") == comboalltasks->currentText());
108 return rc;
111 #include "csvexportdialog.moc"