moviebrowser: allow to delete all marked movies

Origin commit data
------------------
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
This commit is contained in:
vanhofen
2015-09-29 08:00:00 +02:00
parent cf2caa3c56
commit a724a13f2d
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,14 +1819,30 @@ 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;
movieinfo = NULL;
filelist_it = filelist.end();
if (getSelectedFiles(filelist, movielist))
filelist_it = filelist.begin();
if (filelist.empty()) { //just add the m_movieSelectionHandler
filelist.push_back(m_movieSelectionHandler->file);
movielist.push_back(m_movieSelectionHandler);
}
for (filelist_it = filelist.begin(); filelist_it != filelist.end(); ++filelist_it)
{
unsigned int idx = filelist_it - filelist.begin();
movieinfo = movielist[idx];
TRACE("[mb]-> try to delete %d:%s\n", idx, movieinfo->file.Name.c_str());
if ((!m_vMovieInfo.empty()) && (movieinfo != NULL)) {
bool onDelete = true; bool onDelete = true;
bool skipAsk = false; bool skipAsk = false;
CRecordInstance* inst = CRecordManager::getInstance()->getRecordInstance(m_movieSelectionHandler->file.Name); CRecordInstance* inst = CRecordManager::getInstance()->getRecordInstance(movieinfo->file.Name);
if (inst != NULL) { if (inst != NULL) {
std::string delName = m_movieSelectionHandler->epgTitle; std::string delName = movieinfo->epgTitle;
if (delName.empty()) if (delName.empty())
delName = m_movieSelectionHandler->file.getFileName(); delName = movieinfo->file.getFileName();
char buf1[1024]; char buf1[1024];
snprintf(buf1, sizeof(buf1), g_Locale->getText(LOCALE_MOVIEBROWSER_ASK_REC_TO_DELETE), delName.c_str()); snprintf(buf1, sizeof(buf1), g_Locale->getText(LOCALE_MOVIEBROWSER_ASK_REC_TO_DELETE), delName.c_str());
if (ShowMsg(LOCALE_RECORDINGMENU_RECORD_IS_RUNNING, buf1, if (ShowMsg(LOCALE_RECORDINGMENU_RECORD_IS_RUNNING, buf1,
@@ -1838,7 +1858,8 @@ bool CMovieBrowser::onButtonPressMainFrame(neutrino_msg_t msg)
} }
} }
if (onDelete) if (onDelete)
onDeleteFile(*m_movieSelectionHandler, skipAsk); onDeleteFile(movieinfo, 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 /////////////