10#include <QDomDocument>
75 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'exportnative'");
108 for (
int i = 0; i < actions.size() && !handled; i++)
110 const QString&
action = actions[i];
117 else if (
action ==
"DELETE")
147 QString tmpSize = QString(
"%1 Mb").arg(freeSpace);
192 (a->subtitle !=
"" ? a->subtitle +
"\n" :
"") + a->description);
201 ShowOkPopup(tr(
"You need to add at least one item to archive!"));
239 item->SetData(QVariant::fromValue(a));
257 query.
prepare(
"SELECT intid, type, title, subtitle, description, size, "
258 "startdate, starttime, filename, hascutlist "
259 "FROM archiveitems WHERE type = 'Recording' OR type = 'Video' "
260 "ORDER BY title, subtitle");
268 item->
id = query.
value(0).toInt();
269 item->type = query.
value(1).toString();
270 item->title = query.
value(2).toString();
271 item->subtitle = query.
value(3).toString();
272 item->description = query.
value(4).toString();
273 item->size = query.
value(5).toLongLong();
274 item->startDate = query.
value(6).toString();
275 item->startTime = query.
value(7).toString();
276 item->filename = query.
value(8).toString();
277 item->hasCutlist = (query.
value(9).toInt() > 0);
278 item->useCutlist =
false;
279 item->editedDetails =
false;
304 query.
prepare(
"DELETE FROM archiveitems;");
307 "deleting archiveitems", query);
310 query.
prepare(
"INSERT INTO archiveitems (type, title, subtitle, "
311 "description, startdate, starttime, size, filename, hascutlist, "
312 "duration, cutduration, videowidth, videoheight, filecodec,"
313 "videocodec, encoderprofile) "
314 "VALUES(:TYPE, :TITLE, :SUBTITLE, :DESCRIPTION, :STARTDATE, "
315 ":STARTTIME, :SIZE, :FILENAME, :HASCUTLIST, :DURATION, "
316 ":CUTDURATION, :VIDEOWIDTH, :VIDEOHEIGHT, :FILECODEC, "
317 ":VIDEOCODEC, :ENCODERPROFILE);");
322 query.
bindValue(
":SUBTITLE", a->subtitle);
323 query.
bindValue(
":DESCRIPTION", a->description);
324 query.
bindValue(
":STARTDATE", a->startDate);
325 query.
bindValue(
":STARTTIME", a->startTime);
327 query.
bindValue(
":FILENAME", a->filename);
328 query.
bindValue(
":HASCUTLIST", a->hasCutlist);
346 auto *menuPopup =
new MythDialogBox(tr(
"Menu"), popupStack,
"actionmenu");
348 if (menuPopup->Create())
351 menuPopup->SetReturnEvent(
this,
"action");
365 query.
prepare(
"DELETE FROM archiveitems WHERE filename = :FILENAME;");
366 query.
bindValue(
":FILENAME", curItem->filename);
375 QDomDocument doc(
"NATIVEARCHIVEJOB");
377 QDomElement root = doc.createElement(
"nativearchivejob");
378 doc.appendChild(root);
380 QDomElement job = doc.createElement(
"job");
381 root.appendChild(job);
383 QDomElement media = doc.createElement(
"media");
384 job.appendChild(media);
389 QDomElement
file = doc.createElement(
"file");
390 file.setAttribute(
"type", a->type.toLower() );
391 file.setAttribute(
"title", a->title);
392 file.setAttribute(
"filename", a->filename);
393 file.setAttribute(
"delete",
"0");
394 media.appendChild(
file);
398 QDomElement
options = doc.createElement(
"options");
409 if (!f.open(QIODevice::WriteOnly))
411 LOG(VB_GENERAL, LOG_ERR,
412 QString(
"ExportNative::createConfigFile: "
413 "Failed to open file for writing - %1") .arg(
filename));
418 t << doc.toString(4);
425 QString logDir = tempDir +
"logs";
426 QString configDir = tempDir +
"config";
434 QFile::remove(logDir +
"/mythburncancel.lck");
437 commandline =
"mytharchivehelper --logpath " + logDir +
" --nativearchive "
438 "--outfile " + configDir +
"/mydata.xml";
445 ShowOkPopup(tr(
"It was not possible to create the DVD. "
446 "An error occured when running the scripts") );
462 if (selector->Create())
475 query.
prepare(
"SELECT title FROM videometadata");
492 if (selector->Create())
QString getTempDirectory(bool showError)
void handleNextPage(void)
void loadConfiguration(void)
MythUIText * m_descriptionText
MythScreenType * m_previousScreen
~ExportNative(void) override
void getArchiveList(void)
bool Create(void) override
void handlePrevPage(void)
MythUIButtonList * m_archiveButtonList
void createConfigFile(const QString &filename)
void titleChanged(MythUIButtonListItem *item)
void handleAddRecording(void)
void ShowMenu(void) override
MythUIButton * m_nextButton
MythUIText * m_currsizeText
void updateArchiveList(void)
MythUIText * m_currsizeErrText
QList< ArchiveItem * > m_archiveList
MythUIButton * m_cancelButton
MythUIButton * m_addrecordingButton
MythUIText * m_datetimeText
MythUIText * m_filesizeText
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
MythUIButton * m_prevButton
void selectorClosed(bool ok)
void getArchiveListFromDB(void)
ArchiveDestination m_archiveDestination
void saveConfiguration(void)
void handleAddVideo(void)
MythUIButton * m_addvideoButton
MythUIProgressBar * m_sizeBar
MythUIText * m_nofilesText
MythUIText * m_maxsizeText
MythUIText * m_minsizeText
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
int numRowsAffected() const
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
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 GetSetting(const QString &key, const QString &defaultval="")
static void DBError(const QString &where, const MSqlQuery &query)
Basic menu dialog, message and a list of options.
MythScreenStack * GetMainStack()
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)
void BuildFocusList(void)
MythUIType * GetFocusWidget(void) const
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
bool SetFocusWidget(MythUIType *widget=nullptr)
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)
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
@ GENERIC_EXIT_OK
Exited with no error.
@ GENERIC_EXIT_RUNNING
Process is running.
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)
@ kMSDontBlockInputDevs
avoid blocking LIRC & Joystick Menu
@ kMSRunBackground
run child in the background
@ kMSDontDisableDrawing
avoid disabling UI drawing
uint myth_system(const QString &command, uint flags, std::chrono::seconds timeout)
MBASE_PUBLIC QString formatKBytes(int64_t sizeKB, int prec=1)
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)