diff options
Diffstat (limited to 'kopete/plugins/statistics/statisticscontact.cpp')
-rw-r--r-- | kopete/plugins/statistics/statisticscontact.cpp | 128 |
1 files changed, 64 insertions, 64 deletions
diff --git a/kopete/plugins/statistics/statisticscontact.cpp b/kopete/plugins/statistics/statisticscontact.cpp index e9068fe5..821b8f59 100644 --- a/kopete/plugins/statistics/statisticscontact.cpp +++ b/kopete/plugins/statistics/statisticscontact.cpp @@ -16,8 +16,8 @@ #include <stdlib.h> -#include <qvaluelist.h> -#include <quuid.h> +#include <tqvaluelist.h> +#include <tquuid.h> #include <kdebug.h> #include <klocale.h> @@ -31,7 +31,7 @@ StatisticsContact::StatisticsContact(Kopete::MetaContact *mc, StatisticsDB *db) : m_metaContact(mc),m_db(db), m_oldStatus(Kopete::OnlineStatus::Unknown) { m_isChatWindowOpen = false; - m_oldStatusDateTime = QDateTime::currentDateTime(); + m_oldStatusDateTime = TQDateTime::currentDateTime(); // Last*Changed are always false at start m_timeBetweenTwoMessagesChanged = false; @@ -48,9 +48,9 @@ StatisticsContact::~StatisticsContact() if (m_statisticsContactId.isEmpty()) return; - commonStatsSave("timebetweentwomessages",QString::number(m_timeBetweenTwoMessages), - QString::number(m_timeBetweenTwoMessagesOn), m_timeBetweenTwoMessagesChanged); - commonStatsSave("messagelength",QString::number(m_messageLength), QString::number(m_messageLengthOn), m_messageLengthChanged); + commonStatsSave("timebetweentwomessages",TQString::number(m_timeBetweenTwoMessages), + TQString::number(m_timeBetweenTwoMessagesOn), m_timeBetweenTwoMessagesChanged); + commonStatsSave("messagelength",TQString::number(m_messageLength), TQString::number(m_messageLengthOn), m_messageLengthChanged); commonStatsSave("lasttalk", m_lastTalk.toString(), "", m_lastTalkChanged); commonStatsSave("lastpresent", m_lastPresent.toString(), "", m_lastPresentChanged); } @@ -58,7 +58,7 @@ StatisticsContact::~StatisticsContact() void StatisticsContact::initialize(Kopete::Contact *c) { // Generate statisticsContactId or get it from database - QStringList buffer = m_db->query(QString("SELECT statisticid FROM contacts " + TQStringList buffer = m_db->query(TQString("SELECT statisticid FROM contacts " "WHERE contactid LIKE '%1';" ).arg(c->contactId())); @@ -66,7 +66,7 @@ void StatisticsContact::initialize(Kopete::Contact *c) { // Check if we don't have old data if ( !c->metaContact()->metaContactId().isEmpty() && - !m_db->query(QString("SELECT metacontactid FROM commonstats " + !m_db->query(TQString("SELECT metacontactid FROM commonstats " "WHERE metacontactid LIKE '%1';" ).arg(c->metaContact()->metaContactId())).isEmpty()) { @@ -80,7 +80,7 @@ void StatisticsContact::initialize(Kopete::Contact *c) } // Assign contactId to m_statisticsContactId - m_db->query(QString("INSERT INTO contacts (statisticid, contactid) VALUES('%1', '%2');" + m_db->query(TQString("INSERT INTO contacts (statisticid, contactid) VALUES('%1', '%2');" ).arg(m_statisticsContactId).arg(c->contactId())); } else @@ -94,8 +94,8 @@ void StatisticsContact::initialize(Kopete::Contact *c) commonStatsCheck("messagelength", m_messageLength, m_messageLengthOn, 0, 0); // Check for last talk - QString lastTalk; - QString dummy = ""; + TQString lastTalk; + TQString dummy = ""; commonStatsCheck("lasttalk", lastTalk, dummy); if (lastTalk.isEmpty()) { @@ -103,15 +103,15 @@ void StatisticsContact::initialize(Kopete::Contact *c) m_lastTalkChanged = true; } else - m_lastTalk = QDateTime::fromString(lastTalk); + m_lastTalk = TQDateTime::fromString(lastTalk); // Get last time a message was received - m_lastMessageReceived = QDateTime::currentDateTime(); + m_lastMessageReceived = TQDateTime::currentDateTime(); // Check for lastPresent - QString lastPresent = ""; + TQString lastPresent = ""; commonStatsCheck("lastpresent", lastPresent, dummy); if (lastPresent.isEmpty()) { @@ -119,7 +119,7 @@ void StatisticsContact::initialize(Kopete::Contact *c) m_lastPresentChanged = true; } else - m_lastPresent = QDateTime::fromString(lastPresent); + m_lastPresent = TQDateTime::fromString(lastPresent); } void StatisticsContact::contactAdded( Kopete::Contact *c ) @@ -127,12 +127,12 @@ void StatisticsContact::contactAdded( Kopete::Contact *c ) if ( !m_statisticsContactId.isEmpty() ) { // Check if contact is allready in database if not add it - if (m_db->query(QString("SELECT id FROM contacts " + if (m_db->query(TQString("SELECT id FROM contacts " "WHERE statisticid LIKE '%1' AND contactid LIKE '%2';" ).arg(m_statisticsContactId).arg(c->contactId())).isEmpty()) { // Assign contactId to m_statisticsContactId - m_db->query(QString("INSERT INTO contacts (statisticid, contactid) VALUES('%1', '%2');" + m_db->query(TQString("INSERT INTO contacts (statisticid, contactid) VALUES('%1', '%2');" ).arg(m_statisticsContactId).arg(c->contactId())); } kdDebug() << k_funcinfo << " m_statisticsContactId: " << m_statisticsContactId << endl; @@ -150,7 +150,7 @@ void StatisticsContact::contactRemoved( Kopete::Contact *c ) return; kdDebug() << k_funcinfo << " m_statisticsContactId: " << m_statisticsContactId << endl; - m_db->query(QString("DELETE FROM contacts WHERE statisticid LIKE '%1' AND contactid LIKE '%2';" + m_db->query(TQString("DELETE FROM contacts WHERE statisticid LIKE '%1' AND contactid LIKE '%2';" ).arg(m_statisticsContactId).arg(c->contactId())); } @@ -160,14 +160,14 @@ void StatisticsContact::removeFromDB() return; kdDebug() << k_funcinfo << " m_statisticsContactId: " << m_statisticsContactId << endl; - m_db->query(QString("DELETE FROM contacts WHERE statisticid LIKE '%1';").arg(m_statisticsContactId)); - m_db->query(QString("DELETE FROM contactstatus WHERE metacontactid LIKE '%1';").arg(m_statisticsContactId)); - m_db->query(QString("DELETE FROM commonstats WHERE metacontactid LIKE '%1';").arg(m_statisticsContactId)); + m_db->query(TQString("DELETE FROM contacts WHERE statisticid LIKE '%1';").arg(m_statisticsContactId)); + m_db->query(TQString("DELETE FROM contactstatus WHERE metacontactid LIKE '%1';").arg(m_statisticsContactId)); + m_db->query(TQString("DELETE FROM commonstats WHERE metacontactid LIKE '%1';").arg(m_statisticsContactId)); - m_statisticsContactId = QString::null; + m_statisticsContactId = TQString::null; } -void StatisticsContact::commonStatsSave(const QString name, const QString statVar1, const QString statVar2, const bool statVarChanged) +void StatisticsContact::commonStatsSave(const TQString name, const TQString statVar1, const TQString statVar2, const bool statVarChanged) { // Only update the database if there was a change if (!statVarChanged) return; @@ -175,28 +175,28 @@ void StatisticsContact::commonStatsSave(const QString name, const QString statVa if (m_statisticsContactId.isEmpty()) return; - m_db->query(QString("UPDATE commonstats SET statvalue1 = '%1', statvalue2='%2'" + m_db->query(TQString("UPDATE commonstats SET statvalue1 = '%1', statvalue2='%2'" "WHERE statname LIKE '%3' AND metacontactid LIKE '%4';").arg(statVar1).arg(statVar2).arg(name).arg(m_statisticsContactId)); } -void StatisticsContact::commonStatsCheck(const QString name, int& statVar1, int& statVar2, const int defaultValue1, const int defaultValue2) +void StatisticsContact::commonStatsCheck(const TQString name, int& statVar1, int& statVar2, const int defaultValue1, const int defaultValue2) { - QString a = QString::number(statVar1); - QString b = QString::number(statVar2); + TQString a = TQString::number(statVar1); + TQString b = TQString::number(statVar2); - commonStatsCheck(name, a, b, QString::number(defaultValue1), QString::number(defaultValue2)); + commonStatsCheck(name, a, b, TQString::number(defaultValue1), TQString::number(defaultValue2)); statVar1 = a.toInt(); statVar2 = b.toInt(); } -void StatisticsContact::commonStatsCheck(const QString name, QString& statVar1, QString& statVar2, const QString defaultValue1, const QString defaultValue2) +void StatisticsContact::commonStatsCheck(const TQString name, TQString& statVar1, TQString& statVar2, const TQString defaultValue1, const TQString defaultValue2) { if (m_statisticsContactId.isEmpty()) return; - QStringList buffer = m_db->query(QString("SELECT statvalue1,statvalue2 FROM commonstats WHERE statname LIKE '%1' AND metacontactid LIKE '%2';").arg(name, m_statisticsContactId)); + TQStringList buffer = m_db->query(TQString("SELECT statvalue1,statvalue2 FROM commonstats WHERE statname LIKE '%1' AND metacontactid LIKE '%2';").arg(name, m_statisticsContactId)); if (!buffer.isEmpty()) { statVar1 = buffer[0]; @@ -204,7 +204,7 @@ void StatisticsContact::commonStatsCheck(const QString name, QString& statVar1, } else { - m_db->query(QString("INSERT INTO commonstats (metacontactid, statname, statvalue1, statvalue2) VALUES('%1', '%2', 0, 0);").arg(m_statisticsContactId, name)); + m_db->query(TQString("INSERT INTO commonstats (metacontactid, statname, statvalue1, statvalue2) VALUES('%1', '%2', 0, 0);").arg(m_statisticsContactId, name)); statVar1 = defaultValue1; statVar2 = defaultValue2; } @@ -234,7 +234,7 @@ void StatisticsContact::commonStatsCheck(const QString name, QString& statVar1, void StatisticsContact::newMessageReceived(Kopete::Message& m) { kdDebug() << "statistics: new message received" << endl; - QDateTime currentDateTime = QDateTime::currentDateTime(); + TQDateTime currentDateTime = TQDateTime::currentDateTime(); if (m_timeBetweenTwoMessagesOn != -1 && m_isChatWindowOpen) { @@ -269,17 +269,17 @@ void StatisticsContact::onlineStatusChanged(Kopete::OnlineStatus::StatusType sta if (m_statisticsContactId.isEmpty()) return; - QDateTime currentDateTime = QDateTime::currentDateTime(); + TQDateTime currentDateTime = TQDateTime::currentDateTime(); /// We don't want to log if oldStatus is unknown /// the change could not be a real one; see StatisticsPlugin::slotMySelfOnlineStatusChanged if (m_oldStatus != Kopete::OnlineStatus::Unknown) { - kdDebug() << "statistics - status change for "<< metaContact()->metaContactId() << " : "<< QString::number(m_oldStatus) << endl; - m_db->query(QString("INSERT INTO contactstatus " + kdDebug() << "statistics - status change for "<< metaContact()->metaContactId() << " : "<< TQString::number(m_oldStatus) << endl; + m_db->query(TQString("INSERT INTO contactstatus " "(metacontactid, status, datetimebegin, datetimeend) " - "VALUES('%1', '%2', '%3', '%4'" ");").arg(m_statisticsContactId).arg(Kopete::OnlineStatus::statusTypeToString(m_oldStatus)).arg(QString::number(m_oldStatusDateTime.toTime_t())).arg(QString::number(currentDateTime.toTime_t()))); + "VALUES('%1', '%2', '%3', '%4'" ");").arg(m_statisticsContactId).arg(Kopete::OnlineStatus::statusTypeToString(m_oldStatus)).arg(TQString::number(m_oldStatusDateTime.toTime_t())).arg(TQString::number(currentDateTime.toTime_t()))); } if (m_oldStatus == Kopete::OnlineStatus::Online || m_oldStatus == Kopete::OnlineStatus::Away) @@ -294,12 +294,12 @@ void StatisticsContact::onlineStatusChanged(Kopete::OnlineStatus::StatusType sta } -bool StatisticsContact::wasStatus(QDateTime dt, Kopete::OnlineStatus::StatusType status) +bool StatisticsContact::wasStatus(TQDateTime dt, Kopete::OnlineStatus::StatusType status) { if (m_statisticsContactId.isEmpty()) return false; - QStringList values = m_db->query(QString("SELECT status, datetimebegin, datetimeend " + TQStringList values = m_db->query(TQString("SELECT status, datetimebegin, datetimeend " "FROM contactstatus WHERE metacontactid LIKE '%1' AND datetimebegin <= %2 AND datetimeend >= %3 " "AND status LIKE '%4' " "ORDER BY datetimebegin;" @@ -310,12 +310,12 @@ bool StatisticsContact::wasStatus(QDateTime dt, Kopete::OnlineStatus::StatusType return false; } -QString StatisticsContact::statusAt(QDateTime dt) +TQString StatisticsContact::statusAt(TQDateTime dt) { if (m_statisticsContactId.isEmpty()) return ""; - QStringList values = m_db->query(QString("SELECT status, datetimebegin, datetimeend " + TQStringList values = m_db->query(TQString("SELECT status, datetimebegin, datetimeend " "FROM contactstatus WHERE metacontactid LIKE '%1' AND datetimebegin <= %2 AND datetimeend >= %3 " "ORDER BY datetimebegin;" ).arg(m_statisticsContactId).arg(dt.toTime_t()).arg(dt.toTime_t())); @@ -324,28 +324,28 @@ QString StatisticsContact::statusAt(QDateTime dt) else return ""; } -QString StatisticsContact::mainStatusDate(const QDate& date) +TQString StatisticsContact::mainStatusDate(const TQDate& date) { if (m_statisticsContactId.isEmpty()) return ""; - QDateTime dt1(date, QTime(0,0,0)); - QDateTime dt2(date.addDays(1), QTime(0,0,0)); + TQDateTime dt1(date, TQTime(0,0,0)); + TQDateTime dt2(date.addDays(1), TQTime(0,0,0)); kdDebug() << "dt1:" << dt1.toString() << " dt2:" << dt2.toString() << endl; - QString request = QString("SELECT status, datetimebegin, datetimeend, metacontactid " + TQString request = TQString("SELECT status, datetimebegin, datetimeend, metacontactid " "FROM contactstatus WHERE metacontactid = '%1' AND " "(datetimebegin >= %2 AND datetimebegin <= %3 OR " "datetimeend >= %4 AND datetimeend <= %5) " "ORDER BY datetimebegin;" ).arg(m_statisticsContactId).arg(dt1.toTime_t()).arg(dt2.toTime_t()).arg(dt1.toTime_t()).arg(dt2.toTime_t()); kdDebug() << request << endl; - QStringList values = m_db->query(request); + TQStringList values = m_db->query(request); unsigned int online = 0, offline = 0, away = 0; for(uint i=0; i<values.count(); i+=4) { unsigned int datetimebegin = values[i+1].toInt(), datetimeend = values[i+2].toInt(); - kdDebug() << "statistics: id "<< values[i+3]<< " status " << values[i] << " datetimeend " << QString::number(datetimeend) << " datetimebegin " << QString::number(datetimebegin) << endl; + kdDebug() << "statistics: id "<< values[i+3]<< " status " << values[i] << " datetimeend " << TQString::number(datetimeend) << " datetimebegin " << TQString::number(datetimebegin) << endl; if (datetimebegin <= dt1.toTime_t()) datetimebegin = dt1.toTime_t(); if (datetimeend >= dt2.toTime_t()) datetimeend = dt2.toTime_t(); @@ -366,35 +366,35 @@ QString StatisticsContact::mainStatusDate(const QDate& date) return ""; } -// QDateTime StatisticsContact::nextOfflineEvent() +// TQDateTime StatisticsContact::nextOfflineEvent() // { // return nextEvent(Kopete::OnlineStatus::Offline); // } // -// QDateTime StatisticsContact::nextOnlineEvent() +// TQDateTime StatisticsContact::nextOnlineEvent() // { // return nextEvent(Kopete::OnlineStatus::Online); // } -// QDateTime StatisticsContact::nextEvent(const Kopete::OnlineStatus::StatusType& status) +// TQDateTime StatisticsContact::nextEvent(const Kopete::OnlineStatus::StatusType& status) // { // // } -QValueList<QTime> StatisticsContact::mainEvents(const Kopete::OnlineStatus::StatusType& status) +TQValueList<TQTime> StatisticsContact::mainEvents(const Kopete::OnlineStatus::StatusType& status) { - QStringList buffer; - QValueList<QTime> mainEvents; + TQStringList buffer; + TQValueList<TQTime> mainEvents; if (m_statisticsContactId.isEmpty()) return mainEvents; - QDateTime currentDateTime = QDateTime::currentDateTime(); - buffer = m_db->query(QString("SELECT datetimebegin, datetimeend, status FROM contactstatus WHERE metacontactid LIKE '%1' ORDER BY datetimebegin").arg(m_statisticsContactId)); + TQDateTime currentDateTime = TQDateTime::currentDateTime(); + buffer = m_db->query(TQString("SELECT datetimebegin, datetimeend, status FROM contactstatus WHERE metacontactid LIKE '%1' ORDER BY datetimebegin").arg(m_statisticsContactId)); // Only select the events for which the previous is not Unknown AND the status is status. - QStringList values; + TQStringList values; for (uint i=0; i<buffer.count(); i += 3) { if (buffer[i+2] == Kopete::OnlineStatus::statusTypeToString(status) @@ -409,7 +409,7 @@ QValueList<QTime> StatisticsContact::mainEvents(const Kopete::OnlineStatus::Stat // First we compute the average number of events/day : avEventsPerDay; int avEventsPerDay = 0; - QDateTime dt1, dt2; + TQDateTime dt1, dt2; dt1.setTime_t(values[0].toInt()); dt2.setTime_t(values[values.count()-1].toInt()); @@ -417,19 +417,19 @@ QValueList<QTime> StatisticsContact::mainEvents(const Kopete::OnlineStatus::Stat kdDebug() << "statistics: average events per day : " <<avEventsPerDay << endl; // We want to work on hours - QValueList<int> hoursValues; + TQValueList<int> hoursValues; for (uint i=0; i<values.count(); i++) { - QDateTime dt; + TQDateTime dt; dt.setTime_t(values[i].toInt()); - hoursValues.push_back(QTime(0, 0, 0).secsTo(dt.time())); + hoursValues.push_back(TQTime(0, 0, 0).secsTo(dt.time())); } // Sort the list qHeapSort(hoursValues); // Then we put some centroids (centroids in [0..24[) - QValueList<int> centroids; + TQValueList<int> centroids; int incr=qRound((double)hoursValues.count()/(double)avEventsPerDay); incr = incr ? incr : 1; for (uint i=0; i<hoursValues.count(); i+=incr) @@ -447,7 +447,7 @@ QValueList<QTime> StatisticsContact::mainEvents(const Kopete::OnlineStatus::Stat { kdDebug() << "statistics: new centroid : " << centroids[i] << endl; - QTime dt(0, 0, 0); + TQTime dt(0, 0, 0); dt = dt.addSecs(centroids[i]); mainEvents.push_back(dt); } @@ -456,12 +456,12 @@ QValueList<QTime> StatisticsContact::mainEvents(const Kopete::OnlineStatus::Stat return mainEvents; } -QValueList<int> StatisticsContact::computeCentroids(const QValueList<int>& centroids, const QValueList<int>& values) +TQValueList<int> StatisticsContact::computeCentroids(const TQValueList<int>& centroids, const TQValueList<int>& values) { kdDebug() << "statistics: enter compute centroids"<< endl; - QValueList<int> whichCentroid; // whichCentroid[i] = j <=> values[i] has centroid j for closest one - QValueList<int> newCentroids; + TQValueList<int> whichCentroid; // whichCentroid[i] = j <=> values[i] has centroid j for closest one + TQValueList<int> newCentroids; for (uint i=0; i<values.count(); i++) // Iterates over the values. For each one we need to get the closest centroid. { |