mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-22 11:46:14 +02:00
Check for empty strings using empty() instead of comparing to ""
This commit is contained in:
parent
8472acc26c
commit
6c80a663e1
@ -578,7 +578,7 @@ void GMenu2X::writeTmp(int selelem, const string &selectordir) {
|
||||
inf << "link=" << menu->selLinkIndex() << endl;
|
||||
if (selelem>-1)
|
||||
inf << "selectorelem=" << selelem << endl;
|
||||
if (selectordir!="")
|
||||
if (!selectordir.empty())
|
||||
inf << "selectordir=" << selectordir << endl;
|
||||
inf.close();
|
||||
sync();
|
||||
|
@ -47,7 +47,7 @@ InputDialog::InputDialog(GMenu2X *gmenu2x, InputManager &inputMgr_,
|
||||
, inputMgr(inputMgr_)
|
||||
, ts(ts_)
|
||||
{
|
||||
if (title == "") {
|
||||
if (title.empty()) {
|
||||
this->title = text;
|
||||
this->text = "";
|
||||
} else {
|
||||
@ -55,7 +55,7 @@ InputDialog::InputDialog(GMenu2X *gmenu2x, InputManager &inputMgr_,
|
||||
this->text = text;
|
||||
}
|
||||
this->icon = "";
|
||||
if (icon != "" && gmenu2x->sc[icon] != NULL) {
|
||||
if (!icon.empty() && gmenu2x->sc[icon] != NULL) {
|
||||
this->icon = icon;
|
||||
}
|
||||
|
||||
|
@ -202,7 +202,7 @@ LinkApp::LinkApp(GMenu2X *gmenu2x_, Touchscreen &ts, InputManager &inputMgr_,
|
||||
ifstream infile (file.c_str(), ios_base::in);
|
||||
while (getline(infile, line, '\n')) {
|
||||
line = trim(line);
|
||||
if (line=="") continue;
|
||||
if (line.empty()) continue;
|
||||
if (line[0]=='#') continue;
|
||||
|
||||
string::size_type position = line.find("=");
|
||||
@ -320,22 +320,22 @@ bool LinkApp::save() {
|
||||
ofstream f(file.c_str());
|
||||
if (f.is_open()) {
|
||||
if (!isOpk()) {
|
||||
if (title!="" ) f << "title=" << title << endl;
|
||||
if (description!="" ) f << "description=" << description << endl;
|
||||
if (icon!="" ) f << "icon=" << icon << endl;
|
||||
if (exec!="" ) f << "exec=" << exec << endl;
|
||||
if (params!="" ) f << "params=" << params << endl;
|
||||
if (manual!="" ) f << "manual=" << manual << endl;
|
||||
if (!title.empty() ) f << "title=" << title << endl;
|
||||
if (!description.empty() ) f << "description=" << description << endl;
|
||||
if (!icon.empty() ) f << "icon=" << icon << endl;
|
||||
if (!exec.empty() ) f << "exec=" << exec << endl;
|
||||
if (!params.empty() ) f << "params=" << params << endl;
|
||||
if (!manual.empty() ) f << "manual=" << manual << endl;
|
||||
#if defined(PLATFORM_A320) || defined(PLATFORM_GCW0)
|
||||
if (consoleApp ) f << "consoleapp=true" << endl;
|
||||
if (consoleApp ) f << "consoleapp=true" << endl;
|
||||
#endif
|
||||
if (selectorfilter!="*" ) f << "selectorfilter=" << selectorfilter << endl;
|
||||
if (selectorfilter != "*") f << "selectorfilter=" << selectorfilter << endl;
|
||||
}
|
||||
if (iclock!=0 ) f << "clock=" << iclock << endl;
|
||||
if (selectordir!="" ) f << "selectordir=" << selectordir << endl;
|
||||
if (!selectorbrowser ) f << "selectorbrowser=false" << endl;
|
||||
if (selectorscreens!="") f << "selectorscreens=" << selectorscreens << endl;
|
||||
if (aliasfile!="" ) f << "selectoraliases=" << aliasfile << endl;
|
||||
if (iclock != 0 ) f << "clock=" << iclock << endl;
|
||||
if (!selectordir.empty() ) f << "selectordir=" << selectordir << endl;
|
||||
if (!selectorbrowser ) f << "selectorbrowser=false" << endl;
|
||||
if (!selectorscreens.empty() ) f << "selectorscreens=" << selectorscreens << endl;
|
||||
if (!aliasfile.empty() ) f << "selectoraliases=" << aliasfile << endl;
|
||||
f.close();
|
||||
sync();
|
||||
return true;
|
||||
@ -359,7 +359,7 @@ void LinkApp::drawRun() {
|
||||
gmenu2x->s->rectangle(gmenu2x->halfX-halfBoxW, gmenu2x->halfY-21, boxW, 42, gmenu2x->skinConfColors[COLOR_MESSAGE_BOX_BORDER]);
|
||||
|
||||
int x = gmenu2x->halfX+10-halfBoxW;
|
||||
/*if (getIcon()!="")
|
||||
/*if (!getIcon().empty())
|
||||
gmenu2x->sc[getIcon()]->blit(gmenu2x->s,x,104);
|
||||
else
|
||||
gmenu2x->sc["icons/generic.png"]->blit(gmenu2x->s,x,104);*/
|
||||
@ -369,7 +369,7 @@ void LinkApp::drawRun() {
|
||||
}
|
||||
|
||||
void LinkApp::start() {
|
||||
if (selectordir!="")
|
||||
if (!selectordir.empty())
|
||||
selector();
|
||||
else
|
||||
launch();
|
||||
@ -550,7 +550,7 @@ void LinkApp::selector(int startSelection, const string &selectorDir) {
|
||||
void LinkApp::launch(const string &selectedFile, const string &selectedDir) {
|
||||
drawRun();
|
||||
|
||||
if (selectedDir == "")
|
||||
if (selectedDir.empty())
|
||||
selectordir = getSelectorDir();
|
||||
else
|
||||
selectordir = selectedDir;
|
||||
@ -591,10 +591,10 @@ void LinkApp::launch(const string &selectedFile, const string &selectedDir) {
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedFile != "") {
|
||||
if (!selectedFile.empty()) {
|
||||
string path = cmdclean(selectordir + selectedFile);
|
||||
|
||||
if (params == "") {
|
||||
if (params.empty()) {
|
||||
params = path;
|
||||
} else {
|
||||
unsigned int i;
|
||||
@ -623,7 +623,7 @@ void LinkApp::launch(const string &selectedFile, const string &selectedDir) {
|
||||
chmod( command.c_str(), newstat.st_mode );
|
||||
} // else, well.. we are no worse off :)
|
||||
|
||||
if (params!="") command += " " + params;
|
||||
if (!params.empty()) command += " " + params;
|
||||
#if defined(PLATFORM_A320) || defined(PLATFORM_GCW0)
|
||||
if (gmenu2x->confInt["outputLogs"] && !consoleApp)
|
||||
command += " &> " + cmdclean(gmenu2x->getHome()) + "/log.txt";
|
||||
@ -638,7 +638,7 @@ void LinkApp::launch(const string &selectedFile, const string &selectedDir) {
|
||||
|
||||
gmenu2x->saveSelection();
|
||||
|
||||
if (selectedFile == "") {
|
||||
if (selectedFile.empty()) {
|
||||
gmenu2x->writeTmp();
|
||||
}
|
||||
#ifdef ENABLE_CPUFREQ
|
||||
@ -729,7 +729,9 @@ const string &LinkApp::getSelectorDir() {
|
||||
|
||||
void LinkApp::setSelectorDir(const string &selectordir) {
|
||||
this->selectordir = selectordir;
|
||||
if (this->selectordir!="" && this->selectordir[this->selectordir.length()-1]!='/') this->selectordir += "/";
|
||||
if (!selectordir.empty() && selectordir[selectordir.length() - 1] != '/') {
|
||||
this->selectordir += "/";
|
||||
}
|
||||
edited = true;
|
||||
}
|
||||
|
||||
|
@ -411,9 +411,9 @@ bool Menu::addActionLink(uint section, const string &title, function_t action, c
|
||||
}
|
||||
|
||||
bool Menu::addLink(string path, string file, string section) {
|
||||
if (section=="")
|
||||
if (section.empty()) {
|
||||
section = selSection();
|
||||
else if (find(sections.begin(),sections.end(),section)==sections.end()) {
|
||||
} else if (find(sections.begin(),sections.end(),section)==sections.end()) {
|
||||
//section directory doesn't exists
|
||||
if (!addSection(section))
|
||||
return false;
|
||||
|
@ -82,7 +82,7 @@ int MessageBox::exec() {
|
||||
|
||||
int btnX = gmenu2x->halfX+box.w/2-6;
|
||||
for (uint i = 0; i < BUTTON_TYPE_SIZE; i++) {
|
||||
if (buttons[i] != "") {
|
||||
if (!buttons[i].empty()) {
|
||||
buttonPositions[i].y = box.y+box.h-4;
|
||||
buttonPositions[i].w = btnX;
|
||||
|
||||
@ -101,8 +101,8 @@ int MessageBox::exec() {
|
||||
while (result < 0) {
|
||||
InputManager::ButtonEvent event;
|
||||
if (gmenu2x->input.pollEvent(&event)
|
||||
&& (event.state == InputManager::PRESSED)
|
||||
&& (buttons[event.button] != "")) {
|
||||
&& event.state == InputManager::PRESSED
|
||||
&& !buttons[event.button].empty()) {
|
||||
result = event.button;
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ Selector::Selector(GMenu2X *gmenu2x, LinkApp *link, const string &selectorDir) :
|
||||
this->link = link;
|
||||
loadAliases();
|
||||
selRow = 0;
|
||||
if (selectorDir=="")
|
||||
if (selectorDir.empty())
|
||||
dir = link->getSelectorDir();
|
||||
else
|
||||
dir = selectorDir;
|
||||
@ -103,7 +103,8 @@ int Selector::exec(int startSelection) {
|
||||
gmenu2x->s->box(1, iY, 309, 14, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
|
||||
|
||||
//Screenshot
|
||||
if (selected-fl.dirCount()<screens.size() && screens[selected-fl.dirCount()]!="") {
|
||||
if (selected-fl.dirCount()<screens.size()
|
||||
&& !screens[selected-fl.dirCount()].empty()) {
|
||||
curTick = SDL_GetTicks();
|
||||
if (curTick - selTick > 200) {
|
||||
gmenu2x->sc[screens[selected-fl.dirCount()]]->blitRight(
|
||||
@ -262,7 +263,9 @@ void Selector::prepare(FileLister *fl, vector<string> *screens, vector<string> *
|
||||
titles->resize(fl->getFiles().size());
|
||||
|
||||
string screendir = link->getSelectorScreens();
|
||||
if (screendir != "" && screendir[screendir.length()-1]!='/') screendir += "/";
|
||||
if (!screendir.empty() && screendir[screendir.length() - 1] != '/') {
|
||||
screendir += "/";
|
||||
}
|
||||
|
||||
string noext;
|
||||
string::size_type pos;
|
||||
@ -272,7 +275,7 @@ void Selector::prepare(FileLister *fl, vector<string> *screens, vector<string> *
|
||||
if (pos!=string::npos && pos>0)
|
||||
noext = noext.substr(0, pos);
|
||||
titles->at(i) = getAlias(noext);
|
||||
if (titles->at(i)=="")
|
||||
if (titles->at(i).empty())
|
||||
titles->at(i) = noext;
|
||||
|
||||
DEBUG("Searching for screen '%s%s.png'\n", screendir.c_str(), noext.c_str());
|
||||
@ -286,7 +289,7 @@ void Selector::prepare(FileLister *fl, vector<string> *screens, vector<string> *
|
||||
|
||||
void Selector::freeScreenshots(vector<string> *screens) {
|
||||
for (uint i=0; i<screens->size(); i++) {
|
||||
if (screens->at(i) != "")
|
||||
if (!screens->at(i).empty())
|
||||
gmenu2x->sc.del(screens->at(i));
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ SettingsDialog::SettingsDialog(
|
||||
, ts(ts_)
|
||||
, text(text_)
|
||||
{
|
||||
if (icon != "" && gmenu2x->sc[icon] != NULL) {
|
||||
if (!icon.empty() && gmenu2x->sc[icon] != NULL) {
|
||||
this->icon = icon;
|
||||
} else {
|
||||
this->icon = "icons/generic.png";
|
||||
|
@ -58,10 +58,10 @@ TextManualDialog::TextManualDialog(GMenu2X *gmenu2x, const string &title, const
|
||||
for (uint page=0; page<pages.size(); page++) {
|
||||
if (pages[page].text.size() > 0) {
|
||||
//first lines
|
||||
while (trim(pages[page].text[0])=="")
|
||||
while (trim(pages[page].text[0]).empty())
|
||||
pages[page].text.erase(pages[page].text.begin());
|
||||
//last lines
|
||||
while (trim(pages[page].text[pages[page].text.size()-1])=="")
|
||||
while (trim(pages[page].text[pages[page].text.size()-1]).empty())
|
||||
pages[page].text.erase(pages[page].text.end());
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ void Translator::setLang(const string &lang) {
|
||||
if (infile.is_open()) {
|
||||
while (getline(infile, line, '\n')) {
|
||||
line = trim(line);
|
||||
if (line=="") continue;
|
||||
if (line.empty()) continue;
|
||||
if (line[0]=='#') continue;
|
||||
|
||||
string::size_type position = line.find("=");
|
||||
|
Loading…
Reference in New Issue
Block a user