@ -56,18 +56,20 @@ void RSSImp::displayRSSListMenu(const QPoint& pos){
myRSSListMenu . addSeparator ( ) ;
myRSSListMenu . addSeparator ( ) ;
if ( selectedItems . size ( ) = = 1 ) {
if ( selectedItems . size ( ) = = 1 ) {
myRSSListMenu . addAction ( actionRename ) ;
myRSSListMenu . addAction ( actionRename ) ;
RssFile * rss_item = rssmanager - > getFile ( listStreams - > getItemPath ( selectedItems . first ( ) ) ) ;
myRSSListMenu . addAction ( actionDelete ) ;
if ( rss_item - > getType ( ) = = RssFile : : FOLDER )
myRSSListMenu . addSeparator ( ) ;
if ( listStreams - > getItemType ( selectedItems . first ( ) ) = = RssFile : : FOLDER )
myRSSListMenu . addAction ( actionNew_folder ) ;
myRSSListMenu . addAction ( actionNew_folder ) ;
}
}
myRSSListMenu . addAction ( actionDelete ) ;
myRSSListMenu . addAction ( actionNew_subscription ) ;
if ( listStreams - > getItemType ( selectedItems . first ( ) ) = = RssFile : : STREAM ) {
myRSSListMenu . addSeparator ( ) ;
myRSSListMenu . addSeparator ( ) ;
myRSSListMenu . addAction ( actionCopy_feed_URL ) ;
myRSSListMenu . addAction ( actionCopy_feed_URL ) ;
if ( selectedItems . size ( ) = = 1 ) {
if ( selectedItems . size ( ) = = 1 ) {
myRSSListMenu . addSeparator ( ) ;
myRSSListMenu . addSeparator ( ) ;
myRSSListMenu . addAction ( actionRSS_feed_downloader ) ;
myRSSListMenu . addAction ( actionRSS_feed_downloader ) ;
}
}
}
} else {
} else {
myRSSListMenu . addAction ( actionNew_subscription ) ;
myRSSListMenu . addAction ( actionNew_subscription ) ;
myRSSListMenu . addAction ( actionNew_folder ) ;
myRSSListMenu . addAction ( actionNew_folder ) ;
@ -87,38 +89,29 @@ void RSSImp::displayItemsListMenu(const QPoint&){
myItemListMenu . exec ( QCursor : : pos ( ) ) ;
myItemListMenu . exec ( QCursor : : pos ( ) ) ;
}
}
QStringList RSSImp : : getCurrentFeedPath ( ) const {
return listStreams - > getItemPath ( listStreams - > currentItem ( ) ) ;
}
RssFile : : FileType RSSImp : : getItemType ( QTreeWidgetItem * item ) const {
if ( ! item )
return RssFile : : FOLDER ;
return ( RssFile : : FileType ) item - > text ( 2 ) . toInt ( ) ;
}
void RSSImp : : askNewFolder ( ) {
void RSSImp : : askNewFolder ( ) {
QStringList dest_path ;
QTreeWidgetItem * parent_item = 0 ;
QTreeWidgetItem * parent_item = 0 ;
RssFolder * rss_parent ;
if ( listStreams - > selectedItems ( ) . size ( ) > 0 ) {
if ( listStreams - > selectedItems ( ) . size ( ) > 0 ) {
parent_item = listStreams - > selectedItems ( ) . at ( 0 ) ;
parent_item = listStreams - > selectedItems ( ) . at ( 0 ) ;
foreach ( QString name , listStreams - > getItemPath ( parent_item ) ) {
rss_parent = ( RssFolder * ) listStreams - > getRSSItem ( parent_item ) ;
dest_path < < name ;
Q_ASSERT ( rss_parent - > getType ( ) = = RssFile : : FOLDER ) ;
}
} else {
rss_parent = rssmanager ;
}
}
bool ok ;
bool ok ;
QString newFolder = 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 ) ;
if ( ok ) {
if ( ok ) {
dest_path < < newFolder ;
RssFolder * new_folder = rss_parent - > addFolder ( new_name ) ;
RssFolder * new_folder = rssmanager - > addFolder ( dest_path ) ;
QTreeWidgetItem * folder_item ;
QTreeWidgetItem * folder_item ;
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 ( listStreams ) ;
// Notify TreeWidget
listStreams - > itemAdded ( folder_item , new_folder ) ;
// Set Text
folder_item - > setText ( 0 , new_folder - > getName ( ) + QString : : fromUtf8 ( " (0) " ) ) ;
folder_item - > setText ( 0 , new_folder - > getName ( ) + QString : : fromUtf8 ( " (0) " ) ) ;
folder_item - > setText ( 1 , new_folder - > getName ( ) ) ;
folder_item - > setData ( 2 , Qt : : DisplayRole , QVariant ( ( int ) RssFile : : FOLDER ) ) ;
folder_item - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( " :/Icons/oxygen/folder.png " ) ) ) ;
folder_item - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( " :/Icons/oxygen/folder.png " ) ) ) ;
// Expand parent folder to display new folder
// Expand parent folder to display new folder
if ( parent_item )
if ( parent_item )
@ -129,12 +122,22 @@ void RSSImp::askNewFolder() {
// add a stream by a button
// add a stream by a button
void RSSImp : : on_newFeedButton_clicked ( ) {
void RSSImp : : on_newFeedButton_clicked ( ) {
QStringList dest_path ;
// Determine parent folder for new feed
QTreeWidgetItem * current_item = listStreams - > currentItem ( ) ;
QTreeWidgetItem * parent_item = 0 ;
if ( getItemType ( current_item ) ! = RssFile : : FOLDER )
QList < QTreeWidgetItem * > selected_items = listStreams - > selectedItems ( ) ;
dest_path = listStreams - > getItemPath ( current_item - > parent ( ) ) ;
if ( ! selected_items . empty ( ) )
parent_item = selected_items . first ( ) ;
RssFolder * rss_parent ;
if ( parent_item ) {
RssFile * tmp = listStreams - > getRSSItem ( parent_item ) ;
if ( tmp - > getType ( ) = = RssFile : : FOLDER )
rss_parent = ( RssFolder * ) tmp ;
else
else
dest_path = listStreams - > getItemPath ( current_item ) ;
rss_parent = tmp - > getParent ( ) ;
} else {
rss_parent = rssmanager ;
}
// Ask for feed URL
bool ok ;
bool ok ;
QString clip_txt = qApp - > clipboard ( ) - > text ( ) ;
QString clip_txt = qApp - > clipboard ( ) - > text ( ) ;
QString default_url = " http:// " ;
QString default_url = " http:// " ;
@ -145,19 +148,19 @@ void RSSImp::on_newFeedButton_clicked() {
if ( ok ) {
if ( ok ) {
newUrl = newUrl . trimmed ( ) ;
newUrl = newUrl . trimmed ( ) ;
if ( ! newUrl . isEmpty ( ) ) {
if ( ! newUrl . isEmpty ( ) ) {
dest_path . append ( newUrl ) ;
if ( listStreams - > hasFeed ( newUrl ) ) {
RssStream * stream = rssmanager - > addStream ( dest_path ) ;
if ( stream = = 0 ) {
// Already existing
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 ) ;
return ;
return ;
}
}
RssStream * stream = rss_parent - > addStream ( newUrl ) ;
// Create TreeWidget item
QTreeWidgetItem * item = new QTreeWidgetItem ( listStreams ) ;
QTreeWidgetItem * item = new QTreeWidgetItem ( listStreams ) ;
// Notify TreeWidget
listStreams - > itemAdded ( item , stream ) ;
// Set text
item - > setText ( 0 , stream - > getName ( ) + QString : : fromUtf8 ( " (0) " ) ) ;
item - > setText ( 0 , stream - > getName ( ) + QString : : fromUtf8 ( " (0) " ) ) ;
item - > setText ( 1 , stream - > getUrl ( ) ) ;
item - > setData ( 2 , Qt : : DisplayRole , QVariant ( ( int ) RssFile : : STREAM ) ) ;
item - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( " :/Icons/loading.png " ) ) ) ;
item - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( " :/Icons/loading.png " ) ) ) ;
if ( listStreams - > topLevelItemCount ( ) = = 1 )
if ( listStreams - > topLevelItemCount ( ) = = 1 )
selectFirstFeed ( ) ;
selectFirstFeed ( ) ;
@ -171,17 +174,26 @@ void RSSImp::on_newFeedButton_clicked() {
void RSSImp : : deleteSelectedItems ( ) {
void RSSImp : : deleteSelectedItems ( ) {
QList < QTreeWidgetItem * > selectedItems = listStreams - > selectedItems ( ) ;
QList < QTreeWidgetItem * > selectedItems = listStreams - > selectedItems ( ) ;
if ( selectedItems . size ( ) = = 0 ) return ;
if ( selectedItems . size ( ) = = 0 ) return ;
if ( ! selectedItems . size ( ) ) return ;
int ret ;
int ret = QMessageBox : : question ( this , tr ( " Are you sure? -- qBittorrent " ) , tr ( " Are you sure you want to delete this RSS feed from the list? " ) ,
if ( selectedItems . size ( ) > 1 )
ret = QMessageBox : : question ( this , tr ( " Are you sure? -- qBittorrent " ) , tr ( " Are you sure you want to delete these elements from the list? " ) ,
tr ( " &Yes " ) , tr ( " &No " ) ,
QString ( ) , 0 , 1 ) ;
else
ret = QMessageBox : : question ( this , tr ( " Are you sure? -- qBittorrent " ) , tr ( " Are you sure you want to delete this element from the list? " ) ,
tr ( " &Yes " ) , tr ( " &No " ) ,
tr ( " &Yes " ) , tr ( " &No " ) ,
QString ( ) , 0 , 1 ) ;
QString ( ) , 0 , 1 ) ;
if ( ! ret ) {
if ( ! ret ) {
foreach ( QTreeWidgetItem * item , selectedItems ) {
foreach ( QTreeWidgetItem * item , selectedItems ) {
if ( listStreams - > currentItem ( ) = = item ) {
if ( listStreams - > currentFeed ( ) = = item ) {
textBrowser - > clear ( ) ;
textBrowser - > clear ( ) ;
listNews - > clear ( ) ;
listNews - > clear ( ) ;
}
}
rssmanager - > removeFile ( listStreams - > getItemPath ( item ) ) ;
RssFile * rss_item = listStreams - > getRSSItem ( item ) ;
rss_item - > getParent ( ) - > removeFile ( rss_item - > getID ( ) ) ;
// Notify TreeWidget
listStreams - > itemRemoved ( item ) ;
// Actually delete the item
delete item ;
delete item ;
}
}
rssmanager - > saveStreamList ( ) ;
rssmanager - > saveStreamList ( ) ;
@ -199,7 +211,7 @@ void RSSImp::on_updateAllButton_clicked() {
void RSSImp : : downloadTorrent ( ) {
void RSSImp : : downloadTorrent ( ) {
QList < QListWidgetItem * > selected_items = listNews - > selectedItems ( ) ;
QList < QListWidgetItem * > selected_items = listNews - > selectedItems ( ) ;
foreach ( const QListWidgetItem * item , selected_items ) {
foreach ( const QListWidgetItem * item , selected_items ) {
RssItem * news = ( ( RssStream * ) rssmanager - > getFile ( getCurrentFeedPath ( ) ) ) - > getItem ( listNews - > row ( item ) ) ;
RssItem * news = ( ( RssStream * ) listSt ream s- > getCurrentRSSItem ( ) ) - > getItem ( listNews - > row ( item ) ) ;
BTSession - > downloadFromUrl ( news - > getTorrentUrl ( ) ) ;
BTSession - > downloadFromUrl ( news - > getTorrentUrl ( ) ) ;
}
}
}
}
@ -208,7 +220,7 @@ void RSSImp::downloadTorrent() {
void RSSImp : : openNewsUrl ( ) {
void RSSImp : : openNewsUrl ( ) {
QList < QListWidgetItem * > selected_items = listNews - > selectedItems ( ) ;
QList < QListWidgetItem * > selected_items = listNews - > selectedItems ( ) ;
foreach ( const QListWidgetItem * item , selected_items ) {
foreach ( const QListWidgetItem * item , selected_items ) {
RssItem * news = ( ( RssStream * ) rssmanager - > getFile ( getCurrentFeedPath ( ) ) ) - > getItem ( listNews - > row ( item ) ) ;
RssItem * news = ( ( RssStream * ) listSt ream s- > getCurrentRSSItem ( ) ) - > getItem ( listNews - > row ( item ) ) ;
QString link = news - > getLink ( ) ;
QString link = news - > getLink ( ) ;
if ( ! link . isEmpty ( ) )
if ( ! link . isEmpty ( ) )
QDesktopServices : : openUrl ( QUrl ( link ) ) ;
QDesktopServices : : openUrl ( QUrl ( link ) ) ;
@ -220,16 +232,22 @@ void RSSImp::renameFiles() {
QList < QTreeWidgetItem * > selectedItems = listStreams - > selectedItems ( ) ;
QList < QTreeWidgetItem * > selectedItems = listStreams - > 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 ) ;
bool ok ;
bool ok ;
QString newName = QInputDialog : : getText ( this , tr ( " Please choose a new name for this RSS feed " ) , tr ( " New feed name: " ) , QLineEdit : : Normal , rssmanager - > getFile ( listStreams - > getItemPath ( item ) ) - > getName ( ) , & ok ) ;
QString newName ;
do {
newName = QInputDialog : : getText ( this , tr ( " Please choose a new name for this RSS feed " ) , tr ( " New feed name: " ) , QLineEdit : : Normal , listStreams - > getRSSItem ( item ) - > getName ( ) , & ok ) ;
// Check if name is already taken
if ( ok & & rss_item - > getParent ( ) - > contains ( newName ) ) {
QMessageBox : : warning ( 0 , tr ( " Name already in use " ) , tr ( " This name is already used by another item, please choose another one. " ) ) ;
ok = false ;
}
} while ( ! ok ) ;
if ( ok ) {
if ( ok ) {
QStringList item_path = listStreams - > getItemPath ( item ) ;
// Rename item
rssmanager - > rename ( item_path , newName ) ;
rss_item - > rename ( newName ) ;
item - > setText ( 0 , newName ) ;
// Update TreeWidget
if ( rssmanager - > getFile ( item_path ) - > getType ( ) = = RssFile : : FOLDER ) {
item - > setText ( 0 , newName + QString ( " ( " ) + QString : : number ( rss_item - > getNbUnRead ( ) ) + QString ( " ) " ) ) ;
// If it is a folder, we must update second column too
item - > setText ( 1 , newName ) ;
}
}
}
}
}
@ -238,8 +256,10 @@ void RSSImp::refreshSelectedStreams() {
QList < QTreeWidgetItem * > selectedItems = listStreams - > selectedItems ( ) ;
QList < QTreeWidgetItem * > selectedItems = listStreams - > selectedItems ( ) ;
QTreeWidgetItem * item ;
QTreeWidgetItem * item ;
foreach ( item , selectedItems ) {
foreach ( item , selectedItems ) {
rssmanager - > refresh ( listStreams - > getItemPath ( item ) ) ;
RssFile * file = listStreams - > getRSSItem ( item ) ;
if ( getItemType ( item ) = = RssFile : : STREAM )
file - > refresh ( ) ;
// FIXME: Should recursively set icons for feeds in a folder
if ( file - > getType ( ) = = RssFile : : STREAM )
item - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( " :/Icons/loading.png " ) ) ) ;
item - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( " :/Icons/loading.png " ) ) ) ;
}
}
}
}
@ -249,23 +269,23 @@ void RSSImp::copySelectedFeedsURL() {
QList < QTreeWidgetItem * > selectedItems = listStreams - > selectedItems ( ) ;
QList < QTreeWidgetItem * > selectedItems = listStreams - > selectedItems ( ) ;
QTreeWidgetItem * item ;
QTreeWidgetItem * item ;
foreach ( item , selectedItems ) {
foreach ( item , selectedItems ) {
URLs < < item - > text ( 1 ) ;
URLs < < l istS tr ea ms - > getItemID ( item ) ;
}
}
qApp - > clipboard ( ) - > setText ( URLs . join ( " \n " ) ) ;
qApp - > clipboard ( ) - > setText ( URLs . join ( " \n " ) ) ;
}
}
void RSSImp : : showFeedDownloader ( ) {
void RSSImp : : showFeedDownloader ( ) {
QTreeWidgetItem * item = listStreams - > selectedItems ( ) [ 0 ] ;
QTreeWidgetItem * item = listStreams - > selectedItems ( ) [ 0 ] ;
RssFile * rss_item = rssmanager - > getFile ( listStreams - > getItemPath ( item ) ) ;
RssFile * rss_item = listStreams - > getRSS Item ( item ) ;
if ( rss_item - > getType ( ) = = RssFile : : STREAM )
if ( rss_item - > getType ( ) = = RssFile : : STREAM )
new FeedDownloaderDlg ( this , item - > text ( 1 ) , rss_item - > getName ( ) , BTSession ) ;
new FeedDownloaderDlg ( this , l istS tr ea ms - > getItemID ( item ) , rss_item - > getName ( ) , BTSession ) ;
}
}
void RSSImp : : on_markReadButton_clicked ( ) {
void RSSImp : : on_markReadButton_clicked ( ) {
QList < QTreeWidgetItem * > selectedItems = listStreams - > selectedItems ( ) ;
QList < QTreeWidgetItem * > selectedItems = listStreams - > selectedItems ( ) ;
QTreeWidgetItem * item ;
QTreeWidgetItem * item ;
foreach ( item , selectedItems ) {
foreach ( item , selectedItems ) {
RssFile * rss_item = rssmanager - > getFile ( listStreams - > getItemPath ( item ) ) ;
RssFile * rss_item = listStreams - > getRSS Item ( item ) ;
rss_item - > markAllAsRead ( ) ;
rss_item - > markAllAsRead ( ) ;
item - > setData ( 0 , Qt : : DisplayRole , rss_item - > getName ( ) + QString : : fromUtf8 ( " (0) " ) ) ;
item - > setData ( 0 , Qt : : DisplayRole , rss_item - > getName ( ) + QString : : fromUtf8 ( " (0) " ) ) ;
}
}
@ -287,14 +307,13 @@ void RSSImp::fillFeedsList(QTreeWidgetItem *parent, RssFolder *rss_parent) {
else
else
item = new QTreeWidgetItem ( parent ) ;
item = new QTreeWidgetItem ( parent ) ;
item - > setData ( 0 , Qt : : DisplayRole , rss_child - > getName ( ) + QString : : fromUtf8 ( " ( " ) + QString : : number ( rss_child - > getNbUnRead ( ) , 10 ) + QString ( " ) " ) ) ;
item - > setData ( 0 , Qt : : DisplayRole , rss_child - > getName ( ) + QString : : fromUtf8 ( " ( " ) + QString : : number ( rss_child - > getNbUnRead ( ) , 10 ) + QString ( " ) " ) ) ;
// Notify TreeWidget of item addition
listStreams - > itemAdded ( item , rss_child ) ;
// Set Icon
if ( rss_child - > getType ( ) = = RssFile : : STREAM ) {
if ( rss_child - > getType ( ) = = RssFile : : STREAM ) {
item - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( QString : : fromUtf8 ( " :/Icons/loading.png " ) ) ) ) ;
item - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( QString : : fromUtf8 ( " :/Icons/loading.png " ) ) ) ) ;
item - > setData ( 1 , Qt : : DisplayRole , ( ( RssStream * ) rss_child ) - > getUrl ( ) ) ;
item - > setData ( 2 , Qt : : DisplayRole , QVariant ( ( int ) rss_child - > getType ( ) ) ) ;
} else {
} else {
item - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( QString : : fromUtf8 ( " :/Icons/oxygen/folder.png " ) ) ) ) ;
item - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( QString : : fromUtf8 ( " :/Icons/oxygen/folder.png " ) ) ) ) ;
item - > setData ( 1 , Qt : : DisplayRole , ( ( RssFolder * ) rss_child ) - > getName ( ) ) ;
item - > setData ( 2 , Qt : : DisplayRole , QVariant ( ( int ) rss_child - > getType ( ) ) ) ;
// Recurvive call to load sub folders/files
// Recurvive call to load sub folders/files
fillFeedsList ( item , ( RssFolder * ) rss_child ) ;
fillFeedsList ( item , ( RssFolder * ) rss_child ) ;
}
}
@ -307,14 +326,12 @@ void RSSImp::refreshNewsList(QTreeWidgetItem* item) {
listNews - > clear ( ) ;
listNews - > clear ( ) ;
return ;
return ;
}
}
qDebug ( " RefreshNewsList for item: %s " , item - > text ( 1 ) . toLocal8Bit ( ) . data ( ) ) ;
if ( listStreams - > getItemType ( item ) ! = RssFile : : STREAM ) {
qDebug ( " Item path: %s " , listStreams - > getItemPath ( item ) . join ( " \\ " ) . toLocal8Bit ( ) . data ( ) ) ;
RssFile * file = rssmanager - > getFile ( listStreams - > getItemPath ( item ) ) ;
if ( file - > getType ( ) ! = RssFile : : STREAM ) {
listNews - > clear ( ) ;
listNews - > clear ( ) ;
return ;
return ;
}
}
RssStream * stream = ( RssStream * ) file ;
RssStream * stream = ( RssStream * ) listStreams - > getRSSItem ( item ) ;
qDebug ( " Getting the list of news " ) ;
qDebug ( " Getting the list of news " ) ;
QList < RssItem * > news = stream - > getNewsList ( ) ;
QList < RssItem * > news = stream - > getNewsList ( ) ;
@ -333,14 +350,13 @@ void RSSImp::refreshNewsList(QTreeWidgetItem* item) {
}
}
}
}
qDebug ( " Added all news to the GUI " ) ;
qDebug ( " Added all news to the GUI " ) ;
//selectFirstNews();
qDebug ( " First news selected " ) ;
qDebug ( " First news selected " ) ;
}
}
// display a news
// display a news
void RSSImp : : refreshTextBrowser ( QListWidgetItem * item ) {
void RSSImp : : refreshTextBrowser ( QListWidgetItem * item ) {
if ( ! item ) return ;
if ( ! item ) return ;
RssStream * stream = ( RssStream * ) rssmanager - > getFile ( getCurrentFeedPath ( ) ) ;
RssStream * stream = ( RssStream * ) listSt ream s- > getCurrentRSSItem ( ) ;
RssItem * article = stream - > getItem ( listNews - > row ( item ) ) ;
RssItem * article = stream - > getItem ( listNews - > row ( item ) ) ;
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;'> " ;
@ -380,32 +396,19 @@ void RSSImp::restoreSlidersPosition() {
}
}
}
}
QTreeWidgetItem * RSSImp : : getTreeItemFromUrl ( QString url ) const {
QList < QTreeWidgetItem * > items = listStreams - > findItems ( url , Qt : : MatchExactly , 1 ) ;
Q_ASSERT ( items . size ( ) = = 1 ) ;
return items . at ( 0 ) ;
}
void RSSImp : : updateFeedIcon ( QString url , QString icon_path ) {
void RSSImp : : updateFeedIcon ( QString url , QString icon_path ) {
QTreeWidgetItem * item = getTreeItemFromUrl ( url ) ;
QTreeWidgetItem * item = listStreams - > getTreeItemFromUrl ( url ) ;
item - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( icon_path ) ) ) ;
item - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( icon_path ) ) ) ;
}
}
void RSSImp : : updateFeedNbNews ( RssStream * stream ) {
void RSSImp : : updateFeedNbNews ( RssStream * stream ) {
QTreeWidgetItem * item = getTreeItemFromUrl ( stream - > getUrl ( ) ) ;
QTreeWidgetItem * item = listStreams - > getTreeItemFromUrl ( stream - > getUrl ( ) ) ;
item - > setText ( 0 , stream - > getName ( ) + QString : : fromUtf8 ( " ( " ) + QString : : number ( stream - > getNbUnRead ( ) , 10 ) + QString ( " ) " ) ) ;
item - > setText ( 0 , stream - > getName ( ) + QString : : fromUtf8 ( " ( " ) + QString : : number ( stream - > getNbUnRead ( ) , 10 ) + QString ( " ) " ) ) ;
}
}
QString RSSImp : : getCurrentFeedUrl ( ) const {
QTreeWidgetItem * item = listStreams - > currentItem ( ) ;
if ( item )
return item - > text ( 1 ) ;
return QString : : null ;
}
void RSSImp : : updateFeedInfos ( QString url , QString aliasOrUrl , unsigned int nbUnread ) {
void RSSImp : : updateFeedInfos ( QString url , QString aliasOrUrl , unsigned int nbUnread ) {
QTreeWidgetItem * item = getTreeItemFromUrl ( url ) ;
QTreeWidgetItem * item = listStreams - > getTreeItemFromUrl ( url ) ;
RssStream * stream = ( RssStream * ) rssmanager - > getFile ( listStreams - > getItemPath ( item ) ) ;
RssStream * stream = ( RssStream * ) listStreams - > getRSSItem ( item ) ;
item - > setText ( 0 , aliasOrUrl + QString : : fromUtf8 ( " ( " ) + QString : : number ( nbUnread , 10 ) + QString ( " ) " ) ) ;
item - > setText ( 0 , aliasOrUrl + QString : : fromUtf8 ( " ( " ) + QString : : number ( nbUnread , 10 ) + QString ( " ) " ) ) ;
item - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( stream - > getIconPath ( ) ) ) ) ;
item - > setData ( 0 , Qt : : DecorationRole , QVariant ( QIcon ( stream - > getIconPath ( ) ) ) ) ;
// If the feed is selected, update the displayed news
// If the feed is selected, update the displayed news