added new TupleTableModel for settingsdialog

This commit is contained in:
fourtf
2018-04-25 14:49:30 +02:00
parent 1edcfe5219
commit 859f4aefcb
18 changed files with 574 additions and 236 deletions
+13 -4
View File
@@ -10,13 +10,14 @@ namespace messages {
struct HighlightPhrase {
QString key;
bool sound;
bool alert;
bool sound;
bool regex;
bool operator==(const HighlightPhrase &rhs) const
bool operator==(const HighlightPhrase &other) const
{
return std::tie(this->key, this->sound, this->alert) ==
std::tie(rhs.key, rhs.sound, rhs.alert);
return std::tie(this->key, this->sound, this->alert, this->regex) ==
std::tie(other.key, other.sound, other.alert, other.regex);
}
};
} // namespace messages
@@ -35,6 +36,7 @@ struct Serialize<chatterino::messages::HighlightPhrase> {
AddMember(ret, "key", value.key, a);
AddMember(ret, "alert", value.alert, a);
AddMember(ret, "sound", value.sound, a);
AddMember(ret, "regex", value.regex, a);
return ret;
}
@@ -70,6 +72,13 @@ struct Deserialize<chatterino::messages::HighlightPhrase> {
}
}
if (value.HasMember("regex")) {
const rapidjson::Value &regex = value["regex"];
if (regex.IsBool()) {
ret.regex = regex.GetBool();
}
}
return ret;
}
};
+1 -1
View File
@@ -198,7 +198,7 @@ void MessageLayout::updateBuffer(QPixmap *buffer, int messageIndex, Selection &s
// draw message
this->container.paintElements(painter);
#ifdef OHHEYITSFOURTF
#ifdef FOURTF
// debug
painter.setPen(QColor(255, 0, 0));
painter.drawRect(buffer->rect().x(), buffer->rect().y(), buffer->rect().width() - 1,
@@ -191,7 +191,7 @@ MessageLayoutElement *MessageLayoutContainer::getElementAt(QPoint point)
void MessageLayoutContainer::paintElements(QPainter &painter)
{
for (const std::unique_ptr<MessageLayoutElement> &element : this->elements) {
#ifdef OHHEYITSFOURTF
#ifdef FOURTF
painter.setPen(QColor(0, 255, 0));
painter.drawRect(element->getRect());
#endif
@@ -214,12 +214,14 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex,
QColor selectionColor = themeManager.messages.selection;
// don't draw anything
if (selection.selectionMin.messageIndex > messageIndex || selection.selectionMax.messageIndex < messageIndex) {
if (selection.selectionMin.messageIndex > messageIndex ||
selection.selectionMax.messageIndex < messageIndex) {
return;
}
// fully selected
if (selection.selectionMin.messageIndex < messageIndex && selection.selectionMax.messageIndex > messageIndex) {
if (selection.selectionMin.messageIndex < messageIndex &&
selection.selectionMax.messageIndex > messageIndex) {
for (Line &line : this->lines) {
QRect rect = line.rect;
@@ -267,8 +269,8 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex,
int c = this->elements[i]->getSelectionIndexCount();
if (index + c > selection.selectionMax.charIndex) {
r = this->elements[i]->getXFromIndex(selection.selectionMax.charIndex -
index);
r = this->elements[i]->getXFromIndex(
selection.selectionMax.charIndex - index);
break;
}
index += c;