MCPcopy Create free account
hub / github.com/YACReader/yacreader / addFolderToCurrentIndex

Method addFolderToCurrentIndex

YACReaderLibrary/library_window.cpp:1184–1212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1182}
1183
1184void LibraryWindow::addFolderToCurrentIndex()
1185{
1186 exitSearchMode(); // Creating a folder in search mode is broken => exit it.
1187
1188 QModelIndex currentIndex = getCurrentFolderIndex();
1189
1190 bool ok;
1191 QString newFolderName = QInputDialog::getText(this, tr("Add new folder"),
1192 tr("Folder name:"), QLineEdit::Normal,
1193 "", &ok);
1194
1195 // chars not supported in a folder's name: / \ : * ? " < > |
1196 QRegularExpression invalidChars("\\/\\:\\*\\?\\\"\\<\\>\\|\\\\"); // TODO this regexp is not properly written
1197 bool isValid = !newFolderName.contains(invalidChars);
1198
1199 if (ok && !newFolderName.isEmpty() && isValid) {
1200 QString parentPath = QDir::cleanPath(currentPath() + foldersModel->getFolderPath(currentIndex));
1201 QDir parentDir(parentPath);
1202 QDir newFolder(parentPath + "/" + newFolderName);
1203 if (parentDir.mkdir(newFolderName) || newFolder.exists()) {
1204 QModelIndex newIndex = foldersModel->addFolderAtParent(newFolderName, currentIndex);
1205 foldersView->setCurrentIndex(foldersModelProxy->mapFromSource(newIndex));
1206 navigationController->loadFolderInfo(newIndex);
1207 historyController->updateHistory(YACReaderLibrarySourceContainer(newIndex, YACReaderLibrarySourceContainer::Folder));
1208 // a new folder is always an empty folder
1209 contentViewsManager->showFolderContentView();
1210 }
1211 }
1212}
1213
1214void LibraryWindow::deleteSelectedFolder()
1215{

Callers

nothing calls this directly

Calls 9

isEmptyMethod · 0.80
getFolderPathMethod · 0.80
addFolderAtParentMethod · 0.80
loadFolderInfoMethod · 0.80
updateHistoryMethod · 0.80
showFolderContentViewMethod · 0.80
containsMethod · 0.45
setCurrentIndexMethod · 0.45

Tested by

no test coverage detected