- QPixmap connectionStateIcon;
- if(network) {
- if(network->connectionState() == Network::Initialized) {
- connectionStateIcon = SmallIcon("network-connect");
- } else if(network->connectionState() == Network::Disconnected) {
- connectionStateIcon = SmallIcon("network-disconnect");
- } else {
- connectionStateIcon = SmallIcon("network-wired"); // FIXME network-connecting
- }
- }
-
- 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);
- 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;
- }
+void BufferView::changeBuffer(Direction direction)
+{
+ QModelIndex currentIndex = selectionModel()->currentIndex();
+ QModelIndex resultingIndex;
+
+ if (currentIndex.parent().isValid()) {
+ //If we are a child node just switch among siblings unless it's the first/last child
+ resultingIndex = currentIndex.sibling(currentIndex.row() + direction, 0);
+
+ if (!resultingIndex.isValid()) {
+ QModelIndex parent = currentIndex.parent();
+ if (direction == Backward)
+ resultingIndex = parent;
+ else
+ resultingIndex = parent.sibling(parent.row() + direction, 0);
+ }