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> <number>0</number>
</property> </property>
<item> <item>
<widget class="HeaderFrame" name="headerFrame"> <widget class="HeaderFrame" name="headerFrame"/>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>64</height>
</size>
</property>
</widget>
</item> </item>
<item> <item>
<widget class="QFrame" name="frame"> <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(mNotify, SIGNAL(notifyMsgChanged(QString,QString,int)), this, SLOT(msgChanged(QString,QString,int)));
/* connect signals */ /* 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->messageTabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(messageTabCloseRequested(int)));
connect(ui->feedTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(feedTreeCustomPopupMenu(QPoint))); 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 = new RSTreeWidgetItemCompareRole;
mFeedCompareRole->setRole(COLUMN_FEED_NAME, ROLE_FEED_SORT); 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->sortItems(COLUMN_FEED_NAME, Qt::AscendingOrder);
ui->feedTreeWidget->installEventFilter(this); ui->feedTreeWidget->installEventFilter(this);
feedItemChanged(NULL);
} }
FeedReaderDialog::~FeedReaderDialog() FeedReaderDialog::~FeedReaderDialog()
@ -536,13 +541,20 @@ FeedReaderMessageWidget *FeedReaderDialog::feedMessageWidget(const std::string &
void FeedReaderDialog::feedItemChanged(QTreeWidgetItem *item) void FeedReaderDialog::feedItemChanged(QTreeWidgetItem *item)
{ {
if (!item) { if (!item) {
ui->feedAddButton->setEnabled(false);
ui->feedProcessButton->setEnabled(false);
return; return;
} }
ui->feedProcessButton->setEnabled(true);
if (item->data(COLUMN_FEED_DATA, ROLE_FEED_FOLDER).toBool()) { if (item->data(COLUMN_FEED_DATA, ROLE_FEED_FOLDER).toBool()) {
ui->feedAddButton->setEnabled(true);
return; return;
} }
ui->feedAddButton->setEnabled(false);
std::string feedId = item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toString().toStdString(); std::string feedId = item->data(COLUMN_FEED_DATA, ROLE_FEED_ID).toString().toStdString();
/* search exisiting tab */ /* search exisiting tab */
FeedReaderMessageWidget *messageWidget = feedMessageWidget(feedId); FeedReaderMessageWidget *messageWidget = feedMessageWidget(feedId);

View File

@ -82,6 +82,34 @@
</property> </property>
</spacer> </spacer>
</item> </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> </layout>
</widget> </widget>
</item> </item>

View File

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

View File

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

View File

@ -39,6 +39,79 @@
<property name="margin"> <property name="margin">
<number>2</number> <number>2</number>
</property> </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> <item>
<widget class="LineEditClear" name="filterLineEdit"> <widget class="LineEditClear" name="filterLineEdit">
<property name="toolTip"> <property name="toolTip">
@ -174,16 +247,16 @@
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget>
<class>LineEditClear</class>
<extends>QLineEdit</extends>
<header>gui/common/LineEditClear.h</header>
</customwidget>
<customwidget> <customwidget>
<class>LinkTextBrowser</class> <class>LinkTextBrowser</class>
<extends>QTextBrowser</extends> <extends>QTextBrowser</extends>
<header>gui/common/LinkTextBrowser.h</header> <header>gui/common/LinkTextBrowser.h</header>
</customwidget> </customwidget>
<customwidget>
<class>LineEditClear</class>
<extends>QLineEdit</extends>
<header location="global">gui/common/LineEditClear.h</header>
</customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="FeedReader_images.qrc"/> <include location="FeedReader_images.qrc"/>

View File

@ -4,6 +4,11 @@
<file>images/Root.png</file> <file>images/Root.png</file>
<file>images/Folder.png</file> <file>images/Folder.png</file>
<file>images/Feed.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/FeedProcessOverlay.png</file>
<file>images/FeedErrorOverlay.png</file> <file>images/FeedErrorOverlay.png</file>
<file>images/FolderAdd.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,12 +1241,14 @@ void p3FeedReader::cleanFeeds()
if (removedMsgIds.size()) { if (removedMsgIds.size()) {
IndicateConfigChanged(); IndicateConfigChanged();
if (mNotify) {
std::list<std::pair<std::string, std::string> >::iterator it; std::list<std::pair<std::string, std::string> >::iterator it;
for (it = removedMsgIds.begin(); it != removedMsgIds.end(); ++it) { for (it = removedMsgIds.begin(); it != removedMsgIds.end(); ++it) {
mNotify->msgChanged(it->first, it->second, NOTIFY_TYPE_DEL); mNotify->msgChanged(it->first, it->second, NOTIFY_TYPE_DEL);
} }
} }
} }
}
} }
/***************************************************************************/ /***************************************************************************/