summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Swift/QtUI/QtHighlightEditor.cpp44
-rw-r--r--Swift/QtUI/QtHighlightEditor.h2
2 files changed, 39 insertions, 7 deletions
diff --git a/Swift/QtUI/QtHighlightEditor.cpp b/Swift/QtUI/QtHighlightEditor.cpp
index 18101d5..457d397 100644
--- a/Swift/QtUI/QtHighlightEditor.cpp
+++ b/Swift/QtUI/QtHighlightEditor.cpp
@@ -69,7 +69,8 @@ QtHighlightEditor::QtHighlightEditor(QtSettingsProvider* settings, QWidget* pare
connect(ui_.radioButton_6, SIGNAL(clicked()), SLOT(soundCustomSelect()));
ui_.lineEdit->setVisible(false);
- ui_.horizontalLayout_2->addWidget(new QtSuggestingJIDInput(this, settings));
+ jid_ = new QtSuggestingJIDInput(this, settings);
+ ui_.horizontalLayout_2->addWidget(jid_);
setWindowTitle(tr("Highlight Rules"));
}
@@ -104,6 +105,35 @@ std::string formatNaturalDescription(const HighlightRule& rule)
return "This rule has not been marked as a chat or room rule!";
}
+ std::vector<std::string> senders = rule.getSenders();
+ std::vector<std::string> keywords = rule.getKeywords();
+
+ if (!senders.empty() || !keywords.empty()) {
+ text += " if";
+ }
+
+ if (!senders.empty()) {
+ text += " the sender is called '" + senders[0] + "'";
+ }
+
+ if (!senders.empty() && !keywords.empty()) {
+ text += ", and";
+ }
+
+ if (!keywords.empty()) {
+ text += " the message contains '" + keywords[0] + "'";
+ if (rule.getMatchCase()) {
+ text += " (case sensivitive)";
+ } else {
+ text += " (not case sensivitive)";
+ }
+ if (rule.getMatchWholeWords()) {
+ text += " as a whole word.";
+ } else {
+ text += " as a part of any word.";
+ }
+ }
+
return text;
}
@@ -244,7 +274,7 @@ HighlightRule QtHighlightEditor::ruleFromDialog()
rule.setMatchMUC(ui_.checkBox_2->isChecked());
if (ui_.checkBox_3->isChecked()) {
- QString senderName = ui_.lineEdit->text();
+ QString senderName = jid_->text();
if (!senderName.isEmpty()) {
std::vector<std::string> senders;
senders.push_back(Q2PSTRING(senderName));
@@ -257,7 +287,7 @@ HighlightRule QtHighlightEditor::ruleFromDialog()
if (!keywordString.isEmpty()) {
std::vector<std::string> keywords;
keywords.push_back(Q2PSTRING(keywordString));
- rule.setSenders(keywords);
+ rule.setKeywords(keywords);
}
}
@@ -290,12 +320,12 @@ void QtHighlightEditor::ruleToDialog(const HighlightRule& rule)
std::vector<std::string> senders = rule.getSenders();
if (senders.empty()) {
ui_.checkBox_3->setChecked(false);
- ui_.lineEdit->setEnabled(false);
- ui_.lineEdit->setText("");
+ jid_->setEnabled(false);
+ jid_->setText("");
} else {
ui_.checkBox_3->setChecked(true);
- ui_.lineEdit->setEnabled(true);
- ui_.lineEdit->setText(P2QSTRING(senders[0]));
+ jid_->setEnabled(true);
+ jid_->setText(P2QSTRING(senders[0]));
}
std::vector<std::string> keywords = rule.getKeywords();
diff --git a/Swift/QtUI/QtHighlightEditor.h b/Swift/QtUI/QtHighlightEditor.h
index 792adab..ebae432 100644
--- a/Swift/QtUI/QtHighlightEditor.h
+++ b/Swift/QtUI/QtHighlightEditor.h
@@ -19,6 +19,7 @@
namespace Swift {
class QtSettingsProvider;
+ class QtSuggestingJIDInput;
class QtHighlightEditor : public QWidget, public HighlightEditorWindow {
Q_OBJECT
@@ -54,6 +55,7 @@ namespace Swift {
Ui::QtHighlightEditor ui_;
QtSettingsProvider* settings_;
HighlightManager* highlightManager_;
+ QtSuggestingJIDInput* jid_;
};
}