mirror of
https://github.com/YACReader/yacreader
synced 2025-07-22 15:04:40 -04:00
new folders are selected automatically after creation
fixed a couple of bugs in TreeModel::addFolderAtParent
This commit is contained in:
@ -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<QVariant> 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)
|
||||
|
@ -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,
|
||||
|
@ -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()
|
||||
|
Reference in New Issue
Block a user