author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /microkde/kdeui/kguiitem.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-p1.zip kdepimpi-p1.tar.gz kdepimpi-p1.tar.bz2 |
initial public commit of qt4 portp1
-rw-r--r-- | microkde/kdeui/kguiitem.cpp | 14 |
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 | |||
@@ -7,33 +7,33 @@ | |||
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 | ||
32 | class KGuiItem::KGuiItemPrivate | 32 | class KGuiItem::KGuiItemPrivate |
33 | { | 33 | { |
34 | public: | 34 | public: |
35 | KGuiItemPrivate() | 35 | KGuiItemPrivate() |
36 | { | 36 | { |
37 | m_enabled = true; | 37 | m_enabled = true; |
38 | m_hasIcon = false; | 38 | m_hasIcon = false; |
39 | } | 39 | } |
@@ -49,53 +49,53 @@ public: | |||
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 | ||
71 | KGuiItem::KGuiItem() { | 71 | KGuiItem::KGuiItem() { |
72 | d = new KGuiItemPrivate; | 72 | d = new KGuiItemPrivate; |
73 | } | 73 | } |
74 | 74 | ||
75 | KGuiItem::KGuiItem( const QString &text, const QString &iconName, | 75 | KGuiItem::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 | ||
85 | KGuiItem::KGuiItem( const QString &text, const QIconSet &iconSet, | 85 | KGuiItem::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 | ||
95 | KGuiItem::KGuiItem( const KGuiItem &rhs ) | 95 | KGuiItem::KGuiItem( const KGuiItem &rhs ) |
96 | : d( 0 ) | 96 | : d( 0 ) |
97 | { | 97 | { |
98 | (*this) = rhs; | 98 | (*this) = rhs; |
99 | } | 99 | } |
100 | 100 | ||
101 | KGuiItem &KGuiItem::operator=( const KGuiItem &rhs ) { | 101 | KGuiItem &KGuiItem::operator=( const KGuiItem &rhs ) { |
@@ -111,95 +111,95 @@ KGuiItem &KGuiItem::operator=( const KGuiItem &rhs ) { | |||
111 | } | 111 | } |
112 | 112 | ||
113 | KGuiItem::~KGuiItem() { | 113 | KGuiItem::~KGuiItem() { |
114 | delete d; | 114 | delete d; |
115 | } | 115 | } |
116 | 116 | ||
117 | QString KGuiItem::text() const { | 117 | QString KGuiItem::text() const { |
118 | return d->m_text; | 118 | return d->m_text; |
119 | } | 119 | } |
120 | QString KGuiItem::plainText() const { | 120 | QString 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 | ||
127 | QIconSet KGuiItem::iconSet( KIcon::Group group, int size /*US, KInstance* instance */ ) const | 127 | QIcon 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 | ||
154 | QString KGuiItem::iconName() const | 154 | QString KGuiItem::iconName() const |
155 | { | 155 | { |
156 | return d->m_iconName; | 156 | return d->m_iconName; |
157 | } | 157 | } |
158 | 158 | ||
159 | QString KGuiItem::toolTip() const { | 159 | QString KGuiItem::toolTip() const { |
160 | return d->m_toolTip; | 160 | return d->m_toolTip; |
161 | } | 161 | } |
162 | QString KGuiItem::whatsThis() const { | 162 | QString KGuiItem::whatsThis() const { |
163 | return d->m_whatsThis; | 163 | return d->m_whatsThis; |
164 | } | 164 | } |
165 | 165 | ||
166 | bool KGuiItem::isEnabled() const | 166 | bool KGuiItem::isEnabled() const |
167 | { | 167 | { |
168 | return d->m_enabled; | 168 | return d->m_enabled; |
169 | } | 169 | } |
170 | 170 | ||
171 | bool KGuiItem::hasIcon() const | 171 | bool KGuiItem::hasIcon() const |
172 | { | 172 | { |
173 | return d->m_hasIcon; | 173 | return d->m_hasIcon; |
174 | } | 174 | } |
175 | 175 | ||
176 | void KGuiItem::setText( const QString &text ) { | 176 | void KGuiItem::setText( const QString &text ) { |
177 | d->m_text=text; | 177 | d->m_text=text; |
178 | } | 178 | } |
179 | 179 | ||
180 | void KGuiItem::setIconSet( const QIconSet &iconset ) | 180 | void 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 | ||
187 | void KGuiItem::setIconName( const QString &iconName ) | 187 | void 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 | ||
194 | void KGuiItem::setToolTip( const QString &toolTip) { | 194 | void KGuiItem::setToolTip( const QString &toolTip) { |
195 | d->m_toolTip = toolTip; | 195 | d->m_toolTip = toolTip; |
196 | } | 196 | } |
197 | void KGuiItem::setWhatsThis( const QString &whatsThis ) { | 197 | void KGuiItem::setWhatsThis( const QString &whatsThis ) { |
198 | d->m_whatsThis = whatsThis; | 198 | d->m_whatsThis = whatsThis; |
199 | } | 199 | } |
200 | void KGuiItem::setEnabled( bool enabled ){ | 200 | void 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 | */ |