1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00
This commit is contained in:
apprb 2014-10-11 18:53:25 +09:00
parent b0ef7e8152
commit 02092c9a90
No known key found for this signature in database
GPG Key ID: B001911B5B22FB9B
12 changed files with 34 additions and 72 deletions

View File

@ -63,8 +63,31 @@ HistoryKeeper::HistoryKeeper(const QString &path, bool encr) :
db.open();
}
/*
DB format
chats:
* name -> id map
id -- auto-incrementing number
name -- chat's name (for user to user conversation it is opposite user public key)
ctype -- chat type, reserved for group chats
alisases:
* user_id -> id map
id -- auto-incrementing number
name -- user's public key
history:
id -- auto-incrementing number
timestamp
profile_id -- profile ID (resolves from aliases table)
chat_id -- current chat ID (resolves from chats table)
sender -- sender's ID (resolves from aliases table)
mtype -- type of message (message, action, etc) (UNUSED now)
message
*/
db.exec(QString("CREATE TABLE IF NOT EXISTS history (id INTEGER PRIMARY KEY AUTOINCREMENT, timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL, ") +
QString("profile_id INTEGER NOT NULL, chat_id INTEGER NOT NULL, sender INTERGER NOT NULL, message TEXT NOT NULL);"));
QString("profile_id INTEGER NOT NULL, chat_id INTEGER NOT NULL, sender INTERGER NOT NULL, mtype INTEGER NOT NULL, message TEXT NOT NULL);"));
db.exec(QString("CREATE TABLE IF NOT EXISTS aliases (id INTEGER PRIMARY KEY AUTOINCREMENT, user_id TEXT UNIQUE NOT NULL);"));
db.exec(QString("CREATE TABLE IF NOT EXISTS chats (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT UNIQUE NOT NULL, ctype INTEGER NOT NULL);"));
@ -83,7 +106,7 @@ void HistoryKeeper::addChatEntry(const QString& chat, const QString& message, co
int sender_id = getAliasID(sender);
int profile_id = getCurrentProfileID();
db.exec(QString("INSERT INTO history (profile_id, chat_id, sender, message) VALUES (%1, %2, %3, '%4');")
db.exec(QString("INSERT INTO history (profile_id, chat_id, sender, mtype, message) VALUES (%1, %2, %3, 0, '%4');")
.arg(profile_id).arg(chat_id).arg(sender_id).arg(wrapMessage(message)));
}
@ -221,7 +244,7 @@ void HistoryKeeper::syncToDisk()
return;
}
// encryption there
// encryption here
} else
{
// warning

View File

@ -184,8 +184,3 @@ void ChatAreaWidget::clearChatArea()
insertMessage(message);
}
}
void ChatAreaWidget::rerenderContent()
{
}

View File

@ -31,7 +31,6 @@ public:
virtual ~ChatAreaWidget();
void insertMessage(ChatAction *msgAction);
QList<ChatAction*>& getMesages() {return messages;}
void rerenderContent();
int nameColWidth() {return nameWidth;}
void setNameColWidth(int w);

View File

@ -228,7 +228,7 @@ void GenericChatForm::clearChatArea(bool notinform)
previousName = "";
if (!notinform)
addSystemInfoMessage(tr("Cleared"), "green");
addSystemInfoMessage(tr("Cleared"), "white");
if (earliestMessage)
{

View File

@ -13,11 +13,14 @@
<property name="windowTitle">
<string>Load History Dialog</string>
</property>
<property name="modal">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="fromLabel">
<property name="text">
<string>From Date</string>
<string>Load history from:</string>
</property>
</widget>
</item>

View File

@ -23,21 +23,6 @@ ActionAction::ActionAction(const QString &author, const QString &message, const
{
}
void ActionAction::setup(QTextCursor cursor, QTextEdit *)
{
// When this function is called, we're supposed to only update ourselve when needed
// Nobody should ask us to do anything with our content, we're on our own
// Except we never udpate on our own, so we can safely free our resources
(void) cursor;
// message.clear();
// message.squeeze();
// name.clear();
// name.squeeze();
// date.clear();
// date.squeeze();
}
QString ActionAction::getName()
{
return QString("<div class=action>*</div>");

View File

@ -26,7 +26,7 @@ public:
virtual ~ActionAction(){;}
virtual QString getMessage();
virtual QString getName();
virtual void setup(QTextCursor cursor, QTextEdit*) override;
virtual void setup(QTextCursor, QTextEdit*) override {;}
private:
QString message;

View File

@ -74,17 +74,6 @@ void FileTransferAction::updateHtml()
// restore old slider value
edit->verticalScrollBar()->setValue(vSliderVal);
// Free our ressources if we'll never need to update again
if (w->getState() == FileTransferInstance::TransfState::tsCanceled
|| w->getState() == FileTransferInstance::TransfState::tsFinished)
{
// name.clear();
// name.squeeze();
// date.clear();
// date.squeeze();
// cur = QTextCursor();
}
}
bool FileTransferAction::isInteractive()

View File

@ -23,21 +23,6 @@ MessageAction::MessageAction(const QString &author, const QString &message, cons
{
}
void MessageAction::setup(QTextCursor cursor, QTextEdit *)
{
// When this function is called, we're supposed to only update ourselve when needed
// Nobody should ask us to do anything with our content, we're on our own
// Except we never udpate on our own, so we can safely free our resources
(void) cursor;
// message.clear();
// message.squeeze();
// name.clear();
// name.squeeze();
// date.clear();
// date.squeeze();
}
QString MessageAction::getMessage()
{
QString message_ = SmileyPack::getInstance().smileyfied(toHtmlChars(message));

View File

@ -25,7 +25,7 @@ public:
MessageAction(const QString &author, const QString &message, const QString &date, const bool &me);
virtual ~MessageAction(){;}
virtual QString getMessage();
virtual void setup(QTextCursor cursor, QTextEdit*) override;
virtual void setup(QTextCursor, QTextEdit*) override {;}
private:
QString message;

View File

@ -27,20 +27,3 @@ QString SystemMessageAction::getMessage()
{
return QString("<table width=100%><tr><td align=center><div class=" + type + ">" + message + "</td><tr></div></table>");
}
void SystemMessageAction::setup(QTextCursor cursor, QTextEdit *)
{
// When this function is called, we're supposed to only update ourselve when needed
// Nobody should ask us to do anything with our content, we're on our own
// Except we never udpate on our own, so we can safely free our resources
(void) cursor;
// message.clear();
// message.squeeze();
// name.clear();
// name.squeeze();
// date.clear();
// date.squeeze();
// type.clear();
// type.squeeze();
}

View File

@ -24,7 +24,7 @@ class SystemMessageAction : public ChatAction
public:
SystemMessageAction(const QString &message, const QString& type, const QString &date);
virtual ~SystemMessageAction(){;}
virtual void setup(QTextCursor cursor, QTextEdit*) override;
virtual void setup(QTextCursor, QTextEdit*) override {;}
virtual QString getName() {return QString();}
virtual QString getMessage();