mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
revert GUI part of svn commit 7042
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-initdev@7043 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
f3afc128ee
commit
46518ebf51
@ -86,8 +86,8 @@ PostedListDialog::PostedListDialog(QWidget *parent)
|
||||
/* create posted tree */
|
||||
yourTopics = ui.groupTreeWidget->addCategoryItem(tr("My Topics"), QIcon(IMAGE_FOLDER), true);
|
||||
subscribedTopics = ui.groupTreeWidget->addCategoryItem(tr("Subscribed Topics"), QIcon(IMAGE_FOLDERRED), true);
|
||||
allTopics = ui.groupTreeWidget->addCategoryItem(tr("All Topics"), QIcon(IMAGE_FOLDERGREEN), false);
|
||||
//otherTopics = ui.groupTreeWidget->addCategoryItem(tr("Other Topics"), QIcon(IMAGE_FOLDERYELLOW), false);
|
||||
popularTopics = ui.groupTreeWidget->addCategoryItem(tr("Popular Topics"), QIcon(IMAGE_FOLDERGREEN), false);
|
||||
otherTopics = ui.groupTreeWidget->addCategoryItem(tr("Other Topics"), QIcon(IMAGE_FOLDERYELLOW), false);
|
||||
|
||||
ui.hotSortButton->setChecked(true);
|
||||
|
||||
@ -181,8 +181,6 @@ void PostedListDialog::groupListCustomPopupMenu(QPoint /*point*/)
|
||||
action->setEnabled(!isSubscribed);
|
||||
action = contextMnu.addAction(QIcon(IMAGE_MESSAGE), tr("Unsubscribe"), this, SLOT(unsubscribeTopic()));
|
||||
action->setEnabled(isSubscribed);
|
||||
action = contextMnu.addAction(QIcon(IMAGE_FOLDERGREEN), tr("New Child-Group"), this, SLOT(newSubTopic()));
|
||||
action->setEnabled(isSubscribed);
|
||||
|
||||
contextMnu.exec(QCursor::pos());
|
||||
}
|
||||
@ -363,23 +361,6 @@ void PostedListDialog::newTopic()
|
||||
PostedGroupDialog cf (mPostedQueue, this);
|
||||
cf.exec ();
|
||||
}
|
||||
void PostedListDialog::newSubTopic()
|
||||
{
|
||||
std::cerr << "mCurrTopicId: " << mCurrTopicId << std::endl;
|
||||
PostedGroupDialog cf (mPostedQueue, this);
|
||||
cf.setParentLabel(mCurrTopicId.c_str());
|
||||
cf.exec ();
|
||||
/*
|
||||
if (mCurrTopicId.empty()) {
|
||||
return;
|
||||
}
|
||||
RsPostedGroup grp;
|
||||
grp.mMeta.mParentGroupId = mCurrTopicId;
|
||||
|
||||
PostedGroupDialog cf (grp, this);
|
||||
GxsForumGroupDialog cf(grp, GxsGroupDialog::MODE_SHOW, this);
|
||||
cf.exec ();*/
|
||||
}
|
||||
|
||||
void PostedListDialog::showGroupDetails()
|
||||
{
|
||||
@ -942,16 +923,17 @@ void PostedListDialog::groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo
|
||||
groupItemInfo.popularity = groupInfo.mPop;
|
||||
groupItemInfo.lastpost = QDateTime::fromTime_t(groupInfo.mLastPost);
|
||||
groupItemInfo.subscribeFlags = groupInfo.mSubscribeFlags;
|
||||
groupItemInfo.parentId = QString::fromStdString(groupInfo.mParentGrpId);
|
||||
}
|
||||
|
||||
void PostedListDialog::insertGroupData( std::list<RsGroupMetaData> &groupList)
|
||||
void PostedListDialog::insertGroupData(const std::list<RsGroupMetaData> &groupList)
|
||||
{
|
||||
std::list<RsGroupMetaData>::const_iterator it;
|
||||
|
||||
QList<GroupItemInfo> adminList;
|
||||
QList<GroupItemInfo> subList;
|
||||
QList<GroupItemInfo> completeList;
|
||||
QList<GroupItemInfo> popList;
|
||||
QList<GroupItemInfo> otherList;
|
||||
std::multimap<uint32_t, GroupItemInfo> popMap;
|
||||
|
||||
for (it = groupList.begin(); it != groupList.end(); it++)
|
||||
{
|
||||
@ -961,8 +943,6 @@ void PostedListDialog::insertGroupData( std::list<RsGroupMetaData> &groupList)
|
||||
GroupItemInfo groupItemInfo;
|
||||
groupInfoToGroupItemInfo(*it, groupItemInfo);
|
||||
|
||||
completeList.push_back(groupItemInfo);
|
||||
|
||||
if (IS_GROUP_SUBSCRIBED(flags))
|
||||
{
|
||||
if (IS_GROUP_ADMIN(flags) || IS_GROUP_PUBLISHER(flags))
|
||||
@ -974,12 +954,40 @@ void PostedListDialog::insertGroupData( std::list<RsGroupMetaData> &groupList)
|
||||
subList.push_back(groupItemInfo);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
popMap.insert(std::make_pair(it->mPop, groupItemInfo));
|
||||
}
|
||||
}
|
||||
|
||||
/* iterate backwards through popMap - take the top 5 or 10% of list */
|
||||
uint32_t popCount = 5;
|
||||
if (popCount < popMap.size() / 10)
|
||||
{
|
||||
popCount = popMap.size() / 10;
|
||||
}
|
||||
|
||||
uint32_t i = 0;
|
||||
uint32_t popLimit = 0;
|
||||
std::multimap<uint32_t, GroupItemInfo>::reverse_iterator rit;
|
||||
for(rit = popMap.rbegin(); ((rit != popMap.rend()) && (i < popCount)); rit++, i++) ;
|
||||
if (rit != popMap.rend()) {
|
||||
popLimit = rit->first;
|
||||
}
|
||||
|
||||
for (rit = popMap.rbegin(); rit != popMap.rend(); rit++) {
|
||||
if (rit->second.popularity < (int) popLimit) {
|
||||
otherList.append(rit->second);
|
||||
} else {
|
||||
popList.append(rit->second);
|
||||
}
|
||||
}
|
||||
|
||||
/* now we can add them in as a tree! */
|
||||
ui.groupTreeWidget->fillGroupItems(yourTopics, adminList);
|
||||
ui.groupTreeWidget->fillGroupItems(subscribedTopics, subList);
|
||||
ui.groupTreeWidget->fillGroupItems(allTopics, completeList);
|
||||
ui.groupTreeWidget->fillGroupItems(popularTopics, popList);
|
||||
ui.groupTreeWidget->fillGroupItems(otherTopics, otherList);
|
||||
}
|
||||
|
||||
/**************************************************************************************/
|
||||
|
@ -66,7 +66,6 @@ private slots:
|
||||
void changedTopic(const QString &id);
|
||||
|
||||
void newTopic();
|
||||
void newSubTopic();
|
||||
void showGroupDetails();
|
||||
void newPost();
|
||||
|
||||
@ -127,7 +126,7 @@ private:
|
||||
void updateDisplayedItems(const std::vector<RsGxsMessageId>& msgIds);
|
||||
void updateCurrentDisplayComplete(const uint32_t& token);
|
||||
|
||||
void insertGroupData(std::list<RsGroupMetaData> &groupList);
|
||||
void insertGroupData(const std::list<RsGroupMetaData> &groupList);
|
||||
void groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo);
|
||||
|
||||
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
@ -135,7 +134,8 @@ private:
|
||||
private:
|
||||
QTreeWidgetItem *yourTopics;
|
||||
QTreeWidgetItem *subscribedTopics;
|
||||
QTreeWidgetItem *allTopics;
|
||||
QTreeWidgetItem *popularTopics;
|
||||
QTreeWidgetItem *otherTopics;
|
||||
|
||||
int mSortMethod;
|
||||
int mLastSortMethod;
|
||||
|
@ -21,8 +21,6 @@
|
||||
|
||||
#include <QMenu>
|
||||
#include <QToolButton>
|
||||
#include <QMutableListIterator>
|
||||
#include <QDebug>
|
||||
|
||||
#include "GroupTreeWidget.h"
|
||||
#include "ui_GroupTreeWidget.h"
|
||||
@ -33,7 +31,6 @@
|
||||
#include "RSTreeWidgetItem.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <iostream>
|
||||
|
||||
#define COLUMN_NAME 0
|
||||
#define COLUMN_POPULARITY 1
|
||||
@ -48,7 +45,6 @@
|
||||
#define ROLE_SEARCH_SCORE Qt::UserRole + 5
|
||||
#define ROLE_SUBSCRIBE_FLAGS Qt::UserRole + 6
|
||||
#define ROLE_COLOR Qt::UserRole + 7
|
||||
#define ROLE_PARENT_ID Qt::UserRole + 8
|
||||
|
||||
#define FILTER_NAME_INDEX 0
|
||||
#define FILTER_DESC_INDEX 1
|
||||
@ -303,38 +299,6 @@ QString GroupTreeWidget::itemId(QTreeWidgetItem *item)
|
||||
return item->data(COLUMN_DATA, ROLE_ID).toString();
|
||||
}
|
||||
|
||||
QTreeWidgetItem* GroupTreeWidget::recursiveIdSearch(QTreeWidgetItem *currentItem, const QString &id){
|
||||
int childCount = currentItem->childCount();
|
||||
for (int child = 0; child < childCount; child++) {
|
||||
QTreeWidgetItem *childItem = currentItem->child(child);
|
||||
if (childItem->data(COLUMN_DATA, ROLE_ID).toString() == id) {
|
||||
/* Found child */
|
||||
return childItem;
|
||||
}
|
||||
QTreeWidgetItem* recur = recursiveIdSearch(childItem, id);
|
||||
if(recur) return recur;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void GroupTreeWidget::checkOrphans(QList<QTreeWidgetItem *> &orphanList, QTreeWidgetItem *justInserted){
|
||||
|
||||
if(orphanList.length()==0)return;
|
||||
QString newID = justInserted->data(COLUMN_DATA, ROLE_ID).toString();
|
||||
|
||||
QList<QTreeWidgetItem *> oList = orphanList;
|
||||
QMutableListIterator<QTreeWidgetItem *> i(oList);
|
||||
while (i.hasNext()) {
|
||||
QTreeWidgetItem *orphan = i.next();
|
||||
QString parentID = orphan->data(COLUMN_DATA, ROLE_PARENT_ID).toString();
|
||||
if (parentID.compare(newID)==0){
|
||||
justInserted->addChild(orphan);
|
||||
i.remove();
|
||||
checkOrphans(orphanList,orphan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList<GroupItemInfo> &itemList)
|
||||
{
|
||||
if (categoryItem == NULL) {
|
||||
@ -343,32 +307,28 @@ void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList<
|
||||
|
||||
QString filterText = ui->filterLineEdit->text();
|
||||
|
||||
QList<QTreeWidgetItem *> orphans;
|
||||
|
||||
/* Iterate all items */
|
||||
QList<GroupItemInfo>::const_iterator it;
|
||||
for (it = itemList.begin(); it != itemList.end(); it++) {
|
||||
const GroupItemInfo &itemInfo = *it;
|
||||
|
||||
QTreeWidgetItem *item = recursiveIdSearch(categoryItem, itemInfo.id);
|
||||
QTreeWidgetItem *item = NULL;
|
||||
|
||||
/* Search exisiting item */
|
||||
int childCount = categoryItem->childCount();
|
||||
for (int child = 0; child < childCount; child++) {
|
||||
QTreeWidgetItem *childItem = categoryItem->child(child);
|
||||
if (childItem->data(COLUMN_DATA, ROLE_ID).toString() == itemInfo.id) {
|
||||
/* Found child */
|
||||
item = childItem;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (item == NULL) {
|
||||
item = new RSTreeWidgetItem(compareRole);
|
||||
item->setData(COLUMN_DATA, ROLE_ID, itemInfo.id);
|
||||
item->setData(COLUMN_DATA, ROLE_PARENT_ID, itemInfo.parentId);
|
||||
|
||||
if(itemInfo.parentId.length()<10){
|
||||
categoryItem->addChild(item);
|
||||
checkOrphans(orphans,item);
|
||||
}else{
|
||||
QTreeWidgetItem *parentItem = recursiveIdSearch(categoryItem, itemInfo.parentId);
|
||||
if(parentItem){
|
||||
parentItem->addChild(item);
|
||||
checkOrphans(orphans,item);
|
||||
}else{
|
||||
orphans.append(item);
|
||||
}
|
||||
}
|
||||
categoryItem->addChild(item);
|
||||
}
|
||||
|
||||
item->setText(COLUMN_NAME, itemInfo.name);
|
||||
@ -411,16 +371,6 @@ void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList<
|
||||
calculateScore(item, filterText);
|
||||
}
|
||||
|
||||
/* Add remaning topics whose parents are unknown */
|
||||
QMutableListIterator<QTreeWidgetItem *> i(orphans);
|
||||
while (i.hasNext()) {
|
||||
QTreeWidgetItem *orphan = i.next();
|
||||
categoryItem->addChild(orphan);
|
||||
std::cerr << "adding orphan\n"<< orphan->data(COLUMN_DATA, ROLE_PARENT_ID).toString().toStdString() <<"\n";
|
||||
std::cerr << orphan->data(COLUMN_DATA, ROLE_ID).toString().toStdString() <<"\n";
|
||||
std::cerr << "\n";
|
||||
}
|
||||
|
||||
/* Remove all items not in list */
|
||||
int child = 0;
|
||||
int childCount = categoryItem->childCount();
|
||||
@ -441,7 +391,7 @@ void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList<
|
||||
}
|
||||
}
|
||||
|
||||
resort(categoryItem, NULL);
|
||||
resort(categoryItem);
|
||||
}
|
||||
|
||||
void GroupTreeWidget::setUnreadCount(QTreeWidgetItem *item, int unreadCount)
|
||||
@ -516,104 +466,88 @@ int GroupTreeWidget::subscribeFlags(const QString &id)
|
||||
return item->data(COLUMN_DATA, ROLE_SUBSCRIBE_FLAGS).toInt();
|
||||
}
|
||||
|
||||
int GroupTreeWidget::calculateScore(QTreeWidgetItem *item, const QString &filterText)
|
||||
void GroupTreeWidget::calculateScore(QTreeWidgetItem *item, const QString &filterText)
|
||||
{
|
||||
|
||||
int score = 0;
|
||||
if (!item) return score;
|
||||
|
||||
/* Calculate one item */
|
||||
if (filterText.isEmpty()) {
|
||||
score = 0;
|
||||
item->setHidden(false);
|
||||
int count = item->childCount();
|
||||
for (int nIndex = 0; nIndex < count; ++nIndex) {
|
||||
calculateScore(item->child(nIndex), filterText);
|
||||
}
|
||||
} else {
|
||||
QString scoreString;
|
||||
|
||||
switch (ui->filterLineEdit->currentFilter()) {
|
||||
case FILTER_NAME_INDEX:
|
||||
scoreString = item->data(COLUMN_DATA, ROLE_NAME).toString();
|
||||
break;
|
||||
case FILTER_DESC_INDEX:
|
||||
scoreString = item->data(COLUMN_DATA, ROLE_DESCRIPTION).toString();
|
||||
break;
|
||||
}
|
||||
|
||||
score = scoreString.count(filterText, Qt::CaseInsensitive);
|
||||
|
||||
int count = item->childCount();
|
||||
for (int nIndex = 0; nIndex < count; ++nIndex) {
|
||||
score += calculateScore(item->child(nIndex), filterText);
|
||||
}
|
||||
|
||||
if (score) {
|
||||
if (item) {
|
||||
/* Calculate one item */
|
||||
int score;
|
||||
if (filterText.isEmpty()) {
|
||||
score = 0;
|
||||
item->setHidden(false);
|
||||
} else {
|
||||
item->setHidden(true);
|
||||
QString scoreString;
|
||||
|
||||
switch (ui->filterLineEdit->currentFilter()) {
|
||||
case FILTER_NAME_INDEX:
|
||||
scoreString = item->data(COLUMN_DATA, ROLE_NAME).toString();
|
||||
break;
|
||||
case FILTER_DESC_INDEX:
|
||||
scoreString = item->data(COLUMN_DATA, ROLE_DESCRIPTION).toString();
|
||||
break;
|
||||
}
|
||||
|
||||
score = scoreString.count(filterText, Qt::CaseInsensitive);
|
||||
|
||||
if (score) {
|
||||
item->setHidden(false);
|
||||
} else {
|
||||
item->setHidden(true);
|
||||
}
|
||||
}
|
||||
|
||||
item->setData(COLUMN_DATA, ROLE_SEARCH_SCORE, -score); // negative for correct sorting
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
item->setData(COLUMN_DATA, ROLE_SEARCH_SCORE, -score); // negative for correct sorting
|
||||
|
||||
return score;
|
||||
|
||||
}
|
||||
|
||||
void GroupTreeWidget::calculateScores(const QString &filterText)
|
||||
{
|
||||
/* Find out which has given word in it */
|
||||
QTreeWidgetItemIterator itemIterator(ui->treeWidget);
|
||||
QTreeWidgetItem *item;
|
||||
while ((item = *itemIterator) != NULL) {
|
||||
itemIterator++;
|
||||
|
||||
int count = ui->treeWidget->topLevelItemCount();
|
||||
for (int child = 0; child < count; child++) {
|
||||
QTreeWidgetItem *catitem = ui->treeWidget->topLevelItem(child);
|
||||
int icount = catitem->childCount();
|
||||
for (int nIndex = 0; nIndex < icount; ++nIndex) {
|
||||
calculateScore(catitem->child(nIndex), filterText);
|
||||
if (item->data(COLUMN_DATA, ROLE_ID).toString().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
calculateScore(item, filterText);
|
||||
}
|
||||
}
|
||||
|
||||
void GroupTreeWidget::filterChanged()
|
||||
{
|
||||
/* Recalculate score */
|
||||
calculateScores(ui->filterLineEdit->text());
|
||||
calculateScore(NULL, ui->filterLineEdit->text());
|
||||
|
||||
sort();
|
||||
resort(NULL);
|
||||
}
|
||||
|
||||
void GroupTreeWidget::resort(QTreeWidgetItem *categoryItem, Qt::SortOrder *order)
|
||||
void GroupTreeWidget::resort(QTreeWidgetItem *categoryItem)
|
||||
{
|
||||
if(order == NULL){
|
||||
Qt::SortOrder so = (actionSortAscending == NULL || actionSortAscending->isChecked()) ? Qt::AscendingOrder : Qt::DescendingOrder;
|
||||
order = &so;
|
||||
Qt::SortOrder order = (actionSortAscending == NULL || actionSortAscending->isChecked()) ? Qt::AscendingOrder : Qt::DescendingOrder;
|
||||
|
||||
if (ui->filterLineEdit->text().isEmpty() == false) {
|
||||
compareRole->setRole(COLUMN_DATA, ROLE_SEARCH_SCORE);
|
||||
compareRole->addRole(COLUMN_DATA, ROLE_LASTPOST);
|
||||
} else if (actionSortByName && actionSortByName->isChecked()) {
|
||||
compareRole->setRole(COLUMN_DATA, ROLE_NAME);
|
||||
} else if (actionSortByPopularity && actionSortByPopularity->isChecked()) {
|
||||
compareRole->setRole(COLUMN_DATA, ROLE_POPULARITY);
|
||||
} else if (actionSortByLastPost && actionSortByLastPost->isChecked()) {
|
||||
compareRole->setRole(COLUMN_DATA, ROLE_LASTPOST);
|
||||
}
|
||||
if (ui->filterLineEdit->text().isEmpty() == false) {
|
||||
compareRole->setRole(COLUMN_DATA, ROLE_SEARCH_SCORE);
|
||||
compareRole->addRole(COLUMN_DATA, ROLE_LASTPOST);
|
||||
} else if (actionSortByName && actionSortByName->isChecked()) {
|
||||
compareRole->setRole(COLUMN_DATA, ROLE_NAME);
|
||||
} else if (actionSortByPopularity && actionSortByPopularity->isChecked()) {
|
||||
compareRole->setRole(COLUMN_DATA, ROLE_POPULARITY);
|
||||
} else if (actionSortByLastPost && actionSortByLastPost->isChecked()) {
|
||||
compareRole->setRole(COLUMN_DATA, ROLE_LASTPOST);
|
||||
}
|
||||
|
||||
categoryItem->sortChildren(COLUMN_DATA, *order);
|
||||
int count = categoryItem->childCount();
|
||||
for (int child = 0; child < count; child++) {
|
||||
resort(categoryItem->child(child), order);
|
||||
if (categoryItem) {
|
||||
categoryItem->sortChildren(COLUMN_DATA, order);
|
||||
} else {
|
||||
int count = ui->treeWidget->topLevelItemCount();
|
||||
for (int child = 0; child < count; child++) {
|
||||
ui->treeWidget->topLevelItem(child)->sortChildren(COLUMN_DATA, order);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GroupTreeWidget::sort()
|
||||
{
|
||||
int count = ui->treeWidget->topLevelItemCount();
|
||||
for (int child = 0; child < count; child++) {
|
||||
resort(ui->treeWidget->topLevelItem(child), NULL);
|
||||
}
|
||||
resort(NULL);
|
||||
}
|
||||
|
@ -55,7 +55,6 @@ public:
|
||||
QString id;
|
||||
QString name;
|
||||
QString description;
|
||||
QString parentId;
|
||||
int popularity;
|
||||
QDateTime lastpost;
|
||||
QIcon icon;
|
||||
@ -86,8 +85,6 @@ public:
|
||||
QString itemId(QTreeWidgetItem *item);
|
||||
// Fill items of a group
|
||||
void fillGroupItems(QTreeWidgetItem *categoryItem, const QList<GroupItemInfo> &itemList);
|
||||
QTreeWidgetItem *recursiveIdSearch(QTreeWidgetItem *currentItem, const QString &id);
|
||||
void checkOrphans(QList<QTreeWidgetItem *> &orphanList, QTreeWidgetItem *justInserted);
|
||||
// Set the unread count of an item
|
||||
void setUnreadCount(QTreeWidgetItem *item, int unreadCount);
|
||||
|
||||
@ -123,9 +120,8 @@ private slots:
|
||||
private:
|
||||
// Initialize the display menu for sorting
|
||||
void initDisplayMenu(QToolButton *toolButton);
|
||||
int calculateScore(QTreeWidgetItem *item, const QString &filterText);
|
||||
void calculateScores(const QString &filterText);
|
||||
void resort(QTreeWidgetItem *categoryItem, Qt::SortOrder *order);
|
||||
void calculateScore(QTreeWidgetItem *item, const QString &filterText);
|
||||
void resort(QTreeWidgetItem *categoryItem);
|
||||
void updateColors();
|
||||
|
||||
private:
|
||||
|
@ -94,8 +94,6 @@ void GxsGroupDialog::init()
|
||||
this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height());
|
||||
}
|
||||
|
||||
ui.parentGroupBox->setVisible(false);
|
||||
|
||||
/* initialize key share list */
|
||||
ui.keyShareList->setHeaderText(tr("Contacts:"));
|
||||
ui.keyShareList->setModus(FriendSelectionWidget::MODUS_CHECK);
|
||||
@ -150,13 +148,13 @@ void GxsGroupDialog::initMode()
|
||||
{
|
||||
ui.buttonBox->setStandardButtons(QDialogButtonBox::Close);
|
||||
}
|
||||
break;
|
||||
//TODO
|
||||
// case MODE_EDIT:
|
||||
// {
|
||||
// ui.createButton->setText(tr("Submit Changes"));
|
||||
// }
|
||||
// break;
|
||||
break;
|
||||
case MODE_EDIT:
|
||||
{
|
||||
ui.buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
ui.buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Submit Group Changes"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -322,17 +320,40 @@ void GxsGroupDialog::submitGroup()
|
||||
break;
|
||||
|
||||
case MODE_EDIT:
|
||||
{
|
||||
/* TEMP: just close if down */
|
||||
cancelDialog();
|
||||
{
|
||||
|
||||
editGroup();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void GxsGroupDialog::setParentLabel(QString parentId){
|
||||
ui.parentGroupBox->setVisible(true);
|
||||
ui.parentLabel->setText(parentId);
|
||||
void GxsGroupDialog::editGroup()
|
||||
{
|
||||
std::cerr << "GxsGroupDialog::editGroup()" << std::endl;
|
||||
|
||||
QString name = misc::removeNewLine(ui.groupName->text());
|
||||
uint32_t flags = GXS_SERV::FLAG_PRIVACY_PUBLIC;
|
||||
|
||||
if(name.isEmpty())
|
||||
{
|
||||
/* error message */
|
||||
QMessageBox::warning(this, "RetroShare", tr("Please add a Name"), QMessageBox::Ok, QMessageBox::Ok);
|
||||
return; //Don't add a empty name!!
|
||||
}
|
||||
|
||||
uint32_t token;
|
||||
RsGxsGroupUpdateMeta updateMeta(mGrpMeta.mGroupId);
|
||||
updateMeta.setMetaUpdate(RsGxsGroupUpdateMeta::NAME, std::string(name.toUtf8()));
|
||||
|
||||
if (service_EditGroup(token, updateMeta))
|
||||
{
|
||||
// get the Queue to handle response.
|
||||
if(mTokenQueue != NULL)
|
||||
mTokenQueue->queueRequest(token, TOKENREQ_GROUPINFO, RS_TOKREQ_ANSTYPE_ACK, GXSGROUP_NEWGROUPID);
|
||||
}
|
||||
|
||||
close();
|
||||
}
|
||||
|
||||
void GxsGroupDialog::createGroup()
|
||||
@ -340,8 +361,7 @@ void GxsGroupDialog::createGroup()
|
||||
std::cerr << "GxsGroupDialog::createGroup()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
QString name = misc::removeNewLine(ui.groupName->text());
|
||||
QString parentGroupId = misc::removeNewLine(ui.parentLabel->text());
|
||||
QString name = misc::removeNewLine(ui.groupName->text());
|
||||
uint32_t flags = GXS_SERV::FLAG_PRIVACY_PUBLIC;
|
||||
|
||||
if(name.isEmpty())
|
||||
@ -356,8 +376,6 @@ void GxsGroupDialog::createGroup()
|
||||
|
||||
// Fill in the MetaData as best we can.
|
||||
meta.mGroupName = std::string(name.toUtf8());
|
||||
if(parentGroupId.length()>10)
|
||||
meta.mParentGrpId = parentGroupId.toStdString();
|
||||
|
||||
meta.mGroupFlags = flags;
|
||||
meta.mSignFlags = getGroupSignFlags();
|
||||
|
@ -143,7 +143,6 @@ public:
|
||||
|
||||
uint32_t mode() { return mMode; }
|
||||
|
||||
void setParentLabel(QString parentId);
|
||||
private:
|
||||
void newGroup();
|
||||
void init();
|
||||
@ -156,8 +155,6 @@ protected slots:
|
||||
void addGroupLogo();
|
||||
|
||||
protected:
|
||||
/** Qt Designer generated object */
|
||||
Ui::GxsGroupDialog ui;
|
||||
virtual void showEvent(QShowEvent*);
|
||||
|
||||
virtual void initUi() = 0;
|
||||
@ -166,13 +163,21 @@ protected:
|
||||
void setUiText(UiType uiType, const QString &text);
|
||||
|
||||
/*!
|
||||
* Main purpose is to help tansfer meta data to service
|
||||
*
|
||||
* It is up to the service to do the actual group creation
|
||||
* Service can also modify initial meta going into group
|
||||
* @param token This should be set to the token retrieved
|
||||
* @param meta The deriving GXS service should set their grp meta to this value
|
||||
*/
|
||||
virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta) = 0;
|
||||
|
||||
/*!
|
||||
* It is up to the service to do the actual group editing
|
||||
* TODO: make pure virtual
|
||||
* @param token This should be set to the token retrieved
|
||||
* @param meta The deriving GXS service should set their grp meta to this value
|
||||
*/
|
||||
virtual bool service_EditGroup(uint32_t &token, RsGxsGroupUpdateMeta &updateMeta) {}
|
||||
|
||||
/*!
|
||||
* This returns a group logo from the ui \n
|
||||
* Should be calleld by deriving service
|
||||
@ -205,6 +210,7 @@ private:
|
||||
void setupVisibility();
|
||||
void clearForm();
|
||||
void createGroup();
|
||||
void editGroup();
|
||||
void sendShareList(std::string forumId);
|
||||
void loadNewGroupId(const uint32_t &token);
|
||||
|
||||
@ -218,7 +224,10 @@ private:
|
||||
uint32_t mReadonlyFlags;
|
||||
uint32_t mDefaultsFlags;
|
||||
|
||||
protected:
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::GxsGroupDialog ui;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>695</width>
|
||||
<height>518</height>
|
||||
<height>448</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -156,7 +156,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" rowspan="7">
|
||||
<item row="0" column="1" rowspan="6">
|
||||
<widget class="QDockWidget" name="contactsdockWidget">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
@ -257,7 +257,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="distribGroupBox">
|
||||
<property name="title">
|
||||
<string>Message Distribution</string>
|
||||
@ -323,7 +323,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<item row="3" column="0">
|
||||
<widget class="QGroupBox" name="publishGroupBox">
|
||||
<property name="title">
|
||||
<string>Publish Signatures</string>
|
||||
@ -366,7 +366,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QGroupBox" name="personalGroupBox">
|
||||
<property name="title">
|
||||
<string>Personal Signatures</string>
|
||||
@ -402,7 +402,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<item row="5" column="0">
|
||||
<widget class="QGroupBox" name="commentGroupBox">
|
||||
<property name="title">
|
||||
<string>Comments</string>
|
||||
@ -431,7 +431,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<item row="6" column="0" colspan="2">
|
||||
<widget class="QFrame" name="extraFrame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
@ -441,40 +441,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="2">
|
||||
<item row="7" column="0" colspan="2">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="parentGroupBox">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_10">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_11">
|
||||
<item>
|
||||
<widget class="QLabel" name="prLabel">
|
||||
<property name="text">
|
||||
<string>Parent: </string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="parentLabel">
|
||||
<property name="text">
|
||||
<string>None</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -506,6 +479,7 @@
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../images.qrc"/>
|
||||
<include location="../images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
Loading…
Reference in New Issue
Block a user