-
- BufferInfo bufferInfo = index.data(NetworkModel::BufferInfoRole).value<BufferInfo>();
- QString channelname = index.sibling(index.row(), 0).data().toString();
-
- if(index.data(NetworkModel::ItemTypeRole) == NetworkModel::BufferItemType) {
- if(bufferInfo.type() != BufferInfo::ChannelBuffer && bufferInfo.type() != BufferInfo::QueryBuffer) return;
- contextMenu.addAction(joinBufferAction);
- contextMenu.addAction(partBufferAction);
- contextMenu.addAction(removeBufferAction);
- contextMenu.addMenu(hideEventsMenu);
- contextMenu.addAction(ignoreListAction);
- contextMenu.addAction(whoBufferAction);
-
- if(bufferInfo.type() == BufferInfo::ChannelBuffer) {
- if(index.data(NetworkModel::ItemActiveRole).toBool()) {
- removeBufferAction->setEnabled(false);
- removeBufferAction->setToolTip("To delete the buffer, part the channel first.");
- joinBufferAction->setVisible(false);
- whoBufferAction->setVisible(false);
- } else {
- partBufferAction->setVisible(false);
+
+ QMenu contextMenu(this);
+ NetworkModel::itemType itemType = static_cast<NetworkModel::itemType>(index.data(NetworkModel::ItemTypeRole).toInt());
+
+ switch(itemType) {
+ case NetworkModel::NetworkItemType:
+ showChannelList.setData(index.data(NetworkModel::NetworkIdRole));
+ _disconnectNetAction.setIcon(connectionStateIcon);
+ _connectNetAction.setIcon(connectionStateIcon);
+ addItemToMenu(showChannelList, contextMenu, index, ActiveState);
+ qDebug() << "state:" << network->connectionState() << Network::Disconnected << Network::Disconnecting;
+ addItemToMenu(_disconnectNetAction, contextMenu, network->connectionState() != Network::Disconnected);
+ addItemToMenu(_connectNetAction, contextMenu, network->connectionState() == Network::Disconnected);
+ addSeparatorToMenu(contextMenu, index, ActiveState);
+ addItemToMenu(_joinChannelAction, contextMenu, index, ActiveState);
+ break;
+ case NetworkModel::BufferItemType:
+ {
+ BufferInfo bufferInfo = index.data(NetworkModel::BufferInfoRole).value<BufferInfo>();
+ switch(bufferInfo.type()) {
+ case BufferInfo::ChannelBuffer:
+ addItemToMenu(_joinBufferAction, contextMenu, index, InactiveState);
+ addItemToMenu(_partBufferAction, contextMenu, index, ActiveState);
+ addItemToMenu(_hideBufferTemporarilyAction, contextMenu, (bool)config());
+ addItemToMenu(_hideBufferPermanentlyAction, contextMenu, (bool)config());
+ addItemToMenu(_removeBufferAction, contextMenu, index, InactiveState);
+ createHideEventsSubMenu(contextMenu);
+ addItemToMenu(_ignoreListAction, contextMenu);
+ break;
+ case BufferInfo::QueryBuffer:
+ addItemToMenu(_hideBufferTemporarilyAction, contextMenu, (bool)config());
+ addItemToMenu(_hideBufferPermanentlyAction, contextMenu, (bool)config());
+ addItemToMenu(_removeBufferAction, contextMenu);
+ createHideEventsSubMenu(contextMenu);
+ break;
+ default:
+ addItemToMenu(_hideBufferTemporarilyAction, contextMenu, (bool)config());
+ addItemToMenu(_hideBufferPermanentlyAction, contextMenu, (bool)config());
+ break;