/** * @brief Project::save */ void Project::save() { Q_ASSERT(!!m_Database); m_Errors.clear(); if (!m_Path.isEmpty()) { QDir dir(m_Path); if (!dir.exists()) if (!dir.mkpath(m_Path)) { m_Errors << tr("Cannot create project directory."); emit errors(tr("Make path error%1").arg(m_Errors.count() <= 1 ? "" : "s"), m_Errors); return; } if (!utility::writeToFile(*this, projectPath(m_Path))) m_Errors << tr("Cannot save project to file."); m_Database->setName(databaseFileName()); m_Database->setPath(m_Path); if (!m_Database->save()) m_Errors << tr("Cannot save database to file."); } else { m_Errors << "Project path is empty."; } setSaveStatus(m_Errors.isEmpty()); if (!m_Errors.isEmpty()) emit errors(tr("Project save error%1").arg(m_Errors.count() <= 1 ? "" : "s"), m_Errors); }
/** * @brief Project::load * @param path */ void Project::load(const QString &path) { Q_ASSERT(!!m_Database); m_Errors.clear(); if (!utility::readFromFile(*this, path)) m_Errors << tr("Cannot read project file."); if (m_Path != path) m_Path = QFileInfo(path).absolutePath(); m_Database->setPath(m_Path); m_Database->setName(databaseFileName()); m_Database->load(m_Errors); setSaveStatus(m_Errors.isEmpty()); for (auto &&scope : m_Database->scopes()) for (auto &&entity : scope->types()) connect(entity.get(), &entity::BasicEntity::nameChanged, this, &Project::touch); if (!m_Errors.isEmpty()) errors(tr("Project load error%1").arg(m_Errors.count() <= 1 ? "" : "s"), m_Errors); }
wxSQLite3ResultSet TagsDatabase::SelectTagsByFile(const wxString& file, const wxFileName& path) { // Incase empty file path is provided, use the current file name wxFileName databaseFileName(path); path.IsOk() == false ? databaseFileName = m_fileName : databaseFileName = path; OpenDatabase(databaseFileName); wxString query; query = wxString::Format(_T("select * from tags where file='%s';"), file.GetData()); return m_db->ExecuteQuery(query.GetData()); }