- // we have to determine the real offset first
- QSqlQuery &offsetQuery = cachedQuery("select_messagesOffset");
- offsetQuery.bindValue(":bufferid", bufferId.toInt());
- offsetQuery.bindValue(":messageid", offset);
- offsetQuery.exec();
- offsetQuery.first();
- offset = offsetQuery.value(0).toInt();
- }
-
- // now let's select the messages
- QSqlQuery &msgQuery = cachedQuery("select_messages");
- msgQuery.bindValue(":bufferid", bufferId.toInt());
- msgQuery.bindValue(":limit", lastmsgs);
- msgQuery.bindValue(":offset", offset);
- msgQuery.exec();
-
- watchQuery(msgQuery);
-
- while(msgQuery.next()) {
- Message msg(QDateTime::fromTime_t(msgQuery.value(1).toInt()),
- bufferInfo,
- (Message::Type)msgQuery.value(2).toUInt(),
- msgQuery.value(5).toString(),
- msgQuery.value(4).toString(),
- (Message::Flags)msgQuery.value(3).toUInt());
- msg.setMsgId(msgQuery.value(0).toInt());
- messagelist << msg;