From 69cac65817d949cda2672ec4f0aa73d5e66a0ba1 Mon Sep 17 00:00:00 2001 From: tpearson Date: Wed, 22 Jun 2011 00:30:31 +0000 Subject: TQt4 port kdenetwork This enables compilation under both Qt3 and Qt4 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1237912 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kopete/plugins/history/historylogger.cpp | 112 +++++++++++++++---------------- 1 file changed, 56 insertions(+), 56 deletions(-) (limited to 'kopete/plugins/history/historylogger.cpp') diff --git a/kopete/plugins/history/historylogger.cpp b/kopete/plugins/history/historylogger.cpp index 96f4d6dc..714fe966 100644 --- a/kopete/plugins/history/historylogger.cpp +++ b/kopete/plugins/history/historylogger.cpp @@ -37,15 +37,15 @@ #include "kopetechatsession.h" // ----------------------------------------------------------------------------- -HistoryLogger::HistoryLogger( Kopete::MetaContact *m, TQObject *parent, const char *name ) - : TQObject(parent, name) +HistoryLogger::HistoryLogger( Kopete::MetaContact *m, TQObject *tqparent, const char *name ) + : TQObject(tqparent, name) { m_saveTimer=0L; m_saveTimerTime=0; m_metaContact=m; m_hideOutgoing=false; m_cachedMonth=-1; - m_realMonth=TQDate::currentDate().month(); + m_realMonth=TQDate::tqcurrentDate().month(); m_oldSens=Default; //the contact may be destroyed, for example, if the contact changes its metacontact @@ -55,15 +55,15 @@ HistoryLogger::HistoryLogger( Kopete::MetaContact *m, TQObject *parent, const c } -HistoryLogger::HistoryLogger( Kopete::Contact *c, TQObject *parent, const char *name ) - : TQObject(parent, name) +HistoryLogger::HistoryLogger( Kopete::Contact *c, TQObject *tqparent, const char *name ) + : TQObject(tqparent, name) { m_saveTimer=0L; m_saveTimerTime=0; m_cachedMonth=-1; m_metaContact=c->metaContact(); m_hideOutgoing=false; - m_realMonth=TQDate::currentDate().month(); + m_realMonth=TQDate::tqcurrentDate().month(); m_oldSens=Default; //the contact may be destroyed, for example, if the contact changes its metacontact @@ -107,14 +107,14 @@ void HistoryLogger::setCurrentMonth(int month) TQDomDocument HistoryLogger::getDocument(const Kopete::Contact *c, unsigned int month , bool canLoad , bool* contain) { - if(m_realMonth!=TQDate::currentDate().month()) + if(m_realMonth!=TQDate::tqcurrentDate().month()) { //We changed month, our indice are not correct anymore, clean memory. // or we will see what i called "the 31 midnight bug"(TM) :-) -Olivier m_documents.clear(); m_cachedMonth=-1; m_currentMonth++; //Not usre it's ok, but should work; m_oldMonth++; // idem - m_realMonth=TQDate::currentDate().month(); + m_realMonth=TQDate::tqcurrentDate().month(); } if(!m_metaContact) @@ -125,7 +125,7 @@ TQDomDocument HistoryLogger::getDocument(const Kopete::Contact *c, unsigned int return TQDomDocument(); } - if(!m_metaContact->contacts().contains(c)) + if(!m_metaContact->contacts().tqcontains(c)) { if(contain) *contain=false; @@ -133,11 +133,11 @@ TQDomDocument HistoryLogger::getDocument(const Kopete::Contact *c, unsigned int } TQMap documents = m_documents[c]; - if (documents.contains(month)) + if (documents.tqcontains(month)) return documents[month]; - TQDomDocument doc = getDocument(c, TQDate::currentDate().addMonths(0-month), canLoad, contain); + TQDomDocument doc = getDocument(c, TQDate::tqcurrentDate().addMonths(0-month), canLoad, contain); documents.insert(month, doc); m_documents[c]=documents; @@ -156,7 +156,7 @@ TQDomDocument HistoryLogger::getDocument(const Kopete::Contact *c, const TQDate return TQDomDocument(); } - if(!m_metaContact->contacts().contains(c)) + if(!m_metaContact->contacts().tqcontains(c)) { if(contain) *contain=false; @@ -170,7 +170,7 @@ TQDomDocument HistoryLogger::getDocument(const Kopete::Contact *c, const TQDate return TQDomDocument(); } - QString FileName = getFileName(c, date); + TQString FileName = getFileName(c, date); TQDomDocument doc( "Kopete-History" ); @@ -223,7 +223,7 @@ void HistoryLogger::appendMessage( const Kopete::Message &msg , const Kopete::Co } - if(!c || !m_metaContact->contacts().contains(c) ) + if(!c || !m_metaContact->contacts().tqcontains(c) ) { /*TQPtrList contacts= m_metaContact->contacts(); TQPtrListIterator it( contacts ); @@ -253,8 +253,8 @@ void HistoryLogger::appendMessage( const Kopete::Message &msg , const Kopete::Co TQDomElement headElem = doc.createElement( "head" ); docElem.appendChild( headElem ); TQDomElement dateElem = doc.createElement( "date" ); - dateElem.setAttribute( "year", TQString::number(TQDate::currentDate().year()) ); - dateElem.setAttribute( "month", TQString::number(TQDate::currentDate().month()) ); + dateElem.setAttribute( "year", TQString::number(TQDate::tqcurrentDate().year()) ); + dateElem.setAttribute( "month", TQString::number(TQDate::tqcurrentDate().month()) ); headElem.appendChild(dateElem); TQDomElement myselfElem = doc.createElement( "contact" ); myselfElem.setAttribute( "type", "myself" ); @@ -280,7 +280,7 @@ void HistoryLogger::appendMessage( const Kopete::Message &msg , const Kopete::Co // On hight-traffic channel, saving can take lots of CPU. (because the file is big) // So i wait a time proportional to the time needed to save.. - const TQString filename=getFileName(c,TQDate::currentDate()); + const TQString filename=getFileName(c,TQDate::tqcurrentDate()); if(!m_toSaveFileName.isEmpty() && m_toSaveFileName != filename) { //that mean the contact or the month has changed, save it now. saveToDisk(); @@ -316,14 +316,14 @@ void HistoryLogger::saveToDisk() m_toSaveDocument.save( *stream, 1 ); file.close(); - m_saveTimerTime=QMIN(t.elapsed()*1000, 300000); + m_saveTimerTime=TQMIN(t.elapsed()*1000, 300000); //a time 1000 times supperior to the time needed to save. but with a upper limit of 5 minutes //on a my machine, (2.4Ghz, but old HD) it should take about 10 ms to save the file. // So that would mean save every 10 seconds, which seems to be ok. // But it may take 500 ms if the file to save becomes too big (1Mb). kdDebug(14310) << k_funcinfo << m_toSaveFileName << " saved in " << t.elapsed() << " ms " < HistoryLogger::readMessages(TQDate date) to.append( dir==Kopete::Message::Inbound ? (*it)->account()->myself() : *it ); Kopete::Message msg(dt, from, to, msgElem2.text(), dir); - msg.setBody( TQString::fromLatin1("%2") - .arg( dt.toString(Qt::LocalDate), msg.escapedBody() ), + msg.setBody( TQString::tqfromLatin1("%2") + .tqarg( dt.toString(Qt::LocalDate), msg.escapedBody() ), Kopete::Message::RichText); @@ -403,7 +403,7 @@ TQValueList HistoryLogger::readMessages(TQDate date) TQValueList HistoryLogger::readMessages(unsigned int lines, const Kopete::Contact *c, Sens sens, bool reverseOrder, bool colorize) { - //TQDate dd = TQDate::currentDate().addMonths(0-m_currentMonth); + //TQDate dd = TQDate::tqcurrentDate().addMonths(0-m_currentMonth); TQValueList messages; @@ -418,7 +418,7 @@ TQValueList HistoryLogger::readMessages(unsigned int lines, return messages; } - if(c && !m_metaContact->contacts().contains(c) ) + if(c && !m_metaContact->contacts().tqcontains(c) ) return messages; if(sens ==0 ) //if no sens are selected, just continue in the previous sens @@ -473,7 +473,7 @@ TQValueList HistoryLogger::readMessages(unsigned int lines, // date, this date will bocomes the limit. TQDomNode n; - if(m_currentElements.contains(*it)) + if(m_currentElements.tqcontains(*it)) n=m_currentElements[*it]; else //there is not yet "next message" register, so we will take the first (for the current month) { @@ -490,7 +490,7 @@ TQValueList HistoryLogger::readMessages(unsigned int lines, if( !msgElem2.isNull() && msgElem2.tagName()=="msg") { rxTime.search(msgElem2.attribute("time")); - TQDate d=TQDate::currentDate().addMonths(0-m_currentMonth); + TQDate d=TQDate::tqcurrentDate().addMonths(0-m_currentMonth); TQDateTime dt( TQDate(d.year() , d.month() , rxTime.cap(1).toUInt()), TQTime( rxTime.cap(2).toUInt() , rxTime.cap(3).toUInt(), rxTime.cap(5).toUInt() ) ); if(!timestamp.isValid() || ((sens==Chronological )? dt < timestamp : dt > timestamp) ) { @@ -512,7 +512,7 @@ TQValueList HistoryLogger::readMessages(unsigned int lines, } else //we don't have to merge the history. just take the next item in the contact { - if(m_currentElements.contains(currentContact)) + if(m_currentElements.tqcontains(currentContact)) msgElem=m_currentElements[currentContact]; else { @@ -572,7 +572,7 @@ TQValueList HistoryLogger::readMessages(unsigned int lines, if(!m_hideOutgoing || dir != Kopete::Message::Outbound) { //parse only if we don't hide it - if( m_filter.isNull() || ( m_filterRegExp? msgElem.text().contains(TQRegExp(m_filter,m_filterCaseSensitive)) : msgElem.text().contains(m_filter,m_filterCaseSensitive) )) + if( m_filter.isNull() || ( m_filterRegExp? msgElem.text().tqcontains(TQRegExp(m_filter,m_filterCaseSensitive)) : msgElem.text().tqcontains(m_filter,m_filterCaseSensitive) )) { TQString f=msgElem.attribute("from" ); const Kopete::Contact *from=(f.isNull() || !currentContact) ? 0L : currentContact->account()->contacts()[f]; @@ -587,23 +587,23 @@ TQValueList HistoryLogger::readMessages(unsigned int lines, { //parse timestamp only if it was not already parsed rxTime.search(msgElem.attribute("time")); - TQDate d=TQDate::currentDate().addMonths(0-m_currentMonth); + TQDate d=TQDate::tqcurrentDate().addMonths(0-m_currentMonth); timestamp=TQDateTime( TQDate(d.year() , d.month() , rxTime.cap(1).toUInt()), TQTime( rxTime.cap(2).toUInt() , rxTime.cap(3).toUInt() , rxTime.cap(5).toUInt() ) ); } Kopete::Message msg(timestamp, from, to, msgElem.text(), dir); if (colorize) { - msg.setBody( TQString::fromLatin1("%3") - .arg( fgColor.name(), timestamp.toString(Qt::LocalDate), msg.escapedBody() ), + msg.setBody( TQString::tqfromLatin1("%3") + .tqarg( fgColor.name(), timestamp.toString(Qt::LocalDate), msg.escapedBody() ), Kopete::Message::RichText ); msg.setFg( fgColor ); } else { - msg.setBody( TQString::fromLatin1("%2") - .arg( timestamp.toString(Qt::LocalDate), msg.escapedBody() ), + msg.setBody( TQString::tqfromLatin1("%2") + .tqarg( timestamp.toString(Qt::LocalDate), msg.escapedBody() ), Kopete::Message::RichText ); } @@ -635,7 +635,7 @@ TQValueList HistoryLogger::readMessages(unsigned int lines, TQRegExp rx("(\\d+) (\\d+):(\\d+):(\\d+)"); rx.search(msgElem.attribute("time")); - TQDate d = TQDate::currentDate().addMonths(0-m_currentMonth); + TQDate d = TQDate::tqcurrentDate().addMonths(0-m_currentMonth); timestamp = TQDateTime( TQDate(d.year(), d.month(), rx.cap(1).toUInt()), TQTime( rx.cap(2).toUInt(), rx.cap(3).toUInt() ) ); @@ -663,25 +663,25 @@ TQValueList HistoryLogger::readMessages(unsigned int lines, TQString HistoryLogger::getFileName(const Kopete::Contact* c, TQDate date) { - TQString name = c->protocol()->pluginId().replace( TQRegExp( TQString::fromLatin1( "[./~?*]" ) ), TQString::fromLatin1( "-" ) ) + - TQString::fromLatin1( "/" ) + - c->account()->accountId().replace( TQRegExp( TQString::fromLatin1( "[./~?*]" ) ), TQString::fromLatin1( "-" ) ) + - TQString::fromLatin1( "/" ) + - c->contactId().replace( TQRegExp( TQString::fromLatin1( "[./~?*]" ) ), TQString::fromLatin1( "-" ) ) + + TQString name = c->protocol()->pluginId().tqreplace( TQRegExp( TQString::tqfromLatin1( "[./~?*]" ) ), TQString::tqfromLatin1( "-" ) ) + + TQString::tqfromLatin1( "/" ) + + c->account()->accountId().tqreplace( TQRegExp( TQString::tqfromLatin1( "[./~?*]" ) ), TQString::tqfromLatin1( "-" ) ) + + TQString::tqfromLatin1( "/" ) + + c->contactId().tqreplace( TQRegExp( TQString::tqfromLatin1( "[./~?*]" ) ), TQString::tqfromLatin1( "-" ) ) + date.toString(".yyyyMM"); - TQString filename=locateLocal( "data", TQString::fromLatin1( "kopete/logs/" ) + name+ TQString::fromLatin1( ".xml" ) ) ; + TQString filename=locateLocal( "data", TQString::tqfromLatin1( "kopete/logs/" ) + name+ TQString::tqfromLatin1( ".xml" ) ) ; //Check if there is a kopete 0.7.x file TQFileInfo fi(filename); if(!fi.exists()) { - name = c->protocol()->pluginId().replace( TQRegExp( TQString::fromLatin1( "[./~?*]" ) ), TQString::fromLatin1( "-" ) ) + - TQString::fromLatin1( "/" ) + - c->contactId().replace( TQRegExp( TQString::fromLatin1( "[./~?*]" ) ), TQString::fromLatin1( "-" ) ) + + name = c->protocol()->pluginId().tqreplace( TQRegExp( TQString::tqfromLatin1( "[./~?*]" ) ), TQString::tqfromLatin1( "-" ) ) + + TQString::tqfromLatin1( "/" ) + + c->contactId().tqreplace( TQRegExp( TQString::tqfromLatin1( "[./~?*]" ) ), TQString::tqfromLatin1( "-" ) ) + date.toString(".yyyyMM"); - TQString filename2=locateLocal( "data", TQString::fromLatin1( "kopete/logs/" ) + name+ TQString::fromLatin1( ".xml" ) ) ; + TQString filename2=locateLocal( "data", TQString::tqfromLatin1( "kopete/logs/" ) + name+ TQString::tqfromLatin1( ".xml" ) ) ; TQFileInfo fi2(filename2); if(fi2.exists()) @@ -702,20 +702,20 @@ unsigned int HistoryLogger::getFirstMonth(const Kopete::Contact *c) // BEGIN check if there are Kopete 0.7.x TQDir d1(locateLocal("data",TQString("kopete/logs/")+ - c->protocol()->pluginId().replace( TQRegExp(TQString::fromLatin1("[./~?*]")),TQString::fromLatin1("-")) + c->protocol()->pluginId().tqreplace( TQRegExp(TQString::tqfromLatin1("[./~?*]")),TQString::tqfromLatin1("-")) )); d1.setFilter( TQDir::Files | TQDir::NoSymLinks ); d1.setSorting( TQDir::Name ); - const QFileInfoList *list1 = d1.entryInfoList(); - QFileInfoListIterator it1( *list1 ); + const TQFileInfoList *list1 = d1.entryInfoList(); + TQFileInfoListIterator it1( *list1 ); while ( (fi = it1.current()) != 0 ) { - if(fi->fileName().contains(c->contactId().replace( TQRegExp( TQString::fromLatin1( "[./~?*]" ) ), TQString::fromLatin1( "-" ) ))) + if(fi->fileName().tqcontains(c->contactId().tqreplace( TQRegExp( TQString::tqfromLatin1( "[./~?*]" ) ), TQString::tqfromLatin1( "-" ) ))) { rx.search(fi->fileName()); - int result = 12*(TQDate::currentDate().year() - rx.cap(1).toUInt()) +TQDate::currentDate().month() - rx.cap(2).toUInt(); + int result = 12*(TQDate::tqcurrentDate().year() - rx.cap(1).toUInt()) +TQDate::tqcurrentDate().month() - rx.cap(2).toUInt(); if(result < 0) { @@ -730,22 +730,22 @@ unsigned int HistoryLogger::getFirstMonth(const Kopete::Contact *c) TQDir d(locateLocal("data",TQString("kopete/logs/")+ - c->protocol()->pluginId().replace( TQRegExp(TQString::fromLatin1("[./~?*]")),TQString::fromLatin1("-")) + - TQString::fromLatin1( "/" ) + - c->account()->accountId().replace( TQRegExp( TQString::fromLatin1( "[./~?*]" ) ), TQString::fromLatin1( "-" ) ) + c->protocol()->pluginId().tqreplace( TQRegExp(TQString::tqfromLatin1("[./~?*]")),TQString::tqfromLatin1("-")) + + TQString::tqfromLatin1( "/" ) + + c->account()->accountId().tqreplace( TQRegExp( TQString::tqfromLatin1( "[./~?*]" ) ), TQString::tqfromLatin1( "-" ) ) )); d.setFilter( TQDir::Files | TQDir::NoSymLinks ); d.setSorting( TQDir::Name ); - const QFileInfoList *list = d.entryInfoList(); - QFileInfoListIterator it( *list ); + const TQFileInfoList *list = d.entryInfoList(); + TQFileInfoListIterator it( *list ); while ( (fi = it.current()) != 0 ) { - if(fi->fileName().contains(c->contactId().replace( TQRegExp( TQString::fromLatin1( "[./~?*]" ) ), TQString::fromLatin1( "-" ) ))) + if(fi->fileName().tqcontains(c->contactId().tqreplace( TQRegExp( TQString::tqfromLatin1( "[./~?*]" ) ), TQString::tqfromLatin1( "-" ) ))) { rx.search(fi->fileName()); - int result = 12*(TQDate::currentDate().year() - rx.cap(1).toUInt()) +TQDate::currentDate().month() - rx.cap(2).toUInt(); + int result = 12*(TQDate::tqcurrentDate().year() - rx.cap(1).toUInt()) +TQDate::tqcurrentDate().month() - rx.cap(2).toUInt(); if(result < 0) { kdWarning(14310) << k_funcinfo << "Kopete only found log file made in the future. Check your date!" << endl; @@ -838,7 +838,7 @@ TQValueList HistoryLogger::getDaysForMonth(TQDate date) pos += rxTime.matchedLength(); int day=rxTime.capturedTexts()[1].toInt(); - if ( day !=lastDay && dayList.find(day) == dayList.end()) // avoid duplicates + if ( day !=lastDay && dayList.tqfind(day) == dayList.end()) // avoid duplicates { dayList.append(rxTime.capturedTexts()[1].toInt()); lastDay=day; -- cgit v1.2.1