mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
added DataIndexes to ItemList classes
This commit is contained in:
parent
c4022cf9bd
commit
e576bebc2a
@ -228,7 +228,10 @@ bool DataBaseManagement::createV8Tables(QSqlDatabase &database)
|
||||
//8.0> tables
|
||||
//LABEL
|
||||
QSqlQuery queryLabel(database);
|
||||
queryLabel.prepare("CREATE TABLE label (id INTEGER PRIMARY KEY, name TEXT NOT NULL, color TEXT NOT NULL, ordering INTEGER NOT NULL)"); //order depends on the color
|
||||
queryLabel.prepare("CREATE TABLE label (id INTEGER PRIMARY KEY, "
|
||||
"name TEXT NOT NULL, "
|
||||
"color TEXT NOT NULL, "
|
||||
"ordering INTEGER NOT NULL)"); //order depends on the color
|
||||
success = success && queryLabel.exec();
|
||||
|
||||
//COMIC LABEL
|
||||
|
@ -31,18 +31,18 @@ SpecialListItem::SpecialListItem(const QList<QVariant> &data)
|
||||
|
||||
QIcon SpecialListItem::getIcon() const
|
||||
{
|
||||
if(itemData.count()>1)
|
||||
if(itemData.count()>Id)
|
||||
{
|
||||
QString id = itemData.at(1).toString();
|
||||
QString id = itemData.at(Id).toString();
|
||||
return YACReader::noHighlightedIcon(QString(":/images/lists/default_%1.png").arg(id));
|
||||
}
|
||||
}
|
||||
|
||||
ReadingListModel::TypeSpecialList SpecialListItem::getType() const
|
||||
{
|
||||
if(itemData.count()>1)
|
||||
if(itemData.count()>Id)
|
||||
{
|
||||
int id = itemData.at(1).toInt();
|
||||
int id = itemData.at(Id).toInt();
|
||||
return (ReadingListModel::TypeSpecialList)id;
|
||||
}
|
||||
}
|
||||
@ -57,39 +57,42 @@ LabelItem::LabelItem(const QList<QVariant> &data)
|
||||
|
||||
QIcon LabelItem::getIcon() const
|
||||
{
|
||||
if(itemData.count()>1)
|
||||
if(itemData.count()>Color)
|
||||
{
|
||||
QString color = itemData.at(1).toString();
|
||||
QString color = itemData.at(Color).toString();
|
||||
return YACReader::noHighlightedIcon(QString(":/images/lists/label_%1.png").arg(color).toLower());
|
||||
}
|
||||
}
|
||||
|
||||
YACReader::LabelColors LabelItem::colorid() const
|
||||
{
|
||||
if(itemData.count()>3)
|
||||
if(itemData.count()>Ordering)
|
||||
{
|
||||
return YACReader::LabelColors(itemData.at(3).toInt());
|
||||
return YACReader::LabelColors(itemData.at(Ordering).toInt());
|
||||
}
|
||||
}
|
||||
|
||||
QString LabelItem::name() const
|
||||
{
|
||||
if(itemData.count()>0)
|
||||
if(itemData.count()>Name)
|
||||
{
|
||||
return itemData.at(0).toString();
|
||||
return itemData.at(Name).toString();
|
||||
}
|
||||
}
|
||||
|
||||
void LabelItem::setName(const QString &name)
|
||||
{
|
||||
itemData[0] = name;
|
||||
if(itemData.count()>Name)
|
||||
{
|
||||
itemData[Name] = name;
|
||||
}
|
||||
}
|
||||
|
||||
qulonglong LabelItem::getId() const
|
||||
{
|
||||
if(itemData.count()>2)
|
||||
if(itemData.count()>Id)
|
||||
{
|
||||
return YACReader::LabelColors(itemData.at(2).toULongLong());
|
||||
return YACReader::LabelColors(itemData.at(Id).toULongLong());
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,9 +107,9 @@ ReadingListItem::ReadingListItem(const QList<QVariant> &data, ReadingListItem *p
|
||||
QIcon ReadingListItem::getIcon() const
|
||||
{
|
||||
if(parent->getId() == 0)
|
||||
return YACReader::noHighlightedIcon(":/images/lists/list.png");
|
||||
return YACReader::noHighlightedIcon(":/images/lists/list.png"); //top level list
|
||||
else
|
||||
return YACReader::noHighlightedIcon(":/images/folder.png");
|
||||
return YACReader::noHighlightedIcon(":/images/folder.png"); //sublist
|
||||
}
|
||||
|
||||
int ReadingListItem::childCount() const
|
||||
@ -168,23 +171,32 @@ void ReadingListItem::removeChild(ReadingListItem *item)
|
||||
|
||||
qulonglong ReadingListItem::getId() const
|
||||
{
|
||||
if(itemData.count()>1)
|
||||
{
|
||||
return itemData.at(1).toULongLong();
|
||||
}
|
||||
if(itemData.count()>Id)
|
||||
return itemData.at(Id).toULongLong();
|
||||
}
|
||||
|
||||
QString ReadingListItem::name() const
|
||||
{
|
||||
if(itemData.count()>0)
|
||||
{
|
||||
return itemData.at(0).toString();
|
||||
}
|
||||
if(itemData.count()>Name)
|
||||
return itemData.at(Name).toString();
|
||||
}
|
||||
|
||||
void ReadingListItem::setName(const QString &name)
|
||||
{
|
||||
itemData[0] = name;
|
||||
if(itemData.count()>Name)
|
||||
itemData[Name] = name;
|
||||
}
|
||||
|
||||
int ReadingListItem::getOrdering() const
|
||||
{
|
||||
if(itemData.count()>Ordering)
|
||||
return itemData[Ordering].toInt();
|
||||
}
|
||||
|
||||
void ReadingListItem::setOrdering(const int ordering)
|
||||
{
|
||||
if(itemData.count()>Ordering)
|
||||
itemData[Ordering] = ordering;
|
||||
}
|
||||
|
||||
QList<ReadingListItem *> ReadingListItem::children()
|
||||
|
@ -27,6 +27,12 @@ public:
|
||||
SpecialListItem(const QList<QVariant> &data);
|
||||
QIcon getIcon() const;
|
||||
ReadingListModel::TypeSpecialList getType() const;
|
||||
private:
|
||||
enum DataIndexes {
|
||||
Name,
|
||||
Id
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
//------------------------------------------------------
|
||||
@ -41,6 +47,14 @@ public:
|
||||
void setName(const QString & name);
|
||||
qulonglong getId() const;
|
||||
|
||||
|
||||
private:
|
||||
enum DataIndexes {
|
||||
Name,
|
||||
Color,
|
||||
Id,
|
||||
Ordering
|
||||
};
|
||||
};
|
||||
|
||||
//------------------------------------------------------
|
||||
@ -59,12 +73,21 @@ public:
|
||||
qulonglong getId() const;
|
||||
QString name() const;
|
||||
void setName(const QString & name);
|
||||
|
||||
int getOrdering() const;
|
||||
void setOrdering(const int ordering);
|
||||
QList<ReadingListItem*> children();
|
||||
|
||||
private:
|
||||
QList<ReadingListItem*> childItems;
|
||||
|
||||
enum DataIndexes {
|
||||
Name,
|
||||
Id,
|
||||
Finished,
|
||||
Completed,
|
||||
Ordering
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
//------------------------------------------------------
|
||||
|
@ -497,7 +497,7 @@ QList<SpecialListItem *> ReadingListModel::setupSpecialLists(QSqlDatabase & db)
|
||||
<< record.value("id"));
|
||||
}
|
||||
|
||||
//Reading after Favorites, Why? Because I want :P
|
||||
//Reading after Favorites, Why? Because I want to :P
|
||||
list.insert(1,new SpecialListItem(QList<QVariant>() << "Reading" << 0));
|
||||
|
||||
return list;
|
||||
@ -508,7 +508,11 @@ void ReadingListModel::setupLabels(QSqlDatabase & db)
|
||||
QSqlQuery selectQuery("SELECT * FROM label ORDER BY ordering,name",db); //TODO add some kind of
|
||||
while(selectQuery.next()) {
|
||||
QSqlRecord record = selectQuery.record();
|
||||
addLabelIntoList(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
|
||||
|
Loading…
Reference in New Issue
Block a user