mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 07:29:33 -05:00
Replaced scroll area in NewsFeed with RSFeedWidget.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7680 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
dcabaf780d
commit
dee39a8840
@ -20,8 +20,10 @@
|
||||
****************************************************************/
|
||||
|
||||
#include <QTimer>
|
||||
#include <QDateTime>
|
||||
|
||||
#include "NewsFeed.h"
|
||||
#include "ui_NewsFeed.h"
|
||||
|
||||
#include <retroshare/rsnotify.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
@ -51,6 +53,7 @@
|
||||
#include "chat/ChatDialog.h"
|
||||
#include "msgs/MessageComposer.h"
|
||||
#include "common/FeedNotify.h"
|
||||
#include "notifyqt.h"
|
||||
|
||||
const uint32_t NEWSFEED_PEERLIST = 0x0001;
|
||||
|
||||
@ -67,6 +70,8 @@ const uint32_t NEWSFEED_MESSAGELIST = 0x0008;
|
||||
const uint32_t NEWSFEED_CHATMSGLIST = 0x0009;
|
||||
const uint32_t NEWSFEED_SECLIST = 0x000a;
|
||||
|
||||
#define ROLE_RECEIVED FEED_TREEWIDGET_SORTROLE
|
||||
|
||||
/*****
|
||||
* #define NEWS_DEBUG 1
|
||||
****/
|
||||
@ -74,11 +79,12 @@ const uint32_t NEWSFEED_SECLIST = 0x000a;
|
||||
static NewsFeed *instance = NULL;
|
||||
|
||||
/** Constructor */
|
||||
NewsFeed::NewsFeed(QWidget *parent)
|
||||
: RsAutoUpdatePage(1000,parent)
|
||||
NewsFeed::NewsFeed(QWidget *parent) :
|
||||
RsAutoUpdatePage(1000,parent),
|
||||
ui(new Ui::NewsFeed)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
setupUi(this);
|
||||
ui->setupUi(this);
|
||||
|
||||
setUpdateWhenInvisible(true);
|
||||
|
||||
@ -86,8 +92,12 @@ NewsFeed::NewsFeed(QWidget *parent)
|
||||
instance = this;
|
||||
}
|
||||
|
||||
connect(removeAllButton, SIGNAL(clicked()), this, SLOT(removeAll()));
|
||||
connect(feedOptionsButton, SIGNAL(clicked()), this, SLOT(feedoptions()));
|
||||
ui->feedWidget->enableRemove(true);
|
||||
|
||||
connect(ui->removeAllButton, SIGNAL(clicked()), ui->feedWidget, SLOT(clear()));
|
||||
connect(ui->feedOptionsButton, SIGNAL(clicked()), this, SLOT(feedoptions()));
|
||||
connect(ui->feedWidget, SIGNAL(feedCountChanged()), this, SLOT(sendNewsFeedChanged()));
|
||||
connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged()));
|
||||
|
||||
QString hlp_str = tr(
|
||||
" <h1><img width=\"32\" src=\":/images/64px_help.png\"> News Feed</h1> \
|
||||
@ -103,7 +113,9 @@ QString hlp_str = tr(
|
||||
</ul> </p> \
|
||||
") ;
|
||||
|
||||
registerHelpButton(helpButton,hlp_str) ;
|
||||
registerHelpButton(ui->helpButton,hlp_str) ;
|
||||
|
||||
settingsChanged();
|
||||
}
|
||||
|
||||
NewsFeed::~NewsFeed()
|
||||
@ -118,6 +130,11 @@ UserNotify *NewsFeed::getUserNotify(QObject *parent)
|
||||
return new NewsFeedUserNotify(this, parent);
|
||||
}
|
||||
|
||||
void NewsFeed::settingsChanged()
|
||||
{
|
||||
ui->feedWidget->setSortRole(ROLE_RECEIVED, Settings->getAddFeedsAtEnd() ? Qt::AscendingOrder : Qt::DescendingOrder);
|
||||
}
|
||||
|
||||
void NewsFeed::updateDisplay()
|
||||
{
|
||||
if (!rsNotify)
|
||||
@ -235,7 +252,7 @@ void NewsFeed::updateDisplay()
|
||||
if (rsPlugin) {
|
||||
FeedNotify *feedNotify = rsPlugin->qt_feedNotify();
|
||||
if (feedNotify && feedNotify->notifyEnabled()) {
|
||||
QWidget *item = feedNotify->feedItem(this);
|
||||
FeedItem *item = feedNotify->feedItem(this);
|
||||
if (item) {
|
||||
addFeedItem(item);
|
||||
break;
|
||||
@ -252,6 +269,8 @@ void NewsFeed::testFeeds(uint notifyFlags)
|
||||
return;
|
||||
}
|
||||
|
||||
instance->ui->feedWidget->enableCountChangedSignal(false);
|
||||
|
||||
uint pos = 0;
|
||||
|
||||
while (notifyFlags) {
|
||||
@ -439,6 +458,10 @@ void NewsFeed::testFeeds(uint notifyFlags)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
instance->ui->feedWidget->enableCountChangedSignal(true);
|
||||
|
||||
instance->sendNewsFeedChanged();
|
||||
}
|
||||
|
||||
void NewsFeed::testFeed(FeedNotify *feedNotify)
|
||||
@ -451,7 +474,7 @@ void NewsFeed::testFeed(FeedNotify *feedNotify)
|
||||
return;
|
||||
}
|
||||
|
||||
QWidget *feedItem = feedNotify->testFeedItem(instance);
|
||||
FeedItem *feedItem = feedNotify->testFeedItem(instance);
|
||||
if (!feedItem) {
|
||||
return;
|
||||
}
|
||||
@ -459,62 +482,73 @@ void NewsFeed::testFeed(FeedNotify *feedNotify)
|
||||
instance->addFeedItem(feedItem);
|
||||
}
|
||||
|
||||
void NewsFeed::addFeedItem(QWidget *item)
|
||||
void NewsFeed::addFeedItem(FeedItem *item)
|
||||
{
|
||||
static const unsigned int MAX_WIDGETS_SIZE = 500 ;
|
||||
static const unsigned int MAX_FEEDITEM_COUNT = 500 ;
|
||||
|
||||
item->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
|
||||
connect(item, SIGNAL(destroyed(QObject*)), this, SLOT(itemDestroyed(QObject*)));
|
||||
widgets.push_back(item);
|
||||
|
||||
// costly, but not really a problem here
|
||||
while(widgets.size() > MAX_WIDGETS_SIZE)
|
||||
{
|
||||
QWidget *item = dynamic_cast<QWidget*>(widgets.front()) ;
|
||||
|
||||
if(item)
|
||||
item->close() ;
|
||||
widgets.pop_front() ;
|
||||
int feedItemCount;
|
||||
bool fromTop = Settings->getAddFeedsAtEnd();
|
||||
|
||||
while ((feedItemCount = ui->feedWidget->feedItemCount()) >= MAX_FEEDITEM_COUNT) {
|
||||
FeedItem *feedItem = ui->feedWidget->feedItem(fromTop ? 0 : feedItemCount - 1);
|
||||
if (!feedItem) {
|
||||
break;
|
||||
}
|
||||
|
||||
ui->feedWidget->removeFeedItem(feedItem);
|
||||
}
|
||||
|
||||
sendNewsFeedChanged();
|
||||
|
||||
lockLayout(NULL, true);
|
||||
|
||||
if (Settings->getAddFeedsAtEnd()) {
|
||||
itemsLayout->addWidget(item);
|
||||
} else {
|
||||
itemsLayout->insertWidget(0, item);
|
||||
}
|
||||
item->show();
|
||||
|
||||
lockLayout(item, false);
|
||||
ui->feedWidget->addFeedItem(item, ROLE_RECEIVED, QDateTime::currentDateTime());
|
||||
}
|
||||
|
||||
void NewsFeed::addFeedItemIfUnique(QWidget *item, int itemType, const RsPeerId &sslId, bool replace)
|
||||
struct AddFeedItemIfUniqueData
|
||||
{
|
||||
foreach (QObject *itemObject, widgets) {
|
||||
SecurityItem *secitem = dynamic_cast<SecurityItem*>(itemObject);
|
||||
if ((secitem) && (secitem->isSame(sslId, itemType)))
|
||||
{
|
||||
if (!replace)
|
||||
{
|
||||
delete item;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
secitem->close();
|
||||
break;
|
||||
}
|
||||
AddFeedItemIfUniqueData(int type, const RsPeerId &sslId) : mType(type), mSslId(sslId) {}
|
||||
|
||||
int mType;
|
||||
const RsPeerId &mSslId;
|
||||
};
|
||||
|
||||
static bool addFeedItemIfUniqueCallback(FeedItem *feedItem, void *data)
|
||||
{
|
||||
AddFeedItemIfUniqueData *findData = (AddFeedItemIfUniqueData*) data;
|
||||
if (!findData || findData->mSslId.isNull()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SecurityItem *secitem = dynamic_cast<SecurityItem*>(feedItem);
|
||||
if (!secitem) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (secitem->isSame(findData->mSslId, findData->mType)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void NewsFeed::addFeedItemIfUnique(FeedItem *item, int itemType, const RsPeerId &sslId, bool replace)
|
||||
{
|
||||
AddFeedItemIfUniqueData data(itemType, sslId);
|
||||
FeedItem *feedItem = ui->feedWidget->findFeedItem(addFeedItemIfUniqueCallback, &data);
|
||||
|
||||
if (feedItem) {
|
||||
if (!replace) {
|
||||
delete item;
|
||||
return;
|
||||
}
|
||||
|
||||
ui->feedWidget->removeFeedItem(item);
|
||||
}
|
||||
|
||||
addFeedItem(item);
|
||||
}
|
||||
|
||||
void NewsFeed::addFeedItemPeerConnect(RsFeedItem &fi)
|
||||
void NewsFeed::addFeedItemPeerConnect(const RsFeedItem &fi)
|
||||
{
|
||||
/* make new widget */
|
||||
PeerItem *pi = new PeerItem(this, NEWSFEED_PEERLIST, RsPeerId(fi.mId1), PEER_TYPE_CONNECT, false);
|
||||
@ -526,10 +560,9 @@ void NewsFeed::addFeedItemPeerConnect(RsFeedItem &fi)
|
||||
std::cerr << "NewsFeed::addFeedItemPeerConnect()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void NewsFeed::addFeedItemPeerDisconnect(RsFeedItem &fi)
|
||||
void NewsFeed::addFeedItemPeerDisconnect(const RsFeedItem &fi)
|
||||
{
|
||||
/* make new widget */
|
||||
PeerItem *pi = new PeerItem(this, NEWSFEED_PEERLIST, RsPeerId(fi.mId1), PEER_TYPE_STD, false);
|
||||
@ -543,7 +576,7 @@ void NewsFeed::addFeedItemPeerDisconnect(RsFeedItem &fi)
|
||||
#endif
|
||||
}
|
||||
|
||||
void NewsFeed::addFeedItemPeerHello(RsFeedItem &fi)
|
||||
void NewsFeed::addFeedItemPeerHello(const RsFeedItem &fi)
|
||||
{
|
||||
/* make new widget */
|
||||
PeerItem *pi = new PeerItem(this, NEWSFEED_PEERLIST, RsPeerId(fi.mId1), PEER_TYPE_HELLO, false);
|
||||
@ -557,7 +590,7 @@ void NewsFeed::addFeedItemPeerHello(RsFeedItem &fi)
|
||||
#endif
|
||||
}
|
||||
|
||||
void NewsFeed::addFeedItemPeerNew(RsFeedItem &fi)
|
||||
void NewsFeed::addFeedItemPeerNew(const RsFeedItem &fi)
|
||||
{
|
||||
/* make new widget */
|
||||
PeerItem *pi = new PeerItem(this, NEWSFEED_PEERLIST, RsPeerId(fi.mId1), PEER_TYPE_NEW_FOF, false);
|
||||
@ -571,7 +604,7 @@ void NewsFeed::addFeedItemPeerNew(RsFeedItem &fi)
|
||||
#endif
|
||||
}
|
||||
|
||||
void NewsFeed::addFeedItemSecurityConnectAttempt(RsFeedItem &fi)
|
||||
void NewsFeed::addFeedItemSecurityConnectAttempt(const RsFeedItem &fi)
|
||||
{
|
||||
/* make new widget */
|
||||
SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, RsPgpId(fi.mId1), RsPeerId(fi.mId2), fi.mId3, fi.mId4, fi.mType, false);
|
||||
@ -585,7 +618,7 @@ void NewsFeed::addFeedItemSecurityConnectAttempt(RsFeedItem &fi)
|
||||
#endif
|
||||
}
|
||||
|
||||
void NewsFeed::addFeedItemSecurityAuthDenied(RsFeedItem &fi)
|
||||
void NewsFeed::addFeedItemSecurityAuthDenied(const RsFeedItem &fi)
|
||||
{
|
||||
/* make new widget */
|
||||
SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, RsPgpId(fi.mId1), RsPeerId(fi.mId2), fi.mId3, fi.mId4, fi.mType, false);
|
||||
@ -599,7 +632,7 @@ void NewsFeed::addFeedItemSecurityAuthDenied(RsFeedItem &fi)
|
||||
#endif
|
||||
}
|
||||
|
||||
void NewsFeed::addFeedItemSecurityUnknownIn(RsFeedItem &fi)
|
||||
void NewsFeed::addFeedItemSecurityUnknownIn(const RsFeedItem &fi)
|
||||
{
|
||||
/* make new widget */
|
||||
SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, RsPgpId(fi.mId1), RsPeerId(fi.mId2), fi.mId3, fi.mId4, RS_FEED_ITEM_SEC_UNKNOWN_IN, false);
|
||||
@ -613,7 +646,7 @@ void NewsFeed::addFeedItemSecurityUnknownIn(RsFeedItem &fi)
|
||||
#endif
|
||||
}
|
||||
|
||||
void NewsFeed::addFeedItemSecurityUnknownOut(RsFeedItem &fi)
|
||||
void NewsFeed::addFeedItemSecurityUnknownOut(const RsFeedItem &fi)
|
||||
{
|
||||
/* make new widget */
|
||||
SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, RsPgpId(fi.mId1), RsPeerId(fi.mId2), fi.mId3, fi.mId4, RS_FEED_ITEM_SEC_UNKNOWN_OUT, false);
|
||||
@ -627,7 +660,7 @@ void NewsFeed::addFeedItemSecurityUnknownOut(RsFeedItem &fi)
|
||||
#endif
|
||||
}
|
||||
|
||||
void NewsFeed::addFeedItemChannelNew(RsFeedItem &fi)
|
||||
void NewsFeed::addFeedItemChannelNew(const RsFeedItem &fi)
|
||||
{
|
||||
/* make new widget */
|
||||
// ChanNewItem *cni = new ChanNewItem(this, NEWSFEED_CHANNEWLIST, fi.mId1, false, true);
|
||||
@ -641,7 +674,7 @@ void NewsFeed::addFeedItemChannelNew(RsFeedItem &fi)
|
||||
#endif
|
||||
}
|
||||
|
||||
//void NewsFeed::addFeedItemChannelUpdate(RsFeedItem &fi)
|
||||
//void NewsFeed::addFeedItemChannelUpdate(const RsFeedItem &fi)
|
||||
//{
|
||||
// /* make new widget */
|
||||
// ChanNewItem *cni = new ChanNewItem(this, NEWSFEED_CHANNEWLIST, fi.mId1, false, false);
|
||||
@ -655,7 +688,7 @@ void NewsFeed::addFeedItemChannelNew(RsFeedItem &fi)
|
||||
//#endif
|
||||
//}
|
||||
|
||||
void NewsFeed::addFeedItemChannelMsg(RsFeedItem &fi)
|
||||
void NewsFeed::addFeedItemChannelMsg(const RsFeedItem &fi)
|
||||
{
|
||||
RsGxsGroupId grpId(fi.mId1);
|
||||
RsGxsMessageId msgId(fi.mId2);
|
||||
@ -676,7 +709,7 @@ void NewsFeed::addFeedItemChannelMsg(RsFeedItem &fi)
|
||||
#endif
|
||||
}
|
||||
|
||||
void NewsFeed::addFeedItemForumNew(RsFeedItem &fi)
|
||||
void NewsFeed::addFeedItemForumNew(const RsFeedItem &fi)
|
||||
{
|
||||
/* make new widget */
|
||||
// ForumNewItem *fni = new ForumNewItem(this, NEWSFEED_FORUMNEWLIST, fi.mId1, false, true);
|
||||
@ -690,7 +723,7 @@ void NewsFeed::addFeedItemForumNew(RsFeedItem &fi)
|
||||
#endif
|
||||
}
|
||||
|
||||
//void NewsFeed::addFeedItemForumUpdate(RsFeedItem &fi)
|
||||
//void NewsFeed::addFeedItemForumUpdate(const RsFeedItem &fi)
|
||||
//{
|
||||
// /* make new widget */
|
||||
// ForumNewItem *fni = new ForumNewItem(this, NEWSFEED_FORUMNEWLIST, fi.mId1, false, false);
|
||||
@ -704,7 +737,7 @@ void NewsFeed::addFeedItemForumNew(RsFeedItem &fi)
|
||||
//#endif
|
||||
//}
|
||||
|
||||
void NewsFeed::addFeedItemForumMsg(RsFeedItem &fi)
|
||||
void NewsFeed::addFeedItemForumMsg(const RsFeedItem &fi)
|
||||
{
|
||||
/* make new widget */
|
||||
// ForumMsgItem *fm = new ForumMsgItem(this, NEWSFEED_FORUMMSGLIST, fi.mId1, fi.mId2, false);
|
||||
@ -719,7 +752,7 @@ void NewsFeed::addFeedItemForumMsg(RsFeedItem &fi)
|
||||
}
|
||||
|
||||
#if 0
|
||||
void NewsFeed::addFeedItemBlogNew(RsFeedItem &fi)
|
||||
void NewsFeed::addFeedItemBlogNew(const RsFeedItem &fi)
|
||||
{
|
||||
#ifdef BLOGS
|
||||
/* make new widget */
|
||||
@ -737,7 +770,7 @@ void NewsFeed::addFeedItemBlogNew(RsFeedItem &fi)
|
||||
#endif
|
||||
}
|
||||
|
||||
void NewsFeed::addFeedItemBlogMsg(RsFeedItem &fi)
|
||||
void NewsFeed::addFeedItemBlogMsg(const RsFeedItem &fi)
|
||||
{
|
||||
#ifdef BLOGS
|
||||
/* make new widget */
|
||||
@ -757,7 +790,7 @@ void NewsFeed::addFeedItemBlogMsg(RsFeedItem &fi)
|
||||
|
||||
#endif
|
||||
|
||||
void NewsFeed::addFeedItemChatNew(RsFeedItem &fi, bool addWithoutCheck)
|
||||
void NewsFeed::addFeedItemChatNew(const RsFeedItem &fi, bool addWithoutCheck)
|
||||
{
|
||||
#ifdef NEWS_DEBUG
|
||||
std::cerr << "NewsFeed::addFeedItemChatNew()";
|
||||
@ -776,7 +809,7 @@ void NewsFeed::addFeedItemChatNew(RsFeedItem &fi, bool addWithoutCheck)
|
||||
addFeedItem(cm);
|
||||
}
|
||||
|
||||
void NewsFeed::addFeedItemMessage(RsFeedItem &fi)
|
||||
void NewsFeed::addFeedItemMessage(const RsFeedItem &fi)
|
||||
{
|
||||
/* make new widget */
|
||||
MsgItem *mi = new MsgItem(this, NEWSFEED_MESSAGELIST, fi.mId1, false);
|
||||
@ -790,7 +823,7 @@ void NewsFeed::addFeedItemMessage(RsFeedItem &fi)
|
||||
#endif
|
||||
}
|
||||
|
||||
void NewsFeed::addFeedItemFilesNew(RsFeedItem &/*fi*/)
|
||||
void NewsFeed::addFeedItemFilesNew(const RsFeedItem &/*fi*/)
|
||||
{
|
||||
#ifdef NEWS_DEBUG
|
||||
std::cerr << "NewsFeed::addFeedItemFilesNew()";
|
||||
@ -801,7 +834,7 @@ void NewsFeed::addFeedItemFilesNew(RsFeedItem &/*fi*/)
|
||||
/* FeedHolder Functions (for FeedItem functionality) */
|
||||
QScrollArea *NewsFeed::getScrollArea()
|
||||
{
|
||||
return scrollArea;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void NewsFeed::deleteFeedItem(QWidget *item, uint32_t /*type*/)
|
||||
@ -832,36 +865,18 @@ void NewsFeed::openComments(uint32_t /*type*/, const RsGxsGroupId &/*groupId*/,
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
void NewsFeed::itemDestroyed(QObject *item)
|
||||
static void sendNewsFeedChangedCallback(FeedItem *feedItem, void *data)
|
||||
{
|
||||
widgets.remove(item);
|
||||
sendNewsFeedChanged();
|
||||
}
|
||||
|
||||
void NewsFeed::removeAll()
|
||||
{
|
||||
#ifdef NEWS_DEBUG
|
||||
std::cerr << "NewsFeed::removeAll()" << std::endl;
|
||||
#endif
|
||||
|
||||
foreach (QObject *item, widgets) {
|
||||
if (item) {
|
||||
item->deleteLater();
|
||||
}
|
||||
if (dynamic_cast<PeerItem*>(feedItem) == NULL) {
|
||||
/* don't count PeerItem's */
|
||||
++(*((int*) data));
|
||||
}
|
||||
widgets.clear();
|
||||
}
|
||||
|
||||
void NewsFeed::sendNewsFeedChanged()
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
foreach (QObject *item, widgets) {
|
||||
if (dynamic_cast<PeerItem*>(item) == NULL) {
|
||||
/* don't count PeerItem's */
|
||||
count++;
|
||||
}
|
||||
}
|
||||
ui->feedWidget->withAll(sendNewsFeedChangedCallback, &count);
|
||||
|
||||
emit newsFeedChanged(count);
|
||||
}
|
||||
|
@ -23,18 +23,21 @@
|
||||
#define _NEWS_FEED_DIALOG_H
|
||||
|
||||
#include "mainpage.h"
|
||||
#include "ui_NewsFeed.h"
|
||||
|
||||
#include "gui/feeds/FeedHolder.h"
|
||||
#include <retroshare-gui/RsAutoUpdatePage.h>
|
||||
|
||||
#define IMAGE_NEWSFEED ":/images/newsfeed/news-feed-32.png"
|
||||
#define IMAGE_NEWSFEED ":/images/newsfeed/news-feed-32.png"
|
||||
|
||||
namespace Ui {
|
||||
class NewsFeed;
|
||||
}
|
||||
|
||||
class RsFeedItem;
|
||||
|
||||
class FeedNotify;
|
||||
class FeedItem;
|
||||
|
||||
class NewsFeed : public RsAutoUpdatePage, public FeedHolder, private Ui::NewsFeed
|
||||
class NewsFeed : public RsAutoUpdatePage, public FeedHolder
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -67,42 +70,42 @@ signals:
|
||||
private slots:
|
||||
// void toggleChanMsgItems(bool on);
|
||||
void feedoptions();
|
||||
|
||||
void removeAll();
|
||||
void itemDestroyed(QObject*);
|
||||
|
||||
private:
|
||||
void addFeedItem(QWidget *item);
|
||||
void addFeedItemIfUnique(QWidget *item, int itemType, const RsPeerId &sslId, bool replace);
|
||||
|
||||
void addFeedItemPeerConnect(RsFeedItem &fi);
|
||||
void addFeedItemPeerDisconnect(RsFeedItem &fi);
|
||||
void addFeedItemPeerNew(RsFeedItem &fi);
|
||||
void addFeedItemPeerHello(RsFeedItem &fi);
|
||||
|
||||
void addFeedItemSecurityConnectAttempt(RsFeedItem &fi);
|
||||
void addFeedItemSecurityAuthDenied(RsFeedItem &fi);
|
||||
void addFeedItemSecurityUnknownIn(RsFeedItem &fi);
|
||||
void addFeedItemSecurityUnknownOut(RsFeedItem &fi);
|
||||
|
||||
void addFeedItemChannelNew(RsFeedItem &fi);
|
||||
// void addFeedItemChannelUpdate(RsFeedItem &fi);
|
||||
void addFeedItemChannelMsg(RsFeedItem &fi);
|
||||
void addFeedItemForumNew(RsFeedItem &fi);
|
||||
// void addFeedItemForumUpdate(RsFeedItem &fi);
|
||||
void addFeedItemForumMsg(RsFeedItem &fi);
|
||||
#if 0
|
||||
void addFeedItemBlogNew(RsFeedItem &fi);
|
||||
void addFeedItemBlogMsg(RsFeedItem &fi);
|
||||
#endif
|
||||
|
||||
void addFeedItemChatNew(RsFeedItem &fi, bool addWithoutCheck);
|
||||
void addFeedItemMessage(RsFeedItem &fi);
|
||||
void addFeedItemFilesNew(RsFeedItem &fi);
|
||||
void settingsChanged();
|
||||
|
||||
void sendNewsFeedChanged();
|
||||
|
||||
std::list<QObject*> widgets;
|
||||
private:
|
||||
void addFeedItem(FeedItem *item);
|
||||
void addFeedItemIfUnique(FeedItem *item, int itemType, const RsPeerId &sslId, bool replace);
|
||||
|
||||
void addFeedItemPeerConnect(const RsFeedItem &fi);
|
||||
void addFeedItemPeerDisconnect(const RsFeedItem &fi);
|
||||
void addFeedItemPeerNew(const RsFeedItem &fi);
|
||||
void addFeedItemPeerHello(const RsFeedItem &fi);
|
||||
|
||||
void addFeedItemSecurityConnectAttempt(const RsFeedItem &fi);
|
||||
void addFeedItemSecurityAuthDenied(const RsFeedItem &fi);
|
||||
void addFeedItemSecurityUnknownIn(const RsFeedItem &fi);
|
||||
void addFeedItemSecurityUnknownOut(const RsFeedItem &fi);
|
||||
|
||||
void addFeedItemChannelNew(const RsFeedItem &fi);
|
||||
// void addFeedItemChannelUpdate(const RsFeedItem &fi);
|
||||
void addFeedItemChannelMsg(const RsFeedItem &fi);
|
||||
void addFeedItemForumNew(const RsFeedItem &fi);
|
||||
// void addFeedItemForumUpdate(const RsFeedItem &fi);
|
||||
void addFeedItemForumMsg(const RsFeedItem &fi);
|
||||
#if 0
|
||||
void addFeedItemBlogNew(const RsFeedItem &fi);
|
||||
void addFeedItemBlogMsg(const RsFeedItem &fi);
|
||||
#endif
|
||||
|
||||
void addFeedItemChatNew(const RsFeedItem &fi, bool addWithoutCheck);
|
||||
void addFeedItemMessage(const RsFeedItem &fi);
|
||||
void addFeedItemFilesNew(const RsFeedItem &fi);
|
||||
|
||||
private:
|
||||
/* UI - from Designer */
|
||||
Ui::NewsFeed *ui;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -113,38 +113,25 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
<widget class="RSFeedWidget" name="feedWidget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>551</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="itemsLayout">
|
||||
<property name="spacing">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>RSFeedWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>gui/common/RSFeedWidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="images.qrc"/>
|
||||
</resources>
|
||||
|
@ -44,12 +44,12 @@ void FeedNotify::setNotifyEnabled(bool /*enabled*/)
|
||||
{
|
||||
}
|
||||
|
||||
QWidget *FeedNotify::feedItem(FeedHolder */*parent*/)
|
||||
FeedItem *FeedNotify::feedItem(FeedHolder */*parent*/)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
QWidget *FeedNotify::testFeedItem(FeedHolder */*parent*/)
|
||||
FeedItem *FeedNotify::testFeedItem(FeedHolder */*parent*/)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <QObject>
|
||||
|
||||
class FeedHolder;
|
||||
class FeedItem;
|
||||
|
||||
class FeedNotify : public QObject
|
||||
{
|
||||
@ -37,8 +38,8 @@ public:
|
||||
virtual bool hasSetting(QString &/*name*/);
|
||||
virtual bool notifyEnabled();
|
||||
virtual void setNotifyEnabled(bool /*enabled*/);
|
||||
virtual QWidget *feedItem(FeedHolder */*parent*/);
|
||||
virtual QWidget *testFeedItem(FeedHolder */*parent*/);
|
||||
virtual FeedItem *feedItem(FeedHolder */*parent*/);
|
||||
virtual FeedItem *testFeedItem(FeedHolder */*parent*/);
|
||||
};
|
||||
|
||||
#endif // FEEDNOTIFY_H
|
||||
|
@ -45,6 +45,9 @@ RSFeedWidget::RSFeedWidget(QWidget *parent)
|
||||
/* Remove */
|
||||
mEnableRemove = false;
|
||||
|
||||
/* Options */
|
||||
mCountChangedDisabled = 0;
|
||||
|
||||
ui->treeWidget->installEventFilter(this);
|
||||
}
|
||||
|
||||
@ -85,6 +88,10 @@ bool RSFeedWidget::eventFilter(QObject *object, QEvent *event)
|
||||
delete(treeItem);
|
||||
}
|
||||
|
||||
if (!mCountChangedDisabled) {
|
||||
emit feedCountChanged();
|
||||
}
|
||||
|
||||
return true; // eat event
|
||||
}
|
||||
}
|
||||
@ -128,6 +135,10 @@ void RSFeedWidget::addFeedItem(FeedItem *feedItem, Qt::ItemDataRole sortRole, co
|
||||
connectSignals(feedItem);
|
||||
|
||||
filterItem(treeItem, feedItem);
|
||||
|
||||
if (!mCountChangedDisabled) {
|
||||
emit feedCountChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void RSFeedWidget::addFeedItem(FeedItem *feedItem, const QMap<Qt::ItemDataRole, QVariant> &sort)
|
||||
@ -149,6 +160,10 @@ void RSFeedWidget::addFeedItem(FeedItem *feedItem, const QMap<Qt::ItemDataRole,
|
||||
connectSignals(feedItem);
|
||||
|
||||
filterItem(treeItem, feedItem);
|
||||
|
||||
if (!mCountChangedDisabled) {
|
||||
emit feedCountChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void RSFeedWidget::setSort(FeedItem *feedItem, Qt::ItemDataRole sortRole, const QVariant &value)
|
||||
@ -184,7 +199,24 @@ void RSFeedWidget::setSort(FeedItem *feedItem, const QMap<Qt::ItemDataRole, QVar
|
||||
|
||||
void RSFeedWidget::clear()
|
||||
{
|
||||
/* Disconnect signals */
|
||||
QTreeWidgetItemIterator it(ui->treeWidget);
|
||||
QTreeWidgetItem *treeItem;
|
||||
while ((treeItem = *it) != NULL) {
|
||||
++it;
|
||||
|
||||
FeedItem *feedItem = feedItemFromTreeItem(treeItem);
|
||||
if (feedItem) {
|
||||
disconnectSignals(feedItem);
|
||||
}
|
||||
}
|
||||
|
||||
/* Clear items */
|
||||
ui->treeWidget->clear();
|
||||
|
||||
if (!mCountChangedDisabled) {
|
||||
emit feedCountChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void RSFeedWidget::setSortRole(Qt::ItemDataRole role, Qt::SortOrder order)
|
||||
@ -260,11 +292,39 @@ void RSFeedWidget::enableRemove(bool enable)
|
||||
mEnableRemove = enable;
|
||||
}
|
||||
|
||||
void RSFeedWidget::enableCountChangedSignal(bool enable)
|
||||
{
|
||||
if (enable) {
|
||||
--mCountChangedDisabled;
|
||||
if (mCountChangedDisabled < 0) {
|
||||
std::cerr << "RSFeedWidget::enableCountChangedSignal error disable count change signal" << std::endl;
|
||||
mCountChangedDisabled = 0;
|
||||
}
|
||||
} else {
|
||||
++mCountChangedDisabled;
|
||||
}
|
||||
}
|
||||
|
||||
void RSFeedWidget::setSelectionMode(QAbstractItemView::SelectionMode mode)
|
||||
{
|
||||
ui->treeWidget->setSelectionMode(mode);
|
||||
}
|
||||
|
||||
int RSFeedWidget::feedItemCount()
|
||||
{
|
||||
return ui->treeWidget->topLevelItemCount();
|
||||
}
|
||||
|
||||
FeedItem *RSFeedWidget::feedItem(int index)
|
||||
{
|
||||
QTreeWidgetItem *treeItem = ui->treeWidget->topLevelItem(index);
|
||||
if (!treeItem) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return feedItemFromTreeItem(treeItem);
|
||||
}
|
||||
|
||||
void RSFeedWidget::removeFeedItem(FeedItem *feedItem)
|
||||
{
|
||||
if (!feedItem) {
|
||||
@ -277,6 +337,10 @@ void RSFeedWidget::removeFeedItem(FeedItem *feedItem)
|
||||
if (treeItem) {
|
||||
delete(treeItem);
|
||||
}
|
||||
|
||||
if (!mCountChangedDisabled) {
|
||||
emit feedCountChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void RSFeedWidget::feedItemSizeChanged(FeedItem */*feedItem*/)
|
||||
@ -300,6 +364,10 @@ void RSFeedWidget::feedItemDestroyed(FeedItem *feedItem)
|
||||
if (treeItem) {
|
||||
delete(treeItem);
|
||||
}
|
||||
|
||||
if (!mCountChangedDisabled) {
|
||||
emit feedCountChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QTreeWidgetItem *RSFeedWidget::findTreeWidgetItem(FeedItem *feedItem)
|
||||
@ -333,15 +401,7 @@ bool RSFeedWidget::scrollTo(FeedItem *feedItem, bool focus)
|
||||
return true;
|
||||
}
|
||||
|
||||
class RSFeedWidgetCallback
|
||||
{
|
||||
public:
|
||||
RSFeedWidgetCallback() {}
|
||||
|
||||
virtual void callback(FeedItem *feedItem, const QVariant &data) = 0;
|
||||
};
|
||||
|
||||
void RSFeedWidget::withAll(RSFeedWidgetCallbackFunction callback, const QVariant &data)
|
||||
void RSFeedWidget::withAll(RSFeedWidgetCallbackFunction callback, void *data)
|
||||
{
|
||||
if (!callback) {
|
||||
return;
|
||||
@ -361,7 +421,7 @@ void RSFeedWidget::withAll(RSFeedWidgetCallbackFunction callback, const QVariant
|
||||
}
|
||||
}
|
||||
|
||||
FeedItem *RSFeedWidget::findFeedItem(RSFeedWidgetFindCallbackFunction callback, const QVariant &data1, const QVariant &data2)
|
||||
FeedItem *RSFeedWidget::findFeedItem(RSFeedWidgetFindCallbackFunction callback, void *data)
|
||||
{
|
||||
if (!callback) {
|
||||
return NULL;
|
||||
@ -377,7 +437,7 @@ FeedItem *RSFeedWidget::findFeedItem(RSFeedWidgetFindCallbackFunction callback,
|
||||
continue;
|
||||
}
|
||||
|
||||
if (callback(feedItem, data1, data2)) {
|
||||
if (callback(feedItem, data)) {
|
||||
return feedItem;
|
||||
}
|
||||
}
|
||||
@ -397,9 +457,18 @@ void RSFeedWidget::selectedFeedItems(QList<FeedItem*> &feedItems)
|
||||
}
|
||||
}
|
||||
|
||||
static bool findGxsFeedItemCallback(FeedItem *feedItem, const QVariant &data1, const QVariant &data2)
|
||||
struct FindGxsFeedItemData
|
||||
{
|
||||
if (!data1.canConvert<RsGxsGroupId>() || !data2.canConvert<RsGxsMessageId>()) {
|
||||
FindGxsFeedItemData(const RsGxsGroupId &groupId, const RsGxsMessageId &messageId) : mGroupId(groupId), mMessageId(messageId) {}
|
||||
|
||||
const RsGxsGroupId &mGroupId;
|
||||
const RsGxsMessageId &mMessageId;
|
||||
};
|
||||
|
||||
static bool findGxsFeedItemCallback(FeedItem *feedItem, void *data)
|
||||
{
|
||||
FindGxsFeedItemData *findData = (FindGxsFeedItemData*) data;
|
||||
if (!findData || findData->mGroupId.isNull() || findData->mMessageId.isNull()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -408,8 +477,8 @@ static bool findGxsFeedItemCallback(FeedItem *feedItem, const QVariant &data1, c
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item->groupId() != data1.value<RsGxsGroupId>() ||
|
||||
item->messageId() != data2.value<RsGxsMessageId>()) {
|
||||
if (item->groupId() != findData->mGroupId ||
|
||||
item->messageId() != findData->mMessageId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -418,6 +487,7 @@ static bool findGxsFeedItemCallback(FeedItem *feedItem, const QVariant &data1, c
|
||||
|
||||
GxsFeedItem *RSFeedWidget::findGxsFeedItem(const RsGxsGroupId &groupId, const RsGxsMessageId &messageId)
|
||||
{
|
||||
FeedItem *feedItem = findFeedItem(findGxsFeedItemCallback, qVariantFromValue(groupId), qVariantFromValue(messageId));
|
||||
FindGxsFeedItemData data(groupId, messageId);
|
||||
FeedItem *feedItem = findFeedItem(findGxsFeedItemCallback, &data);
|
||||
return dynamic_cast<GxsFeedItem*>(feedItem);
|
||||
}
|
||||
|
@ -39,8 +39,8 @@ namespace Ui {
|
||||
class RSFeedWidget;
|
||||
}
|
||||
|
||||
typedef void (*RSFeedWidgetCallbackFunction)(FeedItem *feedItem, const QVariant &data);
|
||||
typedef bool (*RSFeedWidgetFindCallbackFunction)(FeedItem *feedItem, const QVariant &data1, const QVariant &data2);
|
||||
typedef void (*RSFeedWidgetCallbackFunction)(FeedItem *feedItem, void *data);
|
||||
typedef bool (*RSFeedWidgetFindCallbackFunction)(FeedItem *feedItem, void *data);
|
||||
typedef bool (*RSFeedWidgetFilterCallbackFunction)(FeedItem *feedItem, const QString &text, int filter);
|
||||
|
||||
class RSFeedWidget : public QWidget
|
||||
@ -57,27 +57,33 @@ public:
|
||||
void setSort(FeedItem *feedItem, Qt::ItemDataRole sortRole, const QVariant &value);
|
||||
void setSort(FeedItem *feedItem, const QMap<Qt::ItemDataRole, QVariant> &sort);
|
||||
|
||||
int feedItemCount();
|
||||
FeedItem *feedItem(int index);
|
||||
void removeFeedItem(FeedItem *feedItem);
|
||||
void clear();
|
||||
|
||||
void setSortRole(Qt::ItemDataRole role, Qt::SortOrder order);
|
||||
void setSortingEnabled(bool enable);
|
||||
void setFilterCallback(RSFeedWidgetFilterCallbackFunction callback);
|
||||
|
||||
void enableRemove(bool enable);
|
||||
void enableCountChangedSignal(bool enable);
|
||||
void setSelectionMode(QAbstractItemView::SelectionMode mode);
|
||||
|
||||
bool scrollTo(FeedItem *feedItem, bool focus);
|
||||
|
||||
void withAll(RSFeedWidgetCallbackFunction callback, const QVariant &data);
|
||||
FeedItem *findFeedItem(RSFeedWidgetFindCallbackFunction callback, const QVariant &data1, const QVariant &data2);
|
||||
void withAll(RSFeedWidgetCallbackFunction callback, void *data);
|
||||
FeedItem *findFeedItem(RSFeedWidgetFindCallbackFunction callback, void *data);
|
||||
|
||||
void selectedFeedItems(QList<FeedItem*> &feedItems);
|
||||
|
||||
/* Convenience functions */
|
||||
GxsFeedItem *findGxsFeedItem(const RsGxsGroupId &groupId, const RsGxsMessageId &messageId);
|
||||
|
||||
signals:
|
||||
void feedCountChanged();
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
void setFilter(const QString &text, int type);
|
||||
void setFilterText(const QString &text);
|
||||
void setFilterType(int type);
|
||||
@ -109,6 +115,9 @@ private:
|
||||
/* Remove */
|
||||
bool mEnableRemove;
|
||||
|
||||
/* Options */
|
||||
int mCountChangedDisabled;
|
||||
|
||||
Ui::RSFeedWidget *ui;
|
||||
};
|
||||
|
||||
|
@ -41,8 +41,8 @@
|
||||
****/
|
||||
|
||||
/** Constructor */
|
||||
ChatMsgItem::ChatMsgItem(FeedHolder *parent, uint32_t feedId, const RsPeerId &peerId, const std::string &message)
|
||||
:QWidget(NULL), mParent(parent), mFeedId(feedId), mPeerId(peerId)
|
||||
ChatMsgItem::ChatMsgItem(FeedHolder *parent, uint32_t feedId, const RsPeerId &peerId, const std::string &message) :
|
||||
FeedItem(NULL), mParent(parent), mFeedId(feedId), mPeerId(peerId)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
setupUi(this);
|
||||
@ -224,16 +224,18 @@ void ChatMsgItem::togglequickmessage()
|
||||
|
||||
if (messageFrame->isHidden())
|
||||
{
|
||||
messageFrame->setVisible(true);
|
||||
messageFrame->show();
|
||||
sendButton->show();
|
||||
cancelButton->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
messageFrame->setVisible(false);
|
||||
messageFrame->hide();
|
||||
sendButton->hide();
|
||||
cancelButton->hide();
|
||||
}
|
||||
}
|
||||
|
||||
emit sizeChanged(this);
|
||||
|
||||
mParent->lockLayout(this, false);
|
||||
}
|
||||
@ -253,6 +255,8 @@ void ChatMsgItem::sendMessage()
|
||||
messageFrame->setVisible(false);
|
||||
sendButton->hide();
|
||||
cancelButton->hide();
|
||||
|
||||
emit sizeChanged(this);
|
||||
}
|
||||
|
||||
void ChatMsgItem::on_quickmsgText_textChanged()
|
||||
|
@ -23,20 +23,24 @@
|
||||
#define _CHATMSG_ITEM_DIALOG_H
|
||||
|
||||
#include "ui_ChatMsgItem.h"
|
||||
#include "FeedItem.h"
|
||||
#include <stdint.h>
|
||||
|
||||
class FeedHolder;
|
||||
|
||||
class ChatMsgItem : public QWidget, private Ui::ChatMsgItem
|
||||
class ChatMsgItem : public FeedItem, private Ui::ChatMsgItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/** Default Constructor */
|
||||
ChatMsgItem(FeedHolder *parent, uint32_t feedId, const RsPeerId &peerId, const std::string &message);
|
||||
ChatMsgItem(FeedHolder *parent, uint32_t feedId, const RsPeerId &peerId, const std::string &message);
|
||||
|
||||
void updateItemStatic();
|
||||
|
||||
/* FeedItem */
|
||||
virtual void expand(bool /*open*/) {}
|
||||
|
||||
private slots:
|
||||
/* default stuff */
|
||||
void gotoHome();
|
||||
@ -58,7 +62,7 @@ private:
|
||||
FeedHolder *mParent;
|
||||
uint32_t mFeedId;
|
||||
|
||||
RsPeerId mPeerId;
|
||||
RsPeerId mPeerId;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -11,8 +11,17 @@
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_1">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
<property name="leftMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QFrame" name="frame">
|
||||
@ -204,32 +213,22 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="5">
|
||||
<widget class="QFrame" name="frame_2">
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<property name="margin">
|
||||
<item row="3" column="0" colspan="5">
|
||||
<widget class="QFrame" name="buttonFrame">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0" colspan="6">
|
||||
<widget class="QFrame" name="messageFrame">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QTextEdit" name="quickmsgText">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>115</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QToolButton" name="quickmsgButton">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
@ -252,7 +251,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item>
|
||||
<widget class="QToolButton" name="msgButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
@ -281,7 +280,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<item>
|
||||
<widget class="QToolButton" name="chatButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
@ -313,7 +312,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
@ -326,7 +325,17 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="5">
|
||||
<item>
|
||||
<widget class="QPushButton" name="cancelButton">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="sendButton">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
@ -339,13 +348,31 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="QPushButton" name="cancelButton">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="5">
|
||||
<widget class="QFrame" name="messageFrame">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QTextEdit" name="quickmsgText">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>115</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -39,8 +39,8 @@
|
||||
****/
|
||||
|
||||
/** Constructor */
|
||||
MsgItem::MsgItem(FeedHolder *parent, uint32_t feedId, const std::string &msgId, bool isHome)
|
||||
:QWidget(NULL), mParent(parent), mFeedId(feedId), mMsgId(msgId), mIsHome(isHome)
|
||||
MsgItem::MsgItem(FeedHolder *parent, uint32_t feedId, const std::string &msgId, bool isHome) :
|
||||
FeedItem(NULL), mParent(parent), mFeedId(feedId), mMsgId(msgId), mIsHome(isHome)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
setupUi(this);
|
||||
@ -194,24 +194,34 @@ void MsgItem::updateItem()
|
||||
|
||||
void MsgItem::toggle()
|
||||
{
|
||||
mParent->lockLayout(this, true);
|
||||
expand(expandFrame->isHidden());
|
||||
}
|
||||
|
||||
if (expandFrame->isHidden())
|
||||
void MsgItem::expand(bool open)
|
||||
{
|
||||
if (mParent) {
|
||||
mParent->lockLayout(this, true);
|
||||
}
|
||||
|
||||
if (open)
|
||||
{
|
||||
expandFrame->show();
|
||||
expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png")));
|
||||
expandButton->setToolTip(tr("Hide"));
|
||||
expandButton->setToolTip(tr("Hide"));
|
||||
}
|
||||
else
|
||||
{
|
||||
expandFrame->hide();
|
||||
expandButton->setIcon(QIcon(QString(":/images/edit_add24.png")));
|
||||
expandButton->setToolTip(tr("Expand"));
|
||||
expandButton->setIcon(QIcon(QString(":/images/edit_add24.png")));
|
||||
expandButton->setToolTip(tr("Expand"));
|
||||
}
|
||||
|
||||
mParent->lockLayout(this, false);
|
||||
}
|
||||
emit sizeChanged(this);
|
||||
|
||||
if (mParent) {
|
||||
mParent->lockLayout(this, false);
|
||||
}
|
||||
}
|
||||
|
||||
void MsgItem::removeItem()
|
||||
{
|
||||
|
@ -23,12 +23,13 @@
|
||||
#define _MSG_ITEM_DIALOG_H
|
||||
|
||||
#include "ui_MsgItem.h"
|
||||
#include "FeedItem.h"
|
||||
#include <stdint.h>
|
||||
|
||||
class FeedHolder;
|
||||
class SubFileItem;
|
||||
|
||||
class MsgItem : public QWidget, private Ui::MsgItem
|
||||
class MsgItem : public FeedItem, private Ui::MsgItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -38,6 +39,9 @@ public:
|
||||
|
||||
void updateItemStatic();
|
||||
|
||||
/* FeedItem */
|
||||
virtual void expand(bool open);
|
||||
|
||||
private slots:
|
||||
/* default stuff */
|
||||
void gotoHome();
|
||||
|
@ -11,8 +11,17 @@
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
<property name="leftMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QFrame" name="frame">
|
||||
|
@ -40,9 +40,9 @@
|
||||
****/
|
||||
|
||||
/** Constructor */
|
||||
PeerItem::PeerItem(FeedHolder *parent, uint32_t feedId, const RsPeerId &peerId, uint32_t type, bool isHome)
|
||||
:QWidget(NULL), mParent(parent), mFeedId(feedId),
|
||||
mPeerId(peerId), mType(type), mIsHome(isHome)
|
||||
PeerItem::PeerItem(FeedHolder *parent, uint32_t feedId, const RsPeerId &peerId, uint32_t type, bool isHome) :
|
||||
FeedItem(NULL), mParent(parent), mFeedId(feedId),
|
||||
mPeerId(peerId), mType(type), mIsHome(isHome)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
setupUi(this);
|
||||
@ -209,9 +209,16 @@ void PeerItem::updateItem()
|
||||
|
||||
void PeerItem::toggle()
|
||||
{
|
||||
mParent->lockLayout(this, true);
|
||||
expand(expandFrame->isHidden());
|
||||
}
|
||||
|
||||
if (expandFrame->isHidden())
|
||||
void PeerItem::expand(bool open)
|
||||
{
|
||||
if (mParent) {
|
||||
mParent->lockLayout(this, true);
|
||||
}
|
||||
|
||||
if (open)
|
||||
{
|
||||
expandFrame->show();
|
||||
expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png")));
|
||||
@ -224,9 +231,12 @@ void PeerItem::toggle()
|
||||
expandButton->setToolTip(tr("Expand"));
|
||||
}
|
||||
|
||||
mParent->lockLayout(this, false);
|
||||
}
|
||||
emit sizeChanged(this);
|
||||
|
||||
if (mParent) {
|
||||
mParent->lockLayout(this, false);
|
||||
}
|
||||
}
|
||||
|
||||
void PeerItem::removeItem()
|
||||
{
|
||||
|
@ -23,6 +23,7 @@
|
||||
#define _PEER_ITEM_DIALOG_H
|
||||
|
||||
#include "ui_PeerItem.h"
|
||||
#include "FeedItem.h"
|
||||
#include <stdint.h>
|
||||
|
||||
const uint32_t PEER_TYPE_STD = 0x0001;
|
||||
@ -32,16 +33,19 @@ const uint32_t PEER_TYPE_NEW_FOF = 0x0004; /* new Friend of Friend */
|
||||
|
||||
class FeedHolder;
|
||||
|
||||
class PeerItem : public QWidget, private Ui::PeerItem
|
||||
class PeerItem : public FeedItem, private Ui::PeerItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/** Default Constructor */
|
||||
PeerItem(FeedHolder *parent, uint32_t feedId, const RsPeerId &peerId, uint32_t type, bool isHome);
|
||||
PeerItem(FeedHolder *parent, uint32_t feedId, const RsPeerId &peerId, uint32_t type, bool isHome);
|
||||
|
||||
void updateItemStatic();
|
||||
|
||||
/* FeedItem */
|
||||
virtual void expand(bool open);
|
||||
|
||||
private slots:
|
||||
/* default stuff */
|
||||
void removeItem();
|
||||
|
@ -11,8 +11,17 @@
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
<property name="leftMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QFrame" name="frame">
|
||||
|
@ -43,43 +43,42 @@
|
||||
****/
|
||||
|
||||
/** Constructor */
|
||||
SecurityItem::SecurityItem(FeedHolder *parent, uint32_t feedId, const RsPgpId &gpgId, const RsPeerId &sslId, const std::string &sslCn, const std::string& ip_address,uint32_t type, bool isHome)
|
||||
:QWidget(NULL), mParent(parent), mFeedId(feedId),
|
||||
mGpgId(gpgId), mSslId(sslId), mSslCn(sslCn), mIP(ip_address), mType(type), mIsHome(isHome)
|
||||
SecurityItem::SecurityItem(FeedHolder *parent, uint32_t feedId, const RsPgpId &gpgId, const RsPeerId &sslId, const std::string &sslCn, const std::string& ip_address,uint32_t type, bool isHome) :
|
||||
FeedItem(NULL), mParent(parent), mFeedId(feedId),
|
||||
mGpgId(gpgId), mSslId(sslId), mSslCn(sslCn), mIP(ip_address), mType(type), mIsHome(isHome)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
setupUi(this);
|
||||
|
||||
quickmsgButton->hide();
|
||||
chatButton->hide();
|
||||
removeFriendButton->setEnabled(false);
|
||||
removeFriendButton->hide();
|
||||
peerDetailsButton->setEnabled(false);
|
||||
friendRequesttoolButton->hide();
|
||||
requestLabel->hide();
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
setupUi(this);
|
||||
|
||||
/* general ones */
|
||||
connect( expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggle ( void ) ) );
|
||||
connect( clearButton, SIGNAL( clicked( void ) ), this, SLOT( removeItem ( void ) ) );
|
||||
quickmsgButton->hide();
|
||||
chatButton->hide();
|
||||
removeFriendButton->setEnabled(false);
|
||||
removeFriendButton->hide();
|
||||
peerDetailsButton->setEnabled(false);
|
||||
friendRequesttoolButton->hide();
|
||||
requestLabel->hide();
|
||||
|
||||
/* specific ones */
|
||||
connect( chatButton, SIGNAL( clicked( void ) ), this, SLOT( openChat ( void ) ) );
|
||||
/* general ones */
|
||||
connect( expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggle ( void ) ) );
|
||||
connect( clearButton, SIGNAL( clicked( void ) ), this, SLOT( removeItem ( void ) ) );
|
||||
|
||||
connect( quickmsgButton, SIGNAL( clicked( ) ), this, SLOT( sendMsg() ) );
|
||||
/* specific ones */
|
||||
connect( chatButton, SIGNAL( clicked( void ) ), this, SLOT( openChat ( void ) ) );
|
||||
|
||||
connect( removeFriendButton, SIGNAL(clicked()), this, SLOT(removeFriend()));
|
||||
connect( peerDetailsButton, SIGNAL(clicked()), this, SLOT(peerDetails()));
|
||||
connect( friendRequesttoolButton, SIGNAL(clicked()), this, SLOT(friendRequest()));
|
||||
connect( quickmsgButton, SIGNAL( clicked( ) ), this, SLOT( sendMsg() ) );
|
||||
|
||||
connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()), this, SLOT(updateItem()));
|
||||
connect( removeFriendButton, SIGNAL(clicked()), this, SLOT(removeFriend()));
|
||||
connect( peerDetailsButton, SIGNAL(clicked()), this, SLOT(peerDetails()));
|
||||
connect( friendRequesttoolButton, SIGNAL(clicked()), this, SLOT(friendRequest()));
|
||||
|
||||
connect(NotifyQt::getInstance(), SIGNAL(friendsChanged()), this, SLOT(updateItem()));
|
||||
|
||||
avatar->setId(mSslId);
|
||||
avatar->setId(mSslId);
|
||||
|
||||
expandFrame->hide();
|
||||
expandFrame->hide();
|
||||
|
||||
updateItemStatic();
|
||||
updateItem();
|
||||
updateItemStatic();
|
||||
updateItem();
|
||||
}
|
||||
|
||||
|
||||
@ -283,9 +282,16 @@ void SecurityItem::updateItem()
|
||||
|
||||
void SecurityItem::toggle()
|
||||
{
|
||||
mParent->lockLayout(this, true);
|
||||
expand(expandFrame->isHidden());
|
||||
}
|
||||
|
||||
if (expandFrame->isHidden())
|
||||
void SecurityItem::expand(bool open)
|
||||
{
|
||||
if (mParent) {
|
||||
mParent->lockLayout(this, true);
|
||||
}
|
||||
|
||||
if (open)
|
||||
{
|
||||
expandFrame->show();
|
||||
expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png")));
|
||||
@ -298,7 +304,11 @@ void SecurityItem::toggle()
|
||||
expandButton->setToolTip(tr("Expand"));
|
||||
}
|
||||
|
||||
mParent->lockLayout(this, false);
|
||||
emit sizeChanged(this);
|
||||
|
||||
if (mParent) {
|
||||
mParent->lockLayout(this, false);
|
||||
}
|
||||
}
|
||||
|
||||
void SecurityItem::removeItem()
|
||||
|
@ -23,6 +23,7 @@
|
||||
#define _SECURITY_ITEM_DIALOG_H
|
||||
|
||||
#include "ui_SecurityItem.h"
|
||||
#include "FeedItem.h"
|
||||
#include <stdint.h>
|
||||
|
||||
//const uint32_t SEC_TYPE_CONNECT_ATTEMPT = 0x0001; /* failed Connect Attempt */
|
||||
@ -32,17 +33,20 @@
|
||||
|
||||
class FeedHolder;
|
||||
|
||||
class SecurityItem : public QWidget, private Ui::SecurityItem
|
||||
class SecurityItem : public FeedItem, private Ui::SecurityItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/** Default Constructor */
|
||||
SecurityItem(FeedHolder *parent, uint32_t feedId, const RsPgpId &gpgId, const RsPeerId &sslId, const std::string &sslCn, const std::string& ip_addr,uint32_t type, bool isHome);
|
||||
SecurityItem(FeedHolder *parent, uint32_t feedId, const RsPgpId &gpgId, const RsPeerId &sslId, const std::string &sslCn, const std::string& ip_addr,uint32_t type, bool isHome);
|
||||
|
||||
void updateItemStatic();
|
||||
|
||||
bool isSame(const RsPeerId &sslId, uint32_t type);
|
||||
bool isSame(const RsPeerId &sslId, uint32_t type);
|
||||
|
||||
/* FeedItem */
|
||||
virtual void expand(bool open);
|
||||
|
||||
private slots:
|
||||
/* default stuff */
|
||||
@ -57,14 +61,12 @@ private slots:
|
||||
|
||||
void updateItem();
|
||||
|
||||
|
||||
|
||||
private:
|
||||
FeedHolder *mParent;
|
||||
uint32_t mFeedId;
|
||||
|
||||
RsPgpId mGpgId;
|
||||
RsPeerId mSslId;
|
||||
RsPgpId mGpgId;
|
||||
RsPeerId mSslId;
|
||||
std::string mSslCn;
|
||||
std::string mIP;
|
||||
uint32_t mType;
|
||||
|
@ -11,8 +11,17 @@
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
<property name="leftMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QFrame" name="frame">
|
||||
|
@ -467,7 +467,7 @@ void GxsChannelPostsWidget::insertRelatedPosts(const uint32_t &token)
|
||||
insertChannelPosts(posts, NULL, true);
|
||||
}
|
||||
|
||||
static void setAllMessagesReadCallback(FeedItem *feedItem, const QVariant &data)
|
||||
static void setAllMessagesReadCallback(FeedItem *feedItem, void *data)
|
||||
{
|
||||
GxsChannelPostItem *channelPostItem = dynamic_cast<GxsChannelPostItem*>(feedItem);
|
||||
if (!channelPostItem) {
|
||||
@ -477,7 +477,7 @@ static void setAllMessagesReadCallback(FeedItem *feedItem, const QVariant &data)
|
||||
RsGxsGrpMsgIdPair msgPair = std::make_pair(channelPostItem->groupId(), channelPostItem->messageId());
|
||||
|
||||
uint32_t token;
|
||||
rsGxsChannels->setMessageReadStatus(token, msgPair, data.toBool());
|
||||
rsGxsChannels->setMessageReadStatus(token, msgPair, *((bool*) data));
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::setAllMessagesRead(bool read)
|
||||
@ -486,5 +486,5 @@ void GxsChannelPostsWidget::setAllMessagesRead(bool read)
|
||||
return;
|
||||
}
|
||||
|
||||
ui->feedWidget->withAll(setAllMessagesReadCallback, read);
|
||||
ui->feedWidget->withAll(setAllMessagesReadCallback, &read);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user