Exemplo n.º 1
0
bool Task::AddTemplate(const QString &template_path)
{
	Template *t = new Template();
	if (t && t->Initialize(template_path)) {
		return AddTemplate(t);
	} else {
		return false;
	}
}
Exemplo n.º 2
0
//=============================================================================
// 生成
//=============================================================================
bool Template::Create(Template** outPointer)
{
	Template* pointer = new Template();
	if(!pointer->Initialize())
		return false;

	*outPointer = pointer;
	return true;
}
Exemplo n.º 3
0
bool Task::Open(const QString &task_file)
{
	Close();
	QFile file(task_file);
	if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
		QXmlStreamReader xml(&file);
		while(xml.readNextStartElement()) {
			if (xml.name() == "Task") {
				name = xml.attributes().value("Name").toString();
				description = xml.attributes().value("Description").toString();
				creation_time = xml.attributes().value("Timestamp").toString();
				directory = QFileInfo(task_file).absolutePath();
				res_directory = directory + "/" + TASK_RESOURCES_DIRECTORY;
			} else if (xml.name() == "Template") {
				QString template_path = xml.attributes().value("Path").toString();
				Template *t = new Template();
				if (!t) {
					Close();
					return false;
				} 
				if (t->Initialize(template_path)) {
					templates.push_back(t);
					while(xml.readNextStartElement()) {
						if (xml.name() == "Section") {
							QString section_name = xml.attributes().value("Name").toString();
							while(xml.readNextStartElement()) {
								if (xml.name() == "Picture") {
									QString picture_name = xml.attributes().value("Name").toString();
									t->AddPicture(section_name, picture_name);
								} 
								xml.skipCurrentElement();
							}
						} else {
							xml.skipCurrentElement();
						}
					}
				} else {
					xml.skipCurrentElement();
				}
			} else {
				xml.skipCurrentElement();
			}
		}
		return true;
	}
	return false;
}