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);
}
}
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;
return qHash(_networkId);
}
-void NetworkItem::setActive(bool connected) {
- Q_UNUSED(connected);
- emit dataChanged();
-}
-
bool NetworkItem::isActive() const {
if(_network)
return _network->isConnected();
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...
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;
void attachNetwork(Network *network);
void attachIrcChannel(const QString &channelName);
-
- void setActive(bool connected);
private:
NetworkId _networkId;
}
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) {
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;
// virtual void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint);
// virtual void commitData(QWidget *editor);
virtual void currentChanged(const QModelIndex ¤t, 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);
quasselVersion = "0.2.0-pre";
quasselDate = "2008-02-18";
- quasselBuild = 530;
+ quasselBuild = 531;
//! Minimum client build number the core needs
clientBuildNeeded = 526;