channellist: simplify MaxChanNr() function

Origin commit data
------------------
Branch: ni/coolstream
Commit: 763f16ccca
Author: vanhofen <vanhofen@gmx.de>
Date: 2017-04-11 (Tue, 11 Apr 2017)

Origin message was:
------------------
- channellist: simplify MaxChanNr() function

------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
vanhofen
2017-04-11 23:12:41 +02:00
parent 290eb19dae
commit d291aa3c22

View File

@@ -68,6 +68,7 @@
#else #else
#include <gui/widget/msgbox.h> #include <gui/widget/msgbox.h>
#endif #endif
#include <system/helpers.h>
#include <system/settings.h> #include <system/settings.h>
#include <system/set_threadname.h> #include <system/set_threadname.h>
@@ -1276,7 +1277,7 @@ int CChannelList::numericZap(int key)
} }
return res; return res;
} }
size_t maxchansize = MaxChanNr().size(); size_t maxchansize = MaxChanNr().size();
int fw = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->getMaxDigitWidth(); int fw = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->getMaxDigitWidth();
int sx = maxchansize * fw + (fw/2); int sx = maxchansize * fw + (fw/2);
int sy = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->getHeight() + 6; int sy = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->getHeight() + 6;
@@ -2288,19 +2289,14 @@ bool CChannelList::SameTP(CZapitChannel * channel)
return iscurrent; return iscurrent;
} }
std::string CChannelList::MaxChanNr() std::string CChannelList::MaxChanNr()
{ {
zapit_list_it_t chan_it; int n = 1;
std::stringstream ss; for (zapit_list_it_t it = (*chanlist).begin(); it != (*chanlist).end(); ++it)
std::string maxchansize; {
int chan_nr_max = 1; n = std::max(n, (*it)->number);
unsigned int nr = 0;
for (chan_it=(*chanlist).begin(); chan_it!=(*chanlist).end(); ++chan_it) {
chan_nr_max = std::max(chan_nr_max, (*chanlist)[nr++]->number);
} }
ss << chan_nr_max; return to_string(n);
ss >> maxchansize;
return maxchansize;
} }
void CChannelList::paintPig (int _x, int _y, int w, int h) void CChannelList::paintPig (int _x, int _y, int w, int h)