mirror of
https://github.com/YACReader/yacreader
synced 2025-07-23 23:44:52 -04:00
renaming lists working for labels
This commit is contained in:
@ -16,6 +16,11 @@ QVariant ListItem::data(int column) const
|
||||
return itemData.at(column);
|
||||
}
|
||||
|
||||
qulonglong ListItem::getId() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
|
||||
SpecialListItem::SpecialListItem(const QList<QVariant> &data)
|
||||
@ -50,7 +55,7 @@ QIcon LabelItem::getIcon() const
|
||||
}
|
||||
}
|
||||
|
||||
YACReader::LabelColors LabelItem::colorid()
|
||||
YACReader::LabelColors LabelItem::colorid() const
|
||||
{
|
||||
if(itemData.count()>3)
|
||||
{
|
||||
@ -58,7 +63,7 @@ YACReader::LabelColors LabelItem::colorid()
|
||||
}
|
||||
}
|
||||
|
||||
QString LabelItem::name()
|
||||
QString LabelItem::name() const
|
||||
{
|
||||
if(itemData.count()>0)
|
||||
{
|
||||
@ -66,6 +71,19 @@ QString LabelItem::name()
|
||||
}
|
||||
}
|
||||
|
||||
void LabelItem::setName(const QString &name)
|
||||
{
|
||||
itemData[0] = name;
|
||||
}
|
||||
|
||||
qulonglong LabelItem::getId() const
|
||||
{
|
||||
if(itemData.count()>2)
|
||||
{
|
||||
return YACReader::LabelColors(itemData.at(2).toULongLong());
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
|
||||
ReadingListItem::ReadingListItem(const QList<QVariant> &data, ReadingListItem *p)
|
||||
@ -124,6 +142,27 @@ void ReadingListItem::appendChild(ReadingListItem *item)
|
||||
|
||||
}
|
||||
|
||||
qulonglong ReadingListItem::getId() const
|
||||
{
|
||||
if(itemData.count()>1)
|
||||
{
|
||||
return YACReader::LabelColors(itemData.at(1).toULongLong());
|
||||
}
|
||||
}
|
||||
|
||||
QString ReadingListItem::name() const
|
||||
{
|
||||
if(itemData.count()>0)
|
||||
{
|
||||
return itemData.at(0).toString();
|
||||
}
|
||||
}
|
||||
|
||||
void ReadingListItem::setName(const QString &name)
|
||||
{
|
||||
itemData[0] = name;
|
||||
}
|
||||
|
||||
int ReadingListItem::row() const
|
||||
{
|
||||
if (parent)
|
||||
|
@ -14,7 +14,7 @@ public:
|
||||
int columnCount();
|
||||
virtual QIcon getIcon() const = 0;
|
||||
QVariant data(int column) const;
|
||||
|
||||
virtual qulonglong getId() const;
|
||||
QList<QVariant> itemData;
|
||||
};
|
||||
|
||||
@ -34,8 +34,11 @@ class LabelItem : public ListItem
|
||||
public:
|
||||
LabelItem(const QList<QVariant> &data);
|
||||
QIcon getIcon() const;
|
||||
YACReader::LabelColors colorid();
|
||||
QString name();
|
||||
YACReader::LabelColors colorid() const;
|
||||
QString name() const;
|
||||
void setName(const QString & name);
|
||||
qulonglong getId() const;
|
||||
|
||||
};
|
||||
|
||||
//------------------------------------------------------
|
||||
@ -50,6 +53,9 @@ public:
|
||||
int row() const;
|
||||
ReadingListItem * child(int row);
|
||||
void appendChild(ReadingListItem *item);
|
||||
qulonglong getId() const;
|
||||
QString name() const;
|
||||
void setName(const QString & name);
|
||||
|
||||
private:
|
||||
QList<ReadingListItem*> childItems;
|
||||
|
@ -26,8 +26,6 @@ int ReadingListModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
ListItem * item = static_cast<ListItem*>(parent.internalPointer());
|
||||
|
||||
QLOG_DEBUG() << item->itemData;
|
||||
|
||||
if(typeid(*item) == typeid(ReadingListItem))
|
||||
{
|
||||
ReadingListItem * item = static_cast<ReadingListItem*>(parent.internalPointer());
|
||||
@ -213,8 +211,20 @@ void ReadingListModel::rename(const QModelIndex &mi, const QString &name)
|
||||
|
||||
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
|
||||
|
||||
//TODO
|
||||
ListItem * item = static_cast<ListItem*>(mi.internalPointer());
|
||||
|
||||
if(typeid(*item) == typeid(ReadingListItem))
|
||||
{
|
||||
ReadingListItem * rli = static_cast<ReadingListItem*>(item);
|
||||
rli->setName(name);
|
||||
DBHelper::renameList(item->getId(), name, db);
|
||||
}
|
||||
else if(typeid(*item) == typeid(LabelItem))
|
||||
{
|
||||
LabelItem * li = static_cast<LabelItem*>(item);
|
||||
li->setName(name);
|
||||
DBHelper::renameLabel(item->getId(), name, db);
|
||||
}
|
||||
|
||||
emit dataChanged(index(mi.row(), 0), index(mi.row(), 0));
|
||||
|
||||
|
Reference in New Issue
Block a user