summaryrefslogtreecommitdiffstats
path: root/kopete/plugins/statistics/statisticscontact.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-22 00:30:31 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-22 00:30:31 +0000
commit69cac65817d949cda2672ec4f0aa73d5e66a0ba1 (patch)
tree073fde0496ea90eb5bf5cffe66a8da43a9f55fbc /kopete/plugins/statistics/statisticscontact.cpp
parent3467e6464beac3a162839bf7078e22e3a74d73e7 (diff)
downloadtdenetwork-69cac65817d949cda2672ec4f0aa73d5e66a0ba1.tar.gz
tdenetwork-69cac65817d949cda2672ec4f0aa73d5e66a0ba1.zip
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
Diffstat (limited to 'kopete/plugins/statistics/statisticscontact.cpp')
-rw-r--r--kopete/plugins/statistics/statisticscontact.cpp80
1 files changed, 40 insertions, 40 deletions
diff --git a/kopete/plugins/statistics/statisticscontact.cpp b/kopete/plugins/statistics/statisticscontact.cpp
index 821b8f59..c178b39b 100644
--- a/kopete/plugins/statistics/statisticscontact.cpp
+++ b/kopete/plugins/statistics/statisticscontact.cpp
@@ -28,10 +28,10 @@
#include "statisticscontact.h"
#include "statisticsdb.h"
-StatisticsContact::StatisticsContact(Kopete::MetaContact *mc, StatisticsDB *db) : m_metaContact(mc),m_db(db), m_oldStatus(Kopete::OnlineStatus::Unknown)
+StatisticsContact::StatisticsContact(Kopete::MetaContact *mc, StatisticsDB *db) : m_metaContact(mc),m_db(db), m_oldtqStatus(Kopete::OnlineStatus::Unknown)
{
m_isChatWindowOpen = false;
- m_oldStatusDateTime = TQDateTime::currentDateTime();
+ m_oldStatusDateTime = TQDateTime::tqcurrentDateTime();
// Last*Changed are always false at start
m_timeBetweenTwoMessagesChanged = false;
@@ -60,7 +60,7 @@ void StatisticsContact::initialize(Kopete::Contact *c)
// Generate statisticsContactId or get it from database
TQStringList buffer = m_db->query(TQString("SELECT statisticid FROM contacts "
"WHERE contactid LIKE '%1';"
- ).arg(c->contactId()));
+ ).tqarg(c->contactId()));
if (buffer.isEmpty())
{
@@ -68,7 +68,7 @@ void StatisticsContact::initialize(Kopete::Contact *c)
if ( !c->metaContact()->metaContactId().isEmpty() &&
!m_db->query(TQString("SELECT metacontactid FROM commonstats "
"WHERE metacontactid LIKE '%1';"
- ).arg(c->metaContact()->metaContactId())).isEmpty())
+ ).tqarg(c->metaContact()->metaContactId())).isEmpty())
{
// Use old style id
m_statisticsContactId = c->metaContact()->metaContactId();
@@ -76,12 +76,12 @@ void StatisticsContact::initialize(Kopete::Contact *c)
else
{
// Create new id
- m_statisticsContactId = QUuid::createUuid().toString();
+ m_statisticsContactId = TQUuid::createUuid().toString();
}
// Assign contactId to m_statisticsContactId
m_db->query(TQString("INSERT INTO contacts (statisticid, contactid) VALUES('%1', '%2');"
- ).arg(m_statisticsContactId).arg(c->contactId()));
+ ).tqarg(m_statisticsContactId).tqarg(c->contactId()));
}
else
{
@@ -107,7 +107,7 @@ void StatisticsContact::initialize(Kopete::Contact *c)
// Get last time a message was received
- m_lastMessageReceived = TQDateTime::currentDateTime();
+ m_lastMessageReceived = TQDateTime::tqcurrentDateTime();
// Check for lastPresent
@@ -129,11 +129,11 @@ void StatisticsContact::contactAdded( Kopete::Contact *c )
// Check if contact is allready in database if not add it
if (m_db->query(TQString("SELECT id FROM contacts "
"WHERE statisticid LIKE '%1' AND contactid LIKE '%2';"
- ).arg(m_statisticsContactId).arg(c->contactId())).isEmpty())
+ ).tqarg(m_statisticsContactId).tqarg(c->contactId())).isEmpty())
{
// Assign contactId to m_statisticsContactId
m_db->query(TQString("INSERT INTO contacts (statisticid, contactid) VALUES('%1', '%2');"
- ).arg(m_statisticsContactId).arg(c->contactId()));
+ ).tqarg(m_statisticsContactId).tqarg(c->contactId()));
}
kdDebug() << k_funcinfo << " m_statisticsContactId: " << m_statisticsContactId << endl;
}
@@ -151,7 +151,7 @@ void StatisticsContact::contactRemoved( Kopete::Contact *c )
kdDebug() << k_funcinfo << " m_statisticsContactId: " << m_statisticsContactId << endl;
m_db->query(TQString("DELETE FROM contacts WHERE statisticid LIKE '%1' AND contactid LIKE '%2';"
- ).arg(m_statisticsContactId).arg(c->contactId()));
+ ).tqarg(m_statisticsContactId).tqarg(c->contactId()));
}
void StatisticsContact::removeFromDB()
@@ -160,11 +160,11 @@ void StatisticsContact::removeFromDB()
return;
kdDebug() << k_funcinfo << " m_statisticsContactId: " << m_statisticsContactId << endl;
- 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_db->query(TQString("DELETE FROM contacts WHERE statisticid LIKE '%1';").tqarg(m_statisticsContactId));
+ m_db->query(TQString("DELETE FROM contactstatus WHERE metacontactid LIKE '%1';").tqarg(m_statisticsContactId));
+ m_db->query(TQString("DELETE FROM commonstats WHERE metacontactid LIKE '%1';").tqarg(m_statisticsContactId));
- m_statisticsContactId = TQString::null;
+ m_statisticsContactId = TQString();
}
void StatisticsContact::commonStatsSave(const TQString name, const TQString statVar1, const TQString statVar2, const bool statVarChanged)
@@ -176,7 +176,7 @@ void StatisticsContact::commonStatsSave(const TQString name, const TQString stat
return;
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));
+ "WHERE statname LIKE '%3' AND metacontactid LIKE '%4';").tqarg(statVar1).tqarg(statVar2).tqarg(name).tqarg(m_statisticsContactId));
}
@@ -196,7 +196,7 @@ void StatisticsContact::commonStatsCheck(const TQString name, TQString& statVar1
if (m_statisticsContactId.isEmpty())
return;
- TQStringList buffer = m_db->query(TQString("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';").tqarg(name, m_statisticsContactId));
if (!buffer.isEmpty())
{
statVar1 = buffer[0];
@@ -204,7 +204,7 @@ void StatisticsContact::commonStatsCheck(const TQString name, TQString& statVar1
}
else
{
- m_db->query(TQString("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);").tqarg(m_statisticsContactId, name));
statVar1 = defaultValue1;
statVar2 = defaultValue2;
}
@@ -234,18 +234,18 @@ void StatisticsContact::commonStatsCheck(const TQString name, TQString& statVar1
void StatisticsContact::newMessageReceived(Kopete::Message& m)
{
kdDebug() << "statistics: new message received" << endl;
- TQDateTime currentDateTime = TQDateTime::currentDateTime();
+ TQDateTime tqcurrentDateTime = TQDateTime::tqcurrentDateTime();
if (m_timeBetweenTwoMessagesOn != -1 && m_isChatWindowOpen)
{
- m_timeBetweenTwoMessages = (m_timeBetweenTwoMessages*m_timeBetweenTwoMessagesOn + m_lastMessageReceived.secsTo(currentDateTime))/(1 + m_timeBetweenTwoMessagesOn);
+ m_timeBetweenTwoMessages = (m_timeBetweenTwoMessages*m_timeBetweenTwoMessagesOn + m_lastMessageReceived.secsTo(tqcurrentDateTime))/(1 + m_timeBetweenTwoMessagesOn);
}
setIsChatWindowOpen(true);
m_timeBetweenTwoMessagesOn += 1;
- m_lastMessageReceived = currentDateTime;
+ m_lastMessageReceived = tqcurrentDateTime;
// Message lenght
@@ -254,7 +254,7 @@ void StatisticsContact::newMessageReceived(Kopete::Message& m)
// Last talked
/// @todo do this in message sent too. So we need setLastTalk()
- m_lastTalk = currentDateTime;
+ m_lastTalk = tqcurrentDateTime;
m_messageLengthChanged = true;
m_lastTalkChanged = true;
@@ -269,32 +269,32 @@ void StatisticsContact::onlineStatusChanged(Kopete::OnlineStatus::StatusType sta
if (m_statisticsContactId.isEmpty())
return;
- TQDateTime currentDateTime = TQDateTime::currentDateTime();
+ TQDateTime tqcurrentDateTime = TQDateTime::tqcurrentDateTime();
- /// We don't want to log if oldStatus is unknown
+ /// We don't want to log if oldtqStatus is unknown
/// the change could not be a real one; see StatisticsPlugin::slotMySelfOnlineStatusChanged
- if (m_oldStatus != Kopete::OnlineStatus::Unknown)
+ if (m_oldtqStatus != Kopete::OnlineStatus::Unknown)
{
- kdDebug() << "statistics - status change for "<< metaContact()->metaContactId() << " : "<< TQString::number(m_oldStatus) << endl;
+ kdDebug() << "statistics - status change for "<< metaContact()->metaContactId() << " : "<< TQString::number(m_oldtqStatus) << 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(TQString::number(m_oldStatusDateTime.toTime_t())).arg(TQString::number(currentDateTime.toTime_t())));
+ "VALUES('%1', '%2', '%3', '%4'" ");").tqarg(m_statisticsContactId).tqarg(Kopete::OnlineStatus::statusTypeToString(m_oldtqStatus)).tqarg(TQString::number(m_oldStatusDateTime.toTime_t())).tqarg(TQString::number(tqcurrentDateTime.toTime_t())));
}
- if (m_oldStatus == Kopete::OnlineStatus::Online || m_oldStatus == Kopete::OnlineStatus::Away)
+ if (m_oldtqStatus == Kopete::OnlineStatus::Online || m_oldtqStatus == Kopete::OnlineStatus::Away)
// If the last status was Online or Away, the last time contact was present is the time he goes offline
{
- m_lastPresent = currentDateTime;
+ m_lastPresent = tqcurrentDateTime;
m_lastPresentChanged = true;
}
- m_oldStatus = status;
- m_oldStatusDateTime = currentDateTime;
+ m_oldtqStatus = status;
+ m_oldStatusDateTime = tqcurrentDateTime;
}
-bool StatisticsContact::wasStatus(TQDateTime dt, Kopete::OnlineStatus::StatusType status)
+bool StatisticsContact::wastqStatus(TQDateTime dt, Kopete::OnlineStatus::StatusType status)
{
if (m_statisticsContactId.isEmpty())
return false;
@@ -303,7 +303,7 @@ bool StatisticsContact::wasStatus(TQDateTime dt, Kopete::OnlineStatus::StatusTyp
"FROM contactstatus WHERE metacontactid LIKE '%1' AND datetimebegin <= %2 AND datetimeend >= %3 "
"AND status LIKE '%4' "
"ORDER BY datetimebegin;"
- ).arg(m_statisticsContactId).arg(dt.toTime_t()).arg(dt.toTime_t()).arg(Kopete::OnlineStatus::statusTypeToString(status)));
+ ).tqarg(m_statisticsContactId).tqarg(dt.toTime_t()).tqarg(dt.toTime_t()).tqarg(Kopete::OnlineStatus::statusTypeToString(status)));
if (!values.isEmpty()) return true;
@@ -318,7 +318,7 @@ TQString StatisticsContact::statusAt(TQDateTime dt)
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()));
+ ).tqarg(m_statisticsContactId).tqarg(dt.toTime_t()).tqarg(dt.toTime_t()));
if (!values.isEmpty()) return Kopete::OnlineStatus(Kopete::OnlineStatus::statusStringToType(values[0])).description();
else return "";
@@ -337,7 +337,7 @@ TQString StatisticsContact::mainStatusDate(const TQDate& date)
"(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());
+ ).tqarg(m_statisticsContactId).tqarg(dt1.toTime_t()).tqarg(dt2.toTime_t()).tqarg(dt1.toTime_t()).tqarg(dt2.toTime_t());
kdDebug() << request << endl;
TQStringList values = m_db->query(request);
@@ -389,8 +389,8 @@ TQValueList<TQTime> StatisticsContact::mainEvents(const Kopete::OnlineStatus::St
if (m_statisticsContactId.isEmpty())
return mainEvents;
- 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));
+ TQDateTime tqcurrentDateTime = TQDateTime::tqcurrentDateTime();
+ buffer = m_db->query(TQString("SELECT datetimebegin, datetimeend, status FROM contactstatus WHERE metacontactid LIKE '%1' ORDER BY datetimebegin").tqarg(m_statisticsContactId));
// Only select the events for which the previous is not Unknown AND the status is status.
@@ -413,7 +413,7 @@ TQValueList<TQTime> StatisticsContact::mainEvents(const Kopete::OnlineStatus::St
dt1.setTime_t(values[0].toInt());
dt2.setTime_t(values[values.count()-1].toInt());
- avEventsPerDay = qRound((double)values.count()/(double)dt1.daysTo(dt2));
+ avEventsPerDay = tqRound((double)values.count()/(double)dt1.daysTo(dt2));
kdDebug() << "statistics: average events per day : " <<avEventsPerDay << endl;
// We want to work on hours
@@ -430,7 +430,7 @@ TQValueList<TQTime> StatisticsContact::mainEvents(const Kopete::OnlineStatus::St
// Then we put some centroids (centroids in [0..24[)
TQValueList<int> centroids;
- int incr=qRound((double)hoursValues.count()/(double)avEventsPerDay);
+ int incr=tqRound((double)hoursValues.count()/(double)avEventsPerDay);
incr = incr ? incr : 1;
for (uint i=0; i<hoursValues.count(); i+=incr)
{
@@ -442,7 +442,7 @@ TQValueList<TQTime> StatisticsContact::mainEvents(const Kopete::OnlineStatus::St
// We need to compute the centroids
centroids = computeCentroids(centroids, hoursValues);
- // Convert to QDateTime
+ // Convert to TQDateTime
for (uint i=0; i<centroids.count(); i++)
{
kdDebug() << "statistics: new centroid : " << centroids[i] << endl;
@@ -491,7 +491,7 @@ TQValueList<int> StatisticsContact::computeCentroids(const TQValueList<int>& cen
int value = values[j];
if (whichCentroid[j] == i)
{
- newCentroids[i] = qRound((double)(value + newCentroids[i]*weight)/(double)(weight + 1));
+ newCentroids[i] = tqRound((double)(value + newCentroids[i]*weight)/(double)(weight + 1));
weight++;
}