10#include <QDomDocument>
73 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'exportnative'");
106 for (
int i = 0; i < actions.size() && !handled; i++)
108 const QString&
action = actions[i];
115 else if (
action ==
"DELETE")
145 QString tmpSize = QString(
"%1 Mb").arg(freeSpace);
190 (a->subtitle !=
"" ? a->subtitle +
"\n" :
"") + a->description);
199 ShowOkPopup(tr(
"You need to add at least one item to archive!"));
237 item->SetData(QVariant::fromValue(a));
255 query.
prepare(
"SELECT intid, type, title, subtitle, description, size, "
256 "startdate, starttime, filename, hascutlist "
257 "FROM archiveitems WHERE type = 'Recording' OR type = 'Video' "
258 "ORDER BY title, subtitle");
266 item->
id = query.
value(0).toInt();
267 item->type = query.
value(1).toString();
268 item->title = query.
value(2).toString();
269 item->subtitle = query.
value(3).toString();
270 item->description = query.
value(4).toString();
271 item->size = query.
value(5).toLongLong();
272 item->startDate = query.
value(6).toString();
273 item->startTime = query.
value(7).toString();
274 item->filename = query.
value(8).toString();
275 item->hasCutlist = (query.
value(9).toInt() > 0);
276 item->useCutlist =
false;
277 item->editedDetails =
false;
302 query.
prepare(
"DELETE FROM archiveitems;");
305 "deleting archiveitems", query);
308 query.
prepare(
"INSERT INTO archiveitems (type, title, subtitle, "
309 "description, startdate, starttime, size, filename, hascutlist, "
310 "duration, cutduration, videowidth, videoheight, filecodec,"
311 "videocodec, encoderprofile) "
312 "VALUES(:TYPE, :TITLE, :SUBTITLE, :DESCRIPTION, :STARTDATE, "
313 ":STARTTIME, :SIZE, :FILENAME, :HASCUTLIST, :DURATION, "
314 ":CUTDURATION, :VIDEOWIDTH, :VIDEOHEIGHT, :FILECODEC, "
315 ":VIDEOCODEC, :ENCODERPROFILE);");
320 query.
bindValue(
":SUBTITLE", a->subtitle);
321 query.
bindValue(
":DESCRIPTION", a->description);
322 query.
bindValue(
":STARTDATE", a->startDate);
323 query.
bindValue(
":STARTTIME", a->startTime);
325 query.
bindValue(
":FILENAME", a->filename);
326 query.
bindValue(
":HASCUTLIST", a->hasCutlist);
344 auto *menuPopup =
new MythDialogBox(tr(
"Menu"), popupStack,
"actionmenu");
346 if (menuPopup->Create())
349 menuPopup->SetReturnEvent(
this,
"action");
363 query.
prepare(
"DELETE FROM archiveitems WHERE filename = :FILENAME;");
364 query.
bindValue(
":FILENAME", curItem->filename);
373 QDomDocument doc(
"NATIVEARCHIVEJOB");
375 QDomElement root = doc.createElement(
"nativearchivejob");
376 doc.appendChild(root);
378 QDomElement job = doc.createElement(
"job");
379 root.appendChild(job);
381 QDomElement media = doc.createElement(
"media");
382 job.appendChild(media);
387 QDomElement
file = doc.createElement(
"file");
388 file.setAttribute(
"type", a->type.toLower() );
389 file.setAttribute(
"title", a->title);
390 file.setAttribute(
"filename", a->filename);
391 file.setAttribute(
"delete",
"0");
392 media.appendChild(
file);
396 QDomElement
options = doc.createElement(
"options");
407 if (!f.open(QIODevice::WriteOnly))
409 LOG(VB_GENERAL, LOG_ERR,
410 QString(
"ExportNative::createConfigFile: "
411 "Failed to open file for writing - %1") .arg(
filename));
416 t << doc.toString(4);
423 QString logDir = tempDir +
"logs";
424 QString configDir = tempDir +
"config";
432 QFile::remove(logDir +
"/mythburncancel.lck");
435 commandline =
"mytharchivehelper --logpath " + logDir +
" --nativearchive "
436 "--outfile " + configDir +
"/mydata.xml";
443 ShowOkPopup(tr(
"It was not possible to create the DVD. "
444 "An error occured when running the scripts") );
460 if (selector->Create())
473 query.
prepare(
"SELECT title FROM videometadata");
490 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)