1 /*
2  * Copyright (C) 2001-2015 Klaralvdalens Datakonsult AB.  All rights reserved.
3  *
4  * This file is part of the KGantt library.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
18  */
19 
20 #include "kganttstyleoptionganttitem.h"
21 
22 using namespace KGantt;
23 
24 /*!\class KGantt::StyleOptionGanttItem kganttstyleoptionganttitem.h KGanttStyleOptionGanttItem
25  * \ingroup KGantt
26  * \brief QStyleOption subclass for gantt items.
27  */
28 
29 typedef QStyleOptionViewItem BASE;
30 
31 /*! Constructor. Sets grid to 0. */
StyleOptionGanttItem()32 StyleOptionGanttItem::StyleOptionGanttItem()
33     : BASE(),
34       displayPosition( Left ),
35       grid( nullptr )
36 {
37     type = QStyleOption::SO_CustomBase+89;
38     version = 1;
39 }
40 
41 /*! Copy constructor. Creates a copy of \a other */
StyleOptionGanttItem(const StyleOptionGanttItem & other)42 StyleOptionGanttItem::StyleOptionGanttItem( const StyleOptionGanttItem& other )
43     : BASE(other)
44 {
45     operator=( other );
46 }
47 
48 /*! Assignment operator */
operator =(const StyleOptionGanttItem & other)49 StyleOptionGanttItem& StyleOptionGanttItem::operator=( const StyleOptionGanttItem& other )
50 {
51     BASE::operator=( other );
52     boundingRect = other.boundingRect;
53     itemRect = other.itemRect;
54     displayPosition = other.displayPosition;
55     grid = other.grid;
56     text = other.text;
57     return *this;
58 }
59 
60 #ifndef QT_NO_DEBUG_STREAM
operator <<(QDebug dbg,KGantt::StyleOptionGanttItem::Position p)61 QDebug operator<<( QDebug dbg, KGantt::StyleOptionGanttItem::Position p)
62 {
63     switch ( p ) {
64     case KGantt::StyleOptionGanttItem::Left:   dbg << "KGantt::StyleOptionGanttItem::Left"; break;
65     case KGantt::StyleOptionGanttItem::Right:  dbg << "KGantt::StyleOptionGanttItem::Right"; break;
66     case KGantt::StyleOptionGanttItem::Center: dbg << "KGantt::StyleOptionGanttItem::Center"; break;
67     case KGantt::StyleOptionGanttItem::Hidden: dbg << "KGantt::StyleOptionGanttItem::Hidden"; break;
68     default: dbg << static_cast<int>( p );
69     }
70     return dbg;
71 }
72 
operator <<(QDebug dbg,const KGantt::StyleOptionGanttItem & s)73 QDebug operator<<( QDebug dbg, const KGantt::StyleOptionGanttItem& s )
74 {
75     dbg << "KGantt::StyleOptionGanttItem[ boundingRect="<<s.boundingRect
76         <<", itemRect="<<s.itemRect
77         <<", displayPosition="<<s.displayPosition
78         <<", grid="<<s.grid
79         <<", text="<<s.text
80         <<"]";
81     return dbg;
82 }
83 
84 #endif /* QT_NO_DEBUG_STREAM */
85 
86 
87 /*!\enum KGantt::StyleOptionGanttItem::Position
88  * This enum is used to describe where the Qt::DisplayRole
89  * (the label) should be located relative to the item itself.
90  */
91 
92 /*!\var StyleOptionGanttItem::boundingRect
93  * Contains the bounding rectangle for the item
94  */
95 
96 /*!\var StyleOptionGanttItem::itemRect
97  * Contains the "active" item rectangle that corresponds
98  * to the values from the model.
99  */
100 
101 /*!\var StyleOptionGanttItem::displayPosition
102  * \see StyleOptionGanttItem::Position.
103  */
104 
105 /*!\var StyleOptionGanttItem::grid
106  * Contains a pointer to the AbstractGrid used by the view
107  */
108 
109 /*!\var StyleOptionGanttItem::text
110  * Contains a string printed to the item
111  */
112