From 0efede7857a86f729bec0fdfd1789f7faf23d957 Mon Sep 17 00:00:00 2001
From: David Faure <faure@kde.org>
Date: Thu, 28 Nov 2019 17:41:33 +0100
Subject: Port to QElapsedTimer; remove unused default constructor

Tested by printing out the value of age(), works like before.
---
 src/irc/ircqueue.cpp |  8 ++++++++
 src/irc/ircqueue.h   | 18 +++++++-----------
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/src/irc/ircqueue.cpp b/src/irc/ircqueue.cpp
index 1101623..3cc33a5 100644
--- a/src/irc/ircqueue.cpp
+++ b/src/irc/ircqueue.cpp
@@ -19,6 +19,14 @@
 
 #include "server.h"
 
+IRCMessage::IRCMessage(const QString &str)
+    : s(str) //, codec(QTextCodec::codecForName("utf8"))
+{
+    t.start();
+}
+
+////
+
 int IRCQueue::EmptyingRate::nextInterval(int, int elapsed)
 {
     if (!isValid())
diff --git a/src/irc/ircqueue.h b/src/irc/ircqueue.h
index 3f7f0c8..7a91776 100644
--- a/src/irc/ircqueue.h
+++ b/src/irc/ircqueue.h
@@ -19,6 +19,7 @@
 #include <QObject>
 #include <QList>
 #include <QTime>
+#include <QElapsedTimer>
 
 class QTimer;
 class Server;
@@ -34,29 +35,24 @@ class Server;
  */
 struct IRCMessage
 {
-    IRCMessage() : t(QTime::currentTime()) //, codec(QTextCodec::codecForName("utf8"))
-    {} ///< this constructor required for QValueList, do not use
-
     /**
         Make a new IRCMessage with timestamp of QTime::currentTime().
 
         Note the constructor takes a QString, not a const QString& or a QString *. If you want to modify the
         contained text, put it back with setText.
     */
-    IRCMessage(QString i) : s(i), t(QTime::currentTime()) //, codec(QTextCodec::codecForName("utf8"))
-    {}
+    IRCMessage(const QString &str);
 
-    QString text() { return s; }
-    int age() { return t.elapsed(); }
-    QTime time() { return t; }
-    void setText(QString text) { s=text; }
+    QString text() const { return s; }
+    int age() const { return t.elapsed(); } // in milliseconds
+    void setText(const QString &text) { s=text; }
 private:
     QString s;
-    QTime t;
+    QElapsedTimer t;
 
     //FIXME wire this up
     //QTextCodec* codec;
-    //operator const char * () const { return codec->fromUnicode(text()); }
+    //operator QByteArray () const { return codec->fromUnicode(text()); }
 
 };
 
-- 
cgit v1.1

