mirror of
https://github.com/YACReader/yacreader
synced 2025-11-20 17:42:54 -05:00
completed drag comics from comics view to reading lists
This commit is contained in:
@ -47,16 +47,17 @@ QMimeData *ComicModel::mimeData(const QModelIndexList &indexes) const
|
|||||||
QList<qulonglong> ids;
|
QList<qulonglong> ids;
|
||||||
foreach(QModelIndex index, indexes)
|
foreach(QModelIndex index, indexes)
|
||||||
{
|
{
|
||||||
|
QLOG_DEBUG() << "dragging : " << index.data(IdRole).toULongLong();
|
||||||
ids << index.data(IdRole).toULongLong();
|
ids << index.data(IdRole).toULongLong();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray data;
|
QByteArray data;
|
||||||
QBuffer buffer(&data);
|
QDataStream out(&data,QIODevice::WriteOnly);
|
||||||
QDataStream out(&buffer);
|
|
||||||
out << ids; //serialize the list of identifiers
|
out << ids; //serialize the list of identifiers
|
||||||
|
|
||||||
QMimeData * mimeData = new QMimeData();
|
QMimeData * mimeData = new QMimeData();
|
||||||
mimeData->setData("application/yacreaderlibrary-comics-ids", data);
|
mimeData->setData(YACReader::YACReaderLibrarComiscSelectionMimeDataFormat, data);
|
||||||
|
|
||||||
return mimeData;
|
return mimeData;
|
||||||
}
|
}
|
||||||
@ -137,6 +138,8 @@ QVariant ComicModel::data(const QModelIndex &index, int role) const
|
|||||||
return item->data(ReadColumn).toBool();
|
return item->data(ReadColumn).toBool();
|
||||||
else if (role == HasBeenOpenedRole)
|
else if (role == HasBeenOpenedRole)
|
||||||
return item->data(ComicModel::HasBeenOpened);
|
return item->data(ComicModel::HasBeenOpened);
|
||||||
|
else if (role == IdRole)
|
||||||
|
return item->data(Id);
|
||||||
|
|
||||||
if (role != Qt::DisplayRole)
|
if (role != Qt::DisplayRole)
|
||||||
return QVariant();
|
return QVariant();
|
||||||
@ -705,7 +708,18 @@ QModelIndex ComicModel::getIndexFromId(quint64 id)
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return index(i,0);
|
return index(i,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO completely inefficiently
|
||||||
|
QList<QModelIndex> ComicModel::getIndexesFromIds(const QList<qulonglong> &comicIds)
|
||||||
|
{
|
||||||
|
QList<QModelIndex> comicsIndexes;
|
||||||
|
|
||||||
|
foreach(qulonglong id,comicIds)
|
||||||
|
comicsIndexes << getIndexFromId(id);
|
||||||
|
|
||||||
|
return comicsIndexes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComicModel::startTransaction()
|
void ComicModel::startTransaction()
|
||||||
@ -720,8 +734,6 @@ void ComicModel::finishTransaction()
|
|||||||
dbTransaction.commit();
|
dbTransaction.commit();
|
||||||
dbTransaction.close();
|
dbTransaction.close();
|
||||||
QSqlDatabase::removeDatabase(_databasePath);
|
QSqlDatabase::removeDatabase(_databasePath);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComicModel::removeInTransaction(int row)
|
void ComicModel::removeInTransaction(int row)
|
||||||
@ -800,6 +812,11 @@ void ComicModel::resetComicRating(const QModelIndex &mi)
|
|||||||
QSqlDatabase::removeDatabase(_databasePath);
|
QSqlDatabase::removeDatabase(_databasePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ComicModel::addComicsToFavorites(const QList<qulonglong> &comicIds)
|
||||||
|
{
|
||||||
|
addComicsToFavorites(getIndexesFromIds(comicIds));
|
||||||
|
}
|
||||||
|
|
||||||
void ComicModel::addComicsToFavorites(const QList<QModelIndex> & comicsList)
|
void ComicModel::addComicsToFavorites(const QList<QModelIndex> & comicsList)
|
||||||
{
|
{
|
||||||
QList<ComicDB> comics = getComics(comicsList);
|
QList<ComicDB> comics = getComics(comicsList);
|
||||||
@ -812,6 +829,11 @@ void ComicModel::addComicsToFavorites(const QList<QModelIndex> & comicsList)
|
|||||||
QSqlDatabase::removeDatabase(_databasePath);
|
QSqlDatabase::removeDatabase(_databasePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ComicModel::addComicsToLabel(const QList<qulonglong> &comicIds, qulonglong labelId)
|
||||||
|
{
|
||||||
|
addComicsToLabel(getIndexesFromIds(comicIds),labelId);
|
||||||
|
}
|
||||||
|
|
||||||
void ComicModel::addComicsToLabel(const QList<QModelIndex> &comicsList, qulonglong labelId)
|
void ComicModel::addComicsToLabel(const QList<QModelIndex> &comicsList, qulonglong labelId)
|
||||||
{
|
{
|
||||||
QList<ComicDB> comics = getComics(comicsList);
|
QList<ComicDB> comics = getComics(comicsList);
|
||||||
@ -824,6 +846,23 @@ void ComicModel::addComicsToLabel(const QList<QModelIndex> &comicsList, qulonglo
|
|||||||
QSqlDatabase::removeDatabase(_databasePath);
|
QSqlDatabase::removeDatabase(_databasePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ComicModel::addComicsToReadingList(const QList<qulonglong> &comicIds, qulonglong readingListId)
|
||||||
|
{
|
||||||
|
addComicsToReadingList(getIndexesFromIds(comicIds),readingListId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComicModel::addComicsToReadingList(const QList<QModelIndex> &comicsList, qulonglong readingListId)
|
||||||
|
{
|
||||||
|
QList<ComicDB> comics = getComics(comicsList);
|
||||||
|
|
||||||
|
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
|
||||||
|
|
||||||
|
DBHelper::insertComicsInReadingList(comics,readingListId,db);
|
||||||
|
|
||||||
|
db.close();
|
||||||
|
QSqlDatabase::removeDatabase(_databasePath);
|
||||||
|
}
|
||||||
|
|
||||||
void ComicModel::deleteComicsFromFavorites(const QList<QModelIndex> &comicsList)
|
void ComicModel::deleteComicsFromFavorites(const QList<QModelIndex> &comicsList)
|
||||||
{
|
{
|
||||||
QList<ComicDB> comics = getComics(comicsList);
|
QList<ComicDB> comics = getComics(comicsList);
|
||||||
|
|||||||
@ -55,6 +55,7 @@ public:
|
|||||||
QList<ComicDB> getComics(QList<QModelIndex> list); //--> recupera la información común a los comics seleccionados
|
QList<ComicDB> getComics(QList<QModelIndex> list); //--> recupera la información común a los comics seleccionados
|
||||||
QList<ComicDB> getAllComics();
|
QList<ComicDB> getAllComics();
|
||||||
QModelIndex getIndexFromId(quint64 id);
|
QModelIndex getIndexFromId(quint64 id);
|
||||||
|
QList<QModelIndex> getIndexesFromIds(const QList<qulonglong> &comicIds);
|
||||||
//setcomicInfo(QModelIndex & mi); --> inserta en la base datos
|
//setcomicInfo(QModelIndex & mi); --> inserta en la base datos
|
||||||
//setComicInfoForAllComics(); --> inserta la información común a todos los cómics de una sola vez.
|
//setComicInfoForAllComics(); --> inserta la información común a todos los cómics de una sola vez.
|
||||||
//setComicInfoForSelectedComis(QList<QModelIndex> list); -->inserta la información común para los comics seleccionados
|
//setComicInfoForSelectedComis(QList<QModelIndex> list); -->inserta la información común para los comics seleccionados
|
||||||
@ -64,8 +65,11 @@ public:
|
|||||||
void removeInTransaction(int row);
|
void removeInTransaction(int row);
|
||||||
void reload(const ComicDB & comic);
|
void reload(const ComicDB & comic);
|
||||||
void resetComicRating(const QModelIndex & mi);
|
void resetComicRating(const QModelIndex & mi);
|
||||||
|
|
||||||
|
|
||||||
void addComicsToFavorites(const QList<QModelIndex> &comicsList);
|
void addComicsToFavorites(const QList<QModelIndex> &comicsList);
|
||||||
void addComicsToLabel(const QList<QModelIndex> &comicsList, qulonglong labelId);
|
void addComicsToLabel(const QList<QModelIndex> &comicsList, qulonglong labelId);
|
||||||
|
void addComicsToReadingList(const QList<QModelIndex> &comicsList, qulonglong readingListId);
|
||||||
|
|
||||||
void deleteComicsFromFavorites(const QList<QModelIndex> &comicsList);
|
void deleteComicsFromFavorites(const QList<QModelIndex> &comicsList);
|
||||||
void deleteComicsFromLabel(const QList<QModelIndex> &comicsList, qulonglong labelId);
|
void deleteComicsFromLabel(const QList<QModelIndex> &comicsList, qulonglong labelId);
|
||||||
@ -115,6 +119,10 @@ public slots:
|
|||||||
void finishTransaction();
|
void finishTransaction();
|
||||||
void updateRating(int rating, QModelIndex mi);
|
void updateRating(int rating, QModelIndex mi);
|
||||||
|
|
||||||
|
void addComicsToFavorites(const QList<qulonglong> &comicIds);
|
||||||
|
void addComicsToLabel(const QList<qulonglong> &comicIds, qulonglong labelId);
|
||||||
|
void addComicsToReadingList(const QList<qulonglong> &comicIds, qulonglong readingListId);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -170,7 +170,7 @@ qulonglong ReadingListItem::getId() const
|
|||||||
{
|
{
|
||||||
if(itemData.count()>1)
|
if(itemData.count()>1)
|
||||||
{
|
{
|
||||||
return YACReader::LabelColors(itemData.at(1).toULongLong());
|
return itemData.at(1).toULongLong();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -80,7 +80,10 @@ QVariant ReadingListModel::data(const QModelIndex &index, int role) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (role == ReadingListModel::IDRole)
|
if (role == ReadingListModel::IDRole)
|
||||||
|
{
|
||||||
|
QLOG_DEBUG() << "getting role";
|
||||||
return item->getId();
|
return item->getId();
|
||||||
|
}
|
||||||
|
|
||||||
if (role == ReadingListModel::SpecialListTypeRole && typeid(*item) == typeid(SpecialListItem))
|
if (role == ReadingListModel::SpecialListTypeRole && typeid(*item) == typeid(SpecialListItem))
|
||||||
{
|
{
|
||||||
@ -131,20 +134,20 @@ QModelIndex ReadingListModel::index(int row, int column, const QModelIndex &pare
|
|||||||
{
|
{
|
||||||
int separatorsCount = labels.isEmpty()?1:2;
|
int separatorsCount = labels.isEmpty()?1:2;
|
||||||
|
|
||||||
if(row >= 0 && row < specialLists.count())
|
if(rowIsSpecialList(row,parent))
|
||||||
return createIndex(row, column, specialLists.at(row));
|
return createIndex(row, column, specialLists.at(row));
|
||||||
|
|
||||||
if(row == specialLists.count())
|
if(row == specialLists.count())
|
||||||
return createIndex(row,column,separator1);
|
return createIndex(row,column,separator1);
|
||||||
|
|
||||||
if(row > specialLists.count() && row <= specialLists.count() + labels.count())
|
if(rowIsLabel(row,parent))
|
||||||
return createIndex(row,column,labels.at(row-specialLists.count()-1));
|
return createIndex(row,column,labels.at(row-specialLists.count()-1));
|
||||||
|
|
||||||
if(separatorsCount == 2)
|
if(separatorsCount == 2)
|
||||||
if(row == specialLists.count() + labels.count() + 1)
|
if(row == specialLists.count() + labels.count() + 1)
|
||||||
return createIndex(row,column,separator2);
|
return createIndex(row,column,separator2);
|
||||||
|
|
||||||
if(row >= specialLists.count() + labels.count() + separatorsCount)
|
if(rowIsReadingList(row,parent))
|
||||||
return createIndex(row,column,rootItem->child(row - (specialLists.count() + labels.count() + separatorsCount)));
|
return createIndex(row,column,rootItem->child(row - (specialLists.count() + labels.count() + separatorsCount)));
|
||||||
|
|
||||||
} else //sublist
|
} else //sublist
|
||||||
@ -188,13 +191,71 @@ QModelIndex ReadingListModel::parent(const QModelIndex &index) const
|
|||||||
|
|
||||||
bool ReadingListModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const
|
bool ReadingListModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
return data->formats().contains("application/yacreaderlibrary-comics-ids");
|
QLOG_DEBUG() << "trying to drop into row = " << row << "column column = " << column << "parent" << parent;
|
||||||
|
|
||||||
|
if(row == -1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(!parent.isValid()) //top level items
|
||||||
|
{
|
||||||
|
if(row == -1) //no list
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(row == 1) //reading is just an smart list
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(rowIsSeparator(row,parent))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return data->formats().contains(YACReader::YACReaderLibrarComiscSelectionMimeDataFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReadingListModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
|
bool ReadingListModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
|
||||||
{
|
{
|
||||||
QLOG_DEBUG() << "drop mimedata into row = " << row << "column column = " << column << "parent" << parent;
|
QLOG_DEBUG() << "drop mimedata into row = " << row << " column = " << column << "parent" << parent;
|
||||||
return true;
|
|
||||||
|
QList<qulonglong> comicIds;
|
||||||
|
QByteArray rawData = data->data(YACReader::YACReaderLibrarComiscSelectionMimeDataFormat);
|
||||||
|
QDataStream in(&rawData,QIODevice::ReadOnly);
|
||||||
|
in >> comicIds; //deserialize the list of indentifiers
|
||||||
|
|
||||||
|
QLOG_DEBUG() << "dropped : " << comicIds;
|
||||||
|
|
||||||
|
QModelIndex dest;
|
||||||
|
QModelIndex parentDest;
|
||||||
|
|
||||||
|
if(row == -1)
|
||||||
|
{
|
||||||
|
dest = parent;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
dest = index(row,column,parent);
|
||||||
|
|
||||||
|
parentDest = dest.parent();
|
||||||
|
|
||||||
|
if(rowIsSpecialList(dest.row(),parentDest)) {
|
||||||
|
if(dest.row() == 0) //add to favorites
|
||||||
|
{
|
||||||
|
QLOG_DEBUG() << "-------addComicsToFavorites : " << comicIds << " to " << dest.data(IDRole).toULongLong();
|
||||||
|
emit addComicsToFavorites(comicIds);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(rowIsLabel(dest.row(),parentDest)) {
|
||||||
|
QLOG_DEBUG() << "+++++++++++addComicsToLabel : " << comicIds << " to " << dest.data(IDRole).toULongLong();
|
||||||
|
emit addComicsToLabel(comicIds, dest.data(IDRole).toULongLong());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(rowIsReadingList(dest.row(),parentDest)) {
|
||||||
|
QLOG_DEBUG() << "///////////addComicsToReadingList : " << comicIds << " to " << dest.data(IDRole).toULongLong();
|
||||||
|
emit addComicsToReadingList(comicIds, dest.data(IDRole).toULongLong());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadingListModel::setupReadingListsData(QString path)
|
void ReadingListModel::setupReadingListsData(QString path)
|
||||||
@ -498,8 +559,55 @@ int ReadingListModel::addLabelIntoList(LabelItem *item)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ReadingListModel::rowIsSpecialList(int row, const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
if(parent.isValid())
|
||||||
|
return false; //by now no sublists in special list
|
||||||
|
|
||||||
|
if(row >=0 && row < specialLists.count())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ReadingListModel::rowIsLabel(int row, const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
if(parent.isValid())
|
||||||
|
return false; //by now no sublists in labels
|
||||||
|
|
||||||
|
if(row > specialLists.count() && row <= specialLists.count() + labels.count())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ReadingListModel::rowIsReadingList(int row, const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
if(parent.isValid())
|
||||||
|
return true; //only lists with sublists
|
||||||
|
|
||||||
|
int separatorsCount = labels.isEmpty()?1:2;
|
||||||
|
|
||||||
|
if(row >= specialLists.count() + labels.count() + separatorsCount)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ReadingListModel::rowIsSeparator(int row, const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
if(parent.isValid())
|
||||||
|
return false; //only separators at top level
|
||||||
|
|
||||||
|
if(row == specialLists.count())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
int separatorsCount = labels.isEmpty()?1:2;
|
||||||
|
if(separatorsCount == 2 && row == specialLists.count() + labels.count() + 1)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ReadingListModelProxy::ReadingListModelProxy(QObject *parent)
|
ReadingListModelProxy::ReadingListModelProxy(QObject *parent)
|
||||||
:QSortFilterProxyModel(parent)
|
:QSortFilterProxyModel(parent)
|
||||||
|
|||||||
@ -74,6 +74,10 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
void addComicsToFavorites(const QList<qulonglong> & comicIds);
|
||||||
|
void addComicsToLabel(const QList<qulonglong> & comicIds, qulonglong labelId);
|
||||||
|
void addComicsToReadingList(const QList<qulonglong> & comicIds, qulonglong readingListId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void cleanAll();
|
void cleanAll();
|
||||||
void setupReadingListsData(QSqlQuery &sqlquery, ReadingListItem *parent);
|
void setupReadingListsData(QSqlQuery &sqlquery, ReadingListItem *parent);
|
||||||
@ -82,6 +86,11 @@ private:
|
|||||||
void setupReadingLists(QSqlDatabase &db);
|
void setupReadingLists(QSqlDatabase &db);
|
||||||
int addLabelIntoList(LabelItem *item);
|
int addLabelIntoList(LabelItem *item);
|
||||||
|
|
||||||
|
bool rowIsSpecialList(int row, const QModelIndex & parent = QModelIndex()) const;
|
||||||
|
bool rowIsLabel(int row, const QModelIndex & parent = QModelIndex()) const;
|
||||||
|
bool rowIsReadingList(int row, const QModelIndex & parent = QModelIndex()) const;
|
||||||
|
bool rowIsSeparator(int row, const QModelIndex & parent = QModelIndex()) const;
|
||||||
|
|
||||||
//Special lists
|
//Special lists
|
||||||
QList<SpecialListItem *> specialLists;
|
QList<SpecialListItem *> specialLists;
|
||||||
|
|
||||||
|
|||||||
@ -474,11 +474,6 @@ qulonglong DBHelper::insertReadingList(const QString &name, QSqlDatabase &db)
|
|||||||
|
|
||||||
void DBHelper::insertComicsInFavorites(const QList<ComicDB> &comicsList, QSqlDatabase &db)
|
void DBHelper::insertComicsInFavorites(const QList<ComicDB> &comicsList, QSqlDatabase &db)
|
||||||
{
|
{
|
||||||
/*QSqlQuery getNumComicsInFavoritesQuery("SELECT count(*) from comic_reading_list;",db);
|
|
||||||
getNumComicsInFavoritesQuery.next();
|
|
||||||
QSqlRecord record = getNumComicsInFavoritesQuery.record();
|
|
||||||
int numComics = record.value(0).toInt();*/
|
|
||||||
|
|
||||||
db.transaction();
|
db.transaction();
|
||||||
|
|
||||||
QSqlQuery query(db);
|
QSqlQuery query(db);
|
||||||
@ -512,6 +507,30 @@ void DBHelper::insertComicsInLabel(const QList<ComicDB> &comicsList, qulonglong
|
|||||||
|
|
||||||
db.commit();
|
db.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DBHelper::insertComicsInReadingList(const QList<ComicDB> &comicsList, qulonglong readingListId, QSqlDatabase &db)
|
||||||
|
{
|
||||||
|
QSqlQuery getNumComicsInFavoritesQuery("SELECT count(*) from comic_reading_list;",db);
|
||||||
|
getNumComicsInFavoritesQuery.next();
|
||||||
|
QSqlRecord record = getNumComicsInFavoritesQuery.record();
|
||||||
|
int numComics = record.value(0).toInt();
|
||||||
|
|
||||||
|
db.transaction();
|
||||||
|
|
||||||
|
QSqlQuery query(db);
|
||||||
|
query.prepare("INSERT INTO comic_reading_list (reading_list_id, comic_id, ordering) "
|
||||||
|
"VALUES (:reading_list_id, :comic_id, :ordering)");
|
||||||
|
|
||||||
|
foreach(ComicDB comic, comicsList)
|
||||||
|
{
|
||||||
|
query.bindValue(":reading_list_id", readingListId);
|
||||||
|
query.bindValue(":comic_id", comic.id);
|
||||||
|
query.bindValue(":ordering", numComics++);
|
||||||
|
query.exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
db.commit();
|
||||||
|
}
|
||||||
//queries
|
//queries
|
||||||
QList<LibraryItem *> DBHelper::getFoldersFromParent(qulonglong parentId, QSqlDatabase & db, bool sort)
|
QList<LibraryItem *> DBHelper::getFoldersFromParent(qulonglong parentId, QSqlDatabase & db, bool sort)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -47,6 +47,7 @@ public:
|
|||||||
static qulonglong insertReadingList(const QString & name, QSqlDatabase & db);
|
static qulonglong insertReadingList(const QString & name, QSqlDatabase & db);
|
||||||
static void insertComicsInFavorites(const QList<ComicDB> & comicsList, QSqlDatabase & db);
|
static void insertComicsInFavorites(const QList<ComicDB> & comicsList, QSqlDatabase & db);
|
||||||
static void insertComicsInLabel(const QList<ComicDB> & comicsList, qulonglong labelId, QSqlDatabase & db);
|
static void insertComicsInLabel(const QList<ComicDB> & comicsList, qulonglong labelId, QSqlDatabase & db);
|
||||||
|
static void insertComicsInReadingList(const QList<ComicDB> & comicsList, qulonglong readingListId, QSqlDatabase & db);
|
||||||
//updates
|
//updates
|
||||||
static void update(qulonglong libraryId, ComicInfo & comicInfo);
|
static void update(qulonglong libraryId, ComicInfo & comicInfo);
|
||||||
static void update(ComicDB * comics, QSqlDatabase & db);
|
static void update(ComicDB * comics, QSqlDatabase & db);
|
||||||
|
|||||||
@ -169,7 +169,29 @@ void GridComicsView::requestedContextMenu(const QPoint &point)
|
|||||||
QSize GridComicsView::sizeHint()
|
QSize GridComicsView::sizeHint()
|
||||||
{
|
{
|
||||||
QLOG_INFO() << "sizeHint";
|
QLOG_INFO() << "sizeHint";
|
||||||
return QSize(1280,768);
|
return QSize(1280,768);
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray GridComicsView::getMimeDataFromSelection()
|
||||||
|
{
|
||||||
|
QByteArray data;
|
||||||
|
|
||||||
|
QMimeData * mimeData = model->mimeData(_selectionModel->selectedIndexes());
|
||||||
|
data = mimeData->data(YACReader::YACReaderLibrarComiscSelectionMimeDataFormat);
|
||||||
|
|
||||||
|
delete mimeData;
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GridComicsView::startDrag()
|
||||||
|
{
|
||||||
|
QLOG_DEBUG() << "performDrag";
|
||||||
|
QDrag *drag = new QDrag(this);
|
||||||
|
drag->setMimeData(model->mimeData(_selectionModel->selectedRows()));
|
||||||
|
drag->setPixmap(QPixmap(":/images/openInYACReader.png")); //TODO add better image
|
||||||
|
|
||||||
|
Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
//helper
|
//helper
|
||||||
|
|||||||
@ -28,6 +28,8 @@ public:
|
|||||||
void updateConfig(QSettings * settings);
|
void updateConfig(QSettings * settings);
|
||||||
void enableFilterMode(bool enabled);
|
void enableFilterMode(bool enabled);
|
||||||
QSize sizeHint();
|
QSize sizeHint();
|
||||||
|
QByteArray getMimeDataFromSelection();
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void comicRated(int,QModelIndex);
|
void comicRated(int,QModelIndex);
|
||||||
@ -48,6 +50,8 @@ public slots:
|
|||||||
//rating
|
//rating
|
||||||
void rate(int index, int rating);
|
void rate(int index, int rating);
|
||||||
|
|
||||||
|
void startDrag();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void requestedContextMenu(const QPoint & point);
|
void requestedContextMenu(const QPoint & point);
|
||||||
|
|
||||||
|
|||||||
@ -1148,6 +1148,9 @@ void LibraryWindow::createConnections()
|
|||||||
connect(addLabelAction,SIGNAL(triggered()),this,SLOT(showAddNewLabelDialog()));
|
connect(addLabelAction,SIGNAL(triggered()),this,SLOT(showAddNewLabelDialog()));
|
||||||
connect(renameListAction,SIGNAL(triggered()),this,SLOT(showRenameCurrentList()));
|
connect(renameListAction,SIGNAL(triggered()),this,SLOT(showRenameCurrentList()));
|
||||||
|
|
||||||
|
connect(listsModel,SIGNAL(addComicsToFavorites(QList<qulonglong>)),comicsModel,SLOT(addComicsToFavorites(QList<qulonglong>)));
|
||||||
|
connect(listsModel,SIGNAL(addComicsToLabel(QList<qulonglong>,qulonglong)),comicsModel,SLOT(addComicsToLabel(QList<qulonglong>,qulonglong)));
|
||||||
|
connect(listsModel,SIGNAL(addComicsToReadingList(QList<qulonglong>,qulonglong)),comicsModel,SLOT(addComicsToReadingList(QList<qulonglong>,qulonglong)));
|
||||||
//--
|
//--
|
||||||
|
|
||||||
connect(addToFavoritesAction,SIGNAL(triggered()),this,SLOT(addSelectedComicsToFavorites()));
|
connect(addToFavoritesAction,SIGNAL(triggered()),this,SLOT(addSelectedComicsToFavorites()));
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import QtQuick 2.3
|
import QtQuick 2.3
|
||||||
import QtQuick.Controls 1.0
|
|
||||||
import QtQuick.Controls 1.1
|
import QtQuick.Controls 1.2
|
||||||
import QtGraphicalEffects 1.0
|
import QtGraphicalEffects 1.0
|
||||||
import comicModel 1.0
|
import comicModel 1.0
|
||||||
|
|
||||||
@ -39,13 +39,21 @@ Rectangle {
|
|||||||
id: realCell
|
id: realCell
|
||||||
|
|
||||||
property int position : 0
|
property int position : 0
|
||||||
|
property bool dragging: false;
|
||||||
Drag.active: mouseArea.drag.active
|
Drag.active: mouseArea.drag.active
|
||||||
Drag.hotSpot.x: 32
|
Drag.hotSpot.x: 32
|
||||||
Drag.hotSpot.y: 32
|
Drag.hotSpot.y: 32
|
||||||
Drag.dragType: Drag.Automatic
|
Drag.dragType: Drag.Automatic
|
||||||
Drag.mimeData: { "text/plain": titleText.text }
|
//Drag.mimeData: { "x": 1 }
|
||||||
Drag.proposedAction: Qt.CopyAction
|
Drag.proposedAction: Qt.CopyAction
|
||||||
|
Drag.onActiveChanged: {
|
||||||
|
if(!dragging)
|
||||||
|
{
|
||||||
|
comicsSelectionHelper.startDrag();
|
||||||
|
dragging = true;
|
||||||
|
}else
|
||||||
|
dragging = false;
|
||||||
|
}
|
||||||
|
|
||||||
width: 156; height: 287
|
width: 156; height: 287
|
||||||
color: ((dummyValue || !dummyValue) && comicsSelectionHelper.isSelectedIndex(index)) || grid.currentIndex === index?selectedColor:cellColor;
|
color: ((dummyValue || !dummyValue) && comicsSelectionHelper.isSelectedIndex(index)) || grid.currentIndex === index?selectedColor:cellColor;
|
||||||
@ -65,8 +73,8 @@ Rectangle {
|
|||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
onDoubleClicked: {
|
|
||||||
|
|
||||||
|
onDoubleClicked: {
|
||||||
comicsSelectionHelper.clear();
|
comicsSelectionHelper.clear();
|
||||||
|
|
||||||
comicsSelectionHelper.selectIndex(index);
|
comicsSelectionHelper.selectIndex(index);
|
||||||
@ -74,13 +82,14 @@ Rectangle {
|
|||||||
comicsSelectionHelper.selectedItem(index);
|
comicsSelectionHelper.selectedItem(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: {
|
onPressed: {
|
||||||
//grid.currentIndex = index
|
//grid.currentIndex = index
|
||||||
//comicsSelection.setCurrentIndex(index,0x0002)
|
//comicsSelection.setCurrentIndex(index,0x0002)
|
||||||
var ci = grid.currentIndex;
|
var ci = grid.currentIndex;
|
||||||
if(mouse.button != Qt.RightButton && !(mouse.modifiers & Qt.ControlModifier || mouse.modifiers & Qt.ShiftModifier))
|
if(mouse.button != Qt.RightButton && !(mouse.modifiers & Qt.ControlModifier || mouse.modifiers & Qt.ShiftModifier))
|
||||||
{
|
{
|
||||||
comicsSelectionHelper.clear();
|
if(!comicsSelectionHelper.isSelectedIndex(index))
|
||||||
|
comicsSelectionHelper.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mouse.modifiers & Qt.ShiftModifier)
|
if(mouse.modifiers & Qt.ShiftModifier)
|
||||||
@ -126,9 +135,8 @@ Rectangle {
|
|||||||
anchors {horizontalCenter: parent.horizontalCenter; top: realCell.top; topMargin: 4}
|
anchors {horizontalCenter: parent.horizontalCenter; top: realCell.top; topMargin: 4}
|
||||||
source: cover_path
|
source: cover_path
|
||||||
fillMode: Image.PreserveAspectCrop
|
fillMode: Image.PreserveAspectCrop
|
||||||
//smooth: true
|
smooth: true
|
||||||
mipmap: true
|
mipmap: true
|
||||||
//antialiasing: true
|
|
||||||
asynchronous : true
|
asynchronous : true
|
||||||
cache: false //TODO clear cache only when it is neede
|
cache: false //TODO clear cache only when it is neede
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,6 +46,7 @@ void YACReaderFoldersView::dragLeaveEvent(QDragLeaveEvent *event)
|
|||||||
void YACReaderFoldersView::dragMoveEvent(QDragMoveEvent *event)
|
void YACReaderFoldersView::dragMoveEvent(QDragMoveEvent *event)
|
||||||
{
|
{
|
||||||
YACReaderTreeView::dragMoveEvent(event);
|
YACReaderTreeView::dragMoveEvent(event);
|
||||||
|
event->acceptProposedAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
void YACReaderFoldersView::dropEvent(QDropEvent *event)
|
void YACReaderFoldersView::dropEvent(QDropEvent *event)
|
||||||
@ -58,7 +59,6 @@ void YACReaderFoldersView::dropEvent(QDropEvent *event)
|
|||||||
|
|
||||||
if(validAction)
|
if(validAction)
|
||||||
{
|
{
|
||||||
|
|
||||||
QList<QPair<QString, QString> > droppedFiles = ComicFilesManager::getDroppedFiles(event->mimeData()->urls());
|
QList<QPair<QString, QString> > droppedFiles = ComicFilesManager::getDroppedFiles(event->mimeData()->urls());
|
||||||
QModelIndex destinationIndex = indexAt(event->pos());
|
QModelIndex destinationIndex = indexAt(event->pos());
|
||||||
|
|
||||||
|
|||||||
@ -14,6 +14,14 @@ void YACReaderReadingListsView::dragEnterEvent(QDragEnterEvent *event)
|
|||||||
{
|
{
|
||||||
YACReaderTreeView::dragEnterEvent(event);
|
YACReaderTreeView::dragEnterEvent(event);
|
||||||
|
|
||||||
|
/*QModelIndex destinationIndex = indexAt(event->pos());
|
||||||
|
if(model()->canDropMimeData(event->mimeData(), event->proposedAction(), destinationIndex.row(), destinationIndex.column(), destinationIndex.parent()))*/
|
||||||
|
event->acceptProposedAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderReadingListsView::dragMoveEvent(QDragMoveEvent *event)
|
||||||
|
{
|
||||||
|
YACReaderTreeView::dragMoveEvent(event);
|
||||||
QModelIndex destinationIndex = indexAt(event->pos());
|
QModelIndex destinationIndex = indexAt(event->pos());
|
||||||
if(model()->canDropMimeData(event->mimeData(), event->proposedAction(), destinationIndex.row(), destinationIndex.column(), destinationIndex.parent()))
|
if(model()->canDropMimeData(event->mimeData(), event->proposedAction(), destinationIndex.row(), destinationIndex.column(), destinationIndex.parent()))
|
||||||
event->acceptProposedAction();
|
event->acceptProposedAction();
|
||||||
|
|||||||
@ -14,6 +14,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
//Drop to import
|
//Drop to import
|
||||||
void dragEnterEvent(QDragEnterEvent *event);
|
void dragEnterEvent(QDragEnterEvent *event);
|
||||||
|
void dragMoveEvent(QDragMoveEvent *event);
|
||||||
};
|
};
|
||||||
|
|
||||||
class YACReaderReadingListsViewItemDeletegate: public QStyledItemDelegate
|
class YACReaderReadingListsViewItemDeletegate: public QStyledItemDelegate
|
||||||
|
|||||||
@ -71,6 +71,8 @@
|
|||||||
namespace YACReader
|
namespace YACReader
|
||||||
{
|
{
|
||||||
|
|
||||||
|
static const QString YACReaderLibrarComiscSelectionMimeDataFormat = "application/yacreaderlibrary-comics-ids";
|
||||||
|
|
||||||
enum FlowType
|
enum FlowType
|
||||||
{
|
{
|
||||||
CoverFlowLike=0,
|
CoverFlowLike=0,
|
||||||
|
|||||||
@ -114,7 +114,7 @@ void YACReaderTableView::mouseMoveEvent(QMouseEvent *event)
|
|||||||
performDrag();
|
performDrag();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//disabled mouseMoveEvent in the parent class
|
||||||
}
|
}
|
||||||
void YACReaderTableView::mousePressEvent(QMouseEvent * event)
|
void YACReaderTableView::mousePressEvent(QMouseEvent * event)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -123,7 +123,6 @@ void YACReaderTreeView::dragLeaveEvent(QDragLeaveEvent *event)
|
|||||||
void YACReaderTreeView::dragMoveEvent(QDragMoveEvent *event)
|
void YACReaderTreeView::dragMoveEvent(QDragMoveEvent *event)
|
||||||
{
|
{
|
||||||
QTreeView::dragMoveEvent(event);
|
QTreeView::dragMoveEvent(event);
|
||||||
event->acceptProposedAction();
|
|
||||||
|
|
||||||
//fix for drop auto expand
|
//fix for drop auto expand
|
||||||
QModelIndex underMouse = indexAt(event->pos());
|
QModelIndex underMouse = indexAt(event->pos());
|
||||||
|
|||||||
Reference in New Issue
Block a user