2008-04-09 08:57:26 -04:00
|
|
|
/****************************************************************
|
|
|
|
* 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
|
2010-05-01 15:03:35 -04:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
2008-04-09 08:57:26 -04:00
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
****************************************************************/
|
|
|
|
|
2010-07-23 14:52:58 -04:00
|
|
|
#include <QMenu>
|
|
|
|
#include <QFile>
|
|
|
|
#include <QDateTime>
|
|
|
|
#include <QMessageBox>
|
2010-08-08 18:58:10 -04:00
|
|
|
#include <QItemDelegate>
|
2010-07-23 14:52:58 -04:00
|
|
|
|
2008-04-09 08:57:26 -04:00
|
|
|
#include "ForumsDialog.h"
|
2010-09-14 13:47:11 -04:00
|
|
|
#include "RetroShareLink.h"
|
|
|
|
#include "forums/CreateForum.h"
|
|
|
|
#include "forums/CreateForumMsg.h"
|
|
|
|
#include "forums/ForumDetails.h"
|
2010-09-14 15:38:47 -04:00
|
|
|
#include "forums/EditForumDetails.h"
|
2010-05-23 15:13:41 -04:00
|
|
|
#include "msgs/MessageComposer.h"
|
2010-09-14 13:47:11 -04:00
|
|
|
#include "settings/rsharesettings.h"
|
|
|
|
#include "common/Emoticons.h"
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-08-06 05:40:23 -04:00
|
|
|
#include <retroshare/rspeers.h>
|
|
|
|
#include <retroshare/rsforums.h>
|
2010-01-04 09:29:49 -05:00
|
|
|
|
2008-04-09 08:57:26 -04:00
|
|
|
#include <sstream>
|
2008-11-02 10:20:42 -05:00
|
|
|
#include <algorithm>
|
2008-04-09 08:57:26 -04:00
|
|
|
|
|
|
|
|
|
|
|
/* 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"
|
|
|
|
|
2008-11-26 19:01:46 -05:00
|
|
|
/* Images for TreeWidget */
|
2008-08-12 08:03:23 -04:00
|
|
|
#define IMAGE_FOLDER ":/images/folder16.png"
|
2008-08-16 21:09:32 -04:00
|
|
|
#define IMAGE_FOLDERGREEN ":/images/folder_green.png"
|
|
|
|
#define IMAGE_FOLDERRED ":/images/folder_red.png"
|
|
|
|
#define IMAGE_FOLDERYELLOW ":/images/folder_yellow.png"
|
2008-08-12 08:03:23 -04:00
|
|
|
#define IMAGE_FORUM ":/images/konversation16.png"
|
2009-08-13 09:35:18 -04:00
|
|
|
#define IMAGE_SUBSCRIBE ":/images/edit_add24.png"
|
2008-08-12 17:07:41 -04:00
|
|
|
#define IMAGE_UNSUBSCRIBE ":/images/cancel.png"
|
|
|
|
#define IMAGE_INFO ":/images/info16.png"
|
|
|
|
#define IMAGE_NEWFORUM ":/images/new_forum16.png"
|
2010-01-01 13:58:39 -05:00
|
|
|
#define IMAGE_FORUMAUTHD ":/images/konv_message2.png"
|
2008-08-12 17:07:41 -04:00
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
#define VIEW_LAST_POST 0
|
|
|
|
#define VIEW_THREADED 1
|
|
|
|
#define VIEW_FLAT 2
|
2008-08-12 17:07:41 -04:00
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
/* Forum constants */
|
|
|
|
#define COLUMN_FORUM_COUNT 2
|
|
|
|
#define COLUMN_FORUM_TITLE 0
|
|
|
|
#define COLUMN_FORUM_DATE 1
|
|
|
|
|
|
|
|
#define COLUMN_FORUM_DATA 0
|
|
|
|
|
|
|
|
#define ROLE_FORUM_ID Qt::UserRole
|
2010-08-09 17:20:34 -04:00
|
|
|
#define ROLE_FORUM_TITLE Qt::UserRole + 1
|
|
|
|
|
|
|
|
#define ROLE_FORUM_COUNT 2
|
2010-08-08 18:58:10 -04:00
|
|
|
|
|
|
|
/* 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
|
|
|
|
// no need to copy, don't count in ROLE_THREAD_COUNT
|
|
|
|
#define ROLE_THREAD_READCHILDREN Qt::UserRole + 2
|
|
|
|
#define ROLE_THREAD_UNREADCHILDREN Qt::UserRole + 3
|
|
|
|
|
|
|
|
#define ROLE_THREAD_COUNT 2
|
|
|
|
|
|
|
|
#define IS_UNREAD(status) ((status & FORUM_MSG_STATUS_READ) == 0 || (status & FORUM_MSG_STATUS_UNREAD_BY_USER))
|
|
|
|
|
|
|
|
class ForumsItemDelegate : public QItemDelegate
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ForumsItemDelegate(QObject *parent = 0) : QItemDelegate(parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
|
|
|
{
|
|
|
|
QStyleOptionViewItem ownOption (option);
|
|
|
|
|
|
|
|
if (index.column() == COLUMN_THREAD_READ) {
|
|
|
|
ownOption.state &= ~QStyle::State_HasFocus; // don't show text and focus rectangle
|
|
|
|
}
|
|
|
|
|
|
|
|
QItemDelegate::paint (painter, ownOption, index);
|
|
|
|
}
|
|
|
|
|
|
|
|
QSize sizeHint (const QStyleOptionViewItem &option, const QModelIndex &index) const
|
|
|
|
{
|
|
|
|
QStyleOptionViewItem ownOption (option);
|
|
|
|
|
|
|
|
if (index.column() == COLUMN_THREAD_READ) {
|
|
|
|
ownOption.state &= ~QStyle::State_HasFocus; // don't show text and focus rectangle
|
|
|
|
}
|
|
|
|
|
|
|
|
return QItemDelegate::sizeHint(ownOption, index);
|
|
|
|
}
|
|
|
|
};
|
2010-05-19 16:17:43 -04:00
|
|
|
|
|
|
|
static int FilterColumnFromComboBox(int nIndex)
|
|
|
|
{
|
|
|
|
switch (nIndex) {
|
|
|
|
case 0:
|
2010-08-08 18:58:10 -04:00
|
|
|
return COLUMN_THREAD_DATE;
|
2010-05-19 16:17:43 -04:00
|
|
|
case 1:
|
2010-08-08 18:58:10 -04:00
|
|
|
return COLUMN_THREAD_TITLE;
|
2010-05-19 16:17:43 -04:00
|
|
|
case 2:
|
2010-08-08 18:58:10 -04:00
|
|
|
return COLUMN_THREAD_AUTHOR;
|
2010-05-19 16:17:43 -04:00
|
|
|
case 3:
|
2010-08-08 18:58:10 -04:00
|
|
|
return COLUMN_THREAD_CONTENT;
|
2010-05-19 16:17:43 -04:00
|
|
|
}
|
2008-08-12 17:07:41 -04:00
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
return COLUMN_THREAD_TITLE;
|
2010-05-19 16:17:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int FilterColumnToComboBox(int nIndex)
|
|
|
|
{
|
|
|
|
switch (nIndex) {
|
2010-08-08 18:58:10 -04:00
|
|
|
case COLUMN_THREAD_DATE:
|
2010-05-19 16:17:43 -04:00
|
|
|
return 0;
|
2010-08-08 18:58:10 -04:00
|
|
|
case COLUMN_THREAD_TITLE:
|
2010-05-19 16:17:43 -04:00
|
|
|
return 1;
|
2010-08-08 18:58:10 -04:00
|
|
|
case COLUMN_THREAD_AUTHOR:
|
2010-05-19 16:17:43 -04:00
|
|
|
return 2;
|
2010-08-08 18:58:10 -04:00
|
|
|
case COLUMN_THREAD_CONTENT:
|
2010-05-19 16:17:43 -04:00
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
return FilterColumnToComboBox(COLUMN_THREAD_TITLE);
|
2010-05-19 16:17:43 -04:00
|
|
|
}
|
2008-04-09 08:57:26 -04:00
|
|
|
|
|
|
|
/** Constructor */
|
2008-11-26 19:01:46 -05:00
|
|
|
ForumsDialog::ForumsDialog(QWidget *parent)
|
2010-07-05 15:41:46 -04:00
|
|
|
: RsAutoUpdatePage(1000,parent)
|
2008-04-09 08:57:26 -04:00
|
|
|
{
|
2010-05-19 16:17:43 -04:00
|
|
|
/* Invoke the Qt Designer generated object setup routine */
|
|
|
|
ui.setupUi(this);
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-05-20 17:53:27 -04:00
|
|
|
m_bProcessSettings = false;
|
2010-08-08 18:58:10 -04:00
|
|
|
m_bIsForumSubscribed = false;
|
2010-09-14 15:38:47 -04:00
|
|
|
m_bIsForumAdmin = false;
|
2010-05-20 17:53:27 -04:00
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
connect( ui.forumTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( forumListCustomPopupMenu( QPoint ) ) );
|
|
|
|
connect( ui.threadTreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( threadListCustomPopupMenu( QPoint ) ) );
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
connect(ui.actionCreate_Forum, SIGNAL(triggered()), this, SLOT(newforum()));
|
|
|
|
connect(ui.newmessageButton, SIGNAL(clicked()), this, SLOT(createmessage()));
|
2010-08-08 18:58:10 -04:00
|
|
|
connect(ui.newthreadButton, SIGNAL(clicked()), this, SLOT(createthread()));
|
2008-04-15 12:40:38 -04:00
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
connect( ui.forumTreeWidget, SIGNAL( currentItemChanged ( QTreeWidgetItem *, QTreeWidgetItem *) ), this, SLOT( changedForum( QTreeWidgetItem *, QTreeWidgetItem * ) ) );
|
2008-04-15 12:40:38 -04:00
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
connect( ui.threadTreeWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( changedThread () ) );
|
2010-08-08 18:58:10 -04:00
|
|
|
connect( ui.threadTreeWidget, SIGNAL( itemClicked(QTreeWidgetItem*,int)), this, SLOT( clickedThread (QTreeWidgetItem*,int) ) );
|
2010-05-19 16:17:43 -04:00
|
|
|
connect( ui.viewBox, SIGNAL( currentIndexChanged ( int ) ), this, SLOT( changedViewBox () ) );
|
|
|
|
connect( ui.postText, SIGNAL( anchorClicked(const QUrl &)), SLOT(anchorClicked(const QUrl &)));
|
2008-04-15 12:40:38 -04:00
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
connect(ui.expandButton, SIGNAL(clicked()), this, SLOT(togglethreadview()));
|
|
|
|
connect(ui.previousButton, SIGNAL(clicked()), this, SLOT(previousMessage()));
|
|
|
|
connect(ui.nextButton, SIGNAL(clicked()), this, SLOT(nextMessage()));
|
2010-01-14 08:03:43 -05:00
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
connect(ui.clearButton, SIGNAL(clicked()), this, SLOT(clearFilter()));
|
|
|
|
connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged()));
|
|
|
|
connect(ui.filterColumnComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(filterColumnChanged()));
|
2008-04-15 12:40:38 -04:00
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
/* Set own item delegate */
|
|
|
|
QItemDelegate *pDelegate = new ForumsItemDelegate(this);
|
|
|
|
ui.threadTreeWidget->setItemDelegate(pDelegate);
|
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
/* Set header resize modes and initial section sizes */
|
|
|
|
QHeaderView * ftheader = ui.forumTreeWidget->header () ;
|
2010-08-08 18:58:10 -04:00
|
|
|
ftheader->setResizeMode (COLUMN_FORUM_TITLE, QHeaderView::Interactive);
|
|
|
|
ftheader->resizeSection (COLUMN_FORUM_TITLE, 170);
|
2010-05-01 15:03:35 -04:00
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
/* Set header resize modes and initial section sizes */
|
|
|
|
QHeaderView * ttheader = ui.threadTreeWidget->header () ;
|
2010-08-08 18:58:10 -04:00
|
|
|
ttheader->setResizeMode (COLUMN_THREAD_TITLE, QHeaderView::Interactive);
|
|
|
|
ttheader->resizeSection (COLUMN_THREAD_DATE, 190);
|
|
|
|
ttheader->resizeSection (COLUMN_THREAD_TITLE, 170);
|
2010-05-01 15:03:35 -04:00
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
ui.threadTreeWidget->sortItems( COLUMN_THREAD_DATE, Qt::DescendingOrder );
|
2008-08-12 08:24:47 -04:00
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
/* 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, "");
|
2009-09-13 09:25:24 -04:00
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
m_ForumNameFont = QFont("Times", 12, QFont::Bold);
|
|
|
|
ui.forumName->setFont(m_ForumNameFont);
|
|
|
|
ui.threadTitle->setFont(m_ForumNameFont);
|
2010-05-01 15:03:35 -04:00
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
QMenu *forummenu = new QMenu();
|
|
|
|
forummenu->addAction(ui.actionCreate_Forum);
|
|
|
|
forummenu->addSeparator();
|
|
|
|
ui.forumpushButton->setMenu(forummenu);
|
2010-05-01 15:03:35 -04:00
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
ui.postText->setOpenExternalLinks ( false );
|
|
|
|
ui.postText->setOpenLinks ( false );
|
2010-05-01 15:03:35 -04:00
|
|
|
|
|
|
|
/* create forum tree */
|
|
|
|
m_ItemFont = QFont("ARIAL", 10);
|
|
|
|
m_ItemFont.setBold(true);
|
|
|
|
|
|
|
|
QList<QTreeWidgetItem *> TopList;
|
|
|
|
|
|
|
|
YourForums = new QTreeWidgetItem();
|
2010-08-08 18:58:10 -04:00
|
|
|
YourForums->setText(COLUMN_FORUM_TITLE, tr("Your Forums"));
|
|
|
|
YourForums->setFont(COLUMN_FORUM_TITLE, m_ItemFont);
|
|
|
|
YourForums->setIcon(COLUMN_FORUM_TITLE,(QIcon(IMAGE_FOLDER)));
|
|
|
|
YourForums->setSizeHint(COLUMN_FORUM_TITLE, QSize( 18,18 ) );
|
|
|
|
YourForums->setForeground(COLUMN_FORUM_TITLE, QBrush(QColor(79, 79, 79)));
|
2010-05-01 15:03:35 -04:00
|
|
|
TopList.append(YourForums);
|
|
|
|
|
|
|
|
SubscribedForums = new QTreeWidgetItem((QTreeWidget*)0);
|
2010-08-08 18:58:10 -04:00
|
|
|
SubscribedForums->setText(COLUMN_FORUM_TITLE, tr("Subscribed Forums"));
|
|
|
|
SubscribedForums->setFont(COLUMN_FORUM_TITLE, m_ItemFont);
|
|
|
|
SubscribedForums->setIcon(COLUMN_FORUM_TITLE,(QIcon(IMAGE_FOLDERRED)));
|
|
|
|
SubscribedForums->setSizeHint(COLUMN_FORUM_TITLE, QSize( 18,18 ) );
|
|
|
|
SubscribedForums->setForeground(COLUMN_FORUM_TITLE, QBrush(QColor(79, 79, 79)));
|
2010-05-01 15:03:35 -04:00
|
|
|
TopList.append(SubscribedForums);
|
|
|
|
|
|
|
|
PopularForums = new QTreeWidgetItem();
|
2010-08-08 18:58:10 -04:00
|
|
|
PopularForums->setText(COLUMN_FORUM_TITLE, tr("Popular Forums"));
|
|
|
|
PopularForums->setFont(COLUMN_FORUM_TITLE, m_ItemFont);
|
|
|
|
PopularForums->setIcon(COLUMN_FORUM_TITLE,(QIcon(IMAGE_FOLDERGREEN)));
|
|
|
|
PopularForums->setSizeHint(COLUMN_FORUM_TITLE, QSize( 18,18 ) );
|
|
|
|
PopularForums->setForeground(COLUMN_FORUM_TITLE, QBrush(QColor(79, 79, 79)));
|
2010-05-01 15:03:35 -04:00
|
|
|
TopList.append(PopularForums);
|
|
|
|
|
|
|
|
OtherForums = new QTreeWidgetItem();
|
2010-08-08 18:58:10 -04:00
|
|
|
OtherForums->setText(COLUMN_FORUM_TITLE, tr("Other Forums"));
|
|
|
|
OtherForums->setFont(COLUMN_FORUM_TITLE, m_ItemFont);
|
|
|
|
OtherForums->setIcon(COLUMN_FORUM_TITLE,(QIcon(IMAGE_FOLDERYELLOW)));
|
|
|
|
OtherForums->setSizeHint(COLUMN_FORUM_TITLE, QSize( 18,18 ) );
|
|
|
|
OtherForums->setForeground(COLUMN_FORUM_TITLE, QBrush(QColor(79, 79, 79)));
|
2010-05-01 15:03:35 -04:00
|
|
|
TopList.append(OtherForums);
|
|
|
|
|
|
|
|
ui.forumTreeWidget->addTopLevelItems(TopList);
|
|
|
|
|
|
|
|
YourForums->setExpanded(true);
|
|
|
|
SubscribedForums->setExpanded(true);
|
|
|
|
|
|
|
|
m_LastViewType = -1;
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
ui.clearButton->hide();
|
|
|
|
|
|
|
|
// load settings
|
|
|
|
processSettings(true);
|
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
/* 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);
|
|
|
|
|
|
|
|
insertThreads();
|
|
|
|
|
|
|
|
/* Hide platform specific features */
|
2008-04-09 08:57:26 -04:00
|
|
|
#ifdef Q_WS_WIN
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
ForumsDialog::~ForumsDialog()
|
|
|
|
{
|
|
|
|
// save settings
|
|
|
|
processSettings(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ForumsDialog::processSettings(bool bLoad)
|
|
|
|
{
|
2010-05-20 17:53:27 -04:00
|
|
|
m_bProcessSettings = true;
|
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
QHeaderView *pHeader = ui.threadTreeWidget->header () ;
|
|
|
|
|
2010-05-20 17:53:27 -04:00
|
|
|
Settings->beginGroup(QString("ForumsDialog"));
|
2010-05-19 16:17:43 -04:00
|
|
|
|
|
|
|
if (bLoad) {
|
|
|
|
// load settings
|
|
|
|
|
|
|
|
// expandFiles
|
2010-05-20 17:53:27 -04:00
|
|
|
bool bValue = Settings->value("expandButton", true).toBool();
|
2010-05-19 16:17:43 -04:00
|
|
|
ui.expandButton->setChecked(bValue);
|
|
|
|
togglethreadview_internal();
|
|
|
|
|
|
|
|
// filterColumn
|
2010-05-20 17:53:27 -04:00
|
|
|
int nValue = FilterColumnToComboBox(Settings->value("filterColumn", true).toInt());
|
2010-05-19 16:17:43 -04:00
|
|
|
ui.filterColumnComboBox->setCurrentIndex(nValue);
|
|
|
|
|
|
|
|
// index of viewBox
|
2010-05-20 17:53:27 -04:00
|
|
|
ui.viewBox->setCurrentIndex(Settings->value("viewBox", VIEW_THREADED).toInt());
|
2010-05-19 16:17:43 -04:00
|
|
|
|
|
|
|
// state of thread tree
|
2010-05-20 17:53:27 -04:00
|
|
|
pHeader->restoreState(Settings->value("ThreadTree").toByteArray());
|
2010-05-19 16:17:43 -04:00
|
|
|
|
|
|
|
// state of splitter
|
2010-05-20 17:53:27 -04:00
|
|
|
ui.splitter->restoreState(Settings->value("Splitter").toByteArray());
|
|
|
|
ui.threadSplitter->restoreState(Settings->value("threadSplitter").toByteArray());
|
2010-05-19 16:17:43 -04:00
|
|
|
} else {
|
|
|
|
// save settings
|
|
|
|
|
|
|
|
// state of thread tree
|
2010-05-20 17:53:27 -04:00
|
|
|
Settings->setValue("ThreadTree", pHeader->saveState());
|
2010-05-19 16:17:43 -04:00
|
|
|
|
|
|
|
// state of splitter
|
2010-05-20 17:53:27 -04:00
|
|
|
Settings->setValue("Splitter", ui.splitter->saveState());
|
|
|
|
Settings->setValue("threadSplitter", ui.threadSplitter->saveState());
|
2010-05-19 16:17:43 -04:00
|
|
|
}
|
2010-05-20 17:53:27 -04:00
|
|
|
|
|
|
|
Settings->endGroup();
|
|
|
|
m_bProcessSettings = false;
|
2010-05-19 16:17:43 -04:00
|
|
|
}
|
|
|
|
|
2008-04-09 08:57:26 -04:00
|
|
|
void ForumsDialog::forumListCustomPopupMenu( QPoint point )
|
|
|
|
{
|
2010-05-01 15:03:35 -04:00
|
|
|
QMenu contextMnu( this );
|
|
|
|
|
2010-07-15 07:25:34 -04:00
|
|
|
QAction *subForumAct = new QAction(QIcon(IMAGE_SUBSCRIBE), tr( "Subscribe to Forum" ), &contextMnu );
|
2010-08-08 18:58:10 -04:00
|
|
|
subForumAct->setDisabled (m_bIsForumSubscribed);
|
2010-05-01 15:03:35 -04:00
|
|
|
connect( subForumAct , SIGNAL( triggered() ), this, SLOT( subscribeToForum() ) );
|
|
|
|
|
2010-07-15 07:25:34 -04:00
|
|
|
QAction *unsubForumAct = new QAction(QIcon(IMAGE_UNSUBSCRIBE), tr( "Unsubscribe to Forum" ), &contextMnu );
|
2010-08-08 18:58:10 -04:00
|
|
|
unsubForumAct->setEnabled (m_bIsForumSubscribed);
|
2010-05-01 15:03:35 -04:00
|
|
|
connect( unsubForumAct , SIGNAL( triggered() ), this, SLOT( unsubscribeToForum() ) );
|
|
|
|
|
2010-07-15 07:25:34 -04:00
|
|
|
QAction *newForumAct = new QAction(QIcon(IMAGE_NEWFORUM), tr( "New Forum" ), &contextMnu );
|
2010-05-01 15:03:35 -04:00
|
|
|
connect( newForumAct , SIGNAL( triggered() ), this, SLOT( newforum() ) );
|
|
|
|
|
2010-07-15 07:25:34 -04:00
|
|
|
QAction *detailsForumAct = new QAction(QIcon(IMAGE_INFO), tr( "Show Forum Details" ), &contextMnu );
|
2010-05-01 15:03:35 -04:00
|
|
|
detailsForumAct->setDisabled (true);
|
|
|
|
connect( detailsForumAct , SIGNAL( triggered() ), this, SLOT( showForumDetails() ) );
|
|
|
|
|
2010-09-14 15:38:47 -04:00
|
|
|
QAction *editForumDetailsAct = new QAction(QIcon(":/images/settings16.png"), tr("Edit Forum Details"), this);
|
|
|
|
editForumDetailsAct->setDisabled (true);
|
|
|
|
connect( editForumDetailsAct, SIGNAL( triggered() ), this, SLOT( editForumDetails() ) );
|
|
|
|
|
2010-05-01 15:03:35 -04:00
|
|
|
if (!mCurrForumId.empty ()) {
|
|
|
|
detailsForumAct->setEnabled (true);
|
2010-09-14 15:38:47 -04:00
|
|
|
editForumDetailsAct->setEnabled(m_bIsForumAdmin);
|
2010-05-01 15:03:35 -04:00
|
|
|
}
|
2010-01-02 17:50:56 -05:00
|
|
|
|
2010-05-01 15:03:35 -04:00
|
|
|
contextMnu.addAction( subForumAct );
|
|
|
|
contextMnu.addAction( unsubForumAct );
|
|
|
|
contextMnu.addSeparator();
|
|
|
|
contextMnu.addAction( newForumAct );
|
|
|
|
contextMnu.addAction( detailsForumAct );
|
2010-09-14 15:38:47 -04:00
|
|
|
contextMnu.addAction( editForumDetailsAct );
|
2010-05-14 16:55:44 -04:00
|
|
|
|
|
|
|
contextMnu.exec(QCursor::pos());
|
2008-04-09 08:57:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ForumsDialog::threadListCustomPopupMenu( QPoint point )
|
|
|
|
{
|
2010-05-01 15:03:35 -04:00
|
|
|
QMenu contextMnu( this );
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-07-15 07:25:34 -04:00
|
|
|
QAction *replyAct = new QAction(QIcon(IMAGE_MESSAGEREPLY), tr( "Reply" ), &contextMnu );
|
2010-05-01 15:03:35 -04:00
|
|
|
connect( replyAct , SIGNAL( triggered() ), this, SLOT( createmessage() ) );
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-07-15 07:25:34 -04:00
|
|
|
QAction *newthreadAct = new QAction(QIcon(IMAGE_DOWNLOADALL), tr( "Start New Thread" ), &contextMnu );
|
2010-08-08 18:58:10 -04:00
|
|
|
newthreadAct->setEnabled (m_bIsForumSubscribed);
|
|
|
|
connect( newthreadAct , SIGNAL( triggered() ), this, SLOT( createthread() ) );
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-07-15 07:25:34 -04:00
|
|
|
QAction *replyauthorAct = new QAction(QIcon(IMAGE_MESSAGEREPLY), tr( "Reply to Author" ), &contextMnu );
|
2010-05-01 15:03:35 -04:00
|
|
|
connect( replyauthorAct , SIGNAL( triggered() ), this, SLOT( replytomessage() ) );
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-07-15 07:25:34 -04:00
|
|
|
QAction* expandAll = new QAction(tr( "Expand all" ), &contextMnu );
|
2010-05-01 15:03:35 -04:00
|
|
|
connect( expandAll , SIGNAL( triggered() ), ui.threadTreeWidget, SLOT (expandAll()) );
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-07-15 07:25:34 -04:00
|
|
|
QAction* collapseAll = new QAction(tr( "Collapse all" ), &contextMnu );
|
2010-05-01 15:03:35 -04:00
|
|
|
connect( collapseAll , SIGNAL( triggered() ), ui.threadTreeWidget, SLOT(collapseAll()) );
|
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
QAction *markMsgAsRead = new QAction(QIcon(":/images/message-mail-read.png"), tr("Mark as read"), &contextMnu);
|
|
|
|
connect(markMsgAsRead , SIGNAL(triggered()), this, SLOT(markMsgAsRead()));
|
|
|
|
|
2010-09-12 18:17:17 -04:00
|
|
|
QAction *markMsgAsReadAll = new QAction(QIcon(":/images/message-mail-read.png"), tr("Mark as read") + " (" + tr ("with children") + ")", &contextMnu);
|
2010-08-08 18:58:10 -04:00
|
|
|
connect(markMsgAsReadAll, SIGNAL(triggered()), this, SLOT(markMsgAsReadAll()));
|
|
|
|
|
|
|
|
QAction *markMsgAsUnread = new QAction(QIcon(":/images/message-mail.png"), tr("Mark as unread"), &contextMnu);
|
|
|
|
connect(markMsgAsUnread , SIGNAL(triggered()), this, SLOT(markMsgAsUnread()));
|
|
|
|
|
|
|
|
QAction *markMsgAsUnreadAll = new QAction(QIcon(":/images/message-mail.png"), tr("Mark as unread") + " (" + tr ("with children") + ")", &contextMnu);
|
|
|
|
connect(markMsgAsUnreadAll , SIGNAL(triggered()), this, SLOT(markMsgAsUnreadAll()));
|
|
|
|
|
|
|
|
if (m_bIsForumSubscribed) {
|
|
|
|
QList<QTreeWidgetItem*> Rows;
|
|
|
|
QList<QTreeWidgetItem*> RowsRead;
|
|
|
|
QList<QTreeWidgetItem*> 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
markMsgAsReadAll->setEnabled(bHasUnreadChildren);
|
|
|
|
markMsgAsUnreadAll->setEnabled(bHasReadChildren);
|
|
|
|
|
|
|
|
if (nCount == 1) {
|
2010-05-01 15:03:35 -04:00
|
|
|
replyAct->setEnabled (true);
|
|
|
|
replyauthorAct->setEnabled (true);
|
2010-09-13 19:35:21 -04:00
|
|
|
} else {
|
|
|
|
replyAct->setDisabled (true);
|
|
|
|
replyauthorAct->setDisabled (true);
|
2010-05-01 15:03:35 -04:00
|
|
|
}
|
2010-08-08 18:58:10 -04:00
|
|
|
} else {
|
|
|
|
markMsgAsRead->setDisabled(true);
|
|
|
|
markMsgAsReadAll->setDisabled(true);
|
|
|
|
markMsgAsUnread->setDisabled(true);
|
|
|
|
markMsgAsUnreadAll->setDisabled(true);
|
|
|
|
replyAct->setDisabled (true);
|
|
|
|
replyauthorAct->setDisabled (true);
|
2010-05-01 15:03:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
contextMnu.addAction( replyAct);
|
2010-06-23 18:11:42 -04:00
|
|
|
contextMnu.addAction( newthreadAct);
|
2010-05-01 15:03:35 -04:00
|
|
|
contextMnu.addAction( replyauthorAct);
|
|
|
|
contextMnu.addSeparator();
|
2010-08-08 18:58:10 -04:00
|
|
|
contextMnu.addAction(markMsgAsRead);
|
|
|
|
contextMnu.addAction(markMsgAsReadAll);
|
|
|
|
contextMnu.addAction(markMsgAsUnread);
|
|
|
|
contextMnu.addAction(markMsgAsUnreadAll);
|
|
|
|
contextMnu.addSeparator();
|
2010-05-01 15:03:35 -04:00
|
|
|
contextMnu.addAction( expandAll);
|
|
|
|
contextMnu.addAction( collapseAll);
|
2010-05-14 16:55:44 -04:00
|
|
|
|
|
|
|
contextMnu.exec(QCursor::pos());
|
2008-04-09 08:57:26 -04:00
|
|
|
}
|
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
void ForumsDialog::togglethreadview()
|
2008-04-09 08:57:26 -04:00
|
|
|
{
|
2010-05-19 16:17:43 -04:00
|
|
|
// save state of button
|
2010-05-20 17:53:27 -04:00
|
|
|
Settings->setValueToGroup("ForumsDialog", "expandButton", ui.expandButton->isChecked());
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
togglethreadview_internal();
|
|
|
|
}
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
void ForumsDialog::togglethreadview_internal()
|
|
|
|
{
|
|
|
|
if (ui.expandButton->isChecked()) {
|
|
|
|
ui.postText->setVisible(true);
|
|
|
|
ui.expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png")));
|
2010-09-13 11:11:20 -04:00
|
|
|
ui.expandButton->setToolTip(tr("Hide"));
|
2010-05-19 16:17:43 -04:00
|
|
|
} else {
|
|
|
|
ui.postText->setVisible(false);
|
|
|
|
ui.expandButton->setIcon(QIcon(QString(":/images/edit_add24.png")));
|
2010-09-13 11:11:20 -04:00
|
|
|
ui.expandButton->setToolTip(tr("Expand"));
|
2010-05-19 16:17:43 -04:00
|
|
|
}
|
2008-04-15 12:40:38 -04:00
|
|
|
}
|
|
|
|
|
2010-07-05 15:41:46 -04:00
|
|
|
void ForumsDialog::updateDisplay()
|
2008-04-15 12:40:38 -04:00
|
|
|
{
|
2010-05-19 16:17:43 -04:00
|
|
|
std::list<std::string> forumIds;
|
|
|
|
std::list<std::string>::iterator it;
|
|
|
|
if (!rsForums)
|
|
|
|
return;
|
2008-04-15 12:40:38 -04:00
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
if (rsForums->forumsChanged(forumIds))
|
|
|
|
{
|
|
|
|
/* update Forums List */
|
|
|
|
insertForums();
|
|
|
|
|
|
|
|
it = std::find(forumIds.begin(), forumIds.end(), mCurrForumId);
|
|
|
|
if (it != forumIds.end())
|
|
|
|
{
|
|
|
|
/* update threads as well */
|
|
|
|
insertThreads();
|
|
|
|
}
|
|
|
|
}
|
2008-04-09 08:57:26 -04:00
|
|
|
}
|
|
|
|
|
2010-05-01 15:03:35 -04:00
|
|
|
static void CleanupItems (QList<QTreeWidgetItem *> &Items)
|
2008-04-09 08:57:26 -04:00
|
|
|
{
|
2010-05-01 15:03:35 -04:00
|
|
|
QList<QTreeWidgetItem *>::iterator Item;
|
|
|
|
for (Item = Items.begin (); Item != Items.end (); Item++) {
|
2010-05-17 17:42:18 -04:00
|
|
|
if (*Item) {
|
|
|
|
delete (*Item);
|
|
|
|
}
|
2010-05-01 15:03:35 -04:00
|
|
|
}
|
2008-04-09 08:57:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ForumsDialog::insertForums()
|
|
|
|
{
|
|
|
|
std::list<ForumInfo> forumList;
|
|
|
|
std::list<ForumInfo>::iterator it;
|
|
|
|
if (!rsForums)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
rsForums->getForumList(forumList);
|
|
|
|
|
|
|
|
QList<QTreeWidgetItem *> AdminList;
|
|
|
|
QList<QTreeWidgetItem *> SubList;
|
|
|
|
QList<QTreeWidgetItem *> PopList;
|
|
|
|
QList<QTreeWidgetItem *> OtherList;
|
|
|
|
std::multimap<uint32_t, std::string> popMap;
|
|
|
|
|
|
|
|
for(it = forumList.begin(); it != forumList.end(); it++)
|
|
|
|
{
|
|
|
|
/* sort it into Publish (Own), Subscribed, Popular and Other */
|
2008-12-05 19:30:56 -05:00
|
|
|
uint32_t flags = it->subscribeFlags;
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2008-06-13 11:46:34 -04:00
|
|
|
if (flags & RS_DISTRIB_ADMIN)
|
2008-04-09 08:57:26 -04:00
|
|
|
{
|
|
|
|
/* own */
|
|
|
|
|
2010-05-01 15:03:35 -04:00
|
|
|
/* Name,
|
2008-04-09 08:57:26 -04:00
|
|
|
* Type,
|
|
|
|
* Rank,
|
|
|
|
* LastPost
|
|
|
|
* ForumId,
|
|
|
|
*/
|
|
|
|
|
|
|
|
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
|
|
|
|
|
2008-12-05 19:30:56 -05:00
|
|
|
QString name = QString::fromStdWString(it->forumName);
|
|
|
|
if (it->forumFlags & RS_DISTRIB_AUTHEN_REQ)
|
|
|
|
{
|
|
|
|
name += " (AUTHD)";
|
2010-08-08 18:58:10 -04:00
|
|
|
item -> setIcon(COLUMN_FORUM_TITLE,(QIcon(IMAGE_FORUMAUTHD)));
|
2008-12-05 19:30:56 -05:00
|
|
|
}
|
2010-01-01 13:58:39 -05:00
|
|
|
else
|
|
|
|
{
|
2010-08-08 18:58:10 -04:00
|
|
|
item -> setIcon(COLUMN_FORUM_TITLE,(QIcon(IMAGE_FORUM)));
|
2010-01-01 13:58:39 -05:00
|
|
|
}
|
2010-05-01 15:03:35 -04:00
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
item -> setText(COLUMN_FORUM_TITLE, name);
|
2010-08-09 17:20:34 -04:00
|
|
|
item -> setData(COLUMN_FORUM_DATA, ROLE_FORUM_TITLE, name);
|
2008-12-05 19:30:56 -05:00
|
|
|
|
2008-04-09 08:57:26 -04:00
|
|
|
/* (1) Popularity */
|
|
|
|
{
|
|
|
|
std::ostringstream out;
|
|
|
|
out << it->pop;
|
2010-09-12 18:17:17 -04:00
|
|
|
item -> setToolTip(COLUMN_FORUM_TITLE, tr("Popularity:") + " " + QString::fromStdString(out.str()));
|
2008-04-09 08:57:26 -04:00
|
|
|
}
|
|
|
|
|
2010-05-01 15:03:35 -04:00
|
|
|
// Date
|
2008-04-09 08:57:26 -04:00
|
|
|
{
|
|
|
|
QDateTime qtime;
|
|
|
|
qtime.setTime_t(it->lastPost);
|
|
|
|
QString timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss");
|
2010-08-08 18:58:10 -04:00
|
|
|
item -> setText(COLUMN_FORUM_DATE, timestamp);
|
2008-04-09 08:57:26 -04:00
|
|
|
}
|
|
|
|
// Id.
|
2010-08-08 18:58:10 -04:00
|
|
|
item -> setData(COLUMN_FORUM_DATA, ROLE_FORUM_ID, QString::fromStdString(it->forumId));
|
2008-04-09 08:57:26 -04:00
|
|
|
AdminList.append(item);
|
|
|
|
}
|
2008-06-13 11:46:34 -04:00
|
|
|
else if (flags & RS_DISTRIB_SUBSCRIBED)
|
2008-04-09 08:57:26 -04:00
|
|
|
{
|
|
|
|
/* subscribed forum */
|
|
|
|
|
2010-05-01 15:03:35 -04:00
|
|
|
/* Name,
|
2008-04-09 08:57:26 -04:00
|
|
|
* Type,
|
|
|
|
* Rank,
|
|
|
|
* LastPost
|
|
|
|
* ForumId,
|
|
|
|
*/
|
|
|
|
|
|
|
|
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
|
|
|
|
|
2008-12-05 19:30:56 -05:00
|
|
|
QString name = QString::fromStdWString(it->forumName);
|
|
|
|
if (it->forumFlags & RS_DISTRIB_AUTHEN_REQ)
|
|
|
|
{
|
|
|
|
name += " (AUTHD)";
|
2010-08-08 18:58:10 -04:00
|
|
|
item -> setIcon(COLUMN_FORUM_TITLE,(QIcon(IMAGE_FORUMAUTHD)));
|
2010-01-01 13:58:39 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-08-08 18:58:10 -04:00
|
|
|
item -> setIcon(COLUMN_FORUM_TITLE,(QIcon(IMAGE_FORUM)));
|
2008-12-05 19:30:56 -05:00
|
|
|
}
|
2010-05-01 15:03:35 -04:00
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
item -> setText(COLUMN_FORUM_TITLE, name);
|
2010-08-09 17:20:34 -04:00
|
|
|
item -> setData(COLUMN_FORUM_DATA, ROLE_FORUM_TITLE, name);
|
2008-12-05 19:30:56 -05:00
|
|
|
|
2008-04-09 08:57:26 -04:00
|
|
|
/* (1) Popularity */
|
|
|
|
{
|
|
|
|
std::ostringstream out;
|
|
|
|
out << it->pop;
|
2010-09-12 18:17:17 -04:00
|
|
|
item -> setToolTip(COLUMN_FORUM_TITLE, tr("Popularity:") + " " + QString::fromStdString(out.str()));
|
2008-04-09 08:57:26 -04:00
|
|
|
}
|
|
|
|
|
2010-05-01 15:03:35 -04:00
|
|
|
// Date
|
2008-04-09 08:57:26 -04:00
|
|
|
{
|
|
|
|
QDateTime qtime;
|
|
|
|
qtime.setTime_t(it->lastPost);
|
|
|
|
QString timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss");
|
2010-08-08 18:58:10 -04:00
|
|
|
item -> setText(COLUMN_FORUM_DATE, timestamp);
|
2008-04-09 08:57:26 -04:00
|
|
|
}
|
|
|
|
// Id.
|
2010-08-08 18:58:10 -04:00
|
|
|
item -> setData(COLUMN_FORUM_DATA, ROLE_FORUM_ID, QString::fromStdString(it->forumId));
|
2008-04-09 08:57:26 -04:00
|
|
|
SubList.append(item);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* rate the others by popularity */
|
|
|
|
popMap.insert(std::make_pair(it->pop, it->forumId));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* iterate backwards through popMap - take the top 5 or 10% of list */
|
|
|
|
uint32_t popCount = 5;
|
|
|
|
if (popCount < popMap.size() / 10)
|
|
|
|
{
|
|
|
|
popCount = popMap.size() / 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t i = 0;
|
|
|
|
uint32_t popLimit = 0;
|
|
|
|
std::multimap<uint32_t, std::string>::reverse_iterator rit;
|
|
|
|
for(rit = popMap.rbegin(); ((rit != popMap.rend()) && (i < popCount)); rit++, i++);
|
|
|
|
if (rit != popMap.rend())
|
|
|
|
{
|
|
|
|
popLimit = rit->first;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(it = forumList.begin(); it != forumList.end(); it++)
|
|
|
|
{
|
|
|
|
/* ignore the ones we've done already */
|
2008-12-05 19:30:56 -05:00
|
|
|
uint32_t flags = it->subscribeFlags;
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2008-06-13 11:46:34 -04:00
|
|
|
if (flags & RS_DISTRIB_ADMIN)
|
2008-04-09 08:57:26 -04:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2008-06-13 11:46:34 -04:00
|
|
|
else if (flags & RS_DISTRIB_SUBSCRIBED)
|
2008-04-09 08:57:26 -04:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-01-02 12:31:43 -05:00
|
|
|
/* popular forum */
|
2010-05-01 15:03:35 -04:00
|
|
|
|
|
|
|
/* Name,
|
2008-04-09 08:57:26 -04:00
|
|
|
* Type,
|
|
|
|
* Rank,
|
|
|
|
* LastPost
|
|
|
|
* ForumId,
|
|
|
|
*/
|
|
|
|
|
|
|
|
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
|
|
|
|
|
2008-12-05 19:30:56 -05:00
|
|
|
QString name = QString::fromStdWString(it->forumName);
|
|
|
|
if (it->forumFlags & RS_DISTRIB_AUTHEN_REQ)
|
|
|
|
{
|
|
|
|
name += " (AUTHD)";
|
2010-08-08 18:58:10 -04:00
|
|
|
item -> setIcon(COLUMN_FORUM_TITLE,(QIcon(IMAGE_FORUMAUTHD)));
|
2010-01-01 13:58:39 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-08-08 18:58:10 -04:00
|
|
|
item -> setIcon(COLUMN_FORUM_TITLE,(QIcon(IMAGE_FORUM)));
|
2008-12-05 19:30:56 -05:00
|
|
|
}
|
2010-05-01 15:03:35 -04:00
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
item -> setText(COLUMN_FORUM_TITLE, name);
|
2010-08-09 17:20:34 -04:00
|
|
|
item -> setData(COLUMN_FORUM_DATA, ROLE_FORUM_TITLE, name);
|
2010-05-01 15:03:35 -04:00
|
|
|
|
2008-12-05 19:30:56 -05:00
|
|
|
|
2008-04-09 08:57:26 -04:00
|
|
|
/* (1) Popularity */
|
|
|
|
{
|
|
|
|
std::ostringstream out;
|
|
|
|
out << it->pop;
|
2010-09-12 18:17:17 -04:00
|
|
|
item -> setToolTip(COLUMN_FORUM_TITLE, tr("Popularity:") + " " + QString::fromStdString(out.str()));
|
2008-04-09 08:57:26 -04:00
|
|
|
}
|
|
|
|
|
2010-05-01 15:03:35 -04:00
|
|
|
// Date
|
2008-04-09 08:57:26 -04:00
|
|
|
{
|
|
|
|
QDateTime qtime;
|
|
|
|
qtime.setTime_t(it->lastPost);
|
|
|
|
QString timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss");
|
2010-08-08 18:58:10 -04:00
|
|
|
item -> setText(COLUMN_FORUM_DATE, timestamp);
|
2008-04-09 08:57:26 -04:00
|
|
|
}
|
|
|
|
// Id.
|
2010-08-08 18:58:10 -04:00
|
|
|
item -> setData(COLUMN_FORUM_DATA, ROLE_FORUM_ID, QString::fromStdString(it->forumId));
|
2008-04-09 08:57:26 -04:00
|
|
|
|
|
|
|
if (it->pop < popLimit)
|
|
|
|
{
|
|
|
|
OtherList.append(item);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PopList.append(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now we can add them in as a tree! */
|
2010-05-01 15:03:35 -04:00
|
|
|
FillForums (YourForums, AdminList);
|
|
|
|
FillForums (SubscribedForums, SubList);
|
|
|
|
FillForums (PopularForums, PopList);
|
|
|
|
FillForums (OtherForums, OtherList);
|
|
|
|
|
|
|
|
// cleanup
|
|
|
|
CleanupItems (AdminList);
|
|
|
|
CleanupItems (SubList);
|
|
|
|
CleanupItems (PopList);
|
|
|
|
CleanupItems (OtherList);
|
2010-08-09 17:20:34 -04:00
|
|
|
|
|
|
|
updateMessageSummaryList("");
|
2008-04-09 08:57:26 -04:00
|
|
|
}
|
|
|
|
|
2010-05-01 15:03:35 -04:00
|
|
|
void ForumsDialog::FillForums(QTreeWidgetItem *Forum, QList<QTreeWidgetItem *> &ChildList)
|
2008-04-09 08:57:26 -04:00
|
|
|
{
|
2010-05-01 15:03:35 -04:00
|
|
|
int ChildIndex;
|
|
|
|
int ChildIndexCur = 0;
|
|
|
|
|
|
|
|
QTreeWidgetItem *Child;
|
|
|
|
|
2010-05-17 17:42:18 -04:00
|
|
|
// iterate all new children
|
2010-05-01 15:03:35 -04:00
|
|
|
QList<QTreeWidgetItem *>::iterator NewChild;
|
|
|
|
for (NewChild = ChildList.begin (); NewChild != ChildList.end (); NewChild++) {
|
|
|
|
// search existing child
|
|
|
|
int ChildIndexFound = -1;
|
|
|
|
int ChildCount = Forum->childCount ();
|
|
|
|
for (ChildIndex = ChildIndexCur; ChildIndex < ChildCount; ChildIndex++) {
|
|
|
|
Child = Forum->child (ChildIndex);
|
2010-08-08 18:58:10 -04:00
|
|
|
if (Child->data (COLUMN_FORUM_DATA, ROLE_FORUM_ID) == (*NewChild)->data (COLUMN_FORUM_DATA, ROLE_FORUM_ID)) {
|
2010-05-01 15:03:35 -04:00
|
|
|
// found it
|
|
|
|
ChildIndexFound = ChildIndex;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ChildIndexFound >= 0) {
|
2010-05-17 17:42:18 -04:00
|
|
|
// delete all children between
|
2010-05-01 15:03:35 -04:00
|
|
|
while (ChildIndexCur < ChildIndexFound) {
|
|
|
|
Child = Forum->takeChild (ChildIndexCur);
|
|
|
|
delete (Child);
|
|
|
|
ChildIndexFound--;
|
|
|
|
}
|
|
|
|
|
|
|
|
// set child data
|
|
|
|
Child = Forum->child (ChildIndexFound);
|
2010-08-08 18:58:10 -04:00
|
|
|
Child->setIcon (COLUMN_FORUM_TITLE, (*NewChild)->icon (COLUMN_FORUM_TITLE));
|
|
|
|
Child->setToolTip (COLUMN_FORUM_TITLE, (*NewChild)->toolTip (COLUMN_FORUM_TITLE));
|
2010-05-01 15:03:35 -04:00
|
|
|
|
2010-08-09 17:20:34 -04:00
|
|
|
int i;
|
|
|
|
for (i = 0; i < COLUMN_FORUM_COUNT; i++) {
|
2010-05-01 15:03:35 -04:00
|
|
|
Child->setText (i, (*NewChild)->text (i));
|
|
|
|
}
|
2010-08-09 17:20:34 -04:00
|
|
|
for (i = 0; i < ROLE_FORUM_COUNT; i++) {
|
|
|
|
Child->setData (COLUMN_FORUM_DATA, Qt::UserRole + i, (*NewChild)->data (COLUMN_FORUM_DATA, Qt::UserRole + i));
|
|
|
|
}
|
2010-05-01 15:03:35 -04:00
|
|
|
} else {
|
|
|
|
// insert new child
|
|
|
|
if (ChildIndexCur < ChildCount) {
|
2010-05-17 17:42:18 -04:00
|
|
|
Forum->insertChild (ChildIndexCur, *NewChild);
|
2010-05-01 15:03:35 -04:00
|
|
|
} else {
|
2010-05-17 17:42:18 -04:00
|
|
|
Forum->addChild (*NewChild);
|
2010-05-01 15:03:35 -04:00
|
|
|
}
|
2010-05-17 17:42:18 -04:00
|
|
|
*NewChild = NULL;
|
2010-05-01 15:03:35 -04:00
|
|
|
}
|
|
|
|
ChildIndexCur++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// delete rest
|
|
|
|
while (ChildIndexCur < Forum->childCount ()) {
|
|
|
|
Child = Forum->takeChild (ChildIndexCur);
|
|
|
|
delete (Child);
|
|
|
|
}
|
2008-04-15 12:40:38 -04:00
|
|
|
}
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-05-01 15:03:35 -04:00
|
|
|
void ForumsDialog::changedForum( QTreeWidgetItem *curr, QTreeWidgetItem *prev )
|
2008-04-15 12:40:38 -04:00
|
|
|
{
|
2010-05-01 15:03:35 -04:00
|
|
|
insertThreads();
|
2008-04-15 12:40:38 -04:00
|
|
|
}
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-05-01 15:03:35 -04:00
|
|
|
void ForumsDialog::changedThread ()
|
2008-04-15 12:40:38 -04:00
|
|
|
{
|
2010-05-01 15:03:35 -04:00
|
|
|
/* just grab the ids of the current item */
|
|
|
|
QTreeWidgetItem *curr = ui.threadTreeWidget->currentItem();
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-05-01 15:03:35 -04:00
|
|
|
if ((!curr) || (!curr->isSelected())) {
|
2010-08-08 18:58:10 -04:00
|
|
|
mCurrThreadId = "";
|
2010-05-01 15:03:35 -04:00
|
|
|
} else {
|
2010-08-08 18:58:10 -04:00
|
|
|
mCurrThreadId = curr->data(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID).toString().toStdString();
|
2010-05-01 15:03:35 -04:00
|
|
|
}
|
|
|
|
insertPost();
|
2008-04-15 12:40:38 -04:00
|
|
|
}
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
void ForumsDialog::clickedThread (QTreeWidgetItem *item, int column)
|
|
|
|
{
|
|
|
|
if (mCurrForumId.empty() || m_bIsForumSubscribed == false) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (column == COLUMN_THREAD_READ) {
|
|
|
|
QList<QTreeWidgetItem*> Rows;
|
|
|
|
Rows.append(item);
|
|
|
|
uint32_t status = item->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt();
|
|
|
|
setMsgAsReadUnread(Rows, IS_UNREAD(status));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ForumsDialog::CalculateIconsAndFonts(QTreeWidgetItem *pItem, bool &bHasReadChilddren, bool &bHasUnreadChilddren)
|
|
|
|
{
|
|
|
|
uint32_t status = pItem->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt();
|
|
|
|
|
|
|
|
bool bUnread = IS_UNREAD(status);
|
|
|
|
|
|
|
|
// set icon
|
|
|
|
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 & FORUM_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);
|
|
|
|
qf.setBold(bUnread || bMyUnreadChilddren);
|
|
|
|
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 ForumsDialog::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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-15 12:40:38 -04:00
|
|
|
void ForumsDialog::insertThreads()
|
|
|
|
{
|
2010-05-19 16:17:43 -04:00
|
|
|
/* get the current Forum */
|
|
|
|
std::cerr << "ForumsDialog::insertThreads()" << std::endl;
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
m_bIsForumSubscribed = false;
|
2010-09-14 15:38:47 -04:00
|
|
|
m_bIsForumAdmin = false;
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
QTreeWidgetItem *forumItem = ui.forumTreeWidget->currentItem();
|
|
|
|
if ((!forumItem) || (forumItem->parent() == NULL))
|
|
|
|
{
|
|
|
|
/* not an actual forum - clear */
|
|
|
|
ui.threadTreeWidget->clear();
|
|
|
|
/* when no Thread selected - clear */
|
|
|
|
ui.forumName->clear();
|
|
|
|
ui.threadTitle->clear();
|
|
|
|
ui.postText->clear();
|
|
|
|
/* clear last stored forumID */
|
2010-08-08 18:58:10 -04:00
|
|
|
mCurrForumId.erase();
|
|
|
|
m_LastForumID.erase();
|
2010-05-19 16:17:43 -04:00
|
|
|
std::cerr << "ForumsDialog::insertThreads() Current Thread Invalid" << std::endl;
|
2008-04-15 12:40:38 -04:00
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
ui.newmessageButton->setEnabled (false);
|
|
|
|
ui.newthreadButton->setEnabled (false);
|
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
return;
|
|
|
|
}
|
2009-09-09 17:17:03 -04:00
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
/* store forumId */
|
2010-08-08 18:58:10 -04:00
|
|
|
mCurrForumId = forumItem->data(COLUMN_FORUM_DATA, ROLE_FORUM_ID).toString().toStdString();
|
|
|
|
ui.forumName->setText(forumItem->text(COLUMN_FORUM_TITLE));
|
2010-05-19 16:17:43 -04:00
|
|
|
std::string fId = mCurrForumId;
|
2009-09-09 17:17:03 -04:00
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
ForumInfo fi;
|
|
|
|
if (rsForums->getForumInfo (fId, fi)) {
|
2010-09-14 15:38:47 -04:00
|
|
|
if (fi.subscribeFlags & RS_DISTRIB_ADMIN) {
|
|
|
|
m_bIsForumAdmin = true;
|
|
|
|
}
|
2010-08-08 18:58:10 -04:00
|
|
|
if (fi.subscribeFlags & (RS_DISTRIB_ADMIN | RS_DISTRIB_SUBSCRIBED)) {
|
|
|
|
m_bIsForumSubscribed = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ui.newmessageButton->setEnabled (m_bIsForumSubscribed);
|
|
|
|
ui.newthreadButton->setEnabled (m_bIsForumSubscribed);
|
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
bool flatView = false;
|
|
|
|
bool useChildTS = false;
|
|
|
|
int ViewType = ui.viewBox->currentIndex();
|
|
|
|
switch(ViewType)
|
|
|
|
{
|
|
|
|
case VIEW_LAST_POST:
|
|
|
|
useChildTS = true;
|
|
|
|
break;
|
|
|
|
case VIEW_FLAT:
|
|
|
|
flatView = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
case VIEW_THREADED:
|
|
|
|
break;
|
|
|
|
}
|
2008-12-03 14:39:20 -05:00
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
bool bExpandNewMessages = Settings->getExpandNewMessages();
|
|
|
|
std::list<QTreeWidgetItem*> itemToExpand;
|
|
|
|
|
|
|
|
bool bFillComplete = false;
|
|
|
|
if (m_LastViewType != ViewType || m_LastForumID != mCurrForumId) {
|
|
|
|
bFillComplete = true;
|
|
|
|
}
|
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
int nFilterColumn = FilterColumnFromComboBox(ui.filterColumnComboBox->currentIndex());
|
2010-08-08 18:58:10 -04:00
|
|
|
uint32_t status;
|
2010-05-01 15:03:35 -04:00
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
std::list<ThreadInfoSummary> threads;
|
|
|
|
std::list<ThreadInfoSummary>::iterator tit;
|
|
|
|
rsForums->getForumThreadList(mCurrForumId, threads);
|
2010-05-01 15:03:35 -04:00
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
QList<QTreeWidgetItem *> items;
|
|
|
|
for(tit = threads.begin(); tit != threads.end(); tit++)
|
2010-01-04 11:03:26 -05:00
|
|
|
{
|
2010-05-19 16:17:43 -04:00
|
|
|
std::cerr << "ForumsDialog::insertThreads() Adding TopLevel Thread: mId: ";
|
|
|
|
std::cerr << tit->msgId << std::endl;
|
|
|
|
|
|
|
|
/* add the top threads */
|
|
|
|
ForumMsgInfo msg;
|
|
|
|
if (!rsForums->getForumMessage(fId, tit->threadId, msg))
|
|
|
|
{
|
|
|
|
std::cerr << "ForumsDialog::insertThreads() Failed to Get TopLevel Msg";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
continue;
|
|
|
|
}
|
2010-05-01 15:03:35 -04:00
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
ForumMsgInfo msginfo;
|
|
|
|
if (rsForums->getForumMessage(fId,tit->msgId,msginfo) == false) {
|
|
|
|
std::cerr << "ForumsDialog::insertThreads() Failed to Get Msg";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
/* add Msg */
|
|
|
|
/* setup
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
QTreeWidgetItem *item = new QTreeWidgetItem();
|
|
|
|
|
|
|
|
{
|
|
|
|
QDateTime qtime;
|
|
|
|
if (useChildTS)
|
|
|
|
qtime.setTime_t(tit->childTS);
|
|
|
|
else
|
|
|
|
qtime.setTime_t(tit->ts);
|
|
|
|
|
|
|
|
QString timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss");
|
|
|
|
|
|
|
|
QString txt = timestamp;
|
|
|
|
if (useChildTS)
|
|
|
|
{
|
|
|
|
QDateTime qtime2;
|
|
|
|
qtime2.setTime_t(tit->ts);
|
|
|
|
QString timestamp2 = qtime2.toString("yyyy-MM-dd hh:mm:ss");
|
|
|
|
txt += " / ";
|
|
|
|
txt += timestamp2;
|
|
|
|
}
|
2010-08-08 18:58:10 -04:00
|
|
|
item -> setText(COLUMN_THREAD_DATE, txt);
|
2010-05-19 16:17:43 -04:00
|
|
|
}
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
item->setText(COLUMN_THREAD_TITLE, QString::fromStdWString(tit->title));
|
|
|
|
item->setSizeHint(COLUMN_THREAD_TITLE, QSize( 18,18 ) );
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
if (rsPeers->getPeerName(msginfo.srcId) !="")
|
|
|
|
{
|
2010-08-08 18:58:10 -04:00
|
|
|
item->setText(COLUMN_THREAD_AUTHOR, QString::fromStdString(rsPeers->getPeerName(msginfo.srcId)));
|
2010-05-19 16:17:43 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-08-08 18:58:10 -04:00
|
|
|
item->setText(COLUMN_THREAD_AUTHOR, tr("Anonymous"));
|
2010-05-19 16:17:43 -04:00
|
|
|
}
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
if (msginfo.msgflags & RS_DISTRIB_AUTHEN_REQ)
|
|
|
|
{
|
2010-08-08 18:58:10 -04:00
|
|
|
item->setText(COLUMN_THREAD_SIGNED, tr("signed"));
|
|
|
|
item->setIcon(COLUMN_THREAD_SIGNED,(QIcon(":/images/mail-signed.png")));
|
2010-05-19 16:17:43 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-08-08 18:58:10 -04:00
|
|
|
item->setText(COLUMN_THREAD_SIGNED, tr("none"));
|
|
|
|
item->setIcon(COLUMN_THREAD_SIGNED,(QIcon(":/images/mail-signature-unknown.png")));
|
2010-05-19 16:17:43 -04:00
|
|
|
}
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
if (nFilterColumn == COLUMN_THREAD_CONTENT) {
|
2010-05-19 16:17:43 -04:00
|
|
|
// need content for filter
|
|
|
|
QTextDocument doc;
|
|
|
|
doc.setHtml(QString::fromStdWString(msginfo.msg));
|
2010-08-08 18:58:10 -04:00
|
|
|
item->setText(COLUMN_THREAD_CONTENT, doc.toPlainText().replace(QString("\n"), QString(" ")));
|
2010-05-19 16:17:43 -04:00
|
|
|
}
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID, QString::fromStdString(tit->msgId));
|
|
|
|
|
|
|
|
if (m_bIsForumSubscribed) {
|
|
|
|
rsForums->getMessageStatus(msginfo.forumId, msginfo.msgId, status);
|
|
|
|
} else {
|
|
|
|
// show message as read
|
|
|
|
status = FORUM_MSG_STATUS_READ;
|
|
|
|
}
|
|
|
|
item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS, status);
|
2010-05-19 16:17:43 -04:00
|
|
|
|
|
|
|
std::list<QTreeWidgetItem *> threadlist;
|
|
|
|
threadlist.push_back(item);
|
|
|
|
|
|
|
|
while (threadlist.size() > 0)
|
|
|
|
{
|
|
|
|
/* get children */
|
|
|
|
QTreeWidgetItem *parent = threadlist.front();
|
|
|
|
threadlist.pop_front();
|
2010-08-08 18:58:10 -04:00
|
|
|
std::string pId = parent->data(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID).toString().toStdString();
|
2010-05-19 16:17:43 -04:00
|
|
|
|
|
|
|
std::list<ThreadInfoSummary> msgs;
|
|
|
|
std::list<ThreadInfoSummary>::iterator mit;
|
|
|
|
|
|
|
|
std::cerr << "ForumsDialog::insertThreads() Getting Children of : " << pId;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
if (rsForums->getForumThreadMsgList(fId, pId, msgs))
|
|
|
|
{
|
|
|
|
std::cerr << "ForumsDialog::insertThreads() #Children " << msgs.size();
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
/* iterate through child */
|
|
|
|
for(mit = msgs.begin(); mit != msgs.end(); mit++)
|
|
|
|
{
|
|
|
|
std::cerr << "ForumsDialog::insertThreads() adding " << mit->msgId;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
ForumMsgInfo msginfo;
|
|
|
|
if (rsForums->getForumMessage(fId,mit->msgId,msginfo) == false) {
|
|
|
|
std::cerr << "ForumsDialog::insertThreads() Failed to Get Msg";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
QTreeWidgetItem *child = NULL;
|
|
|
|
if (flatView)
|
|
|
|
{
|
|
|
|
child = new QTreeWidgetItem();
|
2010-05-30 19:49:20 -04:00
|
|
|
ui.threadTreeWidget->setRootIsDecorated( true );
|
2010-05-19 16:17:43 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
child = new QTreeWidgetItem(parent);
|
|
|
|
ui.threadTreeWidget->setRootIsDecorated( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
QDateTime qtime;
|
|
|
|
if (useChildTS)
|
|
|
|
qtime.setTime_t(mit->childTS);
|
|
|
|
else
|
|
|
|
qtime.setTime_t(mit->ts);
|
|
|
|
|
|
|
|
QString timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss");
|
|
|
|
|
|
|
|
QString txt = timestamp;
|
|
|
|
if (useChildTS)
|
|
|
|
{
|
|
|
|
QDateTime qtime2;
|
|
|
|
qtime2.setTime_t(mit->ts);
|
|
|
|
QString timestamp2 = qtime2.toString("yyyy-MM-dd hh:mm:ss");
|
|
|
|
txt += " / ";
|
|
|
|
txt += timestamp2;
|
|
|
|
}
|
2010-08-08 18:58:10 -04:00
|
|
|
child -> setText(COLUMN_THREAD_DATE, txt);
|
2010-05-19 16:17:43 -04:00
|
|
|
}
|
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
child->setText(COLUMN_THREAD_TITLE, QString::fromStdWString(mit->title));
|
|
|
|
child->setSizeHint(COLUMN_THREAD_TITLE, QSize( 17,17 ) );
|
2010-05-19 16:17:43 -04:00
|
|
|
|
|
|
|
if (rsPeers->getPeerName(msginfo.srcId) !="")
|
|
|
|
{
|
2010-08-08 18:58:10 -04:00
|
|
|
child->setText(COLUMN_THREAD_AUTHOR, QString::fromStdString(rsPeers->getPeerName(msginfo.srcId)));
|
2010-05-19 16:17:43 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-08-08 18:58:10 -04:00
|
|
|
child->setText(COLUMN_THREAD_AUTHOR, tr("Anonymous"));
|
2010-05-19 16:17:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (msginfo.msgflags & RS_DISTRIB_AUTHEN_REQ)
|
|
|
|
{
|
2010-08-08 18:58:10 -04:00
|
|
|
child->setText(COLUMN_THREAD_SIGNED, tr("signed"));
|
|
|
|
child->setIcon(COLUMN_THREAD_SIGNED,(QIcon(":/images/mail-signed.png")));
|
2010-05-19 16:17:43 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-08-08 18:58:10 -04:00
|
|
|
child->setText(COLUMN_THREAD_SIGNED, tr("none"));
|
|
|
|
child->setIcon(COLUMN_THREAD_SIGNED,(QIcon(":/images/mail-signature-unknown.png")));
|
2010-05-19 16:17:43 -04:00
|
|
|
}
|
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
if (nFilterColumn == COLUMN_THREAD_CONTENT) {
|
2010-05-19 16:17:43 -04:00
|
|
|
// need content for filter
|
|
|
|
QTextDocument doc;
|
|
|
|
doc.setHtml(QString::fromStdWString(msginfo.msg));
|
2010-08-08 18:58:10 -04:00
|
|
|
child->setText(COLUMN_THREAD_CONTENT, doc.toPlainText().replace(QString("\n"), QString(" ")));
|
2010-05-19 16:17:43 -04:00
|
|
|
}
|
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
child->setData(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID, QString::fromStdString(mit->msgId));
|
|
|
|
|
|
|
|
if (m_bIsForumSubscribed) {
|
|
|
|
rsForums->getMessageStatus(msginfo.forumId, msginfo.msgId, status);
|
|
|
|
} else {
|
|
|
|
// show message as read
|
|
|
|
status = FORUM_MSG_STATUS_READ;
|
|
|
|
}
|
|
|
|
child->setData(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS, status);
|
|
|
|
|
|
|
|
if (bFillComplete && bExpandNewMessages && IS_UNREAD(status)) {
|
|
|
|
QTreeWidgetItem *pParent = child;
|
|
|
|
while ((pParent = pParent->parent()) != NULL) {
|
|
|
|
if (std::find(itemToExpand.begin(), itemToExpand.end(), pParent) == itemToExpand.end()) {
|
|
|
|
itemToExpand.push_back(pParent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-05-19 16:17:43 -04:00
|
|
|
|
|
|
|
/* setup child */
|
|
|
|
threadlist.push_back(child);
|
|
|
|
|
|
|
|
if (flatView)
|
|
|
|
{
|
|
|
|
items.append(child);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
/* add to list */
|
|
|
|
items.append(item);
|
|
|
|
}
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
ui.postText->clear();
|
|
|
|
ui.threadTitle->clear();
|
|
|
|
/* add all messages in! */
|
|
|
|
if (m_LastViewType != ViewType || m_LastForumID != mCurrForumId) {
|
|
|
|
ui.threadTreeWidget->clear();
|
|
|
|
m_LastViewType = ViewType;
|
|
|
|
m_LastForumID = mCurrForumId;
|
|
|
|
ui.threadTreeWidget->insertTopLevelItems(0, items);
|
|
|
|
} else {
|
2010-08-08 18:58:10 -04:00
|
|
|
FillThreads (items, bExpandNewMessages, itemToExpand);
|
2010-05-01 15:03:35 -04:00
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
CleanupItems (items);
|
|
|
|
}
|
2010-05-01 15:03:35 -04:00
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
if (ui.filterPatternLineEdit->text().isEmpty() == false) {
|
|
|
|
FilterItems();
|
|
|
|
}
|
2010-05-01 15:03:35 -04:00
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
std::list<QTreeWidgetItem*>::iterator Item;
|
|
|
|
for (Item = itemToExpand.begin(); Item != itemToExpand.end(); Item++) {
|
|
|
|
if ((*Item)->isHidden() == false) {
|
|
|
|
(*Item)->setExpanded(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
insertPost ();
|
2010-08-08 18:58:10 -04:00
|
|
|
CalculateIconsAndFonts();
|
2008-04-09 08:57:26 -04:00
|
|
|
}
|
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
void ForumsDialog::FillThreads(QList<QTreeWidgetItem *> &ThreadList, bool bExpandNewMessages, std::list<QTreeWidgetItem*> &itemToExpand)
|
2008-04-09 08:57:26 -04:00
|
|
|
{
|
2010-05-12 18:23:05 -04:00
|
|
|
int Index = 0;
|
2010-05-01 15:03:35 -04:00
|
|
|
QTreeWidgetItem *Thread;
|
2010-05-17 17:42:18 -04:00
|
|
|
QList<QTreeWidgetItem *>::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++) {
|
2010-08-08 18:58:10 -04:00
|
|
|
if (Thread->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID) == (*NewThread)->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID)) {
|
2010-05-17 17:42:18 -04:00
|
|
|
// found it
|
|
|
|
Found = Index;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Found >= 0) {
|
|
|
|
Index++;
|
|
|
|
} else {
|
|
|
|
delete (ui.threadTreeWidget->takeTopLevelItem (Index));
|
|
|
|
}
|
|
|
|
}
|
2010-05-01 15:03:35 -04:00
|
|
|
|
|
|
|
// 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);
|
2010-08-08 18:58:10 -04:00
|
|
|
if (Thread->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID) == (*NewThread)->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID)) {
|
2010-05-01 15:03:35 -04:00
|
|
|
// found it
|
|
|
|
Found = Index;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-08-08 18:58:10 -04:00
|
|
|
|
2010-05-01 15:03:35 -04:00
|
|
|
if (Found >= 0) {
|
|
|
|
// set child data
|
2010-08-08 18:58:10 -04:00
|
|
|
int i;
|
|
|
|
for (i = 0; i < COLUMN_THREAD_COUNT; i++) {
|
2010-05-01 15:03:35 -04:00
|
|
|
Thread->setText (i, (*NewThread)->text (i));
|
|
|
|
}
|
2010-08-08 18:58:10 -04:00
|
|
|
for (i = 0; i < ROLE_THREAD_COUNT; i++) {
|
|
|
|
Thread->setData (COLUMN_THREAD_DATA, Qt::UserRole + i, (*NewThread)->data (COLUMN_THREAD_DATA, Qt::UserRole + i));
|
|
|
|
}
|
2010-05-01 15:03:35 -04:00
|
|
|
|
|
|
|
// fill recursive
|
2010-08-08 18:58:10 -04:00
|
|
|
FillChildren (Thread, *NewThread, bExpandNewMessages, itemToExpand);
|
2010-05-01 15:03:35 -04:00
|
|
|
} else {
|
|
|
|
// add new thread
|
2010-05-17 17:42:18 -04:00
|
|
|
ui.threadTreeWidget->addTopLevelItem (*NewThread);
|
2010-08-08 18:58:10 -04:00
|
|
|
Thread = *NewThread;
|
2010-05-17 17:42:18 -04:00
|
|
|
*NewThread = NULL;
|
2010-05-01 15:03:35 -04:00
|
|
|
}
|
2010-08-08 18:58:10 -04:00
|
|
|
|
|
|
|
uint32_t status = Thread->data (COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt();
|
|
|
|
if (bExpandNewMessages && IS_UNREAD(status)) {
|
|
|
|
QTreeWidgetItem *pParent = Thread;
|
|
|
|
while ((pParent = pParent->parent()) != NULL) {
|
|
|
|
if (std::find(itemToExpand.begin(), itemToExpand.end(), pParent) == itemToExpand.end()) {
|
|
|
|
itemToExpand.push_back(pParent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-05-01 15:03:35 -04:00
|
|
|
}
|
2010-05-17 17:42:18 -04:00
|
|
|
}
|
2010-05-01 15:03:35 -04:00
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
void ForumsDialog::FillChildren(QTreeWidgetItem *Parent, QTreeWidgetItem *NewParent, bool bExpandNewMessages, std::list<QTreeWidgetItem*> &itemToExpand)
|
2010-05-17 17:42:18 -04:00
|
|
|
{
|
|
|
|
int Index = 0;
|
|
|
|
int NewIndex;
|
|
|
|
int NewCount = NewParent->childCount();
|
2010-05-01 15:03:35 -04:00
|
|
|
|
2010-05-17 17:42:18 -04:00
|
|
|
QTreeWidgetItem *Child;
|
|
|
|
QTreeWidgetItem *NewChild;
|
|
|
|
|
|
|
|
// delete not existing
|
|
|
|
while (Index < Parent->childCount ()) {
|
|
|
|
Child = Parent->child (Index);
|
|
|
|
|
|
|
|
// search existing new child
|
2010-05-01 15:03:35 -04:00
|
|
|
int Found = -1;
|
2010-05-17 17:42:18 -04:00
|
|
|
int Count = NewParent->childCount();
|
|
|
|
for (NewIndex = 0; NewIndex < Count; NewIndex++) {
|
|
|
|
NewChild = NewParent->child (NewIndex);
|
2010-08-08 18:58:10 -04:00
|
|
|
if (NewChild->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID) == Child->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID)) {
|
2010-05-01 15:03:35 -04:00
|
|
|
// found it
|
|
|
|
Found = Index;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Found >= 0) {
|
|
|
|
Index++;
|
|
|
|
} else {
|
2010-05-17 17:42:18 -04:00
|
|
|
delete (Parent->takeChild (Index));
|
2010-05-01 15:03:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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);
|
2010-08-08 18:58:10 -04:00
|
|
|
if (Child->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID) == NewChild->data (COLUMN_THREAD_DATA, ROLE_THREAD_MSGID)) {
|
2010-05-01 15:03:35 -04:00
|
|
|
// found it
|
|
|
|
Found = Index;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-08-08 18:58:10 -04:00
|
|
|
|
2010-05-01 15:03:35 -04:00
|
|
|
if (Found >= 0) {
|
|
|
|
// set child data
|
2010-08-08 18:58:10 -04:00
|
|
|
int i;
|
|
|
|
for (i = 0; i < COLUMN_THREAD_COUNT; i++) {
|
2010-05-01 15:03:35 -04:00
|
|
|
Child->setText (i, NewChild->text (i));
|
|
|
|
}
|
2010-08-08 18:58:10 -04:00
|
|
|
for (i = 0; i < ROLE_THREAD_COUNT; i++) {
|
|
|
|
Child->setData (COLUMN_THREAD_DATA, Qt::UserRole + i, NewChild->data (COLUMN_THREAD_DATA, Qt::UserRole + i));
|
|
|
|
}
|
2010-05-01 15:03:35 -04:00
|
|
|
|
|
|
|
// fill recursive
|
2010-08-08 18:58:10 -04:00
|
|
|
FillChildren (Child, NewChild, bExpandNewMessages, itemToExpand);
|
2010-05-01 15:03:35 -04:00
|
|
|
} else {
|
|
|
|
// add new child
|
2010-08-08 18:58:10 -04:00
|
|
|
Child = NewParent->takeChild(NewIndex);
|
|
|
|
Parent->addChild (Child);
|
2010-05-17 17:42:18 -04:00
|
|
|
NewIndex--;
|
|
|
|
NewCount--;
|
2010-05-01 15:03:35 -04:00
|
|
|
}
|
2010-08-08 18:58:10 -04:00
|
|
|
|
|
|
|
uint32_t status = Child->data (COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt();
|
|
|
|
if (bExpandNewMessages && IS_UNREAD(status)) {
|
|
|
|
QTreeWidgetItem *pParent = Child;
|
|
|
|
while ((pParent = pParent->parent()) != NULL) {
|
|
|
|
if (std::find(itemToExpand.begin(), itemToExpand.end(), pParent) == itemToExpand.end()) {
|
|
|
|
itemToExpand.push_back(pParent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-05-01 15:03:35 -04:00
|
|
|
}
|
|
|
|
}
|
2008-04-09 08:57:26 -04:00
|
|
|
|
|
|
|
void ForumsDialog::insertPost()
|
|
|
|
{
|
2010-08-08 18:58:10 -04:00
|
|
|
if ((mCurrForumId == "") || (mCurrThreadId == ""))
|
2010-05-19 16:17:43 -04:00
|
|
|
{
|
|
|
|
ui.postText->setText("");
|
|
|
|
ui.threadTitle->setText("");
|
|
|
|
ui.previousButton->setEnabled(false);
|
|
|
|
ui.nextButton->setEnabled(false);
|
2010-09-13 19:35:21 -04:00
|
|
|
ui.newmessageButton->setEnabled (false);
|
2010-05-19 16:17:43 -04:00
|
|
|
return;
|
|
|
|
}
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
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);
|
|
|
|
}
|
2010-05-01 15:03:35 -04:00
|
|
|
|
2010-09-13 19:35:21 -04:00
|
|
|
ui.newmessageButton->setEnabled (m_bIsForumSubscribed && mCurrThreadId.empty() == false);
|
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
/* get the Post */
|
|
|
|
ForumMsgInfo msg;
|
2010-08-08 18:58:10 -04:00
|
|
|
if (!rsForums->getForumMessage(mCurrForumId, mCurrThreadId, msg))
|
2010-05-19 16:17:43 -04:00
|
|
|
{
|
|
|
|
ui.postText->setText("");
|
|
|
|
return;
|
|
|
|
}
|
2010-05-01 15:03:35 -04:00
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
bool bSetToReadOnActive = Settings->getForumMsgSetToReadOnActivate();
|
|
|
|
uint32_t status = curr->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt();
|
|
|
|
|
|
|
|
QList<QTreeWidgetItem*> Row;
|
|
|
|
Row.append(curr);
|
|
|
|
if (status & FORUM_MSG_STATUS_READ) {
|
|
|
|
if (bSetToReadOnActive && (status & FORUM_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);
|
|
|
|
}
|
2010-05-19 16:17:43 -04:00
|
|
|
}
|
2010-05-01 15:03:35 -04:00
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
QString extraTxt;
|
|
|
|
extraTxt += QString::fromStdWString(msg.msg);
|
2010-09-14 13:47:11 -04:00
|
|
|
Emoticons::formatText(extraTxt);
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
ui.postText->setHtml(extraTxt);
|
2010-08-08 18:58:10 -04:00
|
|
|
ui.threadTitle->setText(QString::fromStdWString(msg.title));
|
2008-04-09 08:57:26 -04:00
|
|
|
}
|
|
|
|
|
2010-05-01 15:03:35 -04:00
|
|
|
void ForumsDialog::previousMessage ()
|
|
|
|
{
|
|
|
|
QTreeWidgetItem *Item = ui.threadTreeWidget->currentItem ();
|
|
|
|
if (Item == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-05-01 15:03:35 -04:00
|
|
|
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 ForumsDialog::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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO
|
2010-08-08 18:58:10 -04:00
|
|
|
#if 0
|
2008-04-09 08:57:26 -04:00
|
|
|
void ForumsDialog::removemessage()
|
|
|
|
{
|
|
|
|
//std::cerr << "ForumsDialog::removemessage()" << std::endl;
|
|
|
|
std::string cid, mid;
|
|
|
|
if (!getCurrentMsg(cid, mid))
|
|
|
|
{
|
|
|
|
//std::cerr << "ForumsDialog::removemessage()";
|
|
|
|
//std::cerr << " No Message selected" << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
rsMsgs -> MessageDelete(mid);
|
2010-08-08 18:58:10 -04:00
|
|
|
}
|
2008-04-09 08:57:26 -04:00
|
|
|
#endif
|
2010-08-08 18:58:10 -04:00
|
|
|
|
|
|
|
/* get selected messages
|
|
|
|
the messages tree is single selected, but who knows ... */
|
|
|
|
int ForumsDialog::getSelectedMsgCount(QList<QTreeWidgetItem*> *pRows, QList<QTreeWidgetItem*> *pRowsRead, QList<QTreeWidgetItem*> *pRowsUnread)
|
|
|
|
{
|
|
|
|
if (pRowsRead) pRowsRead->clear();
|
|
|
|
if (pRowsUnread) pRowsUnread->clear();
|
|
|
|
|
|
|
|
QList<QTreeWidgetItem*> selectedItems = ui.threadTreeWidget->selectedItems();
|
|
|
|
for(QList<QTreeWidgetItem*>::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_UNREAD(status)) {
|
|
|
|
if (pRowsUnread) pRowsUnread->append(*it);
|
|
|
|
} else {
|
|
|
|
if (pRowsRead) pRowsRead->append(*it);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return selectedItems.size();
|
2008-04-09 08:57:26 -04:00
|
|
|
}
|
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
void ForumsDialog::setMsgAsReadUnread(QList<QTreeWidgetItem*> &Rows, bool bRead)
|
|
|
|
{
|
|
|
|
QList<QTreeWidgetItem*>::iterator Row;
|
2010-08-11 04:31:11 -04:00
|
|
|
std::list<QTreeWidgetItem*> changedItems;
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
for (Row = Rows.begin(); Row != Rows.end(); Row++) {
|
|
|
|
uint32_t status = (*Row)->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt();
|
|
|
|
|
|
|
|
/* set always as read ... */
|
|
|
|
uint32_t statusNew = status | FORUM_MSG_STATUS_READ;
|
|
|
|
if (bRead) {
|
|
|
|
/* ... and as read by user */
|
|
|
|
statusNew &= ~FORUM_MSG_STATUS_UNREAD_BY_USER;
|
|
|
|
} else {
|
|
|
|
/* ... and as unread by user */
|
|
|
|
statusNew |= FORUM_MSG_STATUS_UNREAD_BY_USER;
|
|
|
|
}
|
|
|
|
if (status != statusNew) {
|
|
|
|
std::string msgId = (*Row)->data(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID).toString().toStdString();
|
|
|
|
rsForums->setMessageStatus(mCurrForumId, msgId, statusNew, FORUM_MSG_STATUS_READ | FORUM_MSG_STATUS_UNREAD_BY_USER);
|
|
|
|
|
|
|
|
(*Row)->setData(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS, statusNew);
|
2010-08-11 04:31:11 -04:00
|
|
|
|
|
|
|
QTreeWidgetItem *parentItem = *Row;
|
|
|
|
while (parentItem->parent()) {
|
|
|
|
parentItem = parentItem->parent();
|
|
|
|
}
|
|
|
|
if (std::find(changedItems.begin(), changedItems.end(), parentItem) == changedItems.end()) {
|
|
|
|
changedItems.push_back(parentItem);
|
|
|
|
}
|
2010-08-08 18:58:10 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-11 04:31:11 -04:00
|
|
|
if (changedItems.size()) {
|
|
|
|
for (std::list<QTreeWidgetItem*>::iterator it = changedItems.begin(); it != changedItems.end(); it++) {
|
|
|
|
CalculateIconsAndFonts(*it);
|
|
|
|
}
|
2010-08-09 17:20:34 -04:00
|
|
|
updateMessageSummaryList(mCurrForumId);
|
2010-08-08 18:58:10 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ForumsDialog::markMsgAsReadUnread (bool bRead, bool bAll)
|
2008-04-09 08:57:26 -04:00
|
|
|
{
|
2010-08-08 18:58:10 -04:00
|
|
|
if (mCurrForumId.empty() || m_bIsForumSubscribed == false) {
|
|
|
|
return;
|
|
|
|
}
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
/* get selected messages */
|
|
|
|
QList<QTreeWidgetItem*> Rows;
|
|
|
|
getSelectedMsgCount (&Rows, NULL, NULL);
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
if (bAll) {
|
|
|
|
/* add children */
|
|
|
|
QList<QTreeWidgetItem*> AllRows;
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
while (Rows.isEmpty() == false) {
|
|
|
|
QTreeWidgetItem *pRow = Rows.takeFirst();
|
|
|
|
|
|
|
|
/* add only items with the right state or with not FORUM_MSG_STATUS_READ */
|
|
|
|
uint32_t status = pRow->data(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS).toUInt();
|
|
|
|
if (IS_UNREAD(status) == bRead || (status & FORUM_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);
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
setMsgAsReadUnread (Rows, bRead);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ForumsDialog::markMsgAsRead()
|
|
|
|
{
|
|
|
|
markMsgAsReadUnread(true, false);
|
|
|
|
}
|
2008-04-09 08:57:26 -04:00
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
void ForumsDialog::markMsgAsReadAll()
|
|
|
|
{
|
|
|
|
markMsgAsReadUnread(true, true);
|
2008-04-09 08:57:26 -04:00
|
|
|
}
|
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
void ForumsDialog::markMsgAsUnread()
|
|
|
|
{
|
|
|
|
markMsgAsReadUnread(false, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ForumsDialog::markMsgAsUnreadAll()
|
|
|
|
{
|
|
|
|
markMsgAsReadUnread(false, true);
|
|
|
|
}
|
2008-04-09 08:57:26 -04:00
|
|
|
|
|
|
|
void ForumsDialog::newforum()
|
|
|
|
{
|
2010-05-01 15:03:35 -04:00
|
|
|
CreateForum cf (this);
|
|
|
|
cf.exec ();
|
2008-04-09 08:57:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-15 12:40:38 -04:00
|
|
|
void ForumsDialog::createmessage()
|
|
|
|
{
|
2010-08-08 18:58:10 -04:00
|
|
|
if (mCurrForumId.empty () || m_bIsForumSubscribed == false) {
|
2010-05-01 15:03:35 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
CreateForumMsg *cfm = new CreateForumMsg(mCurrForumId, mCurrThreadId);
|
2010-05-01 15:03:35 -04:00
|
|
|
cfm->show();
|
2008-04-15 12:40:38 -04:00
|
|
|
|
2010-05-01 15:03:35 -04:00
|
|
|
/* window will destroy itself! */
|
2008-04-15 12:40:38 -04:00
|
|
|
}
|
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
void ForumsDialog::createthread()
|
2008-04-15 12:40:38 -04:00
|
|
|
{
|
2010-05-01 15:03:35 -04:00
|
|
|
if (mCurrForumId.empty ()) {
|
2010-09-14 15:38:47 -04:00
|
|
|
QMessageBox::information(this, tr("RetroShare"), tr("No Forum Selected!"));
|
2010-05-01 15:03:35 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
CreateForumMsg *cfm = new CreateForumMsg(mCurrForumId, "");
|
|
|
|
cfm->setWindowTitle(tr("Start New Thread"));
|
|
|
|
cfm->show();
|
2008-04-15 12:40:38 -04:00
|
|
|
|
2010-05-01 15:03:35 -04:00
|
|
|
/* window will destroy itself! */
|
2008-04-15 12:40:38 -04:00
|
|
|
}
|
|
|
|
|
2008-06-13 11:46:34 -04:00
|
|
|
void ForumsDialog::subscribeToForum()
|
|
|
|
{
|
|
|
|
forumSubscribe(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ForumsDialog::unsubscribeToForum()
|
|
|
|
{
|
|
|
|
forumSubscribe(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ForumsDialog::forumSubscribe(bool subscribe)
|
|
|
|
{
|
2010-08-08 18:58:10 -04:00
|
|
|
QTreeWidgetItem *forumItem = ui.forumTreeWidget->currentItem();
|
|
|
|
if ((!forumItem) || (forumItem->parent() == NULL))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2008-06-13 11:46:34 -04:00
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
/* store forumId */
|
|
|
|
std::string fId = forumItem->data(COLUMN_FORUM_DATA, ROLE_FORUM_ID).toString().toStdString();
|
2008-06-13 11:46:34 -04:00
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
rsForums->forumSubscribe(fId, subscribe);
|
2008-06-13 11:46:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ForumsDialog::showForumDetails()
|
|
|
|
{
|
2010-05-01 15:03:35 -04:00
|
|
|
if (mCurrForumId == "")
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2010-01-02 10:47:07 -05:00
|
|
|
|
2010-05-01 15:03:35 -04:00
|
|
|
ForumDetails fui;
|
2008-06-13 11:46:34 -04:00
|
|
|
|
2010-05-01 15:03:35 -04:00
|
|
|
fui.showDetails (mCurrForumId);
|
|
|
|
fui.exec ();
|
2008-06-13 11:46:34 -04:00
|
|
|
}
|
|
|
|
|
2010-09-14 15:38:47 -04:00
|
|
|
void ForumsDialog::editForumDetails()
|
|
|
|
{
|
|
|
|
if (mCurrForumId == "")
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
EditForumDetails editUi(mCurrForumId, this);
|
|
|
|
editUi.exec();
|
|
|
|
}
|
|
|
|
|
2010-01-09 11:33:00 -05:00
|
|
|
void ForumsDialog::replytomessage()
|
|
|
|
{
|
2010-08-08 18:58:10 -04:00
|
|
|
if (mCurrForumId.empty()) {
|
2010-05-01 15:03:35 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-08-08 18:58:10 -04:00
|
|
|
std::string fId = mCurrForumId;
|
|
|
|
std::string pId = mCurrThreadId;
|
2010-05-01 15:03:35 -04:00
|
|
|
|
|
|
|
ForumMsgInfo msgInfo ;
|
|
|
|
rsForums->getForumMessage(fId,pId,msgInfo) ;
|
|
|
|
|
|
|
|
if (rsPeers->getPeerName(msgInfo.srcId) !="")
|
|
|
|
{
|
2010-05-25 05:32:14 -04:00
|
|
|
MessageComposer *nMsgDialog = new MessageComposer();
|
2010-05-01 15:03:35 -04:00
|
|
|
nMsgDialog->newMsg();
|
2010-09-12 18:17:17 -04:00
|
|
|
nMsgDialog->insertTitleText( (QString("Re:") + " " + QString::fromStdWString(msgInfo.title)).toStdString()) ;
|
|
|
|
nMsgDialog->setWindowTitle(tr("Re:") + " " + QString::fromStdWString(msgInfo.title) ) ;
|
2010-05-01 15:03:35 -04:00
|
|
|
|
|
|
|
QTextDocument doc ;
|
|
|
|
doc.setHtml(QString::fromStdWString(msgInfo.msg)) ;
|
|
|
|
std::string cited_text(doc.toPlainText().toStdString()) ;
|
|
|
|
|
|
|
|
nMsgDialog->insertPastedText(cited_text) ;
|
|
|
|
nMsgDialog->addRecipient( msgInfo.srcId ) ;
|
|
|
|
nMsgDialog->show();
|
|
|
|
nMsgDialog->activateWindow();
|
2010-05-02 20:09:55 -04:00
|
|
|
|
|
|
|
/* window will destroy itself! */
|
2010-05-01 15:03:35 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QMessageBox::information(this, tr("RetroShare"),tr("You cant reply a Anonymous Author"));
|
|
|
|
}
|
2010-01-09 11:33:00 -05:00
|
|
|
}
|
2008-06-13 11:46:34 -04:00
|
|
|
|
2010-05-01 15:03:35 -04:00
|
|
|
void ForumsDialog::anchorClicked (const QUrl& link )
|
2010-01-14 08:03:43 -05:00
|
|
|
{
|
|
|
|
#ifdef FORUM_DEBUG
|
2010-07-15 07:25:34 -04:00
|
|
|
std::cerr << "ForumsDialog::anchorClicked link.scheme() : " << link.scheme().toStdString() << std::endl;
|
2010-01-14 08:03:43 -05:00
|
|
|
#endif
|
2010-05-01 15:03:35 -04:00
|
|
|
|
2010-09-24 17:01:13 -04:00
|
|
|
RetroShareLink::processUrl(link, RSLINK_PROCESS_NOTIFY_ALL);
|
2010-01-16 09:31:32 -05:00
|
|
|
}
|
2010-05-19 16:17:43 -04:00
|
|
|
|
|
|
|
void ForumsDialog::filterRegExpChanged()
|
|
|
|
{
|
|
|
|
// QRegExp regExp(ui.filterPatternLineEdit->text(), Qt::CaseInsensitive , QRegExp::FixedString);
|
|
|
|
// proxyModel->setFilterRegExp(regExp);
|
|
|
|
|
|
|
|
QString text = ui.filterPatternLineEdit->text();
|
|
|
|
|
|
|
|
if (text.isEmpty()) {
|
|
|
|
ui.clearButton->hide();
|
|
|
|
} else {
|
|
|
|
ui.clearButton->show();
|
|
|
|
}
|
|
|
|
|
|
|
|
FilterItems();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* clear Filter */
|
|
|
|
void ForumsDialog::clearFilter()
|
|
|
|
{
|
|
|
|
ui.filterPatternLineEdit->clear();
|
|
|
|
ui.filterPatternLineEdit->setFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ForumsDialog::changedViewBox()
|
|
|
|
{
|
2010-05-20 17:53:27 -04:00
|
|
|
if (m_bProcessSettings) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
// save index
|
2010-05-20 17:53:27 -04:00
|
|
|
Settings->setValueToGroup("ForumsDialog", "viewBox", ui.viewBox->currentIndex());
|
2010-05-19 16:17:43 -04:00
|
|
|
|
|
|
|
insertThreads();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ForumsDialog::filterColumnChanged()
|
|
|
|
{
|
2010-05-20 17:53:27 -04:00
|
|
|
if (m_bProcessSettings) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-05-19 16:17:43 -04:00
|
|
|
int nFilterColumn = FilterColumnFromComboBox(ui.filterColumnComboBox->currentIndex());
|
2010-08-08 18:58:10 -04:00
|
|
|
if (nFilterColumn == COLUMN_THREAD_CONTENT) {
|
2010-05-19 16:17:43 -04:00
|
|
|
// need content ... refill
|
|
|
|
insertThreads();
|
|
|
|
} else {
|
|
|
|
FilterItems();
|
|
|
|
}
|
|
|
|
|
|
|
|
// save index
|
2010-05-20 17:53:27 -04:00
|
|
|
Settings->setValueToGroup("ForumsDialog", "filterColumn", nFilterColumn);
|
2010-05-19 16:17:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ForumsDialog::FilterItems()
|
|
|
|
{
|
|
|
|
QString sPattern = ui.filterPatternLineEdit->text();
|
|
|
|
int nFilterColumn = FilterColumnFromComboBox(ui.filterColumnComboBox->currentIndex());
|
|
|
|
|
|
|
|
int nCount = ui.threadTreeWidget->topLevelItemCount ();
|
|
|
|
for (int nIndex = 0; nIndex < nCount; nIndex++) {
|
|
|
|
FilterItem(ui.threadTreeWidget->topLevelItem(nIndex), sPattern, nFilterColumn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ForumsDialog::FilterItem(QTreeWidgetItem *pItem, QString &sPattern, int nFilterColumn)
|
|
|
|
{
|
|
|
|
bool bVisible = true;
|
|
|
|
|
|
|
|
if (sPattern.isEmpty() == false) {
|
|
|
|
if (pItem->text(nFilterColumn).contains(sPattern, Qt::CaseInsensitive) == false) {
|
|
|
|
bVisible = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int nVisibleChildCount = 0;
|
|
|
|
int nCount = pItem->childCount();
|
|
|
|
for (int nIndex = 0; nIndex < nCount; nIndex++) {
|
|
|
|
if (FilterItem(pItem->child(nIndex), sPattern, nFilterColumn)) {
|
|
|
|
nVisibleChildCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bVisible || nVisibleChildCount) {
|
|
|
|
pItem->setHidden(false);
|
|
|
|
} else {
|
|
|
|
pItem->setHidden(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (bVisible || nVisibleChildCount);
|
|
|
|
}
|
2010-08-09 17:20:34 -04:00
|
|
|
|
|
|
|
void ForumsDialog::updateMessageSummaryList(std::string forumId)
|
|
|
|
{
|
|
|
|
QTreeWidgetItem *apToplevelItem[2] = { YourForums, SubscribedForums };
|
|
|
|
int nToplevelItem;
|
|
|
|
|
|
|
|
for (nToplevelItem = 0; nToplevelItem < 2; nToplevelItem++) {
|
|
|
|
QTreeWidgetItem *pToplevelItem = apToplevelItem[nToplevelItem];
|
|
|
|
|
|
|
|
int nItem;
|
|
|
|
int nItemCount = pToplevelItem->childCount();
|
|
|
|
|
|
|
|
for (nItem = 0; nItem < nItemCount; nItem++) {
|
|
|
|
QTreeWidgetItem *pItem = pToplevelItem->child(nItem);
|
|
|
|
std::string fId = pItem->data(COLUMN_FORUM_DATA, ROLE_FORUM_ID).toString().toStdString();
|
|
|
|
if (forumId.empty() || fId == forumId) {
|
|
|
|
/* calculating the new messages */
|
|
|
|
unsigned int newMessageCount = 0;
|
|
|
|
unsigned int unreadMessageCount = 0;
|
|
|
|
rsForums->getMessageCount(fId, newMessageCount, unreadMessageCount);
|
|
|
|
|
|
|
|
QString sTitle = pItem->data(COLUMN_FORUM_DATA, ROLE_FORUM_TITLE).toString();
|
2010-08-10 11:41:25 -04:00
|
|
|
QFont qf = pItem->font(COLUMN_FORUM_TITLE);
|
2010-08-09 17:20:34 -04:00
|
|
|
if (unreadMessageCount) {
|
|
|
|
sTitle += " (" + QString::number(unreadMessageCount) + ")";
|
2010-08-10 11:41:25 -04:00
|
|
|
qf.setBold(true);
|
|
|
|
} else {
|
|
|
|
qf.setBold(false);
|
2010-08-09 17:20:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
pItem->setText(COLUMN_FORUM_TITLE, sTitle);
|
2010-08-10 11:41:25 -04:00
|
|
|
pItem->setFont(COLUMN_FORUM_TITLE, qf);
|
2010-08-09 17:20:34 -04:00
|
|
|
|
|
|
|
if (forumId.empty() == false) {
|
|
|
|
/* calculate only this forum */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|