void DiskBrowser::changeItem(const QModelIndex &item) { if(browseMode == Folder) { ok->setEnabled(model->isDir(item)); image->name = ""; info->setText(""); applyPatch->setVisible(false); } else { string filename; currentFilename(filename); if(filename.length() == 0) { //nothing selected? ok->setEnabled(false); image->name = ""; info->setText(""); applyPatch->setVisible(false); } else { ok->setEnabled(true); image->name = nall::basename(filename) << ".png"; if(file::exists(image->name) == false) image->name = ""; info->setText(utf8() << queryImageInformation()); string patch = nall::basename(filename) << ".ups"; applyPatch->setVisible(file::exists(patch)); } } image->update(); }
void Document::autosaveNow() { if(!isDirty() || !isAutosave()) return; Q_ASSERT(utils::isWritableFormat(currentFilename())); QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); bool saved = m_canvas->save(currentFilename()); QApplication::restoreOverrideCursor(); if(saved) unmarkDirty(); else qWarning("Error autosaving"); }
wxString wxFileDialog::GetFilename() const { wxString currentFilename( m_fc.GetFilename() ); if (currentFilename.empty()) { // m_fc.GetFilename() will return empty until the dialog has been shown // in which case use any previously provided value currentFilename = m_fileName; } return currentFilename; }
string DiskBrowser::queryImageInformation() { string text; string filename; if(currentFilename(filename) == true) { if(striend(filename, ".sfc") || striend(filename, ".smc")) { unsigned size = file::size(filename); text << "<b>" << notdir(nall::basename(filename)) << "</b>"; text << "<small><table cellspacing='5'>"; text << "<tr><td><b>ROM size:</b></td><td>" << size * 8 / 1024 / 1024 << "mbit</td></tr>"; text << "</table></small>"; } } return text; }
void MFileLogger::log(const QString &pText, const QString &pChannel) { if(_filenameTemplate != "") { QFileInfo fi(currentFilename(pChannel)); QDir dir; if(!dir.exists(fi.path())) { dir.mkpath(fi.path()); } QFile logFile(currentFilename(pChannel)); if(!logFile.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) { QString current = currentFilename(pChannel); _filenameTemplate = ""; throw new MException(__FUNCTION_NAME__, "Error opening logfile " + current + "\n" + logFile.errorString()); } logFile.write(("[" + pChannel + QDateTime::currentDateTime().toString(" yyyy-MM-dd hh:mm:ss] ") + pText + "\n").toAscii()); logFile.close(); } }
void DiskBrowser::loadSelected() { string filename; bool loadable = currentFilename(filename); if(browseMode == Folder || loadable == true) { QModelIndex item = view->currentIndex(); config.path.current = dir(model->filePath(item).toUtf8().constData()); hide(); switch(browseMode) { default: case Folder: activePath->selectPath(filename); break; case Cartridge: utility.loadCartridgeNormal(filename); break; case BaseCartridge: loaderWindow->selectBaseCartridge(filename); break; case BsxCartridge: loaderWindow->selectSlot1Cartridge(filename); break; case SufamiTurboCartridge1: loaderWindow->selectSlot1Cartridge(filename); break; case SufamiTurboCartridge2: loaderWindow->selectSlot2Cartridge(filename); break; case SuperGameBoyCartridge: loaderWindow->selectSlot1Cartridge(filename); break; } } else { //this is a standard folder in ROM loading mode; enter into the folder QModelIndex item = view->currentIndex(); setPath(model->filePath(item)); } }
const QString MFileLogger::currentFilename(const QString &pChannel) { return currentFilename(_filenameTemplate, pChannel); }