#include "clientignorelistmanager.h"
+#include <QRegExp>
+
INIT_SYNCABLE_OBJECT(ClientIgnoreListManager)
ClientIgnoreListManager::ClientIgnoreListManager(QObject *parent)
: IgnoreListManager(parent)
{
- connect(this, SIGNAL(updated()), SIGNAL(ignoreListChanged()));
+ connect(this, SIGNAL(updatedRemotely()), SIGNAL(ignoreListChanged()));
+}
+
+bool ClientIgnoreListManager::pureMatch(const IgnoreListItem &item, const QString &string) const {
+ QRegExp ruleRx = QRegExp(item.ignoreRule);
+ ruleRx.setCaseSensitivity(Qt::CaseInsensitive);
+ if(!item.isRegEx)
+ ruleRx.setPatternSyntax(QRegExp::Wildcard);
+
+ if((!item.isRegEx && ruleRx.exactMatch(string)) ||
+ (item.isRegEx && ruleRx.indexIn(string) != -1))
+ return true;
+ return false;
+}
+
+QMap<QString, bool> ClientIgnoreListManager::matchingRulesForHostmask(const QString &hostmask, const QString &network, const QString &channel) const {
+ QMap<QString, bool> result;
+ foreach(IgnoreListItem item, ignoreList()) {
+ if(item.type == SenderIgnore && pureMatch(item, hostmask)
+ && ((network.isEmpty() && channel.isEmpty()) || item.scope == GlobalScope || (item.scope == NetworkScope && scopeMatch(item.scopeRule, network))
+ || (item.scope == ChannelScope && scopeMatch(item.scopeRule, channel)))) {
+ result[item.ignoreRule] = item.isActive;
+// qDebug() << "matchingRulesForHostmask found: " << item.ignoreRule << "is active: " << item.isActive;
+ }
+
+ }
+ return result;
}
#define CLIENTIGNORELISTMANAGER_H
#include "ignorelistmanager.h"
+#include <QMap>
class ClientIgnoreListManager : public IgnoreListManager
{
explicit ClientIgnoreListManager(QObject *parent = 0);
inline virtual const QMetaObject *syncMetaObject() const { return &IgnoreListManager::staticMetaObject; }
+ //! Fetch all matching ignore rules for a given hostmask
+ /** \param hostmask The hostmask of the user
+ * \param network The network name
+ * \param channel The channel name
+ * \return Returns a QMap with the rule as key and a bool, representing if the rule is enabled or not, as value
+ */
+ QMap<QString, bool> matchingRulesForHostmask(const QString &hostmask, const QString &network, const QString &channel) const;
+
signals:
void ignoreListChanged();
+
+private:
+ // matches an ignore rule against a given string
+ bool pureMatch(const IgnoreListItem &item, const QString &string) const;
};
#endif // CLIENTIGNORELISTMANAGER_H
}
}
+/* since overloaded methods aren't syncable (yet?) we can't use that anymore
void IgnoreListManager::addIgnoreListItem(const IgnoreListItem &item) {
addIgnoreListItem(item.type, item.ignoreRule, item.isRegEx, item.strictness, item.scope, item.scopeRule, item.isActive);
}
-
-void IgnoreListManager::addIgnoreListItem(IgnoreType type, const QString &ignoreRule, bool isRegEx, StrictnessType strictness,
- ScopeType scope, const QString &scopeRule, bool isActive) {
+*/
+void IgnoreListManager::addIgnoreListItem(int type, const QString &ignoreRule, bool isRegEx, int strictness,
+ int scope, const QString &scopeRule, bool isActive) {
if(contains(ignoreRule)) {
return;
}
- _ignoreList << IgnoreListItem(type, ignoreRule, isRegEx, strictness, scope, scopeRule, isActive);
+ IgnoreListItem newItem = IgnoreListItem(static_cast<IgnoreType>(type), ignoreRule, isRegEx, static_cast<StrictnessType>(strictness),
+ static_cast<ScopeType>(scope), scopeRule, isActive);
+ _ignoreList << newItem;
- emit ignoreAdded(type, ignoreRule, isRegEx, strictness, scope, scopeRule, isActive);
+ SYNC(ARG(type), ARG(ignoreRule), ARG(isRegEx), ARG(strictness), ARG(scope), ARG(scopeRule), ARG(isActive))
}
IgnoreListManager::StrictnessType IgnoreListManager::match(const Message &msg, const QString &network) {
return UnmatchedStrictness;
}
-bool IgnoreListManager::scopeMatch(const QString &scopeRule, const QString &string) {
+bool IgnoreListManager::scopeMatch(const QString &scopeRule, const QString &string) const {
foreach(QString rule, scopeRule.split(";")) {
QRegExp ruleRx = QRegExp(rule.trimmed());
ruleRx.setCaseSensitivity(Qt::CaseInsensitive);
}
return false;
}
+
+void IgnoreListManager::removeIgnoreListItem(const QString &ignoreRule) {
+ removeAt(indexOf(ignoreRule));
+ SYNC(ARG(ignoreRule))
+}
+
+void IgnoreListManager::toggleIgnoreRule(const QString &ignoreRule) {
+ int idx = indexOf(ignoreRule);
+ if(idx == -1)
+ return;
+ _ignoreList[idx].isActive = !_ignoreList[idx].isActive;
+ SYNC(ARG(ignoreRule))
+}
*/
StrictnessType match(const Message &msg, const QString &network = QString());
- virtual void addIgnoreListItem(IgnoreType type, const QString &ignoreRule, bool isRegEx, StrictnessType strictness,
- ScopeType scope, const QString &scopeRule, bool isActive);
- virtual void addIgnoreListItem(const IgnoreListItem &item);
+
+// virtual void addIgnoreListItem(const IgnoreListItem &item);
public slots:
virtual QVariantMap initIgnoreList() const;
virtual void initSetIgnoreList(const QVariantMap &ignoreList);
+ //! Request removal of an ignore rule based on the rule itself.
+ /** Use this method if you want to remove a single ignore rule
+ * and get that synced with the core immediately.
+ * \param ignoreRule A valid ignore rule
+ */
+ virtual inline void requestRemoveIgnoreListItem(const QString &ignoreRule) { REQUEST(ARG(ignoreRule)) }
+ virtual void removeIgnoreListItem(const QString &ignoreRule);
+
+ //! Request toggling of "isActive" flag of a given ignore rule.
+ /** Use this method if you want to toggle the "isActive" flag of a single ignore rule
+ * and get that synced with the core immediately.
+ * \param ignoreRule A valid ignore rule
+ */
+ virtual inline void requestToggleIgnoreRule(const QString &ignoreRule) { REQUEST(ARG(ignoreRule)) }
+ virtual void toggleIgnoreRule(const QString &ignoreRule);
+
+ //! Request an IgnoreListItem to be added to the ignore list
+ /** Items added to the list with this method, get immediately synced with the core
+ * \param type The IgnoreType of the new rule
+ * \param ignoreRule The rule itself
+ * \param isRegEx Signals if the rule should be interpreted as a regular expression
+ * \param strictness Th StrictnessType that should be applied
+ * \param scope The ScopeType that should be set
+ * \param scopeRule A string of semi-colon separated network- or channelnames
+ * \param isActive Signals if the rule is enabled or not
+ */
+ virtual inline void requestAddIgnoreListItem(int type, const QString &ignoreRule, bool isRegEx, int strictness,
+ int scope, const QString &scopeRule, bool isActive) {
+ REQUEST(ARG(type), ARG(ignoreRule), ARG(isRegEx), ARG(strictness), ARG(scope), ARG(scopeRule), ARG(isActive))
+ }
+ virtual void addIgnoreListItem(int type, const QString &ignoreRule, bool isRegEx, int strictness,
+ int scope, const QString &scopeRule, bool isActive);
+
protected:
void setIgnoreList(const QList<IgnoreListItem> &ignoreList) { _ignoreList = ignoreList; }
+ // scopeRule is a ; separated list, string is a network/channel-name
+ bool scopeMatch(const QString &scopeRule, const QString &string) const;
signals:
void ignoreAdded(IgnoreType type, const QString &ignoreRule, bool isRegex, StrictnessType strictness, ScopeType scope, const QVariant &scopeRule, bool isActive);
private:
- // scopeRule is a ; separated list, string is a network/channel-name
- bool scopeMatch(const QString &scopeRule, const QString &string);
IgnoreList _ignoreList;
};
inline virtual const QMetaObject *syncMetaObject() const { return &IgnoreListManager::staticMetaObject; }
+public slots:
+ virtual inline void requestToggleIgnoreRule(const QString &ignoreRule) { toggleIgnoreRule(ignoreRule); }
+ virtual inline void requestRemoveIgnoreListItem(const QString &ignoreRule) { removeIgnoreListItem(ignoreRule); }
+ virtual inline void requestAddIgnoreListItem(int type, const QString &ignoreRule, bool isRegEx, int strictness,
+ int scope, const QString &scopeRule, bool isActive) {
+ addIgnoreListItem(type, ignoreRule, isRegEx, strictness, scope, scopeRule, isActive);
+ }
+
//private:
// void loadDefaults();
connect(Client::messageModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)),
SLOT(messagesInserted(const QModelIndex &, int, int)));
connect(GraphicalUi::contextMenuActionProvider(), SIGNAL(showChannelList(NetworkId)), SLOT(showChannelList(NetworkId)));
+ connect(GraphicalUi::contextMenuActionProvider(), SIGNAL(showIgnoreList(QString)), SLOT(showIgnoreList(QString)));
// Setup Dock Areas
setDockNestingEnabled(true);
channelListDlg->show();
}
+void MainWin::showIgnoreList(QString newRule) {
+ SettingsPageDlg dlg(new IgnoreListSettingsPage(this), this);
+ // prepare config dialog for new rule
+ if(!newRule.isEmpty())
+ qobject_cast<IgnoreListSettingsPage *>(dlg.currentPage())->editIgnoreRule(newRule);
+ dlg.exec();
+}
+
void MainWin::showCoreInfoDlg() {
CoreInfoDlg(this).exec();
}
void showAwayLog();
void showSettingsDlg();
void showNotificationsDlg();
+ void showIgnoreList(QString newRule = QString());
#ifdef HAVE_KDE
void showShortcutsDlg();
#endif
if(manager.contains(item.ignoreRule))
return false;
beginInsertRows(QModelIndex(), rowCount(), rowCount());
- manager.addIgnoreListItem(item);
+ // manager.addIgnoreListItem(item);
+ manager.addIgnoreListItem(item.type, item.ignoreRule, item.isRegEx, item.strictness, item.scope,
+ item.scopeRule, item.isActive);
endInsertRows();
return true;
}
cloneIgnoreListManager()[row] = item;
emit dataChanged(createIndex(row, 0), createIndex(row, 2));
}
+
+const QModelIndex IgnoreListModel::indexOf(const QString &rule) {
+ return createIndex(ignoreListManager().indexOf(rule), 2);
+}
const IgnoreListManager::IgnoreListItem &ignoreListItemAt(int row) const;
void setIgnoreListItemAt(int row, const IgnoreListManager::IgnoreListItem &item);
bool newIgnoreRule(const IgnoreListManager::IgnoreListItem &item);
+ const QModelIndex indexOf(const QString &rule);
public slots:
void loadDefaults();
#include <QMessageBox>
#include <QString>
#include <QEvent>
-
+#include <QDebug>
#include "iconloader.h"
IgnoreListSettingsPage::IgnoreListSettingsPage(QWidget *parent)
void IgnoreListSettingsPage::load() {
if(_ignoreListModel.configChanged())
_ignoreListModel.revert();
+ ui.ignoreListView->selectionModel()->reset();
+ ui.editIgnoreRuleButton->setEnabled(false);
}
void IgnoreListSettingsPage::defaults() {
_ignoreListModel.commit();
}
ui.ignoreListView->selectionModel()->reset();
+ ui.editIgnoreRuleButton->setEnabled(false);
}
void IgnoreListSettingsPage::enableDialog(bool enabled) {
_ignoreListModel.removeIgnoreRule(ui.ignoreListView->selectionModel()->selectedIndexes()[0].row());
}
-void IgnoreListSettingsPage::newIgnoreRule() {
- IgnoreListEditDlg *dlg = new IgnoreListEditDlg(-1, IgnoreListManager::IgnoreListItem(), this);
+void IgnoreListSettingsPage::newIgnoreRule(QString rule) {
+ IgnoreListManager::IgnoreListItem newItem = IgnoreListManager::IgnoreListItem();
+ newItem.isActive = true;
+ bool enableOkButton = false;
+ if(!rule.isEmpty()) {
+ // we're called from contextmenu
+ newItem.ignoreRule = rule;
+ enableOkButton = true;
+ }
+
+ IgnoreListEditDlg *dlg = new IgnoreListEditDlg(newItem, this, enableOkButton);
+ dlg->enableOkButton(enableOkButton);
while(dlg->exec() == QDialog::Accepted) {
if(!_ignoreListModel.newIgnoreRule(dlg->ignoreListItem())) {
IgnoreListManager::IgnoreListItem item = dlg->ignoreListItem();
delete dlg;
- dlg = new IgnoreListEditDlg(-1, item, this);
+ dlg = new IgnoreListEditDlg(item, this);
}
else {
break;
if(!ui.ignoreListView->selectionModel()->hasSelection())
return;
int row = ui.ignoreListView->selectionModel()->selectedIndexes()[0].row();
- IgnoreListEditDlg dlg(row, _ignoreListModel.ignoreListItemAt(row), this);
+ IgnoreListEditDlg dlg(_ignoreListModel.ignoreListItemAt(row), this);
dlg.setAttribute(Qt::WA_DeleteOnClose, false);
if(dlg.exec() == QDialog::Accepted) {
_ignoreListModel.setIgnoreListItemAt(row, dlg.ignoreListItem());
}
}
+void IgnoreListSettingsPage::editIgnoreRule(const QString &ignoreRule) {
+ ui.ignoreListView->selectionModel()->select(_ignoreListModel.indexOf(ignoreRule), QItemSelectionModel::Select);
+ if(ui.ignoreListView->selectionModel()->hasSelection())// && ui.ignoreListView->selectionModel()->selectedIndexes()[0].row() != -1)
+ editSelectedIgnoreRule();
+ else
+ newIgnoreRule(ignoreRule);
+}
+
+/*
+ IgnoreListDelegate
+*/
void IgnoreListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {
if(index.column() == 0) {
QStyle *style = QApplication::style();
QStyledItemDelegate::paint(painter, option, index);
}
-IgnoreListEditDlg::IgnoreListEditDlg(int row, const IgnoreListManager::IgnoreListItem &item, QWidget *parent)
- : QDialog(parent), _selectedRow(row), _ignoreListItem(item), _hasChanged(false) {
+// provide interactivity for the checkboxes
+bool IgnoreListDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
+ const QStyleOptionViewItem &option, const QModelIndex &index) {
+ Q_UNUSED(option)
+ switch(event->type()) {
+ case QEvent::MouseButtonRelease:
+ model->setData(index, !index.data().toBool());
+ return true;
+ // don't show the default editor for the column
+ case QEvent::MouseButtonDblClick:
+ return true;
+ default:
+ return false;
+ }
+}
+
+/*
+ IgnoreListEditDlg
+*/
+IgnoreListEditDlg::IgnoreListEditDlg(const IgnoreListManager::IgnoreListItem &item, QWidget *parent, bool enabled)
+ : QDialog(parent), _ignoreListItem(item), _hasChanged(enabled) {
ui.setupUi(this);
setAttribute(Qt::WA_DeleteOnClose, false);
setModal(true);
ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(_hasChanged);
}
-// provide interactivity for the checkboxes
-bool IgnoreListDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
- const QStyleOptionViewItem &option, const QModelIndex &index) {
- Q_UNUSED(option)
- switch(event->type()) {
- case QEvent::MouseButtonRelease:
- model->setData(index, !index.data().toBool());
- return true;
- // don't show the default editor for the column
- case QEvent::MouseButtonDblClick:
- return true;
- default:
- return false;
- }
+void IgnoreListEditDlg::enableOkButton(bool state) {
+ ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(state);
}
Q_OBJECT
public:
- IgnoreListEditDlg(int row, const IgnoreListManager::IgnoreListItem &item, QWidget *parent = 0);
+ IgnoreListEditDlg(const IgnoreListManager::IgnoreListItem &item, QWidget *parent = 0, bool enabled = false);
inline IgnoreListManager::IgnoreListItem ignoreListItem() { return _ignoreListItem; }
+ void enableOkButton(bool state);
private slots:
void widgetHasChanged();
void aboutToAccept() { _ignoreListItem = _clonedIgnoreListItem; }
+
private:
- int _selectedRow;
IgnoreListManager::IgnoreListItem _ignoreListItem;
IgnoreListManager::IgnoreListItem _clonedIgnoreListItem;
bool _hasChanged;
public:
IgnoreListSettingsPage(QWidget *parent = 0);
~IgnoreListSettingsPage();
- virtual inline bool hasDefaults() const { return true; }
+ virtual inline bool hasDefaults() const { return false; }
+ void editIgnoreRule(const QString &ignoreRule);
public slots:
void save();
void load();
void defaults();
+ void newIgnoreRule(QString rule = QString());
private slots:
void enableDialog(bool);
void deleteSelectedIgnoreRule();
void editSelectedIgnoreRule();
- void newIgnoreRule();
void selectionChanged(const QItemSelection &selection, const QItemSelection &);
private:
#include <QInputDialog>
#include <QMenu>
#include <QMessageBox>
+#include <QMap>
#include "contextmenuactionprovider.h"
#include "clientidentity.h"
#include "network.h"
#include "util.h"
+#include "client.h"
+#include "clientignorelistmanager.h"
ContextMenuActionProvider::ContextMenuActionProvider(QObject *parent) : NetworkModelController(parent) {
registerAction(NetworkConnect, SmallIcon("network-connect"), tr("Connect"));
registerAction(NickCtcpTime, tr("Time"));
registerAction(NickCtcpPing, tr("Ping"));
registerAction(NickCtcpFinger, tr("Finger"));
+ registerAction(NickIgnoreCustom, tr("Custom..."));
+
+ // these texts are only dummies! don't think about tr() here!
+ registerAction(NickIgnoreUser, "*!ident@host.domain.tld");
+ registerAction(NickIgnoreHost, "*!*@host.domain.tld");
+ registerAction(NickIgnoreDomain, "*!ident@*.domain.tld");
+ registerAction(NickIgnoreToggleEnabled0, "Enable", true);
+ registerAction(NickIgnoreToggleEnabled1, "Enable", true);
+ registerAction(NickIgnoreToggleEnabled2, "Enable", true);
+ registerAction(NickIgnoreToggleEnabled3, "Enable", true);
+ registerAction(NickIgnoreToggleEnabled4, "Enable", true);
registerAction(NickOp, SmallIcon("irc-operator"), tr("Give Operator Status"));
registerAction(NickDeop, SmallIcon("irc-remove-operator"), tr("Take Operator Status"));
nickModeMenu->addAction(action(NickKickBan));
_nickModeMenuAction = new Action(tr("Actions"), 0);
_nickModeMenuAction->setMenu(nickModeMenu);
+
+ QMenu *ignoreMenu = new QMenu();
+ _nickIgnoreMenuAction = new Action(tr("Ignore"), 0);
+ _nickIgnoreMenuAction->setMenu(ignoreMenu);
}
ContextMenuActionProvider::~ContextMenuActionProvider() {
_nickCtcpMenuAction->deleteLater();
_nickModeMenuAction->menu()->deleteLater();
_nickModeMenuAction->deleteLater();
+ _nickIgnoreMenuAction->menu()->deleteLater();
+ _nickIgnoreMenuAction->deleteLater();
}
void ContextMenuActionProvider::addActions(QMenu *menu, BufferId bufId, QObject *receiver, const char *method) {
NetworkModel::ItemType itemType = static_cast<NetworkModel::ItemType>(index.data(NetworkModel::ItemTypeRole).toInt());
addAction(_nickModeMenuAction, menu, itemType == NetworkModel::IrcUserItemType);
addAction(_nickCtcpMenuAction, menu);
+
+ IrcUser *ircUser = qobject_cast<IrcUser *>(index.data(NetworkModel::IrcUserRole).value<QObject *>());
+ if(ircUser) {
+ // ignoreliststuff
+ QString bufferName;
+ BufferInfo bufferInfo = index.data(NetworkModel::BufferInfoRole).value<BufferInfo>();
+ if(bufferInfo.type() == BufferInfo::ChannelBuffer)
+ bufferName = bufferInfo.bufferName();
+ QMap<QString, bool> ignoreMap = Client::ignoreListManager()->matchingRulesForHostmask(ircUser->hostmask(), ircUser->network()->networkName(), bufferName);
+ addIgnoreMenu(menu, ircUser->hostmask(), ignoreMap);
+ // end of ignoreliststuff
+ }
menu->addSeparator();
addAction(NickQuery, menu, itemType == NetworkModel::IrcUserItemType && !haveQuery && indexList().count() == 1);
addAction(NickSwitchTo, menu, itemType == NetworkModel::IrcUserItemType && haveQuery);
menu->addAction(_hideEventsMenuAction);
}
+
+void ContextMenuActionProvider::addIgnoreMenu(QMenu *menu, const QString &hostmask, const QMap<QString, bool> &ignoreMap) {
+ QMenu *ignoreMenu = _nickIgnoreMenuAction->menu();
+ ignoreMenu->clear();
+ QString nick = nickFromMask(hostmask);
+ QString ident = userFromMask(hostmask);
+ QString host = hostFromMask(hostmask);
+ QString domain = host;
+ QRegExp domainRx = QRegExp("(\\.[^.]+\\.\\w+)$");
+ if(domainRx.indexIn(host) != -1)
+ domain = domainRx.cap(1);
+ // we can't rely on who-data
+ // if we don't have the data, we skip actions where we would need it
+ bool haveWhoData = !ident.isEmpty() && !host.isEmpty();
+
+
+ ignoreMenu->addAction(tr("Add Ignore Rule"))->setEnabled(false);
+
+ if(haveWhoData) {
+ action(NickIgnoreUser)->setText(QString("*!%1@%2").arg(ident, host));
+ action(NickIgnoreHost)->setText(QString("*!*@%1").arg(host));
+ action(NickIgnoreDomain)->setText(domain.at(0) == '.' ? QString("*!%1@*%2").arg(ident, domain)
+ : QString("*!%1@%2").arg(ident, domain));
+
+ if(!ignoreMap.contains(action(NickIgnoreUser)->text()))
+ ignoreMenu->addAction(action(NickIgnoreUser));
+ if(!ignoreMap.contains(action(NickIgnoreHost)->text()))
+ ignoreMenu->addAction(action(NickIgnoreHost));
+ if(!ignoreMap.contains(action(NickIgnoreDomain)->text()))
+ ignoreMenu->addAction(action(NickIgnoreDomain));
+ }
+ ignoreMenu->addAction(action(NickIgnoreCustom));
+ ignoreMenu->addSeparator();
+
+ if(haveWhoData) {
+ QMap<QString, bool>::const_iterator ruleIter = ignoreMap.begin();
+ int counter = 0;
+ if(!ignoreMap.isEmpty())
+ ignoreMenu->addAction(tr("Existing Rules"))->setEnabled(false);
+ while(ruleIter != ignoreMap.constEnd()) {
+ if(counter < 5) {
+ ActionType type = static_cast<ActionType>(NickIgnoreToggleEnabled0 + counter*0x100000);
+ Action *act = action(type);
+ act->setText(ruleIter.key());
+ act->setChecked(ruleIter.value());
+ ignoreMenu->addAction(act);
+ }
+ counter++;
+ ruleIter++;
+ }
+ if(counter)
+ ignoreMenu->addSeparator();
+ }
+ ignoreMenu->addAction(action(ShowIgnoreList));
+ addAction(_nickIgnoreMenuAction, menu);
+}
void addHideEventsMenu(QMenu *, BufferId bufferId);
void addHideEventsMenu(QMenu *, MessageFilter *msgFilter);
void addHideEventsMenu(QMenu *, int filter = -1);
+ void addIgnoreMenu(QMenu *menu, const QString &hostmask, const QMap<QString, bool> &ignoreMap);
void addNetworkItemActions(QMenu *, const QModelIndex &);
void addBufferItemActions(QMenu *, const QModelIndex &, bool isCustomBufferView = false);
Action *_hideEventsMenuAction;
Action *_nickCtcpMenuAction;
Action *_nickModeMenuAction;
+ Action *_nickIgnoreMenuAction;
};
#endif
#include "clientidentity.h"
#include "network.h"
#include "util.h"
+#include "clientignorelistmanager.h"
+#include "client.h"
NetworkModelController::NetworkModelController(QObject *parent)
: QObject(parent),
break;
case ShowIgnoreList:
if(networkId.isValid())
- emit showIgnoreList(networkId);
+ emit showIgnoreList(QString());
break;
default:
break;
}
}
-void NetworkModelController::handleNickAction(ActionType type, QAction *) {
+void NetworkModelController::handleNickAction(ActionType type, QAction *action) {
foreach(QModelIndex index, indexList()) {
NetworkId networkId = index.data(NetworkModel::NetworkIdRole).value<NetworkId>();
if(!networkId.isValid())
if(!bufferInfo.isValid())
continue;
+ // the validity of that cast is checked on contextmenu creation, take care
+ IrcUser *ircUser = qobject_cast<IrcUser *>(index.data(NetworkModel::IrcUserRole).value<QObject *>());
+
switch(type) {
case NickWhois:
Client::userInput(bufferInfo, QString("/WHOIS %1 %1").arg(nick));
case NickQuery:
Client::userInput(bufferInfo, QString("/QUERY %1").arg(nick));
break;
+ case NickIgnoreUser:
+ Client::ignoreListManager()->requestAddIgnoreListItem(IgnoreListManager::SenderIgnore,
+ action->text(),
+ false, IgnoreListManager::SoftStrictness,
+ IgnoreListManager::NetworkScope,
+ ircUser->network()->networkName(), true);
+ break;
+ case NickIgnoreHost:
+ Client::ignoreListManager()->requestAddIgnoreListItem(IgnoreListManager::SenderIgnore,
+ action->text(),
+ false, IgnoreListManager::SoftStrictness,
+ IgnoreListManager::NetworkScope,
+ ircUser->network()->networkName(), true);
+ break;
+ case NickIgnoreDomain:
+ Client::ignoreListManager()->requestAddIgnoreListItem(IgnoreListManager::SenderIgnore,
+ action->text(),
+ false, IgnoreListManager::SoftStrictness,
+ IgnoreListManager::NetworkScope,
+ ircUser->network()->networkName(), true);
+ break;
+ case NickIgnoreCustom:
+ // forward that to mainwin since we can access the settingspage only from there
+ emit showIgnoreList(ircUser->hostmask());
+ break;
+ case NickIgnoreToggleEnabled0:
+ case NickIgnoreToggleEnabled1:
+ case NickIgnoreToggleEnabled2:
+ case NickIgnoreToggleEnabled3:
+ case NickIgnoreToggleEnabled4:
+ Client::ignoreListManager()->requestToggleIgnoreRule(action->text());
+ break;
default:
qWarning() << "Unhandled nick action";
}
NickKick = 0x0c0000,
NickBan = 0x0d0000,
NickKickBan = 0x0e0000,
+ NickIgnoreUser = 0x0f0000,
+ NickIgnoreHost = 0x100000,
+ NickIgnoreDomain = 0x200000,
+ NickIgnoreCustom = 0x300000,
+ // The next 5 types have stay together
+ // Don't change without reading ContextMenuActionProvider::addIgnoreMenu!
+ NickIgnoreToggleEnabled0 = 0x400000,
+ NickIgnoreToggleEnabled1 = 0x500000,
+ NickIgnoreToggleEnabled2 = 0x600000,
+ NickIgnoreToggleEnabled3 = 0x700000,
+ NickIgnoreToggleEnabled4 = 0x800000,
// Actions that are handled externally
// These emit a signal to the action requester, rather than being handled here
signals:
void showChannelList(NetworkId);
- void showIgnoreList(NetworkId);
+ void showIgnoreList(QString);
protected:
virtual void handleNetworkAction(ActionType, QAction *);
virtual void handleBufferAction(ActionType, QAction *);
virtual void handleHideAction(ActionType, QAction *);
- virtual void handleNickAction(ActionType, QAction *);
+ virtual void handleNickAction(ActionType, QAction *action);
virtual void handleGeneralAction(ActionType, QAction *);
virtual void handleExternalAction(ActionType, QAction *);