ACF $AcfVersion:0$
CExtLineEdit.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ACF-Commercial
2#pragma once
3
4
5// Qt includes
6#include <QtCore/QList>
7#include <QtGui/QIcon>
8#if QT_VERSION >= 0x050000
9#include <QtWidgets/QLineEdit>
10#include <QtWidgets/QLabel>
11#else
12#include <QtGui/QLineEdit>
13#include <QtGui/QLabel>
14#endif
15
16// ACF includes
17#include <istd/TDelPtr.h>
18
19#include <iwidgets/iwidgets.h>
20
21
22namespace iwidgets
23{
24
25
31class CExtLineEdit: public QLineEdit
32{
33 Q_OBJECT
34
35public:
36 typedef QLineEdit BaseClass;
37
38 explicit CExtLineEdit(QWidget* parent = NULL);
39
44 const QString& startupText,
45 int margins,
46 QWidget* parent = NULL);
47
51 virtual void SetStartupText(const QString& startupText);
52
56 virtual QString GetStartupText() const;
57
61 virtual QString GetText() const;
62
66 void SetIcon(const QIcon& icon);
67
73 void AddWidget(QWidget* widgetPtr, int alignmentFlags);
74
75protected:
76 // reimplemented (QWidget)
77 virtual void resizeEvent(QResizeEvent* resizeEvent) override;
78 virtual void focusInEvent(QFocusEvent* focusEvent) override;
79
80private Q_SLOTS:
81 void OnEditingFinished();
82 void OnTextChanged(const QString& text);
83
84private:
85 void UpdateLayout();
86 void UpdateStartupText();
87 void InitWidget();
88
89private:
90 QString m_startupText;
91 int m_margins;
92
93 struct SubWidgetInfo
94 {
95 QWidget* widget;
96 int alignmentFlags;
97 int margin;
98 };
99
100 typedef QList<SubWidgetInfo> SubWidgetsList;
101
102 QLabel* m_iconPtr;
103 SubWidgetsList m_subWidgets;
104};
105
106
107} // namespace iwidgets
108
109
110
111
Input editor with extended functionality.
void SetIcon(const QIcon &icon)
Set the icon, that will appeared on the left side of the line edit.
virtual void SetStartupText(const QString &startupText)
Set the text, that will be shown at the first time the editor becomes visible.
CExtLineEdit(QWidget *parent=NULL)
virtual void focusInEvent(QFocusEvent *focusEvent) override
CExtLineEdit(const QString &startupText, int margins, QWidget *parent=NULL)
Construct a line edit with the given properties.
virtual QString GetStartupText() const
Get the startup text.
virtual QString GetText() const
Get editor text.
virtual void resizeEvent(QResizeEvent *resizeEvent) override
void AddWidget(QWidget *widgetPtr, int alignmentFlags)
Add a widget to the line edit area according to alginmentFlags.
#define NULL
Definition istd.h:74
Namespace contains implementation of Qt widget extensions.