mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor(settings): Deleted unreadFriendRequests field
Replaced unreadFriendRequests on work with "read" field of struct Request
This commit is contained in:
parent
9f01b662bf
commit
5966c84b84
|
@ -326,7 +326,6 @@ void Settings::loadPersonal(Profile* profile)
|
||||||
ps.endGroup();
|
ps.endGroup();
|
||||||
|
|
||||||
ps.beginGroup("Requests");
|
ps.beginGroup("Requests");
|
||||||
unreadFriendRequests = ps.value("unread", 0).toUInt();
|
|
||||||
size = ps.beginReadArray("Request");
|
size = ps.beginReadArray("Request");
|
||||||
friendRequests.clear();
|
friendRequests.clear();
|
||||||
friendRequests.reserve(size);
|
friendRequests.reserve(size);
|
||||||
|
@ -527,7 +526,6 @@ void Settings::savePersonal(QString profileName, QString password)
|
||||||
ps.endGroup();
|
ps.endGroup();
|
||||||
|
|
||||||
ps.beginGroup("Requests");
|
ps.beginGroup("Requests");
|
||||||
ps.setValue("unread", unreadFriendRequests);
|
|
||||||
ps.beginWriteArray("Request", friendRequests.size());
|
ps.beginWriteArray("Request", friendRequests.size());
|
||||||
index = 0;
|
index = 0;
|
||||||
for (auto& request : friendRequests)
|
for (auto& request : friendRequests)
|
||||||
|
@ -1690,13 +1688,17 @@ bool Settings::addFriendRequest(const QString &friendAddress, const QString &mes
|
||||||
request.read = false;
|
request.read = false;
|
||||||
|
|
||||||
friendRequests.push_back(request);
|
friendRequests.push_back(request);
|
||||||
++unreadFriendRequests;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Settings::getUnreadFriendRequests() const
|
unsigned int Settings::getUnreadFriendRequests() const
|
||||||
{
|
{
|
||||||
QMutexLocker locker{&bigLock};
|
QMutexLocker locker{&bigLock};
|
||||||
|
unsigned int unreadFriendRequests = 0;
|
||||||
|
for (auto request : friendRequests)
|
||||||
|
if (!request.read)
|
||||||
|
unreadFriendRequests++;
|
||||||
|
|
||||||
return unreadFriendRequests;
|
return unreadFriendRequests;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1715,7 +1717,9 @@ int Settings::getFriendRequestSize() const
|
||||||
void Settings::clearUnreadFriendRequests()
|
void Settings::clearUnreadFriendRequests()
|
||||||
{
|
{
|
||||||
QMutexLocker locker{&bigLock};
|
QMutexLocker locker{&bigLock};
|
||||||
unreadFriendRequests = 0;
|
|
||||||
|
for (auto& request : friendRequests)
|
||||||
|
request.read = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::removeFriendRequest(int index)
|
void Settings::removeFriendRequest(int index)
|
||||||
|
@ -1724,6 +1728,12 @@ void Settings::removeFriendRequest(int index)
|
||||||
friendRequests.removeAt(index);
|
friendRequests.removeAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Settings::readFriendRequest(int index)
|
||||||
|
{
|
||||||
|
QMutexLocker locker{&bigLock};
|
||||||
|
friendRequests[index].read = true;
|
||||||
|
}
|
||||||
|
|
||||||
int Settings::removeCircle(int id)
|
int Settings::removeCircle(int id)
|
||||||
{
|
{
|
||||||
// Replace index with last one and remove last one instead.
|
// Replace index with last one and remove last one instead.
|
||||||
|
|
|
@ -311,6 +311,7 @@ public:
|
||||||
int getFriendRequestSize() const;
|
int getFriendRequestSize() const;
|
||||||
void clearUnreadFriendRequests();
|
void clearUnreadFriendRequests();
|
||||||
void removeFriendRequest(int index);
|
void removeFriendRequest(int index);
|
||||||
|
void readFriendRequest(int index);
|
||||||
|
|
||||||
// Assume all widgets have unique names
|
// Assume all widgets have unique names
|
||||||
// Don't use it to save every single thing you want to save, use it
|
// Don't use it to save every single thing you want to save, use it
|
||||||
|
@ -398,7 +399,6 @@ private:
|
||||||
QString globalAutoAcceptDir;
|
QString globalAutoAcceptDir;
|
||||||
|
|
||||||
QList<Request> friendRequests;
|
QList<Request> friendRequests;
|
||||||
unsigned int unreadFriendRequests;
|
|
||||||
|
|
||||||
// GUI
|
// GUI
|
||||||
QString smileyPack;
|
QString smileyPack;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user