mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-01 05:33:23 +00:00
Do not copy strings when you don't need it.
This patch removed the use of copy-constructors on the QString to use the const-references. Even knowing that the QString is a refcounted class, let's not get that bad habit. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
3d83c48c49
commit
30770f5d85
2 changed files with 7 additions and 7 deletions
|
@ -138,13 +138,13 @@ void TagWidget::reparse()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TagWidget::completionSelected(QString completion)
|
void TagWidget::completionSelected(const QString& completion)
|
||||||
{
|
{
|
||||||
completionHighlighted(completion);
|
completionHighlighted(completion);
|
||||||
emit textChanged();
|
emit textChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TagWidget::completionHighlighted(QString completion)
|
void TagWidget::completionHighlighted(const QString& completion)
|
||||||
{
|
{
|
||||||
QPair<int, int> pos;
|
QPair<int, int> pos;
|
||||||
pos = getCursorTagPosition();
|
pos = getCursorTagPosition();
|
||||||
|
@ -152,7 +152,7 @@ void TagWidget::completionHighlighted(QString completion)
|
||||||
setText(text().remove(pos.first, pos.second - pos.first).insert(pos.first, completion));
|
setText(text().remove(pos.first, pos.second - pos.first).insert(pos.first, completion));
|
||||||
setCursorPosition(pos.first + completion.length());
|
setCursorPosition(pos.first + completion.length());
|
||||||
} else {
|
} else {
|
||||||
setText(completion.append(", "));
|
setText(completion + QString(", "));
|
||||||
setCursorPosition(text().length());
|
setCursorPosition(text().length());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ void TagWidget::setCursorPosition(int position)
|
||||||
blockSignals(false);
|
blockSignals(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TagWidget::setText(QString text)
|
void TagWidget::setText(const QString& text)
|
||||||
{
|
{
|
||||||
blockSignals(true);
|
blockSignals(true);
|
||||||
GroupedLineEdit::setText(text);
|
GroupedLineEdit::setText(text);
|
||||||
|
|
|
@ -12,15 +12,15 @@ public:
|
||||||
void setCompleter(QCompleter *completer);
|
void setCompleter(QCompleter *completer);
|
||||||
QPair<int, int> getCursorTagPosition();
|
QPair<int, int> getCursorTagPosition();
|
||||||
void highlight();
|
void highlight();
|
||||||
void setText(QString text);
|
void setText(const QString& text);
|
||||||
void clear();
|
void clear();
|
||||||
void setCursorPosition(int position);
|
void setCursorPosition(int position);
|
||||||
void wheelEvent(QWheelEvent *event);
|
void wheelEvent(QWheelEvent *event);
|
||||||
public
|
public
|
||||||
slots:
|
slots:
|
||||||
void reparse();
|
void reparse();
|
||||||
void completionSelected(QString);
|
void completionSelected(const QString& text);
|
||||||
void completionHighlighted(QString);
|
void completionHighlighted(const QString& text);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void keyPressEvent(QKeyEvent *e);
|
void keyPressEvent(QKeyEvent *e);
|
||||||
|
|
Loading…
Add table
Reference in a new issue