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
#include "networkconnection.h"
#include "userinputhandler.h"
-
QVariantList CoreIrcListHelper::requestChannelList(const NetworkId &netId, const QStringList &channelFilters) {
if(_finishedChannelLists.contains(netId))
return _finishedChannelLists.take(netId);
if(_channelLists.contains(netId)) {
_queuedQuery[netId] = channelFilters.join(",");
} else {
- _channelLists[netId] = QList<ChannelDescription>();
-
- NetworkConnection *networkConnection = coreSession()->networkConnection(netId);
- if(networkConnection)
- networkConnection->userInputHandler()->handleList(BufferInfo(), channelFilters.join(","));
+ dispatchQuery(netId, channelFilters.join(","));
}
-
return QVariantList();
}
return true;
}
+bool CoreIrcListHelper::dispatchQuery(const NetworkId &netId, const QString &query) {
+ NetworkConnection *networkConnection = coreSession()->networkConnection(netId);
+ if(networkConnection) {
+ _channelLists[netId] = QList<ChannelDescription>();
+ 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<ChannelDescription>();
-
- 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]) {
}
}
+void CoreIrcListHelper::timerEvent(QTimerEvent *event) {
+ int timerId = event->timerId();
+ killTimer(timerId);
+ NetworkId netId = _queryTimeout.take(timerId);
+ endOfChannelList(netId);
+}
#include "coresession.h"
+class QTimerEvent;
+
class CoreIrcListHelper : public IrcListHelper {
Q_OBJECT
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<NetworkId, QString> _queuedQuery;
QHash<NetworkId, QList<ChannelDescription> > _channelLists;
QHash<NetworkId, QVariantList> _finishedChannelLists;
+ QHash<int, NetworkId> _queryTimeout;
};
#endif //COREIRCLISTHELPER_H
// 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 <<":"<<cmd<<params;
#include "clientirclisthelper.h"
#include <QHeaderView>
+#include <QHBoxLayout>
+#include <QSpacerItem>
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);
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<IrcListHelper::ChannelDescription>)),
this, SLOT(receiveChannelList(NetworkId , QStringList, QList<IrcListHelper::ChannelDescription>)));
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;
void ChannelListDlg::requestSearch() {
_listFinished = false;
enableQuery(false);
+ showErrors(false);
QStringList channelFilters;
channelFilters << ui.channelNameLineEdit->text().trimmed();
Client::ircListHelper()->requestChannelList(_netId, channelFilters);
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()));
#include <QSortFilterProxyModel>
+class QSpacerItem;
+
class ChannelListDlg : public QDialog {
Q_OBJECT
void receiveChannelList(const NetworkId &netId, const QStringList &channelFilters, const QList<IrcListHelper::ChannelDescription> &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;
NetworkId _netId;
IrcListModel _ircListModel;
QSortFilterProxyModel _sortFilter;
+ QSpacerItem *_simpleModeSpacer;
+ bool _advancedMode;
};
#endif //CHANNELLIST_H
<rect>
<x>0</x>
<y>0</y>
- <width>454</width>
- <height>406</height>
+ <width>566</width>
+ <height>580</height>
</rect>
</property>
<property name="windowTitle" >
<number>0</number>
</property>
<item>
- <layout class="QHBoxLayout" name="horizontalLayout" >
+ <layout class="QHBoxLayout" name="searchLayout" >
<property name="spacing" >
<number>6</number>
</property>
<number>6</number>
</property>
<item>
- <widget class="QLabel" name="label" >
+ <widget class="QLabel" name="searchPatternLabel" >
<property name="text" >
<string>Search Pattern:</string>
</property>
<item>
<widget class="QLineEdit" name="channelNameLineEdit" />
</item>
+ <item>
+ <widget class="ClickableLabel" name="advancedModeLabel" >
+ <property name="toolTip" >
+ <string>Toggle between simple and advanced mode.
+Advanced mode allows to pass search strings to the IRC Server.</string>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="pixmap" >
+ <pixmap resource="../../icons/icons.qrc" >:/22x22/actions/oxygen/22x22/actions/edit-clear-locationbar-rtl.png</pixmap>
+ </property>
+ </widget>
+ </item>
<item>
<widget class="QPushButton" name="searchChannelsButton" >
<property name="text" >
- <string>Search Channels</string>
+ <string>Show Channels</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
- <widget class="QTableView" name="channelListView" />
+ <widget class="QLabel" name="errorLabel" >
+ <property name="text" >
+ <string>Errors Occured:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTextEdit" name="errorTextEdit" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize" >
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize" >
+ <size>
+ <width>16777215</width>
+ <height>100</height>
+ </size>
+ </property>
+ <property name="acceptDrops" >
+ <bool>false</bool>
+ </property>
+ <property name="undoRedoEnabled" >
+ <bool>false</bool>
+ </property>
+ <property name="readOnly" >
+ <bool>true</bool>
+ </property>
+ <property name="html" >
+ <string><!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></string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTableView" name="channelListView" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
</item>
</layout>
</widget>
+ <customwidgets>
+ <customwidget>
+ <class>ClickableLabel</class>
+ <extends>QLabel</extends>
+ <header location="global" >clickablelabel.h</header>
+ </customwidget>
+ </customwidgets>
<resources>
<include location="../../icons/icons.qrc" />
</resources>
bufferview.cpp
bufferviewfilter.cpp
clearablelineedit.cpp
+ clickablelabel.cpp
colorbutton.cpp
nickviewfilter.cpp
inputline.cpp
bufferview.h
bufferviewfilter.h
clearablelineedit.h
+ clickablelabel.h
colorbutton.h
nickviewfilter.h
inputline.h
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2005-08 by the Quassel Project *
+ * devel@quassel-irc.org *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) version 3. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "clickablelabel.h"
+
+#include <QDebug>
+#include <QMouseEvent>
+
+ClickableLabel::ClickableLabel(QWidget *parent)
+ : QLabel(parent)
+{
+}
+
+
+void ClickableLabel::mouseReleaseEvent(QMouseEvent *event) {
+ if(event->pos().x() > size().width() || event->pos().y() > size().height())
+ return;
+
+ event->accept();
+ emit clicked();
+}
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2005-08 by the Quassel Project *
+ * devel@quassel-irc.org *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) version 3. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef CLICKABLELABEL_H
+#define CLICKABLELABEL_H
+
+#include <QLabel>
+
+class ClickableLabel : public QLabel {
+ Q_OBJECT
+
+public:
+ ClickableLabel(QWidget *parent = 0);
+
+signals:
+ void clicked();
+
+protected:
+ void mouseReleaseEvent(QMouseEvent *event);
+};
+
+#endif //CLICKABLELABEL_H