aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/utils/fancylineedit.h
diff options
context:
space:
mode:
authorhjk <hjk121@nokiamail.com>2014-02-13 16:13:54 +0100
committerhjk <hjk121@nokiamail.com>2014-02-14 16:59:47 +0100
commit680209aef5008638b5239cca35ddaac1c3ff010f (patch)
treedd452fc4111c1b97d4cfa1fb632a4bb0ca754788 /src/libs/utils/fancylineedit.h
parenta74de6af81b659ef0dcbbbe25f94d9b527c2be98 (diff)
Utils: Merge BaseValidatingLineEdit into FancyLineEdit
Change-Id: Idb7a6f28ac41bacbfd2603feb8b786c31d3769e3 Reviewed-by: Eike Ziller <eike.ziller@digia.com> Reviewed-by: Christian Stenger <christian.stenger@digia.com>
Diffstat (limited to 'src/libs/utils/fancylineedit.h')
-rw-r--r--src/libs/utils/fancylineedit.h48
1 files changed, 44 insertions, 4 deletions
diff --git a/src/libs/utils/fancylineedit.h b/src/libs/utils/fancylineedit.h
index d1432573cc6..ae58dcb7bff 100644
--- a/src/libs/utils/fancylineedit.h
+++ b/src/libs/utils/fancylineedit.h
@@ -71,6 +71,10 @@ class QTCREATOR_UTILS_EXPORT FancyLineEdit : public CompletingLineEdit
Q_OBJECT
Q_ENUMS(Side)
+ // Validation.
+ Q_PROPERTY(QString initialText READ initialText WRITE setInitialText DESIGNABLE true)
+ Q_PROPERTY(QColor errorColor READ errorColor WRITE setErrorColor DESIGNABLE true)
+
public:
enum Side {Left = 0, Right = 1};
@@ -97,29 +101,66 @@ public:
void setAutoHideButton(Side side, bool h);
bool hasAutoHideButton(Side side) const;
+
+ // Completion
+
// Enable a history completer with a history of entries.
void setHistoryCompleter(const QString &historyKey);
-
// Sets a completer that is not a history completer.
void setSpecialCompleter(QCompleter *completer);
+
+ // Filtering
+
// Enables fitering
void setFiltering(bool on);
+
+ // Validation
+
+ enum State { Invalid, DisplayingInitialText, Valid };
+
+ State state() const;
+ bool isValid() const;
+ QString errorMessage() const;
+
+ QString initialText() const;
+ void setInitialText(const QString &);
+
+ QColor errorColor() const;
+ void setErrorColor(const QColor &);
+
+ // Trigger an update (after changing settings)
+ void triggerChanged();
+
+ static QColor textColor(const QWidget *w);
+ static void setTextColor(QWidget *w, const QColor &c);
+
+protected slots:
+ // Custom behaviour can be added here.
+ virtual void handleChanged(const QString &) {}
+
signals:
void buttonClicked(Utils::FancyLineEdit::Side side);
void leftButtonClicked();
void rightButtonClicked();
+
void filterChanged(const QString &);
+ void validChanged();
+ void validChanged(bool validState);
+ void validReturnPressed();
+
private slots:
- void checkButtons(const QString &);
void iconClicked();
- void slotTextChanged(); // For filtering.
+ void onTextChanged(const QString &);
protected:
void resizeEvent(QResizeEvent *e);
+ virtual bool validate(const QString &value, QString *errorMessage) const;
+ virtual QString fixInputString(const QString &string);
+
private:
// Unimplemented, to force the user to make a decision on
// whether to use setHistoryCompleter() or setSpecialCompleter().
@@ -130,7 +171,6 @@ private:
friend class Utils::FancyLineEditPrivate;
FancyLineEditPrivate *d;
- QString m_oldText;
};
} // namespace Utils