1#ifndef MYTHUIBUTTONLIST_H_
2#define MYTHUIBUTTONLIST_H_
35using muibCbFn = QString (*)(
const QString &name,
void *data);
53 QString image =
"",
bool checkable =
false,
54 CheckState state = CantCheck,
bool showArrow =
false,
55 int listPosition = -1);
57 QVariant data,
int listPosition = -1);
58 template <
typename SLOT>
60 const QString& text, SLOT slot,
int listPosition = -1)
62 template <
typename SLOT>
64 const QString& text, SLOT slot,
int listPosition = -1)
70 void SetText(
const QString &text,
const QString &name=
"",
71 const QString &state=
"");
72 void SetTextFromMap(
const InfoMap &infoMap,
const QString &state=
"");
73 void SetTextFromMap(
const QMap<QString, TextProperties> &stringMap);
74 void SetTextCb(
muibCbFn fn,
void *data);
75 QString GetText(
const QString &name=
"")
const;
78 bool FindText(
const QString &searchStr,
const QString &fieldList =
"**ALL**",
79 bool startsWith =
false)
const;
81 void SetFontState(
const QString &state,
const QString &name=
"");
86 void SetImage(
MythImage *image,
const QString &name=
"");
93 MythImage *GetImage(
const QString &name=
"");
108 void SetImage(
const QString &
filename,
const QString &name=
"",
109 bool force_reload =
false);
110 void SetImageFromMap(
const InfoMap &imageMap);
111 void SetImageCb(
muibCbFn fn,
void *data);
112 QString GetImageFilename(
const QString &name=
"")
const;
114 void SetProgress1(
int start,
int total,
int used);
115 void SetProgress2(
int start,
int total,
int used);
117 void DisplayState(
const QString &state,
const QString &name);
118 void SetStatesFromMap(
const InfoMap &stateMap);
119 void SetStateCb(
muibCbFn fn,
void *data);
120 QString
GetState(
const QString &name);
125 bool checkable()
const;
126 void setCheckable(
bool flag);
128 bool isEnabled()
const;
129 void setEnabled(
bool flag);
131 CheckState state()
const;
132 void setChecked(CheckState state);
134 void setDrawArrow(
bool flag);
136 void SetData(QVariant data);
139 bool MoveUpDown(
bool flag);
146 void DoButtonArrow(
MythUIImage *buttonarrow)
const;
153 static void DoButtonLookupState(
MythUIStateType *statetype,
const QString& name);
161 bool m_checkable {
false};
164 bool m_showArrow {
false};
165 bool m_isVisible {
false};
166 bool m_enabled {
true};
167 bool m_debugme {
false};
197 QString shadow =
"");
199 QRect area,
bool showArrow =
true,
200 bool showScrollBar =
false);
203 bool keyPressEvent(QKeyEvent *event)
override;
205 void customEvent(QEvent *event)
override;
209 MoveMid, MoveByAmount };
211 { LayoutVertical, LayoutHorizontal, LayoutGrid };
214 void SetDrawFromBottom(
bool draw);
217 void Reset()
override;
220 virtual void SetValue(
int value) { MoveToNamedPosition(QString::number(value)); }
221 virtual void SetValue(
const QString &value) { MoveToNamedPosition(value); }
222 void SetValueByData(
const QVariant& data);
223 virtual int GetIntValue()
const;
224 virtual QString GetValue()
const;
225 QVariant GetDataValue()
const;
229 void SetItemCurrent(
int current,
int topPos = -1);
236 uint ItemWidth(
void);
237 uint ItemHeight(
void);
247 int GetCount()
const;
248 int GetVisibleCount();
249 bool IsEmpty()
const;
251 virtual bool MoveDown(MovementUnit unit = MoveItem,
uint amount = 0);
252 virtual bool MoveUp(MovementUnit unit = MoveItem,
uint amount = 0);
253 bool MoveToNamedPosition(
const QString &position_name);
257 bool IsShadowing(
void) {
return m_shadowListName == GetFocusedName(); }
258 void SetLCDTitles(
const QString &title,
const QString &columnList =
"");
259 void updateLCD(
void);
262 void ShowSearchDialog(
void);
263 bool Find(
const QString &searchStr,
bool startsWith =
false);
267 void LoadInBackground(
int start = 0,
int pageSize = 20);
273 void ToggleEnabled();
287 { WrapCaptive = -1, WrapNone = 0, WrapSelect = 1,
288 WrapItems = 2, WrapFlowing = 3 };
291 int alphaMod, QRect clipRect)
override;
297 int minButtonWidth(
const MythRect & area);
298 int minButtonHeight(
const MythRect & area);
301 MythUIGroup *PrepareButton(
int buttonIdx,
int itemIdx,
302 int & selectedIdx,
int & button_shift);
303 bool DistributeRow(
int & first_button,
int & last_button,
304 int & first_item,
int & last_item,
305 int & selected_column,
int & skip_cols,
306 bool grow_left,
bool grow_right,
307 int ** col_widths,
int & row_height,
308 int total_height,
int split_height,
309 int & col_cnt,
bool & wrapped);
310 bool DistributeCols(
int & first_button,
int & last_button,
311 int & first_item,
int & last_item,
312 int & selected_column,
int & selected_row,
313 int & skip_cols,
int ** col_widths,
314 QList<int> & row_heights,
315 int & top_height,
int & bottom_height,
317 bool DistributeButtons(
void);
318 void CalculateButtonPositions(
void);
319 void CalculateArrowStates(
void);
320 void SetScrollBarPosition(
void);
323 void SetActive(
bool active);
328 bool DoFind(
bool doMove,
bool searchForward);
330 void FindEnabledUp(MovementUnit unit);
331 void FindEnabledDown(MovementUnit unit);
334 virtual void CalculateVisibleItems(
void);
335 virtual QPoint GetButtonPosition(
int column,
int row)
const;
337 void SetButtonArea(
const MythRect &rect);
338 bool ParseElement(
const QString &
filename, QDomElement &element,
339 bool showWarnings)
override;
342 void Finalize(
void)
override;
344 void SanitizePosition(
void);
352 int m_defaultAlignment {Qt::AlignLeft | Qt::AlignTop};
353 std::optional<int> m_shadowAlignment {std::nullopt};
357 QString m_searchFields {
"**ALL**"};
359 bool m_searchStartsWith {
false};
362 int m_itemHeight {0};
363 int m_itemHorizSpacing {0};
364 int m_itemVertSpacing {0};
365 int m_itemsVisible {0};
366 int m_maxVisible {0};
369 int m_leftColumns {0};
370 int m_rightColumns {0};
372 int m_bottomRows {0};
376 bool m_active {
false};
377 bool m_showArrow {
true};
378 bool m_showScrollBar {
true};
390 bool m_initialized {
false};
391 bool m_needsUpdate {
false};
392 bool m_clearing {
false};
394 int m_selPosition {0};
395 int m_topPosition {0};
397 bool m_keepSelAtBottom {
false};
400 int m_nextItemLoaded {0};
402 bool m_defaultDrawFromBottom {
false};
403 std::optional<bool> m_shadowDrawFromBottom {std::nullopt};
419 m_parentList(parentList), m_searchText(
std::move(searchText)) {}
422 bool Create(
void)
override;
423 bool keyPressEvent(QKeyEvent *event)
override;
426 void searchChanged(
void);
427 void prevClicked(
void);
428 void nextClicked(
void);
431 bool m_startsWith {
false};
A custom event that represents a mouse gesture.
int DecrRef(void) override
Decrements reference count and deletes on 0.
Wrapper around QPoint allowing us to handle percentage and other relative values for positioning in m...
Wrapper around QRect allowing us to handle percentage and other relative values for areas in mythui.
Screen in which all other widgets are contained and rendered.
Create a group of widgets.
Image widget, displays a single image or multiple images in sequence.
This widget is used for grouping other widgets for display when a particular named state is called.
A text entry and edit widget.
All purpose text widget, displays a text string.
The base class on which all widgets and screens are based.
Q_DECLARE_METATYPE(std::chrono::seconds)
QHash< QString, QString > InfoMap
void(QObject::*)(void) const MythUICallbackMFc
void(QObject::*)(void) MythUICallbackMF
QDateTime current(bool stripped)
Returns current Date and Time in UTC.