From: Marcus Eggenberger Date: Thu, 24 Jul 2008 13:38:22 +0000 (+0200) Subject: improving the channel lists. errors are redirected to the channel widget and act... X-Git-Tag: 0.3.0~220 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=02455427bfd88584a81f94b1b234fe21ad3e09cd improving the channel lists. errors are redirected to the channel widget and act sanly when a server doesn't send a RPL_LISTEND --- diff --git a/src/common/irclisthelper.h b/src/common/irclisthelper.h index 0d8ad398..e62fda10 100644 --- a/src/common/irclisthelper.h +++ b/src/common/irclisthelper.h @@ -49,10 +49,12 @@ public slots: inline virtual QVariantList requestChannelList(const NetworkId &netId, const QStringList &channelFilters) { emit channelListRequested(netId, channelFilters); return QVariantList(); } inline virtual void receiveChannelList(const NetworkId &, const QStringList &, const QVariantList &) {}; inline virtual void reportFinishedList(const NetworkId &netId) { emit finishedListReported(netId); } + inline virtual void reportError(const QString &error) { emit errorReported(error); } signals: void channelListRequested(const NetworkId &netId, const QStringList &channelFilters); void finishedListReported(const NetworkId &netId); + void errorReported(const QString &error); }; #endif //IRCLISTHELPER_H diff --git a/src/core/coreirclisthelper.cpp b/src/core/coreirclisthelper.cpp index d8a317cd..dbcdcc4c 100644 --- a/src/core/coreirclisthelper.cpp +++ b/src/core/coreirclisthelper.cpp @@ -23,7 +23,6 @@ #include "networkconnection.h" #include "userinputhandler.h" - QVariantList CoreIrcListHelper::requestChannelList(const NetworkId &netId, const QStringList &channelFilters) { if(_finishedChannelLists.contains(netId)) return _finishedChannelLists.take(netId); @@ -31,13 +30,8 @@ QVariantList CoreIrcListHelper::requestChannelList(const NetworkId &netId, const if(_channelLists.contains(netId)) { _queuedQuery[netId] = channelFilters.join(","); } else { - _channelLists[netId] = QList(); - - NetworkConnection *networkConnection = coreSession()->networkConnection(netId); - if(networkConnection) - networkConnection->userInputHandler()->handleList(BufferInfo(), channelFilters.join(",")); + dispatchQuery(netId, channelFilters.join(",")); } - return QVariantList(); } @@ -49,17 +43,22 @@ bool CoreIrcListHelper::addChannel(const NetworkId &netId, const QString &channe return true; } +bool CoreIrcListHelper::dispatchQuery(const NetworkId &netId, const QString &query) { + NetworkConnection *networkConnection = coreSession()->networkConnection(netId); + if(networkConnection) { + _channelLists[netId] = QList(); + networkConnection->userInputHandler()->handleList(BufferInfo(), query); + _queryTimeout[startTimer(10000)] = netId; + return true; + } else { + return false; + } +} + bool CoreIrcListHelper::endOfChannelList(const NetworkId &netId) { if(_queuedQuery.contains(netId)) { // we're no longer interessted in the current data. drop it and issue a new request. - _channelLists[netId] = QList(); - - NetworkConnection *networkConnection = coreSession()->networkConnection(netId); - if(networkConnection) - networkConnection->userInputHandler()->handleList(BufferInfo(), _queuedQuery[netId]); - - _queuedQuery.remove(netId); - return true; + return dispatchQuery(netId, _queuedQuery.take(netId)); } else if(_channelLists.contains(netId)) { QVariantList channelList; foreach(ChannelDescription channel, _channelLists[netId]) { @@ -78,3 +77,9 @@ bool CoreIrcListHelper::endOfChannelList(const NetworkId &netId) { } } +void CoreIrcListHelper::timerEvent(QTimerEvent *event) { + int timerId = event->timerId(); + killTimer(timerId); + NetworkId netId = _queryTimeout.take(timerId); + endOfChannelList(netId); +} diff --git a/src/core/coreirclisthelper.h b/src/core/coreirclisthelper.h index 84303ad6..c42d6a08 100644 --- a/src/core/coreirclisthelper.h +++ b/src/core/coreirclisthelper.h @@ -25,6 +25,8 @@ #include "coresession.h" +class QTimerEvent; + class CoreIrcListHelper : public IrcListHelper { Q_OBJECT @@ -35,17 +37,26 @@ public: inline CoreSession *coreSession() const { return _coreSession; } + inline bool requestInProgress(const NetworkId &netId) const { return _channelLists.contains(netId); } + public slots: virtual QVariantList requestChannelList(const NetworkId &netId, const QStringList &channelFilters); bool addChannel(const NetworkId &netId, const QString &channelName, quint32 userCount, const QString &topic); bool endOfChannelList(const NetworkId &netId); +protected: + void timerEvent(QTimerEvent *event); + +private: + bool dispatchQuery(const NetworkId &netId, const QString &query); + private: CoreSession *_coreSession; QHash _queuedQuery; QHash > _channelLists; QHash _finishedChannelLists; + QHash _queryTimeout; }; #endif //COREIRCLISTHELPER_H diff --git a/src/core/ircserverhandler.cpp b/src/core/ircserverhandler.cpp index ae7736d9..ec3789db 100644 --- a/src/core/ircserverhandler.cpp +++ b/src/core/ircserverhandler.cpp @@ -153,7 +153,10 @@ void IrcServerHandler::defaultHandler(QString cmd, const QString &prefix, const // many nets define their own WHOIS fields. we fetch those not in need of special attention here: emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", "[Whois] " + params.join(" "), prefix); } else { - emit displayMsg(Message::Error, BufferInfo::StatusBuffer, "", cmd + " " + params.join(" "), prefix); + if(networkConnection()->coreSession()->ircListHelper()->requestInProgress(network()->networkId())) + networkConnection()->coreSession()->ircListHelper()->reportError(params.join(" ")); + else + emit displayMsg(Message::Error, BufferInfo::StatusBuffer, "", cmd + " " + params.join(" "), prefix); } } //qDebug() << prefix <<":"< +#include +#include ChannelListDlg::ChannelListDlg(QWidget *parent) : QDialog(parent), _listFinished(true), _ircListModel(this), - _sortFilter(this) + _sortFilter(this), + _simpleModeSpacer(0), + _advancedMode(false) { _sortFilter.setSourceModel(&_ircListModel); _sortFilter.setFilterCaseSensitivity(Qt::CaseInsensitive); @@ -47,19 +51,22 @@ ChannelListDlg::ChannelListDlg(QWidget *parent) ui.searchChannelsButton->setAutoDefault(false); + connect(ui.advancedModeLabel, SIGNAL(clicked()), this, SLOT(toggleMode())); connect(ui.searchChannelsButton, SIGNAL(clicked()), this, SLOT(requestSearch())); connect(ui.channelNameLineEdit, SIGNAL(returnPressed()), this, SLOT(requestSearch())); connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), &_sortFilter, SLOT(setFilterFixedString(QString))); connect(Client::ircListHelper(), SIGNAL(channelListReceived(const NetworkId &, const QStringList &, QList)), this, SLOT(receiveChannelList(NetworkId , QStringList, QList))); connect(Client::ircListHelper(), SIGNAL(finishedListReported(const NetworkId &)), this, SLOT(reportFinishedList())); + connect(Client::ircListHelper(), SIGNAL(errorReported(const QString &)), this, SLOT(showError(const QString &))); connect(ui.channelListView, SIGNAL(activated(QModelIndex)), this, SLOT(joinChannel(QModelIndex))); + setAdvancedMode(false); enableQuery(true); showFilterLine(false); + showErrors(false); } - void ChannelListDlg::setNetwork(NetworkId netId) { if(_netId == netId) return; @@ -72,6 +79,7 @@ void ChannelListDlg::setNetwork(NetworkId netId) { void ChannelListDlg::requestSearch() { _listFinished = false; enableQuery(false); + showErrors(false); QStringList channelFilters; channelFilters << ui.channelNameLineEdit->text().trimmed(); Client::ircListHelper()->requestChannelList(_netId, channelFilters); @@ -97,10 +105,45 @@ void ChannelListDlg::enableQuery(bool enable) { ui.searchChannelsButton->setEnabled(enable); } +void ChannelListDlg::setAdvancedMode(bool advanced) { + _advancedMode = advanced; + if(advanced) { + if(_simpleModeSpacer) { + ui.searchLayout->removeItem(_simpleModeSpacer); + delete _simpleModeSpacer; + _simpleModeSpacer = 0; + } + ui.advancedModeLabel->setPixmap(QPixmap(QString::fromUtf8(":/22x22/actions/oxygen/22x22/actions/edit-clear-locationbar-rtl.png"))); + } else { + if(!_simpleModeSpacer) { + _simpleModeSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + ui.searchLayout->insertSpacerItem(0, _simpleModeSpacer); + } + ui.advancedModeLabel->setPixmap(QPixmap(QString::fromUtf8(":/22x22/actions/oxygen/22x22/actions/edit-clear.png"))); + } + ui.channelNameLineEdit->clear(); + ui.channelNameLineEdit->setVisible(advanced); + ui.searchPatternLabel->setVisible(advanced); +} + +void ChannelListDlg::showErrors(bool show) { + if(!show) { + ui.errorTextEdit->clear(); + } + ui.errorLabel->setVisible(show); + ui.errorTextEdit->setVisible(show); +} + + void ChannelListDlg::reportFinishedList() { _listFinished = true; } +void ChannelListDlg::showError(const QString &error) { + showErrors(true); + ui.errorTextEdit->moveCursor(QTextCursor::End); + ui.errorTextEdit->insertPlainText(error + "\n"); +} void ChannelListDlg::joinChannel(const QModelIndex &index) { Client::instance()->userInput(BufferInfo::fakeStatusBuffer(_netId), QString("/JOIN %1").arg(index.sibling(index.row(), 0).data().toString())); diff --git a/src/qtui/channellistdlg.h b/src/qtui/channellistdlg.h index 84e5b7ad..dddd88e5 100644 --- a/src/qtui/channellistdlg.h +++ b/src/qtui/channellistdlg.h @@ -29,6 +29,8 @@ #include +class QSpacerItem; + class ChannelListDlg : public QDialog { Q_OBJECT @@ -42,10 +44,16 @@ protected slots: void receiveChannelList(const NetworkId &netId, const QStringList &channelFilters, const QList &channelList); void reportFinishedList(); void joinChannel(const QModelIndex &); - + +private slots: + inline void toggleMode() { setAdvancedMode(!_advancedMode); } + void showError(const QString &error); + private: void showFilterLine(bool show); + void showErrors(bool show); void enableQuery(bool enable); + void setAdvancedMode(bool advanced); Ui::ChannelListDlg ui; @@ -53,6 +61,8 @@ private: NetworkId _netId; IrcListModel _ircListModel; QSortFilterProxyModel _sortFilter; + QSpacerItem *_simpleModeSpacer; + bool _advancedMode; }; #endif //CHANNELLIST_H diff --git a/src/qtui/ui/channellistdlg.ui b/src/qtui/ui/channellistdlg.ui index 70c3c211..8b12aeff 100644 --- a/src/qtui/ui/channellistdlg.ui +++ b/src/qtui/ui/channellistdlg.ui @@ -5,8 +5,8 @@ 0 0 - 454 - 406 + 566 + 580 @@ -24,7 +24,7 @@ 0 - + 6 @@ -32,7 +32,7 @@ 6 - + Search Pattern: @@ -41,10 +41,24 @@ + + + + Toggle between simple and advanced mode. +Advanced mode allows to pass search strings to the IRC Server. + + + + + + :/22x22/actions/oxygen/22x22/actions/edit-clear-locationbar-rtl.png + + + - Search Channels + Show Channels @@ -78,10 +92,70 @@ - + + + Errors Occured: + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 100 + + + + false + + + false + + + true + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">SUPER EVIL CATASTROPHIC ERROR!!11</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p></body></html> + + + + + + + + 0 + 0 + + + + + + ClickableLabel + QLabel +
clickablelabel.h
+
+