finished conversion to RsNodeGroupId for file transfer and GUI

This commit is contained in:
csoler 2016-07-05 23:49:43 -04:00
parent 4ee9effc4e
commit 01c0d2f0f1
29 changed files with 338 additions and 256 deletions

View file

@ -56,8 +56,9 @@
*****/
MessengerWindow* MessengerWindow::_instance = NULL;
static std::set<std::string> *expandedPeers = NULL;
static std::set<std::string> *expandedGroups = NULL;
std::set<std::string> MessengerWindow::expandedPeers ;
std::set<RsNodeGroupId> MessengerWindow::expandedGroups ;
/*static*/ void MessengerWindow::showYourself ()
{
@ -79,16 +80,6 @@ void MessengerWindow::releaseInstance()
if (_instance) {
delete _instance;
}
if (expandedPeers) {
/* delete saved expanded peers */
delete(expandedPeers);
expandedPeers = NULL;
}
if (expandedGroups) {
/* delete saved expanded groups */
delete(expandedGroups);
expandedGroups = NULL;
}
}
/** Constructor */
@ -108,21 +99,15 @@ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WindowFlags flags)
connect(NotifyQt::getInstance(), SIGNAL(ownStatusMessageChanged()), this, SLOT(loadmystatusmessage()));
connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateOwnStatus(QString,int)));
if (expandedPeers != NULL) {
for (std::set<std::string>::iterator peerIt = expandedPeers->begin(); peerIt != expandedPeers->end(); ++peerIt) {
for (std::set<std::string>::iterator peerIt = expandedPeers.begin(); peerIt != expandedPeers.end(); ++peerIt) {
ui.friendList->addPeerToExpand(*peerIt);
}
delete expandedPeers;
expandedPeers = NULL;
}
expandedPeers.clear();
if (expandedGroups != NULL) {
for (std::set<std::string>::iterator groupIt = expandedGroups->begin(); groupIt != expandedGroups->end(); ++groupIt) {
for (std::set<RsNodeGroupId>::iterator groupIt = expandedGroups.begin(); groupIt != expandedGroups.end(); ++groupIt) {
ui.friendList->addGroupToExpand(*groupIt);
}
delete expandedGroups;
expandedGroups = NULL;
}
expandedGroups.clear();
ui.messagelineEdit->setMinimumWidth(20);
@ -203,22 +188,12 @@ void MessengerWindow::addFriend()
void MessengerWindow::closeEvent (QCloseEvent * /*event*/)
{
/* save the expanded peers */
if (expandedPeers == NULL) {
expandedPeers = new std::set<std::string>;
} else {
expandedPeers->clear();
}
ui.friendList->getExpandedPeers(*expandedPeers);
expandedPeers.clear();
ui.friendList->getExpandedPeers(expandedPeers);
/* save the expanded groups */
if (expandedGroups == NULL) {
expandedGroups = new std::set<std::string>;
} else {
expandedGroups->clear();
}
ui.friendList->getExpandedGroups(*expandedGroups);
expandedGroups.clear();
ui.friendList->getExpandedGroups(expandedGroups);
}
/** Shows Share Manager */

View file

@ -66,6 +66,9 @@ private:
/** Qt Designer generated object */
Ui::MessengerWindow ui;
static std::set<std::string> expandedPeers ;
static std::set<RsNodeGroupId> expandedGroups ;
};
#endif

View file

@ -212,12 +212,12 @@ QString RetroshareDirModel::getFlagsString(FileStorageFlags flags)
return QString(str) ;
}
QString RetroshareDirModel::getGroupsString(const std::list<std::string>& group_ids)
QString RetroshareDirModel::getGroupsString(const std::list<RsNodeGroupId>& group_ids)
{
QString groups_str ;
RsGroupInfo group_info ;
for(std::list<std::string>::const_iterator it(group_ids.begin());it!=group_ids.end();)
for(std::list<RsNodeGroupId>::const_iterator it(group_ids.begin());it!=group_ids.end();)
if(rsPeers->getGroupInfo(*it,group_info))
{
groups_str += GroupDefs::name(group_info) ;

View file

@ -91,7 +91,7 @@ class RetroshareDirModel : public QAbstractItemModel
void treeStyle();
void downloadDirectory(const DirDetails & details, int prefixLen);
static QString getFlagsString(FileStorageFlags f) ;
static QString getGroupsString(const std::list<std::string>&) ;
static QString getGroupsString(const std::list<RsNodeGroupId> &) ;
QString getAgeIndicatorString(const DirDetails &) const;
// void getAgeIndicatorRec(const DirDetails &details, QString &ret) const;

View file

@ -249,7 +249,7 @@ void ShareManager::updateGroups()
QString group_string;
int n = 0;
for (std::list<std::string>::const_iterator it2((*it).parent_groups.begin());it2!=(*it).parent_groups.end();++it2,++n)
for (std::list<RsNodeGroupId>::const_iterator it2((*it).parent_groups.begin());it2!=(*it).parent_groups.end();++it2,++n)
{
if (n>0)
group_string += ", " ;

View file

@ -116,9 +116,7 @@ FriendList::FriendList(QWidget *parent) :
mShowGroups(true),
mShowState(false),
mHideUnconnected(false),
groupsHasChanged(false),
openGroups(NULL),
openPeers(NULL)
groupsHasChanged(false)
{
ui->setupUi(this);
@ -219,7 +217,7 @@ void FriendList::processSettings(bool load)
int arrayIndex = Settings->beginReadArray("Groups");
for (int index = 0; index < arrayIndex; ++index) {
Settings->setArrayIndex(index);
addGroupToExpand(Settings->value("open").toString().toStdString());
addGroupToExpand(RsNodeGroupId(Settings->value("open").toString().toStdString()));
}
Settings->endArray();
} else {
@ -236,11 +234,11 @@ void FriendList::processSettings(bool load)
// open groups
Settings->beginWriteArray("Groups");
int arrayIndex = 0;
std::set<std::string> expandedPeers;
std::set<RsNodeGroupId> expandedPeers;
getExpandedGroups(expandedPeers);
foreach (std::string groupId, expandedPeers) {
foreach (RsNodeGroupId groupId, expandedPeers) {
Settings->setArrayIndex(arrayIndex++);
Settings->setValue("open", QString::fromStdString(groupId));
Settings->setValue("open", QString::fromStdString(groupId.toStdString()));
}
Settings->endArray();
}
@ -369,7 +367,7 @@ void FriendList::peerTreeWidgetCustomPopupMenu()
addToGroupMenu = new QMenu(tr("Add to group"), &contextMnu);
}
QAction* addToGroupAction = new QAction(GroupDefs::name(*groupIt), addToGroupMenu);
addToGroupAction->setData(QString::fromStdString(groupIt->id));
addToGroupAction->setData(QString::fromStdString(groupIt->id.toStdString()));
connect(addToGroupAction, SIGNAL(triggered()), this, SLOT(addToGroup()));
addToGroupMenu->addAction(addToGroupAction);
}
@ -378,7 +376,7 @@ void FriendList::peerTreeWidgetCustomPopupMenu()
moveToGroupMenu = new QMenu(tr("Move to group"), &contextMnu);
}
QAction* moveToGroupAction = new QAction(GroupDefs::name(*groupIt), moveToGroupMenu);
moveToGroupAction->setData(QString::fromStdString(groupIt->id));
moveToGroupAction->setData(QString::fromStdString(groupIt->id.toStdString()));
connect(moveToGroupAction, SIGNAL(triggered()), this, SLOT(moveToGroup()));
moveToGroupMenu->addAction(moveToGroupAction);
} else {
@ -456,7 +454,7 @@ void FriendList::peerTreeWidgetCustomPopupMenu()
void FriendList::createNewGroup()
{
CreateGroup createGrpDialog ("", this);
CreateGroup createGrpDialog (RsNodeGroupId(), this);
createGrpDialog.exec();
}
@ -596,7 +594,7 @@ void FriendList::insertPeers()
if (mShowGroups && groupsHasChanged) {
if (parent) {
if (parent->type() == TYPE_GROUP) {
std::string groupId = getRsId(parent);
RsNodeGroupId groupId(getRsId(parent));
// the parent is a group, check if the gpg id is assigned to the group
for (groupIt = groupInfoList.begin(); groupIt != groupInfoList.end(); ++groupIt) {
@ -630,7 +628,7 @@ void FriendList::insertPeers()
}
} else if (groupsHasChanged) {
// remove deleted groups
std::string groupId = getRsId(item);
RsNodeGroupId groupId ( getRsId(item));
for (groupIt = groupInfoList.begin(); groupIt != groupInfoList.end(); ++groupIt) {
if (groupIt->id == groupId) {
break;
@ -671,7 +669,7 @@ void FriendList::insertPeers()
int itemCount = peerTreeWidget->topLevelItemCount();
for (int index = 0; index < itemCount; ++index) {
QTreeWidgetItem *groupItemLoop = peerTreeWidget->topLevelItem(index);
if (groupItemLoop->type() == TYPE_GROUP && getRsId(groupItemLoop) == groupInfo->id) {
if (groupItemLoop->type() == TYPE_GROUP && RsNodeGroupId(getRsId(groupItemLoop)) == groupInfo->id) {
groupItem = groupItemLoop;
break;
}
@ -690,7 +688,7 @@ void FriendList::insertPeers()
groupItem->setForeground(COLUMN_NAME, QBrush(textColorGroup()));
/* used to find back the item */
groupItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(groupInfo->id));
groupItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(groupInfo->id.toStdString()));
groupItem->setData(COLUMN_DATA, ROLE_STANDARD, (groupInfo->flag & RS_GROUP_FLAG_STANDARD) ? true : false);
/* Sort data */
@ -716,7 +714,7 @@ void FriendList::insertPeers()
}
}
if (openGroups != NULL && openGroups->find(groupInfo->id) != openGroups->end()) {
if (openGroups.find(groupInfo->id) != openGroups.end()) {
groupItem->setExpanded(true);
}
@ -1182,7 +1180,7 @@ void FriendList::insertPeers()
gpgItem->setFont(i, gpgFont);
}
if (openPeers != NULL && openPeers->find(gpgId.toStdString()) != openPeers->end()) {
if (openPeers.find(gpgId.toStdString()) != openPeers.end()) {
gpgItem->setExpanded(true);
}
}
@ -1217,14 +1215,6 @@ void FriendList::insertPeers()
}
groupsHasChanged = false;
if (openGroups != NULL) {
delete(openGroups);
openGroups = NULL;
}
if (openPeers != NULL) {
delete(openPeers);
openPeers = NULL;
}
ui->peerTreeWidget->resort();
}
@ -1232,13 +1222,13 @@ void FriendList::insertPeers()
/**
* Returns a list with all groupIds that are expanded
*/
bool FriendList::getExpandedGroups(std::set<std::string> &groups) const
bool FriendList::getExpandedGroups(std::set<RsNodeGroupId> &groups) const
{
int itemCount = ui->peerTreeWidget->topLevelItemCount();
for (int index = 0; index < itemCount; ++index) {
QTreeWidgetItem *item = ui->peerTreeWidget->topLevelItem(index);
if (item->type() == TYPE_GROUP && item->isExpanded()) {
groups.insert(item->data(COLUMN_DATA, ROLE_ID).toString().toStdString());
groups.insert(RsNodeGroupId(item->data(COLUMN_DATA, ROLE_ID).toString().toStdString()));
}
}
return true;
@ -1626,7 +1616,7 @@ void FriendList::getSslIdsFromItem(QTreeWidgetItem *item, std::list<RsPeerId> &s
case TYPE_GROUP:
{
RsGroupInfo groupInfo;
if (rsPeers->getGroupInfo(peerId, groupInfo)) {
if (rsPeers->getGroupInfo(RsNodeGroupId(peerId), groupInfo)) {
std::set<RsPgpId>::iterator gpgIt;
for (gpgIt = groupInfo.peerIds.begin(); gpgIt != groupInfo.peerIds.end(); ++gpgIt) {
rsPeers->getAssociatedSSLIds(*gpgIt, sslIds);
@ -1649,10 +1639,10 @@ void FriendList::addToGroup()
return;
}
std::string groupId = qobject_cast<QAction*>(sender())->data().toString().toStdString();
RsNodeGroupId groupId ( qobject_cast<QAction*>(sender())->data().toString().toStdString());
RsPgpId gpgId ( getRsId(c));
if (gpgId.isNull() || groupId.empty()) {
if (gpgId.isNull() || groupId.isNull()) {
return;
}
@ -1675,15 +1665,15 @@ void FriendList::moveToGroup()
return;
}
std::string groupId = qobject_cast<QAction*>(sender())->data().toString().toStdString();
RsNodeGroupId groupId ( qobject_cast<QAction*>(sender())->data().toString().toStdString());
RsPgpId gpgId ( getRsId(c));
if (gpgId.isNull() || groupId.empty()) {
if (gpgId.isNull() || groupId.isNull()) {
return;
}
// remove from all groups
rsPeers->assignPeerToGroup("", gpgId, false);
rsPeers->assignPeerToGroup(RsNodeGroupId(), gpgId, false);
// automatically expand the group, the peer is added to
addGroupToExpand(groupId);
@ -1704,7 +1694,7 @@ void FriendList::removeFromGroup()
return;
}
std::string groupId = qobject_cast<QAction*>(sender())->data().toString().toStdString();
RsNodeGroupId groupId ( qobject_cast<QAction*>(sender())->data().toString().toStdString());
RsPgpId gpgId ( getRsId(c));
if (gpgId.isNull()) {
@ -1727,14 +1717,13 @@ void FriendList::editGroup()
return;
}
std::string groupId = getRsId(c);
RsNodeGroupId groupId ( getRsId(c));
if (groupId.empty()) {
return;
if (!groupId.isNull())
{
CreateGroup editGrpDialog(groupId, this);
editGrpDialog.exec();
}
CreateGroup editGrpDialog(groupId, this);
editGrpDialog.exec();
}
void FriendList::removeGroup()
@ -1749,13 +1738,10 @@ void FriendList::removeGroup()
return;
}
std::string groupId = getRsId(c);
RsNodeGroupId groupId ( getRsId(c));
if (groupId.empty()) {
return;
}
rsPeers->removeGroup(groupId);
if (!groupId.isNull())
rsPeers->removeGroup(groupId);
}
void FriendList::exportFriendlistClicked()
@ -2089,7 +2075,7 @@ bool FriendList::importFriendlist(QString &fileName, bool &errorPeers, bool &err
// get name and flags and try to get the group ID
std::string groupName = group.attribute("name").toStdString();
uint32_t flag = group.attribute("flag").toInt();
std::string groupId;
RsNodeGroupId groupId;
if(getOrCreateGroup(groupName, flag, groupId)) {
// group id found!
QDomElement pgpID = group.firstChildElement("pgpID");
@ -2123,7 +2109,7 @@ bool FriendList::importFriendlist(QString &fileName, bool &errorPeers, bool &err
* @param id groupd id for the given name
* @return success or fail
*/
bool FriendList::getGroupIdByName(const std::string &name, std::string &id)
bool FriendList::getGroupIdByName(const std::string &name, RsNodeGroupId &id)
{
std::list<RsGroupInfo> grpList;
if(!rsPeers->getGroupInfoList(grpList))
@ -2146,14 +2132,14 @@ bool FriendList::getGroupIdByName(const std::string &name, std::string &id)
* @param id groupd id
* @return success or failure
*/
bool FriendList::getOrCreateGroup(const std::string &name, const uint &flag, std::string &id)
bool FriendList::getOrCreateGroup(const std::string &name, const uint &flag, RsNodeGroupId &id)
{
if(getGroupIdByName(name, id))
return true;
// -> create one
RsGroupInfo grp;
grp.id = "0"; // RS will generate an ID
grp.id.clear(); // RS will generate an ID
grp.name = name;
grp.flag = flag;
@ -2271,12 +2257,9 @@ void FriendList::filterItems(const QString &text)
* Add a groupId to the openGroups list. These groups
* will be expanded, when they're added to the QTreeWidget
*/
void FriendList::addGroupToExpand(const std::string &groupId)
void FriendList::addGroupToExpand(const RsNodeGroupId &groupId)
{
if (openGroups == NULL) {
openGroups = new std::set<std::string>;
}
openGroups->insert(groupId);
openGroups.insert(groupId);
}
/**
@ -2285,10 +2268,7 @@ void FriendList::addGroupToExpand(const std::string &groupId)
*/
void FriendList::addPeerToExpand(const std::string &gpgId)
{
if (openPeers == NULL) {
openPeers = new std::set<std::string>;
}
openPeers->insert(gpgId);
openPeers.insert(gpgId);
}
void FriendList::createDisplayMenu()

View file

@ -63,8 +63,8 @@ public:
// Add a tool button to the tool area
void addToolButton(QToolButton *toolButton);
void processSettings(bool load);
void addGroupToExpand(const std::string &groupId);
bool getExpandedGroups(std::set<std::string> &groups) const;
void addGroupToExpand(const RsNodeGroupId &groupId);
bool getExpandedGroups(std::set<RsNodeGroupId> &groups) const;
void addPeerToExpand(const std::string &gpgId);
bool getExpandedPeers(std::set<std::string> &peers) const;
@ -119,8 +119,9 @@ private:
QString mFilterText;
bool groupsHasChanged;
std::set<std::string> *openGroups;
std::set<std::string> *openPeers;
std::set<RsNodeGroupId> openGroups;
#warning this would needs an ID, not a std::string.
std::set<std::string> openPeers;
/* Color definitions (for standard see qss.default) */
QColor mTextColorGroup;
@ -129,8 +130,8 @@ private:
QTreeWidgetItem *getCurrentPeer() const;
void getSslIdsFromItem(QTreeWidgetItem *item, std::list<RsPeerId> &sslIds);
bool getOrCreateGroup(const std::string &name, const uint &flag, std::string &id);
bool getGroupIdByName(const std::string &name, std::string &id);
bool getOrCreateGroup(const std::string &name, const uint &flag, RsNodeGroupId &id);
bool getGroupIdByName(const std::string &name, RsNodeGroupId &id);
bool importExportFriendlistFileDialog(QString &fileName, bool import);
bool exportFriendlist(QString &fileName);

View file

@ -271,9 +271,9 @@ void FriendSelectionWidget::secured_fillList()
selectedIds<RsPeerId,IDTYPE_SSL>(sslIdsSelected,true);
}
std::set<std::string> groupIdsSelected;
std::set<RsNodeGroupId> groupIdsSelected;
if (mShowTypes & SHOW_GROUP) {
selectedIds<std::string,IDTYPE_GROUP>(groupIdsSelected,true);
selectedIds<RsNodeGroupId,IDTYPE_GROUP>(groupIdsSelected,true);
}
std::set<RsPgpId> gpgIdsSelected;
@ -347,7 +347,7 @@ void FriendSelectionWidget::secured_fillList()
groupItem->setTextAlignment(COLUMN_NAME, Qt::AlignLeft | Qt::AlignVCenter);
groupItem->setIcon(COLUMN_NAME, QIcon(IMAGE_GROUP16));
groupItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(groupInfo->id));
groupItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(groupInfo->id.toStdString()));
groupItem->setExpanded(true);
@ -363,7 +363,7 @@ void FriendSelectionWidget::secured_fillList()
groupItem->setCheckState(0, Qt::Unchecked);
}
emit itemAdded(IDTYPE_GROUP, QString::fromStdString(groupInfo->id), groupItem);
emit itemAdded(IDTYPE_GROUP, QString::fromStdString(groupInfo->id.toStdString()), groupItem);
if (std::find(groupIdsSelected.begin(), groupIdsSelected.end(), groupInfo->id) != groupIdsSelected.end()) {
setSelected(mListModus, groupItem, true);

View file

@ -20,7 +20,7 @@ GroupSelectionBox::GroupSelectionBox(QWidget *parent)
void GroupSelectionBox::fillGroups()
{
std::list<std::string> selectedIds;
std::list<RsNodeGroupId> selectedIds;
selectedGroupIds(selectedIds);
clear();
@ -30,7 +30,7 @@ void GroupSelectionBox::fillGroups()
for (std::list<RsGroupInfo>::const_iterator it(groupIds.begin()); it != groupIds.end(); ++it) {
QListWidgetItem *item = new QListWidgetItem(GroupDefs::name(*it));
item->setData(ROLE_ID, QString::fromStdString(it->id));
item->setData(ROLE_ID, QString::fromStdString(it->id.toStdString()));
item->setBackgroundColor(QColor(183,236,181));
addItem(item);
}
@ -38,27 +38,27 @@ void GroupSelectionBox::fillGroups()
setSelectedGroupIds(selectedIds);
}
void GroupSelectionBox::selectedGroupIds(std::list<std::string> &groupIds) const
void GroupSelectionBox::selectedGroupIds(std::list<RsNodeGroupId> &groupIds) const
{
int itemCount = count();
for (int i = 0; i < itemCount; ++i) {
QListWidgetItem *listItem = item(i);
if (listItem->checkState() == Qt::Checked) {
groupIds.push_back(item(i)->data(ROLE_ID).toString().toStdString());
groupIds.push_back(RsNodeGroupId(item(i)->data(ROLE_ID).toString().toStdString()));
std::cerr << "Adding selected item " << groupIds.back() << std::endl;
}
}
}
void GroupSelectionBox::setSelectedGroupIds(const std::list<std::string>& groupIds)
void GroupSelectionBox::setSelectedGroupIds(const std::list<RsNodeGroupId>& groupIds)
{
int itemCount = count();
for (int i = 0; i < itemCount; ++i) {
QListWidgetItem *listItem = item(i);
if (std::find(groupIds.begin(), groupIds.end(), listItem->data(ROLE_ID).toString().toStdString()) != groupIds.end()) {
if (std::find(groupIds.begin(), groupIds.end(), RsNodeGroupId(listItem->data(ROLE_ID).toString().toStdString())) != groupIds.end()) {
listItem->setCheckState(Qt::Checked);
} else {
listItem->setCheckState(Qt::Unchecked);

View file

@ -1,4 +1,5 @@
#include <QListWidget>
#include <retroshare/rsids.h>
class GroupSelectionBox: public QListWidget
{
@ -7,10 +8,10 @@ class GroupSelectionBox: public QListWidget
public:
GroupSelectionBox(QWidget *parent);
void selectedGroupIds(std::list<std::string> &groupIds) const;
void selectedGroupIds(std::list<RsNodeGroupId> &groupIds) const;
void selectedGroupNames(QList<QString> &groupNames) const;
void setSelectedGroupIds(const std::list<std::string> &groupIds);
void setSelectedGroupIds(const std::list<RsNodeGroupId> &groupIds);
private slots:
void fillGroups();

View file

@ -297,7 +297,7 @@ static void fillGroups(ConnectFriendWizard *wizard, QComboBox *comboBox, const Q
GroupDefs::sortByName(groupInfoList);
comboBox->addItem("", ""); // empty value
for (std::list<RsGroupInfo>::iterator groupIt = groupInfoList.begin(); groupIt != groupInfoList.end(); ++groupIt) {
comboBox->addItem(GroupDefs::name(*groupIt), QString::fromStdString(groupIt->id));
comboBox->addItem(GroupDefs::name(*groupIt), QString::fromStdString(groupIt->id.toStdString()));
}
if (groupId.isEmpty() == false) {
@ -853,7 +853,7 @@ void ConnectFriendWizard::accept()
}
if (!groupId.isEmpty())
rsPeers->assignPeerToGroup(groupId.toStdString(), peerDetails.gpg_id, true);
rsPeers->assignPeerToGroup(RsNodeGroupId(groupId.toStdString()), peerDetails.gpg_id, true);
}
if ((accept_connection) && (!peerDetails.id.isNull()))

View file

@ -31,7 +31,7 @@
#include <algorithm>
/** Default constructor */
CreateGroup::CreateGroup(const std::string &groupId, QWidget *parent)
CreateGroup::CreateGroup(const RsNodeGroupId &groupId, QWidget *parent)
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint)
{
/* Invoke Qt Designer generated QObject setup routine */
@ -51,7 +51,7 @@ CreateGroup::CreateGroup(const std::string &groupId, QWidget *parent)
ui.friendList->setShowType(FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_GPG);
ui.friendList->start();
if (mGroupId.empty() == false) {
if (!mGroupId.isNull()) {
/* edit exisiting group */
RsGroupInfo groupInfo;
if (rsPeers->getGroupInfo(mGroupId, groupInfo)) {
@ -83,7 +83,7 @@ CreateGroup::CreateGroup(const std::string &groupId, QWidget *parent)
std::list<RsGroupInfo>::iterator groupIt;
for (groupIt = groupInfoList.begin(); groupIt != groupInfoList.end(); ++groupIt) {
if (mGroupId.empty() || groupIt->id != mGroupId) {
if (mGroupId.isNull() || groupIt->id != mGroupId) {
mUsedGroupNames.append(GroupDefs::name(*groupIt));
}
}
@ -114,14 +114,19 @@ void CreateGroup::changeGroup()
{
RsGroupInfo groupInfo;
if (mGroupId.empty()) {
if (mGroupId.isNull())
{
// add new group
groupInfo.name = misc::removeNewLine(ui.groupName->text()).toUtf8().constData();
if (!rsPeers->addGroup(groupInfo)) {
if (!rsPeers->addGroup(groupInfo))
return;
}
} else {
if (rsPeers->getGroupInfo(mGroupId, groupInfo) == true) {
}
else
{
if (rsPeers->getGroupInfo(mGroupId, groupInfo))
{
if (!mIsStandard) {
groupInfo.name = misc::removeNewLine(ui.groupName->text()).toUtf8().constData();
if (!rsPeers->editGroup(mGroupId, groupInfo)) {

View file

@ -30,7 +30,7 @@ class CreateGroup : public QDialog
public:
/** Default constructor */
CreateGroup(const std::string &groupId, QWidget *parent = 0);
CreateGroup(const RsNodeGroupId &groupId, QWidget *parent = 0);
/** Default destructor */
~CreateGroup();
@ -39,7 +39,7 @@ private slots:
void groupNameChanged(QString);
private:
std::string mGroupId;
RsNodeGroupId mGroupId;
QStringList mUsedGroupNames;
bool mIsStandard;

View file

@ -887,7 +887,7 @@ void MessageComposer::calculateTitle()
setWindowTitle(tr("Compose") + ": " + misc::removeNewLine(ui.titleEdit->text()));
}
static void calculateGroupsOfSslIds(const std::list<RsGroupInfo> &existingGroupInfos, std::list<RsPeerId> &checkSslIds, std::list<std::string> &checkGroupIds)
static void calculateGroupsOfSslIds(const std::list<RsGroupInfo> &existingGroupInfos, std::list<RsPeerId> &checkSslIds, std::list<RsNodeGroupId> &checkGroupIds)
{
checkGroupIds.clear();
@ -1342,7 +1342,7 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox)
{
case PEER_TYPE_GROUP: {
RsGroupInfo groupInfo;
if (rsPeers->getGroupInfo(id, groupInfo) == false) {
if (rsPeers->getGroupInfo(RsNodeGroupId(id), groupInfo) == false) {
// group not found
continue;
}
@ -1587,7 +1587,7 @@ void MessageComposer::setRecipientToRow(int row, enumType type, destinationType
icon = QIcon(IMAGE_GROUP16);
RsGroupInfo groupInfo;
if (rsPeers->getGroupInfo(id, groupInfo)) {
if (rsPeers->getGroupInfo(RsNodeGroupId(id), groupInfo)) {
name = GroupDefs::name(groupInfo);
} else {
name = tr("Unknown");
@ -1771,7 +1771,7 @@ void MessageComposer::editingRecipientFinished()
QString groupName = GroupDefs::name(*groupIt);
if (text.compare(groupName, Qt::CaseSensitive) == 0) {
// found it
setRecipientToRow(row, type, PEER_TYPE_GROUP, groupIt->id);
setRecipientToRow(row, type, PEER_TYPE_GROUP, groupIt->id.toStdString());
return;
}
}