- return false;
- }
- return false;
-}
-
-void InputWidget::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) {
- BufferId currentBufferId = current.data(NetworkModel::BufferIdRole).value<BufferId>();
- BufferId previousBufferId = previous.data(NetworkModel::BufferIdRole).value<BufferId>();
-
- if (_perChatHistory) {
- //backup
- historyMap[previousBufferId].history = inputLine()->history();
- historyMap[previousBufferId].tempHistory = inputLine()->tempHistory();
- historyMap[previousBufferId].idx = inputLine()->idx();
- historyMap[previousBufferId].inputLine = inputLine()->html();
-
- //restore
- inputLine()->setHistory(historyMap[currentBufferId].history);
- inputLine()->setTempHistory(historyMap[currentBufferId].tempHistory);
- inputLine()->setIdx(historyMap[currentBufferId].idx);
- inputLine()->setHtml(historyMap[currentBufferId].inputLine);
- inputLine()->moveCursor(QTextCursor::End,QTextCursor::MoveAnchor);
-
- // FIXME this really should be in MultiLineEdit (and the const int on top removed)
- QTextBlockFormat format = inputLine()->textCursor().blockFormat();
- format.setLeftMargin(leftMargin); // we want a little space between the frame and the contents
- inputLine()->textCursor().setBlockFormat(format);
- }
-
- NetworkId networkId = current.data(NetworkModel::NetworkIdRole).value<NetworkId>();
- if(networkId == _networkId)
- return;
-
- setNetwork(networkId);
- updateNickSelector();
- updateEnabledState();
-}
-
-void InputWidget::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) {
- QItemSelectionRange changedArea(topLeft, bottomRight);
- if(changedArea.contains(selectionModel()->currentIndex())) {
- updateEnabledState();
- }
-};
-
-void InputWidget::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) {
- NetworkId networkId;
- QModelIndex child;
- for(int row = start; row <= end; row++) {
- child = model()->index(row, 0, parent);
- if(NetworkModel::NetworkItemType != child.data(NetworkModel::ItemTypeRole).toInt())
- continue;
- networkId = child.data(NetworkModel::NetworkIdRole).value<NetworkId>();
- if(networkId == _networkId) {
- setNetwork(0);
- updateNickSelector();
- return;
- }
- }
-}
-
-
-void InputWidget::updateEnabledState() {
-// FIXME: Find a visualization for this that does not disable the widget!
-// Disabling kills global action shortcuts, plus users sometimes need/want to enter text
-// even in inactive channels.
-#if 0
- QModelIndex currentIndex = selectionModel()->currentIndex();
-
- const Network *net = Client::networkModel()->networkByIndex(currentIndex);
- bool enabled = false;
- if(net) {
- // disable inputline if it's a channelbuffer we parted from or...
- enabled = (currentIndex.data(NetworkModel::ItemActiveRole).value<bool>() || (currentIndex.data(NetworkModel::BufferTypeRole).toInt() != BufferInfo::ChannelBuffer));
- // ... if we're not connected to the network at all
- enabled &= net->isConnected();
- }
-
- ui.inputEdit->setEnabled(enabled);
-#endif