From 9c57fb511378fabd7ba1ead3400ad19e95f43e66 Mon Sep 17 00:00:00 2001 From: Szymon Tomasz Stefanek Date: Fri, 11 Jan 2008 16:38:56 +0000 Subject: More work on the context module and some QT4 port in trunk: no longer use Q3PtrList but also leave the client code untouched git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@1071 17fca916-40b9-46aa-a4ea-0a15b648b75c --- src/modules/context/libkvicontext.cpp | 113 ++++++++++++++++++++++++---- src/modules/help/index.cpp | 20 ++--- src/modules/help/index.h | 11 +-- src/modules/list/listwindow.cpp | 3 +- src/modules/logview/logviewmdiwindow.cpp | 2 +- src/modules/my/libkvimy.cpp | 4 + src/modules/notifier/notifierwindowtabs.cpp | 24 +++--- src/modules/notifier/notifierwindowtabs.h | 12 +-- src/modules/objects/class_list.cpp | 10 ++- src/modules/url/libkviurl.cpp | 11 ++- 10 files changed, 144 insertions(+), 66 deletions(-) (limited to 'src/modules') diff --git a/src/modules/context/libkvicontext.cpp b/src/modules/context/libkvicontext.cpp index 28f3fb1bf..f205b5930 100644 --- a/src/modules/context/libkvicontext.cpp +++ b/src/modules/context/libkvicontext.cpp @@ -1,6 +1,6 @@ //============================================================================= // -// File : libkvistr.cpp +// File : libkvicontext.cpp // Creation date : Wed Jan 02 2007 03:04:12 GMT by Szymon Stefanek // // This file is part of the KVirc irc client distribution @@ -72,31 +72,61 @@ return true; \ } +/* + @doc: context.networkName + @type: + function + @title: + $context.networkName + @short: + Returns the IRC network name of an IRC context + @syntax: + $contex.networkName + $contex.networkName() + @description: + Returns the name of the network for the specified IRC context. + If no irc_context_id is specified then the current irc_context is used. + If the irc_context_id specification is not valid then this function + returns nothing. If the specified IRC context is not currently connected + then this function returns nothing. + @seealso: + $context.serverHostName +*/ + +STANDARD_IRC_CONNECTION_TARGET_PARAMETER( + context_kvs_fnc_networkName, + c->returnValue()->setString(pConnection->target()->network()->name()) + ) /* - @doc: context.serverName + @doc: context.serverHostName @type: function @title: - $context.serverName + $context.serverHostName @short: Returns the IRC server name of an IRC context @syntax: - $contex.serverName - $contex.serverName() + $contex.serverHostName + $contex.serverHostName() @description: - Returns the name of the IRC server for the specified irc context. + Returns the host name of the IRC server that was used to perform + the connection in the specified irc context. If no irc_context_id is specified then the current irc_context is used. If the irc_context_id specification is not valid then this function returns nothing. If the specified IRC context is not currently connected then this function returns nothing. + If the returned value is non empty then it will always be a valid + DNS hostname that can be used to perform a real connection. + Please note that this is different from $my.server() which might + return an invalid DNS entry. @seealso: $context.serverPort, $context.serverIpAddress, $context.serverPassword */ STANDARD_IRC_CONNECTION_TARGET_PARAMETER( - context_kvs_fnc_serverName, + context_kvs_fnc_serverHostName, c->returnValue()->setString(pConnection->target()->server()->hostName()) ) @@ -118,7 +148,7 @@ STANDARD_IRC_CONNECTION_TARGET_PARAMETER( returns nothing. If the specified IRC context is not currently connected then this function returns nothing. @seealso: - $context.serverPort, $context.serverName, $context.serverPassword + $context.serverPort, $context.serverHostName, $context.serverPassword */ STANDARD_IRC_CONNECTION_TARGET_PARAMETER( @@ -126,6 +156,60 @@ STANDARD_IRC_CONNECTION_TARGET_PARAMETER( c->returnValue()->setString(pConnection->target()->server()->ipAddress()) ) +/* + @doc: context.serverIsIPV6 + @type: + function + @title: + $context.serverIsIPV6 + @short: + Returns the IPV6 state of an IRC context + @syntax: + $contex.serverIsIPV6 + $contex.serverIsIPV6() + @description: + Returns true if the current irc context connection runs over IPV6. + If no irc_context_id is specified then the current irc_context is used. + If the irc_context_id specification is not valid then this function + returns nothing (that evaluates to false). If the specified IRC context + is not currently connected then this function returns nothing (that + evaluates to false). + @seealso: + $context.serverPort, $context.serverHostName, $context.serverPassword +*/ + +STANDARD_IRC_CONNECTION_TARGET_PARAMETER( + context_kvs_fnc_serverIsIPV6, + c->returnValue()->setBoolean(pConnection->target()->server()->isIpV6()) + ) + +/* + @doc: context.serverIsSSL + @type: + function + @title: + $context.serverIsSSL + @short: + Returns the SSL state of an IRC context + @syntax: + $contex.serverIsSSL + $contex.serverIsSSL() + @description: + Returns true if the current irc context connection runs over SSL. + If no irc_context_id is specified then the current irc_context is used. + If the irc_context_id specification is not valid then this function + returns nothing (that evaluates to false). If the specified IRC context + is not currently connected then this function returns nothing (that + evaluates to false). + @seealso: + $context.serverPort, $context.serverHostName, $context.serverPassword +*/ + +STANDARD_IRC_CONNECTION_TARGET_PARAMETER( + context_kvs_fnc_serverIsSSL, + c->returnValue()->setBoolean(pConnection->target()->server()->useSSL()) + ) + /* @doc: context.serverPassword @type: @@ -144,7 +228,7 @@ STANDARD_IRC_CONNECTION_TARGET_PARAMETER( returns nothing. If the specified IRC context is not currently connected then this function returns nothing. @seealso: - $context.serverName, $context.serverIpAddress, $context.serverPort + $context.serverHostName, $context.serverIpAddress, $context.serverPort */ STANDARD_IRC_CONNECTION_TARGET_PARAMETER( @@ -171,7 +255,7 @@ STANDARD_IRC_CONNECTION_TARGET_PARAMETER( returns nothing. If the specified IRC context is not currently connected then this function returns nothing. @seealso: - $context.serverName, $context.serverIpAddress + $context.serverHostName, $context.serverIpAddress */ STANDARD_IRC_CONNECTION_TARGET_PARAMETER( @@ -198,7 +282,7 @@ STANDARD_IRC_CONNECTION_TARGET_PARAMETER( If the irc_context_id specification is not valid then this function returns nothing. @seealso: - $context.serverName, $context.serverIpAddress + $context.serverHostName, $context.serverIpAddress */ static bool context_kvs_fnc_state(KviKvsModuleFunctionCall * c) @@ -250,7 +334,7 @@ static bool context_kvs_fnc_state(KviKvsModuleFunctionCall * c) Print the names of the currently connected servers [example] foreach(%ic,$context.list) - echo "IRC Context" %ic ": " $context.serverName + echo "IRC Context" %ic ": " $context.serverHostName [/example] */ @@ -275,10 +359,13 @@ static bool context_kvs_fnc_list(KviKvsModuleFunctionCall * c) static bool context_module_init(KviModule * m) { - KVSM_REGISTER_FUNCTION(m,"serverName",context_kvs_fnc_serverName); + KVSM_REGISTER_FUNCTION(m,"serverHostName",context_kvs_fnc_serverHostName); KVSM_REGISTER_FUNCTION(m,"serverIpAddress",context_kvs_fnc_serverIpAddress); KVSM_REGISTER_FUNCTION(m,"serverPort",context_kvs_fnc_serverPort); + KVSM_REGISTER_FUNCTION(m,"serverIsIPV6",context_kvs_fnc_serverIsIPV6); + KVSM_REGISTER_FUNCTION(m,"serverIsSSL",context_kvs_fnc_serverIsSSL); KVSM_REGISTER_FUNCTION(m,"serverPassword",context_kvs_fnc_serverPassword); + KVSM_REGISTER_FUNCTION(m,"networkName",context_kvs_fnc_networkName); KVSM_REGISTER_FUNCTION(m,"state",context_kvs_fnc_state); KVSM_REGISTER_FUNCTION(m,"list",context_kvs_fnc_list); diff --git a/src/modules/help/index.cpp b/src/modules/help/index.cpp index 540273d0e..d1c629793 100755 --- a/src/modules/help/index.cpp +++ b/src/modules/help/index.cpp @@ -69,23 +69,15 @@ #include -#ifndef COMPILE_USE_QT4 -int TermList::compareItems( QPtrCollection::Item i1, QPtrCollection::Item i2 ) +int kvi_compare(const Term * p1,const Term * p2) { - - if( ( (Term*)i1 )->frequency == ( (Term*)i2 )->frequency ) - - return 0; - - if( ( (Term*)i1 )->frequency < ( (Term*)i2 )->frequency ) - - return -1; - - return 1; - + if(p1->frequency == p2->frequency) + return 0; + if(p1->frequency < p2->frequency) + return -1; + return 1; } -#endif QDataStream &operator>>( QDataStream &s, Document &l ) diff --git a/src/modules/help/index.h b/src/modules/help/index.h index fc8ab72a9..3d2abd996 100755 --- a/src/modules/help/index.h +++ b/src/modules/help/index.h @@ -116,14 +116,9 @@ struct Term { KviValueListdocuments; }; -class TermList : public KviPtrList -{ -public: - TermList() : KviPtrList() {} -#ifndef COMPILE_USE_QT4 - int compareItems( QPtrCollection::Item i1, QPtrCollection::Item i2 ); -#endif -}; + + +#define TermList KviPtrList #endif diff --git a/src/modules/list/listwindow.cpp b/src/modules/list/listwindow.cpp index a4b23510c..6594d878f 100644 --- a/src/modules/list/listwindow.cpp +++ b/src/modules/list/listwindow.cpp @@ -346,8 +346,9 @@ void KviListWindow::exportList() QString szFile; if(connection()) { + QString szDate = QDateTime::currentDateTime().toString("d MMM yyyy hh-mm"); KviQString::sprintf(szFile,__tr2qs("Channel list for %Q - %Q"), - &(connection()->networkName()),&(QDateTime::currentDateTime().toString("d MMM yyyy hh-mm"))); + &(connection()->networkName()),&(szDate)); } else { szFile = __tr2qs("Channel list"); } diff --git a/src/modules/logview/logviewmdiwindow.cpp b/src/modules/logview/logviewmdiwindow.cpp index c282c4c49..8571761cb 100644 --- a/src/modules/logview/logviewmdiwindow.cpp +++ b/src/modules/logview/logviewmdiwindow.cpp @@ -226,7 +226,7 @@ void KviLogViewMDIWindow::setupItemList() { m_pListView->clear(); KviLogFile *pFile; - m_logList.begin(); + //m_logList.begin(); KviLogListViewItem *pLastCategory=0; KviLogListViewItemFolder *pLastGroupItem; QString szLastGroup; diff --git a/src/modules/my/libkvimy.cpp b/src/modules/my/libkvimy.cpp index e76ebf0f6..b1c5dcafc 100644 --- a/src/modules/my/libkvimy.cpp +++ b/src/modules/my/libkvimy.cpp @@ -340,6 +340,10 @@ static bool my_kvs_fnc_serverIsSSL(KviKvsModuleFunctionCall * c) If the irc context is not connected then an empty string is returned.[br] If is specified this function returns acts as it was called in that irc_context.[br] + Please note that this function returns the name of the server as reported + by the server itself. Some servers report a bogus value for this field. + You should take a look at $context.serverIpAddress or $context.serverHostName + if you want a value that can be used to really reconnect to this server. */ static bool my_kvs_fnc_server(KviKvsModuleFunctionCall * c) diff --git a/src/modules/notifier/notifierwindowtabs.cpp b/src/modules/notifier/notifierwindowtabs.cpp index 3b778ecc1..cca66d387 100644 --- a/src/modules/notifier/notifierwindowtabs.cpp +++ b/src/modules/notifier/notifierwindowtabs.cpp @@ -371,17 +371,17 @@ void KviNotifierWindowTabs::prev() if(!m_pTabFocused)return; KviNotifierWindowTab * tab; - QPtrListIterator tabIterator (m_tabPtrList); + KviPtrListIterator tabIterator (m_tabPtrList); tab = m_tabMap[m_pTabFocused->wnd()]; - tabIterator.atFirst(); + tabIterator.moveFirst(); while ((tabIterator.current()) != tab) { ++tabIterator; } - if (!tabIterator.atFirst()) { + if (!tabIterator.moveFirst()) { --tabIterator; tab = tabIterator.current(); setFocusOn(tab); @@ -394,15 +394,15 @@ void KviNotifierWindowTabs::next() if(!m_pTabFocused)return; KviNotifierWindowTab * tab; - QPtrListIterator tabIterator (m_tabPtrList); + KviPtrListIterator tabIterator (m_tabPtrList); tab = m_tabMap[m_pTabFocused->wnd()]; - tabIterator.atFirst(); + tabIterator.moveFirst(); while ((tabIterator.current()) != tab) { ++tabIterator; } - if (!tabIterator.atLast()) { + if (!tabIterator.moveLast()) { ++tabIterator; tab = tabIterator.current(); setFocusOn(tab); @@ -514,9 +514,7 @@ void KviNotifierWindowTabs::setFocusOn(KviNotifierWindowTab * tab) m_pTabFocused = tab; if(m_pTabFocused)m_pTabFocused->setFocused(); - if (m_lastVisitedTabPtrList.containsRef(tab)) { - m_lastVisitedTabPtrList.removeRef(tab); - } + m_lastVisitedTabPtrList.removeRef(tab); m_lastVisitedTabPtrList.insert(0, tab); @@ -554,14 +552,14 @@ void KviNotifierWindowTabs::draw(QPainter * p) m_pPainter->drawPixmap(m_rct.width()-m_pixDX.width(),0,m_pixDX); m_pPainter->drawTiledPixmap(m_pixSX.width(),0,m_rct.width()-m_pixSX.width()-m_pixDX.width(),m_rct.height(),m_pixBKG); - QPtrListIterator tabIterator (m_tabPtrList); + KviPtrListIterator tabIterator (m_tabPtrList); //m_tabPtrList.findRef(m_tabMap[m_pTabFocused->wnd()]); // QMap::Iterator tab; KviNotifierWindowTab * tab; //for (tab = m_tabMap.begin(); tab != m_tabMap.end() && !isBigger; tab++ ) - tabIterator.toFirst(); + tabIterator.moveFirst(); int i = 0; while(m_iTabToStartFrom!=i) { @@ -694,9 +692,9 @@ void KviNotifierWindowTabs::closeTab(KviWindow * pWnd, KviNotifierWindowTab * pT } else { if (m_lastVisitedTabPtrList.count()) { - m_pTabFocused = m_lastVisitedTabPtrList.getFirst(); + m_pTabFocused = m_lastVisitedTabPtrList.first(); } else { - m_pTabFocused = m_tabPtrList.getLast(); + m_pTabFocused = m_tabPtrList.last(); } m_pTabFocused->setFocused(true); diff --git a/src/modules/notifier/notifierwindowtabs.h b/src/modules/notifier/notifierwindowtabs.h index 221a834ed..8b92eb091 100644 --- a/src/modules/notifier/notifierwindowtabs.h +++ b/src/modules/notifier/notifierwindowtabs.h @@ -37,14 +37,6 @@ #include "notifiermessage.h" -#ifdef COMPILE_USE_QT4 - #define QPtrList Q3PtrList - #define QPtrListIterator Q3PtrListIterator - #include -#else - #include - //#include -#endif class QPainter; class KviWindow; @@ -149,8 +141,8 @@ private: QPoint m_pnt; QMap m_tabMap; - QPtrList m_tabPtrList; - QPtrList m_lastVisitedTabPtrList; + KviPtrList m_tabPtrList; + KviPtrList m_lastVisitedTabPtrList; QFont * m_pFocusedFont; QFont * m_pUnfocusedFont; diff --git a/src/modules/objects/class_list.cpp b/src/modules/objects/class_list.cpp index d51daf33e..d798cad2f 100644 --- a/src/modules/objects/class_list.cpp +++ b/src/modules/objects/class_list.cpp @@ -261,9 +261,9 @@ bool KviKvsObject_list::function_removeCurrent(KviKvsObjectFunctionCall *c) c->returnValue()->setBoolean(false); return true; } - if(m_pDataList->currentNode()) + if(m_pDataList->current()) { - m_pDataList->removeNode(m_pDataList->currentNode()); + m_pDataList->removeCurrent(); c->returnValue()->setBoolean(true); } else { c->returnValue()->setBoolean(false); @@ -355,6 +355,12 @@ bool KviKvsObject_list::function_clear(KviKvsObjectFunctionCall *c) m_pDataList->clear(); return true; } + +inline int kvi_compare(const KviKvsVariant * p1,const KviKvsVariant * p2) +{ + return p1->compare(p2); +} + bool KviKvsObject_list::function_sort(KviKvsObjectFunctionCall *c) { if(!m_pDataList)return true; diff --git a/src/modules/url/libkviurl.cpp b/src/modules/url/libkviurl.cpp index f979da4fb..a7c1d874e 100644 --- a/src/modules/url/libkviurl.cpp +++ b/src/modules/url/libkviurl.cpp @@ -17,7 +17,6 @@ // Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // - #include "kvi_styled_controls.h" #include "kvi_module.h" #include "libkviurl.h" @@ -213,11 +212,11 @@ void UrlDialog::remove() QMessageBox::warning(0,__tr2qs("Warning - KVIrc"),__tr2qs("Select an URL."),QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); return; } + for(KviUrl *tmp=g_pList->first();tmp;tmp=g_pList->next()) { if (tmp->url == m_pUrlList->currentItem()->text(0)) { - g_pList->find(tmp); - g_pList->remove(); + g_pList->removeRef(tmp); m_pUrlList->takeItem(m_pUrlList->currentItem()); return; } @@ -468,7 +467,11 @@ void BanFrame::removeBan() KviStr item(m_pBanList->text(i).utf8().data()); for(KviStr *tmp=g_pBanList->first();tmp;tmp=g_pBanList->next()) { - if (*tmp == item) g_pBanList->remove(); + if (*tmp == item) + { + g_pBanList->removeCurrent(); + return; + } } m_pBanList->removeItem(i); -- cgit v1.3.1-10-gc9f91