VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox4/include/QIRichLabel_p.h@ 9382

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

FE/Qt4: Initial version of the ported QIRichLabel class.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 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
72protected:
73
74 void resizeEvent (QResizeEvent *aEvent);
75 void mousePressEvent (QMouseEvent *aEvent);
76 void contextMenuEvent (QContextMenuEvent *aEvent);
77
78protected slots:
79
80 void copy();
81
82private:
83
84 void init();
85
86 void updateText();
87
88 QString removeHtmlTags (QString aText) const
89 {
90 /* Remove all HTML tags from the text and return it. */
91 return QString(aText).remove (mCopyRegExp);
92 }
93
94 Qt::TextElideMode toTextElideMode (const QString& aStr) const
95 {
96 /* Converts a string to a Qt elide mode */
97 Qt::TextElideMode mode = Qt::ElideNone;
98 if (aStr == "start")
99 mode = Qt::ElideLeft;
100 else
101 if (aStr == "middle")
102 mode = Qt::ElideMiddle;
103 else
104 if (aStr == "end")
105 mode = Qt::ElideRight;
106 return mode;
107 }
108
109
110 QString compressText (const QString &aText) const;
111
112 /* Private member vars */
113 QString mText;
114 bool mFullSizeSeclection;
115 static const QRegExp mCopyRegExp;
116 static QRegExp mElideRegExp;
117};
118
119#endif // __QILabel_p_h__
120
Note: See TracBrowser for help on using the repository browser.

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