mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Contacts changing status to offline and having new events are not moved to the bottom of the list. (see issue #740)
This commit is contained in:
parent
d042c2f346
commit
1ec40b74b7
|
@ -32,7 +32,7 @@ FriendListWidget::FriendListWidget(QWidget *parent) :
|
||||||
|
|
||||||
for (Status s : {Status::Online, Status::Away, Status::Busy, Status::Offline})
|
for (Status s : {Status::Online, Status::Away, Status::Busy, Status::Offline})
|
||||||
{
|
{
|
||||||
QLayout *l = new QVBoxLayout();
|
QVBoxLayout *l = new QVBoxLayout();
|
||||||
l->setSpacing(0);
|
l->setSpacing(0);
|
||||||
l->setMargin(0);
|
l->setMargin(0);
|
||||||
|
|
||||||
|
@ -46,12 +46,12 @@ FriendListWidget::FriendListWidget(QWidget *parent) :
|
||||||
mainLayout->addLayout(layouts[static_cast<int>(Status::Offline)], 4, 0);
|
mainLayout->addLayout(layouts[static_cast<int>(Status::Offline)], 4, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
QLayout* FriendListWidget::getGroupLayout()
|
QVBoxLayout* FriendListWidget::getGroupLayout()
|
||||||
{
|
{
|
||||||
return groupLayout;
|
return groupLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
QLayout* FriendListWidget::getFriendLayout(Status s)
|
QVBoxLayout* FriendListWidget::getFriendLayout(Status s)
|
||||||
{
|
{
|
||||||
auto res = layouts.find(static_cast<int>(s));
|
auto res = layouts.find(static_cast<int>(s));
|
||||||
if (res != layouts.end())
|
if (res != layouts.end())
|
||||||
|
@ -61,8 +61,11 @@ QLayout* FriendListWidget::getFriendLayout(Status s)
|
||||||
return layouts[static_cast<int>(Status::Online)];
|
return layouts[static_cast<int>(Status::Online)];
|
||||||
}
|
}
|
||||||
|
|
||||||
void FriendListWidget::moveWidget(QWidget *w, Status s)
|
void FriendListWidget::moveWidget(QWidget *w, Status s, int hasNewEvents)
|
||||||
{
|
{
|
||||||
mainLayout->removeWidget(w);
|
mainLayout->removeWidget(w);
|
||||||
getFriendLayout(s)->addWidget(w);
|
if (hasNewEvents == 0)
|
||||||
|
getFriendLayout(s)->addWidget(w);
|
||||||
|
else
|
||||||
|
getFriendLayout(s)->insertWidget(0, w);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include "src/corestructs.h"
|
#include "src/corestructs.h"
|
||||||
|
|
||||||
class QLayout;
|
class QVBoxLayout;
|
||||||
class QGridLayout;
|
class QGridLayout;
|
||||||
class QPixmap;
|
class QPixmap;
|
||||||
|
|
||||||
|
@ -31,17 +31,17 @@ class FriendListWidget : public QWidget
|
||||||
public:
|
public:
|
||||||
explicit FriendListWidget(QWidget *parent = 0);
|
explicit FriendListWidget(QWidget *parent = 0);
|
||||||
|
|
||||||
QLayout* getGroupLayout();
|
QVBoxLayout* getGroupLayout();
|
||||||
QLayout* getFriendLayout(Status s);
|
QVBoxLayout* getFriendLayout(Status s);
|
||||||
void moveWidget(QWidget *w, Status s);
|
void moveWidget(QWidget *w, Status s, int hasNewEvents);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QHash<int, QLayout*> layouts;
|
QHash<int, QVBoxLayout*> layouts;
|
||||||
QLayout *groupLayout;
|
QVBoxLayout *groupLayout;
|
||||||
QGridLayout *mainLayout;
|
QGridLayout *mainLayout;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -725,7 +725,7 @@ void Widget::onFriendStatusChanged(int friendId, Status status)
|
||||||
if (!f)
|
if (!f)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
contactListWidget->moveWidget(f->getFriendWidget(), status);
|
contactListWidget->moveWidget(f->getFriendWidget(), status, f->getEventFlag());
|
||||||
|
|
||||||
bool isActualChange = f->getStatus() != status;
|
bool isActualChange = f->getStatus() != status;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user