mirror of
https://github.com/YACReader/yacreader
synced 2025-07-18 21:14:33 -04:00
Use auto to avoid duplicating the type name
This commit is contained in:
@ -202,7 +202,7 @@ QMimeData *ComicModel::mimeData(const QModelIndexList &indexes) const
|
||||
QDataStream out(&data, QIODevice::WriteOnly);
|
||||
out << ids; //serialize the list of identifiers
|
||||
|
||||
QMimeData *mimeData = new QMimeData();
|
||||
auto mimeData = new QMimeData();
|
||||
mimeData->setData(YACReader::YACReaderLibrarComiscSelectionMimeDataFormat, data);
|
||||
|
||||
return mimeData;
|
||||
@ -272,7 +272,7 @@ QVariant ComicModel::data(const QModelIndex &index, int role) const
|
||||
//TODO check here if any view is asking for TableModel::Roles
|
||||
//these roles will be used from QML/GridView
|
||||
|
||||
ComicItem *item = static_cast<ComicItem *>(index.internalPointer());
|
||||
auto item = static_cast<ComicItem *>(index.internalPointer());
|
||||
|
||||
if (role == NumberRole)
|
||||
return item->data(Number);
|
||||
|
@ -142,7 +142,7 @@ QVariant FolderModel::data(const QModelIndex &index, int role) const
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
FolderItem *item = static_cast<FolderItem *>(index.internalPointer());
|
||||
auto item = static_cast<FolderItem *>(index.internalPointer());
|
||||
|
||||
if (role == Qt::ToolTipRole) {
|
||||
QString toolTip = item->data(FolderModel::Name).toString();
|
||||
@ -238,7 +238,7 @@ QModelIndex FolderModel::parent(const QModelIndex &index) const
|
||||
if (!index.isValid())
|
||||
return QModelIndex();
|
||||
|
||||
FolderItem *childItem = static_cast<FolderItem *>(index.internalPointer());
|
||||
auto childItem = static_cast<FolderItem *>(index.internalPointer());
|
||||
FolderItem *parentItem = childItem->parent();
|
||||
|
||||
if (parentItem == rootItem)
|
||||
@ -328,7 +328,7 @@ void FolderModel::setupModelData(QSqlQuery &sqlquery, FolderItem *parent)
|
||||
data << sqlquery.value(path).toString();
|
||||
data << sqlquery.value(finished).toBool();
|
||||
data << sqlquery.value(completed).toBool();
|
||||
FolderItem *item = new FolderItem(data);
|
||||
auto item = new FolderItem(data);
|
||||
|
||||
item->id = sqlquery.value(id).toULongLong();
|
||||
//la inserci<63>n de hijos se hace de forma ordenada
|
||||
@ -360,7 +360,7 @@ void FolderModel::updateFolderModelData(QSqlQuery &sqlquery, FolderItem *parent)
|
||||
data << sqlquery.value(path).toString();
|
||||
data << sqlquery.value(finished).toBool();
|
||||
data << sqlquery.value(completed).toBool();
|
||||
FolderItem *item = new FolderItem(data);
|
||||
auto item = new FolderItem(data);
|
||||
|
||||
item->id = sqlquery.value(id).toULongLong();
|
||||
//la inserci<63>n de hijos se hace de forma ordenada
|
||||
@ -410,7 +410,7 @@ void FolderModel::updateFolderCompletedStatus(const QModelIndexList &list, bool
|
||||
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
|
||||
db.transaction();
|
||||
foreach (QModelIndex mi, list) {
|
||||
FolderItem *item = static_cast<FolderItem *>(mi.internalPointer());
|
||||
auto item = static_cast<FolderItem *>(mi.internalPointer());
|
||||
item->setData(FolderModel::Completed, status);
|
||||
|
||||
Folder f = DBHelper::loadFolder(item->id, db);
|
||||
@ -429,7 +429,7 @@ void FolderModel::updateFolderFinishedStatus(const QModelIndexList &list, bool s
|
||||
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
|
||||
db.transaction();
|
||||
foreach (QModelIndex mi, list) {
|
||||
FolderItem *item = static_cast<FolderItem *>(mi.internalPointer());
|
||||
auto item = static_cast<FolderItem *>(mi.internalPointer());
|
||||
item->setData(FolderModel::Finished, status);
|
||||
|
||||
Folder f = DBHelper::loadFolder(item->id, db);
|
||||
@ -448,7 +448,7 @@ QStringList FolderModel::getSubfoldersNames(const QModelIndex &mi)
|
||||
QStringList result;
|
||||
qulonglong id = 1;
|
||||
if (mi.isValid()) {
|
||||
FolderItem *item = static_cast<FolderItem *>(mi.internalPointer());
|
||||
auto item = static_cast<FolderItem *>(mi.internalPointer());
|
||||
id = item->id;
|
||||
}
|
||||
|
||||
@ -559,7 +559,7 @@ QModelIndex FolderModel::addFolderAtParent(const QString &folderName, const QMod
|
||||
data << false; //finished
|
||||
data << true; //completed
|
||||
|
||||
FolderItem *item = new FolderItem(data);
|
||||
auto item = new FolderItem(data);
|
||||
item->id = newFolder.id;
|
||||
|
||||
beginInsertRows(parent, 0, 0); //TODO calculate the destRow before inserting the new child
|
||||
@ -577,7 +577,7 @@ void FolderModel::deleteFolder(const QModelIndex &mi)
|
||||
{
|
||||
beginRemoveRows(mi.parent(), mi.row(), mi.row());
|
||||
|
||||
FolderItem *item = static_cast<FolderItem *>(mi.internalPointer());
|
||||
auto item = static_cast<FolderItem *>(mi.internalPointer());
|
||||
|
||||
FolderItem *parent = item->parent();
|
||||
parent->removeChild(mi.row());
|
||||
@ -616,7 +616,7 @@ bool FolderModelProxy::filterAcceptsRow(int source_row, const QModelIndex &sourc
|
||||
if (!filterEnabled)
|
||||
return true;
|
||||
|
||||
FolderItem *parent = static_cast<FolderItem *>(source_parent.internalPointer());
|
||||
auto parent = static_cast<FolderItem *>(source_parent.internalPointer());
|
||||
|
||||
if (parent == 0)
|
||||
parent = static_cast<FolderModel *>(sourceModel())->rootItem;
|
||||
@ -656,7 +656,7 @@ void FolderModelProxy::setupFilteredModelData()
|
||||
rootItem->id = ROOT;
|
||||
rootItem->parentItem = 0;
|
||||
|
||||
FolderModel *model = static_cast<FolderModel *>(sourceModel());
|
||||
auto model = static_cast<FolderModel *>(sourceModel());
|
||||
|
||||
//cargar la base de datos
|
||||
QSqlDatabase db = DataBaseManagement::loadDatabase(model->_databasePath);
|
||||
@ -719,7 +719,7 @@ void FolderModelProxy::clear()
|
||||
|
||||
void FolderModelProxy::setupFilteredModelData(QSqlQuery &sqlquery, FolderItem *parent)
|
||||
{
|
||||
FolderModel *model = static_cast<FolderModel *>(sourceModel());
|
||||
auto model = static_cast<FolderModel *>(sourceModel());
|
||||
|
||||
//64 bits para la primary key, es decir la misma precisi<73>n que soporta sqlit 2^64
|
||||
filteredItems.clear();
|
||||
@ -744,7 +744,7 @@ void FolderModelProxy::setupFilteredModelData(QSqlQuery &sqlquery, FolderItem *p
|
||||
data << sqlquery.value(finished).toBool();
|
||||
data << sqlquery.value(completed).toBool();
|
||||
|
||||
FolderItem *item = new FolderItem(data);
|
||||
auto item = new FolderItem(data);
|
||||
item->id = sqlquery.value(0).toULongLong();
|
||||
|
||||
//id del padre
|
||||
|
@ -24,10 +24,10 @@ int ReadingListModel::rowCount(const QModelIndex &parent) const
|
||||
int separatorsCount = 2; //labels.isEmpty()?1:2;
|
||||
return specialLists.count() + labels.count() + rootItem->childCount() + separatorsCount;
|
||||
} else {
|
||||
ListItem *item = static_cast<ListItem *>(parent.internalPointer());
|
||||
auto item = static_cast<ListItem *>(parent.internalPointer());
|
||||
|
||||
if (typeid(*item) == typeid(ReadingListItem)) {
|
||||
ReadingListItem *item = static_cast<ReadingListItem *>(parent.internalPointer());
|
||||
auto item = static_cast<ReadingListItem *>(parent.internalPointer());
|
||||
return item->childCount();
|
||||
}
|
||||
}
|
||||
@ -38,7 +38,7 @@ int ReadingListModel::rowCount(const QModelIndex &parent) const
|
||||
int ReadingListModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
if (parent.isValid()) {
|
||||
ListItem *item = static_cast<ListItem *>(parent.internalPointer());
|
||||
auto item = static_cast<ListItem *>(parent.internalPointer());
|
||||
if (typeid(*item) == typeid(ReadingListSeparatorItem))
|
||||
return 0;
|
||||
}
|
||||
@ -54,7 +54,7 @@ QVariant ReadingListModel::data(const QModelIndex &index, int role) const
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
ListItem *item = static_cast<ListItem *>(index.internalPointer());
|
||||
auto item = static_cast<ListItem *>(index.internalPointer());
|
||||
|
||||
if (role == ReadingListModel::TypeListsRole) {
|
||||
if (typeid(*item) == typeid(SpecialListItem))
|
||||
@ -71,7 +71,7 @@ QVariant ReadingListModel::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
|
||||
if (role == ReadingListModel::LabelColorRole && typeid(*item) == typeid(LabelItem)) {
|
||||
LabelItem *labelItem = static_cast<LabelItem *>(item);
|
||||
auto labelItem = static_cast<LabelItem *>(item);
|
||||
return QVariant(labelItem->colorid());
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ QVariant ReadingListModel::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
|
||||
if (role == ReadingListModel::SpecialListTypeRole && typeid(*item) == typeid(SpecialListItem)) {
|
||||
SpecialListItem *specialListItem = static_cast<SpecialListItem *>(item);
|
||||
auto specialListItem = static_cast<SpecialListItem *>(item);
|
||||
return QVariant(specialListItem->getType());
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ Qt::ItemFlags ReadingListModel::flags(const QModelIndex &index) const
|
||||
if (!index.isValid())
|
||||
return 0;
|
||||
|
||||
ListItem *item = static_cast<ListItem *>(index.internalPointer());
|
||||
auto item = static_cast<ListItem *>(index.internalPointer());
|
||||
if (typeid(*item) == typeid(ReadingListSeparatorItem))
|
||||
return 0;
|
||||
|
||||
@ -170,10 +170,10 @@ QModelIndex ReadingListModel::parent(const QModelIndex &index) const
|
||||
if (!index.isValid())
|
||||
return QModelIndex();
|
||||
|
||||
ListItem *item = static_cast<ListItem *>(index.internalPointer());
|
||||
auto item = static_cast<ListItem *>(index.internalPointer());
|
||||
|
||||
if (typeid(*item) == typeid(ReadingListItem)) {
|
||||
ReadingListItem *childItem = static_cast<ReadingListItem *>(index.internalPointer());
|
||||
auto childItem = static_cast<ReadingListItem *>(index.internalPointer());
|
||||
ReadingListItem *parent = childItem->parent;
|
||||
if (parent->getId() != 0)
|
||||
return createIndex(parent->row() + specialLists.count() + labels.count() + 2, 0, parent);
|
||||
@ -305,7 +305,7 @@ bool ReadingListModel::dropSublist(const QMimeData *data, Qt::DropAction action,
|
||||
|
||||
//beginMoveRows(destParent,sourceRow,sourceRow,destParent,destRow);
|
||||
|
||||
ReadingListItem *parentItem = static_cast<ReadingListItem *>(destParent.internalPointer());
|
||||
auto parentItem = static_cast<ReadingListItem *>(destParent.internalPointer());
|
||||
ReadingListItem *child = parentItem->child(sourceRow);
|
||||
parentItem->removeChild(child);
|
||||
parentItem->appendChild(child, destRow);
|
||||
@ -339,7 +339,7 @@ QMimeData *ReadingListModel::mimeData(const QModelIndexList &indexes) const
|
||||
QDataStream out(&data, QIODevice::WriteOnly);
|
||||
out << rows; //serialize the list of identifiers
|
||||
|
||||
QMimeData *mimeData = new QMimeData();
|
||||
auto mimeData = new QMimeData();
|
||||
mimeData->setData(YACReader::YACReaderLibrarSubReadingListMimeDataFormat, data);
|
||||
|
||||
return mimeData;
|
||||
@ -415,7 +415,7 @@ void ReadingListModel::addReadingListAt(const QString &name, const QModelIndex &
|
||||
|
||||
beginInsertRows(mi, 0, 0); //TODO calculate the right coordinates before inserting
|
||||
|
||||
ReadingListItem *readingListParent = static_cast<ReadingListItem *>(mi.internalPointer());
|
||||
auto readingListParent = static_cast<ReadingListItem *>(mi.internalPointer());
|
||||
qulonglong id = DBHelper::insertReadingSubList(name, mi.data(IDRole).toULongLong(), readingListParent->childCount(), db);
|
||||
ReadingListItem *newItem;
|
||||
|
||||
@ -441,7 +441,7 @@ bool ReadingListModel::isEditable(const QModelIndex &mi)
|
||||
{
|
||||
if (!mi.isValid())
|
||||
return false;
|
||||
ListItem *item = static_cast<ListItem *>(mi.internalPointer());
|
||||
auto item = static_cast<ListItem *>(mi.internalPointer());
|
||||
return typeid(*item) != typeid(SpecialListItem);
|
||||
}
|
||||
|
||||
@ -449,7 +449,7 @@ bool ReadingListModel::isReadingList(const QModelIndex &mi)
|
||||
{
|
||||
if (!mi.isValid())
|
||||
return false;
|
||||
ListItem *item = static_cast<ListItem *>(mi.internalPointer());
|
||||
auto item = static_cast<ListItem *>(mi.internalPointer());
|
||||
return typeid(*item) == typeid(ReadingListItem);
|
||||
}
|
||||
|
||||
@ -457,9 +457,9 @@ bool ReadingListModel::isReadingSubList(const QModelIndex &mi)
|
||||
{
|
||||
if (!mi.isValid())
|
||||
return false;
|
||||
ListItem *item = static_cast<ListItem *>(mi.internalPointer());
|
||||
auto item = static_cast<ListItem *>(mi.internalPointer());
|
||||
if (typeid(*item) == typeid(ReadingListItem)) {
|
||||
ReadingListItem *readingListItem = static_cast<ReadingListItem *>(item);
|
||||
auto readingListItem = static_cast<ReadingListItem *>(item);
|
||||
if (readingListItem->parent == rootItem)
|
||||
return false;
|
||||
else
|
||||
@ -480,10 +480,10 @@ void ReadingListModel::rename(const QModelIndex &mi, const QString &name)
|
||||
|
||||
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
|
||||
|
||||
ListItem *item = static_cast<ListItem *>(mi.internalPointer());
|
||||
auto item = static_cast<ListItem *>(mi.internalPointer());
|
||||
|
||||
if (typeid(*item) == typeid(ReadingListItem)) {
|
||||
ReadingListItem *rli = static_cast<ReadingListItem *>(item);
|
||||
auto rli = static_cast<ReadingListItem *>(item);
|
||||
rli->setName(name);
|
||||
DBHelper::renameList(item->getId(), name, db);
|
||||
|
||||
@ -493,7 +493,7 @@ void ReadingListModel::rename(const QModelIndex &mi, const QString &name)
|
||||
} else
|
||||
emit dataChanged(index(mi.row(), 0), index(mi.row(), 0));
|
||||
} else if (typeid(*item) == typeid(LabelItem)) {
|
||||
LabelItem *li = static_cast<LabelItem *>(item);
|
||||
auto li = static_cast<LabelItem *>(item);
|
||||
li->setName(name);
|
||||
DBHelper::renameLabel(item->getId(), name, db);
|
||||
emit dataChanged(index(mi.row(), 0), index(mi.row(), 0));
|
||||
@ -510,10 +510,10 @@ void ReadingListModel::deleteItem(const QModelIndex &mi)
|
||||
|
||||
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
|
||||
|
||||
ListItem *item = static_cast<ListItem *>(mi.internalPointer());
|
||||
auto item = static_cast<ListItem *>(mi.internalPointer());
|
||||
|
||||
if (typeid(*item) == typeid(ReadingListItem)) {
|
||||
ReadingListItem *rli = static_cast<ReadingListItem *>(item);
|
||||
auto rli = static_cast<ReadingListItem *>(item);
|
||||
QLOG_DEBUG() << "num children : " << rli->parent->childCount();
|
||||
rli->parent->removeChild(rli);
|
||||
QLOG_DEBUG() << "num children : " << rli->parent->childCount();
|
||||
@ -523,7 +523,7 @@ void ReadingListModel::deleteItem(const QModelIndex &mi)
|
||||
}
|
||||
QLOG_DEBUG() << "num children : " << rli->parent->childCount();
|
||||
} else if (typeid(*item) == typeid(LabelItem)) {
|
||||
LabelItem *li = static_cast<LabelItem *>(item);
|
||||
auto li = static_cast<LabelItem *>(item);
|
||||
labels.removeOne(li);
|
||||
DBHelper::removeLabelFromDB(item->getId(), db);
|
||||
}
|
||||
|
Reference in New Issue
Block a user