ScanFoldersModel::PathStatus ScanFoldersModel::addPath(const QString &watchPath, const PathType &downloadType, const QString &downloadPath, bool addToFSWatcher) { QDir watchDir(watchPath); if (!watchDir.exists()) return DoesNotExist; if (!watchDir.isReadable()) return CannotRead; const QString &canonicalWatchPath = watchDir.canonicalPath(); if (findPathData(canonicalWatchPath) != -1) return AlreadyInList; QDir downloadDir(downloadPath); const QString &canonicalDownloadPath = downloadDir.canonicalPath(); if (!m_fsWatcher) { m_fsWatcher = new FileSystemWatcher(this); connect(m_fsWatcher, &FileSystemWatcher::torrentsAdded, this, &ScanFoldersModel::addTorrentsToSession); } beginInsertRows(QModelIndex(), rowCount(), rowCount()); m_pathList << new PathData(Utils::Fs::toNativePath(canonicalWatchPath), downloadType, Utils::Fs::toNativePath(canonicalDownloadPath)); endInsertRows(); // Start scanning if (addToFSWatcher) m_fsWatcher->addPath(canonicalWatchPath); return Ok; }
static void watchSubtree(int inotifyFd, char *path) { int cnt; cnt = watchDir(inotifyFd, path); logMessage(VB_BASIC, " watchSubtree: %s: %d entries added\n", path, cnt); }
void ScanFoldersModel::addToFSWatcher(const QStringList &watchPaths) { if (!m_fsWatcher) return; // addPath() wasn't called before this foreach (const QString &path, watchPaths) { QDir watchDir(path); const QString &canonicalWatchPath = watchDir.canonicalPath(); m_fsWatcher->addPath(canonicalWatchPath); }
ScanFoldersModel::PathStatus ScanFoldersModel::updatePath(const QString &watchPath, const PathType &downloadType, const QString &downloadPath) { QDir watchDir(watchPath); const QString &canonicalWatchPath = watchDir.canonicalPath(); int row = findPathData(canonicalWatchPath); if (row == -1) return DoesNotExist; QDir downloadDir(downloadPath); const QString &canonicalDownloadPath = downloadDir.canonicalPath(); m_pathList.at(row)->downloadType = downloadType; m_pathList.at(row)->downloadPath = Utils::Fs::toNativePath(canonicalDownloadPath); return Ok; }
Window::Window(int argc, char *argv[]) : QMainWindow(NULL), ui(new Ui::Window) { ui->setupUi(this); // Cache size cacheSize = 50; cachePos = 0; prefs = new Preferences(this); about = new AboutDialog(this); connect(prefs, SIGNAL(finished(int)), this, SLOT(updatePrefs())); initSlider(ui->xSlider); initSlider(ui->ySlider); initSlider(ui->zSlider); initSpanSlider(ui->xSpanSlider); initSpanSlider(ui->ySpanSlider); initSpanSlider(ui->zSpanSlider); // Rotation connect(ui->xSlider, SIGNAL(valueChanged(int)), ui->viewport, SLOT(setXRotation(int))); connect(ui->viewport, SIGNAL(xRotationChanged(int)), ui->xSlider, SLOT(setValue(int))); connect(ui->ySlider, SIGNAL(valueChanged(int)), ui->viewport, SLOT(setYRotation(int))); connect(ui->viewport, SIGNAL(yRotationChanged(int)), ui->ySlider, SLOT(setValue(int))); connect(ui->zSlider, SIGNAL(valueChanged(int)), ui->viewport, SLOT(setZRotation(int))); connect(ui->viewport, SIGNAL(zRotationChanged(int)), ui->zSlider, SLOT(setValue(int))); // Slicing connect(ui->xSpanSlider, SIGNAL(lowerValueChanged(int)), ui->viewport, SLOT(setXSliceLow(int))); connect(ui->xSpanSlider, SIGNAL(upperValueChanged(int)), ui->viewport, SLOT(setXSliceHigh(int))); connect(ui->ySpanSlider, SIGNAL(lowerValueChanged(int)), ui->viewport, SLOT(setYSliceLow(int))); connect(ui->ySpanSlider, SIGNAL(upperValueChanged(int)), ui->viewport, SLOT(setYSliceHigh(int))); connect(ui->zSpanSlider, SIGNAL(lowerValueChanged(int)), ui->viewport, SLOT(setZSliceLow(int))); connect(ui->zSpanSlider, SIGNAL(upperValueChanged(int)), ui->viewport, SLOT(setZSliceHigh(int))); ui->animSlider->setRange(0, 10); ui->animSlider->setSingleStep(1); ui->animSlider->setPageStep(10); ui->animSlider->setTickInterval(2); ui->animSlider->setTickPosition(QSlider::TicksRight); ui->animSlider->setEnabled(false); // Actions connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(openAbout())); connect(ui->actionPreferences, SIGNAL(triggered()), this, SLOT(openSettings())); connect(ui->actionFiles, SIGNAL(triggered()), this, SLOT(openFiles())); connect(ui->actionDir, SIGNAL(triggered()), this, SLOT(openDir())); connect(ui->actionCubes, SIGNAL(triggered()), this, SLOT(toggleDisplay())); connect(ui->actionCones, SIGNAL(triggered()), this, SLOT(toggleDisplay())); connect(ui->actionVectors, SIGNAL(triggered()), this, SLOT(toggleDisplay())); displayType = new QActionGroup(this); displayType->addAction(ui->actionCubes); displayType->addAction(ui->actionCones); displayType->addAction(ui->actionVectors); ui->actionCubes->setChecked(true); signalMapper = new QSignalMapper(this); signalMapper->setMapping (ui->actionFollow, "") ; connect (signalMapper, SIGNAL(mapped(QString)), this, SLOT(watchDir(QString))) ; connect(ui->actionFollow, SIGNAL(triggered()), signalMapper, SLOT(map())); ui->xSlider->setValue(15 * 16); ui->ySlider->setValue(345 * 16); ui->zSlider->setValue(0 * 16); setWindowTitle(tr("MuView 0.9")); // Data, don't connect until we are ready (probably still not ready here)... connect(ui->animSlider, SIGNAL(valueChanged(int)), this, SLOT(updateDisplayData(int))); // Load files from command line if supplied if (argc > 1) { QStringList rawList; for (int i=1; i<argc; i++) { rawList << argv[i]; } if (rawList.contains(QString("-w"))) { if (rawList.indexOf("-w") < (rawList.length() - 1)) { watchDir(rawList[rawList.indexOf("-w")+1]); } } else { QStringList allLoadedFiles; foreach (QString item, rawList) { QFileInfo info(item); if (!info.exists()) { std::cout << "File " << item.toStdString() << " does not exist" << std::endl; } else { // Push our new content... if (info.isDir()) { QDir chosenDir(item); dirString = chosenDir.path()+"/"; QStringList filters; filters << "*.omf" << "*.ovf"; chosenDir.setNameFilters(filters); QStringList files = chosenDir.entryList(); foreach (QString file, files) { filenames << (dirString+file); displayNames << (dirString+item); //omfCache.push_back(readOMF((dirString+file).toStdString(), tempHeader)); } } else {