new folders are selected automatically after creation

fixed a couple of bugs in TreeModel::addFolderAtParent
This commit is contained in:
Luis Ángel San Martín
2014-10-22 21:16:43 +02:00
parent a5705861bc
commit e9a487db5e
3 changed files with 12 additions and 5 deletions

View File

@ -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)

View File

@ -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,

View File

@ -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()