Only re-load favourites if filename changed
This commit is contained in:
committed by
craig.p.drummond
parent
988b084bd2
commit
d32a9badb2
@@ -50,6 +50,7 @@
|
||||
#include <QFileInfo>
|
||||
#include <QTimer>
|
||||
#include <QLocale>
|
||||
#include <QFileSystemWatcher>
|
||||
#if QT_VERSION >= 0x050000
|
||||
#include <QUrlQuery>
|
||||
#endif
|
||||
@@ -61,6 +62,7 @@ K_GLOBAL_STATIC(StreamsModel, instance)
|
||||
#include <QDesktopServices>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#if defined ENABLE_MODEL_TEST
|
||||
#include "modeltest.h"
|
||||
@@ -840,6 +842,13 @@ bool StreamsModel::exportFavourites(const QString &fileName)
|
||||
return favourites->saveXml(fileName, true);
|
||||
}
|
||||
|
||||
void StreamsModel::reloadFavourites()
|
||||
{
|
||||
if (favourites->lastFileName.isEmpty() || favourites->lastFileName!=getInternalFile() || favourites->lastFileName.startsWith("http://")) {
|
||||
reload(favouritesIndex());
|
||||
}
|
||||
}
|
||||
|
||||
bool StreamsModel::checkFavouritesWritable()
|
||||
{
|
||||
bool wasWriteable=favouritesIsWriteable;
|
||||
@@ -1171,6 +1180,7 @@ void StreamsModel::jobFinished()
|
||||
QList<Item *> newItems;
|
||||
if (cat==favourites) {
|
||||
newItems=favourites->loadXml(job->actualJob());
|
||||
favourites->lastFileName=QString();
|
||||
} else if (QLatin1String("http")==job->url().scheme()) {
|
||||
QString url=job->origUrl().toString();
|
||||
if (constRadioTimeHost==job->origUrl().host()) {
|
||||
@@ -1830,7 +1840,10 @@ StreamsModel::Item * StreamsModel::parseSomaFmEntry(QXmlStreamReader &doc, Categ
|
||||
|
||||
bool StreamsModel::loadFavourites(const QString &fileName, const QModelIndex &index, bool importing)
|
||||
{
|
||||
QList<Item *> newItems=favourites->loadXml(fileName, importing);
|
||||
QList<Item *> newItems=favourites->CategoryItem::loadXml(fileName, importing);
|
||||
if (!importing) {
|
||||
favourites->lastFileName=fileName;
|
||||
}
|
||||
|
||||
if (!newItems.isEmpty()) {
|
||||
beginInsertRows(index, favourites->children.count(), (favourites->children.count()+newItems.count())-1);
|
||||
|
||||
@@ -112,6 +112,7 @@ public:
|
||||
QList<Item *> loadXml(QIODevice *dev, bool importing=false);
|
||||
bool isFavourites() const { return true; }
|
||||
bool canReload() const { return false; }
|
||||
QString lastFileName;
|
||||
};
|
||||
|
||||
struct IceCastCategoryItem : public CategoryItem
|
||||
@@ -204,7 +205,7 @@ public:
|
||||
bool haveFavourites() const { return !favourites->children.isEmpty(); }
|
||||
bool isFavoritesWritable() { return favouritesIsWriteable; }
|
||||
bool checkFavouritesWritable();
|
||||
void reloadFavourites() { reload(favouritesIndex()); }
|
||||
void reloadFavourites();
|
||||
void removeFromFavourites(const QModelIndex &index);
|
||||
bool addToFavourites(const QString &url, const QString &name);
|
||||
QString favouritesNameForUrl(const QString &u);
|
||||
@@ -271,7 +272,7 @@ private:
|
||||
private:
|
||||
QMap<NetworkJob *, CategoryItem *> jobs;
|
||||
CategoryItem *root;
|
||||
CategoryItem *favourites;
|
||||
FavouritesCategoryItem *favourites;
|
||||
CategoryItem *tuneIn;
|
||||
CategoryItem *shoutCast;
|
||||
CategoryItem *listenLive;
|
||||
|
||||
Reference in New Issue
Block a user