Added tabs to gxsforums.

Moved the thread message part from GxsForumsDialog to GxsForumThreadWidget.
Added placeholder text to existing and new base classes to display for example "Loading".

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5905 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-11-27 23:21:20 +00:00
parent ca3ef27595
commit 25de47c6f9
13 changed files with 2946 additions and 2463 deletions

View File

@ -376,6 +376,7 @@ HEADERS += rshare.h \
gui/common/PopularityDefs.h \
gui/common/GroupTreeWidget.h \
gui/common/RSTreeView.h \
gui/common/RSTreeWidget.h \
gui/common/AvatarWidget.h \
gui/common/FriendList.h \
gui/common/FriendSelectionWidget.h \
@ -636,6 +637,7 @@ SOURCES += main.cpp \
gui/common/PopularityDefs.cpp \
gui/common/GroupTreeWidget.cpp \
gui/common/RSTreeView.cpp \
gui/common/RSTreeWidget.cpp \
gui/common/AvatarWidget.cpp \
gui/common/FriendList.cpp \
gui/common/FriendSelectionWidget.cpp \
@ -968,17 +970,19 @@ gxsforums {
gui/gxsforums/GxsForumDetails.h \
gui/gxsforums/EditGxsForumDetails.h \
gui/gxsforums/CreateGxsForumMsg.h \
gui/gxsforums/GxsForumThreadWidget.h
FORMS += gui/GxsForumsDialog.ui \
gui/gxsforums/GxsForumDetails.ui \
gui/gxsforums/EditGxsForumDetails.ui \
gui/gxsforums/CreateGxsForumMsg.ui \
gui/gxsforums/GxsForumThreadWidget.ui
SOURCES += gui/GxsForumsDialog.cpp \
gui/gxsforums/GxsForumDetails.cpp \
gui/gxsforums/EditGxsForumDetails.cpp \
gui/gxsforums/CreateGxsForumMsg.cpp \
gui/gxsforums/GxsForumThreadWidget.cpp
}

File diff suppressed because it is too large Load Diff

View File

@ -32,47 +32,15 @@
#include "util/TokenQueue.h"
#include <retroshare/rsgxsforums.h>
#include "gui/gxs/GxsIdTreeWidgetItem.h"
class ForumInfo;
/* These are all the parameters that are required for thread loading.
* They are kept static for the load duration.
*/
class GxsForumsThreadLoadParameters
{
public:
std::string ForumId;
std::string FocusMsgId;
uint32_t SubscribeFlags;
int ViewType;
uint32_t FilterColumn;
std::map<uint32_t, QTreeWidgetItem *> MsgTokens;
QList<QTreeWidgetItem*> Items;
QList<QTreeWidgetItem*> ItemToExpand;
bool FillComplete;
bool FlatView;
bool UseChildTS;
bool ExpandNewMessages;
};
class RsGxsForumMsg;
class GxsForumsDialog : public RsAutoUpdatePage, public TokenResponse
{
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();
@ -87,56 +55,24 @@ public:
// Callback for all Loads.
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);
void changeEvent(QEvent *e);
// Utility Fns.
static QString titleFromInfo(const RsMsgMetaData &meta);
static QString messageFromInfo(const RsGxsForumMsg &msg);
private slots:
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();
void changedForum(const QString &id);
void changedThread();
void clickedThread (QTreeWidgetItem *item, int column);
void threadTabCloseRequested(int index);
void threadTabChanged(QWidget *widget);
void replytomessage();
void replyMessageData(const RsGxsForumMsg &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();
@ -144,110 +80,40 @@ private slots:
void showForumDetails();
void editForumDetails();
void previousMessage ();
void nextMessage ();
void nextUnreadMessage();
void downloadAllFiles();
void changedViewBox();
void filterColumnChanged(int column);
void filterItems(const QString &text);
void generateMassData();
void fillThreadFinished();
void fillThreadProgress(int current, int count);
void shareKey();
private:
void insertForums();
void insertThreads();
void insertPost();
void insertPostData(const RsGxsForumMsg &msg); // Second Half.
// Utility Fns.
QString titleFromInfo(const RsMsgMetaData &meta);
QString messageFromInfo(const RsGxsForumMsg &msg);
void forumMsgReadStatusChanged(const QString &forumId, const QString &msgId, int status);
int subscribeFlags(const std::string &forumId);
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<QTreeWidgetItem *> &ThreadList, bool bExpandNewMessages, QList<QTreeWidgetItem*> &itemToExpand);
void FillChildren(QTreeWidgetItem *Parent, QTreeWidgetItem *NewParent, bool bExpandNewMessages, QList<QTreeWidgetItem*> &itemToExpand);
int getSelectedMsgCount(QList<QTreeWidgetItem*> *pRows, QList<QTreeWidgetItem*> *pRowsRead, QList<QTreeWidgetItem*> *pRowsUnread);
void setMsgReadStatus(QList<QTreeWidgetItem*> &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();
bool filterItem(QTreeWidgetItem *pItem, const QString &text, int filterColumn);
void processSettings(bool load);
// New Request/Response Loading Functions.
void insertForumsData(const std::list<RsGroupMetaData> &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 RsGxsForumMsg &msg);
void requestChildData_InsertThreads(uint32_t &token, const RsGxsGrpMsgIdPair &parentId);
void loadChildData_InsertThreads(const uint32_t &token);
void loadForumChildMsg(const RsGxsForumMsg &msg, QTreeWidgetItem *parent);
void requestMsgData_InsertPost(const RsGxsGrpMsgIdPair &msgId);
void loadMsgData_InsertPost(const uint32_t &token);
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);
// void requestGroupSummary_CurrentForum(const std::string &forumId);
// void loadGroupSummary_CurrentForum(const uint32_t &token);
std::string mForumId;
QMap<std::string, int> mSubscribeFlags;
TokenQueue *mForumQueue;
bool m_bProcessSettings;
bool inMsgAsReadUnread;
QTreeWidgetItem *yourForums;
QTreeWidgetItem *subscribedForums;
QTreeWidgetItem *popularForums;
QTreeWidgetItem *otherForums;
RSTreeWidgetItemCompareRole *threadCompareRole;
std::string mCurrForumId;
std::string mCurrThreadId;
int subscribeFlags;
int lastViewType;
std::string lastForumID;
// New Datatypes to replace the FillThread.
bool mThreadLoading;
GxsForumsThreadLoadParameters mThreadLoad;
/* Color definitions (for standard see qss.default) */
QColor mTextColorRead;
QColor mTextColorUnread;
QColor mTextColorUnreadChildren;
QColor mTextColorNotSubscribed;
QColor mTextColorMissing;
/** Qt Designer generated object */
Ui::GxsForumsDialog ui;
};

View File

@ -97,6 +97,13 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="refreshButton">
<property name="text">
<string notr="true">Refresh</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="displayButton">
<property name="focusPolicy">
@ -161,458 +168,16 @@
</item>
</layout>
</widget>
<widget class="QSplitter" name="threadSplitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
<widget class="QTabWidget" name="threadTabWidget">
<property name="currentIndex">
<number>-1</number>
</property>
<property name="tabsClosable">
<bool>true</bool>
</property>
<property name="movable">
<bool>true</bool>
</property>
<widget class="QWidget" name="layoutWidget">
<layout class="QGridLayout">
<item row="1" column="0">
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="forumName">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>1677215</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="viewBox">
<item>
<property name="text">
<string>Last Post</string>
</property>
</item>
<item>
<property name="text">
<string>Threaded View</string>
</property>
</item>
<item>
<property name="text">
<string>Flat View</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QTreeWidget" name="threadTreeWidget">
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="allColumnsShowFocus">
<bool>true</bool>
</property>
<column>
<property name="text">
<string>Title</string>
</property>
</column>
<column>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/message-state-header.png</normaloff>:/images/message-state-header.png</iconset>
</property>
</column>
<column>
<property name="text">
<string>Date</string>
</property>
</column>
<column>
<property name="text">
<string>Author</string>
</property>
</column>
<column>
<property name="text">
<string>Signed</string>
</property>
</column>
</widget>
</item>
<item row="6" column="0">
<layout class="QGridLayout">
<item row="0" column="3">
<widget class="QPushButton" name="previousButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Previous Thread</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/back.png</normaloff>:/images/back.png</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QPushButton" name="nextButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Next Thread</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/forward.png</normaloff>:/images/forward.png</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="13">
<widget class="QPushButton" name="expandButton">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/edit_remove24.png</normaloff>:/images/edit_remove24.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="11">
<widget class="QPushButton" name="nextUnreadButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Force Refresh</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="newmessageButton">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Reply Message</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/mail_reply.png</normaloff>:/images/mail_reply.png</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="9">
<widget class="QLabel" name="by_label">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="7">
<widget class="QLabel" name="time_label">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="8">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QPushButton" name="downloadButton">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Download all files</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/down.png</normaloff>:/images/down.png</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="0" column="10">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QFrame" name="toolBarFrame">
<property name="minimumSize">
<size>
<width>0</width>
<height>32</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="margin">
<number>2</number>
</property>
<item>
<widget class="QToolButton" name="newthreadButton">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Start new Thread for Selected Forum</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/mail_new.png</normaloff>:/images/mail_new.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>16</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="LineEditClear" name="filterLineEdit">
<property name="toolTip">
<string>Search forums</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="0">
<layout class="QHBoxLayout" name="progressBarLayOut">
<item>
<widget class="QLabel" name="progLayOutTxt">
<property name="font">
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Loading</string>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
<property name="maximum">
<number>1000</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="5" column="0">
<widget class="QLabel" name="threadTitle">
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="LinkTextBrowser" name="postText">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>10</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
</widget>
</widget>
</widget>
</item>
@ -629,16 +194,6 @@
</action>
</widget>
<customwidgets>
<customwidget>
<class>LinkTextBrowser</class>
<extends>QTextBrowser</extends>
<header>gui/common/LinkTextBrowser.h</header>
</customwidget>
<customwidget>
<class>LineEditClear</class>
<extends>QLineEdit</extends>
<header location="global">gui/common/LineEditClear.h</header>
</customwidget>
<customwidget>
<class>GroupTreeWidget</class>
<extends>QWidget</extends>

View File

@ -68,6 +68,7 @@ GroupTreeWidget::GroupTreeWidget(QWidget *parent) :
connect(ui->treeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customContextMenuRequested(QPoint)));
connect(ui->treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), this, SLOT(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)));
connect(ui->treeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(itemClicked(QTreeWidgetItem*,int)));
/* Add own item delegate */
RSItemDelegate *itemDelegate = new RSItemDelegate(this);
@ -201,6 +202,19 @@ void GroupTreeWidget::currentItemChanged(QTreeWidgetItem *current, QTreeWidgetIt
emit treeCurrentItemChanged(id);
}
void GroupTreeWidget::itemClicked(QTreeWidgetItem *item, int column)
{
Q_UNUSED(column);
QString id;
if (item) {
id = item->data(COLUMN_DATA, ROLE_ID).toString();
}
emit treeItemClicked(id);
}
QTreeWidgetItem *GroupTreeWidget::addCategoryItem(const QString &name, const QIcon &icon, bool expand)
{
QFont font = QFont("ARIAL", 10);

View File

@ -82,6 +82,7 @@ public:
signals:
void treeCustomContextMenuRequested(const QPoint &pos);
void treeCurrentItemChanged(const QString &id);
void treeItemClicked(const QString &id);
protected:
void changeEvent(QEvent *e);
@ -89,6 +90,7 @@ protected:
private slots:
void customContextMenuRequested(const QPoint &pos);
void currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
void itemClicked(QTreeWidgetItem *item, int column);
void filterChanged();
void sort();

View File

@ -1,4 +1,5 @@
#include <QDesktopServices>
#include <QPainter>
#include "LinkTextBrowser.h"
@ -17,3 +18,27 @@ void LinkTextBrowser::linkClicked(const QUrl &url)
// so we handle links by our own
QDesktopServices::openUrl(url);
}
void LinkTextBrowser::setPlaceholderText(const QString &text)
{
placeholderText = text;
viewport()->repaint();
}
void LinkTextBrowser::paintEvent(QPaintEvent *event)
{
QTextBrowser::paintEvent(event);
if (placeholderText.isEmpty() == false && document()->isEmpty()) {
QWidget *vieportWidget = viewport();
QPainter painter(vieportWidget);
QPen pen = painter.pen();
QColor color = pen.color();
color.setAlpha(128);
pen.setColor(color);
painter.setPen(pen);
painter.drawText(QRect(QPoint(), vieportWidget->size()), Qt::AlignHCenter | Qt::AlignVCenter | Qt::TextWordWrap, placeholderText);
}
}

View File

@ -10,8 +10,15 @@ class LinkTextBrowser : public QTextBrowser
public:
explicit LinkTextBrowser(QWidget *parent = 0);
void setPlaceholderText(const QString &text);
private slots:
void linkClicked(const QUrl &url);
protected:
void paintEvent(QPaintEvent *event);
QString placeholderText;
};
#endif // LINKTEXTBROWSER_H

View File

@ -0,0 +1,52 @@
/****************************************************************
* This file is distributed under the following license:
*
* Copyright (c) 2012, 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 <QPainter>
#include "RSTreeWidget.h"
RSTreeWidget::RSTreeWidget(QWidget *parent) : QTreeWidget(parent)
{
}
void RSTreeWidget::setPlaceholderText(const QString &text)
{
placeholderText = text;
viewport()->repaint();
}
void RSTreeWidget::paintEvent(QPaintEvent *event)
{
QTreeWidget::paintEvent(event);
if (placeholderText.isEmpty() == false && model() && model()->rowCount() == 0) {
QWidget *vieportWidget = viewport();
QPainter painter(vieportWidget);
QPen pen = painter.pen();
QColor color = pen.color();
color.setAlpha(128);
pen.setColor(color);
painter.setPen(pen);
painter.drawText(QRect(QPoint(), vieportWidget->size()), Qt::AlignHCenter | Qt::AlignVCenter | Qt::TextWordWrap, placeholderText);
}
}

View File

@ -0,0 +1,43 @@
/****************************************************************
* This file is distributed under the following license:
*
* Copyright (c) 2012, 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 _RSTREEWIDGET_H
#define _RSTREEWIDGET_H
#include <QTreeWidget>
/* Subclassing QTreeWidget */
class RSTreeWidget : public QTreeWidget
{
Q_OBJECT
public:
RSTreeWidget(QWidget *parent = 0);
void setPlaceholderText(const QString &text);
protected:
void paintEvent(QPaintEvent *event);
QString placeholderText;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,191 @@
#ifndef GXSFORUMTHREADWIDGET_H
#define GXSFORUMTHREADWIDGET_H
#include <QWidget>
#include "util/TokenQueue.h"
class QTreeWidgetItem;
class GxsIdTreeWidgetItem;
class RSTreeWidgetItemCompareRole;
class RsGxsForumMsg;
namespace Ui {
class GxsForumThreadWidget;
}
/* These are all the parameters that are required for thread loading.
* They are kept static for the load duration.
*/
class GxsForumsThreadLoadParameters
{
public:
std::string ForumId;
std::string FocusMsgId;
uint32_t SubscribeFlags;
int ViewType;
uint32_t FilterColumn;
std::map<uint32_t, QTreeWidgetItem *> MsgTokens;
QList<QTreeWidgetItem*> Items;
QList<QTreeWidgetItem*> ItemToExpand;
bool FillComplete;
bool FlatView;
bool UseChildTS;
bool ExpandNewMessages;
};
class GxsForumThreadWidget : public QWidget, public TokenResponse
{
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:
explicit GxsForumThreadWidget(const std::string &forumId, QWidget *parent = NULL);
~GxsForumThreadWidget();
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; }
std::string forumId() { return mForumId; }
QString forumName();
// Callback for all Loads.
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
signals:
void forumChanged(QWidget *widget);
protected:
bool eventFilter(QObject *obj, QEvent *ev);
void changeEvent(QEvent *e);
private slots:
/** Create the context popup menu and it's submenus */
void threadListCustomPopupMenu(QPoint point);
void changedThread();
void clickedThread (QTreeWidgetItem *item, int column);
void replytomessage();
void replyMessageData(const RsGxsForumMsg &msg);
//void print();
//void printpreview();
//void removemessage();
void markMsgAsRead();
void markMsgAsReadChildren();
void markMsgAsReadAll();
void markMsgAsUnread();
void markMsgAsUnreadAll();
void markMsgAsUnreadChildren();
void copyMessageLink();
/* handle splitter */
void togglethreadview();
void createthread();
void createmessage();
void previousMessage();
void nextMessage();
void nextUnreadMessage();
void downloadAllFiles();
void changedViewBox();
void filterColumnChanged(int column);
void filterItems(const QString &text);
void fillThreadFinished();
// void fillThreadProgress(int current, int count);
private:
void insertForumThreads(const RsGroupMetaData &fi);
void insertPostData(const RsGxsForumMsg &msg); // Second Half.
void insertThreads();
void insertPost();
// void forumMsgReadStatusChanged(const QString &forumId, const QString &msgId, int status);
void fillThreads(QList<QTreeWidgetItem *> &threadList, bool expandNewMessages, QList<QTreeWidgetItem*> &itemToExpand);
void fillChildren(QTreeWidgetItem *parentItem, QTreeWidgetItem *newParentItem, bool expandNewMessages, QList<QTreeWidgetItem*> &itemToExpand);
int getSelectedMsgCount(QList<QTreeWidgetItem*> *pRows, QList<QTreeWidgetItem*> *pRowsRead, QList<QTreeWidgetItem*> *pRowsUnread);
void setMsgReadStatus(QList<QTreeWidgetItem*> &rows, bool read);
void markMsgAsReadUnread(bool read, bool children, bool forum);
void calculateIconsAndFonts(QTreeWidgetItem *item = NULL);
void calculateIconsAndFonts(QTreeWidgetItem *item, bool &hasReadChilddren, bool &hasUnreadChilddren);
void togglethreadview_internal();
bool filterItem(QTreeWidgetItem *item, const QString &text, int filterColumn);
void processSettings(bool bLoad);
std::string mForumId;
std::string mLastForumID;
std::string mThreadId;
int mSubscribeFlags;
bool mInProcessSettings;
bool mInMsgAsReadUnread;
int mLastViewType;
RSTreeWidgetItemCompareRole *mThreadCompareRole;
TokenQueue *mThreadQueue;
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 RsGxsForumMsg &msg);
void requestChildData_InsertThreads(uint32_t &token, const RsGxsGrpMsgIdPair &parentId);
void loadChildData_InsertThreads(const uint32_t &token);
void loadForumChildMsg(const RsGxsForumMsg &msg, QTreeWidgetItem *parent);
void requestMsgData_InsertPost(const RsGxsGrpMsgIdPair &msgId);
void loadMsgData_InsertPost(const uint32_t &token);
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);
// New Datatypes to replace the FillThread.
bool mThreadLoading;
GxsForumsThreadLoadParameters mThreadLoad;
/* Color definitions (for standard see qss.default) */
QColor mTextColorRead;
QColor mTextColorUnread;
QColor mTextColorUnreadChildren;
QColor mTextColorNotSubscribed;
QColor mTextColorMissing;
Ui::GxsForumThreadWidget *ui;
};
#endif // GXSFORUMTHREADWIDGET_H

View File

@ -0,0 +1,511 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GxsForumThreadWidget</class>
<widget class="QWidget" name="GxsForumThreadWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>622</width>
<height>412</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QSplitter" name="threadSplitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QFrame" name="toolBarFrame">
<property name="minimumSize">
<size>
<width>0</width>
<height>32</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="margin">
<number>2</number>
</property>
<item>
<widget class="QToolButton" name="newthreadButton">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Start new Thread for Selected Forum</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/mail_new.png</normaloff>:/images/mail_new.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>16</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="LineEditClear" name="filterLineEdit">
<property name="toolTip">
<string>Search forums</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="forumLayout">
<property name="leftMargin">
<number>3</number>
</property>
<item>
<widget class="QLabel" name="forumName">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>1677215</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="viewBox">
<item>
<property name="text">
<string>Last Post</string>
</property>
</item>
<item>
<property name="text">
<string>Threaded View</string>
</property>
</item>
<item>
<property name="text">
<string>Flat View</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="RSTreeWidget" name="threadTreeWidget">
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="allColumnsShowFocus">
<bool>true</bool>
</property>
<column>
<property name="text">
<string>Title</string>
</property>
</column>
<column>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/message-state-header.png</normaloff>:/images/message-state-header.png</iconset>
</property>
</column>
<column>
<property name="text">
<string>Date</string>
</property>
</column>
<column>
<property name="text">
<string>Author</string>
</property>
</column>
<column>
<property name="text">
<string>Signed</string>
</property>
</column>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="progressBarLayOut">
<property name="leftMargin">
<number>3</number>
</property>
<item>
<widget class="QLabel" name="progLayOutTxt">
<property name="font">
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Loading</string>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
<property name="maximum">
<number>1000</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="threadLayout">
<property name="leftMargin">
<number>3</number>
</property>
<item>
<widget class="QLabel" name="threadTitle">
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="postLayout">
<item row="0" column="1">
<widget class="QToolButton" name="newmessageButton">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Reply Message</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/mail_reply.png</normaloff>:/images/mail_reply.png</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="previousButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Previous Thread</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/back.png</normaloff>:/images/back.png</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QPushButton" name="nextButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Next Thread</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/forward.png</normaloff>:/images/forward.png</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QToolButton" name="downloadButton">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Download all files</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/down.png</normaloff>:/images/down.png</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="0" column="7">
<widget class="QLabel" name="time_label">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item row="0" column="9">
<widget class="QLabel" name="by_label">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item row="0" column="10">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="11">
<widget class="QPushButton" name="nextUnreadButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Next unread</string>
</property>
</widget>
</item>
<item row="0" column="13">
<widget class="QPushButton" name="expandButton">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/edit_remove24.png</normaloff>:/images/edit_remove24.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="8">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="LinkTextBrowser" name="postText">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>10</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>LinkTextBrowser</class>
<extends>QTextBrowser</extends>
<header>gui/common/LinkTextBrowser.h</header>
</customwidget>
<customwidget>
<class>LineEditClear</class>
<extends>QLineEdit</extends>
<header location="global">gui/common/LineEditClear.h</header>
</customwidget>
<customwidget>
<class>RSTreeWidget</class>
<extends>QTreeWidget</extends>
<header>gui/common/RSTreeWidget.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>