moviebrowser: allow to delete all marked movies

Origin commit data
------------------
Branch: ni/coolstream
Commit: 644e3efee3
Author: vanhofen <vanhofen@gmx.de>
Date: 2015-09-29 (Tue, 29 Sep 2015)

Origin message was:
------------------
- moviebrowser: allow to delete all marked movies

------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
vanhofen
2015-09-29 08:00:00 +02:00
parent 1fa1b4bf9b
commit a483b5e187
2 changed files with 57 additions and 32 deletions

View File

@@ -496,6 +496,10 @@ void CMovieBrowser::init(void)
g_PicViewer->getSupportedImageFormats(PicExts); g_PicViewer->getSupportedImageFormats(PicExts);
show_mode = MB_SHOW_RECORDS; //FIXME show_mode = MB_SHOW_RECORDS; //FIXME
filelist.clear();
filelist_it = filelist.end();
movielist.clear();
CChannelLogo = NULL; CChannelLogo = NULL;
m_doRefresh = false; m_doRefresh = false;
@@ -1815,30 +1819,47 @@ bool CMovieBrowser::onButtonPressMainFrame(neutrino_msg_t msg)
} }
else if (msg == CRCInput::RC_spkr) else if (msg == CRCInput::RC_spkr)
{ {
if ((!m_vMovieInfo.empty()) && (m_movieSelectionHandler != NULL)) { MI_MOVIE_INFO *movieinfo;
bool onDelete = true; movieinfo = NULL;
bool skipAsk = false; filelist_it = filelist.end();
CRecordInstance* inst = CRecordManager::getInstance()->getRecordInstance(m_movieSelectionHandler->file.Name); if (getSelectedFiles(filelist, movielist))
if (inst != NULL) { filelist_it = filelist.begin();
std::string delName = m_movieSelectionHandler->epgTitle; if (filelist.empty()) { //just add the m_movieSelectionHandler
if (delName.empty()) filelist.push_back(m_movieSelectionHandler->file);
delName = m_movieSelectionHandler->file.getFileName(); movielist.push_back(m_movieSelectionHandler);
char buf1[1024]; }
snprintf(buf1, sizeof(buf1), g_Locale->getText(LOCALE_MOVIEBROWSER_ASK_REC_TO_DELETE), delName.c_str());
if (ShowMsg(LOCALE_RECORDINGMENU_RECORD_IS_RUNNING, buf1, for (filelist_it = filelist.begin(); filelist_it != filelist.end(); ++filelist_it)
CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, false) == CMessageBox::mbrNo) {
onDelete = false; unsigned int idx = filelist_it - filelist.begin();
else { movieinfo = movielist[idx];
CTimerd::RecordingStopInfo recinfo; TRACE("[mb]-> try to delete %d:%s\n", idx, movieinfo->file.Name.c_str());
recinfo.channel_id = inst->GetChannelId();
recinfo.eventID = inst->GetRecordingId(); if ((!m_vMovieInfo.empty()) && (movieinfo != NULL)) {
CRecordManager::getInstance()->Stop(&recinfo); bool onDelete = true;
g_Timerd->removeTimerEvent(recinfo.eventID); bool skipAsk = false;
skipAsk = true; CRecordInstance* inst = CRecordManager::getInstance()->getRecordInstance(movieinfo->file.Name);
if (inst != NULL) {
std::string delName = movieinfo->epgTitle;
if (delName.empty())
delName = movieinfo->file.getFileName();
char buf1[1024];
snprintf(buf1, sizeof(buf1), g_Locale->getText(LOCALE_MOVIEBROWSER_ASK_REC_TO_DELETE), delName.c_str());
if (ShowMsg(LOCALE_RECORDINGMENU_RECORD_IS_RUNNING, buf1,
CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, false) == CMessageBox::mbrNo)
onDelete = false;
else {
CTimerd::RecordingStopInfo recinfo;
recinfo.channel_id = inst->GetChannelId();
recinfo.eventID = inst->GetRecordingId();
CRecordManager::getInstance()->Stop(&recinfo);
g_Timerd->removeTimerEvent(recinfo.eventID);
skipAsk = true;
}
} }
if (onDelete)
onDeleteFile(movieinfo, skipAsk);
} }
if (onDelete)
onDeleteFile(*m_movieSelectionHandler, skipAsk);
} }
} }
else if (msg == CRCInput::RC_help || msg == CRCInput::RC_info) else if (msg == CRCInput::RC_help || msg == CRCInput::RC_info)
@@ -2106,11 +2127,11 @@ bool CMovieBrowser::onButtonPressMovieInfoList(neutrino_msg_t msg)
return (result); return (result);
} }
void CMovieBrowser::onDeleteFile(MI_MOVIE_INFO& movieSelectionHandler, bool skipAsk) void CMovieBrowser::onDeleteFile(MI_MOVIE_INFO *movieinfo, bool skipAsk)
{ {
//TRACE("[onDeleteFile] "); //TRACE("[onDeleteFile] ");
#if 0 #if 0
int test= movieSelectionHandler.file.Name.find(".ts", movieSelectionHandler.file.Name.length()-3); int test= movieinfo->file.Name.find(".ts", movieinfo->file.Name.length()-3);
if (test == -1) { if (test == -1) {
// not a TS file, return!!!!! // not a TS file, return!!!!!
TRACE("show_ts_info: not a TS file "); TRACE("show_ts_info: not a TS file ");
@@ -2119,13 +2140,13 @@ void CMovieBrowser::onDeleteFile(MI_MOVIE_INFO& movieSelectionHandler, bool skip
#endif #endif
std::string msg = g_Locale->getText(LOCALE_FILEBROWSER_DODELETE1); std::string msg = g_Locale->getText(LOCALE_FILEBROWSER_DODELETE1);
msg += "\n "; msg += "\n ";
if (movieSelectionHandler.file.Name.length() > 40) if (movieinfo->file.Name.length() > 40)
{ {
msg += movieSelectionHandler.file.Name.substr(0,40); msg += movieinfo->file.Name.substr(0,40);
msg += "..."; msg += "...";
} }
else else
msg += movieSelectionHandler.file.Name; msg += movieinfo->file.Name;
msg += "\n "; msg += "\n ";
msg += g_Locale->getText(LOCALE_FILEBROWSER_DODELETE2); msg += g_Locale->getText(LOCALE_FILEBROWSER_DODELETE2);
@@ -2133,20 +2154,20 @@ void CMovieBrowser::onDeleteFile(MI_MOVIE_INFO& movieSelectionHandler, bool skip
{ {
CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_MOVIEBROWSER_DELETE_INFO)); CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_MOVIEBROWSER_DELETE_INFO));
hintBox->paint(); hintBox->paint();
delFile(movieSelectionHandler.file); delFile(movieinfo->file);
std::string fname = getScreenshotName(movieSelectionHandler.file.Name, S_ISDIR(m_movieSelectionHandler->file.Mode)); std::string fname = getScreenshotName(movieinfo->file.Name, S_ISDIR(movieinfo->file.Mode));
if (!fname.empty()) if (!fname.empty())
unlink(fname.c_str()); unlink(fname.c_str());
CFile file_xml = movieSelectionHandler.file; CFile file_xml = movieinfo->file;
if (m_movieInfo.convertTs2XmlName(file_xml.Name)) if (m_movieInfo.convertTs2XmlName(file_xml.Name))
unlink(file_xml.Name.c_str()); unlink(file_xml.Name.c_str());
delete hintBox; delete hintBox;
g_RCInput->clearRCMsg(); g_RCInput->clearRCMsg();
m_vMovieInfo.erase((std::vector<MI_MOVIE_INFO>::iterator)&movieSelectionHandler); m_vMovieInfo.erase((std::vector<MI_MOVIE_INFO>::iterator)movieinfo);
TRACE("List size: %d\n", (int)m_vMovieInfo.size()); TRACE("List size: %d\n", (int)m_vMovieInfo.size());
updateSerienames(); updateSerienames();

View File

@@ -331,6 +331,10 @@ class CMovieBrowser : public CMenuTarget
MB_SETTINGS m_settings; MB_SETTINGS m_settings;
std::vector<MB_DIR> m_dir; std::vector<MB_DIR> m_dir;
CFileList filelist;
CFileList::iterator filelist_it;
P_MI_MOVIE_LIST movielist;
CComponentsChannelLogo* CChannelLogo; CComponentsChannelLogo* CChannelLogo;
int movieInfoUpdateAll[MB_INFO_MAX_NUMBER]; int movieInfoUpdateAll[MB_INFO_MAX_NUMBER];
@@ -421,7 +425,7 @@ class CMovieBrowser : public CMenuTarget
void onSetGUIWindow(MB_GUI gui); void onSetGUIWindow(MB_GUI gui);
void onSetGUIWindowNext(void); void onSetGUIWindowNext(void);
void onSetGUIWindowPrev(void); void onSetGUIWindowPrev(void);
void onDeleteFile(MI_MOVIE_INFO& movieSelectionHandler, bool skipAsk = false); // P4 void onDeleteFile(MI_MOVIE_INFO *movieinfo, bool skipAsk = false); // P4
bool onSortMovieInfoHandleList(std::vector<MI_MOVIE_INFO*>& pv_handle_list, MB_INFO_ITEM sort_type, MB_DIRECTION direction); bool onSortMovieInfoHandleList(std::vector<MI_MOVIE_INFO*>& pv_handle_list, MB_INFO_ITEM sort_type, MB_DIRECTION direction);
///// parse Storage Directories ///////////// ///// parse Storage Directories /////////////