//
// C++ Implementation: StringCheck
//
// Description: 
//
//
// Author: Muylkens Toon <toon.muylkens@student.kuleuven.be>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include <StringCheck.h>

/**
*returns true if the string is OK
*returns false if string contains:  '_' or '!'
*if emptystringallowed is false, an empty string will return false
*/
bool StringCheck::check(QString string, bool emptystringallowed, QString title){
bool result = true;
if(!emptystringallowed && string.size()==0){result=false;}
if(string.contains("!")) {result=false;}
if(string.contains("_")) {result=false;}
//if(string.contains("\n")) {result=false;}
if(!result){
	///not a good name
	QMessageBox msgBox;
	msgBox.setStandardButtons(QMessageBox::Ok);
	msgBox.setIcon(QMessageBox::Critical);
	msgBox.setText(title);
	QString detail=tr("You may not use ! or _.");
	if(!emptystringallowed){detail.append(tr("Empty strings are also not allowed."));}
	msgBox.setDetailedText(detail);
	msgBox.exec();
	}
return result;
}

StringCheck::StringCheck():QObject(){

}

StringCheck::~StringCheck()
 {
 }
