From: Manuel Nickschas Date: Fri, 6 Feb 2009 00:22:33 +0000 (+0100) Subject: Pimp JoinDlg X-Git-Tag: 0.4.0~121 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=4e9b713cf4941e9d1d8341ed2dea3cbdf4a22a8a;hp=982359db5545edf340a246cd13dfcdc9bf2ccf33 Pimp JoinDlg We now pre-select a currently selected channel if it's not joined. This way, pressing the Join toolbutton while a non-joined channel is selected provides a direct way to join that channel. --- diff --git a/src/uisupport/networkmodelcontroller.cpp b/src/uisupport/networkmodelcontroller.cpp index 626d495f..8a1d90a8 100644 --- a/src/uisupport/networkmodelcontroller.cpp +++ b/src/uisupport/networkmodelcontroller.cpp @@ -317,14 +317,12 @@ void NetworkModelController::handleGeneralAction(ActionType type, QAction *actio if(!indexList().count()) return; NetworkId networkId = indexList().at(0).data(NetworkModel::NetworkIdRole).value(); - if(!networkId.isValid()) - return; switch(type) { case JoinChannel: { QString channelName = contextItem(); if(channelName.isEmpty()) { - JoinDlg dlg(networkId); + JoinDlg dlg(indexList().first()); if(dlg.exec() == QDialog::Accepted) { channelName = dlg.channelName(); networkId = dlg.networkId(); @@ -336,10 +334,12 @@ void NetworkModelController::handleGeneralAction(ActionType type, QAction *actio break; } case ShowChannelList: - emit showChannelList(networkId); + if(networkId.isValid()) + emit showChannelList(networkId); break; case ShowIgnoreList: - emit showIgnoreList(networkId); + if(networkId.isValid()) + emit showIgnoreList(networkId); break; default: break; @@ -412,7 +412,7 @@ void NetworkModelController::handleNickAction(ActionType type, QAction *) { * JoinDlg ***************************************************************************************************************/ -NetworkModelController::JoinDlg::JoinDlg(NetworkId defaultId, QWidget *parent) : QDialog(parent) { +NetworkModelController::JoinDlg::JoinDlg(const QModelIndex &index, QWidget *parent) : QDialog(parent) { setWindowIcon(SmallIcon("irc-join-channel")); setWindowTitle(tr("Join Channel")); @@ -432,20 +432,22 @@ NetworkModelController::JoinDlg::JoinDlg(NetworkId defaultId, QWidget *parent) : connect(buttonBox, SIGNAL(rejected()), SLOT(reject())); connect(channel, SIGNAL(textChanged(QString)), SLOT(on_channel_textChanged(QString))); - - QString defaultName; foreach(NetworkId id, Client::networkIds()) { const Network *net = Client::network(id); if(net->isConnected()) { networks->addItem(net->networkName(), QVariant::fromValue(id)); - if(id == defaultId) - defaultName = net->networkName(); } } - if(!defaultName.isEmpty()) - networks->setCurrentIndex(networks->findText(defaultName)); - + if(index.isValid()) { + NetworkId networkId = index.data(NetworkModel::NetworkIdRole).value(); + if(networkId.isValid()) { + networks->setCurrentIndex(networks->findText(Client::network(networkId)->networkName())); + if(index.data(NetworkModel::BufferTypeRole) == BufferInfo::ChannelBuffer + && !index.data(NetworkModel::ItemActiveRole).toBool()) + channel->setText(index.data(Qt::DisplayRole).toString()); + } + } } NetworkId NetworkModelController::JoinDlg::networkId() const { diff --git a/src/uisupport/networkmodelcontroller.h b/src/uisupport/networkmodelcontroller.h index 4333a0c4..0aa5860a 100644 --- a/src/uisupport/networkmodelcontroller.h +++ b/src/uisupport/networkmodelcontroller.h @@ -162,7 +162,7 @@ class NetworkModelController::JoinDlg : public QDialog { Q_OBJECT public: - JoinDlg(NetworkId id, QWidget *parent = 0); + JoinDlg(const QModelIndex &index, QWidget *parent = 0); QString channelName() const; NetworkId networkId() const;