mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Fixed refill of author column in forums.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7971 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
f371ca6a98
commit
eccb2db7c2
@ -95,6 +95,10 @@ void GxsIdRSTreeWidgetItem::setId(const RsGxsId &id, int column)
|
|||||||
//std::cerr << " GxsIdRSTreeWidgetItem::setId(" << id << "," << column << ")";
|
//std::cerr << " GxsIdRSTreeWidgetItem::setId(" << id << "," << column << ")";
|
||||||
//std::cerr << std::endl;
|
//std::cerr << std::endl;
|
||||||
|
|
||||||
|
if (mColumn == column && mId == id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
mId = id;
|
mId = id;
|
||||||
mColumn = column;
|
mColumn = column;
|
||||||
|
|
||||||
|
@ -75,12 +75,13 @@
|
|||||||
#define ROLE_THREAD_MSGID Qt::UserRole
|
#define ROLE_THREAD_MSGID Qt::UserRole
|
||||||
#define ROLE_THREAD_STATUS Qt::UserRole + 1
|
#define ROLE_THREAD_STATUS Qt::UserRole + 1
|
||||||
#define ROLE_THREAD_MISSING Qt::UserRole + 2
|
#define ROLE_THREAD_MISSING Qt::UserRole + 2
|
||||||
|
#define ROLE_THREAD_AUTHOR Qt::UserRole + 3
|
||||||
// no need to copy, don't count in ROLE_THREAD_COUNT
|
// no need to copy, don't count in ROLE_THREAD_COUNT
|
||||||
#define ROLE_THREAD_READCHILDREN Qt::UserRole + 3
|
#define ROLE_THREAD_READCHILDREN Qt::UserRole + 4
|
||||||
#define ROLE_THREAD_UNREADCHILDREN Qt::UserRole + 4
|
#define ROLE_THREAD_UNREADCHILDREN Qt::UserRole + 5
|
||||||
#define ROLE_THREAD_SORT Qt::UserRole + 5
|
#define ROLE_THREAD_SORT Qt::UserRole + 6
|
||||||
|
|
||||||
#define ROLE_THREAD_COUNT 3
|
#define ROLE_THREAD_COUNT 4
|
||||||
|
|
||||||
#define TOKEN_TYPE_GROUPDATA 1
|
#define TOKEN_TYPE_GROUPDATA 1
|
||||||
#define TOKEN_TYPE_INSERT_THREADS 2
|
#define TOKEN_TYPE_INSERT_THREADS 2
|
||||||
@ -849,7 +850,8 @@ QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForum
|
|||||||
item->setText(COLUMN_THREAD_DATE, text);
|
item->setText(COLUMN_THREAD_DATE, text);
|
||||||
item->setData(COLUMN_THREAD_DATE, ROLE_THREAD_SORT, sort);
|
item->setData(COLUMN_THREAD_DATE, ROLE_THREAD_SORT, sort);
|
||||||
|
|
||||||
item->setId(msg.mMeta.mAuthorId, COLUMN_THREAD_AUTHOR);
|
item->setId(msg.mMeta.mAuthorId, COLUMN_THREAD_AUTHOR);
|
||||||
|
item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_AUTHOR, QString::fromStdString(msg.mMeta.mAuthorId.toStdString()));
|
||||||
//#TODO
|
//#TODO
|
||||||
#if 0
|
#if 0
|
||||||
text = QString::fromUtf8(authorName.c_str());
|
text = QString::fromUtf8(authorName.c_str());
|
||||||
@ -1000,6 +1002,33 @@ void GxsForumThreadWidget::insertThreads()
|
|||||||
emit groupChanged(this);
|
emit groupChanged(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void copyItem(QTreeWidgetItem *item, const QTreeWidgetItem *newItem)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < COLUMN_THREAD_COUNT; ++i) {
|
||||||
|
if (i == COLUMN_THREAD_AUTHOR) {
|
||||||
|
QString authorId = newItem->data(COLUMN_THREAD_DATA, ROLE_THREAD_AUTHOR).toString();
|
||||||
|
if (authorId != item->data(COLUMN_THREAD_DATA, ROLE_THREAD_AUTHOR).toString()) {
|
||||||
|
/* Author has changed? */
|
||||||
|
GxsIdRSTreeWidgetItem *gxsIdItem = dynamic_cast<GxsIdRSTreeWidgetItem*>(item);
|
||||||
|
if (gxsIdItem) {
|
||||||
|
/* Set new gxs id */
|
||||||
|
gxsIdItem->setId(RsGxsId(authorId.toStdString()), i);
|
||||||
|
} else {
|
||||||
|
/* Copy text */
|
||||||
|
item->setText(i, newItem->text(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* Copy text */
|
||||||
|
item->setText(i, newItem->text(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (i = 0; i < ROLE_THREAD_COUNT; ++i) {
|
||||||
|
item->setData(COLUMN_THREAD_DATA, Qt::UserRole + i, newItem->data(COLUMN_THREAD_DATA, Qt::UserRole + i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GxsForumThreadWidget::fillThreads(QList<QTreeWidgetItem *> &threadList, bool expandNewMessages, QList<QTreeWidgetItem*> &itemToExpand)
|
void GxsForumThreadWidget::fillThreads(QList<QTreeWidgetItem *> &threadList, bool expandNewMessages, QList<QTreeWidgetItem*> &itemToExpand)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_FORUMS
|
#ifdef DEBUG_FORUMS
|
||||||
@ -1046,13 +1075,7 @@ void GxsForumThreadWidget::fillThreads(QList<QTreeWidgetItem *> &threadList, boo
|
|||||||
|
|
||||||
if (found >= 0) {
|
if (found >= 0) {
|
||||||
// set child data
|
// set child data
|
||||||
int i;
|
copyItem(threadItem, *newThread);
|
||||||
for (i = 0; i < COLUMN_THREAD_COUNT; ++i) {
|
|
||||||
threadItem->setText(i, (*newThread)->text(i));
|
|
||||||
}
|
|
||||||
for (i = 0; i < ROLE_THREAD_COUNT; ++i) {
|
|
||||||
threadItem->setData(COLUMN_THREAD_DATA, Qt::UserRole + i, (*newThread)->data(COLUMN_THREAD_DATA, Qt::UserRole + i));
|
|
||||||
}
|
|
||||||
|
|
||||||
// fill recursive
|
// fill recursive
|
||||||
fillChildren(threadItem, *newThread, expandNewMessages, itemToExpand);
|
fillChildren(threadItem, *newThread, expandNewMessages, itemToExpand);
|
||||||
@ -1128,13 +1151,7 @@ void GxsForumThreadWidget::fillChildren(QTreeWidgetItem *parentItem, QTreeWidget
|
|||||||
|
|
||||||
if (found >= 0) {
|
if (found >= 0) {
|
||||||
// set child data
|
// set child data
|
||||||
int i;
|
copyItem(childItem, newChildItem);
|
||||||
for (i = 0; i < COLUMN_THREAD_COUNT; ++i) {
|
|
||||||
childItem->setText(i, newChildItem->text(i));
|
|
||||||
}
|
|
||||||
for (i = 0; i < ROLE_THREAD_COUNT; ++i) {
|
|
||||||
childItem->setData(COLUMN_THREAD_DATA, Qt::UserRole + i, newChildItem->data(COLUMN_THREAD_DATA, Qt::UserRole + i));
|
|
||||||
}
|
|
||||||
|
|
||||||
// fill recursive
|
// fill recursive
|
||||||
fillChildren(childItem, newChildItem, expandNewMessages, itemToExpand);
|
fillChildren(childItem, newChildItem, expandNewMessages, itemToExpand);
|
||||||
|
Loading…
Reference in New Issue
Block a user