1/* This file is part of the KDE project
2 Copyright (C) 2009 Dag Andersen <calligra-devel@kde.org>
3
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.
8
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.
13
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.
18*/
19
20#include "kpttaskcompletedelegate.h"
21
22#include "kptnodeitemmodel.h"
23#include "kptnode.h"
24
25#include <kdebug.h>
26
27#include <QModelIndex>
28#include <QApplication>
29#include <QToolTip>
30#include <QStyleOptionViewItem>
31#include <QStyle>
32#include <QPainter>
33
34namespace KPlato
35{
36
37//-----------------------------
38TaskCompleteDelegate::TaskCompleteDelegate( QObject *parent )
39 : ProgressBarDelegate( parent )
40{
41}
42
43TaskCompleteDelegate::~TaskCompleteDelegate()
44{
45}
46
47void TaskCompleteDelegate::paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const
48{
49 QModelIndex typeidx = index.model()->index( index.row(), NodeModel::NodeType, index.parent() );
50 if ( ! typeidx.isValid() ) {
51 kError()<<"Cannot find nodetype for index:"<<index;
52 return;
53 }
54 int type = typeidx.data( Qt::EditRole ).toInt();
55 if ( type == Node::Type_Task || type == Node::Type_Milestone ) {
56 ProgressBarDelegate::paint( painter, option, index );
57 } else {
58 QStyle *style;
59 QStyleOptionViewItemV4 opt = option;
60 //initStyleOption( &opt, index );
61 style = opt.widget ? opt.widget->style() : QApplication::style();
62 style->drawPrimitive( QStyle::PE_PanelItemViewItem, &opt, painter );
63
64 //kDebug(planDbg())<<"Draw something else, type="<<type<<index.model()->index( index.row(), NodeModel::NodeName, index.parent() ).data().toString();
65
66 ItemDelegate::paint( painter, option, index );
67 }
68}
69
70} //namespace KPlato
71
72#include "kpttaskcompletedelegate.moc"
73