mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-18 05:44:14 -05:00
Chozabu patch
- New db created for parent group id field, you will all previous gxs data - posted now support sub post topics git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-initdev@7042 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
efd1447a84
commit
f3afc128ee
@ -44,6 +44,7 @@
|
||||
#define KEY_NXS_IDENTITY std::string("identity")
|
||||
#define KEY_GRP_ID std::string("grpId")
|
||||
#define KEY_ORIG_GRP_ID std::string("origGrpId")
|
||||
#define KEY_PARENT_GRP_ID std::string("parentGrpId")
|
||||
#define KEY_SIGN_SET std::string("signSet")
|
||||
#define KEY_TIME_STAMP std::string("timeStamp")
|
||||
#define KEY_NXS_FLAGS std::string("flags")
|
||||
@ -114,7 +115,8 @@
|
||||
#define COL_GRP_INTERN_CIRCLE 18
|
||||
#define COL_GRP_ORIGINATOR 19
|
||||
#define COL_GRP_AUTHEN_FLAGS 20
|
||||
#define COL_GRP_RECV_TS 21
|
||||
#define COL_PARENT_GRP_ID 21
|
||||
#define COL_GRP_RECV_TS 22
|
||||
|
||||
|
||||
// msg col numbers
|
||||
@ -173,7 +175,8 @@ RsDataService::RsDataService(const std::string &serviceDir, const std::string &d
|
||||
grpMetaColumns.push_back(KEY_GRP_LAST_POST); grpMetaColumns.push_back(KEY_ORIG_GRP_ID); grpMetaColumns.push_back(KEY_NXS_SERV_STRING);
|
||||
grpMetaColumns.push_back(KEY_GRP_SIGN_FLAGS); grpMetaColumns.push_back(KEY_GRP_CIRCLE_ID); grpMetaColumns.push_back(KEY_GRP_CIRCLE_TYPE);
|
||||
grpMetaColumns.push_back(KEY_GRP_INTERNAL_CIRCLE); grpMetaColumns.push_back(KEY_GRP_ORIGINATOR);
|
||||
grpMetaColumns.push_back(KEY_GRP_AUTHEN_FLAGS); grpMetaColumns.push_back(KEY_RECV_TS);
|
||||
grpMetaColumns.push_back(KEY_GRP_AUTHEN_FLAGS); grpMetaColumns.push_back(KEY_PARENT_GRP_ID); grpMetaColumns.push_back(KEY_RECV_TS);
|
||||
|
||||
|
||||
// for retrieving actual grp data
|
||||
grpColumns.push_back(KEY_GRP_ID); grpColumns.push_back(KEY_NXS_FILE); grpColumns.push_back(KEY_NXS_FILE_OFFSET);
|
||||
@ -247,6 +250,7 @@ void RsDataService::initialise(){
|
||||
KEY_GRP_ORIGINATOR + " TEXT," +
|
||||
KEY_NXS_HASH + " TEXT," +
|
||||
KEY_RECV_TS + " INT," +
|
||||
KEY_PARENT_GRP_ID + " TEXT," +
|
||||
KEY_SIGN_SET + " BLOB);");
|
||||
|
||||
mDb->execSQL("CREATE TRIGGER " + GRP_LAST_POST_UPDATE_TRIGGER +
|
||||
@ -309,6 +313,8 @@ RsGxsGrpMetaData* RsDataService::locked_getGrpMeta(RetroCursor &c)
|
||||
grpMeta->mRecvTS = c.getInt32(COL_GRP_RECV_TS);
|
||||
|
||||
|
||||
c.getString(COL_PARENT_GRP_ID, grpMeta->mParentGrpId);
|
||||
|
||||
if(ok)
|
||||
return grpMeta;
|
||||
else
|
||||
@ -613,6 +619,7 @@ int RsDataService::storeGroup(std::map<RsNxsGrp *, RsGxsGrpMetaData *> &grp)
|
||||
cv.put(KEY_GRP_INTERNAL_CIRCLE, grpMetaPtr->mInternalCircle);
|
||||
cv.put(KEY_GRP_ORIGINATOR, grpMetaPtr->mOriginator);
|
||||
cv.put(KEY_GRP_AUTHEN_FLAGS, (int32_t)grpMetaPtr->mAuthenFlags);
|
||||
cv.put(KEY_PARENT_GRP_ID, grpMetaPtr->mParentGrpId);
|
||||
cv.put(KEY_NXS_HASH, grpMetaPtr->mHash);
|
||||
cv.put(KEY_RECV_TS, (int32_t)grpMetaPtr->mRecvTS);
|
||||
|
||||
|
@ -2051,6 +2051,7 @@ void RsGenExchange::publishGrps()
|
||||
{
|
||||
grp->metaData = new RsGxsGrpMetaData();
|
||||
grpItem->meta.mPublishTs = time(NULL);
|
||||
//grpItem->meta.mParentGrpId = std::string("empty");
|
||||
*(grp->metaData) = grpItem->meta;
|
||||
|
||||
// TODO: change when publish key optimisation added (public groups don't have publish key
|
||||
|
@ -49,6 +49,7 @@ uint32_t RsGxsGrpMetaData::serial_size()
|
||||
s += 4; // for mCircleType
|
||||
s += GetTlvStringSize(mCircleId);
|
||||
s += 4; // mAuthenFlag
|
||||
s += GetTlvStringSize(mParentGrpId);
|
||||
|
||||
return s;
|
||||
}
|
||||
@ -74,6 +75,7 @@ void RsGxsGrpMetaData::clear(){
|
||||
mOriginator.clear();
|
||||
mCircleType = 0;
|
||||
mAuthenFlags = 0;
|
||||
mParentGrpId.clear();
|
||||
mRecvTS = 0;
|
||||
|
||||
}
|
||||
@ -104,6 +106,7 @@ bool RsGxsGrpMetaData::serialise(void *data, uint32_t &pktsize)
|
||||
|
||||
ok &= SetTlvString(data, tlvsize, &offset, 0, mGroupId);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, 0, mOrigGrpId);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, 0, mParentGrpId);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, 0, mGroupName);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, mGroupFlags);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, mPublishTs);
|
||||
@ -134,6 +137,7 @@ bool RsGxsGrpMetaData::deserialise(void *data, uint32_t &pktsize)
|
||||
|
||||
ok &= GetTlvString(data, pktsize, &offset, 0, mGroupId);
|
||||
ok &= GetTlvString(data, pktsize, &offset, 0, mOrigGrpId);
|
||||
ok &= GetTlvString(data, pktsize, &offset, 0, mParentGrpId);
|
||||
ok &= GetTlvString(data, pktsize, &offset, 0, mGroupName);
|
||||
ok &= getRawUInt32(data, pktsize, &offset, &mGroupFlags);
|
||||
ok &= getRawUInt32(data, pktsize, &offset, &mPublishTs);
|
||||
@ -286,6 +290,8 @@ void RsGxsGrpMetaData::operator =(const RsGroupMetaData& rMeta)
|
||||
this->mInternalCircle = rMeta.mInternalCircle;
|
||||
this->mOriginator = rMeta.mOriginator;
|
||||
this->mAuthenFlags = rMeta.mAuthenFlags;
|
||||
//std::cout << "rMeta.mParentGrpId= " <<rMeta.mParentGrpId<<"\n";
|
||||
this->mParentGrpId = rMeta.mParentGrpId;
|
||||
}
|
||||
|
||||
void RsGxsMsgMetaData::operator =(const RsMsgMetaData& rMeta)
|
||||
|
@ -63,6 +63,7 @@ public:
|
||||
|
||||
std::string mServiceString;
|
||||
uint32_t mAuthenFlags;
|
||||
RsGxsGroupId mParentGrpId;
|
||||
|
||||
// BELOW HERE IS LOCAL DATA, THAT IS NOT FROM MSG.
|
||||
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "util/rsstring.h"
|
||||
|
||||
#include "pqi/p3linkmgr.h"
|
||||
#include <unistd.h>
|
||||
|
||||
const int pqissludpzone = 3144;
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
|
||||
#include "pqi/pqithreadstreamer.h"
|
||||
#include <unistd.h>
|
||||
|
||||
#define DEFAULT_STREAMER_TIMEOUT 10000 // 10 ms.
|
||||
#define DEFAULT_STREAMER_SLEEP 1000 // 1 ms.
|
||||
|
@ -65,6 +65,7 @@ public:
|
||||
std::string mCircleId;
|
||||
uint32_t mCircleType;
|
||||
uint32_t mAuthenFlags;
|
||||
std::string mParentGrpId;
|
||||
|
||||
// BELOW HERE IS LOCAL DATA, THAT IS NOT FROM MSG.
|
||||
|
||||
|
@ -1319,7 +1319,7 @@ int RsServer::StartupRetroShare()
|
||||
std::string currGxsDir = rsAccounts.PathAccountDirectory() + "/GXS_phase2";
|
||||
|
||||
#ifdef GXS_DEV_TESTNET // Different Directory for testing.
|
||||
currGxsDir += "_TESTNET6";
|
||||
currGxsDir += "_TESTNET7";
|
||||
#endif
|
||||
|
||||
bool cleanUpGxsDir = false;
|
||||
|
@ -47,13 +47,16 @@
|
||||
this->mInternalCircle = rGxsMeta.mInternalCircle;
|
||||
this->mOriginator = rGxsMeta.mOriginator;
|
||||
this->mAuthenFlags = rGxsMeta.mAuthenFlags;
|
||||
// std::cout << "rGxsMeta.mParentGrpId= " <<rGxsMeta.mParentGrpId<<"\n";
|
||||
// std::cout << "rGxsMeta.mParentGrpId.length()= " <<rGxsMeta.mParentGrpId.length()<<"\n";
|
||||
//std::cout << "this->mParentGrpId= " <<this->mParentGrpId<<"\n";
|
||||
this->mParentGrpId = rGxsMeta.mParentGrpId;
|
||||
}
|
||||
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const RsGroupMetaData &meta)
|
||||
{
|
||||
out << "[ GroupId: " << meta.mGroupId << " Name: " << meta.mGroupName;
|
||||
out << " PublishTs: " << meta.mPublishTs << " ]";
|
||||
out << "[ GroupId: " << meta.mGroupId << " Name: " << meta.mGroupName << " ]";
|
||||
return out;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
popularTopics = ui.groupTreeWidget->addCategoryItem(tr("Popular Topics"), QIcon(IMAGE_FOLDERGREEN), false);
|
||||
otherTopics = ui.groupTreeWidget->addCategoryItem(tr("Other Topics"), QIcon(IMAGE_FOLDERYELLOW), false);
|
||||
allTopics = ui.groupTreeWidget->addCategoryItem(tr("All Topics"), QIcon(IMAGE_FOLDERGREEN), false);
|
||||
//otherTopics = ui.groupTreeWidget->addCategoryItem(tr("Other Topics"), QIcon(IMAGE_FOLDERYELLOW), false);
|
||||
|
||||
ui.hotSortButton->setChecked(true);
|
||||
|
||||
@ -181,6 +181,8 @@ 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());
|
||||
}
|
||||
@ -361,6 +363,23 @@ 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()
|
||||
{
|
||||
@ -923,17 +942,16 @@ 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(const std::list<RsGroupMetaData> &groupList)
|
||||
void PostedListDialog::insertGroupData( std::list<RsGroupMetaData> &groupList)
|
||||
{
|
||||
std::list<RsGroupMetaData>::const_iterator it;
|
||||
|
||||
QList<GroupItemInfo> adminList;
|
||||
QList<GroupItemInfo> subList;
|
||||
QList<GroupItemInfo> popList;
|
||||
QList<GroupItemInfo> otherList;
|
||||
std::multimap<uint32_t, GroupItemInfo> popMap;
|
||||
QList<GroupItemInfo> completeList;
|
||||
|
||||
for (it = groupList.begin(); it != groupList.end(); it++)
|
||||
{
|
||||
@ -943,6 +961,8 @@ void PostedListDialog::insertGroupData(const std::list<RsGroupMetaData> &groupLi
|
||||
GroupItemInfo groupItemInfo;
|
||||
groupInfoToGroupItemInfo(*it, groupItemInfo);
|
||||
|
||||
completeList.push_back(groupItemInfo);
|
||||
|
||||
if (IS_GROUP_SUBSCRIBED(flags))
|
||||
{
|
||||
if (IS_GROUP_ADMIN(flags) || IS_GROUP_PUBLISHER(flags))
|
||||
@ -954,40 +974,12 @@ void PostedListDialog::insertGroupData(const std::list<RsGroupMetaData> &groupLi
|
||||
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(popularTopics, popList);
|
||||
ui.groupTreeWidget->fillGroupItems(otherTopics, otherList);
|
||||
ui.groupTreeWidget->fillGroupItems(allTopics, completeList);
|
||||
}
|
||||
|
||||
/**************************************************************************************/
|
||||
|
@ -66,6 +66,7 @@ private slots:
|
||||
void changedTopic(const QString &id);
|
||||
|
||||
void newTopic();
|
||||
void newSubTopic();
|
||||
void showGroupDetails();
|
||||
void newPost();
|
||||
|
||||
@ -126,7 +127,7 @@ private:
|
||||
void updateDisplayedItems(const std::vector<RsGxsMessageId>& msgIds);
|
||||
void updateCurrentDisplayComplete(const uint32_t& token);
|
||||
|
||||
void insertGroupData(const std::list<RsGroupMetaData> &groupList);
|
||||
void insertGroupData(std::list<RsGroupMetaData> &groupList);
|
||||
void groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo);
|
||||
|
||||
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
@ -134,8 +135,7 @@ private:
|
||||
private:
|
||||
QTreeWidgetItem *yourTopics;
|
||||
QTreeWidgetItem *subscribedTopics;
|
||||
QTreeWidgetItem *popularTopics;
|
||||
QTreeWidgetItem *otherTopics;
|
||||
QTreeWidgetItem *allTopics;
|
||||
|
||||
int mSortMethod;
|
||||
int mLastSortMethod;
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
#include <QMenu>
|
||||
#include <QToolButton>
|
||||
#include <QMutableListIterator>
|
||||
#include <QDebug>
|
||||
|
||||
#include "GroupTreeWidget.h"
|
||||
#include "ui_GroupTreeWidget.h"
|
||||
@ -31,6 +33,7 @@
|
||||
#include "RSTreeWidgetItem.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <iostream>
|
||||
|
||||
#define COLUMN_NAME 0
|
||||
#define COLUMN_POPULARITY 1
|
||||
@ -45,6 +48,7 @@
|
||||
#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
|
||||
@ -299,6 +303,38 @@ 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) {
|
||||
@ -307,28 +343,32 @@ 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 = 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;
|
||||
}
|
||||
}
|
||||
QTreeWidgetItem *item = recursiveIdSearch(categoryItem, itemInfo.id);
|
||||
|
||||
if (item == NULL) {
|
||||
item = new RSTreeWidgetItem(compareRole);
|
||||
item->setData(COLUMN_DATA, ROLE_ID, itemInfo.id);
|
||||
categoryItem->addChild(item);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
item->setText(COLUMN_NAME, itemInfo.name);
|
||||
@ -371,6 +411,16 @@ 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();
|
||||
@ -391,7 +441,7 @@ void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList<
|
||||
}
|
||||
}
|
||||
|
||||
resort(categoryItem);
|
||||
resort(categoryItem, NULL);
|
||||
}
|
||||
|
||||
void GroupTreeWidget::setUnreadCount(QTreeWidgetItem *item, int unreadCount)
|
||||
@ -466,88 +516,104 @@ int GroupTreeWidget::subscribeFlags(const QString &id)
|
||||
return item->data(COLUMN_DATA, ROLE_SUBSCRIBE_FLAGS).toInt();
|
||||
}
|
||||
|
||||
void GroupTreeWidget::calculateScore(QTreeWidgetItem *item, const QString &filterText)
|
||||
int GroupTreeWidget::calculateScore(QTreeWidgetItem *item, const QString &filterText)
|
||||
{
|
||||
if (item) {
|
||||
/* Calculate one item */
|
||||
int score;
|
||||
if (filterText.isEmpty()) {
|
||||
score = 0;
|
||||
|
||||
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) {
|
||||
item->setHidden(false);
|
||||
} 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);
|
||||
|
||||
if (score) {
|
||||
item->setHidden(false);
|
||||
} else {
|
||||
item->setHidden(true);
|
||||
}
|
||||
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++;
|
||||
|
||||
if (item->data(COLUMN_DATA, ROLE_ID).toString().isEmpty()) {
|
||||
continue;
|
||||
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);
|
||||
}
|
||||
|
||||
calculateScore(item, filterText);
|
||||
}
|
||||
}
|
||||
|
||||
void GroupTreeWidget::filterChanged()
|
||||
{
|
||||
/* Recalculate score */
|
||||
calculateScore(NULL, ui->filterLineEdit->text());
|
||||
calculateScores(ui->filterLineEdit->text());
|
||||
|
||||
resort(NULL);
|
||||
sort();
|
||||
}
|
||||
|
||||
void GroupTreeWidget::resort(QTreeWidgetItem *categoryItem)
|
||||
void GroupTreeWidget::resort(QTreeWidgetItem *categoryItem, Qt::SortOrder *order)
|
||||
{
|
||||
Qt::SortOrder order = (actionSortAscending == NULL || actionSortAscending->isChecked()) ? Qt::AscendingOrder : Qt::DescendingOrder;
|
||||
if(order == NULL){
|
||||
Qt::SortOrder so = (actionSortAscending == NULL || actionSortAscending->isChecked()) ? Qt::AscendingOrder : Qt::DescendingOrder;
|
||||
order = &so;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
categoryItem->sortChildren(COLUMN_DATA, *order);
|
||||
int count = categoryItem->childCount();
|
||||
for (int child = 0; child < count; child++) {
|
||||
resort(categoryItem->child(child), order);
|
||||
}
|
||||
}
|
||||
|
||||
void GroupTreeWidget::sort()
|
||||
{
|
||||
resort(NULL);
|
||||
int count = ui->treeWidget->topLevelItemCount();
|
||||
for (int child = 0; child < count; child++) {
|
||||
resort(ui->treeWidget->topLevelItem(child), NULL);
|
||||
}
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ public:
|
||||
QString id;
|
||||
QString name;
|
||||
QString description;
|
||||
QString parentId;
|
||||
int popularity;
|
||||
QDateTime lastpost;
|
||||
QIcon icon;
|
||||
@ -85,6 +86,8 @@ 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);
|
||||
|
||||
@ -120,8 +123,9 @@ private slots:
|
||||
private:
|
||||
// Initialize the display menu for sorting
|
||||
void initDisplayMenu(QToolButton *toolButton);
|
||||
void calculateScore(QTreeWidgetItem *item, const QString &filterText);
|
||||
void resort(QTreeWidgetItem *categoryItem);
|
||||
int calculateScore(QTreeWidgetItem *item, const QString &filterText);
|
||||
void calculateScores(const QString &filterText);
|
||||
void resort(QTreeWidgetItem *categoryItem, Qt::SortOrder *order);
|
||||
void updateColors();
|
||||
|
||||
private:
|
||||
|
@ -94,6 +94,8 @@ 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);
|
||||
@ -148,13 +150,13 @@ void GxsGroupDialog::initMode()
|
||||
{
|
||||
ui.buttonBox->setStandardButtons(QDialogButtonBox::Close);
|
||||
}
|
||||
break;
|
||||
case MODE_EDIT:
|
||||
{
|
||||
ui.buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
ui.buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Submit Group Changes"));
|
||||
}
|
||||
break;
|
||||
break;
|
||||
//TODO
|
||||
// case MODE_EDIT:
|
||||
// {
|
||||
// ui.createButton->setText(tr("Submit Changes"));
|
||||
// }
|
||||
// break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -320,40 +322,17 @@ void GxsGroupDialog::submitGroup()
|
||||
break;
|
||||
|
||||
case MODE_EDIT:
|
||||
{
|
||||
|
||||
editGroup();
|
||||
{
|
||||
/* TEMP: just close if down */
|
||||
cancelDialog();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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::setParentLabel(QString parentId){
|
||||
ui.parentGroupBox->setVisible(true);
|
||||
ui.parentLabel->setText(parentId);
|
||||
}
|
||||
|
||||
void GxsGroupDialog::createGroup()
|
||||
@ -361,7 +340,8 @@ void GxsGroupDialog::createGroup()
|
||||
std::cerr << "GxsGroupDialog::createGroup()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
QString name = misc::removeNewLine(ui.groupName->text());
|
||||
QString name = misc::removeNewLine(ui.groupName->text());
|
||||
QString parentGroupId = misc::removeNewLine(ui.parentLabel->text());
|
||||
uint32_t flags = GXS_SERV::FLAG_PRIVACY_PUBLIC;
|
||||
|
||||
if(name.isEmpty())
|
||||
@ -376,6 +356,8 @@ 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,6 +143,7 @@ public:
|
||||
|
||||
uint32_t mode() { return mMode; }
|
||||
|
||||
void setParentLabel(QString parentId);
|
||||
private:
|
||||
void newGroup();
|
||||
void init();
|
||||
@ -155,6 +156,8 @@ protected slots:
|
||||
void addGroupLogo();
|
||||
|
||||
protected:
|
||||
/** Qt Designer generated object */
|
||||
Ui::GxsGroupDialog ui;
|
||||
virtual void showEvent(QShowEvent*);
|
||||
|
||||
virtual void initUi() = 0;
|
||||
@ -163,21 +166,13 @@ protected:
|
||||
void setUiText(UiType uiType, const QString &text);
|
||||
|
||||
/*!
|
||||
* It is up to the service to do the actual group creation
|
||||
* Service can also modify initial meta going into group
|
||||
* Main purpose is to help tansfer meta data to service
|
||||
*
|
||||
* @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
|
||||
@ -210,7 +205,6 @@ private:
|
||||
void setupVisibility();
|
||||
void clearForm();
|
||||
void createGroup();
|
||||
void editGroup();
|
||||
void sendShareList(std::string forumId);
|
||||
void loadNewGroupId(const uint32_t &token);
|
||||
|
||||
@ -224,10 +218,7 @@ 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>448</height>
|
||||
<height>518</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -156,7 +156,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" rowspan="6">
|
||||
<item row="0" column="1" rowspan="7">
|
||||
<widget class="QDockWidget" name="contactsdockWidget">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
@ -257,7 +257,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="3" column="0">
|
||||
<widget class="QGroupBox" name="distribGroupBox">
|
||||
<property name="title">
|
||||
<string>Message Distribution</string>
|
||||
@ -323,7 +323,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QGroupBox" name="publishGroupBox">
|
||||
<property name="title">
|
||||
<string>Publish Signatures</string>
|
||||
@ -366,7 +366,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<item row="5" column="0">
|
||||
<widget class="QGroupBox" name="personalGroupBox">
|
||||
<property name="title">
|
||||
<string>Personal Signatures</string>
|
||||
@ -402,7 +402,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="6" column="0">
|
||||
<widget class="QGroupBox" name="commentGroupBox">
|
||||
<property name="title">
|
||||
<string>Comments</string>
|
||||
@ -431,7 +431,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<item row="7" column="0" colspan="2">
|
||||
<widget class="QFrame" name="extraFrame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
@ -441,13 +441,40 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<item row="8" 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>
|
||||
@ -479,7 +506,6 @@
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../images.qrc"/>
|
||||
<include location="../images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
Loading…
x
Reference in New Issue
Block a user