X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fplaylistmodel.cpp;h=99083489b18356919e86058779abcb804ebb66b2;hb=de286bbf3fb8456ced35bf99730b98c59050f7c4;hp=c4a7d72b9fdfd096491c56de9ffa870fc4c8902e;hpb=297c5a7db3d7359f3a445758c4ac8a8b4887391e;p=minitube diff --git a/src/playlistmodel.cpp b/src/playlistmodel.cpp index c4a7d72..9908348 100644 --- a/src/playlistmodel.cpp +++ b/src/playlistmodel.cpp @@ -24,10 +24,12 @@ $END_LICENSE */ #include "video.h" #include "videomimedata.h" #include "videosource.h" + +#include "ivchannelsource.h" +#include "ivsearch.h" #include "ytsearch.h" namespace { -const int maxItems = 50; const QString recentKeywordsKey = "recentKeywords"; const QString recentChannelsKey = "recentChannels"; } // namespace @@ -186,27 +188,25 @@ void PlaylistModel::setVideoSource(VideoSource *videoSource) { }, Qt::UniqueConnection); + canSearchMore = true; searchMore(); } -void PlaylistModel::searchMore(int max) { - if (videoSource == nullptr || searching) return; +void PlaylistModel::searchMore() { + if (!canSearchMore || videoSource == nullptr || searching) return; searching = true; firstSearch = startIndex == 1; - this->max = max; + max = videoSource->maxResults(); + if (max == 0) max = 20; errorMessage.clear(); videoSource->loadVideos(max, startIndex); startIndex += max; } -void PlaylistModel::searchMore() { - searchMore(maxItems); -} - void PlaylistModel::searchNeeded() { const int desiredRowsAhead = 10; int remainingRows = videos.size() - m_activeRow; - if (remainingRows < desiredRowsAhead) searchMore(maxItems); + if (remainingRows < desiredRowsAhead) searchMore(); } void PlaylistModel::abortSearch() { @@ -229,7 +229,7 @@ void PlaylistModel::searchFinished(int total) { canSearchMore = videoSource->hasMoreVideos(); // update the message item - emit dataChanged(createIndex(maxItems, 0), createIndex(maxItems, columnCount() - 1)); + emit dataChanged(createIndex(videos.size(), 0), createIndex(videos.size(), columnCount() - 1)); if (firstSearch && !videos.isEmpty()) handleFirstVideo(videos.at(0)); } @@ -237,7 +237,7 @@ void PlaylistModel::searchFinished(int total) { void PlaylistModel::searchError(const QString &message) { errorMessage = message; // update the message item - emit dataChanged(createIndex(maxItems, 0), createIndex(maxItems, columnCount() - 1)); + emit dataChanged(createIndex(videos.size(), 0), createIndex(videos.size(), columnCount() - 1)); } void PlaylistModel::addVideos(const QVector