forked from qt-creator/qt-creator
FancyLineEdit: Refactor class
Rename the code that evaluates the text and make it a public slot. Change-Id: I843bf505fa6e33661fc840a1fd2ec13ceb210037 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
@@ -169,7 +169,7 @@ FancyLineEdit::FancyLineEdit(QWidget *parent) :
|
||||
|
||||
connect(d->m_iconbutton[Left], &QAbstractButton::clicked, this, &FancyLineEdit::iconClicked);
|
||||
connect(d->m_iconbutton[Right], &QAbstractButton::clicked, this, &FancyLineEdit::iconClicked);
|
||||
connect(this, &QLineEdit::textChanged, this, &FancyLineEdit::onTextChanged);
|
||||
connect(this, &QLineEdit::textChanged, this, &FancyLineEdit::validate);
|
||||
}
|
||||
|
||||
FancyLineEdit::~FancyLineEdit()
|
||||
@@ -451,8 +451,10 @@ QString FancyLineEdit::errorMessage() const
|
||||
return d->m_errorMessage;
|
||||
}
|
||||
|
||||
void FancyLineEdit::onTextChanged(const QString &t)
|
||||
void FancyLineEdit::validate()
|
||||
{
|
||||
const QString t = text();
|
||||
|
||||
if (d->m_isFiltering){
|
||||
if (t != d->m_lastFilterText) {
|
||||
d->m_lastFilterText = t;
|
||||
@@ -498,17 +500,11 @@ void FancyLineEdit::onTextChanged(const QString &t)
|
||||
handleChanged(t);
|
||||
}
|
||||
|
||||
void FancyLineEdit::triggerChanged()
|
||||
{
|
||||
onTextChanged(text());
|
||||
}
|
||||
|
||||
QString FancyLineEdit::fixInputString(const QString &string)
|
||||
{
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// IconButton - helper class to represent a clickable icon
|
||||
//
|
||||
|
@@ -143,16 +143,14 @@ public:
|
||||
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);
|
||||
|
||||
void setValidationFunction(const ValidationFunction &fn);
|
||||
static ValidationFunction defaultValidationFunction();
|
||||
void validate();
|
||||
|
||||
protected slots:
|
||||
protected:
|
||||
// Custom behaviour can be added here.
|
||||
virtual void handleChanged(const QString &) {}
|
||||
|
||||
@@ -166,17 +164,15 @@ signals:
|
||||
void validChanged(bool validState);
|
||||
void validReturnPressed();
|
||||
|
||||
private slots:
|
||||
void iconClicked();
|
||||
void onTextChanged(const QString &);
|
||||
void onEditingFinished();
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
|
||||
virtual QString fixInputString(const QString &string);
|
||||
|
||||
private:
|
||||
void iconClicked();
|
||||
void onEditingFinished();
|
||||
|
||||
static bool validateWithValidator(FancyLineEdit *edit, QString *errorMessage);
|
||||
// Unimplemented, to force the user to make a decision on
|
||||
// whether to use setHistoryCompleter() or setSpecialCompleter().
|
||||
|
@@ -533,11 +533,6 @@ bool NewClassWidget::isValid(QString *error) const
|
||||
return true;
|
||||
}
|
||||
|
||||
void NewClassWidget::triggerUpdateFileNames()
|
||||
{
|
||||
d->m_ui.classLineEdit->triggerChanged();
|
||||
}
|
||||
|
||||
void NewClassWidget::slotUpdateFileNames(const QString &baseName)
|
||||
{
|
||||
if (debugNewClassWidget)
|
||||
|
@@ -155,10 +155,6 @@ public slots:
|
||||
*/
|
||||
void suggestClassNameFromBase();
|
||||
|
||||
public slots:
|
||||
/** Trigger an update (after changing settings) */
|
||||
void triggerUpdateFileNames();
|
||||
|
||||
private slots:
|
||||
void slotUpdateFileNames(const QString &t);
|
||||
void slotValidChanged();
|
||||
|
@@ -453,7 +453,7 @@ QString PathChooser::errorMessage() const
|
||||
|
||||
void PathChooser::triggerChanged()
|
||||
{
|
||||
d->m_lineEdit->triggerChanged();
|
||||
d->m_lineEdit->validate();
|
||||
}
|
||||
|
||||
void PathChooser::setAboutToShowContextMenuHandler(PathChooser::AboutToShowContextMenuHandler handler)
|
||||
@@ -616,7 +616,7 @@ void PathChooser::setExpectedKind(Kind expected)
|
||||
if (d->m_acceptingKind == expected)
|
||||
return;
|
||||
d->m_acceptingKind = expected;
|
||||
d->m_lineEdit->triggerChanged();
|
||||
d->m_lineEdit->validate();
|
||||
}
|
||||
|
||||
PathChooser::Kind PathChooser::expectedKind() const
|
||||
|
Reference in New Issue
Block a user