Browse Source

cleanup

pull/423/head
apprb 11 years ago
parent
commit
02092c9a90
No known key found for this signature in database
GPG Key ID: B001911B5B22FB9B
  1. 29
      historykeeper.cpp
  2. 5
      widget/chatareawidget.cpp
  3. 1
      widget/chatareawidget.h
  4. 2
      widget/form/genericchatform.cpp
  5. 5
      widget/form/loadhistorydialog.ui
  6. 15
      widget/tool/chatactions/actionaction.cpp
  7. 2
      widget/tool/chatactions/actionaction.h
  8. 11
      widget/tool/chatactions/filetransferaction.cpp
  9. 15
      widget/tool/chatactions/messageaction.cpp
  10. 2
      widget/tool/chatactions/messageaction.h
  11. 17
      widget/tool/chatactions/systemmessageaction.cpp
  12. 2
      widget/tool/chatactions/systemmessageaction.h

29
historykeeper.cpp

@ -63,8 +63,31 @@ HistoryKeeper::HistoryKeeper(const QString &path, bool encr) : @@ -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 @@ -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() @@ -221,7 +244,7 @@ void HistoryKeeper::syncToDisk()
return;
}
// encryption there
// encryption here
} else
{
// warning

5
widget/chatareawidget.cpp

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

1
widget/chatareawidget.h

@ -31,7 +31,6 @@ public: @@ -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);

2
widget/form/genericchatform.cpp

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

5
widget/form/loadhistorydialog.ui

@ -13,11 +13,14 @@ @@ -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>

15
widget/tool/chatactions/actionaction.cpp

@ -23,21 +23,6 @@ ActionAction::ActionAction(const QString &author, const QString &message, const @@ -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>");

2
widget/tool/chatactions/actionaction.h

@ -26,7 +26,7 @@ public: @@ -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;

11
widget/tool/chatactions/filetransferaction.cpp

@ -74,17 +74,6 @@ void FileTransferAction::updateHtml() @@ -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()

15
widget/tool/chatactions/messageaction.cpp

@ -23,21 +23,6 @@ MessageAction::MessageAction(const QString &author, const QString &message, cons @@ -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));

2
widget/tool/chatactions/messageaction.h

@ -25,7 +25,7 @@ public: @@ -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;

17
widget/tool/chatactions/systemmessageaction.cpp

@ -27,20 +27,3 @@ QString SystemMessageAction::getMessage() @@ -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();
}

2
widget/tool/chatactions/systemmessageaction.h

@ -24,7 +24,7 @@ class SystemMessageAction : public ChatAction @@ -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();

Loading…
Cancel
Save