added brace wrapping after if and for

This commit is contained in:
fourtf
2018-10-21 13:43:02 +02:00
parent c6e1ec3c71
commit e259b9e39f
138 changed files with 4738 additions and 2237 deletions
+43 -21
View File
@@ -44,18 +44,22 @@ QString ResizingTextEdit::textUnderCursor(bool *hadSpace) const
auto textUpToCursor = currentText.left(tc.selectionStart());
auto words = textUpToCursor.splitRef(' ');
if (words.size() == 0) {
if (words.size() == 0)
{
return QString();
}
bool first = true;
QString lastWord;
for (auto it = words.crbegin(); it != words.crend(); ++it) {
for (auto it = words.crbegin(); it != words.crend(); ++it)
{
auto word = *it;
if (first && word.isEmpty()) {
if (first && word.isEmpty())
{
first = false;
if (hadSpace != nullptr) {
if (hadSpace != nullptr)
{
*hadSpace = true;
}
continue;
@@ -65,7 +69,8 @@ QString ResizingTextEdit::textUnderCursor(bool *hadSpace) const
break;
}
if (lastWord.isEmpty()) {
if (lastWord.isEmpty())
{
return QString();
}
@@ -82,23 +87,27 @@ void ResizingTextEdit::keyPressEvent(QKeyEvent *event)
(event->key() == Qt::Key_Tab || event->key() == Qt::Key_Backtab) &&
(event->modifiers() & Qt::ControlModifier) == Qt::NoModifier;
if (doComplete) {
if (doComplete)
{
// check if there is a completer
if (!this->completer_) {
if (!this->completer_)
{
return;
}
QString currentCompletionPrefix = this->textUnderCursor();
// check if there is something to complete
if (!currentCompletionPrefix.size()) {
if (!currentCompletionPrefix.size())
{
return;
}
auto *completionModel =
static_cast<CompletionModel *>(this->completer_->model());
if (!this->completionInProgress_) {
if (!this->completionInProgress_)
{
// First type pressing tab after modifying a message, we refresh our
// completion model
this->completer_->setModel(completionModel);
@@ -110,15 +119,20 @@ void ResizingTextEdit::keyPressEvent(QKeyEvent *event)
}
// scrolling through selections
if (event->key() == Qt::Key_Tab) {
if (event->key() == Qt::Key_Tab)
{
if (!this->completer_->setCurrentRow(
this->completer_->currentRow() + 1)) {
this->completer_->currentRow() + 1))
{
// wrap over and start again
this->completer_->setCurrentRow(0);
}
} else {
}
else
{
if (!this->completer_->setCurrentRow(
this->completer_->currentRow() - 1)) {
this->completer_->currentRow() - 1))
{
// wrap over and start again
this->completer_->setCurrentRow(
this->completer_->completionCount() - 1);
@@ -136,11 +150,13 @@ void ResizingTextEdit::keyPressEvent(QKeyEvent *event)
// might be a better solution but nobody is gonna bother anyways
if (event->key() != Qt::Key_Shift && event->key() != Qt::Key_Control &&
event->key() != Qt::Key_Alt && event->key() != Qt::Key_Super_L &&
event->key() != Qt::Key_Super_R) {
event->key() != Qt::Key_Super_R)
{
this->completionInProgress_ = false;
}
if (!event->isAccepted()) {
if (!event->isAccepted())
{
QTextEdit::keyPressEvent(event);
}
}
@@ -149,7 +165,8 @@ void ResizingTextEdit::focusInEvent(QFocusEvent *event)
{
QTextEdit::focusInEvent(event);
if (event->gotFocus()) {
if (event->gotFocus())
{
this->focused.invoke();
}
}
@@ -158,20 +175,23 @@ void ResizingTextEdit::focusOutEvent(QFocusEvent *event)
{
QTextEdit::focusOutEvent(event);
if (event->lostFocus()) {
if (event->lostFocus())
{
this->focusLost.invoke();
}
}
void ResizingTextEdit::setCompleter(QCompleter *c)
{
if (this->completer_) {
if (this->completer_)
{
QObject::disconnect(this->completer_, nullptr, this, nullptr);
}
this->completer_ = c;
if (!this->completer_) {
if (!this->completer_)
{
return;
}
@@ -186,7 +206,8 @@ void ResizingTextEdit::setCompleter(QCompleter *c)
void ResizingTextEdit::insertCompletion(const QString &completion)
{
if (this->completer_->widget() != this) {
if (this->completer_->widget() != this)
{
return;
}
@@ -195,7 +216,8 @@ void ResizingTextEdit::insertCompletion(const QString &completion)
int prefixSize = prefix.size();
if (hadSpace) {
if (hadSpace)
{
++prefixSize;
}