MCPcopy Create free account
hub / github.com/dail8859/NotepadNext / renameFile

Method renameFile

src/dialogs/MainWindow.cpp:1473–1503  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1471}
1472
1473void MainWindow::renameFile()
1474{
1475 ScintillaNext *editor = currentEditor();
1476
1477 if (editor->isFile()) {
1478 const QString filter = app->getFileDialogFilter();
1479 QString selectedFilter = app->getFileDialogFilterForLanguage(editor->languageName);
1480 QString fileName = FileDialogHelpers::getSaveFileName(this, tr("Rename"), defaultDirectoryManager->getDefaultDirectory(), filter, &selectedFilter);
1481
1482 if (fileName.isEmpty()) {
1483 return;
1484 }
1485
1486 emit fileDialogAccepted(fileName);
1487
1488 // TODO
1489 // The new fileName might be to one of the existing editors.
1490 //auto otherEditor = app->getEditorByFilePath(fileName);
1491
1492 bool renameSuccessful = editor->rename(fileName);
1493 Q_UNUSED(renameSuccessful)
1494 }
1495 else {
1496 bool ok;
1497 QString text = QInputDialog::getText(this, tr("Rename"), tr("Name:"), QLineEdit::Normal, editor->getName(), &ok);
1498
1499 if (ok && !text.isEmpty()) {
1500 editor->setName(text);
1501 }
1502 }
1503}
1504
1505void MainWindow::moveCurrentFileToTrash()
1506{

Callers

nothing calls this directly

Calls 8

isFileMethod · 0.80
getFileDialogFilterMethod · 0.80
getDefaultDirectoryMethod · 0.80
isEmptyMethod · 0.80
renameMethod · 0.80
getNameMethod · 0.45
setNameMethod · 0.45

Tested by

no test coverage detected