From b9cc52bf23fa453ee093704961f8a1e40e4663de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sun, 11 Jan 2015 12:31:13 +0100 Subject: [PATCH] fixed issues creating first label and first reading list --- YACReaderLibrary/db/reading_list_model.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/YACReaderLibrary/db/reading_list_model.cpp b/YACReaderLibrary/db/reading_list_model.cpp index 8a825e96..8124e26e 100644 --- a/YACReaderLibrary/db/reading_list_model.cpp +++ b/YACReaderLibrary/db/reading_list_model.cpp @@ -19,7 +19,7 @@ int ReadingListModel::rowCount(const QModelIndex &parent) const { 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; } else @@ -132,7 +132,7 @@ QModelIndex ReadingListModel::index(int row, int column, const QModelIndex &pare if(!parent.isValid()) { - int separatorsCount = labels.isEmpty()?1:2; + int separatorsCount = 2;//labels.isEmpty()?1:2; if(rowIsSpecialList(row,parent)) return createIndex(row, column, specialLists.at(row)); @@ -302,6 +302,8 @@ void ReadingListModel::addReadingList(const QString &name) { QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath); + beginInsertRows(QModelIndex(), 0, 0); //TODO calculate the right coordinates before inserting + qulonglong id = DBHelper::insertReadingList(name,db); ReadingListItem * newItem; rootItem->appendChild(newItem = new ReadingListItem(QList() @@ -313,11 +315,11 @@ void ReadingListModel::addReadingList(const QString &name) 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(); QSqlDatabase::removeDatabase(_databasePath); @@ -343,9 +345,9 @@ void ReadingListModel::addReadingListAt(const QString &name, const QModelIndex & 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();