Gui: Minor cleanup

Cleans up code which was touched in previous commit.

* Don't call popup() twice when not needed
* use nullptr instead of 0 for pointers
This commit is contained in:
Benjamin Nauck
2021-02-13 02:24:23 +01:00
committed by wwmayer
parent f5b7f645d8
commit db3b35cb5d
2 changed files with 12 additions and 12 deletions

View File

@@ -473,8 +473,8 @@ void ExpressionCompleter::slotUpdate(const QString & prefix, int pos)
// No tokens
if (tokens.size() == 0) {
if (popup())
popup()->setVisible(false);
if (auto p = popup())
p->setVisible(false);
return;
}
@@ -520,8 +520,8 @@ void ExpressionCompleter::slotUpdate(const QString & prefix, int pos)
// Not an unclosed string and the last character is a space
if(!stringing && prefix.size() && prefix[prefixEnd-1] == QChar(32)) {
if (popup())
popup()->setVisible(false);
if (auto p = popup())
p->setVisible(false);
return;
}
@@ -560,14 +560,14 @@ void ExpressionCompleter::slotUpdate(const QString & prefix, int pos)
if (!completionPrefix.empty() && widget()->hasFocus())
complete();
else {
if (popup())
popup()->setVisible(false);
if (auto p = popup())
p->setVisible(false);
}
}
ExpressionLineEdit::ExpressionLineEdit(QWidget *parent, bool noProperty, bool requireLeadingEqualSign)
: QLineEdit(parent)
, completer(0)
, completer(nullptr)
, block(true)
, noProperty(noProperty)
, exactMatch(false)
@@ -681,7 +681,7 @@ void ExpressionLineEdit::contextMenuEvent(QContextMenuEvent *event)
ExpressionTextEdit::ExpressionTextEdit(QWidget *parent)
: QPlainTextEdit(parent)
, completer(0)
, completer(nullptr)
, block(true)
, exactMatch(false)
{
@@ -703,7 +703,7 @@ void ExpressionTextEdit::setDocumentObject(const App::DocumentObject * currentDo
return;
}
if (currentDocObj != 0) {
if (currentDocObj != nullptr) {
completer = new ExpressionCompleter(currentDocObj, this);
#if QT_VERSION>=QT_VERSION_CHECK(5,2,0)
if (!exactMatch)

View File

@@ -51,7 +51,7 @@ class GuiExport ExpressionCompleter : public QCompleter
Q_OBJECT
public:
ExpressionCompleter(const App::DocumentObject * currentDocObj,
QObject *parent = 0, bool noProperty = false);
QObject *parent = nullptr, bool noProperty = false);
void getPrefixRange(int &start, int &end) const {
start = prefixStart;
@@ -87,7 +87,7 @@ private:
class GuiExport ExpressionLineEdit : public QLineEdit {
Q_OBJECT
public:
ExpressionLineEdit(QWidget *parent = 0, bool noProperty = false, bool requireLeadingEqualSign = false);
ExpressionLineEdit(QWidget *parent = nullptr, bool noProperty = false, bool requireLeadingEqualSign = false);
void setDocumentObject(const App::DocumentObject *currentDocObj);
bool completerActive() const;
void hideCompleter();
@@ -112,7 +112,7 @@ private:
class GuiExport ExpressionTextEdit : public QPlainTextEdit {
Q_OBJECT
public:
ExpressionTextEdit(QWidget *parent = 0);
ExpressionTextEdit(QWidget *parent = nullptr);
void setDocumentObject(const App::DocumentObject *currentDocObj);
bool completerActive() const;
void hideCompleter();