void QMathMLFileViewer::readSettings( QSettings& settings ) { QString path = settings.value("FmlIde/mmlfileviewer/dir", QVariant(QDir::currentPath())).toString(); changeDir( path ); //if( m_dirTree ) // m_dirTree->setCurrentIndex( m_dirModel.index( m_currentDir.absolutePath() ) ); setRecursive(settings.value("FmlIde/mmlfileviewer/recursive", QVariant(true)).toBool()); if( btnRecursive ) btnRecursive->setChecked( isRecursive() ); }
void QMathMLFileViewer::fileFind() { filesTable->setRowCount(0); QString fileName = fileComboBox->currentText(); QString path = directoryComboBox->currentText(); updateComboBox(fileComboBox); updateComboBox(directoryComboBox); m_currentDir = QDir(path); if( fileName.isEmpty() ) fileName = DEFAULT_MASK; //QApplication::setOverrideCursor( Qt::WaitCursor ); QStringList files; if( isRecursive() ) { QProgressDialog progress("Searching files...", "Abort Search", 0, 100, this); progress.setWindowModality(Qt::WindowModal); progress.setMinimumDuration( 500 ); progress.setValue( 0 ); fileFind( files, m_currentDir, QStringList(fileName), &progress ); //progress.setValue( 100 + files.size() ); progress.setValue( progress.maximum() ); } else { //QStringList newFiles = m_currentDir.entryList(QStringList(fileName), QDir::Files | QDir::NoSymLinks); //for( QStringList::const_iterator item = newFiles.constBegin(); item != newFiles.constEnd(); item++ ) // files.append(m_currentDir.absoluteFilePath(*item)); files = m_currentDir.entryList(QStringList(fileName), QDir::Files | QDir::NoSymLinks); } if(files.size() > 0) { filesTable->show(); showFiles(files); filesTable->resizeRowsToContents(); filesTable->resizeColumnsToContents(); foundMessage->setText(QString(tr("%1 file(s) shown of %2 found").arg(filesTable->rowCount()).arg(files.size()))); emit hasFound( true ); } else { filesTable->hide(); foundMessage->setText(QString(tr("No files found to match %1")).arg(fileName)); emit hasFound( false ); } //QApplication::restoreOverrideCursor(); }
void DirectoryScannerPipe::addDocumentsInDirectory( string const & directory, Corpus * const corpus) const { for (fs::directory_iterator end, dir(directory); dir != end; ++dir) { string const location = (* dir).path().generic_string(); if (fs::is_directory(*dir)) { if (isRecursive()) { addDocumentsInDirectory(location, corpus); } } else { addDocument(location, corpus); } } }
void ScanThread::scanDir( const RecordID& dirId, EntriesIt itEntriesBegin, EntriesIt itEntriesEnd) { if (shouldBreak()) { return; } Records oldRecords = db_.children(dirId); std::sort(oldRecords.begin(), oldRecords.end(), CmpByPath()); auto entriesRange = boost::make_iterator_range(itEntriesBegin, itEntriesEnd); for (const auto& entry : entriesRange) { scanEntry(getPath(entry), dirId, oldRecords, isRecursive(entry)); if (shouldBreak()) { return; } } for (const Record& missing : oldRecords) { try { delEntry(missing.first); } catch(std::exception const& ex) { std::cerr << "Failed to delete DB record for '" << missing.second.header.fileName << "' entry: " << ex.what() << std::endl; } } }
QHBoxLayout* QMathMLFileViewer::setupToolLayout() { QHBoxLayout *toolLayout = new QHBoxLayout(); QToolButton *btnRefresh = new QToolButton(); btnRefresh->setIcon(QIcon(":/images/reload.png")); //btnRefresh->setIconSize(m_iconSize); btnRefresh->setToolTip(tr("Refresh contents of the current directory")); connect(btnRefresh, SIGNAL(clicked()), this, SLOT(fileRefresh())); toolLayout->addWidget( btnRefresh ); QToolButton *btnView = new QToolButton(); btnView->setIcon(QIcon(":/images/printpreview.png")); //btnView->setIconSize(m_iconSize); btnView->setToolTip(tr("Open the selected file as a new read-only window in the editor - for viewing purposes only")); connect(btnView, SIGNAL(clicked()), this, SLOT(fileLoad())); connect(this, SIGNAL(hasSelectedItem(bool)), btnView, SLOT(setEnabled(bool))); btnView->setEnabled( false ); toolLayout->addWidget( btnView ); QToolButton *btnOpen = new QToolButton(); btnOpen->setIcon(QIcon(":/images/open.png")); //btnOpen->setIconSize(m_iconSize); btnOpen->setToolTip(tr("Open the selected file as a new window in the editor")); connect(btnOpen, SIGNAL(clicked()), this, SLOT(fileOpen())); connect(this, SIGNAL(hasSelectedItem(bool)), btnOpen, SLOT(setEnabled(bool))); btnOpen->setEnabled( false ); toolLayout->addWidget( btnOpen ); toolLayout->addSpacing( 12 ); QLabel *labelMask = new QLabel(tr("Mask:")); fileComboBox = createComboBox(tr(DEFAULT_MASK)); fileComboBox->setMinimumWidth( 80 ); //fileComboBox->setIconSize(m_iconSize); toolLayout->addWidget( labelMask ); toolLayout->addWidget( fileComboBox ); QToolButton *btnFind = new QToolButton(); btnFind->setIcon(QIcon(":/images/find.png")); //btnFind->setIconSize(m_iconSize); btnFind->setToolTip(tr("Find all files with a given name starting from the current directory")); connect(btnFind, SIGNAL(clicked()), this, SLOT(fileFind())); toolLayout->addWidget( btnFind ); btnRecursive = new QToolButton(); btnRecursive->setObjectName("__qt__fmlide_widget_QMathMLFileViewer_button_Recursive"); btnRecursive->setIcon(QIcon(":/images/contents.png")); btnRecursive->setToolTip(tr("Set on/off recursive search from the current folder")); btnRecursive->setToolButtonStyle( Qt::ToolButtonIconOnly ); btnRecursive->setCheckable( true ); btnRecursive->setChecked( isRecursive() ); connect(btnRecursive, SIGNAL(toggled(bool)), this, SLOT(setRecursive(bool))); toolLayout->addWidget( btnRecursive ); QToolButton *btnBack = new QToolButton(); btnBack->setIcon(QIcon(":/images/back.png")); //btnBack->setIconSize(m_iconSize); btnBack->setToolTip(tr("Select the previous found file")); connect(btnBack, SIGNAL(clicked()), this, SLOT(fileBack())); connect(this, SIGNAL(hasFound(bool)), btnBack, SLOT(setEnabled(bool))); btnBack->setEnabled( false ); toolLayout->addWidget( btnBack ); QToolButton *btnForward = new QToolButton(); btnForward->setIcon(QIcon(":/images/forward.png")); //btnForward->setIconSize(m_iconSize); btnForward->setToolTip(tr("Select the next found file")); connect(btnForward, SIGNAL(clicked()), this, SLOT(fileForward())); connect(this, SIGNAL(hasFound(bool)), btnForward, SLOT(setEnabled(bool))); btnForward->setEnabled( false ); toolLayout->addWidget( btnForward ); toolLayout->addStretch( 1 ); return toolLayout; }
void QMathMLFileViewer::writeSettings( QSettings& settings ) { settings.setValue("FmlIde/mmlfileviewer/dir", m_currentDir.absolutePath() ); settings.setValue("FmlIde/mmlfileviewer/recursive", isRecursive()); }