31 m_archiveList(archiveList)
49 bool foundtheme =
LoadWindowFromXML(
"mytharchive-ui.xml",
"video_selector",
this);
67 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'video_selector'");
103 for (
int i = 0; i < actions.size() && !handled; i++)
105 const QString&
action = actions[i];
144 auto *menuPopup =
new MythDialogBox(tr(
"Menu"), popupStack,
"actionmenu");
146 if (menuPopup->Create())
149 menuPopup->SetReturnEvent(
this,
"action");
210 if (v->coverfile !=
"" && v->coverfile !=
"No Cover")
226 struct stat fileinfo {};
230 v->size = (uint64_t)fileinfo.st_size;
234 LOG(VB_GENERAL, LOG_ERR,
235 QString(
"VideoSelector: Cannot find file: %1")
248 QList<ArchiveItem *> tempAList;
255 if (a->type !=
"Video" || a->filename == v->filename)
266 for (
auto *x : std::as_const(tempAList))
270 QList<VideoInfo *> tempSList;
275 if (a->filename == v->filename)
283 for (
auto *x : std::as_const(tempSList))
293 a->description = v->plot;
297 a->newsize = v->size;
298 a->filename = v->filename;
299 a->hasCutlist =
false;
300 a->useCutlist =
false;
307 a->encoderProfile =
nullptr;
308 a->editedDetails =
false;
340 item->setCheckable(
true);
350 item->SetData(QVariant::fromValue(v));
376 using CategoryMap = QMap<int, QString>;
377 CategoryMap categoryMap;
379 query.
prepare(
"SELECT intid, category FROM videocategory");
385 int id = query.
value(0).toInt();
386 QString category = query.
value(1).toString();
387 categoryMap.insert(
id, category);
391 query.
prepare(
"SELECT intid, title, plot, length, filename, coverfile, "
392 "category, showlevel, subtitle, season, episode, host "
393 "FROM videometadata ORDER BY title,season,episode");
397 auto *videoList =
new std::vector<VideoInfo*>;
409 if (query.
value(9).toInt() > 0)
411 episode = query.
value(10).toString();
412 if (episode.size() < 2)
413 episode.prepend(
"0");
414 info->title = QString(
"%1 %2x%3 - %4")
415 .arg(query.
value(1).toString(),
416 query.
value(9).toString(),
418 query.
value(8).toString());
427 QString host = query.
value(11).toString();
446 LOG(VB_GENERAL, LOG_ERR,
447 QString(
"VideoSelector: Failed to find local file '%1'").arg(
info->filename));
448 info->filename.clear();
452 if (
info->filename.isEmpty())
459 LOG(VB_FILE, LOG_INFO,
460 QString(
"VideoSelector: found file '%1'").arg(
info->filename));
462 info->coverfile = query.
value(5).toString();
463 info->category = categoryMap[query.
value(6).toInt()];
464 info->parentalLevel = query.
value(7).toInt();
465 if (
info->category.isEmpty())
466 info->category =
"(None)";
467 videoList->push_back(
info);
473 LOG(VB_GENERAL, LOG_ERR,
"VideoSelector: Failed to get any videos");
481 QStringList categories;
487 if (categories.indexOf(v->category) == -1)
488 categories.append(v->category);
505 for (
int x = 0; x < categories.count(); x++)
530 if (v->filename == a->filename)
555 ShowOkPopup(tr(
"You need to enter a valid password for this parental level"));
QSqlQuery wrapper that fetches a DB connection from the connection pool.
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
QVariant value(int i) const
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
QString GetHostName(void)
Basic menu dialog, message and a list of options.
bool TranslateKeyPress(const QString &Context, QKeyEvent *Event, QStringList &Actions, bool AllowJumps=true)
Get a list of actions for a keypress in the given context.
MythScreenStack * GetStack(const QString &Stackname)
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
Screen in which all other widgets are contained and rendered.
void BuildFocusList(void)
MythUIType * GetFocusWidget(void) const
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
bool SetFocusWidget(MythUIType *widget=nullptr)
bool Load(bool allowLoadInBackground=true, bool forceStat=false)
Load the image(s), wraps ImageLoader::LoadImage()
void SetFilename(const QString &filename)
Must be followed by a call to Load() to load the image.
void Reset(void) override
Reset the widget to it's original state, should not reset changes made by the theme.
virtual void SetText(const QString &text)
void SigResultReady(bool passwordValid, ParentalLevel::Level newLevel)
void Check(ParentalLevel::Level fromLevel, ParentalLevel::Level toLevel)
static bool Exists(const QString &url, struct stat *fileinfo)
QString FindFile(const QString &filename)
static QString generate_file_url(const QString &storage_group, const QString &host, const QString &path)
void ShowMenu(void) override
void setParentalLevel(ParentalLevel::Level level)
MythUIButtonList * m_categorySelector
MythUIButtonList * m_videoButtonList
MythUIButton * m_cancelButton
VideoSelector(MythScreenStack *parent, QList< ArchiveItem * > *archiveList)
~VideoSelector(void) override
QList< VideoInfo * > m_selectedList
MythUIButton * m_okButton
void parentalLevelChanged(bool passwordValid, ParentalLevel::Level newLevel)
void titleChanged(MythUIButtonListItem *item)
void toggleSelected(MythUIButtonListItem *item)
ParentalLevel::Level m_currentParentalLevel
QList< ArchiveItem * > * m_archiveList
bool keyPressEvent(QKeyEvent *e) override
Key event handler.
std::vector< VideoInfo * > * m_videoList
void updateVideoList(void)
MythUIText * m_warningText
void setCategory(MythUIButtonListItem *item)
static std::vector< VideoInfo * > * getVideoListFromDB(void)
MythUIText * m_filesizeText
void updateSelectedList(void)
MythUIImage * m_coverImage
ParentalLevelChangeChecker * m_parentalLevelChecker
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
MythConfirmationDialog * ShowOkPopup(const QString &message, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
MythMainWindow * GetMythMainWindow(void)
MBASE_PUBLIC QString formatKBytes(int64_t sizeKB, int prec=1)
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)