summaryrefslogtreecommitdiffabout
path: root/microkde/kdeui/kguiitem.cpp
Unidiff
Diffstat (limited to 'microkde/kdeui/kguiitem.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdeui/kguiitem.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/microkde/kdeui/kguiitem.cpp b/microkde/kdeui/kguiitem.cpp
index 828c5e6..c91ffb7 100644
--- a/microkde/kdeui/kguiitem.cpp
+++ b/microkde/kdeui/kguiitem.cpp
@@ -1,205 +1,205 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 2001 Holger Freyther (freyher@yahoo.com) 2 Copyright (C) 2001 Holger Freyther (freyher@yahoo.com)
3 based on ideas from Martijn and Simon 3 based on ideas from Martijn and Simon
4 many thanks to Simon 4 many thanks to Simon
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License version 2 as published by the Free Software Foundation. 8 License version 2 as published by the Free Software Foundation.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <qregexp.h> 21#include <qregexp.h>
22#include <qstring.h> 22#include <qstring.h>
23#include <qiconset.h> 23#include <qicon.h>
24#include <qpixmap.h> 24#include <qpixmap.h>
25 25
26#include <assert.h> 26#include <assert.h>
27//US #include <kiconloader.h> 27//US #include <kiconloader.h>
28#include <kdebug.h> 28#include <kdebug.h>
29 29
30#include "kguiitem.h" 30#include "kguiitem.h"
31 31
32class KGuiItem::KGuiItemPrivate 32class KGuiItem::KGuiItemPrivate
33{ 33{
34public: 34public:
35 KGuiItemPrivate() 35 KGuiItemPrivate()
36 { 36 {
37 m_enabled = true; 37 m_enabled = true;
38 m_hasIcon = false; 38 m_hasIcon = false;
39 } 39 }
40 40
41 KGuiItemPrivate( const KGuiItemPrivate &rhs ) 41 KGuiItemPrivate( const KGuiItemPrivate &rhs )
42 { 42 {
43 (*this ) = rhs; 43 (*this ) = rhs;
44 } 44 }
45 45
46 KGuiItemPrivate &operator=( const KGuiItemPrivate &rhs ) 46 KGuiItemPrivate &operator=( const KGuiItemPrivate &rhs )
47 { 47 {
48 m_text = rhs.m_text; 48 m_text = rhs.m_text;
49 m_iconSet = rhs.m_iconSet; 49 m_iconSet = rhs.m_iconSet;
50 m_iconName = rhs.m_iconName; 50 m_iconName = rhs.m_iconName;
51 m_toolTip = rhs.m_toolTip; 51 m_toolTip = rhs.m_toolTip;
52 m_whatsThis = rhs.m_whatsThis; 52 m_whatsThis = rhs.m_whatsThis;
53 m_statusText = rhs.m_statusText; 53 m_statusText = rhs.m_statusText;
54 m_enabled = rhs.m_enabled; 54 m_enabled = rhs.m_enabled;
55 m_hasIcon = rhs.m_hasIcon; 55 m_hasIcon = rhs.m_hasIcon;
56 56
57 return *this; 57 return *this;
58 } 58 }
59 59
60 QString m_text; 60 QString m_text;
61 QString m_toolTip; 61 QString m_toolTip;
62 QString m_whatsThis; 62 QString m_whatsThis;
63 QString m_statusText; 63 QString m_statusText;
64 QString m_iconName; 64 QString m_iconName;
65 QIconSet m_iconSet; 65 QIcon m_iconSet;
66 bool m_hasIcon : 1; 66 bool m_hasIcon : 1;
67 bool m_enabled : 1; 67 bool m_enabled : 1;
68}; 68};
69 69
70 70
71KGuiItem::KGuiItem() { 71KGuiItem::KGuiItem() {
72 d = new KGuiItemPrivate; 72 d = new KGuiItemPrivate;
73} 73}
74 74
75KGuiItem::KGuiItem( const QString &text, const QString &iconName, 75KGuiItem::KGuiItem( const QString &text, const QString &iconName,
76 const QString &toolTip, const QString &whatsThis ) 76 const QString &toolTip, const QString &whatsThis )
77{ 77{
78 d = new KGuiItemPrivate; 78 d = new KGuiItemPrivate;
79 d->m_text = text; 79 d->m_text = text;
80 d->m_toolTip = toolTip; 80 d->m_toolTip = toolTip;
81 d->m_whatsThis = whatsThis; 81 d->m_whatsThis = whatsThis;
82 setIconName( iconName ); 82 setIconName( iconName );
83} 83}
84 84
85KGuiItem::KGuiItem( const QString &text, const QIconSet &iconSet, 85KGuiItem::KGuiItem( const QString &text, const QIcon &iconSet,
86 const QString &toolTip, const QString &whatsThis ) 86 const QString &toolTip, const QString &whatsThis )
87{ 87{
88 d = new KGuiItemPrivate; 88 d = new KGuiItemPrivate;
89 d->m_text = text; 89 d->m_text = text;
90 d->m_toolTip = toolTip; 90 d->m_toolTip = toolTip;
91 d->m_whatsThis = whatsThis; 91 d->m_whatsThis = whatsThis;
92 setIconSet( iconSet ); 92 setIconSet( iconSet );
93} 93}
94 94
95KGuiItem::KGuiItem( const KGuiItem &rhs ) 95KGuiItem::KGuiItem( const KGuiItem &rhs )
96 : d( 0 ) 96 : d( 0 )
97{ 97{
98 (*this) = rhs; 98 (*this) = rhs;
99} 99}
100 100
101KGuiItem &KGuiItem::operator=( const KGuiItem &rhs ) { 101KGuiItem &KGuiItem::operator=( const KGuiItem &rhs ) {
102 if ( d == rhs.d ) 102 if ( d == rhs.d )
103 return *this; 103 return *this;
104 104
105 assert( rhs.d ); 105 assert( rhs.d );
106 106
107 delete d; 107 delete d;
108 d = new KGuiItemPrivate( *rhs.d ); 108 d = new KGuiItemPrivate( *rhs.d );
109 109
110 return *this; 110 return *this;
111} 111}
112 112
113KGuiItem::~KGuiItem() { 113KGuiItem::~KGuiItem() {
114 delete d; 114 delete d;
115} 115}
116 116
117QString KGuiItem::text() const { 117QString KGuiItem::text() const {
118 return d->m_text; 118 return d->m_text;
119} 119}
120QString KGuiItem::plainText() const { 120QString KGuiItem::plainText() const {
121 QString stripped( d->m_text ); 121 QString stripped( d->m_text );
122 stripped.replace( QRegExp( "&(?!&)" ), QString::null ); 122 stripped.replace( QRegExp( "&(?!&)" ), QString::null );
123 123
124 return stripped; 124 return stripped;
125} 125}
126 126
127QIconSet KGuiItem::iconSet( KIcon::Group group, int size /*US, KInstance* instance */ ) const 127QIcon KGuiItem::iconSet( KIcon::Group group, int size /*US, KInstance* instance */ ) const
128{ 128{
129 if( d->m_hasIcon ) 129 if( d->m_hasIcon )
130 { 130 {
131 if( !d->m_iconName.isEmpty()) 131 if( !d->m_iconName.isEmpty())
132 { 132 {
133// some caching here would(?) come handy 133// some caching here would(?) come handy
134//US return instance->iconLoader()->loadIconSet( d->m_iconName, group, size ); 134//US return instance->iconLoader()->loadIconSet( d->m_iconName, group, size );
135 return KGlobal::iconLoader()->loadIconSet( d->m_iconName); 135 return KGlobal::iconLoader()->loadIconSet( d->m_iconName);
136// here is a little problem that with delayed icon loading 136// here is a little problem that with delayed icon loading
137// we can't check if the icon really exists ... so what ... 137// we can't check if the icon really exists ... so what ...
138// if( set.isNull() ) 138// if( set.isNull() )
139// { 139// {
140// d->m_hasIcon = false; 140// d->m_hasIcon = false;
141// return QIconSet(); 141// return QIconSet();
142// } 142// }
143// return set; 143// return set;
144 } 144 }
145 else 145 else
146 { 146 {
147 return d->m_iconSet; 147 return d->m_iconSet;
148 } 148 }
149 } 149 }
150 else 150 else
151 return QIconSet(); 151 return QIcon();
152} 152}
153 153
154QString KGuiItem::iconName() const 154QString KGuiItem::iconName() const
155{ 155{
156 return d->m_iconName; 156 return d->m_iconName;
157} 157}
158 158
159QString KGuiItem::toolTip() const { 159QString KGuiItem::toolTip() const {
160 return d->m_toolTip; 160 return d->m_toolTip;
161} 161}
162QString KGuiItem::whatsThis() const { 162QString KGuiItem::whatsThis() const {
163 return d->m_whatsThis; 163 return d->m_whatsThis;
164} 164}
165 165
166bool KGuiItem::isEnabled() const 166bool KGuiItem::isEnabled() const
167{ 167{
168 return d->m_enabled; 168 return d->m_enabled;
169} 169}
170 170
171bool KGuiItem::hasIcon() const 171bool KGuiItem::hasIcon() const
172{ 172{
173 return d->m_hasIcon; 173 return d->m_hasIcon;
174} 174}
175 175
176void KGuiItem::setText( const QString &text ) { 176void KGuiItem::setText( const QString &text ) {
177 d->m_text=text; 177 d->m_text=text;
178} 178}
179 179
180void KGuiItem::setIconSet( const QIconSet &iconset ) 180void KGuiItem::setIconSet( const QIcon &iconset )
181{ 181{
182 d->m_iconSet = iconset; 182 d->m_iconSet = iconset;
183 d->m_iconName = QString::null; 183 d->m_iconName = QString::null;
184 d->m_hasIcon = !iconset.isNull(); 184 d->m_hasIcon = !iconset.isNull();
185} 185}
186 186
187void KGuiItem::setIconName( const QString &iconName ) 187void KGuiItem::setIconName( const QString &iconName )
188{ 188{
189 d->m_iconName = iconName; 189 d->m_iconName = iconName;
190 d->m_iconSet = QIconSet(); 190 d->m_iconSet = QIcon();
191 d->m_hasIcon = !iconName.isEmpty(); 191 d->m_hasIcon = !iconName.isEmpty();
192} 192}
193 193
194void KGuiItem::setToolTip( const QString &toolTip) { 194void KGuiItem::setToolTip( const QString &toolTip) {
195 d->m_toolTip = toolTip; 195 d->m_toolTip = toolTip;
196} 196}
197void KGuiItem::setWhatsThis( const QString &whatsThis ) { 197void KGuiItem::setWhatsThis( const QString &whatsThis ) {
198 d->m_whatsThis = whatsThis; 198 d->m_whatsThis = whatsThis;
199} 199}
200void KGuiItem::setEnabled( bool enabled ){ 200void KGuiItem::setEnabled( bool enabled ){
201 d->m_enabled = enabled; 201 d->m_enabled = enabled;
202} 202}
203 203
204/* vim: et sw=4 204/* vim: et sw=4
205 */ 205 */