mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-26 23:13:13 +02:00
- bookmarkmanager: formatting code using astyle; some manual code nicenings
Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
@@ -57,7 +57,6 @@
|
||||
|
||||
#define info_height 60
|
||||
|
||||
|
||||
CBookmark::CBookmark(const std::string &inName, const std::string &inUrl, const std::string &inTime)
|
||||
{
|
||||
name = inName;
|
||||
@@ -65,9 +64,8 @@ CBookmark::CBookmark(const std::string & inName, const std::string & inUrl, cons
|
||||
time = inTime;
|
||||
}
|
||||
|
||||
//------------------------------
|
||||
|
||||
int CBookmarkManager::addBookmark (CBookmark inBookmark) {
|
||||
int CBookmarkManager::addBookmark(CBookmark inBookmark)
|
||||
{
|
||||
if (bookmarks.size() < MAXBOOKMARKS)
|
||||
{
|
||||
bookmarks.push_back(inBookmark);
|
||||
@@ -79,12 +77,13 @@ int CBookmarkManager::addBookmark (CBookmark inBookmark) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
inline int CBookmarkManager::createBookmark (const std::string & name, const std::string & url, const std::string & time) {
|
||||
inline int CBookmarkManager::createBookmark(const std::string &name, const std::string &url, const std::string &time)
|
||||
{
|
||||
return addBookmark(CBookmark(name, url, time));
|
||||
}
|
||||
|
||||
int CBookmarkManager::createBookmark (const std::string & url, const std::string & time) {
|
||||
int CBookmarkManager::createBookmark(const std::string &url, const std::string &time)
|
||||
{
|
||||
std::string bookmarkname;
|
||||
CStringInputSMS bookmarkname_input(LOCALE_MOVIEPLAYER_BOOKMARKNAME, &bookmarkname, 25, LOCALE_MOVIEPLAYER_BOOKMARKNAME_HINT1, LOCALE_MOVIEPLAYER_BOOKMARKNAME_HINT2, "abcdefghijklmnopqrstuvwxyz0123456789-_", this);
|
||||
bookmarkname_input.exec(NULL, "");
|
||||
@@ -96,18 +95,17 @@ int CBookmarkManager::createBookmark (const std::string & url, const std::string
|
||||
return -1;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
#if 0
|
||||
// never used
|
||||
void CBookmarkManager::removeBookmark (unsigned int index) {
|
||||
void CBookmarkManager::removeBookmark(unsigned int index)
|
||||
{
|
||||
std::vector<CBookmark>::iterator p = bookmarks.begin() + index;
|
||||
bookmarks.erase(p);
|
||||
bookmarksmodified = true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
void CBookmarkManager::renameBookmark (unsigned int index) {
|
||||
void CBookmarkManager::renameBookmark(unsigned int index)
|
||||
{
|
||||
if (index >= bookmarks.size())
|
||||
return;
|
||||
|
||||
@@ -124,8 +122,9 @@ void CBookmarkManager::renameBookmark (unsigned int index) {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//------------------------------------------------------------------------
|
||||
void CBookmarkManager::readBookmarkFile() {
|
||||
|
||||
void CBookmarkManager::readBookmarkFile()
|
||||
{
|
||||
if (bookmarkfile.loadConfig(BOOKMARKFILE))
|
||||
{
|
||||
bookmarksmodified = false;
|
||||
@@ -147,8 +146,8 @@ void CBookmarkManager::readBookmarkFile() {
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void CBookmarkManager::writeBookmarkFile() {
|
||||
void CBookmarkManager::writeBookmarkFile()
|
||||
{
|
||||
|
||||
printf("CBookmarkManager: Writing bookmark file\n");
|
||||
|
||||
@@ -167,8 +166,6 @@ void CBookmarkManager::writeBookmarkFile() {
|
||||
bookmarksmodified = false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
CBookmarkManager::CBookmarkManager() : bookmarkfile('\t')
|
||||
{
|
||||
bookmarkname_entered = false;
|
||||
@@ -176,43 +173,39 @@ CBookmarkManager::CBookmarkManager() : bookmarkfile ('\t')
|
||||
readBookmarkFile();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
CBookmarkManager::~CBookmarkManager () {
|
||||
CBookmarkManager::~CBookmarkManager()
|
||||
{
|
||||
flush();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
bool CBookmarkManager::changeNotify(const neutrino_locale_t, void *)
|
||||
{
|
||||
bookmarkname_entered = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
#if 0
|
||||
// never used
|
||||
int CBookmarkManager::getBookmarkCount(void) const {
|
||||
int CBookmarkManager::getBookmarkCount(void) const
|
||||
{
|
||||
return bookmarks.size();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
int CBookmarkManager::getMaxBookmarkCount(void) const {
|
||||
int CBookmarkManager::getMaxBookmarkCount(void) const
|
||||
{
|
||||
return MAXBOOKMARKS;
|
||||
}
|
||||
#endif
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
void CBookmarkManager::flush() {
|
||||
if (bookmarksmodified) {
|
||||
void CBookmarkManager::flush()
|
||||
{
|
||||
if (bookmarksmodified)
|
||||
{
|
||||
writeBookmarkFile();
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
#if 0
|
||||
// never used
|
||||
const CBookmark *CBookmarkManager::getBookmark(CMenuTarget *parent)
|
||||
@@ -273,7 +266,8 @@ const CBookmark * CBookmarkManager::getBookmark(CMenuTarget* parent)
|
||||
|
||||
if ((msg == CRCInput::RC_timeout) ||
|
||||
(msg == CRCInput::RC_home))
|
||||
{ //Exit after timeout or cancel key
|
||||
{
|
||||
// Exit after timeout or cancel key
|
||||
res = -1;
|
||||
loop = false;
|
||||
}
|
||||
@@ -329,8 +323,7 @@ const CBookmark * CBookmarkManager::getBookmark(CMenuTarget* parent)
|
||||
renameBookmark(selected);
|
||||
update = true;
|
||||
}
|
||||
else if ((msg==CRCInput::RC_blue)||(msg==CRCInput::RC_green)||
|
||||
(CRCInput::isNumeric(msg)) )
|
||||
else if ((msg == CRCInput::RC_blue) || (msg == CRCInput::RC_green) || (CRCInput::isNumeric(msg)))
|
||||
{
|
||||
// Ignore
|
||||
}
|
||||
@@ -360,7 +353,7 @@ const CBookmark * CBookmarkManager::getBookmark(CMenuTarget* parent)
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
void CBookmarkManager::paintItem(int pos)
|
||||
{
|
||||
int ypos = y + theight + 0 + pos * fheight * 2;
|
||||
@@ -392,14 +385,12 @@ void CBookmarkManager::paintItem(int pos)
|
||||
// LCD Display
|
||||
if (i_selected)
|
||||
{
|
||||
CVFD::getInstance()->showMenuText(0, theBookmark.getName(), -1, true); // UTF-8
|
||||
CVFD::getInstance()->showMenuText(1, theBookmark.getUrl(), -1, true); // UTF-8
|
||||
CVFD::getInstance()->showMenuText(0, theBookmark.getName(), -1, true);
|
||||
CVFD::getInstance()->showMenuText(1, theBookmark.getUrl(), -1, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
void CBookmarkManager::hide()
|
||||
{
|
||||
if (visible)
|
||||
@@ -409,7 +400,6 @@ void CBookmarkManager::hide()
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void CBookmarkManager::paintHead()
|
||||
{
|
||||
CComponentsHeader header(x, y, width, theight, LOCALE_BOOKMARKMANAGER_NAME, NEUTRINO_ICON_BOOKMARK_MANAGER, CComponentsHeader::CC_BTN_HELP);
|
||||
@@ -422,14 +412,14 @@ const struct button_label BookmarkmanagerButtons[2] =
|
||||
{ NEUTRINO_ICON_BUTTON_YELLOW, LOCALE_BOOKMARKMANAGER_RENAME }
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void CBookmarkManager::paintFoot()
|
||||
{
|
||||
int ButtonWidth = (width - 20) / 4;
|
||||
frameBuffer->paintBoxRel(x, y + height, width, footerHeight, COL_MENUFOOT_PLUS_0);
|
||||
frameBuffer->paintHLine(x, x + width, y, COL_MENUFOOT_PLUS_0);
|
||||
|
||||
if (bookmarks.empty()) {
|
||||
if (bookmarks.empty())
|
||||
{
|
||||
frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_OKAY, x + width - 1 * ButtonWidth + 10, y + height);
|
||||
g_Font[SNeutrinoSettings::FONT_TYPE_MENU_FOOT]->RenderString(x + width - 1 * ButtonWidth + 38, y + height + footerHeight - 2, ButtonWidth - 28, g_Locale->getText(LOCALE_BOOKMARKMANAGER_SELECT), COL_INFOBAR_TEXT);
|
||||
}
|
||||
@@ -442,7 +432,6 @@ void CBookmarkManager::paintFoot()
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void CBookmarkManager::paint()
|
||||
{
|
||||
unsigned int page_nr = (listmaxshow == 0) ? 0 : (selected / listmaxshow);
|
||||
@@ -453,9 +442,8 @@ void CBookmarkManager::paint()
|
||||
paintHead();
|
||||
|
||||
for (unsigned int count = 0; count < listmaxshow; count++)
|
||||
{
|
||||
paintItem(count);
|
||||
}
|
||||
|
||||
if (bookmarks.size() > listmaxshow)
|
||||
{
|
||||
int ypos = y + theight;
|
||||
@@ -474,4 +462,3 @@ void CBookmarkManager::paint()
|
||||
paintFoot();
|
||||
visible = true;
|
||||
}
|
||||
|
||||
|
@@ -61,8 +61,6 @@ class CBookmark
|
||||
inline void setTime(const std::string &new_time) { time = new_time; };
|
||||
};
|
||||
|
||||
//-----------------------------------------
|
||||
|
||||
class CBookmarkManager : public CChangeObserver
|
||||
{
|
||||
private:
|
||||
@@ -82,7 +80,6 @@ class CBookmarkManager : public CChangeObserver
|
||||
int x;
|
||||
int y;
|
||||
|
||||
|
||||
//int bookmarkCount;
|
||||
bool bookmarkname_entered;
|
||||
bool bookmarksmodified;
|
||||
@@ -97,8 +94,6 @@ class CBookmarkManager : public CChangeObserver
|
||||
void paintFoot();
|
||||
void hide();
|
||||
|
||||
|
||||
|
||||
public:
|
||||
CBookmarkManager();
|
||||
~CBookmarkManager();
|
||||
|
Reference in New Issue
Block a user