fixed renaming issue for queries
authorMarcus Eggenberger <egs@quassel-irc.org>
Sun, 16 Mar 2008 15:25:02 +0000 (15:25 +0000)
committerMarcus Eggenberger <egs@quassel-irc.org>
Sun, 16 Mar 2008 15:25:02 +0000 (15:25 +0000)
src/client/networkmodel.cpp
src/qtui/inputwidget.cpp
src/qtui/inputwidget.h

index 75dd515..6b1a785 100644 (file)
@@ -160,7 +160,7 @@ void BufferItem::setBufferName(const QString &name) {
   _bufferName = name;
   // as long as we need those bufferInfos, we have to update that one aswell.
   // pretty ugly though :/
-  _bufferInfo = BufferInfo(_bufferInfo.bufferId(), _bufferInfo.networkId(), _bufferInfo.type(), _bufferInfo.groupId(), _bufferInfo.bufferName());
+  _bufferInfo = BufferInfo(_bufferInfo.bufferId(), _bufferInfo.networkId(), _bufferInfo.type(), _bufferInfo.groupId(), name);
   emit dataChanged(0);
 }
 
index 0c66767..d232182 100644 (file)
@@ -44,19 +44,9 @@ InputWidget::~InputWidget() {
 }
 
 void InputWidget::currentChanged(const QModelIndex &current, const QModelIndex &previous) {
-  Q_UNUSED(previous);
-
-  validBuffer = current.isValid();
-
-  if(!validBuffer)
-    return;
-  
-  QVariant variant;
-  variant = current.data(NetworkModel::BufferInfoRole);
-  if(!variant.isValid())
+  if(current.data(NetworkModel::BufferInfoRole) == previous.data(NetworkModel::BufferInfoRole))
     return;
 
-  currentBufferInfo  = current.data(NetworkModel::BufferInfoRole).value<BufferInfo>();
   setNetwork(Client::networkModel()->networkByIndex(current));
   updateNickSelector();
   ui.inputEdit->setEnabled(current.data(NetworkModel::ItemActiveRole).value<bool>());
@@ -78,6 +68,10 @@ const Network *InputWidget::currentNetwork() const {
   return Client::network(_networkId);
 }
 
+BufferInfo InputWidget::currentBufferInfo() const {
+  return selectionModel()->currentIndex().data(NetworkModel::BufferInfoRole).value<BufferInfo>();
+};
+
 void InputWidget::setNetwork(const Network *network) {
   if(!network || _networkId == network->networkId())
     return;
@@ -150,11 +144,11 @@ void InputWidget::changeNick(const QString &newNick) const {
   const Network *net = currentNetwork();
   if(!net || net->isMyNick(newNick))
     return;
-  emit userInput(currentBufferInfo, QString("/nick %1").arg(newNick));
+  emit userInput(currentBufferInfo(), QString("/nick %1").arg(newNick));
 }
 
 void InputWidget::sendText(QString text) {
-  emit userInput(currentBufferInfo, text);
+  emit userInput(currentBufferInfo(), text);
 }
 
 
index 371d429..dbf783e 100644 (file)
@@ -50,6 +50,8 @@ private slots:
   void setIdentity(const IdentityId &identityId);
   void updateNickSelector() const;
 
+  BufferInfo currentBufferInfo() const;
+
 signals:
   void userInput(BufferInfo, QString msg) const;
 
@@ -57,7 +59,6 @@ private:
   Ui::InputWidget ui;
 
   bool validBuffer;
-  BufferInfo currentBufferInfo;
   
   NetworkId _networkId;
   IdentityId _identityId;