mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 07:23:09 +02:00
- favorites: formatting code using astyle; some manual code nicenings
Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
@@ -28,45 +28,37 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <gui/channellist.h>
|
|
||||||
|
|
||||||
#include <global.h>
|
#include <global.h>
|
||||||
#include <neutrino.h>
|
#include <neutrino.h>
|
||||||
|
|
||||||
#include <gui/favorites.h>
|
#include <gui/favorites.h>
|
||||||
|
|
||||||
|
#include <gui/bouquetlist.h>
|
||||||
|
#include <gui/channellist.h>
|
||||||
#include <gui/widget/hintbox.h>
|
#include <gui/widget/hintbox.h>
|
||||||
#include <gui/widget/msgbox.h>
|
#include <gui/widget/msgbox.h>
|
||||||
#include <gui/widget/stringinput.h>
|
#include <gui/widget/stringinput.h>
|
||||||
|
|
||||||
#include <zapit/client/zapitclient.h>
|
#include <zapit/client/zapitclient.h>
|
||||||
#include <zapit/zapit.h>
|
#include <zapit/zapit.h>
|
||||||
|
|
||||||
|
extern CBouquetList *bouquetList;
|
||||||
#include <gui/bouquetlist.h>
|
|
||||||
|
|
||||||
extern CBouquetList * bouquetList; /* neutrino.cpp */
|
|
||||||
extern CBouquetManager *g_bouquetManager;
|
extern CBouquetManager *g_bouquetManager;
|
||||||
|
|
||||||
//
|
//
|
||||||
// -- Add current channel to Favorites-Bouquet
|
// -- Add current channel to Favorites-Bouquet
|
||||||
// -- Return Status (bit-Status):A
|
// -- Return Status (bit-Status):A
|
||||||
// -- 1 = Bouquet created
|
// -- 1 = Bouquet created
|
||||||
// -- 2 = Channel added (if not set, channel already in BQ)
|
// -- 2 = Channel added (if not set, channel already in BQ)
|
||||||
// -- rasc
|
// -- rasc
|
||||||
//
|
//
|
||||||
|
|
||||||
int CFavorites::addChannelToFavorites(bool show_list)
|
int CFavorites::addChannelToFavorites(bool show_list)
|
||||||
{
|
{
|
||||||
signed int bouquet_id;
|
signed int bouquet_id;
|
||||||
t_channel_id channel_id;
|
t_channel_id channel_id;
|
||||||
//const char * fav_bouquetname;
|
int status = 0;
|
||||||
int status = 0;
|
|
||||||
|
|
||||||
#if 0
|
if (show_list)
|
||||||
// no bouquet-List? do nothing
|
|
||||||
if (!bouquetList) return status;
|
|
||||||
#endif
|
|
||||||
if(show_list)
|
|
||||||
{
|
{
|
||||||
bouquet_id = bouquetList->exec(false);
|
bouquet_id = bouquetList->exec(false);
|
||||||
if (bouquet_id < 0)
|
if (bouquet_id < 0)
|
||||||
@@ -78,90 +70,73 @@ int CFavorites::addChannelToFavorites(bool show_list)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// -- check if Favorite Bouquet exists: if not, create it.
|
|
||||||
bouquet_id = g_bouquetManager->existsUBouquet(DEFAULT_BQ_NAME_FAV, true);
|
bouquet_id = g_bouquetManager->existsUBouquet(DEFAULT_BQ_NAME_FAV, true);
|
||||||
if (bouquet_id == -1) {
|
if (bouquet_id == -1)
|
||||||
|
{
|
||||||
g_bouquetManager->addBouquet(DEFAULT_BQ_NAME_FAV, true);
|
g_bouquetManager->addBouquet(DEFAULT_BQ_NAME_FAV, true);
|
||||||
bouquet_id = g_bouquetManager->existsUBouquet(DEFAULT_BQ_NAME_FAV, true);
|
bouquet_id = g_bouquetManager->existsUBouquet(DEFAULT_BQ_NAME_FAV, true);
|
||||||
// status |= 1;
|
//status |= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
channel_id = CZapit::getInstance()->GetCurrentChannelID();;
|
channel_id = CZapit::getInstance()->GetCurrentChannelID();;
|
||||||
|
|
||||||
if(!g_bouquetManager->existsChannelInBouquet(bouquet_id, channel_id)) {
|
if (!g_bouquetManager->existsChannelInBouquet(bouquet_id, channel_id))
|
||||||
|
{
|
||||||
CZapit::getInstance()->addChannelToBouquet(bouquet_id, channel_id);
|
CZapit::getInstance()->addChannelToBouquet(bouquet_id, channel_id);
|
||||||
status |= 2;
|
status |= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- tell zapit to save Boquets and reinit (if changed)
|
|
||||||
if (status)
|
if (status)
|
||||||
{
|
|
||||||
g_Zapit->saveBouquets();
|
g_Zapit->saveBouquets();
|
||||||
}
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
int CFavorites::exec(CMenuTarget *parent, const std::string &actionKey)
|
||||||
// -- Menue Handler Interface
|
|
||||||
// -- to fit the MenueClasses from McClean
|
|
||||||
// -- Add current channel to Favorites and display user messagebox
|
|
||||||
//
|
|
||||||
|
|
||||||
int CFavorites::exec(CMenuTarget* parent, const std::string & actionKey)
|
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
std::string str;
|
std::string str;
|
||||||
int res = menu_return::RETURN_EXIT_ALL;
|
int res = menu_return::RETURN_EXIT_ALL;
|
||||||
bool show_list;
|
bool show_list = (actionKey == "showlist");
|
||||||
//printf("[favorites] key %s\n", actionKey.c_str());
|
|
||||||
show_list = (actionKey == "showlist");
|
|
||||||
if (parent)
|
if (parent)
|
||||||
parent->hide();
|
parent->hide();
|
||||||
|
|
||||||
#if 0
|
CHintBox hintBox(LOCALE_FAVORITES_BOUQUETNAME, g_Locale->getText(LOCALE_FAVORITES_ADDCHANNEL), 380);
|
||||||
if (!bouquetList) {
|
if (!show_list)
|
||||||
ShowMsg(LOCALE_FAVORITES_BOUQUETNAME, LOCALE_FAVORITES_NOBOUQUETS, CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_INFO);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
CHintBox hintBox(LOCALE_FAVORITES_BOUQUETNAME, g_Locale->getText(LOCALE_FAVORITES_ADDCHANNEL), 380); // UTF-8
|
|
||||||
if(!show_list)
|
|
||||||
hintBox.paint();
|
hintBox.paint();
|
||||||
|
|
||||||
status = addChannelToFavorites(show_list);
|
status = addChannelToFavorites(show_list);
|
||||||
|
|
||||||
hintBox.hide();
|
hintBox.hide();
|
||||||
|
|
||||||
// -- Display result
|
if (status < 0)
|
||||||
|
|
||||||
//printf("[favorites] status %d\n", status);
|
|
||||||
if(status < 0)
|
|
||||||
return menu_return::RETURN_REPAINT;
|
return menu_return::RETURN_REPAINT;
|
||||||
|
|
||||||
str = "";
|
str = "";
|
||||||
if(show_list)
|
if (show_list)
|
||||||
{
|
{
|
||||||
if (status & 2) str += g_Locale->getText(LOCALE_EXTRA_CHADDED);
|
if (status & 2)
|
||||||
else str += g_Locale->getText(LOCALE_EXTRA_CHALREADYINBQ);
|
str += g_Locale->getText(LOCALE_EXTRA_CHADDED);
|
||||||
ShowMsg(LOCALE_EXTRA_ADD_TO_BOUQUET, str, CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_INFO); // UTF-8
|
else
|
||||||
|
str += g_Locale->getText(LOCALE_EXTRA_CHALREADYINBQ);
|
||||||
|
|
||||||
|
ShowMsg(LOCALE_EXTRA_ADD_TO_BOUQUET, str, CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_INFO);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (status & 1) str += g_Locale->getText(LOCALE_FAVORITES_BQCREATED);
|
if (status & 1)
|
||||||
if (status & 2) str += g_Locale->getText(LOCALE_FAVORITES_CHADDED);
|
str += g_Locale->getText(LOCALE_FAVORITES_BQCREATED);
|
||||||
else str += g_Locale->getText(LOCALE_FAVORITES_CHALREADYINBQ);
|
if (status & 2)
|
||||||
if (status) str += g_Locale->getText(LOCALE_FAVORITES_FINALHINT);
|
str += g_Locale->getText(LOCALE_FAVORITES_CHADDED);
|
||||||
ShowMsg(LOCALE_FAVORITES_BOUQUETNAME, str, CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_INFO); // UTF-8
|
else
|
||||||
|
str += g_Locale->getText(LOCALE_FAVORITES_CHALREADYINBQ);
|
||||||
|
if (status)
|
||||||
|
str += g_Locale->getText(LOCALE_FAVORITES_FINALHINT);
|
||||||
|
|
||||||
|
ShowMsg(LOCALE_FAVORITES_BOUQUETNAME, str, CMsgBox::mbrBack, CMsgBox::mbBack, NEUTRINO_ICON_INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// if (status) {
|
|
||||||
// g_RCInput->postMsg( NeutrinoMessages::EVT_BOUQUETSCHANGED, 0 );
|
|
||||||
// }
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Neutrino-GUI - DBoxII-Project
|
Neutrino-GUI - DBoxII-Project
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
License: GPL
|
License: GPL
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
@@ -20,7 +18,6 @@
|
|||||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __favorites__
|
#ifndef __favorites__
|
||||||
#define __favorites__
|
#define __favorites__
|
||||||
|
|
||||||
@@ -28,20 +25,11 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// -- Implement Favorites...
|
|
||||||
// -- Class for adding Favorite channels to a bouquet called "Neutrino__Favorites"
|
|
||||||
// -- Bouquet will be created on the first add!
|
|
||||||
//
|
|
||||||
class CFavorites : public CMenuTarget
|
class CFavorites : public CMenuTarget
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
int addChannelToFavorites(bool show_list);
|
||||||
int addChannelToFavorites (bool show_list);
|
int exec(CMenuTarget *parent, const std::string &actionKey);
|
||||||
int exec(CMenuTarget* parent, const std::string & actionKey);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user