fix highlights - reformat some stuff

This commit is contained in:
Rasmus Karlsson 2017-09-24 18:43:24 +02:00
parent 903cf30ddf
commit c14dc43b18
8 changed files with 27 additions and 46 deletions

View file

@ -7,11 +7,6 @@
#include "ircmanager.hpp"
#include "messages/link.hpp"
#include "resources.hpp"
#include "settingsmanager.hpp"
#include <QColor>
#include <QObjectUserData>
#include <QStringList>
#include <ctime>
#include <list>
@ -20,27 +15,16 @@
namespace chatterino {
namespace messages {
/*
Message::Message(const QString &text)
: text(text)
{
this->words.push_back(
Word(text, Word::Text, ColorScheme::getInstance().SystemMessageColor, text, QString()));
}
*/
//Message::Message(const QString &text, const std::vector<Word> &words, const bool &highlight)
// : text(text)
// , highlightTab(highlight)
// , words(words)
//{
//}
bool Message::getCanHighlightTab() const
{
return this->highlightTab;
}
void Message::setHighlight(bool value)
{
this->highlightTab = value;
}
const QString &Message::getTimeoutUser() const
{
return this->timeoutUser;

View file

@ -1,15 +1,10 @@
#pragma once
#include "messages/message.hpp"
#include "messages/messageparseargs.hpp"
#include "messages/word.hpp"
#include "messages/wordpart.hpp"
#include <IrcMessage>
#include <QVector>
#include <chrono>
#include <memory>
#include <vector>
namespace chatterino {
@ -23,11 +18,8 @@ typedef std::shared_ptr<Message> SharedMessage;
class Message
{
public:
// explicit Message(const QString &text);
// explicit Message(const QString &text, const std::vector<messages::Word> &words,
// const bool &highlight);
bool getCanHighlightTab() const;
void setHighlight(bool value);
const QString &getTimeoutUser() const;
int getTimeoutCount() const;
const QString &getUserName() const;
@ -52,7 +44,9 @@ private:
static QRegularExpression *cheerRegex;
// what is highlightTab?
bool highlightTab = false;
QString timeoutUser = "";
int timeoutCount = 0;
bool disabled = false;

View file

@ -24,14 +24,14 @@ void MessageBuilder::appendWord(const Word &&word)
void MessageBuilder::appendTimestamp()
{
time_t t;
std::time_t t;
time(&t);
appendTimestamp(t);
this->appendTimestamp(t);
}
void MessageBuilder::setHighlight(const bool &value)
void MessageBuilder::setHighlight(bool value)
{
highlight = value;
this->message->setHighlight(value);
}
void MessageBuilder::appendTimestamp(time_t time)
@ -41,13 +41,13 @@ void MessageBuilder::appendTimestamp(time_t time)
// Add word for timestamp with no seconds
strftime(timeStampBuffer, 69, "%H:%M", localtime(&time));
QString timestampNoSeconds(timeStampBuffer);
appendWord(Word(timestampNoSeconds, Word::TimestampNoSeconds,
this->appendWord(Word(timestampNoSeconds, Word::TimestampNoSeconds,
MessageColor(MessageColor::System), QString(), QString()));
// Add word for timestamp with seconds
strftime(timeStampBuffer, 69, "%H:%M:%S", localtime(&time));
QString timestampWithSeconds(timeStampBuffer);
appendWord(Word(timestampWithSeconds, Word::TimestampWithSeconds,
this->appendWord(Word(timestampWithSeconds, Word::TimestampWithSeconds,
MessageColor(MessageColor::System), QString(), QString()));
}
@ -67,6 +67,7 @@ QString MessageBuilder::matchLink(const QString &string)
if (!captured.contains(httpRegex)) {
captured.insert(0, "http://");
}
return captured;
}

View file

@ -19,7 +19,7 @@ public:
void appendWord(const Word &&word);
void appendTimestamp();
void appendTimestamp(std::time_t time);
void setHighlight(const bool &value);
void setHighlight(bool value);
QString matchLink(const QString &string);
QRegularExpression linkRegex;

View file

@ -1,4 +1,4 @@
#include "messageref.hpp"
#include "messages/messageref.hpp"
#include "emotemanager.hpp"
#include "settingsmanager.hpp"

View file

@ -1,6 +1,7 @@
#pragma once
#include "messages/message.hpp"
#include "messages/wordpart.hpp"
#include <QPixmap>
@ -28,14 +29,14 @@ public:
std::shared_ptr<QPixmap> buffer = nullptr;
bool updateBuffer = false;
const messages::Word *tryGetWordPart(QPoint point);
const Word *tryGetWordPart(QPoint point);
int getSelectionIndex(QPoint position);
private:
// variables
SharedMessage message;
std::vector<messages::WordPart> wordParts;
std::vector<WordPart> wordParts;
int height = 0;

View file

@ -390,7 +390,8 @@ void TwitchMessageBuilder::parseHighlights()
bool alert;
};
QStringList blackList = settings.highlightUserBlacklist.get().split("\n",QString::SkipEmptyParts);
QStringList blackList =
settings.highlightUserBlacklist.get().split("\n", QString::SkipEmptyParts);
// TODO: This vector should only be rebuilt upon highlights being changed
std::vector<Highlight> activeHighlights;
@ -410,8 +411,7 @@ void TwitchMessageBuilder::parseHighlights()
bool doHighlight = false;
bool playSound = false;
bool doAlert = false;
if(!blackList.contains(this->ircMessage->nick(),Qt::CaseInsensitive))
{
if (!blackList.contains(this->ircMessage->nick(), Qt::CaseInsensitive)) {
for (const Highlight &highlight : activeHighlights) {
if (this->originalMessage.contains(highlight.target, Qt::CaseInsensitive)) {
qDebug() << "Highlight because " << this->originalMessage << " contains "

View file

@ -2,6 +2,7 @@
#include "emotemanager.hpp"
#include "messages/messagebuilder.hpp"
#include "messages/messageparseargs.hpp"
#include "resources.hpp"
#include "twitch/twitchchannel.hpp"