Expand podcasts by default - if it is the only service, or if it and soundcloud are the only services
This commit is contained in:
committed by
craig.p.drummond
parent
3f36596d25
commit
ccbb0dd87f
@@ -83,6 +83,7 @@ public:
|
||||
void deleteDownloadedPodcasts(MusicLibraryItemPodcast *pod, const QList<MusicLibraryItemPodcastEpisode *> &episodes);
|
||||
bool isDownloading() const;
|
||||
void cancelAll();
|
||||
bool isHidden(OnlineService *srv) { return hiddenServices.contains(srv); }
|
||||
|
||||
QImage requestImage(const QString &id, const QString &artist, const QString &album, const QString &url,
|
||||
const QString cacheName=QString(), int maxSize=-1);
|
||||
|
||||
@@ -132,9 +132,9 @@ public:
|
||||
const MusicLibraryItem * findSong(const Song &s) const;
|
||||
bool songExists(const Song &s) const;
|
||||
bool isConfigured() { return configured; }
|
||||
QModelIndex index() const;
|
||||
|
||||
protected:
|
||||
QModelIndex index() const;
|
||||
QModelIndex createIndex(MusicLibraryItem *child) const;
|
||||
void emitUpdated();
|
||||
void emitError(const QString &msg);
|
||||
|
||||
@@ -122,6 +122,9 @@ void OnlineServicesPage::setEnabled(bool e)
|
||||
controlActions();
|
||||
if (e) {
|
||||
proxy.sort();
|
||||
// TODO: Why do we need to call tis via a timer, whith such a large timeout?
|
||||
// If we use a timeout < 75, then nothing gets expanded - eventhough the indexes are valid!
|
||||
QTimer::singleShot(100, this, SLOT(expandPodcasts()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -767,3 +770,22 @@ void OnlineServicesPage::sortList()
|
||||
{
|
||||
proxy.sort();
|
||||
}
|
||||
|
||||
|
||||
void OnlineServicesPage::expandPodcasts()
|
||||
{
|
||||
// If we only have PodCast service enabled, or only PodCast and SoundCloud, then
|
||||
// expand PodCast by default...
|
||||
if (OnlineServicesModel::self()->rowCount()>0 && OnlineServicesModel::self()->rowCount()<3) {
|
||||
OnlineService *pod=OnlineServicesModel::self()->service(PodcastService::constName);
|
||||
if (!OnlineServicesModel::self()->isHidden(pod)) {
|
||||
if (2==OnlineServicesModel::self()->rowCount()) {
|
||||
OnlineService *sound=OnlineServicesModel::self()->service(SoundCloudService::constName);
|
||||
if (OnlineServicesModel::self()->isHidden(sound)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
view->expand(proxy.mapFromSource(pod->index()), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@ public Q_SLOTS:
|
||||
void searchForPodcasts();
|
||||
void downloadPodcast();
|
||||
void deleteDownloadedPodcast();
|
||||
void expandPodcasts();
|
||||
|
||||
Q_SIGNALS:
|
||||
// These are for communicating with MPD object (which is in its own thread, so need to talk via signal/slots)
|
||||
|
||||
@@ -158,7 +158,7 @@ void StreamsPage::refresh()
|
||||
searchView->setLevel(0);
|
||||
StreamsModel::self()->reloadFavourites();
|
||||
exportAction->setEnabled(StreamsModel::self()->rowCount()>0);
|
||||
view->expand(proxy->mapFromSource(StreamsModel::self()->favouritesIndex()));
|
||||
view->expand(proxy->mapFromSource(StreamsModel::self()->favouritesIndex()), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -820,14 +820,16 @@ void GroupedView::itemClicked(const QModelIndex &idx)
|
||||
}
|
||||
}
|
||||
|
||||
void GroupedView::expand(const QModelIndex &idx)
|
||||
void GroupedView::expand(const QModelIndex &idx, bool singleOnly)
|
||||
{
|
||||
if (idx.isValid()) {
|
||||
if (idx.data(GroupedView::Role_IsCollection).toBool()) {
|
||||
setExpanded(idx, true);
|
||||
quint32 count=model()->rowCount(idx);
|
||||
for (quint32 i=0; i<count; ++i) {
|
||||
expand(idx.child(i, 0));
|
||||
if (!singleOnly) {
|
||||
quint32 count=model()->rowCount(idx);
|
||||
for (quint32 i=0; i<count; ++i) {
|
||||
expand(idx.child(i, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (AlbumHeader==getType(idx)) {
|
||||
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
QModelIndexList selectedIndexes(bool sorted) const;
|
||||
void dropEvent(QDropEvent *event);
|
||||
void collectionRemoved(quint32 key);
|
||||
void expand(const QModelIndex &idx);
|
||||
void expand(const QModelIndex &idx, bool singleOnly=false);
|
||||
|
||||
public Q_SLOTS:
|
||||
void updateRows(const QModelIndex &parent);
|
||||
|
||||
@@ -878,12 +878,12 @@ void ItemView::expandAll(const QModelIndex &index)
|
||||
}
|
||||
}
|
||||
|
||||
void ItemView::expand(const QModelIndex &index)
|
||||
void ItemView::expand(const QModelIndex &index, bool singleOnly)
|
||||
{
|
||||
if (Mode_SimpleTree==mode || Mode_DetailedTree==mode) {
|
||||
treeView->expand(index);
|
||||
treeView->expand(index, singleOnly);
|
||||
} else if (Mode_GroupedTree==mode && groupedView) {
|
||||
groupedView->expand(index);
|
||||
groupedView->expand(index, singleOnly);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ public:
|
||||
void setStartClosed(bool sc);
|
||||
bool isStartClosed();
|
||||
void expandAll(const QModelIndex &index=QModelIndex());
|
||||
void expand(const QModelIndex &index);
|
||||
void expand(const QModelIndex &index, bool singleOnly=false);
|
||||
void showMessage(const QString &message, int timeout);
|
||||
void setBackgroundImage(const QIcon &icon);
|
||||
|
||||
|
||||
@@ -270,13 +270,15 @@ void TreeView::expandAll(const QModelIndex &idx)
|
||||
}
|
||||
}
|
||||
|
||||
void TreeView::expand(const QModelIndex &idx)
|
||||
void TreeView::expand(const QModelIndex &idx, bool singleOnly)
|
||||
{
|
||||
if (idx.isValid()) {
|
||||
setExpanded(idx, true);
|
||||
quint32 count=model()->rowCount(idx);
|
||||
for (quint32 i=0; i<count; ++i) {
|
||||
expand(idx.child(i, 0));
|
||||
if (!singleOnly) {
|
||||
quint32 count=model()->rowCount(idx);
|
||||
for (quint32 i=0; i<count; ++i) {
|
||||
expand(idx.child(i, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
QModelIndexList selectedIndexes() const { return selectedIndexes(true); }
|
||||
QModelIndexList selectedIndexes(bool sorted) const;
|
||||
void expandAll(const QModelIndex &idx=QModelIndex());
|
||||
virtual void expand(const QModelIndex &idx);
|
||||
virtual void expand(const QModelIndex &idx, bool singleOnly=false);
|
||||
virtual void setModel(QAbstractItemModel *m);
|
||||
bool checkBoxClicked(const QModelIndex &idx) const;
|
||||
void setUseSimpleDelegate();
|
||||
|
||||
Reference in New Issue
Block a user