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
This commit is contained in:
defnax 2010-05-20 21:00:59 +00:00
parent 00e5dc311f
commit d2baf4902d
7 changed files with 628 additions and 23 deletions

View File

@ -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 \

View File

@ -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)
{

View File

@ -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;

View File

@ -18,7 +18,7 @@
</property>
<layout class="QGridLayout">
<property name="margin">
<number>0</number>
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QFrame" name="frame">
@ -29,8 +29,11 @@
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">QFrame#frame{border: 2px solid black;
background: white;}</string>
<string notr="true">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);}</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>

View File

@ -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 <QtGui>
#include "BlogNewItem.h"
#include "FeedHolder.h"
#include "rsiface/rsblogs.h"
#define BLOG_DEFAULT_IMAGE ":/images/hi64-app-kblogger.png"
#include <iostream>
/****
* #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();
}

View File

@ -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 <string>
#include <stdint.h>
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

View File

@ -0,0 +1,296 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BlogNewItem</class>
<widget class="QWidget" name="BlogNewItem">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>643</width>
<height>158</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout">
<property name="margin">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">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);}</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout">
<property name="topMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QPushButton" name="clearButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Remove Item</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/close_normal.png</normaloff>:/images/close_normal.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="titleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>New Blog</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="logo_label">
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="text">
<string>Logo</string>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="nameLabel">
<property name="text">
<string>name</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>500</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="subscribeButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt;Subscribe to Blog&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/directoryadd_24x24_shadow.png</normaloff>:/images/directoryadd_24x24_shadow.png</iconset>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="expandButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Expand</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/edit_add24.png</normaloff>:/images/edit_add24.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QFrame" name="expandFrame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Blog Decscription</string>
</property>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="iconLabel">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/contacts24.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="descLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Description
of Blog</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>