mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
fixed adding label and sorting on setup
This commit is contained in:
parent
f95d6715fa
commit
5ec03916fb
@ -195,7 +195,7 @@ void ReadingListModel::setupReadingListsData(QString path)
|
|||||||
//separator--------------------------------------------
|
//separator--------------------------------------------
|
||||||
|
|
||||||
//setup labels
|
//setup labels
|
||||||
labels = setupLabels(db);
|
setupLabels(db);
|
||||||
|
|
||||||
//separator--------------------------------------------
|
//separator--------------------------------------------
|
||||||
|
|
||||||
@ -389,14 +389,12 @@ QList<SpecialListItem *> ReadingListModel::setupSpecialLists(QSqlDatabase & db)
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<LabelItem *> ReadingListModel::setupLabels(QSqlDatabase & db)
|
void ReadingListModel::setupLabels(QSqlDatabase & db)
|
||||||
{
|
{
|
||||||
QList<LabelItem *> list;
|
|
||||||
|
|
||||||
QSqlQuery selectQuery("SELECT * FROM label ORDER BY ordering,name",db); //TODO add some kind of
|
QSqlQuery selectQuery("SELECT * FROM label ORDER BY ordering,name",db); //TODO add some kind of
|
||||||
while(selectQuery.next()) {
|
while(selectQuery.next()) {
|
||||||
QSqlRecord record = selectQuery.record();
|
QSqlRecord record = selectQuery.record();
|
||||||
list << new LabelItem(QList<QVariant>() << record.value("name") << record.value("color") << record.value("id") << record.value("ordering"));
|
addLabelIntoList(new LabelItem(QList<QVariant>() << record.value("name") << record.value("color") << record.value("id") << record.value("ordering")));
|
||||||
}
|
}
|
||||||
|
|
||||||
//TEST
|
//TEST
|
||||||
@ -414,7 +412,6 @@ QList<LabelItem *> ReadingListModel::setupLabels(QSqlDatabase & db)
|
|||||||
// INSERT INTO label (name, color, ordering) VALUES ("ainsss", "light", 11);
|
// INSERT INTO label (name, color, ordering) VALUES ("ainsss", "light", 11);
|
||||||
// INSERT INTO label (name, color, ordering) VALUES ("put a smile on my face", "dark", 12);
|
// INSERT INTO label (name, color, ordering) VALUES ("put a smile on my face", "dark", 12);
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadingListModel::setupReadingLists(QSqlDatabase & db)
|
void ReadingListModel::setupReadingLists(QSqlDatabase & db)
|
||||||
@ -450,16 +447,20 @@ int ReadingListModel::addLabelIntoList(LabelItem *item)
|
|||||||
{
|
{
|
||||||
if(labels.at(i)->colorid() == item->colorid()) //sort by name
|
if(labels.at(i)->colorid() == item->colorid()) //sort by name
|
||||||
{
|
{
|
||||||
while( i < labels.count() && naturalSortLessThanCI(labels.at(i)->name(),item->name()))
|
while( i < labels.count() && labels.at(i)->colorid() == item->colorid() && naturalSortLessThanCI(labels.at(i)->name(),item->name()))
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(i >= labels.count())
|
if(i >= labels.count())
|
||||||
|
{
|
||||||
|
QLOG_DEBUG() << "insertando label al final " << item->name();
|
||||||
labels << item;
|
labels << item;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
QLOG_DEBUG() << "insertando label en " << i << "-" << item->name();
|
||||||
labels.insert(i,item);
|
labels.insert(i,item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ private:
|
|||||||
void cleanAll();
|
void cleanAll();
|
||||||
void setupReadingListsData(QSqlQuery &sqlquery, ReadingListItem *parent);
|
void setupReadingListsData(QSqlQuery &sqlquery, ReadingListItem *parent);
|
||||||
QList<SpecialListItem *> setupSpecialLists(QSqlDatabase &db);
|
QList<SpecialListItem *> setupSpecialLists(QSqlDatabase &db);
|
||||||
QList<LabelItem *> setupLabels(QSqlDatabase &db);
|
void setupLabels(QSqlDatabase &db);
|
||||||
void setupReadingLists(QSqlDatabase &db);
|
void setupReadingLists(QSqlDatabase &db);
|
||||||
int addLabelIntoList(LabelItem *item);
|
int addLabelIntoList(LabelItem *item);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user