void RGraphicsSceneQt::exportRectangle(const RVector& p1, const RVector& p2) { if (getEntity() == NULL && !exportToPreview) { qWarning("RGraphicsSceneQt::exportRectangle: entity is NULL"); return; } RPainterPath p; p.setZLevel(0); p.setPen(currentPen); p.setBrush(currentBrush); RVector v = RVector::getMinimum(p1, p2); p.addRect(v.x, v.y, fabs(p2.x - p1.x), fabs(p2.y - p1.y)); if (!exportToPreview) { if (draftMode) { addPath(getBlockRefOrEntity()->getId(), p, true); } else { addPath(getBlockRefOrEntity()->getId(), p, false); } } else { addToPreview(p); } }
void ResourceFinder::includeHomeDir(const char* filename) { #ifdef _WIN32 // %AppData%/Aseprite/filename wchar_t* env = _wgetenv(L"AppData"); if (env) { std::string path = base::join_path(base::to_utf8(env), "Aseprite"); path = base::join_path(path, filename); addPath(path); m_default = path; } #else char* env = std::getenv("HOME"); char buf[4096]; if ((env) && (*env)) { // $HOME/filename sprintf(buf, "%s/%s", env, filename); addPath(buf); } else { LOG("You don't have set $HOME variable\n"); addPath(filename); } #endif }
void ResourceFinder::includeDesktopDir(const char* filename) { #ifdef _WIN32 std::vector<wchar_t> buf(MAX_PATH); HRESULT hr = SHGetFolderPath(NULL, CSIDL_DESKTOPDIRECTORY, NULL, SHGFP_TYPE_DEFAULT, &buf[0]); if (hr == S_OK) { addPath(base::join_path(base::to_utf8(&buf[0]), filename)); } else { includeHomeDir(filename); } #elif defined(__APPLE__) // TODO get the desktop folder // $HOME/Desktop/filename includeHomeDir(base::join_path(std::string("Desktop"), filename).c_str()); #else char* desktopDir = std::getenv("XDG_DESKTOP_DIR"); if (desktopDir) { // $XDG_DESKTOP_DIR/filename addPath(base::join_path(desktopDir, filename)); } else { // $HOME/Desktop/filename includeHomeDir(base::join_path(std::string("Desktop"), filename).c_str()); } #endif }
void ResourceFinder::findInHomeDir(const char* filename) { #if defined ALLEGRO_UNIX || defined ALLEGRO_MACOSX char *env = getenv("HOME"); char buf[1024]; if ((env) && (*env)) { // $HOME/filename sprintf(buf, "%s/%s", env, filename); addPath(buf); } else { PRINTF("You don't have set $HOME variable\n"); addPath(filename); } #elif defined ALLEGRO_WINDOWS || defined ALLEGRO_DOS // $PREFIX/data/filename findInDataDir(filename); #else // filename addPath(filename); #endif }
std::string Util::addPath( std::string path1, std::string path2 ) { if ( path1.substr( path1.size() - 1, 1 ) == "/" ) { return addPath( path1.substr( 1, path1.size() - 1 ), path2 ); } else if ( path2.substr( 0, 1 ) == "/" ) { return addPath( path1, path2.substr( 1, path2.size() - 1 ) ); } else { return path1 + "/" + path2; } }
void PythonModule::initialize() throw (VoreenException) { VoreenModule::initialize(); // // Initialize Python interpreter // LINFO("Python version: " << Py_GetVersion()); // Pass program name to the Python interpreter char str_pyvoreen[] = "PyVoreen"; Py_SetProgramName(str_pyvoreen); // Initialize the Python interpreter. Required. Py_InitializeEx(false); if (!Py_IsInitialized()) throw VoreenException("Failed to initialize Python interpreter"); // required in order to use threads. PyEval_InitThreads(); // init ResourceManager search path addPath(""); addPath(VoreenApplication::app()->getScriptPath()); addPath(VoreenApplication::app()->getModulePath("python/scripts")); // init Python's internal module search path addModulePath(VoreenApplication::app()->getScriptPath()); addModulePath(VoreenApplication::app()->getModulePath("python/scripts")); // // Redirect script output from std::cout to voreen_print function (see above) // // import helper module if (!Py_InitModule("voreen_internal", internal_methods)) { LWARNING("Failed to init helper module 'voreen_internal'"); } // load output redirector script and run it once std::string filename = "outputcatcher.py"; LDEBUG("Loading Python init script '" << filename << "'"); PythonScript* initScript = load(filename); if (initScript) { if (!initScript->run()) LWARNING("Failed to run init script '" << filename << "': " << initScript->getLog()); dispose(initScript); } else { LWARNING("Failed to load init script '" << filename << "'"); } // // Create actual Voreen Python bindings // pyVoreen_ = new PyVoreen(); }
void ScanFoldersModel::configure() { const QVariantHash dirs = Preferences::instance()->getScanDirs(); for (QVariantHash::const_iterator i = dirs.begin(), e = dirs.end(); i != e; ++i) { if (i.value().type() == QVariant::Int) addPath(i.key(), static_cast<PathType>(i.value().toInt()), QString()); else addPath(i.key(), CUSTOM_LOCATION, i.value().toString()); } }
void FolderMonitor::FolderWatchInfo::startMonitor() { addPath(folderToMonitor); if(monitorSubdirectories) { FileSystem::iterate(folderToMonitor, nullptr, [this](const Path& path) { addPath(path); return true; }); } }
void GraphEstimator::findPath(size_t v) { // std::cout << "Start searching from " << v << std::endl; if (cur_path_.size() > amount_ + 1) { // std::cout << "Path too long" << std::endl; return; } if (v == dst_) { used_.insert(v); cur_path_.push_back(v); // std::cout << "Path found" << std::endl; addPath(); cur_path_.pop_back(); used_.erase(v); return; } cur_path_.push_back(v); used_.insert(v); const std::vector<pair_ud>& neigh = adj_[v]; for (size_t i = 0; i < neigh.size(); ++i) if (used_.find(neigh[i].first) == used_.end()) { findPath(neigh[i].first); } cur_path_.pop_back(); used_.erase(v); // std::cout << "Paths from " << v << " processed" << std::endl; }
int ZipReader::addPath(const Path &p, ZipEntry entry) { auto iter = _pathToEntry.find(p); if (iter == _pathToEntry.end()) { int index = _entries.size(); _pathToEntry.insert(std::make_pair(p, index)); _entries.emplace_back(std::move(entry)); if (p != ".") { Path parent = p.parent().stripSeparator(); if (parent.empty()) parent = "."; ZipEntry parentEntry; parentEntry.fullPath = parent; parentEntry.name = parent.fileName(); parentEntry.size = 0; parentEntry.isDirectory = true; parentEntry.archiveIndex = -1; _entries[addPath(parent, std::move(parentEntry))].contents.push_back(index); } return index; } else { return iter->second; } }
SSLManager::SSLManager(QWidget* parent) : QDialog(parent) , ui(new Ui::SSLManager) { setAttribute(Qt::WA_DeleteOnClose); ui->setupUi(this); refreshLocalList(); refreshCAList(); refreshPaths(); connect(ui->caList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(showCaCertInfo())); connect(ui->caInfoButton, SIGNAL(clicked()), this, SLOT(showCaCertInfo())); connect(ui->deleteButton, SIGNAL(clicked()), this, SLOT(deleteCertificate())); connect(ui->localList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(showLocalCertInfo())); connect(ui->localInfoButton, SIGNAL(clicked()), this, SLOT(showLocalCertInfo())); connect(ui->addLocalCert, SIGNAL(clicked()), this, SLOT(addLocalCertificate())); connect(ui->addPath, SIGNAL(clicked()), this, SLOT(addPath())); connect(ui->deletePath, SIGNAL(clicked()), this, SLOT(deletePath())); connect(ui->ignoreAll, SIGNAL(clicked(bool)), this, SLOT(ignoreAll(bool))); connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(close())); ui->ignoreAll->setChecked(mApp->networkManager()->isIgnoringAllWarnings()); }
std::shared_ptr<EnvironmentNode> EnvironmentMgr::addNewEnvironmentNode(const std::shared_ptr<EnvironmentNode> &pParentNode, const std::shared_ptr<SchemaItem> &pNewCfgItem, Status &status) { std::shared_ptr<EnvironmentNode> pNewNode; // // Create the new node and add it to the parent pNewNode = std::make_shared<EnvironmentNode>(pNewCfgItem, pNewCfgItem->getProperty("name"), pParentNode); pNewNode->setId(getUniqueKey()); pParentNode->addChild(pNewNode); addPath(pNewNode); pNewNode->initialize(); // // Look through the children and add any that are necessary std::vector<std::shared_ptr<SchemaItem>> cfgChildren; pNewCfgItem->getChildren(cfgChildren); for (auto childIt = cfgChildren.begin(); childIt != cfgChildren.end(); ++childIt) { int numReq = (*childIt)->getMinInstances(); for (int i=0; i<numReq; ++i) { addNewEnvironmentNode(pNewNode, *childIt, status); } } return pNewNode; }
ZipReader::ZipReader(const Path &p) : _path(p), _in(FileUtils::openInputStream(p)) { if (!_in) FAIL("Failed to construct ZipReader: Input stream is invalid"); uint64 size = FileUtils::fileSize(p); if (size == 0) FAIL("Failed to construct ZipReader: Error reading file size"); std::memset(&_archive, 0, sizeof(mz_zip_archive)); _archive.m_pRead = &minizFileReadFunc; _archive.m_pIO_opaque = _in.get(); if (!mz_zip_reader_init(&_archive, size, 0)) FAIL("Initializing zip reader failed"); int count = mz_zip_reader_get_num_files(&_archive); for (int i = 0; i < count; ++i) { mz_zip_archive_file_stat stat; mz_zip_reader_file_stat(&_archive, i, &stat); ZipEntry entry; entry.fullPath = Path(stat.m_filename); entry.name = entry.fullPath.fileName(); entry.size = stat.m_uncomp_size; entry.isDirectory = !entry.fullPath.empty() && entry.fullPath.asString().back() == '/'; entry.archiveIndex = i; addPath(Path(stat.m_filename).stripSeparator(), std::move(entry)); } }
void GameTracker::AddDirectory(const QString& dir) { if (!QFileInfo(dir).exists()) return; addPath(dir); UpdateDirectory(dir); }
void AnimatorScene::setShowNodeTrajectory (AnimNode *animNode) { uint32_t nodeId = animNode->getNodeId (); if (m_nodeTrajectory.find (nodeId) == m_nodeTrajectory.end ()) { QPainterPath path; AnimNodeMgr::TimePosVector_t positions = AnimNodeMgr::getInstance ()->getPositions (animNode->getNodeId ()); for (AnimNodeMgr::TimePosVector_t::const_iterator i = positions.begin (); i != positions.end (); ++i) { TimePosition_t tp = *i; QPointF pt = tp.p; path.moveTo (pt); break; } positions = AnimNodeMgr::getInstance ()->getPositions (animNode->getNodeId ()); for (AnimNodeMgr::TimePosVector_t::const_iterator i = positions.begin (); i != positions.end (); ++i) { TimePosition_t tp = *i; QPointF pt = tp.p; path.lineTo (pt); } QGraphicsPathItem * pathItem = addPath (path); m_nodeTrajectory[nodeId] = pathItem; } m_nodeTrajectory[nodeId]->setVisible (animNode->getShowNodeTrajectory ()); }
PathsManagementWidget::PathsManagementWidget(QWidget* Parent): QWidget(Parent),ui(new Ui::PathsManagementWidget), m_AllowEmpty(true) { ui->setupUi(this); ui->AddButton->setText(""); ui->AddButton->setIcon(QIcon(":/ui/common/icons/add.png")); ui->AddButton->setIconSize(QSize(20,20)); ui->RemoveButton->setText(""); ui->RemoveButton->setIcon(QIcon(":/ui/common/icons/remove.png")); ui->RemoveButton->setIconSize(QSize(20,20)); ui->UpButton->setText(""); ui->UpButton->setIcon(QIcon(":/ui/common/icons/go-up.png")); ui->UpButton->setIconSize(QSize(20,20)); ui->DownButton->setText(""); ui->DownButton->setIcon(QIcon(":/ui/common/icons/go-down.png")); ui->DownButton->setIconSize(QSize(20,20)); connect(ui->AddButton,SIGNAL(clicked()),this,SLOT(addPath())); connect(ui->RemoveButton,SIGNAL(clicked()),this,SLOT(removePath())); connect(ui->UpButton,SIGNAL(clicked()),this,SLOT(moveupPath())); connect(ui->DownButton,SIGNAL(clicked()),this,SLOT(movedownPath())); }
void AutoUpdateManager::watchCachedFile(const Account& account, const QString& repo_id, const QString& path) { QString local_path = DataManager::getLocalCacheFilePath(repo_id, path); qDebug("[AutoUpdateManager] watch cache file %s", local_path.toUtf8().data()); if (!QFileInfo(local_path).exists()) { qWarning("[AutoUpdateManager] unable to watch non-existent cache file %s", local_path.toUtf8().data()); return; } // do we have it in deferred list ? // skip if yes Q_FOREACH(const WatchedFileInfo& info, deleted_files_infos_) { if (repo_id == info.repo_id && path == info.path_in_repo) return; } Q_FOREACH(const WatchedFileInfo& info, watch_infos_) { if (repo_id == info.repo_id && path == info.path_in_repo) return; } addPath(&watcher_, local_path); QFileInfo finfo(local_path); watch_infos_[local_path] = WatchedFileInfo(account, repo_id, path, finfo.lastModified().toMSecsSinceEpoch(), finfo.size()); }
bool FileList::addDirectory(const UString &base, const boost::filesystem::path &directory, int recurseDepth) { if (!exists(directory) || !is_directory(directory)) // Path is either no directory or doesn't exist return false; try { // Iterator over the directory's contents directory_iterator itEnd; for (directory_iterator itDir(directory); itDir != itEnd; ++itDir) { if (is_directory(itDir->status())) { // It's a directory. Recurse into it if the depth limit wasn't yet reached if (recurseDepth != 0) if (!addDirectory(base, itDir->path(), (recurseDepth == -1) ? -1 : (recurseDepth - 1))) return false; } else // It's a path, add it to the list addPath(base, itDir->path()); } } catch (...) { return false; } return true; }
QModelIndex QDBusModel::findObject(const QDBusObjectPath &objectPath) { QStringList path = objectPath.path().split(QLatin1Char('/'), QString::SkipEmptyParts); QDBusItem *item = root; int childIdx = -1; while (item && !path.isEmpty()) { const QString branch = path.takeFirst() + QLatin1Char('/'); childIdx = -1; // do a linear search over all the children for (int i = 0; i < item->children.count(); ++i) { QDBusItem *child = item->children.at(i); if (child->type == PathItem && child->name == branch) { item = child; childIdx = i; // prefetch the found branch if (!item->isPrefetched) addPath(item); break; } } // branch not found - bail out if (childIdx == -1) return QModelIndex(); } // found the right item if (childIdx != -1 && item && path.isEmpty()) return createIndex(childIdx, 0, item); return QModelIndex(); }
void ShortRange::addPath(const int site1, const int site2, const double strength, const double* Lab_3x3, const double sig_dot_sig_pow) { if(strength != 0) { if(num + 1 >= size) { if(size > 1024*1024) size = size + 1024*1024; else { if(size == 0) { size = 32; } else size *= 8; } // size *= 32; // size++; pathways = (sss*)realloc(pathways, sizeof(sss) * size); addPath(site1, site2, strength, Lab_3x3, sig_dot_sig_pow); return; } pathways[num].fromsite = site1; pathways[num].tosite = site2; pathways[num].strength = strength; memcpy(pathways[num].matrix, Lab_3x3, sizeof(double)*9); pathways[num].sig_dot_sig_pow = sig_dot_sig_pow; num++; } }
void RGraphicsSceneQt::exportTriangle(const RTriangle& triangle) { if (getEntity() == NULL && !exportToPreview) { qWarning("RGraphicsSceneQt::exportTriangle: entity is NULL"); return; } // add new painter path with current entity ID: RPainterPath p; p.setZLevel(0); if (draftMode || screenBasedLinetypes) { QPen draftPen = currentPen; draftPen.setWidth(0); p.setPen(draftPen); } else { p.setPen(currentPen); } p.setBrush(currentBrush); p.moveTo(triangle.corner[0]); p.lineTo(triangle.corner[1]); p.lineTo(triangle.corner[2]); p.lineTo(triangle.corner[0]); if (!exportToPreview) { addPath(getBlockRefOrEntity()->getId(), p, draftMode); } else { addToPreview(p); } }
void RGraphicsSceneQt::endPath() { // give entity export listeners a chance to decorate entity: // REntity* entity = getEntity(); // if (entity!=NULL && entity->hasCustomProperties()) { // if (RMainWindow::hasMainWindow()) { // RMainWindow* appWin = RMainWindow::getMainWindow(); // // TODO: start separate path: // appWin->notifyEntityExportListeners(this, entity); // } // } if (!exportToPreview) { if (!currentPainterPath.isEmpty()) { // REntity* entity = getEntity(); // if (entity->getColor().isByBlock() || // entity->getLinetypeId()==document->getLinetypeByBlockId() || // entity->getLineweight()==RLineweight::WeightByBlock) { // entities which are part of a block and have attributes ByBlock are exported to block ref ID: addPath(getBlockRefOrEntity()->getId(), currentPainterPath, false); // } // else { // // entities which are part of a block and have NO attributes ByBlock are exported to entity ID: // if (!painterPaths.contains(getEntity()->getId())) { // addPath(getEntity()->getId(), currentPainterPath, false); // } // } } } else { addToPreview(currentPainterPath); } currentPainterPath.setValid(false); //setSelectedMode(false); }
void ResourceFinder::findInDocsDir(const char* filename) { char buf[1024]; #if defined ALLEGRO_UNIX || defined ALLEGRO_MACOSX // $BINDIR/docs/filename sprintf(buf, "docs/%s", filename); findInBinDir(buf); // $BINDIR/../share/aseprite/docs/filename sprintf(buf, "../share/aseprite/docs/%s", filename); findInBinDir(buf); #ifdef ALLEGRO_MACOSX // $BINDIR/aseprite.app/Contents/Resources/docs/filename sprintf(buf, "aseprite.app/Contents/Resources/docs/%s", filename); findInBinDir(buf); #endif #elif defined ALLEGRO_WINDOWS || defined ALLEGRO_DOS // $BINDIR/docs/filename sprintf(buf, "docs/%s", filename); findInBinDir(buf); #else // filename addPath(filename); #endif }
// Simple case of above- get ground delta at given position in unit range void TSShapeInstance::deltaGround1(TSThread * thread, F32 start, F32 end, MatrixF& mat) { mat.identity(); if (thread->transitionData.inTransition) return; addPath(thread, start, end, &mat); }
void RGraphicsSceneQt::exportPainterPaths(const QList<RPainterPath>& paths) { if (getEntity() == NULL && !exportToPreview) { qWarning("RGraphicsSceneQt::exportPainterPaths: entity is NULL"); return; } RPainterPath path; for (int i=0; i<paths.size(); i++) { path = paths.at(i); path.setZLevel(0); path.setBrush(getBrush(path)); if (path.getInheritPen()) { path.setPen(currentPainterPath.getPen()); } else { path.setPen(getPen(path)); } if (!exportToPreview) { // export into current path (used for complex linetypes): if (currentPainterPath.isValid()) { currentPainterPath.addPath(path); } else { addPath(getBlockRefOrEntity()->getId(), path, draftMode); } } else { addToPreview(path); } } }
void ResourceFinder::includeUserDir(const char* filename) { #ifdef _WIN32 if (App::instance()->isPortable()) { // $BINDIR/filename includeBinDir(filename); } else { // %AppData%/Aseprite/filename includeHomeDir(filename); } #elif __APPLE__ // $HOME/Library/Application Support/Aseprite/filename addPath( base::join_path( base::join_path(base::get_lib_app_support_path(), PACKAGE), filename).c_str()); #else // $HOME/.config/aseprite/filename includeHomeDir((std::string(".config/aseprite/") + filename).c_str()); #endif }
void WPainterPath::connectPath(const WPainterPath& path) { if (currentPosition() != path.beginPosition()) lineTo(path.beginPosition()); addPath(path); }
KIconLoader::KIconLoader( KConfig *conf, const QString &app_name, const QString &var_name ){ QStrList list; config = conf; config->setGroup(app_name); config->readListEntry( var_name, list, ':' ); for (const char *it=list.first(); it; it = list.next()) addPath(it); initPath(); name_list.setAutoDelete(TRUE); pixmap_dirs.setAutoDelete(TRUE); pixmap_list.setAutoDelete(TRUE); /* for(char* c = pixmap_dirs.first(); c ; c = pixmap_dirs.next()){ printf("in path:%s\n",pixmap_dirs.current()); } */ }
void Cache::addPath(Socket *socket, const QString &target) { KUrl url = socket->getCurrentUrl(); url.setPath(socket->getCurrentDirectory()); addPath(url, target); }
KCMCgi::KCMCgi(QWidget *parent, const char *name) : KCModule(parent, name) { setButtons(Default|Apply); QVBoxLayout *topLayout = new QVBoxLayout(this, 0, KDialog::spacingHint()); QGroupBox *topBox = new QGroupBox( 1, Horizontal, i18n("Paths to Local CGI Programs"), this ); topLayout->addWidget( topBox ); mListBox = new QListBox( topBox ); QHBox *buttonBox = new QHBox( topBox ); buttonBox->setSpacing( KDialog::spacingHint() ); mAddButton = new QPushButton( i18n("Add..."), buttonBox ); connect( mAddButton, SIGNAL( clicked() ), SLOT( addPath() ) ); mRemoveButton = new QPushButton( i18n("Remove"), buttonBox ); connect( mRemoveButton, SIGNAL( clicked() ), SLOT( removePath() ) ); connect( mListBox, SIGNAL( clicked ( QListBoxItem * )),this, SLOT( slotItemSelected( QListBoxItem *))); mConfig = new KConfig("kcmcgirc"); load(); updateButton(); KAboutData *about = new KAboutData( I18N_NOOP("kcmcgi"), I18N_NOOP("CGI KIO Slave Control Module"), 0, 0, KAboutData::License_GPL, I18N_NOOP("(c) 2002 Cornelius Schumacher") ); about->addAuthor( "Cornelius Schumacher", 0, "*****@*****.**" ); setAboutData(about); }