ScriptItem::ScriptItem(const openstudio::path& path, OSItemType type, QWidget * parent) : OSItem(scriptToItemId(path), type, parent), m_removed(false), m_scriptInfo(path, true, false) { setText(openstudio::toQString(path.filename())); setLeftPixmap(QPixmap(":/images/icon_scripts.png")); if (boost::regex_search(toString(itemId().sourceId()),boost::regex("resource"))) { m_scriptInfo.isUserScript = false; } else { try { m_scriptInfo = runmanager::RubyJobBuilder::updateArgumentsFromDb(m_scriptInfo); } catch (const runmanager::ScriptDetectionError &e) { // Nothing to display here in the constructor m_scriptInfo = e.scriptInfo; } } std::shared_ptr<OSDocument> osDoc = OSAppBase::instance()->currentDocument(); connect(this, &ScriptItem::argChanged, osDoc.get(), &OSDocument::markAsModified); }
void ScriptsVectorController::directoryChanged(const QString &t_path) { StringVector extsToIgnore; extsToIgnore.push_back("osp"); extsToIgnore.push_back("osp-journal"); extsToIgnore.push_back("db"); extsToIgnore.push_back("db-journal"); StringVector::const_iterator extsToIgnoreBegin = extsToIgnore.begin(); StringVector::const_iterator extsToIgnoreEnd = extsToIgnore.end(); openstudio::path path = openstudio::toPath(t_path); if (!m_fswatcher->directories().contains(toQString(m_path)) && boost::filesystem::exists(m_path)) { m_fswatcher->addPath(openstudio::toQString(m_path)); } if (!m_fswatcher->directories().contains(toQString(m_path.parent_path())) && boost::filesystem::exists(m_path.parent_path())) { m_fswatcher->addPath(openstudio::toQString(m_path.parent_path())); } if (path == m_path) { // ooh, it was us. QStringList files = QDir(openstudio::toQString(m_path)).entryList(QDir::Files, QDir::Name); std::vector<OSItemId> items; for (QStringList::const_iterator itr = files.begin(); itr != files.end(); ++itr) { openstudio::path filePath = openstudio::toPath(*itr); std::string ext = getFileExtension(filePath); if (std::find(extsToIgnoreBegin,extsToIgnoreEnd,ext) == extsToIgnoreEnd) { items.push_back(scriptToItemId(m_path / filePath)); } } m_items = items; std::reverse(m_items.begin(), m_items.end()); emit itemIds(m_items); } else { LOG(Debug, "No match for FS Path: " << openstudio::toString(path) << " " << openstudio::toString(m_path)); } }