diff --git a/src/libs/ui/kptaccountsview.cpp b/src/libs/ui/kptaccountsview.cpp index 1cbbcb9e..69b68a7e 100644 --- a/src/libs/ui/kptaccountsview.cpp +++ b/src/libs/ui/kptaccountsview.cpp @@ -1,337 +1,338 @@ /* This file is part of the KDE project Copyright (C) 2005 - 2006, 2012 Dag Andersen danders@get2net> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ // clazy:excludeall=qstring-arg #include "kptaccountsview.h" #include "kptaccountsviewconfigdialog.h" #include "kptdatetime.h" #include "kptproject.h" #include "kpteffortcostmap.h" #include "kptaccountsmodel.h" #include "Help.h" #include "kptdebug.h" #include #include #include #include #include #include #include namespace KPlato { AccountsTreeView::AccountsTreeView( QWidget *parent ) : DoubleTreeViewBase( parent ) { debugPlan<<"---------------"<header(); v->setStretchLastSection( false ); v->setSectionResizeMode( CostBreakdownItemModel::Description, QHeaderView::Stretch ); v->setSectionResizeMode ( CostBreakdownItemModel::Total, QHeaderView::ResizeToContents ); v = m_rightview->header(); v->setSectionResizeMode ( QHeaderView::ResizeToContents ); v->setStretchLastSection( false ); m_leftHidden = QList() << CostBreakdownItemModel::Planned << CostBreakdownItemModel::Actual << -1; slotModelReset(); connect( m, &QAbstractItemModel::modelReset, this, &AccountsTreeView::slotModelReset ); Help::add(this, xi18nc("@info:whatsthis", "Cost Breakdown View" "" "Displays aggregated total cost as well as cost distribution over time." "" "This view supports configuration and printing using the context menu." "More..." "", Help::page("Manual/Cost_Breakdown_View"))); } void AccountsTreeView::slotModelReset() { hideColumns( m_leftHidden ); QHeaderView *v = m_leftview->header(); debugPlan<sectionSize(2)<sectionSizeHint(2)<defaultSectionSize()<minimumSectionSize(); CostBreakdownItemModel *m = static_cast(model()); QList cols; for (int c = 0; c < m->propertyCount(); ++c) { cols << c; } hideColumns( m_rightview, cols); } CostBreakdownItemModel *AccountsTreeView::model() const { return static_cast( DoubleTreeViewBase::model() ); } bool AccountsTreeView::cumulative() const { return model()->cumulative(); } void AccountsTreeView::setCumulative( bool on ) { model()->setCumulative( on ); } int AccountsTreeView::periodType() const { return model()->periodType(); } void AccountsTreeView::setPeriodType( int period ) { model()->setPeriodType( period ); } int AccountsTreeView::startMode() const { return model()->startMode(); } void AccountsTreeView::setStartMode( int mode ) { model()->setStartMode( mode ); } int AccountsTreeView::endMode() const { return model()->endMode(); } void AccountsTreeView::setEndMode( int mode ) { model()->setEndMode( mode ); } QDate AccountsTreeView::startDate() const { return model()->startDate(); } void AccountsTreeView::setStartDate( const QDate &date ) { model()->setStartDate( date ); } QDate AccountsTreeView::endDate() const { return model()->endDate(); } void AccountsTreeView::setEndDate( const QDate &date ) { model()->setEndDate( date ); } int AccountsTreeView::showMode() const { return model()->showMode(); } void AccountsTreeView::setShowMode( int show ) { model()->setShowMode( show ); } //------------------------ AccountsView::AccountsView(KoPart *part, Project *project, KoDocument *doc, QWidget *parent ) : ViewBase(part, doc, parent), m_project(project), m_manager( 0 ) { setXMLFile("AccountsViewUi.rc"); init(); setupGui(); connect(this, &ViewBase::expandAll, m_view, &DoubleTreeViewBase::slotExpand); connect(this, &ViewBase::collapseAll, m_view, &DoubleTreeViewBase::slotCollapse); connect( m_view, &DoubleTreeViewBase::contextMenuRequested, this, &AccountsView::slotContextMenuRequested ); connect( m_view, SIGNAL(headerContextMenuRequested(QPoint)), SLOT(slotHeaderContextMenuRequested(QPoint)) ); } void AccountsView::setZoom( double zoom ) { Q_UNUSED( zoom ); } void AccountsView::init() { QVBoxLayout *l = new QVBoxLayout( this ); l->setMargin(0); m_view = new AccountsTreeView( this ); l->addWidget( m_view ); setProject( m_project ); } void AccountsView::setupGui() { createOptionActions(ViewBase::OptionAll); } void AccountsView::slotContextMenuRequested( const QModelIndex &index, const QPoint &pos ) { debugPlan; m_view->setContextMenuIndex(index); slotHeaderContextMenuRequested( pos ); m_view->setContextMenuIndex(QModelIndex()); } void AccountsView::slotHeaderContextMenuRequested( const QPoint &pos ) { debugPlan; QList lst = contextActionList(); if ( ! lst.isEmpty() ) { QMenu::exec( lst, pos, lst.first() ); } } void AccountsView::slotOptions() { debugPlan; AccountsviewConfigDialog *dlg = new AccountsviewConfigDialog( this, m_view, this, sender()->objectName() == "print_options" ); connect(dlg, SIGNAL(finished(int)), SLOT(slotOptionsFinished(int))); dlg->open(); } void AccountsView::setProject( Project *project ) { model()->setProject( project ); m_project = project; } void AccountsView::setScheduleManager( ScheduleManager *sm ) { if (!sm && m_manager) { // we should only get here if the only schedule manager is scheduled, // or when last schedule manager is deleted m_domdoc.clear(); QDomElement element = m_domdoc.createElement("expanded"); m_domdoc.appendChild(element); m_view->masterView()->saveExpanded(element); } bool tryexpand = sm && !m_manager; bool expand = sm && m_manager && sm != m_manager; QDomDocument doc; if (expand) { QDomElement element = doc.createElement("expanded"); doc.appendChild(element); m_view->masterView()->saveExpanded(element); } m_manager = sm; model()->setScheduleManager( sm ); if (expand) { m_view->masterView()->doExpand(doc); } else if (tryexpand) { m_view->masterView()->doExpand(m_domdoc); } } CostBreakdownItemModel *AccountsView::model() const { return static_cast( m_view->model() ); } #if 0 void AccountsView::print( QPrinter &printer, QPrintDialog &printDialog ) { //debugPlan; uint top, left, bottom, right; printer.margins( &top, &left, &bottom, &right ); //debugPlan<setCumulative( (bool)( context.attribute( "cumulative" ).toInt() ) ); m_view->setPeriodType( context.attribute( "period-type", "0" ).toInt() ); m_view->setStartDate( QDate::fromString( context.attribute( "start-date", "" ), Qt::ISODate ) ); m_view->setStartMode( context.attribute( "start-mode", "0" ).toInt() ); m_view->setEndDate( QDate::fromString( context.attribute( "end-date", "" ), Qt::ISODate ) ); m_view->setEndMode( context.attribute( "end-mode", "0" ).toInt() ); //debugPlan<startMode()<startDate()<endMode()<endDate(); - m_view->masterView()->setObjectName("AccountsView"); - m_view->loadContext(model()->columnMap(), context); + // Skip context loading, it doea not work for this type of view + // m_view->masterView()->setObjectName("AccountsView"); + // m_view->loadContext(model()->columnMap(), context); return true; } void AccountsView::saveContext( QDomElement &context ) const { //debugPlan; ViewBase::saveContext( context ); context.setAttribute( "show-mode", QString::number(m_view->showMode()) ); context.setAttribute( "cumulative", QString::number(m_view->cumulative()) ); context.setAttribute( "period-type", QString::number(m_view->periodType()) ); context.setAttribute( "start-mode", QString::number(m_view->startMode()) ); context.setAttribute( "start-date", m_view->startDate().toString( Qt::ISODate ) ); context.setAttribute( "end-mode", QString::number(m_view->endMode()) ); context.setAttribute( "end-date", m_view->endDate().toString( Qt::ISODate ) ); m_view->saveContext(model()->columnMap(), context); } KoPrintJob *AccountsView::createPrintJob() { return m_view->createPrintJob( this ); } } //KPlato namespace