From kde-commits Mon Jan 31 23:37:22 2011 From: =?utf-8?q?Stefan_B=C3=B6hmann?= Date: Mon, 31 Jan 2011 23:37:22 +0000 To: kde-commits Subject: =?utf-8?q?=5Bknipptasch=5D_/=3A_Move_AbstractAccountTabWidget_fr?= Message-Id: <20110131233722.AE855A60BE () git ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=129651712606193 Git commit 736bc7007aeb66b7397380ee278686af33b0876e by Stefan Böhmann. Pushed by sboehmann into branch 'master'. Move AbstractAccountTabWidget from gui/ to core/ M +6 -0 core/CMakeLists.txt A +207 -0 core/abstractaccounttabwidget.cpp [License: GPL (v2+)] A +93 -0 core/abstractaccounttabwidget.h [License: GPL (v2+)] A +33 -0 core/abstractaccounttabwidgetplugin.cpp [License: GPL (v2+)] A +57 -0 core/abstractaccounttabwidgetplugin.h [License: GPL (v2+)] A +1 -0 core/include/Knipptasch/AbstractAccountTabWidget [License: UNKNOWN] M +1 -9 gui/CMakeLists.txt M +1 -6 gui/accountwidget.cpp D +0 -208 gui/interface/abstractaccounttabwidget.cpp D +0 -91 gui/interface/abstractaccounttabwidget.h http://commits.kde.org/knipptasch/736bc7007aeb66b7397380ee278686af33b0876e diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 5df4818..5b4a670 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -16,6 +16,9 @@ set( knipptasch_core_SOURCES plugin.cpp exportplugin.cpp importplugin.cpp + abstractaccounttabwidgetplugin.cpp + + abstractaccounttabwidget.cpp accountmodel.cpp @@ -39,6 +42,9 @@ set( knipptasch_core_HEADERS plugin.h exportplugin.h importplugin.h + abstractaccounttabwidgetplugin.h + + abstractaccounttabwidget.h accountmodel.h diff --git a/core/abstractaccounttabwidget.cpp b/core/abstractaccounttabwidget.cpp new file mode 100644 index 0000000..d570dc4 --- /dev/null +++ b/core/abstractaccounttabwidget.cpp @@ -0,0 +1,207 @@ +/* + * Copyright 2010 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 "abstractaccounttabwidget.h" + +#include "accountmodel.h" +#include "backend/account.h" + +#include +#include + + +struct AbstractAccountTabWidget::Private +{ + Private() + : model( 0 ) + { + } + + AccountModel *model; + QModelIndex index; + + QIcon icon; + QString label; + QString toolTip; + QString whatsThis; +}; + + + +AbstractAccountTabWidget::AbstractAccountTabWidget(const QString &title, QWidget *parent) + : QWidget( parent ), + d( new AbstractAccountTabWidget::Private ) +{ + d->label = title; +} + + +AbstractAccountTabWidget::AbstractAccountTabWidget(const QString &title, const QIcon &icon, QWidget *parent) + : QWidget( parent ), + d( new AbstractAccountTabWidget::Private ) +{ + d->label = title; + d->icon = icon; +} + + +AbstractAccountTabWidget::~AbstractAccountTabWidget() +{ + delete d; +} + + +AccountModel* AbstractAccountTabWidget::accountModel() +{ + Q_ASSERT( d ); + + return d->model; +} + + +const AccountModel* AbstractAccountTabWidget::accountModel() const +{ + Q_ASSERT( d ); + + return d->model; +} + + +void AbstractAccountTabWidget::setAccountModel(AccountModel *model) +{ + if( d->model != model ) { + setCurrentSelectedIndex( QModelIndex() ); + + accountModelAboutToBeChanged(); + d->model = model; + accountModelChanged( d->model ); + } +} + + +QModelIndex AbstractAccountTabWidget::currentSelectedIndex() const +{ + Q_ASSERT( d ); + + return d->index; +} + + +QIcon AbstractAccountTabWidget::icon() const +{ + Q_ASSERT( d ); + + return d->icon; +} + + +QString AbstractAccountTabWidget::label() const +{ + Q_ASSERT( d ); + + return d->label; +} + +QString AbstractAccountTabWidget::tabToolTip() const +{ + Q_ASSERT( d ); + + return d->toolTip; +} + + +QString AbstractAccountTabWidget::tabWhatsThis() const +{ + Q_ASSERT( d ); + + return d->whatsThis; +} + + +void AbstractAccountTabWidget::setCurrentSelectedIndex(const QModelIndex &index) +{ + Q_ASSERT( d ); + + if( d->index != index ) { + currentSelectedIndexAboutToBeChanged(); + d->index = index; + currentSelectedIndexChanged( d->index ); + } +} + + +void AbstractAccountTabWidget::setIcon(const QIcon &ico) +{ + Q_ASSERT( d ); + + d->icon = ico; + emit updateTabView( this ); +} + + +void AbstractAccountTabWidget::setLabel(const QString &str) +{ + Q_ASSERT( d ); + + if( d->label != str ) { + d->label = str; + emit updateTabView( this ); + } +} + + +void AbstractAccountTabWidget::setToolTip(const QString &str) +{ + Q_ASSERT( d ); + + if( d->toolTip != str ) { + d->toolTip = str; + emit updateTabView( this ); + } +} + + +void AbstractAccountTabWidget::setWhatsThis(const QString &str) +{ + Q_ASSERT( d ); + + if( d->whatsThis != str ) { + d->whatsThis = str; + emit updateTabView( this ); + } +} + + +void AbstractAccountTabWidget::accountModelAboutToBeChanged() +{ +} + + +void AbstractAccountTabWidget::currentSelectedIndexAboutToBeChanged() +{ +} + + +void AbstractAccountTabWidget::changeEvent(QEvent *event) +{ + if( event->type() == QEvent::EnabledChange ) { + emit updateTabView( this ); + } +} + + +// 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/core/abstractaccounttabwidget.h b/core/abstractaccounttabwidget.h new file mode 100644 index 0000000..2fb7347 --- /dev/null +++ b/core/abstractaccounttabwidget.h @@ -0,0 +1,93 @@ +/* + * Copyright 2010 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 KNIPPTASCH_CORE_ABSTRACTACCOUNTTABWIDGET_H +#define KNIPPTASCH_CORE_ABSTRACTACCOUNTTABWIDGET_H + +#include "knipptasch_core_export.h" + +#include + +class AccountModel; +class QModelIndex; + + +/** + * @class AbstractAccountTabWidget + * @brief Abstract base class that provides an interface for account tab widgets. + * + * @author Stefan Böhmann + */ +class KNIPPTASCH_CORE_EXPORT AbstractAccountTabWidget : public QWidget +{ + Q_OBJECT + + public: + explicit AbstractAccountTabWidget(const QString &title, QWidget *parent = 0); + AbstractAccountTabWidget(const QString &title, const QIcon &icon, QWidget *parent = 0); + + /** + * Default Destructor + */ + virtual ~AbstractAccountTabWidget(); + + AccountModel* accountModel(); + const AccountModel* accountModel() const; + void setAccountModel(AccountModel *model); + + QModelIndex currentSelectedIndex() const; + + /** + * Returns a icon for the tab. + * Calls virtual tabIcon() if the user wants a icon, + * else returns a empty icon. + */ + QIcon icon() const; + QString label() const; + QString tabToolTip() const; + QString tabWhatsThis() const; + + signals: + void updateTabView(AbstractAccountTabWidget *widget); + + public slots: + void setCurrentSelectedIndex(const QModelIndex &index); + + protected slots: + void setIcon(const QIcon &icon); + void setLabel(const QString &str); + void setToolTip(const QString &str); + void setWhatsThis(const QString &str); + + protected: + virtual void accountModelAboutToBeChanged(); + virtual void accountModelChanged(AccountModel *model) = 0; + virtual void currentSelectedIndexAboutToBeChanged(); + virtual void currentSelectedIndexChanged(const QModelIndex &index) = 0; + + void changeEvent(QEvent *event); + + private: + class Private; + Private * const d; +}; + + + +#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/core/abstractaccounttabwidgetplugin.cpp b/core/abstractaccounttabwidgetplugin.cpp new file mode 100644 index 0000000..fce785d --- /dev/null +++ b/core/abstractaccounttabwidgetplugin.cpp @@ -0,0 +1,33 @@ +/* + * Copyright 2011 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 "abstractaccounttabwidgetplugin.h" + + +namespace Knipptasch +{ + + + AbstractAccountTabWidgetPlugin::~AbstractAccountTabWidgetPlugin() + { + } + + +} //EndNamespace Knipptasch + + +// 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/core/abstractaccounttabwidgetplugin.h b/core/abstractaccounttabwidgetplugin.h new file mode 100644 index 0000000..70b6db1 --- /dev/null +++ b/core/abstractaccounttabwidgetplugin.h @@ -0,0 +1,57 @@ +/* + * Copyright 2011 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 KNIPPTASCH_CORE_ABSTRACT_ACCOUNT_TAB_WIDGET_PLUGIN_H +#define KNIPPTASCH_CORE_ABSTRACT_ACCOUNT_TAB_WIDGET_PLUGIN_H + +#include "plugin.h" + +class AbstractAccountTabWidget; + + +/** + * @namespace Knipptasch + * @brief Default namespace for Knipptasch + * + * @author Stefan Böhmann + */ +namespace Knipptasch +{ + + /** + * @class AbstractAccountTabWidgetPlugin + * @brief + * + * @author Stefan Böhmann + */ + class KNIPPTASCH_CORE_EXPORT AbstractAccountTabWidgetPlugin : public Plugin + { + public: + virtual AbstractAccountTabWidget* widget() = 0; + + protected: + virtual ~AbstractAccountTabWidgetPlugin(); + }; + +} // EndNamspace Knipptasch + + +Q_DECLARE_INTERFACE( Knipptasch::AbstractAccountTabWidgetPlugin, "org.kde.Knipptasch.AbstractAccountTabWidgetPlugin/0.1" ); + +#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/core/include/Knipptasch/AbstractAccountTabWidget b/core/include/Knipptasch/AbstractAccountTabWidget new file mode 100644 index 0000000..958c334 --- /dev/null +++ b/core/include/Knipptasch/AbstractAccountTabWidget @@ -0,0 +1 @@ +#include "abstractaccounttabwidget.h" diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index 3556c7f..bc46d2f 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -29,12 +29,6 @@ set(knipptasch_SOURCES config/preferencesaccounttableconfigpage.cpp config/appearancecolorchooserwidget.cpp - interface/abstractaccounttabwidget.cpp - - #accounttabwidgets/postingtabwidget.cpp - #accounttabwidgets/descriptiontabwidget.cpp - #accounttabwidgets/splitpostingtabwidget.cpp - delegate/datedelegate.cpp delegate/moneydelegate.cpp delegate/postingtextdelegate.cpp @@ -70,8 +64,6 @@ set( knipptasch_HEADERS config/preferencesaccounttableconfigpage.h config/appearancecolorchooserwidget.h - interface/abstractaccounttabwidget.h - delegate/datedelegate.h delegate/moneydelegate.h delegate/postingtextdelegate.h @@ -166,7 +158,7 @@ else( HAVE_KDE ) ) set_target_properties( knipptasch-bin PROPERTIES OUTPUT_NAME knipptasch ) - + install( TARGETS knipptasch-bin ${INSTALL_TARGETS_DEFAULT_ARGS} ) install( FILES ${QM_FILES} DESTINATION ${KNIPPTASCH_LOCALE_INSTALL_DIR} ) endif( HAVE_KDE ) diff --git a/gui/accountwidget.cpp b/gui/accountwidget.cpp index d4e0730..c21911c 100644 --- a/gui/accountwidget.cpp +++ b/gui/accountwidget.cpp @@ -30,12 +30,6 @@ #include "delegate/moneydelegate.h" #include "delegate/categorydelegate.h" -#include "interface/abstractaccounttabwidget.h" - -#include "accounttabwidgets/postingtabwidget.h" -#include "accounttabwidgets/splitpostingtabwidget.h" -#include "accounttabwidgets/descriptiontabwidget.h" - #include "compat/iconloader.h" #include "compat/actioncollection.h" #include "compat/standardaction.h" @@ -45,6 +39,7 @@ #include #include #include +#include #include diff --git a/gui/interface/abstractaccounttabwidget.cpp b/gui/interface/abstractaccounttabwidget.cpp deleted file mode 100644 index a6cc1a2..0000000 --- a/gui/interface/abstractaccounttabwidget.cpp +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Copyright 2010 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 "abstractaccounttabwidget.h" - -#include "accountmodel.h" -#include "backend/account.h" -#include "preferences.h" - -#include -#include - - -struct AbstractAccountTabWidget::Private -{ - Private() - : model( 0 ) - { - } - - AccountModel *model; - QModelIndex index; - - QIcon icon; - QString label; - QString toolTip; - QString whatsThis; -}; - - - -AbstractAccountTabWidget::AbstractAccountTabWidget(const QString &title, QWidget *parent) - : QWidget( parent ), - d( new AbstractAccountTabWidget::Private ) -{ - d->label = title; -} - - -AbstractAccountTabWidget::AbstractAccountTabWidget(const QString &title, const QIcon &icon, QWidget *parent) - : QWidget( parent ), - d( new AbstractAccountTabWidget::Private ) -{ - d->label = title; - d->icon = icon; -} - - -AbstractAccountTabWidget::~AbstractAccountTabWidget() -{ - delete d; -} - - -AccountModel* AbstractAccountTabWidget::accountModel() -{ - Q_ASSERT( d ); - - return d->model; -} - - -const AccountModel* AbstractAccountTabWidget::accountModel() const -{ - Q_ASSERT( d ); - - return d->model; -} - - -void AbstractAccountTabWidget::setAccountModel(AccountModel *model) -{ - if( d->model != model ) { - setCurrentSelectedIndex( QModelIndex() ); - - accountModelAboutToBeChanged(); - d->model = model; - accountModelChanged( d->model ); - } -} - - -QModelIndex AbstractAccountTabWidget::currentSelectedIndex() const -{ - Q_ASSERT( d ); - - return d->index; -} - - -QIcon AbstractAccountTabWidget::icon() const -{ - Q_ASSERT( d ); - - return d->icon; -} - - -QString AbstractAccountTabWidget::label() const -{ - Q_ASSERT( d ); - - return d->label; -} - -QString AbstractAccountTabWidget::tabToolTip() const -{ - Q_ASSERT( d ); - - return d->toolTip; -} - - -QString AbstractAccountTabWidget::tabWhatsThis() const -{ - Q_ASSERT( d ); - - return d->whatsThis; -} - - -void AbstractAccountTabWidget::setCurrentSelectedIndex(const QModelIndex &index) -{ - Q_ASSERT( d ); - - if( d->index != index ) { - currentSelectedIndexAboutToBeChanged(); - d->index = index; - currentSelectedIndexChanged( d->index ); - } -} - - -void AbstractAccountTabWidget::setIcon(const QIcon &ico) -{ - Q_ASSERT( d ); - - d->icon = ico; - emit updateTabView( this ); -} - - -void AbstractAccountTabWidget::setLabel(const QString &str) -{ - Q_ASSERT( d ); - - if( d->label != str ) { - d->label = str; - emit updateTabView( this ); - } -} - - -void AbstractAccountTabWidget::setToolTip(const QString &str) -{ - Q_ASSERT( d ); - - if( d->toolTip != str ) { - d->toolTip = str; - emit updateTabView( this ); - } -} - - -void AbstractAccountTabWidget::setWhatsThis(const QString &str) -{ - Q_ASSERT( d ); - - if( d->whatsThis != str ) { - d->whatsThis = str; - emit updateTabView( this ); - } -} - - -void AbstractAccountTabWidget::accountModelAboutToBeChanged() -{ -} - - -void AbstractAccountTabWidget::currentSelectedIndexAboutToBeChanged() -{ -} - - -void AbstractAccountTabWidget::changeEvent(QEvent *event) -{ - if( event->type() == QEvent::EnabledChange ) { - emit updateTabView( this ); - } -} - - -// 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/gui/interface/abstractaccounttabwidget.h b/gui/interface/abstractaccounttabwidget.h deleted file mode 100644 index 095f78d..0000000 --- a/gui/interface/abstractaccounttabwidget.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2010 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 ABSTRACTACCOUNTTABWIDGET_H -#define ABSTRACTACCOUNTTABWIDGET_H - -#include - -class AccountModel; -class QModelIndex; - - -/** - * @class AbstractAccountTabWidget - * @brief Abstract base class that provides an interface for account tab widgets. - * - * @author Stefan Böhmann - */ -class AbstractAccountTabWidget : public QWidget -{ - Q_OBJECT - - public: - explicit AbstractAccountTabWidget(const QString &title, QWidget *parent = 0); - AbstractAccountTabWidget(const QString &title, const QIcon &icon, QWidget *parent = 0); - - /** - * Default Destructor - */ - virtual ~AbstractAccountTabWidget(); - - AccountModel* accountModel(); - const AccountModel* accountModel() const; - void setAccountModel(AccountModel *model); - - QModelIndex currentSelectedIndex() const; - - /** - * Returns a icon for the tab. - * Calls virtual tabIcon() if the user wants a icon, - * else returns a empty icon. - */ - QIcon icon() const; - QString label() const; - QString tabToolTip() const; - QString tabWhatsThis() const; - - signals: - void updateTabView(AbstractAccountTabWidget *widget); - - public slots: - void setCurrentSelectedIndex(const QModelIndex &index); - - protected slots: - void setIcon(const QIcon &icon); - void setLabel(const QString &str); - void setToolTip(const QString &str); - void setWhatsThis(const QString &str); - - protected: - virtual void accountModelAboutToBeChanged(); - virtual void accountModelChanged(AccountModel *model) = 0; - virtual void currentSelectedIndexAboutToBeChanged(); - virtual void currentSelectedIndexChanged(const QModelIndex &index) = 0; - - void changeEvent(QEvent *event); - - private: - class Private; - Private * const d; -}; - - - -#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: