1
/* This file is part of the KDE project
2
Copyright (C) 2005, 2012 Dag Andersen <danders@get2net.dk>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Library General Public
6
License as published by the Free Software Foundation; either
7
version 2 of the License, or (at your option) any later version.
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Library General Public License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to
16
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
* Boston, MA 02110-1301, USA.
20
#include "kptaccountsviewconfigdialog.h"
22
#include "kptaccountsview.h"
23
#include "kptaccountsmodel.h"
24
#include "kptviewbase.h"
27
#include "KoPageLayoutWidget.h"
29
#include <KLocalizedString>
31
#include <QPushButton>
39
AccountsviewConfigDialog::AccountsviewConfigDialog( ViewBase *view, AccountsTreeView *treeview, QWidget *p, bool selectPrint)
42
m_treeview( treeview )
44
setWindowTitle( i18n("Settings") );
45
m_panel = new AccountsviewConfigPanel( this );
46
switch ( treeview->startMode() ) {
47
case CostBreakdownItemModel::StartMode_Project:
48
m_panel->ui_projectstartBtn->setChecked( true );
49
m_panel->ui_startdate->setEnabled( false );
51
case CostBreakdownItemModel::StartMode_Date:
52
m_panel->ui_startdateBtn->setChecked( true );
55
switch ( treeview->endMode() ) {
56
case CostBreakdownItemModel::EndMode_Project:
57
m_panel->ui_projectendBtn->setChecked( true );
58
m_panel->ui_enddate->setEnabled( false );
60
case CostBreakdownItemModel::EndMode_Date:
61
m_panel->ui_enddateBtn->setChecked( true );
63
case CostBreakdownItemModel::EndMode_CurrentDate:
64
m_panel->ui_currentdateBtn->setChecked( true );
65
m_panel->ui_enddate->setEnabled( false );
68
m_panel->ui_startdate->setDate( treeview->startDate() );
69
m_panel->ui_enddate->setDate( treeview->endDate() );
70
m_panel->ui_periodBox->setCurrentIndex( treeview->periodType() );
71
m_panel->ui_cumulative->setChecked( treeview->cumulative() );
72
m_panel->ui_showBox->setCurrentIndex( treeview->showMode() );
74
KPageWidgetItem *page = addPage( m_panel, i18n( "General" ) );
75
page->setHeader( i18n( "View Settings" ) );
77
QTabWidget *tab = new QTabWidget();
79
QWidget *w = ViewBase::createPageLayoutWidget( view );
80
tab->addTab( w, w->windowTitle() );
81
m_pagelayout = w->findChild<KoPageLayoutWidget*>();
82
Q_ASSERT( m_pagelayout );
84
m_headerfooter = ViewBase::createHeaderFooterWidget( view );
85
m_headerfooter->setOptions( view->printingOptions() );
86
tab->addTab( m_headerfooter, m_headerfooter->windowTitle() );
88
page = addPage( tab, i18n( "Printing" ) );
89
page->setHeader( i18n( "Printing Options" ) );
93
connect( this, SIGNAL(accepted()), this, SLOT(slotOk()));
95
connect(m_panel, SIGNAL(changed(bool)), SLOT(enableOkButton(bool)));
98
void AccountsviewConfigDialog::enableOkButton(bool enabled)
100
button( QDialogButtonBox::Ok )->setEnabled( enabled );
104
void AccountsviewConfigDialog::slotOk()
107
m_treeview->setPeriodType( m_panel->ui_periodBox->currentIndex() );
108
m_treeview->setCumulative( m_panel->ui_cumulative->isChecked() );
109
m_treeview->setShowMode( m_panel->ui_showBox->currentIndex() );
110
if ( m_panel->ui_startdateBtn->isChecked() ) {
111
m_treeview->setStartDate( m_panel->ui_startdate->date() );
112
m_treeview->setStartMode( CostBreakdownItemModel::StartMode_Date );
114
m_treeview->setStartMode( CostBreakdownItemModel::StartMode_Project );
117
if ( m_panel->ui_enddateBtn->isChecked() ) {
118
m_treeview->setEndDate( m_panel->ui_enddate->date() );
119
m_treeview->setEndMode( CostBreakdownItemModel::EndMode_Date );
120
} else if ( m_panel->ui_currentdateBtn->isChecked() ) {
121
m_treeview->setEndMode( CostBreakdownItemModel::EndMode_CurrentDate );
123
m_treeview->setEndMode( CostBreakdownItemModel::EndMode_Project );
126
m_view->setPageLayout( m_pagelayout->pageLayout() );
127
m_view->setPrintingOptions( m_headerfooter->options() );
131
//----------------------------
132
AccountsviewConfigPanel::AccountsviewConfigPanel(QWidget *parent)
133
: AccountsviewConfigurePanelBase(parent)
136
connect(ui_startdate, SIGNAL(dateChanged(QDate)), SLOT(slotChanged()));
137
connect(ui_enddate, SIGNAL(dateChanged(QDate)), SLOT(slotChanged()));
138
connect(ui_periodBox, SIGNAL(activated(int)), SLOT(slotChanged()));
139
connect(ui_cumulative, SIGNAL(clicked()), SLOT(slotChanged()));
141
connect(ui_projectstartBtn, SIGNAL(clicked()), SLOT(slotChanged()));
142
connect(ui_startdateBtn, SIGNAL(clicked()), SLOT(slotChanged()));
143
connect(ui_projectendBtn, SIGNAL(clicked()), SLOT(slotChanged()));
144
connect(ui_currentdateBtn, SIGNAL(clicked()), SLOT(slotChanged()));
145
connect(ui_enddateBtn, SIGNAL(clicked()), SLOT(slotChanged()));
146
connect(ui_showBox, SIGNAL(activated(int)), SLOT(slotChanged()));
148
connect(ui_startdateBtn, SIGNAL(toggled(bool)), ui_startdate, SLOT(setEnabled(bool)));
149
connect(ui_enddateBtn, SIGNAL(toggled(bool)), ui_enddate, SLOT(setEnabled(bool)));
152
void AccountsviewConfigPanel::slotChanged() {