1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
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
|