summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorRichard Maudsley <richard.maudsley@isode.com>2014-01-17 11:18:40 (GMT)
committerRichard Maudsley <richard.maudsley@isode.com>2014-01-17 11:18:40 (GMT)
commit3965c1874cf6d141b3575eae4078cd57628515a4 (patch)
tree5dbb0cf1f8f741e1c82c06f6d55ec86b5867cd97 /Swift
parent1d3d73e81fa08a588036bbd1b9c896f9eefd7644 (diff)
downloadswift-3965c1874cf6d141b3575eae4078cd57628515a4.zip
swift-3965c1874cf6d141b3575eae4078cd57628515a4.tar.bz2
Improved natural language rule display.
Change-Id: I1d47a33baac4f8dd0789c61a56f7a2fa8128d925
Diffstat (limited to 'Swift')
-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_;
};
}