X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchannellistdlg.cpp;h=97db22033d8b113fbd55bfcb6bfbeb592f1707b9;hp=97d801bc8f1f37d5a744735cc0681d9251bb4ada;hb=f04db2cb802b1296ca739c823495930c71d3b4ab;hpb=c8e11a9292db37e0e0258537006e41c95c3f9ffe diff --git a/src/qtui/channellistdlg.cpp b/src/qtui/channellistdlg.cpp index 97d801bc..97db2203 100644 --- a/src/qtui/channellistdlg.cpp +++ b/src/qtui/channellistdlg.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel Project * + * Copyright (C) 2005-2013 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -15,159 +15,165 @@ * 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. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "channellistdlg.h" -#include "client.h" -#include "clientirclisthelper.h" - #include #include #include +#include "client.h" +#include "clientirclisthelper.h" +#include "icon.h" +#include "iconloader.h" + ChannelListDlg::ChannelListDlg(QWidget *parent) - : QDialog(parent), + : QDialog(parent), _listFinished(true), _ircListModel(this), _sortFilter(this), _simpleModeSpacer(0), _advancedMode(false) { - _sortFilter.setSourceModel(&_ircListModel); - _sortFilter.setFilterCaseSensitivity(Qt::CaseInsensitive); - _sortFilter.setFilterKeyColumn(-1); - - ui.setupUi(this); - ui.channelListView->setSelectionBehavior(QAbstractItemView::SelectRows); - ui.channelListView->setSelectionMode(QAbstractItemView::SingleSelection); - ui.channelListView->setAlternatingRowColors(true); - ui.channelListView->setTabKeyNavigation(false); - ui.channelListView->setModel(&_sortFilter); - ui.channelListView->setSortingEnabled(true); - ui.channelListView->verticalHeader()->hide(); - ui.channelListView->horizontalHeader()->setStretchLastSection(true); - - 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); + _sortFilter.setSourceModel(&_ircListModel); + _sortFilter.setFilterCaseSensitivity(Qt::CaseInsensitive); + _sortFilter.setFilterKeyColumn(-1); + + ui.setupUi(this); + ui.advancedModeLabel->setPixmap(BarIcon("edit-rename")); + + ui.channelListView->setSelectionBehavior(QAbstractItemView::SelectRows); + ui.channelListView->setSelectionMode(QAbstractItemView::SingleSelection); + ui.channelListView->setAlternatingRowColors(true); + ui.channelListView->setTabKeyNavigation(false); + ui.channelListView->setModel(&_sortFilter); + ui.channelListView->setSortingEnabled(true); + ui.channelListView->verticalHeader()->hide(); + ui.channelListView->horizontalHeader()->setStretchLastSection(true); + + ui.searchChannelsButton->setAutoDefault(false); + + setWindowIcon(Icon("format-list-unordered")); + + 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; - - _netId = netId; - _ircListModel.setChannelList(); - showFilterLine(false); + +void ChannelListDlg::setNetwork(NetworkId netId) +{ + if (_netId == netId) + return; + + _netId = netId; + _ircListModel.setChannelList(); + showFilterLine(false); } -void ChannelListDlg::requestSearch() { - _listFinished = false; - enableQuery(false); - showErrors(false); - QStringList channelFilters; - channelFilters << ui.channelNameLineEdit->text().trimmed(); - Client::ircListHelper()->requestChannelList(_netId, channelFilters); + +void ChannelListDlg::requestSearch() +{ + _listFinished = false; + enableQuery(false); + showErrors(false); + QStringList channelFilters; + channelFilters << ui.channelNameLineEdit->text().trimmed(); + Client::ircListHelper()->requestChannelList(_netId, channelFilters); } -void ChannelListDlg::receiveChannelList(const NetworkId &netId, const QStringList &channelFilters, const QList &channelList) { - Q_UNUSED(netId) - Q_UNUSED(channelFilters) - showFilterLine(!channelList.isEmpty()); - _ircListModel.setChannelList(channelList); - enableQuery(_listFinished); +void ChannelListDlg::receiveChannelList(const NetworkId &netId, const QStringList &channelFilters, const QList &channelList) +{ + Q_UNUSED(channelFilters) + if (netId != _netId) + return; + + showFilterLine(!channelList.isEmpty()); + _ircListModel.setChannelList(channelList); + enableQuery(_listFinished); } -void ChannelListDlg::showFilterLine(bool show) { - ui.line->setVisible(show); - ui.filterLabel->setVisible(show); - ui.filterLineEdit->setVisible(show); + +void ChannelListDlg::showFilterLine(bool show) +{ + ui.line->setVisible(show); + ui.filterLabel->setVisible(show); + ui.filterLineEdit->setVisible(show); } -void ChannelListDlg::enableQuery(bool enable) { - ui.channelNameLineEdit->setEnabled(enable); - ui.searchChannelsButton->setEnabled(enable); + +void ChannelListDlg::enableQuery(bool enable) +{ + ui.channelNameLineEdit->setEnabled(enable); + ui.searchChannelsButton->setEnabled(enable); } -void ChannelListDlg::setAdvancedMode(bool advanced) { - _advancedMode = advanced; - - QHBoxLayout *searchLayout = 0; -#if QT_VERSION >= 0x040400 - searchLayout = ui.searchLayout; -#else - // FIXME: REMOVE WHEN WE DEPEND ON Qt 4.4 - /* - * ok this just sucks: in Qt 4.3 there is no way to search for a layout as uic creates - * them without a parent -.- - * in this case there are only 2 candidates: ui.hboxLayout and ui.hboxLayout1 - */ - if(ui.hboxLayout.findWidget(ui.searchPatternLabel) != -1) - searchLayout = ui.hboxLayout; - else if(ui.hboxLayout1.findWidget(ui.searchPatternLabel) != -1) - searchLayout = ui.hboxLayout1; - else - /* if this assert trigger we have been compiled on a too old Qt - * or uic generated something very unexpected. we cannot find the layout to manipulate. - * Please upgrade to a recent version of Qt. - */ - Q_ASSERT(false); -#endif - - if(advanced) { - if(_simpleModeSpacer) { - searchLayout->removeItem(_simpleModeSpacer); - delete _simpleModeSpacer; - _simpleModeSpacer = 0; + +void ChannelListDlg::setAdvancedMode(bool advanced) +{ + _advancedMode = advanced; + + if (advanced) { + if (_simpleModeSpacer) { + ui.searchLayout->removeItem(_simpleModeSpacer); + delete _simpleModeSpacer; + _simpleModeSpacer = 0; + } + ui.advancedModeLabel->setPixmap(BarIcon("edit-clear-locationbar-rtl")); } - 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); - searchLayout->insertSpacerItem(0, _simpleModeSpacer); + else { + if (!_simpleModeSpacer) { + _simpleModeSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + ui.searchLayout->insertSpacerItem(0, _simpleModeSpacer); + } + ui.advancedModeLabel->setPixmap(BarIcon("edit-rename")); } - 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); + + 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::showErrors(bool show) +{ + if (!show) { + ui.errorTextEdit->clear(); + } + ui.errorLabel->setVisible(show); + ui.errorTextEdit->setVisible(show); } -void ChannelListDlg::reportFinishedList() { - _listFinished = true; +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::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())); + +void ChannelListDlg::joinChannel(const QModelIndex &index) +{ + Client::instance()->userInput(BufferInfo::fakeStatusBuffer(_netId), QString("/JOIN %1").arg(index.sibling(index.row(), 0).data().toString())); }