bool Database::removeProject(const SProject * project) { QDomDocument doc = loadDataBase(); QDomElement docElem = doc.documentElement(); QDomNode n = docElem.firstChild(); while (!n.isNull()) { QDomElement e = n.toElement(); if (!e.isNull()) { if (e.attribute("name") == project->projectName()) docElem.removeChild(n); } n = n.nextSibling(); } QFile file(m_dbfile); if (file.open(QIODevice::WriteOnly| QIODevice::Text)) { QTextStream ts(&file); ts << doc.toString(); file.close(); } else { return false; } return true; }
void startDialog::on_Compile_clicked() { ClearLog(); if (!loadDataBase()) { nd_logerror("load database error\n"); } if (false == compile()){ WriteLog("compile script error"); return; } WriteLog("=========compile script success===========\n"); const char *packaged_cmd = _getFromIocfg("compiled_rum_cmd"); if (packaged_cmd && *packaged_cmd) { int ret = system(packaged_cmd); if (0 != ret) { nd_logerror("run command error %s %d\n", packaged_cmd, ret); } } }
bool Database::addProject(const SProject * project) { QDomDocument db = loadDataBase(); QDomNode root = db.firstChild(); root.appendChild(project->infoToXml(db)); QFile file(m_dbfile); if (file.open(QIODevice::WriteOnly| QIODevice::Text)) { QTextStream ts(&file); ts << db.toString(); file.close(); } else { return false; } return true; }
void startDialog::on_ScriptEdit_clicked() { EditorFrame *pMain = new EditorFrame(); pMain->setHostWidget(this); pMain->setAttribute(Qt::WA_DeleteOnClose, true); if (!loadDataBase()) { nd_logerror("load database error\n"); } std::string defProj = getPathFromConfig("script_root"); if (!defProj.empty() && pMain->myInit(defProj.c_str() )) { this->setVisible(false); pMain->showMaximized(); } else { delete pMain; } }
void Database::setDBFile(const QString& dbfile) { m_dbfile = dbfile; loadDataBase(); }
Database::Database(const QString &dbfile): m_dbfile(dbfile) { loadDataBase(); }
SProject *Database::loadProject(const QString &projectName) { Parsers::DatabaseParser parser; return parser.loadProject( projectName, loadDataBase().toString()); }
bool Database::exists(const QString &projectName) { Parsers::DatabaseParser parser; return parser.exists(projectName, loadDataBase().toString()); }
Database::ProjectInfo Database::projectInfo(const QString &project) { Parsers::DatabaseParser parser; return parser.projectInfo(project, loadDataBase().toString()); }
QList< Database::ProjectInfo> Database::userProjects(const QString& user) { Parsers::DatabaseParser parser; return parser.userProjects(user, loadDataBase().toString()); }
QList<Database::ProjectInfo> Database::allProjects() { Parsers::DatabaseParser parser; return parser.allProjects(loadDataBase().toString()); }