/*************************************************************************** * Copyright (C) 2010 by Pierre Marchand * * pierre@oep-h.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "options.h" #include "names.h" #include #include #include Options::Options(const QStringList& opt) { QList images; foreach(QString s, opt) { QStringList arg(s.split("=")); if(arg.size() > 1) { // special case for images if(arg.at(0) == QString(OPTIMAGE)) { if(arg.at(1).startsWith("+")) { QString ipat(arg.at(1).mid(1)); QDir dir("."); QStringList globbed(dir.entryList(QStringList(ipat))); for(int i(0); i < globbed.count(); ++i) { insert(QString(OPTIMAGE) + QString::number(i), globbed.at(i)); // qDebug()< "<= 1) { for(int i(0); i < images.count(); ++i) { insert(QString(OPTIMAGE) + QString::number(i), images.at(i)); } } // else // { // QDir dir("."); // QStringList globbed(dir.entryList(images)); // for(int i(0); i < globbed.count(); ++i) // { // insert(QString(OPTIMAGE) + QString::number(i), globbed.at(i)); // qDebug()< "< 0) || contains(key + QString::number(0))) key.append( QString::number(n) ); QString v(value(key)); if(allString.contains(v)) { if(trueString.contains(v)) return true; else return false; } int ival(value(key,"0").toInt()); return (ival == 0 ? false : true); } int Options::toInt(const QString &s , int n) { QString key( s ); if((n > 0) || contains(key + QString::number(0))) key.append( QString::number(n) ); return value(key,"0").toInt(); } double Options::toDouble(const QString &s , int n) { QString key( s ); if((n > 0) || contains(key + QString::number(0))) key.append( QString::number(n) ); return value(key,"0").toDouble(); } GridSpec Options::toSpec(const QString &s , int n) { QString key( s ); if((n > 0) || contains(key + QString::number(0))) key.append( QString::number(n) ); GridSpec ret(value(key,"0+0+0+0+0+0")); return ret; } QString Options::toString(const QString &s, int n) { QString key( s ); if((n > 0) || contains(key + QString::number(0))) key.append( QString::number(n) ); return value(key, QString()); } void Options::Dump() { foreach(QString k, keys()) { qDebug()<