2007-04-05 23:26:30 +04:00
/*
* Bittorrent Client using Qt4 and libtorrent .
2007-07-14 18:31:59 +04:00
* Copyright ( C ) 2006 Christophe Dumez , Arnaud Demaiziere
2007-04-05 23:26:30 +04:00
*
2007-07-14 18:31:59 +04:00
* 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 .
2007-04-05 23:26:30 +04:00
*
* 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
2007-07-14 18:31:59 +04:00
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
*
2009-04-05 21:00:55 +04:00
* In addition , as a special exception , the copyright holders give permission to
* link this program with the OpenSSL project ' s " OpenSSL " library ( or with
* modified versions of it that use the same license as the " OpenSSL " library ) ,
* and distribute the linked executables . You must obey the GNU General Public
* License in all respects for all of the code used other than " OpenSSL " . If you
* modify file ( s ) , you may extend this exception to your version of the file ( s ) ,
* but you are not obligated to do so . If you do not wish to do so , delete this
* exception statement from your version .
*
2007-07-14 18:31:59 +04:00
* Contact : chris @ qbittorrent . org arnaud @ qbittorrent . org
2007-04-05 23:26:30 +04:00
*/
# include <QDesktopServices>
# include <QInputDialog>
# include <QMenu>
# include <QStandardItemModel>
2007-07-23 16:12:55 +04:00
# include <QMessageBox>
2007-07-23 16:46:36 +04:00
# include <QTimer>
2007-09-29 12:00:14 +04:00
# include <QString>
2009-08-21 11:40:57 +04:00
# include <QClipboard>
2007-04-05 23:26:30 +04:00
2009-08-21 11:40:57 +04:00
# include "rss_imp.h"
# include "rss.h"
# include "FeedDownloader.h"
# include "bittorrent.h"
2007-04-05 23:26:30 +04:00
2009-08-21 11:40:57 +04:00
// display a right-click menu
2009-08-22 06:19:40 +04:00
void RSSImp : : displayRSSListMenu ( const QPoint & pos ) {
if ( ! listStreams - > indexAt ( pos ) . isValid ( ) ) {
// No item under the mouse, clear selection
listStreams - > clearSelection ( ) ;
}
2009-08-21 11:40:57 +04:00
QMenu myFinishedListMenu ( this ) ;
QList < QTreeWidgetItem * > selectedItems = listStreams - > selectedItems ( ) ;
if ( selectedItems . size ( ) > 0 ) {
2009-08-22 06:19:40 +04:00
myFinishedListMenu . addAction ( actionUpdate_feed ) ;
myFinishedListMenu . addAction ( actionMark_items_read ) ;
2009-08-21 13:06:57 +04:00
myFinishedListMenu . addSeparator ( ) ;
2009-08-21 11:40:57 +04:00
if ( selectedItems . size ( ) = = 1 ) {
2009-08-22 06:19:40 +04:00
myFinishedListMenu . addAction ( actionRename_feed ) ;
2007-04-05 23:26:30 +04:00
}
2009-08-22 06:19:40 +04:00
myFinishedListMenu . addAction ( actionDelete_feed ) ;
2009-08-21 13:06:57 +04:00
myFinishedListMenu . addSeparator ( ) ;
2009-08-21 11:40:57 +04:00
myFinishedListMenu . addAction ( actionCopy_feed_URL ) ;
2009-08-21 13:06:57 +04:00
if ( selectedItems . size ( ) = = 1 ) {
myFinishedListMenu . addSeparator ( ) ;
myFinishedListMenu . addAction ( actionRSS_feed_downloader ) ;
}
2009-08-21 11:40:57 +04:00
} else {
2009-08-22 06:19:40 +04:00
myFinishedListMenu . addAction ( actionNew_subscription ) ;
myFinishedListMenu . addAction ( actionUpdate_all_feeds ) ;
2009-08-21 11:40:57 +04:00
}
myFinishedListMenu . exec ( QCursor : : pos ( ) ) ;
}
2007-04-05 23:26:30 +04:00
2009-08-21 11:40:57 +04:00
void RSSImp : : displayItemsListMenu ( const QPoint & ) {
QMenu myItemListMenu ( this ) ;
QList < QTreeWidgetItem * > selectedItems = listStreams - > selectedItems ( ) ;
if ( selectedItems . size ( ) > 0 ) {
myItemListMenu . addAction ( actionDownload_torrent ) ;
myItemListMenu . addAction ( actionOpen_news_URL ) ;
}
myItemListMenu . exec ( QCursor : : pos ( ) ) ;
}
2007-04-05 23:26:30 +04:00
2009-08-21 11:40:57 +04:00
// add a stream by a button
2009-08-22 06:19:40 +04:00
void RSSImp : : on_newFeedButton_clicked ( ) {
bool ok ;
QString clip_txt = qApp - > clipboard ( ) - > text ( ) ;
QString default_url = " http:// " ;
if ( clip_txt . startsWith ( " http:// " , Qt : : CaseInsensitive ) | | clip_txt . startsWith ( " https:// " , Qt : : CaseInsensitive ) | | clip_txt . startsWith ( " ftp:// " , Qt : : CaseInsensitive ) ) {
default_url = clip_txt ;
}
QString newUrl = QInputDialog : : getText ( this , tr ( " Please type a rss stream url " ) , tr ( " Stream URL: " ) , QLineEdit : : Normal , default_url , & ok ) ;
if ( ok ) {
newUrl = newUrl . trimmed ( ) ;
if ( ! newUrl . isEmpty ( ) ) {
RssStream * stream = rssmanager - > addStream ( newUrl ) ;
if ( stream = = 0 ) {
// Already existing
QMessageBox : : warning ( this , tr ( " qBittorrent " ) ,
tr ( " This rss feed is already in the list. " ) ,
QMessageBox : : Ok ) ;
return ;
}
QTreeWidgetItem * item = new QTreeWidgetItem ( listStreams ) ;
item - > setText ( 0 , stream - > getAliasOrUrl ( ) + QString : : fromUtf8 ( " (0) " ) ) ;
item - > setText ( 1 , stream - > getUrl ( ) ) ;
item - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( " :/Icons/loading.png " ) ) ) ;
item - > setToolTip ( 0 , QString : : fromUtf8 ( " <b> " ) + tr ( " Description: " ) + QString : : fromUtf8 ( " </b> " ) + stream - > getDescription ( ) + QString : : fromUtf8 ( " <br/><b> " ) + tr ( " url: " ) + QString : : fromUtf8 ( " </b> " ) + stream - > getUrl ( ) + QString : : fromUtf8 ( " <br/><b> " ) + tr ( " Last refresh: " ) + QString : : fromUtf8 ( " </b> " ) + stream - > getLastRefreshElapsedString ( ) ) ;
if ( listStreams - > topLevelItemCount ( ) = = 1 )
selectFirstFeed ( ) ;
rssmanager - > refresh ( newUrl ) ;
rssmanager - > saveStreamList ( ) ;
}
}
2009-08-21 11:40:57 +04:00
}
2007-04-15 23:06:19 +04:00
2009-08-21 11:40:57 +04:00
// delete a stream by a button
2009-08-22 06:30:28 +04:00
void RSSImp : : deleteSelectedFeeds ( ) {
2009-08-21 11:40:57 +04:00
QList < QTreeWidgetItem * > selectedItems = listStreams - > selectedItems ( ) ;
2009-08-22 07:00:31 +04:00
if ( selectedItems . size ( ) = = 0 ) return ;
2009-08-21 11:40:57 +04:00
if ( ! selectedItems . size ( ) ) return ;
int ret = QMessageBox : : question ( this , tr ( " Are you sure? -- qBittorrent " ) , tr ( " Are you sure you want to delete this stream from the list? " ) ,
tr ( " &Yes " ) , tr ( " &No " ) ,
QString ( ) , 0 , 1 ) ;
if ( ! ret ) {
2009-08-22 07:00:31 +04:00
foreach ( QTreeWidgetItem * item , selectedItems ) {
if ( listStreams - > currentItem ( ) = = item ) {
2007-08-03 18:37:56 +04:00
textBrowser - > clear ( ) ;
listNews - > clear ( ) ;
2007-04-05 23:26:30 +04:00
}
2009-08-22 07:00:31 +04:00
rssmanager - > removeStream ( item - > text ( 1 ) ) ;
delete item ;
2007-04-05 23:26:30 +04:00
}
2009-08-22 07:00:31 +04:00
rssmanager - > saveStreamList ( ) ;
2009-08-21 11:40:57 +04:00
}
}
2007-04-05 23:26:30 +04:00
2009-08-21 11:40:57 +04:00
// refresh all streams by a button
2009-08-22 06:19:40 +04:00
void RSSImp : : on_updateAllButton_clicked ( ) {
unsigned int nbFeeds = listStreams - > topLevelItemCount ( ) ;
for ( unsigned int i = 0 ; i < nbFeeds ; + + i )
listStreams - > topLevelItem ( i ) - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( " :/Icons/loading.png " ) ) ) ;
rssmanager - > refreshAll ( ) ;
updateLastRefreshedTimeForStreams ( ) ;
2009-08-21 11:40:57 +04:00
}
2007-09-09 15:31:51 +04:00
2009-08-21 11:40:57 +04:00
void RSSImp : : downloadTorrent ( ) {
QList < QListWidgetItem * > selected_items = listNews - > selectedItems ( ) ;
foreach ( const QListWidgetItem * item , selected_items ) {
2009-08-22 07:00:31 +04:00
RssItem * news = rssmanager - > getFeed ( getCurrentFeedUrl ( ) ) - > getItem ( listNews - > row ( item ) ) ;
2009-08-21 11:40:57 +04:00
BTSession - > downloadFromUrl ( news - > getTorrentUrl ( ) ) ;
}
}
2007-04-05 23:26:30 +04:00
2009-08-21 11:40:57 +04:00
// open the url of the news in a browser
void RSSImp : : openNewsUrl ( ) {
QList < QListWidgetItem * > selected_items = listNews - > selectedItems ( ) ;
foreach ( const QListWidgetItem * item , selected_items ) {
2009-08-22 07:00:31 +04:00
RssItem * news = rssmanager - > getFeed ( getCurrentFeedUrl ( ) ) - > getItem ( listNews - > row ( item ) ) ;
2009-08-21 11:40:57 +04:00
QString link = news - > getLink ( ) ;
if ( ! link . isEmpty ( ) )
QDesktopServices : : openUrl ( QUrl ( link ) ) ;
}
}
2007-08-03 18:37:56 +04:00
2009-08-21 11:40:57 +04:00
//right-click on stream : give him an alias
void RSSImp : : renameStream ( ) {
QList < QTreeWidgetItem * > selectedItems = listStreams - > selectedItems ( ) ;
Q_ASSERT ( selectedItems . size ( ) = = 1 ) ;
QTreeWidgetItem * item = selectedItems . at ( 0 ) ;
QString url = item - > data ( 1 , Qt : : DisplayRole ) . toString ( ) ;
bool ok ;
QString newAlias = QInputDialog : : getText ( this , tr ( " Please choose a new name for this stream " ) , tr ( " New stream name: " ) , QLineEdit : : Normal , rssmanager - > getFeed ( url ) - > getAlias ( ) , & ok ) ;
if ( ok ) {
rssmanager - > setAlias ( url , newAlias ) ;
}
}
2007-04-06 02:38:46 +04:00
2009-08-21 11:40:57 +04:00
//right-click on stream : refresh it
void RSSImp : : refreshSelectedStreams ( ) {
QList < QTreeWidgetItem * > selectedItems = listStreams - > selectedItems ( ) ;
QTreeWidgetItem * item ;
foreach ( item , selectedItems ) {
QString url = item - > text ( 1 ) ;
rssmanager - > refresh ( url ) ;
item - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( " :/Icons/loading.png " ) ) ) ;
}
}
2007-04-05 23:26:30 +04:00
2009-08-21 11:40:57 +04:00
void RSSImp : : copySelectedFeedsURL ( ) {
QStringList URLs ;
QList < QTreeWidgetItem * > selectedItems = listStreams - > selectedItems ( ) ;
QTreeWidgetItem * item ;
foreach ( item , selectedItems ) {
URLs < < item - > text ( 1 ) ;
}
qApp - > clipboard ( ) - > setText ( URLs . join ( " \n " ) ) ;
}
2007-04-05 23:26:30 +04:00
2009-08-21 11:40:57 +04:00
void RSSImp : : showFeedDownloader ( ) {
QTreeWidgetItem * item = listStreams - > selectedItems ( ) [ 0 ] ;
new FeedDownloaderDlg ( this , item - > text ( 1 ) , rssmanager - > getFeed ( item - > text ( 1 ) ) - > getAliasOrUrl ( ) , BTSession ) ;
}
2007-07-22 15:53:43 +04:00
2009-08-22 06:19:40 +04:00
void RSSImp : : on_markReadButton_clicked ( ) {
2009-08-21 11:40:57 +04:00
QList < QTreeWidgetItem * > selectedItems = listStreams - > selectedItems ( ) ;
QTreeWidgetItem * item ;
foreach ( item , selectedItems ) {
QString url = item - > text ( 1 ) ;
RssStream * feed = rssmanager - > getFeed ( url ) ;
feed - > markAllAsRead ( ) ;
item - > setData ( 0 , Qt : : DisplayRole , feed - > getAliasOrUrl ( ) + QString : : fromUtf8 ( " (0) " ) ) ;
}
2009-08-21 22:36:50 +04:00
if ( selectedItems . size ( ) )
refreshNewsList ( listStreams - > currentItem ( ) ) ;
2009-08-21 11:40:57 +04:00
}
2007-08-03 18:37:56 +04:00
2009-08-21 11:40:57 +04:00
void RSSImp : : fillFeedsList ( ) {
QList < RssStream * > feeds = rssmanager - > getRssFeeds ( ) ;
RssStream * stream ;
foreach ( stream , feeds ) {
QTreeWidgetItem * item = new QTreeWidgetItem ( listStreams ) ;
2009-08-22 06:43:11 +04:00
item - > setData ( 0 , Qt : : DisplayRole , stream - > getAliasOrUrl ( ) + QString : : fromUtf8 ( " ( " ) + QString : : number ( stream - > getNbUnRead ( ) , 10 ) + QString ( " ) " ) ) ;
2009-08-21 11:40:57 +04:00
item - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( QString : : fromUtf8 ( " :/Icons/loading.png " ) ) ) ) ;
item - > setData ( 1 , Qt : : DisplayRole , stream - > getUrl ( ) ) ;
item - > setToolTip ( 0 , QString : : fromUtf8 ( " <b> " ) + tr ( " Description: " ) + QString : : fromUtf8 ( " </b> " ) + stream - > getDescription ( ) + QString : : fromUtf8 ( " <br/><b> " ) + tr ( " url: " ) + QString : : fromUtf8 ( " </b> " ) + stream - > getUrl ( ) + QString : : fromUtf8 ( " <br/><b> " ) + tr ( " Last refresh: " ) + QString : : fromUtf8 ( " </b> " ) + stream - > getLastRefreshElapsedString ( ) ) ;
}
}
void RSSImp : : updateLastRefreshedTimeForStreams ( ) {
unsigned int nbFeeds = listStreams - > topLevelItemCount ( ) ;
for ( unsigned int i = 0 ; i < nbFeeds ; + + i ) {
QTreeWidgetItem * item = listStreams - > topLevelItem ( i ) ;
RssStream * stream = rssmanager - > getFeed ( item - > data ( 1 , Qt : : DisplayRole ) . toString ( ) ) ;
item - > setToolTip ( 0 , QString : : fromUtf8 ( " <b> " ) + tr ( " Description: " ) + QString : : fromUtf8 ( " </b> " ) + stream - > getDescription ( ) + QString : : fromUtf8 ( " <br/><b> " ) + tr ( " url: " ) + QString : : fromUtf8 ( " </b> " ) + stream - > getUrl ( ) + QString : : fromUtf8 ( " <br/><b> " ) + tr ( " Last refresh: " ) + QString : : fromUtf8 ( " </b> " ) + stream - > getLastRefreshElapsedString ( ) ) ;
}
}
2007-04-05 23:26:30 +04:00
2009-08-21 11:40:57 +04:00
// fills the newsList
2009-08-21 18:48:33 +04:00
void RSSImp : : refreshNewsList ( QTreeWidgetItem * item ) {
2009-08-21 21:49:48 +04:00
if ( ! item ) {
listNews - > clear ( ) ;
return ;
}
2009-08-22 07:00:31 +04:00
RssStream * stream = rssmanager - > getFeed ( getCurrentFeedUrl ( ) ) ;
2009-08-21 11:40:57 +04:00
qDebug ( " Getting the list of news " ) ;
QList < RssItem * > news = stream - > getNewsList ( ) ;
// Clear the list first
2009-08-21 22:24:29 +04:00
textBrowser - > clear ( ) ;
2009-08-21 11:40:57 +04:00
listNews - > clear ( ) ;
qDebug ( " Got the list of news " ) ;
foreach ( RssItem * article , news ) {
QListWidgetItem * it = new QListWidgetItem ( article - > getTitle ( ) , listNews ) ;
if ( article - > isRead ( ) ) {
it - > setData ( Qt : : ForegroundRole , QVariant ( QColor ( " grey " ) ) ) ;
it - > setData ( Qt : : DecorationRole , QVariant ( QIcon ( " :/Icons/sphere.png " ) ) ) ;
} else {
it - > setData ( Qt : : ForegroundRole , QVariant ( QColor ( " blue " ) ) ) ;
it - > setData ( Qt : : DecorationRole , QVariant ( QIcon ( " :/Icons/sphere2.png " ) ) ) ;
2007-08-03 18:37:56 +04:00
}
2009-08-21 11:40:57 +04:00
}
qDebug ( " Added all news to the GUI " ) ;
//selectFirstNews();
qDebug ( " First news selected " ) ;
}
2007-08-03 18:37:56 +04:00
2009-08-21 11:40:57 +04:00
// display a news
void RSSImp : : refreshTextBrowser ( QListWidgetItem * item ) {
2009-08-21 22:24:29 +04:00
if ( ! item ) return ;
2009-08-22 07:00:31 +04:00
RssItem * article = rssmanager - > getFeed ( getCurrentFeedUrl ( ) ) - > getItem ( listNews - > row ( item ) ) ;
2009-08-21 11:40:57 +04:00
QString html ;
html + = " <div style='border: 2px solid red; margin-left: 5px; margin-right: 5px; margin-bottom: 5px;'> " ;
html + = " <div style='background-color: #678db2; font-weight: bold; color: #fff;'> " + article - > getTitle ( ) + " </div> " ;
if ( article - > getDate ( ) . isValid ( ) ) {
html + = " <div style='background-color: #efefef;'><b> " + tr ( " Date: " ) + " </b> " + article - > getDate ( ) . toString ( ) + " </div> " ;
}
if ( ! article - > getAuthor ( ) . isEmpty ( ) ) {
html + = " <div style='background-color: #efefef;'><b> " + tr ( " Author: " ) + " </b> " + article - > getAuthor ( ) + " </div> " ;
}
html + = " </div> " ;
html + = " <divstyle='margin-left: 5px; margin-right: 5px;'> " + article - > getDescription ( ) + " </div> " ;
textBrowser - > setHtml ( html ) ;
article - > setRead ( ) ;
item - > setData ( Qt : : ForegroundRole , QVariant ( QColor ( " grey " ) ) ) ;
item - > setData ( Qt : : DecorationRole , QVariant ( QIcon ( " :/Icons/sphere.png " ) ) ) ;
2009-08-22 07:00:31 +04:00
updateFeedNbNews ( getCurrentFeedUrl ( ) ) ;
2009-08-21 11:40:57 +04:00
}
2007-08-03 18:37:56 +04:00
2009-08-21 11:40:57 +04:00
void RSSImp : : saveSlidersPosition ( ) {
// Remember sliders positions
QSettings settings ( " qBittorrent " , " qBittorrent " ) ;
settings . setValue ( " rss/splitter_h " , splitter_h - > saveState ( ) ) ;
settings . setValue ( " rss/splitter_v " , splitter_v - > saveState ( ) ) ;
qDebug ( " Splitters position saved " ) ;
}
void RSSImp : : restoreSlidersPosition ( ) {
QSettings settings ( " qBittorrent " , " qBittorrent " ) ;
QByteArray pos_h = settings . value ( " rss/splitter_h " , QByteArray ( ) ) . toByteArray ( ) ;
if ( ! pos_h . isNull ( ) ) {
splitter_h - > restoreState ( pos_h ) ;
}
QByteArray pos_v = settings . value ( " rss/splitter_v " , QByteArray ( ) ) . toByteArray ( ) ;
if ( ! pos_v . isNull ( ) ) {
splitter_v - > restoreState ( pos_v ) ;
}
}
QTreeWidgetItem * RSSImp : : getTreeItemFromUrl ( QString url ) const {
unsigned int nbItems = listStreams - > topLevelItemCount ( ) ;
for ( unsigned int i = 0 ; i < nbItems ; + + i ) {
QTreeWidgetItem * item = listStreams - > topLevelItem ( i ) ;
if ( item - > text ( 1 ) = = url )
return item ;
}
qDebug ( " Cannot find url %s in feeds list " , ( const char * ) url . toLocal8Bit ( ) ) ;
Q_ASSERT ( false ) ; // Should never go through here
return ( QTreeWidgetItem * ) 0 ;
}
void RSSImp : : updateFeedIcon ( QString url , QString icon_path ) {
QTreeWidgetItem * item = getTreeItemFromUrl ( url ) ;
item - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( icon_path ) ) ) ;
}
void RSSImp : : updateFeedNbNews ( QString url ) {
QTreeWidgetItem * item = getTreeItemFromUrl ( url ) ;
RssStream * stream = rssmanager - > getFeed ( url ) ;
item - > setText ( 0 , stream - > getAliasOrUrl ( ) + QString : : fromUtf8 ( " ( " ) + QString : : number ( stream - > getNbUnRead ( ) , 10 ) + QString ( " ) " ) ) ;
}
2009-08-22 07:00:31 +04:00
QString RSSImp : : getCurrentFeedUrl ( ) const {
QTreeWidgetItem * item = listStreams - > currentItem ( ) ;
if ( item )
return item - > text ( 1 ) ;
return QString : : null ;
}
2009-08-21 11:40:57 +04:00
void RSSImp : : updateFeedInfos ( QString url , QString aliasOrUrl , unsigned int nbUnread ) {
QTreeWidgetItem * item = getTreeItemFromUrl ( url ) ;
RssStream * stream = rssmanager - > getFeed ( url ) ;
item - > setText ( 0 , aliasOrUrl + QString : : fromUtf8 ( " ( " ) + QString : : number ( nbUnread , 10 ) + QString ( " ) " ) ) ;
item - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( stream - > getIconPath ( ) ) ) ) ;
item - > setToolTip ( 0 , QString : : fromUtf8 ( " <b> " ) + tr ( " Description: " ) + QString : : fromUtf8 ( " </b> " ) + stream - > getDescription ( ) + QString : : fromUtf8 ( " <br/><b> " ) + tr ( " url: " ) + QString : : fromUtf8 ( " </b> " ) + stream - > getUrl ( ) + QString : : fromUtf8 ( " <br/><b> " ) + tr ( " Last refresh: " ) + QString : : fromUtf8 ( " </b> " ) + stream - > getLastRefreshElapsedString ( ) ) ;
// If the feed is selected, update the displayed news
2009-08-22 07:00:31 +04:00
if ( listStreams - > currentItem ( ) = = item ) {
2009-08-21 18:48:33 +04:00
refreshNewsList ( item ) ;
2009-08-21 11:40:57 +04:00
}
}
RSSImp : : RSSImp ( bittorrent * BTSession ) : QWidget ( ) , BTSession ( BTSession ) {
setupUi ( this ) ;
2009-08-21 21:49:48 +04:00
2009-08-21 11:40:57 +04:00
// Hide second column (url)
listStreams - > hideColumn ( 1 ) ;
rssmanager = new RssManager ( BTSession ) ;
fillFeedsList ( ) ;
connect ( rssmanager , SIGNAL ( feedInfosChanged ( QString , QString , unsigned int ) ) , this , SLOT ( updateFeedInfos ( QString , QString , unsigned int ) ) ) ;
connect ( rssmanager , SIGNAL ( feedIconChanged ( QString , QString ) ) , this , SLOT ( updateFeedIcon ( QString , QString ) ) ) ;
connect ( listStreams , SIGNAL ( customContextMenuRequested ( const QPoint & ) ) , this , SLOT ( displayRSSListMenu ( const QPoint & ) ) ) ;
connect ( listNews , SIGNAL ( customContextMenuRequested ( const QPoint & ) ) , this , SLOT ( displayItemsListMenu ( const QPoint & ) ) ) ;
2009-08-22 06:19:40 +04:00
// Feeds list actions
2009-08-22 06:30:28 +04:00
connect ( actionDelete_feed , SIGNAL ( triggered ( ) ) , this , SLOT ( deleteSelectedFeeds ( ) ) ) ;
2009-08-22 06:19:40 +04:00
connect ( actionRename_feed , SIGNAL ( triggered ( ) ) , this , SLOT ( renameStream ( ) ) ) ;
connect ( actionUpdate_feed , SIGNAL ( triggered ( ) ) , this , SLOT ( refreshSelectedStreams ( ) ) ) ;
connect ( actionNew_subscription , SIGNAL ( triggered ( ) ) , this , SLOT ( on_newFeedButton_clicked ( ) ) ) ;
connect ( actionUpdate_all_feeds , SIGNAL ( triggered ( ) ) , this , SLOT ( on_updateAllButton_clicked ( ) ) ) ;
2009-08-21 11:40:57 +04:00
connect ( actionCopy_feed_URL , SIGNAL ( triggered ( ) ) , this , SLOT ( copySelectedFeedsURL ( ) ) ) ;
connect ( actionRSS_feed_downloader , SIGNAL ( triggered ( ) ) , this , SLOT ( showFeedDownloader ( ) ) ) ;
2009-08-22 06:19:40 +04:00
connect ( actionMark_items_read , SIGNAL ( triggered ( ) ) , this , SLOT ( on_markReadButton_clicked ( ) ) ) ;
// News list actions
2009-08-21 11:40:57 +04:00
connect ( actionOpen_news_URL , SIGNAL ( triggered ( ) ) , this , SLOT ( openNewsUrl ( ) ) ) ;
connect ( actionDownload_torrent , SIGNAL ( triggered ( ) ) , this , SLOT ( downloadTorrent ( ) ) ) ;
2009-08-21 18:48:33 +04:00
connect ( listStreams , SIGNAL ( currentItemChanged ( QTreeWidgetItem * , QTreeWidgetItem * ) ) , this , SLOT ( refreshNewsList ( QTreeWidgetItem * ) ) ) ;
2009-08-22 06:43:11 +04:00
connect ( listNews , SIGNAL ( itemClicked ( QListWidgetItem * ) ) , this , SLOT ( refreshTextBrowser ( QListWidgetItem * ) ) ) ;
2009-08-21 11:40:57 +04:00
connect ( listNews , SIGNAL ( itemDoubleClicked ( QListWidgetItem * ) ) , this , SLOT ( downloadTorrent ( ) ) ) ;
refreshTimeTimer = new QTimer ( this ) ;
connect ( refreshTimeTimer , SIGNAL ( timeout ( ) ) , this , SLOT ( updateLastRefreshedTimeForStreams ( ) ) ) ;
refreshTimeTimer - > start ( 60000 ) ; // 1min
// Select first news of first feed
selectFirstFeed ( ) ;
// Refresh all feeds
rssmanager - > refreshAll ( ) ;
// Restore sliders position
restoreSlidersPosition ( ) ;
// Bind saveSliders slots
connect ( splitter_v , SIGNAL ( splitterMoved ( int , int ) ) , this , SLOT ( saveSlidersPosition ( ) ) ) ;
connect ( splitter_h , SIGNAL ( splitterMoved ( int , int ) ) , this , SLOT ( saveSlidersPosition ( ) ) ) ;
qDebug ( " RSSImp constructed " ) ;
}
void RSSImp : : selectFirstFeed ( ) {
if ( listStreams - > topLevelItemCount ( ) ) {
QTreeWidgetItem * first = listStreams - > topLevelItem ( 0 ) ;
listStreams - > setCurrentItem ( first ) ;
}
}
RSSImp : : ~ RSSImp ( ) {
qDebug ( " Deleting RSSImp... " ) ;
delete refreshTimeTimer ;
delete rssmanager ;
qDebug ( " RSSImp deleted " ) ;
}
2007-04-05 23:26:30 +04:00