mirror of
https://github.com/YACReader/yacreader
synced 2025-07-21 22:44:56 -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);
|
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)
|
QString ReadingListModel::name(const QModelIndex &mi)
|
||||||
{
|
{
|
||||||
return data(mi,Qt::DisplayRole).toString();
|
return data(mi,Qt::DisplayRole).toString();
|
||||||
|
@ -48,6 +48,7 @@ public:
|
|||||||
void addReadingListAt(const QString & name, const QModelIndex & mi);
|
void addReadingListAt(const QString & name, const QModelIndex & mi);
|
||||||
bool isEditable(const QModelIndex & mi);
|
bool isEditable(const QModelIndex & mi);
|
||||||
bool isReadingList(const QModelIndex & mi);
|
bool isReadingList(const QModelIndex & mi);
|
||||||
|
bool isReadingSubList(const QModelIndex & mi);
|
||||||
QString name(const QModelIndex & mi);
|
QString name(const QModelIndex & mi);
|
||||||
void rename(const QModelIndex & mi, const QString & name);
|
void rename(const QModelIndex & mi, const QString & name);
|
||||||
void deleteItem(const QModelIndex & mi);
|
void deleteItem(const QModelIndex & mi);
|
||||||
|
@ -1560,16 +1560,18 @@ void LibraryWindow::errorDeletingFolder()
|
|||||||
|
|
||||||
void LibraryWindow::addNewReadingList()
|
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();
|
QModelIndexList selectedLists = listsView->selectionModel()->selectedIndexes();
|
||||||
QModelIndex sourceMI;
|
QModelIndex sourceMI;
|
||||||
if(!selectedLists.isEmpty())
|
if(!selectedLists.isEmpty())
|
||||||
sourceMI = listsModelProxy->mapToSource(selectedLists.at(0));
|
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))
|
if(selectedLists.isEmpty() || !listsModel->isReadingList(sourceMI))
|
||||||
listsModel->addReadingList(newListName); //top level
|
listsModel->addReadingList(newListName); //top level
|
||||||
else
|
else
|
||||||
@ -1578,6 +1580,7 @@ void LibraryWindow::addNewReadingList()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void LibraryWindow::deleteSelectedReadingList()
|
void LibraryWindow::deleteSelectedReadingList()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user