- switch(role) {
- case Qt::ToolTipRole:
- switch(index.column()) {
- /*
- case 0: return "<b>Type:</b><br />"
- "<i><u>BySender:</u></i><br />"
- "The ignore rule is matched against the <i>nick!ident@host.mask</i> sender-string.<br />"
- "<i><u>ByMessage:</u></i><br />"
- "The ignore rule is matched against the message content.";
- case 1:
- return "<b>Strictness:</b><br />"
- "<i><u>Dynamic:</u></i><br />"
- "Messages are hidden but still get stored in the database.<br />Deactivate or delete an ignore rule to show the messages again<br />"
- "<i><u>Permanent:</u></i><br />"
- "Messages are never stored or shown anywhere.";
- */
- case 0:
- return tr("<b>Enable / Disable:</b><br />"
- "Only enabled rules are filtered.<br />"
- "For dynamic rules, disabling actually shows the filtered messages again");
- case 2:
- return tr("<b>Ignore rule:</b><br />"
- "Depending on the type of the rule, the text is matched against either:<br /><br />"
- "- <u>the message content:</u><br />"
- "<i>Example:<i><br />"
- " \"*foobar*\" matches any text containing the word \"foobar\"<br /><br />"
- "- <u>the sender string <i>nick!ident@host.name<i></u><br />"
- "<i>Example:</i><br />"
- " \"*@foobar.com\" matches any sender from host foobar.com<br />"
- " \"stupid!.+\" (RegEx) matches any sender with nickname \"stupid\" from any host<br />");
+QVariant IgnoreListModel::data(const QModelIndex &index, int role) const
+{
+ if (!_modelReady)
+ return QVariant();
+
+ if (!index.isValid() || index.row() >= rowCount() || index.column() >= columnCount())
+ return QVariant();
+
+ switch (role) {
+ case Qt::ToolTipRole:
+ switch (index.column()) {
+ /*
+ case 0: return "<b>Type:</b><br />"
+ "<i><u>BySender:</u></i><br />"
+ "The ignore rule is matched against the <i>nick!ident@host.mask</i> sender-string.<br />"
+ "<i><u>ByMessage:</u></i><br />"
+ "The ignore rule is matched against the message content.";
+ case 1:
+ return "<b>Strictness:</b><br />"
+ "<i><u>Dynamic:</u></i><br />"
+ "Messages are hidden but still get stored in the database.<br />Deactivate or delete an ignore rule to show the messages again<br />"
+ "<i><u>Permanent:</u></i><br />"
+ "Messages are never stored or shown anywhere.";
+ */
+ case 0:
+ return tr("<b>Enable / Disable:</b><br />"
+ "Only enabled rules are filtered.<br />"
+ "For dynamic rules, disabling actually shows the filtered messages again");
+ case 2:
+ return tr("<b>Ignore rule:</b><br />"
+ "Depending on the type of the rule, the text is matched against either:<br /><br />"
+ "- <u>the message content:</u><br />"
+ "<i>Example:<i><br />"
+ " \"*foobar*\" matches any text containing the word \"foobar\"<br /><br />"
+ "- <u>the sender string <i>nick!ident@host.name<i></u><br />"
+ "<i>Example:</i><br />"
+ " \"*@foobar.com\" matches any sender from host foobar.com<br />"
+ " \"stupid!.+\" (RegEx) matches any sender with nickname \"stupid\" from any host<br />");
+ default:
+ return QVariant();
+ }
+ case Qt::DisplayRole:
+ switch (index.column()) {
+ case 1:
+ if (ignoreListManager()[index.row()].type == IgnoreListManager::SenderIgnore)
+ return tr("By Sender");
+ else
+ return tr("By Message");
+ }
+ case Qt::EditRole:
+ switch (index.column()) {
+ case 0:
+ return ignoreListManager()[index.row()].isActive;
+ case 1:
+ return ignoreListManager()[index.row()].type;
+ case 2:
+ return ignoreListManager()[index.row()].ignoreRule;
+ default:
+ return QVariant();
+ }