| 1182 | } |
| 1183 | |
| 1184 | void 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 | |
| 1214 | void LibraryWindow::deleteSelectedFolder() |
| 1215 | { |
nothing calls this directly
no test coverage detected