fixed to not stretch News Feed items when you has one few items in News Feed.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2227 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2010-02-07 15:47:30 +00:00
parent 57454e0486
commit dcfdaf44e0
2 changed files with 103 additions and 76 deletions

View File

@ -58,29 +58,6 @@ NewsFeed::NewsFeed(QWidget *parent)
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
setupUi(this); setupUi(this);
/* mLayout -> to add widgets to */
mLayout = new QVBoxLayout;
mLayout->setSpacing(0);
mLayout->setMargin(0);
QWidget *middleWidget = new QWidget();
//middleWidget->setSizePolicy( QSizePolicy::Policy::Maximum, QSizePolicy::Policy::Minimum);
middleWidget->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
middleWidget->setLayout(mLayout);
QScrollArea *scrollArea = new QScrollArea;
//scrollArea->setBackgroundRole(QPalette::Dark);
scrollArea->setWidget(middleWidget);
scrollArea->setWidgetResizable(true);
scrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
QVBoxLayout *layout2 = new QVBoxLayout;
layout2->addWidget(scrollArea);
layout2->setSpacing(0);
layout2->setMargin(0);
frame->setLayout(layout2);
QTimer *timer = new QTimer(this); QTimer *timer = new QTimer(this);
timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateFeed())); timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateFeed()));
@ -178,7 +155,7 @@ void NewsFeed::addFeedItemPeerConnect(RsFeedItem &fi)
/* store */ /* store */
/* add to layout */ /* add to layout */
mLayout->addWidget(pi); verticalLayout->addWidget(pi);
#ifdef NEWS_DEBUG #ifdef NEWS_DEBUG
std::cerr << "NewsFeed::addFeedItemPeerConnect()"; std::cerr << "NewsFeed::addFeedItemPeerConnect()";
@ -196,7 +173,7 @@ void NewsFeed::addFeedItemPeerDisconnect(RsFeedItem &fi)
/* store */ /* store */
/* add to layout */ /* add to layout */
mLayout->addWidget(pi); verticalLayout->addWidget(pi);
@ -215,7 +192,7 @@ void NewsFeed::addFeedItemPeerHello(RsFeedItem &fi)
/* store */ /* store */
/* add to layout */ /* add to layout */
mLayout->addWidget(pi); verticalLayout->addWidget(pi);
#ifdef NEWS_DEBUG #ifdef NEWS_DEBUG
@ -233,7 +210,7 @@ void NewsFeed::addFeedItemPeerNew(RsFeedItem &fi)
/* store */ /* store */
/* add to layout */ /* add to layout */
mLayout->addWidget(pi); verticalLayout->addWidget(pi);
#ifdef NEWS_DEBUG #ifdef NEWS_DEBUG
std::cerr << "NewsFeed::addFeedItemPeerNew()"; std::cerr << "NewsFeed::addFeedItemPeerNew()";
@ -250,7 +227,7 @@ void NewsFeed::addFeedItemChanNew(RsFeedItem &fi)
/* store in list */ /* store in list */
/* add to layout */ /* add to layout */
mLayout->addWidget(cni); verticalLayout->addWidget(cni);
#ifdef NEWS_DEBUG #ifdef NEWS_DEBUG
std::cerr << "NewsFeed::addFeedItemChanNew()"; std::cerr << "NewsFeed::addFeedItemChanNew()";
@ -267,7 +244,7 @@ void NewsFeed::addFeedItemChanUpdate(RsFeedItem &fi)
/* store in list */ /* store in list */
/* add to layout */ /* add to layout */
mLayout->addWidget(cni); verticalLayout->addWidget(cni);
#ifdef NEWS_DEBUG #ifdef NEWS_DEBUG
std::cerr << "NewsFeed::addFeedItemChanUpdate()"; std::cerr << "NewsFeed::addFeedItemChanUpdate()";
@ -284,7 +261,7 @@ void NewsFeed::addFeedItemChanMsg(RsFeedItem &fi)
/* store in forum list */ /* store in forum list */
/* add to layout */ /* add to layout */
mLayout->addWidget(cm); verticalLayout->addWidget(cm);
#ifdef NEWS_DEBUG #ifdef NEWS_DEBUG
std::cerr << "NewsFeed::addFeedItemChanMsg()"; std::cerr << "NewsFeed::addFeedItemChanMsg()";
@ -302,7 +279,7 @@ void NewsFeed::addFeedItemForumNew(RsFeedItem &fi)
mForumNewItems.push_back(fni); mForumNewItems.push_back(fni);
/* add to layout */ /* add to layout */
mLayout->addWidget(fni); verticalLayout->addWidget(fni);
#ifdef NEWS_DEBUG #ifdef NEWS_DEBUG
@ -321,7 +298,7 @@ void NewsFeed::addFeedItemForumUpdate(RsFeedItem &fi)
mForumNewItems.push_back(fni); mForumNewItems.push_back(fni);
/* add to layout */ /* add to layout */
mLayout->addWidget(fni); verticalLayout->addWidget(fni);
#ifdef NEWS_DEBUG #ifdef NEWS_DEBUG
std::cerr << "NewsFeed::addFeedItemForumUpdate()"; std::cerr << "NewsFeed::addFeedItemForumUpdate()";
@ -338,7 +315,7 @@ void NewsFeed::addFeedItemForumMsg(RsFeedItem &fi)
/* store in forum list */ /* store in forum list */
/* add to layout */ /* add to layout */
mLayout->addWidget(fm); verticalLayout->addWidget(fm);
#ifdef NEWS_DEBUG #ifdef NEWS_DEBUG
std::cerr << "NewsFeed::addFeedItemForumMsg()"; std::cerr << "NewsFeed::addFeedItemForumMsg()";
@ -355,7 +332,7 @@ void NewsFeed::addFeedItemBlogMsg(RsFeedItem &fi)
/* store in forum list */ /* store in forum list */
/* add to layout */ /* add to layout */
mLayout->addWidget(bm); verticalLayout->addWidget(bm);
#ifdef NEWS_DEBUG #ifdef NEWS_DEBUG
std::cerr << "NewsFeed::addFeedItemBlogMsg()"; std::cerr << "NewsFeed::addFeedItemBlogMsg()";
@ -381,7 +358,7 @@ void NewsFeed::addFeedItemMessage(RsFeedItem &fi)
/* store in list */ /* store in list */
/* add to layout */ /* add to layout */
mLayout->addWidget(mi); verticalLayout->addWidget(mi);
#ifdef NEWS_DEBUG #ifdef NEWS_DEBUG
std::cerr << "NewsFeed::addFeedItemMessage()"; std::cerr << "NewsFeed::addFeedItemMessage()";

View File

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>NewsFeed</class> <class>NewsFeed</class>
<widget class="QWidget" name="NewsFeed"> <widget class="QWidget" name="NewsFeed">
@ -39,34 +40,34 @@
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" > <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <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>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css"> &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; } p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> &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=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;img src=":/images/konqsidebar_news16.png" />&lt;/p>&lt;/body>&lt;/html></string> &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;img src=&quot;:/images/konqsidebar_news16.png&quot; /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLabel" name="newslabel"> <widget class="QLabel" name="newslabel">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" > <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <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>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css"> &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; } p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> &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=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-size:9pt; font-weight:600;">News Feed&lt;/span>&lt;/p>&lt;/body>&lt;/html></string> &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:9pt; font-weight:600;&quot;&gt;News Feed&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -93,6 +94,55 @@ p, li { white-space: pre-wrap; }
<property name="frameShadow"> <property name="frameShadow">
<enum>QFrame::Raised</enum> <enum>QFrame::Raised</enum>
</property> </property>
<layout class="QGridLayout" name="gridLayout_3">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QScrollArea" name="scrollArea">
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>424</width>
<height>229</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout"/>
</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>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
</layout> </layout>