VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox4/include/QILabel_p.h@ 10812

Last change on this file since 10812 was 9799, checked in by vboxsync, 17 years ago

FE/Qt4: Use right text color if the label is selected & paint a focus rect if the label has the focus.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1/** @file
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
4 * VirtualBox Qt extensions: QILabelPrivate class declaration
5 */
6
7/*
8 * Copyright (C) 2008 Sun Microsystems, Inc.
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 *
18 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
19 * Clara, CA 95054 USA or visit http://www.sun.com if you need
20 * additional information or have any questions.
21 */
22
23/*
24 * This class is based on the original QLabel implementation.
25 */
26
27#ifndef __QILabel_p_h__
28#define __QILabel_p_h__
29
30/* Qt includes */
31#include <QLabel>
32
33class QILabelPrivate: public QLabel
34{
35 Q_OBJECT;
36
37public:
38
39 QILabelPrivate (QWidget *aParent = NULL, Qt::WindowFlags aFlags = 0)
40 : QLabel (aParent, aFlags)
41 {
42 init();
43 }
44
45 QILabelPrivate (const QString &aText, QWidget *aParent = NULL, Qt::WindowFlags aFlags = 0)
46 : QLabel (aParent, aFlags)
47 {
48 init();
49 setFullText (aText);
50 }
51
52 void clearAll()
53 {
54 QLabel::clear();
55 setFullText ("");
56 }
57
58 QString fullText () const
59 {
60 return mText;
61 }
62
63 void setFullText (const QString &aText)
64 {
65 mText = aText;
66 updateText();
67 }
68
69 bool fullSizeSelection () const;
70 void setFullSizeSelection (bool bOn);
71
72 void updateSizeHint()
73 {
74 if (minimumWidth() > 0)
75 mOwnSizeHint = QSize (minimumWidth(),
76 heightForWidth (minimumWidth()));
77 }
78
79 QSize sizeHint() const
80 {
81 /* If there is an updated sizeHint() present - using it. */
82 return mOwnSizeHint.isValid() ? mOwnSizeHint : QLabel::sizeHint();
83 }
84
85protected:
86
87 void resizeEvent (QResizeEvent *aEvent);
88 void mousePressEvent (QMouseEvent *aEvent);
89 void mouseReleaseEvent (QMouseEvent *aEvent);
90 void mouseMoveEvent (QMouseEvent *aEvent);
91 void contextMenuEvent (QContextMenuEvent *aEvent);
92 void focusInEvent (QFocusEvent *aEvent);
93 void focusOutEvent (QFocusEvent *aEvent);
94 void paintEvent (QPaintEvent *aEvent);
95
96protected slots:
97
98 void copy();
99
100private:
101
102 void init();
103
104 void updateText();
105
106 QString removeHtmlTags (QString aText) const
107 {
108 /* Remove all HTML tags from the text and return it. */
109 return QString(aText).remove (mCopyRegExp);
110 }
111
112 Qt::TextElideMode toTextElideMode (const QString& aStr) const
113 {
114 /* Converts a string to a Qt elide mode */
115 Qt::TextElideMode mode = Qt::ElideNone;
116 if (aStr == "start")
117 mode = Qt::ElideLeft;
118 else
119 if (aStr == "middle")
120 mode = Qt::ElideMiddle;
121 else
122 if (aStr == "end")
123 mode = Qt::ElideRight;
124 return mode;
125 }
126
127
128 QString compressText (const QString &aText) const;
129
130 /* Private member vars */
131 QString mText;
132 bool mFullSizeSeclection;
133 static const QRegExp mCopyRegExp;
134 static QRegExp mElideRegExp;
135 QSize mOwnSizeHint;
136 bool mStartDragging;
137};
138
139#endif // __QILabel_p_h__
140
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette