diff --git a/YACReaderLibrary/comic_files_manager.cpp b/YACReaderLibrary/comic_files_manager.cpp index 0d2f3ef9..c40383c4 100644 --- a/YACReaderLibrary/comic_files_manager.cpp +++ b/YACReaderLibrary/comic_files_manager.cpp @@ -5,30 +5,61 @@ #include +#include "comic.h" + ComicFilesManager::ComicFilesManager(QObject *parent) : QObject(parent), canceled(false) { } -void ComicFilesManager::copyComicsTo(const QList &sourceComics, const QString &folderDest) +void ComicFilesManager::copyComicsTo(const QList > &sourceComics, const QString &folderDest) { comics = sourceComics; folder = folderDest; move = false; } -void ComicFilesManager::moveComicsTo(const QList &sourceComics, const QString &folderDest) +void ComicFilesManager::moveComicsTo(const QList > &sourceComics, const QString &folderDest) { comics = sourceComics; folder = folderDest; move = true; } +QList > ComicFilesManager::getDroppedFiles(const QList &urls) +{ + QList > dropedFiles; + + QString currentPath; + foreach(QUrl url, urls) + { + currentPath = url.toLocalFile(); + if(Comic::fileIsComic(currentPath)) + dropedFiles << QPair(currentPath,"/"); + else + { + QFileInfo info(currentPath); + if(info.isDir()) + { + foreach(QString comicPath, Comic::findValidComicFilesInFolder(info.absoluteFilePath())) + { + QFileInfo comicInfo(comicPath); + QString path = comicInfo.absolutePath(); + dropedFiles << QPair(comicPath, path.remove(info.absolutePath())); + } + } + } + } + + return dropedFiles; +} + void ComicFilesManager::process() { int i=0; bool successProcesingFiles = false; - foreach (QString source, comics) { + QPair source; + foreach (source, comics) { if(canceled) { @@ -39,12 +70,17 @@ void ComicFilesManager::process() return; //TODO rollback? } - QFileInfo info(source); - if(QFile::copy(source, QDir::cleanPath(folder+'/'+info.fileName()))) + QFileInfo info(source.first); + QString destPath = QDir::cleanPath(folder+'/'+source.second); + QLOG_DEBUG() << "crear : " << destPath; + QDir().mkpath(destPath); + if(QFile::copy(source.first, QDir::cleanPath(destPath+'/'+info.fileName()))) { successProcesingFiles = true; if(move) - QFile::remove(source); + { + QFile::remove(source.first); //TODO: remove the whole path.... + } } i++; diff --git a/YACReaderLibrary/comic_files_manager.h b/YACReaderLibrary/comic_files_manager.h index 7058e17e..14cb59aa 100644 --- a/YACReaderLibrary/comic_files_manager.h +++ b/YACReaderLibrary/comic_files_manager.h @@ -9,9 +9,9 @@ class ComicFilesManager : public QObject Q_OBJECT public: explicit ComicFilesManager(QObject *parent = 0); - void copyComicsTo(const QList & sourceComics, const QString & folderDest); - void moveComicsTo(const QList & comics, const QString & folderDest); - + void copyComicsTo(const QList > & sourceComics, const QString & folderDest); + void moveComicsTo(const QList > & comics, const QString & folderDest); + static QList > getDroppedFiles(const QList & urls); signals: void currentComic(QString); void progress(int); @@ -24,7 +24,7 @@ public slots: protected: bool move; bool canceled; - QList comics; + QList > comics; QString folder; }; diff --git a/YACReaderLibrary/comics_view.cpp b/YACReaderLibrary/comics_view.cpp index 8803594e..137a8889 100644 --- a/YACReaderLibrary/comics_view.cpp +++ b/YACReaderLibrary/comics_view.cpp @@ -1,5 +1,6 @@ #include "comics_view.h" #include "comic.h" +#include "comic_files_manager.h" #include "QsLog.h" @@ -21,9 +22,12 @@ void ComicsView::dragEnterEvent(QDragEnterEvent *event) if (event->mimeData()->hasUrls()) { urlList = event->mimeData()->urls(); + QString currentPath; foreach (QUrl url, urlList) { - if(Comic::fileIsComic(url)) + //comics or folders are accepted, folders' content is validate in dropEvent (avoid any lag before droping) + currentPath = url.toLocalFile(); + if(Comic::fileIsComic(currentPath) || QFileInfo(currentPath).isDir()) { event->acceptProposedAction(); return; @@ -34,20 +38,26 @@ void ComicsView::dragEnterEvent(QDragEnterEvent *event) void ComicsView::dropEvent(QDropEvent *event) { - bool accepted = false; -QLOG_DEBUG() << "drop" << event->dropAction(); - if(event->dropAction() == Qt::CopyAction) - { - QLOG_DEBUG() << "copy"; - emit copyComicsToCurrentFolder(Comic::filterInvalidComicFiles(event->mimeData()->urls())); + QLOG_DEBUG() << "drop" << event->dropAction(); - } - else if(event->dropAction() & Qt::MoveAction) - { - QLOG_DEBUG() << "move"; - emit moveComicsToCurrentFolder(Comic::filterInvalidComicFiles(event->mimeData()->urls())); - } + bool validAction = event->dropAction() == Qt::CopyAction || event->dropAction() & Qt::MoveAction; + + if(validAction) + { + + QList > droppedFiles = ComicFilesManager::getDroppedFiles(event->mimeData()->urls()); + + if(event->dropAction() == Qt::CopyAction) + { + QLOG_DEBUG() << "copy :" << droppedFiles; + emit copyComicsToCurrentFolder(droppedFiles); + } + else if(event->dropAction() & Qt::MoveAction) + { + QLOG_DEBUG() << "move :" << droppedFiles; + emit moveComicsToCurrentFolder(droppedFiles); + } - if(accepted) event->acceptProposedAction(); + } } diff --git a/YACReaderLibrary/comics_view.h b/YACReaderLibrary/comics_view.h index e920c572..488c2fd3 100644 --- a/YACReaderLibrary/comics_view.h +++ b/YACReaderLibrary/comics_view.h @@ -35,8 +35,8 @@ signals: void comicRated(int,QModelIndex); //Drops - void copyComicsToCurrentFolder(QList); - void moveComicsToCurrentFolder(QList); + void copyComicsToCurrentFolder(QList >); + void moveComicsToCurrentFolder(QList >); public slots: virtual void setShowMarks(bool show) = 0; diff --git a/YACReaderLibrary/db/treemodel.cpp b/YACReaderLibrary/db/treemodel.cpp index fda51b4b..bebe9096 100644 --- a/YACReaderLibrary/db/treemodel.cpp +++ b/YACReaderLibrary/db/treemodel.cpp @@ -544,3 +544,8 @@ QStringList TreeModel::getSubfoldersNames(const QModelIndex &mi) qSort(result.begin(),result.end(),naturalSortLessThanCI); return result; } + +void TreeModel::fetchMore(const QModelIndex &parent) +{ + +} diff --git a/YACReaderLibrary/db/treemodel.h b/YACReaderLibrary/db/treemodel.h index f288f8bc..7a5f61f4 100644 --- a/YACReaderLibrary/db/treemodel.h +++ b/YACReaderLibrary/db/treemodel.h @@ -87,6 +87,8 @@ public: QStringList getSubfoldersNames(const QModelIndex & mi); + void fetchMore(const QModelIndex & parent); + enum Columns { Name = 0, Path = 1, diff --git a/YACReaderLibrary/library_creator.cpp b/YACReaderLibrary/library_creator.cpp index 22b7ea2c..4234e7cd 100644 --- a/YACReaderLibrary/library_creator.cpp +++ b/YACReaderLibrary/library_creator.cpp @@ -38,7 +38,7 @@ using namespace std; LibraryCreator::LibraryCreator() :creation(false), partialUpdate(false) { - _nameFilter << "*.cbr" << "*.cbz" << "*.rar" << "*.zip" << "*.tar" << "*.pdf" << "*.7z" << "*.cb7" << "*.arj" << "*.cbt"; + _nameFilter << Comic::comicExtensions; } void LibraryCreator::createLibrary(const QString &source, const QString &target) @@ -66,11 +66,18 @@ void LibraryCreator::updateFolder(const QString &source, const QString &target, if(relativeFolderPath.startsWith("/")) relativeFolderPath = relativeFolderPath.remove(0,1);//remove firts '/' - QStringList folders = relativeFolderPath.split('/'); + QStringList folders; + + if(!relativeFolderPath.isEmpty()) //updating root + folders = relativeFolderPath.split('/'); + + QLOG_DEBUG() << "folders found in relative path : " << folders << "-" << relativeFolderPath; QSqlDatabase db = DataBaseManagement::loadDatabase(target); foreach (QString folderName, folders) { + if(folderName.isEmpty()) + break; qulonglong parentId = _currentPathFolders.last().id; _currentPathFolders.append(DBHelper::loadFolder(folderName, parentId, db)); QLOG_DEBUG() << "Folder appended : " << _currentPathFolders.last().id << " " << _currentPathFolders.last().name << " with parent" << _currentPathFolders.last().parentId; diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index d7b2ab14..621cc9c7 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -392,8 +392,8 @@ void LibraryWindow::disconnectComicsViewConnections(ComicsView * widget) disconnect(widget,SIGNAL(selected(unsigned int)),this,SLOT(openComic())); disconnect(widget,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(openComic())); disconnect(selectAllComicsAction,SIGNAL(triggered()),widget,SLOT(selectAll())); - disconnect(comicsView, SIGNAL(copyComicsToCurrentFolder(QList)), this, SLOT(copyAndImportComicsToCurrentFolder(QList))); - disconnect(comicsView, SIGNAL(moveComicsToCurrentFolder(QList)), this, SLOT(moveAndImportComicsToCurrentFolder(QList))); + disconnect(comicsView, SIGNAL(copyComicsToCurrentFolder(QList >)), this, SLOT(copyAndImportComicsToCurrentFolder(QList >))); + disconnect(comicsView, SIGNAL(moveComicsToCurrentFolder(QList >)), this, SLOT(moveAndImportComicsToCurrentFolder(QList >))); } void LibraryWindow::doComicsViewConnections() @@ -404,8 +404,8 @@ void LibraryWindow::doComicsViewConnections() connect(comicsView,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(openComic())); connect(selectAllComicsAction,SIGNAL(triggered()),comicsView,SLOT(selectAll())); //Drops - connect(comicsView, SIGNAL(copyComicsToCurrentFolder(QList)), this, SLOT(copyAndImportComicsToCurrentFolder(QList))); - connect(comicsView, SIGNAL(moveComicsToCurrentFolder(QList)), this, SLOT(moveAndImportComicsToCurrentFolder(QList))); + connect(comicsView, SIGNAL(copyComicsToCurrentFolder(QList >)), this, SLOT(copyAndImportComicsToCurrentFolder(QList >))); + connect(comicsView, SIGNAL(moveComicsToCurrentFolder(QList >)), this, SLOT(moveAndImportComicsToCurrentFolder(QList >))); } void LibraryWindow::createActions() @@ -993,8 +993,8 @@ void LibraryWindow::createConnections() connect(foldersView, SIGNAL(clicked(QModelIndex)), this, SLOT(updateHistory(QModelIndex))); //drops in folders view - connect(foldersView, SIGNAL(copyComicsToFolder(QList,QModelIndex)), this, SLOT(copyAndImportComicsToFolder(QList,QModelIndex))); - connect(foldersView, SIGNAL(moveComicsToFolder(QList,QModelIndex)), this, SLOT(moveAndImportComicsToFolder(QList,QModelIndex))); + connect(foldersView, SIGNAL(copyComicsToFolder(QList >,QModelIndex)), this, SLOT(copyAndImportComicsToFolder(QList >,QModelIndex))); + connect(foldersView, SIGNAL(moveComicsToFolder(QList >,QModelIndex)), this, SLOT(moveAndImportComicsToFolder(QList >,QModelIndex))); //actions connect(createLibraryAction,SIGNAL(triggered()),this,SLOT(createLibrary())); @@ -1282,37 +1282,46 @@ void LibraryWindow::loadCoversFromCurrentModel() } } -void LibraryWindow::copyAndImportComicsToCurrentFolder(const QList &comics) +void LibraryWindow::copyAndImportComicsToCurrentFolder(const QList > &comics) { - QString destFolderPath = currentFolderPath(); + QLOG_DEBUG() << "-copyAndImportComicsToCurrentFolder-"; + if(comics.size()>0) + { + QString destFolderPath = currentFolderPath(); - updateDestination = getCurrentFolderIndex(); + updateDestination = getCurrentFolderIndex(); - QProgressDialog * progressDialog = newProgressDialog(tr("Copying comics..."),comics.size()); + QProgressDialog * progressDialog = newProgressDialog(tr("Copying comics..."),comics.size()); - ComicFilesManager * comicFilesManager = new ComicFilesManager(); - comicFilesManager->copyComicsTo(comics,destFolderPath); + ComicFilesManager * comicFilesManager = new ComicFilesManager(); + comicFilesManager->copyComicsTo(comics,destFolderPath); - processComicFiles(comicFilesManager, progressDialog); + processComicFiles(comicFilesManager, progressDialog); + } } -void LibraryWindow::moveAndImportComicsToCurrentFolder(const QList &comics) +void LibraryWindow::moveAndImportComicsToCurrentFolder(const QList > &comics) { - QString destFolderPath = currentFolderPath(); + QLOG_DEBUG() << "-moveAndImportComicsToCurrentFolder-"; + if(comics.size()>0) + { + QString destFolderPath = currentFolderPath(); - updateDestination = getCurrentFolderIndex(); + updateDestination = getCurrentFolderIndex(); - QProgressDialog * progressDialog = newProgressDialog(tr("Moving comics..."),comics.size()); + QProgressDialog * progressDialog = newProgressDialog(tr("Moving comics..."),comics.size()); - ComicFilesManager * comicFilesManager = new ComicFilesManager(); - comicFilesManager->moveComicsTo(comics,destFolderPath); + ComicFilesManager * comicFilesManager = new ComicFilesManager(); + comicFilesManager->moveComicsTo(comics,destFolderPath); - processComicFiles(comicFilesManager, progressDialog); + processComicFiles(comicFilesManager, progressDialog); + } } -void LibraryWindow::copyAndImportComicsToFolder(const QList &comics, const QModelIndex &miFolder) +void LibraryWindow::copyAndImportComicsToFolder(const QList > &comics, const QModelIndex &miFolder) { - if(miFolder.isValid()) + QLOG_DEBUG() << "-copyAndImportComicsToFolder-"; + if(comics.size()>0) { QString destFolderPath = QDir::cleanPath(currentPath()+foldersModel->getFolderPath(miFolder)); @@ -1329,9 +1338,10 @@ void LibraryWindow::copyAndImportComicsToFolder(const QList &comics, co } } -void LibraryWindow::moveAndImportComicsToFolder(const QList &comics, const QModelIndex &miFolder) +void LibraryWindow::moveAndImportComicsToFolder(const QList > &comics, const QModelIndex &miFolder) { - if(miFolder.isValid()) + QLOG_DEBUG() << "-moveAndImportComicsToFolder-"; + if(comics.size()>0) { QString destFolderPath = QDir::cleanPath(currentPath()+foldersModel->getFolderPath(miFolder)); @@ -1415,6 +1425,9 @@ void LibraryWindow::reloadAfterCopyMove() if(getCurrentFolderIndex() == updateDestination) reloadCovers(); + //TODO do not reload the whole model, just the current folder... + foldersModel->setupModelData(QDir::cleanPath(libraries.getPath(selectedLibrary->currentText())+"/.yacreaderlibrary")); + enableNeededActions(); } diff --git a/YACReaderLibrary/library_window.h b/YACReaderLibrary/library_window.h index 10ac5b5c..b0fa49db 100644 --- a/YACReaderLibrary/library_window.h +++ b/YACReaderLibrary/library_window.h @@ -326,10 +326,10 @@ public slots: void toggleComicsView(); void checkSearchNumResults(int numResults); void loadCoversFromCurrentModel(); - void copyAndImportComicsToCurrentFolder(const QList & comics); - void moveAndImportComicsToCurrentFolder(const QList &comics); - void copyAndImportComicsToFolder(const QList & comics, const QModelIndex & miFolder); - void moveAndImportComicsToFolder(const QList & comics, const QModelIndex & miFolder); + void copyAndImportComicsToCurrentFolder(const QList > & comics); + void moveAndImportComicsToCurrentFolder(const QList > &comics); + void copyAndImportComicsToFolder(const QList > & comics, const QModelIndex & miFolder); + void moveAndImportComicsToFolder(const QList > & comics, const QModelIndex & miFolder); void processComicFiles(ComicFilesManager * comicFilesManager, QProgressDialog * progressDialog); void updateCopyMoveFolderDestination(); //imports new comics from the current folder void updateCurrentFolder(); diff --git a/common/comic.cpp b/common/comic.cpp index e06adb95..86b3095d 100644 --- a/common/comic.cpp +++ b/common/comic.cpp @@ -13,11 +13,13 @@ #include "compressed_archive.h" #include "comic_db.h" -QStringList Comic::imageExtensions = QStringList() << "*.jpg" << "*.jpeg" << "*.png" << "*.gif" << "*.tiff" << "*.tif" << "*.bmp"; -QStringList Comic::literalImageExtensions = QStringList() << "jpg" << "jpeg" << "png" << "gif" << "tiff" << "tif" << "bmp"; +#include "QsLog.h" -QStringList Comic::comicExtensions = QStringList() << "*.cbr" << "*.cbz" << "*.rar" << "*.zip" << "*.tar" << "*.pdf" << "*.7z" << "*.cb7" << "*.arj" << "*.cbt"; -QStringList Comic::literalComicExtensions = QStringList() << "cbr" << "cbz" << "rar" << "zip" << "tar" << "pdf" << "7z" << "cb7" << "arj" << "cbt"; +const QStringList Comic::imageExtensions = QStringList() << "*.jpg" << "*.jpeg" << "*.png" << "*.gif" << "*.tiff" << "*.tif" << "*.bmp"; +const QStringList Comic::literalImageExtensions = QStringList() << "jpg" << "jpeg" << "png" << "gif" << "tiff" << "tif" << "bmp"; + +const QStringList Comic::comicExtensions = QStringList() << "*.cbr" << "*.cbz" << "*.rar" << "*.zip" << "*.tar" << "*.pdf" << "*.7z" << "*.cb7" << "*.arj" << "*.cbt"; +const QStringList Comic::literalComicExtensions = QStringList() << "cbr" << "cbz" << "rar" << "zip" << "tar" << "pdf" << "7z" << "cb7" << "arj" << "cbt"; //----------------------------------------------------------------------------- Comic::Comic() @@ -183,18 +185,52 @@ bool Comic::pageIsLoaded(int page) return _loadedPages[page]; } -bool Comic::fileIsComic(QUrl &path) +bool Comic::fileIsComic(const QString &path) { - QFileInfo info(path.toLocalFile()); + QFileInfo info(path); return literalComicExtensions.contains(info.suffix()); } -QList Comic::filterInvalidComicFiles(const QList &list) +QList Comic::findValidComicFiles(const QList &list) { + QLOG_DEBUG() << "-findValidComicFiles-"; QList validComicFiles; + QString currentPath; foreach (QUrl url, list) { - if(Comic::fileIsComic(url)) - validComicFiles << url.toLocalFile(); + currentPath = url.toLocalFile(); + if(Comic::fileIsComic(currentPath)) + validComicFiles << currentPath; + else if(QFileInfo(currentPath).isDir()) + { + validComicFiles << findValidComicFilesInFolder(currentPath); + } + } + QLOG_DEBUG() << "-" << validComicFiles << "-"; + return validComicFiles; +} + +QList Comic::findValidComicFilesInFolder(const QString &path) +{ + QLOG_DEBUG() << "-findValidComicFilesInFolder-" << path; + + if(!QFileInfo(path).isDir()) + return QList(); + + QList validComicFiles; + QDir folder(path); + folder.setNameFilters(Comic::comicExtensions); + folder.setFilter(QDir::AllDirs|QDir::Files|QDir::NoDotAndDotDot); + QFileInfoList folderContent = folder.entryInfoList(); + + QString currentPath; + foreach (QFileInfo info, folderContent) { + currentPath = info.absoluteFilePath(); + if(info.isDir()) + validComicFiles << findValidComicFilesInFolder(currentPath); //find comics recursively + else if(Comic::fileIsComic(currentPath)) + { + validComicFiles << currentPath; + } } return validComicFiles; diff --git a/common/comic.h b/common/comic.h index f4a96942..2f633429 100644 --- a/common/comic.h +++ b/common/comic.h @@ -49,13 +49,14 @@ class ComicDB; bool _isPDF; - static QStringList imageExtensions; - static QStringList literalImageExtensions; - static QStringList comicExtensions; - static QStringList literalComicExtensions; - public: - Bookmarks * bm; + + static const QStringList imageExtensions; + static const QStringList literalImageExtensions; + static const QStringList comicExtensions; + static const QStringList literalComicExtensions; + + Bookmarks * bm; //Constructors Comic(); @@ -84,9 +85,9 @@ class ComicDB; inline static QStringList getSupportedImageFormats() { return imageExtensions;} inline static QStringList getSupportedImageLiteralFormats() { return literalImageExtensions;} - static bool fileIsComic(QUrl & path); - static QList filterInvalidComicFiles(const QList & list); - + static bool fileIsComic(const QString &path); + static QList findValidComicFiles(const QList & list); + static QList findValidComicFilesInFolder(const QString &path); public slots: void loadFinished(); void setBookmark(); diff --git a/custom_widgets/yacreader_treeview.cpp b/custom_widgets/yacreader_treeview.cpp index 03d28878..a6410481 100644 --- a/custom_widgets/yacreader_treeview.cpp +++ b/custom_widgets/yacreader_treeview.cpp @@ -3,6 +3,7 @@ #include "treemodel.h" #include "comic.h" +#include "comic_files_manager.h" #include "QsLog.h" @@ -77,9 +78,12 @@ void YACReaderTreeView::dragEnterEvent(QDragEnterEvent *event) if (event->mimeData()->hasUrls()) { urlList = event->mimeData()->urls(); + QString currentPath; foreach (QUrl url, urlList) { - if(Comic::fileIsComic(url)) + //comics or folders are accepted, folders' content is validate in dropEvent (avoid any lag before droping) + currentPath = url.toLocalFile(); + if(Comic::fileIsComic(currentPath) || QFileInfo(currentPath).isDir()) { event->acceptProposedAction(); return; @@ -88,20 +92,25 @@ void YACReaderTreeView::dragEnterEvent(QDragEnterEvent *event) } } +void YACReaderTreeView::dragLeaveEvent(QDragLeaveEvent *event) +{ + Q_UNUSED(event) +} + void YACReaderTreeView::dragMoveEvent(QDragMoveEvent *event) { QTreeView::dragMoveEvent(event); event->acceptProposedAction(); //fix for drop auto expand - QModelIndex lastExpanded = indexAt(expandPos); QModelIndex underMouse = indexAt(event->pos()); - if( underMouse.isValid() && (underMouse != lastExpanded)) { + if( underMouse.isValid()) { expandPos = event->pos(); connect(&expandTimer,SIGNAL(timeout()),this,SLOT(expandCurrent())); - expandTimer.start(750); + expandTimer.setSingleShot(true); + expandTimer.start(500); } - //TODO force mouse hover decoration, why the event loop is not working here? + //force mouse hover decoration, TODO why the event loop is not working here? if(!t.isActive()) { t.setSingleShot(true); @@ -114,24 +123,33 @@ void YACReaderTreeView::dragMoveEvent(QDragMoveEvent *event) void YACReaderTreeView::dropEvent(QDropEvent *event) { + t.stop(); + QTreeView::dropEvent(event); - bool accepted = false; QLOG_DEBUG() << "drop on tree" << event->dropAction(); - if(event->dropAction() == Qt::CopyAction) - { - QLOG_DEBUG() << "copy - tree"; - emit copyComicsToFolder(Comic::filterInvalidComicFiles(event->mimeData()->urls()),indexAt(event->pos())); - } - else if(event->dropAction() & Qt::MoveAction) - { - QLOG_DEBUG() << "move - tree"; - emit moveComicsToFolder(Comic::filterInvalidComicFiles(event->mimeData()->urls()),indexAt(event->pos())); - } + bool validAction = event->dropAction() == Qt::CopyAction || event->dropAction() & Qt::MoveAction; + + if(validAction) + { + + QList > droppedFiles = ComicFilesManager::getDroppedFiles(event->mimeData()->urls()); + QModelIndex destinationIndex = indexAt(event->pos()); + + if(event->dropAction() == Qt::CopyAction) + { + QLOG_DEBUG() << "copy - tree :" << droppedFiles; + emit copyComicsToFolder(droppedFiles, destinationIndex); + } + else if(event->dropAction() & Qt::MoveAction) + { + QLOG_DEBUG() << "move - tree :" << droppedFiles; + emit moveComicsToFolder(droppedFiles, destinationIndex); + } - if(accepted) event->acceptProposedAction(); + } } diff --git a/custom_widgets/yacreader_treeview.h b/custom_widgets/yacreader_treeview.h index e0c48cd1..a70e8615 100644 --- a/custom_widgets/yacreader_treeview.h +++ b/custom_widgets/yacreader_treeview.h @@ -11,8 +11,8 @@ public: signals: //Drops - void copyComicsToFolder(QList,QModelIndex); - void moveComicsToFolder(QList,QModelIndex); + void copyComicsToFolder(QList >,QModelIndex); + void moveComicsToFolder(QList >,QModelIndex); protected slots: //fix for drop auto expand @@ -21,9 +21,11 @@ protected slots: protected: //Drop to import void dragEnterEvent(QDragEnterEvent *event); + void dragLeaveEvent(QDragLeaveEvent *event); void dragMoveEvent(QDragMoveEvent *event); void dropEvent(QDropEvent *event); + //fix for drop auto expand QTimer expandTimer; QTimer t;