commit abd7218ba40261da41f58576047cee7c17fd7ded
parent eb8b86f058c3eb39cac532b49ab725db74743afd
Author: MTRNord <mtrnord1@gmail.com>
Date: Wed, 18 Oct 2017 17:02:37 +0200
Split Dbs close #17, set timestamp on messages
Signed-off-by: MTRNord <mtrnord1@gmail.com>
Diffstat:
10 files changed, 154 insertions(+), 124 deletions(-)
diff --git a/elements/messageList.go b/elements/messageList.go
@@ -8,6 +8,7 @@ import (
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/uitools"
"github.com/therecipe/qt/widgets"
+ "time"
)
////////////////////////////////////////////////////
@@ -25,7 +26,7 @@ import (
type QVBoxLayoutWithTriggerSlot struct {
widgets.QVBoxLayout
- _ func(messageBody, sender string) `slot:"TriggerMessage"`
+ _ func(messageBody, sender string, timestamp int64) `slot:"TriggerMessage"`
}
// NewMessageList generates a new QVBoxLayoutWithTriggerSlot and adds it to the message scrollArea
@@ -42,7 +43,7 @@ func NewMessageList(scrollArea *widgets.QScrollArea, messageView *widgets.QWidge
}
// NewMessage adds a new message object to the view
-func (messageViewLayout *QVBoxLayoutWithTriggerSlot) NewMessage(body string, cli *gomatrix.Client, sender string, scrollArea *widgets.QScrollArea) (err error) {
+func (messageViewLayout *QVBoxLayoutWithTriggerSlot) NewMessage(body string, cli *gomatrix.Client, sender string, timestamp int64, scrollArea *widgets.QScrollArea) (err error) {
avatar, AvatarErr := matrix.GetUserAvatar(cli, sender, 61)
if err != nil {
err = AvatarErr
@@ -58,9 +59,13 @@ func (messageViewLayout *QVBoxLayoutWithTriggerSlot) NewMessage(body string, cli
var wrapperWidget = loader.Load(file, widget)
file.Close()
+ timestampFormat := time.Unix(0, int64(timestamp)*int64(time.Millisecond))
+ timestampString := timestampFormat.Format("15:04:05 - Mon 2.01.2006")
+
messageWidget := widgets.NewQWidgetFromPointer(widget.FindChild("message", core.Qt__FindChildrenRecursively).Pointer())
avatarLogo := widgets.NewQLabelFromPointer(widget.FindChild("avatar", core.Qt__FindChildrenRecursively).Pointer())
messageContent := widgets.NewQLabelFromPointer(widget.FindChild("messageContent", core.Qt__FindChildrenRecursively).Pointer())
+ timestampContent := widgets.NewQLabelFromPointer(widget.FindChild("timestamp", core.Qt__FindChildrenRecursively).Pointer())
senderContent := widgets.NewQLabelFromPointer(widget.FindChild("sender", core.Qt__FindChildrenRecursively).Pointer())
markdownMessage := commonmark.Md2Html(body, 0)
@@ -78,6 +83,7 @@ func (messageViewLayout *QVBoxLayoutWithTriggerSlot) NewMessage(body string, cli
}
fmt.Println(senderDisplayName)
senderContent.SetText(senderDisplayName)
+ timestampContent.SetText(timestampString)
avatarLogo.SetPixmap(avatar)
messageContent.SetMinimumWidth(messageContent.LineWidth())
diff --git a/elements/moc.cpp b/elements/moc.cpp
@@ -27,6 +27,55 @@
#include <QWidget>
+class QVBoxLayoutWithTriggerSlot: public QVBoxLayout
+{
+Q_OBJECT
+public:
+ QVBoxLayoutWithTriggerSlot() : QVBoxLayout() {qRegisterMetaType<quintptr>("quintptr");QVBoxLayoutWithTriggerSlot_QVBoxLayoutWithTriggerSlot_QRegisterMetaType();QVBoxLayoutWithTriggerSlot_QVBoxLayoutWithTriggerSlot_QRegisterMetaTypes();callbackQVBoxLayoutWithTriggerSlot_Constructor(this);};
+ QVBoxLayoutWithTriggerSlot(QWidget *parent) : QVBoxLayout(parent) {qRegisterMetaType<quintptr>("quintptr");QVBoxLayoutWithTriggerSlot_QVBoxLayoutWithTriggerSlot_QRegisterMetaType();QVBoxLayoutWithTriggerSlot_QVBoxLayoutWithTriggerSlot_QRegisterMetaTypes();callbackQVBoxLayoutWithTriggerSlot_Constructor(this);};
+ QLayoutItem * takeAt(int index) { return static_cast<QLayoutItem*>(callbackQVBoxLayoutWithTriggerSlot_TakeAt(this, index)); };
+ void addItem(QLayoutItem * item) { callbackQVBoxLayoutWithTriggerSlot_AddItem(this, item); };
+ void invalidate() { callbackQVBoxLayoutWithTriggerSlot_Invalidate(this); };
+ void setGeometry(const QRect & r) { callbackQVBoxLayoutWithTriggerSlot_SetGeometry(this, const_cast<QRect*>(&r)); };
+ QLayoutItem * itemAt(int index) const { return static_cast<QLayoutItem*>(callbackQVBoxLayoutWithTriggerSlot_ItemAt(const_cast<void*>(static_cast<const void*>(this)), index)); };
+ QSize maximumSize() const { return *static_cast<QSize*>(callbackQVBoxLayoutWithTriggerSlot_MaximumSize(const_cast<void*>(static_cast<const void*>(this)))); };
+ QSize minimumSize() const { return *static_cast<QSize*>(callbackQVBoxLayoutWithTriggerSlot_MinimumSize(const_cast<void*>(static_cast<const void*>(this)))); };
+ QSize sizeHint() const { return *static_cast<QSize*>(callbackQVBoxLayoutWithTriggerSlot_SizeHint(const_cast<void*>(static_cast<const void*>(this)))); };
+ Qt::Orientations expandingDirections() const { return static_cast<Qt::Orientation>(callbackQVBoxLayoutWithTriggerSlot_ExpandingDirections(const_cast<void*>(static_cast<const void*>(this)))); };
+ bool hasHeightForWidth() const { return callbackQVBoxLayoutWithTriggerSlot_HasHeightForWidth(const_cast<void*>(static_cast<const void*>(this))) != 0; };
+ int count() const { return callbackQVBoxLayoutWithTriggerSlot_Count(const_cast<void*>(static_cast<const void*>(this))); };
+ int heightForWidth(int w) const { return callbackQVBoxLayoutWithTriggerSlot_HeightForWidth(const_cast<void*>(static_cast<const void*>(this)), w); };
+ int minimumHeightForWidth(int w) const { return callbackQVBoxLayoutWithTriggerSlot_MinimumHeightForWidth(const_cast<void*>(static_cast<const void*>(this)), w); };
+ QLayout * layout() { return static_cast<QLayout*>(callbackQVBoxLayoutWithTriggerSlot_Layout(this)); };
+ void childEvent(QChildEvent * e) { callbackQVBoxLayoutWithTriggerSlot_ChildEvent(this, e); };
+ QRect geometry() const { return *static_cast<QRect*>(callbackQVBoxLayoutWithTriggerSlot_Geometry(const_cast<void*>(static_cast<const void*>(this)))); };
+ QSizePolicy::ControlTypes controlTypes() const { return static_cast<QSizePolicy::ControlType>(callbackQVBoxLayoutWithTriggerSlot_ControlTypes(const_cast<void*>(static_cast<const void*>(this)))); };
+ bool isEmpty() const { return callbackQVBoxLayoutWithTriggerSlot_IsEmpty(const_cast<void*>(static_cast<const void*>(this))) != 0; };
+ int indexOf(QWidget * widget) const { return callbackQVBoxLayoutWithTriggerSlot_IndexOf(const_cast<void*>(static_cast<const void*>(this)), widget); };
+ bool event(QEvent * e) { return callbackQVBoxLayoutWithTriggerSlot_Event(this, e) != 0; };
+ bool eventFilter(QObject * watched, QEvent * event) { return callbackQVBoxLayoutWithTriggerSlot_EventFilter(this, watched, event) != 0; };
+ void connectNotify(const QMetaMethod & sign) { callbackQVBoxLayoutWithTriggerSlot_ConnectNotify(this, const_cast<QMetaMethod*>(&sign)); };
+ void customEvent(QEvent * event) { callbackQVBoxLayoutWithTriggerSlot_CustomEvent(this, event); };
+ void deleteLater() { callbackQVBoxLayoutWithTriggerSlot_DeleteLater(this); };
+ void Signal_Destroyed(QObject * obj) { callbackQVBoxLayoutWithTriggerSlot_Destroyed(this, obj); };
+ void disconnectNotify(const QMetaMethod & sign) { callbackQVBoxLayoutWithTriggerSlot_DisconnectNotify(this, const_cast<QMetaMethod*>(&sign)); };
+ void Signal_ObjectNameChanged(const QString & objectName) { QByteArray taa2c4f = objectName.toUtf8(); Moc_PackedString objectNamePacked = { const_cast<char*>(taa2c4f.prepend("WHITESPACE").constData()+10), taa2c4f.size()-10 };callbackQVBoxLayoutWithTriggerSlot_ObjectNameChanged(this, objectNamePacked); };
+ void timerEvent(QTimerEvent * event) { callbackQVBoxLayoutWithTriggerSlot_TimerEvent(this, event); };
+
+ QSpacerItem * spacerItem() { return static_cast<QSpacerItem*>(callbackQVBoxLayoutWithTriggerSlot_SpacerItem(this)); };
+ QWidget * widget() { return static_cast<QWidget*>(callbackQVBoxLayoutWithTriggerSlot_Widget(this)); };
+signals:
+public slots:
+ void TriggerMessage(QString messageBody, QString sender, qint64 timestamp) { QByteArray t59bf16 = messageBody.toUtf8(); Moc_PackedString messageBodyPacked = { const_cast<char*>(t59bf16.prepend("WHITESPACE").constData()+10), t59bf16.size()-10 };QByteArray tacc6a3 = sender.toUtf8(); Moc_PackedString senderPacked = { const_cast<char*>(tacc6a3.prepend("WHITESPACE").constData()+10), tacc6a3.size()-10 };callbackQVBoxLayoutWithTriggerSlot_TriggerMessage(this, messageBodyPacked, senderPacked, timestamp); };
+private:
+};
+
+Q_DECLARE_METATYPE(QVBoxLayoutWithTriggerSlot*)
+
+
+void QVBoxLayoutWithTriggerSlot_QVBoxLayoutWithTriggerSlot_QRegisterMetaTypes() {
+}
+
class QRoomVBoxLayoutWithTriggerSlot: public QVBoxLayout
{
Q_OBJECT
@@ -76,55 +125,6 @@ Q_DECLARE_METATYPE(QRoomVBoxLayoutWithTriggerSlot*)
void QRoomVBoxLayoutWithTriggerSlot_QRoomVBoxLayoutWithTriggerSlot_QRegisterMetaTypes() {
}
-class QVBoxLayoutWithTriggerSlot: public QVBoxLayout
-{
-Q_OBJECT
-public:
- QVBoxLayoutWithTriggerSlot() : QVBoxLayout() {qRegisterMetaType<quintptr>("quintptr");QVBoxLayoutWithTriggerSlot_QVBoxLayoutWithTriggerSlot_QRegisterMetaType();QVBoxLayoutWithTriggerSlot_QVBoxLayoutWithTriggerSlot_QRegisterMetaTypes();callbackQVBoxLayoutWithTriggerSlot_Constructor(this);};
- QVBoxLayoutWithTriggerSlot(QWidget *parent) : QVBoxLayout(parent) {qRegisterMetaType<quintptr>("quintptr");QVBoxLayoutWithTriggerSlot_QVBoxLayoutWithTriggerSlot_QRegisterMetaType();QVBoxLayoutWithTriggerSlot_QVBoxLayoutWithTriggerSlot_QRegisterMetaTypes();callbackQVBoxLayoutWithTriggerSlot_Constructor(this);};
- QLayoutItem * takeAt(int index) { return static_cast<QLayoutItem*>(callbackQVBoxLayoutWithTriggerSlot_TakeAt(this, index)); };
- void addItem(QLayoutItem * item) { callbackQVBoxLayoutWithTriggerSlot_AddItem(this, item); };
- void invalidate() { callbackQVBoxLayoutWithTriggerSlot_Invalidate(this); };
- void setGeometry(const QRect & r) { callbackQVBoxLayoutWithTriggerSlot_SetGeometry(this, const_cast<QRect*>(&r)); };
- QLayoutItem * itemAt(int index) const { return static_cast<QLayoutItem*>(callbackQVBoxLayoutWithTriggerSlot_ItemAt(const_cast<void*>(static_cast<const void*>(this)), index)); };
- QSize maximumSize() const { return *static_cast<QSize*>(callbackQVBoxLayoutWithTriggerSlot_MaximumSize(const_cast<void*>(static_cast<const void*>(this)))); };
- QSize minimumSize() const { return *static_cast<QSize*>(callbackQVBoxLayoutWithTriggerSlot_MinimumSize(const_cast<void*>(static_cast<const void*>(this)))); };
- QSize sizeHint() const { return *static_cast<QSize*>(callbackQVBoxLayoutWithTriggerSlot_SizeHint(const_cast<void*>(static_cast<const void*>(this)))); };
- Qt::Orientations expandingDirections() const { return static_cast<Qt::Orientation>(callbackQVBoxLayoutWithTriggerSlot_ExpandingDirections(const_cast<void*>(static_cast<const void*>(this)))); };
- bool hasHeightForWidth() const { return callbackQVBoxLayoutWithTriggerSlot_HasHeightForWidth(const_cast<void*>(static_cast<const void*>(this))) != 0; };
- int count() const { return callbackQVBoxLayoutWithTriggerSlot_Count(const_cast<void*>(static_cast<const void*>(this))); };
- int heightForWidth(int w) const { return callbackQVBoxLayoutWithTriggerSlot_HeightForWidth(const_cast<void*>(static_cast<const void*>(this)), w); };
- int minimumHeightForWidth(int w) const { return callbackQVBoxLayoutWithTriggerSlot_MinimumHeightForWidth(const_cast<void*>(static_cast<const void*>(this)), w); };
- QLayout * layout() { return static_cast<QLayout*>(callbackQVBoxLayoutWithTriggerSlot_Layout(this)); };
- void childEvent(QChildEvent * e) { callbackQVBoxLayoutWithTriggerSlot_ChildEvent(this, e); };
- QRect geometry() const { return *static_cast<QRect*>(callbackQVBoxLayoutWithTriggerSlot_Geometry(const_cast<void*>(static_cast<const void*>(this)))); };
- QSizePolicy::ControlTypes controlTypes() const { return static_cast<QSizePolicy::ControlType>(callbackQVBoxLayoutWithTriggerSlot_ControlTypes(const_cast<void*>(static_cast<const void*>(this)))); };
- bool isEmpty() const { return callbackQVBoxLayoutWithTriggerSlot_IsEmpty(const_cast<void*>(static_cast<const void*>(this))) != 0; };
- int indexOf(QWidget * widget) const { return callbackQVBoxLayoutWithTriggerSlot_IndexOf(const_cast<void*>(static_cast<const void*>(this)), widget); };
- bool event(QEvent * e) { return callbackQVBoxLayoutWithTriggerSlot_Event(this, e) != 0; };
- bool eventFilter(QObject * watched, QEvent * event) { return callbackQVBoxLayoutWithTriggerSlot_EventFilter(this, watched, event) != 0; };
- void connectNotify(const QMetaMethod & sign) { callbackQVBoxLayoutWithTriggerSlot_ConnectNotify(this, const_cast<QMetaMethod*>(&sign)); };
- void customEvent(QEvent * event) { callbackQVBoxLayoutWithTriggerSlot_CustomEvent(this, event); };
- void deleteLater() { callbackQVBoxLayoutWithTriggerSlot_DeleteLater(this); };
- void Signal_Destroyed(QObject * obj) { callbackQVBoxLayoutWithTriggerSlot_Destroyed(this, obj); };
- void disconnectNotify(const QMetaMethod & sign) { callbackQVBoxLayoutWithTriggerSlot_DisconnectNotify(this, const_cast<QMetaMethod*>(&sign)); };
- void Signal_ObjectNameChanged(const QString & objectName) { QByteArray taa2c4f = objectName.toUtf8(); Moc_PackedString objectNamePacked = { const_cast<char*>(taa2c4f.prepend("WHITESPACE").constData()+10), taa2c4f.size()-10 };callbackQVBoxLayoutWithTriggerSlot_ObjectNameChanged(this, objectNamePacked); };
- void timerEvent(QTimerEvent * event) { callbackQVBoxLayoutWithTriggerSlot_TimerEvent(this, event); };
-
- QSpacerItem * spacerItem() { return static_cast<QSpacerItem*>(callbackQVBoxLayoutWithTriggerSlot_SpacerItem(this)); };
- QWidget * widget() { return static_cast<QWidget*>(callbackQVBoxLayoutWithTriggerSlot_Widget(this)); };
-signals:
-public slots:
- void TriggerMessage(QString messageBody, QString sender) { QByteArray t59bf16 = messageBody.toUtf8(); Moc_PackedString messageBodyPacked = { const_cast<char*>(t59bf16.prepend("WHITESPACE").constData()+10), t59bf16.size()-10 };QByteArray tacc6a3 = sender.toUtf8(); Moc_PackedString senderPacked = { const_cast<char*>(tacc6a3.prepend("WHITESPACE").constData()+10), tacc6a3.size()-10 };callbackQVBoxLayoutWithTriggerSlot_TriggerMessage(this, messageBodyPacked, senderPacked); };
-private:
-};
-
-Q_DECLARE_METATYPE(QVBoxLayoutWithTriggerSlot*)
-
-
-void QVBoxLayoutWithTriggerSlot_QVBoxLayoutWithTriggerSlot_QRegisterMetaTypes() {
-}
-
void QRoomVBoxLayoutWithTriggerSlot_TriggerMessage(void* ptr, struct Moc_PackedString messageBody, struct Moc_PackedString sender)
{
QMetaObject::invokeMethod(static_cast<QRoomVBoxLayoutWithTriggerSlot*>(ptr), "TriggerMessage", Q_ARG(QString, QString::fromUtf8(messageBody.data, messageBody.len)), Q_ARG(QString, QString::fromUtf8(sender.data, sender.len)));
@@ -395,9 +395,9 @@ void* QRoomVBoxLayoutWithTriggerSlot_WidgetDefault(void* ptr)
return static_cast<QRoomVBoxLayoutWithTriggerSlot*>(ptr)->QVBoxLayout::widget();
}
-void QVBoxLayoutWithTriggerSlot_TriggerMessage(void* ptr, struct Moc_PackedString messageBody, struct Moc_PackedString sender)
+void QVBoxLayoutWithTriggerSlot_TriggerMessage(void* ptr, struct Moc_PackedString messageBody, struct Moc_PackedString sender, long long timestamp)
{
- QMetaObject::invokeMethod(static_cast<QVBoxLayoutWithTriggerSlot*>(ptr), "TriggerMessage", Q_ARG(QString, QString::fromUtf8(messageBody.data, messageBody.len)), Q_ARG(QString, QString::fromUtf8(sender.data, sender.len)));
+ QMetaObject::invokeMethod(static_cast<QVBoxLayoutWithTriggerSlot*>(ptr), "TriggerMessage", Q_ARG(QString, QString::fromUtf8(messageBody.data, messageBody.len)), Q_ARG(QString, QString::fromUtf8(sender.data, sender.len)), Q_ARG(qint64, timestamp));
}
int QVBoxLayoutWithTriggerSlot_QVBoxLayoutWithTriggerSlot_QRegisterMetaType()
diff --git a/elements/moc.go b/elements/moc.go
@@ -841,20 +841,20 @@ func callbackQVBoxLayoutWithTriggerSlot_Constructor(ptr unsafe.Pointer) {
}
//export callbackQVBoxLayoutWithTriggerSlot_TriggerMessage
-func callbackQVBoxLayoutWithTriggerSlot_TriggerMessage(ptr unsafe.Pointer, messageBody C.struct_Moc_PackedString, sender C.struct_Moc_PackedString) {
+func callbackQVBoxLayoutWithTriggerSlot_TriggerMessage(ptr unsafe.Pointer, messageBody C.struct_Moc_PackedString, sender C.struct_Moc_PackedString, timestamp C.longlong) {
if signal := qt.GetSignal(ptr, "TriggerMessage"); signal != nil {
- signal.(func(string, string))(cGoUnpackString(messageBody), cGoUnpackString(sender))
+ signal.(func(string, string, int64))(cGoUnpackString(messageBody), cGoUnpackString(sender), int64(timestamp))
}
}
-func (ptr *QVBoxLayoutWithTriggerSlot) ConnectTriggerMessage(f func(messageBody string, sender string)) {
+func (ptr *QVBoxLayoutWithTriggerSlot) ConnectTriggerMessage(f func(messageBody string, sender string, timestamp int64)) {
if ptr.Pointer() != nil {
if signal := qt.LendSignal(ptr.Pointer(), "TriggerMessage"); signal != nil {
- qt.ConnectSignal(ptr.Pointer(), "TriggerMessage", func(messageBody string, sender string) {
- signal.(func(string, string))(messageBody, sender)
- f(messageBody, sender)
+ qt.ConnectSignal(ptr.Pointer(), "TriggerMessage", func(messageBody string, sender string, timestamp int64) {
+ signal.(func(string, string, int64))(messageBody, sender, timestamp)
+ f(messageBody, sender, timestamp)
})
} else {
qt.ConnectSignal(ptr.Pointer(), "TriggerMessage", f)
@@ -869,7 +869,7 @@ func (ptr *QVBoxLayoutWithTriggerSlot) DisconnectTriggerMessage() {
}
}
-func (ptr *QVBoxLayoutWithTriggerSlot) TriggerMessage(messageBody string, sender string) {
+func (ptr *QVBoxLayoutWithTriggerSlot) TriggerMessage(messageBody string, sender string, timestamp int64) {
if ptr.Pointer() != nil {
var messageBodyC *C.char
if messageBody != "" {
@@ -881,7 +881,7 @@ func (ptr *QVBoxLayoutWithTriggerSlot) TriggerMessage(messageBody string, sender
senderC = C.CString(sender)
defer C.free(unsafe.Pointer(senderC))
}
- C.QVBoxLayoutWithTriggerSlot_TriggerMessage(ptr.Pointer(), C.struct_Moc_PackedString{data: messageBodyC, len: C.longlong(len(messageBody))}, C.struct_Moc_PackedString{data: senderC, len: C.longlong(len(sender))})
+ C.QVBoxLayoutWithTriggerSlot_TriggerMessage(ptr.Pointer(), C.struct_Moc_PackedString{data: messageBodyC, len: C.longlong(len(messageBody))}, C.struct_Moc_PackedString{data: senderC, len: C.longlong(len(sender))}, C.longlong(timestamp))
}
}
diff --git a/elements/moc.h b/elements/moc.h
@@ -69,7 +69,7 @@ void QRoomVBoxLayoutWithTriggerSlot_TimerEventDefault(void* ptr, void* event);
;
void* QRoomVBoxLayoutWithTriggerSlot_SpacerItemDefault(void* ptr);
void* QRoomVBoxLayoutWithTriggerSlot_WidgetDefault(void* ptr);
-void QVBoxLayoutWithTriggerSlot_TriggerMessage(void* ptr, struct Moc_PackedString messageBody, struct Moc_PackedString sender);
+void QVBoxLayoutWithTriggerSlot_TriggerMessage(void* ptr, struct Moc_PackedString messageBody, struct Moc_PackedString sender, long long timestamp);
int QVBoxLayoutWithTriggerSlot_QVBoxLayoutWithTriggerSlot_QRegisterMetaType();
int QVBoxLayoutWithTriggerSlot_QVBoxLayoutWithTriggerSlot_QRegisterMetaType2(char* typeName);
int QVBoxLayoutWithTriggerSlot_QVBoxLayoutWithTriggerSlot_QmlRegisterType();
diff --git a/elements/moc_moc.h b/elements/moc_moc.h
@@ -19,30 +19,31 @@
QT_BEGIN_MOC_NAMESPACE
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
-struct qt_meta_stringdata_QRoomVBoxLayoutWithTriggerSlot_t {
- QByteArrayData data[5];
- char stringdata0[66];
+struct qt_meta_stringdata_QVBoxLayoutWithTriggerSlot_t {
+ QByteArrayData data[6];
+ char stringdata0[72];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
- qptrdiff(offsetof(qt_meta_stringdata_QRoomVBoxLayoutWithTriggerSlot_t, stringdata0) + ofs \
+ qptrdiff(offsetof(qt_meta_stringdata_QVBoxLayoutWithTriggerSlot_t, stringdata0) + ofs \
- idx * sizeof(QByteArrayData)) \
)
-static const qt_meta_stringdata_QRoomVBoxLayoutWithTriggerSlot_t qt_meta_stringdata_QRoomVBoxLayoutWithTriggerSlot = {
+static const qt_meta_stringdata_QVBoxLayoutWithTriggerSlot_t qt_meta_stringdata_QVBoxLayoutWithTriggerSlot = {
{
-QT_MOC_LITERAL(0, 0, 30), // "QRoomVBoxLayoutWithTriggerSlot"
-QT_MOC_LITERAL(1, 31, 14), // "TriggerMessage"
-QT_MOC_LITERAL(2, 46, 0), // ""
-QT_MOC_LITERAL(3, 47, 11), // "messageBody"
-QT_MOC_LITERAL(4, 59, 6) // "sender"
+QT_MOC_LITERAL(0, 0, 26), // "QVBoxLayoutWithTriggerSlot"
+QT_MOC_LITERAL(1, 27, 14), // "TriggerMessage"
+QT_MOC_LITERAL(2, 42, 0), // ""
+QT_MOC_LITERAL(3, 43, 11), // "messageBody"
+QT_MOC_LITERAL(4, 55, 6), // "sender"
+QT_MOC_LITERAL(5, 62, 9) // "timestamp"
},
- "QRoomVBoxLayoutWithTriggerSlot\0"
- "TriggerMessage\0\0messageBody\0sender"
+ "QVBoxLayoutWithTriggerSlot\0TriggerMessage\0"
+ "\0messageBody\0sender\0timestamp"
};
#undef QT_MOC_LITERAL
-static const uint qt_meta_data_QRoomVBoxLayoutWithTriggerSlot[] = {
+static const uint qt_meta_data_QVBoxLayoutWithTriggerSlot[] = {
// content:
7, // revision
@@ -56,46 +57,46 @@ static const uint qt_meta_data_QRoomVBoxLayoutWithTriggerSlot[] = {
0, // signalCount
// slots: name, argc, parameters, tag, flags
- 1, 2, 19, 2, 0x0a /* Public */,
+ 1, 3, 19, 2, 0x0a /* Public */,
// slots: parameters
- QMetaType::Void, QMetaType::QString, QMetaType::QString, 3, 4,
+ QMetaType::Void, QMetaType::QString, QMetaType::QString, QMetaType::LongLong, 3, 4, 5,
0 // eod
};
-void QRoomVBoxLayoutWithTriggerSlot::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
+void QVBoxLayoutWithTriggerSlot::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
- QRoomVBoxLayoutWithTriggerSlot *_t = static_cast<QRoomVBoxLayoutWithTriggerSlot *>(_o);
+ QVBoxLayoutWithTriggerSlot *_t = static_cast<QVBoxLayoutWithTriggerSlot *>(_o);
Q_UNUSED(_t)
switch (_id) {
- case 0: _t->TriggerMessage((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
+ case 0: _t->TriggerMessage((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2])),(*reinterpret_cast< qint64(*)>(_a[3]))); break;
default: ;
}
}
}
-const QMetaObject QRoomVBoxLayoutWithTriggerSlot::staticMetaObject = {
- { &QVBoxLayout::staticMetaObject, qt_meta_stringdata_QRoomVBoxLayoutWithTriggerSlot.data,
- qt_meta_data_QRoomVBoxLayoutWithTriggerSlot, qt_static_metacall, nullptr, nullptr}
+const QMetaObject QVBoxLayoutWithTriggerSlot::staticMetaObject = {
+ { &QVBoxLayout::staticMetaObject, qt_meta_stringdata_QVBoxLayoutWithTriggerSlot.data,
+ qt_meta_data_QVBoxLayoutWithTriggerSlot, qt_static_metacall, nullptr, nullptr}
};
-const QMetaObject *QRoomVBoxLayoutWithTriggerSlot::metaObject() const
+const QMetaObject *QVBoxLayoutWithTriggerSlot::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}
-void *QRoomVBoxLayoutWithTriggerSlot::qt_metacast(const char *_clname)
+void *QVBoxLayoutWithTriggerSlot::qt_metacast(const char *_clname)
{
if (!_clname) return nullptr;
- if (!strcmp(_clname, qt_meta_stringdata_QRoomVBoxLayoutWithTriggerSlot.stringdata0))
- return static_cast<void*>(const_cast< QRoomVBoxLayoutWithTriggerSlot*>(this));
+ if (!strcmp(_clname, qt_meta_stringdata_QVBoxLayoutWithTriggerSlot.stringdata0))
+ return static_cast<void*>(const_cast< QVBoxLayoutWithTriggerSlot*>(this));
return QVBoxLayout::qt_metacast(_clname);
}
-int QRoomVBoxLayoutWithTriggerSlot::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+int QVBoxLayoutWithTriggerSlot::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QVBoxLayout::qt_metacall(_c, _id, _a);
if (_id < 0)
@@ -111,30 +112,30 @@ int QRoomVBoxLayoutWithTriggerSlot::qt_metacall(QMetaObject::Call _c, int _id, v
}
return _id;
}
-struct qt_meta_stringdata_QVBoxLayoutWithTriggerSlot_t {
+struct qt_meta_stringdata_QRoomVBoxLayoutWithTriggerSlot_t {
QByteArrayData data[5];
- char stringdata0[62];
+ char stringdata0[66];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
- qptrdiff(offsetof(qt_meta_stringdata_QVBoxLayoutWithTriggerSlot_t, stringdata0) + ofs \
+ qptrdiff(offsetof(qt_meta_stringdata_QRoomVBoxLayoutWithTriggerSlot_t, stringdata0) + ofs \
- idx * sizeof(QByteArrayData)) \
)
-static const qt_meta_stringdata_QVBoxLayoutWithTriggerSlot_t qt_meta_stringdata_QVBoxLayoutWithTriggerSlot = {
+static const qt_meta_stringdata_QRoomVBoxLayoutWithTriggerSlot_t qt_meta_stringdata_QRoomVBoxLayoutWithTriggerSlot = {
{
-QT_MOC_LITERAL(0, 0, 26), // "QVBoxLayoutWithTriggerSlot"
-QT_MOC_LITERAL(1, 27, 14), // "TriggerMessage"
-QT_MOC_LITERAL(2, 42, 0), // ""
-QT_MOC_LITERAL(3, 43, 11), // "messageBody"
-QT_MOC_LITERAL(4, 55, 6) // "sender"
+QT_MOC_LITERAL(0, 0, 30), // "QRoomVBoxLayoutWithTriggerSlot"
+QT_MOC_LITERAL(1, 31, 14), // "TriggerMessage"
+QT_MOC_LITERAL(2, 46, 0), // ""
+QT_MOC_LITERAL(3, 47, 11), // "messageBody"
+QT_MOC_LITERAL(4, 59, 6) // "sender"
},
- "QVBoxLayoutWithTriggerSlot\0TriggerMessage\0"
- "\0messageBody\0sender"
+ "QRoomVBoxLayoutWithTriggerSlot\0"
+ "TriggerMessage\0\0messageBody\0sender"
};
#undef QT_MOC_LITERAL
-static const uint qt_meta_data_QVBoxLayoutWithTriggerSlot[] = {
+static const uint qt_meta_data_QRoomVBoxLayoutWithTriggerSlot[] = {
// content:
7, // revision
@@ -156,10 +157,10 @@ static const uint qt_meta_data_QVBoxLayoutWithTriggerSlot[] = {
0 // eod
};
-void QVBoxLayoutWithTriggerSlot::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
+void QRoomVBoxLayoutWithTriggerSlot::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
- QVBoxLayoutWithTriggerSlot *_t = static_cast<QVBoxLayoutWithTriggerSlot *>(_o);
+ QRoomVBoxLayoutWithTriggerSlot *_t = static_cast<QRoomVBoxLayoutWithTriggerSlot *>(_o);
Q_UNUSED(_t)
switch (_id) {
case 0: _t->TriggerMessage((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
@@ -168,26 +169,26 @@ void QVBoxLayoutWithTriggerSlot::qt_static_metacall(QObject *_o, QMetaObject::Ca
}
}
-const QMetaObject QVBoxLayoutWithTriggerSlot::staticMetaObject = {
- { &QVBoxLayout::staticMetaObject, qt_meta_stringdata_QVBoxLayoutWithTriggerSlot.data,
- qt_meta_data_QVBoxLayoutWithTriggerSlot, qt_static_metacall, nullptr, nullptr}
+const QMetaObject QRoomVBoxLayoutWithTriggerSlot::staticMetaObject = {
+ { &QVBoxLayout::staticMetaObject, qt_meta_stringdata_QRoomVBoxLayoutWithTriggerSlot.data,
+ qt_meta_data_QRoomVBoxLayoutWithTriggerSlot, qt_static_metacall, nullptr, nullptr}
};
-const QMetaObject *QVBoxLayoutWithTriggerSlot::metaObject() const
+const QMetaObject *QRoomVBoxLayoutWithTriggerSlot::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}
-void *QVBoxLayoutWithTriggerSlot::qt_metacast(const char *_clname)
+void *QRoomVBoxLayoutWithTriggerSlot::qt_metacast(const char *_clname)
{
if (!_clname) return nullptr;
- if (!strcmp(_clname, qt_meta_stringdata_QVBoxLayoutWithTriggerSlot.stringdata0))
- return static_cast<void*>(const_cast< QVBoxLayoutWithTriggerSlot*>(this));
+ if (!strcmp(_clname, qt_meta_stringdata_QRoomVBoxLayoutWithTriggerSlot.stringdata0))
+ return static_cast<void*>(const_cast< QRoomVBoxLayoutWithTriggerSlot*>(this));
return QVBoxLayout::qt_metacast(_clname);
}
-int QVBoxLayoutWithTriggerSlot::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+int QRoomVBoxLayoutWithTriggerSlot::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QVBoxLayout::qt_metacall(_c, _id, _a);
if (_id < 0)
diff --git a/main.go b/main.go
@@ -29,7 +29,7 @@ func main() {
}
defer file.Close()
- db, DBOpenErr := matrix.OpenDB()
+ db, DBOpenErr := matrix.OpenUserDB()
if DBOpenErr != nil {
localLog.Fatalln(DBOpenErr)
}
diff --git a/matrix/db.go b/matrix/db.go
@@ -7,10 +7,11 @@ import (
"github.com/matrix-org/gomatrix"
"github.com/shibukawa/configdir"
"github.com/tidwall/buntdb"
+ "strconv"
)
-// OpenDB opens or generates the Database file for settings and Cache
-func OpenDB() (db *buntdb.DB, err error) {
+// OpenCacheDB opens or generates the Database file for settings and Cache
+func OpenCacheDB() (db *buntdb.DB, err error) {
// Open the data.db file. It will be created if it doesn't exist.
configDirs := configdir.New("Nordgedanken", "Morpheus")
if _, StatErr := os.Stat(filepath.ToSlash(configDirs.QueryFolders(configdir.Global)[0].Path) + "/data/"); os.IsNotExist(StatErr) {
@@ -20,7 +21,28 @@ func OpenDB() (db *buntdb.DB, err error) {
return
}
}
- expDB, DBErr := buntdb.Open(filepath.ToSlash(configDirs.QueryFolders(configdir.Global)[0].Path) + "/data/data.db")
+ expDB, DBErr := buntdb.Open(filepath.ToSlash(configDirs.QueryFolders(configdir.Global)[0].Path) + "/data/cache.db")
+ if DBErr != nil {
+ err = DBErr
+ return
+ }
+
+ db = expDB
+ return
+}
+
+// OpenUserDB opens or generates the Database file for settings and Cache
+func OpenUserDB() (db *buntdb.DB, err error) {
+ // Open the data.db file. It will be created if it doesn't exist.
+ configDirs := configdir.New("Nordgedanken", "Morpheus")
+ if _, StatErr := os.Stat(filepath.ToSlash(configDirs.QueryFolders(configdir.Global)[0].Path) + "/data/"); os.IsNotExist(StatErr) {
+ MkdirErr := os.MkdirAll(filepath.ToSlash(configDirs.QueryFolders(configdir.Global)[0].Path)+"/data/", 0666)
+ if MkdirErr != nil {
+ err = MkdirErr
+ return
+ }
+ }
+ expDB, DBErr := buntdb.Open(filepath.ToSlash(configDirs.QueryFolders(configdir.Global)[0].Path) + "/data/userData.db")
if DBErr != nil {
err = DBErr
return
@@ -32,7 +54,7 @@ func OpenDB() (db *buntdb.DB, err error) {
// InitData inits basic Data like getting aliases of joinedRooms
func InitData(cli *gomatrix.Client) (err error) {
- db, DBOpenErr := OpenDB()
+ db, DBOpenErr := OpenCacheDB()
if DBOpenErr != nil {
localLog.Fatalln(DBOpenErr)
}
@@ -72,7 +94,7 @@ func InitData(cli *gomatrix.Client) (err error) {
// CacheMessageEvents writes message infos into the cache into the defined room
func CacheMessageEvents(id, sender, roomID, message string, timestamp int64) (err error) {
- db, DBOpenErr := OpenDB()
+ db, DBOpenErr := OpenCacheDB()
if DBOpenErr != nil {
localLog.Fatalln(DBOpenErr)
}
@@ -96,7 +118,8 @@ func CacheMessageEvents(id, sender, roomID, message string, timestamp int64) (er
return DBSetMessageErr
}
- _, _, DBSeTimestampErr := tx.Set("room:"+roomID+":messages:"+id+":timestamp", string(timestamp), nil)
+ timestampString := strconv.FormatInt(timestamp, 10)
+ _, _, DBSeTimestampErr := tx.Set("room:"+roomID+":messages:"+id+":timestamp", timestampString, nil)
return DBSeTimestampErr
})
diff --git a/matrix/login.go b/matrix/login.go
@@ -11,7 +11,7 @@ import (
//GetClient returns a Client
func GetClient(homeserverURL, userID, accessToken string) (client *gomatrix.Client, err error) {
- db, DBOpenErr := OpenDB()
+ db, DBOpenErr := OpenUserDB()
if DBOpenErr != nil {
localLog.Fatalln(DBOpenErr)
}
@@ -75,7 +75,7 @@ func LoginUser(username, password string) (*gomatrix.Client, error) {
return nil, err
}
- db, DBOpenErr := OpenDB()
+ db, DBOpenErr := OpenUserDB()
if DBOpenErr != nil {
localLog.Fatalln(DBOpenErr)
}
diff --git a/matrix/user.go b/matrix/user.go
@@ -94,7 +94,7 @@ func GetOwnUserAvatar(cli *gomatrix.Client) (avatar *gui.QPixmap, err error) {
// GetUserAvatar returns a *gui.QPixmap of an UserAvatar
func GetUserAvatar(cli *gomatrix.Client, mxid string, size int) (avatarResp *gui.QPixmap, err error) {
- db, DBOpenErr := OpenDB()
+ db, DBOpenErr := OpenCacheDB()
if DBOpenErr != nil {
localLog.Fatalln(DBOpenErr)
}
diff --git a/ui/MainUI.go b/ui/MainUI.go
@@ -124,8 +124,8 @@ func (m *MainUI) NewUI() (err error) {
// Init Message View
messageListLayout := elements.NewMessageList(messageScrollArea, messagesScrollAreaContent)
- messageListLayout.ConnectTriggerMessage(func(messageBody, sender string) {
- NewMessageErr := messageListLayout.NewMessage(messageBody, m.cli, sender, messageScrollArea)
+ messageListLayout.ConnectTriggerMessage(func(messageBody, sender string, timestamp int64) {
+ NewMessageErr := messageListLayout.NewMessage(messageBody, m.cli, sender, timestamp, messageScrollArea)
if NewMessageErr != nil {
err = NewMessageErr
return
@@ -197,7 +197,7 @@ func (m *MainUI) logout(widget *widgets.QWidget, messageScrollArea *widgets.QScr
}
cli.ClearCredentials()
- db, DBOpenErr := matrix.OpenDB()
+ db, DBOpenErr := matrix.OpenUserDB()
if DBOpenErr != nil {
localLog.Fatalln(DBOpenErr)
}
@@ -260,7 +260,7 @@ func (m *MainUI) startSync(messageListLayout *elements.QVBoxLayoutWithTriggerSlo
id := ev.ID
timestamp := ev.Timestamp
go matrix.CacheMessageEvents(id, sender, room, msg, timestamp)
- messageListLayout.TriggerMessage(msg, sender)
+ messageListLayout.TriggerMessage(msg, sender, timestamp)
})
// Start Non-blocking sync