- 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);
- 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, bufferInfo.bufferId());
- addItemToMenu(_ignoreListAction, contextMenu);
- break;
- case BufferInfo::QueryBuffer:
- addItemToMenu(_hideBufferTemporarilyAction, contextMenu, (bool)config());
- addItemToMenu(_hideBufferPermanentlyAction, contextMenu, (bool)config());
- addItemToMenu(_removeBufferAction, contextMenu);
- createHideEventsSubMenu(contextMenu, bufferInfo.bufferId());
- break;
- default:
- addItemToMenu(_hideBufferTemporarilyAction, contextMenu, (bool)config());
- addItemToMenu(_hideBufferPermanentlyAction, contextMenu, (bool)config());
- break;
- }
- }
- break;
- default:
- return;
- }
-
- if(contextMenu.actions().isEmpty())
- return;
- QAction *result = contextMenu.exec(QCursor::pos());
-
- // Handle Result
- if(network && result == &_connectNetAction) {
- network->requestConnect();
- return;
- }
-
- if(network && result == &_disconnectNetAction) {
- network->requestDisconnect();
- return;
- }