2014-08-22 23:19:16 +08:00
|
|
|
/*
|
2016-11-28 21:33:38 +08:00
|
|
|
Copyright © 2014-2015 by The qTox Project Contributors
|
2015-06-06 09:40:08 +08:00
|
|
|
|
2014-08-22 23:19:16 +08:00
|
|
|
This file is part of qTox, a Qt-based graphical interface for Tox.
|
|
|
|
|
2015-06-06 09:40:08 +08:00
|
|
|
qTox is libre software: you can redistribute it and/or modify
|
2014-08-22 23:19:16 +08:00
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
2015-06-06 09:40:08 +08:00
|
|
|
|
|
|
|
qTox is distributed in the hope that it will be useful,
|
2014-08-22 23:19:16 +08:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2015-06-06 09:40:08 +08:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2014-08-22 23:19:16 +08:00
|
|
|
|
2015-06-06 09:40:08 +08:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with qTox. If not, see <http://www.gnu.org/licenses/>.
|
2014-08-22 23:19:16 +08:00
|
|
|
*/
|
2015-06-07 11:20:06 +08:00
|
|
|
|
2014-08-22 23:19:16 +08:00
|
|
|
#include "friendlistwidget.h"
|
2015-06-07 11:20:06 +08:00
|
|
|
#include "friendlistlayout.h"
|
2016-12-19 10:26:26 +08:00
|
|
|
#include "src/friend.h"
|
|
|
|
#include "src/friendlist.h"
|
|
|
|
#include "src/persistence/settings.h"
|
2015-06-07 11:20:06 +08:00
|
|
|
#include "friendwidget.h"
|
2015-05-28 01:17:12 +08:00
|
|
|
#include "groupwidget.h"
|
2015-05-28 22:28:11 +08:00
|
|
|
#include "circlewidget.h"
|
2015-06-10 01:40:45 +08:00
|
|
|
#include "widget.h"
|
2015-06-07 11:20:06 +08:00
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QMimeData>
|
|
|
|
#include <QDragEnterEvent>
|
|
|
|
#include <QDragLeaveEvent>
|
2015-07-31 01:24:34 +08:00
|
|
|
#include <QTimer>
|
2015-05-28 01:17:12 +08:00
|
|
|
#include <cassert>
|
2014-08-22 23:19:16 +08:00
|
|
|
|
2015-06-12 03:27:54 +08:00
|
|
|
enum Time : int
|
|
|
|
{
|
|
|
|
Today = 0,
|
|
|
|
Yesterday = 1,
|
|
|
|
ThisWeek = 2,
|
|
|
|
ThisMonth = 3,
|
|
|
|
Month1Ago = 4,
|
|
|
|
Month2Ago = 5,
|
|
|
|
Month3Ago = 6,
|
|
|
|
Month4Ago = 7,
|
|
|
|
Month5Ago = 8,
|
|
|
|
LongAgo = 9,
|
|
|
|
Never = 10
|
|
|
|
};
|
|
|
|
|
|
|
|
bool last7DaysWasLastMonth()
|
|
|
|
{
|
|
|
|
return QDate::currentDate().addDays(-7).month() == QDate::currentDate().month();
|
|
|
|
}
|
|
|
|
|
2015-07-01 21:10:55 +08:00
|
|
|
Time getTime(const QDate& date)
|
2015-06-12 03:27:54 +08:00
|
|
|
{
|
|
|
|
if (date == QDate())
|
|
|
|
return Never;
|
|
|
|
|
|
|
|
QDate today = QDate::currentDate();
|
2015-06-18 03:45:03 +08:00
|
|
|
|
2015-06-12 03:27:54 +08:00
|
|
|
if (date == today)
|
|
|
|
return Today;
|
|
|
|
|
|
|
|
today = today.addDays(-1);
|
2015-06-18 03:45:03 +08:00
|
|
|
|
2015-06-12 03:27:54 +08:00
|
|
|
if (date == today)
|
|
|
|
return Yesterday;
|
|
|
|
|
|
|
|
today = today.addDays(-6);
|
2015-06-18 03:45:03 +08:00
|
|
|
|
2015-06-12 03:27:54 +08:00
|
|
|
if (date >= today)
|
|
|
|
return ThisWeek;
|
|
|
|
|
|
|
|
today = today.addDays(-today.day() + 1); // Go to the beginning of the month.
|
2015-06-18 03:45:03 +08:00
|
|
|
|
2015-06-12 03:27:54 +08:00
|
|
|
if (last7DaysWasLastMonth())
|
|
|
|
{
|
|
|
|
if (date >= today)
|
|
|
|
return ThisMonth;
|
2015-06-18 03:45:03 +08:00
|
|
|
|
2015-06-12 03:27:54 +08:00
|
|
|
today = today.addMonths(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (date >= today)
|
|
|
|
return Month1Ago;
|
|
|
|
|
|
|
|
today = today.addMonths(-1);
|
2015-06-18 03:45:03 +08:00
|
|
|
|
2015-06-12 03:27:54 +08:00
|
|
|
if (date >= today)
|
|
|
|
return Month2Ago;
|
|
|
|
|
|
|
|
today = today.addMonths(-1);
|
2015-06-18 03:45:03 +08:00
|
|
|
|
2015-06-12 03:27:54 +08:00
|
|
|
if (date >= today)
|
|
|
|
return Month3Ago;
|
|
|
|
|
|
|
|
today = today.addMonths(-1);
|
2015-06-18 03:45:03 +08:00
|
|
|
|
2015-06-12 03:27:54 +08:00
|
|
|
if (date >= today)
|
|
|
|
return Month4Ago;
|
|
|
|
|
|
|
|
today = today.addMonths(-1);
|
2015-06-18 03:45:03 +08:00
|
|
|
|
2015-06-12 03:27:54 +08:00
|
|
|
if (date >= today)
|
|
|
|
return Month5Ago;
|
|
|
|
|
|
|
|
return LongAgo;
|
|
|
|
}
|
|
|
|
|
2015-06-18 23:27:50 +08:00
|
|
|
QDate getDateFriend(Friend* contact)
|
|
|
|
{
|
2016-12-30 06:14:48 +08:00
|
|
|
return Settings::getInstance().getFriendActivity(contact->getPublicKey());
|
2015-06-18 23:27:50 +08:00
|
|
|
}
|
|
|
|
|
2015-07-31 01:24:34 +08:00
|
|
|
qint64 timeUntilTomorrow()
|
|
|
|
{
|
|
|
|
QDateTime now = QDateTime::currentDateTime();
|
|
|
|
QDateTime tomorrow = now.addDays(1); // Tomorrow.
|
|
|
|
tomorrow.setTime(QTime()); // Midnight.
|
|
|
|
return now.msecsTo(tomorrow);
|
|
|
|
}
|
|
|
|
|
2015-06-07 11:20:06 +08:00
|
|
|
FriendListWidget::FriendListWidget(Widget* parent, bool groupsOnTop)
|
2015-06-03 21:51:23 +08:00
|
|
|
: QWidget(parent)
|
2015-06-17 20:40:14 +08:00
|
|
|
// Prevent Valgrind from complaining. We're changing this to Name here.
|
|
|
|
// Must be Activity for change to take effect.
|
|
|
|
, mode(Activity)
|
2015-06-03 21:51:23 +08:00
|
|
|
, groupsOnTop(groupsOnTop)
|
2014-08-22 23:19:16 +08:00
|
|
|
{
|
2015-06-03 21:51:23 +08:00
|
|
|
listLayout = new FriendListLayout();
|
2015-05-29 00:58:44 +08:00
|
|
|
setLayout(listLayout);
|
2014-08-22 23:19:16 +08:00
|
|
|
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
|
2015-05-28 01:17:12 +08:00
|
|
|
|
2015-06-03 21:51:23 +08:00
|
|
|
groupLayout.getLayout()->setSpacing(0);
|
|
|
|
groupLayout.getLayout()->setMargin(0);
|
|
|
|
|
2015-06-17 20:40:14 +08:00
|
|
|
// Prevent QLayout's add child warning before setting the mode.
|
|
|
|
listLayout->removeItem(listLayout->getLayoutOnline());
|
|
|
|
listLayout->removeItem(listLayout->getLayoutOffline());
|
|
|
|
|
2015-06-12 03:27:54 +08:00
|
|
|
setMode(Name);
|
2015-05-29 00:58:44 +08:00
|
|
|
|
2015-06-03 21:51:23 +08:00
|
|
|
onGroupchatPositionChanged(groupsOnTop);
|
2015-07-31 01:24:34 +08:00
|
|
|
dayTimer = new QTimer(this);
|
|
|
|
dayTimer->setTimerType(Qt::VeryCoarseTimer);
|
|
|
|
connect(dayTimer, &QTimer::timeout, this, &FriendListWidget::dayTimeout);
|
|
|
|
dayTimer->start(timeUntilTomorrow());
|
2015-06-03 21:51:23 +08:00
|
|
|
|
2015-05-29 00:58:44 +08:00
|
|
|
setAcceptDrops(true);
|
2014-08-22 23:19:16 +08:00
|
|
|
}
|
|
|
|
|
2015-06-17 20:40:14 +08:00
|
|
|
FriendListWidget::~FriendListWidget()
|
|
|
|
{
|
|
|
|
if (activityLayout != nullptr)
|
|
|
|
{
|
|
|
|
QLayoutItem* item;
|
|
|
|
while ((item = activityLayout->takeAt(0)) != nullptr)
|
|
|
|
{
|
|
|
|
delete item->widget();
|
|
|
|
delete item;
|
|
|
|
}
|
|
|
|
delete activityLayout;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (circleLayout != nullptr)
|
|
|
|
{
|
|
|
|
QLayoutItem* item;
|
|
|
|
while ((item = circleLayout->getLayout()->takeAt(0)) != nullptr)
|
|
|
|
{
|
|
|
|
delete item->widget();
|
|
|
|
delete item;
|
|
|
|
}
|
|
|
|
delete circleLayout;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-12 03:27:54 +08:00
|
|
|
void FriendListWidget::setMode(Mode mode)
|
|
|
|
{
|
2015-06-13 02:52:05 +08:00
|
|
|
if (this->mode == mode)
|
|
|
|
return;
|
|
|
|
|
2015-06-12 03:27:54 +08:00
|
|
|
this->mode = mode;
|
2015-06-18 23:27:50 +08:00
|
|
|
|
2015-06-12 03:27:54 +08:00
|
|
|
if (mode == Name)
|
|
|
|
{
|
2015-06-12 21:53:44 +08:00
|
|
|
circleLayout = new GenericChatItemLayout;
|
|
|
|
circleLayout->getLayout()->setSpacing(0);
|
|
|
|
circleLayout->getLayout()->setMargin(0);
|
|
|
|
|
2015-06-12 03:27:54 +08:00
|
|
|
for (int i = 0; i < Settings::getInstance().getCircleCount(); ++i)
|
2015-06-18 23:27:50 +08:00
|
|
|
{
|
2015-06-12 03:27:54 +08:00
|
|
|
addCircleWidget(i);
|
2015-06-18 23:27:50 +08:00
|
|
|
CircleWidget::getFromID(i)->setVisible(false);
|
|
|
|
}
|
2015-06-12 03:27:54 +08:00
|
|
|
|
2015-06-19 00:01:30 +08:00
|
|
|
// Only display circles once all created to avoid artifacts.
|
|
|
|
for (int i = 0; i < Settings::getInstance().getCircleCount(); ++i)
|
|
|
|
CircleWidget::getFromID(i)->setVisible(true);
|
|
|
|
|
2016-08-22 20:24:37 +08:00
|
|
|
int count = activityLayout ? activityLayout->count() : 0;
|
|
|
|
for (int i = 0; i < count; i++)
|
2015-06-12 21:53:44 +08:00
|
|
|
{
|
2017-01-06 19:02:54 +08:00
|
|
|
QWidget* widget = activityLayout->itemAt(i)->widget();
|
2016-08-22 20:24:37 +08:00
|
|
|
CategoryWidget *categoryWidget = qobject_cast<CategoryWidget*>(widget);
|
|
|
|
if (categoryWidget)
|
|
|
|
{
|
|
|
|
categoryWidget->moveFriendWidgets(this);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qWarning() << "Unexpected widget";
|
|
|
|
}
|
2015-06-12 21:53:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
listLayout->addLayout(listLayout->getLayoutOnline());
|
|
|
|
listLayout->addLayout(listLayout->getLayoutOffline());
|
|
|
|
listLayout->addLayout(circleLayout->getLayout());
|
|
|
|
onGroupchatPositionChanged(groupsOnTop);
|
|
|
|
|
|
|
|
if (activityLayout != nullptr)
|
|
|
|
{
|
2015-06-17 20:40:14 +08:00
|
|
|
QLayoutItem* item;
|
|
|
|
while ((item = activityLayout->takeAt(0)) != nullptr)
|
|
|
|
{
|
|
|
|
delete item->widget();
|
|
|
|
delete item;
|
|
|
|
}
|
|
|
|
delete activityLayout;
|
|
|
|
activityLayout = nullptr;
|
2015-06-12 21:53:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
reDraw();
|
2015-06-12 03:27:54 +08:00
|
|
|
}
|
|
|
|
else if (mode == Activity)
|
|
|
|
{
|
2015-06-13 02:52:05 +08:00
|
|
|
activityLayout = new QVBoxLayout();
|
2015-06-12 03:27:54 +08:00
|
|
|
|
|
|
|
CategoryWidget* categoryToday = new CategoryWidget(this);
|
2015-06-17 20:40:14 +08:00
|
|
|
categoryToday->setObjectName("Todddd");
|
2015-06-12 03:27:54 +08:00
|
|
|
categoryToday->setName(tr("Today", "Category for sorting friends by activity"));
|
|
|
|
activityLayout->addWidget(categoryToday);
|
|
|
|
|
|
|
|
CategoryWidget* categoryYesterday = new CategoryWidget(this);
|
|
|
|
categoryYesterday->setName(tr("Yesterday", "Category for sorting friends by activity"));
|
|
|
|
activityLayout->addWidget(categoryYesterday);
|
|
|
|
|
|
|
|
CategoryWidget* categoryLastWeek = new CategoryWidget(this);
|
|
|
|
categoryLastWeek->setName(tr("Last 7 days", "Category for sorting friends by activity"));
|
|
|
|
activityLayout->addWidget(categoryLastWeek);
|
|
|
|
|
|
|
|
QDate currentDate = QDate::currentDate();
|
2015-07-01 21:10:55 +08:00
|
|
|
//if (last7DaysWasLastMonth())
|
2015-06-12 03:27:54 +08:00
|
|
|
{
|
|
|
|
CategoryWidget* categoryThisMonth = new CategoryWidget(this);
|
2015-07-01 19:07:34 +08:00
|
|
|
categoryThisMonth->setName(tr("This month", "Category for sorting friends by activity"));
|
2015-06-12 03:27:54 +08:00
|
|
|
activityLayout->addWidget(categoryThisMonth);
|
2015-07-01 21:10:55 +08:00
|
|
|
categoryThisMonth->setVisible(last7DaysWasLastMonth());
|
|
|
|
|
|
|
|
if (categoryThisMonth->isVisible())
|
|
|
|
currentDate = currentDate.addMonths(-1);
|
2015-06-12 03:27:54 +08:00
|
|
|
}
|
|
|
|
|
2016-05-10 22:33:15 +08:00
|
|
|
QLocale *ql = new QLocale(Settings::getInstance().getTranslation());
|
|
|
|
|
2015-06-12 03:27:54 +08:00
|
|
|
CategoryWidget* categoryLast1Month = new CategoryWidget(this);
|
2016-05-10 22:33:15 +08:00
|
|
|
categoryLast1Month->setName(ql->monthName(currentDate.month()));
|
2015-06-12 03:27:54 +08:00
|
|
|
activityLayout->addWidget(categoryLast1Month);
|
|
|
|
|
|
|
|
currentDate = currentDate.addMonths(-1);
|
|
|
|
CategoryWidget* categoryLast2Month = new CategoryWidget(this);
|
2016-05-10 22:33:15 +08:00
|
|
|
categoryLast2Month->setName(ql->monthName(currentDate.month()));
|
2015-06-12 03:27:54 +08:00
|
|
|
activityLayout->addWidget(categoryLast2Month);
|
|
|
|
|
|
|
|
currentDate = currentDate.addMonths(-1);
|
|
|
|
CategoryWidget* categoryLast3Month = new CategoryWidget(this);
|
2016-05-10 22:33:15 +08:00
|
|
|
categoryLast3Month->setName(ql->monthName(currentDate.month()));
|
2015-06-12 03:27:54 +08:00
|
|
|
activityLayout->addWidget(categoryLast3Month);
|
|
|
|
|
|
|
|
currentDate = currentDate.addMonths(-1);
|
|
|
|
CategoryWidget* categoryLast4Month = new CategoryWidget(this);
|
2016-05-10 22:33:15 +08:00
|
|
|
categoryLast4Month->setName(ql->monthName(currentDate.month()));
|
2015-06-12 03:27:54 +08:00
|
|
|
activityLayout->addWidget(categoryLast4Month);
|
|
|
|
|
|
|
|
currentDate = currentDate.addMonths(-1);
|
|
|
|
CategoryWidget* categoryLast5Month = new CategoryWidget(this);
|
2016-05-10 22:33:15 +08:00
|
|
|
categoryLast5Month->setName(ql->monthName(currentDate.month()));
|
2015-06-12 03:27:54 +08:00
|
|
|
activityLayout->addWidget(categoryLast5Month);
|
|
|
|
|
|
|
|
CategoryWidget* categoryOlder = new CategoryWidget(this);
|
|
|
|
categoryOlder->setName(tr("Older than 6 Months", "Category for sorting friends by activity"));
|
|
|
|
activityLayout->addWidget(categoryOlder);
|
|
|
|
|
|
|
|
CategoryWidget* categoryNever = new CategoryWidget(this);
|
2015-06-13 00:52:41 +08:00
|
|
|
categoryNever->setName(tr("Unknown", "Category for sorting friends by activity"));
|
2015-06-12 03:27:54 +08:00
|
|
|
activityLayout->addWidget(categoryNever);
|
|
|
|
|
2016-05-10 22:33:15 +08:00
|
|
|
delete ql;
|
2016-05-15 02:57:10 +08:00
|
|
|
ql = nullptr;
|
2016-05-10 22:33:15 +08:00
|
|
|
|
2016-08-22 20:24:37 +08:00
|
|
|
moveFriends(listLayout->getLayoutOffline());
|
|
|
|
moveFriends(listLayout->getLayoutOnline());
|
|
|
|
moveFriends(circleLayout->getLayout());
|
2015-06-12 03:27:54 +08:00
|
|
|
|
|
|
|
for (int i = 0; i < activityLayout->count(); ++i)
|
|
|
|
{
|
2016-09-23 10:06:20 +08:00
|
|
|
CategoryWidget* categoryWidget = qobject_cast<CategoryWidget*>(activityLayout->itemAt(i)->widget());
|
2015-06-18 23:27:50 +08:00
|
|
|
categoryWidget->setVisible(categoryWidget->hasChatrooms());
|
2015-06-12 03:27:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
listLayout->removeItem(listLayout->getLayoutOnline());
|
|
|
|
listLayout->removeItem(listLayout->getLayoutOffline());
|
2015-06-12 21:53:44 +08:00
|
|
|
|
2015-06-17 20:40:14 +08:00
|
|
|
if (circleLayout != nullptr)
|
|
|
|
{
|
2016-07-31 22:17:11 +08:00
|
|
|
listLayout->removeItem(circleLayout->getLayout());
|
|
|
|
|
2015-06-17 20:40:14 +08:00
|
|
|
QLayoutItem* item;
|
|
|
|
while ((item = circleLayout->getLayout()->takeAt(0)) != nullptr)
|
|
|
|
{
|
|
|
|
delete item->widget();
|
|
|
|
delete item;
|
|
|
|
}
|
|
|
|
delete circleLayout;
|
|
|
|
circleLayout = nullptr;
|
|
|
|
}
|
2015-06-12 21:53:44 +08:00
|
|
|
|
2016-07-31 22:17:11 +08:00
|
|
|
listLayout->insertLayout(1, activityLayout);
|
|
|
|
|
2015-06-17 20:40:14 +08:00
|
|
|
reDraw();
|
2015-06-12 03:27:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-06 19:02:54 +08:00
|
|
|
void FriendListWidget::moveFriends(QLayout* layout)
|
2016-08-22 20:24:37 +08:00
|
|
|
{
|
|
|
|
for (int i = 0; i < layout->count(); i++)
|
|
|
|
{
|
2017-01-06 19:02:54 +08:00
|
|
|
QWidget* widget = layout->itemAt(i)->widget();
|
2016-08-22 20:24:37 +08:00
|
|
|
FriendWidget *friendWidget = qobject_cast<FriendWidget*>(widget);
|
|
|
|
CircleWidget *circleWidget = qobject_cast<CircleWidget*>(widget);
|
|
|
|
if (circleWidget)
|
|
|
|
{
|
|
|
|
circleWidget->moveFriendWidgets(this);
|
|
|
|
}
|
|
|
|
else if (friendWidget)
|
|
|
|
{
|
|
|
|
int friendId = friendWidget->friendId;
|
|
|
|
Friend *contact = FriendList::findFriend(friendId);
|
|
|
|
QDate activityDate = getDateFriend(contact);
|
|
|
|
Time time = getTime(activityDate);
|
|
|
|
|
2017-01-06 19:02:54 +08:00
|
|
|
QWidget* w = activityLayout->itemAt(time)->widget();
|
2016-08-22 20:24:37 +08:00
|
|
|
CategoryWidget* categoryWidget = qobject_cast<CategoryWidget*>(w);
|
|
|
|
categoryWidget->addFriendWidget(friendWidget, contact->getStatus());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-12 21:53:44 +08:00
|
|
|
FriendListWidget::Mode FriendListWidget::getMode() const
|
|
|
|
{
|
|
|
|
return mode;
|
|
|
|
}
|
|
|
|
|
2015-06-07 11:20:06 +08:00
|
|
|
void FriendListWidget::addGroupWidget(GroupWidget* widget)
|
2014-08-22 23:19:16 +08:00
|
|
|
{
|
2015-06-03 21:51:23 +08:00
|
|
|
groupLayout.addSortedWidget(widget);
|
|
|
|
connect(widget, &GroupWidget::renameRequested, this, &FriendListWidget::renameGroupWidget);
|
2014-08-22 23:19:16 +08:00
|
|
|
}
|
|
|
|
|
2015-06-07 11:20:06 +08:00
|
|
|
void FriendListWidget::addFriendWidget(FriendWidget* w, Status s, int circleIndex)
|
2015-05-31 03:10:43 +08:00
|
|
|
{
|
2015-06-05 23:15:59 +08:00
|
|
|
CircleWidget* circleWidget = CircleWidget::getFromID(circleIndex);
|
|
|
|
if (circleWidget == nullptr)
|
2015-05-31 03:10:43 +08:00
|
|
|
moveWidget(w, s, true);
|
|
|
|
else
|
2015-06-05 23:15:59 +08:00
|
|
|
circleWidget->addFriendWidget(w, s);
|
2015-05-31 03:10:43 +08:00
|
|
|
}
|
|
|
|
|
2015-06-15 21:48:34 +08:00
|
|
|
void FriendListWidget::removeFriendWidget(FriendWidget* w)
|
|
|
|
{
|
|
|
|
Friend* contact = FriendList::findFriend(w->friendId);
|
|
|
|
if (mode == Activity)
|
|
|
|
{
|
2015-06-18 23:27:50 +08:00
|
|
|
QDate activityDate = getDateFriend(contact);
|
2015-06-15 21:48:34 +08:00
|
|
|
Time time = getTime(activityDate);
|
2016-09-23 10:06:20 +08:00
|
|
|
CategoryWidget* categoryWidget = qobject_cast<CategoryWidget*>(activityLayout->itemAt(time)->widget());
|
2015-06-15 21:48:34 +08:00
|
|
|
categoryWidget->removeFriendWidget(w, contact->getStatus());
|
|
|
|
categoryWidget->setVisible(categoryWidget->hasChatrooms());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-12-30 06:14:48 +08:00
|
|
|
int id = Settings::getInstance().getFriendCircleID(contact->getPublicKey());
|
2015-06-15 21:48:34 +08:00
|
|
|
CircleWidget* circleWidget = CircleWidget::getFromID(id);
|
|
|
|
if (circleWidget != nullptr)
|
|
|
|
{
|
|
|
|
circleWidget->removeFriendWidget(w, contact->getStatus());
|
|
|
|
Widget::getInstance()->searchCircle(circleWidget);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-04 04:18:40 +08:00
|
|
|
void FriendListWidget::addCircleWidget(int id)
|
2015-05-31 03:10:43 +08:00
|
|
|
{
|
2015-06-07 11:20:06 +08:00
|
|
|
createCircleWidget(id);
|
2015-05-31 03:10:43 +08:00
|
|
|
}
|
|
|
|
|
2015-06-07 11:20:06 +08:00
|
|
|
void FriendListWidget::addCircleWidget(FriendWidget* friendWidget)
|
2015-05-28 01:17:12 +08:00
|
|
|
{
|
2015-06-07 11:20:06 +08:00
|
|
|
CircleWidget* circleWidget = createCircleWidget();
|
2015-06-19 00:37:37 +08:00
|
|
|
if (circleWidget != nullptr)
|
2015-05-29 21:26:43 +08:00
|
|
|
{
|
2015-06-19 00:37:37 +08:00
|
|
|
if (friendWidget != nullptr)
|
|
|
|
{
|
2017-01-06 19:02:54 +08:00
|
|
|
Friend* f = FriendList::findFriend(friendWidget->friendId);
|
2016-08-22 20:24:37 +08:00
|
|
|
ToxPk toxPk = f->getPublicKey();
|
|
|
|
int circleId = Settings::getInstance().getFriendCircleID(toxPk);
|
|
|
|
CircleWidget* circleOriginal = CircleWidget::getFromID(circleId);
|
2015-06-07 11:20:06 +08:00
|
|
|
|
2016-08-22 20:24:37 +08:00
|
|
|
circleWidget->addFriendWidget(friendWidget, f->getStatus());
|
2015-06-19 00:37:37 +08:00
|
|
|
circleWidget->setExpanded(true);
|
2015-06-07 11:20:06 +08:00
|
|
|
|
2015-06-19 00:37:37 +08:00
|
|
|
if (circleOriginal != nullptr)
|
|
|
|
Widget::getInstance()->searchCircle(circleOriginal);
|
2015-06-19 02:55:46 +08:00
|
|
|
|
2015-06-19 00:37:37 +08:00
|
|
|
}
|
2015-06-07 11:20:06 +08:00
|
|
|
|
2015-06-19 00:37:37 +08:00
|
|
|
Widget::getInstance()->searchCircle(circleWidget);
|
2015-07-20 20:13:51 +08:00
|
|
|
|
|
|
|
if (window()->isActiveWindow())
|
|
|
|
circleWidget->editName();
|
2015-05-29 21:26:43 +08:00
|
|
|
}
|
2015-07-20 20:13:51 +08:00
|
|
|
reDraw();
|
2015-05-29 06:36:21 +08:00
|
|
|
}
|
|
|
|
|
2015-06-07 11:20:06 +08:00
|
|
|
void FriendListWidget::removeCircleWidget(CircleWidget* widget)
|
2015-05-29 06:36:21 +08:00
|
|
|
{
|
2015-06-12 21:53:44 +08:00
|
|
|
circleLayout->removeSortedWidget(widget);
|
2015-05-29 06:36:21 +08:00
|
|
|
widget->deleteLater();
|
2015-05-28 01:17:12 +08:00
|
|
|
}
|
|
|
|
|
2015-05-28 22:28:11 +08:00
|
|
|
void FriendListWidget::searchChatrooms(const QString &searchString, bool hideOnline, bool hideOffline, bool hideGroups)
|
|
|
|
{
|
2015-06-06 00:57:05 +08:00
|
|
|
groupLayout.search(searchString, hideGroups);
|
2015-06-03 21:51:23 +08:00
|
|
|
listLayout->searchChatrooms(searchString, hideOnline, hideOffline);
|
2015-06-18 23:27:50 +08:00
|
|
|
|
2015-06-18 03:45:03 +08:00
|
|
|
if (circleLayout != nullptr)
|
2015-05-28 22:28:11 +08:00
|
|
|
{
|
2015-06-18 03:45:03 +08:00
|
|
|
for (int i = 0; i != circleLayout->getLayout()->count(); ++i)
|
|
|
|
{
|
|
|
|
CircleWidget* circleWidget = static_cast<CircleWidget*>(circleLayout->getLayout()->itemAt(i)->widget());
|
|
|
|
circleWidget->search(searchString, true, hideOnline, hideOffline);
|
|
|
|
}
|
2015-05-28 22:28:11 +08:00
|
|
|
}
|
2015-06-18 23:27:50 +08:00
|
|
|
else if (activityLayout != nullptr)
|
|
|
|
{
|
|
|
|
for (int i = 0; i != activityLayout->count(); ++i)
|
|
|
|
{
|
|
|
|
CategoryWidget* categoryWidget = static_cast<CategoryWidget*>(activityLayout->itemAt(i)->widget());
|
|
|
|
categoryWidget->search(searchString, true, hideOnline, hideOffline);
|
|
|
|
categoryWidget->setVisible(categoryWidget->hasChatrooms());
|
|
|
|
}
|
|
|
|
}
|
2015-05-28 22:28:11 +08:00
|
|
|
}
|
|
|
|
|
2015-06-08 02:25:05 +08:00
|
|
|
void FriendListWidget::renameGroupWidget(GroupWidget* groupWidget, const QString &newName)
|
2015-05-28 01:17:12 +08:00
|
|
|
{
|
2015-06-03 21:51:23 +08:00
|
|
|
groupLayout.removeSortedWidget(groupWidget);
|
|
|
|
groupWidget->setName(newName);
|
|
|
|
groupLayout.addSortedWidget(groupWidget);
|
2014-08-22 23:19:16 +08:00
|
|
|
}
|
|
|
|
|
2015-06-11 00:11:50 +08:00
|
|
|
void FriendListWidget::renameCircleWidget(CircleWidget* circleWidget, const QString &newName)
|
2015-06-02 02:39:40 +08:00
|
|
|
{
|
2015-06-12 21:53:44 +08:00
|
|
|
circleLayout->removeSortedWidget(circleWidget);
|
2015-06-02 02:39:40 +08:00
|
|
|
circleWidget->setName(newName);
|
2015-06-12 21:53:44 +08:00
|
|
|
circleLayout->addSortedWidget(circleWidget);
|
2015-06-02 02:39:40 +08:00
|
|
|
}
|
|
|
|
|
2015-03-12 08:41:18 +08:00
|
|
|
void FriendListWidget::onGroupchatPositionChanged(bool top)
|
|
|
|
{
|
2015-06-03 21:51:23 +08:00
|
|
|
groupsOnTop = top;
|
2015-06-12 21:53:44 +08:00
|
|
|
|
|
|
|
if (mode != Name)
|
|
|
|
return;
|
|
|
|
|
2015-06-03 21:51:23 +08:00
|
|
|
listLayout->removeItem(groupLayout.getLayout());
|
2015-06-12 21:53:44 +08:00
|
|
|
|
2015-03-26 00:27:33 +08:00
|
|
|
if (top)
|
2015-06-03 21:51:23 +08:00
|
|
|
listLayout->insertLayout(0, groupLayout.getLayout());
|
2015-03-23 17:38:24 +08:00
|
|
|
else
|
2015-06-03 21:51:23 +08:00
|
|
|
listLayout->insertLayout(1, groupLayout.getLayout());
|
2015-06-12 21:53:44 +08:00
|
|
|
|
|
|
|
reDraw();
|
2015-06-03 21:51:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void FriendListWidget::cycleContacts(GenericChatroomWidget* activeChatroomWidget, bool forward)
|
|
|
|
{
|
|
|
|
if (activeChatroomWidget == nullptr)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int index = -1;
|
2016-09-23 10:06:20 +08:00
|
|
|
FriendWidget* friendWidget = qobject_cast<FriendWidget*>(activeChatroomWidget);
|
2015-06-18 03:45:03 +08:00
|
|
|
|
|
|
|
if (mode == Activity)
|
|
|
|
{
|
|
|
|
if (friendWidget == nullptr)
|
|
|
|
return;
|
|
|
|
|
2015-06-18 23:27:50 +08:00
|
|
|
QDate activityDate = getDateFriend(FriendList::findFriend(friendWidget->friendId));
|
2015-06-18 03:45:03 +08:00
|
|
|
index = getTime(activityDate);
|
2016-09-23 10:06:20 +08:00
|
|
|
CategoryWidget* categoryWidget = qobject_cast<CategoryWidget*>(activityLayout->itemAt(index)->widget());
|
2015-06-18 03:45:03 +08:00
|
|
|
|
|
|
|
if (categoryWidget == nullptr || categoryWidget->cycleContacts(friendWidget, forward))
|
|
|
|
return;
|
|
|
|
|
|
|
|
index += forward ? 1 : -1;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
// Bounds checking.
|
|
|
|
if (index < Today)
|
|
|
|
{
|
|
|
|
index = Never;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (index > Never)
|
|
|
|
{
|
|
|
|
index = Today;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-09-23 10:06:20 +08:00
|
|
|
CategoryWidget* categoryWidget = qobject_cast<CategoryWidget*>(activityLayout->itemAt(index)->widget());
|
2015-06-18 03:45:03 +08:00
|
|
|
|
|
|
|
if (categoryWidget != nullptr)
|
|
|
|
{
|
|
|
|
if (!categoryWidget->cycleContacts(forward))
|
|
|
|
{
|
|
|
|
// Skip empty or finished categories.
|
|
|
|
index += forward ? 1 : -1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2015-06-03 21:51:23 +08:00
|
|
|
|
2015-06-18 03:45:03 +08:00
|
|
|
QLayout* currentLayout = nullptr;
|
2015-06-06 01:38:07 +08:00
|
|
|
CircleWidget* circleWidget = nullptr;
|
|
|
|
|
|
|
|
if (friendWidget != nullptr)
|
2015-06-03 21:51:23 +08:00
|
|
|
{
|
2016-12-30 06:14:48 +08:00
|
|
|
circleWidget = CircleWidget::getFromID(Settings::getInstance().getFriendCircleID(FriendList::findFriend(friendWidget->friendId)->getPublicKey()));
|
2015-06-06 01:38:07 +08:00
|
|
|
if (circleWidget != nullptr)
|
2015-06-03 21:51:23 +08:00
|
|
|
{
|
2015-06-06 01:38:07 +08:00
|
|
|
if (circleWidget->cycleContacts(friendWidget, forward))
|
|
|
|
return;
|
2015-06-03 21:51:23 +08:00
|
|
|
|
2015-06-12 21:53:44 +08:00
|
|
|
index = circleLayout->indexOfSortedWidget(circleWidget);
|
|
|
|
currentLayout = circleLayout->getLayout();
|
2015-06-06 01:38:07 +08:00
|
|
|
}
|
|
|
|
else
|
2015-06-03 21:51:23 +08:00
|
|
|
{
|
|
|
|
currentLayout = listLayout->getLayoutOnline();
|
|
|
|
index = listLayout->indexOfFriendWidget(friendWidget, true);
|
|
|
|
if (index == -1)
|
|
|
|
{
|
|
|
|
currentLayout = listLayout->getLayoutOffline();
|
|
|
|
index = listLayout->indexOfFriendWidget(friendWidget, false);
|
|
|
|
}
|
|
|
|
}
|
2015-06-06 01:38:07 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-09-23 10:06:20 +08:00
|
|
|
GroupWidget* groupWidget = qobject_cast<GroupWidget*>(activeChatroomWidget);
|
2015-06-06 01:38:07 +08:00
|
|
|
if (groupWidget != nullptr)
|
2015-06-03 21:51:23 +08:00
|
|
|
{
|
2015-06-06 01:38:07 +08:00
|
|
|
currentLayout = groupLayout.getLayout();
|
|
|
|
index = groupLayout.indexOfSortedWidget(groupWidget);
|
2015-06-03 21:51:23 +08:00
|
|
|
}
|
2015-06-06 01:38:07 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
};
|
2015-06-03 21:51:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
index += forward ? 1 : -1;
|
2015-06-18 03:45:03 +08:00
|
|
|
|
2015-06-03 21:51:23 +08:00
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
// Bounds checking.
|
|
|
|
if (index < 0)
|
|
|
|
{
|
|
|
|
currentLayout = nextLayout(currentLayout, forward);
|
|
|
|
index = currentLayout->count() - 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (index >= currentLayout->count())
|
|
|
|
{
|
|
|
|
currentLayout = nextLayout(currentLayout, forward);
|
|
|
|
index = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Go to the actual next index.
|
|
|
|
if (currentLayout == listLayout->getLayoutOnline() || currentLayout == listLayout->getLayoutOffline() || currentLayout == groupLayout.getLayout())
|
|
|
|
{
|
2016-09-23 10:06:20 +08:00
|
|
|
GenericChatroomWidget* chatWidget = qobject_cast<GenericChatroomWidget*>(currentLayout->itemAt(index)->widget());
|
2015-06-18 03:45:03 +08:00
|
|
|
|
2015-06-03 21:51:23 +08:00
|
|
|
if (chatWidget != nullptr)
|
|
|
|
emit chatWidget->chatroomWidgetClicked(chatWidget);
|
2015-06-18 03:45:03 +08:00
|
|
|
|
2015-06-03 21:51:23 +08:00
|
|
|
return;
|
|
|
|
}
|
2015-06-12 21:53:44 +08:00
|
|
|
else if (currentLayout == circleLayout->getLayout())
|
2015-06-03 21:51:23 +08:00
|
|
|
{
|
2016-09-23 10:06:20 +08:00
|
|
|
circleWidget = qobject_cast<CircleWidget*>(currentLayout->itemAt(index)->widget());
|
2015-06-03 21:51:23 +08:00
|
|
|
if (circleWidget != nullptr)
|
|
|
|
{
|
|
|
|
if (!circleWidget->cycleContacts(forward))
|
|
|
|
{
|
|
|
|
// Skip empty or finished circles.
|
|
|
|
index += forward ? 1 : -1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2015-03-12 08:41:18 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-07 11:20:06 +08:00
|
|
|
void FriendListWidget::dragEnterEvent(QDragEnterEvent* event)
|
2015-05-29 00:58:44 +08:00
|
|
|
{
|
2016-08-07 03:28:40 +08:00
|
|
|
ToxId toxId(event->mimeData()->text());
|
2017-01-06 19:02:54 +08:00
|
|
|
Friend* frnd = FriendList::findFriend(toxId.getPublicKey());
|
2016-08-07 03:28:40 +08:00
|
|
|
if (frnd)
|
2015-05-29 00:58:44 +08:00
|
|
|
event->acceptProposedAction();
|
|
|
|
}
|
|
|
|
|
2015-06-07 11:20:06 +08:00
|
|
|
void FriendListWidget::dropEvent(QDropEvent* event)
|
2015-05-29 00:58:44 +08:00
|
|
|
{
|
2016-08-07 03:28:40 +08:00
|
|
|
// Check, that the element is dropped from qTox
|
|
|
|
QObject *o = event->source();
|
|
|
|
FriendWidget *widget = qobject_cast<FriendWidget*>(o);
|
|
|
|
if (!widget)
|
|
|
|
return;
|
2015-05-29 00:58:44 +08:00
|
|
|
|
2016-08-07 03:28:40 +08:00
|
|
|
// Check, that the user has a friend with the same ToxId
|
|
|
|
ToxId toxId(event->mimeData()->text());
|
2017-01-06 19:02:54 +08:00
|
|
|
Friend* f = FriendList::findFriend(toxId.getPublicKey());
|
2016-08-07 03:28:40 +08:00
|
|
|
if (!f)
|
|
|
|
return;
|
2015-05-29 00:58:44 +08:00
|
|
|
|
2016-08-07 03:28:40 +08:00
|
|
|
// Save CircleWidget before changing the Id
|
2016-12-30 06:14:48 +08:00
|
|
|
int circleId = Settings::getInstance().getFriendCircleID(f->getPublicKey());
|
2016-08-07 03:28:40 +08:00
|
|
|
CircleWidget* circleWidget = CircleWidget::getFromID(circleId);
|
2015-05-29 00:58:44 +08:00
|
|
|
|
2016-08-07 03:28:40 +08:00
|
|
|
moveWidget(widget, f->getStatus(), true);
|
2015-05-29 00:58:44 +08:00
|
|
|
|
2016-08-07 03:28:40 +08:00
|
|
|
if (circleWidget)
|
|
|
|
circleWidget->updateStatus();
|
2015-05-29 00:58:44 +08:00
|
|
|
}
|
|
|
|
|
2015-07-31 01:24:34 +08:00
|
|
|
void FriendListWidget::dayTimeout()
|
|
|
|
{
|
|
|
|
if (mode == Activity)
|
|
|
|
{
|
|
|
|
setMode(Name);
|
|
|
|
setMode(Activity); // Refresh all.
|
|
|
|
}
|
|
|
|
|
|
|
|
dayTimer->start(timeUntilTomorrow());
|
|
|
|
}
|
|
|
|
|
2016-08-22 20:24:37 +08:00
|
|
|
void FriendListWidget::moveWidget(FriendWidget* widget, Status s, bool add)
|
2014-08-22 23:19:16 +08:00
|
|
|
{
|
2015-06-12 03:27:54 +08:00
|
|
|
if (mode == Name)
|
|
|
|
{
|
2017-01-06 19:02:54 +08:00
|
|
|
Friend* f = FriendList::findFriend(widget->friendId);
|
2016-08-22 20:24:37 +08:00
|
|
|
int circleId = Settings::getInstance().getFriendCircleID(f->getPublicKey());
|
2015-06-12 03:27:54 +08:00
|
|
|
CircleWidget* circleWidget = CircleWidget::getFromID(circleId);
|
2015-05-28 01:17:12 +08:00
|
|
|
|
2015-06-12 03:27:54 +08:00
|
|
|
if (circleWidget == nullptr || add)
|
|
|
|
{
|
|
|
|
if (circleId != -1)
|
2016-08-22 20:24:37 +08:00
|
|
|
Settings::getInstance().setFriendCircleID(f->getPublicKey(), -1);
|
2015-06-18 03:45:03 +08:00
|
|
|
|
2016-08-22 20:24:37 +08:00
|
|
|
listLayout->addFriendWidget(widget, s);
|
2015-06-12 03:27:54 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-08-22 20:24:37 +08:00
|
|
|
circleWidget->addFriendWidget(widget, s);
|
2015-06-12 03:27:54 +08:00
|
|
|
}
|
|
|
|
else
|
2015-03-23 17:38:24 +08:00
|
|
|
{
|
2016-08-22 20:24:37 +08:00
|
|
|
Friend* contact = FriendList::findFriend(widget->friendId);
|
2015-06-18 23:27:50 +08:00
|
|
|
QDate activityDate = getDateFriend(contact);
|
2015-06-12 03:27:54 +08:00
|
|
|
Time time = getTime(activityDate);
|
2017-01-06 19:02:54 +08:00
|
|
|
QWidget* w = activityLayout->itemAt(time)->widget();
|
2016-08-22 20:24:37 +08:00
|
|
|
CategoryWidget* categoryWidget = qobject_cast<CategoryWidget*>(w);
|
|
|
|
categoryWidget->addFriendWidget(widget, contact->getStatus());
|
2015-06-13 00:09:01 +08:00
|
|
|
categoryWidget->show();
|
2015-03-12 08:23:22 +08:00
|
|
|
}
|
2014-08-22 23:19:16 +08:00
|
|
|
}
|
2015-06-03 18:26:48 +08:00
|
|
|
|
2015-07-01 21:10:55 +08:00
|
|
|
void FriendListWidget::updateActivityDate(const QDate& date)
|
|
|
|
{
|
|
|
|
if (mode != Activity)
|
|
|
|
return;
|
|
|
|
|
|
|
|
CategoryWidget* categoryWidget = static_cast<CategoryWidget*>(activityLayout->itemAt(getTime(date))->widget());
|
|
|
|
categoryWidget->updateStatus();
|
|
|
|
|
|
|
|
categoryWidget->setVisible(categoryWidget->hasChatrooms());
|
|
|
|
}
|
|
|
|
|
2015-06-03 18:26:48 +08:00
|
|
|
// update widget after add/delete/hide/show
|
|
|
|
void FriendListWidget::reDraw()
|
|
|
|
{
|
|
|
|
hide();
|
|
|
|
show();
|
|
|
|
resize(QSize()); //lifehack
|
|
|
|
}
|
2015-06-03 21:51:23 +08:00
|
|
|
|
2015-06-07 11:20:06 +08:00
|
|
|
CircleWidget* FriendListWidget::createCircleWidget(int id)
|
|
|
|
{
|
2015-06-12 03:27:54 +08:00
|
|
|
if (id == -1)
|
|
|
|
id = Settings::getInstance().addCircle();
|
|
|
|
|
2015-06-17 04:26:20 +08:00
|
|
|
// Stop, after it has been created. Code after this is for displaying.
|
2015-06-12 03:27:54 +08:00
|
|
|
if (mode == Activity)
|
|
|
|
return nullptr;
|
|
|
|
|
2015-06-18 23:27:50 +08:00
|
|
|
assert(circleLayout != nullptr);
|
|
|
|
|
2015-06-07 11:20:06 +08:00
|
|
|
CircleWidget* circleWidget = new CircleWidget(this, id);
|
2015-06-12 21:53:44 +08:00
|
|
|
circleLayout->addSortedWidget(circleWidget);
|
2015-06-07 11:20:06 +08:00
|
|
|
connect(this, &FriendListWidget::onCompactChanged, circleWidget, &CircleWidget::onCompactChanged);
|
|
|
|
connect(circleWidget, &CircleWidget::renameRequested, this, &FriendListWidget::renameCircleWidget);
|
|
|
|
circleWidget->show(); // Avoid flickering.
|
2015-06-17 04:26:20 +08:00
|
|
|
|
2015-06-07 11:20:06 +08:00
|
|
|
return circleWidget;
|
|
|
|
}
|
|
|
|
|
2015-06-03 21:51:23 +08:00
|
|
|
QLayout* FriendListWidget::nextLayout(QLayout* layout, bool forward) const
|
|
|
|
{
|
|
|
|
if (layout == groupLayout.getLayout())
|
|
|
|
{
|
|
|
|
if (forward)
|
|
|
|
{
|
|
|
|
if (groupsOnTop)
|
|
|
|
return listLayout->getLayoutOnline();
|
2015-06-18 03:45:03 +08:00
|
|
|
|
2015-06-03 21:51:23 +08:00
|
|
|
return listLayout->getLayoutOffline();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (groupsOnTop)
|
2015-06-12 21:53:44 +08:00
|
|
|
return circleLayout->getLayout();
|
2015-06-18 03:45:03 +08:00
|
|
|
|
2015-06-03 21:51:23 +08:00
|
|
|
return listLayout->getLayoutOnline();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (layout == listLayout->getLayoutOnline())
|
|
|
|
{
|
|
|
|
if (forward)
|
|
|
|
{
|
|
|
|
if (groupsOnTop)
|
|
|
|
return listLayout->getLayoutOffline();
|
2015-06-18 03:45:03 +08:00
|
|
|
|
2015-06-03 21:51:23 +08:00
|
|
|
return groupLayout.getLayout();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (groupsOnTop)
|
|
|
|
return groupLayout.getLayout();
|
2015-06-18 03:45:03 +08:00
|
|
|
|
2015-06-12 21:53:44 +08:00
|
|
|
return circleLayout->getLayout();
|
2015-06-03 21:51:23 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (layout == listLayout->getLayoutOffline())
|
|
|
|
{
|
|
|
|
if (forward)
|
2015-06-12 21:53:44 +08:00
|
|
|
return circleLayout->getLayout();
|
2015-06-03 21:51:23 +08:00
|
|
|
else if (groupsOnTop)
|
|
|
|
return listLayout->getLayoutOnline();
|
2015-06-18 03:45:03 +08:00
|
|
|
|
2015-06-03 21:51:23 +08:00
|
|
|
return groupLayout.getLayout();
|
|
|
|
}
|
2015-06-12 21:53:44 +08:00
|
|
|
else if (layout == circleLayout->getLayout())
|
2015-06-03 21:51:23 +08:00
|
|
|
{
|
|
|
|
if (forward)
|
|
|
|
{
|
|
|
|
if (groupsOnTop)
|
|
|
|
return groupLayout.getLayout();
|
2015-06-18 03:45:03 +08:00
|
|
|
|
2015-06-03 21:51:23 +08:00
|
|
|
return listLayout->getLayoutOnline();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return listLayout->getLayoutOffline();
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|