mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
fixed issues creating first label and first reading list
This commit is contained in:
parent
532b0a0e20
commit
b9cc52bf23
@ -19,7 +19,7 @@ int ReadingListModel::rowCount(const QModelIndex &parent) const
|
|||||||
{
|
{
|
||||||
if(!parent.isValid()) //TOP
|
if(!parent.isValid()) //TOP
|
||||||
{
|
{
|
||||||
int separatorsCount = labels.isEmpty()?1:2;
|
int separatorsCount = 2;//labels.isEmpty()?1:2;
|
||||||
return specialLists.count() + labels.count() + rootItem->childCount() + separatorsCount;
|
return specialLists.count() + labels.count() + rootItem->childCount() + separatorsCount;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -132,7 +132,7 @@ QModelIndex ReadingListModel::index(int row, int column, const QModelIndex &pare
|
|||||||
|
|
||||||
if(!parent.isValid())
|
if(!parent.isValid())
|
||||||
{
|
{
|
||||||
int separatorsCount = labels.isEmpty()?1:2;
|
int separatorsCount = 2;//labels.isEmpty()?1:2;
|
||||||
|
|
||||||
if(rowIsSpecialList(row,parent))
|
if(rowIsSpecialList(row,parent))
|
||||||
return createIndex(row, column, specialLists.at(row));
|
return createIndex(row, column, specialLists.at(row));
|
||||||
@ -302,6 +302,8 @@ void ReadingListModel::addReadingList(const QString &name)
|
|||||||
{
|
{
|
||||||
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
|
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
|
||||||
|
|
||||||
|
beginInsertRows(QModelIndex(), 0, 0); //TODO calculate the right coordinates before inserting
|
||||||
|
|
||||||
qulonglong id = DBHelper::insertReadingList(name,db);
|
qulonglong id = DBHelper::insertReadingList(name,db);
|
||||||
ReadingListItem * newItem;
|
ReadingListItem * newItem;
|
||||||
rootItem->appendChild(newItem = new ReadingListItem(QList<QVariant>()
|
rootItem->appendChild(newItem = new ReadingListItem(QList<QVariant>()
|
||||||
@ -313,11 +315,11 @@ void ReadingListModel::addReadingList(const QString &name)
|
|||||||
|
|
||||||
items.insert(id, newItem);
|
items.insert(id, newItem);
|
||||||
|
|
||||||
int pos = rootItem->children().indexOf(newItem);
|
/*int pos = rootItem->children().indexOf(newItem);
|
||||||
|
|
||||||
|
pos += specialLists.count()+1+labels.count()+labels.count()>0?1:0;*/
|
||||||
|
|
||||||
pos += specialLists.count()+1+labels.count()+labels.count()>0?1:0;
|
|
||||||
|
|
||||||
beginInsertRows(QModelIndex(), pos, pos);
|
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
|
||||||
QSqlDatabase::removeDatabase(_databasePath);
|
QSqlDatabase::removeDatabase(_databasePath);
|
||||||
@ -343,9 +345,9 @@ void ReadingListModel::addReadingListAt(const QString &name, const QModelIndex &
|
|||||||
|
|
||||||
items.insert(id, newItem);
|
items.insert(id, newItem);
|
||||||
|
|
||||||
int pos = readingListParent->children().indexOf(newItem);
|
/*int pos = readingListParent->children().indexOf(newItem);
|
||||||
|
|
||||||
pos += specialLists.count()+1+labels.count()+labels.count()>0?1:0;
|
pos += specialLists.count()+1+labels.count()+labels.count()>0?1:0;*/
|
||||||
|
|
||||||
|
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user