diff --git a/retroshare-gui/src/gui/NewsFeed.cpp b/retroshare-gui/src/gui/NewsFeed.cpp index aa9d01664..2c0002be0 100644 --- a/retroshare-gui/src/gui/NewsFeed.cpp +++ b/retroshare-gui/src/gui/NewsFeed.cpp @@ -20,8 +20,10 @@ ****************************************************************/ #include +#include #include "NewsFeed.h" +#include "ui_NewsFeed.h" #include #include @@ -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( "

  News Feed

\ @@ -103,7 +113,9 @@ QString hlp_str = tr(

\ ") ; - 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(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(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(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(feedItem) == NULL) { + /* don't count PeerItem's */ + ++(*((int*) data)); } - widgets.clear(); } void NewsFeed::sendNewsFeedChanged() { int count = 0; - - foreach (QObject *item, widgets) { - if (dynamic_cast(item) == NULL) { - /* don't count PeerItem's */ - count++; - } - } + ui->feedWidget->withAll(sendNewsFeedChangedCallback, &count); emit newsFeedChanged(count); } diff --git a/retroshare-gui/src/gui/NewsFeed.h b/retroshare-gui/src/gui/NewsFeed.h index 6987ea647..1e38bba87 100644 --- a/retroshare-gui/src/gui/NewsFeed.h +++ b/retroshare-gui/src/gui/NewsFeed.h @@ -23,18 +23,21 @@ #define _NEWS_FEED_DIALOG_H #include "mainpage.h" -#include "ui_NewsFeed.h" #include "gui/feeds/FeedHolder.h" #include -#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 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 diff --git a/retroshare-gui/src/gui/NewsFeed.ui b/retroshare-gui/src/gui/NewsFeed.ui index 60a5e7b7e..8ee8c3597 100644 --- a/retroshare-gui/src/gui/NewsFeed.ui +++ b/retroshare-gui/src/gui/NewsFeed.ui @@ -113,38 +113,25 @@ - - - true + + + + 0 + 0 + - - - - 0 - 0 - 551 - 16 - - - - - 0 - 0 - - - - - 3 - - - 3 - - - + + + RSFeedWidget + QWidget +
gui/common/RSFeedWidget.h
+ 1 +
+
diff --git a/retroshare-gui/src/gui/common/FeedNotify.cpp b/retroshare-gui/src/gui/common/FeedNotify.cpp index 1db718ece..c51eabdad 100644 --- a/retroshare-gui/src/gui/common/FeedNotify.cpp +++ b/retroshare-gui/src/gui/common/FeedNotify.cpp @@ -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; } diff --git a/retroshare-gui/src/gui/common/FeedNotify.h b/retroshare-gui/src/gui/common/FeedNotify.h index cd8f1acbc..6f0b8703c 100644 --- a/retroshare-gui/src/gui/common/FeedNotify.h +++ b/retroshare-gui/src/gui/common/FeedNotify.h @@ -25,6 +25,7 @@ #include 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 diff --git a/retroshare-gui/src/gui/common/RSFeedWidget.cpp b/retroshare-gui/src/gui/common/RSFeedWidget.cpp index c2192309d..fa4d12fc4 100644 --- a/retroshare-gui/src/gui/common/RSFeedWidget.cpp +++ b/retroshare-gui/src/gui/common/RSFeedWidget.cpp @@ -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 &sort) @@ -149,6 +160,10 @@ void RSFeedWidget::addFeedItem(FeedItem *feedItem, const QMaptreeWidget); + 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 &feedItems) } } -static bool findGxsFeedItemCallback(FeedItem *feedItem, const QVariant &data1, const QVariant &data2) +struct FindGxsFeedItemData { - if (!data1.canConvert() || !data2.canConvert()) { + 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() || - item->messageId() != data2.value()) { + 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(feedItem); } diff --git a/retroshare-gui/src/gui/common/RSFeedWidget.h b/retroshare-gui/src/gui/common/RSFeedWidget.h index 5932138df..f93b5a4d4 100644 --- a/retroshare-gui/src/gui/common/RSFeedWidget.h +++ b/retroshare-gui/src/gui/common/RSFeedWidget.h @@ -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 &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 &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; }; diff --git a/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp b/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp index 64b42939d..adad3ae2c 100644 --- a/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp @@ -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() diff --git a/retroshare-gui/src/gui/feeds/ChatMsgItem.h b/retroshare-gui/src/gui/feeds/ChatMsgItem.h index 2c42914d6..028493cea 100644 --- a/retroshare-gui/src/gui/feeds/ChatMsgItem.h +++ b/retroshare-gui/src/gui/feeds/ChatMsgItem.h @@ -23,20 +23,24 @@ #define _CHATMSG_ITEM_DIALOG_H #include "ui_ChatMsgItem.h" +#include "FeedItem.h" #include 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 diff --git a/retroshare-gui/src/gui/feeds/ChatMsgItem.ui b/retroshare-gui/src/gui/feeds/ChatMsgItem.ui index 1088c5d2a..2aec088e8 100644 --- a/retroshare-gui/src/gui/feeds/ChatMsgItem.ui +++ b/retroshare-gui/src/gui/feeds/ChatMsgItem.ui @@ -11,8 +11,17 @@ - - 0 + + 1 + + + 1 + + + 1 + + + 1 @@ -204,32 +213,22 @@ - - - - + + + + 0 - - - - - 0 - - - - - - 16777215 - 115 - - - - - - - - + + 0 + + + 0 + + + 0 + + Qt::NoFocus @@ -252,7 +251,7 @@ - + @@ -281,7 +280,7 @@ - + @@ -313,7 +312,7 @@ - + Qt::Horizontal @@ -326,7 +325,17 @@ - + + + + Qt::NoFocus + + + Cancel + + + + Qt::NoFocus @@ -339,13 +348,31 @@ - - - - Qt::NoFocus - - - Cancel + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 16777215 + 115 + diff --git a/retroshare-gui/src/gui/feeds/MsgItem.cpp b/retroshare-gui/src/gui/feeds/MsgItem.cpp index 7d8c41431..f153d1caf 100644 --- a/retroshare-gui/src/gui/feeds/MsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/MsgItem.cpp @@ -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() { diff --git a/retroshare-gui/src/gui/feeds/MsgItem.h b/retroshare-gui/src/gui/feeds/MsgItem.h index cb61991e7..be5f74035 100644 --- a/retroshare-gui/src/gui/feeds/MsgItem.h +++ b/retroshare-gui/src/gui/feeds/MsgItem.h @@ -23,12 +23,13 @@ #define _MSG_ITEM_DIALOG_H #include "ui_MsgItem.h" +#include "FeedItem.h" #include 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(); diff --git a/retroshare-gui/src/gui/feeds/MsgItem.ui b/retroshare-gui/src/gui/feeds/MsgItem.ui index b6d0abc98..d4c58776f 100644 --- a/retroshare-gui/src/gui/feeds/MsgItem.ui +++ b/retroshare-gui/src/gui/feeds/MsgItem.ui @@ -11,8 +11,17 @@ - - 0 + + 1 + + + 1 + + + 1 + + + 1 diff --git a/retroshare-gui/src/gui/feeds/PeerItem.cpp b/retroshare-gui/src/gui/feeds/PeerItem.cpp index 37ebe4945..31ef1b461 100644 --- a/retroshare-gui/src/gui/feeds/PeerItem.cpp +++ b/retroshare-gui/src/gui/feeds/PeerItem.cpp @@ -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() { diff --git a/retroshare-gui/src/gui/feeds/PeerItem.h b/retroshare-gui/src/gui/feeds/PeerItem.h index f47297cdb..d408e5a54 100644 --- a/retroshare-gui/src/gui/feeds/PeerItem.h +++ b/retroshare-gui/src/gui/feeds/PeerItem.h @@ -23,6 +23,7 @@ #define _PEER_ITEM_DIALOG_H #include "ui_PeerItem.h" +#include "FeedItem.h" #include 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(); diff --git a/retroshare-gui/src/gui/feeds/PeerItem.ui b/retroshare-gui/src/gui/feeds/PeerItem.ui index f5714d9eb..dcdfbdeca 100644 --- a/retroshare-gui/src/gui/feeds/PeerItem.ui +++ b/retroshare-gui/src/gui/feeds/PeerItem.ui @@ -11,8 +11,17 @@ - - 0 + + 1 + + + 1 + + + 1 + + + 1 diff --git a/retroshare-gui/src/gui/feeds/SecurityItem.cpp b/retroshare-gui/src/gui/feeds/SecurityItem.cpp index 650342fb7..1700a8117 100644 --- a/retroshare-gui/src/gui/feeds/SecurityItem.cpp +++ b/retroshare-gui/src/gui/feeds/SecurityItem.cpp @@ -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() diff --git a/retroshare-gui/src/gui/feeds/SecurityItem.h b/retroshare-gui/src/gui/feeds/SecurityItem.h index 4c8762b2d..396ee6fa1 100644 --- a/retroshare-gui/src/gui/feeds/SecurityItem.h +++ b/retroshare-gui/src/gui/feeds/SecurityItem.h @@ -23,6 +23,7 @@ #define _SECURITY_ITEM_DIALOG_H #include "ui_SecurityItem.h" +#include "FeedItem.h" #include //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; diff --git a/retroshare-gui/src/gui/feeds/SecurityItem.ui b/retroshare-gui/src/gui/feeds/SecurityItem.ui index 21b59b826..44a49244f 100644 --- a/retroshare-gui/src/gui/feeds/SecurityItem.ui +++ b/retroshare-gui/src/gui/feeds/SecurityItem.ui @@ -11,8 +11,17 @@ - - 0 + + 1 + + + 1 + + + 1 + + + 1 diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp index 08a2c5d2e..0607c778c 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp @@ -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(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); }