2018-11-11 10:57:05 -05:00
|
|
|
/*******************************************************************************
|
|
|
|
* gui/common/GroupDefs.cpp *
|
|
|
|
* *
|
|
|
|
* Copyright (C) 2010, Retroshare Team <retroshare.project@gmail.com> *
|
|
|
|
* *
|
|
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU Affero General Public License as *
|
|
|
|
* published by the Free Software Foundation, either version 3 of the *
|
|
|
|
* License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU Affero General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Affero General Public License *
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
|
|
|
* *
|
|
|
|
*******************************************************************************/
|
2010-09-22 18:37:57 -04:00
|
|
|
|
|
|
|
#include <QCoreApplication>
|
|
|
|
#include <retroshare/rspeers.h>
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
#include "GroupDefs.h"
|
2010-11-09 14:57:05 -05:00
|
|
|
#include "util/misc.h"
|
2010-09-22 18:37:57 -04:00
|
|
|
|
|
|
|
const QString GroupDefs::name(const RsGroupInfo &groupInfo)
|
|
|
|
{
|
|
|
|
if ((groupInfo.flag & RS_GROUP_FLAG_STANDARD) == 0) {
|
|
|
|
/* no need to be translated */
|
2010-11-09 14:57:05 -05:00
|
|
|
return misc::removeNewLine(groupInfo.name);
|
2010-09-22 18:37:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (groupInfo.id == RS_GROUP_ID_FRIENDS) {
|
|
|
|
return qApp->translate("GroupDefs", "Friends");
|
|
|
|
}
|
|
|
|
if (groupInfo.id == RS_GROUP_ID_FAMILY) {
|
|
|
|
return qApp->translate("GroupDefs", "Family");
|
|
|
|
}
|
|
|
|
if (groupInfo.id == RS_GROUP_ID_COWORKERS) {
|
|
|
|
return qApp->translate("GroupDefs", "Co-Workers");
|
|
|
|
}
|
|
|
|
if (groupInfo.id == RS_GROUP_ID_OTHERS) {
|
|
|
|
return qApp->translate("GroupDefs", "Other Contacts");
|
|
|
|
}
|
|
|
|
if (groupInfo.id == RS_GROUP_ID_FAVORITES) {
|
|
|
|
return qApp->translate("GroupDefs", "Favorites");
|
|
|
|
}
|
|
|
|
|
2016-07-06 22:02:56 -04:00
|
|
|
std::cerr << "GroupDefs::name: Unknown group id requested " << groupInfo.id << std::endl;
|
2010-09-22 18:37:57 -04:00
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool sortGroupInfo(const RsGroupInfo &groupInfo1, const RsGroupInfo &groupInfo2)
|
|
|
|
{
|
|
|
|
return (GroupDefs::name(groupInfo1).compare(GroupDefs::name(groupInfo2), Qt::CaseInsensitive) < 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GroupDefs::sortByName(std::list<RsGroupInfo> &groupInfoList)
|
|
|
|
{
|
|
|
|
groupInfoList.sort(sortGroupInfo);
|
|
|
|
}
|