1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

make import run once

and rename function
This commit is contained in:
PKEv 2015-10-18 22:15:49 +03:00
parent 20d0eb06f6
commit e5a5074f91
4 changed files with 18 additions and 14 deletions

View File

@ -329,7 +329,7 @@ void Core::start()
toxav_register_audio_callback(toxav, playCallAudio, this);
toxav_register_video_callback(toxav, playCallVideo, this);
HistoryKeeper::getInstance()->importAvatar(getSelfId().toString().left(64));
HistoryKeeper::getInstance()->importAvatarToDatabase(getSelfId().toString().left(64));
QPixmap pic = Settings::getInstance().getSavedAvatar(getSelfId().toString());
if (!pic.isNull() && !pic.size().isEmpty())
{

View File

@ -40,7 +40,7 @@ Friend::Friend(uint32_t FriendId, const ToxId &UserId)
widget = new FriendWidget(friendId, getDisplayedName());
chatForm = new ChatForm(this);
HistoryKeeper::getInstance()->importAvatar(UserId.publicKey);
HistoryKeeper::getInstance()->importAvatarToDatabase(UserId.publicKey);
}
Friend::~Friend()

View File

@ -152,6 +152,7 @@ HistoryKeeper::HistoryKeeper(GenericDdInterface *db_) :
if (!ans.value(1).toString().contains("avatar"))
{
//add collum in table
needImport = true;
db->exec("ALTER TABLE aliases ADD COLUMN avatar BLOB");
qDebug() << "Struct DB updated: Added column avatar in table aliases.";
}
@ -167,7 +168,9 @@ HistoryKeeper::HistoryKeeper(GenericDdInterface *db_) :
messageID = sqlAnswer.value(0).toLongLong();
}
void HistoryKeeper::importAvatar(const QString& ownerId)
void HistoryKeeper::importAvatarToDatabase(const QString& ownerId)
{
if (needImport)
{
QString puth (Settings::getInstance().getSettingsDirPath() +
QString("avatars") + QDir::separator() +
@ -181,6 +184,7 @@ void HistoryKeeper::importAvatar(const QString& ownerId)
qDebug() << QString("Import avatar for: %1.").arg(ownerId);
}
}
}
HistoryKeeper::~HistoryKeeper()
{

View File

@ -83,7 +83,7 @@ public:
void removeAvatar(const QString& ownerId);
bool hasAvatar(const QString& ownerId);
void importAvatar(const QString& ownerId); // may be deleted after all move to new db structure
void importAvatarToDatabase(const QString& ownerId); // may be deleted after all move to new db structure
private:
HistoryKeeper(GenericDdInterface *db_);
@ -99,7 +99,7 @@ private:
QList<QString> generateAddChatEntryCmd(const QString& chat, const QString& message, const QString& sender, const QDateTime &dt, bool isSent, QString dispName);
ChatType convertToChatType(int);
bool needImport = false; // must be deleted with "importAvatarToDatabase"
GenericDdInterface *db;
QMap<QString, int> aliases;
QMap<QString, QPair<int, ChatType>> chats;