Fixing BR #188. This might fix X Errors (BadDrawable) aswell
[quassel.git] / src / uisupport / bufferview.cpp
index e41bdab..b0e365f 100644 (file)
@@ -48,6 +48,7 @@
 // to be on the safe side: call QTreeView's method aswell
 BufferView::BufferView(QWidget *parent)
   : QTreeView(parent),
+    showChannelList(tr("Show Channel List"), this),
     _connectNetAction(tr("Connect"), this),
     _disconnectNetAction(tr("Disconnect"), this),
     _joinChannelAction(tr("Join Channel"), this),
@@ -270,11 +271,9 @@ void BufferView::layoutChanged() {
   QModelIndex networkIdx;
   for(int row = 0; row < model()->rowCount(); row++) {
     networkIdx = model()->index(row, 0);
-    update(networkIdx);
     if(model()->rowCount(networkIdx) > 0 && model()->data(networkIdx, NetworkModel::ItemActiveRole) == true) {
+      update(networkIdx);
       expand(networkIdx);
-    } else {
-      collapse(networkIdx);
     }
   }
 
@@ -288,6 +287,7 @@ void BufferView::layoutChanged() {
 }
 
 void BufferView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) {
+  qDebug() << "dataChanged()";
   QTreeView::dataChanged(topLeft, bottomRight);
   
   // determine how many items have been changed and if any of them is a networkitem
@@ -399,8 +399,10 @@ void BufferView::contextMenuEvent(QContextMenuEvent *event) {
   
   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, index, ActiveState);
     addItemToMenu(_connectNetAction, contextMenu, index, InactiveState);
     addSeparatorToMenu(contextMenu, index, ActiveState);
@@ -457,10 +459,11 @@ void BufferView::contextMenuEvent(QContextMenuEvent *event) {
     bool ok;
     QString channelName = QInputDialog::getText(this, tr("Join Channel"), tr("Input channel name:"), QLineEdit::Normal, QString(), &ok);
     if(ok && !channelName.isEmpty()) {
-      BufferInfo bufferInfo = index.child(0,0).data(NetworkModel::BufferInfoRole).value<BufferInfo>();
-      if(bufferInfo.isValid()) {
-        Client::instance()->userInput(bufferInfo, QString("/J %1").arg(channelName));
-      }
+      Client::instance()->userInput(BufferInfo::fakeStatusBuffer(index.data(NetworkModel::NetworkIdRole).value<NetworkId>()), QString("/J %1").arg(channelName));
+//       BufferInfo bufferInfo = index.child(0,0).data(NetworkModel::BufferInfoRole).value<BufferInfo>();
+//       if(bufferInfo.isValid()) {
+//         Client::instance()->userInput(bufferInfo, QString("/J %1").arg(channelName));
+//       }
     }
 #endif
     return;
@@ -474,7 +477,7 @@ void BufferView::contextMenuEvent(QContextMenuEvent *event) {
 
   if(result == &_partBufferAction) {
     BufferInfo bufferInfo = index.data(NetworkModel::BufferInfoRole).value<BufferInfo>();
-    Client::instance()->userInput(bufferInfo, QString("/PART %1").arg(bufferInfo.bufferName()));
+    Client::instance()->userInput(bufferInfo, QString("/PART"));
     return;
   }