mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-04 23:25:32 -04:00
Groups for friends in PeersDialog.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3523 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
8b1ffdb5d9
commit
077b2871f1
23 changed files with 1784 additions and 544 deletions
65
retroshare-gui/src/gui/common/GroupDefs.cpp
Normal file
65
retroshare-gui/src/gui/common/GroupDefs.cpp
Normal file
|
@ -0,0 +1,65 @@
|
|||
/****************************************************************
|
||||
* This file is distributed under the following license:
|
||||
*
|
||||
* Copyright (c) 2010, RetroShare Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <retroshare/rspeers.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
#include "GroupDefs.h"
|
||||
|
||||
const QString GroupDefs::name(const RsGroupInfo &groupInfo)
|
||||
{
|
||||
if ((groupInfo.flag & RS_GROUP_FLAG_STANDARD) == 0) {
|
||||
/* no need to be translated */
|
||||
return QString::fromUtf8(groupInfo.name.c_str());
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
std::cerr << "GroupDefs::name: Unknown group id requested " << groupInfo.id;
|
||||
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);
|
||||
}
|
37
retroshare-gui/src/gui/common/GroupDefs.h
Normal file
37
retroshare-gui/src/gui/common/GroupDefs.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/****************************************************************
|
||||
* This file is distributed under the following license:
|
||||
*
|
||||
* Copyright (c) 2010, RetroShare Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
|
||||
#ifndef _GROUPDEFS_H
|
||||
#define _GROUPDEFS_H
|
||||
|
||||
class RsGroupInfo;
|
||||
|
||||
class GroupDefs
|
||||
{
|
||||
public:
|
||||
static const QString name(const RsGroupInfo &groupInfo);
|
||||
|
||||
static void sortByName(std::list<RsGroupInfo> &groupInfoList);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue