@ -63,22 +63,22 @@ enum ArticleRoles {
// display a right-click menu
// display a right-click menu
void RSSImp : : displayRSSListMenu ( const QPoint & pos ) {
void RSSImp : : displayRSSListMenu ( const QPoint & pos ) {
if ( ! listStreams - > indexAt ( pos ) . isValid ( ) ) {
if ( ! m_feedList - > indexAt ( pos ) . isValid ( ) ) {
// No item under the mouse, clear selection
// No item under the mouse, clear selection
listStreams - > clearSelection ( ) ;
m_feedList - > clearSelection ( ) ;
}
}
QMenu myRSSListMenu ( this ) ;
QMenu myRSSListMenu ( this ) ;
QList < QTreeWidgetItem * > selectedItems = listStreams - > selectedItems ( ) ;
QList < QTreeWidgetItem * > selectedItems = m_feedList - > selectedItems ( ) ;
if ( selectedItems . size ( ) > 0 ) {
if ( selectedItems . size ( ) > 0 ) {
myRSSListMenu . addAction ( actionUpdate ) ;
myRSSListMenu . addAction ( actionUpdate ) ;
myRSSListMenu . addAction ( actionMark_items_read ) ;
myRSSListMenu . addAction ( actionMark_items_read ) ;
myRSSListMenu . addSeparator ( ) ;
myRSSListMenu . addSeparator ( ) ;
if ( selectedItems . size ( ) = = 1 ) {
if ( selectedItems . size ( ) = = 1 ) {
if ( listStreams - > getRSSItem ( selectedItems . first ( ) ) ! = rssm anager) {
if ( m_feedList - > getRSSItem ( selectedItems . first ( ) ) ! = m_rssM anager) {
myRSSListMenu . addAction ( actionRename ) ;
myRSSListMenu . addAction ( actionRename ) ;
myRSSListMenu . addAction ( actionDelete ) ;
myRSSListMenu . addAction ( actionDelete ) ;
myRSSListMenu . addSeparator ( ) ;
myRSSListMenu . addSeparator ( ) ;
if ( listStreams - > getItemType ( selectedItems . first ( ) ) = = RssFile : : FOLDER ) {
if ( m_feedList - > getItemType ( selectedItems . first ( ) ) = = I RssFile: : FOLDER ) {
myRSSListMenu . addAction ( actionNew_folder ) ;
myRSSListMenu . addAction ( actionNew_folder ) ;
} else {
} else {
myRSSListMenu . addAction ( actionManage_cookies ) ;
myRSSListMenu . addAction ( actionManage_cookies ) ;
@ -86,7 +86,7 @@ void RSSImp::displayRSSListMenu(const QPoint& pos){
}
}
}
}
myRSSListMenu . addAction ( actionNew_subscription ) ;
myRSSListMenu . addAction ( actionNew_subscription ) ;
if ( listStreams - > getItemType ( selectedItems . first ( ) ) = = RssFile : : FEED ) {
if ( m_feedList - > getItemType ( selectedItems . first ( ) ) = = I RssFile: : FEED ) {
myRSSListMenu . addSeparator ( ) ;
myRSSListMenu . addSeparator ( ) ;
myRSSListMenu . addAction ( actionCopy_feed_URL ) ;
myRSSListMenu . addAction ( actionCopy_feed_URL ) ;
}
}
@ -107,7 +107,7 @@ void RSSImp::displayItemsListMenu(const QPoint&){
foreach ( const QListWidgetItem * item , selectedItems ) {
foreach ( const QListWidgetItem * item , selectedItems ) {
qDebug ( " text(3) URL: %s " , qPrintable ( item - > data ( Article : : FeedUrlRole ) . toString ( ) ) ) ;
qDebug ( " text(3) URL: %s " , qPrintable ( item - > data ( Article : : FeedUrlRole ) . toString ( ) ) ) ;
qDebug ( " text(2) TITLE: %s " , qPrintable ( item - > data ( Article : : TitleRole ) . toString ( ) ) ) ;
qDebug ( " text(2) TITLE: %s " , qPrintable ( item - > data ( Article : : TitleRole ) . toString ( ) ) ) ;
if ( listStreams - > getRSSItemFromUrl ( item - > data ( Article : : FeedUrlRole ) . toString ( ) )
if ( m_feedList - > getRSSItemFromUrl ( item - > data ( Article : : FeedUrlRole ) . toString ( ) )
- > getItem ( item - > data ( Article : : IdRole ) . toString ( ) ) . hasAttachment ( ) ) {
- > getItem ( item - > data ( Article : : IdRole ) . toString ( ) ) . hasAttachment ( ) ) {
has_attachment = true ;
has_attachment = true ;
break ;
break ;
@ -121,9 +121,9 @@ void RSSImp::displayItemsListMenu(const QPoint&){
}
}
void RSSImp : : on_actionManage_cookies_triggered ( ) {
void RSSImp : : on_actionManage_cookies_triggered ( ) {
Q_ASSERT ( ! listStreams - > selectedItems ( ) . empty ( ) ) ;
Q_ASSERT ( ! m_feedList - > selectedItems ( ) . empty ( ) ) ;
// Get feed hostname
// Get feed hostname
QString feed_url = listStreams - > getItemID ( listStreams - > selectedItems ( ) . first ( ) ) ;
QString feed_url = m_feedList - > getItemID ( m_feedList - > selectedItems ( ) . first ( ) ) ;
QString feed_hostname = QUrl : : fromEncoded ( feed_url . toLocal8Bit ( ) ) . host ( ) ;
QString feed_hostname = QUrl : : fromEncoded ( feed_url . toLocal8Bit ( ) ) . host ( ) ;
qDebug ( " RSS Feed hostname is: %s " , qPrintable ( feed_hostname ) ) ;
qDebug ( " RSS Feed hostname is: %s " , qPrintable ( feed_hostname ) ) ;
Q_ASSERT ( ! feed_hostname . isEmpty ( ) ) ;
Q_ASSERT ( ! feed_hostname . isEmpty ( ) ) ;
@ -138,12 +138,12 @@ void RSSImp::on_actionManage_cookies_triggered() {
void RSSImp : : askNewFolder ( ) {
void RSSImp : : askNewFolder ( ) {
QTreeWidgetItem * parent_item = 0 ;
QTreeWidgetItem * parent_item = 0 ;
RssFolder * rss_parent ;
RssFolder * rss_parent ;
if ( listStreams - > selectedItems ( ) . size ( ) > 0 ) {
if ( m_feedList - > selectedItems ( ) . size ( ) > 0 ) {
parent_item = listStreams - > selectedItems ( ) . at ( 0 ) ;
parent_item = m_feedList - > selectedItems ( ) . at ( 0 ) ;
rss_parent = ( RssFolder * ) listStreams - > getRSSItem ( parent_item ) ;
rss_parent = dynamic_cast < RssFolder * > ( m_feedList - > getRSSItem ( parent_item ) ) ;
Q_ASSERT ( rss_parent - > type ( ) = = RssFile : : FOLDER ) ;
Q_ASSERT ( rss_parent - > type ( ) = = I RssFile: : FOLDER ) ;
} else {
} else {
rss_parent = rssm anager;
rss_parent = m_rssM anager;
}
}
bool ok ;
bool ok ;
QString new_name = QInputDialog : : getText ( this , tr ( " Please choose a folder name " ) , tr ( " Folder name: " ) , QLineEdit : : Normal , tr ( " New folder " ) , & ok ) ;
QString new_name = QInputDialog : : getText ( this , tr ( " Please choose a folder name " ) , tr ( " Folder name: " ) , QLineEdit : : Normal , tr ( " New folder " ) , & ok ) ;
@ -153,20 +153,20 @@ void RSSImp::askNewFolder() {
if ( parent_item )
if ( parent_item )
folder_item = new QTreeWidgetItem ( parent_item ) ;
folder_item = new QTreeWidgetItem ( parent_item ) ;
else
else
folder_item = new QTreeWidgetItem ( listStreams ) ;
folder_item = new QTreeWidgetItem ( m_feedList ) ;
// Notify TreeWidget
// Notify TreeWidget
listStreams - > itemAdded ( folder_item , new_folder ) ;
m_feedList - > itemAdded ( folder_item , new_folder ) ;
// Set Text
// Set Text
folder_item - > setText ( 0 , new_folder - > displayName ( ) + QString : : fromUtf8 ( " (0) " ) ) ;
folder_item - > setText ( 0 , new_folder - > displayName ( ) + QString : : fromUtf8 ( " (0) " ) ) ;
folder_item - > setData ( 0 , Qt : : DecorationRole , QVariant ( IconProvider : : instance ( ) - > getIcon ( " inode-directory " ) ) ) ;
folder_item - > setData ( 0 , Qt : : DecorationRole , QVariant ( IconProvider : : instance ( ) - > getIcon ( " inode-directory " ) ) ) ;
// Expand parent folder to display new folder
// Expand parent folder to display new folder
if ( parent_item )
if ( parent_item )
parent_item - > setExpanded ( true ) ;
parent_item - > setExpanded ( true ) ;
rssm anager- > saveStreamList ( ) ;
m_rssM anager- > saveStreamList ( ) ;
}
}
}
}
void RSSImp : : displayOverwriteError ( QString filename ) {
void RSSImp : : displayOverwriteError ( const QString & filename ) {
QMessageBox : : warning ( this , tr ( " Overwrite attempt " ) ,
QMessageBox : : warning ( this , tr ( " Overwrite attempt " ) ,
tr ( " You cannot overwrite %1 item. " , " You cannot overwrite myFolder item. " ) . arg ( filename ) ,
tr ( " You cannot overwrite %1 item. " , " You cannot overwrite myFolder item. " ) . arg ( filename ) ,
QMessageBox : : Ok ) ;
QMessageBox : : Ok ) ;
@ -176,22 +176,22 @@ void RSSImp::displayOverwriteError(QString filename) {
void RSSImp : : on_newFeedButton_clicked ( ) {
void RSSImp : : on_newFeedButton_clicked ( ) {
// Determine parent folder for new feed
// Determine parent folder for new feed
QTreeWidgetItem * parent_item = 0 ;
QTreeWidgetItem * parent_item = 0 ;
QList < QTreeWidgetItem * > selected_items = listStreams - > selectedItems ( ) ;
QList < QTreeWidgetItem * > selected_items = m_feedList - > selectedItems ( ) ;
if ( ! selected_items . empty ( ) ) {
if ( ! selected_items . empty ( ) ) {
parent_item = selected_items . first ( ) ;
parent_item = selected_items . first ( ) ;
// Consider the case where the user clicked on Unread item
// Consider the case where the user clicked on Unread item
if ( parent_item = = listStreams - > get UnreadItem( ) ) {
if ( parent_item = = m_feedList - > sticky UnreadItem( ) ) {
parent_item = 0 ;
parent_item = 0 ;
} else {
} else {
if ( listStreams - > getItemType ( parent_item ) ! = RssFile : : FOLDER )
if ( m_feedList - > getItemType ( parent_item ) ! = I RssFile: : FOLDER )
parent_item = parent_item - > parent ( ) ;
parent_item = parent_item - > parent ( ) ;
}
}
}
}
RssFolder * rss_parent ;
RssFolder * rss_parent ;
if ( parent_item ) {
if ( parent_item ) {
rss_parent = ( RssFolder * ) listStreams - > getRSSItem ( parent_item ) ;
rss_parent = ( RssFolder * ) m_feedList - > getRSSItem ( parent_item ) ;
} else {
} else {
rss_parent = rssm anager;
rss_parent = m_rssM anager;
}
}
// Ask for feed URL
// Ask for feed URL
bool ok ;
bool ok ;
@ -204,7 +204,7 @@ void RSSImp::on_newFeedButton_clicked() {
if ( ok ) {
if ( ok ) {
newUrl = newUrl . trimmed ( ) ;
newUrl = newUrl . trimmed ( ) ;
if ( ! newUrl . isEmpty ( ) ) {
if ( ! newUrl . isEmpty ( ) ) {
if ( listStreams - > hasFeed ( newUrl ) ) {
if ( m_feedList - > hasFeed ( newUrl ) ) {
QMessageBox : : warning ( this , tr ( " qBittorrent " ) ,
QMessageBox : : warning ( this , tr ( " qBittorrent " ) ,
tr ( " This rss feed is already in the list. " ) ,
tr ( " This rss feed is already in the list. " ) ,
QMessageBox : : Ok ) ;
QMessageBox : : Ok ) ;
@ -216,21 +216,21 @@ void RSSImp::on_newFeedButton_clicked() {
if ( parent_item )
if ( parent_item )
item = new QTreeWidgetItem ( parent_item ) ;
item = new QTreeWidgetItem ( parent_item ) ;
else
else
item = new QTreeWidgetItem ( listStreams ) ;
item = new QTreeWidgetItem ( m_feedList ) ;
// Notify TreeWidget
// Notify TreeWidget
listStreams - > itemAdded ( item , stream ) ;
m_feedList - > itemAdded ( item , stream ) ;
// Set text
// Set text
item - > setText ( 0 , stream - > displayName ( ) + QString : : fromUtf8 ( " (0) " ) ) ;
item - > setText ( 0 , stream - > displayName ( ) + QString : : fromUtf8 ( " (0) " ) ) ;
item - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( " :/Icons/loading.png " ) ) ) ;
item - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( " :/Icons/loading.png " ) ) ) ;
stream - > refresh ( ) ;
stream - > refresh ( ) ;
rssm anager- > saveStreamList ( ) ;
m_rssM anager- > saveStreamList ( ) ;
}
}
}
}
}
}
// delete a stream by a button
// delete a stream by a button
void RSSImp : : deleteSelectedItems ( ) {
void RSSImp : : deleteSelectedItems ( ) {
QList < QTreeWidgetItem * > selectedItems = listStreams - > selectedItems ( ) ;
QList < QTreeWidgetItem * > selectedItems = m_feedList - > selectedItems ( ) ;
if ( selectedItems . size ( ) = = 0 ) return ;
if ( selectedItems . size ( ) = = 0 ) return ;
int ret ;
int ret ;
if ( selectedItems . size ( ) > 1 )
if ( selectedItems . size ( ) > 1 )
@ -243,21 +243,21 @@ void RSSImp::deleteSelectedItems() {
QString ( ) , 0 , 1 ) ;
QString ( ) , 0 , 1 ) ;
if ( ! ret ) {
if ( ! ret ) {
foreach ( QTreeWidgetItem * item , selectedItems ) {
foreach ( QTreeWidgetItem * item , selectedItems ) {
if ( listStreams - > currentFeed ( ) = = item ) {
if ( m_feedList - > currentFeed ( ) = = item ) {
textBrowser - > clear ( ) ;
textBrowser - > clear ( ) ;
m_currentArticle = 0 ;
m_currentArticle = 0 ;
listArticles - > clear ( ) ;
listArticles - > clear ( ) ;
}
}
RssFile * rss_item = listStreams - > getRSSItem ( item ) ;
I RssFile * rss_item = m_feedList - > getRSSItem ( item ) ;
// Notify TreeWidget
// Notify TreeWidget
listStreams - > itemAboutToBeRemoved ( item ) ;
m_feedList - > itemAboutToBeRemoved ( item ) ;
// Actually delete the item
// Actually delete the item
rss_item - > parent ( ) - > removeChild ( rss_item - > id ( ) ) ;
rss_item - > parent ( ) - > removeChild ( rss_item - > id ( ) ) ;
delete item ;
delete item ;
}
}
rssm anager- > saveStreamList ( ) ;
m_rssM anager- > saveStreamList ( ) ;
// Update Unread items
// Update Unread items
updateItemInfos ( listStreams - > get UnreadItem( ) ) ;
updateItemInfos ( m_feedList - > sticky UnreadItem( ) ) ;
}
}
}
}
@ -274,14 +274,14 @@ void RSSImp::loadFoldersOpenState() {
if ( parent )
if ( parent )
nbChildren = parent - > childCount ( ) ;
nbChildren = parent - > childCount ( ) ;
else
else
nbChildren = listStreams - > topLevelItemCount ( ) ;
nbChildren = m_feedList - > topLevelItemCount ( ) ;
for ( int i = 0 ; i < nbChildren ; + + i ) {
for ( int i = 0 ; i < nbChildren ; + + i ) {
QTreeWidgetItem * child ;
QTreeWidgetItem * child ;
if ( parent )
if ( parent )
child = parent - > child ( i ) ;
child = parent - > child ( i ) ;
else
else
child = listStreams - > topLevelItem ( i ) ;
child = m_feedList - > topLevelItem ( i ) ;
if ( listStreams - > getRSSItem ( child ) - > id ( ) = = name ) {
if ( m_feedList - > getRSSItem ( child ) - > id ( ) = = name ) {
parent = child ;
parent = child ;
parent - > setExpanded ( true ) ;
parent - > setExpanded ( true ) ;
qDebug ( " expanding folder %s " , qPrintable ( name ) ) ;
qDebug ( " expanding folder %s " , qPrintable ( name ) ) ;
@ -294,9 +294,9 @@ void RSSImp::loadFoldersOpenState() {
void RSSImp : : saveFoldersOpenState ( ) {
void RSSImp : : saveFoldersOpenState ( ) {
QStringList open_folders ;
QStringList open_folders ;
QList < QTreeWidgetItem * > items = listStreams - > getAllOpenFolders ( ) ;
QList < QTreeWidgetItem * > items = m_feedList - > getAllOpenFolders ( ) ;
foreach ( QTreeWidgetItem * item , items ) {
foreach ( QTreeWidgetItem * item , items ) {
QString path = listStreams - > getItemPath ( item ) . join ( " \\ " ) ;
QString path = m_feedList - > getItemPath ( item ) . join ( " \\ " ) ;
qDebug ( " saving open folder: %s " , qPrintable ( path ) ) ;
qDebug ( " saving open folder: %s " , qPrintable ( path ) ) ;
open_folders < < path ;
open_folders < < path ;
}
}
@ -308,16 +308,16 @@ void RSSImp::saveFoldersOpenState() {
// refresh all streams by a button
// refresh all streams by a button
void RSSImp : : on_updateAllButton_clicked ( ) {
void RSSImp : : on_updateAllButton_clicked ( ) {
foreach ( QTreeWidgetItem * item , listStreams - > getAllFeedItems ( ) ) {
foreach ( QTreeWidgetItem * item , m_feedList - > getAllFeedItems ( ) ) {
item - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( " :/Icons/loading.png " ) ) ) ;
item - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( " :/Icons/loading.png " ) ) ) ;
}
}
rssm anager- > refresh ( ) ;
m_rssM anager- > refresh ( ) ;
}
}
void RSSImp : : downloadTorrent ( ) {
void RSSImp : : downloadTorrent ( ) {
QList < QListWidgetItem * > selected_items = listArticles - > selectedItems ( ) ;
QList < QListWidgetItem * > selected_items = listArticles - > selectedItems ( ) ;
foreach ( const QListWidgetItem * item , selected_items ) {
foreach ( const QListWidgetItem * item , selected_items ) {
const RssArticle article = listStreams - > getRSSItemFromUrl ( item - > data ( Article : : FeedUrlRole ) . toString ( ) )
const RssArticle article = m_feedList - > getRSSItemFromUrl ( item - > data ( Article : : FeedUrlRole ) . toString ( ) )
- > getItem ( item - > data ( Article : : IdRole ) . toString ( ) ) ;
- > getItem ( item - > data ( Article : : IdRole ) . toString ( ) ) ;
if ( article . hasAttachment ( ) ) {
if ( article . hasAttachment ( ) ) {
QBtSession : : instance ( ) - > downloadFromUrl ( article . torrentUrl ( ) ) ;
QBtSession : : instance ( ) - > downloadFromUrl ( article . torrentUrl ( ) ) ;
@ -331,7 +331,7 @@ void RSSImp::downloadTorrent() {
void RSSImp : : openNewsUrl ( ) {
void RSSImp : : openNewsUrl ( ) {
QList < QListWidgetItem * > selected_items = listArticles - > selectedItems ( ) ;
QList < QListWidgetItem * > selected_items = listArticles - > selectedItems ( ) ;
foreach ( const QListWidgetItem * item , selected_items ) {
foreach ( const QListWidgetItem * item , selected_items ) {
const RssArticle news = listStreams - > getRSSItemFromUrl ( item - > data ( Article : : FeedUrlRole ) . toString ( ) )
const RssArticle news = m_feedList - > getRSSItemFromUrl ( item - > data ( Article : : FeedUrlRole ) . toString ( ) )
- > getItem ( item - > data ( Article : : IdRole ) . toString ( ) ) ;
- > getItem ( item - > data ( Article : : IdRole ) . toString ( ) ) ;
const QString link = news . link ( ) ;
const QString link = news . link ( ) ;
if ( ! link . isEmpty ( ) )
if ( ! link . isEmpty ( ) )
@ -341,14 +341,14 @@ void RSSImp::openNewsUrl() {
//right-click on stream : give it an alias
//right-click on stream : give it an alias
void RSSImp : : renameFiles ( ) {
void RSSImp : : renameFiles ( ) {
QList < QTreeWidgetItem * > selectedItems = listStreams - > selectedItems ( ) ;
QList < QTreeWidgetItem * > selectedItems = m_feedList - > selectedItems ( ) ;
Q_ASSERT ( selectedItems . size ( ) = = 1 ) ;
Q_ASSERT ( selectedItems . size ( ) = = 1 ) ;
QTreeWidgetItem * item = selectedItems . at ( 0 ) ;
QTreeWidgetItem * item = selectedItems . at ( 0 ) ;
RssFile * rss_item = listStreams - > getRSSItem ( item ) ;
I RssFile * rss_item = m_feedList - > getRSSItem ( item ) ;
bool ok ;
bool ok ;
QString newName ;
QString newName ;
do {
do {
newName = QInputDialog : : getText ( this , tr ( " Please choose a new name for this RSS feed " ) , tr ( " New feed name: " ) , QLineEdit : : Normal , listStreams - > getRSSItem ( item ) - > displayName ( ) , & ok ) ;
newName = QInputDialog : : getText ( this , tr ( " Please choose a new name for this RSS feed " ) , tr ( " New feed name: " ) , QLineEdit : : Normal , m_feedList - > getRSSItem ( item ) - > displayName ( ) , & ok ) ;
// Check if name is already taken
// Check if name is already taken
if ( ok ) {
if ( ok ) {
if ( rss_item - > parent ( ) - > hasChild ( newName ) ) {
if ( rss_item - > parent ( ) - > hasChild ( newName ) ) {
@ -367,22 +367,22 @@ void RSSImp::renameFiles() {
//right-click on stream : refresh it
//right-click on stream : refresh it
void RSSImp : : refreshSelectedItems ( ) {
void RSSImp : : refreshSelectedItems ( ) {
QList < QTreeWidgetItem * > selectedItems = listStreams - > selectedItems ( ) ;
QList < QTreeWidgetItem * > selectedItems = m_feedList - > selectedItems ( ) ;
foreach ( QTreeWidgetItem * item , selectedItems ) {
foreach ( QTreeWidgetItem * item , selectedItems ) {
RssFile * file = listStreams - > getRSSItem ( item ) ;
I RssFile* file = m_feedList - > getRSSItem ( item ) ;
// Update icons
// Update icons
if ( item = = listStreams - > get UnreadItem( ) ) {
if ( item = = m_feedList - > sticky UnreadItem( ) ) {
foreach ( QTreeWidgetItem * feed , listStreams - > getAllFeedItems ( ) ) {
foreach ( QTreeWidgetItem * feed , m_feedList - > getAllFeedItems ( ) ) {
feed - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( " :/Icons/loading.png " ) ) ) ;
feed - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( " :/Icons/loading.png " ) ) ) ;
}
}
file - > refresh ( ) ;
file - > refresh ( ) ;
break ;
break ;
} else {
} else {
if ( file - > type ( ) = = RssFile : : FEED ) {
if ( file - > type ( ) = = I RssFile: : FEED ) {
item - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( " :/Icons/loading.png " ) ) ) ;
item - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( " :/Icons/loading.png " ) ) ) ;
} else {
} else {
// Update feeds in the folder
// Update feeds in the folder
foreach ( QTreeWidgetItem * feed , listStreams - > getAllFeedItems ( item ) ) {
foreach ( QTreeWidgetItem * feed , m_feedList - > getAllFeedItems ( item ) ) {
feed - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( " :/Icons/loading.png " ) ) ) ;
feed - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( " :/Icons/loading.png " ) ) ) ;
}
}
}
}
@ -394,45 +394,45 @@ void RSSImp::refreshSelectedItems() {
void RSSImp : : copySelectedFeedsURL ( ) {
void RSSImp : : copySelectedFeedsURL ( ) {
QStringList URLs ;
QStringList URLs ;
QList < QTreeWidgetItem * > selectedItems = listStreams - > selectedItems ( ) ;
QList < QTreeWidgetItem * > selectedItems = m_feedList - > selectedItems ( ) ;
QTreeWidgetItem * item ;
QTreeWidgetItem * item ;
foreach ( item , selectedItems ) {
foreach ( item , selectedItems ) {
if ( listStreams - > getItemType ( item ) = = RssFile : : FEED )
if ( m_feedList - > getItemType ( item ) = = I RssFile: : FEED )
URLs < < listStreams - > getItemID ( item ) ;
URLs < < m_feedList - > getItemID ( item ) ;
}
}
qApp - > clipboard ( ) - > setText ( URLs . join ( " \n " ) ) ;
qApp - > clipboard ( ) - > setText ( URLs . join ( " \n " ) ) ;
}
}
void RSSImp : : on_markReadButton_clicked ( ) {
void RSSImp : : on_markReadButton_clicked ( ) {
QList < QTreeWidgetItem * > selectedItems = listStreams - > selectedItems ( ) ;
QList < QTreeWidgetItem * > selectedItems = m_feedList - > selectedItems ( ) ;
QTreeWidgetItem * item ;
QTreeWidgetItem * item ;
foreach ( item , selectedItems ) {
foreach ( item , selectedItems ) {
RssFile * rss_item = listStreams - > getRSSItem ( item ) ;
I RssFile * rss_item = m_feedList - > getRSSItem ( item ) ;
rss_item - > markAsRead ( ) ;
rss_item - > markAsRead ( ) ;
updateItemInfos ( item ) ;
updateItemInfos ( item ) ;
}
}
if ( selectedItems . size ( ) )
if ( selectedItems . size ( ) )
refreshNewsList ( listStreams - > currentItem ( ) ) ;
refreshArticleList ( m_feedList - > currentItem ( ) ) ;
}
}
void RSSImp : : fillFeedsList ( QTreeWidgetItem * parent , RssFolder * rss_parent ) {
void RSSImp : : fillFeedsList ( QTreeWidgetItem * parent , RssFolder * rss_parent ) {
QList < RssFile * > children ;
QList < I RssFile* > children ;
if ( parent ) {
if ( parent ) {
children = rss_parent - > getContent ( ) ;
children = rss_parent - > getContent ( ) ;
} else {
} else {
children = rssm anager- > getContent ( ) ;
children = m_rssM anager- > getContent ( ) ;
}
}
foreach ( RssFile * rss_child , children ) {
foreach ( I RssFile* rss_child , children ) {
QTreeWidgetItem * item ;
QTreeWidgetItem * item ;
if ( ! parent )
if ( ! parent )
item = new QTreeWidgetItem ( listStreams ) ;
item = new QTreeWidgetItem ( m_feedList ) ;
else
else
item = new QTreeWidgetItem ( parent ) ;
item = new QTreeWidgetItem ( parent ) ;
item - > setData ( 0 , Qt : : DisplayRole , QVariant ( rss_child - > displayName ( ) + QString : : fromUtf8 ( " ( " ) + QString : : number ( rss_child - > unreadCount ( ) , 10 ) + QString ( " ) " ) ) ) ;
item - > setData ( 0 , Qt : : DisplayRole , QVariant ( rss_child - > displayName ( ) + QString : : fromUtf8 ( " ( " ) + QString : : number ( rss_child - > unreadCount ( ) , 10 ) + QString ( " ) " ) ) ) ;
// Notify TreeWidget of item addition
// Notify TreeWidget of item addition
listStreams - > itemAdded ( item , rss_child ) ;
m_feedList - > itemAdded ( item , rss_child ) ;
// Set Icon
// Set Icon
if ( rss_child - > type ( ) = = RssFile : : FEED ) {
if ( rss_child - > type ( ) = = I RssFile: : FEED ) {
item - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( QString : : fromUtf8 ( " :/Icons/loading.png " ) ) ) ) ;
item - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( QString : : fromUtf8 ( " :/Icons/loading.png " ) ) ) ) ;
} else {
} else {
item - > setData ( 0 , Qt : : DecorationRole , QVariant ( IconProvider : : instance ( ) - > getIcon ( " inode-directory " ) ) ) ;
item - > setData ( 0 , Qt : : DecorationRole , QVariant ( IconProvider : : instance ( ) - > getIcon ( " inode-directory " ) ) ) ;
@ -443,18 +443,18 @@ void RSSImp::fillFeedsList(QTreeWidgetItem *parent, RssFolder *rss_parent) {
}
}
// fills the newsList
// fills the newsList
void RSSImp : : refreshNews List ( QTreeWidgetItem * item ) {
void RSSImp : : refreshArticle List ( QTreeWidgetItem * item ) {
if ( ! item ) {
if ( ! item ) {
listArticles - > clear ( ) ;
listArticles - > clear ( ) ;
return ;
return ;
}
}
RssFile * rss_item = listStreams - > getRSSItem ( item ) ;
I RssFile * rss_item = m_feedList - > getRSSItem ( item ) ;
if ( ! rss_item ) return ;
if ( ! rss_item ) return ;
qDebug ( " Getting the list of news " ) ;
qDebug ( " Getting the list of news " ) ;
QList < RssArticle > news ;
QList < RssArticle > news ;
if ( rss_item = = rssm anager)
if ( rss_item = = m_rssM anager)
news = RssManager : : sortNewsList ( rss_item - > unreadArticleList ( ) ) ;
news = RssManager : : sortNewsList ( rss_item - > unreadArticleList ( ) ) ;
else if ( rss_item )
else if ( rss_item )
news = RssManager : : sortNewsList ( rss_item - > articleList ( ) ) ;
news = RssManager : : sortNewsList ( rss_item - > articleList ( ) ) ;
@ -489,7 +489,7 @@ void RSSImp::refreshTextBrowser() {
Q_ASSERT ( item ) ;
Q_ASSERT ( item ) ;
if ( item = = m_currentArticle ) return ;
if ( item = = m_currentArticle ) return ;
// Stop displaying previous news if necessary
// Stop displaying previous news if necessary
if ( listStreams - > currentFeed ( ) = = listStreams - > get UnreadItem( ) ) {
if ( m_feedList - > currentFeed ( ) = = m_feedList - > sticky UnreadItem( ) ) {
if ( m_currentArticle ) {
if ( m_currentArticle ) {
disconnect ( listArticles , SIGNAL ( itemSelectionChanged ( ) ) , this , SLOT ( refreshTextBrowser ( ) ) ) ;
disconnect ( listArticles , SIGNAL ( itemSelectionChanged ( ) ) , this , SLOT ( refreshTextBrowser ( ) ) ) ;
listArticles - > removeItemWidget ( m_currentArticle ) ;
listArticles - > removeItemWidget ( m_currentArticle ) ;
@ -499,7 +499,7 @@ void RSSImp::refreshTextBrowser() {
}
}
m_currentArticle = item ;
m_currentArticle = item ;
}
}
RssFeed * stream = listStreams - > getRSSItemFromUrl ( item - > data ( Article : : FeedUrlRole ) . toString ( ) ) ;
RssFeed * stream = m_feedList - > getRSSItemFromUrl ( item - > data ( Article : : FeedUrlRole ) . toString ( ) ) ;
RssArticle article = stream - > getItem ( item - > data ( Article : : IdRole ) . toString ( ) ) ;
RssArticle article = stream - > getItem ( item - > data ( Article : : IdRole ) . toString ( ) ) ;
QString html ;
QString html ;
html + = " <div style='border: 2px solid red; margin-left: 5px; margin-right: 5px; margin-bottom: 5px;'> " ;
html + = " <div style='border: 2px solid red; margin-left: 5px; margin-right: 5px; margin-bottom: 5px;'> " ;
@ -517,8 +517,8 @@ void RSSImp::refreshTextBrowser() {
item - > setData ( Article : : ColorRole , QVariant ( QColor ( " grey " ) ) ) ;
item - > setData ( Article : : ColorRole , QVariant ( QColor ( " grey " ) ) ) ;
item - > setData ( Article : : IconRole , QVariant ( QIcon ( " :/Icons/sphere.png " ) ) ) ;
item - > setData ( Article : : IconRole , QVariant ( QIcon ( " :/Icons/sphere.png " ) ) ) ;
// Decrement feed nb unread news
// Decrement feed nb unread news
updateItemInfos ( listStreams - > get UnreadItem( ) ) ;
updateItemInfos ( m_feedList - > sticky UnreadItem( ) ) ;
updateItemInfos ( listStreams - > getTreeItemFromUrl ( item - > data ( Article : : FeedUrlRole ) . toString ( ) ) ) ;
updateItemInfos ( m_feedList - > getTreeItemFromUrl ( item - > data ( Article : : FeedUrlRole ) . toString ( ) ) ) ;
}
}
void RSSImp : : saveSlidersPosition ( ) {
void RSSImp : : saveSlidersPosition ( ) {
@ -541,16 +541,16 @@ void RSSImp::restoreSlidersPosition() {
}
}
}
}
void RSSImp : : updateItemsInfos ( QList < QTreeWidgetItem * > items ) {
void RSSImp : : updateItemsInfos ( const QList < QTreeWidgetItem * > & items ) {
foreach ( QTreeWidgetItem * item , items ) {
foreach ( QTreeWidgetItem * item , items ) {
updateItemInfos ( item ) ;
updateItemInfos ( item ) ;
}
}
}
}
void RSSImp : : updateItemInfos ( QTreeWidgetItem * item ) {
void RSSImp : : updateItemInfos ( QTreeWidgetItem * item ) {
RssFile * rss_item = listStreams - > getRSSItem ( item ) ;
I RssFile * rss_item = m_feedList - > getRSSItem ( item ) ;
QString name ;
QString name ;
if ( rss_item = = rssm anager)
if ( rss_item = = m_rssM anager)
name = tr ( " Unread " ) ;
name = tr ( " Unread " ) ;
else
else
name = rss_item - > displayName ( ) ;
name = rss_item - > displayName ( ) ;
@ -560,15 +560,15 @@ void RSSImp::updateItemInfos(QTreeWidgetItem *item) {
updateItemInfos ( item - > parent ( ) ) ;
updateItemInfos ( item - > parent ( ) ) ;
}
}
void RSSImp : : updateFeedIcon ( QString url , QString icon_path ) {
void RSSImp : : updateFeedIcon ( const QString & url , const QString & icon_path ) {
QTreeWidgetItem * item = listStreams - > getTreeItemFromUrl ( url ) ;
QTreeWidgetItem * item = m_feedList - > getTreeItemFromUrl ( url ) ;
item - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( icon_path ) ) ) ;
item - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( icon_path ) ) ) ;
}
}
void RSSImp : : updateFeedInfos ( QString url , QString display_name , unsigned int nbUnread ) {
void RSSImp : : updateFeedInfos ( const QString & url , const QString & display_name , u int nbUnread ) {
qDebug ( ) < < Q_FUNC_INFO < < display_name ;
qDebug ( ) < < Q_FUNC_INFO < < display_name ;
QTreeWidgetItem * item = listStreams - > getTreeItemFromUrl ( url ) ;
QTreeWidgetItem * item = m_feedList - > getTreeItemFromUrl ( url ) ;
RssFeed * stream = ( RssFeed * ) listStreams - > getRSSItem ( item ) ;
RssFeed * stream = ( RssFeed * ) m_feedList - > getRSSItem ( item ) ;
item - > setText ( 0 , display_name + QString : : fromUtf8 ( " ( " ) + QString : : number ( nbUnread , 10 ) + QString ( " ) " ) ) ;
item - > setText ( 0 , display_name + QString : : fromUtf8 ( " ( " ) + QString : : number ( nbUnread , 10 ) + QString ( " ) " ) ) ;
if ( ! stream - > isLoading ( ) )
if ( ! stream - > isLoading ( ) )
item - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( stream - > icon ( ) ) ) ) ;
item - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( stream - > icon ( ) ) ) ) ;
@ -576,20 +576,20 @@ void RSSImp::updateFeedInfos(QString url, QString display_name, unsigned int nbU
if ( item - > parent ( ) )
if ( item - > parent ( ) )
updateItemInfos ( item - > parent ( ) ) ;
updateItemInfos ( item - > parent ( ) ) ;
// Update Unread item
// Update Unread item
updateItemInfos ( listStreams - > get UnreadItem( ) ) ;
updateItemInfos ( m_feedList - > sticky UnreadItem( ) ) ;
// If the feed is selected, update the displayed news
// If the feed is selected, update the displayed news
if ( listStreams - > currentItem ( ) = = item ) {
if ( m_feedList - > currentItem ( ) = = item ) {
refreshNews List ( item ) ;
refreshArticle List ( item ) ;
} else {
} else {
// Update unread items
// Update unread items
if ( listStreams - > currentItem ( ) = = listStreams - > get UnreadItem( ) ) {
if ( m_feedList - > currentItem ( ) = = m_feedList - > sticky UnreadItem( ) ) {
refreshNewsList ( listStreams - > get UnreadItem ( ) ) ;
refreshArticleList ( m_feedList - > sticky UnreadItem ( ) ) ;
}
}
}
}
}
}
void RSSImp : : updateRefreshInterval ( unsigned int val ) {
void RSSImp : : updateRefreshInterval ( u int val ) {
rssm anager- > updateRefreshInterval ( val ) ;
m_rssM anager- > updateRefreshInterval ( val ) ;
}
}
RSSImp : : RSSImp ( QWidget * parent ) : QWidget ( parent ) {
RSSImp : : RSSImp ( QWidget * parent ) : QWidget ( parent ) {
@ -612,22 +612,22 @@ RSSImp::RSSImp(QWidget *parent) : QWidget(parent) {
rssDownloaderBtn - > setIcon ( IconProvider : : instance ( ) - > getIcon ( " download " ) ) ;
rssDownloaderBtn - > setIcon ( IconProvider : : instance ( ) - > getIcon ( " download " ) ) ;
settingsButton - > setIcon ( IconProvider : : instance ( ) - > getIcon ( " preferences-system " ) ) ;
settingsButton - > setIcon ( IconProvider : : instance ( ) - > getIcon ( " preferences-system " ) ) ;
rssm anager = RssManager : : instance ( ) ;
m_rssM anager = RssManager : : instance ( ) ;
listStreams = new FeedListWidget ( splitter_h , rssm anager) ;
m_feedList = new FeedListWidget ( splitter_h , m_rssM anager) ;
splitter_h - > insertWidget ( 0 , listStreams ) ;
splitter_h - > insertWidget ( 0 , m_feedList ) ;
listArticles - > setSelectionBehavior ( QAbstractItemView : : SelectItems ) ;
listArticles - > setSelectionBehavior ( QAbstractItemView : : SelectItems ) ;
listArticles - > setSelectionMode ( QAbstractItemView : : SingleSelection ) ;
listArticles - > setSelectionMode ( QAbstractItemView : : SingleSelection ) ;
rssm anager- > loadStreamList ( ) ;
m_rssM anager- > loadStreamList ( ) ;
fillFeedsList ( ) ;
fillFeedsList ( ) ;
refreshNewsList ( listStreams - > currentItem ( ) ) ;
refreshArticleList ( m_feedList - > currentItem ( ) ) ;
loadFoldersOpenState ( ) ;
loadFoldersOpenState ( ) ;
connect ( rssm anager, SIGNAL ( feedInfosChanged ( QString , QString , unsigned int ) ) , this , SLOT ( updateFeedInfos ( QString , QString , unsigned int ) ) ) ;
connect ( m_rssM anager, SIGNAL ( feedInfosChanged ( QString , QString , unsigned int ) ) , this , SLOT ( updateFeedInfos ( QString , QString , unsigned int ) ) ) ;
connect ( rssm anager, SIGNAL ( feedIconChanged ( QString , QString ) ) , this , SLOT ( updateFeedIcon ( QString , QString ) ) ) ;
connect ( m_rssM anager, SIGNAL ( feedIconChanged ( QString , QString ) ) , this , SLOT ( updateFeedIcon ( QString , QString ) ) ) ;
connect ( listStreams , SIGNAL ( customContextMenuRequested ( const QPoint & ) ) , this , SLOT ( displayRSSListMenu ( const QPoint & ) ) ) ;
connect ( m_feedList , SIGNAL ( customContextMenuRequested ( const QPoint & ) ) , this , SLOT ( displayRSSListMenu ( const QPoint & ) ) ) ;
connect ( listArticles , SIGNAL ( customContextMenuRequested ( const QPoint & ) ) , this , SLOT ( displayItemsListMenu ( const QPoint & ) ) ) ;
connect ( listArticles , SIGNAL ( customContextMenuRequested ( const QPoint & ) ) , this , SLOT ( displayItemsListMenu ( const QPoint & ) ) ) ;
// Feeds list actions
// Feeds list actions
@ -643,15 +643,15 @@ RSSImp::RSSImp(QWidget *parent) : QWidget(parent) {
connect ( actionOpen_news_URL , SIGNAL ( triggered ( ) ) , this , SLOT ( openNewsUrl ( ) ) ) ;
connect ( actionOpen_news_URL , SIGNAL ( triggered ( ) ) , this , SLOT ( openNewsUrl ( ) ) ) ;
connect ( actionDownload_torrent , SIGNAL ( triggered ( ) ) , this , SLOT ( downloadTorrent ( ) ) ) ;
connect ( actionDownload_torrent , SIGNAL ( triggered ( ) ) , this , SLOT ( downloadTorrent ( ) ) ) ;
connect ( listStreams , SIGNAL ( currentItemChanged ( QTreeWidgetItem * , QTreeWidgetItem * ) ) , this , SLOT ( refreshNews List ( QTreeWidgetItem * ) ) ) ;
connect ( m_feedList , SIGNAL ( currentItemChanged ( QTreeWidgetItem * , QTreeWidgetItem * ) ) , this , SLOT ( refreshArticle List ( QTreeWidgetItem * ) ) ) ;
connect ( listStreams , SIGNAL ( foldersAltered ( QList < QTreeWidgetItem * > ) ) , this , SLOT ( updateItemsInfos ( QList < QTreeWidgetItem * > ) ) ) ;
connect ( m_feedList , SIGNAL ( foldersAltered ( QList < QTreeWidgetItem * > ) ) , this , SLOT ( updateItemsInfos ( QList < QTreeWidgetItem * > ) ) ) ;
connect ( listStreams , SIGNAL ( overwriteAttempt ( QString ) ) , this , SLOT ( displayOverwriteError ( QString ) ) ) ;
connect ( m_feedList , SIGNAL ( overwriteAttempt ( QString ) ) , this , SLOT ( displayOverwriteError ( QString ) ) ) ;
connect ( listArticles , SIGNAL ( itemSelectionChanged ( ) ) , this , SLOT ( refreshTextBrowser ( ) ) ) ;
connect ( listArticles , SIGNAL ( itemSelectionChanged ( ) ) , this , SLOT ( refreshTextBrowser ( ) ) ) ;
connect ( listArticles , SIGNAL ( itemDoubleClicked ( QListWidgetItem * , int ) ) , this , SLOT ( downloadTorrent ( ) ) ) ;
connect ( listArticles , SIGNAL ( itemDoubleClicked ( QListWidgetItem * , int ) ) , this , SLOT ( downloadTorrent ( ) ) ) ;
// Refresh all feeds
// Refresh all feeds
rssm anager- > refresh ( ) ;
m_rssM anager- > refresh ( ) ;
// Restore sliders position
// Restore sliders position
restoreSlidersPosition ( ) ;
restoreSlidersPosition ( ) ;
// Bind saveSliders slots
// Bind saveSliders slots
@ -664,7 +664,7 @@ RSSImp::RSSImp(QWidget *parent) : QWidget(parent) {
RSSImp : : ~ RSSImp ( ) {
RSSImp : : ~ RSSImp ( ) {
qDebug ( " Deleting RSSImp... " ) ;
qDebug ( " Deleting RSSImp... " ) ;
saveFoldersOpenState ( ) ;
saveFoldersOpenState ( ) ;
delete listStreams ;
delete m_feedList ;
RssManager : : drop ( ) ;
RssManager : : drop ( ) ;
qDebug ( " RSSImp deleted " ) ;
qDebug ( " RSSImp deleted " ) ;
}
}