From 55d562238ed17f0d059d8ec38ab5e3dcc2fbbd10 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Wed, 21 Nov 2012 18:55:52 +0000 Subject: [PATCH] Applied changes from the trunk to the GXS forums. Cleaned old and unused files. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5868 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/RetroShare.pro | 3 - retroshare-gui/src/gui/ForumsV2Dialog.cpp | 2404 --------------- retroshare-gui/src/gui/ForumsV2Dialog.h | 271 -- retroshare-gui/src/gui/ForumsV2Dialog.ui | 1251 -------- retroshare-gui/src/gui/GxsForumsDialog.cpp | 2624 ++++++++--------- retroshare-gui/src/gui/GxsForumsDialog.h | 271 +- retroshare-gui/src/gui/GxsForumsDialog.ui | 775 +---- .../src/gui/Posted/PostedGroupDialog.cpp | 11 +- .../src/gui/Posted/PostedGroupDialog.h | 3 +- .../src/gui/forumsv2/CreateForumV2.cpp | 230 -- .../src/gui/forumsv2/CreateForumV2.h | 67 - .../src/gui/forumsv2/CreateForumV2.ui | 374 --- .../src/gui/forumsv2/CreateForumV2Msg.cpp | 424 --- .../src/gui/forumsv2/CreateForumV2Msg.h | 86 - .../src/gui/forumsv2/CreateForumV2Msg.ui | 333 --- .../src/gui/forumsv2/EditForumV2Details.cpp | 89 - .../src/gui/forumsv2/EditForumV2Details.h | 53 - .../src/gui/forumsv2/EditForumV2Details.ui | 130 - .../src/gui/forumsv2/ForumV2Details.cpp | 146 - .../src/gui/forumsv2/ForumV2Details.h | 67 - .../src/gui/forumsv2/ForumV2Details.ui | 201 -- .../src/gui/gxs/ForumV2GroupDialog.cpp | 100 - .../src/gui/gxs/ForumV2GroupDialog.h | 44 - .../src/gui/gxs/GxsForumGroupDialog.cpp | 14 +- .../src/gui/gxs/GxsForumGroupDialog.h | 4 +- retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp | 54 +- retroshare-gui/src/gui/gxs/GxsGroupDialog.h | 10 +- retroshare-gui/src/gui/gxs/GxsGroupDialog.ui | 130 +- .../src/gui/gxs/GxsIdTreeWidgetItem.cpp | 26 +- .../src/gui/gxs/GxsIdTreeWidgetItem.h | 12 +- .../src/gui/gxs/WikiGroupDialog.cpp | 14 +- retroshare-gui/src/gui/gxs/WikiGroupDialog.h | 4 +- .../src/gui/gxsforums/CreateGxsForum.cpp | 234 -- .../src/gui/gxsforums/CreateGxsForum.h | 67 - .../src/gui/gxsforums/CreateGxsForum.ui | 374 --- .../src/gui/gxsforums/CreateGxsForumMsg.cpp | 29 +- .../src/gui/gxsforums/CreateGxsForumMsg.h | 13 +- .../src/gui/gxsforums/CreateGxsForumMsg.ui | 257 +- .../src/gui/gxsforums/EditGxsForumDetails.cpp | 7 +- .../src/gui/gxsforums/EditGxsForumDetails.h | 2 +- .../src/gui/gxsforums/EditGxsForumDetails.ui | 51 +- .../src/gui/gxsforums/GxsForumDetails.cpp | 36 +- .../src/gui/gxsforums/GxsForumDetails.h | 11 +- .../src/gui/gxsforums/GxsForumDetails.ui | 32 +- 44 files changed, 1744 insertions(+), 9594 deletions(-) delete mode 100644 retroshare-gui/src/gui/ForumsV2Dialog.cpp delete mode 100644 retroshare-gui/src/gui/ForumsV2Dialog.h delete mode 100644 retroshare-gui/src/gui/ForumsV2Dialog.ui delete mode 100644 retroshare-gui/src/gui/forumsv2/CreateForumV2.cpp delete mode 100644 retroshare-gui/src/gui/forumsv2/CreateForumV2.h delete mode 100644 retroshare-gui/src/gui/forumsv2/CreateForumV2.ui delete mode 100644 retroshare-gui/src/gui/forumsv2/CreateForumV2Msg.cpp delete mode 100644 retroshare-gui/src/gui/forumsv2/CreateForumV2Msg.h delete mode 100644 retroshare-gui/src/gui/forumsv2/CreateForumV2Msg.ui delete mode 100644 retroshare-gui/src/gui/forumsv2/EditForumV2Details.cpp delete mode 100644 retroshare-gui/src/gui/forumsv2/EditForumV2Details.h delete mode 100644 retroshare-gui/src/gui/forumsv2/EditForumV2Details.ui delete mode 100644 retroshare-gui/src/gui/forumsv2/ForumV2Details.cpp delete mode 100644 retroshare-gui/src/gui/forumsv2/ForumV2Details.h delete mode 100644 retroshare-gui/src/gui/forumsv2/ForumV2Details.ui delete mode 100644 retroshare-gui/src/gui/gxs/ForumV2GroupDialog.cpp delete mode 100644 retroshare-gui/src/gui/gxs/ForumV2GroupDialog.h delete mode 100644 retroshare-gui/src/gui/gxsforums/CreateGxsForum.cpp delete mode 100644 retroshare-gui/src/gui/gxsforums/CreateGxsForum.h delete mode 100644 retroshare-gui/src/gui/gxsforums/CreateGxsForum.ui diff --git a/retroshare-gui/src/RetroShare.pro b/retroshare-gui/src/RetroShare.pro index e8e1dc8ed..9af9bfef8 100644 --- a/retroshare-gui/src/RetroShare.pro +++ b/retroshare-gui/src/RetroShare.pro @@ -967,19 +967,16 @@ gxsforums { HEADERS += gui/GxsForumsDialog.h \ gui/gxsforums/GxsForumDetails.h \ gui/gxsforums/EditGxsForumDetails.h \ - gui/gxsforums/CreateGxsForum.h \ gui/gxsforums/CreateGxsForumMsg.h \ FORMS += gui/GxsForumsDialog.ui \ gui/gxsforums/GxsForumDetails.ui \ gui/gxsforums/EditGxsForumDetails.ui \ - gui/gxsforums/CreateGxsForum.ui \ gui/gxsforums/CreateGxsForumMsg.ui \ SOURCES += gui/GxsForumsDialog.cpp \ gui/gxsforums/GxsForumDetails.cpp \ gui/gxsforums/EditGxsForumDetails.cpp \ - gui/gxsforums/CreateGxsForum.cpp \ gui/gxsforums/CreateGxsForumMsg.cpp \ } diff --git a/retroshare-gui/src/gui/ForumsV2Dialog.cpp b/retroshare-gui/src/gui/ForumsV2Dialog.cpp deleted file mode 100644 index 62ec6061c..000000000 --- a/retroshare-gui/src/gui/ForumsV2Dialog.cpp +++ /dev/null @@ -1,2404 +0,0 @@ -/**************************************************************** - * RetroShare is distributed under the following license: - * - * Copyright (C) 2008 Robert Fernie - * - * 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 -#include -#include -#include -#include -#include - -#include "ForumsV2Dialog.h" - -#include "gxs/ForumV2GroupDialog.h" - -#include "forumsv2/CreateForumV2Msg.h" - -#include "msgs/MessageComposer.h" -#include "settings/rsharesettings.h" -#include "common/Emoticons.h" -#include "common/RSItemDelegate.h" -#include "common/PopularityDefs.h" -#include "RetroShareLink.h" -#include "channels/ShareKey.h" -#include "notifyqt.h" -#include "util/HandleRichText.h" - -#include -#include - -#include - -//#define DEBUG_FORUMS - -/* Images for context menu icons */ -#define IMAGE_MESSAGE ":/images/folder-draft.png" -#define IMAGE_MESSAGEREPLY ":/images/mail_reply.png" -#define IMAGE_MESSAGEREMOVE ":/images/mail_delete.png" -#define IMAGE_DOWNLOAD ":/images/start.png" -#define IMAGE_DOWNLOADALL ":/images/startall.png" - -/* Images for TreeWidget */ -#define IMAGE_FOLDER ":/images/folder16.png" -#define IMAGE_FOLDERGREEN ":/images/folder_green.png" -#define IMAGE_FOLDERRED ":/images/folder_red.png" -#define IMAGE_FOLDERYELLOW ":/images/folder_yellow.png" -#define IMAGE_FORUM ":/images/konversation.png" -#define IMAGE_SUBSCRIBE ":/images/edit_add24.png" -#define IMAGE_UNSUBSCRIBE ":/images/cancel.png" -#define IMAGE_INFO ":/images/info16.png" -#define IMAGE_NEWFORUM ":/images/new_forum16.png" -#define IMAGE_FORUMAUTHD ":/images/konv_message2.png" -#define IMAGE_COPYLINK ":/images/copyrslink.png" - -#define VIEW_LAST_POST 0 -#define VIEW_THREADED 1 -#define VIEW_FLAT 2 - -/* Thread constants */ -#define COLUMN_THREAD_COUNT 6 -#define COLUMN_THREAD_TITLE 0 -#define COLUMN_THREAD_READ 1 -#define COLUMN_THREAD_DATE 2 -#define COLUMN_THREAD_AUTHOR 3 -#define COLUMN_THREAD_SIGNED 4 -#define COLUMN_THREAD_CONTENT 5 - -#define COLUMN_THREAD_DATA 0 // column for storing the userdata like msgid and parentid - -#define ROLE_THREAD_MSGID Qt::UserRole -#define ROLE_THREAD_STATUS Qt::UserRole + 1 -#define ROLE_THREAD_MISSING Qt::UserRole + 2 -// no need to copy, don't count in ROLE_THREAD_COUNT -#define ROLE_THREAD_READCHILDREN Qt::UserRole + 3 -#define ROLE_THREAD_UNREADCHILDREN Qt::UserRole + 4 - -#define ROLE_THREAD_COUNT 3 - - -static int FilterColumnFromComboBox(int nIndex) -{ - switch (nIndex) { - case 0: - return COLUMN_THREAD_DATE; - case 1: - return COLUMN_THREAD_TITLE; - case 2: - return COLUMN_THREAD_AUTHOR; - case 3: - return COLUMN_THREAD_CONTENT; - } - - return COLUMN_THREAD_TITLE; -} - -static int FilterColumnToComboBox(int nIndex) -{ - switch (nIndex) { - case COLUMN_THREAD_DATE: - return 0; - case COLUMN_THREAD_TITLE: - return 1; - case COLUMN_THREAD_AUTHOR: - return 2; - case COLUMN_THREAD_CONTENT: - return 3; - } - - return FilterColumnToComboBox(COLUMN_THREAD_TITLE); -} - - -/* - * Transformation Notes: - * there are still a couple of things that the new forums differ from Old version. - * these will need to be addressed in the future. - * -> Missing Messages are not handled yet. - * -> Child TS (for sorting) is not handled by GXS, this will probably have to be done in the GUI. - * -> Need to handle IDs properly. - * -> Popularity not handled in GXS yet. - * -> Much more to do. - */ - -/** Constructor */ -ForumsV2Dialog::ForumsV2Dialog(QWidget *parent) -: RsAutoUpdatePage(1000,parent) -{ - /* Invoke the Qt Designer generated object setup routine */ - ui.setupUi(this); - - m_bProcessSettings = false; - subscribeFlags = 0; - inMsgAsReadUnread = false; - - - /* Setup Queue */ - mForumQueue = new TokenQueue(rsForumsV2, this); - - - - connect( ui.forumTreeWidget, SIGNAL( treeCustomContextMenuRequested( QPoint ) ), this, SLOT( forumListCustomPopupMenu( QPoint ) ) ); - connect( ui.threadTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( threadListCustomPopupMenu( QPoint ) ) ); - - connect(ui.newForumButton, SIGNAL(clicked()), this, SLOT(newforum())); - connect(ui.newmessageButton, SIGNAL(clicked()), this, SLOT(createmessage())); - connect(ui.newthreadButton, SIGNAL(clicked()), this, SLOT(createthread())); - - connect( ui.forumTreeWidget, SIGNAL( treeCurrentItemChanged(QString) ), this, SLOT( changedForum(QString) ) ); - - connect( ui.threadTreeWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( changedThread () ) ); - connect( ui.threadTreeWidget, SIGNAL( itemClicked(QTreeWidgetItem*,int)), this, SLOT( clickedThread (QTreeWidgetItem*,int) ) ); - connect( ui.viewBox, SIGNAL( currentIndexChanged ( int ) ), this, SLOT( changedViewBox () ) ); - - connect(ui.expandButton, SIGNAL(clicked()), this, SLOT(togglethreadview())); - connect(ui.previousButton, SIGNAL(clicked()), this, SLOT(previousMessage())); - connect(ui.nextButton, SIGNAL(clicked()), this, SLOT(nextMessage())); - connect(ui.nextUnreadButton, SIGNAL(clicked()), this, SLOT(nextUnreadMessage())); - - connect(ui.downloadButton, SIGNAL(clicked()), this, SLOT(downloadAllFiles())); - - connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString))); - connect(ui.filterColumnComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(filterColumnChanged())); - - connect(NotifyQt::getInstance(), SIGNAL(forumMsgReadSatusChanged(QString,QString,int)), this, SLOT(forumMsgReadSatusChanged(QString,QString,int))); - - /* Set initial size the splitter */ - QList sizes; - sizes << 300 << width(); // Qt calculates the right sizes - //ui.splitter->setSizes(sizes); - - /* Set own item delegate */ - RSItemDelegate *itemDelegate = new RSItemDelegate(this); - itemDelegate->setSpacing(QSize(0, 2)); - ui.threadTreeWidget->setItemDelegate(itemDelegate); - - /* Set header resize modes and initial section sizes */ - QHeaderView * ttheader = ui.threadTreeWidget->header () ; - ttheader->setResizeMode (COLUMN_THREAD_TITLE, QHeaderView::Interactive); - ttheader->resizeSection (COLUMN_THREAD_DATE, 140); - ttheader->resizeSection (COLUMN_THREAD_TITLE, 290); - - ui.threadTreeWidget->sortItems( COLUMN_THREAD_DATE, Qt::DescendingOrder ); - - /* Set text of column "Read" to empty - without this the column has a number as header text */ - QTreeWidgetItem *headerItem = ui.threadTreeWidget->headerItem(); - headerItem->setText(COLUMN_THREAD_READ, ""); - - m_ForumNameFont = QFont("Times", 12, QFont::Bold); - ui.forumName->setFont(m_ForumNameFont); - ui.threadTitle->setFont(m_ForumNameFont); - - /* Initialize group tree */ - ui.forumTreeWidget->initDisplayMenu(ui.displayButton); - - /* create forum tree */ - yourForums = ui.forumTreeWidget->addCategoryItem(tr("Your Forums"), QIcon(IMAGE_FOLDER), true); - subscribedForums = ui.forumTreeWidget->addCategoryItem(tr("Subscribed Forums"), QIcon(IMAGE_FOLDERRED), true); - popularForums = ui.forumTreeWidget->addCategoryItem(tr("Popular Forums"), QIcon(IMAGE_FOLDERGREEN), false); - otherForums = ui.forumTreeWidget->addCategoryItem(tr("Other Forums"), QIcon(IMAGE_FOLDERYELLOW), false); - - lastViewType = -1; - - // load settings - processSettings(true); - - /* Set header sizes for the fixed columns and resize modes, must be set after processSettings */ - ttheader->resizeSection (COLUMN_THREAD_READ, 24); - ttheader->setResizeMode (COLUMN_THREAD_READ, QHeaderView::Fixed); - ttheader->hideSection (COLUMN_THREAD_CONTENT); - - ui.progressBar->hide(); - ui.progLayOutTxt->hide(); - ui.progressBarLayOut->setEnabled(false); - - mThreadLoading = false; - - insertThreads(); - - ui.threadTreeWidget->installEventFilter(this); - - /* Hide platform specific features */ -#ifdef Q_WS_WIN - -#endif -} - -ForumsV2Dialog::~ForumsV2Dialog() -{ - // save settings - processSettings(false); -} - -void ForumsV2Dialog::processSettings(bool bLoad) -{ - m_bProcessSettings = true; - - QHeaderView *pHeader = ui.threadTreeWidget->header () ; - - Settings->beginGroup(QString("ForumsV2Dialog")); - - if (bLoad) { - // load settings - - // expandFiles - bool bValue = Settings->value("expandButton", true).toBool(); - ui.expandButton->setChecked(bValue); - togglethreadview_internal(); - - // filterColumn - int nValue = FilterColumnToComboBox(Settings->value("filterColumn", COLUMN_THREAD_TITLE).toInt()); - ui.filterColumnComboBox->setCurrentIndex(nValue); - - // index of viewBox - ui.viewBox->setCurrentIndex(Settings->value("viewBox", VIEW_THREADED).toInt()); - - // state of thread tree - pHeader->restoreState(Settings->value("ThreadTree").toByteArray()); - - // state of splitter - ui.splitter->restoreState(Settings->value("Splitter").toByteArray()); - ui.threadSplitter->restoreState(Settings->value("threadSplitter").toByteArray()); - } else { - // save settings - - // state of thread tree - Settings->setValue("ThreadTree", pHeader->saveState()); - - // state of splitter - Settings->setValue("Splitter", ui.splitter->saveState()); - Settings->setValue("threadSplitter", ui.threadSplitter->saveState()); - } - - ui.forumTreeWidget->processSettings(Settings, bLoad); - - Settings->endGroup(); - m_bProcessSettings = false; -} - -void ForumsV2Dialog::forumListCustomPopupMenu( QPoint /*point*/ ) -{ - QMenu contextMnu( this ); - - QAction *action = contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Subscribe to Forum"), this, SLOT(subscribeToForum())); - action->setDisabled (mCurrForumId.empty() || IS_GROUP_SUBSCRIBED(subscribeFlags)); - - action = contextMnu.addAction(QIcon(IMAGE_UNSUBSCRIBE), tr("Unsubscribe to Forum"), this, SLOT(unsubscribeToForum())); - action->setEnabled (!mCurrForumId.empty() && IS_GROUP_SUBSCRIBED(subscribeFlags)); - - contextMnu.addSeparator(); - - contextMnu.addAction(QIcon(IMAGE_NEWFORUM), tr("New Forum"), this, SLOT(newforum())); - - action = contextMnu.addAction(QIcon(IMAGE_INFO), tr("Show Forum Details"), this, SLOT(showForumDetails())); - action->setEnabled (!mCurrForumId.empty ()); - - action = contextMnu.addAction(QIcon(":/images/settings16.png"), tr("Edit Forum Details"), this, SLOT(editForumDetails())); - action->setEnabled (!mCurrForumId.empty () && IS_GROUP_ADMIN(subscribeFlags)); - - QAction *shareKeyAct = new QAction(QIcon(":/images/gpgp_key_generate.png"), tr("Share Forum"), &contextMnu); - connect( shareKeyAct, SIGNAL( triggered() ), this, SLOT( shareKey() ) ); - shareKeyAct->setEnabled(!mCurrForumId.empty() && IS_GROUP_ADMIN(subscribeFlags)); - contextMnu.addAction( shareKeyAct); - - QAction *restoreKeysAct = new QAction(QIcon(":/images/settings16.png"), tr("Restore Publish Rights for Forum" ), &contextMnu); - connect( restoreKeysAct , SIGNAL( triggered() ), this, SLOT( restoreForumKeys() ) ); - restoreKeysAct->setEnabled(!mCurrForumId.empty() && !IS_GROUP_ADMIN(subscribeFlags)); - contextMnu.addAction( restoreKeysAct); - - action = contextMnu.addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyForumLink())); - action->setEnabled(!mCurrForumId.empty()); - - contextMnu.addSeparator(); - - action = contextMnu.addAction(QIcon(":/images/message-mail-read.png"), tr("Mark all as read"), this, SLOT(markMsgAsReadAll())); - action->setEnabled (!mCurrForumId.empty () && IS_GROUP_SUBSCRIBED(subscribeFlags)); - - action = contextMnu.addAction(QIcon(":/images/message-mail.png"), tr("Mark all as unread"), this, SLOT(markMsgAsUnreadAll())); - action->setEnabled (!mCurrForumId.empty () && IS_GROUP_SUBSCRIBED(subscribeFlags)); - -#ifdef DEBUG_FORUMS - contextMnu.addSeparator(); - action = contextMnu.addAction("Generate mass data", this, SLOT(generateMassData())); - action->setEnabled (!mCurrForumId.empty() && IS_GROUP_SUBSCRIBED(subscribeFlags)); -#endif - - contextMnu.exec(QCursor::pos()); -} - -void ForumsV2Dialog::threadListCustomPopupMenu( QPoint /*point*/ ) -{ - if (mThreadLoading) { - return; - } - - QMenu contextMnu( this ); - - QAction *replyAct = new QAction(QIcon(IMAGE_MESSAGEREPLY), tr( "Reply" ), &contextMnu ); - connect( replyAct , SIGNAL( triggered() ), this, SLOT( createmessage() ) ); - - QAction *newthreadAct = new QAction(QIcon(IMAGE_DOWNLOADALL), tr( "Start New Thread" ), &contextMnu ); - newthreadAct->setEnabled (IS_GROUP_SUBSCRIBED(subscribeFlags)); - connect( newthreadAct , SIGNAL( triggered() ), this, SLOT( createthread() ) ); - - QAction *replyauthorAct = new QAction(QIcon(IMAGE_MESSAGEREPLY), tr( "Reply to Author" ), &contextMnu ); - connect( replyauthorAct , SIGNAL( triggered() ), this, SLOT( replytomessage() ) ); - - QAction* expandAll = new QAction(tr( "Expand all" ), &contextMnu ); - connect( expandAll , SIGNAL( triggered() ), ui.threadTreeWidget, SLOT (expandAll()) ); - - QAction* collapseAll = new QAction(tr( "Collapse all" ), &contextMnu ); - connect( collapseAll , SIGNAL( triggered() ), ui.threadTreeWidget, SLOT(collapseAll()) ); - - QAction *markMsgAsRead = new QAction(QIcon(":/images/message-mail-read.png"), tr("Mark as read"), &contextMnu); - connect(markMsgAsRead , SIGNAL(triggered()), this, SLOT(markMsgAsRead())); - - QAction *markMsgAsReadChildren = new QAction(QIcon(":/images/message-mail-read.png"), tr("Mark as read") + " (" + tr ("with children") + ")", &contextMnu); - connect(markMsgAsReadChildren, SIGNAL(triggered()), this, SLOT(markMsgAsReadChildren())); - - QAction *markMsgAsUnread = new QAction(QIcon(":/images/message-mail.png"), tr("Mark as unread"), &contextMnu); - connect(markMsgAsUnread , SIGNAL(triggered()), this, SLOT(markMsgAsUnread())); - - QAction *markMsgAsUnreadChildren = new QAction(QIcon(":/images/message-mail.png"), tr("Mark as unread") + " (" + tr ("with children") + ")", &contextMnu); - connect(markMsgAsUnreadChildren , SIGNAL(triggered()), this, SLOT(markMsgAsUnreadChildren())); - - if (IS_GROUP_SUBSCRIBED(subscribeFlags)) { - QList Rows; - QList RowsRead; - QList RowsUnread; - int nCount = getSelectedMsgCount (&Rows, &RowsRead, &RowsUnread); - - if (RowsUnread.size() == 0) { - - markMsgAsRead->setDisabled(true); - } - if (RowsRead.size() == 0) { - markMsgAsUnread->setDisabled(true); - } - - bool bHasUnreadChildren = false; - bool bHasReadChildren = false; - int nRowCount = Rows.count(); - for (int i = 0; i < nRowCount; i++) { - if (bHasUnreadChildren || Rows[i]->data(COLUMN_THREAD_DATA, ROLE_THREAD_UNREADCHILDREN).toBool()) { - bHasUnreadChildren = true; - } - if (bHasReadChildren || Rows[i]->data(COLUMN_THREAD_DATA, ROLE_THREAD_READCHILDREN).toBool()) { - bHasReadChildren = true; - } - } - markMsgAsReadChildren->setEnabled(bHasUnreadChildren); - markMsgAsUnreadChildren->setEnabled(bHasReadChildren); - - if (nCount == 1) { - replyAct->setEnabled (true); - replyauthorAct->setEnabled (true); - } else { - replyAct->setDisabled (true); - replyauthorAct->setDisabled (true); - } - } else { - markMsgAsRead->setDisabled(true); - markMsgAsReadChildren->setDisabled(true); - markMsgAsUnread->setDisabled(true); - markMsgAsUnreadChildren->setDisabled(true); - replyAct->setDisabled (true); - replyauthorAct->setDisabled (true); - } - - contextMnu.addAction( replyAct); - contextMnu.addAction( newthreadAct); - contextMnu.addAction( replyauthorAct); - QAction* action = contextMnu.addAction(QIcon(IMAGE_COPYLINK), tr( "Copy RetroShare Link"), this, SLOT(copyMessageLink())); - action->setEnabled(!mCurrForumId.empty() && !mCurrThreadId.empty()); - contextMnu.addSeparator(); - contextMnu.addAction(markMsgAsRead); - contextMnu.addAction(markMsgAsReadChildren); - contextMnu.addAction(markMsgAsUnread); - contextMnu.addAction(markMsgAsUnreadChildren); - contextMnu.addSeparator(); - contextMnu.addAction( expandAll); - contextMnu.addAction( collapseAll); - - contextMnu.exec(QCursor::pos()); -} - -bool ForumsV2Dialog::eventFilter(QObject *obj, QEvent *event) -{ - if (obj == ui.threadTreeWidget) { - if (event->type() == QEvent::KeyPress) { - QKeyEvent *keyEvent = static_cast(event); - if (keyEvent && keyEvent->key() == Qt::Key_Space) { - // Space pressed - QTreeWidgetItem *item = ui.threadTreeWidget->currentItem (); - clickedThread (item, COLUMN_THREAD_READ); - return true; // eat event - } - } - } - // pass the event on to the parent class - return RsAutoUpdatePage::eventFilter(obj, event); -} - -void ForumsV2Dialog::restoreForumKeys(void) -{ - rsForumsV2->groupRestoreKeys(mCurrForumId); -} - -void ForumsV2Dialog::togglethreadview() -{ - // save state of button - Settings->setValueToGroup("ForumsV2Dialog", "expandButton", ui.expandButton->isChecked()); - - togglethreadview_internal(); -} - -void ForumsV2Dialog::togglethreadview_internal() -{ - if (ui.expandButton->isChecked()) { - ui.postText->setVisible(true); - ui.expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png"))); - ui.expandButton->setToolTip(tr("Hide")); - } else { - ui.postText->setVisible(false); - ui.expandButton->setIcon(QIcon(QString(":/images/edit_add24.png"))); - ui.expandButton->setToolTip(tr("Expand")); - } -} - -void ForumsV2Dialog::updateDisplay() -{ - std::list forumIds; - std::list::iterator it; - if (!rsForumsV2) - return; - -#if 0 - // TODO groupsChanged... HACK XXX. - if ((rsForumsV2->groupsChanged(forumIds)) || (rsForumsV2->updated())) - { - /* update Forums List */ - insertForums(); - - it = std::find(forumIds.begin(), forumIds.end(), mCurrForumId); - if (it != forumIds.end()) - { - /* update threads as well */ - insertThreads(); - } - } -#endif - - /* The proper version (above) can be done with a data request -> TODO */ - if (rsForumsV2->updated()) - { - /* update Forums List */ - insertForums(); - /* update threads as well */ - insertThreads(); - } -} - -static void CleanupItems (QList &items) -{ - QList::iterator item; - for (item = items.begin (); item != items.end (); item++) { - if (*item) { - delete (*item); - } - } - items.clear(); -} - -void ForumsV2Dialog::forumInfoToGroupItemInfo(const RsGroupMetaData &forumInfo, GroupItemInfo &groupItemInfo) -//void ForumsV2Dialog::forumInfoToGroupItemInfo(const ForumInfo &forumInfo, GroupItemInfo &groupItemInfo) -{ - - groupItemInfo.id = QString::fromStdString(forumInfo.mGroupId); - groupItemInfo.name = QString::fromUtf8(forumInfo.mGroupName.c_str()); - //groupItemInfo.description = QString::fromUtf8(forumInfo.forumDesc); - groupItemInfo.popularity = forumInfo.mPop; - groupItemInfo.lastpost = QDateTime::fromTime_t(forumInfo.mLastPost); - - if (forumInfo.mGroupFlags & RS_DISTRIB_AUTHEN_REQ) { - groupItemInfo.name += " (" + tr("AUTHD") + ")"; - groupItemInfo.icon = QIcon(IMAGE_FORUMAUTHD); - } else { - groupItemInfo.icon = QIcon(IMAGE_FORUM); - } - -// groupItemInfo.id = QString::fromStdString(forumInfo.forumId); -// groupItemInfo.name = QString::fromStdWString(forumInfo.forumName); -// groupItemInfo.description = QString::fromStdWString(forumInfo.forumDesc); -// groupItemInfo.popularity = forumInfo.pop; -// groupItemInfo.lastpost = QDateTime::fromTime_t(forumInfo.lastPost); -// -// if (forumInfo.forumFlags & RS_DISTRIB_AUTHEN_REQ) { -// groupItemInfo.name += " (" + tr("AUTHD") + ")"; -// groupItemInfo.icon = QIcon(IMAGE_FORUMAUTHD); -// } else { -// groupItemInfo.icon = QIcon(IMAGE_FORUM); -// } -} - - -/***** INSERT FORUM LISTS *****/ -void ForumsV2Dialog::insertForumsData(const std::list &forumList) -{ - std::list::const_iterator it; - - QList adminList; - QList subList; - QList popList; - QList otherList; - std::multimap popMap; - - for (it = forumList.begin(); it != forumList.end(); it++) { - /* sort it into Publish (Own), Subscribed, Popular and Other */ - uint32_t flags = it->mSubscribeFlags; - - GroupItemInfo groupItemInfo; - forumInfoToGroupItemInfo(*it, groupItemInfo); - - if (flags & RSGXS_GROUP_SUBSCRIBE_ADMIN) { - adminList.push_back(groupItemInfo); - } else if (flags & RSGXS_GROUP_SUBSCRIBE_SUBSCRIBED) { - /* subscribed forum */ - subList.push_back(groupItemInfo); - } else { - /* rate the others by popularity */ - 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::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.forumTreeWidget->fillGroupItems(yourForums, adminList); - ui.forumTreeWidget->fillGroupItems(subscribedForums, subList); - ui.forumTreeWidget->fillGroupItems(popularForums, popList); - ui.forumTreeWidget->fillGroupItems(otherForums, otherList); - - updateMessageSummaryList(""); -} - -void ForumsV2Dialog::changedForum(const QString &id) -{ - mCurrForumId = id.toStdString(); - - insertThreads(); -} - -void ForumsV2Dialog::changedThread () -{ - if (mThreadLoading) { - return; - } - - /* just grab the ids of the current item */ - QTreeWidgetItem *curr = ui.threadTreeWidget->currentItem(); - - if ((!curr) || (!curr->isSelected())) { - mCurrThreadId = ""; - } else { - mCurrThreadId = curr->data(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID).toString().toStdString(); - } - insertPost(); -} - -void ForumsV2Dialog::clickedThread (QTreeWidgetItem *item, int column) -{ - if (mCurrForumId.empty() || !IS_GROUP_SUBSCRIBED(subscribeFlags)) { - return; - } - - if (item == NULL) { - return; - } - - if (column == COLUMN_THREAD_READ) { - QList Rows; - Rows.append(item); - uint32_t status = item->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt(); - setMsgAsReadUnread(Rows, IS_MSG_UNREAD(status)); - return; - } -} - -void ForumsV2Dialog::forumMsgReadStatusChanged(const QString &forumId, const QString &msgId, int status) -{ - if (inMsgAsReadUnread) { - return; - } - - if (forumId.toStdString() == mCurrForumId) { - /* Search exisiting item */ - QTreeWidgetItemIterator itemIterator(ui.threadTreeWidget); - QTreeWidgetItem *item = NULL; - while ((item = *itemIterator) != NULL) { - itemIterator++; - - if (item->data(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID).toString() == msgId) { - // update status - item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS, status); - - QTreeWidgetItem *parentItem = item; - while (parentItem->parent()) { - parentItem = parentItem->parent(); - } - CalculateIconsAndFonts(parentItem); - break; - } - } - } - updateMessageSummaryList(forumId.toStdString()); -} - -void ForumsV2Dialog::CalculateIconsAndFonts(QTreeWidgetItem *pItem, bool &bHasReadChilddren, bool &bHasUnreadChilddren) -{ - uint32_t status = pItem->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt(); - - bool bUnread = IS_MSG_UNREAD(status); - bool missing = pItem->data(COLUMN_THREAD_DATA, ROLE_THREAD_MISSING).toBool(); - - // set icon - if (missing) { - pItem->setIcon(COLUMN_THREAD_READ, QIcon()); - pItem->setIcon(COLUMN_THREAD_TITLE, QIcon()); - } else { - if (bUnread) { - pItem->setIcon(COLUMN_THREAD_READ, QIcon(":/images/message-state-unread.png")); - } else { - pItem->setIcon(COLUMN_THREAD_READ, QIcon(":/images/message-state-read.png")); - } - if (status & RSGXS_MSG_STATUS_READ) { - pItem->setIcon(COLUMN_THREAD_TITLE, QIcon()); - } else { - pItem->setIcon(COLUMN_THREAD_TITLE, QIcon(":/images/message-state-new.png")); - } - } - - int nItem; - int nItemCount = pItem->childCount(); - - bool bMyReadChilddren = false; - bool bMyUnreadChilddren = false; - - for (nItem = 0; nItem < nItemCount; nItem++) { - CalculateIconsAndFonts(pItem->child(nItem), bMyReadChilddren, bMyUnreadChilddren); - } - - // set font - for (int i = 0; i < COLUMN_THREAD_COUNT; i++) { - QFont qf = pItem->font(i); - - if (!IS_GROUP_SUBSCRIBED(subscribeFlags)) { - qf.setBold(false); - pItem->setTextColor(i, Qt::black); - } else if (bUnread) { - qf.setBold(true); - pItem->setTextColor(i, Qt::black); - } else if (bMyUnreadChilddren) { - qf.setBold(true); - pItem->setTextColor(i, Qt::gray); - } else { - qf.setBold(false); - pItem->setTextColor(i, Qt::gray); - } - if (missing) { - /* Missing message */ - pItem->setTextColor(i, Qt::darkRed); - } - pItem->setFont(i, qf); - } - - pItem->setData(COLUMN_THREAD_DATA, ROLE_THREAD_READCHILDREN, bHasReadChilddren || bMyReadChilddren); - pItem->setData(COLUMN_THREAD_DATA, ROLE_THREAD_UNREADCHILDREN, bHasUnreadChilddren || bMyUnreadChilddren); - - bHasReadChilddren = bHasReadChilddren || bMyReadChilddren || !bUnread; - bHasUnreadChilddren = bHasUnreadChilddren || bMyUnreadChilddren || bUnread; -} - -void ForumsV2Dialog::CalculateIconsAndFonts(QTreeWidgetItem *pItem /*= NULL*/) -{ - bool bDummy1 = false; - bool bDummy2 = false; - - if (pItem) { - CalculateIconsAndFonts(pItem, bDummy1, bDummy2); - return; - } - - int nItem; - int nItemCount = ui.threadTreeWidget->topLevelItemCount(); - - for (nItem = 0; nItem < nItemCount; nItem++) { - bDummy1 = false; - bDummy2 = false; - CalculateIconsAndFonts(ui.threadTreeWidget->topLevelItem(nItem), bDummy1, bDummy2); - } -} - -void ForumsV2Dialog::fillThreadFinished() -{ -#ifdef DEBUG_FORUMS - std::cerr << "ForumsV2Dialog::fillThreadFinished" << std::endl; -#endif - - // This is now only called with a successful Load. - // cleanup of incomplete is handled elsewhere. - - // current thread has finished, hide progressbar and release thread - ui.progressBar->hide(); - ui.progLayOutTxt->hide(); - ui.progressBarLayOut->setEnabled(false); - -#ifdef DEBUG_FORUMS - std::cerr << "ForumsV2Dialog::fillThreadFinished Add messages" << std::endl; -#endif - ui.threadTreeWidget->setSortingEnabled(false); - - /* add all messages in! */ - if (lastViewType != mThreadLoad.ViewType || lastForumID != mCurrForumId) - { - ui.threadTreeWidget->clear(); - lastViewType = mThreadLoad.ViewType; - lastForumID = mCurrForumId; - ui.threadTreeWidget->insertTopLevelItems(0, mThreadLoad.Items); - - // clear list - mThreadLoad.Items.clear(); - } - else - { - FillThreads (mThreadLoad.Items, mThreadLoad.ExpandNewMessages, mThreadLoad.ItemToExpand); - - // cleanup list - CleanupItems (mThreadLoad.Items); - } - - ui.threadTreeWidget->setSortingEnabled(true); - - if (mThreadLoad.FocusMsgId.empty() == false) - { - /* Search exisiting item */ - QTreeWidgetItemIterator itemIterator(ui.threadTreeWidget); - QTreeWidgetItem *item = NULL; - while ((item = *itemIterator) != NULL) - { - itemIterator++; - - if (item->data(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID).toString().toStdString() == mThreadLoad.FocusMsgId) - { - ui.threadTreeWidget->setCurrentItem(item); - ui.threadTreeWidget->setFocus(); - break; - } - } - } - - QList::iterator Item; - for (Item = mThreadLoad.ItemToExpand.begin(); Item != mThreadLoad.ItemToExpand.end(); Item++) - { - if ((*Item)->isHidden() == false) - { - (*Item)->setExpanded(true); - } - } - mThreadLoad.ItemToExpand.clear(); - - if (ui.filterLineEdit->text().isEmpty() == false) { - filterItems(ui.filterLineEdit->text()); - } - - insertPost (); - CalculateIconsAndFonts(); - - ui.newthreadButton->setEnabled (IS_GROUP_SUBSCRIBED(subscribeFlags)); - - mThreadLoading = false; - -#ifdef DEBUG_FORUMS - std::cerr << "ForumsV2Dialog::fillThreadFinished done" << std::endl; -#endif -} - -void ForumsV2Dialog::fillThreadProgress(int current, int count) -{ - // show fill progress - if (count) { - ui.progressBar->setValue(current * ui.progressBar->maximum() / count); - } - -} - -void ForumsV2Dialog::insertThreads() -{ -#ifdef DEBUG_FORUMS - /* get the current Forum */ - std::cerr << "ForumsV2Dialog::insertThreads()" << std::endl; -#endif - - subscribeFlags = 0; - - ui.newmessageButton->setEnabled (false); - ui.newthreadButton->setEnabled (false); - - ui.postText->clear(); - ui.threadTitle->clear(); - - if (mCurrForumId.empty()) - { - /* not an actual forum - clear */ - ui.threadTreeWidget->clear(); - /* when no Thread selected - clear */ - ui.forumName->clear(); - /* clear last stored forumID */ - mCurrForumId.erase(); - lastForumID.erase(); - -#ifdef DEBUG_FORUMS - std::cerr << "ForumsV2Dialog::insertThreads() Current Thread Invalid" << std::endl; -#endif - - return; - } - - // Get Current Forum Info... then complete insertForumThreads(). - requestGroupSummary_CurrentForum(mCurrForumId); -} - - -void ForumsV2Dialog::insertForumThreads(const RsGroupMetaData &fi) -{ - subscribeFlags = fi.mSubscribeFlags; - ui.forumName->setText(QString::fromUtf8(fi.mGroupName.c_str())); - - ui.progressBarLayOut->setEnabled(true); - - ui.progLayOutTxt->show(); - ui.progressBar->reset(); - ui.progressBar->show(); - -#ifdef DEBUG_FORUMS - std::cerr << "ForumsV2Dialog::insertThreads() Start filling Forum threads" << std::endl; -#endif - - loadCurrentForumThreads(fi.mGroupId); -} - - - - -void ForumsV2Dialog::FillThreads(QList &ThreadList, bool expandNewMessages, QList &itemToExpand) -{ -#ifdef DEBUG_FORUMS - std::cerr << "ForumsV2Dialog::FillThreads()" << std::endl; -#endif - - int Index = 0; - QTreeWidgetItem *Thread; - QList::iterator NewThread; - - // delete not existing - while (Index < ui.threadTreeWidget->topLevelItemCount ()) { - Thread = ui.threadTreeWidget->topLevelItem (Index); - - // search existing new thread - int Found = -1; - for (NewThread = ThreadList.begin (); NewThread != ThreadList.end (); NewThread++) { - if (Thread->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID) == (*NewThread)->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID)) { - // found it - Found = Index; - break; - } - } - if (Found >= 0) { - Index++; - } else { - delete (ui.threadTreeWidget->takeTopLevelItem (Index)); - } - } - - // iterate all new threads - for (NewThread = ThreadList.begin (); NewThread != ThreadList.end (); NewThread++) { - // search existing thread - int Found = -1; - int Count = ui.threadTreeWidget->topLevelItemCount (); - for (Index = 0; Index < Count; Index++) { - Thread = ui.threadTreeWidget->topLevelItem (Index); - if (Thread->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID) == (*NewThread)->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID)) { - // found it - Found = Index; - break; - } - } - - if (Found >= 0) { - // set child data - int i; - for (i = 0; i < COLUMN_THREAD_COUNT; i++) { - Thread->setText (i, (*NewThread)->text (i)); - } - for (i = 0; i < ROLE_THREAD_COUNT; i++) { - Thread->setData (COLUMN_THREAD_DATA, Qt::UserRole + i, (*NewThread)->data (COLUMN_THREAD_DATA, Qt::UserRole + i)); - } - - // fill recursive - FillChildren (Thread, *NewThread, expandNewMessages, itemToExpand); - } else { - // add new thread - ui.threadTreeWidget->addTopLevelItem (*NewThread); - Thread = *NewThread; - *NewThread = NULL; - } - - uint32_t status = Thread->data (COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt(); - if (expandNewMessages && IS_MSG_UNREAD(status)) { - QTreeWidgetItem *pParent = Thread; - while ((pParent = pParent->parent()) != NULL) { - if (std::find(itemToExpand.begin(), itemToExpand.end(), pParent) == itemToExpand.end()) { - itemToExpand.push_back(pParent); - } - } - } - } - -#ifdef DEBUG_FORUMS - std::cerr << "ForumsV2Dialog::FillThreads() done" << std::endl; -#endif -} - -void ForumsV2Dialog::FillChildren(QTreeWidgetItem *Parent, QTreeWidgetItem *NewParent, bool expandNewMessages, QList &itemToExpand) -{ - int Index = 0; - int NewIndex; - int NewCount = NewParent->childCount(); - - QTreeWidgetItem *Child; - QTreeWidgetItem *NewChild; - - // delete not existing - while (Index < Parent->childCount ()) { - Child = Parent->child (Index); - - // search existing new child - int Found = -1; - int Count = NewParent->childCount(); - for (NewIndex = 0; NewIndex < Count; NewIndex++) { - NewChild = NewParent->child (NewIndex); - if (NewChild->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID) == Child->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID)) { - // found it - Found = Index; - break; - } - } - if (Found >= 0) { - Index++; - } else { - delete (Parent->takeChild (Index)); - } - } - - // iterate all new children - for (NewIndex = 0; NewIndex < NewCount; NewIndex++) { - NewChild = NewParent->child (NewIndex); - - // search existing child - int Found = -1; - int Count = Parent->childCount(); - for (Index = 0; Index < Count; Index++) { - Child = Parent->child (Index); - if (Child->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID) == NewChild->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID)) { - // found it - Found = Index; - break; - } - } - - if (Found >= 0) { - // set child data - int i; - for (i = 0; i < COLUMN_THREAD_COUNT; i++) { - Child->setText (i, NewChild->text (i)); - } - for (i = 0; i < ROLE_THREAD_COUNT; i++) { - Child->setData (COLUMN_THREAD_DATA, Qt::UserRole + i, NewChild->data (COLUMN_THREAD_DATA, Qt::UserRole + i)); - } - - // fill recursive - FillChildren (Child, NewChild, expandNewMessages, itemToExpand); - } else { - // add new child - Child = NewParent->takeChild(NewIndex); - Parent->addChild (Child); - NewIndex--; - NewCount--; - } - - uint32_t status = Child->data (COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt(); - if (expandNewMessages && IS_MSG_UNREAD(status)) { - QTreeWidgetItem *pParent = Child; - while ((pParent = pParent->parent()) != NULL) { - if (std::find(itemToExpand.begin(), itemToExpand.end(), pParent) == itemToExpand.end()) { - itemToExpand.push_back(pParent); - } - } - } - } -} - -QString ForumsV2Dialog::titleFromInfo(const RsMsgMetaData &meta) -{ - // NOTE - NOTE SURE HOW THIS WILL WORK! - if (meta.mMsgStatus & RS_DISTRIB_MISSING_MSG) { - return QApplication::translate("ForumsV2Dialog", "[ ... Missing Message ... ]"); - } - - return QString::fromUtf8(meta.mMsgName.c_str()); -} - -QString ForumsV2Dialog::messageFromInfo(const RsForumV2Msg &msg) -{ - if (msg.mMeta.mMsgStatus & RS_DISTRIB_MISSING_MSG) { - return QApplication::translate("ForumsV2Dialog", "Placeholder for missing Message"); - } - - return QString::fromUtf8(msg.mMsg.c_str()); -} - -void ForumsV2Dialog::insertPost() -{ - if ((mCurrForumId == "") || (mCurrThreadId == "")) - { - ui.postText->setText(""); - ui.threadTitle->setText(""); - ui.previousButton->setEnabled(false); - ui.nextButton->setEnabled(false); - ui.newmessageButton->setEnabled (false); - return; - } - - QTreeWidgetItem *curr = ui.threadTreeWidget->currentItem(); - if (curr) { - QTreeWidgetItem *Parent = curr->parent (); - int Index = Parent ? Parent->indexOfChild (curr) : ui.threadTreeWidget->indexOfTopLevelItem (curr); - int Count = Parent ? Parent->childCount () : ui.threadTreeWidget->topLevelItemCount (); - ui.previousButton->setEnabled (Index > 0); - ui.nextButton->setEnabled (Index < Count - 1); - } else { - // there is something wrong - ui.previousButton->setEnabled(false); - ui.nextButton->setEnabled(false); - return; - } - - ui.newmessageButton->setEnabled (IS_GROUP_SUBSCRIBED(subscribeFlags) && mCurrThreadId.empty() == false); - - /* blank text, incase we get nothing */ - ui.postText->setText(""); - /* request Post */ - - requestMsgData_InsertPost(mCurrThreadId); - -} - - - -void ForumsV2Dialog::insertPostData(const RsForumV2Msg &msg) -{ - /* As some time has elapsed since request - check that this is still the current msg. - * otherwise, another request will fill the data - */ - - if ((msg.mMeta.mGroupId != mCurrForumId) || (msg.mMeta.mMsgId != mCurrThreadId)) - { - std::cerr << "ForumsV2Dialog::insertPostData() Ignoring Invalid Data...."; - std::cerr << std::endl; - std::cerr << "\t CurrForumId: " << mCurrForumId << " != msg.GroupId: " << msg.mMeta.mGroupId; - std::cerr << std::endl; - std::cerr << "\t or CurrThdId: " << mCurrThreadId << " != msg.MsgId: " << msg.mMeta.mMsgId; - std::cerr << std::endl; - std::cerr << std::endl; - return; - } - - QTreeWidgetItem *curr = ui.threadTreeWidget->currentItem(); - - bool bSetToReadOnActive = Settings->getForumMsgSetToReadOnActivate(); - uint32_t status = curr->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt(); - - QList Row; - Row.append(curr); - if (status & RSGXS_MSG_STATUS_READ) { - if (bSetToReadOnActive && (status & RSGXS_MSG_STATUS_UNREAD_BY_USER)) { - /* set to read */ - setMsgAsReadUnread(Row, true); - } - } else { - /* set to read */ - if (bSetToReadOnActive) { - setMsgAsReadUnread(Row, true); - } else { - /* set to unread by user */ - setMsgAsReadUnread(Row, false); - } - } - - QString extraTxt = RsHtml().formatText(ui.postText->document(), messageFromInfo(msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS); - - ui.postText->setHtml(extraTxt); - ui.threadTitle->setText(titleFromInfo(msg.mMeta)); -} - - -void ForumsV2Dialog::previousMessage () -{ - QTreeWidgetItem *Item = ui.threadTreeWidget->currentItem (); - if (Item == NULL) { - return; - } - - QTreeWidgetItem *Parent = Item->parent (); - int Index = Parent ? Parent->indexOfChild (Item) : ui.threadTreeWidget->indexOfTopLevelItem (Item); - if (Index > 0) { - QTreeWidgetItem *Previous = Parent ? Parent->child (Index - 1) : ui.threadTreeWidget->topLevelItem (Index - 1); - if (Previous) { - ui.threadTreeWidget->setCurrentItem (Previous); - } - } -} - -void ForumsV2Dialog::nextMessage () -{ - QTreeWidgetItem *Item = ui.threadTreeWidget->currentItem (); - if (Item == NULL) { - return; - } - - QTreeWidgetItem *Parent = Item->parent (); - int Index = Parent ? Parent->indexOfChild (Item) : ui.threadTreeWidget->indexOfTopLevelItem (Item); - int Count = Parent ? Parent->childCount () : ui.threadTreeWidget->topLevelItemCount (); - if (Index < Count - 1) { - QTreeWidgetItem *Next = Parent ? Parent->child (Index + 1) : ui.threadTreeWidget->topLevelItem (Index + 1); - if (Next) { - ui.threadTreeWidget->setCurrentItem (Next); - } - } -} - -void ForumsV2Dialog::downloadAllFiles() -{ - QStringList urls; - if (RsHtml::findAnchors(ui.postText->toHtml(), urls) == false) { - return; - } - - if (urls.count() == 0) { - return; - } - - RetroShareLink::process(urls, RetroShareLink::TYPE_FILE/*, true*/); -} - -void ForumsV2Dialog::nextUnreadMessage() -{ - QTreeWidgetItem* currentItem = ui.threadTreeWidget->currentItem(); - if( !currentItem ) - { - currentItem = ui.threadTreeWidget->topLevelItem(0); - if( !currentItem ) - return; - } - - do - { - uint32_t status = currentItem->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt(); - if( IS_MSG_UNREAD(status) ) - { - ui.threadTreeWidget->setCurrentItem(currentItem); - return; - } - } while( (currentItem = ui.threadTreeWidget->itemBelow(currentItem)) != NULL ); -} - -// TODO -#if 0 -void ForumsV2Dialog::removemessage() -{ - //std::cerr << "ForumsV2Dialog::removemessage()" << std::endl; - std::string cid, mid; - if (!getCurrentMsg(cid, mid)) - { - //std::cerr << "ForumsV2Dialog::removemessage()"; - //std::cerr << " No Message selected" << std::endl; - return; - } - - rsMsgs -> MessageDelete(mid); -} -#endif - -/* get selected messages - the messages tree is single selected, but who knows ... */ -int ForumsV2Dialog::getSelectedMsgCount(QList *pRows, QList *pRowsRead, QList *pRowsUnread) -{ - if (pRowsRead) pRowsRead->clear(); - if (pRowsUnread) pRowsUnread->clear(); - - QList selectedItems = ui.threadTreeWidget->selectedItems(); - for(QList::iterator it = selectedItems.begin(); it != selectedItems.end(); it++) { - if (pRows) pRows->append(*it); - if (pRowsRead || pRowsUnread) { - uint32_t status = (*it)->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt(); - if (IS_MSG_UNREAD(status)) { - if (pRowsUnread) pRowsUnread->append(*it); - } else { - if (pRowsRead) pRowsRead->append(*it); - } - } - } - - return selectedItems.size(); -} - -void ForumsV2Dialog::setMsgAsReadUnread(QList &Rows, bool bRead) -{ - QList::iterator Row; - std::list changedItems; - - inMsgAsReadUnread = true; - - for (Row = Rows.begin(); Row != Rows.end(); Row++) { - if ((*Row)->data(COLUMN_THREAD_DATA, ROLE_THREAD_MISSING).toBool()) { - /* Missing message */ - continue; - } - - uint32_t status = (*Row)->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt(); - - /* set always as read ... */ - uint32_t statusNew = status | RSGXS_MSG_STATUS_READ; - if (bRead) { - /* ... and as read by user */ - statusNew &= ~RSGXS_MSG_STATUS_UNREAD_BY_USER; - } else { - /* ... and as unread by user */ - statusNew |= RSGXS_MSG_STATUS_UNREAD_BY_USER; - } - if (status != statusNew) { - std::string msgId = (*Row)->data(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID).toString().toStdString(); - rsForumsV2->setMessageStatus(msgId, statusNew, RSGXS_MSG_STATUS_READ | RSGXS_MSG_STATUS_UNREAD_BY_USER); - - (*Row)->setData(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS, statusNew); - - QTreeWidgetItem *parentItem = *Row; - while (parentItem->parent()) { - parentItem = parentItem->parent(); - } - if (std::find(changedItems.begin(), changedItems.end(), parentItem) == changedItems.end()) { - changedItems.push_back(parentItem); - } - } - } - - inMsgAsReadUnread = false; - - if (changedItems.size()) { - for (std::list::iterator it = changedItems.begin(); it != changedItems.end(); it++) { - CalculateIconsAndFonts(*it); - } - updateMessageSummaryList(mCurrForumId); - } -} - -void ForumsV2Dialog::markMsgAsReadUnread (bool bRead, bool bChildren, bool bForum) -{ - if (mCurrForumId.empty() || !IS_GROUP_SUBSCRIBED(subscribeFlags)) { - return; - } - - /* get selected messages */ - QList Rows; - if (bForum) { - int itemCount = ui.threadTreeWidget->topLevelItemCount(); - for (int item = 0; item < itemCount; item++) { - Rows.push_back(ui.threadTreeWidget->topLevelItem(item)); - } - } else { - getSelectedMsgCount (&Rows, NULL, NULL); - } - - if (bChildren) { - /* add children */ - QList AllRows; - - while (Rows.isEmpty() == false) { - QTreeWidgetItem *pRow = Rows.takeFirst(); - - /* add only items with the right state or with not RSGXS_MSG_STATUS_READ */ - uint32_t status = pRow->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt(); - if (IS_MSG_UNREAD(status) == bRead || (status & RSGXS_MSG_STATUS_READ) == 0) { - AllRows.append(pRow); - } - - for (int i = 0; i < pRow->childCount(); i++) { - /* add child to main list and let the main loop do the work */ - Rows.append(pRow->child(i)); - } - } - - if (AllRows.isEmpty()) { - /* nothing to do */ - return; - } - - setMsgAsReadUnread (AllRows, bRead); - - return; - } - - setMsgAsReadUnread (Rows, bRead); -} - -void ForumsV2Dialog::markMsgAsRead() -{ - markMsgAsReadUnread(true, false, false); -} - -void ForumsV2Dialog::markMsgAsReadChildren() -{ - markMsgAsReadUnread(true, true, false); -} - -void ForumsV2Dialog::markMsgAsReadAll() -{ - markMsgAsReadUnread(true, true, true); -} - -void ForumsV2Dialog::markMsgAsUnread() -{ - markMsgAsReadUnread(false, false, false); -} - -void ForumsV2Dialog::markMsgAsUnreadChildren() -{ - markMsgAsReadUnread(false, true, false); -} - -void ForumsV2Dialog::markMsgAsUnreadAll() -{ - markMsgAsReadUnread(false, true, true); -} - -void ForumsV2Dialog::copyForumLink() -{ - if (mCurrForumId.empty()) { - return; - } - -// THIS CODE CALLS getForumInfo() to verify that the Ids are valid. -// As we are switching to Request/Response this is now harder to do... -// So not bothering any more - shouldn't be necessary. -// IF we get errors - fix them, rather than patching here. -#if 0 - ForumInfo fi; - if (rsForumsV2->getForumInfo(mCurrForumId, fi)) { - RetroShareLink link; - if (link.createForum(fi.forumId, "")) { - QList urls; - urls.push_back(link); - RSLinkClipboard::copyLinks(urls); - } - } -#endif - - { - RetroShareLink link; - if (link.createForum(mCurrForumId, "")) - { - QList urls; - urls.push_back(link); - RSLinkClipboard::copyLinks(urls); - } - } -} - - - - -void ForumsV2Dialog::copyMessageLink() -{ - if (mCurrForumId.empty() || mCurrThreadId.empty()) { - return; - } - -// SEE NOTE In fn above. -#if 0 - ForumInfo fi; - if (rsForumsV2->getForumInfo(mCurrForumId, fi)) { - RetroShareLink link; - if (link.createForum(mCurrForumId, mCurrThreadId)) { - QList urls; - urls.push_back(link); - RSLinkClipboard::copyLinks(urls); - } - } -#endif - - { - RetroShareLink link; - if (link.createForum(mCurrForumId, mCurrThreadId)) - { - QList urls; - urls.push_back(link); - RSLinkClipboard::copyLinks(urls); - } - } -} - - -void ForumsV2Dialog::newforum() -{ - ForumV2GroupDialog cf (this); - cf.newGroup(); - - cf.exec (); -} - -void ForumsV2Dialog::createmessage() -{ - if (mCurrForumId.empty () || !IS_GROUP_SUBSCRIBED(subscribeFlags)) { - return; - } - - CreateForumV2Msg *cfm = new CreateForumV2Msg(mCurrForumId, mCurrThreadId); - cfm->show(); - - /* window will destroy itself! */ -} - -void ForumsV2Dialog::createthread() -{ - if (mCurrForumId.empty ()) { - QMessageBox::information(this, tr("RetroShare"), tr("No Forum Selected!")); - return; - } - - CreateForumV2Msg *cfm = new CreateForumV2Msg(mCurrForumId, ""); - cfm->setWindowTitle(tr("Start New Thread")); - cfm->show(); - - /* window will destroy itself! */ -} - -void ForumsV2Dialog::subscribeToForum() -{ - forumSubscribe(true); -} - -void ForumsV2Dialog::unsubscribeToForum() -{ - forumSubscribe(false); -} - -void ForumsV2Dialog::forumSubscribe(bool subscribe) -{ - if (mCurrForumId.empty()) { - return; - } - - uint32_t flags = RSGXS_GROUP_SUBSCRIBE_SUBSCRIBED; - if (!subscribe) - { - flags = 0; - } - - rsForumsV2->setGroupSubscribeFlags(mCurrForumId, flags, RSGXS_GROUP_SUBSCRIBE_SUBSCRIBED); - -} - -void ForumsV2Dialog::showForumDetails() -{ - if (mCurrForumId.empty()) { - return; - } - - ForumV2GroupDialog cf (this); - cf.existingGroup(mCurrForumId, GXS_GROUP_DIALOG_SHOW_MODE); - - cf.exec (); -} - -void ForumsV2Dialog::editForumDetails() -{ - if (mCurrForumId.empty()) { - return; - } - - ForumV2GroupDialog cf (this); - cf.existingGroup(mCurrForumId, GXS_GROUP_DIALOG_EDIT_MODE); - - cf.exec (); -} - -static QString buildReplyHeader(const RsMsgMetaData &meta) -{ - RetroShareLink link; - link.createMessage(meta.mAuthorId, ""); - QString from = link.toHtml(); - - QDateTime qtime; - qtime.setTime_t(meta.mPublishTs); - - QString header = QString("-----%1-----").arg(QApplication::translate("ForumsV2Dialog", "Original Message")); - header += QString("
%1: %2
").arg(QApplication::translate("ForumsV2Dialog", "From"), from); - - header += QString("
%1: %2
").arg(QApplication::translate("ForumsV2Dialog", "Sent"), qtime.toString(Qt::SystemLocaleLongDate)); - header += QString("%1: %2

").arg(QApplication::translate("ForumsV2Dialog", "Subject"), QString::fromUtf8(meta.mMsgName.c_str())); - header += "
"; - - header += QApplication::translate("ForumsV2Dialog", "On %1, %2 wrote:").arg(qtime.toString(Qt::SystemLocaleShortDate), from); - - return header; -} - -void ForumsV2Dialog::replytomessage() -{ - if (mCurrForumId.empty() || mCurrThreadId.empty()) { - QMessageBox::information(this, tr("RetroShare"),tr("You cant reply to a non-existant Message")); - return; - } - - - requestMsgData_ReplyMessage(mCurrThreadId); -} - -void ForumsV2Dialog::replyMessageData(const RsForumV2Msg &msg) -{ - if ((msg.mMeta.mGroupId != mCurrForumId) || (msg.mMeta.mMsgId != mCurrThreadId)) - { - std::cerr << "ForumsV2Dialog::replyMessageData() ERROR Message Ids have changed!"; - std::cerr << std::endl; - return; - } - - // NB: TODO REMOVE rsPeers references. - if (rsPeers->getPeerName(msg.mMeta.mAuthorId) !="") - { - MessageComposer *nMsgDialog = MessageComposer::newMsg(); - nMsgDialog->setTitleText(QString::fromUtf8(msg.mMeta.mMsgName.c_str()), MessageComposer::REPLY); - - nMsgDialog->setQuotedMsg(QString::fromUtf8(msg.mMsg.c_str()), buildReplyHeader(msg.mMeta)); - - nMsgDialog->addRecipient(MessageComposer::TO, msg.mMeta.mAuthorId, false); - nMsgDialog->show(); - nMsgDialog->activateWindow(); - - /* window will destroy itself! */ - } - else - { - QMessageBox::information(this, tr("RetroShare"),tr("You cant reply to an Anonymous Author")); - } -} - -void ForumsV2Dialog::changedViewBox() -{ - if (m_bProcessSettings) { - return; - } - - // save index - Settings->setValueToGroup("ForumsV2Dialog", "viewBox", ui.viewBox->currentIndex()); - - insertThreads(); -} - -void ForumsV2Dialog::filterColumnChanged() -{ - if (m_bProcessSettings) { - return; - } - - int filterColumn = FilterColumnFromComboBox(ui.filterColumnComboBox->currentIndex()); - if (filterColumn == COLUMN_THREAD_CONTENT) { - // need content ... refill - insertThreads(); - } else { - filterItems(ui.filterLineEdit->text()); - } - - // save index - Settings->setValueToGroup("ForumsV2Dialog", "filterColumn", filterColumn); -} - -void ForumsV2Dialog::filterItems(const QString& text) -{ - int filterColumn = FilterColumnFromComboBox(ui.filterColumnComboBox->currentIndex()); - - int nCount = ui.threadTreeWidget->topLevelItemCount (); - for (int nIndex = 0; nIndex < nCount; nIndex++) { - filterItem(ui.threadTreeWidget->topLevelItem(nIndex), text, filterColumn); - } -} - -void ForumsV2Dialog::shareKey() -{ - ShareKey shareUi(this, 0, mCurrForumId, FORUM_KEY_SHARE); - shareUi.exec(); -} - -bool ForumsV2Dialog::filterItem(QTreeWidgetItem *pItem, const QString &text, int filterColumn) -{ - bool bVisible = true; - - if (text.isEmpty() == false) { - if (pItem->text(filterColumn).contains(text, Qt::CaseInsensitive) == false) { - bVisible = false; - } - } - - int nVisibleChildCount = 0; - int nCount = pItem->childCount(); - for (int nIndex = 0; nIndex < nCount; nIndex++) { - if (filterItem(pItem->child(nIndex), text, filterColumn)) { - nVisibleChildCount++; - } - } - - if (bVisible || nVisibleChildCount) { - pItem->setHidden(false); - } else { - pItem->setHidden(true); - } - - return (bVisible || nVisibleChildCount); -} - -void ForumsV2Dialog::updateMessageSummaryList(std::string forumId) -{ - QTreeWidgetItem *items[2] = { yourForums, subscribedForums }; - - for (int item = 0; item < 2; item++) { - int child; - int childCount = items[item]->childCount(); - for (child = 0; child < childCount; child++) { - QTreeWidgetItem *childItem = items[item]->child(child); - std::string childId = ui.forumTreeWidget->itemId(childItem).toStdString(); - if (childId.empty()) { - continue; - } - - if (forumId.empty() || childId == forumId) { - /* calculate unread messages */ - unsigned int newMessageCount = 0; - unsigned int unreadMessageCount = 0; - //rsForumsV2->getMessageCount(childId, newMessageCount, unreadMessageCount); - std::cerr << "IMPLEMENT rsForumsV2->getMessageCount()"; - std::cerr << std::endl; - - ui.forumTreeWidget->setUnreadCount(childItem, unreadMessageCount); - - if (forumId.empty() == false) { - /* Calculate only this forum */ - break; - } - } - } - } -} - -bool ForumsV2Dialog::navigate(const std::string& forumId, const std::string& msgId) -{ - if (forumId.empty()) { - return false; - } - - if (ui.forumTreeWidget->activateId(QString::fromStdString(forumId), msgId.empty()) == NULL) { - return false; - } - - /* Threads are filled in changedForum */ - if (mCurrForumId != forumId) { - return false; - } - - if (msgId.empty()) { - return true; - } - - if (mThreadLoading) { - mThreadLoad.FocusMsgId = msgId; - return true; - } - - /* Search exisiting item */ - QTreeWidgetItemIterator itemIterator(ui.threadTreeWidget); - QTreeWidgetItem *item = NULL; - while ((item = *itemIterator) != NULL) { - itemIterator++; - - if (item->data(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID).toString().toStdString() == msgId) { - ui.threadTreeWidget->setCurrentItem(item); - ui.threadTreeWidget->setFocus(); - return true; - } - } - - return false; -} - -void ForumsV2Dialog::generateMassData() -{ -#ifdef DEBUG_FORUMS - if (mCurrForumId.empty ()) { - return; - } - - if (QMessageBox::question(this, "Generate mass data", "Do you really want to generate mass data ?", QMessageBox::Yes|QMessageBox::No, QMessageBox::No) == QMessageBox::No) { - return; - } - - for (int thread = 1; thread < 1000; thread++) { - ForumMsgInfo threadInfo; - threadInfo.forumId = mCurrForumId; - threadInfo.title = QString("Test %1").arg(thread, 3, 10, QChar('0')).toStdWString(); - threadInfo.msg = QString("That is only a test").toStdWString(); - - if (rsForumsV2->ForumMessageSend(threadInfo) == false) { - return; - } - - for (int msg = 1; msg < 3; msg++) { - ForumMsgInfo msgInfo; - msgInfo.forumId = mCurrForumId; - msgInfo.threadId = threadInfo.msgId; - msgInfo.parentId = threadInfo.msgId; - msgInfo.title = threadInfo.title; - msgInfo.msg = threadInfo.msg; - - if (rsForumsV2->ForumMessageSend(msgInfo) == false) { - return; - } - } - } -#endif -} - - - -/*********************** **** **** **** ***********************/ -/** Request / Response of Data ********************************/ -/*********************** **** **** **** ***********************/ - -#define FORUMSV2DIALOG_LISTING 1 -#define FORUMSV2DIALOG_CURRENTFORUM 2 -#define FORUMSV2DIALOG_INSERTTHREADS 3 -#define FORUMSV2DIALOG_INSERTCHILD 4 -#define FORUMV2DIALOG_INSERT_POST 5 -#define FORUMV2DIALOG_REPLY_MESSAGE 6 - - -void ForumsV2Dialog::insertForums() -{ - requestGroupSummary(); -} - -void ForumsV2Dialog::requestGroupSummary() -{ - std::cerr << "ForumsV2Dialog::requestGroupSummary()"; - std::cerr << std::endl; - - std::list ids; - RsTokReqOptions opts; - uint32_t token; - mForumQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, ids, FORUMSV2DIALOG_LISTING); -} - -void ForumsV2Dialog::loadGroupSummary(const uint32_t &token) -{ - std::cerr << "ForumsV2Dialog::loadGroupSummary()"; - std::cerr << std::endl; - - std::list groupInfo; - rsForumsV2->getGroupSummary(token, groupInfo); - - if (groupInfo.size() > 0) - { - insertForumsData(groupInfo); - } - else - { - std::cerr << "ForumsV2Dialog::loadGroupSummary() ERROR No Groups..."; - std::cerr << std::endl; - } -} - -/*********************** **** **** **** ***********************/ -/*********************** **** **** **** ***********************/ - - - -void ForumsV2Dialog::requestGroupSummary_CurrentForum(const std::string &forumId) -{ - RsTokReqOptions opts; - - std::list grpIds; - grpIds.push_back(forumId); - - std::cerr << "ForumsV2Dialog::requestGroupSummary_CurrentForum(" << forumId << ")"; - std::cerr << std::endl; - - uint32_t token; - mForumQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, grpIds, FORUMSV2DIALOG_CURRENTFORUM); -} - -void ForumsV2Dialog::loadGroupSummary_CurrentForum(const uint32_t &token) -{ - std::cerr << "ForumsV2Dialog::loadGroupSummary_CurrentForum()"; - std::cerr << std::endl; - - std::list groupInfo; - rsForumsV2->getGroupSummary(token, groupInfo); - - if (groupInfo.size() == 1) - { - RsGroupMetaData fi = groupInfo.front(); - insertForumThreads(fi); - } - else - { - std::cerr << "ForumsV2Dialog::loadGroupSummary_CurrentForum() ERROR Invalid Number of Groups..."; - std::cerr << std::endl; - } -} - -/*********************** **** **** **** ***********************/ -/*********************** **** **** **** ***********************/ -/*********************** **** **** **** ***********************/ -/*********************** **** **** **** ***********************/ - - - -void ForumsV2Dialog::loadCurrentForumThreads(const std::string &forumId) -{ - - std::cerr << "ForumsV2Dialog::loadCurrentForumThreads(" << forumId << ")"; - std::cerr << std::endl; - - /* if already active -> kill current loading */ - if (mThreadLoading) - { - /* Cleanup */ - std::cerr << "ForumsV2Dialog::loadCurrentForumThreads() Cleanup old Threads"; - std::cerr << std::endl; - - /* Wipe Widget Tree */ - mThreadLoad.Items.clear(); - - /* Stop all active requests */ - std::map::iterator it; - for(it = mThreadLoad.MsgTokens.begin(); it != mThreadLoad.MsgTokens.end(); it++) - { - std::cerr << "ForumsV2Dialog::loadCurrentForumThreads() Canceling Request: " << it->first; - std::cerr << std::endl; - - mForumQueue->cancelRequest(it->first); - } - - mThreadLoad.MsgTokens.clear(); - mThreadLoad.ItemToExpand.clear(); - } - - /* initiate loading */ - std::cerr << "ForumsV2Dialog::loadCurrentForumThreads() Initiating Loading"; - std::cerr << std::endl; - - mThreadLoading = true; - - mThreadLoad.ForumId = mCurrForumId; - mThreadLoad.FilterColumn = FilterColumnFromComboBox(ui.filterColumnComboBox->currentIndex()); - mThreadLoad.ViewType = ui.viewBox->currentIndex(); - mThreadLoad.FillComplete = false; - - if (lastViewType != mThreadLoad.ViewType || lastForumID != mCurrForumId) { - mThreadLoad.FillComplete = true; - } - - mThreadLoad.FlatView = false; - mThreadLoad.UseChildTS = false; - mThreadLoad.ExpandNewMessages = Settings->getExpandNewMessages(); - mThreadLoad.SubscribeFlags = subscribeFlags; - - if (mThreadLoad.ViewType == VIEW_FLAT) { - ui.threadTreeWidget->setRootIsDecorated(false); - } else { - ui.threadTreeWidget->setRootIsDecorated(true); - } - - switch(mThreadLoad.ViewType) - { - case VIEW_LAST_POST: - mThreadLoad.UseChildTS = true; - break; - case VIEW_FLAT: - mThreadLoad.FlatView = true; - break; - case VIEW_THREADED: - break; - } - - requestGroupThreadData_InsertThreads(forumId); -} - - - -void ForumsV2Dialog::requestGroupThreadData_InsertThreads(const std::string &forumId) -{ - RsTokReqOptions opts; - - opts.mOptions = RS_TOKREQOPT_MSG_THREAD | RS_TOKREQOPT_MSG_LATEST; - - std::list grpIds; - grpIds.push_back(forumId); - - std::cerr << "ForumsV2Dialog::requestGroupThreadData_InsertThreads(" << forumId << ")"; - std::cerr << std::endl; - - uint32_t token; - mForumQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, grpIds, FORUMSV2DIALOG_INSERTTHREADS); -} - - -void ForumsV2Dialog::loadGroupThreadData_InsertThreads(const uint32_t &token) -{ - std::cerr << "ForumsV2Dialog::loadGroupThreadData_InsertThreads()"; - std::cerr << std::endl; - - bool moreData = true; - bool someData = false; - while(moreData) - { - RsForumV2Msg msg; - if (rsForumsV2->getMsgData(token, msg)) - { - std::cerr << "ForumsV2Dialog::loadGroupThreadData_InsertThreads() MsgId: " << msg.mMeta.mMsgId; - std::cerr << std::endl; - - loadForumBaseThread(msg); - someData = true; - } - else - { - moreData = false; - } - } - - /* completed with no data */ - if (!someData) - { - fillThreadFinished(); - } -} - -bool ForumsV2Dialog::convertMsgToThreadWidget(const RsForumV2Msg &msgInfo, std::string authorName, - bool useChildTS, uint32_t filterColumn, QTreeWidgetItem *item) -{ - QString text; - - { - QDateTime qtime; - if (useChildTS) - qtime.setTime_t(msgInfo.mMeta.mChildTs); - else - qtime.setTime_t(msgInfo.mMeta.mPublishTs); - - text = qtime.toString("yyyy-MM-dd hh:mm:ss"); - if (useChildTS) - { - QDateTime qtime2; - qtime2.setTime_t(msgInfo.mMeta.mPublishTs); - QString timestamp2 = qtime2.toString("yyyy-MM-dd hh:mm:ss"); - text += " / "; - text += timestamp2; - } - item->setText(COLUMN_THREAD_DATE, text); - } - - item->setText(COLUMN_THREAD_TITLE, ForumsV2Dialog::titleFromInfo(msgInfo.mMeta)); - - text = QString::fromUtf8(authorName.c_str()); - - if (text.isEmpty()) - { - item->setText(COLUMN_THREAD_AUTHOR, tr("Anonymous")); - } - else - { - item->setText(COLUMN_THREAD_AUTHOR, text); - } - - if (msgInfo.mMeta.mMsgFlags & RS_DISTRIB_AUTHEN_REQ) - { - item->setText(COLUMN_THREAD_SIGNED, tr("signed")); - item->setIcon(COLUMN_THREAD_SIGNED, QIcon(":/images/mail-signed.png")); - } - else - { - item->setText(COLUMN_THREAD_SIGNED, tr("none")); - item->setIcon(COLUMN_THREAD_SIGNED, QIcon(":/images/mail-signature-unknown.png")); - } - - if (filterColumn == COLUMN_THREAD_CONTENT) { - // need content for filter - QTextDocument doc; - doc.setHtml(QString::fromUtf8(msgInfo.mMsg.c_str())); - item->setText(COLUMN_THREAD_CONTENT, doc.toPlainText().replace(QString("\n"), QString(" "))); - } - - item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID, QString::fromStdString(msgInfo.mMeta.mMsgId)); - -#if 0 - if (IS_GROUP_SUBSCRIBED(subscribeFlags) && !(msginfo.mMsgFlags & RS_DISTRIB_MISSING_MSG)) { - rsForumsV2->getMessageStatus(msginfo.forumId, msginfo.msgId, status); - } else { - // show message as read - status = RSGXS_MSG_STATUS_READ; - } -#endif - item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS, msgInfo.mMeta.mMsgStatus); - - item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_MISSING, (msgInfo.mMeta.mMsgFlags & RS_DISTRIB_MISSING_MSG) ? true : false); - - return true; -} - - -void ForumsV2Dialog::loadForumBaseThread(const RsForumV2Msg &msg) -{ - std::string authorName = rsPeers->getPeerName(msg.mMeta.mAuthorId); - - QTreeWidgetItem *item = new QTreeWidgetItem(); // no Parent. - - convertMsgToThreadWidget(msg, authorName, mThreadLoad.UseChildTS, mThreadLoad.FilterColumn, item); - - /* request Children Data */ - uint32_t token; - requestChildData_InsertThreads(token, msg.mMeta.mMsgId); - - /* store pair of (token, item) */ - mThreadLoad.MsgTokens[token] = item; - - /* add item to final tree */ - mThreadLoad.Items.append(item); -} - - - -/*********************** **** **** **** ***********************/ - -void ForumsV2Dialog::requestChildData_InsertThreads(uint32_t &token, const std::string &parentId) -{ - RsTokReqOptions opts; - - opts.mOptions = RS_TOKREQOPT_MSG_PARENT | RS_TOKREQOPT_MSG_LATEST; - - std::list msgIds; - msgIds.push_back(parentId); - - std::cerr << "ForumsV2Dialog::requestChildData_InsertThreads(" << parentId << ")"; - std::cerr << std::endl; - - //mForumQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, FORUMSV2DIALOG_INSERTCHILD); -} - - -void ForumsV2Dialog::loadChildData_InsertThreads(const uint32_t &token) -{ - std::cerr << "ForumsV2Dialog::loadChildData_InsertThreads()"; - std::cerr << std::endl; - - /* find the matching *item */ - std::map::iterator it; - it = mThreadLoad.MsgTokens.find(token); - if (it == mThreadLoad.MsgTokens.end()) - { - std::cerr << "ForumsV2Dialog::loadGroupThreadData_InsertThreads() ERROR Missing Token->Parent in Map"; - std::cerr << std::endl; - /* finished with this one */ - return; - } - - QTreeWidgetItem *parent = it->second; - // cleanup map. - mThreadLoad.MsgTokens.erase(it); - - std::cerr << "ForumsV2Dialog::loadGroupThreadData_InsertThreads()"; - std::cerr << std::endl; - - bool moreData = true; - while(moreData) - { - RsForumV2Msg msg; - if (rsForumsV2->getMsgData(token, msg)) - { - std::cerr << "ForumsV2Dialog::loadGroupThreadData_InsertThreads() MsgId: " << msg.mMeta.mMsgId; - std::cerr << std::endl; - - loadForumChildMsg(msg, parent); - } - else - { - moreData = false; - } - } - - - /* check for completion */ - if (mThreadLoad.MsgTokens.size() == 0) - { - /* finished */ - /* push data into GUI */ - fillThreadFinished(); - } -} - -void ForumsV2Dialog::loadForumChildMsg(const RsForumV2Msg &msg, QTreeWidgetItem *parent) -{ - std::string authorName = rsPeers->getPeerName(msg.mMeta.mAuthorId); - - QTreeWidgetItem *child = NULL; - - if (mThreadLoad.FlatView) - { - child = new QTreeWidgetItem(); // no Parent. - } - else - { - child = new QTreeWidgetItem(parent); - } - - - convertMsgToThreadWidget(msg, authorName, mThreadLoad.UseChildTS, mThreadLoad.FilterColumn, child); - - /* request Children Data */ - uint32_t token; - requestChildData_InsertThreads(token, msg.mMeta.mMsgId); - - /* store pair of (token, item) */ - mThreadLoad.MsgTokens[token] = child; - - // Leave this here... BUT IT WILL NEED TO BE FIXED. - if (mThreadLoad.FillComplete && mThreadLoad.ExpandNewMessages && IS_MSG_UNREAD(msg.mMeta.mMsgStatus)) - { - QTreeWidgetItem *pParent = child; - while ((pParent = pParent->parent()) != NULL) - { - if (std::find(mThreadLoad.ItemToExpand.begin(), mThreadLoad.ItemToExpand.end(), pParent) == mThreadLoad.ItemToExpand.end()) - { - mThreadLoad.ItemToExpand.push_back(pParent); - } - } - } - - if (mThreadLoad.FlatView) - { - /* add item to final tree */ - mThreadLoad.Items.append(child); - } -} - - - -/*********************** **** **** **** ***********************/ -/*********************** **** **** **** ***********************/ - -void ForumsV2Dialog::requestMsgData_InsertPost(const std::string &msgId) -{ - RsTokReqOptions opts; - - std::list msgIds; - msgIds.push_back(msgId); - - std::cerr << "ForumsV2Dialog::requestMsgData_InsertPost(" << msgId << ")"; - std::cerr << std::endl; - - - uint32_t token; - //mForumQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, FORUMV2DIALOG_INSERT_POST); -} - - -void ForumsV2Dialog::loadMsgData_InsertPost(const uint32_t &token) -{ - std::cerr << "ForumsV2Dialog::loadMsgData_InsertPost()"; - std::cerr << std::endl; - - RsForumV2Msg msg; - if (rsForumsV2->getMsgData(token, msg)) - { - insertPostData(msg); - } - else - { - std::cerr << "ForumsV2Dialog::loadMsgData_InsertPost() ERROR Missing Message Data..."; - std::cerr << std::endl; - } -} - - -/*********************** **** **** **** ***********************/ -/*********************** **** **** **** ***********************/ - -void ForumsV2Dialog::requestMsgData_ReplyMessage(const std::string &msgId) -{ - RsTokReqOptions opts; - - std::list msgIds; - msgIds.push_back(msgId); - - std::cerr << "ForumsV2Dialog::requestMsgData_ReplyMessage(" << msgId << ")"; - std::cerr << std::endl; - - uint32_t token; - mForumQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, FORUMV2DIALOG_REPLY_MESSAGE); -} - - -void ForumsV2Dialog::loadMsgData_ReplyMessage(const uint32_t &token) -{ - std::cerr << "ForumsV2Dialog::loadMsgData_ReplyMessage()"; - std::cerr << std::endl; - - RsForumV2Msg msg; - if (rsForumsV2->getMsgData(token, msg)) - { - replyMessageData(msg); - } - else - { - std::cerr << "ForumsV2Dialog::loadMsgData_ReplyMessage() ERROR Missing Message Data..."; - std::cerr << std::endl; - } -} - - -/*********************** **** **** **** ***********************/ -/*********************** **** **** **** ***********************/ - - - -/*********************** **** **** **** ***********************/ -/*********************** **** **** **** ***********************/ -/*********************** **** **** **** ***********************/ -/*********************** **** **** **** ***********************/ - -void ForumsV2Dialog::loadRequest(const TokenQueue *queue, const TokenRequest &req) -{ - std::cerr << "ForumsV2Dialog::loadRequest() UserType: " << req.mUserType; - std::cerr << std::endl; - - if (queue == mForumQueue) - { - /* now switch on req */ - switch(req.mUserType) - { - case FORUMSV2DIALOG_LISTING: - loadGroupSummary(req.mToken); - break; - - case FORUMSV2DIALOG_CURRENTFORUM: - loadGroupSummary_CurrentForum(req.mToken); - break; - - case FORUMSV2DIALOG_INSERTTHREADS: - loadGroupThreadData_InsertThreads(req.mToken); - break; - - case FORUMSV2DIALOG_INSERTCHILD: - loadChildData_InsertThreads(req.mToken); - break; - - case FORUMV2DIALOG_INSERT_POST: - loadMsgData_InsertPost(req.mToken); - break; - - case FORUMV2DIALOG_REPLY_MESSAGE: - loadMsgData_ReplyMessage(req.mToken); - break; - - default: - std::cerr << "ForumsV2Dialog::loadRequest() ERROR: INVALID TYPE"; - std::cerr << std::endl; - break; - } - } -} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/retroshare-gui/src/gui/ForumsV2Dialog.h b/retroshare-gui/src/gui/ForumsV2Dialog.h deleted file mode 100644 index 39c831d57..000000000 --- a/retroshare-gui/src/gui/ForumsV2Dialog.h +++ /dev/null @@ -1,271 +0,0 @@ -/**************************************************************** - * RetroShare is distributed under the following license: - * - * Copyright (C) 2008 Robert Fernie - * - * 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 _FORUMSV2DIALOG_H -#define _FORUMSV2DIALOG_H - -#include - -#include "mainpage.h" -#include "RsAutoUpdatePage.h" -#include "ui_ForumsV2Dialog.h" - -#include - -#include "util/TokenQueue.h" - -#include - -class ForumInfo; - - -/* These are all the parameters that are required for thread loading. - * They are kept static for the load duration. - */ - -class ForumsV2ThreadLoadParameters -{ - public: - - std::string ForumId; - std::string FocusMsgId; - - uint32_t SubscribeFlags; - int ViewType; - uint32_t FilterColumn; - - std::map MsgTokens; - QList Items; - QList ItemToExpand; - - bool FillComplete; - bool FlatView; - bool UseChildTS; - bool ExpandNewMessages; -}; - - - - - - -class ForumsV2Dialog : public RsAutoUpdatePage, public TokenResponse -{ - Q_OBJECT - -public: - ForumsV2Dialog(QWidget *parent = 0); - ~ForumsV2Dialog(); - - bool navigate(const std::string& forumId, const std::string& msgId); - - /* overloaded from RsAuthUpdatePage */ - virtual void updateDisplay(); - - // Callback for all Loads. -virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req); - -protected: - bool eventFilter(QObject *obj, QEvent *ev); - -private slots: - /** Create the context popup menu and it's submenus */ - void forumListCustomPopupMenu( QPoint point ); - void threadListCustomPopupMenu( QPoint point ); - void restoreForumKeys(); - void newforum(); - - void changedForum(const QString &id); - void changedThread(); - void clickedThread (QTreeWidgetItem *item, int column); - - void replytomessage(); - void replyMessageData(const RsForumV2Msg &msg); - - //void print(); - //void printpreview(); - - //void removemessage(); - void markMsgAsRead(); - void markMsgAsReadChildren(); - void markMsgAsReadAll(); - void markMsgAsUnread(); - void markMsgAsUnreadAll(); - void markMsgAsUnreadChildren(); - void copyForumLink(); - void copyMessageLink(); - - /* handle splitter */ - void togglethreadview(); - - void createthread(); - void createmessage(); - - void subscribeToForum(); - void unsubscribeToForum(); - - void showForumDetails(); - void editForumDetails(); - - void previousMessage (); - void nextMessage (); - void nextUnreadMessage(); - void downloadAllFiles(); - - void changedViewBox(); - - void filterColumnChanged(); - //void filterRegExpChanged(); - ///void clearFilter(); - - void generateMassData(); - - void fillThreadFinished(); - void fillThreadProgress(int current, int count); - - void shareKey(); - -private: - void insertForums(); - void insertThreads(); - void insertPost(); - void insertPostData(const RsForumV2Msg &msg); // Second Half. - - // Utility Fns. - QString titleFromInfo(const RsMsgMetaData &meta); - QString messageFromInfo(const RsForumV2Msg &msg); - - void forumMsgReadStatusChanged(const QString &forumId, const QString &msgId, int status); - - void updateMessageSummaryList(std::string forumId); - //void forumInfoToGroupItemInfo(const ForumInfo &forumInfo, GroupItemInfo &groupItemInfo); - void forumInfoToGroupItemInfo(const RsGroupMetaData &forumInfo, GroupItemInfo &groupItemInfo); - - void forumSubscribe(bool subscribe); - void FillThreads(QList &ThreadList, bool bExpandNewMessages, QList &itemToExpand); - void FillChildren(QTreeWidgetItem *Parent, QTreeWidgetItem *NewParent, bool bExpandNewMessages, QList &itemToExpand); - - int getSelectedMsgCount(QList *pRows, QList *pRowsRead, QList *pRowsUnread); - void setMsgAsReadUnread(QList &Rows, bool bRead); - void markMsgAsReadUnread(bool bRead, bool bChildren, bool bForum); - void CalculateIconsAndFonts(QTreeWidgetItem *pItem = NULL); - void CalculateIconsAndFonts(QTreeWidgetItem *pItem, bool &bHasReadChilddren, bool &bHasUnreadChilddren); - - void processSettings(bool bLoad); - void togglethreadview_internal(); - - void filterItems(const QString& text); - bool filterItem(QTreeWidgetItem *pItem, const QString &text, int filterColumn); - - // New Request/Response Loading Functions. - void insertForumsData(const std::list &forumList); - void insertForumThreads(const RsGroupMetaData &fi); - - void requestGroupSummary(); - void loadGroupSummary(const uint32_t &token); - - void requestGroupSummary_CurrentForum(const std::string &forumId); - void loadGroupSummary_CurrentForum(const uint32_t &token); - - void loadCurrentForumThreads(const std::string &forumId); - void requestGroupThreadData_InsertThreads(const std::string &forumId); - void loadGroupThreadData_InsertThreads(const uint32_t &token); - void loadForumBaseThread(const RsForumV2Msg &msg); - - void requestChildData_InsertThreads(uint32_t &token, const std::string &parentId); - void loadChildData_InsertThreads(const uint32_t &token); - void loadForumChildMsg(const RsForumV2Msg &msg, QTreeWidgetItem *parent); - - void requestMsgData_InsertPost(const std::string &msgId); - void loadMsgData_InsertPost(const uint32_t &token); - void requestMsgData_ReplyMessage(const std::string &msgId); - void loadMsgData_ReplyMessage(const uint32_t &token); - - bool convertMsgToThreadWidget(const RsForumV2Msg &msgInfo, std::string authorName, - bool useChildTS, uint32_t filterColumn, QTreeWidgetItem *item); - - TokenQueue *mForumQueue; - - - bool m_bProcessSettings; - - QTreeWidgetItem *yourForums; - QTreeWidgetItem *subscribedForums; - QTreeWidgetItem *popularForums; - QTreeWidgetItem *otherForums; - - std::string mCurrForumId; - std::string mCurrThreadId; - int subscribeFlags; - - QFont m_ForumNameFont; - int lastViewType; - std::string lastForumID; - - bool inMsgAsReadUnread; - //ForumsV2FillThread *fillThread; - - // New Datatypes to replace the FillThread. - bool mThreadLoading; - ForumsV2ThreadLoadParameters mThreadLoad; - - - /** Qt Designer generated object */ - Ui::ForumsV2Dialog ui; -}; - -#if 0 -class ForumsV2FillThread : public QThread -{ - Q_OBJECT - -public: - ForumsV2FillThread(ForumsV2Dialog *parent); - ~ForumsV2FillThread(); - - void run(); - void stop(); - bool wasStopped() { return stopped; } - -signals: - void progress(int current, int count); - -public: - std::string forumId; - int filterColumn; - int subscribeFlags; - bool fillComplete; - int viewType; - bool expandNewMessages; - std::string focusMsgId; - - QList Items; - QList ItemToExpand; - -private: - volatile bool stopped; -}; - -#endif - - -#endif - diff --git a/retroshare-gui/src/gui/ForumsV2Dialog.ui b/retroshare-gui/src/gui/ForumsV2Dialog.ui deleted file mode 100644 index 988837ac8..000000000 --- a/retroshare-gui/src/gui/ForumsV2Dialog.ui +++ /dev/null @@ -1,1251 +0,0 @@ - - - ForumsV2Dialog - - - - 0 - 0 - 732 - 420 - - - - - 0 - 2 - - - - - 60 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - 208 - 208 - 208 - - - - - - - 255 - 255 - 255 - - - - - - - 247 - 247 - 247 - - - - - - - 104 - 104 - 104 - - - - - - - 139 - 139 - 139 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 240 - 240 - 240 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 128 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 255 - - - - - - - 255 - 0 - 255 - - - - - - - 231 - 231 - 231 - - - - - - - - - 0 - 0 - 0 - - - - - - - 208 - 208 - 208 - - - - - - - 255 - 255 - 255 - - - - - - - 247 - 247 - 247 - - - - - - - 104 - 104 - 104 - - - - - - - 139 - 139 - 139 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 240 - 240 - 240 - - - - - - - 0 - 0 - 0 - - - - - - - 192 - 192 - 192 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 255 - - - - - - - 255 - 0 - 255 - - - - - - - 231 - 231 - 231 - - - - - - - - - 104 - 104 - 104 - - - - - - - 208 - 208 - 208 - - - - - - - 255 - 255 - 255 - - - - - - - 247 - 247 - 247 - - - - - - - 104 - 104 - 104 - - - - - - - 139 - 139 - 139 - - - - - - - 104 - 104 - 104 - - - - - - - 255 - 255 - 255 - - - - - - - 104 - 104 - 104 - - - - - - - 240 - 240 - 240 - - - - - - - 240 - 240 - 240 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 128 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 255 - - - - - - - 255 - 0 - 255 - - - - - - - 231 - 231 - 231 - - - - - - - - - Arial - 8 - 50 - false - false - false - false - - - - Qt::DefaultContextMenu - - - - 9 - - - 9 - - - - - Qt::Horizontal - - - - - 300 - 300 - - - - QFrame#frame{border: none;} - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - - - QFrame#chheaderframe{ -background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, - stop:0 #FEFEFE, stop:1 #E8E8E8); - -border: 1px solid #CCCCCC;} - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 2 - - - - - 0 - - - - - - 24 - 24 - - - - - - - :/images/konversation.png - - - true - - - - - - - - Arial - 10 - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:10pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-weight:600;">Forums</span></p></body></html> - - - - - - - - - Qt::Horizontal - - - - 123 - 13 - - - - - - - - Qt::NoFocus - - - Display - - - QPushButton::menu-indicator { - subcontrol-origin: padding; - subcontrol-position: bottom right; - } - - QPushButton::menu-indicator:pressed, QPushButton::menu-indicator:open { - position: relative; - top: 2px; left: 2px; /* shift the arrow by 2 px */ - } - - QPushButton:hover { - border: 1px solid #CCCCCC; - } - - - - :/images/looknfeel.png:/images/looknfeel.png - - - true - - - - - - - Qt::NoFocus - - - Create Forum - - - - :/images/new_forum16.png:/images/new_forum16.png - - - true - - - - - - - - - - - 0 - 0 - - - - - 9 - - - - - -1 - -1 - - - - - - - - - Qt::Vertical - - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - 10 - 75 - true - - - - Forum: - - - - - - - - 2 - 0 - - - - - 0 - 0 - - - - - 16777215 - 1677215 - - - - -border: 2px solid #CCCCCC; -border-radius:6px; -background: white; - - - - - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - - Last Post - - - - - Threaded View - - - - - Flat View - - - - - - - - - - - 9 - - - - Qt::CustomContextMenu - - - true - - - true - - - - Title - - - - - - - - - :/images/message-state-header.png:/images/message-state-header.png - - - - - Date - - - - - Author - - - - - Signed - - - - - - - - - - - 0 - 0 - - - - - 10 - 75 - true - - - - Thread: - - - - - - - QLabel#threadTitle{ -border: 2px solid #CCCCCC; -border-radius: 6px; -background: white;} - - - true - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - false - - - - 0 - 0 - - - - - 24 - 24 - - - - - 24 - 24 - - - - Qt::NoFocus - - - Previous Thread - - - - - - - :/images/back.png:/images/back.png - - - - - - - false - - - - 0 - 0 - - - - - 24 - 24 - - - - - 24 - 24 - - - - Qt::NoFocus - - - Next Thread - - - - - - - :/images/forward.png:/images/forward.png - - - - - - - - 24 - 24 - - - - Qt::NoFocus - - - - - - - :/images/edit_remove24.png:/images/edit_remove24.png - - - true - - - true - - - - - - - - 24 - 24 - - - - Qt::NoFocus - - - Download all files - - - - :/images/down.png:/images/down.png - - - - - - - - 0 - 0 - - - - Next unread - - - - - - - - - - 0 - 32 - - - - QFrame#frame_2{ -background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, - stop:0 #FEFEFE, stop:1 #E8E8E8); - -border: 1px solid #CCCCCC;} - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 2 - - - - - 2 - - - - - - - - :/images/find-16.png - - - - - - - Search forums - - - - - - - - - - 0 - 0 - - - - - MS Shell Dlg 2 - - - - 1 - - - - Date - - - - - Title - - - - - Author - - - - - Content - - - - - - - - - 24 - 24 - - - - Qt::NoFocus - - - Reply Message - - - - :/images/mail_reply.png:/images/mail_reply.png - - - true - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 40 - 20 - - - - - - - - - 24 - 24 - - - - Qt::NoFocus - - - Start new Thread for Selected Forum - - - - :/images/mail_new.png:/images/mail_new.png - - - true - - - - - - - - - - - - - 10 - 75 - true - - - - Loading - - - - - - - - 16777215 - 25 - - - - 1000 - - - 0 - - - - - - - - - - - 0 - 10 - - - - - 9 - - - - - - - - - - Print - - - - - PrintPreview - - - - - - GroupTreeWidget - QWidget -
gui/common/GroupTreeWidget.h
- 1 -
- - LineEditClear - QLineEdit -
gui/common/LineEditClear.h
-
- - LinkTextBrowser - QTextBrowser -
gui/common/LinkTextBrowser.h
-
-
- - - - -
diff --git a/retroshare-gui/src/gui/GxsForumsDialog.cpp b/retroshare-gui/src/gui/GxsForumsDialog.cpp index a0abfb71b..19d1aff46 100644 --- a/retroshare-gui/src/gui/GxsForumsDialog.cpp +++ b/retroshare-gui/src/gui/GxsForumsDialog.cpp @@ -27,9 +27,7 @@ #include #include "GxsForumsDialog.h" - #include "gxs/GxsForumGroupDialog.h" - #include "gxsforums/CreateGxsForumMsg.h" #include "msgs/MessageComposer.h" @@ -37,10 +35,12 @@ #include "common/Emoticons.h" #include "common/RSItemDelegate.h" #include "common/PopularityDefs.h" +#include "common/RSTreeWidgetItem.h" #include "RetroShareLink.h" #include "channels/ShareKey.h" #include "notifyqt.h" #include "util/HandleRichText.h" +//#AFTER MERGE #include "util/DateTime.h" #include #include @@ -93,43 +93,10 @@ // no need to copy, don't count in ROLE_THREAD_COUNT #define ROLE_THREAD_READCHILDREN Qt::UserRole + 3 #define ROLE_THREAD_UNREADCHILDREN Qt::UserRole + 4 +#define ROLE_THREAD_SORT Qt::UserRole + 5 #define ROLE_THREAD_COUNT 3 - -static int FilterColumnFromComboBox(int nIndex) -{ - switch (nIndex) { - case 0: - return COLUMN_THREAD_DATE; - case 1: - return COLUMN_THREAD_TITLE; - case 2: - return COLUMN_THREAD_AUTHOR; - case 3: - return COLUMN_THREAD_CONTENT; - } - - return COLUMN_THREAD_TITLE; -} - -static int FilterColumnToComboBox(int nIndex) -{ - switch (nIndex) { - case COLUMN_THREAD_DATE: - return 0; - case COLUMN_THREAD_TITLE: - return 1; - case COLUMN_THREAD_AUTHOR: - return 2; - case COLUMN_THREAD_CONTENT: - return 3; - } - - return FilterColumnToComboBox(COLUMN_THREAD_TITLE); -} - - /* * Transformation Notes: * there are still a couple of things that the new forums differ from Old version. @@ -145,103 +112,113 @@ static int FilterColumnToComboBox(int nIndex) GxsForumsDialog::GxsForumsDialog(QWidget *parent) : RsAutoUpdatePage(1000,parent) { - /* Invoke the Qt Designer generated object setup routine */ - ui.setupUi(this); + /* Invoke the Qt Designer generated object setup routine */ + ui.setupUi(this); - m_bProcessSettings = false; - subscribeFlags = 0; - inMsgAsReadUnread = false; + m_bProcessSettings = false; + subscribeFlags = 0; + inMsgAsReadUnread = false; + threadCompareRole = new RSTreeWidgetItemCompareRole; + threadCompareRole->setRole(COLUMN_THREAD_DATE, ROLE_THREAD_SORT); /* Setup Queue */ - mForumQueue = new TokenQueue(rsGxsForums->getTokenService(), this); + mForumQueue = new TokenQueue(rsGxsForums->getTokenService(), this); - - - connect( ui.forumTreeWidget, SIGNAL( treeCustomContextMenuRequested( QPoint ) ), this, SLOT( forumListCustomPopupMenu( QPoint ) ) ); - connect( ui.threadTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( threadListCustomPopupMenu( QPoint ) ) ); + connect( ui.forumTreeWidget, SIGNAL( treeCustomContextMenuRequested( QPoint ) ), this, SLOT( forumListCustomPopupMenu( QPoint ) ) ); + connect( ui.threadTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( threadListCustomPopupMenu( QPoint ) ) ); connect(ui.newForumButton, SIGNAL(clicked()), this, SLOT(newforum())); - connect(ui.newmessageButton, SIGNAL(clicked()), this, SLOT(createmessage())); - connect(ui.newthreadButton, SIGNAL(clicked()), this, SLOT(createthread())); + connect(ui.newmessageButton, SIGNAL(clicked()), this, SLOT(createmessage())); + connect(ui.newthreadButton, SIGNAL(clicked()), this, SLOT(createthread())); - connect( ui.forumTreeWidget, SIGNAL( treeCurrentItemChanged(QString) ), this, SLOT( changedForum(QString) ) ); + connect( ui.forumTreeWidget, SIGNAL( treeCurrentItemChanged(QString) ), this, SLOT( changedForum(QString) ) ); - connect( ui.threadTreeWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( changedThread () ) ); - connect( ui.threadTreeWidget, SIGNAL( itemClicked(QTreeWidgetItem*,int)), this, SLOT( clickedThread (QTreeWidgetItem*,int) ) ); - connect( ui.viewBox, SIGNAL( currentIndexChanged ( int ) ), this, SLOT( changedViewBox () ) ); + connect( ui.threadTreeWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( changedThread () ) ); + connect( ui.threadTreeWidget, SIGNAL( itemClicked(QTreeWidgetItem*,int)), this, SLOT( clickedThread (QTreeWidgetItem*,int) ) ); + connect( ui.viewBox, SIGNAL( currentIndexChanged ( int ) ), this, SLOT( changedViewBox () ) ); - connect(ui.expandButton, SIGNAL(clicked()), this, SLOT(togglethreadview())); - connect(ui.previousButton, SIGNAL(clicked()), this, SLOT(previousMessage())); - connect(ui.nextButton, SIGNAL(clicked()), this, SLOT(nextMessage())); + connect(ui.expandButton, SIGNAL(clicked()), this, SLOT(togglethreadview())); + connect(ui.previousButton, SIGNAL(clicked()), this, SLOT(previousMessage())); + connect(ui.nextButton, SIGNAL(clicked()), this, SLOT(nextMessage())); + connect(ui.nextUnreadButton, SIGNAL(clicked()), this, SLOT(nextUnreadMessage())); - // HACK - TEMPORARY HIJACKING THIS BUTTON FOR REFRESH. - //connect(ui.nextUnreadButton, SIGNAL(clicked()), this, SLOT(nextUnreadMessage())); - connect(ui.nextUnreadButton, SIGNAL(clicked()), this, SLOT(forceUpdateDisplay())); + // HACK - TEMPORARY HIJACKING THIS BUTTON FOR REFRESH. + //connect(ui.nextUnreadButton, SIGNAL(clicked()), this, SLOT(nextUnreadMessage())); + connect(ui.nextUnreadButton, SIGNAL(clicked()), this, SLOT(forceUpdateDisplay())); - connect(ui.downloadButton, SIGNAL(clicked()), this, SLOT(downloadAllFiles())); + connect(ui.downloadButton, SIGNAL(clicked()), this, SLOT(downloadAllFiles())); - connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString))); - connect(ui.filterColumnComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(filterColumnChanged())); + connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString))); + connect(ui.filterLineEdit, SIGNAL(filterChanged(int)), this, SLOT(filterColumnChanged(int))); - connect(NotifyQt::getInstance(), SIGNAL(forumMsgReadSatusChanged(QString,QString,int)), this, SLOT(forumMsgReadSatusChanged(QString,QString,int))); + connect(NotifyQt::getInstance(), SIGNAL(forumMsgReadSatusChanged(QString,QString,int)), this, SLOT(forumMsgReadSatusChanged(QString,QString,int))); - /* Set initial size the splitter */ - QList sizes; - sizes << 300 << width(); // Qt calculates the right sizes - //ui.splitter->setSizes(sizes); + /* Set initial size the splitter */ + QList sizes; + sizes << 300 << width(); // Qt calculates the right sizes + //ui.splitter->setSizes(sizes); - /* Set own item delegate */ - RSItemDelegate *itemDelegate = new RSItemDelegate(this); - itemDelegate->setSpacing(QSize(0, 2)); - ui.threadTreeWidget->setItemDelegate(itemDelegate); + /* Set own item delegate */ + RSItemDelegate *itemDelegate = new RSItemDelegate(this); + itemDelegate->setSpacing(QSize(0, 2)); + ui.threadTreeWidget->setItemDelegate(itemDelegate); - /* Set header resize modes and initial section sizes */ - QHeaderView * ttheader = ui.threadTreeWidget->header () ; - ttheader->setResizeMode (COLUMN_THREAD_TITLE, QHeaderView::Interactive); - ttheader->resizeSection (COLUMN_THREAD_DATE, 140); - ttheader->resizeSection (COLUMN_THREAD_TITLE, 290); + /* Set header resize modes and initial section sizes */ + QHeaderView * ttheader = ui.threadTreeWidget->header () ; + ttheader->setResizeMode (COLUMN_THREAD_TITLE, QHeaderView::Interactive); + ttheader->resizeSection (COLUMN_THREAD_DATE, 140); + ttheader->resizeSection (COLUMN_THREAD_TITLE, 290); - ui.threadTreeWidget->sortItems( COLUMN_THREAD_DATE, Qt::DescendingOrder ); + ui.threadTreeWidget->sortItems( COLUMN_THREAD_DATE, Qt::DescendingOrder ); - /* Set text of column "Read" to empty - without this the column has a number as header text */ - QTreeWidgetItem *headerItem = ui.threadTreeWidget->headerItem(); - headerItem->setText(COLUMN_THREAD_READ, ""); + /* Set text of column "Read" to empty - without this the column has a number as header text */ + QTreeWidgetItem *headerItem = ui.threadTreeWidget->headerItem(); + headerItem->setText(COLUMN_THREAD_READ, ""); - m_ForumNameFont = QFont("Times", 12, QFont::Bold); - ui.forumName->setFont(m_ForumNameFont); - ui.threadTitle->setFont(m_ForumNameFont); +//#AFTER MERGE setTextColorNotSubscribed(Qt::black); +//#AFTER MERGE setTextColorUnread(Qt::black); +//#AFTER MERGE setTextColorUnreadChildren(Qt::gray); +//#AFTER MERGE setTextColorRead(Qt::gray); +//#AFTER MERGE setTextColorMissing(Qt::darkRed); - /* Initialize group tree */ - ui.forumTreeWidget->initDisplayMenu(ui.displayButton); + /* Initialize group tree */ +//#AFTER MERGE ui.forumTreeWidget->initDisplayMenu(ui.displayButton); - /* create forum tree */ - yourForums = ui.forumTreeWidget->addCategoryItem(tr("Your Forums"), QIcon(IMAGE_FOLDER), true); - subscribedForums = ui.forumTreeWidget->addCategoryItem(tr("Subscribed Forums"), QIcon(IMAGE_FOLDERRED), true); - popularForums = ui.forumTreeWidget->addCategoryItem(tr("Popular Forums"), QIcon(IMAGE_FOLDERGREEN), false); - otherForums = ui.forumTreeWidget->addCategoryItem(tr("Other Forums"), QIcon(IMAGE_FOLDERYELLOW), false); + /* create forum tree */ + yourForums = ui.forumTreeWidget->addCategoryItem(tr("Your Forums"), QIcon(IMAGE_FOLDER), true); + subscribedForums = ui.forumTreeWidget->addCategoryItem(tr("Subscribed Forums"), QIcon(IMAGE_FOLDERRED), true); + popularForums = ui.forumTreeWidget->addCategoryItem(tr("Popular Forums"), QIcon(IMAGE_FOLDERGREEN), false); + otherForums = ui.forumTreeWidget->addCategoryItem(tr("Other Forums"), QIcon(IMAGE_FOLDERYELLOW), false); - lastViewType = -1; + lastViewType = -1; - // load settings - processSettings(true); + /* add filter actions */ +//#AFTER MERGE ui.filterLineEdit->addFilter(QIcon(), tr("Title"), COLUMN_THREAD_TITLE, tr("Search Title")); +//#AFTER MERGE ui.filterLineEdit->addFilter(QIcon(), tr("Date"), COLUMN_THREAD_DATE, tr("Search Date")); +//#AFTER MERGE ui.filterLineEdit->addFilter(QIcon(), tr("Author"), COLUMN_THREAD_AUTHOR, tr("Search Author")); +//#AFTER MERGE ui.filterLineEdit->addFilter(QIcon(), tr("Content"), COLUMN_THREAD_CONTENT, tr("Search Content")); +//#AFTER MERGE ui.filterLineEdit->setCurrentFilter(COLUMN_THREAD_TITLE); - /* Set header sizes for the fixed columns and resize modes, must be set after processSettings */ - ttheader->resizeSection (COLUMN_THREAD_READ, 24); - ttheader->setResizeMode (COLUMN_THREAD_READ, QHeaderView::Fixed); - ttheader->hideSection (COLUMN_THREAD_CONTENT); + // load settings + processSettings(true); - ui.progressBar->hide(); - ui.progLayOutTxt->hide(); - ui.progressBarLayOut->setEnabled(false); + /* Set header sizes for the fixed columns and resize modes, must be set after processSettings */ + ttheader->resizeSection (COLUMN_THREAD_READ, 24); + ttheader->setResizeMode (COLUMN_THREAD_READ, QHeaderView::Fixed); + ttheader->hideSection (COLUMN_THREAD_CONTENT); - mThreadLoading = false; + ui.progressBar->hide(); + ui.progLayOutTxt->hide(); + ui.progressBarLayOut->setEnabled(false); - insertThreads(); + mThreadLoading = false; - ui.threadTreeWidget->installEventFilter(this); + insertThreads(); - /* Hide platform specific features */ + ui.threadTreeWidget->installEventFilter(this); + +/* Hide platform specific features */ #ifdef Q_WS_WIN #endif @@ -249,218 +226,237 @@ GxsForumsDialog::GxsForumsDialog(QWidget *parent) GxsForumsDialog::~GxsForumsDialog() { - // save settings - processSettings(false); + delete(threadCompareRole); + + // save settings + processSettings(false); } +//#AFTER MERGE UserNotify *GxsForumsDialog::getUserNotify(QObject *parent) +//{ +// return new GxsForumUserNotify(parent); +//} + void GxsForumsDialog::processSettings(bool bLoad) { - m_bProcessSettings = true; + m_bProcessSettings = true; - QHeaderView *pHeader = ui.threadTreeWidget->header () ; + QHeaderView *pHeader = ui.threadTreeWidget->header () ; - Settings->beginGroup(QString("GxsForumsDialog")); + Settings->beginGroup(QString("GxsForumsDialog")); - if (bLoad) { - // load settings + if (bLoad) { + // load settings - // expandFiles - bool bValue = Settings->value("expandButton", true).toBool(); - ui.expandButton->setChecked(bValue); - togglethreadview_internal(); + // expandFiles + bool bValue = Settings->value("expandButton", true).toBool(); + ui.expandButton->setChecked(bValue); + togglethreadview_internal(); - // filterColumn - int nValue = FilterColumnToComboBox(Settings->value("filterColumn", COLUMN_THREAD_TITLE).toInt()); - ui.filterColumnComboBox->setCurrentIndex(nValue); + // filterColumn +//#AFTER MERGE ui.filterLineEdit->setCurrentFilter(Settings->value("filterColumn", COLUMN_THREAD_TITLE).toInt()); - // index of viewBox - ui.viewBox->setCurrentIndex(Settings->value("viewBox", VIEW_THREADED).toInt()); + // index of viewBox + ui.viewBox->setCurrentIndex(Settings->value("viewBox", VIEW_THREADED).toInt()); - // state of thread tree - pHeader->restoreState(Settings->value("ThreadTree").toByteArray()); + // state of thread tree + pHeader->restoreState(Settings->value("ThreadTree").toByteArray()); - // state of splitter - ui.splitter->restoreState(Settings->value("Splitter").toByteArray()); - ui.threadSplitter->restoreState(Settings->value("threadSplitter").toByteArray()); - } else { - // save settings + // state of splitter + ui.splitter->restoreState(Settings->value("Splitter").toByteArray()); + ui.threadSplitter->restoreState(Settings->value("threadSplitter").toByteArray()); + } else { + // save settings - // state of thread tree - Settings->setValue("ThreadTree", pHeader->saveState()); + // state of thread tree + Settings->setValue("ThreadTree", pHeader->saveState()); - // state of splitter - Settings->setValue("Splitter", ui.splitter->saveState()); - Settings->setValue("threadSplitter", ui.threadSplitter->saveState()); - } + // state of splitter + Settings->setValue("Splitter", ui.splitter->saveState()); + Settings->setValue("threadSplitter", ui.threadSplitter->saveState()); + } - ui.forumTreeWidget->processSettings(Settings, bLoad); + ui.forumTreeWidget->processSettings(Settings, bLoad); - Settings->endGroup(); - m_bProcessSettings = false; + Settings->endGroup(); + m_bProcessSettings = false; +} + +void GxsForumsDialog::changeEvent(QEvent *e) +{ + QWidget::changeEvent(e); + switch (e->type()) { + case QEvent::StyleChange: + CalculateIconsAndFonts(); + break; + default: + // remove compiler warnings + break; + } } void GxsForumsDialog::forumListCustomPopupMenu( QPoint /*point*/ ) { - QMenu contextMnu( this ); + QMenu contextMnu( this ); - QAction *action = contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Subscribe to Forum"), this, SLOT(subscribeToForum())); - action->setDisabled (mCurrForumId.empty() || IS_GROUP_SUBSCRIBED(subscribeFlags)); + QAction *action = contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Subscribe to Forum"), this, SLOT(subscribeToForum())); + action->setDisabled (mCurrForumId.empty() || IS_GROUP_SUBSCRIBED(subscribeFlags)); - action = contextMnu.addAction(QIcon(IMAGE_UNSUBSCRIBE), tr("Unsubscribe to Forum"), this, SLOT(unsubscribeToForum())); - action->setEnabled (!mCurrForumId.empty() && IS_GROUP_SUBSCRIBED(subscribeFlags)); + action = contextMnu.addAction(QIcon(IMAGE_UNSUBSCRIBE), tr("Unsubscribe to Forum"), this, SLOT(unsubscribeToForum())); + action->setEnabled (!mCurrForumId.empty() && IS_GROUP_SUBSCRIBED(subscribeFlags)); - contextMnu.addSeparator(); + contextMnu.addSeparator(); - contextMnu.addAction(QIcon(IMAGE_NEWFORUM), tr("New Forum"), this, SLOT(newforum())); + contextMnu.addAction(QIcon(IMAGE_NEWFORUM), tr("New Forum"), this, SLOT(newforum())); - action = contextMnu.addAction(QIcon(IMAGE_INFO), tr("Show Forum Details"), this, SLOT(showForumDetails())); - action->setEnabled (!mCurrForumId.empty ()); + action = contextMnu.addAction(QIcon(IMAGE_INFO), tr("Show Forum Details"), this, SLOT(showForumDetails())); + action->setEnabled (!mCurrForumId.empty ()); - action = contextMnu.addAction(QIcon(":/images/settings16.png"), tr("Edit Forum Details"), this, SLOT(editForumDetails())); - action->setEnabled (!mCurrForumId.empty () && IS_GROUP_ADMIN(subscribeFlags)); + action = contextMnu.addAction(QIcon(":/images/settings16.png"), tr("Edit Forum Details"), this, SLOT(editForumDetails())); + action->setEnabled (!mCurrForumId.empty () && IS_GROUP_ADMIN(subscribeFlags)); - QAction *shareKeyAct = new QAction(QIcon(":/images/gpgp_key_generate.png"), tr("Share Forum"), &contextMnu); - connect( shareKeyAct, SIGNAL( triggered() ), this, SLOT( shareKey() ) ); - shareKeyAct->setEnabled(!mCurrForumId.empty() && IS_GROUP_ADMIN(subscribeFlags)); - contextMnu.addAction( shareKeyAct); + QAction *shareKeyAct = new QAction(QIcon(":/images/gpgp_key_generate.png"), tr("Share Forum"), &contextMnu); + connect( shareKeyAct, SIGNAL( triggered() ), this, SLOT( shareKey() ) ); + shareKeyAct->setEnabled(!mCurrForumId.empty() && IS_GROUP_ADMIN(subscribeFlags)); + contextMnu.addAction( shareKeyAct); - QAction *restoreKeysAct = new QAction(QIcon(":/images/settings16.png"), tr("Restore Publish Rights for Forum" ), &contextMnu); - connect( restoreKeysAct , SIGNAL( triggered() ), this, SLOT( restoreForumKeys() ) ); - restoreKeysAct->setEnabled(!mCurrForumId.empty() && !IS_GROUP_ADMIN(subscribeFlags)); - contextMnu.addAction( restoreKeysAct); + QAction *restoreKeysAct = new QAction(QIcon(":/images/settings16.png"), tr("Restore Publish Rights for Forum" ), &contextMnu); + connect( restoreKeysAct , SIGNAL( triggered() ), this, SLOT( restoreForumKeys() ) ); + restoreKeysAct->setEnabled(!mCurrForumId.empty() && !IS_GROUP_ADMIN(subscribeFlags)); + contextMnu.addAction( restoreKeysAct); - action = contextMnu.addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyForumLink())); - action->setEnabled(!mCurrForumId.empty()); + action = contextMnu.addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyForumLink())); + action->setEnabled(!mCurrForumId.empty()); - contextMnu.addSeparator(); + contextMnu.addSeparator(); - action = contextMnu.addAction(QIcon(":/images/message-mail-read.png"), tr("Mark all as read"), this, SLOT(markMsgAsReadAll())); - action->setEnabled (!mCurrForumId.empty () && IS_GROUP_SUBSCRIBED(subscribeFlags)); + action = contextMnu.addAction(QIcon(":/images/message-mail-read.png"), tr("Mark all as read"), this, SLOT(markMsgAsReadAll())); + action->setEnabled (!mCurrForumId.empty () && IS_GROUP_SUBSCRIBED(subscribeFlags)); - action = contextMnu.addAction(QIcon(":/images/message-mail.png"), tr("Mark all as unread"), this, SLOT(markMsgAsUnreadAll())); - action->setEnabled (!mCurrForumId.empty () && IS_GROUP_SUBSCRIBED(subscribeFlags)); + action = contextMnu.addAction(QIcon(":/images/message-mail.png"), tr("Mark all as unread"), this, SLOT(markMsgAsUnreadAll())); + action->setEnabled (!mCurrForumId.empty () && IS_GROUP_SUBSCRIBED(subscribeFlags)); #ifdef DEBUG_FORUMS - contextMnu.addSeparator(); - action = contextMnu.addAction("Generate mass data", this, SLOT(generateMassData())); - action->setEnabled (!mCurrForumId.empty() && IS_GROUP_SUBSCRIBED(subscribeFlags)); + contextMnu.addSeparator(); + action = contextMnu.addAction("Generate mass data", this, SLOT(generateMassData())); + action->setEnabled (!mCurrForumId.empty() && IS_GROUP_SUBSCRIBED(subscribeFlags)); #endif - contextMnu.exec(QCursor::pos()); + contextMnu.exec(QCursor::pos()); } void GxsForumsDialog::threadListCustomPopupMenu( QPoint /*point*/ ) { - if (mThreadLoading) { - return; - } + if (mThreadLoading) { + return; + } - QMenu contextMnu( this ); + QMenu contextMnu( this ); - QAction *replyAct = new QAction(QIcon(IMAGE_MESSAGEREPLY), tr( "Reply" ), &contextMnu ); - connect( replyAct , SIGNAL( triggered() ), this, SLOT( createmessage() ) ); + QAction *replyAct = new QAction(QIcon(IMAGE_MESSAGEREPLY), tr( "Reply" ), &contextMnu ); + connect( replyAct , SIGNAL( triggered() ), this, SLOT( createmessage() ) ); - QAction *newthreadAct = new QAction(QIcon(IMAGE_DOWNLOADALL), tr( "Start New Thread" ), &contextMnu ); - newthreadAct->setEnabled (IS_GROUP_SUBSCRIBED(subscribeFlags)); - connect( newthreadAct , SIGNAL( triggered() ), this, SLOT( createthread() ) ); + QAction *newthreadAct = new QAction(QIcon(IMAGE_DOWNLOADALL), tr( "Start New Thread" ), &contextMnu ); + newthreadAct->setEnabled (IS_GROUP_SUBSCRIBED(subscribeFlags)); + connect( newthreadAct , SIGNAL( triggered() ), this, SLOT( createthread() ) ); - QAction *replyauthorAct = new QAction(QIcon(IMAGE_MESSAGEREPLY), tr( "Reply to Author" ), &contextMnu ); - connect( replyauthorAct , SIGNAL( triggered() ), this, SLOT( replytomessage() ) ); + QAction *replyauthorAct = new QAction(QIcon(IMAGE_MESSAGEREPLY), tr( "Reply to Author" ), &contextMnu ); + connect( replyauthorAct , SIGNAL( triggered() ), this, SLOT( replytomessage() ) ); - QAction* expandAll = new QAction(tr( "Expand all" ), &contextMnu ); - connect( expandAll , SIGNAL( triggered() ), ui.threadTreeWidget, SLOT (expandAll()) ); + QAction* expandAll = new QAction(tr( "Expand all" ), &contextMnu ); + connect( expandAll , SIGNAL( triggered() ), ui.threadTreeWidget, SLOT (expandAll()) ); - QAction* collapseAll = new QAction(tr( "Collapse all" ), &contextMnu ); - connect( collapseAll , SIGNAL( triggered() ), ui.threadTreeWidget, SLOT(collapseAll()) ); + QAction* collapseAll = new QAction(tr( "Collapse all" ), &contextMnu ); + connect( collapseAll , SIGNAL( triggered() ), ui.threadTreeWidget, SLOT(collapseAll()) ); - QAction *markMsgAsRead = new QAction(QIcon(":/images/message-mail-read.png"), tr("Mark as read"), &contextMnu); - connect(markMsgAsRead , SIGNAL(triggered()), this, SLOT(markMsgAsRead())); + QAction *markMsgAsRead = new QAction(QIcon(":/images/message-mail-read.png"), tr("Mark as read"), &contextMnu); + connect(markMsgAsRead , SIGNAL(triggered()), this, SLOT(markMsgAsRead())); - QAction *markMsgAsReadChildren = new QAction(QIcon(":/images/message-mail-read.png"), tr("Mark as read") + " (" + tr ("with children") + ")", &contextMnu); - connect(markMsgAsReadChildren, SIGNAL(triggered()), this, SLOT(markMsgAsReadChildren())); + QAction *markMsgAsReadChildren = new QAction(QIcon(":/images/message-mail-read.png"), tr("Mark as read") + " (" + tr ("with children") + ")", &contextMnu); + connect(markMsgAsReadChildren, SIGNAL(triggered()), this, SLOT(markMsgAsReadChildren())); - QAction *markMsgAsUnread = new QAction(QIcon(":/images/message-mail.png"), tr("Mark as unread"), &contextMnu); - connect(markMsgAsUnread , SIGNAL(triggered()), this, SLOT(markMsgAsUnread())); + QAction *markMsgAsUnread = new QAction(QIcon(":/images/message-mail.png"), tr("Mark as unread"), &contextMnu); + connect(markMsgAsUnread , SIGNAL(triggered()), this, SLOT(markMsgAsUnread())); - QAction *markMsgAsUnreadChildren = new QAction(QIcon(":/images/message-mail.png"), tr("Mark as unread") + " (" + tr ("with children") + ")", &contextMnu); - connect(markMsgAsUnreadChildren , SIGNAL(triggered()), this, SLOT(markMsgAsUnreadChildren())); + QAction *markMsgAsUnreadChildren = new QAction(QIcon(":/images/message-mail.png"), tr("Mark as unread") + " (" + tr ("with children") + ")", &contextMnu); + connect(markMsgAsUnreadChildren , SIGNAL(triggered()), this, SLOT(markMsgAsUnreadChildren())); - if (IS_GROUP_SUBSCRIBED(subscribeFlags)) { - QList Rows; - QList RowsRead; - QList RowsUnread; - int nCount = getSelectedMsgCount (&Rows, &RowsRead, &RowsUnread); + if (IS_GROUP_SUBSCRIBED(subscribeFlags)) { + QList Rows; + QList RowsRead; + QList RowsUnread; + int nCount = getSelectedMsgCount (&Rows, &RowsRead, &RowsUnread); - if (RowsUnread.size() == 0) { + if (RowsUnread.size() == 0) { - markMsgAsRead->setDisabled(true); - } - if (RowsRead.size() == 0) { - markMsgAsUnread->setDisabled(true); - } + markMsgAsRead->setDisabled(true); + } + if (RowsRead.size() == 0) { + markMsgAsUnread->setDisabled(true); + } - bool bHasUnreadChildren = false; - bool bHasReadChildren = false; - int nRowCount = Rows.count(); - for (int i = 0; i < nRowCount; i++) { - if (bHasUnreadChildren || Rows[i]->data(COLUMN_THREAD_DATA, ROLE_THREAD_UNREADCHILDREN).toBool()) { - bHasUnreadChildren = true; - } - if (bHasReadChildren || Rows[i]->data(COLUMN_THREAD_DATA, ROLE_THREAD_READCHILDREN).toBool()) { - bHasReadChildren = true; - } - } - markMsgAsReadChildren->setEnabled(bHasUnreadChildren); - markMsgAsUnreadChildren->setEnabled(bHasReadChildren); + bool bHasUnreadChildren = false; + bool bHasReadChildren = false; + int nRowCount = Rows.count(); + for (int i = 0; i < nRowCount; i++) { + if (bHasUnreadChildren || Rows[i]->data(COLUMN_THREAD_DATA, ROLE_THREAD_UNREADCHILDREN).toBool()) { + bHasUnreadChildren = true; + } + if (bHasReadChildren || Rows[i]->data(COLUMN_THREAD_DATA, ROLE_THREAD_READCHILDREN).toBool()) { + bHasReadChildren = true; + } + } + markMsgAsReadChildren->setEnabled(bHasUnreadChildren); + markMsgAsUnreadChildren->setEnabled(bHasReadChildren); - if (nCount == 1) { - replyAct->setEnabled (true); - replyauthorAct->setEnabled (true); - } else { - replyAct->setDisabled (true); - replyauthorAct->setDisabled (true); - } - } else { - markMsgAsRead->setDisabled(true); - markMsgAsReadChildren->setDisabled(true); - markMsgAsUnread->setDisabled(true); - markMsgAsUnreadChildren->setDisabled(true); - replyAct->setDisabled (true); - replyauthorAct->setDisabled (true); - } + if (nCount == 1) { + replyAct->setEnabled (true); + replyauthorAct->setEnabled (true); + } else { + replyAct->setDisabled (true); + replyauthorAct->setDisabled (true); + } + } else { + markMsgAsRead->setDisabled(true); + markMsgAsReadChildren->setDisabled(true); + markMsgAsUnread->setDisabled(true); + markMsgAsUnreadChildren->setDisabled(true); + replyAct->setDisabled (true); + replyauthorAct->setDisabled (true); + } - contextMnu.addAction( replyAct); - contextMnu.addAction( newthreadAct); - contextMnu.addAction( replyauthorAct); - QAction* action = contextMnu.addAction(QIcon(IMAGE_COPYLINK), tr( "Copy RetroShare Link"), this, SLOT(copyMessageLink())); - action->setEnabled(!mCurrForumId.empty() && !mCurrThreadId.empty()); - contextMnu.addSeparator(); - contextMnu.addAction(markMsgAsRead); - contextMnu.addAction(markMsgAsReadChildren); - contextMnu.addAction(markMsgAsUnread); - contextMnu.addAction(markMsgAsUnreadChildren); - contextMnu.addSeparator(); - contextMnu.addAction( expandAll); - contextMnu.addAction( collapseAll); + contextMnu.addAction( replyAct); + contextMnu.addAction( newthreadAct); + contextMnu.addAction( replyauthorAct); + QAction* action = contextMnu.addAction(QIcon(IMAGE_COPYLINK), tr( "Copy RetroShare Link"), this, SLOT(copyMessageLink())); + action->setEnabled(!mCurrForumId.empty() && !mCurrThreadId.empty()); + contextMnu.addSeparator(); + contextMnu.addAction(markMsgAsRead); + contextMnu.addAction(markMsgAsReadChildren); + contextMnu.addAction(markMsgAsUnread); + contextMnu.addAction(markMsgAsUnreadChildren); + contextMnu.addSeparator(); + contextMnu.addAction( expandAll); + contextMnu.addAction( collapseAll); - contextMnu.exec(QCursor::pos()); + contextMnu.exec(QCursor::pos()); } bool GxsForumsDialog::eventFilter(QObject *obj, QEvent *event) { - if (obj == ui.threadTreeWidget) { - if (event->type() == QEvent::KeyPress) { - QKeyEvent *keyEvent = static_cast(event); - if (keyEvent && keyEvent->key() == Qt::Key_Space) { - // Space pressed - QTreeWidgetItem *item = ui.threadTreeWidget->currentItem (); - clickedThread (item, COLUMN_THREAD_READ); - return true; // eat event - } - } - } - // pass the event on to the parent class - return RsAutoUpdatePage::eventFilter(obj, event); + if (obj == ui.threadTreeWidget) { + if (event->type() == QEvent::KeyPress) { + QKeyEvent *keyEvent = static_cast(event); + if (keyEvent && keyEvent->key() == Qt::Key_Space) { + // Space pressed + QTreeWidgetItem *item = ui.threadTreeWidget->currentItem (); + clickedThread (item, COLUMN_THREAD_READ); + return true; // eat event + } + } + } + // pass the event on to the parent class + return RsAutoUpdatePage::eventFilter(obj, event); } void GxsForumsDialog::restoreForumKeys(void) @@ -472,56 +468,56 @@ void GxsForumsDialog::restoreForumKeys(void) void GxsForumsDialog::togglethreadview() { - // save state of button - Settings->setValueToGroup("GxsForumsDialog", "expandButton", ui.expandButton->isChecked()); + // save state of button + Settings->setValueToGroup("GxsForumsDialog", "expandButton", ui.expandButton->isChecked()); - togglethreadview_internal(); + togglethreadview_internal(); } void GxsForumsDialog::togglethreadview_internal() { - if (ui.expandButton->isChecked()) { - ui.postText->setVisible(true); - ui.expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png"))); - ui.expandButton->setToolTip(tr("Hide")); - } else { - ui.postText->setVisible(false); - ui.expandButton->setIcon(QIcon(QString(":/images/edit_add24.png"))); - ui.expandButton->setToolTip(tr("Expand")); - } + if (ui.expandButton->isChecked()) { + ui.postText->setVisible(true); + ui.expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png"))); + ui.expandButton->setToolTip(tr("Hide")); + } else { + ui.postText->setVisible(false); + ui.expandButton->setIcon(QIcon(QString(":/images/edit_add24.png"))); + ui.expandButton->setToolTip(tr("Expand")); + } } void GxsForumsDialog::updateDisplay() { - std::list forumIds; - std::list::iterator it; - if (!rsGxsForums) - return; + std::list forumIds; + std::list::iterator it; + if (!rsGxsForums) + return; #if 0 // TODO groupsChanged... HACK XXX. - if ((rsGxsForums->groupsChanged(forumIds)) || (rsGxsForums->updated())) - { - /* update Forums List */ - insertForums(); + if ((rsGxsForums->groupsChanged(forumIds)) || (rsGxsForums->updated())) + { + /* update Forums List */ + insertForums(); - it = std::find(forumIds.begin(), forumIds.end(), mCurrForumId); - if (it != forumIds.end()) - { - /* update threads as well */ - insertThreads(); - } - } + it = std::find(forumIds.begin(), forumIds.end(), mCurrForumId); + if (it != forumIds.end()) + { + /* update threads as well */ + insertThreads(); + } + } #endif - /* The proper version (above) can be done with a data request -> TODO */ - if (rsGxsForums->updated()) - { - /* update Forums List */ - insertForums(); - /* update threads as well */ - insertThreads(); - } + /* The proper version (above) can be done with a data request -> TODO */ + if (rsGxsForums->updated()) + { + /* update Forums List */ + insertForums(); + /* update threads as well */ + insertThreads(); + } } // HACK until update works. @@ -530,86 +526,83 @@ void GxsForumsDialog::forceUpdateDisplay() std::cerr << "GxsForumsDialog::forceUpdateDisplay()"; std::cerr << std::endl; - /* update Forums List */ - insertForums(); - /* update threads as well */ - insertThreads(); + /* update Forums List */ + insertForums(); + /* update threads as well */ + insertThreads(); } - static void CleanupItems (QList &items) { - QList::iterator item; - for (item = items.begin (); item != items.end (); item++) { - if (*item) { - delete (*item); - } - } - items.clear(); + QList::iterator item; + for (item = items.begin (); item != items.end (); item++) { + if (*item) { + delete (*item); + } + } + items.clear(); } void GxsForumsDialog::forumInfoToGroupItemInfo(const RsGroupMetaData &forumInfo, GroupItemInfo &groupItemInfo) //void GxsForumsDialog::forumInfoToGroupItemInfo(const ForumInfo &forumInfo, GroupItemInfo &groupItemInfo) { - - groupItemInfo.id = QString::fromStdString(forumInfo.mGroupId); - groupItemInfo.name = QString::fromUtf8(forumInfo.mGroupName.c_str()); - //groupItemInfo.description = QString::fromUtf8(forumInfo.forumDesc); - groupItemInfo.popularity = forumInfo.mPop; - groupItemInfo.lastpost = QDateTime::fromTime_t(forumInfo.mLastPost); + groupItemInfo.id = QString::fromStdString(forumInfo.mGroupId); + groupItemInfo.name = QString::fromUtf8(forumInfo.mGroupName.c_str()); + //groupItemInfo.description = QString::fromUtf8(forumInfo.forumDesc); + groupItemInfo.popularity = forumInfo.mPop; + groupItemInfo.lastpost = QDateTime::fromTime_t(forumInfo.mLastPost); #if TOGXS - if (forumInfo.mGroupFlags & RS_DISTRIB_AUTHEN_REQ) { - groupItemInfo.name += " (" + tr("AUTHD") + ")"; - groupItemInfo.icon = QIcon(IMAGE_FORUMAUTHD); - } - else + if (forumInfo.mGroupFlags & RS_DISTRIB_AUTHEN_REQ) { + groupItemInfo.name += " (" + tr("AUTHD") + ")"; + groupItemInfo.icon = QIcon(IMAGE_FORUMAUTHD); + } + else #endif - { - groupItemInfo.icon = QIcon(IMAGE_FORUM); - } + { + groupItemInfo.icon = QIcon(IMAGE_FORUM); + } -// groupItemInfo.id = QString::fromStdString(forumInfo.forumId); -// groupItemInfo.name = QString::fromStdWString(forumInfo.forumName); -// groupItemInfo.description = QString::fromStdWString(forumInfo.forumDesc); -// groupItemInfo.popularity = forumInfo.pop; -// groupItemInfo.lastpost = QDateTime::fromTime_t(forumInfo.lastPost); +// groupItemInfo.id = QString::fromStdString(forumInfo.forumId); +// groupItemInfo.name = QString::fromStdWString(forumInfo.forumName); +// groupItemInfo.description = QString::fromStdWString(forumInfo.forumDesc); +// groupItemInfo.popularity = forumInfo.pop; +// groupItemInfo.lastpost = QDateTime::fromTime_t(forumInfo.lastPost); // -// if (forumInfo.forumFlags & RS_DISTRIB_AUTHEN_REQ) { -// groupItemInfo.name += " (" + tr("AUTHD") + ")"; -// groupItemInfo.icon = QIcon(IMAGE_FORUMAUTHD); -// } else { -// groupItemInfo.icon = QIcon(IMAGE_FORUM); -// } +// if (forumInfo.forumFlags & RS_DISTRIB_AUTHEN_REQ) { +// groupItemInfo.name += " (" + tr("AUTHD") + ")"; +// groupItemInfo.icon = QIcon(IMAGE_FORUMAUTHD); +// } else { +// groupItemInfo.icon = QIcon(IMAGE_FORUM); +// } } - /***** INSERT FORUM LISTS *****/ void GxsForumsDialog::insertForumsData(const std::list &forumList) { std::list::const_iterator it; - QList adminList; - QList subList; - QList popList; - QList otherList; - std::multimap popMap; + QList adminList; + QList subList; + QList popList; + QList otherList; + std::multimap popMap; - for (it = forumList.begin(); it != forumList.end(); it++) { + for (it = forumList.begin(); it != forumList.end(); it++) { /* sort it into Publish (Own), Subscribed, Popular and Other */ uint32_t flags = it->mSubscribeFlags; - GroupItemInfo groupItemInfo; - forumInfoToGroupItemInfo(*it, groupItemInfo); + GroupItemInfo groupItemInfo; + forumInfoToGroupItemInfo(*it, groupItemInfo); - if (IS_GROUP_ADMIN(flags)) { - adminList.push_back(groupItemInfo); - } else if (IS_GROUP_SUBSCRIBED(flags)) { + if (IS_GROUP_ADMIN(flags)) { + adminList.push_back(groupItemInfo); + } else if (IS_GROUP_SUBSCRIBED(flags)) { /* subscribed forum */ - subList.push_back(groupItemInfo); - } else { + subList.push_back(groupItemInfo); + } else { /* rate the others by popularity */ - popMap.insert(std::make_pair(it->mPop, groupItemInfo)); + popMap.insert(std::make_pair(it->mPop, groupItemInfo)); } } @@ -622,190 +615,190 @@ void GxsForumsDialog::insertForumsData(const std::list &forumLi uint32_t i = 0; uint32_t popLimit = 0; - std::multimap::reverse_iterator rit; + std::multimap::reverse_iterator rit; for(rit = popMap.rbegin(); ((rit != popMap.rend()) && (i < popCount)); rit++, i++) ; - if (rit != popMap.rend()) { - popLimit = rit->first; - } + if (rit != popMap.rend()) { + popLimit = rit->first; + } - for (rit = popMap.rbegin(); rit != popMap.rend(); rit++) { + for (rit = popMap.rbegin(); rit != popMap.rend(); rit++) { if (rit->second.popularity < (int) popLimit) { - otherList.append(rit->second); - } else { - popList.append(rit->second); - } + otherList.append(rit->second); + } else { + popList.append(rit->second); + } } /* now we can add them in as a tree! */ - ui.forumTreeWidget->fillGroupItems(yourForums, adminList); - ui.forumTreeWidget->fillGroupItems(subscribedForums, subList); - ui.forumTreeWidget->fillGroupItems(popularForums, popList); - ui.forumTreeWidget->fillGroupItems(otherForums, otherList); + ui.forumTreeWidget->fillGroupItems(yourForums, adminList); + ui.forumTreeWidget->fillGroupItems(subscribedForums, subList); + ui.forumTreeWidget->fillGroupItems(popularForums, popList); + ui.forumTreeWidget->fillGroupItems(otherForums, otherList); updateMessageSummaryList(""); } void GxsForumsDialog::changedForum(const QString &id) { - mCurrForumId = id.toStdString(); + mCurrForumId = id.toStdString(); - insertThreads(); + insertThreads(); } void GxsForumsDialog::changedThread () { - if (mThreadLoading) { - return; - } + if (mThreadLoading) { + return; + } - /* just grab the ids of the current item */ - QTreeWidgetItem *curr = ui.threadTreeWidget->currentItem(); + /* just grab the ids of the current item */ + QTreeWidgetItem *curr = ui.threadTreeWidget->currentItem(); - if ((!curr) || (!curr->isSelected())) { - mCurrThreadId = ""; - } else { - mCurrThreadId = curr->data(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID).toString().toStdString(); - } - insertPost(); + if ((!curr) || (!curr->isSelected())) { + mCurrThreadId = ""; + } else { + mCurrThreadId = curr->data(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID).toString().toStdString(); + } + insertPost(); } void GxsForumsDialog::clickedThread (QTreeWidgetItem *item, int column) { - if (mCurrForumId.empty() || !IS_GROUP_SUBSCRIBED(subscribeFlags)) { - return; - } + if (mCurrForumId.empty() || !IS_GROUP_SUBSCRIBED(subscribeFlags)) { + return; + } - if (item == NULL) { - return; - } + if (item == NULL) { + return; + } - if (column == COLUMN_THREAD_READ) { - QList Rows; - Rows.append(item); - uint32_t status = item->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt(); - setMsgReadStatus(Rows, IS_MSG_UNREAD(status)); - return; - } + if (column == COLUMN_THREAD_READ) { + QList Rows; + Rows.append(item); + uint32_t status = item->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt(); + setMsgReadStatus(Rows, IS_MSG_UNREAD(status)); + return; + } } void GxsForumsDialog::forumMsgReadStatusChanged(const QString &forumId, const QString &msgId, int status) { - if (inMsgAsReadUnread) { - return; - } + if (inMsgAsReadUnread) { + return; + } - if (forumId.toStdString() == mCurrForumId) { - /* Search exisiting item */ - QTreeWidgetItemIterator itemIterator(ui.threadTreeWidget); - QTreeWidgetItem *item = NULL; - while ((item = *itemIterator) != NULL) { - itemIterator++; + if (forumId.toStdString() == mCurrForumId) { + /* Search exisiting item */ + QTreeWidgetItemIterator itemIterator(ui.threadTreeWidget); + QTreeWidgetItem *item = NULL; + while ((item = *itemIterator) != NULL) { + itemIterator++; - if (item->data(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID).toString() == msgId) { - // update status - item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS, status); + if (item->data(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID).toString() == msgId) { + // update status + item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS, status); - QTreeWidgetItem *parentItem = item; - while (parentItem->parent()) { - parentItem = parentItem->parent(); - } - CalculateIconsAndFonts(parentItem); - break; - } - } - } - updateMessageSummaryList(forumId.toStdString()); + QTreeWidgetItem *parentItem = item; + while (parentItem->parent()) { + parentItem = parentItem->parent(); + } + CalculateIconsAndFonts(parentItem); + break; + } + } + } + updateMessageSummaryList(forumId.toStdString()); } void GxsForumsDialog::CalculateIconsAndFonts(QTreeWidgetItem *pItem, bool &bHasReadChilddren, bool &bHasUnreadChilddren) { - uint32_t status = pItem->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt(); + uint32_t status = pItem->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt(); - bool bUnread = IS_MSG_UNREAD(status); - bool missing = pItem->data(COLUMN_THREAD_DATA, ROLE_THREAD_MISSING).toBool(); + bool bUnread = IS_MSG_UNREAD(status); + bool missing = pItem->data(COLUMN_THREAD_DATA, ROLE_THREAD_MISSING).toBool(); - // set icon - if (missing) { - pItem->setIcon(COLUMN_THREAD_READ, QIcon()); - pItem->setIcon(COLUMN_THREAD_TITLE, QIcon()); - } else { - if (bUnread) { - pItem->setIcon(COLUMN_THREAD_READ, QIcon(":/images/message-state-unread.png")); - } else { - pItem->setIcon(COLUMN_THREAD_READ, QIcon(":/images/message-state-read.png")); - } - if (IS_MSG_UNREAD(status)) { - pItem->setIcon(COLUMN_THREAD_TITLE, QIcon(":/images/message-state-new.png")); - } else { - pItem->setIcon(COLUMN_THREAD_TITLE, QIcon()); - } - } + // set icon + if (missing) { + pItem->setIcon(COLUMN_THREAD_READ, QIcon()); + pItem->setIcon(COLUMN_THREAD_TITLE, QIcon()); + } else { + if (bUnread) { + pItem->setIcon(COLUMN_THREAD_READ, QIcon(":/images/message-state-unread.png")); + } else { + pItem->setIcon(COLUMN_THREAD_READ, QIcon(":/images/message-state-read.png")); + } + if (IS_MSG_UNREAD(status)) { + pItem->setIcon(COLUMN_THREAD_TITLE, QIcon(":/images/message-state-new.png")); + } else { + pItem->setIcon(COLUMN_THREAD_TITLE, QIcon()); + } + } - int nItem; - int nItemCount = pItem->childCount(); + int nItem; + int nItemCount = pItem->childCount(); - bool bMyReadChilddren = false; - bool bMyUnreadChilddren = false; + bool bMyReadChilddren = false; + bool bMyUnreadChilddren = false; - for (nItem = 0; nItem < nItemCount; nItem++) { - CalculateIconsAndFonts(pItem->child(nItem), bMyReadChilddren, bMyUnreadChilddren); - } + for (nItem = 0; nItem < nItemCount; nItem++) { + CalculateIconsAndFonts(pItem->child(nItem), bMyReadChilddren, bMyUnreadChilddren); + } - // set font - for (int i = 0; i < COLUMN_THREAD_COUNT; i++) { - QFont qf = pItem->font(i); + // set font + for (int i = 0; i < COLUMN_THREAD_COUNT; i++) { + QFont qf = pItem->font(i); - if (!IS_GROUP_SUBSCRIBED(subscribeFlags)) { - qf.setBold(false); - pItem->setTextColor(i, Qt::black); - } else if (bUnread) { - qf.setBold(true); - pItem->setTextColor(i, Qt::black); - } else if (bMyUnreadChilddren) { - qf.setBold(true); - pItem->setTextColor(i, Qt::gray); - } else { - qf.setBold(false); - pItem->setTextColor(i, Qt::gray); - } - if (missing) { - /* Missing message */ - pItem->setTextColor(i, Qt::darkRed); - } - pItem->setFont(i, qf); - } + if (!IS_GROUP_SUBSCRIBED(subscribeFlags)) { + qf.setBold(false); + pItem->setTextColor(i, textColorNotSubscribed()); + } else if (bUnread) { + qf.setBold(true); + pItem->setTextColor(i, textColorUnread()); + } else if (bMyUnreadChilddren) { + qf.setBold(true); + pItem->setTextColor(i, textColorUnreadChildren()); + } else { + qf.setBold(false); + pItem->setTextColor(i, textColorRead()); + } + if (missing) { + /* Missing message */ + pItem->setTextColor(i, textColorMissing()); + } + pItem->setFont(i, qf); + } - pItem->setData(COLUMN_THREAD_DATA, ROLE_THREAD_READCHILDREN, bHasReadChilddren || bMyReadChilddren); - pItem->setData(COLUMN_THREAD_DATA, ROLE_THREAD_UNREADCHILDREN, bHasUnreadChilddren || bMyUnreadChilddren); + pItem->setData(COLUMN_THREAD_DATA, ROLE_THREAD_READCHILDREN, bHasReadChilddren || bMyReadChilddren); + pItem->setData(COLUMN_THREAD_DATA, ROLE_THREAD_UNREADCHILDREN, bHasUnreadChilddren || bMyUnreadChilddren); - bHasReadChilddren = bHasReadChilddren || bMyReadChilddren || !bUnread; - bHasUnreadChilddren = bHasUnreadChilddren || bMyUnreadChilddren || bUnread; + bHasReadChilddren = bHasReadChilddren || bMyReadChilddren || !bUnread; + bHasUnreadChilddren = bHasUnreadChilddren || bMyUnreadChilddren || bUnread; } void GxsForumsDialog::CalculateIconsAndFonts(QTreeWidgetItem *pItem /*= NULL*/) { - bool bDummy1 = false; - bool bDummy2 = false; + bool bDummy1 = false; + bool bDummy2 = false; - if (pItem) { - CalculateIconsAndFonts(pItem, bDummy1, bDummy2); - return; - } + if (pItem) { + CalculateIconsAndFonts(pItem, bDummy1, bDummy2); + return; + } - int nItem; - int nItemCount = ui.threadTreeWidget->topLevelItemCount(); + int nItem; + int nItemCount = ui.threadTreeWidget->topLevelItemCount(); - for (nItem = 0; nItem < nItemCount; nItem++) { - bDummy1 = false; - bDummy2 = false; - CalculateIconsAndFonts(ui.threadTreeWidget->topLevelItem(nItem), bDummy1, bDummy2); - } + for (nItem = 0; nItem < nItemCount; nItem++) { + bDummy1 = false; + bDummy2 = false; + CalculateIconsAndFonts(ui.threadTreeWidget->topLevelItem(nItem), bDummy1, bDummy2); + } } void GxsForumsDialog::fillThreadFinished() { #ifdef DEBUG_FORUMS - std::cerr << "GxsForumsDialog::fillThreadFinished" << std::endl; + std::cerr << "GxsForumsDialog::fillThreadFinished" << std::endl; #endif // This is now only called with a successful Load. @@ -815,43 +808,43 @@ void GxsForumsDialog::fillThreadFinished() ui.progressBar->hide(); ui.progLayOutTxt->hide(); ui.progressBarLayOut->setEnabled(false); - + #ifdef DEBUG_FORUMS std::cerr << "GxsForumsDialog::fillThreadFinished Add messages" << std::endl; #endif - ui.threadTreeWidget->setSortingEnabled(false); + ui.threadTreeWidget->setSortingEnabled(false); - /* add all messages in! */ - if (lastViewType != mThreadLoad.ViewType || lastForumID != mCurrForumId) + /* add all messages in! */ + if (lastViewType != mThreadLoad.ViewType || lastForumID != mCurrForumId) { ui.threadTreeWidget->clear(); lastViewType = mThreadLoad.ViewType; lastForumID = mCurrForumId; ui.threadTreeWidget->insertTopLevelItems(0, mThreadLoad.Items); - + // clear list mThreadLoad.Items.clear(); - } - else + } + else { FillThreads (mThreadLoad.Items, mThreadLoad.ExpandNewMessages, mThreadLoad.ItemToExpand); - + // cleanup list CleanupItems (mThreadLoad.Items); } - ui.threadTreeWidget->setSortingEnabled(true); + ui.threadTreeWidget->setSortingEnabled(true); - if (mThreadLoad.FocusMsgId.empty() == false) + if (mThreadLoad.FocusMsgId.empty() == false) { /* Search exisiting item */ QTreeWidgetItemIterator itemIterator(ui.threadTreeWidget); QTreeWidgetItem *item = NULL; - while ((item = *itemIterator) != NULL) + while ((item = *itemIterator) != NULL) { itemIterator++; - - if (item->data(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID).toString().toStdString() == mThreadLoad.FocusMsgId) + + if (item->data(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID).toString().toStdString() == mThreadLoad.FocusMsgId) { ui.threadTreeWidget->setCurrentItem(item); ui.threadTreeWidget->setFocus(); @@ -859,40 +852,39 @@ void GxsForumsDialog::fillThreadFinished() } } } - + QList::iterator Item; - for (Item = mThreadLoad.ItemToExpand.begin(); Item != mThreadLoad.ItemToExpand.end(); Item++) + for (Item = mThreadLoad.ItemToExpand.begin(); Item != mThreadLoad.ItemToExpand.end(); Item++) { - if ((*Item)->isHidden() == false) + if ((*Item)->isHidden() == false) { (*Item)->setExpanded(true); } } mThreadLoad.ItemToExpand.clear(); - - if (ui.filterLineEdit->text().isEmpty() == false) { - filterItems(ui.filterLineEdit->text()); + + if (ui.filterLineEdit->text().isEmpty() == false) { + filterItems(ui.filterLineEdit->text()); } - + insertPost (); CalculateIconsAndFonts(); - + ui.newthreadButton->setEnabled (IS_GROUP_SUBSCRIBED(subscribeFlags)); mThreadLoading = false; #ifdef DEBUG_FORUMS - std::cerr << "GxsForumsDialog::fillThreadFinished done" << std::endl; + std::cerr << "GxsForumsDialog::fillThreadFinished done" << std::endl; #endif } void GxsForumsDialog::fillThreadProgress(int current, int count) { - // show fill progress - if (count) { - ui.progressBar->setValue(current * ui.progressBar->maximum() / count); - } - + // show fill progress + if (count) { + ui.progressBar->setValue(current * ui.progressBar->maximum() / count); + } } void GxsForumsDialog::insertThreads() @@ -903,13 +895,13 @@ void GxsForumsDialog::insertThreads() #endif subscribeFlags = 0; - + ui.newmessageButton->setEnabled (false); ui.newthreadButton->setEnabled (false); - + ui.postText->clear(); ui.threadTitle->clear(); - + if (mCurrForumId.empty()) { /* not an actual forum - clear */ @@ -919,14 +911,14 @@ void GxsForumsDialog::insertThreads() /* clear last stored forumID */ mCurrForumId.erase(); lastForumID.erase(); - + #ifdef DEBUG_FORUMS std::cerr << "GxsForumsDialog::insertThreads() Current Thread Invalid" << std::endl; #endif - + return; } - + // Get Current Forum Info... then complete insertForumThreads(). requestGroupSummary_CurrentForum(mCurrForumId); } @@ -934,236 +926,233 @@ void GxsForumsDialog::insertThreads() void GxsForumsDialog::insertForumThreads(const RsGroupMetaData &fi) { - subscribeFlags = fi.mSubscribeFlags; - ui.forumName->setText(QString::fromUtf8(fi.mGroupName.c_str())); + subscribeFlags = fi.mSubscribeFlags; + ui.forumName->setText(QString::fromUtf8(fi.mGroupName.c_str())); - ui.progressBarLayOut->setEnabled(true); + ui.progressBarLayOut->setEnabled(true); - ui.progLayOutTxt->show(); - ui.progressBar->reset(); - ui.progressBar->show(); + ui.progLayOutTxt->show(); + ui.progressBar->reset(); + ui.progressBar->show(); #ifdef DEBUG_FORUMS - std::cerr << "GxsForumsDialog::insertThreads() Start filling Forum threads" << std::endl; + std::cerr << "GxsForumsDialog::insertThreads() Start filling Forum threads" << std::endl; #endif - loadCurrentForumThreads(fi.mGroupId); + loadCurrentForumThreads(fi.mGroupId); } - - - void GxsForumsDialog::FillThreads(QList &ThreadList, bool expandNewMessages, QList &itemToExpand) { #ifdef DEBUG_FORUMS - std::cerr << "GxsForumsDialog::FillThreads()" << std::endl; + std::cerr << "GxsForumsDialog::FillThreads()" << std::endl; #endif - int Index = 0; - QTreeWidgetItem *Thread; - QList::iterator NewThread; + int Index = 0; + QTreeWidgetItem *Thread; + QList::iterator NewThread; - // delete not existing - while (Index < ui.threadTreeWidget->topLevelItemCount ()) { - Thread = ui.threadTreeWidget->topLevelItem (Index); + // delete not existing + while (Index < ui.threadTreeWidget->topLevelItemCount ()) { + Thread = ui.threadTreeWidget->topLevelItem (Index); - // search existing new thread - int Found = -1; - for (NewThread = ThreadList.begin (); NewThread != ThreadList.end (); NewThread++) { - if (Thread->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID) == (*NewThread)->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID)) { - // found it - Found = Index; - break; - } - } - if (Found >= 0) { - Index++; - } else { - delete (ui.threadTreeWidget->takeTopLevelItem (Index)); - } - } + // search existing new thread + int Found = -1; + for (NewThread = ThreadList.begin (); NewThread != ThreadList.end (); NewThread++) { + if (Thread->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID) == (*NewThread)->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID)) { + // found it + Found = Index; + break; + } + } + if (Found >= 0) { + Index++; + } else { + delete (ui.threadTreeWidget->takeTopLevelItem (Index)); + } + } - // iterate all new threads - for (NewThread = ThreadList.begin (); NewThread != ThreadList.end (); NewThread++) { - // search existing thread - int Found = -1; - int Count = ui.threadTreeWidget->topLevelItemCount (); - for (Index = 0; Index < Count; Index++) { - Thread = ui.threadTreeWidget->topLevelItem (Index); - if (Thread->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID) == (*NewThread)->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID)) { - // found it - Found = Index; - break; - } - } + // iterate all new threads + for (NewThread = ThreadList.begin (); NewThread != ThreadList.end (); NewThread++) { + // search existing thread + int Found = -1; + int Count = ui.threadTreeWidget->topLevelItemCount (); + for (Index = 0; Index < Count; Index++) { + Thread = ui.threadTreeWidget->topLevelItem (Index); + if (Thread->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID) == (*NewThread)->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID)) { + // found it + Found = Index; + break; + } + } - if (Found >= 0) { - // set child data - int i; - for (i = 0; i < COLUMN_THREAD_COUNT; i++) { - Thread->setText (i, (*NewThread)->text (i)); - } - for (i = 0; i < ROLE_THREAD_COUNT; i++) { - Thread->setData (COLUMN_THREAD_DATA, Qt::UserRole + i, (*NewThread)->data (COLUMN_THREAD_DATA, Qt::UserRole + i)); - } + if (Found >= 0) { + // set child data + int i; + for (i = 0; i < COLUMN_THREAD_COUNT; i++) { + Thread->setText (i, (*NewThread)->text (i)); + } + for (i = 0; i < ROLE_THREAD_COUNT; i++) { + Thread->setData (COLUMN_THREAD_DATA, Qt::UserRole + i, (*NewThread)->data (COLUMN_THREAD_DATA, Qt::UserRole + i)); + } - // fill recursive - FillChildren (Thread, *NewThread, expandNewMessages, itemToExpand); - } else { - // add new thread - ui.threadTreeWidget->addTopLevelItem (*NewThread); - Thread = *NewThread; - *NewThread = NULL; - } + // fill recursive + FillChildren (Thread, *NewThread, expandNewMessages, itemToExpand); + } else { + // add new thread + ui.threadTreeWidget->addTopLevelItem (*NewThread); + Thread = *NewThread; + *NewThread = NULL; + } - uint32_t status = Thread->data (COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt(); - if (expandNewMessages && IS_MSG_UNREAD(status)) { - QTreeWidgetItem *pParent = Thread; - while ((pParent = pParent->parent()) != NULL) { - if (std::find(itemToExpand.begin(), itemToExpand.end(), pParent) == itemToExpand.end()) { - itemToExpand.push_back(pParent); - } - } - } - } + uint32_t status = Thread->data (COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt(); + if (expandNewMessages && IS_MSG_UNREAD(status)) { + QTreeWidgetItem *pParent = Thread; + while ((pParent = pParent->parent()) != NULL) { + if (std::find(itemToExpand.begin(), itemToExpand.end(), pParent) == itemToExpand.end()) { + itemToExpand.push_back(pParent); + } + } + } + } #ifdef DEBUG_FORUMS - std::cerr << "GxsForumsDialog::FillThreads() done" << std::endl; + std::cerr << "GxsForumsDialog::FillThreads() done" << std::endl; #endif } void GxsForumsDialog::FillChildren(QTreeWidgetItem *Parent, QTreeWidgetItem *NewParent, bool expandNewMessages, QList &itemToExpand) { - int Index = 0; - int NewIndex; - int NewCount = NewParent->childCount(); + int Index = 0; + int NewIndex; + int NewCount = NewParent->childCount(); - QTreeWidgetItem *Child; - QTreeWidgetItem *NewChild; + QTreeWidgetItem *Child; + QTreeWidgetItem *NewChild; - // delete not existing - while (Index < Parent->childCount ()) { - Child = Parent->child (Index); + // delete not existing + while (Index < Parent->childCount ()) { + Child = Parent->child (Index); - // search existing new child - int Found = -1; - int Count = NewParent->childCount(); - for (NewIndex = 0; NewIndex < Count; NewIndex++) { - NewChild = NewParent->child (NewIndex); - if (NewChild->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID) == Child->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID)) { - // found it - Found = Index; - break; - } - } - if (Found >= 0) { - Index++; - } else { - delete (Parent->takeChild (Index)); - } - } + // search existing new child + int Found = -1; + int Count = NewParent->childCount(); + for (NewIndex = 0; NewIndex < Count; NewIndex++) { + NewChild = NewParent->child (NewIndex); + if (NewChild->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID) == Child->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID)) { + // found it + Found = Index; + break; + } + } + if (Found >= 0) { + Index++; + } else { + delete (Parent->takeChild (Index)); + } + } - // iterate all new children - for (NewIndex = 0; NewIndex < NewCount; NewIndex++) { - NewChild = NewParent->child (NewIndex); + // iterate all new children + for (NewIndex = 0; NewIndex < NewCount; NewIndex++) { + NewChild = NewParent->child (NewIndex); - // search existing child - int Found = -1; - int Count = Parent->childCount(); - for (Index = 0; Index < Count; Index++) { - Child = Parent->child (Index); - if (Child->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID) == NewChild->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID)) { - // found it - Found = Index; - break; - } - } + // search existing child + int Found = -1; + int Count = Parent->childCount(); + for (Index = 0; Index < Count; Index++) { + Child = Parent->child (Index); + if (Child->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID) == NewChild->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID)) { + // found it + Found = Index; + break; + } + } - if (Found >= 0) { - // set child data - int i; - for (i = 0; i < COLUMN_THREAD_COUNT; i++) { - Child->setText (i, NewChild->text (i)); - } - for (i = 0; i < ROLE_THREAD_COUNT; i++) { - Child->setData (COLUMN_THREAD_DATA, Qt::UserRole + i, NewChild->data (COLUMN_THREAD_DATA, Qt::UserRole + i)); - } + if (Found >= 0) { + // set child data + int i; + for (i = 0; i < COLUMN_THREAD_COUNT; i++) { + Child->setText (i, NewChild->text (i)); + } + for (i = 0; i < ROLE_THREAD_COUNT; i++) { + Child->setData (COLUMN_THREAD_DATA, Qt::UserRole + i, NewChild->data (COLUMN_THREAD_DATA, Qt::UserRole + i)); + } - // fill recursive - FillChildren (Child, NewChild, expandNewMessages, itemToExpand); - } else { - // add new child - Child = NewParent->takeChild(NewIndex); - Parent->addChild (Child); - NewIndex--; - NewCount--; - } + // fill recursive + FillChildren (Child, NewChild, expandNewMessages, itemToExpand); + } else { + // add new child + Child = NewParent->takeChild(NewIndex); + Parent->addChild (Child); + NewIndex--; + NewCount--; + } - uint32_t status = Child->data (COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt(); - if (expandNewMessages && IS_MSG_UNREAD(status)) { - QTreeWidgetItem *pParent = Child; - while ((pParent = pParent->parent()) != NULL) { - if (std::find(itemToExpand.begin(), itemToExpand.end(), pParent) == itemToExpand.end()) { - itemToExpand.push_back(pParent); - } - } - } - } + uint32_t status = Child->data (COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt(); + if (expandNewMessages && IS_MSG_UNREAD(status)) { + QTreeWidgetItem *pParent = Child; + while ((pParent = pParent->parent()) != NULL) { + if (std::find(itemToExpand.begin(), itemToExpand.end(), pParent) == itemToExpand.end()) { + itemToExpand.push_back(pParent); + } + } + } + } } QString GxsForumsDialog::titleFromInfo(const RsMsgMetaData &meta) { - // NOTE - NOTE SURE HOW THIS WILL WORK! + // NOTE - NOTE SURE HOW THIS WILL WORK! #ifdef TOGXS - if (meta.mMsgStatus & RS_DISTRIB_MISSING_MSG) { - return QApplication::translate("GxsForumsDialog", "[ ... Missing Message ... ]"); - } + if (meta.mMsgStatus & RS_DISTRIB_MISSING_MSG) { + return QApplication::translate("GxsForumsDialog", "[ ... Missing Message ... ]"); + } #endif - return QString::fromUtf8(meta.mMsgName.c_str()); + return QString::fromUtf8(meta.mMsgName.c_str()); } QString GxsForumsDialog::messageFromInfo(const RsGxsForumMsg &msg) { #ifdef TOGXS - if (msg.mMeta.mMsgStatus & RS_DISTRIB_MISSING_MSG) { - return QApplication::translate("GxsForumsDialog", "Placeholder for missing Message"); - } + if (msg.mMeta.mMsgStatus & RS_DISTRIB_MISSING_MSG) { + return QApplication::translate("GxsForumsDialog", "Placeholder for missing Message"); + } #endif - return QString::fromUtf8(msg.mMsg.c_str()); + return QString::fromUtf8(msg.mMsg.c_str()); } void GxsForumsDialog::insertPost() { - if ((mCurrForumId == "") || (mCurrThreadId == "")) - { - ui.postText->setText(""); - ui.threadTitle->setText(""); - ui.previousButton->setEnabled(false); - ui.nextButton->setEnabled(false); - ui.newmessageButton->setEnabled (false); - return; - } - - QTreeWidgetItem *curr = ui.threadTreeWidget->currentItem(); - if (curr) { - QTreeWidgetItem *Parent = curr->parent (); - int Index = Parent ? Parent->indexOfChild (curr) : ui.threadTreeWidget->indexOfTopLevelItem (curr); - int Count = Parent ? Parent->childCount () : ui.threadTreeWidget->topLevelItemCount (); - ui.previousButton->setEnabled (Index > 0); - ui.nextButton->setEnabled (Index < Count - 1); - } else { - // there is something wrong - ui.previousButton->setEnabled(false); - ui.nextButton->setEnabled(false); + if ((mCurrForumId == "") || (mCurrThreadId == "")) + { + ui.postText->setText(""); + ui.threadTitle->setText(""); + ui.previousButton->setEnabled(false); + ui.nextButton->setEnabled(false); + ui.newmessageButton->setEnabled (false); return; - } + } - ui.newmessageButton->setEnabled (IS_GROUP_SUBSCRIBED(subscribeFlags) && mCurrThreadId.empty() == false); + QTreeWidgetItem *curr = ui.threadTreeWidget->currentItem(); + if (curr) { + QTreeWidgetItem *Parent = curr->parent (); + int Index = Parent ? Parent->indexOfChild (curr) : ui.threadTreeWidget->indexOfTopLevelItem (curr); + int Count = Parent ? Parent->childCount () : ui.threadTreeWidget->topLevelItemCount (); + ui.previousButton->setEnabled (Index > 0); + ui.nextButton->setEnabled (Index < Count - 1); + } else { + // there is something wrong + ui.previousButton->setEnabled(false); + ui.nextButton->setEnabled(false); + return; + } + + ui.newmessageButton->setEnabled (IS_GROUP_SUBSCRIBED(subscribeFlags) && mCurrThreadId.empty() == false); /* blank text, incase we get nothing */ - ui.postText->setText(""); + ui.postText->setText(""); /* request Post */ RsGxsGrpMsgIdPair postId = std::make_pair(mCurrForumId, mCurrThreadId); @@ -1171,12 +1160,10 @@ void GxsForumsDialog::insertPost() } - - void GxsForumsDialog::insertPostData(const RsGxsForumMsg &msg) { /* As some time has elapsed since request - check that this is still the current msg. - * otherwise, another request will fill the data + * otherwise, another request will fill the data */ if ((msg.mMeta.mGroupId != mCurrForumId) || (msg.mMeta.mMsgId != mCurrThreadId)) @@ -1191,31 +1178,23 @@ void GxsForumsDialog::insertPostData(const RsGxsForumMsg &msg) return; } - QTreeWidgetItem *curr = ui.threadTreeWidget->currentItem(); + QTreeWidgetItem *curr = ui.threadTreeWidget->currentItem(); - bool bSetToReadOnActive = Settings->getForumMsgSetToReadOnActivate(); - uint32_t status = curr->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt(); + bool bSetToReadOnActive = Settings->getForumMsgSetToReadOnActivate(); + uint32_t status = curr->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt(); - QList Row; - Row.append(curr); + QList Row; + Row.append(curr); - if (bSetToReadOnActive && IS_MSG_UNREAD(status)) - { - setMsgReadStatus(Row, true); - } - - QString text; + if (bSetToReadOnActive && IS_MSG_UNREAD(status)) { - QDateTime qtime; - qtime.setTime_t(msg.mMeta.mPublishTs); - - text = qtime.toString("yyyy-MM-dd hh:mm:ss"); - - ui.time_label->setText(text); + setMsgReadStatus(Row, true); } - + +//#AFTER MERGE ui.time_label->setText(DateTime::formatLongDateTime(msg.mMeta.mPublishTs)); + std::string authorName = rsPeers->getPeerName(msg.mMeta.mAuthorId); - text = QString::fromUtf8(authorName.c_str()); + QString text = QString::fromUtf8(authorName.c_str()); if (text.isEmpty()) { @@ -1223,51 +1202,48 @@ void GxsForumsDialog::insertPostData(const RsGxsForumMsg &msg) } else { - ui.by_label->setText( tr("By") + " " + text ); - } + ui.by_label->setText( tr("By") + " " + text ); + } - QString extraTxt = RsHtml().formatText(ui.postText->document(), messageFromInfo(msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS); - - ui.postText->setHtml(extraTxt); - ui.threadTitle->setText(titleFromInfo(msg.mMeta)); - + QString extraTxt = RsHtml().formatText(ui.postText->document(), messageFromInfo(msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS); + ui.postText->setHtml(extraTxt); + ui.threadTitle->setText(titleFromInfo(msg.mMeta)); } - -void GxsForumsDialog::previousMessage () +void GxsForumsDialog::previousMessage() { - QTreeWidgetItem *Item = ui.threadTreeWidget->currentItem (); - if (Item == NULL) { - return; - } + QTreeWidgetItem *Item = ui.threadTreeWidget->currentItem (); + if (Item == NULL) { + return; + } - QTreeWidgetItem *Parent = Item->parent (); - int Index = Parent ? Parent->indexOfChild (Item) : ui.threadTreeWidget->indexOfTopLevelItem (Item); - if (Index > 0) { - QTreeWidgetItem *Previous = Parent ? Parent->child (Index - 1) : ui.threadTreeWidget->topLevelItem (Index - 1); - if (Previous) { - ui.threadTreeWidget->setCurrentItem (Previous); - } - } + QTreeWidgetItem *Parent = Item->parent (); + int Index = Parent ? Parent->indexOfChild (Item) : ui.threadTreeWidget->indexOfTopLevelItem (Item); + if (Index > 0) { + QTreeWidgetItem *Previous = Parent ? Parent->child (Index - 1) : ui.threadTreeWidget->topLevelItem (Index - 1); + if (Previous) { + ui.threadTreeWidget->setCurrentItem (Previous); + } + } } -void GxsForumsDialog::nextMessage () +void GxsForumsDialog::nextMessage() { - QTreeWidgetItem *Item = ui.threadTreeWidget->currentItem (); - if (Item == NULL) { - return; - } + QTreeWidgetItem *Item = ui.threadTreeWidget->currentItem (); + if (Item == NULL) { + return; + } - QTreeWidgetItem *Parent = Item->parent (); - int Index = Parent ? Parent->indexOfChild (Item) : ui.threadTreeWidget->indexOfTopLevelItem (Item); - int Count = Parent ? Parent->childCount () : ui.threadTreeWidget->topLevelItemCount (); - if (Index < Count - 1) { - QTreeWidgetItem *Next = Parent ? Parent->child (Index + 1) : ui.threadTreeWidget->topLevelItem (Index + 1); - if (Next) { - ui.threadTreeWidget->setCurrentItem (Next); - } - } + QTreeWidgetItem *Parent = Item->parent (); + int Index = Parent ? Parent->indexOfChild (Item) : ui.threadTreeWidget->indexOfTopLevelItem (Item); + int Count = Parent ? Parent->childCount () : ui.threadTreeWidget->topLevelItemCount (); + if (Index < Count - 1) { + QTreeWidgetItem *Next = Parent ? Parent->child (Index + 1) : ui.threadTreeWidget->topLevelItem (Index + 1); + if (Next) { + ui.threadTreeWidget->setCurrentItem (Next); + } + } } void GxsForumsDialog::downloadAllFiles() @@ -1286,23 +1262,34 @@ void GxsForumsDialog::downloadAllFiles() void GxsForumsDialog::nextUnreadMessage() { - QTreeWidgetItem* currentItem = ui.threadTreeWidget->currentItem(); - if( !currentItem ) - { - currentItem = ui.threadTreeWidget->topLevelItem(0); - if( !currentItem ) - return; - } + QTreeWidgetItem *currentItem = ui.threadTreeWidget->currentItem(); - do - { - uint32_t status = currentItem->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt(); - if( IS_MSG_UNREAD(status) ) - { - ui.threadTreeWidget->setCurrentItem(currentItem); - return; - } - } while( (currentItem = ui.threadTreeWidget->itemBelow(currentItem)) != NULL ); + while (TRUE) { + QTreeWidgetItemIterator itemIterator = currentItem ? QTreeWidgetItemIterator(currentItem, QTreeWidgetItemIterator::NotHidden) : QTreeWidgetItemIterator(ui.threadTreeWidget, QTreeWidgetItemIterator::NotHidden); + + QTreeWidgetItem *item; + while ((item = *itemIterator) != NULL) { + itemIterator++; + + if (item == currentItem) { + continue; + } + + uint32_t status = item->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt(); + if (IS_MSG_UNREAD(status)) { + ui.threadTreeWidget->setCurrentItem(item); + ui.threadTreeWidget->scrollToItem(item, QAbstractItemView::EnsureVisible); + return; + } + } + + if (currentItem == NULL) { + break; + } + + /* start from top */ + currentItem = NULL; + } } // TODO @@ -1326,258 +1313,253 @@ void GxsForumsDialog::removemessage() the messages tree is single selected, but who knows ... */ int GxsForumsDialog::getSelectedMsgCount(QList *pRows, QList *pRowsRead, QList *pRowsUnread) { - if (pRowsRead) pRowsRead->clear(); - if (pRowsUnread) pRowsUnread->clear(); + if (pRowsRead) pRowsRead->clear(); + if (pRowsUnread) pRowsUnread->clear(); - QList selectedItems = ui.threadTreeWidget->selectedItems(); - for(QList::iterator it = selectedItems.begin(); it != selectedItems.end(); it++) { - if (pRows) pRows->append(*it); - if (pRowsRead || pRowsUnread) { - uint32_t status = (*it)->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt(); - if (IS_MSG_UNREAD(status)) { - if (pRowsUnread) pRowsUnread->append(*it); - } else { - if (pRowsRead) pRowsRead->append(*it); - } - } - } + QList selectedItems = ui.threadTreeWidget->selectedItems(); + for(QList::iterator it = selectedItems.begin(); it != selectedItems.end(); it++) { + if (pRows) pRows->append(*it); + if (pRowsRead || pRowsUnread) { + uint32_t status = (*it)->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt(); + if (IS_MSG_UNREAD(status)) { + if (pRowsUnread) pRowsUnread->append(*it); + } else { + if (pRowsRead) pRowsRead->append(*it); + } + } + } - return selectedItems.size(); + return selectedItems.size(); } void GxsForumsDialog::setMsgReadStatus(QList &Rows, bool bRead) { - QList::iterator Row; - std::list changedItems; + QList::iterator Row; + std::list changedItems; - inMsgAsReadUnread = true; + inMsgAsReadUnread = true; - for (Row = Rows.begin(); Row != Rows.end(); Row++) { - if ((*Row)->data(COLUMN_THREAD_DATA, ROLE_THREAD_MISSING).toBool()) { - /* Missing message */ - continue; - } + for (Row = Rows.begin(); Row != Rows.end(); Row++) { + if ((*Row)->data(COLUMN_THREAD_DATA, ROLE_THREAD_MISSING).toBool()) { + /* Missing message */ + continue; + } - uint32_t status = (*Row)->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt(); + uint32_t status = (*Row)->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt(); - uint32_t statusNew = (status & ~GXS_SERV::GXS_MSG_STATUS_UNREAD); // orig status, without UNREAD. - if (!bRead) { - statusNew |= GXS_SERV::GXS_MSG_STATUS_UNREAD; - } + uint32_t statusNew = (status & ~GXS_SERV::GXS_MSG_STATUS_UNREAD); // orig status, without UNREAD. + if (!bRead) { + statusNew |= GXS_SERV::GXS_MSG_STATUS_UNREAD; + } - if (IS_MSG_UNREAD(status) == bRead) // is it different? - { - std::string msgId = (*Row)->data(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID).toString().toStdString(); + if (IS_MSG_UNREAD(status) == bRead) // is it different? + { + std::string msgId = (*Row)->data(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID).toString().toStdString(); - // NB: MUST BE PART OF ACTIVE THREAD--- OR ELSE WE MUST STORE GROUPID SOMEWHERE!. - // LIKE THIS BELOW... - //std::string grpId = (*Row)->data(COLUMN_THREAD_DATA, ROLE_THREAD_GROUPID).toString().toStdString(); + // NB: MUST BE PART OF ACTIVE THREAD--- OR ELSE WE MUST STORE GROUPID SOMEWHERE!. + // LIKE THIS BELOW... + //std::string grpId = (*Row)->data(COLUMN_THREAD_DATA, ROLE_THREAD_GROUPID).toString().toStdString(); - RsGxsGrpMsgIdPair msgPair = std::make_pair(mCurrForumId, msgId); + RsGxsGrpMsgIdPair msgPair = std::make_pair(mCurrForumId, msgId); - uint32_t token; - rsGxsForums->setMessageReadStatus(token, msgPair, bRead); + uint32_t token; + rsGxsForums->setMessageReadStatus(token, msgPair, bRead); - (*Row)->setData(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS, statusNew); + (*Row)->setData(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS, statusNew); - QTreeWidgetItem *parentItem = *Row; - while (parentItem->parent()) { - parentItem = parentItem->parent(); - } - if (std::find(changedItems.begin(), changedItems.end(), parentItem) == changedItems.end()) { - changedItems.push_back(parentItem); - } - } - } + QTreeWidgetItem *parentItem = *Row; + while (parentItem->parent()) { + parentItem = parentItem->parent(); + } + if (std::find(changedItems.begin(), changedItems.end(), parentItem) == changedItems.end()) { + changedItems.push_back(parentItem); + } + } + } - inMsgAsReadUnread = false; + inMsgAsReadUnread = false; - if (changedItems.size()) { - for (std::list::iterator it = changedItems.begin(); it != changedItems.end(); it++) { - CalculateIconsAndFonts(*it); - } - updateMessageSummaryList(mCurrForumId); - } + if (changedItems.size()) { + for (std::list::iterator it = changedItems.begin(); it != changedItems.end(); it++) { + CalculateIconsAndFonts(*it); + } + updateMessageSummaryList(mCurrForumId); + } } void GxsForumsDialog::markMsgAsReadUnread (bool bRead, bool bChildren, bool bForum) { - if (mCurrForumId.empty() || !IS_GROUP_SUBSCRIBED(subscribeFlags)) { - return; - } + if (mCurrForumId.empty() || !IS_GROUP_SUBSCRIBED(subscribeFlags)) { + return; + } - /* get selected messages */ - QList Rows; - if (bForum) { - int itemCount = ui.threadTreeWidget->topLevelItemCount(); - for (int item = 0; item < itemCount; item++) { - Rows.push_back(ui.threadTreeWidget->topLevelItem(item)); - } - } else { - getSelectedMsgCount (&Rows, NULL, NULL); - } + /* get selected messages */ + QList Rows; + if (bForum) { + int itemCount = ui.threadTreeWidget->topLevelItemCount(); + for (int item = 0; item < itemCount; item++) { + Rows.push_back(ui.threadTreeWidget->topLevelItem(item)); + } + } else { + getSelectedMsgCount (&Rows, NULL, NULL); + } - if (bChildren) { - /* add children */ - QList AllRows; + if (bChildren) { + /* add children */ + QList AllRows; - while (Rows.isEmpty() == false) { - QTreeWidgetItem *pRow = Rows.takeFirst(); + while (Rows.isEmpty() == false) { + QTreeWidgetItem *pRow = Rows.takeFirst(); - /* add only items with the right state or with not RSGXS_MSG_STATUS_READ */ - uint32_t status = pRow->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt(); - if (IS_MSG_UNREAD(status) == bRead) { - AllRows.append(pRow); - } + /* add only items with the right state or with not RSGXS_MSG_STATUS_READ */ + uint32_t status = pRow->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt(); + if (IS_MSG_UNREAD(status) == bRead) { + AllRows.append(pRow); + } - for (int i = 0; i < pRow->childCount(); i++) { - /* add child to main list and let the main loop do the work */ - Rows.append(pRow->child(i)); - } - } + for (int i = 0; i < pRow->childCount(); i++) { + /* add child to main list and let the main loop do the work */ + Rows.append(pRow->child(i)); + } + } - if (AllRows.isEmpty()) { - /* nothing to do */ - return; - } + if (AllRows.isEmpty()) { + /* nothing to do */ + return; + } - setMsgReadStatus(AllRows, bRead); + setMsgReadStatus(AllRows, bRead); - return; - } + return; + } - setMsgReadStatus(Rows, bRead); + setMsgReadStatus(Rows, bRead); } void GxsForumsDialog::markMsgAsRead() { - markMsgAsReadUnread(true, false, false); + markMsgAsReadUnread(true, false, false); } void GxsForumsDialog::markMsgAsReadChildren() { - markMsgAsReadUnread(true, true, false); + markMsgAsReadUnread(true, true, false); } void GxsForumsDialog::markMsgAsReadAll() { - markMsgAsReadUnread(true, true, true); + markMsgAsReadUnread(true, true, true); } void GxsForumsDialog::markMsgAsUnread() { - markMsgAsReadUnread(false, false, false); + markMsgAsReadUnread(false, false, false); } void GxsForumsDialog::markMsgAsUnreadChildren() { - markMsgAsReadUnread(false, true, false); + markMsgAsReadUnread(false, true, false); } void GxsForumsDialog::markMsgAsUnreadAll() { - markMsgAsReadUnread(false, true, true); + markMsgAsReadUnread(false, true, true); } void GxsForumsDialog::copyForumLink() { - if (mCurrForumId.empty()) { - return; - } + if (mCurrForumId.empty()) { + return; + } // THIS CODE CALLS getForumInfo() to verify that the Ids are valid. // As we are switching to Request/Response this is now harder to do... // So not bothering any more - shouldn't be necessary. // IF we get errors - fix them, rather than patching here. #if 0 - ForumInfo fi; - if (rsGxsForums->getForumInfo(mCurrForumId, fi)) { - RetroShareLink link; - if (link.createForum(fi.forumId, "")) { - QList urls; - urls.push_back(link); - RSLinkClipboard::copyLinks(urls); - } - } + ForumInfo fi; + if (rsGxsForums->getForumInfo(mCurrForumId, fi)) { + RetroShareLink link; + if (link.createForum(fi.forumId, "")) { + QList urls; + urls.push_back(link); + RSLinkClipboard::copyLinks(urls); + } + } #endif { - RetroShareLink link; - if (link.createForum(mCurrForumId, "")) + RetroShareLink link; + if (link.createForum(mCurrForumId, "")) { - QList urls; - urls.push_back(link); - RSLinkClipboard::copyLinks(urls); + QList urls; + urls.push_back(link); + RSLinkClipboard::copyLinks(urls); } } } - - - void GxsForumsDialog::copyMessageLink() { - if (mCurrForumId.empty() || mCurrThreadId.empty()) { - return; - } + if (mCurrForumId.empty() || mCurrThreadId.empty()) { + return; + } // SEE NOTE In fn above. #if 0 - ForumInfo fi; - if (rsGxsForums->getForumInfo(mCurrForumId, fi)) { - RetroShareLink link; - if (link.createForum(mCurrForumId, mCurrThreadId)) { - QList urls; - urls.push_back(link); - RSLinkClipboard::copyLinks(urls); - } - } + ForumInfo fi; + if (rsGxsForums->getForumInfo(mCurrForumId, fi)) { + RetroShareLink link; + if (link.createForum(mCurrForumId, mCurrThreadId)) { + QList urls; + urls.push_back(link); + RSLinkClipboard::copyLinks(urls); + } + } #endif { - RetroShareLink link; - if (link.createForum(mCurrForumId, mCurrThreadId)) + RetroShareLink link; + if (link.createForum(mCurrForumId, mCurrThreadId)) { - QList urls; - urls.push_back(link); - RSLinkClipboard::copyLinks(urls); + QList urls; + urls.push_back(link); + RSLinkClipboard::copyLinks(urls); } } } - void GxsForumsDialog::newforum() { - GxsForumGroupDialog cf (mForumQueue, this); - //cf.newGroup(); + GxsForumGroupDialog cf (mForumQueue, this); + //cf.newGroup(); - cf.exec (); + cf.exec (); } void GxsForumsDialog::createmessage() { - if (mCurrForumId.empty () || !IS_GROUP_SUBSCRIBED(subscribeFlags)) { - return; - } + if (mCurrForumId.empty () || !IS_GROUP_SUBSCRIBED(subscribeFlags)) { + return; + } - CreateGxsForumMsg *cfm = new CreateGxsForumMsg(mCurrForumId, mCurrThreadId); - cfm->show(); + CreateGxsForumMsg *cfm = new CreateGxsForumMsg(mCurrForumId, mCurrThreadId); + cfm->show(); - /* window will destroy itself! */ + /* window will destroy itself! */ } void GxsForumsDialog::createthread() { - if (mCurrForumId.empty ()) { - QMessageBox::information(this, tr("RetroShare"), tr("No Forum Selected!")); - return; - } + if (mCurrForumId.empty ()) { + QMessageBox::information(this, tr("RetroShare"), tr("No Forum Selected!")); + return; + } - CreateGxsForumMsg *cfm = new CreateGxsForumMsg(mCurrForumId, ""); - cfm->setWindowTitle(tr("Start New Thread")); - cfm->show(); + CreateGxsForumMsg *cfm = new CreateGxsForumMsg(mCurrForumId, ""); + cfm->show(); - /* window will destroy itself! */ + /* window will destroy itself! */ } void GxsForumsDialog::subscribeToForum() @@ -1595,68 +1577,65 @@ void GxsForumsDialog::forumSubscribe(bool subscribe) if (mCurrForumId.empty()) { return; } - + uint32_t token; rsGxsForums->subscribeToGroup(token, mCurrForumId, subscribe); } void GxsForumsDialog::showForumDetails() { - if (mCurrForumId.empty()) { - return; - } + if (mCurrForumId.empty()) { + return; + } - RsGxsForumGroup grp; - grp.mMeta.mGroupId = mCurrForumId; + RsGxsForumGroup grp; + grp.mMeta.mGroupId = mCurrForumId; - GxsForumGroupDialog cf(grp, this); + GxsForumGroupDialog cf(grp, this); - cf.exec (); + cf.exec (); } void GxsForumsDialog::editForumDetails() { - if (mCurrForumId.empty()) { - return; - } + if (mCurrForumId.empty()) { + return; + } - RsGxsForumGroup grp; - grp.mMeta.mGroupId = mCurrForumId; + RsGxsForumGroup grp; + grp.mMeta.mGroupId = mCurrForumId; - GxsForumGroupDialog cf(grp, this); + GxsForumGroupDialog cf(grp, this); - //GxsForumGroupDialog cf (mForumQueue, this, mCurrForumId, GXS_GROUP_DIALOG_EDIT_MODE); + //GxsForumGroupDialog cf (mForumQueue, this, mCurrForumId, GXS_GROUP_DIALOG_EDIT_MODE); - cf.exec (); + cf.exec (); } static QString buildReplyHeader(const RsMsgMetaData &meta) { - RetroShareLink link; - link.createMessage(meta.mAuthorId, ""); - QString from = link.toHtml(); + RetroShareLink link; + link.createMessage(meta.mAuthorId, ""); + QString from = link.toHtml(); - QDateTime qtime; - qtime.setTime_t(meta.mPublishTs); + QString header = QString("-----%1-----").arg(QApplication::translate("GxsForumsDialog", "Original Message")); + header += QString("
%1: %2
").arg(QApplication::translate("GxsForumsDialog", "From"), from); - QString header = QString("-----%1-----").arg(QApplication::translate("GxsForumsDialog", "Original Message")); - header += QString("
%1: %2
").arg(QApplication::translate("GxsForumsDialog", "From"), from); +//#AFTER MERGE header += QString("
%1: %2
").arg(QApplication::translate("GxsForumsDialog", "Sent"), DateTime::formatLongDateTime(meta.mPublishTs)); + header += QString("%1: %2

").arg(QApplication::translate("GxsForumsDialog", "Subject"), QString::fromUtf8(meta.mMsgName.c_str())); + header += "
"; - header += QString("
%1: %2
").arg(QApplication::translate("GxsForumsDialog", "Sent"), qtime.toString(Qt::SystemLocaleLongDate)); - header += QString("%1: %2

").arg(QApplication::translate("GxsForumsDialog", "Subject"), QString::fromUtf8(meta.mMsgName.c_str())); - header += "
"; +//#AFTER MERGE header += QApplication::translate("GxsForumsDialog", "On %1, %2 wrote:").arg(DateTime::formatDateTime(meta.mPublishTs), from); - header += QApplication::translate("GxsForumsDialog", "On %1, %2 wrote:").arg(qtime.toString(Qt::SystemLocaleShortDate), from); - - return header; + return header; } void GxsForumsDialog::replytomessage() { - if (mCurrForumId.empty() || mCurrThreadId.empty()) { - QMessageBox::information(this, tr("RetroShare"),tr("You cant reply to a non-existant Message")); - return; - } + if (mCurrForumId.empty() || mCurrThreadId.empty()) { + QMessageBox::information(this, tr("RetroShare"),tr("You cant reply to a non-existant Message")); + return; + } RsGxsGrpMsgIdPair postId = std::make_pair(mCurrForumId, mCurrThreadId); requestMsgData_ReplyMessage(postId); @@ -1672,210 +1651,210 @@ void GxsForumsDialog::replyMessageData(const RsGxsForumMsg &msg) } // NB: TODO REMOVE rsPeers references. - if (rsPeers->getPeerName(msg.mMeta.mAuthorId) !="") - { - MessageComposer *nMsgDialog = MessageComposer::newMsg(); - nMsgDialog->setTitleText(QString::fromUtf8(msg.mMeta.mMsgName.c_str()), MessageComposer::REPLY); + if (rsPeers->getPeerName(msg.mMeta.mAuthorId) !="") + { + MessageComposer *nMsgDialog = MessageComposer::newMsg(); + nMsgDialog->setTitleText(QString::fromUtf8(msg.mMeta.mMsgName.c_str()), MessageComposer::REPLY); - nMsgDialog->setQuotedMsg(QString::fromUtf8(msg.mMsg.c_str()), buildReplyHeader(msg.mMeta)); + nMsgDialog->setQuotedMsg(QString::fromUtf8(msg.mMsg.c_str()), buildReplyHeader(msg.mMeta)); - nMsgDialog->addRecipient(MessageComposer::TO, msg.mMeta.mAuthorId, false); - nMsgDialog->show(); - nMsgDialog->activateWindow(); + nMsgDialog->addRecipient(MessageComposer::TO, msg.mMeta.mAuthorId, false); + nMsgDialog->show(); + nMsgDialog->activateWindow(); - /* window will destroy itself! */ - } - else - { - QMessageBox::information(this, tr("RetroShare"),tr("You cant reply to an Anonymous Author")); - } + /* window will destroy itself! */ + } + else + { + QMessageBox::information(this, tr("RetroShare"),tr("You cant reply to an Anonymous Author")); + } } void GxsForumsDialog::changedViewBox() { - if (m_bProcessSettings) { - return; - } + if (m_bProcessSettings) { + return; + } - // save index - Settings->setValueToGroup("GxsForumsDialog", "viewBox", ui.viewBox->currentIndex()); + // save index + Settings->setValueToGroup("GxsForumsDialog", "viewBox", ui.viewBox->currentIndex()); - insertThreads(); + insertThreads(); } -void GxsForumsDialog::filterColumnChanged() +void GxsForumsDialog::filterColumnChanged(int column) { - if (m_bProcessSettings) { - return; - } + if (m_bProcessSettings) { + return; + } - int filterColumn = FilterColumnFromComboBox(ui.filterColumnComboBox->currentIndex()); - if (filterColumn == COLUMN_THREAD_CONTENT) { - // need content ... refill - insertThreads(); - } else { - filterItems(ui.filterLineEdit->text()); - } + if (column == COLUMN_THREAD_CONTENT) { + // need content ... refill + insertThreads(); + } else { + filterItems(ui.filterLineEdit->text()); + } - // save index - Settings->setValueToGroup("GxsForumsDialog", "filterColumn", filterColumn); + // save index + Settings->setValueToGroup("GxsForumsDialog", "filterColumn", column); } void GxsForumsDialog::filterItems(const QString& text) { - int filterColumn = FilterColumnFromComboBox(ui.filterColumnComboBox->currentIndex()); +//#AFTER MERGE int filterColumn = ui.filterLineEdit->currentFilter(); + int filterColumn = COLUMN_THREAD_TITLE; - int nCount = ui.threadTreeWidget->topLevelItemCount (); - for (int nIndex = 0; nIndex < nCount; nIndex++) { - filterItem(ui.threadTreeWidget->topLevelItem(nIndex), text, filterColumn); - } + int nCount = ui.threadTreeWidget->topLevelItemCount (); + for (int nIndex = 0; nIndex < nCount; nIndex++) { + filterItem(ui.threadTreeWidget->topLevelItem(nIndex), text, filterColumn); + } } void GxsForumsDialog::shareKey() { - ShareKey shareUi(this, 0, mCurrForumId, FORUM_KEY_SHARE); - shareUi.exec(); + ShareKey shareUi(this, 0, mCurrForumId, FORUM_KEY_SHARE); + shareUi.exec(); } bool GxsForumsDialog::filterItem(QTreeWidgetItem *pItem, const QString &text, int filterColumn) { - bool bVisible = true; + bool bVisible = true; - if (text.isEmpty() == false) { - if (pItem->text(filterColumn).contains(text, Qt::CaseInsensitive) == false) { - bVisible = false; - } - } + if (text.isEmpty() == false) { + if (pItem->text(filterColumn).contains(text, Qt::CaseInsensitive) == false) { + bVisible = false; + } + } - int nVisibleChildCount = 0; - int nCount = pItem->childCount(); - for (int nIndex = 0; nIndex < nCount; nIndex++) { - if (filterItem(pItem->child(nIndex), text, filterColumn)) { - nVisibleChildCount++; - } - } + int nVisibleChildCount = 0; + int nCount = pItem->childCount(); + for (int nIndex = 0; nIndex < nCount; nIndex++) { + if (filterItem(pItem->child(nIndex), text, filterColumn)) { + nVisibleChildCount++; + } + } - if (bVisible || nVisibleChildCount) { - pItem->setHidden(false); - } else { - pItem->setHidden(true); - } + if (bVisible || nVisibleChildCount) { + pItem->setHidden(false); + } else { + pItem->setHidden(true); + } - return (bVisible || nVisibleChildCount); + return (bVisible || nVisibleChildCount); } void GxsForumsDialog::updateMessageSummaryList(std::string forumId) { - QTreeWidgetItem *items[2] = { yourForums, subscribedForums }; + QTreeWidgetItem *items[2] = { yourForums, subscribedForums }; - for (int item = 0; item < 2; item++) { - int child; - int childCount = items[item]->childCount(); - for (child = 0; child < childCount; child++) { - QTreeWidgetItem *childItem = items[item]->child(child); - std::string childId = ui.forumTreeWidget->itemId(childItem).toStdString(); - if (childId.empty()) { - continue; - } + for (int item = 0; item < 2; item++) { + int child; + int childCount = items[item]->childCount(); + for (child = 0; child < childCount; child++) { + QTreeWidgetItem *childItem = items[item]->child(child); + std::string childId = ui.forumTreeWidget->itemId(childItem).toStdString(); + if (childId.empty()) { + continue; + } - if (forumId.empty() || childId == forumId) { - /* calculate unread messages */ - unsigned int newMessageCount = 0; - unsigned int unreadMessageCount = 0; - //rsGxsForums->getMessageCount(childId, newMessageCount, unreadMessageCount); - std::cerr << "IMPLEMENT rsGxsForums->getMessageCount()"; - std::cerr << std::endl; + if (forumId.empty() || childId == forumId) { + /* calculate unread messages */ + unsigned int newMessageCount = 0; + unsigned int unreadMessageCount = 0; - ui.forumTreeWidget->setUnreadCount(childItem, unreadMessageCount); + //rsGxsForums->getMessageCount(childId, newMessageCount, unreadMessageCount); - if (forumId.empty() == false) { - /* Calculate only this forum */ - break; - } - } - } - } + std::cerr << "IMPLEMENT rsGxsForums->getMessageCount()"; + std::cerr << std::endl; + + ui.forumTreeWidget->setUnreadCount(childItem, unreadMessageCount); + + if (forumId.empty() == false) { + /* Calculate only this forum */ + break; + } + } + } + } } bool GxsForumsDialog::navigate(const std::string& forumId, const std::string& msgId) { - if (forumId.empty()) { - return false; - } + if (forumId.empty()) { + return false; + } - if (ui.forumTreeWidget->activateId(QString::fromStdString(forumId), msgId.empty()) == NULL) { - return false; - } + if (ui.forumTreeWidget->activateId(QString::fromStdString(forumId), msgId.empty()) == NULL) { + return false; + } - /* Threads are filled in changedForum */ - if (mCurrForumId != forumId) { - return false; - } + /* Threads are filled in changedForum */ + if (mCurrForumId != forumId) { + return false; + } - if (msgId.empty()) { - return true; - } + if (msgId.empty()) { + return true; + } - if (mThreadLoading) { - mThreadLoad.FocusMsgId = msgId; - return true; - } + if (mThreadLoading) { + mThreadLoad.FocusMsgId = msgId; + return true; + } - /* Search exisiting item */ - QTreeWidgetItemIterator itemIterator(ui.threadTreeWidget); - QTreeWidgetItem *item = NULL; - while ((item = *itemIterator) != NULL) { - itemIterator++; + /* Search exisiting item */ + QTreeWidgetItemIterator itemIterator(ui.threadTreeWidget); + QTreeWidgetItem *item = NULL; + while ((item = *itemIterator) != NULL) { + itemIterator++; - if (item->data(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID).toString().toStdString() == msgId) { - ui.threadTreeWidget->setCurrentItem(item); - ui.threadTreeWidget->setFocus(); - return true; - } - } + if (item->data(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID).toString().toStdString() == msgId) { + ui.threadTreeWidget->setCurrentItem(item); + ui.threadTreeWidget->setFocus(); + return true; + } + } - return false; + return false; } void GxsForumsDialog::generateMassData() { #ifdef DEBUG_FORUMS - if (mCurrForumId.empty ()) { - return; - } + if (mCurrForumId.empty ()) { + return; + } - if (QMessageBox::question(this, "Generate mass data", "Do you really want to generate mass data ?", QMessageBox::Yes|QMessageBox::No, QMessageBox::No) == QMessageBox::No) { - return; - } + if (QMessageBox::question(this, "Generate mass data", "Do you really want to generate mass data ?", QMessageBox::Yes|QMessageBox::No, QMessageBox::No) == QMessageBox::No) { + return; + } - for (int thread = 1; thread < 1000; thread++) { - ForumMsgInfo threadInfo; - threadInfo.forumId = mCurrForumId; - threadInfo.title = QString("Test %1").arg(thread, 3, 10, QChar('0')).toStdWString(); - threadInfo.msg = QString("That is only a test").toStdWString(); + for (int thread = 1; thread < 1000; thread++) { + ForumMsgInfo threadInfo; + threadInfo.forumId = mCurrForumId; + threadInfo.title = QString("Test %1").arg(thread, 3, 10, QChar('0')).toStdWString(); + threadInfo.msg = QString("That is only a test").toStdWString(); - if (rsGxsForums->ForumMessageSend(threadInfo) == false) { - return; - } + if (rsGxsForums->ForumMessageSend(threadInfo) == false) { + return; + } - for (int msg = 1; msg < 3; msg++) { - ForumMsgInfo msgInfo; - msgInfo.forumId = mCurrForumId; - msgInfo.threadId = threadInfo.msgId; - msgInfo.parentId = threadInfo.msgId; - msgInfo.title = threadInfo.title; - msgInfo.msg = threadInfo.msg; + for (int msg = 1; msg < 3; msg++) { + ForumMsgInfo msgInfo; + msgInfo.forumId = mCurrForumId; + msgInfo.threadId = threadInfo.msgId; + msgInfo.parentId = threadInfo.msgId; + msgInfo.title = threadInfo.title; + msgInfo.msg = threadInfo.msg; - if (rsGxsForums->ForumMessageSend(msgInfo) == false) { - return; - } - } - } + if (rsGxsForums->ForumMessageSend(msgInfo) == false) { + return; + } + } + } #endif } - - /*********************** **** **** **** ***********************/ /** Request / Response of Data ********************************/ /*********************** **** **** **** ***********************/ @@ -1895,73 +1874,71 @@ void GxsForumsDialog::insertForums() void GxsForumsDialog::requestGroupSummary() { - std::cerr << "GxsForumsDialog::requestGroupSummary()"; - std::cerr << std::endl; + std::cerr << "GxsForumsDialog::requestGroupSummary()"; + std::cerr << std::endl; - RsTokReqOptions opts; + RsTokReqOptions opts; opts.mReqType = GXS_REQUEST_TYPE_GROUP_META; uint32_t token; - mForumQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, FORUMSV2DIALOG_LISTING); + mForumQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, FORUMSV2DIALOG_LISTING); } void GxsForumsDialog::loadGroupSummary(const uint32_t &token) { - std::cerr << "GxsForumsDialog::loadGroupSummary()"; - std::cerr << std::endl; + std::cerr << "GxsForumsDialog::loadGroupSummary()"; + std::cerr << std::endl; - std::list groupInfo; - rsGxsForums->getGroupSummary(token, groupInfo); + std::list groupInfo; + rsGxsForums->getGroupSummary(token, groupInfo); - if (groupInfo.size() > 0) - { + if (groupInfo.size() > 0) + { insertForumsData(groupInfo); - } - else - { - std::cerr << "GxsForumsDialog::loadGroupSummary() ERROR No Groups..."; - std::cerr << std::endl; - } + } + else + { + std::cerr << "GxsForumsDialog::loadGroupSummary() ERROR No Groups..."; + std::cerr << std::endl; + } } /*********************** **** **** **** ***********************/ /*********************** **** **** **** ***********************/ - - void GxsForumsDialog::requestGroupSummary_CurrentForum(const std::string &forumId) { RsTokReqOptions opts; opts.mReqType = GXS_REQUEST_TYPE_GROUP_META; - + std::list grpIds; grpIds.push_back(forumId); - std::cerr << "GxsForumsDialog::requestGroupSummary_CurrentForum(" << forumId << ")"; - std::cerr << std::endl; + std::cerr << "GxsForumsDialog::requestGroupSummary_CurrentForum(" << forumId << ")"; + std::cerr << std::endl; - uint32_t token; + uint32_t token; mForumQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, grpIds, FORUMSV2DIALOG_CURRENTFORUM); } void GxsForumsDialog::loadGroupSummary_CurrentForum(const uint32_t &token) { - std::cerr << "GxsForumsDialog::loadGroupSummary_CurrentForum()"; - std::cerr << std::endl; + std::cerr << "GxsForumsDialog::loadGroupSummary_CurrentForum()"; + std::cerr << std::endl; - std::list groupInfo; - rsGxsForums->getGroupSummary(token, groupInfo); + std::list groupInfo; + rsGxsForums->getGroupSummary(token, groupInfo); - if (groupInfo.size() == 1) - { + if (groupInfo.size() == 1) + { RsGroupMetaData fi = groupInfo.front(); insertForumThreads(fi); - } - else - { - std::cerr << "GxsForumsDialog::loadGroupSummary_CurrentForum() ERROR Invalid Number of Groups..."; - std::cerr << std::endl; - } + } + else + { + std::cerr << "GxsForumsDialog::loadGroupSummary_CurrentForum() ERROR Invalid Number of Groups..."; + std::cerr << std::endl; + } } /*********************** **** **** **** ***********************/ @@ -1969,30 +1946,28 @@ void GxsForumsDialog::loadGroupSummary_CurrentForum(const uint32_t &token) /*********************** **** **** **** ***********************/ /*********************** **** **** **** ***********************/ - - void GxsForumsDialog::loadCurrentForumThreads(const std::string &forumId) { - std::cerr << "GxsForumsDialog::loadCurrentForumThreads(" << forumId << ")"; - std::cerr << std::endl; + std::cerr << "GxsForumsDialog::loadCurrentForumThreads(" << forumId << ")"; + std::cerr << std::endl; /* if already active -> kill current loading */ if (mThreadLoading) { /* Cleanup */ - std::cerr << "GxsForumsDialog::loadCurrentForumThreads() Cleanup old Threads"; - std::cerr << std::endl; + std::cerr << "GxsForumsDialog::loadCurrentForumThreads() Cleanup old Threads"; + std::cerr << std::endl; /* Wipe Widget Tree */ mThreadLoad.Items.clear(); - + /* Stop all active requests */ std::map::iterator it; for(it = mThreadLoad.MsgTokens.begin(); it != mThreadLoad.MsgTokens.end(); it++) { - std::cerr << "GxsForumsDialog::loadCurrentForumThreads() Canceling Request: " << it->first; - std::cerr << std::endl; + std::cerr << "GxsForumsDialog::loadCurrentForumThreads() Canceling Request: " << it->first; + std::cerr << std::endl; mForumQueue->cancelRequest(it->first); } @@ -2002,22 +1977,23 @@ void GxsForumsDialog::loadCurrentForumThreads(const std::string &forumId) } /* initiate loading */ - std::cerr << "GxsForumsDialog::loadCurrentForumThreads() Initiating Loading"; - std::cerr << std::endl; + std::cerr << "GxsForumsDialog::loadCurrentForumThreads() Initiating Loading"; + std::cerr << std::endl; mThreadLoading = true; mThreadLoad.ForumId = mCurrForumId; - mThreadLoad.FilterColumn = FilterColumnFromComboBox(ui.filterColumnComboBox->currentIndex()); - mThreadLoad.ViewType = ui.viewBox->currentIndex(); +//#AFTER MERGE mThreadLoad.FilterColumn = ui.filterLineEdit->currentFilter(); + mThreadLoad.FilterColumn = COLUMN_THREAD_TITLE; + mThreadLoad.ViewType = ui.viewBox->currentIndex(); mThreadLoad.FillComplete = false; - if (lastViewType != mThreadLoad.ViewType || lastForumID != mCurrForumId) { - mThreadLoad.FillComplete = true; - } + if (lastViewType != mThreadLoad.ViewType || lastForumID != mCurrForumId) { + mThreadLoad.FillComplete = true; + } - mThreadLoad.FlatView = false; - mThreadLoad.UseChildTS = false; + mThreadLoad.FlatView = false; + mThreadLoad.UseChildTS = false; mThreadLoad.ExpandNewMessages = Settings->getExpandNewMessages(); mThreadLoad.SubscribeFlags = subscribeFlags; @@ -2028,56 +2004,53 @@ void GxsForumsDialog::loadCurrentForumThreads(const std::string &forumId) } switch(mThreadLoad.ViewType) - { - case VIEW_LAST_POST: + { + case VIEW_LAST_POST: mThreadLoad.UseChildTS = true; - break; - case VIEW_FLAT: + break; + case VIEW_FLAT: mThreadLoad.FlatView = true; - break; - case VIEW_THREADED: - break; + break; + case VIEW_THREADED: + break; } requestGroupThreadData_InsertThreads(forumId); } - - void GxsForumsDialog::requestGroupThreadData_InsertThreads(const std::string &forumId) { RsTokReqOptions opts; opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA; opts.mOptions = RS_TOKREQOPT_MSG_THREAD | RS_TOKREQOPT_MSG_LATEST; - + std::list grpIds; grpIds.push_back(forumId); - std::cerr << "GxsForumsDialog::requestGroupThreadData_InsertThreads(" << forumId << ")"; - std::cerr << std::endl; + std::cerr << "GxsForumsDialog::requestGroupThreadData_InsertThreads(" << forumId << ")"; + std::cerr << std::endl; - uint32_t token; + uint32_t token; mForumQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, grpIds, FORUMSV2DIALOG_INSERTTHREADS); } - void GxsForumsDialog::loadGroupThreadData_InsertThreads(const uint32_t &token) { std::cerr << "GxsForumsDialog::loadGroupThreadData_InsertThreads()"; std::cerr << std::endl; - + bool someData = false; - std::vector msgs; - std::vector::iterator vit; - if (rsGxsForums->getMsgData(token, msgs)) + std::vector msgs; + std::vector::iterator vit; + if (rsGxsForums->getMsgData(token, msgs)) { for(vit = msgs.begin(); vit != msgs.end(); vit++) { std::cerr << "GxsForumsDialog::loadGroupThreadData_InsertThreads() MsgId: " << vit->mMeta.mMsgId; std::cerr << std::endl; - + loadForumBaseThread(*vit); someData = true; } @@ -2090,93 +2063,95 @@ void GxsForumsDialog::loadGroupThreadData_InsertThreads(const uint32_t &token) } } -bool GxsForumsDialog::convertMsgToThreadWidget(const RsGxsForumMsg &msgInfo, - bool useChildTS, uint32_t filterColumn, GxsIdTreeWidgetItem *item) +bool GxsForumsDialog::convertMsgToThreadWidget(const RsGxsForumMsg &msgInfo, bool useChildTS, uint32_t filterColumn, GxsIdTreeWidgetItem *item) { - QString text; + QString text; - { - QDateTime qtime; - if (useChildTS) - qtime.setTime_t(msgInfo.mMeta.mChildTs); - else - qtime.setTime_t(msgInfo.mMeta.mPublishTs); + { + QDateTime qtime; + QString sort; - text = qtime.toString("yyyy-MM-dd hh:mm:ss"); - if (useChildTS) - { - QDateTime qtime2; - qtime2.setTime_t(msgInfo.mMeta.mPublishTs); - QString timestamp2 = qtime2.toString("yyyy-MM-dd hh:mm:ss"); - text += " / "; - text += timestamp2; - } - item->setText(COLUMN_THREAD_DATE, text); - } + if (useChildTS) + qtime.setTime_t(msgInfo.mMeta.mChildTs); + else + qtime.setTime_t(msgInfo.mMeta.mPublishTs); - item->setText(COLUMN_THREAD_TITLE, GxsForumsDialog::titleFromInfo(msgInfo.mMeta)); +//#AFTER MERGE text = DateTime::formatDateTime(qtime); + sort = qtime.toString("yyyyMMdd_hhmmss"); + + if (useChildTS) + { + qtime.setTime_t(msgInfo.mMeta.mPublishTs); + text += " / "; +//#AFTER MERGE text += DateTime::formatDateTime(qtime); + sort += "_" + qtime.toString("yyyyMMdd_hhmmss"); + } + item->setText(COLUMN_THREAD_DATE, text); + item->setData(COLUMN_THREAD_DATE, ROLE_THREAD_SORT, sort); + } + + item->setText(COLUMN_THREAD_TITLE, GxsForumsDialog::titleFromInfo(msgInfo.mMeta)); item->setId(msgInfo.mMeta.mAuthorId, COLUMN_THREAD_AUTHOR); #if 0 - text = QString::fromUtf8(authorName.c_str()); + text = QString::fromUtf8(authorName.c_str()); - if (text.isEmpty()) - { - item->setText(COLUMN_THREAD_AUTHOR, tr("Anonymous")); - } - else - { - item->setText(COLUMN_THREAD_AUTHOR, text); - } + if (text.isEmpty()) + { + item->setText(COLUMN_THREAD_AUTHOR, tr("Anonymous")); + } + else + { + item->setText(COLUMN_THREAD_AUTHOR, text); + } #endif #ifdef TOGXS - if (msgInfo.mMeta.mMsgFlags & RS_DISTRIB_AUTHEN_REQ) - { - item->setText(COLUMN_THREAD_SIGNED, tr("signed")); - item->setIcon(COLUMN_THREAD_SIGNED, QIcon(":/images/mail-signed.png")); - } - else - { - item->setText(COLUMN_THREAD_SIGNED, tr("none")); - item->setIcon(COLUMN_THREAD_SIGNED, QIcon(":/images/mail-signature-unknown.png")); - } + if (msgInfo.mMeta.mMsgFlags & RS_DISTRIB_AUTHEN_REQ) + { + item->setText(COLUMN_THREAD_SIGNED, tr("signed")); + item->setIcon(COLUMN_THREAD_SIGNED, QIcon(":/images/mail-signed.png")); + } + else + { + item->setText(COLUMN_THREAD_SIGNED, tr("none")); + item->setIcon(COLUMN_THREAD_SIGNED, QIcon(":/images/mail-signature-unknown.png")); + } #endif - if (filterColumn == COLUMN_THREAD_CONTENT) { - // need content for filter - QTextDocument doc; - doc.setHtml(QString::fromUtf8(msgInfo.mMsg.c_str())); - item->setText(COLUMN_THREAD_CONTENT, doc.toPlainText().replace(QString("\n"), QString(" "))); - } + if (filterColumn == COLUMN_THREAD_CONTENT) { + // need content for filter + QTextDocument doc; + doc.setHtml(QString::fromUtf8(msgInfo.mMsg.c_str())); + item->setText(COLUMN_THREAD_CONTENT, doc.toPlainText().replace(QString("\n"), QString(" "))); + } - item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID, QString::fromStdString(msgInfo.mMeta.mMsgId)); + item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID, QString::fromStdString(msgInfo.mMeta.mMsgId)); #if 0 - if (IS_GROUP_SUBSCRIBED(subscribeFlags) && !(msginfo.mMsgFlags & RS_DISTRIB_MISSING_MSG)) { - rsGxsForums->getMessageStatus(msginfo.forumId, msginfo.msgId, status); - } else { - // show message as read - status = RSGXS_MSG_STATUS_READ; - } + if (IS_GROUP_SUBSCRIBED(subscribeFlags) && !(msginfo.mMsgFlags & RS_DISTRIB_MISSING_MSG)) { + rsGxsForums->getMessageStatus(msginfo.forumId, msginfo.msgId, status); + } else { + // show message as read + status = RSGXS_MSG_STATUS_READ; + } #endif - item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS, msgInfo.mMeta.mMsgStatus); + item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS, msgInfo.mMeta.mMsgStatus); #ifdef TOGXS - item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_MISSING, (msgInfo.mMeta.mMsgFlags & RS_DISTRIB_MISSING_MSG) ? true : false); + item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_MISSING, (msgInfo.mMeta.mMsgFlags & RS_DISTRIB_MISSING_MSG) ? true : false); #endif return true; } - void GxsForumsDialog::loadForumBaseThread(const RsGxsForumMsg &msg) { - //std::string authorName = rsPeers->getPeerName(msg.mMeta.mAuthorId); - - //QTreeWidgetItem *item = new QTreeWidgetItem(); // no Parent. - GxsIdTreeWidgetItem *item = new GxsIdTreeWidgetItem(); // no Parent. - + //std::string authorName = rsPeers->getPeerName(msg.mMeta.mAuthorId); + + //QTreeWidgetItem *item = new QTreeWidgetItem(); // no Parent. + GxsIdTreeWidgetItem *item = new GxsIdTreeWidgetItem(threadCompareRole); // no Parent. + //convertMsgToThreadWidget(msg, authorName, mThreadLoad.UseChildTS, mThreadLoad.FilterColumn, item); convertMsgToThreadWidget(msg, mThreadLoad.UseChildTS, mThreadLoad.FilterColumn, item); @@ -2189,11 +2164,9 @@ void GxsForumsDialog::loadForumBaseThread(const RsGxsForumMsg &msg) mThreadLoad.MsgTokens[token] = item; /* add item to final tree */ - mThreadLoad.Items.append(item); + mThreadLoad.Items.append(item); } - - /*********************** **** **** **** ***********************/ void GxsForumsDialog::requestChildData_InsertThreads(uint32_t &token, const RsGxsGrpMsgIdPair &parentId) @@ -2201,20 +2174,19 @@ void GxsForumsDialog::requestChildData_InsertThreads(uint32_t &token, const RsGx RsTokReqOptions opts; opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA; opts.mOptions = RS_TOKREQOPT_MSG_PARENT | RS_TOKREQOPT_MSG_LATEST; - - std::cerr << "GxsForumsDialog::requestChildData_InsertThreads(" << parentId.first << "," << parentId.second << ")"; - std::cerr << std::endl; - std::vector msgIds; - msgIds.push_back(parentId); - mForumQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, FORUMSV2DIALOG_INSERTCHILD); + std::cerr << "GxsForumsDialog::requestChildData_InsertThreads(" << parentId.first << "," << parentId.second << ")"; + std::cerr << std::endl; + + std::vector msgIds; + msgIds.push_back(parentId); + mForumQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, FORUMSV2DIALOG_INSERTCHILD); } - void GxsForumsDialog::loadChildData_InsertThreads(const uint32_t &token) { - std::cerr << "GxsForumsDialog::loadChildData_InsertThreads()"; - std::cerr << std::endl; + std::cerr << "GxsForumsDialog::loadChildData_InsertThreads()"; + std::cerr << std::endl; /* find the matching *item */ std::map::iterator it; @@ -2234,15 +2206,15 @@ void GxsForumsDialog::loadChildData_InsertThreads(const uint32_t &token) std::cerr << "GxsForumsDialog::loadChildData_InsertThreads()"; std::cerr << std::endl; - std::vector msgs; - std::vector::iterator vit; - if (rsGxsForums->getRelatedMessages(token, msgs)) + std::vector msgs; + std::vector::iterator vit; + if (rsGxsForums->getRelatedMessages(token, msgs)) { for(vit = msgs.begin(); vit != msgs.end(); vit++) { std::cerr << "GxsForumsDialog::loadChildData_InsertThreads() MsgId: " << vit->mMeta.mMsgId; std::cerr << std::endl; - + loadForumChildMsg(*vit, parent); } } @@ -2263,21 +2235,20 @@ void GxsForumsDialog::loadChildData_InsertThreads(const uint32_t &token) void GxsForumsDialog::loadForumChildMsg(const RsGxsForumMsg &msg, QTreeWidgetItem *parent) { - //std::string authorName = rsPeers->getPeerName(msg.mMeta.mAuthorId); + //std::string authorName = rsPeers->getPeerName(msg.mMeta.mAuthorId); //QTreeWidgetItem *child = NULL; GxsIdTreeWidgetItem *child = NULL; if (mThreadLoad.FlatView) { - child = new GxsIdTreeWidgetItem(); // no Parent. + child = new GxsIdTreeWidgetItem(threadCompareRole); // no Parent. } else { - child = new GxsIdTreeWidgetItem(parent); + child = new GxsIdTreeWidgetItem(threadCompareRole, parent); } - convertMsgToThreadWidget(msg, mThreadLoad.UseChildTS, mThreadLoad.FilterColumn, child); //convertMsgToThreadWidget(msg, authorName, mThreadLoad.UseChildTS, mThreadLoad.FilterColumn, child); @@ -2290,12 +2261,12 @@ void GxsForumsDialog::loadForumChildMsg(const RsGxsForumMsg &msg, QTreeWidgetIte mThreadLoad.MsgTokens[token] = child; // Leave this here... BUT IT WILL NEED TO BE FIXED. - if (mThreadLoad.FillComplete && mThreadLoad.ExpandNewMessages && IS_MSG_UNREAD(msg.mMeta.mMsgStatus)) + if (mThreadLoad.FillComplete && mThreadLoad.ExpandNewMessages && IS_MSG_UNREAD(msg.mMeta.mMsgStatus)) { QTreeWidgetItem *pParent = child; - while ((pParent = pParent->parent()) != NULL) + while ((pParent = pParent->parent()) != NULL) { - if (std::find(mThreadLoad.ItemToExpand.begin(), mThreadLoad.ItemToExpand.end(), pParent) == mThreadLoad.ItemToExpand.end()) + if (std::find(mThreadLoad.ItemToExpand.begin(), mThreadLoad.ItemToExpand.end(), pParent) == mThreadLoad.ItemToExpand.end()) { mThreadLoad.ItemToExpand.push_back(pParent); } @@ -2305,12 +2276,10 @@ void GxsForumsDialog::loadForumChildMsg(const RsGxsForumMsg &msg, QTreeWidgetIte if (mThreadLoad.FlatView) { /* add item to final tree */ - mThreadLoad.Items.append(child); + mThreadLoad.Items.append(child); } } - - /*********************** **** **** **** ***********************/ /*********************** **** **** **** ***********************/ @@ -2319,59 +2288,57 @@ void GxsForumsDialog::requestMsgData_InsertPost(const RsGxsGrpMsgIdPair &msgId) #if 0 RsTokReqOptions opts; opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA; - - std::cerr << "GxsForumsDialog::requestMsgData_InsertPost(" << msgId.first << "," << msgId.second << ")"; - std::cerr << std::endl; - std::vector msgIds; - msgIds.push_back(msgId); - uint32_t token; - mForumQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, FORUMV2DIALOG_INSERT_POST); + std::cerr << "GxsForumsDialog::requestMsgData_InsertPost(" << msgId.first << "," << msgId.second << ")"; + std::cerr << std::endl; + + std::vector msgIds; + msgIds.push_back(msgId); + uint32_t token; + mForumQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, FORUMV2DIALOG_INSERT_POST); #else RsTokReqOptions opts; opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA; - - std::cerr << "GxsForumsDialog::requestMsgData_InsertPost(" << msgId.first << "," << msgId.second << ")"; - std::cerr << std::endl; + + std::cerr << "GxsForumsDialog::requestMsgData_InsertPost(" << msgId.first << "," << msgId.second << ")"; + std::cerr << std::endl; GxsMsgReq msgIds; - std::vector &vect = msgIds[msgId.first]; - vect.push_back(msgId.second); + std::vector &vect = msgIds[msgId.first]; + vect.push_back(msgId.second); - uint32_t token; - mForumQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, FORUMV2DIALOG_INSERT_POST); + uint32_t token; + mForumQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, FORUMV2DIALOG_INSERT_POST); #endif } - void GxsForumsDialog::loadMsgData_InsertPost(const uint32_t &token) { - std::cerr << "GxsForumsDialog::loadMsgData_InsertPost()"; - std::cerr << std::endl; + std::cerr << "GxsForumsDialog::loadMsgData_InsertPost()"; + std::cerr << std::endl; - std::vector msgs; + std::vector msgs; #if 0 - if (rsGxsForums->getRelatedMessages(token, msgs)) + if (rsGxsForums->getRelatedMessages(token, msgs)) #else - if (rsGxsForums->getMsgData(token, msgs)) + if (rsGxsForums->getMsgData(token, msgs)) #endif { if (msgs.size() != 1) { - std::cerr << "GxsForumsDialog::loadMsgData_InsertPost() ERROR Wrong number of answers"; - std::cerr << std::endl; + std::cerr << "GxsForumsDialog::loadMsgData_InsertPost() ERROR Wrong number of answers"; + std::cerr << std::endl; return; } insertPostData(msgs[0]); } - else - { - std::cerr << "GxsForumsDialog::loadMsgData_InsertPost() ERROR Missing Message Data..."; - std::cerr << std::endl; - } + else + { + std::cerr << "GxsForumsDialog::loadMsgData_InsertPost() ERROR Missing Message Data..."; + std::cerr << std::endl; + } } - /*********************** **** **** **** ***********************/ /*********************** **** **** **** ***********************/ @@ -2380,139 +2347,102 @@ void GxsForumsDialog::requestMsgData_ReplyMessage(const RsGxsGrpMsgIdPair &msgId #if 0 RsTokReqOptions opts; opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA; - - std::cerr << "GxsForumsDialog::requestMsgData_ReplyMessage(" << msgId.first << "," << msgId.second << ")"; - std::cerr << std::endl; - std::vector msgIds; - msgIds.push_back(msgId); - uint32_t token; - mForumQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, FORUMV2DIALOG_REPLY_MESSAGE); + std::cerr << "GxsForumsDialog::requestMsgData_ReplyMessage(" << msgId.first << "," << msgId.second << ")"; + std::cerr << std::endl; + + std::vector msgIds; + msgIds.push_back(msgId); + uint32_t token; + mForumQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, FORUMV2DIALOG_REPLY_MESSAGE); #else RsTokReqOptions opts; opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA; - - std::cerr << "GxsForumsDialog::requestMsgData_ReplyMessage(" << msgId.first << "," << msgId.second << ")"; - std::cerr << std::endl; + + std::cerr << "GxsForumsDialog::requestMsgData_ReplyMessage(" << msgId.first << "," << msgId.second << ")"; + std::cerr << std::endl; GxsMsgReq msgIds; - std::vector &vect = msgIds[msgId.first]; - vect.push_back(msgId.second); + std::vector &vect = msgIds[msgId.first]; + vect.push_back(msgId.second); - uint32_t token; - mForumQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, FORUMV2DIALOG_REPLY_MESSAGE); + uint32_t token; + mForumQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, FORUMV2DIALOG_REPLY_MESSAGE); #endif - } - void GxsForumsDialog::loadMsgData_ReplyMessage(const uint32_t &token) { - std::cerr << "GxsForumsDialog::loadMsgData_ReplyMessage()"; - std::cerr << std::endl; + std::cerr << "GxsForumsDialog::loadMsgData_ReplyMessage()"; + std::cerr << std::endl; - std::vector msgs; + std::vector msgs; #if 0 - if (rsGxsForums->getRelatedMessages(token, msgs)) + if (rsGxsForums->getRelatedMessages(token, msgs)) #else - if (rsGxsForums->getMsgData(token, msgs)) + if (rsGxsForums->getMsgData(token, msgs)) #endif { if (msgs.size() != 1) { - std::cerr << "GxsForumsDialog::loadMsgData_ReplyMessage() ERROR Wrong number of answers"; - std::cerr << std::endl; + std::cerr << "GxsForumsDialog::loadMsgData_ReplyMessage() ERROR Wrong number of answers"; + std::cerr << std::endl; return; } replyMessageData(msgs[0]); } - else - { - std::cerr << "GxsForumsDialog::loadMsgData_ReplyMessage() ERROR Missing Message Data..."; - std::cerr << std::endl; - } + else + { + std::cerr << "GxsForumsDialog::loadMsgData_ReplyMessage() ERROR Missing Message Data..."; + std::cerr << std::endl; + } } - +/*********************** **** **** **** ***********************/ +/*********************** **** **** **** ***********************/ /*********************** **** **** **** ***********************/ /*********************** **** **** **** ***********************/ - - -/*********************** **** **** **** ***********************/ -/*********************** **** **** **** ***********************/ -/*********************** **** **** **** ***********************/ -/*********************** **** **** **** ***********************/ - void GxsForumsDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req) { std::cerr << "GxsForumsDialog::loadRequest() UserType: " << req.mUserType; std::cerr << std::endl; - + if (queue == mForumQueue) { /* now switch on req */ switch(req.mUserType) { - case FORUMSV2DIALOG_LISTING: - loadGroupSummary(req.mToken); - break; + case FORUMSV2DIALOG_LISTING: + loadGroupSummary(req.mToken); + break; - case FORUMSV2DIALOG_CURRENTFORUM: - loadGroupSummary_CurrentForum(req.mToken); - break; + case FORUMSV2DIALOG_CURRENTFORUM: + loadGroupSummary_CurrentForum(req.mToken); + break; - case FORUMSV2DIALOG_INSERTTHREADS: - loadGroupThreadData_InsertThreads(req.mToken); - break; + case FORUMSV2DIALOG_INSERTTHREADS: + loadGroupThreadData_InsertThreads(req.mToken); + break; - case FORUMSV2DIALOG_INSERTCHILD: - loadChildData_InsertThreads(req.mToken); - break; + case FORUMSV2DIALOG_INSERTCHILD: + loadChildData_InsertThreads(req.mToken); + break; - case FORUMV2DIALOG_INSERT_POST: - loadMsgData_InsertPost(req.mToken); - break; + case FORUMV2DIALOG_INSERT_POST: + loadMsgData_InsertPost(req.mToken); + break; - case FORUMV2DIALOG_REPLY_MESSAGE: - loadMsgData_ReplyMessage(req.mToken); - break; + case FORUMV2DIALOG_REPLY_MESSAGE: + loadMsgData_ReplyMessage(req.mToken); + break; - default: - std::cerr << "GxsForumsDialog::loadRequest() ERROR: INVALID TYPE"; - std::cerr << std::endl; - break; + default: + std::cerr << "GxsForumsDialog::loadRequest() ERROR: INVALID TYPE"; + std::cerr << std::endl; + break; } } } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/retroshare-gui/src/gui/GxsForumsDialog.h b/retroshare-gui/src/gui/GxsForumsDialog.h index f80769575..d74601faf 100644 --- a/retroshare-gui/src/gui/GxsForumsDialog.h +++ b/retroshare-gui/src/gui/GxsForumsDialog.h @@ -45,112 +45,126 @@ class ForumInfo; class GxsForumsThreadLoadParameters { - public: - - std::string ForumId; - std::string FocusMsgId; +public: + std::string ForumId; + std::string FocusMsgId; - uint32_t SubscribeFlags; - int ViewType; - uint32_t FilterColumn; - - std::map MsgTokens; - QList Items; - QList ItemToExpand; - - bool FillComplete; - bool FlatView; - bool UseChildTS; - bool ExpandNewMessages; + uint32_t SubscribeFlags; + int ViewType; + uint32_t FilterColumn; + + std::map MsgTokens; + QList Items; + QList ItemToExpand; + + bool FillComplete; + bool FlatView; + bool UseChildTS; + bool ExpandNewMessages; }; - - - - - class GxsForumsDialog : public RsAutoUpdatePage, public TokenResponse { - Q_OBJECT + Q_OBJECT + + Q_PROPERTY(QColor textColorRead READ textColorRead WRITE setTextColorRead) + Q_PROPERTY(QColor textColorUnread READ textColorUnread WRITE setTextColorUnread) + Q_PROPERTY(QColor textColorUnreadChildren READ textColorUnreadChildren WRITE setTextColorUnreadChildren) + Q_PROPERTY(QColor textColorNotSubscribed READ textColorNotSubscribed WRITE setTextColorNotSubscribed) + Q_PROPERTY(QColor textColorMissing READ textColorMissing WRITE setTextColorMissing) public: - GxsForumsDialog(QWidget *parent = 0); - ~GxsForumsDialog(); + GxsForumsDialog(QWidget *parent = 0); + ~GxsForumsDialog(); - bool navigate(const std::string& forumId, const std::string& msgId); +//#AFTER MERGE virtual UserNotify *getUserNotify(QObject *parent); - /* overloaded from RsAuthUpdatePage */ - virtual void updateDisplay(); + bool navigate(const std::string& forumId, const std::string& msgId); + + /* overloaded from RsAuthUpdatePage */ + virtual void updateDisplay(); // Callback for all Loads. -virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req); + virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req); + + QColor textColorRead() const { return mTextColorRead; } + QColor textColorUnread() const { return mTextColorUnread; } + QColor textColorUnreadChildren() const { return mTextColorUnreadChildren; } + QColor textColorNotSubscribed() const { return mTextColorNotSubscribed; } + QColor textColorMissing() const { return mTextColorMissing; } + + void setTextColorRead(QColor color) { mTextColorRead = color; } + void setTextColorUnread(QColor color) { mTextColorUnread = color; } + void setTextColorUnreadChildren(QColor color) { mTextColorUnreadChildren = color; } + void setTextColorNotSubscribed(QColor color) { mTextColorNotSubscribed = color; } + void setTextColorMissing(QColor color) { mTextColorMissing = color; } protected: - bool eventFilter(QObject *obj, QEvent *ev); + bool eventFilter(QObject *obj, QEvent *ev); + void changeEvent(QEvent *e); private slots: - void forceUpdateDisplay(); // TEMP HACK FN. + void forceUpdateDisplay(); // TEMP HACK FN. - /** Create the context popup menu and it's submenus */ - void forumListCustomPopupMenu( QPoint point ); - void threadListCustomPopupMenu( QPoint point ); - void restoreForumKeys(); - void newforum(); + /** Create the context popup menu and it's submenus */ + void forumListCustomPopupMenu( QPoint point ); + void threadListCustomPopupMenu( QPoint point ); + void restoreForumKeys(); + void newforum(); - void changedForum(const QString &id); - void changedThread(); - void clickedThread (QTreeWidgetItem *item, int column); + void changedForum(const QString &id); + void changedThread(); + void clickedThread (QTreeWidgetItem *item, int column); - void replytomessage(); + void replytomessage(); void replyMessageData(const RsGxsForumMsg &msg); - //void print(); - //void printpreview(); + //void print(); + //void printpreview(); - //void removemessage(); - void markMsgAsRead(); - void markMsgAsReadChildren(); - void markMsgAsReadAll(); - void markMsgAsUnread(); - void markMsgAsUnreadAll(); - void markMsgAsUnreadChildren(); - void copyForumLink(); - void copyMessageLink(); + //void removemessage(); + void markMsgAsRead(); + void markMsgAsReadChildren(); + void markMsgAsReadAll(); + void markMsgAsUnread(); + void markMsgAsUnreadAll(); + void markMsgAsUnreadChildren(); + void copyForumLink(); + void copyMessageLink(); - /* handle splitter */ - void togglethreadview(); + /* handle splitter */ + void togglethreadview(); - void createthread(); - void createmessage(); + void createthread(); + void createmessage(); - void subscribeToForum(); - void unsubscribeToForum(); + void subscribeToForum(); + void unsubscribeToForum(); - void showForumDetails(); - void editForumDetails(); + void showForumDetails(); + void editForumDetails(); - void previousMessage (); - void nextMessage (); - void nextUnreadMessage(); - void downloadAllFiles(); + void previousMessage (); + void nextMessage (); + void nextUnreadMessage(); + void downloadAllFiles(); - void changedViewBox(); + void changedViewBox(); - void filterColumnChanged(); - //void filterRegExpChanged(); - ///void clearFilter(); + void filterColumnChanged(int column); + void filterItems(const QString &text); - void generateMassData(); + void generateMassData(); - void fillThreadFinished(); - void fillThreadProgress(int current, int count); + void fillThreadFinished(); + void fillThreadProgress(int current, int count); - void shareKey(); + void shareKey(); private: - void insertForums(); - void insertThreads(); - void insertPost(); + void insertForums(); + void insertThreads(); + void insertPost(); void insertPostData(const RsGxsForumMsg &msg); // Second Half. // Utility Fns. @@ -159,25 +173,23 @@ private: void forumMsgReadStatusChanged(const QString &forumId, const QString &msgId, int status); - void updateMessageSummaryList(std::string forumId); - //void forumInfoToGroupItemInfo(const ForumInfo &forumInfo, GroupItemInfo &groupItemInfo); - void forumInfoToGroupItemInfo(const RsGroupMetaData &forumInfo, GroupItemInfo &groupItemInfo); + void updateMessageSummaryList(std::string forumId); +// void forumInfoToGroupItemInfo(const ForumInfo &forumInfo, GroupItemInfo &groupItemInfo); + void forumInfoToGroupItemInfo(const RsGroupMetaData &forumInfo, GroupItemInfo &groupItemInfo); - void forumSubscribe(bool subscribe); - void FillThreads(QList &ThreadList, bool bExpandNewMessages, QList &itemToExpand); - void FillChildren(QTreeWidgetItem *Parent, QTreeWidgetItem *NewParent, bool bExpandNewMessages, QList &itemToExpand); + void forumSubscribe(bool subscribe); + void FillThreads(QList &ThreadList, bool bExpandNewMessages, QList &itemToExpand); + void FillChildren(QTreeWidgetItem *Parent, QTreeWidgetItem *NewParent, bool bExpandNewMessages, QList &itemToExpand); - int getSelectedMsgCount(QList *pRows, QList *pRowsRead, QList *pRowsUnread); + int getSelectedMsgCount(QList *pRows, QList *pRowsRead, QList *pRowsUnread); + void setMsgReadStatus(QList &Rows, bool bRead); + void markMsgAsReadUnread(bool bRead, bool bChildren, bool bForum); + void CalculateIconsAndFonts(QTreeWidgetItem *pItem = NULL); + void CalculateIconsAndFonts(QTreeWidgetItem *pItem, bool &bHasReadChilddren, bool &bHasUnreadChilddren); - void setMsgReadStatus(QList &Rows, bool bRead); - void markMsgAsReadUnread(bool bRead, bool bChildren, bool bForum); - void CalculateIconsAndFonts(QTreeWidgetItem *pItem = NULL); - void CalculateIconsAndFonts(QTreeWidgetItem *pItem, bool &bHasReadChilddren, bool &bHasUnreadChilddren); + void processSettings(bool bLoad); + void togglethreadview_internal(); - void processSettings(bool bLoad); - void togglethreadview_internal(); - - void filterItems(const QString& text); bool filterItem(QTreeWidgetItem *pItem, const QString &text, int filterColumn); // New Request/Response Loading Functions. @@ -204,75 +216,40 @@ private: void requestMsgData_ReplyMessage(const RsGxsGrpMsgIdPair &msgId); void loadMsgData_ReplyMessage(const uint32_t &token); - bool convertMsgToThreadWidget(const RsGxsForumMsg &msgInfo, - bool useChildTS, uint32_t filterColumn, GxsIdTreeWidgetItem *item); - //bool convertMsgToThreadWidget(const RsGxsForumMsg &msgInfo, std::string authorName, - // bool useChildTS, uint32_t filterColumn, QTreeWidgetItem *item); + bool convertMsgToThreadWidget(const RsGxsForumMsg &msgInfo, bool useChildTS, uint32_t filterColumn, GxsIdTreeWidgetItem *item); +// bool convertMsgToThreadWidget(const RsGxsForumMsg &msgInfo, std::string authorName, bool useChildTS, uint32_t filterColumn, QTreeWidgetItem *item); TokenQueue *mForumQueue; - - bool m_bProcessSettings; - - QTreeWidgetItem *yourForums; - QTreeWidgetItem *subscribedForums; - QTreeWidgetItem *popularForums; - QTreeWidgetItem *otherForums; - - std::string mCurrForumId; - std::string mCurrThreadId; - int subscribeFlags; - - QFont m_ForumNameFont; - int lastViewType; - std::string lastForumID; - + bool m_bProcessSettings; bool inMsgAsReadUnread; - //GxsForumsFillThread *fillThread; - // New Datatypes to replace the FillThread. - bool mThreadLoading; - GxsForumsThreadLoadParameters mThreadLoad; - + QTreeWidgetItem *yourForums; + QTreeWidgetItem *subscribedForums; + QTreeWidgetItem *popularForums; + QTreeWidgetItem *otherForums; - /** Qt Designer generated object */ - Ui::GxsForumsDialog ui; -}; + RSTreeWidgetItemCompareRole *threadCompareRole; + std::string mCurrForumId; + std::string mCurrThreadId; + int subscribeFlags; -#if 0 -class GxsForumsFillThread : public QThread -{ - Q_OBJECT + int lastViewType; + std::string lastForumID; -public: - GxsForumsFillThread(GxsForumsDialog *parent); - ~GxsForumsFillThread(); + // New Datatypes to replace the FillThread. + bool mThreadLoading; + GxsForumsThreadLoadParameters mThreadLoad; - void run(); - void stop(); - bool wasStopped() { return stopped; } + /* Color definitions (for standard see qss.default) */ + QColor mTextColorRead; + QColor mTextColorUnread; + QColor mTextColorUnreadChildren; + QColor mTextColorNotSubscribed; + QColor mTextColorMissing; -signals: - void progress(int current, int count); - -public: - std::string forumId; - int filterColumn; - int subscribeFlags; - bool fillComplete; - int viewType; - bool expandNewMessages; - std::string focusMsgId; - - QList Items; - QList ItemToExpand; - -private: - volatile bool stopped; + /** Qt Designer generated object */ + Ui::GxsForumsDialog ui; }; #endif - - -#endif - diff --git a/retroshare-gui/src/gui/GxsForumsDialog.ui b/retroshare-gui/src/gui/GxsForumsDialog.ui index c3228a940..9d8f4d4dd 100644 --- a/retroshare-gui/src/gui/GxsForumsDialog.ui +++ b/retroshare-gui/src/gui/GxsForumsDialog.ui @@ -10,501 +10,6 @@ 420 - - - 0 - 2 - - - - - 60 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - 208 - 208 - 208 - - - - - - - 255 - 255 - 255 - - - - - - - 247 - 247 - 247 - - - - - - - 104 - 104 - 104 - - - - - - - 139 - 139 - 139 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 240 - 240 - 240 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 128 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 255 - - - - - - - 255 - 0 - 255 - - - - - - - 231 - 231 - 231 - - - - - - - - - 0 - 0 - 0 - - - - - - - 208 - 208 - 208 - - - - - - - 255 - 255 - 255 - - - - - - - 247 - 247 - 247 - - - - - - - 104 - 104 - 104 - - - - - - - 139 - 139 - 139 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 240 - 240 - 240 - - - - - - - 0 - 0 - 0 - - - - - - - 192 - 192 - 192 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 255 - - - - - - - 255 - 0 - 255 - - - - - - - 231 - 231 - 231 - - - - - - - - - 104 - 104 - 104 - - - - - - - 208 - 208 - 208 - - - - - - - 255 - 255 - 255 - - - - - - - 247 - 247 - 247 - - - - - - - 104 - 104 - 104 - - - - - - - 139 - 139 - 139 - - - - - - - 104 - 104 - 104 - - - - - - - 255 - 255 - 255 - - - - - - - 104 - 104 - 104 - - - - - - - 240 - 240 - 240 - - - - - - - 240 - 240 - 240 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 128 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 255 - - - - - - - 255 - 0 - 255 - - - - - - - 231 - 231 - 231 - - - - - - - - - Arial - 8 - 50 - false - false - false - false - - - - Qt::DefaultContextMenu - 9 @@ -524,14 +29,8 @@ 300 - - QFrame#frame{border: none;} - - QFrame::StyledPanel - - - QFrame::Raised + QFrame::NoFrame @@ -541,70 +40,51 @@ 0 - - - QFrame#chheaderframe{ -background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, - stop:0 #FEFEFE, stop:1 #E8E8E8); - -border: 1px solid #CCCCCC;} - - - + - QFrame::StyledPanel + QFrame::Box - QFrame::Raised + QFrame::Sunken - + 2 - - - - 0 + + + + + 24 + 24 + - - - - - 24 - 24 - - - - - - - :/images/konversation.png - - - true - - - - - - - - Arial - 10 - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:10pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-weight:600;">Forums</span></p></body></html> - - - - + + + + + :/images/konversation.png + + + true + + - + + + + + 10 + 75 + true + + + + Forums + + + + Qt::Horizontal @@ -617,39 +97,33 @@ p, li { white-space: pre-wrap; } - - + + Qt::NoFocus Display - - QPushButton::menu-indicator { - subcontrol-origin: padding; - subcontrol-position: bottom right; - } - - QPushButton::menu-indicator:pressed, QPushButton::menu-indicator:open { - position: relative; - top: 2px; left: 2px; /* shift the arrow by 2 px */ - } - - QPushButton:hover { - border: 1px solid #CCCCCC; - } - :/images/looknfeel.png:/images/looknfeel.png - + + + 32 + 16 + + + + QToolButton::InstantPopup + + true - + Qt::NoFocus @@ -661,6 +135,12 @@ p, li { white-space: pre-wrap; } :/images/new_forum16.png:/images/new_forum16.png + + + 32 + 16 + + true @@ -677,17 +157,6 @@ p, li { white-space: pre-wrap; } 0 - - - 9 - - - - - -1 - -1 - - @@ -720,9 +189,6 @@ p, li { white-space: pre-wrap; } 1677215 - - - @@ -1022,93 +488,47 @@ p, li { white-space: pre-wrap; } - + 0 32 - - QFrame#frame_2{ -background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, - stop:0 #FEFEFE, stop:1 #E8E8E8); - -border: 1px solid #CCCCCC;} - - QFrame::StyledPanel + QFrame::Box - QFrame::Raised + QFrame::Sunken - + 2 - - - - 2 + + + + Qt::NoFocus - - - - - - - :/images/find-16.png - - - - - - - Search forums - - - - - - - - + + Start new Thread for Selected Forum + + + + :/images/mail_new.png:/images/mail_new.png + + - 0 - 0 + 24 + 16 - - - MS Shell Dlg 2 - + + true - - 1 - - - - Date - - - - - Title - - - - - Author - - - - - Content - - - + Qt::Horizontal @@ -1124,26 +544,10 @@ border: 1px solid #CCCCCC;} - - - - - 24 - 24 - - - - Qt::NoFocus - + + - Start new Thread for Selected Forum - - - - :/images/mail_new.png:/images/mail_new.png - - - true + Search forums @@ -1186,9 +590,6 @@ border: 1px solid #CCCCCC;} - - - true @@ -1229,20 +630,20 @@ border: 1px solid #CCCCCC;} - GroupTreeWidget - QWidget -
gui/common/GroupTreeWidget.h
- 1 + LinkTextBrowser + QTextBrowser +
gui/common/LinkTextBrowser.h
LineEditClear QLineEdit -
gui/common/LineEditClear.h
+
gui/common/LineEditClear.h
- LinkTextBrowser - QTextBrowser -
gui/common/LinkTextBrowser.h
+ GroupTreeWidget + QWidget +
gui/common/GroupTreeWidget.h
+ 1
diff --git a/retroshare-gui/src/gui/Posted/PostedGroupDialog.cpp b/retroshare-gui/src/gui/Posted/PostedGroupDialog.cpp index ef27fb73b..d44ab1a5a 100644 --- a/retroshare-gui/src/gui/Posted/PostedGroupDialog.cpp +++ b/retroshare-gui/src/gui/Posted/PostedGroupDialog.cpp @@ -41,7 +41,7 @@ 0) PostedGroupDialog::PostedGroupDialog(TokenQueue* tokenQueue, RsPosted* posted, QWidget *parent) - :GxsGroupDialog(tokenQueue, POSTED_ENABLE_FLAG, POSTED_CREATE_DEFAULT_FLAG, parent, "Create New Posted Topic"), + :GxsGroupDialog(tokenQueue, POSTED_ENABLE_FLAG, POSTED_CREATE_DEFAULT_FLAG, parent), mPosted(posted) { } @@ -51,6 +51,15 @@ PostedGroupDialog::PostedGroupDialog(const RsPostedGroup& grp, uint32_t mode, QW { } +QString PostedGroupDialog::serviceHeader() +{ + return tr("Create New Posted Topic"); +} + +QPixmap PostedGroupDialog::serviceImage() +{ + return QPixmap(); +} bool PostedGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta) { diff --git a/retroshare-gui/src/gui/Posted/PostedGroupDialog.h b/retroshare-gui/src/gui/Posted/PostedGroupDialog.h index 187f1416d..3ed4faed3 100644 --- a/retroshare-gui/src/gui/Posted/PostedGroupDialog.h +++ b/retroshare-gui/src/gui/Posted/PostedGroupDialog.h @@ -43,7 +43,8 @@ public: PostedGroupDialog(const RsPostedGroup& grp, uint32_t mode, QWidget *parent = NULL); protected: - + virtual QString serviceHeader(); + virtual QPixmap serviceImage(); bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta); private: diff --git a/retroshare-gui/src/gui/forumsv2/CreateForumV2.cpp b/retroshare-gui/src/gui/forumsv2/CreateForumV2.cpp deleted file mode 100644 index d261c024e..000000000 --- a/retroshare-gui/src/gui/forumsv2/CreateForumV2.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/**************************************************************** - * RetroShare is distributed under the following license: - * - * Copyright (C) 2008 Robert Fernie - * - * 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 - -#include "util/misc.h" -#include "CreateForumV2.h" -#include "gui/common/PeerDefs.h" - -#include - -#include -#include - -#include - -#define CREATEFORUMSV2_NEWFORUMID 1 - - -/** Constructor */ -CreateForumV2::CreateForumV2(QWidget *parent) -: QDialog(parent) -{ - /* Invoke the Qt Designer generated object setup routine */ - ui.setupUi(this); - - mForumQueue = new TokenQueue(rsForumsV2, this); - - // connect up the buttons. - connect( ui.cancelButton, SIGNAL( clicked ( bool ) ), this, SLOT( cancelForum( ) ) ); - connect( ui.createButton, SIGNAL( clicked ( bool ) ), this, SLOT( createForum( ) ) ); - connect( ui.pubKeyShare_cb, SIGNAL( clicked() ), this, SLOT( setShareList( ) )); - - if (!ui.pubKeyShare_cb->isChecked()) { - ui.contactsdockWidget->hide(); - this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height()); - } - - /* initialize key share list */ - ui.keyShareList->setHeaderText(tr("Contacts:")); - ui.keyShareList->setModus(FriendSelectionWidget::MODUS_CHECK); - ui.keyShareList->start(); - - newForum(); -} - -void CreateForumV2::newForum() -{ - /* enforce Public for the moment */ - ui.typePublic->setChecked(true); - - ui.typePrivate->setEnabled(false); - ui.typeEncrypted->setEnabled(true); - -#ifdef RS_RELEASE_VERSION - ui.typePrivate->setVisible(false); - ui.typeEncrypted->setVisible(true); -#endif - - ui.msgAnon->setChecked(true); - //ui.msgAuth->setEnabled(false); - - ui.forumName->clear(); - ui.forumDesc->clear(); - - ui.forumName->setFocus(); -} - -void CreateForumV2::createForum() -{ - QString name = misc::removeNewLine(ui.forumName->text()); - QString desc = ui.forumDesc->toPlainText(); //toHtml(); - uint32_t flags = 0; - - 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!! - } - - if (ui.typePublic->isChecked()) { - flags |= RS_DISTRIB_PUBLIC; - } else if (ui.typePrivate->isChecked()) { - flags |= RS_DISTRIB_PRIVATE; - } else if (ui.typeEncrypted->isChecked()) { - flags |= RS_DISTRIB_ENCRYPTED; - } - - if (ui.msgAuth->isChecked()) { - flags |= RS_DISTRIB_AUTHEN_REQ; - } else if (ui.msgAnon->isChecked()) { - flags |= RS_DISTRIB_AUTHEN_ANON; - } - - if (rsForumsV2) { - - - uint32_t token; - RsForumV2Group grp; - grp.mMeta.mGroupName = std::string(name.toUtf8()); - grp.mDescription = std::string(desc.toUtf8()); - grp.mMeta.mGroupFlags = flags; - - rsForumsV2->createGroup(token, grp, true); - - // get the Queue to handle response. - mForumQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_SUMMARY, CREATEFORUMSV2_NEWFORUMID); - - } -} - -void CreateForumV2::completeCreateNewForum(const RsGroupMetaData &newForumMeta) -{ - sendShareList(newForumMeta.mGroupId); - - close(); -} - - -void CreateForumV2::sendShareList(std::string forumId) -{ - if (!rsForumsV2) - { - std::cerr << "CreateForumV2::sendShareList() ForumsV2 not active"; - std::cerr << std::endl; - return; - } - - if (ui.pubKeyShare_cb->isChecked()) - { - std::list shareList; - ui.keyShareList->selectedSslIds(shareList, false); - rsForumsV2->groupShareKeys(forumId, shareList); - } - close(); -} - - - - - - -void CreateForumV2::setShareList() -{ - if (ui.pubKeyShare_cb->isChecked()){ - this->resize(this->size().width() + ui.contactsdockWidget->size().width(), this->size().height()); - ui.contactsdockWidget->show(); - } else { // hide share widget - ui.contactsdockWidget->hide(); - this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height()); - } -} - -void CreateForumV2::cancelForum() -{ - close(); -} - - - - -void CreateForumV2::loadNewForumId(const uint32_t &token) -{ - std::cerr << "CreateForumV2::loadNewForumId()"; - std::cerr << std::endl; - - std::list groupInfo; - rsForumsV2->getGroupSummary(token, groupInfo); - - if (groupInfo.size() == 1) - { - RsGroupMetaData fi = groupInfo.front(); - completeCreateNewForum(fi); - } - else - { - std::cerr << "CreateForumV2::loadNewForumId() ERROR INVALID Number of Forums Created"; - std::cerr << std::endl; - } -} - - - - - - - - -void CreateForumV2::loadRequest(const TokenQueue *queue, const TokenRequest &req) -{ - std::cerr << "CreateForumV2::loadRequest() UserType: " << req.mUserType; - std::cerr << std::endl; - - if (queue == mForumQueue) - { - /* now switch on req */ - switch(req.mUserType) - { - - case CREATEFORUMSV2_NEWFORUMID: - loadNewForumId(req.mToken); - break; - default: - std::cerr << "CreateForumV2::loadRequest() UNKNOWN UserType "; - std::cerr << std::endl; - - } - } -} - - - diff --git a/retroshare-gui/src/gui/forumsv2/CreateForumV2.h b/retroshare-gui/src/gui/forumsv2/CreateForumV2.h deleted file mode 100644 index 0aa72e26e..000000000 --- a/retroshare-gui/src/gui/forumsv2/CreateForumV2.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************** - * RetroShare is distributed under the following license: - * - * Copyright (C) 2008 Robert Fernie - * - * 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 _CREATE_FORUMV2_DIALOG_H -#define _CREATE_FORUMV2_DIALOG_H - -#include "ui_CreateForumV2.h" - -#include "util/TokenQueue.h" - -class CreateForumV2 : public QDialog, public TokenResponse -{ - Q_OBJECT - -public: - CreateForumV2(QWidget *parent = 0); - - void newForum(); /* cleanup */ - - // Callback for all Loads. -virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req); - -private slots: - /* actions to take.... */ - void createForum(); - void cancelForum(); - - // set private forum key share list - void setShareList(); - -private: - void sendShareList(std::string forumId); - void completeCreateNewForum(const RsGroupMetaData &newForumMeta); - void loadNewForumId(const uint32_t &token); - - - std::list mShareList; - - QPixmap picture; - - TokenQueue *mForumQueue; - - /** Qt Designer generated object */ - Ui::CreateForumV2 ui; -}; - -#endif - diff --git a/retroshare-gui/src/gui/forumsv2/CreateForumV2.ui b/retroshare-gui/src/gui/forumsv2/CreateForumV2.ui deleted file mode 100644 index 0cfcb4ca5..000000000 --- a/retroshare-gui/src/gui/forumsv2/CreateForumV2.ui +++ /dev/null @@ -1,374 +0,0 @@ - - - CreateForumV2 - - - - 0 - 0 - 672 - 495 - - - - Create new Forum - - - - :/images/rstray3.png:/images/rstray3.png - - - - 0 - - - 0 - - - - - - 16777215 - 64 - - - - QFrame#frame_2{background-image: url(:/images/connect/connectFriendBanner.png);} - - - QFrame::NoFrame - - - QFrame::Raised - - - - 6 - - - 6 - - - - - - 48 - 48 - - - - - - - - - - :/images/konversation64.png - - - true - - - - - - - color: rgb(255, 255, 255); - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:24pt; font-weight:600; color:#ffffff;">New Forum</span></p></body></html> - - - - - - - - - - QFrame::NoFrame - - - QFrame::Raised - - - - - - - - Name - - - - - - - - - - - - true - - - - 0 - 0 - - - - - 300 - 524287 - - - - - 220 - 0 - - - - - 0 - 0 - - - - check peers you would like to share private publish key with - - - false - - - QDockWidget::NoDockWidgetFeatures - - - Share Key With - - - - - 0 - - - 0 - - - - - - 0 - 4 - - - - - 20 - 0 - - - - - 300 - 16777215 - - - - - 220 - 0 - - - - - 200 - 0 - - - - - - - - - - - - - - Description - - - - - - - - - - - - Type: - - - - 6 - - - - - Public - Anyone can read and publish (Shared Publish Key) - - - - - - - Restricted - Anyone can read, limited publishing (Private Publish Key) - - - - - - - Private - (Private Publish Key required to view Messages) - - - - - - - - - - Key Sharing - - - - 0 - - - 6 - - - - - Key recipients can publish to restricted-type channels, and can view and publish for private-type channels - - - Share Private Publish Key - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Allowed Messages - - - - 0 - - - 6 - - - - - Authenticated Messages - - - - - - - Anonymous Messages - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::Horizontal - - - - 238 - 20 - - - - - - - - Cancel - - - - - - - Create - - - true - - - - - - - - - - - FriendSelectionWidget - QWidget -
gui/common/FriendSelectionWidget.h
- 1 -
-
- - - - -
diff --git a/retroshare-gui/src/gui/forumsv2/CreateForumV2Msg.cpp b/retroshare-gui/src/gui/forumsv2/CreateForumV2Msg.cpp deleted file mode 100644 index 6ace6db7e..000000000 --- a/retroshare-gui/src/gui/forumsv2/CreateForumV2Msg.cpp +++ /dev/null @@ -1,424 +0,0 @@ -/**************************************************************** - * RetroShare is distributed under the following license: - * - * Copyright (C) 2008 Robert Fernie - * - * 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 "CreateForumV2Msg.h" - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "gui/settings/rsharesettings.h" -#include "gui/RetroShareLink.h" -#include "gui/common/Emoticons.h" - -#include "util/misc.h" - -#include -#include - - -#define CREATEFORUMV2MSG_FORUMINFO 1 -#define CREATEFORUMV2MSG_PARENTMSG 2 - - -/** Constructor */ -CreateForumV2Msg::CreateForumV2Msg(std::string fId, std::string pId) -: QMainWindow(NULL), mForumId(fId), mParentId(pId) -{ - /* Invoke the Qt Designer generated object setup routine */ - ui.setupUi(this); - setAttribute(Qt::WA_DeleteOnClose, true); - - /* Setup Queue */ - mForumQueue = new TokenQueue(rsForumsV2, this); - - Settings->loadWidgetInformation(this); - - connect( ui.forumMessage, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( forumMessageCostumPopupMenu( QPoint ) ) ); - - connect(ui.hashBox, SIGNAL(fileHashingFinished(QList)), this, SLOT(fileHashingFinished(QList))); - - // connect up the buttons. - connect( ui.postmessage_action, SIGNAL( triggered (bool) ), this, SLOT( createMsg( ) ) ); - connect( ui.close_action, SIGNAL( triggered (bool) ), this, SLOT( cancelMsg( ) ) ); - connect( ui.emoticonButton, SIGNAL(clicked()), this, SLOT(smileyWidgetForums())); - connect( ui.attachFileButton, SIGNAL(clicked() ), this , SLOT(addFile())); - connect( ui.pastersButton, SIGNAL(clicked() ), this , SLOT(pasteLink())); - - setAcceptDrops(true); - ui.hashBox->setDropWidget(this); - ui.hashBox->setAutoHide(false); - - mParentMsgLoaded = false; - mForumMetaLoaded = false; - - newMsg(); -} - -/** context menu searchTablewidget2 **/ -void CreateForumV2Msg::forumMessageCostumPopupMenu( QPoint /*point*/ ) -{ - QMenu *contextMnu = ui.forumMessage->createStandardContextMenu(); - - contextMnu->addSeparator(); - QAction *pasteLinkAct = contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteLink())); - QAction *pasteLinkFullAct = contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste full RetroShare Link"), this, SLOT(pasteLinkFull())); - contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste own certificate link"), this, SLOT(pasteOwnCertificateLink())); - - if (RSLinkClipboard::empty()) { - pasteLinkAct->setDisabled (true); - pasteLinkFullAct->setDisabled (true); - } - - contextMnu->exec(QCursor::pos()); - delete(contextMnu); -} - -void CreateForumV2Msg::newMsg() -{ - /* clear all */ - mParentMsgLoaded = false; - mForumMetaLoaded = false; - - /* request Data */ - { - RsTokReqOptions opts; - - std::list groupIds; - groupIds.push_back(mForumId); - - std::cerr << "ForumsV2Dialog::newMsg() Requesting Group Summary(" << mForumId << ")"; - std::cerr << std::endl; - - uint32_t token; - mForumQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, groupIds, CREATEFORUMV2MSG_FORUMINFO); - - } - - if (mParentId != "") - { - - RsTokReqOptions opts; - - std::list msgIds; - msgIds.push_back(mParentId); - - std::cerr << "ForumsV2Dialog::newMsg() Requesting Parent Summary(" << mParentId << ")"; - std::cerr << std::endl; - - uint32_t token; - //mForumQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, CREATEFORUMV2MSG_PARENTMSG); - } -} - - -void CreateForumV2Msg::saveForumInfo(const RsGroupMetaData &meta) -{ - mForumMeta = meta; - mForumMetaLoaded = true; - - loadFormInformation(); -} - -void CreateForumV2Msg::saveParentMsg(const RsForumV2Msg &msg) -{ - mParentMsg = msg; - mParentMsgLoaded = true; - - loadFormInformation(); -} - -void CreateForumV2Msg::loadFormInformation() -{ - if ((!mParentMsgLoaded) && (mParentId != "")) - { - std::cerr << "CreateForumV2Msg::loadMsgInformation() ParentMsg not Loaded Yet"; - std::cerr << std::endl; - return; - } - - if (!mForumMetaLoaded) - { - std::cerr << "CreateForumV2Msg::loadMsgInformation() ForumMeta not Loaded Yet"; - std::cerr << std::endl; - return; - } - - std::cerr << "CreateForumV2Msg::loadMsgInformation() Data Available!"; - std::cerr << std::endl; - - QString name = QString::fromUtf8(mForumMeta.mGroupName.c_str()); - QString subj; - if (mParentId != "") - { - QString title = QString::fromUtf8(mParentMsg.mMeta.mMsgName.c_str()); - name += " " + tr("In Reply to") + ": "; - name += title; - - QString text = title; - - if (text.startsWith("Re:", Qt::CaseInsensitive)) - { - subj = title; - } - else - { - subj = "Re: " + title; - } - - } - - ui.forumName->setText(misc::removeNewLine(name)); - ui.forumSubject->setText(misc::removeNewLine(subj)); - - if (!ui.forumSubject->text().isEmpty()) - { - ui.forumMessage->setFocus(); - } - else - { - ui.forumSubject->setFocus(); - } - - if (mForumMeta.mGroupFlags & RS_DISTRIB_AUTHEN_REQ) - { - ui.signBox->setChecked(true); - ui.signBox->setEnabled(false); - } - else - { - /* Uncheck sign box by default for anonymous forums */ - ui.signBox->setChecked(false); - ui.signBox->setEnabled(true); - } - - ui.forumMessage->setText(""); -} - - - -void CreateForumV2Msg::createMsg() -{ - QString name = misc::removeNewLine(ui.forumSubject->text()); - QString desc = ui.forumMessage->toHtml(); - - if(desc == QTextDocument(ui.forumMessage->toPlainText()).toHtml()) - desc = ui.forumMessage->toPlainText() ; - - if(name.isEmpty()) - { /* error message */ - QMessageBox::warning(this, tr("RetroShare"),tr("Please set a Forum Subject and Forum Message"), - QMessageBox::Ok, QMessageBox::Ok); - - return; //Don't add a empty Subject!! - } - - RsForumV2Msg msg; - msg.mMeta.mGroupId = mForumId; - msg.mMeta.mParentId = mParentId; - msg.mMeta.mMsgId = ""; - if (mParentMsgLoaded) - { - msg.mMeta.mThreadId = mParentMsg.mMeta.mThreadId; - } - - msg.mMeta.mMsgName = std::string(name.toUtf8()); - msg.mMsg = std::string(desc.toUtf8()); - msg.mMeta.mMsgFlags = RS_DISTRIB_AUTHEN_REQ; - - if ((msg.mMsg == "") && (msg.mMeta.mMsgName == "")) - return; /* do nothing */ - - uint32_t token; - rsForumsV2->createMsg(token, msg, true); - close(); - - - // Previous Info - for reference. - - //ForumMsgInfo msgInfo; - - //msgInfo.forumId = mForumId; - //msgInfo.threadId = ""; - //msgInfo.parentId = mParentId; - //msgInfo.msgId = ""; - - //msgInfo.title = name.toStdWString(); - //msgInfo.msg = desc.toStdWString(); - //msgInfo.msgflags = 0; - - //if (ui.signBox->isChecked()) - //{ - // msgInfo.msgflags = RS_DISTRIB_AUTHEN_REQ; - //} - - //if ((msgInfo.msg == L"") && (msgInfo.title == L"")) - // return; /* do nothing */ - - //if (rsForumsV2->ForumMessageSend(msgInfo) == true) { - // close(); - //} -} - - - - -void CreateForumV2Msg::closeEvent (QCloseEvent * /*event*/) -{ - Settings->saveWidgetInformation(this); -} - -void CreateForumV2Msg::cancelMsg() -{ - close(); -} - -void CreateForumV2Msg::smileyWidgetForums() -{ - Emoticons::showSmileyWidget(this, ui.emoticonButton, SLOT(addSmileys()), false); -} - -void CreateForumV2Msg::addSmileys() -{ - ui.forumMessage->textCursor().insertText(qobject_cast(sender())->toolTip().split("|").first()); -} - -void CreateForumV2Msg::addFile() -{ - QStringList files; - if (misc::getOpenFileNames(this, RshareSettings::LASTDIR_EXTRAFILE, tr("Add Extra File"), "", files)) { - ui.hashBox->addAttachments(files); - } -} - -void CreateForumV2Msg::fileHashingFinished(QList hashedFiles) -{ - std::cerr << "CreateForumV2Msg::fileHashingFinished() started." << std::endl; - - QString mesgString; - - QList::iterator it; - for (it = hashedFiles.begin(); it != hashedFiles.end(); ++it) { - HashedFile& hashedFile = *it; - RetroShareLink link; - if (link.createFile(hashedFile.filename, hashedFile.size, QString::fromStdString(hashedFile.hash))) { - mesgString += link.toHtmlSize() + "
"; - } - } - -#ifdef CHAT_DEBUG - std::cerr << "CreateForumV2Msg::anchorClicked mesgString : " << mesgString.toStdString() << std::endl; -#endif - - if (!mesgString.isEmpty()) { - ui.forumMessage->textCursor().insertHtml(mesgString); - } - - ui.forumMessage->setFocus( Qt::OtherFocusReason ); -} - -void CreateForumV2Msg::pasteLink() -{ - ui.forumMessage->insertHtml(RSLinkClipboard::toHtml()) ; -} - -void CreateForumV2Msg::pasteLinkFull() -{ - ui.forumMessage->insertHtml(RSLinkClipboard::toHtmlFull()) ; -} - -void CreateForumV2Msg::pasteOwnCertificateLink() -{ - RetroShareLink link ; - std::string ownId = rsPeers->getOwnId() ; - if( link.createCertificate(ownId) ) { - ui.forumMessage->insertHtml(link.toHtml() + " "); - } -} - - - - -void CreateForumV2Msg::loadForumInfo(const uint32_t &token) -{ - std::cerr << "CreateForumV2Msg::loadForumInfo()"; - std::cerr << std::endl; - - std::list groupInfo; - rsForumsV2->getGroupSummary(token, groupInfo); - - if (groupInfo.size() == 1) - { - RsGroupMetaData fi = groupInfo.front(); - saveForumInfo(fi); - } - else - { - std::cerr << "CreateForumV2Msg::loadForumInfo() ERROR INVALID Number of Forums"; - std::cerr << std::endl; - } -} - - -void CreateForumV2Msg::loadParentMsg(const uint32_t &token) -{ - std::cerr << "CreateForumV2Msg::loadParentMsg()"; - std::cerr << std::endl; - - // Only grab one.... ignore more (shouldn't be any). - RsForumV2Msg msg; - rsForumsV2->getMsgData(token, msg); - saveParentMsg(msg); -} - - - -void CreateForumV2Msg::loadRequest(const TokenQueue *queue, const TokenRequest &req) -{ - std::cerr << "CreateForumV2::loadRequest() UserType: " << req.mUserType; - std::cerr << std::endl; - - if (queue == mForumQueue) - { - /* now switch on req */ - switch(req.mUserType) - { - case CREATEFORUMV2MSG_FORUMINFO: - loadForumInfo(req.mToken); - break; - - case CREATEFORUMV2MSG_PARENTMSG: - loadParentMsg(req.mToken); - break; - default: - std::cerr << "CreateForumV2::loadRequest() UNKNOWN UserType "; - std::cerr << std::endl; - - } - } -} - diff --git a/retroshare-gui/src/gui/forumsv2/CreateForumV2Msg.h b/retroshare-gui/src/gui/forumsv2/CreateForumV2Msg.h deleted file mode 100644 index 5b5de0194..000000000 --- a/retroshare-gui/src/gui/forumsv2/CreateForumV2Msg.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************** - * RetroShare is distributed under the following license: - * - * Copyright (C) 2008 Robert Fernie - * - * 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 _CREATE_FORUMV2_MSG_DIALOG_H -#define _CREATE_FORUMV2_MSG_DIALOG_H - -#include "ui_CreateForumV2Msg.h" - -#include "util/TokenQueue.h" - -#include - - -class CreateForumV2Msg : public QMainWindow, public TokenResponse -{ - Q_OBJECT - -public: - CreateForumV2Msg(std::string fId, std::string pId); - - void newMsg(); /* cleanup */ - virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req); - -private slots: - /** Create the context popup menu and it's submenus */ - void forumMessageCostumPopupMenu( QPoint point ); - - void fileHashingFinished(QList hashedFiles); - /* actions to take.... */ - void createMsg(); - void cancelMsg(); - void pasteLink(); - void pasteLinkFull(); - void pasteOwnCertificateLink(); - - void smileyWidgetForums(); - void addSmileys(); - void addFile(); - -protected: - void closeEvent (QCloseEvent * event); - -private: - - void saveForumInfo(const RsGroupMetaData &meta); - void saveParentMsg(const RsForumV2Msg &msg); - void loadFormInformation(); - - void loadForumInfo(const uint32_t &token); - void loadParentMsg(const uint32_t &token); - - std::string mForumId; - std::string mParentId; - - bool mParentMsgLoaded; - bool mForumMetaLoaded; - RsForumV2Msg mParentMsg; - RsGroupMetaData mForumMeta; - - TokenQueue *mForumQueue; - - /** Qt Designer generated object */ - Ui::CreateForumV2Msg ui; -}; - -#endif - diff --git a/retroshare-gui/src/gui/forumsv2/CreateForumV2Msg.ui b/retroshare-gui/src/gui/forumsv2/CreateForumV2Msg.ui deleted file mode 100644 index a9ce1bf29..000000000 --- a/retroshare-gui/src/gui/forumsv2/CreateForumV2Msg.ui +++ /dev/null @@ -1,333 +0,0 @@ - - - CreateForumV2Msg - - - Qt::NonModal - - - - 0 - 0 - 482 - 448 - - - - Post Forum Message - - - - :/images/rstray3.png:/images/rstray3.png - - - QToolBar#toolBar{background-image: url(:/images/connect/connectFriendBanner.png)} - - - Qt::ToolButtonTextUnderIcon - - - - - 0 - - - 0 - - - - - - - QFrame::NoFrame - - - QFrame::Raised - - - - 6 - - - 6 - - - - - - - Forum - - - - - - - false - - - - - - - - - - - Subject - - - - - - - - - - - - - - - - 16777215 - 38 - - - - QFrame#frame_2{ -background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, -stop:0 #FEFEFE, stop:1 #E8E8E8); - -border: 1px solid #CCCCCC;} - - - QFrame::Raised - - - - 6 - - - - - Qt::NoFocus - - - Attach File - - - - - - - :/images/add-share24.png:/images/add-share24.png - - - - 24 - 24 - - - - true - - - - - - - Qt::NoFocus - - - - - - - :/images/emoticons/kopete/kopete020.png:/images/emoticons/kopete/kopete020.png - - - - 24 - 24 - - - - true - - - - - - - Qt::NoFocus - - - Sign Message - - - - :/images/pgp.png:/images/pgp.png - - - - 24 - 24 - - - - true - - - - - - - Qt::Horizontal - - - - 40 - 15 - - - - - - - - Qt::NoFocus - - - Paste RetroShare Link - - - - - - - :/images/pasterslink.png:/images/pasterslink.png - - - true - - - - - - - - - - QFrame::NoFrame - - - QFrame::Raised - - - - 6 - - - 6 - - - - - Forum Post - - - - - - Qt::CustomContextMenu - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p></body></html> - - - - - - - - - - Attach files via drag and drop - - - - - - - 0 - 0 - - - - You can attach files via drag and drop here in this window - - - true - - - - - - - - - - - - - - - - toolBar - - - TopToolBarArea - - - false - - - - - - - - :/images/mail_send24.png:/images/mail_send24.png - - - Post Forum Msg - - - - - - :/images/button_cancel.png:/images/button_cancel.png - - - Close - - - - - - HashBox - QScrollArea -
gui/common/HashBox.h
- 1 -
-
- - - - -
diff --git a/retroshare-gui/src/gui/forumsv2/EditForumV2Details.cpp b/retroshare-gui/src/gui/forumsv2/EditForumV2Details.cpp deleted file mode 100644 index 5d7d9c690..000000000 --- a/retroshare-gui/src/gui/forumsv2/EditForumV2Details.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************** - * RetroShare 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 "EditForumV2Details.h" - -#include - -#include "util/misc.h" - -#include -#include -#include - - -/** Default constructor */ -EditForumV2Details::EditForumV2Details(std::string forumId, QWidget *parent, Qt::WFlags flags) - : QDialog(parent, flags), m_forumId(forumId) -{ - /* Invoke Qt Designer generated QObject setup routine */ - ui.setupUi(this); - - connect(ui.applyButton, SIGNAL(clicked()), this, SLOT(applyDialog())); - - loadForum(); -} - -void EditForumV2Details::loadForum() -{ - if (!rsForumsV2) { - return; - } - -#warning "EditForumV2Details incomplete" -#if 0 - ForumInfo info; - rsForumsV2->getForumInfo(m_forumId, info); - - // set name - ui.nameline->setText(QString::fromStdWString(info.forumName)); - - // set description - ui.DescriptiontextEdit->setText(QString::fromStdWString(info.forumDesc)); -#endif - -} - -void EditForumV2Details::applyDialog() -{ - if (!rsForumsV2) { - return; - } - - // if text boxes have not been edited leave alone - if (!ui.nameline->isModified() && !ui.DescriptiontextEdit->document()->isModified()) { - return; - } - -#warning "EditForumV2Details incomplete" -#if 0 - - ForumInfo info; - - info.forumName = misc::removeNewLine(ui.nameline->text()).toStdWString(); - info.forumDesc = ui.DescriptiontextEdit->document()->toPlainText().toStdWString(); - - rsForumsV2->setForumInfo(m_forumId, info); -#endif - - /* close the Dialog after the Changes applied */ - close(); -} diff --git a/retroshare-gui/src/gui/forumsv2/EditForumV2Details.h b/retroshare-gui/src/gui/forumsv2/EditForumV2Details.h deleted file mode 100644 index 55c9c2bc7..000000000 --- a/retroshare-gui/src/gui/forumsv2/EditForumV2Details.h +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************** - * RetroShare 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 _EDITFORUMV2DETAILS_H -#define _EDITFORUMV2DETAILS_H - -#include - -#include "ui_EditForumV2Details.h" - -class EditForumV2Details : public QDialog -{ - Q_OBJECT - -public: - /** Default constructor */ - EditForumV2Details(std::string forumId = "", QWidget *parent = 0, Qt::WFlags flags = 0); - -signals: - void configChanged(); - -private slots: - void applyDialog(); - -private: - void loadForum(); - - std::string m_forumId; - - /** Qt Designer generated object */ - Ui::EditForumV2Details ui; -}; - -#endif - diff --git a/retroshare-gui/src/gui/forumsv2/EditForumV2Details.ui b/retroshare-gui/src/gui/forumsv2/EditForumV2Details.ui deleted file mode 100644 index b32810506..000000000 --- a/retroshare-gui/src/gui/forumsv2/EditForumV2Details.ui +++ /dev/null @@ -1,130 +0,0 @@ - - - EditForumV2Details - - - - 0 - 0 - 436 - 355 - - - - Forum Details - - - - :/images/rstray3.png:/images/rstray3.png - - - - - - - - Qt::Horizontal - - - - 311 - 20 - - - - - - - - Cancel - - - - - - - OK - - - false - - - true - - - - - - - - - 0 - - - - - :/images/info16.png:/images/info16.png - - - Edit Forum Details - - - - - - Forum Info - - - - - - Forum Name - - - - - - - - - - Forum Description - - - - - - - - - - - - - - - - - - - - - - - cancelButton - clicked() - EditForumDetails - close() - - - 307 - 333 - - - 217 - 177 - - - - - diff --git a/retroshare-gui/src/gui/forumsv2/ForumV2Details.cpp b/retroshare-gui/src/gui/forumsv2/ForumV2Details.cpp deleted file mode 100644 index 0f3d0f4dc..000000000 --- a/retroshare-gui/src/gui/forumsv2/ForumV2Details.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/**************************************************************** - * RetroShare is distributed under the following license: - * - * Copyright (C) 2009 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 "ForumV2Details.h" - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - - -/* Define the format used for displaying the date and time */ -#define DATETIME_FMT "MMM dd hh:mm:ss" - -/** Default constructor */ -ForumV2Details::ForumV2Details(QWidget *parent, Qt::WFlags flags) - : QDialog(parent, flags) -{ - /* Invoke Qt Designer generated QObject setup routine */ - ui.setupUi(this); - - connect(ui.applyButton, SIGNAL(clicked()), this, SLOT(applyDialog())); - connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(closeinfodlg())); - - ui.applyButton->setToolTip(tr("Apply and Close")); - - ui.nameline ->setReadOnly(true); - ui.popline ->setReadOnly(true); - ui.postline ->setReadOnly(true); - ui.IDline ->setReadOnly(true); - ui.DescriptiontextEdit ->setReadOnly(true); - - ui.radioButton_authd->setEnabled(false); - ui.radioButton_anonymous->setEnabled(false); -} - - -/** - Overloads the default show() slot so we can set opacity*/ - -void -ForumV2Details::show() -{ - //loadSettings(); - if(!this->isVisible()) { - QDialog::show(); - - } -} - -void ForumV2Details::closeEvent (QCloseEvent * event) -{ - QWidget::closeEvent(event); -} - -void ForumV2Details::closeinfodlg() -{ - close(); -} - -void ForumV2Details::showDetails(std::string mCurrForumId) -{ - fId = mCurrForumId; - loadDialog(); -} - -void ForumV2Details::loadDialog() -{ - if (!rsForumsV2) - { - return; - } - -#warning "ForumV2Details Incomplete" -#if 0 - ForumInfo fi; - rsForumsV2->getForumInfo(fId, fi); - - // Set Forum Name - ui.nameline->setText(QString::fromStdWString(fi.forumName)); - - // Set Popularity - ui.popline->setText(QString::number(fi.pop)); - - // Set Last Post Date - if (fi.lastPost) { - QDateTime qtime; - qtime.setTime_t(fi.lastPost); - QString timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss"); - ui.postline->setText(timestamp); - } - - // Set Forum ID - ui.IDline->setText(QString::fromStdString(fi.forumId)); - - // Set Forum Description - ui.DescriptiontextEdit->setText(QString::fromStdWString(fi.forumDesc)); - - if (fi.forumFlags & RS_DISTRIB_AUTHEN_REQ) - { - ui.radioButton_authd->setChecked(true); - ui.radioButton_anonymous->setChecked(false); - } - if (fi.forumFlags & RS_DISTRIB_AUTHEN_ANON) - { - ui.radioButton_authd->setChecked(false); - ui.radioButton_anonymous->setChecked(true); - } -#endif - -} - -void ForumV2Details::applyDialog() -{ - - /* reload now */ - loadDialog(); - - /* close the Dialog after the Changes applied */ - closeinfodlg(); - -} diff --git a/retroshare-gui/src/gui/forumsv2/ForumV2Details.h b/retroshare-gui/src/gui/forumsv2/ForumV2Details.h deleted file mode 100644 index 3489fb344..000000000 --- a/retroshare-gui/src/gui/forumsv2/ForumV2Details.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************** - * RetroShare is distributed under the following license: - * - * Copyright (C) 2009 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 _FORUMV2DETAILS_H -#define _FORUMV2DETAILS_H - -#include - -#include "ui_ForumV2Details.h" - -class ForumV2Details : public QDialog -{ - Q_OBJECT - - public: - - /** Default constructor */ - ForumV2Details(QWidget *parent = 0, Qt::WFlags flags = 0); - /** Default destructor */ - - void showDetails(std::string mCurrForumId); - -signals: - void configChanged() ; - -public slots: - /** Overloaded QWidget.show */ - void show(); - -protected: - void closeEvent (QCloseEvent * event); - -private slots: - - void closeinfodlg(); - void applyDialog(); - -private: - - void loadDialog(); - - std::string fId; - /** Qt Designer generated object */ - Ui::ForumV2Details ui; - -}; - -#endif - diff --git a/retroshare-gui/src/gui/forumsv2/ForumV2Details.ui b/retroshare-gui/src/gui/forumsv2/ForumV2Details.ui deleted file mode 100644 index c9e05074b..000000000 --- a/retroshare-gui/src/gui/forumsv2/ForumV2Details.ui +++ /dev/null @@ -1,201 +0,0 @@ - - - ForumV2Details - - - - 0 - 0 - 436 - 355 - - - - Forum Details - - - - :/images/rstray3.png:/images/rstray3.png - - - - - - 0 - - - - - :/images/info16.png:/images/info16.png - - - Forum Details - - - - - - Forum Info - - - - - - Forum Name - - - - - - - - - - Popularity - - - - - - - true - - - - - - - Last Post - - - - - - - true - - - - - - - Forum ID - - - - - - - - - - Forum Description - - - - - - - - - - - - - - - - - :/images/encrypted22.png:/images/encrypted22.png - - - Security - - - - - - Allowed Messages - - - - - - Authenticated Messages - - - - - - - Anonymous Messages - - - true - - - - - - - - - - Qt::Vertical - - - - 358 - 172 - - - - - - - - - - - - - - Qt::Horizontal - - - - 311 - 20 - - - - - - - - Cancel - - - - - - - OK - - - false - - - true - - - - - - - - - - - - diff --git a/retroshare-gui/src/gui/gxs/ForumV2GroupDialog.cpp b/retroshare-gui/src/gui/gxs/ForumV2GroupDialog.cpp deleted file mode 100644 index f462181d2..000000000 --- a/retroshare-gui/src/gui/gxs/ForumV2GroupDialog.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************** - * RetroShare is distributed under the following license: - * - * Copyright (C) 2008 Robert Fernie - * - * 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 "ForumV2GroupDialog.h" - -#include -#include - -ForumV2GroupDialog::ForumV2GroupDialog(QWidget *parent) - :GxsGroupDialog(rsForumsV2, parent) -{ - - // To start with we only have open forums - with distribution controls. - - uint32_t enabledFlags = ( GXS_GROUP_FLAGS_ICON | - GXS_GROUP_FLAGS_DESCRIPTION | - GXS_GROUP_FLAGS_DISTRIBUTION | - // GXS_GROUP_FLAGS_PUBLISHSIGN | - GXS_GROUP_FLAGS_SHAREKEYS | - // GXS_GROUP_FLAGS_PERSONALSIGN | - // GXS_GROUP_FLAGS_COMMENTS | - 0); - - uint32_t readonlyFlags = 0; - - uint32_t defaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC | - //GXS_GROUP_DEFAULTS_DISTRIB_GROUP | - //GXS_GROUP_DEFAULTS_DISTRIB_LOCAL | - - GXS_GROUP_DEFAULTS_PUBLISH_OPEN | - //GXS_GROUP_DEFAULTS_PUBLISH_THREADS | - //GXS_GROUP_DEFAULTS_PUBLISH_REQUIRED | - //GXS_GROUP_DEFAULTS_PUBLISH_ENCRYPTED | - - //GXS_GROUP_DEFAULTS_PERSONAL_GPG | - GXS_GROUP_DEFAULTS_PERSONAL_REQUIRED | - //GXS_GROUP_DEFAULTS_PERSONAL_IFNOPUB | - - //GXS_GROUP_DEFAULTS_COMMENTS_YES | - GXS_GROUP_DEFAULTS_COMMENTS_NO | - 0); - - setFlags(enabledFlags, readonlyFlags, defaultsFlags); - -} - - -bool ForumV2GroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta) -{ - // Specific Function. - RsForumV2Group grp; - grp.mMeta = meta; - //grp.mDescription = std::string(desc.toUtf8()); - - rsForumsV2->createGroup(token, grp, true); - return true; -} - -void ForumV2GroupDialog::service_loadExistingGroup(const uint32_t &token) -{ - std::cerr << "ForumV2GroupDialog::service_loadExistingGroup()"; - std::cerr << std::endl; - - RsForumV2Group group; - if (!rsForumsV2->getGroupData(token, group)) - { - std::cerr << "ForumV2GroupDialog::service_loadExistingGroup() ERROR Getting Group"; - std::cerr << std::endl; - - return; - } - - /* must call metadata loader */ - loadExistingGroupMetaData(group.mMeta); - - /* now load any extra data we feel like */ - -} - - - - diff --git a/retroshare-gui/src/gui/gxs/ForumV2GroupDialog.h b/retroshare-gui/src/gui/gxs/ForumV2GroupDialog.h deleted file mode 100644 index f549ae077..000000000 --- a/retroshare-gui/src/gui/gxs/ForumV2GroupDialog.h +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************** - * RetroShare is distributed under the following license: - * - * Copyright (C) 2008 Robert Fernie - * - * 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 _FORUMV2_GROUP_DIALOG_H -#define _FORUMV2_GROUP_DIALOG_H - -#include "GxsGroupDialog.h" - -class ForumV2GroupDialog : public GxsGroupDialog -{ - Q_OBJECT - -public: - ForumV2GroupDialog(QWidget *parent); - -protected: - virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta); -// virtual bool service_CompleteCreateGroup(const RsGroupMetaData &meta); - - virtual void service_loadExistingGroup(const uint32_t &token); - -}; - -#endif - diff --git a/retroshare-gui/src/gui/gxs/GxsForumGroupDialog.cpp b/retroshare-gui/src/gui/gxs/GxsForumGroupDialog.cpp index 7f8773671..a9dceae31 100644 --- a/retroshare-gui/src/gui/gxs/GxsForumGroupDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsForumGroupDialog.cpp @@ -55,18 +55,26 @@ const uint32_t ForumCreateDefaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC GxsForumGroupDialog::GxsForumGroupDialog(TokenQueue *tokenQueue, QWidget *parent) - :GxsGroupDialog(tokenQueue, ForumCreateEnabledFlags, ForumCreateDefaultsFlags, parent, "Create New Forum") + :GxsGroupDialog(tokenQueue, ForumCreateEnabledFlags, ForumCreateDefaultsFlags, parent) { } GxsForumGroupDialog::GxsForumGroupDialog(const RsGxsForumGroup &group, QWidget *parent) - :GxsGroupDialog(group.mMeta, GXS_GROUP_DIALOG_SHOW_MODE, parent) + :GxsGroupDialog(group.mMeta, GXS_GROUP_DIALOG_SHOW_MODE, parent) { return; } +QString GxsForumGroupDialog::serviceHeader() +{ + return tr("Create New Forum"); +} +QPixmap GxsForumGroupDialog::serviceImage() +{ + return QPixmap(":/images/konversation64.png"); +} bool GxsForumGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta) { @@ -78,5 +86,3 @@ bool GxsForumGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMeta rsGxsForums->createGroup(token, grp); return true; } - - diff --git a/retroshare-gui/src/gui/gxs/GxsForumGroupDialog.h b/retroshare-gui/src/gui/gxs/GxsForumGroupDialog.h index 8d27e0864..2dc8d1a27 100644 --- a/retroshare-gui/src/gui/gxs/GxsForumGroupDialog.h +++ b/retroshare-gui/src/gui/gxs/GxsForumGroupDialog.h @@ -35,7 +35,9 @@ public: GxsForumGroupDialog(const RsGxsForumGroup &group, QWidget *parent); protected: - virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta); + virtual QString serviceHeader(); + virtual QPixmap serviceImage(); + virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta); }; #endif diff --git a/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp b/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp index 402fd3cde..0cf782840 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupDialog.cpp @@ -50,27 +50,20 @@ #define GXSGROUP_LOADGROUP 2 /** Constructor */ -GxsGroupDialog::GxsGroupDialog(TokenQueue *tokenQueue, uint32_t enableFlags, uint16_t defaultFlags, QWidget *parent, const QString &serviceHeader) -: QDialog(parent), mTokenQueue(tokenQueue), mMode(GXS_GROUP_DIALOG_CREATE_MODE), mEnabledFlags(enableFlags), mDefaultsFlags(defaultFlags), mReadonlyFlags(0) +GxsGroupDialog::GxsGroupDialog(TokenQueue *tokenQueue, uint32_t enableFlags, uint16_t defaultFlags, QWidget *parent) +: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint), mTokenQueue(tokenQueue), mMode(GXS_GROUP_DIALOG_CREATE_MODE), mEnabledFlags(enableFlags), mDefaultsFlags(defaultFlags), mReadonlyFlags(0) { /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); // connect up the buttons. - connect( ui.cancelButton, SIGNAL( clicked ( bool ) ), this, SLOT( cancelDialog( ) ) ); - connect( ui.createButton, SIGNAL( clicked ( bool ) ), this, SLOT( submitGroup( ) ) ); + connect( ui.buttonBox, SIGNAL(accepted()), this, SLOT(submitGroup())); + connect( ui.buttonBox, SIGNAL(rejected()), this, SLOT(cancelDialog())); connect( ui.pubKeyShare_cb, SIGNAL( clicked() ), this, SLOT( setShareList( ) )); connect( ui.groupLogo, SIGNAL(clicked() ), this , SLOT(addGroupLogo())); connect( ui.addLogoButton, SIGNAL(clicked() ), this , SLOT(addGroupLogo())); - if(!serviceHeader.isEmpty()) - ui.mServiceHeader->setText(serviceHeader); - setWindowTitle(serviceHeader); - - //ui.headerFrame->setHeaderImage(QPixmap(":/WikiPoos/images/resource-group-new_48.png")); - //ui.headerFrame->setHeaderText(tr("Create")); - if (!ui.pubKeyShare_cb->isChecked()) { ui.contactsdockWidget->hide(); @@ -93,13 +86,22 @@ GxsGroupDialog::GxsGroupDialog(const RsGroupMetaData &grpMeta, uint32_t mode, QW ui.idChooser->loadIds(0,""); } +void GxsGroupDialog::showEvent(QShowEvent*) +{ + QString header = serviceHeader(); + ui.headerFrame->setHeaderText(header); + setWindowTitle(header); + ui.headerFrame->setHeaderImage(serviceImage()); +} + void GxsGroupDialog::setMode(uint32_t mode) { switch(mMode) { case GXS_GROUP_DIALOG_CREATE_MODE: { - ui.createButton->setText(tr("Create Group")); + ui.buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + ui.buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Create Group")); newGroup(); } break; @@ -107,8 +109,7 @@ void GxsGroupDialog::setMode(uint32_t mode) default: case GXS_GROUP_DIALOG_SHOW_MODE: { - ui.cancelButton->setVisible(false); - ui.createButton->setText(tr("Close")); + ui.buttonBox->setStandardButtons(QDialogButtonBox::Close); } break; //TODO @@ -354,7 +355,6 @@ uint32_t GxsGroupDialog::getGroupSignFlags() void GxsGroupDialog::setGroupSignFlags(uint32_t signFlags) { - if (signFlags & RSGXS_GROUP_SIGN_PUBLISH_ENCRYPTED) { ui.publish_encrypt->setChecked(true); } else if (signFlags & RSGXS_GROUP_SIGN_PUBLISH_ALLSIGNED) { @@ -388,7 +388,6 @@ void GxsGroupDialog::setGroupSignFlags(uint32_t signFlags) } } - void GxsGroupDialog::cancelDialog() { std::cerr << "GxsGroupDialog::cancelDialog() Should Close!"; @@ -397,7 +396,6 @@ void GxsGroupDialog::cancelDialog() close(); } - void GxsGroupDialog::addGroupLogo() { QPixmap img = misc::getOpenThumbnailedPicture(this, tr("Load Group Logo"), 64, 64); @@ -408,7 +406,7 @@ void GxsGroupDialog::addGroupLogo() picture = img; // to show the selected - ui.groupLogo->setIcon(picture); + ui.groupLogo->setPixmap(picture); } QPixmap GxsGroupDialog::getLogo() @@ -441,13 +439,13 @@ void GxsGroupDialog::setShareList() } } -void GxsGroupDialog::wikitype() -{ - // hide logo Button/Label - ui.groupLogo->hide(); - ui.addLogoButton->hide(); - - ui.headerImage->setPixmap(QPixmap(":/images/resource-group-new_48.png")) ; - ui.pubKeyShare_cb->setText(tr("Add Wiki Moderators")); - ui.contactsdockWidget->setWindowTitle(tr("Select Wiki Moderators")); -} +void GxsGroupDialog::wikitype() +{ + // hide logo Button/Label + ui.groupLogo->hide(); + ui.addLogoButton->hide(); + + ui.headerFrame->setHeaderImage(QPixmap(":/images/resource-group-new_48.png")) ; + ui.pubKeyShare_cb->setText(tr("Add Wiki Moderators")); + ui.contactsdockWidget->setWindowTitle(tr("Select Wiki Moderators")); +} diff --git a/retroshare-gui/src/gui/gxs/GxsGroupDialog.h b/retroshare-gui/src/gui/gxs/GxsGroupDialog.h index b4186c898..4c89e2ac0 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupDialog.h +++ b/retroshare-gui/src/gui/gxs/GxsGroupDialog.h @@ -125,7 +125,7 @@ public: * @param parent The parent dialog * @param mode */ - GxsGroupDialog(TokenQueue* tokenQueue, uint32_t enableFlags, uint16_t defaultFlags, QWidget *parent = NULL, const QString& serviceHeader = ""); + GxsGroupDialog(TokenQueue* tokenQueue, uint32_t enableFlags, uint16_t defaultFlags, QWidget *parent = NULL); /*! * Contructs a GxsGroupDialog for display a group or editing @@ -134,11 +134,11 @@ public: * @param parent */ GxsGroupDialog(const RsGroupMetaData& grpMeta, uint32_t mode = GXS_GROUP_DIALOG_SHOW_MODE, QWidget *parent = NULL); - void wikitype(); + void wikitype(); private: void newGroup(); - void setMode(uint32_t mode); + void setMode(uint32_t mode); // Functions that can be overloaded for specific stuff. @@ -147,6 +147,10 @@ protected slots: void addGroupLogo(); protected: + virtual void showEvent(QShowEvent*); + + virtual QString serviceHeader() = 0; + virtual QPixmap serviceImage() = 0; /*! * Main purpose is to help tansfer meta data to service diff --git a/retroshare-gui/src/gui/gxs/GxsGroupDialog.ui b/retroshare-gui/src/gui/gxs/GxsGroupDialog.ui index b67f9eee4..c2811703c 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupDialog.ui +++ b/retroshare-gui/src/gui/gxs/GxsGroupDialog.ui @@ -25,53 +25,7 @@ 0 - - - - 16777215 - 64 - - - - - 11 - - - - - - - QFrame::NoFrame - - - QFrame::Raised - - - - 6 - - - - - - 48 - 48 - - - - - - - - - - - Create New - - - - - + @@ -103,7 +57,7 @@ 0 - + 64 @@ -116,24 +70,17 @@ 64 - - -border: 2px solid white; -border-radius: 10px; - + + QFrame::StyledPanel - - + + QFrame::Raised - - - :/images/channels.png:/images/channels.png + + :/images/channels.png - - - 64 - 64 - + + true @@ -195,11 +142,7 @@ border-radius: 10px; - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Key recipients can publish to restricted-type Wiki Group, and can view and publish for private-type channels</span></p></body></html> + Key recipients can publish to restricted-type Wiki Group, and can view and publish for private-type channels Share Publish Key @@ -518,33 +461,10 @@ p, li { white-space: pre-wrap; } - - - - Qt::Horizontal - - - - 238 - 20 - - - - - - - Cancel - - - - - - - Create - - - true + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok @@ -554,26 +474,26 @@ p, li { white-space: pre-wrap; }
+ + GxsIdChooser + QComboBox +
gui/gxs/GxsIdChooser.h
+
+ + HeaderFrame + QFrame +
gui/common/HeaderFrame.h
+ 1 +
FriendSelectionWidget QWidget
gui/common/FriendSelectionWidget.h
1
- - GxsIdChooser - QComboBox -
gui/gxs/GxsIdChooser.h
-
- - - - - - diff --git a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp index bee6c95cd..17668bb61 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp @@ -21,31 +21,28 @@ #include "GxsIdTreeWidgetItem.h" -#include - #include #include /** Constructor */ -GxsIdTreeWidgetItem::GxsIdTreeWidgetItem(QTreeWidget *parent) -:QTreeWidgetItem(parent), QObject(NULL), mTimer(NULL), mCount(0), mColumn(0) +GxsIdTreeWidgetItem::GxsIdTreeWidgetItem(const RSTreeWidgetItemCompareRole *compareRole, QTreeWidget *parent) +:RSTreeWidgetItem(compareRole, parent), QObject(NULL), mTimer(NULL), mCount(0), mColumn(0) { - mTimer = new QTimer(this); - mTimer->setSingleShot(true); - connect(mTimer, SIGNAL(timeout()), this, SLOT(loadId())); - - return; + init(); } -GxsIdTreeWidgetItem::GxsIdTreeWidgetItem(QTreeWidgetItem *parent) -:QTreeWidgetItem(parent), QObject(NULL), mTimer(NULL), mCount(0), mColumn(0) +GxsIdTreeWidgetItem::GxsIdTreeWidgetItem(const RSTreeWidgetItemCompareRole *compareRole, QTreeWidgetItem *parent) +:RSTreeWidgetItem(compareRole, parent), QObject(NULL), mTimer(NULL), mCount(0), mColumn(0) +{ + init(); +} + +void GxsIdTreeWidgetItem::init() { mTimer = new QTimer(this); mTimer->setSingleShot(true); connect(mTimer, SIGNAL(timeout()), this, SLOT(loadId())); - - return; } void GxsIdTreeWidgetItem::setId(const RsGxsId &id, int column) @@ -135,7 +132,6 @@ void GxsIdTreeWidgetItem::loadId() { /* timer event to try again */ mTimer->setInterval(mCount * 1000); - mTimer->start(); + mTimer->start(); } } - diff --git a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.h b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.h index 0db4b346e..9b61bff28 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.h +++ b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.h @@ -23,17 +23,18 @@ #ifndef _GXS_ID_TREEWIDGETITEM_H #define _GXS_ID_TREEWIDGETITEM_H -#include #include #include -class GxsIdTreeWidgetItem : public QObject, public QTreeWidgetItem +#include "gui/common/RSTreeWidgetItem.h" + +class GxsIdTreeWidgetItem : public QObject, public RSTreeWidgetItem { - Q_OBJECT + Q_OBJECT public: - GxsIdTreeWidgetItem(QTreeWidget *parent = NULL); - GxsIdTreeWidgetItem(QTreeWidgetItem *parent); + GxsIdTreeWidgetItem(const RSTreeWidgetItemCompareRole *compareRole, QTreeWidget *parent = NULL); + GxsIdTreeWidgetItem(const RSTreeWidgetItemCompareRole *compareRole, QTreeWidgetItem *parent); void setId(const RsGxsId &id, int column); bool getId(RsGxsId &id); @@ -42,6 +43,7 @@ private slots: void loadId(); private: + void init(); QTimer *mTimer; RsGxsId mId; diff --git a/retroshare-gui/src/gui/gxs/WikiGroupDialog.cpp b/retroshare-gui/src/gui/gxs/WikiGroupDialog.cpp index 6a4026714..dd7c23288 100644 --- a/retroshare-gui/src/gui/gxs/WikiGroupDialog.cpp +++ b/retroshare-gui/src/gui/gxs/WikiGroupDialog.cpp @@ -52,7 +52,7 @@ uint32_t WikiCreateDefaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC | WikiGroupDialog::WikiGroupDialog(TokenQueue *tokenQueue, QWidget *parent) - :GxsGroupDialog(tokenQueue, WikiCreateEnabledFlags, WikiCreateDefaultsFlags, parent, "Create New Wiki Group") + :GxsGroupDialog(tokenQueue, WikiCreateEnabledFlags, WikiCreateDefaultsFlags, parent) { // To start with we only have open forums - with distribution controls. @@ -93,7 +93,6 @@ WikiGroupDialog::WikiGroupDialog(TokenQueue *tokenQueue, QWidget *parent) WikiGroupDialog::WikiGroupDialog(const RsWikiCollection &collection, QWidget *parent) :GxsGroupDialog(collection.mMeta, GXS_GROUP_DIALOG_SHOW_MODE, parent) - { #if 0 @@ -118,6 +117,15 @@ WikiGroupDialog::WikiGroupDialog(const RsWikiCollection &collection, QWidget *pa } +QString WikiGroupDialog::serviceHeader() +{ + return tr("Create New Wiki Group"); +} + +QPixmap WikiGroupDialog::serviceImage() +{ + return QPixmap(); +} bool WikiGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta) { @@ -132,5 +140,3 @@ bool WikiGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMetaData return true; } - - diff --git a/retroshare-gui/src/gui/gxs/WikiGroupDialog.h b/retroshare-gui/src/gui/gxs/WikiGroupDialog.h index fb217d36a..b35333065 100644 --- a/retroshare-gui/src/gui/gxs/WikiGroupDialog.h +++ b/retroshare-gui/src/gui/gxs/WikiGroupDialog.h @@ -35,7 +35,9 @@ public: WikiGroupDialog(const RsWikiCollection &collection, QWidget *parent); protected: - virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta); + virtual QString serviceHeader(); + virtual QPixmap serviceImage(); + virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta); private: diff --git a/retroshare-gui/src/gui/gxsforums/CreateGxsForum.cpp b/retroshare-gui/src/gui/gxsforums/CreateGxsForum.cpp deleted file mode 100644 index 3c2a190d4..000000000 --- a/retroshare-gui/src/gui/gxsforums/CreateGxsForum.cpp +++ /dev/null @@ -1,234 +0,0 @@ -/**************************************************************** - * RetroShare is distributed under the following license: - * - * Copyright (C) 2008 Robert Fernie - * - * 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 - -#include "util/misc.h" -#include "CreateGxsForum.h" -#include "gui/common/PeerDefs.h" - -#include - -#include -#include - -#include - -#define CREATEGXSFORUMS_NEWFORUMID 1 - - -/** Constructor */ -CreateGxsForum::CreateGxsForum(QWidget *parent) -: QDialog(parent) -{ - /* Invoke the Qt Designer generated object setup routine */ - ui.setupUi(this); - - mForumQueue = new TokenQueue(rsGxsForums->getTokenService(), this); - - // connect up the buttons. - connect( ui.cancelButton, SIGNAL( clicked ( bool ) ), this, SLOT( cancelForum( ) ) ); - connect( ui.createButton, SIGNAL( clicked ( bool ) ), this, SLOT( createForum( ) ) ); - connect( ui.pubKeyShare_cb, SIGNAL( clicked() ), this, SLOT( setShareList( ) )); - - if (!ui.pubKeyShare_cb->isChecked()) { - ui.contactsdockWidget->hide(); - this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height()); - } - - /* initialize key share list */ - ui.keyShareList->setHeaderText(tr("Contacts:")); - ui.keyShareList->setModus(FriendSelectionWidget::MODUS_CHECK); - ui.keyShareList->start(); - - newForum(); -} - -void CreateGxsForum::newForum() -{ - /* enforce Public for the moment */ - ui.typePublic->setChecked(true); - - ui.typePrivate->setEnabled(false); - ui.typeEncrypted->setEnabled(true); - -#ifdef RS_RELEASE_VERSION - ui.typePrivate->setVisible(false); - ui.typeEncrypted->setVisible(true); -#endif - - ui.msgAnon->setChecked(true); - //ui.msgAuth->setEnabled(false); - - ui.forumName->clear(); - ui.forumDesc->clear(); - - ui.forumName->setFocus(); -} - -void CreateGxsForum::createForum() -{ - QString name = misc::removeNewLine(ui.forumName->text()); - QString desc = ui.forumDesc->toPlainText(); //toHtml(); - uint32_t flags = 0; - - 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!! - } - -#ifdef TOGXS - if (ui.typePublic->isChecked()) { - flags |= RS_DISTRIB_PUBLIC; - } else if (ui.typePrivate->isChecked()) { - flags |= RS_DISTRIB_PRIVATE; - } else if (ui.typeEncrypted->isChecked()) { - flags |= RS_DISTRIB_ENCRYPTED; - } - - if (ui.msgAuth->isChecked()) { - flags |= RS_DISTRIB_AUTHEN_REQ; - } else if (ui.msgAnon->isChecked()) { - flags |= RS_DISTRIB_AUTHEN_ANON; - } -#endif - - if (rsGxsForums) { - - - uint32_t token; - RsGxsForumGroup grp; - grp.mMeta.mGroupName = std::string(name.toUtf8()); - grp.mDescription = std::string(desc.toUtf8()); - grp.mMeta.mGroupFlags = flags; - - rsGxsForums->createGroup(token, grp); - - // get the Queue to handle response. - mForumQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_SUMMARY, CREATEGXSFORUMS_NEWFORUMID); - - } -} - -void CreateGxsForum::completeCreateNewForum(const RsGroupMetaData &newForumMeta) -{ - sendShareList(newForumMeta.mGroupId); - - close(); -} - - -void CreateGxsForum::sendShareList(std::string forumId) -{ - if (!rsGxsForums) - { - std::cerr << "CreateGxsForum::sendShareList() GxsForums not active"; - std::cerr << std::endl; - return; - } - - if (ui.pubKeyShare_cb->isChecked()) - { - std::list shareList; - ui.keyShareList->selectedSslIds(shareList, false); -#ifdef TOGXS - rsGxsForums->groupShareKeys(forumId, shareList); -#endif - } - close(); -} - - - - - - -void CreateGxsForum::setShareList() -{ - if (ui.pubKeyShare_cb->isChecked()){ - this->resize(this->size().width() + ui.contactsdockWidget->size().width(), this->size().height()); - ui.contactsdockWidget->show(); - } else { // hide share widget - ui.contactsdockWidget->hide(); - this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height()); - } -} - -void CreateGxsForum::cancelForum() -{ - close(); -} - - - - -void CreateGxsForum::loadNewForumId(const uint32_t &token) -{ - std::cerr << "CreateGxsForum::loadNewForumId()"; - std::cerr << std::endl; - - std::list groupInfo; - rsGxsForums->getGroupSummary(token, groupInfo); - - if (groupInfo.size() == 1) - { - RsGroupMetaData fi = groupInfo.front(); - completeCreateNewForum(fi); - } - else - { - std::cerr << "CreateGxsForum::loadNewForumId() ERROR INVALID Number of Forums Created"; - std::cerr << std::endl; - } -} - - - - - - - - -void CreateGxsForum::loadRequest(const TokenQueue *queue, const TokenRequest &req) -{ - std::cerr << "CreateGxsForum::loadRequest() UserType: " << req.mUserType; - std::cerr << std::endl; - - if (queue == mForumQueue) - { - /* now switch on req */ - switch(req.mUserType) - { - - case CREATEGXSFORUMS_NEWFORUMID: - loadNewForumId(req.mToken); - break; - default: - std::cerr << "CreateGxsForum::loadRequest() UNKNOWN UserType "; - std::cerr << std::endl; - - } - } -} - - - diff --git a/retroshare-gui/src/gui/gxsforums/CreateGxsForum.h b/retroshare-gui/src/gui/gxsforums/CreateGxsForum.h deleted file mode 100644 index 05ca6d1c5..000000000 --- a/retroshare-gui/src/gui/gxsforums/CreateGxsForum.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************** - * RetroShare is distributed under the following license: - * - * Copyright (C) 2008 Robert Fernie - * - * 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 _CREATE_GXSFORUM_DIALOG_H -#define _CREATE_GXSFORUM_DIALOG_H - -#include "ui_CreateGxsForum.h" - -#include "util/TokenQueue.h" - -class CreateGxsForum : public QDialog, public TokenResponse -{ - Q_OBJECT - -public: - CreateGxsForum(QWidget *parent = 0); - - void newForum(); /* cleanup */ - - // Callback for all Loads. -virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req); - -private slots: - /* actions to take.... */ - void createForum(); - void cancelForum(); - - // set private forum key share list - void setShareList(); - -private: - void sendShareList(std::string forumId); - void completeCreateNewForum(const RsGroupMetaData &newForumMeta); - void loadNewForumId(const uint32_t &token); - - - std::list mShareList; - - QPixmap picture; - - TokenQueue *mForumQueue; - - /** Qt Designer generated object */ - Ui::CreateGxsForum ui; -}; - -#endif - diff --git a/retroshare-gui/src/gui/gxsforums/CreateGxsForum.ui b/retroshare-gui/src/gui/gxsforums/CreateGxsForum.ui deleted file mode 100644 index 85f7acf24..000000000 --- a/retroshare-gui/src/gui/gxsforums/CreateGxsForum.ui +++ /dev/null @@ -1,374 +0,0 @@ - - - CreateGxsForum - - - - 0 - 0 - 672 - 495 - - - - Create new Forum - - - - :/images/rstray3.png:/images/rstray3.png - - - - 0 - - - 0 - - - - - - 16777215 - 64 - - - - QFrame#frame_2{background-image: url(:/images/connect/connectFriendBanner.png);} - - - QFrame::NoFrame - - - QFrame::Raised - - - - 6 - - - 6 - - - - - - 48 - 48 - - - - - - - - - - :/images/konversation64.png - - - true - - - - - - - color: rgb(255, 255, 255); - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:24pt; font-weight:600; color:#ffffff;">New Forum</span></p></body></html> - - - - - - - - - - QFrame::NoFrame - - - QFrame::Raised - - - - - - - - Name - - - - - - - - - - - - true - - - - 0 - 0 - - - - - 300 - 524287 - - - - - 220 - 0 - - - - - 0 - 0 - - - - check peers you would like to share private publish key with - - - false - - - QDockWidget::NoDockWidgetFeatures - - - Share Key With - - - - - 0 - - - 0 - - - - - - 0 - 4 - - - - - 20 - 0 - - - - - 300 - 16777215 - - - - - 220 - 0 - - - - - 200 - 0 - - - - - - - - - - - - - - Description - - - - - - - - - - - - Type: - - - - 6 - - - - - Public - Anyone can read and publish (Shared Publish Key) - - - - - - - Restricted - Anyone can read, limited publishing (Private Publish Key) - - - - - - - Private - (Private Publish Key required to view Messages) - - - - - - - - - - Key Sharing - - - - 0 - - - 6 - - - - - Key recipients can publish to restricted-type channels, and can view and publish for private-type channels - - - Share Private Publish Key - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Allowed Messages - - - - 0 - - - 6 - - - - - Authenticated Messages - - - - - - - Anonymous Messages - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::Horizontal - - - - 238 - 20 - - - - - - - - Cancel - - - - - - - Create - - - true - - - - - - - - - - - FriendSelectionWidget - QWidget -
gui/common/FriendSelectionWidget.h
- 1 -
-
- - - - -
diff --git a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp index eb8df4a9c..864fe9fb3 100644 --- a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp +++ b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp @@ -35,6 +35,7 @@ #include "gui/RetroShareLink.h" #include "gui/common/Emoticons.h" +#include "util/HandleRichText.h" #include "util/misc.h" #include @@ -46,8 +47,8 @@ /** Constructor */ -CreateGxsForumMsg::CreateGxsForumMsg(std::string fId, std::string pId) -: QMainWindow(NULL), mForumId(fId), mParentId(pId) +CreateGxsForumMsg::CreateGxsForumMsg(const std::string &fId, const std::string &pId) +: QDialog(NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), mForumId(fId), mParentId(pId) { /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); @@ -56,6 +57,12 @@ CreateGxsForumMsg::CreateGxsForumMsg(std::string fId, std::string pId) /* Setup Queue */ mForumQueue = new TokenQueue(rsGxsForums->getTokenService(), this); + QString text = pId.empty() ? tr("Start New Thread") : tr("Post Forum Message"); + setWindowTitle(text); + + ui.headerFrame->setHeaderImage(QPixmap(":/images/konversation64.png")); + ui.headerFrame->setHeaderText(text); + Settings->loadWidgetInformation(this); connect( ui.forumMessage, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( forumMessageCostumPopupMenu( QPoint ) ) ); @@ -63,8 +70,8 @@ CreateGxsForumMsg::CreateGxsForumMsg(std::string fId, std::string pId) connect(ui.hashBox, SIGNAL(fileHashingFinished(QList)), this, SLOT(fileHashingFinished(QList))); // connect up the buttons. - connect( ui.postmessage_action, SIGNAL( triggered (bool) ), this, SLOT( createMsg( ) ) ); - connect( ui.close_action, SIGNAL( triggered (bool) ), this, SLOT( cancelMsg( ) ) ); + connect( ui.buttonBox, SIGNAL(accepted()), this, SLOT(createMsg())); + connect( ui.buttonBox, SIGNAL(rejected()), this, SLOT(close())); connect( ui.emoticonButton, SIGNAL(clicked()), this, SLOT(smileyWidgetForums())); connect( ui.attachFileButton, SIGNAL(clicked() ), this , SLOT(addFile())); connect( ui.pastersButton, SIGNAL(clicked() ), this , SLOT(pasteLink())); @@ -80,9 +87,9 @@ CreateGxsForumMsg::CreateGxsForumMsg(std::string fId, std::string pId) } /** context menu searchTablewidget2 **/ -void CreateGxsForumMsg::forumMessageCostumPopupMenu( QPoint /*point*/ ) +void CreateGxsForumMsg::forumMessageCostumPopupMenu(QPoint point) { - QMenu *contextMnu = ui.forumMessage->createStandardContextMenu(); + QMenu *contextMnu = ui.forumMessage->createStandardContextMenu(point); contextMnu->addSeparator(); QAction *pasteLinkAct = contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteLink())); @@ -233,10 +240,9 @@ void CreateGxsForumMsg::loadFormInformation() void CreateGxsForumMsg::createMsg() { QString name = misc::removeNewLine(ui.forumSubject->text()); - QString desc = ui.forumMessage->toHtml(); + QString desc; - if(desc == QTextDocument(ui.forumMessage->toPlainText()).toHtml()) - desc = ui.forumMessage->toPlainText() ; + RsHtml::optimizeHtml(ui.forumMessage, desc); if(name.isEmpty()) { /* error message */ @@ -324,11 +330,6 @@ void CreateGxsForumMsg::closeEvent (QCloseEvent * /*event*/) Settings->saveWidgetInformation(this); } -void CreateGxsForumMsg::cancelMsg() -{ - close(); -} - void CreateGxsForumMsg::smileyWidgetForums() { Emoticons::showSmileyWidget(this, ui.emoticonButton, SLOT(addSmileys()), false); diff --git a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.h b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.h index a3be9e183..7227234fd 100644 --- a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.h +++ b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.h @@ -29,17 +29,16 @@ #include - -class CreateGxsForumMsg : public QMainWindow, public TokenResponse +class CreateGxsForumMsg : public QDialog, public TokenResponse { Q_OBJECT public: - CreateGxsForumMsg(std::string fId, std::string pId); + CreateGxsForumMsg(const std::string &fId, const std::string &pId); void newMsg(); /* cleanup */ virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req); - + private slots: /** Create the context popup menu and it's submenus */ void forumMessageCostumPopupMenu( QPoint point ); @@ -47,7 +46,6 @@ private slots: void fileHashingFinished(QList hashedFiles); /* actions to take.... */ void createMsg(); - void cancelMsg(); void pasteLink(); void pasteLinkFull(); void pasteOwnCertificateLink(); @@ -60,17 +58,16 @@ protected: void closeEvent (QCloseEvent * event); private: - void saveForumInfo(const RsGroupMetaData &meta); void saveParentMsg(const RsGxsForumMsg &msg); void loadFormInformation(); void loadForumInfo(const uint32_t &token); void loadParentMsg(const uint32_t &token); - + std::string mForumId; std::string mParentId; - + bool mParentMsgLoaded; bool mForumMetaLoaded; RsGxsForumMsg mParentMsg; diff --git a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.ui b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.ui index 40d8dcb15..fcd330af9 100644 --- a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.ui +++ b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.ui @@ -1,16 +1,13 @@ CreateGxsForumMsg - - - Qt::NonModal - + 0 0 482 - 497 + 448 @@ -20,24 +17,27 @@ :/images/rstray3.png:/images/rstray3.png - - QToolBar#toolBar{background-image: url(:/images/connect/connectFriendBanner.png)} - - - Qt::ToolButtonTextUnderIcon - - - - - 0 - - - 0 - - - - - + + + 0 + + + 0 + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + QFrame::NoFrame @@ -45,64 +45,49 @@ QFrame::Raised - - 6 - - - 6 + + 0 - - - - - Forum - - - - - - - false - - - - + + + Forum + + + + + + + false + + - - - - - Subject - - - - - - - + + + Subject + + + + + - - + + 16777215 38 - - QFrame#frame_2{ -background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, -stop:0 #FEFEFE, stop:1 #E8E8E8); - -border: 1px solid #CCCCCC;} + + QFrame::Box - QFrame::Raised + QFrame::Sunken @@ -219,107 +204,65 @@ border: 1px solid #CCCCCC;} - - - - QFrame::NoFrame + + + + Forum Post - - QFrame::Raised - - - - 6 - - - 6 - + - - - Forum Post + + + Qt::CustomContextMenu - - - - - Qt::CustomContextMenu - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"></p></body></html> - - - - - - - - - - Attach files via drag and drop +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p></body></html> - - - - - - 0 - 0 - - - - You can attach files via drag and drop here in this window - - - true - - - - + + + + Attach files via drag and drop + + + + + + + 0 + 0 + + + + You can attach files via drag and drop here in this window + + + true + + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + - - - - - - toolBar - - - TopToolBarArea - - - false - - - - - - - - :/images/mail_send24.png:/images/mail_send24.png - - - Post Forum Msg - - - - - - :/images/button_cancel.png:/images/button_cancel.png - - - Close - - + +
+ @@ -327,6 +270,12 @@ p, li { white-space: pre-wrap; } QComboBox
gui/gxs/GxsIdChooser.h
+ + HeaderFrame + QFrame +
gui/common/HeaderFrame.h
+ 1 +
HashBox QScrollArea diff --git a/retroshare-gui/src/gui/gxsforums/EditGxsForumDetails.cpp b/retroshare-gui/src/gui/gxsforums/EditGxsForumDetails.cpp index 13ebfe43e..840a7f47f 100644 --- a/retroshare-gui/src/gui/gxsforums/EditGxsForumDetails.cpp +++ b/retroshare-gui/src/gui/gxsforums/EditGxsForumDetails.cpp @@ -31,13 +31,14 @@ /** Default constructor */ -EditGxsForumDetails::EditGxsForumDetails(std::string forumId, QWidget *parent, Qt::WFlags flags) - : QDialog(parent, flags), m_forumId(forumId) +EditGxsForumDetails::EditGxsForumDetails(std::string forumId, QWidget *parent) + : QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint), m_forumId(forumId) { /* Invoke Qt Designer generated QObject setup routine */ ui.setupUi(this); - connect(ui.applyButton, SIGNAL(clicked()), this, SLOT(applyDialog())); + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(applyDialog())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(close())); loadForum(); } diff --git a/retroshare-gui/src/gui/gxsforums/EditGxsForumDetails.h b/retroshare-gui/src/gui/gxsforums/EditGxsForumDetails.h index 3a38cc7c9..b21fadafc 100644 --- a/retroshare-gui/src/gui/gxsforums/EditGxsForumDetails.h +++ b/retroshare-gui/src/gui/gxsforums/EditGxsForumDetails.h @@ -32,7 +32,7 @@ class EditGxsForumDetails : public QDialog public: /** Default constructor */ - EditGxsForumDetails(std::string forumId = "", QWidget *parent = 0, Qt::WFlags flags = 0); + EditGxsForumDetails(std::string forumId = "", QWidget *parent = 0); signals: void configChanged(); diff --git a/retroshare-gui/src/gui/gxsforums/EditGxsForumDetails.ui b/retroshare-gui/src/gui/gxsforums/EditGxsForumDetails.ui index b211bd0e6..483e94a2f 100644 --- a/retroshare-gui/src/gui/gxsforums/EditGxsForumDetails.ui +++ b/retroshare-gui/src/gui/gxsforums/EditGxsForumDetails.ui @@ -21,35 +21,9 @@ - - - Qt::Horizontal - - - - 311 - 20 - - - - - - - - Cancel - - - - - - - OK - - - false - - - true + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok @@ -109,22 +83,5 @@ - - - cancelButton - clicked() - EditForumDetails - close() - - - 307 - 333 - - - 217 - 177 - - - - + diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumDetails.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumDetails.cpp index 3f26dc1c5..ed45f8dfd 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumDetails.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumDetails.cpp @@ -19,6 +19,7 @@ * Boston, MA 02110-1301, USA. ****************************************************************/ #include "GxsForumDetails.h" +//#AFTER MERGE #include "util/DateTime.h" #include #include @@ -37,16 +38,13 @@ #define DATETIME_FMT "MMM dd hh:mm:ss" /** Default constructor */ -GxsForumDetails::GxsForumDetails(QWidget *parent, Qt::WFlags flags) - : QDialog(parent, flags) +GxsForumDetails::GxsForumDetails(QWidget *parent) + : QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint) { /* Invoke Qt Designer generated QObject setup routine */ ui.setupUi(this); - connect(ui.applyButton, SIGNAL(clicked()), this, SLOT(applyDialog())); - connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(closeinfodlg())); - - ui.applyButton->setToolTip(tr("Apply and Close")); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(close())); ui.nameline ->setReadOnly(true); ui.popline ->setReadOnly(true); @@ -72,16 +70,6 @@ GxsForumDetails::show() } } -void GxsForumDetails::closeEvent (QCloseEvent * event) -{ - QWidget::closeEvent(event); -} - -void GxsForumDetails::closeinfodlg() -{ - close(); -} - void GxsForumDetails::showDetails(std::string mCurrForumId) { fId = mCurrForumId; @@ -108,10 +96,7 @@ void GxsForumDetails::loadDialog() // Set Last Post Date if (fi.lastPost) { - QDateTime qtime; - qtime.setTime_t(fi.lastPost); - QString timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss"); - ui.postline->setText(timestamp); + ui.postline->setText(DateTime::formatLongDateTime(fi.lastPost)); } // Set Forum ID @@ -133,14 +118,3 @@ void GxsForumDetails::loadDialog() #endif } - -void GxsForumDetails::applyDialog() -{ - - /* reload now */ - loadDialog(); - - /* close the Dialog after the Changes applied */ - closeinfodlg(); - -} diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumDetails.h b/retroshare-gui/src/gui/gxsforums/GxsForumDetails.h index a45f9d018..d7c014262 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumDetails.h +++ b/retroshare-gui/src/gui/gxsforums/GxsForumDetails.h @@ -33,8 +33,7 @@ class GxsForumDetails : public QDialog public: /** Default constructor */ - GxsForumDetails(QWidget *parent = 0, Qt::WFlags flags = 0); - /** Default destructor */ + GxsForumDetails(QWidget *parent = 0); void showDetails(std::string mCurrForumId); @@ -45,14 +44,6 @@ public slots: /** Overloaded QWidget.show */ void show(); -protected: - void closeEvent (QCloseEvent * event); - -private slots: - - void closeinfodlg(); - void applyDialog(); - private: void loadDialog(); diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumDetails.ui b/retroshare-gui/src/gui/gxsforums/GxsForumDetails.ui index 182d7bc63..b6dfb4c1e 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumDetails.ui +++ b/retroshare-gui/src/gui/gxsforums/GxsForumDetails.ui @@ -158,35 +158,9 @@ - - - Qt::Horizontal - - - - 311 - 20 - - - - - - - - Cancel - - - - - - - OK - - - false - - - true + + + QDialogButtonBox::Close