Go to the documentation of this file.
44 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'searchview'");
53 QVariant::fromValue(0));
55 QVariant::fromValue(1));
57 QVariant::fromValue(2));
59 QVariant::fromValue(3));
61 QVariant::fromValue(4));
145 if (mdata && mdata->ID() == trackID)
148 mdata->
toMap(metadataMap);
161 if ((dce ==
nullptr) || (dce->GetResult() < 0))
164 QString resultid = dce->
GetId();
165 QString resulttext = dce->GetResultText();
166 if (resultid ==
"searchviewmenu")
168 if (resulttext == tr(
"Add To Playlist") || resulttext == tr(
"Remove From Playlist"))
180 else if (resulttext == tr(
"Play Now"))
192 else if (resulttext == tr(
"Prefer Play Now"))
196 else if (resulttext == tr(
"Prefer Add Tracks"))
200 else if (resulttext == tr(
"Search List..."))
219 for (
int i = 0; i < actions.size() && !handled; i++)
221 const QString&
action = actions[i];
245 else if (
action ==
"PLAY")
277 QString label = tr(
"Search Actions");
279 auto *
menu =
new MythMenu(label,
this,
"searchviewmenu");
288 menu->AddItem(tr(
"Remove From Playlist"));
293 menu->AddItem(tr(
"Play Now"));
294 menu->AddItem(tr(
"Add To Playlist"));
295 menu->AddItem(tr(
"Prefer Add To Playlist"));
299 menu->AddItem(tr(
"Add To Playlist"));
300 menu->AddItem(tr(
"Play Now"));
301 menu->AddItem(tr(
"Prefer Play Now"));
308 menu->AddItem(tr(
"Search List..."));
316 if (menuPopup->Create())
347 int field = item->
GetData().toInt();
352 if (searchStr.isEmpty())
354 sql =
"SELECT song_id "
365 sql =
"SELECT song_id "
367 "LEFT JOIN music_artists ON "
368 " music_songs.artist_id=music_artists.artist_id "
369 "WHERE music_artists.artist_name LIKE '%" + searchStr +
"%' ";
375 sql =
"SELECT song_id "
377 "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id "
378 "WHERE music_albums.album_name LIKE '%" + searchStr +
"%' ";
384 sql =
"SELECT song_id "
386 "WHERE music_songs.name LIKE '%" + searchStr +
"%' ";
392 sql =
"SELECT song_id "
394 "LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id "
395 "WHERE music_genres.genre LIKE '%" + searchStr +
"%' ";
407 sql =
"SELECT song_id "
409 "LEFT JOIN music_artists ON "
410 " music_songs.artist_id=music_artists.artist_id "
411 "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id "
412 "LEFT JOIN music_artists AS music_comp_artists ON "
413 " music_albums.artist_id=music_comp_artists.artist_id "
414 "LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id "
415 "WHERE music_songs.name LIKE '%" + searchStr +
"%' "
416 "OR music_artists.artist_name LIKE '%" + searchStr +
"%' "
417 "OR music_albums.album_name LIKE '%" + searchStr +
"%' "
418 "OR music_genres.genre LIKE '%" + searchStr +
"%' ";
433 int trackid = query.
value(0).toInt();
439 newitem->SetData(QVariant::fromValue(mdata));
441 mdata->
toMap(metadataMap);
442 newitem->SetTextFromMap(metadataMap);
445 newitem->DisplayState(
"on",
"selectedstate");
447 newitem->DisplayState(
"off",
"selectedstate");
486 if (artFile.isEmpty())
489 item->
SetImage(mdata->getAlbumArtFile());
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
bool isActive(void) const
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
QSqlQuery wrapper that fetches a DB connection from the connection pool.
static void editTrackInfo(MusicMetadata *mdata)
void fieldSelected(MythUIButtonListItem *item)
void criteriaChanged(void)
bool keyPressEvent(QKeyEvent *e) override
Key event handler.
void playlistItemClicked(MythUIButtonListItem *item)
MythMenu * createSubMenu(void)
static bool getPlayNow(void)
QVariant value(int i) const
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
static void showTrackInfo(MusicMetadata *mdata)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Screen in which all other widgets are contained and rendered.
static const Type kMetadataChangedEvent
QString GetText(void) const
Playlist * getCurrentPlaylist(void)
MythUIText * m_matchesText
static const Type kAllTracksRemovedEvent
MythUITextEdit * m_criteriaEdit
MythUIType * GetFocusWidget(void) const
QHash< QString, QString > InfoMap
bool TranslateKeyPress(const QString &Context, QKeyEvent *Event, QStringList &Actions, bool AllowJumps=true)
Get a list of actions for a keypress in the given context.
void removeTrack(MusicMetadata::IdType trackID)
bool SetFocusWidget(MythUIType *widget=nullptr)
MythUIButtonList * m_fieldList
Basic menu dialog, message and a list of options.
static MythThemedMenu * menu
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
static void DBError(const QString &where, const MSqlQuery &query)
void BuildFocusList(void)
SearchView(MythScreenStack *parent, MythScreenType *parentScreen)
void addTrack(MusicMetadata::IdType trackID, bool update_display)
Given a tracks ID, add that track to this playlist.
MythUIButtonList * m_currentPlaylist
static void trackClicked(MythUIButtonListItem *item)
bool Create(void) override
void ShowMenu(void) override
bool checkTrack(MusicMetadata::IdType trackID) const
MusicMetadata * getMetadata(int an_id)
static bool Assign(ContainerType *container, UIType *&item, const QString &name, bool *err=nullptr)
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
void searchButtonList(void)
void customEvent(QEvent *event) override
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
MythUIButtonList * m_tracksList
static void trackVisible(MythUIButtonListItem *item)
virtual void SetText(const QString &text)
static const Type kEventType
MythMainWindow * GetMythMainWindow(void)
static const Type kTrackRemovedEvent
MythScreenStack * GetStack(const QString &Stackname)
static const Type kTrackAddedEvent
static void setPlayNow(bool PlayNow)
whether we prefer Play Now over Add Tracks
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
void customEvent(QEvent *event) override
void updateTracksList(void)
void ShowMenu(void) override
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.