// Updates the actions for the recent files. // Must be called after having added a new name to the list. void MainWindow::updateRecentFileActions() { QStringList recent_files = recentFiles.recentFiles(); for ( int j = 0; j < MaxRecentFiles; ++j ) { if ( j < recent_files.count() ) { QString text = tr("&%1 %2").arg(j + 1).arg(strippedName(recent_files[j])); recentFileActions[j]->setText( text ); recentFileActions[j]->setToolTip( recent_files[j] ); recentFileActions[j]->setData( recent_files[j] ); recentFileActions[j]->setVisible( true ); } else { recentFileActions[j]->setVisible( false ); } } // separatorAction->setVisible(!recentFiles.isEmpty()); }
void TextRoom::setCurrentFile(const QString &fileName) { curFile = fileName; const QFileInfo f(fileName); textEdit->document()->setModified(false); setWindowModified(false); if (curFile.isEmpty()) { shownName = "Untitled.txr"; } else { shownName = strippedName(curFile); curDir = f.absolutePath(); } setWindowTitle(tr("%1[*] - %2").arg(shownName).arg( qApp->applicationName() )); }
/** Update Recent File Actions Function * * Updates the list of recent files that have been open, written * to, created,... */ void MainWindow::updateRecentFileActions() { QMutableStringListIterator i(recentFiles); while(i.hasNext()) if(!QFile::exists(i.next())) i.remove(); for(int j=0 ; j<MaxRecentFiles ; j++) { if(j < recentFiles.count()) { QString text = tr(&%1 %2) .arg(j+1) .arg(strippedName(recentFiles[j])); recentFileActions[j]->setText(text); recentFileActions[j]->setData(recentFiles[j]); recentFileActions[j]->setVisible(true); } else
/// Return document's title. QString Document::title() const { QString title; if (m_file == NULL) { title = tr("Untitled"); } else { title = strippedName(*m_file); } if (m_modified) { title.append(" "); title.append(tr("[modified]")); } return title; }
void RecentFiles::_updateRecentActions() { const int numRecentItems = qMin( _names.size(), (int)_maxRecentItems ); for( int i = 0; i < numRecentItems; ++i ) { Q_ASSERT( _recentActs[i] ); QString text = tr("&%1 %2").arg(i + 1).arg( strippedName( _names[i] )); _recentActs[i]->setText( text ); _recentActs[i]->setData( _names[i] ); _recentActs[i]->setVisible( true ); } for( int j = numRecentItems; j < _maxRecentItems; ++j ) { Q_ASSERT( _recentActs[j] ); _recentActs[j]->setVisible( false ); } Q_ASSERT( _separatorAct ); _separatorAct->setVisible( numRecentItems > 0 ); }
void SoulNote::updateRecentFileActions() { QSettings settings(QSettings::IniFormat, QSettings::UserScope, "Soulless", "SoulNote"); settings.beginGroup("Window"); QStringList files = settings.value("recentFileList").toStringList(); int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles); for (int i = 0; i < numRecentFiles - 1; ++i) { QString text = tr("&%1 %2").arg(i + 1).arg(strippedName(files[i])); recentFileActs[i]->setText(text); recentFileActs[i]->setData(files[i]); recentFileActs[i]->setVisible(true); } for (int j = numRecentFiles; j < MaxRecentFiles; ++j) recentFileActs[j]->setVisible(false); separatorAct->setVisible(numRecentFiles > 0); settings.endGroup(); }
// Add the filename to the recent files list and update the title bar. void MainWindow::setCurrentFile( const QString& fileName ) { // Change the current file currentFile = fileName; QString shownName = tr( "Untitled" ); if ( !currentFile.isEmpty() ) { // (reload the list first in case another glogg changed it) GetPersistentInfo().retrieve( "recentFiles" ); recentFiles.addRecent( currentFile ); GetPersistentInfo().save( "recentFiles" ); updateRecentFileActions(); shownName = strippedName( currentFile ); } setWindowTitle( tr("%1 - %2").arg(shownName).arg(tr("glogg")) #ifdef GLOGG_COMMIT + " (dev build " GLOGG_VERSION ")" #endif ); }
bool ImageDisplay::okToContinue() { if (isWindowModified()) { int r = QMessageBox::warning(this, tr("MDI Editor"), tr("File %1 has been modified.\n" "Do you want to save your changes?") .arg(strippedName(curFile)), QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::Cancel | QMessageBox::Escape); if (r == QMessageBox::Yes) { return save(); } else if (r == QMessageBox::Cancel) { return false; } } return true; }
void MainWindow::updateRecentFileActions() { QSettings settings; QStringList files = settings.value("recentFileList").toStringList(); int numRecentFiles = qMin(files.size(), MAX_RECENT_FILES); for (int i = 0; i < numRecentFiles; ++i) { QString text = strippedName(files[i]); m_action_open_recent_file[i]->setText(text); m_action_open_recent_file[i]->setData(files[i]); m_action_open_recent_file[i]->setVisible(true); } for (int j = numRecentFiles; j < MAX_RECENT_FILES; ++j) { m_action_open_recent_file[j]->setVisible(false); } m_action_recent_file_separator->setVisible(numRecentFiles > 0); m_action_clear_recent_files->setEnabled(numRecentFiles > 0); }
void ImageWindow::setCurrentFile(const QString &fileName) { curFile = fileName; setWindowModified(false); bool hasImage = !curFile.isEmpty(); if (hasImage) { setWindowTitle(tr("%1[*] - %2").arg(strippedName(curFile)) .arg(tr("Image Pro"))); } else { setWindowTitle(tr("Image Pro")); } saveAction->setEnabled(hasImage); saveAsAction->setEnabled(hasImage); flipHorizontallyAction->setEnabled(hasImage); flipVerticallyAction->setEnabled(hasImage); resizeAction->setEnabled(hasImage); convertTo32BitAction->setEnabled(hasImage); convertTo8BitAction->setEnabled(hasImage); convertTo1BitAction->setEnabled(hasImage); }
void MainWindow::setCurrentFile(const QString &fileName) { curFile = fileName; if (curFile.isEmpty()) setWindowTitle(tr("Recent Files")); else setWindowTitle(tr("%1 - %2").arg(strippedName(curFile)) .arg(tr("Recent Files"))); QSettings settings("Trolltech", "Recent Files Example"); QStringList files = settings.value("recentFileList").toStringList(); files.removeAll(fileName); files.prepend(fileName); while (files.size() > MaxRecentFiles) files.removeLast(); settings.setValue("recentFileList", files); foreach (QWidget *widget, QApplication::topLevelWidgets()) { MainWindow *mainWin = qobject_cast<MainWindow *>(widget); if (mainWin) mainWin->updateRecentFileActions(); }
void RecentFiles::updateRecentFiles(QSettings &settings) { int numOfRecentFiles = settings.value(recentFileCount, QVariant(4)).toInt(); QStringList MyRecentFileList = settings.value(recentFileListId).toStringList(); purgeMissingFilesFromList(MyRecentFileList); settings.setValue(recentFileListId, QVariant(MyRecentFileList)); // If there are no recent files, then the menu item (that would show the list) // should not be visible. if (m_recentMenuTriggeredAction) { if (numOfRecentFiles == 0) { m_recentMenuTriggeredAction->setVisible(false); } else { m_recentMenuTriggeredAction->setVisible(true); } } for (int j = 0; j < MaxRecentFiles; ++j) { if (j < MyRecentFileList.count() && j < numOfRecentFiles) { QString text = strippedName(MyRecentFileList[j]); m_recentFileActions[j]->setText(text); m_recentFileActions[j]->setData(MyRecentFileList[j]); m_recentFileActions[j]->setObjectName(sanitizedFileName(text)); m_recentFileActions[j]->setVisible(true); } else { m_recentFileActions[j]->setVisible(false); } } for (int j = numOfRecentFiles; j < MyRecentFileList.count(); j++) m_recentFileActions[j]->setVisible(false); getRecentFiles(); }
void MainWindow::updateRecentFileActions() { QMutableStringListIterator i(m_recentFiles); while (i.hasNext()) { if (!QFile::exists(i.next())) i.remove(); } for (int j = 0; j < MaxRecentFiles; ++j) { if (j < m_recentFiles.count()) { QString text = tr("&%1 %2") .arg(j + 1) .arg(strippedName(m_recentFiles[j])); m_recentFileActions[j]->setText(text); m_recentFileActions[j]->setData(m_recentFiles[j]); m_recentFileActions[j]->setVisible(true); } else m_recentFileActions[j]->setVisible(false); } m_separatorAction->setVisible(!m_recentFiles.isEmpty()); }
QString ImageDisplay::getCurFileWithStrippedName() { return strippedName(curFile); }
void MdiChild::writeEeprom() // write to Tx { bool backupEnable=true; QString backupPath=((MainWindow *)this->parent())->getBackupPath(); if (backupPath.isEmpty()) { backupEnable=false; } QString stickCal=g.profile[g.id()].stickPotCalib(); burnConfigDialog bcd; QString tempFile = generateProcessUniqueTempFileName("temp.bin"); saveFile(tempFile, false); if(!QFileInfo(tempFile).exists()) { QMessageBox::critical(this,tr("Error"), tr("Cannot write temporary file!")); return; } bool backup=false; burnDialog *cd = new burnDialog(this, 1, &tempFile, &backup,strippedName(curFile)); cd->exec(); if (!tempFile.isEmpty()) { if (backup) { if (backupEnable) { QString backupFile=backupPath+"/backup-"+QDateTime().currentDateTime().toString("yyyy-MM-dd-HHmmss")+".bin"; if (!((MainWindow *)this->parent())->readEepromFromRadio(backupFile, tr("Backup EEPROM From Radio"))) return; } int oldrev=((MainWindow *)this->parent())->getEpromVersion(tempFile); QString tempFlash = generateProcessUniqueTempFileName("flash.bin"); if (!((MainWindow *)this->parent())->readFirmwareFromRadio(tempFlash)) return; QString restoreFile = generateProcessUniqueTempFileName("compat.bin"); if (!((MainWindow *)this->parent())->convertEEPROM(tempFile, restoreFile, tempFlash)) { int ret = QMessageBox::question(this, tr("Error"), tr("Cannot check eeprom compatibility! Continue anyway?"), QMessageBox::Yes | QMessageBox::No); if (ret == QMessageBox::No) return; } else { int rev=((MainWindow *)this->parent())->getEpromVersion(restoreFile); if ((rev/100)!=(oldrev/100)) { QMessageBox::warning(this,tr("Warning"), tr("Firmware in radio is of a different family of eeprom written, check file and preferences!")); } if (rev<oldrev) { QMessageBox::warning(this,tr("Warning"), tr("Firmware in flash is outdated, please upgrade!")); } tempFile=restoreFile; } qunlink(tempFlash); } else { if (backupEnable) { QString backupFile=backupPath+"/backup-"+QDateTime().currentDateTime().toString("yyyy-MM-dd-hhmmss")+".bin"; if (!((MainWindow *)this->parent())->readEepromFromRadio(backupFile, tr("Backup EEPROM From Radio"))) return; } } if (!((MainWindow *)this->parent())->writeEepromToRadio(tempFile, tr("Write EEPROM To Radio"))) return; } }
QString MdiChild::userFriendlyCurrentFile() { return strippedName(curFile); }
QString MdiChild::userFriendlyCurrentFile() { return strippedName(QString( FaceObject->getPath().c_str() )); }
QString npcedit::userFriendlyCurrentFile() { return strippedName(curFile); }
QString CodeEditor::userFriendlyCurrentFile() { return strippedName(m_curFile); }
QString MapWindow::userFriendlyCurrentFile(void) { return mapData.name() + " (" + strippedName(curFile) + ")"; }
QString SyntaxTextEditor::userFriendlyCurrentFile() { return strippedName(curFile); }
/* FUNCTION: setupSimulationResultsTree */ void ResultsWindow::setupSimulationResultsTree(void) { NXDataStoreInfo *dataStoreInfo = entityManager->getDataStoreInfo(); QWidget *tab1Widget = tabWidget->widget(0); resultsTree = dynamic_cast<QTreeWidget*>(tab1Widget); resultsTree->clear(); QTreeWidgetItem* rootNode = new QTreeWidgetItem(resultsTree); rootNode->setText(0, userFriendlyCurrentFile()); rootNode->setIcon(0, nh5FileIcon); rootNode->setFlags(Qt::ItemIsEnabled); rootNode->setExpanded(true); resultsTree->addTopLevelItem(rootNode); // input parameters NXProperties *inputParameters = dataStoreInfo->getInputParameters(); if (inputParameters != NULL) { DataWindowTreeItem* inputParametersItem = new InputParametersTreeItem(this, rootNode); inputParametersItem->setIcon(0, inputParametersIcon); inputParametersItem->setText(0, tr("Input parameters")); inputParametersItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); } // input files vector<string> inputFileNames = dataStoreInfo->getInputFileNames(); if (inputFileNames.size() > 0) { QTreeWidgetItem *inputFilesItem = new QTreeWidgetItem(rootNode); inputFilesItem->setIcon(0, inputFilesIcon); inputFilesItem->setText(0, tr("Input files")); inputFilesItem->setFlags(Qt::ItemIsEnabled); inputFilesItem->setExpanded(true); vector<string>::const_iterator inputFileNameIter; for (inputFileNameIter = inputFileNames.begin(); inputFileNameIter != inputFileNames.end(); ++inputFileNameIter) { QTreeWidgetItem *inputFileItem = new QTreeWidgetItem(inputFilesItem); inputFileItem->setIcon(0, inputFileIcon); inputFileItem->setText (0, strippedName(QString(inputFileNameIter->c_str()))); inputFileItem->setFlags(Qt::ItemIsEnabled); // inputFilesItem->addChild(inputFileItem); if(isMMPFile(*inputFileNameIter)) { int mmpFileFrameSetId = dataStoreInfo->getInputStructureId(*inputFileNameIter); if (mmpFileFrameSetId > -1) { NXMoleculeSet *rootMoleculeSet = entityManager->getRootMoleculeSet(mmpFileFrameSetId, 0); setupMoleculeSetResultsSubtree(rootMoleculeSet, inputFileItem); } else { // TODO: handle this } } } } // Results NXProperties *resultsSummary = dataStoreInfo->getResultsSummary(); vector<string> trajectoryNames = dataStoreInfo->getTrajectoryNames(); // don't create if no children if (resultsSummary == NULL && trajectoryNames.size()==0) return; QTreeWidgetItem *resultsItem = new QTreeWidgetItem(rootNode); resultsItem->setIcon(0, resultsIcon); resultsItem->setText(0, tr("Results")); resultsItem->setFlags(Qt::ItemIsEnabled); resultsItem->setExpanded(true); // Results -> Summary DataWindowTreeItem* resultsSummaryItem = NULL; if (resultsSummary != NULL) { resultsSummaryItem = new ResultsSummaryTreeItem(this, resultsItem); resultsSummaryItem->setText(0, tr("Summary")); resultsSummaryItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); } // Results -> Trajectories if (trajectoryNames.size() > 0) { QTreeWidgetItem *trajectoryItem = new QTreeWidgetItem(resultsItem); trajectoryItem->setIcon(0, resultsTrajectoriesIcon); trajectoryItem->setText(0, tr("Trajectories")); trajectoryItem->setFlags(Qt::ItemIsEnabled); trajectoryItem->setExpanded(true); vector<string>::const_iterator trajectoryNameIter; for (trajectoryNameIter = trajectoryNames.begin(); trajectoryNameIter != trajectoryNames.end(); ++trajectoryNameIter) { TrajectoryGraphicsTreeItem* trajectoryNameItem = new TrajectoryGraphicsTreeItem(*trajectoryNameIter, this, trajectoryItem); trajectoryNameItem->setIcon(0, resultsTrajectoriesIcon); trajectoryNameItem->setText(0, QString(trajectoryNameIter->c_str())); trajectoryNameItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); // trajectoryItem->addChild(trajectoryNameItem); // Show some graphics right away if (trajectoryNameIter == trajectoryNames.begin()) trajectoryNameItem->showWindow(); // Signal the results summary window once the data store is // complete so it can refresh itself int trajectoryId = dataStoreInfo->getTrajectoryId(*trajectoryNameIter); if ((resultsSummaryItem != NULL) && (!dataStoreInfo->storeIsComplete(trajectoryId))) { /// @todo: This code will need to be a little smarter once we support multiple /// trajectories and such. As it stands, it would make multiple identical signal- /// slot connections. QObject::connect(entityManager, SIGNAL(dataStoreComplete()), resultsSummaryItem, SLOT(refresh())); ((ResultsSummaryTreeItem*)resultsSummaryItem) ->setTrajectoryId(trajectoryId); resultsSummaryItem->refresh(); } } } }
//////// Common QString WLD_SetPoint::userFriendlyCurrentFile() { return strippedName(curFile); }
QString MdiChild::userFriendlyCurrentFile() { return strippedName(_document->fileName()); }
QString tva::Doc::userFriendlyCurrentFile() { return strippedName(curFile); }