#include "videomimedata.h"
#include "videosource.h"
-#include "ivchannelsource.h"
-#include "ivsearch.h"
-#include "ytsearch.h"
+#include "searchvideosource.h"
namespace {
const QString recentKeywordsKey = "recentKeywords";
case Qt::TextAlignmentRole:
return QVariant(int(Qt::AlignHCenter | Qt::AlignVCenter));
case Qt::ForegroundRole:
- if (!errorMessage.isEmpty())
- return palette.color(QPalette::ToolTipText);
- else
- return palette.color(QPalette::Dark);
- case Qt::BackgroundColorRole:
+ return palette.color(QPalette::Dark);
+ case Qt::BackgroundRole:
if (!errorMessage.isEmpty())
return palette.color(QPalette::ToolTipBase);
else
}
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();
- }
+ 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://")) {
// 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();
}