From 4f3f9906f111f59f5f04cc3a1de6ac2b8e84de3e Mon Sep 17 00:00:00 2001 From: Date: Wed, 27 Dec 2017 21:29:56 +0100 Subject: [PATCH] commented code out that didn't compile --- src/commandmanager.cpp | 120 ++++++++++++++--------------- src/commandmanager.hpp | 30 ++++---- src/widgets/helper/channelview.cpp | 16 ++-- 3 files changed, 85 insertions(+), 81 deletions(-) diff --git a/src/commandmanager.cpp b/src/commandmanager.cpp index ae996ac15..6179b3542 100644 --- a/src/commandmanager.cpp +++ b/src/commandmanager.cpp @@ -3,75 +3,75 @@ #include namespace chatterino { -void CommandManager::execCommand(QString text) -{ - QStringList words = text.split(' ', QString::SkipEmptyParts); +// QString CommandManager::execCommand(QString text) +//{ +// QStringList words = text.split(' ', QString::SkipEmptyParts); - if (words.length() == 0) { - return text; - } +// if (words.length() == 0) { +// return text; +// } - QString commandName = words[0]; - if (commandName[0] == "/") { - commandName = commandName.mid(1); - } +// QString commandName = words[0]; +// if (commandName[0] == "/") { +// commandName = commandName.mid(1); +// } - Command *command = nullptr; - for (Command &command : this->commands) { - if (command.name == commandName) { - command = &command; - break; - } - } +// Command *command = nullptr; +// for (Command &command : this->commands) { +// if (command.name == commandName) { +// command = &command; +// break; +// } +// } - if (command == nullptr) { - return text; - } +// if (command == nullptr) { +// return text; +// } - QString result; +// QString result; - static QRegularExpression parseCommand("[^{]({{)*{(\d+\+?)}"); - for (QRegularExpressionMatch &match : parseCommand.globalMatch(command->text)) { - result += text.mid(match.capturedStart(), match.capturedLength()); +// static QRegularExpression parseCommand("[^{]({{)*{(\d+\+?)}"); +// for (QRegularExpressionMatch &match : parseCommand.globalMatch(command->text)) { +// result += text.mid(match.capturedStart(), match.capturedLength()); - QString wordIndexMatch = match.captured(2); +// QString wordIndexMatch = match.captured(2); - bool ok; - int wordIndex = wordIndexMatch.replace("=", "").toInt(ok); - if (!ok) { - result += match.captured(); - continue; - } - if (words.length() <= wordIndex) { - // alternatively return text because the operation failed - result += ""; - return; - } +// bool ok; +// int wordIndex = wordIndexMatch.replace("=", "").toInt(ok); +// if (!ok) { +// result += match.captured(); +// continue; +// } +// if (words.length() <= wordIndex) { +// // alternatively return text because the operation failed +// result += ""; +// return; +// } - if (wordIndexMatch[wordIndexMatch.length() - 1] == '+') { - for (int i = wordIndex; i < words.length(); i++) { - result += words[i]; - } - } else { - result += words[wordIndex]; - } - } +// if (wordIndexMatch[wordIndexMatch.length() - 1] == '+') { +// for (int i = wordIndex; i < words.length(); i++) { +// result += words[i]; +// } +// } else { +// result += words[wordIndex]; +// } +// } - result += text.mid(match.capturedStart(), match.capturedLength()); +// result += text.mid(match.capturedStart(), match.capturedLength()); - return result; -} - -CommandManager::Command::Command(QString _text) -{ - int index = _text.indexOf(' '); - - if (index == -1) { - this->name == _text; - return; - } - - this->name = _text.mid(0, index); - this->text = _text.mid(index + 1); -} +// return result; +//} + +// CommandManager::Command::Command(QString _text) +//{ +// int index = _text.indexOf(' '); + +// if (index == -1) { +// this->name == _text; +// return; +// } + +// this->name = _text.mid(0, index); +// this->text = _text.mid(index + 1); +//} } diff --git a/src/commandmanager.hpp b/src/commandmanager.hpp index 87d915a6b..2fb566ec3 100644 --- a/src/commandmanager.hpp +++ b/src/commandmanager.hpp @@ -7,28 +7,28 @@ namespace chatterino { class CommandManager { -public: - CommandManager() = delete; + // public: + // CommandManager() = delete; - QString execCommand(QString text); + // QString execCommand(QString text); // void addCommand ? // void loadCommands(QString) taking all commands as a \n seperated list ? - static CommandManager *getInstance() - { - static CommandManager manager; + // static CommandManager *getInstance() + // { + // static CommandManager manager; - return manager; - } + // return manager; + // } -private: - struct Command { - QString name; - QString text; + // private: + // struct Command { + // QString name; + // QString text; - Command(QString text); - }; + // Command(QString text); + // }; - std::vector commands; + // std::vector commands; }; } diff --git a/src/widgets/helper/channelview.cpp b/src/widgets/helper/channelview.cpp index e8c17ec08..2454737a9 100644 --- a/src/widgets/helper/channelview.cpp +++ b/src/widgets/helper/channelview.cpp @@ -127,8 +127,10 @@ void ChannelView::actuallyLayoutMessages() this->showingLatestMessages = this->scrollBar.isAtBottom() || !this->scrollBar.isVisible(); size_t start = this->scrollBar.getCurrentValue(); + // int layoutWidth = + // (this->scrollBar.isVisible() ? width() - this->scrollBar.width() : width()) - 4; int layoutWidth = - (this->scrollBar.isVisible() ? width() - this->scrollBar.width() : width()) - 4; + this->width() - (this->scrollBar.isVisible() ? 16 : 4) * this->getDpiMultiplier(); // layout the visible messages in the view if (messagesSnapshot.getLength() > start) { @@ -251,8 +253,9 @@ QString ChannelView::getSelectedText() if (first) { first = false; - bool isSingleWord = isSingleMessage && this->selection.max.charIndex - charIndex < - part.getCharacterLength(); + bool isSingleWord = + isSingleMessage && + this->selection.max.charIndex - charIndex < part.getCharacterLength(); if (isSingleWord) { // return single word @@ -573,9 +576,10 @@ void ChannelView::updateMessageBuffer(messages::MessageRef *messageRef, QPixmap // this->selectionMax.messageIndex >= messageIndex) { // painter.fillRect(buffer->rect(), QColor(24, 55, 25)); //} else { - painter.fillRect(buffer->rect(), (messageRef->getMessage()->containsHighlightedPhrase()) - ? this->colorScheme.ChatBackgroundHighlighted - : this->colorScheme.ChatBackground); + painter.fillRect(buffer->rect(), + (messageRef->getMessage()->containsHighlightedPhrase()) + ? this->colorScheme.ChatBackgroundHighlighted + : this->colorScheme.ChatBackground); //} // draw selection