mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-05 12:54:28 -04:00
Added basic widget RSFeedWidget for showing feed items in a QTreeWidget as replacement for the QScrollArea.
- Use sort of QTreeWidget - Filter items - Open/collapse selected item with +/- - Remove selecteds item with dselete key git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7478 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
e588b25b67
commit
d13aa90b2b
20 changed files with 841 additions and 183 deletions
32
retroshare-gui/src/gui/feeds/FeedItem.cpp
Normal file
32
retroshare-gui/src/gui/feeds/FeedItem.cpp
Normal file
|
@ -0,0 +1,32 @@
|
|||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2014 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 "FeedItem.h"
|
||||
|
||||
/** Constructor */
|
||||
FeedItem::FeedItem(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
}
|
||||
|
||||
FeedItem::~FeedItem()
|
||||
{
|
||||
emit feedItemDestroyed(this);
|
||||
}
|
44
retroshare-gui/src/gui/feeds/FeedItem.h
Normal file
44
retroshare-gui/src/gui/feeds/FeedItem.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2014 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 _FEED_ITEM_H
|
||||
#define _FEED_ITEM_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class FeedItem : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/** Default Constructor */
|
||||
FeedItem(QWidget *parent = 0);
|
||||
/** Default Destructor */
|
||||
virtual ~FeedItem();
|
||||
|
||||
virtual void expand(bool open) = 0;
|
||||
|
||||
signals:
|
||||
void sizeChanged(FeedItem *feedItem);
|
||||
void feedItemDestroyed(FeedItem *feedItem);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -48,8 +48,8 @@
|
|||
#define SELF_LOAD 1
|
||||
#define DATA_PROVIDED 2
|
||||
|
||||
GxsChannelPostItem::GxsChannelPostItem(FeedHolder *parent, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate) :
|
||||
GxsFeedItem(parent, feedId, groupId, messageId, isHome, rsGxsChannels, true, autoUpdate)
|
||||
GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate) :
|
||||
GxsFeedItem(feedHolder, feedId, groupId, messageId, isHome, rsGxsChannels, true, autoUpdate)
|
||||
{
|
||||
mMode = SELF_LOAD;
|
||||
|
||||
|
@ -57,8 +57,8 @@ GxsChannelPostItem::GxsChannelPostItem(FeedHolder *parent, uint32_t feedId, cons
|
|||
}
|
||||
|
||||
/** Constructor */
|
||||
GxsChannelPostItem::GxsChannelPostItem(FeedHolder *parent, uint32_t feedId, const RsGxsChannelPost &post, uint32_t subFlags, bool isHome, bool autoUpdate) :
|
||||
GxsFeedItem(parent, feedId, post.mMeta.mGroupId, post.mMeta.mMsgId, isHome, rsGxsChannels, false, autoUpdate)
|
||||
GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelPost &post, uint32_t subFlags, bool isHome, bool autoUpdate) :
|
||||
GxsFeedItem(feedHolder, feedId, post.mMeta.mGroupId, post.mMeta.mMsgId, isHome, rsGxsChannels, false, autoUpdate)
|
||||
{
|
||||
std::cerr << "GxsChannelPostItem::GxsChannelPostItem() Direct Load";
|
||||
std::cerr << std::endl;
|
||||
|
@ -249,7 +249,7 @@ void GxsChannelPostItem::loadPost(const RsGxsChannelPost &post)
|
|||
}
|
||||
|
||||
// differences between Feed or Top of Comment.
|
||||
if (mParent)
|
||||
if (mFeedHolder)
|
||||
{
|
||||
ui->commentButton->show();
|
||||
|
||||
|
@ -348,7 +348,8 @@ void GxsChannelPostItem::setReadStatus(bool isNew, bool isUnread)
|
|||
ui->frame->style()->unpolish(ui->frame);
|
||||
|
||||
QPalette palette = ui->frame->palette();
|
||||
palette.setColor(ui->frame->backgroundRole(), isNew ? COLOR_NEW : COLOR_NORMAL);
|
||||
palette.setColor(ui->frame->backgroundRole(), isNew ? COLOR_NEW : COLOR_NORMAL); // QScrollArea
|
||||
palette.setColor(QPalette::Base, isNew ? COLOR_NEW : COLOR_NORMAL); // QTreeWidget
|
||||
ui->frame->setPalette(palette);
|
||||
|
||||
ui->frame->setProperty("new", isNew);
|
||||
|
@ -447,14 +448,14 @@ void GxsChannelPostItem::updateItem()
|
|||
//downloadButton->setEnabled(true);
|
||||
}
|
||||
|
||||
void GxsChannelPostItem::toggle()
|
||||
void GxsChannelPostItem::expand(bool open)
|
||||
{
|
||||
if (mParent)
|
||||
if (mFeedHolder)
|
||||
{
|
||||
mParent->lockLayout(this, true);
|
||||
mFeedHolder->lockLayout(this, true);
|
||||
}
|
||||
|
||||
if (ui->expandFrame->isHidden())
|
||||
if (open)
|
||||
{
|
||||
ui->expandFrame->show();
|
||||
ui->expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png")));
|
||||
|
@ -469,12 +470,19 @@ void GxsChannelPostItem::toggle()
|
|||
ui->expandButton->setToolTip(tr("Expand"));
|
||||
}
|
||||
|
||||
if (mParent)
|
||||
emit sizeChanged(this);
|
||||
|
||||
if (mFeedHolder)
|
||||
{
|
||||
mParent->lockLayout(this, false);
|
||||
mFeedHolder->lockLayout(this, false);
|
||||
}
|
||||
}
|
||||
|
||||
void GxsChannelPostItem::toggle()
|
||||
{
|
||||
expand(ui->expandFrame->isHidden());
|
||||
}
|
||||
|
||||
/*********** SPECIFIC FUNCTIONS ***********************/
|
||||
|
||||
void GxsChannelPostItem::readAndClearItem()
|
||||
|
|
|
@ -44,8 +44,8 @@ class GxsChannelPostItem : public GxsFeedItem
|
|||
|
||||
public:
|
||||
/** Default Constructor */
|
||||
GxsChannelPostItem(FeedHolder *parent, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate);
|
||||
GxsChannelPostItem(FeedHolder *parent, uint32_t feedId, const RsGxsChannelPost &post, uint32_t subscribeFlags, bool isHome, bool autoUpdate);
|
||||
GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome, bool autoUpdate);
|
||||
GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelPost &post, uint32_t subscribeFlags, bool isHome, bool autoUpdate);
|
||||
virtual ~GxsChannelPostItem();
|
||||
|
||||
virtual void setContent(const QVariant &content);
|
||||
|
@ -57,6 +57,9 @@ public:
|
|||
const QString getMsgLabel() {return RsHtml().formatText(NULL, QString::fromUtf8(mPost.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS); }
|
||||
const std::list<SubFileItem *> &getFileItems() {return mFileItems; }
|
||||
|
||||
/* FeedItem */
|
||||
virtual void expand(bool open);
|
||||
|
||||
protected:
|
||||
virtual void loadMessage(const uint32_t &token);
|
||||
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_CHANNEL; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue