/** Construit un projet a partir du chemin d'un fichier. @param path Chemin du fichier @param parent QObject parent */ QETProject::QETProject(const QString &path, QObject *parent) : QObject(parent), collection_(0), project_qet_version_(-1), modified_(false), read_only_(false), titleblocks_(this) { // ouvre le fichier QFile project_file(path); if (!project_file.open(QIODevice::ReadOnly | QIODevice::Text)) { state_ = FileOpenFailed; return; } setFilePath(path); // en extrait le contenu XML bool xml_parsing = document_root_.setContent(&project_file); if (!xml_parsing) { state_ = XmlParsingFailed; return; } // et construit le projet readProjectXml(); setupTitleBlockTemplatesCollection(); // passe le projet en lecture seule si le fichier l'est QFileInfo project_file_info(path); if (!project_file_info.isWritable()) { setReadOnly(true); } }
void OutOfMemoryDialog::saveProjectAs() { // XXX: this function is duplicated MainWindow QString project_dir; if (!m_projectFile.isEmpty()) { project_dir = QFileInfo(m_projectFile).absolutePath(); } else { QSettings settings; project_dir = settings.value("project/lastDir").toString(); } QString project_file( QFileDialog::getSaveFileName( this, QString(), project_dir, tr("Scan Tailor Projects")+" (*.ScanTailor)" ) ); if (project_file.isEmpty()) { return; } if (!project_file.endsWith(".ScanTailor", Qt::CaseInsensitive)) { project_file += ".ScanTailor"; } if (saveProjectWithFeedback(project_file)) { m_projectFile = project_file; showSaveSuccessScreen(); QSettings settings; settings.setValue( "project/lastDir", QFileInfo(m_projectFile).absolutePath() ); RecentProjects rp; rp.read(); rp.setMostRecent(m_projectFile); rp.write(); } }
/** Construit un projet a partir du chemin d'un fichier. @param path Chemin du fichier @param parent QObject parent */ QETProject::QETProject(const QString &path, QObject *parent) : QObject (parent), collection_ (0 ), project_qet_version_ (-1 ), modified_ (false ), read_only_ (false ), titleblocks_ (this ), folioSheetsQuantity (0 ), m_auto_conductor (true ) { // ouvre le fichier QFile project_file(path); if (!project_file.open(QIODevice::ReadOnly | QIODevice::Text)) { state_ = FileOpenFailed; return; } setFilePath(path); // en extrait le contenu XML bool xml_parsing = document_root_.setContent(&project_file); if (!xml_parsing) { state_ = XmlParsingFailed; return; } // et construit le projet readProjectXml(); setupTitleBlockTemplatesCollection(); // passe le projet en lecture seule si le fichier l'est QFileInfo project_file_info(path); if (!project_file_info.isWritable()) { setReadOnly(true); } undo_stack_ = new QUndoStack(); connect(undo_stack_, SIGNAL(cleanChanged(bool)), this, SLOT(undoStackChanged(bool))); }
void gen_vc_project(const Project &project, const Workspace &workspace) { std::list<std::string> options_list, defines_list, targets, inc_dir, lib_dir; std::string filename = "Sources/" + project.libname + ".cbp"; std::cout << " Generating project " << filename << "... "; std::ofstream project_file(filename.c_str()); gen_project_head(project_file); inc_dir.push_back("."); inc_dir.push_back(workspace.input_include_dir); lib_dir.push_back(workspace.input_lib_dir); // project title. project_file << "\t\t<Option title=\"" << project.libname << "\"/>\n"; // compiler to use. project_file << "\t\t<Option compiler=\"1\"/>\n"; project_file << "\t\t<Build>\n"; // compile target: release project_file << "\t\t\t<Target title=\"Release\">\n"; project_file << "\t\t\t\t<Option output=\"" << workspace.output_lib_dir << "/" << project.libname << ".lib\"/>\n"; project_file << "\t\t\t\t<Option working_dir=\"\"/>\n"; project_file << "\t\t\t\t<Option object_output=\"Release/" << project.libname << "\"/>\n"; project_file << "\t\t\t\t<Option deps_output=\".deps\"/>\n"; project_file << "\t\t\t\t<Option external_deps=\"\"/>\n"; project_file << "\t\t\t\t<Option type=\"2\"/>\n"; project_file << "\t\t\t\t<Option compiler=\"1\"/>\n"; project_file << "\t\t\t\t<Option projectResourceIncludeDirsRelation=\"1\"/>\n"; // generate compiler options options_list.push_back("MT"); options_list.push_back("nologo"); options_list.push_back("W3"); options_list.push_back("GR"); options_list.push_back("GX"); options_list.push_back("Zi"); options_list.push_back("O2"); options_list.push_back("YX"); options_list.push_back("FD"); options_list.push_back("c"); defines_list = project.defines_list; defines_list.push_back("WIN32"); defines_list.push_back("NDEBUG"); defines_list.push_back("_WINDOWS"); gen_compiler_options(project_file, options_list, defines_list, inc_dir); // generate linker options options_list.clear(); options_list.push_back("nologo"); gen_linker_options(project_file, options_list, lib_dir); project_file << "\t\t\t</Target>\n"; // compile target: debug project_file << "\t\t\t<Target title=\"Debug\">\n"; project_file << "\t\t\t\t<Option output=\"" << workspace.output_lib_dir << "/" << project.libname << "d.lib\"/>\n"; project_file << "\t\t\t\t<Option working_dir=\"\"/>\n"; project_file << "\t\t\t\t<Option object_output=\"Debug/" << project.libname << "\"/>\n"; project_file << "\t\t\t\t<Option deps_output=\".deps\"/>\n"; project_file << "\t\t\t\t<Option external_deps=\"\"/>\n"; project_file << "\t\t\t\t<Option type=\"2\"/>\n"; project_file << "\t\t\t\t<Option compiler=\"1\"/>\n"; project_file << "\t\t\t\t<Option projectResourceIncludeDirsRelation=\"1\"/>\n"; // generate compiler options options_list.clear(); options_list.push_back("MTd"); options_list.push_back("nologo"); options_list.push_back("W3"); options_list.push_back("Gm"); options_list.push_back("GR"); options_list.push_back("GX"); options_list.push_back("Zi"); options_list.push_back("Od"); options_list.push_back("YX"); options_list.push_back("FD"); options_list.push_back("GZ"); options_list.push_back("c"); defines_list = project.defines_list; defines_list.push_back("WIN32"); defines_list.push_back("_DEBUG"); defines_list.push_back("NDEBUG"); defines_list.push_back("_WINDOWS"); gen_compiler_options(project_file, options_list, defines_list, inc_dir); // generate linker options options_list.clear(); options_list.push_back("nologo"); gen_linker_options(project_file, options_list, lib_dir); project_file << "\t\t\t</Target>\n"; project_file << "\t\t</Build>\n"; project_file << "\t\t<ExtraCommands>\n"; project_file << "\t\t\t<Add after=\"install_" << project.libname << ".bat\"/>\n"; project_file << "\t\t</ExtraCommands>\n"; targets.push_back("Release"); targets.push_back("Debug"); #ifdef __BORLANDC__ gen_file_units(project_file, "Sources", project.file_paths, targets); #else gen_file_units(project_file, "Sources", project.files, targets); #endif gen_project_foot(project_file); std::cout << "done." << std::endl; std::cout << " Generating install script... "; gen_vc_install_bat(project, workspace); std::cout << "done." << std::endl; }