From dcdaad92cf9c9e277f40b255b681ec5f2069ad12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sat, 14 Jul 2012 09:56:50 +0200 Subject: [PATCH] cambiado casting de void * a uint por qint64 (se evita el error ce compilaci?n al compilar en 64 bit) --- COPYING.txt | 674 +++++++++ README.txt | 4 + YACReader/YACReader.pro | 57 + YACReader/bookmarks.cpp | 159 ++ YACReader/bookmarks.h | 77 + YACReader/bookmarks_dialog.cpp | 182 +++ YACReader/bookmarks_dialog.h | 45 + YACReader/comic.cpp | 289 ++++ YACReader/comic.h | 70 + YACReader/configuration.cpp | 199 +++ YACReader/configuration.h | 77 + YACReader/files.qrc | 15 + YACReader/goto_dialog.cpp | 75 + YACReader/goto_dialog.h | 31 + YACReader/goto_flow.cpp | 373 +++++ YACReader/goto_flow.h | 105 ++ YACReader/icon.ico | Bin 0 -> 99678 bytes YACReader/icon.rc | 1 + YACReader/images.qrc | 67 + YACReader/magnifying_glass.cpp | 267 ++++ YACReader/magnifying_glass.h | 34 + YACReader/main.cpp | 34 + YACReader/main_window_viewer.cpp | 680 +++++++++ YACReader/main_window_viewer.h | 115 ++ YACReader/options_dialog.cpp | 188 +++ YACReader/options_dialog.h | 57 + YACReader/render.cpp | 746 +++++++++ YACReader/render.h | 177 +++ YACReader/shortcuts_dialog.cpp | 74 + YACReader/shortcuts_dialog.h | 19 + YACReader/translator.cpp | 88 ++ YACReader/translator.h | 32 + YACReader/viewer.cpp | 671 +++++++++ YACReader/viewer.h | 131 ++ YACReader/yacreader_es.qm | Bin 0 -> 9964 bytes YACReader/yacreader_es.ts | 569 +++++++ YACReader/yacreader_fr.ts | 548 +++++++ YACReaderLibrary/YACReaderLibrary.pro | 82 + YACReaderLibrary/add_library_dialog.cpp | 91 ++ YACReaderLibrary/add_library_dialog.h | 33 + YACReaderLibrary/bundle_creator.cpp | 13 + YACReaderLibrary/bundle_creator.h | 14 + YACReaderLibrary/comic_flow.cpp | 205 +++ YACReaderLibrary/comic_flow.h | 73 + YACReaderLibrary/create_library_dialog.cpp | 192 +++ YACReaderLibrary/create_library_dialog.h | 56 + YACReaderLibrary/db/comic.cpp | 665 ++++++++ YACReaderLibrary/db/comic.h | 139 ++ YACReaderLibrary/db/data_base_management.cpp | 579 +++++++ YACReaderLibrary/db/data_base_management.h | 58 + YACReaderLibrary/db/folder.cpp | 71 + YACReaderLibrary/db/folder.h | 26 + YACReaderLibrary/db/library_item.cpp | 0 YACReaderLibrary/db/library_item.h | 17 + YACReaderLibrary/db/tableitem.cpp | 43 + YACReaderLibrary/db/tableitem.h | 26 + YACReaderLibrary/db/tablemodel.cpp | 366 +++++ YACReaderLibrary/db/tablemodel.h | 59 + YACReaderLibrary/db/treeitem.cpp | 147 ++ YACReaderLibrary/db/treeitem.h | 78 + YACReaderLibrary/db/treemodel.cpp | 413 +++++ YACReaderLibrary/db/treemodel.h | 106 ++ .../export_comics_info_dialog.cpp | 84 ++ YACReaderLibrary/export_comics_info_dialog.h | 35 + YACReaderLibrary/export_library_dialog.cpp | 96 ++ YACReaderLibrary/export_library_dialog.h | 36 + YACReaderLibrary/files.qrc | 13 + YACReaderLibrary/icon.ico | Bin 0 -> 99678 bytes YACReaderLibrary/icon.rc | 2 + YACReaderLibrary/icon2.ico | Bin 0 -> 99678 bytes YACReaderLibrary/images.qrc | 41 + .../import_comics_info_dialog.cpp | 111 ++ YACReaderLibrary/import_comics_info_dialog.h | 52 + YACReaderLibrary/import_library_dialog.cpp | 144 ++ YACReaderLibrary/import_library_dialog.h | 43 + YACReaderLibrary/library_creator.cpp | 487 ++++++ YACReaderLibrary/library_creator.h | 81 + YACReaderLibrary/library_window.cpp | 1328 ++++++++++++++++ YACReaderLibrary/library_window.h | 207 +++ YACReaderLibrary/main.cpp | 25 + YACReaderLibrary/options_dialog.cpp | 148 ++ YACReaderLibrary/options_dialog.h | 50 + YACReaderLibrary/package_manager.cpp | 47 + YACReaderLibrary/package_manager.h | 24 + YACReaderLibrary/properties_dialog.cpp | 691 +++++++++ YACReaderLibrary/properties_dialog.h | 116 ++ YACReaderLibrary/rename_library_dialog.cpp | 68 + YACReaderLibrary/rename_library_dialog.h | 30 + .../server/controllers/dumpcontroller.cpp | 62 + .../server/controllers/dumpcontroller.h | 29 + .../controllers/fileuploadcontroller.cpp | 38 + .../server/controllers/fileuploadcontroller.h | 30 + .../server/controllers/formcontroller.cpp | 33 + .../server/controllers/formcontroller.h | 30 + .../server/controllers/sessioncontroller.cpp | 31 + .../server/controllers/sessioncontroller.h | 29 + .../server/controllers/templatecontroller.cpp | 31 + .../server/controllers/templatecontroller.h | 30 + YACReaderLibrary/server/documentcache.h | 4 + .../server/lib/bfHttpServer/bfHttpServer.pri | 12 + .../bfHttpServer/httpconnectionhandler.cpp | 154 ++ .../lib/bfHttpServer/httpconnectionhandler.h | 97 ++ .../httpconnectionhandlerpool.cpp | 55 + .../bfHttpServer/httpconnectionhandlerpool.h | 69 + .../server/lib/bfHttpServer/httpcookie.cpp | 199 +++ .../server/lib/bfHttpServer/httpcookie.h | 110 ++ .../server/lib/bfHttpServer/httplistener.cpp | 56 + .../server/lib/bfHttpServer/httplistener.h | 76 + .../server/lib/bfHttpServer/httprequest.cpp | 435 ++++++ .../server/lib/bfHttpServer/httprequest.h | 214 +++ .../lib/bfHttpServer/httprequesthandler.cpp | 19 + .../lib/bfHttpServer/httprequesthandler.h | 45 + .../server/lib/bfHttpServer/httpresponse.cpp | 122 ++ .../server/lib/bfHttpServer/httpresponse.h | 134 ++ .../server/lib/bfHttpServer/httpsession.cpp | 158 ++ .../server/lib/bfHttpServer/httpsession.h | 118 ++ .../lib/bfHttpServer/httpsessionstore.cpp | 107 ++ .../lib/bfHttpServer/httpsessionstore.h | 104 ++ .../lib/bfHttpServer/staticfilecontroller.cpp | 165 ++ .../lib/bfHttpServer/staticfilecontroller.h | 85 ++ .../server/lib/bfLogging/bfLogging.pri | 7 + .../server/lib/bfLogging/dualfilelogger.cpp | 20 + .../server/lib/bfLogging/dualfilelogger.h | 60 + .../server/lib/bfLogging/filelogger.cpp | 176 +++ .../server/lib/bfLogging/filelogger.h | 131 ++ .../server/lib/bfLogging/logger.cpp | 154 ++ .../server/lib/bfLogging/logger.h | 144 ++ .../server/lib/bfLogging/logmessage.cpp | 68 + .../server/lib/bfLogging/logmessage.h | 74 + .../lib/bfTemplateEngine/bfTemplateEngine.pri | 7 + .../server/lib/bfTemplateEngine/template.cpp | 187 +++ .../server/lib/bfTemplateEngine/template.h | 167 +++ .../lib/bfTemplateEngine/templatecache.cpp | 30 + .../lib/bfTemplateEngine/templatecache.h | 77 + .../lib/bfTemplateEngine/templateloader.cpp | 103 ++ .../lib/bfTemplateEngine/templateloader.h | 85 ++ YACReaderLibrary/server/main.cpp | 58 + YACReaderLibrary/server/requestmapper.cpp | 46 + YACReaderLibrary/server/requestmapper.h | 36 + YACReaderLibrary/server/server.pri | 26 + YACReaderLibrary/server/startup.cpp | 77 + YACReaderLibrary/server/startup.h | 30 + YACReaderLibrary/server/static.cpp | 59 + YACReaderLibrary/server/static.h | 64 + YACReaderLibrary/yacreaderlibrary_es.qm | Bin 0 -> 9449 bytes YACReaderLibrary/yacreaderlibrary_es.ts | 522 +++++++ common/check_new_version.cpp | 112 ++ common/check_new_version.h | 32 + common/custom_widgets.cpp | 461 ++++++ common/custom_widgets.h | 189 +++ common/pictureflow.cpp | 1332 +++++++++++++++++ common/pictureflow.h | 224 +++ common/qnaturalsorting.cpp | 257 ++++ common/qnaturalsorting.h | 13 + files/about.html | 29 + files/about_es_ES.html | 30 + files/helpYACReader.html | 126 ++ files/helpYACReaderLibrary.html | 75 + files/helpYACReaderLibrary_es_ES.html | 73 + files/helpYACReader_es_ES.html | 126 ++ files/shortcuts.html | 38 + files/shortcuts2.html | 38 + files/translator.html | 639 ++++++++ generateVS2010Projects.bat | 31 + images/adjustToFullSize.png | Bin 0 -> 21893 bytes images/alwaysOnTop.png | Bin 0 -> 28230 bytes images/asignNumber.png | Bin 0 -> 18890 bytes images/bookmark.png | Bin 0 -> 24352 bytes images/center.png | Bin 0 -> 17966 bytes images/close.png | Bin 0 -> 8350 bytes images/colapse.png | Bin 0 -> 13159 bytes images/comicFolder.png | Bin 0 -> 26436 bytes images/coversPackage.png | Bin 0 -> 29501 bytes images/db.png | Bin 0 -> 16617 bytes images/deleteLibrary.png | Bin 0 -> 21641 bytes images/dictionary.png | Bin 0 -> 23238 bytes images/doublePage.png | Bin 0 -> 35580 bytes images/down.png | Bin 0 -> 689 bytes images/edit.png | Bin 0 -> 15944 bytes images/editComic.png | Bin 0 -> 27320 bytes images/expand.png | Bin 0 -> 18214 bytes images/exportComicsInfo.png | Bin 0 -> 20391 bytes images/exportLibrary.png | Bin 0 -> 29212 bytes images/fit.png | Bin 0 -> 6359 bytes images/flow1.png | Bin 0 -> 9112 bytes images/flow2.png | Bin 0 -> 13316 bytes images/flow3.png | Bin 0 -> 13026 bytes images/folder.png | Bin 0 -> 21534 bytes images/goto.png | Bin 0 -> 15572 bytes images/help.png | Bin 0 -> 16817 bytes images/helpImages/bookmark.png | Bin 0 -> 1801 bytes images/helpImages/center.png | Bin 0 -> 1645 bytes images/helpImages/colapse.png | Bin 0 -> 1379 bytes images/helpImages/comicFolder.png | Bin 0 -> 1826 bytes images/helpImages/coversPackage.png | Bin 0 -> 1670 bytes images/helpImages/deleteLibrary.png | Bin 0 -> 1601 bytes images/helpImages/doublePage.png | Bin 0 -> 1761 bytes images/helpImages/edit.png | Bin 0 -> 1399 bytes images/helpImages/expand.png | Bin 0 -> 1543 bytes images/helpImages/exportLibrary.png | Bin 0 -> 1633 bytes images/helpImages/fit.png | Bin 0 -> 1574 bytes images/helpImages/flow1.png | Bin 0 -> 766 bytes images/helpImages/flow2.png | Bin 0 -> 1039 bytes images/helpImages/flow3.png | Bin 0 -> 1038 bytes images/helpImages/folder.png | Bin 0 -> 1758 bytes images/helpImages/goto.png | Bin 0 -> 1369 bytes images/helpImages/help.png | Bin 0 -> 1615 bytes images/helpImages/icon.png | Bin 0 -> 1654 bytes images/helpImages/importLibrary.png | Bin 0 -> 1631 bytes images/helpImages/keyboard.png | Bin 0 -> 1502 bytes images/helpImages/mouse.png | Bin 0 -> 1550 bytes images/helpImages/new.png | Bin 0 -> 1685 bytes images/helpImages/next.png | Bin 0 -> 1665 bytes images/helpImages/nextComic.png | Bin 0 -> 1574 bytes images/helpImages/notCover.png | Bin 0 -> 583 bytes images/helpImages/open.png | Bin 0 -> 1790 bytes images/helpImages/openFolder.png | Bin 0 -> 1896 bytes images/helpImages/openLibrary.png | Bin 0 -> 1829 bytes images/helpImages/options.png | Bin 0 -> 1573 bytes images/helpImages/prev.png | Bin 0 -> 1694 bytes images/helpImages/previousComic.png | Bin 0 -> 1585 bytes images/helpImages/properties.png | Bin 0 -> 1721 bytes images/helpImages/removeLibrary.png | Bin 0 -> 1612 bytes images/helpImages/rotateL.png | Bin 0 -> 1757 bytes images/helpImages/rotateR.png | Bin 0 -> 1755 bytes images/helpImages/save.png | Bin 0 -> 1642 bytes images/helpImages/setBookmark.png | Bin 0 -> 1532 bytes images/helpImages/setRoot.png | Bin 0 -> 1810 bytes images/helpImages/shortcuts.png | Bin 0 -> 1703 bytes images/helpImages/speaker.png | Bin 0 -> 658 bytes images/helpImages/updateLibrary.png | Bin 0 -> 1589 bytes images/helpImages/zoom.png | Bin 0 -> 1618 bytes images/hideComicFlow.png | Bin 0 -> 18733 bytes images/icon.png | Bin 0 -> 20829 bytes images/importComicsInfo.png | Bin 0 -> 20723 bytes images/importCover.png | Bin 0 -> 25015 bytes images/importLibrary.png | Bin 0 -> 28417 bytes images/new.png | Bin 0 -> 17139 bytes images/next.png | Bin 0 -> 21672 bytes images/nextComic.png | Bin 0 -> 23796 bytes images/notCover.png | Bin 0 -> 104820 bytes images/open.png | Bin 0 -> 21566 bytes images/openFolder.png | Bin 0 -> 30976 bytes images/openLibrary.png | Bin 0 -> 29748 bytes images/options.png | Bin 0 -> 20699 bytes images/prev.png | Bin 0 -> 24468 bytes images/previousComic.png | Bin 0 -> 23714 bytes images/properties.png | Bin 0 -> 21282 bytes images/removeLibrary.png | Bin 0 -> 19700 bytes images/rotateL.png | Bin 0 -> 27714 bytes images/rotateR.png | Bin 0 -> 27567 bytes images/save.png | Bin 0 -> 23937 bytes images/selectAll.png | Bin 0 -> 19946 bytes images/setAllRead.png | Bin 0 -> 25807 bytes images/setAllUnread.png | Bin 0 -> 26128 bytes images/setBookmark.png | Bin 0 -> 17421 bytes images/setRead.png | Bin 0 -> 18976 bytes images/setRoot.png | Bin 0 -> 25357 bytes images/setUnread.png | Bin 0 -> 22095 bytes images/shortcuts.png | Bin 0 -> 16124 bytes images/showMarks.png | Bin 0 -> 24751 bytes images/up.png | Bin 0 -> 702 bytes images/updateLibrary.png | Bin 0 -> 20542 bytes images/zoom.png | Bin 0 -> 17891 bytes 264 files changed, 23555 insertions(+) create mode 100644 COPYING.txt create mode 100644 README.txt create mode 100644 YACReader/YACReader.pro create mode 100644 YACReader/bookmarks.cpp create mode 100644 YACReader/bookmarks.h create mode 100644 YACReader/bookmarks_dialog.cpp create mode 100644 YACReader/bookmarks_dialog.h create mode 100644 YACReader/comic.cpp create mode 100644 YACReader/comic.h create mode 100644 YACReader/configuration.cpp create mode 100644 YACReader/configuration.h create mode 100644 YACReader/files.qrc create mode 100644 YACReader/goto_dialog.cpp create mode 100644 YACReader/goto_dialog.h create mode 100644 YACReader/goto_flow.cpp create mode 100644 YACReader/goto_flow.h create mode 100644 YACReader/icon.ico create mode 100644 YACReader/icon.rc create mode 100644 YACReader/images.qrc create mode 100644 YACReader/magnifying_glass.cpp create mode 100644 YACReader/magnifying_glass.h create mode 100644 YACReader/main.cpp create mode 100644 YACReader/main_window_viewer.cpp create mode 100644 YACReader/main_window_viewer.h create mode 100644 YACReader/options_dialog.cpp create mode 100644 YACReader/options_dialog.h create mode 100644 YACReader/render.cpp create mode 100644 YACReader/render.h create mode 100644 YACReader/shortcuts_dialog.cpp create mode 100644 YACReader/shortcuts_dialog.h create mode 100644 YACReader/translator.cpp create mode 100644 YACReader/translator.h create mode 100644 YACReader/viewer.cpp create mode 100644 YACReader/viewer.h create mode 100644 YACReader/yacreader_es.qm create mode 100644 YACReader/yacreader_es.ts create mode 100644 YACReader/yacreader_fr.ts create mode 100644 YACReaderLibrary/YACReaderLibrary.pro create mode 100644 YACReaderLibrary/add_library_dialog.cpp create mode 100644 YACReaderLibrary/add_library_dialog.h create mode 100644 YACReaderLibrary/bundle_creator.cpp create mode 100644 YACReaderLibrary/bundle_creator.h create mode 100644 YACReaderLibrary/comic_flow.cpp create mode 100644 YACReaderLibrary/comic_flow.h create mode 100644 YACReaderLibrary/create_library_dialog.cpp create mode 100644 YACReaderLibrary/create_library_dialog.h create mode 100644 YACReaderLibrary/db/comic.cpp create mode 100644 YACReaderLibrary/db/comic.h create mode 100644 YACReaderLibrary/db/data_base_management.cpp create mode 100644 YACReaderLibrary/db/data_base_management.h create mode 100644 YACReaderLibrary/db/folder.cpp create mode 100644 YACReaderLibrary/db/folder.h create mode 100644 YACReaderLibrary/db/library_item.cpp create mode 100644 YACReaderLibrary/db/library_item.h create mode 100644 YACReaderLibrary/db/tableitem.cpp create mode 100644 YACReaderLibrary/db/tableitem.h create mode 100644 YACReaderLibrary/db/tablemodel.cpp create mode 100644 YACReaderLibrary/db/tablemodel.h create mode 100644 YACReaderLibrary/db/treeitem.cpp create mode 100644 YACReaderLibrary/db/treeitem.h create mode 100644 YACReaderLibrary/db/treemodel.cpp create mode 100644 YACReaderLibrary/db/treemodel.h create mode 100644 YACReaderLibrary/export_comics_info_dialog.cpp create mode 100644 YACReaderLibrary/export_comics_info_dialog.h create mode 100644 YACReaderLibrary/export_library_dialog.cpp create mode 100644 YACReaderLibrary/export_library_dialog.h create mode 100644 YACReaderLibrary/files.qrc create mode 100644 YACReaderLibrary/icon.ico create mode 100644 YACReaderLibrary/icon.rc create mode 100644 YACReaderLibrary/icon2.ico create mode 100644 YACReaderLibrary/images.qrc create mode 100644 YACReaderLibrary/import_comics_info_dialog.cpp create mode 100644 YACReaderLibrary/import_comics_info_dialog.h create mode 100644 YACReaderLibrary/import_library_dialog.cpp create mode 100644 YACReaderLibrary/import_library_dialog.h create mode 100644 YACReaderLibrary/library_creator.cpp create mode 100644 YACReaderLibrary/library_creator.h create mode 100644 YACReaderLibrary/library_window.cpp create mode 100644 YACReaderLibrary/library_window.h create mode 100644 YACReaderLibrary/main.cpp create mode 100644 YACReaderLibrary/options_dialog.cpp create mode 100644 YACReaderLibrary/options_dialog.h create mode 100644 YACReaderLibrary/package_manager.cpp create mode 100644 YACReaderLibrary/package_manager.h create mode 100644 YACReaderLibrary/properties_dialog.cpp create mode 100644 YACReaderLibrary/properties_dialog.h create mode 100644 YACReaderLibrary/rename_library_dialog.cpp create mode 100644 YACReaderLibrary/rename_library_dialog.h create mode 100644 YACReaderLibrary/server/controllers/dumpcontroller.cpp create mode 100644 YACReaderLibrary/server/controllers/dumpcontroller.h create mode 100644 YACReaderLibrary/server/controllers/fileuploadcontroller.cpp create mode 100644 YACReaderLibrary/server/controllers/fileuploadcontroller.h create mode 100644 YACReaderLibrary/server/controllers/formcontroller.cpp create mode 100644 YACReaderLibrary/server/controllers/formcontroller.h create mode 100644 YACReaderLibrary/server/controllers/sessioncontroller.cpp create mode 100644 YACReaderLibrary/server/controllers/sessioncontroller.h create mode 100644 YACReaderLibrary/server/controllers/templatecontroller.cpp create mode 100644 YACReaderLibrary/server/controllers/templatecontroller.h create mode 100644 YACReaderLibrary/server/documentcache.h create mode 100644 YACReaderLibrary/server/lib/bfHttpServer/bfHttpServer.pri create mode 100644 YACReaderLibrary/server/lib/bfHttpServer/httpconnectionhandler.cpp create mode 100644 YACReaderLibrary/server/lib/bfHttpServer/httpconnectionhandler.h create mode 100644 YACReaderLibrary/server/lib/bfHttpServer/httpconnectionhandlerpool.cpp create mode 100644 YACReaderLibrary/server/lib/bfHttpServer/httpconnectionhandlerpool.h create mode 100644 YACReaderLibrary/server/lib/bfHttpServer/httpcookie.cpp create mode 100644 YACReaderLibrary/server/lib/bfHttpServer/httpcookie.h create mode 100644 YACReaderLibrary/server/lib/bfHttpServer/httplistener.cpp create mode 100644 YACReaderLibrary/server/lib/bfHttpServer/httplistener.h create mode 100644 YACReaderLibrary/server/lib/bfHttpServer/httprequest.cpp create mode 100644 YACReaderLibrary/server/lib/bfHttpServer/httprequest.h create mode 100644 YACReaderLibrary/server/lib/bfHttpServer/httprequesthandler.cpp create mode 100644 YACReaderLibrary/server/lib/bfHttpServer/httprequesthandler.h create mode 100644 YACReaderLibrary/server/lib/bfHttpServer/httpresponse.cpp create mode 100644 YACReaderLibrary/server/lib/bfHttpServer/httpresponse.h create mode 100644 YACReaderLibrary/server/lib/bfHttpServer/httpsession.cpp create mode 100644 YACReaderLibrary/server/lib/bfHttpServer/httpsession.h create mode 100644 YACReaderLibrary/server/lib/bfHttpServer/httpsessionstore.cpp create mode 100644 YACReaderLibrary/server/lib/bfHttpServer/httpsessionstore.h create mode 100644 YACReaderLibrary/server/lib/bfHttpServer/staticfilecontroller.cpp create mode 100644 YACReaderLibrary/server/lib/bfHttpServer/staticfilecontroller.h create mode 100644 YACReaderLibrary/server/lib/bfLogging/bfLogging.pri create mode 100644 YACReaderLibrary/server/lib/bfLogging/dualfilelogger.cpp create mode 100644 YACReaderLibrary/server/lib/bfLogging/dualfilelogger.h create mode 100644 YACReaderLibrary/server/lib/bfLogging/filelogger.cpp create mode 100644 YACReaderLibrary/server/lib/bfLogging/filelogger.h create mode 100644 YACReaderLibrary/server/lib/bfLogging/logger.cpp create mode 100644 YACReaderLibrary/server/lib/bfLogging/logger.h create mode 100644 YACReaderLibrary/server/lib/bfLogging/logmessage.cpp create mode 100644 YACReaderLibrary/server/lib/bfLogging/logmessage.h create mode 100644 YACReaderLibrary/server/lib/bfTemplateEngine/bfTemplateEngine.pri create mode 100644 YACReaderLibrary/server/lib/bfTemplateEngine/template.cpp create mode 100644 YACReaderLibrary/server/lib/bfTemplateEngine/template.h create mode 100644 YACReaderLibrary/server/lib/bfTemplateEngine/templatecache.cpp create mode 100644 YACReaderLibrary/server/lib/bfTemplateEngine/templatecache.h create mode 100644 YACReaderLibrary/server/lib/bfTemplateEngine/templateloader.cpp create mode 100644 YACReaderLibrary/server/lib/bfTemplateEngine/templateloader.h create mode 100644 YACReaderLibrary/server/main.cpp create mode 100644 YACReaderLibrary/server/requestmapper.cpp create mode 100644 YACReaderLibrary/server/requestmapper.h create mode 100644 YACReaderLibrary/server/server.pri create mode 100644 YACReaderLibrary/server/startup.cpp create mode 100644 YACReaderLibrary/server/startup.h create mode 100644 YACReaderLibrary/server/static.cpp create mode 100644 YACReaderLibrary/server/static.h create mode 100644 YACReaderLibrary/yacreaderlibrary_es.qm create mode 100644 YACReaderLibrary/yacreaderlibrary_es.ts create mode 100644 common/check_new_version.cpp create mode 100644 common/check_new_version.h create mode 100644 common/custom_widgets.cpp create mode 100644 common/custom_widgets.h create mode 100644 common/pictureflow.cpp create mode 100644 common/pictureflow.h create mode 100644 common/qnaturalsorting.cpp create mode 100644 common/qnaturalsorting.h create mode 100644 files/about.html create mode 100644 files/about_es_ES.html create mode 100644 files/helpYACReader.html create mode 100644 files/helpYACReaderLibrary.html create mode 100644 files/helpYACReaderLibrary_es_ES.html create mode 100644 files/helpYACReader_es_ES.html create mode 100644 files/shortcuts.html create mode 100644 files/shortcuts2.html create mode 100644 files/translator.html create mode 100644 generateVS2010Projects.bat create mode 100644 images/adjustToFullSize.png create mode 100644 images/alwaysOnTop.png create mode 100644 images/asignNumber.png create mode 100644 images/bookmark.png create mode 100644 images/center.png create mode 100644 images/close.png create mode 100644 images/colapse.png create mode 100644 images/comicFolder.png create mode 100644 images/coversPackage.png create mode 100644 images/db.png create mode 100644 images/deleteLibrary.png create mode 100644 images/dictionary.png create mode 100644 images/doublePage.png create mode 100644 images/down.png create mode 100644 images/edit.png create mode 100644 images/editComic.png create mode 100644 images/expand.png create mode 100644 images/exportComicsInfo.png create mode 100644 images/exportLibrary.png create mode 100644 images/fit.png create mode 100644 images/flow1.png create mode 100644 images/flow2.png create mode 100644 images/flow3.png create mode 100644 images/folder.png create mode 100644 images/goto.png create mode 100644 images/help.png create mode 100644 images/helpImages/bookmark.png create mode 100644 images/helpImages/center.png create mode 100644 images/helpImages/colapse.png create mode 100644 images/helpImages/comicFolder.png create mode 100644 images/helpImages/coversPackage.png create mode 100644 images/helpImages/deleteLibrary.png create mode 100644 images/helpImages/doublePage.png create mode 100644 images/helpImages/edit.png create mode 100644 images/helpImages/expand.png create mode 100644 images/helpImages/exportLibrary.png create mode 100644 images/helpImages/fit.png create mode 100644 images/helpImages/flow1.png create mode 100644 images/helpImages/flow2.png create mode 100644 images/helpImages/flow3.png create mode 100644 images/helpImages/folder.png create mode 100644 images/helpImages/goto.png create mode 100644 images/helpImages/help.png create mode 100644 images/helpImages/icon.png create mode 100644 images/helpImages/importLibrary.png create mode 100644 images/helpImages/keyboard.png create mode 100644 images/helpImages/mouse.png create mode 100644 images/helpImages/new.png create mode 100644 images/helpImages/next.png create mode 100644 images/helpImages/nextComic.png create mode 100644 images/helpImages/notCover.png create mode 100644 images/helpImages/open.png create mode 100644 images/helpImages/openFolder.png create mode 100644 images/helpImages/openLibrary.png create mode 100644 images/helpImages/options.png create mode 100644 images/helpImages/prev.png create mode 100644 images/helpImages/previousComic.png create mode 100644 images/helpImages/properties.png create mode 100644 images/helpImages/removeLibrary.png create mode 100644 images/helpImages/rotateL.png create mode 100644 images/helpImages/rotateR.png create mode 100644 images/helpImages/save.png create mode 100644 images/helpImages/setBookmark.png create mode 100644 images/helpImages/setRoot.png create mode 100644 images/helpImages/shortcuts.png create mode 100644 images/helpImages/speaker.png create mode 100644 images/helpImages/updateLibrary.png create mode 100644 images/helpImages/zoom.png create mode 100644 images/hideComicFlow.png create mode 100644 images/icon.png create mode 100644 images/importComicsInfo.png create mode 100644 images/importCover.png create mode 100644 images/importLibrary.png create mode 100644 images/new.png create mode 100644 images/next.png create mode 100644 images/nextComic.png create mode 100644 images/notCover.png create mode 100644 images/open.png create mode 100644 images/openFolder.png create mode 100644 images/openLibrary.png create mode 100644 images/options.png create mode 100644 images/prev.png create mode 100644 images/previousComic.png create mode 100644 images/properties.png create mode 100644 images/removeLibrary.png create mode 100644 images/rotateL.png create mode 100644 images/rotateR.png create mode 100644 images/save.png create mode 100644 images/selectAll.png create mode 100644 images/setAllRead.png create mode 100644 images/setAllUnread.png create mode 100644 images/setBookmark.png create mode 100644 images/setRead.png create mode 100644 images/setRoot.png create mode 100644 images/setUnread.png create mode 100644 images/shortcuts.png create mode 100644 images/showMarks.png create mode 100644 images/up.png create mode 100644 images/updateLibrary.png create mode 100644 images/zoom.png diff --git a/COPYING.txt b/COPYING.txt new file mode 100644 index 00000000..94a9ed02 --- /dev/null +++ b/COPYING.txt @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/README.txt b/README.txt new file mode 100644 index 00000000..f2e8f777 --- /dev/null +++ b/README.txt @@ -0,0 +1,4 @@ +This software was developed by Luis Ángel San Martín Rodríguez (luisangelsm@gmail.com) under GPL v3 license (for more details read COPYING.txt). + +Project home page : http://code.google.com/p/yacreader/ + diff --git a/YACReader/YACReader.pro b/YACReader/YACReader.pro new file mode 100644 index 00000000..6c155e26 --- /dev/null +++ b/YACReader/YACReader.pro @@ -0,0 +1,57 @@ +# ##################################################################### +# Automatically generated by qmake (2.01a) mié 8. oct 20:54:05 2008 +# ##################################################################### +TEMPLATE = app +TARGET = +DEPENDPATH += . \ + release +INCLUDEPATH += . +INCLUDEPATH += ../common +QT += network webkit phonon +CONFIG += release +CONFIG -= flat + +# Input +HEADERS += comic.h \ + configuration.h \ + goto_dialog.h \ + magnifying_glass.h \ + main_window_viewer.h \ + viewer.h \ + ../common/pictureflow.h \ + ../common/custom_widgets.h \ + ../common/check_new_version.h \ + ../common/qnaturalsorting.h \ + goto_flow.h \ + options_dialog.h \ + bookmarks.h \ + bookmarks_dialog.h \ + render.h \ + shortcuts_dialog.h \ + translator.h +SOURCES += comic.cpp \ + configuration.cpp \ + goto_dialog.cpp \ + magnifying_glass.cpp \ + main.cpp \ + main_window_viewer.cpp \ + viewer.cpp \ + ../common/pictureflow.cpp \ + ../common/custom_widgets.cpp \ + ../common/check_new_version.cpp \ + ../common/qnaturalsorting.cpp \ + goto_flow.cpp \ + options_dialog.cpp \ + bookmarks.cpp \ + bookmarks_dialog.cpp \ + render.cpp \ + shortcuts_dialog.cpp \ + translator.cpp +RESOURCES += images.qrc \ + files.qrc +RC_FILE = icon.rc +TRANSLATIONS = yacreader_es.ts \ yacreader_fr.ts +FORMS += + +Release:DESTDIR = ../release +Debug:DESTDIR = ../debug \ No newline at end of file diff --git a/YACReader/bookmarks.cpp b/YACReader/bookmarks.cpp new file mode 100644 index 00000000..2e5978ec --- /dev/null +++ b/YACReader/bookmarks.cpp @@ -0,0 +1,159 @@ +#include "bookmarks.h" +#include +#include +#include +#include + +#include + +#define NUM_BOOKMARKS 250 + +Bookmarks::Bookmarks() +:lastPageIndex(0) +{ + list.load(); +} +void Bookmarks::setLastPage(int index,const QPixmap & page) +{ + lastPageIndex = index; + lastPage = page; +} +void Bookmarks::setBookmark(int index,const QPixmap & page) +{ + if(!bookmarks.contains(index)) + { + bookmarks.insert(index,page); + latestBookmarks.push_front(index); + if(latestBookmarks.count()>3) + { + bookmarks.remove(latestBookmarks.back()); + latestBookmarks.pop_back(); + } + } + else //udate de pixmap; + { + bookmarks[index]=page; + } +} + +void Bookmarks::removeBookmark(int index) +{ + bookmarks.remove(index); +} + +QList Bookmarks::getBookmarkPages() const +{ + return bookmarks.keys(); +} + +QPixmap Bookmarks::getBookmarkPixmap(int page) const +{ + return bookmarks.value(page); +} + +QPixmap Bookmarks::getLastPagePixmap() const +{ + return lastPage; +} + +int Bookmarks::getLastPage() const +{ + return lastPageIndex; +} + + +bool Bookmarks::isBookmark(int page) +{ + return bookmarks.contains(page); +} + +bool Bookmarks::imageLoaded(int page) +{ + return !bookmarks.value(page).isNull(); +} + +void Bookmarks::newComic(const QString & path) +{ + QFileInfo f(path); + QString comicID = f.fileName().toLower()+QString::number(f.size()); + clear(); + BookmarksList::Bookmark b = list.get(comicID); + comicPath=comicID; + lastPageIndex = b.lastPage; + latestBookmarks = b.bookmarks; + for(int i=0;i> list; + f.close(); + } +} + +void BookmarksList::save() +{ + QFile f(QCoreApplication::applicationDirPath()+"/bookmarks.yacr"); + f.open(QIODevice::WriteOnly); + QDataStream dataS(&f); + if(list.count()>NUM_BOOKMARKS) + deleteOldest(list.count()-NUM_BOOKMARKS); + dataS << list; + f.close(); +} + + +void BookmarksList::deleteOldest(int num) +{ + QString comic; + QDateTime date(QDate(10000,1,1));//TODO MAX_DATE?? + for(QMap::const_iterator itr=list.begin();itr!=list.end();itr++) + { + if(itr->addedadded; + } + } + list.remove(comic); +} + +void BookmarksList::add(const QString & comicID, const Bookmark & b) +{ + list.insert(comicID,b); +} + +BookmarksList::Bookmark BookmarksList::get(const QString & comicID) +{ + //if(list.contains(comicID) + return list.value(comicID); +} \ No newline at end of file diff --git a/YACReader/bookmarks.h b/YACReader/bookmarks.h new file mode 100644 index 00000000..adb0b835 --- /dev/null +++ b/YACReader/bookmarks.h @@ -0,0 +1,77 @@ +#ifndef BOOKMARKS_H +#define BOOKMARKS_H + +#include +#include +#include +#include +#include +#include +class BookmarksList +{ +public: + struct Bookmark { + int lastPage; + QList bookmarks; + QDateTime added; + Bookmark():lastPage(0){}; + friend QDataStream & operator<< ( QDataStream & out, const Bookmark & bm ) + { + out << bm.lastPage; + out << bm.bookmarks; + out << bm.added; + return out; + } + friend QDataStream & operator>> ( QDataStream & in, Bookmark & bm ) + { + in >> bm.lastPage; + in >> bm.bookmarks; + in >> bm.added; + return in; + } + + }; + BookmarksList(){} + void load(); + void save(); + void add(const QString & comicID, const Bookmark & b); + Bookmark get(const QString & comicID); +protected: + QMap list; + void deleteOldest(int num); + +}; + +class Bookmarks : public QObject +{ + Q_OBJECT + + protected: + QString comicPath; + //bookmarks setted by the user + QMap bookmarks; + QList latestBookmarks; + //last page readed + int lastPageIndex; + QPixmap lastPage; + BookmarksList list; + QDateTime added; + + public: + Bookmarks(); + void setLastPage(int index,const QPixmap & page); + void setBookmark(int index,const QPixmap & page); + void removeBookmark(int index); + QList getBookmarkPages() const; + QPixmap getBookmarkPixmap(int page) const; + QPixmap getLastPagePixmap() const; + int getLastPage() const; + bool isBookmark(int page); + bool imageLoaded(int page); + void newComic(const QString & path); + void clear(); + void save(); + +}; + +#endif // BOOKMARKS_H diff --git a/YACReader/bookmarks_dialog.cpp b/YACReader/bookmarks_dialog.cpp new file mode 100644 index 00000000..40d4007d --- /dev/null +++ b/YACReader/bookmarks_dialog.cpp @@ -0,0 +1,182 @@ +#include "bookmarks_dialog.h" + +#include +#include +#include +#include +#include +#include + +#include "bookmarks.h" + +BookmarksDialog::BookmarksDialog(QWidget * parent) + :QDialog(parent,Qt::FramelessWindowHint) +{ + setModal(true); + + animation = new QPropertyAnimation(this,"windowOpacity"); + animation->setDuration(150); + + QHBoxLayout * layout = new QHBoxLayout(); + + //bookmarks + QGridLayout * bookmarksL = new QGridLayout(); + + pages.push_back(new QLabel(tr("Lastest Page"))); + for(int i=0;i<3;i++) + pages.push_back(new QLabel("-")); + + int heightDesktopResolution = QApplication::desktop()->screenGeometry().height(); + int height,width; + height = heightDesktopResolution*0.50; + width = height*0.65; + + coverSize = QSize(width,height); + + for(int i=0;i<4;i++) + { + QLabel * l = new QLabel(); + l->setFixedSize(coverSize); + l->setScaledContents(false); + //l->setPixmap(QPixmap(":/images/notCover.png")); + l->installEventFilter(this); + images.push_back(l); + } + + for(int i=0;i<3;i++) + bookmarksL->addWidget(pages.at(i+1),0,i,Qt::AlignCenter); + + for(int i=0;i<3;i++) + bookmarksL->addWidget(images.at(i+1),1,i,Qt::AlignCenter); + + + //last page + QGridLayout * lp = new QGridLayout(); + lp->addWidget(pages.at(0),0,0,Qt::AlignCenter); + lp->addWidget(images.at(0),1,0,Qt::AlignCenter); + + layout->addLayout(bookmarksL); + QFrame *f = new QFrame( this ); + f->setFrameStyle( QFrame::VLine | QFrame::Sunken ); + layout->addWidget(f); + layout->addLayout(lp); + + QHBoxLayout * buttons = new QHBoxLayout(); + + cancel = new QPushButton(tr("Close")); + cancel->setFlat(true); + connect(cancel,SIGNAL(clicked()),this,SLOT(hide())); + buttons->addStretch(); + buttons->addWidget(cancel); + + QVBoxLayout * l = new QVBoxLayout(); + + l->addWidget(new QLabel(tr("Click on any image to go to the bookmark")),0,Qt::AlignCenter); + l->addLayout(layout); + l->addLayout(buttons); + + this->setPalette(QPalette(QColor(25,25,25))); + //this->setAutoFillBackground(true); + setLayout(l); +} + +void BookmarksDialog::setBookmarks(const Bookmarks & bm) +{ + lastPage = bm.getLastPage(); + if (lastPage > 0) + { + QPixmap p = bm.getLastPagePixmap(); + if(p.isNull()) + { + images.at(0)->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter); + images.at(0)->setText(tr("Loading...")); + } + else + { + images.at(0)->setAlignment(Qt::AlignHCenter|Qt::AlignBottom); + images.at(0)->setPixmap(p.scaled(coverSize,Qt::KeepAspectRatio,Qt::SmoothTransformation)); + } + } + else + { + images.at(0)->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter); + images.at(0)->setPixmap(QPixmap(":/images/notCover.png").scaled(coverSize,Qt::KeepAspectRatio,Qt::SmoothTransformation)); + + } + + QList l = bm.getBookmarkPages(); + int s = l.count(); + for(int i=0;isetText(QString::number(l.at(i)+1)); + QPixmap p = bm.getBookmarkPixmap(l.at(i)); + if(p.isNull()) + { + images.at(i+1)->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter); + images.at(i+1)->setText(tr("Loading...")); + } + else + { + images.at(i+1)->setAlignment(Qt::AlignHCenter|Qt::AlignBottom); + images.at(i+1)->setPixmap(p.scaled(coverSize,Qt::KeepAspectRatio,Qt::SmoothTransformation)); + } + } + for(int i=s;i<3;i++) + { + pages.at(i+1)->setText("-"); + images.at(i+1)->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter); + images.at(i+1)->setPixmap(QPixmap(":/images/notCover.png").scaled(coverSize,Qt::KeepAspectRatio,Qt::SmoothTransformation)); + } +} + +bool BookmarksDialog::eventFilter(QObject *obj, QEvent *event) +{ + if(event->type() == QEvent::MouseButtonPress) + { + if (obj == images.at(0)) + { + emit(goToPage(lastPage+1)); + close(); + event->accept(); + } + for(int i=1;i<=3;i++) + { + if(obj == images.at(i)) + { + bool b; + int page = pages.at(i)->text().toInt(&b); + if(b) + { + emit(goToPage(page)); + close(); + } + event->accept(); + } + } + } + // pass the event on to the parent class + return QDialog::eventFilter(obj, event); +} + +void BookmarksDialog::keyPressEvent(QKeyEvent * event) +{ + if(event->key() == Qt::Key_M) + hide(); +} + +void BookmarksDialog::show() +{ + QDialog::show(); + disconnect(animation,SIGNAL(finished()),this,SLOT(close())); + animation->setStartValue(0); + animation->setEndValue(1); + animation->start(); +} + +void BookmarksDialog::hide() +{ + connect(animation,SIGNAL(finished()),this,SLOT(close())); + animation->setStartValue(1); + animation->setEndValue(0); + animation->start(); +} diff --git a/YACReader/bookmarks_dialog.h b/YACReader/bookmarks_dialog.h new file mode 100644 index 00000000..363ed372 --- /dev/null +++ b/YACReader/bookmarks_dialog.h @@ -0,0 +1,45 @@ +#ifndef __BOOKMARKS_DIALOG_H +#define __BOOKMARKS_DIALOG_H + +#include +#include +#include +#include +#include +#include +#include + +#include "bookmarks.h" + + class BookmarksDialog : public QDialog + { + Q_OBJECT + + protected: + QList pages; + QList images; + + int lastPage; + + QPushButton * accept; + QPushButton * cancel; + + QSize coverSize; + + bool eventFilter(QObject *obj, QEvent *event); + void keyPressEvent(QKeyEvent * event); + QPropertyAnimation * animation; + + public: + BookmarksDialog(QWidget * parent = 0); + + public slots: + void setBookmarks(const Bookmarks & bookmarks); + void show(); + void hide(); + + signals: + void goToPage(unsigned int page); + }; + +#endif // BOOKMARKS_DIALOG_H diff --git a/YACReader/comic.cpp b/YACReader/comic.cpp new file mode 100644 index 00000000..4be17ce1 --- /dev/null +++ b/YACReader/comic.cpp @@ -0,0 +1,289 @@ +#include "comic.h" + +#include +#include +#include +#include +#include +#include +#include "bookmarks.h" +#include "qnaturalsorting.h" + +#define EXTENSIONS << "*.jpg" << "*.jpeg" << "*.png" << "*.gif" << "*.tiff" << "*.tif" << "*.bmp" + +//----------------------------------------------------------------------------- +Comic::Comic() +:_pages(),_index(0),_path(),_loaded(false),bm(new Bookmarks()) +{ + setup(); +} +//----------------------------------------------------------------------------- +Comic::Comic(const QString pathFile) +:_pages(),_index(0),_path(pathFile),_loaded(false),bm(new Bookmarks()) +{ + setup(); + loadFromFile(pathFile); +} +//----------------------------------------------------------------------------- +void Comic::setup() +{ + connect(this,SIGNAL(pageChanged(int)),this,SLOT(checkIsBookmark(int))); + connect(this,SIGNAL(imageLoaded(int)),this,SLOT(updateBookmarkImage(int))); +} +//----------------------------------------------------------------------------- +void Comic::load(const QString & path) +{ + QFileInfo fi(path); + bm->newComic(path); + emit bookmarksLoaded(*bm); + if(fi.isFile()) + { + loadFromFile(path); + } + else + { + if(fi.isDir()) + { + loadFromDir(path); + } + } +} +//----------------------------------------------------------------------------- +void Comic::loadFromFile(const QString & pathFile) +{ + _path = QDir::cleanPath(pathFile); + //load files size + _7z = new QProcess(); + QStringList attributes; + attributes << "l" << "-ssc-" << "-r" << _path EXTENSIONS; + connect(_7z,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(loadSizes(void))); + connect(_7z,SIGNAL(error(QProcess::ProcessError)),this,SLOT(openingError(QProcess::ProcessError))); + _7z->start(QCoreApplication::applicationDirPath()+"/utils/7z",attributes); +} +//----------------------------------------------------------------------------- +void Comic::loadFromDir(const QString & pathDir) +{ + _pathDir = pathDir; + start(); +} +//----------------------------------------------------------------------------- +void Comic::run() +{ + QDir d(_pathDir); + QStringList l; + l EXTENSIONS; + d.setNameFilters(l); + d.setFilter(QDir::Files|QDir::NoDotAndDotDot); + //d.setSorting(QDir::Name|QDir::IgnoreCase|QDir::LocaleAware); + QFileInfoList list = d.entryInfoList(); + + qSort(list.begin(),list.end(),naturalSortLessThanCIFileInfo); + + int nPages = list.size(); + _pages.clear(); + _pages.resize(nPages); + if(nPages==0) + { + QMessageBox::critical(NULL,tr("No images found"),tr("There are not images on the selected folder")); + emit errorOpening(); + } + else + { + emit pageChanged(0); // this indicates new comic, index=0 + emit numPages(_pages.size()); + _loaded = true; + + for(int i=0;ireadAllStandardOutput(); + QList lines = ba.split('\n'); + QByteArray line; + QString name; + foreach(line,lines) + { + if(rx.indexIn(QString(line))!=-1) + { + _sizes.push_back(rx.cap(1).toInt()); + name = rx.cap(3).trimmed(); + _order.push_back(name); + _fileNames.push_back(name); + } + } + if(_sizes.size()==0) + { + QMessageBox::critical(NULL,tr("File error"),tr("File not found or not images in file")); + emit errorOpening(); + return; + } + _pages.resize(_sizes.size()); + + emit pageChanged(0); // this indicates new comic, index=0 + emit numPages(_pages.size()); + _loaded = true; + + _cfi=0; + qSort(_fileNames.begin(),_fileNames.end(), naturalSortLessThanCI); + int i=0; + foreach(name,_fileNames) + { + _newOrder.insert(name,i); + i++; + } + _7ze = new QProcess(); + QStringList attributes; + attributes << "e" << "-ssc-" << "-so" << "-r" << _path EXTENSIONS; + connect(_7ze,SIGNAL(error(QProcess::ProcessError)),this,SLOT(openingError(QProcess::ProcessError))); + connect(_7ze,SIGNAL(readyReadStandardOutput()),this,SLOT(loadImages(void))); + connect(_7ze,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(loadFinished(void))); + _7ze->start(QCoreApplication::applicationDirPath()+"/utils/7z",attributes); +} +//----------------------------------------------------------------------------- +void Comic::loadImages() +{ + + QByteArray ba = _7ze->readAllStandardOutput(); + int s; + int rigthIndex; + while(ba.size()>0) + { + rigthIndex = _newOrder.value(_order[_cfi]); + s = _pages[rigthIndex].size(); + _pages[rigthIndex].append(ba.left(_sizes[_cfi]-s)); + ba.remove(0,_sizes[_cfi]-s); + if(_pages[rigthIndex].size()==static_cast(_sizes[_cfi])) + { + emit imageLoaded(rigthIndex); + emit imageLoaded(rigthIndex,_pages[rigthIndex]); + _cfi++; + } + } +} +//----------------------------------------------------------------------------- +void Comic::openingError(QProcess::ProcessError error) +{ + switch(error) + { + case QProcess::FailedToStart: + QMessageBox::critical(NULL,tr("7z not found"),tr("7z wasn't found in your PATH.")); + break; + case QProcess::Crashed: + QMessageBox::critical(NULL,tr("7z crashed"),tr("7z crashed.")); + break; + case QProcess::ReadError: + QMessageBox::critical(NULL,tr("7z reading"),tr("problem reading from 7z")); + break; + case QProcess::UnknownError: + QMessageBox::critical(NULL,tr("7z problem"),tr("Unknown error 7z")); + break; + default: + //TODO + break; + } + _loaded = false; + emit errorOpening(); +} +int Comic::nextPage() +{ + if(_index<_pages.size()-1) + _index++; + + emit pageChanged(_index); + + return _index; +} +//----------------------------------------------------------------------------- +int Comic::previousPage() +{ + if(_index>0) + _index--; + + emit pageChanged(_index); + + return _index; +} +//----------------------------------------------------------------------------- +void Comic::setIndex(unsigned int index) +{ + if(static_cast(index)<_pages.size()-1) + _index = index; + else + _index = _pages.size()-1; + + emit pageChanged(_index); +} +//----------------------------------------------------------------------------- +QPixmap * Comic::currentPage() +{ + QPixmap * p = new QPixmap(); + p->loadFromData(_pages[_index]); + return p; +} +//----------------------------------------------------------------------------- +QPixmap * Comic::operator[](unsigned int index) +{ + QPixmap * p = new QPixmap(); + p->loadFromData(_pages[index]); + return p; +} +//----------------------------------------------------------------------------- +bool Comic::loaded() +{ + return _loaded; +} +//----------------------------------------------------------------------------- +void Comic::loadFinished() +{ + emit imagesLoaded(); +} +//----------------------------------------------------------------------------- +void Comic::setBookmark() +{ + bm->setBookmark(_index,*operator[](_index)); + emit bookmarksLoaded(*bm); +} +//----------------------------------------------------------------------------- +void Comic::removeBookmark() +{ + bm->removeBookmark(_index); + emit bookmarksLoaded(*bm); +} +//----------------------------------------------------------------------------- +void Comic::saveBookmarks() +{ + bm->setLastPage(_index,*operator[](_index)); + bm->save(); +} +//----------------------------------------------------------------------------- +void Comic::checkIsBookmark(int index) +{ + emit isBookmark(bm->isBookmark(index)); +} +//----------------------------------------------------------------------------- +void Comic::updateBookmarkImage(int index) +{ + if(bm->isBookmark(index)) + { + bm->setBookmark(index,*operator[](index)); + emit bookmarksLoaded(*bm); + } + if(bm->getLastPage() == index) + { + bm->setLastPage(index,*operator[](index)); + emit bookmarksLoaded(*bm); + } + +} diff --git a/YACReader/comic.h b/YACReader/comic.h new file mode 100644 index 00000000..2e5a2d49 --- /dev/null +++ b/YACReader/comic.h @@ -0,0 +1,70 @@ +#ifndef __COMIC_H +#define __COMIC_H +#include +#include +#include +#include +#include + +#include "bookmarks.h" + + class Comic : public QThread + { + Q_OBJECT + private: + //Comic pages, one QPixmap for each file. + QVector _pages; + QVector _sizes; + QStringList _fileNames; + QMap _newOrder; + QVector _order; + int _index; + QString _path; + bool _loaded; + QProcess * _7z; + QProcess * _7ze; + int _cfi; + QString _pathDir; + Bookmarks * bm; + void run(); + public: + //Constructors + Comic(); + Comic(const QString pathFile); + void setup(); + //Load pages from file + void load(const QString & path); + void loadFromFile(const QString & pathFile); + void loadFromDir(const QString & pathDir); + int nextPage(); + int previousPage(); + void setIndex(unsigned int index); + unsigned int getIndex(){return _index;}; + unsigned int numPages(){return _pages.size();} + QPixmap * currentPage(); + bool loaded(); + QPixmap * operator[](unsigned int index); + QVector * getRawData(){return &_pages;}; + public slots: + void loadImages(); + void loadSizes(); + void openingError(QProcess::ProcessError error); + void loadFinished(); + void setBookmark(); + void removeBookmark(); + void saveBookmarks(); + void checkIsBookmark(int index); + void updateBookmarkImage(int); + signals: + void imagesLoaded(); + void imageLoaded(int index); + void imageLoaded(int index,const QByteArray & image); + void pageChanged(int index); + void numPages(unsigned int numPages); + void errorOpening(); + void isBookmark(bool); + void bookmarksLoaded(const Bookmarks &); + + }; + +#endif diff --git a/YACReader/configuration.cpp b/YACReader/configuration.cpp new file mode 100644 index 00000000..1235f06b --- /dev/null +++ b/YACReader/configuration.cpp @@ -0,0 +1,199 @@ +#include "configuration.h" + +#include +#include +#include +#include +#include +#include + + + +#define PATH "PATH" +#define MAG_GLASS_SIZE "MAG_GLASS_SIZE" +#define ZOOM_LEVEL "ZOOM_LEVEL" +#define SLIDE_SIZE "SLIDE_SIZE" +#define FIT "FIT" +#define FLOW_TYPE "FLOW_TYPE" +#define FULLSCREEN "FULLSCREEN" +#define FIT_TO_WIDTH_RATIO "FIT_TO_WIDTH_RATIO" +#define POS "POS" +#define SIZE "SIZE" +#define MAXIMIZED "MAXIMIZED" +#define DOUBLE_PAGE "DOUBLE_PAGE" +#define ADJUST_TO_FULL_SIZE "ADJUST_TO_FULL_SIZE" +#define BACKGROUND_COLOR "BACKGROUND_COLOR" +#define ALWAYS_ON_TOP "ALWAYS_ON_TOP" + +Configuration::Configuration() +{ + //read configuration + load("/YACReader.conf"); +} + +Configuration::Configuration(const Configuration & conf) +{ + //nothing +} + +void Configuration::load(const QString & path) +{ + //load default configuration + defaultPath = "."; + magnifyingGlassSize = QSize(350,175); + gotoSlideSize = QSize(126,200); //normal + //gotoSlideSize = QSize(79,125); //small + //gotoSlideSize = QSize(173,275); //big + //gotoSlideSize = QSize(220,350); //huge + zoomLevel = 0.5; + adjustToWidth = true; + flowType = PictureFlow::Strip; + fullScreen = false; + fitToWidthRatio = 1; + windowSize = QSize(0,0); + maximized = false; + doublePage = false; + adjustToFullSize = false; + backgroundColor = QColor(0,0,0); + alwaysOnTop = false; + + //load from file + QFile f(QCoreApplication::applicationDirPath()+path); + f.open(QIODevice::ReadOnly); + QTextStream txtS(&f); + QString content = txtS.readAll(); + QStringList lines = content.split('\n'); + QString line,name; + int i=0; + foreach(line,lines) + { + if((i%2)==0) + { + name = line.trimmed(); + } + else + { + if(name==PATH) + defaultPath = line.trimmed(); + else + if(name==MAG_GLASS_SIZE) + { + QStringList values = line.split(','); + magnifyingGlassSize = QSize(values[0].toInt(),values[1].toInt()); + } + else + if(name==ZOOM_LEVEL) + zoomLevel = line.toFloat(); + else + if(name==SLIDE_SIZE) + { + int height = line.toInt(); + gotoSlideSize = QSize(static_cast(height/SLIDE_ASPECT_RATIO),height); + } + else + if(name==FIT) + adjustToWidth = line.toInt(); + else + if(name==FLOW_TYPE) + flowType = (PictureFlow::FlowType)line.toInt(); + else + if(name==FULLSCREEN) + fullScreen = line.toInt(); + else + if(name==FIT_TO_WIDTH_RATIO) + fitToWidthRatio = line.toFloat(); + else + if(name==POS) + { + QStringList l = line.split(','); + windowPos = QPoint(l[0].toInt(),l[1].toInt()); + } + else + if(name==SIZE) + { + QStringList l = line.split(','); + windowSize = QSize(l[0].toInt(),l[1].toInt()); + } + else + if(name==MAXIMIZED) + maximized = line.toInt(); + else + if(name==DOUBLE_PAGE) + doublePage = line.toInt(); + else + if(name==ADJUST_TO_FULL_SIZE) + adjustToFullSize = line.toInt(); + else + if(name==BACKGROUND_COLOR) + { + QStringList l = line.split(','); + backgroundColor = QColor(l[0].toInt(),l[1].toInt(),l[2].toInt()); + } + else + if(name==ALWAYS_ON_TOP) + alwaysOnTop = line.toInt(); + + + + } + i++; + } +} + +void Configuration::save() +{ + QFile f(QCoreApplication::applicationDirPath()+"/YACReader.conf"); + if(!f.open(QIODevice::WriteOnly)) + { + QMessageBox::critical(NULL,tr("Saving config file...."),tr("There was a problem saving YACReader configuration. Please, check if you have enough permissions in the YACReader root folder.")); + } + else + { + QTextStream txtS(&f); + + txtS << PATH << "\n"; + txtS << defaultPath << "\n"; + + txtS << MAG_GLASS_SIZE << "\n"; + txtS << magnifyingGlassSize.width() <<","<< magnifyingGlassSize.height() << "\n"; + + txtS << ZOOM_LEVEL << "\n"; + txtS << zoomLevel << "\n"; + + txtS << SLIDE_SIZE << "\n"; + txtS << gotoSlideSize.height() << "\n"; + + txtS << FIT << "\n"; + txtS << (int)adjustToWidth << "\n"; + + txtS << FLOW_TYPE << "\n"; + txtS << (int)flowType << "\n"; + + txtS << FULLSCREEN << "\n"; + txtS << (int)fullScreen << "\n"; + + txtS << FIT_TO_WIDTH_RATIO << "\n"; + txtS << fitToWidthRatio << "\n"; + + txtS << POS << "\n"; + txtS << windowPos.x() << "," << windowPos.y() << "\n"; + + txtS << SIZE << "\n"; + txtS << windowSize.width() << "," << windowSize.height() << "\n"; + + txtS << MAXIMIZED << "\n"; + txtS << (int)maximized << "\n"; + + txtS << DOUBLE_PAGE << "\n"; + txtS << (int)doublePage << "\n"; + + txtS << ADJUST_TO_FULL_SIZE << "\n"; + txtS << (int) adjustToFullSize << "\n"; + + txtS << BACKGROUND_COLOR << "\n"; + txtS << backgroundColor.red() << "," << backgroundColor.green() << "," << backgroundColor.blue() << "\n"; + + txtS << ALWAYS_ON_TOP << "\n"; + txtS << (int)alwaysOnTop << "\n"; + } +} diff --git a/YACReader/configuration.h b/YACReader/configuration.h new file mode 100644 index 00000000..f2644d51 --- /dev/null +++ b/YACReader/configuration.h @@ -0,0 +1,77 @@ +#ifndef __CONFIGURATION_H +#define __CONFIGURATION_H +#include +#include +#include +#include "pictureflow.h" + +#define CONF_FILE_PATH "." +#define SLIDE_ASPECT_RATIO 1.585 + + class Configuration : public QObject + { + Q_OBJECT + + private: + QString defaultPath; + //configuration properties + QSize magnifyingGlassSize; + QSize gotoSlideSize; + float zoomLevel; + bool adjustToWidth; + bool fullScreen; + PictureFlow::FlowType flowType; + float fitToWidthRatio; + QPoint windowPos; + QSize windowSize; + bool maximized; + bool doublePage; + bool alwaysOnTop; + bool adjustToFullSize; + QColor backgroundColor; + + Configuration(); + Configuration(const Configuration & conf); + void load(const QString & path = CONF_FILE_PATH); + + public: + static Configuration & getConfiguration() + { + static Configuration configuration; + return configuration; + }; + QString getDefaultPath() { return defaultPath; }; + void setDefaultPath(QString defaultPath){this->defaultPath = defaultPath;}; + QSize getMagnifyingGlassSize() { return magnifyingGlassSize;}; + void setMagnifyingGlassSize(const QSize & mgs) { magnifyingGlassSize = mgs;}; + QSize getGotoSlideSize() { return gotoSlideSize;}; + void setGotoSlideSize(const QSize & gss) { gotoSlideSize = gss;}; + float getZoomLevel() { return zoomLevel;}; + void setZoomLevel(float zl) { zoomLevel = zl;}; + bool getAdjustToWidth() {return adjustToWidth;}; + void setAdjustToWidth(bool atw=true) {adjustToWidth = atw;}; + PictureFlow::FlowType getFlowType(){return flowType;}; + void setFlowType(PictureFlow::FlowType type){flowType = type;}; + bool getFullScreen(){return fullScreen;}; + void setFullScreen(bool f){fullScreen = f;}; + float getFitToWidthRatio(){return fitToWidthRatio;}; + void setFitToWidthRatio(float r){fitToWidthRatio = r;}; + QPoint getPos(){return windowPos;}; + void setPos(QPoint p){windowPos = p;}; + QSize getSize(){return windowSize;}; + void setSize(QSize s){windowSize = s;}; + bool getMaximized(){return maximized;}; + void setMaximized(bool b){maximized = b;}; + bool getDoublePage(){return doublePage;}; + void setDoublePage(bool b){doublePage = b;}; + void setAdjustToFullSize(bool b){adjustToFullSize = b;}; + bool getAdjustToFullSize(){return adjustToFullSize;}; + void setBackgroundColor(const QColor& color){backgroundColor = color;}; + QColor getBackgroundColor(){return backgroundColor;}; + void setAlwaysOnTop(bool b){alwaysOnTop = b;}; + bool getAlwaysOnTop(){return alwaysOnTop;}; + void save(); + + }; + +#endif diff --git a/YACReader/files.qrc b/YACReader/files.qrc new file mode 100644 index 00000000..9dcfa4f3 --- /dev/null +++ b/YACReader/files.qrc @@ -0,0 +1,15 @@ + + + ../files/about.html + ../files/helpYACReader.html + ../files/shortcuts.html + ../files/shortcuts2.html + ../files/translator.html + ./yacreader_es.qm + + + + ../files/about_es_ES.html + ../files/helpYACReader_es_ES.html + + diff --git a/YACReader/goto_dialog.cpp b/YACReader/goto_dialog.cpp new file mode 100644 index 00000000..8b8dd66d --- /dev/null +++ b/YACReader/goto_dialog.cpp @@ -0,0 +1,75 @@ +#include "goto_dialog.h" + +#include +#include +#include + + + +GoToDialog::GoToDialog(QWidget * parent) +:QDialog(parent) +{ + setupUI(); +} + +void GoToDialog::setupUI() +{ + textLabel = new QLabel(tr("Page : ")); + pageNumber = new QLineEdit; + v = new QIntValidator(this); + v->setBottom(1); + pageNumber->setValidator(v); + textLabel->setBuddy(pageNumber); + textLabel->setAlignment(Qt::AlignRight|Qt::AlignVCenter); + + accept = new QPushButton(tr("Go To")); + connect(accept,SIGNAL(clicked()),this,SLOT(goTo())); + cancel = new QPushButton(tr("Cancel")); + connect(cancel,SIGNAL(clicked()),this,SLOT(close())); + + QHBoxLayout *topLayout = new QHBoxLayout; + + topLayout->addWidget(textLabel); + topLayout->addWidget(pageNumber); + + QHBoxLayout *bottomLayout = new QHBoxLayout; + bottomLayout->addStretch(); + bottomLayout->addWidget(accept); + bottomLayout->addWidget(cancel); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(numPagesLabel = new QLabel(tr("Total pages : "))); + mainLayout->addLayout(topLayout); + mainLayout->addStretch(); + mainLayout->addLayout(bottomLayout); + + QHBoxLayout *imgMainLayout = new QHBoxLayout; + QLabel * imgLabel = new QLabel(); + QPixmap p(":/images/goto.png"); + imgLabel->setPixmap(p); + imgMainLayout->addWidget(imgLabel); + imgMainLayout->addLayout(mainLayout); + + setLayout(imgMainLayout); + + setWindowTitle(tr("Go to...")); + setModal (true); +} + +void GoToDialog::goTo() +{ + unsigned int page = pageNumber->text().toInt(); + pageNumber->clear(); + + if(page >= 1) + emit(goToPage(page)); + + close(); + +} + +void GoToDialog::setNumPages(unsigned int numPages) +{ + numPagesLabel->setText(tr("Total pages : ")+QString::number(numPages)); + v->setTop(numPages); +} diff --git a/YACReader/goto_dialog.h b/YACReader/goto_dialog.h new file mode 100644 index 00000000..9d13e647 --- /dev/null +++ b/YACReader/goto_dialog.h @@ -0,0 +1,31 @@ +#ifndef __GOTODIALOG_H +#define __GOTODIALOG_H + +#include +#include +#include +#include +#include + + class GoToDialog : public QDialog + { + Q_OBJECT + public: + GoToDialog(QWidget * parent = 0); + private: + QLabel * numPagesLabel; + QLabel * textLabel; + QLineEdit * pageNumber; + QIntValidator * v; + QPushButton * accept; + QPushButton * cancel; + void setupUI(); + public slots: + void goTo(); + void setNumPages(unsigned int numPages); + signals: + void goToPage(unsigned int page); + }; + +#endif + diff --git a/YACReader/goto_flow.cpp b/YACReader/goto_flow.cpp new file mode 100644 index 00000000..edb8fd17 --- /dev/null +++ b/YACReader/goto_flow.cpp @@ -0,0 +1,373 @@ +#include "goto_flow.h" +#include "configuration.h" +#include "comic.h" +#include "custom_widgets.h" + +#include +#include +#include +#include +#include +#include +#include + +/*#define WIDTH 126 +#define HEIGHT 200*/ + +QMutex mutexGoToFlow; + + + +GoToFlow::GoToFlow(QWidget *parent,PictureFlow::FlowType flowType) +:QWidget(parent),ready(false) +{ + updateTimer = new QTimer; + connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateImageData())); + + worker = new PageLoader; + + QVBoxLayout * layout = new QVBoxLayout(this); + flow = new YACReaderFlow(this,flowType); + flow->setReflectionEffect(PictureFlow::PlainReflection); + imageSize = Configuration::getConfiguration().getGotoSlideSize(); + + flow->setSlideSize(imageSize); + connect(flow,SIGNAL(centerIndexChanged(int)),this,SLOT(setPageNumber(int))); + connect(flow,SIGNAL(selected(unsigned int)),this,SLOT(goTo())); + + QHBoxLayout * bottom = new QHBoxLayout(this); + bottom->addStretch(); + bottom->addWidget(new QLabel(tr("Page : "),this)); + bottom->addWidget(edit = new QLineEdit(this)); + v = new QIntValidator(this); + v->setBottom(1); + edit->setValidator(v); + edit->setAlignment(Qt::AlignRight|Qt::AlignVCenter); + edit->setFixedWidth(40); + edit->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Minimum)); + + centerButton = new QPushButton(this); + centerButton->setIcon(QIcon(":/images/center.png")); + connect(centerButton,SIGNAL(clicked()),this,SLOT(centerSlide())); + bottom->addWidget(centerButton); + + goToButton = new QPushButton(this); + goToButton->setIcon(QIcon(":/images/goto.png")); + connect(goToButton,SIGNAL(clicked()),this,SLOT(goTo())); + bottom->addWidget(goToButton); + + bottom->addStretch(); + + layout->addWidget(flow); + layout->addLayout(bottom); + layout->setStretchFactor(flow,1); + layout->setStretchFactor(bottom,0); + layout->setMargin(0); + layout->setSpacing(0); + setLayout(layout); + this->setAutoFillBackground(true); + resize(static_cast(5*imageSize.width()),static_cast(imageSize.height()*1.7)); + + //install eventFilter + //flow->installEventFilter(this); + edit->installEventFilter(this); + centerButton->installEventFilter(this); + goToButton->installEventFilter(this); + + connect(edit,SIGNAL(returnPressed()),goToButton,SIGNAL(clicked())); + + this->setCursor(QCursor(Qt::ArrowCursor)); +} + +void GoToFlow::goTo() +{ + //emit(goToPage(flow->centerIndex()+1)); + emit(goToPage(edit->text().toInt())); +} + +void GoToFlow::setPageNumber(int page) +{ + edit->setText(QString::number(page+1)); +} + +void GoToFlow::centerSlide() +{ + int page = edit->text().toInt()-1; + int distance = flow->centerIndex()-page; + + if(abs(distance)>10) + { + if(distance<0) + flow->setCenterIndex(flow->centerIndex()+(-distance)-10); + else + flow->setCenterIndex(flow->centerIndex()-distance+10); + } + + flow->showSlide(page); +} + +void GoToFlow::centerSlide(int slide) +{ + if(flow->centerIndex()!=slide) + { + flow->setCenterIndex(slide); + if(ready)// load images if pages are loaded. + { + //worker->reset(); //BUG FIXED : image didn't load if worker was working + preload(); + } + } +} + +void GoToFlow::setNumSlides(unsigned int slides) +{ + // numPagesLabel->setText(tr("Total pages : ")+QString::number(slides)); + // numPagesLabel->adjustSize(); + imagesReady.clear(); + imagesReady.fill(false,slides); + + rawImages.clear(); + rawImages.resize(slides); + + v->setTop(slides); + + SlideInitializer * si = new SlideInitializer(flow,slides); + + imagesLoaded.clear(); + imagesLoaded.fill(false,slides); + + imagesSetted.clear(); + imagesSetted.fill(false,slides); + + numImagesLoaded = 0; + + connect(flow, SIGNAL(centerIndexChanged(int)), this, SLOT(preload())); + + ready = true; + worker->reset(); + + si->start(); +} + +void GoToFlow::reset() +{ + updateTimer->stop(); + /*imagesLoaded.clear(); + numImagesLoaded = 0; + imagesReady.clear(); + rawImages.clear();*/ + ready = false; +} + +void GoToFlow::setImageReady(int index,const QByteArray & image) +{ + rawImages[index]=image; + imagesReady[index]=true; + preload(); +} + +void GoToFlow::preload() +{ + if(numImagesLoaded < imagesLoaded.size()) + updateTimer->start(30); //TODO comprobar rendimiento, antes era 70 +} + +void GoToFlow::updateImageData() +{ + // can't do anything, wait for the next possibility + if(worker->busy()) + return; + + // set image of last one + int idx = worker->index(); + if( idx >= 0 && !worker->result().isNull()) + { + if(!imagesSetted[idx]) + { + flow->setSlide(idx, worker->result()); + imagesSetted[idx] = true; + numImagesLoaded++; + rawImages[idx].clear();; //release memory + } + + } + + // try to load only few images on the left and right side + // i.e. all visible ones plus some extra +#define COUNT 8 + int indexes[2*COUNT+1]; + int center = flow->centerIndex(); + indexes[0] = center; + for(int j = 0; j < COUNT; j++) + { + indexes[j*2+1] = center+j+1; + indexes[j*2+2] = center-j-1; + } + for(int c = 0; c < 2*COUNT+1; c++) + { + int i = indexes[c]; + if((i >= 0) && (i < flow->slideCount())) + if(!imagesLoaded[i]&&imagesReady[i])//slide(i).isNull()) + { + // schedule thumbnail generation + imagesLoaded[i]=true; + worker->generate(i, flow->slideSize(),rawImages[i]); + return; + } + + } + + // no need to generate anything? stop polling... + updateTimer->stop(); +} + +bool GoToFlow::eventFilter(QObject *target, QEvent *event) +{ + if (event->type() == QEvent::KeyPress) + { + QKeyEvent *keyEvent = static_cast(event); + int key = keyEvent->key(); + if((key==Qt::Key_Return)|| + (key==Qt::Key_Enter)|| + (key==Qt::Key_Space)|| + (key==Qt::Key_Left)|| + (key==Qt::Key_Right)|| + (key==Qt::Key_S)) + this->keyPressEvent(keyEvent); + } + return QWidget::eventFilter(target, event); +} + + +void GoToFlow::keyPressEvent(QKeyEvent* event) +{ + switch (event->key()) + { + case Qt::Key_Return: case Qt::Key_Enter: + goTo(); + centerSlide(); + break; + case Qt::Key_Space: + centerSlide(); + break; + case Qt::Key_S: + QCoreApplication::sendEvent(this->parent(),event); + break; + case Qt::Key_Left: case Qt::Key_Right: + QCoreApplication::sendEvent(flow,event); + } + + event->accept(); +} + +void GoToFlow::wheelEvent(QWheelEvent * event) +{ + if(event->delta()<0) + flow->showNext(); + else + flow->showPrevious(); + event->accept(); +} + +void GoToFlow::setFlowType(PictureFlow::FlowType flowType) +{ + flow->setFlowType(flowType); +} + +void GoToFlow::updateSize() //TODO : fix. it doesn't work. +{ + imageSize = Configuration::getConfiguration().getGotoSlideSize(); + flow->setSlideSize(imageSize); + resize(static_cast(5*imageSize.width()),static_cast(imageSize.height()*1.7)); +} +//----------------------------------------------------------------------------- +//SlideInitializer +//----------------------------------------------------------------------------- +SlideInitializer::SlideInitializer(PictureFlow * flow,int slides) +:QThread(),_flow(flow),_slides(slides) +{ + +} +void SlideInitializer::run() +{ + mutexGoToFlow.lock(); + + _flow->clear(); + for(int i=0;i<_slides;i++) + _flow->addSlide(QImage()); + _flow->setCenterIndex(0); + + mutexGoToFlow.unlock(); +} +//----------------------------------------------------------------------------- +//PageLoader +//----------------------------------------------------------------------------- + + +PageLoader::PageLoader(): +QThread(), restart(false), working(false), idx(-1) +{ +} + +PageLoader::~PageLoader() +{ + mutexGoToFlow.lock(); + condition.wakeOne(); + mutexGoToFlow.unlock(); + wait(); +} + +bool PageLoader::busy() const +{ + return isRunning() ? working : false; +} + +void PageLoader::generate(int index, QSize size,const QByteArray & rImage) +{ + mutexGoToFlow.lock(); + this->idx = index; + //this->img = QImage(); + this->size = size; + this->rawImage = rImage; + mutexGoToFlow.unlock(); + + if (!isRunning()) + start(); + else + { + // already running, wake up whenever ready + restart = true; + condition.wakeOne(); + } +} + +void PageLoader::run() +{ + for(;;) + { + // copy necessary data + mutexGoToFlow.lock(); + this->working = true; + //int idx = this->idx; + + + QImage image; + image.loadFromData(this->rawImage); + // let everyone knows it is ready + image = image.scaled(this->size,Qt::KeepAspectRatio,Qt::SmoothTransformation); + + mutexGoToFlow.unlock(); + + mutexGoToFlow.lock(); + this->working = false; + this->img = image; + mutexGoToFlow.unlock(); + + // put to sleep + mutexGoToFlow.lock(); + if (!this->restart) + condition.wait(&mutexGoToFlow); + restart = false; + mutexGoToFlow.unlock(); + } +} diff --git a/YACReader/goto_flow.h b/YACReader/goto_flow.h new file mode 100644 index 00000000..c521f2f4 --- /dev/null +++ b/YACReader/goto_flow.h @@ -0,0 +1,105 @@ +#ifndef __GOTO_FLOW_H +#define __GOTO_FLOW_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "custom_widgets.h" +class Comic; + +class SlideInitializer; +class PageLoader; + +class GoToFlow : public QWidget +{ + Q_OBJECT +public: + GoToFlow(QWidget* parent = 0,PictureFlow::FlowType flowType = PictureFlow::CoverFlowLike); + bool ready; //comic is ready for read. + void keyPressEvent(QKeyEvent* event); + bool eventFilter(QObject *target, QEvent *event); +private: + YACReaderFlow * flow; + QLineEdit * edit; + QIntValidator * v; + QPushButton * centerButton; + QPushButton * goToButton; + Comic * comic; + QSize imageSize; + + QVector imagesLoaded; + QVector imagesSetted; + uint numImagesLoaded; + QVector imagesReady; + QVector rawImages; + QTimer* updateTimer; + PageLoader* worker; + virtual void wheelEvent(QWheelEvent * event); + + private slots: + void preload(); + void updateImageData(); + + public slots: + void goTo(); + void setPageNumber(int page); + void centerSlide(); + void centerSlide(int slide); + void reset(); + void setNumSlides(unsigned int slides); + void setImageReady(int index,const QByteArray & image); + void setFlowType(PictureFlow::FlowType flowType); + void updateSize(); +signals: + void goToPage(unsigned int page); + + +}; +//----------------------------------------------------------------------------- +//SlideInitializer +//----------------------------------------------------------------------------- +class SlideInitializer : public QThread +{ +public: + SlideInitializer(PictureFlow * flow,int slides); +private: + PictureFlow * _flow; + int _slides; + void run(); +}; +//----------------------------------------------------------------------------- +//PageLoader +//----------------------------------------------------------------------------- +class PageLoader : public QThread +{ +public: + PageLoader(); + ~PageLoader(); + // returns FALSE if worker is still busy and can't take the task + bool busy() const; + void generate(int index, QSize size,const QByteArray & rImage); + void reset(){idx = -1;}; + int index() const { return idx; } + QImage result() const { return img; } +protected: + void run(); +private: + QWaitCondition condition; + + bool restart; + bool working; + int idx; + + QSize size; + QImage img; + QByteArray rawImage; +}; + +#endif diff --git a/YACReader/icon.ico b/YACReader/icon.ico new file mode 100644 index 0000000000000000000000000000000000000000..6c31de5a6f6c0c322fe853c1b53fe9c204f6330f GIT binary patch literal 99678 zcmeEv2YgpW+BLo|qN1ya)DTDr=?Nu;7D5j#bVNWzL7IqwNbkMZkc5zg^iCiNy>|gY z>Am+RA|i`*eb0B!O)l>xhNA24r@I?|hnai-w>)jiotfvEeEFWqmp|XDujb>QUB37K zk}uzz%GqTfr}F$Jo~u|f=h!h{z8*#L<*Qvg``D#!zI=c6%a?EL*qr0%pUGEwRK9#J zJk%rYh-Zxdc@LkH$KNx?CHe9_%k*WUFj0)KAsh(4F`s?Tv3}Qe<~`O__qY@Fh%Uqk zVi@r*(T)fp^m_@SAYr{%d7ZCDwECa_c{a$gQk5Ty6e)V~#ey%*;JHpjAW?;|B`ASk z+%LLByEEZlt$x$xkr`Qdr&Fh&?aDe+A_hOYS13f}e!p>C#@?xbn}@f9yQfd@Zc{@r zW%&jS9y%1R?v+LrE?iX4FF^c42E5+0l5dUmwHvkkp+$!-2<+GsZ;hRck&9Pj?bb~g zI&w6s*Q|frqr7i_dk2???&rO>-u0T_YCRzgqheDrJuwvvmSiA4D+7yHufXz6>#=^@ zM#L{p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!wUS}G_`~OZ%Z-0}` zP(O~%WzAo*y_)}5u>7TeXRR*u=lk1)y^sBf^S|zG^JNdQ)^FkOZ~9BWgWuop+233n zFGTXaj^O*XnBfF=!5#%3`>i?hHJ`bMziSeBcjoW>)%Iol&V?WMy4Ui-i|@QG-~VK+ z5Zi?v$9^qd80U6k+2+gn>`3gg-*Nd7mw)zmQOk>l;L;i!XgUmDQ?Qj-3APVAh*@3o z1?;7B%=W(@!XCw{uuN<&HpZ~FbN{pdeZPPHzYf=a$KrP^e&@jN9QYUJ0Ds!=|NZ_A Y{QeF6{tf*84gCHM{QeF6zw{0K|6N)}g8%>k literal 0 HcmV?d00001 diff --git a/YACReader/icon.rc b/YACReader/icon.rc new file mode 100644 index 00000000..86e8e9b3 --- /dev/null +++ b/YACReader/icon.rc @@ -0,0 +1 @@ +IDI_ICON1 ICON DISCARDABLE "icon.ico" diff --git a/YACReader/images.qrc b/YACReader/images.qrc new file mode 100644 index 00000000..2aab79e4 --- /dev/null +++ b/YACReader/images.qrc @@ -0,0 +1,67 @@ + + + ../images/open.png + ../images/openFolder.png + ../images/next.png + ../images/prev.png + ../images/icon.png + ../images/zoom.png + ../images/fit.png + ../images/goto.png + ../images/help.png + ../images/center.png + ../images/options.png + ../images/comicFolder.png + ../images/save.png + ../images/rotateL.png + ../images/rotateR.png + ../images/flow1.png + ../images/flow2.png + ../images/flow3.png + ../images/bookmark.png + ../images/setBookmark.png + ../images/notCover.png + ../images/previousComic.png + ../images/nextComic.png + ../images/deleteLibrary.png + ../images/properties.png + ../images/doublePage.png + ../images/shortcuts.png + ../images/close.png + ../images/up.png + ../images/down.png + ../images/dictionary.png + ../images/alwaysOnTop.png + ../images/adjustToFullSize.png + ../images/helpImages/open.png + ../images/helpImages/openFolder.png + ../images/helpImages/next.png + ../images/helpImages/prev.png + ../images/helpImages/icon.png + ../images/helpImages/zoom.png + ../images/helpImages/fit.png + ../images/helpImages/goto.png + ../images/helpImages/help.png + ../images/helpImages/center.png + ../images/helpImages/options.png + ../images/helpImages/comicFolder.png + ../images/helpImages/save.png + ../images/helpImages/rotateL.png + ../images/helpImages/rotateR.png + ../images/helpImages/flow1.png + ../images/helpImages/flow2.png + ../images/helpImages/flow3.png + ../images/helpImages/bookmark.png + ../images/helpImages/setBookmark.png + ../images/helpImages/notCover.png + ../images/helpImages/previousComic.png + ../images/helpImages/nextComic.png + ../images/helpImages/deleteLibrary.png + ../images/helpImages/properties.png + ../images/helpImages/doublePage.png + ../images/helpImages/shortcuts.png + ../images/helpImages/keyboard.png + ../images/helpImages/mouse.png + ../images/helpImages/speaker.png + + diff --git a/YACReader/magnifying_glass.cpp b/YACReader/magnifying_glass.cpp new file mode 100644 index 00000000..766716a3 --- /dev/null +++ b/YACReader/magnifying_glass.cpp @@ -0,0 +1,267 @@ +#include "magnifying_glass.h" +#include "viewer.h" + + + +MagnifyingGlass::MagnifyingGlass(int w, int h, QWidget * parent) +:QLabel(parent),zoomLevel(0.5) +{ + setup(QSize(w,h)); +} + +MagnifyingGlass::MagnifyingGlass(const QSize & size, QWidget * parent) +:QLabel(parent),zoomLevel(0.5) +{ + setup(size); +} + +void MagnifyingGlass::setup(const QSize & size) +{ + resize(size); + setScaledContents(true); + setMouseTracking(true); + setCursor(QCursor(Qt::BlankCursor)); +} + +void MagnifyingGlass::mouseMoveEvent(QMouseEvent * event) +{ + updateImage(); +} + +void MagnifyingGlass::updateImage(int x, int y) +{ + //image section augmented + int zoomWidth = static_cast(width() * zoomLevel); + int zoomHeight = static_cast(height() * zoomLevel); + Viewer * p = (Viewer *)parent(); + int currentPos = p->verticalScrollBar()->sliderPosition(); + const QPixmap * image = p->pixmap(); + int iWidth = image->width(); + int iHeight = image->height(); + float wFactor = static_cast(iWidth) / p->widget()->width(); + float hFactor = static_cast(iHeight) / p->widget()->height(); + zoomWidth *= wFactor; + zoomHeight *= hFactor; + if(p->verticalScrollBar()->minimum()==p->verticalScrollBar()->maximum()) + { + int xp = static_cast(((x-p->widget()->pos().x())*wFactor)-zoomWidth/2); + int yp = static_cast((y-p->widget()->pos().y()+currentPos)*hFactor-zoomHeight/2); + int xOffset=0; + int yOffset=0; + int zw=zoomWidth; + int zh=zoomHeight; + //int wOffset,hOffset=0; + bool outImage = false; + if(xp<0) + { + xOffset = -xp; + xp=0; + zw = zw - xOffset; + outImage = true; + } + if(yp<0) + { + yOffset = -yp; + yp=0; + zh = zh - yOffset; + outImage = true; + } + + if(xp+zoomWidth >= image->width()) + { + zw -= xp+zw - image->width(); + outImage = true; + } + if(yp+zoomHeight >= image->height()) + { + zh -= yp+zh - image->height(); + outImage = true; + } + if(outImage) + { + QImage img(zoomWidth,zoomHeight,QImage::Format_RGB32); + img.fill(0); + if(zw>0&&zh>0) + { + QPainter painter(&img); + painter.drawPixmap(xOffset,yOffset,p->pixmap()->copy(xp,yp,zw,zh)); + } + setPixmap(QPixmap().fromImage(img)); + } + else + setPixmap(p->pixmap()->copy(xp,yp,zoomWidth,zoomHeight)); + } + else + { + int xp = static_cast(((x-p->widget()->pos().x())*wFactor)-zoomWidth/2); + int yp = static_cast((y+currentPos)*hFactor-zoomHeight/2); + int xOffset=0; + int yOffset=0; + int zw=zoomWidth; + int zh=zoomHeight; + //int wOffset,hOffset=0; + bool outImage = false; + if(xp<0) + { + xOffset = -xp; + xp=0; + zw = zw - xOffset; + outImage = true; + } + if(yp<0) + { + yOffset = -yp; + yp=0; + zh = zh - yOffset; + outImage = true; + } + + if(xp+zoomWidth >= image->width()) + { + zw -= xp+zw - image->width(); + outImage = true; + } + if(yp+zoomHeight >= image->height()) + { + zh -= yp+zh - image->height(); + outImage = true; + } + if(outImage) + { + QImage img(zoomWidth,zoomHeight,QImage::Format_RGB32); + img.fill(0); + if(zw>0&&zh>0) + { + QPainter painter(&img); + painter.drawPixmap(xOffset,yOffset,p->pixmap()->copy(xp,yp,zw,zh)); + } + setPixmap(QPixmap().fromImage(img)); + } + else + setPixmap(p->pixmap()->copy(xp,yp,zoomWidth,zoomHeight)); + } + move(static_cast(x-float(width())/2),static_cast(y-float(height())/2)); +} + +void MagnifyingGlass::updateImage() +{ + if(isVisible()) + { + QPoint p = QPoint(cursor().pos().x(),cursor().pos().y()); + p = this->parentWidget()->mapFromGlobal(p); + updateImage(p.x(),p.y()); + } +} +void MagnifyingGlass::wheelEvent(QWheelEvent * event) +{ + switch(event->modifiers()) + { + //size + case Qt::NoModifier: + if(event->delta()<0) + sizeUp(); + else + sizeDown(); + break; + //size height + case Qt::ControlModifier: + if(event->delta()<0) + heightUp(); + else + heightDown(); + break; + //size width + case Qt::AltModifier: + if(event->delta()<0) + widthUp(); + else + widthDown(); + break; + //zoom level + case Qt::ShiftModifier: + if(event->delta()<0) + zoomIn(); + else + zoomOut(); + break; + } + updateImage(); + event->setAccepted(true); +} +void MagnifyingGlass::zoomIn() +{ + if(zoomLevel>0.2) + zoomLevel -= 0.025; +} + +void MagnifyingGlass::zoomOut() +{ + if(zoomLevel<0.9) + zoomLevel += 0.025; +} + +void MagnifyingGlass::sizeUp() +{ + Viewer * p = (Viewer *)parent(); + if(width()<(p->width()*0.90)) + resize(width()+30,height()+15); +} + +void MagnifyingGlass::sizeDown() +{ + if(width()>175) + resize(width()-30,height()-15); +} + +void MagnifyingGlass::heightUp() +{ + Viewer * p = (Viewer *)parent(); + if(height()<(p->height()*0.90)) + resize(width(),height()+15); +} + +void MagnifyingGlass::heightDown() +{ + if(height()>80) + resize(width(),height()-15); +} + +void MagnifyingGlass::widthUp() +{ + Viewer * p = (Viewer *)parent(); + if(width()<(p->width()*0.90)) + resize(width()+30,height()); +} + +void MagnifyingGlass::widthDown() +{ + if(width()>175) + resize(width()-30,height()); +} + +void MagnifyingGlass::keyPressEvent(QKeyEvent *event) +{ + bool validKey = false; + switch (event->key()) + { + case Qt::Key_Plus: + sizeUp(); + validKey = true; + break; + case Qt::Key_Minus: + sizeDown(); + validKey = true; + break; + case Qt::Key_Underscore: + zoomOut(); + validKey = true; + break; + case Qt::Key_Asterisk: + zoomIn(); + validKey = true; + break; + } + updateImage(); + if(validKey) + event->setAccepted(true); +} diff --git a/YACReader/magnifying_glass.h b/YACReader/magnifying_glass.h new file mode 100644 index 00000000..519e3404 --- /dev/null +++ b/YACReader/magnifying_glass.h @@ -0,0 +1,34 @@ +#ifndef __MAGNIFYING_GLASS +#define __MAGNIFYING_GLASS + +#include +#include +#include +#include + + class MagnifyingGlass : public QLabel + { + Q_OBJECT + private: + float zoomLevel; + void setup(const QSize & size); + void keyPressEvent(QKeyEvent * event); + public: + MagnifyingGlass(int width,int height,QWidget * parent); + MagnifyingGlass(const QSize & size, QWidget * parent); + void mouseMoveEvent(QMouseEvent * event); + public slots: + void updateImage(int x, int y); + void updateImage(); + void wheelEvent(QWheelEvent * event); + void zoomIn(); + void zoomOut(); + void sizeUp(); + void sizeDown(); + void heightUp(); + void heightDown(); + void widthUp(); + void widthDown(); + }; + +#endif diff --git a/YACReader/main.cpp b/YACReader/main.cpp new file mode 100644 index 00000000..911aba72 --- /dev/null +++ b/YACReader/main.cpp @@ -0,0 +1,34 @@ +#include +#include +#include +//#include +#include +#include +#include +#include +#include +#include +#include +#include "main_window_viewer.h" +#include "configuration.h" + + +int main(int argc, char * argv[]) +{ + QApplication app(argc, argv); + + QTranslator translator; + QString sufix = QLocale::system().name(); + translator.load(":/yacreader_"+sufix); + app.installTranslator(&translator); + app.setApplicationName("YACReader"); + + MainWindowViewer mwv; + mwv.show(); + + int ret = app.exec(); + + Configuration::getConfiguration().save(); + + return ret; +} diff --git a/YACReader/main_window_viewer.cpp b/YACReader/main_window_viewer.cpp new file mode 100644 index 00000000..7bbfaac0 --- /dev/null +++ b/YACReader/main_window_viewer.cpp @@ -0,0 +1,680 @@ +#include "main_window_viewer.h" +#include "configuration.h" +#include "viewer.h" +#include "goto_dialog.h" +#include "custom_widgets.h" +#include "options_dialog.h" +#include "check_new_version.h" +#include "comic.h" +#include "bookmarks_dialog.h" +#include "shortcuts_dialog.h" + + +MainWindowViewer::MainWindowViewer() +:QMainWindow(),fullscreen(false),toolbars(true),alwaysOnTop(false),currentDirectory("."),currentDirectoryImgDest(".") +{ + loadConfiguration(); + setupUI(); +} + +void MainWindowViewer::loadConfiguration() +{ + Configuration & config = Configuration::getConfiguration(); + currentDirectory = config.getDefaultPath(); + fullscreen = config.getFullScreen(); +} + +void MainWindowViewer::setupUI() +{ + + setWindowIcon(QIcon(":/images/icon.png")); + + viewer = new Viewer(this); + connect(viewer,SIGNAL(reset()),this,SLOT(disableActions())); + + setCentralWidget(viewer); + int heightDesktopResolution = QApplication::desktop()->screenGeometry().height(); + int widthDesktopResolution = QApplication::desktop()->screenGeometry().width(); + int height,width; + height = static_cast(heightDesktopResolution*0.84); + width = static_cast(height*0.70); + Configuration & conf = Configuration::getConfiguration(); + QPoint p = conf.getPos(); + QSize s = conf.getSize(); + if(s.width()!=0) + { + move(p); + resize(s); + } + else + { + move(QPoint((widthDesktopResolution-width)/2,((heightDesktopResolution-height)-40)/2)); + resize(QSize(width,height)); + } + + had = new HelpAboutDialog(this); //TODO load data + + had->loadAboutInformation(":/files/about.html"); + had->loadHelp(":/files/helpYACReader.html"); + + optionsDialog = new OptionsDialog(this); + connect(optionsDialog,SIGNAL(accepted()),viewer,SLOT(updateOptions())); + + shortcutsDialog = new ShortcutsDialog(this); + + createActions(); + createToolBars(); + if(QCoreApplication::argc()>1) + { + //TODO: new method open(QString) + QString pathFile = QCoreApplication::arguments().at(1); + currentDirectory = pathFile; + QFileInfo fi(pathFile); + getSiblingComics(fi.absolutePath(),fi.fileName()); + viewer->open(pathFile); + enableActions(); + } + + versionChecker = new HttpVersionChecker(); + + connect(versionChecker,SIGNAL(newVersionDetected()), + this,SLOT(newVersion())); + + versionChecker->get(); + + viewer->setFocusPolicy(Qt::StrongFocus); + + setWindowTitle("YACReader"); + + if(Configuration::getConfiguration().getAlwaysOnTop()) + { + setWindowFlags(this->windowFlags() | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint); + } + + if(fullscreen) + toFullScreen(); + if(conf.getMaximized()) + showMaximized(); + + setAcceptDrops(true); +} + +void MainWindowViewer::createActions() +{ + openAction = new QAction(tr("&Open"),this); + openAction->setShortcut(tr("O")); + openAction->setIcon(QIcon(":/images/open.png")); + openAction->setToolTip(tr("Open a comic")); + connect(openAction, SIGNAL(triggered()), this, SLOT(open())); + + openFolderAction = new QAction(tr("Open Folder"),this); + openFolderAction->setShortcut(tr("Ctrl+O")); + openFolderAction->setIcon(QIcon(":/images/openFolder.png")); + openFolderAction->setToolTip(tr("Open image folder")); + connect(openFolderAction, SIGNAL(triggered()), this, SLOT(openFolder())); + + saveImageAction = new QAction(tr("Save"),this); + saveImageAction->setIcon(QIcon(":/images/save.png")); + saveImageAction->setToolTip(tr("Save current page")); + saveImageAction->setDisabled(true); + connect(saveImageAction,SIGNAL(triggered()),this,SLOT(saveImage())); + + openPreviousComicAction = new QAction(tr("Previous Comic"),this); + openPreviousComicAction->setIcon(QIcon(":/images/previousComic.png")); + openPreviousComicAction->setShortcut(Qt::CTRL + Qt::Key_Left); + openPreviousComicAction->setToolTip(tr("Open previous comic")); + openPreviousComicAction->setDisabled(true); + connect(openPreviousComicAction,SIGNAL(triggered()),this,SLOT(openPreviousComic())); + + openNextComicAction = new QAction(tr("Next Comic"),this); + openNextComicAction->setIcon(QIcon(":/images/nextComic.png")); + openNextComicAction->setShortcut(Qt::CTRL + Qt::Key_Right); + openNextComicAction->setToolTip(tr("Open next comic")); + openNextComicAction->setDisabled(true); + connect(openNextComicAction,SIGNAL(triggered()),this,SLOT(openNextComic())); + + prevAction = new QAction(tr("&Previous"),this); + prevAction->setIcon(QIcon(":/images/prev.png")); + prevAction->setShortcut(Qt::Key_Left); + prevAction->setToolTip(tr("Go to previous page")); + prevAction->setDisabled(true); + connect(prevAction, SIGNAL(triggered()),viewer,SLOT(prev())); + + nextAction = new QAction(tr("&Next"),this); + nextAction->setIcon(QIcon(":/images/next.png")); + nextAction->setShortcut(Qt::Key_Right); + nextAction->setToolTip(tr("Go to next page")); + nextAction->setDisabled(true); + connect(nextAction, SIGNAL(triggered()),viewer,SLOT(next())); + + adjustWidth = new QAction(tr("Fit Width"),this); + adjustWidth->setShortcut(tr("A")); + adjustWidth->setIcon(QIcon(":/images/fit.png")); + adjustWidth->setCheckable(true); + adjustWidth->setDisabled(true); + adjustWidth->setChecked(Configuration::getConfiguration().getAdjustToWidth()); + adjustWidth->setToolTip(tr("Fit image to ...")); + //adjustWidth->setIcon(QIcon(":/images/fitWidth.png")); + connect(adjustWidth, SIGNAL(triggered()),this,SLOT(changeFit())); + + leftRotationAction = new QAction(tr("Rotate image to the left"),this); + leftRotationAction->setShortcut(tr("L")); + leftRotationAction->setIcon(QIcon(":/images/rotateL.png")); + leftRotationAction->setDisabled(true); + connect(leftRotationAction, SIGNAL(triggered()),viewer,SLOT(rotateLeft())); + + rightRotationAction = new QAction(tr("Rotate image to the right"),this); + rightRotationAction->setShortcut(tr("R")); + rightRotationAction->setIcon(QIcon(":/images/rotateR.png")); + rightRotationAction->setDisabled(true); + connect(rightRotationAction, SIGNAL(triggered()),viewer,SLOT(rotateRight())); + + doublePageAction = new QAction(tr("Double page mode"),this); + doublePageAction->setToolTip(tr("Switch to double page mode")); + doublePageAction->setShortcut(tr("D")); + doublePageAction->setIcon(QIcon(":/images/doublePage.png")); + doublePageAction->setDisabled(true); + doublePageAction->setCheckable(true); + doublePageAction->setChecked(Configuration::getConfiguration().getDoublePage()); + connect(doublePageAction, SIGNAL(triggered()),viewer,SLOT(doublePageSwitch())); + + goToPage = new QAction(tr("Go To"),this); + goToPage->setShortcut(tr("G")); + goToPage->setIcon(QIcon(":/images/goto.png")); + goToPage->setDisabled(true); + goToPage->setToolTip(tr("Go to page ...")); + connect(goToPage, SIGNAL(triggered()),viewer,SLOT(showGoToDialog())); + + optionsAction = new QAction(tr("Options"),this); + optionsAction->setShortcut(tr("C")); + optionsAction->setToolTip(tr("YACReader options")); + optionsAction->setIcon(QIcon(":/images/options.png")); + + connect(optionsAction, SIGNAL(triggered()),optionsDialog,SLOT(show())); + + helpAboutAction = new QAction(tr("Help"),this); + helpAboutAction->setToolTip(tr("Help, About YACReader")); + helpAboutAction->setShortcut(Qt::Key_F1); + helpAboutAction->setIcon(QIcon(":/images/help.png")); + connect(helpAboutAction, SIGNAL(triggered()),had,SLOT(show())); + + showMagnifyingGlass = new QAction(tr("Magnifying glass"),this); + showMagnifyingGlass->setToolTip(tr("Switch Magnifying glass")); + showMagnifyingGlass->setShortcut(tr("Z")); + showMagnifyingGlass->setIcon(QIcon(":/images/zoom.png")); + showMagnifyingGlass->setDisabled(true); + showMagnifyingGlass->setCheckable(true); + connect(showMagnifyingGlass, SIGNAL(triggered()),viewer,SLOT(magnifyingGlassSwitch())); + + setBookmark = new QAction(tr("Set bookmark"),this); + setBookmark->setToolTip(tr("Set a bookmark on the current page")); + setBookmark->setShortcut(Qt::CTRL+Qt::Key_M); + setBookmark->setIcon(QIcon(":/images/setBookmark.png")); + setBookmark->setDisabled(true); + setBookmark->setCheckable(true); + connect(setBookmark,SIGNAL(triggered (bool)),viewer,SLOT(setBookmark(bool))); + connect(viewer,SIGNAL(pageAvailable(bool)),setBookmark,SLOT(setEnabled(bool))); + connect(viewer,SIGNAL(pageIsBookmark(bool)),setBookmark,SLOT(setChecked(bool))); + + showBookmarks = new QAction(tr("Show bookmarks"),this); + showBookmarks->setToolTip(tr("Show the bookmarks of the current comic")); + showBookmarks->setShortcut(tr("M")); + showBookmarks->setIcon(QIcon(":/images/bookmark.png")); + showBookmarks->setDisabled(true); + connect(showBookmarks, SIGNAL(triggered()),viewer->getBookmarksDialog(),SLOT(show())); + + showShorcutsAction = new QAction(tr("Show keyboard shortcuts"), this ); + showShorcutsAction->setIcon(QIcon(":/images/shortcuts.png")); + connect(showShorcutsAction, SIGNAL(triggered()),shortcutsDialog,SLOT(show())); + + showInfo = new QAction(tr("Show Info"),this); + showInfo->setShortcut(tr("I")); + showInfo->setIcon(QIcon(":/images/properties.png")); + showInfo->setDisabled(true); + connect(showInfo, SIGNAL(triggered()),viewer,SLOT(informationSwitch())); + + closeAction = new QAction(tr("Close"),this); + closeAction->setShortcut(Qt::Key_Escape); + closeAction->setIcon(QIcon(":/images/deleteLibrary.png")); + connect(closeAction,SIGNAL(triggered()),this,SLOT(close())); + + showDictionaryAction = new QAction(tr("Show Dictionary"),this); + showDictionaryAction->setShortcut(Qt::Key_T); + showDictionaryAction->setIcon(QIcon(":/images/dictionary.png")); + showDictionaryAction->setCheckable(true); + showDictionaryAction->setDisabled(true); + connect(showDictionaryAction,SIGNAL(triggered()),viewer,SLOT(translatorSwitch())); + + alwaysOnTopAction = new QAction(tr("Always on top"),this); + alwaysOnTopAction->setShortcut(Qt::Key_Q); + alwaysOnTopAction->setIcon(QIcon(":/images/alwaysOnTop.png")); + alwaysOnTopAction->setCheckable(true); + alwaysOnTopAction->setDisabled(true); + alwaysOnTopAction->setChecked(Configuration::getConfiguration().getAlwaysOnTop()); + connect(alwaysOnTopAction,SIGNAL(triggered()),this,SLOT(alwaysOnTopSwitch())); + + adjustToFullSizeAction = new QAction(tr("Show full size"),this); + adjustToFullSizeAction->setShortcut(Qt::Key_W); + adjustToFullSizeAction->setIcon(QIcon(":/images/adjustToFullSize.png")); + adjustToFullSizeAction->setCheckable(true); + adjustToFullSizeAction->setDisabled(true); + adjustToFullSizeAction->setChecked(Configuration::getConfiguration().getAdjustToFullSize()); + connect(adjustToFullSizeAction,SIGNAL(triggered()),this,SLOT(adjustToFullSizeSwitch())); +} + +void MainWindowViewer::createToolBars() +{ + comicToolBar = addToolBar(tr("&File")); + + QToolButton * tb = new QToolButton(); + tb->addAction(openAction); + tb->addAction(openFolderAction); + tb->setPopupMode(QToolButton::MenuButtonPopup); + tb->setDefaultAction(openAction); + + comicToolBar->addWidget(tb); + comicToolBar->addAction(saveImageAction); + comicToolBar->addAction(openPreviousComicAction); + comicToolBar->addAction(openNextComicAction); + + comicToolBar->addSeparator(); + comicToolBar->addAction(prevAction); + comicToolBar->addAction(nextAction); + comicToolBar->addAction(goToPage); + + comicToolBar->addSeparator(); + comicToolBar->addAction(alwaysOnTopAction); + + comicToolBar->addSeparator(); + comicToolBar->addAction(adjustWidth); + comicToolBar->addAction(adjustToFullSizeAction); + comicToolBar->addAction(leftRotationAction); + comicToolBar->addAction(rightRotationAction); + comicToolBar->addAction(doublePageAction); + + comicToolBar->addSeparator(); + comicToolBar->addAction(showMagnifyingGlass); + + comicToolBar->addSeparator(); + comicToolBar->addAction(setBookmark); + comicToolBar->addAction(showBookmarks); + + comicToolBar->addSeparator(); + comicToolBar->addAction(showDictionaryAction); + + comicToolBar->addWidget(new QToolBarStretch()); + + comicToolBar->addAction(showShorcutsAction); + comicToolBar->addAction(optionsAction); + comicToolBar->addAction(helpAboutAction); + comicToolBar->addAction(closeAction); + + comicToolBar->setMovable(false); + + + viewer->addAction(openAction); + viewer->addAction(openFolderAction); + viewer->addAction(saveImageAction); + viewer->addAction(openPreviousComicAction); + viewer->addAction(openNextComicAction); + QAction * separator = new QAction("",this); + separator->setSeparator(true); + viewer->addAction(separator); + viewer->addAction(prevAction); + viewer->addAction(nextAction); + viewer->addAction(goToPage); + viewer->addAction(adjustWidth); + viewer->addAction(adjustToFullSizeAction); + viewer->addAction(leftRotationAction); + viewer->addAction(rightRotationAction); + viewer->addAction(doublePageAction); + separator = new QAction("",this); + separator->setSeparator(true); + viewer->addAction(separator); + + viewer->addAction(setBookmark); + viewer->addAction(showBookmarks); + separator = new QAction("",this); + separator->setSeparator(true); + viewer->addAction(separator); + + viewer->addAction(showDictionaryAction); + separator = new QAction("",this); + separator->setSeparator(true); + viewer->addAction(separator); + + viewer->addAction(showMagnifyingGlass); + viewer->addAction(optionsAction); + viewer->addAction(helpAboutAction); + viewer->addAction(showInfo); + viewer->addAction(showShorcutsAction); + separator = new QAction("",this); + separator->setSeparator(true); + viewer->addAction(separator); + viewer->addAction(closeAction); + + viewer->setContextMenuPolicy(Qt::ActionsContextMenu); +} + +void MainWindowViewer::open() +{ + QFileDialog openDialog; + QString pathFile = openDialog.getOpenFileName(this,tr("Open Comic"),currentDirectory,tr("Comic files (*.cbr *.cbz *.rar *.zip *.tar *.arj)")); + if (!pathFile.isEmpty()) + { + openComicFromPath(pathFile); + } +} + +void MainWindowViewer::openComicFromPath(QString pathFile) +{ + currentDirectory = pathFile; + QFileInfo fi(pathFile); + getSiblingComics(fi.absolutePath(),fi.fileName()); + viewer->open(pathFile); + enableActions(); +} + +void MainWindowViewer::openFolder() +{ + QFileDialog openDialog; + QString pathDir = openDialog.getExistingDirectory(this,tr("Open folder"),currentDirectory); + if (!pathDir.isEmpty()) + { + openFolderFromPath(pathDir); + } +} + +void MainWindowViewer::openFolderFromPath(QString pathDir) +{ + currentDirectory = pathDir; //TODO ?? + QFileInfo fi(pathDir); + getSiblingComics(fi.absolutePath(),fi.fileName()); + viewer->open(pathDir); + enableActions(); +} + +void MainWindowViewer::saveImage() +{ + QFileDialog saveDialog; + QString pathFile = saveDialog.getSaveFileName(this,tr("Save current page"),currentDirectoryImgDest,tr("Image files (*.jpg)")); + if (!pathFile.isEmpty()) + { + currentDirectoryImgDest = pathFile; + const QPixmap * p = viewer->pixmap(); + if(p!=NULL) + p->save(pathFile); + } +} + +void MainWindowViewer::enableActions() +{ + saveImageAction->setDisabled(false); + prevAction->setDisabled(false); + nextAction->setDisabled(false); + adjustWidth->setDisabled(false); + goToPage->setDisabled(false); + alwaysOnTopAction->setDisabled(false); + leftRotationAction->setDisabled(false); + rightRotationAction->setDisabled(false); + showMagnifyingGlass->setDisabled(false); + doublePageAction->setDisabled(false); + adjustToFullSizeAction->setDisabled(false); + //setBookmark->setDisabled(false); + showBookmarks->setDisabled(false); + showInfo->setDisabled(false); //TODO enable goTo and showInfo (or update) when numPages emited + showDictionaryAction->setDisabled(false); +} +void MainWindowViewer::disableActions() +{ + saveImageAction->setDisabled(true); + prevAction->setDisabled(true); + nextAction->setDisabled(true); + adjustWidth->setDisabled(true); + goToPage->setDisabled(true); + alwaysOnTopAction->setDisabled(true); + leftRotationAction->setDisabled(true); + rightRotationAction->setDisabled(true); + showMagnifyingGlass->setDisabled(true); + doublePageAction->setDisabled(true); + adjustToFullSizeAction->setDisabled(true); + setBookmark->setDisabled(true); + showBookmarks->setDisabled(true); + showInfo->setDisabled(true); //TODO enable goTo and showInfo (or update) when numPages emited + openPreviousComicAction->setDisabled(true); + openNextComicAction->setDisabled(true); + showDictionaryAction->setDisabled(true); +} + +void MainWindowViewer::keyPressEvent(QKeyEvent *event) +{ + switch (event->key()) + { + case Qt::Key_Escape: + this->close(); + break; + case Qt::Key_F: + toggleFullScreen(); + break; + case Qt::Key_H: + toggleToolBars(); + break; + case Qt::Key_O: + open(); + break; + default: + QWidget::keyPressEvent(event); + break; + } +} + +void MainWindowViewer::mouseDoubleClickEvent ( QMouseEvent * event ) +{ + toggleFullScreen(); + event->accept(); +} + +void MainWindowViewer::toggleFullScreen() +{ + fullscreen?toNormal():toFullScreen(); + Configuration::getConfiguration().setFullScreen(fullscreen = !fullscreen); +} + +void MainWindowViewer::toFullScreen() +{ + hideToolBars(); + viewer->hide(); + viewer->fullscreen = true;//TODO, change by the right use of windowState(); + showFullScreen(); + viewer->show(); + if(viewer->magnifyingGlassIsVisible()) + viewer->showMagnifyingGlass(); +} + +void MainWindowViewer::toNormal() +{ + //show all + viewer->hide(); + viewer->fullscreen = false;//TODO, change by the right use of windowState(); + //viewer->hideMagnifyingGlass(); + showNormal(); + showToolBars(); + viewer->show(); + if(viewer->magnifyingGlassIsVisible()) + viewer->showMagnifyingGlass(); +} +void MainWindowViewer::toggleToolBars() +{ + toolbars?hideToolBars():showToolBars(); +} +void MainWindowViewer::hideToolBars() +{ + //hide all + this->comicToolBar->hide(); + toolbars = false; +} + +void MainWindowViewer::showToolBars() +{ + this->comicToolBar->show(); + toolbars = true; +} + +void MainWindowViewer::changeFit() +{ + Configuration & conf = Configuration::getConfiguration(); + conf.setAdjustToWidth(!conf.getAdjustToWidth()); + viewer->updatePage(); +} + +void MainWindowViewer::newVersion() +{ + QMessageBox msgBox; + msgBox.setText(tr("There is a new version avaliable")); + msgBox.setInformativeText(tr("Do you want to download the new version?")); + msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + msgBox.setDefaultButton(QMessageBox::Yes); + int ret = msgBox.exec(); + + if(ret==QMessageBox::Yes){ + QDesktopServices::openUrl(QUrl("http://code.google.com/p/yacreader/")); + } +} + + + + + +void MainWindowViewer::closeEvent ( QCloseEvent * event ) +{ + viewer->save(); + Configuration & conf = Configuration::getConfiguration(); + if(!fullscreen && !isMaximized()) + { + conf.setPos(pos()); + conf.setSize(size()); + } + conf.setMaximized(isMaximized()); +} + +void MainWindowViewer::openPreviousComic() +{ + if(!previousComicPath.isEmpty()) + { + viewer->open(previousComicPath); + QFileInfo fi(previousComicPath); + getSiblingComics(fi.absolutePath(),fi.fileName()); + } +} + +void MainWindowViewer::openNextComic() +{ + if(!nextComicPath.isEmpty()) + { + viewer->open(nextComicPath); + QFileInfo fi(nextComicPath); + getSiblingComics(fi.absolutePath(),fi.fileName()); + } +} + +void MainWindowViewer::getSiblingComics(QString path,QString currentComic) +{ + QDir d(path); + d.setFilter(QDir::Files|QDir::NoDotAndDotDot); + d.setNameFilters(QStringList() << "*.cbr" << "*.cbz" << "*.rar" << "*.zip" << "*.tar"); + d.setSorting(QDir::Name|QDir::IgnoreCase|QDir::LocaleAware); + QStringList list = d.entryList(); + int index = list.indexOf(currentComic); + if(index == -1) //comic not found + { + QFile f(QCoreApplication::applicationDirPath()+"/errorLog.txt"); + if(!f.open(QIODevice::WriteOnly)) + { + QMessageBox::critical(NULL,tr("Saving error log file...."),tr("There was a problem saving YACReader error log file. Please, check if you have enough permissions in the YACReader root folder.")); + } + else + { + QTextStream txtS(&f); + txtS << "METHOD : MainWindowViewer::getSiblingComics" << '\n'; + txtS << "ERROR : current comic not found in its own path" << '\n'; + txtS << path << '\n'; + txtS << currentComic << '\n'; + txtS << "Comic list count : " + list.count() << '\n'; + foreach(QString s, list){ + txtS << s << '\n'; + } + f.close(); + } + } + + previousComicPath = nextComicPath = ""; + if(index>0) + { + previousComicPath = path+"/"+list.at(index-1); + openPreviousComicAction->setDisabled(false); + } + else + openPreviousComicAction->setDisabled(true); + + if(index+1setDisabled(false); + } + else + openNextComicAction->setDisabled(true); +} + +void MainWindowViewer::dropEvent(QDropEvent *event) +{ + QList urlList; + QString fName; + QFileInfo info; + + if (event->mimeData()->hasUrls()) + { + urlList = event->mimeData()->urls(); + + if ( urlList.size() > 0) + { + fName = urlList[0].toLocalFile(); // convert first QUrl to local path + info.setFile( fName ); // information about file + if (info.isFile()) + openComicFromPath(fName); // if is file, setText + else + if(info.isDir()) + openFolderFromPath(fName); + } + } + + event->acceptProposedAction(); +} +void MainWindowViewer::dragEnterEvent(QDragEnterEvent *event) +{ + // accept just text/uri-list mime format + if (event->mimeData()->hasFormat("text/uri-list")) + { + event->acceptProposedAction(); + } +} + +void MainWindowViewer::alwaysOnTopSwitch() +{ + if(!Configuration::getConfiguration().getAlwaysOnTop()) + { + setWindowFlags(this->windowFlags() | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint); //always on top + show(); + } + else + { + setWindowFlags(this->windowFlags() ^ (Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint)); + show(); + } + Configuration::getConfiguration().setAlwaysOnTop(!Configuration::getConfiguration().getAlwaysOnTop()); +} + +void MainWindowViewer::adjustToFullSizeSwitch() +{ + Configuration::getConfiguration().setAdjustToFullSize(!Configuration::getConfiguration().getAdjustToFullSize()); + viewer->updatePage(); +} \ No newline at end of file diff --git a/YACReader/main_window_viewer.h b/YACReader/main_window_viewer.h new file mode 100644 index 00000000..c6221510 --- /dev/null +++ b/YACReader/main_window_viewer.h @@ -0,0 +1,115 @@ +#ifndef __MAIN_WINDOW_VIEWER_H +#define __MAIN_WINDOW_VIEWER_H +#include +#include +#include +#include +#include +#include +#include + +class Comic; +class Viewer; +class OptionsDialog; +class HelpAboutDialog; +class HttpVersionChecker; +class ShortcutsDialog; + + + class MainWindowViewer : public QMainWindow + { + Q_OBJECT + + public slots: + void open(); + void openFolder(); + void saveImage(); + void toggleToolBars(); + void hideToolBars(); + void showToolBars(); + void changeFit(); + void enableActions(); + void disableActions(); + void toggleFullScreen(); + void toFullScreen(); + void toNormal(); + void loadConfiguration(); + void newVersion(); + void openPreviousComic(); + void openNextComic(); + void openComicFromPath(QString pathFile); + void openFolderFromPath(QString pathDir); + void alwaysOnTopSwitch(); + void adjustToFullSizeSwitch(); + /*void viewComic(); + void prev(); + void next(); + void updatePage();*/ + + private: + //!State + bool fullscreen; + bool toolbars; + bool alwaysOnTop; + + QString currentDirectory; + QString currentDirectoryImgDest; + //!Widgets + Viewer * viewer; + //GoToDialog * goToDialog; + OptionsDialog * optionsDialog; + HelpAboutDialog * had; + ShortcutsDialog * shortcutsDialog; + + //! ToolBars + QToolBar *comicToolBar; + + //! Actions + QAction *openAction; + QAction *openFolderAction; + QAction *saveImageAction; + QAction *openPreviousComicAction; + QAction *openNextComicAction; + QAction *nextAction; + QAction *prevAction; + QAction *adjustWidth; + QAction *adjustHeight; + QAction *goToPage; + QAction *optionsAction; + QAction *helpAboutAction; + QAction *showMagnifyingGlass; + QAction *setBookmark; + QAction *showBookmarks; + QAction *leftRotationAction; + QAction *rightRotationAction; + QAction *showInfo; + QAction *closeAction; + QAction *doublePageAction; + QAction *showShorcutsAction; + QAction *showDictionaryAction; + QAction *alwaysOnTopAction; + QAction *adjustToFullSizeAction; + + HttpVersionChecker * versionChecker; + QString previousComicPath; + QString nextComicPath; + //! Método que inicializa el interfaz. + void setupUI(); + void createActions(); + void createToolBars(); + void getSiblingComics(QString path,QString currentComic); + + //! Manejadores de evento: + void keyPressEvent(QKeyEvent *event); + //void resizeEvent(QResizeEvent * event); + void mouseDoubleClickEvent ( QMouseEvent * event ); + void dropEvent(QDropEvent *event); + void dragEnterEvent(QDragEnterEvent *event); + + protected: + virtual void closeEvent ( QCloseEvent * event ); + public: + MainWindowViewer(); + + }; +#endif diff --git a/YACReader/options_dialog.cpp b/YACReader/options_dialog.cpp new file mode 100644 index 00000000..e45b124c --- /dev/null +++ b/YACReader/options_dialog.cpp @@ -0,0 +1,188 @@ +#include "options_dialog.h" +#include "configuration.h" +#include +#include +#include +#include +#include + + +OptionsDialog::OptionsDialog(QWidget * parent) +:QDialog(parent) +{ + QVBoxLayout * layout = new QVBoxLayout(this); + + QGroupBox *slideSizeBox = new QGroupBox(tr("\"Go to flow\" size")); + //slideSizeLabel = new QLabel(,this); + slideSize = new QSlider(this); + slideSize->setMinimum(125); + slideSize->setMaximum(350); + slideSize->setPageStep(5); + slideSize->setOrientation(Qt::Horizontal); + QHBoxLayout * slideLayout = new QHBoxLayout(); + slideLayout->addWidget(slideSize); + slideSizeBox->setLayout(slideLayout); + + QGroupBox *pathBox = new QGroupBox(tr("My comics path")); + + QHBoxLayout * path = new QHBoxLayout(); + path->addWidget(pathEdit = new QLineEdit()); + path->addWidget(pathFindButton = new QPushButton(QIcon(":/images/comicFolder.png"),"")); + pathBox->setLayout(path); + + connect(pathFindButton,SIGNAL(clicked()),this,SLOT(findFolder())); + + accept = new QPushButton(tr("Save")); + cancel = new QPushButton(tr("Cancel")); + connect(accept,SIGNAL(clicked()),this,SLOT(saveOptions())); + connect(cancel,SIGNAL(clicked()),this,SLOT(restoreOptions())); + connect(cancel,SIGNAL(clicked()),this,SLOT(close())); + + QGroupBox *groupBox = new QGroupBox(tr("How to show pages in GoToFlow:")); + + radio1 = new QRadioButton(tr("CoverFlow look")); + radio2 = new QRadioButton(tr("Stripe look")); + radio3 = new QRadioButton(tr("Overlapped Stripe look")); + + + QVBoxLayout *vbox = new QVBoxLayout; + QHBoxLayout * opt1 = new QHBoxLayout; + opt1->addWidget(radio1); + QLabel * lOpt1 = new QLabel(); + lOpt1->setPixmap(QPixmap(":/images/flow1.png")); + opt1->addStretch(); + opt1->addWidget(lOpt1); + vbox->addLayout(opt1); + + QHBoxLayout * opt2 = new QHBoxLayout; + opt2->addWidget(radio2); + QLabel * lOpt2 = new QLabel(); + lOpt2->setPixmap(QPixmap(":/images/flow2.png")); + opt2->addStretch(); + opt2->addWidget(lOpt2); + vbox->addLayout(opt2); + + QHBoxLayout * opt3 = new QHBoxLayout; + opt3->addWidget(radio3); + QLabel * lOpt3 = new QLabel(); + lOpt3->setPixmap(QPixmap(":/images/flow3.png")); + opt3->addStretch(); + opt3->addWidget(lOpt3); + vbox->addLayout(opt3); + + + //vbox->addStretch(1); + groupBox->setLayout(vbox); + + //fitToWidthRatioLabel = new QLabel(tr("Page width stretch"),this); + QGroupBox *fitBox = new QGroupBox(tr("Page width stretch")); + fitToWidthRatioS = new QSlider(this); + fitToWidthRatioS->setMinimum(50); + fitToWidthRatioS->setMaximum(100); + fitToWidthRatioS->setPageStep(5); + fitToWidthRatioS->setOrientation(Qt::Horizontal); + QHBoxLayout * fitLayout = new QHBoxLayout; + fitLayout->addWidget(fitToWidthRatioS); + fitBox->setLayout(fitLayout); + + QHBoxLayout * colorSelection = new QHBoxLayout; + backgroundColor = new QLabel(); + QPalette pal = backgroundColor->palette(); + pal.setColor(backgroundColor->backgroundRole(), Qt::black); + backgroundColor->setPalette(pal); + backgroundColor->setAutoFillBackground(true); + + colorDialog = new QColorDialog(Qt::red,this); + connect(colorDialog,SIGNAL(colorSelected(QColor)),this,SLOT(updateColor(QColor))); + + QGroupBox *colorBox = new QGroupBox(tr("Background color")); + //backgroundColor->setMinimumWidth(100); + colorSelection->addWidget(backgroundColor); + colorSelection->addWidget(selectBackgroundColorButton = new QPushButton(tr("Choose"))); + //colorSelection->addStretch(); + connect(selectBackgroundColorButton, SIGNAL(clicked()), colorDialog, SLOT(show())); + colorBox->setLayout(colorSelection); + + QHBoxLayout * buttons = new QHBoxLayout(); + buttons->addStretch(); + buttons->addWidget(new QLabel(tr("Restart is needed"))); + buttons->addWidget(accept); + buttons->addWidget(cancel); + + layout->addWidget(pathBox); + //layout->addLayout(path); + layout->addWidget(slideSizeBox); + //layout->addWidget(slideSize); + layout->addWidget(groupBox); + //layout->addWidget(fitToWidthRatioLabel); + layout->addWidget(fitBox); + layout->addWidget(colorBox); + //layout->addLayout(colorSelection); + layout->addLayout(buttons); + + + setLayout(layout); + + restoreOptions(); //load options + resize(400,0); + setModal (true); + setWindowTitle("Options"); +} + +void OptionsDialog::findFolder() +{ + QString s = QFileDialog::getExistingDirectory(0,tr("Comics directory"),"."); + if(!s.isEmpty()) + { + pathEdit->setText(s); + } +} + +void OptionsDialog::saveOptions() +{ + Configuration & conf = Configuration::getConfiguration(); + conf.setDefaultPath(pathEdit->text()); + conf.setGotoSlideSize(QSize(static_cast(slideSize->sliderPosition()*SLIDE_ASPECT_RATIO),slideSize->sliderPosition())); + if(radio1->isChecked()) + conf.setFlowType(PictureFlow::CoverFlowLike); + if(radio2->isChecked()) + conf.setFlowType(PictureFlow::Strip); + if(radio3->isChecked()) + conf.setFlowType(PictureFlow::StripOverlapped); + conf.setFitToWidthRatio(fitToWidthRatioS->sliderPosition()/100.0); + conf.setBackgroundColor(colorDialog->currentColor()); + conf.save(); + close(); + emit(accepted()); +} + +void OptionsDialog::restoreOptions() +{ + Configuration & conf = Configuration::getConfiguration(); + + slideSize->setSliderPosition(conf.getGotoSlideSize().height()); + fitToWidthRatioS->setSliderPosition(conf.getFitToWidthRatio()*100); + pathEdit->setText(conf.getDefaultPath()); + updateColor(Configuration::getConfiguration().getBackgroundColor()); + switch(conf.getFlowType()){ + case PictureFlow::CoverFlowLike: + radio1->setChecked(true); + break; + case PictureFlow::Strip: + radio2->setChecked(true); + break; + case PictureFlow::StripOverlapped: + radio3->setChecked(true); + break; + } +} + + +void OptionsDialog::updateColor(const QColor & color) +{ + QPalette pal = backgroundColor->palette(); + pal.setColor(backgroundColor->backgroundRole(), color); + backgroundColor->setPalette(pal); + backgroundColor->setAutoFillBackground(true); + colorDialog->setCurrentColor(color); +} \ No newline at end of file diff --git a/YACReader/options_dialog.h b/YACReader/options_dialog.h new file mode 100644 index 00000000..11b92171 --- /dev/null +++ b/YACReader/options_dialog.h @@ -0,0 +1,57 @@ +#ifndef __OPTIONS_DIALOG_H +#define __OPTIONS_DIALOG_H + +#include +#include +#include +#include +#include +#include +#include +#include + +class OptionsDialog : public QDialog +{ +Q_OBJECT + public: + OptionsDialog(QWidget * parent = 0); + private: + //QLabel * pathLabel; + QLineEdit * pathEdit; + QPushButton * pathFindButton; + + QLabel * magGlassSizeLabel; + + QLabel * zoomLevel; + + //QLabel * slideSizeLabel; + QSlider * slideSize; + + QPushButton * accept; + QPushButton * cancel; + + QRadioButton *radio1; + QRadioButton *radio2; + QRadioButton *radio3; + + //QLabel * fitToWidthRatioLabel; + QSlider * fitToWidthRatioS; + + QLabel * backgroundColor; + QPushButton * selectBackgroundColorButton; + + QColorDialog * colorDialog; + + public slots: + void saveOptions(); + void restoreOptions(); + void findFolder(); + void updateColor(const QColor & color); + +signals: + void changedOptions(); + +}; + + +#endif diff --git a/YACReader/render.cpp b/YACReader/render.cpp new file mode 100644 index 00000000..46fe60e2 --- /dev/null +++ b/YACReader/render.cpp @@ -0,0 +1,746 @@ +#include "render.h" +#include +#include +#include +#include +#include + +#define NL 2 +#define NR 2 + +QMutex mutex; + +//----------------------------------------------------------------------------- +// MeanNoiseReductionFilter +//----------------------------------------------------------------------------- + +MeanNoiseReductionFilter::MeanNoiseReductionFilter(enum NeighborghoodSize ns) +:neighborghoodSize(ns) +{ + +} + +QImage MeanNoiseReductionFilter::setFilter(const QImage & image) +{ + int width = image.width(); + int height = image.height(); + QImage result(width,height,image.format()); + int filterSize = sqrt((float)neighborghoodSize); + int bound = filterSize/2; + QRgb pix; + int r,g,b; + for(int j=bound;j redChannel; + QList greenChannel; + QList blueChannel; + for(int j=bound;j hist(256,0); + + for(int j=0;j 1; i--) + { + new_count += hist[i]; + percentage = new_count/count; + next_percentage = (new_count+hist[i-1])/count; + if(fabs (percentage - 0.006) < fabs (next_percentage - 0.006)) + { + max = i-1; + break; + } + } + QColor c; + int range = max - min; + for(int j=0;j f) +:QThread(), +numPage(np), +data(rd), +page(p), +degrees(d), +filters(f) +{ +} + +void PageRender::run() +{ + //QMutexLocker locker(&mutex); + + QImage img; + img.loadFromData(data); + if(degrees > 0) + { + QMatrix m; + m.rotate(degrees); + img = img.transformed(m,Qt::SmoothTransformation); + } + for(int i=0;isetFilter(img); + } + + + *page = img; + + emit pageReady(numPage); +} + +//----------------------------------------------------------------------------- +// DoublePageRender +//----------------------------------------------------------------------------- + +DoublePageRender::DoublePageRender(int np, const QByteArray & rd, const QByteArray & rd2, QImage * p,unsigned int d, QVector f) +:PageRender(), +numPage(np), +data(rd), +data2(rd2), +page(p), +degrees(d), +filters(f) +{ + +} + +void DoublePageRender::run() +{ + //QImage result; + //QMutexLocker locker(&mutex); + QImage img, img2; + if(!data.isEmpty()) + img.loadFromData(data); + if(!data2.isEmpty()) + img2.loadFromData(data2); + /*if(img.isNull()) + img = QPixmap(img2.width(),img2.height()); + if(img2.isNull()) + img2 = QPixmap(img.width(),img.height());*/ + + int x,y; + x = img.width()+img2.width(); + y = qMax(img.height(),img2.height()); + + + QImage auxImg(x,y,QImage::Format_RGB32); + QPainter painter(&auxImg); + painter.drawImage(0,0,img); + painter.drawImage(img.width(),0,img2); + painter.end(); + + if(degrees > 0) + { + QMatrix m; + m.rotate(degrees); + auxImg = auxImg.transformed(m,Qt::SmoothTransformation); + } + for(int i=0;isetFilter(auxImg); + } + + *page = auxImg; + + emit pageReady(numPage); +} + +//----------------------------------------------------------------------------- +// Render +//----------------------------------------------------------------------------- + +Render::Render() +:currentIndex(0),doublePage(false),comic(0),loadedComic(false),imageRotation(0),numLeftPages(NL),numRightPages(NR) +{ + int size = numLeftPages+numRightPages+1; + currentPageBufferedIndex = numLeftPages; + for(int i = 0; iisNull()) + { + if(pagesReady.size()>0) + { + if(doublePage) + { + if(pagesReady[currentIndex] && pagesReady[qMin(currentIndex+1,(int)comic->numPages()-1)]) + if(currentIndex+1 > comic->numPages()-1) + pageRenders[currentPageBufferedIndex] = new DoublePageRender(currentIndex,comic->getRawData()->at(currentIndex),QByteArray(),buffer[currentPageBufferedIndex],imageRotation,filters); + else + pageRenders[currentPageBufferedIndex] = new DoublePageRender(currentIndex,comic->getRawData()->at(currentIndex),comic->getRawData()->at(currentIndex+1),buffer[currentPageBufferedIndex],imageRotation,filters); + else + //las páginas no están listas, y se están cargando en el cómic + emit processingPage(); //para evitar confusiones esta señal debería llamarse de otra forma + } + else + if(pagesReady[currentIndex]) + pageRenders[currentPageBufferedIndex] = new PageRender(currentIndex,comic->getRawData()->at(currentIndex),buffer[currentPageBufferedIndex],imageRotation,filters); + else + //las páginas no están listas, y se están cargando en el cómic + emit processingPage(); //para evitar confusiones esta señal debería llamarse de otra forma + + //si se ha creado un hilo para renderizar la página actual, se arranca + if(pageRenders[currentPageBufferedIndex]!=0) + { + //se conecta la señal pageReady del hilo, con el SLOT prepareAvailablePage + connect(pageRenders[currentPageBufferedIndex],SIGNAL(pageReady(int)),this,SLOT(prepareAvailablePage(int))); + //se emite la señal de procesando, debido a que los hilos se arrancan aquí + if(doublePage || filters.size()>0) + emit processingPage(); + pageRenders[currentPageBufferedIndex]->start(); + pageRenders[currentPageBufferedIndex]->setPriority(QThread::TimeCriticalPriority); + } + else + //en qué caso sería necesario hacer esto??? //TODO: IMPORTANTE, puede que no sea necesario. + emit processingPage(); + } + else + //no hay ninguna página lista para ser renderizada, es necesario esperar. + emit processingPage(); + } + else + // la página actual está lista + emit currentPageReady(); + + //se renderizan las páginas restantes para llenar el buffer. + if(doublePage) + fillBufferDoublePage(); + else + fillBuffer(); +} + +QPixmap * Render::getCurrentPage() +{ + QPixmap * page = new QPixmap(); + *page = page->fromImage(*buffer[currentPageBufferedIndex]); + return page; +} + +void Render::setRotation(int degrees) +{ + +} + +void Render::setComic(Comic * c) +{ + if(comic !=0) + delete comic; + comic = c; +} + +void Render::prepareAvailablePage(int page) +{ + if(currentIndex == page) + emit currentPageReady(); +} + +void Render::update() +{ + render(); +} +//----------------------------------------------------------------------------- +// Comic interface +//----------------------------------------------------------------------------- +void Render::load(const QString & path) +{ + if(comic!=0) + delete comic; + comic = new Comic(); + previousIndex = currentIndex = 0; + + connect(comic,SIGNAL(errorOpening()),this,SIGNAL(errorOpening())); + connect(comic,SIGNAL(imageLoaded(int)),this,SIGNAL(imageLoaded(int))); + connect(comic,SIGNAL(imageLoaded(int)),this,SLOT(pageRawDataReady(int))); + //connect(comic,SIGNAL(pageChanged(int)),this,SIGNAL(pageChanged(int))); + connect(comic,SIGNAL(numPages(unsigned int)),this,SIGNAL(numPages(unsigned int))); + connect(comic,SIGNAL(numPages(unsigned int)),this,SLOT(setNumPages(unsigned int))); + connect(comic,SIGNAL(imageLoaded(int,QByteArray)),this,SIGNAL(imageLoaded(int,QByteArray))); + connect(comic,SIGNAL(isBookmark(bool)),this,SIGNAL(currentPageIsBookmark(bool))); + connect(comic,SIGNAL(bookmarksLoaded(const Bookmarks &)),this,SIGNAL(bookmarksLoaded(const Bookmarks &))); + pagesReady.clear(); + comic->load(path); + invalidate(); + loadedComic = true; //TODO reset if an error occurs while opening +} +//si se solicita la siguiente página, se calcula cuál debe ser en función de si se lee en modo a doble página o no. +//la página sólo se renderiza, si realmente ha cambiado. +void Render::nextPage() +{ + int nextPage; //indica cuál será la próxima página + if(doublePage) + { + nextPage = currentIndex; + if(currentIndex+2numPages()) + { + nextPage = currentIndex+2; + if(currentIndex != nextPage) + comic->setIndex(nextPage); + } + } + else + { + nextPage = comic->nextPage(); + } + + //se fuerza renderizado si la página ha cambiado + if(currentIndex != nextPage) + { + previousIndex = currentIndex; + currentIndex = nextPage; + update(); + } +} +//si se solicita la página anterior, se calcula cuál debe ser en función de si se lee en modo a doble página o no. +//la página sólo se renderiza, si realmente ha cambiado. +void Render::previousPage() +{ + int previousPage; //indica cuál será la próxima página + if(doublePage) + { + if(currentIndex == 1) + invalidate(); + previousPage = qMax(currentIndex-2,0); + if(currentIndex != previousPage) + { + comic->setIndex(previousPage); + } + } + else + { + previousPage = comic->previousPage(); + } + + //se fuerza renderizado si la página ha cambiado + if(currentIndex != previousPage) + { + previousIndex = currentIndex; + currentIndex = previousPage; + update(); + } +} +unsigned int Render::getIndex() +{ + return comic->getIndex(); +} +unsigned int Render::numPages() +{ + return comic->numPages(); +} + +bool Render::hasLoadedComic() +{ + if(comic!=0) + return comic->loaded(); + return false; +} + +void Render::setNumPages(unsigned int numPages) +{ + pagesReady.fill(false,numPages); +} + +void Render::pageRawDataReady(int page) +{ + pagesEmited.push_back(page); + if(pageRenders.size()>0) + { + for(int i=0;i currentIndex-2*numLeftPages)) || + ((pagesEmited.at(i) > currentIndex+1) && (pagesEmited.at(i) < currentIndex+1+2*numRightPages)) ) + { + fillBufferDoublePage(); + } + } + else + { + if ( ((pagesEmited.at(i) < currentIndex) && (pagesEmited.at(i) > currentIndex-numLeftPages)) || + ((pagesEmited.at(i) > currentIndex) && (pagesEmited.at(i) < currentIndex+numRightPages)) ) + { + fillBuffer(); + } + } + } + pagesEmited.clear(); + } +} + +//sólo se renderiza la página, si ha habido un cambio de página +void Render::goTo(int index) +{ + + if(currentIndex != index) + { + comic->setIndex(index); + previousIndex = currentIndex; + currentIndex = index; + + //si cambia la paridad de las página en modo a doble página, se rellena el buffer. + //esto solo debería orcurrir al llegar al principio o al final + if(doublePage && ((previousIndex - index) % 2)!=0) + invalidate(); + + update(); + } +} + +void Render::rotateRight() +{ + imageRotation = (imageRotation+90) % 360; + invalidate(); + update(); +} +void Render::rotateLeft() +{ + if(imageRotation == 0) + imageRotation = 270; + else + imageRotation = imageRotation - 90; + invalidate(); + update(); +} + +//Actualiza el buffer, añadiendo las imágenes (vacías) necesarias para su posterior renderizado y +//eliminado aquellas que ya no sean necesarias. También libera los hilos (no estoy seguro de que sea responsabilidad suya) +//Calcula el número de nuevas páginas que hay que buferear y si debe hacerlo por la izquierda o la derecha (según sea el sentido de la lectura) +void Render::updateBuffer() +{ + //QMutexLocker locker(&mutex); + int windowSize = currentIndex - previousIndex; + if(doublePage) + { + windowSize = windowSize/2; + if(currentIndex == 0 && windowSize == 0 && previousIndex == 1) + windowSize = -1; + + } + if(windowSize > 0)//add pages to right pages and remove on the left + { + windowSize = qMin(windowSize,buffer.size()); + for(int i = 0; i < windowSize; i++) + { + //renders + PageRender * pr = pageRenders.front(); + pageRenders.pop_front(); + if(pr !=0) + { + if(pr->wait()) + delete pr; + } + pageRenders.push_back(0); + + //images + + if(buffer.front()!=0) + delete buffer.front(); + buffer.pop_front(); + buffer.push_back(new QImage()); + } + } + else //add pages to left pages and remove on the right + if(windowSize<0) + { + windowSize = -windowSize; + windowSize = qMin(windowSize,buffer.size()); + for(int i = 0; i < windowSize; i++) + { + //renders + PageRender * pr = pageRenders.back(); + pageRenders.pop_back(); + if(pr !=0) + { + if(pr->wait()) + delete pr; + } + pageRenders.push_front(0); + + //images + buffer.push_front(new QImage()); + QImage * p = buffer.back(); + if(p!=0) + delete p; + buffer.pop_back(); + } + } + previousIndex = currentIndex; +} + +void Render::fillBuffer() +{ + for(int i = 1; i <= qMax(numLeftPages,numRightPages); i++) + { + if ((currentIndex+i < comic->numPages()) && + buffer[currentPageBufferedIndex+i]->isNull() && + i <= numRightPages && + pageRenders[currentPageBufferedIndex+i]==0 && + pagesReady[currentIndex+1]) //preload next pages + { + pageRenders[currentPageBufferedIndex+i] = new PageRender(currentIndex+i,comic->getRawData()->at(currentIndex+i),buffer[currentPageBufferedIndex+i],imageRotation); + connect(pageRenders[currentPageBufferedIndex],SIGNAL(pageReady(int)),this,SLOT(prepareAvailablePage(int))); + pageRenders[currentPageBufferedIndex+i]->start(); + } + + if ((currentIndex-i > 0) && + buffer[currentPageBufferedIndex-i]->isNull() && + i <= numLeftPages && + pageRenders[currentPageBufferedIndex-i]==0 && + pagesReady[currentIndex-1]) //preload previous pages + { + pageRenders[currentPageBufferedIndex-i] = new PageRender(currentIndex-i,comic->getRawData()->at(currentIndex-i),buffer[currentPageBufferedIndex-i],imageRotation); + connect(pageRenders[currentPageBufferedIndex],SIGNAL(pageReady(int)),this,SLOT(prepareAvailablePage(int))); + pageRenders[currentPageBufferedIndex-i]->start(); + } + } +} + +void Render::fillBufferDoublePage() +{ + for(int i = 1; i <= qMax(numLeftPages,numRightPages); i++) + { + if ((currentIndex+2*i < comic->numPages()) && + buffer[currentPageBufferedIndex+i]->isNull() && + i <= numRightPages && + pageRenders[currentPageBufferedIndex+i]==0 && + (pagesReady[currentIndex+2*i] && pagesReady[qMin(currentIndex+(2*i)+1,(int)comic->numPages()-1)])) //preload next pages + { + if(currentIndex+(2*i)+1 > comic->numPages()-1) + pageRenders[currentPageBufferedIndex+i] = new DoublePageRender(currentIndex+2*i,comic->getRawData()->at(currentIndex+(2*i)),QByteArray(),buffer[currentPageBufferedIndex+i],imageRotation); + else + pageRenders[currentPageBufferedIndex+i] = new DoublePageRender(currentIndex+2*i,comic->getRawData()->at(currentIndex+(2*i)),comic->getRawData()->at(currentIndex+(2*i)+1),buffer[currentPageBufferedIndex+i],imageRotation); + connect(pageRenders[currentPageBufferedIndex],SIGNAL(pageReady(int)),this,SLOT(prepareAvailablePage(int))); + pageRenders[currentPageBufferedIndex+i]->start(); + } + + if ((currentIndex-2*i >= -1) && + buffer[currentPageBufferedIndex-i]->isNull() && + i <= numLeftPages && + pageRenders[currentPageBufferedIndex-i]==0 && + (pagesReady[qMax(currentIndex-2*i,0)] && pagesReady[qMin(currentIndex-(2*i)+1,(int)comic->numPages()-1)])) //preload previous pages + { + if(currentIndex-2*i == -1) + pageRenders[currentPageBufferedIndex-i] = new DoublePageRender(0,QByteArray(),comic->getRawData()->at(0),buffer[currentPageBufferedIndex-i],imageRotation); + else + pageRenders[currentPageBufferedIndex-i] = new DoublePageRender(currentIndex-2*i,comic->getRawData()->at(currentIndex-(2*i)),comic->getRawData()->at(currentIndex-(2*i)+1),buffer[currentPageBufferedIndex-i],imageRotation); + connect(pageRenders[currentPageBufferedIndex],SIGNAL(pageReady(int)),this,SLOT(prepareAvailablePage(int))); + pageRenders[currentPageBufferedIndex-i]->start(); + } + } +} + +//Método que debe ser llamado cada vez que la estructura del buffer se vuelve inconsistente con el modo de lectura actual. +//se terminan todos los hilos en ejecución y se libera la memoria (de hilos e imágenes) +void Render::invalidate() +{ + for(int i=0;iterminate(); + delete pageRenders[i]; + pageRenders[i] = 0; + } + } + + for(int i=0;inumPages())) + s += "-"+QString::number(currentIndex+2); + s += "/"+QString::number(comic->numPages()); + return s; +} + +void Render::setBookmark() +{ + comic->setBookmark(); +} + +void Render::removeBookmark() +{ + comic->removeBookmark(); +} + +void Render::save() +{ + comic->saveBookmarks(); +} diff --git a/YACReader/render.h b/YACReader/render.h new file mode 100644 index 00000000..d13d1fee --- /dev/null +++ b/YACReader/render.h @@ -0,0 +1,177 @@ + #ifndef RENDER_H +#define RENDER_H + +#include +#include +#include +#include +#include +#include +#include "comic.h" +//----------------------------------------------------------------------------- +// FILTERS +//----------------------------------------------------------------------------- + +#include + +class Comic; + +class ImageFilter { +public: + ImageFilter(){}; + virtual QImage setFilter(const QImage & image) = 0; +}; + +class MeanNoiseReductionFilter : public ImageFilter { +public: + enum NeighborghoodSize{SMALL=9, LARGE=25 }; + MeanNoiseReductionFilter(enum NeighborghoodSize ns = SMALL); + virtual QImage setFilter(const QImage & image); +private: + enum NeighborghoodSize neighborghoodSize; +}; + +class MedianNoiseReductionFilter : public ImageFilter { +public: + enum NeighborghoodSize{SMALL=9, LARGE=25 }; + MedianNoiseReductionFilter(enum NeighborghoodSize ns = SMALL); + virtual QImage setFilter(const QImage & image); +private: + enum NeighborghoodSize neighborghoodSize; +}; + +class BrightnessFilter : public ImageFilter { +public: + BrightnessFilter(int l=150); + virtual QImage setFilter(const QImage & image); +private: + int level; +}; + +class ContrastFilter : public ImageFilter { +public: + ContrastFilter(); + virtual QImage setFilter(const QImage & image); +private: + int level; +}; + +//----------------------------------------------------------------------------- +// RENDER +//----------------------------------------------------------------------------- + +class PageRender : public QThread +{ + Q_OBJECT +public: + PageRender(); + PageRender(int numPage, const QByteArray & rawData, QImage * page,unsigned int degrees=0, QVector filters = QVector()); + int getNumPage(){return numPage;}; + void setData(const QByteArray & rawData){data = rawData;}; + void setPage(QImage * p){page = p;}; + void setRotation(unsigned int d){degrees = d;}; + void setFilters(QVector f){filters = f;}; +private: + int numPage; + QByteArray data; + QImage * page; + unsigned int degrees; + QVector filters; + void run(); +signals: + void pageReady(int); + +}; +//----------------------------------------------------------------------------- +// RENDER +//----------------------------------------------------------------------------- + +class DoublePageRender : public PageRender +{ + Q_OBJECT +public: + DoublePageRender(int firstPage, const QByteArray & firstPageData,const QByteArray & secondPageData, QImage * page,unsigned int degrees=0, QVector filters = QVector()); +private: + int numPage; + QByteArray data; + QByteArray data2; + QImage * page; + unsigned int degrees; + QVector filters; + void run(); +signals: + void pageReady(int); + +}; + + +class Render : public QObject { +Q_OBJECT +public: + Render(); + +public slots: + void render(); + QPixmap * getCurrentPage(); + void goTo(int index); + void doublePageSwitch(); + void setRotation(int degrees); + void setComic(Comic * c); + void prepareAvailablePage(int page); + void update(); + void setNumPages(unsigned int numPages); + void pageRawDataReady(int page); + //--comic interface + void nextPage(); + void previousPage(); + void load(const QString & path); + void rotateRight(); + void rotateLeft(); + unsigned int getIndex(); + unsigned int numPages(); + bool hasLoadedComic(); + void updateBuffer(); + void fillBuffer(); + void fillBufferDoublePage(); + void invalidate(); + QString getCurrentPagesInformation(); + void setBookmark(); + void removeBookmark(); + void save(); + +signals: + void currentPageReady(); + void processingPage(); + void imagesLoaded(); + void imageLoaded(int index); + void imageLoaded(int index,const QByteArray & image); + void pageChanged(int index); + void numPages(unsigned int numPages); + void errorOpening(); + void currentPageIsBookmark(bool); + void bookmarksLoaded(const Bookmarks &); + +private: + Comic * comic; + bool doublePage; + int previousIndex; + int currentIndex; + //QPixmap * currentPage; + int currentPageBufferedIndex; + int numLeftPages; + int numRightPages; + QList pageRenders; + QList buffer; + void loadAll(); + void updateRightPages(); + void updateLeftPages(); + bool loadedComic; + QList pagesEmited; + QVector pagesReady; + int imageRotation; + QVector filters; + +}; + + +#endif // RENDER_H diff --git a/YACReader/shortcuts_dialog.cpp b/YACReader/shortcuts_dialog.cpp new file mode 100644 index 00000000..cc40b1e4 --- /dev/null +++ b/YACReader/shortcuts_dialog.cpp @@ -0,0 +1,74 @@ +#include "shortcuts_dialog.h" +#include +#include +#include +#include +#include +#include +#include + +ShortcutsDialog::ShortcutsDialog(QWidget * parent) + :QDialog(parent)//,Qt::FramelessWindowHint) +{ + setModal(true); + setWindowIcon(QIcon(":/images/shortcuts.png")); + setWindowTitle(tr("YACReader keyboard shortcuts")); + + QVBoxLayout * mainLayout = new QVBoxLayout; + + close = new QPushButton(tr("Close")); + connect(close,SIGNAL(clicked()),this,SLOT(close())); + + QHBoxLayout *bottomLayout = new QHBoxLayout; + bottomLayout->addStretch(); + bottomLayout->addWidget(close); + + QHBoxLayout * shortcutsLayout = new QHBoxLayout; + + shortcuts = new QTextEdit(); + QTextEdit * shortcuts2 = new QTextEdit(); + shortcuts->setFrameStyle(QFrame::NoFrame); + shortcuts2->setFrameStyle(QFrame::NoFrame); + //"

General functions:


O : Open comic
Esc : Exit

" + shortcuts->setReadOnly(true); + shortcuts2->setReadOnly(true); + shortcutsLayout->addWidget(shortcuts); + shortcutsLayout->addWidget(shortcuts2); + shortcutsLayout->setSpacing(0); + mainLayout->addLayout(shortcutsLayout); + mainLayout->addLayout(bottomLayout); + + QHBoxLayout *imgMainLayout = new QHBoxLayout; + QLabel * imgLabel = new QLabel(); + QPixmap p(":/images/shortcuts.png"); + imgLabel->setPixmap(p); + + QVBoxLayout * imgLayout = new QVBoxLayout; + imgLayout->addWidget(imgLabel); + imgLayout->addStretch(); + + imgMainLayout->addLayout(imgLayout); + imgMainLayout->addLayout(mainLayout); + + setLayout(imgMainLayout); + + setFixedSize(QSize(700,500)); + + QFile f(":/files/shortcuts.html"); + f.open(QIODevice::ReadOnly); + QTextStream txtS(&f); + QString content = txtS.readAll(); + f.close(); + + shortcuts->setHtml(content); + + QFile f2(":/files/shortcuts2.html"); + f2.open(QIODevice::ReadOnly); + QTextStream txtS2(&f2); + content = txtS2.readAll(); + f2.close(); + + shortcuts2->setHtml(content); + + setWindowTitle(tr("Keyboard Shortcuts")); +} diff --git a/YACReader/shortcuts_dialog.h b/YACReader/shortcuts_dialog.h new file mode 100644 index 00000000..8f1b66b6 --- /dev/null +++ b/YACReader/shortcuts_dialog.h @@ -0,0 +1,19 @@ +#ifndef SHORTCUTS_DIALOG_H +#define SHORTCUTS_DIALOG_H + +#include +#include +#include + +class ShortcutsDialog : public QDialog +{ +Q_OBJECT + public: + ShortcutsDialog(QWidget * parent = 0); + private: + QTextEdit * shortcuts; + QPushButton * close; + public slots: +}; + +#endif // SHORTCUTS_DIALOG_H diff --git a/YACReader/translator.cpp b/YACReader/translator.cpp new file mode 100644 index 00000000..fce5832d --- /dev/null +++ b/YACReader/translator.cpp @@ -0,0 +1,88 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "translator.h" + +YACReaderTranslator::YACReaderTranslator(QWidget * parent) +:QWidget(parent) +{ + this->setCursor(QCursor(Qt::ArrowCursor)); + this->setAutoFillBackground(true); + this->setBackgroundRole(QPalette::Window); + QPalette p(this->palette()); + p.setColor(QPalette::Window, QColor(96,96,96)); + this->setPalette(p); + + QVBoxLayout *layout = new QVBoxLayout(this); + QWebView * view = new QWebView(); + QFile f(":/files/translator.html"); + f.open(QIODevice::ReadOnly); + QTextStream txtS(&f); + QString contentHTML = txtS.readAll(); + view->setHtml(contentHTML); + view->page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks); + connect(view->page(),SIGNAL(linkClicked(QUrl)),this,SLOT(play(QUrl))); + + QHBoxLayout * buttonBar = new QHBoxLayout(); + QPushButton * close = new QPushButton(QIcon(QPixmap(":/images/close.png")),""); + close->setFlat(true); + buttonBar->addStretch(); + close->resize(18,18); + buttonBar->addWidget(close); + buttonBar->setMargin(0); + connect(close,SIGNAL(clicked()),this->parent(),SLOT(animateHideTranslator())); + + layout->setMargin(0); + layout->setSpacing(0); + + layout->addLayout(buttonBar); + layout->addWidget(view); + + resize(view->size().width()/1.60,view->size().height()); + + music = createPlayer(MusicCategory); + + show(); +} + +void YACReaderTranslator::play(const QUrl & url) +{ + MediaSource src(url); + src.setAutoDelete(true); + music->setCurrentSource(src); + music->play(); +} + +YACReaderTranslator::~YACReaderTranslator() +{ + delete music; +} + +void YACReaderTranslator::mousePressEvent(QMouseEvent *event) +{ + drag = true; + click = event->pos(); +} + +void YACReaderTranslator::mouseReleaseEvent(QMouseEvent *event) +{ + drag = false; +} + +void YACReaderTranslator::mouseMoveEvent(QMouseEvent * event) +{ + if(drag) + this->move(QPoint(mapToParent(event->pos())-click)); + +} + diff --git a/YACReader/translator.h b/YACReader/translator.h new file mode 100644 index 00000000..759ce22c --- /dev/null +++ b/YACReader/translator.h @@ -0,0 +1,32 @@ +#ifndef __TRANSLATOR_H +#define __TRANSLATOR_H + +class QUrl; +class QMouseEvent; +class QPoint; +#include +#include + +using namespace Phonon; + +class YACReaderTranslator : public QWidget +{ + Q_OBJECT + public: + YACReaderTranslator(QWidget * parent = 0); + ~YACReaderTranslator(); + + public slots: + void play(const QUrl & url); + +protected: + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void mouseMoveEvent ( QMouseEvent * event ); + bool drag; + QPoint click; +private: + MediaObject * music; +}; + +#endif \ No newline at end of file diff --git a/YACReader/viewer.cpp b/YACReader/viewer.cpp new file mode 100644 index 00000000..a107d394 --- /dev/null +++ b/YACReader/viewer.cpp @@ -0,0 +1,671 @@ +#include "viewer.h" +#include "magnifying_glass.h" +#include "configuration.h" +#include "magnifying_glass.h" +#include "goto_flow.h" +#include "bookmarks_dialog.h" +#include "render.h" +#include "goto_dialog.h" +#include "translator.h" + +#include +#include +#define STEPS 22 + + + +Viewer::Viewer(QWidget * parent) +:QScrollArea(parent), +currentPage(0), +magnifyingGlassShowed(false), +fullscreen(false), +information(false), +adjustToWidthRatio(1), +doublePage(false), +wheelStop(false), +direction(1), +restoreMagnifyingGlass(false), +drag(false) + +{ + translator = new YACReaderTranslator(this); + translator->hide(); + translatorAnimation = new QPropertyAnimation(translator,"pos"); + translatorAnimation->setDuration(150); + translatorXPos = -10000; + translator->move(-translator->width(),10); + //current comic page + content = new QLabel(this); + configureContent(tr("Press 'O' to open comic.")); + //scroll area configuration + setBackgroundRole(QPalette::Dark); + setWidget(content); + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setFrameStyle(QFrame::NoFrame); + setAlignment(Qt::AlignCenter); + + QPalette palette; + palette.setColor(backgroundRole(), Configuration::getConfiguration().getBackgroundColor()); + setPalette(palette); + //--------------------------------------- + mglass = new MagnifyingGlass(Configuration::getConfiguration().getMagnifyingGlassSize(),this); + mglass->hide(); + content->setMouseTracking(true); + setMouseTracking(true); + + informationLabel = new QLabel(this); + informationLabel->setAlignment(Qt::AlignVCenter|Qt::AlignHCenter); + informationLabel->setAutoFillBackground(true); + informationLabel->setFont(QFont("courier new", 12)); + informationLabel->hide(); + informationLabel->resize(100,25); + + showCursor(); + + goToDialog = new GoToDialog(this); + + goToFlow = new GoToFlow(this,Configuration::getConfiguration().getFlowType()); + goToFlow->hide(); + showGoToFlowAnimation = new QPropertyAnimation(goToFlow,"pos"); + showGoToFlowAnimation->setDuration(150); + + bd = new BookmarksDialog(this->parentWidget()); + + render = new Render(); + + scroller = new QTimer(this); + + hideCursorTimer = new QTimer(); + hideCursorTimer->setSingleShot(true); + + if(Configuration::getConfiguration().getDoublePage()) + doublePageSwitch(); + + createConnections(); + + hideCursorTimer->start(2500); + + setMouseTracking(true); +} + +void Viewer::createConnections() +{ + //magnifyingGlass (update mg after a background change + connect(this,SIGNAL(backgroundChanges()),mglass,SLOT(updateImage())); + + //goToDialog + connect(goToDialog,SIGNAL(goToPage(unsigned int)),this,SLOT(goTo(unsigned int))); + + //goToFlow goTo + connect(goToFlow,SIGNAL(goToPage(unsigned int)),this,SLOT(goTo(unsigned int))); + + //current time + QTimer * t = new QTimer(); + connect(t,SIGNAL(timeout()),this,SLOT(updateInformation())); + t->start(1000); + + //hide cursor + connect(hideCursorTimer,SIGNAL(timeout()),this,SLOT(hideCursor())); + + //bookmarks + connect(bd,SIGNAL(goToPage(unsigned int)),this,SLOT(goTo(unsigned int))); + + //render + connect(render,SIGNAL(errorOpening()),this,SLOT(resetContent())); + connect(render,SIGNAL(numPages(unsigned int)),goToFlow,SLOT(setNumSlides(unsigned int))); + connect(render,SIGNAL(numPages(unsigned int)),goToDialog,SLOT(setNumPages(unsigned int))); + connect(render,SIGNAL(imageLoaded(int,QByteArray)),goToFlow,SLOT(setImageReady(int,QByteArray))); + connect(render,SIGNAL(currentPageReady()),this,SLOT(updatePage())); + connect(render,SIGNAL(processingPage()),this,SLOT(setLoadingMessage())); + connect(render,SIGNAL(currentPageIsBookmark(bool)),this,SIGNAL(pageIsBookmark(bool))); + connect(render,SIGNAL(bookmarksLoaded(const Bookmarks &)),bd,SLOT(setBookmarks(const Bookmarks &))); +} + +void Viewer::open(QString pathFile) +{ + if(render->hasLoadedComic()) + save(); + //bd->setBookmarks(*bm); + + goToFlow->reset(); + render->load(pathFile); + render->update(); + + verticalScrollBar()->setSliderPosition(verticalScrollBar()->minimum()); +} + +void Viewer::next() +{ + direction = 1; + render->nextPage(); +} + +void Viewer::prev() +{ + direction = -1; + render->previousPage(); +} +void Viewer::showGoToDialog() +{ + goToDialog->show(); +} +void Viewer::goTo(unsigned int page) +{ + direction = 1; //in "go to" direction is always fordward + render->goTo(page-1); +} + +void Viewer::updatePage() +{ + QPixmap * previousPage = currentPage; + currentPage = render->getCurrentPage(); + content->setPixmap(*currentPage); + updateContentSize(); + updateVerticalScrollBar(); + emit backgroundChanges(); + emit(pageAvailable(true)); + //TODO -> update bookmark action + setFocus(Qt::ShortcutFocusReason); + delete previousPage; + if(restoreMagnifyingGlass) + { + restoreMagnifyingGlass = false; + showMagnifyingGlass(); + } + +} + +void Viewer::updateContentSize() +{ + //there is an image to resize + if(currentPage !=0 && !currentPage->isNull()) + { + if(Configuration::getConfiguration().getAdjustToFullSize()) + { + content->resize(currentPage->width(),currentPage->height()); + } + else + { + float aspectRatio = (float)currentPage->width()/currentPage->height(); + //Fit to width + if(Configuration::getConfiguration().getAdjustToWidth()) + { + adjustToWidthRatio = Configuration::getConfiguration().getFitToWidthRatio(); + if(static_cast(width()*adjustToWidthRatio/aspectRatio)(height()*aspectRatio)>width()) + content->resize(width(),static_cast(width()/aspectRatio)); + else + content->resize(static_cast(height()*aspectRatio),height()); + else + content->resize(width()*adjustToWidthRatio,static_cast(width()*adjustToWidthRatio/aspectRatio)); + } + //Fit to height or fullsize/custom size + else + { + if(static_cast(height()*aspectRatio)>width()) //page width exceeds window width + content->resize(width(),static_cast(width()/aspectRatio)); + else + content->resize(static_cast(height()*aspectRatio),height()); + } + } + emit backgroundChanges(); + } + content->update(); //TODO, it shouldn't be neccesary +} + +void Viewer::updateVerticalScrollBar() +{ + if(direction > 0) + verticalScrollBar()->setSliderPosition(verticalScrollBar()->minimum()); + else + verticalScrollBar()->setSliderPosition(verticalScrollBar()->maximum()); +} + +void Viewer::scrollDown() +{ + if(verticalScrollBar()->sliderPosition()==verticalScrollBar()->maximum()) + { + next(); + scroller->stop(); + } + else + { + int currentPos = verticalScrollBar()->sliderPosition(); + verticalScrollBar()->setSliderPosition(currentPos=currentPos+posByStep); + if((verticalScrollBar()->sliderPosition()==verticalScrollBar()->maximum()) + ||(verticalScrollBar()->sliderPosition()>=nextPos)) + scroller->stop(); + emit backgroundChanges(); + } +} + +void Viewer::scrollUp() +{ + if(verticalScrollBar()->sliderPosition()==verticalScrollBar()->minimum()) + { + prev(); + scroller->stop(); + } + else + { + int currentPos = verticalScrollBar()->sliderPosition(); + verticalScrollBar()->setSliderPosition(currentPos=currentPos-posByStep); + if((verticalScrollBar()->sliderPosition()==verticalScrollBar()->minimum()) + ||(verticalScrollBar()->sliderPosition()<=nextPos)) + scroller->stop(); + emit backgroundChanges(); + } +} + +void Viewer::keyPressEvent(QKeyEvent *event) +{ + if(render->hasLoadedComic()) + { + if(goToFlow->isVisible() && event->key()!=Qt::Key_S) + QCoreApplication::sendEvent(goToFlow,event); + else + switch (event->key()) + { + case Qt::Key_Space: + disconnect(scroller,SIGNAL(timeout()),this,0); + connect(scroller,SIGNAL(timeout()),this,SLOT(scrollDown())); + posByStep = height()/STEPS; + nextPos=verticalScrollBar()->sliderPosition()+static_cast((height()*0.80)); + scroller->start(20); + break; + case Qt::Key_B: + disconnect(scroller,SIGNAL(timeout()),this,0); + connect(scroller,SIGNAL(timeout()),this,SLOT(scrollUp())); + posByStep = height()/STEPS; + nextPos=verticalScrollBar()->sliderPosition()-static_cast((height()*0.80)); + scroller->start(20); + break; + case Qt::Key_S: + goToFlowSwitch(); + break; + case Qt::Key_T: + translatorSwitch(); + break; + case Qt::Key_Down: + /*if(verticalScrollBar()->sliderPosition()==verticalScrollBar()->maximum()) + next(); + else*/ + QAbstractScrollArea::keyPressEvent(event); + emit backgroundChanges(); + break; + case Qt::Key_Up: + /*if(verticalScrollBar()->sliderPosition()==verticalScrollBar()->minimum()) + prev(); + else*/ + QAbstractScrollArea::keyPressEvent(event); + emit backgroundChanges(); + break; + case Qt::Key_Home: + goTo(1); + break; + case Qt::Key_End: + goTo(this->render->numPages()); + break; + default: + QAbstractScrollArea::keyPressEvent(event); + break; + } + if(mglass->isVisible()) + switch(event->key()) + { + case Qt::Key_Plus: case Qt::Key_Minus: case Qt::Key_Underscore: case Qt::Key_Asterisk: + QCoreApplication::sendEvent(mglass,event); + } + } +} + +void Viewer::wheelEvent(QWheelEvent * event) +{ + if(render->hasLoadedComic()) + { + if((event->delta()<0)&&(verticalScrollBar()->sliderPosition()==verticalScrollBar()->maximum())) + { + if(wheelStop) + { + next(); + event->accept(); + wheelStop = false; + return; + } + else + wheelStop = true; + } + else + if((event->delta()>0)&&(verticalScrollBar()->sliderPosition()==verticalScrollBar()->minimum())) + { + if(wheelStop) + { + prev(); + event->accept(); + wheelStop = false; + return; + } + else + wheelStop = true; + } + + QAbstractScrollArea::wheelEvent(event); + emit backgroundChanges(); + } +} + +void Viewer::resizeEvent(QResizeEvent * event) +{ + updateContentSize(); + goToFlow->move(QPoint((width()-goToFlow->width())/2,height()-goToFlow->height())); + informationLabel->move(QPoint((width()-informationLabel->width())/2,0)); + QScrollArea::resizeEvent(event); +} + +void Viewer::mouseMoveEvent(QMouseEvent * event) +{ + showCursor(); + hideCursorTimer->start(2500); + + if(magnifyingGlassShowed) + mglass->move(static_cast(event->x()-float(mglass->width())/2),static_cast(event->y()-float(mglass->height())/2)); + + if(render->hasLoadedComic()) + { + if(showGoToFlowAnimation->state()!=QPropertyAnimation::Running) + { + if(goToFlow->isVisible()) + { + animateHideGoToFlow(); + //goToFlow->hide(); + } + else + { + int umbral = (width()-goToFlow->width())/2; + if((event->y()>height()-15)&&(event->x()>umbral)&&(event->x()stop(); + } + } + } + + if(drag) + { + int currentPosY = verticalScrollBar()->sliderPosition(); + int currentPosX = horizontalScrollBar()->sliderPosition(); + verticalScrollBar()->setSliderPosition(currentPosY=currentPosY+(yDragOrigin-event->y())); + horizontalScrollBar()->setSliderPosition(currentPosX=currentPosX+(xDragOrigin-event->x())); + yDragOrigin = event->y(); + xDragOrigin = event->x(); + } + } + + +} + +const QPixmap * Viewer::pixmap() +{ + return content->pixmap(); +} + +void Viewer::magnifyingGlassSwitch() +{ + magnifyingGlassShowed?hideMagnifyingGlass():showMagnifyingGlass(); +} + +void Viewer::showMagnifyingGlass() +{ + if(render->hasLoadedComic()) + { + QPoint p = QPoint(cursor().pos().x(),cursor().pos().y()); + p = this->parentWidget()->mapFromGlobal(p); + mglass->move(static_cast(p.x()-float(mglass->width())/2) + ,static_cast(p.y()-float(mglass->height())/2)); + mglass->show(); + mglass->updateImage(mglass->x()+mglass->width()/2,mglass->y()+mglass->height()/2); + magnifyingGlassShowed = true; + } +} + +void Viewer::hideMagnifyingGlass() +{ + mglass->hide(); + magnifyingGlassShowed = false; +} + +void Viewer::informationSwitch() +{ + information?informationLabel->hide():informationLabel->show(); + informationLabel->move(QPoint((width()-informationLabel->width())/2,0)); + information=!information; + //TODO it shouldn't be neccesary + informationLabel->adjustSize(); + informationLabel->update(); +} + +void Viewer::updateInformation() +{ + if(render->hasLoadedComic()) + { + informationLabel->setText(render->getCurrentPagesInformation()+" - "+QTime::currentTime().toString("HH:mm")); + informationLabel->adjustSize(); + informationLabel->update(); //TODO it shouldn't be neccesary + } +} + +void Viewer::goToFlowSwitch() +{ + goToFlow->isVisible()?animateHideGoToFlow():showGoToFlow(); +} + +void Viewer::translatorSwitch() +{ + translator->isVisible()?animateHideTranslator():animateShowTranslator(); +} + +void Viewer::showGoToFlow() +{ + if(render->hasLoadedComic()) + { + animateShowGoToFlow(); + } +} + +void Viewer::animateShowGoToFlow() +{ + if(goToFlow->isHidden() && showGoToFlowAnimation->state()!=QPropertyAnimation::Running) + { + disconnect(showGoToFlowAnimation,SIGNAL(finished()),goToFlow,SLOT(hide())); + connect(showGoToFlowAnimation,SIGNAL(finished()),this,SLOT(moveCursoToGoToFlow())); + showGoToFlowAnimation->setStartValue(QPoint((width()-goToFlow->width())/2,height()-10)); + showGoToFlowAnimation->setEndValue(QPoint((width()-goToFlow->width())/2,height()-goToFlow->height())); + showGoToFlowAnimation->start(); + goToFlow->centerSlide(render->getIndex()); + goToFlow->setPageNumber(render->getIndex()); + goToFlow->show(); + goToFlow->setFocus(Qt::OtherFocusReason); + } +} + +void Viewer::animateHideGoToFlow() +{ + if(goToFlow->isVisible() && showGoToFlowAnimation->state()!=QPropertyAnimation::Running) + { + connect(showGoToFlowAnimation,SIGNAL(finished()),goToFlow,SLOT(hide())); + disconnect(showGoToFlowAnimation,SIGNAL(finished()),this,SLOT(moveCursoToGoToFlow())); + showGoToFlowAnimation->setStartValue(QPoint((width()-goToFlow->width())/2,height()-goToFlow->height())); + showGoToFlowAnimation->setEndValue(QPoint((width()-goToFlow->width())/2,height())); + showGoToFlowAnimation->start(); + goToFlow->centerSlide(render->getIndex()); + goToFlow->setPageNumber(render->getIndex()); + this->setFocus(Qt::OtherFocusReason); + } +} + +void Viewer::moveCursoToGoToFlow() +{ + //Move cursor to goToFlow widget on show (this avoid hide when mouse is moved) + int y = goToFlow->pos().y(); + int x1 = goToFlow->pos().x(); + int x2 = x1 + goToFlow->width(); + QPoint cursorPos = mapFromGlobal(cursor().pos()); + int cursorX = cursorPos.x(); + int cursorY = cursorPos.y(); + + if(cursorY <= y) + cursorY = y + 10; + if(cursorX <= x1) + cursorX = x1 + 10; + if(cursorX >= x2) + cursorX = x2 - 10; + cursor().setPos(mapToGlobal(QPoint(cursorX,cursorY))); + hideCursorTimer->stop(); + showCursor(); +} + +void Viewer::rotateLeft() +{ + render->rotateLeft(); +} +void Viewer::rotateRight() +{ + render->rotateRight(); +} + +//TODO +void Viewer::setBookmark(bool set) +{ + render->setBookmark(); + if(set) //add bookmark + { + render->setBookmark(); + } + else //remove bookmark + { + render->removeBookmark(); + } +} + +void Viewer::save () +{ + if(render->hasLoadedComic()) + render->save(); +} + +void Viewer::doublePageSwitch() +{ + doublePage = !doublePage; + render->doublePageSwitch(); + Configuration::getConfiguration().setDoublePage(doublePage); +} + +void Viewer::resetContent() +{ + configureContent(tr("Press 'O' to open comic.")); + goToFlow->reset(); + emit reset(); +} + +void Viewer::setLoadingMessage() +{ + if(magnifyingGlassShowed) + { + hideMagnifyingGlass(); + restoreMagnifyingGlass = true; + } + emit(pageAvailable(false)); + configureContent(tr("Loading...please wait!")); +} + +void Viewer::configureContent(QString msg) +{ + content->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); + content->setScaledContents(true); + content->setAlignment(Qt::AlignTop|Qt::AlignHCenter); + content->setText(msg); + content->setFont(QFont("courier new", 12)); + content->adjustSize(); + setFocus(Qt::ShortcutFocusReason); + //emit showingText(); +} + +void Viewer::hideCursor() +{ + setCursor(Qt::BlankCursor); +} +void Viewer::showCursor() +{ + if(drag) + setCursor(Qt::ClosedHandCursor); + else + setCursor(Qt::OpenHandCursor); +} + +void Viewer::updateOptions() +{ + + goToFlow->setFlowType(Configuration::getConfiguration().getFlowType()); + updateBackgroundColor(Configuration::getConfiguration().getBackgroundColor()); + updateContentSize(); + //goToFlow->updateSize(); +} + +void Viewer::updateBackgroundColor(const QColor & color) +{ + QPalette palette; + palette.setColor(backgroundRole(), color); + setPalette(palette); +} + +void Viewer::animateShowTranslator() +{ + if(translator->isHidden() && translatorAnimation->state()!=QPropertyAnimation::Running) + { + disconnect(translatorAnimation,SIGNAL(finished()),translator,SLOT(hide())); + if(translatorXPos == -10000) + translatorXPos = (width()-translator->width())/2; + int x = qMax(0,qMin(translatorXPos,width()-translator->width())); + if(translator->pos().x()<0) + { + translatorAnimation->setStartValue(QPoint(-translator->width(),translator->pos().y())); + } + else + { + translatorAnimation->setStartValue(QPoint(width()+translator->width(),translator->pos().y())); + } + translatorAnimation->setEndValue(QPoint(x,translator->pos().y())); + translatorAnimation->start(); + translator->show(); + translator->setFocus(Qt::OtherFocusReason); + } +} +void Viewer::animateHideTranslator() +{ + if(translator->isVisible() && translatorAnimation->state()!=QPropertyAnimation::Running) + { + connect(translatorAnimation,SIGNAL(finished()),translator,SLOT(hide())); + translatorAnimation->setStartValue(QPoint(translatorXPos = translator->pos().x(),translator->pos().y())); + if((translator->width()/2)+translator->pos().x() <= width()/2) + translatorAnimation->setEndValue(QPoint(-translator->width(),translator->pos().y())); + else + translatorAnimation->setEndValue(QPoint(width()+translator->width(),translator->pos().y())); + translatorAnimation->start(); + this->setFocus(Qt::OtherFocusReason); + } +} + +void Viewer::mousePressEvent ( QMouseEvent * event ) +{ + drag = true; + yDragOrigin = event->y(); + xDragOrigin = event->x(); + setCursor(Qt::ClosedHandCursor); +} +void Viewer::mouseReleaseEvent ( QMouseEvent * event ) +{ + drag = false; + setCursor(Qt::OpenHandCursor); +} \ No newline at end of file diff --git a/YACReader/viewer.h b/YACReader/viewer.h new file mode 100644 index 00000000..6da04035 --- /dev/null +++ b/YACReader/viewer.h @@ -0,0 +1,131 @@ +#ifndef __VIEWER_H +#define __VIEWER_H + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +class Comic; +class MagnifyingGlass; +class GoToFlow; +class BookmarksDialog; +class Render; +class GoToDialog; +class YACReaderTranslator; + + class Viewer : public QScrollArea + { + Q_OBJECT + public: + bool fullscreen; //TODO, change by the right use of windowState(); + public slots: + void open(QString pathFile); + void prev(); + void next(); + void showGoToDialog(); + void goTo(unsigned int page); + void updatePage(); + void updateContentSize(); + void updateVerticalScrollBar(); + void updateOptions(); + void scrollDown(); + void scrollUp(); + void magnifyingGlassSwitch(); + void showMagnifyingGlass(); + void hideMagnifyingGlass(); + void informationSwitch(); + void updateInformation(); + void goToFlowSwitch(); + void showGoToFlow(); + void moveCursoToGoToFlow(); + void animateShowGoToFlow(); + void animateHideGoToFlow(); + void rotateLeft(); + void rotateRight(); + bool magnifyingGlassIsVisible() {return magnifyingGlassShowed;} + void setBookmark(bool); + void save(); + void doublePageSwitch(); + void resetContent(); + void setLoadingMessage(); + void configureContent(QString msg); + void hideCursor(); + void showCursor(); + void createConnections(); + void translatorSwitch(); + void animateShowTranslator(); + void animateHideTranslator(); +virtual void mousePressEvent ( QMouseEvent * event ); +virtual void mouseReleaseEvent ( QMouseEvent * event ); + void updateBackgroundColor(const QColor & color); + + private: + bool information; + bool doublePage; + QLabel * informationLabel; + QTimer * scroller; + int posByStep; + int nextPos; + GoToFlow * goToFlow; + QPropertyAnimation * showGoToFlowAnimation; + GoToDialog * goToDialog; + //!Image properties + float adjustToWidthRatio; + //! Comic + //Comic * comic; + int index; + QPixmap *currentPage; + BookmarksDialog * bd; + bool wheelStop; + Render * render; + QTimer * hideCursorTimer; + int direction; + bool drag; + + //!Widgets + QLabel *content; + + YACReaderTranslator * translator; + int translatorXPos; + QPropertyAnimation * translatorAnimation; + + int yDragOrigin; + int xDragOrigin; + private: + //!Magnifying glass + MagnifyingGlass *mglass; + bool magnifyingGlassShowed; + bool restoreMagnifyingGlass; + + //! Manejadores de evento: + void keyPressEvent(QKeyEvent * event); + void resizeEvent(QResizeEvent * event); + void wheelEvent(QWheelEvent * event); + void mouseMoveEvent(QMouseEvent * event); + + public: + Viewer(QWidget * parent = 0); + void toggleFullScreen(); + const QPixmap * pixmap(); + //Comic * getComic(){return comic;} + const BookmarksDialog * getBookmarksDialog(){return bd;} + signals: + void backgroundChanges(); + void pageAvailable(bool); + void pageIsBookmark(bool); + void reset(); + }; + +#endif diff --git a/YACReader/yacreader_es.qm b/YACReader/yacreader_es.qm new file mode 100644 index 0000000000000000000000000000000000000000..acfc1ae4982a08683571e62be9029a68906d1085 GIT binary patch literal 9964 zcmdT~e~cVe9e=yM+xxwH{dFyEDX&L+J=$_WQJT~uz3$QL$z8AMoi;5gVQz1BcY1p> z%gpYrcNG-1L4g3lQVA+*5ThtD@;hovVl)P&gg=lF3`S!7K?Df`iIQmjeBYaSGrKpl zTaEwNOZV;0zVGj!@B4PwGt;Yo`Sw@uJG)`svp0V8^lN(=_`JF%u2>uAC{ z#8~H1tiy~YS7RMvta~HYQLN8k9mD!NtmBL=y%+02##Y>c^$24Z-prcb1kSdCTvKs=>3T8U-<*ZTGz@oxtm>o^jC~sw3^Md-N4wz{p{9{JjU3vSJ_h!u4k<4bnI%9 z;i3;>$2a{IaKo|VKkUZ(SnRPwz}Gt%`|S;D8C$hGzVYe%8RMUi7l%$lFTamho?Hoe z9$vD4&6A9+nOJhK(+oMzE;)VZeSCji)1hV^_qXFI?4{=CSD#=kwJFj4(3imPNTRpti_q(6;?hU2 zXKcf5iLuL;0Pfnvp_Tg?>$x&<^r`QF-c5<)2|QoH5;r^dK#otj>$$|q)7LZHgFD7r@`wTAzRGaoAn7;$blc%qKgZbW zf3(e<1HD9VyLA})SiYzI4*MnGG1{N`0D4^WLI>+~AlDlmv8Qgq^GzMM|LI-8UET5A z)N<_qM#tYDYJyykcNX5fn6V3To%WgMAkW>M50_!r<_9{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iF%Un^6w+{BluqkL>#YIx_vVRCR-qX-%E@ zAJ0s~^V^o%<|tbK%5j$ZgITLl0~KdS6kO~`q(|XsHwkCBrb8>@G>l;3rSN2z96F{NeCv!^VY?B`anv z=5zR`;P#-p!$#KyPZjll&@#<6iW%Wl>e-j7#2$ z1WS&uwdB~mJh(Z)FDFv97^`&FGY*v%v|u9X6MssLt3S~nQ2=ZPi`F#7EW!HJFjlx8# z48=>vYk*f7Z&B4!%3bGY&G5D=l=e>1X)O9(hA^qT=+nhmj7mJEHvcMdgQDEy|8}D& zuHo>b0i(2m + + + + BookmarksDialog + + + Lastest Page + Última página + + + + Close + Cerrar + + + + Click on any image to go to the bookmark + Pulsa en cualquier imagen para ir al marcador + + + + + Loading... + Cargando... + + + + Comic + + + No images found + No se han encontrado imágenes + + + + There are not images on the selected folder + No hay imágenes en el directorio seleccionado + + + + File error + Error en archivo + + + + File not found or not images in file + Archivo no encontrado o no hay imágenes en él + + + + 7z not found + 7z no encontrado + + + + 7z wasn't found in your PATH. + 7z no se ha encontrado en el PATH. + + + + 7z crashed + 7z falló + + + + 7z crashed. + 7z falló. + + + + 7z reading + 7z leyendo + + + + problem reading from 7z + Problema leyendo desde 7z + + + + 7z problem + 7z problema + + + + Unknown error 7z + Error desconocido 7z + + + + Configuration + + + Saving config file.... + Guardando el archivo de configuración... + + + + There was a problem saving YACReader configuration. Please, check if you have enough permissions in the YACReader root folder. + Hubo un problema al guardar la configuración de YACReader. Por favor, comprueba si tienes suficientes permisos en el directorio raíz de YACReader. + + + + GoToDialog + + + Page : + Página : + + + + Go To + Ir a + + + + Cancel + Cancelar + + + + + Total pages : + Páginas totales: + + + + Go to... + Ir a... + + + + GoToFlow + + + Page : + Página: + + + Total pages : + Page: + + + + HelpAboutDialog + + + About + Acerca de + + + + Help + Ayuda + + + + MainWindowViewer + + + &Open + &Abrir + + + + O + O + + + + Open a comic + Abrir cómic + + + + Open Folder + Abrir carpeta + + + + Ctrl+O + Ctrl+O + + + + Open image folder + Open images in a folder + Abrir carpeta de imágenes + + + + Save + Guardar + + + + + Save current page + Guardar la página actual + + + + Previous Comic + Cómic anterior + + + + Open previous comic + Abrir cómic anterior + + + + Next Comic + Siguiente Cómic + + + + Open next comic + Abrir siguiente cómic + + + + &Previous + A&nterior + + + + Go to previous page + Ir a la página anterior + + + + &Next + Siguie&nte + + + + Go to next page + Ir a la página siguiente + + + + Fit Width + Ajustar anchura + + + + A + A + + + + Fit image to ... + Ajustar imagen a... + + + + Rotate image to the left + Rotar imagen a la izquierda + + + + L + L + + + + Rotate image to the right + Rotar imagen a la derecha + + + + R + R + + + + Double page mode + Modo a doble página + + + + Switch to double page mode + Cambiar a modo de doble página + + + + D + D + + + + Go To + Ir a + + + + G + G + + + + Go to page ... + Ir a página... + + + + Options + Opciones + + + + C + C + + + + YACReader options + Opciones de YACReader + + + + Help + Ayuda + + + + Help, About YACReader + Ayuda, Sobre YACReader + + + + Magnifying glass + Lupa + + + + Switch Magnifying glass + Lupa On/Off + + + + Z + Z + + + + Set bookmark + Añadir marcador + + + + Set a bookmark on the current page + Añadir un marcador en la página actual + + + + Show bookmarks + Mostrar marcadores + + + + Show the bookmarks of the current comic + Mostrar los marcadores del cómic actual + + + + M + M + + + + Show keyboard shortcuts + Mostrar atajos de teclado + + + + Show Info + Mostrar información + + + + I + I + + + + Close + Cerrar + + + + Show Dictionary + Mostrar diccionario + + + + Always on top + Siempre visible + + + + Show full size + Mostrar a tamaño original + + + + &File + &Archivo + + + + Open Comic + Abrir cómic + + + + Comic files (*.cbr *.cbz *.rar *.zip *.tar *.arj) + Archivos de cómic (*.cbr *.cbz *.rar *.zip *.tar *.arj) + + + + Open folder + Abrir carpeta + + + + Image files (*.jpg) + Archivos de imagen (*.jpg) + + + + There is a new version avaliable + Hay una nueva versión disponible + + + + Do you want to download the new version? + ¿Desea descargar la nueva versión? + + + + Saving error log file.... + Guardando el archivo de log... + + + + There was a problem saving YACReader error log file. Please, check if you have enough permissions in the YACReader root folder. + Hubo un problema al guardar el archivo de log de YACReader. Por favor, comprueba si tienes suficientes permisos en el directorio raíz de YACReader. + + + + OptionsDialog + + + "Go to flow" size + Tamaño de "Go to flow" + + + + My comics path + Ruta a mis cómics + + + + Save + Guardar + + + + Cancel + Cancelar + + + + How to show pages in GoToFlow: + ¿Cómo deseas que se muestren las páginas en "Go To Flow": + + + + CoverFlow look + + + + + Stripe look + + + + + Overlapped Stripe look + Overlaped Stripe look + + + + + Page width stretch + Ajuste en anchura de la página + + + + Background color + Color de fondo + + + + Choose + Elegir + + + + Restart is needed + Es necesario reiniciar + + + + Comics directory + Directorio de cómics + + + + QPushButton + + Hello world! + Hola mundo! + + + + ShortcutsDialog + + + YACReader keyboard shortcuts + Atajos de teclado de YACReader + + + + Close + Cerrar + + + + Keyboard Shortcuts + Atajos de teclado + + + + Viewer + + + + Press 'O' to open comic. + Pulsa 'O' para abrir un fichero. + + + Show Info + Mostrar información + + + I + I + + + + Loading...please wait! + Cargando...espere, por favor! + + + diff --git a/YACReader/yacreader_fr.ts b/YACReader/yacreader_fr.ts new file mode 100644 index 00000000..fd42ce28 --- /dev/null +++ b/YACReader/yacreader_fr.ts @@ -0,0 +1,548 @@ + + + + + BookmarksDialog + + + Lastest Page + + + + + Close + + + + + Click on any image to go to the bookmark + + + + + + Loading... + + + + + Comic + + + No images found + + + + + There are not images on the selected folder + + + + + File error + + + + + File not found or not images in file + + + + + 7z not found + + + + + 7z wasn't found in your PATH. + + + + + 7z crashed + + + + + 7z crashed. + + + + + 7z reading + + + + + problem reading from 7z + + + + + 7z problem + + + + + Unknown error 7z + + + + + Configuration + + + Saving config file.... + + + + + There was a problem saving YACReader configuration. Please, check if you have enough permissions in the YACReader root folder. + + + + + GoToDialog + + + Page : + + + + + Go To + + + + + Cancel + + + + + + Total pages : + + + + + Go to... + + + + + GoToFlow + + + Page : + + + + + HelpAboutDialog + + + About + + + + + Help + + + + + MainWindowViewer + + + &Open + + + + + O + + + + + Open a comic + + + + + Open Folder + + + + + Ctrl+O + + + + + Open image folder + + + + + Save + + + + + + Save current page + + + + + Previous Comic + + + + + Open previous comic + + + + + Next Comic + + + + + Open next comic + + + + + &Previous + + + + + Go to previous page + + + + + &Next + + + + + Go to next page + + + + + Fit Width + + + + + A + + + + + Fit image to ... + + + + + Rotate image to the left + + + + + L + + + + + Rotate image to the right + + + + + R + + + + + Double page mode + + + + + Switch to double page mode + + + + + D + + + + + Go To + + + + + G + + + + + Go to page ... + + + + + Options + + + + + C + + + + + YACReader options + + + + + Help + + + + + Help, About YACReader + + + + + Magnifying glass + + + + + Switch Magnifying glass + + + + + Z + + + + + Set bookmark + + + + + Set a bookmark on the current page + + + + + Show bookmarks + + + + + Show the bookmarks of the current comic + + + + + M + + + + + Show keyboard shortcuts + + + + + Show Info + + + + + I + + + + + Close + + + + + Show Dictionary + + + + + Always on top + + + + + Show full size + + + + + &File + + + + + Open Comic + + + + + Comic files (*.cbr *.cbz *.rar *.zip *.tar *.arj) + + + + + Open folder + + + + + Image files (*.jpg) + + + + + There is a new version avaliable + + + + + Do you want to download the new version? + + + + + Saving error log file.... + + + + + There was a problem saving YACReader error log file. Please, check if you have enough permissions in the YACReader root folder. + + + + + OptionsDialog + + + "Go to flow" size + + + + + My comics path + + + + + Save + + + + + Cancel + + + + + How to show pages in GoToFlow: + + + + + CoverFlow look + + + + + Stripe look + + + + + Overlapped Stripe look + + + + + Page width stretch + + + + + Background color + + + + + Choose + + + + + Restart is needed + + + + + Comics directory + + + + + ShortcutsDialog + + + YACReader keyboard shortcuts + + + + + Close + + + + + Keyboard Shortcuts + + + + + Viewer + + + + Press 'O' to open comic. + + + + + Loading...please wait! + + + + diff --git a/YACReaderLibrary/YACReaderLibrary.pro b/YACReaderLibrary/YACReaderLibrary.pro new file mode 100644 index 00000000..1963d1ef --- /dev/null +++ b/YACReaderLibrary/YACReaderLibrary.pro @@ -0,0 +1,82 @@ +###################################################################### +# Automatically generated by qmake (2.01a) dom 12. oct 20:47:48 2008 +###################################################################### + +TEMPLATE = app +TARGET = +DEPENDPATH += . +INCLUDEPATH += . +INCLUDEPATH += ../common \ + ./server \ + ./db +CONFIG += release +CONFIG -= flat +QT += sql network + +# Input +HEADERS += comic_flow.h \ + create_library_dialog.h \ + library_creator.h \ + library_window.h \ + ../common/pictureflow.h \ + add_library_dialog.h \ + ../common/custom_widgets.h \ + rename_library_dialog.h \ + properties_dialog.h \ + options_dialog.h \ + export_library_dialog.h \ + import_library_dialog.h \ + package_manager.h \ + ../common/qnaturalsorting.h \ + bundle_creator.h \ + ./db/data_base_management.h \ + ./db/treeitem.h \ + ./db/treemodel.h \ + ./db/tablemodel.h \ + ./db/tableitem.h \ + ./db/comic.h \ + ./db/folder.h \ + ./db/library_item.h \ + export_comics_info_dialog.h \ + import_comics_info_dialog.h \ + ../common/check_new_version.h + +SOURCES += comic_flow.cpp \ + create_library_dialog.cpp \ + library_creator.cpp \ + library_window.cpp \ + main.cpp \ + ../common/pictureflow.cpp \ + add_library_dialog.cpp \ + ../common/custom_widgets.cpp \ + rename_library_dialog.cpp \ + properties_dialog.cpp \ + options_dialog.cpp \ + export_library_dialog.cpp \ + import_library_dialog.cpp \ + package_manager.cpp \ + ../common/qnaturalsorting.cpp \ + bundle_creator.cpp \ + ./db/data_base_management.cpp \ + ./db/treeitem.cpp \ + ./db/treemodel.cpp \ + ./db/tablemodel.cpp \ + ./db/tableitem.cpp \ + ./db/comic.cpp \ + ./db/folder.cpp \ + ./db/library_item.cpp \ + export_comics_info_dialog.cpp \ + import_comics_info_dialog.cpp \ + ../common/check_new_version.cpp + +include(./server/server.pri) + + +RESOURCES += images.qrc files.qrc +RC_FILE = icon.rc + +TRANSLATIONS = yacreaderlibrary_es.ts + +Release:DESTDIR = ../release +Debug:DESTDIR = ../debug + diff --git a/YACReaderLibrary/add_library_dialog.cpp b/YACReaderLibrary/add_library_dialog.cpp new file mode 100644 index 00000000..e94b4691 --- /dev/null +++ b/YACReaderLibrary/add_library_dialog.cpp @@ -0,0 +1,91 @@ +#include "add_library_dialog.h" + +#include +#include +#include +#include + + +AddLibraryDialog::AddLibraryDialog(QWidget * parent) +:QDialog(parent) +{ + setupUI(); +} + +void AddLibraryDialog::setupUI() +{ + textLabel = new QLabel(tr("Comics folder : ")); + path = new QLineEdit; + textLabel->setBuddy(path); + + nameLabel = new QLabel(tr("Library Name : ")); + nameEdit = new QLineEdit; + nameLabel->setBuddy(nameEdit); + + accept = new QPushButton(tr("Add")); + accept->setDisabled(true); + connect(accept,SIGNAL(clicked()),this,SLOT(add())); + + cancel = new QPushButton(tr("Cancel")); + connect(cancel,SIGNAL(clicked()),this,SLOT(close())); + + find = new QPushButton(QIcon(":/images/comicFolder.png"),""); + connect(find,SIGNAL(clicked()),this,SLOT(findPath())); + + QGridLayout * content = new QGridLayout; + + content->addWidget(nameLabel,0,0); + content->addWidget(nameEdit,0,1); + + content->addWidget(textLabel,1,0); + content->addWidget(path,1,1); + content->addWidget(find,1,2); + content->setColumnStretch(2,0); + + QHBoxLayout *bottomLayout = new QHBoxLayout; + bottomLayout->addStretch(); + bottomLayout->addWidget(accept); + bottomLayout->addWidget(cancel); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addLayout(content); + mainLayout->addStretch(); + mainLayout->addLayout(bottomLayout); + + QHBoxLayout * imgMainLayout = new QHBoxLayout; + QLabel * imgLabel = new QLabel(this); + QPixmap p(":/images/openLibrary.png"); + imgLabel->setPixmap(p); + imgMainLayout->addWidget(imgLabel);//,0,Qt::AlignTop); + imgMainLayout->addLayout(mainLayout); + + setLayout(imgMainLayout); + + setModal(true); + setWindowTitle(tr("Add an existing library")); +} + +void AddLibraryDialog::add() +{ + //accept->setEnabled(false); + emit(addLibrary(QDir::cleanPath(path->text()),nameEdit->text())); + close(); +} + +void AddLibraryDialog::findPath() +{ + QString s = QFileDialog::getExistingDirectory(0,"Comics directory","."); + if(!s.isEmpty()) + { + path->setText(s); + accept->setEnabled(true); + } +} + +void AddLibraryDialog::close() +{ + path->clear(); + nameEdit->clear(); + accept->setEnabled(false); + QDialog::close(); +} \ No newline at end of file diff --git a/YACReaderLibrary/add_library_dialog.h b/YACReaderLibrary/add_library_dialog.h new file mode 100644 index 00000000..f6274270 --- /dev/null +++ b/YACReaderLibrary/add_library_dialog.h @@ -0,0 +1,33 @@ +#ifndef __ADD_LIBRARY_DIALOG_H +#define __ADD_LIBRARY_DIALOG_H + +#include +#include +#include +#include +#include + + class AddLibraryDialog : public QDialog + { + Q_OBJECT + public: + AddLibraryDialog(QWidget * parent = 0); + private: + QLabel * nameLabel; + QLabel * textLabel; + QLineEdit * path; + QLineEdit * nameEdit; + QPushButton * find; + QPushButton * accept; + QPushButton * cancel; + void setupUI(); + public slots: + void add(); + void findPath(); + void close(); + signals: + void addLibrary(QString target, QString name); + }; + +#endif + diff --git a/YACReaderLibrary/bundle_creator.cpp b/YACReaderLibrary/bundle_creator.cpp new file mode 100644 index 00000000..8ea6eef2 --- /dev/null +++ b/YACReaderLibrary/bundle_creator.cpp @@ -0,0 +1,13 @@ +#include "bundle_creator.h" + + +BundleCreator::BundleCreator(void) + :QObject() +{ + +} + + +BundleCreator::~BundleCreator(void) +{ +} diff --git a/YACReaderLibrary/bundle_creator.h b/YACReaderLibrary/bundle_creator.h new file mode 100644 index 00000000..ff4dbd08 --- /dev/null +++ b/YACReaderLibrary/bundle_creator.h @@ -0,0 +1,14 @@ +#ifndef __BUNDLE_CREATOR_H +#define __BUNDLE_CREATOR_H + +#include + +class BundleCreator : public QObject +{ +Q_OBJECT +public: + BundleCreator(void); + ~BundleCreator(void); +}; + +#endif \ No newline at end of file diff --git a/YACReaderLibrary/comic_flow.cpp b/YACReaderLibrary/comic_flow.cpp new file mode 100644 index 00000000..ddc708aa --- /dev/null +++ b/YACReaderLibrary/comic_flow.cpp @@ -0,0 +1,205 @@ +#include "comic_flow.h" +#include "qnaturalsorting.h" + +#include +#include +#include + +ComicFlow::ComicFlow(QWidget* parent,FlowType flowType) +:YACReaderFlow(parent,flowType) +{ + updateTimer = new QTimer; + connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateImageData())); + + worker = new ImageLoader; + connect(this, SIGNAL(centerIndexChanged(int)), this, SLOT(preload())); + + setReflectionEffect(PlainReflection); +} + +ComicFlow::~ComicFlow() +{ + delete worker; + delete updateTimer; +} + +void ComicFlow::setImagePaths(const QStringList& paths) +{ + clear(); + + //imagePath = path; + imageFiles = paths; + imagesLoaded.clear(); + imagesLoaded.fill(false,imageFiles.size()); + numImagesLoaded = 0; + + imagesSetted.clear(); + imagesSetted.fill(false,imageFiles.size()); + + // populate with empty images + QImage img; //TODO remove + QString s; + for(int i = 0; i < (int)imageFiles.size(); i++) + { + addSlide(img); + s = imageFiles.at(i); + s.remove(s.size()-4,4); + if(QFileInfo(s+".r").exists()) + markSlide(i); + } + + setCenterIndex(0); + worker->reset(); + preload(); +} + +void ComicFlow::preload() +{ + if(numImagesLoaded < imagesLoaded.size()) + updateTimer->start(30); //TODO comprobar rendimiento, originalmente era 70 +} + +void ComicFlow::updateImageData() +{ + // can't do anything, wait for the next possibility + if(worker->busy()) + return; + + // set image of last one + int idx = worker->index(); + if( idx >= 0 && !worker->result().isNull()) + { + if(!imagesSetted[idx]) + { + setSlide(idx, worker->result()); + imagesSetted[idx] = true; + numImagesLoaded++; + } + } + + // try to load only few images on the left and right side + // i.e. all visible ones plus some extra +#define COUNT 8 + int indexes[2*COUNT+1]; + int center = centerIndex(); + indexes[0] = center; + for(int j = 0; j < COUNT; j++) + { + indexes[j*2+1] = center+j+1; + indexes[j*2+2] = center-j-1; + } + for(int c = 0; c < 2*COUNT+1; c++) + { + int i = indexes[c]; + if((i >= 0) && (i < slideCount())) + if(!imagesLoaded[i])//slide(i).isNull()) + { + // schedule thumbnail generation + QString fname = imageFiles[i]; + imagesLoaded[i]=true; + + worker->generate(i, fname, slideSize()); + return; + } + } + + // no need to generate anything? stop polling... + updateTimer->stop(); +} + +void ComicFlow::keyPressEvent(QKeyEvent* event) +{ + PictureFlow::keyPressEvent(event); +} + +void ComicFlow::wheelEvent(QWheelEvent * event) +{ + if(event->delta()<0) + showNext(); + else + showPrevious(); + event->accept(); +} + +//----------------------------------------------------------------------------- +//ImageLoader +//----------------------------------------------------------------------------- +static QImage loadImage(const QString& fileName) +{ + QImage image; + bool result = image.load(fileName); + + if(!result) + return QImage(); + + return image; +} + +ImageLoader::ImageLoader(): +QThread(), restart(false), working(false), idx(-1) +{ +} + +ImageLoader::~ImageLoader() +{ + mutex.lock(); + condition.wakeOne(); + mutex.unlock(); + wait(); +} + +bool ImageLoader::busy() const +{ + return isRunning() ? working : false; +} + +void ImageLoader::generate(int index, const QString& fileName, QSize size) +{ + mutex.lock(); + this->idx = index; + this->fileName = fileName; + this->size = size; + this->img = QImage(); + mutex.unlock(); + + if (!isRunning()) + start(); + else + { + // already running, wake up whenever ready + restart = true; + condition.wakeOne(); + } +} + +void ImageLoader::run() +{ + for(;;) + { + // copy necessary data + mutex.lock(); + this->working = true; + QString fileName = this->fileName; + mutex.unlock(); + + QImage image = loadImage(fileName); + + // let everyone knows it is ready + mutex.lock(); + this->working = false; + this->img = image; + mutex.unlock(); + + // put to sleep + mutex.lock(); + if (!this->restart) + condition.wait(&mutex); + restart = false; + mutex.unlock(); + } +} + +QImage ImageLoader::result() +{ + return img; +} \ No newline at end of file diff --git a/YACReaderLibrary/comic_flow.h b/YACReaderLibrary/comic_flow.h new file mode 100644 index 00000000..e4448de2 --- /dev/null +++ b/YACReaderLibrary/comic_flow.h @@ -0,0 +1,73 @@ +#ifndef __COMICFLOW_H +#define __COMICFLOW_H + +#include "custom_widgets.h" +#include +#include +#include +#include +#include +#include +#include +#include + +class ImageLoader; +class ComicFlow : public YACReaderFlow +{ + Q_OBJECT +public: + ComicFlow(QWidget* parent = 0,FlowType flowType = CoverFlowLike); + virtual ~ComicFlow(); + + void setImagePaths(const QStringList& paths); + //bool eventFilter(QObject *target, QEvent *event); + void keyPressEvent(QKeyEvent* event); + +private slots: + void preload(); + void updateImageData(); + +private: + //QString imagePath; + QStringList imageFiles; + QVector imagesLoaded; + QVector imagesSetted; + uint numImagesLoaded; + QTimer* updateTimer; + ImageLoader* worker; + virtual void wheelEvent(QWheelEvent * event); +}; + + +//----------------------------------------------------------------------------- +// Source code of ImageLoader class was modified from http://code.google.com/p/photoflow/ +//------------------------------------------------------------------------------ +class ImageLoader : public QThread +{ +public: + ImageLoader(); + ~ImageLoader(); + // returns FALSE if worker is still busy and can't take the task + bool busy() const; + void generate(int index, const QString& fileName, QSize size); + void reset(){idx = -1;}; + int index() const { return idx; }; + QImage result(); + +protected: + void run(); + +private: + QMutex mutex; + QWaitCondition condition; + + bool restart; + bool working; + int idx; + QString fileName; + QSize size; + QImage img; +}; + + +#endif diff --git a/YACReaderLibrary/create_library_dialog.cpp b/YACReaderLibrary/create_library_dialog.cpp new file mode 100644 index 00000000..4a608590 --- /dev/null +++ b/YACReaderLibrary/create_library_dialog.cpp @@ -0,0 +1,192 @@ +#include "create_library_dialog.h" + +#include +#include +#include +#include + + +CreateLibraryDialog::CreateLibraryDialog(QWidget * parent) +:QDialog(parent) +{ + setupUI(); +} + +void CreateLibraryDialog::setupUI() +{ + textLabel = new QLabel(tr("Comics folder : ")); + path = new QLineEdit; + textLabel->setBuddy(path); + + nameLabel = new QLabel(tr("Library Name : ")); + nameEdit = new QLineEdit; + nameLabel->setBuddy(nameEdit); + + accept = new QPushButton(tr("Create")); + accept->setDisabled(true); + connect(accept,SIGNAL(clicked()),this,SLOT(create())); + + cancel = new QPushButton(tr("Cancel")); + connect(cancel,SIGNAL(clicked()),this,SIGNAL(cancelCreate())); + connect(cancel,SIGNAL(clicked()),this,SLOT(close())); + + find = new QPushButton(QIcon(":/images/comicFolder.png"),""); + connect(find,SIGNAL(clicked()),this,SLOT(findPath())); + + QGridLayout * content = new QGridLayout; + + //QHBoxLayout *nameLayout = new QHBoxLayout; + + content->addWidget(nameLabel,0,0); + content->addWidget(nameEdit,0,1); + + //QHBoxLayout *libraryLayout = new QHBoxLayout; + + content->addWidget(textLabel,1,0); + content->addWidget(path,1,1); + content->addWidget(find,1,2); + content->setColumnMinimumWidth(2,0); //TODO + + QHBoxLayout *middleLayout = new QHBoxLayout; + + progressBar = new QProgressBar(this); + progressBar->setMinimum(0); + progressBar->setMaximum(0); + progressBar->setTextVisible(false); + progressBar->hide(); + + currentFileLabel = new QLabel(""); + currentFileLabel->setWordWrap(true); + middleLayout->addWidget(currentFileLabel); + middleLayout->addStretch(); + middleLayout->setSizeConstraint(QLayout::SetMaximumSize); + + + QHBoxLayout *bottomLayout = new QHBoxLayout; + bottomLayout->addWidget(message = new QLabel(tr("Create a library could take several minutes. You can stop the process and update the library later for completing the task."))); + message->setWordWrap(true); + //message->hide(); + bottomLayout->addStretch(); + bottomLayout->addWidget(accept); + bottomLayout->addWidget(cancel); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addLayout(content); + + mainLayout->addLayout(middleLayout); + mainLayout->addStretch(); + mainLayout->addWidget(progressBar); + mainLayout->addLayout(bottomLayout); + + QHBoxLayout * imgMainLayout = new QHBoxLayout; + QLabel * imgLabel = new QLabel(this); + QPixmap p(":/images/new.png"); + imgLabel->setPixmap(p); + imgMainLayout->addWidget(imgLabel); + imgMainLayout->addLayout(mainLayout); + + setLayout(imgMainLayout); + + setModal(true); + setWindowTitle(tr("Create new library")); +} + +void CreateLibraryDialog::create() +{ + progressBar->show(); + message->show(); + currentFileLabel->setText("Importing : \n\n\n\n\n"); + this->adjustSize(); + accept->setEnabled(false); + emit(createLibrary(QDir::cleanPath(path->text()),QDir::cleanPath(path->text())+"/.yacreaderlibrary",nameEdit->text())); +} + +void CreateLibraryDialog::findPath() +{ + QString s = QFileDialog::getExistingDirectory(0,"Comics directory","."); + if(!s.isEmpty()) + { + path->setText(s); + accept->setEnabled(true); + } +} + +void CreateLibraryDialog::showCurrentFile(QString file) +{ + currentFileLabel->setText(tr("Importing : \n") + file); + currentFileLabel->update(); + //this->adjustSize(); + //is->update(); +} +void CreateLibraryDialog::close() +{ + progressBar->hide(); + path->clear(); + nameEdit->clear(); + currentFileLabel->setText(""); + this->adjustSize(); + accept->setEnabled(true); + QDialog::close(); +} + +void CreateLibraryDialog::setDataAndStart(QString name, QString path) +{ + this->path->setText(path); + this->nameEdit->setText(name); + show(); + create(); +} +//----------------------------------------------------------------------------- +// UpdateLibraryDialog +//----------------------------------------------------------------------------- +UpdateLibraryDialog::UpdateLibraryDialog(QWidget * parent) +:QDialog(parent) +{ + QVBoxLayout * mainLayout = new QVBoxLayout; + mainLayout->addWidget(message = new QLabel(tr("Updating...."))); + mainLayout->addWidget(currentFileLabel = new QLabel("\n\n\n\n")); + currentFileLabel->setWordWrap(true); + + QHBoxLayout * bottom = new QHBoxLayout; + bottom->addStretch(); + bottom->addWidget(cancel = new QPushButton(tr("Cancel"))); + + connect(cancel,SIGNAL(clicked()),this,SIGNAL(cancelUpdate())); + connect(cancel,SIGNAL(clicked()),this,SLOT(close())); + + mainLayout->addStretch(); + + progressBar = new QProgressBar(this); + progressBar->setMinimum(0); + progressBar->setMaximum(0); + progressBar->setTextVisible(false); + + mainLayout->addWidget(progressBar); + mainLayout->addLayout(bottom); + + QHBoxLayout * imgMainLayout = new QHBoxLayout; + QLabel * imgLabel = new QLabel(this); + QPixmap p(":/images/updateLibrary.png"); + imgLabel->setPixmap(p); + imgMainLayout->addWidget(imgLabel); + imgMainLayout->addLayout(mainLayout); + + setLayout(imgMainLayout); + + setModal(true); + setWindowTitle(tr("Update library")); +} + +void UpdateLibraryDialog::showCurrentFile(QString file) +{ + currentFileLabel->setText(file); + currentFileLabel->update(); + this->update(); +} + +void UpdateLibraryDialog::close() +{ + currentFileLabel->setText(""); + this->adjustSize(); + QDialog::close(); +} diff --git a/YACReaderLibrary/create_library_dialog.h b/YACReaderLibrary/create_library_dialog.h new file mode 100644 index 00000000..a671fcce --- /dev/null +++ b/YACReaderLibrary/create_library_dialog.h @@ -0,0 +1,56 @@ +#ifndef __CREATE_LIBRARY_DIALOG_H +#define __CREATE_LIBRARY_DIALOG_H + +#include +#include +#include +#include +#include +#include + + class CreateLibraryDialog : public QDialog + { + Q_OBJECT + public: + CreateLibraryDialog(QWidget * parent = 0); + private: + QLabel * nameLabel; + QLabel * textLabel; + QLabel * message; + QProgressBar *progressBar; + QLabel * currentFileLabel; + QLineEdit * path; + QLineEdit * nameEdit; + QPushButton * find; + QPushButton * accept; + QPushButton * cancel; + void setupUI(); + public slots: + void create(); + void findPath(); + void showCurrentFile(QString file); + void close(); + void setDataAndStart(QString name, QString paht); + signals: + void createLibrary(QString source, QString target, QString name); + void cancelCreate(); + }; + + class UpdateLibraryDialog : public QDialog + { + Q_OBJECT + public: + UpdateLibraryDialog(QWidget * parent = 0); + private: + QLabel * message; + QLabel * currentFileLabel; + QProgressBar *progressBar; + QPushButton * cancel; + public slots: + void showCurrentFile(QString file); + void close(); + signals: + void cancelUpdate(); + }; + +#endif diff --git a/YACReaderLibrary/db/comic.cpp b/YACReaderLibrary/db/comic.cpp new file mode 100644 index 00000000..5ac14521 --- /dev/null +++ b/YACReaderLibrary/db/comic.cpp @@ -0,0 +1,665 @@ +#include "comic.h" + +#include +#include +#include + +//----------------------------------------------------------------------------- +//COMIC------------------------------------------------------------------------ +//----------------------------------------------------------------------------- +Comic::Comic() +{ + +} + +Comic::Comic(qulonglong cparentId, QString cname, QString cpath, QString chash, QSqlDatabase & database) +{ + parentId = cparentId; + name = cname; + path = cpath; + + if(!info.load(chash,database)) + { + info.hash = chash; + info.coverPage = new int(1); + _hasCover = false; + } + else + _hasCover = true; +} + +QList Comic::getComicsFromParent(qulonglong parentId, QSqlDatabase & db) +{ + QList list; + + QSqlQuery selectQuery(db); //TODO check + selectQuery.prepare("select c.id,c.parentId,c.fileName,c.path,ci.hash from comic c inner join comic_info ci on (c.comicInfoId = ci.id) where c.parentId = :parentId"); + selectQuery.bindValue(":parentId", parentId); + selectQuery.exec(); + + Comic * currentItem; + while (selectQuery.next()) + { + QList data; + QSqlRecord record = selectQuery.record(); + for(int i=0;iid = record.value("id").toULongLong(); + currentItem->parentId = record.value(1).toULongLong(); + currentItem->name = record.value(2).toString(); + currentItem->path = record.value(3).toString(); + currentItem->info.load(record.value(4).toString(),db); + int lessThan = 0; + if(list.isEmpty()) + list.append(currentItem); + else + { + Comic * last = static_cast(list.back()); + QString nameLast = last->name; + QString nameCurrent = currentItem->name; + QList::iterator i; + i = list.end(); + i--; + while ((0 > (lessThan = nameCurrent.localeAwareCompare(nameLast))) && i != list.begin()) //se usa la misma ordenación que en QDir + { + i--; + nameLast = (*i)->name; + } + if(lessThan>0) //si se ha encontrado un elemento menor que current, se inserta justo después + list.insert(++i,currentItem); + else + list.insert(i,currentItem); + + } + } + //selectQuery.finish(); + return list; +} + +bool Comic::load(qulonglong idc, QSqlDatabase & db) +{ + + QSqlQuery selectQuery(db); //TODO check + selectQuery.prepare("select c.id,c.parentId,c.fileName,c.path,ci.hash from comic c inner join comic_info ci on (c.comicInfoId = ci.id) where c.id = :id"); + selectQuery.bindValue(":id", idc); + selectQuery.exec(); + this->id = idc; + if(selectQuery.next()) + { + QSqlRecord record = selectQuery.record(); + //id = record.value("id").toULongLong(); + parentId = record.value("parentId").toULongLong(); + name = record.value("name").toString(); + path = record.value("path").toString(); + info.load(record.value("hash").toString(),db); + + return true; + } + //selectQuery.finish(); + return false; + +} + +qulonglong Comic::insert(QSqlDatabase & db) +{ + //TODO comprobar si ya hay comic info con ese hash + //TODO cambiar por info.insert(db) + + if(!info.existOnDb) + { + QSqlQuery comicInfoInsert(db); + comicInfoInsert.prepare("INSERT INTO comic_info (hash,numPages) " + "VALUES (:hash,:numPages)"); + comicInfoInsert.bindValue(":hash", info.hash); + comicInfoInsert.bindValue(":numPages", *info.numPages); + comicInfoInsert.exec(); + info.id =comicInfoInsert.lastInsertId().toULongLong(); + _hasCover = false; + } + else + _hasCover = true; //TODO check on disk... + + QSqlQuery query(db); + query.prepare("INSERT INTO comic (parentId, comicInfoId, fileName, path) " + "VALUES (:parentId,:comicInfoId,:name, :path)"); + query.bindValue(":parentId", parentId); + query.bindValue(":comicInfoId", info.id); + query.bindValue(":name", name); + query.bindValue(":path", path); + query.exec(); + return query.lastInsertId().toULongLong(); +} + +void Comic::update(QSqlDatabase & db) +{ + +} + +void Comic::removeFromDB(QSqlDatabase & db) +{ + QSqlQuery query(db); + query.prepare("DELETE FROM comic WHERE id = :id"); + query.bindValue(":id", id); + query.exec(); + //query.finish(); +} + +bool Comic::isDir() +{ + return false; +} + +//----------------------------------------------------------------------------- +//COMIC_INFO------------------------------------------------------------------- +//----------------------------------------------------------------------------- +ComicInfo::ComicInfo() + :existOnDb(false), + title(NULL), + coverPage(NULL), + numPages(NULL), + number(NULL), + isBis(NULL), + count(NULL), + volume(NULL), + storyArc(NULL), + arcNumber(NULL), + arcCount(NULL), + genere(NULL), + writer(NULL), + penciller(NULL), + inker(NULL), + colorist(NULL), + letterer(NULL), + coverArtist(NULL), + date(NULL), + publisher(NULL), + format(NULL), + color(NULL), + ageRating(NULL), + synopsis(NULL), + characters(NULL), + notes(NULL) +{ + +} + +ComicInfo::ComicInfo(const ComicInfo & comicInfo) +: title(NULL), + coverPage(NULL), + numPages(NULL), + number(NULL), + isBis(NULL), + count(NULL), + volume(NULL), + storyArc(NULL), + arcNumber(NULL), + arcCount(NULL), + genere(NULL), + writer(NULL), + penciller(NULL), + inker(NULL), + colorist(NULL), + letterer(NULL), + coverArtist(NULL), + date(NULL), + publisher(NULL), + format(NULL), + color(NULL), + ageRating(NULL), + synopsis(NULL), + characters(NULL), + notes(NULL) +{ + copyField(title,comicInfo.title); + copyField(coverPage,comicInfo.coverPage); + copyField(numPages,comicInfo.numPages); + copyField(number,comicInfo.number); + copyField(isBis,comicInfo.isBis); + copyField(count,comicInfo.count); + copyField(volume,comicInfo.volume); + copyField(storyArc,comicInfo.storyArc); + copyField(arcNumber,comicInfo.arcNumber); + copyField(arcCount,comicInfo.arcCount); + copyField(genere,comicInfo.genere); + copyField(writer,comicInfo.writer); + copyField(penciller,comicInfo.penciller); + copyField(inker,comicInfo.inker); + copyField(colorist,comicInfo.colorist); + copyField(letterer,comicInfo.letterer); + copyField(coverArtist,comicInfo.coverArtist); + copyField(date,comicInfo.date); + copyField(publisher,comicInfo.publisher); + copyField(format,comicInfo.format); + copyField(color,comicInfo.color); + copyField(ageRating,comicInfo.ageRating); + copyField(synopsis,comicInfo.synopsis); + copyField(characters,comicInfo.characters); + copyField(notes,comicInfo.notes); + + hash = comicInfo.hash; + id = comicInfo.id; + existOnDb = comicInfo.existOnDb; + read = comicInfo.read; + edited = comicInfo.edited; + +} + +ComicInfo::~ComicInfo() +{ + delete title; + delete coverPage; + delete numPages; + delete number; + delete isBis; + delete count; + delete volume; + delete storyArc; + delete arcNumber; + delete arcCount; + delete genere; + delete writer; + delete penciller; + delete inker; + delete colorist; + delete letterer; + delete coverArtist; + delete date; + delete publisher; + delete format; + delete color; + delete ageRating; + delete synopsis; + delete characters; + delete notes; +} + +void ComicInfo::setField(const QString & name, QString * & field, QSqlRecord & record) +{ + if(!record.value(name).isNull()) + { + field = new QString(); + *field = record.value(name).toString(); + } +} + +void ComicInfo::setField(const QString & name, int * & field, QSqlRecord & record) +{ + if(!record.value(name).isNull()) + { + field = new int; + *field = record.value(name).toInt(); + } +} + +void ComicInfo::setField(const QString & name, bool * & field, QSqlRecord & record) +{ + if(!record.value(name).isNull()) + { + field = new bool; + *field = record.value(name).toBool(); + } +} + + +void ComicInfo::bindField(const QString & name, QString * field, QSqlQuery & query) +{ + if(field != NULL) + { + query.bindValue(name,*field); + } +} + +void ComicInfo::bindField(const QString & name, int * field, QSqlQuery & query) +{ + if(field != NULL) + { + query.bindValue(name,*field); + } +} + +void ComicInfo::bindField(const QString & name, bool * field, QSqlQuery & query) +{ + if(field != NULL) + { + query.bindValue(name,*field); + } +} + +void ComicInfo::setValue(QString * & field, const QString & value) +{ + if(field == NULL) + field = new QString; + *field = value; +} + +void ComicInfo::setValue(int * & field, int value) +{ + if(field == NULL) + field = new int; + *field = value; +} + +void ComicInfo::setValue(bool * & field, bool value) +{ + if(field == NULL) + field = new bool; + *field = value; +} + +void ComicInfo::copyField(QString * & field, const QString * value) +{ + if(value != NULL) + field = new QString(*value); +} + +void ComicInfo::copyField(int * & field, int * value) +{ + if(value != NULL) + field = new int(*value); +} + +void ComicInfo::copyField(bool * & field, bool * value) +{ + if(value != NULL) + field = new bool(*value); +} + +bool ComicInfo::load(QString hash, QSqlDatabase & db) +{ + QSqlQuery findComicInfo(db); + findComicInfo.prepare("SELECT * FROM comic_info WHERE hash = :hash"); + findComicInfo.bindValue(":hash", hash); + findComicInfo.exec(); + + + if(findComicInfo.next()) + { + this->hash = hash; + QSqlRecord record = findComicInfo.record(); + + hash = hash; + id = record.value("id").toULongLong(); + read = record.value("read").toBool(); + edited = record.value("edited").toBool(); + + setField("title",title,record); + setField("numPages",numPages,record); + + setField("coverPage",coverPage,record); + + setField("number",number,record); + setField("isBis",isBis,record); + setField("count",count,record); + + setField("volume",volume,record); + setField("storyArc",storyArc,record); + setField("arcNumber",arcNumber,record); + setField("arcCount",arcCount,record); + + setField("genere",genere,record); + + setField("writer",writer,record); + setField("penciller",penciller,record); + setField("inker",inker,record); + setField("colorist",colorist,record); + setField("letterer",letterer,record); + setField("coverArtist",coverArtist,record); + + setField("date",date,record); + setField("publisher",publisher,record); + setField("format",format,record); + setField("color",color,record); + setField("ageRating",ageRating,record); + + setField("synopsis",synopsis,record); + setField("characters",characters,record); + setField("notes",notes,record); + + return existOnDb = true; + } + + return existOnDb = false; +} + +qulonglong ComicInfo::insert(QSqlDatabase & db) +{ + return 0; +} +void ComicInfo::removeFromDB(QSqlDatabase & db) +{ + +} +void ComicInfo::update(QSqlDatabase & db) +{ + //db.open(); + QSqlQuery updateComicInfo(db); + updateComicInfo.prepare("UPDATE comic_info SET " + "title = :title," + + "coverPage = :coverPage," + "numPages = :numPages," + + "number = :number," + "isBis = :isBis," + "count = :count," + + "volume = :volume," + "storyArc = :storyArc," + "arcNumber = :arcNumber," + "arcCount = :arcCount," + + "genere = :genere," + + "writer = :writer," + "penciller = :penciller," + "inker = :inker," + "colorist = :colorist," + "letterer = :letterer," + "coverArtist = :coverArtist," + + "date = :date," + "publisher = :publisher," + "format = :format," + "color = :color," + "ageRating = :ageRating," + + "synopsis = :synopsis," + "characters = :characters," + "notes = :notes," + + "read = :read," + "edited = :edited" + + " WHERE id = :id "); + bindField(":title",title,updateComicInfo); + + bindField(":coverPage",coverPage,updateComicInfo); + bindField(":numPages",numPages,updateComicInfo); + + bindField(":number",number,updateComicInfo); + bindField(":isBis",isBis,updateComicInfo); + bindField(":count",count,updateComicInfo); + + bindField(":volume",volume,updateComicInfo); + bindField(":storyArc",storyArc,updateComicInfo); + bindField(":arcNumber",arcNumber,updateComicInfo); + bindField(":arcCount",arcCount,updateComicInfo); + + bindField(":genere",genere,updateComicInfo); + + bindField(":writer",writer,updateComicInfo); + bindField(":penciller",penciller,updateComicInfo); + bindField(":inker",inker,updateComicInfo); + bindField(":colorist",colorist,updateComicInfo); + bindField(":letterer",letterer,updateComicInfo); + bindField(":coverArtist",coverArtist,updateComicInfo); + + bindField(":date",date,updateComicInfo); + bindField(":publisher",publisher,updateComicInfo); + bindField(":format",format,updateComicInfo); + bindField(":color",color,updateComicInfo); + bindField(":ageRating",ageRating,updateComicInfo); + + bindField(":synopsis",synopsis,updateComicInfo); + bindField(":characters",characters,updateComicInfo); + bindField(":notes",notes,updateComicInfo); + + updateComicInfo.bindValue(":read", read?1:0); + updateComicInfo.bindValue(":id", id); + updateComicInfo.bindValue(":edited", edited?1:0); + updateComicInfo.exec(); + //updateComicInfo.finish(); + //db.close(); +} + +void ComicInfo::updateRead(QSqlDatabase & db) +{ + QSqlQuery findComicInfo(db); + findComicInfo.prepare("UPDATE comic_info SET " + "read = :read" + " WHERE id = :id "); + + findComicInfo.bindValue(":read", read?1:0); + findComicInfo.bindValue(":id", id); + findComicInfo.exec(); + //findComicInfo.finish(); +} + + +//set fields +void ComicInfo::setTitle(QString value) +{ + setValue(title,value); +} + +void ComicInfo::setCoverPage(int value) +{ + setValue(coverPage,value); +} +void ComicInfo::setNumPages(int value) +{ + setValue(numPages,value); +} + +void ComicInfo::setNumber(int value) +{ + setValue(number,value); +} + +void ComicInfo::setIsBis(bool value) +{ + setValue(isBis,value); +} + +void ComicInfo::setCount(int value) +{ + setValue(count,value); +} + +void ComicInfo::setVolume(QString value) +{ + setValue(volume,value); +} + +void ComicInfo::setStoryArc(QString value) +{ + setValue(storyArc,value); +} + +void ComicInfo::setArcNumber(int value) +{ + setValue(arcNumber,value); +} + +void ComicInfo::setArcCount(int value) +{ + setValue(arcCount,value); +} + +void ComicInfo::setGenere(QString value) +{ + setValue(genere,value); +} + +void ComicInfo::setWriter(QString value) +{ + setValue(writer,value); +} + +void ComicInfo::setPenciller(QString value) +{ + setValue(penciller,value); +} + +void ComicInfo::setInker(QString value) +{ + setValue(inker,value); +} + +void ComicInfo::setColorist(QString value) +{ + setValue(colorist,value); +} + +void ComicInfo::setLetterer(QString value) +{ + setValue(letterer,value); +} + +void ComicInfo::setCoverArtist(QString value) +{ + setValue(coverArtist,value); +} + +void ComicInfo::setDate(QString value) +{ + setValue(date,value); +} + +void ComicInfo::setPublisher(QString value) +{ + setValue(publisher,value); +} + +void ComicInfo::setFormat(QString value) +{ + setValue(format,value); +} + +void ComicInfo::setColor(bool value) +{ + setValue(color,value); +} + +void ComicInfo::setAgeRating(QString value) +{ + setValue(ageRating,value); +} + +void ComicInfo::setSynopsis(QString value) +{ + setValue(synopsis,value); +} + +void ComicInfo::setCharacters(QString value) +{ + setValue(characters,value); +} + +void ComicInfo::setNotes(QString value) +{ + setValue(notes,value); +} + +QPixmap ComicInfo::getCover(const QString & basePath) +{ + if(cover.isNull()) + { + cover.load(basePath + "/.yacreaderlibrary/covers/" + hash + ".jpg"); + } + QPixmap c; + c.convertFromImage(cover); + return c; +} \ No newline at end of file diff --git a/YACReaderLibrary/db/comic.h b/YACReaderLibrary/db/comic.h new file mode 100644 index 00000000..8824dd15 --- /dev/null +++ b/YACReaderLibrary/db/comic.h @@ -0,0 +1,139 @@ +#ifndef __COMIC_H +#define __COMIC_H + +#include "library_item.h" +#include +#include +#include +#include + +class ComicInfo +{ +public: + ComicInfo(); + ComicInfo(const ComicInfo & comicInfo); + ~ComicInfo(); + + bool load(QString hash, QSqlDatabase & db); + qulonglong insert(QSqlDatabase & db); + void removeFromDB(QSqlDatabase & db); + void update(QSqlDatabase & db); + void updateRead(QSqlDatabase & db); + + qulonglong id; + bool read; + bool edited; + QString hash; + bool existOnDb; + + QString * title; + + int * coverPage; + int * numPages; + + int * number; + bool * isBis; + int * count; + + QString * volume; + QString * storyArc; + int * arcNumber; + int * arcCount; + + QString * genere; + + QString * writer; + QString * penciller; + QString * inker; + QString * colorist; + QString * letterer; + QString * coverArtist; + + QString * date; + QString * publisher; + QString * format; + bool * color; + QString * ageRating; + + QString * synopsis; + QString * characters; + QString * notes; + + QImage cover; + + void setTitle(QString value); + + void setCoverPage(int value); + void setNumPages(int value); + + void setNumber(int value); + void setIsBis(bool value); + void setCount(int value); + + void setVolume(QString value); + void setStoryArc(QString value); + void setArcNumber(int value); + void setArcCount(int value); + + void setGenere(QString value); + + void setWriter(QString value); + void setPenciller(QString value); + void setInker(QString value); + void setColorist(QString value); + void setLetterer(QString value); + void setCoverArtist(QString value); + + void setDate(QString value); + void setPublisher(QString value); + void setFormat(QString value); + void setColor(bool value); + void setAgeRating(QString value); + + void setSynopsis(QString value); + void setCharacters(QString value); + void setNotes(QString value); + + QPixmap getCover(const QString & basePath); + +private: + void setField(const QString & name, QString * & field, QSqlRecord & record); + void setField(const QString & name, int * & field, QSqlRecord & record); + void setField(const QString & name, bool * & field, QSqlRecord & record); + + void bindField(const QString & name, QString * field, QSqlQuery & query); + void bindField(const QString & name, int * field, QSqlQuery & query); + void bindField(const QString & name, bool * field, QSqlQuery & query); + + void setValue(QString * & field, const QString & value); + void setValue(int * & field, int value); + void setValue(bool * & field, bool value); + + void copyField(QString * & field, const QString * value); + void copyField(int * & field, int * value); + void copyField(bool * & field, bool * value); +}; + +class Comic : public LibraryItem +{ +private: + bool _hasCover; +public: + Comic(); + Comic(qulonglong cparentId, QString cname, QString cpath, QString chash, QSqlDatabase & database); + //Comic(QString fn, QString fp):name(fn),path(fp),knownParent(false), knownId(false){}; + + static QList getComicsFromParent(qulonglong parentId, QSqlDatabase & db); + bool isDir(); + + bool load(qulonglong id, QSqlDatabase & db); + qulonglong insert(QSqlDatabase & db); + void removeFromDB(QSqlDatabase & db); + void update(QSqlDatabase & db); + bool hasCover() {return _hasCover;}; + + ComicInfo info; +}; + + +#endif \ No newline at end of file diff --git a/YACReaderLibrary/db/data_base_management.cpp b/YACReaderLibrary/db/data_base_management.cpp new file mode 100644 index 00000000..8d9d1aa2 --- /dev/null +++ b/YACReaderLibrary/db/data_base_management.cpp @@ -0,0 +1,579 @@ +#include "data_base_management.h" + +#include +#include "library_creator.h" +#include "check_new_version.h" + +static QString fields = "title ," + + "coverPage," + "numPages," + + "number," + "isBis," + "count," + + "volume," + "storyArc," + "arcNumber," + "arcCount," + + "genere," + + "writer," + "penciller," + "inker," + "colorist," + "letterer," + "coverArtist," + + "date," + "publisher," + "format," + "color," + "ageRating," + + "synopsis," + "characters," + "notes," + + "hash"; + +DataBaseManagement::DataBaseManagement() + :QObject(),dataBasesList() +{ + +} + +/*TreeModel * DataBaseManagement::newTreeModel(QString path) +{ + //la consulta se ejecuta... + QSqlQuery selectQuery(loadDatabase(path)); + selectQuery.setForwardOnly(true); + selectQuery.exec("select * from folder order by parentId,name"); + //selectQuery.finish(); + return new TreeModel(selectQuery); +}*/ + +QSqlDatabase DataBaseManagement::createDatabase(QString name, QString path) +{ + return createDatabase(QDir::cleanPath(path) + "/" + name + ".ydb"); +} + +QSqlDatabase DataBaseManagement::createDatabase(QString dest) +{ + QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE",dest); + db.setDatabaseName(dest); + if (!db.open()) + qDebug() << db.lastError(); + else { + qDebug() << db.tables(); + } + + { + QSqlQuery pragma("PRAGMA foreign_keys = ON",db); + //pragma.finish(); + DataBaseManagement::createTables(db); + + QSqlQuery query("INSERT INTO folder (parentId, name, path) " + "VALUES (1,'root', '/')",db); + } + //query.finish(); + //db.close(); + + return db; +} + +QSqlDatabase DataBaseManagement::loadDatabase(QString path) +{ + //TODO check path + QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE",path); + db.setDatabaseName(path+"/library.ydb"); + if (!db.open()) { + //se devuelve una base de datos vacía e inválida + + return QSqlDatabase(); + } + QSqlQuery pragma("PRAGMA foreign_keys = ON",db); + //pragma.finish(); + //devuelve la base de datos + return db; +} + +QSqlDatabase DataBaseManagement::loadDatabaseFromFile(QString filePath) +{ + //TODO check path + QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE",filePath); + db.setDatabaseName(filePath); + if (!db.open()) { + //se devuelve una base de datos vacía e inválida + + return QSqlDatabase(); + } + { + QSqlQuery pragma("PRAGMA foreign_keys = ON",db); + } + //pragma.finish(); + //devuelve la base de datos + return db; +} + +bool DataBaseManagement::createTables(QSqlDatabase & database) +{ + bool success = true; + + //FOLDER (representa una carpeta en disco) + { + QSqlQuery queryFolder(database); + queryFolder.prepare("CREATE TABLE folder (id INTEGER PRIMARY KEY, parentId INTEGER NOT NULL, name TEXT NOT NULL, path TEXT NOT NULL, FOREIGN KEY(parentId) REFERENCES folder(id) ON DELETE CASCADE)"); + success = success && queryFolder.exec(); + //queryFolder.finish(); + //COMIC INFO (representa la información de un cómic, cada cómic tendrá un idéntificador único formado por un hash sha1'de los primeros 512kb' + su tamaño en bytes) + QSqlQuery queryComicInfo(database); + queryComicInfo.prepare("CREATE TABLE comic_info (" + "id INTEGER PRIMARY KEY," + "title TEXT," + + "coverPage INTEGER DEFAULT 1," + "numPages INTEGER," + + "number INTEGER," + "isBis BOOLEAN," + "count INTEGER," + + "volume TEXT," + "storyArc TEXT," + "arcNumber INTEGER," + "arcCount INTEGER," + + "genere TEXT," + + "writer TEXT," + "penciller TEXT," + "inker TEXT," + "colorist TEXT," + "letterer TEXT," + "coverArtist TEXT," + + "date TEXT," //dd/mm/yyyy --> se mostrará en 3 campos diferentes + "publisher TEXT," + "format TEXT," + "color BOOLEAN," + "ageRating BOOLEAN," + + "synopsis TEXT," + "characters TEXT," + "notes TEXT," + + "hash TEXT UNIQUE NOT NULL," + "edited BOOLEAN DEFAULT 0," + "read BOOLEAN DEFAULT 0)"); + success = success && queryComicInfo.exec(); + //queryComicInfo.finish(); + + //COMIC (representa un cómic en disco, contiene el nombre de fichero) + QSqlQuery queryComic(database); + queryComic.prepare("CREATE TABLE comic (id INTEGER PRIMARY KEY, parentId INTEGER NOT NULL, comicInfoId INTEGER NOT NULL, fileName TEXT NOT NULL, path TEXT, FOREIGN KEY(parentId) REFERENCES folder(id) ON DELETE CASCADE, FOREIGN KEY(comicInfoId) REFERENCES comic_info(id))"); + success = success && queryComic.exec(); + //queryComic.finish(); + //DB INFO + QSqlQuery queryDBInfo(database); + queryDBInfo.prepare("CREATE TABLE db_info (version TEXT NOT NULL)"); + success = success && queryDBInfo.exec(); + //queryDBInfo.finish(); + + QSqlQuery query("INSERT INTO db_info (version) " + "VALUES ('"VERSION"')",database); + //query.finish(); + } + + return success; +} +#include +void DataBaseManagement::exportComicsInfo(QString source, QString dest) +{ + //QSqlDatabase sourceDB = loadDatabase(source); + QSqlDatabase destDB = loadDatabaseFromFile(dest); + //sourceDB.open(); + { + QSqlQuery attach(destDB); + attach.prepare("ATTACH DATABASE '"+QDir().toNativeSeparators(dest) +"' AS dest;"); + //attach.bindValue(":dest",QDir().toNativeSeparators(dest)); + attach.exec(); + //attach.finish(); + + QSqlQuery attach2(destDB); + attach2.prepare("ATTACH DATABASE '"+QDir().toNativeSeparators(source) +"' AS source;"); + attach2.exec(); + //attach2.finish(); + + //sourceDB.close(); + QSqlQuery queryDBInfo(destDB); + queryDBInfo.prepare("CREATE TABLE dest.db_info (version TEXT NOT NULL)"); + queryDBInfo.exec(); + //queryDBInfo.finish(); + + /*QSqlQuery queryComicsInfo(sourceDB); + queryComicsInfo.prepare("CREATE TABLE dest.comic_info (id INTEGER PRIMARY KEY, hash TEXT NOT NULL, edited BOOLEAN DEFAULT FALSE, title TEXT, read BOOLEAN)"); + queryComicsInfo.exec();*/ + + QSqlQuery query("INSERT INTO dest.db_info (version) " + "VALUES ('5.0.0')",destDB); + //query.finish(); + + QSqlQuery exportData(destDB); + exportData.prepare("create table dest.comic_info as select " + fields + + " from source.comic_info where source.comic_info.edited = 1"); + exportData.exec(); + //exportData.finish(); + } + + //sourceDB.close(); + destDB.close(); + QSqlDatabase::removeDatabase(dest); + +} + +bool DataBaseManagement::importComicsInfo(QString source, QString dest) +{ + QString error; + QString driver; + QStringList hashes; + + bool b = false; + + QSqlDatabase sourceDB = loadDatabaseFromFile(source); + QSqlDatabase destDB = loadDatabaseFromFile(dest); + + { + QSqlQuery pragma("PRAGMA synchronous=OFF",destDB); + + QSqlQuery update(destDB); + update.prepare("UPDATE comic_info SET " + "title = :title," + + "coverPage = :coverPage," + "numPages = :numPages," + + "number = :number," + "isBis = :isBis," + "count = :count," + + "volume = :volume," + "storyArc = :storyArc," + "arcNumber = :arcNumber," + "arcCount = :arcCount," + + "genere = :genere," + + "writer = :writer," + "penciller = :penciller," + "inker = :inker," + "colorist = :colorist," + "letterer = :letterer," + "coverArtist = :coverArtist," + + "date = :date," + "publisher = :publisher," + "format = :format," + "color = :color," + "ageRating = :ageRating," + + "synopsis = :synopsis," + "characters = :characters," + "notes = :notes," + + "edited = :edited" + + " WHERE hash = :hash "); + + QSqlQuery insert(destDB); + insert.prepare("INSERT INTO comic_info " + "(title," + "coverPage," + "numPages," + "number," + "isBis," + "count," + "volume," + "storyArc," + "arcNumber," + "arcCount," + "genere," + "writer," + "penciller," + "inker," + "colorist," + "letterer," + "coverArtist," + "date," + "publisher," + "format," + "color," + "ageRating," + "synopsis," + "characters," + "notes," + "read," + "edited," + "hash)" + + "VALUES (:title," + ":coverPage," + ":numPages," + ":number," + ":isBis," + ":count," + + ":volume," + ":storyArc," + ":arcNumber," + ":arcCount," + + ":genere," + + ":writer," + ":penciller," + ":inker," + ":colorist," + ":letterer," + ":coverArtist," + + ":date," + ":publisher," + ":format," + ":color," + ":ageRating," + + ":synopsis," + ":characters," + ":notes," + + ":read," + ":edited," + + ":hash )"); + QSqlQuery newInfo(sourceDB); + newInfo.prepare("SELECT * FROM comic_info"); + newInfo.exec(); + destDB.transaction(); + int cp; + while (newInfo.next()) //cada tupla deberá ser insertada o actualizada + { + QSqlRecord record = newInfo.record(); + cp = record.value("coverPage").toInt(); + if(cp>1) + { + QSqlQuery checkCoverPage(destDB); + checkCoverPage.prepare("SELECT coverPage FROM comic_info where hash = :hash"); + checkCoverPage.bindValue(":hash",record.value("hash").toString()); + checkCoverPage.exec(); + bool extract = false; + if(checkCoverPage.next()) + { + extract = checkCoverPage.record().value("coverPage").toInt() != cp; + } + if(extract) + hashes.append(record.value("hash").toString()); + } + + bindValuesFromRecord(record,update); + + update.bindValue(":edited",1); + + + update.exec(); + + if(update.numRowsAffected() == 0) + { + + bindValuesFromRecord(record,insert); + insert.bindValue(":edited",1); + insert.bindValue(":read",0); + + insert.exec(); + + QString error1 = insert.lastError().databaseText(); + QString error2 = insert.lastError().driverText(); + + QMessageBox::critical(NULL,"db",error1); + QMessageBox::critical(NULL,"driver",error2); + } + update.finish(); + insert.finish(); + } + } + + destDB.commit(); + QString hash; + foreach(hash, hashes) + { + QSqlQuery getComic(destDB); + getComic.prepare("SELECT c.path,ci.coverPage FROM comic c INNER JOIN comic_info ci ON (c.comicInfoId = ci.id) where ci.hash = :hash"); + getComic.bindValue(":hash",hash); + getComic.exec(); + if(getComic.next()) + { + QString basePath = QString(dest).remove("/.yacreaderlibrary/library.ydb"); + QString path = basePath + getComic.record().value("path").toString(); + int coverPage = getComic.record().value("coverPage").toInt(); + ThumbnailCreator tc(path,basePath+"/.yacreaderlibrary/covers/"+hash+".jpg",coverPage); + tc.create(); + + } + } + + destDB.close(); + sourceDB.close(); + QSqlDatabase::removeDatabase(source); + QSqlDatabase::removeDatabase(dest); + return b; + +} + +void DataBaseManagement::bindValuesFromRecord(const QSqlRecord & record, QSqlQuery & query) +{ + bindString("title",record,query); + + bindInt("coverPage",record,query); + bindInt("numPages",record,query); + + bindInt("number",record,query); + bindInt("isBis",record,query); + bindInt("count",record,query); + + bindString("volume",record,query); + bindString("storyArc",record,query); + bindInt("arcNumber",record,query); + bindInt("arcCount",record,query); + + bindString("genere",record,query); + + bindString("writer",record,query); + bindString("penciller",record,query); + bindString("inker",record,query); + bindString("colorist",record,query); + bindString("letterer",record,query); + bindString("coverArtist",record,query); + + bindString("date",record,query); + bindString("publisher",record,query); + bindString("format",record,query); + bindInt("color",record,query); + bindString("ageRating",record,query); + + bindString("synopsis",record,query); + bindString("characters",record,query); + bindString("notes",record,query); + + bindString("hash",record,query); +} + +void DataBaseManagement::bindString(const QString & name, const QSqlRecord & record, QSqlQuery & query) +{ + if(!record.value(name).isNull()) + { + query.bindValue(":"+name,record.value(name).toString()); + } +} +void DataBaseManagement::bindInt(const QString & name, const QSqlRecord & record, QSqlQuery & query) +{ + if(!record.value(name).isNull()) + { + query.bindValue(":"+name,record.value(name).toInt()); + } +} + +QString DataBaseManagement::checkValidDB(const QString & fullPath) +{ + QSqlDatabase db = loadDatabaseFromFile(fullPath); + if(db.isValid() && db.isOpen()) + { + QSqlQuery version(db); + version.prepare("SELECT * FROM db_info"); + version.exec(); + if(version.next()) + { + db.close(); + QSqlDatabase::removeDatabase(fullPath); + return version.record().value("version").toString(); + } + else + { + db.close(); + QSqlDatabase::removeDatabase(fullPath); + return ""; + } + + } + else + { + db.close(); + QSqlDatabase::removeDatabase(fullPath); + return ""; + } +} + +int DataBaseManagement::compareVersions(const QString & v1, const QString v2) +{ + QStringList v1l = v1.split('.'); + QStringList v2l = v2.split('.'); + QList v1il; + QList v2il; + + foreach(QString s, v1l) + v1il.append(s.toInt()); + + foreach(QString s,v2l) + v2il.append(s.toInt()); + + for(int i=0;iv2il[i]) + return 1; + } + + if(v1il.length() < v2il.length()) + return -1; + if(v1il.length() == v2il.length()) + return 0; + if(v1il.length() > v2il.length()) + return 1; + + return 0; +} + +//COMICS_INFO_EXPORTER +ComicsInfoExporter::ComicsInfoExporter() +:QThread() +{ +} + +void ComicsInfoExporter::exportComicsInfo(QSqlDatabase & source, QSqlDatabase & dest) +{ + +} + +void ComicsInfoExporter::run() +{ + +} + + +//COMICS_INFO_IMPORTER +ComicsInfoImporter::ComicsInfoImporter() +:QThread() +{ +} + +void ComicsInfoImporter::importComicsInfo(QSqlDatabase & source, QSqlDatabase & dest) +{ + +} + +void ComicsInfoImporter::run() +{ + +} \ No newline at end of file diff --git a/YACReaderLibrary/db/data_base_management.h b/YACReaderLibrary/db/data_base_management.h new file mode 100644 index 00000000..470bc24c --- /dev/null +++ b/YACReaderLibrary/db/data_base_management.h @@ -0,0 +1,58 @@ +#ifndef __DATA_BASE_MANAGEMENT_H +#define __DATA_BASE_MANAGEMENT_H + +#include +#include +#include + +#include "treemodel.h" + +class ComicsInfoExporter : public QThread +{ + Q_OBJECT +public: + ComicsInfoExporter(); + void exportComicsInfo(QSqlDatabase & source, QSqlDatabase & dest); +private: + void run(); +}; + +class ComicsInfoImporter : public QThread +{ + Q_OBJECT +public: + ComicsInfoImporter(); + void importComicsInfo(QSqlDatabase & source, QSqlDatabase & dest); +private: + void run(); + +}; + +class DataBaseManagement : public QObject +{ + Q_OBJECT +private: + QList dataBasesList; + static void bindString(const QString & name, const QSqlRecord & record, QSqlQuery & query); + static void bindInt(const QString & name, const QSqlRecord & record, QSqlQuery & query); + static void bindValuesFromRecord(const QSqlRecord & record, QSqlQuery & query); + +public: + DataBaseManagement(); + //TreeModel * newTreeModel(QString path); + //crea una base de datos y todas sus tablas + static QSqlDatabase createDatabase(QString name, QString path); + static QSqlDatabase createDatabase(QString dest); + //carga una base de datos desde la ruta path + static QSqlDatabase loadDatabase(QString path); + static QSqlDatabase loadDatabaseFromFile(QString path); + static bool createTables(QSqlDatabase & database); + + static void exportComicsInfo(QString source, QString dest); + static bool importComicsInfo(QString source, QString dest); + + static QString checkValidDB(const QString & fullPath); //retorna "" si la DB es inválida ó la versión si es válida. + static int compareVersions(const QString & v1, const QString v2); //retorna <0 si v1 < v2, 0 si v1 = v2 y >0 si v1 > v2 +}; + +#endif \ No newline at end of file diff --git a/YACReaderLibrary/db/folder.cpp b/YACReaderLibrary/db/folder.cpp new file mode 100644 index 00000000..41f2bcaa --- /dev/null +++ b/YACReaderLibrary/db/folder.cpp @@ -0,0 +1,71 @@ + +#include "folder.h" +#include +#include +#include + +qulonglong Folder::insert(QSqlDatabase & db) +{ + QSqlQuery query(db); + query.prepare("INSERT INTO folder (parentId, name, path) " + "VALUES (:parentId, :name, :path)"); + query.bindValue(":parentId", parentId); + query.bindValue(":name", name); + query.bindValue(":path", path); + query.exec(); + return query.lastInsertId().toULongLong(); +} + +QList Folder::getFoldersFromParent(qulonglong parentId, QSqlDatabase & db) +{ + QList list; + + QSqlQuery selectQuery(db); //TODO check + selectQuery.prepare("SELECT * FROM folder WHERE parentId = :parentId and id <> 1"); + selectQuery.bindValue(":parentId", parentId); + selectQuery.exec(); + + Folder * currentItem; + while (selectQuery.next()) + { + QList data; + QSqlRecord record = selectQuery.record(); + for(int i=0;i(list.back()); + QString nameLast = last->name; //TODO usar info name si está disponible, sino el nombre del fichero..... + QString nameCurrent = currentItem->name; + QList::iterator i; + i = list.end(); + i--; + while ((0 > (lessThan = nameCurrent.localeAwareCompare(nameLast))) && i != list.begin()) + { + i--; + nameLast = (*i)->name; + } + if(lessThan>0) //si se ha encontrado un elemento menor que current, se inserta justo después + list.insert(++i,currentItem); + else + list.insert(i,currentItem); + + } + } + + return list; +} + +void Folder::removeFromDB(QSqlDatabase & db) +{ + QSqlQuery query(db); + query.prepare("DELETE FROM folder WHERE id = :id"); + query.bindValue(":id", id); + query.exec(); +} + diff --git a/YACReaderLibrary/db/folder.h b/YACReaderLibrary/db/folder.h new file mode 100644 index 00000000..dba5c44c --- /dev/null +++ b/YACReaderLibrary/db/folder.h @@ -0,0 +1,26 @@ +#ifndef __FOLDER_H +#define __FOLDER_H + +#include "library_item.h" + +#include +#include + +class Folder : public LibraryItem +{ +public: + bool knownParent; + bool knownId; + + Folder():knownParent(false), knownId(false){}; + Folder(qulonglong sid, qulonglong pid,QString fn, QString fp):knownParent(true), knownId(true){id = sid; parentId = pid;name = fn; path = fp;}; + Folder(QString fn, QString fp):knownParent(false), knownId(false){name = fn; path = fp;}; + void setId(qulonglong sid){id = sid;knownId = true;}; + void setFather(qulonglong pid){parentId = pid;knownParent = true;}; + static QList getFoldersFromParent(qulonglong parentId, QSqlDatabase & db); + qulonglong insert(QSqlDatabase & db); + bool isDir(){return true;}; + void removeFromDB(QSqlDatabase & db); +}; + +#endif \ No newline at end of file diff --git a/YACReaderLibrary/db/library_item.cpp b/YACReaderLibrary/db/library_item.cpp new file mode 100644 index 00000000..e69de29b diff --git a/YACReaderLibrary/db/library_item.h b/YACReaderLibrary/db/library_item.h new file mode 100644 index 00000000..52c3d654 --- /dev/null +++ b/YACReaderLibrary/db/library_item.h @@ -0,0 +1,17 @@ +#ifndef __LIBRARY_ITEM_H +#define __LIBRARY_ITEM_H + +#include + +class LibraryItem +{ +public: + virtual bool isDir() = 0; + virtual void removeFromDB(QSqlDatabase & db) = 0; + QString name; + QString path; + qulonglong parentId; + qulonglong id; +}; + +#endif \ No newline at end of file diff --git a/YACReaderLibrary/db/tableitem.cpp b/YACReaderLibrary/db/tableitem.cpp new file mode 100644 index 00000000..c1a4e21f --- /dev/null +++ b/YACReaderLibrary/db/tableitem.cpp @@ -0,0 +1,43 @@ + +#include + +#include "tableitem.h" + +//! [0] +TableItem::TableItem(const QList &data) + +{ + itemData = data; +} +//! [0] + +//! [1] +TableItem::~TableItem() +{ + +} +//! [1] + + +//! [5] +int TableItem::columnCount() const +{ + return itemData.count(); +} +//! [5] + +//! [6] +QVariant TableItem::data(int column) const +{ + return itemData.value(column); +} +//! [6] + + +//! [8] +int TableItem::row() const +{ + + return 0; +} +//! [8] diff --git a/YACReaderLibrary/db/tableitem.h b/YACReaderLibrary/db/tableitem.h new file mode 100644 index 00000000..969c53af --- /dev/null +++ b/YACReaderLibrary/db/tableitem.h @@ -0,0 +1,26 @@ +#ifndef TABLEITEM_H +#define TABLEITEM_H + +#include +#include +#include "comic.h" + +//! [0] +class TableItem +{ +public: + TableItem(const QList &data); + ~TableItem(); + int columnCount() const; + QVariant data(int column) const; + int row() const; + unsigned long long int id; //TODO sustituir por una clase adecuada + //Comic comic; +private: + QList itemData; + + +}; +//! [0] + +#endif \ No newline at end of file diff --git a/YACReaderLibrary/db/tablemodel.cpp b/YACReaderLibrary/db/tablemodel.cpp new file mode 100644 index 00000000..4625acb0 --- /dev/null +++ b/YACReaderLibrary/db/tablemodel.cpp @@ -0,0 +1,366 @@ + +#include +#include + +#include "tableitem.h" +#include "tablemodel.h" +#include "data_base_management.h" +#include "qnaturalsorting.h" + +//ci.number,ci.title,c.fileName,ci.numPages,c.id,c.parentId,c.path,ci.hash,ci.read +#define NUMBER 0 +#define TITLE 1 +#define FILE_NAME 2 +#define NUM_PAGES 3 +#define ID 4 +#define PARENT_ID 5 +#define PATH 6 +#define HASH 7 +#define READ 8 +#define IS_BIS 9 + +TableModel::TableModel(QObject *parent) + : QAbstractItemModel(parent) +{ + connect(this,SIGNAL(beforeReset()),this,SIGNAL(modelAboutToBeReset())); + connect(this,SIGNAL(reset()),this,SIGNAL(modelReset())); +} + +//! [0] +TableModel::TableModel( QSqlQuery &sqlquery, QObject *parent) + : QAbstractItemModel(parent) +{ + setupModelData(sqlquery); +} +//! [0] + +//! [1] +TableModel::~TableModel() +{ + qDeleteAll(_data); +} +//! [1] + +//! [2] +int TableModel::columnCount(const QModelIndex &parent) const +{ + if(_data.isEmpty()) + return 0; + return _data.first()->columnCount(); +} +//! [2] + +//! [3] +QVariant TableModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid()) + return QVariant(); + + if (role == Qt::DecorationRole) + { + return QVariant(); + } + + if (role != Qt::DisplayRole) + return QVariant(); + + TableItem *item = static_cast(index.internalPointer()); + + return item->data(index.column()); +} +//! [3] + +//! [4] +Qt::ItemFlags TableModel::flags(const QModelIndex &index) const +{ + if (!index.isValid()) + return 0; + + return Qt::ItemIsEnabled | Qt::ItemIsSelectable; +} +//! [4] + +//! [5] +QVariant TableModel::headerData(int section, Qt::Orientation orientation, + int role) const +{ + if (orientation == Qt::Horizontal && role == Qt::DisplayRole) + { + switch(section)//TODO obtener esto de la query + { + case 0: + return QVariant(QString("#")); + case 1: + return QVariant(QString(tr("Title"))); + case 2: + return QVariant(QString(tr("File Name"))); + case 3: + return QVariant(QString(tr("Pages"))); + } + } + + if(orientation == Qt::Vertical && role == Qt::DecorationRole) + return QVariant(QIcon(":/images/icon.png")); + + return QVariant(); +} +//! [5] + +//! [6] +QModelIndex TableModel::index(int row, int column, const QModelIndex &parent) + const +{ + if (!hasIndex(row, column, parent)) + return QModelIndex(); + + return createIndex(row, column, _data.at(row)); +} +//! [6] + +//! [7] +QModelIndex TableModel::parent(const QModelIndex &index) const +{ + return QModelIndex(); +} +//! [7] + +//! [8] +int TableModel::rowCount(const QModelIndex &parent) const +{ + TreeItem *parentItem; + if (parent.column() > 0) + return 0; + + if (!parent.isValid()) + return _data.count(); + + return 0; +} +//! [8] + +QStringList TableModel::getPaths(const QString & _source) +{ + QStringList paths; + QString source = _source + "/.yacreaderlibrary/covers/"; + QList::ConstIterator itr; + for(itr = _data.constBegin();itr != _data.constEnd();itr++) + { + QString hash = (*itr)->data(HASH).toString(); + paths << source+ hash +".jpg"; + } + + return paths; +} + +void TableModel::setupModelData(unsigned long long int folderId,const QString & databasePath) +{ + //QFile f(QCoreApplication::applicationDirPath()+"/performance.txt"); + //f.open(QIODevice::Append); + beginResetModel(); + //QElapsedTimer timer; + //timer.start(); + qDeleteAll(_data); + _data.clear(); + + //QTextStream txtS(&f); + //txtS << "TABLEMODEL: Tiempo de borrado: " << timer.elapsed() << "ms\r\n"; + _databasePath = databasePath; + QSqlDatabase db = DataBaseManagement::loadDatabase(databasePath); + { + //crear la consulta + //timer.restart(); + QSqlQuery selectQuery(db); //TODO check + selectQuery.prepare("select ci.number,ci.title,c.fileName,ci.numPages,c.id,c.parentId,c.path,ci.hash,ci.read,ci.isBis from comic c inner join comic_info ci on (c.comicInfoId = ci.id) where c.parentId = :parentId"); + selectQuery.bindValue(":parentId", folderId); + selectQuery.exec(); + //txtS << "TABLEMODEL: Tiempo de consulta: " << timer.elapsed() << "ms\r\n"; + //timer.restart(); + setupModelData(selectQuery); + //txtS << "TABLEMODEL: Tiempo de creación del modelo: " << timer.elapsed() << "ms\r\n"; + //selectQuery.finish(); + } + db.close(); + QSqlDatabase::removeDatabase(_databasePath); + endResetModel(); + //f.close(); +} + +QString TableModel::getComicPath(QModelIndex mi) +{ + if(mi.isValid()) + return _data.at(mi.row())->data(PATH).toString(); + return ""; +} +#define NUMBER_MAX 99999999 +void TableModel::setupModelData(QSqlQuery &sqlquery) +{ + TableItem * currentItem; + while (sqlquery.next()) + { + QList data; + QSqlRecord record = sqlquery.record(); + for(int i=0;idata(FILE_NAME).toString(); //TODO usar info name si está disponible, sino el nombre del fichero..... + QString nameCurrent = currentItem->data(FILE_NAME).toString(); + int numberLast,numberCurrent; + numberLast = numberCurrent = NUMBER_MAX; //TODO change by std limit + + if(!last->data(NUMBER).isNull()) + numberLast = last->data(NUMBER).toInt(); + + if(!currentItem->data(NUMBER).isNull()) + numberCurrent = currentItem->data(NUMBER).toInt(); + + QList::iterator i; + i = _data.end(); + i--; + + if(numberCurrent != NUMBER_MAX) + { + while ((lessThan =numberCurrent < numberLast) && i != _data.begin()) + { + i--; + numberLast = NUMBER_MAX; //TODO change by std limit + + if(!(*i)->data(NUMBER).isNull()) + numberLast = (*i)->data(NUMBER).toInt(); + } + } + else + { + while ((lessThan = naturalSortLessThanCI(nameCurrent,nameLast)) && i != _data.begin() && numberLast == 99999999) + { + i--; + nameLast = (*i)->data(FILE_NAME).toString(); + numberLast = NUMBER_MAX; //TODO change by std limit + + if(!(*i)->data(NUMBER).isNull()) + numberLast = (*i)->data(NUMBER).toInt(); + } + + } + if(!lessThan) //si se ha encontrado un elemento menor que current, se inserta justo después + { + if(numberCurrent != NUMBER_MAX) + { + if(numberCurrent == numberLast) + if(currentItem->data(IS_BIS).toBool()) + { + _data.insert(++i,currentItem); + } + else + _data.insert(i,currentItem); + else + _data.insert(++i,currentItem); + } + else + _data.insert(++i,currentItem); + } + else + { + _data.insert(i,currentItem); + } + + } + } +} + +Comic TableModel::getComic(const QModelIndex & mi) +{ + Comic c; + + QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath); + c.load(_data.at(mi.row())->data(ID).toULongLong(),db); + db.close(); + QSqlDatabase::removeDatabase(_databasePath); + + return c; +} + +Comic TableModel::_getComic(const QModelIndex & mi) +{ + Comic c; + + QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath); + c.load(_data.at(mi.row())->data(ID).toULongLong(),db); + db.close(); + QSqlDatabase::removeDatabase(_databasePath); + + return c; +} + + +QVector TableModel::getReadList() +{ + int numComics = _data.count(); + QVector readList(numComics); + for(int i=0;idata(READ).toBool(); + } + return readList; +} + +QVector TableModel::setAllComicsRead(bool read) +{ + QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath); + db.transaction(); + int numComics = _data.count(); + QVector readList(numComics); + for(int i=0;idata(READ) = QVariant(true); + Comic c; + c.load(_data.value(i)->data(ID).toULongLong(),db); + c.info.read = read; + c.info.update(db); + } + db.commit(); + db.close(); + QSqlDatabase::removeDatabase(_databasePath); + + return readList; +} + +QList TableModel::getComics(QList list) +{ + QList comics; + + QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath); + db.transaction(); + QList::const_iterator itr; + for(itr = list.constBegin(); itr!= list.constEnd();itr++) + { + comics.append(_getComic(*itr)); + } + db.commit(); + db.close(); + QSqlDatabase::removeDatabase(_databasePath); + return comics; +} + +QModelIndex TableModel::getIndexFromId(quint64 id) +{ + QList::ConstIterator itr; + int i=0; + for(itr = _data.constBegin();itr != _data.constEnd();itr++) + { + if((*itr)->data(ID).toULongLong() == id) + break; + i++; + } + + return index(i,0); +} \ No newline at end of file diff --git a/YACReaderLibrary/db/tablemodel.h b/YACReaderLibrary/db/tablemodel.h new file mode 100644 index 00000000..ebdd0847 --- /dev/null +++ b/YACReaderLibrary/db/tablemodel.h @@ -0,0 +1,59 @@ +#ifndef TABLEMODEL_H +#define TABLEMODEL_H + +#include +#include +#include +#include +#include + +#include "comic.h" + +class TableItem; + +//! [0] +class TableModel : public QAbstractItemModel +{ + Q_OBJECT + +public: + TableModel(QObject *parent = 0); + TableModel( QSqlQuery &sqlquery, QObject *parent = 0); + ~TableModel(); + + QVariant data(const QModelIndex &index, int role) const; + Qt::ItemFlags flags(const QModelIndex &index) const; + QVariant headerData(int section, Qt::Orientation orientation, + int role = Qt::DisplayRole) const; + QModelIndex index(int row, int column, + const QModelIndex &parent = QModelIndex()) const; + QModelIndex parent(const QModelIndex &index) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + void setupModelData(unsigned long long int parentFolder,const QString & databasePath); + + //Métodos de conveniencia + QStringList getPaths(const QString & _source); + QString getComicPath(QModelIndex mi); + Comic getComic(const QModelIndex & mi); //--> para la edición + QVector getReadList(); + QVector setAllComicsRead(bool read); + QList getComics(QList list); //--> recupera la información común a los comics seleccionados + QModelIndex getIndexFromId(quint64 id); + //setcomicInfo(QModelIndex & mi); --> inserta en la base datos + //setComicInfoForAllComics(); --> inserta la información común a todos los cómics de una sola vez. + //setComicInfoForSelectedComis(QList list); -->inserta la información común para los comics seleccionados +private: + void setupModelData( QSqlQuery &sqlquery); + Comic _getComic(const QModelIndex & mi); + QList _data; + + QString _databasePath; + +signals: + void beforeReset(); + void reset(); +}; +//! [0] + +#endif diff --git a/YACReaderLibrary/db/treeitem.cpp b/YACReaderLibrary/db/treeitem.cpp new file mode 100644 index 00000000..086c1556 --- /dev/null +++ b/YACReaderLibrary/db/treeitem.cpp @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/* + treeitem.cpp + + A container for items of data supplied by the simple tree model. +*/ + +#include + +#include "treeitem.h" +#include "qnaturalsorting.h" + +//! [0] +TreeItem::TreeItem(const QList &data, TreeItem *parent) +{ + parentItem = parent; + itemData = data; +} +//! [0] + +//! [1] +TreeItem::~TreeItem() +{ + qDeleteAll(childItems); +} +//! [1] + +//! [2] +void TreeItem::appendChild(TreeItem *item) +{ + item->parentItem = this; + //TODO insertar odernado + if(childItems.isEmpty()) + childItems.append(item); + else + { + TreeItem * last = childItems.back(); + QString nameLast = last->data(1).toString(); //TODO usar info name si está disponible, sino el nombre del fichero..... + QString nameCurrent = item->data(1).toString(); + QList::iterator i; + i = childItems.end(); + i--; + while (naturalSortLessThanCI(nameCurrent,nameLast) && i != childItems.begin()) + { + i--; + nameLast = (*i)->data(1).toString(); + } + if(!naturalSortLessThanCI(nameCurrent,nameLast)) //si se ha encontrado un elemento menor que current, se inserta justo después + childItems.insert(++i,item); + else + childItems.insert(i,item); + + } + + //childItems.append(item); +} +//! [2] + +//! [3] +TreeItem *TreeItem::child(int row) +{ + return childItems.value(row); +} +//! [3] + +//! [4] +int TreeItem::childCount() const +{ + return childItems.count(); +} +//! [4] + +//! [5] +int TreeItem::columnCount() const +{ + return itemData.count(); +} +//! [5] + +//! [6] +QVariant TreeItem::data(int column) const +{ + return itemData.value(column); +} +//! [6] + +//! [7] +TreeItem *TreeItem::parent() +{ + return parentItem; +} +//! [7] + +//! [8] +int TreeItem::row() const +{ + if (parentItem) + return parentItem->childItems.indexOf(const_cast(this)); + + return 0; +} +//! [8] + + +QList TreeItem::getData() const +{ + return itemData; +} \ No newline at end of file diff --git a/YACReaderLibrary/db/treeitem.h b/YACReaderLibrary/db/treeitem.h new file mode 100644 index 00000000..3cdf35f7 --- /dev/null +++ b/YACReaderLibrary/db/treeitem.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TREEITEM_H +#define TREEITEM_H + +#include +#include +#include + +//! [0] +class TreeItem +{ +public: + TreeItem(const QList &data, TreeItem *parent = 0); + ~TreeItem(); + + void appendChild(TreeItem *child); + + TreeItem *child(int row); + int childCount() const; + int columnCount() const; + QVariant data(int column) const; + QList getData() const; + int row() const; + TreeItem *parent(); + TreeItem *parentItem; + unsigned long long int id; + QList comicNames; + TreeItem * originalItem; +private: + QList childItems; + QList itemData; + + + + +}; +//! [0] + +#endif diff --git a/YACReaderLibrary/db/treemodel.cpp b/YACReaderLibrary/db/treemodel.cpp new file mode 100644 index 00000000..b207edc8 --- /dev/null +++ b/YACReaderLibrary/db/treemodel.cpp @@ -0,0 +1,413 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/* + treemodel.cpp + + Provides a simple tree model to show how to create and use hierarchical + models. +*/ + +#include + + +#include "treeitem.h" +#include "treemodel.h" +#include "data_base_management.h" + +#define ROOT 1 + +TreeModel::TreeModel(QObject *parent) + : QAbstractItemModel(parent),rootItem(0),rootBeforeFilter(0),filterEnabled(false),includeComics(false) +{ + connect(this,SIGNAL(beforeReset()),this,SIGNAL(modelAboutToBeReset())); + connect(this,SIGNAL(reset()),this,SIGNAL(modelReset())); +} + +//! [0] +TreeModel::TreeModel( QSqlQuery &sqlquery, QObject *parent) + : QAbstractItemModel(parent),rootItem(0),rootBeforeFilter(0),filterEnabled(false),includeComics(false) +{ + //lo más probable es que el nodo raíz no necesite tener información + QList rootData; + rootData << "root"; //id 0, padre 0, title "root" (el id, y el id del padre van a ir en la clase TreeItem) + rootItem = new TreeItem(rootData); + rootItem->id = ROOT; + rootItem->parentItem = 0; + setupModelData(sqlquery, rootItem); + //sqlquery.finish(); +} +//! [0] + +//! [1] +TreeModel::~TreeModel() +{ + if(rootItem != 0) + delete rootItem; +} +//! [1] + +//! [2] +int TreeModel::columnCount(const QModelIndex &parent) const +{ + if (parent.isValid()) + return static_cast(parent.internalPointer())->columnCount(); + else + return rootItem->columnCount(); +} +//! [2] + +//! [3] +QVariant TreeModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid()) + return QVariant(); + + if (role == Qt::DecorationRole) + return QVariant(QIcon(":/images/folder.png")); + + if (role != Qt::DisplayRole) + return QVariant(); + + TreeItem *item = static_cast(index.internalPointer()); + + return item->data(index.column()); +} +//! [3] + +//! [4] +Qt::ItemFlags TreeModel::flags(const QModelIndex &index) const +{ + if (!index.isValid()) + return 0; + + return Qt::ItemIsEnabled | Qt::ItemIsSelectable; +} +//! [4] + +//! [5] +QVariant TreeModel::headerData(int section, Qt::Orientation orientation, + int role) const +{ + if (orientation == Qt::Horizontal && role == Qt::DisplayRole) + return rootItem->data(section); + + return QVariant(); +} +//! [5] + +//! [6] +QModelIndex TreeModel::index(int row, int column, const QModelIndex &parent) + const +{ + if (!hasIndex(row, column, parent)) + return QModelIndex(); + + TreeItem *parentItem; + + if (!parent.isValid()) + parentItem = rootItem; + else + parentItem = static_cast(parent.internalPointer()); + + TreeItem *childItem = parentItem->child(row); + if (childItem) + return createIndex(row, column, childItem); + else + return QModelIndex(); +} +//! [6] + +//! [7] +QModelIndex TreeModel::parent(const QModelIndex &index) const +{ + if (!index.isValid()) + return QModelIndex(); + + TreeItem *childItem = static_cast(index.internalPointer()); + TreeItem *parentItem = childItem->parent(); + + if (parentItem == rootItem) + return QModelIndex(); + + return createIndex(parentItem->row(), 0, parentItem); +} +//! [7] + +QModelIndex TreeModel::indexFromItem(TreeItem * item,int column) +{ + //if(item->parent() != 0) + // return index(item->row(),column,parent(indexFromItem(item->parent(),column-1))); + //else + // return index(item->row(),0,QModelIndex()); + return createIndex(item->row(), column, item); +} + + +//! [8] +int TreeModel::rowCount(const QModelIndex &parent) const +{ + TreeItem *parentItem; + if (parent.column() > 0) + return 0; + + if (!parent.isValid()) + parentItem = rootItem; + else + parentItem = static_cast(parent.internalPointer()); + + return parentItem->childCount(); +} +//! [8] + +void TreeModel::setupModelData(QString path) +{ + beginResetModel(); + if(rootItem != 0) + delete rootItem; //TODO comprobar que se libera bien la memoria + filterEnabled = false; + rootItem = 0; + rootBeforeFilter = 0; + //inicializar el nodo raíz + QList rootData; + rootData << "root"; //id 0, padre 0, title "root" (el id, y el id del padre van a ir en la clase TreeItem) + rootItem = new TreeItem(rootData); + rootItem->id = ROOT; + rootItem->parentItem = 0; + + //cargar la base de datos + _databasePath = path; + QSqlDatabase db = DataBaseManagement::loadDatabase(path); + //crear la consulta + { + QSqlQuery selectQuery("select * from folder where id <> 1 order by parentId,name",db); + + setupModelData(selectQuery,rootItem); + } + //selectQuery.finish(); + db.close(); + QSqlDatabase::removeDatabase(path); + endResetModel(); + +} + + +void TreeModel::setupModelData(QSqlQuery &sqlquery, TreeItem *parent) +{ + //64 bits para la primary key, es decir la misma precisión que soporta sqlit 2^64 + //el diccionario permitirá encontrar cualquier nodo del árbol rápidamente, de forma que añadir un hijo a un padre sea O(1) + items.clear(); + //se añade el nodo 0 + items.insert(parent->id,parent); + + while (sqlquery.next()) { + QList data; + QSqlRecord record = sqlquery.record(); + + data << record.value("name").toString(); + data << record.value("path").toString(); + TreeItem * item = new TreeItem(data); + + item->id = record.value("id").toULongLong(); + //la inserción de hijos se hace de forma ordenada + items.value(record.value("parentId").toULongLong())->appendChild(item); + //se añade el item al map, de forma que se pueda encontrar como padre en siguientes iteraciones + items.insert(item->id,item); + } +} + +void TreeModel::setupFilteredModelData() +{ + beginResetModel(); + + //TODO hay que liberar memoria de anteriores filtrados + + //inicializar el nodo raíz + + if(rootBeforeFilter == 0) + rootBeforeFilter = rootItem; + else + delete rootItem;//los resultados de la búsqueda anterior deben ser borrados + + QList rootData; + rootData << "root"; //id 1, padre 1, title "root" (el id, y el id del padre van a ir en la clase TreeItem) + rootItem = new TreeItem(rootData); + rootItem->id = ROOT; + rootItem->parentItem = 0; + + //cargar la base de datos + QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath); + //crear la consulta + { + QSqlQuery selectQuery(db); //TODO check + if(!includeComics) + { + selectQuery.prepare("select * from folder where id <> 1 and upper(name) like upper(:filter) order by parentId,name "); + selectQuery.bindValue(":filter", "%%"+filter+"%%"); + } + else + { + selectQuery.prepare("SELECT DISTINCT f.id, f.parentId, f.name, f.path FROM folder f INNER JOIN comic c ON (f.id = c.parentId) WHERE f.id <> 1 AND ((UPPER(c.fileName) like UPPER(:filter)) OR (UPPER(f.name) like UPPER(:filter2))) ORDER BY f.parentId,f.name"); + selectQuery.bindValue(":filter", "%%"+filter+"%%"); + selectQuery.bindValue(":filter2", "%%"+filter+"%%"); + } + selectQuery.exec(); + + setupFilteredModelData(selectQuery,rootItem); + } + //selectQuery.finish(); + db.close(); + QSqlDatabase::removeDatabase(_databasePath); + + endResetModel(); +} + +void TreeModel::setupFilteredModelData(QSqlQuery &sqlquery, TreeItem *parent) +{ + //64 bits para la primary key, es decir la misma precisión que soporta sqlit 2^64 + filteredItems.clear(); + + //se añade el nodo 0 al modelo que representa el arbol de elementos que cumplen con el filtro + filteredItems.insert(parent->id,parent); + + while (sqlquery.next()) { //se procesan todos los folders que cumplen con el filtro + //datos de la base de datos + QList data; + QSqlRecord record = sqlquery.record(); + + data << record.value("name").toString(); + data << record.value("path").toString(); + TreeItem * item = new TreeItem(data); + item->id = sqlquery.value(0).toULongLong(); + + //id del padre + quint64 parentId = record.value("parentId").toULongLong(); + + //se añade el item al map, de forma que se pueda encontrar como padre en siguientes iteraciones + if(!filteredItems.contains(item->id)) + filteredItems.insert(item->id,item); + + //es necesario conocer las coordenadas de origen para poder realizar scroll automático en la vista + item->originalItem = items.value(item->id); + + //si el padre ya existe en el modelo, el item se añade como hijo + if(filteredItems.contains(parentId)) + filteredItems.value(parentId)->appendChild(item); + else//si el padre aún no se ha añadido, hay que añadirlo a él y todos los padres hasta el nodo raíz + { + //comprobamos con esta variable si el último de los padres (antes del nodo raíz) ya existía en el modelo + bool parentPreviousInserted = false; + + //mientras no se alcance el nodo raíz se procesan todos los padres (de abajo a arriba) + while(parentId != ROOT ) + { + //el padre no estaba en el modelo filtrado, así que se rescata del modelo original + TreeItem * parentItem = items.value(parentId); + //se debe crear un nuevo nodo (para no compartir los hijos con el nodo original) + TreeItem * newparentItem = new TreeItem(parentItem->getData()); //padre que se añadirá a la estructura de directorios filtrados + newparentItem->id = parentId; + + newparentItem->originalItem = parentItem; + + //si el modelo contiene al padre, se añade el item actual como hijo + if(filteredItems.contains(parentId)) + { + filteredItems.value(parentId)->appendChild(item); + parentPreviousInserted = true; + } + //sino se registra el nodo para poder encontrarlo con posterioridad y se añade el item actual como hijo + else + { + newparentItem->appendChild(item); + filteredItems.insert(newparentItem->id,newparentItem); + parentPreviousInserted = false; + } + + //variables de control del bucle, se avanza hacia el nodo padre + item = newparentItem; + parentId = parentItem->parentItem->id; + } + + //si el nodo es hijo de 1 y no había sido previamente insertado como hijo, se añade como tal + if(!parentPreviousInserted) + filteredItems.value(ROOT)->appendChild(item); + } + } +} + + + +QString TreeModel::getDatabase() +{ + return _databasePath; +} + +QString TreeModel::getFolderPath(const QModelIndex &folder) +{ + return static_cast(folder.internalPointer())->data(1).toString(); +} + +void TreeModel::setFilter(QString filter, bool includeComics) +{ + this->filter = filter; + this->includeComics = includeComics; + filterEnabled = true; + setupFilteredModelData(); +} + +void TreeModel::resetFilter() +{ + beginResetModel(); + filter = ""; + includeComics = false; + //TODO hay que liberar la memoria reservada para el filtrado + //items.clear(); + filteredItems.clear(); + TreeItem * root = rootItem; + rootItem = rootBeforeFilter; //TODO si no se aplica el filtro previamente, esto invalidaría en modelo + if(root !=0) + delete root; + + rootBeforeFilter = 0; + filterEnabled = false; + endResetModel(); + + +} \ No newline at end of file diff --git a/YACReaderLibrary/db/treemodel.h b/YACReaderLibrary/db/treemodel.h new file mode 100644 index 00000000..eb61b13d --- /dev/null +++ b/YACReaderLibrary/db/treemodel.h @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TREEMODEL_H +#define TREEMODEL_H + +#include +#include +#include +#include +#include + +class TreeItem; + +//! [0] +class TreeModel : public QAbstractItemModel +{ + Q_OBJECT + +public: + TreeModel(QObject *parent = 0); + TreeModel( QSqlQuery &sqlquery, QObject *parent = 0); + ~TreeModel(); + + QVariant data(const QModelIndex &index, int role) const; + Qt::ItemFlags flags(const QModelIndex &index) const; + QVariant headerData(int section, Qt::Orientation orientation, + int role = Qt::DisplayRole) const; + QModelIndex index(int row, int column, + const QModelIndex &parent = QModelIndex()) const; + QModelIndex parent(const QModelIndex &index) const; + QModelIndex indexFromItem(TreeItem * item, int column); + /*QModelIndex _indexFromItem(TreeItem * item, int column); + int column;*/ + + int rowCount(const QModelIndex &parent = QModelIndex()) const; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + void setupModelData(QString path); + QString getDatabase(); + + //Métodos de conveniencia + QString getFolderPath(const QModelIndex &folder); + + void setFilter(QString filter, bool includeComics); + void resetFilter(); + bool isFilterEnabled(){return filterEnabled;}; +private: + void setupModelData( QSqlQuery &sqlquery, TreeItem *parent); + void setupFilteredModelData( QSqlQuery &sqlquery, TreeItem *parent); + void setupFilteredModelData(); + + TreeItem *rootItem; //el árbol + QMap items; //relación entre folders + + TreeItem *rootBeforeFilter; + QMap filteredItems; //relación entre folders + + QString _databasePath; + + bool includeComics; + QString filter; + bool filterEnabled; +signals: + void beforeReset(); + void reset(); +}; +//! [0] + +#endif diff --git a/YACReaderLibrary/export_comics_info_dialog.cpp b/YACReaderLibrary/export_comics_info_dialog.cpp new file mode 100644 index 00000000..4a4b3208 --- /dev/null +++ b/YACReaderLibrary/export_comics_info_dialog.cpp @@ -0,0 +1,84 @@ +#include "export_comics_info_dialog.h" + +#include +#include +#include +#include + +#include "data_base_management.h" + +ExportComicsInfoDialog::ExportComicsInfoDialog(QWidget *parent) + : QDialog(parent) +{ + textLabel = new QLabel(tr("Output file : ")); + path = new QLineEdit; + textLabel->setBuddy(path); + + accept = new QPushButton(tr("Create")); + accept->setDisabled(true); + connect(accept,SIGNAL(clicked()),this,SLOT(exportComicsInfo())); + + cancel = new QPushButton(tr("Cancel")); + connect(cancel,SIGNAL(clicked()),this,SLOT(close())); + connect(cancel,SIGNAL(clicked()),this,SIGNAL(rejected())); + + find = new QPushButton(QIcon(":/images/db.png"),""); + connect(find,SIGNAL(clicked()),this,SLOT(findPath())); + + QHBoxLayout *libraryLayout = new QHBoxLayout; + + libraryLayout->addWidget(textLabel); + libraryLayout->addWidget(path); + libraryLayout->addWidget(find); + libraryLayout->setStretchFactor(find,0); //TODO + + QHBoxLayout *bottomLayout = new QHBoxLayout; + bottomLayout->addStretch(); + bottomLayout->addWidget(accept); + bottomLayout->addWidget(cancel); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addLayout(libraryLayout); + mainLayout->addWidget(progress=new QLabel()); + mainLayout->addStretch(); + mainLayout->addLayout(bottomLayout); + + QHBoxLayout * imgMainLayout = new QHBoxLayout; + QLabel * imgLabel = new QLabel(this); + QPixmap p(":/images/exportComicsInfo.png"); + imgLabel->setPixmap(p); + imgMainLayout->addWidget(imgLabel); + imgMainLayout->addLayout(mainLayout); + + setLayout(imgMainLayout); + + setModal(true); + setWindowTitle(tr("Export comics info")); +} + +ExportComicsInfoDialog::~ExportComicsInfoDialog() +{ + +} + +void ExportComicsInfoDialog::findPath() +{ + QString s = QFileDialog::getSaveFileName(this,tr("Destination database name"),".","*.ydb"); + if(!s.isEmpty()) + { + path->setText(s); + accept->setEnabled(true); + } +} + +void ExportComicsInfoDialog::exportComicsInfo() +{ + DataBaseManagement::exportComicsInfo(source,path->text()); + close(); +} + +void ExportComicsInfoDialog::close() +{ + path->clear(); + QDialog::close(); +} \ No newline at end of file diff --git a/YACReaderLibrary/export_comics_info_dialog.h b/YACReaderLibrary/export_comics_info_dialog.h new file mode 100644 index 00000000..07e3bf0d --- /dev/null +++ b/YACReaderLibrary/export_comics_info_dialog.h @@ -0,0 +1,35 @@ +#ifndef EXPORT_COMICS_INFO_DIALOG_H +#define EXPORT_COMICS_INFO_DIALOG_H + +#include +#include +#include +#include + + +class ExportComicsInfoDialog : public QDialog +{ + Q_OBJECT + +public: + ExportComicsInfoDialog(QWidget *parent = 0); + ~ExportComicsInfoDialog(); + QString source; + +public slots: + void findPath(); + void exportComicsInfo(); + void close(); + +private: + QLabel * progress; + QLabel * textLabel; + QLineEdit * path; + QPushButton * find; + QPushButton * accept; + QPushButton * cancel; + + +}; + +#endif // EXPORT_COMICS_INFO_DIALOG_H diff --git a/YACReaderLibrary/export_library_dialog.cpp b/YACReaderLibrary/export_library_dialog.cpp new file mode 100644 index 00000000..66e0b212 --- /dev/null +++ b/YACReaderLibrary/export_library_dialog.cpp @@ -0,0 +1,96 @@ +#include "export_library_dialog.h" +#include +#include +#include +#include + +ExportLibraryDialog::ExportLibraryDialog(QWidget * parent) +:QDialog(parent),progressCount(0) +{ + textLabel = new QLabel(tr("Output folder : ")); + path = new QLineEdit; + textLabel->setBuddy(path); + + accept = new QPushButton(tr("Create")); + accept->setDisabled(true); + connect(accept,SIGNAL(clicked()),this,SLOT(exportLibrary())); + + cancel = new QPushButton(tr("Cancel")); + connect(cancel,SIGNAL(clicked()),this,SLOT(close())); + connect(cancel,SIGNAL(clicked()),this,SIGNAL(rejected())); + + find = new QPushButton(QIcon(":/images/comicFolder.png"),""); + connect(find,SIGNAL(clicked()),this,SLOT(findPath())); + + QHBoxLayout *libraryLayout = new QHBoxLayout; + + libraryLayout->addWidget(textLabel); + libraryLayout->addWidget(path); + libraryLayout->addWidget(find); + libraryLayout->setStretchFactor(find,0); //TODO + + QHBoxLayout *bottomLayout = new QHBoxLayout; + bottomLayout->addStretch(); + bottomLayout->addWidget(accept); + bottomLayout->addWidget(cancel); + + progressBar = new QProgressBar(this); + progressBar->setMinimum(0); + progressBar->setMaximum(0); + progressBar->setTextVisible(false); + progressBar->hide(); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addLayout(libraryLayout); + mainLayout->addStretch(); + mainLayout->addWidget(progressBar); + mainLayout->addLayout(bottomLayout); + + QHBoxLayout * imgMainLayout = new QHBoxLayout; + QLabel * imgLabel = new QLabel(this); + QPixmap p(":/images/exportLibrary.png"); + imgLabel->setPixmap(p); + imgMainLayout->addWidget(imgLabel); + imgMainLayout->addLayout(mainLayout); + + setLayout(imgMainLayout); + + setModal(true); + setWindowTitle(tr("Create covers package")); + t.setInterval(500); + connect(&t,SIGNAL(timeout()),this,SLOT(updateProgress())); +} + +void ExportLibraryDialog::exportLibrary() +{ + progressBar->show(); + accept->setEnabled(false); + emit exportPath(QDir::cleanPath(path->text())); + t.start(); +} + +void ExportLibraryDialog::findPath() +{ + QString s = QFileDialog::getExistingDirectory(0,tr("Destination directory"),"."); + if(!s.isEmpty()) + { + path->setText(s); + accept->setEnabled(true); + } +} + +void ExportLibraryDialog::close() +{ + path->clear(); + progressBar->hide(); + accept->setEnabled(false); + t.stop(); + progressCount=0; + QDialog::close(); +} + +void ExportLibraryDialog::run() +{ + +} + diff --git a/YACReaderLibrary/export_library_dialog.h b/YACReaderLibrary/export_library_dialog.h new file mode 100644 index 00000000..cfc73b1b --- /dev/null +++ b/YACReaderLibrary/export_library_dialog.h @@ -0,0 +1,36 @@ +#ifndef EXPORT_LIBRARY_DIALOG_H +#define EXPORT_LIBRARY_DIALOG_H + +#include +#include +#include +#include +#include +#include +#include +#include + +class ExportLibraryDialog : public QDialog +{ + Q_OBJECT +public: + ExportLibraryDialog(QWidget * parent = 0); +public slots: + void exportLibrary(); + void findPath(); + void close(); +private: + int progressCount; + QProgressBar *progressBar; + QLabel * textLabel; + QLineEdit * path; + QPushButton * find; + QPushButton * accept; + QPushButton * cancel; + void run(); + QTimer t; +signals: + void exportPath(QString); +}; + +#endif \ No newline at end of file diff --git a/YACReaderLibrary/files.qrc b/YACReaderLibrary/files.qrc new file mode 100644 index 00000000..42bce93f --- /dev/null +++ b/YACReaderLibrary/files.qrc @@ -0,0 +1,13 @@ + + + ../files/about.html + ../files/helpYACReaderLibrary.html + ./yacreaderlibrary_es.qm + + + + ../files/about_es_ES.html + ../files/helpYACReaderLibrary_es_ES.html + + + diff --git a/YACReaderLibrary/icon.ico b/YACReaderLibrary/icon.ico new file mode 100644 index 0000000000000000000000000000000000000000..b2232648330a45c5639a6c13790191bbf0dd1a9a GIT binary patch literal 99678 zcmeFa2UJ$)wgsxO#h64BV~f3uf}kKMii+3}6c7PLibw}(BE5r1mnI+}A|e8!A_`)| z-g}K2HEN78#u!g-US6If!!h4nzx-ZeNKV>4C+FTc#`N2Jv&(8TC{A@rbVYt zE%>ir3%AxST3E_aznA9~yuP2;G&CB|2e)Y9(xpX<$&+8651Z1W#k=EMw1|#wJb$xg z3+;#&Er#(_UfGXmsraAI@IB4^YpJ+JZu>D>@w|N_P>rRP`SYm6I22Wuqj*a-94zOeXm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-JXBXYn))q<8?c;Rkwbp;#fB9+fQLY zvY`#G$dzWpBUg^i;#al8D9Hz@C@3R_+_h4 bSt|Z2dZ3~QDte%z2P%4?q6hw$df@*7sMu_a literal 0 HcmV?d00001 diff --git a/YACReaderLibrary/icon.rc b/YACReaderLibrary/icon.rc new file mode 100644 index 00000000..afe5a14f --- /dev/null +++ b/YACReaderLibrary/icon.rc @@ -0,0 +1,2 @@ +IDI_ICON1 ICON DISCARDABLE "icon.ico" +IDI_ICON2 ICON DISCARDABLE "icon2.ico" \ No newline at end of file diff --git a/YACReaderLibrary/icon2.ico b/YACReaderLibrary/icon2.ico new file mode 100644 index 0000000000000000000000000000000000000000..e87778428481086fb0b280ade6be220b1425b6a4 GIT binary patch literal 99678 zcmeFa2Yi)vwl0hU(i4ypLI~+~C)w$}_uhL*LJ~rHLJ}Ye0TKwILx9jB^bVnl2#AOX zsHn)GA}T7QjN@?}$K&yMy?p$h?^!R|-W&#L;@oq;@AC8UeY5vlR{O7iTWjqeJ)Y^& zyT{^QAdbm#S(ZiB|$|DVlXO#c*9zN&Ze*m884t_s~Fdxn5hfz)U4W!m7RxCHf`4T z_U-{{&HH)ZP$GiwIzM4t&YgAb?U*)w9;Qy4hiw}=kkBv(CTmZ?Wa(j8%-RZv#x<}_ zEnVI1{vo_SE+oMJo2_eBpm6*|WERxJGh{5{Q%g|V(1O@EK10CyPvLy{Z5S^;1e45~ z_1*68Gi;&fQ zjWqYm(ZR{@ctS!hLLzez99IIzs7egb^M!e6HOzhT;TD*M5jvwfNhdAff5}enHL?lR zcJm1P$=x>@)~-o#3mp&lxEh#;RKY%VHgs%aVCRzwJ!6MWymv_V_sY4swM&}XB?4B? z39$4pf@{WXgr!Y_d&)F8q|CzeCc*HCEQXQFZ`Zx|%HO6|9=k@H`D2W8CR}nC!?SP& zdkKcR0mCCW7fu+y)ZpjUBOqv1f*akR{U5L<%H3+WW zh@i|yc!Z6IcU(2>-NH`ad%w!o*}=ji86lIm!LMRHRB_XwYo7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h-6Mdexv{N9cY`d3a&9JXwCCP zZFyhz{|n1~wmR40Y5rT30o4(7Ah}bY`g4unA#EV#l&v>;U~H^%%MaLE=>=iQE^WJD zU~nW>u3?_J@LSB|Y^lTy>Vw^UO*u$8b_p{NUBKjh=P)^!q$_DWWo0yRW#J1w-_Jz* zk!!g3ml2EVT^Yy!k@pv6-`|g>+n-dXxz3s~@i|F8mSmt@4$5CYaBWFhaB=MjuU>sH z^~0G+-?j(SGL9g8{ZS0vauOr9alexii6h)xBb1R;Wf{gxBs)RfPDq*D_~y% N`wG}s;3->y{{v~kuC)LF literal 0 HcmV?d00001 diff --git a/YACReaderLibrary/images.qrc b/YACReaderLibrary/images.qrc new file mode 100644 index 00000000..92ef8e47 --- /dev/null +++ b/YACReaderLibrary/images.qrc @@ -0,0 +1,41 @@ + + + ../images/deleteLibrary.png + ../images/folder.png + ../images/help.png + ../images/icon.png + ../images/new.png + ../images/openLibrary.png + ../images/removeLibrary.png + ../images/updateLibrary.png + ../images/setRoot.png + ../images/expand.png + ../images/colapse.png + ../images/comicFolder.png + ../images/notCover.png + ../images/edit.png + ../images/fit.png + ../images/properties.png + ../images/options.png + ../images/flow1.png + ../images/flow2.png + ../images/flow3.png + ../images/importLibrary.png + ../images/exportLibrary.png + ../images/open.png + ../images/coversPackage.png + ../images/setRead.png + ../images/setAllRead.png + ../images/setUnread.png + ../images/setAllUnread.png + ../images/showMarks.png + ../images/importCover.png + ../images/editComic.png + ../images/selectAll.png + ../images/hideComicFlow.png + ../images/exportComicsInfo.png + ../images/importComicsInfo.png + ../images/db.png + ../images/asignNumber.png + + \ No newline at end of file diff --git a/YACReaderLibrary/import_comics_info_dialog.cpp b/YACReaderLibrary/import_comics_info_dialog.cpp new file mode 100644 index 00000000..ae240c70 --- /dev/null +++ b/YACReaderLibrary/import_comics_info_dialog.cpp @@ -0,0 +1,111 @@ +#include "import_comics_info_dialog.h" + +#include +#include +#include +#include + +#include "data_base_management.h" + +ImportComicsInfoDialog::ImportComicsInfoDialog(QWidget *parent) + : QDialog(parent) +{ + setModal(true); + setWindowTitle(tr("Import comics info")); + + + textLabel = new QLabel(tr("Info database location : ")); + path = new QLineEdit; + textLabel->setBuddy(path); + + accept = new QPushButton(tr("Import")); + accept->setDisabled(true); + connect(accept,SIGNAL(clicked()),this,SLOT(import())); + + cancel = new QPushButton(tr("Cancel")); + connect(cancel,SIGNAL(clicked()),this,SLOT(close())); + //connect(cancel,SIGNAL(clicked()),this,SIGNAL(rejected())); + + find = new QPushButton(QIcon(":/images/coversPackage.png"),""); + connect(find,SIGNAL(clicked()),this,SLOT(findPath())); + + QHBoxLayout *libraryLayout = new QHBoxLayout; + + libraryLayout->addWidget(textLabel); + libraryLayout->addWidget(path); + libraryLayout->addWidget(find); + libraryLayout->setStretchFactor(find,0); //TODO + + progressBar = new QProgressBar(this); + progressBar->setMinimum(0); + progressBar->setMaximum(0); + progressBar->setTextVisible(false); + progressBar->hide(); + connect(accept,SIGNAL(progressBar()),this,SLOT(show())); + + QHBoxLayout *bottomLayout = new QHBoxLayout; + bottomLayout->addStretch(); + bottomLayout->addWidget(accept); + bottomLayout->addWidget(cancel); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addLayout(libraryLayout); + mainLayout->addStretch(); + mainLayout->addWidget(progressBar); + mainLayout->addLayout(bottomLayout); + + QHBoxLayout * imgMainLayout = new QHBoxLayout; + QLabel * imgLabel = new QLabel(this); + QPixmap p(":/images/importComicsInfo.png"); + imgLabel->setPixmap(p); + imgMainLayout->addWidget(imgLabel); + imgMainLayout->addLayout(mainLayout); + + setLayout(imgMainLayout); + + setModal(true); +} + +ImportComicsInfoDialog::~ImportComicsInfoDialog() +{ + +} + + +void ImportComicsInfoDialog::findPath() +{ + QString s = QFileDialog::getOpenFileName(0,"Comics Info",".",tr("Comics info file (*.ydb)")); + if(!s.isEmpty()) + { + path->setText(s); + accept->setEnabled(true); + } +} + +void ImportComicsInfoDialog::import() +{ + progressBar->show(); + + Importer * importer = new Importer(); + importer->source = path->text(); + importer->dest = dest; + connect(importer,SIGNAL(finished()),this,SLOT(close())); + connect(importer,SIGNAL(finished()),this,SLOT(hide())); + importer->start(); +} + +void ImportComicsInfoDialog::close() +{ + path->clear(); + progressBar->hide(); + accept->setDisabled(true); + QDialog::close(); + emit(finished(0)); +} + +void Importer::run() +{ + DataBaseManagement::importComicsInfo(source,dest); +} + + diff --git a/YACReaderLibrary/import_comics_info_dialog.h b/YACReaderLibrary/import_comics_info_dialog.h new file mode 100644 index 00000000..edc5e85e --- /dev/null +++ b/YACReaderLibrary/import_comics_info_dialog.h @@ -0,0 +1,52 @@ +#ifndef IMPORT_COMICS_INFO_DIALOG_H +#define IMPORT_COMICS_INFO_DIALOG_H + +#include +#include +#include +#include +#include +#include +#include + +class Importer : public QThread +{ +public: + QString source; + QString dest; +private: + void run(); +}; + +class ImportComicsInfoDialog : public QDialog +{ + Q_OBJECT + +public: + ImportComicsInfoDialog(QWidget *parent = 0); + ~ImportComicsInfoDialog(); + QString dest; + +private: + QLabel * nameLabel; + QLabel * textLabel; + QLabel * destLabel; + QLineEdit * path; + QLineEdit * destPath; + QLineEdit * nameEdit; + QPushButton * find; + QPushButton * findDest; + QPushButton * accept; + QPushButton * cancel; + QLabel * progress; + void setupUI(); + int progressCount; + QProgressBar *progressBar; + +public slots: + void findPath(); + void import(); + void close(); +}; + +#endif // IMPORT_COMICS_INFO_DIALOG_H diff --git a/YACReaderLibrary/import_library_dialog.cpp b/YACReaderLibrary/import_library_dialog.cpp new file mode 100644 index 00000000..ad38fd1e --- /dev/null +++ b/YACReaderLibrary/import_library_dialog.cpp @@ -0,0 +1,144 @@ +#include "import_library_dialog.h" + +#include +#include +#include +#include + + +ImportLibraryDialog::ImportLibraryDialog(QWidget * parent) +:QDialog(parent),progressCount(0) +{ + setupUI(); +} + +void ImportLibraryDialog::setupUI() +{ + nameLabel = new QLabel(tr("Library Name : ")); + nameEdit = new QLineEdit; + nameLabel->setBuddy(nameEdit); + connect(nameEdit,SIGNAL(textChanged(QString)),this,SLOT(nameEntered())); + + textLabel = new QLabel(tr("Package location : ")); + path = new QLineEdit; + textLabel->setBuddy(path); + + destLabel = new QLabel(tr("Destination folder : ")); + destPath = new QLineEdit; + textLabel->setBuddy(destPath); + + accept = new QPushButton(tr("Unpack")); + accept->setDisabled(true); + connect(accept,SIGNAL(clicked()),this,SLOT(add())); + + cancel = new QPushButton(tr("Cancel")); + connect(cancel,SIGNAL(clicked()),this,SLOT(close())); + //connect(cancel,SIGNAL(clicked()),this,SIGNAL(rejected())); + + find = new QPushButton(QIcon(":/images/coversPackage.png"),""); + connect(find,SIGNAL(clicked()),this,SLOT(findPath())); + + findDest = new QPushButton(QIcon(":/images/open.png"),""); + connect(findDest,SIGNAL(clicked()),this,SLOT(findDestination())); + + QGridLayout * content = new QGridLayout; + + content->addWidget(nameLabel,0,0); + content->addWidget(nameEdit,0,1); + + content->addWidget(textLabel,1,0); + content->addWidget(path,1,1); + content->addWidget(find,1,2); + content->setColumnStretch(2,0); //TODO + + content->addWidget(destLabel,2,0); + content->addWidget(destPath,2,1); + content->addWidget(findDest,2,2); + //destLayout->setStretchFactor(findDest,0); //TODO + + QHBoxLayout *bottomLayout = new QHBoxLayout; + bottomLayout->addStretch(); + bottomLayout->addWidget(accept); + bottomLayout->addWidget(cancel); + + progressBar = new QProgressBar(this); + progressBar->setMinimum(0); + progressBar->setMaximum(0); + progressBar->setTextVisible(false); + progressBar->hide(); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addLayout(content); + //mainLayout->addWidget(progress = new QLabel()); + mainLayout->addStretch(); + mainLayout->addWidget(progressBar); + mainLayout->addLayout(bottomLayout); + + QHBoxLayout * imgMainLayout = new QHBoxLayout; + QLabel * imgLabel = new QLabel(this); + QPixmap p(":/images/importLibrary.png"); + imgLabel->setPixmap(p); + imgMainLayout->addWidget(imgLabel); + imgMainLayout->addLayout(mainLayout); + + setLayout(imgMainLayout); + + setModal(true); + setWindowTitle(tr("Extract a catalog")); +} + +void ImportLibraryDialog::add() +{ + accept->setEnabled(false); + progressBar->show(); + emit(unpackCLC(QDir::cleanPath(path->text()),QDir::cleanPath(destPath->text()),nameEdit->text())); +} + +void ImportLibraryDialog::findPath() +{ + QString s = QFileDialog::getOpenFileName(0,"Covers Package",".",tr("Compresed library covers (*.clc)")); + if(!s.isEmpty()) + { + path->setText(s); + if(!destPath->text().isEmpty() && !nameEdit->text().isEmpty()) + accept->setEnabled(true); + } +} + + +void ImportLibraryDialog::findDestination() +{ + QString s = QFileDialog::getExistingDirectory(0,"Folder",".",QFileDialog::ShowDirsOnly); + if(!s.isEmpty()) + { + destPath->setText(s); + if(!path->text().isEmpty() && !nameEdit->text().isEmpty()) + accept->setEnabled(true); + } +} + +void ImportLibraryDialog::nameEntered() +{ + if(!nameEdit->text().isEmpty()) + { + if(!path->text().isEmpty() && !destPath->text().isEmpty()) + accept->setEnabled(true); + } + else + accept->setEnabled(false); +} + +void ImportLibraryDialog::close() +{ + path->clear(); + destPath->clear(); + nameEdit->clear(); + accept->setEnabled(false); + progressBar->hide(); + QDialog::hide(); +} + +void ImportLibraryDialog::closeEvent ( QCloseEvent * e ) +{ + close(); +} diff --git a/YACReaderLibrary/import_library_dialog.h b/YACReaderLibrary/import_library_dialog.h new file mode 100644 index 00000000..7c4f9305 --- /dev/null +++ b/YACReaderLibrary/import_library_dialog.h @@ -0,0 +1,43 @@ +#ifndef IMPORT_LIBRARY_DIALOG_H +#define IMPORT_LIBRARY_DIALOG_H + + +#include +#include +#include +#include +#include +#include + + class ImportLibraryDialog : public QDialog + { + Q_OBJECT + public: + ImportLibraryDialog(QWidget * parent = 0); + private: + QLabel * nameLabel; + QLabel * textLabel; + QLabel * destLabel; + QLineEdit * path; + QLineEdit * destPath; + QLineEdit * nameEdit; + QPushButton * find; + QPushButton * findDest; + QPushButton * accept; + QPushButton * cancel; + QProgressBar *progressBar; + void setupUI(); + int progressCount; + void closeEvent ( QCloseEvent * e ); + public slots: + void add(); + void findPath(); + void findDestination(); + void close(); + void nameEntered(); + + signals: + void unpackCLC(QString clc,QString targetFolder, QString name); + }; + +#endif diff --git a/YACReaderLibrary/library_creator.cpp b/YACReaderLibrary/library_creator.cpp new file mode 100644 index 00000000..8a4e1d88 --- /dev/null +++ b/YACReaderLibrary/library_creator.cpp @@ -0,0 +1,487 @@ +#include "library_creator.h" +#include "custom_widgets.h" + +#include +#include +#include +#include +#include "data_base_management.h" +#include "qnaturalsorting.h" + +#include +using namespace std; + +//QMutex mutex; + + + +/*int numThreads = 0; +QWaitCondition waitCondition; +QMutex mutex; +*/ + + +//-------------------------------------------------------------------------------- +LibraryCreator::LibraryCreator() +{ + _nameFilter << "*.cbr" << "*.cbz" << "*.rar" << "*.zip" << "*.tar"; +} + +void LibraryCreator::createLibrary(const QString &source, const QString &target) +{ + processLibrary(source,target); +} + +void LibraryCreator::updateLibrary(const QString &source, const QString &target) +{ + processLibrary(source,target); +} + +void LibraryCreator::processLibrary(const QString & source, const QString & target) +{ + _source = source; + _target = target; + //if(!(QFile(target+"/library.ydb").exists())) //TODO, no sirve sólo con realizar el update, hay que validar la base de datos y determinar si existe "/covers" + if(DataBaseManagement::checkValidDB(target+"/library.ydb")=="") + { + //se limpia el directorio ./yacreaderlibrary + delTree(target); + _mode = CREATOR; + } + else + _mode = UPDATER; +} + + +// +void LibraryCreator::run() +{ + stopRunning = false; + + if(_mode == CREATOR) + { + _currentPathFolders.clear(); + _currentPathFolders.append(Folder(1,1,"root","/")); + //se crean los directorios .yacreaderlibrary y .yacreaderlibrary/covers + QDir dir; + dir.mkpath(_target+"/covers"); + + //se crea la base de datos .yacreaderlibrary/library.ydb + _database = DataBaseManagement::createDatabase("library",_target);// + /*if(!_database.open()) + return; //TODO avisar del problema + + QSqlQuery pragma("PRAGMA foreign_keys = ON",_database);*/ + _database.transaction(); + //se crea la librería + create(QDir(_source)); + _database.commit(); + _database.close(); + QSqlDatabase::removeDatabase(_database.connectionName()); + emit(created()); + } + else + { + _currentPathFolders.clear(); + _currentPathFolders.append(Folder(1,1,"root","/")); + _database = DataBaseManagement::loadDatabase(_target); + //_database.setDatabaseName(_target+"/library.ydb"); + /*if(!_database.open()) + return; //TODO avisar del problema*/ + //QSqlQuery pragma("PRAGMA foreign_keys = ON",_database); + _database.transaction(); + update(QDir(_source)); + _database.commit(); + _database.close(); + QSqlDatabase::removeDatabase(_target); + emit(updated()); + } + msleep(100);//TODO try to solve the problem with the udpate dialog + emit(finished()); +} + +void LibraryCreator::stop() +{ + _database.commit(); //TODO check + stopRunning = true; +} + +//retorna el id del ultimo de los folders +qulonglong LibraryCreator::insertFolders() +{ + QList::iterator i; + int currentId = 0; + for (i = _currentPathFolders.begin(); i != _currentPathFolders.end(); ++i) + { + if(!(i->knownId)) + { + i->setFather(currentId); + currentId = i->insert(_database);//insertFolder(currentId,*i); + i->setId(currentId); + } + else + { + currentId = i->id; + } + } + return 0; +} + +/*qulonglong LibraryCreator::insertFolder(qulonglong parentId,const Folder & folder) +{ + QSqlQuery query(_database); + query.prepare("INSERT INTO folder (parentId, name, path) " + "VALUES (:parentId, :name, :path)"); + query.bindValue(":parentId", parentId); + query.bindValue(":name", folder.name); + query.bindValue(":path", folder.path); + query.exec(); + return query.lastInsertId().toULongLong(); +}*/ + +/*qulonglong LibraryCreator::insertComic(const Comic & comic) +{ + //TODO comprobar si ya hay comic info con ese hash + QSqlQuery comicInfoInsert(_database); + comicInfoInsert.prepare("INSERT INTO comic_info (hash) " + "VALUES (:hash)"); + comicInfoInsert.bindValue(":hash", comic.hash); + comicInfoInsert.exec(); + qulonglong comicInfoId =comicInfoInsert.lastInsertId().toULongLong(); + + QSqlQuery query(_database); + query.prepare("INSERT INTO comic (parentId, comicInfoId, fileName, path) " + "VALUES (:parentId,:comicInfoId,:name, :path)"); + query.bindValue(":parentId", comic.parentId); + query.bindValue(":comicInfoId", comicInfoId); + query.bindValue(":name", comic.name); + query.bindValue(":path", comic.path); + query.exec(); + return query.lastInsertId().toULongLong(); +}*/ + +void LibraryCreator::create(QDir dir) +{ + dir.setNameFilters(_nameFilter); + dir.setFilter(QDir::AllDirs|QDir::Files|QDir::NoDotAndDotDot); + QFileInfoList list = dir.entryInfoList(); + for (int i = 0; i < list.size(); ++i) + { + if(stopRunning) + return; + QFileInfo fileInfo = list.at(i); + QString fileName = fileInfo.fileName(); + QString relativePath = QDir::cleanPath(fileInfo.absoluteFilePath()).remove(_source); + if(fileInfo.isDir()) + { + //se añade al path actual el folder, aún no se sabe si habrá que añadirlo a la base de datos + _currentPathFolders.append(Folder(fileInfo.fileName(),relativePath)); + create(QDir(fileInfo.absoluteFilePath())); + //una vez importada la información del folder, se retira del path actual ya que no volverá a ser visitado + _currentPathFolders.pop_back(); + } + else + { + insertComic(relativePath,fileInfo); + } + } +} + +bool LibraryCreator::checkCover(const QString & hash) +{ + return QFile::exists(_target+"/covers/"+hash+".jpg"); +} + +void LibraryCreator::insertComic(const QString & relativePath,const QFileInfo & fileInfo) +{ + //en este punto sabemos que todos los folders que hay en _currentPath, deberían estar añadidos a la base de datos + insertFolders(); + emit(coverExtracted(relativePath)); + + //Se calcula el hash del cómic + + QCryptographicHash crypto(QCryptographicHash::Sha1); + QFile file(fileInfo.absoluteFilePath()); + file.open(QFile::ReadOnly); + crypto.addData(file.read(524288)); + file.close(); + //hash Sha1 del primer 0.5MB + filesize + QString hash = QString(crypto.result().toHex().constData()) + QString::number(fileInfo.size()); + Comic comic(_currentPathFolders.last().id,fileInfo.fileName(),relativePath,hash,_database); + int numPages; + + if(! ( comic.hasCover() && checkCover(hash))) + { + ThumbnailCreator tc(QDir::cleanPath(fileInfo.absoluteFilePath()),_target+"/covers/"+hash+".jpg",*comic.info.coverPage); + //ThumbnailCreator tc(QDir::cleanPath(fileInfo.absoluteFilePath()),_target+"/covers/"+fileInfo.fileName()+".jpg"); + tc.create(); + numPages = tc.getNumPages(); + } + comic.info.setNumPages(numPages); + comic.insert(_database); +} + +void LibraryCreator::update(QDir dirS) +{ + dirS.setNameFilters(_nameFilter); + dirS.setFilter(QDir::AllDirs|QDir::Files|QDir::NoDotAndDotDot); + dirS.setSorting(QDir::Name|QDir::IgnoreCase|QDir::LocaleAware|QDir::DirsFirst); //TODO la ordenación debe ser igual que en la base de datos + //TODO obtener primero los directorios, después los ficheros, ordenar por separado y concatenar + QFileInfoList listS = dirS.entryInfoList(); + + QList folders = Folder::getFoldersFromParent(_currentPathFolders.last().id,_database); + QList comics = Comic::getComicsFromParent(_currentPathFolders.last().id,_database); + + QList listD; + listD.append(folders); + listD.append(comics); + + int lenghtS = listS.size(); + int lenghtD = listD.size(); + int maxLenght = qMax(lenghtS,lenghtD); + + bool updated; + int i,j; + for (i=0,j=0; (i < lenghtS)||(j < lenghtD);) + { + if(stopRunning) + return; + updated = false; + if(i>=lenghtS) //finished source files/dirs + { + //delete listD //from j + for(;jremoveFromDB(_database); + } + updated = true; + } + if(j>=lenghtD) //finished library files/dirs + { + //create listS //from i + for(;iname; + + int comparation = QString::localeAwareCompare(nameS,nameD); + if(fileInfoS.isDir()&&fileInfoD->isDir()) + if(comparation == 0)//same folder, update + { + _currentPathFolders.append(*static_cast(fileInfoD));//fileInfoD conoce su padre y su id + update(QDir(fileInfoS.absoluteFilePath())); + _currentPathFolders.pop_back(); + i++; + j++; + } + else + if(comparation < 0) //nameS doesn't exist on DB + { + if(nameS!="/.yacreaderlibrary") + { + _currentPathFolders.append(Folder(fileInfoS.fileName(),QDir::cleanPath(fileInfoS.absoluteFilePath()).remove(_source))); + create(QDir(fileInfoS.absoluteFilePath())); + _currentPathFolders.pop_back(); + } + i++; + } + else //nameD no longer avaliable on Source folder... + { + if(nameS!="/.yacreaderlibrary") + { + fileInfoD->removeFromDB(_database); + j++; + } + else + i++; //skip library directory + } + else // one of them(or both) is a file + if(fileInfoS.isDir()) //this folder doesn't exist on library + { + if(nameS!="/.yacreaderlibrary") //skip .yacreaderlibrary folder + { + _currentPathFolders.append(Folder(fileInfoS.fileName(),QDir::cleanPath(fileInfoS.absoluteFilePath()).remove(_source))); + create(QDir(fileInfoS.absoluteFilePath())); + _currentPathFolders.pop_back(); + } + i++; + } + else + if(fileInfoD->isDir()) //delete this folder from library + { + fileInfoD->removeFromDB(_database); + j++; + } + else //both are files //BUG on windows (no case sensitive) + { + //nameD.remove(nameD.size()-4,4); + int comparation = QString::localeAwareCompare(nameS,nameD); + if(comparation < 0) //create new thumbnail + { + insertComic(QDir::cleanPath(fileInfoS.absoluteFilePath()).remove(_source),fileInfoS); + i++; + } + else + { + if(comparation > 0) //delete thumbnail + { + fileInfoD->removeFromDB(_database); + j++; + } + else //same file + { + if(fileInfoS.isFile() && !fileInfoD->isDir()) + { + //TODO comprobar fechas + tamaño + //if(fileInfoS.lastModified()>fileInfoD.lastModified()) + //{ + // dirD.mkpath(_target+(QDir::cleanPath(fileInfoS.absolutePath()).remove(_source))); + // emit(coverExtracted(QDir::cleanPath(fileInfoS.absoluteFilePath()).remove(_source))); + // ThumbnailCreator tc(QDir::cleanPath(fileInfoS.absoluteFilePath()),_target+(QDir::cleanPath(fileInfoS.absoluteFilePath()).remove(_source))+".jpg"); + // tc.create(); + //} + } + i++;j++; + } + } + } + } + } +} +ThumbnailCreator::ThumbnailCreator(QString fileSource, QString target="", int coverPage) +:_fileSource(fileSource),_target(target),_numPages(0),_coverPage(coverPage) +{ +} + +void ThumbnailCreator::create() +{ + _7z = new QProcess(); + QStringList attributes; + attributes << "l" << "-ssc-" << "-r" << _fileSource << "*.jpg" << "*.jpeg" << "*.png" << "*.gif" << "*.tiff" << "*.tif" << "*.bmp"; + //connect(_7z,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(loadFirstImage(void))); + connect(_7z,SIGNAL(error(QProcess::ProcessError)),this,SIGNAL(openingError(QProcess::ProcessError))); + _7z->start(QCoreApplication::applicationDirPath()+"/utils/7z",attributes); + _7z->waitForFinished(60000); + + QRegExp rx("[0-9]{4}-[0-9]{2}-[0-9]{2}[ ]+[0-9]{2}:[0-9]{2}:[0-9]{2}[ ]+.{5}[ ]+([0-9]+)[ ]+([0-9]+)[ ]+(.+)"); + + QString ba = QString::fromUtf8(_7z->readAllStandardOutput()); + QList lines = ba.split('\n'); + QString line; + _currentName = "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"; //TODO + QString name; + if(_coverPage == 1) + { + foreach(line,lines) + { + if(rx.indexIn(line)!=-1) + { + name = rx.cap(3).trimmed(); + if(naturalSortLessThanCI(name,_currentName)) + _currentName = name; + _numPages++; + } + } + } + else + { + QList names; + foreach(line,lines) + { + if(rx.indexIn(line)!=-1) + { + name = rx. cap(3).trimmed(); + names.append(name); + } + } + std::sort(names.begin(),names.end(),naturalSortLessThanCI); + _currentName = names[_coverPage-1]; + } + delete _7z; + attributes.clear(); + _currentName = QDir::fromNativeSeparators(_currentName).split('/').last(); //separator fixed. +#ifdef Q_WS_WIN + attributes << "e" << "-so" << "-r" << _fileSource << QString(_currentName.toLocal8Bit().constData()); //TODO platform dependency?? OEM 437 +#else + attributes << "e" << "-so" << "-r" << _fileSource << _currentName; //TODO platform dependency?? OEM 437 +#endif + _7z = new QProcess(); + connect(_7z,SIGNAL(error(QProcess::ProcessError)),this,SIGNAL(openingError(QProcess::ProcessError))); + //connect(_7z,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(writeThumbnail(void))); + _7z->start(QCoreApplication::applicationDirPath()+"/utils/7z",attributes); + _7z->waitForFinished(60000); + + QByteArray image = _7z->readAllStandardOutput(); + QString error = _7z->readAllStandardError(); + QImage p; + if(_target=="") + { + if(!_cover.loadFromData(image)) + _cover.load(":/images/notCover.png"); + } + else + { + if(p.loadFromData(image)) + { + //TODO calculate aspect ratio + QImage scaled; + if(p.width()>p.height()) //landscape?? + scaled = p.scaledToWidth(640,Qt::SmoothTransformation); + else + scaled = p.scaledToWidth(480,Qt::SmoothTransformation); + scaled.save(_target,0,75); + } + else + { + p.load(":/images/notCover.png"); + p.save(_target); + //TODO save a default image. + } + } + delete _7z; +} + +/*void ThumbnailCreator::openingError(QProcess::ProcessError error) +{ + //TODO : move to the gui thread + switch(error) + { + case QProcess::FailedToStart: + QMessageBox::critical(NULL,tr("7z not found"),tr("7z wasn't found in your PATH.")); + break; + case QProcess::Crashed: + QMessageBox::critical(NULL,tr("7z crashed"),tr("7z crashed.")); + break; + case QProcess::ReadError: + QMessageBox::critical(NULL,tr("7z reading"),tr("problem reading from 7z")); + break; + case QProcess::UnknownError: + QMessageBox::critical(NULL,tr("7z problem"),tr("Unknown error 7z")); + break; + default: + //TODO + break; + } +}*/ diff --git a/YACReaderLibrary/library_creator.h b/YACReaderLibrary/library_creator.h new file mode 100644 index 00000000..dedd7043 --- /dev/null +++ b/YACReaderLibrary/library_creator.h @@ -0,0 +1,81 @@ +#ifndef __LIBRARY_CREATOR_H +#define __LIBRARY_CREATOR_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "folder.h" +#include "comic.h" + + + class LibraryCreator : public QThread + { + Q_OBJECT + public: + LibraryCreator(); + void createLibrary(const QString & source, const QString & target); + void updateLibrary(const QString & source, const QString & target); + void stop(); + private: + void processLibrary(const QString & source, const QString & target); + enum Mode {CREATOR,UPDATER}; + //atributos "globales" durante el proceso de creación y actualización + enum Mode _mode; + QString _source; + QString _target; + QStringList _nameFilter; + QSqlDatabase _database; + QList _currentPathFolders; //lista de folders en el orden en el que están siendo explorados, el último es el folder actual + //recursive method + void create(QDir currentDirectory); + void update(QDir currentDirectory); + void run(); + qulonglong insertFolders();//devuelve el id del último folder añadido (último en la ruta) + bool checkCover(const QString & hash); + void insertComic(const QString & relativePath,const QFileInfo & fileInfo); + //qulonglong insertFolder(qulonglong parentId,const Folder & folder); + //qulonglong insertComic(const Comic & comic); + bool stopRunning; + signals: + void finished(); + void coverExtracted(QString); + void folderUpdated(QString); + void updated(); + void created(); + }; + + class ThumbnailCreator : public QObject + { + Q_OBJECT + + public: + ThumbnailCreator(QString fileSource, QString target, int coverPage = 1); + private: + QProcess * _7z; + QString _fileSource; + QString _target; + QString _currentName; + int _numPages; + QPixmap _cover; + int _coverPage; + + public slots: + void create(); + int getNumPages(){return _numPages;}; + QPixmap getCover(){return _cover;}; + signals: + void openingError(QProcess::ProcessError error); + + }; + +#endif diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp new file mode 100644 index 00000000..3d80075d --- /dev/null +++ b/YACReaderLibrary/library_window.cpp @@ -0,0 +1,1328 @@ +#include "library_window.h" +#include "custom_widgets.h" +#include "treeitem.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "data_base_management.h" +#include "check_new_version.h" + +// + +LibraryWindow::LibraryWindow() + :QMainWindow(),skip(0),fullscreen(false),fetching(false) +{ + setupUI(); + loadLibraries(); +} + +void LibraryWindow::setupUI() +{ + libraryCreator = new LibraryCreator(); + packageManager = new PackageManager(); + + doModels(); + doDialogs(); + doLayout(); + createActions(); + createToolBars(); + createMenus(); + createConnections(); + + setWindowTitle(tr("YACReader Library")); +} + +void LibraryWindow::doLayout() +{ + sVertical = new QSplitter(Qt::Vertical); //spliter derecha + QSplitter * sHorizontal = new QSplitter(Qt::Horizontal); //spliter principal + //TODO: flowType is a global variable + //CONFIG COMIC_FLOW-------------------------------------------------------- + comicFlow = new ComicFlow(0,flowType); + comicFlow->setFocusPolicy(Qt::StrongFocus); + comicFlow->setShowMarks(true); + QMatrix m; + m.rotate(-90); + m.scale(-1,1); + comicFlow->setMarkImage(QImage(":/images/setRead.png").transformed(m,Qt::SmoothTransformation)); + int heightDesktopResolution = QApplication::desktop()->screenGeometry().height(); + int height,width; + height = heightDesktopResolution*0.39; + width = height*0.65; + slideSizeW = QSize(width,height); + height = heightDesktopResolution*0.55; + width = height*0.70; + slideSizeF = QSize(width,height); + comicFlow->setSlideSize(slideSizeW); + setFocusProxy(comicFlow); + //------------------------------------------------------------------------- + + //CONFIG TREE/TABLE VIEWS-------------------------------------------------- + comicView = new QTableView; + foldersView = new QTreeView; + //------------------------------------------------------------------------- + + //CONFIG FOLDERS/COMICS------------------------------------------------------- + /*sVertical->setStretchFactor(0,1); + sVertical->setStretchFactor(1,0); + */ + //views + //foldersView->setAnimated(true); + foldersView->setContextMenuPolicy(Qt::ActionsContextMenu); + foldersView->setContextMenuPolicy(Qt::ActionsContextMenu); + foldersView->header()->hide(); + foldersView->setUniformRowHeights(true); + foldersView->setSelectionBehavior(QAbstractItemView::SelectRows); + + comicView->setAlternatingRowColors(true); + //comicView->setStyleSheet("alternate-background-color: #e7e7d7;background-color: white;"); + //comicView->setItemDelegate(new YACReaderComicViewDelegate()); + comicView->setContextMenuPolicy(Qt::ActionsContextMenu); + comicView->setShowGrid(false); + //comicView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); + comicView->horizontalHeader()->setStretchLastSection(true); + comicView->horizontalHeader()->setClickable(false); + //comicView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents); + comicView->verticalHeader()->setDefaultSectionSize(24); + comicView->verticalHeader()->setClickable(false); //TODO comportamiento anómalo + comicView->setCornerButtonEnabled(false); + qApp->setStyleSheet ( qApp->styleSheet() +" QTableView::item{border-right-style:solid;border-width:1;border-color: #d7d7c7;} QTableView::item:selected{background-color: #d7d7c7; color:#000000; border-right-style:solid;border-width:1;border-color: #8c8590;}"); + //qApp->setStyleSheet ( qApp->styleSheet() +" QTableView {selection-background-color: #d7d7c7; selection-color: #000000;}" ); + + /*comicView->setStyleSheet("QTableView {selection-background-color: #d7d7c7; selection-color: #000000; selection-border: 1px solid;}\n QTableView::item{" +"border-right-style:solid;" +"border-width:1;" +"border-color: #DEDEDE;" +"}");*/ +// comicView->verticalHeader()->setStyleSheet("QHeaderView::section" +//"{" +// "background-color: white /* steelblue */" +//"}"); + comicView->setSelectionBehavior(QAbstractItemView::SelectRows); + comicView->setSelectionMode(QAbstractItemView::ExtendedSelection); + //------------------------------------------------------------------------- + + //CONFIG NAVEGACIÓN/BÚSQUEDA----------------------------------------------- + left = new QWidget; + QVBoxLayout * l = new QVBoxLayout; + selectedLibrary = new QComboBox; + l->setContentsMargins(2,2,0,0); + l->addWidget(new QLabel(tr("Select a library:"))); + l->addWidget(selectedLibrary); + treeActions = new QToolBar(left); + treeActions->setIconSize(QSize(16,16)); + l->addWidget(treeActions); + l->addWidget(foldersView); + + QVBoxLayout * searchLayout = new QVBoxLayout; + + QHBoxLayout * filter = new QHBoxLayout; + filter->addWidget(foldersFilter = new QLineEdit()); + previousFilter = ""; + filter->addWidget(clearFoldersFilter = new QPushButton(tr("Clear"))); + + searchLayout->addWidget(new QLabel(tr("Search folders/comics"),this)); + + searchLayout->addLayout(filter); + includeComicsCheckBox = new QCheckBox(tr("Include files (slower)"),this); + includeComicsCheckBox->setChecked(true); + searchLayout->addWidget(includeComicsCheckBox); + + l->addLayout(searchLayout); + l->setSpacing(1); + left->setLayout(l); + //------------------------------------------------------------------------- + + //FINAL LAYOUT------------------------------------------------------------- + sVertical->addWidget(comicFlow); + comics = new QWidget; + QVBoxLayout * comicsLayout = new QVBoxLayout; + comicsLayout->setContentsMargins(2,2,0,0); + comicsLayout->addWidget(editInfoToolBar = new QToolBar(comics)); + comicsLayout->addWidget(comicView); + comics->setLayout(comicsLayout); + sVertical->addWidget(comics); + sHorizontal->addWidget(left); + sHorizontal->addWidget(sVertical); + sHorizontal->setStretchFactor(0,0); + sHorizontal->setStretchFactor(1,1); + setCentralWidget(sHorizontal); + //FINAL LAYOUT------------------------------------------------------------- + + fullScreenToolTip = new QLabel(this); + fullScreenToolTip->setText(tr(" press 'F' to close fullscreen mode ")); + fullScreenToolTip->setPalette(QPalette(QColor(0,0,0))); + fullScreenToolTip->setFont(QFont("courier new",15,234)); + fullScreenToolTip->setAutoFillBackground(true); + fullScreenToolTip->hide(); + fullScreenToolTip->adjustSize(); + + comicFlow->setFocus(Qt::OtherFocusReason); +} + +void LibraryWindow::doDialogs() +{ + createLibraryDialog = new CreateLibraryDialog(this); + updateLibraryDialog = new UpdateLibraryDialog(this); + renameLibraryDialog = new RenameLibraryDialog(this); + propertiesDialog = new PropertiesDialog(this); + exportLibraryDialog = new ExportLibraryDialog(this); + importLibraryDialog = new ImportLibraryDialog(this); + exportComicsInfoDialog = new ExportComicsInfoDialog(this); + importComicsInfoDialog = new ImportComicsInfoDialog(this); + addLibraryDialog = new AddLibraryDialog(this); + optionsDialog = new OptionsDialog(this); + optionsDialog->restoreOptions(); + had = new HelpAboutDialog(this); //TODO load data. + QString sufix = QLocale::system().name(); + if(QFile(":/files/about_"+sufix+".html").exists()) + had->loadAboutInformation(":/files/about_"+sufix+".html"); + else + had->loadAboutInformation(":/files/about.html"); + + if(QFile(":/files/helpYACReaderLibrary_"+sufix+".html").exists()) + had->loadHelp(":/files/helpYACReaderLibrary_"+sufix+".html"); + else + had->loadHelp(":/files/helpYACReaderLibrary.html"); +} + +void LibraryWindow::doModels() +{ + //dirmodels + dm = new TreeModel(); + dmCV = new TableModel(); + sm = new QItemSelectionModel(dm); + + + /*proxyFilter = new YACReaderTreeSearch(); + proxyFilter->setSourceModel(dm); + proxyFilter->setFilterRole(Qt::DisplayRole);*/ + + /*proxySort = new YACReaderSortComics(); + proxySort->setSourceModel(dmCV); + proxySort->setFilterRole(Qt::DisplayRole);*/ + setFoldersFilter(""); +} + +void LibraryWindow::createActions() +{ + createLibraryAction = new QAction(this); + createLibraryAction->setToolTip(tr("Create a new library")); + createLibraryAction->setShortcut(Qt::Key_C); + createLibraryAction->setIcon(QIcon(":/images/new.png")); + + openLibraryAction = new QAction(this); + openLibraryAction->setToolTip(tr("Open an existing library")); + openLibraryAction->setShortcut(Qt::Key_O); + openLibraryAction->setIcon(QIcon(":/images/openLibrary.png")); + + exportComicsInfo = new QAction(tr("Export comics info"),this); + exportComicsInfo->setToolTip(tr("Export comics info")); + exportComicsInfo->setIcon(QIcon(":/images/exportComicsInfo.png")); + + importComicsInfo = new QAction(tr("Import comics info"),this); + importComicsInfo->setToolTip(tr("Import comics info")); + importComicsInfo->setIcon(QIcon(":/images/importComicsInfo.png")); + + exportLibraryAction = new QAction(tr("Pack covers"),this); + exportLibraryAction->setToolTip(tr("Pack the covers of the selected library")); + exportLibraryAction->setIcon(QIcon(":/images/exportLibrary.png")); + + importLibraryAction = new QAction(tr("Unpack covers"),this); + importLibraryAction->setToolTip(tr("Unpack a catalog")); + importLibraryAction->setIcon(QIcon(":/images/importLibrary.png")); + + updateLibraryAction = new QAction(this); + updateLibraryAction->setToolTip(tr("Update current library")); + updateLibraryAction->setShortcut(Qt::Key_U); + updateLibraryAction->setIcon(QIcon(":/images/updateLibrary.png")); + + renameLibraryAction = new QAction(this); + renameLibraryAction->setToolTip(tr("Rename current library")); + renameLibraryAction->setShortcut(Qt::Key_R); + renameLibraryAction->setIcon(QIcon(":/images/edit.png")); + + deleteLibraryAction = new QAction(this); + deleteLibraryAction->setToolTip(tr("Delete current library from disk")); + deleteLibraryAction->setIcon(QIcon(":/images/deleteLibrary.png")); + + removeLibraryAction = new QAction(this); + removeLibraryAction->setToolTip(tr("Remove current library from your collection")); + removeLibraryAction->setIcon(QIcon(":/images/removeLibrary.png")); + + openComicAction = new QAction(this); + openComicAction->setToolTip(tr("Open current comic on YACReader")); + openComicAction->setShortcut(Qt::Key_Return); + openComicAction->setIcon(QIcon(":/images/icon.png")); + + setAsReadAction = new QAction(tr("Set as read"),this); + setAsReadAction->setToolTip(tr("Set comic as read")); + setAsReadAction->setIcon(QIcon(":/images/setRead.png")); + + setAsNonReadAction = new QAction(tr("Set as unread"),this); + setAsNonReadAction->setToolTip(tr("Set comic as unread")); + setAsNonReadAction->setIcon(QIcon(":/images/setUnread.png")); + + setAllAsReadAction = new QAction(tr("Set all as read"),this); + setAllAsReadAction->setToolTip(tr("Set all comics as read")); + setAllAsReadAction->setIcon(QIcon(":/images/setAllRead.png")); + + setAllAsNonReadAction = new QAction(tr("Set all as unread"),this); + setAllAsNonReadAction->setToolTip(tr("Set all comics as unread")); + setAllAsNonReadAction->setIcon(QIcon(":/images/setAllUnread.png")); + + showHideMarksAction = new QAction(tr("Show/Hide marks"),this); + showHideMarksAction->setToolTip(tr("Show or hide readed marks")); + showHideMarksAction->setShortcut(Qt::Key_M); + showHideMarksAction->setCheckable(true); + showHideMarksAction->setIcon(QIcon(":/images/showMarks.png")); + showHideMarksAction->setChecked(true); + + + showPropertiesAction = new QAction(this); + showPropertiesAction->setToolTip(tr("Show properties of current comic")); + showPropertiesAction->setShortcut(Qt::Key_P); + showPropertiesAction->setIcon(QIcon(":/images/properties.png")); + + toggleFullScreenAction = new QAction(this); + toggleFullScreenAction->setToolTip(tr("Fullscreen mode on/off (F)")); + toggleFullScreenAction->setShortcut(Qt::Key_F); + toggleFullScreenAction->setIcon(QIcon(":/images/fit.png")); + + helpAboutAction = new QAction(this); + helpAboutAction->setToolTip(tr("Help, About YACReader")); + helpAboutAction->setShortcut(Qt::Key_F1); + helpAboutAction->setIcon(QIcon(":/images/help.png")); + + setRootIndexAction = new QAction(this); + setRootIndexAction->setToolTip(tr("Select root node")); + setRootIndexAction->setIcon(QIcon(":/images/setRoot.png")); + + expandAllNodesAction = new QAction(this); + expandAllNodesAction->setToolTip(tr("Expand all nodes")); + expandAllNodesAction->setIcon(QIcon(":/images/expand.png")); + + colapseAllNodesAction = new QAction(this); + colapseAllNodesAction->setToolTip(tr("Colapse all nodes")); + colapseAllNodesAction->setIcon(QIcon(":/images/colapse.png")); + + optionsAction = new QAction(this); + optionsAction->setToolTip(tr("Show options dialog")); + optionsAction->setIcon(QIcon(":/images/options.png")); + + //disable actions + updateLibraryAction->setEnabled(false); + renameLibraryAction->setEnabled(false); + deleteLibraryAction->setEnabled(false); + removeLibraryAction->setEnabled(false); + openComicAction->setEnabled(false); + showPropertiesAction->setEnabled(false); + setAsReadAction->setEnabled(false); + setAsNonReadAction->setEnabled(false); + setAllAsReadAction->setEnabled(false); + setAllAsNonReadAction->setEnabled(false); + + openContainingFolderAction = new QAction(this); + openContainingFolderAction->setText(tr("Open folder...")); + openContainingFolderAction->setIcon(QIcon(":/images/open.png")); + + openContainingFolderComicAction = new QAction(this); + openContainingFolderComicAction->setText(tr("Open containing folder...")); + openContainingFolderComicAction->setIcon(QIcon(":/images/open.png")); + + //Edit comics actions------------------------------------------------------ + selectAllComicsAction = new QAction(this); + selectAllComicsAction->setText(tr("Select all comics")); + selectAllComicsAction->setIcon(QIcon(":/images/selectAll.png")); + + editSelectedComicsAction = new QAction(this); + editSelectedComicsAction->setText(tr("Edit")); + editSelectedComicsAction->setIcon(QIcon(":/images/editComic.png")); + + asignOrderActions = new QAction(this); + asignOrderActions->setText(tr("Asign current order to comics")); + asignOrderActions->setIcon(QIcon(":/images/asignNumber.png")); + + forceConverExtractedAction = new QAction(this); + forceConverExtractedAction->setText(tr("Update cover")); + forceConverExtractedAction->setIcon(QIcon(":/images/importCover.png")); + + hideComicViewAction = new QAction(this); + hideComicViewAction->setText(tr("Hide comic flow")); + hideComicViewAction->setIcon(QIcon(":/images/hideComicFlow.png")); + hideComicViewAction->setCheckable(true); + hideComicViewAction->setChecked(false); + //------------------------------------------------------------------------- +} + +//TODO unificar con disableActions +void LibraryWindow::disableAllActions() +{ + updateLibraryAction->setEnabled(false); + renameLibraryAction->setEnabled(false); + deleteLibraryAction->setEnabled(false); + removeLibraryAction->setEnabled(false); + foldersFilter->setEnabled(false); + clearFoldersFilter->setEnabled(false); + setAsReadAction->setEnabled(false); + setAsNonReadAction->setEnabled(false); + setAllAsReadAction->setEnabled(false); + setAllAsNonReadAction->setEnabled(false); + selectAllComicsAction->setEnabled(false); + editSelectedComicsAction->setEnabled(false); + asignOrderActions->setEnabled(false); +} + +//librería de sólo lectura +void LibraryWindow::disableActions() +{ + updateLibraryAction->setEnabled(false); + openComicAction->setEnabled(false); + showPropertiesAction->setEnabled(false); + openContainingFolderAction->setEnabled(false); + openContainingFolderComicAction->setEnabled(false); + setAsReadAction->setEnabled(false); + setAsNonReadAction->setEnabled(false); + setAllAsReadAction->setEnabled(false); + setAllAsNonReadAction->setEnabled(false); + selectAllComicsAction->setEnabled(false); + editSelectedComicsAction->setEnabled(false); + asignOrderActions->setEnabled(false); +} +//librería abierta +void LibraryWindow::enableActions() +{ + updateLibraryAction->setEnabled(true); + openComicAction->setEnabled(true); + showPropertiesAction->setEnabled(true); + openContainingFolderAction->setEnabled(true); + openContainingFolderComicAction->setEnabled(true); + setAsReadAction->setEnabled(true); + setAsNonReadAction->setEnabled(true); + setAllAsReadAction->setEnabled(true); + setAllAsNonReadAction->setEnabled(true); +} +void LibraryWindow::enableLibraryActions() +{ + renameLibraryAction->setEnabled(true); + deleteLibraryAction->setEnabled(true); + removeLibraryAction->setEnabled(true); + foldersFilter->setEnabled(true); + clearFoldersFilter->setEnabled(true); +} + +void LibraryWindow::createToolBars() +{ + libraryToolBar = addToolBar(tr("Library")); + libraryToolBar->setIconSize(QSize(32,32)); //TODO make icon size dynamic + libraryToolBar->addAction(createLibraryAction); + libraryToolBar->addAction(openLibraryAction); + + libraryToolBar->addSeparator(); + + libraryToolBar->addAction(exportComicsInfo); + libraryToolBar->addAction(importComicsInfo); + + libraryToolBar->addSeparator(); + + libraryToolBar->addAction(importLibraryAction); + libraryToolBar->addAction(exportLibraryAction); + + libraryToolBar->addSeparator(); + libraryToolBar->addAction(updateLibraryAction); + libraryToolBar->addAction(renameLibraryAction); + libraryToolBar->addAction(removeLibraryAction); + libraryToolBar->addAction(deleteLibraryAction); + + libraryToolBar->addSeparator(); + libraryToolBar->addAction(openComicAction); + libraryToolBar->addAction(showPropertiesAction); + + QToolButton * tb = new QToolButton(); + tb->addAction(setAsReadAction); + tb->addAction(setAllAsReadAction); + tb->setPopupMode(QToolButton::MenuButtonPopup); + tb->setDefaultAction(setAsReadAction); + + QToolButton * tb2 = new QToolButton(); + tb2->addAction(setAsNonReadAction); + tb2->addAction(setAllAsNonReadAction); + tb2->setPopupMode(QToolButton::MenuButtonPopup); + tb2->setDefaultAction(setAsNonReadAction); + + libraryToolBar->addWidget(tb); + libraryToolBar->addWidget(tb2); + + libraryToolBar->addAction(showHideMarksAction); + + libraryToolBar->addSeparator(); + libraryToolBar->addAction(toggleFullScreenAction); + + libraryToolBar->addWidget(new QToolBarStretch()); + libraryToolBar->addAction(optionsAction); + libraryToolBar->addAction(helpAboutAction); + + + libraryToolBar->setMovable(false); + + treeActions->addAction(setRootIndexAction); + treeActions->addAction(expandAllNodesAction); + treeActions->addAction(colapseAllNodesAction); + + comicFlow->addAction(toggleFullScreenAction); + comicFlow->addAction(openComicAction); + + editInfoToolBar->addAction(openComicAction); + editInfoToolBar->addSeparator(); + editInfoToolBar->addAction(editSelectedComicsAction); + editInfoToolBar->addAction(selectAllComicsAction); + editInfoToolBar->addSeparator(); + editInfoToolBar->addAction(asignOrderActions); + editInfoToolBar->addWidget(new QToolBarStretch()); + editInfoToolBar->addAction(hideComicViewAction); +} + +void LibraryWindow::createMenus() +{ + comicView->addAction(openContainingFolderComicAction); + foldersView->addAction(openContainingFolderAction); +} + +void LibraryWindow::createConnections() +{ + //libraryCreator connections + connect(createLibraryDialog,SIGNAL(createLibrary(QString,QString,QString)),this,SLOT(create(QString,QString,QString))); + connect(importComicsInfoDialog,SIGNAL(finished(int)),this,SLOT(reloadCurrentLibrary())); + connect(libraryCreator,SIGNAL(coverExtracted(QString)),createLibraryDialog,SLOT(showCurrentFile(QString))); + connect(libraryCreator,SIGNAL(finished()),createLibraryDialog,SLOT(close())); + connect(libraryCreator,SIGNAL(coverExtracted(QString)),updateLibraryDialog,SLOT(showCurrentFile(QString))); + connect(libraryCreator,SIGNAL(finished()),updateLibraryDialog,SLOT(close())); + connect(libraryCreator,SIGNAL(updated()),this,SLOT(reloadCurrentLibrary())); + connect(libraryCreator,SIGNAL(created()),this,SLOT(openLastCreated())); + + //packageManager connections + connect(exportLibraryDialog,SIGNAL(exportPath(QString)),this,SLOT(exportLibrary(QString))); + connect(exportLibraryDialog,SIGNAL(rejected()),packageManager,SLOT(cancel())); + connect(packageManager,SIGNAL(exported()),exportLibraryDialog,SLOT(close())); + connect(importLibraryDialog,SIGNAL(unpackCLC(QString,QString,QString)),this,SLOT(importLibrary(QString,QString,QString))); + connect(importLibraryDialog,SIGNAL(rejected()),packageManager,SLOT(cancel())); + connect(importLibraryDialog,SIGNAL(rejected()),this,SLOT(deleteCurrentLibrary())); + connect(packageManager,SIGNAL(imported()),importLibraryDialog,SLOT(hide())); + connect(packageManager,SIGNAL(imported()),this,SLOT(openLastCreated())); + + + //create and update dialogs + connect(createLibraryDialog,SIGNAL(cancelCreate()),this,SLOT(cancelCreating())); + connect(updateLibraryDialog,SIGNAL(cancelUpdate()),this,SLOT(stopLibraryCreator())); + + //open existing library from dialog. + connect(addLibraryDialog,SIGNAL(addLibrary(QString,QString)),this,SLOT(openLibrary(QString,QString))); + + //load library when selected library changes + connect(selectedLibrary,SIGNAL(currentIndexChanged(QString)),this,SLOT(loadLibrary(QString))); + + //rename library dialog + connect(renameLibraryDialog,SIGNAL(renameLibrary(QString)),this,SLOT(rename(QString))); + + //navigations between view modes (tree,list and flow) + connect(foldersView, SIGNAL(pressed(QModelIndex)), this, SLOT(loadCovers(QModelIndex))); + connect(comicView, SIGNAL(pressed(QModelIndex)), this, SLOT(centerComicFlow(QModelIndex))); + connect(comicFlow, SIGNAL(centerIndexChanged(int)), this, SLOT(updateComicView(int))); + + //actions + connect(createLibraryAction,SIGNAL(triggered()),this,SLOT(createLibrary())); + connect(exportLibraryAction,SIGNAL(triggered()),exportLibraryDialog,SLOT(show())); + connect(importLibraryAction,SIGNAL(triggered()),importLibraryDialog,SLOT(show())); + + connect(openLibraryAction,SIGNAL(triggered()),this,SLOT(showAddLibrary())); + connect(showPropertiesAction,SIGNAL(triggered()),this,SLOT(showProperties())); + connect(setAsReadAction,SIGNAL(triggered()),this,SLOT(setCurrentComicReaded())); + connect(setAsNonReadAction,SIGNAL(triggered()),this,SLOT(setCurrentComicUnreaded())); + connect(setAllAsReadAction,SIGNAL(triggered()),this,SLOT(setComicsReaded())); + connect(setAllAsNonReadAction,SIGNAL(triggered()),this,SLOT(setComicsUnreaded())); + + connect(showHideMarksAction,SIGNAL(toggled(bool)),comicFlow,SLOT(setShowMarks(bool))); + + //comicsInfoManagement + connect(exportComicsInfo,SIGNAL(triggered()),this,SLOT(showExportComicsInfo())); + connect(importComicsInfo,SIGNAL(triggered()),this,SLOT(showImportComicsInfo())); + + //properties + connect(propertiesDialog,SIGNAL(accepted()),this,SLOT(reloadCovers())); + + connect(updateLibraryAction,SIGNAL(triggered()),this,SLOT(updateLibrary())); + connect(renameLibraryAction,SIGNAL(triggered()),this,SLOT(renameLibrary())); + connect(deleteLibraryAction,SIGNAL(triggered()),this,SLOT(deleteLibrary())); + connect(removeLibraryAction,SIGNAL(triggered()),this,SLOT(removeLibrary())); + connect(openComicAction,SIGNAL(triggered()),this,SLOT(openComic())); + connect(helpAboutAction,SIGNAL(triggered()),had,SLOT(show())); + connect(setRootIndexAction,SIGNAL(triggered()),this,SLOT(setRootIndex())); + connect(expandAllNodesAction,SIGNAL(triggered()),foldersView,SLOT(expandAll())); + connect(colapseAllNodesAction,SIGNAL(triggered()),foldersView,SLOT(collapseAll())); + connect(toggleFullScreenAction,SIGNAL(triggered()),this,SLOT(toggleFullScreen())); + connect(optionsAction, SIGNAL(triggered()),optionsDialog,SLOT(show())); + connect(optionsDialog, SIGNAL(optionsChanged()),this,SLOT(reloadOptions())); + //ComicFlow + connect(comicFlow,SIGNAL(selected(unsigned int)),this,SLOT(openComic())); + connect(comicView,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(openComic())); + //Folders filter + connect(clearFoldersFilter,SIGNAL(clicked()),foldersFilter,SLOT(clear())); + connect(foldersFilter,SIGNAL(textChanged(QString)),this,SLOT(setFoldersFilter(QString))); + connect(includeComicsCheckBox,SIGNAL(stateChanged(int)),this,SLOT(searchInFiles(int))); + + //ContextMenus + connect(openContainingFolderComicAction,SIGNAL(triggered()),this,SLOT(openContainingFolderComic())); + connect(openContainingFolderAction,SIGNAL(triggered()),this,SLOT(openContainingFolder())); + + //connect(dm,SIGNAL(directoryLoaded(QString)),foldersView,SLOT(expandAll())); + //connect(dm,SIGNAL(directoryLoaded(QString)),this,SLOT(updateFoldersView(QString))); + //Comicts edition + connect(selectAllComicsAction,SIGNAL(triggered()),comicView,SLOT(selectAll())); + connect(editSelectedComicsAction,SIGNAL(triggered()),this,SLOT(showProperties())); + connect(asignOrderActions,SIGNAL(triggered()),this,SLOT(asignNumbers())); + + connect(hideComicViewAction, SIGNAL(toggled(bool)),this, SLOT(hideComicFlow(bool))); + +} + +void LibraryWindow::loadLibrary(const QString & name) +{ + if(libraries.size()>0) //si hay bibliotecas... + { + QString path=libraries.value(name)+"/.yacreaderlibrary"; + QDir d; //TODO change this by static methods (utils class?? with delTree for example) + QString dbVersion; + if(d.exists(path) && (dbVersion = DataBaseManagement::checkValidDB(path+"/library.ydb")) != "") //si existe en disco la biblioteca seleccionada, y es válida.. + { + int comparation; + if((comparation = DataBaseManagement::compareVersions(dbVersion,VERSION)) == 0) //en caso de que la versión se igual que la actual + { + index = 0; + sm->clear(); + //foldersView->setModel(NULL); //TODO comprobar pq no sirve con usar simplemente las señales beforeReset y reset + //comicView->setModel(NULL); + + dm->setupModelData(path); + foldersView->setModel(dm); + + d.setCurrent(libraries.value(name)); + d.setFilter(QDir::AllDirs | QDir::Files | QDir::Hidden | QDir::NoSymLinks | QDir::NoDotAndDotDot); + if(d.count()<=1) //librería de sólo lectura + { + //QMessageBox::critical(NULL,QString::number(d.count()),QString::number(d.count())); + disableActions(); + importedCovers = true; + } + else //librería normal abierta + { + enableActions(); + importedCovers = false; + } + enableLibraryActions(); + + loadCovers(QModelIndex()); + + //includeComicsCheckBox->setCheckState(Qt::Unchecked); + foldersFilter->clear(); + } + else + { + if(comparation < 0) + { + int ret = QMessageBox::question(this,tr("Update needed"),tr("This library was created with a previous version of YACReaderLibrary. It needs to be updated. Update now?")); + if(ret == QMessageBox::Yes) + { + } + else + { + comicView->setModel(NULL); + foldersView->setModel(NULL); + comicFlow->clear(); + disableAllActions();//TODO comprobar que se deben deshabilitar + } + } + else + { + int ret = QMessageBox::question(this,tr("Download new version"),tr("This library was created with a newer version of YACReaderLibrary. Download the new version now?"),QMessageBox::Yes,QMessageBox::No); + if(ret == QMessageBox::Yes) + QDesktopServices::openUrl(QUrl("http://code.google.com/p/yacreader/")); + + comicView->setModel(NULL); + foldersView->setModel(NULL); + comicFlow->clear(); + disableAllActions();//TODO comprobar que se deben deshabilitar + + } + } + } + else + { + comicView->setModel(NULL); + foldersView->setModel(NULL); + comicFlow->clear(); + disableAllActions();//TODO comprobar que se deben deshabilitar + + //si la librería no existe en disco, se ofrece al usuario la posibiliad de eliminarla + if(!d.exists(path)) + { + QString currentLibrary = selectedLibrary->currentText(); + if(QMessageBox::question(this,tr("Library not available"),tr("Library ")+currentLibrary+tr(" is no longer available. Do you want to remove it?"),QMessageBox::Yes,QMessageBox::No)==QMessageBox::Yes) + { + deleteCurrentLibrary(); + } + } + else//si existe el path, puede ser que la librería sea alguna versión pre-5.0 ó que esté corrupta + { + QString currentLibrary = selectedLibrary->currentText(); + QString path = libraries.value(selectedLibrary->currentText()); + if(QMessageBox::question(this,tr("Old library or corrupted"),tr("Library ")+currentLibrary+tr(" is corrupted or has been created with an older version of YACReaderLibrary. It must be created again. Do you want to create the library now?"),QMessageBox::Yes,QMessageBox::No)==QMessageBox::Yes) + { + QDir d(path+"/.yacreaderlibrary"); + delTree(d); + d.rmdir(path+"/.yacreaderlibrary"); + createLibraryDialog->setDataAndStart(currentLibrary,path); + //create(path,path+"/.yacreaderlibrary",currentLibrary); + } + } + } + } + else //en caso de que no exista ninguna biblioteca se desactivan los botones pertinentes + { + disableAllActions(); + } +} + +void LibraryWindow::loadCovers(const QModelIndex & mi) +{ + _rootIndexCV = mi; + unsigned long long int folderId = 1; + if(mi.isValid()) + { + TreeItem *item = static_cast(mi.internalPointer()); + folderId = item->id; + } + + //cambiado de orden, ya que al llamar a foldersFilter->clear() se invalidan los model index + if(foldersFilter->text()!="") + { + //setFoldersFilter(""); + if(mi.isValid()) + { + index = static_cast(mi.internalPointer())->originalItem; + column = mi.column(); + foldersFilter->clear(); + } + } + else + { + index = static_cast(mi.internalPointer()); + column = mi.column(); + } + + //comicView->setModel(NULL); + dmCV->setupModelData(folderId,dm->getDatabase()); + comicView->setModel(dmCV); + comicView->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); + for(int i = 4;ihorizontalHeader()->count();i++) + comicView->horizontalHeader()->hideSection(i); + + + //debido a un bug, qt4 no es capaz de ajustar el ancho teniendo en cuenta todas la filas (no sólo las visibles) + //así que se ecala la primera vez y después se deja el control al usuario. + comicView->resizeColumnsToContents(); + comicView->horizontalHeader()->setStretchLastSection(true); + + QStringList paths = dmCV->getPaths(currentPath()); + comicFlow->setImagePaths(paths); + comicFlow->setMarks(dmCV->getReadList()); + comicFlow->setFocus(Qt::OtherFocusReason); + + if(paths.size()>0 && !importedCovers) + { + openComicAction->setEnabled(true); + showPropertiesAction->setEnabled(true); + setAsReadAction->setEnabled(true); + setAsNonReadAction->setEnabled(true); + setAllAsReadAction->setEnabled(true); + setAllAsNonReadAction->setEnabled(true); + selectAllComicsAction->setEnabled(true); + editSelectedComicsAction->setEnabled(true); + asignOrderActions->setEnabled(true); + } + else + { + openComicAction->setEnabled(false); + showPropertiesAction->setEnabled(false); + setAsReadAction->setEnabled(false); + setAsNonReadAction->setEnabled(false); + setAllAsReadAction->setEnabled(false); + setAllAsNonReadAction->setEnabled(false); + selectAllComicsAction->setEnabled(false); + editSelectedComicsAction->setEnabled(false); + asignOrderActions->setEnabled(false); + } + if(paths.size()>0) + comicView->setCurrentIndex(dmCV->index(0,0)); +} + +void LibraryWindow::reloadCovers() +{ + loadCovers(_rootIndexCV); + + QModelIndex mi = dmCV->getIndexFromId(_comicIdEdited); + comicView->scrollTo(mi,QAbstractItemView::PositionAtCenter); + comicView->setCurrentIndex(mi); + //centerComicFlow(mi); + comicFlow->setCenterIndex(mi.row()); +} + +void LibraryWindow::centerComicFlow(const QModelIndex & mi) +{ + int distance = comicFlow->centerIndex()-mi.row(); + if(abs(distance)>10) + { + if(distance<0) + comicFlow->setCenterIndex(comicFlow->centerIndex()+(-distance)-10); + else + comicFlow->setCenterIndex(comicFlow->centerIndex()-distance+10); + skip = 10; + } + else + skip = abs(comicFlow->centerIndex()-mi.row()); + comicFlow->showSlide(mi.row()); + comicFlow->setFocus(Qt::OtherFocusReason); +} + +void LibraryWindow::updateComicView(int i) +{ + + if(skip==0) + { + QModelIndex mi = dmCV->index(i,2); + comicView->setCurrentIndex(mi); + comicView->scrollTo(mi,QAbstractItemView::EnsureVisible); + } + skip?(--skip):0; +} + +void LibraryWindow::openComic() +{ + if(!importedCovers) + { + QString path = currentPath() + dmCV->getComicPath(comicView->currentIndex()); + + QProcess::startDetached(QDir::cleanPath(QCoreApplication::applicationDirPath())+"/YACReader",QStringList() << path); + //Comic is readed + setCurrentComicReaded(); + } +} + +void LibraryWindow::setCurrentComicReaded() +{ + comicFlow->markSlide(comicFlow->centerIndex()); + comicFlow->updateMarks(); + + Comic c = dmCV->getComic(comicView->currentIndex()); + c.info.read = true; + QSqlDatabase db = DataBaseManagement::loadDatabase(dm->getDatabase()); + db.open(); + c.info.updateRead(db); + db.close(); + QSqlDatabase::removeDatabase(dm->getDatabase()); +} + +void LibraryWindow::setComicsReaded() +{ + comicFlow->setMarks(dmCV->setAllComicsRead(true)); + comicFlow->updateMarks(); +} + +void LibraryWindow::setCurrentComicUnreaded() +{ + comicFlow->unmarkSlide(comicFlow->centerIndex()); + comicFlow->updateMarks(); + + Comic c = dmCV->getComic(comicView->currentIndex()); + c.info.read = false; + QSqlDatabase db = DataBaseManagement::loadDatabase(dm->getDatabase()); + db.open(); + c.info.updateRead(db); + db.close(); + QSqlDatabase::removeDatabase(dm->getDatabase()); + +} + +void LibraryWindow::setComicsUnreaded() +{ + comicFlow->setMarks(dmCV->setAllComicsRead(false)); + comicFlow->updateMarks(); +} + +void LibraryWindow::createLibrary() +{ + createLibraryDialog->show(); +} + +void LibraryWindow::create(QString source, QString dest, QString name) +{ + libraryCreator->createLibrary(source,dest); + libraryCreator->start(); + _lastAdded = name; + _sourceLastAdded = source; + +} + +void LibraryWindow::reloadCurrentLibrary() +{ + loadLibrary(selectedLibrary->currentText()); +} + +void LibraryWindow::openLastCreated() +{ + + selectedLibrary->disconnect(); + + selectedLibrary->setCurrentIndex(selectedLibrary->findText(_lastAdded)); + libraries.insert(_lastAdded,_sourceLastAdded); + selectedLibrary->addItem(_lastAdded,_sourceLastAdded); + selectedLibrary->setCurrentIndex(selectedLibrary->findText(_lastAdded)); + saveLibraries(); + + connect(selectedLibrary,SIGNAL(currentIndexChanged(QString)),this,SLOT(loadLibrary(QString))); + + loadLibrary(_lastAdded); +} + +void LibraryWindow::showAddLibrary() +{ + addLibraryDialog->show(); +} + +void LibraryWindow::openLibrary(QString path, QString name) +{ + path.remove("/.yacreaderlibrary"); + QDir d; //TODO change this by static methods (utils class?? with delTree for example) + if(d.exists(path + "/.yacreaderlibrary")) + { + _lastAdded = name; + _sourceLastAdded = path; + openLastCreated(); + } + else + QMessageBox::warning(this,tr("Library not found"),tr("The selected folder doesn't contain any library.")); +} + +void LibraryWindow::loadLibraries() +{ + QFile f(QCoreApplication::applicationDirPath()+"/libraries.yacr"); + f.open(QIODevice::ReadOnly); + QTextStream txtS(&f); + QString content = txtS.readAll(); + QStringList lines = content.split('\n'); + QString line,name; + int i=0; + bool librariesAvailable = false; + foreach(line,lines) + { + if((i%2)==0) + { + name = line; + } + else + { + librariesAvailable = true; + libraries.insert(name.trimmed(),line.trimmed()); + selectedLibrary->addItem(name.trimmed(),line.trimmed()); + } + i++; + } + + if(!librariesAvailable) + { + disableAllActions(); + } +} + +void LibraryWindow::saveLibraries() +{ + QFile f(QCoreApplication::applicationDirPath()+"/libraries.yacr"); + if(!f.open(QIODevice::WriteOnly)) + { + QMessageBox::critical(NULL,tr("Saving libraries file...."),tr("There was a problem saving YACReaderLibrary libraries file. Please, check if you have enough permissions in the YACReader root folder.")); + } + else + { + QTextStream txtS(&f); + for(QMap::iterator i = libraries.begin();i!=libraries.end();i++) + { + txtS << i.key() << "\n"; + txtS << i.value() << "\n"; + } + } +} + +void LibraryWindow::updateLibrary() +{ + updateLibraryDialog->show(); + QString currentLibrary = selectedLibrary->currentText(); + QString path = libraries.value(currentLibrary); + _lastAdded = currentLibrary; + libraryCreator->updateLibrary(path,path+"/.yacreaderlibrary"); + libraryCreator->start(); +} + +void LibraryWindow::deleteLibrary() +{ + QString currentLibrary = selectedLibrary->currentText(); + if(QMessageBox::question(this,tr("Are you sure?"),tr("Do you want delete ")+currentLibrary+" library?",QMessageBox::Yes,QMessageBox::No)==QMessageBox::Yes) + { + deleteCurrentLibrary(); + } +} + +void LibraryWindow::deleteCurrentLibrary() +{ + //QSqlDatabase db = dm->getDatabase(); + //db.commit(); + //db.close(); + //QSqlDatabase::removeDatabase(db.connectionName()); + //if(!dm->getDatabase().isOpen()) + //{ + QString path = libraries.value(selectedLibrary->currentText()); + libraries.remove(selectedLibrary->currentText()); + selectedLibrary->removeItem(selectedLibrary->currentIndex()); + selectedLibrary->setCurrentIndex(0); + path = path+"/.yacreaderlibrary"; + + QDir d(path); + delTree(d); + d.rmdir(path); + if(libraries.size()==0)//no more libraries avaliable. + { + comicView->setModel(NULL); + foldersView->setModel(NULL); + comicFlow->clear(); + } + saveLibraries(); + //} +} + +void LibraryWindow::removeLibrary() +{ + QString currentLibrary = selectedLibrary->currentText(); + if(QMessageBox::question(this,tr("Are you sure?"),tr("Do you want remove ")+currentLibrary+tr(" library?\nFiles won't be erased from disk."),QMessageBox::Yes,QMessageBox::No)==QMessageBox::Yes) + { + libraries.remove(currentLibrary); + selectedLibrary->removeItem(selectedLibrary->currentIndex()); + selectedLibrary->setCurrentIndex(0); + if(libraries.size()==0)//no more libraries avaliable. + { + comicView->setModel(NULL); + foldersView->setModel(NULL); + comicFlow->clear(); + } + saveLibraries(); + } +} + +void LibraryWindow::renameLibrary() +{ + renameLibraryDialog->show(); +} + +void LibraryWindow::rename(QString newName) +{ + QString currentLibrary = selectedLibrary->currentText(); + QString path = libraries.value(currentLibrary); + libraries.remove(currentLibrary); + selectedLibrary->removeItem(selectedLibrary->currentIndex()); + libraries.insert(newName,path); + selectedLibrary->addItem(newName,path); + saveLibraries(); + selectedLibrary->setCurrentIndex(selectedLibrary->findText(newName)); +} + +void LibraryWindow::cancelCreating() +{ + stopLibraryCreator(); + //TODO delete library. +} + +void LibraryWindow::stopLibraryCreator() +{ + libraryCreator->stop(); + libraryCreator->wait(); +} + +void LibraryWindow::setRootIndex() +{ + if(libraries.size()>0) + { + QString path=libraries.value(selectedLibrary->currentText())+"/.yacreaderlibrary"; + QDir d; //TODO change this by static methods (utils class?? with delTree for example) + if(d.exists(path)) + { + loadCovers(QModelIndex()); + } + else + { + comicView->setModel(NULL); + comicFlow->clear(); + } + } +} + + +void LibraryWindow::toggleFullScreen() +{ + fullscreen?toNormal():toFullScreen(); + fullscreen = !fullscreen; +} + +void LibraryWindow::toFullScreen() +{ + comicFlow->hide(); + comicFlow->setSlideSize(slideSizeF); + comicFlow->setCenterIndex(comicFlow->centerIndex()); + comics->hide(); + left->hide(); + libraryToolBar->hide(); + + showFullScreen(); + + comicFlow->show(); + comicFlow->setFocus(Qt::OtherFocusReason); + fullScreenToolTip->move((width()-fullScreenToolTip->width())/2,0); + fullScreenToolTip->adjustSize(); + fullScreenToolTip->show(); +} + +void LibraryWindow::toNormal() +{ + comicFlow->hide(); + comicFlow->setSlideSize(slideSizeW); + comicFlow->setCenterIndex(comicFlow->centerIndex()); + comicFlow->render(); + comics->show(); + left->show(); + fullScreenToolTip->hide(); + libraryToolBar->show(); + comicFlow->show(); + + showMaximized(); +} + +void LibraryWindow::setFoldersFilter(QString filter) +{ + if(filter.isEmpty() && dm->isFilterEnabled()) + { + dm->resetFilter(); + //foldersView->collapseAll(); + if(index != 0) + { + QModelIndex mi = dm->indexFromItem(index,column); + foldersView->scrollTo(mi,QAbstractItemView::PositionAtTop); + sm->select(mi,QItemSelectionModel::Select); + foldersView->setSelectionModel(sm); + } + } + else + { + if(!filter.isEmpty()) + { + dm->setFilter(filter, includeComicsCheckBox->isChecked()); + foldersView->expandAll(); + } + } +} + +void LibraryWindow::showProperties() +{ + QModelIndexList indexList = comicView->selectionModel()->selectedRows(); + + QList comics = dmCV->getComics(indexList); + Comic c = comics[0]; + _comicIdEdited = c.id;//static_cast(indexList[0].internalPointer())->data(4).toULongLong(); + + //QModelIndex mi = comicView->currentIndex(); + //QString path = QDir::cleanPath(currentPath()+dmCV->getComicPath(mi)); + + //ThumbnailCreator tc(path,""); + //tc.create(); + propertiesDialog->databasePath = dm->getDatabase(); + propertiesDialog->basePath = currentPath(); + propertiesDialog->setComics(comics); + + /*propertiesDialog->setCover(tc.getCover()); + propertiesDialog->setFilename(path.split("/").last()); + propertiesDialog->setNumpages(tc.getNumPages()); + QFile file(path); + propertiesDialog->setSize(file.size()/(1024.0*1024)); + file.close();*/ + propertiesDialog->show(); +} + +void LibraryWindow::asignNumbers() +{ + QModelIndexList indexList = comicView->selectionModel()->selectedRows(); + + QList comics = dmCV->getComics(indexList); + Comic c = comics[0]; + _comicIdEdited = c.id; + + int startingNumber = dmCV->getIndexFromId(comics[0].id).row()+1; + if(comics.count()>1) + { + bool ok; + int n = QInputDialog::getInt(this, tr("Asign comics numbers"), + tr("Asign numbers starting in:"), dmCV->getIndexFromId(comics[0].id).row()+1,0,2147483647,1,&ok); + if (ok) + startingNumber = n; + else + return; + } + + QSqlDatabase db = DataBaseManagement::loadDatabase(dm->getDatabase()); + db.transaction(); + + for(int i = 0;igetDatabase()); + + reloadCovers(); +} + +void LibraryWindow::openContainingFolderComic() +{ + QModelIndex modelIndex = comicView->currentIndex(); + QFileInfo file = QDir::cleanPath(currentPath() + dmCV->getComicPath(modelIndex)); + QString path = file.absolutePath(); + QDesktopServices::openUrl(QUrl("file:///"+path, QUrl::TolerantMode)); +} + +void LibraryWindow::openContainingFolder() +{ + QModelIndex modelIndex = foldersView->currentIndex(); + QString path = QDir::cleanPath(currentPath() + dm->getFolderPath(modelIndex)); + QDesktopServices::openUrl(QUrl("file:///"+path, QUrl::TolerantMode)); +} + +void LibraryWindow::exportLibrary(QString destPath) +{ + QString currentLibrary = selectedLibrary->currentText(); + QString path = libraries.value(currentLibrary)+"/.yacreaderlibrary"; + packageManager->createPackage(path,destPath+"/"+currentLibrary); +} + +void LibraryWindow::importLibrary(QString clc,QString destPath,QString name) +{ + packageManager->extractPackage(clc,destPath+"/"+name); + openLibrary(destPath+"/"+name,name); +} + +void LibraryWindow::reloadOptions() +{ + comicFlow->setFlowType(flowType); +} + +//TODO esto sobra +void LibraryWindow::updateFoldersView(QString path) +{ + //QModelIndex mi = dm->index(path); + //int rowCount = dm->rowCount(mi); + //if(!fetching) + //{ + // //fetching = true; + // for(int i=0;ifetchMore(dm->index(i,0,mi)); + // //int childCount = dm->rowCount(dm->index(i,0,mi)); + // //if(childCount>0) + // // QMessageBox::critical(NULL,tr("..."),tr("-----")); + // fetching = false; + // } + //} + +} + +void LibraryWindow::searchInFiles(int state) +{ + + if(state == Qt::Checked) + { + if(!foldersFilter->text().isEmpty()) + { + dm->setFilter(foldersFilter->text(), true); + foldersView->expandAll(); + } + } + else + { + if(!foldersFilter->text().isEmpty()) + { + dm->setFilter(foldersFilter->text(), false); + foldersView->expandAll(); + } + } +} + +QString LibraryWindow::currentPath() +{ + return libraries.value(selectedLibrary->currentText()); +} + +void LibraryWindow::hideComicFlow(bool hide) +{ + if(hide) + { + QList sizes; + sizes.append(0); + int total = sVertical->sizes().at(0) + sVertical->sizes().at(1); + sizes.append(total); + sVertical->setSizes(sizes); + } + else + { + QList sizes; + int total = sVertical->sizes().at(0) + sVertical->sizes().at(1); + sizes.append(2*total/3); + sizes.append(total/3); + sVertical->setSizes(sizes); + } + +} + +void LibraryWindow::showExportComicsInfo() +{ + exportComicsInfoDialog->source = currentPath() + "/.yacreaderlibrary/library.ydb"; + exportComicsInfoDialog->show(); +} + +void LibraryWindow::showImportComicsInfo() +{ + importComicsInfoDialog->dest = currentPath() + "/.yacreaderlibrary/library.ydb"; + importComicsInfoDialog->show(); +} \ No newline at end of file diff --git a/YACReaderLibrary/library_window.h b/YACReaderLibrary/library_window.h new file mode 100644 index 00000000..29fb491b --- /dev/null +++ b/YACReaderLibrary/library_window.h @@ -0,0 +1,207 @@ +#ifndef __LIBRARYWINDOW_H +#define __LIBRARYWINDOW_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "create_library_dialog.h" +#include "add_library_dialog.h" +#include "library_creator.h" +#include "comic_flow.h" +#include "custom_widgets.h" +#include "rename_library_dialog.h" +#include "properties_dialog.h" +#include "options_dialog.h" +#include "export_comics_info_dialog.h" +#include "import_comics_info_dialog.h" +#include "export_library_dialog.h" +#include "import_library_dialog.h" +#include "package_manager.h" +#include "treemodel.h" +#include "tablemodel.h" +#include "treeitem.h" + +class LibraryWindow : public QMainWindow +{ + Q_OBJECT +private: + QWidget * left; + QSplitter * sVertical; + CreateLibraryDialog * createLibraryDialog; + UpdateLibraryDialog * updateLibraryDialog; + ExportLibraryDialog * exportLibraryDialog; + ImportLibraryDialog * importLibraryDialog; + ExportComicsInfoDialog * exportComicsInfoDialog; + ImportComicsInfoDialog * importComicsInfoDialog; + AddLibraryDialog * addLibraryDialog; + LibraryCreator * libraryCreator; + HelpAboutDialog * had; + RenameLibraryDialog * renameLibraryDialog; + PropertiesDialog * propertiesDialog; + bool fullscreen; + bool importedCovers; //if true, the library is read only (not updates,open comic or properties) + YACReaderTreeSearch * proxyFilter; + YACReaderSortComics * proxySort; + PackageManager * packageManager; + + ComicFlow * comicFlow; + QSize slideSizeW; + QSize slideSizeF; + //search filter + QLineEdit * foldersFilter; + TreeItem * index; //index al que hay que hacer scroll después de pulsar sobre un folder filtrado + int column; + QString previousFilter; + QPushButton * clearFoldersFilter; + QCheckBox * includeComicsCheckBox; + //------------- + QWidget *comics; + QTableView * comicView; + QTreeView * foldersView; + QComboBox * selectedLibrary; + TreeModel * dm; + QItemSelectionModel * sm; + TableModel * dmCV; + //QStringList paths; + QMap libraries; + QLabel * fullScreenToolTip; + YACReaderIconProvider fip; + + bool fetching; + + int i; + unsigned int skip; + + QAction * openComicAction; + QAction * showPropertiesAction; + QAction * createLibraryAction; + QAction * openLibraryAction; + + QAction * exportComicsInfo; + QAction * importComicsInfo; + + QAction * exportLibraryAction; + QAction * importLibraryAction; + + QAction * updateLibraryAction; + QAction * deleteLibraryAction; + QAction * removeLibraryAction; + QAction * helpAboutAction; + QAction * renameLibraryAction; + QAction * toggleFullScreenAction; + QAction * optionsAction; + + //tree actions + QAction * setRootIndexAction; + QAction * expandAllNodesAction; + QAction * colapseAllNodesAction; + + QAction * openContainingFolderAction; + QAction * openContainingFolderComicAction; + QAction * setAsReadAction; + QAction * setAsNonReadAction; + QAction * setAllAsReadAction; + QAction * setAllAsNonReadAction; + QAction * showHideMarksAction; + + //edit info actions + QAction * selectAllComicsAction; + QAction * editSelectedComicsAction; + QAction * asignOrderActions; + QAction * forceConverExtractedAction; + QAction * hideComicViewAction; + + + QToolBar * libraryToolBar; + QToolBar * treeActions; + QToolBar * comicsToolBar; + QToolBar * editInfoToolBar; + + OptionsDialog * optionsDialog; + + QString libraryPath; + QString comicsPath; + + QString _lastAdded; + QString _sourceLastAdded; + + QModelIndex _rootIndex; + QModelIndex _rootIndexCV; + + quint64 _comicIdEdited; + + void setupUI(); + void createActions(); + void createToolBars(); + void createMenus(); + void createConnections(); + void doLayout(); + void doDialogs(); + void doModels(); + + void disableAllActions(); + void disableActions(); + void enableActions(); + void enableLibraryActions(); + + QString currentPath(); +public: + LibraryWindow(); + public slots: + void loadLibrary(const QString & path); + void loadCovers(const QModelIndex & mi); + void reloadCovers(); + void centerComicFlow(const QModelIndex & mi); + void updateComicView(int i); + void openComic(); + void createLibrary(); + void create(QString source,QString dest, QString name); + void showAddLibrary(); + void openLibrary(QString path, QString name); + void loadLibraries(); + void saveLibraries(); + void reloadCurrentLibrary(); + void openLastCreated(); + void updateLibrary(); + void deleteLibrary(); + void openContainingFolder(); + void openContainingFolderComic(); + void deleteCurrentLibrary(); + void removeLibrary(); + void renameLibrary(); + void rename(QString newName); + void cancelCreating(); + void stopLibraryCreator(); + void setRootIndex(); + void toggleFullScreen(); + void toNormal(); + void toFullScreen(); + void setFoldersFilter(QString filter); + void showProperties(); + void exportLibrary(QString destPath); + void importLibrary(QString clc,QString destPath,QString name); + void reloadOptions(); + void updateFoldersView(QString); + void setCurrentComicReaded(); + void setCurrentComicUnreaded(); + void setComicsReaded(); + void setComicsUnreaded(); + void searchInFiles(int); + void hideComicFlow(bool hide); + void showExportComicsInfo(); + void showImportComicsInfo(); + void asignNumbers(); +}; + +#endif + + + diff --git a/YACReaderLibrary/main.cpp b/YACReaderLibrary/main.cpp new file mode 100644 index 00000000..85aa9f30 --- /dev/null +++ b/YACReaderLibrary/main.cpp @@ -0,0 +1,25 @@ +#include "library_window.h" + +#include +//#include "startup.h" +#define PICTUREFLOW_QT4 1 + +int main( int argc, char ** argv ) +{ + QApplication app( argc, argv ); + + QTranslator translator; + QString sufix = QLocale::system().name(); + translator.load(":/yacreaderlibrary_"+sufix); + app.installTranslator(&translator); + app.setApplicationName("YACReaderLibrary"); + + QMainWindow * mw = new LibraryWindow(); + mw->resize(800,480); + mw->showMaximized(); + + //Startup * s = new Startup(); + //s->start(); + + return app.exec(); +} diff --git a/YACReaderLibrary/options_dialog.cpp b/YACReaderLibrary/options_dialog.cpp new file mode 100644 index 00000000..0744b59f --- /dev/null +++ b/YACReaderLibrary/options_dialog.cpp @@ -0,0 +1,148 @@ +#include "options_dialog.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +PictureFlow::FlowType flowType = PictureFlow::Strip; + +OptionsDialog::OptionsDialog(QWidget * parent) +:QDialog() +{ + QVBoxLayout * layout = new QVBoxLayout(this); + + accept = new QPushButton(tr("Save")); + cancel = new QPushButton(tr("Cancel")); + connect(accept,SIGNAL(clicked()),this,SLOT(saveOptions())); + connect(cancel,SIGNAL(clicked()),this,SLOT(restoreOptions())); + connect(cancel,SIGNAL(clicked()),this,SLOT(close())); + + QGroupBox *groupBox = new QGroupBox(tr("How to show covers:")); + + radio1 = new QRadioButton(tr("CoverFlow look")); + radio2 = new QRadioButton(tr("Stripe look")); + radio3 = new QRadioButton(tr("Overlapped Stripe look")); + + + QVBoxLayout *vbox = new QVBoxLayout; + QHBoxLayout * opt1 = new QHBoxLayout; + opt1->addWidget(radio1); + QLabel * lOpt1 = new QLabel(); + lOpt1->setPixmap(QPixmap(":/images/flow1.png")); + opt1->addStretch(); + opt1->addWidget(lOpt1); + vbox->addLayout(opt1); + + QHBoxLayout * opt2 = new QHBoxLayout; + opt2->addWidget(radio2); + QLabel * lOpt2 = new QLabel(); + lOpt2->setPixmap(QPixmap(":/images/flow2.png")); + opt2->addStretch(); + opt2->addWidget(lOpt2); + vbox->addLayout(opt2); + + QHBoxLayout * opt3 = new QHBoxLayout; + opt3->addWidget(radio3); + QLabel * lOpt3 = new QLabel(); + lOpt3->setPixmap(QPixmap(":/images/flow3.png")); + opt3->addStretch(); + opt3->addWidget(lOpt3); + vbox->addLayout(opt3); + + + //vbox->addStretch(1); + groupBox->setLayout(vbox); + + QHBoxLayout * buttons = new QHBoxLayout(); + buttons->addStretch(); + buttons->addWidget(accept); + buttons->addWidget(cancel); + + layout->addWidget(groupBox); + layout->addLayout(buttons); + + setLayout(layout); + + restoreOptions(); //load options + resize(200,0); + setModal (true); + setWindowTitle("Options"); +} + +void OptionsDialog::findFolder() +{ + QString s = QFileDialog::getExistingDirectory(0,tr("Comics directory"),"."); + if(!s.isEmpty()) + { + pathEdit->setText(s); + } +} + +void OptionsDialog::saveOptions() +{ + QFile f(QCoreApplication::applicationDirPath()+"/YACReaderLibrary.conf"); + if(!f.open(QIODevice::WriteOnly)) + { + QMessageBox::critical(NULL,tr("Saving config file...."),tr("There was a problem saving YACReaderLibrary configuration. Please, check if you have enough permissions in the YACReader root folder.")); + } + else + { + QTextStream txtS(&f); + if(radio1->isChecked()) + { + txtS << "FLOW_TYPE" << "\n" << (int)PictureFlow::CoverFlowLike << "\n"; + flowType = PictureFlow::CoverFlowLike; + } + if(radio2->isChecked()) + { + txtS << "FLOW_TYPE" << "\n" << (int)PictureFlow::Strip << "\n"; + flowType = PictureFlow::Strip; + } + if(radio3->isChecked()) + { + txtS << "FLOW_TYPE" << "\n" << (int)PictureFlow::StripOverlapped << "\n"; + flowType = PictureFlow::StripOverlapped; + } + f.close(); + close(); + emit(optionsChanged()); + } +} + +void OptionsDialog::restoreOptions() +{ + QFile f(QCoreApplication::applicationDirPath()+"/YACReaderLibrary.conf"); + if(f.exists()) + { + f.open(QIODevice::ReadOnly); + QTextStream txtS(&f); + QString content = txtS.readAll(); + + QStringList lines = content.split('\n'); + if(lines.count()>0){ + QString name = lines.at(1); + + switch(flowType=(PictureFlow::FlowType)name.toInt()){ + case PictureFlow::CoverFlowLike: + radio1->setChecked(true); + break; + case PictureFlow::Strip: + radio2->setChecked(true); + break; + case PictureFlow::StripOverlapped: + radio3->setChecked(true); + break; + } + } + else + flowType=PictureFlow::Strip; + } + else + flowType=PictureFlow::Strip; + +} diff --git a/YACReaderLibrary/options_dialog.h b/YACReaderLibrary/options_dialog.h new file mode 100644 index 00000000..36fe2d6a --- /dev/null +++ b/YACReaderLibrary/options_dialog.h @@ -0,0 +1,50 @@ +#ifndef __OPTIONS_DIALOG_H +#define __OPTIONS_DIALOG_H + +#include +#include +#include +#include +#include +#include +#include +#include "pictureflow.h" + +extern PictureFlow::FlowType flowType; + +class OptionsDialog : public QDialog +{ +Q_OBJECT + public: + OptionsDialog(QWidget * parent = 0); + private: + QLabel * pathLabel; + QLineEdit * pathEdit; + QPushButton * pathFindButton; + + QLabel * magGlassSizeLabel; + + QLabel * zoomLevel; + + QLabel * slideSizeLabel; + QSlider * slideSize; + + QPushButton * accept; + QPushButton * cancel; + + QRadioButton *radio1; + QRadioButton *radio2; + QRadioButton *radio3; + + public slots: + void saveOptions(); + void restoreOptions(); + void findFolder(); + +signals: + void optionsChanged(); + +}; + + +#endif diff --git a/YACReaderLibrary/package_manager.cpp b/YACReaderLibrary/package_manager.cpp new file mode 100644 index 00000000..44066d54 --- /dev/null +++ b/YACReaderLibrary/package_manager.cpp @@ -0,0 +1,47 @@ +#include "package_manager.h" +#include + +PackageManager::PackageManager() +:_7z(0) +{ + +} + +void PackageManager::createPackage(const QString & libraryPath,const QString & dest) +{ + QStringList attributes; + attributes << "a" << "-y" << "-ttar" << dest+".clc" << libraryPath ; + _7z = new QProcess(); + connect(_7z,SIGNAL(error(QProcess::ProcessError)),this,SLOT(openingError(QProcess::ProcessError))); + connect(_7z,SIGNAL(finished(int,QProcess::ExitStatus)),this,SIGNAL(exported())); + _7z->start(QCoreApplication::applicationDirPath()+"/utils/7z",attributes); +} + +void PackageManager::extractPackage(const QString & packagePath,const QString & destDir) +{ + QStringList attributes; + QString output = "-o"; + output += destDir; + attributes << "x" << "-y" << output << packagePath; + _7z = new QProcess(); + connect(_7z,SIGNAL(error(QProcess::ProcessError)),this,SLOT(openingError(QProcess::ProcessError))); + connect(_7z,SIGNAL(finished(int,QProcess::ExitStatus)),this,SIGNAL(imported())); + _7z->start(QCoreApplication::applicationDirPath()+"/utils/7z",attributes); +} + +void PackageManager::cancel() +{ + if(_7z!=0) + { + _7z->disconnect(); + _7z->kill(); + if(creating) + { + //TODO remove dest+".clc" + } + else + { + //TODO fixed: is done by libraryWindow + } + } +} diff --git a/YACReaderLibrary/package_manager.h b/YACReaderLibrary/package_manager.h new file mode 100644 index 00000000..497fc826 --- /dev/null +++ b/YACReaderLibrary/package_manager.h @@ -0,0 +1,24 @@ +#ifndef PACKAGE_MANAGER_H +#define PACKAGE_MANAGER_H + +#include + +class PackageManager : public QObject +{ + Q_OBJECT +public: + PackageManager(); + void createPackage(const QString & libraryPath,const QString & dest); + void extractPackage(const QString & packagePath,const QString & destDir); + public slots: + void cancel(); +private: + bool creating; + QProcess * _7z; + +signals: + void exported(); + void imported(); +}; + +#endif diff --git a/YACReaderLibrary/properties_dialog.cpp b/YACReaderLibrary/properties_dialog.cpp new file mode 100644 index 00000000..69ec4202 --- /dev/null +++ b/YACReaderLibrary/properties_dialog.cpp @@ -0,0 +1,691 @@ +#include "properties_dialog.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#include "data_base_management.h" +#include "library_creator.h" + +PropertiesDialog::PropertiesDialog(QWidget * parent) +:QDialog(parent) +{ + + createCoverBox(); + createGeneralInfoBox(); + createAuthorsBox(); + createPublishingBox(); + createButtonBox(); + createPlotBox(); + + createTabBar(); + + mainLayout = new QGridLayout; + mainLayout->addWidget(coverBox,0,0); + mainLayout->addWidget(tabBar,0,1); + mainLayout->setColumnStretch(1,1); + /*mainLayout->addWidget(authorsBox,1,1); + mainLayout->addWidget(publishingBox,2,1);*/ + mainLayout->addWidget(buttonBox,1,1,Qt::AlignBottom); + + this->setLayout(mainLayout); + mainLayout->setSizeConstraint(QLayout::SetMinimumSize); + + int heightDesktopResolution = QApplication::desktop()->screenGeometry().height(); + int widthDesktopResolution = QApplication::desktop()->screenGeometry().width(); + int sHeight,sWidth; + sHeight = static_cast(heightDesktopResolution*0.65); + sWidth = static_cast(sHeight*1.4); + setCover(QPixmap(":/images/notCover.png")); + this->resize(sWidth,this->height()); + this->move(QPoint((widthDesktopResolution-sWidth)/2,((heightDesktopResolution-sHeight)-40)/2)); + setModal(true); + repaint(); + +} + +void PropertiesDialog::createTabBar() +{ + tabBar = new QTabWidget; + tabBar->addTab(generalInfoBox,tr("General info")); + tabBar->addTab(authorsBox,tr("Authors")); + tabBar->addTab(publishingBox,tr("Publishing")); + tabBar->addTab(plotBox,tr("Plot")); +} + +void PropertiesDialog::createCoverBox() +{ + coverBox = new QGroupBox(tr("Cover")); + + sa = new QScrollArea(); + cover = new QLabel(); + cover->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); + cover->setScaledContents(false); + cover->setAlignment(Qt::AlignTop|Qt::AlignHCenter); + + + /*sa->setWidget(cover); + sa->setBackgroundRole(QPalette::Dark); + sa->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + sa->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + sa->setFrameStyle(QFrame::NoFrame); + sa->setAlignment(Qt::AlignCenter);*/ + + QVBoxLayout * coverLayout = new QVBoxLayout(); + coverLayout->addWidget(cover); + + QHBoxLayout * coverPageLayout = new QHBoxLayout; + coverPageLayout->addWidget(new QLabel(tr("Cover page : "))); + coverPageLayout->addWidget(coverPageEdit = new YACReaderFieldEdit()); + coverPageLayout->setStretch(1,0); + + coverLayout->addLayout(coverPageLayout); + + coverBox->setLayout(coverLayout); +} + +QFrame * createLine() +{ + QFrame * line = new QFrame(); + line->setObjectName(QString::fromUtf8("line")); + //line->setGeometry(QRect(320, 150, 118, 3)); + line->setFrameShape(QFrame::HLine); + line->setFrameShadow(QFrame::Sunken); + + return line; +} + +void PropertiesDialog::createGeneralInfoBox() +{ + generalInfoBox = new QWidget; + + QFormLayout *generalInfoLayout = new QFormLayout; + + //generalInfoLayout->setRowWrapPolicy(QFormLayout::WrapAllRows); + generalInfoLayout->addRow(tr("Title:"), title = new YACReaderFieldEdit()); + + + QHBoxLayout * number = new QHBoxLayout; + number->addWidget(numberEdit = new YACReaderFieldEdit()); + numberValidator.setBottom(0); + numberEdit->setValidator(&numberValidator); + number->addWidget(new QLabel("Bis:")); + number->addWidget(isBisCheck = new QCheckBox()); + number->addWidget(new QLabel("of:")); + number->addWidget(countEdit = new YACReaderFieldEdit()); + countValidator.setBottom(0); + countEdit->setValidator(&countValidator); + number->addStretch(1); + /*generalInfoLayout->addRow(tr("&Issue number:"), ); + generalInfoLayout->addRow(tr("&Bis:"), );*/ + generalInfoLayout->addRow(tr("Issue number:"), number); + + generalInfoLayout->addRow(tr("Volume:"), volumeEdit = new YACReaderFieldEdit()); + + QHBoxLayout * arc = new QHBoxLayout; + arc->addWidget(storyArcEdit = new YACReaderFieldEdit()); + arc->addWidget(new QLabel("Arc number:")); + arc->addWidget(arcNumberEdit = new YACReaderFieldEdit()); + arcNumberValidator.setBottom(0); + arcNumberEdit->setValidator(&arcNumberValidator); + arc->addWidget(new QLabel("of:")); + arc->addWidget(arcCountEdit = new YACReaderFieldEdit()); + arcCountValidator.setBottom(0); + arcCountEdit->setValidator(&arcCountValidator); + arc->addStretch(1); + generalInfoLayout->addRow(tr("Story arc:"), arc); + + generalInfoLayout->addRow(tr("Genere:"), genereEdit = new YACReaderFieldEdit()); + + generalInfoLayout->addRow(tr("Size:"), size = new QLabel("size")); + + generalInfoBox->setLayout(generalInfoLayout); +} + +void PropertiesDialog::createAuthorsBox() +{ + authorsBox = new QWidget; + + QVBoxLayout *authorsLayout = new QVBoxLayout; + + //authorsLayout->setRowWrapPolicy(QFormLayout::WrapAllRows); + QHBoxLayout * h1 = new QHBoxLayout; + QVBoxLayout * vl1 = new QVBoxLayout; + QVBoxLayout * vr1 = new QVBoxLayout; + vl1->addWidget(new QLabel(tr("Writer(s):"))); + vl1->addWidget(writer = new YACReaderFieldPlainTextEdit()); + h1->addLayout(vl1); + vr1->addWidget(new QLabel(tr("Penciller(s):"))); + vr1->addWidget(penciller = new YACReaderFieldPlainTextEdit()); + h1->addLayout(vr1); + //authorsLayout->addRow(tr("Writer(s):"), new YACReaderFieldPlainTextEdit()); + //authorsLayout->addRow(tr("Penciller(s):"), new YACReaderFieldPlainTextEdit()); + QHBoxLayout * h2 = new QHBoxLayout; + QVBoxLayout * vl2 = new QVBoxLayout; + QVBoxLayout * vr2 = new QVBoxLayout; + vl2->addWidget(new QLabel(tr("Inker(s):"))); + vl2->addWidget(inker = new YACReaderFieldPlainTextEdit()); + h2->addLayout(vl2); + vr2->addWidget(new QLabel(tr("Colorist(s):"))); + vr2->addWidget(colorist = new YACReaderFieldPlainTextEdit()); + h2->addLayout(vr2); + + //authorsLayout->addRow(tr("Inker(s):"), new YACReaderFieldPlainTextEdit()); + //authorsLayout->addRow(tr("Colorist(s):"), new YACReaderFieldPlainTextEdit()); + + QHBoxLayout * h3 = new QHBoxLayout; + QVBoxLayout * vl3 = new QVBoxLayout; + QVBoxLayout * vr3 = new QVBoxLayout; + vl3->addWidget(new QLabel(tr("Letterer(es):"))); + vl3->addWidget(letterer = new YACReaderFieldPlainTextEdit()); + h3->addLayout(vl3); + vr3->addWidget(new QLabel(tr("Cover Artist(s):"))); + vr3->addWidget(coverArtist = new YACReaderFieldPlainTextEdit()); + h3->addLayout(vr3); + //authorsLayout->addRow(tr("Letterer(es):"), new YACReaderFieldPlainTextEdit()); + //authorsLayout->addRow(tr("Cover Artist(s):"), new YACReaderFieldPlainTextEdit()); + + authorsLayout->addLayout(h1); + authorsLayout->addLayout(h2); + authorsLayout->addLayout(h3); + authorsLayout->addStretch(1); + authorsBox->setLayout(authorsLayout); + +} + +void PropertiesDialog::createPublishingBox() +{ + publishingBox = new QWidget; + + QFormLayout *publishingLayout = new QFormLayout; + + QHBoxLayout * date = new QHBoxLayout; + date->addWidget(new QLabel(tr("Day:"))); + date->addWidget(dayEdit = new YACReaderFieldEdit()); + dayValidator.setRange(1,31); + dayEdit->setValidator(&dayValidator); + date->addWidget(new QLabel(tr("Month:"))); + date->addWidget(monthEdit = new YACReaderFieldEdit()); + monthValidator.setRange(1,12); + monthEdit->setValidator(&monthValidator); + date->addWidget(new QLabel(tr("Year:"))); + date->addWidget(yearEdit = new YACReaderFieldEdit()); + yearValidator.setRange(1,9999); + yearEdit->setValidator(&yearValidator); + date->addStretch(1); + + publishingLayout->setRowWrapPolicy(QFormLayout::WrapAllRows); + publishingLayout->addRow(date); + publishingLayout->addRow(tr("Publisher:"), publisherEdit = new YACReaderFieldEdit()); + publishingLayout->addRow(tr("Format:"), formatEdit = new YACReaderFieldEdit()); + publishingLayout->addRow(tr("Color/BW:"), colorCheck = new QCheckBox()); + publishingLayout->addRow(tr("Age rating:"), ageRatingEdit = new YACReaderFieldEdit()); + + publishingBox->setLayout(publishingLayout); +} + +void PropertiesDialog::createPlotBox() +{ + plotBox = new QWidget; + + QFormLayout *plotLayout = new QFormLayout; + + plotLayout->setRowWrapPolicy(QFormLayout::WrapAllRows); + plotLayout->addRow(tr("Synopsis:"), synopsis = new YACReaderFieldPlainTextEdit()); + plotLayout->addRow(tr("Characters:"), characters = new YACReaderFieldPlainTextEdit()); + plotLayout->addRow(tr("Notes:"), notes = new YACReaderFieldPlainTextEdit()); + + plotBox->setLayout(plotLayout); + +} + +void PropertiesDialog::createButtonBox() +{ + buttonBox = new QDialogButtonBox; + + closeButton = buttonBox->addButton(QDialogButtonBox::Close); + saveButton = buttonBox->addButton(QDialogButtonBox::Save); + //rotateWidgetsButton = buttonBox->addButton(tr("Rotate &Widgets"),QDialogButtonBox::ActionRole); + + //connect(rotateWidgetsButton, SIGNAL(clicked()), this, SLOT(rotateWidgets())); + connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); + connect(saveButton, SIGNAL(clicked()), this, SLOT(save())); +} + + + +void PropertiesDialog::setComics(QList comics) +{ + this->comics = comics; + + Comic comic = comics.at(0); + + if(comic.info.title != NULL) + title->setText(*comic.info.title); + + if(comic.info.coverPage != NULL) + { + coverPageEdit->setText(QString::number(*comic.info.coverPage)); + coverPageValidator.setRange(1,*comic.info.numPages); + coverPageEdit->setValidator(&coverPageValidator); + } + /*if(comic.info.numPages != NULL) + numPagesEdit->setText(QString::number(*comic.info.numPages));*/ + + + if(comic.info.number != NULL) + numberEdit->setText(QString::number(*comic.info.number)); + if(comic.info.isBis != NULL) + isBisCheck->setChecked(*comic.info.isBis); + if(comic.info.count != NULL) + countEdit->setText(QString::number(*comic.info.count)); + + if(comic.info.volume != NULL) + volumeEdit->setText(*comic.info.volume); + if(comic.info.storyArc != NULL) + storyArcEdit->setText(*comic.info.storyArc); + if(comic.info.arcNumber != NULL) + arcNumberEdit->setText(QString::number(*comic.info.arcNumber)); + if(comic.info.arcCount != NULL) + arcCountEdit->setText(QString::number(*comic.info.arcCount)); + + if(comic.info.genere != NULL) + genereEdit->setText(*comic.info.genere); + + if(comic.info.writer != NULL) + writer->setPlainText(*comic.info.writer); + if(comic.info.penciller != NULL) + penciller->setPlainText(*comic.info.penciller); + if(comic.info.inker != NULL) + inker->setPlainText(*comic.info.inker); + if(comic.info.colorist != NULL) + colorist->setPlainText(*comic.info.colorist); + if(comic.info.letterer != NULL) + letterer->setPlainText(*comic.info.letterer); + if(comic.info.coverArtist != NULL) + coverArtist->setPlainText(*comic.info.coverArtist); + + size->setText(QString::number(comic.info.hash.right(comic.info.hash.length()-40).toInt()/1024.0/1024.0,'f',2)+"Mb"); + + if(comic.info.date != NULL) + { + QStringList date = (*comic.info.date).split("/"); + dayEdit->setText(date[0]); + monthEdit->setText(date[1]); + yearEdit->setText(date[2]); + } + if(comic.info.publisher != NULL) + publisherEdit->setText(*comic.info.publisher); + if(comic.info.format != NULL) + formatEdit->setText(*comic.info.format); + if(comic.info.color != NULL) + colorCheck->setChecked(*comic.info.color); + else + colorCheck->setCheckState(Qt::PartiallyChecked); + + if(comic.info.ageRating != NULL) + ageRatingEdit->setText(*comic.info.ageRating); + + if(comic.info.synopsis != NULL) + synopsis->setPlainText(*comic.info.synopsis); + if(comic.info.characters != NULL) + characters->setPlainText(*comic.info.characters); + if(comic.info.notes != NULL) + notes->setPlainText(*comic.info.notes); + + + if(comics.length() > 1) + { + setDisableUniqueValues(true); + this->setWindowTitle(tr("Edit selected comics information")); + setCover(QPixmap(":/images/editComic.png")); + + QList::iterator itr; + for(itr = ++comics.begin();itr!=comics.end();itr++) + { + if(itr->info.title == NULL || *(itr->info.title) != title->text()) + title->clear(); + + if(itr->info.count == NULL || *(itr->info.count) != countEdit->text().toInt()) //TODO esto está mal + countEdit->clear(); + + if(itr->info.volume == NULL || *(itr->info.volume) != volumeEdit->text()) + volumeEdit->clear(); + if(itr->info.storyArc == NULL || *(itr->info.storyArc) != storyArcEdit->text()) + storyArcEdit->clear(); + if(itr->info.arcCount == NULL || *(itr->info.arcCount) != storyArcEdit->text().toInt()) + arcCountEdit->clear(); + + if(itr->info.genere == NULL || *(itr->info.genere) != genereEdit->text()) + genereEdit->clear(); + + if(itr->info.writer == NULL || *(itr->info.writer) != writer->toPlainText()) + writer->clear(); + if(itr->info.penciller == NULL || *(itr->info.penciller) != penciller->toPlainText()) + penciller->clear(); + if(itr->info.inker == NULL || *(itr->info.inker) != inker->toPlainText()) + inker->clear(); + if(itr->info.colorist == NULL || *(itr->info.colorist) != colorist->toPlainText()) + colorist->clear(); + if(itr->info.letterer == NULL || *(itr->info.letterer) != letterer->toPlainText()) + letterer->clear(); + if(itr->info.coverArtist == NULL || *(itr->info.coverArtist) != coverArtist->toPlainText()) + coverArtist->clear(); + + if(itr->info.date == NULL) + { + dayEdit->clear(); + monthEdit->clear(); + yearEdit->clear(); + } + else + { + QStringList date = itr->info.date->split("/"); + if(dayEdit->text() != date[0]) + dayEdit->clear(); + if(monthEdit->text() != date[1]) + monthEdit->clear(); + if(yearEdit->text() != date[2]) + yearEdit->clear(); + } + + if(itr->info.publisher == NULL || *(itr->info.publisher) != publisherEdit->text()) + publisherEdit->clear(); + if(itr->info.format == NULL || *(itr->info.format) != formatEdit->text()) + formatEdit->clear(); + if(itr->info.color == NULL || *(itr->info.color) != colorCheck->isChecked()) + colorCheck->setCheckState(Qt::PartiallyChecked); + if(itr->info.ageRating == NULL || *(itr->info.ageRating) != ageRatingEdit->text()) + ageRatingEdit->clear(); + + if(itr->info.synopsis == NULL || *(itr->info.synopsis) != synopsis->toPlainText()) + synopsis->clear(); + if(itr->info.characters == NULL || *(itr->info.characters) != characters->toPlainText()) + characters->clear(); + if(itr->info.notes == NULL || *(itr->info.notes) != notes->toPlainText()) + notes->clear(); + } + } + else + { + this->setWindowTitle(tr("Edit comic information")); + setCover(comic.info.getCover(basePath)); + } + +} + + + +void PropertiesDialog::updateComics() +{ + QSqlDatabase db = DataBaseManagement::loadDatabase(databasePath); + db.open(); + db.transaction(); + QList::iterator itr; + for(itr = comics.begin();itr!=comics.end();itr++) + { + if(itr->info.edited) + itr->info.update(db); + } + db.commit(); + db.close(); + QSqlDatabase::removeDatabase(databasePath); +} +//Deprecated +void PropertiesDialog::setCover(const QPixmap & coverImage) +{ + cover->setPixmap(coverImage.scaledToWidth(125,Qt::SmoothTransformation)); + //cover->repaint(); + + //float aspectRatio = (float)coverImage.width()/coverImage.height(); + //int heightDesktopResolution = QApplication::desktop()->screenGeometry().height(); + //int widthDesktopResolution = QApplication::desktop()->screenGeometry().width(); + //int sHeight,sWidth; + //sHeight = static_cast(heightDesktopResolution*0.65); + + //if(aspectRatio<1) + //{ + // sWidth = static_cast(sHeight*1.4); + // //this->resize(sWidth,sHeight); + // this->move(QPoint((widthDesktopResolution-sWidth)/2,((heightDesktopResolution-sHeight)-40)/2)); + // //sa->resize(sa->width(),sa->width()*1.333); + // /*cover->resize(static_cast((sa->height())*aspectRatio), + // (sa->height()));*/ + + //} + //else + //{ + // sWidth = static_cast(sHeight/1.16); + // //this->resize(sWidth,sHeight); + // this->move(QPoint((widthDesktopResolution-sWidth)/2,((heightDesktopResolution-sHeight)-40)/2)); + // cover->resize((width()-25), + // static_cast((width()-25)/aspectRatio)); + //} + +} +void PropertiesDialog::setFilename(const QString & nameString) +{ + title->setText(nameString); +} +void PropertiesDialog::setNumpages(int pagesNum) +{ + numPagesEdit->setText(QString::number(pagesNum)); +} +void PropertiesDialog::setSize(float sizeFloat) +{ + + size->setText(QString::number(sizeFloat,'f',2) + " MB"); +} + +void PropertiesDialog::save() +{ + QList::iterator itr; + for(itr = comics.begin();itr!=comics.end();itr++) + { + //Comic & comic = comics[0]; + bool edited = false; + + if(title->isModified()) + { + itr->info.setTitle(title->text()); + edited = true; + } + + if(comics.size()==1) + if(coverPageEdit->isModified() && !coverPageEdit->text().isEmpty() && coverPageEdit->text().toInt() != 0) + { + itr->info.setCoverPage(coverPageEdit->text().toInt()); + edited = true; + } + + /*if(comic.info.numPages != NULL) + numPagesEdit->setText(QString::number(*comic.info.numPages));*/ + if(comics.size()==1) + if(numberEdit->isModified() && !numberEdit->text().isEmpty()) + { + itr->info.setNumber(numberEdit->text().toInt()); + edited = true; + } + if(comics.size()==1) + if(itr->info.isBis != NULL || isBisCheck->isChecked()) + { + itr->info.setIsBis(isBisCheck->isChecked()); + edited = true; + } + + if(countEdit->isModified()) + { + itr->info.setCount(countEdit->text().toInt()); + edited = true; + } + + if(volumeEdit->isModified()) + { + itr->info.setVolume(volumeEdit->text()); + edited = true; + } + if(storyArcEdit->isModified()) + { + itr->info.setStoryArc(storyArcEdit->text()); + edited = true; + } + if(comics.size()==1) + if(arcNumberEdit->isModified() && !arcNumberEdit->text().isEmpty()) + { + itr->info.setArcNumber(arcNumberEdit->text().toInt()); + edited = true; + } + if(arcCountEdit->isModified()) + { + itr->info.setArcCount(arcCountEdit->text().toInt()); + edited = true; + } + + if(genereEdit->isModified()) + { + itr->info.setGenere(genereEdit->text()); + edited = true; + } + + if(writer->document()->isModified()) + { + itr->info.setWriter(writer->toPlainText()); + edited = true; + } + if(penciller->document()->isModified()) + { + itr->info.setPenciller(penciller->toPlainText()); + edited = true; + } + if(inker->document()->isModified()) + { + itr->info.setInker(inker->toPlainText()); + edited = true; + } + if(colorist->document()->isModified()) + { + itr->info.setColorist(colorist->toPlainText()); + edited = true; + } + if(letterer->document()->isModified()) + { + itr->info.setLetterer(letterer->toPlainText()); + edited = true; + } + if(coverArtist->document()->isModified()) + { + itr->info.setCoverArtist(coverArtist->toPlainText()); + edited = true; + } + + if(dayEdit->isModified() || monthEdit->isModified() || yearEdit->isModified() ) + { + itr->info.setDate(dayEdit->text()+"/"+monthEdit->text()+"/"+yearEdit->text()); + edited = true; + } + if(publisherEdit->isModified()) + { + itr->info.setPublisher(publisherEdit->text()); + edited = true; + } + if(formatEdit->isModified()) + { + itr->info.setFormat(formatEdit->text()); + edited = true; + } + if(colorCheck->checkState() != Qt::PartiallyChecked) + { + itr->info.setColor(colorCheck->isChecked()); + edited = true; + } + if(ageRatingEdit->isModified()) + { + itr->info.setAgeRating(ageRatingEdit->text()); + edited = true; + } + + if(synopsis->document()->isModified()) + { + itr->info.setSynopsis(synopsis->toPlainText()); + edited = true; + } + if(characters->document()->isModified()) + { + itr->info.setCharacters(characters->toPlainText()); + edited = true; + } + if(notes->document()->isModified()) + { + itr->info.setNotes(notes->toPlainText()); + edited = true; + } + + itr->info.edited = edited; + } + updateComics(); + if(comics.count() == 1) + { + if(coverPageEdit->isModified())// && coverPageEdit->text().toInt() != *comics[0].info.coverPage) + { + ThumbnailCreator tc(basePath+comics[0].path,basePath+"/.yacreaderlibrary/covers/"+comics[0].info.hash+".jpg",*comics[0].info.coverPage); + tc.create(); + } + } + close(); + emit(accepted()); +} + +void PropertiesDialog::setDisableUniqueValues(bool disabled) +{ + coverPageEdit->setDisabled(disabled); + coverPageEdit->clear(); + numberEdit->setDisabled(disabled); + numberEdit->clear(); + isBisCheck->setDisabled(disabled); + isBisCheck->setChecked(false); + arcNumberEdit->setDisabled(disabled); + arcNumberEdit->clear(); +} + +void PropertiesDialog::closeEvent ( QCloseEvent * e ) +{ + + title->clear(); + title->setModified(false); + coverPageEdit->clear(); + // numPagesEdit->setText(QString::number(*comic.info.numPages)); + numberEdit->clear(); + isBisCheck->setChecked(false); + countEdit->clear(); + volumeEdit->clear(); + storyArcEdit->clear(); + arcNumberEdit->clear(); + arcCountEdit->clear(); + genereEdit->clear(); + writer->clear(); + penciller->clear(); + inker->clear(); + colorist->clear(); + letterer->clear(); + coverArtist->clear(); + dayEdit->clear(); + monthEdit->clear(); + yearEdit->clear(); + publisherEdit->clear(); + formatEdit->clear(); + colorCheck->setCheckState(Qt::PartiallyChecked); + ageRatingEdit->clear(); + synopsis->clear(); + characters->clear(); + notes->clear(); + + setDisableUniqueValues(false); + + tabBar->setCurrentIndex(0); + + QDialog::closeEvent(e); +} diff --git a/YACReaderLibrary/properties_dialog.h b/YACReaderLibrary/properties_dialog.h new file mode 100644 index 00000000..addfeb9a --- /dev/null +++ b/YACReaderLibrary/properties_dialog.h @@ -0,0 +1,116 @@ +#ifndef __PROPERTIES_DIALOG_H +#define __PROPERTIES_DIALOG_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "comic.h" +#include "custom_widgets.h" + + class PropertiesDialog : public QDialog + { + Q_OBJECT + private: + QGridLayout * mainLayout; + + QTabWidget * tabBar; + + QGroupBox * coverBox; + QLabel * cover; + QScrollArea * sa; + + QWidget * generalInfoBox; + YACReaderFieldEdit * title; + YACReaderFieldEdit * numPagesEdit; + QLabel * size; + + YACReaderFieldEdit * coverPageEdit; + QIntValidator coverPageValidator; + + YACReaderFieldEdit * numberEdit; + QIntValidator numberValidator; + QCheckBox * isBisCheck; + YACReaderFieldEdit * countEdit; + QIntValidator countValidator; + + YACReaderFieldEdit * volumeEdit; + YACReaderFieldEdit * storyArcEdit; + YACReaderFieldEdit * arcNumberEdit; + QIntValidator arcNumberValidator; + YACReaderFieldEdit * arcCountEdit; + QIntValidator arcCountValidator; + + YACReaderFieldEdit * genereEdit; + + YACReaderFieldPlainTextEdit * writer; + YACReaderFieldPlainTextEdit * penciller; + YACReaderFieldPlainTextEdit * inker; + YACReaderFieldPlainTextEdit * colorist; + YACReaderFieldPlainTextEdit * letterer; + YACReaderFieldPlainTextEdit * coverArtist; + + YACReaderFieldEdit * dayEdit; + QIntValidator dayValidator; + YACReaderFieldEdit * monthEdit; + QIntValidator monthValidator; + YACReaderFieldEdit * yearEdit; + QIntValidator yearValidator; + YACReaderFieldEdit * publisherEdit; + YACReaderFieldEdit * formatEdit; + QCheckBox * colorCheck; + YACReaderFieldEdit * ageRatingEdit; + + YACReaderFieldPlainTextEdit * synopsis; + YACReaderFieldPlainTextEdit * characters; + YACReaderFieldPlainTextEdit * notes; + + QWidget * authorsBox; + + QWidget * publishingBox; + + QWidget * plotBox; + + QDialogButtonBox *buttonBox; + QPushButton *closeButton; + QPushButton *saveButton; + QPushButton *restoreButton; //?? + + void createTabBar(); + void createCoverBox(); + void createGeneralInfoBox(); + void createAuthorsBox(); + void createPublishingBox(); + void createPlotBox(); + + void createButtonBox(); + + void setDisableUniqueValues(bool disabled); + + QList comics; + void closeEvent ( QCloseEvent * e ); + public: + PropertiesDialog(QWidget * parent = 0); + QString databasePath; + QString basePath; + + public slots: + void setComics(QList comics); + void updateComics(); + void save(); + //Deprecated + void setCover(const QPixmap & cover); + void setFilename(const QString & name); + void setNumpages(int pages); + void setSize(float size); + + }; +#endif + diff --git a/YACReaderLibrary/rename_library_dialog.cpp b/YACReaderLibrary/rename_library_dialog.cpp new file mode 100644 index 00000000..64c84f52 --- /dev/null +++ b/YACReaderLibrary/rename_library_dialog.cpp @@ -0,0 +1,68 @@ +#include "rename_library_dialog.h" + +#include +#include +#include + + + +RenameLibraryDialog::RenameLibraryDialog(QWidget * parent) +:QDialog(parent) +{ + setupUI(); +} + +void RenameLibraryDialog::setupUI() +{ + newNameLabel = new QLabel(tr("New Library Name : ")); + newNameEdit = new QLineEdit; + newNameLabel->setBuddy(newNameEdit); + + accept = new QPushButton(tr("Rename")); + //accept->setDisabled(true); + connect(accept,SIGNAL(clicked()),this,SLOT(rename())); + + cancel = new QPushButton(tr("Cancel")); + connect(cancel,SIGNAL(clicked()),this,SLOT(close())); + + QHBoxLayout *nameLayout = new QHBoxLayout; + + nameLayout->addWidget(newNameLabel); + nameLayout->addWidget(newNameEdit); + + QHBoxLayout *bottomLayout = new QHBoxLayout; + bottomLayout->addStretch(); + bottomLayout->addWidget(accept); + bottomLayout->addWidget(cancel); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addLayout(nameLayout); + mainLayout->addStretch(); + mainLayout->addLayout(bottomLayout); + + QHBoxLayout * imgMainLayout = new QHBoxLayout; + QLabel * imgLabel = new QLabel(this); + QPixmap p(":/images/edit.png"); + imgLabel->setPixmap(p); + imgMainLayout->addWidget(imgLabel); + imgMainLayout->addLayout(mainLayout); + + setLayout(imgMainLayout); + + setModal(true); + setWindowTitle(tr("Rename current library")); +} + +void RenameLibraryDialog::rename() +{ + //accept->setEnabled(false); + emit(renameLibrary(newNameEdit->text())); + close(); +} + +void RenameLibraryDialog::close() +{ + newNameEdit->clear(); + //accept->setEnabled(false); + QDialog::close(); +} \ No newline at end of file diff --git a/YACReaderLibrary/rename_library_dialog.h b/YACReaderLibrary/rename_library_dialog.h new file mode 100644 index 00000000..aa5eaccf --- /dev/null +++ b/YACReaderLibrary/rename_library_dialog.h @@ -0,0 +1,30 @@ +#ifndef __RENAME_LIBRARY_DIALOG_H +#define __RENAME_LIBRARY_DIALOG_H + +#include +#include +#include +#include + + + class RenameLibraryDialog : public QDialog + { + Q_OBJECT + public: + RenameLibraryDialog(QWidget * parent = 0); + private: + QLabel * newNameLabel; + QLineEdit * newNameEdit; + QPushButton * accept; + QPushButton * cancel; + void setupUI(); + public slots: + void rename(); + void close(); +signals: + void renameLibrary(QString newName); + }; + + +#endif + diff --git a/YACReaderLibrary/server/controllers/dumpcontroller.cpp b/YACReaderLibrary/server/controllers/dumpcontroller.cpp new file mode 100644 index 00000000..2b67e536 --- /dev/null +++ b/YACReaderLibrary/server/controllers/dumpcontroller.cpp @@ -0,0 +1,62 @@ +/** + @file + @author Stefan Frings +*/ + +#include "dumpcontroller.h" +#include +#include + +DumpController::DumpController(){} + +void DumpController::service(HttpRequest& request, HttpResponse& response) { + + response.setHeader("Content-Type", "text/html; charset=ISO-8859-1"); + response.setCookie(HttpCookie("firstCookie","hello",600)); + response.setCookie(HttpCookie("secondCookie","world",600)); + + QByteArray body(""); + body.append("Request:"); + body.append("
Method: "); + body.append(request.getMethod()); + body.append("
Path: "); + body.append(request.getPath()); + body.append("
Version: "); + body.append(request.getVersion()); + + body.append("

Headers:"); + QMapIterator i(request.getHeaderMap()); + while (i.hasNext()) { + i.next(); + body.append("
"); + body.append(i.key()); + body.append("="); + body.append(i.value()); + } + + body.append("

Parameters:"); + i=QMapIterator(request.getParameterMap()); + while (i.hasNext()) { + i.next(); + body.append("
"); + body.append(i.key()); + body.append("="); + body.append(i.value()); + } + + body.append("

Cookies:"); + i=QMapIterator(request.getCookieMap()); + while (i.hasNext()) { + i.next(); + body.append("
"); + body.append(i.key()); + body.append("="); + body.append(i.value()); + } + + body.append("

Body:
"); + body.append(request.getBody()); + + body.append(""); + response.write(body,true); +} diff --git a/YACReaderLibrary/server/controllers/dumpcontroller.h b/YACReaderLibrary/server/controllers/dumpcontroller.h new file mode 100644 index 00000000..a3787dbb --- /dev/null +++ b/YACReaderLibrary/server/controllers/dumpcontroller.h @@ -0,0 +1,29 @@ +/** + @file + @author Stefan Frings +*/ + +#ifndef DUMPCONTROLLER_H +#define DUMPCONTROLLER_H + +#include "httprequest.h" +#include "httpresponse.h" +#include "httprequesthandler.h" + +/** + This controller dumps the received HTTP request in the response. +*/ + +class DumpController : public HttpRequestHandler { + Q_OBJECT + Q_DISABLE_COPY(DumpController); +public: + + /** Constructor */ + DumpController(); + + /** Generates the response */ + void service(HttpRequest& request, HttpResponse& response); +}; + +#endif // DUMPCONTROLLER_H diff --git a/YACReaderLibrary/server/controllers/fileuploadcontroller.cpp b/YACReaderLibrary/server/controllers/fileuploadcontroller.cpp new file mode 100644 index 00000000..30d76035 --- /dev/null +++ b/YACReaderLibrary/server/controllers/fileuploadcontroller.cpp @@ -0,0 +1,38 @@ +/** + @file + @author Stefan Frings +*/ + +#include "fileuploadcontroller.h" + +FileUploadController::FileUploadController() {} + +void FileUploadController::service(HttpRequest& request, HttpResponse& response) { + + if (request.getParameter("action")=="show") { + response.setHeader("Content-Type", "image/jpeg"); + QTemporaryFile* file=request.getUploadedFile("file1"); + if (file) { + while (!file->atEnd() && !file->error()) { + QByteArray buffer=file->read(65536); + response.write(buffer); + } + } + else { + response.write("upload failed"); + } + } + + else { + response.setHeader("Content-Type", "text/html; charset=ISO-8859-1"); + response.write(""); + response.write("Upload a JPEG image file

"); + response.write("

"); + response.write(" "); + response.write(" File:
"); + response.write(" "); + response.write("
"); + response.write("",true); + } +} + diff --git a/YACReaderLibrary/server/controllers/fileuploadcontroller.h b/YACReaderLibrary/server/controllers/fileuploadcontroller.h new file mode 100644 index 00000000..01865ea6 --- /dev/null +++ b/YACReaderLibrary/server/controllers/fileuploadcontroller.h @@ -0,0 +1,30 @@ +/** + @file + @author Stefan Frings +*/ + +#ifndef FILEUPLOADCONTROLLER_H +#define FILEUPLOADCONTROLLER_H + +#include "httprequest.h" +#include "httpresponse.h" +#include "httprequesthandler.h" + +/** + This controller displays a HTML form for file upload and recieved the file. +*/ + + +class FileUploadController : public HttpRequestHandler { + Q_OBJECT + Q_DISABLE_COPY(FileUploadController); +public: + + /** Constructor */ + FileUploadController(); + + /** Generates the response */ + void service(HttpRequest& request, HttpResponse& response); +}; + +#endif // FILEUPLOADCONTROLLER_H diff --git a/YACReaderLibrary/server/controllers/formcontroller.cpp b/YACReaderLibrary/server/controllers/formcontroller.cpp new file mode 100644 index 00000000..bcfebd66 --- /dev/null +++ b/YACReaderLibrary/server/controllers/formcontroller.cpp @@ -0,0 +1,33 @@ +/** + @file + @author Stefan Frings +*/ + +#include "formcontroller.h" + +FormController::FormController() {} + +void FormController::service(HttpRequest& request, HttpResponse& response) { + + response.setHeader("Content-Type", "text/html; charset=ISO-8859-1"); + + if (request.getParameter("action")=="show") { + response.write(""); + response.write("Name = "); + response.write(request.getParameter("name")); + response.write("
City = "); + response.write(request.getParameter("city")); + response.write("",true); + } + else { + response.write(""); + response.write("
"); + response.write(" "); + response.write(" Name:
"); + response.write(" City:
"); + response.write(" "); + response.write("
"); + response.write("",true); + } +} + diff --git a/YACReaderLibrary/server/controllers/formcontroller.h b/YACReaderLibrary/server/controllers/formcontroller.h new file mode 100644 index 00000000..5ae709a8 --- /dev/null +++ b/YACReaderLibrary/server/controllers/formcontroller.h @@ -0,0 +1,30 @@ +/** + @file + @author Stefan Frings +*/ + +#ifndef FORMCONTROLLER_H +#define FORMCONTROLLER_H + +#include "httprequest.h" +#include "httpresponse.h" +#include "httprequesthandler.h" + +/** + This controller displays a HTML form and dumps the submitted input. +*/ + + +class FormController : public HttpRequestHandler { + Q_OBJECT + Q_DISABLE_COPY(FormController); +public: + + /** Constructor */ + FormController(); + + /** Generates the response */ + void service(HttpRequest& request, HttpResponse& response); +}; + +#endif // FORMCONTROLLER_H diff --git a/YACReaderLibrary/server/controllers/sessioncontroller.cpp b/YACReaderLibrary/server/controllers/sessioncontroller.cpp new file mode 100644 index 00000000..34d56526 --- /dev/null +++ b/YACReaderLibrary/server/controllers/sessioncontroller.cpp @@ -0,0 +1,31 @@ +/** + @file + @author Stefan Frings +*/ + +#include "sessioncontroller.h" +#include "../static.h" +#include +#include + +SessionController::SessionController(){} + +void SessionController::service(HttpRequest& request, HttpResponse& response) { + + response.setHeader("Content-Type", "text/html; charset=ISO-8859-1"); + + // Get current session, or create a new one + HttpSession session=Static::sessionStore->getSession(request,response); + if (!session.contains("startTime")) { + response.write("New session started. Reload this page now."); + session.set("startTime",QDateTime::currentDateTime()); + } + + else { + QDateTime startTime=session.get("startTime").toDateTime(); + response.write("Your session started "); + response.write(startTime.toString().toLatin1()); + response.write(""); + } + +} diff --git a/YACReaderLibrary/server/controllers/sessioncontroller.h b/YACReaderLibrary/server/controllers/sessioncontroller.h new file mode 100644 index 00000000..a13ee51f --- /dev/null +++ b/YACReaderLibrary/server/controllers/sessioncontroller.h @@ -0,0 +1,29 @@ +/** + @file + @author Stefan Frings +*/ + +#ifndef SESSIONCONTROLLER_H +#define SESSIONCONTROLLER_H + +#include "httprequest.h" +#include "httpresponse.h" +#include "httprequesthandler.h" + +/** + This controller demonstrates how to use sessions. +*/ + +class SessionController : public HttpRequestHandler { + Q_OBJECT + Q_DISABLE_COPY(SessionController); +public: + + /** Constructor */ + SessionController(); + + /** Generates the response */ + void service(HttpRequest& request, HttpResponse& response); +}; + +#endif // SESSIONCONTROLLER_H diff --git a/YACReaderLibrary/server/controllers/templatecontroller.cpp b/YACReaderLibrary/server/controllers/templatecontroller.cpp new file mode 100644 index 00000000..d1816808 --- /dev/null +++ b/YACReaderLibrary/server/controllers/templatecontroller.cpp @@ -0,0 +1,31 @@ +/** + @file + @author Stefan Frings +*/ + +#include "templatecontroller.h" +#include "template.h" +#include "../static.h" + +TemplateController::TemplateController(){} + +void TemplateController::service(HttpRequest& request, HttpResponse& response) { + + response.setHeader("Content-Type", "text/html; charset=ISO-8859-1"); + + Template t=Static::templateLoader->getTemplate("demo",request.getHeader("Accept-Language")); + t.enableWarnings(); + t.setVariable("path",request.getPath()); + QMap headers=request.getHeaderMap(); + QMapIterator iterator(headers); + t.loop("header",headers.size()); + int i=0; + while (iterator.hasNext()) { + iterator.next(); + t.setVariable(QString("header%1.name").arg(i),QString(iterator.key())); + t.setVariable(QString("header%1.value").arg(i),QString(iterator.value())); + ++i; + } + + response.write(t.toLatin1(),true); +} diff --git a/YACReaderLibrary/server/controllers/templatecontroller.h b/YACReaderLibrary/server/controllers/templatecontroller.h new file mode 100644 index 00000000..c5b0077d --- /dev/null +++ b/YACReaderLibrary/server/controllers/templatecontroller.h @@ -0,0 +1,30 @@ +/** + @file + @author Stefan Frings +*/ + +#ifndef TEMPLATECONTROLLER_H +#define TEMPLATECONTROLLER_H + +#include "httprequest.h" +#include "httpresponse.h" +#include "httprequesthandler.h" + +/** + This controller generates a website using the template engine. + It generates a Latin1 (ISO-8859-1) encoded website from a UTF-8 encoded template file. +*/ + +class TemplateController : public HttpRequestHandler { + Q_OBJECT + Q_DISABLE_COPY(TemplateController); + public: + + /** Constructor */ + TemplateController(); + + /** Generates the response */ + void service(HttpRequest& request, HttpResponse& response); + }; + +#endif // TEMPLATECONTROLLER_H diff --git a/YACReaderLibrary/server/documentcache.h b/YACReaderLibrary/server/documentcache.h new file mode 100644 index 00000000..06ff67ac --- /dev/null +++ b/YACReaderLibrary/server/documentcache.h @@ -0,0 +1,4 @@ +#ifndef DOCUMENTCACHE_H +#define DOCUMENTCACHE_H + +#endif // DOCUMENTCACHE_H diff --git a/YACReaderLibrary/server/lib/bfHttpServer/bfHttpServer.pri b/YACReaderLibrary/server/lib/bfHttpServer/bfHttpServer.pri new file mode 100644 index 00000000..a109a573 --- /dev/null +++ b/YACReaderLibrary/server/lib/bfHttpServer/bfHttpServer.pri @@ -0,0 +1,12 @@ +INCLUDEPATH += $$PWD +DEPENDPATH += $$PWD + +HEADERS += $$PWD/httplistener.h $$PWD/httpconnectionhandler.h $$PWD/httpconnectionhandlerpool.h $$PWD/httprequest.h $$PWD/httpresponse.h $$PWD/httpcookie.h $$PWD/httprequesthandler.h +HEADERS += $$PWD/httpsession.h $$PWD/httpsessionstore.h +HEADERS += $$PWD/staticfilecontroller.h + +SOURCES += $$PWD/httplistener.cpp $$PWD/httpconnectionhandler.cpp $$PWD/httpconnectionhandlerpool.cpp $$PWD/httprequest.cpp $$PWD/httpresponse.cpp $$PWD/httpcookie.cpp $$PWD/httprequesthandler.cpp +SOURCES += $$PWD/httpsession.cpp $$PWD/httpsessionstore.cpp +SOURCES += $$PWD/staticfilecontroller.cpp + +OTHER_FILES += $$PWD/../doc/readme.txt diff --git a/YACReaderLibrary/server/lib/bfHttpServer/httpconnectionhandler.cpp b/YACReaderLibrary/server/lib/bfHttpServer/httpconnectionhandler.cpp new file mode 100644 index 00000000..91fa3365 --- /dev/null +++ b/YACReaderLibrary/server/lib/bfHttpServer/httpconnectionhandler.cpp @@ -0,0 +1,154 @@ +/** + @file + @author Stefan Frings +*/ + +#include "httpconnectionhandler.h" +#include "httpresponse.h" +#include +#include + +HttpConnectionHandler::HttpConnectionHandler(QSettings* settings, HttpRequestHandler* requestHandler) + : QThread() +{ + Q_ASSERT(settings!=0); + Q_ASSERT(requestHandler!=0); + this->settings=settings; + this->requestHandler=requestHandler; + currentRequest=0; + busy = false; // pdiener: it is not busy if it is new + // execute signals in my own thread + moveToThread(this); + socket.moveToThread(this); + readTimer.moveToThread(this); + connect(&socket, SIGNAL(readyRead()), SLOT(read())); + connect(&socket, SIGNAL(disconnected()), SLOT(disconnected())); + connect(&readTimer, SIGNAL(timeout()), SLOT(readTimeout())); + readTimer.setSingleShot(true); + qDebug("HttpConnectionHandler (%p): constructed", this); + this->start(); +} + + +HttpConnectionHandler::~HttpConnectionHandler() { + qDebug("HttpConnectionHandler (%p): destroyed", this); +} + + +void HttpConnectionHandler::run() { + qDebug("HttpConnectionHandler (%p): thread started", this); + try { + exec(); + } + catch (...) { + qCritical("HttpConnectionHandler (%p): an uncatched exception occured in the thread",this); + } + qDebug("HttpConnectionHandler (%p): thread stopped", this); + // Change to the main thread, otherwise deleteLater() would not work + moveToThread(QCoreApplication::instance()->thread()); +} + + +void HttpConnectionHandler::handleConnection(int socketDescriptor) { + qDebug("HttpConnectionHandler (%p): handle new connection", this); + busy = true; + Q_ASSERT(socket.isOpen()==false); // if not, then the handler is already busy + if (!socket.setSocketDescriptor(socketDescriptor)) { + qCritical("HttpConnectionHandler (%p): cannot initialize socket: %s", this,qPrintable(socket.errorString())); + return; + } + // Start timer for read timeout + int readTimeout=settings->value("readTimeout",10000).toInt(); + readTimer.start(readTimeout); + currentRequest=0; +} + + +bool HttpConnectionHandler::isBusy() { + //return socket.isOpen(); + return busy; // pdiener: changed this from socket readout to bool variable +} + +void HttpConnectionHandler::setBusy() { + this->busy = true; +} + + +void HttpConnectionHandler::readTimeout() { + qDebug("HttpConnectionHandler (%p): read timeout occured",this); + socket.write("HTTP/1.1 408 request timeout\r\nConnection: close\r\n\r\n408 request timeout\r\n"); + socket.disconnectFromHost(); + delete currentRequest; + currentRequest=0; +} + + +void HttpConnectionHandler::disconnected() { + qDebug("HttpConnectionHandler (%p): disconnected", this); + socket.close(); + delete currentRequest; + currentRequest=0; + readTimer.stop(); + busy = false; // pdiener: now we have finished +} + +void HttpConnectionHandler::read() { +#ifdef SUPERVERBOSE + qDebug("HttpConnectionHandler (%x): read input",(unsigned int) this); +#endif + + // Create new HttpRequest object if necessary + if (!currentRequest) { + currentRequest=new HttpRequest(settings); + } + + // Collect data for the request object + while (socket.bytesAvailable() && currentRequest->getStatus()!=HttpRequest::complete && currentRequest->getStatus()!=HttpRequest::abort) { + currentRequest->readFromSocket(socket); + if (currentRequest->getStatus()==HttpRequest::waitForBody) { + // Restart timer for read timeout, otherwise it would + // expire during large file uploads. + int readTimeout=settings->value("readTimeout",10000).toInt(); + readTimer.start(readTimeout); + } + } + + // If the request is aborted, return error message and close the connection + if (currentRequest->getStatus()==HttpRequest::abort) { + socket.write("HTTP/1.1 413 entity too large\r\nConnection: close\r\n\r\n413 Entity too large\r\n"); + socket.disconnectFromHost(); + delete currentRequest; + currentRequest=0; + return; + } + + // If the request is complete, let the request mapper dispatch it + if (currentRequest->getStatus()==HttpRequest::complete) { + readTimer.stop(); + qDebug("HttpConnectionHandler (%p): received request",this); + HttpResponse response(&socket); + try { + requestHandler->service(*currentRequest, response); + } + catch (...) { + qCritical("HttpConnectionHandler (%p): An uncatched exception occured in the request handler",this); + } + + // Finalize sending the response if not already done + if (!response.hasSentLastPart()) { + response.write(QByteArray(),true); + } + // Close the connection after delivering the response, if requested + if (QString::compare(currentRequest->getHeader("Connection"),"close",Qt::CaseInsensitive)==0) { + socket.disconnectFromHost(); + } + else { + // Start timer for next request + int readTimeout=settings->value("readTimeout",10000).toInt(); + readTimer.start(readTimeout); + } + // Prepare for next request + delete currentRequest; + currentRequest=0; + } +} diff --git a/YACReaderLibrary/server/lib/bfHttpServer/httpconnectionhandler.h b/YACReaderLibrary/server/lib/bfHttpServer/httpconnectionhandler.h new file mode 100644 index 00000000..1b793daa --- /dev/null +++ b/YACReaderLibrary/server/lib/bfHttpServer/httpconnectionhandler.h @@ -0,0 +1,97 @@ +/** + @file + @author Stefan Frings +*/ + +#ifndef HTTPCONNECTIONHANDLER_H +#define HTTPCONNECTIONHANDLER_H + +#include +#include +#include +#include +#include "httprequest.h" +#include "httprequesthandler.h" + +/** + The connection handler accepts incoming connections and dispatches incoming requests to to a + request mapper. Since HTTP clients can send multiple requests before waiting for the response, + the incoming requests are queued and processed one after the other. +

+ Example for the required configuration settings: +

+  readTimeout=60000
+  maxRequestSize=16000
+  maxMultiPartSize=1000000
+  
+

+ The readTimeout value defines the maximum time to wait for a complete HTTP request. + @see HttpRequest for description of config settings maxRequestSize and maxMultiPartSize +*/ + +class HttpConnectionHandler : public QThread { + Q_OBJECT + Q_DISABLE_COPY(HttpConnectionHandler) +public: + + /** + Constructor. + @param settings Configuration settings of the HTTP webserver + @param requestHandler handler that will process each incomin HTTP request + */ + HttpConnectionHandler(QSettings* settings, HttpRequestHandler* requestHandler); + + /** Destructor */ + virtual ~HttpConnectionHandler(); + + /** Returns true, if this handler is busy */ + bool isBusy(); + + /** Mark this handler as busy */ + void setBusy(); + + /** This shows the busy-state from a very early time */ + bool busy; + +private: + + /** Configuration settings */ + QSettings* settings; + + /** TCP socket of the current connection */ + QTcpSocket socket; + + /** Time for read timeout detection */ + QTimer readTimer; + + /** Storage for the current incoming HTTP request */ + HttpRequest* currentRequest; + + /** Dispatches received requests to services */ + HttpRequestHandler* requestHandler; + + /** Executes the htreads own event loop */ + void run(); + +public slots: + + /** + Received from from the listener, when the handler shall start processing a new connection. + @param socketDescriptor references the accepted connection. + */ + void handleConnection(int socketDescriptor); + +private slots: + + /** Received from the socket when a read-timeout occured */ + void readTimeout(); + + /** Received from the socket when incoming data can be read */ + void read(); + + /** Received from the socket when a connection has been closed */ + void disconnected(); + +}; + +#endif // HTTPCONNECTIONHANDLER_H diff --git a/YACReaderLibrary/server/lib/bfHttpServer/httpconnectionhandlerpool.cpp b/YACReaderLibrary/server/lib/bfHttpServer/httpconnectionhandlerpool.cpp new file mode 100644 index 00000000..0bdd4796 --- /dev/null +++ b/YACReaderLibrary/server/lib/bfHttpServer/httpconnectionhandlerpool.cpp @@ -0,0 +1,55 @@ +#include "httpconnectionhandlerpool.h" + +HttpConnectionHandlerPool::HttpConnectionHandlerPool(QSettings* settings, HttpRequestHandler* requestHandler) + : QObject() +{ + Q_ASSERT(settings!=0); + this->settings=settings; + this->requestHandler=requestHandler; + cleanupTimer.start(settings->value("cleanupInterval",1000).toInt()); + connect(&cleanupTimer, SIGNAL(timeout()), SLOT(cleanup())); +} + + +HttpConnectionHandlerPool::~HttpConnectionHandlerPool() { + foreach(HttpConnectionHandler* handler, pool) { + delete handler; + } +} + + +HttpConnectionHandler* HttpConnectionHandlerPool::getConnectionHandler() { + HttpConnectionHandler* freeHandler=0; + foreach(HttpConnectionHandler* handler, pool) { + if (!handler->isBusy()) { + freeHandler=handler; + } + } + if (!freeHandler) { + int maxConnectionHandlers=settings->value("maxThreads",10).toInt(); + if (pool.count()busy = true; // pdiener: set it to busy-state immediately + return freeHandler; +} + + + +void HttpConnectionHandlerPool::cleanup() { + int maxIdleHandlers=settings->value("minThreads",1).toInt(); + int idleCounter=0; + foreach(HttpConnectionHandler* handler, pool) { + if (!handler->isBusy()) { + if (++idleCounter > maxIdleHandlers) { + pool.removeOne(handler); + qDebug("HttpConnectionHandlerPool: Removed connection handler (%p), pool size is now %i",handler,pool.size()); + connect(handler,SIGNAL(finished()),handler,SLOT(deleteLater())); + handler->quit(); + break; // remove only one handler in each interval + } + } + } +} diff --git a/YACReaderLibrary/server/lib/bfHttpServer/httpconnectionhandlerpool.h b/YACReaderLibrary/server/lib/bfHttpServer/httpconnectionhandlerpool.h new file mode 100644 index 00000000..ec557d78 --- /dev/null +++ b/YACReaderLibrary/server/lib/bfHttpServer/httpconnectionhandlerpool.h @@ -0,0 +1,69 @@ +#ifndef HTTPCONNECTIONHANDLERPOOL_H +#define HTTPCONNECTIONHANDLERPOOL_H + +#include +#include +#include +#include "httpconnectionhandler.h" + +/** + Pool of http connection handlers. Connection handlers are created on demand and idle handlers are + cleaned up in regular time intervals. +

+ Example for the required configuration settings: +

+  minThreads=1
+  maxThreads=10
+  cleanupInterval=1000
+  maxRequestSize=16000
+  maxMultiPartSize=1000000
+  
+ The pool is empty initially and grows with the number of concurrent + connections. A timer removes one idle connection handler at each + interval, but a it leaves some spare handlers in memory to improve + performance. + @see HttpConnectionHandler for description of config settings readTimeout + @see HttpRequest for description of config settings maxRequestSize and maxMultiPartSize +*/ + +class HttpConnectionHandlerPool : public QObject { + Q_OBJECT + Q_DISABLE_COPY(HttpConnectionHandlerPool) +public: + + /** + Constructor. + @param settings Configuration settings for the HTTP server. Must not be 0. + @param requestHandler The handler that will process each received HTTP request. + @warning The requestMapper gets deleted by the destructor of this pool + */ + HttpConnectionHandlerPool(QSettings* settings, HttpRequestHandler* requestHandler); + + /** Destructor */ + virtual ~HttpConnectionHandlerPool(); + + /** Get a free connection handler, or 0 if not available. */ + HttpConnectionHandler* getConnectionHandler(); + +private: + + /** Settings for this pool */ + QSettings* settings; + + /** Will be assigned to each Connectionhandler during their creation */ + HttpRequestHandler* requestHandler; + + /** Pool of connection handlers */ + QList pool; + + /** Timer to clean-up unused connection handler */ + QTimer cleanupTimer; + +private slots: + + /** Received from the clean-up timer. */ + void cleanup(); + +}; + +#endif // HTTPCONNECTIONHANDLERPOOL_H diff --git a/YACReaderLibrary/server/lib/bfHttpServer/httpcookie.cpp b/YACReaderLibrary/server/lib/bfHttpServer/httpcookie.cpp new file mode 100644 index 00000000..3f5be929 --- /dev/null +++ b/YACReaderLibrary/server/lib/bfHttpServer/httpcookie.cpp @@ -0,0 +1,199 @@ +/** + @file + @author Stefan Frings +*/ + +#include "httpcookie.h" + +HttpCookie::HttpCookie() { + version=1; + maxAge=0; + secure=false; +} + +HttpCookie::HttpCookie(const QByteArray name, const QByteArray value, const int maxAge, const QByteArray path, const QByteArray comment, const QByteArray domain, const bool secure) { + this->name=name; + this->value=value; + this->maxAge=maxAge; + this->path=path; + this->comment=comment; + this->domain=domain; + this->secure=secure; + this->version=1; +} + +HttpCookie::HttpCookie(const QByteArray source) { + version=1; + maxAge=0; + secure=false; + QList list=splitCSV(source); + foreach(QByteArray part, list) { + + // Split the part into name and value + QByteArray name; + QByteArray value; + int posi=part.indexOf('='); + if (posi) { + name=part.left(posi).trimmed(); + value=part.mid(posi+1).trimmed(); + } + else { + name=part.trimmed(); + value=""; + } + + // Set fields + if (name=="Comment") { + comment=value; + } + else if (name=="Domain") { + domain=value; + } + else if (name=="Max-Age") { + maxAge=value.toInt(); + } + else if (name=="Path") { + path=value; + } + else if (name=="Secure") { + secure=true; + } + else if (name=="Version") { + version=value.toInt(); + } + else { + if (this->name.isEmpty()) { + this->name=name; + this->value=value; + } + else { + qWarning("HttpCookie: Ignoring unknown %s=%s",name.data(),value.data()); + } + } + } +} + +QByteArray HttpCookie::toByteArray() const { + QByteArray buffer(name); + buffer.append('='); + buffer.append(value); + if (!comment.isEmpty()) { + buffer.append("; Comment="); + buffer.append(comment); + } + if (!domain.isEmpty()) { + buffer.append("; Domain="); + buffer.append(domain); + } + if (maxAge!=0) { + buffer.append("; Max-Age="); + buffer.append(QByteArray::number(maxAge)); + } + if (!path.isEmpty()) { + buffer.append("; Path="); + buffer.append(path); + } + if (secure) { + buffer.append("; Secure"); + } + buffer.append("; Version="); + buffer.append(QByteArray::number(version)); + return buffer; +} + +void HttpCookie::setName(const QByteArray name){ + this->name=name; +} + +void HttpCookie::setValue(const QByteArray value){ + this->value=value; +} + +void HttpCookie::setComment(const QByteArray comment){ + this->comment=comment; +} + +void HttpCookie::setDomain(const QByteArray domain){ + this->domain=domain; +} + +void HttpCookie::setMaxAge(const int maxAge){ + this->maxAge=maxAge; +} + +void HttpCookie::setPath(const QByteArray path){ + this->path=path; +} + +void HttpCookie::setSecure(const bool secure){ + this->secure=secure; +} + +QByteArray HttpCookie::getName() const { + return name; +} + +QByteArray HttpCookie::getValue() const { + return value; +} + +QByteArray HttpCookie::getComment() const { + return comment; +} + +QByteArray HttpCookie::getDomain() const { + return domain; +} + +int HttpCookie::getMaxAge() const { + return maxAge; +} + +QByteArray HttpCookie::getPath() const { + return path; +} + +bool HttpCookie::getSecure() const { + return secure; +} + +int HttpCookie::getVersion() const { + return version; +} + +QList HttpCookie::splitCSV(const QByteArray source) { + bool inString=false; + QList list; + QByteArray buffer; + for (int i=0; i +#include + +/** + HTTP cookie as defined in RFC 2109. This class can also parse + RFC 2965 cookies, but skips fields that are not defined in RFC + 2109. +*/ + +class HttpCookie +{ +public: + + /** Creates an empty cookie */ + HttpCookie(); + + /** + Create a cookie and set name/value pair. + @param name name of the cookie + @param value value of the cookie + @param maxAge maximum age of the cookie in seconds. 0=discard immediately + @param path Path for that the cookie will be sent, default="/" which means the whole domain + @param comment Optional comment, may be displayed by the web browser somewhere + @param domain Optional domain for that the cookie will be sent. Defaults to the current domain + @param secure If true, the cookie will only be sent on secure connections + */ + HttpCookie(const QByteArray name, const QByteArray value, const int maxAge, const QByteArray path="/", const QByteArray comment=QByteArray(), const QByteArray domain=QByteArray(), const bool secure=false); + + /** + Create a cookie from a string. + @param source String as received in a HTTP Cookie2 header. + */ + HttpCookie(const QByteArray source); + + /** Convert this cookie to a string that may be used in a Set-Cookie2 header. */ + QByteArray toByteArray() const ; + + /** + Split a string list into parts, where each part is delimited by semicolon. + Semicolons within double quotes are skipped. Double quotes are removed. + */ + static QList splitCSV(const QByteArray source); + + /** Set the name of this cookie */ + void setName(const QByteArray name); + + /** Set the value of this cookie */ + void setValue(const QByteArray value); + + /** Set the comment of this cookie */ + void setComment(const QByteArray comment); + + /** Set the domain of this cookie */ + void setDomain(const QByteArray domain); + + /** Set the maximum age of this cookie in seconds. 0=discard immediately */ + void setMaxAge(const int maxAge); + + /** Set the path for that the cookie will be sent, default="/" which means the whole domain */ + void setPath(const QByteArray path); + + /** Set secure mode, so that the cokkie will only be sent on secure connections */ + void setSecure(const bool secure); + + /** Get the name of this cookie */ + QByteArray getName() const; + + /** Get the value of this cookie */ + QByteArray getValue() const; + + /** Get the comment of this cookie */ + QByteArray getComment() const; + + /** Get the domain of this cookie */ + QByteArray getDomain() const; + + /** Set the maximum age of this cookie in seconds. */ + int getMaxAge() const; + + /** Set the path of this cookie */ + QByteArray getPath() const; + + /** Get the secure flag of this cookie */ + bool getSecure() const; + + /** Returns always 1 */ + int getVersion() const; + +private: + + QByteArray name; + QByteArray value; + QByteArray comment; + QByteArray domain; + int maxAge; + QByteArray path; + bool secure; + int version; + +}; + +#endif // HTTPCOOKIE_H diff --git a/YACReaderLibrary/server/lib/bfHttpServer/httplistener.cpp b/YACReaderLibrary/server/lib/bfHttpServer/httplistener.cpp new file mode 100644 index 00000000..bcac23cb --- /dev/null +++ b/YACReaderLibrary/server/lib/bfHttpServer/httplistener.cpp @@ -0,0 +1,56 @@ +/** + @file + @author Stefan Frings +*/ + +#include "httplistener.h" +#include "httpconnectionhandler.h" +#include "httpconnectionhandlerpool.h" +#include + +HttpListener::HttpListener(QSettings* settings, HttpRequestHandler* requestHandler, QObject *parent) + : QTcpServer(parent), pool(settings,requestHandler) +{ + Q_ASSERT(settings!=0); + this->settings=settings; + // Start listening + int port=settings->value("port").toInt(); + listen(QHostAddress::Any, port); + if (!isListening()) { + qCritical("HttpListener: Cannot bind on port %i: %s",port,qPrintable(errorString())); + } + else { + qDebug("HttpListener: Listening on port %i",port); + } +} + +HttpListener::~HttpListener() { + close(); + qDebug("HttpListener: closed"); +} + + +void HttpListener::incomingConnection(int socketDescriptor) { +#ifdef SUPERVERBOSE + qDebug("HttpListener: New connection"); +#endif + HttpConnectionHandler* freeHandler=pool.getConnectionHandler(); + + // Let the handler process the new connection. + if (freeHandler) { + // The descriptor is passed via signal/slot because the handler lives in another + // thread and cannot open the socket when called by another thread. + connect(this,SIGNAL(handleConnection(int)),freeHandler,SLOT(handleConnection(int))); + emit handleConnection(socketDescriptor); + disconnect(this,SIGNAL(handleConnection(int)),freeHandler,SLOT(handleConnection(int))); + } + else { + // Reject the connection + qDebug("HttpListener: Too many connections"); + QTcpSocket* socket=new QTcpSocket(this); + socket->setSocketDescriptor(socketDescriptor); + connect(socket, SIGNAL(disconnected()), socket, SLOT(deleteLater())); + socket->write("HTTP/1.1 503 too many connections\r\nConnection: close\r\n\r\nToo many connections\r\n"); + socket->disconnectFromHost(); + } +} diff --git a/YACReaderLibrary/server/lib/bfHttpServer/httplistener.h b/YACReaderLibrary/server/lib/bfHttpServer/httplistener.h new file mode 100644 index 00000000..614e3c5e --- /dev/null +++ b/YACReaderLibrary/server/lib/bfHttpServer/httplistener.h @@ -0,0 +1,76 @@ +/** + @file + @author Stefan Frings +*/ + +#ifndef LISTENER_H +#define LISTENER_H + +#include +#include +#include +#include "httpconnectionhandler.h" +#include "httpconnectionhandlerpool.h" +#include "httprequesthandler.h" + +/** + Listens for incoming TCP connections and passes control to + one of the pooled connection handlers. This class is also + responsible for managing the pool. +

+ Example for the required settings in the config file: +

+  port=8080
+  minThreads=1
+  maxThreads=10
+  cleanupInterval=1000
+  readTimeout=60000
+  maxRequestSize=16000
+  maxMultiPartSize=1000000
+  
+ The port number is the incoming TCP port that this listener listens to. + @see HttpConnectionHandlerPool for description of config settings minThreads, maxThreads and cleanupInterval + @see HttpConnectionHandler for description of config settings readTimeout + @see HttpRequest for description of config settings maxRequestSize and maxMultiPartSize +*/ + +class HttpListener : public QTcpServer { + Q_OBJECT + Q_DISABLE_COPY(HttpListener) +public: + + /** + Constructor. + @param settings Configuration settings for the HTTP server. Must not be 0. + @param requestHandler Processes each received HTTP request, usually by dispatching to controller classes. + @param parent Parent object + */ + HttpListener(QSettings* settings, HttpRequestHandler* requestHandler, QObject* parent = 0); + + /** Destructor */ + virtual ~HttpListener(); + +protected: + + /** Serves new incoming connection requests */ + void incomingConnection(int socketDescriptor); + +private: + + /** Configuration settings for the HTTP server */ + QSettings* settings; + + /** Pool of connection handlers */ + HttpConnectionHandlerPool pool; + +signals: + + /** + Emitted when the connection handler shall process a new incoming onnection. + @param socketDescriptor references the accepted connection. + */ + void handleConnection(int socketDescriptor); + +}; + +#endif // LISTENER_H diff --git a/YACReaderLibrary/server/lib/bfHttpServer/httprequest.cpp b/YACReaderLibrary/server/lib/bfHttpServer/httprequest.cpp new file mode 100644 index 00000000..f63b3502 --- /dev/null +++ b/YACReaderLibrary/server/lib/bfHttpServer/httprequest.cpp @@ -0,0 +1,435 @@ +/** + @file + @author Stefan Frings +*/ + +#include "httprequest.h" +#include +#include +#include "httpcookie.h" + +HttpRequest::HttpRequest(QSettings* settings) { + status=waitForRequest; + currentSize=0; + expectedBodySize=0; + maxSize=settings->value("maxRequestSize","16000").toInt(); + maxMultiPartSize=settings->value("maxMultiPartSize","1000000").toInt(); + + // Convert relative path to absolute, based on the directory of the config file. +#ifdef Q_OS_WIN32 + if (QDir::isRelativePath(tempDir) && settings->format()!=QSettings::NativeFormat) +#else + if (QDir::isRelativePath(tempDir)) +#endif + { + QFileInfo configFile(settings->fileName()); + tempDir=QFileInfo(configFile.absolutePath(),tempDir).absoluteFilePath(); + } +} + +void HttpRequest::readRequest(QTcpSocket& socket) { +#ifdef SUPERVERBOSE + qDebug("HttpRequest: read request"); +#endif + int toRead=maxSize-currentSize+1; // allow one byte more to be able to detect overflow + QByteArray newData=socket.readLine(toRead).trimmed(); + currentSize+=newData.size(); + if (!newData.isEmpty()) { + QList list=newData.split(' '); + if (list.count()!=3 || !list.at(2).contains("HTTP")) { + qWarning("HttpRequest: received broken HTTP request, invalid first line"); + status=abort; + } + else { + method=list.at(0); + path=list.at(1); + version=list.at(2); + status=waitForHeader; + } + } +} + +void HttpRequest::readHeader(QTcpSocket& socket) { +#ifdef SUPERVERBOSE + qDebug("HttpRequest: read header"); +#endif + int toRead=maxSize-currentSize+1; // allow one byte more to be able to detect overflow + QByteArray newData=socket.readLine(toRead).trimmed(); + currentSize+=newData.size(); + int colon=newData.indexOf(':'); + if (colon>0) { + // Received a line with a colon - a header + currentHeader=newData.left(colon); + QByteArray value=newData.mid(colon+1).trimmed(); + headers.insert(currentHeader,value); +#ifdef SUPERVERBOSE + qDebug("HttpRequest: received header %s: %s",currentHeader.data(),value.data()); +#endif + } + else if (!newData.isEmpty()) { + // received another line - belongs to the previous header +#ifdef SUPERVERBOSE + qDebug("HttpRequest: read additional line of header"); +#endif + // Received additional line of previous header + if (headers.contains(currentHeader)) { + headers.insert(currentHeader,headers.value(currentHeader)+" "+newData); + } + } + else { + // received an empty line - end of headers reached +#ifdef SUPERVERBOSE + qDebug("HttpRequest: headers completed"); +#endif + // Empty line received, that means all headers have been received + // Check for multipart/form-data + QByteArray contentType=headers.value("Content-Type"); + if (contentType.startsWith("multipart/form-data")) { + int posi=contentType.indexOf("boundary="); + if (posi>=0) { + boundary=contentType.mid(posi+9); + } + } + QByteArray contentLength=getHeader("Content-Length"); + if (!contentLength.isEmpty()) { + expectedBodySize=contentLength.toInt(); + } + if (expectedBodySize==0) { +#ifdef SUPERVERBOSE + qDebug("HttpRequest: expect no body"); +#endif + status=complete; + } + else if (boundary.isEmpty() && expectedBodySize+currentSize>maxSize) { + qWarning("HttpRequest: expected body is too large"); + status=abort; + } + else if (!boundary.isEmpty() && expectedBodySize>maxMultiPartSize) { + qWarning("HttpRequest: expected multipart body is too large"); + status=abort; + } + else { +#ifdef SUPERVERBOSE + qDebug("HttpRequest: expect %i bytes body",expectedBodySize); +#endif + status=waitForBody; + } + } +} + +void HttpRequest::readBody(QTcpSocket& socket) { + Q_ASSERT(expectedBodySize!=0); + if (boundary.isEmpty()) { + // normal body, no multipart +#ifdef SUPERVERBOSE + qDebug("HttpRequest: receive body"); +#endif + int toRead=expectedBodySize-bodyData.size(); + QByteArray newData=socket.read(toRead); + currentSize+=newData.size(); + bodyData.append(newData); + if (bodyData.size()>=expectedBodySize) { + status=complete; + } + } + else { + // multipart body, store into temp file +#ifdef SUPERVERBOSE + qDebug("HttpRequest: receiving multipart body"); +#endif + if (!tempFile.isOpen()) { + tempFile.open(); + } + // Transfer data in 64kb blocks + int fileSize=tempFile.size(); + int toRead=expectedBodySize-fileSize; + if (toRead>65536) { + toRead=65536; + } + fileSize+=tempFile.write(socket.read(toRead)); + if (fileSize>=maxMultiPartSize) { + qWarning("HttpRequest: received too many multipart bytes"); + status=abort; + } + else if (fileSize>=expectedBodySize) { +#ifdef SUPERVERBOSE + qDebug("HttpRequest: received whole multipart body"); +#endif + tempFile.flush(); + if (tempFile.error()) { + qCritical("HttpRequest: Error writing temp file for multipart body"); + } + parseMultiPartFile(); + tempFile.close(); + status=complete; + } + } +} + +void HttpRequest::decodeRequestParams() { +#ifdef SUPERVERBOSE + qDebug("HttpRequest: extract and decode request parameters"); +#endif + QByteArray rawParameters; + if (headers.value("Content-Type")=="application/x-www-form-urlencoded") { + rawParameters=bodyData; + } + else { + int questionMark=path.indexOf('?'); + if (questionMark>=0) { + rawParameters=path.mid(questionMark+1); + path=path.left(questionMark); + } + } + // Split the parameters into pairs of value and name + QList list=rawParameters.split('&'); + foreach (QByteArray part, list) { + int equalsChar=part.indexOf('='); + if (equalsChar>=0) { + QByteArray name=part.left(equalsChar).trimmed(); + QByteArray value=part.mid(equalsChar+1).trimmed(); + parameters.insert(urlDecode(name),urlDecode(value)); + } + else if (!part.isEmpty()){ + // Name without value + parameters.insert(urlDecode(part),""); + } + } +} + +void HttpRequest::extractCookies() { +#ifdef SUPERVERBOSE + qDebug("HttpRequest: extract cookies"); +#endif + foreach(QByteArray cookieStr, headers.values("Cookie")) { + QList list=HttpCookie::splitCSV(cookieStr); + foreach(QByteArray part, list) { +#ifdef SUPERVERBOSE + qDebug("HttpRequest: found cookie %s",part.data()); +#endif // Split the part into name and value + QByteArray name; + QByteArray value; + int posi=part.indexOf('='); + if (posi) { + name=part.left(posi).trimmed(); + value=part.mid(posi+1).trimmed(); + } + else { + name=part.trimmed(); + value=""; + } + cookies.insert(name,value); + } + } + headers.remove("Cookie"); +} + +void HttpRequest::readFromSocket(QTcpSocket& socket) { + Q_ASSERT(status!=complete); + if (status==waitForRequest) { + readRequest(socket); + } + else if (status==waitForHeader) { + readHeader(socket); + } + else if (status==waitForBody) { + readBody(socket); + } + if (currentSize>maxSize) { + qWarning("HttpRequest: received too many bytes"); + status=abort; + } + if (status==complete) { + // Extract and decode request parameters from url and body + decodeRequestParams(); + // Extract cookies from headers + extractCookies(); + } +} + + +HttpRequest::RequestStatus HttpRequest::getStatus() const { + return status; +} + + +QByteArray HttpRequest::getMethod() const { + return method; +} + + +QByteArray HttpRequest::getPath() const { + return urlDecode(path); +} + + +QByteArray HttpRequest::getVersion() const { + return version; +} + + +QByteArray HttpRequest::getHeader(const QByteArray& name) const { + return headers.value(name); +} + +QList HttpRequest::getHeaders(const QByteArray& name) const { + return headers.values(name); +} + +QMultiMap HttpRequest::getHeaderMap() const { + return headers; +} + +QByteArray HttpRequest::getParameter(const QByteArray& name) const { + return parameters.value(name); +} + +QList HttpRequest::getParameters(const QByteArray& name) const { + return parameters.values(name); +} + +QMultiMap HttpRequest::getParameterMap() const { + return parameters; +} + +QByteArray HttpRequest::getBody() const { + return bodyData; +} + +QByteArray HttpRequest::urlDecode(const QByteArray source) { + QByteArray buffer(source); + buffer.replace('+',' '); + int percentChar=buffer.indexOf('%'); + while (percentChar>=0) { + bool ok; + char byte=buffer.mid(percentChar+1,2).toInt(&ok,16); + if (ok) { + buffer.replace(percentChar,3,(char*)&byte,1); + } + percentChar=buffer.indexOf('%',percentChar+1); + } + return buffer; +} + + +void HttpRequest::parseMultiPartFile() { + qDebug("HttpRequest: parsing multipart temp file"); + tempFile.seek(0); + bool finished=false; + while (!tempFile.atEnd() && !finished && !tempFile.error()) { + +#ifdef SUPERVERBOSE + qDebug("HttpRequest: reading multpart headers"); +#endif + QByteArray fieldName; + QByteArray fileName; + while (!tempFile.atEnd() && !finished && !tempFile.error()) { + QByteArray line=tempFile.readLine(65536).trimmed(); + if (line.startsWith("Content-Disposition:")) { + if (line.contains("form-data")) { + int start=line.indexOf(" name=\""); + int end=line.indexOf("\"",start+7); + if (start>=0 && end>=start) { + fieldName=line.mid(start+7,end-start-7); + } + start=line.indexOf(" filename=\""); + end=line.indexOf("\"",start+11); + if (start>=0 && end>=start) { + fileName=line.mid(start+11,end-start-11); + } +#ifdef SUPERVERBOSE + qDebug("HttpRequest: multipart field=%s, filename=%s",fieldName.data(),fileName.data()); +#endif + } + else { + qDebug("HttpRequest: ignoring unsupported content part %s",line.data()); + } + } + else if (line.isEmpty()) { + break; + } + } + +#ifdef SUPERVERBOSE + qDebug("HttpRequest: reading multpart data"); +#endif + QTemporaryFile* uploadedFile=0; + QByteArray fieldValue; + while (!tempFile.atEnd() && !finished && !tempFile.error()) { + QByteArray line=tempFile.readLine(65536); + if (line.startsWith("--"+boundary)) { + // Boundary found. Until now we have collected 2 bytes too much, + // so remove them from the last result + if (fileName.isEmpty() && !fieldName.isEmpty()) { + // last field was a form field + fieldValue.remove(fieldValue.size()-2,2); + parameters.insert(fieldName,fieldValue); + qDebug("HttpRequest: set parameter %s=%s",fieldName.data(),fieldValue.data()); + } + else if (!fileName.isEmpty() && !fieldName.isEmpty()) { + // last field was a file +#ifdef SUPERVERBOSE + qDebug("HttpRequest: finishing writing to uploaded file"); +#endif + uploadedFile->resize(uploadedFile->size()-2); + uploadedFile->flush(); + uploadedFile->seek(0); + parameters.insert(fieldName,fileName); + qDebug("HttpRequest: set parameter %s=%s",fieldName.data(),fileName.data()); + uploadedFiles.insert(fieldName,uploadedFile); + qDebug("HttpRequest: uploaded file size is %i",(int) uploadedFile->size()); + } + if (line.contains(boundary+"--")) { + finished=true; + } + break; + } + else { + if (fileName.isEmpty() && !fieldName.isEmpty()) { + // this is a form field. + currentSize+=line.size(); + fieldValue.append(line); + } + else if (!fileName.isEmpty() && !fieldName.isEmpty()) { + // this is a file + if (!uploadedFile) { + uploadedFile=new QTemporaryFile(); + uploadedFile->open(); + } + uploadedFile->write(line); + if (uploadedFile->error()) { + qCritical("HttpRequest: error writing temp file, %s",qPrintable(uploadedFile->errorString())); + } + } + } + } + } + if (tempFile.error()) { + qCritical("HttpRequest: cannot read temp file, %s",qPrintable(tempFile.errorString())); + } +#ifdef SUPERVERBOSE + qDebug("HttpRequest: finished parsing multipart temp file"); +#endif +} + +HttpRequest::~HttpRequest() { + foreach(QByteArray key, uploadedFiles.keys()) { + QTemporaryFile* file=uploadedFiles.value(key); + file->close(); + delete file; + } +} + +QTemporaryFile* HttpRequest::getUploadedFile(const QByteArray fieldName) { + return uploadedFiles.value(fieldName); +} + +QByteArray HttpRequest::getCookie(const QByteArray& name) const { + return cookies.value(name); +} + +/** Get the map of cookies */ +QMap& HttpRequest::getCookieMap() { + return cookies; +} + diff --git a/YACReaderLibrary/server/lib/bfHttpServer/httprequest.h b/YACReaderLibrary/server/lib/bfHttpServer/httprequest.h new file mode 100644 index 00000000..943a62c5 --- /dev/null +++ b/YACReaderLibrary/server/lib/bfHttpServer/httprequest.h @@ -0,0 +1,214 @@ +/** + @file + @author Stefan Frings +*/ + +#ifndef HTTPREQUEST_H +#define HTTPREQUEST_H + +#include +#include +#include +#include +#include +#include +#include + +/** + This object represents a single HTTP request. It reads the request + from a TCP socket and provides getters for the individual parts + of the request. +

+ The follwing config settings are required: +

+  maxRequestSize=16000
+  maxMultiPartSize=1000000
+  
+

+ MaxRequestSize is the maximum size of a HTTP request. In case of + multipart/form-data requests (also known as file-upload), the maximum + size of the body must not exceed maxMultiPartSize. + The body is always a little larger than the file itself. +*/ + +class HttpRequest { + Q_DISABLE_COPY(HttpRequest) + friend class HttpSessionStore; +public: + + /** Values for getStatus() */ + enum RequestStatus {waitForRequest, waitForHeader, waitForBody, complete, abort}; + + /** + Constructor. + @param settings Configuration settings + */ + HttpRequest(QSettings* settings); + + /** + Destructor. + */ + virtual ~HttpRequest(); + + /** + Read the request from a socket. This method must be called repeatedly + until the status is RequestStatus::complete or RequestStatus::abort. + @param socket Source of the data + */ + void readFromSocket(QTcpSocket& socket); + + /** + Get the status of this reqeust. + @see RequestStatus + */ + RequestStatus getStatus() const; + + /** Get the method of the HTTP request (e.g. "GET") */ + QByteArray getMethod() const; + + /** Get the decoded path of the HTPP request (e.g. "/index.html") */ + QByteArray getPath() const; + + /** Get the version of the HTPP request (e.g. "HTTP/1.1") */ + QByteArray getVersion() const; + + /** + Get the value of a HTTP request header. + @param name Name of the header + @return If the header occurs multiple times, only the last + one is returned. + */ + QByteArray getHeader(const QByteArray& name) const; + + /** + Get the values of a HTTP request header. + @param name Name of the header + */ + QList getHeaders(const QByteArray& name) const; + + /** Get all HTTP request headers */ + QMultiMap getHeaderMap() const; + + /** + Get the value of a HTTP request parameter. + @param name Name of the parameter + @return If the parameter occurs multiple times, only the last + one is returned. + */ + QByteArray getParameter(const QByteArray& name) const; + + /** + Get the values of a HTTP request parameter. + @param name Name of the parameter + */ + QList getParameters(const QByteArray& name) const; + + /** Get all HTTP request parameters */ + QMultiMap getParameterMap() const; + + /** Get the HTTP request body */ + QByteArray getBody() const; + + /** + Decode an URL parameter. + E.g. replace "%23" by '#' and replace '+' by ' ' + @param source The url encoded string + */ + static QByteArray urlDecode(const QByteArray source); + + /** + Get an uploaded file. The file is already open. It will + be closed and deleted by the destructor of this HttpRequest + object (after processing the request). +

+ For uploaded files, the method getParameters() returns + the original fileName as provided by the calling web browser. + */ + QTemporaryFile* getUploadedFile(const QByteArray fieldName); + + /** + Get the value of a cookie + @param name Name of the cookie + */ + QByteArray getCookie(const QByteArray& name) const; + + /** Get the map of cookies */ + QMap& getCookieMap(); + +private: + + /** Request headers */ + QMultiMap headers; + + /** Parameters of the request */ + QMultiMap parameters; + + /** Uploaded files of the request, key is the field name. */ + QMap uploadedFiles; + + /** Received cookies */ + QMap cookies; + + /** Storage for raw body data */ + QByteArray bodyData; + + /** Request method */ + QByteArray method; + + /** Request path (in raw encoded format) */ + QByteArray path; + + /** Request protocol version */ + QByteArray version; + + /** + Status of this request. + @see RequestStatus + */ + RequestStatus status; + + /** Maximum size of requests in bytes. */ + int maxSize; + + /** Maximum allowed size of multipart forms in bytes. */ + int maxMultiPartSize; + + /** Directory for temp files */ + QString tempDir; + + /** Current size */ + int currentSize; + + /** Expected size of body */ + int expectedBodySize; + + /** Name of the current header, or empty if no header is being processed */ + QByteArray currentHeader; + + /** Boundary of multipart/form-data body. Empty if there is no such header */ + QByteArray boundary; + + /** Temp file, that is used to store the multipart/form-data body */ + QTemporaryFile tempFile; + + /** Parset he multipart body, that has been stored in the temp file. */ + void parseMultiPartFile(); + + /** Sub-procedure of readFromSocket(), read the first line of a request. */ + void readRequest(QTcpSocket& socket); + + /** Sub-procedure of readFromSocket(), read header lines. */ + void readHeader(QTcpSocket& socket); + + /** Sub-procedure of readFromSocket(), read the request body. */ + void readBody(QTcpSocket& socket); + + /** Sub-procedure of readFromSocket(), extract and decode request parameters. */ + void decodeRequestParams(); + + /** Sub-procedure of readFromSocket(), extract cookies from headers */ + void extractCookies(); + +}; + +#endif // HTTPREQUEST_H diff --git a/YACReaderLibrary/server/lib/bfHttpServer/httprequesthandler.cpp b/YACReaderLibrary/server/lib/bfHttpServer/httprequesthandler.cpp new file mode 100644 index 00000000..d8ad7caf --- /dev/null +++ b/YACReaderLibrary/server/lib/bfHttpServer/httprequesthandler.cpp @@ -0,0 +1,19 @@ +/** + @file + @author Stefan Frings +*/ + +#include "httprequesthandler.h" + +HttpRequestHandler::HttpRequestHandler(QObject* parent) + : QObject(parent) +{} + +HttpRequestHandler::~HttpRequestHandler() {} + +void HttpRequestHandler::service(HttpRequest& request, HttpResponse& response) { + qCritical("HttpRequestHandler: you need to override the dispatch() function"); + qDebug("HttpRequestHandler: request=%s %s %s",request.getMethod().data(),request.getPath().data(),request.getVersion().data()); + response.setStatus(501,"not implemented"); + response.write("501 not implemented",true); +} diff --git a/YACReaderLibrary/server/lib/bfHttpServer/httprequesthandler.h b/YACReaderLibrary/server/lib/bfHttpServer/httprequesthandler.h new file mode 100644 index 00000000..a5f9f4e2 --- /dev/null +++ b/YACReaderLibrary/server/lib/bfHttpServer/httprequesthandler.h @@ -0,0 +1,45 @@ +/** + @file + @author Stefan Frings +*/ + +#ifndef HTTPREQUESTHANDLER_H +#define HTTPREQUESTHANDLER_H + +#include "httprequest.h" +#include "httpresponse.h" + +/** + The request handler generates a response for each HTTP request. Web Applications + usually have one central request handler that maps incoming requests to several + controllers (servlets) based on the requested path. +

+ You need to override the service() method or you will always get an HTTP error 501. +

+ @warning Be aware that the main request handler instance must be created on the heap and + that it is used by multiple threads simultaneously. + @see StaticFileController which delivers static local files. +*/ + +class HttpRequestHandler : public QObject { + Q_OBJECT + Q_DISABLE_COPY(HttpRequestHandler) +public: + + /** Constructor */ + HttpRequestHandler(QObject* parent=0); + + /** Destructor */ + virtual ~HttpRequestHandler(); + + /** + Generate a response for an incoming HTTP request. + @param request The received HTTP request + @param response Must be used to return the response + @warning This method must be thread safe + */ + virtual void service(HttpRequest& request, HttpResponse& response); + +}; + +#endif // HTTPREQUESTHANDLER_H diff --git a/YACReaderLibrary/server/lib/bfHttpServer/httpresponse.cpp b/YACReaderLibrary/server/lib/bfHttpServer/httpresponse.cpp new file mode 100644 index 00000000..efa3ee8a --- /dev/null +++ b/YACReaderLibrary/server/lib/bfHttpServer/httpresponse.cpp @@ -0,0 +1,122 @@ +/** + @file + @author Stefan Frings +*/ + +#include "httpresponse.h" + +HttpResponse::HttpResponse(QTcpSocket* socket) { + this->socket=socket; + statusCode=200; + statusText="OK"; + sentHeaders=false; + sentLastPart=false; +} + +void HttpResponse::setHeader(QByteArray name, QByteArray value) { + Q_ASSERT(sentHeaders==false); + headers.insert(name,value); +} + +void HttpResponse::setHeader(QByteArray name, int value) { + Q_ASSERT(sentHeaders==false); + headers.insert(name,QByteArray::number(value)); +} + +QMap& HttpResponse::getHeaders() { + return headers; +} + +void HttpResponse::setStatus(int statusCode, QByteArray description) { + this->statusCode=statusCode; + statusText=description; +} + +void HttpResponse::writeHeaders() { + Q_ASSERT(sentHeaders==false); + QByteArray buffer; + buffer.append("HTTP/1.1 "); + buffer.append(QByteArray::number(statusCode)); + buffer.append(' '); + buffer.append(statusText); + buffer.append("\r\n"); + foreach(QByteArray name, headers.keys()) { + buffer.append(name); + buffer.append(": "); + buffer.append(headers.value(name)); + buffer.append("\r\n"); + } + foreach(HttpCookie cookie,cookies.values()) { + buffer.append("Set-Cookie: "); + buffer.append(cookie.toByteArray()); + buffer.append("\r\n"); + } + buffer.append("\r\n"); + writeToSocket(buffer); + sentHeaders=true; +} + +void HttpResponse::writeToSocket(QByteArray data) { + int remaining=data.size(); + char* ptr=data.data(); + while (socket->isOpen() && remaining>0) { + int written=socket->write(data); + ptr+=written; + remaining-=written; + } +} + +void HttpResponse::write(QByteArray data, bool lastPart) { + Q_ASSERT(sentLastPart==false); + if (sentHeaders==false) { + QByteArray connectionMode=headers.value("Connection"); + if (!headers.contains("Content-Length") && !headers.contains("Transfer-Encoding") && connectionMode!="close" && connectionMode!="Close") { + if (!lastPart) { + headers.insert("Transfer-Encoding","chunked"); + } + else { + headers.insert("Content-Length",QByteArray::number(data.size())); + } + } + writeHeaders(); + } + bool chunked=headers.value("Transfer-Encoding")=="chunked" || headers.value("Transfer-Encoding")=="Chunked"; + if (chunked) { + if (data.size()>0) { + QByteArray buffer=QByteArray::number(data.size(),16); + buffer.append("\r\n"); + writeToSocket(buffer); + writeToSocket(data); + writeToSocket("\r\n"); + } + } + else { + writeToSocket(data); + } + if (lastPart) { + if (chunked) { + writeToSocket("0\r\n\r\n"); + } + else if (!headers.contains("Content-Length")) { + socket->disconnectFromHost(); + } + sentLastPart=true; + } +} + + +bool HttpResponse::hasSentLastPart() const { + return sentLastPart; +} + + +void HttpResponse::setCookie(const HttpCookie& cookie) { + Q_ASSERT(sentHeaders==false); + if (!cookie.getName().isEmpty()) { + cookies.insert(cookie.getName(),cookie); + } +} + +QMap& HttpResponse::getCookies() { + return cookies; +} diff --git a/YACReaderLibrary/server/lib/bfHttpServer/httpresponse.h b/YACReaderLibrary/server/lib/bfHttpServer/httpresponse.h new file mode 100644 index 00000000..3c28a903 --- /dev/null +++ b/YACReaderLibrary/server/lib/bfHttpServer/httpresponse.h @@ -0,0 +1,134 @@ +/** + @file + @author Stefan Frings +*/ + +#ifndef HTTPRESPONSE_H +#define HTTPRESPONSE_H + +#include +#include +#include +#include "httpcookie.h" + +/** + This object represents a HTTP response, in particular the response headers. +

+ Example code for proper response generation: +

+    response.setStatus(200,"OK"); // optional, because this is the default
+    response.writeBody("Hello");
+    response.writeBody("World!",true);
+  
+

+ Example how to return an error: +

+    response.setStatus(500,"server error");
+    response.write("The request cannot be processed because the servers is broken",true);
+  
+

+ For performance reason, writing a single or few large packets is better than writing + many small packets. In case of large responses (e.g. file downloads), a Content-Length + header should be set before calling write(). Web Browsers use that information to display + a progress bar. +*/ + +class HttpResponse { + Q_DISABLE_COPY(HttpResponse) +public: + + /** + Constructor. + @param socket used to write the response + */ + HttpResponse(QTcpSocket* socket); + + /** + Set a HTTP response header + @param name name of the header + @param value value of the header + */ + void setHeader(QByteArray name, QByteArray value); + + /** + Set a HTTP response header + @param name name of the header + @param value value of the header + */ + void setHeader(QByteArray name, int value); + + /** Get the map of HTTP response headers */ + QMap& getHeaders(); + + /** Get the map of cookies */ + QMap& getCookies(); + + /** + Set status code and description. The default is 200,OK. + */ + void setStatus(int statusCode, QByteArray description=QByteArray()); + + /** + Write body data to the socket. +

+ The HTTP status line and headers are sent automatically before the first + byte of the body gets sent. +

+ If the response contains only a single chunk (indicated by lastPart=true), + the response is transferred in traditional mode with a Content-Length + header, which is automatically added if not already set before. +

+ Otherwise, each part is transferred in chunked mode. + @param data Data bytes of the body + @param lastPart Indicator, if this is the last part of the response. + */ + void write(QByteArray data, bool lastPart=false); + + /** + Indicates wheter the body has been sent completely. Used by the connection + handler to terminate the body automatically when necessary. + */ + bool hasSentLastPart() const; + + /** + Set a cookie. Cookies are sent together with the headers when the first + call to write() occurs. + */ + void setCookie(const HttpCookie& cookie); + +private: + + /** Request headers */ + QMap headers; + + /** Socket for writing output */ + QTcpSocket* socket; + + /** HTTP status code*/ + int statusCode; + + /** HTTP status code description */ + QByteArray statusText; + + /** Indicator whether headers have been sent */ + bool sentHeaders; + + /** Indicator whether the body has been sent completely */ + bool sentLastPart; + + /** Cookies */ + QMap cookies; + + /** Write raw data to the socket. This method blocks until all bytes have been passed to the TCP buffer */ + void writeToSocket(QByteArray data); + + /** + Write the response HTTP status and headers to the socket. + Calling this method is optional, because writeBody() calls + it automatically when required. + */ + void writeHeaders(); + +}; + +#endif // HTTPRESPONSE_H diff --git a/YACReaderLibrary/server/lib/bfHttpServer/httpsession.cpp b/YACReaderLibrary/server/lib/bfHttpServer/httpsession.cpp new file mode 100644 index 00000000..9c7bdd62 --- /dev/null +++ b/YACReaderLibrary/server/lib/bfHttpServer/httpsession.cpp @@ -0,0 +1,158 @@ +/** + @file + @author Stefan Frings +*/ + +#include "httpsession.h" +#include +#include + + +HttpSession::HttpSession(bool canStore) { + if (canStore) { + dataPtr=new HttpSessionData(); + dataPtr->refCount=1; + dataPtr->lastAccess=QDateTime::currentMSecsSinceEpoch(); + dataPtr->id=QUuid::createUuid().toString().toAscii(); +#ifdef SUPERVERBOSE + qDebug("HttpSession: created new session data with id %s",dataPtr->id.data()); +#endif + } + else { + dataPtr=0; + } +} + +HttpSession::HttpSession(const HttpSession& other) { + dataPtr=other.dataPtr; + if (dataPtr) { + dataPtr->lock.lockForWrite(); + dataPtr->refCount++; +#ifdef SUPERVERBOSE + qDebug("HttpSession: refCount of %s is %i",dataPtr->id.data(),dataPtr->refCount); +#endif + dataPtr->lock.unlock(); + } +} + +HttpSession& HttpSession::operator= (const HttpSession& other) { + HttpSessionData* oldPtr=dataPtr; + dataPtr=other.dataPtr; + if (dataPtr) { + dataPtr->lock.lockForWrite(); + dataPtr->refCount++; +#ifdef SUPERVERBOSE + qDebug("HttpSession: refCount of %s is %i",dataPtr->id.data(),dataPtr->refCount); +#endif + dataPtr->lastAccess=QDateTime::currentMSecsSinceEpoch(); + dataPtr->lock.unlock(); + } + if (oldPtr) { + int refCount; + oldPtr->lock.lockForRead(); + refCount=oldPtr->refCount--; +#ifdef SUPERVERBOSE + qDebug("HttpSession: refCount of %s is %i",oldPtr->id.data(),oldPtr->refCount); +#endif + oldPtr->lock.unlock(); + if (refCount==0) { + delete oldPtr; + } + } + return *this; +} + +HttpSession::~HttpSession() { + if (dataPtr) { + int refCount; + dataPtr->lock.lockForRead(); + refCount=--dataPtr->refCount; +#ifdef SUPERVERBOSE + qDebug("HttpSession: refCount of %s is %i",dataPtr->id.data(),dataPtr->refCount); +#endif + dataPtr->lock.unlock(); + if (refCount==0) { + qDebug("HttpSession: deleting data"); + delete dataPtr; + } + } +} + + +QByteArray HttpSession::getId() const { + if (dataPtr) { + return dataPtr->id; + } + else { + return QByteArray(); + } +} + +bool HttpSession::isNull() const { + return dataPtr==0; +} + +void HttpSession::set(const QByteArray& key, const QVariant& value) { + if (dataPtr) { + dataPtr->lock.lockForWrite(); + dataPtr->values.insert(key,value); + dataPtr->lock.unlock(); + } +} + +void HttpSession::remove(const QByteArray& key) { + if (dataPtr) { + dataPtr->lock.lockForWrite(); + dataPtr->values.remove(key); + dataPtr->lock.unlock(); + } +} + +QVariant HttpSession::get(const QByteArray& key) const { + QVariant value; + if (dataPtr) { + dataPtr->lock.lockForRead(); + value=dataPtr->values.value(key); + dataPtr->lock.unlock(); + } + return value; +} + +bool HttpSession::contains(const QByteArray& key) const { + bool found=false; + if (dataPtr) { + dataPtr->lock.lockForRead(); + found=dataPtr->values.contains(key); + dataPtr->lock.unlock(); + } + return found; +} + +QMap HttpSession::getAll() const { + QMap values; + if (dataPtr) { + dataPtr->lock.lockForRead(); + values=dataPtr->values; + dataPtr->lock.unlock(); + } + return values; +} + +qint64 HttpSession::getLastAccess() const { + qint64 value=0; + if (dataPtr) { + dataPtr->lock.lockForRead(); + value=dataPtr->lastAccess; + dataPtr->lock.unlock(); + } + return value; +} + + +void HttpSession::setLastAccess() { + if (dataPtr) { + dataPtr->lock.lockForRead(); + dataPtr->lastAccess=QDateTime::currentMSecsSinceEpoch(); + dataPtr->lock.unlock(); + } +} diff --git a/YACReaderLibrary/server/lib/bfHttpServer/httpsession.h b/YACReaderLibrary/server/lib/bfHttpServer/httpsession.h new file mode 100644 index 00000000..7a9470aa --- /dev/null +++ b/YACReaderLibrary/server/lib/bfHttpServer/httpsession.h @@ -0,0 +1,118 @@ +/** + @file + @author Stefan Frings +*/ + +#ifndef HTTPSESSION_H +#define HTTPSESSION_H + +#include +#include +#include + + +/** + This class stores data for a single HTTP session. + A session can store any number of key/value pairs. This class uses implicit + sharing for read and write access. This class is thread safe. + @see HttpSessionStore should be used to create and get instances of this class. +*/ + +class HttpSession { + +public: + + /** + Constructor. + @param canStore The session can store data, if this parameter is true. + Otherwise all calls to set() and remove() do not have any effect. + */ + HttpSession(bool canStore=false); + + /** + Copy constructor. Creates another HttpSession object that shares the + data of the other object. + */ + HttpSession(const HttpSession& other); + + /** + Copy operator. Detaches from the current shared data and attaches to + the data of the other object. + */ + HttpSession& operator= (const HttpSession& other); + + + /** + Destructor. Detaches from the shared data. + */ + virtual ~HttpSession(); + + /** Get the unique ID of this session. This method is thread safe. */ + QByteArray getId() const; + + /** + Null sessions cannot store data. All calls to set() and remove() + do not have any effect.This method is thread safe. + */ + bool isNull() const; + + /** Set a value. This method is thread safe. */ + void set(const QByteArray& key, const QVariant& value); + + /** Remove a value. This method is thread safe. */ + void remove(const QByteArray& key); + + /** Get a value. This method is thread safe. */ + QVariant get(const QByteArray& key) const; + + /** Check if a key exists. This method is thread safe. */ + bool contains(const QByteArray& key) const; + + /** + Get a copy of all data stored in this session. + Changes to the session do not affect the copy and vice versa. + This method is thread safe. + */ + QMap getAll() const; + + /** + Get the timestamp of last access. That is the time when the last + HttpSessionStore::getSession() has been called. + This method is thread safe. + */ + qint64 getLastAccess() const; + + /** + Set the timestamp of last access, to renew the timeout period. + Called by HttpSessionStore::getSession(). + This method is thread safe. + */ + void setLastAccess(); + +private: + + struct HttpSessionData { + + /** Unique ID */ + QByteArray id; + + /** Timestamp of last access, set by the HttpSessionStore */ + qint64 lastAccess; + + /** Reference counter */ + int refCount; + + /** Used to synchronize threads */ + QReadWriteLock lock; + + /** Storage for the key/value pairs; */ + QMap values; + + }; + + /** Pointer to the shared data. */ + HttpSessionData* dataPtr; + +}; + +#endif // HTTPSESSION_H diff --git a/YACReaderLibrary/server/lib/bfHttpServer/httpsessionstore.cpp b/YACReaderLibrary/server/lib/bfHttpServer/httpsessionstore.cpp new file mode 100644 index 00000000..5eb281aa --- /dev/null +++ b/YACReaderLibrary/server/lib/bfHttpServer/httpsessionstore.cpp @@ -0,0 +1,107 @@ +/** + @file + @author Stefan Frings +*/ + +#include "httpsessionstore.h" +#include +#include + +HttpSessionStore::HttpSessionStore(QSettings* settings, QObject* parent) + :QObject(parent) +{ + this->settings=settings; + connect(&cleanupTimer,SIGNAL(timeout()),this,SLOT(timerEvent())); + cleanupTimer.start(60000); + cookieName=settings->value("cookieName","sessionid").toByteArray(); + expirationTime=settings->value("expirationTime",3600000).toInt(); + qDebug("HttpSessionStore: Sessions expire after %i milliseconds",expirationTime); +} + +HttpSessionStore::~HttpSessionStore() +{ + cleanupTimer.stop(); +} + +QByteArray HttpSessionStore::getSessionId(HttpRequest& request, HttpResponse& response) { + // The session ID in the response has priority because this one will be used in the next request. + mutex.lock(); + // Get the session ID from the response cookie + QByteArray sessionId=response.getCookies().value(cookieName).getValue(); + if (sessionId.isEmpty()) { + // Get the session ID from the request cookie + sessionId=request.getCookie(cookieName); + } + // Clear the session ID if there is no such session in the storage. + if (!sessionId.isEmpty()) { + if (!sessions.contains(sessionId)) { + qDebug("HttpSessionStore: received invalid session cookie with ID %s",sessionId.data()); + sessionId.clear(); + } + } + mutex.unlock(); + return sessionId; +} + +HttpSession HttpSessionStore::getSession(HttpRequest& request, HttpResponse& response, bool allowCreate) { + QByteArray sessionId=getSessionId(request,response); + mutex.lock(); + if (!sessionId.isEmpty()) { + HttpSession session=sessions.value(sessionId); + if (!session.isNull()) { + mutex.unlock(); + session.setLastAccess(); + return session; + } + } + // Need to create a new session + if (allowCreate) { + QByteArray cookieName=settings->value("cookieName","sessionid").toByteArray(); + QByteArray cookiePath=settings->value("cookiePath").toByteArray(); + QByteArray cookieComment=settings->value("cookieComment").toByteArray(); + QByteArray cookieDomain=settings->value("cookieDomain").toByteArray(); + HttpSession session(true); + qDebug("HttpSessionStore: create new session with ID %s",session.getId().data()); + sessions.insert(session.getId(),session); + response.setCookie(HttpCookie(cookieName,session.getId(),expirationTime/1000,cookiePath,cookieComment,cookieDomain)); + mutex.unlock(); + return session; + } + // Return a null session + mutex.unlock(); + return HttpSession(); +} + +HttpSession HttpSessionStore::getSession(const QByteArray id) { + mutex.lock(); + HttpSession session=sessions.value(id); + mutex.unlock(); + session.setLastAccess(); + return session; +} + +void HttpSessionStore::timerEvent() { + // Todo: find a way to delete sessions only if no controller is accessing them + mutex.lock(); + qint64 now=QDateTime::currentMSecsSinceEpoch(); + QMap::iterator i = sessions.begin(); + while (i != sessions.end()) { + QMap::iterator prev = i; + ++i; + HttpSession session=prev.value(); + qint64 lastAccess=session.getLastAccess(); + if (now-lastAccess>expirationTime) { + qDebug("HttpSessionStore: session %s expired",session.getId().data()); + sessions.erase(prev); + } + } + mutex.unlock(); +} + + +/** Delete a session */ +void HttpSessionStore::removeSession(HttpSession session) { + mutex.lock(); + sessions.remove(session.getId()); + mutex.unlock(); +} diff --git a/YACReaderLibrary/server/lib/bfHttpServer/httpsessionstore.h b/YACReaderLibrary/server/lib/bfHttpServer/httpsessionstore.h new file mode 100644 index 00000000..e68a2267 --- /dev/null +++ b/YACReaderLibrary/server/lib/bfHttpServer/httpsessionstore.h @@ -0,0 +1,104 @@ +/** + @file + @author Stefan Frings +*/ + +#ifndef HTTPSESSIONSTORE_H +#define HTTPSESSIONSTORE_H + +#include +#include +#include +#include +#include "httpsession.h" +#include "httpresponse.h" +#include "httprequest.h" + +/** + Stores HTTP sessions and deletes them when they have expired. + The following configuration settings are required in the config file: +

+  expirationTime=3600000
+  cookieName=sessionid
+  
+ The following additional configurations settings are optionally: +
+  cookiePath=/
+  cookieComment=Session ID
+  cookieDomain=stefanfrings.de
+  
+*/ + +class HttpSessionStore : public QObject { + Q_OBJECT + Q_DISABLE_COPY(HttpSessionStore); +public: + + /** Constructor. */ + HttpSessionStore(QSettings* settings, QObject* parent); + + /** Destructor */ + virtual ~HttpSessionStore(); + + /** + Get the ID of the current HTTP session, if it is valid. + This method is thread safe. + @warning Sessions may expire at any time, so subsequent calls of + getSession() might return a new session with a different ID. + @param request Used to get the session cookie + @param response Used to get and set the new session cookie + @return Empty string, if there is no valid session. + */ + QByteArray getSessionId(HttpRequest& request, HttpResponse& response); + + /** + Get the session of a HTTP request, eventually create a new one. + This method is thread safe. New sessions can only be created before + the first byte has been written to the HTTP response. + @param request Used to get the session cookie + @param response Used to get and set the new session cookie + @param allowCreate can be set to false, to disable the automatic creation of a new session. + @return If autoCreate is disabled, the function returns a null session if there is no session. + @see HttpSession::isNull() + */ + HttpSession getSession(HttpRequest& request, HttpResponse& response, bool allowCreate=true); + + /** + Get a HTTP session by it's ID number. + This method is thread safe. + @return If there is no such session, the function returns a null session. + @param id ID number of the session + @see HttpSession::isNull() + */ + HttpSession getSession(const QByteArray id); + + /** Delete a session */ + void removeSession(HttpSession session); + +private: + + /** Configuration settings */ + QSettings* settings; + + /** Storage for the sessions */ + QMap sessions; + + /** Timer to remove expired sessions */ + QTimer cleanupTimer; + + /** Name of the session cookie */ + QByteArray cookieName; + + /** Time when sessions expire (in ms)*/ + int expirationTime; + + /** Used to synchronize threads */ + QMutex mutex; + +private slots: + + /** Called every minute to cleanup expired sessions. */ + void timerEvent(); +}; + +#endif // HTTPSESSIONSTORE_H diff --git a/YACReaderLibrary/server/lib/bfHttpServer/staticfilecontroller.cpp b/YACReaderLibrary/server/lib/bfHttpServer/staticfilecontroller.cpp new file mode 100644 index 00000000..6ffc10a3 --- /dev/null +++ b/YACReaderLibrary/server/lib/bfHttpServer/staticfilecontroller.cpp @@ -0,0 +1,165 @@ +/** + @file + @author Stefan Frings +*/ + +#include "staticfilecontroller.h" +#include +#include +#include + +StaticFileController::StaticFileController(QSettings* settings, QObject* parent) + :HttpRequestHandler(parent) +{ + maxAge=settings->value("maxAge","60000").toInt(); + encoding=settings->value("encoding","UTF-8").toString(); + docroot=settings->value("path",".").toString(); + // Convert relative path to absolute, based on the directory of the config file. +#ifdef Q_OS_WIN32 + if (QDir::isRelativePath(docroot) && settings->format()!=QSettings::NativeFormat) +#else + if (QDir::isRelativePath(docroot)) +#endif + { + QFileInfo configFile(settings->fileName()); + docroot=QFileInfo(configFile.absolutePath(),docroot).absoluteFilePath(); + } + qDebug("StaticFileController: docroot=%s, encoding=%s, maxAge=%i",qPrintable(docroot),qPrintable(encoding),maxAge); + maxCachedFileSize=settings->value("maxCachedFileSize","65536").toInt(); + cache.setMaxCost(settings->value("cacheSize","1000000").toInt()); + cacheTimeout=settings->value("cacheTime","60000").toInt(); + qDebug("StaticFileController: cache timeout=%i, size=%i",cacheTimeout,cache.maxCost()); +} + + +void StaticFileController::service(HttpRequest& request, HttpResponse& response) { + QByteArray path=request.getPath(); + // Forbid access to files outside the docroot directory + if (path.startsWith("/..")) { + qWarning("StaticFileController: somebody attempted to access a file outside the docroot directory"); + response.setStatus(403,"forbidden"); + response.write("403 forbidden",true); + } + // Check if we have the file in cache + qint64 now=QDateTime::currentMSecsSinceEpoch(); + CacheEntry* entry=cache.object(path); + if (entry && (cacheTimeout==0 || entry->created>now-cacheTimeout)) { + qDebug("StaticFileController: Cache hit for %s",path.data()); + setContentType(path,response); + response.setHeader("Cache-Control","max-age="+QByteArray::number(maxAge/1000)); + response.write(entry->document); + } + else { + qDebug("StaticFileController: Cache miss for %s",path.data()); + // The file is not in cache. + // If the filename is a directory, append index.html. + if (QFileInfo(docroot+path).isDir()) { + path+="/index.html"; + } + + //TODO(DONE) carga sensible a la localización + QString stringPath = path; + QStringList paths = QString(path).split('/'); + QString fileName = paths.last(); + stringPath.remove(fileName); + fileName = getLocalizedFileName(fileName, request.getHeader("Accept-Language"), stringPath); + QString newPath = stringPath.append(fileName); + //END_TODO + QFile file(docroot+newPath); + if (file.exists()) { + qDebug("StaticFileController: Open file %s",qPrintable(file.fileName())); + if (file.open(QIODevice::ReadOnly)) { + setContentType(newPath,response); + response.setHeader("Cache-Control","max-age="+QByteArray::number(maxAge/1000)); + if (file.size()<=maxCachedFileSize) { + // Return the file content and store it also in the cache + entry=new CacheEntry(); + while (!file.atEnd() && !file.error()) { + QByteArray buffer=file.read(65536); + response.write(buffer); + entry->document.append(buffer); + } + entry->created=now; + cache.insert(request.getPath(),entry,entry->document.size()); + } + else { + // Return the file content, do not store in cache + while (!file.atEnd() && !file.error()) { + response.write(file.read(65536)); + } + } + file.close(); + } + else { + qWarning("StaticFileController: Cannot open existing file %s for reading",qPrintable(file.fileName())); + response.setStatus(403,"forbidden"); + response.write("403 forbidden",true); + } + } + else { + response.setStatus(404,"not found"); + response.write("404 not found",true); + } + } +} + +void StaticFileController::setContentType(QString fileName, HttpResponse& response) const { + if (fileName.endsWith(".png")) { + response.setHeader("Content-Type", "image/png"); + } + else if (fileName.endsWith(".jpg")) { + response.setHeader("Content-Type", "image/jpeg"); + } + else if (fileName.endsWith(".gif")) { + response.setHeader("Content-Type", "image/gif"); + } + else if (fileName.endsWith(".txt")) { + response.setHeader("Content-Type", qPrintable("text/plain; charset="+encoding)); + } + else if (fileName.endsWith(".html") || fileName.endsWith(".htm")) { + response.setHeader("Content-Type", qPrintable("text/html; charset=charset="+encoding)); + } + // Todo: add all of your content types +} + +bool StaticFileController::exists(QString localizedName, QString path) const +{ + QString fileName=docroot+"/"+path + localizedName; + QFile file(fileName); + return file.exists(); +} + +//retorna fileName si no se encontró alternativa traducida ó fileName-locale.extensión si se encontró +QString StaticFileController::getLocalizedFileName(QString fileName, QString locales, QString path) const +{ + QSet tried; // used to suppress duplicate attempts + QStringList locs=locales.split(',',QString::SkipEmptyParts); + QStringList fileNameParts = fileName.split('.'); + QString file = fileNameParts.first(); + QString extension = fileNameParts.last(); + // Search for exact match + foreach (QString loc,locs) { + loc.replace(QRegExp(";.*"),""); + loc.replace('-','_'); + QString localizedName=file+"-"+loc.trimmed()+"."+extension; + if (!tried.contains(localizedName)) { + if(exists(localizedName, path)) + return localizedName; + tried.insert(localizedName); + } + } + + // Search for correct language but any country + foreach (QString loc,locs) { + loc.replace(QRegExp("[;_-].*"),""); + QString localizedName=file+"-"+loc.trimmed()+"."+extension; + if (!tried.contains(localizedName)) { + if(exists(localizedName, path)) + return localizedName; + tried.insert(localizedName); + } + } + + return fileName; +} + \ No newline at end of file diff --git a/YACReaderLibrary/server/lib/bfHttpServer/staticfilecontroller.h b/YACReaderLibrary/server/lib/bfHttpServer/staticfilecontroller.h new file mode 100644 index 00000000..e671b1dc --- /dev/null +++ b/YACReaderLibrary/server/lib/bfHttpServer/staticfilecontroller.h @@ -0,0 +1,85 @@ +/** + @file + @author Stefan Frings +*/ + +#ifndef STATICFILECONTROLLER_H +#define STATICFILECONTROLLER_H + +#include "httprequest.h" +#include "httpresponse.h" +#include "httprequesthandler.h" +#include + +/** + Delivers static files. It is usually called by the applications main request handler when + the caller request a path that is mapped to static files. +

+ The following settings are required in the config file: +

+  path=docroot
+  encoding=UTF-8
+  maxAge=60000
+  cacheTime=60000
+  cacheSize=1000000
+  maxCachedFileSize=65536
+  
+ The path is relative to the directory of the config file. In case of windows, if the + settings are in the registry, the path is relative to the current working directory. +

+ The encoding is sent to the web browser in case of text and html files. +

+ The cache improves performance of small files when loaded from a network + drive. Large files are not cached. Files are cached as long as possible, + when cacheTime=0. The maxAge value (in msec!) controls the remote browsers cache. +

+ Do not instantiate this class in each request, because this would make the file cache + useless. Better create one instance during start-up and call it when the application + received a related HTTP request. +*/ + +class StaticFileController : public HttpRequestHandler { + Q_OBJECT + Q_DISABLE_COPY(StaticFileController); +public: + + /** Constructor */ + StaticFileController(QSettings* settings, QObject* parent = 0); + + /** Generates the response */ + void service(HttpRequest& request, HttpResponse& response); + +private: + + /** Encoding of text files */ + QString encoding; + + /** Root directory of documents */ + QString docroot; + + /** Maximum age of files in the browser cache */ + int maxAge; + + struct CacheEntry { + QByteArray document; + qint64 created; + }; + + /** Timeout for each cached file */ + int cacheTimeout; + + /** Maximum size of files in cache, larger files are not cached */ + int maxCachedFileSize; + + /** Cache storage */ + QCache cache; + + /** Set a content-type header in the response depending on the ending of the filename */ + void setContentType(QString file, HttpResponse& response) const; + + QString getLocalizedFileName(QString fileName, QString locales, QString path) const; + + bool exists(QString localizedName, QString path) const; +}; + +#endif // STATICFILECONTROLLER_H diff --git a/YACReaderLibrary/server/lib/bfLogging/bfLogging.pri b/YACReaderLibrary/server/lib/bfLogging/bfLogging.pri new file mode 100644 index 00000000..a5d95282 --- /dev/null +++ b/YACReaderLibrary/server/lib/bfLogging/bfLogging.pri @@ -0,0 +1,7 @@ +INCLUDEPATH += $$PWD +DEPENDPATH += $$PWD + +HEADERS += $$PWD/logmessage.h $$PWD/logger.h $$PWD/filelogger.h $$PWD/dualfilelogger.h +SOURCES += $$PWD/logmessage.cpp $$PWD/logger.cpp $$PWD/filelogger.cpp $$PWD/dualfilelogger.cpp + +OTHER_FILES += $$PWD/../doc/readme.txt diff --git a/YACReaderLibrary/server/lib/bfLogging/dualfilelogger.cpp b/YACReaderLibrary/server/lib/bfLogging/dualfilelogger.cpp new file mode 100644 index 00000000..7329cae0 --- /dev/null +++ b/YACReaderLibrary/server/lib/bfLogging/dualfilelogger.cpp @@ -0,0 +1,20 @@ +/** + @file + @author Stefan Frings +*/ + +#include "dualfilelogger.h" + + +DualFileLogger::DualFileLogger(QSettings* firstSettings, QSettings* secondSettings, const int refreshInterval, QObject* parent) + :Logger(parent) +{ + firstLogger=new FileLogger(firstSettings, refreshInterval, this); + secondLogger=new FileLogger(secondSettings, refreshInterval, this); +} + + +void DualFileLogger::log(const QtMsgType type, const QString& message) { + firstLogger->log(type, message); + secondLogger->log(type, message); +} diff --git a/YACReaderLibrary/server/lib/bfLogging/dualfilelogger.h b/YACReaderLibrary/server/lib/bfLogging/dualfilelogger.h new file mode 100644 index 00000000..b680ced5 --- /dev/null +++ b/YACReaderLibrary/server/lib/bfLogging/dualfilelogger.h @@ -0,0 +1,60 @@ +/** + @file + @author Stefan Frings +*/ + +#ifndef DUALFILELOGGER_H +#define DUALFILELOGGER_H + +#include "logger.h" +#include "filelogger.h" +#include +#include +#include + +/** + Logs messages into two log files. This is specially useful to get one less detailed + logfile for normal operation plus one more detailed file for debugging. + @see FileLogger for a description of the required config settings. + @see set() describes how to set logger variables + @see LogMessage for a description of the message decoration. +*/ + +class DualFileLogger : public Logger { + Q_OBJECT + Q_DISABLE_COPY(DualFileLogger) +public: + + /** + Constructor. + @param firstSettings Configuration settings for the first log file, usually stored in an INI file. + Must not be 0. + Settings are read from the current group, so the caller must have called settings->beginGroup(). + Because the group must not change during runtime, it is recommended to provide a + separate QSettings instance to the logger that is not used by other parts of the program. + @param secondSettings Same as firstSettings, but for the second log file. + @param refreshInterval Interval of checking the config settings in msec, or 0=disabled + @param parent Parent object + */ + DualFileLogger(QSettings* firstSettings, QSettings* secondSettings, const int refreshInterval=10000, QObject *parent = 0); + + /** + Decorate and log a message. + This method is thread safe. + @param type Message type (level) + @param message Message text + @see LogMessage for a description of the message decoration. + */ + virtual void log(const QtMsgType type, const QString& message); + +private: + + /** First logger */ + FileLogger* firstLogger; + + /** Second logger */ + FileLogger* secondLogger; + +}; + +#endif // DUALFILELOGGER_H diff --git a/YACReaderLibrary/server/lib/bfLogging/filelogger.cpp b/YACReaderLibrary/server/lib/bfLogging/filelogger.cpp new file mode 100644 index 00000000..7e35a6d9 --- /dev/null +++ b/YACReaderLibrary/server/lib/bfLogging/filelogger.cpp @@ -0,0 +1,176 @@ +/** + @file + @author Stefan Frings +*/ + +#include "filelogger.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void FileLogger::refreshSettings() { + mutex.lock(); + // Save old file name for later comparision with new settings + QString oldFileName=fileName; + + // Load new config settings + settings->sync(); + fileName=settings->value("fileName").toString(); + // Convert relative fileName to absolute, based on the directory of the config file. +#ifdef Q_OS_WIN32 + if (QDir::isRelativePath(fileName) && settings->format()!=QSettings::NativeFormat) +#else + if (QDir::isRelativePath(fileName)) +#endif + { + QFileInfo configFile(settings->fileName()); + fileName=QFileInfo(configFile.absolutePath(),fileName).absoluteFilePath(); + } + maxSize=settings->value("maxSize",0).toLongLong(); + maxBackups=settings->value("maxBackups",0).toInt(); + msgFormat=settings->value("msgFormat","{timestamp} {type} {msg}").toString(); + timestampFormat=settings->value("timestampFormat","{yyyy-MM-dd hh:mm:ss.zzz}").toString(); + minLevel=static_cast(settings->value("minLevel",0).toInt()); + bufferSize=settings->value("bufferSize",0).toInt(); + disabled=settings->value("disabled",false).toBool(); + + // Create new file if the filename has been changed + if (oldFileName!=fileName) { + fprintf(stderr,"Logging to %s\n",qPrintable(fileName)); + close(); + open(); + } + mutex.unlock(); +} + + +FileLogger::FileLogger(QSettings* settings, const int refreshInterval, QObject* parent) + : Logger(parent) +{ + Q_ASSERT(settings!=0); + Q_ASSERT(refreshInterval>=0); + this->settings=settings; + file=0; + if (refreshInterval>0) + refreshTimer.start(refreshInterval,this); + flushTimer.start(1000,this); + refreshSettings(); +} + + +FileLogger::~FileLogger() { + close(); +} + + +void FileLogger::write(const LogMessage* logMessage) { + // Write to the file + if (!disabled) { + // Try to write to the file + if (file) { + + // Write the message + file->write(qPrintable(logMessage->toString(msgFormat,timestampFormat))); + + // Flush error messages immediately, to ensure that no important message + // gets lost when the program terinates abnormally. + if (logMessage->getType()>=QtCriticalMsg) { + file->flush(); + } + + // Check for success + if (file->error()) { + close(); + qWarning("Cannot write to log file %s: %s",qPrintable(fileName),qPrintable(file->errorString())); + } + + } + + // Fall-back to the super class method, if writing failed + if (!file) { + Logger::write(logMessage); + } + } + +} + +void FileLogger::open() { + if (fileName.isEmpty()) { + qWarning("Name of logFile is empty"); + } + else { + file=new QFile(fileName); + if (!file->open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) { + qWarning("Cannot open log file %s: %s",qPrintable(fileName),qPrintable(file->errorString())); + file=0; + } + } +} + + +void FileLogger::close() { + if (file) { + file->close(); + delete file; + file=0; + } +} + +void FileLogger::rotate() { + // count current number of existing backup files + int count=0; + forever { + QFile bakFile(QString("%1.%2").arg(fileName).arg(count+1)); + if (bakFile.exists()) { + ++count; + } + else { + break; + } + } + + // Remove all old backup files that exceed the maximum number + while (maxBackups>0 && count>=maxBackups) { + QFile::remove(QString("%1.%2").arg(fileName).arg(count)); + --count; + } + + // Rotate backup files + for (int i=count; i>0; --i) { + QFile::rename(QString("%1.%2").arg(fileName).arg(i),QString("%1.%2").arg(fileName).arg(i+1)); + } + + // Backup the current logfile + QFile::rename(fileName,fileName+".1"); +} + + +void FileLogger::timerEvent(QTimerEvent* event) { + if (!event) { + return; + } + else if (event->timerId()==refreshTimer.timerId()) { + refreshSettings(); + } + else if (event->timerId()==flushTimer.timerId() && file) { + mutex.lock(); + + // Flush the I/O buffer + file->flush(); + + // Rotate the file if it is too large + if (maxSize>0 && file->size()>=maxSize) { + close(); + rotate(); + open(); + } + + mutex.unlock(); + } +} diff --git a/YACReaderLibrary/server/lib/bfLogging/filelogger.h b/YACReaderLibrary/server/lib/bfLogging/filelogger.h new file mode 100644 index 00000000..bd15d4c8 --- /dev/null +++ b/YACReaderLibrary/server/lib/bfLogging/filelogger.h @@ -0,0 +1,131 @@ +/** + @file + @author Stefan Frings +*/ + +#ifndef FILELOGGER_H +#define FILELOGGER_H + +#include +#include +#include +#include +#include +#include "logger.h" + +/** + Logger that uses a text file for output. Settings are read from a + config file using a QSettings object. Config settings can be changed at runtime. + They are copied to private fields in regular intervals for permance reason. +

+ Example for the required configuration settings: +

+  disabled=false
+  fileName=logs/QtWebApp.log
+  maxSize=1000000
+  maxBackups=2
+  minLevel=0
+  msgformat={timestamp} {typeNr} {type} thread={thread}: {msg}
+  timestampFormat=dd.MM.yyyy hh:mm:ss.zzz
+  bufferSize=0
+  
+ + - fileName is the name of the log file, relative to the directory of the settings file. + In case of windows, if the settings are in the registry, the path is relative to the current + working directory. + - maxSize is the maximum size of that file in bytes. The file will be backed up and + replaced by a new file if it becomes larger than this limit. Please note that + the actual file size may become a little bit larger than this limit. 0=unlimited. + - maxBackups defines the number of backup files to keep. 0=unlimited. + - minLevel defines the minimum level of message types to be written into the file. + - msgFormat defines the decoration of log messages. + - timestampFormat defines the format of timestamps. + - buffersize defines the size of the backtrace buffer. 0=disabled. + The buffer stores log messages of any level from the time before an error occurs. + It can be used to provide detailed debug information when an error occurs, while keeping + the logfile clean as long no error occurs. Using this buffer may reduce performance + significantly. + + @see set() describes how to set logger variables + @see LogMessage for a description of the message decoration. + @see Logger for a descrition of the backtrace buffer +*/ + +class FileLogger : public Logger { + Q_OBJECT + Q_DISABLE_COPY(FileLogger) +public: + + /** + Constructor. + @param settings Configuration settings, usually stored in an INI file. Must not be 0. + Settings are read from the current group, so the caller must have called settings->beginGroup(). + Because the group must not change during runtime, it is recommended to provide a + separate QSettings instance to the logger that is not used by other parts of the program. + @param refreshInterval Interval of checking the config settings in msec, or 0=disabled + @param parent Parent object + */ + FileLogger(QSettings* settings, const int refreshInterval=10000, QObject* parent = 0); + + /** + Destructor. Closes the file. + */ + virtual ~FileLogger(); + + /** Write a message to the log file */ + virtual void write(const LogMessage* logMessage); + +protected: + + /** + Handler for timer events. + Refreshes config settings or synchronizes I/O buffer, depending on the event. + This method is thread-safe. + @param event used to distinguish between the two timers. + */ + void timerEvent(QTimerEvent* event); + +private: + + /** Configured name of the log file */ + QString fileName; + + /** Configured maximum size of the file in bytes, or 0=unlimited */ + long maxSize; + + /** Configured maximum number of backup files, or 0=unlimited */ + int maxBackups; + + /** Whether this logger is disabled */ + bool disabled; + + /** Pointer to the configuration settings */ + QSettings* settings; + + /** Output file, or 0=disabled */ + QFile* file; + + /** Timer for refreshing configuration settings */ + QBasicTimer refreshTimer; + + /** Timer for flushing the file I/O buffer */ + QBasicTimer flushTimer; + + /** Open the output file */ + void open(); + + /** Close the output file */ + void close(); + + /** Rotate files and delete some backups if there are too many */ + void rotate(); + + /** + Refreshes the configuration settings. + This method is thread-safe. + */ + void refreshSettings(); + +}; + +#endif // FILELOGGER_H diff --git a/YACReaderLibrary/server/lib/bfLogging/logger.cpp b/YACReaderLibrary/server/lib/bfLogging/logger.cpp new file mode 100644 index 00000000..065bb897 --- /dev/null +++ b/YACReaderLibrary/server/lib/bfLogging/logger.cpp @@ -0,0 +1,154 @@ +/** + @file + @author Stefan Frings +*/ + +#include "logger.h" +#include +#include +#include +#include +#include + +Logger* Logger::defaultLogger=0; + + +QThreadStorage*> Logger::logVars; + + +QThreadStorage*> Logger::buffers; + + +QMutex Logger::mutex; + + +Logger::Logger(QObject* parent) + : QObject(parent), + msgFormat("{timestamp} {type} {msg}"), + timestampFormat("dd.MM.yyyy hh:mm:ss.zzz"), + minLevel(QtDebugMsg), + bufferSize(0) + {} + + +Logger::Logger(const QString msgFormat, const QString timestampFormat, const QtMsgType minLevel, const int bufferSize, QObject* parent) + :QObject(parent) { + this->msgFormat=msgFormat; + this->timestampFormat=timestampFormat; + this->minLevel=minLevel; + this->bufferSize=bufferSize; +} + + +void Logger::msgHandler(const QtMsgType type, const char* message) { + static QMutex recursiveMutex(QMutex::Recursive); + static QMutex nonRecursiveMutex(QMutex::NonRecursive); + + // Prevent multiple threads from calling this method simultaneoulsy. + // But allow recursive calls, which is required to prevent a deadlock + // if the logger itself produces an error message. + recursiveMutex.lock(); + + // Fall back to stderr when this method has been called recursively. + if (defaultLogger && nonRecursiveMutex.tryLock()) { + defaultLogger->log(type,message); + nonRecursiveMutex.unlock(); + } + else { + fputs(message,stderr); + fflush(stderr); + } + + // Abort the program after logging a fatal message + if (type>=QtFatalMsg) { + abort(); + } + + recursiveMutex.unlock(); +} + + + + +Logger::~Logger() { + if (defaultLogger==this) { + qInstallMsgHandler(0); + defaultLogger=0; + } +} + + +void Logger::write(const LogMessage* logMessage) { + fputs(qPrintable(logMessage->toString(msgFormat,timestampFormat)),stderr); + fflush(stderr); +} + + +void Logger::installMsgHandler() { + defaultLogger=this; + qInstallMsgHandler(msgHandler); +} + + +void Logger::set(const QString& name, const QString& value) { + mutex.lock(); + if (!logVars.hasLocalData()) { + logVars.setLocalData(new QHash); + } + logVars.localData()->insert(name,value); + mutex.unlock(); +} + + +void Logger::clear(const bool buffer, const bool variables) { + mutex.lock(); + if (buffer && buffers.hasLocalData()) { + QList* buffer=buffers.localData(); + while (buffer && !buffer->isEmpty()) { + LogMessage* logMessage=buffer->takeLast(); + delete logMessage; + } + } + if (variables && logVars.hasLocalData()) { + logVars.localData()->clear(); + } + mutex.unlock(); +} + + +void Logger::log(const QtMsgType type, const QString& message) { + mutex.lock(); + + // If the buffer is enabled, write the message into it + if (bufferSize>0) { + // Create new thread local buffer, if necessary + if (!buffers.hasLocalData()) { + buffers.setLocalData(new QList()); + } + QList* buffer=buffers.localData(); + // Append the decorated log message + LogMessage* logMessage=new LogMessage(type,message,logVars.localData()); + buffer->append(logMessage); + // Delete oldest message if the buffer became too large + if (buffer->size()>bufferSize) { + delete buffer->takeFirst(); + } + // If the type of the message is high enough, print the whole buffer + if (type>=minLevel) { + while (!buffer->isEmpty()) { + LogMessage* logMessage=buffer->takeFirst(); + write(logMessage); + delete logMessage; + } + } + } + + // Buffer is disabled, print the message if the type is high enough + else { + if (type>=minLevel) { + LogMessage logMessage(type,message,logVars.localData()); + write(&logMessage); + } + } + mutex.unlock(); +} diff --git a/YACReaderLibrary/server/lib/bfLogging/logger.h b/YACReaderLibrary/server/lib/bfLogging/logger.h new file mode 100644 index 00000000..bd37385e --- /dev/null +++ b/YACReaderLibrary/server/lib/bfLogging/logger.h @@ -0,0 +1,144 @@ +/** + @file + @author Stefan Frings +*/ + +#ifndef LOGGER_H +#define LOGGER_H + +#include +#include +#include +#include +#include +#include "logmessage.h" + +/** + Decorates and writes log messages to the console, stderr. +

+ The decorator uses a predefined msgFormat string to enrich log messages + with additional information (e.g. timestamp). +

+ The msgFormat string and also the message text may contain additional + variable names in the form {name} that are filled by values + taken from a static thread local dictionary. +

+ The buffer stores log messages of any level from the time before an error occurs. + It can be used to provide detailed debug information when an error occurs, while + keeping the logfile clean as long no error occurs. Using this buffer may + reduce performance significantly. +

+ The logger can be registered to handle messages from + the static global functions qDebug(), qWarning(), qCritical() and qFatal(). + @see set() describes how to set logger variables + @see LogMessage for a description of the message decoration. + @warning You should prefer a derived class, for example FileLogger, + because logging to the console is less useful. +*/ + +class Logger : public QObject { + Q_OBJECT + Q_DISABLE_COPY(Logger) +public: + + /** + Constructor. + Uses the same defaults as the other constructor. + @param parent Parent object + */ + Logger(QObject* parent); + + + /** + Constructor. + @param msgFormat Format of the decoration, e.g. "{timestamp} {type} thread={thread}: {msg}" + @param timestampFormat Format of timestamp, e.g. "dd.MM.yyyy hh:mm:ss.zzz" + @param minLevel Minimum type of messages that are written out. + @param bufferSize Size of the backtrace buffer, number of messages per thread. 0=disabled. + @param parent Parent object + @see LogMessage for a description of the message decoration. + */ + Logger(const QString msgFormat="{timestamp} {type} {msg}", const QString timestampFormat="dd.MM.yyyy hh:mm:ss.zzz", const QtMsgType minLevel=QtDebugMsg, const int bufferSize=0, QObject* parent = 0); + + /** Destructor */ + virtual ~Logger(); + + /** + Decorate and log the message, if type>=minLevel. + This method is thread safe. + @param type Message type (level) + @param message Message text + @see LogMessage for a description of the message decoration. + */ + virtual void log(const QtMsgType type, const QString& message); + + /** + Installs this logger as the default message handler, so it + can be used through the global static logging functions (e.g. qDebug()). + */ + void installMsgHandler(); + + /** + Sets a thread-local variable that may be used to decorate log messages. + This method is thread safe. + @param name Name of the variable + @param value Value of the variable + */ + static void set(const QString& name, const QString& value); + + /** + Clear the thread-local data of the current thread. + @param buffer Whether to clear the backtrace buffer + @param variables Whether to clear the log variables + */ + static void clear(const bool buffer=true, const bool variables=true); + +protected: + + /** Format string for message decoration */ + QString msgFormat; + + /** Format string of timestamps */ + QString timestampFormat; + + /** Minimum level of message types that are written out */ + QtMsgType minLevel; + + /** Size of backtrace buffer, number of messages per thread. 0=disabled */ + int bufferSize; + + /** Used to synchronize access to the static members */ + static QMutex mutex; + + /** + Decorate and write a log message to stderr. Override this method + to provide a different output medium. + */ + virtual void write(const LogMessage* logMessage); + +private: + + /** Pointer to the default logger, used by msgHandler() */ + static Logger* defaultLogger; + + /** + Message Handler for the global static logging functions (e.g. qDebug()). + Forward calls to the default logger. +

+ In case of a fatal message, the program will abort. + Variables in the in the message are replaced by their values. + This method is thread safe. + @param type Message type (level) + @param message Message text + */ + static void msgHandler(const QtMsgType type, const char* message); + + /** Thread local variables to be used in log messages */ + static QThreadStorage*> logVars; + + /** Thread local backtrace buffers */ + static QThreadStorage*> buffers; + +}; + +#endif // LOGGER_H diff --git a/YACReaderLibrary/server/lib/bfLogging/logmessage.cpp b/YACReaderLibrary/server/lib/bfLogging/logmessage.cpp new file mode 100644 index 00000000..b5754e32 --- /dev/null +++ b/YACReaderLibrary/server/lib/bfLogging/logmessage.cpp @@ -0,0 +1,68 @@ +/** + @file + @author Stefan Frings +*/ + +#include "logmessage.h" +#include + +LogMessage::LogMessage(const QtMsgType type, const QString& message, QHash* logVars) { + this->type=type; + this->message=message; + timestamp=QDateTime::currentDateTime(); + threadId=QThread::currentThreadId(); + + // Copy the logVars if not null, + // so that later changes in the original do not affect the copy + if (logVars) { + this->logVars=*logVars; + } +} + +QString LogMessage::toString(const QString& msgFormat, const QString& timestampFormat) const { + QString decorated=msgFormat+"\n"; + decorated.replace("{msg}",message); + + if (decorated.contains("{timestamp}")) { + decorated.replace("{timestamp}",QDateTime::currentDateTime().toString(timestampFormat)); + } + + QString typeNr; + typeNr.setNum(type); + decorated.replace("{typeNr}",typeNr); + + switch (type) { + case QtDebugMsg: + decorated.replace("{type}","DEBUG"); + break; + case QtWarningMsg: + decorated.replace("{type}","WARNING"); + break; + case QtCriticalMsg: + decorated.replace("{type}","CRITICAL"); + break; + case QtFatalMsg: + decorated.replace("{type}","FATAL"); + break; + default: + decorated.replace("{type}",typeNr); + } + + QString threadId; + threadId.setNum((qint64)QThread::currentThreadId()); + decorated.replace("{thread}",threadId); + + // Fill in variables + if (decorated.contains("{") && !logVars.isEmpty()) { + QList keys=logVars.keys(); + foreach (QString key, keys) { + decorated.replace("{"+key+"}",logVars.value(key)); + } + } + + return decorated; +} + +QtMsgType LogMessage::getType() const { + return type; +} diff --git a/YACReaderLibrary/server/lib/bfLogging/logmessage.h b/YACReaderLibrary/server/lib/bfLogging/logmessage.h new file mode 100644 index 00000000..b348a20e --- /dev/null +++ b/YACReaderLibrary/server/lib/bfLogging/logmessage.h @@ -0,0 +1,74 @@ +/** + @file + @author Stefan Frings +*/ + +#ifndef LOGMESSAGE_H +#define LOGMESSAGE_H + +#include +#include +#include + +/** + Represents a single log message together with some data + that are used to decorate the log message. + + The following variables may be used in the message and in msgFormat: + + - {timestamp} Date and time of creation + - {typeNr} Type of the message in numeric format (0-3) + - {type} Type of the message in string format (DEBUG, WARNING, CRITICAL, FATAL) + - {thread} ID number of the thread + - {msg} Message text (only useable in msgFormat) + - {xxx} For any user-defined logger variable +*/ + +class LogMessage +{ + Q_DISABLE_COPY(LogMessage) +public: + + /** + Constructor. All parameters are copied, so that later changes to them do not + affect this object. + @param type Type of the message + @param message Message text + @param logVars Logger variables, 0 is allowed + */ + LogMessage(const QtMsgType type, const QString& message, QHash* logVars); + + /** + Returns the log message as decorated string. + @param msgFormat Format of the decoration. May contain variables and static text, + e.g. "{timestamp} {type} thread={thread}: {msg}" + @param timestampFormat Format of timestamp, e.g. "dd.MM.yyyy hh:mm:ss.zzz" + @see QDatetime for a description of the timestamp format pattern + */ + QString toString(const QString& msgFormat, const QString& timestampFormat) const; + + /** + Get the message type. + */ + QtMsgType getType() const; + +private: + + /** Logger variables */ + QHash logVars; + + /** Date and time of creation */ + QDateTime timestamp; + + /** Type of the message */ + QtMsgType type; + + /** ID number of the thread */ + Qt::HANDLE threadId; + + /** Message text */ + QString message; + +}; + +#endif // LOGMESSAGE_H diff --git a/YACReaderLibrary/server/lib/bfTemplateEngine/bfTemplateEngine.pri b/YACReaderLibrary/server/lib/bfTemplateEngine/bfTemplateEngine.pri new file mode 100644 index 00000000..d3eba98b --- /dev/null +++ b/YACReaderLibrary/server/lib/bfTemplateEngine/bfTemplateEngine.pri @@ -0,0 +1,7 @@ +INCLUDEPATH += $$PWD +DEPENDPATH += $$PWD + +HEADERS += $$PWD/template.h $$PWD/templateloader.h $$PWD/templatecache.h +SOURCES += $$PWD/template.cpp $$PWD/templateloader.cpp $$PWD/templatecache.cpp + +OTHER_FILES += $$PWD/../doc/readme.txt diff --git a/YACReaderLibrary/server/lib/bfTemplateEngine/template.cpp b/YACReaderLibrary/server/lib/bfTemplateEngine/template.cpp new file mode 100644 index 00000000..427f132e --- /dev/null +++ b/YACReaderLibrary/server/lib/bfTemplateEngine/template.cpp @@ -0,0 +1,187 @@ +/** + @file + @author Stefan Frings +*/ + +#include "template.h" +#include + +Template::Template(QString source, QString sourceName) + : QString(source) { + this->sourceName=sourceName; + this->warnings=false; +} + +Template::Template(QFile& file, QTextCodec* textCodec) { + sourceName=QFileInfo(file.fileName()).baseName(); + if (!file.isOpen()) { + file.open(QFile::ReadOnly | QFile::Text); + } + QByteArray data=file.readAll(); + file.close(); + if (data.size()==0 || file.error()) { + qCritical("Template: cannot read from %s, %s",qPrintable(sourceName),qPrintable(file.errorString())); + append(textCodec->toUnicode(data)); + } +} + + +int Template::setVariable(QString name, QString value) { + int count=0; + QString variable="{"+name+"}"; + int start=indexOf(variable); + while (start>=0) { + replace(start, variable.length(), value); + count++; + start=indexOf(variable,start+variable.length()); + } + if (count==0 && warnings) { + qWarning("Template: missing variable %s in %s",qPrintable(variable),qPrintable(sourceName)); + } + return count; +} + +int Template::setCondition(QString name, bool value) { + int count=0; + QString startTag=QString("{if %1}").arg(name); + QString elseTag=QString("{else %1}").arg(name); + QString endTag=QString("{end %1}").arg(name); + // search for if-else-end + int start=indexOf(startTag); + while (start>=0) { + int end=indexOf(endTag,start+startTag.length()); + if (end>=0) { + count++; + int ellse=indexOf(elseTag,start+startTag.length()); + if (ellse>start && ellse=0) { + int end=indexOf(endTag,start+startTag2.length()); + if (end>=0) { + count++; + int ellse=indexOf(elseTag,start+startTag2.length()); + if (ellse>start && ellse=0); + int count=0; + QString startTag="{loop "+name+"}"; + QString elseTag="{else "+name+"}"; + QString endTag="{end "+name+"}"; + // search for loop-else-end + int start=indexOf(startTag); + while (start>=0) { + int end=indexOf(endTag,start+startTag.length()); + if (end>=0) { + count++; + int ellse=indexOf(elseTag,start+startTag.length()); + if (ellse>start && ellse0) { + QString loopPart=mid(start+startTag.length(), ellse-start-startTag.length()); + QString insertMe; + for (int i=0; i0) { // and no else part + QString loopPart=mid(start+startTag.length(), end-start-startTag.length()); + QString insertMe; + for (int i=0; i +#include +#include +#include +#include +#include + +/** + Enhanced version of QString for template processing. Templates + are usually loaded from files, but may also be loaded from + prepared Strings. + Example template file: +

+ Hello {username}, how are you?
+
+ {if locked}
+     Your account is locked.
+ {else locked}
+     Welcome on our system.
+ {end locked}
+
+ The following users are on-line:
+     Username       Time
+ {loop user}
+     {user.name}    {user.time}
+ {end user}
+ 

+

+ Example code to fill this template: +

+ Template t(QFile("test.tpl"),QTextCode::codecForName("UTF-8"));
+ t.setVariable("user", "Stefan");
+ t.setCondition("locked",false);
+ t.loop("user",2);
+ t.setVariable("user0.name,"Markus");
+ t.setVariable("user0.time,"8:30");
+ t.setVariable("user1.name,"Roland");
+ t.setVariable("user1.time,"8:45");
+ 

+

+ The code example above shows how variable within loops are numbered. + Counting starts with 0. Loops can be nested, for example: +

+ <table>
+ {loop row}
+     <tr>
+     {loop row.column}
+         <td>{row.column.value}</td>
+     {end row.column}
+     </tr>
+ {end row}
+ </table>
+ 

+

+ Example code to fill this nested loop with 3 rows and 4 columns: +

+ t.loop("row",3);
+
+ t.loop("row0.column",4);
+ t.setVariable("row0.column0.value","a");
+ t.setVariable("row0.column1.value","b");
+ t.setVariable("row0.column2.value","c");
+ t.setVariable("row0.column3.value","d");
+
+ t.loop("row1.column",4);
+ t.setVariable("row1.column0.value","e");
+ t.setVariable("row1.column1.value","f");
+ t.setVariable("row1.column2.value","g");
+ t.setVariable("row1.column3.value","h");
+
+ t.loop("row2.column",4);
+ t.setVariable("row2.column0.value","i");
+ t.setVariable("row2.column1.value","j");
+ t.setVariable("row2.column2.value","k");
+ t.setVariable("row2.column3.value","l");
+ 

+ @see TemplateLoader + @see TemplateCache +*/ + +class Template : public QString { +public: + + /** + Constructor that reads the template from a string. + @param source The template source text + @param sourceName Name of the source file, used for logging + */ + Template(QString source, QString sourceName); + + /** + Constructor that reads the template from a file. Note that this class does not + cache template files by itself, so using this constructor is only recommended + to be used on local filesystem. + @param file File that provides the source text + @param textCodec Encoding of the source + @see TemplateLoader + @see TemplateCache + */ + Template(QFile& file, QTextCodec* textCodec); + + /** + Replace a variable by the given value. + Affects tags with the syntax + + - {name} + + After settings the + value of a variable, the variable does not exist anymore, + it it cannot be changed multiple times. + @param name name of the variable + @param value new value + @return The count of variables that have been processed + */ + int setVariable(QString name, QString value); + + /** + Set a condition. This affects tags with the syntax + + - {if name}...{end name} + - {if name}...{else name}...{end name} + - {ifnot name}...{end name} + - {ifnot name}...{else name}...{end name} + + @param name Name of the condition + @param value Value of the condition + @return The count of conditions that have been processed + */ + int setCondition(QString name, bool value); + + /** + Set number of repetitions of a loop. + This affects tags with the syntax + + - {loop name}...{end name} + - {loop name}...{else name}...{end name} + + @param name Name of the loop + @param repetitions The number of repetitions + @return The number of loops that have been processed + */ + int loop(QString name, int repetitions); + + /** + Enable warnings for missing tags + @param enable Warnings are enabled, if true + */ + void enableWarnings(bool enable=true); + +private: + + /** Name of the source file */ + QString sourceName; + + /** Enables warnings, if true */ + bool warnings; +}; + +#endif // TEMPLATE_H diff --git a/YACReaderLibrary/server/lib/bfTemplateEngine/templatecache.cpp b/YACReaderLibrary/server/lib/bfTemplateEngine/templatecache.cpp new file mode 100644 index 00000000..9073e34b --- /dev/null +++ b/YACReaderLibrary/server/lib/bfTemplateEngine/templatecache.cpp @@ -0,0 +1,30 @@ +#include "templatecache.h" +#include +#include +#include + +TemplateCache::TemplateCache(QSettings* settings, QObject* parent) + :TemplateLoader(settings,parent) +{ + cache.setMaxCost(settings->value("cacheSize","1000000").toInt()); + cacheTimeout=settings->value("cacheTime","60000").toInt(); + qDebug("TemplateCache: timeout=%i, size=%i",cacheTimeout,cache.maxCost()); +} + +QString TemplateCache::tryFile(QString localizedName) { + qint64 now=QDateTime::currentMSecsSinceEpoch(); + // search in cache + qDebug("TemplateCache: trying cached %s",qPrintable(localizedName)); + CacheEntry* entry=cache.object(localizedName); + if (entry && (cacheTimeout==0 || entry->created>now-cacheTimeout)) { + return entry->document; + } + // search on filesystem + entry=new CacheEntry(); + entry->created=now; + entry->document=TemplateLoader::tryFile(localizedName); + // Store in cache even when the file did not exist, to remember that there is no such file + cache.insert(localizedName,entry,entry->document.size()); + return entry->document; +} + diff --git a/YACReaderLibrary/server/lib/bfTemplateEngine/templatecache.h b/YACReaderLibrary/server/lib/bfTemplateEngine/templatecache.h new file mode 100644 index 00000000..6e79f119 --- /dev/null +++ b/YACReaderLibrary/server/lib/bfTemplateEngine/templatecache.h @@ -0,0 +1,77 @@ +#ifndef TEMPLATECACHE_H +#define TEMPLATECACHE_H + +#include "templateloader.h" +#include + +/** + Caching template loader, reduces the amount of I/O and improves performance + on remote file systems. The cache has a limited size, it prefers to keep + the last recently used files. Optionally, the maximum time of cached entries + can be defined to enforce a reload of the template file after a while. +

+ In case of local file system, the use of this cache is optionally, since + the operating system caches files already. +

+ Loads localized versions of template files. If the caller requests a file with the + name "index" and the suffix is ".tpl" and the requested locale is "de_DE, de, en-US", + then files are searched in the following order: + + - index-de_DE.tpl + - index-de.tpl + - index-en_US.tpl + - index-en.tpl + - index.tpl +

+ The following settings are required: +

+  path=.
+  suffix=.tpl
+  encoding=UTF-8
+  cacheSize=1000000
+  cacheTime=60000
+  
+ The path is relative to the directory of the config file. In case of windows, if the + settings are in the registry, the path is relative to the current working directory. +

+ Files are cached as long as possible, when cacheTime=0. + @see TemplateLoader +*/ + +class TemplateCache : public TemplateLoader { + Q_OBJECT + Q_DISABLE_COPY(TemplateCache); +public: + + /** + Constructor. + @param settings configurations settings + @param parent Parent object + */ + TemplateCache(QSettings* settings, QObject* parent=0); + +protected: + + /** + Try to get a file from cache or filesystem. + @param localizedName Name of the template with locale to find + @return The template document, or empty string if not found + */ + virtual QString tryFile(QString localizedName); + +private: + + struct CacheEntry { + QString document; + qint64 created; + }; + + /** Timeout for each cached file */ + int cacheTimeout; + + /** Cache storage */ + QCache cache; + +}; + +#endif // TEMPLATECACHE_H diff --git a/YACReaderLibrary/server/lib/bfTemplateEngine/templateloader.cpp b/YACReaderLibrary/server/lib/bfTemplateEngine/templateloader.cpp new file mode 100644 index 00000000..33ba7d02 --- /dev/null +++ b/YACReaderLibrary/server/lib/bfTemplateEngine/templateloader.cpp @@ -0,0 +1,103 @@ +/** + @file + @author Stefan Frings +*/ + +#include "templateloader.h" +#include +#include +#include +#include +#include + +TemplateLoader::TemplateLoader(QSettings* settings, QObject* parent) + : QObject(parent) +{ + templatePath=settings->value("path",".").toString(); + // Convert relative path to absolute, based on the directory of the config file. +#ifdef Q_OS_WIN32 + if (QDir::isRelativePath(templatePath) && settings->format()!=QSettings::NativeFormat) +#else + if (QDir::isRelativePath(templatePath)) +#endif + { + QFileInfo configFile(settings->fileName()); + templatePath=QFileInfo(configFile.absolutePath(),templatePath).absoluteFilePath(); + } + fileNameSuffix=settings->value("suffix",".tpl").toString(); + QString encoding=settings->value("encoding").toString(); + if (encoding.isEmpty()) { + textCodec=QTextCodec::codecForLocale(); + } + else { + textCodec=QTextCodec::codecForName(encoding.toAscii()); + } + qDebug("TemplateLoader: path=%s, codec=%s",qPrintable(templatePath),textCodec->name().data()); +} + +TemplateLoader::~TemplateLoader() {} + +QString TemplateLoader::tryFile(QString localizedName) { + QString fileName=templatePath+"/"+localizedName+fileNameSuffix; + qDebug("TemplateCache: trying file %s",qPrintable(fileName)); + QFile file(fileName); + if (file.exists()) { + file.open(QIODevice::ReadOnly); + QString document=textCodec->toUnicode(file.readAll()); + file.close(); + if (file.error()) { + qCritical("TemplateLoader: cannot load file %s, %s",qPrintable(fileName),qPrintable(file.errorString())); + return ""; + } + else { + return document; + } + } + return ""; +} + +Template TemplateLoader::getTemplate(QString templateName, QString locales) { + mutex.lock(); + QSet tried; // used to suppress duplicate attempts + QStringList locs=locales.split(',',QString::SkipEmptyParts); + + // Search for exact match + foreach (QString loc,locs) { + loc.replace(QRegExp(";.*"),""); + loc.replace('-','_'); + QString localizedName=templateName+"-"+loc.trimmed(); + if (!tried.contains(localizedName)) { + QString document=tryFile(localizedName); + if (!document.isEmpty()) { + mutex.unlock(); + return Template(document,localizedName); + } + tried.insert(localizedName); + } + } + + // Search for correct language but any country + foreach (QString loc,locs) { + loc.replace(QRegExp("[;_-].*"),""); + QString localizedName=templateName+"-"+loc.trimmed(); + if (!tried.contains(localizedName)) { + QString document=tryFile(localizedName); + if (!document.isEmpty()) { + mutex.unlock(); + return Template(document,localizedName); + } + tried.insert(localizedName); + } + } + + // Search for default file + QString document=tryFile(templateName); + if (!document.isEmpty()) { + mutex.unlock(); + return Template(document,templateName); + } + + qCritical("TemplateCache: cannot find template %s",qPrintable(templateName)); + mutex.unlock(); + return Template("",templateName); +} diff --git a/YACReaderLibrary/server/lib/bfTemplateEngine/templateloader.h b/YACReaderLibrary/server/lib/bfTemplateEngine/templateloader.h new file mode 100644 index 00000000..5635af40 --- /dev/null +++ b/YACReaderLibrary/server/lib/bfTemplateEngine/templateloader.h @@ -0,0 +1,85 @@ +/** + @file + @author Stefan Frings +*/ + +#ifndef TEMPLATELOADER_H +#define TEMPLATELOADER_H + +#include +#include +#include +#include "template.h" +#include + +/** + Loads localized versions of template files. If the caller requests a file with the + name "index" and the suffix is ".tpl" and the requested locale is "de_DE, de, en-US", + then files are searched in the following order: + + - index-de_DE.tpl + - index-de.tpl + - index-en_US.tpl + - index-en.tpl + - index.tpl + + The following settings are required: +

+  path=.
+  suffix=.tpl
+  encoding=UTF-8
+  
+ The path is relative to the directory of the config file. In case of windows, if the + settings are in the registry, the path is relative to the current working directory. + @see TemplateCache +*/ + +class TemplateLoader : public QObject { + Q_OBJECT + Q_DISABLE_COPY(TemplateLoader); +public: + + /** + Constructor. + @param settings configurations settings + @param parent parent object + */ + TemplateLoader(QSettings* settings, QObject* parent=0); + + /** Destructor */ + virtual ~TemplateLoader(); + + /** + Get a template for a given locale. + This method is thread safe. + @param templateName base name of the template file, without suffix and without locale + @param locales Requested locale(s), e.g. "de_DE, en_EN". Strings in the format of + the HTTP header Accept-Locale may be used. Badly formatted parts in the string are silently + ignored. + @return If the template cannot be loaded, an error message is logged and an empty template is returned. + */ + Template getTemplate(QString templateName, QString locales=QString()); + +protected: + + /** + Try to get a file from cache or filesystem. + @param localizedName Name of the template with locale to find + @return The template document, or empty string if not found + */ + virtual QString tryFile(QString localizedName); + + /** Directory where the templates are searched */ + QString templatePath; + + /** Suffix to the filenames */ + QString fileNameSuffix; + + /** Codec for decoding the files */ + QTextCodec* textCodec; + + /** Used to synchronize threads */ + QMutex mutex; +}; + +#endif // TEMPLATELOADER_H diff --git a/YACReaderLibrary/server/main.cpp b/YACReaderLibrary/server/main.cpp new file mode 100644 index 00000000..d5ac4be5 --- /dev/null +++ b/YACReaderLibrary/server/main.cpp @@ -0,0 +1,58 @@ +/** + @file + @author Stefan Frings +*/ + +/** + @mainpage + This project provies libraries for writing server-side web application in C++ + based on the Qt toolkit. It is a light-weight implementation that works like + Java Servlets from the programmers point of view. +

+ Features: + + - HTTP 1.1 web server + - persistent connections + - chunked and non-chunked transfer + - file uploads (multipart encoded forms) + - cookies + - sessions + - uses dynamic thread pool + - optional file cache + - Template engine + - multi-language + - optional file cache + - Logger + - configurable without program restart + - automatic backup and file rotation + - configurable message format + - messages may contain thread-local variables + - optional buffer for writing history details in case of an error + - Example application + - Install and run as Windows service, unix daemon or at the command-line + - Search config file in multiple common directories + - Demonstrates how to write servlets for common use-cases + + If you write a real application based on this source, take a look into startup.cpp, + which contains startup and shutdown procedures. The example source sets + up a single listener on port 8080, however multiple listeners with individual + configuration could be set up. +

+ Incoming requests are mapped to controller classes in requestmapper.cpp, based on the + requested path. If you want to learn form the example, then focus on these classes. +

+ High-availability and HTTPS encryption can be easily added by putting an Apache HTTP server + in front of the self-written web application using the mod-proxy module with sticky sessions. +*/ + +#include "startup.h" + +/** + Entry point of the program. + Passes control to the service helper. +*/ +int main(int argc, char *argv[]) { + // Use a qtservice wrapper to start the application as a Windows service or Unix daemon + Startup startup(argc, argv); + return startup.exec(); +} diff --git a/YACReaderLibrary/server/requestmapper.cpp b/YACReaderLibrary/server/requestmapper.cpp new file mode 100644 index 00000000..107cba28 --- /dev/null +++ b/YACReaderLibrary/server/requestmapper.cpp @@ -0,0 +1,46 @@ +/** + @file + @author Stefan Frings +*/ + +#include "requestmapper.h" +#include "static.h" +#include "staticfilecontroller.h" +#include "controllers/dumpcontroller.h" +#include "controllers/templatecontroller.h" +#include "controllers/formcontroller.h" +#include "controllers/fileuploadcontroller.h" +#include "controllers/sessioncontroller.h" + +RequestMapper::RequestMapper(QObject* parent) + :HttpRequestHandler(parent) {} + +void RequestMapper::service(HttpRequest& request, HttpResponse& response) { + QByteArray path=request.getPath(); + qDebug("RequestMapper: path=%s",path.data()); + + if (path.startsWith("/dump")) { + DumpController().service(request, response); + } + + else if (path.startsWith("/template")) { + TemplateController().service(request, response); + } + + else if (path.startsWith("/form")) { + FormController().service(request, response); + } + + else if (path.startsWith("/file")) { + FileUploadController().service(request, response); + } + + else if (path.startsWith("/session")) { + SessionController().service(request, response); + } + + // All other pathes are mapped to the static file controller. + else { + Static::staticFileController->service(request, response); + } +} diff --git a/YACReaderLibrary/server/requestmapper.h b/YACReaderLibrary/server/requestmapper.h new file mode 100644 index 00000000..d44586f6 --- /dev/null +++ b/YACReaderLibrary/server/requestmapper.h @@ -0,0 +1,36 @@ +/** + @file + @author Stefan Frings +*/ + +#ifndef REQUESTMAPPER_H +#define REQUESTMAPPER_H + +#include "httprequesthandler.h" + +/** + The request mapper dispatches incoming HTTP requests to controller classes + depending on the requested path. +*/ + +class RequestMapper : public HttpRequestHandler { + Q_OBJECT + Q_DISABLE_COPY(RequestMapper) +public: + + /** + Constructor. + @param parent Parent object + */ + RequestMapper(QObject* parent=0); + + /** + Dispatch a request to a controller. + @param request The received HTTP request + @param response Must be used to return the response + */ + void service(HttpRequest& request, HttpResponse& response); + +}; + +#endif // REQUESTMAPPER_H diff --git a/YACReaderLibrary/server/server.pri b/YACReaderLibrary/server/server.pri new file mode 100644 index 00000000..1f4e5df4 --- /dev/null +++ b/YACReaderLibrary/server/server.pri @@ -0,0 +1,26 @@ +INCLUDEPATH += $$PWD +DEPENDPATH += $$PWD + +HEADERS += \ + $$PWD/static.h \ + $$PWD/startup.h \ + $$PWD/requestmapper.h \ + $$PWD/controllers/dumpcontroller.h \ + $$PWD/controllers/templatecontroller.h \ + $$PWD/controllers/formcontroller.h \ + $$PWD/controllers/fileuploadcontroller.h \ + $$PWD/controllers/sessioncontroller.h + +SOURCES += \ + $$PWD/static.cpp \ + $$PWD/startup.cpp \ + $$PWD/requestmapper.cpp \ + $$PWD/controllers/dumpcontroller.cpp \ + $$PWD/controllers/templatecontroller.cpp \ + $$PWD/controllers/formcontroller.cpp \ + $$PWD/controllers/fileuploadcontroller.cpp \ + $$PWD/controllers/sessioncontroller.cpp + +include(lib/bfLogging/bfLogging.pri) +include(lib/bfHttpServer/bfHttpServer.pri) +include(lib/bfTemplateEngine/bfTemplateEngine.pri) diff --git a/YACReaderLibrary/server/startup.cpp b/YACReaderLibrary/server/startup.cpp new file mode 100644 index 00000000..221d9dce --- /dev/null +++ b/YACReaderLibrary/server/startup.cpp @@ -0,0 +1,77 @@ +/** + @file + @author Stefan Frings +*/ + +#include "static.h" +#include "startup.h" +#include "dualfilelogger.h" +#include "httplistener.h" +#include "requestmapper.h" +#include "staticfilecontroller.h" +#include +#include + +/** Name of this application */ +#define APPNAME "YACReaderLibrary" + +/** Publisher of this application */ +#define ORGANISATION "Butterfly" + +/** Short description of this application */ +#define DESCRIPTION "Web service based on Qt" + +void Startup::start() { + // Initialize the core application + QCoreApplication* app = QApplication::instance(); + app->setApplicationName(APPNAME); + //app->setOrganizationName(ORGANISATION); + QString configFileName=Static::getConfigDir()+"/"+QCoreApplication::applicationName()+".ini"; + + // Configure logging into files + QSettings* mainLogSettings=new QSettings(configFileName,QSettings::IniFormat,app); + mainLogSettings->beginGroup("mainLogFile"); + QSettings* debugLogSettings=new QSettings(configFileName,QSettings::IniFormat,app); + debugLogSettings->beginGroup("debugLogFile"); + Logger* logger=new DualFileLogger(mainLogSettings,debugLogSettings,10000,app); + logger->installMsgHandler(); + + // Configure template loader and cache + QSettings* templateSettings=new QSettings(configFileName,QSettings::IniFormat,app); + templateSettings->beginGroup("templates"); + Static::templateLoader=new TemplateCache(templateSettings,app); + + // Configure session store + QSettings* sessionSettings=new QSettings(configFileName,QSettings::IniFormat,app); + sessionSettings->beginGroup("sessions"); + Static::sessionStore=new HttpSessionStore(sessionSettings,app); + + // Configure static file controller + QSettings* fileSettings=new QSettings(configFileName,QSettings::IniFormat,app); + fileSettings->beginGroup("docroot"); + Static::staticFileController=new StaticFileController(fileSettings,app); + + // Configure and start the TCP listener + qDebug("ServiceHelper: Starting service"); + QSettings* listenerSettings=new QSettings(configFileName,QSettings::IniFormat,app); + listenerSettings->beginGroup("listener"); + listener = new HttpListener(listenerSettings,new RequestMapper(app),app); + + qDebug("ServiceHelper: Service has started"); +} + + +void Startup::stop() { + qDebug("ServiceHelper: Service has been stopped"); + // QCoreApplication destroys all objects that have been created in start(). + listener->close(); +} + + +Startup::Startup() +{ + +} + + + diff --git a/YACReaderLibrary/server/startup.h b/YACReaderLibrary/server/startup.h new file mode 100644 index 00000000..7405f0d1 --- /dev/null +++ b/YACReaderLibrary/server/startup.h @@ -0,0 +1,30 @@ +/** + @file + @author Stefan Frings +*/ + +#ifndef STARTUP_H +#define STARTUP_H + +class HttpListener; +/** + Helper class to install and run the application as a windows + service. +*/ +class Startup +{ +private: + //QTcpServer + HttpListener * listener; +public: + + /** Constructor */ + Startup(); + /** Start the server */ + void start(); + /** Stop the server */ + void stop(); +protected: +}; + +#endif // STARTUP_H diff --git a/YACReaderLibrary/server/static.cpp b/YACReaderLibrary/server/static.cpp new file mode 100644 index 00000000..dd1bc4e9 --- /dev/null +++ b/YACReaderLibrary/server/static.cpp @@ -0,0 +1,59 @@ +/** + @file + @author Stefan Frings +*/ + +#include "static.h" +#include +#include +#include +#include + +QString Static::configDir=0; + +TemplateLoader* Static::templateLoader=0; + +HttpSessionStore* Static::sessionStore=0; + +StaticFileController* Static::staticFileController=0; + +QString Static::getConfigFileName() { + return QString("%1/%2.ini").arg(getConfigDir()).arg(QCoreApplication::applicationName()); +} + +QString Static::getConfigDir() { + if (!configDir.isNull()) { + return configDir; + } + // Search config file + + QString binDir=QCoreApplication::applicationDirPath(); + QString organization=QCoreApplication::organizationName(); + QString configFileName=QCoreApplication::applicationName()+".ini"; + + QStringList searchList; + searchList.append(QDir::cleanPath(binDir)); + searchList.append(QDir::cleanPath(binDir+"/../etc")); + searchList.append(QDir::cleanPath(binDir+"/../../etc")); // for development under windows + searchList.append(QDir::rootPath()+"etc/xdg/"+organization); + searchList.append(QDir::rootPath()+"etc/opt"); + searchList.append(QDir::rootPath()+"etc"); + + foreach (QString dir, searchList) { + QFile file(dir+"/"+configFileName); + if (file.exists()) { + // found + configDir=dir; + qDebug("Using config file %s",qPrintable(file.fileName())); + return configDir; + } + } + + // not found + foreach (QString dir, searchList) { + qWarning("%s/%s not found",qPrintable(dir),qPrintable(configFileName)); + } + qFatal("Cannot find config file %s",qPrintable(configFileName)); + return 0; +} + diff --git a/YACReaderLibrary/server/static.h b/YACReaderLibrary/server/static.h new file mode 100644 index 00000000..74abf55b --- /dev/null +++ b/YACReaderLibrary/server/static.h @@ -0,0 +1,64 @@ +/** + @file + @author Stefan Frings +*/ + +#ifndef STATIC_H +#define STATIC_H + +#include +#include "templatecache.h" +#include "httpsessionstore.h" +#include "staticfilecontroller.h" + +/** + This class contains some static resources that are used by the application. +*/ + +class Static +{ +public: + + /** + Search the main config file and return its full path. + On the first call, the INI file gets searched. If not found, + the application aborts with an error message. +

+ The filename is the applications name plus the ending ".ini". It is searched + in the following directories: + + - Same directory as the applications executable file + - In ../etc relative to the applications executable file + - In ../../etc relative to the applications executable file + - In /etc/xdg/{organisation name} on the root drive + - In /etc/opt on the root drive + - In /etc on the root drive + + */ + static QString getConfigFileName(); + + /** + Gets the directory where the main config file is located. + On the first call, the INI file gets searched. If not found, + the application aborts with an error message. + @see getConfigFileName() + */ + static QString getConfigDir(); + + /** Cache for template files */ + static TemplateLoader* templateLoader; + + /** Storage for session cookies */ + static HttpSessionStore* sessionStore; + + /** Controller for static files */ + static StaticFileController* staticFileController; + +private: + + /** Directory of the main config file */ + static QString configDir; + +}; + +#endif // STATIC_H diff --git a/YACReaderLibrary/yacreaderlibrary_es.qm b/YACReaderLibrary/yacreaderlibrary_es.qm new file mode 100644 index 0000000000000000000000000000000000000000..92ed41fc9d9dce6f5d59d11efddbc2e7069f208a GIT binary patch literal 9449 zcmcgxd2Afz6@R|%_>7%62?@!Uw27U>I98MbF(xLlablFi#H5HqQO2{g_LT9=c4jtC zLe(Nrsst4YwLpQQib|!We^7$@2ZtyiL|P6NRZS1ks31zKsuF=xL?tMt{k`woId*qu z?W(Abb|*Wt-@D)M9Xs?yX8FtSK5+Lh)~8j1Q5-qxeuK(gIM5}J8TL0lV=-5@i9QKHo z-&(zX`#VI7_g3$F!YAs^R^N5*3;5pY>JLx8MAY_R&B&!Do}W|KwT(4To;yg?{zA=J z7yMSPti7S{7NUBq*1BvzQO9_#KLoj2+}hi`JBii|*4{h*G~{|%U8^2Y*P89>TK5BW zUHOi>ilyqh_V(I`pLhszUaYP)b9K%x(5*dJ_l-TDBN8vx{qQT0vuktRnd$EkH5zqi zK7I}IURrFlIvEmcZTivko z<{v@d4GoXjJ3!}=#Thp`y;n3X z{o_WW=Fc?kdJ1xh$)@{r-vZxrO+VSN9d`dy)5|yLu={gOuP+&go$hP;;A>qt|F=aQ z(k{PSwBnT;i5j*wZ+!I>NB9Xt@+L;e@wLY#pd(- zp2PP)X}RUWv!HXL<)J*zUwESB-9wOf$ek5?^_QqTLFLE*Q)nF4?WJb z-g9aj{QL9PpPgP0yWQFP(M6X*{yW;5pTe=KA$6_(t-3bc-PZZ%Yl$v+ylwd7U*r3K zZ@cP^4`Hw4ZHNE)IQ;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(AoK+J6z*9J}bCRA*NY@{ zp?+JcG%zBeN@||Ku19VN6AYGtM2Z9r!w6}Xv@80qHn`yV6BjlF#}~p^OCR*V6(tVA@^*Uwh@yRiis;`OmtM7E2vVlntM|k zh)tBSiV7-EY&l>KHzuk%j1SCFCKYuQp}sXSW7sNv>Hzw^7zj zhwUm;IVL;q3GiczSy1Lpg)4h>m8dKYufM18jBBuocb+9wf5_(d@H~q<9Abr^QE-p@ zAD#$#X!1al@2JL3m5HPx7?uotS2ZE!(nq_HuU|7`U}T>|-f378I8&A}D?C-3!(On^ zf)|QfSggeaCU(#06Z(vShRV#!*>Fa~^k&#jetJeAMrKXVlc{0avdIdG3R%Gl{b5Sb zYz?Q(DGHrHiiYdTCpG943_~)y!qi(F*{j8yXv5j?a#m#Mm3=uE|Kcf|` z>PspA8-Jk^Z6n-sk6{|bUeS?@z|!wy0maK0t{t4v{2oW*AZ1HOgQyMb+5_s?b9oHS zs>fH2Sc%F-f^{E&Tv!$50Iie0Yvznf0=5-(zR`4Di@sL=*pi^sRYhllbu#-n+HVFq z%eY}nL{Lk%XmMLSWpx+&Xv~pW6EkGIiLRt=^E@gRndZcQ0}@J-yen76{hu~Ql<0&| z*+dht;DSn87=$Wp8Se^JjI*<2BK#Q3iO!NG{a|cw)e!$}H}P~YPJe_5W)SCCR)Czt z4s{xk&U-M1^f=AV{rTA`{34CAn#1pQUhva#BKc0b1|+z?y(h`X2{lZb$HO0<6HhM) zCc4x>SOA=uVFpVK6CZfvTT>pDi$~*FqVC5py+L(}88ek>XZf%jI<;O&%C1a3|9=~n oQzclK(Nzs8H~OlCV#VvFVo+$2$1z?9^K@4dy^}Chbyd}W0AI{hV*mgE literal 0 HcmV?d00001 diff --git a/YACReaderLibrary/yacreaderlibrary_es.ts b/YACReaderLibrary/yacreaderlibrary_es.ts new file mode 100644 index 00000000..8fc05d28 --- /dev/null +++ b/YACReaderLibrary/yacreaderlibrary_es.ts @@ -0,0 +1,522 @@ + + + + + AddLibraryDialog + + + Comics folder : + Carpeta de cómics: + + + + Library Name : + Nombre de la librería: + + + + Add + Añadir + + + + Cancel + Cancelar + + + + Add an existing library + Añadir la librería existente + + + + CreateLibraryDialog + + + Comics folder : + Carpeta de cómics: + + + + Library Name : + Nombre de la libreria: + + + + Create + Crear + + + + Cancel + Cancelar + + + + Create new library + Crear la nueva librería + + + + ExportLibraryDialog + + + Output folder : + Carpeta de destino: + + + + Create + Crear + + + + Cancel + Cancelar + + + + Create covers package + Crear paquete de portadas + + + + Destination directory + Carpeta de destino + + + + Creating package . + Creando paquete . + + + + HelpAboutDialog + + + About + Acerca de + + + + Help + Ayuda + + + + ImportLibraryDialog + + Comics folder : + Carpeta de cómics: + + + + Library Name : + Nombre de la biblioteca : + + + Add + Añadir + + + + Package location : + Ubicación del paquete: + + + + Destination folder : + Directorio de destino: + + + + Unpack + Desempaquetar + + + + Cancel + Cancelar + + + + Extract a catalog + Extraer un catálogo + + + + Compresed library covers (*.clc) + Compresed library covers (*.clc) + + + + Importing package . + Importando paquete. + + + + LibraryWindow + + + Select a library: + Seleciona una biblioteca: + + + + Clear + Borrar + + + + Search folders/comics + Buscar directorios/cómics + + + + Include files (slower) + Incluir archivos (lento) + + + + <font color='white'> press 'F' to close fullscreen mode </font> + <font color='white'> presiona 'F' para salir de pantalla completa </font> + + + + YACReader Library + YACReader Library + + + + Create a new library + Crear una nueva biblioteca + + + + Open an existing library + Abrir una biblioteca existente + + + + Pack the covers of the selected library + Empaquetar las portadas de la biblioteca seleccionada + + + + Unpack a catalog + Desempaquetar un catálogo + + + + Update current library + Actualizar la librería seleccionada + + + + Rename current library + Renombrar la libreria seleccionada + + + + Delete current library from disk + Borrar la libería seleccionada del disco + + + + Remove current library from your collection + Eliminar librería de la colección + + + + Open current comic on YACReader + Abrir el cómic actual en YACReader + + + + Set as read + Marcar como leído + + + + Set comic as read + Marcar cómic como leído + + + + Set as unread + Marcar como no leído + + + + Set comic as unread + Marcar cómic como no leído + + + + Set all as read + Marcar todos como leídos + + + + Set all comics as read + Marcar todos los cómics como leídos + + + + Set all as unread + Marcar todos como no leídos + + + + Set all comics as unread + Marcar todos los cómics como no leídos + + + + Show/Hide marks + Mostrar/Ocultar marcas + + + + Show or hide readed marks + Mostrar u ocultar marcas + + + + Show properties of current comic + Mostrar las propiedades del cómic actual + + + + Fullscreen mode on/off (F) + Activar/desactivar modo a pantalla completa (F) + + + + Help, About YACReader + Ayuda, A cerca de... YACReader + + + + Select root node + Seleccionar el nodo raíz + + + + Expand all nodes + Expandir todos los nodos + + + + Colapse all nodes + Contraer todos los nodos + + + + Show options dialog + Mostrar opciones + + + + Open folder... + Abrir carpeta... + + + + Open containing folder... + Abrir carpeta contenedora... + + + + Library + Librería + + + + Saving libraries file.... + Guardando bibliotecas... + + + + There was a problem saving YACReaderLibrary libraries file. Please, check if you have enough permissions in the YACReader root folder. + Hubo un problema al guardar las bibliotecas de YACReaderLibrary. Por favor, comprueba si tienes suficientes permisos en el directorio raíz de YACReader. + + + + + Are you sure? + ¿Estás seguro? + + + + Do you want delete + ¿Deseas borrar + + + + Do you want remove + ¿Deseas eliminar + + + + library? +Files won't be erased from disk. + ? Los archivos no serán borrados del disco. + + + + OptionsDialog + + + Save + Guardar + + + + Cancel + Cancelar + + + + How to show covers: + Cómo mostrar las portadas: + + + + CoverFlow look + + + + + Stripe look + + + + + Overlapped Stripe look + Overlaped Stripe look + + + + Restart is needed + Es necesario reiniciar + + + + Comics directory + Directorio de cómics + + + + Saving config file.... + Hubo un problema al guardar la configuración de YACReaderLibrary. Por favor, comprueba si tienes suficientes permisos en el directorio raíz de YACReader. + Guardando archivo de configuración... + + + + There was a problem saving YACReaderLibrary configuration. Please, check if you have enough permissions in the YACReader root folder. + + + + + PropertiesDialog + + + Comic properties + Propiedades del cómic + + + + Name : + Nombre : + + + + Number of pages : + Número de páginas : + + + + Size : + Tamaño : + + + + QPushButton + + Hello world! + Hola mundo! + + + + RenameLibraryDialog + + + New Library Name : + Nombre de la nueva librería : + + + + Rename + Renombrar + + + + Cancel + Cancelar + + + + Rename current library + Renombrar la libreria seleccionada + + + + ThumbnailCreator + + 7z not found + 7z no encontrado + + + 7z wasn't found in your PATH. + 7z no ha sido encontrado en tu PATH. + + + 7z crashed + fallo en 7z + + + 7z crashed. + fallo en 7z. + + + 7z reading + Leyendo de 7z + + + problem reading from 7z + Problema lenyendo de 7z + + + 7z problem + Problema en 7z + + + Unknown error 7z + Error desconocido en 7z + + + + UpdateLibraryDialog + + + Updating.... + Actualizado... + + + + Cancel + Cancelar + + + diff --git a/common/check_new_version.cpp b/common/check_new_version.cpp new file mode 100644 index 00000000..af586246 --- /dev/null +++ b/common/check_new_version.cpp @@ -0,0 +1,112 @@ +#include "check_new_version.h" +#include +#include +#include +#include + +#define PREVIOUS_VERSION "0.4.5" + +HttpVersionChecker::HttpVersionChecker() + :QWidget() +{ + http = new QHttp(this); + + connect(http, SIGNAL(requestFinished(int, bool)), + this, SLOT(httpRequestFinished(int, bool))); + + connect(http, SIGNAL(responseHeaderReceived(const QHttpResponseHeader &)), + this, SLOT(readResponseHeader(const QHttpResponseHeader &))); + + connect(http, SIGNAL(readyRead(const QHttpResponseHeader &)), + this, SLOT(read(const QHttpResponseHeader &))); +} + +void HttpVersionChecker::get() +{ + QUrl url("http://code.google.com/p/yacreader/downloads/list"); + QHttp::ConnectionMode mode = QHttp::ConnectionModeHttp; + http->setHost(url.host(), mode, url.port() == -1 ? 0 : url.port()); + QByteArray path = QUrl::toPercentEncoding(url.path(), "!$&'()*+,;=:@/"); + if (path.isEmpty()) + path = "/"; + httpGetId = http->get(path, 0); +} +void HttpVersionChecker::readResponseHeader(const QHttpResponseHeader &responseHeader) +{ + +} + +void HttpVersionChecker::read(const QHttpResponseHeader &){ + content.append(http->readAll()); +} + +void HttpVersionChecker::httpRequestFinished(int requestId, bool error) +{ +#ifdef QT_DEBUG + QString response("YACReader-5.0.0 win32.exe"); +#else + QString response(content); +#endif + checkNewVersion(response); +} + +//TODO escribir prueba unitaria +bool HttpVersionChecker::checkNewVersion(QString sourceContent) +{ + #ifdef Q_WS_WIN + QRegExp rx(".*YACReader\\-([0-9]+).([0-9]+).([0-9]+)\\.?([0-9]+)?.{0,5}win32.*"); +#endif + +#ifdef Q_WS_X11 + QRegExp rx(".*YACReader\\-([0-9]+).([0-9]+).([0-9]+)\\.?([0-9]+)?.{0,5}X11.*"); +#endif + +#ifdef Q_WS_MAC + QRegExp rx(".*YACReader\\-([0-9]+).([0-9]+).([0-9]+)\\.?([0-9]+)?.{0,5}Mac.*"); +#endif + + int index = 0; + bool newVersion = false; + bool sameVersion = true; + //bool currentVersionIsNewer = false; +#ifdef QT_DEBUG + QString version(PREVIOUS_VERSION); +#else + QString version(VERSION); +#endif + QStringList sl = version.split("."); + if((index = rx.indexIn(sourceContent))!=-1) + { + int length = qMin(sl.size(),(rx.cap(4)!="")?4:3); + for(int i=0;isl.at(i).toInt()){ + newVersion=true; + break; + } + else + sameVersion = sameVersion && rx.cap(i+1).toInt()==sl.at(i).toInt(); + } + if(!newVersion && sameVersion) + { + if((sl.size()==3)&&(rx.cap(4)!="")) + newVersion = true; + } + + + } + + if(newVersion == true) + { + emit newVersionDetected(); + return true; + } + else + { + return false; + } +} \ No newline at end of file diff --git a/common/check_new_version.h b/common/check_new_version.h new file mode 100644 index 00000000..eddca21f --- /dev/null +++ b/common/check_new_version.h @@ -0,0 +1,32 @@ +#ifndef __CHECKUPDATE_H +#define __CHECKUPDATE_H + +#include +#include +#include +#include + +#define VERSION "5.0.0" + + class HttpVersionChecker : public QWidget + { + Q_OBJECT + public: + HttpVersionChecker(); + bool thereIsNewVersion(); + public slots: + void httpRequestFinished(int requestId, bool error); + void readResponseHeader(const QHttpResponseHeader &); + void read(const QHttpResponseHeader &); + void get(); + private: + QHttp *http; + int httpGetId; + QByteArray content; + bool found; + bool checkNewVersion(QString sourceContent); + signals: + void newVersionDetected(); + }; + +#endif diff --git a/common/custom_widgets.cpp b/common/custom_widgets.cpp new file mode 100644 index 00000000..42af4acc --- /dev/null +++ b/common/custom_widgets.cpp @@ -0,0 +1,461 @@ +#include "custom_widgets.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "qnaturalsorting.h" + + + + +HelpAboutDialog::HelpAboutDialog(QWidget * parent) +:QDialog(parent) +{ + QVBoxLayout * layout = new QVBoxLayout(); + + tabWidget = new QTabWidget(); + + tabWidget->addTab(aboutText = new QTextBrowser(), tr("About")); + aboutText->setOpenExternalLinks(true); + aboutText->setFont(QFont("Comic Sans MS", 10)); //purisa + tabWidget->addTab(helpText = new QTextBrowser(), tr("Help")); + helpText->setOpenExternalLinks(true); + helpText->setFont(QFont("Comic Sans MS", 10)); + //helpText->setDisabled(true); + //tabWidget->addTab(,"About Qt"); + + layout->addWidget(tabWidget); + layout->setContentsMargins(1,3,1,1); + + setLayout(layout); + resize(500, QApplication::desktop()->availableGeometry().height()*0.83); +} + +HelpAboutDialog::HelpAboutDialog(const QString & pathAbout,const QString & pathHelp,QWidget * parent) +:QDialog(parent) +{ + loadAboutInformation(pathAbout); + loadHelp(pathHelp); +} + +void HelpAboutDialog::loadAboutInformation(const QString & path) +{ + aboutText->insertHtml(fileToString(path)); + aboutText->moveCursor(QTextCursor::Start); +} + +void HelpAboutDialog::loadHelp(const QString & path) +{ + helpText->insertHtml(fileToString(path)); + helpText->moveCursor(QTextCursor::Start); +} + +QString HelpAboutDialog::fileToString(const QString & path) +{ + QFile f(path); + f.open(QIODevice::ReadOnly); + QTextStream txtS(&f); + QString content = txtS.readAll(); + f.close(); + + return content; +} + +void delTree(QDir dir) +{ + dir.setFilter(QDir::AllDirs|QDir::Files|QDir::Hidden|QDir::NoDotAndDotDot); + QFileInfoList list = dir.entryInfoList(); + for (int i = 0; i < list.size(); ++i) + { + QFileInfo fileInfo = list.at(i); + QString path = fileInfo.filePath(); + if(fileInfo.isDir()) + { + delTree(QDir(fileInfo.absoluteFilePath())); + dir.rmdir(fileInfo.absoluteFilePath()); + } + else + { + dir.remove(fileInfo.absoluteFilePath()); + } + } +} + +YACReaderIconProvider::YACReaderIconProvider() +:QFileIconProvider() +{ +} + +QIcon YACReaderIconProvider::icon(IconType type) const +{ + switch(type) + { + case Folder: + return QIcon(":/images/folder.png"); + break; + case File: + return QIcon(":/images/icon.png"); + break; + default: + return QFileIconProvider::icon(type); + } +} +QIcon YACReaderIconProvider::icon(const QFileInfo & info) const +{ + if(info.isDir()) + return QIcon(":/images/folder.png"); + if(info.isFile()) + return QIcon(":/images/icon.png"); +} +QString YACReaderIconProvider::type(const QFileInfo & info) const +{ + return QFileIconProvider::type(info); +} + +YACReaderFlow::YACReaderFlow(QWidget * parent,FlowType flowType) : PictureFlow(parent,flowType) {} + +void YACReaderFlow::mousePressEvent(QMouseEvent* event) +{ + if(event->x() > (width()+slideSize().width())/2) + showNext(); + else + if(event->x() < (width()-slideSize().width())/2) + showPrevious(); + //else (centered cover space) +} + +void YACReaderFlow::mouseDoubleClickEvent(QMouseEvent* event) +{ + if((event->x() > (width()-slideSize().width())/2)&&(event->x() < (width()+slideSize().width())/2)) + emit selected(centerIndex()); +} + +YACReaderComicDirModel::YACReaderComicDirModel( const QStringList & nameFilters, QDir::Filters filters, QDir::SortFlags sort, QObject * parent ) +:QDirModel(nameFilters,filters,sort,parent) +{ + +} + +//this method isn't used to show fileName on QListView +QString YACReaderComicDirModel::fileName ( const QModelIndex & index ) const +{ + QString fileName = QDirModel::fileName(index); + return fileName.remove(fileName.size()-4,4); +} + +QFileInfo YACReaderComicDirModel::fileInfo ( const QModelIndex & index ) const +{ + QFileInfo fileInfo = QDirModel::fileInfo(index); + QString path = QDir::cleanPath(filePath(index)).remove("/.yacreaderlibrary"); + path.remove(path.size()-4,4); + fileInfo.setFile(path); + return fileInfo; +} + + +YACReaderComicViewDelegate::YACReaderComicViewDelegate(QObject * parent) +:QItemDelegate(parent) +{ +} + +void YACReaderComicViewDelegate::paint ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const +{ + QStyleOptionViewItemV4 opt = setOptions(index, option); + + const QStyleOptionViewItemV2 *v2 = qstyleoption_cast(&option); + opt.features = v2 ? v2->features + : QStyleOptionViewItemV2::ViewItemFeatures(QStyleOptionViewItemV2::None); + const QStyleOptionViewItemV3 *v3 = qstyleoption_cast(&option); + opt.locale = v3 ? v3->locale : QLocale(); + opt.widget = v3 ? v3->widget : 0; + + // prepare + painter->save(); + painter->setClipRect(opt.rect); + + // get the data and the rectangles + + QVariant value; + + QPixmap pixmap; + QRect decorationRect; + QIcon icon; + value = index.data(Qt::DecorationRole); + if (value.isValid()) { + // ### we need the pixmap to call the virtual function + pixmap = decoration(opt, value); + if (value.type() == QVariant::Icon) { + icon = qvariant_cast(value); + const QSize size = icon.actualSize(option.decorationSize); + decorationRect = QRect(QPoint(0, 0), size); + } else { + icon = QIcon(); + decorationRect = QRect(QPoint(0, 0), pixmap.size()); + } + } else { + icon = QIcon(); + decorationRect = QRect(); + } + + QString text; + QRect displayRect; + value = index.data(Qt::DisplayRole); + if (value.isValid() && !value.isNull()) { + text = value.toString(); + text.remove(text.size()-4,4); + displayRect = textRectangle(painter, textLayoutBounds(opt), opt.font, text); + } + + QRect checkRect; + Qt::CheckState checkState = Qt::Unchecked; + value = index.data(Qt::CheckStateRole); + if (value.isValid()) { + checkState = static_cast(value.toInt()); + checkRect = check(opt, opt.rect, value); + } + + // do the layout + + doLayout(opt, &checkRect, &decorationRect, &displayRect, false); + + // draw the item + + drawBackground(painter, opt, index); + drawCheck(painter, opt, checkRect, checkState); + drawDecoration(painter, opt, decorationRect, pixmap); + drawDisplay(painter, opt, displayRect, text); + drawFocus(painter, opt, displayRect); + + // done + painter->restore(); +} + +QRect YACReaderComicViewDelegate::textLayoutBounds(const QStyleOptionViewItemV2 &option) const +{ + QRect rect = option.rect; + const bool wrapText = option.features & QStyleOptionViewItemV2::WrapText; + switch (option.decorationPosition) { + case QStyleOptionViewItem::Left: + case QStyleOptionViewItem::Right: + rect.setWidth(wrapText && rect.isValid() ? rect.width() : (1000)); + break; + case QStyleOptionViewItem::Top: + case QStyleOptionViewItem::Bottom: + rect.setWidth(wrapText ? option.decorationSize.width() : (1000)); + break; + } + + return rect; +} + +YACReaderTreeSearch::YACReaderTreeSearch(QObject * parent) +:QSortFilterProxyModel(parent),cache(new ModelIndexCache()) +{ + this->setFilterCaseSensitivity(Qt::CaseInsensitive); +} + +bool YACReaderTreeSearch::containsFiles(QString path,const QRegExp &exp) const +{ + QDir dir(path); + QStringList list = dir.entryList(QStringList() << "*"+exp.pattern()+"*",QDir::Files | QDir::NoDotAndDotDot); + return list.size()>0; +} + +bool YACReaderTreeSearch::itemMatchesExpression(const QModelIndex &index, const QRegExp &exp) const +{ + + QString name = ((QFileSystemModel *)sourceModel())->filePath(index); + ModelIndexCache::CacheData cd = cache->getCacheData(name); + bool v = false; + if(!cd.visited || cd.acepted) + { + v = name.contains(exp);// || containsFiles(name,exp); // TODO : complete path? + int numChildren = sourceModel()->rowCount(index); + for(int i=0; iindex(i,0,index), exp); + } + cd.visited = true; + cd.acepted = v; + cache->setModelIndex(name,cd); + } + + return cd.acepted; +} + +bool YACReaderTreeSearch::filterAcceptsRow ( int sourceRow, const QModelIndex & sourceParent ) const +{ + QString name = sourceModel()->data(sourceModel()->index(sourceRow, 0, sourceParent),Qt::DisplayRole ).toString(); + QFileSystemModel * dm = (QFileSystemModel *)sourceModel(); + if(!dm->isDir(dm->index(sourceRow, 0, sourceParent))) + //if(name.endsWith(".jpg")||name.endsWith(".db")) //TODO: if is not a dir + return false; + if(filterRegExp().isEmpty()) + return true; + if(name.contains("yacreader")) + return true; + QString path = dm->filePath(dm->index(sourceRow, 0, sourceParent)); + if(path.contains("yacreaderlibrary")) + return itemMatchesExpression(sourceModel()->index(sourceRow, 0, sourceParent), filterRegExp()); + else + return true; +} + +void YACReaderTreeSearch::reset() +{ + //invalidateFilter(); + cache->clear(); +} + +void YACReaderTreeSearch::softReset() +{ + //invalidateFilter(); +} + +ModelIndexCache::ModelIndexCache() +:cache() +{ +} + +void ModelIndexCache::setModelIndex(const QString & index, const CacheData & cd) +{ + cache.insert(index,cd); +} +ModelIndexCache::CacheData ModelIndexCache::getCacheData(const QString & index) const +{ + if(cache.contains(index)) + return cache.value(index); + else + { + CacheData cd; + cd.visited = false; + cd.acepted = true; + return cd; + } +} + +void ModelIndexCache::clear() +{ + cache.clear(); +} + +YACReaderSortComics::YACReaderSortComics(QObject * parent) +:QSortFilterProxyModel(parent) +{ + +} + +bool YACReaderSortComics::lessThan(const QModelIndex &left, const QModelIndex &right) const +{ + QVariant leftData = sourceModel()->data(left); + QVariant rightData = sourceModel()->data(right); + + QString leftString = leftData.toString(); + QString rightString = rightData.toString(); + + return naturalSortLessThanCI(leftString,rightString); +} + + +//-------------------------------------------- + +YACReaderFieldEdit::YACReaderFieldEdit(QWidget * parent) + :QLineEdit(parent) +{ + setPlaceholderText(tr("Click to overwrite")); + setModified(false); + restore = new QAction(tr("Restore to default"),this); + this->addAction(restore); + //this->setContextMenuPolicy(Qt::ActionsContextMenu); +} + +void YACReaderFieldEdit::focusInEvent(QFocusEvent* e) +{ + if (e->reason() == Qt::MouseFocusReason) + { + setModified(true); + setPlaceholderText(""); + } + + QLineEdit::focusInEvent(e); +} + +void YACReaderFieldEdit::clear() +{ + setPlaceholderText(tr("Click to overwrite")); + QLineEdit::clear(); + QLineEdit::setModified(false); +} + +void YACReaderFieldEdit::setDisabled(bool disabled) +{ + if(disabled) + setPlaceholderText(""); + QLineEdit::setDisabled(disabled); +} + +//-------------------------------------------- + +YACReaderFieldPlainTextEdit::YACReaderFieldPlainTextEdit(QWidget * parent) + :QPlainTextEdit(parent) +{ + document()->setModified(false); + setPlainText(tr("Click to overwrite")); + restore = new QAction(tr("Restore to default"),this); + this->addAction(restore); + //this->setContextMenuPolicy(Qt::ActionsContextMenu); +} + +void YACReaderFieldPlainTextEdit::focusInEvent(QFocusEvent* e) +{ + if (e->reason() == Qt::MouseFocusReason || e->reason() == Qt::TabFocusReason) + { + document()->setModified(true); + if(toPlainText()==tr("Click to overwrite")) + setPlainText(""); + } + + QPlainTextEdit::focusInEvent(e); +} + +void YACReaderFieldPlainTextEdit::focusOutEvent(QFocusEvent* e) +{ + /*if (e->reason() == Qt::MouseFocusReason || e->reason() == Qt::TabFocusReason) + { + if(toPlainText().isEmpty()) + { + setPlainText(tr("Click to overwrite")); + document()->setModified(false); + } + } + */ + QPlainTextEdit::focusOutEvent(e); +} + +void YACReaderFieldPlainTextEdit::clear() +{ + QPlainTextEdit::clear(); + document()->setModified(false); + setPlainText(tr("Click to overwrite")); +} + +void YACReaderFieldPlainTextEdit::setDisabled(bool disabled) +{ + if(disabled) + setPlainText(tr("Click to overwrite")); + QPlainTextEdit::setDisabled(disabled); +} \ No newline at end of file diff --git a/common/custom_widgets.h b/common/custom_widgets.h new file mode 100644 index 00000000..5d06566f --- /dev/null +++ b/common/custom_widgets.h @@ -0,0 +1,189 @@ +#ifndef __CUSTOM_WIDGETS_H +#define __CUSTOM_WIDGETS_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "pictureflow.h" + +class QToolBarStretch : public QWidget +{ +public: + QToolBarStretch(QWidget * parent=0):QWidget(parent) + { + QHBoxLayout * l= new QHBoxLayout(); + l->addStretch(); + setLayout(l); + } +}; + +class HelpAboutDialog : public QDialog +{ +Q_OBJECT +public: + HelpAboutDialog(QWidget * parent=0); + HelpAboutDialog(const QString & pathAbout,const QString & pathHelp,QWidget * parent =0); +public slots: + void loadAboutInformation(const QString & path); + void loadHelp(const QString & path); + +private: + QTabWidget *tabWidget; + QTextBrowser *aboutText; + QTextBrowser *helpText; + QString fileToString(const QString & path); +}; + +class YACReaderIconProvider : public QFileIconProvider +{ +public: + YACReaderIconProvider(); + virtual QIcon icon ( IconType type ) const; + virtual QIcon icon ( const QFileInfo & info ) const; + virtual QString type ( const QFileInfo & info ) const; +}; + +class YACReaderFlow : public PictureFlow +{ +Q_OBJECT +public: + YACReaderFlow(QWidget * parent,FlowType flowType = CoverFlowLike); +protected: + void mousePressEvent(QMouseEvent* event); + void mouseDoubleClickEvent(QMouseEvent* event); + +signals: + void selected(unsigned int centerIndex); +}; + +class YACReaderComicDirModel : public QDirModel +{ +Q_OBJECT + public: + YACReaderComicDirModel( const QStringList & nameFilters, QDir::Filters filters, QDir::SortFlags sort, QObject * parent = 0 ); + QString fileName ( const QModelIndex & index ) const; + QFileInfo fileInfo ( const QModelIndex & index ) const; +}; + +class YACReaderComicViewDelegate : public QItemDelegate +{ + Q_OBJECT + public: + YACReaderComicViewDelegate(QObject * parent = 0); + virtual void paint ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const; + QRect textLayoutBounds(const QStyleOptionViewItemV2 &option) const; +}; + +class ModelIndexCache +{ + +public: + struct CacheData{ + bool visited; + bool acepted; + }; + ModelIndexCache(); + void setModelIndex(const QString & index, const CacheData & cd); + CacheData getCacheData(const QString & index) const; + void clear(); + + +private: + QHash cache; +}; + + +class YACReaderTreeSearch : public QSortFilterProxyModel +{ + Q_OBJECT + public: + YACReaderTreeSearch(QObject * parent = 0); +protected: + virtual bool filterAcceptsRow ( int sourceRow, const QModelIndex & source_parent ) const; + bool itemMatchesExpression(const QModelIndex &index, const QRegExp &exp) const; + bool containsFiles(QString path,const QRegExp &exp) const; + public slots: + void reset(); + void softReset(); +private: + ModelIndexCache * cache; +}; + +class YACReaderSortComics : public QSortFilterProxyModel +{ + Q_OBJECT + public: + YACReaderSortComics(QObject * parent = 0); + protected: + bool lessThan(const QModelIndex &left, const QModelIndex &right) const; +}; + +void delTree(QDir dir); + + +class YACReaderFieldEdit : public QLineEdit +{ + Q_OBJECT + public: + YACReaderFieldEdit(QWidget * parent = 0); + void clear(); + void setDisabled(bool disabled); + protected: + void focusInEvent(QFocusEvent* e); +private: + QAction * restore; + +}; + +class YACReaderFieldPlainTextEdit : public QPlainTextEdit +{ + Q_OBJECT + public: + YACReaderFieldPlainTextEdit(QWidget * parent = 0); + void clear(); + void setDisabled(bool disabled); + protected: + void focusInEvent(QFocusEvent* e); + void focusOutEvent(QFocusEvent* e); +private: + QAction * restore; + +}; + + +//class YACReaderTableView : public QTableView +//{ +// Q_OBJECT +//public: +// YACReaderTableView(QWidget *parent = 0) +// : QTableView(parent) {} +// +//protected: +// bool viewportEvent ( QEvent * event ) +// { +// resizeColumnsToContents(); +// return QTableView::viewportEvent(event); +// } +//}; + +#endif + + diff --git a/common/pictureflow.cpp b/common/pictureflow.cpp new file mode 100644 index 00000000..8f74b337 --- /dev/null +++ b/common/pictureflow.cpp @@ -0,0 +1,1332 @@ +/* + PictureFlow - animated image show widget + http://pictureflow.googlecode.com + + Copyright (C) 2008 Ariya Hidayat (ariya@kde.org) + Copyright (C) 2007 Ariya Hidayat (ariya@kde.org) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +#include "pictureflow.h" + +// detect Qt version +#if QT_VERSION >= 0x040000 +#define PICTUREFLOW_QT4 +#elif QT_VERSION >= 0x030000 +#define PICTUREFLOW_QT3 +#elif QT_VERSION >= 235 +#define PICTUREFLOW_QT2 +#else +#error PictureFlow widgets need Qt 2, Qt 3 or Qt 4 +#endif + +#ifdef PICTUREFLOW_QT4 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +#ifdef PICTUREFLOW_QT3 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define qMax(x,y) ((x) > (y)) ? (x) : (y) +#define qMin(x,y) ((x) < (y)) ? (x) : (y) + +#define QVector QValueVector + +#define toImage convertToImage +#define contains find +#define modifiers state +#define ControlModifier ControlButton +#endif + +#ifdef PICTUREFLOW_QT2 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define qMax(x,y) ((x) > (y)) ? (x) : (y) +#define qMin(x,y) ((x) < (y)) ? (x) : (y) + +#define QVector QArray + +#define toImage convertToImage +#define contains find +#define modifiers state +#define ControlModifier ControlButton +#define flush flushX +#endif + +// for fixed-point arithmetic, we need minimum 32-bit long +// long long (64-bit) might be useful for multiplication and division +typedef long PFreal; +#define PFREAL_SHIFT 10 +#define PFREAL_ONE (1 << PFREAL_SHIFT) + +#define IANGLE_MAX 1024 +#define IANGLE_MASK 1023 + +inline PFreal fmul(PFreal a, PFreal b) +{ + return ((long long)(a))*((long long)(b)) >> PFREAL_SHIFT; +} + +inline PFreal fdiv(PFreal num, PFreal den) +{ + long long p = (long long)(num) << (PFREAL_SHIFT*2); + long long q = p / (long long)den; + long long r = q >> PFREAL_SHIFT; + + return r; +} + +inline PFreal fsin(int iangle) +{ + // warning: regenerate the table if IANGLE_MAX and PFREAL_SHIFT are changed! + static const PFreal tab[] = { + 3, 103, 202, 300, 394, 485, 571, 652, + 726, 793, 853, 904, 947, 980, 1004, 1019, + 1023, 1018, 1003, 978, 944, 901, 849, 789, + 721, 647, 566, 479, 388, 294, 196, 97, + -4, -104, -203, -301, -395, -486, -572, -653, + -727, -794, -854, -905, -948, -981, -1005, -1020, + -1024, -1019, -1004, -979, -945, -902, -850, -790, + -722, -648, -567, -480, -389, -295, -197, -98, + 3 + }; + + while(iangle < 0) + iangle += IANGLE_MAX; + iangle &= IANGLE_MASK; + + int i = (iangle >> 4); + PFreal p = tab[i]; + PFreal q = tab[(i+1)]; + PFreal g = (q - p); + return p + g * (iangle-i*16)/16; +} + +inline PFreal fcos(int iangle) +{ + return fsin(iangle + (IANGLE_MAX >> 2)); +} + +/* ---------------------------------------------------------- + +PictureFlowState stores the state of all slides, i.e. all the necessary +information to be able to render them. + +PictureFlowAnimator is responsible to move the slides during the +transition between slides, to achieve the effect similar to Cover Flow, +by changing the state. + +PictureFlowSoftwareRenderer (or PictureFlowOpenGLRenderer) is +the actual 3-d renderer. It should render all slides given the state +(an instance of PictureFlowState). + +Instances of all the above three classes are stored in +PictureFlowPrivate. + +------------------------------------------------------- */ + +struct SlideInfo +{ + int slideIndex; + int angle; + PFreal cx; + PFreal cy; + int blend; +}; + +class PictureFlowState +{ +public: + PictureFlowState(int angle=50, float spacingRatio=0); + ~PictureFlowState(); + + void reposition(); + void reset(); + + QRgb backgroundColor; + int slideWidth; + int slideHeight; + PictureFlow::ReflectionEffect reflectionEffect; + QVector slideImages; + + QVector marks; + bool showMarks; + QImage mark; + + int angle; + int rawAngle; + int spacing; + float spacingRatio; + PFreal offsetX; + PFreal offsetY; + + SlideInfo centerSlide; + QVector leftSlides; + QVector rightSlides; + int centerIndex; +}; + +class PictureFlowAnimator +{ +public: + PictureFlowAnimator(); + PictureFlowState* state; + + void start(int slide); + void stop(int slide); + void update(); + + int target; + int step; + int frame; + QTimer animateTimer; + bool animating; +}; + +class PictureFlowAbstractRenderer +{ +public: + PictureFlowAbstractRenderer(): state(0), dirty(false), widget(0) {} + virtual ~PictureFlowAbstractRenderer() {} + + PictureFlowState* state; + bool dirty; + QWidget* widget; + + virtual void init() = 0; + virtual void paint() = 0; +}; + +class PictureFlowSoftwareRenderer: public PictureFlowAbstractRenderer +{ +public: + PictureFlowSoftwareRenderer(); + ~PictureFlowSoftwareRenderer(); + + virtual void init(); + virtual void paint(); + void render(); + + +private: + QSize size; + QRgb bgcolor; + int effect; + QImage buffer; + QVector rays; + QImage* blankSurface; +#ifdef PICTUREFLOW_QT4 + QCache surfaceCache; + QHash imageHash; +#endif +#ifdef PICTUREFLOW_QT3 + QCache surfaceCache; + QMap imageHash; +#endif +#ifdef PICTUREFLOW_QT2 + QCache surfaceCache; + QIntDict imageHash; +#endif + + + void renderSlides(); + QRect renderSlide(const SlideInfo &slide, int col1 = -1, int col2 = -1); + QImage* surface(int slideIndex); +}; + +// ------------- PictureFlowState --------------------------------------- + +PictureFlowState::PictureFlowState(int a, float sr): +backgroundColor(0), slideWidth(150), slideHeight(200), +reflectionEffect(PictureFlow::BlurredReflection), centerIndex(0) , rawAngle(a), spacingRatio(sr) +{ +} + +PictureFlowState::~PictureFlowState() +{ + for(int i = 0; i < (int)slideImages.count(); i++) + delete slideImages[i]; +} + +// readjust the settings, call this when slide dimension is changed +void PictureFlowState::reposition() +{ + // angle = 70 * IANGLE_MAX / 360; // approx. 70 degrees tilted + angle = rawAngle * IANGLE_MAX / 360; + offsetX = slideWidth/2 * (PFREAL_ONE-fcos(angle)); + offsetY = slideWidth/2 * fsin(angle); + offsetX += slideWidth * PFREAL_ONE; + offsetY += slideWidth * PFREAL_ONE / 3; + if(rawAngle < 45) + offsetX += offsetX/4; + if(angle>0) + spacing = slideWidth * 0.35; + else + spacing = slideWidth*spacingRatio + slideWidth*(spacingRatio?0.10:0.2); +} + +// adjust slides so that they are in "steady state" position +void PictureFlowState::reset() +{ + centerSlide.angle = 0; + centerSlide.cx = 0; + centerSlide.cy = 0; + centerSlide.slideIndex = centerIndex; + centerSlide.blend = 256; + + if(angle == 0 && spacingRatio) + leftSlides.resize(4); + else + leftSlides.resize(6); + for(int i = 0; i < (int)leftSlides.count(); i++) + { + SlideInfo& si = leftSlides[i]; + si.angle = angle; + si.cx = -(offsetX + spacing*(i)*PFREAL_ONE); + si.cy = offsetY; + si.slideIndex = centerIndex-1-i; + si.blend = 200; + if(i == (int)leftSlides.count()-2) + si.blend = 128; + if(i == (int)leftSlides.count()-1) + si.blend = 0; + } + if(angle==0 && spacingRatio) + rightSlides.resize(4); + else + rightSlides.resize(6); + for(int i = 0; i < (int)rightSlides.count(); i++) + { + SlideInfo& si = rightSlides[i]; + si.angle = -angle; + si.cx = offsetX + spacing*(i)*PFREAL_ONE; + si.cy = offsetY; + si.slideIndex = centerIndex+1+i; + si.blend = 200; + if(i == (int)rightSlides.count()-2) + si.blend = 128; + if(i == (int)rightSlides.count()-1) + si.blend = 0; + } +} + +// ------------- PictureFlowAnimator --------------------------------------- + +PictureFlowAnimator::PictureFlowAnimator(): +state(0), target(0), step(0), frame(0), animating(false) +{ +} + +void PictureFlowAnimator::start(int slide) +{ + target = slide; + if(!animateTimer.isActive() && state) + { + step = (target < state->centerSlide.slideIndex) ? -1 : 1; + animateTimer.setSingleShot(true); + animateTimer.start(0); //TODO comprobar rendimiento, originalmente era 30 + animating = true; + } +} + +void PictureFlowAnimator::stop(int slide) +{ + step = 0; + target = slide; + frame = slide << 16; + animateTimer.stop(); + animating = false; +} + +void PictureFlowAnimator::update() +{ + /*if(!animateTimer.isActive()) + return;*/ + if(step == 0) + return; + if(!state) + return; + + int speed = 16384/4; //TODO comprobar rendimiento, originalmente era /4 + +#if 1 + // deaccelerate when approaching the target + const int max = 2 * 65536; //TODO cambiado de 2 * a 4 * comprobar rendimiento + + int fi = frame; + fi -= (target << 16); + if(fi < 0) + fi = -fi; + fi = qMin(fi, max); + + int ia = IANGLE_MAX * (fi-max/2) / (max*2); + speed = 512 + 16384 * (PFREAL_ONE+fsin(ia))/PFREAL_ONE; +#endif + + frame += speed*step; + + int index = frame >> 16; + int pos = frame & 0xffff; + int neg = 65536 - pos; + int tick = (step < 0) ? neg : pos; + PFreal ftick = (tick * PFREAL_ONE) >> 16; + + if(step < 0) + index++; + + if(state->centerIndex != index) + { + state->centerIndex = index; + frame = index << 16; + state->centerSlide.slideIndex = state->centerIndex; + for(int i = 0; i < (int)state->leftSlides.count(); i++) + state->leftSlides[i].slideIndex = state->centerIndex-1-i; + for(int i = 0; i < (int)state->rightSlides.count(); i++) + state->rightSlides[i].slideIndex = state->centerIndex+1+i; + } + + state->centerSlide.angle = (step * tick * state->angle) >> 16; + state->centerSlide.cx = -step * fmul(state->offsetX, ftick); + state->centerSlide.cy = fmul(state->offsetY, ftick); + + if(state->centerIndex == target) + { + stop(target); + state->reset(); + return; + } + + for(int i = 0; i < (int)state->leftSlides.count(); i++) + { + SlideInfo& si = state->leftSlides[i]; + si.angle = state->angle; + si.cx = -(state->offsetX + state->spacing*(i)*PFREAL_ONE + step*state->spacing*ftick); + si.cy = state->offsetY; + } + + for(int i = 0; i < (int)state->rightSlides.count(); i++) + { + SlideInfo& si = state->rightSlides[i]; + si.angle = -state->angle; + si.cx = state->offsetX + state->spacing*(i)*PFREAL_ONE - step*state->spacing*ftick; + si.cy = state->offsetY; + } + + if(step > 0) + { + PFreal ftick = (neg * PFREAL_ONE) >> 16; + state->rightSlides[0].angle = -(neg * state->angle) >> 16; + state->rightSlides[0].cx = fmul(state->offsetX, ftick); + state->rightSlides[0].cy = fmul(state->offsetY, ftick); + } + else + { + PFreal ftick = (pos * PFREAL_ONE) >> 16; + state->leftSlides[0].angle = (pos * state->angle) >> 16; + state->leftSlides[0].cx = -fmul(state->offsetX, ftick); + state->leftSlides[0].cy = fmul(state->offsetY, ftick); + } + + // must change direction ? + if(target < index) if(step > 0) + step = -1; + if(target > index) if(step < 0) + step = 1; + + // the first and last slide must fade in/fade out + int nleft = state->leftSlides.count(); + int nright = state->rightSlides.count(); + int fade = pos / 256; + + for(int index = 0; index < nleft; index++) + { + int blend = 200; + if(index == nleft-1) + blend = (step > 0) ? 0 : 128-fade/2; + if(index == nleft-2) + blend = (step > 0) ? 128-fade/2 : 200-(0.5625*fade/2); + if(index == nleft-3) + blend = (step > 0) ? 200-(0.5625*fade/2) : 200; + if(index == 0) + blend = (step > 0) ? 200 : 200 + 56-(0.4375*fade/2) ; + state->leftSlides[index].blend = blend; + } + for(int index = 0; index < nright; index++) + { + int blend = (index < nright-2) ? 200 : 128; + if(index == nright-1) + blend = (step > 0) ? fade/2 : 0; + if(index == nright-2) + blend = (step > 0) ? 128+(0.5625*fade/2) : (0.5625*fade/2); + if(index == nright-3) + blend = (step > 0) ? 200 : 128+(0.5625*fade/2); + if(index == 0) + blend = (step > 0) ? 200 + (0.4375*fade/2) : 200; + state->rightSlides[index].blend = blend; + } + + state->centerSlide.blend = (step > 0) ? 256 - (0.4375*fade/2) : 200 + (0.4375*fade/2); + +} + +// ------------- PictureFlowSoftwareRenderer --------------------------------------- + +PictureFlowSoftwareRenderer::PictureFlowSoftwareRenderer(): +PictureFlowAbstractRenderer(), size(0,0), bgcolor(0), effect(-1), blankSurface(0) +{ +#ifdef PICTUREFLOW_QT3 + surfaceCache.setAutoDelete(true); +#endif +} + +PictureFlowSoftwareRenderer::~PictureFlowSoftwareRenderer() +{ + surfaceCache.clear(); + buffer = QImage(); + delete blankSurface; +} + +void PictureFlowSoftwareRenderer::paint() +{ + if(!widget) + return; + + if(widget->size() != size) + init(); + + if(state->backgroundColor != bgcolor) + { + bgcolor = state->backgroundColor; + surfaceCache.clear(); + } + + if((int)(state->reflectionEffect) != effect) + { + effect = (int)state->reflectionEffect; + surfaceCache.clear(); + } + + if(dirty) + render(); + + QPainter painter(widget); + painter.drawImage(QPoint(0,0), buffer); +} + +void PictureFlowSoftwareRenderer::init() +{ + if(!widget) + return; + + surfaceCache.clear(); + blankSurface = 0; + + size = widget->size(); + int ww = size.width(); + int wh = size.height(); + int w = (ww+1)/2; + int h = (wh+1)/2; + if(h<10)//TODO a partir de qué h es seguro?? + return; + +#ifdef PICTUREFLOW_QT4 + buffer = QImage(ww, wh, QImage::Format_RGB32); +#endif +#if defined(PICTUREFLOW_QT3) || defined(PICTUREFLOW_QT2) + buffer.create(ww, wh, 32); +#endif + buffer.fill(bgcolor); + + rays.resize(w*2); + for(int i = 0; i < w; i++) + { + PFreal gg = ((PFREAL_ONE >> 1) + i * PFREAL_ONE) / (2*h); + rays[w-i-1] = -gg; + rays[w+i] = gg; + } + + dirty = true; +} + +// TODO: optimize this with lookup tables +static QRgb blendColor(QRgb c1, QRgb c2, int blend) +{ + int r = qRed(c1) * blend/256 + qRed(c2)*(256-blend)/256; + int g = qGreen(c1) * blend/256 + qGreen(c2)*(256-blend)/256; + int b = qBlue(c1) * blend/256 + qBlue(c2)*(256-blend)/256; + return qRgb(r, g, b); +} + + +static QImage* prepareSurface(const QImage* slideImage, int w, int h, QRgb bgcolor, +PictureFlow::ReflectionEffect reflectionEffect) +{ + + int iw,ih; + iw = slideImage->width(); + ih = slideImage->height(); + int psw,psh; + if(iw>ih) + { + psw = w; + psh = w * (1.0*ih/iw); + } + else + { + int h1=h; + psw = h1 * (1.0*iw/ih); + psh = h1; + + while(psw>w) + { + h1-=2; + psw = h1 * (1.0*iw/ih); + psh = h1; + } + } + w = psw; + +#ifdef PICTUREFLOW_QT4 + Qt::TransformationMode mode = Qt::SmoothTransformation; + QImage img = slideImage->scaled(psw, psh, Qt::IgnoreAspectRatio, mode); +#endif +#if defined(PICTUREFLOW_QT3) || defined(PICTUREFLOW_QT2) + QImage img = slideImage->smoothScale(w, h); +#endif + + // slightly larger, to accomodate for the reflection + int hs = h * 2; + int hofs = h / 3; + + // offscreen buffer: black is sweet +#ifdef PICTUREFLOW_QT4 + QImage* result = new QImage(hs, w, QImage::Format_RGB32); +#endif +#if defined(PICTUREFLOW_QT3) || defined(PICTUREFLOW_QT2) + QImage* result = new QImage; + result->create(hs, w, 32); +#endif + result->fill(bgcolor); + + // transpose the image, this is to speed-up the rendering + // because we process one column at a time + // (and much better and faster to work row-wise, i.e in one scanline) + int lhof = (h-psh); + //int lwof = (w-psw)/2; + for(int x = 0; x < psw; x++) + for(int y = 0; y < psh; y++) + + result->setPixel(hofs + y + lhof , x, img.pixel(x, y)); + + if(reflectionEffect != PictureFlow::NoReflection) + { + // create the reflection + int ht = hs - (h+hofs); + int hte = ht; + for(int x = 0; x < psw; x++) + for(int y = 0; y < ht; y++) + { + QRgb color; + if(ysetPixel(h+hofs + y, x,blendColor(color,bgcolor,80*(hte-y)/hte)); + } + + + } + + return result; +} + +QImage* PictureFlowSoftwareRenderer::surface(int slideIndex) +{ + if(!state) + return 0; + if(slideIndex < 0) + return 0; + if(slideIndex >= (int)state->slideImages.count()) + return 0; + +#ifdef PICTUREFLOW_QT4 + int key = slideIndex; +#endif +#if defined(PICTUREFLOW_QT3) || defined(PICTUREFLOW_QT2) + QString key = QString::number(slideIndex); +#endif + + QImage* img = state->slideImages.at(slideIndex); + + bool empty = img ? img->isNull() : true; + if(empty) + { + surfaceCache.remove(key); + imageHash.remove(slideIndex); + if(!blankSurface) + { + int sw = state->slideWidth; + int sh = state->slideHeight; + +#ifdef PICTUREFLOW_QT4 + QImage img = QImage(sw, sh, QImage::Format_RGB32); + + QPainter painter(&img); + QPoint p1(sw*4/10, 0); + QPoint p2(sw*6/10, sh); + QLinearGradient linearGrad(p1, p2); + linearGrad.setColorAt(0, Qt::black); + linearGrad.setColorAt(1, Qt::white); + painter.setBrush(linearGrad); + painter.fillRect(0, 0, sw, sh, QBrush(linearGrad)); + + + painter.end(); +#endif +#if defined(PICTUREFLOW_QT3) || defined(PICTUREFLOW_QT2) + QPixmap pixmap(sw, sh, 32); + QPainter painter(&pixmap); + painter.fillRect(pixmap.rect(), QColor(192,192,192)); + painter.fillRect(5, 5, sw-10, sh-10, QColor(64,64,64)); + painter.end(); + QImage img = pixmap.convertToImage(); +#endif + + blankSurface = prepareSurface(&img, sw, sh, bgcolor, state->reflectionEffect); + } + return blankSurface; + } + +#ifdef PICTUREFLOW_QT4 + bool exist = imageHash.contains(slideIndex); + if(exist) + if(img == imageHash.find(slideIndex).value()) +#endif +#ifdef PICTUREFLOW_QT3 + bool exist = imageHash.find(slideIndex) != imageHash.end(); + if(exist) + if(img == imageHash.find(slideIndex).data()) +#endif +#ifdef PICTUREFLOW_QT2 + if(img == imageHash[slideIndex]) +#endif + if(surfaceCache.contains(key)) + return surfaceCache[key]; + + + QImage* sr = prepareSurface(img, state->slideWidth, state->slideHeight, bgcolor, state->reflectionEffect); + //check if this slide must be marked + //if(marks[slideIndex]) + if(state->showMarks) + { + if(state->marks[slideIndex]) + { + QPainter painter(sr); + painter.setPen(QColor(255,0,0).rgb()); + int sh = sr->height(); + int jInit = sh*4/5; + int iInit = state->slideHeight+state->slideHeight/3; + /*for(int j = jInit; j < sh; j ++) + { + for(int i = iInit-(j-jInit); i < iInit; i ++) + { + + painter.drawPoint(i,j); + } + }*/ + painter.drawImage(QRect(iInit-(sh-jInit),jInit,sh-jInit,sh-jInit),state->mark); + } + } + surfaceCache.insert(key, sr); + imageHash.insert(slideIndex, img); + + return sr; +} + +// Renders a slide to offscreen buffer. Returns a rect of the rendered area. +// col1 and col2 limit the column for rendering. +QRect PictureFlowSoftwareRenderer::renderSlide(const SlideInfo &slide, int col1, int col2) +{ + int blend = slide.blend; + if(!blend) + return QRect(); + + QImage* src = surface(slide.slideIndex); + if(!src) + return QRect(); + + QRect rect(0, 0, 0, 0); + + int sw = src->height(); + int sh = src->width(); + int h = buffer.height(); + int w = buffer.width(); + + if(col1 > col2) + { + int c = col2; + col2 = col1; + col1 = c; + } + + col1 = (col1 >= 0) ? col1 : 0; + col2 = (col2 >= 0) ? col2 : w-1; + col1 = qMin(col1, w-1); + col2 = qMin(col2, w-1); + + int zoom = 100; + int distance = h * 100 / zoom; + PFreal sdx = fcos(slide.angle); + PFreal sdy = fsin(slide.angle); + PFreal xs = slide.cx - state->slideWidth * sdx/2; + PFreal ys = slide.cy - state->slideWidth * sdy/2; + PFreal dist = distance * PFREAL_ONE; + + int xi = qMax((PFreal)0, (w*PFREAL_ONE/2) + fdiv(xs*h, dist+ys) >> PFREAL_SHIFT); + if(xi >= w) + return rect; + + bool flag = false; + rect.setLeft(xi); + for(int x = qMax(xi, col1); x <= col2; x++) + { + PFreal hity = 0; + PFreal fk = rays[x]; + if(sdy) + { + fk = fk - fdiv(sdx,sdy); + hity = -fdiv((rays[x]*distance - slide.cx + slide.cy*sdx/sdy), fk); + } + + dist = distance*PFREAL_ONE + hity; + if(dist < 0) + continue; + + PFreal hitx = fmul(dist, rays[x]); + PFreal hitdist = fdiv(hitx - slide.cx, sdx); + + int column = sw/2 + (hitdist >> PFREAL_SHIFT); + if(column >= sw) + break; + if(column < 0) + continue; + + rect.setRight(x); + if(!flag) + rect.setLeft(x); + flag = true; + + int y1 = h/2; + int y2 = y1+ 1; + QRgb* pixel1 = (QRgb*)(buffer.scanLine(y1)) + x; + QRgb* pixel2 = (QRgb*)(buffer.scanLine(y2)) + x; + QRgb pixelstep = pixel2 - pixel1; + + int center = (sh/2); + int dy = dist / h; + int p1 = center*PFREAL_ONE - dy/2; + int p2 = center*PFREAL_ONE + dy/2; + + const QRgb *ptr = (const QRgb*)(src->scanLine(column)); + if(blend == 256) + while((y1 >= 0) && (y2 < h) && (p1 >= 0)) + { + *pixel1 = ptr[p1 >> PFREAL_SHIFT]; + *pixel2 = ptr[p2 >> PFREAL_SHIFT]; + p1 -= dy; + p2 += dy; + y1--; + y2++; + pixel1 -= pixelstep; + pixel2 += pixelstep; + } + else + while((y1 >= 0) && (y2 < h) && (p1 >= 0)) + { + QRgb c1 = ptr[p1 >> PFREAL_SHIFT]; + QRgb c2 = ptr[p2 >> PFREAL_SHIFT]; + *pixel1 = blendColor(c1, bgcolor, blend); + *pixel2 = blendColor(c2, bgcolor, blend); + p1 -= dy; + p2 += dy; + y1--; + y2++; + pixel1 -= pixelstep; + pixel2 += pixelstep; + } + } + + rect.setTop(0); + rect.setBottom(h-1); + return rect; +} + +void PictureFlowSoftwareRenderer::renderSlides() +{ + int nleft = state->leftSlides.count(); + int nright = state->rightSlides.count(); + + QRect r = renderSlide(state->centerSlide); + int c1 = r.left(); + int c2 = r.right(); + + for(int index = 0; index < nleft; index++) + { + QRect rs = renderSlide(state->leftSlides[index], 0, c1-1); + if(!rs.isEmpty()) + c1 = rs.left(); + } + for(int index = 0; index < nright; index++) + { + QRect rs = renderSlide(state->rightSlides[index], c2+1, buffer.width()); + if(!rs.isEmpty()) + c2 = rs.right(); + } +} + +// Render the slides. Updates only the offscreen buffer. +void PictureFlowSoftwareRenderer::render() +{ + buffer.fill(state->backgroundColor); + renderSlides(); + if(state->slideImages.size()>0) + { + int x = buffer.width()/2; + int size = buffer.width() * 0.021; + int start = buffer.width() * 0.010; + for(int j = start; jbackgroundColor); + for(int i = 0; ibackgroundColor); + buffer.setPixel(QPoint(x+i,j),QColor(255,255,255).rgb()-state->backgroundColor); + } + } + + QPainter painter(&buffer); + painter.setPen(QColor(255,255,255).rgb()-state->backgroundColor); + painter.setFont(QFont("Arial", start+size*0.5)); + painter.drawText(start , start+size, QString().setNum(state->centerIndex+1)+"/"+QString().setNum(state->slideImages.size())); + } + dirty = false; +} + +// ----------------------------------------- + +class PictureFlowPrivate +{ +public: + PictureFlowState* state; + PictureFlowAnimator* animator; + PictureFlowAbstractRenderer* renderer; + QTimer triggerTimer; +}; + + +PictureFlow::PictureFlow(QWidget* parent,FlowType flowType): QWidget(parent) +{ + d = new PictureFlowPrivate; + + switch(flowType){ + case CoverFlowLike: + d->state = new PictureFlowState(50,0); + break; + case Strip: + d->state = new PictureFlowState(0,1); + break; + case StripOverlapped: + d->state = new PictureFlowState(0,0); + break; + } + + framesSkip = 0; + + d->state->reset(); + d->state->reposition(); + + d->renderer = new PictureFlowSoftwareRenderer; + d->renderer->state = d->state; + d->renderer->widget = this; + d->renderer->init(); + + d->animator = new PictureFlowAnimator; + d->animator->state = d->state; + QObject::connect(&d->animator->animateTimer, SIGNAL(timeout()), this, SLOT(updateAnimation())); + + QObject::connect(&d->triggerTimer, SIGNAL(timeout()), this, SLOT(render())); + +#ifdef PICTUREFLOW_QT4 + setAttribute(Qt::WA_StaticContents, true); + setAttribute(Qt::WA_OpaquePaintEvent, true); + setAttribute(Qt::WA_NoSystemBackground, true); +#endif +#ifdef PICTUREFLOW_QT3 + setWFlags(getWFlags() | Qt::WStaticContents); + setWFlags(getWFlags() | Qt::WNoAutoErase); +#endif +#ifdef PICTUREFLOW_QT2 + setWFlags(getWFlags() | Qt::WPaintClever); + setWFlags(getWFlags() | Qt::WRepaintNoErase); + setWFlags(getWFlags() | Qt::WResizeNoErase); +#endif +} + +PictureFlow::~PictureFlow() +{ + delete d->renderer; + delete d->animator; + delete d->state; + delete d; +} + +int PictureFlow::slideCount() const +{ + return d->state->slideImages.count(); +} + +QColor PictureFlow::backgroundColor() const +{ + return QColor(d->state->backgroundColor); +} + +void PictureFlow::setBackgroundColor(const QColor& c) +{ + d->state->backgroundColor = c.rgb(); + triggerRender(); +} + +QSize PictureFlow::slideSize() const +{ + return QSize(d->state->slideWidth, d->state->slideHeight); +} + +void PictureFlow::setSlideSize(QSize size) +{ + d->state->slideWidth = size.width(); + d->state->slideHeight = size.height(); + d->state->reposition(); + triggerRender(); +} + +PictureFlow::ReflectionEffect PictureFlow::reflectionEffect() const +{ + return d->state->reflectionEffect; +} + +void PictureFlow::setReflectionEffect(ReflectionEffect effect) +{ + d->state->reflectionEffect = effect; + triggerRender(); +} + +QImage PictureFlow::slide(int index) const +{ + QImage* i = 0; + if((index >= 0) && (index < slideCount())) + i = d->state->slideImages[index]; + return i ? QImage(*i) : QImage(); +} + +void PictureFlow::addSlide(const QImage& image) +{ + int c = d->state->slideImages.count(); + d->state->slideImages.resize(c+1); + d->state->slideImages[c] = new QImage(image); + d->state->marks.resize(c+1); + d->state->marks[c] = false; + triggerRender(); +} + +void PictureFlow::addSlide(const QPixmap& pixmap) +{ + addSlide(pixmap.toImage()); +} + +void PictureFlow::setSlide(int index, const QImage& image) +{ + if((index >= 0) && (index < slideCount())) + { + QImage* i = image.isNull() ? 0 : new QImage(image); + delete d->state->slideImages[index]; + d->state->slideImages[index] = i; + triggerRender(); + } +} + +void PictureFlow::setSlide(int index, const QPixmap& pixmap) +{ + setSlide(index, pixmap.toImage()); +} + +int PictureFlow::centerIndex() const +{ + return d->state->centerIndex; +} + +void PictureFlow::setCenterIndex(int index) +{ + index = qMin(index, slideCount()-1); + index = qMax(index, 0); + d->state->centerIndex = index; + d->state->reset(); + d->animator->stop(index); + triggerRender(); +} + +void PictureFlow::clear() +{ + int c = d->state->slideImages.count(); + for(int i = 0; i < c; i++) + delete d->state->slideImages[i]; + d->state->slideImages.resize(0); + + d->state->marks.resize(0); + + d->state->reset(); + triggerRender(); +} + +void PictureFlow::render() +{ + d->renderer->dirty = true; + update(); +} + +void PictureFlow::triggerRender() +{ +#ifdef PICTUREFLOW_QT4 + d->triggerTimer.setSingleShot(true); + d->triggerTimer.start(0); +#endif +#if defined(PICTUREFLOW_QT3) || defined(PICTUREFLOW_QT2) + d->triggerTimer.start(0, true); +#endif +} + +void PictureFlow::showPrevious() +{ + int step = d->animator->step; + int center = d->state->centerIndex; + + if(step > 0) + d->animator->start(center); + + if(step == 0) + if(center > 0) + d->animator->start(center - 1); + + if(step < 0) + d->animator->target = qMax(0, center - 2); +} + +void PictureFlow::showNext() +{ + int step = d->animator->step; + int center = d->state->centerIndex; + + if(step < 0) + d->animator->start(center); + + if(step == 0) + if(center < slideCount()-1) + d->animator->start(center + 1); + + if(step > 0) + d->animator->target = qMin(center + 2, slideCount()-1); +} + +void PictureFlow::showSlide(int index) +{ + index = qMax(index, 0); + index = qMin(slideCount()-1, index); + if(index == d->state->centerSlide.slideIndex) + return; + + d->animator->start(index); +} + +void PictureFlow::keyPressEvent(QKeyEvent* event) +{ + if(event->key() == Qt::Key_Left) + { + if(event->modifiers() == Qt::ControlModifier) + showSlide(centerIndex()-10); + else + showPrevious(); + event->accept(); + return; + } + + if(event->key() == Qt::Key_Right) + { + if(event->modifiers() == Qt::ControlModifier) + showSlide(centerIndex()+10); + else + showNext(); + event->accept(); + return; + } + + event->ignore(); +} + +void PictureFlow::mousePressEvent(QMouseEvent* event) +{ + if(event->x() > width()/2) + showNext(); + else + showPrevious(); +} + +void PictureFlow::paintEvent(QPaintEvent* event) +{ + Q_UNUSED(event); + d->renderer->paint(); +} + +void PictureFlow::resizeEvent(QResizeEvent* event) +{ + triggerRender(); + QWidget::resizeEvent(event); +} +#include +void PictureFlow::updateAnimation() //bucle principal +{ + QTime now; + now.start(); + bool frameSkiped = false; + + int old_center = d->state->centerIndex; + d->animator->update(); + if(framesSkip == 0) + render();//triggerRender(); + else + { + framesSkip--; + frameSkiped = true; + } + + if(d->state->centerIndex != old_center) + emit centerIndexChanged(d->state->centerIndex); + if(d->animator->animating == true) + { + int difference = 10-now.elapsed(); + if(difference >= 0 && !frameSkiped) + QTimer::singleShot(difference, this, SLOT(updateAnimation())); + else + { + QTimer::singleShot(0, this, SLOT(updateAnimation())); + if(!frameSkiped) + framesSkip = -( (difference - 10) / 10); + } + } + +} + +void PictureFlow::setFlowType(FlowType flowType) +{ + switch(flowType){ + case CoverFlowLike: + d->state->rawAngle = 50; + d->state->spacingRatio = 0, + d->state->reposition(); + break; + case Strip: + d->state->rawAngle = 0; + d->state->spacingRatio = 1; + d->state->reposition(); + break; + case StripOverlapped: + d->state->rawAngle = 0; + d->state->spacingRatio = 0; + d->state->reposition(); + break; + } + d->state->reset(); + d->renderer->init(); +} + +void PictureFlow::setMarkImage(const QImage & m) +{ + d->state->mark = m; +} + +void PictureFlow::markSlide(int index) +{ + if(indexstate->marks.size()) + d->state->marks[index] = true; +} + +void PictureFlow::updateMarks() +{ + d->renderer->init(); + d->renderer->paint(); + repaint(); +} + +void PictureFlow::unmarkSlide(int index) +{ + if(indexstate->marks.size()) + d->state->marks[index] = false; +} + +void PictureFlow::setMarks(const QVector & m) +{ + d->state->marks = m; + updateMarks(); +} + +void PictureFlow::setShowMarks(bool enable) +{ + d->state->showMarks = enable; + updateMarks(); +} + +QVector PictureFlow::getMarks() +{ + return d->state->marks; +} + diff --git a/common/pictureflow.h b/common/pictureflow.h new file mode 100644 index 00000000..abe80073 --- /dev/null +++ b/common/pictureflow.h @@ -0,0 +1,224 @@ +/* + PictureFlow - animated image show widget + http://pictureflow.googlecode.com + + Copyright (C) 2008 Ariya Hidayat (ariya@kde.org) + Copyright (C) 2007 Ariya Hidayat (ariya@kde.org) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +#ifndef PICTUREFLOW_H +#define PICTUREFLOW_H + +#include + +class PictureFlowPrivate; + +/*! + Class PictureFlow implements an image show widget with animation effect + like Apple's CoverFlow (in iTunes and iPod). Images are arranged in form + of slides, one main slide is shown at the center with few slides on + the left and right sides of the center slide. When the next or previous + slide is brought to the front, the whole slides flow to the right or + the right with smooth animation effect; until the new slide is finally + placed at the center. + + */ +class PictureFlow : public QWidget +{ +Q_OBJECT + + Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor) + Q_PROPERTY(QSize slideSize READ slideSize WRITE setSlideSize) + Q_PROPERTY(int slideCount READ slideCount) + Q_PROPERTY(int centerIndex READ centerIndex WRITE setCenterIndex) + +public: + + enum ReflectionEffect + { + NoReflection, + PlainReflection, + BlurredReflection + }; + + enum FlowType + { + CoverFlowLike, + Strip, + StripOverlapped + }; + + /*! + Creates a new PictureFlow widget. + */ + PictureFlow(QWidget* parent = 0, FlowType flowType = CoverFlowLike); + + /*! + Destroys the widget. + */ + ~PictureFlow(); + + /*! + Returns the background color. + */ + QColor backgroundColor() const; + + /*! + Sets the background color. By default it is black. + */ + void setBackgroundColor(const QColor& c); + + /*! + Returns the dimension of each slide (in pixels). + */ + QSize slideSize() const; + + /*! + Sets the dimension of each slide (in pixels). + */ + void setSlideSize(QSize size); + + /*! + Returns the total number of slides. + */ + int slideCount() const; + + /*! + Returns QImage of specified slide. + */ + QImage slide(int index) const; + + /*! + Returns the index of slide currently shown in the middle of the viewport. + */ + int centerIndex() const; + + /*! + Returns the effect applied to the reflection. + */ + ReflectionEffect reflectionEffect() const; + + /*! + Sets the effect applied to the reflection. The default is PlainReflection. + */ + void setReflectionEffect(ReflectionEffect effect); + + +public slots: + + /*! + Adds a new slide. + */ + void addSlide(const QImage& image); + + /*! + Adds a new slide. + */ + void addSlide(const QPixmap& pixmap); + + /*! + Sets an image for specified slide. If the slide already exists, + it will be replaced. + */ + void setSlide(int index, const QImage& image); + + /*! + Sets a pixmap for specified slide. If the slide already exists, + it will be replaced. + */ + void setSlide(int index, const QPixmap& pixmap); + + /*! + Sets slide to be shown in the middle of the viewport. No animation + effect will be produced, unlike using showSlide. + */ + void setCenterIndex(int index); + + /*! + Clears all slides. + */ + void clear(); + + /*! + Shows previous slide using animation effect. + */ + void showPrevious(); + + /*! + Shows next slide using animation effect. + */ + void showNext(); + + /*! + Go to specified slide using animation effect. + */ + void showSlide(int index); + + /*! + Rerender the widget. Normally this function will be automatically invoked + whenever necessary, e.g. during the transition animation. + */ + void render(); + + /*! + Schedules a rendering update. Unlike render(), this function does not cause + immediate rendering. + */ + void triggerRender(); + + void setFlowType(FlowType flowType); + + void setMarkImage(const QImage & mark); + + void markSlide(int index); + + void updateMarks(); + + void unmarkSlide(int index); + + void setMarks(const QVector & marks); + + void setShowMarks(bool enable); + + QVector getMarks(); + + +signals: + void centerIndexChanged(int index); + +protected: + void paintEvent(QPaintEvent *event); + void keyPressEvent(QKeyEvent* event); + void mousePressEvent(QMouseEvent* event); + void resizeEvent(QResizeEvent* event); + +private slots: + void updateAnimation(); + +private: + PictureFlowPrivate* d; + QImage mark; + QVector marks; + int framesSkip; +}; + +#endif // PICTUREFLOW_H + diff --git a/common/qnaturalsorting.cpp b/common/qnaturalsorting.cpp new file mode 100644 index 00000000..0c60d846 --- /dev/null +++ b/common/qnaturalsorting.cpp @@ -0,0 +1,257 @@ +/* This file contains parts of the KDE libraries + Copyright (C) 1999 Ian Zepp (icszepp@islc.net) + Copyright (C) 2006 by Dominic Battre + Copyright (C) 2006 by Martin Pool + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "qnaturalsorting.h" + +//from KDE +/* +int naturalCompare(const QString &_a, const QString &_b, Qt::CaseSensitivity caseSensitivity) +{ + // This method chops the input a and b into pieces of + // digits and non-digits (a1.05 becomes a | 1 | . | 05) + // and compares these pieces of a and b to each other + // (first with first, second with second, ...). + // + // This is based on the natural sort order code code by Martin Pool + // http://sourcefrog.net/projects/natsort/ + // Martin Pool agreed to license this under LGPL or GPL. + + // FIXME: Using toLower() to implement case insensitive comparison is + // sub-optimal, but is needed because we compare strings with + // localeAwareCompare(), which does not know about case sensitivity. + // A task has been filled for this in Qt Task Tracker with ID 205990. + // http://trolltech.com/developer/task-tracker/index_html?method=entry&id=205990 + QString a; + QString b; + if (caseSensitivity == Qt::CaseSensitive) { + a = _a; + b = _b; + } else { + a = _a.toLower(); + b = _b.toLower(); + } + + const QChar* currA = a.unicode(); // iterator over a + const QChar* currB = b.unicode(); // iterator over b + + if (currA == currB) { + return 0; + } + + const QChar* begSeqA = currA; // beginning of a new character sequence of a + const QChar* begSeqB = currB; + + while (!currA->isNull() && !currB->isNull()) { + if (currA->unicode() == QChar::ObjectReplacementCharacter) { + return 1; + } + + if (currB->unicode() == QChar::ObjectReplacementCharacter) { + return -1; + } + + if (currA->unicode() == QChar::ReplacementCharacter) { + return 1; + } + + if (currB->unicode() == QChar::ReplacementCharacter) { + return -1; + } + + // find sequence of characters ending at the first non-character + while (!currA->isNull() && !currA->isDigit() && !currA->isPunct() && !currA->isSpace()) { + ++currA; + } + + while (!currB->isNull() && !currB->isDigit() && !currB->isPunct() && !currB->isSpace()) { + ++currB; + } + + // compare these sequences + const QStringRef& subA(a.midRef(begSeqA - a.unicode(), currA - begSeqA)); + const QStringRef& subB(b.midRef(begSeqB - b.unicode(), currB - begSeqB)); + const int cmp = QStringRef::localeAwareCompare(subA, subB); + if (cmp != 0) { + return cmp < 0 ? -1 : +1; + } + + if (currA->isNull() || currB->isNull()) { + break; + } + + // find sequence of characters ending at the first non-character + while (currA->isPunct() || currA->isSpace() || currB->isPunct() || currB->isSpace()) { + if (*currA != *currB) { + return (*currA < *currB) ? -1 : +1; + } + ++currA; + ++currB; + } + + // now some digits follow... + if ((*currA == '0') || (*currB == '0')) { + // one digit-sequence starts with 0 -> assume we are in a fraction part + // do left aligned comparison (numbers are considered left aligned) + while (1) { + if (!currA->isDigit() && !currB->isDigit()) { + break; + } else if (!currA->isDigit()) { + return +1; + } else if (!currB->isDigit()) { + return -1; + } else if (*currA < *currB) { + return -1; + } else if (*currA > *currB) { + return + 1; + } + ++currA; + ++currB; + } + } else { + // No digit-sequence starts with 0 -> assume we are looking at some integer + // do right aligned comparison. + // + // The longest run of digits wins. That aside, the greatest + // value wins, but we can't know that it will until we've scanned + // both numbers to know that they have the same magnitude. + + bool isFirstRun = true; + int weight = 0; + while (1) { + if (!currA->isDigit() && !currB->isDigit()) { + if (weight != 0) { + return weight; + } + break; + } else if (!currA->isDigit()) { + if (isFirstRun) { + return *currA < *currB ? -1 : +1; + } else { + return -1; + } + } else if (!currB->isDigit()) { + if (isFirstRun) { + return *currA < *currB ? -1 : +1; + } else { + return +1; + } + } else if ((*currA < *currB) && (weight == 0)) { + weight = -1; + } else if ((*currA > *currB) && (weight == 0)) { + weight = + 1; + } + ++currA; + ++currB; + isFirstRun = false; + } + } + + begSeqA = currA; + begSeqB = currB; + } + + if (currA->isNull() && currB->isNull()) { + return 0; + } + + return currA->isNull() ? -1 : + 1; +} + +*/ +static inline QChar getNextChar(const QString &s, int location) +{ + return (location < s.length()) ? s.at(location) : QChar(); +} + +int naturalCompare(const QString &s1, const QString &s2, Qt::CaseSensitivity cs) +{ + for (int l1 = 0, l2 = 0; l1 <= s1.count() && l2 <= s2.count(); ++l1, ++l2) { + // skip spaces, tabs and 0's + QChar c1 = getNextChar(s1, l1); + while (c1.isSpace()) + c1 = getNextChar(s1, ++l1); + QChar c2 = getNextChar(s2, l2); + while (c2.isSpace()) + c2 = getNextChar(s2, ++l2); + + if (c1.isDigit() && c2.isDigit()) { + while (c1.digitValue() == 0) + c1 = getNextChar(s1, ++l1); + while (c2.digitValue() == 0) + c2 = getNextChar(s2, ++l2); + + int lookAheadLocation1 = l1; + int lookAheadLocation2 = l2; + int currentReturnValue = 0; + // find the last digit, setting currentReturnValue as we go if it isn't equal + for ( + QChar lookAhead1 = c1, lookAhead2 = c2; + (lookAheadLocation1 <= s1.length() && lookAheadLocation2 <= s2.length()); + lookAhead1 = getNextChar(s1, ++lookAheadLocation1), + lookAhead2 = getNextChar(s2, ++lookAheadLocation2) + ) { + bool is1ADigit = !lookAhead1.isNull() && lookAhead1.isDigit(); + bool is2ADigit = !lookAhead2.isNull() && lookAhead2.isDigit(); + if (!is1ADigit && !is2ADigit) + break; + if (!is1ADigit) + return -1; + if (!is2ADigit) + return 1; + if (currentReturnValue == 0) { + if (lookAhead1 < lookAhead2) { + currentReturnValue = -1; + } else if (lookAhead1 > lookAhead2) { + currentReturnValue = 1; + } + } + } + if (currentReturnValue != 0) + return currentReturnValue; + } + + if (cs == Qt::CaseInsensitive) { + if (!c1.isLower()) c1 = c1.toLower(); + if (!c2.isLower()) c2 = c2.toLower(); + } + int r = QString::localeAwareCompare(c1, c2); + if (r < 0) + return -1; + if (r > 0) + return 1; + } + // The two strings are the same (02 == 2) so fall back to the normal sort + return QString::compare(s1, s2, cs); +} +bool naturalSortLessThanCS( const QString &left, const QString &right ) +{ + return (naturalCompare( left, right, Qt::CaseSensitive ) < 0); +} + +bool naturalSortLessThanCI( const QString &left, const QString &right ) +{ + return (naturalCompare( left, right, Qt::CaseInsensitive ) < 0); +} + +bool naturalSortLessThanCIFileInfo(const QFileInfo & left,const QFileInfo & right) +{ + return naturalSortLessThanCI(left.fileName(),right.fileName()); +} diff --git a/common/qnaturalsorting.h b/common/qnaturalsorting.h new file mode 100644 index 00000000..d1eb0163 --- /dev/null +++ b/common/qnaturalsorting.h @@ -0,0 +1,13 @@ + + +#ifndef __QNATURALSORTING_H +#define __QNATURALSORTING_H + +#include +#include + +bool naturalSortLessThanCS( const QString &left, const QString &right ); +bool naturalSortLessThanCI( const QString &left, const QString &right ); +bool naturalSortLessThanCIFileInfo(const QFileInfo & left,const QFileInfo & right); + +#endif \ No newline at end of file diff --git a/files/about.html b/files/about.html new file mode 100644 index 00000000..83d38825 --- /dev/null +++ b/files/about.html @@ -0,0 +1,29 @@ + + + + +

+YACReader - Yet Another Comic Reader - version 0.4.5
+by Luis Ángel San Martín Rodríguez
+e-mail: luisangelsm@gmail.com
+web site: http://code.google.com/p/yacreader/
+Published under GPL v3 license. +


+

+ +

+If you like YACReader, please, consider to make a donation Donate! +


+

+ +

+Compressed files are loaded using 7zip (Windows version) and p7zip (Linux/MacOS X versions) +

+

+Flow effect uses PictureFlow. +

+

+Icons were desinged by Mattahan. +

+ + \ No newline at end of file diff --git a/files/about_es_ES.html b/files/about_es_ES.html new file mode 100644 index 00000000..fb983a8a --- /dev/null +++ b/files/about_es_ES.html @@ -0,0 +1,30 @@ + + + + +

+
+YACReader - Yet Another Comic Reader - versión 0.4.5
+por Luis Ángel San Martín Rodríguez
+e-mail: luisangelsm@gmail.com
+Página web: http://code.google.com/p/yacreader/
+Publicado bajo licencia GPL v3. +


+

+ +

+Si te gusta YACReader, por favor, considera realizar una donación. ¡Dona! +


+

+ +

+Los archivos comprimidos son cargados mediante 7zip (en Windows) y p7zip (en las versiones Linux/MacOS X) +

+

+Los efectos de animación 'flow' usan PictureFlow. +

+

+Los iconos han sido diseñados por Mattahan. +

+ + \ No newline at end of file diff --git a/files/helpYACReader.html b/files/helpYACReader.html new file mode 100644 index 00000000..1b71eac4 --- /dev/null +++ b/files/helpYACReader.html @@ -0,0 +1,126 @@ + + + + +

Quick start guide

+

Features

+

+ YACReader is a fast and simple comic reader with the following features: +

    +
  • Multiplatform, there are Windows, Linux and MacOS X versions.
  • +
  • cbr, cbz, rar, zip, tar and folders support
  • +
  • jpeg, gif, png, tiff and bmp image support
  • +
  • comic reading using keyboard and mouse
  • +
  • fast open and comic navigation
  • +
  • fullscreen mode
  • +
  • configurable magnifying glass for improved reading, since 0.2.0 version is avaliable in windowed mode
  • +
  • fit width (also adjust to an specific width) and fit height modes.
  • +
  • configurable CoverFlow like effect for "go to page" function.
  • +
  • image rotation for comfortable reading even in tablet PCs
  • +
  • double page reading
  • +
  • Comic bookmarks
  • +
+

+

Functions and sortcuts

+

+ General functions: +

    +
  • Open comic : 'O' key
  • +
  • Open folder : 'Ctrl' + 'O' key
  • +
  • Open next cómic : 'Ctrl' + 'Right'
  • +
  • Open previous comic : 'Ctrl' + 'Left' key
  • +
  • Exit : 'Esc' key
  • +
  • Go to previous page : 'Left' key
  • +
  • Go to next page : 'Right' key
  • +
  • Scroll up : 'Wheel mouse up' or 'Up' key
  • +
  • Scroll down : 'Wheel mouse down' or 'Down' key
  • +
  • Auto Scroll down : 'Space Bar'
  • +
  • Auto Scroll up : 'B' key
  • +
  • Rotate to the left : 'L' key
  • +
  • Rotate to the rigth : 'R' key
  • +
  • Open "Go to" dialog : 'G' key
  • +
  • Change between fit width/height modes : 'A' key
  • +
  • Double page mode : 'D' key
  • +
  • Toggle Full Screen mode : 'F' key or double click
  • +
  • For "Go to flow" mode aproximate mouse cursor to bottom border or press 'S' key (show/hide switch).
  • +
  • Show magnifying glass (only in fullscreen mode) : 'Z' key
  • +
  • Show options : 'C' key
  • +
  • Show/hide tool bar : 'H' key
  • +
  • Show information ("current page/number of pages - current time"): 'I' key
  • +
  • Show bookmarks dialog : 'M' key
  • +
  • Set bookmark: 'Ctrl' + 'M' key
  • +
+

+

+ "Go to flow" functions: +

    +
  • Hide / show : 'S' key.
  • + +
  • Go to current central page on the flow : 'Return' or 'Enter'
  • +
  • Next flow page : 'Right' key or left mouse click on the right area of the flow
  • +
  • Previous flow page : 'Left' key or left mouse click on the left area of the flow
  • +
  • Fast forward : 'Ctrl' + 'Right'
  • +
  • Fast backward : 'Ctrl' + 'Left'
  • +
  • Scroll flow : Wheel mouse
  • +
+

+

+ Magnifying glass functions: +

    +
  • Show/hide : 'Z' key.
  • +
  • Resize : Wheel mouse or '+'/'-' keys.
  • +
  • Resize height : 'Ctrl' + Wheel mouse.
  • +
  • Resize width : 'Alt' + Wheel mouse.
  • +
  • Adjust zoom level : 'Shift' + Wheel mouse or 'Shift' + '+'/'-' keys.
  • +
+

+

+ Configuration dialog +