QString SongDbWindow::selectSongFolder() { QString folder = QFileDialog::getExistingDirectory ( this, tr("Please pick the folder containing the songs."), getDefaultFolder( "SongDefaultFolder" ) ); if ( !folder.isEmpty() ) { DEBUG() << folder; mPreference.setValue( "SongDefaultFolder", folder ); reset(); mSongDatabase = new SongDatabase( folder ); songTableView->setModel( new SongTableModel( mSongDatabase ) ); songTableView->setSelectionBehavior( QAbstractItemView::SelectRows ); songTableView->setSelectionMode( QAbstractItemView::SingleSelection ); songTableView->show(); emit sgnlSongDatabaseChanged( mSongDatabase ); } else { DEBUG() << "cancel folder selection"; } return folder; }
void TLevelSet::saveFolder(TOStream &os, TFilePath folder) { std::map<std::string, std::string> attr; attr["name"] = folder.getName(); if (folder == getDefaultFolder()) attr["type"] = "default"; os.openChild("folder", attr); std::vector<TFilePath> folders; listFolders(folders, folder); if (!folders.empty()) { for (int i = 0; i < (int)folders.size(); i++) saveFolder(os, folders[i]); } std::vector<TXshLevel *> levels; listLevels(levels, folder); if (!levels.empty()) { os.openChild("levels"); for (int i = 0; i < (int)levels.size(); i++) if (m_saveSet.empty() || m_saveSet.count(levels[i]) > 0) os << levels[i]; os.closeChild(); } os.closeChild(); }
void SongDbWindow::writePdfFile() { if ( mSongDatabase != NULL && !mSongDatabase->isEmpty() ) { QString fileName = QFileDialog::getSaveFileName ( this, tr("Please enter the file name."), getDefaultFolder( "WritePdfDefaultFolder" ), tr("Pdf (*.pdf)") ); if ( !fileName.isEmpty() ) { DEBUG() << "ready to write " << fileName; SongBook::Book( mSongDatabase ).makePdf( fileName ); mPreference.setValue( "WritePdfDefaultFolder", QFileInfo( fileName ).canonicalPath() ); } else { DEBUG() << "filename invalid"; } } }