summaryrefslogtreecommitdiff
authorzecke <zecke>2004-03-26 22:36:43 (UTC)
committer zecke <zecke>2004-03-26 22:36:43 (UTC)
commitc54a3c8cc47258743381d4dee4200304d247182d (patch) (unidiff)
treebc96497821743c7b7789004fd700f58f10f0f772
parent2487838d0f9358d6efdf714e9dfd892f92802b46 (diff)
downloadopie-c54a3c8cc47258743381d4dee4200304d247182d.zip
opie-c54a3c8cc47258743381d4dee4200304d247182d.tar.gz
opie-c54a3c8cc47258743381d4dee4200304d247182d.tar.bz2
Add WFlags to the c'tor so we eventually can use this
in the designer... but anyway making it more consistent with Qt Ah and this is binary incompatible but the API isn't marked as stable anyway
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/olistview.cpp4
-rw-r--r--libopie2/opieui/olistview.h2
2 files changed, 3 insertions, 3 deletions
diff --git a/libopie2/opieui/olistview.cpp b/libopie2/opieui/olistview.cpp
index 38670b4..d7c92fd 100644
--- a/libopie2/opieui/olistview.cpp
+++ b/libopie2/opieui/olistview.cpp
@@ -1,177 +1,177 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 =. (C) 2003-2004 Michael 'Mickey' Lauer <mickey@Vanille.de> 3 =. (C) 2003-2004 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 .=l. 4 .=l.
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details. 19++=   -.     .`     .: details.
20 :     =  ...= . :.=- 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27 27
28*/ 28*/
29 29
30/* QT */ 30/* QT */
31 31
32#include <qpixmap.h> 32#include <qpixmap.h>
33 33
34/* OPIE */ 34/* OPIE */
35 35
36#include <opie2/odebug.h> 36#include <opie2/odebug.h>
37#include <opie2/olistview.h> 37#include <opie2/olistview.h>
38 38
39using namespace Opie::Core; 39using namespace Opie::Core;
40 40
41 41
42namespace Opie { 42namespace Opie {
43namespace Ui { 43namespace Ui {
44/*====================================================================================== 44/*======================================================================================
45 * OListView 45 * OListView
46 *======================================================================================*/ 46 *======================================================================================*/
47 47
48OListView::OListView( QWidget *parent, const char *name ) 48OListView::OListView( QWidget *parent, const char *name, WFlags fl )
49 :QListView( parent, name ) 49 :QListView( parent, name, fl )
50{ 50{
51 //FIXME: get from global settings and calculate ==> see oglobalsettings.* 51 //FIXME: get from global settings and calculate ==> see oglobalsettings.*
52 52
53 m_alternateBackground = QColor( 238, 246, 255 ); 53 m_alternateBackground = QColor( 238, 246, 255 );
54 m_columnSeparator = QPen( QColor( 150, 160, 170 ), 0, DotLine ); 54 m_columnSeparator = QPen( QColor( 150, 160, 170 ), 0, DotLine );
55 m_fullWidth = true; 55 m_fullWidth = true;
56 connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*))); 56 connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*)));
57} 57}
58 58
59OListView::~OListView() 59OListView::~OListView()
60{ 60{
61} 61}
62 62
63void OListView::setFullWidth( bool fullWidth ) 63void OListView::setFullWidth( bool fullWidth )
64{ 64{
65 m_fullWidth = m_fullWidth; 65 m_fullWidth = m_fullWidth;
66 #if QT_VERSION > 290 66 #if QT_VERSION > 290
67 header()->setStretchEnabled( fullWidth, columns()-1 ); 67 header()->setStretchEnabled( fullWidth, columns()-1 );
68 #endif 68 #endif
69} 69}
70 70
71bool OListView::fullWidth() const 71bool OListView::fullWidth() const
72{ 72{
73 return m_fullWidth; 73 return m_fullWidth;
74} 74}
75 75
76int OListView::addColumn( const QString& label, int width ) 76int OListView::addColumn( const QString& label, int width )
77{ 77{
78 int result = QListView::addColumn( label, width ); 78 int result = QListView::addColumn( label, width );
79 #if QT_VERSION > 290 79 #if QT_VERSION > 290
80 if (m_fullWidth) { 80 if (m_fullWidth) {
81 header()->setStretchEnabled( false, columns()-2 ); 81 header()->setStretchEnabled( false, columns()-2 );
82 header()->setStretchEnabled( true, columns()-1 ); 82 header()->setStretchEnabled( true, columns()-1 );
83 } 83 }
84 #endif 84 #endif
85 return result; 85 return result;
86} 86}
87 87
88int OListView::addColumn( const QIconSet& iconset, const QString& label, int width ) 88int OListView::addColumn( const QIconSet& iconset, const QString& label, int width )
89{ 89{
90 int result = QListView::addColumn( iconset, label, width ); 90 int result = QListView::addColumn( iconset, label, width );
91 #if QT_VERSION > 290 91 #if QT_VERSION > 290
92 if (m_fullWidth) { 92 if (m_fullWidth) {
93 header()->setStretchEnabled( false, columns()-2 ); 93 header()->setStretchEnabled( false, columns()-2 );
94 header()->setStretchEnabled( true, columns()-1 ); 94 header()->setStretchEnabled( true, columns()-1 );
95 } 95 }
96 #endif 96 #endif
97 return result; 97 return result;
98} 98}
99 99
100void OListView::removeColumn( int index ) 100void OListView::removeColumn( int index )
101{ 101{
102 QListView::removeColumn(index); 102 QListView::removeColumn(index);
103 #if QT_VERSION > 290 103 #if QT_VERSION > 290
104 if ( m_fullWidth && index == columns() ) 104 if ( m_fullWidth && index == columns() )
105 { 105 {
106 header()->setStretchEnabled( true, columns()-1 ); 106 header()->setStretchEnabled( true, columns()-1 );
107 } 107 }
108 #endif 108 #endif
109} 109}
110 110
111const QColor& OListView::alternateBackground() const 111const QColor& OListView::alternateBackground() const
112{ 112{
113 return m_alternateBackground; 113 return m_alternateBackground;
114} 114}
115 115
116void OListView::setAlternateBackground( const QColor &c ) 116void OListView::setAlternateBackground( const QColor &c )
117{ 117{
118 m_alternateBackground = c; 118 m_alternateBackground = c;
119 repaint(); 119 repaint();
120} 120}
121 121
122const QPen& OListView::columnSeparator() const 122const QPen& OListView::columnSeparator() const
123{ 123{
124 return m_columnSeparator; 124 return m_columnSeparator;
125} 125}
126 126
127void OListView::setColumnSeparator( const QPen& p ) 127void OListView::setColumnSeparator( const QPen& p )
128{ 128{
129 m_columnSeparator = p; 129 m_columnSeparator = p;
130 repaint(); 130 repaint();
131} 131}
132 132
133void OListView::expand(QListViewItem *item) 133void OListView::expand(QListViewItem *item)
134{ 134{
135 ((OListViewItem*)item)->expand(); 135 ((OListViewItem*)item)->expand();
136} 136}
137 137
138OListViewItem* OListView::childFactory() 138OListViewItem* OListView::childFactory()
139{ 139{
140 return new OListViewItem( this ); 140 return new OListViewItem( this );
141} 141}
142 142
143#ifndef QT_NO_DATASTREAM 143#ifndef QT_NO_DATASTREAM
144void OListView::serializeTo( QDataStream& s ) const 144void OListView::serializeTo( QDataStream& s ) const
145{ 145{
146 #warning Caution... the binary format is still under construction... 146 #warning Caution... the binary format is still under construction...
147 odebug << "storing OListView..." << oendl; 147 odebug << "storing OListView..." << oendl;
148 148
149 // store number of columns and the labels 149 // store number of columns and the labels
150 s << columns(); 150 s << columns();
151 for ( int i = 0; i < columns(); ++i ) 151 for ( int i = 0; i < columns(); ++i )
152 s << columnText( i ); 152 s << columnText( i );
153 153
154 // calculate the number of top-level items to serialize 154 // calculate the number of top-level items to serialize
155 int items = 0; 155 int items = 0;
156 QListViewItem* item = firstChild(); 156 QListViewItem* item = firstChild();
157 while ( item ) 157 while ( item )
158 { 158 {
159 item = item->nextSibling(); 159 item = item->nextSibling();
160 items++; 160 items++;
161 } 161 }
162 162
163 // store number of items and the items itself 163 // store number of items and the items itself
164 s << items; 164 s << items;
165 item = firstChild(); 165 item = firstChild();
166 for ( int i = 0; i < items; ++i ) 166 for ( int i = 0; i < items; ++i )
167 { 167 {
168 s << *static_cast<OListViewItem*>( item ); 168 s << *static_cast<OListViewItem*>( item );
169 item = item->nextSibling(); 169 item = item->nextSibling();
170 } 170 }
171 171
172 odebug << "OListview stored." << oendl; 172 odebug << "OListview stored." << oendl;
173} 173}
174 174
175void OListView::serializeFrom( QDataStream& s ) 175void OListView::serializeFrom( QDataStream& s )
176{ 176{
177 #warning Caution... the binary format is still under construction... 177 #warning Caution... the binary format is still under construction...
diff --git a/libopie2/opieui/olistview.h b/libopie2/opieui/olistview.h
index 8195a62..3ff11ef 100644
--- a/libopie2/opieui/olistview.h
+++ b/libopie2/opieui/olistview.h
@@ -1,196 +1,196 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 =. (C) 2003-2004 Michael 'Mickey' Lauer <mickey@vanille.de> 3 =. (C) 2003-2004 Michael 'Mickey' Lauer <mickey@vanille.de>
4 .=l. 4 .=l.
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details. 19++=   -.     .`     .: details.
20 :     =  ...= . :.=- 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27 27
28*/ 28*/
29 29
30#ifndef OLISTVIEW_H 30#ifndef OLISTVIEW_H
31#define OLISTVIEW_H 31#define OLISTVIEW_H
32 32
33#include <qcolor.h> 33#include <qcolor.h>
34#include <qlistview.h> 34#include <qlistview.h>
35#include <qpen.h> 35#include <qpen.h>
36#include <qdatastream.h> 36#include <qdatastream.h>
37#include <qstringlist.h> 37#include <qstringlist.h>
38 38
39 39
40namespace Opie { 40namespace Opie {
41namespace Ui { 41namespace Ui {
42class OListViewItem; 42class OListViewItem;
43 43
44 44
45/*====================================================================================== 45/*======================================================================================
46 * OListView 46 * OListView
47 *======================================================================================*/ 47 *======================================================================================*/
48 48
49/** 49/**
50 * @brief A list/tree widget. 50 * @brief A list/tree widget.
51 * 51 *
52 * A @ref QListView variant featuring visual and functional enhancements 52 * A @ref QListView variant featuring visual and functional enhancements
53 * like an alternate background for odd rows, an autostretch mode 53 * like an alternate background for odd rows, an autostretch mode
54 * for the width of the widget ( >= Qt 3 only ) and persistence capabilities. 54 * for the width of the widget ( >= Qt 3 only ) and persistence capabilities.
55 * 55 *
56 * @author Michael 'Mickey' Lauer <mickey@vanille.de> 56 * @author Michael 'Mickey' Lauer <mickey@vanille.de>
57 */ 57 */
58class OListView: public QListView 58class OListView: public QListView
59{ 59{
60 Q_OBJECT 60 Q_OBJECT
61 public: 61 public:
62 /** 62 /**
63 * Constructor. 63 * Constructor.
64 * 64 *
65 * The parameters @a parent and @a name are handled by 65 * The parameters @a parent and @a name are handled by
66 * @ref QListView, as usual. 66 * @ref QListView, as usual.
67 */ 67 */
68 OListView( QWidget* parent = 0, const char* name = 0 ); 68 OListView( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
69 /** 69 /**
70 * Destructor. 70 * Destructor.
71 */ 71 */
72 virtual ~OListView(); 72 virtual ~OListView();
73 /** 73 /**
74 * Let the last column fit exactly all the available width. 74 * Let the last column fit exactly all the available width.
75 */ 75 */
76 void setFullWidth( bool fullWidth ); 76 void setFullWidth( bool fullWidth );
77 /** 77 /**
78 * Returns whether the last column is set to fit the available width. 78 * Returns whether the last column is set to fit the available width.
79 */ 79 */
80 bool fullWidth() const; 80 bool fullWidth() const;
81 /** 81 /**
82 * Reimplemented for full width support 82 * Reimplemented for full width support
83 */ 83 */
84 virtual int addColumn( const QString& label, int width = -1 ); 84 virtual int addColumn( const QString& label, int width = -1 );
85 /** 85 /**
86 * Reimplemented for full width support 86 * Reimplemented for full width support
87 */ 87 */
88 virtual int addColumn( const QIconSet& iconset, const QString& label, int width = -1 ); 88 virtual int addColumn( const QIconSet& iconset, const QString& label, int width = -1 );
89 /** 89 /**
90 * Reimplemented for full width support 90 * Reimplemented for full width support
91 */ 91 */
92 virtual void removeColumn(int index); 92 virtual void removeColumn(int index);
93 /** 93 /**
94 * Set the alternate background background @a color. 94 * Set the alternate background background @a color.
95 * Set to an invalid color to disable alternate colors. 95 * Set to an invalid color to disable alternate colors.
96 * This only has an effect if the items are OListViewItems 96 * This only has an effect if the items are OListViewItems
97 */ 97 */
98 void setAlternateBackground( const QColor& color ); 98 void setAlternateBackground( const QColor& color );
99 /** 99 /**
100 * Sets the column separator @a pen. 100 * Sets the column separator @a pen.
101 */ 101 */
102 void setColumnSeparator( const QPen& pen ); 102 void setColumnSeparator( const QPen& pen );
103 103
104 /** 104 /**
105 * @returns the alternate background color 105 * @returns the alternate background color
106 */ 106 */
107 const QColor& alternateBackground() const; 107 const QColor& alternateBackground() const;
108 /** 108 /**
109 * @return the column separator pen 109 * @return the column separator pen
110 */ 110 */
111 const QPen& columnSeparator() const; 111 const QPen& columnSeparator() const;
112 /** 112 /**
113 * Create a list view item as child of this object 113 * Create a list view item as child of this object
114 * @returns the new object 114 * @returns the new object
115 */ 115 */
116 virtual OListViewItem* childFactory(); 116 virtual OListViewItem* childFactory();
117#ifndef QT_NO_DATASTREAM 117#ifndef QT_NO_DATASTREAM
118 /** 118 /**
119 * Serialize this object to @ref QDataStream @a stream 119 * Serialize this object to @ref QDataStream @a stream
120 */ 120 */
121 virtual void serializeTo( QDataStream& stream ) const; 121 virtual void serializeTo( QDataStream& stream ) const;
122 /** 122 /**
123 * Serialize this object from a @ref QDataStream @a stream 123 * Serialize this object from a @ref QDataStream @a stream
124 */ 124 */
125 virtual void serializeFrom( QDataStream& s ); 125 virtual void serializeFrom( QDataStream& s );
126#endif 126#endif
127 127
128 public slots: 128 public slots:
129 /** 129 /**
130 * Expand all items 130 * Expand all items
131 */ 131 */
132 void expand(); 132 void expand();
133 /** 133 /**
134 * Collapse all items 134 * Collapse all items
135 */ 135 */
136 void collapse(); 136 void collapse();
137 137
138 protected slots: 138 protected slots:
139 /** 139 /**
140 * expand the current OListViewItem 140 * expand the current OListViewItem
141 */ 141 */
142 void expand(QListViewItem*); 142 void expand(QListViewItem*);
143 143
144 private: 144 private:
145 QColor m_alternateBackground; 145 QColor m_alternateBackground;
146 bool m_fullWidth : 1; 146 bool m_fullWidth : 1;
147 QPen m_columnSeparator; 147 QPen m_columnSeparator;
148 class Private; 148 class Private;
149 Private *d; 149 Private *d;
150}; 150};
151 151
152#ifndef QT_NO_DATASTREAM 152#ifndef QT_NO_DATASTREAM
153/** 153/**
154 * @relates OListView 154 * @relates OListView
155 * Writes @a listview to the @a stream and returns a reference to the stream. 155 * Writes @a listview to the @a stream and returns a reference to the stream.
156 */ 156 */
157QDataStream& operator<<( QDataStream& stream, const OListView& listview ); 157QDataStream& operator<<( QDataStream& stream, const OListView& listview );
158/** 158/**
159 * @relates OListView 159 * @relates OListView
160 * Reads @a listview from the @a stream and returns a reference to the stream. 160 * Reads @a listview from the @a stream and returns a reference to the stream.
161 */ 161 */
162QDataStream& operator>>( QDataStream& stream, OListView& listview ); 162QDataStream& operator>>( QDataStream& stream, OListView& listview );
163#endif // QT_NO_DATASTREAM 163#endif // QT_NO_DATASTREAM
164 164
165/*====================================================================================== 165/*======================================================================================
166 * OListViewItem 166 * OListViewItem
167 *======================================================================================*/ 167 *======================================================================================*/
168 168
169class OListViewItem: public QListViewItem 169class OListViewItem: public QListViewItem
170{ 170{
171 friend class OCheckListItem; 171 friend class OCheckListItem;
172 public: 172 public:
173 /** 173 /**
174 * Constructors. 174 * Constructors.
175 */ 175 */
176 OListViewItem( QListView * parent ); 176 OListViewItem( QListView * parent );
177 OListViewItem( QListViewItem * parent ); 177 OListViewItem( QListViewItem * parent );
178 OListViewItem( QListView * parent, QListViewItem * after ); 178 OListViewItem( QListView * parent, QListViewItem * after );
179 OListViewItem( QListViewItem * parent, QListViewItem * after ); 179 OListViewItem( QListViewItem * parent, QListViewItem * after );
180 180
181 OListViewItem( QListView * parent, 181 OListViewItem( QListView * parent,
182 QString, QString = QString::null, 182 QString, QString = QString::null,
183 QString = QString::null, QString = QString::null, 183 QString = QString::null, QString = QString::null,
184 QString = QString::null, QString = QString::null, 184 QString = QString::null, QString = QString::null,
185 QString = QString::null, QString = QString::null ); 185 QString = QString::null, QString = QString::null );
186 186
187 OListViewItem( QListViewItem * parent, 187 OListViewItem( QListViewItem * parent,
188 QString, QString = QString::null, 188 QString, QString = QString::null,
189 QString = QString::null, QString = QString::null, 189 QString = QString::null, QString = QString::null,
190 QString = QString::null, QString = QString::null, 190 QString = QString::null, QString = QString::null,
191 QString = QString::null, QString = QString::null ); 191 QString = QString::null, QString = QString::null );
192 192
193 OListViewItem( QListView * parent, QListViewItem * after, 193 OListViewItem( QListView * parent, QListViewItem * after,
194 QString, QString = QString::null, 194 QString, QString = QString::null,
195 QString = QString::null, QString = QString::null, 195 QString = QString::null, QString = QString::null,
196 QString = QString::null, QString = QString::null, 196 QString = QString::null, QString = QString::null,