mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-31 17:31:20 +02:00
Moviebrowser: functions outsourced
TODO: Classes and menus should follow someday.
This commit is contained in:
@@ -42,8 +42,9 @@
|
||||
#include <driver/screen_max.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
//#include <cstdlib>
|
||||
#include "mb.h"
|
||||
#include "mb_functions.h"
|
||||
#include <gui/filebrowser.h>
|
||||
#include <gui/tmdb.h>
|
||||
#include <gui/epgview.h>
|
||||
@@ -62,12 +63,12 @@
|
||||
#include <sys/vfs.h> // for statfs
|
||||
#include <sys/mount.h>
|
||||
#include <utime.h>
|
||||
#include <unistd.h>
|
||||
//#include <unistd.h>
|
||||
#include <gui/pictureviewer.h>
|
||||
#include <gui/customcolor.h>
|
||||
#include <driver/record.h>
|
||||
#include <driver/display.h>
|
||||
#include <system/helpers.h>
|
||||
//#include <system/helpers.h>
|
||||
#include <system/ytcache.h>
|
||||
#include <zapit/debug.h>
|
||||
#include <driver/moviecut.h>
|
||||
@@ -227,122 +228,7 @@ static MI_MOVIE_INFO* playing_info;
|
||||
//------------------------------------------------------------------------
|
||||
#define FILEBROWSER_NUMBER_OF_SORT_VARIANTS 5
|
||||
|
||||
bool sortDirection = 0;
|
||||
|
||||
bool compare_to_lower(const char a, const char b)
|
||||
{
|
||||
return tolower(a) < tolower(b);
|
||||
}
|
||||
|
||||
// sort operators
|
||||
bool sortByTitle(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b)
|
||||
{
|
||||
if (std::lexicographical_compare(a->epgTitle.begin(), a->epgTitle.end(), b->epgTitle.begin(), b->epgTitle.end(), compare_to_lower))
|
||||
return true;
|
||||
if (std::lexicographical_compare(b->epgTitle.begin(), b->epgTitle.end(), a->epgTitle.begin(), a->epgTitle.end(), compare_to_lower))
|
||||
return false;
|
||||
return a->file.Time < b->file.Time;
|
||||
}
|
||||
bool sortByGenre(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b)
|
||||
{
|
||||
if (std::lexicographical_compare(a->epgInfo1.begin(), a->epgInfo1.end(), b->epgInfo1.begin(), b->epgInfo1.end(), compare_to_lower))
|
||||
return true;
|
||||
if (std::lexicographical_compare(b->epgInfo1.begin(), b->epgInfo1.end(), a->epgInfo1.begin(), a->epgInfo1.end(), compare_to_lower))
|
||||
return false;
|
||||
return sortByTitle(a,b);
|
||||
}
|
||||
bool sortByChannel(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b)
|
||||
{
|
||||
if (std::lexicographical_compare(a->epgChannel.begin(), a->epgChannel.end(), b->epgChannel.begin(), b->epgChannel.end(), compare_to_lower))
|
||||
return true;
|
||||
if (std::lexicographical_compare(b->epgChannel.begin(), b->epgChannel.end(), a->epgChannel.begin(), a->epgChannel.end(), compare_to_lower))
|
||||
return false;
|
||||
return sortByTitle(a,b);
|
||||
}
|
||||
bool sortByFileName(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b)
|
||||
{
|
||||
if (std::lexicographical_compare(a->file.getFileName().begin(), a->file.getFileName().end(), b->file.getFileName().begin(), b->file.getFileName().end(), compare_to_lower))
|
||||
return true;
|
||||
if (std::lexicographical_compare(b->file.getFileName().begin(), b->file.getFileName().end(), a->file.getFileName().begin(), a->file.getFileName().end(), compare_to_lower))
|
||||
return false;
|
||||
return a->file.Time < b->file.Time;
|
||||
}
|
||||
bool sortByRecordDate(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b)
|
||||
{
|
||||
if (sortDirection)
|
||||
return a->file.Time > b->file.Time ;
|
||||
else
|
||||
return a->file.Time < b->file.Time ;
|
||||
}
|
||||
bool sortBySize(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b)
|
||||
{
|
||||
if (sortDirection)
|
||||
return a->file.Size > b->file.Size;
|
||||
else
|
||||
return a->file.Size < b->file.Size;
|
||||
}
|
||||
bool sortByAge(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b)
|
||||
{
|
||||
if (sortDirection)
|
||||
return a->parentalLockAge > b->parentalLockAge;
|
||||
else
|
||||
return a->parentalLockAge < b->parentalLockAge;
|
||||
}
|
||||
bool sortByRating(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b)
|
||||
{
|
||||
if (sortDirection)
|
||||
return a->rating > b->rating;
|
||||
else
|
||||
return a->rating < b->rating;
|
||||
}
|
||||
bool sortByQuality(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b)
|
||||
{
|
||||
if (sortDirection)
|
||||
return a->quality > b->quality;
|
||||
else
|
||||
return a->quality < b->quality;
|
||||
}
|
||||
bool sortByDir(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b)
|
||||
{
|
||||
if (sortDirection)
|
||||
return a->dirItNr > b->dirItNr;
|
||||
else
|
||||
return a->dirItNr < b->dirItNr;
|
||||
}
|
||||
|
||||
bool sortByLastPlay(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b)
|
||||
{
|
||||
if (sortDirection)
|
||||
return a->dateOfLastPlay > b->dateOfLastPlay;
|
||||
else
|
||||
return a->dateOfLastPlay < b->dateOfLastPlay;
|
||||
}
|
||||
|
||||
bool (* const sortBy[MB_INFO_MAX_NUMBER+1])(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b) =
|
||||
{
|
||||
&sortByFileName, //MB_INFO_FILENAME = 0,
|
||||
&sortByDir, //MB_INFO_FILEPATH = 1,
|
||||
&sortByTitle, //MB_INFO_TITLE = 2,
|
||||
NULL, //MB_INFO_SERIE = 3,
|
||||
&sortByGenre, //MB_INFO_INFO1 = 4,
|
||||
NULL, //MB_INFO_MAJOR_GENRE = 5,
|
||||
NULL, //MB_INFO_MINOR_GENRE = 6,
|
||||
NULL, //MB_INFO_INFO2 = 7,
|
||||
&sortByAge, //MB_INFO_PARENTAL_LOCKAGE = 8,
|
||||
&sortByChannel, //MB_INFO_CHANNEL = 9,
|
||||
NULL, //MB_INFO_BOOKMARK = 10,
|
||||
&sortByQuality, //MB_INFO_QUALITY = 11,
|
||||
&sortByLastPlay, //MB_INFO_PREVPLAYDATE = 12,
|
||||
&sortByRecordDate, //MB_INFO_RECORDDATE = 13,
|
||||
NULL, //MB_INFO_PRODDATE = 14,
|
||||
NULL, //MB_INFO_COUNTRY = 15,
|
||||
NULL, //MB_INFO_GEOMETRIE = 16,
|
||||
NULL, //MB_INFO_AUDIO = 17,
|
||||
NULL, //MB_INFO_LENGTH = 18,
|
||||
&sortBySize, //MB_INFO_SIZE = 19,
|
||||
&sortByRating, //MB_INFO_RATING = 20,
|
||||
NULL //MB_INFO_MAX_NUMBER = 21
|
||||
};
|
||||
|
||||
CMovieBrowser::CMovieBrowser(): configfile ('\t')
|
||||
{
|
||||
@@ -2977,10 +2863,7 @@ void CMovieBrowser::showHelp(void)
|
||||
help.exec(NULL,NULL);
|
||||
}
|
||||
|
||||
static std::string rateFormat(int i)
|
||||
{
|
||||
return to_string(i/10) + "," + to_string(i%10);
|
||||
}
|
||||
|
||||
|
||||
#define MAX_STRING 30
|
||||
int CMovieBrowser::showMovieInfoMenu(MI_MOVIE_INFO* movie_info)
|
||||
|
@@ -73,7 +73,7 @@
|
||||
|
||||
#include <configfile.h>
|
||||
|
||||
#include <string>
|
||||
//#include <string>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
|
||||
|
138
src/gui/moviebrowser/mb_functions.h
Normal file
138
src/gui/moviebrowser/mb_functions.h
Normal file
@@ -0,0 +1,138 @@
|
||||
|
||||
#ifndef __MB_FUNCTIONS__
|
||||
#define __MB_FUNCTIONS__
|
||||
|
||||
|
||||
#include "mb_types.h"
|
||||
#include <system/helpers.h>
|
||||
|
||||
|
||||
|
||||
|
||||
void strReplace(std::string& orig, const char* fstr, const std::string &rstr);
|
||||
|
||||
static std::string rateFormat(int i)
|
||||
{
|
||||
return to_string(i/10) + "," + to_string(i%10);
|
||||
}
|
||||
|
||||
bool sortDirection = 0;
|
||||
|
||||
bool compare_to_lower(const char a, const char b)
|
||||
{
|
||||
return tolower(a) < tolower(b);
|
||||
}
|
||||
|
||||
// sort operators
|
||||
bool sortByTitle(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b)
|
||||
{
|
||||
if (std::lexicographical_compare(a->epgTitle.begin(), a->epgTitle.end(), b->epgTitle.begin(), b->epgTitle.end(), compare_to_lower))
|
||||
return true;
|
||||
if (std::lexicographical_compare(b->epgTitle.begin(), b->epgTitle.end(), a->epgTitle.begin(), a->epgTitle.end(), compare_to_lower))
|
||||
return false;
|
||||
return a->file.Time < b->file.Time;
|
||||
}
|
||||
bool sortByGenre(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b)
|
||||
{
|
||||
if (std::lexicographical_compare(a->epgInfo1.begin(), a->epgInfo1.end(), b->epgInfo1.begin(), b->epgInfo1.end(), compare_to_lower))
|
||||
return true;
|
||||
if (std::lexicographical_compare(b->epgInfo1.begin(), b->epgInfo1.end(), a->epgInfo1.begin(), a->epgInfo1.end(), compare_to_lower))
|
||||
return false;
|
||||
return sortByTitle(a,b);
|
||||
}
|
||||
bool sortByChannel(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b)
|
||||
{
|
||||
if (std::lexicographical_compare(a->epgChannel.begin(), a->epgChannel.end(), b->epgChannel.begin(), b->epgChannel.end(), compare_to_lower))
|
||||
return true;
|
||||
if (std::lexicographical_compare(b->epgChannel.begin(), b->epgChannel.end(), a->epgChannel.begin(), a->epgChannel.end(), compare_to_lower))
|
||||
return false;
|
||||
return sortByTitle(a,b);
|
||||
}
|
||||
bool sortByFileName(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b)
|
||||
{
|
||||
if (std::lexicographical_compare(a->file.getFileName().begin(), a->file.getFileName().end(), b->file.getFileName().begin(), b->file.getFileName().end(), compare_to_lower))
|
||||
return true;
|
||||
if (std::lexicographical_compare(b->file.getFileName().begin(), b->file.getFileName().end(), a->file.getFileName().begin(), a->file.getFileName().end(), compare_to_lower))
|
||||
return false;
|
||||
return a->file.Time < b->file.Time;
|
||||
}
|
||||
bool sortByRecordDate(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b)
|
||||
{
|
||||
if (sortDirection)
|
||||
return a->file.Time > b->file.Time ;
|
||||
else
|
||||
return a->file.Time < b->file.Time ;
|
||||
}
|
||||
bool sortBySize(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b)
|
||||
{
|
||||
if (sortDirection)
|
||||
return a->file.Size > b->file.Size;
|
||||
else
|
||||
return a->file.Size < b->file.Size;
|
||||
}
|
||||
bool sortByAge(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b)
|
||||
{
|
||||
if (sortDirection)
|
||||
return a->parentalLockAge > b->parentalLockAge;
|
||||
else
|
||||
return a->parentalLockAge < b->parentalLockAge;
|
||||
}
|
||||
bool sortByRating(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b)
|
||||
{
|
||||
if (sortDirection)
|
||||
return a->rating > b->rating;
|
||||
else
|
||||
return a->rating < b->rating;
|
||||
}
|
||||
bool sortByQuality(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b)
|
||||
{
|
||||
if (sortDirection)
|
||||
return a->quality > b->quality;
|
||||
else
|
||||
return a->quality < b->quality;
|
||||
}
|
||||
bool sortByDir(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b)
|
||||
{
|
||||
if (sortDirection)
|
||||
return a->dirItNr > b->dirItNr;
|
||||
else
|
||||
return a->dirItNr < b->dirItNr;
|
||||
}
|
||||
|
||||
bool sortByLastPlay(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b)
|
||||
{
|
||||
if (sortDirection)
|
||||
return a->dateOfLastPlay > b->dateOfLastPlay;
|
||||
else
|
||||
return a->dateOfLastPlay < b->dateOfLastPlay;
|
||||
}
|
||||
|
||||
bool (* const sortBy[MB_INFO_MAX_NUMBER+1])(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b) =
|
||||
{
|
||||
&sortByFileName, //MB_INFO_FILENAME = 0,
|
||||
&sortByDir, //MB_INFO_FILEPATH = 1,
|
||||
&sortByTitle, //MB_INFO_TITLE = 2,
|
||||
NULL, //MB_INFO_SERIE = 3,
|
||||
&sortByGenre, //MB_INFO_INFO1 = 4,
|
||||
NULL, //MB_INFO_MAJOR_GENRE = 5,
|
||||
NULL, //MB_INFO_MINOR_GENRE = 6,
|
||||
NULL, //MB_INFO_INFO2 = 7,
|
||||
&sortByAge, //MB_INFO_PARENTAL_LOCKAGE = 8,
|
||||
&sortByChannel, //MB_INFO_CHANNEL = 9,
|
||||
NULL, //MB_INFO_BOOKMARK = 10,
|
||||
&sortByQuality, //MB_INFO_QUALITY = 11,
|
||||
&sortByLastPlay, //MB_INFO_PREVPLAYDATE = 12,
|
||||
&sortByRecordDate, //MB_INFO_RECORDDATE = 13,
|
||||
NULL, //MB_INFO_PRODDATE = 14,
|
||||
NULL, //MB_INFO_COUNTRY = 15,
|
||||
NULL, //MB_INFO_GEOMETRIE = 16,
|
||||
NULL, //MB_INFO_AUDIO = 17,
|
||||
NULL, //MB_INFO_LENGTH = 18,
|
||||
&sortBySize, //MB_INFO_SIZE = 19,
|
||||
&sortByRating, //MB_INFO_RATING = 20,
|
||||
NULL //MB_INFO_MAX_NUMBER = 21
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /*__MB_FUNCTIONS__*/
|
Reference in New Issue
Block a user