void MainWindow::on_path_returnPressed() { QFileSystemModel *FSM; QStringList sImageFilters; QDir d; QString sPath; sImageFilters << "*.png"; //Show files in the tree view sPath = ui->path->text(); FSM = new QFileSystemModel(this); FSM->setFilter(QDir::NoDotAndDotDot | QDir::AllEntries); FSM->setRootPath(sPath); FSM->setNameFilters(sImageFilters); ui->file_browser->setModel(FSM); ui->file_browser->setRootIndex(FSM->index(sPath)); ui->file_browser->hideColumn(1); ui->file_browser->hideColumn(2); ui->file_browser->hideColumn(3); //initiate the filelist to the image d.setPath(ui->path->text()); d.setFilter( QDir::Files | QDir::NoSymLinks ); d.setNameFilters(sImageFilters); filelist = d.entryInfoList(); //initiate the dir for the yml files ymlFileDir = ui->path->text(); ymlFileDir.append("/data/"); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { setupUi(this); Settings *settings = Settings::getInstance(); this->setWindowIcon(QIcon(":/icons/mmmmp.ico")); this->filesystem->header()->setResizeMode(QHeaderView::ResizeToContents); this->setStyleSheet(settings->styleSheet(this)); leftTabs->setStyleSheet(settings->styleSheet(leftTabs)); widgetSearchBar->setStyleSheet(settings->styleSheet(0)); splitter->setStyleSheet(settings->styleSheet(splitter)); volumeSlider->setStyleSheet(settings->styleSheet(volumeSlider)); seekSlider->setStyleSheet(settings->styleSheet(seekSlider)); QFileSystemModel *fileSystemModel = new QFileSystemModel(this); fileSystemModel->setFilter(QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot); QStringList filters; filters << "*.mp3"; fileSystemModel->setNameFilters(filters); filesystem->setModel(fileSystemModel); filesystem->setRootIndex(fileSystemModel->setRootPath(QDesktopServices::storageLocation(QDesktopServices::MusicLocation))); // Hide columns "size" and "date modified" columns, useless for almost everyone filesystem->setColumnHidden(1, true); filesystem->setColumnHidden(3, true); // Special behaviour for media buttons mediaButtons << skipBackwardButton << seekBackwardButton << playButton << pauseButton << stopButton << seekForwardButton << skipForwardButton << repeatButton << shuffleButton; foreach (MediaButton *b, mediaButtons) { b->setStyleSheet(settings->styleSheet(b)); }
void MainWindow::updateListView(){ QFileSystemModel *model = new QFileSystemModel; QString path(QFileInfo(currentFile->fileName()).dir().path()); model->setFilter(QDir::AllDirs | QDir::AllEntries); QStringList flt; flt << "*.md" << "*.mkd"; model->setNameFilters(flt); model->setNameFilterDisables(false); model->setRootPath(path); ui->listView->setModel(model); ui->listView->setRootIndex(model->index(path)); }
void TagEditor::readSettings(){ /* guiSettings->beginGroup("MainWindow"); //this->resize(guiSettings->value("size", QSize(630, 750)).toSize()); //this->move(guiSettings->value("pos", QPoint(200, 200)).toPoint()); guiSettings->endGroup(); */ style = guiSettings->value("style","WindowsXP").toString(); startupFolder = guiSettings->value("startupFolder","").toString(); QString defaultExt = "*.mp3;*.wma;*.wav;*.ogg;*.aac;*.ac3;*.m4a"; extensions = guiSettings->value("extensions",defaultExt.split(";")).toStringList(); QFileSystemModel *model = static_cast<QFileSystemModel*>(TreeView->model()); model->setRootPath(startupFolder); model->setNameFilters(extensions); model->setNameFilterDisables(false); TreeView->setRootIndex(model->index(startupFolder)); treeViewLabel->setText(startupFolder); //api_key = guiSettings->value("api_key","").toString(); showSaveTagWarning = guiSettings->value("showSaveTagWarning",true).toBool(); subfolders = guiSettings->value("subfolders",true).toBool(); ArtistCheckbox->setChecked( guiSettings->value("artistChecked",true).toBool() ); TitleCheckbox->setChecked( guiSettings->value("titleChecked",true).toBool() ); AlbumCheckbox->setChecked( guiSettings->value("albumChecked",true).toBool() ); YearCheckbox->setChecked( guiSettings->value("yearChecked",true).toBool() ); TrackCheckbox->setChecked( guiSettings->value("trackChecked",true).toBool() ); GenreCheckbox->setChecked( guiSettings->value("genreChecked",true).toBool() ); CommentCheckbox->setChecked( guiSettings->value("commentChecked",true).toBool() ); lastStyleSheetFolder = guiSettings->value("lastStyleSheetFolder","").toString(); TreeWidget_->setShowFullFileName( guiSettings->value("showFullFileName",false).toBool() ); TreeWidget_->setShowTagInfo( guiSettings->value("showTagInfo",false).toBool() ); TreeWidget_->setSortingEnabled( guiSettings->value("sortingEnabled",true).toBool() ); if(TreeWidget_->isSortingEnabled()){ TreeWidget_->header()->setSortIndicator( guiSettings->value("sortColumn",0).toInt(), static_cast<Qt::SortOrder>(guiSettings->value("sortOrder",0).toInt()) ); TreeWidget_->header()->setSortIndicatorShown(true); } QVariantList colstmp = guiSettings->value("columns").toList(); QList<Global::TagField> cols; for(int i=0;i<colstmp.size();i++){ qDebug()<<"colstmp[i] "<<colstmp[i]; cols.append(static_cast<Global::TagField>(colstmp[i].toInt())); } TreeWidget_->setColumnsList(cols); restoreState(guiSettings->value("windowState").toByteArray()); restoreGeometry(guiSettings->value("geometry").toByteArray()); //splitter->setSizes(guiSettings->value("splittersizes").value< QList<int> >() ); scriptEditor_->setText(guiSettings->value("script","").toString()); }
MainWindow::MainWindow(QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags) { setupUi(this); menuView->addAction(fileBrowserDock->toggleViewAction()); menuView->addAction(informationDock->toggleViewAction()); menuView->addAction(drawingDock->toggleViewAction()); // Load and initialize palettes _ildaPalette = loadPalette(":/data/ilda.palette"); _pangolinPalette = loadPalette(":/data/pangolin.palette"); _currentPalette = &_ildaPalette; // File browser QFileSystemModel *fsModel = new QFileSystemModel(this); fsModel->setRootPath(QDir::rootPath()); fsModel->setNameFilterDisables(false); fsModel->setNameFilters(QStringList() << "*.ild"); treeView->setModel(fsModel); treeView->header()->setResizeMode(0, QHeaderView::ResizeToContents); //treeView->setSortingEnabled(true); //treeView->sortByColumn(0, Qt::AscendingOrder); treeView->setColumnHidden(2, true); treeView->setColumnHidden(3, true); //treeView->setRootIndex(fsModel->index(QDir::homePath())); // Create the connections connect(actionOpen, SIGNAL(triggered()), this, SLOT(fileOpen())); connect(actionSaveAs, SIGNAL(triggered()), this, SLOT(fileSaveAs())); connect(actionPangolin_palette, SIGNAL(triggered()), SLOT(usePangolinPalette())); connect(actionILDA_palette, SIGNAL(triggered()), SLOT(useILDAPalette())); connect(actionAbout, SIGNAL(triggered()), SLOT(about())); connect(treeView, SIGNAL(clicked(QModelIndex)), SLOT(fileBrowserItemClicked(QModelIndex))); connect(treeView, SIGNAL(doubleClicked(QModelIndex)), SLOT(fileBrowserItemDblClicked(QModelIndex))); connect(normalRadioButton, SIGNAL(clicked()), SLOT(drawModeChanged())); connect(diagnosticRadioButton, SIGNAL(clicked()), SLOT(drawModeChanged())); // restore settings readSettings(); }
/** * Setup the tree view widget. */ void CodeImpSelectPage::setupTreeView() { QFileSystemModel* model = new QFileSystemModel(); model->setRootPath(""); m_fileExtensions << "*.h" << "*.hpp" << "*.hh" << "*.hxx" << "*.H"; //:TODO set according to the current language! model->setNameFilters(m_fileExtensions); ui_treeView->setModel(model); ui_treeView->setIndentation(20); ui_treeView->setColumnWidth(0, 200); ui_treeView->setSortingEnabled(true); ui_treeView->setWindowTitle(i18n("File System Model")); if (s_recentPath.isEmpty()) { ui_treeView->setCurrentIndex(model->index(QDir::currentPath())); } else { ui_treeView->setCurrentIndex(model->index(s_recentPath)); } ui_treeView->show(); }
QObject* FileSystemTab::component(Jerboa::Plugin::ComponentType type, QObject* parent) { switch(type) { case Jerboa::Plugin::WidgetUsedWithPlaylist: { QFileSystemModel* model = new FileSystemModelWithToolTip(parent); model->setRootPath("/"); model->setFilter(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::AllDirs); model->setNameFilterDisables(false); QStringList musicGlobs; musicGlobs << "*.aac" << "*.aiff" << "*.ape" << "*.au" << "*.cdda" << "*.flac" << "*.m4a" << "*.mp3" << "*.oga" << "*.ogg" << "*.ogm" << "*.wav" << "*.wma" ; model->setNameFilters(musicGlobs); QTreeView* view = new QTreeView(qobject_cast<QWidget*>(parent)); view->setWindowTitle("Files"); view->setModel(model); view->setHeaderHidden(true); for(int i = 1; i < model->columnCount(); ++i) { view->setColumnHidden(i, true); } QString path = QDesktopServices::storageLocation(QDesktopServices::MusicLocation); if(path.isEmpty() || !QDir(path).exists()) { path = QDesktopServices::storageLocation(QDesktopServices::HomeLocation); } const QModelIndex index(model->index(QSettings().value("collection/directory", path).toString())); for(QModelIndex iterator(index); iterator.isValid(); iterator = iterator.parent()) { view->setExpanded(iterator, true); } view->setDragDropMode(QAbstractItemView::DragOnly); view->selectionModel()->select(index, QItemSelectionModel::ClearAndSelect); view->setSelectionMode(QAbstractItemView::ExtendedSelection); connect( view, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(addPathToPlaylist(QModelIndex)) ); QTimer* timer = new QTimer(this); connect( timer, SIGNAL(timeout()), this, SLOT(scrollToSelection()) ); timer->setSingleShot(true); timer->start(1000); m_view = view; return view; } default: return Jerboa::Plugin::component(type, parent); } }