Friends Storm:

- Don't update the connection time of the PeerItem. Only show the real connection time.
- Removed memory leak. All PeerItems are only set to invisible and wasn't deleted.
- Added button to remove all items.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3754 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-11-06 19:13:33 +00:00
parent c19c8b5532
commit 2122dd8351
4 changed files with 58 additions and 19 deletions

View File

@ -64,11 +64,11 @@ NewsFeed::NewsFeed(QWidget *parent)
/* Invoke the Qt Designer generated object setup routine */
setupUi(this);
connect(removeAllButton, SIGNAL(clicked()), this, SLOT(removeAll()));
QTimer *timer = new QTimer(this);
timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateFeed()));
timer->start(1000);
}
@ -157,6 +157,11 @@ void NewsFeed::updateFeed()
void NewsFeed::addFeedItem(QWidget *item)
{
item->setAttribute(Qt::WA_DeleteOnClose, true);
connect(item, SIGNAL(destroyed(QObject*)), this, SLOT(itemDestroyed(QObject*)));
widgetList.push_back(item);
if (Settings->getAddFeedsAtEnd()) {
verticalLayout->addWidget(item);
} else {
@ -440,3 +445,26 @@ void NewsFeed::openChat(std::string peerId)
PopupChatDialog::chatFriend(peerId);
}
void NewsFeed::itemDestroyed(QObject *item)
{
int index = widgetList.indexOf(item);
if (index >= 0) {
widgetList.removeAt(index);
}
}
void NewsFeed::removeAll()
{
#ifdef NEWS_DEBUG
std::cerr << "NewsFeed::removeAll()" << std::endl;
#endif
while (widgetList.count()) {
QObject *item = widgetList.first();
widgetList.pop_front();
if (item) {
item->deleteLater();
}
}
}

View File

@ -48,7 +48,9 @@ public:
private slots:
// void toggleChanMsgItems(bool on);
void updateFeed();
void updateFeed();
void removeAll();
void itemDestroyed(QObject*);
private:
void addFeedItem(QWidget *item);
@ -70,6 +72,7 @@ private:
void addFeedItemFilesNew(RsFeedItem &fi);
QLayout *mLayout;
QObjectList widgetList;
/* lists of feedItems */
std::list<ForumNewItem *> mForumNewItems;

View File

@ -70,20 +70,7 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>321</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="2">
<item row="1" column="0" colspan="4">
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
@ -142,6 +129,26 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="removeAllButton">
<property name="text">
<string>Remove All</string>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>321</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>

View File

@ -122,6 +122,10 @@ void PeerItem::updateItemStatic()
QString peername = QString::fromStdString(details.name);
peernameLabel->setText(nameStr.arg(peername));
QDateTime date = QDateTime::fromTime_t(details.lastConnect);
QString stime = date.toString(Qt::LocalDate);
lastLabel-> setText(stime);
/* expanded Info */
nameLabel->setText(QString::fromStdString(details.name));
idLabel->setText(QString::fromStdString(details.id));
@ -198,9 +202,6 @@ void PeerItem::updateItem()
}
connLabel->setText(QString::fromStdString(details.autoconnect));
QDateTime date = QDateTime::fromTime_t(details.lastConnect);
QString stime = date.toString(Qt::LocalDate);
lastLabel-> setText(stime);
/* do buttons */
chatButton->setEnabled(details.state & RS_PEER_STATE_CONNECTED);