karm Library API Documentation

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  *      59 Temple Place - Suite 330
00018  *      Boston, MA  02111-1307  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 <qbuttongroup.h>
00029 #include <qcombobox.h>
00030 #include <qradiobutton.h>
00031 
00032 #include "csvexportdialog.h"
00033 #include "reportcriteria.h"
00034 
00035 CSVExportDialog::CSVExportDialog( ReportCriteria::REPORTTYPE rt,
00036                                   QWidget *parent, 
00037                                   const char *name
00038                                   ) 
00039   : CSVExportDialogBase( parent, name )
00040 {
00041   switch ( rt ) {
00042     case ReportCriteria::CSVTotalsExport:
00043       grpDateRange->setEnabled( false );      
00044       rc.reportType = rt;
00045       break;
00046     case ReportCriteria::CSVHistoryExport:
00047       grpDateRange->setEnabled( true );      
00048       rc.reportType = rt;
00049       break;
00050     default:
00051       break;
00052 
00053   }
00054 
00055   // If decimal symbol is a comma, then default field seperator to semi-colon.
00056   // In France and Germany, one-and-a-half is written as 1,5 not 1.5
00057   QString d = KGlobal::locale()->decimalSymbol();
00058   if ( "," == d ) CSVExportDialogBase::radioSemicolon->setChecked(true);
00059   else CSVExportDialogBase::radioComma->setChecked(true);
00060 
00061 }
00062 
00063 void CSVExportDialog::enableExportButton()
00064 {
00065   btnExport->setEnabled( !urlExportTo->lineEdit()->text().isEmpty() );
00066 }
00067 
00068 void CSVExportDialog::enableTasksToExportQuestion()
00069 {
00070   return;
00071   //grpTasksToExport->setEnabled( true );      
00072 }
00073 
00074 ReportCriteria CSVExportDialog::reportCriteria()
00075 {
00076   rc.url = urlExportTo->url();
00077   rc.from = dtFrom->date();
00078   rc.to = dtTo->date();
00079 
00080   // Hard code to true for now as the CSV export of totals does not support
00081   // this choice currenly and I'm trying to minimize pre-3.3 hacking at the
00082   // moment.
00083   rc.allTasks = true;
00084 
00085   QString t = grpTimeFormat->selected()->text(); 
00086   rc.decimalMinutes = ( t == i18n( "Decimal" ) );
00087 
00088   QString d = grpDelimiter->selected()->text(); 
00089   if      ( d == i18n( "Comma" ) )     rc.delimiter = ",";
00090   else if ( d == i18n( "Tab" ) )       rc.delimiter = "\t";
00091   else if ( d == i18n( "Semicolon" ) ) rc.delimiter = ";";
00092   else if ( d == i18n( "Space" ) )     rc.delimiter = " ";
00093   else if ( d == i18n( "Other:" ) )     rc.delimiter = txtOther->text();
00094   else {
00095     kdDebug(5970) 
00096       << "*** CSVExportDialog::reportCriteria: Unexpected delimiter choice '" 
00097       << d << "'--defaulting to a tab" << endl;
00098     rc.delimiter = "\t";
00099   }
00100 
00101   rc.quote = cboQuote->currentText();
00102 
00103   return rc;
00104 }
00105 
00106 #include "csvexportdialog.moc"
KDE Logo
This file is part of the documentation for karm Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu May 3 20:21:29 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003