Пример #1
0
QStringList Themes::getSubDirs(const QString &path, bool validate) const
{
	QDir dir(path);
	dir.setFilter(QDir::Dirs);
	QStringList dirs = dir.entryList();
	dirs.removeAll(".");
	dirs.removeAll("..");

	if (!validate)
		return dirs;

	QStringList subdirs;
	foreach(const QString &dir, dirs)
	{
		QString dirname = path + '/' + dir;
		if (validateDir(dirname))
			subdirs.append(dir);
	}
// ---
bool VSWAEImportContentWindow::verifyContent ()
{
	// By default the verification will be true...
	bool result = true;

	// Switch off all the warning indicators...
	switchOffWarnings ();
	
	// First of all, it verifies all the mandatoty fields
	// are introduced. If not the result will be nok.
	if (_name -> text () == QString (__NULL_STRING__) || 
		_implementationFile -> fileName () ==  QString (__NULL_STRING__) ||
		_type -> currentText () == QString (__NULL_STRING__))
		result &= false;

	// If the name introduce already exists...
	// Then a indication is switched on, and the ok button woill not be enabled...
	// But only if something has been introduced.
	if (_name -> text () != QString (__NULL_STRING__))
	{
		bool nameExists = (_contentNames.indexOf (_name -> text ()) != -1);
		if (nameExists) result &= false;
		_nameTF -> setPixmap (QPixmap (nameExists ? 
			":/VSWAdvancedEditor/Resources/Error.png" : ":/VSWAdvancedEditor/Resources/Ok.png"));
	}

	// If the definition directory is not a directory o the directory is not 
	// contained in the basic path, then there is mistake...
	if (_definitionDirName -> dirName () != QString (__NULL_STRING__) && 
		_name -> text () != QString (__NULL_STRING__))
	{
		bool isValidDir = validateDir (_definitionDirName -> dirName ());
		Poco::File defFile = Poco::File ((_definitionDirName -> dirName () + QString (__PATH_SEPARATOR__) + 
			_name -> text () + QString (".xml")).toStdString ());
		if (!isValidDir) result &= false;
		_definitionDirNameTF -> setPixmap (QPixmap (isValidDir ? 
			":/VSWAdvancedEditor/Resources/Ok.png" : ":/VSWAdvancedEditor/Resources/Error.png"));
		if (isValidDir &&  defFile.exists ()) // Being valid, the definition file already exists...
			_definitionDirNameTF -> setPixmap (QPixmap (":/VSWAdvancedEditor/Resources/Warning.png"));
	}

	// If the implementation directory is not a directory o the directory is not 
	// contained in the basic path, then there is mistake...
	if (_implementationDirName -> dirName () != QString (__NULL_STRING__) && 
		_name -> text () != QString (__NULL_STRING__))
	{
		QString iF = _implementationFile -> fileName ();
		#ifdef __WINDOWSPLATFORM__
		iF.replace ("/","\\");
		#endif

		bool isValidDir = validateDir (_implementationDirName -> dirName ());
		Poco::File defFile = Poco::File ((_implementationDirName -> dirName () + QString (__PATH_SEPARATOR__) + 
			QString (onlyFileName (iF.toStdString ()).c_str ())).toStdString ());
		if (!isValidDir) result &= false;
		_implementationDirNameTF -> setPixmap (QPixmap (isValidDir ? 
			":/VSWAdvancedEditor/Resources/Ok.png" : ":/VSWAdvancedEditor/Resources/Error.png"));
		if (isValidDir &&  defFile.exists ()) // Being valid, the implementation file already exists...
			_implementationDirNameTF -> setPixmap (QPixmap (":/VSWAdvancedEditor/Resources/Warning.png"));
	}

	// Test also the destination of the ocon name,
	// to show a warning icon if an element with the same name already exists in the destination...
	if (_implementationDirName -> dirName () != QString (__NULL_STRING__) && 
		_iconFile -> fileName () != QString (__NULL_STRING__))
	{
		QString iF = _iconFile -> fileName ();
		#ifdef __WINDOWSPLATFORM__
		iF.replace ("/","\\");
		#endif

		bool isValidDir = validateDir (_implementationDirName -> dirName ());
		Poco::File defFile = Poco::File ((_implementationDirName -> dirName () + QString (__PATH_SEPARATOR__) + 
			QString (onlyFileName (iF.toStdString ()).c_str ())).toStdString ());
		if (!isValidDir) result &= false;
		_iconFileTF -> setPixmap (QPixmap (isValidDir ? 
			":/VSWAdvancedEditor/Resources/Ok.png" : ":/VSWAdvancedEditor/Resources/Error.png"));
		if (isValidDir &&  defFile.exists ()) // Being valid, the implementation file already exists...
			_iconFileTF -> setPixmap (QPixmap (":/VSWAdvancedEditor/Resources/Warning.png"));
	}

	// The same with the resumen file...
	if (_implementationDirName -> dirName () != QString (__NULL_STRING__) && 
		_resumeFile -> fileName () != QString (__NULL_STRING__))
	{
		QString iF = _resumeFile -> fileName ();
		#ifdef __WINDOWSPLATFORM__
		iF.replace ("/","\\");
		#endif

		bool isValidDir = validateDir (_implementationDirName -> dirName ());
		Poco::File defFile = Poco::File ((_implementationDirName -> dirName () + QString (__PATH_SEPARATOR__) + 
			QString (onlyFileName (iF.toStdString ()).c_str ())).toStdString ());
		if (!isValidDir) result &= false;
		_resumeFileTF -> setPixmap (QPixmap (isValidDir ? 
			":/VSWAdvancedEditor/Resources/Ok.png" : ":/VSWAdvancedEditor/Resources/Error.png"));
		if (isValidDir &&  defFile.exists ()) // Being valid, the implementation file already exists...
			_resumeFileTF -> setPixmap (QPixmap (":/VSWAdvancedEditor/Resources/Warning.png"));
	}
		
	return (result);
}