33 LOG(VB_GENERAL, LOG_ERR,
"Theme is missing required elements.");
76 m_createdSrcMan(srcman == nullptr)
121 activeheader->
SetText(tr(
"Active Screens"));
125 inactiveheader->
SetText(tr(
"Inactive Screens"));
129 LOG(VB_GENERAL, LOG_ERR,
"Theme is missing required elements.");
162 for (
int i = 0; i < actions.size() && !handled; i++)
164 const QString&
action = actions[i];
204 text = tr(
"Add desired screen to the Active Screens list "
205 "by pressing SELECT.") +
"\n";
206 text += si->m_title +
"\n";
207 text += QString(
"%1: %2").arg(tr(
"Sources"), sources.join(
", "));
222 text += tr(
"Units: ");
224 tr(
"English Units") : tr(
"SI Units");
227 if (!si->m_multiLoc && !si->m_types.empty())
230 text += tr(
"Location: ");
233 text += tr(
"Source: " );
237 text +=
"\n" + tr(
"Press SELECT to ");
239 text += tr(
"change location; ");
241 text += tr(
"change units; ");
242 text += tr(
"move screen up or down; or remove screen.");
255 ScreenListMap::const_iterator i = screenListMap.constBegin();
256 while (i != screenListMap.constEnd())
262 QStringList type_strs;
263 for (
const QString&
type : std::as_const(
types))
270 QList<ScriptInfo *> scriptList;
275 for (
const auto *script : std::as_const(scriptList))
284 QMap<long, ScreenListInfo*> active_screens;
287 QString query =
"SELECT weatherscreens.container, weatherscreens.units, "
288 "weatherdatalayout.dataitem, weatherdatalayout.location, "
289 "weathersourcesettings.source_name, weatherscreens.draworder "
290 "FROM weatherscreens, weatherdatalayout, weathersourcesettings "
291 "WHERE weatherscreens.hostname = :HOST "
292 "AND weatherscreens.screen_id = weatherdatalayout.weatherscreens_screen_id "
293 "AND weathersourcesettings.sourceid = weatherdatalayout.weathersourcesettings_sourceid "
294 "ORDER BY weatherscreens.draworder;";
306 QString name = db.
value(0).toString();
308 QString dataitem = db.
value(2).toString();
309 QString location = db.
value(3).toString();
310 QString src = db.
value(4).toString();
313 types = screenListMap[name].m_dataTypes;
318 if (!active_screens.contains(draworder))
328 for (
const auto &
type : std::as_const(
types))
330 if (
type == dataitem)
331 si->m_types.insert(dataitem, ti);
334 item->SetData(QVariant::fromValue(si));
335 active_screens.insert(draworder, si);
340 for (
const auto &
type : std::as_const(
types))
342 if (
type == dataitem)
344 si->
m_types.insert(dataitem, ti);
354 QStringList notDefined;
360 for (
const auto &
type : std::as_const(si->m_types))
365 notDefined <<
type.m_name;
366 LOG(VB_GENERAL, LOG_ERR, QString(
"Not defined %1").arg(
type.m_name));
370 if (!notDefined.empty())
372 LOG(VB_GENERAL, LOG_ERR,
"A Selected screen has data items with no "
379 QString query =
"DELETE FROM weatherscreens WHERE hostname=:HOST";
385 query =
"INSERT into weatherscreens (draworder, container, units, hostname) "
386 "VALUES (:DRAW, :CONT, :UNITS, :HOST);";
401 QString query2 =
"SELECT screen_id FROM weatherscreens "
402 "WHERE draworder = :DRAW AND hostname = :HOST;";
413 int screen_id = db2.
value(0).toInt();
415 query2 =
"INSERT INTO weatherdatalayout (location, dataitem, "
416 "weatherscreens_screen_id, weathersourcesettings_sourceid) "
417 "VALUES (:LOC, :ITEM, :SCREENID, :SRCID);";
419 for (
const auto &
type : std::as_const(si->m_types))
455 QString label = tr(
"Manipulate Screen");
461 "screensetupmenupopup");
463 if (menuPopup->Create())
467 menuPopup->SetReturnEvent(
this,
"options");
469 menuPopup->AddButtonV(tr(
"Move Up"), QVariant::fromValue(selected));
470 menuPopup->AddButtonV(tr(
"Move Down"), QVariant::fromValue(selected));
471 menuPopup->AddButtonV(tr(
"Remove"), QVariant::fromValue(selected));
472 menuPopup->AddButtonV(tr(
"Change Location"), QVariant::fromValue(selected));
474 menuPopup->AddButtonV(tr(
"Change Units"), QVariant::fromValue(selected));
475 menuPopup->AddButtonV(tr(
"Cancel"), QVariant::fromValue(selected));
486 QStringList type_strs;
490 for (
auto it = si->m_types.begin(); it != si->m_types.end(); ++it)
492 types.insert(it.key(), *it);
493 type_strs << it.key();
495 bool hasUnits = si->m_hasUnits;
497 QList<ScriptInfo *> tmp;
512 LOG(VB_GENERAL, LOG_ERR,
"Screen cannot be used, not all required "
513 "data is supplied by existing sources");
526 if (locdialog->Create())
537 QString label = QString(
"%1 %2").arg(name, tr(
"Change Units"));
541 auto *menuPopup =
new MythDialogBox(label, popupStack,
"weatherunitspopup");
543 if (menuPopup->Create())
547 menuPopup->SetReturnEvent(
this,
"units");
549 menuPopup->AddButtonV(tr(
"English Units"), QVariant::fromValue(si));
550 menuPopup->AddButtonV(tr(
"SI Units"), QVariant::fromValue(si));
584 QString resultid = dce->
GetId();
585 int buttonnum = dce->GetResult();
587 if (resultid ==
"options")
598 else if (buttonnum == 1)
602 else if (buttonnum == 2)
606 else if (buttonnum == 3)
608 si->m_updating =
true;
611 else if (si->m_hasUnits && buttonnum == 4)
613 si->m_updating =
true;
619 else if (resultid ==
"units")
629 else if (buttonnum == 1)
637 si->m_updating =
false;
642 else if (resultid ==
"location")
646 auto emptyloc = [](
const auto &
type)
647 {
return type.m_location.isEmpty(); };
648 if (std::ranges::any_of(std::as_const(si->m_types), emptyloc))
653 si->m_updating =
false;
656 item->
SetData(QVariant::fromValue(si));
661 item->SetData(QVariant::fromValue(si));
698 LOG(VB_GENERAL, LOG_ERR,
"Theme is missing required elements.");
734 "SELECT DISTINCT sourceid, source_name, update_timeout, retrieve_timeout, "
735 "author, email, version FROM weathersourcesettings, weatherdatalayout "
736 "WHERE weathersourcesettings.sourceid = weatherdatalayout.weathersourcesettings_sourceid "
737 "AND hostname=:HOST;";
755 si->name = db.
value(1).toString();
756 si->update_timeout = std::chrono::minutes(db.
value(2).toUInt() / 60);
757 si->retrieve_timeout = std::chrono::seconds(db.
value(3).toUInt());
758 si->author = db.
value(4).toString();
759 si->email = db.
value(5).toString();
760 si->version = db.
value(6).toString();
780 QString query =
"UPDATE weathersourcesettings "
781 "SET update_timeout = :UPDATE, retrieve_timeout = :RETRIEVE "
782 "WHERE sourceid = :ID;";
790 db.
bindValue(
":UPDATE", (
int)duration_cast<std::chrono::seconds>(si->update_timeout).count());
791 db.
bindValue(
":RETRIEVE", (
int)si->retrieve_timeout.count());
834 QString txt = tr(
"Author: ");
836 txt +=
"\n" + tr(
"Email: ") + si->email;
837 txt +=
"\n" + tr(
"Version: ") + si->version;
847 m_screenListInfo(new
ScreenListInfo(*si)), m_sourceManager(srcman),
848 m_retScreen(retScreen)
850 for (
const auto &
type : std::as_const(si->
m_types))
879 LOG(VB_GENERAL, LOG_ERR,
"Theme is missing required elements.");
898 QString busymessage = tr(
"Searching...");
903 "mythweatherbusydialog");
905 if (busyPopup->Create())
916 QHash<ScriptInfo *, QStringList> result_cache;
920 QString searchingresults = tr(
"Searching... Results: %1");
923 QCoreApplication::processEvents();
925 QList<ScriptInfo *> sources;
929 for (
auto *si : std::as_const(sources))
931 if (!result_cache.contains(si))
937 QCoreApplication::processEvents();
941 for (
auto it = result_cache.begin(); it != result_cache.end(); ++it)
944 QStringList
results = it.value();
945 QString name = si->
name;
946 QStringList::iterator rit;
949 QStringList tmp = (*rit).split(
"::");
952 LOG(VB_GENERAL, LOG_WARNING,
953 QString(
"Invalid line in Location Search reponse "
954 "from %1: %2").arg(name, *rit));
957 QString resultstring = QString(
"%1 (%2)").arg(tmp[1], name);
962 item->SetData(QVariant::fromValue(ri));
963 QCoreApplication::processEvents();
1006 (*it).m_location = ri->
idstr;
1007 (*it).m_src = ri->src;
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
static const Type kEventType
bool Create(void) override
MythUICheckBox * m_backgroundCheckbox
MythUISpinBox * m_timeoutSpinbox
MythUIButton * m_finishButton
ScreenListInfo * m_screenListInfo
SourceManager * m_sourceManager
MythUIText * m_sourceText
LocationDialog(MythScreenStack *parent, const QString &name, MythScreenType *retScreen, ScreenListInfo *si, SourceManager *srcman)
MythUITextEdit * m_locationEdit
MythUIButtonList * m_locationList
bool Create(void) override
~LocationDialog() override
void itemClicked(MythUIButtonListItem *item)
MythUIButton * m_searchButton
MythScreenType * m_retScreen
void itemSelected(MythUIButtonListItem *item)
MythUIText * m_resultsText
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.
QString executedQuery(void) const
QSqlError lastError(void) const
QVariant value(int i) 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 GetHostName(void)
void SaveSetting(const QString &key, int newValue)
int GetNumSetting(const QString &key, int defaultval=0)
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)
Screen in which all other widgets are contained and rendered.
virtual bool NextPrevWidgetFocus(bool up_or_down)
void BuildFocusList(void)
MythUIType * GetFocusWidget(void) const
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
bool SetFocusWidget(MythUIType *widget=nullptr)
A checkbox widget supporting three check states - on,off,half and two conditions - selected and unsel...
void SetCheckState(MythUIStateType::StateType state)
MythUIStateType::StateType GetCheckState() const
A widget for offering a range of numerical values where only the the bounding values and interval are...
void SetRange(int low, int high, int step, uint pageMultiple=5)
Set the lower and upper bounds of the spinbox, the interval and page amount.
void SetValue(int val) override
int GetIntValue(void) const override
A text entry and edit widget.
QString GetText(void) const
All purpose text widget, displays a text string.
virtual void SetText(const QString &text)
The base class on which all widgets and screens are based.
void SetEnabled(bool enable)
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
MythUIButtonList * m_activeList
void customEvent(QEvent *event) override
MythUIButtonList * m_inactiveList
bool Create(void) override
SourceManager * m_sourceManager
MythUIButton * m_finishButton
void doLocationDialog(ScreenListInfo *si)
void updateHelpText(void)
void doListSelect(MythUIButtonListItem *selected)
ScreenSetup(MythScreenStack *parent, const QString &name, SourceManager *srcman)
void showUnitsPopup(const QString &name, ScreenListInfo *si)
bool findPossibleSources(QStringList types, QList< ScriptInfo * > &sources)
QStringList getLocationList(ScriptInfo *si, const QString &str)
ScriptInfo * getSourceByName(const QString &name)
void updateSpinboxUpdate(void)
MythUISpinBox * m_retrieveSpinbox
MythUIText * m_sourceText
void retrieveSpinboxUpdate(void)
MythUISpinBox * m_updateSpinbox
void sourceListItemSelected(MythUIButtonListItem *item)
bool Create(void) override
MythUIButtonList * m_sourceList
MythUIButton * m_finishButton
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
static const struct wl_interface * types[]
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
MythMainWindow * GetMythMainWindow(void)
std::chrono::seconds retrieve_timeout
std::chrono::minutes update_timeout
ScreenListMap loadScreens()
static constexpr uint8_t ENG_UNITS
static constexpr uint8_t SI_UNITS
QMap< QString, ScreenListInfo > ScreenListMap
QMultiHash< QString, TypeListInfo > TypeListMap