From kde-commits Mon Jan 31 23:37:23 2011 From: =?utf-8?q?Stefan_B=C3=B6hmann?= Date: Mon, 31 Jan 2011 23:37:23 +0000 To: kde-commits Subject: =?utf-8?q?=5Bknipptasch=5D_plugins=3A_add_xml_plugin_and_cleanup?= Message-Id: <20110131233723.A25C4A60D1 () git ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=129651718606265 Git commit 09ebe3bcaf46e95f49c62f63f7e0a1dd5ae8cd05 by Stefan Böhmann. Pushed by sboehmann into branch 'master'. add xml plugin and cleanup M +3 -4 plugins/CMakeLists.txt A +56 -0 plugins/csv/CMakeLists.txt [License: UNKNOWN] A +399 -0 plugins/csv/csvexportdialog.cpp [License: GPL (v2+)] A +74 -0 plugins/csv/csvexportdialog.h [License: GPL (v2+)] A +597 -0 plugins/csv/csvexportdialog.ui [License: UNKNOWN] A +75 -0 plugins/csv/csvexportplugin.cpp [License: GPL (v2+)] A +52 -0 plugins/csv/csvexportplugin.h [License: GPL (v2+)] A +104 -0 plugins/csv/csvimportdialog.cpp [License: GPL (v2+)] A +58 -0 plugins/csv/csvimportdialog.h [License: GPL (v2+)] A +317 -0 plugins/csv/csvimportdialog.ui [License: UNKNOWN] A +85 -0 plugins/csv/csvimportplugin.cpp [License: GPL (v2+)] A +52 -0 plugins/csv/csvimportplugin.h [License: GPL (v2+)] D +0 -24 plugins/csv_export/CMakeLists.txt D +0 -399 plugins/csv_export/csvexportdialog.cpp D +0 -74 plugins/csv_export/csvexportdialog.h D +0 -597 plugins/csv_export/csvexportdialog.ui D +0 -75 plugins/csv_export/csvexportplugin.cpp D +0 -52 plugins/csv_export/csvexportplugin.h D +0 -24 plugins/csv_import/CMakeLists.txt D +0 -104 plugins/csv_import/csvimportdialog.cpp D +0 -58 plugins/csv_import/csvimportdialog.h D +0 -317 plugins/csv_import/csvimportdialog.ui D +0 -85 plugins/csv_import/csvimportplugin.cpp D +0 -52 plugins/csv_import/csvimportplugin.h A +15 -0 plugins/demo/CMakeLists.txt [License: UNKNOWN] A +245 -0 plugins/demo/demoimportplugin.cpp [License: GPL (v2+)] A +52 -0 plugins/demo/demoimportplugin.h [License: GPL (v2+)] D +0 -15 plugins/demo_import/CMakeLists.txt D +0 -245 plugins/demo_import/demoimportplugin.cpp D +0 -52 plugins/demo_import/demoimportplugin.h A +56 -0 plugins/xml/CMakeLists.txt [License: UNKNOWN] M +23 -1 plugins/xml/xmlexportplugin.cpp M +11 -3 plugins/xml/xmlexportplugin.h M +23 -1 plugins/xml/xmlimportplugin.cpp M +11 -3 plugins/xml/xmlimportplugin.h http://commits.kde.org/knipptasch/09ebe3bcaf46e95f49c62f63f7e0a1dd5ae8cd05 diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index ddafc5a..a122b7e 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -3,8 +3,7 @@ set( knipptasch_plugin_MINOR_VERSION ${knipptasch_MINOR_VERSION} ) set( knipptasch_plugin_PATCH_LEVEL ${knipptasch_PATCH_LEVEL} ) set( knipptasch_plugin_VERSION_SUFFIX ${knipptasch_VERSION_SUFFIX} ) -macro_optional_add_subdirectory( csv_export ) -macro_optional_add_subdirectory( csv_import ) -macro_optional_add_subdirectory( demo_import ) -#macro_optional_add_subdirectory( xml ) +macro_optional_add_subdirectory( csv ) +macro_optional_add_subdirectory( demo ) +macro_optional_add_subdirectory( xml ) diff --git a/plugins/csv/CMakeLists.txt b/plugins/csv/CMakeLists.txt new file mode 100644 index 0000000..777d1b7 --- /dev/null +++ b/plugins/csv/CMakeLists.txt @@ -0,0 +1,56 @@ +project( knipptasch_csv_plugin ) + + +################################################################################### +#### knipptasch_csv_export_plugin +################################################################################### + +set( knipptasch_export_plugin_SOURCES + csvexportdialog.cpp + csvexportplugin.cpp + ) + +set( knipptasch_export_plugin_HEADERS + csvexportdialog.h + csvexportplugin.h + ) + +set( knipptasch_export_plugin_FORMS + csvexportdialog.ui + ) + +qt4_wrap_ui( knipptasch_export_plugin_SOURCES ${knipptasch_export_plugin_FORMS} ) +qt4_wrap_cpp( knipptasch_export_plugin_SOURCES ${knipptasch_export_plugin_HEADERS} ) + +add_library( knipptasch_csv_export_plugin SHARED ${knipptasch_export_plugin_SOURCES} ) +target_link_libraries( knipptasch_csv_export_plugin ${QT_LIBRARIES} knipptasch compat ) + +install( TARGETS knipptasch_csv_export_plugin DESTINATION ${KNIPPTASCH_PLUGIN_INSTALL_DIR} ) + + + +################################################################################### +#### knipptasch_csv_import_plugin +################################################################################### + +set( knipptasch_import_plugin_SOURCES + csvimportdialog.cpp + csvimportplugin.cpp + ) + +set( knipptasch_import_plugin_HEADERS + csvimportdialog.h + csvimportplugin.h + ) + +set( knipptasch_import_plugin_FORMS + csvimportdialog.ui + ) + +qt4_wrap_ui( knipptasch_import_plugin_SOURCES ${knipptasch_import_plugin_FORMS} ) +qt4_wrap_cpp( knipptasch_import_plugin_SOURCES ${knipptasch_import_plugin_HEADERS} ) + +add_library( knipptasch_csv_import_plugin SHARED ${knipptasch_import_plugin_SOURCES} ) +target_link_libraries( knipptasch_csv_import_plugin ${QT_LIBRARIES} knipptasch compat ) + +install( TARGETS knipptasch_csv_import_plugin DESTINATION ${KNIPPTASCH_PLUGIN_INSTALL_DIR} ) diff --git a/plugins/csv/csvexportdialog.cpp b/plugins/csv/csvexportdialog.cpp new file mode 100644 index 0000000..f745225 --- /dev/null +++ b/plugins/csv/csvexportdialog.cpp @@ -0,0 +1,399 @@ +/* + * Copyright 2010 by Stefan Böhmann + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include "csvexportdialog.h" +#include "ui_csvexportdialog.h" + +#include "backend/account.h" +#include "backend/posting.h" +#include "backend/money.h" + +#include "compat/iconloader.h" + +#include +#include +#include +#include +#include + +#include + +#if defined(HAVE_KDE) +#include +#include +#else +#include +#include +#endif + +#include +#include +#include + +#include + +#include + + + +CsvExportDialog::CsvExportDialog(const Account *account, const QList &selected, QWidget *parent) + : QDialog( parent ), + ui( new Ui::CsvExportDialog ), + m_account( account ), + m_selectedPostings( selected ), + m_updateTimer( new QTimer( this ) ) +{ + Q_ASSERT( m_account ); + + ui->setupUi( this ); + + setWindowTitle( tr( "CSV Export - %1" ).arg( QCoreApplication::applicationName() ) ); + ui->iconLabel->setPixmap( DesktopIcon("text-csv") ); + + m_updateTimer->setInterval( 300 ); + + ui->allInYearEdit->setDate( QDate::currentDate() ); + ui->allBetweenDateStart->setDate( account->openingDate().isValid() + ? account->openingDate() + : QDate( 1, 1, QDate::currentDate().year() ) + ); + ui->allBetweenDateEnd->setDate( QDate::currentDate() ); + + if( !m_selectedPostings.isEmpty() ) { + ui->selected->setEnabled( true ); + ui->selected->setChecked( true ); + } + else { + ui->selected->setEnabled( false ); + ui->all->setChecked( true ); + } + + const QLocale l; + + ui->decimalSymbol->clear(); + ui->decimalSymbol->addItem( "" ); + ui->decimalSymbol->addItem( "," ); + ui->decimalSymbol->addItem( "." ); + if( ui->decimalSymbol->findText( l.decimalPoint() ) < 0 ) { + ui->decimalSymbol->addItem( l.decimalPoint() ); + } + Q_ASSERT( ui->decimalSymbol->findText( l.decimalPoint() ) >= 0 ); + ui->decimalSymbol->setCurrentIndex( ui->decimalSymbol->findText( l.decimalPoint() ) ); + + ui->decimalSymbol->setEnabled( false ); //TODO + + ui->thousandsSeparator->clear(); + ui->thousandsSeparator->addItem( "" ); + ui->thousandsSeparator->addItem( "." ); + ui->thousandsSeparator->setCurrentIndex( 0 ); + ui->thousandsSeparator->setEnabled( false ); //TODO + + ui->textquote->clear(); + ui->textquote->addItem( "" ); + ui->textquote->addItem( "\"" ); + ui->textquote->addItem( "'" ); + ui->textquote->addItem( "`" ); + ui->textquote->setCurrentIndex( 1 ); + + ui->delimiter->clear(); + ui->delimiter->addItem( "" ); + ui->delimiter->addItem( tr( "Comma" ), "," ); + ui->delimiter->addItem( tr( "Tabulator" ), "\t" ); + ui->delimiter->addItem( tr( "Semicolon" ), ";" ); + ui->delimiter->addItem( tr( "Space" ), " " ); + ui->delimiter->setCurrentIndex( 3 ); + + QString df = tr( + "

These expressions may be used for the date format:

" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "
ExpressionOutput
dThe day as a number without a leading zero (1 to 31)
ddThe day as a number with a leading zero (01 to 31)
dddThe abbreviated localized day name (e.g. 'Mon' to 'Sun')
ddddThe long localized day name (e.g. 'Monday' to 'Sunday')
MThe month as a number without a leading zero (1 to 12)
MMThe month as a number with a leading zero (01 to 12)
MMMThe abbreviated localized month name (e.g. 'Jan' to 'Dec')
MMMMThe long localized month name (e.g. 'January' to 'December')
yyThe year as two digit number (00 to 99)
yyyyThe year as four digit number
" + "" + "" + "" + "" + "" + "" + ) + .arg( "ddd MMM d yyyy" ) + .arg( "yyyy-MM-dd" ) + .arg( l.dateFormat( QLocale::ShortFormat ) ) + .arg( l.dateFormat( QLocale::LongFormat ) ); + + ui->dateFormat->setToolTip( df ); + ui->dateFormat->setWhatsThis( df ); + + ui->dateFormat->clear(); + ui->dateFormat->addItem( "" ); + ui->dateFormat->addItem( tr( "Text Date" ), "ddd MMM d yyyy" ); + ui->dateFormat->addItem( tr( "ISO Date" ), "yyyy-MM-dd" ); + ui->dateFormat->addItem( tr( "Short Date" ), l.dateFormat( QLocale::ShortFormat ) ); + ui->dateFormat->addItem( tr( "Long Date" ), l.dateFormat( QLocale::LongFormat ) ); + ui->dateFormat->setCurrentIndex( 2 ); + + ui->encoding->clear(); + foreach(const QByteArray &name, QTextCodec::availableCodecs() ) { + ui->encoding->addItem( name, name ); + } + ui->encoding->setCurrentIndex( ui->encoding->findData( + QTextCodec::codecForLocale()->name() ) ); + + ui->endOfLine->clear(); + ui->endOfLine->addItem( tr( "Unix" ), "\n" ); + ui->endOfLine->addItem( tr( "Windows/DOS" ), "\r\n" ); + ui->endOfLine->addItem( tr( "Macintosh" ), "\r" ); + +#if defined( Q_WS_WIN ) + ui->endOfLine->setCurrentIndex( 1 ); +#elif defined( Q_WS_MAC ) + ui->endOfLine->setCurrentIndex( 2 ); +#else + ui->endOfLine->setCurrentIndex( 0 ); +#endif + + ui->buttonBox->button( QDialogButtonBox::Save )->setEnabled( false ); + + connect( ui->delimiter, SIGNAL( activated(int) ), + this, SLOT( onDelimiterComboBoxIndexChanged(int) ) ); + connect( ui->delimiter->lineEdit(), SIGNAL( textEdited(QString) ), + this, SLOT( onDelimiterComboBoxTextChanged() ) ); + + connect( ui->dateFormat, SIGNAL( activated(int) ), + this, SLOT( onDateFormatComboBoxIndexChanged(int) ) ); + connect( ui->dateFormat->lineEdit(), SIGNAL( textEdited(QString) ), + this, SLOT( onDateFormatComboBoxTextChanged() ) ); + + connect( ui->all, SIGNAL( toggled(bool) ), + this, SLOT( onStartUpdateTimer() ) ); + connect( ui->selected, SIGNAL( toggled(bool) ), + this, SLOT( onStartUpdateTimer() ) ); + connect( ui->allInYear, SIGNAL( toggled(bool) ), + this, SLOT( onStartUpdateTimer() ) ); + connect( ui->allBetween, SIGNAL( toggled(bool) ), + this, SLOT( onStartUpdateTimer() ) ); + connect( ui->allInYearEdit, SIGNAL( dateChanged(QDate) ), + this, SLOT( onStartUpdateTimer() ) ); + connect( ui->allBetweenDateStart, SIGNAL( dateChanged(QDate) ), + this, SLOT( onStartUpdateTimer() ) ); + connect( ui->allBetweenDateEnd, SIGNAL( dateChanged(QDate) ), + this, SLOT( onStartUpdateTimer() ) ); + connect( ui->textquote, SIGNAL( editTextChanged(QString) ), + this, SLOT( onStartUpdateTimer() ) ); + connect( ui->decimalSymbol, SIGNAL( editTextChanged(QString) ), + this, SLOT( onStartUpdateTimer() ) ); + connect( ui->thousandsSeparator, SIGNAL( editTextChanged(QString) ), + this, SLOT( onStartUpdateTimer() ) ); + connect( ui->encoding, SIGNAL( activated(int) ), + this, SLOT( onStartUpdateTimer() ) ); + connect( ui->endOfLine, SIGNAL( activated(int) ), + this, SLOT( onStartUpdateTimer() ) ); + + connect( ui->buttonBox->button( QDialogButtonBox::Save ), SIGNAL( clicked() ), + this, SLOT( onSave() ) ); + + connect( m_updateTimer, SIGNAL( timeout() ), + this, SLOT( onUpdatePreview() ) ); + + onDateFormatComboBoxIndexChanged( ui->dateFormat->currentIndex() ); + onDelimiterComboBoxIndexChanged( ui->delimiter->currentIndex() ); +} + + +CsvExportDialog::~CsvExportDialog() +{ + delete ui; +} + + +void CsvExportDialog::onStartUpdateTimer() +{ + Q_ASSERT( ui->buttonBox->button( QDialogButtonBox::Save ) ); + + ui->buttonBox->button( QDialogButtonBox::Save )->setEnabled( false ); + + m_updateTimer->start(); +} + + +void CsvExportDialog::onUpdatePreview() +{ + ui->preview->clear(); + ui->rowCountLabel->setText( QString::number( 0 ) ); + ui->columnCountLabel->setText( QString::number( 0 ) ); + ui->characterCountLabel->setText( QString::number( 0 ) ); + + m_result.clear(); + + QList postings; + + if( ui->all->isChecked() ) { + postings = m_account->postings(); + } + else if( ui->selected->isChecked() ) { + postings = m_selectedPostings; + } + else if( ui->allInYear->isChecked() ) { + QList plist = m_account->postings(); + int year = ui->allInYearEdit->date().year(); + + foreach(const Posting *p, plist) { + if( ( p->maturity().isValid() && p->maturity().year() == year ) || + ( p->valueDate().isValid() && p->valueDate().year() == year ) ) { + postings.append( p ); + } + } + } + else if( ui->allBetween->isChecked() ) { + QList plist = m_account->postings(); + + QDate start = ui->allBetweenDateStart->date(); + QDate end = ui->allBetweenDateEnd->date() > start + ? ui->allBetweenDateEnd->date() + : start; + + Q_ASSERT( start.isValid() ); + Q_ASSERT( end.isValid() ); + + foreach(const Posting *p, plist) { + if( ( p->maturity().isValid() && p->maturity() >= start && p->maturity() <= end ) || + ( p->valueDate().isValid() && p->valueDate() >= start && p->valueDate() <= end ) ) { + postings.append( p ); + } + } + } + else { + Q_ASSERT( false ); + } + + QString eof = ui->endOfLine->itemData( ui->endOfLine->currentIndex() ).toString(); + QString tq = ui->textquote->currentText(); + + QBuffer buffer( &m_result ); + buffer.open( QIODevice::WriteOnly ); + + QTextStream out( &buffer ); + out.setCodec( QTextCodec::codecForName( + ui->encoding->itemData( ui->encoding->currentIndex() ) + .toByteArray() + ) ); + + for(int i = 0; i < postings.size(); ++i) { + const Posting *p = postings[ i ]; + + out << tq << p->valueDate().toString( m_dateFormat ) << tq << m_delimiter; + out << tq << p->postingText() << tq << m_delimiter; + out << tq << p->maturity().toString( m_dateFormat ) << tq << m_delimiter; + out << tq << p->amount().toString() << tq << m_delimiter; + out << eof; + } + + buffer.close(); + + ui->rowCountLabel->setText( QString::number( postings.size() ) ); + ui->columnCountLabel->setText( QString::number( postings.size() * 4 ) ); + ui->characterCountLabel->setText( QString::number( m_result.size() ) ); + + ui->preview->setPlainText( m_result ); + + Q_ASSERT( ui->buttonBox->button( QDialogButtonBox::Save ) ); + ui->buttonBox->button( QDialogButtonBox::Save ) + ->setEnabled( !m_result.isEmpty() ); +} + +void CsvExportDialog::onSave() +{ + hide(); + + QString filename; + +#if defined(HAVE_KDE) + filename = KFileDialog::getSaveFileName( KUrl(), "*.csv|" + tr( "All Supported Files" ), this ); +#else + filename = QFileDialog::getSaveFileName( this, // krazy:exclude=qclasses + tr( "Export File - %1" ).arg( QCoreApplication::applicationName() ), + QString(), tr( "All Supported Files" ) + " (*.csv)" + ); +#endif + + if( filename.isEmpty() ) { + rejected(); + return; + } + + QFile file( filename ); + if( !file.open( QIODevice::WriteOnly ) ) { + QString message = tr( "The file given could not be written; " + "check whether it exists or is writeable " + "for the current user." ); +#if defined(HAVE_KDE) + KMessageBox::error( parentWidget(), message ); +#else + QMessageBox::warning( parentWidget(), // krazy:exclude=qclasses + tr( "Error - %1" ) + .arg( QCoreApplication::applicationName() ), + message ); +#endif + reject(); + return; + } + + file.write( m_result ); + file.close(); + + accept(); +} + + +void CsvExportDialog::onDelimiterComboBoxIndexChanged(int index) +{ + m_delimiter = ui->delimiter->itemData( index ).toString(); + onStartUpdateTimer(); +} + + +void CsvExportDialog::onDelimiterComboBoxTextChanged() +{ + m_delimiter = ui->delimiter->currentText(); + onStartUpdateTimer(); +} + + +void CsvExportDialog::onDateFormatComboBoxIndexChanged(int index) +{ + m_dateFormat = ui->dateFormat->itemData( index ).toString(); + onStartUpdateTimer(); +} + + +void CsvExportDialog::onDateFormatComboBoxTextChanged() +{ + m_dateFormat = ui->dateFormat->currentText(); + onStartUpdateTimer(); +} + + +// kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; replace-tabs on; space-indent on; +// vim:set spell et sw=4 ts=4 nowrap cino=l1,cs,U1: diff --git a/plugins/csv/csvexportdialog.h b/plugins/csv/csvexportdialog.h new file mode 100644 index 0000000..68698f3 --- /dev/null +++ b/plugins/csv/csvexportdialog.h @@ -0,0 +1,74 @@ +/* + * Copyright 2010 by Stefan Böhmann + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#ifndef CSVEXPORTDIALOG_H +#define CSVEXPORTDIALOG_H + +#include +#include + +class QTimer; +class Posting; +class Account; + +namespace Ui +{ + class CsvExportDialog; +} + + +/** + * @class CsvExportDialog + * @brief + * + * @author Stefan Böhmann + */ +class CsvExportDialog : public QDialog +{ + Q_OBJECT + + public: + CsvExportDialog(const Account *account, const QList &selected, QWidget *parent = 0); + ~CsvExportDialog(); + + private slots: + void onStartUpdateTimer(); + void onUpdatePreview(); + + void onSave(); + + void onDelimiterComboBoxIndexChanged(int); + void onDelimiterComboBoxTextChanged(); + + void onDateFormatComboBoxIndexChanged(int index); + void onDateFormatComboBoxTextChanged(); + + private: + Ui::CsvExportDialog *ui; + + const Account *m_account; + QList m_selectedPostings; + + QString m_delimiter; + QString m_dateFormat; + QByteArray m_result; + QTimer *m_updateTimer; +}; + +#endif + +// kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; replace-tabs on; space-indent on; +// vim:set spell et sw=4 ts=4 nowrap cino=l1,cs,U1: diff --git a/plugins/csv/csvexportdialog.ui b/plugins/csv/csvexportdialog.ui new file mode 100644 index 0000000..8307a1c --- /dev/null +++ b/plugins/csv/csvexportdialog.ui @@ -0,0 +1,597 @@ + + + Stefan Böhmann + CsvExportDialog + + + + 0 + 0 + 699 + 632 + + + + + 0 + 0 + + + + + + + Settings + + + + + + QFormLayout::ExpandingFieldsGrow + + + + + Date format: + + + dateFormat + + + + + + + true + + + -1 + + + 8 + + + + + + + Decimal symbol: + + + decimalSymbol + + + + + + + true + + + 8 + + + + + + + Thousands separator: + + + thousandsSeparator + + + + + + + true + + + 8 + + + + + + + + + QFormLayout::ExpandingFieldsGrow + + + + + Encoding: + + + encoding + + + + + + + 8 + + + + + + + End of Line: + + + endOfLine + + + + + + + 8 + + + + + + + + + QFormLayout::ExpandingFieldsGrow + + + + + Delimiter: + + + delimiter + + + + + + + true + + + -1 + + + 8 + + + + + + + Text quote: + + + textquote + + + + + + + true + + + -1 + + + 8 + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Save + + + + + + + Selection + + + + + + All + + + true + + + + + + + Selected + + + + + + + + + All in: + + + + + + + false + + + yyyy + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + All between: + + + + + + + false + + + M/d/yyyy + + + + + + + false + + + and + + + + + + + false + + + M/d/yyyy + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + icon + + + + + + + + 0 + 0 + + + + + 75 + true + + + + CSV Export + + + 3 + + + 5 + + + + + + + + + Preview + + + + -1 + + + 0 + + + 2 + + + + + + DejaVu Sans Mono + 7 + + + + Rows: + + + + + + + + 0 + 0 + + + + + DejaVu Sans Mono + 7 + + + + 0 + + + + + + + + DejaVu Sans Mono + 7 + + + + Columns: + + + + + + + + 0 + 0 + + + + + DejaVu Sans Mono + 7 + + + + 0 + + + + + + + + DejaVu Sans Mono + 7 + + + + Characters: + + + + + + + + 0 + 0 + + + + + DejaVu Sans Mono + 7 + + + + 0 + + + + + + + false + + + true + + + + + + + + + + + KComboBox + QComboBox +
kcombobox.h
+
+
+ + selected + all + allInYear + allInYearEdit + allBetween + allBetweenDateStart + allBetweenDateEnd + delimiter + textquote + dateFormat + decimalSymbol + thousandsSeparator + encoding + endOfLine + buttonBox + + + + + allInYear + toggled(bool) + allInYearEdit + setEnabled(bool) + + + 70 + 143 + + + 157 + 146 + + + + + allBetween + toggled(bool) + allBetweenDateStart + setEnabled(bool) + + + 86 + 176 + + + 259 + 179 + + + + + allBetween + toggled(bool) + label + setEnabled(bool) + + + 121 + 176 + + + 290 + 179 + + + + + allBetween + toggled(bool) + allBetweenDateEnd + setEnabled(bool) + + + 29 + 176 + + + 423 + 179 + + + + + buttonBox + rejected() + CsvExportDialog + reject() + + + 584 + 415 + + + 593 + 487 + + + + +
diff --git a/plugins/csv/csvexportplugin.cpp b/plugins/csv/csvexportplugin.cpp new file mode 100644 index 0000000..0f8a9d3 --- /dev/null +++ b/plugins/csv/csvexportplugin.cpp @@ -0,0 +1,75 @@ +/* + * Copyright 2010 by Stefan Böhmann + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include "csvexportplugin.h" +#include "csvexportdialog.h" + +#include "compat/iconloader.h" + +#include + + +CsvExportPlugin::CsvExportPlugin(QObject *parent) + : QObject( parent ) +{ +} + + +QByteArray CsvExportPlugin::pluginIdentifier() const +{ + return "csv_export_plugin"; +} + + +QString CsvExportPlugin::pluginName() const +{ + return tr( "CSV Export Plugin" ); + +} + + +QByteArray CsvExportPlugin::pluginVersion() const +{ + return "0.0.1"; +} + + +QString CsvExportPlugin::exportActionName() const +{ + return QObject::tr( "Export &CSV File..." ); +} + + +QPixmap CsvExportPlugin::exportActionIcon() const +{ + return BarIcon("text-csv"); +} + + +void CsvExportPlugin::exportAccount(const Account *account, const QList &selected, QWidget *parent) const +{ + QPointer dialog = new CsvExportDialog( account, selected, parent ); + + dialog->exec(); + + delete dialog; +} + + +Q_EXPORT_PLUGIN2( "CsvExportPlugin", CsvExportPlugin ); + +// kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; replace-tabs on; space-indent on; +// vim:set spell et sw=4 ts=4 nowrap cino=l1,cs,U1: diff --git a/plugins/csv/csvexportplugin.h b/plugins/csv/csvexportplugin.h new file mode 100644 index 0000000..2c1727e --- /dev/null +++ b/plugins/csv/csvexportplugin.h @@ -0,0 +1,52 @@ +/* + * Copyright 2010 by Stefan Böhmann + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#ifndef CSVEXPORTPLUGIN_H +#define CSVEXPORTPLUGIN_H + +#include + + +/** + * @class CsvExportPlugin + * @brief + * + * @author Stefan Böhmann + */ +class CsvExportPlugin : public QObject, public Knipptasch::ExportPlugin +{ + Q_OBJECT + Q_INTERFACES( Knipptasch::Plugin ) + Q_INTERFACES( Knipptasch::ExportPlugin ) + + public: + CsvExportPlugin(QObject *parent = 0); + + QByteArray pluginIdentifier() const; + QString pluginName() const; + QByteArray pluginVersion() const; + + QString exportActionName() const; + QPixmap exportActionIcon() const; + + void exportAccount(const Account *account, const QList &selected, QWidget *parent = 0) const; +}; + + +#endif + +// kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; replace-tabs on; space-indent on; +// vim:set spell et sw=4 ts=4 nowrap cino=l1,cs,U1: diff --git a/plugins/csv/csvimportdialog.cpp b/plugins/csv/csvimportdialog.cpp new file mode 100644 index 0000000..05a208d --- /dev/null +++ b/plugins/csv/csvimportdialog.cpp @@ -0,0 +1,104 @@ +/* + * Copyright 2010 by Stefan Böhmann + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include "csvimportdialog.h" +#include "ui_csvimportdialog.h" + +#include "backend/account.h" + +#include "compat/iconloader.h" + +#include +#include +#include + +#include + +#include + + +CsvImportDialog::CsvImportDialog(QWidget *parent) + : QDialog( parent ), + ui( new Ui::CsvImportDialog ) +{ + ui->setupUi( this ); + + setWindowTitle( tr( "CSV Import - %1" ).arg( QCoreApplication::applicationName() ) ); + ui->iconLabel->setPixmap( DesktopIcon("text-csv") ); + + ui->fileButton->setIcon( BarIcon("document-open") ); + + ui->delimiter->clear(); + ui->delimiter->addItem( "" ); + ui->delimiter->addItem( tr( "Comma" ), ',' ); + ui->delimiter->addItem( tr( "Tabulator" ), '\t' ); + ui->delimiter->addItem( tr( "Semicolon" ), ';' ); + ui->delimiter->addItem( tr( "Space" ), ' ' ); + ui->delimiter->setCurrentIndex( 3 ); + m_delimiter = ui->delimiter->itemData( 3 ).toChar(); + + ui->encoding->clear(); + foreach(const QByteArray &name, QTextCodec::availableCodecs() ) { + ui->encoding->addItem( name, name ); + } + ui->encoding->setCurrentIndex( ui->encoding->findData( QTextCodec::codecForLocale()->name() ) ); + + ui->endOfLine->clear(); + ui->endOfLine->addItem( tr( "Unix" ) ); + ui->endOfLine->addItem( tr( "Windows/DOS" ) ); + ui->endOfLine->addItem( tr( "Macintosh" ) ); + +#if defined( Q_WS_WIN ) + ui->endOfLine->setCurrentIndex( 1 ); +#elif defined( Q_WS_MAC ) + ui->endOfLine->setCurrentIndex( 2 ); +#else + ui->endOfLine->setCurrentIndex( 0 ); +#endif + + connect( ui->delimiter, SIGNAL( activated(int) ), this, SLOT( onDelimiterComboBoxIndexChanged(int) ) ); + connect( ui->delimiter->lineEdit(), SIGNAL( textEdited(QString) ), this, SLOT( onDelimiterComboBoxTextChanged() ) ); +} + + +CsvImportDialog::~CsvImportDialog() +{ + delete ui; +} + + +Account* CsvImportDialog::account() const +{ + return 0; +} + + +void CsvImportDialog::onDelimiterComboBoxIndexChanged(int index) +{ + m_delimiter = ui->delimiter->itemData( index ).toChar(); +} + + +void CsvImportDialog::onDelimiterComboBoxTextChanged() +{ + m_delimiter = ui->delimiter->currentText(); +} + + + + +// kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; replace-tabs on; space-indent on; +// vim:set spell et sw=4 ts=4 nowrap cino=l1,cs,U1: diff --git a/plugins/csv/csvimportdialog.h b/plugins/csv/csvimportdialog.h new file mode 100644 index 0000000..a87e308 --- /dev/null +++ b/plugins/csv/csvimportdialog.h @@ -0,0 +1,58 @@ +/* + * Copyright 2010 by Stefan Böhmann + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#ifndef CSVIMPORTDIALOG_H +#define CSVIMPORTDIALOG_H + +#include + +class Account; + +namespace Ui +{ + class CsvImportDialog; +} + + +/** + * @class CsvImportDialog + * @brief + * + * @author Stefan Böhmann + */ +class CsvImportDialog : public QDialog +{ + Q_OBJECT + + public: + CsvImportDialog(QWidget *parent = 0); + ~CsvImportDialog(); + + Account* account() const; + + private slots: + void onDelimiterComboBoxIndexChanged(int); + void onDelimiterComboBoxTextChanged(); + + private: + QString m_delimiter; + Ui::CsvImportDialog *ui; +}; + +#endif + +// kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; replace-tabs on; space-indent on; +// vim:set spell et sw=4 ts=4 nowrap cino=l1,cs,U1: diff --git a/plugins/csv/csvimportdialog.ui b/plugins/csv/csvimportdialog.ui new file mode 100644 index 0000000..7fa8770 --- /dev/null +++ b/plugins/csv/csvimportdialog.ui @@ -0,0 +1,317 @@ + + + Stefan Böhmann + CsvImportDialog + + + + 0 + 0 + 923 + 438 + + + + + 0 + 0 + + + + + + + + + icon + + + + + + + + 0 + 0 + + + + + 75 + true + + + + CSV Import + + + 3 + + + 5 + + + + + + + + + + + File to import: + + + + + + + + + + + + + + + + + + + + + + + Settings + + + + + + QFormLayout::ExpandingFieldsGrow + + + + + Delimiter: + + + + + + + true + + + -1 + + + 8 + + + + + + + Text quote: + + + + + + + true + + + -1 + + + 8 + + + + + + + Ignore duplicate delimiters + + + + + + + + + QFormLayout::ExpandingFieldsGrow + + + + + Date format: + + + + + + + true + + + -1 + + + 8 + + + + + + + Decimal symbol: + + + + + + + true + + + 8 + + + + + + + Thousands separator: + + + + + + + true + + + 8 + + + + + + + + + + + Encoding: + + + + + + + 8 + + + + + + + End of Line: + + + + + + + 8 + + + + + + + Skip first row of file + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + 1 + 1 + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + KLineEdit + QLineEdit +
klineedit.h
+
+ + KComboBox + QComboBox +
kcombobox.h
+
+
+ + +
diff --git a/plugins/csv/csvimportplugin.cpp b/plugins/csv/csvimportplugin.cpp new file mode 100644 index 0000000..c1ae668 --- /dev/null +++ b/plugins/csv/csvimportplugin.cpp @@ -0,0 +1,85 @@ +/* + * Copyright 2010 by Stefan Böhmann + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include "csvimportplugin.h" +#include "csvimportdialog.h" + +#include "backend/account.h" + +#include +#include + + + +CsvImportPlugin::CsvImportPlugin(QObject *parent) + : QObject( parent ) +{ + +} + + +QByteArray CsvImportPlugin::pluginIdentifier() const +{ + return "csv_import_plugin"; +} + + +QString CsvImportPlugin::pluginName() const +{ + return tr( "CSV Import Plugin" ); + +} + + +QByteArray CsvImportPlugin::pluginVersion() const +{ + return "0.0.1"; +} + + +QString CsvImportPlugin::importActionName() const +{ + return QObject::tr( "Import &CSV File..." ); +} + + +QPixmap CsvImportPlugin::importActionIcon() const +{ + return BarIcon("text-csv"); +} + + +Account* CsvImportPlugin::importAccount(QWidget *parent) const +{ + QPointer dialog = new CsvImportDialog( parent ); + Account *account = 0; + + if( dialog->exec() == QDialog::Accepted ) { + if( dialog ) { + account = dialog->account(); + } + } + + delete dialog; + + return account; +} + + +Q_EXPORT_PLUGIN2( "CsvImportPlugin", CsvImportPlugin ); + +// kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; replace-tabs on; space-indent on; +// vim:set spell et sw=4 ts=4 nowrap cino=l1,cs,U1: diff --git a/plugins/csv/csvimportplugin.h b/plugins/csv/csvimportplugin.h new file mode 100644 index 0000000..e310ffa --- /dev/null +++ b/plugins/csv/csvimportplugin.h @@ -0,0 +1,52 @@ +/* + * Copyright 2010 by Stefan Böhmann + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#ifndef CSVIMPORTPLUGIN_H +#define CSVIMPORTPLUGIN_H + +#include + + +/** + * @class CsvImportPlugin + * @brief + * + * @author Stefan Böhmann + */ +class CsvImportPlugin : public QObject, public Knipptasch::ImportPlugin +{ + Q_OBJECT + Q_INTERFACES( Knipptasch::Plugin ) + Q_INTERFACES( Knipptasch::ImportPlugin ) + + public: + CsvImportPlugin(QObject *parent = 0); + + QByteArray pluginIdentifier() const; + QString pluginName() const; + QByteArray pluginVersion() const; + + QString importActionName() const; + QPixmap importActionIcon() const; + + Account* importAccount(QWidget *parent = 0) const; +}; + + +#endif + +// kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; replace-tabs on; space-indent on; +// vim:set spell et sw=4 ts=4 nowrap cino=l1,cs,U1: diff --git a/plugins/csv_export/CMakeLists.txt b/plugins/csv_export/CMakeLists.txt deleted file mode 100644 index 3ec5ed1..0000000 --- a/plugins/csv_export/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -project( knipptasch_csv_export_plugin ) - -set( knipptasch_plugin_SOURCES - csvexportdialog.cpp - csvexportplugin.cpp - ) - -set( knipptasch_plugin_HEADERS - csvexportdialog.h - csvexportplugin.h - ) - -set( knipptasch_plugin_FORMS - csvexportdialog.ui - ) - - -qt4_wrap_ui( knipptasch_plugin_SOURCES ${knipptasch_plugin_FORMS} ) -qt4_wrap_cpp( knipptasch_plugin_SOURCES ${knipptasch_plugin_HEADERS} ) - -add_library( knipptasch_csv_export_plugin SHARED ${knipptasch_plugin_SOURCES} ) -target_link_libraries( knipptasch_csv_export_plugin ${QT_LIBRARIES} knipptasch compat ) - -install( TARGETS knipptasch_csv_export_plugin DESTINATION ${KNIPPTASCH_PLUGIN_INSTALL_DIR} ) diff --git a/plugins/csv_export/csvexportdialog.cpp b/plugins/csv_export/csvexportdialog.cpp deleted file mode 100644 index f745225..0000000 --- a/plugins/csv_export/csvexportdialog.cpp +++ /dev/null @@ -1,399 +0,0 @@ -/* - * Copyright 2010 by Stefan Böhmann - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#include "csvexportdialog.h" -#include "ui_csvexportdialog.h" - -#include "backend/account.h" -#include "backend/posting.h" -#include "backend/money.h" - -#include "compat/iconloader.h" - -#include -#include -#include -#include -#include - -#include - -#if defined(HAVE_KDE) -#include -#include -#else -#include -#include -#endif - -#include -#include -#include - -#include - -#include - - - -CsvExportDialog::CsvExportDialog(const Account *account, const QList &selected, QWidget *parent) - : QDialog( parent ), - ui( new Ui::CsvExportDialog ), - m_account( account ), - m_selectedPostings( selected ), - m_updateTimer( new QTimer( this ) ) -{ - Q_ASSERT( m_account ); - - ui->setupUi( this ); - - setWindowTitle( tr( "CSV Export - %1" ).arg( QCoreApplication::applicationName() ) ); - ui->iconLabel->setPixmap( DesktopIcon("text-csv") ); - - m_updateTimer->setInterval( 300 ); - - ui->allInYearEdit->setDate( QDate::currentDate() ); - ui->allBetweenDateStart->setDate( account->openingDate().isValid() - ? account->openingDate() - : QDate( 1, 1, QDate::currentDate().year() ) - ); - ui->allBetweenDateEnd->setDate( QDate::currentDate() ); - - if( !m_selectedPostings.isEmpty() ) { - ui->selected->setEnabled( true ); - ui->selected->setChecked( true ); - } - else { - ui->selected->setEnabled( false ); - ui->all->setChecked( true ); - } - - const QLocale l; - - ui->decimalSymbol->clear(); - ui->decimalSymbol->addItem( "" ); - ui->decimalSymbol->addItem( "," ); - ui->decimalSymbol->addItem( "." ); - if( ui->decimalSymbol->findText( l.decimalPoint() ) < 0 ) { - ui->decimalSymbol->addItem( l.decimalPoint() ); - } - Q_ASSERT( ui->decimalSymbol->findText( l.decimalPoint() ) >= 0 ); - ui->decimalSymbol->setCurrentIndex( ui->decimalSymbol->findText( l.decimalPoint() ) ); - - ui->decimalSymbol->setEnabled( false ); //TODO - - ui->thousandsSeparator->clear(); - ui->thousandsSeparator->addItem( "" ); - ui->thousandsSeparator->addItem( "." ); - ui->thousandsSeparator->setCurrentIndex( 0 ); - ui->thousandsSeparator->setEnabled( false ); //TODO - - ui->textquote->clear(); - ui->textquote->addItem( "" ); - ui->textquote->addItem( "\"" ); - ui->textquote->addItem( "'" ); - ui->textquote->addItem( "`" ); - ui->textquote->setCurrentIndex( 1 ); - - ui->delimiter->clear(); - ui->delimiter->addItem( "" ); - ui->delimiter->addItem( tr( "Comma" ), "," ); - ui->delimiter->addItem( tr( "Tabulator" ), "\t" ); - ui->delimiter->addItem( tr( "Semicolon" ), ";" ); - ui->delimiter->addItem( tr( "Space" ), " " ); - ui->delimiter->setCurrentIndex( 3 ); - - QString df = tr( - "

These expressions may be used for the date format:

" - "
ExpressionOutput
Text Date%1
ISO Date%2
Short Date%3
Long Date%4
" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "
ExpressionOutput
dThe day as a number without a leading zero (1 to 31)
ddThe day as a number with a leading zero (01 to 31)
dddThe abbreviated localized day name (e.g. 'Mon' to 'Sun')
ddddThe long localized day name (e.g. 'Monday' to 'Sunday')
MThe month as a number without a leading zero (1 to 12)
MMThe month as a number with a leading zero (01 to 12)
MMMThe abbreviated localized month name (e.g. 'Jan' to 'Dec')
MMMMThe long localized month name (e.g. 'January' to 'December')
yyThe year as two digit number (00 to 99)
yyyyThe year as four digit number
" - "" - "" - "" - "" - "" - "" - ) - .arg( "ddd MMM d yyyy" ) - .arg( "yyyy-MM-dd" ) - .arg( l.dateFormat( QLocale::ShortFormat ) ) - .arg( l.dateFormat( QLocale::LongFormat ) ); - - ui->dateFormat->setToolTip( df ); - ui->dateFormat->setWhatsThis( df ); - - ui->dateFormat->clear(); - ui->dateFormat->addItem( "" ); - ui->dateFormat->addItem( tr( "Text Date" ), "ddd MMM d yyyy" ); - ui->dateFormat->addItem( tr( "ISO Date" ), "yyyy-MM-dd" ); - ui->dateFormat->addItem( tr( "Short Date" ), l.dateFormat( QLocale::ShortFormat ) ); - ui->dateFormat->addItem( tr( "Long Date" ), l.dateFormat( QLocale::LongFormat ) ); - ui->dateFormat->setCurrentIndex( 2 ); - - ui->encoding->clear(); - foreach(const QByteArray &name, QTextCodec::availableCodecs() ) { - ui->encoding->addItem( name, name ); - } - ui->encoding->setCurrentIndex( ui->encoding->findData( - QTextCodec::codecForLocale()->name() ) ); - - ui->endOfLine->clear(); - ui->endOfLine->addItem( tr( "Unix" ), "\n" ); - ui->endOfLine->addItem( tr( "Windows/DOS" ), "\r\n" ); - ui->endOfLine->addItem( tr( "Macintosh" ), "\r" ); - -#if defined( Q_WS_WIN ) - ui->endOfLine->setCurrentIndex( 1 ); -#elif defined( Q_WS_MAC ) - ui->endOfLine->setCurrentIndex( 2 ); -#else - ui->endOfLine->setCurrentIndex( 0 ); -#endif - - ui->buttonBox->button( QDialogButtonBox::Save )->setEnabled( false ); - - connect( ui->delimiter, SIGNAL( activated(int) ), - this, SLOT( onDelimiterComboBoxIndexChanged(int) ) ); - connect( ui->delimiter->lineEdit(), SIGNAL( textEdited(QString) ), - this, SLOT( onDelimiterComboBoxTextChanged() ) ); - - connect( ui->dateFormat, SIGNAL( activated(int) ), - this, SLOT( onDateFormatComboBoxIndexChanged(int) ) ); - connect( ui->dateFormat->lineEdit(), SIGNAL( textEdited(QString) ), - this, SLOT( onDateFormatComboBoxTextChanged() ) ); - - connect( ui->all, SIGNAL( toggled(bool) ), - this, SLOT( onStartUpdateTimer() ) ); - connect( ui->selected, SIGNAL( toggled(bool) ), - this, SLOT( onStartUpdateTimer() ) ); - connect( ui->allInYear, SIGNAL( toggled(bool) ), - this, SLOT( onStartUpdateTimer() ) ); - connect( ui->allBetween, SIGNAL( toggled(bool) ), - this, SLOT( onStartUpdateTimer() ) ); - connect( ui->allInYearEdit, SIGNAL( dateChanged(QDate) ), - this, SLOT( onStartUpdateTimer() ) ); - connect( ui->allBetweenDateStart, SIGNAL( dateChanged(QDate) ), - this, SLOT( onStartUpdateTimer() ) ); - connect( ui->allBetweenDateEnd, SIGNAL( dateChanged(QDate) ), - this, SLOT( onStartUpdateTimer() ) ); - connect( ui->textquote, SIGNAL( editTextChanged(QString) ), - this, SLOT( onStartUpdateTimer() ) ); - connect( ui->decimalSymbol, SIGNAL( editTextChanged(QString) ), - this, SLOT( onStartUpdateTimer() ) ); - connect( ui->thousandsSeparator, SIGNAL( editTextChanged(QString) ), - this, SLOT( onStartUpdateTimer() ) ); - connect( ui->encoding, SIGNAL( activated(int) ), - this, SLOT( onStartUpdateTimer() ) ); - connect( ui->endOfLine, SIGNAL( activated(int) ), - this, SLOT( onStartUpdateTimer() ) ); - - connect( ui->buttonBox->button( QDialogButtonBox::Save ), SIGNAL( clicked() ), - this, SLOT( onSave() ) ); - - connect( m_updateTimer, SIGNAL( timeout() ), - this, SLOT( onUpdatePreview() ) ); - - onDateFormatComboBoxIndexChanged( ui->dateFormat->currentIndex() ); - onDelimiterComboBoxIndexChanged( ui->delimiter->currentIndex() ); -} - - -CsvExportDialog::~CsvExportDialog() -{ - delete ui; -} - - -void CsvExportDialog::onStartUpdateTimer() -{ - Q_ASSERT( ui->buttonBox->button( QDialogButtonBox::Save ) ); - - ui->buttonBox->button( QDialogButtonBox::Save )->setEnabled( false ); - - m_updateTimer->start(); -} - - -void CsvExportDialog::onUpdatePreview() -{ - ui->preview->clear(); - ui->rowCountLabel->setText( QString::number( 0 ) ); - ui->columnCountLabel->setText( QString::number( 0 ) ); - ui->characterCountLabel->setText( QString::number( 0 ) ); - - m_result.clear(); - - QList postings; - - if( ui->all->isChecked() ) { - postings = m_account->postings(); - } - else if( ui->selected->isChecked() ) { - postings = m_selectedPostings; - } - else if( ui->allInYear->isChecked() ) { - QList plist = m_account->postings(); - int year = ui->allInYearEdit->date().year(); - - foreach(const Posting *p, plist) { - if( ( p->maturity().isValid() && p->maturity().year() == year ) || - ( p->valueDate().isValid() && p->valueDate().year() == year ) ) { - postings.append( p ); - } - } - } - else if( ui->allBetween->isChecked() ) { - QList plist = m_account->postings(); - - QDate start = ui->allBetweenDateStart->date(); - QDate end = ui->allBetweenDateEnd->date() > start - ? ui->allBetweenDateEnd->date() - : start; - - Q_ASSERT( start.isValid() ); - Q_ASSERT( end.isValid() ); - - foreach(const Posting *p, plist) { - if( ( p->maturity().isValid() && p->maturity() >= start && p->maturity() <= end ) || - ( p->valueDate().isValid() && p->valueDate() >= start && p->valueDate() <= end ) ) { - postings.append( p ); - } - } - } - else { - Q_ASSERT( false ); - } - - QString eof = ui->endOfLine->itemData( ui->endOfLine->currentIndex() ).toString(); - QString tq = ui->textquote->currentText(); - - QBuffer buffer( &m_result ); - buffer.open( QIODevice::WriteOnly ); - - QTextStream out( &buffer ); - out.setCodec( QTextCodec::codecForName( - ui->encoding->itemData( ui->encoding->currentIndex() ) - .toByteArray() - ) ); - - for(int i = 0; i < postings.size(); ++i) { - const Posting *p = postings[ i ]; - - out << tq << p->valueDate().toString( m_dateFormat ) << tq << m_delimiter; - out << tq << p->postingText() << tq << m_delimiter; - out << tq << p->maturity().toString( m_dateFormat ) << tq << m_delimiter; - out << tq << p->amount().toString() << tq << m_delimiter; - out << eof; - } - - buffer.close(); - - ui->rowCountLabel->setText( QString::number( postings.size() ) ); - ui->columnCountLabel->setText( QString::number( postings.size() * 4 ) ); - ui->characterCountLabel->setText( QString::number( m_result.size() ) ); - - ui->preview->setPlainText( m_result ); - - Q_ASSERT( ui->buttonBox->button( QDialogButtonBox::Save ) ); - ui->buttonBox->button( QDialogButtonBox::Save ) - ->setEnabled( !m_result.isEmpty() ); -} - -void CsvExportDialog::onSave() -{ - hide(); - - QString filename; - -#if defined(HAVE_KDE) - filename = KFileDialog::getSaveFileName( KUrl(), "*.csv|" + tr( "All Supported Files" ), this ); -#else - filename = QFileDialog::getSaveFileName( this, // krazy:exclude=qclasses - tr( "Export File - %1" ).arg( QCoreApplication::applicationName() ), - QString(), tr( "All Supported Files" ) + " (*.csv)" - ); -#endif - - if( filename.isEmpty() ) { - rejected(); - return; - } - - QFile file( filename ); - if( !file.open( QIODevice::WriteOnly ) ) { - QString message = tr( "The file given could not be written; " - "check whether it exists or is writeable " - "for the current user." ); -#if defined(HAVE_KDE) - KMessageBox::error( parentWidget(), message ); -#else - QMessageBox::warning( parentWidget(), // krazy:exclude=qclasses - tr( "Error - %1" ) - .arg( QCoreApplication::applicationName() ), - message ); -#endif - reject(); - return; - } - - file.write( m_result ); - file.close(); - - accept(); -} - - -void CsvExportDialog::onDelimiterComboBoxIndexChanged(int index) -{ - m_delimiter = ui->delimiter->itemData( index ).toString(); - onStartUpdateTimer(); -} - - -void CsvExportDialog::onDelimiterComboBoxTextChanged() -{ - m_delimiter = ui->delimiter->currentText(); - onStartUpdateTimer(); -} - - -void CsvExportDialog::onDateFormatComboBoxIndexChanged(int index) -{ - m_dateFormat = ui->dateFormat->itemData( index ).toString(); - onStartUpdateTimer(); -} - - -void CsvExportDialog::onDateFormatComboBoxTextChanged() -{ - m_dateFormat = ui->dateFormat->currentText(); - onStartUpdateTimer(); -} - - -// kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; replace-tabs on; space-indent on; -// vim:set spell et sw=4 ts=4 nowrap cino=l1,cs,U1: diff --git a/plugins/csv_export/csvexportdialog.h b/plugins/csv_export/csvexportdialog.h deleted file mode 100644 index 68698f3..0000000 --- a/plugins/csv_export/csvexportdialog.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2010 by Stefan Böhmann - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#ifndef CSVEXPORTDIALOG_H -#define CSVEXPORTDIALOG_H - -#include -#include - -class QTimer; -class Posting; -class Account; - -namespace Ui -{ - class CsvExportDialog; -} - - -/** - * @class CsvExportDialog - * @brief - * - * @author Stefan Böhmann - */ -class CsvExportDialog : public QDialog -{ - Q_OBJECT - - public: - CsvExportDialog(const Account *account, const QList &selected, QWidget *parent = 0); - ~CsvExportDialog(); - - private slots: - void onStartUpdateTimer(); - void onUpdatePreview(); - - void onSave(); - - void onDelimiterComboBoxIndexChanged(int); - void onDelimiterComboBoxTextChanged(); - - void onDateFormatComboBoxIndexChanged(int index); - void onDateFormatComboBoxTextChanged(); - - private: - Ui::CsvExportDialog *ui; - - const Account *m_account; - QList m_selectedPostings; - - QString m_delimiter; - QString m_dateFormat; - QByteArray m_result; - QTimer *m_updateTimer; -}; - -#endif - -// kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; replace-tabs on; space-indent on; -// vim:set spell et sw=4 ts=4 nowrap cino=l1,cs,U1: diff --git a/plugins/csv_export/csvexportdialog.ui b/plugins/csv_export/csvexportdialog.ui deleted file mode 100644 index 8307a1c..0000000 --- a/plugins/csv_export/csvexportdialog.ui +++ /dev/null @@ -1,597 +0,0 @@ - - - Stefan Böhmann - CsvExportDialog - - - - 0 - 0 - 699 - 632 - - - - - 0 - 0 - - - - - - - Settings - - - - - - QFormLayout::ExpandingFieldsGrow - - - - - Date format: - - - dateFormat - - - - - - - true - - - -1 - - - 8 - - - - - - - Decimal symbol: - - - decimalSymbol - - - - - - - true - - - 8 - - - - - - - Thousands separator: - - - thousandsSeparator - - - - - - - true - - - 8 - - - - - - - - - QFormLayout::ExpandingFieldsGrow - - - - - Encoding: - - - encoding - - - - - - - 8 - - - - - - - End of Line: - - - endOfLine - - - - - - - 8 - - - - - - - - - QFormLayout::ExpandingFieldsGrow - - - - - Delimiter: - - - delimiter - - - - - - - true - - - -1 - - - 8 - - - - - - - Text quote: - - - textquote - - - - - - - true - - - -1 - - - 8 - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Save - - - - - - - Selection - - - - - - All - - - true - - - - - - - Selected - - - - - - - - - All in: - - - - - - - false - - - yyyy - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - All between: - - - - - - - false - - - M/d/yyyy - - - - - - - false - - - and - - - - - - - false - - - M/d/yyyy - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - icon - - - - - - - - 0 - 0 - - - - - 75 - true - - - - CSV Export - - - 3 - - - 5 - - - - - - - - - Preview - - - - -1 - - - 0 - - - 2 - - - - - - DejaVu Sans Mono - 7 - - - - Rows: - - - - - - - - 0 - 0 - - - - - DejaVu Sans Mono - 7 - - - - 0 - - - - - - - - DejaVu Sans Mono - 7 - - - - Columns: - - - - - - - - 0 - 0 - - - - - DejaVu Sans Mono - 7 - - - - 0 - - - - - - - - DejaVu Sans Mono - 7 - - - - Characters: - - - - - - - - 0 - 0 - - - - - DejaVu Sans Mono - 7 - - - - 0 - - - - - - - false - - - true - - - - - - - - - - - KComboBox - QComboBox -
kcombobox.h
-
-
- - selected - all - allInYear - allInYearEdit - allBetween - allBetweenDateStart - allBetweenDateEnd - delimiter - textquote - dateFormat - decimalSymbol - thousandsSeparator - encoding - endOfLine - buttonBox - - - - - allInYear - toggled(bool) - allInYearEdit - setEnabled(bool) - - - 70 - 143 - - - 157 - 146 - - - - - allBetween - toggled(bool) - allBetweenDateStart - setEnabled(bool) - - - 86 - 176 - - - 259 - 179 - - - - - allBetween - toggled(bool) - label - setEnabled(bool) - - - 121 - 176 - - - 290 - 179 - - - - - allBetween - toggled(bool) - allBetweenDateEnd - setEnabled(bool) - - - 29 - 176 - - - 423 - 179 - - - - - buttonBox - rejected() - CsvExportDialog - reject() - - - 584 - 415 - - - 593 - 487 - - - - -
diff --git a/plugins/csv_export/csvexportplugin.cpp b/plugins/csv_export/csvexportplugin.cpp deleted file mode 100644 index 8fb0567..0000000 --- a/plugins/csv_export/csvexportplugin.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2010 by Stefan Böhmann - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#include "csvexportplugin.h" -#include "csvexportdialog.h" - -#include "compat/iconloader.h" - -#include - - -CsvExportPlugin::CsvExportPlugin(QObject *parent) - : QObject( parent ) -{ -} - - -QByteArray CsvExportPlugin::pluginIdentifier() const -{ - return "csv_export_plugin"; -} - - -QString CsvExportPlugin::pluginName() const -{ - return tr( "CSV Export Plugin" ); - -} - - -QByteArray CsvExportPlugin::pluginVersion() const -{ - return "0.0.1"; -} - - -QString CsvExportPlugin::exportActionName() const -{ - return QObject::tr( "Export &CSV File..." ); -} - - -QPixmap CsvExportPlugin::exportActionIcon() const -{ - return BarIcon("text-csv"); -} - - -void CsvExportPlugin::exportAccount(const Account *account, const QList &selected, QWidget *parent) const -{ - QPointer dialog = new CsvExportDialog( account, selected, parent ); - - dialog->exec(); - - delete dialog; -} - - -Q_EXPORT_PLUGIN2( "CsvExportPlugin", CsvExportPlugin ); - -// kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; replace-tabs on; space-indent on; -// vim:set spell et sw=4 ts=4 nowrap cino=l1,cs,U1: diff --git a/plugins/csv_export/csvexportplugin.h b/plugins/csv_export/csvexportplugin.h deleted file mode 100644 index 2c1727e..0000000 --- a/plugins/csv_export/csvexportplugin.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2010 by Stefan Böhmann - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#ifndef CSVEXPORTPLUGIN_H -#define CSVEXPORTPLUGIN_H - -#include - - -/** - * @class CsvExportPlugin - * @brief - * - * @author Stefan Böhmann - */ -class CsvExportPlugin : public QObject, public Knipptasch::ExportPlugin -{ - Q_OBJECT - Q_INTERFACES( Knipptasch::Plugin ) - Q_INTERFACES( Knipptasch::ExportPlugin ) - - public: - CsvExportPlugin(QObject *parent = 0); - - QByteArray pluginIdentifier() const; - QString pluginName() const; - QByteArray pluginVersion() const; - - QString exportActionName() const; - QPixmap exportActionIcon() const; - - void exportAccount(const Account *account, const QList &selected, QWidget *parent = 0) const; -}; - - -#endif - -// kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; replace-tabs on; space-indent on; -// vim:set spell et sw=4 ts=4 nowrap cino=l1,cs,U1: diff --git a/plugins/csv_import/CMakeLists.txt b/plugins/csv_import/CMakeLists.txt deleted file mode 100644 index ed53b9b..0000000 --- a/plugins/csv_import/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -project( knipptasch_csv_import_plugin ) - -set( knipptasch_plugin_SOURCES - csvimportdialog.cpp - csvimportplugin.cpp - ) - -set( knipptasch_plugin_HEADERS - csvimportdialog.h - csvimportplugin.h - ) - -set( knipptasch_plugin_FORMS - csvimportdialog.ui - ) - - -qt4_wrap_ui( knipptasch_plugin_SOURCES ${knipptasch_plugin_FORMS} ) -qt4_wrap_cpp( knipptasch_plugin_SOURCES ${knipptasch_plugin_HEADERS} ) - -add_library( knipptasch_csv_import_plugin SHARED ${knipptasch_plugin_SOURCES} ) -target_link_libraries( knipptasch_csv_import_plugin ${QT_LIBRARIES} knipptasch compat ) - -install( TARGETS knipptasch_csv_import_plugin DESTINATION ${KNIPPTASCH_PLUGIN_INSTALL_DIR} ) diff --git a/plugins/csv_import/csvimportdialog.cpp b/plugins/csv_import/csvimportdialog.cpp deleted file mode 100644 index 05a208d..0000000 --- a/plugins/csv_import/csvimportdialog.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright 2010 by Stefan Böhmann - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#include "csvimportdialog.h" -#include "ui_csvimportdialog.h" - -#include "backend/account.h" - -#include "compat/iconloader.h" - -#include -#include -#include - -#include - -#include - - -CsvImportDialog::CsvImportDialog(QWidget *parent) - : QDialog( parent ), - ui( new Ui::CsvImportDialog ) -{ - ui->setupUi( this ); - - setWindowTitle( tr( "CSV Import - %1" ).arg( QCoreApplication::applicationName() ) ); - ui->iconLabel->setPixmap( DesktopIcon("text-csv") ); - - ui->fileButton->setIcon( BarIcon("document-open") ); - - ui->delimiter->clear(); - ui->delimiter->addItem( "" ); - ui->delimiter->addItem( tr( "Comma" ), ',' ); - ui->delimiter->addItem( tr( "Tabulator" ), '\t' ); - ui->delimiter->addItem( tr( "Semicolon" ), ';' ); - ui->delimiter->addItem( tr( "Space" ), ' ' ); - ui->delimiter->setCurrentIndex( 3 ); - m_delimiter = ui->delimiter->itemData( 3 ).toChar(); - - ui->encoding->clear(); - foreach(const QByteArray &name, QTextCodec::availableCodecs() ) { - ui->encoding->addItem( name, name ); - } - ui->encoding->setCurrentIndex( ui->encoding->findData( QTextCodec::codecForLocale()->name() ) ); - - ui->endOfLine->clear(); - ui->endOfLine->addItem( tr( "Unix" ) ); - ui->endOfLine->addItem( tr( "Windows/DOS" ) ); - ui->endOfLine->addItem( tr( "Macintosh" ) ); - -#if defined( Q_WS_WIN ) - ui->endOfLine->setCurrentIndex( 1 ); -#elif defined( Q_WS_MAC ) - ui->endOfLine->setCurrentIndex( 2 ); -#else - ui->endOfLine->setCurrentIndex( 0 ); -#endif - - connect( ui->delimiter, SIGNAL( activated(int) ), this, SLOT( onDelimiterComboBoxIndexChanged(int) ) ); - connect( ui->delimiter->lineEdit(), SIGNAL( textEdited(QString) ), this, SLOT( onDelimiterComboBoxTextChanged() ) ); -} - - -CsvImportDialog::~CsvImportDialog() -{ - delete ui; -} - - -Account* CsvImportDialog::account() const -{ - return 0; -} - - -void CsvImportDialog::onDelimiterComboBoxIndexChanged(int index) -{ - m_delimiter = ui->delimiter->itemData( index ).toChar(); -} - - -void CsvImportDialog::onDelimiterComboBoxTextChanged() -{ - m_delimiter = ui->delimiter->currentText(); -} - - - - -// kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; replace-tabs on; space-indent on; -// vim:set spell et sw=4 ts=4 nowrap cino=l1,cs,U1: diff --git a/plugins/csv_import/csvimportdialog.h b/plugins/csv_import/csvimportdialog.h deleted file mode 100644 index a87e308..0000000 --- a/plugins/csv_import/csvimportdialog.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2010 by Stefan Böhmann - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#ifndef CSVIMPORTDIALOG_H -#define CSVIMPORTDIALOG_H - -#include - -class Account; - -namespace Ui -{ - class CsvImportDialog; -} - - -/** - * @class CsvImportDialog - * @brief - * - * @author Stefan Böhmann - */ -class CsvImportDialog : public QDialog -{ - Q_OBJECT - - public: - CsvImportDialog(QWidget *parent = 0); - ~CsvImportDialog(); - - Account* account() const; - - private slots: - void onDelimiterComboBoxIndexChanged(int); - void onDelimiterComboBoxTextChanged(); - - private: - QString m_delimiter; - Ui::CsvImportDialog *ui; -}; - -#endif - -// kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; replace-tabs on; space-indent on; -// vim:set spell et sw=4 ts=4 nowrap cino=l1,cs,U1: diff --git a/plugins/csv_import/csvimportdialog.ui b/plugins/csv_import/csvimportdialog.ui deleted file mode 100644 index 7fa8770..0000000 --- a/plugins/csv_import/csvimportdialog.ui +++ /dev/null @@ -1,317 +0,0 @@ - - - Stefan Böhmann - CsvImportDialog - - - - 0 - 0 - 923 - 438 - - - - - 0 - 0 - - - - - - - - - icon - - - - - - - - 0 - 0 - - - - - 75 - true - - - - CSV Import - - - 3 - - - 5 - - - - - - - - - - - File to import: - - - - - - - - - - - - - - - - - - - - - - - Settings - - - - - - QFormLayout::ExpandingFieldsGrow - - - - - Delimiter: - - - - - - - true - - - -1 - - - 8 - - - - - - - Text quote: - - - - - - - true - - - -1 - - - 8 - - - - - - - Ignore duplicate delimiters - - - - - - - - - QFormLayout::ExpandingFieldsGrow - - - - - Date format: - - - - - - - true - - - -1 - - - 8 - - - - - - - Decimal symbol: - - - - - - - true - - - 8 - - - - - - - Thousands separator: - - - - - - - true - - - 8 - - - - - - - - - - - Encoding: - - - - - - - 8 - - - - - - - End of Line: - - - - - - - 8 - - - - - - - Skip first row of file - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - 1 - 1 - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - KLineEdit - QLineEdit -
klineedit.h
-
- - KComboBox - QComboBox -
kcombobox.h
-
-
- - -
diff --git a/plugins/csv_import/csvimportplugin.cpp b/plugins/csv_import/csvimportplugin.cpp deleted file mode 100644 index de61662..0000000 --- a/plugins/csv_import/csvimportplugin.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2010 by Stefan Böhmann - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#include "csvimportplugin.h" -#include "csvimportdialog.h" - -#include "backend/account.h" - -#include -#include - - - -CsvImportPlugin::CsvImportPlugin(QObject *parent) - : QObject( parent ) -{ - -} - - -QByteArray CsvImportPlugin::pluginIdentifier() const -{ - return "csv_import_plugin"; -} - - -QString CsvImportPlugin::pluginName() const -{ - return tr( "CSV Import Plugin" ); - -} - - -QByteArray CsvImportPlugin::pluginVersion() const -{ - return "0.0.1"; -} - - -QString CsvImportPlugin::importActionName() const -{ - return QObject::tr( "Import &CSV File..." ); -} - - -QPixmap CsvImportPlugin::importActionIcon() const -{ - return BarIcon("text-csv"); -} - - -Account* CsvImportPlugin::importAccount(QWidget *parent) const -{ - QPointer dialog = new CsvImportDialog( parent ); - Account *account = 0; - - if( dialog->exec() == QDialog::Accepted ) { - if( dialog ) { - account = dialog->account(); - } - } - - delete dialog; - - return account; -} - - -Q_EXPORT_PLUGIN2( "CsvImportPlugin", CsvImportPlugin ); - -// kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; replace-tabs on; space-indent on; -// vim:set spell et sw=4 ts=4 nowrap cino=l1,cs,U1: diff --git a/plugins/csv_import/csvimportplugin.h b/plugins/csv_import/csvimportplugin.h deleted file mode 100644 index e310ffa..0000000 --- a/plugins/csv_import/csvimportplugin.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2010 by Stefan Böhmann - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#ifndef CSVIMPORTPLUGIN_H -#define CSVIMPORTPLUGIN_H - -#include - - -/** - * @class CsvImportPlugin - * @brief - * - * @author Stefan Böhmann - */ -class CsvImportPlugin : public QObject, public Knipptasch::ImportPlugin -{ - Q_OBJECT - Q_INTERFACES( Knipptasch::Plugin ) - Q_INTERFACES( Knipptasch::ImportPlugin ) - - public: - CsvImportPlugin(QObject *parent = 0); - - QByteArray pluginIdentifier() const; - QString pluginName() const; - QByteArray pluginVersion() const; - - QString importActionName() const; - QPixmap importActionIcon() const; - - Account* importAccount(QWidget *parent = 0) const; -}; - - -#endif - -// kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; replace-tabs on; space-indent on; -// vim:set spell et sw=4 ts=4 nowrap cino=l1,cs,U1: diff --git a/plugins/demo/CMakeLists.txt b/plugins/demo/CMakeLists.txt new file mode 100644 index 0000000..88abb6b --- /dev/null +++ b/plugins/demo/CMakeLists.txt @@ -0,0 +1,15 @@ +project( knipptasch_demo_import_plugin ) + +set( knipptasch_plugin_SOURCES + demoimportplugin.cpp + ) + +set( knipptasch_plugin_HEADERS + demoimportplugin.h + ) + +qt4_wrap_cpp( knipptasch_plugin_SOURCES ${knipptasch_plugin_HEADERS} ) +add_library( knipptasch_demo_import_plugin SHARED ${knipptasch_plugin_SOURCES} ) +target_link_libraries( knipptasch_demo_import_plugin ${QT_LIBRARIES} knipptasch compat ) + +install( TARGETS knipptasch_demo_import_plugin DESTINATION ${KNIPPTASCH_PLUGIN_INSTALL_DIR} ) diff --git a/plugins/demo/demoimportplugin.cpp b/plugins/demo/demoimportplugin.cpp new file mode 100644 index 0000000..f9d2461 --- /dev/null +++ b/plugins/demo/demoimportplugin.cpp @@ -0,0 +1,245 @@ +/* + * Copyright 2010 by Stefan Böhmann + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include "demoimportplugin.h" + +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include + + + +Money initDemoAccountAddPosting(Account *acc, const QDate &date, const QString &postingText, const Money &amount, bool valueDate = true) +{ + Q_ASSERT( acc ); + + Posting *p = new Posting; + p->setMaturity( date ); + p->setPostingText( postingText ); + p->setAmount( amount ); + p->setValueDate( valueDate ? date.addDays( qrand() % 8 ) : QDate() ); + + acc->addPosting( p ); + + return p->amount(); +} + +Money initRent(Account *acc, const QDate &date) +{ + return initDemoAccountAddPosting( acc, date.addDays( qrand() % 6 ), + QObject::tr( "Rent" ) , -348.50, + date < QDate::currentDate() ); +} + + + +DemoImportPlugin::DemoImportPlugin(QObject *parent) + : QObject( parent ) +{ + qsrand( QTime::currentTime().msec() ); +} + + +QByteArray DemoImportPlugin::pluginIdentifier() const +{ + return "demo_import_plugin"; +} + + +QString DemoImportPlugin::pluginName() const +{ + return tr( "Demo Import Plugin" ); + +} + + +QByteArray DemoImportPlugin::pluginVersion() const +{ + return "0.0.1"; +} + + +QString DemoImportPlugin::importActionName() const +{ + return QObject::tr( "Import &Example File" ); +} + + +QPixmap DemoImportPlugin::importActionIcon() const +{ + return BarIcon("applications-education-miscellaneous"); +} + + +Account* DemoImportPlugin::importAccount(QWidget *parent) const +{ + bool ok; + int count = QInputDialog::getInt( parent, // krazy:exclude=qclasses + QString(), + QObject::tr("Past month:"), + 15, 1, 120, 1, &ok ); + if( ok ) { + QList v; + v << -5 << -10 << -15 << -20 << -25 << -30 << -35 << -40 << -50 + << -60 << -70 << -80 << -90 << -100 << -120 << -130 << -150 + << -200 << -250 << -300; + + QStringList cost; + cost << QObject::tr( "ATM" ); + cost << QObject::tr( "Food" ); + cost << QObject::tr( "Clothes" ); + cost << QObject::tr( "Reading material" ); + cost << QObject::tr( "Repairs" ); + cost << QObject::tr( "Fuel" ); + cost << QObject::tr( "Books" ); + cost << QObject::tr( "Dining Out" ); + cost << QObject::tr( "Gifts" ); + cost << QObject::tr( "Tax" ); + cost << QObject::tr( "Insurance" ); + cost << QObject::tr( "Office Supplies" ); + + Account *acc = new Account; + + acc->setName( QObject::tr( "Example Account" ) ); + acc->setNumber( "105626320" ); + acc->setOpeningBalance( 542.20 ); + acc->setOpeningDate( QDate::currentDate().addMonths( -count ) ); + + { + Category *p = acc->rootCategory()->addCategory( QObject::tr( "Auto" ) ); + p->setColor( Qt::blue ); + + p->addCategory( QObject::tr( "Fuel" ) )->setColor( Qt::red ); + p->addCategory( QObject::tr( "Insurance" ) )->setColor( Qt::green ); + p->addCategory( QObject::tr( "Tax" ) )->setColor( Qt::gray ); + p->addCategory( QObject::tr( "Service" ) )->setColor( Qt::darkMagenta ); + } + { + Category *p = acc->rootCategory()->addCategory( QObject::tr( "Food" ) ); + p->setColor( Qt::cyan ); + p->addCategory( QObject::tr( "Dining Out" ) )->setColor( Qt::darkBlue ); + } + { + Category *p = acc->rootCategory()->addCategory( QObject::tr( "Recreation" ) ); + p->setColor( Qt::yellow ); + + p->addCategory( QObject::tr( "Books" ) )->setColor( Qt::darkRed ); + p->addCategory( QObject::tr( "Photo" ) )->setColor( Qt::black ); + p->addCategory( QObject::tr( "Sport" ) ); + Category *p1 = p->addCategory( QObject::tr( "Culture" ) ); + p1->setColor( Qt::darkGreen ); + p1->addCategory( QObject::tr( "Theater" ) )->setColor( Qt::lightGray ); + p1->addCategory( QObject::tr( "Stage" ) ); + p1->addCategory( QObject::tr( "Exposition" ) ); + p1->addCategory( QObject::tr( "Classical Music" ) ); + p1->addCategory( QObject::tr( "Museum" ) ); + p1->addCategory( QObject::tr( "Art" ) ); + p->addCategory( QObject::tr( "Entertainment" ) )->setColor( Qt::darkYellow ); + } + + Money total = acc->openingBalance(); + for( QDate d = acc->openingDate(); d < QDate::currentDate().addMonths( 4 ); d = d.addMonths( 1 ) ) { + Money month; + QDate date( d.year(), d.month(), 1 ); + + month += initRent( acc, date ); + + if( date < QDate::currentDate() ) { + month += initDemoAccountAddPosting( + acc, + date.addDays( qrand() % 6 ), + QObject::tr( "Phone and Internet" ), + -20 - ( ( qrand() % 5000 + 100 ) / 100.00 ) + ); + + month += initDemoAccountAddPosting( + acc, + date.addDays( qrand() % 6 ), + QObject::tr( "Salary" ), + 1000.00 + ( ( qrand() % 50000 + 100 ) / 100.00 ) + ); + + if( total > 800.00 ) { + month += initDemoAccountAddPosting( + acc, + date.addDays( qrand() % date.daysInMonth() + 1 ), + QObject::tr( "Travel" ), + -1700.00 + ( ( qrand() % 50000 + 100 ) / 100.00 ) + ); + } + + while( month > 200.0 ) { + month += initDemoAccountAddPosting( + acc, + date.addDays( qrand() % date.daysInMonth() + 1 ), + cost.at( qrand() % cost.size() ), + v[ qrand() % v.size() ] + ); + } + + if( month < -50.0 ) { + month += initDemoAccountAddPosting( + acc, + date.addDays( qrand() % date.daysInMonth() + 1 ), + QObject::tr( "Dividend" ), + Money( v[ qrand() % v.size() ] ).abs() + ); + } + } + else { + month += initDemoAccountAddPosting( + acc, + date.addDays( qrand() % 6 ), + QObject::tr( "Phone and Internet" ), + Money(), + false + ); + + month += initDemoAccountAddPosting( + acc, + date.addDays( qrand() % 6 ), + QObject::tr( "Salary" ), + Money(), + false + ); + } + + total += month; + } + + acc->setModified( false ); + + return acc; + } + + return 0; +} + + +Q_EXPORT_PLUGIN2( "DemoImportPlugin", DemoImportPlugin ); + + +// kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; replace-tabs on; space-indent on; +// vim:set spell et sw=4 ts=4 nowrap cino=l1,cs,U1: diff --git a/plugins/demo/demoimportplugin.h b/plugins/demo/demoimportplugin.h new file mode 100644 index 0000000..104c68a --- /dev/null +++ b/plugins/demo/demoimportplugin.h @@ -0,0 +1,52 @@ +/* + * Copyright 2010 by Stefan Böhmann + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#ifndef DEMOIMPORTPLUGIN_H +#define DEMOIMPORTPLUGIN_H + +#include + + +/** + * @class DemoImportPlugin + * @brief + * + * @author Stefan Böhmann + */ +class DemoImportPlugin : public QObject, public Knipptasch::ImportPlugin +{ + Q_OBJECT + Q_INTERFACES( Knipptasch::Plugin ) + Q_INTERFACES( Knipptasch::ImportPlugin ) + + public: + DemoImportPlugin(QObject *parent = 0); + + QByteArray pluginIdentifier() const; + QString pluginName() const; + QByteArray pluginVersion() const; + + QString importActionName() const; + QPixmap importActionIcon() const; + + Account* importAccount(QWidget *parent = 0) const; +}; + + +#endif + +// kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; replace-tabs on; space-indent on; +// vim:set spell et sw=4 ts=4 nowrap cino=l1,cs,U1: diff --git a/plugins/demo_import/CMakeLists.txt b/plugins/demo_import/CMakeLists.txt deleted file mode 100644 index 88abb6b..0000000 --- a/plugins/demo_import/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -project( knipptasch_demo_import_plugin ) - -set( knipptasch_plugin_SOURCES - demoimportplugin.cpp - ) - -set( knipptasch_plugin_HEADERS - demoimportplugin.h - ) - -qt4_wrap_cpp( knipptasch_plugin_SOURCES ${knipptasch_plugin_HEADERS} ) -add_library( knipptasch_demo_import_plugin SHARED ${knipptasch_plugin_SOURCES} ) -target_link_libraries( knipptasch_demo_import_plugin ${QT_LIBRARIES} knipptasch compat ) - -install( TARGETS knipptasch_demo_import_plugin DESTINATION ${KNIPPTASCH_PLUGIN_INSTALL_DIR} ) diff --git a/plugins/demo_import/demoimportplugin.cpp b/plugins/demo_import/demoimportplugin.cpp deleted file mode 100644 index f9d2461..0000000 --- a/plugins/demo_import/demoimportplugin.cpp +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright 2010 by Stefan Böhmann - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#include "demoimportplugin.h" - -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include - - - -Money initDemoAccountAddPosting(Account *acc, const QDate &date, const QString &postingText, const Money &amount, bool valueDate = true) -{ - Q_ASSERT( acc ); - - Posting *p = new Posting; - p->setMaturity( date ); - p->setPostingText( postingText ); - p->setAmount( amount ); - p->setValueDate( valueDate ? date.addDays( qrand() % 8 ) : QDate() ); - - acc->addPosting( p ); - - return p->amount(); -} - -Money initRent(Account *acc, const QDate &date) -{ - return initDemoAccountAddPosting( acc, date.addDays( qrand() % 6 ), - QObject::tr( "Rent" ) , -348.50, - date < QDate::currentDate() ); -} - - - -DemoImportPlugin::DemoImportPlugin(QObject *parent) - : QObject( parent ) -{ - qsrand( QTime::currentTime().msec() ); -} - - -QByteArray DemoImportPlugin::pluginIdentifier() const -{ - return "demo_import_plugin"; -} - - -QString DemoImportPlugin::pluginName() const -{ - return tr( "Demo Import Plugin" ); - -} - - -QByteArray DemoImportPlugin::pluginVersion() const -{ - return "0.0.1"; -} - - -QString DemoImportPlugin::importActionName() const -{ - return QObject::tr( "Import &Example File" ); -} - - -QPixmap DemoImportPlugin::importActionIcon() const -{ - return BarIcon("applications-education-miscellaneous"); -} - - -Account* DemoImportPlugin::importAccount(QWidget *parent) const -{ - bool ok; - int count = QInputDialog::getInt( parent, // krazy:exclude=qclasses - QString(), - QObject::tr("Past month:"), - 15, 1, 120, 1, &ok ); - if( ok ) { - QList v; - v << -5 << -10 << -15 << -20 << -25 << -30 << -35 << -40 << -50 - << -60 << -70 << -80 << -90 << -100 << -120 << -130 << -150 - << -200 << -250 << -300; - - QStringList cost; - cost << QObject::tr( "ATM" ); - cost << QObject::tr( "Food" ); - cost << QObject::tr( "Clothes" ); - cost << QObject::tr( "Reading material" ); - cost << QObject::tr( "Repairs" ); - cost << QObject::tr( "Fuel" ); - cost << QObject::tr( "Books" ); - cost << QObject::tr( "Dining Out" ); - cost << QObject::tr( "Gifts" ); - cost << QObject::tr( "Tax" ); - cost << QObject::tr( "Insurance" ); - cost << QObject::tr( "Office Supplies" ); - - Account *acc = new Account; - - acc->setName( QObject::tr( "Example Account" ) ); - acc->setNumber( "105626320" ); - acc->setOpeningBalance( 542.20 ); - acc->setOpeningDate( QDate::currentDate().addMonths( -count ) ); - - { - Category *p = acc->rootCategory()->addCategory( QObject::tr( "Auto" ) ); - p->setColor( Qt::blue ); - - p->addCategory( QObject::tr( "Fuel" ) )->setColor( Qt::red ); - p->addCategory( QObject::tr( "Insurance" ) )->setColor( Qt::green ); - p->addCategory( QObject::tr( "Tax" ) )->setColor( Qt::gray ); - p->addCategory( QObject::tr( "Service" ) )->setColor( Qt::darkMagenta ); - } - { - Category *p = acc->rootCategory()->addCategory( QObject::tr( "Food" ) ); - p->setColor( Qt::cyan ); - p->addCategory( QObject::tr( "Dining Out" ) )->setColor( Qt::darkBlue ); - } - { - Category *p = acc->rootCategory()->addCategory( QObject::tr( "Recreation" ) ); - p->setColor( Qt::yellow ); - - p->addCategory( QObject::tr( "Books" ) )->setColor( Qt::darkRed ); - p->addCategory( QObject::tr( "Photo" ) )->setColor( Qt::black ); - p->addCategory( QObject::tr( "Sport" ) ); - Category *p1 = p->addCategory( QObject::tr( "Culture" ) ); - p1->setColor( Qt::darkGreen ); - p1->addCategory( QObject::tr( "Theater" ) )->setColor( Qt::lightGray ); - p1->addCategory( QObject::tr( "Stage" ) ); - p1->addCategory( QObject::tr( "Exposition" ) ); - p1->addCategory( QObject::tr( "Classical Music" ) ); - p1->addCategory( QObject::tr( "Museum" ) ); - p1->addCategory( QObject::tr( "Art" ) ); - p->addCategory( QObject::tr( "Entertainment" ) )->setColor( Qt::darkYellow ); - } - - Money total = acc->openingBalance(); - for( QDate d = acc->openingDate(); d < QDate::currentDate().addMonths( 4 ); d = d.addMonths( 1 ) ) { - Money month; - QDate date( d.year(), d.month(), 1 ); - - month += initRent( acc, date ); - - if( date < QDate::currentDate() ) { - month += initDemoAccountAddPosting( - acc, - date.addDays( qrand() % 6 ), - QObject::tr( "Phone and Internet" ), - -20 - ( ( qrand() % 5000 + 100 ) / 100.00 ) - ); - - month += initDemoAccountAddPosting( - acc, - date.addDays( qrand() % 6 ), - QObject::tr( "Salary" ), - 1000.00 + ( ( qrand() % 50000 + 100 ) / 100.00 ) - ); - - if( total > 800.00 ) { - month += initDemoAccountAddPosting( - acc, - date.addDays( qrand() % date.daysInMonth() + 1 ), - QObject::tr( "Travel" ), - -1700.00 + ( ( qrand() % 50000 + 100 ) / 100.00 ) - ); - } - - while( month > 200.0 ) { - month += initDemoAccountAddPosting( - acc, - date.addDays( qrand() % date.daysInMonth() + 1 ), - cost.at( qrand() % cost.size() ), - v[ qrand() % v.size() ] - ); - } - - if( month < -50.0 ) { - month += initDemoAccountAddPosting( - acc, - date.addDays( qrand() % date.daysInMonth() + 1 ), - QObject::tr( "Dividend" ), - Money( v[ qrand() % v.size() ] ).abs() - ); - } - } - else { - month += initDemoAccountAddPosting( - acc, - date.addDays( qrand() % 6 ), - QObject::tr( "Phone and Internet" ), - Money(), - false - ); - - month += initDemoAccountAddPosting( - acc, - date.addDays( qrand() % 6 ), - QObject::tr( "Salary" ), - Money(), - false - ); - } - - total += month; - } - - acc->setModified( false ); - - return acc; - } - - return 0; -} - - -Q_EXPORT_PLUGIN2( "DemoImportPlugin", DemoImportPlugin ); - - -// kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; replace-tabs on; space-indent on; -// vim:set spell et sw=4 ts=4 nowrap cino=l1,cs,U1: diff --git a/plugins/demo_import/demoimportplugin.h b/plugins/demo_import/demoimportplugin.h deleted file mode 100644 index 104c68a..0000000 --- a/plugins/demo_import/demoimportplugin.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2010 by Stefan Böhmann - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#ifndef DEMOIMPORTPLUGIN_H -#define DEMOIMPORTPLUGIN_H - -#include - - -/** - * @class DemoImportPlugin - * @brief - * - * @author Stefan Böhmann - */ -class DemoImportPlugin : public QObject, public Knipptasch::ImportPlugin -{ - Q_OBJECT - Q_INTERFACES( Knipptasch::Plugin ) - Q_INTERFACES( Knipptasch::ImportPlugin ) - - public: - DemoImportPlugin(QObject *parent = 0); - - QByteArray pluginIdentifier() const; - QString pluginName() const; - QByteArray pluginVersion() const; - - QString importActionName() const; - QPixmap importActionIcon() const; - - Account* importAccount(QWidget *parent = 0) const; -}; - - -#endif - -// kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; replace-tabs on; space-indent on; -// vim:set spell et sw=4 ts=4 nowrap cino=l1,cs,U1: diff --git a/plugins/xml/CMakeLists.txt b/plugins/xml/CMakeLists.txt new file mode 100644 index 0000000..b79b3b1 --- /dev/null +++ b/plugins/xml/CMakeLists.txt @@ -0,0 +1,56 @@ +project( knipptasch_xml_plugin ) + + +################################################################################### +#### knipptasch_xml_export_plugin +################################################################################### + +set( knipptasch_export_plugin_SOURCES + xmlexportplugin.cpp + xmlwriter.cpp + ) + +set( knipptasch_export_plugin_HEADERS + xmlexportplugin.h + xmlwriter.h + ) + +set( knipptasch_export_plugin_FORMS + #xmlexportdialog.ui + ) + +qt4_wrap_ui( knipptasch_export_plugin_SOURCES ${knipptasch_export_plugin_FORMS} ) +qt4_wrap_cpp( knipptasch_export_plugin_SOURCES ${knipptasch_export_plugin_HEADERS} ) + +add_library( knipptasch_xml_export_plugin SHARED ${knipptasch_export_plugin_SOURCES} ) +target_link_libraries( knipptasch_xml_export_plugin ${QT_LIBRARIES} knipptasch compat ) + +install( TARGETS knipptasch_xml_export_plugin DESTINATION ${KNIPPTASCH_PLUGIN_INSTALL_DIR} ) + + + +################################################################################### +#### knipptasch_xml_import_plugin +################################################################################### + +set( knipptasch_import_plugin_SOURCES + xmlimportplugin.cpp + xmlreader.cpp + ) + +set( knipptasch_import_plugin_HEADERS + xmlimportplugin.h + xmlreader.h + ) + +set( knipptasch_import_plugin_FORMS + #xmlimportdialog.ui + ) + +qt4_wrap_ui( knipptasch_import_plugin_SOURCES ${knipptasch_import_plugin_FORMS} ) +qt4_wrap_cpp( knipptasch_import_plugin_SOURCES ${knipptasch_import_plugin_HEADERS} ) + +add_library( knipptasch_xml_import_plugin SHARED ${knipptasch_import_plugin_SOURCES} ) +target_link_libraries( knipptasch_xml_import_plugin ${QT_LIBRARIES} knipptasch compat ) + +install( TARGETS knipptasch_xml_import_plugin DESTINATION ${KNIPPTASCH_PLUGIN_INSTALL_DIR} ) diff --git a/plugins/xml/xmlexportplugin.cpp b/plugins/xml/xmlexportplugin.cpp index 203ffb3..d7c6b9a 100644 --- a/plugins/xml/xmlexportplugin.cpp +++ b/plugins/xml/xmlexportplugin.cpp @@ -29,11 +29,31 @@ #include -XmlExportPlugin::XmlExportPlugin() +XmlExportPlugin::XmlExportPlugin(QObject *parent) + : QObject( parent ) { } +QByteArray XmlExportPlugin::pluginIdentifier() const +{ + return "xml_export_plugin"; +} + + +QString XmlExportPlugin::pluginName() const +{ + return tr( "XML Export Plugin" ); + +} + + +QByteArray XmlExportPlugin::pluginVersion() const +{ + return "0.0.1"; +} + + QString XmlExportPlugin::exportActionName() const { return QObject::tr( "Export &XML File..." ); @@ -67,5 +87,7 @@ void XmlExportPlugin::exportAccount(const Account *account, const QList /** @@ -26,10 +26,18 @@ * * @author Stefan Böhmann */ -class XmlExportPlugin : public ExportPlugin +class XmlExportPlugin : public QObject, public Knipptasch::ExportPlugin { + Q_OBJECT + Q_INTERFACES( Knipptasch::Plugin ) + Q_INTERFACES( Knipptasch::ExportPlugin ) + public: - XmlExportPlugin(); + XmlExportPlugin(QObject *parent = 0); + + QByteArray pluginIdentifier() const; + QString pluginName() const; + QByteArray pluginVersion() const; QString exportActionName() const; QPixmap exportActionIcon() const; diff --git a/plugins/xml/xmlimportplugin.cpp b/plugins/xml/xmlimportplugin.cpp index 94b05d5..034e920 100644 --- a/plugins/xml/xmlimportplugin.cpp +++ b/plugins/xml/xmlimportplugin.cpp @@ -35,12 +35,32 @@ -XmlImportPlugin::XmlImportPlugin() +XmlImportPlugin::XmlImportPlugin(QObject *parent) + : QObject( parent ) { qsrand( QTime::currentTime().msec() ); } +QByteArray XmlImportPlugin::pluginIdentifier() const +{ + return "xml_import_plugin"; +} + + +QString XmlImportPlugin::pluginName() const +{ + return tr( "XML Import Plugin" ); + +} + + +QByteArray XmlImportPlugin::pluginVersion() const +{ + return "0.0.1"; +} + + QString XmlImportPlugin::importActionName() const { return QObject::tr( "Import &XML File..." ); @@ -80,5 +100,7 @@ Account* XmlImportPlugin::importAccount(QWidget *parent) const } +Q_EXPORT_PLUGIN2( "XmlImportPlugin", XmlImportPlugin ); + // kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; replace-tabs on; space-indent on; // vim:set spell et sw=4 ts=4 nowrap cino=l1,cs,U1: diff --git a/plugins/xml/xmlimportplugin.h b/plugins/xml/xmlimportplugin.h index f2d731e..276f501 100644 --- a/plugins/xml/xmlimportplugin.h +++ b/plugins/xml/xmlimportplugin.h @@ -17,7 +17,7 @@ #ifndef XMLIMPORTPLUGIN_H #define XMLIMPORTPLUGIN_H -#include "interface/importplugin.h" +#include /** @@ -26,10 +26,18 @@ * * @author Stefan Böhmann */ -class XmlImportPlugin : public ImportPlugin +class XmlImportPlugin : public QObject, public Knipptasch::ImportPlugin { + Q_OBJECT + Q_INTERFACES( Knipptasch::Plugin ) + Q_INTERFACES( Knipptasch::ImportPlugin ) + public: - XmlImportPlugin(); + XmlImportPlugin(QObject *parent = 0); + + QByteArray pluginIdentifier() const; + QString pluginName() const; + QByteArray pluginVersion() const; QString importActionName() const; QPixmap importActionIcon() const;
ExpressionOutput
Text Date%1
ISO Date%2
Short Date%3
Long Date%4