mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-07 22:02:32 -04:00
Added a standard tab to GxsForums and FeedReader.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6055 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
999d9c3920
commit
35cc460e71
12 changed files with 252 additions and 58 deletions
|
@ -72,8 +72,9 @@ GxsForumsDialog::GxsForumsDialog(QWidget *parent)
|
|||
|
||||
connect(ui.forumTreeWidget, SIGNAL(treeCustomContextMenuRequested(QPoint)), this, SLOT(forumListCustomPopupMenu(QPoint)));
|
||||
connect(ui.newForumButton, SIGNAL(clicked()), this, SLOT(newforum()));
|
||||
connect(ui.forumTreeWidget, SIGNAL(treeItemClicked(QString)), this, SLOT(changedForum(QString)));
|
||||
connect(ui.forumTreeWidget, SIGNAL(treeItemActivated(QString)), this, SLOT(changedForum(QString)));
|
||||
connect(ui.threadTabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(threadTabCloseRequested(int)));
|
||||
connect(ui.threadTabWidget, SIGNAL(currentChanged(int)), this, SLOT(threadTabChanged(int)));
|
||||
connect(NotifyQt::getInstance(), SIGNAL(forumMsgReadSatusChanged(QString,QString,int)), this, SLOT(forumMsgReadSatusChanged(QString,QString,int)));
|
||||
|
||||
// HACK - TEMPORARY HIJACKING THIS BUTTON FOR REFRESH.
|
||||
|
@ -96,6 +97,10 @@ GxsForumsDialog::GxsForumsDialog(QWidget *parent)
|
|||
// load settings
|
||||
processSettings(true);
|
||||
|
||||
mThreadWidget = createThreadWidget("");
|
||||
// remove close button of the the first tab
|
||||
ui.threadTabWidget->hideCloseButton(ui.threadTabWidget->indexOf(mThreadWidget));
|
||||
|
||||
/* Hide platform specific features */
|
||||
#ifdef Q_WS_WIN
|
||||
|
||||
|
@ -148,6 +153,11 @@ void GxsForumsDialog::forumListCustomPopupMenu(QPoint /*point*/)
|
|||
action = contextMnu.addAction(QIcon(IMAGE_UNSUBSCRIBE), tr("Unsubscribe to Forum"), this, SLOT(unsubscribeToForum()));
|
||||
action->setEnabled (!mForumId.empty() && IS_GROUP_SUBSCRIBED(subscribeFlags));
|
||||
|
||||
action = contextMnu.addAction(QIcon(""), tr("Open in new tab"), this, SLOT(openInNewTab()));
|
||||
if (mForumId.empty() || forumThreadWidget(mForumId)) {
|
||||
action->setEnabled(false);
|
||||
}
|
||||
|
||||
contextMnu.addSeparator();
|
||||
|
||||
contextMnu.addAction(QIcon(IMAGE_NEWFORUM), tr("New Forum"), this, SLOT(newforum()));
|
||||
|
@ -320,12 +330,15 @@ void GxsForumsDialog::insertForumsData(const std::list<RsGroupMetaData> &forumLi
|
|||
updateMessageSummaryList("");
|
||||
}
|
||||
|
||||
GxsForumThreadWidget *GxsForumsDialog::forumThreadWidget(const std::string &id)
|
||||
GxsForumThreadWidget *GxsForumsDialog::forumThreadWidget(const std::string &forumId)
|
||||
{
|
||||
int tabCount = ui.threadTabWidget->count();
|
||||
for (int index = 0; index < tabCount; ++index) {
|
||||
GxsForumThreadWidget *childWidget = dynamic_cast<GxsForumThreadWidget*>(ui.threadTabWidget->widget(index));
|
||||
if (childWidget && childWidget->forumId() == id) {
|
||||
if (childWidget == mThreadWidget) {
|
||||
continue;
|
||||
}
|
||||
if (childWidget && childWidget->forumId() == forumId) {
|
||||
return childWidget;
|
||||
break;
|
||||
}
|
||||
|
@ -334,9 +347,19 @@ GxsForumThreadWidget *GxsForumsDialog::forumThreadWidget(const std::string &id)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void GxsForumsDialog::changedForum(const QString &id)
|
||||
GxsForumThreadWidget *GxsForumsDialog::createThreadWidget(const std::string &forumId)
|
||||
{
|
||||
mForumId = id.toStdString();
|
||||
GxsForumThreadWidget *threadWidget = new GxsForumThreadWidget(forumId);
|
||||
int index = ui.threadTabWidget->addTab(threadWidget, threadWidget->forumName(true));
|
||||
ui.threadTabWidget->setTabIcon(index, threadWidget->forumIcon());
|
||||
connect(threadWidget, SIGNAL(forumChanged(QWidget*)), this, SLOT(threadTabInfoChanged(QWidget*)));
|
||||
|
||||
return threadWidget;
|
||||
}
|
||||
|
||||
void GxsForumsDialog::changedForum(const QString &forumId)
|
||||
{
|
||||
mForumId = forumId.toStdString();
|
||||
if (mForumId.empty()) {
|
||||
return;
|
||||
}
|
||||
|
@ -344,14 +367,28 @@ void GxsForumsDialog::changedForum(const QString &id)
|
|||
// requestGroupSummary_CurrentForum(mForumId);
|
||||
|
||||
/* search exisiting tab */
|
||||
GxsForumThreadWidget *threadWidget = forumThreadWidget(id.toStdString());
|
||||
GxsForumThreadWidget *threadWidget = forumThreadWidget(mForumId);
|
||||
|
||||
if (!threadWidget) {
|
||||
/* create a thread widget */
|
||||
threadWidget = new GxsForumThreadWidget(id.toStdString());
|
||||
int index = ui.threadTabWidget->addTab(threadWidget, threadWidget->forumName(true));
|
||||
ui.threadTabWidget->setTabIcon(index, threadWidget->forumIcon());
|
||||
connect(threadWidget, SIGNAL(forumChanged(QWidget*)), this, SLOT(threadTabChanged(QWidget*)));
|
||||
/* not found, use standard tab */
|
||||
threadWidget = mThreadWidget;
|
||||
threadWidget->setForumId(mForumId);
|
||||
}
|
||||
|
||||
ui.threadTabWidget->setCurrentWidget(threadWidget);
|
||||
}
|
||||
|
||||
void GxsForumsDialog::openInNewTab()
|
||||
{
|
||||
if (mForumId.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* search exisiting tab */
|
||||
GxsForumThreadWidget *threadWidget = forumThreadWidget(mForumId);
|
||||
if (!threadWidget) {
|
||||
/* not found, create new tab */
|
||||
threadWidget = createThreadWidget(mForumId);
|
||||
}
|
||||
|
||||
ui.threadTabWidget->setCurrentWidget(threadWidget);
|
||||
|
@ -360,12 +397,28 @@ void GxsForumsDialog::changedForum(const QString &id)
|
|||
void GxsForumsDialog::threadTabCloseRequested(int index)
|
||||
{
|
||||
GxsForumThreadWidget *threadWidget = dynamic_cast<GxsForumThreadWidget*>(ui.threadTabWidget->widget(index));
|
||||
if (threadWidget) {
|
||||
delete(threadWidget);
|
||||
if (!threadWidget) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (threadWidget == mThreadWidget) {
|
||||
return;
|
||||
}
|
||||
|
||||
delete(threadWidget);
|
||||
}
|
||||
|
||||
void GxsForumsDialog::threadTabChanged(QWidget *widget)
|
||||
void GxsForumsDialog::threadTabChanged(int index)
|
||||
{
|
||||
GxsForumThreadWidget *threadWidget = dynamic_cast<GxsForumThreadWidget*>(ui.threadTabWidget->widget(index));
|
||||
if (!threadWidget) {
|
||||
return;
|
||||
}
|
||||
|
||||
ui.forumTreeWidget->activateId(QString::fromStdString(threadWidget->forumId()), false);
|
||||
}
|
||||
|
||||
void GxsForumsDialog::threadTabInfoChanged(QWidget *widget)
|
||||
{
|
||||
int index = ui.threadTabWidget->indexOf(widget);
|
||||
if (index < 0) {
|
||||
|
|
|
@ -65,9 +65,11 @@ private slots:
|
|||
void restoreForumKeys();
|
||||
void newforum();
|
||||
|
||||
void changedForum(const QString &id);
|
||||
void changedForum(const QString &forumId);
|
||||
void openInNewTab();
|
||||
void threadTabCloseRequested(int index);
|
||||
void threadTabChanged(QWidget *widget);
|
||||
void threadTabChanged(int index);
|
||||
void threadTabInfoChanged(QWidget *widget);
|
||||
|
||||
void copyForumLink();
|
||||
|
||||
|
@ -101,13 +103,15 @@ private:
|
|||
void requestGroupSummary();
|
||||
void loadGroupSummary(const uint32_t &token);
|
||||
|
||||
GxsForumThreadWidget *forumThreadWidget(const std::string &id);
|
||||
GxsForumThreadWidget *forumThreadWidget(const std::string &forumId);
|
||||
GxsForumThreadWidget *createThreadWidget(const std::string &forumId);
|
||||
|
||||
// void requestGroupSummary_CurrentForum(const std::string &forumId);
|
||||
// void loadGroupSummary_CurrentForum(const uint32_t &token);
|
||||
|
||||
std::string mForumId;
|
||||
TokenQueue *mForumQueue;
|
||||
GxsForumThreadWidget *mThreadWidget;
|
||||
|
||||
QTreeWidgetItem *yourForums;
|
||||
QTreeWidgetItem *subscribedForums;
|
||||
|
|
|
@ -168,7 +168,7 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QTabWidget" name="threadTabWidget">
|
||||
<widget class="RSTabWidget" name="threadTabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
|
@ -194,6 +194,12 @@
|
|||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>RSTabWidget</class>
|
||||
<extends>QTabWidget</extends>
|
||||
<header>gui/common/RSTabWidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>GroupTreeWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
|
|
|
@ -70,7 +70,11 @@ 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)));
|
||||
connect(ui->treeWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)), this, SLOT(itemActivated(QTreeWidgetItem*,int)));
|
||||
if (!style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, NULL, this)) {
|
||||
// need signal itemClicked too
|
||||
connect(ui->treeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(itemActivated(QTreeWidgetItem*,int)));
|
||||
}
|
||||
|
||||
/* Add own item delegate */
|
||||
RSItemDelegate *itemDelegate = new RSItemDelegate(this);
|
||||
|
@ -234,7 +238,7 @@ void GroupTreeWidget::currentItemChanged(QTreeWidgetItem *current, QTreeWidgetIt
|
|||
emit treeCurrentItemChanged(id);
|
||||
}
|
||||
|
||||
void GroupTreeWidget::itemClicked(QTreeWidgetItem *item, int column)
|
||||
void GroupTreeWidget::itemActivated(QTreeWidgetItem *item, int column)
|
||||
{
|
||||
Q_UNUSED(column);
|
||||
|
||||
|
@ -244,7 +248,7 @@ void GroupTreeWidget::itemClicked(QTreeWidgetItem *item, int column)
|
|||
id = item->data(COLUMN_DATA, ROLE_ID).toString();
|
||||
}
|
||||
|
||||
emit treeItemClicked(id);
|
||||
emit treeItemActivated(id);
|
||||
}
|
||||
|
||||
QTreeWidgetItem *GroupTreeWidget::addCategoryItem(const QString &name, const QIcon &icon, bool expand)
|
||||
|
|
|
@ -100,7 +100,7 @@ public:
|
|||
signals:
|
||||
void treeCustomContextMenuRequested(const QPoint &pos);
|
||||
void treeCurrentItemChanged(const QString &id);
|
||||
void treeItemClicked(const QString &id);
|
||||
void treeItemActivated(const QString &id);
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
@ -108,7 +108,7 @@ protected:
|
|||
private slots:
|
||||
void customContextMenuRequested(const QPoint &pos);
|
||||
void currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||
void itemClicked(QTreeWidgetItem *item, int column);
|
||||
void itemActivated(QTreeWidgetItem *item, int column);
|
||||
void filterChanged();
|
||||
|
||||
void sort();
|
||||
|
|
|
@ -90,7 +90,6 @@ GxsForumThreadWidget::GxsForumThreadWidget(const std::string &forumId, QWidget *
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
mForumId = forumId;
|
||||
mSubscribeFlags = 0;
|
||||
mInProcessSettings = false;
|
||||
mUnreadCount = 0;
|
||||
|
@ -172,8 +171,7 @@ GxsForumThreadWidget::GxsForumThreadWidget(const std::string &forumId, QWidget *
|
|||
|
||||
mFillThread = NULL;
|
||||
|
||||
ui->forumName->setText(tr("Loading"));
|
||||
insertThreads();
|
||||
setForumId(forumId);
|
||||
|
||||
ui->threadTreeWidget->installEventFilter(this);
|
||||
}
|
||||
|
@ -234,9 +232,27 @@ void GxsForumThreadWidget::processSettings(bool load)
|
|||
mInProcessSettings = false;
|
||||
}
|
||||
|
||||
void GxsForumThreadWidget::setForumId(const std::string &forumId)
|
||||
{
|
||||
if (mForumId == forumId) {
|
||||
if (!forumId.empty()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
mForumId = forumId;
|
||||
ui->forumName->setText(mForumId.empty () ? "" : tr("Loading"));
|
||||
mNewCount = 0;
|
||||
mUnreadCount = 0;
|
||||
|
||||
emit forumChanged(this);
|
||||
|
||||
insertThreads();
|
||||
}
|
||||
|
||||
QString GxsForumThreadWidget::forumName(bool withUnreadCount)
|
||||
{
|
||||
QString name = ui->forumName->text();
|
||||
QString name = mForumId.empty () ? tr("No name") : ui->forumName->text();
|
||||
|
||||
if (withUnreadCount && mUnreadCount) {
|
||||
name += QString(" (%1)").arg(mUnreadCount);
|
||||
|
|
|
@ -41,6 +41,7 @@ public:
|
|||
void setTextColorMissing(QColor color) { mTextColorMissing = color; }
|
||||
|
||||
std::string forumId() { return mForumId; }
|
||||
void setForumId(const std::string &forumId);
|
||||
QString forumName(bool withUnreadCount);
|
||||
QIcon forumIcon();
|
||||
unsigned int newCount() { return mNewCount; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue