mirror of
https://github.com/YACReader/yacreader
synced 2025-07-21 06:24:39 -04:00
only one level of sublists are allowed
This commit is contained in:
@ -369,6 +369,23 @@ bool ReadingListModel::isReadingList(const QModelIndex &mi)
|
||||
return typeid(*item) == typeid(ReadingListItem);
|
||||
}
|
||||
|
||||
bool ReadingListModel::isReadingSubList(const QModelIndex &mi)
|
||||
{
|
||||
if(!mi.isValid())
|
||||
return false;
|
||||
ListItem * item = static_cast<ListItem*>(mi.internalPointer());
|
||||
if(typeid(*item) == typeid(ReadingListItem))
|
||||
{
|
||||
ReadingListItem * readingListItem = static_cast<ReadingListItem *>(item);
|
||||
if(readingListItem->parent == rootItem)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
QString ReadingListModel::name(const QModelIndex &mi)
|
||||
{
|
||||
return data(mi,Qt::DisplayRole).toString();
|
||||
|
@ -48,6 +48,7 @@ public:
|
||||
void addReadingListAt(const QString & name, const QModelIndex & mi);
|
||||
bool isEditable(const QModelIndex & mi);
|
||||
bool isReadingList(const QModelIndex & mi);
|
||||
bool isReadingSubList(const QModelIndex & mi);
|
||||
QString name(const QModelIndex & mi);
|
||||
void rename(const QModelIndex & mi, const QString & name);
|
||||
void deleteItem(const QModelIndex & mi);
|
||||
|
@ -1560,16 +1560,18 @@ void LibraryWindow::errorDeletingFolder()
|
||||
|
||||
void LibraryWindow::addNewReadingList()
|
||||
{
|
||||
bool ok;
|
||||
QString newListName = QInputDialog::getText(this, tr("Add new reading lists"),
|
||||
tr("List name:"), QLineEdit::Normal,
|
||||
"", &ok);
|
||||
|
||||
if (ok) {
|
||||
QModelIndexList selectedLists = listsView->selectionModel()->selectedIndexes();
|
||||
QModelIndex sourceMI;
|
||||
if(!selectedLists.isEmpty())
|
||||
sourceMI = listsModelProxy->mapToSource(selectedLists.at(0));
|
||||
|
||||
if(selectedLists.isEmpty() || !listsModel->isReadingSubList(sourceMI) )
|
||||
{
|
||||
bool ok;
|
||||
QString newListName = QInputDialog::getText(this, tr("Add new reading lists"),
|
||||
tr("List name:"), QLineEdit::Normal,
|
||||
"", &ok);
|
||||
if (ok) {
|
||||
if(selectedLists.isEmpty() || !listsModel->isReadingList(sourceMI))
|
||||
listsModel->addReadingList(newListName); //top level
|
||||
else
|
||||
@ -1577,6 +1579,7 @@ void LibraryWindow::addNewReadingList()
|
||||
listsModel->addReadingListAt(newListName,sourceMI); //sublist
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LibraryWindow::deleteSelectedReadingList()
|
||||
|
Reference in New Issue
Block a user