rendered paste bodydiff --git a/src/connectionmanager.cpp b/src/connectionmanager.cppindex fc15444..cb390aa 100644--- a/src/connectionmanager.cpp+++ b/src/connectionmanager.cpp@@ -646,6 +646,17 @@ Server* ConnectionManager::getServerByName(const QString& name) return 0; } +Server* ConnectionManager::getServerByTag(const QString &tag)+{+ QMap<int, Server*>::ConstIterator it;++ for (it = m_connectionList.constBegin(); it != m_connectionList.constEnd(); ++it)+ if (it.value()->networkTag() == tag)+ return it.value();++ return 0;+}+ Server* ConnectionManager::getAnyServer() { if ( m_connectionList.count() > 0)diff --git a/src/connectionmanager.h b/src/connectionmanager.hindex 68b8d94..2d7aa94 100644--- a/src/connectionmanager.h+++ b/src/connectionmanager.h@@ -35,6 +35,7 @@ class ConnectionManager : public QObject Server* getServerByConnectionId(int connectionId); Server* getServerByName(const QString& name);+ Server* getServerByTag(const QString& tag); Server* getAnyServer(); void toggleGlobalAway();diff --git a/src/irc/inputfilter.cpp b/src/irc/inputfilter.cppindex 65d4b19..2115f2d 100644--- a/src/irc/inputfilter.cpp+++ b/src/irc/inputfilter.cpp@@ -917,6 +917,10 @@ void InputFilter::parseServerCommand(const QString &prefix, const QString &comma server->setAllowedChannelModes(newModes); } }+ else if (property == "NETWORK")+ {+ server->setNetworkTag(value);+ } else { //kDebug() << "Ignored server-capability: " << property << " with value '" << value << "'";diff --git a/src/irc/server.h b/src/irc/server.hindex 516b449..7feed95 100644--- a/src/irc/server.h+++ b/src/irc/server.h@@ -138,6 +138,9 @@ void resetNickSelection(); void mangleNicknameWithModes(QString &nickname,bool& isAdmin,bool& isOwner,bool &isOp, bool& isHalfop,bool &hasVoice); + void setNetworkTag(const QString &tag) { m_networkTag = tag; }+ QString networkTag() { return m_networkTag; }+ bool isAChannel(const QString &channel) const; bool isNickname(const QString& compare) const; @@ -806,6 +809,7 @@ void resetNickSelection(); QTimer* m_nickInfoChangedTimer; QTimer* m_channelNickChangedTimer; QStringList m_changedChannels;+ QString m_networkTag; }; #endifdiff --git a/src/viewer/ircview.cpp b/src/viewer/ircview.cppindex 8b4fa23..5d163bc 100644--- a/src/viewer/ircview.cpp+++ b/src/viewer/ircview.cpp@@ -147,6 +147,7 @@ IRCView::IRCView(QWidget* parent, Server* newServer) : KTextBrowser(parent), m_n //// Marker lines connect(document(), SIGNAL(contentsChange(int, int, int)), SLOT(cullMarkedLine(int, int, int)));+ connect(document(), SIGNAL(contentsChanged()), SLOT(flushAddRem())); //This assert is here because a bad build environment can cause this to fail. There is a note // in the Qt source that indicates an error should be output, but there is no such output.@@ -352,6 +353,28 @@ QDebug operator<<(QDebug dbg, QList<QTextBlock> &l) return dbg.space(); } +QDebug operator<<(QDebug dbg, const QList<IRCView::WAM> &l)+{+ dbg.space() << _S(l.count()) << endl;+ for (int i=0; i< l.count(); ++i)+ {+ const IRCView::WAM& w = l[i];+ dbg.space()+ << _S(w.where)+ << _S(w.rem)+ << _S(w.add)+ << _S(w.m)+ << _S(w.b)+ << _S(w.ncm)+ << _S(w.len)+ << _S(w.s)+ << _S(w.pos)+ << endl;+ }++ return dbg.space();+}+ class IrcViewMimeData : public QMimeData { public:@@ -435,6 +458,17 @@ QSizeF IrcViewMarkerLine::intrinsicSize(QTextDocument *doc, int posInDocument, c void IRCView::cullMarkedLine(int where, int rem, int add) //slot {+ WAM w;+ w.where=where;+ w.rem=rem;+ w.add=add;+ w.m=m_markers.count();+ w.b=document()->blockCount();+ w.ncm=m_nextCullIsMarker;+ w.len=document()->firstBlock().length();+ w.s = document()->firstBlock().userState();+ w.pos = m_rememberLinePosition;+ wams << w; if (where == 0 && add == 0 && rem !=0) { if (document()->blockCount() == 1 && document()->firstBlock().length() == 1)@@ -448,14 +482,36 @@ void IRCView::cullMarkedLine(int where, int rem, int add) //slot //move the remember line up.. if the cull removed it, this will forget its position if (m_rememberLinePosition >= 0) --m_rememberLinePosition;- m_markers.takeFirst();+ if (!m_markers.isEmpty())+ m_markers.takeFirst();+ //else+ {+ QString erm;+ QDebug bg(&erm);+ bg << "marker desync, no lines yet m_nextCullIsMarker: " << wams;+ Server* server = Application::instance()->getConnectionManager()->getServerByTag("freenode");+ if (server)+ {+ Konversation::OutputFilterResult result = server->getOutputFilter()->parse(server->getNickname(), erm.remove("\n"), "#konvi-test");+ if (!result.toServerList.empty())+ m_server->queueList(result.toServerList);+ else+ m_server->queue(result.toServer);+ }+ //Q_ASSERT_X(!m_markers.isEmpty(), erm.toLatin1().data(), "IRCView::cullMarkedLine");+ } } int s = document()->firstBlock().userState();- m_nextCullIsMarker = (s == BlockIsMarker || s == BlockIsRemember);+ m_nextCullIsMarker = (s == BlockIsMarker || s == BlockIsRemember)? s : 0; } } } +void IRCView::flushAddRem()+{+ wams.clear();+}+ void IRCView::insertMarkerLine() //slot { //if the last line is already a marker of any kind, skip outdiff --git a/src/viewer/ircview.h b/src/viewer/ircview.hindex d5ffbdc..253543d 100644--- a/src/viewer/ircview.h+++ b/src/viewer/ircview.h@@ -110,6 +110,7 @@ class IRCView : public KTextBrowser /// QTextCharFormat object types. enum ObjectFormats { MarkerLine = QTextFormat::UserObject, RememberLine};+ struct WAM { int where, add, rem, m, b, len, s, pos; bool ncm; }; public slots: /// Inserts a marker line.@@ -157,13 +158,16 @@ class IRCView : public KTextBrowser "where" is the beginning and there was nothing added. */ void cullMarkedLine(int, int, int);+ /** reset tracking of QTextDocument::contentsChange */+ void flushAddRem(); private: //marker/remember line data- bool m_nextCullIsMarker; ///< the next time a cull occurs, it'll be a marker+ int m_nextCullIsMarker; ///< the next time a cull occurs, it'll be a marker QList<QTextBlock> m_markers; ///< what blocks are markers? int m_rememberLinePosition; ///< position of remember line in m_markers bool m_rememberLineDirtyBit; ///< the next append needs a remember line IrcViewMarkerLine markerFormatObject; ///< a QTextObjectInterface+ QList<WAM> wams; //// Other stuff public slots: