The input line is now enabled disabled correctly according to the current buffer...
authorMarcus Eggenberger <egs@quassel-irc.org>
Mon, 18 Feb 2008 13:16:26 +0000 (13:16 +0000)
committerMarcus Eggenberger <egs@quassel-irc.org>
Mon, 18 Feb 2008 13:16:26 +0000 (13:16 +0000)
src/client/networkmodel.cpp
src/client/networkmodel.h
src/qtui/inputwidget.cpp
src/qtui/inputwidget.h
version.inc

index be13afd..3e380d4 100644 (file)
@@ -42,6 +42,11 @@ BufferItem::BufferItem(BufferInfo bufferInfo, AbstractTreeItem *parent)
   Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled;
   if(bufferType() == BufferInfo::QueryBuffer)
     flags |= Qt::ItemIsDropEnabled;
+
+  if(bufferType() == BufferInfo::StatusBuffer) {
+    NetworkItem *networkItem = qobject_cast<NetworkItem *>(parent);
+    connect(networkItem, SIGNAL(dataChanged()), this, SIGNAL(dataChanged()));
+  }
   setFlags(flags);
 }
 
@@ -221,7 +226,12 @@ void BufferItem::part(IrcUser *ircUser) {
 }
 
 void BufferItem::removeUserFromCategory(IrcUser *ircUser) {
-  Q_ASSERT(_ircChannel);
+  if(!_ircChannel) {
+    // If we parted the channel there might still be some ircUsers connected.
+    // in that case we just ignore the call
+    Q_ASSERT(childCount() == 0);
+    return;
+  }
 
   bool success = false;
   UserCategoryItem *categoryItem = 0;
@@ -311,11 +321,6 @@ quint64 NetworkItem::id() const {
   return qHash(_networkId);
 }
 
-void NetworkItem::setActive(bool connected) {
-  Q_UNUSED(connected);
-  emit dataChanged();
-}
-
 bool NetworkItem::isActive() const {
   if(_network)
     return _network->isConnected();
@@ -357,7 +362,7 @@ void NetworkItem::attachNetwork(Network *network) {
   connect(network, SIGNAL(ircChannelAdded(QString)),
          this, SLOT(attachIrcChannel(QString)));
   connect(network, SIGNAL(connectedSet(bool)),
-         this, SLOT(setActive(bool)));
+         this, SIGNAL(dataChanged()));
   
   // FIXME: connect this and that...
 
index 961c1ca..41e5f1d 100644 (file)
@@ -110,6 +110,7 @@ public:
   NetworkItem(const NetworkId &netid, AbstractTreeItem *parent = 0);
 
   virtual quint64 id() const;
+  inline const NetworkId &networkId() const { return _networkId; }
   virtual QVariant data(int column, int row) const;
 
   bool isActive() const;
@@ -124,8 +125,6 @@ public slots:
 
   void attachNetwork(Network *network);
   void attachIrcChannel(const QString &channelName);
-
-  void setActive(bool connected);
   
 private:
   NetworkId _networkId;
index 0745d66..0f4a7ee 100644 (file)
@@ -43,7 +43,12 @@ InputWidget::~InputWidget() {
 }
 
 void InputWidget::setModel(BufferModel *bufferModel) {
+  if(_bufferModel) {
+    disconnect(_bufferModel, 0, this, 0);
+  }
   _bufferModel = bufferModel;
+  connect(bufferModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)),
+         this, SLOT(dataChanged(QModelIndex, QModelIndex)));
 }
 
 void InputWidget::setSelectionModel(QItemSelectionModel *selectionModel) {
@@ -74,6 +79,15 @@ void InputWidget::currentChanged(const QModelIndex &current, const QModelIndex &
   ui.inputEdit->setEnabled(current.data(NetworkModel::ItemActiveRole).value<bool>());
 }
 
+void InputWidget::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) {
+  QItemSelectionRange changedArea(topLeft, bottomRight);
+  QModelIndex currentIndex = Client::bufferModel()->currentIndex();
+  if(changedArea.contains(currentIndex)) {
+    ui.inputEdit->setEnabled(currentIndex.data(NetworkModel::ItemActiveRole).value<bool>());
+  }
+};
+
+
 const Network *InputWidget::currentNetwork() const {
   if(!validBuffer)
     return 0;
index 86a7693..70449d2 100644 (file)
@@ -49,7 +49,7 @@ protected slots:
 //   virtual void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint);
 //   virtual void commitData(QWidget *editor);
   virtual void currentChanged(const QModelIndex &current, const QModelIndex &previous);
-//   virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
+  virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
 //   virtual void editorDestroyed(QObject *editor);
 //   virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
 //   virtual void rowsInserted(const QModelIndex &parent, int start, int end);
index 62ba353..329e0ff 100644 (file)
@@ -5,7 +5,7 @@
 
   quasselVersion = "0.2.0-pre";
   quasselDate = "2008-02-18";
-  quasselBuild = 530;
+  quasselBuild = 531;
 
   //! Minimum client build number the core needs
   clientBuildNeeded = 526;