From d2baf4902d99e97937c0035a023f2dc627dd0adb Mon Sep 17 00:00:00 2001 From: defnax Date: Thu, 20 May 2010 21:00:59 +0000 Subject: [PATCH] Added Blog New Item to News Feed. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2962 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/RetroShare.pro | 3 + retroshare-gui/src/gui/NewsFeed.cpp | 27 +- retroshare-gui/src/gui/NewsFeed.h | 35 +-- retroshare-gui/src/gui/feeds/BlogMsgItem.ui | 9 +- retroshare-gui/src/gui/feeds/BlogNewItem.cpp | 213 +++++++++++++ retroshare-gui/src/gui/feeds/BlogNewItem.h | 68 +++++ retroshare-gui/src/gui/feeds/BlogNewItem.ui | 296 +++++++++++++++++++ 7 files changed, 628 insertions(+), 23 deletions(-) create mode 100644 retroshare-gui/src/gui/feeds/BlogNewItem.cpp create mode 100644 retroshare-gui/src/gui/feeds/BlogNewItem.h create mode 100644 retroshare-gui/src/gui/feeds/BlogNewItem.ui diff --git a/retroshare-gui/src/RetroShare.pro b/retroshare-gui/src/RetroShare.pro index 2d94d0b22..997a32332 100644 --- a/retroshare-gui/src/RetroShare.pro +++ b/retroshare-gui/src/RetroShare.pro @@ -274,6 +274,7 @@ HEADERS += rshare.h \ gui/feeds/MsgItem.h \ gui/feeds/ChanNewItem.h \ gui/feeds/ChanMsgItem.h \ + gui/feeds/BlogNewItem.h \ gui/feeds/BlogMsgItem.h \ gui/feeds/SubFileItem.h \ gui/feeds/SubDestItem.h \ @@ -348,6 +349,7 @@ FORMS += gui/StartDialog.ui \ gui/feeds/MsgItem.ui \ gui/feeds/ChanNewItem.ui \ gui/feeds/ChanMsgItem.ui \ + gui/feeds/BlogNewItem.ui \ gui/feeds/BlogMsgItem.ui \ gui/feeds/SubFileItem.ui \ gui/feeds/SubDestItem.ui \ @@ -473,6 +475,7 @@ SOURCES += main.cpp \ gui/feeds/MsgItem.cpp \ gui/feeds/ChanNewItem.cpp \ gui/feeds/ChanMsgItem.cpp \ + gui/feeds/BlogNewItem.cpp \ gui/feeds/BlogMsgItem.cpp \ gui/feeds/SubFileItem.cpp \ gui/feeds/SubDestItem.cpp \ diff --git a/retroshare-gui/src/gui/NewsFeed.cpp b/retroshare-gui/src/gui/NewsFeed.cpp index ac937231b..2d6b46c11 100644 --- a/retroshare-gui/src/gui/NewsFeed.cpp +++ b/retroshare-gui/src/gui/NewsFeed.cpp @@ -30,9 +30,10 @@ #include "feeds/ChanMsgItem.h" #include "feeds/ForumNewItem.h" #include "feeds/ForumMsgItem.h" -#include "feeds/PeerItem.h" +#include "feeds/BlogNewItem.h" #include "feeds/BlogMsgItem.h" #include "feeds/MsgItem.h" +#include "feeds/PeerItem.h" #include "settings/rsharesettings.h" @@ -44,8 +45,9 @@ const uint32_t NEWSFEED_FORUMNEWLIST = 0x0002; const uint32_t NEWSFEED_FORUMMSGLIST = 0x0003; const uint32_t NEWSFEED_CHANNEWLIST = 0x0004; const uint32_t NEWSFEED_CHANMSGLIST = 0x0005; -const uint32_t NEWSFEED_BLOGMSGLIST = 0x0006; -const uint32_t NEWSFEED_MESSAGELIST = 0x0007; +const uint32_t NEWSFEED_BLOGNEWLIST = 0x0006; +const uint32_t NEWSFEED_BLOGMSGLIST = 0x0007; +const uint32_t NEWSFEED_MESSAGELIST = 0x0008; /***** * #define NEWS_DEBUG 1 @@ -125,6 +127,10 @@ void NewsFeed::updateFeed() addFeedItemForumMsg(fi); break; + case RS_FEED_ITEM_BLOG_NEW: + if (flags & RS_FEED_TYPE_BLOG) + addFeedItemBlogNew(fi); + break; case RS_FEED_ITEM_BLOG_MSG: if (flags & RS_FEED_TYPE_BLOG) addFeedItemBlogMsg(fi); @@ -323,6 +329,21 @@ void NewsFeed::addFeedItemForumMsg(RsFeedItem &fi) #endif } +void NewsFeed::addFeedItemBlogNew(RsFeedItem &fi) +{ + /* make new widget */ + BlogNewItem *bni = new BlogNewItem(this, NEWSFEED_BLOGNEWLIST, fi.mId1, false, true); + + /* store in list */ + + /* add to layout */ + verticalLayout->addWidget(bni); + +#ifdef NEWS_DEBUG + std::cerr << "NewsFeed::addFeedItemBlogNew()"; + std::cerr << std::endl; +#endif +} void NewsFeed::addFeedItemBlogMsg(RsFeedItem &fi) { diff --git a/retroshare-gui/src/gui/NewsFeed.h b/retroshare-gui/src/gui/NewsFeed.h index 6e5e9d180..aa1611537 100644 --- a/retroshare-gui/src/gui/NewsFeed.h +++ b/retroshare-gui/src/gui/NewsFeed.h @@ -41,9 +41,9 @@ public: /** Default Destructor */ /* FeedHolder Functions (for FeedItem functionality) */ -virtual void deleteFeedItem(QWidget *item, uint32_t type); -virtual void openChat(std::string peerId); -virtual void openMsg(uint32_t type, std::string grpId, std::string inReplyTo); + virtual void deleteFeedItem(QWidget *item, uint32_t type); + virtual void openChat(std::string peerId); + virtual void openMsg(uint32_t type, std::string grpId, std::string inReplyTo); private slots: // void toggleChanMsgItems(bool on); @@ -52,20 +52,21 @@ private slots: private: -void addFeedItemPeerConnect(RsFeedItem &fi); -void addFeedItemPeerDisconnect(RsFeedItem &fi); -void addFeedItemPeerNew(RsFeedItem &fi); -void addFeedItemPeerHello(RsFeedItem &fi); -void addFeedItemChanNew(RsFeedItem &fi); -void addFeedItemChanUpdate(RsFeedItem &fi); -void addFeedItemChanMsg(RsFeedItem &fi); -void addFeedItemForumNew(RsFeedItem &fi); -void addFeedItemForumUpdate(RsFeedItem &fi); -void addFeedItemForumMsg(RsFeedItem &fi); -void addFeedItemBlogMsg(RsFeedItem &fi); -void addFeedItemChatNew(RsFeedItem &fi); -void addFeedItemMessage(RsFeedItem &fi); -void addFeedItemFilesNew(RsFeedItem &fi); + void addFeedItemPeerConnect(RsFeedItem &fi); + void addFeedItemPeerDisconnect(RsFeedItem &fi); + void addFeedItemPeerNew(RsFeedItem &fi); + void addFeedItemPeerHello(RsFeedItem &fi); + void addFeedItemChanNew(RsFeedItem &fi); + void addFeedItemChanUpdate(RsFeedItem &fi); + void addFeedItemChanMsg(RsFeedItem &fi); + void addFeedItemForumNew(RsFeedItem &fi); + void addFeedItemForumUpdate(RsFeedItem &fi); + void addFeedItemForumMsg(RsFeedItem &fi); + void addFeedItemBlogNew(RsFeedItem &fi); + void addFeedItemBlogMsg(RsFeedItem &fi); + void addFeedItemChatNew(RsFeedItem &fi); + void addFeedItemMessage(RsFeedItem &fi); + void addFeedItemFilesNew(RsFeedItem &fi); ; QLayout *mLayout; diff --git a/retroshare-gui/src/gui/feeds/BlogMsgItem.ui b/retroshare-gui/src/gui/feeds/BlogMsgItem.ui index ceba88428..56e8d775b 100644 --- a/retroshare-gui/src/gui/feeds/BlogMsgItem.ui +++ b/retroshare-gui/src/gui/feeds/BlogMsgItem.ui @@ -18,7 +18,7 @@ - 0 + 6 @@ -29,8 +29,11 @@ - QFrame#frame{border: 2px solid black; -background: white;} + QFrame#frame{ +border: 2px solid #6ACEFF; +border-radius: 10px; +background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, +stop:0 #0076B1, stop:1 #12A3EB);} QFrame::StyledPanel diff --git a/retroshare-gui/src/gui/feeds/BlogNewItem.cpp b/retroshare-gui/src/gui/feeds/BlogNewItem.cpp new file mode 100644 index 000000000..ccb2c83f6 --- /dev/null +++ b/retroshare-gui/src/gui/feeds/BlogNewItem.cpp @@ -0,0 +1,213 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2008 Robert Fernie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ +#include + +#include "BlogNewItem.h" +#include "FeedHolder.h" + +#include "rsiface/rsblogs.h" + +#define BLOG_DEFAULT_IMAGE ":/images/hi64-app-kblogger.png" + +#include + +/**** + * #define DEBUG_ITEM 1 + ****/ + +/** Constructor */ +BlogNewItem::BlogNewItem(FeedHolder *parent, uint32_t feedId, std::string blogId, bool isHome, bool isNew) +:QWidget(NULL), mParent(parent), mFeedId(feedId), + mBlogId(blogId), mIsHome(isHome), mIsNew(isNew) +{ + /* Invoke the Qt Designer generated object setup routine */ + setupUi(this); + + setAttribute ( Qt::WA_DeleteOnClose, true ); + + /* general ones */ + connect( expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggle ( void ) ) ); + connect( clearButton, SIGNAL( clicked( void ) ), this, SLOT( removeItem ( void ) ) ); + + /* specific ones */ + connect( subscribeButton, SIGNAL( clicked( void ) ), this, SLOT( subscribeBlog ( void ) ) ); + + small(); + updateItemStatic(); + updateItem(); +} + + +void BlogNewItem::updateItemStatic() +{ + if (!rsBlogs) + return; + + + /* fill in */ +#ifdef DEBUG_ITEM + std::cerr << "BlogNewItem::updateItemStatic()"; + std::cerr << std::endl; +#endif + + BlogInfo bi; + if (rsBlogs->getBlogInfo(mBlogId, bi)) + { + nameLabel->setText(QString::fromStdWString(bi.blogName)); + + descLabel->setText(QString::fromStdWString(bi.blogDesc)); + + if(bi.pngImageLen != 0){ + + QPixmap blogImage; + blogImage.loadFromData(bi.pngChanImage, bi.pngImageLen, "PNG"); + logo_label->setPixmap(QPixmap(blogImage)); + }else{ + QPixmap defaulImage(BLOG_DEFAULT_IMAGE); + logo_label->setPixmap(QPixmap(defaulImage)); + } + + if (bi.blogFlags & RS_DISTRIB_SUBSCRIBED) + { + subscribeButton->setEnabled(false); + //postButton->setEnabled(true); + } + else + { + subscribeButton->setEnabled(true); + //postButton->setEnabled(false); + } + + + /* should also check the other flags */ + } + else + { + nameLabel->setText("Unknown Blog"); + titleLabel->setText("Blog ???"); + descLabel->setText(""); + } + + if (mIsNew) + { + titleLabel->setText("New Blog"); + } + else + { + titleLabel->setText("Updated Blog"); + } + + if (mIsHome) + { + /* disable buttons */ + clearButton->setEnabled(false); + //gotoButton->setEnabled(false); + } +} + + +void BlogNewItem::updateItem() +{ + /* fill in */ +#ifdef DEBUG_ITEM + std::cerr << "BlogNewItem::updateItem()"; + std::cerr << std::endl; +#endif + +} + + +void BlogNewItem::small() +{ + expandFrame->hide(); +} + +void BlogNewItem::toggle() +{ + if (expandFrame->isHidden()) + { + expandFrame->show(); + expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png"))); + expandButton->setToolTip("Hide"); + } + else + { + expandFrame->hide(); + expandButton->setIcon(QIcon(QString(":/images/edit_add24.png"))); + expandButton->setToolTip("Expand"); + } +} + + +void BlogNewItem::removeItem() +{ +#ifdef DEBUG_ITEM + std::cerr << "BlogNewItem::removeItem()"; + std::cerr << std::endl; +#endif + hide(); + if (mParent) + { + mParent->deleteFeedItem(this, mFeedId); + } +} + + +void BlogNewItem::gotoHome() +{ +#ifdef DEBUG_ITEM + std::cerr << "BlogNewItem::gotoHome()"; + std::cerr << std::endl; +#endif +} + +/*********** SPECIFIC FUNCTIOSN ***********************/ + + +void BlogNewItem::unsubscribeBlog() +{ +#ifdef DEBUG_ITEM + std::cerr << "BlogNewItem::unsubscribeBlog()"; + std::cerr << std::endl; +#endif + if (rsBlogs) + { + rsBlogs->blogSubscribe(mBlogId, false); + } + updateItemStatic(); +} + + +void BlogNewItem::subscribeBlog() +{ +#ifdef DEBUG_ITEM + std::cerr << "BlogNewItem::subscribeBlog()"; + std::cerr << std::endl; +#endif + if (rsBlogs) + { + rsBlogs->blogSubscribe(mBlogId, true); + } + updateItemStatic(); +} + + + diff --git a/retroshare-gui/src/gui/feeds/BlogNewItem.h b/retroshare-gui/src/gui/feeds/BlogNewItem.h new file mode 100644 index 000000000..255a1f9a5 --- /dev/null +++ b/retroshare-gui/src/gui/feeds/BlogNewItem.h @@ -0,0 +1,68 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2008 Robert Fernie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + +#ifndef _BLOG_NEW_ITEM_DIALOG_H +#define _BLOG_NEW_ITEM_DIALOG_H + +#include "ui_BlogNewItem.h" + +#include +#include + +class FeedHolder; + +class BlogNewItem : public QWidget, private Ui::BlogNewItem +{ + Q_OBJECT + +public: + /** Default Constructor */ + BlogNewItem(FeedHolder *parent, uint32_t feedId, std::string blogId, bool isHome, bool isNew); + + /** Default Destructor */ + + void updateItemStatic(); + void small(); + +private slots: + /* default stuff */ + void gotoHome(); + void removeItem(); + void toggle(); + + void unsubscribeBlog(); + void subscribeBlog(); + + void updateItem(); + +private: + FeedHolder *mParent; + uint32_t mFeedId; + + std::string mBlogId; + bool mIsHome; + bool mIsNew; +}; + + + +#endif + diff --git a/retroshare-gui/src/gui/feeds/BlogNewItem.ui b/retroshare-gui/src/gui/feeds/BlogNewItem.ui new file mode 100644 index 000000000..455fd35ee --- /dev/null +++ b/retroshare-gui/src/gui/feeds/BlogNewItem.ui @@ -0,0 +1,296 @@ + + + BlogNewItem + + + + 0 + 0 + 643 + 158 + + + + Form + + + + 6 + + + + + + 0 + 0 + + + + QFrame#frame{ +border: 2px solid #6ACEFF; +border-radius: 10px; +background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, +stop:0 #0076B1, stop:1 #12A3EB);} + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 6 + + + 6 + + + + + + + + 0 + 0 + + + + Remove Item + + + + + + + :/images/close_normal.png:/images/close_normal.png + + + + + + + + 0 + 0 + + + + + 75 + true + true + + + + New Blog + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 32 + 32 + + + + Logo + + + true + + + + + + + name + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 500 + 20 + + + + + + + + + 0 + 0 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Subscribe to Blog</span></p></body></html> + + + + + + + :/images/directoryadd_24x24_shadow.png:/images/directoryadd_24x24_shadow.png + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + Expand + + + + + + + :/images/edit_add24.png:/images/edit_add24.png + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 0 + + + + + Blog Decscription + + + + + + + + + :/images/contacts24.png + + + + + + + + 0 + 0 + + + + Description + of Blog + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +