karm

csvexportdialog.cpp
1 /*
2  * Copyright (C) 2004 Mark Bucciarelli <mark@hubcapconsulting.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the
16  * Free Software Foundation, Inc.
17  * 51 Franklin Street, Fifth Floor
18  * Boston, MA 02110-1301 USA.
19  *
20  */
21 #include <kdateedit.h>
22 #include <kdebug.h>
23 #include <tdeglobal.h>
24 #include <klineedit.h>
25 #include <tdelocale.h>
26 #include <kpushbutton.h>
27 #include <kurlrequester.h>
28 #include <tqbuttongroup.h>
29 #include <tqcombobox.h>
30 #include <tqradiobutton.h>
31 
32 #include "csvexportdialog.h"
33 #include "reportcriteria.h"
34 
35 CSVExportDialog::CSVExportDialog( ReportCriteria::REPORTTYPE rt,
36  TQWidget *parent,
37  const char *name
38  )
39  : CSVExportDialogBase( parent, name )
40 {
41  switch ( rt ) {
42  case ReportCriteria::CSVTotalsExport:
43  grpDateRange->setEnabled( false );
44  grpDateRange->hide();
45  rc.reportType = rt;
46  break;
47  case ReportCriteria::CSVHistoryExport:
48  grpDateRange->setEnabled( true );
49  rc.reportType = rt;
50  break;
51  default:
52  break;
53 
54  }
55 
56  // If decimal symbol is a comma, then default field seperator to semi-colon.
57  // In France and Germany, one-and-a-half is written as 1,5 not 1.5
58  TQString d = TDEGlobal::locale()->decimalSymbol();
59  if ( "," == d ) CSVExportDialogBase::radioSemicolon->setChecked(true);
60  else CSVExportDialogBase::radioComma->setChecked(true);
61 
62 }
63 
64 void CSVExportDialog::enableExportButton()
65 {
66  btnExport->setEnabled( !urlExportTo->lineEdit()->text().isEmpty() );
67 }
68 
69 void CSVExportDialog::enableTasksToExportQuestion()
70 {
71  return;
72  //grpTasksToExport->setEnabled( true );
73 }
74 
75 ReportCriteria CSVExportDialog::reportCriteria()
76 {
77  rc.url = urlExportTo->url();
78  rc.from = dtFrom->date();
79  rc.to = dtTo->date();
80 
81  // Hard code to true for now as the CSV export of totals does not support
82  // this choice currenly and I'm trying to minimize pre-3.3 hacking at the
83  // moment.
84  rc.allTasks = true;
85 
86  TQString t = grpTimeFormat->selected()->name();
87  rc.decimalMinutes = ( t == i18n( "radioDecimal" ) );
88 
89  TQString d = grpDelimiter->selected()->name();
90  if ( d == "radioComma" ) rc.delimiter = ",";
91  else if ( d == "radioTab" ) rc.delimiter = "\t";
92  else if ( d == "radioSemicolon" ) rc.delimiter = ";";
93  else if ( d == "radioSpace" ) rc.delimiter = " ";
94  else if ( d == "radioOther" ) rc.delimiter = txtOther->text();
95  else {
96  kdDebug(5970)
97  << "*** CSVExportDialog::reportCriteria: Unexpected delimiter choice '"
98  << d << "'--defaulting to a tab" << endl;
99  rc.delimiter = "\t";
100  }
101 
102  rc.quote = cboQuote->currentText();
103 
104  return rc;
105 }
106 
107 #include "csvexportdialog.moc"
Stores entries from export dialog.
REPORTTYPE
The different report types.
KURL url
For reports that write to a file, the filename to write to.