diff --git a/YACReaderLibrary/db/treemodel.cpp b/YACReaderLibrary/db/treemodel.cpp index bb5e571f..16aecd03 100644 --- a/YACReaderLibrary/db/treemodel.cpp +++ b/YACReaderLibrary/db/treemodel.cpp @@ -622,7 +622,7 @@ void TreeModel::fetchMoreFromDB(const QModelIndex &parent) QSqlDatabase::removeDatabase(_databasePath); } -void TreeModel::addFolderAtParent(const QString &folderName, const QModelIndex &parent) +QModelIndex TreeModel::addFolderAtParent(const QString &folderName, const QModelIndex &parent) { TreeItem * parentItem; @@ -645,8 +645,8 @@ void TreeModel::addFolderAtParent(const QString &folderName, const QModelIndex & QList data; data << newFolder.name; data << newFolder.path; - data << false; - data << false; + data << false; //finished + data << true; //completed TreeItem * item = new TreeItem(data); item->id = newFolder.id; @@ -656,6 +656,10 @@ void TreeModel::addFolderAtParent(const QString &folderName, const QModelIndex & beginInsertRows(parent,destRow,destRow); endInsertRows(); + + items.insert(item->id,item); + + return index(destRow,0,parent); } void TreeModel::deleteFolder(const QModelIndex &mi) diff --git a/YACReaderLibrary/db/treemodel.h b/YACReaderLibrary/db/treemodel.h index b15119d6..0242dba2 100644 --- a/YACReaderLibrary/db/treemodel.h +++ b/YACReaderLibrary/db/treemodel.h @@ -89,7 +89,7 @@ public: void fetchMoreFromDB(const QModelIndex & parent); - void addFolderAtParent(const QString & folderName, const QModelIndex & parent); + QModelIndex addFolderAtParent(const QString & folderName, const QModelIndex & parent); enum Columns { Name = 0, diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index c65bbfc8..676dfe7f 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -1484,7 +1484,10 @@ void LibraryWindow::addFolderToCurrentIndex() QDir parentDir(parentPath); QDir newFolder(parentPath+"/"+newFolderName); if(parentDir.mkdir(newFolderName) || newFolder.exists()) - foldersModel->addFolderAtParent(newFolderName,currentIndex); + { + foldersView->setCurrentIndex(foldersModel->addFolderAtParent(newFolderName,currentIndex)); + reloadCovers(); + } } void LibraryWindow::deleteSelectedFolder()