void QmlProject::parseProject(RefreshOptions options) { Core::MessageManager *messageManager = Core::ICore::messageManager(); if (options & Files) { if (options & ProjectFile) delete m_projectItem.data(); if (!m_projectItem) { Utils::FileReader reader; if (reader.fetch(m_fileName)) { QDeclarativeComponent *component = new QDeclarativeComponent(&m_engine, this); component->setData(reader.data(), QUrl::fromLocalFile(m_fileName)); if (component->isReady() && qobject_cast<QmlProjectItem*>(component->create())) { m_projectItem = qobject_cast<QmlProjectItem*>(component->create()); connect(m_projectItem.data(), SIGNAL(qmlFilesChanged(QSet<QString>,QSet<QString>)), this, SLOT(refreshFiles(QSet<QString>,QSet<QString>))); } else { messageManager->printToOutputPane(tr("Error while loading project file %1.").arg(m_fileName), Core::MessageManager::NoModeSwitch); messageManager->printToOutputPane(component->errorString(), Core::MessageManager::NoModeSwitch); } } else { messageManager->printToOutputPane(tr("QML project: %1").arg(reader.errorString()), Core::MessageManager::NoModeSwitch); } } if (m_projectItem) { m_projectItem.data()->setSourceDirectory(projectDir().path()); m_modelManager->updateSourceFiles(m_projectItem.data()->files(), true); QString mainFilePath = m_projectItem.data()->mainFile(); if (!mainFilePath.isEmpty()) { mainFilePath = projectDir().absoluteFilePath(mainFilePath); Utils::FileReader reader; QString errorMessage; if (!reader.fetch(mainFilePath, &errorMessage)) { messageManager->printToOutputPane( tr("Warning while loading project file %1.").arg(m_fileName), Core::MessageManager::NoModeSwitch); messageManager->printToOutputPane(errorMessage, Core::MessageManager::NoModeSwitch); } else { m_defaultImport = detectImport(QString::fromUtf8(reader.data())); } } } m_rootNode->refresh(); } if (options & Configuration) { // update configuration } if (options & Files) emit fileListChanged(); }
void GoProject::parseProject(RefreshOptions options) { if (options & Files) { if (options & ProjectFile) delete m_projectItem.data(); if (!m_projectItem) { QString errorMessage; m_projectItem = GoProjectFileFormat::parseProjectFile(m_fileName, &errorMessage); if (m_projectItem) { connect(m_projectItem.data(), SIGNAL(filesChanged(QSet<QString>,QSet<QString>)), this, SLOT(refreshFiles(QSet<QString>,QSet<QString>))); } else { MessageManager::write(tr("Error while loading project file %1.").arg(m_fileName), MessageManager::NoModeSwitch); MessageManager::write(errorMessage); } } if (m_projectItem) { m_projectItem.data()->setSourceDirectory(projectDir().path()); m_modelManager->updateSourceFiles(m_projectItem.data()->files(), true); /* QString mainFilePath = m_projectItem.data()->mainFile(); if (!mainFilePath.isEmpty()) { mainFilePath = projectDir().absoluteFilePath(mainFilePath); Utils::FileReader reader; QString errorMessage; if (!reader.fetch(mainFilePath, &errorMessage)) { MessageManager::write(tr("Warning while loading project file %1.").arg(m_fileName)); MessageManager::write(errorMessage); } else { m_defaultImport = detectImport(QString::fromUtf8(reader.data())); } } */ } m_rootNode->refresh(); updateConfigurations(); } if (options & Configuration) { // update configuration } if (options & Files) emit fileListChanged(); }
void DocumentCatalog::queryChanged() { int newStatus = 0; if(query() == "") { // reset query dir = QDir::home(); currentPath = ""; queryMatched = 0; refreshFolders(); } else { if(query().length() >= minQueryLen()) { QString path = query().lower().remove(0, queryMatched); int index; while((index = path.find('/')) != -1) { QString folderQuery = path.left(index); QString guess = QString::null; for(QStringList::Iterator it = folders.begin(); it != folders.end(); ++it) { QString folderName = *it; if(folderName.lower().startsWith(folderQuery) && (guess.isNull() || folderName.length() < guess.length())) guess = folderName; } if(guess == QString::null) { path = QString::null; break; } if(!dir.cd(guess)) { path = QString::null; break; } refreshFolders(); queryMatched += folderQuery.length() + 1; currentPath += guess + "/"; path = path.remove(0, index+1); } Match newBestMatch; if(path.isNull()) { files.clear(); } else { if(!filesListed) { refreshFiles(); } if(!path.isEmpty()) { if(currentDirDoc != 0) { files.removeRef(currentDirDoc); currentDirDoc = 0; } QPtrListIterator<Document> it(files); Document *document; while((document = it.current()) != 0) { ++it; if(document->name().lower().startsWith(path)) { int rank = 100*query().length()/document->text().length(); if(newBestMatch.isNull() || rank > newBestMatch.rank()) newBestMatch = Match(document, rank, currentPath.length() + path.length()); } else { files.removeRef(document); } } } } if(currentDirDoc != 0 && path.isEmpty()) newBestMatch = Match(currentDirDoc, 100, currentPath.length()); newStatus |= S_Active; if(files.count() > 0) { newStatus |= S_HasResults; if(files.count() > 1 || files.at(0)->className() == "Directory") newStatus |= S_Multiple; } else newStatus |= S_NoResults; setBestMatch(newBestMatch); } else { setBestMatch(Match()); } } setStatus(newStatus); }
void DocumentCatalog::initialize() { dir = QDir::home(); refreshFolders(); refreshFiles(); }
void MatchStarter::reloadBaseDirs() { guiManager_->reloadBaseDirs(); refreshFiles(); }
void ofxPocoDirectoryLister::getFileNames( vector<string> & files ) { refreshFiles(); for( int i = 0; i < currentFiles.size(); i++) files.push_back(currentFiles[i].getFileName()); }
// Constructor. qtractorMidiControlForm::qtractorMidiControlForm ( QWidget *pParent, Qt::WindowFlags wflags ) : QDialog(pParent, wflags) { // Setup UI struct... m_ui.setupUi(this); // Window modality (let plugin/tool windows rave around). QDialog::setWindowModality(Qt::WindowModal); m_iDirtyCount = 0; m_iDirtyMap = 0; m_iUpdating = 0; QHeaderView *pHeader = m_ui.FilesListView->header(); pHeader->setDefaultAlignment(Qt::AlignLeft); #if QT_VERSION >= 0x050000 // pHeader->setSectionResizeMode(QHeaderView::Custom); pHeader->setSectionResizeMode(QHeaderView::ResizeToContents); pHeader->setSectionsMovable(false); #else // pHeader->setResizeMode(QHeaderView::Custom); pHeader->setResizeMode(QHeaderView::ResizeToContents); pHeader->setMovable(false); #endif pHeader = m_ui.ControlMapListView->header(); pHeader->setDefaultAlignment(Qt::AlignLeft); #if QT_VERSION >= 0x050000 // pHeader->setSectionResizeMode(QHeaderView::Custom); pHeader->setSectionResizeMode(QHeaderView::ResizeToContents); pHeader->setSectionsMovable(false); #else // pHeader->setResizeMode(QHeaderView::Custom); pHeader->setResizeMode(QHeaderView::ResizeToContents); pHeader->setMovable(false); #endif m_pControlTypeGroup = new qtractorMidiControlTypeGroup(NULL, m_ui.ControlTypeComboBox, m_ui.ParamComboBox, m_ui.ParamTextLabel); m_ui.ControlTypeComboBox->setCurrentIndex(3); // Controller (default). // m_ui.ChannelComboBox->clear(); m_ui.ChannelComboBox->addItem("*"); for (unsigned short iChannel = 0; iChannel < 16; ++iChannel) m_ui.ChannelComboBox->addItem(textFromChannel(iChannel)); const QIcon iconCommand(":/images/itemChannel.png"); // m_ui.CommandComboBox->clear(); m_ui.CommandComboBox->addItem(iconCommand, qtractorMidiControl::nameFromCommand(qtractorMidiControl::TRACK_GAIN)); m_ui.CommandComboBox->addItem(iconCommand, qtractorMidiControl::nameFromCommand(qtractorMidiControl::TRACK_PANNING)); m_ui.CommandComboBox->addItem(iconCommand, qtractorMidiControl::nameFromCommand(qtractorMidiControl::TRACK_MONITOR)); m_ui.CommandComboBox->addItem(iconCommand, qtractorMidiControl::nameFromCommand(qtractorMidiControl::TRACK_RECORD)); m_ui.CommandComboBox->addItem(iconCommand, qtractorMidiControl::nameFromCommand(qtractorMidiControl::TRACK_MUTE)); m_ui.CommandComboBox->addItem(iconCommand, qtractorMidiControl::nameFromCommand(qtractorMidiControl::TRACK_SOLO)); m_ui.SyncCheckBox->setChecked(qtractorMidiControl::isSync()); stabilizeTypeChange(); refreshFiles(); adjustSize(); // UI signal/slot connections... QObject::connect(m_ui.FilesListView, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), SLOT(stabilizeForm())); QObject::connect(m_ui.ControlMapListView, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), SLOT(stabilizeForm())); QObject::connect(m_ui.ImportPushButton, SIGNAL(clicked()), SLOT(importSlot())); QObject::connect(m_ui.RemovePushButton, SIGNAL(clicked()), SLOT(removeSlot())); QObject::connect(m_ui.MoveUpPushButton, SIGNAL(clicked()), SLOT(moveUpSlot())); QObject::connect(m_ui.MoveDownPushButton, SIGNAL(clicked()), SLOT(moveDownSlot())); QObject::connect(m_pControlTypeGroup, SIGNAL(controlTypeChanged(int)), SLOT(typeChangedSlot())); QObject::connect(m_pControlTypeGroup, SIGNAL(controlParamChanged(int)), SLOT(keyChangedSlot())); QObject::connect(m_ui.ChannelComboBox, SIGNAL(activated(int)), SLOT(keyChangedSlot())); QObject::connect(m_ui.TrackCheckBox, SIGNAL(toggled(bool)), SLOT(keyChangedSlot())); QObject::connect(m_ui.TrackSpinBox, SIGNAL(valueChanged(int)), SLOT(valueChangedSlot())); QObject::connect(m_ui.CommandComboBox, SIGNAL(activated(int)), SLOT(valueChangedSlot())); QObject::connect(m_ui.FeedbackCheckBox, SIGNAL(toggled(bool)), SLOT(valueChangedSlot())); QObject::connect(m_ui.MapPushButton, SIGNAL(clicked()), SLOT(mapSlot())); QObject::connect(m_ui.UnmapPushButton, SIGNAL(clicked()), SLOT(unmapSlot())); QObject::connect(m_ui.SyncCheckBox, SIGNAL(toggled(bool)), SLOT(syncSlot(bool))); QObject::connect(m_ui.ReloadPushButton, SIGNAL(clicked()), SLOT(reloadSlot())); QObject::connect(m_ui.ExportPushButton, SIGNAL(clicked()), SLOT(exportSlot())); QObject::connect(m_ui.ClosePushButton, SIGNAL(clicked()), SLOT(reject())); }
// Export the whole state into a single controller file. void qtractorMidiControlForm::exportSlot (void) { qtractorMidiControl *pMidiControl = qtractorMidiControl::getInstance(); if (pMidiControl == NULL) return; qtractorOptions *pOptions = qtractorOptions::getInstance(); if (pOptions == NULL) return; QString sPath; const QString sExt("qtc"); const QString& sTitle = tr("Export Controller File") + " - " QTRACTOR_TITLE; const QString& sFilter = tr("Controller files (*.%1)").arg(sExt); if (pOptions->midiControlFiles.isEmpty()) { sPath = QFileInfo(pOptions->sMidiControlDir, tr("controller") + '.' + sExt).absoluteFilePath(); } else sPath = pOptions->midiControlFiles.last(); #if 1//QT_VERSION < 0x040400 // Ask for the filename to open... QFileDialog::Options options = 0; if (pOptions->bDontUseNativeDialogs) options |= QFileDialog::DontUseNativeDialog; sPath = QFileDialog::getSaveFileName(this, sTitle, sPath, sFilter, NULL, options); #else // Construct open-files dialog... QFileDialog fileDialog(this, sTitle, sPath, sFilter); // Set proper open-file modes... fileDialog.setAcceptMode(QFileDialog::AcceptSave); fileDialog.setFileMode(QFileDialog::AnyFile); fileDialog.setHistory(pOptions->midiControlFiles); fileDialog.setDefaultSuffix(sExt); // Stuff sidebar... QList<QUrl> urls(fileDialog.sidebarUrls()); urls.append(QUrl::fromLocalFile(pOptions->sSessionDir)); urls.append(QUrl::fromLocalFile(pOptions->sMidiControlDir)); fileDialog.setSidebarUrls(urls); if (pOptions->bDontUseNativeDialogs) fileDialog.setOptions(QFileDialog::DontUseNativeDialog); // Show dialog... if (fileDialog.exec()) sPath = fileDialog.selectedFiles().first(); else sPath.clear(); #endif if (sPath.isEmpty()) return; // Enforce .qtc extension... if (QFileInfo(sPath).suffix().isEmpty()) { sPath += '.' + sExt; // Check if already exists... if (QFileInfo(sPath).exists()) { if (QMessageBox::warning(this, tr("Warning") + " - " QTRACTOR_TITLE, tr("The controller file already exists:\n\n" "\"%1\"\n\n" "Do you want to replace it?") .arg(sPath), QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Cancel) return; } } // Just save the whole bunch... if (pMidiControl->saveDocument(sPath)) { pOptions->sMidiControlDir = QFileInfo(sPath).absolutePath(); if (m_iDirtyMap > 0 && QMessageBox::warning(this, tr("Warning") + " - " QTRACTOR_TITLE, tr("Saved controller mappings may not be effective\n" "the next time you start this program.\n\n" "\"%1\"\n\n" "Do you want to apply to controller files?") .arg(sPath), QMessageBox::Apply | QMessageBox::Ignore) == QMessageBox::Apply) { // Apply by append... pOptions->midiControlFiles.clear(); pOptions->midiControlFiles.append(sPath); // Won't be dirty anymore. m_iDirtyMap = 0; // Make it renew... refreshFiles(); reloadSlot(); } } }