X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fnetworkmodelactionprovider.cpp;h=12fd2e4ba2c25c25cbaddc24a027e9180adc64c9;hp=31117f4eff54e8d4c86110c45ad4b54d206b9ffc;hb=7ea9c498bfb975a95c11d6ddc28835840cf3353d;hpb=6eebebc97f84a94f732b05a793ea8e4c000643ab diff --git a/src/uisupport/networkmodelactionprovider.cpp b/src/uisupport/networkmodelactionprovider.cpp index 31117f4e..12fd2e4b 100644 --- a/src/uisupport/networkmodelactionprovider.cpp +++ b/src/uisupport/networkmodelactionprovider.cpp @@ -29,6 +29,7 @@ #include "iconloader.h" #include "identity.h" #include "network.h" +#include "util.h" NetworkModelActionProvider::NetworkModelActionProvider(QObject *parent) : AbstractActionProvider(parent), @@ -219,6 +220,24 @@ void NetworkModelActionProvider::addActions(QMenu *menu, // TODO: actions for merged buffers... _indexList contains the index of the message we clicked on } + } else { + // context item = chan or nick, _indexList = buf where the msg clicked on originated + if(isChannelName(_contextItem)) { + QModelIndex msgIdx = _indexList.at(0); + if(!msgIdx.isValid()) + return; + NetworkId networkId = msgIdx.data(NetworkModel::NetworkIdRole).value(); + BufferId bufId = Client::networkModel()->bufferId(networkId, _contextItem); + if(bufId.isValid()) { + QModelIndex targetIdx = Client::networkModel()->bufferIndex(bufId); + _indexList = QList() << targetIdx; + addAction(BufferJoin, menu, targetIdx, InactiveState); + addAction(BufferSwitchTo, menu, targetIdx, ActiveState); + } else + addAction(JoinChannel, menu); + } else { + // TODO: actions for a nick + } } } } @@ -520,17 +539,17 @@ void NetworkModelActionProvider::handleGeneralAction(ActionType type, QAction *a return; switch(type) { - case JoinChannel: - { - // FIXME no QInputDialog in Qtopia -# ifndef Q_WS_QWS - bool ok; - QString channelName = QInputDialog::getText(0, tr("Join Channel"), tr("Input channel name:"), QLineEdit::Normal, QString(), &ok); - if(ok && !channelName.isEmpty()) { - Client::instance()->userInput(BufferInfo::fakeStatusBuffer(networkId), - QString("/JOIN %1").arg(channelName)); + case JoinChannel: { + QString channelName = _contextItem; + if(channelName.isEmpty()) { + bool ok; + channelName = QInputDialog::getText(0, tr("Join Channel"), tr("Input channel name:"), QLineEdit::Normal, QString(), &ok); + if(!ok) + return; + } + if(!channelName.isEmpty()) { + Client::instance()->userInput(BufferInfo::fakeStatusBuffer(networkId), QString("/JOIN %1").arg(channelName)); } -# endif break; } case ShowChannelList: