#include "playlistmodel.h"
#include "mediaview.h"
+#include "playlistitemdelegate.h"
#include "searchparams.h"
#include "video.h"
#include "videomimedata.h"
#include "videosource.h"
-#include "ivchannelsource.h"
-#include "ivsearch.h"
-#include "ytsearch.h"
-
-#include "ytjschannelsource.h"
-#include "ytjssearch.h"
+#include "searchvideosource.h"
namespace {
const QString recentKeywordsKey = "recentKeywords";
videos.append(newVideos);
endInsertRows();
for (Video *video : newVideos) {
- connect(video, SIGNAL(gotThumbnail()), SLOT(updateVideoSender()), Qt::UniqueConnection);
- video->loadThumbnail();
+ connect(video, &Video::changed, this, [video, this] {
+ int row = rowForVideo(video);
+ emit dataChanged(createIndex(row, 0), createIndex(row, columnCount() - 1));
+ });
}
}
}
auto clazz = videoSource->metaObject()->className();
- if (clazz == QLatin1String("YTSearch") || clazz == QLatin1String("IVSearch") ||
- clazz == QLatin1String("IVChannelSource")) {
- static const int maxRecentElements = 10;
-
- SearchParams *searchParams;
- if (clazz == QLatin1String("YTSearch")) {
- auto search = qobject_cast<YTSearch *>(videoSource);
- searchParams = search->getSearchParams();
- } else if (clazz == QLatin1String("IVSearch")) {
- auto search = qobject_cast<IVSearch *>(videoSource);
- searchParams = search->getSearchParams();
- } else if (clazz == QLatin1String("IVChannelSource")) {
- auto search = qobject_cast<IVChannelSource *>(videoSource);
- searchParams = search->getSearchParams();
- } else if (clazz == QLatin1String("YTJSSearch")) {
- auto search = qobject_cast<YTJSSearch *>(videoSource);
- searchParams = search->getSearchParams();
- } else if (clazz == QLatin1String("YTJSChannelSource")) {
- auto search = qobject_cast<YTJSChannelSource *>(videoSource);
- searchParams = search->getSearchParams();
- }
+ if (clazz == QLatin1String("SearchVideoSource")) {
+ auto search = qobject_cast<SearchVideoSource *>(videoSource);
+ SearchParams *searchParams = search->getSearchParams();
// save keyword
+ static const int maxRecentElements = 10;
QString query = searchParams->keywords();
if (!query.isEmpty() && !searchParams->isTransient()) {
if (query.startsWith("http://")) {
}
}
-void PlaylistModel::updateVideoSender() {
- Video *video = static_cast<Video *>(sender());
- if (!video) {
- qDebug() << "Cannot get sender";
- return;
- }
- int row = rowForVideo(video);
- emit dataChanged(createIndex(row, 0), createIndex(row, columnCount() - 1));
-}
-
void PlaylistModel::emitDataChanged() {
QModelIndex index = createIndex(rowCount() - 1, 0);
emit dataChanged(index, index);
// and then add them again at the new position
beginInsertRows(QModelIndex(), beginRow, beginRow);
- videos.insert(beginRow, video);
+ if (beginRow >= videos.size()) {
+ videos.push_back(video);
+ } else {
+ videos.insert(beginRow, video);
+ }
endInsertRows();
}