VirtualBox

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

Last change on this file since 9600 was 9392, checked in by vboxsync, 17 years ago

FE/Qt4: typo

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 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
93protected slots:
94
95 void copy();
96
97private:
98
99 void init();
100
101 void updateText();
102
103 QString removeHtmlTags (QString aText) const
104 {
105 /* Remove all HTML tags from the text and return it. */
106 return QString(aText).remove (mCopyRegExp);
107 }
108
109 Qt::TextElideMode toTextElideMode (const QString& aStr) const
110 {
111 /* Converts a string to a Qt elide mode */
112 Qt::TextElideMode mode = Qt::ElideNone;
113 if (aStr == "start")
114 mode = Qt::ElideLeft;
115 else
116 if (aStr == "middle")
117 mode = Qt::ElideMiddle;
118 else
119 if (aStr == "end")
120 mode = Qt::ElideRight;
121 return mode;
122 }
123
124
125 QString compressText (const QString &aText) const;
126
127 /* Private member vars */
128 QString mText;
129 bool mFullSizeSeclection;
130 static const QRegExp mCopyRegExp;
131 static QRegExp mElideRegExp;
132 QSize mOwnSizeHint;
133 bool mStartDragging;
134};
135
136#endif // __QILabel_p_h__
137
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