- 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;
+ colorChosen(ui.textcolorButton->defaultAction());
+}
+
+
+void InputWidget::applyFormatActiveColorFill()
+{
+ if (!ui.highlightcolorButton->defaultAction()) {
+ return;
+ }
+ colorHighlightChosen(ui.highlightcolorButton->defaultAction());
+}
+
+
+void InputWidget::toggleFormatBold()
+{
+ setFormatBold(!ui.boldButton->isChecked());
+}
+
+
+void InputWidget::toggleFormatItalic()
+{
+ setFormatItalic(!ui.italicButton->isChecked());
+}
+
+
+void InputWidget::toggleFormatUnderline()
+{
+ setFormatUnderline(!ui.underlineButton->isChecked());
+}
+
+
+void InputWidget::clearFormat()
+{
+ // Clear all formatting for selection (not global)
+ setFormatClear(false);
+}
+
+
+void InputWidget::setNetwork(NetworkId networkId)
+{
+ if (_networkId == networkId)
+ return;
+
+ const Network *previousNet = Client::network(_networkId);
+ if (previousNet) {
+ disconnect(previousNet, 0, this, 0);
+ if (previousNet->me())
+ disconnect(previousNet->me(), 0, this, 0);
+ }
+
+ _networkId = networkId;
+
+ const Network *network = Client::network(networkId);
+ if (network) {
+ connect(network, SIGNAL(identitySet(IdentityId)), this, SLOT(setIdentity(IdentityId)));
+ connectMyIrcUser();
+ setIdentity(network->identity());
+ }
+ else {
+ setIdentity(0);
+ _networkId = 0;
+ }
+}
+
+
+void InputWidget::connectMyIrcUser()
+{
+ const Network *network = currentNetwork();
+ if (network->me()) {
+ connect(network->me(), SIGNAL(nickSet(const QString &)), this, SLOT(updateNickSelector()));
+ connect(network->me(), SIGNAL(userModesSet(QString)), this, SLOT(updateNickSelector()));
+ connect(network->me(), SIGNAL(userModesAdded(QString)), this, SLOT(updateNickSelector()));
+ connect(network->me(), SIGNAL(userModesRemoved(QString)), this, SLOT(updateNickSelector()));
+ connect(network->me(), SIGNAL(awaySet(bool)), this, SLOT(updateNickSelector()));
+ disconnect(network, SIGNAL(myNickSet(const QString &)), this, SLOT(connectMyIrcUser()));
+ updateNickSelector();
+ }
+ else {
+ connect(network, SIGNAL(myNickSet(const QString &)), this, SLOT(connectMyIrcUser()));
+ }
+}
+
+
+void InputWidget::setIdentity(IdentityId identityId)
+{
+ if (_identityId == identityId)
+ return;
+
+ const Identity *previousIdentity = Client::identity(_identityId);
+ if (previousIdentity)
+ disconnect(previousIdentity, 0, this, 0);
+
+ _identityId = identityId;
+
+ const Identity *identity = Client::identity(identityId);
+ if (identity) {
+ connect(identity, SIGNAL(nicksSet(QStringList)), this, SLOT(updateNickSelector()));
+ }
+ else {
+ _identityId = 0;