FeedReader

- fixed crash at startup
- added some toolbar icons
- added QTimer to message navigation

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6052 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-12-28 00:42:27 +00:00
parent 24a40fc665
commit 4804f950af
13 changed files with 187 additions and 17 deletions

View File

@ -25,14 +25,7 @@
<number>0</number>
</property>
<item>
<widget class="HeaderFrame" name="headerFrame">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>64</height>
</size>
</property>
</widget>
<widget class="HeaderFrame" name="headerFrame"/>
</item>
<item>
<widget class="QFrame" name="frame">

View File

@ -68,11 +68,14 @@ FeedReaderDialog::FeedReaderDialog(RsFeedReader *feedReader, QWidget *parent)
connect(mNotify, SIGNAL(notifyMsgChanged(QString,QString,int)), this, SLOT(msgChanged(QString,QString,int)));
/* connect signals */
connect(ui->feedTreeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(feedItemChanged(QTreeWidgetItem*)));
connect(ui->feedTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(feedItemChanged(QTreeWidgetItem*)));
connect(ui->messageTabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(messageTabCloseRequested(int)));
connect(ui->feedTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(feedTreeCustomPopupMenu(QPoint)));
connect(ui->feedAddButton, SIGNAL(clicked()), this, SLOT(newFeed()));
connect(ui->feedProcessButton, SIGNAL(clicked()), this, SLOT(processFeed()));
mFeedCompareRole = new RSTreeWidgetItemCompareRole;
mFeedCompareRole->setRole(COLUMN_FEED_NAME, ROLE_FEED_SORT);
@ -98,6 +101,8 @@ FeedReaderDialog::FeedReaderDialog(RsFeedReader *feedReader, QWidget *parent)
ui->feedTreeWidget->sortItems(COLUMN_FEED_NAME, Qt::AscendingOrder);
ui->feedTreeWidget->installEventFilter(this);
feedItemChanged(NULL);
}
FeedReaderDialog::~FeedReaderDialog()
@ -536,13 +541,20 @@ FeedReaderMessageWidget *FeedReaderDialog::feedMessageWidget(const std::string &
void FeedReaderDialog::feedItemChanged(QTreeWidgetItem *item)
{
if (!item) {
ui->feedAddButton->setEnabled(false);
ui->feedProcessButton->setEnabled(false);
return;
}
ui->feedProcessButton->setEnabled(true);
if (item->data(COLUMN_FEED_DATA, ROLE_FEED_FOLDER).toBool()) {
ui->feedAddButton->setEnabled(true);
return;
}
ui->feedAddButton->setEnabled(false);
std::string feedId = item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toString().toStdString();
/* search exisiting tab */
FeedReaderMessageWidget *messageWidget = feedMessageWidget(feedId);

View File

@ -82,6 +82,34 @@
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="feedAddButton">
<property name="toolTip">
<string>Add new feed</string>
</property>
<property name="icon">
<iconset resource="FeedReader_images.qrc">
<normaloff>:/images/FeedAdd.png</normaloff>:/images/FeedAdd.png</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="feedProcessButton">
<property name="toolTip">
<string>Update feed</string>
</property>
<property name="icon">
<iconset resource="FeedReader_images.qrc">
<normaloff>:/images/FeedProcess.png</normaloff>:/images/FeedProcess.png</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View File

@ -3,6 +3,7 @@
#include <QKeyEvent>
#include <QClipboard>
#include <QDesktopServices>
#include <QTimer>
#include "FeedReaderMessageWidget.h"
#include "ui_FeedReaderMessageWidget.h"
@ -51,6 +52,18 @@ FeedReaderMessageWidget::FeedReaderMessageWidget(const std::string &feedId, RsFe
connect(ui->linkButton, SIGNAL(clicked()), this, SLOT(openLinkMsg()));
connect(ui->expandButton, SIGNAL(clicked()), this, SLOT(toggleMsgText()));
connect(ui->msgReadButton, SIGNAL(clicked()), this, SLOT(markAsReadMsg()));
connect(ui->msgUnreadButton, SIGNAL(clicked()), this, SLOT(markAsUnreadMsg()));
connect(ui->msgReadAllButton, SIGNAL(clicked()), this, SLOT(markAllAsReadMsg()));
connect(ui->msgRemoveButton, SIGNAL(clicked()), this, SLOT(removeMsg()));
connect(ui->feedProcessButton, SIGNAL(clicked()), this, SLOT(processFeed()));
// create timer for navigation
timer = new QTimer(this);
timer->setInterval(300);
timer->setSingleShot(true);
connect(timer, SIGNAL(timeout()), this, SLOT(updateCurrentMessage()));
mMsgCompareRole = new RSTreeWidgetItemCompareRole;
mMsgCompareRole->setRole(COLUMN_MSG_TITLE, ROLE_MSG_SORT);
mMsgCompareRole->setRole(COLUMN_MSG_READ, ROLE_MSG_SORT);
@ -108,10 +121,15 @@ FeedReaderMessageWidget::FeedReaderMessageWidget(const std::string &feedId, RsFe
}
updateMsgs();
updateCurrentMessage();
}
FeedReaderMessageWidget::~FeedReaderMessageWidget()
{
// stop and delete timer
timer->stop();
delete(timer);
/* save settings */
processSettings(false);
@ -452,10 +470,21 @@ void FeedReaderMessageWidget::msgItemClicked(QTreeWidgetItem *item, int column)
setMsgAsReadUnread(rows, !read);
return;
}
// show current message directly
updateCurrentMessage();
}
void FeedReaderMessageWidget::msgItemChanged()
{
timer->stop();
timer->start();
}
void FeedReaderMessageWidget::updateCurrentMessage()
{
timer->stop();
long todo; // show link somewhere
std::string msgId = currentMsgId();
@ -465,6 +494,11 @@ void FeedReaderMessageWidget::msgItemChanged()
// ui->msgLink->clear();
ui->msgText->clear();
ui->linkButton->setEnabled(false);
ui->msgReadButton->setEnabled(false);
ui->msgUnreadButton->setEnabled(false);
ui->msgReadAllButton->setEnabled(false);
ui->msgRemoveButton->setEnabled(false);
return;
}
@ -475,9 +509,19 @@ void FeedReaderMessageWidget::msgItemChanged()
// ui->msgLink->clear();
ui->msgText->clear();
ui->linkButton->setEnabled(false);
ui->msgReadButton->setEnabled(false);
ui->msgUnreadButton->setEnabled(false);
ui->msgReadAllButton->setEnabled(false);
ui->msgRemoveButton->setEnabled(false);
return;
}
ui->msgReadButton->setEnabled(true);
ui->msgUnreadButton->setEnabled(true);
ui->msgReadAllButton->setEnabled(true);
ui->msgRemoveButton->setEnabled(true);
/* get msg */
FeedMsgInfo msgInfo;
if (!mFeedReader->getMsgInfo(mFeedId, msgId, msgInfo)) {
@ -657,6 +701,15 @@ void FeedReaderMessageWidget::removeMsg()
mFeedReader->removeMsgs(mFeedId, msgIds);
}
void FeedReaderMessageWidget::processFeed()
{
if (mFeedId.empty()) {
return;
}
mFeedReader->processFeed(mFeedId);
}
void FeedReaderMessageWidget::copyLinkMsg()
{
QTreeWidgetItem *item = ui->msgTreeWidget->currentItem();

View File

@ -7,6 +7,7 @@ namespace Ui {
class FeedReaderMessageWidget;
}
class QTimer;
class FeedMsgInfo;
class QTreeWidgetItem;
class RSTreeWidgetItemCompareRole;
@ -34,6 +35,7 @@ signals:
private slots:
void msgTreeCustomPopupMenu(QPoint point);
void updateCurrentMessage();
void msgItemChanged();
void msgItemClicked(QTreeWidgetItem *item, int column);
void filterColumnChanged(int column);
@ -44,6 +46,7 @@ private slots:
void markAllAsReadMsg();
void copyLinksMsg();
void removeMsg();
void processFeed();
void openLinkMsg();
void copyLinkMsg();
@ -67,6 +70,7 @@ private:
std::string mFeedId;
QString mFeedName;
unsigned int mUnreadCount;
QTimer *timer;
// gui interface
RsFeedReader *mFeedReader;

View File

@ -39,6 +39,79 @@
<property name="margin">
<number>2</number>
</property>
<item>
<widget class="QToolButton" name="msgReadButton">
<property name="toolTip">
<string>Mark messages as read</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="FeedReader_images.qrc">
<normaloff>:/images/FeedMsgRead.png</normaloff>:/images/FeedMsgRead.png</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="msgUnreadButton">
<property name="toolTip">
<string>Mark messages as unread</string>
</property>
<property name="icon">
<iconset resource="FeedReader_images.qrc">
<normaloff>:/images/FeedMsgUnread.png</normaloff>:/images/FeedMsgUnread.png</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="msgReadAllButton">
<property name="toolTip">
<string>Mark all messages as read</string>
</property>
<property name="icon">
<iconset resource="FeedReader_images.qrc">
<normaloff>:/images/FeedMsgReadAll.png</normaloff>:/images/FeedMsgReadAll.png</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="msgRemoveButton">
<property name="toolTip">
<string>Remove messages</string>
</property>
<property name="icon">
<iconset resource="FeedReader_images.qrc">
<normaloff>:/images/FeedMsgDelete.png</normaloff>:/images/FeedMsgDelete.png</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="feedProcessButton">
<property name="toolTip">
<string>Update feed</string>
</property>
<property name="icon">
<iconset resource="FeedReader_images.qrc">
<normaloff>:/images/FeedProcess.png</normaloff>:/images/FeedProcess.png</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="LineEditClear" name="filterLineEdit">
<property name="toolTip">
@ -174,16 +247,16 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>LineEditClear</class>
<extends>QLineEdit</extends>
<header>gui/common/LineEditClear.h</header>
</customwidget>
<customwidget>
<class>LinkTextBrowser</class>
<extends>QTextBrowser</extends>
<header>gui/common/LinkTextBrowser.h</header>
</customwidget>
<customwidget>
<class>LineEditClear</class>
<extends>QLineEdit</extends>
<header location="global">gui/common/LineEditClear.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="FeedReader_images.qrc"/>

View File

@ -4,6 +4,11 @@
<file>images/Root.png</file>
<file>images/Folder.png</file>
<file>images/Feed.png</file>
<file>images/FeedMsgDelete.png</file>
<file>images/FeedMsgRead.png</file>
<file>images/FeedMsgReadAll.png</file>
<file>images/FeedMsgUnread.png</file>
<file>images/FeedProcess.png</file>
<file>images/FeedProcessOverlay.png</file>
<file>images/FeedErrorOverlay.png</file>
<file>images/FolderAdd.png</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -1241,9 +1241,11 @@ void p3FeedReader::cleanFeeds()
if (removedMsgIds.size()) {
IndicateConfigChanged();
std::list<std::pair<std::string, std::string> >::iterator it;
for (it = removedMsgIds.begin(); it != removedMsgIds.end(); ++it) {
mNotify->msgChanged(it->first, it->second, NOTIFY_TYPE_DEL);
if (mNotify) {
std::list<std::pair<std::string, std::string> >::iterator it;
for (it = removedMsgIds.begin(); it != removedMsgIds.end(); ++it) {
mNotify->msgChanged(it->first, it->second, NOTIFY_TYPE_DEL);
}
}
}
}