- bookmarkmanager: formatting code using astyle; some manual code nicenings

Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
svenhoefer
2021-12-14 11:11:25 +01:00
committed by Thilo Graf
parent 62253613e1
commit 38e3181064
2 changed files with 166 additions and 184 deletions

View File

@@ -57,7 +57,6 @@
#define info_height 60 #define info_height 60
CBookmark::CBookmark(const std::string &inName, const std::string &inUrl, const std::string &inTime) CBookmark::CBookmark(const std::string &inName, const std::string &inUrl, const std::string &inTime)
{ {
name = inName; name = inName;
@@ -65,9 +64,8 @@ CBookmark::CBookmark(const std::string & inName, const std::string & inUrl, cons
time = inTime; time = inTime;
} }
//------------------------------ int CBookmarkManager::addBookmark(CBookmark inBookmark)
{
int CBookmarkManager::addBookmark (CBookmark inBookmark) {
if (bookmarks.size() < MAXBOOKMARKS) if (bookmarks.size() < MAXBOOKMARKS)
{ {
bookmarks.push_back(inBookmark); bookmarks.push_back(inBookmark);
@@ -79,12 +77,13 @@ int CBookmarkManager::addBookmark (CBookmark inBookmark) {
return -1; 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)); 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; std::string bookmarkname;
CStringInputSMS bookmarkname_input(LOCALE_MOVIEPLAYER_BOOKMARKNAME, &bookmarkname, 25, LOCALE_MOVIEPLAYER_BOOKMARKNAME_HINT1, LOCALE_MOVIEPLAYER_BOOKMARKNAME_HINT2, "abcdefghijklmnopqrstuvwxyz0123456789-_", this); CStringInputSMS bookmarkname_input(LOCALE_MOVIEPLAYER_BOOKMARKNAME, &bookmarkname, 25, LOCALE_MOVIEPLAYER_BOOKMARKNAME_HINT1, LOCALE_MOVIEPLAYER_BOOKMARKNAME_HINT2, "abcdefghijklmnopqrstuvwxyz0123456789-_", this);
bookmarkname_input.exec(NULL, ""); bookmarkname_input.exec(NULL, "");
@@ -96,18 +95,17 @@ int CBookmarkManager::createBookmark (const std::string & url, const std::string
return -1; return -1;
} }
//------------------------------------------------------------------------
#if 0 #if 0
// never used // never used
void CBookmarkManager::removeBookmark (unsigned int index) { void CBookmarkManager::removeBookmark(unsigned int index)
{
std::vector<CBookmark>::iterator p = bookmarks.begin() + index; std::vector<CBookmark>::iterator p = bookmarks.begin() + index;
bookmarks.erase(p); bookmarks.erase(p);
bookmarksmodified = true; bookmarksmodified = true;
} }
//------------------------------------------------------------------------ void CBookmarkManager::renameBookmark(unsigned int index)
{
void CBookmarkManager::renameBookmark (unsigned int index) {
if (index >= bookmarks.size()) if (index >= bookmarks.size())
return; return;
@@ -124,8 +122,9 @@ void CBookmarkManager::renameBookmark (unsigned int index) {
} }
} }
#endif #endif
//------------------------------------------------------------------------
void CBookmarkManager::readBookmarkFile() { void CBookmarkManager::readBookmarkFile()
{
if (bookmarkfile.loadConfig(BOOKMARKFILE)) if (bookmarkfile.loadConfig(BOOKMARKFILE))
{ {
bookmarksmodified = false; bookmarksmodified = false;
@@ -147,8 +146,8 @@ void CBookmarkManager::readBookmarkFile() {
} }
} }
//------------------------------------------------------------------------ void CBookmarkManager::writeBookmarkFile()
void CBookmarkManager::writeBookmarkFile() { {
printf("CBookmarkManager: Writing bookmark file\n"); printf("CBookmarkManager: Writing bookmark file\n");
@@ -167,8 +166,6 @@ void CBookmarkManager::writeBookmarkFile() {
bookmarksmodified = false; bookmarksmodified = false;
} }
//------------------------------------------------------------------------
CBookmarkManager::CBookmarkManager() : bookmarkfile('\t') CBookmarkManager::CBookmarkManager() : bookmarkfile('\t')
{ {
bookmarkname_entered = false; bookmarkname_entered = false;
@@ -176,43 +173,39 @@ CBookmarkManager::CBookmarkManager() : bookmarkfile ('\t')
readBookmarkFile(); readBookmarkFile();
} }
//------------------------------------------------------------------------ CBookmarkManager::~CBookmarkManager()
{
CBookmarkManager::~CBookmarkManager () {
flush(); flush();
} }
//------------------------------------------------------------------------
bool CBookmarkManager::changeNotify(const neutrino_locale_t, void *) bool CBookmarkManager::changeNotify(const neutrino_locale_t, void *)
{ {
bookmarkname_entered = true; bookmarkname_entered = true;
return false; return false;
} }
//------------------------------------------------------------------------
#if 0 #if 0
// never used // never used
int CBookmarkManager::getBookmarkCount(void) const { int CBookmarkManager::getBookmarkCount(void) const
{
return bookmarks.size(); return bookmarks.size();
} }
//------------------------------------------------------------------------ int CBookmarkManager::getMaxBookmarkCount(void) const
{
int CBookmarkManager::getMaxBookmarkCount(void) const {
return MAXBOOKMARKS; return MAXBOOKMARKS;
} }
#endif #endif
//------------------------------------------------------------------------
void CBookmarkManager::flush() { void CBookmarkManager::flush()
if (bookmarksmodified) { {
if (bookmarksmodified)
{
writeBookmarkFile(); writeBookmarkFile();
} }
} }
//------------------------------------------------------------------------
#if 0 #if 0
// never used // never used
const CBookmark *CBookmarkManager::getBookmark(CMenuTarget *parent) const CBookmark *CBookmarkManager::getBookmark(CMenuTarget *parent)
@@ -273,7 +266,8 @@ const CBookmark * CBookmarkManager::getBookmark(CMenuTarget* parent)
if ((msg == CRCInput::RC_timeout) || if ((msg == CRCInput::RC_timeout) ||
(msg == CRCInput::RC_home)) (msg == CRCInput::RC_home))
{ //Exit after timeout or cancel key {
// Exit after timeout or cancel key
res = -1; res = -1;
loop = false; loop = false;
} }
@@ -329,8 +323,7 @@ const CBookmark * CBookmarkManager::getBookmark(CMenuTarget* parent)
renameBookmark(selected); renameBookmark(selected);
update = true; update = true;
} }
else if ((msg==CRCInput::RC_blue)||(msg==CRCInput::RC_green)|| else if ((msg == CRCInput::RC_blue) || (msg == CRCInput::RC_green) || (CRCInput::isNumeric(msg)))
(CRCInput::isNumeric(msg)) )
{ {
// Ignore // Ignore
} }
@@ -360,7 +353,7 @@ const CBookmark * CBookmarkManager::getBookmark(CMenuTarget* parent)
return NULL; return NULL;
} }
#endif #endif
//------------------------------------------------------------------------
void CBookmarkManager::paintItem(int pos) void CBookmarkManager::paintItem(int pos)
{ {
int ypos = y + theight + 0 + pos * fheight * 2; int ypos = y + theight + 0 + pos * fheight * 2;
@@ -392,14 +385,12 @@ void CBookmarkManager::paintItem(int pos)
// LCD Display // LCD Display
if (i_selected) if (i_selected)
{ {
CVFD::getInstance()->showMenuText(0, theBookmark.getName(), -1, true); // UTF-8 CVFD::getInstance()->showMenuText(0, theBookmark.getName(), -1, true);
CVFD::getInstance()->showMenuText(1, theBookmark.getUrl(), -1, true); // UTF-8 CVFD::getInstance()->showMenuText(1, theBookmark.getUrl(), -1, true);
} }
} }
} }
//------------------------------------------------------------------------
void CBookmarkManager::hide() void CBookmarkManager::hide()
{ {
if (visible) if (visible)
@@ -409,7 +400,6 @@ void CBookmarkManager::hide()
} }
} }
//------------------------------------------------------------------------
void CBookmarkManager::paintHead() void CBookmarkManager::paintHead()
{ {
CComponentsHeader header(x, y, width, theight, LOCALE_BOOKMARKMANAGER_NAME, NEUTRINO_ICON_BOOKMARK_MANAGER, CComponentsHeader::CC_BTN_HELP); 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 } { NEUTRINO_ICON_BUTTON_YELLOW, LOCALE_BOOKMARKMANAGER_RENAME }
}; };
//------------------------------------------------------------------------
void CBookmarkManager::paintFoot() void CBookmarkManager::paintFoot()
{ {
int ButtonWidth = (width - 20) / 4; int ButtonWidth = (width - 20) / 4;
frameBuffer->paintBoxRel(x, y + height, width, footerHeight, COL_MENUFOOT_PLUS_0); frameBuffer->paintBoxRel(x, y + height, width, footerHeight, COL_MENUFOOT_PLUS_0);
frameBuffer->paintHLine(x, x + width, y, 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); 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); 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() void CBookmarkManager::paint()
{ {
unsigned int page_nr = (listmaxshow == 0) ? 0 : (selected / listmaxshow); unsigned int page_nr = (listmaxshow == 0) ? 0 : (selected / listmaxshow);
@@ -453,9 +442,8 @@ void CBookmarkManager::paint()
paintHead(); paintHead();
for (unsigned int count = 0; count < listmaxshow; count++) for (unsigned int count = 0; count < listmaxshow; count++)
{
paintItem(count); paintItem(count);
}
if (bookmarks.size() > listmaxshow) if (bookmarks.size() > listmaxshow)
{ {
int ypos = y + theight; int ypos = y + theight;
@@ -474,4 +462,3 @@ void CBookmarkManager::paint()
paintFoot(); paintFoot();
visible = true; visible = true;
} }

View File

@@ -61,8 +61,6 @@ class CBookmark
inline void setTime(const std::string &new_time) { time = new_time; }; inline void setTime(const std::string &new_time) { time = new_time; };
}; };
//-----------------------------------------
class CBookmarkManager : public CChangeObserver class CBookmarkManager : public CChangeObserver
{ {
private: private:
@@ -82,7 +80,6 @@ class CBookmarkManager : public CChangeObserver
int x; int x;
int y; int y;
//int bookmarkCount; //int bookmarkCount;
bool bookmarkname_entered; bool bookmarkname_entered;
bool bookmarksmodified; bool bookmarksmodified;
@@ -97,8 +94,6 @@ class CBookmarkManager : public CChangeObserver
void paintFoot(); void paintFoot();
void hide(); void hide();
public: public:
CBookmarkManager(); CBookmarkManager();
~CBookmarkManager(); ~CBookmarkManager();