1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox frontends: Qt GUI ("VirtualBox"):
|
---|
4 | * VirtualBox Qt extensions: QILabel class declaration
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2009 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_h__
|
---|
28 | #define __QILabel_h__
|
---|
29 |
|
---|
30 | /* Global includes */
|
---|
31 | #include <QLabel>
|
---|
32 |
|
---|
33 | class QILabel: public QLabel
|
---|
34 | {
|
---|
35 | Q_OBJECT;
|
---|
36 |
|
---|
37 | public:
|
---|
38 |
|
---|
39 | QILabel (QWidget *aParent = 0, Qt::WindowFlags aFlags = 0);
|
---|
40 | QILabel (const QString &aText, QWidget *aParent = 0, Qt::WindowFlags aFlags = 0);
|
---|
41 |
|
---|
42 | /* Focusing extensions */
|
---|
43 | bool fullSizeSelection() const;
|
---|
44 | void setFullSizeSelection (bool aEnabled);
|
---|
45 |
|
---|
46 | /* Size-Hint extensions */
|
---|
47 | void useSizeHintForWidth (int aWidthHint) const;
|
---|
48 | QSize sizeHint() const;
|
---|
49 | QSize minimumSizeHint() const;
|
---|
50 |
|
---|
51 | /* Default QLabel methods */
|
---|
52 | QString text() const;
|
---|
53 |
|
---|
54 | public slots:
|
---|
55 |
|
---|
56 | void clear();
|
---|
57 | void setText (const QString &aText);
|
---|
58 | void copy();
|
---|
59 |
|
---|
60 | protected:
|
---|
61 |
|
---|
62 | void resizeEvent (QResizeEvent *aEvent);
|
---|
63 | void mousePressEvent (QMouseEvent *aEvent);
|
---|
64 | void mouseReleaseEvent (QMouseEvent *aEvent);
|
---|
65 | void mouseMoveEvent (QMouseEvent *aEvent);
|
---|
66 | void contextMenuEvent (QContextMenuEvent *aEvent);
|
---|
67 | void focusInEvent (QFocusEvent *aEvent);
|
---|
68 | void focusOutEvent (QFocusEvent *aEvent);
|
---|
69 | void paintEvent (QPaintEvent *aEvent);
|
---|
70 |
|
---|
71 | private:
|
---|
72 |
|
---|
73 | void init();
|
---|
74 |
|
---|
75 | void updateSizeHint() const;
|
---|
76 | void setFullText (const QString &aText);
|
---|
77 | void updateText();
|
---|
78 | QString removeHtmlTags (QString aText) const;
|
---|
79 | Qt::TextElideMode toTextElideMode (const QString& aStr) const;
|
---|
80 | QString compressText (const QString &aText) const;
|
---|
81 |
|
---|
82 | QString mText;
|
---|
83 | bool mFullSizeSelection;
|
---|
84 | static const QRegExp mCopyRegExp;
|
---|
85 | static QRegExp mElideRegExp;
|
---|
86 | mutable bool mIsHintValid;
|
---|
87 | mutable int mWidthHint;
|
---|
88 | mutable QSize mOwnSizeHint;
|
---|
89 | bool mStartDragging;
|
---|
90 | QAction *mCopyAction;
|
---|
91 | };
|
---|
92 |
|
---|
93 | #endif // __QILabel_h__
|
---|
94 |
|
---|