diff -Nru dde-calendar-5.7.0.4/assets/dde-calendar.desktop dde-calendar-5.7.0.23/assets/dde-calendar.desktop --- dde-calendar-5.7.0.4/assets/dde-calendar.desktop 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/assets/dde-calendar.desktop 2020-11-03 09:03:22.000000000 +0000 @@ -10,6 +10,7 @@ Type=Application X-Deepin-Vendor=deepin X-MultipleArgs=false +X-Deepin-TurboType=dtkwidget # Translations: # Do not manually modify! @@ -18,92 +19,118 @@ Comment[ast]=Calendariu ye una ferramienta de dates. Comment[az]=Kalendar tarix alətidir Comment[bg]=Календарът е приложение за показване на датата. -Comment[bn]=কেলেণ্ডার একটি সময় টুল +Comment[bn]=ক্যালেন্ডার একটি তারিখ টুল +Comment[bo]=ལོ་ཐོ་ནི་ཚེས་གྲངས་ལྟ་བའི་ཡོ་བྱད་ཆུང་ཆུང་ཞིག་རེད། Comment[ca]=El calendari és una eina de cites. Comment[cs]=Kalendář je nástroj pro práci s daty. Comment[da]=Kalender er et datoværktøj. Comment[de]=Kalender ist ein Datumswerkzeug. Comment[el]=Εφαρμογή Ημερολογίου +Comment[en_AU]=Calendar is a date tool. Comment[en_GB]=Calendar is a date tool Comment[eo]=Kalendaro estas datilo. -Comment[es]=Calendario es una herramienta de gestión de fechas. -Comment[es_419]=Calendario es un almanaque. +Comment[es]=Calendario de Deepin es una herramienta de gestión de eventos. +Comment[et]=Kalender on kuupäeva tööriist. Comment[fa]=تقویم یک ابزار تاریخ است. -Comment[fi]=Kalenteri on päivämäärätyökalu. +Comment[fi]=Kalenteri on ajankäytön apuohjelma. Comment[fr]=Simple calendrier. Comment[gl_ES]=O calendario é unha ferramenta de datas. -Comment[hi_IN]=दिनदर्शिका दिनांक हेतु एक साधन है। +Comment[hi_IN]=दिनदर्शिका तिथि हेतु एक साधन है। Comment[hr]=Kalendar je alat za rad sa vremenom. -Comment[hu]=Naptár alkalmazás -Comment[id]=Kalender adalah sebuah peralatan tanggal. -Comment[it]=Calendar è un tool calendario. Localizzazione italiana a cura di Carofano Massimo Antonio. +Comment[hu]=A Naptár egy dátum megjelenítő eszköz. +Comment[id]=Kalender adalah sebuah peralatan penanggalan. +Comment[it]=Calendario è un tool calendario. Localizzazione italiana a cura di Carofano Massimo Antonio. Comment[ja]=カレンダーは日時ツールです。 Comment[kn_IN]=ಕ್ಯಾಲೆಂಡರ್ ಒಂದು ದಿನದರ್ಶಕವಾಗಿದೆ. -Comment[ko]=Calendar는 일정 관리도구입니다. +Comment[ko]=달력은 날짜 도구입니다. +Comment[ku]=Salname navgîneke tarîxê ye. Comment[ku_IQ]=ساڵنامە ئامرازێکی بەروارە Comment[lt]=Kalendorius yra datų įrankis. +Comment[lv]=Kalendārs ir datumu rīks. Comment[ml]=കലണ്ടർ ഒരു തീയതി ഉപകരണം ആണ് +Comment[mn]=Хуанли нь огноо, цагалбарын хэрэгсэл. Comment[ms]=Kalendar merupakan alat tarikh. Comment[nb]=Kalander er et redskap for å organisere hendelser etter dato og klokkeslett. Comment[ne]=क्यालेन्डर एक मिति उपकरण हो। Comment[nl]=Kalender is een hulpmiddel voor het bijhouden van afspraken. +Comment[pa]=ਕੈਲੰਡਰ ਤਾਰੀਖ ਸਾਧਨ ਹੈ। Comment[pl]=Kalendarz to narzędzie zarządzania czasem. -Comment[pt]=O Calendário é uma ferramenta de agendamento. -Comment[pt_BR]=Calendário é uma ferramenta de data. +Comment[pt]=O Calendário é uma ferramenta de data. +Comment[pt_BR]=O Calendário é uma ferramenta que permite agendar e visualizar eventos. Comment[ro]=Calendarul este un instrument pentru date Comment[ru]=Календарь является приложением для планирования Вашего времени. +Comment[si]=දින දසුන දින මෙවලමකි. Comment[sk]=Kalendár je dátumový nástroj. Comment[sl]=Koledar je orodje za urejanje datumov. +Comment[sq]=Kalendari është një mjet datash. Comment[sr]=Календар је алат за приказивање датума. Comment[sv]=Kalender är ett datumverktyg. +Comment[sw]=Kalenda ni chombo ya tarehe Comment[ta]=அட்டவணை தேதி கருவியாகும் Comment[tr]=Takvim, tarihi görüntüleyen bir araçtır. Comment[ug]=كالىندار ئۇ ۋاقىت قۇرالى Comment[uk]=Календар Comment[vi]=Lịch là một công cụ ngày tháng. -Comment[zh_CN]=日历是一款查看日期、管理日程的工具。 +Comment[zh_CN]=日历是一款查看日期的小工具。 +Comment[zh_HK]=日曆是一款查看日期的小工具。 Comment[zh_TW]=簡易日期顯示工具 GenericName[am_ET]=ቀን መቁጠሪያ GenericName[ar]=التقويم GenericName[ast]=Calendariu GenericName[az]=Kalendar GenericName[bg]=Календар +GenericName[bn]=ক্যালেন্ডার +GenericName[bo]=ལོ་ཐོ། GenericName[ca]=Calendari GenericName[cs]=Kalendář GenericName[da]=Kalender GenericName[de]=Kalender GenericName[el]=Ημερολόγιο +GenericName[en_AU]=Calendar +GenericName[en_GB]=Calendar GenericName[eo]=Kalendaro GenericName[es]=Calendario -GenericName[es_419]=Calendario +GenericName[et]=Kalender +GenericName[fa]=تقویم +GenericName[fi]=Kalenteri GenericName[fr]=Calendrier GenericName[gl_ES]=Calendario +GenericName[hi_IN]=दिनदर्शिका GenericName[hr]=Kalendar GenericName[hu]=Naptár GenericName[id]=Kalender -GenericName[it]=Calendar +GenericName[it]=Calendario GenericName[ja]=カレンダー GenericName[ko]=달력 +GenericName[ku]=Salname GenericName[ku_IQ]=Salname GenericName[lt]=Kalendorius +GenericName[lv]=Kalendārs GenericName[ml]=കലണ്ടർ -GenericName[mn]=Календар +GenericName[mn]=Хуанли GenericName[ms]=Kalendar +GenericName[nb]=Kalender GenericName[ne]=क्यालेन्डर GenericName[nl]=Kalender +GenericName[pa]=ਕੈਲੰਡਰ GenericName[pl]=Kalendarz GenericName[pt]=Calendário GenericName[pt_BR]=Calendário GenericName[ro]=Calendar GenericName[ru]=Календарь +GenericName[si]=දින දසුන GenericName[sk]=Kalendár GenericName[sl]=Koledar +GenericName[sq]=Kalendar GenericName[sr]=Календар GenericName[sv]=Kalender +GenericName[sw]=Kalenda GenericName[tr]=Takvim +GenericName[ug]=كالىندار GenericName[uk]=Календар GenericName[vi]=Lịch GenericName[zh_CN]=日历 +GenericName[zh_HK]=日曆 GenericName[zh_TW]=日曆 Name[am_ET]=ዲፕኢን ቀን መቁጠሪያ Name[ar]=تقويم ديبين @@ -111,48 +138,58 @@ Name[az]=Deepin Kalendarı Name[bg]=Deepin Календар Name[bn]=ডিপিন ক্যালেন্ডার +Name[bo]=གྲ་རྒྱས་པའི་ལོ་ཐོ། Name[ca]=Calendari del Deepin Name[cs]=Kalendář Name[da]=Deepin kalender Name[de]=Deepin Kalender Name[el]=Ημερολόγιο Deepin +Name[en_AU]=Deepin Calendar Name[en_GB]=Deepin Calendar Name[eo]=Deepin kalendaro -Name[es]=Calendario Deepin -Name[es_419]=Calendario Deepin +Name[es]=Calendario +Name[et]=Deepin Kalender Name[fa]=تقویم Deepin -Name[fi]=Deepin-kalenteri -Name[fr]=Deepin Calendrier +Name[fi]=Deepin kalenteri +Name[fr]=Calendrier Deepin Name[gl_ES]=Calendario do Deepin Name[hi_IN]=डीपिन दिनदर्शिका Name[hr]=Deepin kalendar Name[hu]=Deepin Naptár Name[id]=Kalender Deepin -Name[it]=Deepin Calendar +Name[it]=Calendario di Deepin Name[ja]=Deepin カレンダー Name[kn_IN]=ಡೀಪಿನ್ ಕ್ಯಾಲೆಂಡರ್ -Name[ko]=Deepin Calendar +Name[ko]=Deepin 달력 +Name[ku]=Salnameya Deepin Name[ku_IQ]=ساڵنامەی Deepin Name[lt]=Deepin kalendorius +Name[lv]=Deepin kalendārs Name[ml]=ഡീപിൻ കലണ്ടർ +Name[mn]=Деепин Хуанли Name[ms]=Kalendar Deepin Name[nb]=Deepin Kalender Name[ne]=डिपिन क्यालेन्डर Name[nl]=Deepin Kalender +Name[pa]=ਡੀਪਿਨ ਕੈਲੰਡਰ Name[pl]=Kalendarz Deepin -Name[pt]=Deepin Calendar -Name[pt_BR]=Calendário +Name[pt]=Calendário Deepin +Name[pt_BR]=deepin Calendário Name[ro]=Calendarul Deepin Name[ru]=Календарь Deepin +Name[si]=Deepin දින දසුන Name[sk]=Deepin Kalendár Name[sl]=Koledar Deepin +Name[sq]=Kalendar Deepin Name[sr]=Дипин Календар Name[sv]=Deepin kalender +Name[sw]=Kalenda ya Deepin Name[ta]=டீபின் நாள்காட்டி Name[tr]=Deepin Takvim Name[ug]=Deepin كالىندارى Name[uk]=Календар Deepin Name[vi]=Lịch Deepin -Name[zh_CN]=日历 +Name[zh_CN]=深度日历 +Name[zh_HK]=深度日曆 Name[zh_TW]=Deepin 日曆 diff -Nru dde-calendar-5.7.0.4/CMakeLists.txt dde-calendar-5.7.0.23/CMakeLists.txt --- dde-calendar-5.7.0.4/CMakeLists.txt 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/CMakeLists.txt 2020-11-03 09:03:22.000000000 +0000 @@ -18,10 +18,14 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") +set(CMAKE_CXX_FLAGS "-Wl,--as-needed -fPIE") +set(CMAKE_EXE_LINKER_FLAGS "-pie") + if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "sw_64") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mieee") +elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "mips64") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -ftree-vectorize -march=loongson3a -mhard-float -mno-micromips -mno-mips16 -flax-vector-conversions -mloongson-ext2 -mloongson-mmi -Wl,--as-needed") endif () #compile flags @@ -107,3 +111,4 @@ install(FILES ${APP_QM_FILES} DESTINATION share/dde-calendar/translations) install(FILES ${APP_DESKTOP} DESTINATION share/applications) install(FILES ${APP_SERVICE} DESTINATION share/dbus-1/services) +add_subdirectory(schedule-plugin) diff -Nru dde-calendar-5.7.0.4/CMakeLists.txt.user dde-calendar-5.7.0.23/CMakeLists.txt.user --- dde-calendar-5.7.0.4/CMakeLists.txt.user 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/CMakeLists.txt.user 1970-01-01 00:00:00.000000000 +0000 @@ -1,375 +0,0 @@ - - - - - - EnvironmentId - {007bf241-48ca-47e0-a8f7-51fca421f6ce} - - - ProjectExplorer.Project.ActiveTarget - 0 - - - ProjectExplorer.Project.EditorSettings - - true - false - true - - Cpp - - CppGlobal - - - - QmlJS - - QmlJSGlobal - - - 2 - UTF-8 - false - 4 - false - 80 - true - true - 1 - true - false - 0 - true - true - 0 - 8 - true - 1 - true - true - true - false - - - - ProjectExplorer.Project.PluginSettings - - - true - - - - ProjectExplorer.Project.Target.0 - - cmake - cmake - {09e64d91-b4ea-4e80-b920-864834365e6e} - 0 - 0 - 0 - - - /home/uniontech/workspace/GitSrc/build-calendar-cmake-Default - - - - - all - - true - CMake Build - - CMakeProjectManager.MakeStep - - 1 - Build - - ProjectExplorer.BuildSteps.Build - - - - - - all - - true - CMake Build - - CMakeProjectManager.MakeStep - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Default - Default - CMakeProjectManager.CMakeBuildConfiguration - - - - CMAKE_BUILD_TYPE:STRING=Debug - - /home/uniontech/workspace/GitSrc/build-calendar-cmake-Debug - - - - - all - - true - CMake Build - - CMakeProjectManager.MakeStep - - 1 - Build - - ProjectExplorer.BuildSteps.Build - - - - - - all - - true - CMake Build - - CMakeProjectManager.MakeStep - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Debug - Debug - CMakeProjectManager.CMakeBuildConfiguration - - - - CMAKE_BUILD_TYPE:STRING=Release - - /home/uniontech/workspace/GitSrc/build-calendar-cmake-Release - - - - - all - - true - CMake Build - - CMakeProjectManager.MakeStep - - 1 - Build - - ProjectExplorer.BuildSteps.Build - - - - - - all - - true - CMake Build - - CMakeProjectManager.MakeStep - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Release - Release - CMakeProjectManager.CMakeBuildConfiguration - - - - CMAKE_BUILD_TYPE:STRING=RelWithDebInfo - - /home/uniontech/workspace/GitSrc/build-calendar-cmake-Release with Debug Information - - - - - all - - true - CMake Build - - CMakeProjectManager.MakeStep - - 1 - Build - - ProjectExplorer.BuildSteps.Build - - - - - - all - - true - CMake Build - - CMakeProjectManager.MakeStep - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Release with Debug Information - Release with Debug Information - CMakeProjectManager.CMakeBuildConfiguration - - - - CMAKE_BUILD_TYPE:STRING=MinSizeRel - - /home/uniontech/workspace/GitSrc/build-calendar-cmake-Minimum Size Release - - - - - all - - true - CMake Build - - CMakeProjectManager.MakeStep - - 1 - Build - - ProjectExplorer.BuildSteps.Build - - - - - - all - - true - CMake Build - - CMakeProjectManager.MakeStep - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Minimum Size Release - Minimum Size Release - CMakeProjectManager.CMakeBuildConfiguration - - 5 - - - 0 - 部署 - - ProjectExplorer.BuildSteps.Deploy - - 1 - Deploy Configuration - - ProjectExplorer.DefaultDeployConfiguration - - 1 - - - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - dde-calendar - - CMakeProjectManager.CMakeRunConfiguration.dde-calendar -/home/uniontech/workspace/GitSrc/calendar/ - - 3768 - false - true - false - false - true - - /home/uniontech/workspace/GitSrc/build-calendar-cmake-Default - - 1 - - - - ProjectExplorer.Project.TargetCount - 1 - - - ProjectExplorer.Project.Updater.FileVersion - 20 - - - Version - 20 - - diff -Nru dde-calendar-5.7.0.4/debian/changelog dde-calendar-5.7.0.23/debian/changelog --- dde-calendar-5.7.0.4/debian/changelog 2020-12-05 16:18:58.000000000 +0000 +++ dde-calendar-5.7.0.23/debian/changelog 2021-02-28 10:25:11.000000000 +0000 @@ -1,101 +1,11 @@ -dde-calendar (5.7.0.4-1) unstable; urgency=medium +dde-calendar (5.7.0.23-1ubuntu1) hirsute; urgency=medium - [ Clay Stan ] - * New upstream release 5.7.0.4. - + Add Clay Stan to uploaders list. + * Rebuild for hirsute. - [ Arun Kumar Pariyar ] - * debian/control: - + Add Arun Kumar Pariyar to Uploaders. - + Bump Standards-Version to 4.5.1. - + Bump debhelper compat to v13. - + Update Build-Depends and tighten version for libdtkwidget-dev - to (>=5.2~) and libdframeworkdbus-dev to (>=5.2.0~). - * debian/rules: Ensure proper build and drop LDFLAGS. - * debian/patches: - + Add 0001-fix-qt5-14-incompatibility-issue patch file. - + Add 0002-fix-desktop-entry-lacks-keywords-entry patch file. - * debian/upstream: Set upstream metadata fields. - * debian/copyright: Update copyright information. + -- Arun Kumar Pariyar Sun, 28 Feb 2021 16:10:11 +0545 - -- Arun Kumar Pariyar Sat, 05 Dec 2020 22:03:58 +0545 +dde-calendar (5.7.0.23-1) groovy; urgency=medium -dde-calendar (5.0.1-1) unstable; urgency=medium + * New upstream 5.7.0.23. - * Team upload. - * New upstream release 5.0.1. - * debian/control: - + Switch buildsystem from qmake to cmake (>= 3.7). - - -- Boyuan Yang Sat, 07 Dec 2019 14:49:00 -0500 - -dde-calendar (1.2.6-1) unstable; urgency=high - - * Team upload. - * New upstream version 1.2.6. - * Rebuild for Debian Buster. - + Fix crashing when starting up the program. - * debian/control: - + Bump debhelper compat to v12. - + Bump Standards-Version to 4.3.0. - + R³: Use Rules-Requires-Root: no. - - -- Boyuan Yang Mon, 07 Jan 2019 09:26:38 -0500 - -dde-calendar (1.2.5-1) unstable; urgency=medium - - * New upstream version 1.2.5 - * Bump Standards-Version to 4.2.0 (no changes needed). - - -- Yanhao Mo Thu, 09 Aug 2018 10:06:58 +0800 - -dde-calendar (1.2.4-1) unstable; urgency=medium - - * New upstream version 1.2.4 - * Bump Standards-Version to 4.1.5 (no changes needed). - - -- Yanhao Mo Wed, 01 Aug 2018 09:52:35 +0800 - -dde-calendar (1.2.3-1) unstable; urgency=medium - - * New upstream release. - * d/control: Use pkg-deepin-devel@lists.alioth.debian.org in maintainer - field. - * d/patches: Drop patches, applied by upstream. - - -- Yanhao Mo Sat, 26 May 2018 10:56:44 +0800 - -dde-calendar (1.2.2-2) unstable; urgency=medium - - * Team upload. - * Backport upstream patch to fix date refreshing issue. - * Use team+pkg-deepin@tracker.debian.org in maintainer field. - * Bump Standards-Version to 4.1.4 (no changes needed). - * d/rules: Use "dh-missing --fail-missing". - * d/copyright: Fix typos. - - -- Boyuan Yang <073plan@gmail.com> Fri, 20 Apr 2018 17:04:32 +0800 - -dde-calendar (1.2.2-1) unstable; urgency=medium - - * New release. - * Some Bug Fixes - * d/rules: use /usr/share/dpkg/pkg-info.mk instead of dpkg-parsechangelog. - * d/control: Use Salsa platform for Vcs field. - * debian/control: Update Standers-Version to 4.1.3. - * debian/compat: Switch compat to level 11. - - -- Yanhao Mo Fri, 30 Mar 2018 10:57:34 +0800 - -dde-calendar (1.1.1-2) unstable; urgency=medium - - * Team upload. - * Set build architecture as linux-any. - - -- Boyuan Yang <073plan@gmail.com> Tue, 12 Dec 2017 09:56:27 +0800 - -dde-calendar (1.1.1-1) unstable; urgency=medium - - * Initial release (Closes: #871981) - - -- Yangfl Thu, 07 Dec 2017 15:19:48 +0800 + -- Arun Kumar Pariyar Tue, 12 Jan 2021 17:16:00 +0545 diff -Nru dde-calendar-5.7.0.4/debian/compat dde-calendar-5.7.0.23/debian/compat --- dde-calendar-5.7.0.4/debian/compat 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/debian/compat 2021-01-12 11:28:49.000000000 +0000 @@ -0,0 +1 @@ +9 diff -Nru dde-calendar-5.7.0.4/debian/control dde-calendar-5.7.0.23/debian/control --- dde-calendar-5.7.0.4/debian/control 2020-12-05 16:18:58.000000000 +0000 +++ dde-calendar-5.7.0.23/debian/control 2021-01-12 11:28:49.000000000 +0000 @@ -1,38 +1,27 @@ Source: dde-calendar Section: utils Priority: optional -Maintainer: Debian Deepin Packaging Team -Uploaders: - Yangfl , - Yanhao Mo , - Arun Kumar Pariyar , - Clay Stan , +Maintainer: Deepin Packages Builder Build-Depends: - cmake (>= 3.7), - debhelper-compat (= 13), - deepin-gettext-tools, - libdframeworkdbus-dev (>=5.2.0~), - libdtkgui-dev, - libdtkwidget-dev (>=5.2~), - libqt5svg5-dev, + debhelper (>=9), + cmake, pkg-config, qtbase5-dev, + libdtkgui-dev, + libdtkwidget-dev, qttools5-dev-tools, -Rules-Requires-Root: no -Standards-Version: 4.5.1 -Homepage: https://github.com/linuxdeepin/dde-calendar -Vcs-Git: https://salsa.debian.org/pkg-deepin-team/dde-calendar.git -Vcs-Browser: https://salsa.debian.org/pkg-deepin-team/dde-calendar + deepin-gettext-tools, + libdframeworkdbus-dev +Standards-Version: 3.9.6 +Homepage: http://www.deepin.org +Vcs-Git: https://github.com/linuxdeepin/dde-calendar Package: dde-calendar -Architecture: linux-any +Architecture: any Depends: - ${misc:Depends}, ${shlibs:Depends}, -Recommends: - dde-api, -Description: Deepin Calendar - Deepin Calendar is an easy calendar tool developed by Deepin Technology, main - features current date, solar terms, lunar calendar and world holidays. - . - This package is part of DDE (Deepin Desktop Environment). + ${misc:Depends}, + dde-api +Description: Calendar is a smart daily planner to schedule all things in life. + Calendar is a small management tool for personal life that combines time + and events and integrates the function of memorizing and scheduling. diff -Nru dde-calendar-5.7.0.4/debian/copyright dde-calendar-5.7.0.23/debian/copyright --- dde-calendar-5.7.0.4/debian/copyright 2020-12-05 16:18:58.000000000 +0000 +++ dde-calendar-5.7.0.23/debian/copyright 2021-01-12 11:28:49.000000000 +0000 @@ -1,25 +1,13 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: dde-calendar Source: https://github.com/linuxdeepin/dde-calendar -Upstream-Contact: https://github.com/linuxdeepin/dde-calendar/issues Files: * -Copyright: 2015-2018 Deepin Technology Co., Ltd. - 2019-2020 Uniontech Software Technology Co.,Ltd. +Copyright: Deepin Technology Co., Ltd. License: GPL-3+ - -Files: debian/* -Copyright: 2016-2017 Deepin Technology Co., Ltd. - 2017 Yangfl - 2019 Boyuan Yang - 2020 Arun Kumar Pariyar - 2020 Clay Stan -License: GPL-3+ - -License: GPL-3+ - This program is free software: you can redistribute it and/or modify + This package 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 + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. . This package is distributed in the hope that it will be useful, @@ -28,7 +16,7 @@ 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 . + along with this program. If not, see . On Debian systems, the complete text of the GNU General Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". diff -Nru dde-calendar-5.7.0.4/debian/dde-calendar.1 dde-calendar-5.7.0.23/debian/dde-calendar.1 --- dde-calendar-5.7.0.4/debian/dde-calendar.1 2020-12-05 16:18:58.000000000 +0000 +++ dde-calendar-5.7.0.23/debian/dde-calendar.1 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -.TH "dde-calendar" "1" "2017-12-07" "Deepin" - -.SH NAME -dde\-calendar \- Deepin's voice recorder - -.SH SYNOPSIS -.B dde\-calendar - -.SH DESCRIPTION -.B dde\-calendar -is an easy calendar tool developed by Deepin Technology, main features current date, solar terms, lunar calendar and world holidays. - -.SH OPTIONS -.PP -This program does not accept any command line options. - -.SH SEE ALSO -https://www.deepin.org/en/original/dde-calendar/ - -.SH AUTHOR -.PP -.B dde\-calendar -is written by Deepin Technology Co., Ltd. -.PP -This manual page was written by -.MT mmyangfl@\:gmail.com -Yangfl -.ME -for the Debian Project (but may be used by others). diff -Nru dde-calendar-5.7.0.4/debian/docs dde-calendar-5.7.0.23/debian/docs --- dde-calendar-5.7.0.4/debian/docs 2020-12-05 16:18:58.000000000 +0000 +++ dde-calendar-5.7.0.23/debian/docs 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -README.md diff -Nru dde-calendar-5.7.0.4/debian/manpages dde-calendar-5.7.0.23/debian/manpages --- dde-calendar-5.7.0.4/debian/manpages 2020-12-05 16:18:58.000000000 +0000 +++ dde-calendar-5.7.0.23/debian/manpages 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -debian/dde-calendar.1 diff -Nru dde-calendar-5.7.0.4/debian/patches/0001-fix-qt5-14-incompatibility-issue.patch dde-calendar-5.7.0.23/debian/patches/0001-fix-qt5-14-incompatibility-issue.patch --- dde-calendar-5.7.0.4/debian/patches/0001-fix-qt5-14-incompatibility-issue.patch 2020-12-05 16:18:58.000000000 +0000 +++ dde-calendar-5.7.0.23/debian/patches/0001-fix-qt5-14-incompatibility-issue.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,97 +0,0 @@ -From: Arun Kumar Pariyar -Date: Tue, 14 Jul 2020 16:46:49 +0545 -Subject: [PATCH] fix qt5-14 incompatibility issue - ---- - src/customframe.cpp | 1 + - src/daymonthview.cpp | 2 ++ - src/draginfographicsview.cpp | 1 + - src/schcedulesearchview.cpp | 2 ++ - src/weekheadview.cpp | 1 + - src/yearwindow.cpp | 1 + - 6 files changed, 8 insertions(+) - -diff --git a/src/customframe.cpp b/src/customframe.cpp -index cb33581..dcfe2ea 100644 ---- a/src/customframe.cpp -+++ b/src/customframe.cpp -@@ -20,6 +20,7 @@ - */ - #include "customframe.h" - #include -+#include - #include - #include - DGUI_USE_NAMESPACE -diff --git a/src/daymonthview.cpp b/src/daymonthview.cpp -index f80a1f5..a268526 100644 ---- a/src/daymonthview.cpp -+++ b/src/daymonthview.cpp -@@ -22,11 +22,13 @@ - #include - #include - #include -+#include - #include - #include - #include - #include - #include -+#include - #include "daymonthview.h" - #include - #include "constants.h" -diff --git a/src/draginfographicsview.cpp b/src/draginfographicsview.cpp -index 8648f4f..c9591b5 100644 ---- a/src/draginfographicsview.cpp -+++ b/src/draginfographicsview.cpp -@@ -25,6 +25,7 @@ - #include - #include - #include -+#include - - #include "schceduledlg.h" - #include "schcedulectrldlg.h" -diff --git a/src/schcedulesearchview.cpp b/src/schcedulesearchview.cpp -index c090ed5..748515f 100755 ---- a/src/schcedulesearchview.cpp -+++ b/src/schcedulesearchview.cpp -@@ -22,8 +22,10 @@ - #include - #include - #include -+#include - #include - #include -+#include - #include - #include "schceduledlg.h" - #include "scheduledatamanage.h" -diff --git a/src/weekheadview.cpp b/src/weekheadview.cpp -index 64964fb..7606a87 100755 ---- a/src/weekheadview.cpp -+++ b/src/weekheadview.cpp -@@ -22,6 +22,7 @@ - - #include - #include -+#include - #include - #include - #include -diff --git a/src/yearwindow.cpp b/src/yearwindow.cpp -index d2faf29..eccb8c0 100644 ---- a/src/yearwindow.cpp -+++ b/src/yearwindow.cpp -@@ -24,6 +24,7 @@ - #include - #include - #include -+#include - #include "schcedulesearchview.h" - DGUI_USE_NAMESPACE - CYearWindow::CYearWindow(QWidget *parent): QMainWindow (parent) --- -2.25.1 - diff -Nru dde-calendar-5.7.0.4/debian/patches/0002-fix-desktop-entry-lacks-keywords-entry.patch dde-calendar-5.7.0.23/debian/patches/0002-fix-desktop-entry-lacks-keywords-entry.patch --- dde-calendar-5.7.0.4/debian/patches/0002-fix-desktop-entry-lacks-keywords-entry.patch 2020-12-05 16:18:58.000000000 +0000 +++ dde-calendar-5.7.0.23/debian/patches/0002-fix-desktop-entry-lacks-keywords-entry.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -From: Arun Kumar Pariyar -Date: Sat, 5 Dec 2020 22:42:33 +0545 -Subject: [PATCH] fix desktop-entry-lacks-keywords-entry - ---- - assets/dde-calendar.desktop | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/assets/dde-calendar.desktop b/assets/dde-calendar.desktop -index 4936d17..dc17813 100644 ---- a/assets/dde-calendar.desktop -+++ b/assets/dde-calendar.desktop -@@ -1,5 +1,6 @@ - [Desktop Entry] - Categories=Application;Utility;Calendar; -+Keywords=calendar;date;deepin;dde; - Comment=Calendar is a date tool. - Exec=dde-calendar - GenericName=Calendar --- -2.27.0 - diff -Nru dde-calendar-5.7.0.4/debian/patches/fix-qt5-15-compatibility.patch dde-calendar-5.7.0.23/debian/patches/fix-qt5-15-compatibility.patch --- dde-calendar-5.7.0.4/debian/patches/fix-qt5-15-compatibility.patch 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/debian/patches/fix-qt5-15-compatibility.patch 2021-01-12 11:43:33.000000000 +0000 @@ -0,0 +1,115 @@ +Description: + TODO: Put a short summary on the line above and replace this paragraph + with a longer explanation of this change. Complete the meta-information + with other relevant fields (see below for details). To make it easier, the + information below has been extracted from the changelog. Adjust it or drop + it. + . + dde-calendar (5.7.0.23-1) groovy; urgency=medium + . + * New upstream 5.7.0.23. +Author: Arun Kumar Pariyar + +--- +The information above should follow the Patch Tagging Guidelines, please +checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here +are templates for supplementary fields that you might want to add: + +Origin: , +Bug: +Bug-Debian: https://bugs.debian.org/ +Bug-Ubuntu: https://launchpad.net/bugs/ +Forwarded: +Reviewed-By: +Last-Update: 2021-01-12 + +--- dde-calendar-5.7.0.23.orig/schedule-plugin/src/widget/itemwidget.h ++++ dde-calendar-5.7.0.23/schedule-plugin/src/widget/itemwidget.h +@@ -25,6 +25,8 @@ + #include "../data/schedulestructs.h" + + #include ++#include ++#include + #include + #include + #include +--- dde-calendar-5.7.0.23.orig/src/customWidget/customframe.cpp ++++ dde-calendar-5.7.0.23/src/customWidget/customframe.cpp +@@ -24,6 +24,7 @@ + #include + + #include ++#include + #include + + DGUI_USE_NAMESPACE +--- dde-calendar-5.7.0.23.orig/src/view/draginfographicsview.cpp ++++ dde-calendar-5.7.0.23/src/view/draginfographicsview.cpp +@@ -30,6 +30,7 @@ + #include + #include + #include ++#include + + DragInfoGraphicsView::DragInfoGraphicsView(DWidget *parent) + : DGraphicsView(parent) +--- dde-calendar-5.7.0.23.orig/src/widget/dayWidget/daymonthview.cpp ++++ dde-calendar-5.7.0.23/src/widget/dayWidget/daymonthview.cpp +@@ -31,11 +31,13 @@ + #include + #include + #include ++#include + #include + #include + #include + #include + #include ++#include + #include + + DGUI_USE_NAMESPACE +--- dde-calendar-5.7.0.23.orig/src/widget/schcedulesearchview.cpp ++++ dde-calendar-5.7.0.23/src/widget/schcedulesearchview.cpp +@@ -34,8 +34,10 @@ + #include + #include + #include ++#include + #include + #include ++#include + #include + + DGUI_USE_NAMESPACE +--- dde-calendar-5.7.0.23.orig/src/widget/weekWidget/weekheadview.cpp ++++ dde-calendar-5.7.0.23/src/widget/weekWidget/weekheadview.cpp +@@ -27,6 +27,7 @@ + + #include + #include ++#include + #include + #include + #include +--- dde-calendar-5.7.0.23.orig/src/widget/yearWidget/yearview.cpp ++++ dde-calendar-5.7.0.23/src/widget/yearWidget/yearview.cpp +@@ -32,6 +32,7 @@ + #include + #include + #include ++#include + #include + #include + #include +--- dde-calendar-5.7.0.23.orig/src/widget/yearWidget/yearwindow.cpp ++++ dde-calendar-5.7.0.23/src/widget/yearWidget/yearwindow.cpp +@@ -26,6 +26,7 @@ + #include + + #include ++#include + #include + + DGUI_USE_NAMESPACE diff -Nru dde-calendar-5.7.0.4/debian/patches/series dde-calendar-5.7.0.23/debian/patches/series --- dde-calendar-5.7.0.4/debian/patches/series 2020-12-05 16:18:58.000000000 +0000 +++ dde-calendar-5.7.0.23/debian/patches/series 2021-01-12 11:43:33.000000000 +0000 @@ -1,2 +1 @@ -0001-fix-qt5-14-incompatibility-issue.patch -0002-fix-desktop-entry-lacks-keywords-entry.patch +fix-qt5-15-compatibility.patch diff -Nru dde-calendar-5.7.0.4/debian/README.Debian dde-calendar-5.7.0.23/debian/README.Debian --- dde-calendar-5.7.0.4/debian/README.Debian 2020-12-05 16:18:58.000000000 +0000 +++ dde-calendar-5.7.0.23/debian/README.Debian 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ -README.Debian for dde-calendar ------------------------------- - -Note that dde-calendar needs a running dde-api daemon to provide with -lunar calendar information via D-Bus. - - -- Boyuan Yang <073plan@gmail.com> Tue, 12 Dec 2017 09:56:27 +0800 diff -Nru dde-calendar-5.7.0.4/debian/rules dde-calendar-5.7.0.23/debian/rules --- dde-calendar-5.7.0.4/debian/rules 2020-12-05 16:18:58.000000000 +0000 +++ dde-calendar-5.7.0.23/debian/rules 2021-01-12 11:28:49.000000000 +0000 @@ -1,23 +1,24 @@ #!/usr/bin/make -f -# See debhelper(7) (uncomment to enable) -# output every command that modifies files on the build system. -#export DH_VERBOSE = 1 -include /usr/share/dpkg/pkg-info.mk - -# see FEATURE AREAS in dpkg-buildflags(1) -export DEB_BUILD_MAINT_OPTIONS = hardening=+all - -# see ENVIRONMENT in dpkg-buildflags(1) -# package maintainers to append CFLAGS -export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic -export QT_SELECT := 5 +export QT_SELECT=5 +include /usr/share/dpkg/default.mk + +DEB_BUILD_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH) +DH_AUTO_ARGS = --parallel --buildsystem=cmake + +# Uncomment this to turn on verbose mode. +export DH_VERBOSE=1 %: - dh $@ + dh $@ --parallel override_dh_auto_configure: - dh_auto_configure -- VERSION=$(DEB_VERSION_UPSTREAM) LIB_INSTALL_DIR=/usr/lib/$(DEB_HOST_MULTIARCH) DEFINES+="VERSION=$(DEB_VERSION_UPSTREAM)" + dh_auto_configure -- \ + -DCMAKE_BUILD_TYPE=Release \ + -DAPP_VERSION=$(DEB_VERSION_UPSTREAM) -DVERSION=$(DEB_VERSION_UPSTREAM) LIB_INSTALL_DIR=/usr/lib/$(DEB_HOST_MULTIARCH) + +#Ignore the dpkg-shlibdeps: warning (it uses none of the library's symbols) +#Qt Mutidedia lib will ref to network libraray. +override_dh_shlibdeps: + dh_shlibdeps --dpkg-shlibdeps-params=--warnings=0 -override_dh_missing: - dh_missing --fail-missing diff -Nru dde-calendar-5.7.0.4/debian/upstream/metadata dde-calendar-5.7.0.23/debian/upstream/metadata --- dde-calendar-5.7.0.4/debian/upstream/metadata 2020-12-05 16:18:58.000000000 +0000 +++ dde-calendar-5.7.0.23/debian/upstream/metadata 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ ---- -Bug-Database: https://github.com/linuxdeepin/dde-calendar/issues -Bug-Submit: https://github.com/linuxdeepin/dde-calendar/issues/new -Repository: https://github.com/linuxdeepin/dde-calendar.git -Repository-Browse: https://github.com/linuxdeepin/dde-calendar diff -Nru dde-calendar-5.7.0.4/debian/watch dde-calendar-5.7.0.23/debian/watch --- dde-calendar-5.7.0.4/debian/watch 2020-12-05 16:18:58.000000000 +0000 +++ dde-calendar-5.7.0.23/debian/watch 1970-01-01 00:00:00.000000000 +0000 @@ -1,4 +0,0 @@ -version=4 -opts="filenamemangle=s%(?:.*?)?v?(\d[\d.]*)\.tar\.gz%dde-calendar-$1.tar.gz%" \ - https://github.com/linuxdeepin/dde-calendar/tags \ - (?:.*?/)?(\d[\d.]*)\.tar\.gz debian uupdate diff -Nru dde-calendar-5.7.0.4/.gitignore dde-calendar-5.7.0.23/.gitignore --- dde-calendar-5.7.0.4/.gitignore 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/.gitignore 2020-11-03 09:03:22.000000000 +0000 @@ -37,3 +37,4 @@ debian/files debian/dde-calendar.substvars CMakeLists.txt.user +*.user.* \ No newline at end of file diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/calendar_bg.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/calendar_bg.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/calendar_bg.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/calendar_bg.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day10.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day10.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day10.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day10.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day11.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day11.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day11.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day11.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day12.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day12.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day12.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day12.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day13.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day13.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day13.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day13.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day14.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day14.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day14.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day14.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day15.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day15.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day15.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day15.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day16.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day16.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day16.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day16.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day17.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day17.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day17.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day17.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day18.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day18.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day18.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day18.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day19.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day19.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day19.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day19.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day1.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day1.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day1.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day1.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day20.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day20.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day20.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day20.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day21.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day21.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day21.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day21.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day22.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day22.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day22.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day22.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day23.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day23.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day23.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day23.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day24.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day24.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day24.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day24.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day25.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day25.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day25.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day25.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day26.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day26.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day26.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day26.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day27.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day27.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day27.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day27.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day28.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day28.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day28.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day28.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day29.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day29.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day29.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day29.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day2.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day2.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day2.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day2.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day30.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day30.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day30.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day30.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day31.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day31.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day31.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day31.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day3.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day3.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day3.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day3.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day4.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day4.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day4.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day4.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day5.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day5.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day5.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day5.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day6.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day6.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day6.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day6.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day7.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day7.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day7.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day7.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day8.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day8.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day8.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day8.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day9.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day9.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/day9.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/day9.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/month10.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/month10.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/month10.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/month10.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,3 @@ + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/month11.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/month11.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/month11.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/month11.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,3 @@ + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/month12.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/month12.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/month12.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/month12.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,3 @@ + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/month1.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/month1.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/month1.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/month1.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,3 @@ + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/month2.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/month2.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/month2.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/month2.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,3 @@ + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/month3.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/month3.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/month3.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/month3.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,3 @@ + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/month4.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/month4.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/month4.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/month4.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,3 @@ + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/month5.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/month5.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/month5.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/month5.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,3 @@ + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/month6.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/month6.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/month6.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/month6.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,3 @@ + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/month7.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/month7.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/month7.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/month7.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,3 @@ + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/month8.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/month8.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/month8.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/month8.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,3 @@ + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/month9.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/month9.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/month9.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/month9.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,3 @@ + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/week1.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/week1.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/week1.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/week1.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,3 @@ + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/week2.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/week2.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/week2.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/week2.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,3 @@ + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/week3.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/week3.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/week3.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/week3.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,3 @@ + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/week4.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/week4.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/week4.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/week4.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,3 @@ + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/week5.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/week5.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/week5.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/week5.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,3 @@ + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/week6.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/week6.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/week6.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/week6.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,3 @@ + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/week7.svg dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/week7.svg --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources/DynamicIcon/week7.svg 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources/DynamicIcon/week7.svg 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,3 @@ + + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/assets/resources.qrc dde-calendar-5.7.0.23/schedule-plugin/assets/resources.qrc --- dde-calendar-5.7.0.4/schedule-plugin/assets/resources.qrc 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/assets/resources.qrc 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,55 @@ + + + resources/DynamicIcon/calendar_bg.svg + resources/DynamicIcon/day1.svg + resources/DynamicIcon/day2.svg + resources/DynamicIcon/day3.svg + resources/DynamicIcon/day4.svg + resources/DynamicIcon/day5.svg + resources/DynamicIcon/day6.svg + resources/DynamicIcon/day7.svg + resources/DynamicIcon/day8.svg + resources/DynamicIcon/day9.svg + resources/DynamicIcon/day10.svg + resources/DynamicIcon/day11.svg + resources/DynamicIcon/day12.svg + resources/DynamicIcon/day13.svg + resources/DynamicIcon/day14.svg + resources/DynamicIcon/day15.svg + resources/DynamicIcon/day16.svg + resources/DynamicIcon/day17.svg + resources/DynamicIcon/day18.svg + resources/DynamicIcon/day19.svg + resources/DynamicIcon/day20.svg + resources/DynamicIcon/day21.svg + resources/DynamicIcon/day22.svg + resources/DynamicIcon/day23.svg + resources/DynamicIcon/day24.svg + resources/DynamicIcon/day25.svg + resources/DynamicIcon/day26.svg + resources/DynamicIcon/day27.svg + resources/DynamicIcon/day28.svg + resources/DynamicIcon/day29.svg + resources/DynamicIcon/day30.svg + resources/DynamicIcon/day31.svg + resources/DynamicIcon/month1.svg + resources/DynamicIcon/month2.svg + resources/DynamicIcon/month3.svg + resources/DynamicIcon/month4.svg + resources/DynamicIcon/month5.svg + resources/DynamicIcon/month6.svg + resources/DynamicIcon/month7.svg + resources/DynamicIcon/month8.svg + resources/DynamicIcon/month9.svg + resources/DynamicIcon/month10.svg + resources/DynamicIcon/month11.svg + resources/DynamicIcon/month12.svg + resources/DynamicIcon/week1.svg + resources/DynamicIcon/week2.svg + resources/DynamicIcon/week3.svg + resources/DynamicIcon/week4.svg + resources/DynamicIcon/week5.svg + resources/DynamicIcon/week6.svg + resources/DynamicIcon/week7.svg + + diff -Nru dde-calendar-5.7.0.4/schedule-plugin/CMakeLists.txt dde-calendar-5.7.0.23/schedule-plugin/CMakeLists.txt --- dde-calendar-5.7.0.4/schedule-plugin/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/CMakeLists.txt 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,84 @@ +cmake_minimum_required(VERSION 3.7) + +if (NOT DEFINED VERSION) + set(VERSION 1.2.2) +endif () + +#common resource names +set(APP_RES_DIR "assets") +set(APP_BIN_NAME "uosschedulex-plugin") +set(APP_QRC "${APP_RES_DIR}/resources.qrc") + +project(${APP_BIN_NAME}) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") + +if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "sw_64") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mieee") +endif () +add_definitions("-DSCHEDULEPLUGIN_LIBRARY") +add_definitions("-DQT_DEPRECATED_WARNINGS") +#compile flags +if (CMAKE_BUILD_TYPE MATCHES Debug) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra") + + # Enable Qt builtin debug mode + add_definitions("-DQT_MESSAGELOGCONTEXT") +else() + # -Wl, -O2 Enable linker optimizations + # -Wl, --gc-sections Remove unused code resulting from -fdsta-sections and + # -ffunction-sections + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O2 -Wl,-O1 -Wl,--gc-sections") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O2 -Wl,-O1 -Wl,--gc-sections") +endif() + +macro(SUBDIRLIST result curdir) + file(GLOB children RELATIVE ${curdir} ${curdir}/*) + set(dirlist "") + foreach(child ${children}) + if(IS_DIRECTORY ${curdir}/${child}) + LIST(APPEND dirlist ${child}) + endif() + endforeach() + set(${result} ${dirlist}) +endmacro() + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src) + +SUBDIRLIST(all_src ${CMAKE_CURRENT_SOURCE_DIR}/src) + +#Include all app own subdirectorys +foreach(subdir ${all_src}) + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/${subdir}) +endforeach() + +file(GLOB_RECURSE Schedule_Plugin_SRC ${CMAKE_CURRENT_LIST_DIR}/src/*.cpp) + +find_package(PkgConfig REQUIRED) +find_package(DFrameworkdbus REQUIRED) +find_package(DtkWidget REQUIRED) +find_package(Qt5Svg REQUIRED) +find_package(Qt5DBus REQUIRED) + + +include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS}) + +# Tell CMake to create the lib +add_library(${PROJECT_NAME} SHARED ${Schedule_Plugin_SRC} ${APP_QRC} src/interface/service.h) + +target_include_directories(${PROJECT_NAME} PUBLIC ${DtkWidget_INCLUDE_DIRS} ${OBJECT_BINARY_DIR}) + +target_link_libraries(${PROJECT_NAME} + ${Qt5Svg_LIBRARIES} + ${Qt5DBus_LIBRARIES} + ${DtkWidget_LIBRARIES} + ${DFrameworkdbus_LIBRARIES} +) + +# Install files +install(TARGETS ${PROJECT_NAME} DESTINATION /usr/lib/deepin-aiassistant/serivce-plugins) diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/data/canceljsondata.cpp dde-calendar-5.7.0.23/schedule-plugin/src/data/canceljsondata.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/data/canceljsondata.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/data/canceljsondata.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,32 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "canceljsondata.h" +#include + +#include "../globaldef.h" +cancelJsonData::cancelJsonData() + : JsonData() +{ +} + +cancelJsonData::~cancelJsonData() +{ +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/data/canceljsondata.h dde-calendar-5.7.0.23/schedule-plugin/src/data/canceljsondata.h --- dde-calendar-5.7.0.4/schedule-plugin/src/data/canceljsondata.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/data/canceljsondata.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,32 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef CANCELJSONDATA_H +#define CANCELJSONDATA_H +#include "jsondata.h" + +class cancelJsonData : public JsonData +{ +public: + cancelJsonData(); + ~cancelJsonData() override; +}; + +#endif // CANCELJSONDATA_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/data/changejsondata.cpp dde-calendar-5.7.0.23/schedule-plugin/src/data/changejsondata.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/data/changejsondata.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/data/changejsondata.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,106 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "changejsondata.h" + +#include "../globaldef.h" + +#include + +changejsondata::changejsondata() + : JsonData() +{ +} + +void changejsondata::jsonObjResolve(const QJsonObject &jsobj) +{ + if (jsobj[JSON_NAME] == JSON_FROMDATETIME) { + fromDatetimeJsonResolve(jsobj); + return; + } + if (jsobj[JSON_NAME] == JSON_TODATETIME) { + toDatetimeJsonResolve(jsobj); + return; + } + if (jsobj[JSON_NAME] == JSON_TOPLACE) { + toPlaceJsonResolve(jsobj); + return; + } +} + +void changejsondata::setDefaultValue() +{ + JsonData::setDefaultValue(); + m_fromDateTime.clear(); + m_toDateTime.clear(); + m_toPlaceStr.clear(); +} + +void changejsondata::fromDatetimeJsonResolve(const QJsonObject &jsobj) +{ + setFromDateTime(suggestDatetimeResolve(jsobj)); +} + +void changejsondata::toDatetimeJsonResolve(const QJsonObject &jsobj) +{ + setToDateTime(suggestDatetimeResolve(jsobj)); +} + +void changejsondata::toPlaceJsonResolve(const QJsonObject &jsobj) +{ + setToPlaceStr(jsobj[JSON_VALUE].toString()); +} + +QString changejsondata::toPlaceStr() const +{ + return m_toPlaceStr; +} + +void changejsondata::setToPlaceStr(const QString &toPlaceStr) +{ + m_toPlaceStr = toPlaceStr; +} + +bool changejsondata::isVaild() const +{ + return this->m_toDateTime.suggestDatetime.size() ==0 + && this->m_fromDateTime.suggestDatetime.size()==0 && this->toPlaceStr().isEmpty() + && JsonData::isVaild(); +} + +SemanticsDateTime changejsondata::toDateTime() const +{ + return m_toDateTime; +} + +void changejsondata::setToDateTime(const SemanticsDateTime &toDateTime) +{ + m_toDateTime = toDateTime; +} + +SemanticsDateTime changejsondata::fromDateTime() const +{ + return m_fromDateTime; +} + +void changejsondata::setFromDateTime(const SemanticsDateTime &fromDateTime) +{ + m_fromDateTime = fromDateTime; +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/data/changejsondata.h dde-calendar-5.7.0.23/schedule-plugin/src/data/changejsondata.h --- dde-calendar-5.7.0.4/schedule-plugin/src/data/changejsondata.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/data/changejsondata.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,81 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef CHANGEJSONDATA_H +#define CHANGEJSONDATA_H + +#include "jsondata.h" + +class changejsondata : public JsonData +{ +public: + changejsondata(); + /** + * @brief fromDateTime 获取语义from时间数据 + * @return 时间数据 + */ + SemanticsDateTime fromDateTime() const; + /** + * @brief setFromDateTime 设置语义from时间数据 + * @param fromDateTime 时间数据 + */ + void setFromDateTime(const SemanticsDateTime &fromDateTime); + /** + * @brief toDateTime 获取语义toDateTime时间数据 + * @return 时间数据 + */ + SemanticsDateTime toDateTime() const; + /** + * @brief setToDateTime 设置语义toDateTime时间数据 + * @param toDateTime 时间数据 + */ + void setToDateTime(const SemanticsDateTime &toDateTime); + + QString toPlaceStr() const; + void setToPlaceStr(const QString &toPlaceStr); + /** + * @brief isVaild 判断json是否为原始数据 + * @return true为原始数据 + */ + bool isVaild() const override; + +private: + void jsonObjResolve(const QJsonObject &jsobj) override; + void setDefaultValue() override; + void fromDatetimeJsonResolve(const QJsonObject &jsobj); + void toDatetimeJsonResolve(const QJsonObject &jsobj); + void toPlaceJsonResolve(const QJsonObject &jsobj); + +private: + /** + * @brief m_fromDateTime 需要修改的时间信息 + */ + SemanticsDateTime m_fromDateTime {}; + /** + * @brief m_toDateTime 修改到的时间信息 + */ + SemanticsDateTime m_toDateTime {}; + /** + * @brief m_toPlaceStr 修改的日常内容 + */ + QString m_toPlaceStr {}; +}; + +#endif // CHANGEJSONDATA_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/data/clocaldata.cpp dde-calendar-5.7.0.23/schedule-plugin/src/data/clocaldata.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/data/clocaldata.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/data/clocaldata.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,97 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "clocaldata.h" + +CLocalData::CLocalData() +{ +} + +QVector CLocalData::scheduleInfoVector() const +{ + return m_scheduleInfoVector; +} + +void CLocalData::setScheduleInfoVector(const QVector &scheduleInfoVector) +{ + m_scheduleInfoVector = scheduleInfoVector; +} + +ScheduleDtailInfo CLocalData::SelectInfo() const +{ + return m_SelectInfo; +} + +void CLocalData::setSelectInfo(const ScheduleDtailInfo &SelectInfo) +{ + m_SelectInfo = SelectInfo; +} + +void CLocalData::setToTitleName(const QString &title) +{ + m_ToTitleName = title; +} + +QString CLocalData::getToTitleName() const +{ + return m_ToTitleName; +} + +void CLocalData::setToTime(const QVector &timeInfo) +{ + m_ToTime = timeInfo; +} + +QVector CLocalData::getToTime() const +{ + return m_ToTime; +} + +int CLocalData::getOffet() const +{ + return m_offset; +} + +void CLocalData::setOffset(int offset) +{ + m_offset = offset; +} + +CLocalData *CLocalData::getDataByPoint(const CLocalData *localData) +{ + if (this == localData || localData == nullptr) + return this; + this->m_offset = localData->m_offset; + this->m_SelectInfo = localData->m_SelectInfo; + this->m_ToTime = localData->m_ToTime; + this->m_scheduleInfoVector = localData->m_scheduleInfoVector; + this->m_ToTitleName = localData->m_ToTitleName; + return this; +} + +void CLocalData::setNewInfo(const ScheduleDtailInfo &newInfo) +{ + m_NewInfo = newInfo; +} + +ScheduleDtailInfo CLocalData::getNewInfo() const +{ + return m_NewInfo; +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/data/clocaldata.h dde-calendar-5.7.0.23/schedule-plugin/src/data/clocaldata.h --- dde-calendar-5.7.0.4/schedule-plugin/src/data/clocaldata.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/data/clocaldata.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,53 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef CLOCALDATA_H +#define CLOCALDATA_H + +#include "schedulestructs.h" +#include "timedatastruct.h" +class CLocalData +{ +public: + CLocalData(); + QVector scheduleInfoVector() const; + void setScheduleInfoVector(const QVector &scheduleInfoVector); + ScheduleDtailInfo SelectInfo() const; + void setSelectInfo(const ScheduleDtailInfo &SelectInfo); + void setToTitleName(const QString &title); + QString getToTitleName() const; + void setToTime(const QVector &timeInfo); + QVector getToTime() const; + int getOffet() const; + void setOffset(int offset); + CLocalData *getDataByPoint(const CLocalData *localData); + void setNewInfo(const ScheduleDtailInfo &newInfo); + ScheduleDtailInfo getNewInfo() const; + +private: + QVector m_scheduleInfoVector {}; + ScheduleDtailInfo m_SelectInfo {}; + ScheduleDtailInfo m_NewInfo {}; + QString m_ToTitleName {""}; + QVector m_ToTime {}; + int m_offset {-1}; +}; + +#endif // CLOCALDATA_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/data/createjsondata.cpp dde-calendar-5.7.0.23/schedule-plugin/src/data/createjsondata.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/data/createjsondata.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/data/createjsondata.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,33 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "createjsondata.h" + +#include +#include +#include +#include + +#include "../globaldef.h" + +CreateJsonData::CreateJsonData() + : JsonData() +{ +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/data/createjsondata.h dde-calendar-5.7.0.23/schedule-plugin/src/data/createjsondata.h --- dde-calendar-5.7.0.4/schedule-plugin/src/data/createjsondata.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/data/createjsondata.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,34 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef CREATEJSONDATA_H +#define CREATEJSONDATA_H + +#include "jsondata.h" + +class CreateJsonData : public JsonData +{ +public: + CreateJsonData(); + +private: +}; + +#endif // CREATEJSONDATA_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/data/jsondata.cpp dde-calendar-5.7.0.23/schedule-plugin/src/data/jsondata.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/data/jsondata.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/data/jsondata.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,336 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "jsondata.h" + +#include +#include +#include +#include + +#include "../globaldef.h" + +JsonData::JsonData() +{ +} + +JsonData::~JsonData() +{ +} + +void JsonData::JosnResolve(const QJsonObject &jsObj) +{ + setDefaultValue(); + if (jsObj.contains("slots") && jsObj["slots"].isArray()) { + auto slotsObjArr = jsObj["slots"].toArray(); + for (int j = 0; j < slotsObjArr.size(); ++j) { + auto slotsObj = slotsObjArr[j].toObject(); + if (slotsObj.contains(JSON_NAME) && slotsObj[JSON_NAME].isString()) { + if (slotsObj[JSON_NAME] == JSON_CONTENT) { + contentJsonResolve(slotsObj); + continue; + } + if (slotsObj[JSON_NAME] == JSON_REPEAT) { + repeatJsonResolve(slotsObj); + continue; + } + if (slotsObj[JSON_NAME] == JSON_DATETIME) { + datetimeJsonResolve(slotsObj); + continue; + } + if (slotsObj[JSON_NAME] == JSON_PROPERTY) { + propertyJsonResolve(slotsObj); + continue; + } + if (slotsObj[JSON_NAME] == JSON_POSRANK_OFFSET) { + posRankOffsetResolve(slotsObj); + continue; + } + jsonObjResolve(slotsObj); + } + } + } +} + +QString JsonData::SuggestMsg() const +{ + return m_SuggestMsg; +} + +void JsonData::setSuggestMsg(const QString &SuggestMsg) +{ + m_SuggestMsg = SuggestMsg; +} + +bool JsonData::ShouldEndSession() const +{ + return m_ShouldEndSession; +} + +void JsonData::setShouldEndSession(bool ShouldEndSession) +{ + m_ShouldEndSession = ShouldEndSession; +} + +void JsonData::setRepeatStatus(const JsonData::RepeatStatus &RepeatStatus) +{ + m_RepeatStatus = RepeatStatus; +} + +QString JsonData::TitleName() const +{ + return m_TitleName; +} + +void JsonData::setTitleName(const QString &TitleName) +{ + m_TitleName = TitleName; +} + +void JsonData::setDateTimeStatus(const JsonData::DateTimeStatus &DateTimeStatus) +{ + m_DateTimeStatus = DateTimeStatus; +} + +JsonData::RepeatStatus JsonData::getRepeatStatus() const +{ + return m_RepeatStatus; +} + +QVector JsonData::getRepeatNum() const +{ + return m_RepeatNum; +} + +void JsonData::setRepeatNum(const QVector &RepeatNum) +{ + m_RepeatNum = RepeatNum; +} + +SemanticsDateTime JsonData::getDateTime() const +{ + return m_DateTime; +} + +void JsonData::setDateTime(const SemanticsDateTime &DateTime) +{ + m_DateTime = DateTime; +} + +void JsonData::contentJsonResolve(const QJsonObject &jsobj) +{ + setTitleName(jsobj[JSON_VALUE].toString()); +} + +void JsonData::repeatJsonResolve(const QJsonObject &jsobj) +{ + QString repeatValue = jsobj[JSON_VALUE].toString(); + if (repeatValue.contains("EVERYEAR")) { + setRepeatStatus(EVEY); + return; + } + if (repeatValue.contains("EVERYDAY")) { + setRepeatStatus(EVED); + return; + } + if (repeatValue.contains("WORKDAY")) { + setRepeatStatus(WORKD); + return; + } + if (repeatValue.contains("RESTDAY")) { + setRepeatStatus(RESTD); + return; + } + if (repeatValue.contains("WEEKEND")) { + setRepeatStatus(RESTD); + return; + } + + QRegExp rxlen("([W,M])([0-9]{0,2})"); + int pos = 0; + QVector repeatnum {}; + repeatnum.clear(); + while ((pos = rxlen.indexIn(repeatValue, pos)) != -1) { + if (rxlen.cap(1).contains("M")) { + setRepeatStatus(EVEM); + } + if (rxlen.cap(1).contains("W")) { + setRepeatStatus(EVEW); + } + if (rxlen.cap(0).size() > 0 && rxlen.cap(2) != "") { + repeatnum.append(rxlen.cap(2).toInt()); + } + pos += rxlen.matchedLength(); + } + setRepeatNum(repeatnum); +} + +void JsonData::datetimeJsonResolve(const QJsonObject &jsobj) +{ + setDateTime(suggestDatetimeResolve(jsobj)); +} + +void JsonData::propertyJsonResolve(const QJsonObject &jsobj) +{ + QString propertyValue = jsobj[JSON_VALUE].toString(); + if (propertyValue == JSON_NEXT) { + setPropertyStatus(NEXT); + return; + } + if (propertyValue == JSON_LAST) { + setPropertyStatus(LAST); + return; + } + if (propertyValue == JSON_ALL) { + setPropertyStatus(ALL); + return; + } + if (propertyValue == JSON_THIS) { + setPropertyStatus(PRO_THIS); + return; + } +} + +void JsonData::posRankOffsetResolve(const QJsonObject &jsobj) +{ + setOffset(jsobj[JSON_VALUE].toString().toInt()); +} + +SemanticsDateTime JsonData::suggestDatetimeResolve(const QJsonObject &jsobj) +{ + SemanticsDateTime semdatetime {}; + semdatetime.clear(); + QString DateTimeJson = jsobj[JSON_NORMVALUE].toString(); + QJsonParseError jsonError; + QJsonDocument doc = QJsonDocument::fromJson(DateTimeJson.toUtf8(), &jsonError); + //建议时间 + QString sugdateTimeStr{""}; + //模糊时间 + QString dateTimeStr{""}; + + if (!doc.isNull() && (jsonError.error == QJsonParseError::NoError)) { + auto rootObject = doc.object(); + sugdateTimeStr = (rootObject["suggestDatetime"].toString()); + dateTimeStr = rootObject["datetime"].toString(); + } + //建议时间解析赋值 + if (sugdateTimeStr != "") { + if (sugdateTimeStr.contains("/")) { + QStringList dateTimeList = sugdateTimeStr.split("/"); + for (int i = 0; i < dateTimeList.size(); ++i) { + //如果数据不为空,添加解析数据 + if(!dateTimeList.at(i).isEmpty()){ + semdatetime.suggestDatetime.append(resolveNormValue(dateTimeList.at(i))); + } + } + } else { + semdatetime.suggestDatetime.append(resolveNormValue(sugdateTimeStr)); + } + } + //模糊时间解析赋值 + if(!dateTimeStr.isEmpty()){ + if(dateTimeStr.contains("/")){ + QStringList dateTimeList = dateTimeStr.split("/"); + for (int i = 0; i < dateTimeList.size(); ++i) { + //如果数据不为空,添加解析数据 + if(!dateTimeList.at(i).isEmpty()){ + semdatetime.dateTime.append(resolveDateTimeValeu(dateTimeList.at(i))); + } + } + } else { + semdatetime.dateTime.append(resolveDateTimeValeu(dateTimeStr)); + } + } + return semdatetime; +} + +SuggestDatetimeInfo JsonData::resolveNormValue(const QString &str) +{ + SuggestDatetimeInfo datetimeInfo; + datetimeInfo.hasTime = str.contains(JSON_DATETIME_DELIMITER); + datetimeInfo.datetime = QDateTime::fromString(str, Qt::ISODate); + return datetimeInfo; +} + +DateTimeInfo JsonData::resolveDateTimeValeu(const QString &dateTimeStr) +{ + DateTimeInfo dateTimeInfo{}; + //根据关键符合“T”分割字符 + QStringList dateList = dateTimeStr.split(JSON_DATETIME_DELIMITER); + //如果只有一个表示没有时间信息 + if(dateList.size() ==1){ + dateTimeInfo.m_Date = QDate::fromString(dateList.at(0),DATEFORMAT); + dateTimeInfo.hasDate = true; + dateTimeInfo.hasTime = false; + }else if (dateList.size()>1) { + //如果第一个数据为空表示没有日期信息 + if(dateList.at(0).isEmpty()){ + dateTimeInfo.hasDate = false; + }else { + dateTimeInfo.m_Date = QDate::fromString(dateList.at(0),DATEFORMAT); + dateTimeInfo.hasDate = true; + } + dateTimeInfo.m_Time = QTime::fromString(dateList.at(1),TIMEFORMAT); + dateTimeInfo.hasTime = true; + } + return dateTimeInfo; +} + +void JsonData::setDefaultValue() +{ + setTitleName(""); + setDateTimeStatus(NODATE); + setRepeatStatus(NONE); + setPropertyStatus(PRO_NONE); + m_RepeatNum.clear(); + m_DateTime.clear(); + setOffset(-1); +} + +void JsonData::jsonObjResolve(const QJsonObject &jsobj) +{ + Q_UNUSED(jsobj); +} + +JsonData::PropertyStatus JsonData::getPropertyStatus() const +{ + return m_propertyStatus; +} + +void JsonData::setPropertyStatus(const PropertyStatus &propertyStatus) +{ + m_propertyStatus = propertyStatus; +} + +int JsonData::offset() const +{ + return m_offset; +} + +void JsonData::setOffset(int offset) +{ + m_offset = offset; +} + +bool JsonData::isVaild() const +{ + return TitleName() == "" && getDateTime().suggestDatetime.size() == 0 + && m_offset == -1 && m_RepeatStatus == NONE && m_propertyStatus == PRO_NONE; +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/data/jsondata.h dde-calendar-5.7.0.23/schedule-plugin/src/data/jsondata.h --- dde-calendar-5.7.0.4/schedule-plugin/src/data/jsondata.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/data/jsondata.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,129 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef JSONDATA_H +#define JSONDATA_H + +#include +#include +#include "timedatastruct.h" +class QJsonObject; +class JsonData +{ +public: + enum RepeatStatus { NONE, + EVED, + EVEW, + EVEM, + EVEY, + WORKD, + RESTD + }; + enum DateTimeStatus { NODATE, + NOTIME, + ALLHAS + }; + enum PropertyStatus { PRO_NONE, + NEXT, + LAST, + ALL, + PRO_THIS + }; + +public: + JsonData(); + virtual ~JsonData(); + void JosnResolve(const QJsonObject &jsObj); + QString SuggestMsg() const; + void setSuggestMsg(const QString &SuggestMsg); + + bool ShouldEndSession() const; + void setShouldEndSession(bool ShouldEndSession); + + void setRepeatStatus(const RepeatStatus &RepeatStatus); + + QString TitleName() const; + void setTitleName(const QString &TitleName); + + void setDateTimeStatus(const DateTimeStatus &DateTimeStatus); + + RepeatStatus getRepeatStatus() const; + + QVector getRepeatNum() const; + void setRepeatNum(const QVector &RepeatNum); + + SemanticsDateTime getDateTime() const; + void setDateTime(const SemanticsDateTime &DateTime); + + PropertyStatus getPropertyStatus() const; + void setPropertyStatus(const PropertyStatus &propertyStatus); + + int offset() const; + void setOffset(int offset); + + /** + * @brief isVaild 判断json是否为原始数据 + * @return true为原始数据 + */ + virtual bool isVaild() const; + +protected: + void contentJsonResolve(const QJsonObject &jsobj); + void repeatJsonResolve(const QJsonObject &jsobj); + /** + * @brief datetimeJsonResolve 时间关键字解析 + * @param jsobj json对象 + */ + void datetimeJsonResolve(const QJsonObject &jsobj); + void propertyJsonResolve(const QJsonObject &jsobj); + /** + * @brief posRankOffsetResolve 偏移关键字解析 + * @param jsobj json对象 + */ + void posRankOffsetResolve(const QJsonObject &jsobj); + SemanticsDateTime suggestDatetimeResolve(const QJsonObject &jsobj); + /** + * @brief resolveNormValue 解析建议时间数据 + * @param str string格式的建议时间 + * @return 建议时间 + */ + SuggestDatetimeInfo resolveNormValue(const QString &str); + /** + * @brief resolveDateTimeValeu 解析模糊时间数据 + * @param dateTimeStr string格式的模糊时间 + * @return 模糊时间 + */ + DateTimeInfo resolveDateTimeValeu(const QString &dateTimeStr); + virtual void setDefaultValue(); + virtual void jsonObjResolve(const QJsonObject &jsobj); + +private: + QString m_SuggestMsg {""}; + bool m_ShouldEndSession {false}; + RepeatStatus m_RepeatStatus {NONE}; + QVector m_RepeatNum {}; + DateTimeStatus m_DateTimeStatus {NODATE}; + PropertyStatus m_propertyStatus {PRO_NONE}; + QString m_TitleName {""}; + SemanticsDateTime m_DateTime {}; + int m_offset {-1}; +}; + +#endif // JSONDATA_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/data/queryjsondata.cpp dde-calendar-5.7.0.23/schedule-plugin/src/data/queryjsondata.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/data/queryjsondata.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/data/queryjsondata.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,33 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "queryjsondata.h" + +#include +#include +#include +#include + +#include "../globaldef.h" + +QueryJsonData::QueryJsonData() + : JsonData() +{ +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/data/queryjsondata.h dde-calendar-5.7.0.23/schedule-plugin/src/data/queryjsondata.h --- dde-calendar-5.7.0.4/schedule-plugin/src/data/queryjsondata.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/data/queryjsondata.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,32 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef QUERYJSONDATA_H +#define QUERYJSONDATA_H + +#include "jsondata.h" + +class QueryJsonData : public JsonData +{ +public: + QueryJsonData(); +}; + +#endif // QUERYJSONDATA_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/data/schedulecolourmanage.cpp dde-calendar-5.7.0.23/schedule-plugin/src/data/schedulecolourmanage.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/data/schedulecolourmanage.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/data/schedulecolourmanage.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,401 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "schedulecolourmanage.h" + +ScheduleColourManage::ScheduleColourManage() + : m_LifeScheduleColour(new CSchedulesColor()) + , m_WorkScheduleColour(new CSchedulesColor()) + , m_OtherScheduleColour(new CSchedulesColor()) + , m_SolarScheduleColour(new CSchedulesColor()) +{ +} + +ScheduleColourManage::~ScheduleColourManage() +{ + delete m_LifeScheduleColour; + m_LifeScheduleColour = nullptr; + delete m_WorkScheduleColour; + m_WorkScheduleColour = nullptr; + delete m_OtherScheduleColour; + m_OtherScheduleColour = nullptr; + delete m_SolarScheduleColour; + m_SolarScheduleColour = nullptr; +} + +void ScheduleColourManage::setTheMe(int type) +{ + setLifeScheduleTheme(type); + setOtherScheduleTheme(type); + setWorkScheduleTheme(type); + setSolarScheduleTheme(type); +} + +CSchedulesColor ScheduleColourManage::getColorByTypeId(const int &id) +{ + //1工作 2 生活 3其他 + CSchedulesColor color; + switch (id) { + case 1: + color = WorkScheduleColour(); + break; + case 2: + color = LifeScheduleColour(); + break; + case 3: + color = OtherScheduleColour(); + break; + case 4: + color = SolarScheduleColour(); + break; + default: + color = OtherScheduleColour(); + break; + } + return color; +} + +CSchedulesColor ScheduleColourManage::LifeScheduleColour() const +{ + return *m_LifeScheduleColour; +} + +CSchedulesColor ScheduleColourManage::WorkScheduleColour() const +{ + return *m_WorkScheduleColour; +} + +CSchedulesColor ScheduleColourManage::OtherScheduleColour() const +{ + return *m_OtherScheduleColour; +} + +CSchedulesColor ScheduleColourManage::SolarScheduleColour() const +{ + return *m_SolarScheduleColour; +} + +void ScheduleColourManage::setLifeScheduleTheme(int type) +{ + if (type == 0 || type == 1) { + m_LifeScheduleColour->type = 2; + m_LifeScheduleColour->dotColor = "#82D245"; + m_LifeScheduleColour->dotColor.setAlphaF(1); + m_LifeScheduleColour->gradientFromC = "#B7E6FB"; + m_LifeScheduleColour->gradientFromC.setAlphaF(0.7); + m_LifeScheduleColour->gradientToC = "#D4FFB3"; + m_LifeScheduleColour->gradientToC.setAlphaF(0.7); + m_LifeScheduleColour->Purecolor = "#6FFF00"; + m_LifeScheduleColour->Purecolor.setAlphaF(0.2); + m_LifeScheduleColour->shadowcolor = "#82D245"; + m_LifeScheduleColour->textColor = "#000000"; + m_LifeScheduleColour->timeColor = "#53A316"; + m_LifeScheduleColour->hightlightgradientFromC = "#9AE5FF"; + m_LifeScheduleColour->hightlightgradientToC = "#C7FF94"; + QColor lifeP("#C7FF94"); + //lifeP.setAlphaF(0.8); + m_LifeScheduleColour->hightlightPurecolor = lifeP; + + m_LifeScheduleColour->hovergradientFromC = "#A8E9FF"; + m_LifeScheduleColour->hovergradientToC = "#D5FFAF"; + m_LifeScheduleColour->hovergradientFromC.setAlphaF(0.95); + m_LifeScheduleColour->hovergradientToC.setAlphaF(0.95); + QColor lifehP("#C4FF98"); + lifehP.setAlphaF(0.8); + m_LifeScheduleColour->hoverPurecolor = lifehP; + m_LifeScheduleColour->splitColor = "#82D245"; + m_LifeScheduleColour->pressgradientToC = m_LifeScheduleColour->gradientToC; + m_LifeScheduleColour->pressgradientFromC = m_LifeScheduleColour->gradientFromC; + m_LifeScheduleColour->pressPurecolor = m_LifeScheduleColour->Purecolor; + m_LifeScheduleColour->pressgradientToC.setAlphaF(0.8); + m_LifeScheduleColour->pressgradientFromC.setAlphaF(0.8); + m_LifeScheduleColour->pressPurecolor.setAlphaF(0.2); + + } else { + m_LifeScheduleColour->type = 2; + m_LifeScheduleColour->dotColor = "#59F88D"; + m_LifeScheduleColour->dotColor.setAlphaF(0.5); + m_LifeScheduleColour->gradientFromC = "#2D6883"; + m_LifeScheduleColour->gradientToC = "#5D7D44"; + m_LifeScheduleColour->gradientToC.setAlphaF(0.5); + m_LifeScheduleColour->gradientFromC.setAlphaF(0.5); + m_LifeScheduleColour->Purecolor = "#59F88D"; + m_LifeScheduleColour->Purecolor.setAlphaF(0.1); + m_LifeScheduleColour->shadowcolor = "#25FA6B"; + m_LifeScheduleColour->shadowcolor.setAlphaF(0.5); + m_LifeScheduleColour->textColor = "#C0C6D4"; + // m_LifeScheduleColour->textColor.setAlphaF(1); + m_LifeScheduleColour->timeColor = "#38A35B"; + m_LifeScheduleColour->hightlightgradientFromC = "#2D6883"; + m_LifeScheduleColour->hightlightgradientFromC.setAlphaF(0.8); + m_LifeScheduleColour->hightlightgradientToC = "#5D7D44"; + m_LifeScheduleColour->hightlightgradientToC.setAlphaF(0.8); + QColor lifeP("#337044"); + lifeP.setAlphaF(0.8); + m_LifeScheduleColour->hightlightPurecolor = lifeP; + m_LifeScheduleColour->splitColor = "#25FA6B"; + m_LifeScheduleColour->splitColor.setAlphaF(0.3); + m_LifeScheduleColour->hovergradientFromC = "#2D6883"; + m_LifeScheduleColour->hovergradientToC = "#5D7D44"; + m_LifeScheduleColour->hovergradientFromC.setAlphaF(0.65); + m_LifeScheduleColour->hovergradientToC.setAlphaF(0.65); + QColor lifehP("#59F88D"); + lifehP.setAlphaF(0.2); + m_LifeScheduleColour->hoverPurecolor = lifehP; + m_LifeScheduleColour->pressgradientToC = m_LifeScheduleColour->gradientToC; + m_LifeScheduleColour->pressgradientFromC = m_LifeScheduleColour->gradientFromC; + m_LifeScheduleColour->pressPurecolor = m_LifeScheduleColour->Purecolor; + m_LifeScheduleColour->pressgradientToC.setAlphaF(0.4); + m_LifeScheduleColour->pressgradientFromC.setAlphaF(0.4); + m_LifeScheduleColour->pressPurecolor.setAlphaF(0.15); + } +} + +void ScheduleColourManage::setWorkScheduleTheme(int type) +{ + if (type == 0 || type == 1) { + m_WorkScheduleColour->type = 1; + m_WorkScheduleColour->dotColor = "#FB2525"; + m_WorkScheduleColour->dotColor.setAlphaF(0.5); + m_WorkScheduleColour->gradientFromC = "#FBCEB7"; + m_WorkScheduleColour->gradientFromC.setAlphaF(0.7); + m_WorkScheduleColour->gradientToC = "#FA9D9A"; + m_WorkScheduleColour->gradientToC.setAlphaF(0.7); + m_WorkScheduleColour->Purecolor = "#F85566"; + m_WorkScheduleColour->Purecolor.setAlphaF(0.2); + m_WorkScheduleColour->shadowcolor = "#FB2525"; + m_WorkScheduleColour->shadowcolor.setAlphaF(0.5); + m_WorkScheduleColour->textColor = "#000000"; + m_WorkScheduleColour->timeColor = "#B54A4B"; + m_WorkScheduleColour->hightlightgradientFromC = "#FFD0B8"; + m_WorkScheduleColour->hightlightgradientToC = "#FF908D"; + QColor workP("#F9AEB8"); + //workP.setAlphaF(0.8); + m_WorkScheduleColour->hightlightPurecolor = workP; + m_WorkScheduleColour->splitColor = "#FB2525"; + m_WorkScheduleColour->splitColor.setAlphaF(0.5); + + m_WorkScheduleColour->hovergradientFromC = "#FFD0B8"; + m_WorkScheduleColour->hovergradientFromC.setAlphaF(0.95); + m_WorkScheduleColour->hovergradientToC = "#FF9D9A"; + m_WorkScheduleColour->hovergradientToC.setAlphaF(0.95); + QColor workhP("#FFB6BD"); + workhP.setAlphaF(0.8); + m_WorkScheduleColour->hoverPurecolor = workhP; + + m_WorkScheduleColour->pressgradientToC = m_WorkScheduleColour->gradientToC; + m_WorkScheduleColour->pressgradientFromC = m_WorkScheduleColour->gradientFromC; + m_WorkScheduleColour->pressPurecolor = m_WorkScheduleColour->Purecolor; + m_WorkScheduleColour->pressgradientToC.setAlphaF(0.8); + m_WorkScheduleColour->pressgradientFromC.setAlphaF(0.8); + m_WorkScheduleColour->pressPurecolor.setAlphaF(0.2); + + } else { + m_WorkScheduleColour->type = 1; + m_WorkScheduleColour->dotColor = "#F85566"; + m_WorkScheduleColour->dotColor.setAlphaF(0.5); + m_WorkScheduleColour->gradientFromC = "#965A26"; + m_WorkScheduleColour->gradientToC = "#8B2521"; + m_WorkScheduleColour->gradientToC.setAlphaF(0.5); + m_WorkScheduleColour->gradientFromC.setAlphaF(0.5); + m_WorkScheduleColour->Purecolor = "#F85566"; + m_WorkScheduleColour->Purecolor.setAlphaF(0.1); + m_WorkScheduleColour->shadowcolor = "#FB2525"; + m_WorkScheduleColour->shadowcolor.setAlphaF(0.5); + m_WorkScheduleColour->textColor = "#C0C6D4"; + // m_WorkScheduleColour->textColor.setAlphaF(1); + m_WorkScheduleColour->timeColor = "#B54A4B"; + m_WorkScheduleColour->hightlightgradientToC = "#992D2A"; + m_WorkScheduleColour->hightlightgradientToC.setAlphaF(0.8); + m_WorkScheduleColour->hightlightgradientFromC = "#8B521F"; + m_WorkScheduleColour->hightlightgradientFromC.setAlphaF(0.8); + QColor workP("#77373E"); + workP.setAlphaF(0.8); + m_WorkScheduleColour->hightlightPurecolor = workP; + + m_WorkScheduleColour->hovergradientFromC = "#965A26"; + m_WorkScheduleColour->hovergradientToC = "#8B2521"; + m_WorkScheduleColour->hovergradientFromC.setAlphaF(0.65); + m_WorkScheduleColour->hovergradientToC.setAlphaF(0.65); + QColor workhP("#F85566"); + workhP.setAlphaF(0.2); + m_WorkScheduleColour->hoverPurecolor = workhP; + m_WorkScheduleColour->splitColor = "#F85566"; + m_WorkScheduleColour->splitColor.setAlphaF(0.5); + m_WorkScheduleColour->pressgradientToC = m_WorkScheduleColour->gradientToC; + m_WorkScheduleColour->pressgradientFromC = m_WorkScheduleColour->gradientFromC; + m_WorkScheduleColour->pressPurecolor = m_WorkScheduleColour->Purecolor; + m_WorkScheduleColour->pressgradientToC.setAlphaF(0.4); + m_WorkScheduleColour->pressgradientFromC.setAlphaF(0.4); + m_WorkScheduleColour->pressPurecolor.setAlphaF(0.15); + } +} + +void ScheduleColourManage::setOtherScheduleTheme(int type) +{ + if (type == 0 || type == 1) { + m_OtherScheduleColour->type = 3; + m_OtherScheduleColour->dotColor = "#BA60FA"; + m_OtherScheduleColour->dotColor.setAlphaF(1); + m_OtherScheduleColour->gradientFromC = "#FBE9B7"; + m_OtherScheduleColour->gradientFromC.setAlphaF(0.7); + m_OtherScheduleColour->gradientToC = "#DFB3FF"; + m_OtherScheduleColour->gradientToC.setAlphaF(0.7); + m_OtherScheduleColour->Purecolor = "#D191FF"; + m_OtherScheduleColour->Purecolor.setAlphaF(0.2); + m_OtherScheduleColour->shadowcolor = "#BA60FA"; + m_OtherScheduleColour->textColor = "#000000"; + m_OtherScheduleColour->timeColor = "#8548B1"; + m_OtherScheduleColour->hightlightgradientFromC = "#FFE8AC"; + m_OtherScheduleColour->hightlightgradientToC = "#FBA5FF"; + QColor otherP("#EAC4FF"); + //otherP.setAlphaF(0.8); + m_OtherScheduleColour->hightlightPurecolor = otherP; + + m_OtherScheduleColour->hovergradientFromC = "#FFE8AC"; + m_OtherScheduleColour->hovergradientToC = "#E2A5FF"; + m_OtherScheduleColour->hovergradientFromC.setAlphaF(0.95); + m_OtherScheduleColour->hovergradientToC.setAlphaF(0.95); + QColor otherhP("#E6C5FF"); + otherhP.setAlphaF(0.8); + m_OtherScheduleColour->hoverPurecolor = otherhP; + m_OtherScheduleColour->splitColor = "#BA60FA"; + m_OtherScheduleColour->pressgradientToC = m_OtherScheduleColour->gradientToC; + m_OtherScheduleColour->pressgradientFromC = m_OtherScheduleColour->gradientFromC; + m_OtherScheduleColour->pressPurecolor = m_OtherScheduleColour->Purecolor; + m_OtherScheduleColour->pressgradientToC.setAlphaF(0.8); + m_OtherScheduleColour->pressgradientFromC.setAlphaF(0.8); + m_OtherScheduleColour->pressPurecolor.setAlphaF(0.2); + } else { + m_OtherScheduleColour->type = 3; + m_OtherScheduleColour->dotColor = "#C155F8"; + m_OtherScheduleColour->dotColor.setAlphaF(0.7); + m_OtherScheduleColour->gradientFromC = "#8C4E2C"; + m_OtherScheduleColour->gradientToC = "#7D37AF"; + m_OtherScheduleColour->gradientToC.setAlphaF(0.5); + m_OtherScheduleColour->gradientFromC.setAlphaF(0.5); + m_OtherScheduleColour->Purecolor = "#C155F8"; + m_OtherScheduleColour->Purecolor.setAlphaF(0.1); + m_OtherScheduleColour->shadowcolor = "#BE3DFF"; + m_OtherScheduleColour->shadowcolor.setAlphaF(0.5); + m_OtherScheduleColour->textColor = "#C0C6D4"; + // m_OtherScheduleColour->textColor.setAlphaF(1); + m_OtherScheduleColour->timeColor = "#9857C8"; + m_OtherScheduleColour->hightlightgradientFromC = "#8C4E2C"; + m_OtherScheduleColour->hightlightgradientFromC.setAlphaF(0.8); + m_OtherScheduleColour->hightlightgradientToC = "#803BAE"; + m_OtherScheduleColour->hightlightgradientToC.setAlphaF(0.8); + QColor otherP("#613776"); + otherP.setAlphaF(0.8); + m_OtherScheduleColour->hightlightPurecolor = otherP; + + m_OtherScheduleColour->hovergradientFromC = "#8C4E2C"; + m_OtherScheduleColour->hovergradientToC = "#7D37AF"; + m_OtherScheduleColour->hovergradientFromC.setAlphaF(0.65); + m_OtherScheduleColour->hovergradientToC.setAlphaF(0.65); + QColor otherhP("#C155F8"); + otherhP.setAlphaF(0.2); + m_OtherScheduleColour->hoverPurecolor = otherhP; + m_OtherScheduleColour->splitColor = "#BA32FF"; + m_OtherScheduleColour->splitColor.setAlphaF(0.5); + m_OtherScheduleColour->pressgradientToC = m_OtherScheduleColour->gradientToC; + m_OtherScheduleColour->pressgradientFromC = m_OtherScheduleColour->gradientFromC; + m_OtherScheduleColour->pressPurecolor = m_OtherScheduleColour->Purecolor; + m_OtherScheduleColour->pressgradientToC.setAlphaF(0.4); + m_OtherScheduleColour->pressgradientFromC.setAlphaF(0.4); + m_OtherScheduleColour->pressPurecolor.setAlphaF(0.15); + } +} + +void ScheduleColourManage::setSolarScheduleTheme(int type) +{ + if (type == 0 || type == 1) { + m_SolarScheduleColour->type = 4; + m_SolarScheduleColour->dotColor = "#FF7272"; + m_SolarScheduleColour->dotColor.setAlphaF(1); + m_SolarScheduleColour->gradientFromC = "#FF7272"; + m_SolarScheduleColour->gradientFromC.setAlphaF(0.3); + m_SolarScheduleColour->gradientToC = "#FF7272"; + m_SolarScheduleColour->gradientToC.setAlphaF(0.3); + m_SolarScheduleColour->Purecolor = "#FF7272"; + m_SolarScheduleColour->Purecolor.setAlphaF(0.3); + m_SolarScheduleColour->shadowcolor = "#BA60FA"; + m_SolarScheduleColour->textColor = "#000000"; + m_SolarScheduleColour->timeColor = "#8548B1"; + m_SolarScheduleColour->hightlightgradientFromC = "#F9AAAA"; + m_SolarScheduleColour->hightlightgradientFromC.setAlphaF(1); + m_SolarScheduleColour->hightlightgradientToC = "#F9AAAA"; + m_SolarScheduleColour->hightlightgradientToC.setAlphaF(1); + m_SolarScheduleColour->hightlightPurecolor = "#F9AAAA"; + m_SolarScheduleColour->hightlightPurecolor.setAlphaF(1); + + m_SolarScheduleColour->hovergradientFromC = "#FFB0B1"; + m_SolarScheduleColour->hovergradientToC = "#FFB0B1"; + m_SolarScheduleColour->hovergradientFromC.setAlphaF(0.95); + m_SolarScheduleColour->hovergradientToC.setAlphaF(0.95); + m_SolarScheduleColour->hoverPurecolor = "#FF7272"; + m_SolarScheduleColour->splitColor = "#FF7272"; + m_SolarScheduleColour->pressgradientFromC = "#FF7272"; + m_SolarScheduleColour->pressgradientFromC.setAlphaF(0.3); + m_SolarScheduleColour->pressgradientToC = "#FF7272"; + m_SolarScheduleColour->pressgradientToC.setAlphaF(0.3); + + m_SolarScheduleColour->pressPurecolor = m_SolarScheduleColour->Purecolor; + m_SolarScheduleColour->pressgradientToC.setAlphaF(0.4); + m_SolarScheduleColour->pressgradientFromC.setAlphaF(0.4); + m_SolarScheduleColour->pressPurecolor.setAlphaF(0.1); + } else { + m_SolarScheduleColour->type = 4; + m_SolarScheduleColour->dotColor = "#FF7272"; + m_SolarScheduleColour->dotColor.setAlphaF(0.8); + m_SolarScheduleColour->gradientFromC = "#FF7272"; + m_SolarScheduleColour->gradientFromC.setAlphaF(0.3); + m_SolarScheduleColour->gradientToC = "#FF7272"; + m_SolarScheduleColour->gradientToC.setAlphaF(0.3); + m_SolarScheduleColour->Purecolor = "#FF7272"; + m_SolarScheduleColour->Purecolor.setAlphaF(0.3); + m_SolarScheduleColour->shadowcolor = "#BA60FA"; + m_SolarScheduleColour->textColor = "#C0C6D4"; + m_SolarScheduleColour->timeColor = "#8548B1"; + m_SolarScheduleColour->hightlightgradientFromC = "#A24545"; + m_SolarScheduleColour->hightlightgradientFromC.setAlphaF(0.8); + m_SolarScheduleColour->hightlightgradientToC = "#A24545"; + m_SolarScheduleColour->hightlightgradientToC.setAlphaF(0.8); + m_SolarScheduleColour->hightlightPurecolor = "#A24545"; + m_SolarScheduleColour->hightlightPurecolor.setAlphaF(0.8); + + m_SolarScheduleColour->hovergradientFromC = "#E56464"; + m_SolarScheduleColour->hovergradientToC = "#E56464"; + m_SolarScheduleColour->hovergradientFromC.setAlphaF(0.35); + m_SolarScheduleColour->hovergradientToC.setAlphaF(0.35); + m_SolarScheduleColour->hoverPurecolor = "#E56464"; + m_SolarScheduleColour->splitColor = "#FF7272"; + m_SolarScheduleColour->pressgradientFromC = "#FF7272"; + m_SolarScheduleColour->pressgradientFromC.setAlphaF(0.3); + m_SolarScheduleColour->pressgradientToC = m_SolarScheduleColour->pressgradientFromC; + // m_SolarScheduleColour->pressgradientToC = "#000000"; + // m_SolarScheduleColour->pressgradientToC.setAlphaF(0.05); + + m_SolarScheduleColour->pressPurecolor = m_SolarScheduleColour->Purecolor; + m_SolarScheduleColour->pressgradientToC.setAlphaF(0.4); + m_SolarScheduleColour->pressgradientFromC.setAlphaF(0.4); + m_SolarScheduleColour->pressPurecolor.setAlphaF(0.1); + } +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/data/schedulecolourmanage.h dde-calendar-5.7.0.23/schedule-plugin/src/data/schedulecolourmanage.h --- dde-calendar-5.7.0.4/schedule-plugin/src/data/schedulecolourmanage.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/data/schedulecolourmanage.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,78 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef SCHEDULECOLOURMANAGE_H +#define SCHEDULECOLOURMANAGE_H + +#include +struct CSchedulesColor { + int type; + QColor gradientFromC; + QColor gradientToC; + QColor dotColor; + QColor Purecolor; + QColor shadowcolor; + QColor textColor; + QColor timeColor; + QColor hightlightgradientFromC; + QColor hightlightgradientToC; + QColor hightlightPurecolor; + QColor hovergradientFromC; + QColor hovergradientToC; + QColor hoverPurecolor; + QColor splitColor; + QColor pressgradientFromC; + QColor pressgradientToC; + QColor pressPurecolor; +}; + +class ScheduleColourManage +{ +public: + ScheduleColourManage(); + ~ScheduleColourManage(); + +public: + void setTheMe(int type = 0); + CSchedulesColor getColorByTypeId(const int &id); + +private: + CSchedulesColor LifeScheduleColour() const; + + CSchedulesColor WorkScheduleColour() const; + + CSchedulesColor OtherScheduleColour() const; + + CSchedulesColor SolarScheduleColour() const; + +private: + void setLifeScheduleTheme(int type = 0); + void setWorkScheduleTheme(int type = 0); + void setOtherScheduleTheme(int type = 0); + void setSolarScheduleTheme(int type = 0); + +private: + CSchedulesColor *m_LifeScheduleColour {nullptr}; + CSchedulesColor *m_WorkScheduleColour {nullptr}; + CSchedulesColor *m_OtherScheduleColour {nullptr}; + CSchedulesColor *m_SolarScheduleColour {nullptr}; +}; + +#endif // SCHEDULECOLOURMANAGE_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/data/schedulestructs.h dde-calendar-5.7.0.23/schedule-plugin/src/data/schedulestructs.h --- dde-calendar-5.7.0.4/schedule-plugin/src/data/schedulestructs.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/data/schedulestructs.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,131 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#ifndef SCHEDULESTURCTS_H +#define SCHEDULESTURCTS_H + +#include +#include +#include +#include + +typedef struct _tagScheduleRemindInfo { + int id; + QDateTime remindDateTime; + int times; + _tagScheduleRemindInfo() + { + times = 1; + } +} ScheduleRemindInfo; +typedef struct _tagScheduleRemindData { + int n; //全天代表天数 非全天代表分钟 + QTime time; //全天该变量才有效 +} ScheduleRemindData; +typedef struct _tagScheduleEndRepeatData { + int type; //0 永不 1 多少次结束 2 结束日期 + QDateTime date; //为2时才有效 + int tcount; //1时有效 +} ScheduleEndRepeatData; +typedef struct _tagScheduleType { + QString typeName; //work life other + QColor color; //颜色 + int ID; +} ScheduleType; +typedef struct _tagScheduleDtailInfo { + int id; + QDateTime beginDateTime; + QDateTime endDateTime; + QVector ignore; + QString titleName; + QString description; + bool allday; //1全天 + ScheduleType type; //1工作 2 生活 3其他 + int RecurID; //0 代表原始 大于0 代表克隆 + bool remind; //0无 1 提醒 + ScheduleRemindData remindData; + int rpeat; //0 无 1 每天 2 每个工作日 3 每周 4每月 5每年 + ScheduleEndRepeatData enddata; + explicit _tagScheduleDtailInfo() + { + type.ID = -1; + } + bool operator==(const _tagScheduleDtailInfo &info) const + { + if (info.type.ID == 4) { + return this->id == info.id && this->RecurID == info.RecurID && titleName == info.titleName && beginDateTime == info.beginDateTime; + } else { + return this->id == info.id && this->RecurID == info.RecurID && titleName == info.titleName; + } + } + bool operator<(const _tagScheduleDtailInfo &info) const + { + if (beginDateTime.date() != endDateTime.date() && info.beginDateTime.date() == info.endDateTime.date()) { + return true; + } else if (beginDateTime.date() == endDateTime.date() && info.beginDateTime.date() != info.endDateTime.date()) { + return false; + } else if (beginDateTime.date() != endDateTime.date() && info.beginDateTime.date() != info.endDateTime.date()) { + if (beginDateTime.date() == info.beginDateTime.date()) { + return beginDateTime.daysTo(endDateTime) > info.beginDateTime.daysTo(info.endDateTime); + } + return beginDateTime.date() < info.beginDateTime.date(); + } else { + if (type.ID == 4) + return true; + if (info.type.ID == 4) + return false; + if (beginDateTime == info.beginDateTime) { + if (titleName == info.titleName) { + return id < info.id; + } + return titleName < info.titleName; + } else { + return beginDateTime < info.beginDateTime; + } + } + } +} ScheduleDtailInfo; + +typedef struct _tagScheduleDateRangeInfo { + QDate date; + QVector vData; +} ScheduleDateRangeInfo; +typedef struct _tagMScheduleDateRangeInfo { + QDate bdate; + QDate edate; + bool state; + int num; + ScheduleDtailInfo tData; + bool operator<(const _tagMScheduleDateRangeInfo &info) const + { + if (bdate == info.bdate) { + if (bdate.daysTo(edate) == info.bdate.daysTo(info.edate)) { + return tData < info.tData; + } else { + return bdate.daysTo(edate) > info.bdate.daysTo(info.edate); + } + } else { + return bdate < info.bdate; + } + } + bool operator==(const _tagMScheduleDateRangeInfo &info) const + { + return bdate == info.bdate && edate == info.edate && tData == info.tData && state == info.state && num == info.num; + } +} MScheduleDateRangeInfo; +#endif diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/data/timedatastruct.h dde-calendar-5.7.0.23/schedule-plugin/src/data/timedatastruct.h --- dde-calendar-5.7.0.4/schedule-plugin/src/data/timedatastruct.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/data/timedatastruct.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,68 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef TIMEDATASTRUCT_H +#define TIMEDATASTRUCT_H + +#include +#include +/** + * @brief The ToDateTimeInfo struct 修改时间信息 + * m_Date 日期信息 + * m_Time 时间信息 + * hasDate 是否存在日期信息 + * hasTime 是否存在时间信息 + */ +struct DateTimeInfo { + QDate m_Date{}; + QTime m_Time{}; + bool hasDate{false}; + bool hasTime{false}; +}; +/** + * @brief The SuggestDatetimeInfo struct 建议时间信息 + * datetime 时间信息 + * hasTime 是否存在具体时间点 + */ +struct SuggestDatetimeInfo{ + QDateTime datetime {}; + bool hasTime {false}; +}; + +/** + * @brief The ScheduleDateTime struct 语言时间信息 + * m_DateTime 时间信息,获取时间点的时候需要用到 + * m_sugTime 建议使用的时间信息 + */ +struct SemanticsDateTime { + QVector dateTime{}; + QVector suggestDatetime{}; + /** + * @brief clear 清空数据 + */ + void clear(){ + this->dateTime.clear(); + this->suggestDatetime.clear(); + } +}; + + + +#endif // TIMEDATASTRUCT_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/dbus/schedulesdbus.cpp dde-calendar-5.7.0.23/schedule-plugin/src/dbus/schedulesdbus.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/dbus/schedulesdbus.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/dbus/schedulesdbus.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,676 @@ +/* + * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ + +/* + * This file was generated by qdbusxml2cpp version 0.8 + * Command line was: qdbusxml2cpp -c DCalendarDBus -p dcalendardbus com.deepin.api.LunarCalendar.xml + * + * qdbusxml2cpp is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * This file may have been hand-edited. Look for HAND-EDIT comments + * before re-generating it. + */ + +#include "schedulesdbus.h" +#include +#include +#include +/* + * Implementation of interface class DCalendarDBus + */ + +CSchedulesDBus::CSchedulesDBus(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) + : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) +{ + QDBusConnection::sessionBus().connect(this->service(), this->path(), "org.freedesktop.DBus.Properties", "PropertiesChanged", "sa{sv}as", this, SLOT(__propertyChanged__(QDBusMessage))); +} + +CSchedulesDBus::~CSchedulesDBus() +{ + QDBusConnection::sessionBus().disconnect(service(), path(), "org.freedesktop.DBus.Properties", "PropertiesChanged", "sa{sv}as", this, SLOT(propertyChanged(QDBusMessage))); +} + +QString CSchedulesDBus::createScheduleDtailInfojson(const ScheduleDtailInfo &info) +{ + QJsonObject json; + json.insert("ID", info.id); + json.insert("AllDay", info.allday); + json.insert("Remind", createScheduleRemind(info)); + json.insert("RRule", createScheduleRRule(info)); + json.insert("Title", info.titleName); + json.insert("Description", info.description); + json.insert("Type", info.type.ID); + json.insert("Start", toconvertData(info.beginDateTime)); + json.insert("End", toconvertData(info.endDateTime)); + //json.insert("Start", "2006-01-02T15:04:05+07:00"); + //json.insert("End", "2006-01-02T17:04:05+07:00"); + json.insert("RecurID", info.RecurID); + QJsonArray jsonarry; + for (int i = 0; i < info.ignore.count(); i++) { + jsonarry.append(toconvertData(info.ignore.at(i))); + } + json.insert("Ignore", jsonarry); + // 构建 JSON 文档 + QJsonDocument document; + document.setObject(json); + QByteArray byteArray = document.toJson(QJsonDocument::Compact); + QString strJson(byteArray); + return strJson; +} + +QString CSchedulesDBus::createScheduleTypejson(const ScheduleType &info) +{ + QJsonObject json; + json.insert("ID", info.ID); + json.insert("Name", info.typeName); + QString colorName = QString("#%1%2%3").arg(info.color.red(), 2, 16, QChar('0')).arg(info.color.green(), 2, 16, QChar('0')).arg(info.color.blue(), 2, 16, QChar('0')); + json.insert("Color", info.color.name()); + // 构建 JSON 文档 + QJsonDocument document; + document.setObject(json); + QByteArray byteArray = document.toJson(QJsonDocument::Compact); + QString strJson(byteArray); + return strJson; +} + +ScheduleType CSchedulesDBus::parsingScheduleTypejson(QJsonObject &object) +{ + ScheduleType type; + QJsonObject &rootObj = object; + + //因为是预先定义好的JSON数据格式,所以这里可以这样读取 + if (rootObj.contains("ID")) { + type.ID = rootObj.value("ID").toInt(); + } + if (rootObj.contains("Name")) { + type.typeName = rootObj.value("Name").toString(); + } + if (rootObj.contains("Color")) { + QString str = rootObj.value("Color").toString(); + type.color = QColor(rootObj.value("Color").toString()); + } + return type; +} + +ScheduleDtailInfo CSchedulesDBus::parsingScheduleDtailInfojsonID(QJsonObject &obj) +{ + ScheduleDtailInfo info; + + QJsonObject &rootObj = obj; + //因为是预先定义好的JSON数据格式,所以这里可以这样读取 + if (rootObj.contains("ID")) { + info.id = rootObj.value("ID").toInt(); + } + if (rootObj.contains("AllDay")) { + info.allday = rootObj.value("AllDay").toBool(); + } + if (rootObj.contains("Remind")) { + parsingScheduleRemind(rootObj.value("Remind").toString(), info); + } + if (rootObj.contains("Title")) { + info.titleName = rootObj.value("Title").toString(); + } + if (rootObj.contains("Description")) { + info.description = rootObj.value("Description").toString(); + } + if (rootObj.contains("Type")) { + GetType(rootObj.value("Type").toInt(), info.type); + } + if (rootObj.contains("Start")) { + info.beginDateTime = fromconvertData(rootObj.value("Start").toString()); + } + if (rootObj.contains("End")) { + info.endDateTime = fromconvertData(rootObj.value("End").toString()); + } + if (rootObj.contains("RecurID")) { + info.RecurID = rootObj.value("RecurID").toInt(); + } + if (rootObj.contains("RRule")) { + parsingScheduleRRule(rootObj.value("RRule").toString(), info); + } + if (rootObj.contains("Ignore")) { + QJsonArray subArray = rootObj.value("Ignore").toArray(); + for (int i = 0; i < subArray.size(); i++) { + QString subObj = subArray.at(i).toString(); + info.ignore.append(fromconvertData(subObj)); + } + } + return info; +} + +QString CSchedulesDBus::createScheduleRRule(const ScheduleDtailInfo &info) +{ + if (info.rpeat == 0) + return QString(); + // QString str = "'"; + QString str; + switch (info.rpeat) { + case 1: { + str += "FREQ=DAILY"; + } break; + case 2: { + str += "FREQ=DAILY;BYDAY=MO,TU,WE,TH,FR"; + } break; + case 3: { + str += "FREQ=WEEKLY"; + } break; + case 4: { + str += "FREQ=MONTHLY"; + } break; + case 5: { + str += "FREQ=YEARLY"; + } break; + } + switch (info.enddata.type) { + case 1: { + str += QString(";COUNT=%1").arg(info.enddata.tcount + 1); + } break; + case 2: { + QDateTime datetime = info.enddata.date; + //datetime.setDate(datetime); + str += ";UNTIL=" + datetime.toString("yyyyMMddThhmmss") + "Z"; + // str += ";UNTIL=" + toconvertData(datetime); + } break; + } + //str += "'"; + return str; +} + +void CSchedulesDBus::parsingScheduleRRule(QString str, ScheduleDtailInfo &info) +{ + if (str.isEmpty()) { + info.rpeat = 0; + return; + } + QString rrulestrs = str; + QStringList rruleslist = rrulestrs.split(";", QString::SkipEmptyParts); + if (rruleslist.count() > 0) { + if (rruleslist.contains("FREQ=DAILY") && rruleslist.contains("BYDAY=MO,TU,WE,TH,FR")) + info.rpeat = 2; + else if (rruleslist.contains("FREQ=DAILY")) { + info.rpeat = 1; + } else if (rruleslist.contains("FREQ=WEEKLY")) { + info.rpeat = 3; + } else if (rruleslist.contains("FREQ=MONTHLY")) { + info.rpeat = 4; + } else if (rruleslist.contains("FREQ=YEARLY")) { + info.rpeat = 5; + } + info.enddata.type = 0; + for (int i = 0; i < rruleslist.count(); i++) { + if (rruleslist.at(i).contains("COUNT=")) { + QStringList liststr = rruleslist.at(i).split("=", QString::SkipEmptyParts); + info.enddata.type = 1; + info.enddata.tcount = liststr.at(1).toInt() - 1; + } + + if (rruleslist.at(i).contains("UNTIL=")) { + QStringList liststr = rruleslist.at(i).split("=", QString::SkipEmptyParts); + info.enddata.type = 2; + info.enddata.date = QDateTime::fromString(liststr.at(1).left(liststr.at(1).count() - 1), "yyyyMMddThhmmss"); + //info.enddata.date = fromconvertData(liststr.at(1)); + info.enddata.date = info.enddata.date; + } + } + } +} + +QString CSchedulesDBus::createScheduleRemind(const ScheduleDtailInfo &info) +{ + if (!info.remind) + return QString(); + QString str; + if (info.allday) { + str = QString::number(info.remindData.n) + ";" + info.remindData.time.toString("hh:mm"); + } else { + str = QString::number(info.remindData.n); + } + return str; +} + +void CSchedulesDBus::parsingScheduleRemind(QString str, ScheduleDtailInfo &info) +{ + if (str.isEmpty()) { + info.remind = false; + return; + } + info.remind = true; + if (info.allday) { + QStringList liststr = str.split(";", QString::SkipEmptyParts); + info.remindData.n = liststr.at(0).toInt(); + info.remindData.time = QTime::fromString(liststr.at(1), "hh:mm"); + } else { + info.remindData.n = str.toInt(); + } +} + +QString CSchedulesDBus::toconvertData(QDateTime date) +{ + QDateTime datetimeutc11 = date; + datetimeutc11.setTimeSpec(Qt::UTC); + QString strss = datetimeutc11.toString(Qt::ISODate); + datetimeutc11.setTimeSpec(Qt::OffsetFromUTC); + strss = datetimeutc11.toString(Qt::ISODateWithMs); + QDateTime datetimeutc = QDateTime::fromTime_t(0); + QString str = date.toString("yyyy-MM-ddThh:mm:ss") + "+" + datetimeutc.toString("hh:mm"); + //QString str = date.toString("yyyy-MM-ddThh:mm:ss") + "Z07:00"; + return str; +} + +QDateTime CSchedulesDBus::fromconvertData(QString str) +{ + QStringList liststr = str.split("+", QString::SkipEmptyParts); + return QDateTime::fromString(liststr.at(0), "yyyy-MM-ddThh:mm:ss"); +} + +QString CSchedulesDBus::toconvertIGData(QDateTime date) +{ + QDateTime datetimeutc11 = date; + datetimeutc11.setTimeSpec(Qt::UTC); + QString strss = datetimeutc11.toString(Qt::ISODate); + datetimeutc11.setTimeSpec(Qt::OffsetFromUTC); + strss = datetimeutc11.toString(Qt::ISODateWithMs); + QDateTime datetimeutc = QDateTime::fromTime_t(0); + QString str = date.toString("yyyy-MM-ddThh:mm:ss") + "Z" + datetimeutc.toString("hh:mm"); + //QString str = date.toString("yyyy-MM-ddThh:mm:ss") + "Z07:00"; + return str; +} + +QDateTime CSchedulesDBus::fromconvertiIGData(QString str) +{ + QStringList liststr = str.split("Z", QString::SkipEmptyParts); + return QDateTime::fromString(liststr.at(0), "yyyy-MM-ddThh:mm:ss"); +} + +qint64 CSchedulesDBus::CreateJob(const ScheduleDtailInfo &info) +{ + QList argumentList; + argumentList << QVariant::fromValue(createScheduleDtailInfojson(info)); + qDebug() << argumentList.at(0); + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("CreateJob"), argumentList); + if (reply.type() != QDBusMessage::ReplyMessage) { + qDebug() << reply; + return -1; + } + QDBusReply id = reply; + + return id.value(); +} + +bool CSchedulesDBus::GetJobs(int startYear, int startMonth, int startDay, int endYear, int endMonth, int endDay, QVector &out) +{ + QList argumentList; + argumentList << QVariant::fromValue(startYear) << QVariant::fromValue(startMonth) << QVariant::fromValue(startDay); + argumentList << QVariant::fromValue(endYear) << QVariant::fromValue(endMonth) << QVariant::fromValue(endDay); + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetJobs"), argumentList); + if (reply.type() != QDBusMessage::ReplyMessage) { + return false; + } + QDBusReply jobs = reply; + + if (!jobs.isValid()) + return false; + QJsonParseError json_error; + QJsonDocument jsonDoc(QJsonDocument::fromJson(jobs.value().toLocal8Bit(), &json_error)); + + if (json_error.error != QJsonParseError::NoError) { + return false; + } + + QJsonArray rootarry = jsonDoc.array(); + for (int i = 0; i < rootarry.size(); i++) { + QJsonObject subObj = rootarry.at(i).toObject(); + + ScheduleDateRangeInfo info; + //因为是预先定义好的JSON数据格式,所以这里可以这样读取 + if (subObj.contains("Date")) { + info.date = QDate::fromString(subObj.value("Date").toString(), "yyyy-MM-dd"); + } + if (subObj.contains("Jobs")) { + QJsonArray subarry = subObj.value("Jobs").toArray(); + for (int j = 0; j < subarry.size(); j++) { + QJsonObject ssubObj = subarry.at(j).toObject(); + info.vData.append(parsingScheduleDtailInfojsonID(ssubObj)); + } + } + out.append(info); + } + + return true; +} + +bool CSchedulesDBus::GetJob(qint64 jobId, ScheduleDtailInfo &out) +{ + QList argumentList; + argumentList << QVariant::fromValue(jobId); + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetJob"), argumentList); + if (reply.type() != QDBusMessage::ReplyMessage) { + return false; + } + QDBusReply jobs = reply; + + if (!jobs.isValid()) + return false; + QJsonParseError json_error; + QJsonDocument jsonDoc(QJsonDocument::fromJson(jobs.value().toLocal8Bit(), &json_error)); + + if (json_error.error != QJsonParseError::NoError) { + return false; + } + + QJsonObject ssubObj = jsonDoc.object(); + out = parsingScheduleDtailInfojsonID(ssubObj); + + return true; +} + +bool CSchedulesDBus::UpdateJob(const ScheduleDtailInfo &info) +{ + QList argumentList; + argumentList << QVariant::fromValue(createScheduleDtailInfojson(info)); + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("UpdateJob"), argumentList); + if (reply.type() != QDBusMessage::ReplyMessage) { + //dbus UpdateJob 错误提醒 + qDebug()<<"UpdateJob Err"; + qDebug()< jobs = reply; + + //if (!jobs.isValid()) return false; + + return true; +} + +bool CSchedulesDBus::DeleteJob(qint64 jobId) +{ + QList argumentList; + argumentList << QVariant::fromValue(jobId); + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("DeleteJob"), argumentList); + if (reply.type() != QDBusMessage::ReplyMessage) { + return false; + } + + return true; +} + +bool CSchedulesDBus::QueryJobs(QString key, QDateTime starttime, QDateTime endtime, QVector &out) +{ + QJsonObject qjson; + qjson.insert("Key", key); + qjson.insert("Start", toconvertData(starttime)); + qjson.insert("End", toconvertData(endtime)); + // 构建 JSON 文档 + QJsonDocument qdocument; + qdocument.setObject(qjson); + QByteArray qbyteArray = qdocument.toJson(QJsonDocument::Compact); + QString strJson(qbyteArray); + + QList argumentList; + argumentList << QVariant::fromValue(strJson); + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("QueryJobs"), argumentList); + if (reply.type() != QDBusMessage::ReplyMessage) { + return false; + } + QDBusReply jobs = reply; + + if (!jobs.isValid()) + return false; + QJsonParseError json_error; + QJsonDocument jsonDoc(QJsonDocument::fromJson(jobs.value().toLocal8Bit(), &json_error)); + + if (json_error.error != QJsonParseError::NoError) { + return false; + } + + QJsonArray rootarry = jsonDoc.array(); + for (int i = 0; i < rootarry.size(); i++) { + QJsonObject subObj = rootarry.at(i).toObject(); + + ScheduleDateRangeInfo info; + //因为是预先定义好的JSON数据格式,所以这里可以这样读取 + if (subObj.contains("Date")) { + info.date = QDate::fromString(subObj.value("Date").toString(), "yyyy-MM-dd"); + } + if (subObj.contains("Jobs")) { + QJsonArray subarry = subObj.value("Jobs").toArray(); + for (int j = 0; j < subarry.size(); j++) { + QJsonObject ssubObj = subarry.at(j).toObject(); + info.vData.append(parsingScheduleDtailInfojsonID(ssubObj)); + } + } + out.append(info); + } + return true; +} + +bool CSchedulesDBus::QueryJobs(QString key, QDateTime starttime, QDateTime endtime, QString &out) +{ + QJsonObject qjson; + qjson.insert("Key", key); + qjson.insert("Start", toconvertData(starttime)); + qjson.insert("End", toconvertData(endtime)); + // 构建 JSON 文档 + QJsonDocument qdocument; + qdocument.setObject(qjson); + QByteArray qbyteArray = qdocument.toJson(QJsonDocument::Compact); + QString strJson(qbyteArray); + + QList argumentList; + argumentList << QVariant::fromValue(strJson); + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("QueryJobs"), argumentList); + if (reply.type() != QDBusMessage::ReplyMessage) { + return false; + } + QDBusReply jobs = reply; + + if (!jobs.isValid()) + return false; + out = jobs.value().toLocal8Bit(); + return true; +} + +bool CSchedulesDBus::QueryJobsWithLimit(QDateTime starttime, QDateTime endtime, qint32 maxNum, QVector &out) +{ + QJsonObject qjson; + qjson.insert("Start", toconvertData(starttime)); + qjson.insert("End", toconvertData(endtime)); + qjson.insert("key", ""); + // 构建 JSON 文档 + QJsonDocument qdocument; + qdocument.setObject(qjson); + QByteArray qbyteArray = qdocument.toJson(QJsonDocument::Compact); + QString strJson(qbyteArray); + + QList argumentList; + argumentList << QVariant::fromValue(strJson); + argumentList << maxNum; + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("QueryJobsWithLimit"), argumentList); + if (reply.type() != QDBusMessage::ReplyMessage) { + return false; + } + QDBusReply jobs = reply; + + if (!jobs.isValid()) + return false; + QJsonParseError json_error; + QJsonDocument jsonDoc(QJsonDocument::fromJson(jobs.value().toLocal8Bit(), &json_error)); + + if (json_error.error != QJsonParseError::NoError) { + return false; + } + + QJsonArray rootarry = jsonDoc.array(); + for (int i = 0; i < rootarry.size(); i++) { + QJsonObject subObj = rootarry.at(i).toObject(); + + ScheduleDateRangeInfo info; + //因为是预先定义好的JSON数据格式,所以这里可以这样读取 + if (subObj.contains("Date")) { + info.date = QDate::fromString(subObj.value("Date").toString(), "yyyy-MM-dd"); + } + if (subObj.contains("Jobs")) { + QJsonArray subarry = subObj.value("Jobs").toArray(); + for (int j = 0; j < subarry.size(); j++) { + QJsonObject ssubObj = subarry.at(j).toObject(); + info.vData.append(parsingScheduleDtailInfojsonID(ssubObj)); + } + } + out.append(info); + } + return true; +} + +bool CSchedulesDBus::QueryJobsWithRule(QDateTime starttime, QDateTime endtime, QString rule, QVector &out) +{ + QJsonObject qjson; + qjson.insert("Start", toconvertData(starttime)); + qjson.insert("End", toconvertData(endtime)); + qjson.insert("key", ""); + // 构建 JSON 文档 + QJsonDocument qdocument; + qdocument.setObject(qjson); + QByteArray qbyteArray = qdocument.toJson(QJsonDocument::Compact); + QString strJson(qbyteArray); + + QList argumentList; + argumentList << QVariant::fromValue(strJson); + argumentList << rule; + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("QueryJobsWithRule"), argumentList); + if (reply.type() != QDBusMessage::ReplyMessage) { + return false; + } + QDBusReply jobs = reply; + + if (!jobs.isValid()) + return false; + QJsonParseError json_error; + QJsonDocument jsonDoc(QJsonDocument::fromJson(jobs.value().toLocal8Bit(), &json_error)); + + if (json_error.error != QJsonParseError::NoError) { + return false; + } + + QJsonArray rootarry = jsonDoc.array(); + for (int i = 0; i < rootarry.size(); i++) { + QJsonObject subObj = rootarry.at(i).toObject(); + + ScheduleDateRangeInfo info; + //因为是预先定义好的JSON数据格式,所以这里可以这样读取 + if (subObj.contains("Date")) { + info.date = QDate::fromString(subObj.value("Date").toString(), "yyyy-MM-dd"); + } + if (subObj.contains("Jobs")) { + QJsonArray subarry = subObj.value("Jobs").toArray(); + for (int j = 0; j < subarry.size(); j++) { + QJsonObject ssubObj = subarry.at(j).toObject(); + info.vData.append(parsingScheduleDtailInfojsonID(ssubObj)); + } + } + out.append(info); + } + return true; +} + +bool CSchedulesDBus::GetTypes(QVector &out) +{ + QList argumentList; + //argumentList << QVariant::fromValue(jobId); + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetTypes"), argumentList); + if (reply.type() != QDBusMessage::ReplyMessage) { + return false; + } + QDBusReply jobs = reply; + + if (!jobs.isValid()) + return false; + QJsonParseError json_error; + QJsonDocument jsonDoc(QJsonDocument::fromJson(jobs.value().toLocal8Bit(), &json_error)); + + if (json_error.error != QJsonParseError::NoError) { + return false; + } + + QJsonArray rootarry = jsonDoc.array(); + for (int i = 0; i < rootarry.size(); i++) { + QJsonObject subObj = rootarry.at(i).toObject(); + out.append(parsingScheduleTypejson(subObj)); + } + return true; +} + +bool CSchedulesDBus::GetType(qint64 jobId, ScheduleType &out) +{ + QList argumentList; + argumentList << QVariant::fromValue(jobId); + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetType"), argumentList); + if (reply.type() != QDBusMessage::ReplyMessage) { + return false; + } + QDBusReply jobs = reply; + + if (!jobs.isValid()) + return false; + QJsonParseError json_error; + QJsonDocument jsonDoc(QJsonDocument::fromJson(jobs.value().toLocal8Bit(), &json_error)); + + if (json_error.error != QJsonParseError::NoError) { + return false; + } + + QJsonObject subObj = jsonDoc.object(); + out = parsingScheduleTypejson(subObj); + return true; +} + +qint64 CSchedulesDBus::CreateType(const ScheduleType &info) +{ + QList argumentList; + argumentList << QVariant::fromValue(createScheduleTypejson(info)); + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("CreateType"), argumentList); + if (reply.type() != QDBusMessage::ReplyMessage) { + return -1; + } + QDBusReply id = reply; + + return id.value(); +} + +bool CSchedulesDBus::DeleteType(qint64 jobId) +{ + QList argumentList; + argumentList << QVariant::fromValue(jobId); + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("DeleteType"), argumentList); + if (reply.type() != QDBusMessage::ReplyMessage) { + return false; + } + return true; +} + +bool CSchedulesDBus::UpdateType(const ScheduleType &info) +{ + QList argumentList; + argumentList << QVariant::fromValue(createScheduleTypejson(info)); + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("UpdateType"), argumentList); + if (reply.type() != QDBusMessage::ReplyMessage) { + return false; + } + return true; +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/dbus/schedulesdbus.h dde-calendar-5.7.0.23/schedule-plugin/src/dbus/schedulesdbus.h --- dde-calendar-5.7.0.4/schedule-plugin/src/dbus/schedulesdbus.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/dbus/schedulesdbus.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ + +/* + * This file was generated by qdbusxml2cpp version 0.8 + * Command line was: qdbusxml2cpp -c DCalendarDBus -p dcalendardbus com.deepin.api.LunarCalendar.xml + * + * qdbusxml2cpp is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * Do not edit! All changes made to it will be lost. + */ + +#ifndef SCHEDULESDBUS_H +#define SCHEDULESDBUS_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../data/schedulestructs.h" + +/* + * Proxy class for interface com.deepin.api.LunarCalendar + */ +class CSchedulesDBus : public QDBusAbstractInterface +{ + Q_OBJECT + + Q_SLOT void __propertyChanged__(const QDBusMessage &msg) + { + QList arguments = msg.arguments(); + if (3 != arguments.count()) + return; + QString interfaceName = msg.arguments().at(0).toString(); + if (interfaceName != "com.deepin.api.LunarCalendar") + return; + QVariantMap changedProps = qdbus_cast(arguments.at(1).value()); + foreach (const QString &prop, changedProps.keys()) { + const QMetaObject *self = metaObject(); + for (int i = self->propertyOffset(); i < self->propertyCount(); ++i) { + QMetaProperty p = self->property(i); + if (p.name() == prop) { + Q_EMIT p.notifySignal().invoke(this); + } + } + } + } + +public: + static inline const char *staticInterfaceName() + { + return "com.deepin.daemon.Calendar.Scheduler"; + } + +public: + CSchedulesDBus(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = nullptr); + + ~CSchedulesDBus(); + QString toconvertIGData(QDateTime date); + QDateTime fromconvertiIGData(QString str); + static QString createScheduleDtailInfojson(const ScheduleDtailInfo &info); + ScheduleDtailInfo parsingScheduleDtailInfojsonID(QJsonObject &obj); + +private: + QString createScheduleTypejson(const ScheduleType &info); + ScheduleType parsingScheduleTypejson(QJsonObject &object); + + static QString createScheduleRRule(const ScheduleDtailInfo &info); + void parsingScheduleRRule(QString str, ScheduleDtailInfo &info); + static QString createScheduleRemind(const ScheduleDtailInfo &info); + void parsingScheduleRemind(QString str, ScheduleDtailInfo &info); + static QString toconvertData(QDateTime date); + QDateTime fromconvertData(QString str); +public Q_SLOTS: // METHODS + + qint64 CreateJob(const ScheduleDtailInfo &info); + bool GetJobs(int startYear, int startMonth, int startDay, int endYear, int endMonth, int endDay, QVector &out); + bool GetJob(qint64 jobId, ScheduleDtailInfo &out); + bool UpdateJob(const ScheduleDtailInfo &info); + bool DeleteJob(qint64 jobId); + bool QueryJobs(QString key, QDateTime starttime, QDateTime endtime, QVector &out); + bool QueryJobs(QString key, QDateTime starttime, QDateTime endtime, QString &out); + bool QueryJobsWithLimit(QDateTime starttime, QDateTime endtime, qint32 maxNum, QVector &out); + bool QueryJobsWithRule(QDateTime starttime, QDateTime endtime, QString rule, QVector &out); + + bool GetTypes(QVector &out); + bool GetType(qint64 jobId, ScheduleType &out); + qint64 CreateType(const ScheduleType &info); + bool DeleteType(qint64 jobId); + bool UpdateType(const ScheduleType &info); + +Q_SIGNALS: // SIGNALS + // begin property changed signals +}; +#endif diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/globaldef.h dde-calendar-5.7.0.23/schedule-plugin/src/globaldef.h --- dde-calendar-5.7.0.4/schedule-plugin/src/globaldef.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/globaldef.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,186 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef GLOBALDEF_H +#define GLOBALDEF_H + +#define PLUGIN_TITLE_NAME "日历" + +#define LOG_FILENAME "/home/uniontech/.cache/deepin/dde-calendar/scheduleplugin.log" + +#define SERVICE_NAME "scheduleX" + +#define DBUS_SERVICE "com.deepin.daemon.Calendar" +#define DBUS_PATCH "/com/deepin/daemon/Calendar/Scheduler" + +#define DBUS_CALENDAR_SERVICE "com.deepin.Calendar" +#define DBUS_CALENDAR_PATCH "/com/deepin/Calendar" +#define DBUS_CALENDAR_INTFACE "com.deepin.Calendar" + +#define NEW_SCHEDULE "新建日程" + +#define DATETIME_FRAME "yyyyMMdd hh:mm:ss" +//日期格式 +#define DATEFORMAT "yyyy-MM-dd" +//时间格式 +#define TIMEFORMAT "hh:mm:ss" + + +#define PROCESS_OPEN_CALENDAR "dbus-send --print-reply --dest=com.deepin.Calendar /com/deepin/Calendar com.deepin.Calendar.RaiseWindow" + +//日程重复类型 +//每天 +#define DBUS_RRUL_EVED "FREQ=DAILY" +//每周 +#define DBUS_RRUL_EVEW "FREQ=WEEKLY" +//每月 +#define DBUS_RRUL_EVEM "FREQ=MONTHLY" +//每年 +#define DBUS_RRUL_EVEY "FREQ=YEARLY" +//每个工作日 +#define DBUS_RRUL_WORK "FREQ=DAILY;BYDAY=MO,TU,WE,TH,FR" + +//日程json关键字 +#define JSON_CREATE "CREATE" +#define JSON_VIEW "VIEW" +#define JSON_CANCEL "CANCEL" +#define JSON_CHANGE "CHANGE" +#define JSON_NO_INTENT "NO_INTENT" +#define JSON_YES_INTENT "YES_INTENT" +//日程json槽位关键字 +#define JSON_NAME "name" +#define JSON_CONTENT "content" +#define JSON_REPEAT "repeat" +#define JSON_DATETIME "datetime" +#define JSON_VALUE "value" +#define JSON_NORMVALUE "normValue" +#define JSON_PROPERTY "property" +#define JSON_NEXT "next" +#define JSON_LAST "last" +#define JSON_FROMDATETIME "fromTime" +#define JSON_TODATETIME "toTime" +#define JSON_TOPLACE "toPlace" +#define JSON_ALL "all" +#define JSON_THIS "this" +#define JSON_POSRANK_OFFSET "posRank.offset" + +#define JOSN_DATE_DELIMITER "/" +#define JSON_DATETIME_DELIMITER "T" +//每天多少秒 +#define ONE_DAY_SECS 60 * 60 * 24 + +//widget show +#define CONFIRM_BUTTON_STRING "确定" +#define CANCEL_BUTTON_STRING "取消" +#define DELETE_BUTTON_STRING "删除日程" +#define DELETEALL_BUTTON_STRING "删除全部" +#define ONLY_DELETE_THIS_BUTTON_STRING "仅删除此日程" + +#define CHANGE_ALL_BUTTON_STRING "修改全部" +#define CHANGE_ONLYL_BUTTON_STRING "仅修改此日程" + + +#define CREATE_ERR_TTS "新建功能不支持此说法" +#define CANCEL_ERR_TTS "查询功能不支持此说法" +//没有对应日程的回复语 +#define QUERY_ERR_TTS "您还没有日程提醒,无法寻找对应的日程!" +//修改日程初始状态错误回复语 +#define CHANGE_INI_ERR_TSS "当前场景不支持这个操作哦。请问您要将什么日程修改到什么时间或修改到什么内容?" +//修改日程询问回复语 +#define CHANGE_TO_TTS "请问您要将此日程修改到什么时间或修改到什么内容?" +//错误操作回复语 +#define G_ERR_TTS "当前场景不支持这个操作哦。" +//取消删除日程回复语 +#define CANCEL_DELETION_TTS "已为您取消删除日程。" +//确认删除日程回复语 +#define CONFIRM_DELETION_TTS "已为您删除日程。" +//取消修改日程回复语 +#define CANCEL_CHANGE_TTS "已为您取消修改日程。" +//确认修改日程回复语 +#define CONFIRM_CHANGE_TTS "已为您修改日程。" +//没有日程提醒回复语 +#define NO_SCHEDULE_TTS "您还没有日程提醒。" +//删除重复日程询问回复语 +#define REPEST_SCHEDULE_CANCEL_TTS "该日程是循环的日程,请问是删除当前日程还是所有日程?" +//删除普通日程询问回复语 +#define CONFIRM_SCHEDULE_CANCEL_TTS "我要帮您取消这个日程吗?操作后将在日历中同步删除。" +//删除选择日程回复语 +#define CANCEL_SELECT_TTS "这是您的所有日程,您要删除哪一个日程?" +//选择修改回复语 +#define SELECT_CHANGE_TTS "这是您的所有日程,您要修改哪一个日程?" +//修改重复日程询问回复语 +#define REPEST_SCHEDULE_CHANGE_TTS "该日程是循环的日程,请问是修改当前日程还是所有日程?" +//修改普通日程询问回复语 +#define CONFIRM_SCHEDULE_CHANGE_TTS "我要帮您修改这个日程吗?操作后将在日历中同步修改。" +//修改到的时间不在规定时间范围内 +#define CHANGE_TIME_OUT_TTS "修改日程的时间范围为未来半年哦。" +#define ALL_DAY "全天" +//修改或取消时间不在未来半年的回复语 +#define OVERTIME_TTS "只能取消或修改未来半年的日程!" +//新建日程开始时间不在规定时间范围内 +#define CREATE_TIME_OUT_TTS "只能创建未来半年的日程" +//新建每周末提醒的日程的回复语 +#define EVERY_WEEKEND_TTS "好的,每周六到周日的%1我都会提醒您。" +//跨天日程,开始日期小于当前时间的回复语 +#define BEGINDATETIME_LATER_THAN_CURRENTDATETIME_ACROSS_THE_DAY_TTS "好的,%1我会提醒您。" +//查询日期过期 +#define VIEW_DATE_IS_OVERDUE_TTS "抱歉,不能查询过期的提醒" +//查询日程时间不再规定范围内 +#define VIEW_DATETIME_OUT_TTS "只能查询未来半年的日程" +//没有查询到日程 +#define NO_SCHEDULE_VIEWED_TTS "没有找到对应的日程" +//查找到n个日程 +#define VIEW_SCHEDULE_TTS "找到%1个日程" +//半年天数 +#define MAXIMUM_DAYS_IN_THE_FUTURE 183 +//不带窗口的回复宏定义 +#define REPLY_ONLY_TTS(reply, msgtts, dsptts, isEnd) \ + reply.setReplyType(Reply::RT_STRING_TTS | Reply::RT_STRING_DISPLAY); \ + reply.ttsMessage(msgtts); \ + reply.displayMessage(dsptts); \ + reply.code(0); \ + reply.setShouldEndSession(isEnd); \ + +//带窗口的回复宏定义 +#define REPLY_WIDGET_TTS(reply, widget, msgtts, dsptts, isEnd) \ + reply.setReplyType(Reply::RT_INNER_WIDGET | Reply::RT_STRING_TTS | Reply::RT_STRING_DISPLAY); \ + reply.setReplyWidget(widget); \ + reply.ttsMessage(msgtts); \ + reply.displayMessage(dsptts); \ + reply.code(0); \ + reply.setShouldEndSession(isEnd); \ + +//未来半年开始时间和结束时间 +#define TIME_FRAME_IN_THE_NEXT_SIX_MONTHT \ + QDateTime beginTime = QDateTime::currentDateTime(); \ + QDateTime endTime = QDateTime::currentDateTime().addDays(180); + +//modifyScheduleItem +#define MODIFY_ITEM_HEIGHT 48 +//item圆角 +#define ITEM_RADIUS 8 + +//最多显示10个item +#define ITEM_SHOW_NUM 10 + +#define OPENCALENDAR_WIDGET_TITLE "在“日历”中查看所有%1个结果..." +#define OPENCALENDAR_WDIGET_HEIGHT 17 + +#endif // GLOBALDEF_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/interface/reply.h dde-calendar-5.7.0.23/schedule-plugin/src/interface/reply.h --- dde-calendar-5.7.0.4/schedule-plugin/src/interface/reply.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/interface/reply.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,205 @@ +#ifndef REPLY_H +#define REPLY_H + +#include +#include +#include +#include +enum IRet { + ERR_SUCCESS = (0), /* 一切正常 */ + ERR_FAIL = (-1), /* 常规错误 */ + ERR_PARAM = (-2), /* 函数入参异常 */ + ERR_CONFIG = (-3), /* 配置错误 */ + ERR_NOT_FOUND = (-4), /* 未找到对应项 */ + + ERR_UNSUPPORT_SERVICE = (-20), /* 不支持的服务 */ + ERR_UNSUPPORT_INTENT = (-21), /* 不支持的操作 */ + ERR_UNSUPPORT_SLOTS = (-22), /* 不支持的槽位 */ + ERR_UNSUPPORT_ABILITY = (-23), /* 不支持的能力 */ + ERR_UNSUPPORT_EXPRESS = (-24), /* 不支持的说法 */ + + ERR_CLOUD_SERVICE = (-100), /* 云端服务内容异常 */ + ERR_CLOUD_INTENT = (-101), /* 云端意图内容异常 */ + ERR_CLOUD_SLOTS = (-102) /* 云端参数内容异常 */ +}; +class Reply +{ +public: + enum ReplyType { + RT_NONE = 0, + RT_STRING_DISPLAY = 1, + RT_STRING_TTS = 2, + RT_POP_WIDGET = 4, + RT_INNER_WIDGET = 8 + }; + +public: + Reply() + : messageCode(ERR_FAIL) + , messageDisplay() + , messageTTS() + , m_widget(nullptr) + , m_replyType(RT_NONE) + , m_shouldEndSession(true) + { + } + + Reply(int msgCode, const QString &message, int type = RT_STRING_TTS | RT_STRING_DISPLAY) + : messageCode(msgCode) + , messageDisplay(message) + , messageTTS(message) + , m_widget(nullptr) + , m_replyType(type) + , m_shouldEndSession(true) + { + } + + Reply(int msgCode, const QString &msgDisplay, const QString &msgSynthesis, int type, QWidget *parent) + : messageCode(msgCode) + , messageDisplay(msgDisplay) + , messageTTS(msgSynthesis) + , m_widget(parent) + , m_replyType(type) + , m_shouldEndSession(true) + + { + } + + Reply(const Reply &reply) + : messageCode(reply.messageCode) + , messageDisplay(reply.messageDisplay) + , messageTTS(reply.messageTTS) + , m_widget(reply.m_widget) + , m_replyType(reply.m_replyType) + , m_shouldEndSession(reply.m_shouldEndSession) + { + } + + Reply &operator=(const Reply &reply) + { + this->messageCode = reply.messageCode; + this->messageDisplay = reply.messageDisplay; + this->messageTTS = reply.messageTTS; + this->m_widget = reply.m_widget; + this->m_replyType = reply.m_replyType; + m_shouldEndSession = reply.m_shouldEndSession; + return *this; + } + + int code() + { + if (messageCode.isValid()) { + return messageCode.toInt(); + } else { + return ERR_SUCCESS; + } + } + + void code(int msgCode) + { + this->messageCode = msgCode; + } + + const QString displayMessage() + { + if (messageDisplay.isValid()) { + return messageDisplay.toString(); + } else { + return ""; + } + } + + void displayMessage(const QString &msgDisplay) + { + this->messageDisplay = msgDisplay; + } + + const QString ttsMessage() + { + if (messageTTS.isValid()) { + return messageTTS.toString(); + } else { + return ""; + } + } + + void ttsMessage(const QString &msgSynthesis) + { + this->messageTTS = msgSynthesis; + } + void update(int msgCode) + { + this->messageCode = msgCode; + } + void update(int msgCode, const QString &message, int replyType = RT_STRING_TTS | RT_STRING_DISPLAY) + { + this->messageCode = msgCode; + this->messageDisplay = message; + this->messageTTS = message; + this->m_replyType = replyType; + } + + void update(int msgCode, const QString &msgDisplay, const QString &msgSynthesis, int replyType = RT_STRING_TTS | RT_STRING_DISPLAY) + { + this->messageCode = msgCode; + this->messageDisplay = msgDisplay; + this->messageTTS = msgSynthesis; + this->m_replyType = replyType; + } + + operator int() { return messageCode.toInt(); } + + bool isCodeValid() + { + return messageCode.isValid(); + } + + bool isDisplayMessageValid() + { + return messageDisplay.isValid(); + } + + bool isSynthesisMessageValid() + { + return messageTTS.isValid(); + } + + QWidget *getReplyWidget() + { + return m_widget; + } + + void setReplyWidget(QWidget *w) + { + m_widget = w; + } + + int getReplyType() + { + return m_replyType; + } + void setReplyType(int type) + { + m_replyType = type; + } + + int getShouldEndSession() + { + return m_shouldEndSession; + } + + void setShouldEndSession(bool bShouldEndSession) + { + m_shouldEndSession = bShouldEndSession; + } + +private: + QVariant messageCode; + QVariant messageDisplay; + QVariant messageTTS; + QWidget *m_widget; + int m_replyType; + bool m_shouldEndSession; +}; + +#endif // REPLY_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/interface/service.h dde-calendar-5.7.0.23/schedule-plugin/src/interface/service.h --- dde-calendar-5.7.0.4/schedule-plugin/src/interface/service.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/interface/service.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,32 @@ +#ifndef SERVICE_H +#define SERVICE_H +#include +#include "reply.h" + +/* 服务优先级: + * SeriesIgnore表示该service可忽略 + * ServicePriorityPatch表示服务修复代码,直接覆盖旧的服务 + */ +enum ServicePriority { + ServicePriorityIgnore = -10, + ServicePriorityLow = 0, + SerivcePriorityNormal = 10, + SerivcePriorityHigh = 50, + SerivcePriorityPatch = 127 +}; + +class IService : public QObject // IReplyHandler +{ + Q_OBJECT +public: + virtual ~IService() {} + virtual QString serviceName() = 0; + virtual int servicePriority() = 0; + virtual bool canHandle(const QString &s) = 0; + virtual IRet service(const QString &semantic) = 0; + virtual Reply &getServiceReply() = 0; +signals: + void signalSendShowMessage(Reply reply); +}; + +#endif // SERVICE_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/interface/systemsemanticplugin.h dde-calendar-5.7.0.23/schedule-plugin/src/interface/systemsemanticplugin.h --- dde-calendar-5.7.0.4/schedule-plugin/src/interface/systemsemanticplugin.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/interface/systemsemanticplugin.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,49 @@ +#ifndef SYSTEM_SEMANTIC_PLUGIN_H +#define SYSTEM_SEMANTIC_PLUGIN_H +#include +#include "service.h" + +#if defined(SYSTEM_SEMANTIC_LIBRARY) +#define SYSTEMSEMANTICSHARED_EXPORT Q_DECL_EXPORT +#else +#define SYSTEMSEMANTICSHARED_EXPORT Q_DECL_IMPORT +#endif +#define AIAPluginProtocolVersion 1 +class SYSTEMSEMANTICSHARED_EXPORT IServicePlugin +{ + typedef std::function replyCallback; + +public: + virtual ~IServicePlugin() {} + + virtual int init() = 0; /* 加载配置,初始化整个插件或服务 */ + virtual void uninit() = 0; /* 插件逆向初始化 */ + + virtual QStringList getSupportService() = 0; + virtual IService *createService(const QString &service) = 0; /* 获取一个服务,为多线程考量新建服务 */ + virtual void releaseService(IService *service) = 0; /* 释放一个服务 */ + virtual bool needRunInDifferentThread() + { + return true; /*当前线程是否需要在单独的线程中运行*/ + } + virtual bool isAutoDetectSession() + { + return true; /*是否自动检测多轮对话*/ + } + virtual int getPluginProtocolVersion() + { + return AIAPluginProtocolVersion; + } + virtual void setMessageHandle(replyCallback callback) + { + m_messageHandle = callback; + } + +protected: + replyCallback m_messageHandle; +}; + +#define PluginInterface_iid "com.deepin.iflytek.aiassistant.3" +Q_DECLARE_INTERFACE(IServicePlugin, PluginInterface_iid) + +#endif // SYSTEM_SEMANTIC_PLUGIN_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/scheduleplugin.cpp dde-calendar-5.7.0.23/schedule-plugin/src/scheduleplugin.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/scheduleplugin.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/scheduleplugin.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,93 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "scheduleplugin.h" + +#include "scheduleservice.h" +#include "globaldef.h" +#include "task/schedulemanagetask.h" + +Scheduleplugin::Scheduleplugin(QObject *parent) +{ + Q_UNUSED(parent); +} + +Scheduleplugin::~Scheduleplugin() +{ + ScheduleManageTask::releaseInstance(); +} + +int Scheduleplugin::init() +{ + return 0; +} + +void Scheduleplugin::uninit() +{ +} + +QStringList Scheduleplugin::getSupportService() +{ + return QStringList {SERVICE_NAME}; +} + +IService *Scheduleplugin::createService(const QString &service) +{ + if (!getSupportService().contains(service)) { + return nullptr; + } + QMutexLocker lock(&m_ServiceLock); + auto pService = new scheduleservice(); + connect(pService->getScheduleManageTask(), &ScheduleManageTask::signaleSendMessage, + this, &Scheduleplugin::slotSendMessage, Qt::UniqueConnection); + m_ServiceSet.insert(pService); + return pService; +} + +void Scheduleplugin::releaseService(IService *service) +{ + QMutexLocker lock(&m_ServiceLock); + for (auto iter = m_ServiceSet.begin(); iter != m_ServiceSet.end(); iter++) { + if (service && service == *iter) { + m_ServiceSet.erase(iter); + break; + } + } + if (service) { + delete service; + } +} + +bool Scheduleplugin::needRunInDifferentThread() +{ + return false; +} + +bool Scheduleplugin::isAutoDetectSession() +{ + //设置为不自动检测是否多论 + return false; +} + +void Scheduleplugin::slotSendMessage(Reply reply) +{ + if (this->m_messageHandle) + this->m_messageHandle(this, reply); +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/scheduleplugin.h dde-calendar-5.7.0.23/schedule-plugin/src/scheduleplugin.h --- dde-calendar-5.7.0.4/schedule-plugin/src/scheduleplugin.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/scheduleplugin.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,59 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef SCHEDULEPLUGIN_H +#define SCHEDULEPLUGIN_H + +#include "interface/systemsemanticplugin.h" +#include "interface/reply.h" + +#include + +class Scheduleplugin : public QObject + , public IServicePlugin +{ + Q_OBJECT + Q_INTERFACES(IServicePlugin) + Q_PLUGIN_METADATA(IID PluginInterface_iid) +public: + explicit Scheduleplugin(QObject *parent = nullptr); + ~Scheduleplugin() override; + + int init() override; + void uninit() override; + + QStringList getSupportService() override; + IService *createService(const QString &service) override; + void releaseService(IService *service) override; + bool needRunInDifferentThread() override; + /** + * @brief isAutoDetectSession 是否自动检测多轮对话 + * @return true 检测 false不检测由插件设置 + */ + bool isAutoDetectSession() override; +public slots: + void slotSendMessage(Reply reply); + +private: + QSet m_ServiceSet; + QMutex m_ServiceLock; +}; + +#endif // SCHEDULEPLUGIN_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/scheduleservice.cpp dde-calendar-5.7.0.23/schedule-plugin/src/scheduleservice.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/scheduleservice.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/scheduleservice.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,72 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "scheduleservice.h" + +#include "globaldef.h" +#include "task/schedulemanagetask.h" +#include "task/semanticanalysistask.h" + +scheduleservice::scheduleservice() +{ +} + +scheduleservice::~scheduleservice() +{ +} + +QString scheduleservice::serviceName() +{ + return SERVICE_NAME; +} + +int scheduleservice::servicePriority() +{ + return 0; +} + +bool scheduleservice::canHandle(const QString &s) +{ + Q_UNUSED(s); + return true; +} + +IRet scheduleservice::service(const QString &semantic) +{ + //解析云端返回的数据,进行业务处理 + QString str = semantic; + semanticAnalysisTask task; + if (!task.resolveTaskJson(str)) { + return ERR_FAIL; + } + ScheduleManageTask::getInstance()->process(task); + return ERR_SUCCESS; +} + +Reply &scheduleservice::getServiceReply() +{ + m_reply = ScheduleManageTask::getInstance()->getReply(); + return m_reply; +} + +ScheduleManageTask *scheduleservice::getScheduleManageTask() const +{ + return ScheduleManageTask::getInstance(); +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/scheduleservice.h dde-calendar-5.7.0.23/schedule-plugin/src/scheduleservice.h --- dde-calendar-5.7.0.4/schedule-plugin/src/scheduleservice.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/scheduleservice.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,44 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef SCHEDULESERVICE_H +#define SCHEDULESERVICE_H + +#include "interface/service.h" + +class ScheduleManageTask; +class scheduleservice : public IService +{ + Q_OBJECT +public: + scheduleservice(); + ~scheduleservice() override; + QString serviceName() override; + int servicePriority() override; + bool canHandle(const QString &s) override; + IRet service(const QString &semantic) override; + Reply &getServiceReply() override; + ScheduleManageTask *getScheduleManageTask() const; + +private: + Reply m_reply; +}; + +#endif // SCHEDULESERVICE_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/state/confirwfeedbackstate.cpp dde-calendar-5.7.0.23/schedule-plugin/src/state/confirwfeedbackstate.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/state/confirwfeedbackstate.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/state/confirwfeedbackstate.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,62 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "confirwfeedbackstate.h" + +#include "../globaldef.h" +#include "../task/schedulebasetask.h" +#include "../data/clocaldata.h" +#include "../data/changejsondata.h" + +confirwFeedbackState::confirwFeedbackState(CSchedulesDBus *dbus, scheduleBaseTask *task) + : scheduleState(dbus, task) +{ +} + +Reply confirwFeedbackState::getReplyByIntent(bool isOK) +{ + return m_Task->confirmInfo(isOK); +} + +scheduleState::Filter_Flag confirwFeedbackState::eventFilter(const JsonData *jsonData) +{ + if (jsonData->getPropertyStatus() == JsonData::NEXT) { + return Fileter_Init; + } + if (jsonData->getPropertyStatus() == JsonData::LAST + || jsonData->offset() > 0) { + return Fileter_Err; + } + Filter_Flag result = changeDateErrJudge(jsonData,Fileter_Init); + return result; +} + +Reply confirwFeedbackState::ErrEvent() +{ + Reply reply; + REPLY_ONLY_TTS(reply, G_ERR_TTS, G_ERR_TTS, true) + return reply; +} + +Reply confirwFeedbackState::normalEvent(const JsonData *jsonData) +{ + Q_UNUSED(jsonData); + return m_Task->confirwScheduleHandle(m_localData->SelectInfo()); +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/state/confirwfeedbackstate.h dde-calendar-5.7.0.23/schedule-plugin/src/state/confirwfeedbackstate.h --- dde-calendar-5.7.0.4/schedule-plugin/src/state/confirwfeedbackstate.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/state/confirwfeedbackstate.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,38 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef CONFIRWFEEDBACKSTATE_H +#define CONFIRWFEEDBACKSTATE_H + +#include "schedulestate.h" + +class confirwFeedbackState : public scheduleState +{ +public: + confirwFeedbackState(CSchedulesDBus *dbus, scheduleBaseTask *task); + Reply getReplyByIntent(bool isOK) override; + +protected: + Filter_Flag eventFilter(const JsonData *jsonData) override; + Reply ErrEvent() override; + Reply normalEvent(const JsonData *jsonData) override; +}; + +#endif // CONFIRWFEEDBACKSTATE_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/state/getchangedatastate.cpp dde-calendar-5.7.0.23/schedule-plugin/src/state/getchangedatastate.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/state/getchangedatastate.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/state/getchangedatastate.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,97 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "getchangedatastate.h" + +#include "../globaldef.h" +#include "../data/changejsondata.h" +#include "../task/changescheduletask.h" + +getChangeDataState::getChangeDataState(CSchedulesDBus *dbus, scheduleBaseTask *task) + :scheduleState(dbus,task) +{ + +} + +Reply getChangeDataState::getReplyByIntent(bool isOK) +{ + Q_UNUSED(isOK); + return ErrEvent(); +} + +scheduleState::Filter_Flag getChangeDataState::eventFilter(const JsonData *jsonData) +{ + //如果语义包含全部关键字则为修改初始状态 + if (jsonData->getPropertyStatus() == JsonData::ALL + //如果语义包含下一个关键字则为修改初始状态 + || jsonData->getPropertyStatus() == JsonData::NEXT + || jsonData->isVaild() + //如果语义包含时间则为修改初始状态 + || jsonData->getDateTime().suggestDatetime.size()>0 + // 如果语义包含内容则为修改初始状态 + || !jsonData->TitleName().isEmpty() + //如果语义包含重复类型则为修改初始状态 + || jsonData->getRepeatStatus() != JsonData::NONE) { + return Filter_Flag::Fileter_Init; + } + if (jsonData->getPropertyStatus() == JsonData::LAST) + return Fileter_Err; + if (jsonData->offset() > 0) { + return Fileter_Err; + } + //类型转换 + JsonData *queryData = const_cast(jsonData); + changejsondata *mchangeJsonData = dynamic_cast(queryData); + //如果存在form信息则表示一个新的修改 + if(mchangeJsonData->fromDateTime().suggestDatetime.size() > 0){ + return Fileter_Init; + } + //如果存在修改的信息则为正常状态 + if (mchangeJsonData->toDateTime().suggestDatetime.size() > 0 + || !mchangeJsonData->toPlaceStr().isEmpty()) { + return Fileter_Normal; + }else { + return Fileter_Err; + } +} + +Reply getChangeDataState::ErrEvent() +{ + Reply reply; + //返回错误输入的回复语 + REPLY_ONLY_TTS(reply, G_ERR_TTS, G_ERR_TTS, true) + return reply; +} + +Reply getChangeDataState::normalEvent(const JsonData *jsonData) +{ + //类型转换 + JsonData *queryData = const_cast(jsonData); + changejsondata *mchangeJsonData = dynamic_cast(queryData); + //如果有修改时间的信息则赋值 + if(mchangeJsonData->toDateTime().suggestDatetime.size()>0){ + m_localData->setToTime(mchangeJsonData->toDateTime().dateTime); + } + //如果有修改内容的信息则获取 + if(!mchangeJsonData->toPlaceStr().isEmpty()){ + m_localData->setToTitleName(mchangeJsonData->toPlaceStr()); + } + return m_Task->getReplyBySelectSchedule(m_localData->SelectInfo()); +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/state/getchangedatastate.h dde-calendar-5.7.0.23/schedule-plugin/src/state/getchangedatastate.h --- dde-calendar-5.7.0.4/schedule-plugin/src/state/getchangedatastate.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/state/getchangedatastate.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,57 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef GETCHANGEDATASTATE_H +#define GETCHANGEDATASTATE_H + +#include "schedulestate.h" +/** + * @brief The getChangeDataState class 获取修改信息状态 + */ +class getChangeDataState : public scheduleState +{ +public: + getChangeDataState(CSchedulesDBus *dbus, scheduleBaseTask *task); + /** + * @brief getReplyByIntent 根据意图判断回复 + * @param isOK 确认 或 取消 + * @return 回复 + */ + Reply getReplyByIntent(bool isOK) override; +protected: + /** + * @brief eventFilter 根据json过滤事件 + * @param jsonData json对象 + * @return 返回过滤结果 初始化,错误 或正常 + */ + Filter_Flag eventFilter(const JsonData *jsonData) override; + /** + * @brief ErrEvent 错误事件处理 + * @return 给助手的回复 + */ + Reply ErrEvent() override; + /** + * @brief normalEvent 正常事件处理 + * @param jsonData 需要处理的json数据 + * @return 给助手的回复 + */ + Reply normalEvent(const JsonData *jsonData) override; +}; +#endif // GETCHANGEDATASTATE_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/state/queryschedulestate.cpp dde-calendar-5.7.0.23/schedule-plugin/src/state/queryschedulestate.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/state/queryschedulestate.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/state/queryschedulestate.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,79 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "queryschedulestate.h" +#include "../task/queryscheduleproxy.h" +#include "../task/schedulebasetask.h" +#include "../data/schedulestructs.h" +#include "../data/changejsondata.h" +#include "../globaldef.h" +#include "../data/clocaldata.h" + +queryScheduleState::queryScheduleState(CSchedulesDBus *dbus, scheduleBaseTask *task) + : scheduleState(dbus, task) +{ +} + +Reply queryScheduleState::getReplyByIntent(bool isOK) +{ + Q_UNUSED(isOK); + return ErrEvent(); +} + +Reply queryScheduleState::ErrEvent() +{ + Reply reply; + REPLY_ONLY_TTS(reply, CHANGE_INI_ERR_TSS, CHANGE_INI_ERR_TSS, false) + return reply; +} + +Reply queryScheduleState::normalEvent(const JsonData *jsonData) +{ + QVector m_scheduleInfo {}; + JsonData *queryData = const_cast(jsonData); + queryScheduleProxy m_querySchedule(queryData, m_dbus); + m_scheduleInfo = m_querySchedule.querySchedule(); + if (m_querySchedule.getTimeIsExpired()) { + return m_Task->overdueScheduleProcess(); + } else { + changejsondata *mchangeJsonData = dynamic_cast(queryData); + if (mchangeJsonData != nullptr) { + if (m_localData == nullptr) + m_localData = new CLocalData(); + if (mchangeJsonData->toDateTime().suggestDatetime.size() > 0) { + m_localData->setToTime(mchangeJsonData->toDateTime().dateTime); + } + if (!mchangeJsonData->toPlaceStr().isEmpty()) + m_localData->setToTitleName(mchangeJsonData->toPlaceStr()); + } + return m_Task->getFeedbackByQuerySchedule(m_scheduleInfo); + } +} + +scheduleState::Filter_Flag queryScheduleState::eventFilter(const JsonData *jsonData) +{ + if (jsonData->getPropertyStatus() == JsonData::LAST + || jsonData->getPropertyStatus() == JsonData::PRO_THIS) + return Fileter_Err; + if (jsonData->offset() > -1 && jsonData->getPropertyStatus() == JsonData::PRO_NONE) + return Fileter_Err; + Filter_Flag result = changeDateErrJudge(jsonData,Fileter_Normal); + return result; +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/state/queryschedulestate.h dde-calendar-5.7.0.23/schedule-plugin/src/state/queryschedulestate.h --- dde-calendar-5.7.0.4/schedule-plugin/src/state/queryschedulestate.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/state/queryschedulestate.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,40 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef QUERYSCHEDULESTATE_H +#define QUERYSCHEDULESTATE_H + +#include "schedulestate.h" + +class queryScheduleState : public scheduleState +{ +public: + queryScheduleState(CSchedulesDBus *dbus, scheduleBaseTask *task); + Reply getReplyByIntent(bool isOK) override; + +protected: + Filter_Flag eventFilter(const JsonData *jsonData) override; + Reply ErrEvent() override; + Reply normalEvent(const JsonData *jsonData) override; + +protected: +}; + +#endif // QUERYSCHEDULESTATE_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/state/repeatfeedbackstate.cpp dde-calendar-5.7.0.23/schedule-plugin/src/state/repeatfeedbackstate.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/state/repeatfeedbackstate.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/state/repeatfeedbackstate.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,81 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "repeatfeedbackstate.h" +#include "../globaldef.h" +#include "../task/schedulebasetask.h" +#include "../data/clocaldata.h" +#include "../data/changejsondata.h" + +repeatfeedbackstate::repeatfeedbackstate(CSchedulesDBus *dbus, scheduleBaseTask *task) + : scheduleState(dbus, task) +{ +} + +Reply repeatfeedbackstate::getReplyByIntent(bool isOK) +{ + if (isOK) { + Q_UNUSED(isOK) + Reply reply; + REPLY_ONLY_TTS(reply, G_ERR_TTS, G_ERR_TTS, true) + return reply; + } else { + return m_Task->InitState(nullptr); + } +} + +scheduleState::Filter_Flag repeatfeedbackstate::eventFilter(const JsonData *jsonData) +{ + if (jsonData->getPropertyStatus() == JsonData::NEXT + //如果语义包含时间则为修改初始状态 + || jsonData->getDateTime().suggestDatetime.size()>0 + // 如果语义包含内容则为修改初始状态 + || !jsonData->TitleName().isEmpty() + //如果语义包含重复类型则为修改初始状态 + || jsonData->getRepeatStatus() != JsonData::NONE) { + return Fileter_Init; + } + if (jsonData->getPropertyStatus() == JsonData::ALL + || jsonData->getPropertyStatus() == JsonData::PRO_THIS) { + return Fileter_Normal; + } + if (jsonData->getPropertyStatus() == JsonData::LAST + || jsonData->offset() > 0) { + return Fileter_Err; + } + Filter_Flag result = changeDateErrJudge(jsonData,Fileter_Init); + return result; +} + +Reply repeatfeedbackstate::ErrEvent() +{ + Reply reply; + REPLY_ONLY_TTS(reply, G_ERR_TTS, G_ERR_TTS, true) + return reply; +} + +Reply repeatfeedbackstate::normalEvent(const JsonData *jsonData) +{ + bool isOnlyOne = true; + if (jsonData->getPropertyStatus() == JsonData::ALL) { + isOnlyOne = false; + } + return m_Task->repeatScheduleHandle(m_localData->SelectInfo(), isOnlyOne); +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/state/repeatfeedbackstate.h dde-calendar-5.7.0.23/schedule-plugin/src/state/repeatfeedbackstate.h --- dde-calendar-5.7.0.4/schedule-plugin/src/state/repeatfeedbackstate.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/state/repeatfeedbackstate.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,37 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef REPEATFEEDBACKSTATE_H +#define REPEATFEEDBACKSTATE_H +#include "schedulestate.h" + +class repeatfeedbackstate : public scheduleState +{ +public: + repeatfeedbackstate(CSchedulesDBus *dbus, scheduleBaseTask *task); + Reply getReplyByIntent(bool isOK) override; + +protected: + Filter_Flag eventFilter(const JsonData *jsonData) override; + Reply ErrEvent() override; + Reply normalEvent(const JsonData *jsonData) override; +}; + +#endif // REPEATFEEDBACKSTATE_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/state/schedulestate.cpp dde-calendar-5.7.0.23/schedule-plugin/src/state/schedulestate.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/state/schedulestate.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/state/schedulestate.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,107 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "schedulestate.h" + +#include "../task/schedulebasetask.h" +#include "../data/changejsondata.h" + +scheduleState::scheduleState(CSchedulesDBus *dbus, scheduleBaseTask *task) + : m_dbus(dbus) + , m_Task(task) +{ +} + +scheduleState::~scheduleState() +{ + if (m_localData != nullptr) + delete m_localData; +} + +Reply scheduleState::process(const JsonData *jsonData) +{ + Reply reply; + switch (eventFilter(jsonData)) { + case Fileter_Err: { + reply = ErrEvent(); + } break; + case Fileter_Normal: { + reply = normalEvent(jsonData); + } break; + case Fileter_Init: { + reply = initEvent(jsonData); + } break; + } + return reply; +} + +void scheduleState::setNextState(scheduleState *nextState) +{ + m_nextState = nextState; +} + +scheduleState *scheduleState::getNextState() const +{ + return m_nextState; +} + +void scheduleState::setLocalData(CLocalData *localData) +{ + if (m_localData == localData) { + return; + } + if (m_localData != nullptr) { + delete m_localData; + m_localData = nullptr; + } + if (localData == nullptr) + return; + m_localData = localData; +} + +CLocalData *scheduleState::getLocalData() const +{ + return m_localData; +} + +Reply scheduleState::initEvent(const JsonData *jsonData) +{ + return m_Task->InitState(jsonData); +} + +scheduleState::Filter_Flag scheduleState::changeDateErrJudge(const JsonData *jsonData, const scheduleState::Filter_Flag &defaultflag) +{ + Filter_Flag resultFlag {defaultflag}; + //如果只有修改信息没有被修改信息返回错误 + JsonData *queryData = const_cast(jsonData); + changejsondata *mchangeJsonData = dynamic_cast(queryData); + if (mchangeJsonData != nullptr) { + //是否含有修改信息 + bool hasChangeToData = !mchangeJsonData->toPlaceStr().isEmpty()|| + mchangeJsonData->toDateTime().suggestDatetime.size() >0; + //是否不包含需要修改的信息 + bool noChangeDate = mchangeJsonData->fromDateTime().suggestDatetime.size() == 0 + &&mchangeJsonData->TitleName().isEmpty(); + if (hasChangeToData &&noChangeDate ) { + resultFlag = Filter_Flag::Fileter_Err; + } + } + return resultFlag; +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/state/schedulestate.h dde-calendar-5.7.0.23/schedule-plugin/src/state/schedulestate.h --- dde-calendar-5.7.0.4/schedule-plugin/src/state/schedulestate.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/state/schedulestate.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,67 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef SCHEDULESTATE_H +#define SCHEDULESTATE_H + +#include "../data/jsondata.h" +#include "../interface/reply.h" +#include "../data/clocaldata.h" + +class JsonData; +class CSchedulesDBus; +class scheduleBaseTask; +class scheduleState +{ +public: + enum Filter_Flag { Fileter_Err, + Fileter_Normal, + Fileter_Init }; + +public: + scheduleState(CSchedulesDBus *dbus, scheduleBaseTask *task); + virtual ~scheduleState(); + Reply process(const JsonData *jsonData); + void setNextState(scheduleState *nextState); + scheduleState *getNextState() const; + void setLocalData(CLocalData *localData); + CLocalData *getLocalData() const; + virtual Reply getReplyByIntent(bool isOK) = 0; + +protected: + virtual Filter_Flag eventFilter(const JsonData *jsonData) = 0; + virtual Reply ErrEvent() = 0; + virtual Reply normalEvent(const JsonData *jsonData) = 0; + Reply initEvent(const JsonData *jsonData); + /** + * @brief changeDateErrJudge 修改数据错误判断,在非获取修改数据状态下,输入“修改到xxx”返回错误信息 + * @param jsonData json数据 + * @param defaultflag 默认返回标志 + * @return 过滤标志 + */ + Filter_Flag changeDateErrJudge(const JsonData *jsonData,const Filter_Flag &defaultflag); +protected: + CSchedulesDBus *m_dbus {nullptr}; + scheduleBaseTask *m_Task {nullptr}; + scheduleState *m_nextState {nullptr}; + CLocalData *m_localData {nullptr}; +}; + +#endif // SCHEDULESTATE_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/state/selectandquerystate.cpp dde-calendar-5.7.0.23/schedule-plugin/src/state/selectandquerystate.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/state/selectandquerystate.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/state/selectandquerystate.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,114 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "selectandquerystate.h" +#include "../globaldef.h" +#include "../task/schedulebasetask.h" +#include "../data/changejsondata.h" + +SelectAndQueryState::SelectAndQueryState(CSchedulesDBus *dbus, scheduleBaseTask *task) + : scheduleState(dbus, task) +{ +} + +Reply SelectAndQueryState::getReplyByIntent(bool isOK) +{ + Q_UNUSED(isOK) + Reply reply; + REPLY_ONLY_TTS(reply, G_ERR_TTS, G_ERR_TTS, true) + return reply; +} + +scheduleState::Filter_Flag SelectAndQueryState::eventFilter(const JsonData *jsonData) +{ + //如果语义包含全部关键字则为修改初始状态 + if (jsonData->getPropertyStatus() == JsonData::ALL + //如果语义包含下一个关键字则为修改初始状态 + || jsonData->getPropertyStatus() == JsonData::NEXT + || jsonData->isVaild() + //如果语义包含时间则为修改初始状态 + || jsonData->getDateTime().suggestDatetime.size()>0 + // 如果语义包含内容则为修改初始状态 + || !jsonData->TitleName().isEmpty() + //如果语义包含重复类型则为修改初始状态 + || jsonData->getRepeatStatus() != JsonData::NONE) { + return Filter_Flag::Fileter_Init; + } + if (jsonData->getPropertyStatus() == JsonData::LAST) + return Fileter_Normal; + JsonData *queryData = const_cast(jsonData); + changejsondata *mchangeJsonData = dynamic_cast(queryData); + if (mchangeJsonData->fromDateTime().suggestDatetime.size() > 0) { + return Filter_Flag::Fileter_Init; + } + //根据列表编号判断 + if (m_localData->getOffet() < 0 && jsonData->offset() < 0) { + return Fileter_Err; + } + bool showOpenWidget = m_localData->scheduleInfoVector().size() > ITEM_SHOW_NUM; + const int showcount = showOpenWidget ? ITEM_SHOW_NUM : m_localData->scheduleInfoVector().size(); + if (jsonData->offset() > showcount) { + return Fileter_Err; + } + return Fileter_Normal; +} + +Reply SelectAndQueryState::ErrEvent() +{ + Reply reply; + REPLY_ONLY_TTS(reply, QUERY_ERR_TTS, QUERY_ERR_TTS, true) + return reply; +} + +Reply SelectAndQueryState::normalEvent(const JsonData *jsonData) +{ + bool showOpenWidget = m_localData->scheduleInfoVector().size() > ITEM_SHOW_NUM; + const int showcount = showOpenWidget ? ITEM_SHOW_NUM : m_localData->scheduleInfoVector().size(); + int offset = 0; + //获取第N个日程 + if (jsonData->getPropertyStatus() == JsonData::LAST) { + offset = showcount; + }else { + offset = jsonData->offset(); + } + if(offset > 0){ + m_localData->setOffset(offset); + m_localData->setSelectInfo(m_localData->scheduleInfoVector().at(offset - 1)); + ScheduleDtailInfo info = m_localData->SelectInfo(); + //如果语义为“第xx个修改到xxx”,添加对修改信息的获取 + //类型转换 + JsonData *queryData = const_cast(jsonData); + changejsondata *mchangeJsonData = dynamic_cast(queryData); + //如果有修改时间的信息则赋值 + if(mchangeJsonData->toDateTime().suggestDatetime.size()>0){ + m_localData->setToTime(mchangeJsonData->toDateTime().dateTime); + } + //如果有修改内容的信息则获取 + if(!mchangeJsonData->toPlaceStr().isEmpty()){ + m_localData->setToTitleName(mchangeJsonData->toPlaceStr()); + } + return m_Task->getReplyBySelectSchedule(m_localData->SelectInfo()); + }else { + qDebug()<<"offset <=0"; + Reply reply; + REPLY_ONLY_TTS(reply,G_ERR_TTS,G_ERR_TTS,false); + return reply; + } +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/state/selectandquerystate.h dde-calendar-5.7.0.23/schedule-plugin/src/state/selectandquerystate.h --- dde-calendar-5.7.0.4/schedule-plugin/src/state/selectandquerystate.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/state/selectandquerystate.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,38 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef SELECTANDQUERYSTATE_H +#define SELECTANDQUERYSTATE_H + +#include "schedulestate.h" + +class SelectAndQueryState : public scheduleState +{ +public: + SelectAndQueryState(CSchedulesDBus *dbus, scheduleBaseTask *task); + Reply getReplyByIntent(bool isOK) override; + +protected: + Filter_Flag eventFilter(const JsonData *jsonData) override; + Reply ErrEvent() override; + Reply normalEvent(const JsonData *jsonData) override; +}; + +#endif // SELECTANDQUERYSTATE_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/state/selectinquirystate.cpp dde-calendar-5.7.0.23/schedule-plugin/src/state/selectinquirystate.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/state/selectinquirystate.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/state/selectinquirystate.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,85 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "selectinquirystate.h" + +#include "../globaldef.h" +#include "../widget/repeatschedulewidget.h" +#include "../task/schedulebasetask.h" + +selectInquiryState::selectInquiryState(CSchedulesDBus *dbus, scheduleBaseTask *task) + : scheduleState(dbus, task) +{ +} + +Reply selectInquiryState::getReplyByIntent(bool isOK) +{ + Q_UNUSED(isOK) + Reply reply; + REPLY_ONLY_TTS(reply, G_ERR_TTS, G_ERR_TTS, true) + return reply; +} + +scheduleState::Filter_Flag selectInquiryState::eventFilter(const JsonData *jsonData) +{ + if (jsonData->getPropertyStatus() == JsonData::ALL + || jsonData->getPropertyStatus() == JsonData::NEXT + || jsonData->isVaild() + || jsonData->getRepeatStatus() != JsonData::NONE) { + return Filter_Flag::Fileter_Init; + } + if (jsonData->getPropertyStatus() == JsonData::LAST) + return Fileter_Normal; + + if (jsonData->getDateTime().suggestDatetime.size() > 0 + || !jsonData->TitleName().isEmpty()) { + return Fileter_Init; + } + + bool showOpenWidget = m_localData->scheduleInfoVector().size() > ITEM_SHOW_NUM; + const int showcount = showOpenWidget ? ITEM_SHOW_NUM : m_localData->scheduleInfoVector().size(); + if (jsonData->offset() > showcount) { + return Fileter_Err; + } + return Fileter_Normal; +} + +Reply selectInquiryState::ErrEvent() +{ + Reply reply; + REPLY_ONLY_TTS(reply, QUERY_ERR_TTS, QUERY_ERR_TTS, true) + return reply; +} + +Reply selectInquiryState::normalEvent(const JsonData *jsonData) +{ + bool showOpenWidget = m_localData->scheduleInfoVector().size() > ITEM_SHOW_NUM; + const int showcount = showOpenWidget ? ITEM_SHOW_NUM : m_localData->scheduleInfoVector().size(); + int offset = 0; + if (jsonData->getPropertyStatus() == JsonData::LAST) { + offset = showcount; + } else { + offset = jsonData->offset(); + } + Reply m_reply; + ScheduleDtailInfo info = m_localData->scheduleInfoVector().at(offset - 1); + + return m_Task->getReplyBySelectSchedule(info); +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/state/selectinquirystate.h dde-calendar-5.7.0.23/schedule-plugin/src/state/selectinquirystate.h --- dde-calendar-5.7.0.4/schedule-plugin/src/state/selectinquirystate.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/state/selectinquirystate.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,41 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef SELECTINQUIRYSTATE_H +#define SELECTINQUIRYSTATE_H + +#include "schedulestate.h" +#include "../data/schedulestructs.h" + +class selectInquiryState : public scheduleState +{ +public: + selectInquiryState(CSchedulesDBus *dbus, scheduleBaseTask *task); + Reply getReplyByIntent(bool isOK) override; + +protected: + Filter_Flag eventFilter(const JsonData *jsonData) override; + Reply ErrEvent() override; + Reply normalEvent(const JsonData *jsonData) override; + +private: +}; + +#endif // SELECTINQUIRYSTATE_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/task/cancelscheduletask.cpp dde-calendar-5.7.0.23/schedule-plugin/src/task/cancelscheduletask.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/task/cancelscheduletask.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/task/cancelscheduletask.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,254 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "cancelscheduletask.h" +#include "../data/canceljsondata.h" +#include "../globaldef.h" +#include "../widget/schedulelistwidget.h" +#include "../widget/repeatschedulewidget.h" +#include "queryscheduleproxy.h" +#include "../state/queryschedulestate.h" +#include "../state/selectinquirystate.h" +#include "../state/repeatfeedbackstate.h" +#include "../data/clocaldata.h" +#include "../state/confirwfeedbackstate.h" + +cancelScheduleTask::cancelScheduleTask(CSchedulesDBus *dbus) + : scheduleBaseTask(dbus, new queryScheduleState(dbus, this)) +{ +} + +void cancelScheduleTask::slotSelectScheduleIndex(int index) +{ + scheduleState *currentState = getCurrentState(); + CLocalData *localData = currentState->getLocalData(); + if (!(localData->scheduleInfoVector().size() < index)) { + Reply reply = getReplyBySelectSchedule(localData->scheduleInfoVector().at(index - 1)); + updateState(); + emit signaleSendMessage(reply); + } +} + +void cancelScheduleTask::slotButtonCheckNum(int index, const QString &text, const int buttonCount) +{ + Q_UNUSED(text); + Reply reply; + scheduleState *currentState = getCurrentState(); + if (buttonCount == 2) { + if (index == 1) { + reply = confirwScheduleHandle(currentState->getLocalData()->SelectInfo()); + } + } + if (buttonCount == 3) { + if (index == 1) { + reply = repeatScheduleHandle(currentState->getLocalData()->SelectInfo(), false); + } + if (index == 2) { + reply = repeatScheduleHandle(currentState->getLocalData()->SelectInfo(), true); + } + } + if (index == 0) { + reply = InitState(nullptr, true); + } else { + InitState(nullptr, true); + } + emit signaleSendMessage(reply); +} + +scheduleState *cancelScheduleTask::getCurrentState() +{ + scheduleState *currentState = m_State; + while (currentState->getNextState() != nullptr) { + currentState = currentState->getNextState(); + } + return currentState; +} + +Reply cancelScheduleTask::getFeedbackByQuerySchedule(const QVector &infoVector) +{ + Reply m_reply; + scheduleState *nextState = nullptr; + scheduleState *currentState = getCurrentState(); + if (infoVector.size() == 0) { + QString m_TTSMessage; + QString m_DisplyMessage; + m_TTSMessage = NO_SCHEDULE_TTS; + m_DisplyMessage = NO_SCHEDULE_TTS; + REPLY_ONLY_TTS(m_reply, m_TTSMessage, m_DisplyMessage, true); + currentState->setNextState(nextState); + } else if (infoVector.size() == 1) { + m_reply = getReplyBySelectSchedule(infoVector.at(0)); + } else { + nextState = new selectInquiryState(m_dbus, this); + CLocalData *m_Data = new CLocalData(); + m_Data->setScheduleInfoVector(infoVector); + nextState->setLocalData(m_Data); + m_reply = getListScheduleReply(infoVector); + currentState->setNextState(nextState); + } + return m_reply; +} + +Reply cancelScheduleTask::getReplyBySelectSchedule(const ScheduleDtailInfo &info) +{ + Reply m_reply; + CLocalData *m_Data = new CLocalData(); + scheduleState *nextState = nullptr; + scheduleState *currentState = getCurrentState(); + m_Data->setSelectInfo(info); + if (info.rpeat == 0) { + nextState = new confirwFeedbackState(m_dbus, this); + m_reply = getConfirwScheduleReply(info); + } else { + nextState = new repeatfeedbackstate(m_dbus, this); + m_reply = getRepeatReply(info); + } + nextState->setLocalData(m_Data); + currentState->setNextState(nextState); + return m_reply; +} + +Reply cancelScheduleTask::InitState(const JsonData *jsonData, bool isUpdateState) +{ + Reply m_reply; + scheduleState *nextState = new queryScheduleState(m_dbus, this); + scheduleState *currentState = getCurrentState(); + currentState->setNextState(nextState); + if (jsonData != nullptr) { + m_reply = nextState->process(jsonData); + } else { + REPLY_ONLY_TTS(m_reply, CANCEL_DELETION_TTS, CANCEL_DELETION_TTS, true); + } + if (isUpdateState) { + updateState(); + } + return m_reply; +} + +Reply cancelScheduleTask::repeatScheduleHandle(const ScheduleDtailInfo &info, bool isOnlyOne) +{ + deleteRepeatSchedule(info, isOnlyOne); + Reply reply; + REPLY_ONLY_TTS(reply, CONFIRM_DELETION_TTS, CONFIRM_DELETION_TTS, true); + scheduleState *nextState = new queryScheduleState(m_dbus, this); + scheduleState *currentState = getCurrentState(); + currentState->setNextState(nextState); + return reply; +} + +Reply cancelScheduleTask::confirwScheduleHandle(const ScheduleDtailInfo &info) +{ + deleteOrdinarySchedule(info); + Reply reply; + REPLY_ONLY_TTS(reply, CONFIRM_DELETION_TTS, CONFIRM_DELETION_TTS, true); + scheduleState *nextState = new queryScheduleState(m_dbus, this); + scheduleState *currentState = getCurrentState(); + currentState->setNextState(nextState); + return reply; +} + +Reply cancelScheduleTask::confirmInfo(bool isOK) +{ + if (isOK) { + scheduleState *currentState = getCurrentState(); + return confirwScheduleHandle(currentState->getLocalData()->SelectInfo()); + } else { + return InitState(nullptr); + } +} + +QWidget *cancelScheduleTask::createRepeatWidget(const ScheduleDtailInfo &info) +{ + repeatScheduleWidget *repeatWidget = new repeatScheduleWidget(repeatScheduleWidget::Operation_Cancel, repeatScheduleWidget::Widget_Repeat); + repeatWidget->setSchedule(info); + connect(repeatWidget, &repeatScheduleWidget::signalButtonCheckNum, this, &cancelScheduleTask::slotButtonCheckNum); + return repeatWidget; +} + +QWidget *cancelScheduleTask::createConfirmWidget(const ScheduleDtailInfo &info) +{ + repeatScheduleWidget *cwidget = new repeatScheduleWidget(repeatScheduleWidget::Operation_Cancel, repeatScheduleWidget::Widget_Confirm); + cwidget->setSchedule(info); + connect(cwidget, &repeatScheduleWidget::signalButtonCheckNum, this, &cancelScheduleTask::slotButtonCheckNum); + return cwidget; +} + +Reply cancelScheduleTask::getListScheduleReply(const QVector &infoVector) +{ + scheduleListWidget *m_viewWidget = new scheduleListWidget(); + m_viewWidget->setScheduleInfoVector(infoVector); + connect(m_viewWidget, &scheduleListWidget::signalSelectScheduleIndex, this, &cancelScheduleTask::slotSelectScheduleIndex); + QString m_TTSMessage; + QString m_DisplyMessage; + m_TTSMessage = CANCEL_SELECT_TTS; + m_DisplyMessage = CANCEL_SELECT_TTS; + Reply reply; + REPLY_WIDGET_TTS(reply, m_viewWidget, m_TTSMessage, m_DisplyMessage, false); + return reply; +} + +Reply cancelScheduleTask::getConfirwScheduleReply(const ScheduleDtailInfo &info) +{ + QString m_TTSMessage; + QString m_DisplyMessage; + m_TTSMessage = CONFIRM_SCHEDULE_CANCEL_TTS; + m_DisplyMessage = CONFIRM_SCHEDULE_CANCEL_TTS; + QWidget *m_confirwWidget = createConfirmWidget(info); + Reply reply; + REPLY_WIDGET_TTS(reply, m_confirwWidget, m_TTSMessage, m_DisplyMessage, false); + return reply; +} + +Reply cancelScheduleTask::getRepeatReply(const ScheduleDtailInfo &info) +{ + QString m_TTSMessage; + QString m_DisplyMessage; + m_TTSMessage = REPEST_SCHEDULE_CANCEL_TTS; + m_DisplyMessage = REPEST_SCHEDULE_CANCEL_TTS; + QWidget *m_repeatReply = createRepeatWidget(info); + Reply reply; + REPLY_WIDGET_TTS(reply, m_repeatReply, m_TTSMessage, m_DisplyMessage, false); + return reply; +} + +void cancelScheduleTask::deleteRepeatSchedule(const ScheduleDtailInfo &info, bool isOnlyOne) +{ + if (isOnlyOne) { + ScheduleDtailInfo newschedule; + m_dbus->GetJob(info.id, newschedule); + newschedule.ignore.append(info.beginDateTime); + m_dbus->UpdateJob(newschedule); + } else { + if (info.RecurID == 0) { + m_dbus->DeleteJob(info.id); + } else { + ScheduleDtailInfo newschedule; + m_dbus->GetJob(info.id, newschedule); + newschedule.enddata.type = 2; + newschedule.enddata.date = info.beginDateTime.addDays(-1); + m_dbus->UpdateJob(newschedule); + } + } +} + +void cancelScheduleTask::deleteOrdinarySchedule(const ScheduleDtailInfo &info) +{ + m_dbus->DeleteJob(info.id); +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/task/cancelscheduletask.h dde-calendar-5.7.0.23/schedule-plugin/src/task/cancelscheduletask.h --- dde-calendar-5.7.0.4/schedule-plugin/src/task/cancelscheduletask.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/task/cancelscheduletask.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,59 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef CANCELSCHEDULETASK_H +#define CANCELSCHEDULETASK_H + +#include "schedulebasetask.h" + +class scheduleState; + +class cancelScheduleTask : public scheduleBaseTask +{ + Q_OBJECT +public: + cancelScheduleTask(CSchedulesDBus *dbus); + Reply getFeedbackByQuerySchedule(const QVector &infoVector) override; + Reply getReplyBySelectSchedule(const ScheduleDtailInfo &info) override; + Reply InitState(const JsonData *jsonData, bool isUpdateState = false) override; + Reply repeatScheduleHandle(const ScheduleDtailInfo &info, bool isOnlyOne) override; + Reply confirwScheduleHandle(const ScheduleDtailInfo &info) override; + Reply confirmInfo(bool isOK) override; +public slots: + void slotSelectScheduleIndex(int index); + void slotButtonCheckNum(int index, const QString &text, const int buttonCount); + +private: + scheduleState *getCurrentState(); + QWidget *createRepeatWidget(const ScheduleDtailInfo &info); + QWidget *createConfirmWidget(const ScheduleDtailInfo &info); + + Reply getListScheduleReply(const QVector &infoVector); + + Reply getConfirwScheduleReply(const ScheduleDtailInfo &info); + Reply getRepeatReply(const ScheduleDtailInfo &info); + + void deleteRepeatSchedule(const ScheduleDtailInfo &info, bool isOnlyOne = true); + void deleteOrdinarySchedule(const ScheduleDtailInfo &info); + +private: +}; + +#endif // CANCELSCHEDULETASK_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/task/changescheduletask.cpp dde-calendar-5.7.0.23/schedule-plugin/src/task/changescheduletask.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/task/changescheduletask.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/task/changescheduletask.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,413 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "changescheduletask.h" +#include "../data/changejsondata.h" +#include "../globaldef.h" +#include "../widget/schedulelistwidget.h" +#include "../widget/repeatschedulewidget.h" +#include "queryscheduleproxy.h" +#include "../state/selectandquerystate.h" +#include "../state/confirwfeedbackstate.h" +#include "../state/queryschedulestate.h" +#include "../state/repeatfeedbackstate.h" +#include "../state/getchangedatastate.h" + +changeScheduleTask::changeScheduleTask(CSchedulesDBus *dbus) + : scheduleBaseTask(dbus, new queryScheduleState(dbus, this)) +{ +} + +Reply changeScheduleTask::getFeedbackByQuerySchedule(const QVector &infoVector) +{ + Reply m_reply; + scheduleState *nextState = nullptr; + scheduleState *currentState = getCurrentState(); + if (infoVector.size() == 0) { + QString m_TTSMessage; + QString m_DisplyMessage; + m_TTSMessage = NO_SCHEDULE_TTS; + m_DisplyMessage = NO_SCHEDULE_TTS; + REPLY_ONLY_TTS(m_reply, m_TTSMessage, m_DisplyMessage, true); + currentState->setNextState(nextState); + } else if (infoVector.size() == 1) { + currentState->getLocalData()->setSelectInfo(infoVector.at(0)); + m_reply = getReplyBySelectSchedule(infoVector.at(0)); + } else { + nextState = new SelectAndQueryState(m_dbus, this); + CLocalData *m_Data = new CLocalData(); + m_Data->getDataByPoint(currentState->getLocalData()); + m_Data->setScheduleInfoVector(infoVector); + nextState->setLocalData(m_Data); + m_reply = getListScheduleReply(infoVector); + currentState->setNextState(nextState); + } + return m_reply; +} + +void changeScheduleTask::slotSelectScheduleIndex(int index) +{ + scheduleState *currentState = getCurrentState(); + CLocalData *localData = currentState->getLocalData(); + if (!(localData->scheduleInfoVector().size() < index)) { + localData->setSelectInfo(localData->scheduleInfoVector().at(index - 1)); + Reply reply = getReplyBySelectSchedule(localData->scheduleInfoVector().at(index - 1)); + updateState(); + emit signaleSendMessage(reply); + } +} + +void changeScheduleTask::slotButtonCheckNum(int index, const QString &text, const int buttonCount) +{ + Q_UNUSED(text); + Reply reply; + scheduleState *currentState = getCurrentState(); + if (buttonCount == 2) { + if (index == 1) { + reply = confirwScheduleHandle(currentState->getLocalData()->SelectInfo()); + } + } + if (buttonCount == 3) { + if (index == 1) { + reply = repeatScheduleHandle(currentState->getLocalData()->SelectInfo(), false); + } + if (index == 2) { + reply = repeatScheduleHandle(currentState->getLocalData()->SelectInfo(), true); + } + } + if (index == 0) { + reply = InitState(nullptr, true); + } else { + InitState(nullptr, true); + } + emit signaleSendMessage(reply); +} + +scheduleState *changeScheduleTask::getCurrentState() +{ + scheduleState *currentState = m_State; + while (currentState->getNextState() != nullptr) { + currentState = currentState->getNextState(); + } + return currentState; +} + +Reply changeScheduleTask::getReplyBySelectSchedule(const ScheduleDtailInfo &info) +{ + Reply m_reply; + scheduleState *nextState = nullptr; + CLocalData *m_Data = new CLocalData(); + scheduleState *currentState = getCurrentState(); + m_Data->getDataByPoint(currentState->getLocalData()); + m_Data->setSelectInfo(info); + if (m_Data->getOffet() < 0) { + m_Data->setOffset(1); + } + if (m_Data->getToTime().size() == 0 && m_Data->getToTitleName() == "") { + QWidget *infoWidget = createInquiryWidget(info); + REPLY_WIDGET_TTS(m_reply, infoWidget, CHANGE_TO_TTS, CHANGE_TO_TTS, false); + //添加获取修改信息状态 + nextState = new getChangeDataState(m_dbus, this); + nextState->setLocalData(m_Data); + } else { + //获取下一个状态 + nextState = getNextStateBySelectScheduleInfo(info,m_Data,m_reply); + } + currentState->setNextState(nextState); + return m_reply; +} + +Reply changeScheduleTask::InitState(const JsonData *jsonData, bool isUpdateState) +{ + Reply m_reply; + scheduleState *nextState = new queryScheduleState(m_dbus, this); + scheduleState *currentState = getCurrentState(); + currentState->setNextState(nextState); + if (jsonData != nullptr) { + if (currentState->getLocalData() != nullptr) { + currentState->setLocalData(nullptr); + } + m_reply = nextState->process(jsonData); + } else { + REPLY_ONLY_TTS(m_reply, CANCEL_CHANGE_TTS, CANCEL_CHANGE_TTS, true); + } + if (isUpdateState) { + updateState(); + } + return m_reply; +} + +Reply changeScheduleTask::repeatScheduleHandle(const ScheduleDtailInfo &info, bool isOnlyOne) +{ + changeRepeatSchedule(info, isOnlyOne); + Reply reply; + REPLY_ONLY_TTS(reply, CONFIRM_CHANGE_TTS, CONFIRM_CHANGE_TTS, true); + scheduleState *nextState = new queryScheduleState(m_dbus, this); + scheduleState *currentState = getCurrentState(); + currentState->setNextState(nextState); + return reply; +} + +Reply changeScheduleTask::confirwScheduleHandle(const ScheduleDtailInfo &info) +{ + Q_UNUSED(info); + scheduleState *currentState = getCurrentState(); + changeOrdinarySchedule(currentState->getLocalData()->getNewInfo()); + Reply reply; + REPLY_ONLY_TTS(reply, CONFIRM_CHANGE_TTS, CONFIRM_CHANGE_TTS, true); + scheduleState *nextState = new queryScheduleState(m_dbus, this); + currentState->setNextState(nextState); + return reply; +} + +Reply changeScheduleTask::confirmInfo(bool isOK) +{ + scheduleState *currentState = getCurrentState(); + if (isOK) { + Q_UNUSED(isOK) + changeOrdinarySchedule(currentState->getLocalData()->getNewInfo()); + Reply reply; + REPLY_ONLY_TTS(reply, CONFIRM_CHANGE_TTS, CONFIRM_CHANGE_TTS, true) + return reply; + } else { + return InitState(nullptr); + } +} + +QWidget *changeScheduleTask::createRepeatWidget(const ScheduleDtailInfo &info) +{ + repeatScheduleWidget *repeatWidget = new repeatScheduleWidget(repeatScheduleWidget::Operation_Change, repeatScheduleWidget::Widget_Repeat); + repeatWidget->setSchedule(info); + connect(repeatWidget, &repeatScheduleWidget::signalButtonCheckNum, this, &changeScheduleTask::slotButtonCheckNum); + return repeatWidget; +} + +QWidget *changeScheduleTask::createConfirmWidget(const ScheduleDtailInfo &info) +{ + repeatScheduleWidget *cwidget = new repeatScheduleWidget(repeatScheduleWidget::Operation_Change, repeatScheduleWidget::Widget_Confirm); + cwidget->setSchedule(info); + connect(cwidget, &repeatScheduleWidget::signalButtonCheckNum, this, &changeScheduleTask::slotButtonCheckNum); + return cwidget; +} + +QWidget *changeScheduleTask::createInquiryWidget(const ScheduleDtailInfo &info) +{ + repeatScheduleWidget *infoWidget = + new repeatScheduleWidget(repeatScheduleWidget::Operation_Change, repeatScheduleWidget::Widget_Confirm, false); + infoWidget->setSchedule(info); + return infoWidget; +} + +Reply changeScheduleTask::getListScheduleReply(const QVector &infoVector) +{ + scheduleListWidget *m_viewWidget = new scheduleListWidget(); + connect(m_viewWidget, &scheduleListWidget::signalSelectScheduleIndex, this, &changeScheduleTask::slotSelectScheduleIndex); + m_viewWidget->setScheduleInfoVector(infoVector); + QString m_TTSMessage; + QString m_DisplyMessage; + m_TTSMessage = SELECT_CHANGE_TTS; + m_DisplyMessage = SELECT_CHANGE_TTS; + Reply reply; + REPLY_WIDGET_TTS(reply, m_viewWidget, m_TTSMessage, m_DisplyMessage, false); + return reply; +} + +scheduleState *changeScheduleTask::getNextStateBySelectScheduleInfo(const ScheduleDtailInfo &info, CLocalData *localData, Reply &reply) +{ + QString m_TTSMessage; + QString m_DisplyMessage; + //获取当前状态 + scheduleState *currentState = getCurrentState(); + //下一个状态 + scheduleState *nextState{nullptr}; + //如果修改的新日程时间在范围内则正常提醒 + if(getNewInfo()){ + //需要显示的窗口 + QWidget *_showWidget; + if (info.rpeat == 0) { + m_TTSMessage = CONFIRM_SCHEDULE_CHANGE_TTS; + m_DisplyMessage = CONFIRM_SCHEDULE_CHANGE_TTS; + _showWidget = createConfirmWidget(currentState->getLocalData()->getNewInfo()); + //设置下一个状态为普通日程确认状态 + nextState = new confirwFeedbackState(m_dbus, this); + } else { + m_TTSMessage = REPEST_SCHEDULE_CHANGE_TTS; + m_DisplyMessage = REPEST_SCHEDULE_CHANGE_TTS; + _showWidget = createRepeatWidget(currentState->getLocalData()->getNewInfo()); + //设置下一个状态为重复日程确认状态 + nextState = new repeatfeedbackstate(m_dbus, this); + } + //设置修改的日程信息 + localData->setNewInfo(currentState->getLocalData()->getNewInfo()); + //设置存储数据 + nextState->setLocalData(localData); + REPLY_WIDGET_TTS(reply, _showWidget, m_TTSMessage, m_DisplyMessage, false); + }else { + //如果修改的日程不在正常范围内则回复错误,并设置下一个状态为询问查询状态 + m_TTSMessage = CHANGE_TIME_OUT_TTS; + m_DisplyMessage = CHANGE_TIME_OUT_TTS; + REPLY_ONLY_TTS(reply,m_TTSMessage,m_DisplyMessage,true); + nextState = new queryScheduleState(m_dbus, this); + }; + return nextState; +} + +bool changeScheduleTask::getNewInfo() +{ + scheduleState *currentState = getCurrentState(); + ScheduleDtailInfo m_NewInfo = currentState->getLocalData()->SelectInfo(); + m_NewInfo.allday = false; + m_NewInfo.remind = true; + m_NewInfo.remindData.n = 0; + if (!currentState->getLocalData()->getToTitleName().isEmpty()) + m_NewInfo.titleName = currentState->getLocalData()->getToTitleName(); + QVector m_ToTime = currentState->getLocalData()->getToTime(); + if (m_ToTime.size() > 0) { + if (m_ToTime.size() == 1) { + //如果存在日期信息 + if(m_ToTime.at(0).hasDate){ + //设置修改的开始日期 + m_NewInfo.beginDateTime.setDate(m_ToTime.at(0).m_Date); + //设置修改的结束日期 + m_NewInfo.endDateTime.setDate(m_ToTime.at(0).m_Date); + } + //如果修改的DateTime带时间则设置该时间,否则保持原来的时间点 + if(m_ToTime.at(0).hasTime){ + m_NewInfo.beginDateTime.setTime(m_ToTime.at(0).m_Time); + m_NewInfo.endDateTime = m_NewInfo.beginDateTime.addSecs(3600); + } + } + if (m_ToTime.size() == 2) { + //如果存在日期信息 + if(m_ToTime.at(0).hasDate){ + //设置修改的开始日期 + m_NewInfo.beginDateTime.setDate(m_ToTime.at(0).m_Date); + } + //如果修改的DateTime带时间则设置该时间,否则保持原来的时间点 + if(m_ToTime.at(0).hasTime){ + m_NewInfo.beginDateTime.setTime(m_ToTime.at(0).m_Time); + } + //如果存在日期信息 + if(m_ToTime.at(1).hasDate){ + //设置修改的结束日期 + m_NewInfo.endDateTime.setDate(m_ToTime.at(1).m_Date); + } + //如果修改的DateTime带时间则设置该时间,否则保持原来的时间点 + if (m_ToTime.at(1).hasTime) + m_NewInfo.endDateTime.setTime(m_ToTime.at(1).m_Time); + //如果开始时间大于结束时间则设置结束时间为开始时间往后一小时 + if (m_NewInfo.endDateTime < m_NewInfo.beginDateTime) { + m_NewInfo.endDateTime = m_NewInfo.beginDateTime.addSecs(3600); + } + } + } + currentState->getLocalData()->setNewInfo(m_NewInfo); + return changeDateTimeIsInNormalRange(m_NewInfo); +} + +void changeScheduleTask::changeRepeatSchedule(const ScheduleDtailInfo &info, bool isOnlyOne) +{ + if (isOnlyOne) { + changeOnlyInfo(info); + } else { + changeAllInfo(info); + } +} + +void changeScheduleTask::changeOnlyInfo(const ScheduleDtailInfo &info) +{ + scheduleState *currentState = getCurrentState(); + ScheduleDtailInfo newschedule = currentState->getLocalData()->getNewInfo(); + newschedule.rpeat = 0; + newschedule.RecurID = 0; + newschedule.id = 0; + newschedule.ignore.clear(); + m_dbus->CreateJob(newschedule); + ScheduleDtailInfo updatescheduleData; + m_dbus->GetJob(info.id, updatescheduleData); + updatescheduleData.ignore.append(info.beginDateTime); + m_dbus->UpdateJob(updatescheduleData); +} + +void changeScheduleTask::changeAllInfo(const ScheduleDtailInfo &info) +{ + scheduleState *currentState = getCurrentState(); + ScheduleDtailInfo newinfo = currentState->getLocalData()->getNewInfo(); + if (info.RecurID == 0) { + ScheduleDtailInfo scheduleDtailInfo = newinfo; + if (scheduleDtailInfo.enddata.type == 1 && scheduleDtailInfo.enddata.tcount < 1) { + scheduleDtailInfo.enddata.type = 0; + } else if (scheduleDtailInfo.enddata.type == 2 && scheduleDtailInfo.beginDateTime.daysTo(scheduleDtailInfo.enddata.date) < 0) { + scheduleDtailInfo.enddata.type = 0; + scheduleDtailInfo.rpeat = 0; + } + m_dbus->UpdateJob(scheduleDtailInfo); + } else { + ScheduleDtailInfo newschedule = newinfo; + newschedule.RecurID = 0; + newschedule.id = 0; + if (newschedule.enddata.type == 1) { + newschedule.enddata.tcount = qAbs(newinfo.enddata.tcount - newinfo.RecurID); + if (newschedule.enddata.tcount < 1) { + newschedule.enddata.type = 0; + newschedule.rpeat = 0; + } + } + m_dbus->CreateJob(newschedule); + ScheduleDtailInfo updatescheduleData; + m_dbus->GetJob(info.id, updatescheduleData); + if (updatescheduleData.enddata.type == 1) { + updatescheduleData.enddata.tcount = newinfo.RecurID - 1; + if (updatescheduleData.enddata.tcount < 1) { + updatescheduleData.enddata.type = 0; + updatescheduleData.rpeat = 0; + } + } else if (updatescheduleData.enddata.type == 2) { + updatescheduleData.enddata.type = 2; + updatescheduleData.enddata.date = + info.beginDateTime.addDays(-1); + } + m_dbus->UpdateJob(updatescheduleData); + } +} + +void changeScheduleTask::changeOrdinarySchedule(const ScheduleDtailInfo &info) +{ + m_dbus->UpdateJob(info); +} + +bool changeScheduleTask::changeDateTimeIsInNormalRange(const ScheduleDtailInfo &info) +{ + bool result {true}; + //当前时间 + QDateTime currentDateTime {QDateTime::currentDateTime()}; + //最大时间 + QDateTime maxDateTime = currentDateTime.addMonths(6); + //如果开始时间为过期时间则为false + if(info.beginDateTimemaxDateTime + ||info.endDateTime > maxDateTime){ + result = false; + } + return result; +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/task/changescheduletask.h dde-calendar-5.7.0.23/schedule-plugin/src/task/changescheduletask.h --- dde-calendar-5.7.0.4/schedule-plugin/src/task/changescheduletask.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/task/changescheduletask.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,79 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef CHANGESCHEDULETASK_H +#define CHANGESCHEDULETASK_H + +#include "schedulebasetask.h" + +class CLocalData; +class changeScheduleTask : public scheduleBaseTask +{ + Q_OBJECT +public: + changeScheduleTask(CSchedulesDBus *dbus); + Reply getFeedbackByQuerySchedule(const QVector &infoVector) override; + Reply getReplyBySelectSchedule(const ScheduleDtailInfo &info) override; + Reply InitState(const JsonData *jsonData, bool isUpdateState = false) override; + Reply repeatScheduleHandle(const ScheduleDtailInfo &info, bool isOnlyOne) override; + Reply confirwScheduleHandle(const ScheduleDtailInfo &info) override; + Reply confirmInfo(bool isOK) override; + +public slots: + void slotSelectScheduleIndex(int index); + void slotButtonCheckNum(int index, const QString &text, const int buttonCount); + +private: + scheduleState *getCurrentState(); + QWidget *createRepeatWidget(const ScheduleDtailInfo &info); + QWidget *createConfirmWidget(const ScheduleDtailInfo &info); + QWidget *createInquiryWidget(const ScheduleDtailInfo &info); + + Reply getListScheduleReply(const QVector &infoVector); + /** + * @brief getNextStateBySelectScheduleInfo 根据选择的日程获取下一个修改状态 + * @param info 选择的日程信息 + * @param localData 当前状态的存储数据 + * @param reply 修改的回复 + * @return 下一个状态 + */ + scheduleState *getNextStateBySelectScheduleInfo(const ScheduleDtailInfo &info,CLocalData *localData,Reply &reply); + /** + * @brief getNewInfo 根据修改信息获取新的日程信息 + * @return 在时间范围内返回true + */ + bool getNewInfo(); + + void changeRepeatSchedule(const ScheduleDtailInfo &info, bool isOnlyOne); + void changeOnlyInfo(const ScheduleDtailInfo &info); + void changeAllInfo(const ScheduleDtailInfo &info); + void changeOrdinarySchedule(const ScheduleDtailInfo &info); + /** + * @brief changeDateTimeIsInRange 判断修改的日期在正确的时间范围内 + * @param info 修改过的日程 + * @return 在正常范围内则返回true + */ + bool changeDateTimeIsInNormalRange(const ScheduleDtailInfo &info); + +private: + QVector m_scheduleInfo; +}; + +#endif // CHANGESCHEDULETASK_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/task/createscheduletask.cpp dde-calendar-5.7.0.23/schedule-plugin/src/task/createscheduletask.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/task/createscheduletask.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/task/createscheduletask.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,887 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "createscheduletask.h" + +#include "../globaldef.h" + +createScheduleTask::createScheduleTask(CSchedulesDBus *dbus) + : scheduleBaseTask(dbus) +{ +} + +Reply createScheduleTask::SchedulePress(semanticAnalysisTask &semanticTask) +{ + //创建 + CreateJsonData *createJsonData = dynamic_cast(semanticTask.getJsonData()); + //如果转换失败则返回错误消息 + if (createJsonData == nullptr) + return errorMessage(); + //查询日程 + Reply m_reply; + if (createJsonData->getPropertyStatus() != JsonData::PRO_NONE + || createJsonData->offset() > -1) { + REPLY_ONLY_TTS(m_reply, CREATE_ERR_TTS, CREATE_ERR_TTS, true); + return m_reply; + } + + m_widget = new createSchedulewidget(); + //设置日程时间 + setDateTime(createJsonData); + qDebug() << "beginDateTimeIsinHalfYear" + << beginDateTimeIsinHalfYear() + << "ShouldEndSession" + << createJsonData->ShouldEndSession(); + //判断日程开始时间是否在半年以内 + if (beginDateTimeIsinHalfYear() || m_begintime.date() == QDate::currentDate()) { + //判断多伦标志 + if (createJsonData->ShouldEndSession()) { + //设置日程titlename + setScheduleTitleName(createJsonData); + //创建日程和插件 + creareScheduleUI(createScheduleWithRepeatStatus(createJsonData)); + //带有插件的回复语 + REPLY_WIDGET_TTS(m_reply, m_widget, getReply(createJsonData), getReply(createJsonData), true); + } else { + //开始date为今天,没有给time(默认为00:00,小于当前time),需要进行多轮,设置默认回复语 + //只有回复语 + REPLY_ONLY_TTS(m_reply, createJsonData->SuggestMsg(), createJsonData->SuggestMsg(), false); + } + } else { + if (beginDateTimeBeforeCurrent()) { + //"我现在有点慌,因为我还不会制定过去的提醒" + REPLY_ONLY_TTS(m_reply, createJsonData->SuggestMsg(), createJsonData->SuggestMsg(), true); + } else if (beginDateTimeOutHalfYear()) { + //"只能创建未来半年的日程" + REPLY_ONLY_TTS(m_reply, CREATE_TIME_OUT_TTS, CREATE_TIME_OUT_TTS, true); + } + } + + return m_reply; +} + +void createScheduleTask::setDateTime(CreateJsonData *createJsonData) +{ + if (createJsonData->getDateTime().suggestDatetime.size() > 0) { + //用户有输入时间,则设置开始时间 + m_begintime = createJsonData->getDateTime().suggestDatetime.at(0).datetime; + if (!createJsonData->getDateTime().suggestDatetime.at(0).hasTime) { + //如果没有time,设置当前time + m_begintime.setTime(QTime::currentTime()); + } + if (createJsonData->getDateTime().suggestDatetime.size() == 2 && m_begintime < QDateTime::currentDateTime()) { + if (m_begintime.time() > QTime::currentTime()) { + //跨天日程,如果日程开始时间大于当前时间,则开始时间为当天 + m_begintime.setDate(m_begintime.date().addDays(m_begintime.date().daysTo(QDate::currentDate()))); + } else { + //跨天日程,如果日程开始时间小于等于当前时间,则开始时间加一天 + m_begintime.setDate(m_begintime.date().addDays(m_begintime.date().daysTo(QDate::currentDate()) + 1)); + } + } + } else { + //用户没有输入时间,则日程开始时间设置为当前时间 + m_begintime = QDateTime::currentDateTime(); + } + if (createJsonData->getDateTime().suggestDatetime.size() <= 1) { + //如果只有开始时间,则结束时间默认为开始时间后一个小时 + m_endtime = m_begintime.addSecs(60 * 60); + } else if (createJsonData->getDateTime().suggestDatetime.size() == 2) { + //如果有结束时间,则设置结束时间 + m_endtime = createJsonData->getDateTime().suggestDatetime.at(1).datetime; + if (!createJsonData->getDateTime().suggestDatetime.at(1).hasTime) { + //如果用户没有输入结束时间,则默认为当天23:59:59 + m_endtime.setTime(QTime(23, 59, 59)); + } + } + qDebug() << "m_begintime = " << m_begintime << ", m_endtime = " << m_endtime; +} + +void createScheduleTask::setScheduleTitleName(CreateJsonData *createJsonData) +{ + if (createJsonData->TitleName().isEmpty()) + //如果没有titlename,默认为:新建日程 + m_widget->setTitleName(NEW_SCHEDULE); + else + //设置日程titlename + m_widget->setTitleName(createJsonData->TitleName()); +} + +QVector createScheduleTask::createScheduleWithRepeatStatus(CreateJsonData *createJsonData) +{ + //创建的日程信息 + QVector schedule; + //重复日程的时间 + QVector getDayNum = createJsonData->getRepeatNum(); + //根据不同类型分别创建日程 + switch (createJsonData->getRepeatStatus()) { + case CreateJsonData::NONE: { + //非重复日程,不能创建过期日程 + if (m_begintime > QDateTime::currentDateTime() && m_begintime < QDateTime::currentDateTime().addMonths(6)) + schedule = getNotRepeatDaySchedule(); + } + break; + case CreateJsonData::EVED: + //每天重复日程 + schedule = getEveryDaySchedule(); + break; + case CreateJsonData::EVEW: { + //每周重复日程 + schedule = getEveryWeekSchedule(getDayNum); + } + break; + case CreateJsonData::EVEM: { + //每月重复日程 + schedule = getEveryMonthSchedule(getDayNum); + } + break; + case CreateJsonData::EVEY: { + //每年重复日程,不能创建过期或者超过半年的日程 + if (m_begintime > QDateTime::currentDateTime() && m_begintime < QDateTime::currentDateTime().addMonths(6)) + schedule = getEveryYearSchedule(); + } + break; + case CreateJsonData::WORKD: + //工作日 + schedule = getEveryWorkDaySchedule(); + break; + case CreateJsonData::RESTD: { + //休息日 + schedule = getEveryRestDaySchedule(); + } + break; + } + return schedule; +} + +void createScheduleTask::creareScheduleUI(QVector schedule) +{ + if (!schedule.isEmpty()) { + //日程信息不为空,创建插件 + qDebug() << "creatUI" + << getFirstSchedule(schedule).beginDateTime + << getFirstSchedule(schedule).endDateTime + << m_begintime.daysTo(m_endtime); + //设置日程时间 + setDateTimeAndGetSchedule(getFirstSchedule(schedule).beginDateTime, getFirstSchedule(schedule).endDateTime); + //设置dbus + m_widget->setScheduleDbus(m_dbus); + m_widget->scheduleEmpty(true); + //更新界面 + m_widget->updateUI(); + } +} + +QString createScheduleTask::getReply(CreateJsonData *createJsonData) +{ + QString str_reply; + //为特殊情况拼接回复语 + if (createJsonData->getRepeatStatus() == CreateJsonData::RESTD + && createJsonData->getDateTime().suggestDatetime.at(0).hasTime) { + //如果为休息日,并且有开始时间,拼接回复语 + str_reply = QString(EVERY_WEEKEND_TTS).arg(m_begintime.toString("hh:mm")); + } else if (createJsonData->getRepeatStatus() == CreateJsonData::NONE + && createJsonData->getDateTime().suggestDatetime.at(0).hasTime + && createJsonData->getDateTime().suggestDatetime.at(0).datetime < QDateTime::currentDateTime() + && createJsonData->getDateTime().suggestDatetime.size() == 2 + && createJsonData->ShouldEndSession()) { + //对于跨天日程,开始datetime小于当前datetime,则开始date增加一天,为其拼接回复语 + str_reply = QString(BEGINDATETIME_LATER_THAN_CURRENTDATETIME_ACROSS_THE_DAY_TTS).arg(m_begintime.toString("hh:mm")); + } else { + //没有特殊情况使用默认回复语 + str_reply = createJsonData->SuggestMsg(); + } + + return str_reply; +} + +bool createScheduleTask::beginDateTimeIsinHalfYear() +{ + //判断日程开始时间是否在半年内 + if (m_begintime < QDateTime::currentDateTime() || m_begintime > QDateTime::currentDateTime().addMonths(6)) + return false; + else + return true; +} + +bool createScheduleTask::beginDateTimeOutHalfYear() +{ + //日程开始时间不在半年范围内 + if (m_begintime > QDateTime::currentDateTime().addMonths(6)) + return true; + else + return false; +} + +bool createScheduleTask::beginDateTimeBeforeCurrent() +{ + //日程开始时间早于当前时间 + if (m_begintime < QDateTime::currentDateTime()) + return true; + else + return false; +} + +QVector createScheduleTask::getNotRepeatDaySchedule() +{ + QVector schedule; + //设置重复类型 + m_widget->setRpeat(0); + //创建日程 + m_dbus->CreateJob(setDateTimeAndGetSchedule(m_begintime, m_endtime)); + //将所有日程添加到日程容器中 + schedule.append(setDateTimeAndGetSchedule(m_begintime, m_endtime)); + + return schedule; +} + +QVector createScheduleTask::getEveryDaySchedule() +{ + QVector schedule; + //设置重复类型 + m_widget->setRpeat(1); + //创建日程 + m_dbus->CreateJob(setDateTimeAndGetSchedule(m_begintime, m_endtime)); + //将所有日程添加到日程容器中 + schedule.append(setDateTimeAndGetSchedule(m_begintime, m_endtime)); + //设置完成后,将everyDayState设置为false + everyDayState = false; + + return schedule; +} + +QVector createScheduleTask::getEveryWeekSchedule(QVector dateRange) +{ + QVector beginDateTime {}; + QVector schedule; + //每天重复 + if (everyDayState) + return getEveryDaySchedule(); + //设置重复类型 + m_widget->setRpeat(3); + //获取解析时间 + beginDateTime = analysisEveryWeekDate(dateRange); + + for (int i = 0; i < beginDateTime.count(); i++) { + //设置日程结束时间 + m_endtime.setDate(beginDateTime.at(i).date()); + //创建日程 + m_dbus->CreateJob(setDateTimeAndGetSchedule(beginDateTime.at(i), m_endtime)); + //将所有日程添加到日程容器中 + schedule.append(setDateTimeAndGetSchedule(beginDateTime.at(i), m_endtime)); + } + + return schedule; +} + +QVector createScheduleTask::getEveryMonthSchedule(QVector dateRange) +{ + QVector beginDateTime {}; + QVector schedule; + //每天重复 + if (everyDayState) + return getEveryDaySchedule(); + //设置重复类型 + m_widget->setRpeat(4); + //获取解析日期 + beginDateTime = analysisEveryMonthDate(dateRange); + + for (int i = 0; i < beginDateTime.count(); i++) { + //设置日程结束时间 + m_endtime.setDate(beginDateTime.at(i).date()); + //创建日程 + m_dbus->CreateJob(setDateTimeAndGetSchedule(beginDateTime.at(i), m_endtime)); + //将所有日程添加到日程容器中 + schedule.append(setDateTimeAndGetSchedule(beginDateTime.at(i), m_endtime)); + } + + return schedule; +} + +QVector createScheduleTask::getEveryYearSchedule() +{ + QVector schedule; + //设置重复类型 + m_widget->setRpeat(5); + //创建日程 + m_dbus->CreateJob(setDateTimeAndGetSchedule(m_begintime, m_endtime)); + //将多有日程添加到日程容器中 + schedule.append(setDateTimeAndGetSchedule(m_begintime, m_endtime)); + + return schedule; +} + +QVector createScheduleTask::getEveryWorkDaySchedule() +{ + QVector beginDateTime {}; + QVector schedule; + + //获取解析日期 + beginDateTime = analysisWorkDayDate(); + //设置重复类型 + m_widget->setRpeat(2); + + for (int i = 0; i < beginDateTime.count(); i++) { + //设置日程结束时间 + m_endtime.setDate(beginDateTime.at(i).date()); + //创建日程 + m_dbus->CreateJob(setDateTimeAndGetSchedule(beginDateTime.at(i), m_endtime)); + //将所有日程添加到日程容器中 + schedule.append(setDateTimeAndGetSchedule(beginDateTime.at(i), m_endtime)); + } + + return schedule; +} + +QVector createScheduleTask::getEveryRestDaySchedule() +{ + QVector beginDateTime {}; + QVector schedule; + //设置重复类型 + m_widget->setRpeat(3); + //获取解析的时间 + beginDateTime = analysisRestDayDate(); + + for (int i = 0; i < beginDateTime.count(); i++) { + //设置日程结束时间 + m_endtime.setDate(beginDateTime.at(i).date()); + //创建日程 + m_dbus->CreateJob(setDateTimeAndGetSchedule(beginDateTime.at(i), m_endtime)); + //将所有日程添加到日程容器中 + schedule.append(setDateTimeAndGetSchedule(beginDateTime.at(i), m_endtime)); + } + + return schedule; +} + +ScheduleDtailInfo createScheduleTask::getFirstSchedule(QVector scheduleInfo) +{ + //第一个日程的时间 + QDate earlyDate = scheduleInfo.at(0).beginDateTime.date(); + //第一个日程的索引 + int index = 0; + for (int i = 1; i < scheduleInfo.count(); i++) { + if (earlyDate > scheduleInfo.at(i).beginDateTime.date()) { + earlyDate = scheduleInfo.at(i).beginDateTime.date(); + index = i; + } + } + return scheduleInfo.at(index); +} + +int createScheduleTask::getCreatesDays(int firstDay, int secondday, bool containsToday) +{ + if (containsToday) + //如果包含今天+1 + return secondday - firstDay + 1; + else + //不包含今天 + return secondday - firstDay; +} + +QVector createScheduleTask::getNoneWeekNumDate() +{ + QVector beginDateTime {}; + + if (m_begintime.time() > QTime::currentTime()) { + //日程开始时间大于当天时间 + m_begintime.setDate(QDate::currentDate()); + } else { + //日程开始时间小于等于当天时间 + m_begintime.setDate(QDate::currentDate().addDays(1)); + } + beginDateTime.append(m_begintime); + + return beginDateTime; +} + +QVector createScheduleTask::getOneWeekNumDate(int firstWeekNum) +{ + QVector beginDateTime {}; + int currentDayofWeek = QDate::currentDate().dayOfWeek(); + + if (firstWeekNum >= currentDayofWeek) { + //开始周数大于等于今天所在周数 + if (firstWeekNum == currentDayofWeek && m_begintime.time() <= QTime::currentTime()) { + //开始周数等于今天所在周数,并且日程开始时间小于等于当前时间 + m_begintime.setDate(QDate::currentDate().addDays(firstWeekNum + 7 - currentDayofWeek)); + } else { + //日程开始时间大于当前时间 + m_begintime.setDate(QDate::currentDate().addDays(firstWeekNum - currentDayofWeek)); + } + } else { + //开始周数小于今天所在周数 + m_begintime.setDate(QDate::currentDate().addDays(firstWeekNum + 7 - currentDayofWeek)); + } + beginDateTime.append(m_begintime); + + return beginDateTime; +} + +QVector createScheduleTask::getTwoWeekNumDate(int firstWeekNum, int secondWeekNum) +{ + QVector beginDateTime {}; + + if (firstWeekNum == secondWeekNum || secondWeekNum - firstWeekNum == 6) { + //开始周数等于结束周数,或者结束周数是7开始周数是1,为每天 + everyDayState = true; + return beginDateTime; + } else if (firstWeekNum < secondWeekNum) { + //开始周数小于结束周数 + beginDateTime = firstWeekNumLessThanSecond(firstWeekNum, secondWeekNum); + } else { + //开始周数大于结束周数 + if (firstWeekNum - secondWeekNum == 1) { + //开始周数比结束周数大1,为每天 + everyDayState = true; + return beginDateTime; + } else { + //除去每天的其他情况 + firstWeekNumGreaterThanSecondButEveryDay(firstWeekNum, secondWeekNum); + } + } + + return beginDateTime; +} + +QVector createScheduleTask::firstWeekNumLessThanSecond(int firstWeekNum, int secondWeekNum) +{ + //对于工作日和休息日的情况,助手已自动区分,此处不再讨论 + //对获取到的时间范围分情况讨论 + QVector beginDateTime {}; + int currentDayofWeek = QDate::currentDate().dayOfWeek(); + + //当前日期所在周数小于开始的周数 + if (currentDayofWeek < firstWeekNum) { + beginDateTime.append(getWeekAllDateTime(QDate::currentDate().addDays(firstWeekNum - currentDayofWeek), firstWeekNum, secondWeekNum)); + } else if (currentDayofWeek >= firstWeekNum && currentDayofWeek <= secondWeekNum) { + if (m_begintime.time() > QTime::currentTime()) { + //开始时间大于当前时间 + beginDateTime.append(getWeekBackPartDateTime(QDate::currentDate(), secondWeekNum, true)); + beginDateTime.append(getWeekFrontPartDateTime(QDate::currentDate(), firstWeekNum, false)); + } else { + //开始时间小于等于当前时间 + beginDateTime.append(getWeekBackPartDateTime(QDate::currentDate().addDays(1), secondWeekNum, false)); + beginDateTime.append(getWeekFrontPartDateTime(QDate::currentDate(), firstWeekNum, true)); + } + } else if (currentDayofWeek > secondWeekNum) { + beginDateTime.append(getWeekAllDateTime(QDate::currentDate().addDays(firstWeekNum + 7 - currentDayofWeek), firstWeekNum, secondWeekNum)); + } + + return beginDateTime; +} + +QVector createScheduleTask::firstWeekNumGreaterThanSecondButEveryDay(int firstWeekNum, int secondWeekNum) +{ + QVector beginDateTime {}; + int currentDayofWeek = QDate::currentDate().dayOfWeek(); + + if (currentDayofWeek >= firstWeekNum) { + //今天所在周数大于等于开始周数 + if (m_begintime.time() > QTime::currentTime()) { + //日程开始时间大于当前时间 + beginDateTime.append(getWeekBackPartDateTime(QDate::currentDate(), 7, true)); + beginDateTime.append(getWeekAllDateTime(QDate::currentDate().addDays(1 + 7 - currentDayofWeek), 1, secondWeekNum)); + beginDateTime.append(getWeekFrontPartDateTime(QDate::currentDate(), firstWeekNum, false)); + } else { + //日程开始时间小于等于当前时间 + beginDateTime.append(getWeekBackPartDateTime(QDate::currentDate().addDays(1), 7, false)); + beginDateTime.append(getWeekAllDateTime(QDate::currentDate().addDays(1 + 7 - currentDayofWeek), 1, secondWeekNum)); + beginDateTime.append(getWeekFrontPartDateTime(QDate::currentDate(), firstWeekNum, true)); + } + } else if (currentDayofWeek < firstWeekNum && currentDayofWeek > secondWeekNum) { + //今天所在周数小于开始周数,大于结束周数 + beginDateTime.append(getWeekAllDateTime(QDate::currentDate().addDays(firstWeekNum - currentDayofWeek),firstWeekNum, 7)); + beginDateTime.append(getWeekAllDateTime(QDate::currentDate().addDays(1 + 7 - currentDayofWeek), 1, secondWeekNum)); + } else if (currentDayofWeek <= secondWeekNum) { + //今天所在周数小于等于结束周数 + if (m_begintime.time() > QTime::currentTime()) { + //日程开始时间大于当前时间 + beginDateTime.append(getWeekBackPartDateTime(QDate::currentDate(), secondWeekNum, true)); + beginDateTime.append(getWeekAllDateTime(QDate::currentDate().addDays(firstWeekNum - currentDayofWeek), firstWeekNum, 7)); + beginDateTime.append(getWeekFrontPartDateTime(QDate::currentDate(), 1, false)); + } else { + //日程开始时间小于等于当前时间 + beginDateTime.append(getWeekBackPartDateTime(QDate::currentDate().addDays(1), secondWeekNum, false)); + beginDateTime.append(getWeekAllDateTime(QDate::currentDate().addDays(firstWeekNum - currentDayofWeek), firstWeekNum, 7)); + beginDateTime.append(getWeekFrontPartDateTime(QDate::currentDate(), 1, true)); + } + } + + return beginDateTime; +} + +QVector createScheduleTask::getWeekAllDateTime(QDate BeginDate, int firstWeekNum, int secondWeekNum) +{ + QVector beginDateTime; + + for (int i = 0; i < secondWeekNum - firstWeekNum + 1; i ++) { + m_begintime.setDate(BeginDate.addDays(i)); + beginDateTime.append(m_begintime); + } + + return beginDateTime; +} + +QVector createScheduleTask::getWeekFrontPartDateTime(QDate BeginDate, int firstWeekNum, bool containsToday) +{ + QVector beginDateTime {}; + int currentDayofWeek = QDate::currentDate().dayOfWeek(); + int addDays = getCreatesDays(firstWeekNum, currentDayofWeek, containsToday); + + for (int i = 0; i < addDays; i++) { + m_begintime.setDate(BeginDate.addDays(firstWeekNum + 7 - currentDayofWeek + i)); + beginDateTime.append(m_begintime); + } + + return beginDateTime; +} + +QVector createScheduleTask::getWeekBackPartDateTime(QDate BeginDate, int secondWeekNum, bool containsToday) +{ + QVector beginDateTime {}; + int currentDayofWeek = QDate::currentDate().dayOfWeek(); + int addDays = getCreatesDays(currentDayofWeek, secondWeekNum, containsToday); + + for (int i = 0; i < addDays; i++) { + m_begintime.setDate(BeginDate.addDays(i)); + beginDateTime.append(m_begintime); + } + + return beginDateTime; +} + +ScheduleDtailInfo createScheduleTask::setDateTimeAndGetSchedule(QDateTime beginDateTime, QDateTime endDateTime) +{ + m_widget->setDateTime(beginDateTime, endDateTime); + m_widget->setschedule(); + + return m_widget->getScheduleDtailInfo(); +} + +QVector createScheduleTask::analysisWorkDayDate() +{ + QVector beginDateTime {}; + + if (m_begintime.date().dayOfWeek() == 6) + m_begintime.setDate(m_begintime.date().addDays(2)); + if (m_begintime.date().dayOfWeek() == 7) + m_begintime.setDate(m_begintime.date().addDays(1)); + beginDateTime.append(m_begintime); + + return beginDateTime; +} + +QDate createScheduleTask::getValidDate(QDate viewDate, int viewDateDay) +{ + //设置一个无效时间 + QDate validDate(QDate(0,0,0)); + //初始化年 + int month = viewDate.month(); + //判断未来半年的时间是否合法 + for (int i = month; i <= month + 6; i++) { + //设置月 + validDate = viewDate.addMonths(i - month); + //设置时间 + validDate.setDate(validDate.year(), validDate.month(), viewDateDay); + //判断日期是否合法 + if (validDate.isValid()) + return validDate; + } + //返回判断时间 + return validDate; +} + +QVector createScheduleTask::analysisEveryWeekDate(QVector dateRange) +{ + QVector beginDateTime {}; + + switch (dateRange.size()) { + case 0: { + //每周重复日程,没有具体周数 + beginDateTime = getNoneWeekNumDate(); + } + break; + case 1: { + //每周重复日程,只有一个周数 + beginDateTime = getOneWeekNumDate(dateRange[0]); + } + break; + case 2: { + //每周重复日程,有两个周数 + beginDateTime = getTwoWeekNumDate(dateRange[0], dateRange[1]); + } + break; + } + + return beginDateTime; +} + +QVector createScheduleTask::analysisEveryMonthDate(QVector dateRange) +{ + QVector beginDateTime {}; + + switch (dateRange.size()) { + case 0: { + //每月重复日程,没有具体日期 + beginDateTime = getNoneMonthNumDate(); + } + break; + case 1: { + //每月重复日程,只有一个日期 + beginDateTime = getOneMonthNumDate(dateRange[0]); + } + break; + case 2: { + //每月重复日程,有两个日期 + beginDateTime = getTwoMonthNumDate(dateRange[0], dateRange[1]); + } + break; + } + + return beginDateTime; +} + +QVector createScheduleTask::getNoneMonthNumDate() +{ + QVector beginDateTime {}; + + if (m_begintime.time() > QTime::currentTime()) { + //日程开始时间大于当前时间 + m_begintime.setDate(QDate::currentDate()); + } else { + //日程开始时间小于等于当前时间 + m_begintime.setDate(QDate::currentDate().addDays(1)); + } + beginDateTime.append(m_begintime); + + return beginDateTime; +} + +QVector createScheduleTask::getOneMonthNumDate(int firstMonthNum) +{ + QVector beginDateTime {}; + //今天 + int currentDayofMonth = QDate::currentDate().day(); + + if (currentDayofMonth < firstMonthNum) { + //今天小于开始日期 + //获取合法日期 + QDate validDate = getValidDate(QDate::currentDate(),firstMonthNum); + //日期合法,设置日期 + if (validDate.isValid()) + m_begintime.setDate(validDate); + } else if (currentDayofMonth > firstMonthNum) { + //获取合法日期 + QDate validDate = getValidDate(QDate::currentDate().addMonths(1),firstMonthNum); + //日期合法,设置日期 + if (validDate.isValid()) + m_begintime.setDate(validDate); + } else { + //当前日期等于开始日期 + if (m_begintime.time() > QTime::currentTime()) { + //日程开始时间大于当前时间 + m_begintime.setDate(QDate::currentDate()); + } else { + //日程开始时间小于等于当前时间 + m_begintime.setDate(QDate::currentDate().addMonths(1)); + } + } + beginDateTime.append(m_begintime); + + return beginDateTime; +} + +QVector createScheduleTask::getTwoMonthNumDate(int firstMonthNum, int secondMonthNum) +{ + QVector beginDateTime {}; + + if (firstMonthNum == secondMonthNum) { + //开始日期等于结束日期,为每天 + getEveryDaySchedule(); + return beginDateTime; + } else if (firstMonthNum < secondMonthNum) { + //开始日期小于结束日期 + beginDateTime.append(firstMonthNumLessThanSecond(firstMonthNum, secondMonthNum)); + } else { + //开始日期大于结束日期 + if (firstMonthNum - secondMonthNum == 1) { + //开始日期和结束日期差一天,为每天 + getEveryDaySchedule(); + return beginDateTime; + } else { + //开始日期大于结束日期的其他情况 + beginDateTime.append(firstMonthNumGreaterThanSecondButEveryDay(firstMonthNum, secondMonthNum)); + } + } + + return beginDateTime; +} + +QVector createScheduleTask::firstMonthNumLessThanSecond(int firstMonthNum, int secondWMonthNum) +{ + QVector beginDateTime {}; + int currentDayofMonth = QDate::currentDate().day(); + + if (currentDayofMonth < firstMonthNum) { + //今天的日期小于开始日期 + beginDateTime.append(getMonthAllDateTime(QDate::currentDate().addDays(firstMonthNum - currentDayofMonth), firstMonthNum, secondWMonthNum)); + } else if (currentDayofMonth >= firstMonthNum && currentDayofMonth <= secondWMonthNum) { + //今天的日期大于等于开始日期,小于等于结束日期 + if (m_begintime.time() > QTime::currentTime()) { + //日程开始时间大于当前时间 + beginDateTime.append(getMonthBackPartDateTime(QDate::currentDate(), secondWMonthNum, true)); + beginDateTime.append(getMonthFrontPartDateTime(QDate::currentDate(), firstMonthNum, false)); + } else { + //日程开始时间小于等于当前时间 + beginDateTime.append(getMonthBackPartDateTime(QDate::currentDate().addDays(1), secondWMonthNum, false)); + beginDateTime.append(getMonthFrontPartDateTime(QDate::currentDate(), firstMonthNum, true)); + } + } else if (currentDayofMonth > secondWMonthNum) { + //今天的日程大于结束日期 + beginDateTime.append(getMonthAllDateTime(QDate::currentDate().addDays(firstMonthNum - currentDayofMonth).addMonths(1), firstMonthNum, secondWMonthNum)); + } + + return beginDateTime; +} + +QVector createScheduleTask::getMonthAllDateTime(QDate BeginDate, int firstMonthNum, int secondMonthNum) +{ + QVector beginDateTime; + //设置日期 + for (int i = firstMonthNum; i <= secondMonthNum; i++) { + //日期是否合法 + QDate validDate = getValidDate(BeginDate, i); + //合法日期,设置日期 + if (validDate.isValid()) { + m_begintime.setDate(validDate); + beginDateTime.append(m_begintime); + } + } + + return beginDateTime; +} + +QVector createScheduleTask::getMonthFrontPartDateTime(QDate BeginDate, int firstMonthNum, bool containsToday) +{ + QVector beginDateTime {}; + int currentDayofMonth = QDate::currentDate().day(); + //包含今天 + if (containsToday) + currentDayofMonth +=1; + //设置日期 + for (int i = firstMonthNum; i < currentDayofMonth; i++) { + //获取合法日期 + QDate validDate = getValidDate(BeginDate.addDays(firstMonthNum - currentDayofMonth).addMonths(1), i); + //合法日期 + if (validDate.isValid()) { + m_begintime.setDate(validDate); + beginDateTime.append(m_begintime); + } + } + + return beginDateTime; +} + +QVector createScheduleTask::getMonthBackPartDateTime(QDate BeginDate, int secondMonthNum, bool containsToday) +{ + QVector beginDateTime {}; + int currentDayofMonth = QDate::currentDate().day(); + //不包含今天 + if (!containsToday) + currentDayofMonth +=1; + //设置日期 + for (int i = currentDayofMonth; i < secondMonthNum + 1; i++) { + //获取合法日期 + QDate validDate = getValidDate(BeginDate, i); + //日期合法 + if (validDate.isValid()) { + m_begintime.setDate(validDate); + beginDateTime.append(m_begintime); + } + } + + return beginDateTime; + +} + +QVector createScheduleTask::firstMonthNumGreaterThanSecondButEveryDay(int firstMonthNum, int secondMonthNum) +{ + QVector beginDateTime {}; + int currentDayofMonth = QDate::currentDate().day(); + + if (currentDayofMonth >= firstMonthNum) { + //今天的日期大于等于开始的日期 + if (m_begintime.time() > QTime::currentTime()) { + //日程开始时间大于当前时间 + beginDateTime.append(getMonthBackPartDateTime(QDate::currentDate(), QDate::currentDate().daysInMonth(), true)); + beginDateTime.append(getMonthAllDateTime(QDate::currentDate().addDays(1 - currentDayofMonth), 1, secondMonthNum)); + beginDateTime.append(getMonthFrontPartDateTime(QDate::currentDate(), firstMonthNum, false)); + } else { + //日程开始时间小于等于当前时间 + beginDateTime.append(getMonthBackPartDateTime(QDate::currentDate().addDays(1), QDate::currentDate().daysInMonth(), false)); + beginDateTime.append(getMonthAllDateTime(QDate::currentDate().addDays(1 - currentDayofMonth), 1, secondMonthNum)); + beginDateTime.append(getMonthFrontPartDateTime(QDate::currentDate(), firstMonthNum, true)); + } + } else if (currentDayofMonth < firstMonthNum && currentDayofMonth > secondMonthNum) { + //今天的日期小于开始日期,大于结束日期 + beginDateTime.append(getMonthAllDateTime(QDate::currentDate().addDays(firstMonthNum - currentDayofMonth), firstMonthNum, QDate::currentDate().daysInMonth())); + beginDateTime.append(getMonthAllDateTime(QDate::currentDate().addDays(1 - currentDayofMonth).addMonths(1), 1, secondMonthNum)); + } else if (currentDayofMonth <= secondMonthNum) { + //今天的日期小于等于结束日期 + if (m_begintime.time() > QTime::currentTime()) { + //日程开始时间大于当前时间 + beginDateTime.append(getMonthBackPartDateTime(QDate::currentDate(), secondMonthNum, true)); + beginDateTime.append(getMonthAllDateTime(QDate::currentDate().addDays(firstMonthNum - currentDayofMonth), firstMonthNum, QDate::currentDate().daysInMonth())); + beginDateTime.append(getMonthFrontPartDateTime(QDate::currentDate(), 1, false)); + } else { + //日程开始时间小于等于当前时间 + beginDateTime.append(getMonthBackPartDateTime(QDate::currentDate().addDays(1), secondMonthNum, false)); + beginDateTime.append(getMonthAllDateTime(QDate::currentDate().addDays(firstMonthNum - currentDayofMonth), firstMonthNum, QDate::currentDate().daysInMonth())); + beginDateTime.append(getMonthFrontPartDateTime(QDate::currentDate(), 1, true)); + } + } + + return beginDateTime; +} + +QVector createScheduleTask::analysisRestDayDate() +{ + QVector beginDateTime {}; + //周六的日程开始时间 + QDateTime beginDateTimeSat = m_begintime; + //周日的日程开始时间 + QDateTime beginDateTimeSun = m_begintime; + int currentDayofWeek = QDate::currentDate().dayOfWeek(); + //设置周六的时间 + beginDateTimeSat.setDate(QDate::currentDate().addDays(6 - currentDayofWeek)); + //设置周日的时间 + beginDateTimeSun.setDate(QDate::currentDate().addDays(7 - currentDayofWeek)); + //如果周六的时间小于当前时间,设置日程开始时间为下一周的周六 + if (beginDateTimeSat < QDateTime::currentDateTime()) + beginDateTimeSat.setDate(beginDateTimeSat.date().addDays(7)); + //如果周日的时间小于当前时间,设置日程开始时间为下一周的周日 + if (beginDateTimeSun < QDateTime::currentDateTime()) + beginDateTimeSun.setDate(beginDateTimeSun.date().addDays(7)); + //将周末的日程开始时间放到时间容器里面 + beginDateTime.append(beginDateTimeSat); + beginDateTime.append(beginDateTimeSun); + + return beginDateTime; +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/task/createscheduletask.h dde-calendar-5.7.0.23/schedule-plugin/src/task/createscheduletask.h --- dde-calendar-5.7.0.4/schedule-plugin/src/task/createscheduletask.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/task/createscheduletask.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,284 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef CREATESCHEDULETASK_H +#define CREATESCHEDULETASK_H + +#include "schedulebasetask.h" +#include "../data/createjsondata.h" +#include "../widget/createschedulewidget.h" + +class createScheduleTask : public scheduleBaseTask +{ + Q_OBJECT +public: + createScheduleTask(CSchedulesDBus *dbus); + Reply SchedulePress(semanticAnalysisTask &semanticTask) override; + +private: + /** + * @brief setDateTime 设置查询的开始结束时间 + * @param queryJsonData jsondata句柄 + */ + void setDateTime(CreateJsonData *createJsonData); + /** + * @brief setScheduleTitleName 设置日程的titlename + * @param createJsonData jsondata句柄 + */ + void setScheduleTitleName(CreateJsonData *createJsonData); + /** + * @brief createScheduleWithRepeatStatus 新建日程 + * @param createJsonData jsondata句柄 + * @return 日程信息 + */ + QVector createScheduleWithRepeatStatus(CreateJsonData *createJsonData); + /** + * @brief creareScheduleUI 新建日程插件 + * @param schedule 日程信息 + */ + void creareScheduleUI(QVector schedule); + /** + * @brief getReply 获取回复语 + * @param createJsonData jsondata句柄 + * @return 回复语 + */ + QString getReply(CreateJsonData *createJsonData); + /** + * @brief beginDateTimeIsinHalfYear 判断时间是否合法 + * @return 时间是否合法 + */ + bool beginDateTimeIsinHalfYear(); + /** + * @brief beginDateTimeOutHalfYear 日程开始时间超过半年范围 + * @return true or false + */ + bool beginDateTimeOutHalfYear(); + /** + * @brief buginDateTimeBeforeCurrent 日程开始时间早于当前时间 + * @return true or false + */ + bool beginDateTimeBeforeCurrent(); + /** + * @brief setNotRepeatDay 获取非重复的日程 + * @return 日程信息 + */ + QVector getNotRepeatDaySchedule(); + /** + * @brief getEveryDaySchedule 获取每天重复的日程 + * @return 日程信息 + */ + QVector getEveryDaySchedule(); + /** + * @brief getEveryWeekSchedule 获取每周重复的日程 + * @param dateRange 开始和结束的周数 + * @return 日程信息 + */ + QVector getEveryWeekSchedule(QVector dateRange); + /** + * @brief getEveryMonthSchedule 获取每月重复的日程 + * @param dateRange 开始和结束的日期数 + * @return 日程信息 + */ + QVector getEveryMonthSchedule(QVector dateRange); + /** + * @brief getEveryDYearSchedule 获取每年重复的日程 + * @return 日程信息 + */ + QVector getEveryYearSchedule(); + /** + * @brief getEveryWorkDaySchedule 获取工作日的日程 + * @return 日程信息 + */ + QVector getEveryWorkDaySchedule(); + /** + * @brief getEveryRestDaySchedule 获取休息日的日程 + * @return 日程信息 + */ + QVector getEveryRestDaySchedule(); + /** + * @brief getFirstSchedule 获取第一个日程 + * @param scheduleInfo 所有日程信息的容器 + * @return 第一个日程的日程信息 + */ + ScheduleDtailInfo getFirstSchedule(QVector scheduleInfo); + /** + * @brief getCreatesDays 获取新建日程的天数 + * @param firstDay 开始日期 + * @param secondday 结束日期 + * @param containsToday 是否包含今天 + * @return 总天数 + */ + int getCreatesDays(int firstDay, int secondday, bool containsToday); + /** + * @brief getNoneWeekNumDate 获取没有周数的重复日程的日期 + * @return 日期容器 + */ + QVector getNoneWeekNumDate(); + /** + * @brief getOneWeekNumDate 获取有一个周数的重复日程的日期 + * @param firstWeekNum 这个周数是周几 + * @return 日期容器 + */ + QVector getOneWeekNumDate(int firstWeekNum); + /** + * @brief getTwoWeekNumDate 获取有两个周数的重复日程的日期 + * @param firstWeekNum 第一个周数是周几 + * @param secondWeekNum 第二个周数是周几 + * @return 日期容器 + */ + QVector getTwoWeekNumDate(int firstWeekNum, int secondWeekNum); + /** + * @brief firstWeekNumLessThanSecond 获取第一个周数小于第二个周数的日程的日期 + * @param firstWeekNum 第一个周数 + * @param secondWeekNum 第二个周数 + * @return 日期容器 + */ + QVector firstWeekNumLessThanSecond(int firstWeekNum, int secondWeekNum); + /** + * @brief firstWeekNumGreaterThanSecondButEveryDay 获取第一个周数大于第二个周数但不包含全天日程的日程 + * @param firstWeekNum 第一个周数 + * @param secondWeekNum 第二个周数 + * @return 日期容器 + */ + QVector firstWeekNumGreaterThanSecondButEveryDay(int firstWeekNum, int secondWeekNum); + /** + * @brief getWeekAllDateTime 获取所有的周重复日程的时间 + * @param BeginDate 日程开始的时间 + * @param firstDayofWeek 获取到的第一个周数 + * @param secondDayofWeek 获取到的第二个周数 + * @return DateTime容器 + */ + QVector getWeekAllDateTime(QDate BeginDate, int firstWeekNum, int secondWeekNum); + /** + * @brief getWeekFrontPartDateTime 获取当前时间之前的日程时间 + * @param BeginDate 日程开始的时间 + * @param firstDate 获取到的第一个周数 + * @param containsToday 是否包含今天 + * @return DateTime容器 + */ + QVector getWeekFrontPartDateTime(QDate BeginDate, int firstWeekNum, bool containsToday); + /** + * @brief getWeekBackPartDateTime 获取当前时间之后的日程时间 + * @param BeginDate 日程开始时间 + * @param secondDayofWeek 获取到的第二个周数 + * @param containsToday 是否包含今天 + * @return DateTime容器 + */ + QVector getWeekBackPartDateTime(QDate BeginDate, int secondWeekNum, bool containsToday); + /** + * @brief analysisEveryWeekDate 解析每周重复日程的日期 + * @param dateRange 周数范围 + * @return 日期容器 + */ + QVector analysisEveryWeekDate(QVector dateRange); + /** + * @brief analysisEveryMonthDate 解析每月重复日程的日期 + * @param dateRange 日期范围 + * @return 日期容器 + */ + QVector analysisEveryMonthDate(QVector dateRange); + /** + * @brief getNoneMonthNumDate 获取没有日期的每月重复日程的日期 + * @return 日期容器 + */ + QVector getNoneMonthNumDate(); + /** + * @brief getOneMonthNumDate 获取有一个日期的每月重复日程的日期 + * @param firstMonthNum 第一个日期是几号 + * @return 日期容器 + */ + QVector getOneMonthNumDate(int firstMonthNum); + /** + * @brief getTwoMonthNumDate 获取有两个日期的每月重复日程的日程 + * @param firstMonthNum 第一个日期是几号 + * @param secondMonthNum 第二个日期是几号 + * @return 日期容器 + */ + QVector getTwoMonthNumDate(int firstMonthNum, int secondMonthNum); + /** + * @brief getMonthAllDateTime 获取每月重复日程的日期 + * @param BeginDate 开始时间 + * @param firstMonthNum 第一个日期 + * @param secondMonthNum 第二个日期 + * @return 日期容器 + */ + QVector getMonthAllDateTime(QDate BeginDate, int firstMonthNum, int secondMonthNum); + /** + * @brief getMonthFrontPartDateTime 获取当前时间之前的日程日期 + * @param BeginDate 开始时间 + * @param firstMonthNum 第一个日期 + * @param containsToday 是否包含今天 + * @return 日期容器 + */ + QVector getMonthFrontPartDateTime(QDate BeginDate, int firstMonthNum, bool containsToday); + /** + * @brief getMonthBackPartDateTime 获取当前时间之后的日程日期 + * @param BeginDate 开始时间 + * @param secondMonthNum 第二个日期 + * @param containsToday 是否包含今天 + * @return 日期容器 + */ + QVector getMonthBackPartDateTime(QDate BeginDate, int secondMonthNum, bool containsToday); + /** + * @brief firstMonthNumLessThanSecond 第一个日期小于第二个日期的日程的日期 + * @param firstMonthNum 第一个日期 + * @param secondWMonthNum 第二个日期 + * @return 日期容器 + */ + QVector firstMonthNumLessThanSecond(int firstMonthNum, int secondWMonthNum); + /** + * @brief firstMonthNumGreaterThanSecondButEveryDay 第一个日期大于第二个日期但不包含每天的日程的日期 + * @param firstMonthNum 第一个日期 + * @param secondMonthNum 第二个日期 + * @return 日期容器 + */ + QVector firstMonthNumGreaterThanSecondButEveryDay(int firstMonthNum, int secondMonthNum); + /** + * @brief analysisRestDayDate 解析休息日的日程的日期 + * @return 日期容器 + */ + QVector analysisRestDayDate(); + /** + * @brief setDateTimeAndGetSchedule 设置日程开始结束时间,并获取日程信息 + * @param beginDateTime 日程开始时间 + * @param endDateTime 日程结束时间 + * @return 日程信息 + */ + ScheduleDtailInfo setDateTimeAndGetSchedule(QDateTime beginDateTime, QDateTime endDateTime); + /** + * @brief analysisWorkDayDate 解析工作日的日程的日期 + * @return 日期容器 + */ + QVector analysisWorkDayDate(); + /** + * @brief getValidDate 判断是否是合法日期 + * @param viewDate 判断的日期 + * @param viewDateDay 判断哪一天 + * @return 日期 + */ + QDate getValidDate(QDate viewDate, int viewDateDay); +private: + QDateTime m_begintime; + QDateTime m_endtime; + bool everyDayState = false; + createSchedulewidget *m_widget = nullptr; +}; + +#endif // CREATESCHEDULETASK_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/task/queryscheduleproxy.cpp dde-calendar-5.7.0.23/schedule-plugin/src/task/queryscheduleproxy.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/task/queryscheduleproxy.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/task/queryscheduleproxy.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,476 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "queryscheduleproxy.h" + +#include "../globaldef.h" +#include "../data/changejsondata.h" + +bool scheduleSort(const ScheduleDtailInfo &s1, const ScheduleDtailInfo &s2) +{ + if (s1.beginDateTime < s2.beginDateTime) { + return true; + } else if (s1.beginDateTime == s2.beginDateTime) { + return s1.endDateTime < s2.endDateTime; + } else { + return false; + } +} + +queryScheduleProxy::queryScheduleProxy(JsonData *jsonData, CSchedulesDBus *dbus) + : m_queryJsonData(jsonData) + , m_dbus(dbus) +{ +} + +QVector queryScheduleProxy::querySchedule() +{ + QVector scheduleInfo {}; + scheduleInfo.clear(); + switch (m_queryJsonData->getRepeatStatus()) { + case JsonData::RepeatStatus::NONE: + scheduleInfo = queryNonRepeatingSchedule(); + break; + case JsonData::RepeatStatus::EVED: { + TIME_FRAME_IN_THE_NEXT_SIX_MONTHT + scheduleInfo = queryEveryDaySchedule(beginTime, endTime); + if (!m_queryJsonData->TitleName().isEmpty()) { + scheduleInfo = scheduleFileterByTitleName(scheduleInfo, m_queryJsonData->TitleName()); + } + } break; + case JsonData::RepeatStatus::EVEW: { + TIME_FRAME_IN_THE_NEXT_SIX_MONTHT + int beginW = 0; + int endW = 0; + if (m_queryJsonData->getRepeatNum().size() == 0) { + } else if (m_queryJsonData->getRepeatNum().size() == 1) { + beginW = m_queryJsonData->getRepeatNum().at(0); + endW = m_queryJsonData->getRepeatNum().at(0); + } else { + beginW = m_queryJsonData->getRepeatNum().at(0); + endW = m_queryJsonData->getRepeatNum().at(1); + } + scheduleInfo = queryWeeklySchedule(beginTime, endTime, beginW, endW); + SemanticsDateTime queryDatetime = getQueryDateTime(m_queryJsonData); + TimeLimit fileterTime = getTimeFileterByTimeInfo(queryDatetime); + if (!fileterTime.isInvalid) { + scheduleInfo = scheduleFileterByTime(scheduleInfo, fileterTime.beginTime, fileterTime.endTime); + } + if (!m_queryJsonData->TitleName().isEmpty()) { + scheduleInfo = scheduleFileterByTitleName(scheduleInfo, m_queryJsonData->TitleName()); + } + } break; + case JsonData::RepeatStatus::EVEM: { + TIME_FRAME_IN_THE_NEXT_SIX_MONTHT + int beginM = 0; + int endM = 0; + if (m_queryJsonData->getRepeatNum().size() == 0) { + } else if (m_queryJsonData->getRepeatNum().size() == 1) { + beginM = m_queryJsonData->getRepeatNum().at(0); + endM = m_queryJsonData->getRepeatNum().at(0); + } else { + beginM = m_queryJsonData->getRepeatNum().at(0); + endM = m_queryJsonData->getRepeatNum().at(1); + } + scheduleInfo = queryMonthlySchedule(beginTime, endTime, beginM, endM); + if (!m_queryJsonData->TitleName().isEmpty()) { + scheduleInfo = scheduleFileterByTitleName(scheduleInfo, m_queryJsonData->TitleName()); + } + } break; + case JsonData::RepeatStatus::EVEY: { + TIME_FRAME_IN_THE_NEXT_SIX_MONTHT + scheduleInfo = queryEveryYearSchedule(beginTime, endTime); + if (!m_queryJsonData->TitleName().isEmpty()) { + scheduleInfo = scheduleFileterByTitleName(scheduleInfo, m_queryJsonData->TitleName()); + } + } break; + case JsonData::RepeatStatus::RESTD: { + TIME_FRAME_IN_THE_NEXT_SIX_MONTHT + scheduleInfo = queryWeeklySchedule(beginTime, endTime, 6, 7); + if (!m_queryJsonData->TitleName().isEmpty()) { + scheduleInfo = scheduleFileterByTitleName(scheduleInfo, m_queryJsonData->TitleName()); + } + } break; + case JsonData::RepeatStatus::WORKD: { + TIME_FRAME_IN_THE_NEXT_SIX_MONTHT + scheduleInfo = queryWorkingDaySchedule(beginTime, endTime); + if (!m_queryJsonData->TitleName().isEmpty()) { + scheduleInfo = scheduleFileterByTitleName(scheduleInfo, m_queryJsonData->TitleName()); + } + } break; + } + return scheduleInfo; +} + +QVector queryScheduleProxy::queryWeeklySchedule(QDateTime &beginTime, QDateTime &endTime, int beginW, int endW) +{ + QSet weeklySet; + if (beginW == endW) { + weeklySet.insert(beginW); + } else if (beginW < endW) { + if (beginW == 1) { + if (endW == 5) { + //WORK + return queryWorkingDaySchedule(beginTime, endTime); + } else if (endW == 7) { + //EVED + return queryEveryDaySchedule(beginTime, endTime); + } + } + for (int i = beginW; i <= endW; ++i) { + weeklySet.insert(i); + } + } else { + if (beginW - endW == 1) { + //EVED + return queryEveryDaySchedule(beginTime, endTime); + } + int w; + for (int i = beginW; i <= endW + 7; ++i) { + w = i % 7; + w = w ? w : 7; + weeklySet.insert(w); + } + } + QVector out {}; + m_dbus->QueryJobsWithRule(beginTime, endTime, DBUS_RRUL_EVEW, out); + + if (beginW == 0 || endW == 0) { + weeklySet.clear(); + } + + return WeeklyScheduleFileter(out, weeklySet); +} + +QVector queryScheduleProxy::queryMonthlySchedule(QDateTime &beginTime, QDateTime &endTime, int beginM, int endM) +{ + QVector out {}; + m_dbus->QueryJobsWithRule(beginTime, endTime, DBUS_RRUL_EVEM, out); + return MonthlyScheduleFileter(out, beginM, endM); +} + +QVector queryScheduleProxy::queryEveryDaySchedule(QDateTime &beginTime, QDateTime &endTime) +{ + QVector out {}; + m_dbus->QueryJobsWithRule(beginTime, endTime, DBUS_RRUL_EVED, out); + return sortAndFilterSchedule(out); +} + +QVector queryScheduleProxy::queryEveryYearSchedule(QDateTime &beginTime, QDateTime &endTime) +{ + QVector out {}; + m_dbus->QueryJobsWithRule(beginTime, endTime, DBUS_RRUL_EVEY, out); + return sortAndFilterSchedule(out); +} + +QVector queryScheduleProxy::queryWorkingDaySchedule(QDateTime &beginTime, QDateTime &endTime) +{ + QVector out {}; + m_dbus->QueryJobsWithRule(beginTime, endTime, DBUS_RRUL_WORK, out); + return sortAndFilterSchedule(out); +} + +QVector queryScheduleProxy::queryNonRepeatingSchedule() +{ + QVector mScheduleInfoVector {}; + mScheduleInfoVector.clear(); + SemanticsDateTime queryDatetime = getQueryDateTime(m_queryJsonData); + //如果开始时间大于结束时间则退出 + if(!timeFrameIsValid(queryDatetime)){ + return mScheduleInfoVector; + } + switch (m_queryJsonData->getPropertyStatus()) { + case JsonData::PropertyStatus::ALL: { + DateTimeLimit timeLimit = getTimeLimitByTimeInfo(queryDatetime); + if (!getTimeIsExpired()) { + mScheduleInfoVector = queryAllSchedule(m_queryJsonData->TitleName(), timeLimit.beginTime, timeLimit.endTime); + } + } break; + case JsonData::PropertyStatus::NEXT: { + TIME_FRAME_IN_THE_NEXT_SIX_MONTHT + mScheduleInfoVector = queryNextNumSchedule(beginTime, endTime, 1); + } break; + case JsonData::PropertyStatus::LAST: { + } break; + default: { + //NONE + DateTimeLimit timeLimit = getTimeLimitByTimeInfo(queryDatetime); + if (!getTimeIsExpired()) { + mScheduleInfoVector = queryAllSchedule(m_queryJsonData->TitleName(), timeLimit.beginTime, timeLimit.endTime); + } + } break; + } + return mScheduleInfoVector; +} + +QVector queryScheduleProxy::queryNextNumSchedule(QDateTime &beginTime, QDateTime &endTime, int NextNum) +{ + QVector mScheduleInfoVector {}; + QVector out {}; + m_dbus->QueryJobsWithLimit(beginTime, endTime, NextNum, out); + return sortAndFilterSchedule(out); +} + +QVector queryScheduleProxy::queryAllSchedule(QString key, QDateTime &beginTime, QDateTime &endTime) +{ + QVector out {}; + m_dbus->QueryJobs(key, beginTime, endTime, out); + return sortAndFilterSchedule(out); +} + +QVector queryScheduleProxy::sortAndFilterSchedule(QVector &out) +{ + QVector scheduleInfo {}; + for (int i = 0; i < out.size(); ++i) { + for (int j = 0; j < out[i].vData.size(); ++j) { + if (!(scheduleInfo.contains(out[i].vData[j]) || out[i].vData[j].type.ID == 4)) { + scheduleInfo.append(out[i].vData[j]); + } + } + } + std::sort(scheduleInfo.begin(), scheduleInfo.end(), scheduleSort); + return scheduleInfo; +} + +QVector queryScheduleProxy::WeeklyScheduleFileter(QVector &out, QSet &weeklySet) +{ + QVector scheduleInfo {}; + if (weeklySet.size() == 0) { + return sortAndFilterSchedule(out); + } else { + for (int i = 0; i < out.size(); ++i) { + for (int j = 0; j < out[i].vData.size(); ++j) { + if (!(scheduleInfo.contains(out[i].vData[j])) && weeklyIsIntersections(out[i].vData[j].beginDateTime, out[i].vData[j].endDateTime, weeklySet)) { + scheduleInfo.append(out[i].vData[j]); + } + } + } + } + return scheduleInfo; +} + +QVector queryScheduleProxy::MonthlyScheduleFileter(QVector &out, int beginM, int endM) +{ + if (beginM == 0 || endM == 0) { + return sortAndFilterSchedule(out); + } + QVector scheduleInfo {}; + for (int i = 0; i < out.size(); ++i) { + for (int j = 0; j < out[i].vData.size(); ++j) { + if (!(scheduleInfo.contains(out[i].vData[j])) && monthlyIsIntersections(out[i].vData[j].beginDateTime, out[i].vData[j].endDateTime, beginM, endM)) { + scheduleInfo.append(out[i].vData[j]); + } + } + } + return scheduleInfo; +} + +bool queryScheduleProxy::monthlyIsIntersections(QDateTime &beginTime, QDateTime &endTime, int beginM, int endM) +{ + bool b_monthly = false; + int beginDay = beginTime.date().day(); + int endDay = endTime.date().day(); + if (beginM > endM) { + b_monthly = beginDay > endM && endDay < beginM ? false : true; + } else { + b_monthly = (beginM <= beginDay && endM >= beginDay) || (beginM <= endDay && endM >= endDay) + || (beginDay <= beginM && endDay >= endM); + } + return b_monthly; +} + +bool queryScheduleProxy::checkedTimeIsIntersection(QTime &beginTime, QTime &endTime, QTime &fixbeginTime, QTime &fixendTime) +{ + bool b_checked = false; + if (beginTime.secsTo(endTime) < 0) { + if (fixbeginTime.secsTo(fixendTime) < 0) { + b_checked = true; + } else { + b_checked = endTime.secsTo(fixbeginTime) > 0 && fixendTime.secsTo(beginTime) > 0 ? false : true; + } + } else { + if (fixbeginTime.secsTo(fixendTime) < 0) { + b_checked = fixendTime.secsTo(beginTime) > 0 && endTime.secsTo(fixbeginTime) > 0 ? false : true; + } else { + b_checked = (beginTime.secsTo(fixbeginTime) >= 0 && fixbeginTime.secsTo(endTime) >= 0) + || (beginTime.secsTo(fixendTime) >= 0 && fixendTime.secsTo(endTime) >= 0); + } + } + return b_checked; +} + +QVector queryScheduleProxy::scheduleFileterByTime(QVector &scheduleInfo, QTime &fileterBeginTime, QTime &fileterEndTime) +{ + QVector mScheduleFileter {}; + qint64 timeoffset_Secs = 0; + bool isApppend = false; + for (int i = 0; i < scheduleInfo.size(); ++i) { + timeoffset_Secs = scheduleInfo.at(i).beginDateTime.secsTo(scheduleInfo.at(i).endDateTime); + isApppend = false; + if (timeoffset_Secs < ONE_DAY_SECS) { + QTime begTime = scheduleInfo.at(i).beginDateTime.time(); + QTime endTime = scheduleInfo.at(i).endDateTime.time(); + isApppend = checkedTimeIsIntersection(begTime, endTime, fileterBeginTime, fileterEndTime); + } else { + isApppend = true; + } + if (isApppend) { + mScheduleFileter.append(scheduleInfo.at(i)); + } + } + return mScheduleFileter; +} + +QVector queryScheduleProxy::scheduleFileterByTitleName(QVector &scheduleInfo, const QString &strName) +{ + QVector mScheduleFileter {}; + for (int i = 0; i < scheduleInfo.size(); ++i) { + if (scheduleInfo.at(i).titleName.contains(strName)) { + mScheduleFileter.append(scheduleInfo.at(i)); + } + } + return mScheduleFileter; +} + +bool queryScheduleProxy::weeklyIsIntersections(QDateTime &beginTime, QDateTime &endTime, QSet &weeklySet) +{ + QSet scheduleWeekSet; + bool returnValue = false; + scheduleWeekSet.clear(); + qint64 dayoffset = beginTime.daysTo(endTime); + if (dayoffset > 5) { + returnValue = true; + } else { + int beginW = beginTime.date().dayOfWeek(); + int w; + for (int i = beginW; i <= beginW + dayoffset; ++i) { + w = i % 7; + w = w ? w : 7; + scheduleWeekSet.insert(w); + } + returnValue = scheduleWeekSet.intersects(weeklySet); + } + return returnValue; +} + +SemanticsDateTime queryScheduleProxy::getQueryDateTime(JsonData *jsonData) +{ + changejsondata *changedata = dynamic_cast(jsonData); + if (changedata != nullptr && changedata->fromDateTime().suggestDatetime.size() > 0) { + return changedata->fromDateTime(); + } + return jsonData->getDateTime(); +} + +queryScheduleProxy::DateTimeLimit queryScheduleProxy::getTimeLimitByTimeInfo(const SemanticsDateTime &timeInfoVect) +{ + DateTimeLimit timeLimit; + setTimeIsExpired(false); + if (timeInfoVect.suggestDatetime.size() == 0) { + TIME_FRAME_IN_THE_NEXT_SIX_MONTHT + timeLimit.beginTime = beginTime; + timeLimit.endTime = endTime; + } else if (timeInfoVect.suggestDatetime.size() == 1) { + if (timeInfoVect.suggestDatetime.at(0).datetime.date() < QDateTime::currentDateTime().date() + || timeInfoVect.suggestDatetime.at(0).datetime.date() > QDateTime::currentDateTime().addDays(MAXIMUM_DAYS_IN_THE_FUTURE).date()) { + setTimeIsExpired(true); + return timeLimit; + } + if (timeInfoVect.suggestDatetime.at(0).hasTime) { + if (timeInfoVect.suggestDatetime.at(0).datetime < QDateTime::currentDateTime()) { + setTimeIsExpired(true); + } else { + timeLimit.beginTime = timeInfoVect.suggestDatetime.at(0).datetime; + timeLimit.endTime = timeInfoVect.suggestDatetime.at(0).datetime; + } + } else { + if (timeInfoVect.suggestDatetime.at(0).datetime.date() == QDateTime::currentDateTime().date()) { + timeLimit.beginTime = QDateTime::currentDateTime(); + timeLimit.endTime.setDate(timeLimit.beginTime.date()); + timeLimit.endTime.setTime(QTime(23, 59, 59)); + } else { + timeLimit.beginTime = timeInfoVect.suggestDatetime.at(0).datetime; + timeLimit.endTime.setDate(timeLimit.beginTime.date()); + timeLimit.endTime.setTime(QTime(23, 59, 59)); + } + } + } else { + QDateTime maxDay = QDateTime::currentDateTime().addDays(MAXIMUM_DAYS_IN_THE_FUTURE); + if (timeInfoVect.suggestDatetime.at(1).datetime.date() < QDateTime::currentDateTime().date() + || timeInfoVect.suggestDatetime.at(0).datetime.date() > maxDay.date()) { + setTimeIsExpired(true); + return timeLimit; + } + if (timeInfoVect.suggestDatetime.at(0).datetime < QDateTime::currentDateTime()) { + timeLimit.beginTime = QDateTime::currentDateTime(); + } else { + timeLimit.beginTime = timeInfoVect.suggestDatetime.at(0).datetime; + } + if (timeInfoVect.suggestDatetime.at(1).hasTime) { + timeLimit.endTime = timeInfoVect.suggestDatetime.at(1).datetime; + } else { + timeLimit.endTime.setDate(timeInfoVect.suggestDatetime.at(1).datetime.date()); + timeLimit.endTime.setTime(QTime(23, 59, 59)); + } + if (timeLimit.endTime.date() > maxDay.date()) { + timeLimit.endTime.setDate(maxDay.date()); + timeLimit.endTime.setTime(QTime(23, 59, 59)); + } + } + return timeLimit; +} + +queryScheduleProxy::TimeLimit queryScheduleProxy::getTimeFileterByTimeInfo(const SemanticsDateTime &timeInfoVect) +{ + TimeLimit fileterTime; + fileterTime.isInvalid = true; + if (timeInfoVect.suggestDatetime.size() == 0) { + } else if (timeInfoVect.suggestDatetime.size() == 1) { + if (timeInfoVect.suggestDatetime.at(0).hasTime) { + fileterTime.beginTime = timeInfoVect.suggestDatetime.at(0).datetime.time(); + fileterTime.endTime = fileterTime.beginTime; + fileterTime.isInvalid = false; + } + } else { + fileterTime.beginTime = timeInfoVect.suggestDatetime.at(0).datetime.time(); + fileterTime.endTime = timeInfoVect.suggestDatetime.at(1).datetime.time(); + fileterTime.isInvalid = false; + } + return fileterTime; +} + +bool queryScheduleProxy::getTimeIsExpired() const +{ + return m_TimeIsExpired; +} + +void queryScheduleProxy::setTimeIsExpired(const bool timeisExp) +{ + m_TimeIsExpired = timeisExp; +} + +bool queryScheduleProxy::timeFrameIsValid(const SemanticsDateTime &timeInfoVect) +{ + //如果开始时间大于结束时间则返回false + if(timeInfoVect.suggestDatetime.size()>1 && timeInfoVect.suggestDatetime.at(0).datetime>timeInfoVect.suggestDatetime.at(1).datetime){ + return false; + } + return true; +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/task/queryscheduleproxy.h dde-calendar-5.7.0.23/schedule-plugin/src/task/queryscheduleproxy.h --- dde-calendar-5.7.0.4/schedule-plugin/src/task/queryscheduleproxy.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/task/queryscheduleproxy.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,82 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef QUERYSCHEDULEPROXY_H +#define QUERYSCHEDULEPROXY_H + +#include "../data/schedulestructs.h" +#include "../data/jsondata.h" +#include "../dbus/schedulesdbus.h" + +class queryScheduleProxy +{ +public: + queryScheduleProxy(JsonData *jsonData, CSchedulesDBus *dbus); + QVector querySchedule(); + bool getTimeIsExpired() const; + +private: + struct DateTimeLimit { + QDateTime beginTime; + QDateTime endTime; + }; + struct TimeLimit { + QTime beginTime; + QTime endTime; + bool isInvalid {false}; + }; + QVector queryWeeklySchedule(QDateTime &beginTime, QDateTime &endTime, int beginW = 0, int endW = 0); + QVector queryMonthlySchedule(QDateTime &beginTime, QDateTime &endTime, int beginM = 0, int endM = 0); + QVector queryEveryDaySchedule(QDateTime &beginTime, QDateTime &endTime); + QVector queryEveryYearSchedule(QDateTime &beginTime, QDateTime &endTime); + QVector queryWorkingDaySchedule(QDateTime &beginTime, QDateTime &endTime); + QVector queryNonRepeatingSchedule(); + QVector queryNextNumSchedule(QDateTime &beginTime, QDateTime &endTime, int NextNum); + QVector queryAllSchedule(QString key, QDateTime &beginTime, QDateTime &endTime); + + QVector sortAndFilterSchedule(QVector &out); + QVector WeeklyScheduleFileter(QVector &out, QSet &weeklySet); + QVector MonthlyScheduleFileter(QVector &out, int beginM = 0, int endM = 0); + bool monthlyIsIntersections(QDateTime &beginTime, QDateTime &endTime, int beginM = 0, int endM = 0); + + bool checkedTimeIsIntersection(QTime &beginTime, QTime &endTime, QTime &fixbeginTime, QTime &fixendTime); + + QVector scheduleFileterByTime(QVector &scheduleInfo, QTime &fileterBeginTime, QTime &fileterEndTime); + QVector scheduleFileterByTitleName(QVector &scheduleInfo, const QString &strName); + bool weeklyIsIntersections(QDateTime &beginTime, QDateTime &endTime, QSet &weeklySet); + + SemanticsDateTime getQueryDateTime(JsonData *jsonData); + + DateTimeLimit getTimeLimitByTimeInfo(const SemanticsDateTime &timeInfoVect); + TimeLimit getTimeFileterByTimeInfo(const SemanticsDateTime &timeInfoVect); + void setTimeIsExpired(const bool timeisExp); + /** + * @brief timeFrameIsValid 时间范围是否有效,开始时间不能大于结束时间 + * @param timeInfoVect 时间范围 + * @return 返回false表示开始时间大于结束时间 + */ + bool timeFrameIsValid(const SemanticsDateTime &timeInfoVect); +private: + JsonData *m_queryJsonData; + CSchedulesDBus *m_dbus {nullptr}; + bool m_TimeIsExpired {false}; +}; + +#endif // QUERYSCHEDULEPROXY_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/task/queryscheduletask.cpp dde-calendar-5.7.0.23/schedule-plugin/src/task/queryscheduletask.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/task/queryscheduletask.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/task/queryscheduletask.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,425 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "queryscheduletask.h" +#include "../globaldef.h" + +queryScheduleTask::queryScheduleTask(CSchedulesDBus *dbus) + : scheduleBaseTask(dbus) +{ +} + +Reply queryScheduleTask::SchedulePress(semanticAnalysisTask &semanticTask) +{ + QueryJsonData *queryJsonData = dynamic_cast(semanticTask.getJsonData()); + //如果转换失败则返回错误消息 + if (queryJsonData == nullptr) + return errorMessage(); + //查询日程 + if (queryJsonData->offset() > -1 + && queryJsonData->getPropertyStatus() == JsonData::PRO_NONE) { + Reply m_reply; + REPLY_ONLY_TTS(m_reply, CANCEL_ERR_TTS, CANCEL_ERR_TTS, true); + return m_reply; + } + + QString m_queryTitleName = queryJsonData->TitleName(); + QVector getDayNum = queryJsonData->getRepeatNum(); + viewWidget = new viewschedulewidget(); + + QVector showdate; + TIME_FRAME_IN_THE_NEXT_SIX_MONTHT + QVector schedule = getSchedule(m_queryTitleName, beginTime, endTime); + + setDateTime(queryJsonData); + + switch (queryJsonData->getRepeatStatus()) { + case QueryJsonData::RepeatStatus::EVED: { + showdate = getEveryDayOrWorkDaySchedule(queryJsonData, 1); + } + break; + case QueryJsonData::RepeatStatus::WORKD: { + showdate = getEveryDayOrWorkDaySchedule(queryJsonData, 2); + } + break; + case QueryJsonData::RepeatStatus::RESTD: { + QVector queryRest; + queryRest.append(6); + queryRest.append(7); + + showdate = getRestDaySchedule(queryJsonData, queryRest); + } + break; + case QueryJsonData::RepeatStatus::EVEW: { + showdate = getEveryWeekSchedule(queryJsonData, getDayNum); + } + break; + case QueryJsonData::RepeatStatus::EVEM: { + showdate = getEveryMonthSchedule(queryJsonData, getDayNum); + } + break; + case QueryJsonData::RepeatStatus::EVEY: { + showdate = getEveryYearSchedule(queryJsonData); + } + break; + default: { + showdate = getNonePropertyStatusSchedule(queryJsonData, schedule); + } + break; + } + + viewWidget->viewScheduleInfoShow(showdate); + + Reply m_reply; + + if (queryJsonData->ShouldEndSession()) { + //不进行多轮 + if (queryOverDueDate(queryJsonData)) { + //过期时间 + REPLY_ONLY_TTS(m_reply, VIEW_DATE_IS_OVERDUE_TTS, VIEW_DATE_IS_OVERDUE_TTS, true); + } else if (queryJsonData->getDateTime().suggestDatetime.size() > 0 + && queryJsonData->getDateTime().suggestDatetime.at(0).datetime > QDateTime::currentDateTime().addMonths(6)) { + //超过半年的时间 + REPLY_ONLY_TTS(m_reply, VIEW_DATETIME_OUT_TTS, VIEW_DATETIME_OUT_TTS, true); + } else { + if (viewWidget->getScheduleNum(showdate) == 0) { + //没有查询的日程 + REPLY_ONLY_TTS(m_reply, NO_SCHEDULE_VIEWED_TTS, NO_SCHEDULE_VIEWED_TTS, true); + } else { + //查询到日程 + QString str = QString(VIEW_SCHEDULE_TTS).arg(viewWidget->getScheduleNum(showdate)); + REPLY_WIDGET_TTS(m_reply, viewWidget, str, str, true); + } + } + } else { + //多轮的情况 + REPLY_ONLY_TTS(m_reply, queryJsonData->SuggestMsg(), queryJsonData->SuggestMsg(), false); + } + + return m_reply; +} + +void queryScheduleTask::setDateTime(QueryJsonData *queryJsonData) +{ + switch (queryJsonData->getDateTime().suggestDatetime.size()) { + case 1: { + m_BeginDateTime = queryJsonData->getDateTime().suggestDatetime.at(0).datetime; + m_EndDateTime = m_BeginDateTime; + //时间处理 + if (!queryJsonData->getDateTime().suggestDatetime.at(0).hasTime) { + if (m_BeginDateTime.date() == QDate::currentDate()) { + m_BeginDateTime.setTime(QTime::currentTime()); + } else { + m_BeginDateTime.setTime(QTime(0, 0, 0)); + } + m_EndDateTime.setTime(QTime(23, 59, 59)); + } + } + break; + case 2: { + m_BeginDateTime = queryJsonData->getDateTime().suggestDatetime.at(0).datetime; + m_EndDateTime = queryJsonData->getDateTime().suggestDatetime.at(1).datetime; + + if (queryJsonData->getDateTime().suggestDatetime.at(1).datetime < QDateTime::currentDateTime()) { + //如果查询结束时间小于当前时间,设置开始结束时间为无效时间 + m_BeginDateTime.setDate(QDate(0,0,0)); + m_BeginDateTime.setTime(QTime(0,0,0)); + m_EndDateTime.setDate(QDate(0,0,0)); + m_EndDateTime.setTime(QTime(0,0,0)); + break; + } else { + //最多查询半年的日程 + if (queryJsonData->getDateTime().suggestDatetime.at(1).datetime.date() > QDate::currentDate().addMonths(6)) { + m_EndDateTime.setDate(QDate::currentDate().addMonths(6)); + } + //如果没有时间,设置为一天最后的时间 + if (!queryJsonData->getDateTime().suggestDatetime.at(1).hasTime) { + m_EndDateTime.setTime(QTime(23, 59, 59)); + } + } + + if (queryJsonData->getDateTime().suggestDatetime.at(0).datetime <= QDateTime::currentDateTime()) { + //开始时间小于当前时间,设置当前时间 + m_BeginDateTime = QDateTime::currentDateTime(); + } else { + if (!queryJsonData->getDateTime().suggestDatetime.at(0).hasTime) { + //没有time + if (queryJsonData->getDateTime().suggestDatetime.at(0).datetime.date() == QDate::currentDate()) + //如果是今天,设置当前时间 + m_BeginDateTime.setTime(QTime::currentTime()); + else + //不是今天,设置一天最初的时间 + m_BeginDateTime.setTime(QTime(0,0,0)); + } + } + } + break; + default: { + //如果没有时间,设置开始结束时间为无效时间 + m_BeginDateTime.setDate(QDate(0,0,0)); + m_BeginDateTime.setTime(QTime(0,0,0)); + m_EndDateTime.setDate(QDate(0,0,0)); + m_EndDateTime.setTime(QTime(0,0,0)); + } + break; + } +} + +QVector queryScheduleTask::getSchedule(QString titleName, QDateTime beginDatetime, QDateTime endDateTime) +{ + QVector schedule; + //使用dbus查询日程 + m_dbus->QueryJobs(titleName, beginDatetime, endDateTime, schedule); + //设置查询的日程 + viewWidget->setScheduleDateRangeInfo(schedule); + //返回过滤后的日程 + return viewWidget->getAllScheduleInfo(); +} + +QVector queryScheduleTask::getEveryDayOrWorkDaySchedule(QueryJsonData *queryJsonData, int repeat) +{ + QTime m_BTime; + QTime m_ETime; + QVector schedule; + schedule = viewWidget->getAllRpeatScheduleInfo(repeat); + if (queryJsonData->getDateTime().suggestDatetime.at(0).hasTime) { + m_BTime = m_BeginDateTime.time(); + m_ETime = m_EndDateTime.time(); + schedule = viewWidget->queryScheduleWithTime(schedule, m_BTime, m_ETime); + } + return schedule; +} + +QVector queryScheduleTask::getRestDaySchedule(QueryJsonData *queryJsonData, QVector queryWeek) +{ + QVector schedule; + QTime m_BTime; + QTime m_ETime; + //查询所有周重复的日程 + schedule = viewWidget->getAllRpeatScheduleInfo(3); + //查询周几-周几的重复日程 + schedule = viewWidget->queryScheduleWithWeek(schedule, queryWeek); + //如果有时间,则再按照时间进行过滤 + if (queryJsonData->getDateTime().suggestDatetime.at(0).hasTime) { + m_BTime = queryJsonData->getDateTime().suggestDatetime.at(0).datetime.time(); + m_ETime = m_BTime; + schedule = viewWidget->queryScheduleWithTime(schedule, m_BTime, m_ETime); + } + return schedule; +} + +QVector queryScheduleTask::getEveryWeekSchedule(QueryJsonData *queryJsonData, QVector repeatNum) +{ + QTime m_BTime; + QTime m_ETime; + QVector schedule; + //查询所有周重复的日程 + schedule = viewWidget->getAllRpeatScheduleInfo(3); + + if (repeatNum.size() == 1) { + QVector queryWeek; + queryWeek.append(repeatNum[0]); + + schedule = viewWidget->queryScheduleWithWeek(schedule, queryWeek); + if (queryJsonData->getDateTime().suggestDatetime.at(0).hasTime) { + m_BTime = queryJsonData->getDateTime().suggestDatetime.at(0).datetime.time(); + m_ETime = m_BTime; + schedule = viewWidget->queryScheduleWithTime(schedule, m_BTime, m_ETime); + } + } else if (repeatNum.size() == 2) { + int start = repeatNum[0]; + int end = repeatNum[1]; + QVector queryWeek; + + if (start == end) { + return viewWidget->getAllRpeatScheduleInfo(1); + } else if (start < end) { + if (start == 1 && end == 5) { + return viewWidget->getAllRpeatScheduleInfo(2); + } else if (end - start == 6) { + return viewWidget->getAllRpeatScheduleInfo(1); + } else { + for (int i = start; i <= end; i++) { + queryWeek.append(i); + } + } + } else { + if (start - end == 1) { + return viewWidget->getAllRpeatScheduleInfo(1); + } else { + for (int i = 0; i <= 7 - start; i++) { + queryWeek.append(i + start); + } + for (int i = 0; i < end; i++) { + queryWeek.append(i + 1); + } + } + } + //查询周几-周几的重复日程 + schedule = viewWidget->queryScheduleWithWeek(schedule, queryWeek); + if (queryJsonData->getDateTime().suggestDatetime.size() == 1) { + if (queryJsonData->getDateTime().suggestDatetime.at(0).hasTime) { + m_BTime = QTime(0, 0, 0); + m_ETime = queryJsonData->getDateTime().suggestDatetime.at(0).datetime.time(); + schedule = viewWidget->queryScheduleWithWeek(schedule, queryWeek, end, m_BTime, m_ETime); + } + } + } + return schedule; +} + +QVector queryScheduleTask::getEveryMonthSchedule(QueryJsonData *queryJsonData, QVector repeatNum) +{ + QTime m_BTime; + QTime m_ETime; + QVector schedule; + //查询所有月重复的日程 + schedule = viewWidget->getAllRpeatScheduleInfo(4); + + if (repeatNum.size() == 1) { + QVector queryMonth; + queryMonth.append(repeatNum[0]); + + schedule = viewWidget->queryScheduleWithMonth(schedule, queryMonth); + if (queryJsonData->getDateTime().suggestDatetime.size() == 1) { + if (queryJsonData->getDateTime().suggestDatetime.at(0).hasTime) { + m_BTime = queryJsonData->getDateTime().suggestDatetime.at(0).datetime.time(); + m_ETime = m_BTime; + schedule = viewWidget->queryScheduleWithTime(schedule, m_BTime, m_ETime); + } + } else if (queryJsonData->getDateTime().suggestDatetime.size() == 2) { + m_BTime = queryJsonData->getDateTime().suggestDatetime.at(0).datetime.time(); + m_ETime = queryJsonData->getDateTime().suggestDatetime.at(1).datetime.time(); + schedule = viewWidget->queryScheduleWithTime(schedule, m_BTime, m_ETime); + } + } else if (repeatNum.size() == 2) { + int start = repeatNum[0]; + int end = repeatNum[1]; + QVector queryMonth; + + if (start == end) { + return viewWidget->getAllRpeatScheduleInfo(1); + } else if (start < end) { + for (int i = start; i <= end; i++) { + queryMonth.append(i); + } + } + + schedule = viewWidget->queryScheduleWithMonth(schedule, queryMonth); + } else { + if (queryJsonData->getDateTime().suggestDatetime.at(0).hasTime) { + m_BTime = queryJsonData->getDateTime().suggestDatetime.at(0).datetime.time(); + m_ETime = m_BTime; + schedule = viewWidget->queryScheduleWithTime(schedule, m_BTime, m_ETime); + } + } + return schedule; +} + +QVector queryScheduleTask::getEveryYearSchedule(QueryJsonData *queryJsonData) +{ + Q_UNUSED(queryJsonData) + QVector schedule; + + if (queryJsonData->getDateTime().suggestDatetime.size() == 1) { + //查询所有年重复的日程 + schedule = viewWidget->getAllRpeatScheduleInfo(5); + //设置查询的开始结束日期 + QDate m_beginD = queryJsonData->getDateTime().suggestDatetime.at(0).datetime.date(); + QDate m_endD = m_beginD; + //按照日期查询日程 + schedule = viewWidget->queryScheduleWithDate(schedule, m_beginD, m_endD); + //如果有时间,则按照时间查询 + if (queryJsonData->getDateTime().suggestDatetime.at(0).hasTime) { + QTime m_beginT = queryJsonData->getDateTime().suggestDatetime.at(0).datetime.time(); + QTime m_endT = m_beginT; + schedule = viewWidget->queryScheduleWithTime(schedule, m_beginT, m_endT); + } + } + + return schedule; +} + +QVector queryScheduleTask::getNonePropertyStatusSchedule(QueryJsonData *queryJsonData, QVector schedule) +{ + QVector scheduleInfo; + scheduleInfo.clear(); + + switch (queryJsonData->getPropertyStatus()) { + case QueryJsonData::PropertyStatus::ALL: { + //查询所有的日程,因此不需要对已查询到的日程进行过滤操作 + return schedule; + } + case QueryJsonData::PropertyStatus::NEXT: { + if (schedule.isEmpty()) { + //如果半年内没有日程,返回空容器 + return scheduleInfo; + } else { + schedule.clear(); + scheduleInfo = viewWidget->getNextScheduleInfo(); + } + //返回下一个日程信息 + return scheduleInfo; + } + case QueryJsonData::PropertyStatus::LAST: + break; + default: { + if (m_BeginDateTime.isValid()) { + qDebug() << m_BeginDateTime << m_EndDateTime; + //返回过滤的日程 + return getSchedule(queryJsonData->TitleName(), m_BeginDateTime, m_EndDateTime); + } + } + } + //如果以上情况都没有返回半年所有日程 + return schedule; +} + +bool queryScheduleTask::queryOverDueDate(QueryJsonData *queryJsonData) +{ + bool overduedate = false; + int datenum; + if (queryJsonData->getDateTime().suggestDatetime.size() > 0) { + if (queryJsonData->getDateTime().suggestDatetime.size() == 1) + datenum = 0; + else + datenum = 1; + + if (queryJsonData->getDateTime().suggestDatetime.at(datenum).datetime.date() < QDate::currentDate()) { + overduedate = true; + } else if (queryJsonData->getDateTime().suggestDatetime.at(datenum).datetime.date() == QDate::currentDate() + && queryJsonData->getDateTime().suggestDatetime.at(datenum).hasTime + && queryJsonData->getDateTime().suggestDatetime.at(datenum).datetime.time() < QTime::currentTime()) { + overduedate = true; + } else { + overduedate = false; + } + } else { + overduedate = false; + } + return overduedate; +} + +#ifdef LOG_PRINT +void queryScheduleTask::logPrint(const JsonData *jsonData) +{ + Q_UNUSED(jsonData) +} +#endif diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/task/queryscheduletask.h dde-calendar-5.7.0.23/schedule-plugin/src/task/queryscheduletask.h --- dde-calendar-5.7.0.4/schedule-plugin/src/task/queryscheduletask.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/task/queryscheduletask.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,109 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef QUERYSCHEDULETASK_H +#define QUERYSCHEDULETASK_H + +#include "schedulebasetask.h" +#include "../data/queryjsondata.h" +#include "../widget/viewschedulewidget.h" + +class queryScheduleTask : public scheduleBaseTask +{ + Q_OBJECT +public: + queryScheduleTask(CSchedulesDBus *dbus); + Reply SchedulePress(semanticAnalysisTask &semanticTask) override; + +private: + /** + * @brief setDateTime 设置查询的开始结束时间 + * @param queryJsonData jsondata句柄 + */ + void setDateTime(QueryJsonData *queryJsonData); + /** + * @brief getHalfAYearSchedule 获取半年的日程信息 + * @param titleName 日程titlename + * @param beginDatetime 查询开始时间 + * @param endDateTime 查询结束时间 + * @return 日程信息 + */ + QVector getSchedule(QString titleName, QDateTime beginDatetime, QDateTime endDateTime); + /** + * @brief getEveryDayOrWorkDaySchedule 获取每天或者工作日的日程信息 + * @param queryJsonData jsondatajubing + * @param repeat 重复类型 + * @return 日程信息 + */ + QVector getEveryDayOrWorkDaySchedule(QueryJsonData *queryJsonData, int repeat); + /** + * @brief getRestDaySchedule 获取休息日的日程信息 + * @param queryJsonData jsondata句柄 + * @param queryWeek 需要查询周几的容器 + * @return 日程信息 + */ + QVector getRestDaySchedule(QueryJsonData *queryJsonData, QVector queryWeek); + /** + * @brief getEveryWeekSchedule 获取每周的日程信息 + * @param queryJsonData jsondata句柄 + * @param repeatNum 需要查询每周几-周几的容器 + * @return 日程信息 + */ + QVector getEveryWeekSchedule(QueryJsonData *queryJsonData, QVector repeatNum); + /** + * @brief getEveryMonthSchedule 获取每月的日程信息 + * @param queryJsonData jsondata句柄 + * @param repeatNum 需要查询每月几号-几号的容器 + * @return 日程信息 + */ + QVector getEveryMonthSchedule(QueryJsonData *queryJsonData, QVector repeatNum); + /** + * @brief getEveryYearSchedule 获取每年的日程信息 + * @param queryJsonData jsondata句柄 + * @return 日程信息 + */ + QVector getEveryYearSchedule(QueryJsonData *queryJsonData); + /** + * @brief getNonePropertyStatusSchedule 查询不是重复类型的日程 + * @param queryJsonData jsondata句柄 + * @param schedule 获取到的半年的日程信息 + * @return 日程信息 + */ + QVector getNonePropertyStatusSchedule(QueryJsonData *queryJsonData, QVector schedule); + /** + * @brief queryOverDueDate 是否查询的是过去的日程 + * @param queryJsonData jsondata句柄 + * @return bool + */ + bool queryOverDueDate(QueryJsonData *queryJsonData); + +private: + QDateTime m_BeginDateTime; + QDateTime m_EndDateTime; + viewschedulewidget *viewWidget = nullptr; + + +protected: +#ifdef LOG_PRINT + void logPrint(const JsonData *jsonData) override; +#endif +}; + +#endif // QUERYSCHEDULETASK_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/task/schedulebasetask.cpp dde-calendar-5.7.0.23/schedule-plugin/src/task/schedulebasetask.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/task/schedulebasetask.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/task/schedulebasetask.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,131 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "schedulebasetask.h" +#include "../state/schedulestate.h" +#include "../globaldef.h" + +scheduleBaseTask::scheduleBaseTask(CSchedulesDBus *dbus, scheduleState *state) + : QObject() + , m_dbus(dbus) + , m_State(state) +{ +} + +scheduleBaseTask::~scheduleBaseTask() +{ + if (m_State == nullptr) { + delete m_State; + m_State = nullptr; + } +} + +Reply scheduleBaseTask::SchedulePress(semanticAnalysisTask &semanticTask) +{ +#ifdef LOG_PRINT + logPrint(semanticTask.getJsonData()); +#endif + Reply reply; + if (m_State != nullptr) { + if (semanticTask.Intent() == JSON_NO_INTENT) { + reply = m_State->getReplyByIntent(false); + } else if (semanticTask.Intent() == JSON_YES_INTENT) { + reply = m_State->getReplyByIntent(true); + } else { + reply = m_State->process(semanticTask.getJsonData()); + } + updateState(); + } + return reply; +} + +Reply scheduleBaseTask::getFeedbackByQuerySchedule(const QVector &info) +{ + Q_UNUSED(info); + return Reply(); +} + +Reply scheduleBaseTask::getReplyBySelectSchedule(const ScheduleDtailInfo &info) +{ + Q_UNUSED(info); + return Reply(); +} + +Reply scheduleBaseTask::InitState(const JsonData *jsonData, bool isUpdateState) +{ + Q_UNUSED(jsonData); + Q_UNUSED(isUpdateState); + return Reply(); +} + +Reply scheduleBaseTask::repeatScheduleHandle(const ScheduleDtailInfo &info, bool isOnlyOne) +{ + Q_UNUSED(info); + Q_UNUSED(isOnlyOne); + return Reply(); +} + +Reply scheduleBaseTask::confirwScheduleHandle(const ScheduleDtailInfo &info) +{ + Q_UNUSED(info); + return Reply(); +} + +Reply scheduleBaseTask::confirmInfo(bool isOK) +{ + Q_UNUSED(isOK); + return Reply(); +} + +scheduleState *scheduleBaseTask::getState() const +{ + return m_State; +} + +Reply scheduleBaseTask::overdueScheduleProcess() +{ + Reply reply; + REPLY_ONLY_TTS(reply, OVERTIME_TTS, OVERTIME_TTS, true); + return reply; +} + +void scheduleBaseTask::updateState() +{ + do { + scheduleState *nextState = m_State->getNextState(); + if (nextState != nullptr) { + delete m_State; + m_State = nextState; + } else { + break; + } + } while (1); +} +/** + * @brief scheduleBaseTask::errorMessage 用户输入无法匹配返回错误消息提示 + * @return 关于无法处理该关键字的答复 + */ +Reply scheduleBaseTask::errorMessage() +{ + //答复 + Reply reply; + REPLY_ONLY_TTS(reply, G_ERR_TTS, G_ERR_TTS, true) + return reply; +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/task/schedulebasetask.h dde-calendar-5.7.0.23/schedule-plugin/src/task/schedulebasetask.h --- dde-calendar-5.7.0.4/schedule-plugin/src/task/schedulebasetask.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/task/schedulebasetask.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,65 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef SCHEDULEBASETASK_H +#define SCHEDULEBASETASK_H + +#include "semanticanalysistask.h" +#include "../interface/reply.h" +#include "../dbus/schedulesdbus.h" +#include "../data/schedulestructs.h" +#include + +class scheduleState; +class scheduleBaseTask : public QObject +{ + Q_OBJECT +public: + scheduleBaseTask(CSchedulesDBus *dbus, scheduleState *state = nullptr); + virtual ~scheduleBaseTask(); + virtual Reply SchedulePress(semanticAnalysisTask &semanticTask); + virtual Reply getFeedbackByQuerySchedule(const QVector &info); + virtual Reply getReplyBySelectSchedule(const ScheduleDtailInfo &info); + virtual Reply InitState(const JsonData *jsonData, bool isUpdateState = false); + virtual Reply repeatScheduleHandle(const ScheduleDtailInfo &info, bool isOnlyOne); + virtual Reply confirwScheduleHandle(const ScheduleDtailInfo &info); + virtual Reply confirmInfo(bool isOK); + scheduleState *getState() const; + Reply overdueScheduleProcess(); +signals: + void signaleSendMessage(Reply reply); + +protected: +#ifdef LOG_PRINT + virtual void logPrint(const JsonData *jsonData) = 0; +#endif + void updateState(); + /** + * @brief errorMessage 用户输入无法匹配返回错误消息提示 + * @return 关于无法处理该关键字的答复 + */ + Reply errorMessage(); + +protected: + CSchedulesDBus *m_dbus {nullptr}; + scheduleState *m_State {nullptr}; +}; + +#endif // SCHEDULEBASETASK_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/task/schedulemanagetask.cpp dde-calendar-5.7.0.23/schedule-plugin/src/task/schedulemanagetask.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/task/schedulemanagetask.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/task/schedulemanagetask.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,135 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "schedulemanagetask.h" + +#include "../dbus/schedulesdbus.h" +#include "../globaldef.h" +#include "../widget/schedulelistwidget.h" +#include "../data/createjsondata.h" +#include "../data/queryjsondata.h" +#include "../data/canceljsondata.h" +#include "../data/changejsondata.h" +#include "../widget/viewschedulewidget.h" +#include "createscheduletask.h" +#include "queryscheduletask.h" +#include "cancelscheduletask.h" +#include "changescheduletask.h" + +DWIDGET_USE_NAMESPACE + +ScheduleManageTask *ScheduleManageTask::m_scheduleManageTask = nullptr; + +ScheduleManageTask::ScheduleManageTask(QObject *parent) + : QObject(parent) + , m_dbus(new CSchedulesDBus(DBUS_SERVICE, DBUS_PATCH, QDBusConnection::sessionBus(), this)) +{ + m_scheduleTaskMap[JSON_CREATE] = new createScheduleTask(m_dbus); + m_scheduleTaskMap[JSON_VIEW] = new queryScheduleTask(m_dbus); + m_scheduleTaskMap[JSON_CANCEL] = new cancelScheduleTask(m_dbus); + m_scheduleTaskMap[JSON_CHANGE] = new changeScheduleTask(m_dbus); + + QMap::Iterator inter = m_scheduleTaskMap.begin(); + for (; inter != m_scheduleTaskMap.end(); ++inter) { + scheduleBaseTask *task = inter.value(); + connect(task, &scheduleBaseTask::signaleSendMessage, this, &ScheduleManageTask::signaleSendMessage); + } +} + +ScheduleManageTask::~ScheduleManageTask() +{ + QMap::Iterator inter = m_scheduleTaskMap.begin(); + for (; inter != m_scheduleTaskMap.end(); ++inter) { + scheduleBaseTask *task = inter.value(); + delete task; + } + m_scheduleTaskMap.clear(); +} + +ScheduleManageTask *ScheduleManageTask::getInstance() +{ + if (m_scheduleManageTask == nullptr) { + m_scheduleManageTask = new ScheduleManageTask(); + } + return m_scheduleManageTask; +} + +void ScheduleManageTask::releaseInstance() +{ + if (m_scheduleManageTask != nullptr) { + delete m_scheduleManageTask; + m_scheduleManageTask = nullptr; + } +} + +void ScheduleManageTask::process(semanticAnalysisTask &semanticTask) +{ + if (m_scheduleTaskMap.contains(semanticTask.Intent())) { + if (m_preScheduleTask != m_scheduleTaskMap[semanticTask.Intent()]) { + if (m_preScheduleTask != nullptr) + m_preScheduleTask->InitState(nullptr, true); + m_preScheduleTask = m_scheduleTaskMap[semanticTask.Intent()]; + } + } + Reply reply; + if (m_preScheduleTask == nullptr){ + REPLY_ONLY_TTS(reply, G_ERR_TTS, G_ERR_TTS, true); + } else { + reply =m_preScheduleTask->SchedulePress(semanticTask); + connectHideEventToInitState(reply); + } + setReply(reply); +} + +void ScheduleManageTask::slotReceivce(QVariant data, Reply *reply) +{ + Q_UNUSED(data); + Q_UNUSED(reply); +} + +void ScheduleManageTask::slotWidgetHideInitState() +{ + if (m_preScheduleTask != nullptr) + m_preScheduleTask->InitState(nullptr, true); +} + +void ScheduleManageTask::connectHideEventToInitState(Reply reply) +{ + //判断回复内容是否有回复窗口 + if(reply.getReplyWidget() !=nullptr){ + //转换为IconDFrame窗口 + IconDFrame *_iconWidget = qobject_cast(reply.getReplyWidget()); + if(_iconWidget != nullptr){ + //如果转换成功则关联 + connect(_iconWidget, &IconDFrame::widgetIsHide, + this, &ScheduleManageTask::slotWidgetHideInitState, Qt::UniqueConnection); + } + } +} + +Reply ScheduleManageTask::getReply() const +{ + return m_Reply; +} + +void ScheduleManageTask::setReply(const Reply &reply) +{ + m_Reply = reply; +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/task/schedulemanagetask.h dde-calendar-5.7.0.23/schedule-plugin/src/task/schedulemanagetask.h --- dde-calendar-5.7.0.4/schedule-plugin/src/task/schedulemanagetask.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/task/schedulemanagetask.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,74 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef SCHEDULEMANAGETASK_H +#define SCHEDULEMANAGETASK_H + +#include + +#include "../interface/reply.h" +#include "semanticanalysistask.h" +#include "../dbus/schedulesdbus.h" +#include "../widget/icondframe.h" +#include "../data/schedulestructs.h" +#include "../widget/createschedulewidget.h" +#include "../interface/reply.h" +#include "schedulebasetask.h" + +//class widgetStrategy; +class CSchedulesDBus; +class ScheduleManageTask : public QObject +{ + Q_OBJECT +public: + static ScheduleManageTask *getInstance(); + static void releaseInstance(); + + void process(semanticAnalysisTask &semanticTask); + + Reply getReply() const; + void setReply(const Reply &reply); + +private: + explicit ScheduleManageTask(QObject *parent = nullptr); + ~ScheduleManageTask(); +signals: + void signaleSendMessage(Reply reply); +public slots: + void slotReceivce(QVariant data, Reply *reply); + /** + * @brief slotWidgetHideInitState 窗口隐藏时状态初始化 + */ + void slotWidgetHideInitState(); +private: + static ScheduleManageTask *m_scheduleManageTask; + /** + * @brief connectHideEventToInitState 窗口隐藏绑定状态初始化 + * @param reply 回复 + */ + void connectHideEventToInitState(Reply reply); +private: + CSchedulesDBus *m_dbus {nullptr}; + QMap m_scheduleTaskMap; + Reply m_Reply; + scheduleBaseTask *m_preScheduleTask {nullptr}; +}; + +#endif // SCHEDULEMANAGETASK_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/task/semanticanalysistask.cpp dde-calendar-5.7.0.23/schedule-plugin/src/task/semanticanalysistask.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/task/semanticanalysistask.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/task/semanticanalysistask.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,157 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "semanticanalysistask.h" + +#include +#include +#include + +#include "../data/createjsondata.h" +#include "../data/queryjsondata.h" +#include "../data/canceljsondata.h" +#include "../data/changejsondata.h" +#include "../globaldef.h" + +semanticAnalysisTask::semanticAnalysisTask(QObject *parent) + : QObject(parent) +{ +} + +semanticAnalysisTask::~semanticAnalysisTask() +{ + deleteJsonData(); +} + +bool semanticAnalysisTask::resolveTaskJson(const QString &semantic) +{ + setIntent(""); + deleteJsonData(); + + QJsonParseError jsonError; + QJsonDocument doc = QJsonDocument::fromJson(semantic.toUtf8(), &jsonError); + + if (!doc.isNull() && (jsonError.error == QJsonParseError::NoError)) { + auto rootObject = doc.object(); + if (!(rootObject.contains("intent") + && rootObject["intent"].isObject())) { + return false; + } + + auto intentObject = rootObject["intent"].toObject(); + if (intentObject.empty()) { + return false; + } + if (intentObject.contains("semantic") && intentObject["semantic"].isArray()) { + auto semanticObjArr = intentObject["semantic"].toArray(); + for (int i = 0; i < semanticObjArr.size(); ++i) { + auto semanticObj = semanticObjArr[i].toObject(); + if (semanticObj.contains("intent") && semanticObj["intent"].isString()) { + setIntent(semanticObj["intent"].toString()); + } + m_JsonData = createJsonDataFactory(Intent()); + if (m_JsonData != nullptr) { + m_JsonData->JosnResolve(semanticObj); + } + } + } + if (intentObject.contains("voice_answer") && intentObject["voice_answer"].isArray()) { + auto voiceAnsObjArr = intentObject["voice_answer"].toArray(); + for (int i = 0; i < voiceAnsObjArr.size(); ++i) { + auto voiceAnsObj = voiceAnsObjArr[i].toObject(); + if (voiceAnsObj.contains("type") && voiceAnsObj["type"].isString()) { + if (voiceAnsObj["type"] != "TTS") { + continue; + } + if (voiceAnsObj.contains("content") && voiceAnsObj["content"].isString()) { + //语音播报的文本 + if (m_JsonData != nullptr) { + m_JsonData->setSuggestMsg(voiceAnsObj["content"].toString()); + } + break; + } + } + } + } + if (intentObject.contains("shouldEndSession") && intentObject["shouldEndSession"].isBool()) { + setShouldEndSession(intentObject["shouldEndSession"].toBool()); + } else { + setShouldEndSession(true); + } + } else { + return false; + } + return true; +} + +QString semanticAnalysisTask::Intent() const +{ + return m_Intent; +} + +void semanticAnalysisTask::setIntent(const QString &Intent) +{ + m_Intent = Intent; +} + +JsonData *semanticAnalysisTask::getJsonData() const +{ + return m_JsonData; +} + +void semanticAnalysisTask::deleteJsonData() +{ + if (m_JsonData != nullptr) { + delete m_JsonData; + m_JsonData = nullptr; + } +} + +JsonData *semanticAnalysisTask::createJsonDataFactory(const QString &Intent) +{ + if (Intent == JSON_CREATE) { + //创建 + return new CreateJsonData(); + } else if (Intent == JSON_VIEW) { + //查询 + return new QueryJsonData(); + + } else if (Intent == JSON_CANCEL) { + //取消 + return new cancelJsonData(); + + } else if (Intent == JSON_CHANGE) { + //改变 + return new changejsondata(); + } + return nullptr; +} + +void semanticAnalysisTask::setShouldEndSession(bool isEnd) +{ + if (m_JsonData != nullptr) { + m_JsonData->setShouldEndSession(isEnd); + } +} + +void semanticAnalysisTask::setJsonData(JsonData *JsonData) +{ + m_JsonData = JsonData; +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/task/semanticanalysistask.h dde-calendar-5.7.0.23/schedule-plugin/src/task/semanticanalysistask.h --- dde-calendar-5.7.0.4/schedule-plugin/src/task/semanticanalysistask.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/task/semanticanalysistask.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,55 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef SEMANTICANALYSISTASK_H +#define SEMANTICANALYSISTASK_H + +#include +#include +#include "../data/jsondata.h" + +class QJsonObject; + +class semanticAnalysisTask : public QObject +{ + Q_OBJECT +public: + explicit semanticAnalysisTask(QObject *parent = nullptr); + ~semanticAnalysisTask(); + bool resolveTaskJson(const QString &semantic); + QString Intent() const; + void setIntent(const QString &Intent); + JsonData *getJsonData() const; + void setJsonData(JsonData *JsonData); + +private: + void deleteJsonData(); + JsonData *createJsonDataFactory(const QString &Intent); + void setShouldEndSession(bool isEnd); + +signals: + +public slots: +private: + QString m_Intent; + JsonData *m_JsonData {nullptr}; +}; + +#endif // SEMANTICANALYSISTASK_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/widget/buttonwidget.cpp dde-calendar-5.7.0.23/schedule-plugin/src/widget/buttonwidget.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/widget/buttonwidget.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/widget/buttonwidget.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,94 @@ +#include "buttonwidget.h" +#include +#include +#include +#include + +buttonwidget::buttonwidget(QWidget *parent) + : DWidget(parent) + , buttonLayout(new QHBoxLayout()) +{ + buttonLayout->setMargin(0); + buttonLayout->setContentsMargins(BTWidget::BUTTON_LAYOUT_LEFT_MARGIN, + BTWidget::BUTTON_LAYOUT_TOP_MARGIN, + BTWidget::BUTTON_LAYOUT_RIGHT_MARGIN, + BTWidget::BUTTON_LAYOUT_BOTTOM_MARGIN); + setLayout(buttonLayout); +} + +int buttonwidget::addbutton(const QString &text, bool isDefault, buttonwidget::ButtonType type) +{ + int index = buttonCount(); + insertButton(index, text, isDefault, type); + return index; +} + +void buttonwidget::insertButton(int index, const QString &text, bool isDefault, buttonwidget::ButtonType type) +{ + QAbstractButton *button; + switch (type) { + case ButtonWarning: + button = new DWarningButton(this); + break; + case ButtonRecommend: + button = new DSuggestButton(this); + break; + default: + button = new DPushButton(this); + break; + } + button->setText(text); + button->setObjectName("ActionButton"); + insertButton(index, button, isDefault); +} + +void buttonwidget::insertButton(int index, QAbstractButton *button, bool isDefault) +{ + DVerticalLine *line = new DVerticalLine(this); + line->setObjectName("VLine"); + line->setFixedHeight(30); + + buttonLayout->insertWidget(index * 2, line); + buttonLayout->insertWidget(index * 2 + 1, button); + buttonList << button; + + line->show(); + buttonLayout->itemAt(0)->widget()->hide(); + + connect(button, &QAbstractButton::clicked, this, &buttonwidget::onButtonClicked); + + if (isDefault) { + QPushButton *pushbutton = qobject_cast(button); + pushbutton->setDefault(pushbutton); + } + + const QString &text = button->text(); + + if (text.count() == 2) { + for (const QChar &ch : text) { + switch (ch.script()) { + case QChar::Script_Han: + case QChar::Script_Katakana: + case QChar::Script_Hiragana: + case QChar::Script_Hangul: + break; + default: + return; + } + } + button->setText(QString().append(text.at(0)).append(QChar::Nbsp).append(text.at(1))); + } +} + +int buttonwidget::buttonCount() const +{ + return buttonList.count(); +} + +void buttonwidget::onButtonClicked(bool clicked) +{ + Q_UNUSED(clicked); + QAbstractButton *button = qobject_cast(this->sender()); + clickedButtonIndex = buttonList.indexOf(button); + emit buttonClicked(clickedButtonIndex, button->text()); +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/widget/buttonwidget.h dde-calendar-5.7.0.23/schedule-plugin/src/widget/buttonwidget.h --- dde-calendar-5.7.0.4/schedule-plugin/src/widget/buttonwidget.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/widget/buttonwidget.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,48 @@ +#ifndef BUTTONWIDGET_H +#define BUTTONWIDGET_H +#include +#include +#include +#include + +DWIDGET_USE_NAMESPACE + +namespace BTWidget { +const int BUTTON_LAYOUT_TOP_MARGIN = 0; +const int BUTTON_LAYOUT_BOTTOM_MARGIN = 0; +const int BUTTON_LAYOUT_LEFT_MARGIN = 0; +const int BUTTON_LAYOUT_RIGHT_MARGIN = 0; +} // namespace BTWidget + +class buttonwidget : public DWidget +{ + Q_OBJECT +public: + explicit buttonwidget(QWidget *parent = nullptr); + + enum ButtonType { + ButtonNormal, + ButtonWarning, + ButtonRecommend + }; + + int addbutton(const QString &text, bool isDefault = false, ButtonType type = ButtonNormal); + void insertButton(int index, const QString &text, bool isDefault = false, ButtonType type = ButtonNormal); + void insertButton(int index, QAbstractButton *button, bool isDefault = false); + + int buttonCount() const; + +signals: + void buttonClicked(int index, const QString &text); +public slots: + void onButtonClicked(bool clicked); + +private: + QList buttonList; + QSpacerItem *spacer = nullptr; + + QHBoxLayout *buttonLayout; + int clickedButtonIndex; +}; + +#endif // BUTTONWIDGET_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/widget/createschedulewidget.cpp dde-calendar-5.7.0.23/schedule-plugin/src/widget/createschedulewidget.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/widget/createschedulewidget.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/widget/createschedulewidget.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,177 @@ +#include "createschedulewidget.h" +#include +#include +#include +#include + +#include "buttonwidget.h" +#include "../globaldef.h" + +createSchedulewidget::createSchedulewidget(QWidget *parent) + : IconDFrame(parent) + , m_scheduleDtailInfo(ScheduleDtailInfo()) + , m_scheduleitemwidget(new scheduleitemwidget(this)) +{ + connect(m_scheduleitemwidget, &scheduleitemwidget::signalItemPress, this, &createSchedulewidget::slotItemPress); + // updateUI(); +} + +ScheduleDtailInfo &createSchedulewidget::getScheduleDtailInfo() +{ + return m_scheduleDtailInfo; +} + +void createSchedulewidget::setTitleName(QString titleName) +{ + m_titleName = titleName; +} + +void createSchedulewidget::setDateTime(QDateTime begintime, QDateTime endtime) +{ + m_BeginDateTime = begintime; + m_EndDateTime = endtime; +} + +void createSchedulewidget::setRpeat(int rpeat) +{ + m_rpeat = rpeat; +} + +void createSchedulewidget::setschedule() +{ + QDateTime m_beginTime; + QDateTime m_endTime; + m_beginTime = m_BeginDateTime; + m_endTime = m_EndDateTime; + + m_scheduleDtailInfo.beginDateTime = m_beginTime; + m_scheduleDtailInfo.endDateTime = m_endTime; + m_scheduleDtailInfo.titleName = m_titleName; + m_scheduleDtailInfo.type.ID = 3; + m_scheduleDtailInfo.id = 0; + m_scheduleDtailInfo.RecurID = 0; + m_scheduleDtailInfo.allday = false; + m_scheduleDtailInfo.remind = true; + m_scheduleDtailInfo.remindData.n = 0; + m_scheduleDtailInfo.rpeat = m_rpeat; + // if (m_rpeat != 0) { + //结束重复于类型为:永不 + m_scheduleDtailInfo.enddata.type = 0; + // } +} + +void createSchedulewidget::scheduleEmpty(bool isEmpty) +{ + m_scheduleEmpty = isEmpty; +} + +void createSchedulewidget::updateUI() +{ + if (m_scheduleEmpty) { + //获取筛选到的日程信息 + getCreatScheduleFromDbus(); + //如果筛选到的日程不为空,则展示日程插件 + if (!m_scheduleInfo.isEmpty()) { + QVBoxLayout *mainlayout = new QVBoxLayout(); + m_scheduleitemwidget->setScheduleDtailInfo(m_scheduleInfo); + m_scheduleitemwidget->addscheduleitem(); + mainlayout->addWidget(m_scheduleitemwidget); + setCenterLayout(mainlayout); + } + } else { + //是否创建日程 + QVBoxLayout *mainlayout = new QVBoxLayout(); + buttonwidget *button = new buttonwidget(this); + button->addbutton(CANCEL_BUTTON_STRING, false, buttonwidget::ButtonRecommend); + button->addbutton(CONFIRM_BUTTON_STRING); + connect(button, &buttonwidget::buttonClicked, this, &createSchedulewidget::slotsbuttonchance); + m_scheduleitemwidget->setScheduleDtailInfo(m_scheduleInfo); + m_scheduleitemwidget->addscheduleitem(); + mainlayout->addWidget(m_scheduleitemwidget); + mainlayout->addSpacing(4); + mainlayout->addWidget(button); + setCenterLayout(mainlayout); + } +} + +void createSchedulewidget::setScheduleDbus(CSchedulesDBus *dbus) +{ + m_dbus = dbus; +} + +bool createSchedulewidget::buttonclicked() +{ + return m_buttonclicked; +} + +void createSchedulewidget::slotsbuttonchance(int index, const QString &text) +{ + Q_UNUSED(text) + if (index == 0) { + m_buttonclicked = false; + } + if (index == 1) { + m_buttonclicked = true; + } +} + +void createSchedulewidget::slotItemPress(const ScheduleDtailInfo &info) +{ + QProcess proc; + proc.startDetached(PROCESS_OPEN_CALENDAR); + QThread::msleep(750); + QString schedulestr = CSchedulesDBus::createScheduleDtailInfojson(info); + QDBusMessage message = QDBusMessage::createMethodCall(DBUS_CALENDAR_SERVICE, + DBUS_CALENDAR_PATCH, + DBUS_CALENDAR_INTFACE, + "OpenSchedule"); + message << schedulestr; + //发送消息 + QDBusMessage response = QDBusConnection::sessionBus().call(message); +} + +void createSchedulewidget::getCreatScheduleFromDbus() +{ + //存放查询的日程信息 + QVector out; + //存放符合筛选条件的日程信息 + QVector scheduleinfo; + //清空容器 + scheduleinfo.clear(); + out.clear(); + //通过dbus获取和新建的日程具有相同titlename,beginDateTime,endDateTime的日程 + m_dbus->QueryJobs(m_scheduleDtailInfo.titleName, m_scheduleDtailInfo.beginDateTime, m_scheduleDtailInfo.endDateTime, out); + //筛选具体日程 + for (int i = 0; i < out.count(); i++) { + for (int j = 0; j < out.at(i).vData.count(); j++) { + //筛选条件 + if (out.at(i).vData.at(j).titleName == m_scheduleDtailInfo.titleName + && out.at(i).vData.at(j).beginDateTime == m_scheduleDtailInfo.beginDateTime + && out.at(i).vData.at(j).endDateTime == m_scheduleDtailInfo.endDateTime + && out.at(i).vData.at(j).rpeat == m_scheduleDtailInfo.rpeat + && out.at(i).vData.at(j).allday == m_scheduleDtailInfo.allday + && out.at(i).vData.at(j).type.ID == m_scheduleDtailInfo.type.ID + && out.at(i).vData.at(j).RecurID == m_scheduleDtailInfo.RecurID + && out.at(i).vData.at(j).remind == m_scheduleDtailInfo.remind + && out.at(i).vData.at(j).remindData.n == m_scheduleDtailInfo.remindData.n) { + if (m_scheduleDtailInfo.rpeat > 0 && out.at(i).vData.at(j).enddata.type != m_scheduleDtailInfo.enddata.type) + continue; + scheduleinfo.append(out.at(i).vData.at(j)); + } + } + } + //如果和新建日程具有相同信息的日程有多个,则取id最大的那一个 + if (scheduleinfo.count() > 1) { + for (int i = 0; i < scheduleinfo.count() - 1; i++) { + if (scheduleinfo.at(i).id < scheduleinfo.at(i + 1).id) { + m_scheduleInfo.clear(); + m_scheduleInfo.append(scheduleinfo.at(i + 1)); + } else { + m_scheduleInfo.clear(); + m_scheduleInfo.append(scheduleinfo.at(i)); + } + } + } else { + m_scheduleInfo = scheduleinfo; + } +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/widget/createschedulewidget.h dde-calendar-5.7.0.23/schedule-plugin/src/widget/createschedulewidget.h --- dde-calendar-5.7.0.4/schedule-plugin/src/widget/createschedulewidget.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/widget/createschedulewidget.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,55 @@ +#ifndef CREATESCHEDULE_H +#define CREATESCHEDULE_H + +#include +#include +#include +#include "../data/schedulestructs.h" +#include "icondframe.h" +#include "scheduleitemwidget.h" +#include "../dbus/schedulesdbus.h" + +DWIDGET_USE_NAMESPACE + +class createSchedulewidget : public IconDFrame +{ + Q_OBJECT +public: + explicit createSchedulewidget(QWidget *parent = nullptr); + +public: + ScheduleDtailInfo &getScheduleDtailInfo(); + void setTitleName(QString titleName); + void setDateTime(QDateTime begintime, QDateTime endtime); + void setRpeat(int rpeat); + void setschedule(); + void scheduleEmpty(bool isEmpty); + void updateUI(); + void setScheduleDbus(CSchedulesDBus *dbus); + bool buttonclicked(); +public slots: + void slotsbuttonchance(int index, const QString &text); + void slotItemPress(const ScheduleDtailInfo &info); + /** + * @brief getCreatScheduleFromDbus 通过dbus获取新建的日程信息 + */ + void getCreatScheduleFromDbus(); + +private: + ScheduleDtailInfo m_scheduleDtailInfo; + QDateTime m_BeginDateTime; + QDateTime m_EndDateTime; + QString m_titleName; + int m_rpeat; + bool m_scheduleEmpty = false; + scheduleitemwidget *m_scheduleitemwidget; + QVector m_scheduleInfo; + CSchedulesDBus *m_dbus = nullptr; + bool m_buttonclicked = false; + +signals: + +public slots: +}; + +#endif // CREATESCHEDULE_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/widget/icondframe.cpp dde-calendar-5.7.0.23/schedule-plugin/src/widget/icondframe.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/widget/icondframe.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/widget/icondframe.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,166 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "icondframe.h" +#include +#include +#include +#include + +#include + +#include "../globaldef.h" +#include "../interface/reply.h" + +IconDFrame::IconDFrame(QWidget *parent) + : DFrame(parent) + , m_Dayrenderer(new QSvgRenderer()) + , m_Weekrenderer(new QSvgRenderer()) + , m_Monthrenderer(new QSvgRenderer()) + , m_backgroundrenderer(new QSvgRenderer()) +{ +} + +IconDFrame::~IconDFrame() +{ + delete m_Dayrenderer; + m_Dayrenderer = nullptr; + + delete m_Weekrenderer; + m_Weekrenderer = nullptr; + + delete m_Monthrenderer; + m_Monthrenderer = nullptr; + + delete m_backgroundrenderer; + m_backgroundrenderer = nullptr; +} + +void IconDFrame::setCenterLayout(QLayout *layout) +{ + QVBoxLayout *vlayout = new QVBoxLayout(); + vlayout->addSpacing(25); + vlayout->addLayout(layout); + this->setLayout(vlayout); +} + +void IconDFrame::paintEvent(QPaintEvent *event) +{ + setTheMe(DApplicationHelper::instance()->themeType()); + DFrame::paintEvent(event); + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; + paintPixmap(painter); + paintTitle(painter); +} + +void IconDFrame::hideEvent(QHideEvent *event) +{ + Q_UNUSED(event); + if(isEnabled()){ + //如果窗口为启用状态则触发窗口隐藏信号 + emit widgetIsHide(); + } +} + +void IconDFrame::setTheMe(const int type) +{ + QColor titleColor; + if (type == 0 || type == 1) { + titleColor.setRgb(0, 0, 0); + titleColor.setAlphaF(0.4); + } else { + titleColor.setRgb(255, 255, 255); + titleColor.setAlphaF(0.4); + } + setTitleColor(titleColor); +} + +void IconDFrame::paintPixmap(QPainter &painter) +{ + QString dayfile = QString(":/resources/DynamicIcon/day%1.svg").arg(QDate::currentDate().day()); + + m_Dayrenderer->load(dayfile); + + QString weekfile = QString(":/resources/DynamicIcon/week%1.svg").arg(QDate::currentDate().dayOfWeek()); + m_Weekrenderer->load(weekfile); + + QString monthfile = QString(":/resources/DynamicIcon/month%1.svg").arg(QDate::currentDate().month()); + m_Monthrenderer->load(monthfile); + + QString backgroundfile(":/resources/DynamicIcon/calendar_bg.svg"); + m_backgroundrenderer->load(backgroundfile); + + painter.save(); + painter.setRenderHint(QPainter::SmoothPixmapTransform); + //draw background + QRectF backgroundRect = QRectF(11, + 9, + 16, + 16); + m_backgroundrenderer->render(&painter, backgroundRect); + + //draw month + qreal month_x = 13; + qreal month_y = 10; + qreal month_w = 11; + qreal month_h = 4; + m_Monthrenderer->render(&painter, QRectF(month_x, month_y, month_w, month_h)); + + //draw day + qreal day_x = 14; + qreal day_y = 14; + qreal day_w = 9; + qreal day_h = 7; + m_Dayrenderer->render(&painter, QRectF(day_x, day_y, day_w, day_h)); + painter.restore(); +} + +void IconDFrame::paintTitle(QPainter &painter) +{ + QRect rect(34, 7, 24, 17); + painter.save(); + painter.setPen(TitleColor()); + painter.setFont(TitleFont()); + painter.drawText(rect, Qt::AlignCenter, tr(PLUGIN_TITLE_NAME)); + painter.restore(); +} + +void IconDFrame::slotReceivce(QVariant data, Reply *reply) +{ + Q_UNUSED(data); + Q_UNUSED(reply); +} + +QColor IconDFrame::TitleColor() const +{ + return m_TitleColor; +} + +void IconDFrame::setTitleColor(const QColor &TitleColor) +{ + m_TitleColor = TitleColor; +} + +QFont IconDFrame::TitleFont() +{ + m_TitleFont.setPixelSize(12); + return m_TitleFont; +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/widget/icondframe.h dde-calendar-5.7.0.23/schedule-plugin/src/widget/icondframe.h --- dde-calendar-5.7.0.4/schedule-plugin/src/widget/icondframe.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/widget/icondframe.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,70 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef ICONDFRAME_H +#define ICONDFRAME_H + +#include + +class QSvgRenderer; +class Reply; +DWIDGET_USE_NAMESPACE +class IconDFrame : public DFrame +{ + Q_OBJECT +public: + explicit IconDFrame(QWidget *parent = nullptr); + ~IconDFrame() override; + + void setCenterLayout(QLayout *layout); + + QColor TitleColor() const; + void setTitleColor(const QColor &TitleColor); + +private: + QFont TitleFont(); + +protected: + void paintEvent(QPaintEvent *event) override; + void hideEvent(QHideEvent *event) override; +private: + void setTheMe(const int type); + void paintPixmap(QPainter &painter); + void paintTitle(QPainter &painter); +signals: + void signaleSendMessage(QString text); + /** + * @brief widgetIsHide 窗口隐藏信号 + */ + void widgetIsHide(); +public slots: + virtual void slotReceivce(QVariant data, Reply *reply); + +private: + QSvgRenderer *m_Dayrenderer; + QSvgRenderer *m_Weekrenderer; + QSvgRenderer *m_Monthrenderer; + QSvgRenderer *m_backgroundrenderer; + + QColor m_TitleColor; + QFont m_TitleFont; +}; + +#endif // ICONDFRAME_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/widget/itemwidget.cpp dde-calendar-5.7.0.23/schedule-plugin/src/widget/itemwidget.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/widget/itemwidget.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/widget/itemwidget.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,239 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "itemwidget.h" + +#include + +ItemWidget::ItemWidget(QWidget *parent) + : DWidget(parent) +{ + QFont datetimefont; + datetimefont.setPixelSize(12); + QFont titlefont; + titlefont.setPixelSize(14); + setTitleFont(titlefont); + setDateTimeFont(datetimefont); +} + +void ItemWidget::paintEvent(QPaintEvent *event) +{ + setTheMe(DApplicationHelper::instance()->themeType()); + DWidget::paintEvent(event); + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; + + drawBackground(painter); + DrawItem(painter); +} + +void ItemWidget::drawBackground(QPainter &painter) +{ + const int radius = 8; + const int diameter = radius * 2; + const int RectWidth = this->rect().width(); + const int RectHeight = this->rect().height(); + painter.save(); + painter.setPen(Qt::NoPen); + QColor backgroundcolor(getBackgroundColor()); + painter.setBrush(backgroundcolor); + switch (m_Positon) { + case ItemTop: { + QPainterPath painterPath; + painterPath.moveTo(0, RectHeight); + painterPath.lineTo(RectWidth, RectHeight); + painterPath.lineTo(RectWidth, diameter); + painterPath.arcTo(QRect(RectWidth - diameter, 0, diameter, diameter), 0, 90); + painterPath.lineTo(diameter, 0); + painterPath.arcTo(QRect(0, 0, diameter, diameter), 90, 90); + painterPath.lineTo(0, RectHeight); + painterPath.closeSubpath(); + painter.drawPath(painterPath); + } break; + case ItemMiddle: + painter.drawRect(this->rect()); + break; + case ItemBottom: { + QPainterPath painterPath; + painterPath.moveTo(0, 0); + painterPath.lineTo(0, RectHeight - diameter); + painterPath.arcTo(QRect(0, RectHeight - diameter, diameter, diameter), 180, 90); + painterPath.lineTo(RectWidth - diameter, RectHeight); + painterPath.arcTo(QRect(RectWidth - diameter, RectHeight - diameter, diameter, diameter), 270, 90); + painterPath.lineTo(RectWidth, 0); + painterPath.lineTo(0, 0); + painterPath.closeSubpath(); + painter.drawPath(painterPath); + } break; + case ItemOnly: + painter.drawRoundedRect(this->rect(), 8, 8); + break; + } + painter.restore(); +} + +QColor ItemWidget::getBackgroundColor() +{ + return m_BackgroundColor; +} + +void ItemWidget::setTheMe(const int type) +{ + m_scheduleColor.setTheMe(type); + QColor titleColor; + QColor datetimeColor; + if (type == 0 || type == 1) { + titleColor.setRgb(0, 0, 0); + titleColor.setAlphaF(0.8); + + datetimeColor.setRgb(0, 0, 0); + datetimeColor.setAlphaF(0.6); + //设置浅色背景色 + m_BackgroundColor = "#000000"; + m_BackgroundColor.setAlphaF(0.05); + } else { + titleColor.setRgb(255, 255, 255); + titleColor.setAlphaF(1); + + datetimeColor.setRgb(255, 255, 255); + datetimeColor.setAlphaF(0.6); + //设置深色背景色 + m_BackgroundColor = "#FFFFFF"; + m_BackgroundColor.setAlphaF(0.05); + } + // DPalette palette; + // setTitleColor(palette.color(DPalette::Normal, DPalette::BrightText)); + setTitleColor(titleColor); + setDateTimeColor(datetimeColor); +} + +QColor ItemWidget::ScheduleColor() +{ + return m_scheduleColor.getColorByTypeId(m_scheduleInfo.type.ID).splitColor; +} + +ScheduleDtailInfo ItemWidget::getScheduleInfo() const +{ + return m_scheduleInfo; +} + +void ItemWidget::setDateTimeFont(const QFont &DateTimeFont) +{ + m_DateTimeFont = DateTimeFont; +} + +void ItemWidget::setTitleFont(const QFont &TitleFont) +{ + m_TitleFont = TitleFont; +} + +void ItemWidget::setDateTimeColor(const QColor &DateTimeColor) +{ + m_DateTimeColor = DateTimeColor; +} + +ScheduleDtailInfo ItemWidget::scheduleInfo() const +{ + return m_scheduleInfo; +} + +void ItemWidget::setScheduleInfo(const ScheduleDtailInfo &scheduleInfo) +{ + m_scheduleInfo = scheduleInfo; + setScheduleBeginTime(scheduleInfo.beginDateTime); + setScheduleEndTime(scheduleInfo.endDateTime); + setShowDate(scheduleInfo.beginDateTime.date()); + setTitleContent(scheduleInfo.titleName); +} + +void ItemWidget::setTitleColor(const QColor &TitleColor) +{ + m_TitleColor = TitleColor; +} + +QColor ItemWidget::getDateTimeColor() const +{ + return m_DateTimeColor; +} + +QFont ItemWidget::getDateTimeFont() const +{ + return m_DateTimeFont; +} + +QColor ItemWidget::getTitleColor() const +{ + return m_TitleColor; +} + +QFont ItemWidget::getTitleFont() const +{ + return m_TitleFont; +} + +QDateTime ItemWidget::getScheduleEndTime() const +{ + return m_ScheduleEndTime; +} + +void ItemWidget::setScheduleEndTime(const QDateTime &ScheduleEndTime) +{ + m_ScheduleEndTime = ScheduleEndTime; +} + +QDateTime ItemWidget::getScheduleBeginTime() const +{ + return m_ScheduleBeginTime; +} + +void ItemWidget::setScheduleBeginTime(const QDateTime &ScheduleBeginTime) +{ + m_ScheduleBeginTime = ScheduleBeginTime; +} + +QDate ItemWidget::getShowDate() const +{ + return m_ShowDate; +} + +void ItemWidget::setShowDate(const QDate &ShowDate) +{ + m_ShowDate = ShowDate; +} + +QString ItemWidget::getTitleContent() const +{ + return m_TitleContent; +} + +void ItemWidget::setTitleContent(const QString &TitleContent) +{ + m_TitleContent = TitleContent; +} + +void ItemWidget::setPositon(const Item_Position &Positon) +{ + m_Positon = Positon; +} + +void ItemWidget::DrawItem(QPainter &painter) +{ + Q_UNUSED(painter); +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/widget/itemwidget.h dde-calendar-5.7.0.23/schedule-plugin/src/widget/itemwidget.h --- dde-calendar-5.7.0.4/schedule-plugin/src/widget/itemwidget.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/widget/itemwidget.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,114 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef ITEMWIDGET_H +#define ITEMWIDGET_H + +#include "../data/schedulecolourmanage.h" +#include "../data/schedulestructs.h" + +#include +#include +#include +#include + +DWIDGET_USE_NAMESPACE + +class ItemWidget : public DWidget +{ + Q_OBJECT +public: + enum Item_Position { ItemTop, + ItemMiddle, + ItemBottom, + ItemOnly }; + +public: + explicit ItemWidget(QWidget *parent = nullptr); + + void setPositon(const Item_Position &Positon); + + virtual void DrawItem(QPainter &painter); + + void setTitleContent(const QString &TitleContent); + QString getTitleContent() const; + + QDate getShowDate() const; + void setShowDate(const QDate &ShowDate); + + QDateTime getScheduleBeginTime() const; + void setScheduleBeginTime(const QDateTime &ScheduleBeginTime); + + QDateTime getScheduleEndTime() const; + void setScheduleEndTime(const QDateTime &ScheduleEndTime); + + ScheduleDtailInfo scheduleInfo() const; + void setScheduleInfo(const ScheduleDtailInfo &scheduleInfo); + + ScheduleDtailInfo getScheduleInfo() const; + +protected: + QFont getTitleFont() const; + + QColor getTitleColor() const; + + QFont getDateTimeFont() const; + + QColor getDateTimeColor() const; + + void setTitleColor(const QColor &TitleColor); + + void setDateTimeColor(const QColor &DateTimeColor); + + void setTitleFont(const QFont &TitleFont); + + void setDateTimeFont(const QFont &DateTimeFont); + +protected: + void paintEvent(QPaintEvent *event) override; + void drawBackground(QPainter &painter); + QColor getBackgroundColor(); + virtual void setTheMe(const int type); + QColor ScheduleColor(); +signals: + +public slots: + +private: + Item_Position m_Positon {ItemMiddle}; + QString m_TitleContent; + QDate m_ShowDate; + QDateTime m_ScheduleBeginTime; + QDateTime m_ScheduleEndTime; + + QFont m_TitleFont; + QColor m_TitleColor; + QFont m_DateTimeFont; + QColor m_DateTimeColor; + /** + * @brief m_BackgroundColor 绘制背景色 + */ + QColor m_BackgroundColor{"#000000"}; + + ScheduleColourManage m_scheduleColor; + ScheduleDtailInfo m_scheduleInfo; +}; + +#endif // ITEMWIDGET_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/widget/modifyscheduleitem.cpp dde-calendar-5.7.0.23/schedule-plugin/src/widget/modifyscheduleitem.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/widget/modifyscheduleitem.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/widget/modifyscheduleitem.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,157 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "modifyscheduleitem.h" +#include "../globaldef.h" + +modifyScheduleItem::modifyScheduleItem(QWidget *parent) + : ItemWidget(parent) +{ + setFixedHeight(MODIFY_ITEM_HEIGHT); +} + +void modifyScheduleItem::DrawItem(QPainter &painter) +{ + drawIndex(painter); + drawLine(painter); + drawTitleContent(painter); + drawScheduleColorLine(painter); + drawTime(painter); + drawDate(painter); +} + +int modifyScheduleItem::getIndex() const +{ + return m_Index; +} + +void modifyScheduleItem::setIndex(int Index) +{ + m_Index = Index; +} + +void modifyScheduleItem::drawIndex(QPainter &painter) +{ + painter.save(); + painter.setFont(getTitleFont()); + painter.setPen(getDateTimeColor()); + + const QRect indexRect(m_IndexX, 0, m_IndexWidth, this->rect().height()); + painter.drawText(indexRect, Qt::AlignCenter, QString::number(getIndex())); + painter.restore(); +} + +void modifyScheduleItem::drawLine(QPainter &painter) +{ + painter.save(); + QRect rect(40, 10, 1, 28); + painter.setPen(Qt::NoPen); + painter.setBrush(LineColor()); + painter.drawRect(rect); + painter.restore(); +} + +void modifyScheduleItem::drawTitleContent(QPainter &painter) +{ + painter.save(); + painter.setFont(getTitleFont()); + painter.setPen(getTitleColor()); + const int textRectWidth = this->rect().width() - m_TItleRightMargin - m_TitleX; + const QRect titleContent(m_TitleX, 0, textRectWidth, this->rect().height()); + QFontMetrics metrics(getTitleFont()); + painter.drawText(titleContent, + Qt::AlignLeft | Qt::AlignVCenter, + metrics.elidedText(getTitleContent(), Qt::ElideRight, textRectWidth)); + painter.restore(); +} + +void modifyScheduleItem::drawScheduleColorLine(QPainter &painter) +{ + painter.save(); + QRect rect(this->width() - m_TItleRightMargin, + 0, + 2, + this->height()); + painter.setPen(Qt::NoPen); + painter.setBrush(ScheduleColor()); + painter.drawRect(rect); + painter.restore(); +} + +void modifyScheduleItem::drawTime(QPainter &painter) +{ + painter.save(); + QRect rect(this->width() - 75, 10 - m_DateTimeOffset, 65, 17); + painter.setPen(getDateTimeColor()); + painter.setFont(getDateTimeFont()); + QString timestr; + if (scheduleInfo().allday) { + timestr = ALL_DAY; + } else { + timestr = QString("%1-%2").arg(getScheduleBeginTime().toString("hh:mm")).arg(getScheduleEndTime().toString("hh:mm")); + } + painter.drawText(rect, Qt::AlignLeft | Qt::AlignTop, + timestr); + + painter.restore(); +} + +void modifyScheduleItem::drawDate(QPainter &painter) +{ + painter.save(); + QRect rect(this->width() - 75, 27 - m_DateTimeOffset, 65, 17); + painter.setPen(getDateTimeColor()); + painter.setFont(getDateTimeFont()); + painter.drawText(rect, Qt::AlignLeft | Qt::AlignTop, + getShowDate().toString("yyyy/MM/dd")); + painter.restore(); +} + +void modifyScheduleItem::setLineColor(const QColor &LineColor) +{ + m_LineColor = LineColor; +} + +void modifyScheduleItem::mousePressEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) { + emit signalSendSelectScheduleIndex(getIndex()); + } +} + +QColor modifyScheduleItem::LineColor() const +{ + return m_LineColor; +} + +void modifyScheduleItem::setTheMe(const int type) +{ + ItemWidget::setTheMe(type); + QColor lineColor; + if (type == 0 || type == 1) { + lineColor = QColor("#000000"); + lineColor.setAlphaF(0.1); + } else { + //设置深色主题分割线颜色 + lineColor = QColor("#FFFFFF"); + lineColor.setAlphaF(0.1); + } + setLineColor(lineColor); +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/widget/modifyscheduleitem.h dde-calendar-5.7.0.23/schedule-plugin/src/widget/modifyscheduleitem.h --- dde-calendar-5.7.0.4/schedule-plugin/src/widget/modifyscheduleitem.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/widget/modifyscheduleitem.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,63 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef MODIFYSCHEDULEITEM_H +#define MODIFYSCHEDULEITEM_H + +#include "itemwidget.h" + +class modifyScheduleItem : public ItemWidget +{ + Q_OBJECT +public: + explicit modifyScheduleItem(QWidget *parent = nullptr); + int getIndex() const; + void setIndex(int Index); + +protected: + QColor LineColor() const; + void setLineColor(const QColor &LineColor); + +protected: + void mousePressEvent(QMouseEvent *event) override; + +private: + void setTheMe(const int type) override; + void DrawItem(QPainter &painter) override; + void drawIndex(QPainter &painter); + void drawLine(QPainter &painter); + void drawTitleContent(QPainter &painter); + void drawScheduleColorLine(QPainter &painter); + void drawTime(QPainter &painter); + void drawDate(QPainter &painter); +signals: + void signalSendSelectScheduleIndex(int index); +public slots: +private: + int m_Index {1}; + const int m_IndexWidth {16}; + const int m_IndexX {14}; + QColor m_LineColor {"#000000"}; + const int m_TitleX {51}; + const int m_TItleRightMargin {97}; + const int m_DateTimeOffset = 3; +}; + +#endif // MODIFYSCHEDULEITEM_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/widget/opencalendarwidget.cpp dde-calendar-5.7.0.23/schedule-plugin/src/widget/opencalendarwidget.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/widget/opencalendarwidget.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/widget/opencalendarwidget.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,89 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "opencalendarwidget.h" +#include +#include +#include + +#include "../globaldef.h" + +#include + +OpenCalendarWidget::OpenCalendarWidget(QWidget *parent) + : DWidget(parent) +{ + setFixedHeight(OPENCALENDAR_WDIGET_HEIGHT); +} + +void OpenCalendarWidget::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event); + setTheMe(DApplicationHelper::instance()->themeType()); + QPainter painter(this); + painter.setPen(TitleColor()); + painter.setFont(TitleFont()); + painter.drawText(this->rect(), + Qt::AlignLeft | Qt::AlignVCenter, + QString(OPENCALENDAR_WIDGET_TITLE).arg(m_ScheduleCount)); +} + +void OpenCalendarWidget::mousePressEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) { + QProcess proc; + proc.startDetached(PROCESS_OPEN_CALENDAR); + } +} + +QColor OpenCalendarWidget::TitleColor() const +{ + return m_TitleColor; +} + +void OpenCalendarWidget::setTitleColor(const QColor &TitleColor) +{ + m_TitleColor = TitleColor; +} + +QFont OpenCalendarWidget::TitleFont() +{ + m_TitleFont.setPixelSize(12); + return m_TitleFont; +} + +void OpenCalendarWidget::setTheMe(const int type) +{ + QColor titleColor; + if (type == 0 || type == 1) { + titleColor.setRgb(0, 0, 0); + titleColor.setAlphaF(0.4); + } else { + titleColor.setRgb(255, 255, 255); + titleColor.setAlphaF(0.4); + } + setTitleColor(titleColor); +} + +void OpenCalendarWidget::setScheduleCount(int ScheduleCount) +{ + m_ScheduleCount = ScheduleCount; + update(); +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/widget/opencalendarwidget.h dde-calendar-5.7.0.23/schedule-plugin/src/widget/opencalendarwidget.h --- dde-calendar-5.7.0.4/schedule-plugin/src/widget/opencalendarwidget.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/widget/opencalendarwidget.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,56 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef OPENCALENDARWIDGET_H +#define OPENCALENDARWIDGET_H + +#include +#include +#include + +DWIDGET_USE_NAMESPACE +class OpenCalendarWidget : public DWidget +{ + Q_OBJECT +public: + explicit OpenCalendarWidget(QWidget *parent = nullptr); + + void setScheduleCount(int ScheduleCount); + + QFont TitleFont(); + QColor TitleColor() const; + void setTitleColor(const QColor &TitleColor); + +private: + void setTheMe(const int type); + +protected: + void paintEvent(QPaintEvent *event) override; + void mousePressEvent(QMouseEvent *event) override; +signals: + +public slots: +private: + int m_ScheduleCount; + QColor m_TitleColor; + QFont m_TitleFont; +}; + +#endif // OPENCALENDARWIDGET_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/widget/repeatschedulewidget.cpp dde-calendar-5.7.0.23/schedule-plugin/src/widget/repeatschedulewidget.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/widget/repeatschedulewidget.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/widget/repeatschedulewidget.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,84 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "repeatschedulewidget.h" +#include "scheduleitemwidget.h" +#include "buttonwidget.h" +#include "../globaldef.h" + +repeatScheduleWidget::repeatScheduleWidget(repeatScheduleWidget::Operation_type operation, repeatScheduleWidget::Widget_type widgetype, bool tocreateBtn, QWidget *parent) + : IconDFrame(parent) + , m_OperationType(operation) + , m_WidgetType(widgetype) + , m_createBtnBool(tocreateBtn) +{ +} + +void repeatScheduleWidget::setSchedule(const ScheduleDtailInfo &info) +{ + m_scheduleInfo.clear(); + m_scheduleInfo.append(info); + initUI(); +} + +void repeatScheduleWidget::initUI() +{ + m_scheduleitemwidget = new scheduleitemwidget(this); + QVBoxLayout *mainlayout = new QVBoxLayout(); + m_scheduleitemwidget->setScheduleDtailInfo(m_scheduleInfo); + m_scheduleitemwidget->addscheduleitem(); + mainlayout->addWidget(m_scheduleitemwidget); + + if (m_createBtnBool) { + buttonwidget *button = new buttonwidget(this); + m_buttonCount = 0; + switch (m_WidgetType) { + case Widget_Confirm: { + button->addbutton(CANCEL_BUTTON_STRING); + if (m_OperationType == Operation_Cancel) { + button->addbutton(CONFIRM_BUTTON_STRING, true, buttonwidget::ButtonWarning); + } else { + button->addbutton(CONFIRM_BUTTON_STRING, true, buttonwidget::ButtonRecommend); + } + } break; + default: { + if (m_OperationType == Operation_Cancel) { + button->addbutton(CANCEL_BUTTON_STRING); + button->addbutton(DELETEALL_BUTTON_STRING); + button->addbutton(ONLY_DELETE_THIS_BUTTON_STRING, true, buttonwidget::ButtonWarning); + } else { + button->addbutton(CANCEL_BUTTON_STRING); + button->addbutton(CHANGE_ALL_BUTTON_STRING); + button->addbutton(CHANGE_ONLYL_BUTTON_STRING, true, buttonwidget::ButtonRecommend); + } + } break; + } + m_buttonCount = button->buttonCount(); + connect(button, &buttonwidget::buttonClicked, this, &repeatScheduleWidget::slotButtonCheckNum); + mainlayout->addSpacing(4); + mainlayout->addWidget(button); + } + setCenterLayout(mainlayout); +} + +void repeatScheduleWidget::slotButtonCheckNum(int index, const QString &text) +{ + emit signalButtonCheckNum(index, text, m_buttonCount); +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/widget/repeatschedulewidget.h dde-calendar-5.7.0.23/schedule-plugin/src/widget/repeatschedulewidget.h --- dde-calendar-5.7.0.4/schedule-plugin/src/widget/repeatschedulewidget.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/widget/repeatschedulewidget.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,59 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef REPEATSCHEDULEWIDGET_H +#define REPEATSCHEDULEWIDGET_H + +#include "icondframe.h" +#include "../data/schedulestructs.h" + +class scheduleitemwidget; +class repeatScheduleWidget : public IconDFrame +{ + Q_OBJECT +public: + enum Operation_type { Operation_Cancel, + Operation_Change + }; + enum Widget_type { Widget_Repeat, + Widget_Confirm + }; + +public: + explicit repeatScheduleWidget(Operation_type operation, Widget_type widgetype, bool tocreateBtn = true, QWidget *parent = nullptr); + void setSchedule(const ScheduleDtailInfo &info); + +private: + void initUI(); +signals: + void signalButtonCheckNum(int index, const QString &text, const int buttonCount); +public slots: + void slotButtonCheckNum(int index, const QString &text); + +private: + scheduleitemwidget *m_scheduleitemwidget {nullptr}; + QVector m_scheduleInfo; + Operation_type m_OperationType {Operation_Cancel}; + Widget_type m_WidgetType {Widget_Confirm}; + int m_buttonCount {0}; + bool m_createBtnBool {true}; +}; + +#endif // REPEATSCHEDULEWIDGET_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/widget/scheduleitemwidget.cpp dde-calendar-5.7.0.23/schedule-plugin/src/widget/scheduleitemwidget.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/widget/scheduleitemwidget.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/widget/scheduleitemwidget.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,166 @@ +#include "scheduleitemwidget.h" +#include +#include + +#include "../globaldef.h" + +scheduleitemwidget::scheduleitemwidget(QWidget *parent) + : DWidget(parent) +{ +} + +scheduleitemwidget::~scheduleitemwidget() +{ +} + +void scheduleitemwidget::setScheduleDtailInfo(QVector &scheduleInfo) +{ + m_scheduleInfo = scheduleInfo; + sortScheduleWithTime(); +} + +void scheduleitemwidget::addscheduleitem() +{ + QVBoxLayout *mainlayout = new QVBoxLayout(); + scheduleitemdate *m_scheduleitemdate = new scheduleitemdate(); + mainlayout->setContentsMargins(0, 0, 0, 0); + mainlayout->addWidget(m_scheduleitemdate); + mainlayout->addSpacing(10); + mainlayout->setSpacing(1); + + if (m_scheduleInfo.count() == 1) { + //单个日程 + scheduleitem *m_scheduleitem = new scheduleitem(); + connect(m_scheduleitem, &scheduleitem::signalItemPress, this, &scheduleitemwidget::signalItemPress); + m_scheduleitem->setPositon(ItemWidget::ItemOnly); + m_scheduleitemdate->setScheduleDtailInfo(m_scheduleInfo.first()); + m_scheduleitem->setScheduleInfo(m_scheduleInfo.first()); + mainlayout->addWidget(m_scheduleitem); + } else if (m_scheduleInfo.count() > 1) { + //多个日程 + for (int i = 0; i < m_scheduleInfo.count(); i++) { + scheduleitem *m_scheduleitem = new scheduleitem(); + connect(m_scheduleitem, &scheduleitem::signalItemPress, this, &scheduleitemwidget::signalItemPress); + if (i == 0) { + m_scheduleitem->setPositon(ItemWidget::ItemTop); + } else if (i == m_scheduleInfo.count() - 1) { + m_scheduleitem->setPositon(ItemWidget::ItemBottom); + } else { + m_scheduleitem->setPositon(ItemWidget::ItemMiddle); + } + m_scheduleitemdate->setScheduleDtailInfo(m_scheduleInfo[i]); + m_scheduleitem->setScheduleInfo(m_scheduleInfo[i]); + mainlayout->addWidget(m_scheduleitem); + } + } + + this->setLayout(mainlayout); +} + +void scheduleitemwidget::sortScheduleWithTime() +{ + for (int i = 0; i < m_scheduleInfo.count(); i++) { + for (int j = 0; j < m_scheduleInfo.count() - i - 1; j++) { + if (m_scheduleInfo[j].beginDateTime > m_scheduleInfo[j + 1].beginDateTime) + std::swap(m_scheduleInfo[j], m_scheduleInfo[j + 1]); + } + } +} + +scheduleitem::scheduleitem(QWidget *parent) + : ItemWidget(parent) +{ + setFixedHeight(36); +} + +void scheduleitem::DrawItem(QPainter &painter) +{ + drawScheduleColorLine(painter); + drawTime(painter); + drawDetails(painter); +} + +void scheduleitem::drawScheduleColorLine(QPainter &painter) +{ + painter.save(); + QRect rect(m_LineRightMargin, + 0, + 2, + this->height()); + painter.setPen(Qt::NoPen); + painter.setBrush(ScheduleColor()); + painter.drawRect(rect); + painter.restore(); +} + +void scheduleitem::drawTime(QPainter &painter) +{ + painter.save(); + QRect rect(m_timeLeftMargin, 0, 82, this->rect().height()); + painter.setPen(getDateTimeColor()); + painter.setFont(getDateTimeFont()); + QString timestr; + if (scheduleInfo().allday) { + timestr = ALL_DAY; + } else { + timestr = QString("%1-%2").arg(scheduleInfo().beginDateTime.toString("hh:mm")).arg(scheduleInfo().endDateTime.toString("hh:mm")); + } + painter.drawText(rect, Qt::AlignLeft | Qt::AlignVCenter, + timestr); + painter.restore(); +} + +void scheduleitem::drawDetails(QPainter &painter) +{ + painter.save(); + QRect rect(m_DetailsRightMargin + m_LineRightMargin + 2, 0, m_DetailsWidth, this->rect().height()); + painter.setPen(getTitleColor()); + painter.setFont(getTitleFont()); + QFontMetrics metrics(getTitleFont()); + painter.drawText(rect, + Qt::AlignLeft | Qt::AlignVCenter, + metrics.elidedText(getTitleContent(), Qt::ElideRight, rect.width() - m_EllipsisWidth)); + painter.restore(); +} + +void scheduleitem::mousePressEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) { + emit signalItemPress(getScheduleInfo()); + } +} + +scheduleitemdate::scheduleitemdate(QWidget *parent) + : QWidget(parent) +{ + setFixedHeight(20); +} + +void scheduleitemdate::setScheduleDtailInfo(ScheduleDtailInfo &scheduelDtailInfo) +{ + m_scheduleDtailInfo = scheduelDtailInfo; +} + +QColor scheduleitemdate::DetailsColor() +{ + int type = DGuiApplicationHelper::instance()->themeType(); + + if (type == 0 || type == 1) { + m_DateTimeColor.setRgb(0, 0, 0); + } else { + m_DateTimeColor.setRgb(255, 255, 255); + } + return m_DateTimeColor; +} + +void scheduleitemdate::paintEvent(QPaintEvent *event) +{ + QWidget::paintEvent(event); + QPainter painter(this); + painter.save(); + painter.setRenderHint(QPainter::Antialiasing); + painter.setPen(DetailsColor()); + painter.drawText(QRect(m_LeftMargin, 0, this->rect().width(), 20), Qt::AlignLeft | Qt::AlignVCenter, + QString("%1 %2").arg(m_scheduleDtailInfo.beginDateTime.date().toString("yyyy年MM月dd日")).arg(m_scheduleDtailInfo.beginDateTime.toString("dddd"))); + painter.restore(); +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/widget/scheduleitemwidget.h dde-calendar-5.7.0.23/schedule-plugin/src/widget/scheduleitemwidget.h --- dde-calendar-5.7.0.4/schedule-plugin/src/widget/scheduleitemwidget.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/widget/scheduleitemwidget.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,77 @@ +#ifndef CREATSHCEDULEITEM_H +#define CREATSHCEDULEITEM_H + +#include "itemwidget.h" +#include "../data/schedulestructs.h" +#include "../data/schedulecolourmanage.h" +#include + +class scheduleitemdate; +class scheduleitem; +class scheduleitemwidget : public DWidget +{ + Q_OBJECT +public: + explicit scheduleitemwidget(QWidget *parent = nullptr); + ~scheduleitemwidget(); + + void setScheduleDtailInfo(QVector &scheduleInfo); + void addscheduleitem(); +signals: + void signalItemPress(const ScheduleDtailInfo &info); + +private: + void sortScheduleWithTime(); + +private: + ScheduleDtailInfo m_scheduleDtailInfo; + QVector m_scheduleInfo; +}; + +class scheduleitem : public ItemWidget +{ + Q_OBJECT +public: + explicit scheduleitem(QWidget *parent = nullptr); + +private: + void DrawItem(QPainter &painter) override; + void drawScheduleColorLine(QPainter &painter); + void drawTime(QPainter &painter); + void drawDetails(QPainter &painter); + +protected: + void mousePressEvent(QMouseEvent *event) override; +signals: + void signalItemPress(const ScheduleDtailInfo &info); + +private: + const int m_timeLeftMargin = 13; + const int m_timeTopMargin = 9; + const int m_LineRightMargin = 84; + const int m_DetailsRightMargin = 7; + const int m_DetailsTopMargin = 7; + const int m_DetailsWidth = 256; + const int m_EllipsisWidth = 8; +}; + +class scheduleitemdate : public QWidget +{ + Q_OBJECT +public: + explicit scheduleitemdate(QWidget *parent = nullptr); + void setScheduleDtailInfo(ScheduleDtailInfo &scheduelDtailInfo); + + QColor DetailsColor(); + +protected: + void paintEvent(QPaintEvent *event); + +private: + ScheduleDtailInfo m_scheduleDtailInfo; + QColor m_DateTimeColor; + + const int m_LeftMargin = 13; +}; + +#endif // CREATSHCEDULEITEM_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/widget/schedulelistwidget.cpp dde-calendar-5.7.0.23/schedule-plugin/src/widget/schedulelistwidget.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/widget/schedulelistwidget.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/widget/schedulelistwidget.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,68 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "schedulelistwidget.h" +#include + +#include "modifyscheduleitem.h" +#include "opencalendarwidget.h" +#include "../globaldef.h" + +scheduleListWidget::scheduleListWidget(QWidget *parent) + : IconDFrame(parent) +{ +} + +void scheduleListWidget::setScheduleInfoVector(const QVector &ScheduleInfoVector) +{ + m_ScheduleInfoVector = ScheduleInfoVector; + updateUI(); +} + +void scheduleListWidget::updateUI() +{ + QVBoxLayout *layout = new QVBoxLayout(); + layout->setSpacing(1); + bool showOpenWidget = m_ScheduleInfoVector.size() > ITEM_SHOW_NUM; + const int showcount = showOpenWidget ? ITEM_SHOW_NUM : m_ScheduleInfoVector.size(); + for (int i = 0; i < showcount; ++i) { + modifyScheduleItem *item = new modifyScheduleItem(); + if (i == 0) { + item->setPositon(ItemWidget::ItemTop); + } else if (i == showcount - 1) { + item->setPositon(ItemWidget::ItemBottom); + } else { + item->setPositon(ItemWidget::ItemMiddle); + } + item->setIndex(i + 1); + item->setScheduleInfo(m_ScheduleInfoVector[i]); + connect(item, &modifyScheduleItem::signalSendSelectScheduleIndex, + this, &scheduleListWidget::signalSelectScheduleIndex); + layout->addWidget(item); + } + + if (showOpenWidget) { + OpenCalendarWidget *openWidget = new OpenCalendarWidget(); + openWidget->setScheduleCount(m_ScheduleInfoVector.size()); + layout->addSpacing(6); + layout->addWidget(openWidget); + } + this->setCenterLayout(layout); +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/widget/schedulelistwidget.h dde-calendar-5.7.0.23/schedule-plugin/src/widget/schedulelistwidget.h --- dde-calendar-5.7.0.4/schedule-plugin/src/widget/schedulelistwidget.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/widget/schedulelistwidget.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,46 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef SCHEDULELISTWIDGET_H +#define SCHEDULELISTWIDGET_H + +#include + +#include "../data/schedulestructs.h" +#include "icondframe.h" + +DWIDGET_USE_NAMESPACE +class scheduleListWidget : public IconDFrame +{ + Q_OBJECT +public: + explicit scheduleListWidget(QWidget *parent = nullptr); + + void setScheduleInfoVector(const QVector &ScheduleInfoVector); + + void updateUI(); +signals: + void signalSelectScheduleIndex(int index); + +private: + QVector m_ScheduleInfoVector; +}; + +#endif // SCHEDULELISTWIDGET_H diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/widget/viewschedulewidget.cpp dde-calendar-5.7.0.23/schedule-plugin/src/widget/viewschedulewidget.cpp --- dde-calendar-5.7.0.4/schedule-plugin/src/widget/viewschedulewidget.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/widget/viewschedulewidget.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,274 @@ +#include "viewschedulewidget.h" +#include "opencalendarwidget.h" +#include +#include + +#include "../globaldef.h" +#include "../dbus/schedulesdbus.h" + +viewschedulewidget::viewschedulewidget(QWidget *parent) + : IconDFrame(parent) +{ +} + +viewschedulewidget::~viewschedulewidget() +{ +} + +void viewschedulewidget::setScheduleDateRangeInfo(QVector &scheduleDateInfo) +{ + m_scheduleDateInfo = scheduleDateInfo; +} + +void viewschedulewidget::viewScheduleInfoShow(QVector m_showdate) +{ + QVBoxLayout *mainlayout = new QVBoxLayout(); + mainlayout->setSpacing(10); + int scheduleNum = 0; + QVector scheduleInfo; + for (int i = 0; i < m_showdate.count(); i++) { + for (int j = 0; j < m_showdate.at(i).vData.count(); j++) { + scheduleInfo.append(m_showdate.at(i).vData.at(j)); + + scheduleNum++; + if (scheduleNum == 10) + break; + } + + scheduleitemwidget *item = new scheduleitemwidget(); + connect(item, &scheduleitemwidget::signalItemPress, this, &viewschedulewidget::slotItemPress); + item->setScheduleDtailInfo(scheduleInfo); + item->addscheduleitem(); + mainlayout->addWidget(item); + scheduleInfo.clear(); + + if (scheduleNum == 10) + break; + } + + if (getScheduleNum(m_showdate) > 10) { + OpenCalendarWidget *openWidget = new OpenCalendarWidget(); + openWidget->setScheduleCount(getScheduleNum(m_showdate)); + mainlayout->addWidget(openWidget); + } + + setCenterLayout(mainlayout); +} + +int viewschedulewidget::getScheduleNum(QVector m_showdate) +{ + int scheduleTotalNum = 0; + + for (int i = 0; i < m_showdate.count(); i++) { + scheduleTotalNum += m_showdate.at(i).vData.count(); + } + return scheduleTotalNum; +} + +void viewschedulewidget::setQueryBeginDateTime(QDateTime begindatetime) +{ + m_beginDateTime = begindatetime; +} + +void viewschedulewidget::setQueryEndDateTime(QDateTime enddatetime) +{ + m_endDateTime = enddatetime; +} + +QVector viewschedulewidget::getAllRpeatScheduleInfo(int rpeat) +{ + QVector scheduleInfo; + ScheduleDateRangeInfo scheduleDtailInfo; + + for (int i = 0; i < getAllScheduleInfo().count(); i++) { + for (int j = 0; j < getAllScheduleInfo().at(i).vData.count(); j++) { + if (getAllScheduleInfo().at(i).vData.at(j).rpeat == rpeat) { + scheduleDtailInfo.vData.append(getAllScheduleInfo().at(i).vData.at(j)); + } + } + if (scheduleDtailInfo.vData.count() > 0) + scheduleInfo.append(scheduleDtailInfo); + scheduleDtailInfo.vData.clear(); + } + return scheduleInfo; +} + +QVector viewschedulewidget::getNextScheduleInfo() +{ + //返回的日程信息 + QVector showdate; + //下一个日程当天的所有日程 + ScheduleDateRangeInfo scheduleinfo; + //当天最早的日程 + ScheduleDateRangeInfo viewScheduleInfo; + //下一个日程的时间 + QTime earlyTime; + //下一个日程的索引 + int index = 0; + //下一个日程的id + int scheduleid = 0; + + scheduleinfo = getAllScheduleInfo().first(); + earlyTime = scheduleinfo.vData.at(0).beginDateTime.time(); + scheduleid = scheduleinfo.vData.at(0).id; + //在一天的日程中筛选时间最早(如果时间最早有多个,取id最小的)的日程 + for (int i = 1; i < scheduleinfo.vData.count(); i++) { + QTime viewTime = scheduleinfo.vData.at(i).beginDateTime.time(); + int viewScheduleid = scheduleinfo.vData.at(i).id; + if (earlyTime > viewTime) { + earlyTime = viewTime; + index = i; + } else if (earlyTime == viewTime) { + if (scheduleid > viewScheduleid) { + index = i; + } + } + } + //将筛选到的日程信息添加到当天最早的日程容器中 + viewScheduleInfo.vData.append(scheduleinfo.vData.at(index)); + showdate.append(viewScheduleInfo); + return showdate; +} + +void viewschedulewidget::slotItemPress(const ScheduleDtailInfo &info) +{ + QProcess proc; + proc.startDetached(PROCESS_OPEN_CALENDAR); + QThread::msleep(750); + QString schedulestr = CSchedulesDBus::createScheduleDtailInfojson(info); + QDBusMessage message = QDBusMessage::createMethodCall(DBUS_CALENDAR_SERVICE, + DBUS_CALENDAR_PATCH, + DBUS_CALENDAR_INTFACE, + "OpenSchedule"); + message << schedulestr; + //发送消息 + QDBusMessage response = QDBusConnection::sessionBus().call(message); +} + +QVector viewschedulewidget::queryScheduleWithTime(QVector &scheduleinfo, QTime beginT, QTime endT) +{ + QVector scheduleDateInfo; + ScheduleDateRangeInfo scheduleDInfo; + + for (int i = 0; i < scheduleinfo.count(); i++) { + for (int j = 0; j < scheduleinfo.at(i).vData.count(); j++) { + if (scheduleinfo.at(i).vData.at(j).beginDateTime.time() <= endT + && scheduleinfo.at(i).vData.at(j).endDateTime.time() >= beginT) { + scheduleDInfo.vData.append(scheduleinfo.at(i).vData.at(j)); + } + } + if (scheduleDInfo.vData.count() > 0) + scheduleDateInfo.append(scheduleDInfo); + scheduleDInfo.vData.clear(); + } + return scheduleDateInfo; +} + +QVector viewschedulewidget::queryScheduleWithDate(QVector &scheduleinfo, QDate beginD, QDate endD) +{ + QVector scheduleDateInfo; + ScheduleDateRangeInfo scheduleDInfo; + + for (int i = 0; i < scheduleinfo.count(); i++) { + for (int j = 0; j < scheduleinfo.at(i).vData.count(); j++) { + if (scheduleinfo.at(i).vData.at(j).beginDateTime.date() <= endD + && scheduleinfo.at(i).vData.at(j).endDateTime.date() >= beginD) { + scheduleDInfo.vData.append(scheduleinfo.at(i).vData.at(j)); + } + } + if (scheduleDInfo.vData.count() > 0) + scheduleDateInfo.append(scheduleDInfo); + scheduleDInfo.vData.clear(); + } + return scheduleDateInfo; +} + +QVector viewschedulewidget::queryScheduleWithWeek(QVector &scheduleinfo, QVector weekDay, int dayofweek, QTime beginT, QTime endT) +{ + QVector scheduleDateInfo; + ScheduleDateRangeInfo scheduleDInfo; + + for (int i = 0; i < scheduleinfo.count(); i++) { + for (int j = 0; j < scheduleinfo.at(i).vData.count(); j++) { + for (int k = 0; k < weekDay.count(); k++) { + if (scheduleinfo.at(i).vData.at(j).beginDateTime.date().dayOfWeek() == weekDay[k]) { + if (weekDay[k] == dayofweek) { + if (scheduleinfo.at(i).vData.at(j).beginDateTime.time() <= endT + && scheduleinfo.at(i).vData.at(j).endDateTime.time() >= beginT) { + scheduleDInfo.vData.append(scheduleinfo.at(i).vData.at(j)); + } + } else { + scheduleDInfo.vData.append(scheduleinfo.at(i).vData.at(j)); + } + break; + } + } + } + if (scheduleDInfo.vData.count() > 0) + scheduleDateInfo.append(scheduleDInfo); + scheduleDInfo.vData.clear(); + } + + return scheduleDateInfo; +} + +QVector viewschedulewidget::queryScheduleWithMonth(QVector &scheduleinfo, QVector monthDay, int dayofmonth, QTime beginT, QTime endT) +{ + QVector scheduleDateInfo; + ScheduleDateRangeInfo scheduleDInfo; + + for (int i = 0; i < scheduleinfo.count(); i++) { + for (int j = 0; j < scheduleinfo.at(i).vData.count(); j++) { + for (int k = 0; k < monthDay.count(); k++) { + if (scheduleinfo.at(i).vData.at(j).beginDateTime.date().day() == monthDay[k]) { + if (monthDay[k] == dayofmonth) { + if (scheduleinfo.at(i).vData.at(j).beginDateTime.time() <= endT + && scheduleinfo.at(i).vData.at(j).endDateTime.time() >= beginT) { + scheduleDInfo.vData.append(scheduleinfo.at(i).vData.at(j)); + } + } else { + scheduleDInfo.vData.append(scheduleinfo.at(i).vData.at(j)); + } + break; + } + } + } + if (scheduleDInfo.vData.count() > 0) + scheduleDateInfo.append(scheduleDInfo); + scheduleDInfo.vData.clear(); + } + + return scheduleDateInfo; +} + +QVector viewschedulewidget::getAllScheduleInfo() +{ + //查询到的一天的日程 + ScheduleDateRangeInfo showdate; + //查询到的所有日程 + QVector showDate; + //判断查询到的日程是否有重复的 + QVector allScheduleInfo; + + for (int i = 0; i < m_scheduleDateInfo.count(); i++) { + for (int j = 0; j < m_scheduleDateInfo.at(i).vData.count(); j++) { + if (!(m_scheduleDateInfo[i].vData[j].type.ID == 4 || allScheduleInfo.contains(m_scheduleDateInfo[i].vData[j]))) { + //不是节假日并且allScheduleInfo中没有该日程 + allScheduleInfo.append(m_scheduleDateInfo.at(i).vData.at(j)); + showdate.vData.append(m_scheduleDateInfo.at(i).vData.at(j)); + } + } + if (showdate.vData.count() > 0) { + showDate.append(showdate); + } + showdate.vData.clear(); + } + + for (int i = 0; i < showDate.count(); i++) { + for (int j = 0; j < showDate.count() - i - 1; j++) { + if (showDate[j].date > showDate[j + 1].date) + std::swap(showDate[j], showDate[j + 1]); + } + } + return showDate; +} diff -Nru dde-calendar-5.7.0.4/schedule-plugin/src/widget/viewschedulewidget.h dde-calendar-5.7.0.23/schedule-plugin/src/widget/viewschedulewidget.h --- dde-calendar-5.7.0.4/schedule-plugin/src/widget/viewschedulewidget.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/schedule-plugin/src/widget/viewschedulewidget.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,44 @@ +#ifndef VIEWSCHEDULEWIDGET_H +#define VIEWSCHEDULEWIDGET_H + +#include +#include "icondframe.h" +#include "../data/schedulestructs.h" +#include "scheduleitemwidget.h" + +class viewschedulewidget : public IconDFrame +{ + Q_OBJECT +public: + explicit viewschedulewidget(QWidget *parent = nullptr); + ~viewschedulewidget(); + void setScheduleDateRangeInfo(QVector &scheduleDateInfo); + void viewScheduleInfoShow(QVector m_showdate); + int getScheduleNum(QVector m_showdate); + void setQueryBeginDateTime(QDateTime begindatetime); + void setQueryEndDateTime(QDateTime enddatetime); + + QVector queryScheduleWithTime(QVector &scheduleinfo, QTime beginT, QTime endT); + QVector queryScheduleWithDate(QVector &scheduleinfo, QDate beginD, QDate endD); + QVector queryScheduleWithWeek(QVector &scheduleinfo, QVector weekDay, int dayofweek = 0, QTime beginT = QTime(0, 0, 0), QTime endT = QTime(0, 0, 0)); + QVector queryScheduleWithMonth(QVector &scheduleinfo, QVector monthDay, int dayofmonth = 0, QTime beginT = QTime(0, 0, 0), QTime endT = QTime(0, 0, 0)); + + QVector getAllScheduleInfo(); + QVector getAllRpeatScheduleInfo(int rpeat); + /** + * @brief getNextScheduleInfo 获取下一个日程 + * @return 下一个日程信息 + */ + QVector getNextScheduleInfo(); +public slots: + void slotItemPress(const ScheduleDtailInfo &info); + +private: + QVector m_scheduleInfo; + QVector m_scheduleDateInfo; + QVector m_showdate; + QDateTime m_beginDateTime; + QDateTime m_endDateTime; +}; + +#endif // QUERYSCHEDULEWIDGET_H diff -Nru dde-calendar-5.7.0.4/src/accessible/accessibledefine.h dde-calendar-5.7.0.23/src/accessible/accessibledefine.h --- dde-calendar-5.7.0.4/src/accessible/accessibledefine.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/accessible/accessibledefine.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,365 @@ +#ifndef ACCESSIBLEDEFINE_H +#define ACCESSIBLEDEFINE_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SEPARATOR "_" + +inline QString getAccessibleName(QWidget *w, QAccessible::Role r, const QString &fallback) +{ + const QString lowerFallback = fallback.toLower(); + // 避免重复生成 + static QMap objnameMap; + if (!objnameMap[w].isEmpty()) + return objnameMap[w]; + + static QMap> accessibleMap; + QString oldAccessName = w->accessibleName().toLower(); + oldAccessName.replace(SEPARATOR, ""); + + // 按照类型添加固定前缀 + QMetaEnum metaEnum = QMetaEnum::fromType(); + QByteArray prefix = metaEnum.valueToKeys(r); + switch (r) { + case QAccessible::Form: + prefix = "Form"; + break; + case QAccessible::Button: + prefix = "Btn"; + break; + case QAccessible::StaticText: + prefix = "Label"; + break; + case QAccessible::EditableText: + prefix = "Editable"; + break; + case QAccessible::Slider: + prefix = "Slider"; + break; + default: + break; + } + + // 再加上标识 + QString accessibleName = QString::fromLatin1(prefix) + SEPARATOR; + accessibleName += oldAccessName.isEmpty() ? lowerFallback : oldAccessName; + // 检查名称是否唯一 + if (accessibleMap[r].contains(accessibleName)) { + // 获取编号,然后+1 + int pos = accessibleName.indexOf(SEPARATOR); + int id = accessibleName.mid(pos + 1).toInt(); + + QString newAccessibleName; + do { + // 一直找到一个不重复的名字 + newAccessibleName = accessibleName + SEPARATOR + QString::number(++id); + } while (accessibleMap[r].contains(newAccessibleName)); + + accessibleMap[r].append(newAccessibleName); + objnameMap.insert(w, newAccessibleName); + + QObject::connect(w, &QWidget::destroyed, [=](QObject *obj) { // 对象销毁后移除占用名称 + objnameMap.remove(obj); + accessibleMap[r].removeOne(newAccessibleName); + }); + return newAccessibleName; + } else { + accessibleMap[r].append(accessibleName); + objnameMap.insert(w, accessibleName); + + QObject::connect(w, &QWidget::destroyed, [=](QObject *obj) { // 对象销毁后移除占用名称 + objnameMap.remove(obj); + accessibleMap[r].removeOne(accessibleName); + }); + return accessibleName; + } +} + +// 公共的功能 +#define FUNC_CREATE(classname, accessibletype, accessdescription) \ + explicit Accessible##classname(classname *w) \ + : QAccessibleWidget(w, accessibletype, #classname) \ + , m_w(w) \ + , m_description(accessdescription) \ + { \ + } + +#define FUNC_TEXT(classname, accessiblename) \ + QString Accessible##classname::text(QAccessible::Text t) const \ + { \ + switch (t) { \ + case QAccessible::Name: \ + return getAccessibleName(m_w, this->role(), accessiblename); \ + case QAccessible::Description: \ + return m_description; \ + default: \ + return QString(); \ + } \ + } + +// button控件特有功能 +#define FUNC_ACTIONNAMES(classname) \ + QStringList Accessible##classname::actionNames() const \ + { \ + if (!m_w->isEnabled()) \ + return QStringList(); \ + return QStringList() << pressAction() << showMenuAction(); \ + } + +#define FUNC_DOACTION(classname) \ + void Accessible##classname::doAction(const QString &actionName) \ + { \ + if (actionName == pressAction()) { \ + QPointF localPos = m_w->geometry().center(); \ + QMouseEvent event(QEvent::MouseButtonPress, localPos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); \ + qApp->sendEvent(m_w, &event); \ + } else if (actionName == showMenuAction()) { \ + QPointF localPos = m_w->geometry().center(); \ + QMouseEvent event(QEvent::MouseButtonPress, localPos, Qt::RightButton, Qt::RightButton, Qt::NoModifier); \ + qApp->sendEvent(m_w, &event); \ + } \ + } + +// Label控件特有功能 +#define FUNC_TEXT_(classname) \ + QString Accessible##classname::text(int startOffset, int endOffset) const \ + { \ + Q_UNUSED(startOffset) \ + Q_UNUSED(endOffset) \ + return m_w->text(); \ + } + +// Slider控件特有功能 +#define FUNC_CURRENTVALUE(classname) \ + QVariant Accessible##classname::currentValue() const \ + { \ + return m_w->value(); \ + } + +#define FUNC_SETCURRENTVALUE(classname) \ + void Accessible##classname::setCurrentValue(const QVariant &value) \ + { \ + return m_w->setValue(value.toInt()); \ + } + +#define FUNC_MAXMUMVALUE(classname) \ + QVariant Accessible##classname::maximumValue() const \ + { \ + return QVariant(m_w->maximum()); \ + } + +#define FUNC_FUNC_MINIMUMVALUE(classname) \ + QVariant Accessible##classname::minimumValue() const \ + { \ + return QVariant(m_w->minimum()); \ + } + +#define FUNC_FUNC_MINIMUMSTEPSIZE(classname) \ + QVariant Accessible##classname::minimumStepSize() const \ + { \ + return QVariant(m_w->singleStep()); \ + } + +#define SET_FORM_ACCESSIBLE_WITH_DESCRIPTION(classname, accessiblename, accessdescription) \ + class Accessible##classname : public QAccessibleWidget \ + { \ + public: \ + FUNC_CREATE(classname, QAccessible::Form, accessdescription) \ + QString text(QAccessible::Text t) const override; \ + void *interface_cast(QAccessible::InterfaceType t) override \ + { \ + switch (t) { \ + case QAccessible::ActionInterface: \ + return static_cast(this); \ + default: \ + return nullptr; \ + } \ + } \ +\ + private: \ + classname *m_w; \ + QString m_description; \ + }; \ + FUNC_TEXT(classname, accessiblename) + +#define SET_BUTTON_ACCESSIBLE_WITH_DESCRIPTION(classname, accessiblename, accessdescription) \ + class Accessible##classname : public QAccessibleWidget \ + { \ + public: \ + FUNC_CREATE(classname, QAccessible::Button, accessdescription) \ + QString text(QAccessible::Text t) const override; \ + void *interface_cast(QAccessible::InterfaceType t) override \ + { \ + switch (t) { \ + case QAccessible::ActionInterface: \ + return static_cast(this); \ + default: \ + return nullptr; \ + } \ + } \ + QStringList actionNames() const override; \ + void doAction(const QString &actionName) override; \ +\ + private: \ + classname *m_w; \ + QString m_description; \ + }; \ + FUNC_TEXT(classname, accessiblename) \ + FUNC_ACTIONNAMES(classname) \ + FUNC_DOACTION(classname) + +#define SET_LABEL_ACCESSIBLE_WITH_DESCRIPTION(classname, accessiblename, accessdescription) \ + class Accessible##classname : public QAccessibleWidget \ + , public QAccessibleTextInterface \ + { \ + public: \ + FUNC_CREATE(classname, QAccessible::StaticText, accessdescription) \ + QString text(QAccessible::Text t) const override; \ + void *interface_cast(QAccessible::InterfaceType t) override \ + { \ + switch (t) { \ + case QAccessible::ActionInterface: \ + return static_cast(this); \ + case QAccessible::TextInterface: \ + return static_cast(this); \ + default: \ + return nullptr; \ + } \ + } \ + QString text(int startOffset, int endOffset) const override; \ + void selection(int selectionIndex, int *startOffset, int *endOffset) const override {} \ + int selectionCount() const override { return 0; } \ + void addSelection(int startOffset, int endOffset) override {} \ + void removeSelection(int selectionIndex) override {} \ + void setSelection(int selectionIndex, int startOffset, int endOffset) override {} \ + int cursorPosition() const override { return 0; } \ + void setCursorPosition(int position) override {} \ + int characterCount() const override { return 0; } \ + QRect characterRect(int offset) const override { return QRect(); } \ + int offsetAtPoint(const QPoint &point) const override { return 0; } \ + void scrollToSubstring(int startIndex, int endIndex) override {} \ + QString attributes(int offset, int *startOffset, int *endOffset) const override { return QString(); } \ +\ + private: \ + classname *m_w; \ + QString m_description; \ + }; \ + FUNC_TEXT(classname, accessiblename) \ + FUNC_TEXT_(classname) + +#define SET_SLIDER_ACCESSIBLE_WITH_DESCRIPTION(classname, accessiblename, accessdescription) \ + class Accessible##classname : public QAccessibleWidget \ + , public QAccessibleValueInterface \ + { \ + public: \ + FUNC_CREATE(classname, QAccessible::Slider, accessdescription) \ + QString text(QAccessible::Text t) const override; \ + void *interface_cast(QAccessible::InterfaceType t) override \ + { \ + switch (t) { \ + case QAccessible::ActionInterface: \ + return static_cast(this); \ + case QAccessible::ValueInterface: \ + return static_cast(this); \ + default: \ + return nullptr; \ + } \ + } \ + QVariant currentValue() const override; \ + void setCurrentValue(const QVariant &value) override; \ + QVariant maximumValue() const override; \ + QVariant minimumValue() const override; \ + QVariant minimumStepSize() const override; \ +\ + private: \ + classname *m_w; \ + QString m_description; \ + }; \ + FUNC_TEXT(classname, accessiblename) \ + FUNC_CURRENTVALUE(classname) \ + FUNC_SETCURRENTVALUE(classname) \ + FUNC_MAXMUMVALUE(classname) \ + FUNC_FUNC_MINIMUMVALUE(classname) \ + FUNC_FUNC_MINIMUMSTEPSIZE(classname) + +#define SET_EDITABLE_ACCESSIBLE_WITH_DESCRIPTION(classname, accessiblename, accessdescription) \ + class Accessible##classname : public QAccessibleWidget \ + , public QAccessibleEditableTextInterface \ + , public QAccessibleTextInterface \ + { \ + public: \ + FUNC_CREATE(classname, QAccessible::EditableText, accessdescription) \ + QString text(QAccessible::Text t) const override; \ + QAccessibleInterface *child(int index) const override { return nullptr; } \ + void *interface_cast(QAccessible::InterfaceType t) override \ + { \ + switch (t) { \ + case QAccessible::ActionInterface: \ + return static_cast(this); \ + case QAccessible::TextInterface: \ + return static_cast(this); \ + case QAccessible::EditableTextInterface: \ + return static_cast(this); \ + default: \ + return nullptr; \ + } \ + } \ + QString text(int startOffset, int endOffset) const override; \ + void selection(int selectionIndex, int *startOffset, int *endOffset) const override {} \ + int selectionCount() const override { return 0; } \ + void addSelection(int startOffset, int endOffset) override {} \ + void removeSelection(int selectionIndex) override {} \ + void setSelection(int selectionIndex, int startOffset, int endOffset) override {} \ + int cursorPosition() const override { return 0; } \ + void setCursorPosition(int position) override {} \ + int characterCount() const override { return 0; } \ + QRect characterRect(int offset) const override { return QRect(); } \ + int offsetAtPoint(const QPoint &point) const override { return 0; } \ + void scrollToSubstring(int startIndex, int endIndex) override {} \ + QString attributes(int offset, int *startOffset, int *endOffset) const override { return QString(); } \ + void insertText(int offset, const QString &text) override {} \ + void deleteText(int startOffset, int endOffset) override {}; \ + void replaceText(int startOffset, int endOffset, const QString &text) override {} \ +\ + private: \ + classname *m_w; \ + QString m_description; \ + }; \ + FUNC_TEXT(classname, accessiblename) \ + FUNC_TEXT_(classname) + +#define USE_ACCESSIBLE(classnamestring, classname) \ + if (classnamestring == QLatin1String(#classname) && object && object->isWidgetType()) { \ + interface = new Accessible##classname(static_cast(object)); \ + } + +// [指定objectname]---适用同一个类,但objectname不同的情况 +#define USE_ACCESSIBLE_BY_OBJECTNAME(classnamestring, classname, objectname) \ + if (classnamestring == QLatin1String(#classname) && object && (object->objectName() == objectname) && object->isWidgetType()) { \ + interface = new Accessible##classname(static_cast(object)); \ + } + +/*******************************************简化使用*******************************************/ +#define SET_FORM_ACCESSIBLE(classname, accessiblename) SET_FORM_ACCESSIBLE_WITH_DESCRIPTION(classname, accessiblename, "") + +#define SET_BUTTON_ACCESSIBLE(classname, accessiblename) SET_BUTTON_ACCESSIBLE_WITH_DESCRIPTION(classname, accessiblename, "") + +#define SET_LABEL_ACCESSIBLE(classname, accessiblename) SET_LABEL_ACCESSIBLE_WITH_DESCRIPTION(classname, accessiblename, "") + +#define SET_SLIDER_ACCESSIBLE(classname, accessiblename) SET_SLIDER_ACCESSIBLE_WITH_DESCRIPTION(classname, accessiblename, "") + +#define SET_EDITABLE_ACCESSIBLE(classname, accessiblename) SET_EDITABLE_ACCESSIBLE_WITH_DESCRIPTION(classname, accessiblename, "") + +#define SET_PROGRESSBAR_ACCESSIBLE(classname, accessiblename) SET_PROGRESSBAR_ACCESSIBLE_WITH_DESCRIPTION(classname, accessiblename, "") +/************************************************************************************************/ + +#endif // ACCESSIBLEDEFINE_H diff -Nru dde-calendar-5.7.0.4/src/accessible/accessible.h dde-calendar-5.7.0.23/src/accessible/accessible.h --- dde-calendar-5.7.0.4/src/accessible/accessible.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/accessible/accessible.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,119 @@ +#ifndef ACCESSIBLE_H +#define ACCESSIBLE_H + +#include "accessibledefine.h" + +#include "../widget/yearWidget/yearwindow.h" +#include "../widget/monthWidget/monthwindow.h" +#include "../widget/weekWidget/weekwindow.h" +#include "../widget/dayWidget/daywindow.h" +#include "../customWidget/SchecduleRemindWidget.h" +#include "../view/alldayeventview.h" +#include "../view/monthgraphiview.h" +#include "../view/graphicsview.h" +#include "../customWidget/customframe.h" +#include "../customWidget/animationstackedwidget.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +DWIDGET_USE_NAMESPACE +//using namespace DCC_NAMESPACE; + +SET_FORM_ACCESSIBLE(CYearWindow,"YearWidget"); +SET_FORM_ACCESSIBLE(CMonthWindow,"MonthWidget"); +SET_FORM_ACCESSIBLE(CWeekWindow,"WeekWidget"); +SET_FORM_ACCESSIBLE(CDayWindow,"DayWidget"); +SET_FORM_ACCESSIBLE(SchecduleRemindWidget,"ScheduleRemindWidget"); +SET_FORM_ACCESSIBLE(CAllDayEventWeekView,"AllDayGraphiview"); +SET_FORM_ACCESSIBLE(CMonthGraphiview,"MonthGraphiview"); +SET_FORM_ACCESSIBLE(CGraphicsView,"PartTimeGraphiview"); +SET_FORM_ACCESSIBLE(CustomFrame,"CustomFrame"); +SET_FORM_ACCESSIBLE(AnimationStackedWidget,"AnimationStackedWidget"); + +// Qt控件 +SET_FORM_ACCESSIBLE(QFrame, m_w->objectName().isEmpty() ? "frame" : m_w->objectName()) +SET_FORM_ACCESSIBLE(QWidget, m_w->objectName().isEmpty() ? "widget" : m_w->objectName()) +SET_BUTTON_ACCESSIBLE(QPushButton, m_w->text().isEmpty() ? "qpushbutton" : m_w->text()) +SET_SLIDER_ACCESSIBLE(QSlider, "qslider") +SET_FORM_ACCESSIBLE(QMenu, "qmenu") +//SET_LABEL_ACCESSIBLE(QLabel, m_w->text().isEmpty() ? "qlabel" : m_w->text()) + +// Dtk控件 +SET_FORM_ACCESSIBLE(DFrame, m_w->objectName().isEmpty() ? "frame" : m_w->objectName()) +SET_FORM_ACCESSIBLE(DWidget, m_w->objectName().isEmpty() ? "widget" : m_w->objectName()) +SET_FORM_ACCESSIBLE(DBackgroundGroup, m_w->objectName().isEmpty() ? "dbackgroundgroup" : m_w->objectName()) +SET_BUTTON_ACCESSIBLE(DSwitchButton, m_w->text().isEmpty() ? "switchbutton" : m_w->text()) +SET_BUTTON_ACCESSIBLE(DFloatingButton, m_w->toolTip().isEmpty() ? "DFloatingButton" : m_w->toolTip()) +SET_FORM_ACCESSIBLE(DSearchEdit, m_w->objectName().isEmpty() ? "DSearchEdit" : m_w->objectName()) +SET_BUTTON_ACCESSIBLE(DPushButton, m_w->objectName().isEmpty() ? "DPushButton" : m_w->objectName()) +SET_BUTTON_ACCESSIBLE(DIconButton, m_w->objectName().isEmpty() ? "DIconButton" : m_w->objectName()) +SET_BUTTON_ACCESSIBLE(DCheckBox, m_w->objectName().isEmpty() ? "DCheckBox" : m_w->objectName()) +SET_BUTTON_ACCESSIBLE(DCommandLinkButton, "DCommandLinkButton") +SET_FORM_ACCESSIBLE(DTitlebar, m_w->objectName().isEmpty() ? "DTitlebar" : m_w->objectName()) +//SET_LABEL_ACCESSIBLE(DLabel, m_w->text().isEmpty() ? "DLabel" : m_w->text()) +SET_BUTTON_ACCESSIBLE(DToolButton, m_w->objectName().isEmpty() ? "DToolButton" : m_w->objectName()) +SET_FORM_ACCESSIBLE(DDialog, m_w->objectName().isEmpty() ? "DDialog" : m_w->objectName()) +SET_FORM_ACCESSIBLE(DFileDialog, m_w->objectName().isEmpty() ? "DFileDialog" : m_w->objectName()) + +QAccessibleInterface *accessibleFactory(const QString &classname, QObject *object) +{ + QAccessibleInterface *interface = nullptr; + + USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""),CYearWindow); + USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""),CMonthWindow); + USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""),CWeekWindow); + USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""),CDayWindow); + USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""),SchecduleRemindWidget); + USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""),CAllDayEventWeekView); + USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""),CMonthGraphiview); + USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""),CGraphicsView); + USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""),CustomFrame); + USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""),AnimationStackedWidget); + +// Qt 控件 + USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""), QFrame); + USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""), QWidget); + USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""), QPushButton); + USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""), QSlider); + USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""), QMenu); + // USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""), QLabel); + + // dtk 控件 + USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""), DFrame); + USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""), DWidget); + USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""), DBackgroundGroup); + USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""), DSwitchButton); + USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""), DFloatingButton); + USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""), DSearchEdit); + USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""), DPushButton); + USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""), DIconButton); + USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""), DCheckBox); + USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""), DCommandLinkButton); + USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""), DTitlebar); + // USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""), DLabel); + USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""), DDialog); + USE_ACCESSIBLE(QString(classname).replace("dccV20::", ""), DFileDialog); + + return interface; +} + +#endif // ACCESSIBLE_H diff -Nru dde-calendar-5.7.0.4/src/alldayeventview.cpp dde-calendar-5.7.0.23/src/alldayeventview.cpp --- dde-calendar-5.7.0.4/src/alldayeventview.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/alldayeventview.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,556 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#include "alldayeventview.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "schceduledlg.h" -#include "myschceduleview.h" -#include "scheduledatamanage.h" -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include "schedulecoormanage.h" -#include "schcedulectrldlg.h" - -DGUI_USE_NAMESPACE - -CAllDayEventWidgetItem::CAllDayEventWidgetItem(QRectF rect, QGraphicsItem *parent /*= nullptr*/, int edittype) - : DragInfoItem (rect,parent) -{ - Q_UNUSED(edittype); - -} - -bool CAllDayEventWidgetItem::hasSelectSchedule(const ScheduleDtailInfo &info) -{ - return info == m_vScheduleInfo; -} - -void CAllDayEventWidgetItem::paintBackground(QPainter *painter, const QRectF &rect, const int isPixMap) -{ - Q_UNUSED(isPixMap); - m_font = DFontSizeManager::instance()->get(m_sizeType, m_font); - painter->setRenderHints(QPainter::Antialiasing); - CSchedulesColor gdcolor = CScheduleDataManage::getScheduleDataManage()->getScheduleColorByType(m_vScheduleInfo.type.ID); - QRectF drawrect = rect; - QLinearGradient linearGradient(drawrect.topLeft().x(), 0, drawrect.topRight().x(), 0); - - QColor color1 = gdcolor.gradientFromC; - QColor color2 = gdcolor.gradientToC; - QColor textcolor = gdcolor.textColor; - - m_vHighflag = CScheduleDataManage::getScheduleDataManage()->getSearchResult(m_vScheduleInfo); - - if (CScheduleDataManage::getScheduleDataManage()->getPressSelectInfo() == m_vScheduleInfo ) { - if (m_vScheduleInfo.IsMoveInfo == - CScheduleDataManage::getScheduleDataManage()->getPressSelectInfo().IsMoveInfo) { - m_vHighflag = true; - } else { - painter->setOpacity(0.4); - textcolor.setAlphaF(0.4); - } - m_vSelectflag = m_press; - } - int themetype = CScheduleDataManage::getScheduleDataManage()->getTheme(); - - if (m_vHoverflag) { - color1 = gdcolor.hovergradientFromC; - color2 = gdcolor.hovergradientToC; - } else if (m_vHighflag) { - color1 = gdcolor.hightlightgradientFromC; - color2 = gdcolor.hightlightgradientToC; - } - if (m_vSelectflag) { - color1 = gdcolor.pressgradientFromC; - color2 = gdcolor.pressgradientToC; - textcolor.setAlphaF(0.4); - } - linearGradient.setColorAt(0, color1); - linearGradient.setColorAt(1, color2); - QRectF fillRect = drawrect; - //将直线开始点设为0,终点设为1,然后分段设置颜色 - painter->setBrush(linearGradient); - painter->setPen(Qt::NoPen); - painter->drawRoundedRect(fillRect, 8, 8); - - painter->setFont(m_font); - painter->setPen(textcolor); - QFontMetrics fm = painter->fontMetrics(); - QString tStitlename = m_vScheduleInfo.titleName; - tStitlename.replace("\n", ""); - QString str = tStitlename; - - QString tstr; - for (int i = 0; i < str.count(); i++) { - tstr.append(str.at(i)); - int widthT = fm.width(tstr) + 5; - if (widthT >= fillRect.width() - 13) { - tstr.chop(2); - break; - } - } - if (tstr != str) { - tstr = tstr + "..."; - } - - painter->drawText(QRectF(fillRect.topLeft().x() + 13, fillRect.y(), fillRect.width(), fillRect.height()), - Qt::AlignLeft | Qt::AlignVCenter, tstr); - if (m_vHoverflag && !m_vSelectflag) { - QRectF trect = QRectF(fillRect.x() + 0.5, fillRect.y() + 0.5, fillRect.width() - 1, fillRect.height() - 1); - painter->save(); - - QPen pen; - QColor selcolor; - - if (themetype == 2) { - selcolor = "#FFFFFF"; - } else { - selcolor = "#000000"; - } - selcolor.setAlphaF(0.08); - - pen.setColor(selcolor); - pen.setWidthF(1); - pen.setStyle(Qt::SolidLine); - painter->setBrush(Qt::NoBrush); - painter->setPen(pen); - painter->drawRoundedRect(trect, 8, 8); - painter->restore(); - } - if (m_vSelectflag) { - QColor selcolor = "#000000"; - selcolor.setAlphaF(0.05); - painter->setBrush(selcolor); - painter->setPen(Qt::NoPen); - painter->drawRoundedRect(fillRect, 8, 8); - } -} - - - - -void CAllDayEventWeekView::setTheMe(int type) -{ - m_themetype=type; - updateDateShow(); -} - -bool CAllDayEventWeekView::MeetCreationConditions(const QDateTime &date) -{ - return qAbs(date.daysTo(m_PressDate)<7); -} - -void CAllDayEventWeekView::slotCreate(const QDateTime &date) -{ - emit signalViewtransparentFrame(1); - CSchceduleDlg dlg(1, this); - dlg.setDate(date); - dlg.setAllDay(true); - if (dlg.exec() == DDialog::Accepted) { - emit signalsUpdateShcedule(); - } - emit signalViewtransparentFrame(0); -} - -bool CAllDayEventWeekView::IsEqualtime(const QDateTime &timeFirst, const QDateTime &timeSecond) -{ - return timeFirst.date() == timeSecond.date(); -} - -bool CAllDayEventWeekView::JudgeIsCreate(const QPointF &pos) -{ - return qAbs(pos.x()-m_PressPos.x())>20 || - qAbs(m_PressDate.date().daysTo(m_coorManage->getsDate(mapFrom(this,pos.toPoint()))))>0; - -} - -void CAllDayEventWeekView::RightClickToCreate(QGraphicsItem *listItem, const QPoint &pos) -{ - Q_UNUSED(listItem); - m_rightMenu->clear(); - m_rightMenu->addAction(m_createAction); - - m_createDate.setDate(m_coorManage->getsDate(mapFrom(this, pos))); - m_createDate.setTime(QTime::currentTime()); - m_rightMenu->exec(QCursor::pos()); - -} - -void CAllDayEventWeekView::MoveInfoProcess(ScheduleDtailInfo &info, const QPointF &pos) -{ - Q_UNUSED(pos); - if (info.allday) { - qint64 offset = m_PressDate.daysTo(m_MoveDate); - info.beginDateTime = info.beginDateTime.addDays(offset); - info.endDateTime = info.endDateTime.addDays(offset); - } else { - qint64 offset = info.beginDateTime.daysTo(info.endDateTime); - info.allday = true; - info.remind = true; - info.remindData.time = QTime(9, 0); - info.remindData.n = 1; - m_DragScheduleInfo.beginDateTime = QDateTime(m_MoveDate.date(),QTime(0,0,0)); - m_DragScheduleInfo.endDateTime = QDateTime(m_MoveDate.addDays(offset).date(),QTime(23,59,59)); - } - info.IsMoveInfo = true; - upDateInfoShow(ChangeWhole,info); -} - -QDateTime CAllDayEventWeekView::getDragScheduleInfoBeginTime(const QDateTime &moveDateTime) -{ - return moveDateTime.daysTo(m_InfoEndTime)<0 ? - QDateTime(m_InfoEndTime.date(),QTime(0,0,0)): - QDateTime(moveDateTime.date(),QTime(0,0,0)); -} - -QDateTime CAllDayEventWeekView::getDragScheduleInfoEndTime(const QDateTime &moveDateTime) -{ - return m_InfoBeginTime.daysTo(m_MoveDate)<0? - QDateTime(m_InfoBeginTime.date(),QTime(23,59,0)): - QDateTime(moveDateTime.date(),QTime(23,59,0)); -} - -void CAllDayEventWeekView::setRange(int w, int h, QDate begindate, QDate enddate, int rightmagin) -{ - m_MoveDate.setDate(begindate.addMonths(-2)); - m_beginDate = begindate; - m_endDate = enddate; - w -=2; - m_coorManage->setRange(w, h, begindate, enddate, rightmagin); - m_Scene->setSceneRect(0, 0, w, h); - m_rightmagin = rightmagin; - updateDateShow(); - -} - -void CAllDayEventWeekView::setRange(QDate begin, QDate end) -{ - m_MoveDate.setDate(begin.addMonths(-2)); - m_beginDate = begin; - m_endDate = end; - getCoorManage()->setDateRange(begin, end); -} - -void CAllDayEventWeekView::updateHigh() -{ - for (int i = 0; i < m_baseShowItem.count(); i++) { - m_baseShowItem.at(i)->update(); - } -} - -void CAllDayEventWeekView::setSelectSchedule(const ScheduleDtailInfo &info) -{ - for (int i = 0; i < m_baseShowItem.size(); ++i) { - CAllDayEventWidgetItem *item = m_baseShowItem.at(i); - if (item->hasSelectSchedule(info)) { - QRectF rect = item->rect(); - centerOn(0, rect.y()); - setTransformationAnchor(QGraphicsView::AnchorViewCenter); - item->setStartValue(0); - item->setEndValue(4); - item->startAnimation(); - } - } -} - -void CAllDayEventWeekView::setMargins(int left, int top, int right, int bottom) -{ - setViewportMargins(QMargins(left, top, right, bottom)); -} - -void CAllDayEventWeekView::updateInfo() -{ - switch (m_DragStatus) { - case IsCreate: - upDateInfoShow(IsCreate,m_DragScheduleInfo); - break; - default: - upDateInfoShow(); - break; - } -} - -void CAllDayEventWeekView::upDateInfoShow(const DragStatus &status, const ScheduleDtailInfo &info) -{ - QVector vListData; - vListData = m_scheduleInfo; - switch (status) { - case NONE: - Q_UNUSED(info); - break; - case ChangeBegin: - case ChangeEnd: { - int index = vListData.indexOf(info); - if (index >=0) - vListData[index] = info; - } - break; - case ChangeWhole: - vListData.append(info); - break; - case IsCreate: - vListData.append(info); - break; - } - - - std::sort(vListData.begin(), vListData.end()); -// qSort(vListData.begin(), vListData.end()); - - QVector vMDaySchedule; - for (int i = 0; i < vListData.count(); i++) { - QDate tbegindate = vListData.at(i).beginDateTime.date(); - QDate tenddate = vListData.at(i).endDateTime.date(); - if (tbegindate < m_beginDate) - tbegindate = m_beginDate; - if (tenddate > m_endDate) - tenddate = m_endDate; - MScheduleDateRangeInfo sinfo; - sinfo.bdate = tbegindate; - sinfo.edate = tenddate; - sinfo.tData = vListData.at(i); - sinfo.state = false; - vMDaySchedule.append(sinfo); - } - QVector > vCfillSchedule; - vCfillSchedule.resize(vListData.count()); - int tNum = static_cast(m_beginDate.daysTo(m_endDate) + 1); - for (int i = 0; i < vListData.count(); i++) { - vCfillSchedule[i].resize(tNum); - vCfillSchedule[i].fill(-1); - } - //首先填充跨天日程 - for (int i = 0; i < vMDaySchedule.count(); i++) { - if (vMDaySchedule[i].state) - continue; - int bindex = static_cast(m_beginDate.daysTo(vMDaySchedule[i].bdate)); - int eindex = static_cast(m_beginDate.daysTo(vMDaySchedule[i].edate)); - int c = -1; - for (int k = 0; k < vListData.count(); k++) { - int t = 0; - for (t = bindex; t <= eindex; t++) { - if (vCfillSchedule[k][t] != -1) { - break; - } - } - if (t == eindex + 1) { - c = k; - break; - } - } - if (c == -1) - continue; - - bool flag = false; - for (int sd = bindex; sd <= eindex; sd++) { - if (vCfillSchedule[c][sd] != -1) - continue; - vCfillSchedule[c][sd] = i; - flag = true; - } - if (flag) - vMDaySchedule[i].state = true; - } - QVector > vResultData; - for (int i = 0; i < vListData.count(); i++) { - QVector vId; - for (int j = 0; j < tNum; j++) { - if (vCfillSchedule[i][j] != -1) { - int k = 0; - for (; k < vId.count(); k++) { - if (vId[k] == vCfillSchedule[i][j]) - break; - } - if (k == vId.count()) - vId.append(vCfillSchedule[i][j]); - } - } - QVector tData; - for (int j = 0; j < vId.count(); j++) { - tData.append(vMDaySchedule[vId[j]].tData); - } - if (!tData.isEmpty()) - vResultData.append(tData); - } - - int m_topMagin; - if (vResultData.count() < 2) { - m_topMagin = 31; - } else if (vResultData.count() < 6) { - m_topMagin = 31 + (vResultData.count() - 1) * (itemHeight+1); - - } else { - m_topMagin = 123; - } - setFixedHeight(m_topMagin - 3); - setDayData(vResultData); - update(); - emit signalUpdatePaint(m_topMagin); -// return m_topMagin; -} - -CAllDayEventWeekView::CAllDayEventWeekView(QWidget *parent, int edittype) - : DragInfoGraphicsView (parent) -{ - m_editType = edittype; - - m_coorManage = new CScheduleCoorManage; -} - -CAllDayEventWeekView::~CAllDayEventWeekView() -{ - delete m_coorManage; - m_coorManage = nullptr; -} - -void CAllDayEventWeekView::setDayData(const QVector > &vlistData) -{ - m_vlistData = vlistData; - updateDateShow(); -} - -void CAllDayEventWeekView::setInfo(const QVector &info) -{ - m_scheduleInfo = info; - -} - -void CAllDayEventWeekView::slotDoubleEvent() -{ - m_updateDflag = true; - emit signalsUpdateShcedule(); -} - - -void CAllDayEventWeekView::mouseDoubleClickEvent(QMouseEvent *event) -{ - if (event->button() == Qt::RightButton) { - return; - } - emit signalScheduleShow(false); - DGraphicsView::mouseDoubleClickEvent(event); - CAllDayEventWidgetItem *item = dynamic_cast(itemAt(event->pos())); - if (item == nullptr) { - m_createDate.setDate(m_coorManage->getsDate(mapFrom(this, event->pos()))); - m_createDate.setTime(QTime::currentTime()); - slotCreate(m_createDate); - } else { - emit signalViewtransparentFrame(1); - m_updateDflag = false; - CMySchceduleView dlg(item->getData(), this); - connect(&dlg, &CMySchceduleView::signalsEditorDelete, this, &CAllDayEventWeekView::slotDoubleEvent); - dlg.exec(); - emit signalViewtransparentFrame(0); - disconnect(&dlg, &CMySchceduleView::signalsEditorDelete, this, &CAllDayEventWeekView::slotDoubleEvent); - if (item == nullptr) { - return; - } - } -} - -void CAllDayEventWeekView::wheelEvent(QWheelEvent *event) -{ - emit signalScheduleShow(false); - DGraphicsView::wheelEvent(event); -} - - -void CAllDayEventWeekView::updateDateShow() -{ - m_Scene->setSceneRect(0, - 0, - m_Scene->width(), - (itemHeight + 1)*m_vlistData.size()); - - for (int i = 0; i < m_baseShowItem.count(); i++) { - delete m_baseShowItem[i]; - } - m_baseShowItem.clear(); - for (int i = 0; i < m_vlistData.size(); ++i) { - createItemWidget(i); - } -} - -void CAllDayEventWeekView::createItemWidget(int index, bool average) -{ - Q_UNUSED(average) - for (int i = 0; i < m_vlistData[index].size(); ++i) { - const ScheduleDtailInfo &info = m_vlistData[index].at(i); - QRectF drawrect = m_coorManage->getAllDayDrawRegion(info.beginDateTime.date(), info.endDateTime.date()); - drawrect.setY(3 + (itemHeight + 1)*index); - drawrect.setHeight(itemHeight); - - CAllDayEventWidgetItem *gwi = new CAllDayEventWidgetItem(drawrect, nullptr, m_editType); - gwi->setData(m_vlistData[index].at(i)); - m_Scene->addItem(gwi); - m_baseShowItem.append(gwi); - } -} - - -CAllDayEventWeekView::PosInItem CAllDayEventWeekView::getPosInItem(const QPoint &p, const QRectF &itemRect) -{ - QPointF scenePos = this->mapToScene(p); - QPointF itemPos = QPointF(scenePos.x()-itemRect.x(), - scenePos.y()-itemRect.y()); - double bottomy = itemRect.width()- itemPos.x(); - if (itemPos.x()<5) { - return LEFT; - } - if (bottomy <5) { - return RIGHT; - } - return MIDDLE; -} - -QDateTime CAllDayEventWeekView::getPosDate(const QPoint &p) -{ - return QDateTime(m_coorManage->getsDate(mapFrom(this, p)), - QTime(0,0,0)); -} - - -void CAllDayEventWeekView::slotDeleteItem() -{ - if (CScheduleDataManage::getScheduleDataManage()->getPressSelectInfo().type.ID <0) { - return; - } - if (CScheduleDataManage::getScheduleDataManage()->getPressSelectInfo().type.ID !=4) { - DeleteItem(CScheduleDataManage::getScheduleDataManage()->getPressSelectInfo()); - } - CScheduleDataManage::getScheduleDataManage()->setPressSelectInfo(ScheduleDtailInfo()); -} - -void CAllDayEventWeekView::slotUpdateScene() -{ - this->scene()->update(); -} diff -Nru dde-calendar-5.7.0.4/src/alldayeventview.h dde-calendar-5.7.0.23/src/alldayeventview.h --- dde-calendar-5.7.0.4/src/alldayeventview.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/alldayeventview.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,123 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#ifndef ALLDAYEVENTVIEW_H -#define ALLDAYEVENTVIEW_H - -#include -#include -#include -#include -#include "schedulestructs.h" -#include -#include -#include - -#include - - -#include "SchecduleRemindWidget.h" -#include "draginfoitem.h" -#include "draginfographicsview.h" -DWIDGET_USE_NAMESPACE -class QDrag; -class CAllDayEventWidgetItem; -class CScheduleCoorManage; -class CAllDayEventWeekView : public DragInfoGraphicsView -{ - Q_OBJECT -public: - CAllDayEventWeekView(QWidget *parent = nullptr, int edittype = 0); - ~CAllDayEventWeekView() Q_DECL_OVERRIDE; - void setDayData(const QVector > &vlistData); - void setInfo(const QVector &info); - QVector > &getListData() - { - return m_vlistData; - } - void setRange(int w, int h, QDate begindate, QDate enddate, int rightmagin); - void setRange(QDate begin, QDate end); - CScheduleCoorManage *getCoorManage() - { - return m_coorManage; - } - void updateHigh(); - void setSelectSchedule(const ScheduleDtailInfo &info); - void setMargins(int left, int top, int right, int bottom); - void updateInfo(); -signals: - void signalUpdatePaint(const int topM); - void signalSceneUpdate(); -public slots: - void slotDeleteItem(); - void slotUpdateScene(); -private slots: - void slotDoubleEvent(); -public: - void setTheMe(int type = 0) override; -private: - - bool MeetCreationConditions(const QDateTime &date) override; - void slotCreate(const QDateTime &date) override; - //判断时间是否相等 - bool IsEqualtime(const QDateTime &timeFirst,const QDateTime &timeSecond) override; - //根据鼠标移动的距离判断是否创建日程 - bool JudgeIsCreate(const QPointF &pos) override; - void RightClickToCreate(QGraphicsItem *listItem,const QPoint &pos) override; - void MoveInfoProcess(ScheduleDtailInfo &info,const QPointF &pos) override; - QDateTime getDragScheduleInfoBeginTime(const QDateTime &moveDateTime) override; - QDateTime getDragScheduleInfoEndTime(const QDateTime &moveDateTime) override; - PosInItem getPosInItem(const QPoint &p,const QRectF &itemRect)override; - QDateTime getPosDate(const QPoint &p)override; - void upDateInfoShow(const DragStatus &status = NONE,const ScheduleDtailInfo &info =ScheduleDtailInfo())override; -protected: - void mouseDoubleClickEvent(QMouseEvent *event) override; - void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE; -private: - void updateDateShow(); - void createItemWidget(int index, bool average = false); -private: - int itemHeight = 22; - - QVector > m_vlistData; - QVector m_scheduleInfo; - QVector m_baseShowItem; - int m_editType = 0; - CScheduleCoorManage *m_coorManage; - QDate m_dianjiDay; - - int m_rightmagin = 0; - bool m_updateDflag = false; - - QDate m_beginDate; - QDate m_endDate; - - -}; - -class CAllDayEventWidgetItem : public DragInfoItem -{ - Q_OBJECT -public: - explicit CAllDayEventWidgetItem(QRectF rect, QGraphicsItem *parent = nullptr, int edittype = 0); - bool hasSelectSchedule(const ScheduleDtailInfo &info); -protected: - void paintBackground(QPainter *painter,const QRectF &rect,const int isPixMap = false) override; -}; -#endif // CSHCEDULEDAYVIEW_H - diff -Nru dde-calendar-5.7.0.4/src/animationstackedwidget.cpp dde-calendar-5.7.0.23/src/animationstackedwidget.cpp --- dde-calendar-5.7.0.4/src/animationstackedwidget.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/animationstackedwidget.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,276 +0,0 @@ -/* -* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. -* -* Author: uniontech -* -* Maintainer: uniontech -* -* 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 -* 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 . -*/ -#include "animationstackedwidget.h" - -#include - -AnimationStackedWidget::AnimationStackedWidget(const AnimationOri ori, QWidget *parent) - : QStackedWidget(parent), - m_animationOri(ori) - , animation(new QPropertyAnimation(this, QByteArray())) -{ - setDuration(1000); - connect(animation - , &QPropertyAnimation::valueChanged - , this - , &AnimationStackedWidget::valueChanged_slot); - connect(animation - , &QPropertyAnimation::finished - , this - , &AnimationStackedWidget::animationFinished); -} - -AnimationStackedWidget::~AnimationStackedWidget() -{ - delete animation; -} - -void AnimationStackedWidget::setDuration(int duration) -{ - this->duration = duration; - animation->setEasingCurve(QEasingCurve::InOutQuad); -} - - -void AnimationStackedWidget::paintEvent(QPaintEvent *e) -{ - Q_UNUSED(e); - if ( isAnimation ) { - QPainter paint(this); - paintPrevious(paint, currentIndex()); - paintNext(paint, nextIndex); - } -} - -void AnimationStackedWidget::valueChanged_slot(QVariant value) -{ - currentValue = value; - update(); -} - -void AnimationStackedWidget::animationFinished() -{ - isAnimation = false; - widget(currentIndex())->show(); - setCurrentIndex(nextIndex); - emit signalIsFinished(); -} - - -void AnimationStackedWidget::setCurrent(int index) -{ - //如果正在动画,那么return - if ( isAnimation ) { - return; - } - - //开始动画并设置间隔和开始、结束值 - QRect g = geometry(); - int value = 0; - if (index < currentIndex()) { - switch (m_animationOri) { - case LR: { - m_moveOri = LeftToRight; - value = g.width(); - } - break; - case TB: { - m_moveOri = TopToBottom; - value = g.height(); - } - break; - } - } else if (index > currentIndex()) { - switch (m_animationOri) { - case LR: { - m_moveOri = RightToLeft; - value = g.width(); - } - break; - case TB: { - m_moveOri = BottomToTop; - value = g.height(); - } - break; - } - } else { - emit signalIsFinished(); - return; - } - isAnimation = true; - widgetCount = count(); - int c = currentIndex(); - nextIndex = index; - - //隐藏当前的widget - widget(c)->hide(); - animation->setStartValue(value); - animation->setEndValue(0); - animation->setDuration(duration); - animation->start(); -} - -void AnimationStackedWidget::setPre() -{ - //如果正在动画,那么return - if ( isAnimation ) { - return; - } - - //开始动画并设置间隔和开始、结束值 - QRect g = geometry(); - int value = 0; - int index = currentIndex(); - index = qAbs(index - 1); - switch (m_animationOri) { - case LR: { - m_moveOri = LeftToRight; - value = g.width(); - } - break; - case TB: { - m_moveOri = TopToBottom; - value = g.height(); - } - break; - } - - isAnimation = true; - widgetCount = count(); - int c = currentIndex(); - nextIndex = index; - - //隐藏当前的widget - widget(c)->hide(); - animation->setStartValue(value); - animation->setEndValue(0); - animation->setDuration(duration); - animation->start(); -} - -void AnimationStackedWidget::setNext() -{ - //如果正在动画,那么return - if ( isAnimation ) { - return; - } - - //开始动画并设置间隔和开始、结束值 - QRect g = geometry(); - int value = 0; - int index = currentIndex(); - index = (index + 1) % 2; - - switch (m_animationOri) { - case LR: { - m_moveOri = RightToLeft; - value = g.width(); - } - break; - case TB: { - m_moveOri = BottomToTop; - value = g.height(); - } - break; - } - - - isAnimation = true; - widgetCount = count(); - int c = currentIndex(); - nextIndex = index; - - //隐藏当前的widget - widget(c)->hide(); - animation->setStartValue(value); - animation->setEndValue(0); - animation->setDuration(duration); - animation->start(); -} - -void AnimationStackedWidget::paintPrevious(QPainter &paint, int currentIndex) -{ - //获得当前页面的Widget - QWidget *w = widget(currentIndex); - QPixmap pixmap(w->size()); - //将Widget的内容渲染到QPixmap对象中,即将Widget变成一张图片 - w->render(&pixmap); - QRect r = w->geometry(); - //绘制当前的Widget - double value = currentValue.toDouble(); - QRectF r1(0.0, 0.0, value, r.height()); - QRectF r2(r.width() - value, 0, value, r.height()); - switch (m_moveOri) { - case LeftToRight: - paint.drawPixmap(QRectF(r.width() - value, 0, value, r.height()), - pixmap, - QRectF(0.0, 0.0, value, r.height())); - break; - case RightToLeft: - paint.drawPixmap(QRectF(0.0, 0.0, value, r.height()), - pixmap, - QRectF(r.width() - value, 0, value, r.height())); - break; - case TopToBottom: - paint.drawPixmap(QRectF(0.0, r.height() - value, r.width(), value), - pixmap, - QRectF(0.0, 0.0, r.width(), value)); - break; - case BottomToTop: - paint.drawPixmap(QRectF(0.0, 0.0, r.width(), value), - pixmap, - QRectF( 0, r.height() - value, r.width(), value)); - break; - } -} - -void AnimationStackedWidget::paintNext(QPainter &paint, int nextIndex) -{ - QWidget *nextWidget = widget(nextIndex); - QRect r = geometry(); - //这行代码不加会有bug,第一次切换的时候,QStackedWidget并没有为child分配大小 - nextWidget->resize(r.width(), r.height()); - QPixmap nextPixmap(nextWidget->size()); - nextWidget->render(&nextPixmap); - double value = currentValue.toDouble(); - switch (m_moveOri) { - case LeftToRight: - paint.drawPixmap(QRectF(0.0, 0.0, r.width() - value, r.height()), - nextPixmap, - QRectF(value, 0.0, r.width() - value, r.height())); - break; - case RightToLeft: - paint.drawPixmap(QRectF(value, 0.0, r.width() - value, r.height()), - nextPixmap, - QRectF(0.0, 0.0, r.width() - value, r.height())); - break; - case TopToBottom: - paint.drawPixmap(QRectF(0.0, 0.0, r.width(), r.height() - value), - nextPixmap, - QRectF(0.0, value, r.width(), r.height() - value)); - break; - case BottomToTop: - paint.drawPixmap(QRectF(0.0, value, r.width(), r.height() - value), - nextPixmap, - QRectF(0.0, 0.0, r.width(), r.height() - value)); - break; - } -} diff -Nru dde-calendar-5.7.0.4/src/animationstackedwidget.h dde-calendar-5.7.0.23/src/animationstackedwidget.h --- dde-calendar-5.7.0.4/src/animationstackedwidget.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/animationstackedwidget.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -/* -* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. -* -* Author: uniontech -* -* Maintainer: uniontech -* -* 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 -* 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 . -*/ -#ifndef AnimationStackedWidget_H -#define AnimationStackedWidget_H - -#include -#include -#include - -class AnimationStackedWidget : public QStackedWidget -{ - Q_OBJECT - enum MoveOrientation {LeftToRight, RightToLeft, TopToBottom, BottomToTop}; -public: - enum AnimationOri {LR, TB}; //LR:Left Right ,TB:Top Bottom -public: - explicit AnimationStackedWidget(const AnimationOri ori = LR, QWidget *parent = nullptr); - ~AnimationStackedWidget() Q_DECL_OVERRIDE; - //设置动画持续的间隔 - void setDuration(int duration = 500); - bool IsRunning()const - { - return isAnimation; - } -protected: - void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE; -signals: - void signalIsFinished(); -public slots: - //属性动画值改变的槽 - void valueChanged_slot(QVariant ); - //动画切换完成 - void animationFinished(); - //设置当前页 - void setCurrent(int index); - void setPre(); - void setNext(); -private: - void paintPrevious(QPainter &, int); - void paintNext(QPainter &, int); -private: - AnimationOri m_animationOri; - QPropertyAnimation *animation; - int duration; - bool isAnimation = false; - QVariant currentValue; - int widgetCount; - int nextIndex; - MoveOrientation m_moveOri = MoveOrientation::LeftToRight; - -}; - -#endif // AnimationStackedWidget_H diff -Nru dde-calendar-5.7.0.4/src/calendardbus.cpp dde-calendar-5.7.0.23/src/calendardbus.cpp --- dde-calendar-5.7.0.4/src/calendardbus.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/calendardbus.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,359 +0,0 @@ -/* - * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ - -/* - * This file was generated by qdbusxml2cpp version 0.8 - * Command line was: qdbusxml2cpp -c DCalendarDBus -p dcalendardbus com.deepin.api.LunarCalendar.xml - * - * qdbusxml2cpp is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). - * - * This is an auto-generated file. - * This file may have been hand-edited. Look for HAND-EDIT comments - * before re-generating it. - */ - -#include "calendardbus.h" - -/* - * Implementation of interface class DCalendarDBus - */ - -CalendarDBus::CalendarDBus(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) - : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) -{ - QDBusConnection::sessionBus().connect(this->service(), this->path(), "org.freedesktop.DBus.Properties", "PropertiesChanged", "sa{sv}as", this, SLOT(__propertyChanged__(QDBusMessage))); - - CaYearInfo::registerMetaType(); - CaLunarDayInfo::registerMetaType(); - CaLunarMonthInfo::registerMetaType(); - CaSolarMonthInfo::registerMetaType(); - CaHuangLiDayInfo::registerMetaType(); - CaHuangLiMonthInfo::registerMetaType(); -} - -CalendarDBus::~CalendarDBus() -{ - QDBusConnection::sessionBus().disconnect(service(), path(), "org.freedesktop.DBus.Properties", "PropertiesChanged", "sa{sv}as", this, SLOT(propertyChanged(QDBusMessage))); -} - -void CaYearInfo::registerMetaType() -{ - qRegisterMetaType(); - qDBusRegisterMetaType(); -} - -QDebug operator<<(QDebug argument, const CaYearInfo &what) -{ - argument << what.mYear << what.mMonth << what.mDay; - - return argument; -} - -QDBusArgument &operator<<(QDBusArgument &argument, const CaYearInfo &what) -{ - argument.beginStructure(); - argument << what.mYear << what.mMonth << what.mDay; - argument.endStructure(); - - return argument; -} - -const QDBusArgument &operator>>(const QDBusArgument &argument, CaYearInfo &what) -{ - argument.beginStructure(); - argument >> what.mYear >> what.mMonth >> what.mDay; - argument.endStructure(); - - return argument; -} - - -void CaLunarDayInfo::registerMetaType() -{ - qRegisterMetaType(); - qDBusRegisterMetaType(); -} - -QDebug operator<<(QDebug argument, const CaLunarDayInfo &what) -{ - argument << what.mGanZhiYear << what.mGanZhiMonth << what.mGanZhiDay; - argument << what.mLunarMonthName << what.mLunarDayName; - argument << what.mLunarLeapMonth; - argument << what.mZodiac << what.mTerm; - argument << what.mSolarFestival << what.mLunarFestival; - argument << what.mWorktime; - - return argument; -} - -QDBusArgument &operator<<(QDBusArgument &argument, const CaLunarDayInfo &what) -{ - argument.beginStructure(); - argument << what.mGanZhiYear << what.mGanZhiMonth << what.mGanZhiDay; - argument << what.mLunarMonthName << what.mLunarDayName; - argument << what.mLunarLeapMonth; - argument << what.mZodiac << what.mTerm; - argument << what.mSolarFestival << what.mLunarFestival; - argument << what.mWorktime; - argument.endStructure(); - - return argument; -} - -const QDBusArgument &operator>>(const QDBusArgument &argument, CaLunarDayInfo &what) -{ - argument.beginStructure(); - argument >> what.mGanZhiYear >> what.mGanZhiMonth >> what.mGanZhiDay; - argument >> what.mLunarMonthName >> what.mLunarDayName; - argument >> what.mLunarLeapMonth; - argument >> what.mZodiac >> what.mTerm; - argument >> what.mSolarFestival >> what.mLunarFestival; - argument >> what.mWorktime; - argument.endStructure(); - - return argument; -} - - -void CaLunarMonthInfo::registerMetaType() -{ - qRegisterMetaType(); - qDBusRegisterMetaType(); -} - -QDebug operator<<(QDebug argument, const CaLunarMonthInfo &what) -{ - argument << what.mFirstDayWeek << what.mDays; - argument << what.mCaLunarDayInfo; - - return argument; -} - -QDBusArgument &operator<<(QDBusArgument &argument, const CaLunarMonthInfo &what) -{ - argument.beginStructure(); - argument << what.mFirstDayWeek << what.mDays; - argument << what.mCaLunarDayInfo; - argument.endStructure(); - - return argument; -} - -const QDBusArgument &operator>>(const QDBusArgument &argument, CaLunarMonthInfo &what) -{ - argument.beginStructure(); - argument >> what.mFirstDayWeek >> what.mDays; - argument >> what.mCaLunarDayInfo; - argument.endStructure(); - - return argument; -} - - -void CaSolarMonthInfo::registerMetaType() -{ - qRegisterMetaType(); - qDBusRegisterMetaType(); -} - -QDebug operator<<(QDebug argument, const CaSolarMonthInfo &what) -{ - argument << what.mFirstDayWeek << what.mDays; - argument << what.mCaYearInfo; - - return argument; -} - -QDBusArgument &operator<<(QDBusArgument &argument, const CaSolarMonthInfo &what) -{ - argument.beginStructure(); - argument << what.mFirstDayWeek << what.mDays; - argument.endStructure(); - argument << what.mCaYearInfo; - - return argument; -} - -const QDBusArgument &operator>>(const QDBusArgument &argument, CaSolarMonthInfo &what) -{ - argument.beginStructure(); - argument >> what.mFirstDayWeek >> what.mDays; - argument.endStructure(); - argument >> what.mCaYearInfo; - - return argument; -} -#if 1 -void CaHuangLiDayInfo::registerMetaType() -{ - qRegisterMetaType(); - qDBusRegisterMetaType(); -} -QDebug operator<<(QDebug argument, const CaHuangLiDayInfo &what) -{ - argument << what.mSuit << what.mAvoid; - argument << what.mWorktime; - argument << what.mLunarFestival << what.mSolarFestival; - argument << what.mTerm << what.mZodiac; - argument << what.mLunarLeapMonth; - argument << what.mLunarDayName << what.mLunarMonthName; - argument << what.mGanZhiDay << what.mGanZhiMonth << what.mGanZhiYear ; - return argument; -} - -QDBusArgument &operator<<(QDBusArgument &argument, const CaHuangLiDayInfo &what) -{ - argument.beginStructure(); - argument << what.mSuit << what.mAvoid; - argument << what.mWorktime; - argument << what.mLunarFestival << what.mSolarFestival; - argument << what.mTerm << what.mZodiac; - argument << what.mLunarLeapMonth; - argument << what.mLunarDayName << what.mLunarMonthName; - argument << what.mGanZhiDay << what.mGanZhiMonth << what.mGanZhiYear ; - argument.endStructure(); - return argument; -} - -const QDBusArgument &operator>>(const QDBusArgument &argument, CaHuangLiDayInfo &what) -{ - argument.beginStructure(); - argument >> what.mSuit >> what.mAvoid; - argument >> what.mWorktime; - argument >> what.mLunarFestival >> what.mSolarFestival; - argument >> what.mTerm >> what.mZodiac; - argument >> what.mLunarLeapMonth; - argument >> what.mLunarDayName >> what.mLunarMonthName; - argument >> what.mGanZhiDay >> what.mGanZhiMonth >> what.mGanZhiYear ; - argument.endStructure(); - return argument; -} - -void CaHuangLiMonthInfo::registerMetaType() -{ - qRegisterMetaType(); - qDBusRegisterMetaType(); -} - -QDebug operator<<(QDebug argument, const CaHuangLiMonthInfo &what) -{ - argument << what.mDays << what.mFirstDayWeek; - argument << what.mCaLunarDayInfo; - - return argument; -} - -QDBusArgument &operator<<(QDBusArgument &argument, const CaHuangLiMonthInfo &what) -{ - argument.beginStructure(); - argument << what.mDays << what.mFirstDayWeek; - argument << what.mCaLunarDayInfo; - argument.endStructure(); - - return argument; -} - -const QDBusArgument &operator>>(const QDBusArgument &argument, CaHuangLiMonthInfo &what) -{ - argument.beginStructure(); - argument >> what.mDays >> what.mFirstDayWeek; - argument >> what.mCaLunarDayInfo; - argument.endStructure(); - - return argument; -} -#else -void CaHuangLiDayInfo::registerMetaType() -{ - qRegisterMetaType(); - qDBusRegisterMetaType(); -} -QDebug operator<<(QDebug argument, const CaHuangLiDayInfo &what) -{ - argument << what.mGanZhiYear << what.mGanZhiMonth << what.mGanZhiDay; - argument << what.mLunarMonthName << what.mLunarDayName; - argument << what.mLunarLeapMonth; - argument << what.mZodiac << what.mTerm; - argument << what.mSolarFestival << what.mLunarFestival; - argument << what.mWorktime; - argument << what.mAvoid << what.mSuit ; - return argument; -} - -QDBusArgument &operator<<(QDBusArgument &argument, const CaHuangLiDayInfo &what) -{ - argument.beginStructure(); - argument << what.mGanZhiYear << what.mGanZhiMonth << what.mGanZhiDay; - argument << what.mLunarMonthName << what.mLunarDayName; - argument << what.mLunarLeapMonth; - argument << what.mZodiac << what.mTerm; - argument << what.mSolarFestival << what.mLunarFestival; - argument << what.mWorktime; - argument << what.mAvoid << what.mSuit ; - argument.endStructure(); - return argument; -} - -const QDBusArgument &operator>>(const QDBusArgument &argument, CaHuangLiDayInfo &what) -{ - argument.beginStructure(); - argument >> what.mGanZhiYear >> what.mGanZhiMonth >> what.mGanZhiDay; - argument >> what.mLunarMonthName >> what.mLunarDayName; - argument >> what.mLunarLeapMonth; - argument >> what.mZodiac >> what.mTerm; - argument >> what.mSolarFestival >> what.mLunarFestival; - argument >> what.mWorktime; - argument >> what.mAvoid >> what.mSuit ; - argument.endStructure(); - return argument; -} - -void CaHuangLiMonthInfo::registerMetaType() -{ - qRegisterMetaType(); - qDBusRegisterMetaType(); -} - -QDebug operator<<(QDebug argument, const CaHuangLiMonthInfo &what) -{ - argument << what.mFirstDayWeek << what.mDays; - argument << what.mCaLunarDayInfo; - - return argument; -} - -QDBusArgument &operator<<(QDBusArgument &argument, const CaHuangLiMonthInfo &what) -{ - argument.beginStructure(); - argument << what.mFirstDayWeek << what.mDays; - argument << what.mCaLunarDayInfo; - argument.endStructure(); - - return argument; -} -const QDBusArgument &operator>>(const QDBusArgument &argument, CaHuangLiMonthInfo &what) -{ - argument.beginStructure(); - argument >> what.mFirstDayWeek >> what.mDays; - argument >> what.mCaLunarDayInfo; - argument.endStructure(); - - return argument; -} -#endif diff -Nru dde-calendar-5.7.0.4/src/calendardbus.h dde-calendar-5.7.0.23/src/calendardbus.h --- dde-calendar-5.7.0.4/src/calendardbus.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/calendardbus.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,525 +0,0 @@ -/* - * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ - -/* - * This file was generated by qdbusxml2cpp version 0.8 - * Command line was: qdbusxml2cpp -c DCalendarDBus -p dcalendardbus com.deepin.api.LunarCalendar.xml - * - * qdbusxml2cpp is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). - * - * This is an auto-generated file. - * Do not edit! All changes made to it will be lost. - */ - -#ifndef CALENDARDBUS_H -#define CALENDARDBUS_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -class CaYearInfo -{ -public: - CaYearInfo() {} - - inline static void registerMetaType(); - - friend QDebug operator<<(QDebug argument, const CaYearInfo &what); - friend QDBusArgument &operator<<(QDBusArgument &argument, const CaYearInfo &what); - friend const QDBusArgument &operator>>(const QDBusArgument &argument, CaYearInfo &what); - -public: - qint32 mYear; - qint32 mMonth; - qint32 mDay; -}; - -class CaLunarDayInfo -{ -public: - CaLunarDayInfo() {} - - inline static void registerMetaType(); - - friend QDebug operator<<(QDebug argument, const CaLunarDayInfo &what); - friend QDBusArgument &operator<<(QDBusArgument &argument, const CaLunarDayInfo &what); - friend const QDBusArgument &operator>>(const QDBusArgument &argument, CaLunarDayInfo &what); - -public: - QString mGanZhiYear; - QString mGanZhiMonth; - QString mGanZhiDay; - QString mLunarMonthName; - QString mLunarDayName; - qint32 mLunarLeapMonth; - QString mZodiac; - QString mTerm; - QString mSolarFestival; - QString mLunarFestival; - qint32 mWorktime; -}; - -class CaLunarMonthInfo -{ -public: - CaLunarMonthInfo() {} - - inline static void registerMetaType(); - - friend QDebug operator<<(QDebug argument, const CaLunarMonthInfo &what); - friend QDBusArgument &operator<<(QDBusArgument &argument, const CaLunarMonthInfo &what); - friend const QDBusArgument &operator>>(const QDBusArgument &argument, CaLunarMonthInfo &what); - -public: - qint32 mFirstDayWeek; - qint32 mDays; - QList mCaLunarDayInfo; -}; - -class CaSolarMonthInfo -{ -public: - CaSolarMonthInfo() {} - - inline static void registerMetaType(); - - friend QDebug operator<<(QDebug argument, const CaSolarMonthInfo &what); - friend QDBusArgument &operator<<(QDBusArgument &argument, const CaSolarMonthInfo &what); - friend const QDBusArgument &operator>>(const QDBusArgument &argument, CaSolarMonthInfo &what); - - -public: - qint32 mFirstDayWeek; - qint32 mDays; - QList mCaYearInfo; -}; - -class CaHuangLiDayInfo -{ -public: - CaHuangLiDayInfo() {} - inline static void registerMetaType(); - friend QDebug operator<<(QDebug argument, const CaHuangLiDayInfo &what); - friend QDBusArgument &operator<<(QDBusArgument &argument, const CaHuangLiDayInfo &what); - friend const QDBusArgument &operator>>(const QDBusArgument &argument, CaHuangLiDayInfo &what); -public: - QString mGanZhiYear; - QString mGanZhiMonth; - QString mGanZhiDay; - QString mLunarMonthName; - QString mLunarDayName; - qint32 mLunarLeapMonth; - QString mZodiac; - QString mTerm; - QString mSolarFestival; - QString mLunarFestival; - qint32 mWorktime; - QString mSuit; - QString mAvoid; -}; - -class CaHuangLiMonthInfo -{ -public: - CaHuangLiMonthInfo() {} - inline static void registerMetaType(); - - friend QDebug operator<<(QDebug argument, const CaHuangLiMonthInfo &what); - friend QDBusArgument &operator<<(QDBusArgument &argument, const CaHuangLiMonthInfo &what); - friend const QDBusArgument &operator>>(const QDBusArgument &argument, CaHuangLiMonthInfo &what); -public: - qint32 mFirstDayWeek; - qint32 mDays; - QList mCaLunarDayInfo; -}; -typedef struct _tagHolidayInfo { - - QDate date; - char status; -} HolidayInfo; - -typedef struct _tagFestivalInfo { - QString ID; - QString FestivalName; - QString description; - QString Rest; - int month; - int year; - QVector listHoliday; -} FestivalInfo; - - -/* - * Proxy class for interface com.deepin.api.LunarCalendar - */ -class CalendarDBus: public QDBusAbstractInterface -{ - Q_OBJECT - - Q_SLOT void __propertyChanged__(const QDBusMessage &msg) - { - QList arguments = msg.arguments(); - if (3 != arguments.count()) - return; - QString interfaceName = msg.arguments().at(0).toString(); - if (interfaceName != "com.deepin.api.LunarCalendar") - return; - QVariantMap changedProps = qdbus_cast(arguments.at(1).value()); - foreach (const QString &prop, changedProps.keys()) { - const QMetaObject *self = metaObject(); - for (int i = self->propertyOffset(); i < self->propertyCount(); ++i) { - QMetaProperty p = self->property(i); - if (p.name() == prop) { - Q_EMIT p.notifySignal().invoke(this); - } - } - } - } -public: - static inline const char *staticInterfaceName() - { - return "com.deepin.api.LunarCalendar"; - } - -public: - CalendarDBus(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); - - ~CalendarDBus(); - -public Q_SLOTS: // METHODS - inline QDBusPendingReply GetLunarDateBySolar(int in0, int in1, int in2) - { - QList argumentList; - argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1) << QVariant::fromValue(in2); - return asyncCallWithArgumentList(QStringLiteral("GetLunarDateBySolar"), argumentList); - } - inline QDBusReply GetLunarDateBySolar(int in0, int in1, int in2, bool &out1, bool &out2) - { - QList argumentList; - argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1) << QVariant::fromValue(in2); - QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetLunarDateBySolar"), argumentList); - if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 3) { - out1 = qdbus_cast(reply.arguments().at(1)); - out2 = qdbus_cast(reply.arguments().at(2)); - } - return reply; - } - - inline QDBusPendingReply GetLunarInfoBySolar(int in0, int in1, int in2) - { - QList argumentList; - argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1) << QVariant::fromValue(in2); - return asyncCallWithArgumentList(QStringLiteral("GetLunarInfoBySolar"), argumentList); - } - inline QDBusReply GetLunarInfoBySolar(qint32 in0, qint32 in1, qint32 in2, bool &out1) - { - QList argumentList; - argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1) << QVariant::fromValue(in2); - QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetLunarInfoBySolar"), argumentList); - if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 2) { - out1 = qdbus_cast(reply.arguments().at(1)); - } - return reply; - } - - inline QDBusPendingReply GetLunarMonthCalendar(int in0, int in1, bool in2) - { - QList argumentList; - argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1) << QVariant::fromValue(in2); - return asyncCallWithArgumentList(QStringLiteral("GetLunarMonthCalendar"), argumentList); - } - inline QDBusReply GetLunarMonthCalendar(int in0, int in1, bool in2, bool &out1) - { - QList argumentList; - argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1) << QVariant::fromValue(in2); - QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetLunarMonthCalendar"), argumentList); - if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 2) { - out1 = qdbus_cast(reply.arguments().at(1)); - } - return reply; - } - - inline QDBusPendingReply GetSolarDateByLunar(int in0, int in1, int in2, bool in3) - { - QList argumentList; - argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1) << QVariant::fromValue(in2) << QVariant::fromValue(in3); - return asyncCallWithArgumentList(QStringLiteral("GetSolarDateByLunar"), argumentList); - } - inline QDBusReply GetSolarDateByLunar(int in0, int in1, int in2, bool in3, bool &out1) - { - QList argumentList; - argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1) << QVariant::fromValue(in2) << QVariant::fromValue(in3); - QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetSolarDateByLunar"), argumentList); - if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 2) { - out1 = qdbus_cast(reply.arguments().at(1)); - } - return reply; - } - - inline QDBusPendingReply GetSolarMonthCalendar(int in0, int in1, bool in2) - { - QList argumentList; - argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1) << QVariant::fromValue(in2); - return asyncCallWithArgumentList(QStringLiteral("GetSolarMonthCalendar"), argumentList); - } - inline QDBusReply GetSolarMonthCalendar(int in0, int in1, bool in2, bool &out1) - { - QList argumentList; - argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1) << QVariant::fromValue(in2); - QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetSolarMonthCalendar"), argumentList); - if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 2) { - out1 = qdbus_cast(reply.arguments().at(1)); - } - return reply; - } - inline bool GetHuangLiMonthCalendar(int in0, int in1, bool in2, CaHuangLiMonthInfo &out) - { - QList argumentList; - argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1) << QVariant::fromValue(in2); - QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetHuangLiMonth"), argumentList); - if (reply.type() != QDBusMessage::ReplyMessage ) { - return false; - } - QDBusReply huanglimonth = reply; - if (!huanglimonth.isValid()) return false; - QJsonParseError json_error; - QJsonDocument jsonDoc(QJsonDocument::fromJson(huanglimonth.value().toLocal8Bit(), &json_error)); - - if (json_error.error != QJsonParseError::NoError) { - return false; - } - - QJsonObject rootObj = jsonDoc.object(); - - //因为是预先定义好的JSON数据格式,所以这里可以这样读取 - if (rootObj.contains("Days")) { - out.mDays = rootObj.value("Days").toInt(); - } - if (rootObj.contains("FirstDayWeek")) { - out.mFirstDayWeek = rootObj.value("FirstDayWeek").toInt(); - } - if (rootObj.contains("Datas")) { - QJsonArray subArray = rootObj.value("Datas").toArray(); - for (int i = 0; i < subArray.size(); i++) { - - QJsonObject subObj = subArray.at(i).toObject(); - - CaHuangLiDayInfo huangliday; - - //因为是预先定义好的JSON数据格式,所以这里可以这样读取 - if (subObj.contains("Suit")) { - huangliday.mSuit = subObj.value("Suit").toString(); - } - if (subObj.contains("Avoid")) { - huangliday.mAvoid = subObj.value("Avoid").toString(); - } - if (subObj.contains("Worktime")) { - huangliday.mWorktime = subObj.value("Worktime").toInt(); - } - if (subObj.contains("LunarFestival")) { - huangliday.mLunarFestival = subObj.value("LunarFestival").toString(); - } - if (subObj.contains("SolarFestival")) { - huangliday.mSolarFestival = subObj.value("SolarFestival").toString(); - } - if (subObj.contains("Term")) { - huangliday.mTerm = subObj.value("Term").toString(); - } - if (subObj.contains("Zodiac")) { - huangliday.mZodiac = subObj.value("Zodiac").toString(); - } - if (subObj.contains("LunarLeapMonth")) { - huangliday.mLunarLeapMonth = subObj.value("LunarLeapMonth").toInt(); - } - if (subObj.contains("LunarDayName")) { - huangliday.mLunarDayName = subObj.value("LunarDayName").toString(); - } - if (subObj.contains("LunarMonthName")) { - huangliday.mLunarMonthName = subObj.value("LunarMonthName").toString(); - } - if (subObj.contains("GanZhiDay")) { - huangliday.mGanZhiDay = subObj.value("GanZhiDay").toString(); - } - if (subObj.contains("GanZhiMonth")) { - huangliday.mGanZhiMonth = subObj.value("GanZhiMonth").toString(); - } - if (subObj.contains("GanZhiYear")) { - huangliday.mGanZhiYear = subObj.value("GanZhiYear").toString(); - } - out.mCaLunarDayInfo.append(huangliday); - } - } - - return true; - } - - inline bool GetHuangLiDayCalendar(qint32 in0, qint32 in1, qint32 in2, CaHuangLiDayInfo &out) - { - QList argumentList; - argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1) << QVariant::fromValue(in2); - QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetHuangLiDay"), argumentList); - if (reply.type() != QDBusMessage::ReplyMessage ) { - return false; - } - QDBusReply huangliday = reply; - if (!huangliday.isValid()) return false; - QJsonParseError json_error; - QJsonDocument jsonDoc(QJsonDocument::fromJson(huangliday.value().toLocal8Bit(), &json_error)); - - if (json_error.error != QJsonParseError::NoError) { - return false; - } - - QJsonObject rootObj = jsonDoc.object(); - - //因为是预先定义好的JSON数据格式,所以这里可以这样读取 - if (rootObj.contains("Suit")) { - out.mSuit = rootObj.value("Suit").toString(); - } - if (rootObj.contains("Avoid")) { - out.mAvoid = rootObj.value("Avoid").toString(); - } - if (rootObj.contains("Worktime")) { - out.mWorktime = rootObj.value("Worktime").toInt(); - } - if (rootObj.contains("LunarFestival")) { - out.mLunarFestival = rootObj.value("LunarFestival").toString(); - } - if (rootObj.contains("SolarFestival")) { - out.mSolarFestival = rootObj.value("SolarFestival").toString(); - } - if (rootObj.contains("Term")) { - out.mTerm = rootObj.value("Term").toString(); - } - if (rootObj.contains("Zodiac")) { - out.mZodiac = rootObj.value("Zodiac").toString(); - } - if (rootObj.contains("LunarLeapMonth")) { - out.mLunarLeapMonth = rootObj.value("LunarLeapMonth").toInt(); - } - if (rootObj.contains("LunarDayName")) { - out.mLunarDayName = rootObj.value("LunarDayName").toString(); - } - if (rootObj.contains("LunarMonthName")) { - out.mLunarMonthName = rootObj.value("LunarMonthName").toString(); - } - if (rootObj.contains("GanZhiDay")) { - out.mGanZhiDay = rootObj.value("GanZhiDay").toString(); - } - if (rootObj.contains("GanZhiMonth")) { - out.mGanZhiMonth = rootObj.value("GanZhiMonth").toString(); - } - if (rootObj.contains("GanZhiYear")) { - out.mGanZhiYear = rootObj.value("GanZhiYear").toString(); - } - return true; - } - inline bool GetFestivalMonth(int in0, int in1, QVector &out) - { - QList argumentList; - argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1); - QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetFestivalMonth"), argumentList); - if (reply.type() != QDBusMessage::ReplyMessage ) { - return false; - } - QDBusReply festivalMonthinfo = reply; - if (!festivalMonthinfo.isValid()) return false; - QJsonParseError json_error; - QJsonDocument jsonDoc(QJsonDocument::fromJson(festivalMonthinfo.value().toLocal8Bit(), &json_error)); - - if (json_error.error != QJsonParseError::NoError) { - return false; - } - QJsonArray rootarry = jsonDoc.array(); - - for (int i = 0; i < rootarry.size(); i++) { - - QJsonObject subObj = rootarry.at(i).toObject(); - - FestivalInfo festivalInfoday; - - //因为是预先定义好的JSON数据格式,所以这里可以这样读取 - if (subObj.contains("id")) { - festivalInfoday.ID = subObj.value("id").toString(); - } - if (subObj.contains("name")) { - festivalInfoday.FestivalName = subObj.value("name").toString(); - } - if (subObj.contains("description")) { - festivalInfoday.description = subObj.value("description").toString(); - } - if (subObj.contains("rest")) { - festivalInfoday.Rest = subObj.value("rest").toString(); - } - if (subObj.contains("month")) { - festivalInfoday.month = subObj.value("month").toInt(); - } - if (subObj.contains("list")) { - QJsonArray sublistArray = subObj.value("list").toArray(); - - for (int j = 0; j < sublistArray.size(); j++) { - - QJsonObject hsubObj = sublistArray.at(j).toObject(); - HolidayInfo dayinfo; - if (hsubObj.contains("status")) { - dayinfo.status = hsubObj.value("status").toInt(); - } - if (hsubObj.contains("date")) { - dayinfo.date = QDate::fromString(hsubObj.value("date").toString(), "yyyy-M-d"); - } - festivalInfoday.listHoliday.append(dayinfo); - } - } - festivalInfoday.year = in0; - out.append(festivalInfoday); - } - - return true; - } - - -Q_SIGNALS: // SIGNALS -// begin property changed signals -}; - -namespace com { -namespace deepin { -namespace api { -typedef ::CalendarDBus LunarCalendar; -} -} -} - -Q_DECLARE_METATYPE(CaYearInfo) -Q_DECLARE_METATYPE(CaLunarDayInfo) -Q_DECLARE_METATYPE(CaLunarMonthInfo) -Q_DECLARE_METATYPE(CaSolarMonthInfo) -Q_DECLARE_METATYPE(CaHuangLiDayInfo) -Q_DECLARE_METATYPE(CaHuangLiMonthInfo) -#endif diff -Nru dde-calendar-5.7.0.4/src/calendarmainwindow.cpp dde-calendar-5.7.0.23/src/calendarmainwindow.cpp --- dde-calendar-5.7.0.4/src/calendarmainwindow.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/calendarmainwindow.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,1147 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#include "calendarmainwindow.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "yearwindow.h" -#include "monthwindow.h" -#include "dbuscalendar_adaptor.h" -#include "weekwindow.h" -#include "daywindow.h" -#include "scheduledatamanage.h" -#include "myschceduleview.h" -#include "creatorparschedule.h" -#include "configsettings.h" -#include "shortcut.h" -#include "schcedulesearchview.h" - -#include "cdynamicicon.h" - - -DGUI_USE_NAMESPACE -DWIDGET_USE_NAMESPACE - -static const int CalendarMWidth = 860; -static const int CalendarMHeight = 634; - -Calendarmainwindow::Calendarmainwindow(QWidget *w) - : DMainWindow (w) -{ - m_DataGetThread = new DbusDataGetThread(CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->getDbus(), - nullptr); - m_currentdate = QDate::currentDate(); - setContentsMargins(QMargins(0, 0, 0, 0)); - initUI(); - initConnection(); - initLunar(); - //setFixedSize(CalendarMWidth, CalendarMHeight); - setMinimumSize(CalendarMWidth, CalendarMHeight); - setWindowTitle(tr("Calendar")); - //setWindowFlag(Qt::WindowMaximizeButtonHint, false); - new CalendarAdaptor(this); - resize(CalendarMWidth, CalendarMHeight); - - QShortcut *shortcut = new QShortcut(this); - shortcut->setKey(QKeySequence(QLatin1String("Ctrl+F"))); - connect(shortcut, SIGNAL(activated()), this, SLOT(slotSearchEdit())); - - QShortcut *viewshortcut = new QShortcut(this); - viewshortcut->setKey(QKeySequence(QLatin1String("Ctrl+Shift+/"))); - connect(viewshortcut, SIGNAL(activated()), this, SLOT(onViewShortcut())); - -// QShortcut *viewmaxminshortcut = new QShortcut(this); -// viewmaxminshortcut->setKey(QKeySequence(QLatin1String("Ctrl+Alt+F"))); -// connect(viewmaxminshortcut, SIGNAL(activated()), this, SLOT(slotmaxminViewShortcut())); - - setTitlebarShadowEnabled(true); - setFocusPolicy(Qt::ClickFocus); - QByteArray arrybyte = CConfigSettings::value("base.geometry").toByteArray(); - bool isOk = false; - int state = CConfigSettings::value("base.state").toInt(&isOk); - if (!arrybyte.isEmpty() && isOk) { - Qt::WindowStates winStates = static_cast(state); - setWindowState(winStates); - if (winStates !=Qt::WindowState::WindowMaximized) { - restoreGeometry(arrybyte); - } - } - Dtk::Widget::moveToCenter(this); -} - -Calendarmainwindow::~Calendarmainwindow() -{ - CDynamicIcon::releaseInstance(); -} - -/*void Calendarmainwindow::Invoke(const QString &mothodName, const QString &content) -{ - if (mothodName == "CREATE") { - ScheduleDtailInfo info; - if (!analysisCreate(content, info)) { - QMessageBox::information(this, tr("information"), tr("Failed to parse and create schedule!")); - return; - } - if (CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->addSchedule(info) < 0) { - QMessageBox::information(this, tr("information"), tr("Failed to create schedule!")); - return; - } - m_dayButton->setFocus(); - m_dayButton->setChecked(true); - m_stackWidget->setCurrentIndex(3); - m_DayWindow->setDate(info.beginDateTime.date()); - m_DayWindow->slotupdateSchedule(0); - } -}*/ - -bool Calendarmainwindow::analysisCreate(const QString &content, ScheduleDtailInfo &info) -{ - if (content.isEmpty()) return false; - QJsonParseError json_error; - QJsonDocument jsonDoc(QJsonDocument::fromJson(content.toLocal8Bit(), &json_error)); - - if (json_error.error != QJsonParseError::NoError) { - return false; - } - - QJsonArray rootarry = jsonDoc.array(); - - for (int i = 0; i < rootarry.size(); i++) { - - QJsonObject subObj = rootarry.at(i).toObject(); - if (subObj.value("name").toString() == "content") { - info.titleName = subObj.value("value").toString(); - } - if (subObj.value("name").toString() == "datetime") { - QString ssubObj = subObj.value("normValue").toString(); - QJsonParseError sjson_error; - QJsonDocument sjsonDoc(QJsonDocument::fromJson(ssubObj.toLocal8Bit(), &sjson_error)); - - if (sjson_error.error != QJsonParseError::NoError) { - return false; - } - QJsonObject ssobject = sjsonDoc.object(); - info.beginDateTime = QDateTime::fromString(ssobject.value("datetime").toString(), "yyyy-MM-ddThh:mm:ss"); - } - if (subObj.value("value").toString() == "reminder") { - info.id = 0; - info.rpeat = 0; - info.remind = true; - info.remindData.n = 0; - info.endDateTime = info.beginDateTime.addSecs(3600); - info.allday = false; - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->GetType(1, info.type); - } - } - return true; -} -void Calendarmainwindow::onViewShortcut() -{ - QRect rect = window()->geometry(); - QPoint pos(rect.x() + rect.width() / 2, rect.y() + rect.height() / 2); - Shortcut sc; - QStringList shortcutString; - QString param1 = "-j=" + sc.toStr(); - QString param2 = "-p=" + QString::number(pos.x()) + "," + QString::number(pos.y()); - shortcutString << "-b" << param1 << param2; - - QProcess *shortcutViewProc = new QProcess(this); - shortcutViewProc->startDetached("killall deepin-shortcut-viewer"); - shortcutViewProc->startDetached("deepin-shortcut-viewer", shortcutString); - - connect(shortcutViewProc, SIGNAL(finished(int)), shortcutViewProc, SLOT(deleteLater())); -} - -void Calendarmainwindow::slotmaxminViewShortcut() -{ - if (windowState() == Qt::WindowMaximized) { - showNormal(); - } else { - showMaximized(); - } -} - -void Calendarmainwindow::slotGetScheduleInfoSuccess() -{ - m_yearwindow->getScheduleInfo(); -} - -void Calendarmainwindow::slotDynamicIconUpdate() -{ - if (QDate::currentDate() !=CDynamicIcon::getInstance()->getDate()) { - CDynamicIcon::getInstance()->setDate(QDate::currentDate()); - CDynamicIcon::getInstance()->setIcon(); - } - -} -void Calendarmainwindow::viewWindow(int type, QDateTime datetime) -{ - if (type < 0 || type > m_stackWidget->count()) { - return; - } - m_stackWidget->setCurrentIndex(type - 1); - if (type - 1 != 0) { - m_priindex = type - 1; - } -// if (datetime.date().year() <=1900) -// return; - switch (type) { - case 1: { - m_yearButton->setFocus(); - m_yearButton->setChecked(true); - m_yearwindow->setDate(datetime.date()); - } - break; - case 2: { - m_monthButton->setFocus(); - m_monthButton->setChecked(true); - m_monthWindow->setDate(datetime.date()); - m_monthWindow->slotupdateSchedule(0); - } - break; - case 3: { - m_weekButton->setFocus(); - m_weekButton->setChecked(true); - m_weekWindow->setDate(datetime.date()); - m_weekWindow->setTime(datetime.time()); - m_weekWindow->slotupdateSchedule(0); - } - break; - case 4: { - m_dayButton->setFocus(); - m_dayButton->setChecked(true); - m_DayWindow->setDate(datetime.date()); -// m_DayWindow->setTime(datetime.time()); - m_DayWindow->slotupdateSchedule(0); - m_searchflag = true; - } - break; - } - CConfigSettings::setOption("base.view", type); -// m_priindex = 3; -} - -void Calendarmainwindow::UpdateJob() -{ - int index = m_stackWidget->currentIndex(); - if (index < 0 || index > m_stackWidget->count() - 1) { - - return; - } - switch (index) { - case 1: { - //m_monthWindow->slotReturnTodayUpdate(); - m_monthWindow->slotupdateSchedule(0); - } - break; - case 2: { - //m_weekWindow->slotReturnTodayUpdate(); - m_weekWindow->slotupdateSchedule(0); - } - break; - case 3: { - //m_DayWindow->slotReturnTodayUpdate(); - m_DayWindow->slotupdateSchedule(0); - } - break; - } -} - -void Calendarmainwindow::updateHigh() -{ - int index = m_stackWidget->currentIndex(); - if (index < 0 || index > m_stackWidget->count() - 1) { - - return; - } - switch (index) { - case 0: { -// m_yearwindow->updateHigh(); - } - break; - case 1: { - - } - break; - case 2: { - m_weekWindow->updateHigh(); - } - break; - case 3: { - m_DayWindow->updateHigh(); - } - break; - } -} - -void Calendarmainwindow::setSearchWidth(int w) -{ - m_contentBackground->setFixedWidth(w); -} - -void Calendarmainwindow::slotTheme(int type) -{ - if (type == 0) { - type = DGuiApplicationHelper::instance()->themeType(); - } - if (type == 1) { - - DPalette pl = m_yearButton->palette(); - pl.setColor(DPalette::ButtonText, QColor("#414D68")); - pl.setColor(DPalette::Light, QColor("#E6E6E6")); - pl.setColor(DPalette::Dark, QColor("#E3E3E3")); - QColor sbcolor("#000000"); - sbcolor.setAlphaF(0.08); - pl.setColor(DPalette::Shadow, sbcolor); - m_yearButton->setPalette(pl); - m_monthButton->setPalette(pl); - m_weekButton->setPalette(pl); - m_dayButton->setPalette(pl); - // DPalette maintpl = palette(); - //maintpl.setColor(DPalette::Window, "#FFFFFF"); - //setPalette(maintpl); - - DPalette anipa = m_contentBackground->palette(); - anipa.setColor(DPalette::Background, "#F8F8F8"); - m_contentBackground->setPalette(anipa); - m_contentBackground->setBackgroundRole(DPalette::Background); - - DPalette tframepa = m_transparentFrame->palette(); - QColor tColor = "#FFFFFF"; - tColor.setAlphaF(0.3); - tframepa.setColor(DPalette::Background, tColor); - m_transparentFrame->setPalette(tframepa); - m_transparentFrame->setBackgroundRole(DPalette::Background); - - } else { - DPalette pl = m_yearButton->palette(); - pl.setColor(DPalette::ButtonText, QColor("#C0C6D4")); - pl.setColor(DPalette::Light, QColor("#484848")); - pl.setColor(DPalette::Dark, QColor("#414141")); - QColor sbcolor("#000000"); - sbcolor.setAlphaF(0.08); - pl.setColor(DPalette::Shadow, sbcolor); - m_yearButton->setPalette(pl); - m_monthButton->setPalette(pl); - m_weekButton->setPalette(pl); - m_dayButton->setPalette(pl); - //DPalette maintpl = palette(); - //maintpl.setColor(DPalette::Window, Qt::black); - //setPalette(maintpl); - - DPalette anipa = m_contentBackground->palette(); - anipa.setColor(DPalette::Background, "#252525"); - m_contentBackground->setPalette(anipa); - m_contentBackground->setBackgroundRole(DPalette::Background); - - DPalette tframepa = m_transparentFrame->palette(); - QColor tColor = "#000000"; - tColor.setAlphaF(0.3); - tframepa.setColor(DPalette::Background, tColor); - m_transparentFrame->setPalette(tframepa); - m_transparentFrame->setBackgroundRole(DPalette::Background); - } - CScheduleDataManage::getScheduleDataManage()->setTheMe(type); - m_yearwindow->setTheMe(type); - m_monthWindow->setTheMe(type); - m_weekWindow->setTheMe(type); - m_DayWindow->setTheMe(type); - m_schceduleSearchView->setTheMe(type); -} - -void Calendarmainwindow::OpenSchedule(QString job) -{ - if (job.isEmpty()) return; - ScheduleDtailInfo out; - if (CreatOrParSchedule::GetJob(job, out)) { - m_dayButton->setFocus(); - m_dayButton->setChecked(true); - m_stackWidget->setCurrentIndex(3); - m_DayWindow->setDate(out.beginDateTime.date()); - m_DayWindow->slotupdateSchedule(0); - CMySchceduleView dlg(out, this); -// dlg.setSchedules(out); - dlg.exec(); - m_DayWindow->slotupdateSchedule(0); - slotWUpdateShcedule(nullptr,0); - } -} - -void Calendarmainwindow::ActiveWindow() -{ - raise(); -} - -void Calendarmainwindow::RaiseWindow() -{ - raise(); -} -void Calendarmainwindow::initUI() -{ - m_DynamicIconUpdateTimer = new QTimer(this); - m_DynamicIconUpdateTimer->start(3000); - - QFrame *titleframe = new QFrame(this); - titleframe->setObjectName("TitleBar"); - titleframe->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - CDynamicIcon::getInstance()->setTitlebar(this->titlebar()); - CDynamicIcon::getInstance()->setIcon(); - - - - - - QStringList titlelist; - titlelist << tr("Y") << tr("M") << tr("W") << tr("D"); - m_buttonBox = new DButtonBox(this); - //DPalette wpa = m_segmentedControl->palette(); - //wpa.setColor(DPalette::ButtonText, QColor("#FFFFFF")); - //wpa.setColor(DPalette::Button, QColor("#0081FF ")); - // wpa.setColor(DPalette::Dark, QColor("#0081FF")); - //wpa.setColor(DPalette::Light, QColor("#0081FF")); - // wpa.setColor(DPalette::Window, QColor("#0081FF")); - // wpa.setColor(DPalette::WindowText, QColor("#414D68")); - //m_segmentedControl->setPalette(wpa); - //m_segmentedControl->addSegmented(titlelist); - // m_segmentedControl->setFixedSize(200, 36); - - m_yearButton = new DButtonBoxButton(tr("Y"), this); - DPalette pl = m_yearButton->palette(); - pl.setColor(DPalette::ButtonText, QColor("#414D68")); - pl.setColor(DPalette::Light, QColor("#E6E6E6")); - pl.setColor(DPalette::Dark, QColor("#E3E3E3")); - QColor sbcolor("#000000"); - sbcolor.setAlphaF(0.08); - pl.setColor(DPalette::Shadow, sbcolor); - - QFont viewfont; -// viewfont.setFamily("SourceHanSansSC"); - viewfont.setWeight(QFont::Medium); - viewfont.setPixelSize(14); - - - m_yearButton->setFixedSize(50, 36); - m_monthButton = new DButtonBoxButton(tr("M"), this); - m_monthButton->setFixedSize(50, 36); - m_weekButton = new DButtonBoxButton(tr("W"), this); - m_weekButton->setFixedSize(50, 36); - m_dayButton = new DButtonBoxButton(tr("D"), this); - m_dayButton->setFixedSize(50, 36); - m_yearButton->setPalette(pl); - m_monthButton->setPalette(pl); - m_weekButton->setPalette(pl); - m_dayButton->setPalette(pl); - m_yearButton->setFont(viewfont); - m_monthButton->setFont(viewfont); - m_weekButton->setFont(viewfont); - m_dayButton->setFont(viewfont); - - QList btlist; - btlist.append(m_yearButton); - btlist.append(m_monthButton); - btlist.append(m_weekButton); - btlist.append(m_dayButton); - m_buttonBox->setButtonList(btlist, true); - - m_buttonBox->setId(m_yearButton, 0); - m_buttonBox->setId(m_monthButton, 1); - m_buttonBox->setId(m_weekButton, 2); - m_buttonBox->setId(m_dayButton, 3); - m_buttonBox->setFixedSize(200, 36); - - QHBoxLayout *titleLayout = new QHBoxLayout; - titleLayout->setMargin(0); - titleLayout->setSpacing(0); - //titleLayout->setContentsMargins(0, 0, 0, 0); - //titleLayout->addWidget(m_ybutton); - // titleLayout->addWidget(m_mbutton); - //titleLayout->addWidget(m_wbutton); - titleLayout->addSpacing(8); - //titleLayout->addWidget(m_icon); - //titleLayout->addSpacing(18); - titleLayout->addWidget(m_buttonBox); - titleLayout->addSpacing(52); - // QSpacerItem *lspaceitem = new QSpacerItem(30, CalendarMTitleHeight, QSizePolicy::Expanding, QSizePolicy::Fixed); - //titleLayout->addSpacerItem(lspaceitem); - m_searchEdit = new DSearchEdit(this); - DFontSizeManager::instance()->bind(m_searchEdit, DFontSizeManager::T6); - m_searchEdit->setFixedHeight(36); - m_searchEdit->setMinimumWidth(240); - m_searchEdit->setMaximumWidth(354); - m_searchEdit->setFont(viewfont); - titleLayout->addStretch(); - //QWidget *buttonW = new QWidget; - titleframe->setLayout(titleLayout); - - DTitlebar *titlebar = this->titlebar(); - titlebar->setFixedHeight(50); - titlebar->addWidget(titleframe, Qt::AlignLeft | Qt::AlignVCenter); - titlebar->setCustomWidget(m_searchEdit, true); - - -// titlebar->move(36, 3); - m_stackWidget = new AnimationStackedWidget(); - m_stackWidget->setContentsMargins(0, 0, 0, 0); - m_stackWidget->setDuration(250); -// m_stackWidget->setMargin(0); -// m_stackWidget->setSpacing(0); - //m_stackWidget->setFixedSize(WorkViewWidth, WorkViewHeight); - createview(); - QHBoxLayout *tmainLayout = new QHBoxLayout; - tmainLayout->setMargin(0); - tmainLayout->setSpacing(0); - tmainLayout->setContentsMargins(0, 0, 0, 0); - tmainLayout->addWidget(m_stackWidget); - //mainLayout->addStretch(1); - - m_contentBackground = new DFrame; - m_contentBackground->setContentsMargins(0, 0, 0, 0); - DPalette anipa = m_contentBackground->palette(); - anipa.setColor(DPalette::Background, "#F8F8F8"); - m_contentBackground->setAutoFillBackground(true); - m_contentBackground->setPalette(anipa); - - m_schceduleSearchView = new CSchceduleSearchView(this); - //m_schceduleSearchView->setFixedWidth(200); - - QVBoxLayout *ssLayout = new QVBoxLayout; - ssLayout->setMargin(0); - ssLayout->setSpacing(0); - ssLayout->setContentsMargins(0, 10, 0, 10); - ssLayout->addWidget(m_schceduleSearchView); - m_contentBackground->setLayout(ssLayout); - tmainLayout->addWidget(m_contentBackground); -// m_contentBackground->setFixedWidth(0); - m_contentBackground->setVisible(false); - - DWidget *maincentralWidget = new DWidget(this); - - maincentralWidget->setLayout(tmainLayout); - - setCentralWidget(maincentralWidget); - //m_stackWidget->setGeometry(0, 50, 860, 584); - //m_bttongroup->button(0)->setChecked(true); - m_yearButton->setFocus(); - m_yearButton->setChecked(true); - m_transparentFrame = new DFrame(this); - m_transparentFrame->setAutoFillBackground(true); - m_transparentFrame->hide(); - - m_animation = new QPropertyAnimation(this); - -} - -void Calendarmainwindow::initConnection() -{ - connect(m_DataGetThread, - &DbusDataGetThread::signalGetScheduleSuccess, - this, - &Calendarmainwindow::slotGetScheduleInfoSuccess); - - connect(m_stackWidget - , &AnimationStackedWidget::signalIsFinished - , this - , &Calendarmainwindow::slotSetButtonBox); - connect(m_buttonBox, &DButtonBox::buttonClicked, this, &Calendarmainwindow::slotstackWClicked); - //connect(m_bttongroup, static_cast(&QButtonGroup::buttonClicked), this, &Calendarmainwindow::slotstackWClicked); - connect(m_weekWindow, &CWeekWindow::signalsWUpdateShcedule, this, &Calendarmainwindow::slotWUpdateShcedule); - connect(m_monthWindow, &CMonthWindow::signalsWUpdateShcedule, this, &Calendarmainwindow::slotWUpdateShcedule); - connect(m_DayWindow, &CDayWindow::signalsWUpdateShcedule, this, &Calendarmainwindow::slotWUpdateShcedule); - connect(m_searchEdit, &DSearchEdit::returnPressed, this, &Calendarmainwindow::slotSreturnPressed); - connect(m_searchEdit, &DSearchEdit::textChanged, this, &Calendarmainwindow::slotStextChanged); - connect(m_searchEdit, &DSearchEdit::focusChanged, this, &Calendarmainwindow::slotStextfocusChanged); - connect(m_weekWindow, &CWeekWindow::signalsReturnTodayUpdate, this, &Calendarmainwindow::slotReturnTodyUpdate); - connect(m_monthWindow, &CMonthWindow::signalsReturnTodayUpdate, this, &Calendarmainwindow::slotReturnTodyUpdate); - connect(m_DayWindow, &CDayWindow::signalsReturnTodayUpdate, this, &Calendarmainwindow::slotReturnTodyUpdate); - connect(m_yearwindow, &CYearWindow::signalsReturnTodayUpdate, this, &Calendarmainwindow::slotReturnTodyUpdate); - //监听当前应用主题切换事件 - connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &Calendarmainwindow::slotTheme); - - m_dbus = new com::deepin::daemon::calendar::Scheduler("com.deepin.daemon.Calendar", - "/com/deepin/daemon/Calendar/Scheduler", - QDBusConnection::sessionBus(), this); - connect(m_dbus, &com::deepin::daemon::calendar::Scheduler::JobsUpdated, - this, &Calendarmainwindow::slotJobsUpdated); - connect(m_schceduleSearchView, &CSchceduleSearchView::signalsUpdateShcedule, this, &Calendarmainwindow::slotTransitSearchSchedule); - connect(m_schceduleSearchView, &CSchceduleSearchView::signalDate, this, &Calendarmainwindow::slotsearchDateSelect); - connect(m_schceduleSearchView, &CSchceduleSearchView::signalSelectSchedule, - this, &Calendarmainwindow::slotSearchSelectSchedule); - connect(m_schceduleSearchView, &CSchceduleSearchView::signalScheduleHide, - this, &Calendarmainwindow::setScheduleHide); - - connect(m_yearwindow, &CYearWindow::signaldoubleclickDate, this, &Calendarmainwindow::slotdoubleclickDate); - connect(m_yearwindow, &CYearWindow::signalselectWeekwindow, this, &Calendarmainwindow::slotselectWeek); - connect(m_yearwindow, &CYearWindow::signalselectMonth, this, &Calendarmainwindow::slotselectMonth); - - connect(m_monthWindow, &CMonthWindow::signalsViewSelectDate, this, &Calendarmainwindow::slotViewSelectDate); - connect(m_monthWindow, &CMonthWindow::signalsCurrentScheduleDate, this, &Calendarmainwindow::slotCurrentScheduleDate); - connect(m_weekWindow, &CWeekWindow::signalsCurrentScheduleDate, this, &Calendarmainwindow::slotCurrentScheduleDate); - connect(m_weekWindow, &CWeekWindow::signalsViewSelectDate, this, &Calendarmainwindow::slotViewSelectDate); - connect(m_monthWindow, &CMonthWindow::signalViewtransparentFrame, this, &Calendarmainwindow::slotViewtransparentFrame); - connect(m_schceduleSearchView, &CSchceduleSearchView::signalViewtransparentFrame, this, &Calendarmainwindow::slotViewtransparentFrame); - connect(m_weekWindow, &CWeekWindow::signalViewtransparentFrame, this, &Calendarmainwindow::slotViewtransparentFrame); - connect(m_DayWindow, &CDayWindow::signalViewtransparentFrame, this, &Calendarmainwindow::slotViewtransparentFrame); - - connect(m_weekWindow, &CWeekWindow::signalCurrentDate, this, &Calendarmainwindow::slotCurrentDate); - connect(m_monthWindow, &CMonthWindow::signalCurrentDate, this, &Calendarmainwindow::slotCurrentDate); - connect(m_DayWindow, &CDayWindow::signalCurrentDate, this, &Calendarmainwindow::slotCurrentDate); - connect(m_yearwindow, &CYearWindow::signalCurrentDate, this, &Calendarmainwindow::slotCurrentDate); - - connect(m_yearwindow, - &CYearWindow::signalupdateschcedule, - this, - &Calendarmainwindow::getScheduleInfo); - - connect(m_DynamicIconUpdateTimer, - &QTimer::timeout, - this, - &Calendarmainwindow::slotDynamicIconUpdate); -} - - -void Calendarmainwindow::initLunar() -{ - QLocale locale; - bool flag = false; - if (locale.language() == QLocale::Chinese) { - flag = true; - } - m_yearwindow->setLunarVisible(flag); - m_monthWindow->setLunarVisible(flag); - m_weekWindow->setLunarVisible(flag); - m_DayWindow->setLunarVisible(flag); - //m_yearwindow->setLunarVisible(QLocale::system().name().contains("zh")); - //m_monthWindow->setLunarVisible(QLocale::system().name().contains("zh")); - //m_weekWindow->setLunarVisible(QLocale::system().name().contains("zh")); - //m_DayWindow->setLunarVisible(QLocale::system().name().contains("zh")); -} - -void Calendarmainwindow::createview() -{ - CScheduleDataManage::getScheduleDataManage()->setFirstWeekDay(0); - CScheduleDataManage::getScheduleDataManage()->setCurrentYear(QDate::currentDate().year()); - - getScheduleInfo(); - m_yearwindow = new CYearWindow(this); - m_yearwindow->setDate(QDate::currentDate()); - m_stackWidget->addWidget(m_yearwindow); -#if 1 - m_monthWindow = new CMonthWindow; - //0:周日 1~6:周一~周六 - m_monthWindow->setFirstWeekday(0); - m_monthWindow->setDate(QDate::currentDate()); - m_stackWidget->addWidget(m_monthWindow); - - m_weekWindow = new CWeekWindow(this); - m_weekWindow->setFirstWeekday(0); - m_weekWindow->setDate(QDate::currentDate()); - m_weekWindow->slotupdateSchedule(0); - m_stackWidget->addWidget(m_weekWindow); - - m_DayWindow = new CDayWindow; - QTimer::singleShot(500,[=] { - m_DayWindow->setDate(QDate::currentDate()); - }); - m_stackWidget->addWidget(m_DayWindow); -#else - CYearWindow *yearwindow1 = new CYearWindow; - yearwindow1->setDate(QDate(2014, 2, 1)); - m_stackWidget->addWidget(yearwindow1); - CYearWindow *yearwindow2 = new CYearWindow; - yearwindow2->setDate(QDate(2014, 2, 1)); - m_stackWidget->addWidget(yearwindow2); - - CYearWindow *yearwindow3 = new CYearWindow; - yearwindow3->setDate(QDate(2018, 2, 1)); - m_stackWidget->addWidget(yearwindow3); -#endif - -} - -DPushButton *Calendarmainwindow::createButon(QString name) -{ - DPushButton *button = new DPushButton(); - button->setText(name); - button->setFixedSize(50, 40); - //button->setPressIcon(DHiDPIHelper::loadNxPixmap(":/resources/icon/dde-choose30.svg") - //.scaled(50, 40)); - return button; -} - -void Calendarmainwindow::getScheduleInfo() -{ - YearScheduleInfo *info = CScheduleDataManage::getScheduleDataManage()->getGetAllYearScheduleInfo(); - m_DataGetThread->getScheduleInfo(info); -} - -void Calendarmainwindow::setScheduleHide() -{ - m_yearwindow->slotSetSchceduleHide(); - m_monthWindow->slotScheduleHide(); - m_weekWindow->slotScheduleHide(); - m_DayWindow->slotScheduleHide(); -} - -void Calendarmainwindow::resizeEvent(QResizeEvent *event) -{ - m_transparentFrame->resize(width(), height() - 50); - m_scheduleSearchViewMaxWidth = qRound(0.2325 * width() + 0.5); - m_schceduleSearchView->setMaxWidth(m_scheduleSearchViewMaxWidth); -// if (m_opensearchflag) { - setSearchWidth(m_scheduleSearchViewMaxWidth); -// } - setScheduleHide(); - DMainWindow::resizeEvent(event); - CConfigSettings::setOption("base.geometry", saveGeometry()); - CConfigSettings::setOption("base.state", int(windowState())); -} - -void Calendarmainwindow::slotstackWClicked(QAbstractButton *bt) -{ -#if 0 - int index = m_buttonBox->id(bt); - if (index < 0 || index > m_stackWidget->count() - 1) { - - return; - } - m_searchflag = false; - m_stackWidget->setCurrentIndex(index); - if (index != 0) { - m_priindex = index; - } - switch (index) { - case 0: { - m_yearwindow->slotReturnTodayUpdate(); - } - break; - case 1: { - m_monthWindow->slotReturnTodayUpdate(); - m_monthWindow->slotupdateSchedule(0); - } - break; - case 2: { - m_weekWindow->slotReturnTodayUpdate(); - m_weekWindow->slotupdateSchedule(0); - } - break; - case 3: { - m_DayWindow->slotReturnTodayUpdate(); - m_DayWindow->slotupdateSchedule(0); - m_searchflag = true; - } - break; - } - CConfigSettings::setOption("base.view", index + 1); -#endif - m_buttonBox->setEnabled(false); - setScheduleHide(); - int index = m_buttonBox->id(bt); - if (index < 0 || index > m_stackWidget->count() - 1) { - - return; - } - m_searchflag = false; - m_stackWidget->setCurrent(index); - if (index != 0) { - m_priindex = index; - } - if (m_currentdate.year() < 1900) - return; - switch (index) { - case 0: { - m_yearwindow->setDate(m_currentdate); - } - break; - case 1: { - m_monthWindow->setDate(m_currentdate); - m_monthWindow->slotupdateSchedule(0); - } - break; - case 2: { - m_weekWindow->setDate(m_currentdate); - m_weekWindow->slotupdateSchedule(1); - } - break; - case 3: { - m_DayWindow->setDate(m_currentdate); - m_DayWindow->slotupdateSchedule(1); - m_searchflag = true; - } - break; - } - CConfigSettings::setOption("base.view", index + 1); -} - -void Calendarmainwindow::slotWUpdateShcedule(QMainWindow *w, int id) -{ - Q_UNUSED(w); - Q_UNUSED(id); - if (m_opensearchflag && !m_searchEdit->text().isEmpty()) { - m_schceduleSearchView->slotsetSearch(m_searchEdit->text()); - m_yearwindow->slotupdateSchedule(0); - } - updateHigh(); - return; -} - -void Calendarmainwindow::slotReturnTodyUpdate(QMainWindow *w) -{ - if (w != m_weekWindow) - m_weekWindow->slotReturnTodayUpdate(); - if (w != m_monthWindow) - m_monthWindow->slotReturnTodayUpdate(); - if (w != m_DayWindow) - m_DayWindow->slotReturnTodayUpdate(); - if (w != m_yearwindow) - m_yearwindow->slotReturnTodayUpdate(); -} - -void Calendarmainwindow::slotSreturnPressed() -{ -#if 1 - if (!m_opensearchflag && !m_searchEdit->text().isEmpty()) { - m_opensearchflag = true; - m_contentBackground->setVisible(true); -// m_animation->setTargetObject(this); -// m_animation->setPropertyName("schedulesearchWidth"); -// m_animation->setDuration(500); -// m_animation->setStartValue(0); -// m_animation->setEndValue(m_scheduleSearchViewMaxWidth); -// m_animation->start(); - } - m_schceduleSearchView->slotsetSearch(m_searchEdit->text()); - m_yearwindow->setDate(m_currentdate); -// m_yearwindow->slotupdateSchedule(0); - updateHigh(); -#else - if (!m_searchflag) { - m_dayButton->click(); - m_searchflag = true; - } - //m_segmentedControl->setCurrentIndex(3); - //m_stackWidget->setCurrentIndex(3); - m_DayWindow->setSearchText(m_searchEdit->text()); -#endif -} - -void Calendarmainwindow::slotStextChanged() -{ - if (!m_searchEdit->text().isEmpty()) { - m_yearwindow->setSearchWFlag(true); - m_weekWindow->setSearchWFlag(true); - m_monthWindow->setSearchWFlag(true); - m_DayWindow->setSearchWFlag(true); - // m_contentBackground->setVisible(true); - } else { - m_schceduleSearchView->clearSearch(); - m_yearwindow->setSearchWFlag(false); - m_monthWindow->setSearchWFlag(false); - m_weekWindow->setSearchWFlag(false); - m_DayWindow->setSearchWFlag(false); - m_contentBackground->setVisible(false); -// m_animation->setTargetObject(this); -// m_animation->setDuration(500); -// m_animation->setEndValue(0); -// m_animation->setStartValue(m_scheduleSearchViewMaxWidth); -// m_animation->start(); - m_opensearchflag = false; - } -// m_yearwindow->setDate(m_currentdate); -// m_yearwindow->slotupdateSchedule(0); - updateHigh(); - -} - -void Calendarmainwindow::slotStextfocusChanged(bool onFocus) -{ - if (onFocus) { - setScheduleHide(); - } -} - -void Calendarmainwindow::slotJobsUpdated(const QList &Ids) -{ - Q_UNUSED(Ids); - int index = m_stackWidget->currentIndex(); - if (index < 0 || index > m_stackWidget->count() - 1) { - return; - } - switch (index) { - case 1: { - //m_monthWindow->slotReturnTodayUpdate(); - m_monthWindow->slotupdateSchedule(0); - } - break; - case 2: { - //m_weekWindow->slotReturnTodayUpdate(); - m_weekWindow->slotupdateSchedule(0); - } - break; - case 3: { - //m_DayWindow->slotReturnTodayUpdate(); - m_DayWindow->slotupdateSchedule(0); - } - break; - } -} - -void Calendarmainwindow::slotSearchEdit() -{ - m_searchEdit->lineEdit()->setFocus(); -} - -void Calendarmainwindow::slotTransitSearchSchedule(int id) -{ - Q_UNUSED(id); - getScheduleInfo(); - int index = m_stackWidget->currentIndex(); - if (index < 0 || index > m_stackWidget->count() - 1) { - - return; - } - switch (index) { - case 0: { - m_yearwindow->slotupdateSchedule(0); - } - break; - case 1: { - //m_monthWindow->slotReturnTodayUpdate(); - m_monthWindow->slotupdateSchedule(0); - } - break; - case 2: { - //m_weekWindow->slotReturnTodayUpdate(); - m_weekWindow->slotupdateSchedule(0); - } - break; - case 3: { - //m_DayWindow->slotReturnTodayUpdate(); - m_DayWindow->slotupdateSchedule(0); - } - break; - } - m_schceduleSearchView->slotsetSearch(m_searchEdit->text()); -} - -void Calendarmainwindow::slotsearchDateSelect(QDate date) -{ - setScheduleHide(); - int index = m_stackWidget->currentIndex(); - if (index < 0 || index > m_stackWidget->count() - 1) { - return; - } - switch (index) { - case 0: { - m_yearwindow->setDate(date); - } - break; - case 1: { - m_monthWindow->setDate(date); - } - break; - case 2: { - m_weekWindow->setDate(date); - } - break; - case 3: { - m_DayWindow->setDate(date); - } - break; - } -} - -void Calendarmainwindow::slotSearchSelectSchedule(const ScheduleDtailInfo &scheduleInfo) -{ - int index = m_stackWidget->currentIndex(); - if (index < 0 || index > m_stackWidget->count() - 1) { - return; - } - //等界面刷新完成后进行动作 - QTimer::singleShot(50, [this, index,scheduleInfo] { - switch (index) - { - case 0: { - } - break; - case 1: { - m_monthWindow->setSelectSchedule(scheduleInfo); - } - break; - case 2: { - m_weekWindow->setSelectSchedule(scheduleInfo); - } - break; - case 3: { - m_DayWindow->setSelectSchedule(scheduleInfo); - } - break; - } - }); - -} - -void Calendarmainwindow::slotdoubleclickDate(QDate date) -{ - m_stackWidget->setCurrentIndex(m_priindex); - switch (m_priindex) { - case 1: { - m_monthButton->setFocus(); - m_monthButton->setChecked(true); - m_monthWindow->setDate(date); - m_monthWindow->slotupdateSchedule(0); - } - break; - case 2: { - m_weekButton->setFocus(); - m_weekButton->setChecked(true); - m_weekWindow->setDate(date); - m_weekWindow->setTime(QTime::currentTime()); - m_weekWindow->slotupdateSchedule(0); - } - break; - case 3: { - m_dayButton->setFocus(); - m_dayButton->setChecked(true); - m_DayWindow->setDate(date); - m_DayWindow->setTime(QTime::currentTime()); - m_DayWindow->slotupdateSchedule(0); - } - break; - } - CConfigSettings::setOption("base.view", m_priindex+1); -} - -void Calendarmainwindow::slotselectMonth(QDate date) -{ - qDebug() << date; - viewWindow(2, QDateTime(date)); -} - -void Calendarmainwindow::slotselectWeek(QDate date) -{ - qDebug() << date; - viewWindow(3, QDateTime(date)); - CConfigSettings::setOption("base.view", m_priindex + 1); -} - -void Calendarmainwindow::slotCurrentScheduleDate(QDate date) -{ - viewWindow(4, QDateTime(date)); -} - -void Calendarmainwindow::slotViewSelectDate(QDate date) -{ - if (date.year() < 1900) return; - viewWindow(4, QDateTime(date)); -} - -void Calendarmainwindow::slotViewtransparentFrame(int type) -{ - static int showFrameCount =0; - if (type) { - m_transparentFrame->resize(width(), height() - 50); - m_transparentFrame->move(0, 50); - m_transparentFrame->show(); - ++showFrameCount; - } else { - if (showFrameCount==1) - m_transparentFrame->hide(); - --showFrameCount; - } - - int index = m_stackWidget->currentIndex(); - if (index < 0 || index > m_stackWidget->count() - 1) { - - return; - } - switch (index) { - case 0: { - m_yearwindow->setFocus(); - } - break; - case 1: { - m_monthWindow->setFocus(); - } - break; - case 2: { - m_weekWindow->setFocus(); - } - break; - case 3: { - m_DayWindow->setFocus(); - } - break; - } -} - -void Calendarmainwindow::slotCurrentDate(QDate date) -{ - m_currentdate = date; - CScheduleDataManage::getScheduleDataManage()->setCurrentYear(date.year()); - getScheduleInfo(); -} - -void Calendarmainwindow::slotSetButtonBox() -{ - m_buttonBox->setEnabled(true); -} -void Calendarmainwindow::closeEvent(QCloseEvent *event) -{ -// CConfigSettings::setOption("base.geometry", saveGeometry()); -// CConfigSettings::setOption("base.state", int(windowState())); - QWidget::closeEvent(event); -} - -void Calendarmainwindow::mouseMoveEvent(QMouseEvent *event) -{ - DMainWindow::mouseMoveEvent(event); - setScheduleHide(); -} - -void Calendarmainwindow::changeEvent(QEvent *event) -{ - DMainWindow::changeEvent(event); - if (event->type() == QEvent::ActivationChange) { - setScheduleHide(); - } -} - -void Calendarmainwindow::mousePressEvent(QMouseEvent *event) -{ - Q_UNUSED(event); - setScheduleHide(); -} - diff -Nru dde-calendar-5.7.0.4/src/calendarmainwindow.h dde-calendar-5.7.0.23/src/calendarmainwindow.h --- dde-calendar-5.7.0.4/src/calendarmainwindow.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/calendarmainwindow.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,140 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ - -#ifndef CALENDARMAINWINDOW_H -#define CALENDARMAINWINDOW_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#include "scheduledatamanage.h" -#include "animationstackedwidget.h" -#include "dbusdatagetthread.h" - -DWIDGET_USE_NAMESPACE -class CYearWindow; -class CMonthWindow; -class CWeekWindow; -class CDayWindow; -class __Scheduler; -class CSchceduleSearchView; -class Calendarmainwindow : public DMainWindow -{ - Q_OBJECT -// Q_PROPERTY(int schedulesearchWidth WRITE setSearchWidth) -public: - Calendarmainwindow(QWidget *w = nullptr); - ~Calendarmainwindow() override; - //void Invoke(const QString &mothodName, const QString &content); - bool analysisCreate(const QString &content, ScheduleDtailInfo &info); - void viewWindow(int type, QDateTime datetime); - void UpdateJob(); - void updateHigh(); - void setSearchWidth(int w); -public slots: - void slotTheme(int type); - void OpenSchedule(QString job); - void ActiveWindow(); - void RaiseWindow(); - void onViewShortcut(); - void slotmaxminViewShortcut(); - void slotGetScheduleInfoSuccess(); - void slotDynamicIconUpdate(); -private: - void initUI(); - void initConnection(); - void initLunar(); - void createview(); - DPushButton *createButon(QString name); - - void getScheduleInfo(); -protected: - void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; - void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; - void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void changeEvent(QEvent *event) Q_DECL_OVERRIDE; - void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; -private slots: - void setScheduleHide(); - void slotstackWClicked(QAbstractButton *bt); - void slotWUpdateShcedule(QMainWindow *w, int id = 0); - void slotReturnTodyUpdate(QMainWindow *w); - void slotSreturnPressed(); - void slotStextChanged(); - void slotStextfocusChanged(bool onFocus); - void slotJobsUpdated(const QList &Ids); - void slotSearchEdit(); - void slotTransitSearchSchedule(int id = 0); - void slotsearchDateSelect(QDate date); - void slotSearchSelectSchedule(const ScheduleDtailInfo &scheduleInfo); - - void slotdoubleclickDate(QDate date); - void slotselectMonth(QDate date); - void slotselectWeek(QDate date); - - void slotCurrentScheduleDate(QDate date); - void slotViewSelectDate(QDate date); - void slotViewtransparentFrame(int type); - void slotCurrentDate(QDate date); - void slotSetButtonBox(); -private: - DLabel *m_icon; - AnimationStackedWidget *m_stackWidget; - //DSegmentedControl *m_segmentedControl; - DButtonBox *m_buttonBox; - DButtonBoxButton *m_yearButton; - DButtonBoxButton *m_monthButton; - DButtonBoxButton *m_weekButton; - DButtonBoxButton *m_dayButton; - DSearchEdit *m_searchEdit; - CYearWindow *m_yearwindow; - CMonthWindow *m_monthWindow; - CWeekWindow *m_weekWindow; - CDayWindow *m_DayWindow; - __Scheduler *m_dbus; - bool m_searchflag = false; - CSchceduleSearchView *m_schceduleSearchView; - DFrame *m_contentBackground = nullptr; - int m_priindex = 3; //默认打开日视图双击 - DFrame *m_transparentFrame; - bool m_opensearchflag = false; - QDate m_currentdate; - int m_scheduleSearchViewMaxWidth; - QPropertyAnimation *m_animation; - - DbusDataGetThread *m_DataGetThread; - - QTimer *m_DynamicIconUpdateTimer; - -}; - -#endif // CALENDARMAINWINDOW_H diff -Nru dde-calendar-5.7.0.4/src/cdynamicicon.cpp dde-calendar-5.7.0.23/src/cdynamicicon.cpp --- dde-calendar-5.7.0.4/src/cdynamicicon.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/cdynamicicon.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,173 +0,0 @@ -/* -* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. -* -* Author: uniontech -* -* Maintainer: uniontech -* -* 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 -* 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 . -*/ -#include "cdynamicicon.h" - -#include -#include - - -#include -#include -#include - - -#define BackgroundRatio 0.9394 - -#define Month_X_Ratio 0.3203 -#define Month_Y_Ratio 0.1690 -#define Month_W_Ratio 0.3125 -#define Month_H_Ratio 0.15625 - -#define Day_X_Ratio 0.28125 -#define Day_Y_Ratio 0.33333 -#define Day_W_Ratio 0.4375 -#define Day_H_Ratio 0.4160 - -#define Week_X_Ratio 0.4375 -#define Week_Y_Ratio 0.728515625 -#define Week_W_Ratio 0.21875 -#define Week_H_Ratio 0.09375 - - -CDynamicIcon *CDynamicIcon::m_Icon = nullptr; -CDynamicIcon::CDynamicIcon(int width, int height) - :m_pixmap(new QPixmap(QSize(width,height))), - m_Date(), - m_Dayrenderer(new QSvgRenderer()), - m_Weekrenderer(new QSvgRenderer()), - m_Monthrenderer(new QSvgRenderer()), - m_backgroundrenderer(new QSvgRenderer()) - -{ - m_pixmap->fill(Qt::transparent); - m_Date = QDate::currentDate(); - setDate(m_Date); -} - -CDynamicIcon::~CDynamicIcon() -{ - delete m_pixmap; - m_pixmap = nullptr; - - delete m_Dayrenderer; - m_Dayrenderer = nullptr; - - delete m_Weekrenderer; - m_Weekrenderer = nullptr; - - delete m_Monthrenderer; - m_Monthrenderer = nullptr; - - delete m_backgroundrenderer; - m_backgroundrenderer = nullptr; - -} - -CDynamicIcon *CDynamicIcon::getInstance() -{ - if (nullptr == m_Icon) { - m_Icon = new CDynamicIcon(512,512); - } - return m_Icon; -} - -void CDynamicIcon::releaseInstance() -{ - if (m_Icon !=nullptr) { - delete m_Icon; - m_Icon =nullptr; - } -} - - -void CDynamicIcon::setDate(const QDate &date) -{ - m_Date = date; - QString dayfile = QString(":/resources/DynamicIcon/day%1.svg").arg(date.day()); - - m_Dayrenderer->load(dayfile); - - QString weekfile = QString(":/resources/DynamicIcon/week%1.svg").arg(date.dayOfWeek()); - m_Weekrenderer->load(weekfile); - - QString monthfile = QString(":/resources/DynamicIcon/month%1.svg").arg(date.month()); - m_Monthrenderer->load(monthfile); - - QString backgroundfile(":/resources/DynamicIcon/calendar_bg.svg"); - m_backgroundrenderer->load(backgroundfile); - - - //draw pixmap - paintPixmap(m_pixmap); - -} - -void CDynamicIcon::setIcon() -{ - QIcon icon(this->getPixmap()); - qApp->setProductIcon(icon); - if (qApp->aboutDialog() != nullptr) - qApp->aboutDialog()->setProductIcon(icon); - - m_Titlebar->setIcon(icon); -} - -void CDynamicIcon::setTitlebar(DTitlebar *titlebar) -{ - m_Titlebar = titlebar; -} - -void CDynamicIcon::paintPixmap(QPixmap *pixmap) -{ - QPainter painter(pixmap); - - //draw background - qreal backgroundwidget = pixmap->size().width() * BackgroundRatio; - qreal backgroundheigth = pixmap->size().height() * BackgroundRatio; - QRectF backgroundRect = QRectF((pixmap->size().width()-backgroundwidget)/2, - (pixmap->size().height()-backgroundheigth)/2, - backgroundwidget, - backgroundheigth); - m_backgroundrenderer->render(&painter,backgroundRect); - - //draw month - qreal month_x = pixmap->size().width() * Month_X_Ratio; - qreal month_y = pixmap->size().width() * Month_Y_Ratio; - qreal month_w = pixmap->size().width() * Month_W_Ratio; - qreal month_h = pixmap->size().width() * Month_H_Ratio; - m_Monthrenderer->render(&painter,QRectF(month_x,month_y,month_w,month_h)); - - //draw day - qreal day_x = pixmap->size().width() * Day_X_Ratio; - qreal day_y = pixmap->size().width() * Day_Y_Ratio; - qreal day_w = pixmap->size().width() * Day_W_Ratio; - qreal day_h = pixmap->size().width() * Day_H_Ratio; - m_Dayrenderer->render(&painter,QRectF(day_x,day_y,day_w,day_h)); - - //draw week - qreal week_x = pixmap->size().width() * Week_X_Ratio; - qreal week_y = pixmap->size().width() * Week_Y_Ratio; - qreal week_w = pixmap->size().width() * Week_W_Ratio; - qreal week_h = pixmap->size().width() * Week_H_Ratio; - m_Weekrenderer->render(&painter,QRectF(week_x,week_y,week_w,week_h)); - - painter.end(); -} diff -Nru dde-calendar-5.7.0.4/src/cdynamicicon.h dde-calendar-5.7.0.23/src/cdynamicicon.h --- dde-calendar-5.7.0.4/src/cdynamicicon.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/cdynamicicon.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ -/* -* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. -* -* Author: uniontech -* -* Maintainer: uniontech -* -* 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 -* 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 . -*/ -#ifndef CDYNAMICICON_H -#define CDYNAMICICON_H - -#include -#include -#include -#include - -#include -#include -DWIDGET_USE_NAMESPACE -DCORE_USE_NAMESPACE - -class CDynamicIcon -{ -private: - CDynamicIcon(int width, int height); - ~CDynamicIcon(); -public: - static CDynamicIcon *getInstance(); - static void releaseInstance(); -public: - void setDate(const QDate &date); - QDate getDate() const - { - return m_Date; - } - void setIcon(); - void setTitlebar(DTitlebar *titlebar); - QPixmap getPixmap() const - { - return *m_pixmap; - } -public: - static CDynamicIcon *m_Icon; -private: - void paintPixmap(QPixmap *pixmap); -private: - QPixmap *m_pixmap; - QDate m_Date; - - QSvgRenderer *m_Dayrenderer; - QSvgRenderer *m_Weekrenderer; - QSvgRenderer *m_Monthrenderer; - QSvgRenderer *m_backgroundrenderer; - - DTitlebar *m_Titlebar {nullptr}; - - -}; - -#endif // CDYNAMICICON_H diff -Nru dde-calendar-5.7.0.4/src/CMakeLists.txt dde-calendar-5.7.0.23/src/CMakeLists.txt --- dde-calendar-5.7.0.4/src/CMakeLists.txt 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -cmake_minimum_required(VERSION 3.7) - -set(BIN_NAME dde-calendar) - -configure_file(environments.h.in environments.h @ONLY) - -set(SRCS -./environments.h -./weekindicator.h -./spinner.h -./calendarwindow.h -./infoview.h -./calendardbus.h -./dbuscalendar_adaptor.h -./calendarview.h -./constants.h -./weekindicator.cpp -./spinner.cpp -./infoview.cpp -./calendardbus.cpp -./calendarview.cpp -./main.cpp -./dbuscalendar_adaptor.cpp -./calendarwindow.cpp -) - -set(QRC -./resources.qrc -) - -# Find the library -find_package(PkgConfig REQUIRED) -find_package(Qt5Widgets REQUIRED) -find_package(Qt5Concurrent REQUIRED) -find_package(Qt5DBus REQUIRED) -find_package(DtkWidget REQUIRED) - -add_executable(${BIN_NAME} ${SRCS} ${QRC}) -target_include_directories(${BIN_NAME} PUBLIC - ${DtkWidget_INCLUDE_DIRS} - ${Qt5Gui_PRIVATE_INCLUDE_DIRS} - ${PROJECT_BINARY_DIR} -) - -target_link_libraries(${BIN_NAME} PRIVATE - ${DtkWidget_LIBRARIES} - ${Qt5Widgets_LIBRARIES} - ${Qt5Concurrent_LIBRARIES} - ${Qt5DBus_LIBRARIES} -) - -# bin -install(TARGETS ${BIN_NAME} DESTINATION bin) diff -Nru dde-calendar-5.7.0.4/src/configsettings.cpp dde-calendar-5.7.0.23/src/configsettings.cpp --- dde-calendar-5.7.0.4/src/configsettings.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/configsettings.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -22,19 +22,21 @@ #include "configsettings.h" #include +#include #include #include -#include - #include #include -#include + +#include + DCORE_USE_NAMESPACE; + QPointer CConfigSettings::m_settings = nullptr; -CConfigSettings::CConfigSettings(QObject *parent) : - QObject(parent) +CConfigSettings::CConfigSettings(QObject *parent) + : QObject(parent) { } diff -Nru dde-calendar-5.7.0.4/src/configsettings.h dde-calendar-5.7.0.23/src/configsettings.h --- dde-calendar-5.7.0.4/src/configsettings.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/configsettings.h 2020-11-03 09:03:22.000000000 +0000 @@ -22,6 +22,7 @@ #pragma once #include "singleton.h" + #include class CConfigSettings : public QObject, public DCalendar::DSingleton diff -Nru dde-calendar-5.7.0.4/src/constants.h dde-calendar-5.7.0.23/src/constants.h --- dde-calendar-5.7.0.4/src/constants.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/constants.h 2020-11-03 09:03:22.000000000 +0000 @@ -29,8 +29,51 @@ static const int CellHighlightWidth = 80; static const int CellHighlightHeight = 70; -} + +static const int QueryEarliestYear = 1900; +static const int QueryLatestYear = 9999; + +static const int FestivalTypeID = 4; + +static const int FontSizeEleven = 11; +static const int FontSizeTwelve = 12; +static const int FontSizeFourteen = 14; +static const int FontSizeSixteen = 16; +static const int FontSizeTwentyfour = 24; +static const int FontSizeTwenty = 20; +static const int FontSizeTen = 10; +static const int FontSizeOneHundred = 100; + +static const int CalendarYearWindow = 0; +static const int CalendarMonthWindow = 1; +static const int CalendarWeekWindow = 2; +static const int CalendarDayWindow = 3; + +static const int ThirtyMinutesWithSec = 1800; + +static const int AtTimeOfEvent = 0; +static const int OnStartDay = 0; +static const int FifteenMinutesBefore = 15; +static const int ThirtyMinutesBefore = 30; +static const int OneHourBefore = 60; +static const int OneDayBeforeWithDay = 1; +static const int OneDayBeforeWithMinutes = 1440; +static const int TwoDayBeforeWithDay = 2; +static const int TwoDayBeforeWithMinutes = 2880; +static const int OneWeekBeforeWithDay = 7; +static const int OneWeekBeforeWithMinutes = 10080; + +static const int NewSchceduleLabelWidth = 70; + +static const int QuarterOfAnhourWithMinute = 15; + +} // namespace DDECalendar namespace DDEYearCalendar { + +static const int RectSizeofEveyMonth = 42; +static const int FrameSizeofEveryYear = 12; + +static const int YearScheduleListMaxcount = 5; static const int YHeaderItemWidth = 20; static const int YHeaderItemHeight = 16; @@ -41,10 +84,18 @@ static const int YCellHighlightHeight = 20; static const int Y_MLableHeight = 36; static const int Y_YLableHeight = 45; + static const int Y_MWindowWidth = 202; static const int Y_MWindowHeight = 159; -} +} // namespace DDEYearCalendar namespace DDEMonthCalendar { +static const int ItemSizeofMonthDay = 42; + +static const int AFewDaysofWeek = 7; +static const int LinesNumofMonth = 6; + +static const int MonthNumofYear = 12; + static const int MHeaderItemWidth = 60; static const int MHeaderItemHeight = 33; static const int MEventsItemHeight = 36; @@ -71,12 +122,16 @@ static const int M_MWindowWidth = 202; static const int M_MWindowHeight = 162; - - } namespace DDEWeekCalendar { +static const int FirstDayofWeekend = 6; +static const int AFewDaysofWeek = 7; + +static const int NumWeeksDisplayed = 10; + static const int WCellHeaderItemWidth = 109; static const int WCellHeaderItemHeight = 54; + static const int WMCellHeadrWidth = 80; static const int MCellHighlightWidth = 120; @@ -96,6 +151,8 @@ static const int W_MWindowHeight = 162; } namespace DDEDayCalendar { +static const int PainterCellNum = 42; + static const int DCellWidth = 35; static const int DCellHeight = 28; diff -Nru dde-calendar-5.7.0.4/src/creatorparschedule.cpp dde-calendar-5.7.0.23/src/creatorparschedule.cpp --- dde-calendar-5.7.0.4/src/creatorparschedule.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/creatorparschedule.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,320 +0,0 @@ -/* - * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ - -/* - * This file was generated by qdbusxml2cpp version 0.8 - * Command line was: qdbusxml2cpp -c DCalendarDBus -p dcalendardbus com.deepin.api.LunarCalendar.xml - * - * qdbusxml2cpp is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). - * - * This is an auto-generated file. - * This file may have been hand-edited. Look for HAND-EDIT comments - * before re-generating it. - */ - -#include "creatorparschedule.h" -#include "scheduledatamanage.h" -CreatOrParSchedule::CreatOrParSchedule() -{ - -} - -CreatOrParSchedule::~CreatOrParSchedule() -{ - -} -QString CreatOrParSchedule::createScheduleDtailInfojson(const ScheduleDtailInfo &info) -{ - QJsonObject json; - json.insert("ID", info.id); - json.insert("AllDay", info.allday); - json.insert("Remind", createScheduleRemind(info)); - json.insert("RRule", createScheduleRRule(info)); - json.insert("Title", info.titleName); - json.insert("Description", info.description); - json.insert("Type", info.type.ID); - json.insert("Start", toconvertData(info.beginDateTime)); - json.insert("End", toconvertData(info.endDateTime)); - //json.insert("Start", "2006-01-02T15:04:05+07:00"); - //json.insert("End", "2006-01-02T17:04:05+07:00"); - json.insert("RecurID", info.RecurID); - QJsonArray jsonarry; - for (int i = 0; i < info.ignore.count(); i++) { - jsonarry.append(toconvertData(info.ignore.at(i))); - } - json.insert("Ignore", jsonarry); - // 构建 JSON 文档 - QJsonDocument document; - document.setObject(json); - QByteArray byteArray = document.toJson(QJsonDocument::Compact); - QString strJson(byteArray); - return strJson; -} - -QString CreatOrParSchedule::createScheduleTypejson(const ScheduleType &info) -{ - QJsonObject json; - json.insert("ID", info.ID); - json.insert("Name", info.typeName); - QString colorName = QString("#%1%2%3").arg(info.color.red(), 2, 16, QChar('0')).arg(info.color.green(), 2, 16, QChar('0')).arg(info.color.blue(), 2, 16, QChar('0')); - json.insert("Color", info.color.name()); - // 构建 JSON 文档 - QJsonDocument document; - document.setObject(json); - QByteArray byteArray = document.toJson(QJsonDocument::Compact); - QString strJson(byteArray); - return strJson; -} - -ScheduleType CreatOrParSchedule::parsingScheduleTypejson(QJsonObject &object) -{ - ScheduleType type; - QJsonObject &rootObj = object; - - //因为是预先定义好的JSON数据格式,所以这里可以这样读取 - if (rootObj.contains("ID")) { - type.ID = rootObj.value("ID").toInt(); - } - if (rootObj.contains("Name")) { - type.typeName = rootObj.value("Name").toString(); - } - if (rootObj.contains("Color")) { - QString str = rootObj.value("Color").toString(); - type.color = QColor(rootObj.value("Color").toString()); - } - return type; -} - -ScheduleDtailInfo CreatOrParSchedule::parsingScheduleDtailInfojsonID(QJsonObject &obj) -{ - - ScheduleDtailInfo info; - - QJsonObject &rootObj = obj; - //因为是预先定义好的JSON数据格式,所以这里可以这样读取 - if (rootObj.contains("ID")) { - info.id = rootObj.value("ID").toInt(); - } - if (rootObj.contains("AllDay")) { - info.allday = rootObj.value("AllDay").toBool(); - } - if (rootObj.contains("Remind")) { - parsingScheduleRemind(rootObj.value("Remind").toString(), info); - } - if (rootObj.contains("Title")) { - info.titleName = rootObj.value("Title").toString(); - } - if (rootObj.contains("Description")) { - info.description = rootObj.value("Description").toString(); - } - if (rootObj.contains("Type")) { - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->GetType(rootObj.value("Type").toInt(), info.type); - } - if (rootObj.contains("Start")) { - info.beginDateTime = fromconvertData(rootObj.value("Start").toString()); - } - if (rootObj.contains("End")) { - info.endDateTime = fromconvertData(rootObj.value("End").toString()); - } - if (rootObj.contains("RecurID")) { - info.RecurID = rootObj.value("RecurID").toInt(); - } - if (rootObj.contains("RRule")) { - parsingScheduleRRule(rootObj.value("RRule").toString(), info); - } - if (rootObj.contains("Ignore")) { - QJsonArray subArray = rootObj.value("Ignore").toArray(); - for (int i = 0; i < subArray.size(); i++) { - QString subObj = subArray.at(i).toString(); - info.ignore.append(fromconvertData(subObj)); - } - } - return info; -} - -QString CreatOrParSchedule::createScheduleRRule(const ScheduleDtailInfo &info) -{ - if (info.rpeat == 0) return QString(); - // QString str = "'"; - QString str; - switch (info.rpeat) { - case 1: { - str += "FREQ=DAILY"; - } - break; - case 2: { - str += "FREQ=DAILY;BYDAY=MO,TU,WE,TH,FR"; - } - break; - case 3: { - str += "FREQ=WEEKLY"; - } - break; - case 4: { - str += "FREQ=MONTHLY"; - } - break; - case 5: { - str += "FREQ=YEARLY"; - } - break; - } - switch (info.enddata.type) { - case 1: { - str += QString(";COUNT=%1").arg(info.enddata.tcount + 1); - } - break; - case 2: { - QDateTime datetime = info.enddata.date.addDays(-1); - //datetime.setDate(datetime); - str += ";UNTIL=" + datetime.toString("yyyyMMddThhmmss") + "Z"; - // str += ";UNTIL=" + toconvertData(datetime); - } - break; - } - //str += "'"; - return str; -} - -void CreatOrParSchedule::parsingScheduleRRule(QString str, ScheduleDtailInfo &info) -{ - if (str.isEmpty()) { - info.rpeat = 0; - return; - } - QString rrulestrs = str; - QStringList rruleslist = rrulestrs.split(";", QString::SkipEmptyParts); - if (rruleslist.count() > 0) { - if (rruleslist.contains("FREQ=DAILY") && rruleslist.contains("BYDAY=MO,TU,WE,TH,FR")) info.rpeat = 2; - else if (rruleslist.contains("FREQ=DAILY") ) { - info.rpeat = 1; - } else if (rruleslist.contains("FREQ=WEEKLY") ) { - info.rpeat = 3; - } else if (rruleslist.contains("FREQ=MONTHLY") ) { - info.rpeat = 4; - } else if (rruleslist.contains("FREQ=YEARLY") ) { - info.rpeat = 5; - } - info.enddata.type = 0; - for (int i = 0; i < rruleslist.count(); i++) { - if (rruleslist.at(i).contains("COUNT=")) { - QStringList liststr = rruleslist.at(i).split("=", QString::SkipEmptyParts); - info.enddata.type = 1; - info.enddata.tcount = liststr.at(1).toInt() - 1; - } - - if (rruleslist.at(i).contains("UNTIL=")) { - QStringList liststr = rruleslist.at(i).split("=", QString::SkipEmptyParts); - info.enddata.type = 2; - info.enddata.date = QDateTime::fromString(liststr.at(1).left(liststr.at(1).count() - 1), "yyyyMMddThhmmss"); - //info.enddata.date = fromconvertData(liststr.at(1)); - info.enddata.date = info.enddata.date.addDays(1); - } - } - } -} - -QString CreatOrParSchedule::createScheduleRemind(const ScheduleDtailInfo &info) -{ - if (!info.remind) return QString(); - QString str; - if (info.allday) { - str = QString::number(info.remindData.n) + ";" + info.remindData.time.toString("hh:mm"); - } else { - str = QString::number(info.remindData.n); - } - return str; -} - -void CreatOrParSchedule::parsingScheduleRemind(QString str, ScheduleDtailInfo &info) -{ - if (str.isEmpty()) { - info.remind = false; - return; - } - info.remind = true; - if (info.allday) { - QStringList liststr = str.split(";", QString::SkipEmptyParts); - info.remindData.n = liststr.at(0).toInt(); - info.remindData.time = QTime::fromString(liststr.at(1), "hh:mm"); - } else { - info.remindData.n = str.toInt(); - } -} - -QString CreatOrParSchedule::toconvertData(QDateTime date) -{ - QDateTime datetimeutc11 = date; - datetimeutc11.setTimeSpec(Qt::UTC); - QString strss = datetimeutc11.toString(Qt::ISODate); - datetimeutc11.setTimeSpec(Qt::OffsetFromUTC); - strss = datetimeutc11.toString(Qt::ISODateWithMs); - QDateTime datetimeutc = QDateTime::fromTime_t(0); - QString str = date.toString("yyyy-MM-ddThh:mm:ss") + "+" + datetimeutc.toString("hh:mm"); - //QString str = date.toString("yyyy-MM-ddThh:mm:ss") + "Z07:00"; - return str; -} - -QDateTime CreatOrParSchedule::fromconvertData(QString str) -{ - QStringList liststr = str.split("+", QString::SkipEmptyParts); - return QDateTime::fromString(liststr.at(0), "yyyy-MM-ddThh:mm:ss"); -} - -QString CreatOrParSchedule::toconvertIGData(QDateTime date) -{ - QDateTime datetimeutc11 = date; - datetimeutc11.setTimeSpec(Qt::UTC); - QString strss = datetimeutc11.toString(Qt::ISODate); - datetimeutc11.setTimeSpec(Qt::OffsetFromUTC); - strss = datetimeutc11.toString(Qt::ISODateWithMs); - QDateTime datetimeutc = QDateTime::fromTime_t(0); - QString str = date.toString("yyyy-MM-ddThh:mm:ss") + "Z" + datetimeutc.toString("hh:mm"); - //QString str = date.toString("yyyy-MM-ddThh:mm:ss") + "Z07:00"; - return str; -} - -QDateTime CreatOrParSchedule::fromconvertiIGData(QString str) -{ - QStringList liststr = str.split("Z", QString::SkipEmptyParts); - return QDateTime::fromString(liststr.at(0), "yyyy-MM-ddThh:mm:ss"); -} - -QString CreatOrParSchedule::CreateJob(const ScheduleDtailInfo &info) -{ - QString str = createScheduleDtailInfojson(info); - return str; -} - -bool CreatOrParSchedule::GetJob(QString str, ScheduleDtailInfo &out) -{ - QJsonParseError json_error; - QJsonDocument jsonDoc(QJsonDocument::fromJson(str.toLocal8Bit(), &json_error)); - - if (json_error.error != QJsonParseError::NoError) { - return false; - } - - QJsonObject ssubObj = jsonDoc.object(); - out = parsingScheduleDtailInfojsonID(ssubObj); - - return true; -} - - diff -Nru dde-calendar-5.7.0.4/src/creatorparschedule.h dde-calendar-5.7.0.23/src/creatorparschedule.h --- dde-calendar-5.7.0.4/src/creatorparschedule.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/creatorparschedule.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ - -/* - * This file was generated by qdbusxml2cpp version 0.8 - * Command line was: qdbusxml2cpp -c DCalendarDBus -p dcalendardbus com.deepin.api.LunarCalendar.xml - * - * qdbusxml2cpp is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). - * - * This is an auto-generated file. - * Do not edit! All changes made to it will be lost. - */ - -#ifndef CreatOrParSchedule_H -#define CALENDARDBUS_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "schedulestructs.h" -/* - * Proxy class for interface com.deepin.api.LunarCalendar - */ -class CreatOrParSchedule -{ - -public: - static QString createScheduleDtailInfojson(const ScheduleDtailInfo &info); - static QString createScheduleTypejson(const ScheduleType &info); - static ScheduleType parsingScheduleTypejson(QJsonObject &object); - static ScheduleDtailInfo parsingScheduleDtailInfojsonID(QJsonObject &obj); - static QString createScheduleRRule(const ScheduleDtailInfo &info); - static void parsingScheduleRRule(QString str, ScheduleDtailInfo &info); - static QString createScheduleRemind(const ScheduleDtailInfo &info); - static void parsingScheduleRemind(QString str, ScheduleDtailInfo &info); - static QString toconvertData(QDateTime date); - static QDateTime fromconvertData(QString str); - static QString toconvertIGData(QDateTime date); - static QDateTime fromconvertiIGData(QString str); - static QString CreateJob(const ScheduleDtailInfo &info); - static bool GetJob(QString str, ScheduleDtailInfo &out); -private: - CreatOrParSchedule(); - ~CreatOrParSchedule(); -}; -#endif diff -Nru dde-calendar-5.7.0.4/src/customframe.cpp dde-calendar-5.7.0.23/src/customframe.cpp --- dde-calendar-5.7.0.4/src/customframe.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/customframe.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,169 +0,0 @@ -/* -* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. -* -* Author: uniontech -* -* Maintainer: uniontech -* -* 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 -* 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 . -*/ -#include "customframe.h" -#include -#include -#include -DGUI_USE_NAMESPACE -CustomFrame::CustomFrame(QWidget *parent): QFrame (parent) -{ -// m_font.setFamily("SourceHanSansSC"); - m_font.setWeight(QFont::Medium); - m_font.setPixelSize(14); - this->setAttribute(Qt::WA_TranslucentBackground);//设置窗口背景透明 - this->setWindowFlags(Qt::FramelessWindowHint); //设置无边框窗口 - setContentsMargins(0, 0, 0, 0); -} - -void CustomFrame::setBColor(QColor normalC) -{ - m_bnormalColor = normalC; - m_bflag = true; - update(); -} - -void CustomFrame::setRoundState(bool lstate, bool tstate, bool rstate, bool bstate) -{ - m_lstate = lstate; - m_tstate = tstate; - m_rstate = rstate; - m_bstate = bstate; -} - -void CustomFrame::setTextStr(QFont font, QColor tc, QString strc, int flag) -{ - m_font = font; - m_tnormalColor = tc; - m_text = strc; - m_textflag = flag; -} - -void CustomFrame::setTextStr(QString strc) -{ - m_text = strc; - if (!m_fixsizeflag) { - QFontMetrics fm(m_font); - int w = fm.width(m_text); - setMinimumWidth(w); - } - update(); -} - -void CustomFrame::setTextColor(QColor tc) -{ - m_tnormalColor = tc; - update(); -} - -void CustomFrame::setTextFont(QFont font) -{ - m_font = font; - if (!m_fixsizeflag) { - QFontMetrics fm(m_font); - int w = fm.width(m_text); - setMinimumWidth(w); - } -} - -void CustomFrame::setTextAlign(int flag) -{ - m_textflag = flag; -} - -void CustomFrame::setRadius(int radius) -{ - m_radius = radius; -} - -void CustomFrame::setboreder(int framew) -{ - m_borderframew = framew; -} - -void CustomFrame::setFixedSize(int w, int h) -{ - m_fixsizeflag = true; - QFrame::setFixedSize(w, h); -} - -void CustomFrame::paintEvent(QPaintEvent *e) -{ - int labelwidth = width() - 2 * m_borderframew; - int labelheight = height() - 2 * m_borderframew; - - QPainter painter(this); - QRect fillRect = QRect(m_borderframew, m_borderframew, labelwidth, labelheight); - if (m_bflag) { - painter.save(); - painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; - painter.setBrush(QBrush(m_bnormalColor)); - painter.setPen(Qt::NoPen); - QPainterPath painterPath; - painterPath.moveTo(m_radius, m_borderframew); - if (m_lstate) { - painterPath.arcTo(QRect(m_borderframew, m_borderframew, m_radius * 2, m_radius * 2), 90, 90); - } else { - painterPath.lineTo(m_borderframew, m_borderframew); - painterPath.lineTo(m_borderframew, m_radius); - } - painterPath.lineTo(0, labelheight - m_radius); - if (m_bstate) { - painterPath.arcTo(QRect(m_borderframew, labelheight - m_radius * 2, m_radius * 2, m_radius * 2), 180, 90); - } else { - painterPath.lineTo(m_borderframew, labelheight); - painterPath.lineTo(m_radius, labelheight); - } - painterPath.lineTo(labelwidth - m_radius, labelheight); - if (m_rstate) { - painterPath.arcTo(QRect(labelwidth - m_radius * 2, labelheight - m_radius * 2, m_radius * 2, m_radius * 2), 270, 90); - } else { - painterPath.lineTo(labelwidth, labelheight); - painterPath.lineTo(labelwidth, labelheight - m_radius); - } - painterPath.lineTo(labelwidth, m_radius); - //painterPath.moveTo(labelwidth, m_radius); - if (m_tstate) { - - painterPath.arcTo(QRect(labelwidth - m_radius * 2, m_borderframew, m_radius * 2, m_radius * 2), 0, 90); - - } else { - painterPath.lineTo(labelwidth, m_borderframew); - painterPath.lineTo(labelwidth - m_radius, m_borderframew); - } - painterPath.lineTo(m_radius, m_borderframew); - painterPath.closeSubpath(); - painter.drawPath(painterPath); - painter.restore(); - } - - - if (!m_text.isEmpty()) { - painter.save(); - painter.setRenderHints(QPainter::HighQualityAntialiasing); - painter.setFont(m_font); - painter.setPen(m_tnormalColor); - //painter.setPen(Qt::NoPen); - painter.drawText(fillRect, m_textflag, m_text); - painter.restore(); - } - QFrame::paintEvent(e); -} - diff -Nru dde-calendar-5.7.0.4/src/customframe.h dde-calendar-5.7.0.23/src/customframe.h --- dde-calendar-5.7.0.4/src/customframe.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/customframe.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -/* -* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. -* -* Author: uniontech -* -* Maintainer: uniontech -* -* 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 -* 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 . -*/ -#ifndef CustomFrame_H -#define CustomFrame_H - -#include - -class CustomFrame : public QFrame -{ - Q_OBJECT -public: - CustomFrame(QWidget *parent = nullptr); - void setBColor(QColor normalC); - void setRoundState(bool lstate, bool tstate, bool rstate, bool bstate); - void setTextStr(QFont font, QColor tc, QString strc, int flag = Qt::AlignCenter); - void setTextStr(QString strc); - void setTextColor(QColor tc); - void setTextFont(QFont font); - void setTextAlign(int flag = Qt::AlignCenter); - void setRadius(int radius = 8); - void setboreder(int framew = 0); - QString getTextStr() - { - return m_text; - } - void setFixedSize(int w, int h); -protected: - void paintEvent ( QPaintEvent *e); -private: - QColor m_bnormalColor = "#FFFFFF"; - QColor m_tnormalColor = "#000000"; - QFont m_font; - bool m_bflag = false; - bool m_fixsizeflag = false; - int m_textflag = Qt::AlignCenter;//对齐方式 - QString m_text; - int m_radius = 8; - int m_borderframew = 0; - bool m_lstate = false; - bool m_tstate = false; - bool m_rstate = false; - bool m_bstate = false; -}; - -#endif // TODYBUTTON_H diff -Nru dde-calendar-5.7.0.4/src/customWidget/animationstackedwidget.cpp dde-calendar-5.7.0.23/src/customWidget/animationstackedwidget.cpp --- dde-calendar-5.7.0.4/src/customWidget/animationstackedwidget.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/customWidget/animationstackedwidget.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,276 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "animationstackedwidget.h" + +#include + +AnimationStackedWidget::AnimationStackedWidget(const AnimationOri ori, QWidget *parent) + : QStackedWidget(parent) + , m_animationOri(ori) + , m_Animation(new QPropertyAnimation(this,"offset")) +{ + setDuration(1000); + connect(m_Animation + , &QPropertyAnimation::finished + , this + , &AnimationStackedWidget::animationFinished); +} + +AnimationStackedWidget::~AnimationStackedWidget() +{ + delete m_Animation; +} + +void AnimationStackedWidget::setDuration(int duration) +{ + m_Duration = duration; + m_Animation->setEasingCurve(QEasingCurve::InOutQuad); +} + +void AnimationStackedWidget::paintEvent(QPaintEvent *e) +{ + Q_UNUSED(e); + if ( m_IsAnimation ) { + QPainter paint(this); + paintCurrentWidget(paint, currentIndex()); + paintNextWidget(paint, m_NextIndex); + } +} + +void AnimationStackedWidget::animationFinished() +{ + m_IsAnimation = false; + this->widget(currentIndex())->show(); + setCurrentIndex(m_NextIndex); + emit signalIsFinished(); +} + +void AnimationStackedWidget::setCurrent(int index) +{ + //设置移动方向 + m_moveOri = getMoveOrientation(currentIndex(),index); + setCurrentWidget(index,getBeginValue()); +} + +void AnimationStackedWidget::setPre() +{ + //获取堆窗口数 + const int count = this->count(); + switch (m_animationOri) { + case LR: { + m_moveOri = LeftToRight; + } + break; + case TB: { + m_moveOri = TopToBottom; + } + break; + } + //获取下一个窗口编号 + int nextIndex = currentIndex() - 1; + if(nextIndex < 0){ + nextIndex = nextIndex + count; + } + setCurrentWidget(nextIndex,getBeginValue()); +} + +void AnimationStackedWidget::setNext() +{ + //获取堆窗口数 + const int count = this->count(); + switch (m_animationOri) { + case LR: { + m_moveOri = RightToLeft; + } + break; + case TB: { + m_moveOri = BottomToTop; + } + break; + } + //获取下一个窗口编号 + int nextIndex = (currentIndex() + 1) % count; + setCurrentWidget(nextIndex,getBeginValue()); +} + +void AnimationStackedWidget::setCurrentWidget(int &index,int beginWidth) +{ + //如果正在动画,那么退出 + if ( m_IsAnimation ) { + return; + } + //如果索引为当前索引则退出 + if(index == currentIndex()){ + emit signalIsFinished(); + return; + } + m_IsAnimation = true; + m_NextIndex = index; + //隐藏当前的widget + this->widget(currentIndex())->hide(); + m_Animation->setStartValue(beginWidth); + m_Animation->setEndValue(0); + m_Animation->setDuration(m_Duration); + m_Animation->start(); +} + +int AnimationStackedWidget::getBeginValue() +{ + //存储窗口高度或宽度 + int value {0}; + //获取窗口矩阵 + QRect widgetRect = this->rect(); + switch (m_animationOri) { + case LR: { + value = widgetRect.width(); + } + break; + case TB: { + value = widgetRect.height(); + } + } + return value; +} + +AnimationStackedWidget::MoveOrientation AnimationStackedWidget::getMoveOrientation(const int currIndex, const int nextIndex) +{ + MoveOrientation moveOri{LeftToRight}; + if (nextIndex < currIndex) { + switch (m_animationOri) { + case LR: { + moveOri = LeftToRight; + } + break; + case TB: { + moveOri = TopToBottom; + } + break; + } + } else if (nextIndex > currIndex) { + switch (m_animationOri) { + case LR: { + moveOri = RightToLeft; + } + break; + case TB: { + moveOri = BottomToTop; + } + break; + } + } + return moveOri; +} + +void AnimationStackedWidget::paintCurrentWidget(QPainter &paint, int currentIndex) +{ + //获得当前页面的Widget + QWidget *currentWidget = widget(currentIndex); + QPixmap currentPixmap(currentWidget->size()); + //将当前窗口绘制到pixmap中 + currentWidget->render(¤tPixmap); + QRect widgetRect = this->rect(); + //绘制当前的Widget + double value = m_offset; + //窗口宽度 + const int widgetWidth = widgetRect.width(); + //窗口高度 + const int widgetHeigth = widgetRect.height(); + QRectF targetRect; + QRectF sourceRect; + switch (m_moveOri) { + case LeftToRight:{ + targetRect = QRectF(widgetWidth - value, 0, value, widgetHeigth); + sourceRect = QRectF(0.0, 0.0, value, widgetHeigth); + } + break; + case RightToLeft:{ + targetRect = QRectF(0.0, 0.0, value, widgetHeigth); + sourceRect = QRectF(widgetWidth - value, 0, value, widgetHeigth); + } + break; + case TopToBottom:{ + targetRect = QRectF(0.0, widgetHeigth - value, widgetWidth, value); + sourceRect = QRectF(0.0, 0.0, widgetWidth, value); + } + break; + case BottomToTop:{ + targetRect = QRectF(0.0, 0.0, widgetWidth, value); + sourceRect = QRectF( 0, widgetHeigth - value, widgetWidth, value); + } + break; + } + paint.drawPixmap(targetRect, + currentPixmap, + sourceRect); +} + +void AnimationStackedWidget::paintNextWidget(QPainter &paint, int nextIndex) +{ + QWidget *nextWidget = widget(nextIndex); + QRect widgetRect = this->rect(); + //设置下一个窗口的大小 + nextWidget->resize(widgetRect.width(), widgetRect.height()); + QPixmap nextPixmap(nextWidget->size()); + nextWidget->render(&nextPixmap); + double value = m_offset; + //窗口宽度 + const int widgetWidth = widgetRect.width(); + //窗口高度 + const int widgetHeigth = widgetRect.height(); + QRectF targetRect; + QRectF sourceRect; + switch (m_moveOri) { + case LeftToRight:{ + targetRect = QRectF(0.0, 0.0, widgetWidth - value, widgetHeigth); + sourceRect = QRectF(value, 0.0, widgetWidth - value, widgetHeigth); + } + break; + case RightToLeft:{ + targetRect = QRectF(value, 0.0, widgetWidth - value, widgetHeigth); + sourceRect = QRectF(0.0, 0.0, widgetWidth - value, widgetHeigth); + } + break; + case TopToBottom:{ + targetRect = QRectF(0.0, 0.0, widgetWidth, widgetHeigth - value); + sourceRect = QRectF(0.0, value, widgetWidth, widgetHeigth - value); + } + break; + case BottomToTop:{ + targetRect = QRectF(0.0, value, widgetWidth, widgetHeigth - value); + sourceRect = QRectF(0.0, 0.0, widgetWidth, widgetHeigth - value); + } + break; + } + paint.drawPixmap(targetRect, + nextPixmap, + sourceRect); +} + +double AnimationStackedWidget::offset() const +{ + return m_offset; +} + +void AnimationStackedWidget::setOffset(double offset) +{ + m_offset = offset; + update(); +} diff -Nru dde-calendar-5.7.0.4/src/customWidget/animationstackedwidget.h dde-calendar-5.7.0.23/src/customWidget/animationstackedwidget.h --- dde-calendar-5.7.0.4/src/customWidget/animationstackedwidget.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/customWidget/animationstackedwidget.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,157 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef AnimationStackedWidget_H +#define AnimationStackedWidget_H + +#include +#include +#include + +class AnimationStackedWidget : public QStackedWidget +{ + Q_OBJECT + Q_PROPERTY(double offset READ offset WRITE setOffset) +public: + enum MoveOrientation {LeftToRight, RightToLeft, TopToBottom, BottomToTop}; + enum AnimationOri {LR, TB}; //LR:Left Right ,TB:Top Bottom +public: + explicit AnimationStackedWidget(const AnimationOri ori = LR, QWidget *parent = nullptr); + ~AnimationStackedWidget() override; + /** + * @brief setDuration 设置动画持续时间 + * @param duration 动画时间 + */ + void setDuration(int duration = 500); + /** + * @brief IsRunning 动画是否正在运行 + * @return 动画师傅正在运行 + */ + bool IsRunning()const + { + return m_IsAnimation; + } + /** + * @brief offset 获取移动偏移量 + * @return 移动偏移量 + */ + double offset() const; + /** + * @brief setOffset 设置移动偏移量 + * @param offset 移动偏移量 + */ + void setOffset(double offset); + +protected: + /** + * @brief paintEvent 窗口绘制事件 + * @param e 绘制事件对象 + */ + void paintEvent(QPaintEvent *e) override; +signals: + /** + * @brief signalIsFinished 动画结束信号 + */ + void signalIsFinished(); +public slots: + /** + * @brief animationFinished 动画切换完成 + */ + void animationFinished(); + /** + * @brief setCurrent 设置当前窗口 + * @param index 索引 + */ + void setCurrent(int index); + /** + * @brief setPre 设置上一个索引的窗口 + */ + void setPre(); + /** + * @brief setNext 设置下一个索引的窗口 + */ + void setNext(); +private: + /** + * @brief setCurrentWidget 根据索引设置当前窗口,开启动画绘制 + * @param index 索引 + * @param beginWidth 动画起始值 + */ + void setCurrentWidget(int &index,int beginWidth); + /** + * @brief getBeginValue 获取动画起始值 + * @return 返回动画起始值 + */ + int getBeginValue(); + /** + * @brief getMoveOrientation 根据当前索引和下一个索引获取动画方向 + * @param currIndex 当前索引 + * @param nextIndex 设置的索引 + * @return 动画绘制方向 + */ + MoveOrientation getMoveOrientation(const int currIndex,const int nextIndex); + /** + * @brief paintCurrentWidget获取当前窗口的图片动态绘制 + * @param paint 绘制对象 + * @param nextIndex 窗口索引 + */ + void paintCurrentWidget(QPainter &paint, int currentIndex); + /** + * @brief paintNextWidget 获取下一个窗口的图片动态绘制 + * @param paint 绘制对象 + * @param nextIndex 窗口索引 + */ + void paintNextWidget(QPainter &paint, int nextIndex); +private: + /** + * @brief m_animationOri 动画方向--左右还是上下 + */ + AnimationOri m_animationOri{LR}; + /** + * @brief m_Animation 动画对象 + */ + QPropertyAnimation *m_Animation = nullptr; + /** + * @brief m_Duration 动画时间(ms) + */ + int m_Duration{0}; + /** + * @brief m_IsAnimation 是否为动画状态 + */ + bool m_IsAnimation = false; + /** + * @brief m_offset 移动偏移量 + */ + double m_offset = 0; + /** + * @brief paintNext + */ + int m_WidgetCount{0}; + /** + * @brief m_NextIndex 下一个索引 + */ + int m_NextIndex{0}; + /** + * @brief m_moveOri 移动方向 + */ + MoveOrientation m_moveOri = MoveOrientation::LeftToRight; +}; + +#endif // AnimationStackedWidget_H diff -Nru dde-calendar-5.7.0.4/src/customWidget/cdynamicicon.cpp dde-calendar-5.7.0.23/src/customWidget/cdynamicicon.cpp --- dde-calendar-5.7.0.4/src/customWidget/cdynamicicon.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/customWidget/cdynamicicon.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,170 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "cdynamicicon.h" + +#include +#include +#include + +#include +#include + +#define BackgroundRatio 0.9394 + +#define Month_X_Ratio 0.3203 +#define Month_Y_Ratio 0.1690 +#define Month_W_Ratio 0.3125 +#define Month_H_Ratio 0.15625 + +#define Day_X_Ratio 0.28125 +#define Day_Y_Ratio 0.33333 +#define Day_W_Ratio 0.4375 +#define Day_H_Ratio 0.4160 + +#define Week_X_Ratio 0.4375 +#define Week_Y_Ratio 0.728515625 +#define Week_W_Ratio 0.21875 +#define Week_H_Ratio 0.09375 + + +CDynamicIcon *CDynamicIcon::m_Icon = nullptr; +CDynamicIcon::CDynamicIcon(int width, int height) + : m_pixmap(new QPixmap(QSize(width, height))) + , m_Date() + , m_Dayrenderer(new QSvgRenderer()) + , m_Weekrenderer(new QSvgRenderer()) + , m_Monthrenderer(new QSvgRenderer()) + , m_backgroundrenderer(new QSvgRenderer()) + +{ + m_pixmap->fill(Qt::transparent); + m_Date = QDate::currentDate(); + setDate(m_Date); +} + +CDynamicIcon::~CDynamicIcon() +{ + delete m_pixmap; + m_pixmap = nullptr; + + delete m_Dayrenderer; + m_Dayrenderer = nullptr; + + delete m_Weekrenderer; + m_Weekrenderer = nullptr; + + delete m_Monthrenderer; + m_Monthrenderer = nullptr; + + delete m_backgroundrenderer; + m_backgroundrenderer = nullptr; + +} + +CDynamicIcon *CDynamicIcon::getInstance() +{ + if (nullptr == m_Icon) { + m_Icon = new CDynamicIcon(512,512); + } + return m_Icon; +} + +void CDynamicIcon::releaseInstance() +{ + if (m_Icon !=nullptr) { + delete m_Icon; + m_Icon =nullptr; + } +} + +void CDynamicIcon::setDate(const QDate &date) +{ + m_Date = date; + QString dayfile = QString(":/resources/DynamicIcon/day%1.svg").arg(date.day()); + + m_Dayrenderer->load(dayfile); + + QString weekfile = QString(":/resources/DynamicIcon/week%1.svg").arg(date.dayOfWeek()); + m_Weekrenderer->load(weekfile); + + QString monthfile = QString(":/resources/DynamicIcon/month%1.svg").arg(date.month()); + m_Monthrenderer->load(monthfile); + + QString backgroundfile(":/resources/DynamicIcon/calendar_bg.svg"); + m_backgroundrenderer->load(backgroundfile); + + //draw pixmap + paintPixmap(m_pixmap); + +} + +void CDynamicIcon::setIcon() +{ + QIcon icon(this->getPixmap()); + qApp->setProductIcon(icon); + + if (qApp->aboutDialog() != nullptr) + qApp->aboutDialog()->setProductIcon(icon); + + m_Titlebar->setIcon(icon); +} + +void CDynamicIcon::setTitlebar(DTitlebar *titlebar) +{ + m_Titlebar = titlebar; +} + +void CDynamicIcon::paintPixmap(QPixmap *pixmap) +{ + QPainter painter(pixmap); + + //draw background + qreal backgroundwidget = pixmap->size().width() * BackgroundRatio; + qreal backgroundheigth = pixmap->size().height() * BackgroundRatio; + QRectF backgroundRect = QRectF((pixmap->size().width()-backgroundwidget)/2, + (pixmap->size().height()-backgroundheigth)/2, + backgroundwidget, + backgroundheigth); + m_backgroundrenderer->render(&painter,backgroundRect); + + //draw month + qreal month_x = pixmap->size().width() * Month_X_Ratio; + qreal month_y = pixmap->size().width() * Month_Y_Ratio; + qreal month_w = pixmap->size().width() * Month_W_Ratio; + qreal month_h = pixmap->size().width() * Month_H_Ratio; + m_Monthrenderer->render(&painter,QRectF(month_x,month_y,month_w,month_h)); + + //draw day + qreal day_x = pixmap->size().width() * Day_X_Ratio; + qreal day_y = pixmap->size().width() * Day_Y_Ratio; + qreal day_w = pixmap->size().width() * Day_W_Ratio; + qreal day_h = pixmap->size().width() * Day_H_Ratio; + m_Dayrenderer->render(&painter,QRectF(day_x,day_y,day_w,day_h)); + + //draw week + qreal week_x = pixmap->size().width() * Week_X_Ratio; + qreal week_y = pixmap->size().width() * Week_Y_Ratio; + qreal week_w = pixmap->size().width() * Week_W_Ratio; + qreal week_h = pixmap->size().width() * Week_H_Ratio; + m_Weekrenderer->render(&painter,QRectF(week_x,week_y,week_w,week_h)); + + painter.end(); +} diff -Nru dde-calendar-5.7.0.4/src/customWidget/cdynamicicon.h dde-calendar-5.7.0.23/src/customWidget/cdynamicicon.h --- dde-calendar-5.7.0.4/src/customWidget/cdynamicicon.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/customWidget/cdynamicicon.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,73 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef CDYNAMICICON_H +#define CDYNAMICICON_H + +#include +#include + +#include +#include +#include +#include + +DWIDGET_USE_NAMESPACE +DCORE_USE_NAMESPACE + +class CDynamicIcon +{ +private: + CDynamicIcon(int width, int height); + ~CDynamicIcon(); +public: + static CDynamicIcon *getInstance(); + static void releaseInstance(); +public: + void setDate(const QDate &date); + QDate getDate() const + { + return m_Date; + } + void setIcon(); + void setTitlebar(DTitlebar *titlebar); + QPixmap getPixmap() const + { + return *m_pixmap; + } +public: + static CDynamicIcon *m_Icon; +private: + void paintPixmap(QPixmap *pixmap); +private: + QPixmap *m_pixmap = nullptr; + QDate m_Date; + + QSvgRenderer *m_Dayrenderer = nullptr; + QSvgRenderer *m_Weekrenderer = nullptr; + QSvgRenderer *m_Monthrenderer = nullptr; + QSvgRenderer *m_backgroundrenderer = nullptr; + + DTitlebar *m_Titlebar {nullptr}; + + +}; + +#endif // CDYNAMICICON_H diff -Nru dde-calendar-5.7.0.4/src/customWidget/customframe.cpp dde-calendar-5.7.0.23/src/customWidget/customframe.cpp --- dde-calendar-5.7.0.4/src/customWidget/customframe.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/customWidget/customframe.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,175 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "customframe.h" +#include "constants.h" + +#include + +#include +#include + +DGUI_USE_NAMESPACE +CustomFrame::CustomFrame(QWidget *parent) + : QFrame(parent) +{ + m_font.setWeight(QFont::Medium); + m_font.setPixelSize(DDECalendar::FontSizeFourteen); + this->setAttribute(Qt::WA_TranslucentBackground);//设置窗口背景透明 + this->setWindowFlags(Qt::FramelessWindowHint); //设置无边框窗口 + setContentsMargins(0, 0, 0, 0); +} + +void CustomFrame::setBColor(QColor normalC) +{ + m_bnormalColor = normalC; + m_bflag = true; + update(); +} + +void CustomFrame::setRoundState(bool lstate, bool tstate, bool rstate, bool bstate) +{ + m_lstate = lstate; + m_tstate = tstate; + m_rstate = rstate; + m_bstate = bstate; +} + +void CustomFrame::setTextStr(QFont font, QColor tc, QString strc, int flag) +{ + m_font = font; + m_tnormalColor = tc; + m_text = strc; + m_textflag = flag; +} + +void CustomFrame::setTextStr(QString strc) +{ + m_text = strc; + + if (!m_fixsizeflag) { + QFontMetrics fm(m_font); + int w = fm.width(m_text); + setMinimumWidth(w); + } + update(); +} + +void CustomFrame::setTextColor(QColor tc) +{ + m_tnormalColor = tc; + update(); +} + +void CustomFrame::setTextFont(QFont font) +{ + m_font = font; + + if (!m_fixsizeflag) { + QFontMetrics fm(m_font); + int w = fm.width(m_text); + setMinimumWidth(w); + } +} + +void CustomFrame::setTextAlign(int flag) +{ + m_textflag = flag; +} + +void CustomFrame::setRadius(int radius) +{ + m_radius = radius; +} + +void CustomFrame::setboreder(int framew) +{ + m_borderframew = framew; +} + +void CustomFrame::setFixedSize(int w, int h) +{ + m_fixsizeflag = true; + QFrame::setFixedSize(w, h); +} + +void CustomFrame::paintEvent(QPaintEvent *e) +{ + int labelwidth = width() - 2 * m_borderframew; + int labelheight = height() - 2 * m_borderframew; + + QPainter painter(this); + QRect fillRect = QRect(m_borderframew, m_borderframew, labelwidth, labelheight); + + if (m_bflag) { + painter.save(); + painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; + painter.setBrush(QBrush(m_bnormalColor)); + painter.setPen(Qt::NoPen); + QPainterPath painterPath; + painterPath.moveTo(m_radius, m_borderframew); + + if (m_lstate) { + painterPath.arcTo(QRect(m_borderframew, m_borderframew, m_radius * 2, m_radius * 2), 90, 90); + } else { + painterPath.lineTo(m_borderframew, m_borderframew); + painterPath.lineTo(m_borderframew, m_radius); + } + painterPath.lineTo(0, labelheight - m_radius); + + if (m_bstate) { + painterPath.arcTo(QRect(m_borderframew, labelheight - m_radius * 2, m_radius * 2, m_radius * 2), 180, 90); + } else { + painterPath.lineTo(m_borderframew, labelheight); + painterPath.lineTo(m_radius, labelheight); + } + painterPath.lineTo(labelwidth - m_radius, labelheight); + + if (m_rstate) { + painterPath.arcTo(QRect(labelwidth - m_radius * 2, labelheight - m_radius * 2, m_radius * 2, m_radius * 2), 270, 90); + } else { + painterPath.lineTo(labelwidth, labelheight); + painterPath.lineTo(labelwidth, labelheight - m_radius); + } + painterPath.lineTo(labelwidth, m_radius); + + if (m_tstate) { + painterPath.arcTo(QRect(labelwidth - m_radius * 2, m_borderframew, m_radius * 2, m_radius * 2), 0, 90); + } else { + painterPath.lineTo(labelwidth, m_borderframew); + painterPath.lineTo(labelwidth - m_radius, m_borderframew); + } + painterPath.lineTo(m_radius, m_borderframew); + painterPath.closeSubpath(); + painter.drawPath(painterPath); + painter.restore(); + } + + if (!m_text.isEmpty()) { + painter.save(); + painter.setRenderHints(QPainter::HighQualityAntialiasing); + painter.setFont(m_font); + painter.setPen(m_tnormalColor); + painter.drawText(fillRect, m_textflag, m_text); + painter.restore(); + } + QFrame::paintEvent(e); +} + diff -Nru dde-calendar-5.7.0.4/src/customWidget/customframe.h dde-calendar-5.7.0.23/src/customWidget/customframe.h --- dde-calendar-5.7.0.4/src/customWidget/customframe.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/customWidget/customframe.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,63 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef CustomFrame_H +#define CustomFrame_H + +#include + +class CustomFrame : public QFrame +{ + Q_OBJECT +public: + CustomFrame(QWidget *parent = nullptr); + void setBColor(QColor normalC); + void setRoundState(bool lstate, bool tstate, bool rstate, bool bstate); + void setTextStr(QFont font, QColor tc, QString strc, int flag = Qt::AlignCenter); + void setTextStr(QString strc); + void setTextColor(QColor tc); + void setTextFont(QFont font); + void setTextAlign(int flag = Qt::AlignCenter); + void setRadius(int radius = 8); + void setboreder(int framew = 0); + QString getTextStr() + { + return m_text; + } + void setFixedSize(int w, int h); +protected: + void paintEvent(QPaintEvent *e) override; +private: + QColor m_bnormalColor = "#FFFFFF"; + QColor m_tnormalColor = "#000000"; + QFont m_font; + bool m_bflag = false; + bool m_fixsizeflag = false; + int m_textflag = Qt::AlignCenter;//对齐方式 + QString m_text; + int m_radius = 8; + int m_borderframew = 0; + bool m_lstate = false; + bool m_tstate = false; + bool m_rstate = false; + bool m_bstate = false; +}; + +#endif // TODYBUTTON_H diff -Nru dde-calendar-5.7.0.4/src/customWidget/SchecduleRemindWidget.cpp dde-calendar-5.7.0.23/src/customWidget/SchecduleRemindWidget.cpp --- dde-calendar-5.7.0.4/src/customWidget/SchecduleRemindWidget.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/customWidget/SchecduleRemindWidget.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,170 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "SchecduleRemindWidget.h" +#include "constants.h" + +#include + +#include +#include + +DGUI_USE_NAMESPACE +SchecduleRemindWidget::SchecduleRemindWidget(QWidget *parent) + : DArrowRectangle(DArrowRectangle::ArrowLeft, DArrowRectangle::FloatWindow, parent) + , m_centerWidget(new CenterWidget(this)) +{ + m_centerWidget->setFixedWidth(207); + m_centerWidget->setFixedHeight(57); + setContent(m_centerWidget); + this->resizeWithContent(); + QObject::connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, + m_centerWidget, + &CenterWidget::setTheMe); + m_centerWidget->setTheMe(DGuiApplicationHelper::instance()->themeType()); +} + +SchecduleRemindWidget::~SchecduleRemindWidget() +{ + +} + +void SchecduleRemindWidget::setData(const ScheduleDtailInfo &vScheduleInfo, const CSchedulesColor &gcolor) +{ + m_centerWidget->setData(vScheduleInfo, gcolor); + m_ScheduleInfo = vScheduleInfo; + gdcolor = gcolor; + this->setHeight(m_centerWidget->height() + 10); +} + +CenterWidget::CenterWidget(DWidget *parent) + : DFrame(parent) +{ + textfont.setWeight(QFont::Medium); +} + +CenterWidget::~CenterWidget() +{ + +} + +void CenterWidget::setData(const ScheduleDtailInfo &vScheduleInfo, const CSchedulesColor &gcolor) +{ + m_ScheduleInfo = vScheduleInfo; + gdcolor = gcolor; + textfont.setPixelSize(DDECalendar::FontSizeTwelve); + UpdateTextList(); + update(); +} + +void CenterWidget::setTheMe(const int type) +{ + if (type == 2) { + timeColor = QColor("#C0C6D4"); + timeColor.setAlphaF(0.7); + textColor = QColor("#C0C6D4"); + textColor.setAlphaF(1); + } else { + timeColor = QColor("#414D68"); + timeColor.setAlphaF(0.7); + textColor = QColor("#414D68"); + textColor.setAlphaF(1); + } + update(); +} + +void CenterWidget::UpdateTextList() +{ + testList.clear(); + QFontMetrics metrics(textfont); + textwidth = metrics.width(m_ScheduleInfo.titleName); + textheight = metrics.height(); + const int h_count = qCeil(textwidth / textRectWidth); + QString text; + + if (h_count < 1) { + testList.append(m_ScheduleInfo.titleName); + } else { + const int text_Max_Height = 108; + const int text_HeightMaxCount = qFloor(text_Max_Height / textheight); + + for (int i = 0; i < m_ScheduleInfo.titleName.count(); ++i) { + text += m_ScheduleInfo.titleName.at(i); + if (metrics.width(text) > textRectWidth) { + text.remove(text.count() - 1, 1); + testList.append(text); + text = ""; + + if (testList.count() == (text_HeightMaxCount - 1)) { + text = m_ScheduleInfo.titleName.right( m_ScheduleInfo.titleName.count() - i ); + testList.append(metrics.elidedText(text, Qt::ElideRight, textRectWidth)); + break; + } + --i; + } else { + if (i + 1 == m_ScheduleInfo.titleName.count()) { + testList.append(text); + } + } + } + } + + this->setFixedHeight(testList.count() * textheight + 30 + 8); +} + +void CenterWidget::paintEvent(QPaintEvent *e) +{ + Q_UNUSED(e); + int diam = 8; + int x = 40 - 13; + QFont timeFont; + timeFont.setPixelSize(DDECalendar::FontSizeTwelve); + QPainter painter(this); + //draw time + QPen pen; + pen.setColor(timeColor); + painter.setPen(pen); + painter.setFont(timeFont); + QString timestr; + QLocale locale; + timestr = m_ScheduleInfo.beginDateTime.time().toString("AP h:mm"); + + QFontMetrics metrics(timeFont); + if (m_ScheduleInfo.allday) + timestr = tr("All Day"); + int timewidth = metrics.width(timestr); + int timeheight = metrics.height(); + + painter.drawText(QRect( x + 13, 7, timewidth, timeheight), Qt::AlignLeft | Qt::AlignTop, timestr); + painter.setRenderHints(QPainter::Antialiasing); + painter.setPen(Qt::NoPen); + painter.setBrush(QBrush(gdcolor.dotColor)); + painter.drawEllipse(x, 7 + (timeheight - diam) / 2, diam, diam); + pen.setColor(textColor); + painter.setPen(pen); + painter.setFont(textfont); + + for (int i = 0; i < testList.count(); i++) { + painter.drawText( + QRect(x, 30 + i * textheight, textRectWidth, textheight), + Qt::AlignLeft, testList.at(i)); + } + painter.end(); +} diff -Nru dde-calendar-5.7.0.4/src/customWidget/SchecduleRemindWidget.h dde-calendar-5.7.0.23/src/customWidget/SchecduleRemindWidget.h --- dde-calendar-5.7.0.4/src/customWidget/SchecduleRemindWidget.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/customWidget/SchecduleRemindWidget.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,77 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef SchecduleRemindWidget_H +#define SchecduleRemindWidget_H + +#include "schedulestructs.h" +#include "scheduledatamanage.h" + +#include +#include +#include + +DWIDGET_USE_NAMESPACE + +class CenterWidget; +class SchecduleRemindWidget : public DArrowRectangle +{ + Q_OBJECT + Q_DISABLE_COPY(SchecduleRemindWidget) +public: + explicit SchecduleRemindWidget(QWidget *parent = nullptr); + ~SchecduleRemindWidget() override; + void setData(const ScheduleDtailInfo &vScheduleInfo, const CSchedulesColor &gcolor); + +signals: + +public slots: +private: + CenterWidget *m_centerWidget = nullptr; + ScheduleDtailInfo m_ScheduleInfo; + CSchedulesColor gdcolor; +}; + +class CenterWidget : public DFrame +{ + Q_OBJECT + Q_DISABLE_COPY(CenterWidget) +public: + explicit CenterWidget(DWidget *parent = nullptr); + ~CenterWidget() override; + void setData(const ScheduleDtailInfo &vScheduleInfo, const CSchedulesColor &gcolor); + void setTheMe(const int type = 0); +private: + void UpdateTextList(); +protected: + void paintEvent(QPaintEvent *e) override; +private: + QStringList testList; + QFont textfont; + int textwidth; + int textheight; + const int textRectWidth = 165; + ScheduleDtailInfo m_ScheduleInfo; + CSchedulesColor gdcolor; + QColor textColor; + QColor timeColor; +}; + +#endif // SchecduleRemindWidget_H diff -Nru dde-calendar-5.7.0.4/src/customWidget/scheduleview.cpp dde-calendar-5.7.0.23/src/customWidget/scheduleview.cpp --- dde-calendar-5.7.0.4/src/customWidget/scheduleview.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/customWidget/scheduleview.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,566 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#include "scheduleview.h" +#include "alldayeventview.h" +#include "graphicsview.h" +#include "schceduledlg.h" +#include "schedulecoormanage.h" +#include "scheduledatamanage.h" +#include "constants.h" + +#include +#include + +#include +#include +#include +#include + +DGUI_USE_NAMESPACE + +static int hourTextWidth = 50; +static int hourTextHeight = 20; +CScheduleView::CScheduleView(QWidget *parent, int viewType) + : DFrame(parent) + , m_viewType(viewType) +{ + initUI(); + initConnection(); + setFrameRounded(true); + setLineWidth(0); +} + +CScheduleView::~CScheduleView() {} + +void CScheduleView::setviewMagin(int left, int top, int right, int bttom) +{ + m_leftMagin = left; + m_topMagin = top; + m_rightmagin = right; + m_layout->setContentsMargins(left,0,0,0); + m_graphicsView->setMargins(0, 0, right, bttom); + m_alldaylist->setMargins(0, 0, 0, 0); +} + +void CScheduleView::setRange(int w, int h, QDate begin, QDate end) +{ + Q_UNUSED(h); + + if (!(w > 0)) { + return; + } + m_TotalDay = begin.daysTo(end) + 1; + m_graphicsView->setRange(w, scheduleViewHegith(), begin, end, m_rightmagin); + m_alldaylist->setRange(w, 22, m_beginDate, m_endDate, m_rightmagin); + + if (m_viewType ==1) + m_currteDate = begin; + update(); +} + +void CScheduleView::setRange(QDate begin, QDate end) +{ + m_TotalDay = begin.daysTo(end) + 1; + m_graphicsView->setRange(begin,end); + m_alldaylist->setRange(begin,end); + m_beginDate = begin; + m_endDate = end; + updateSchedule(); +} + +void CScheduleView::setFirstWeekday(int weekday) +{ + m_firstWeekDay = weekday; + m_graphicsView->setFirstWeekday(weekday); +} + +void CScheduleView::setTheMe(int type) +{ + if (type == 0 || type == 1) { + DPalette palette(this->palette()); + palette.setColor(DPalette::Background, "#FFFFFF"); + this->setPalette(palette); + setBackgroundRole(DPalette::Background); + m_linecolor = "#000000"; + m_linecolor.setAlphaF(0.1); + m_ALLDayColor = "#303030"; + m_timeColor = "#7D7D7D"; + } else if (type == 2) { + DPalette palette(this->palette()); + QColor tbcolor = "#282828"; + palette.setColor(DPalette::Background, tbcolor); + this->setPalette(palette); + setBackgroundRole(DPalette::Background); + m_linecolor = "#000000"; + m_linecolor.setAlphaF(0.1); + m_ALLDayColor = "#7D7D7D"; + m_timeColor = "#7D7D7D"; + } + m_graphicsView->setTheMe(type); + m_alldaylist->setTheMe(type); + update(); +} + +void CScheduleView::setLunarVisible(bool state) +{ + Q_UNUSED(state); +} + +void CScheduleView::setTime(QTime time) +{ + m_graphicsView->setTime(time); +} + +void CScheduleView::setSelectSchedule(const ScheduleDtailInfo &scheduleInfo) +{ + if (scheduleInfo.allday) { + m_alldaylist->setSelectSchedule(scheduleInfo); + } else { + m_graphicsView->setSelectSchedule(scheduleInfo); + } +} + +void CScheduleView::updateHigh() +{ + m_graphicsView->updateHigh(); + m_alldaylist->updateHigh(); +} + +bool CScheduleView::IsDragging() +{ + return (m_graphicsView->getDragStatus()!=4) || (m_alldaylist->getDragStatus()!=4); +} + +void CScheduleView::slotsupdatescheduleD(QVector &data) +{ + updateAllday(); + m_graphicsView->updateInfo(); + m_graphicsView->update(); + m_graphicsView->scene()->update(); + + if (m_viewType == 1) { + if (QDate::currentDate() == m_beginDate) { + m_graphicsView->setTime(QTime::currentTime()); + } else { + if (data.isEmpty()) { + m_graphicsView->setTime(QTime(13, 0)); + } else { + QVector scheduleInfolist; + + for (int i = 0; i < data.at(0).vData.count(); i++) { + if (data.at(0).vData.at(i).allday) + continue; + scheduleInfolist.append(data.at(0).vData.at(i)); + } + if (scheduleInfolist.isEmpty()) { + m_graphicsView->setTime(QTime(13, 0)); + } else { + std::sort(scheduleInfolist.begin(),scheduleInfolist.end(), + [](const ScheduleDtailInfo &s1, const ScheduleDtailInfo &s2) ->bool { + return s1.beginDateTime < s2.beginDateTime; + }); + QTime time = scheduleInfolist.at(0).beginDateTime.time(); + + if (scheduleInfolist.at(0).beginDateTime.date() != m_beginDate) { + time = QTime(0, 0); + } + if (time.hour() + 4 >= 24) { + time = QTime(20, 0); + } else { + time = time.addSecs(14400); + } + m_graphicsView->setTime(time); + } + } + } + } + setEnabled(true); +} + + +void CScheduleView::setDate(QDate date) +{ + m_currteDate = date; + updateAllday(); +} + +void CScheduleView::slotupdateSchedule() +{ + updateSchedule(); + emit signalsUpdateShcedule(0); +} + +void CScheduleView::slotPosHours(QVector vPos, QVector vHours, int cuttrnttimetype) +{ + m_vHours = vHours; + m_vPos = vPos; + m_cuttrnttimetype = cuttrnttimetype; + update(); +} + +void CScheduleView::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event); + QPainter painter(this); + font.setWeight(QFont::Normal); + font.setPixelSize(DDECalendar::FontSizeEleven); + + if (m_vPos.isEmpty()) + return; + + painter.save(); + painter.setRenderHint(QPainter::Antialiasing); + painter.setPen(Qt::NoPen); + DPalette backgroundPal; + backgroundPal = this->palette(); + QBrush backgroundBrush = backgroundPal.background(); + painter.setBrush(backgroundBrush); + QPainterPath painterpath; + painterpath.lineTo(1, this->height() - m_radius); + painterpath.arcTo(QRectF(1, this->height() - m_radius * 2, m_radius * 2, m_radius * 2), 180, 90); + painterpath.lineTo(75, this->height()); + painterpath.lineTo(75, 0); + painterpath.lineTo(1, 0); + painter.drawPath(painterpath); + painter.restore(); + + QLocale locale; + + if (locale.language() == QLocale::Chinese) { + QRect tinrect((m_leftMagin - hourTextWidth) / 2 - 5, + m_topMagin - 8 + m_vPos[m_vPos.count() - 1], hourTextWidth, hourTextHeight); + + if (m_cuttrnttimetype == 0) { + painter.save(); + painter.setFont(font); + painter.setPen(m_timeColor); + for (int i = 0; i < m_vPos.size(); i++) { + if (m_vHours[i] == 0) + continue; + if (m_vHours[i] == 24) + continue; + if (m_topMagin - 8 + m_vPos[i] < m_topMagin) + continue; + painter.drawText( + QRect((m_leftMagin - hourTextWidth) / 2 - 5, m_topMagin - 8 + m_vPos[i], + hourTextWidth, hourTextHeight), + Qt::AlignCenter, QTime(m_vHours[i], 0).toString("AP h 时")); + } + painter.restore(); + } else { + painter.save(); + painter.setFont(font); + painter.setPen(m_timeColor); + + for (int i = 0; i < m_vPos.size() - 1; i++) { + if (m_vHours[i] == 0) + continue; + if (m_vHours[i] == 24) + continue; + if (m_topMagin - 8 + m_vPos[i] < m_topMagin) + continue; + QRect rr((m_leftMagin - hourTextWidth) / 2 - 5, m_topMagin - 8 + m_vPos[i], + hourTextWidth, hourTextHeight); + if (rr.intersects(tinrect) && m_viewType == 1 && + m_beginDate == QDate::currentDate()) { + continue; + } + painter.drawText( + QRect((m_leftMagin - hourTextWidth) / 2 - 5, m_topMagin - 8 + m_vPos[i], + hourTextWidth, hourTextHeight), + Qt::AlignCenter, QTime(m_vHours[i], 0).toString("AP h 时")); + } + painter.restore(); + + if (m_viewType == 1 && m_beginDate == QDate::currentDate()) { + painter.save(); + painter.setFont(font); + painter.setPen(m_currenttimecolor); + QString str = QTime::currentTime().toString("AP hh:mm"); + painter.drawText(QRect((m_leftMagin - hourTextWidth) / 2 - 5, + m_topMagin - 8 + m_vPos[m_vPos.count() - 1], hourTextWidth, + hourTextHeight), + Qt::AlignCenter, str); + painter.restore(); + } + } + } else { + if (m_cuttrnttimetype == 0) { + painter.save(); + painter.setFont(font); + painter.setPen(m_timeColor); + + for (int i = 0; i < m_vPos.size(); i++) { + if (m_vHours[i] == 0) + continue; + if (m_vHours[i] == 24) + continue; + if (m_topMagin - 8 + m_vPos[i] < m_topMagin) + continue; + painter.drawText( + QRect((m_leftMagin - hourTextWidth) / 2 - 5, m_topMagin - 8 + m_vPos[i], + hourTextWidth + 2, hourTextHeight), + Qt::AlignCenter, QTime(m_vHours[i], 0).toString("HH:mm")); + } + painter.restore(); + } else { + painter.save(); + painter.setFont(font); + painter.setPen(m_timeColor); + QRect tinrect((m_leftMagin - hourTextWidth) / 2 - 5, + m_topMagin - 8 + m_vPos[m_vPos.count() - 1], hourTextWidth + 2, + hourTextHeight); + + for (int i = 0; i < m_vPos.size() - 1; i++) { + if (m_vHours[i] == 0) + continue; + if (m_vHours[i] == 24) + continue; + if (m_topMagin - 8 + m_vPos[i] < m_topMagin) + continue; + QRect rr((m_leftMagin - hourTextWidth) / 2 - 5, m_topMagin - 8 + m_vPos[i], + hourTextWidth + 2, hourTextHeight); + + if (rr.intersects(tinrect) && m_viewType == 1 && + m_beginDate == QDate::currentDate()) + continue; + + painter.drawText( + QRect((m_leftMagin - hourTextWidth) / 2 - 5, m_topMagin - 8 + m_vPos[i], + hourTextWidth + 2, hourTextHeight), + Qt::AlignCenter, QTime(m_vHours[i], 0).toString("HH:mm")); + } + painter.restore(); + + if (m_viewType == 1 && m_beginDate == QDate::currentDate()) { + painter.save(); + painter.setFont(font); + painter.setPen(m_currenttimecolor); + QString str = QTime::currentTime().toString("hh:mm"); + + if (m_topMagin - 8 + m_vPos[m_vPos.count() - 1] >= m_topMagin) + painter.drawText(QRect((m_leftMagin - hourTextWidth) / 2 - 5, + m_topMagin - 8 + m_vPos[m_vPos.count() - 1], + hourTextWidth + 2, hourTextHeight), + Qt::AlignCenter, str); + painter.restore(); + } + } + } + + painter.save(); + QFont alldayfont; + alldayfont.setWeight(QFont::Medium); + alldayfont.setPixelSize(DDECalendar::FontSizeFourteen); + painter.setFont(alldayfont); + painter.setPen(m_ALLDayColor); + painter.drawText(QRect(0, 0, m_leftMagin - 2, m_topMagin - 2), Qt::AlignCenter, tr("ALL DAY")); + painter.restore(); + + //绘制全天与非全天之间的直线 + painter.setPen(m_linecolor); + //分割线y坐标点 + const int point_y = m_topMagin - 2; + painter.drawLine(0, point_y, this->width() - m_rightmagin - 2, point_y); + painter.end(); +} + +void CScheduleView::resizeEvent(QResizeEvent *event) +{ + if (m_viewType == 0) { + m_sMaxNum = ((width() - m_leftMagin) / 7) / 27; + } else { + } + m_graphicsView->setMaxNum(m_sMaxNum); + m_graphicsView->setRange(width() - m_leftMagin, + scheduleViewHegith(), m_beginDate, m_endDate, m_rightmagin); + m_alldaylist->setRange(width() - m_leftMagin, 22, m_beginDate, m_endDate, m_rightmagin); + update(); + QFrame::resizeEvent(event); + updateAllday(); + m_graphicsView->updateInfo(); + m_graphicsView->keepCenterOnScene(); +} + +void CScheduleView::initUI() +{ + m_layout = new QVBoxLayout; + m_layout->setSpacing(0); + m_layout->setMargin(0); + m_alldaylist = new CAllDayEventWeekView(this, 1); + m_layout->addWidget(m_alldaylist); + m_layout->addSpacing(1); + m_graphicsView = new CGraphicsView(this, m_viewType); + const int miniHeight = m_viewType ==0 ? 300 : 380; + m_graphicsView->setMinimumHeight(miniHeight); + connect(m_graphicsView, SIGNAL(signalsPosHours(QVector, QVector, int)), this, + SLOT(slotPosHours(QVector, QVector, int))); + m_layout->addWidget(m_graphicsView); + setLayout(m_layout); + m_graphicsView->scrollBarValueChangedSlot(); + + m_ScheduleRemindWidget = new SchecduleRemindWidget(this); +} + +void CScheduleView::initConnection() +{ + connect(m_graphicsView, &CGraphicsView::signalsUpdateShcedule, this, + &CScheduleView::slotupdateSchedule); + connect(m_alldaylist, &CAllDayEventWeekView::signalsUpdateShcedule, this, + &CScheduleView::slotupdateSchedule); + connect(m_graphicsView, &CGraphicsView::signalsCurrentScheduleDate, this, + &CScheduleView::slotCurrentScheduleDate); + + connect(m_alldaylist, &CAllDayEventWeekView::signalViewtransparentFrame, this, + &CScheduleView::signalViewtransparentFrame); + connect(m_graphicsView, &CGraphicsView::signalViewtransparentFrame, this, + &CScheduleView::signalViewtransparentFrame); + + connect(m_graphicsView + , &CGraphicsView::signalScheduleShow + , this, &CScheduleView::slotScheduleShow); + + connect(m_alldaylist, &CAllDayEventWeekView::signalScheduleShow + , this, &CScheduleView::slotScheduleShow); + + connect(m_alldaylist,&CAllDayEventWeekView::signalUpdatePaint, + this,&CScheduleView::slotUpdatePaint); + connect(m_alldaylist,&CAllDayEventWeekView::signalSceneUpdate, + this,&CScheduleView::slotUpdateScene); + connect(m_graphicsView,&CGraphicsView::signalSceneUpdate, + this,&CScheduleView::slotUpdateScene); + + QShortcut *dshortcut = new QShortcut(this); + dshortcut->setKey(QKeySequence(QLatin1String("Delete"))); + connect(dshortcut, SIGNAL(activated()), this, SLOT(slotDeleteitem())); + + + +} + +void CScheduleView::slotDeleteitem() +{ + m_graphicsView->slotDeleteItem(); + m_alldaylist->slotDeleteItem(); +} + +void CScheduleView::slotCurrentScheduleDate(QDate date) +{ + if (m_viewType == 1) + return; + emit signalsCurrentScheduleDate(date); +} + +void CScheduleView::slotScheduleShow(const bool isShow, const ScheduleDtailInfo &out) +{ + if (isShow) { + QPoint pos22 = QCursor::pos(); + CSchedulesColor gdcolor = CScheduleDataManage::getScheduleDataManage()->getScheduleColorByType( + out.type.ID); + QDesktopWidget *w = QApplication::desktop(); + m_ScheduleRemindWidget->setData(out, gdcolor); + + if ((pos22.x() + m_ScheduleRemindWidget->width() + 15) > w->width()) { + m_ScheduleRemindWidget->setArrowDirection(DArrowRectangle::ArrowRight); + m_ScheduleRemindWidget->show(pos22.x() - 15, pos22.y()); + } else { + m_ScheduleRemindWidget->setArrowDirection(DArrowRectangle::ArrowLeft); + m_ScheduleRemindWidget->show(pos22.x() + 15, pos22.y()); + } + } else { + m_ScheduleRemindWidget->hide(); + } +} + +void CScheduleView::slotUpdatePaint(const int topM) +{ + m_topMagin = topM; + update(); +} + +void CScheduleView::slotUpdateScene() +{ + m_graphicsView->slotUpdateScene(); + m_alldaylist->slotUpdateScene(); +} + +void CScheduleView::updateSchedule() +{ + m_graphicsView->clearSchdule(); + CScheduleDataCtrl *scheduleDataCtrl = + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl(); + QDateTime bdate = QDateTime(m_beginDate); + QDateTime edate = QDateTime(m_endDate); + edate.setTime(QTime(23, 59, 59)); + QVector data; + scheduleDataCtrl->queryScheduleInfo("", bdate, edate, data); + QVector allInfo; + QVector nonAllInfo; + + for (int i = 0; i < data.size(); ++i) { + for (int j = 0; j< data.at(i).vData.size(); ++j) { + if (data.at(i).vData.at(j).allday) { + if (!allInfo.contains(data.at(i).vData.at(j))) { + allInfo.append(data.at(i).vData.at(j)); + } + } else { + if (!nonAllInfo.contains(data.at(i).vData.at(j))) { + nonAllInfo.append(data.at(i).vData.at(j)); + } + } + } + } + m_alldaylist->setInfo(allInfo); + m_graphicsView->setInfo(nonAllInfo); + slotsupdatescheduleD(data); +} + +void CScheduleView::updateAllday() +{ + m_alldaylist->updateInfo(); + update(); + m_graphicsView->resize(m_graphicsView->width(),this->height()-m_alldaylist->height()); +} + +int CScheduleView::checkDay(int weekday) +{ + if (weekday <= 0) + return weekday += 7; + + if (weekday > 7) + return weekday -= 7; + + return weekday; +} + +int CScheduleView::scheduleViewHegith() +{ + qreal mheight = 0; + + if (m_viewType == 0) { + mheight = 24 * (0.0968 * height() + 0.5); + } else { + mheight = 24 * (0.083 * height() + 0.5); + } + //现在最小高度为20; + mheight = mheight <500? 1035:mheight; + int m_minTime = qRound((20.0/mheight)*86400); + m_graphicsView->setMinTime(m_minTime); + return qRound(mheight); +} diff -Nru dde-calendar-5.7.0.4/src/customWidget/scheduleview.h dde-calendar-5.7.0.23/src/customWidget/scheduleview.h --- dde-calendar-5.7.0.4/src/customWidget/scheduleview.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/customWidget/scheduleview.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#ifndef SCHEDULEVIEW_H +#define SCHEDULEVIEW_H +#include "schedulestructs.h" +#include "SchecduleRemindWidget.h" + +#include + +#include + +DWIDGET_USE_NAMESPACE + +class CGraphicsView; +class CAllDayEventWeekView; +class QVBoxLayout; +class CScheduleView : public DFrame +{ + Q_OBJECT +public: + CScheduleView(QWidget *parent = nullptr, int viewType = 0); + ~CScheduleView() override; + void setviewMagin(int left, int top, int right, int bttom); + void setRange(int w, int h, QDate begin, QDate end); + void setRange(QDate begin, QDate end); + void setFirstWeekday(int weekday); + void setTheMe(int type = 0); + void setLunarVisible(bool state); + void setTime(QTime time); + void setSelectSchedule(const ScheduleDtailInfo &scheduleInfo); + void updateHigh(); + bool IsDragging(); +public slots: + void slotsupdatescheduleD( QVector &data); +signals: + void signalsupdatescheduleD(QWidget *w, QDate begin, QDate end); +signals: + void signalsUpdateShcedule(int id = 0); + void signalsCurrentScheduleDate(QDate date); + void signalViewtransparentFrame(int type); +public slots: + void slotPosHours(QVector vPos, QVector vHours, int cuttrnttimetype = 0); + void setDate(QDate date); + void slotupdateSchedule(); + void slotDeleteitem(); + void slotCurrentScheduleDate(QDate date); + void slotScheduleShow(const bool isShow, const ScheduleDtailInfo &out = ScheduleDtailInfo()); + void slotUpdatePaint(const int topM); + void slotUpdateScene(); +protected: + void paintEvent(QPaintEvent *event) override; + void resizeEvent(QResizeEvent *event) override; +private: + void initUI(); + void initConnection(); + void updateSchedule(); + void updateAllday(); + int checkDay(int weekday); + int scheduleViewHegith(); +private: + CGraphicsView *m_graphicsView = nullptr; + QVector m_vPos; + QVector m_vHours; + CAllDayEventWeekView *m_alldaylist = nullptr; + QVector m_vListSchedule; + int m_leftMagin; + int m_topMagin; + int m_rightmagin = 0; + qint64 m_TotalDay; + QDate m_currteDate; + int m_firstWeekDay; + QDate m_beginDate; + QDate m_endDate; + int m_viewType = 0; + int m_sMaxNum = 4; + QColor m_linecolor = Qt::lightGray; + QColor m_ALLDayColor = "#303030"; + QColor m_timeColor = "#7D7D7D"; + QColor m_currenttimecolor = "#F74444"; + int m_cuttrnttimetype = 0; + QVBoxLayout *m_layout = nullptr; + SchecduleRemindWidget *m_ScheduleRemindWidget = nullptr; + int m_minTime; //最小高度对应的最小时间 + QFont font; + const int m_radius = 8; +}; + +#endif // SCHEDULEVIEW_H diff -Nru dde-calendar-5.7.0.4/src/customWidget/timeedit.cpp dde-calendar-5.7.0.23/src/customWidget/timeedit.cpp --- dde-calendar-5.7.0.4/src/customWidget/timeedit.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/customWidget/timeedit.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#include "timeedit.h" + +#include +#include + +CTimeEdit::CTimeEdit(QWidget *parent) + : DComboBox(parent) +{ + initUI(); + initConnection(); + setFocus(Qt::MouseFocusReason); +} + +CTimeEdit::~CTimeEdit() {} + +void CTimeEdit::setTime(QTime time) +{ + m_time = time; + m_timeEdit->setText(m_time.toString("hh:mm")); +} + +QTime CTimeEdit::getTime() +{ + //获取显示的text + QString timetext = m_timeEdit->lineEdit()->displayText(); + //将text转换为时间 + m_time = QTime::fromString(timetext, "hh:mm"); + return m_time; +} + +void CTimeEdit::initUI() +{ + m_timeEdit = new DLineEdit(this); + m_timeEdit->lineEdit()->setInputMask("00:00;0"); + m_timeEdit->setClearButtonEnabled(false); + QRegExpValidator *validator = nullptr; + QRegExp rx("0[0-9]:[0-5][0-9]|1[0-9]:[0-5][0-9]|2[0-3]:[0-5][0-9]"); + validator = new QRegExpValidator(rx, this); + m_timeEdit->lineEdit()->setValidator(validator); + setLineEdit(m_timeEdit->lineEdit()); + + QStringList list; + + for (int i = 0; i < 24; i++) { + list << QString("%1:%2").arg(i, 2, 10, QLatin1Char('0')).arg(0, 2, 10, QLatin1Char('0')); + list << QString("%1:%2").arg(i, 2, 10, QLatin1Char('0')).arg(30); + } + this->addItems(list); +} + +void CTimeEdit::initConnection() +{ + m_timeEdit->disconnect(SIGNAL(returnPressed())); + m_timeEdit->disconnect(SIGNAL(editingFinished())); + m_timeEdit->disconnect(SIGNAL(selectionChanged())); + m_timeEdit->disconnect(SIGNAL(textChanged(const QString &))); + m_timeEdit->disconnect(SIGNAL(textEdited(const QString &))); + m_timeEdit->disconnect(SIGNAL(cursorPositionChanged(int, int))); + + disconnect(SIGNAL(activated(int))); + disconnect(SIGNAL(activated(const QString &))); + disconnect(SIGNAL(currentIndexChanged(int))); + disconnect(SIGNAL(currentIndexChanged(const QString &))); + disconnect(SIGNAL(currentTextChanged(const QString &))); + disconnect(SIGNAL(editTextChanged(const QString &))); + disconnect(SIGNAL(highlighted(int))); + disconnect(SIGNAL(highlighted(const QString &))); +} diff -Nru dde-calendar-5.7.0.4/src/customWidget/timeedit.h dde-calendar-5.7.0.23/src/customWidget/timeedit.h --- dde-calendar-5.7.0.4/src/customWidget/timeedit.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/customWidget/timeedit.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#pragma once + +#include +#include +#include + +#include +#include + +DWIDGET_USE_NAMESPACE +class CTimeEdit : public DComboBox +{ + Q_OBJECT + +public: + CTimeEdit(QWidget *parent = nullptr); + ~CTimeEdit(); + void setTime(QTime time); + QTime getTime(); +private: + void initUI(); + void initConnection(); +private: + DLineEdit *m_timeEdit = nullptr; + int m_type = 0; // 0 h,1 m + int m_pos = 0; + QTime m_time; +}; diff -Nru dde-calendar-5.7.0.4/src/customWidget/todybutton.cpp dde-calendar-5.7.0.23/src/customWidget/todybutton.cpp --- dde-calendar-5.7.0.4/src/customWidget/todybutton.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/customWidget/todybutton.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,112 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "todybutton.h" +#include "constants.h" + +#include + +#include + +DGUI_USE_NAMESPACE +CTodyButton::CTodyButton(QWidget *parent) + : DPushButton(parent) +{ + m_font.setWeight(QFont::Medium); + m_font.setPixelSize(DDECalendar::FontSizeFourteen); +} + +void CTodyButton::setBColor(QColor normalC, QColor hoverC, QColor pressc, QColor normalC1, QColor hoverC1, QColor pressc1) +{ + m_bnormalColor = normalC; + m_bhoverColor = hoverC; + m_bPressColor = pressc; + m_dbnormalColor = normalC1; + m_dbhoverColor = hoverC1; + m_dbPressColor = pressc1; + m_shadowColor = m_bnormalColor; +} + +void CTodyButton::setTColor(QColor normalC, QColor hoverC, QColor pressc) +{ + m_tnormalColor = normalC; + m_thoverColor = hoverC; + m_tPressColor = pressc; +} + +void CTodyButton::setshadowColor(QColor sc) +{ + m_shadowColor = sc; +} + +void CTodyButton::mousePressEvent(QMouseEvent *event) +{ + DPalette todaypa = palette(); + todaypa.setColor(DPalette::ButtonText, m_tPressColor); + todaypa.setColor(DPalette::Dark, m_dbPressColor); + todaypa.setColor(DPalette::Light, m_bPressColor); + todaypa.setColor(DPalette::Shadow, m_shadowColor); + setPalette(todaypa); + DPushButton::mousePressEvent(event); +} + +void CTodyButton::mouseReleaseEvent(QMouseEvent *event) +{ + DPalette todaypa = palette(); + todaypa.setColor(DPalette::ButtonText, m_tnormalColor); + todaypa.setColor(DPalette::Dark, m_dbnormalColor); + todaypa.setColor(DPalette::Light, m_bnormalColor); + todaypa.setColor(DPalette::Shadow, m_shadowColor); + setPalette(todaypa); + DPushButton::mouseReleaseEvent(event); +} + +void CTodyButton::focusOutEvent(QFocusEvent *event) +{ + DPalette todaypa = palette(); + todaypa.setColor(DPalette::ButtonText, m_tnormalColor); + todaypa.setColor(DPalette::Dark, m_dbnormalColor); + todaypa.setColor(DPalette::Light, m_bnormalColor); + todaypa.setColor(DPalette::Shadow, m_shadowColor); + setPalette(todaypa); + DPushButton::focusOutEvent(event); +} + +void CTodyButton::enterEvent(QEvent *event) +{ + DPalette todaypa = palette(); + todaypa.setColor(DPalette::ButtonText, m_thoverColor); + todaypa.setColor(DPalette::Dark, m_dbhoverColor); + todaypa.setColor(DPalette::Light, m_bhoverColor); + todaypa.setColor(DPalette::Shadow, m_shadowColor); + setPalette(todaypa); + DPushButton::enterEvent(event); +} + +void CTodyButton::leaveEvent(QEvent *event) +{ + DPalette todaypa = palette(); + todaypa.setColor(DPalette::ButtonText, m_tnormalColor); + todaypa.setColor(DPalette::Dark, m_dbnormalColor); + todaypa.setColor(DPalette::Light, m_bnormalColor); + todaypa.setColor(DPalette::Shadow, m_shadowColor); + setPalette(todaypa); + DPushButton::leaveEvent(event); +} diff -Nru dde-calendar-5.7.0.4/src/customWidget/todybutton.h dde-calendar-5.7.0.23/src/customWidget/todybutton.h --- dde-calendar-5.7.0.4/src/customWidget/todybutton.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/customWidget/todybutton.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,57 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef TODYBUTTON_H +#define TODYBUTTON_H + +#include + +DWIDGET_USE_NAMESPACE +class CTodyButton : public DPushButton +{ + Q_OBJECT +public: + CTodyButton(QWidget *parent = nullptr); + void setBColor(QColor normalC, QColor hoverC, QColor pressc, QColor normalC1, QColor hoverC1, QColor pressc1); + void setTColor(QColor normalC, QColor hoverC, QColor pressc); + void setshadowColor(QColor sc); +protected: + void mousePressEvent(QMouseEvent *event) override; + void mouseReleaseEvent(QMouseEvent *event) override; + void focusOutEvent(QFocusEvent *event) override; + void enterEvent(QEvent *event) override; + void leaveEvent(QEvent *event) override; +private: + QColor m_bnormalColor = "#FFFFFF"; + QColor m_bhoverColor = "#FFFFFF"; + QColor m_bPressColor = "#FFFFFF"; + QColor m_dbnormalColor = "#FFFFFF"; + QColor m_dbhoverColor = "#FFFFFF"; + QColor m_dbPressColor = "#FFFFFF"; + QColor m_tnormalColor = "#000000"; + QColor m_thoverColor = "#000000"; + QColor m_tPressColor = "#000000"; + QColor m_shadowColor = "#FFFFFF"; + QFont m_font; + bool m_pressstate = false; + bool m_hovertate = false; +}; + +#endif // TODYBUTTON_H diff -Nru dde-calendar-5.7.0.4/src/dataManage/schedulecoormanage.cpp dde-calendar-5.7.0.23/src/dataManage/schedulecoormanage.cpp --- dde-calendar-5.7.0.4/src/dataManage/schedulecoormanage.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/dataManage/schedulecoormanage.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,259 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#include "schedulecoormanage.h" + +#include + +CScheduleCoorManage::CScheduleCoorManage() +{ + +} + +CScheduleCoorManage::~CScheduleCoorManage() +{ + +} + +void CScheduleCoorManage::setRange( int w, int h, QDate begindate, QDate enddate, int rightmagin) +{ + m_width = w; + m_height = h; + m_rightmagin = rightmagin; + m_begindate = begindate; + m_enddate = enddate; + m_totalDay = begindate.daysTo(enddate) + 1; +} + +void CScheduleCoorManage::setDateRange( QDate begindate, QDate enddate ) +{ + m_begindate = begindate; + m_enddate = enddate; + m_totalDay = begindate.daysTo(enddate) + 1; +} + +QRectF CScheduleCoorManage::getDrawRegion( QDateTime begintime, QDateTime endtime ) +{ + QRectF rect; + QString bb = begintime.toString("yyyyMMddhhmmsszzz"); + QString ee = endtime.toString("yyyyMMddhhmmsszzz"); + + if (begintime > endtime) return rect; + + QDate begindate = begintime.date(); + QDate enddate = endtime.date(); + QTime beginzero(0, 0, 0); + QTime beginScheduleT = begintime.time(); + QTime endScheduleT = endtime.time(); + + if (begindate < m_begindate || enddate > m_enddate) return rect; + + qint64 beginday = m_begindate.daysTo(begindate) + 1; + qint64 day = begindate.daysTo(enddate) + 1; + int ScheduleBT = beginzero.secsTo(beginScheduleT); + int ScheduleET = beginzero.secsTo(endScheduleT); + qreal rWidth = m_width * (1.0 * day / m_totalDay); + qreal rHeight = m_height * ((ScheduleET - ScheduleBT) / 86400.0); + qreal posX = m_width * (1.0 * (beginday - 1) / m_totalDay); + qreal posY = m_height * (ScheduleBT / 86400.0); + rect = QRectF(posX, posY, rWidth, rHeight); + + return rect; +} + +QRectF CScheduleCoorManage::getDrawRegion(QDateTime begintime, QDateTime endtime, int index, int coount) +{ + QRectF rect; + QString bb = begintime.toString("yyyyMMddhhmmsszzz"); + QString ee = endtime.toString("yyyyMMddhhmmsszzz"); + + if (begintime > endtime) return rect; + + QDate begindate = begintime.date(); + QDate enddate = endtime.date(); + QTime beginzero(0, 0, 0); + QTime beginScheduleT = begintime.time(); + QTime endScheduleT = endtime.time(); + + if (begindate < m_begindate || enddate > m_enddate) return rect; + qint64 beginday = m_begindate.daysTo(begindate) + 1; + qint64 day = begindate.daysTo(enddate) + 1; + int ScheduleBT = beginzero.secsTo(beginScheduleT); + int ScheduleET = beginzero.secsTo(endScheduleT); + qreal rWidth = m_width * (1.0 * day / m_totalDay) / coount; + qreal rHeight = m_height * ((ScheduleET - ScheduleBT) / 86400.0); + qreal posX = m_width * (1.0 * (beginday - 1) / m_totalDay) + (index - 1) * rWidth; + qreal posY = m_height * (ScheduleBT / 86400.0); + rect = QRectF(posX, posY, rWidth, rHeight); + + return rect; +} + +QRectF CScheduleCoorManage::getDrawRegion(QDate date, QDateTime begintime, QDateTime endtime, int index, int coount, int maxnum, int type) +{ + QRectF rect; + QString bb = begintime.toString("yyyyMMddhhmmsszzz"); + QString ee = endtime.toString("yyyyMMddhhmmsszzz"); + + if (begintime > endtime) return rect; + + QDate begindate = begintime.date(); + QDate enddate = endtime.date(); + QTime beginzero(0, 0, 0); + QTime beginScheduleT = begintime.time(); + QTime endScheduleT = endtime.time(); + + if (begindate < date) { + begindate = date; + beginScheduleT = beginzero; + } + if (enddate > date) { + enddate = date; + endScheduleT = QTime(23, 59, 59); + } + + qint64 beginday = m_begindate.daysTo(begindate) + 1; + qint64 day = begindate.daysTo(enddate) + 1; + int ScheduleBT = beginzero.secsTo(beginScheduleT); + int ScheduleET = beginzero.secsTo(endScheduleT); + qreal rWidth = m_width * (1.0 * day / m_totalDay) / coount; + qreal rHeight = m_height * ((ScheduleET - ScheduleBT) / 86400.0); + qreal posX = m_width * (1.0 * (beginday - 1) / m_totalDay) + (index - 1) * rWidth; + qreal posY = m_height * (ScheduleBT / 86400.0); + + if (coount > maxnum && type == 0) { + qreal sscale = 27.0 / (m_width * (1.0 * day / m_totalDay)); + + if (index < maxnum + 1) { + rWidth = m_width * (1.0 * day / m_totalDay) * sscale + 0.5; + posX = m_width * (1.0 * (beginday - 1) / m_totalDay) + (index - 1) * rWidth; + } else { + qreal trWidth = m_width * (1.0 * day / m_totalDay) * sscale + 0.5; + rWidth = m_width * (1.0 * day / m_totalDay) - (index - 1) * trWidth; + posX = m_width * (1.0 * (beginday - 1) / m_totalDay) + (index - 1) * trWidth; + } + } + + if (rHeight < 20) { + if (posY + 20 > m_height) + posY = m_height - 20; + rHeight = 20; + } + + if (posX < 1) { + posX = 1; + rWidth = rWidth - posX; + } + + rect = QRectF(posX, posY, rWidth, rHeight); + + return rect; +} + +QRectF CScheduleCoorManage::getDrawRegionF( QDateTime begintime, QDateTime endtime ) +{ + QRectF rectf; + + if (begintime > endtime) return rectf; + + QDate begindate = begintime.date(); + QDate enddate = endtime.date(); + QTime beginzero(0, 0, 0); + QTime beginScheduleT = begintime.time(); + QTime endScheduleT = endtime.time(); + + if (begindate < m_begindate || enddate > m_enddate) return rectf; + + qint64 beginday = m_begindate.daysTo(begindate) + 1; + qint64 day = begindate.daysTo(enddate) + 1; + int ScheduleBT = beginzero.secsTo(beginScheduleT); + int ScheduleET = beginzero.secsTo(endScheduleT); + qreal rWidth = m_width * (1.0 * day / m_totalDay); + qreal rHeight = m_height * ((ScheduleET - ScheduleBT) / 86400.0); + qreal posX = m_width * (1.0 * (beginday - 1) / m_totalDay); + qreal posY = m_height * (ScheduleBT / 86400.0); + rectf = QRectF(posX, posY, rWidth, rHeight); + + return rectf; +} + +QRectF CScheduleCoorManage::getAllDayDrawRegion(QDate begin, QDate end) +{ + QRectF rect; + if (begin > end) return rect; + + QDate begindate = begin; + QDate enddate = end; + + if (begindate < m_begindate) begindate = m_begindate; + if (enddate > m_enddate) enddate = m_enddate; + + qint64 beginday = m_begindate.daysTo(begindate); + qint64 day = begindate.daysTo(enddate) + 1; + qreal rWidth = m_width * (1.0 * day / m_totalDay) - 12; + qreal rHeight = m_height; + qreal posX = m_width * (1.0 * beginday / m_totalDay); + qreal posY = 0; + rect = QRectF(posX + 6, posY, rWidth - m_rightmagin, rHeight); + + return rect; +} + +QDateTime CScheduleCoorManage::getDate(QPointF pos) +{ + QDateTime begintime; + qint64 day = static_cast((1.0 * pos.x() / m_width) * m_totalDay); + + if (day <0) { + day = 0; + } else if (day >=m_totalDay) { + day = m_totalDay-1; + } + int time =static_cast((1.0 * pos.y() / m_height) * 86400.0); + int hours = time / 3600; + int minutes = (time - 3600 * hours) / 60; + int secss = time - 3600 * hours - 60 * minutes; + QDate date = m_begindate.addDays(day); + begintime.setDate(date); + begintime.setTime(QTime(hours, minutes, secss)); + + return begintime; +} + +QDate CScheduleCoorManage::getsDate(QPointF pos) +{ + qint64 day = static_cast((1.0 * pos.x() / m_width) * m_totalDay); + + if (day <0) { + day = 0; + } else if (day >=m_totalDay) { + day = m_totalDay-1; + } + QDate date = m_begindate.addDays(day); + + return date; +} + +float CScheduleCoorManage::getHeight(QTime time) +{ + QTime beginzero(0, 0, 0); + int ScheduleBT = beginzero.secsTo(time); + float posY = static_cast(m_height * (ScheduleBT / 86400.0)); + + return posY; +} diff -Nru dde-calendar-5.7.0.4/src/dataManage/schedulecoormanage.h dde-calendar-5.7.0.23/src/dataManage/schedulecoormanage.h --- dde-calendar-5.7.0.4/src/dataManage/schedulecoormanage.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/dataManage/schedulecoormanage.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#ifndef SCHEDULECOORMANAGE_H +#define SCHEDULECOORMANAGE_H + +#include +#include +#include + +class CScheduleCoorManage +{ +public: + CScheduleCoorManage(); + ~CScheduleCoorManage(); + void setRange(int w, int h, QDate begindate, QDate enddate, int rightmagin); + void setDateRange(QDate begindate, QDate enddate); + int getRightMagin()const + { + return m_rightmagin; + } + QRectF getDrawRegion(QDateTime begintime, QDateTime endtime); + QRectF getDrawRegion(QDateTime begintime, QDateTime endtime, int index, int coount); + QRectF getDrawRegion(QDate date, QDateTime begintime, QDateTime endtime, int index, int coount, int maxNum, int type = 0); + QRectF getDrawRegionF(QDateTime begintime, QDateTime endtime); + QRectF getAllDayDrawRegion(QDate begin, QDate end); + QDateTime getDate(QPointF pos); + QDate getsDate(QPointF pos); + float getHeight(QTime time); + QDate getBegindate() + { + return m_begindate; + } +private: + int m_width; + int m_height; + QDate m_begindate; + QDate m_enddate; + qint64 m_totalDay; + int m_rightmagin = 0; +}; + +#endif // SCHEDULECOORMANAGE_H diff -Nru dde-calendar-5.7.0.4/src/dataManage/scheduledatamanage.cpp dde-calendar-5.7.0.23/src/dataManage/scheduledatamanage.cpp --- dde-calendar-5.7.0.4/src/dataManage/scheduledatamanage.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/dataManage/scheduledatamanage.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,728 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#include "scheduledatamanage.h" +#include "schedulesdbus.h" +#include "calendardbus.h" + +CScheduleDataManage *CScheduleDataManage::m_vscheduleDataManage = new CScheduleDataManage; +CScheduleDataCtrl *CScheduleDataManage::getscheduleDataCtrl() +{ + return m_scheduleDataCtrl; +} + +CHuangliDayDataManage *CScheduleDataManage::getHuangliDayDataManage() +{ + return m_HuangliDayDataManage; +} + +CSchedulesColor CScheduleDataManage::getScheduleColorByType(int type) +{ + CSchedulesColor color; + color.type = -1; + + for (int i = 0; i < m_vScheduleColor.count(); i++) { + if (m_vScheduleColor.at(i).type == type) { + color = m_vScheduleColor.at(i); + break; + } + } + + return color; +} + +QColor CScheduleDataManage::getSystemActiveColor() +{ + return DGuiApplicationHelper::instance()->applicationPalette().highlight().color(); +} + +void CScheduleDataManage::setSearchResult(QVector &vData) +{ + m_vScheduleInfo = vData; +} + +bool CScheduleDataManage::getSearchResult(ScheduleDtailInfo info) +{ + QDateTime date = QDateTime::currentDateTime(); + QDateTime bdate = date.addMonths(-6); + + if (!bdate.isValid()) { + QDateTime tdate = date; + tdate.setDate(QDate(date.date().year(), date.date().month(), 1)); + bdate = tdate.addMonths(-6); + } + + QDateTime edate = date.addMonths(6); + + if (!edate.isValid()) { + QDateTime tdate = date; + tdate.setDate(QDate(date.date().year(), date.date().month(), 1)); + edate = tdate.addMonths(7); + edate = edate.addDays(-1); + } + + for (int i = 0; i < m_vScheduleInfo.size(); i++) { + QVector &scheduleInfolist = m_vScheduleInfo[i].vData; + for (int j = 0; j < scheduleInfolist.count(); j++) { + if (scheduleInfolist.at(j) == info) { + if (bdate < info.beginDateTime && edate > info.endDateTime) + return true; + } + } + } + + return false; +} + +bool CScheduleDataManage::getSearchResult(QDate date) +{ + for (int i = 0; i < m_vScheduleInfo.size(); i++) { + QVector &scheduleInfolist = m_vScheduleInfo[i].vData; + + if (m_vScheduleInfo[i].date == date && !scheduleInfolist.isEmpty()) { + return true; + } + } + return false; +} + +void CScheduleDataManage::setTheMe(int type) +{ + m_theme = type; + m_vScheduleColor.clear(); + + if (type == 0 || type == 1) { + CSchedulesColor workC; + workC.type = 1; + workC.dotColor = "#FB2525"; + workC.dotColor.setAlphaF(0.5); + workC.gradientFromC = "#FBCEB7"; + workC.gradientFromC.setAlphaF(0.7); + workC.gradientToC = "#FA9D9A"; + workC.gradientToC.setAlphaF(0.7); + workC.Purecolor = "#F85566"; + workC.Purecolor.setAlphaF(0.2); + workC.shadowcolor = "#FB2525"; + workC.shadowcolor.setAlphaF(0.5); + workC.textColor = "#000000"; + workC.timeColor = "#B54A4B"; + workC.hightlightgradientFromC = "#FFD0B8"; + workC.hightlightgradientToC = "#FF908D"; + + QColor workP("#F9AEB8"); + workC.hightlightPurecolor = workP; + workC.splitColor = "#FB2525"; + workC.splitColor.setAlphaF(0.5); + workC.hovergradientFromC = "#FFD0B8"; + workC.hovergradientFromC.setAlphaF(0.95); + workC.hovergradientToC = "#FF9D9A"; + workC.hovergradientToC.setAlphaF(0.95); + + QColor workhP("#FFB6BD"); + workhP.setAlphaF(0.8); + workC.hoverPurecolor = workhP; + workC.pressgradientToC = workC.gradientToC; + workC.pressgradientFromC = workC.gradientFromC; + workC.pressPurecolor = workC.Purecolor; + workC.pressgradientToC.setAlphaF(0.8); + workC.pressgradientFromC.setAlphaF(0.8); + workC.pressPurecolor.setAlphaF(0.2); + m_vScheduleColor.append(workC); + + CSchedulesColor lifeC; + lifeC.type = 2; + lifeC.dotColor = "#82D245"; + lifeC.dotColor.setAlphaF(1); + lifeC.gradientFromC = "#B7E6FB"; + lifeC.gradientFromC.setAlphaF(0.7); + lifeC.gradientToC = "#D4FFB3"; + lifeC.gradientToC.setAlphaF(0.7); + lifeC.Purecolor = "#6FFF00"; + lifeC.Purecolor.setAlphaF(0.2); + lifeC.shadowcolor = "#82D245"; + lifeC.textColor = "#000000"; + lifeC.timeColor = "#53A316"; + lifeC.hightlightgradientFromC = "#9AE5FF"; + lifeC.hightlightgradientToC = "#C7FF94"; + + QColor lifeP("#C7FF94"); + lifeC.hightlightPurecolor = lifeP; + lifeC.hovergradientFromC = "#A8E9FF"; + lifeC.hovergradientToC = "#D5FFAF"; + lifeC.hovergradientFromC.setAlphaF(0.95); + lifeC.hovergradientToC.setAlphaF(0.95); + + QColor lifehP("#C4FF98"); + lifehP.setAlphaF(0.8); + lifeC.hoverPurecolor = lifehP; + lifeC.splitColor = "#82D245"; + lifeC.pressgradientToC = lifeC.gradientToC; + lifeC.pressgradientFromC = lifeC.gradientFromC; + lifeC.pressPurecolor = lifeC.Purecolor; + lifeC.pressgradientToC.setAlphaF(0.8); + lifeC.pressgradientFromC.setAlphaF(0.8); + lifeC.pressPurecolor.setAlphaF(0.2); + m_vScheduleColor.append(lifeC); + + CSchedulesColor otherC; + otherC.type = 3; + otherC.dotColor = "#BA60FA"; + otherC.dotColor.setAlphaF(1); + otherC.gradientFromC = "#FBE9B7"; + otherC.gradientFromC.setAlphaF(0.7); + otherC.gradientToC = "#DFB3FF"; + otherC.gradientToC.setAlphaF(0.7); + otherC.Purecolor = "#D191FF"; + otherC.Purecolor.setAlphaF(0.2); + otherC.shadowcolor = "#BA60FA"; + otherC.textColor = "#000000"; + otherC.timeColor = "#8548B1"; + otherC.hightlightgradientFromC = "#FFE8AC"; + otherC.hightlightgradientToC = "#FBA5FF"; + + QColor otherP("#EAC4FF"); + otherC.hightlightPurecolor = otherP; + otherC.hovergradientFromC = "#FFE8AC"; + otherC.hovergradientToC = "#E2A5FF"; + otherC.hovergradientFromC.setAlphaF(0.95); + otherC.hovergradientToC.setAlphaF(0.95); + + QColor otherhP("#E6C5FF"); + otherhP.setAlphaF(0.8); + otherC.hoverPurecolor = otherhP; + otherC.splitColor = "#BA60FA"; + otherC.pressgradientToC = otherC.gradientToC; + otherC.pressgradientFromC = otherC.gradientFromC; + otherC.pressPurecolor = otherC.Purecolor; + otherC.pressgradientToC.setAlphaF(0.8); + otherC.pressgradientFromC.setAlphaF(0.8); + otherC.pressPurecolor.setAlphaF(0.2); + m_vScheduleColor.append(otherC); + + CSchedulesColor solar; + solar.type = 4; + solar.dotColor = "#FF7272"; + solar.dotColor.setAlphaF(1); + solar.gradientFromC = "#FF7272"; + solar.gradientFromC.setAlphaF(0.3); + solar.gradientToC = "#FF7272"; + solar.gradientToC.setAlphaF(0.3); + solar.Purecolor = "#FF7272"; + solar.Purecolor.setAlphaF(0.3); + solar.shadowcolor = "#BA60FA"; + solar.textColor = "#000000"; + solar.timeColor = "#8548B1"; + solar.hightlightgradientFromC = "#F9AAAA"; + solar.hightlightgradientFromC.setAlphaF(1); + solar.hightlightgradientToC = "#F9AAAA"; + solar.hightlightgradientToC.setAlphaF(1); + solar.hightlightPurecolor = "#F9AAAA"; + solar.hightlightPurecolor.setAlphaF(1); + solar.hovergradientFromC = "#FFB0B1"; + solar.hovergradientToC = "#FFB0B1"; + solar.hovergradientFromC.setAlphaF(0.95); + solar.hovergradientToC.setAlphaF(0.95); + solar.hoverPurecolor = "#FF7272"; + solar.splitColor = "#FF7272"; + solar.pressgradientFromC = "#FF7272"; + solar.pressgradientFromC.setAlphaF(0.3); + solar.pressgradientToC = "#FF7272"; + solar.pressgradientToC.setAlphaF(0.3); + solar.pressPurecolor = solar.Purecolor; + solar.pressgradientToC.setAlphaF(0.4); + solar.pressgradientFromC.setAlphaF(0.4); + solar.pressPurecolor.setAlphaF(0.1); + m_vScheduleColor.append(solar); + } else if (type == 2) { + CSchedulesColor workC; + workC.type = 1; + workC.dotColor = "#F85566"; + workC.dotColor.setAlphaF(0.5); + workC.gradientFromC = "#965A26"; + workC.gradientToC = "#8B2521"; + workC.gradientToC.setAlphaF(0.5); + workC.gradientFromC.setAlphaF(0.5); + workC.Purecolor = "#F85566"; + workC.Purecolor.setAlphaF(0.1); + workC.shadowcolor = "#FB2525"; + workC.shadowcolor.setAlphaF(0.5); + workC.textColor = "#C0C6D4"; + workC.timeColor = "#B54A4B"; + workC.hightlightgradientToC = "#992D2A"; + workC.hightlightgradientToC.setAlphaF(0.8); + workC.hightlightgradientFromC = "#8B521F"; + workC.hightlightgradientFromC.setAlphaF(0.8); + + QColor workP("#77373E"); + workP.setAlphaF(0.8); + workC.hightlightPurecolor = workP; + workC.hovergradientFromC = "#965A26"; + workC.hovergradientToC = "#8B2521"; + workC.hovergradientFromC.setAlphaF(0.65); + workC.hovergradientToC.setAlphaF(0.65); + + QColor workhP("#F85566"); + workhP.setAlphaF(0.2); + workC.hoverPurecolor = workhP; + workC.splitColor = "#F85566"; + workC.splitColor.setAlphaF(0.5); + workC.pressgradientToC = workC.gradientToC; + workC.pressgradientFromC = workC.gradientFromC; + workC.pressPurecolor = workC.Purecolor; + workC.pressgradientToC.setAlphaF(0.4); + workC.pressgradientFromC.setAlphaF(0.4); + workC.pressPurecolor.setAlphaF(0.15); + m_vScheduleColor.append(workC); + + CSchedulesColor lifeC; + lifeC.type = 2; + lifeC.dotColor = "#59F88D"; + lifeC.dotColor.setAlphaF(0.5); + lifeC.gradientFromC = "#2D6883"; + lifeC.gradientToC = "#5D7D44"; + lifeC.gradientToC.setAlphaF(0.5); + lifeC.gradientFromC.setAlphaF(0.5); + lifeC.Purecolor = "#59F88D"; + lifeC.Purecolor.setAlphaF(0.1); + lifeC.shadowcolor = "#25FA6B"; + lifeC.shadowcolor.setAlphaF(0.5); + lifeC.textColor = "#C0C6D4"; + lifeC.timeColor = "#38A35B"; + lifeC.hightlightgradientFromC = "#2D6883"; + lifeC.hightlightgradientFromC.setAlphaF(0.8); + lifeC.hightlightgradientToC = "#5D7D44"; + lifeC.hightlightgradientToC.setAlphaF(0.8); + + QColor lifeP("#337044"); + lifeP.setAlphaF(0.8); + lifeC.hightlightPurecolor = lifeP; + lifeC.splitColor = "#25FA6B"; + lifeC.splitColor.setAlphaF(0.3); + lifeC.hovergradientFromC = "#2D6883"; + lifeC.hovergradientToC = "#5D7D44"; + lifeC.hovergradientFromC.setAlphaF(0.65); + lifeC.hovergradientToC.setAlphaF(0.65); + + QColor lifehP("#59F88D"); + lifehP.setAlphaF(0.2); + lifeC.hoverPurecolor = lifehP; + lifeC.pressgradientToC = lifeC.gradientToC; + lifeC.pressgradientFromC = lifeC.gradientFromC; + lifeC.pressPurecolor = lifeC.Purecolor; + lifeC.pressgradientToC.setAlphaF(0.4); + lifeC.pressgradientFromC.setAlphaF(0.4); + lifeC.pressPurecolor.setAlphaF(0.15); + m_vScheduleColor.append(lifeC); + + CSchedulesColor otherC; + otherC.type = 3; + otherC.dotColor = "#C155F8"; + otherC.dotColor.setAlphaF(0.7); + otherC.gradientFromC = "#8C4E2C"; + otherC.gradientToC = "#7D37AF"; + otherC.gradientToC.setAlphaF(0.5); + otherC.gradientFromC.setAlphaF(0.5); + otherC.Purecolor = "#C155F8"; + otherC.Purecolor.setAlphaF(0.1); + otherC.shadowcolor = "#BE3DFF"; + otherC.shadowcolor.setAlphaF(0.5); + otherC.textColor = "#C0C6D4"; + otherC.timeColor = "#9857C8"; + otherC.hightlightgradientFromC = "#8C4E2C"; + otherC.hightlightgradientFromC.setAlphaF(0.8); + otherC.hightlightgradientToC = "#803BAE"; + otherC.hightlightgradientToC.setAlphaF(0.8); + + QColor otherP("#613776"); + otherP.setAlphaF(0.8); + otherC.hightlightPurecolor = otherP; + otherC.hovergradientFromC = "#8C4E2C"; + otherC.hovergradientToC = "#7D37AF"; + otherC.hovergradientFromC.setAlphaF(0.65); + otherC.hovergradientToC.setAlphaF(0.65); + + QColor otherhP("#C155F8"); + otherhP.setAlphaF(0.2); + otherC.hoverPurecolor = otherhP; + otherC.splitColor = "#BA32FF"; + otherC.splitColor.setAlphaF(0.5); + otherC.pressgradientToC = otherC.gradientToC; + otherC.pressgradientFromC = otherC.gradientFromC; + otherC.pressPurecolor = otherC.Purecolor; + otherC.pressgradientToC.setAlphaF(0.4); + otherC.pressgradientFromC.setAlphaF(0.4); + otherC.pressPurecolor.setAlphaF(0.15); + m_vScheduleColor.append(otherC); + + CSchedulesColor solar; + solar.type = 4; + solar.dotColor = "#FF7272"; + solar.dotColor.setAlphaF(0.8); + solar.gradientFromC = "#FF7272"; + solar.gradientFromC.setAlphaF(0.3); + solar.gradientToC = "#FF7272"; + solar.gradientToC.setAlphaF(0.3); + solar.Purecolor = "#FF7272"; + solar.Purecolor.setAlphaF(0.3); + solar.shadowcolor = "#BA60FA"; + solar.textColor = "#C0C6D4"; + solar.timeColor = "#8548B1"; + solar.hightlightgradientFromC = "#A24545"; + solar.hightlightgradientFromC.setAlphaF(0.8); + solar.hightlightgradientToC = "#A24545"; + solar.hightlightgradientToC.setAlphaF(0.8); + solar.hightlightPurecolor = "#A24545"; + solar.hightlightPurecolor.setAlphaF(0.8); + solar.hovergradientFromC = "#E56464"; + solar.hovergradientToC = "#E56464"; + solar.hovergradientFromC.setAlphaF(0.35); + solar.hovergradientToC.setAlphaF(0.35); + solar.hoverPurecolor = "#E56464"; + solar.splitColor = "#FF7272"; + solar.pressgradientFromC = "#FF7272"; + solar.pressgradientFromC.setAlphaF(0.3); + solar.pressgradientToC = solar.pressgradientFromC; + solar.pressPurecolor = solar.Purecolor; + solar.pressgradientToC.setAlphaF(0.4); + solar.pressgradientFromC.setAlphaF(0.4); + solar.pressPurecolor.setAlphaF(0.1); + m_vScheduleColor.append(solar); + } +} + +CScheduleDataManage *CScheduleDataManage::getScheduleDataManage() +{ + return m_vscheduleDataManage; +} + +void CScheduleDataManage::clear() +{ + delete m_scheduleDataCtrl; +} + +CScheduleDataManage::CScheduleDataManage () +{ + m_scheduleDataCtrl = new CScheduleDataCtrl; + m_HuangliDayDataManage = new CHuangliDayDataManage; + + m_GetAllYearScheduleInfo = new YearScheduleInfo(); + CSchedulesColor workC; + workC.type = 1; + workC.gradientFromC = "#FBCEB7"; + workC.gradientToC = "#FA9D9A"; + workC.Purecolor = "#F85566"; + workC.Purecolor.setAlphaF(0.2); + workC.shadowcolor = "#FB2525"; + workC.shadowcolor.setAlphaF(0.5); + workC.textColor = "#000000"; + workC.timeColor = "#B54A4B"; + m_vScheduleColor.append(workC); + + CSchedulesColor lifeC; + lifeC.type = 2; + lifeC.gradientFromC = "#B7E6FB"; + lifeC.gradientToC = "#D4FFB3"; + lifeC.Purecolor = "#6FFF00"; + lifeC.Purecolor.setAlphaF(0.2); + lifeC.shadowcolor = "#82D245"; + lifeC.textColor = "#000000"; + lifeC.timeColor = "#53A316"; + m_vScheduleColor.append(lifeC); + + CSchedulesColor otherC; + otherC.type = 3; + otherC.gradientFromC = "#FBE9B7"; + otherC.gradientToC = "#DFB3FF"; + otherC.Purecolor = "#D191FF"; + otherC.Purecolor.setAlphaF(0.2); + otherC.shadowcolor = "#BA60FA"; + otherC.textColor = "#000000"; + otherC.timeColor = "#8548B1"; + m_vScheduleColor.append(otherC); + + CSchedulesColor solar; + solar.type = 4; + solar.dotColor = "#FF7272"; + solar.dotColor.setAlphaF(1); + solar.gradientFromC = "#FF7272"; + solar.gradientFromC.setAlphaF(0.3); + solar.gradientToC = "#FF7272"; + solar.gradientToC.setAlphaF(0.3); + solar.Purecolor = "#FF7272"; + solar.Purecolor.setAlphaF(0.3); + solar.shadowcolor = "#BA60FA"; + solar.textColor = "#000000"; + solar.timeColor = "#8548B1"; + m_vScheduleColor.append(solar); +} + +CScheduleDataManage::~CScheduleDataManage() +{ + delete m_scheduleDataCtrl; + delete m_HuangliDayDataManage; + delete m_GetAllYearScheduleInfo; +} + +YearScheduleInfo *CScheduleDataManage::getGetAllYearScheduleInfo() const +{ + return m_GetAllYearScheduleInfo; +} + +int CScheduleDataManage::getFirstWeekDay() const +{ + return m_firstWeekDay; +} + +void CScheduleDataManage::setFirstWeekDay(int firstWeekDay) +{ + m_firstWeekDay = firstWeekDay; +} + +QDate CScheduleDataManage::getFirstOfMonth(const QDate &date) +{ + const QDate firstDay(date.year(), date.month(), 1); + int offset = firstDay.dayOfWeek() % 7 - m_firstWeekDay ; + + const int day = offset <0 ?offset +7:offset; + return firstDay.addDays(0 - day); +} + +void CScheduleDataManage::setCurrentYear(int CurrentYear) +{ + m_CurrentYear = CurrentYear; + m_GetAllYearScheduleInfo->m_year = m_CurrentYear; + + for (int i = 1; i < 13; ++i) { + m_GetAllYearScheduleInfo->m_firstDay[i] = + getFirstOfMonth(QDate(m_CurrentYear,i,1)); + } + +} + +ScheduleDtailInfo CScheduleDataManage::getPressSelectInfo() const +{ + return m_PressSelectInfo; +} + +void CScheduleDataManage::setPressSelectInfo(const ScheduleDtailInfo &PressSelectInfo) +{ + m_PressSelectInfo = PressSelectInfo; +} + +CScheduleDataCtrl::CScheduleDataCtrl() +{ + qRegisterMetaType>("QVector"); + m_dbus = new CSchedulesDBus("com.deepin.daemon.Calendar", + "/com/deepin/daemon/Calendar/Scheduler", + QDBusConnection::sessionBus(), this); + m_scheduleDateCache = nullptr; + + if (!m_scheduleDateCache) + m_scheduleDateCache = new QMap; + m_thread = new CDataProcessThread(m_dbus); + connect(m_thread, &CDataProcessThread::signalsDataProcess, this, &CScheduleDataCtrl::slotDataProcess); +} + +CScheduleDataCtrl::~CScheduleDataCtrl() +{ + delete m_scheduleDateCache; + delete m_dbus; + delete m_thread; +} + + + +qint64 CScheduleDataCtrl::addSchedule(const ScheduleDtailInfo &scheduledate) +{ + clearData(); + return m_dbus->CreateJob(scheduledate); +} + +bool CScheduleDataCtrl::getScheduleInfoById(int id, ScheduleDtailInfo &out) +{ + return m_dbus->GetJob(id, out); +} + +bool CScheduleDataCtrl::getScheduleInfo(const QDate bdate, const QDate edate, QVector &out) +{ + return m_dbus->GetJobs(bdate.year(), bdate.month(), bdate.day(), edate.year(), edate.month(), edate.day(), out); +} + +bool CScheduleDataCtrl::queryScheduleInfo(QString key, QDateTime starttime, QDateTime endtime, QVector &out) +{ + return m_dbus->QueryJobs(key, starttime, endtime, out); +} + +bool CScheduleDataCtrl::queryScheduleInfo(QString key, QDateTime starttime, QDateTime endtime, QString &out) +{ + return m_dbus->QueryJobs(key, starttime, endtime, out); +} + +bool CScheduleDataCtrl::updateScheduleInfo(const ScheduleDtailInfo &scheduledate) +{ + clearData(); + return m_dbus->UpdateJob(scheduledate); +} + +bool CScheduleDataCtrl::deleteScheduleInfoById(int id) +{ + clearData(); + return m_dbus->DeleteJob(id); +} + +bool CScheduleDataCtrl::GetType(qint64 jobId, ScheduleType &out) +{ + while (m_thread->isRunning()); + return m_dbus->GetType(jobId, out); +} + +QString CScheduleDataCtrl::InfoToJson(const ScheduleDtailInfo &scheduledate) +{ + return m_dbus->createScheduleDtailInfojson(scheduledate); +} + +ScheduleDtailInfo CScheduleDataCtrl::JsonObjectToInfo(QJsonObject &obj) +{ + return m_dbus->parsingScheduleDtailInfojsonID(obj); +} + +void CScheduleDataCtrl::slotupdatescheduleD(QWidget *w, QDate begin, QDate end) +{ + m_currentWidget = w; + m_begindate = begin; + m_enddate = end; + m_thread->DataProcessStart(begin, end); +} + +void CScheduleDataCtrl::slotDataProcess(QVector out) +{ + emit signalsupdatescheduleD(m_currentWidget, out); +} + +void CScheduleDataCtrl::clearData() +{ + while (m_thread->isRunning()); + m_scheduleDateCache->clear(); +} + +CSchedulesDBus *CScheduleDataCtrl::getDbus() const +{ + return m_dbus; +} + +CDataProcessThread::CDataProcessThread(CSchedulesDBus *_DataManage) + : m_DataManage(_DataManage) + , m_stopFlag(false) +{ + Q_ASSERT(m_DataManage != nullptr); +} + +CDataProcessThread::~CDataProcessThread() +{ + //防止未运行完 + m_mutex.lock(); + m_stopFlag = true; + m_mutex.unlock(); + //是否允许 + while (isRunning()) {} +} + +void CDataProcessThread::DataProcessStart(QDate begin, QDate end) +{ + m_mutex.lock(); + this->m_stopFlag = true; + this->m_begindate = begin; + this->m_enddate = end; + m_mutex.unlock(); + + while (isRunning()) {} + m_mutex.lock(); + m_stopFlag = false; + m_mutex.unlock(); + + start(QThread::NormalPriority); +} + +void CDataProcessThread::run() +{ + forever { + //运行 + m_mutex.lock(); + QDate bdate = m_begindate; + QDate edate = m_enddate; + bool t_stopFlag = m_stopFlag; + m_mutex.unlock(); + if (t_stopFlag) + return; + QVector out; + bool flag = m_DataManage->GetJobs(bdate.year(), bdate.month(), bdate.day(), edate.year(), edate.month(), edate.day(), out); + if (!flag) return; + emit signalsDataProcess(out); + break; + } +} + +CHuangliDayDataManage::CHuangliDayDataManage() +{ + m_DBusInter = new CalendarDBus("com.deepin.api.LunarCalendar", + "/com/deepin/api/LunarCalendar", + QDBusConnection::sessionBus(), this); +} + +CHuangliDayDataManage::~CHuangliDayDataManage() +{ + delete m_DBusInter; +} + +bool CHuangliDayDataManage::getSoloDay(QDate date, QString &str) +{ + CaHuangLiDayInfo scurrentDayinfo; + + if (m_DBusInter->GetHuangLiDayCalendar(date.year(), date.month(), date.day(), scurrentDayinfo)) { + if (scurrentDayinfo.mSolarFestival.isEmpty() && scurrentDayinfo.mLunarFestival.isEmpty()) { + str = QString(); + return false; + } else if (!scurrentDayinfo.mSolarFestival.isEmpty() && !scurrentDayinfo.mLunarFestival.isEmpty()) { + str = scurrentDayinfo.mSolarFestival + " " + scurrentDayinfo.mLunarFestival; + return true; + } else { + str = scurrentDayinfo.mSolarFestival + scurrentDayinfo.mLunarFestival; + return true; + } + } + return false; +} + +QVector CHuangliDayDataManage::getDayFlag(QDate date) +{ + QVector vflag; + vflag.resize(42); + vflag.fill(false); + CaHuangLiMonthInfo out; + + if (m_DBusInter->GetHuangLiMonthCalendar(date.year(), date.month(), true, out)) { + if (out.mCaLunarDayInfo.count() == 42) { + for (int i = 0; i < 42; i++) { + if (!out.mCaLunarDayInfo.at(i).mSolarFestival.isEmpty() || !out.mCaLunarDayInfo.at(i).mLunarFestival.isEmpty()) { + vflag[i] = true; + } + } + } + } + return vflag; +} diff -Nru dde-calendar-5.7.0.4/src/dataManage/scheduledatamanage.h dde-calendar-5.7.0.23/src/dataManage/scheduledatamanage.h --- dde-calendar-5.7.0.4/src/dataManage/scheduledatamanage.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/dataManage/scheduledatamanage.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,192 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#ifndef SCHEDULEDATAMANAGE_H +#define SCHEDULEDATAMANAGE_H + +#include "calendardbus.h" +#include "schedulestructs.h" +#include "dbusdatagetthread.h" + +#include + +#include +#include +#include + + +DGUI_USE_NAMESPACE +struct CSchedulesColor { + int type; + QColor gradientFromC; + QColor gradientToC; + QColor dotColor; + QColor Purecolor; + QColor shadowcolor; + QColor textColor; + QColor timeColor; + QColor hightlightgradientFromC; + QColor hightlightgradientToC; + QColor hightlightPurecolor; + QColor hovergradientFromC; + QColor hovergradientToC; + QColor hoverPurecolor; + QColor splitColor; + QColor pressgradientFromC; + QColor pressgradientToC; + QColor pressPurecolor; +}; + +class CSchedulesDBus; +class CScheduleDataCtrl; +class CHuangliDayDataManage; +class CaLunarMonthInfo; + +class CScheduleDataManage +{ +public: + static CScheduleDataManage *getScheduleDataManage(); + CScheduleDataCtrl *getscheduleDataCtrl(); + CHuangliDayDataManage *getHuangliDayDataManage(); + CSchedulesColor getScheduleColorByType(int type); + QColor getSystemActiveColor(); + void setSearchResult(QVector &vData); + bool getSearchResult(ScheduleDtailInfo info);//true 高亮 + bool getSearchResult(QDate date);//true 高亮 + void setTheMe(int type = 0); + int getTheme() + { + return m_theme; + } + void clear(); + ScheduleDtailInfo getPressSelectInfo() const; + void setPressSelectInfo(const ScheduleDtailInfo &PressSelectInfo); + + void setCurrentYear(int CurrentYear); + QDate getFirstOfMonth(const QDate &date); + int getFirstWeekDay() const; + void setFirstWeekDay(int firstWeekDay); + YearScheduleInfo *getGetAllYearScheduleInfo() const; +private: + CScheduleDataManage(); + ~CScheduleDataManage(); +private: + CScheduleDataCtrl *m_scheduleDataCtrl = nullptr; + CHuangliDayDataManage *m_HuangliDayDataManage = nullptr; + QVector m_vScheduleColor; + QVector m_vScheduleInfo; + ScheduleDtailInfo m_PressSelectInfo; + int m_theme = 0; + int m_CurrentYear; + int m_firstWeekDay =0; + YearScheduleInfo *m_GetAllYearScheduleInfo = nullptr; + + static CScheduleDataManage *m_vscheduleDataManage; +}; + +class CDataProcessThread : public QThread +{ + Q_OBJECT +public: + /****** + 功能:构造函数 + 参数:_DataManage 原始数据管理类 + 返回值:无 + ******/ + explicit CDataProcessThread(CSchedulesDBus *_DataManage=nullptr); + /****** + 功能:析构函数 + 参数:无 + 返回值:无 + ******/ + ~CDataProcessThread(); +public: + /****** + 功能:处理数据函数外部调用 + 返回值:无 + ******/ + void DataProcessStart(QDate begin, QDate end); +signals: + /****** + 功能:发送信号函数 + 返回值:无 + ******/ + void signalsDataProcess(QVector out); +protected: + /****** + 功能:多线程处理函数 + 参数:无 + 返回值:无 + ******/ + void run() override; +private: + CSchedulesDBus *m_DataManage; + //锁 + QMutex m_mutex; + //更新类型 + int m_type; + QDate m_begindate; + QDate m_enddate; + //停止标志 + bool m_stopFlag; +}; +class CScheduleDataCtrl: public QObject +{ + Q_OBJECT +public: + CScheduleDataCtrl(); + ~CScheduleDataCtrl() override; + qint64 addSchedule(const ScheduleDtailInfo &scheduledate); + bool getScheduleInfoById(int id, ScheduleDtailInfo &out); + bool getScheduleInfo(const QDate bdate, const QDate edate, QVector &out); + bool queryScheduleInfo(QString key, QDateTime starttime, QDateTime endtime, QVector &out); + bool queryScheduleInfo(QString key, QDateTime starttime, QDateTime endtime, QString &out); + bool updateScheduleInfo(const ScheduleDtailInfo &scheduledate); + bool deleteScheduleInfoById(int id); + bool GetType(qint64 jobId, ScheduleType &out); + QString InfoToJson(const ScheduleDtailInfo &scheduledate); + ScheduleDtailInfo JsonObjectToInfo(QJsonObject &obj); + CSchedulesDBus *getDbus() const; +public slots: + void slotupdatescheduleD(QWidget *w, QDate begin, QDate end); + void slotDataProcess(QVector out); +signals: + void signalsupdatescheduleD(QWidget *w, QVector &data); +private: + void clearData(); +private: + CSchedulesDBus *m_dbus; + QMap *m_scheduleDateCache; + QDate m_begindate; + QDate m_enddate; + QWidget *m_currentWidget; + CDataProcessThread *m_thread; +}; +class CalendarDBus; +class CHuangliDayDataManage: public QObject +{ +public: + CHuangliDayDataManage(); + ~CHuangliDayDataManage() override; + bool getSoloDay(QDate date, QString &str); + //获取节日状态 + QVector getDayFlag(QDate date); +private: + CalendarDBus *m_DBusInter; +}; +#endif // SCHEDULEVIEW_H diff -Nru dde-calendar-5.7.0.4/src/dayhuangliview.cpp dde-calendar-5.7.0.23/src/dayhuangliview.cpp --- dde-calendar-5.7.0.4/src/dayhuangliview.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/dayhuangliview.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,111 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#include "dayhuangliview.h" -#include -#include -#include -#include -#include -#include -#include -#include "schceduledlg.h" -#include -CDayHuangLiLabel::CDayHuangLiLabel( QWidget *parent /*= nullptr*/ ): DLabel (parent) -{ - setMargin(0); -} - -void CDayHuangLiLabel::setbackgroundColor(QColor backgroundColor) -{ - m_backgroundColor = backgroundColor; -} - -void CDayHuangLiLabel::setTextInfo(QColor tcolor, QFont font) -{ - m_textcolor = tcolor; - m_font = font; -} - -void CDayHuangLiLabel::setHuangLiText(QStringList vhuangli, int type) -{ - m_vHuangli = vhuangli; - m_type = type; - if (!vhuangli.isEmpty()) { - QString str = vhuangli.at(0); - for (int i = 1; i < vhuangli.count(); i++) { - str += "." + vhuangli.at(i); - } - setToolTip(str); - } else { - setToolTip(QString()); - } - update(); -} -void CDayHuangLiLabel::paintEvent( QPaintEvent *e ) -{ - Q_UNUSED(e); - int labelwidth = width(); - int labelheight = height(); - - QPainter painter(this); - QRect fillRect = QRect(0, 0, labelwidth, labelheight); - painter.setRenderHints(QPainter::HighQualityAntialiasing); - painter.setBrush(QBrush(m_backgroundColor)); - painter.setPen(Qt::NoPen); - painter.drawRoundedRect(fillRect, 12, 12); - QPixmap pixmap; - if (m_type == 0) - pixmap = DHiDPIHelper::loadNxPixmap(":/resources/icon/dde-yi.svg"); - else { - pixmap = DHiDPIHelper::loadNxPixmap(":/resources/icon/dde-ji.svg"); - } - pixmap.setDevicePixelRatio(devicePixelRatioF()); - painter.save(); - painter.setRenderHint(QPainter::Antialiasing); - painter.setRenderHint(QPainter::HighQualityAntialiasing); - painter.setRenderHint(QPainter::SmoothPixmapTransform); - painter.drawPixmap(QRect(m_leftMagin, m_topMagin + 1, 22, 22), pixmap); - painter.restore(); - - - painter.setFont(m_font); - painter.setPen(m_textcolor); - int bw = m_leftMagin + 34; - int bh = m_topMagin; - int ss = 14; - for (int i = 0; i < m_vHuangli.count(); i++) { - int currentsw = m_vHuangli.at(i).count() * ss; - if (bw + currentsw + 6 > labelwidth) { - painter.drawText(QRect(bw, bh, labelwidth - bw, 21), Qt::AlignLeft, "..."); - break; - } else { - painter.drawText(QRect(bw, bh, currentsw, 21), Qt::AlignLeft, m_vHuangli.at(i)); - bw += currentsw + 10; - } - } -} - -void CDayHuangLiLabel::resizeEvent(QResizeEvent *event) -{ - m_leftMagin = static_cast(0.0424 * width() + 0.5); - m_topMagin = (height() - 20) / 2; - DLabel::resizeEvent(event); -} - - diff -Nru dde-calendar-5.7.0.4/src/dayhuangliview.h dde-calendar-5.7.0.23/src/dayhuangliview.h --- dde-calendar-5.7.0.4/src/dayhuangliview.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/dayhuangliview.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#ifndef DAYHUANGLILABEL_H -#define DAYHUANGLILABEL_H - -#include - -DWIDGET_USE_NAMESPACE -class CDayHuangLiLabel : public DLabel -{ - Q_OBJECT - -public: - explicit CDayHuangLiLabel(QWidget *parent = nullptr); - void setbackgroundColor(QColor backgroundColor); - void setTextInfo(QColor tcolor, QFont font); - void setHuangLiText(QStringList vhuangli, int type = 0); -protected: - void paintEvent ( QPaintEvent *e); - void resizeEvent(QResizeEvent *event); -private: - QStringList m_vHuangli; - QColor m_backgroundColor; - QColor m_textcolor; - QFont m_font; - int m_type = 0; - int m_leftMagin = 14; - int m_topMagin = 18; -}; - -#endif // DAYHUANGLILABEL_H diff -Nru dde-calendar-5.7.0.4/src/daymonthview.cpp dde-calendar-5.7.0.23/src/daymonthview.cpp --- dde-calendar-5.7.0.4/src/daymonthview.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/daymonthview.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,1002 +0,0 @@ -/* - * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ - -#include "calendardbus.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include "daymonthview.h" -#include -#include "constants.h" -#include "dayhuangliview.h" -#include -#include -#include -#include "todybutton.h" -#include "scheduledatamanage.h" -DGUI_USE_NAMESPACE -CDayMonthView::CDayMonthView(QWidget *parent) : CustomFrame(parent) -{ - m_DBusInter = new CalendarDBus("com.deepin.api.LunarCalendar", - "/com/deepin/api/LunarCalendar", - QDBusConnection::sessionBus(), this); - if (!queue) - queue = new QQueue; - if (!lunarCache) - lunarCache = new QMap; - if (!emptyCaHuangLiDayInfo) - emptyCaHuangLiDayInfo = new CaHuangLiDayInfo; - - m_weeklist.append(tr("Monday")); - m_weeklist.append(tr("Tuesday")); - m_weeklist.append(tr("Wednesday")); - m_weeklist.append(tr("Thursday")); - m_weeklist.append(tr("Friday")); - m_weeklist.append(tr("Saturday")); - m_weeklist.append(tr("Sunday")); - initUI(); - initConnection(); - //setFixedSize(DDEDayCalendar::D_MWindowWidth, DDEDayCalendar::D_MWindowHeight); -} - -CDayMonthView::~CDayMonthView() -{ - if (lunarCache !=nullptr) { - delete lunarCache; - lunarCache = nullptr; - } - if ( queue !=nullptr) { - delete queue; - queue = nullptr; - } - if (emptyCaHuangLiDayInfo != nullptr) { - delete emptyCaHuangLiDayInfo; - emptyCaHuangLiDayInfo = nullptr; - } -} -void CDayMonthView::handleCurrentDateChanged(const QDate date, const CaHuangLiDayInfo &detail) -{ - Q_UNUSED(detail); - if (date != m_currentDate) { - setCurrentDate(date); - } -} - -void CDayMonthView::setFirstWeekday(int weekday) -{ - m_firstWeekDay = weekday; - updateDate(); -} -void CDayMonthView::setLunarVisible(bool visible) -{ - m_huanglistate = visible; - m_yiLabel->setVisible(visible); - m_jiLabel->setVisible(visible); - m_currentLuna->setVisible(visible); - m_splitline->setVisible(visible); - update(); -} - -void CDayMonthView::setTheMe(int type) -{ - m_themetype = type; - if (type == 0 || type == 1) { - DPalette anipa = this->palette(); - QColor tbcolor = "#FFFFFF"; - //tbcolor.setAlphaF(0.05); - anipa.setColor(DPalette::Background, tbcolor); - setPalette(anipa); - setBackgroundRole(DPalette::Background); - setBColor(tbcolor); - - DPalette todaypa = m_today->palette(); - QColor todayColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); - todaypa.setColor(DPalette::ButtonText, todayColor); -// todaypa.setColor(DPalette::ButtonText, QColor("#1D81EC")); - todaypa.setColor(DPalette::Dark, Qt::white); - todaypa.setColor(DPalette::Light, Qt::white); - QColor sbcolor("#002A57"); - sbcolor.setAlphaF(0.05); - todaypa.setColor(DPalette::Shadow, sbcolor); - m_today->setPalette(todaypa); - QColor todayhover = "#000000"; - todayhover.setAlphaF(0.1); - QColor todaypress = "#000000"; - todaypress.setAlphaF(0.2); - m_today->setBColor("#FFFFFF", todayhover, todaypress, "#FFFFFF", todayhover, todaypress); -// m_today->setTColor("#1D81EC", "#001A2E", "#0081FF"); - m_today->setTColor(todayColor, "#001A2E", "#0081FF"); - m_today->setshadowColor(sbcolor); - DPalette prevpa = m_prevButton->palette(); - prevpa.setColor(DPalette::Dark, QColor("#E6E6E6")); - prevpa.setColor(DPalette::Light, QColor("#E3E3E3")); - //m_prevButton->setPalette(prevpa); - - DPalette nextvpa = m_nextButton->palette(); - nextvpa.setColor(DPalette::Dark, QColor("#E6E6E6")); - nextvpa.setColor(DPalette::Light, QColor("#E3E3E3")); - //m_nextButton->setPalette(nextvpa); - - m_currentMouth->setTextColor(QColor("#3B3B3B")); - //m_currentMouth->setBColor(tbcolor); - - -// m_currentDay->setTextColor(QColor("#2CA7F8")); - m_currentDay->setTextColor(todayColor); - //m_currentDay->setBColor(tbcolor); - - m_currentWeek->setTextColor(QColor("#414D68")); - //m_currentWeek->setBColor(tbcolor); - - m_currentLuna->setTextColor(QColor("#414D68")); - //m_currentLuna->setBColor(tbcolor); - - m_currentYear->setTextColor(QColor("#414D68")); - //m_currentYear->setBColor(tbcolor); - - - QFont hlabelF; -// hlabelF.setFamily("PingFangSC-Semibold"); - hlabelF.setPixelSize(14); - - QColor yicolor = QColor("#75C18E"); - yicolor.setAlphaF(0.1); - m_yiLabel->setbackgroundColor(yicolor); - m_yiLabel->setTextInfo(QColor("#7B7B7B"), hlabelF); - m_yiLabel->update(); - - QColor jicolor = QColor("#C17575"); - jicolor.setAlphaF(0.1); - m_jiLabel->setbackgroundColor(jicolor); - m_jiLabel->setTextInfo(QColor("#7B7B7B"), hlabelF); - m_jiLabel->update(); - - m_topBorderColor = Qt::red; - m_backgroundCircleColor = "#0081FF"; - - m_defaultTextColor = Qt::black; -// m_currentDayTextColor = "#0081FF"; - m_currentDayTextColor = todayColor; - m_weekendsTextColor = Qt::black; - m_selectedTextColor = Qt::white; - m_festivalTextColor = Qt::black; - m_notCurrentTextColor = "#b2b2b2"; - m_ceventColor = QColor(255, 93, 0); - - - } else if (type == 2) { - DPalette anipa = this->palette(); - QColor tbcolor = "#282828"; - //tbcolor.setAlphaF(0.05); - anipa.setColor(DPalette::Background, tbcolor); - setPalette(anipa); - setBackgroundRole(DPalette::Background); - setBColor(tbcolor); - - DPalette todaypa = m_today->palette(); - QColor todayColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); - todaypa.setColor(DPalette::ButtonText, todayColor); -// todaypa.setColor(DPalette::ButtonText, QColor("#0081FF")); - todaypa.setColor(DPalette::Light, "#484848"); - todaypa.setColor(DPalette::Dark, "#414141"); - QColor sbcolor("#000000"); - sbcolor.setAlphaF(0.05); - todaypa.setColor(DPalette::Shadow, sbcolor); - m_today->setPalette(todaypa); - m_today->setBColor("#484848", "#727272", "#242424", "#414141", "#535353", "#282828"); -// m_today->setTColor("#0081FF", "#FFFFFF", "#0081FF"); - m_today->setTColor(todayColor, "#FFFFFF", "#0081FF"); - m_today->setshadowColor(sbcolor); - DPalette prevpa = m_prevButton->palette(); - prevpa.setColor(DPalette::Dark, QColor("#484848")); - prevpa.setColor(DPalette::Light, QColor("#414141")); - //prevpa.setColor(DPalette::Dark, Qt::black); - //prevpa.setColor(DPalette::Light, Qt::black); - //m_prevButton->setPalette(prevpa); - - DPalette nextvpa = m_nextButton->palette(); - nextvpa.setColor(DPalette::Dark, QColor("#484848")); - nextvpa.setColor(DPalette::Light, QColor("#414141")); - //m_nextButton->setPalette(nextvpa); - - - - m_currentMouth->setTextColor(QColor("#C0C6D4")); - //m_currentMouth->setBColor(tbcolor); - - -// m_currentDay->setTextColor(QColor("#0081FF")); - m_currentDay->setTextColor(todayColor); - //m_currentDay->setBColor(tbcolor); - - m_currentWeek->setTextColor(QColor("#C0C6D4")); - //m_currentWeek->setBColor(tbcolor); - - m_currentLuna->setTextColor(QColor("#C0C6D4")); - //m_currentLuna->setBColor(tbcolor); - - m_currentYear->setTextColor(QColor("#C0C6D4")); - //m_currentYear->setBColor(tbcolor); - - QFont hlabelF; -// hlabelF.setFamily("PingFangSC-Semibold"); - hlabelF.setPixelSize(14); - - QColor yicolor = QColor("#2F8C4D"); - yicolor.setAlphaF(0.2); - m_yiLabel->setbackgroundColor(yicolor); - m_yiLabel->setTextInfo(QColor("#C0C6D4"), hlabelF); - m_yiLabel->update(); - - QColor jicolor = QColor("#A43B3B"); - jicolor.setAlphaF(0.2); - m_jiLabel->setbackgroundColor(jicolor); - m_jiLabel->setTextInfo(QColor("#C0C6D4"), hlabelF); - m_jiLabel->update(); - - m_topBorderColor = Qt::red; - m_backgroundCircleColor = "#0059D2"; - - m_defaultTextColor = "#C0C6D4"; -// m_currentDayTextColor = "#0081FF"; - m_currentDayTextColor = todayColor; - m_weekendsTextColor = Qt::black; - m_selectedTextColor = "#B8D3FF"; - m_festivalTextColor = Qt::black; - m_notCurrentTextColor = "#C0C6D4"; - m_notCurrentTextColor.setAlphaF(0.5); - m_ceventColor = QColor(204, 77, 3); - } - - for (int i(0); i != 42; ++i) { - m_cellList.at(i)->update(); - } -} - -void CDayMonthView::setSearchFlag(bool flag) -{ - m_searchflag = flag; - update(); -} - -void CDayMonthView::updateFlag() -{ - getlineflag(); - update(); -} -void CDayMonthView::setCurrentDate(const QDate date, int type) -{ - Q_UNUSED(type); - if (date.year() < 1900) return; - if (date == m_currentDate) { - return; - } - if (date == QDate::currentDate()) { - m_today->setText(QCoreApplication::translate("today", "Today", "Today")); - } else { - m_today->setText(QCoreApplication::translate("Return Today", "Today", "Return Today")); - } - //if (date == QDate::currentDate()) { - // m_today->setEnabled(false); - // } else { - // m_today->setEnabled(true); - // } - m_currentDate = date; - // to refresh lunar calendar - //updateDate(); -// emit signalcurrentDateChanged(date); - updateCurrentLunar(); -} - -void CDayMonthView::setCellSelectable(bool selectable) -{ - if (selectable == m_cellSelectable) - return; - m_cellSelectable = selectable; -} - -int CDayMonthView::getDateIndex(const QDate &date) const -{ - for (int i = 0; i != 42; ++i) - if (m_days[i] == date) - return i; - - return 0; -} - -bool CDayMonthView::eventFilter(QObject *o, QEvent *e) -{ - QWidget *cell = qobject_cast(o); - if (cell && m_cellList.contains(cell)) { - const int pos = m_cellList.indexOf(cell); - QDate date = m_days[pos]; - if (date.year() < 1900) return false; - if (e->type() == QEvent::Paint) { - paintCell(cell); - } else if (e->type() == QEvent::MouseButtonPress) { - QMouseEvent *mouseEvent = dynamic_cast(e); - if (mouseEvent->button() ==Qt::LeftButton) { - cellClicked(cell); - } - } - } - return false; -} - -void CDayMonthView::updateDate() -{ - const QDate firstDay(m_currentDate.year(), m_currentDate.month(), 1); - const int day = (firstDay.dayOfWeek() + m_firstWeekDay) % 7; - const int currentIndex = day + m_currentDate.day() - 1; - - if (currentIndex < 0) { - return; - } - - for (int i(0); i != 42; ++i) { - m_days[i] = firstDay.addDays(i - day); - } - - setSelectedCell(currentIndex); - getlineflag(); - update(); -} - -void CDayMonthView::getlineflag() -{ - QLocale locale; - CScheduleDataManage *tdataManage = CScheduleDataManage::getScheduleDataManage(); - m_vlineflag.resize(42); - m_vlineflag.fill(false); - QVector out; - if (tdataManage->getscheduleDataCtrl()->getScheduleInfo(m_days[0], m_days[41], out)) { - if (out.count() == 42) - for (int i = 0; i < 42; i++) { - if (!out.at(i).vData.isEmpty()) { - m_vlineflag[i] = true; - } - } - } -} - -void CDayMonthView::initUI() -{ -// m_dayNumFont.setFamily("Helvetica"); - m_dayNumFont.setPixelSize(12); - //m_dayNumFont.setWeight(QFont::Light); - - m_today = new CTodyButton; - - m_today->setText(QCoreApplication::translate("today", "Today", "Today")); - - //m_today->setText(tr("Today")); - m_today->setFixedSize(100, DDEDayCalendar::D_MLableHeight); - DPalette todaypa = m_today->palette(); - QColor todayColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); - todaypa.setColor(DPalette::ButtonText, todayColor); -// todaypa.setColor(DPalette::ButtonText, QColor("#0098FF")); - todaypa.setColor(DPalette::Dark, Qt::white); - todaypa.setColor(DPalette::Light, Qt::white); - QColor sbcolor("#002A57"); - sbcolor.setAlphaF(0.05); - todaypa.setColor(DPalette::Shadow, sbcolor); - QFont todayfont; -// todayfont.setFamily("SourceHanSansSC-Medium"); - todayfont.setPixelSize(14); - m_today->setFont(todayfont); - m_today->setPalette(todaypa); - m_prevButton = new DIconButton(DStyle::SP_ArrowLeft, this); - m_prevButton->setFixedSize(36, 36); - // m_prevButton->setIconSize(QSize(36, 36)); - // m_prevButton->setIcon(QIcon(DHiDPIHelper::loadNxPixmap(":/resources/icon/previous_normal.svg"))); - - m_nextButton = new DIconButton(DStyle::SP_ArrowRight, this); - //m_nextButton->setFixedSize(DDEDayCalendar::D_MLableHeight, DDEDayCalendar::D_MLableHeight); - m_nextButton->setFixedSize(36, 36); - //m_nextButton->setIconSize(QSize(36, 36)); - //m_nextButton->setIcon(QIcon(DHiDPIHelper::loadNxPixmap(":/resources/icon/next_normal.svg"))); - - - QHBoxLayout *titleLayout = new QHBoxLayout; - titleLayout->setMargin(0); - titleLayout->setSpacing(0); - titleLayout->setContentsMargins(0, 0, 0, 3); - //add separator line - m_currentMouth = new CustomFrame(this); - m_currentMouth->setFixedSize(74, DDEDayCalendar::D_MLableHeight); - QFont mlabelF; -// mlabelF.setFamily("SourceHanSansSC"); - mlabelF.setWeight(QFont::Medium); - mlabelF.setPixelSize(24); - m_currentMouth->setTextFont(mlabelF); - m_currentMouth->setTextAlign(Qt::AlignCenter); - titleLayout->addWidget(m_prevButton); - titleLayout->addWidget(m_currentMouth); - titleLayout->addWidget(m_nextButton); - titleLayout->addStretch(); - titleLayout->addWidget(m_today, 0, Qt::AlignRight); - // cells grid - m_gridLayout = new QGridLayout; - m_gridLayout->setMargin(0); - m_gridLayout->setSpacing(0); - for (int r = 0; r != 6; ++r) { - for (int c = 0; c != 7; ++c) { - QWidget *cell = new QWidget; - cell->setFixedSize(DDEDayCalendar::DCellWidth, DDEDayCalendar::DCellHeight); - cell->installEventFilter(this); - cell->setFocusPolicy(Qt::ClickFocus); - m_gridLayout->addWidget(cell, r, c); - m_cellList.append(cell); - } - } - //上半部分 - m_upLayout = new QVBoxLayout; - m_upLayout->setMargin(0); - m_upLayout->setSpacing(0); - m_upLayout->setContentsMargins(22, 9, 0, 7); - m_upLayout->addLayout(titleLayout); - m_upLayout->addLayout(m_gridLayout); - - - //中间部分 - QVBoxLayout *midLayout = new QVBoxLayout; - midLayout->setMargin(0); - midLayout->setSpacing(0); - midLayout->setContentsMargins(0, 0, 0, 20); - m_currentDay = new CustomFrame(this); - m_currentDay->setFixedHeight(DDEDayCalendar::DDLableHeight); - m_currentDay->setMinimumWidth(width()); - m_currentDay->setTextAlign(Qt::AlignCenter); - QFont daylabelF; -// daylabelF.setFamily("DINAlternate"); - daylabelF.setWeight(QFont::Medium); - daylabelF.setPixelSize(100); - m_currentDay->setTextFont(daylabelF); - midLayout->addWidget(m_currentDay); - - - m_currentWeek = new CustomFrame(this); - m_currentWeek->setFixedHeight(DDEDayCalendar::DWLableHeight); - m_currentWeek->setTextAlign(Qt::AlignCenter); - QFont wlabelF; -// wlabelF.setFamily("PingFangSC-Semibold"); - wlabelF.setPixelSize(16); - m_currentWeek->setTextFont(wlabelF); - midLayout->addWidget(m_currentWeek); - midLayout->addSpacing(2); - - m_currentYear = new CustomFrame(this); - m_currentYear->setFixedHeight(DDEDayCalendar::DWLableHeight); - m_currentYear->setTextAlign(Qt::AlignCenter); - m_currentYear->setTextFont(wlabelF); - midLayout->addWidget(m_currentYear); - midLayout->addSpacing(2); - - m_currentLuna = new CustomFrame(this); - m_currentLuna->setFixedHeight(DDEDayCalendar::DHualiInfoLableHeight); - m_currentLuna->setTextAlign(Qt::AlignCenter); - QFont hlabelF; -// hlabelF.setFamily("PingFangSC-Semibold"); - hlabelF.setPixelSize(12); - m_currentLuna->setTextFont(hlabelF); - midLayout->addWidget(m_currentLuna); - - - m_yidownLayout = new QVBoxLayout; - m_yidownLayout->setMargin(0); - m_yidownLayout->setSpacing(0); - m_yidownLayout->setContentsMargins(10, 5, 10, 0); - hlabelF.setPixelSize(14); - m_yiLabel = new CDayHuangLiLabel(this); - m_yiLabel->setbackgroundColor(QColor("#75C18E")); - m_yiLabel->setTextInfo(QColor("#7B7B7B "), hlabelF); - m_yiLabel->setFixedSize(DDEDayCalendar::DHualiDtailLableWidth, DDEDayCalendar::DHualiDtailLableHeight); - m_yidownLayout->addWidget(m_yiLabel); - - m_jidownLayout = new QVBoxLayout; - m_jidownLayout->setMargin(0); - m_jidownLayout->setSpacing(0); - m_jidownLayout->setContentsMargins(10, 10, 10, 10); - - m_jiLabel = new CDayHuangLiLabel(this); - m_jiLabel->setbackgroundColor(QColor("#C17575")); - m_jiLabel->setTextInfo(QColor("#7B7B7B "), hlabelF); - m_jiLabel->setFixedSize(DDEDayCalendar::DHualiDtailLableWidth, DDEDayCalendar::DHualiDtailLableHeight); - m_jidownLayout->addWidget(m_jiLabel); - - m_hhLayout = new QVBoxLayout; - // mainLayout->addWidget(m_weekIndicator, 0, Qt::AlignHCenter); - m_hhLayout->setMargin(0); - m_hhLayout->setSpacing(0); - m_hhLayout->addLayout(m_upLayout); - m_hhLayout->addLayout(midLayout); - - m_splitline = new DHorizontalLine; - - //QFrame *frame = new QFrame(this); - //frame->setFrameShape(QFrame::HLine); - //frame->setFrameShadow(QFrame::Plain); - //frame->setLineWidth(2); - //frame->setFixedSize(241, 2); - m_splitline->setFixedSize(241, 2); - QHBoxLayout *hlineLayout = new QHBoxLayout; - hlineLayout->setMargin(0); - hlineLayout->setSpacing(0); - hlineLayout->setContentsMargins(0, 0, 0, 3); - hlineLayout->addStretch(1); - hlineLayout->addWidget(m_splitline); - hlineLayout->addStretch(1); - m_hhLayout->addLayout(hlineLayout); - m_hhLayout->addLayout(m_yidownLayout); - m_hhLayout->addLayout(m_jidownLayout); - m_hhLayout->addStretch(); - - setLayout(m_hhLayout); -} - -void CDayMonthView::initConnection() -{ - connect(m_prevButton, &DIconButton::clicked, this, &CDayMonthView::slotprev); - connect(m_today, &CTodyButton::clicked, this, &CDayMonthView::slottoday); - connect(m_nextButton, &DIconButton::clicked, this, &CDayMonthView::slotnext); - connect(this, &CDayMonthView::dateSelected, this, &CDayMonthView::handleCurrentDateChanged); -} - -void CDayMonthView::updateDateShow() -{ - QLocale locale; - // if (locale.language() == QLocale::Chinese) { - // m_currentMouth->setTextStr(m_monthList.at(m_currentDate.month() - 1)); - //} else { - m_currentMouth->setTextStr(locale.monthName(m_currentDate.month(), QLocale::ShortFormat)); - //} - //QLocale locale; - //QString monthName(int month, QLocale::FormatType type = LongFormat) - //m_currentMouth->setTextStr(locale.monthName(m_currentDate.month(), QLocale::ShortFormat)); - // m_currentMouth->setText(QString::number(m_currentDate.month()) + tr("mon")); - m_currentDay->setTextStr(QString::number(m_currentDate.day())); - if (m_currentDate.dayOfWeek() > 0) - m_currentWeek->setTextStr(m_weeklist.at(m_currentDate.dayOfWeek() - 1)); - m_currentYear->setTextStr(m_currentDate.toString("yyyy/M")); -} - -void CDayMonthView::updateDateLunarDay() -{ - if (!m_huanglistate) return; - CaHuangLiDayInfo info = getCaHuangLiDayInfo(getDateIndex(m_currentDate)); - m_currentLuna->setTextStr(info.mGanZhiYear + "年 " + "【" + info.mZodiac + "年】" + info.mGanZhiMonth + "月 " + info.mGanZhiDay + "日 "); - QStringList yilist = info.mSuit.split(".", QString::SkipEmptyParts); - QStringList jilist = info.mAvoid.split(".", QString::SkipEmptyParts); - m_yiLabel->setHuangLiText(yilist); - m_jiLabel->setHuangLiText(jilist, 1); -} -const QString CDayMonthView::getCellDayNum(int pos) -{ - return QString::number(m_days[pos].day()); -} - -const QDate CDayMonthView::getCellDate(int pos) -{ - return m_days[pos]; -} -void CDayMonthView::paintCell(QWidget *cell) -{ - const QRect rect(0, 0, cellwidth, cellheight); - - const int pos = m_cellList.indexOf(cell); - const bool isSelectedCell = pos == m_selectedCell; - const bool isCurrentDay = getCellDate(pos) == QDate::currentDate(); - - QPainter painter(cell); - -// painter.drawRoundedRect(cell->rect(), 4, 4); -#if 0 - // draw selected cell background circle - if (isSelectedCell) { - int hh = 0; - QRect fillRect; - if (cell->width() > cell->height()) { - hh = cell->height(); - fillRect = QRect((cell->width() - hh) / 2.0 + 0.5, hh * 0.1071, hh, hh); - } else { - hh = cell->width(); - fillRect = QRect(0, (cell->height() - hh) / 2.0 + hh * 0.1071, hh, hh); - } - QPixmap pixmap; - if (m_themetype == 2) - pixmap = DHiDPIHelper::loadNxPixmap(":/resources/icon/darkchoose30X30_checked .svg").scaled(hh, hh, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - else { - pixmap = DHiDPIHelper::loadNxPixmap(":/resources/icon/choose30X30_checked .svg").scaled(hh, hh, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - } - - pixmap.setDevicePixelRatio(devicePixelRatioF()); - painter.save(); - painter.setRenderHint(QPainter::Antialiasing); - painter.setRenderHint(QPainter::HighQualityAntialiasing); - painter.setRenderHint(QPainter::SmoothPixmapTransform); - //painter.setRenderHints(QPainter::HighQualityAntialiasing); - //painter.setBrush(QBrush(m_backgroundCircleColor)); - //painter.setPen(Qt::NoPen); - painter.drawPixmap(fillRect, pixmap); - painter.restore(); - } - - painter.setPen(Qt::SolidLine); - - const QString dayNum = getCellDayNum(pos); - - // draw text of day - if (isSelectedCell) { - painter.setPen(m_selectedTextColor); - } else if (isCurrentDay) { - painter.setPen(m_currentDayTextColor); - } else { - if (m_currentDate.month() == getCellDate(pos).month()) - painter.setPen(m_defaultTextColor); - else - painter.setPen(m_notCurrentTextColor); - } - -// painter.drawRect(rect); - QRect test; - painter.setFont(m_dayNumFont); - - painter.drawText(rect, Qt::AlignCenter, dayNum, &test); - - painter.end(); -#else - // draw selected cell background circle - if (isSelectedCell) { - int hh = 0; - QRectF fillRect; -// if (cell->width() > cell->height()) { - hh = cell->height(); - fillRect = QRectF((cell->width() - hh) / 2.0 + 4, hh * 0.1271 + 0.5, hh - 8, hh - 8); -// } else { -// hh = cell->width(); -// fillRect = QRectF(0, (cell->height() - hh) / 2.0 + hh * 0.1271, hh - 8, hh - 8); -// } -// QPixmap pixmap; -// if (m_themetype == 2) -// pixmap = DHiDPIHelper::loadNxPixmap(":/resources/icon/darkchoose30X30_checked .svg"); -// else { -// pixmap = DHiDPIHelper::loadNxPixmap(":/resources/icon/choose30X30_checked .svg"); -// } - -// pixmap.setDevicePixelRatio(devicePixelRatioF()); -// painter.save(); -// painter.setRenderHint(QPainter::Antialiasing); -// painter.setRenderHint(QPainter::HighQualityAntialiasing); -// painter.setRenderHint(QPainter::SmoothPixmapTransform); -// //painter.setRenderHints(QPainter::HighQualityAntialiasing); -// //painter.setBrush(QBrush(m_backgroundCircleColor)); -// //painter.setPen(Qt::NoPen); -// painter.drawPixmap(fillRect.toRect(), pixmap); -// painter.restore(); - painter.save(); - painter.setRenderHint(QPainter::Antialiasing); - painter.setBrush(QBrush(CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor())); - painter.setPen(Qt::NoPen); - painter.drawEllipse(fillRect); - painter.restore(); - } - - painter.setPen(Qt::SolidLine); - - const QString dayNum = getCellDayNum(pos); - - // draw text of day - if (isSelectedCell) { - painter.setPen(m_selectedTextColor); - } else if (isCurrentDay) { - painter.setPen(m_currentDayTextColor); - } else { - if (m_currentDate.month() == getCellDate(pos).month()) - painter.setPen(m_defaultTextColor); - else - painter.setPen(m_notCurrentTextColor); - } - -// painter.drawRect(rect); - QRect test; - painter.setFont(m_dayNumFont); - - painter.drawText(rect, Qt::AlignCenter, dayNum, &test); - - if (m_vlineflag.count() == 42) { - if (m_vlineflag[pos]) { - painter.save(); - painter.setRenderHint(QPainter::Antialiasing); - painter.setRenderHint(QPainter::HighQualityAntialiasing); - painter.setRenderHint(QPainter::SmoothPixmapTransform); - QPen pen; - pen.setWidth(2); - pen.setColor(m_ceventColor); - painter.setPen(pen); - painter.setBrush(QBrush(m_ceventColor)); - painter.setPen(Qt::NoPen); - int r = cell->width() * (4 / 25); - if (r < 4) { - r = 4; - } else if ( r > 7) { - r = 7; - } - painter.drawEllipse(cell->width() - r - 6, 4, r, r); - painter.restore(); - } - } - - painter.end(); -#endif -} - -void CDayMonthView::cellClicked(QWidget *cell) -{ - if (!m_cellSelectable) - return; - - const int pos = m_cellList.indexOf(cell); - if (pos == -1) - return; - - setSelectedCell(pos); -} - -void CDayMonthView::setSelectedCell(int index) -{ - if (m_selectedCell == index) - return; - - const int prevPos = m_selectedCell; - m_selectedCell = index; - - updateDate(); - m_cellList.at(prevPos)->update(); - m_cellList.at(index)->update(); - if (m_currentDate.year() < 1900) return; - emit signalcurrentDateChanged(m_days[index]); -// emit dateSelected(m_days[index], getCaHuangLiDayInfo(getDateIndex(m_currentDate))); -} -void CDayMonthView::updateCurrentLunar() -{ - updateDate(); - updateDateShow(); - updateDateLunarDay(); - emit signalcurrentLunarDateChanged(m_currentDate, getCaHuangLiDayInfo(getDateIndex(m_currentDate)), 1); -} -const QString CDayMonthView::getLunar(int pos) -{ - CaHuangLiDayInfo info = getCaHuangLiDayInfo(pos); - - if (info.mLunarDayName == "初一") { - info.mLunarDayName = info.mLunarMonthName + info.mLunarDayName; - } - - if (info.mTerm.isEmpty()) - return info.mLunarDayName; - - return info.mTerm; -} - -const CaHuangLiDayInfo CDayMonthView::getCaHuangLiDayInfo(int pos) -{ - const QDate date = m_days[pos]; - - if (lunarCache->contains(date)) { - return lunarCache->value(date); - } - - if (lunarCache->size() > 40) - lunarCache->clear(); - -// QTimer::singleShot(500, [this, pos] {getDbusData(pos);}); - queue->push_back(pos); - - QTimer::singleShot(300, this, SLOT(getDbusData())); - - return *emptyCaHuangLiDayInfo; -} - -void CDayMonthView::getDbusData() -{ - if (queue->isEmpty()) - return; - - const int pos = queue->head(); - queue->pop_front(); - const QDate date = m_days[pos]; - if (!date.isValid()) { - return; - } - - CaHuangLiDayInfo currentDayInfo; - if (!lunarCache->contains(date)) { - CaHuangLiDayInfo scurrentDayinfo; - if (m_DBusInter->GetHuangLiDayCalendar(date.year(), date.month(), date.day(), scurrentDayinfo)) { - lunarCache->insert(date, scurrentDayinfo); - currentDayInfo = scurrentDayinfo; - } - - - } else { - currentDayInfo = lunarCache->value(date); - } - - m_cellList.at(pos)->update(); - - // refresh lunar info - if (date == m_currentDate) { - updateCurrentLunar(); - } -} - -void CDayMonthView::resizeEvent(QResizeEvent *event) -{ - Q_UNUSED(event); - cellwidth = qRound(width() * 0.1005 + 0.5); - cellheight = qRound(height() * 0.0496 + 0.5); - m_gridLayout->setHorizontalSpacing(qRound(width() * 0.0287 + 0.5)); - m_gridLayout->setVerticalSpacing(0); - int leftmagin = qRound(width() * 0.0332 + 0.5); - int rightmagin = leftmagin; - int topmagin = qRound(height() * 0.0164 + 0.5); - int buttonmagin = topmagin; - m_upLayout->setContentsMargins(leftmagin, topmagin, rightmagin, buttonmagin); - m_dayNumFont.setPixelSize(qRound(12 + (width() - 347) / 71.66)); - for (int i(0); i != 42; ++i) { - m_cellList.at(i)->setFixedSize(cellwidth, cellheight); - m_cellList.at(i)->update(); - } - m_splitline->setFixedWidth(qRound(0.6925 * width() + 0.5)); - - int hleftmagin = qRound(width() * 0.026 + 0.5); - int hrightmagin = hleftmagin; - int htopmagin = qRound(height() * 0.01773 + 0.5); - int hbuttonmagin = htopmagin; - int lw = width() - hleftmagin * 2; - int lh = qRound(height() * 0.0992); - m_yiLabel->setFixedSize(lw, lh); - m_yidownLayout->setContentsMargins(hleftmagin, qRound(htopmagin * 0.5), hrightmagin, 0); - m_jiLabel->setFixedSize(lw, lh); - m_jidownLayout->setContentsMargins(hleftmagin, htopmagin, hrightmagin, hbuttonmagin); -} - -void CDayMonthView::wheelEvent(QWheelEvent *event) -{ - //如果是拖拽则退出 - bool isDragging = false; - emit signalIsDragging(isDragging); - if (isDragging) - return; - if (event->delta() < 0) { - m_currentDate = m_currentDate.addDays(1); - if (m_currentDate == QDate::currentDate()) { - m_today->setText(QCoreApplication::translate("today", "Today", "Today")); - } else { - m_today->setText(QCoreApplication::translate("Return Today", "Today", "Return Today")); - } - emit signalcurrentDateChanged(m_currentDate); - updateCurrentLunar(); - } else { - QDate t_curret = m_currentDate.addDays(-1); - if (t_curret.year() < 1900) return; - if (m_currentDate.year() >= 1900) { - //if (m_currentDate.year() == 1900 && m_currentDate.month() == 1) return; - m_currentDate = t_curret; - if (m_currentDate == QDate::currentDate()) { - m_today->setText(QCoreApplication::translate("today", "Today", "Today")); - } else { - m_today->setText(QCoreApplication::translate("Return Today", "Today", "Return Today")); - } - emit signalcurrentDateChanged(m_currentDate); - updateCurrentLunar(); - } else { - //QMessageBox::information(this, tr("infomation"), tr("Year less than 1900!")); - } - } -} - -void CDayMonthView::paintEvent(QPaintEvent *e) -{ - Q_UNUSED(e); - int labelwidth = width(); - int labelheight = height(); - DPalette anipa = this->palette(); - QPainter painter(this); - painter.save(); - painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; - painter.setBrush(anipa.background()); - painter.setPen(Qt::NoPen); - QPainterPath painterPath; - painterPath.moveTo(m_radius, 0); - - painterPath.lineTo(0, 0); - painterPath.lineTo(0, m_radius); - - painterPath.lineTo(0, labelheight - m_radius); - - painterPath.lineTo(0, labelheight); - painterPath.lineTo(m_radius, labelheight); - - painterPath.lineTo(labelwidth - m_radius, labelheight); - - if (!m_searchflag) { - painterPath.arcTo(QRect(labelwidth - m_radius * 2, labelheight - m_radius * 2, m_radius * 2, m_radius * 2), 270, 90); - } else { - painterPath.lineTo(labelwidth, labelheight); - painterPath.lineTo(labelwidth, labelheight - m_radius); - } - painterPath.lineTo(labelwidth, m_radius); - if (!m_searchflag) { - - painterPath.arcTo(QRect(labelwidth - m_radius * 2, 0, m_radius * 2, m_radius * 2), 0, 90); - - } else { - painterPath.lineTo(labelwidth, 0); - painterPath.lineTo(labelwidth - m_radius, 0); - } - painterPath.lineTo(m_radius, 0); - painterPath.closeSubpath(); - painter.drawPath(painterPath); - painter.restore(); - //QFrame::paintEvent(e); -} -void CDayMonthView::slotprev() -{ - emit signalSchedulHide(); - if (m_currentDate.year() == 1900 && m_currentDate.month() == 1) return; - if (m_currentDate.year() >= 1900) { - m_currentDate = m_currentDate.addMonths(-1); - if (m_currentDate == QDate::currentDate()) { - m_today->setText(QCoreApplication::translate("today", "Today", "Today")); - } else { - m_today->setText(QCoreApplication::translate("Return Today", "Today", "Return Today")); - } - emit signalcurrentDateChanged(m_currentDate); - updateCurrentLunar(); - } else { - //QMessageBox::information(this, tr("infomation"), tr("Year less than 1900!")); - } -} - -void CDayMonthView::slotnext() -{ - emit signalSchedulHide(); - m_currentDate = m_currentDate.addMonths(1); - if (m_currentDate == QDate::currentDate()) { - m_today->setText(QCoreApplication::translate("today", "Today", "Today")); - } else { - m_today->setText(QCoreApplication::translate("Return Today", "Today", "Return Today")); - } - emit signalcurrentDateChanged(m_currentDate); - updateCurrentLunar(); -} - -void CDayMonthView::slottoday() -{ - emit signalSchedulHide(); - emit signalsReturnDay(); - setCurrentDate(QDate::currentDate()); -} diff -Nru dde-calendar-5.7.0.4/src/daymonthview.h dde-calendar-5.7.0.23/src/daymonthview.h --- dde-calendar-5.7.0.4/src/daymonthview.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/daymonthview.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,155 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#ifndef DAYMONTHVIEW_H -#define DAYMONTHVIEW_H -#include "constants.h" -#include -#include -#include -#include -#include -#include -#include -#include "calendardbus.h" -#include -#include -#include -#include -#include "customframe.h" -DWIDGET_USE_NAMESPACE -class QLabel; -class CDayHuangLiLabel; -class CTodyButton; -class CDayMonthView: public CustomFrame -{ - Q_OBJECT - -public: - explicit CDayMonthView(QWidget *parent = nullptr); - ~CDayMonthView(); - void setFirstWeekday(int weekday); - int getDateType(const QDate &date); - inline bool cellSelectable() const - { - return m_cellSelectable; - } - void updateSelectState(); - void setLunarVisible(bool visible); - QDate getCurrDate() - { - return m_currentDate; - } - void setTheMe(int type = 0); - void setSearchFlag(bool flag); - void updateFlag(); -signals: - void dateSelected(const QDate date, const CaHuangLiDayInfo &detail) const; - void signalcurrentDateChanged(QDate date); - void signalcurrentLunarDateChanged(QDate date, CaHuangLiDayInfo detail, int type = 0); - void cellSelectableChanged(bool cellSelectable) const; - void signalsReturnDay(); - void signalSchedulHide(); - void signalIsDragging(bool &isDragging); -public slots: - void setCurrentDate(const QDate date, int type = 0); - void setCellSelectable(bool selectable); - void handleCurrentDateChanged(const QDate date, const CaHuangLiDayInfo &detail); - void slottoday(); - -private: - int getDateIndex(const QDate &date) const; - const QString getCellDayNum(int pos); - const QDate getCellDate(int pos); - void paintCell(QWidget *cell); - bool eventFilter(QObject *o, QEvent *e); - void updateDate(); - void getlineflag(); - - const QString getLunar(int pos); - const CaHuangLiDayInfo getCaHuangLiDayInfo(int pos); - void updateCurrentLunar(); - - void initUI(); - void initConnection(); - - void updateDateShow(); - void updateDateLunarDay(); -private slots: - void cellClicked(QWidget *cell); - void setSelectedCell(int index); - void slotprev(); - void slotnext(); - void getDbusData(); -protected: - void resizeEvent(QResizeEvent *event); - void wheelEvent(QWheelEvent *event); - void paintEvent ( QPaintEvent *e); -private: - DIconButton *m_prevButton = nullptr; - DIconButton *m_nextButton = nullptr; - CTodyButton *m_today = nullptr; - CustomFrame *m_currentMouth; - CustomFrame *m_currentDay; - CustomFrame *m_currentYear; - CustomFrame *m_currentWeek; - CustomFrame *m_currentLuna; - CDayHuangLiLabel *m_yiLabel; - CDayHuangLiLabel *m_jiLabel; - QList m_cellList; - QDate m_days[42]; - QDate m_currentDate; - - CalendarDBus *m_DBusInter; - int m_selectedCell = 0; - bool m_cellSelectable = true; - - QFont m_dayNumFont; - - QColor m_topBorderColor = Qt::red; - QColor m_backgroundCircleColor = "#2ca7f8"; - - QColor m_defaultTextColor = Qt::black; - QColor m_currentDayTextColor = "#2ca7f8"; - QColor m_weekendsTextColor = Qt::black; - QColor m_selectedTextColor = Qt::white; - QColor m_festivalTextColor = Qt::black; - QColor m_notCurrentTextColor = "#b2b2b2"; - int m_firstWeekDay; - bool m_huanglistate = true; - QGridLayout *m_gridLayout; - int cellwidth = 20; - int cellheight = 20; - QVBoxLayout *m_hhLayout; - QVBoxLayout *m_upLayout; - DHorizontalLine *m_splitline; - QVBoxLayout *m_yidownLayout; - QVBoxLayout *m_jidownLayout; - - QStringList m_weeklist; - QQueue *queue = nullptr; - QMap *lunarCache = nullptr; - CaHuangLiDayInfo *emptyCaHuangLiDayInfo = nullptr; - int m_themetype = 1; - int m_radius = 8; - bool m_searchflag = false; - QColor m_ceventColor = "#FF5D00"; - QVector m_vlineflag; //节假日和日程标识 -}; - -#endif // YEARVIEW_H diff -Nru dde-calendar-5.7.0.4/src/daywindow.cpp dde-calendar-5.7.0.23/src/daywindow.cpp --- dde-calendar-5.7.0.4/src/daywindow.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/daywindow.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,367 +0,0 @@ -/* - * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#include "daywindow.h" -#include -#include -#include -#include "constants.h" -#include "customframe.h" -#include "daymonthview.h" -#include "schcedulesearchview.h" -#include "scheduleview.h" -DGUI_USE_NAMESPACE -CDayWindow::CDayWindow(QWidget *parent) - : QMainWindow(parent) -{ - initUI(); - initConnection(); -} - -CDayWindow::~CDayWindow() {} -void CDayWindow::setTheMe(int type) -{ - if (type == 0 || type == 1) { - DPalette anipa = m_contentBackground->palette(); - anipa.setColor(DPalette::Background, "#F8F8F8"); - m_contentBackground->setPalette(anipa); - m_contentBackground->setBackgroundRole(DPalette::Background); - - // DPalette leftpa = m_leftground->palette(); - // leftpa.setColor(DPalette::Background, "#FFFFFF"); - // m_leftground->setPalette(leftpa); - // m_leftground->setBackgroundRole(DPalette::Background); - m_leftground->setBColor("#FFFFFF"); - - DPalette ypa = m_YearLabel->palette(); - ypa.setColor(DPalette::WindowText, QColor("#3B3B3B")); - m_YearLabel->setPalette(ypa); - m_YearLabel->setForegroundRole(DPalette::WindowText); - DPalette lpa = m_LunarLabel->palette(); - lpa.setColor(DPalette::WindowText, QColor("#8A8A8A")); - m_LunarLabel->setPalette(lpa); - m_LunarLabel->setForegroundRole(DPalette::WindowText); - DPalette spa = m_SolarDay->palette(); - spa.setColor(DPalette::WindowText, Qt::red); - m_SolarDay->setPalette(spa); - m_SolarDay->setForegroundRole(DPalette::WindowText); - } else if (type == 2) { - DPalette anipa = m_contentBackground->palette(); - QColor bcolor = "#252525"; - // bcolor.setAlphaF(0.05); - anipa.setColor(DPalette::Background, bcolor); - m_contentBackground->setPalette(anipa); - m_contentBackground->setBackgroundRole(DPalette::Background); - // DPalette leftpa = m_leftground->palette(); - // leftpa.setColor(DPalette::Background, "#282828"); - // m_leftground->setPalette(leftpa); - // m_leftground->setBackgroundRole(DPalette::Background); - m_leftground->setBColor("#282828"); - - DPalette ypa = m_YearLabel->palette(); - ypa.setColor(DPalette::WindowText, QColor("#C0C6D4")); - m_YearLabel->setPalette(ypa); - m_YearLabel->setForegroundRole(DPalette::WindowText); - DPalette lpa = m_LunarLabel->palette(); - lpa.setColor(DPalette::WindowText, QColor("#798BA8")); - m_LunarLabel->setPalette(lpa); - m_LunarLabel->setForegroundRole(DPalette::WindowText); - DPalette spa = m_SolarDay->palette(); - spa.setColor(DPalette::WindowText, Qt::red); - m_SolarDay->setPalette(spa); - m_SolarDay->setForegroundRole(DPalette::WindowText); - } - m_daymonthView->setTheMe(type); - // m_schceduleSearchView->setTheMe(type); - m_scheduleView->setTheMe(type); -} - -void CDayWindow::setTime(QTime time) -{ - m_scheduleView->setTime(time); -} - -void CDayWindow::updateHigh() -{ - m_scheduleView->updateHigh(); -} -void CDayWindow::setDate(QDate date) -{ - if (!date.isValid()) - return; - m_currentdate = date; - m_daymonthView->setFirstWeekday(0); - m_daymonthView->setCurrentDate(date); - int w = m_scheduleView->width() - 72; - m_scheduleView->setRange(w, 1032, m_currentdate, m_currentdate); - emit signalCurrentDate(date); -} - -void CDayWindow::setSelectSchedule(const ScheduleDtailInfo &scheduleInfo) -{ - m_scheduleView->setSelectSchedule(scheduleInfo); - -} - -void CDayWindow::setSearchWFlag(bool flag) -{ - m_searchfalg = flag; - m_daymonthView->setSearchFlag(flag); - // m_schceduleSearchView->setVisible(flag); -} - -void CDayWindow::clearSearch() -{ - // m_schceduleSearchView->clearSearch(); -} - -void CDayWindow::setSearchText(QString str) -{ - m_searchText = str; - // m_schceduleSearchView->slotsetSearch(str); -} - -void CDayWindow::setLunarVisible(bool state) -{ - m_LunarLabel->setVisible(state); - m_SolarDay->setVisible(state); - m_scheduleView->setLunarVisible(state); - m_daymonthView->setLunarVisible(state); -} - -void CDayWindow::initUI() -{ - m_contentBackground = new DFrame; - m_contentBackground->setAutoFillBackground(true); - DPalette anipa = m_contentBackground->palette(); - anipa.setColor(DPalette::Background, "#F8F8F8"); - m_contentBackground->setPalette(anipa); - m_contentBackground->setFrameRounded(false); - m_contentBackground->setLineWidth(0); - - QHBoxLayout *titleLayout = new QHBoxLayout; - titleLayout->setMargin(0); - titleLayout->setSpacing(0); - titleLayout->setContentsMargins(10, 9, 0, 3); - - m_YearLabel = new QLabel(); - // m_YearLabel->setMinimumSize(175, DDEDayCalendar::D_YLableHeight); - m_YearLabel->setMinimumHeight(DDEDayCalendar::D_YLableHeight); - QFont labelF; -// labelF.setFamily("SourceHanSansSC"); - labelF.setWeight(QFont::Medium); - labelF.setPixelSize(24); - m_YearLabel->setFont(labelF); - DPalette ypa = m_YearLabel->palette(); - ypa.setColor(DPalette::WindowText, QColor("#3B3B3B")); - m_YearLabel->setPalette(ypa); - titleLayout->addWidget(m_YearLabel); - // titleLayout->addStretch(1); - m_LunarLabel = new QLabel(); - titleLayout->addSpacing(15); - m_LunarLabel->setFixedHeight(DDEDayCalendar::D_YLableHeight); - labelF.setPixelSize(14); - m_LunarLabel->setFont(labelF); - m_LunarLabel->setAlignment(Qt::AlignCenter); - DPalette lpa = m_LunarLabel->palette(); - lpa.setColor(DPalette::WindowText, QColor("#8A8A8A")); - m_LunarLabel->setPalette(lpa); - titleLayout->addWidget(m_LunarLabel); - // titleLayout->addStretch(1); - m_SolarDay = new QLabel(); - labelF.setPixelSize(10); - m_SolarDay->setFixedHeight(DDEDayCalendar::D_YLableHeight); - m_SolarDay->setFont(labelF); - m_SolarDay->setAlignment(Qt::AlignCenter); - DPalette spa = m_SolarDay->palette(); - spa.setColor(DPalette::WindowText, Qt::red); - m_SolarDay->setPalette(spa); - titleLayout->addWidget(m_SolarDay); - titleLayout->addStretch(); - - QVBoxLayout *leftLayout = new QVBoxLayout; - leftLayout->setMargin(0); - leftLayout->setSpacing(0); - m_scheduleView = new CScheduleView(this, 1); - // leftLayout->setContentsMargins(12, 0, 10, 12); - m_scheduleView->setviewMagin(72, 109, 20, 0); - m_scheduleView->setRange(423, 1032, QDate(2019, 8, 12), QDate(2019, 8, 12)); - // m_scheduleView->setFixedSize(513, 450); - leftLayout->addLayout(titleLayout); - leftLayout->addWidget(m_scheduleView); - - m_verline = new DVerticalLine; - m_verline->setFixedWidth(2); - - m_daymonthView = new CDayMonthView(this); - - QHBoxLayout *lfetmainLayout = new QHBoxLayout; - lfetmainLayout->setMargin(0); - lfetmainLayout->setSpacing(1); - lfetmainLayout->setContentsMargins(0, 0, 0, 0); - lfetmainLayout->addLayout(leftLayout); - lfetmainLayout->addWidget(m_verline); - - lfetmainLayout->addWidget(m_daymonthView); - m_leftground = new CustomFrame(); - // m_leftground->setContentsMargins(0, 0, 0, 0); - m_leftground->setRoundState(true, true, true, true); - m_leftground->setLayout(lfetmainLayout); - // m_leftground->setAutoFillBackground(true); - // m_leftground->setFrameRounded(true); - m_leftground->setBColor("#FFFFFF"); - // DPalette leftpa = m_leftground->palette(); - // leftpa.setColor(DPalette::Background, "#FFFFFF"); - // m_leftground->setPalette(leftpa); - - m_mainLayout = new QHBoxLayout; - m_mainLayout->setMargin(0); - m_mainLayout->setSpacing(0); - m_mainLayout->setContentsMargins(10, 10, 10, 10); - m_mainLayout->addWidget(m_leftground); - // mainLayout->addStretch(1); - - // m_schceduleSearchView = new CSchceduleSearchView(this); - // m_schceduleSearchView->setFixedWidth(200); - // m_mainLayout->addWidget(m_schceduleSearchView); - // m_schceduleSearchView->setVisible(false); - - m_contentBackground->setLayout(m_mainLayout); - - setCentralWidget(m_contentBackground); -} - -void CDayWindow::initConnection() -{ - connect(m_daymonthView, &CDayMonthView::signalcurrentLunarDateChanged, this, - &CDayWindow::slotcurrentDateLunarChanged); - connect(m_daymonthView, &CDayMonthView::signalcurrentDateChanged, this, - &CDayWindow::slotcurrentDateChanged); - connect(m_daymonthView, &CDayMonthView::signalsReturnDay, this, - &CDayWindow::slotCurrentReturnDay); - connect(m_scheduleView, &CScheduleView::signalViewtransparentFrame, this, - &CDayWindow::signalViewtransparentFrame); - - connect(m_scheduleView, &CScheduleView::signalsUpdateShcedule, this, - &CDayWindow::slotTransitSchedule); - connect(m_daymonthView, &CDayMonthView::signalSchedulHide - , this, &CDayWindow::slotScheduleHide); - - connect(m_daymonthView,&CDayMonthView::signalIsDragging, - this,&CDayWindow::slotIsDragging); - // connect(m_schceduleSearchView, &CSchceduleSearchView::signalsUpdateShcedule, this, - // &CDayWindow::slotTransitSearchSchedule); - // connect(m_schceduleSearchView, &CSchceduleSearchView::signalDate, this, - // &CDayWindow::slotsearchDateSelect); -} - -void CDayWindow::slotupdateSchedule(int id) -{ - Q_UNUSED(id); - m_daymonthView->setCurrentDate(m_currentdate); - m_scheduleView->setRange(m_currentdate, m_currentdate); - m_daymonthView->updateFlag(); -// if (m_daymonthView->getCurrDate() != m_currentdate) { -// m_scheduleView->setRange(m_currentdate, m_currentdate); -// qDebug()<setDate(m_currentdate); -//// m_scheduleView->slotupdateSchedule(id); -// } else { -// m_scheduleView->slotupdateSchedule(id); -// qDebug()<slotsetSearch(m_searchText); - emit signalsWUpdateShcedule(this, id); - m_daymonthView->updateFlag(); -} - -void CDayWindow::slotTransitSearchSchedule(int id) -{ - m_scheduleView->slotupdateSchedule(); - // m_schceduleSearchView->slotsetSearch(m_searchText); - emit signalsWUpdateShcedule(this, id); -} - -void CDayWindow::slotReturnTodayUpdate() -{ - m_daymonthView->slottoday(); -} - -void CDayWindow::slotCurrentReturnDay() -{ - emit signalsReturnTodayUpdate(this); -} - -void CDayWindow::slotScheduleHide() -{ - m_scheduleView->slotScheduleShow(false); -} - -void CDayWindow::resizeEvent(QResizeEvent *event) -{ - Q_UNUSED(event); - qreal dw = 0.4046 * width(); - int dh = height() - 20; - if (m_searchfalg) { - m_mainLayout->setContentsMargins(10, 10, 0, 10); - } else { - m_mainLayout->setContentsMargins(10, 10, 10, 10); - } - if (dw < 350) - dw = 350; - m_daymonthView->setFixedSize(qRound(dw), dh); -} - -void CDayWindow::slotcurrentDateLunarChanged(QDate date, CaHuangLiDayInfo detail, int type) -{ - m_currentdate = date; - if (type == 1) { - QLocale locale; - if (locale.language() == QLocale::Chinese) { - m_YearLabel->setText(QString::number(date.year()) + tr("Y") + - QString::number(date.month()) + tr("M") + - QString::number(date.day()) + tr("D")); - } else { - m_YearLabel->setText(locale.toString(date, "yyyy/M/d")); - } - m_LunarLabel->setText(detail.mLunarMonthName + detail.mLunarDayName); - } -// m_scheduleView->setRange(m_currentdate, m_currentdate); -// emit signalCurrentDate(date); -} - -void CDayWindow::slotcurrentDateChanged(QDate date) -{ - setDate(date); - slotupdateSchedule(1); -} - -void CDayWindow::slotsearchDateSelect(QDate date) -{ - setDate(date); - slotupdateSchedule(1); -} - -void CDayWindow::slotIsDragging(bool &isDragging) -{ - isDragging = m_scheduleView->IsDragging(); -} diff -Nru dde-calendar-5.7.0.4/src/daywindow.h dde-calendar-5.7.0.23/src/daywindow.h --- dde-calendar-5.7.0.4/src/daywindow.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/daywindow.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,90 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#ifndef DAYWINDOW_H -#define DAYWINDOW_H - -#include -#include -#include -#include -#include -#include "calendardbus.h" -#include "schedulestructs.h" -DWIDGET_USE_NAMESPACE - -class CDayMonthView; -class CScheduleView; -class CSchceduleSearchView; -class QHBoxLayout; -class CustomFrame; -class CDayWindow: public QMainWindow -{ - Q_OBJECT -public: - CDayWindow(QWidget *parent = nullptr); - ~CDayWindow(); - void setDate(QDate date); - void setSelectSchedule(const ScheduleDtailInfo &scheduleInfo); - void setSearchWFlag(bool flag); - void clearSearch(); - void setSearchText(QString str); - void setLunarVisible(bool state); - void setTheMe(int type = 0); - void setTime(QTime time); - void updateHigh(); -private: - void initUI(); - void initConnection(); -signals: - void dateSelected(const QDate date, const CaLunarDayInfo &detail) const; - void signalsWUpdateShcedule(QMainWindow *w, int id = 0); - void signalsReturnTodayUpdate(QMainWindow *w); - void signalViewtransparentFrame(int type); - void signalCurrentDate(QDate date); -public slots: - void slotupdateSchedule(int id = 0); - void slotTransitSchedule(int id = 0); - void slotTransitSearchSchedule(int id = 0); - void slotReturnTodayUpdate(); - void slotCurrentReturnDay(); - void slotScheduleHide(); -protected: - void resizeEvent(QResizeEvent *event); -private slots: - void slotcurrentDateLunarChanged(QDate date, CaHuangLiDayInfo detail, int type = 0); - void slotcurrentDateChanged(QDate date); - void slotsearchDateSelect(QDate date); - void slotIsDragging(bool &isDragging); -private: - CDayMonthView *m_daymonthView; - DFrame *m_contentBackground = nullptr; - CustomFrame *m_leftground = nullptr; - DVerticalLine *m_verline; - QDate m_currentdate; - QLabel *m_YearLabel; - QLabel *m_LunarLabel; - QLabel *m_SolarDay; - CScheduleView *m_scheduleView; - // CSchceduleSearchView *m_schceduleSearchView; - QString m_searchText; - bool m_searchfalg = false; - QHBoxLayout *m_mainLayout; -}; - -#endif // YEARWINDOW_H diff -Nru dde-calendar-5.7.0.4/src/dbus/calendardbus.cpp dde-calendar-5.7.0.23/src/dbus/calendardbus.cpp --- dde-calendar-5.7.0.4/src/dbus/calendardbus.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/dbus/calendardbus.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,359 @@ +/* + * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ + +/* + * This file was generated by qdbusxml2cpp version 0.8 + * Command line was: qdbusxml2cpp -c DCalendarDBus -p dcalendardbus com.deepin.api.LunarCalendar.xml + * + * qdbusxml2cpp is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * This file may have been hand-edited. Look for HAND-EDIT comments + * before re-generating it. + */ + +#include "calendardbus.h" + +/* + * Implementation of interface class DCalendarDBus + */ + +CalendarDBus::CalendarDBus(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) + : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) +{ + QDBusConnection::sessionBus().connect(this->service(), this->path(), "org.freedesktop.DBus.Properties", "PropertiesChanged", "sa{sv}as", this, SLOT(__propertyChanged__(QDBusMessage))); + + CaYearInfo::registerMetaType(); + CaLunarDayInfo::registerMetaType(); + CaLunarMonthInfo::registerMetaType(); + CaSolarMonthInfo::registerMetaType(); + CaHuangLiDayInfo::registerMetaType(); + CaHuangLiMonthInfo::registerMetaType(); +} + +CalendarDBus::~CalendarDBus() +{ + QDBusConnection::sessionBus().disconnect(service(), path(), "org.freedesktop.DBus.Properties", "PropertiesChanged", "sa{sv}as", this, SLOT(propertyChanged(QDBusMessage))); +} + +void CaYearInfo::registerMetaType() +{ + qRegisterMetaType(); + qDBusRegisterMetaType(); +} + +QDebug operator<<(QDebug argument, const CaYearInfo &what) +{ + argument << what.mYear << what.mMonth << what.mDay; + + return argument; +} + +QDBusArgument &operator<<(QDBusArgument &argument, const CaYearInfo &what) +{ + argument.beginStructure(); + argument << what.mYear << what.mMonth << what.mDay; + argument.endStructure(); + + return argument; +} + +const QDBusArgument &operator>>(const QDBusArgument &argument, CaYearInfo &what) +{ + argument.beginStructure(); + argument >> what.mYear >> what.mMonth >> what.mDay; + argument.endStructure(); + + return argument; +} + + +void CaLunarDayInfo::registerMetaType() +{ + qRegisterMetaType(); + qDBusRegisterMetaType(); +} + +QDebug operator<<(QDebug argument, const CaLunarDayInfo &what) +{ + argument << what.mGanZhiYear << what.mGanZhiMonth << what.mGanZhiDay; + argument << what.mLunarMonthName << what.mLunarDayName; + argument << what.mLunarLeapMonth; + argument << what.mZodiac << what.mTerm; + argument << what.mSolarFestival << what.mLunarFestival; + argument << what.mWorktime; + + return argument; +} + +QDBusArgument &operator<<(QDBusArgument &argument, const CaLunarDayInfo &what) +{ + argument.beginStructure(); + argument << what.mGanZhiYear << what.mGanZhiMonth << what.mGanZhiDay; + argument << what.mLunarMonthName << what.mLunarDayName; + argument << what.mLunarLeapMonth; + argument << what.mZodiac << what.mTerm; + argument << what.mSolarFestival << what.mLunarFestival; + argument << what.mWorktime; + argument.endStructure(); + + return argument; +} + +const QDBusArgument &operator>>(const QDBusArgument &argument, CaLunarDayInfo &what) +{ + argument.beginStructure(); + argument >> what.mGanZhiYear >> what.mGanZhiMonth >> what.mGanZhiDay; + argument >> what.mLunarMonthName >> what.mLunarDayName; + argument >> what.mLunarLeapMonth; + argument >> what.mZodiac >> what.mTerm; + argument >> what.mSolarFestival >> what.mLunarFestival; + argument >> what.mWorktime; + argument.endStructure(); + + return argument; +} + + +void CaLunarMonthInfo::registerMetaType() +{ + qRegisterMetaType(); + qDBusRegisterMetaType(); +} + +QDebug operator<<(QDebug argument, const CaLunarMonthInfo &what) +{ + argument << what.mFirstDayWeek << what.mDays; + argument << what.mCaLunarDayInfo; + + return argument; +} + +QDBusArgument &operator<<(QDBusArgument &argument, const CaLunarMonthInfo &what) +{ + argument.beginStructure(); + argument << what.mFirstDayWeek << what.mDays; + argument << what.mCaLunarDayInfo; + argument.endStructure(); + + return argument; +} + +const QDBusArgument &operator>>(const QDBusArgument &argument, CaLunarMonthInfo &what) +{ + argument.beginStructure(); + argument >> what.mFirstDayWeek >> what.mDays; + argument >> what.mCaLunarDayInfo; + argument.endStructure(); + + return argument; +} + + +void CaSolarMonthInfo::registerMetaType() +{ + qRegisterMetaType(); + qDBusRegisterMetaType(); +} + +QDebug operator<<(QDebug argument, const CaSolarMonthInfo &what) +{ + argument << what.mFirstDayWeek << what.mDays; + argument << what.mCaYearInfo; + + return argument; +} + +QDBusArgument &operator<<(QDBusArgument &argument, const CaSolarMonthInfo &what) +{ + argument.beginStructure(); + argument << what.mFirstDayWeek << what.mDays; + argument.endStructure(); + argument << what.mCaYearInfo; + + return argument; +} + +const QDBusArgument &operator>>(const QDBusArgument &argument, CaSolarMonthInfo &what) +{ + argument.beginStructure(); + argument >> what.mFirstDayWeek >> what.mDays; + argument.endStructure(); + argument >> what.mCaYearInfo; + + return argument; +} +#if 1 +void CaHuangLiDayInfo::registerMetaType() +{ + qRegisterMetaType(); + qDBusRegisterMetaType(); +} +QDebug operator<<(QDebug argument, const CaHuangLiDayInfo &what) +{ + argument << what.mSuit << what.mAvoid; + argument << what.mWorktime; + argument << what.mLunarFestival << what.mSolarFestival; + argument << what.mTerm << what.mZodiac; + argument << what.mLunarLeapMonth; + argument << what.mLunarDayName << what.mLunarMonthName; + argument << what.mGanZhiDay << what.mGanZhiMonth << what.mGanZhiYear ; + return argument; +} + +QDBusArgument &operator<<(QDBusArgument &argument, const CaHuangLiDayInfo &what) +{ + argument.beginStructure(); + argument << what.mSuit << what.mAvoid; + argument << what.mWorktime; + argument << what.mLunarFestival << what.mSolarFestival; + argument << what.mTerm << what.mZodiac; + argument << what.mLunarLeapMonth; + argument << what.mLunarDayName << what.mLunarMonthName; + argument << what.mGanZhiDay << what.mGanZhiMonth << what.mGanZhiYear ; + argument.endStructure(); + return argument; +} + +const QDBusArgument &operator>>(const QDBusArgument &argument, CaHuangLiDayInfo &what) +{ + argument.beginStructure(); + argument >> what.mSuit >> what.mAvoid; + argument >> what.mWorktime; + argument >> what.mLunarFestival >> what.mSolarFestival; + argument >> what.mTerm >> what.mZodiac; + argument >> what.mLunarLeapMonth; + argument >> what.mLunarDayName >> what.mLunarMonthName; + argument >> what.mGanZhiDay >> what.mGanZhiMonth >> what.mGanZhiYear ; + argument.endStructure(); + return argument; +} + +void CaHuangLiMonthInfo::registerMetaType() +{ + qRegisterMetaType(); + qDBusRegisterMetaType(); +} + +QDebug operator<<(QDebug argument, const CaHuangLiMonthInfo &what) +{ + argument << what.mDays << what.mFirstDayWeek; + argument << what.mCaLunarDayInfo; + + return argument; +} + +QDBusArgument &operator<<(QDBusArgument &argument, const CaHuangLiMonthInfo &what) +{ + argument.beginStructure(); + argument << what.mDays << what.mFirstDayWeek; + argument << what.mCaLunarDayInfo; + argument.endStructure(); + + return argument; +} + +const QDBusArgument &operator>>(const QDBusArgument &argument, CaHuangLiMonthInfo &what) +{ + argument.beginStructure(); + argument >> what.mDays >> what.mFirstDayWeek; + argument >> what.mCaLunarDayInfo; + argument.endStructure(); + + return argument; +} +#else +void CaHuangLiDayInfo::registerMetaType() +{ + qRegisterMetaType(); + qDBusRegisterMetaType(); +} +QDebug operator<<(QDebug argument, const CaHuangLiDayInfo &what) +{ + argument << what.mGanZhiYear << what.mGanZhiMonth << what.mGanZhiDay; + argument << what.mLunarMonthName << what.mLunarDayName; + argument << what.mLunarLeapMonth; + argument << what.mZodiac << what.mTerm; + argument << what.mSolarFestival << what.mLunarFestival; + argument << what.mWorktime; + argument << what.mAvoid << what.mSuit ; + return argument; +} + +QDBusArgument &operator<<(QDBusArgument &argument, const CaHuangLiDayInfo &what) +{ + argument.beginStructure(); + argument << what.mGanZhiYear << what.mGanZhiMonth << what.mGanZhiDay; + argument << what.mLunarMonthName << what.mLunarDayName; + argument << what.mLunarLeapMonth; + argument << what.mZodiac << what.mTerm; + argument << what.mSolarFestival << what.mLunarFestival; + argument << what.mWorktime; + argument << what.mAvoid << what.mSuit ; + argument.endStructure(); + return argument; +} + +const QDBusArgument &operator>>(const QDBusArgument &argument, CaHuangLiDayInfo &what) +{ + argument.beginStructure(); + argument >> what.mGanZhiYear >> what.mGanZhiMonth >> what.mGanZhiDay; + argument >> what.mLunarMonthName >> what.mLunarDayName; + argument >> what.mLunarLeapMonth; + argument >> what.mZodiac >> what.mTerm; + argument >> what.mSolarFestival >> what.mLunarFestival; + argument >> what.mWorktime; + argument >> what.mAvoid >> what.mSuit ; + argument.endStructure(); + return argument; +} + +void CaHuangLiMonthInfo::registerMetaType() +{ + qRegisterMetaType(); + qDBusRegisterMetaType(); +} + +QDebug operator<<(QDebug argument, const CaHuangLiMonthInfo &what) +{ + argument << what.mFirstDayWeek << what.mDays; + argument << what.mCaLunarDayInfo; + + return argument; +} + +QDBusArgument &operator<<(QDBusArgument &argument, const CaHuangLiMonthInfo &what) +{ + argument.beginStructure(); + argument << what.mFirstDayWeek << what.mDays; + argument << what.mCaLunarDayInfo; + argument.endStructure(); + + return argument; +} +const QDBusArgument &operator>>(const QDBusArgument &argument, CaHuangLiMonthInfo &what) +{ + argument.beginStructure(); + argument >> what.mFirstDayWeek >> what.mDays; + argument >> what.mCaLunarDayInfo; + argument.endStructure(); + + return argument; +} +#endif diff -Nru dde-calendar-5.7.0.4/src/dbus/calendardbus.h dde-calendar-5.7.0.23/src/dbus/calendardbus.h --- dde-calendar-5.7.0.4/src/dbus/calendardbus.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/dbus/calendardbus.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,556 @@ +/* + * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ + +/* + * This file was generated by qdbusxml2cpp version 0.8 + * Command line was: qdbusxml2cpp -c DCalendarDBus -p dcalendardbus com.deepin.api.LunarCalendar.xml + * + * qdbusxml2cpp is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * Do not edit! All changes made to it will be lost. + */ + +#ifndef CALENDARDBUS_H +#define CALENDARDBUS_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +class CaYearInfo +{ +public: + CaYearInfo() {} + + inline static void registerMetaType(); + + friend QDebug operator<<(QDebug argument, const CaYearInfo &what); + friend QDBusArgument &operator<<(QDBusArgument &argument, const CaYearInfo &what); + friend const QDBusArgument &operator>>(const QDBusArgument &argument, CaYearInfo &what); + +public: + qint32 mYear; + qint32 mMonth; + qint32 mDay; +}; + +class CaLunarDayInfo +{ +public: + CaLunarDayInfo() {} + + inline static void registerMetaType(); + + friend QDebug operator<<(QDebug argument, const CaLunarDayInfo &what); + friend QDBusArgument &operator<<(QDBusArgument &argument, const CaLunarDayInfo &what); + friend const QDBusArgument &operator>>(const QDBusArgument &argument, CaLunarDayInfo &what); + +public: + QString mGanZhiYear; + QString mGanZhiMonth; + QString mGanZhiDay; + QString mLunarMonthName; + QString mLunarDayName; + qint32 mLunarLeapMonth; + QString mZodiac; + QString mTerm; + QString mSolarFestival; + QString mLunarFestival; + qint32 mWorktime; +}; + +class CaLunarMonthInfo +{ +public: + CaLunarMonthInfo() {} + + inline static void registerMetaType(); + + friend QDebug operator<<(QDebug argument, const CaLunarMonthInfo &what); + friend QDBusArgument &operator<<(QDBusArgument &argument, const CaLunarMonthInfo &what); + friend const QDBusArgument &operator>>(const QDBusArgument &argument, CaLunarMonthInfo &what); + +public: + qint32 mFirstDayWeek; + qint32 mDays; + QList mCaLunarDayInfo; +}; + +class CaSolarMonthInfo +{ +public: + CaSolarMonthInfo() {} + + inline static void registerMetaType(); + + friend QDebug operator<<(QDebug argument, const CaSolarMonthInfo &what); + friend QDBusArgument &operator<<(QDBusArgument &argument, const CaSolarMonthInfo &what); + friend const QDBusArgument &operator>>(const QDBusArgument &argument, CaSolarMonthInfo &what); +public: + qint32 mFirstDayWeek; + qint32 mDays; + QList mCaYearInfo; +}; + +class CaHuangLiDayInfo +{ +public: + CaHuangLiDayInfo() {} + inline static void registerMetaType(); + friend QDebug operator<<(QDebug argument, const CaHuangLiDayInfo &what); + friend QDBusArgument &operator<<(QDBusArgument &argument, const CaHuangLiDayInfo &what); + friend const QDBusArgument &operator>>(const QDBusArgument &argument, CaHuangLiDayInfo &what); +public: + QString mGanZhiYear; + QString mGanZhiMonth; + QString mGanZhiDay; + QString mLunarMonthName; + QString mLunarDayName; + qint32 mLunarLeapMonth; + QString mZodiac; + QString mTerm; + QString mSolarFestival; + QString mLunarFestival; + qint32 mWorktime; + QString mSuit; + QString mAvoid; +}; + +class CaHuangLiMonthInfo +{ +public: + CaHuangLiMonthInfo() {} + inline static void registerMetaType(); + + friend QDebug operator<<(QDebug argument, const CaHuangLiMonthInfo &what); + friend QDBusArgument &operator<<(QDBusArgument &argument, const CaHuangLiMonthInfo &what); + friend const QDBusArgument &operator>>(const QDBusArgument &argument, CaHuangLiMonthInfo &what); +public: + qint32 mFirstDayWeek; + qint32 mDays; + QList mCaLunarDayInfo; +}; +typedef struct _tagHolidayInfo { + + QDate date; + char status; +} HolidayInfo; + +typedef struct _tagFestivalInfo { + QString ID; + QString FestivalName; + QString description; + QString Rest; + int month; + int year; + QVector listHoliday; +} FestivalInfo; + + +/* + * Proxy class for interface com.deepin.api.LunarCalendar + */ +class CalendarDBus: public QDBusAbstractInterface +{ + Q_OBJECT + + Q_SLOT void __propertyChanged__(const QDBusMessage &msg) + { + QList arguments = msg.arguments(); + if (3 != arguments.count()) + return; + QString interfaceName = msg.arguments().at(0).toString(); + if (interfaceName != "com.deepin.api.LunarCalendar") + return; + QVariantMap changedProps = qdbus_cast(arguments.at(1).value()); + foreach (const QString &prop, changedProps.keys()) { + const QMetaObject *self = metaObject(); + for (int i = self->propertyOffset(); i < self->propertyCount(); ++i) { + QMetaProperty p = self->property(i); + if (p.name() == prop) { + Q_EMIT p.notifySignal().invoke(this); + } + } + } + } +public: + static inline const char *staticInterfaceName() + { + return "com.deepin.api.LunarCalendar"; + } + +public: + CalendarDBus(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); + ~CalendarDBus(); + +public Q_SLOTS: // METHODS + inline QDBusPendingReply GetLunarDateBySolar(int in0, int in1, int in2) + { + QList argumentList; + argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1) << QVariant::fromValue(in2); + + return asyncCallWithArgumentList(QStringLiteral("GetLunarDateBySolar"), argumentList); + } + + inline QDBusReply GetLunarDateBySolar(int in0, int in1, int in2, bool &out1, bool &out2) + { + QList argumentList; + argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1) << QVariant::fromValue(in2); + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetLunarDateBySolar"), argumentList); + + if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 3) { + out1 = qdbus_cast(reply.arguments().at(1)); + out2 = qdbus_cast(reply.arguments().at(2)); + } + + return reply; + } + + inline QDBusPendingReply GetLunarInfoBySolar(int in0, int in1, int in2) + { + QList argumentList; + argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1) << QVariant::fromValue(in2); + + return asyncCallWithArgumentList(QStringLiteral("GetLunarInfoBySolar"), argumentList); + } + + inline QDBusReply GetLunarInfoBySolar(qint32 in0, qint32 in1, qint32 in2, bool &out1) + { + QList argumentList; + argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1) << QVariant::fromValue(in2); + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetLunarInfoBySolar"), argumentList); + + if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 2) { + out1 = qdbus_cast(reply.arguments().at(1)); + } + + return reply; + } + + inline QDBusPendingReply GetLunarMonthCalendar(int in0, int in1, bool in2) + { + QList argumentList; + argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1) << QVariant::fromValue(in2); + + return asyncCallWithArgumentList(QStringLiteral("GetLunarMonthCalendar"), argumentList); + } + + inline QDBusReply GetLunarMonthCalendar(int in0, int in1, bool in2, bool &out1) + { + QList argumentList; + argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1) << QVariant::fromValue(in2); + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetLunarMonthCalendar"), argumentList); + + if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 2) { + out1 = qdbus_cast(reply.arguments().at(1)); + } + + return reply; + } + + inline QDBusPendingReply GetSolarDateByLunar(int in0, int in1, int in2, bool in3) + { + QList argumentList; + argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1) << QVariant::fromValue(in2) << QVariant::fromValue(in3); + + return asyncCallWithArgumentList(QStringLiteral("GetSolarDateByLunar"), argumentList); + } + + inline QDBusReply GetSolarDateByLunar(int in0, int in1, int in2, bool in3, bool &out1) + { + QList argumentList; + argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1) << QVariant::fromValue(in2) << QVariant::fromValue(in3); + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetSolarDateByLunar"), argumentList); + + if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 2) { + out1 = qdbus_cast(reply.arguments().at(1)); + } + + return reply; + } + + inline QDBusPendingReply GetSolarMonthCalendar(int in0, int in1, bool in2) + { + QList argumentList; + argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1) << QVariant::fromValue(in2); + + return asyncCallWithArgumentList(QStringLiteral("GetSolarMonthCalendar"), argumentList); + } + + inline QDBusReply GetSolarMonthCalendar(int in0, int in1, bool in2, bool &out1) + { + QList argumentList; + argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1) << QVariant::fromValue(in2); + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetSolarMonthCalendar"), argumentList); + + if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 2) { + out1 = qdbus_cast(reply.arguments().at(1)); + } + + return reply; + } + + inline bool GetHuangLiMonthCalendar(int in0, int in1, bool in2, CaHuangLiMonthInfo &out) + { + QList argumentList; + argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1) << QVariant::fromValue(in2); + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetHuangLiMonth"), argumentList); + + if (reply.type() != QDBusMessage::ReplyMessage ) { + return false; + } + + QDBusReply huanglimonth = reply; + + if (!huanglimonth.isValid()) return false; + QJsonParseError json_error; + QJsonDocument jsonDoc(QJsonDocument::fromJson(huanglimonth.value().toLocal8Bit(), &json_error)); + + if (json_error.error != QJsonParseError::NoError) { + return false; + } + + QJsonObject rootObj = jsonDoc.object(); + + //因为是预先定义好的JSON数据格式,所以这里可以这样读取 + if (rootObj.contains("Days")) { + out.mDays = rootObj.value("Days").toInt(); + } + if (rootObj.contains("FirstDayWeek")) { + out.mFirstDayWeek = rootObj.value("FirstDayWeek").toInt(); + } + if (rootObj.contains("Datas")) { + QJsonArray subArray = rootObj.value("Datas").toArray(); + for (int i = 0; i < subArray.size(); i++) { + + QJsonObject subObj = subArray.at(i).toObject(); + CaHuangLiDayInfo huangliday; + + //因为是预先定义好的JSON数据格式,所以这里可以这样读取 + if (subObj.contains("Suit")) { + huangliday.mSuit = subObj.value("Suit").toString(); + } + if (subObj.contains("Avoid")) { + huangliday.mAvoid = subObj.value("Avoid").toString(); + } + if (subObj.contains("Worktime")) { + huangliday.mWorktime = subObj.value("Worktime").toInt(); + } + if (subObj.contains("LunarFestival")) { + huangliday.mLunarFestival = subObj.value("LunarFestival").toString(); + } + if (subObj.contains("SolarFestival")) { + huangliday.mSolarFestival = subObj.value("SolarFestival").toString(); + } + if (subObj.contains("Term")) { + huangliday.mTerm = subObj.value("Term").toString(); + } + if (subObj.contains("Zodiac")) { + huangliday.mZodiac = subObj.value("Zodiac").toString(); + } + if (subObj.contains("LunarLeapMonth")) { + huangliday.mLunarLeapMonth = subObj.value("LunarLeapMonth").toInt(); + } + if (subObj.contains("LunarDayName")) { + huangliday.mLunarDayName = subObj.value("LunarDayName").toString(); + } + if (subObj.contains("LunarMonthName")) { + huangliday.mLunarMonthName = subObj.value("LunarMonthName").toString(); + } + if (subObj.contains("GanZhiDay")) { + huangliday.mGanZhiDay = subObj.value("GanZhiDay").toString(); + } + if (subObj.contains("GanZhiMonth")) { + huangliday.mGanZhiMonth = subObj.value("GanZhiMonth").toString(); + } + if (subObj.contains("GanZhiYear")) { + huangliday.mGanZhiYear = subObj.value("GanZhiYear").toString(); + } + out.mCaLunarDayInfo.append(huangliday); + } + } + + return true; + } + + inline bool GetHuangLiDayCalendar(qint32 in0, qint32 in1, qint32 in2, CaHuangLiDayInfo &out) + { + QList argumentList; + argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1) << QVariant::fromValue(in2); + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetHuangLiDay"), argumentList); + + if (reply.type() != QDBusMessage::ReplyMessage ) { + return false; + } + + QDBusReply huangliday = reply; + + if (!huangliday.isValid()) return false; + + QJsonParseError json_error; + QJsonDocument jsonDoc(QJsonDocument::fromJson(huangliday.value().toLocal8Bit(), &json_error)); + + if (json_error.error != QJsonParseError::NoError) { + return false; + } + + QJsonObject rootObj = jsonDoc.object(); + + //因为是预先定义好的JSON数据格式,所以这里可以这样读取 + if (rootObj.contains("Suit")) { + out.mSuit = rootObj.value("Suit").toString(); + } + if (rootObj.contains("Avoid")) { + out.mAvoid = rootObj.value("Avoid").toString(); + } + if (rootObj.contains("Worktime")) { + out.mWorktime = rootObj.value("Worktime").toInt(); + } + if (rootObj.contains("LunarFestival")) { + out.mLunarFestival = rootObj.value("LunarFestival").toString(); + } + if (rootObj.contains("SolarFestival")) { + out.mSolarFestival = rootObj.value("SolarFestival").toString(); + } + if (rootObj.contains("Term")) { + out.mTerm = rootObj.value("Term").toString(); + } + if (rootObj.contains("Zodiac")) { + out.mZodiac = rootObj.value("Zodiac").toString(); + } + if (rootObj.contains("LunarLeapMonth")) { + out.mLunarLeapMonth = rootObj.value("LunarLeapMonth").toInt(); + } + if (rootObj.contains("LunarDayName")) { + out.mLunarDayName = rootObj.value("LunarDayName").toString(); + } + if (rootObj.contains("LunarMonthName")) { + out.mLunarMonthName = rootObj.value("LunarMonthName").toString(); + } + if (rootObj.contains("GanZhiDay")) { + out.mGanZhiDay = rootObj.value("GanZhiDay").toString(); + } + if (rootObj.contains("GanZhiMonth")) { + out.mGanZhiMonth = rootObj.value("GanZhiMonth").toString(); + } + if (rootObj.contains("GanZhiYear")) { + out.mGanZhiYear = rootObj.value("GanZhiYear").toString(); + } + + return true; + } + + inline bool GetFestivalMonth(int in0, int in1, QVector &out) + { + QList argumentList; + argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1); + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetFestivalMonth"), argumentList); + + if (reply.type() != QDBusMessage::ReplyMessage ) { + return false; + } + + QDBusReply festivalMonthinfo = reply; + + if (!festivalMonthinfo.isValid()) return false; + + QJsonParseError json_error; + QJsonDocument jsonDoc(QJsonDocument::fromJson(festivalMonthinfo.value().toLocal8Bit(), &json_error)); + + if (json_error.error != QJsonParseError::NoError) { + return false; + } + + QJsonArray rootarry = jsonDoc.array(); + + for (int i = 0; i < rootarry.size(); i++) { + + QJsonObject subObj = rootarry.at(i).toObject(); + FestivalInfo festivalInfoday; + + //因为是预先定义好的JSON数据格式,所以这里可以这样读取 + if (subObj.contains("id")) { + festivalInfoday.ID = subObj.value("id").toString(); + } + if (subObj.contains("name")) { + festivalInfoday.FestivalName = subObj.value("name").toString(); + } + if (subObj.contains("description")) { + festivalInfoday.description = subObj.value("description").toString(); + } + if (subObj.contains("rest")) { + festivalInfoday.Rest = subObj.value("rest").toString(); + } + if (subObj.contains("month")) { + festivalInfoday.month = subObj.value("month").toInt(); + } + if (subObj.contains("list")) { + QJsonArray sublistArray = subObj.value("list").toArray(); + + for (int j = 0; j < sublistArray.size(); j++) { + + QJsonObject hsubObj = sublistArray.at(j).toObject(); + HolidayInfo dayinfo; + + if (hsubObj.contains("status")) { + dayinfo.status = hsubObj.value("status").toInt(); + } + if (hsubObj.contains("date")) { + dayinfo.date = QDate::fromString(hsubObj.value("date").toString(), "yyyy-M-d"); + } + festivalInfoday.listHoliday.append(dayinfo); + } + } + festivalInfoday.year = in0; + out.append(festivalInfoday); + } + + return true; + } + + +Q_SIGNALS: // SIGNALS +// begin property changed signals +}; + +namespace com { +namespace deepin { +namespace api { +typedef ::CalendarDBus LunarCalendar; +} +} +} + +Q_DECLARE_METATYPE(CaYearInfo) +Q_DECLARE_METATYPE(CaLunarDayInfo) +Q_DECLARE_METATYPE(CaLunarMonthInfo) +Q_DECLARE_METATYPE(CaSolarMonthInfo) +Q_DECLARE_METATYPE(CaHuangLiDayInfo) +Q_DECLARE_METATYPE(CaHuangLiMonthInfo) +#endif diff -Nru dde-calendar-5.7.0.4/src/dbus/creatorparschedule.cpp dde-calendar-5.7.0.23/src/dbus/creatorparschedule.cpp --- dde-calendar-5.7.0.4/src/dbus/creatorparschedule.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/dbus/creatorparschedule.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,312 @@ +/* + * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ + +/* + * This file was generated by qdbusxml2cpp version 0.8 + * Command line was: qdbusxml2cpp -c DCalendarDBus -p dcalendardbus com.deepin.api.LunarCalendar.xml + * + * qdbusxml2cpp is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * This file may have been hand-edited. Look for HAND-EDIT comments + * before re-generating it. + */ + +#include "creatorparschedule.h" +#include "scheduledatamanage.h" + +CreatOrParSchedule::CreatOrParSchedule() +{ + +} + +CreatOrParSchedule::~CreatOrParSchedule() +{ + +} +QString CreatOrParSchedule::createScheduleDtailInfojson(const ScheduleDtailInfo &info) +{ + QJsonObject json; + json.insert("ID", info.id); + json.insert("AllDay", info.allday); + json.insert("Remind", createScheduleRemind(info)); + json.insert("RRule", createScheduleRRule(info)); + json.insert("Title", info.titleName); + json.insert("Description", info.description); + json.insert("Type", info.type.ID); + json.insert("Start", toconvertData(info.beginDateTime)); + json.insert("End", toconvertData(info.endDateTime)); + json.insert("RecurID", info.RecurID); + QJsonArray jsonarry; + for (int i = 0; i < info.ignore.count(); i++) { + jsonarry.append(toconvertData(info.ignore.at(i))); + } + json.insert("Ignore", jsonarry); + // 构建 JSON 文档 + QJsonDocument document; + document.setObject(json); + QByteArray byteArray = document.toJson(QJsonDocument::Compact); + QString strJson(byteArray); + return strJson; +} + +QString CreatOrParSchedule::createScheduleTypejson(const ScheduleType &info) +{ + QJsonObject json; + json.insert("ID", info.ID); + json.insert("Name", info.typeName); + QString colorName = QString("#%1%2%3").arg(info.color.red(), 2, 16, QChar('0')).arg(info.color.green(), 2, 16, QChar('0')).arg(info.color.blue(), 2, 16, QChar('0')); + json.insert("Color", info.color.name()); + // 构建 JSON 文档 + QJsonDocument document; + document.setObject(json); + QByteArray byteArray = document.toJson(QJsonDocument::Compact); + QString strJson(byteArray); + return strJson; +} + +ScheduleType CreatOrParSchedule::parsingScheduleTypejson(QJsonObject &object) +{ + ScheduleType type; + QJsonObject &rootObj = object; + + //因为是预先定义好的JSON数据格式,所以这里可以这样读取 + if (rootObj.contains("ID")) { + type.ID = rootObj.value("ID").toInt(); + } + if (rootObj.contains("Name")) { + type.typeName = rootObj.value("Name").toString(); + } + if (rootObj.contains("Color")) { + QString str = rootObj.value("Color").toString(); + type.color = QColor(rootObj.value("Color").toString()); + } + return type; +} + +ScheduleDtailInfo CreatOrParSchedule::parsingScheduleDtailInfojsonID(QJsonObject &obj) +{ + + ScheduleDtailInfo info; + + QJsonObject &rootObj = obj; + //因为是预先定义好的JSON数据格式,所以这里可以这样读取 + if (rootObj.contains("ID")) { + info.id = rootObj.value("ID").toInt(); + } + if (rootObj.contains("AllDay")) { + info.allday = rootObj.value("AllDay").toBool(); + } + if (rootObj.contains("Remind")) { + parsingScheduleRemind(rootObj.value("Remind").toString(), info); + } + if (rootObj.contains("Title")) { + info.titleName = rootObj.value("Title").toString(); + } + if (rootObj.contains("Description")) { + info.description = rootObj.value("Description").toString(); + } + if (rootObj.contains("Type")) { + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->GetType(rootObj.value("Type").toInt(), info.type); + } + if (rootObj.contains("Start")) { + info.beginDateTime = fromconvertData(rootObj.value("Start").toString()); + } + if (rootObj.contains("End")) { + info.endDateTime = fromconvertData(rootObj.value("End").toString()); + } + if (rootObj.contains("RecurID")) { + info.RecurID = rootObj.value("RecurID").toInt(); + } + if (rootObj.contains("RRule")) { + parsingScheduleRRule(rootObj.value("RRule").toString(), info); + } + if (rootObj.contains("Ignore")) { + QJsonArray subArray = rootObj.value("Ignore").toArray(); + for (int i = 0; i < subArray.size(); i++) { + QString subObj = subArray.at(i).toString(); + info.ignore.append(fromconvertData(subObj)); + } + } + return info; +} + +QString CreatOrParSchedule::createScheduleRRule(const ScheduleDtailInfo &info) +{ + if (info.rpeat == 0) return QString(); + QString str; + switch (info.rpeat) { + case 1: { + str += "FREQ=DAILY"; + } + break; + case 2: { + str += "FREQ=DAILY;BYDAY=MO,TU,WE,TH,FR"; + } + break; + case 3: { + str += "FREQ=WEEKLY"; + } + break; + case 4: { + str += "FREQ=MONTHLY"; + } + break; + case 5: { + str += "FREQ=YEARLY"; + } + break; + } + switch (info.enddata.type) { + case 1: { + str += QString(";COUNT=%1").arg(info.enddata.tcount + 1); + } + break; + case 2: { + QDateTime datetime = info.enddata.date.addDays(-1); + str += ";UNTIL=" + datetime.toString("yyyyMMddThhmmss") + "Z"; + } + break; + } + return str; +} + +void CreatOrParSchedule::parsingScheduleRRule(QString str, ScheduleDtailInfo &info) +{ + if (str.isEmpty()) { + info.rpeat = 0; + return; + } + QString rrulestrs = str; + QStringList rruleslist = rrulestrs.split(";", QString::SkipEmptyParts); + if (rruleslist.count() > 0) { + if (rruleslist.contains("FREQ=DAILY") && rruleslist.contains("BYDAY=MO,TU,WE,TH,FR")) info.rpeat = 2; + else if (rruleslist.contains("FREQ=DAILY") ) { + info.rpeat = 1; + } else if (rruleslist.contains("FREQ=WEEKLY") ) { + info.rpeat = 3; + } else if (rruleslist.contains("FREQ=MONTHLY") ) { + info.rpeat = 4; + } else if (rruleslist.contains("FREQ=YEARLY") ) { + info.rpeat = 5; + } + info.enddata.type = 0; + for (int i = 0; i < rruleslist.count(); i++) { + if (rruleslist.at(i).contains("COUNT=")) { + QStringList liststr = rruleslist.at(i).split("=", QString::SkipEmptyParts); + info.enddata.type = 1; + info.enddata.tcount = liststr.at(1).toInt() - 1; + } + + if (rruleslist.at(i).contains("UNTIL=")) { + QStringList liststr = rruleslist.at(i).split("=", QString::SkipEmptyParts); + info.enddata.type = 2; + info.enddata.date = QDateTime::fromString(liststr.at(1).left(liststr.at(1).count() - 1), "yyyyMMddThhmmss"); + info.enddata.date = info.enddata.date.addDays(1); + } + } + } +} + +QString CreatOrParSchedule::createScheduleRemind(const ScheduleDtailInfo &info) +{ + if (!info.remind) return QString(); + QString str; + if (info.allday) { + str = QString::number(info.remindData.n) + ";" + info.remindData.time.toString("hh:mm"); + } else { + str = QString::number(info.remindData.n); + } + return str; +} + +void CreatOrParSchedule::parsingScheduleRemind(QString str, ScheduleDtailInfo &info) +{ + if (str.isEmpty()) { + info.remind = false; + return; + } + info.remind = true; + if (info.allday) { + QStringList liststr = str.split(";", QString::SkipEmptyParts); + info.remindData.n = liststr.at(0).toInt(); + info.remindData.time = QTime::fromString(liststr.at(1), "hh:mm"); + } else { + info.remindData.n = str.toInt(); + } +} + +QString CreatOrParSchedule::toconvertData(QDateTime date) +{ + QDateTime datetimeutc11 = date; + datetimeutc11.setTimeSpec(Qt::UTC); + QString strss = datetimeutc11.toString(Qt::ISODate); + datetimeutc11.setTimeSpec(Qt::OffsetFromUTC); + strss = datetimeutc11.toString(Qt::ISODateWithMs); + QDateTime datetimeutc = QDateTime::fromTime_t(0); + QString str = date.toString("yyyy-MM-ddThh:mm:ss") + "+" + datetimeutc.toString("hh:mm"); + return str; +} + +QDateTime CreatOrParSchedule::fromconvertData(QString str) +{ + QStringList liststr = str.split("+", QString::SkipEmptyParts); + return QDateTime::fromString(liststr.at(0), "yyyy-MM-ddThh:mm:ss"); +} + +QString CreatOrParSchedule::toconvertIGData(QDateTime date) +{ + QDateTime datetimeutc11 = date; + datetimeutc11.setTimeSpec(Qt::UTC); + QString strss = datetimeutc11.toString(Qt::ISODate); + datetimeutc11.setTimeSpec(Qt::OffsetFromUTC); + strss = datetimeutc11.toString(Qt::ISODateWithMs); + QDateTime datetimeutc = QDateTime::fromTime_t(0); + QString str = date.toString("yyyy-MM-ddThh:mm:ss") + "Z" + datetimeutc.toString("hh:mm"); + return str; +} + +QDateTime CreatOrParSchedule::fromconvertiIGData(QString str) +{ + QStringList liststr = str.split("Z", QString::SkipEmptyParts); + return QDateTime::fromString(liststr.at(0), "yyyy-MM-ddThh:mm:ss"); +} + +QString CreatOrParSchedule::CreateJob(const ScheduleDtailInfo &info) +{ + QString str = createScheduleDtailInfojson(info); + return str; +} + +bool CreatOrParSchedule::GetJob(QString str, ScheduleDtailInfo &out) +{ + QJsonParseError json_error; + QJsonDocument jsonDoc(QJsonDocument::fromJson(str.toLocal8Bit(), &json_error)); + + if (json_error.error != QJsonParseError::NoError) { + return false; + } + + QJsonObject ssubObj = jsonDoc.object(); + out = parsingScheduleDtailInfojsonID(ssubObj); + + return true; +} + + diff -Nru dde-calendar-5.7.0.4/src/dbus/creatorparschedule.h dde-calendar-5.7.0.23/src/dbus/creatorparschedule.h --- dde-calendar-5.7.0.4/src/dbus/creatorparschedule.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/dbus/creatorparschedule.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ + +/* + * This file was generated by qdbusxml2cpp version 0.8 + * Command line was: qdbusxml2cpp -c DCalendarDBus -p dcalendardbus com.deepin.api.LunarCalendar.xml + * + * qdbusxml2cpp is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * Do not edit! All changes made to it will be lost. + */ + +#ifndef CreatOrParSchedule_H +#define CALENDARDBUS_H + +#include "schedulestructs.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Proxy class for interface com.deepin.api.LunarCalendar + */ +class CreatOrParSchedule +{ + +public: + static QString createScheduleDtailInfojson(const ScheduleDtailInfo &info); + static QString createScheduleTypejson(const ScheduleType &info); + static ScheduleType parsingScheduleTypejson(QJsonObject &object); + static ScheduleDtailInfo parsingScheduleDtailInfojsonID(QJsonObject &obj); + static QString createScheduleRRule(const ScheduleDtailInfo &info); + static void parsingScheduleRRule(QString str, ScheduleDtailInfo &info); + static QString createScheduleRemind(const ScheduleDtailInfo &info); + static void parsingScheduleRemind(QString str, ScheduleDtailInfo &info); + static QString toconvertData(QDateTime date); + static QDateTime fromconvertData(QString str); + static QString toconvertIGData(QDateTime date); + static QDateTime fromconvertiIGData(QString str); + static QString CreateJob(const ScheduleDtailInfo &info); + static bool GetJob(QString str, ScheduleDtailInfo &out); +private: + CreatOrParSchedule(); + ~CreatOrParSchedule(); +}; +#endif diff -Nru dde-calendar-5.7.0.4/src/dbus/dbuscalendar_adaptor.cpp dde-calendar-5.7.0.23/src/dbus/dbuscalendar_adaptor.cpp --- dde-calendar-5.7.0.4/src/dbus/dbuscalendar_adaptor.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/dbus/dbuscalendar_adaptor.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,59 @@ +/* + * This file was generated by qdbusxml2cpp version 0.8 + * Command line was: qdbusxml2cpp -a dbuscalendar_adaptor -c CalendarAdaptor com.deepin.Calendar.xml + * + * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd. + * + * This is an auto-generated file. + * Do not edit! All changes made to it will be lost. + */ + +#include "dbuscalendar_adaptor.h" +#include "calendarmainwindow.h" +#include "scheduledatamanage.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Implementation of adaptor class CalendarAdaptor + */ + +CalendarAdaptor::CalendarAdaptor(QObject *parent) + : QDBusAbstractAdaptor(parent) +{ + // constructor + setAutoRelaySignals(true); +} + +CalendarAdaptor::~CalendarAdaptor() +{ + // destructor +} + +void CalendarAdaptor::ActiveWindow() +{ + // handle method call com.deepin.Calendar.RaiseWindow + QMetaObject::invokeMethod(parent(), "ActiveWindow"); +} + +void CalendarAdaptor::RaiseWindow() +{ + QWidget *pp = qobject_cast(parent()); + pp->activateWindow(); + pp->raise(); +} + +void CalendarAdaptor::OpenSchedule(QString job) +{ + QMetaObject::invokeMethod(parent(), "OpenSchedule", Q_ARG(QString, job)); +} + + + diff -Nru dde-calendar-5.7.0.4/src/dbus/dbuscalendar_adaptor.h dde-calendar-5.7.0.23/src/dbus/dbuscalendar_adaptor.h --- dde-calendar-5.7.0.4/src/dbus/dbuscalendar_adaptor.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/dbus/dbuscalendar_adaptor.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,57 @@ +/* + * This file was generated by qdbusxml2cpp version 0.8 + * Command line was: qdbusxml2cpp -a dbuscalendar_adaptor -c CalendarAdaptor com.deepin.Calendar.xml + * + * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd. + * + * This is an auto-generated file. + * This file may have been hand-edited. Look for HAND-EDIT comments + * before re-generating it. + */ + +#ifndef DBUSCALENDAR_ADAPTOR_H +#define DBUSCALENDAR_ADAPTOR_H + +#include "schedulestructs.h" + +#include +#include +QT_BEGIN_NAMESPACE +class QByteArray; +template class QList; +template class QMap; +class QString; +class QStringList; +class QVariant; +QT_END_NAMESPACE + +/* + * Adaptor class for interface com.deepin.Calendar + */ +class CalendarAdaptor: public QDBusAbstractAdaptor +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "com.deepin.Calendar") + Q_CLASSINFO("D-Bus Introspection", "" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + "") +public: + explicit CalendarAdaptor(QObject *parent); + virtual ~CalendarAdaptor(); +public: // PROPERTIES +public Q_SLOTS: // METHODS + void ActiveWindow(); + void RaiseWindow(); + void OpenSchedule(QString job); +Q_SIGNALS: // SIGNALS +}; + +#endif diff -Nru dde-calendar-5.7.0.4/src/dbus/dbusdatagetthread.cpp dde-calendar-5.7.0.23/src/dbus/dbusdatagetthread.cpp --- dde-calendar-5.7.0.4/src/dbus/dbusdatagetthread.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/dbus/dbusdatagetthread.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,93 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "dbusdatagetthread.h" +#include "schedulesdbus.h" + +DbusDataGetThread::DbusDataGetThread(CSchedulesDBus *_DataManage, QObject *parent) + : QObject(parent) + , m_work(new DataGetWork(_DataManage)) +{ + m_work->moveToThread(&workerThread); + connect(&workerThread, &QThread::finished, m_work, &QObject::deleteLater); + connect(this,&DbusDataGetThread::getScheduleInfo, + m_work,&DataGetWork::getScheduleInfo); + connect(this,&DbusDataGetThread::getLunarInfo, + m_work,&DataGetWork::getLunarInfo); + connect(this,&DbusDataGetThread::getFestivalInfo, + m_work,&DataGetWork::getFestivalInfo); + + connect(m_work,&DataGetWork::signalGetScheduleSuccess, + this,&DbusDataGetThread::signalGetScheduleSuccess); + + workerThread.start(); +} + +DbusDataGetThread::~DbusDataGetThread() +{ + workerThread.quit(); + workerThread.wait(); +} + +DataGetWork::DataGetWork(CSchedulesDBus *_DataManage) + :m_DataManage(_DataManage) +{ + Q_ASSERT(m_DataManage != nullptr); +} + +DataGetWork::~DataGetWork() +{ + +} + +void DataGetWork::getScheduleInfo(YearScheduleInfo *ScheduleInfo) +{ + QDate firstDay = ScheduleInfo->m_firstDay[1]; + QDate endDay = firstDay.addDays(41); + ScheduleInfo->m_monthInfo.clear(); + QVector out; + + for (int i = 0 ; i < 12 ; ++i) { + out.clear(); + firstDay = ScheduleInfo->m_firstDay[i+1]; + endDay = firstDay.addDays(41); + m_DataManage->GetJobs(firstDay.year(), + firstDay.month(), + firstDay.day(), + endDay.year(), + endDay.month(), + endDay.day(), + out); + ScheduleInfo->m_monthInfo[i+1] = out; + } + emit signalGetScheduleSuccess(); +} + +void DataGetWork::getLunarInfo(YearLunar *lunarInfo) +{ + Q_UNUSED(lunarInfo); + +} + +void DataGetWork::getFestivalInfo(YearFestival *festivalInfo) +{ + Q_UNUSED(festivalInfo); +} + diff -Nru dde-calendar-5.7.0.4/src/dbus/dbusdatagetthread.h dde-calendar-5.7.0.23/src/dbus/dbusdatagetthread.h --- dde-calendar-5.7.0.4/src/dbus/dbusdatagetthread.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/dbus/dbusdatagetthread.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,99 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef DBUSDATAGETTHREAD_H +#define DBUSDATAGETTHREAD_H + +#include "calendardbus.h" +#include "schedulestructs.h" + +#include +#include + +class CSchedulesDBus; +class DataGetWork; +class CaLunarMonthInfo; + +struct YearScheduleInfo { + int m_year; + QMap m_firstDay; + QMap > m_monthInfo; +}; +Q_DECLARE_METATYPE(YearScheduleInfo); + +struct YearLunar { + int m_year; + QMap m_monthLunar; +}; + +struct YearFestival { + int m_year; + QMap m_dayFestival; //1:xiu 2:ban +}; + + +class DbusDataGetThread : public QObject +{ + Q_OBJECT +public: + explicit DbusDataGetThread(CSchedulesDBus *_DataManage,QObject *parent = nullptr); + ~DbusDataGetThread(); +signals: + //获取日程信息 + void getScheduleInfo(YearScheduleInfo *ScheduleInfo); + //获取阴历信息 + void getLunarInfo(YearLunar *lunarInfo); + //获取节假日信息 + void getFestivalInfo(YearFestival *festivalInfo); + + void signalsgetInfo(const QString &str); + +signals: + void signalGetScheduleSuccess(); + +public slots: +private: + QThread workerThread; + DataGetWork *m_work = nullptr; +}; + + +class DataGetWork :public QObject +{ + Q_OBJECT +public: + explicit DataGetWork(CSchedulesDBus *_DataManage); + ~DataGetWork(); +public: + //获取日程信息 + void getScheduleInfo(YearScheduleInfo *ScheduleInfo); + //获取阴历信息 + void getLunarInfo(YearLunar *lunarInfo); + //获取节假日信息 + void getFestivalInfo(YearFestival *festivalInfo); + +signals: + void signalGetScheduleSuccess(); + +private: + CSchedulesDBus *m_DataManage = nullptr; +}; + +#endif // DBUSDATAGETTHREAD_H diff -Nru dde-calendar-5.7.0.4/src/dbus/exportedinterface.cpp dde-calendar-5.7.0.23/src/dbus/exportedinterface.cpp --- dde-calendar-5.7.0.4/src/dbus/exportedinterface.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/dbus/exportedinterface.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,201 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "exportedinterface.h" +#include "scheduledatamanage.h" +#include "calendarmainwindow.h" + +#include +#include +#include +#include + +ExportedInterface::ExportedInterface(QObject *parent) + : Dtk::Core::DUtil::DExportedInterface(parent) +{ + m_object = parent; +} + +QVariant ExportedInterface::invoke(const QString &action, const QString ¶meters) const +{ + ScheduleDtailInfo info; + Exportpara para; + QString tstr = parameters; + + if (!analysispara(tstr, info, para)) { + return QVariant(false); + } + + if (action == "CREATE") { + qint64 tindex = CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->addSchedule(info); + + if (tindex < 0) { + return QVariant(false); + } + } else if (action == "VIEW") { + dynamic_cast(m_object)->viewWindow(para.viewType, para.viewTime); + } else if (action == "QUERY") { + QString qstr; + bool flag = CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->queryScheduleInfo(para.ADTitleName, para.ADStartTime, para.ADEndTime, qstr); + Q_UNUSED(flag); + + return QVariant(qstr); + } else if (action == "CANCEL") { + QVector out; + bool flag = CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->queryScheduleInfo(para.ADTitleName, para.ADStartTime, para.ADEndTime, out); + + if (!flag) return QVariant(false); + + for (int j = 0; j < out.size(); j++) { + QVector scheduleInfolist = out.at(j).vData; + for (int m = 0; m < scheduleInfolist.count(); m++) { + ScheduleDtailInfo newschedule; + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->getScheduleInfoById(scheduleInfolist.at(m).id, newschedule); + newschedule.ignore.append(scheduleInfolist.at(m).beginDateTime); + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo(newschedule); + } + } + } + dynamic_cast(m_object)->UpdateJob(); + return QVariant(true); +} + +bool ExportedInterface::analysispara( QString ¶meters, ScheduleDtailInfo &info, Exportpara ¶) const +{ + QJsonParseError json_error; + QJsonDocument jsonDoc(QJsonDocument::fromJson(parameters.toLocal8Bit(), &json_error)); + + if (json_error.error != QJsonParseError::NoError) { + return false; + } + QJsonObject rootObj = jsonDoc.object(); + //因为是预先定义好的JSON数据格式,所以这里可以这样读取 + if (rootObj.contains("ID")) { + info.id = rootObj.value("ID").toInt(); + } + if (rootObj.contains("AllDay")) { + info.allday = rootObj.value("AllDay").toBool(); + } + if (rootObj.contains("Remind")) { + parsingScheduleRemind(rootObj.value("Remind").toString(), info); + } + if (rootObj.contains("Title")) { + info.titleName = rootObj.value("Title").toString(); + } + if (rootObj.contains("Description")) { + info.description = rootObj.value("Description").toString(); + } + if (rootObj.contains("Type")) { + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->GetType(rootObj.value("Type").toInt(), info.type); + } + if (rootObj.contains("Start")) { + info.beginDateTime = fromconvertData(rootObj.value("Start").toString()); + } + if (rootObj.contains("End")) { + info.endDateTime = fromconvertData(rootObj.value("End").toString()); + } + if (rootObj.contains("RecurID")) { + info.RecurID = rootObj.value("RecurID").toInt(); + } + if (rootObj.contains("RRule")) { + parsingScheduleRRule(rootObj.value("RRule").toString(), info); + } + if (rootObj.contains("Ignore")) { + QJsonArray subArray = rootObj.value("Ignore").toArray(); + for (int i = 0; i < subArray.size(); i++) { + QString subObj = subArray.at(i).toString(); + info.ignore.append(fromconvertData(subObj)); + } + } + if (rootObj.contains("ViewName")) { + para.viewType = rootObj.value("ViewName").toInt(); + } + if (rootObj.contains("ViewTime")) { + para.viewTime = QDateTime::fromString(rootObj.value("ViewTime").toString(), "yyyy-MM-ddThh:mm:ss"); + } + if (rootObj.contains("ADTitleName")) { + para.ADTitleName = rootObj.value("ADTitleName").toString(); + } + if (rootObj.contains("ADStartTime")) { + para.ADStartTime = QDateTime::fromString(rootObj.value("ADStartTime").toString(), "yyyy-MM-ddThh:mm:ss"); + } + if (rootObj.contains("ADEndTime")) { + para.ADEndTime = QDateTime::fromString(rootObj.value("ADEndTime").toString(), "yyyy-MM-ddThh:mm:ss"); + } + return true; +} +void ExportedInterface::parsingScheduleRemind(QString str, ScheduleDtailInfo &info) const +{ + if (str.isEmpty()) { + info.remind = false; + return; + } + info.remind = true; + + if (info.allday) { + QStringList liststr = str.split(";", QString::SkipEmptyParts); + info.remindData.n = liststr.at(0).toInt(); + info.remindData.time = QTime::fromString(liststr.at(1), "hh:mm"); + } else { + info.remindData.n = str.toInt(); + } +} +void ExportedInterface::parsingScheduleRRule(QString str, ScheduleDtailInfo &info) const +{ + if (str.isEmpty()) { + info.rpeat = 0; + return; + } + QString rrulestrs = str; + QStringList rruleslist = rrulestrs.split(";", QString::SkipEmptyParts); + + if (rruleslist.count() > 0) { + if (rruleslist.contains("FREQ=DAILY") && rruleslist.contains("BYDAY=MO,TU,WE,TH,FR")) info.rpeat = 2; + else if (rruleslist.contains("FREQ=DAILY") ) { + info.rpeat = 1; + } else if (rruleslist.contains("FREQ=WEEKLY") ) { + info.rpeat = 3; + } else if (rruleslist.contains("FREQ=MONTHLY") ) { + info.rpeat = 4; + } else if (rruleslist.contains("FREQ=YEARLY") ) { + info.rpeat = 5; + } + info.enddata.type = 0; + + for (int i = 0; i < rruleslist.count(); i++) { + if (rruleslist.at(i).contains("COUNT=")) { + QStringList liststr = rruleslist.at(i).split("=", QString::SkipEmptyParts); + info.enddata.type = 1; + info.enddata.tcount = liststr.at(1).toInt() - 1; + } + if (rruleslist.at(i).contains("UNTIL=")) { + QStringList liststr = rruleslist.at(i).split("=", QString::SkipEmptyParts); + info.enddata.type = 2; + info.enddata.date = QDateTime::fromString(liststr.at(1).left(liststr.at(1).count() - 1), "yyyyMMddThhmmss"); + info.enddata.date = info.enddata.date.addDays(1); + } + } + } +} +QDateTime ExportedInterface::fromconvertData(QString str) const +{ + QStringList liststr = str.split("+", QString::SkipEmptyParts); + return QDateTime::fromString(liststr.at(0), "yyyy-MM-ddThh:mm:ss"); +} diff -Nru dde-calendar-5.7.0.4/src/dbus/exportedinterface.h dde-calendar-5.7.0.23/src/dbus/exportedinterface.h --- dde-calendar-5.7.0.4/src/dbus/exportedinterface.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/dbus/exportedinterface.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,52 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef EXPORTEDINTERFACE_H +#define EXPORTEDINTERFACE_H + +#include "schedulestructs.h" + +#include + +#include + +DCORE_USE_NAMESPACE +struct Exportpara { + int viewType; //视图名称:year,month,week,day对应年、月、周、日视图类型 + QDateTime viewTime; //表示需要查看视图上某个时间 + QString ADTitleName; + QDateTime ADStartTime; + QDateTime ADEndTime; +}; +class ExportedInterface : public Dtk::Core::DUtil::DExportedInterface +{ +public: + explicit ExportedInterface(QObject *parent = nullptr); + QVariant invoke(const QString &action, const QString ¶meters) const override; +private: + bool analysispara( QString ¶meters, ScheduleDtailInfo &info, Exportpara ¶) const; + void parsingScheduleRRule(QString str, ScheduleDtailInfo &info) const; + void parsingScheduleRemind(QString str, ScheduleDtailInfo &info) const; + QDateTime fromconvertData(QString str) const; +private: + QObject *m_object = nullptr; +}; + +#endif // EXPORTEDINTERFACE_H diff -Nru dde-calendar-5.7.0.4/src/dbus/schedulesdbus.cpp dde-calendar-5.7.0.23/src/dbus/schedulesdbus.cpp --- dde-calendar-5.7.0.4/src/dbus/schedulesdbus.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/dbus/schedulesdbus.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,594 @@ +/* + * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ + +/* + * This file was generated by qdbusxml2cpp version 0.8 + * Command line was: qdbusxml2cpp -c DCalendarDBus -p dcalendardbus com.deepin.api.LunarCalendar.xml + * + * qdbusxml2cpp is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * This file may have been hand-edited. Look for HAND-EDIT comments + * before re-generating it. + */ + +#include "schedulesdbus.h" + +#include +#include +#include +/* + * Implementation of interface class DCalendarDBus + */ + +CSchedulesDBus::CSchedulesDBus(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) + : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) +{ + QDBusConnection::sessionBus().connect(this->service(), this->path(), "org.freedesktop.DBus.Properties", "PropertiesChanged", "sa{sv}as", this, SLOT(__propertyChanged__(QDBusMessage))); + +} + +CSchedulesDBus::~CSchedulesDBus() +{ + QDBusConnection::sessionBus().disconnect(service(), path(), "org.freedesktop.DBus.Properties", "PropertiesChanged", "sa{sv}as", this, SLOT(propertyChanged(QDBusMessage))); +} + +QString CSchedulesDBus::createScheduleDtailInfojson(const ScheduleDtailInfo &info) +{ + QJsonObject json; + json.insert("ID", info.id); + json.insert("AllDay", info.allday); + json.insert("Remind", createScheduleRemind(info)); + json.insert("RRule", createScheduleRRule(info)); + json.insert("Title", info.titleName); + json.insert("Description", info.description); + json.insert("Type", info.type.ID); + json.insert("Start", toconvertData(info.beginDateTime)); + json.insert("End", toconvertData(info.endDateTime)); + json.insert("RecurID", info.RecurID); + QJsonArray jsonarry; + + for (int i = 0; i < info.ignore.count(); i++) { + jsonarry.append(toconvertData(info.ignore.at(i))); + } + json.insert("Ignore", jsonarry); + // 构建 JSON 文档 + QJsonDocument document; + document.setObject(json); + QByteArray byteArray = document.toJson(QJsonDocument::Compact); + QString strJson(byteArray); + + return strJson; +} + +QString CSchedulesDBus::createScheduleTypejson(const ScheduleType &info) +{ + QJsonObject json; + json.insert("ID", info.ID); + json.insert("Name", info.typeName); + QString colorName = QString("#%1%2%3").arg(info.color.red(), 2, 16, QChar('0')).arg(info.color.green(), 2, 16, QChar('0')).arg(info.color.blue(), 2, 16, QChar('0')); + json.insert("Color", info.color.name()); + // 构建 JSON 文档 + QJsonDocument document; + document.setObject(json); + QByteArray byteArray = document.toJson(QJsonDocument::Compact); + QString strJson(byteArray); + + return strJson; +} + +ScheduleType CSchedulesDBus::parsingScheduleTypejson(QJsonObject &object) +{ + ScheduleType type; + QJsonObject &rootObj = object; + + //因为是预先定义好的JSON数据格式,所以这里可以这样读取 + if (rootObj.contains("ID")) { + type.ID = rootObj.value("ID").toInt(); + } + if (rootObj.contains("Name")) { + type.typeName = rootObj.value("Name").toString(); + } + if (rootObj.contains("Color")) { + QString str = rootObj.value("Color").toString(); + type.color = QColor(rootObj.value("Color").toString()); + } + + return type; +} + +ScheduleDtailInfo CSchedulesDBus::parsingScheduleDtailInfojsonID(QJsonObject &obj) +{ + + ScheduleDtailInfo info; + + QJsonObject &rootObj = obj; + //因为是预先定义好的JSON数据格式,所以这里可以这样读取 + if (rootObj.contains("ID")) { + info.id = rootObj.value("ID").toInt(); + } + if (rootObj.contains("AllDay")) { + info.allday = rootObj.value("AllDay").toBool(); + } + if (rootObj.contains("Remind")) { + parsingScheduleRemind(rootObj.value("Remind").toString(), info); + } + if (rootObj.contains("Title")) { + info.titleName = rootObj.value("Title").toString(); + } + if (rootObj.contains("Description")) { + info.description = rootObj.value("Description").toString(); + } + if (rootObj.contains("Type")) { + GetType(rootObj.value("Type").toInt(), info.type); + } + if (rootObj.contains("Start")) { + info.beginDateTime = fromconvertData(rootObj.value("Start").toString()); + } + if (rootObj.contains("End")) { + info.endDateTime = fromconvertData(rootObj.value("End").toString()); + } + if (rootObj.contains("RecurID")) { + info.RecurID = rootObj.value("RecurID").toInt(); + } + if (rootObj.contains("RRule")) { + parsingScheduleRRule(rootObj.value("RRule").toString(), info); + } + if (rootObj.contains("Ignore")) { + QJsonArray subArray = rootObj.value("Ignore").toArray(); + for (int i = 0; i < subArray.size(); i++) { + QString subObj = subArray.at(i).toString(); + info.ignore.append(fromconvertData(subObj)); + } + } + return info; +} + +QString CSchedulesDBus::createScheduleRRule(const ScheduleDtailInfo &info) +{ + if (info.rpeat == 0) return QString(); + QString str; + + switch (info.rpeat) { + case 1: { + str += "FREQ=DAILY"; + } + break; + case 2: { + str += "FREQ=DAILY;BYDAY=MO,TU,WE,TH,FR"; + } + break; + case 3: { + str += "FREQ=WEEKLY"; + } + break; + case 4: { + str += "FREQ=MONTHLY"; + } + break; + case 5: { + str += "FREQ=YEARLY"; + } + break; + } + switch (info.enddata.type) { + case 1: { + str += QString(";COUNT=%1").arg(info.enddata.tcount + 1); + } + break; + case 2: { + QDateTime datetime = info.enddata.date; + str += ";UNTIL=" + datetime.toString("yyyyMMddThhmmss") + "Z"; + } + break; + } + return str; +} + +void CSchedulesDBus::parsingScheduleRRule(QString str, ScheduleDtailInfo &info) +{ + if (str.isEmpty()) { + info.rpeat = 0; + return; + } + QString rrulestrs = str; + QStringList rruleslist = rrulestrs.split(";", QString::SkipEmptyParts); + + if (rruleslist.count() > 0) { + if (rruleslist.contains("FREQ=DAILY") && rruleslist.contains("BYDAY=MO,TU,WE,TH,FR")) info.rpeat = 2; + else if (rruleslist.contains("FREQ=DAILY") ) { + info.rpeat = 1; + } else if (rruleslist.contains("FREQ=WEEKLY") ) { + info.rpeat = 3; + } else if (rruleslist.contains("FREQ=MONTHLY") ) { + info.rpeat = 4; + } else if (rruleslist.contains("FREQ=YEARLY") ) { + info.rpeat = 5; + } + info.enddata.type = 0; + + for (int i = 0; i < rruleslist.count(); i++) { + if (rruleslist.at(i).contains("COUNT=")) { + QStringList liststr = rruleslist.at(i).split("=", QString::SkipEmptyParts); + info.enddata.type = 1; + info.enddata.tcount = liststr.at(1).toInt() - 1; + } + + if (rruleslist.at(i).contains("UNTIL=")) { + QStringList liststr = rruleslist.at(i).split("=", QString::SkipEmptyParts); + info.enddata.type = 2; + info.enddata.date = QDateTime::fromString(liststr.at(1).left(liststr.at(1).count() - 1), "yyyyMMddThhmmss"); + info.enddata.date = info.enddata.date; + } + } + } +} + +QString CSchedulesDBus::createScheduleRemind(const ScheduleDtailInfo &info) +{ + if (!info.remind) return QString(); + QString str; + + if (info.allday) { + str = QString::number(info.remindData.n) + ";" + info.remindData.time.toString("hh:mm"); + } else { + str = QString::number(info.remindData.n); + } + return str; +} + +void CSchedulesDBus::parsingScheduleRemind(QString str, ScheduleDtailInfo &info) +{ + if (str.isEmpty()) { + info.remind = false; + return; + } + info.remind = true; + + if (info.allday) { + QStringList liststr = str.split(";", QString::SkipEmptyParts); + info.remindData.n = liststr.at(0).toInt(); + info.remindData.time = QTime::fromString(liststr.at(1), "hh:mm"); + } else { + info.remindData.n = str.toInt(); + } +} + +QString CSchedulesDBus::toconvertData(QDateTime date) +{ + QDateTime datetimeutc11 = date; + datetimeutc11.setTimeSpec(Qt::UTC); + QString strss = datetimeutc11.toString(Qt::ISODate); + datetimeutc11.setTimeSpec(Qt::OffsetFromUTC); + strss = datetimeutc11.toString(Qt::ISODateWithMs); + QDateTime datetimeutc = QDateTime::fromTime_t(0); + QString str = date.toString("yyyy-MM-ddThh:mm:ss") + "+" + datetimeutc.toString("hh:mm"); + + return str; +} + +QDateTime CSchedulesDBus::fromconvertData(QString str) +{ + QStringList liststr = str.split("+", QString::SkipEmptyParts); + + return QDateTime::fromString(liststr.at(0), "yyyy-MM-ddThh:mm:ss"); +} + +QString CSchedulesDBus::toconvertIGData(QDateTime date) +{ + QDateTime datetimeutc11 = date; + datetimeutc11.setTimeSpec(Qt::UTC); + QString strss = datetimeutc11.toString(Qt::ISODate); + datetimeutc11.setTimeSpec(Qt::OffsetFromUTC); + strss = datetimeutc11.toString(Qt::ISODateWithMs); + QDateTime datetimeutc = QDateTime::fromTime_t(0); + QString str = date.toString("yyyy-MM-ddThh:mm:ss") + "Z" + datetimeutc.toString("hh:mm"); + + return str; +} + +QDateTime CSchedulesDBus::fromconvertiIGData(QString str) +{ + QStringList liststr = str.split("Z", QString::SkipEmptyParts); + return QDateTime::fromString(liststr.at(0), "yyyy-MM-ddThh:mm:ss"); +} + +qint64 CSchedulesDBus::CreateJob(const ScheduleDtailInfo &info) +{ + QList argumentList; + argumentList << QVariant::fromValue(createScheduleDtailInfojson(info)) ; + qDebug() << argumentList.at(0); + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("CreateJob"), argumentList); + + if (reply.type() != QDBusMessage::ReplyMessage ) { + qDebug() << reply; + return -1; + } + QDBusReply id = reply; + + return id.value(); +} + +bool CSchedulesDBus::GetJobs(int startYear, int startMonth, int startDay, int endYear, int endMonth, int endDay, QVector &out) +{ + QList argumentList; + argumentList << QVariant::fromValue(startYear) << QVariant::fromValue(startMonth) << QVariant::fromValue(startDay); + argumentList << QVariant::fromValue(endYear) << QVariant::fromValue(endMonth) << QVariant::fromValue(endDay); + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetJobs"), argumentList); + + if (reply.type() != QDBusMessage::ReplyMessage ) { + return false; + } + QDBusReply jobs = reply; + + if (!jobs.isValid()) return false; + QJsonParseError json_error; + QJsonDocument jsonDoc(QJsonDocument::fromJson(jobs.value().toLocal8Bit(), &json_error)); + + if (json_error.error != QJsonParseError::NoError) { + return false; + } + + QJsonArray rootarry = jsonDoc.array(); + + for (int i = 0; i < rootarry.size(); i++) { + + QJsonObject subObj = rootarry.at(i).toObject(); + + ScheduleDateRangeInfo info; + //因为是预先定义好的JSON数据格式,所以这里可以这样读取 + if (subObj.contains("Date")) { + info.date = QDate::fromString(subObj.value("Date").toString(), "yyyy-MM-dd"); + } + if (subObj.contains("Jobs")) { + QJsonArray subarry = subObj.value("Jobs").toArray(); + for (int j = 0; j < subarry.size(); j++) { + QJsonObject ssubObj = subarry.at(j).toObject(); + info.vData.append(parsingScheduleDtailInfojsonID(ssubObj)); + } + } + out.append(info); + } + + return true; +} + +bool CSchedulesDBus::GetJob(qint64 jobId, ScheduleDtailInfo &out) +{ + QList argumentList; + argumentList << QVariant::fromValue(jobId); + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetJob"), argumentList); + + if (reply.type() != QDBusMessage::ReplyMessage ) { + return false; + } + QDBusReply jobs = reply; + + if (!jobs.isValid()) return false; + QJsonParseError json_error; + QJsonDocument jsonDoc(QJsonDocument::fromJson(jobs.value().toLocal8Bit(), &json_error)); + + if (json_error.error != QJsonParseError::NoError) { + return false; + } + + QJsonObject ssubObj = jsonDoc.object(); + out = parsingScheduleDtailInfojsonID(ssubObj); + + return true; +} + +bool CSchedulesDBus::UpdateJob(const ScheduleDtailInfo &info) +{ + QList argumentList; + argumentList << QVariant::fromValue(createScheduleDtailInfojson(info)); + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("UpdateJob"), argumentList); + + if (reply.type() != QDBusMessage::ReplyMessage ) { + return false; + } + + return true; +} + +bool CSchedulesDBus::DeleteJob(qint64 jobId) +{ + QList argumentList; + argumentList << QVariant::fromValue(jobId); + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("DeleteJob"), argumentList); + + if (reply.type() != QDBusMessage::ReplyMessage ) { + return false; + } + + return true; +} + +bool CSchedulesDBus::QueryJobs(QString key, QDateTime starttime, QDateTime endtime, QVector &out) +{ + QJsonObject qjson; + qjson.insert("Key", key); + qjson.insert("Start", toconvertData(starttime)); + qjson.insert("End", toconvertData(endtime)); + // 构建 JSON 文档 + QJsonDocument qdocument; + qdocument.setObject(qjson); + QByteArray qbyteArray = qdocument.toJson(QJsonDocument::Compact); + QString strJson(qbyteArray); + + QList argumentList; + argumentList << QVariant::fromValue(strJson); + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("QueryJobs"), argumentList); + + if (reply.type() != QDBusMessage::ReplyMessage ) { + return false; + } + QDBusReply jobs = reply; + + if (!jobs.isValid()) return false; + QJsonParseError json_error; + QJsonDocument jsonDoc(QJsonDocument::fromJson(jobs.value().toLocal8Bit(), &json_error)); + + if (json_error.error != QJsonParseError::NoError) { + return false; + } + + QJsonArray rootarry = jsonDoc.array(); + + for (int i = 0; i < rootarry.size(); i++) { + + QJsonObject subObj = rootarry.at(i).toObject(); + + ScheduleDateRangeInfo info; + //因为是预先定义好的JSON数据格式,所以这里可以这样读取 + if (subObj.contains("Date")) { + info.date = QDate::fromString(subObj.value("Date").toString(), "yyyy-MM-dd"); + } + if (subObj.contains("Jobs")) { + QJsonArray subarry = subObj.value("Jobs").toArray(); + for (int j = 0; j < subarry.size(); j++) { + QJsonObject ssubObj = subarry.at(j).toObject(); + info.vData.append(parsingScheduleDtailInfojsonID(ssubObj)); + } + } + out.append(info); + } + return true; +} + +bool CSchedulesDBus::QueryJobs(QString key, QDateTime starttime, QDateTime endtime, QString &out) +{ + QJsonObject qjson; + qjson.insert("Key", key); + qjson.insert("Start", toconvertData(starttime)); + qjson.insert("End", toconvertData(endtime)); + // 构建 JSON 文档 + QJsonDocument qdocument; + qdocument.setObject(qjson); + QByteArray qbyteArray = qdocument.toJson(QJsonDocument::Compact); + QString strJson(qbyteArray); + + QList argumentList; + argumentList << QVariant::fromValue(strJson); + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("QueryJobs"), argumentList); + + if (reply.type() != QDBusMessage::ReplyMessage ) { + return false; + } + QDBusReply jobs = reply; + + if (!jobs.isValid()) return false; + out = jobs.value().toLocal8Bit(); + + return true; +} + +bool CSchedulesDBus::GetTypes(QVector &out) +{ + QList argumentList; + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetTypes"), argumentList); + + if (reply.type() != QDBusMessage::ReplyMessage ) { + return false; + } + QDBusReply jobs = reply; + + if (!jobs.isValid()) return false; + QJsonParseError json_error; + QJsonDocument jsonDoc(QJsonDocument::fromJson(jobs.value().toLocal8Bit(), &json_error)); + + if (json_error.error != QJsonParseError::NoError) { + return false; + } + + QJsonArray rootarry = jsonDoc.array(); + for (int i = 0; i < rootarry.size(); i++) { + + QJsonObject subObj = rootarry.at(i).toObject(); + out.append(parsingScheduleTypejson(subObj)); + } + + return true; +} + +bool CSchedulesDBus::GetType(qint64 jobId, ScheduleType &out) +{ + QList argumentList; + argumentList << QVariant::fromValue(jobId); + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetType"), argumentList); + + if (reply.type() != QDBusMessage::ReplyMessage ) { + return false; + } + QDBusReply jobs = reply; + + if (!jobs.isValid()) return false; + QJsonParseError json_error; + QJsonDocument jsonDoc(QJsonDocument::fromJson(jobs.value().toLocal8Bit(), &json_error)); + + if (json_error.error != QJsonParseError::NoError) { + return false; + } + + QJsonObject subObj = jsonDoc.object(); + out = parsingScheduleTypejson(subObj); + + return true; +} + +qint64 CSchedulesDBus::CreateType(const ScheduleType &info) +{ + QList argumentList; + argumentList << QVariant::fromValue(createScheduleTypejson(info)) ; + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("CreateType"), argumentList); + + if (reply.type() != QDBusMessage::ReplyMessage ) { + return -1; + } + QDBusReply id = reply; + + return id.value(); +} + +bool CSchedulesDBus::DeleteType(qint64 jobId) +{ + QList argumentList; + argumentList << QVariant::fromValue(jobId); + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("DeleteType"), argumentList); + + if (reply.type() != QDBusMessage::ReplyMessage ) { + return false; + } + return true; +} + +bool CSchedulesDBus::UpdateType(const ScheduleType &info) +{ + QList argumentList; + argumentList << QVariant::fromValue(createScheduleTypejson(info)) ; + QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("UpdateType"), argumentList); + + if (reply.type() != QDBusMessage::ReplyMessage ) { + return false; + } + + return true; +} + + diff -Nru dde-calendar-5.7.0.4/src/dbus/schedulesdbus.h dde-calendar-5.7.0.23/src/dbus/schedulesdbus.h --- dde-calendar-5.7.0.4/src/dbus/schedulesdbus.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/dbus/schedulesdbus.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ + +/* + * This file was generated by qdbusxml2cpp version 0.8 + * Command line was: qdbusxml2cpp -c DCalendarDBus -p dcalendardbus com.deepin.api.LunarCalendar.xml + * + * qdbusxml2cpp is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * Do not edit! All changes made to it will be lost. + */ + +#ifndef SCHEDULESDBUS_H +#define SCHEDULESDBUS_H + +#include "schedulestructs.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Proxy class for interface com.deepin.api.LunarCalendar + */ +class CSchedulesDBus: public QDBusAbstractInterface +{ + Q_OBJECT + + Q_SLOT void __propertyChanged__(const QDBusMessage &msg) + { + QList arguments = msg.arguments(); + if (3 != arguments.count()) + return; + QString interfaceName = msg.arguments().at(0).toString(); + if (interfaceName != "com.deepin.api.LunarCalendar") + return; + QVariantMap changedProps = qdbus_cast(arguments.at(1).value()); + foreach (const QString &prop, changedProps.keys()) { + const QMetaObject *self = metaObject(); + for (int i = self->propertyOffset(); i < self->propertyCount(); ++i) { + QMetaProperty p = self->property(i); + if (p.name() == prop) { + Q_EMIT p.notifySignal().invoke(this); + } + } + } + } +public: + static inline const char *staticInterfaceName() + { + return "com.deepin.daemon.Calendar.Scheduler"; + } + +public: + CSchedulesDBus(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); + + ~CSchedulesDBus(); + QString toconvertIGData(QDateTime date); + QDateTime fromconvertiIGData(QString str); + QString createScheduleDtailInfojson(const ScheduleDtailInfo &info); + ScheduleDtailInfo parsingScheduleDtailInfojsonID(QJsonObject &obj); +private: + QString createScheduleTypejson(const ScheduleType &info); + ScheduleType parsingScheduleTypejson(QJsonObject &object); + + QString createScheduleRRule(const ScheduleDtailInfo &info); + void parsingScheduleRRule(QString str, ScheduleDtailInfo &info); + QString createScheduleRemind(const ScheduleDtailInfo &info); + void parsingScheduleRemind(QString str, ScheduleDtailInfo &info); + QString toconvertData(QDateTime date); + QDateTime fromconvertData(QString str); +public Q_SLOTS: // METHODS + + qint64 CreateJob(const ScheduleDtailInfo &info); + bool GetJobs(int startYear, int startMonth, int startDay, int endYear, int endMonth, int endDay, QVector &out); + bool GetJob(qint64 jobId, ScheduleDtailInfo &out); + bool UpdateJob(const ScheduleDtailInfo &info); + bool DeleteJob(qint64 jobId); + bool QueryJobs(QString key, QDateTime starttime, QDateTime endtime, QVector &out); + bool QueryJobs(QString key, QDateTime starttime, QDateTime endtime, QString &out); + bool GetTypes(QVector &out); + bool GetType(qint64 jobId, ScheduleType &out); + qint64 CreateType(const ScheduleType &info); + bool DeleteType(qint64 jobId); + bool UpdateType(const ScheduleType &info); + +Q_SIGNALS: // SIGNALS +// begin property changed signals +}; +#endif diff -Nru dde-calendar-5.7.0.4/src/dbuscalendar_adaptor.cpp dde-calendar-5.7.0.23/src/dbuscalendar_adaptor.cpp --- dde-calendar-5.7.0.4/src/dbuscalendar_adaptor.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/dbuscalendar_adaptor.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -/* - * This file was generated by qdbusxml2cpp version 0.8 - * Command line was: qdbusxml2cpp -a dbuscalendar_adaptor -c CalendarAdaptor com.deepin.Calendar.xml - * - * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd. - * - * This is an auto-generated file. - * Do not edit! All changes made to it will be lost. - */ - -#include "dbuscalendar_adaptor.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "calendarmainwindow.h" -#include "scheduledatamanage.h" -/* - * Implementation of adaptor class CalendarAdaptor - */ - -CalendarAdaptor::CalendarAdaptor(QObject *parent) - : QDBusAbstractAdaptor(parent) -{ - // constructor - setAutoRelaySignals(true); -} - -CalendarAdaptor::~CalendarAdaptor() -{ - // destructor -} - -void CalendarAdaptor::ActiveWindow() -{ - // handle method call com.deepin.Calendar.RaiseWindow - //QWidget *pp = qobject_cast(parent()); - // pp->activateWindow(); - //pp->raise(); - QMetaObject::invokeMethod(parent(), "ActiveWindow"); -} - -void CalendarAdaptor::RaiseWindow() -{ - QWidget *pp = qobject_cast(parent()); - pp->activateWindow(); - pp->raise(); - //QMetaObject::invokeMethod(parent(), "RaiseWindow"); -} - -void CalendarAdaptor::OpenSchedule(QString job) -{ - QMetaObject::invokeMethod(parent(), "OpenSchedule", Q_ARG(QString, job)); -} - - - diff -Nru dde-calendar-5.7.0.4/src/dbuscalendar_adaptor.h dde-calendar-5.7.0.23/src/dbuscalendar_adaptor.h --- dde-calendar-5.7.0.4/src/dbuscalendar_adaptor.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/dbuscalendar_adaptor.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -/* - * This file was generated by qdbusxml2cpp version 0.8 - * Command line was: qdbusxml2cpp -a dbuscalendar_adaptor -c CalendarAdaptor com.deepin.Calendar.xml - * - * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd. - * - * This is an auto-generated file. - * This file may have been hand-edited. Look for HAND-EDIT comments - * before re-generating it. - */ - -#ifndef DBUSCALENDAR_ADAPTOR_H -#define DBUSCALENDAR_ADAPTOR_H - -#include -#include -#include "schedulestructs.h" -QT_BEGIN_NAMESPACE -class QByteArray; -template class QList; -template class QMap; -class QString; -class QStringList; -class QVariant; -QT_END_NAMESPACE - -/* - * Adaptor class for interface com.deepin.Calendar - */ -class CalendarAdaptor: public QDBusAbstractAdaptor -{ - Q_OBJECT - Q_CLASSINFO("D-Bus Interface", "com.deepin.Calendar") - Q_CLASSINFO("D-Bus Introspection", "" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "") -public: - CalendarAdaptor(QObject *parent); - virtual ~CalendarAdaptor(); - -public: // PROPERTIES -public Q_SLOTS: // METHODS - void ActiveWindow(); - void RaiseWindow(); - void OpenSchedule(QString job); -Q_SIGNALS: // SIGNALS -}; - -#endif diff -Nru dde-calendar-5.7.0.4/src/dbusdatagetthread.cpp dde-calendar-5.7.0.23/src/dbusdatagetthread.cpp --- dde-calendar-5.7.0.4/src/dbusdatagetthread.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/dbusdatagetthread.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +0,0 @@ -/* -* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. -* -* Author: uniontech -* -* Maintainer: uniontech -* -* 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 -* 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 . -*/ -#include "dbusdatagetthread.h" - -#include "schedulesdbus.h" - -DbusDataGetThread::DbusDataGetThread(CSchedulesDBus *_DataManage, QObject *parent) - :QObject (parent), - m_work(new DataGetWork(_DataManage)) -{ - m_work->moveToThread(&workerThread); - connect(&workerThread, &QThread::finished, m_work, &QObject::deleteLater); - connect(this,&DbusDataGetThread::getScheduleInfo, - m_work,&DataGetWork::getScheduleInfo); - connect(this,&DbusDataGetThread::getLunarInfo, - m_work,&DataGetWork::getLunarInfo); - connect(this,&DbusDataGetThread::getFestivalInfo, - m_work,&DataGetWork::getFestivalInfo); - - connect(m_work,&DataGetWork::signalGetScheduleSuccess, - this,&DbusDataGetThread::signalGetScheduleSuccess); - - workerThread.start(); -} - -DbusDataGetThread::~DbusDataGetThread() -{ - workerThread.quit(); - workerThread.wait(); -} - -DataGetWork::DataGetWork(CSchedulesDBus *_DataManage) - :m_DataManage(_DataManage) -{ - Q_ASSERT(m_DataManage != nullptr); -} - -DataGetWork::~DataGetWork() -{ - -} - -void DataGetWork::getScheduleInfo(YearScheduleInfo *ScheduleInfo) -{ - QDate firstDay = ScheduleInfo->m_firstDay[1]; - QDate endDay = firstDay.addDays(41); - ScheduleInfo->m_monthInfo.clear(); - QVector out; - - for (int i = 0 ; i < 12 ; ++i) { - out.clear(); - firstDay = ScheduleInfo->m_firstDay[i+1]; - endDay = firstDay.addDays(41); - m_DataManage->GetJobs(firstDay.year(), - firstDay.month(), - firstDay.day(), - endDay.year(), - endDay.month(), - endDay.day(), - out); - ScheduleInfo->m_monthInfo[i+1] = out; - } - emit signalGetScheduleSuccess(); -} - -void DataGetWork::getLunarInfo(YearLunar *lunarInfo) -{ - Q_UNUSED(lunarInfo); - -} - -void DataGetWork::getFestivalInfo(YearFestival *festivalInfo) -{ - Q_UNUSED(festivalInfo); -} - diff -Nru dde-calendar-5.7.0.4/src/dbusdatagetthread.h dde-calendar-5.7.0.23/src/dbusdatagetthread.h --- dde-calendar-5.7.0.4/src/dbusdatagetthread.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/dbusdatagetthread.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +0,0 @@ -/* -* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. -* -* Author: uniontech -* -* Maintainer: uniontech -* -* 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 -* 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 . -*/ -#ifndef DBUSDATAGETTHREAD_H -#define DBUSDATAGETTHREAD_H - -#include -#include - -#include "calendardbus.h" -#include "schedulestructs.h" - -class CSchedulesDBus; -class DataGetWork; -class CaLunarMonthInfo; - -struct YearScheduleInfo { - int m_year; - QMap m_firstDay; - QMap > m_monthInfo; -}; -Q_DECLARE_METATYPE(YearScheduleInfo); - -struct YearLunar { - int m_year; - QMap m_monthLunar; -}; - -struct YearFestival { - int m_year; - QMap m_dayFestival; //1:xiu 2:ban -}; - - -class DbusDataGetThread : public QObject -{ - Q_OBJECT -public: - explicit DbusDataGetThread(CSchedulesDBus *_DataManage,QObject *parent = nullptr); - ~DbusDataGetThread(); -signals: - //获取日程信息 - void getScheduleInfo(YearScheduleInfo *ScheduleInfo); - //获取阴历信息 - void getLunarInfo(YearLunar *lunarInfo); - //获取节假日信息 - void getFestivalInfo(YearFestival *festivalInfo); - - void signalsgetInfo(const QString &str); - -signals: - void signalGetScheduleSuccess(); - -public slots: -private: - QThread workerThread; - DataGetWork *m_work; -}; - - -class DataGetWork :public QObject -{ - Q_OBJECT -public: - explicit DataGetWork(CSchedulesDBus *_DataManage); - ~DataGetWork(); -public: - //获取日程信息 - void getScheduleInfo(YearScheduleInfo *ScheduleInfo); - //获取阴历信息 - void getLunarInfo(YearLunar *lunarInfo); - //获取节假日信息 - void getFestivalInfo(YearFestival *festivalInfo); - -signals: - void signalGetScheduleSuccess(); - -private: - CSchedulesDBus *m_DataManage; - -}; - -#endif // DBUSDATAGETTHREAD_H diff -Nru dde-calendar-5.7.0.4/src/dialog/myschceduleview.cpp dde-calendar-5.7.0.23/src/dialog/myschceduleview.cpp --- dde-calendar-5.7.0.4/src/dialog/myschceduleview.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/dialog/myschceduleview.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,348 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#include "myschceduleview.h" +#include "schceduledlg.h" +#include "scheduledatamanage.h" +#include "schcedulectrldlg.h" +#include "cdynamicicon.h" +#include "constants.h" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +DGUI_USE_NAMESPACE +CMySchceduleView::CMySchceduleView(const ScheduleDtailInfo &schduleInfo,QWidget *parent) + : DDialog(parent) +{ + setContentsMargins(0, 0, 0, 0); + m_scheduleInfo = schduleInfo; + initUI(); + initConnection(); + //根据主题type设置颜色 + setLabelTextColor(DGuiApplicationHelper::instance()->themeType()); + setFixedSize(380, 160); + AutoFeed(m_scheduleInfo.titleName); + + if (m_scheduleInfo.type.ID == DDECalendar::FestivalTypeID) { + m_timeLabel->setText(m_scheduleInfo.beginDateTime.toString(("yyyy-MM-dd"))); + } else { + m_timeLabel->setText(m_scheduleInfo.beginDateTime.toString("yyyy-MM-dd hh:mm") + " ~ " + m_scheduleInfo.endDateTime.toString("yyyy-MM-dd hh:mm")); + } +} + +CMySchceduleView::~CMySchceduleView() +{ + emit signalViewtransparentFrame(0); +} +void CMySchceduleView::AutoFeed(QString text) +{ + QString strText = text; + QString resultStr = nullptr; + QFont labelF; + labelF.setWeight(QFont::Medium); + labelF = DFontSizeManager::instance()->get(DFontSizeManager::T6,labelF); + QFontMetrics fm(labelF); + int titlewidth = fm.width(strText); + QStringList strList; + QString str; + int h = fm.height(); + strList.clear(); + + if (titlewidth < 330) { + strList.append(strText); + resultStr += strText; + } else { + for (int i = 0; i < strText.count(); i++) { + str += strText.at(i); + + if (fm.width(str) > 330) { + str.remove(str.count() - 1,1); + strList.append(str); + resultStr += str + "\n"; + str.clear(); + --i; + } + } + strList.append(str); + resultStr += str; + } + + if (strList.count() * h + 140 > 240) { + area->setFixedHeight(100); + setFixedHeight(250); + } else { + area->setFixedHeight(strList.count() * h); + setFixedHeight(strList.count() * h + 152); + } + + m_schceduleLabel->setText(resultStr); +} + +void CMySchceduleView::setLabelTextColor(const int type) +{ + //标题显示颜色 + QColor titleColor; + //日程显示颜色 + QColor scheduleTitleColor; + //时间显示颜色 + QColor timeColor; + if (type == 2) { + titleColor = "#C0C6D4"; + scheduleTitleColor = "#FFFFFF"; + timeColor = "#FFFFFF"; + timeColor.setAlphaF(0.7); + } else { + titleColor = "#001A2E"; + scheduleTitleColor = "#000000"; + scheduleTitleColor.setAlphaF(0.9); + timeColor = "#000000"; + timeColor.setAlphaF(0.7); + } + //设置颜色 + setPaletteTextColor(m_Title,titleColor); + setPaletteTextColor(m_schceduleLabel,scheduleTitleColor); + setPaletteTextColor(m_timeLabel,timeColor); +} + +void CMySchceduleView::setPaletteTextColor(QWidget *widget, QColor textColor) +{ + //如果为空指针则退出 + if(nullptr == widget) + return; + DPalette palette = widget->palette(); + //设置文字显示颜色 + palette.setColor(DPalette::WindowText,textColor); + widget->setPalette(palette); +} + +void CMySchceduleView::showEvent(QShowEvent *event) +{ + Q_UNUSED(event); + emit signalViewtransparentFrame(1); +} + +bool CMySchceduleView::eventFilter(QObject *o, QEvent *e) +{ + Q_UNUSED(o); + + if (e->type() == QEvent::FontChange) { + AutoFeed(m_scheduleInfo.titleName); + } + + return false; +} + +void CMySchceduleView::slotEditBt(int buttonIndex, QString buttonName) +{ + if (buttonIndex != 1 && buttonName != "Edit") + return; + + CSchceduleDlg dlg(0, this); + dlg.setData(m_scheduleInfo); + + if (dlg.exec() == DDialog::Accepted) { + accept(); + emit signalsEditorDelete(1); + } +} + +void CMySchceduleView::slotDeleteBt(int buttonIndex, QString buttonName) +{ + if (buttonIndex != 0 && buttonName != "Delete") + return; + + if (m_scheduleInfo.rpeat == 0) { + CSchceduleCtrlDlg msgBox; + msgBox.setText(tr("You are deleting an event.")); + msgBox.setInformativeText(tr("Are you sure you want to delete this event?")); + msgBox.addPushButton(tr("Cancel"), true); + msgBox.addWaringButton(tr("Delete"), true); + msgBox.exec(); + + if (msgBox.clickButton() == 0) { + return; + } else if (msgBox.clickButton() == 1) { + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->deleteScheduleInfoById(m_scheduleInfo.id); + } else { + return; + } + } else { + if (m_scheduleInfo.RecurID == 0) { + CSchceduleCtrlDlg msgBox; + + msgBox.setText(tr("You are deleting an event.")); + msgBox.setInformativeText(tr("Do you want to delete all occurrences of this event, or only the selected occurrence?")); + msgBox.addPushButton(tr("Cancel")); + msgBox.addPushButton(tr("Delete All")); + msgBox.addWaringButton(tr("Delete Only This Event")); + msgBox.exec(); + + if (msgBox.clickButton() == 0) { + return; + } else if (msgBox.clickButton() == 1) { + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->deleteScheduleInfoById(m_scheduleInfo.id); + } else if (msgBox.clickButton() == 2) { + ScheduleDtailInfo newschedule; + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->getScheduleInfoById(m_scheduleInfo.id, newschedule); + newschedule.ignore.append(m_scheduleInfo.beginDateTime); + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo(newschedule); + } else { + return; + } + } else { + CSchceduleCtrlDlg msgBox; + msgBox.setText(tr("You are deleting an event.")); + msgBox.setInformativeText(tr("Do you want to delete this and all future occurrences of this event, or only the selected occurrence?")); + msgBox.addPushButton(tr("Cancel")); + msgBox.addPushButton(tr("Delete All Future Events")); + msgBox.addWaringButton(tr("Delete Only This Event")); + msgBox.exec(); + + if (msgBox.clickButton() == 0) { + return; + } else if (msgBox.clickButton() == 1) { + ScheduleDtailInfo newschedule; + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->getScheduleInfoById(m_scheduleInfo.id, newschedule); + + newschedule.enddata.type = 2; + newschedule.enddata.date = m_scheduleInfo.beginDateTime.addDays(-1); + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo(newschedule); + + } else if (msgBox.clickButton() == 2) { + + ScheduleDtailInfo newschedule; + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->getScheduleInfoById(m_scheduleInfo.id, newschedule); + + newschedule.ignore.append(m_scheduleInfo.beginDateTime); + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo(newschedule); + } else { + return; + } + } + } + accept(); + emit signalsEditorDelete(1); +} + +void CMySchceduleView::initUI() +{ + //在点击任何对话框上的按钮后不关闭对话框,保证关闭子窗口时不被一起关掉 + setOnButtonClickedClose(false); + + m_Title = new QLabel(this); + m_Title->setFixedSize(108, 51); + m_Title->setAlignment(Qt::AlignCenter); + QFont titleFont; + //设置字重 + titleFont.setWeight(QFont::Bold); + m_Title->setFont(titleFont); + DFontSizeManager::instance()->bind(m_Title,DFontSizeManager::T5); + //设置日期图标 + QIcon t_icon(CDynamicIcon::getInstance()->getPixmap()); + setIcon(t_icon); + QFont labelTitle; + labelTitle.setWeight(QFont::DemiBold); + m_Title->setFont(labelTitle); + m_Title->setText(tr("My Event")); + m_Title->move(137, 0); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->setMargin(0); + mainLayout->setSpacing(0); + + area = new QScrollArea (this); + area->setFrameShape(QFrame::NoFrame); + area->setFixedWidth(363); + area->setBackgroundRole(QPalette::Background); + area->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); + area->setWidgetResizable(true); + area->setAlignment(Qt::AlignCenter); + + m_schceduleLabel = new QLabel(this); + m_schceduleLabel->setTextFormat(Qt::PlainText);//纯文本格式 + m_schceduleLabel->installEventFilter(this); + m_schceduleLabel->setFixedWidth(330); + m_schceduleLabel->setAlignment(Qt::AlignCenter); + DFontSizeManager::instance()->bind(m_schceduleLabel,DFontSizeManager::T6); + labelF.setWeight(QFont::Medium); + m_schceduleLabel->setFont(labelF); + + area->setWidget(m_schceduleLabel); + mainLayout->addWidget(area); + + m_timeLabel = new DLabel(this); + m_timeLabel->setFixedHeight(26); + m_timeLabel->setAlignment(Qt::AlignCenter); + QFont timeFont; + timeFont.setWeight(QFont::Normal); + m_timeLabel->setFont(timeFont); + mainLayout->addSpacing(6); + mainLayout->addWidget(m_timeLabel); + + if (m_scheduleInfo.type.ID == DDECalendar::FestivalTypeID) { + addButton(tr("OK"), false, DDialog::ButtonNormal); + QAbstractButton *button_ok = getButton(0); + button_ok->setFixedSize(360,36); + } else { + addButton(tr("Delete"), false, DDialog::ButtonNormal); + addButton(tr("Edit"), false, DDialog::ButtonRecommend); + for (int i = 0; i < buttonCount(); i++) { + QAbstractButton *button = getButton(i); + button->setFixedSize(165,36); + } + } + + //这种中心铺满的weiget,显示日程标题和时间的控件 + DWidget *centerWidget = new DWidget(this); + centerWidget->setLayout(mainLayout); + //获取widget的调色板 + DPalette centerWidgetPalette = centerWidget->palette(); + //设置背景色为透明 + centerWidgetPalette.setColor(DPalette::Background, Qt::transparent); + centerWidget->setPalette(centerWidgetPalette); + //添加窗口为剧中对齐 + addContent(centerWidget, Qt::AlignCenter); +} + +void CMySchceduleView::initConnection() +{ + //关联主题改变事件 + QObject::connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, + this, + &CMySchceduleView::setLabelTextColor); + if (m_scheduleInfo.type.ID == DDECalendar::FestivalTypeID) { + connect(this, &DDialog::buttonClicked, this, &CMySchceduleView::close); + } else { + connect(this, &DDialog::buttonClicked, this, &CMySchceduleView::slotEditBt); + connect(this, &DDialog::buttonClicked, this, &CMySchceduleView::slotDeleteBt); + } + + QShortcut *shortcut = new QShortcut(this); + shortcut->setKey(QKeySequence(QLatin1String("ESC"))); + connect(shortcut, SIGNAL(activated()), this, SLOT(close())); +} diff -Nru dde-calendar-5.7.0.4/src/dialog/myschceduleview.h dde-calendar-5.7.0.23/src/dialog/myschceduleview.h --- dde-calendar-5.7.0.4/src/dialog/myschceduleview.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/dialog/myschceduleview.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#ifndef MYSCHCEDULEVIEW_H +#define MYSCHCEDULEVIEW_H + +#include "schedulestructs.h" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +DWIDGET_USE_NAMESPACE + +class CMySchceduleView : public DDialog +{ + Q_OBJECT +public: + explicit CMySchceduleView(const ScheduleDtailInfo &schduleInfo,QWidget *parent = nullptr); + ~CMySchceduleView() override; + ScheduleDtailInfo getSchedules() + { + return m_scheduleInfo; + } +signals: + void signalsEditorDelete(int type = 0); + void signalViewtransparentFrame(int type); +public slots: + void slotEditBt(int buttonIndex, QString buttonName); + void slotDeleteBt(int buttonIndex, QString buttonName); +private: + void initUI(); + void initConnection(); + void AutoFeed(QString text); + /** + * @brief setLabelTextColor 设置label文字颜色 + * @param type 主题type + */ + void setLabelTextColor(const int type); + /** + * @brief setPaletteTextColor 设置调色板颜色 + * @param widget 需要设置的widget + * @param textColor 显示颜色 + */ + void setPaletteTextColor(QWidget *widget,QColor textColor); +protected: + void showEvent(QShowEvent *event) override; + bool eventFilter(QObject *o, QEvent *e) override; +private: + QLabel *m_schceduleLabel = nullptr; + QLabel *m_timeLabel = nullptr; + DSuggestButton *m_editBt = nullptr; + DPushButton *m_deleteBt = nullptr; + DPushButton *m_okBt = nullptr; + QLabel *m_icon = nullptr; + QLabel *m_Title = nullptr; + ScheduleDtailInfo m_scheduleInfo; //日程 + QScrollArea *area = nullptr; + QFont labelF; +}; + +#endif // MYSCHCEDULEVIEW_H diff -Nru dde-calendar-5.7.0.4/src/dialog/schcedulectrldlg.cpp dde-calendar-5.7.0.23/src/dialog/schcedulectrldlg.cpp --- dde-calendar-5.7.0.4/src/dialog/schcedulectrldlg.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/dialog/schcedulectrldlg.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,245 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#include "schcedulectrldlg.h" +#include "schceduledlg.h" +#include "scheduledatamanage.h" +#include "cdynamicicon.h" + +#include +#include +#include +#include +#include + +#include + +DGUI_USE_NAMESPACE +CSchceduleCtrlDlg::CSchceduleCtrlDlg(QWidget *parent) + : DDialog(parent) +{ + setContentsMargins(0, 0, 0, 0); + initUI(); + initConnection(); + resize(380, 260); + setFocusPolicy(Qt::ClickFocus); +} + +void CSchceduleCtrlDlg::initUI() +{ + //在点击任何对话框上的按钮后不关闭对话框,保证关闭子窗口时不被一起关掉 + setOnButtonClickedClose(false); + QIcon t_icon(CDynamicIcon::getInstance()->getPixmap());// = QIcon::fromTheme("dde-calendar"); + setIcon(t_icon); + m_Title = new QLabel(this); + m_Title->setFixedHeight(48); + m_Title->setAlignment(Qt::AlignCenter | Qt::AlignVCenter); + + QFont labelTitle; + labelTitle.setWeight(QFont::Bold); + labelTitle.setPixelSize(17); + m_Title->setFont(labelTitle); + + m_mainBoxLayout = new QVBoxLayout(); + m_mainBoxLayout->setMargin(0); + m_mainBoxLayout->setSpacing(0); + + m_firstLabel = new QLabel(this); + m_firstLabel->setAlignment(Qt::AlignCenter); + m_firstLabel->setFixedWidth(350); + m_firstLabel->setWordWrap(true); + labelF.setWeight(QFont::Medium); + DFontSizeManager::instance()->bind(m_firstLabel,DFontSizeManager::T6); + m_firstLabel->setForegroundRole(DPalette::WindowText); + m_firstLabel->setFont(labelF); + m_mainBoxLayout->addWidget(m_firstLabel); + + m_seconLabel = new QLabel(this); + m_seconLabel->setFixedWidth(350); + m_seconLabel->setAlignment(Qt::AlignCenter); + labelTitle.setWeight(QFont::Bold); + DFontSizeManager::instance()->bind(m_seconLabel,DFontSizeManager::T6); + m_seconLabel->setForegroundRole(DPalette::WindowText); + //设置字重 + labelT.setWeight(QFont::Normal); + m_seconLabel->setFont(labelT); + m_seconLabel->setWordWrap(true); + m_mainBoxLayout->addSpacing(3); + m_mainBoxLayout->addWidget(m_seconLabel); + DFrame *gwi = new DFrame(this); + gwi->setContentsMargins(0, 0, 0, 0); + gwi->setLayout(m_mainBoxLayout); + DPalette anipa = gwi->palette(); + QColor color = "#F8F8F8"; + color.setAlphaF(0.0); + anipa.setColor(DPalette::Background, color); + gwi->setAutoFillBackground(true); + gwi->setPalette(anipa); + gwi->setBackgroundRole(DPalette::Background); + addContent(gwi, Qt::AlignCenter); + setFocus(); +} + +void CSchceduleCtrlDlg::initConnection() +{ + //关联主题信号 + QObject::connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, + this, + &CSchceduleCtrlDlg::setTheMe); + connect(this, &DDialog::buttonClicked, this, &CSchceduleCtrlDlg::buttonJudge); //连接信号和槽 +} + +void CSchceduleCtrlDlg::setTheMe(const int type) +{ + //标题文字颜色 + QColor titleColor; + //提示内容文字颜色 + QColor contentColor; + if (type == 2) { + titleColor = "#FFFFFF"; + contentColor = "#FFFFFF"; + contentColor.setAlphaF(0.7); + } else { + titleColor = "#000000"; + titleColor.setAlphaF(0.9); + contentColor = "#000000"; + contentColor.setAlphaF(0.7); + } + setPaletteTextColor(m_firstLabel,titleColor); + setPaletteTextColor(m_seconLabel,contentColor); +} + +void CSchceduleCtrlDlg::setPaletteTextColor(QWidget *widget, QColor textColor) +{ + //如果为空指针则退出 + if(nullptr == widget) + return; + DPalette palette = widget->palette(); + //设置文字显示颜色 + palette.setColor(DPalette::WindowText,textColor); + widget->setPalette(palette); +} + +void CSchceduleCtrlDlg::changeEvent(QEvent *event) +{ + Q_UNUSED(event) + QFont font; + QFontMetrics font_button(font); + QFontMetrics font_firstLabel(font); + QFontMetrics font_seconLabel(font); + int height_firstLabel = (font_firstLabel.width(m_firstLabel->text()) / 300 + 1) * font_firstLabel.height(); + int height_seconLabel = (font_seconLabel.width(m_seconLabel->text()) / 300 + 1) * font_seconLabel.height(); + + for (int i = 0; i < buttonCount(); i++) { + QAbstractButton *button = getButton(i); + QString str = str_btName.at(i); + QString text_button = font_button.elidedText(str, Qt::ElideRight, 112); + + if (str.count() == 2) { + button->setText(QString().append(str.at(0)).append(QChar::Nbsp).append(str.at(1))); + } else { + button->setText(text_button); + } + } + setFixedHeight(36 + 48 + height_firstLabel + height_seconLabel + 30); +} + +void CSchceduleCtrlDlg::buttonJudge(int id) +{ + m_id = id; + accept(); +} + +QAbstractButton *CSchceduleCtrlDlg::addPushButton(QString btName, bool type) +{ + addButton(btName, false, DDialog::ButtonNormal); + int button_index = getButtonIndexByText(btName); + QAbstractButton *button = getButton(button_index); + + if (type) { + button->setFixedHeight(36); + button->setFixedWidth(165); + } else { + button->setFixedHeight(36); + button->setFixedWidth(129); + } + + button->setToolTip(btName); + str_btName.append(btName); + + return button; +} + +QAbstractButton *CSchceduleCtrlDlg::addsuggestButton(QString btName, bool type) +{ + addButton(btName,false,DDialog::ButtonRecommend); + int button_index = getButtonIndexByText(btName); + QAbstractButton *suggestButton = getButton(button_index); + + if (type) { + suggestButton->setFixedHeight(36); + suggestButton->setFixedWidth(165); + } else { + suggestButton->setFixedHeight(36); + suggestButton->setFixedWidth(129); + } + + suggestButton->setToolTip(btName); + str_btName.append(btName); + + return suggestButton; +} + +QAbstractButton *CSchceduleCtrlDlg::addWaringButton(QString btName, bool type) +{ + addButton(btName,false,DDialog::ButtonWarning); + int button_index = getButtonIndexByText(btName); + QAbstractButton *suggestButton = getButton(button_index); + + if (type) { + suggestButton->setFixedHeight(36); + suggestButton->setFixedWidth(165); + } else { + suggestButton->setFixedHeight(36); + suggestButton->setFixedWidth(129); + } + + suggestButton->setToolTip(btName); + str_btName.append(btName); + + return suggestButton; +} + +void CSchceduleCtrlDlg::setText(QString str) +{ + m_firstLabel->setText(str); + m_firstLabel->setToolTip(str); +} + +void CSchceduleCtrlDlg::setInformativeText(QString str) +{ + m_seconLabel->setText(str); + m_seconLabel->setToolTip(str); +} + +int CSchceduleCtrlDlg::clickButton() +{ + if (m_id < 0 || m_id > buttonCount() - 1) return buttonCount(); + return m_id; +} + diff -Nru dde-calendar-5.7.0.4/src/dialog/schcedulectrldlg.h dde-calendar-5.7.0.23/src/dialog/schcedulectrldlg.h --- dde-calendar-5.7.0.4/src/dialog/schcedulectrldlg.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/dialog/schcedulectrldlg.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#ifndef CSCHCEDULECTRLDLG_H +#define CSCHCEDULECTRLDLG_H + +#include +#include +#include + +#include +#include +#include +#include +#include + +DWIDGET_USE_NAMESPACE + +class CSchceduleCtrlDlg : public DDialog +{ + Q_OBJECT +public: + explicit CSchceduleCtrlDlg(QWidget *parent = nullptr); + QAbstractButton *addPushButton(QString btName, bool type = false); + QAbstractButton *addsuggestButton(QString btName, bool type = false); + QAbstractButton *addWaringButton(QString btName, bool type = false); + void setText(QString str); + void setInformativeText(QString str); + int clickButton(); +private: + void initUI(); + void initConnection(); + /** + * @brief setTheMe 根据主题type设置颜色 + * @param type 主题type + */ + void setTheMe(const int type); + /** + * @brief setPaletteTextColor 设置调色板颜色 + * @param widget 需要设置的widget + * @param textColor 显示颜色 + */ + void setPaletteTextColor(QWidget *widget,QColor textColor); +protected: + void changeEvent(QEvent *event) override; +private slots: + void buttonJudge(int id); +private: + QLabel *m_firstLabel = nullptr; + QLabel *m_seconLabel = nullptr; + QLabel *m_icon = nullptr; + QLabel *m_Title = nullptr; + int m_id = -1; + QButtonGroup *m_Buttongroup = nullptr; + QVector m_buttonlist; + QVBoxLayout *m_mainBoxLayout = nullptr; + QHBoxLayout *m_btBoxLayout = nullptr; + QFont labelF; + QFont labelT; + QVector str_btName; +}; + +#endif // MYSCHCEDULEVIEW_H diff -Nru dde-calendar-5.7.0.4/src/dialog/schceduledlg.cpp dde-calendar-5.7.0.23/src/dialog/schceduledlg.cpp --- dde-calendar-5.7.0.4/src/dialog/schceduledlg.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/dialog/schceduledlg.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,1032 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#include "schceduledlg.h" +#include "schcedulectrldlg.h" +#include "scheduledatamanage.h" +#include "timeedit.h" +#include "constants.h" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +DGUI_USE_NAMESPACE +CSchceduleDlg::CSchceduleDlg(int type, QWidget *parent, const bool isAllDay) + : DDialog(parent) + , m_createAllDay(isAllDay) +{ + setContentsMargins(0, 0, 0, 0); + m_type = type; + initUI(); + initConnection(); + + if (type == 1) { + m_titleLabel->setText(tr("New Event")); + m_beginDateEdit->setDate(QDate::currentDate()); + int hours = QTime::currentTime().hour(); + int minnutes = QTime::currentTime().minute() % DDECalendar::QuarterOfAnhourWithMinute; + + if (minnutes != 0) { + minnutes = QTime::currentTime().minute() / DDECalendar::QuarterOfAnhourWithMinute * DDECalendar::QuarterOfAnhourWithMinute + DDECalendar::QuarterOfAnhourWithMinute; + } + m_beginTimeEdit->setTime(QTime(hours, minnutes)); + m_endDateEdit->setDate(QDate::currentDate()); + m_endTimeEdit->setTime(QTime(hours, minnutes).addSecs(3600)); + } else { + m_titleLabel->setText(tr("Edit Event")); + } + + setFocusPolicy(Qt::WheelFocus); + setFixedSize(438, 470); +} + +CSchceduleDlg::~CSchceduleDlg() +{ + emit signalViewtransparentFrame(0); +} + +void CSchceduleDlg::setData(const ScheduleDtailInfo &info) +{ + m_scheduleDtailInfo = info; + m_typeComBox->setCurrentIndex(info.type.ID - 1); + m_textEdit->setPlainText(info.titleName); + m_beginDateEdit->setDate(info.beginDateTime.date()); + m_beginTimeEdit->setTime(info.beginDateTime.time()); + m_endDateEdit->setDate(info.endDateTime.date()); + m_endTimeEdit->setTime(info.endDateTime.time()); + m_allDayCheckbox->setChecked(info.allday); + m_endRepeatDate->setMinimumDate(info.beginDateTime.date()); + + m_currentDate = info.beginDateTime; + m_EndDate = info.endDateTime; + + slotallDayStateChanged(info.allday); + initRmindRpeatUI(); +} + +void CSchceduleDlg::setDate(const QDateTime &date) +{ + m_currentDate = date; + int hours = date.time().hour(); + int minnutes = 0; + + if (date.date() == QDate::currentDate()) { + minnutes = (date.time().minute() / DDECalendar::QuarterOfAnhourWithMinute + 1) * DDECalendar::QuarterOfAnhourWithMinute; + } else { + int minnutes = date.time().minute() % DDECalendar::QuarterOfAnhourWithMinute; + if (minnutes != 0) { + minnutes = (date.time().minute() / DDECalendar::QuarterOfAnhourWithMinute + 1) * DDECalendar::QuarterOfAnhourWithMinute; + } + } + + if (minnutes == 60) { + if (hours + 1 == 24) { + m_currentDate.setTime(QTime(0, 0)); + m_currentDate = m_currentDate.addDays(1); + } else { + m_currentDate.setTime(QTime(hours + 1, 0)); + } + } else { + m_currentDate.setTime(QTime(hours, minnutes)); + } + + m_beginDateEdit->setDate(m_currentDate.date()); + m_beginTimeEdit->setTime(m_currentDate.time()); + QDateTime datetime = m_currentDate.addSecs(3600); + m_EndDate = datetime; + m_endDateEdit->setDate(datetime.date()); + m_endTimeEdit->setTime(datetime.time()); + m_endRepeatDate->setMinimumDate(date.date()); +} + +ScheduleDtailInfo CSchceduleDlg::getScheduleData() +{ + return m_scheduleDtailInfo; +} + +void CSchceduleDlg::setAllDay(bool flag) +{ + m_allDayCheckbox->setChecked(flag); +} + +void CSchceduleDlg::slotCancelBt(int buttonIndex, QString buttonName) +{ + if (buttonIndex != 0 && buttonName != "Cancel") + return; + + reject(); +} + +void CSchceduleDlg::slotOkBt(int buttonIndex, QString buttonName) +{ + if (buttonIndex != 1 && buttonName != "Save") + return; + + int themetype = CScheduleDataManage::getScheduleDataManage()->getTheme(); + + ScheduleDtailInfo scheduleDtailInfo = m_scheduleDtailInfo; + QDateTime beginDateTime, endDateTime; + beginDateTime.setDate(m_beginDateEdit->date()); + beginDateTime.setTime(m_beginTimeEdit->getTime()); + endDateTime.setDate(m_endDateEdit->date()); + endDateTime.setTime(m_endTimeEdit->getTime()); + + if (m_textEdit->toPlainText().isEmpty()) { + scheduleDtailInfo.titleName = m_textEdit->placeholderText(); + } else { + scheduleDtailInfo.titleName = m_textEdit->toPlainText(); + } + + if (scheduleDtailInfo.titleName.isEmpty()) { + return; + } + + if (beginDateTime > endDateTime) { + DDialog *prompt = new DDialog(this); + prompt->setIcon(QIcon(":/resources/icon/warning.svg")); + prompt->setMessage(tr("End time must be greater than start time")); + prompt->setWindowFlags(prompt->windowFlags() | Qt::WindowStaysOnTopHint); + prompt->addButton(tr("OK"), true, DDialog::ButtonNormal); + prompt->exec(); + return; + } + + if (m_type == 1) + scheduleDtailInfo.id = 0; + scheduleDtailInfo.allday = m_allDayCheckbox->isChecked(); + + if (m_rmindCombox->currentIndex() == 0) + scheduleDtailInfo.remind = false; + else { + scheduleDtailInfo.remind = true; + } + + if (scheduleDtailInfo.allday) { + if (scheduleDtailInfo.remind) { + scheduleDtailInfo.remindData.time = QTime(9, 0); + if (m_rmindCombox->currentIndex() == 1) { + scheduleDtailInfo.remindData.n = DDECalendar::OnStartDay; + } else if (m_rmindCombox->currentIndex() == 2) { + scheduleDtailInfo.remindData.n = DDECalendar::OneDayBeforeWithDay; + } else if (m_rmindCombox->currentIndex() == 3) { + scheduleDtailInfo.remindData.n = DDECalendar::TwoDayBeforeWithDay; + } else if (m_rmindCombox->currentIndex() == 4) { + scheduleDtailInfo.remindData.n = DDECalendar::OneWeekBeforeWithDay; + } + } + } else { + if (scheduleDtailInfo.remind) { + if (m_rmindCombox->currentIndex() == 1) { + scheduleDtailInfo.remindData.n = DDECalendar::AtTimeOfEvent; + } else if (m_rmindCombox->currentIndex() == 2) { + scheduleDtailInfo.remindData.n = DDECalendar::FifteenMinutesBefore; + } else if (m_rmindCombox->currentIndex() == 3) { + scheduleDtailInfo.remindData.n = DDECalendar::ThirtyMinutesBefore; + } else if (m_rmindCombox->currentIndex() == 4) { + scheduleDtailInfo.remindData.n = DDECalendar::OneHourBefore; + } else if (m_rmindCombox->currentIndex() == 5) { + scheduleDtailInfo.remindData.n = DDECalendar::OneDayBeforeWithMinutes; + } else if (m_rmindCombox->currentIndex() == 6) { + scheduleDtailInfo.remindData.n = DDECalendar::TwoDayBeforeWithMinutes; + } else if (m_rmindCombox->currentIndex() == 7) { + scheduleDtailInfo.remindData.n = DDECalendar::OneWeekBeforeWithMinutes; + } + } + } + + scheduleDtailInfo.rpeat = m_beginrepeatCombox->currentIndex(); + + if (scheduleDtailInfo.rpeat != 0) { + scheduleDtailInfo.enddata.type = m_endrepeatCombox->currentIndex(); + + if (m_endrepeatCombox->currentIndex() == 1) { + if (m_endrepeattimes->text().isEmpty()) { + return; + } + scheduleDtailInfo.enddata.tcount = m_endrepeattimes->text().toInt(); + } else if (m_endrepeatCombox->currentIndex() == 2) { + QDateTime endrpeattime = beginDateTime; + endrpeattime.setDate(m_endRepeatDate->date()); + + if (beginDateTime > endrpeattime) { + return; + } + scheduleDtailInfo.enddata.date = endrpeattime; + } + } + + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->GetType( + m_typeComBox->currentIndex() + 1, scheduleDtailInfo.type); + scheduleDtailInfo.beginDateTime = beginDateTime; + scheduleDtailInfo.endDateTime = endDateTime; + + if (m_type == 1) { + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->addSchedule( + scheduleDtailInfo); + } else if (m_type == 0) { + if (m_scheduleDtailInfo.rpeat == 0 && + m_scheduleDtailInfo.rpeat == scheduleDtailInfo.rpeat) { + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo( + scheduleDtailInfo); + } else { + if (m_scheduleDtailInfo.allday != scheduleDtailInfo.allday) { + CSchceduleCtrlDlg msgBox; + msgBox.setText( + tr("All occurrences of a repeating event must have the same all-day status.")); + msgBox.setInformativeText(tr("Do you want to change all occurrences?")); + msgBox.addPushButton(tr("Cancel"), true); + msgBox.addWaringButton(tr("Change All"), true); + msgBox.exec(); + + if (msgBox.clickButton() == 0) { + return; + } else if (msgBox.clickButton() == 1) { + CScheduleDataManage::getScheduleDataManage() + ->getscheduleDataCtrl() + ->updateScheduleInfo(scheduleDtailInfo); + } + } else if (m_scheduleDtailInfo.rpeat != scheduleDtailInfo.rpeat) { + CSchceduleCtrlDlg msgBox; + msgBox.setText(tr("You are changing the repeating rule of this event.")); + msgBox.setInformativeText(tr("Do you want to change all occurrences?")); + msgBox.addPushButton(tr("Cancel"), true); + msgBox.addWaringButton(tr("Change All"), true); + msgBox.exec(); + + if (msgBox.clickButton() == 0) { + return; + } else if (msgBox.clickButton() == 1) { + CScheduleDataManage::getScheduleDataManage() + ->getscheduleDataCtrl() + ->updateScheduleInfo(scheduleDtailInfo); + } + } else { + ChangeRecurInfo(this,scheduleDtailInfo,m_scheduleDtailInfo,themetype); + } + } + } + accept(); + emit signalScheduleUpdate(); +} + +void CSchceduleDlg::slotTextChange() +{ + QTextCursor cursor = m_textEdit->textCursor(); + QString textContent = m_textEdit->toPlainText(); + int length = textContent.count(); + QString tStitlename = textContent; + + if (tStitlename.contains("\n")) { + tStitlename.replace("\n", ""); + m_textEdit->setText(tStitlename); + cursor.movePosition(QTextCursor::End); + m_textEdit->setTextCursor(cursor); + return; + } + + int maxLength = 256; // 最大字符数 + + if (length > maxLength) { + m_textEdit->setText(m_context); + cursor.movePosition(QTextCursor::End); + m_textEdit->setTextCursor(cursor); + } + m_context = m_textEdit->toPlainText(); +} + +void CSchceduleDlg::slotendrepeatTextchange() +{ + QAbstractButton *m_OkBt = getButton(1); + + if (m_endrepeattimes->text().isEmpty()) + m_OkBt->setEnabled(false); + else + m_OkBt->setEnabled(true); +} + +void CSchceduleDlg::slotBDateEidtInfo(const QDate &date) +{ + m_beginDateEdit->setDate(date); + m_endRepeatDate->setMinimumDate(date); + m_endDateEdit->setMinimumDate(date); + + QDateTime beginDateTime, endDateTime; + beginDateTime.setDate(m_beginDateEdit->date()); + beginDateTime.setTime(m_beginTimeEdit->getTime()); + endDateTime.setDate(m_endDateEdit->date()); + endDateTime.setTime(m_endTimeEdit->getTime()); + + if (endDateTime < beginDateTime) { + m_endTimeEdit->setTime(m_beginTimeEdit->getTime().addSecs(3600)); + } +} + +void CSchceduleDlg::slotallDayStateChanged(int state) +{ + m_rmindCombox->clear(); + + if (!state) { + m_rmindCombox->addItem(tr("Never")); + m_rmindCombox->addItem(tr("At time of event")); + m_rmindCombox->addItem(tr("15 minutes before")); + m_rmindCombox->addItem(tr("30 minutes before")); + m_rmindCombox->addItem(tr("1 hour before")); + m_rmindCombox->addItem(tr("1 day before")); + m_rmindCombox->addItem(tr("2 days before")); + m_rmindCombox->addItem(tr("1 week before")); + m_beginTimeEdit->setVisible(true); + m_endTimeEdit->setVisible(true); + + if (m_type == 0) { + m_beginDateEdit->setDate(m_scheduleDtailInfo.beginDateTime.date()); + m_beginTimeEdit->setTime(m_scheduleDtailInfo.beginDateTime.time()); + m_endDateEdit->setDate(m_scheduleDtailInfo.endDateTime.date()); + m_endTimeEdit->setTime(m_scheduleDtailInfo.endDateTime.time()); + } else { + m_beginDateEdit->setDate(m_currentDate.date()); + m_beginTimeEdit->setTime(m_currentDate.time()); + m_endDateEdit->setDate(m_EndDate.date()); + m_endTimeEdit->setTime(m_EndDate.time()); + } + } else { + m_rmindCombox->addItem(tr("Never")); + m_rmindCombox->addItem(tr("On start day (9:00 AM)")); + m_rmindCombox->addItem(tr("1 day before")); + m_rmindCombox->addItem(tr("2 days before")); + m_rmindCombox->addItem(tr("1 week before")); + m_beginTimeEdit->setVisible(false); + m_endTimeEdit->setVisible(false); + + if (m_type == 0) { + m_beginDateEdit->setDate(m_scheduleDtailInfo.beginDateTime.date()); + m_beginTimeEdit->setTime(QTime(0, 0)); + m_endDateEdit->setDate(m_scheduleDtailInfo.endDateTime.date()); + m_endTimeEdit->setTime(QTime(23, 59)); + } else { + m_beginDateEdit->setDate(m_currentDate.date()); + m_endDateEdit->setDate(m_EndDate.date()); + m_beginTimeEdit->setTime(QTime(0, 0)); + m_endTimeEdit->setTime(QTime(23, 59)); + m_rmindCombox->setCurrentIndex(2); + } + } +} + +void CSchceduleDlg::slotbRpeatactivated(int index) +{ + if (index > 0) { + m_endrepeatWidget->setVisible(true); + setFixedSize(438, 506); + } else { + m_endrepeatWidget->setVisible(false); + setFixedSize(438, 470); + } +} + +void CSchceduleDlg::sloteRpeatactivated(int index) +{ + if (index == 0) { + m_endrepeattimesWidget->setVisible(false); + m_endRepeatDate->setVisible(false); + } else if (index == 1) { + m_endrepeattimesWidget->setVisible(true); + m_endRepeatDate->setVisible(false); + } else { + m_endrepeattimesWidget->setVisible(false); + m_endRepeatDate->setVisible(true); + } +} + +bool CSchceduleDlg::eventFilter(QObject *obj, QEvent *pEvent) +{ + if (obj == m_textEdit) { + if (pEvent->type() == QEvent::KeyPress) { + QKeyEvent *keyEvent = static_cast(pEvent); + if (keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Enter) { + return true; + } + if (keyEvent->key() == Qt::Key_Tab) + return true; + } + if (m_type == 1) { + if (pEvent->type() == QEvent::FocusIn) { + //清空编辑框默认占位符 + m_textEdit->setPlaceholderText(""); + } else if (pEvent->type() == QEvent::FocusOut) { + //设置编辑框默认占位符 + m_textEdit->setPlaceholderText(tr("New event")); + } + } + } + return QDialog::eventFilter(obj, pEvent); +} + +void CSchceduleDlg::showEvent(QShowEvent *event) +{ + Q_UNUSED(event); + emit signalViewtransparentFrame(1); +} + +void CSchceduleDlg::changeEvent(QEvent *event) +{ + Q_UNUSED(event); + QFont mlabelF; + mlabelF.setWeight(QFont::Medium); + + QFontMetrics fontWidth_typeLabel(mlabelF); + QString str_typelabel = fontWidth_typeLabel.elidedText(tr("Type:"), Qt::ElideRight, DDECalendar::NewSchceduleLabelWidth); + m_typeLabel->setText(str_typelabel); + + QFontMetrics fontWidth_contentlabel(mlabelF); + QString str_contentlabel = fontWidth_contentlabel.elidedText(tr("Description:"), Qt::ElideRight, DDECalendar::NewSchceduleLabelWidth); + m_contentLabel->setText(str_contentlabel); + + QFontMetrics fontWidth_allDayLabel(mlabelF); + QString str_allDayLabel = fontWidth_allDayLabel.elidedText(tr("All Day:"), Qt::ElideRight, DDECalendar::NewSchceduleLabelWidth); + m_adllDayLabel->setText(str_allDayLabel); + + QFontMetrics fontWidth_beginTimeLabel(mlabelF); + QString str_beginTimeLabel = fontWidth_beginTimeLabel.elidedText(tr("Starts:"), Qt::ElideRight, DDECalendar::NewSchceduleLabelWidth); + m_beginTimeLabel->setText(str_beginTimeLabel); + + QFontMetrics fontWidth_endTimeLabel(mlabelF); + QString str_endTimeLabel = fontWidth_endTimeLabel.elidedText(tr("Ends:"), Qt::ElideRight, DDECalendar::NewSchceduleLabelWidth); + m_endTimeLabel->setText(str_endTimeLabel); + + QFontMetrics fontWidth_remindSetLabel(mlabelF); + QString str_remindSetLabel = fontWidth_remindSetLabel.elidedText(tr("Remind Me:"), Qt::ElideRight, DDECalendar::NewSchceduleLabelWidth); + m_remindSetLabel->setText(str_remindSetLabel); + + QFontMetrics fontWidth_beginRepeatLabel(mlabelF); + QString str_beginRepeatLabel = fontWidth_beginRepeatLabel.elidedText(tr("Repeat:"), Qt::ElideRight, DDECalendar::NewSchceduleLabelWidth); + m_beginrepeatLabel->setText(str_beginRepeatLabel); + + QFontMetrics fontWidth_endrepeatLabel(mlabelF); + QString str_endrepeatLabel = fontWidth_endrepeatLabel.elidedText(tr("End Repeat:"), Qt::ElideRight, DDECalendar::NewSchceduleLabelWidth); + m_endrepeatLabel->setText(str_endrepeatLabel); +} + +void CSchceduleDlg::initUI() +{ + //设置对象名称和辅助显示名称 + this->setObjectName("ScheduleEditDialog"); + this->setAccessibleName("ScheduleEditDialog"); + //在点击任何对话框上的按钮后不关闭对话框,保证关闭子窗口时不被一起关掉 + setOnButtonClickedClose(false); + + m_titleLabel = new QLabel(this); + QFont titlelabelF; + titlelabelF.setWeight(QFont::DemiBold); + titlelabelF.setPixelSize(17); + m_titleLabel->setFixedSize(148, 51); + m_titleLabel->setAlignment(Qt::AlignCenter | Qt::AlignVCenter); + m_titleLabel->move(145, 0); + m_titleLabel->setFont(titlelabelF); + + setSpacing(0); + QFont mlabelF; + mlabelF.setWeight(QFont::Medium); + + QVBoxLayout *maintlayout = new QVBoxLayout; + maintlayout->setMargin(0); + maintlayout->setSpacing(10); + QHBoxLayout *typelayout = new QHBoxLayout; + typelayout->setSpacing(0); + typelayout->setMargin(0); + m_typeLabel = new QLabel(); + m_typeLabel->setToolTip(tr("Type")); + DFontSizeManager::instance()->bind(m_typeLabel,DFontSizeManager::T6); + QFontMetrics fontWidth_typeLabel(mlabelF); + QString str_typelabel = fontWidth_typeLabel.elidedText(tr("Type:"), Qt::ElideRight, DDECalendar::NewSchceduleLabelWidth); + m_typeLabel->setText(str_typelabel); + m_typeLabel->setFont(mlabelF); + m_typeLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); + m_typeLabel->setFixedSize(78, 36); + m_typeComBox = new DComboBox(); + //设置对象名称和辅助显示名称 + m_typeComBox->setObjectName("ScheduleTypeCombobox"); + m_typeComBox->setAccessibleName("ScheduleTypeCombobox"); + m_typeComBox->setFixedSize(319, 36); + m_typeComBox->setIconSize(QSize(24,24)); + m_typeComBox->insertItem(0, + QIcon(DHiDPIHelper::loadNxPixmap(":/resources/icon/icon_type_work.svg") + .scaled(QSize(24, 24) * devicePixelRatioF())), + tr("Work")); + m_typeComBox->insertItem(1, + QIcon(DHiDPIHelper::loadNxPixmap(":/resources/icon/icon_type_life.svg") + .scaled(QSize(24, 24) * devicePixelRatioF())), + tr("Life")); + m_typeComBox->insertItem( + 2, + QIcon(DHiDPIHelper::loadNxPixmap(":/resources/icon/icon_type_other.svg") + .scaled(QSize(24, 24) * devicePixelRatioF())), + tr("Other")); + typelayout->addWidget(m_typeLabel); + typelayout->addWidget(m_typeComBox); + maintlayout->addLayout(typelayout); + + QHBoxLayout *contentLabellayout = new QHBoxLayout; + contentLabellayout->setSpacing(0); + contentLabellayout->setMargin(0); + QVBoxLayout *conttelabellayout = new QVBoxLayout; + conttelabellayout->setSpacing(0); + conttelabellayout->setMargin(0); + m_contentLabel = new QLabel(); + DFontSizeManager::instance()->bind(m_contentLabel,DFontSizeManager::T6); + QFontMetrics fontWidth_contentlabel(mlabelF); + QString str_contentlabel = fontWidth_contentlabel.elidedText(tr("Description:"), Qt::ElideRight, DDECalendar::NewSchceduleLabelWidth); + m_contentLabel->setText(str_contentlabel); + m_contentLabel->setFont(mlabelF); + m_contentLabel->setToolTip(tr("Description")); + m_contentLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); + m_contentLabel->setFixedWidth(78); + conttelabellayout->addWidget(m_contentLabel); + conttelabellayout->addStretch(); + m_textEdit = new DTextEdit(this); + //设置对象名称和辅助显示名称 + m_textEdit->setObjectName("ScheduleTitleEdit"); + m_textEdit->setAccessibleName("ScheduleTitleEdit"); + m_textEdit->setFixedSize(319, 86); + m_textEdit->setAcceptRichText(false); + + m_textEdit->setPlaceholderText(tr("New Event")); + //设置关联控件,用于QTextEdit控件捕获MouseButtonPress等事件 + QWidget *mpContentWidget = m_textEdit->viewport(); + //设置事件过滤器 + m_textEdit->installEventFilter(this); + mpContentWidget->installEventFilter(this); + + contentLabellayout->addLayout(conttelabellayout); + contentLabellayout->addWidget(m_textEdit); + maintlayout->addLayout(contentLabellayout); + + QHBoxLayout *alldayLabellayout = new QHBoxLayout; + alldayLabellayout->setSpacing(0); + alldayLabellayout->setMargin(0); + m_adllDayLabel = new QLabel(); + m_adllDayLabel->setToolTip(tr("All Day")); + DFontSizeManager::instance()->bind(m_adllDayLabel,DFontSizeManager::T6); + QFontMetrics fontWidth_allDayLabel(mlabelF); + QString str_allDayLabel = fontWidth_allDayLabel.elidedText(tr("All Day:"), Qt::ElideRight, DDECalendar::NewSchceduleLabelWidth); + m_adllDayLabel->setText(str_allDayLabel); + m_adllDayLabel->setFont(mlabelF); + m_adllDayLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); + m_adllDayLabel->setFixedWidth(78); + m_allDayCheckbox = new DCheckBox(this); + //设置对象名称和辅助显示名称 + m_allDayCheckbox->setObjectName("AllDayCheckBox"); + m_allDayCheckbox->setAccessibleName("AllDayCheckBox"); + alldayLabellayout->addWidget(m_adllDayLabel); + alldayLabellayout->addWidget(m_allDayCheckbox); + maintlayout->addLayout(alldayLabellayout); + + QHBoxLayout *beginLabellayout = new QHBoxLayout; + beginLabellayout->setSpacing(0); + beginLabellayout->setMargin(0); + m_beginTimeLabel = new QLabel(); + m_beginTimeLabel->setToolTip(tr("Starts")); + DFontSizeManager::instance()->bind(m_beginTimeLabel,DFontSizeManager::T6); + QFontMetrics fontWidth_beginTimeLabel(mlabelF); + QString str_beginTimeLabel = fontWidth_beginTimeLabel.elidedText(tr("Starts:"), Qt::ElideRight, DDECalendar::NewSchceduleLabelWidth); + m_beginTimeLabel->setText(str_beginTimeLabel); + m_beginTimeLabel->setFont(mlabelF); + m_beginTimeLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); + m_beginTimeLabel->setFixedSize(78, 36); + m_beginDateEdit = new QDateEdit(this); + //设置对象名称和辅助显示名称 + m_beginDateEdit->setObjectName("ScheduleBeginDateEdit"); + m_beginDateEdit->setAccessibleName("ScheduleBeginDateEdit"); + m_beginDateEdit->setFixedSize(175, 36); + + m_beginTimeEdit = new CTimeEdit(this); + //设置对象名称和辅助显示名称 + m_beginTimeEdit->setObjectName("ScheduleBeginTimeEdit"); + m_beginTimeEdit->setAccessibleName("ScheduleBeginTimeEdit"); + m_beginTimeEdit->setFixedSize(141, 36); + m_beginDateEdit->setCalendarPopup(true); + m_beginDateEdit->setDisplayFormat("yyyy-MM-dd"); + beginLabellayout->addWidget(m_beginTimeLabel); + beginLabellayout->addWidget(m_beginDateEdit); + beginLabellayout->addSpacing(8); + beginLabellayout->addWidget(m_beginTimeEdit); + beginLabellayout->addStretch(); + maintlayout->addLayout(beginLabellayout); + + QHBoxLayout *enQLabellayout = new QHBoxLayout; + enQLabellayout->setSpacing(0); + enQLabellayout->setMargin(0); + m_endTimeLabel = new QLabel(); + m_endTimeLabel->setToolTip(tr("Ends")); + DFontSizeManager::instance()->bind(m_endTimeLabel,DFontSizeManager::T6); + QFontMetrics fontWidth_endTimeLabel(mlabelF); + QString str_endTimeLabel = fontWidth_endTimeLabel.elidedText(tr("Ends:"), Qt::ElideRight, DDECalendar::NewSchceduleLabelWidth); + m_endTimeLabel->setText(str_endTimeLabel); + m_endTimeLabel->setFont(mlabelF); + m_endTimeLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); + m_endTimeLabel->setFixedSize(78, 36); + m_endDateEdit = new QDateEdit(this); + //设置对象名称和辅助显示名称 + m_endDateEdit->setObjectName("ScheduleEndDateEdit"); + m_endDateEdit->setAccessibleName("ScheduleEndDateEdit"); + m_endDateEdit->setFixedSize(175, 36); + m_endTimeEdit = new CTimeEdit(this); + //设置对象名称和辅助显示名称 + m_endTimeEdit->setObjectName("ScheduleEndTimeEdit"); + m_endTimeEdit->setAccessibleName("ScheduleEndTimeEdit"); + m_endTimeEdit->setFixedSize(141, 36); + m_endDateEdit->setCalendarPopup(true); + m_endDateEdit->setDisplayFormat("yyyy-MM-dd"); + + enQLabellayout->addWidget(m_endTimeLabel); + enQLabellayout->addWidget(m_endDateEdit); + enQLabellayout->addSpacing(8); + + enQLabellayout->addWidget(m_endTimeEdit); + enQLabellayout->addStretch(); + maintlayout->addLayout(enQLabellayout); + + QHBoxLayout *rminQLabellayout = new QHBoxLayout; + rminQLabellayout->setSpacing(0); + rminQLabellayout->setMargin(0); + m_remindSetLabel = new QLabel(); + DFontSizeManager::instance()->bind(m_remindSetLabel,DFontSizeManager::T6); + QFontMetrics fontWidth_remindSetLabel(mlabelF); + QString str_remindSetLabel = fontWidth_remindSetLabel.elidedText(tr("Remind Me:"), Qt::ElideRight, DDECalendar::NewSchceduleLabelWidth); + m_remindSetLabel->setToolTip(tr("Remind Me")); + m_remindSetLabel->setText(str_remindSetLabel); + m_remindSetLabel->setFont(mlabelF); + m_remindSetLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); + m_remindSetLabel->setFixedWidth(78); + + m_rmindCombox = new DComboBox(); + //设置对象名称和辅助显示名称 + m_rmindCombox->setObjectName("RmindComboBox"); + m_rmindCombox->setAccessibleName("RmindComboBox"); + m_rmindCombox->setFixedSize(175, 36); + m_rmindCombox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + rminQLabellayout->addWidget(m_remindSetLabel); + rminQLabellayout->addWidget(m_rmindCombox); + rminQLabellayout->addStretch(); + maintlayout->addLayout(rminQLabellayout); + + QHBoxLayout *repeatLabellayout = new QHBoxLayout; + repeatLabellayout->setSpacing(0); + repeatLabellayout->setMargin(0); + m_beginrepeatLabel = new QLabel(); + m_beginrepeatLabel->setToolTip(tr("Repeat")); + DFontSizeManager::instance()->bind(m_beginrepeatLabel,DFontSizeManager::T6); + QFontMetrics fontWidth_beginRepeatLabel(mlabelF); + QString str_beginRepeatLabel = fontWidth_beginRepeatLabel.elidedText(tr("Repeat:"), Qt::ElideRight, DDECalendar::NewSchceduleLabelWidth); + m_beginrepeatLabel->setText(str_beginRepeatLabel); + m_beginrepeatLabel->setFont(mlabelF); + m_beginrepeatLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); + m_beginrepeatLabel->setFixedWidth(78); + m_beginrepeatCombox = new DComboBox(); + //设置对象名称和辅助显示名称 + m_beginrepeatCombox->setObjectName("BeginRepeatComboBox"); + m_beginrepeatCombox->setAccessibleName("BeginRepeatComboBox"); + m_beginrepeatCombox->setFixedSize(175, 36); + m_beginrepeatCombox->addItem(tr("Never")); + m_beginrepeatCombox->addItem(tr("Daily")); + m_beginrepeatCombox->addItem(tr("Weekdays")); + m_beginrepeatCombox->addItem(tr("Weekly")); + m_beginrepeatCombox->addItem(tr("Monthly")); + m_beginrepeatCombox->addItem(tr("Yearly")); + repeatLabellayout->addWidget(m_beginrepeatLabel); + repeatLabellayout->addWidget(m_beginrepeatCombox); + repeatLabellayout->addStretch(); + maintlayout->addLayout(repeatLabellayout); + + QHBoxLayout *endrepeatLabellayout = new QHBoxLayout; + endrepeatLabellayout->setSpacing(0); + endrepeatLabellayout->setMargin(0); + m_endrepeatLabel = new QLabel(); + DFontSizeManager::instance()->bind(m_endrepeatLabel,DFontSizeManager::T6); + QFontMetrics fontWidth_endrepeatLabel(mlabelF); + QString str_endrepeatLabel = fontWidth_endrepeatLabel.elidedText(tr("End Repeat:"), Qt::ElideRight, DDECalendar::NewSchceduleLabelWidth); + m_endrepeatLabel->setToolTip(tr("End Repeat")); + m_endrepeatLabel->setText(str_endrepeatLabel); + m_endrepeatLabel->setFont(mlabelF); + m_endrepeatLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); + m_endrepeatLabel->setFixedWidth(78); + m_endrepeatCombox = new DComboBox(); + //设置对象名称和辅助显示名称 + m_endrepeatCombox->setObjectName("EndRepeatComboBox"); + m_endrepeatCombox->setAccessibleName("EndRepeatComboBox"); + m_endrepeatCombox->setFixedSize(175, 36); + m_endrepeatCombox->addItem(tr("Never")); + m_endrepeatCombox->addItem(tr("After")); + m_endrepeatCombox->addItem(tr("On")); + endrepeatLabellayout->addWidget(m_endrepeatLabel); + endrepeatLabellayout->addWidget(m_endrepeatCombox); + endrepeatLabellayout->addSpacing(8); + + QHBoxLayout *endrepeattimeslayout = new QHBoxLayout; + endrepeattimeslayout->setSpacing(0); + endrepeattimeslayout->setMargin(0); + endrepeattimeslayout->setContentsMargins(10, 0, 0, 0); + m_endrepeattimes = new DLineEdit(this); + //设置对象名称和辅助显示名称 + m_endrepeattimes->setObjectName("EndRepeatTimeEidt"); + m_endrepeattimes->setAccessibleName("EndRepeatTimeEidt"); + m_endrepeattimes->setFixedSize(71, 36); + m_endrepeattimes->setText(QString::number(10)); + m_endrepeattimes->setClearButtonEnabled(false); + QRegExp rx("^[1-9]\\d{0,2}$"); + QValidator *validator = new QRegExpValidator(rx, this); + m_endrepeattimes->lineEdit()->setValidator(validator); + m_endrepeattimesLabel = new QLabel(tr("time(s)")); + m_endrepeattimesLabel->setFont(mlabelF); + m_endrepeattimesLabel->setFixedHeight(36); + endrepeattimeslayout->addWidget(m_endrepeattimes); + endrepeattimeslayout->addWidget(m_endrepeattimesLabel); + m_endrepeattimesWidget = new DWidget; + //设置对象名称和辅助显示名称 + m_endrepeattimesWidget->setObjectName("EndRepeatTimeWidget"); + m_endrepeattimesWidget->setAccessibleName("EndRepeatTimeWidget"); + m_endrepeattimesWidget->setLayout(endrepeattimeslayout); + m_endrepeattimesWidget->setVisible(false); + endrepeatLabellayout->addWidget(m_endrepeattimesWidget); + + m_endRepeatDate = new DDateEdit; + //设置对象名称和辅助显示名称 + m_endRepeatDate->setObjectName("EndRepeatDateEdit"); + m_endRepeatDate->setAccessibleName("EndRepeatDateEdit"); + m_endRepeatDate->setCalendarPopup(true); + m_endRepeatDate->setFixedSize(141, 36); + m_endRepeatDate->setDate(QDate::currentDate()); + m_endRepeatDate->setDisplayFormat("yyyy-MM-dd"); + m_endRepeatDate->setCurrentSectionIndex(2); + QFont enddatefont; + enddatefont.setWeight(QFont::Medium); + m_endRepeatDate->setFont(enddatefont); + endrepeatLabellayout->addWidget(m_endRepeatDate); + endrepeatLabellayout->addStretch(); + m_endRepeatDate->setVisible(false); + m_endrepeatWidget = new DWidget; + //设置对象名称和辅助显示名称 + m_endrepeatWidget->setObjectName("EndRepeatDateWidget"); + m_endrepeatWidget->setAccessibleName("EndRepeatDateWidget"); + m_endrepeatWidget->setLayout(endrepeatLabellayout); + maintlayout->addWidget(m_endrepeatWidget); + m_endrepeatWidget->setVisible(false); + + addButton(tr("Cancel")); + addButton(tr("Save"), false, DDialog::ButtonRecommend); + + for (int i = 0; i < buttonCount(); i++) { + QAbstractButton *button = getButton(i); + button->setFixedSize(189, 36); + } + m_gwi = new DFrame(this); + m_gwi->setFrameShape(QFrame::NoFrame); + m_gwi->setLayout(maintlayout); + DPalette anipa = m_gwi->palette(); + QColor color = "#F8F8F8"; + color.setAlphaF(0.0); + anipa.setColor(DPalette::Background, color); + addContent(m_gwi, Qt::AlignCenter); + initDateEdit(); + + if (m_type == 1) + slotallDayStateChanged(0); + setFocus(); +} + +void CSchceduleDlg::initConnection() +{ + QObject::connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, + this, + &CSchceduleDlg::setTheMe); + connect(this, &DDialog::buttonClicked, this, &CSchceduleDlg::slotCancelBt); + connect(this, &DDialog::buttonClicked, this, &CSchceduleDlg::slotOkBt); + connect(m_textEdit, &DTextEdit::textChanged, this, &CSchceduleDlg::slotTextChange); + connect(m_endrepeattimes,&DLineEdit::textChanged, this, &CSchceduleDlg::slotendrepeatTextchange); + + connect(m_allDayCheckbox, &DCheckBox::stateChanged, this, + &CSchceduleDlg::slotallDayStateChanged); + connect(m_beginrepeatCombox, QOverload::of(&QComboBox::activated), this, + &CSchceduleDlg::slotbRpeatactivated); + connect(m_endrepeatCombox, QOverload::of(&QComboBox::activated), this, + &CSchceduleDlg::sloteRpeatactivated); + connect(m_beginDateEdit, &DDateEdit::userDateChanged, this, &CSchceduleDlg::slotBDateEidtInfo); + + QShortcut *shortcut = new QShortcut(this); + shortcut->setKey(QKeySequence(QLatin1String("ESC"))); + connect(shortcut, SIGNAL(activated()), this, SLOT(close())); +} + +void CSchceduleDlg::initDateEdit() +{ + m_beginDateEdit->setMinimumDate(QDate(DDECalendar::QueryEarliestYear, 1, 1)); // 0天 + m_beginDateEdit->setMaximumDate(QDate(DDECalendar::QueryLatestYear, 12, 31)); + m_endDateEdit->setMinimumDate(QDate(DDECalendar::QueryEarliestYear, 1, 1)); // 0天 + m_endDateEdit->setMaximumDate(QDate(DDECalendar::QueryLatestYear, 12, 31)); + return; +} + +void CSchceduleDlg::initRmindRpeatUI() +{ + if (m_scheduleDtailInfo.allday) { + if (m_scheduleDtailInfo.remind) { + if (m_scheduleDtailInfo.remindData.n == DDECalendar::OnStartDay) { + m_rmindCombox->setCurrentIndex(1); + } else if (m_scheduleDtailInfo.remindData.n == DDECalendar::OneDayBeforeWithDay) { + m_rmindCombox->setCurrentIndex(2); + } else if (m_scheduleDtailInfo.remindData.n == DDECalendar::TwoDayBeforeWithDay) { + m_rmindCombox->setCurrentIndex(3); + } else if (m_scheduleDtailInfo.remindData.n == DDECalendar::OneWeekBeforeWithDay) { + m_rmindCombox->setCurrentIndex(4); + } + } else { + m_rmindCombox->setCurrentIndex(0); + } + } else { + if (m_scheduleDtailInfo.remind) { + if (m_scheduleDtailInfo.remindData.n == DDECalendar::AtTimeOfEvent) { + m_rmindCombox->setCurrentIndex(1); + } else if (m_scheduleDtailInfo.remindData.n == DDECalendar::FifteenMinutesBefore) { + m_rmindCombox->setCurrentIndex(2); + } else if (m_scheduleDtailInfo.remindData.n == DDECalendar::ThirtyMinutesBefore) { + m_rmindCombox->setCurrentIndex(3); + } else if (m_scheduleDtailInfo.remindData.n == DDECalendar::OneHourBefore) { + m_rmindCombox->setCurrentIndex(4); + } else if (m_scheduleDtailInfo.remindData.n == DDECalendar::OneDayBeforeWithMinutes) { + m_rmindCombox->setCurrentIndex(5); + } else if (m_scheduleDtailInfo.remindData.n == DDECalendar::TwoDayBeforeWithMinutes) { + m_rmindCombox->setCurrentIndex(6); + } else if (m_scheduleDtailInfo.remindData.n == DDECalendar::OneWeekBeforeWithMinutes) { + m_rmindCombox->setCurrentIndex(7); + } + } else { + m_rmindCombox->setCurrentIndex(0); + } + } + slotbRpeatactivated(m_scheduleDtailInfo.rpeat); + m_beginrepeatCombox->setCurrentIndex(m_scheduleDtailInfo.rpeat); + + if (m_scheduleDtailInfo.rpeat != 0) { + if (m_scheduleDtailInfo.enddata.type == 0) { + m_endrepeatCombox->setCurrentIndex(0); + } else if (m_scheduleDtailInfo.enddata.type == 1) { + m_endrepeatCombox->setCurrentIndex(1); + m_endrepeattimes->setText(QString::number(m_scheduleDtailInfo.enddata.tcount)); + } else if (m_scheduleDtailInfo.enddata.type == 2) { + m_endrepeatCombox->setCurrentIndex(2); + m_endRepeatDate->setDate(m_scheduleDtailInfo.enddata.date.date()); + } + m_endrepeatWidget->show(); + sloteRpeatactivated(m_scheduleDtailInfo.enddata.type); + } else { + m_endrepeatWidget->hide(); + } +} + +void CSchceduleDlg::setTheMe(const int type) +{ + //日程标题编辑框文字颜色 + QColor titleColor; + if (type == 2) { + titleColor = "#C0C6D4"; + } else { + titleColor = "#414D68"; + } + DPalette pa = m_textEdit->palette(); + //设置颜色 + pa.setColor(DPalette::Text,titleColor); + m_textEdit->setPalette(pa); +} + +void CSchceduleDlg::ChangeRecurInfo(QWidget *parent, const ScheduleDtailInfo &newinfo, const ScheduleDtailInfo &oldinfo, int m_themetype) +{ + Q_UNUSED(m_themetype); + Q_UNUSED(parent); + + if (newinfo.RecurID == 0) { + CSchceduleCtrlDlg msgBox; + msgBox.setText(tr("You are changing a repeating event.")); + msgBox.setInformativeText( + tr("Do you want to change only this occurrence of the event, or all " + "occurrences?")); + msgBox.addPushButton(tr("Cancel")); + msgBox.addPushButton(tr("All")); + msgBox.addsuggestButton(tr("Only This Event")); + msgBox.exec(); + + if (msgBox.clickButton() == 0) { + return; + } else if (msgBox.clickButton() == 1) { + ScheduleDtailInfo scheduleDtailInfo = newinfo; + if (scheduleDtailInfo.enddata.type ==1 &&scheduleDtailInfo.enddata.tcount<1) { + scheduleDtailInfo.enddata.type =0; + } else if (scheduleDtailInfo.enddata.type ==2 && + scheduleDtailInfo.beginDateTime.daysTo( + scheduleDtailInfo.enddata.date)<0) { + scheduleDtailInfo.enddata.type =0; + scheduleDtailInfo.rpeat = 0; + } + CScheduleDataManage::getScheduleDataManage() + ->getscheduleDataCtrl() + ->updateScheduleInfo(scheduleDtailInfo); + } else if (msgBox.clickButton() == 2) { + ChangeOnlyInfo(newinfo,oldinfo); + } + } else { + CSchceduleCtrlDlg msgBox; + msgBox.setText(tr("You are changing a repeating event.")); + msgBox.setInformativeText( + tr("Do you want to change only this occurrence of the event, or this and " + "all future occurrences?")); + msgBox.addPushButton(tr("Cancel")); + msgBox.addPushButton(tr("All Future Events")); + msgBox.addsuggestButton(tr("Only This Event")); + msgBox.exec(); + + if (msgBox.clickButton() == 0) { + return; + } else if (msgBox.clickButton() == 1) { + ScheduleDtailInfo newschedule = newinfo; + newschedule.RecurID = 0; + newschedule.id = 0; + if (newschedule.enddata.type ==1) { + newschedule.enddata.tcount = qAbs(newinfo.enddata.tcount - newinfo.RecurID); + if (newschedule.enddata.tcount <1) { + newschedule.enddata.type =0; + newschedule.rpeat = 0; + } + } + CScheduleDataManage::getScheduleDataManage() + ->getscheduleDataCtrl() + ->addSchedule(newschedule); + ScheduleDtailInfo updatescheduleData; + CScheduleDataManage::getScheduleDataManage() + ->getscheduleDataCtrl() + ->getScheduleInfoById(oldinfo.id, updatescheduleData); + if (updatescheduleData.enddata.type == 1) { + updatescheduleData.enddata.tcount = newinfo.RecurID -1; + if (updatescheduleData.enddata.tcount <1) { + updatescheduleData.enddata.type =0; + updatescheduleData.rpeat = 0; + } + } else { + //如果结束类型为永不或结束于日期 + updatescheduleData.enddata.type = 2; + updatescheduleData.enddata.date = + oldinfo.beginDateTime.addDays(-1); + } + + CScheduleDataManage::getScheduleDataManage() + ->getscheduleDataCtrl() + ->updateScheduleInfo(updatescheduleData); + } else if (msgBox.clickButton() == 2) { + ChangeOnlyInfo(newinfo,oldinfo); + } + } +} + +void CSchceduleDlg::ChangeOnlyInfo(const ScheduleDtailInfo &newinfo, const ScheduleDtailInfo &oldinfo) +{ + ScheduleDtailInfo newschedule = newinfo; + newschedule.rpeat = 0; + newschedule.RecurID = 0; + newschedule.id = 0; + newschedule.ignore.clear(); + CScheduleDataManage::getScheduleDataManage() + ->getscheduleDataCtrl() + ->addSchedule(newschedule); + ScheduleDtailInfo updatescheduleData; + CScheduleDataManage::getScheduleDataManage() + ->getscheduleDataCtrl() + ->getScheduleInfoById(oldinfo.id, updatescheduleData); + updatescheduleData.ignore.append(oldinfo.beginDateTime); + CScheduleDataManage::getScheduleDataManage() + ->getscheduleDataCtrl() + ->updateScheduleInfo(updatescheduleData); +} diff -Nru dde-calendar-5.7.0.4/src/dialog/schceduledlg.h dde-calendar-5.7.0.23/src/dialog/schceduledlg.h --- dde-calendar-5.7.0.4/src/dialog/schceduledlg.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/dialog/schceduledlg.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,126 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#ifndef SCHCEDULEDLG_H +#define SCHCEDULEDLG_H + +#include "schedulestructs.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +DWIDGET_USE_NAMESPACE +class CTimeEdit; +class CSchceduleDlg : public DDialog +{ + Q_OBJECT +public: + CSchceduleDlg(int type, QWidget *parent = nullptr, const bool isAllDay = true); + ~CSchceduleDlg() override; + void setData(const ScheduleDtailInfo &info); + void setDate(const QDateTime &date); + ScheduleDtailInfo getScheduleData(); + void setAllDay(bool flag); +signals: + void signalViewtransparentFrame(int type); + void signalScheduleUpdate(int id = 0); +public slots: + void slotCancelBt(int buttonIndex, QString buttonName); + void slotOkBt(int buttonIndex, QString buttonName); + void slotTextChange(); + void slotendrepeatTextchange(); + void slotBDateEidtInfo(const QDate &date); + void slotallDayStateChanged(int state); + void slotbRpeatactivated(int index); + void sloteRpeatactivated(int index); +protected: + bool eventFilter(QObject *obj, QEvent *pEvent) override; + void showEvent(QShowEvent *event) override; + void changeEvent(QEvent *event) override; +private: + void initUI(); + void initConnection(); + void initDateEdit(); + void initRmindRpeatUI(); + /** + * @brief setTheMe 根据主题type设置颜色 + * @param type 主题type + */ + void setTheMe(const int type); +public: + static void ChangeRecurInfo(QWidget *parent,const ScheduleDtailInfo &newinfo, + const ScheduleDtailInfo &oldinfo,int m_themetype); + static void ChangeOnlyInfo(const ScheduleDtailInfo &newinfo, + const ScheduleDtailInfo &oldinfo); +private: + QLabel *m_typeLabel = nullptr; + DComboBox *m_typeComBox = nullptr; + QLabel *m_contentLabel = nullptr; + DTextEdit *m_textEdit = nullptr; + QLabel *m_beginTimeLabel = nullptr; + DDateEdit *m_beginDateEdit = nullptr; + CTimeEdit *m_beginTimeEdit = nullptr; + QLabel *m_endTimeLabel = nullptr; + DDateEdit *m_endDateEdit = nullptr; + CTimeEdit *m_endTimeEdit = nullptr; + + QLabel *m_adllDayLabel = nullptr; + DCheckBox *m_allDayCheckbox = nullptr; + QLabel *m_remindSetLabel = nullptr; + DComboBox *m_rmindCombox = nullptr; + QLabel *m_beginrepeatLabel = nullptr; + DComboBox *m_beginrepeatCombox = nullptr; + QLabel *m_endrepeatLabel = nullptr; + DComboBox *m_endrepeatCombox = nullptr; + DLineEdit *m_endrepeattimes = nullptr; + QLabel *m_endrepeattimesLabel = nullptr; + DWidget *m_endrepeattimesWidget; + DDateEdit *m_endRepeatDate = nullptr; + DWidget *m_endrepeatWidget = nullptr; + DFrame *m_gwi = nullptr; + QLabel *m_titleLabel = nullptr; + + QString m_context; + const bool m_createAllDay; +private: +//日程 + ScheduleDtailInfo m_scheduleDtailInfo; + int m_type; // 1新建 0 编辑日程 + QDateTime m_currentDate; + QDateTime m_EndDate; +}; + +#endif // SHCEDULEDLG_H diff -Nru dde-calendar-5.7.0.4/src/draginfographicsview.cpp dde-calendar-5.7.0.23/src/draginfographicsview.cpp --- dde-calendar-5.7.0.4/src/draginfographicsview.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/draginfographicsview.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,607 +0,0 @@ -/* -* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. -* -* Author: uniontech -* -* Maintainer: uniontech -* -* 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 -* 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 . -*/ -#include "draginfographicsview.h" - -#include -#include -#include -#include -#include - -#include "schceduledlg.h" -#include "schcedulectrldlg.h" -#include "myschceduleview.h" - -DragInfoGraphicsView::DragInfoGraphicsView(DWidget *parent) - :DGraphicsView (parent), - m_Scene(new QGraphicsScene(this)), - m_rightMenu(new DMenu(this)), - m_MoveDate(QDateTime::currentDateTime()) -{ - setFrameShape(QFrame::NoFrame); - setScene(m_Scene); - setContentsMargins(0, 0, 0, 0); - QPalette pal = palette(); - pal.setColor(QPalette::Light, QColor(0, 0, 0, 0)); - pal.setColor(QPalette::Dark, QColor(0, 0, 0, 0)); - pal.setColor(QPalette::Base, QColor(0, 0, 0, 0)); - setPalette(pal); - - m_editAction = new QAction(tr("Edit"), this); - m_deleteAction = new QAction(tr("Delete"), this); - m_createAction = new QAction(tr("New event"), this); - connect(m_createAction, &QAction::triggered, this, - static_cast(&DragInfoGraphicsView::slotCreate)); - this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - this->setViewportMargins(0, 0, 0, 0); - setMouseTracking(true); - viewport()->setMouseTracking(true); - setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); - setAlignment(Qt::AlignLeft | Qt::AlignTop); - setViewportUpdateMode(QGraphicsView::FullViewportUpdate); - m_Drag = new QDrag(this); -} - -DragInfoGraphicsView::~DragInfoGraphicsView() -{ - -} - - -void DragInfoGraphicsView::mousePressEvent(QMouseEvent *event) -{ - if (event->button() != Qt::LeftButton) { -// m_press = false; -// m_DragStatus =NONE; -// emit signalScheduleShow(false); - return; - } - - setPressSelectInfo(ScheduleDtailInfo()); - QGraphicsItem *listItem =itemAt(event->localPos().toPoint()); - DragInfoItem *infoitem = dynamic_cast(listItem); - if (infoitem != nullptr) { - setPressSelectInfo(infoitem->getData()); - m_press = true; - DragInfoItem::setPressFlag(true); - } else { - emit signalScheduleShow(false); - } - DragPressEvent(event->pos(),infoitem); - update(); -} - -void DragInfoGraphicsView::mouseReleaseEvent(QMouseEvent *event) -{ - if (event->button() ==Qt::RightButton) { - return; - } - mouseReleaseScheduleUpdate(); -} - - -void DragInfoGraphicsView::mouseMoveEvent(QMouseEvent *event) -{ - DGraphicsView::mouseMoveEvent(event); - if (m_press) { - emit signalScheduleShow(false); - m_press = false; - DragInfoItem::setPressFlag(false); - } - DragInfoItem *item = dynamic_cast(itemAt(event->pos())); - if (item != nullptr) { - if (item->getData().type.ID != 4) { - if (m_DragStatus == NONE) { - switch (getPosInItem(event->pos(),item->rect())) { - case LEFT: - case RIGHT: - setCursor(Qt::SplitHCursor); - break; - case TOP: - case BOTTOM: - setCursor(Qt::SplitVCursor); - break; - default: - setCursor(Qt::ArrowCursor); - break; - } - } - } - } else { - if (m_DragStatus == NONE) { - setCursor(Qt::ArrowCursor); - } - } - QDateTime gDate = getPosDate(event->pos()); - switch (m_DragStatus) { - case IsCreate: - m_isCreate = JudgeIsCreate(event->pos()); - if (m_isCreate) { - if (!IsEqualtime(m_MoveDate,gDate)) { - m_MoveDate = gDate; - m_DragScheduleInfo = getScheduleInfo(m_PressDate,m_MoveDate); - upDateInfoShow(IsCreate,m_DragScheduleInfo); - setPressSelectInfo(m_DragScheduleInfo); - } - } - break; - case ChangeBegin: - if (!IsEqualtime(m_MoveDate,gDate)) { - m_MoveDate = gDate; - m_DragScheduleInfo.beginDateTime = - getDragScheduleInfoBeginTime(m_MoveDate); - m_DragScheduleInfo.endDateTime = m_InfoEndTime; - upDateInfoShow(ChangeBegin,m_DragScheduleInfo); - } - break; - case ChangeEnd: - if (!IsEqualtime(m_MoveDate,gDate)) { - m_MoveDate = gDate; - m_DragScheduleInfo.endDateTime = - getDragScheduleInfoEndTime(m_MoveDate); - m_DragScheduleInfo.beginDateTime =m_InfoBeginTime; - upDateInfoShow(ChangeEnd,m_DragScheduleInfo); - } - break; - case ChangeWhole: { - if (!m_PressRect.contains(event->pos())) { - Qt::DropAction dropaction = m_Drag->exec( Qt::MoveAction); - Q_UNUSED(dropaction); - m_Drag = nullptr; - m_DragStatus = NONE; - setCursor(Qt::ArrowCursor); - m_DragScheduleInfo.IsMoveInfo = false; - setPressSelectInfo(m_DragScheduleInfo); - emit signalsUpdateShcedule(); - } - } - break; - default: - break; - } -} - -void DragInfoGraphicsView::wheelEvent(QWheelEvent *event) -{ - DGraphicsView::wheelEvent(event); -} - -void DragInfoGraphicsView::contextMenuEvent(QContextMenuEvent *event) -{ - DGraphicsView::contextMenuEvent(event); - if (m_DragStatus ==IsCreate) { - return; - } - emit signalScheduleShow(false); - m_press = false; - m_DragStatus =NONE; - QGraphicsItem *listItem = itemAt(event->pos()); - - DragInfoItem *infoitem = dynamic_cast(listItem); - if (infoitem !=nullptr) { - if (infoitem->getData().type.ID !=4) { - m_rightMenu->clear(); - m_rightMenu->addAction(m_editAction); - m_rightMenu->addAction(m_deleteAction); - QAction *action_t = m_rightMenu->exec(QCursor::pos()); - if (action_t == m_editAction) { - emit signalViewtransparentFrame(1); - CSchceduleDlg dlg(0, this); - dlg.setData(infoitem->getData()); - if (dlg.exec() == DDialog::Accepted) { - emit signalsUpdateShcedule(); - } - emit signalViewtransparentFrame(0); - } else if (action_t == m_deleteAction) { - DeleteItem(infoitem->getData()); - } - } else { - emit signalViewtransparentFrame(1); - CMySchceduleView dlg(infoitem->getData(), this); - dlg.exec(); - emit signalViewtransparentFrame(0); - -// qDebug()<<"setFocus"; -// emit signalViewtransparentFrame(1); -// this->setFocus(Qt::MouseFocusReason); - } - } else { - RightClickToCreate(listItem,event->pos()); - } -} - -void DragInfoGraphicsView::dragEnterEvent(QDragEnterEvent *event) -{ - if (event->mimeData()->hasFormat("Info")) { - QJsonParseError json_error; - QString str = event->mimeData()->data("Info"); - QJsonDocument jsonDoc(QJsonDocument::fromJson(str.toLocal8Bit(), &json_error)); - if (json_error.error != QJsonParseError::NoError) { - event->ignore(); - } - QJsonObject rootobj = jsonDoc.object(); - ScheduleDtailInfo info = - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->JsonObjectToInfo(rootobj); - if ((event->source() !=this && info.rpeat >0) || - info.type.ID ==4) { - event->ignore(); - } else { - event->accept(); - } - - } else { - event->ignore(); - } - -} - -void DragInfoGraphicsView::dragLeaveEvent(QDragLeaveEvent *event) -{ - Q_UNUSED(event); - upDateInfoShow(); - m_MoveDate = m_MoveDate.addMonths(-2); -} - -void DragInfoGraphicsView::dragMoveEvent(QDragMoveEvent *event) -{ - QString str = event->mimeData()->data("Info"); - QDateTime gDate = getPosDate(event->pos()); - QJsonParseError json_error; - QJsonDocument jsonDoc(QJsonDocument::fromJson(str.toLocal8Bit(), &json_error)); - - if (json_error.error != QJsonParseError::NoError) { - return; - } - if (!IsEqualtime(m_MoveDate,gDate)) { - m_MoveDate = gDate; - QJsonObject rootobj = jsonDoc.object(); - m_DragScheduleInfo = - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->JsonObjectToInfo(rootobj); - - MoveInfoProcess(m_DragScheduleInfo,event->posF()); - setPressSelectInfo(m_DragScheduleInfo); - } -} - -void DragInfoGraphicsView::dropEvent(QDropEvent *event) -{ - if (event->mimeData()->hasFormat("Info")) { - if (event->source()!=this || m_MoveDate !=m_PressDate) { - updateScheduleInfo(m_DragScheduleInfo); - } else { - emit signalsUpdateShcedule(); - } - m_DragStatus = NONE; - m_MoveDate = m_MoveDate.addMonths(-2); - } -} - -bool DragInfoGraphicsView::event(QEvent *e) -{ - if (e->type() ==QEvent::Leave) { - if (m_DragStatus ==IsCreate || - m_DragStatus == ChangeBegin || - m_DragStatus == ChangeEnd) - mouseReleaseScheduleUpdate(); - } - return DGraphicsView::event(e); -} - -void DragInfoGraphicsView::keyPressEvent(QKeyEvent *event) -{ - if (event->key() == Qt::Key_Left || event->key() ==Qt::Key_Right) - return; - DGraphicsView::keyPressEvent(event); -} - -void DragInfoGraphicsView::slotCreate() -{ - slotCreate(m_createDate); -} - -void DragInfoGraphicsView::setPressSelectInfo(const ScheduleDtailInfo &info) -{ - CScheduleDataManage::getScheduleDataManage()->setPressSelectInfo(info); -} - -void DragInfoGraphicsView::updateScheduleInfo(const ScheduleDtailInfo &info) -{ - emit signalViewtransparentFrame(1); - if (info.rpeat >0) { - CSchceduleDlg::ChangeRecurInfo(this,info, - m_PressScheduleInfo,m_themetype); - } else { - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo( - info); - } - emit signalViewtransparentFrame(0); -} - -void DragInfoGraphicsView::DragPressEvent(const QPoint &pos, DragInfoItem *item) -{ - m_PressPos = pos; - m_PressDate = getPosDate(pos); - - m_MoveDate = m_PressDate.addMonths(-2); - if (item != nullptr) { - PosInItem mpressstatus = getPosInItem(pos,item->boundingRect()); - if (mpressstatus != MIDDLE && item->getData().type.ID == 4) { - return; - } - m_DragScheduleInfo = item->getData(); - m_PressScheduleInfo = item->getData(); - m_InfoBeginTime = m_DragScheduleInfo.beginDateTime; - m_InfoEndTime = m_DragScheduleInfo.endDateTime; - switch (mpressstatus) { - case TOP: - m_DragStatus = ChangeBegin; - setCursor(Qt::SplitVCursor); - break; - case BOTTOM: - m_DragStatus = ChangeEnd; - setCursor(Qt::SplitVCursor); - break; - case LEFT: - m_DragStatus = ChangeBegin; - setCursor(Qt::SplitHCursor); - break; - case RIGHT: - m_DragStatus = ChangeEnd; - setCursor(Qt::SplitHCursor); - break; - default: - ShowSchedule(item); - m_DragStatus = ChangeWhole; - QMimeData *mimeData = new QMimeData(); - mimeData->setText(m_DragScheduleInfo.titleName); - mimeData->setData("Info", - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->InfoToJson(m_DragScheduleInfo).toUtf8()); - - if (m_Drag ==nullptr) { - m_Drag = new QDrag(this); - } - m_Drag->setMimeData(mimeData); - setDragPixmap(m_Drag,item); - QPointF itemPos = QPointF(pos.x()-item->boundingRect().x(), - pos.y()-item->boundingRect().y()); - m_Drag->setHotSpot(itemPos.toPoint()); - break; - } - } else { - m_DragStatus = IsCreate; - m_isCreate = false; - } -} - -void DragInfoGraphicsView::mouseReleaseScheduleUpdate() -{ - setCursor(Qt::ArrowCursor); - m_press = false; - DragInfoItem::setPressFlag(false); - bool isUpdateInfo = false; - switch (m_DragStatus) { - case IsCreate: - if (MeetCreationConditions(m_MoveDate)) { - //如果不添加会进入leaveEvent事件内的条件 - m_DragStatus = NONE; - - emit signalViewtransparentFrame(1); - CSchceduleDlg dlg(1, this); - dlg.setData(m_DragScheduleInfo); - if (dlg.exec() == DDialog::Accepted) { - } else { - setPressSelectInfo(ScheduleDtailInfo()); - } - emit signalViewtransparentFrame(0); - isUpdateInfo = true; - } - break; - case ChangeBegin: - if (!IsEqualtime(m_MoveDate,m_InfoBeginTime)) { - //如果不添加会进入leaveEvent事件内的条件 - m_DragStatus = NONE; - updateScheduleInfo(m_DragScheduleInfo); - isUpdateInfo = true; - } - break; - case ChangeEnd: - if (!IsEqualtime(m_MoveDate,m_InfoEndTime)) { - //如果不添加会进入leaveEvent事件内的条件 - m_DragStatus = NONE; - updateScheduleInfo(m_DragScheduleInfo); - isUpdateInfo = true; - } - break; - default: - break; - } - m_DragStatus = NONE; - if (isUpdateInfo) { - emit signalsUpdateShcedule(); - } - update(); -} - -void DragInfoGraphicsView::DeleteItem(const ScheduleDtailInfo &info) -{ - emit signalViewtransparentFrame(1); - if (info.rpeat == 0) { - CSchceduleCtrlDlg msgBox(this); - msgBox.setText(tr("You are deleting an event.")); - msgBox.setInformativeText(tr("Are you sure you want to delete this event?")); - /*QAbstractButton *noButton = */msgBox.addPushButton(tr("Cancel"), true); - /*QAbstractButton *yesButton = */msgBox.addWaringButton(tr("Delete"), true); -// msgBox.updatesize(); -// DPalette pa = yesButton->palette(); -// if (m_themetype == 0 || m_themetype == 1) { -// pa.setColor(DPalette::ButtonText, Qt::red); -// } else { -// pa.setColor(DPalette::ButtonText, "#FF5736"); -// } -// yesButton->setPalette(pa); - msgBox.exec(); - - if (msgBox.clickButton() == 0) { - emit signalViewtransparentFrame(0); - return; - } else if (msgBox.clickButton() == 1) { - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->deleteScheduleInfoById(info.id); - } - } else { - if (info.RecurID == 0) { - CSchceduleCtrlDlg msgBox(this); - msgBox.setText(tr("You are deleting an event.")); - msgBox.setInformativeText(tr("Do you want to delete all occurrences of this event, or only the selected occurrence?")); - /*QAbstractButton *noButton = */msgBox.addPushButton(tr("Cancel")); - /*QAbstractButton *yesallbutton = */msgBox.addPushButton(tr("Delete All")); - /*QAbstractButton *yesButton = */msgBox.addsuggestButton(tr("Delete Only This Event")); -// msgBox.updatesize(); -// DPalette pa = yesButton->palette(); -// if (m_themetype == 0 || m_themetype == 1) { -// pa.setColor(DPalette::ButtonText, Qt::white); -// pa.setColor(DPalette::Dark, QColor("#25B7FF")); -// pa.setColor(DPalette::Light, QColor("#0098FF")); -// } else { -// pa.setColor(DPalette::ButtonText, "#B8D3FF"); -// pa.setColor(DPalette::Dark, QColor("#0056C1")); -// pa.setColor(DPalette::Light, QColor("#004C9C")); -// } -// yesButton->setPalette(pa); - msgBox.exec(); - - if (msgBox.clickButton() == 0) { - emit signalViewtransparentFrame(0); - return; - } else if (msgBox.clickButton() == 1) { - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->deleteScheduleInfoById(info.id); - } else if (msgBox.clickButton() == 2) { - - ScheduleDtailInfo newschedule; - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->getScheduleInfoById(info.id, newschedule); - newschedule.ignore.append(info.beginDateTime); - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo(newschedule); - } - } else { - CSchceduleCtrlDlg msgBox(this); - msgBox.setText(tr("You are deleting an event.")); - msgBox.setInformativeText(tr("Do you want to delete this and all future occurrences of this event, or only the selected occurrence?")); - /*QAbstractButton *noButton = */msgBox.addPushButton(tr("Cancel")); - /*QAbstractButton *yesallbutton = */msgBox.addPushButton(tr("Delete All Future Events")); - /*QAbstractButton *yesButton = */msgBox.addsuggestButton(tr("Delete Only This Event")); -// msgBox.updatesize(); -// DPalette pa = yesButton->palette(); -// if (m_themetype == 0 || m_themetype == 1) { -// pa.setColor(DPalette::ButtonText, Qt::white); -// pa.setColor(DPalette::Dark, QColor("#25B7FF")); -// pa.setColor(DPalette::Light, QColor("#0098FF")); -// } else { -// pa.setColor(DPalette::ButtonText, "#B8D3FF"); -// pa.setColor(DPalette::Dark, QColor("#0056C1")); -// pa.setColor(DPalette::Light, QColor("#004C9C")); -// } -// yesButton->setPalette(pa); - msgBox.exec(); - - if (msgBox.clickButton() == 0) { - emit signalViewtransparentFrame(0); - return; - } else if (msgBox.clickButton() == 1) { - ScheduleDtailInfo newschedule; - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->getScheduleInfoById(info.id, newschedule); - newschedule.enddata.type = 2; - newschedule.enddata.date = info.beginDateTime.addDays(-1); - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo(newschedule); - - } else if (msgBox.clickButton() == 2) { - ScheduleDtailInfo newschedule; - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->getScheduleInfoById(info.id, newschedule); - newschedule.ignore.append(info.beginDateTime); - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo(newschedule); - } - } - } - emit signalsUpdateShcedule(); - emit signalViewtransparentFrame(0); -} - -void DragInfoGraphicsView::setDragPixmap(QDrag *drag, DragInfoItem *item) -{ - Q_UNUSED(drag); - Q_UNUSED(item); -} - -void DragInfoGraphicsView::slotCreate(const QDateTime &date) -{ - emit signalViewtransparentFrame(1); - CSchceduleDlg dlg(1, this); - QDateTime tDatatime; - tDatatime.setDate(date.date()); - if (date.date() == QDate::currentDate()) { - tDatatime.setTime(QTime::currentTime()); - } else { - tDatatime.setTime(QTime(8, 0)); - } - dlg.setDate(tDatatime); - dlg.setAllDay(true); - if (dlg.exec() == DDialog::Accepted) { - emit signalsUpdateShcedule(); - } - emit signalViewtransparentFrame(0); -} - -ScheduleDtailInfo DragInfoGraphicsView::getScheduleInfo(const QDateTime &beginDate, const QDateTime &endDate) -{ - ScheduleDtailInfo info; - if (beginDate.daysTo(endDate)>0) { - info.beginDateTime = QDateTime(beginDate.date(),QTime(0,0,0)); - info.endDateTime = QDateTime(endDate.date(),QTime(23,59,59)); - } else { - info.beginDateTime = QDateTime(endDate.date(),QTime(0,0,0)); - info.endDateTime = QDateTime(beginDate.date(),QTime(23,59,00)); - } - info.titleName = tr("New Event"); - info.allday = true; - info.remind = true; - info.id = 0; - info.remindData.n = 1; - info.remindData.time = QTime(9, 0); - info.RecurID = 0; - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->GetType( - 1, info.type); - info.rpeat = 0; - - return info; -} - -void DragInfoGraphicsView::ShowSchedule(DragInfoItem *infoitem) -{ - if (infoitem ==nullptr) - return; - emit signalScheduleShow(true, infoitem->getData()); - -} - -int DragInfoGraphicsView::getDragStatus() const -{ - return m_DragStatus; -} - diff -Nru dde-calendar-5.7.0.4/src/draginfographicsview.h dde-calendar-5.7.0.23/src/draginfographicsview.h --- dde-calendar-5.7.0.4/src/draginfographicsview.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/draginfographicsview.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,119 +0,0 @@ -/* -* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. -* -* Author: uniontech -* -* Maintainer: uniontech -* -* 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 -* 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 . -*/ -#ifndef DRAGINFOGRAPHICSVIEW_H -#define DRAGINFOGRAPHICSVIEW_H -#include -#include -#include - - -#include "scheduledatamanage.h" -#include "draginfoitem.h" - -DWIDGET_USE_NAMESPACE - -class DragInfoGraphicsView : public DGraphicsView -{ - Q_OBJECT -public: - explicit DragInfoGraphicsView(DWidget *parent = nullptr); - ~DragInfoGraphicsView() override; -public: -//鼠标位置 - enum PosInItem {LEFT,MIDDLE,RIGHT,TOP,BOTTOM}; - //鼠标移动状态 - enum DragStatus {IsCreate =0,ChangeBegin =1,ChangeEnd =2,ChangeWhole =3,NONE =4}; - - int getDragStatus() const; - -protected: - void mousePressEvent(QMouseEvent *event) override; - void mouseReleaseEvent(QMouseEvent *event) override; - void mouseMoveEvent(QMouseEvent *event) override; - void wheelEvent(QWheelEvent *event) override; - void contextMenuEvent(QContextMenuEvent *event) override; - void dragEnterEvent(QDragEnterEvent *event) override; - void dragLeaveEvent(QDragLeaveEvent *event) override; - void dragMoveEvent(QDragMoveEvent *event) override; - void dropEvent(QDropEvent *event) override; - bool event(QEvent *e) override; - void keyPressEvent(QKeyEvent *event) override; -private: - void slotCreate(); - void setPressSelectInfo(const ScheduleDtailInfo &info); - void updateScheduleInfo(const ScheduleDtailInfo &info); - void DragPressEvent(const QPoint &pos,DragInfoItem *item); - void mouseReleaseScheduleUpdate(); -protected: - void DeleteItem(const ScheduleDtailInfo &info); -protected: - virtual void setDragPixmap(QDrag *drag,DragInfoItem *item); - virtual void slotCreate(const QDateTime &date); - //符合创建条件 - virtual bool MeetCreationConditions(const QDateTime &date) =0; - virtual void upDateInfoShow(const DragStatus &status = NONE,const ScheduleDtailInfo &info =ScheduleDtailInfo()) =0; - virtual QDateTime getPosDate(const QPoint &p) =0; - virtual void MoveInfoProcess(ScheduleDtailInfo &info,const QPointF &pos) = 0; - virtual PosInItem getPosInItem(const QPoint &p,const QRectF &itemRect) =0; - virtual ScheduleDtailInfo getScheduleInfo(const QDateTime &beginDate,const QDateTime &endDate); - virtual void ShowSchedule(DragInfoItem *infoitem); - //设置主题 - virtual void setTheMe(int type = 0) =0; - //判断时间是否相等 - virtual bool IsEqualtime(const QDateTime &timeFirst,const QDateTime &timeSecond) =0; - //根据鼠标移动的距离判断是否创建日程 - virtual bool JudgeIsCreate(const QPointF &pos) =0; - virtual void RightClickToCreate(QGraphicsItem *listItem,const QPoint &pos) =0; - // - virtual QDateTime getDragScheduleInfoBeginTime(const QDateTime &moveDateTime) =0; - // - virtual QDateTime getDragScheduleInfoEndTime(const QDateTime &moveDateTime) =0; -signals: - //更新获取日程信息 - void signalsUpdateShcedule(); - void signalViewtransparentFrame(const int id = 0); - void signalScheduleShow(const bool isShow, const ScheduleDtailInfo &out = ScheduleDtailInfo()); -protected: - int m_themetype = 0; - QGraphicsScene *m_Scene; - bool m_press = false; - - QAction *m_createAction; // 创建日程 - QAction *m_editAction; - QAction *m_deleteAction; - DMenu *m_rightMenu; - - QDateTime m_createDate; - DragStatus m_DragStatus =NONE; - bool m_isCreate; - QDateTime m_PressDate; - QDateTime m_MoveDate; - QPoint m_PressPos; - ScheduleDtailInfo m_DragScheduleInfo; - QDateTime m_InfoBeginTime; - QDateTime m_InfoEndTime; - QDrag *m_Drag; - //点击的原始info - ScheduleDtailInfo m_PressScheduleInfo; - QRectF m_PressRect; -}; - -#endif // DRAGINFOGRAPHICSVIEW_H diff -Nru dde-calendar-5.7.0.4/src/draginfoitem.cpp dde-calendar-5.7.0.23/src/draginfoitem.cpp --- dde-calendar-5.7.0.4/src/draginfoitem.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/draginfoitem.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,138 +0,0 @@ -/* -* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. -* -* Author: uniontech -* -* Maintainer: uniontech -* -* 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 -* 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 . -*/ -#include "draginfoitem.h" - -#include -#include -#include - -bool DragInfoItem::m_press = false; -ScheduleDtailInfo DragInfoItem::m_HoverInfo; -DragInfoItem::DragInfoItem(QRectF rect, QGraphicsItem *parent) - :QGraphicsRectItem(parent), - m_rect(rect) -{ - setRect(m_rect); - setAcceptHoverEvents(true); - - const int duration = 200; - m_properAnimationFirst = new QPropertyAnimation( this, "offset", this); - m_properAnimationFirst->setObjectName("First"); - m_properAnimationSecond = new QPropertyAnimation( this, "offset", this); - m_properAnimationSecond->setObjectName("Second"); - m_properAnimationFirst->setDuration(duration); - m_properAnimationSecond->setDuration(duration); - m_properAnimationFirst->setEasingCurve(QEasingCurve::InOutQuad); - m_properAnimationSecond->setEasingCurve(QEasingCurve::InOutQuad); - m_Group = new QSequentialAnimationGroup(this); - m_Group->addAnimation(m_properAnimationFirst); - m_Group->addAnimation(m_properAnimationSecond); - connect(m_Group - , &QPropertyAnimation::finished - , this - , &DragInfoItem::animationFinished); - - -} - -DragInfoItem::~DragInfoItem() -{ - -} - -void DragInfoItem::setData(const ScheduleDtailInfo &vScheduleInfo) -{ - m_vScheduleInfo = vScheduleInfo; -} - -ScheduleDtailInfo DragInfoItem::getData() const -{ - return m_vScheduleInfo; -} - -void DragInfoItem::setPressFlag(const bool flag) -{ - m_press = flag; -} - -void DragInfoItem::setFont(DFontSizeManager::SizeType type) -{ - m_sizeType = type; -} - -void DragInfoItem::setOffset(const int &offset) -{ - m_offset = offset; - setRect(QRectF(m_rect.x() - offset, - m_rect.y() - offset / 2, - m_rect.width() + offset * 2, - m_rect.height() + offset)); - setZValue(offset); -} - - -void DragInfoItem::setStartValue(const int value) -{ - m_properAnimationFirst->setStartValue(value); - m_properAnimationSecond->setEndValue(value); -} - -void DragInfoItem::setEndValue(const int value) -{ - m_properAnimationFirst->setEndValue(value); - m_properAnimationSecond->setStartValue(value); - -} - -void DragInfoItem::startAnimation() -{ - if (m_Group->state() != QAnimationGroup::Running) { - m_Group->start(); - } -} - -void DragInfoItem::animationFinished() -{ - m_isAnimation = false; -} - -void DragInfoItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - m_HoverInfo = m_vScheduleInfo; - update(); -} - -void DragInfoItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_UNUSED(event); - m_HoverInfo = ScheduleDtailInfo(); - update(); -} - - -void DragInfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - Q_UNUSED(option); - Q_UNUSED(widget); - m_vHoverflag = m_HoverInfo == m_vScheduleInfo; - paintBackground(painter,this->rect()); -} diff -Nru dde-calendar-5.7.0.4/src/draginfoitem.h dde-calendar-5.7.0.23/src/draginfoitem.h --- dde-calendar-5.7.0.4/src/draginfoitem.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/draginfoitem.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -/* -* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. -* -* Author: uniontech -* -* Maintainer: uniontech -* -* 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 -* 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 . -*/ -#ifndef DRAGINFOITEM_H -#define DRAGINFOITEM_H -#include -#include - -#include "scheduledatamanage.h" - -DWIDGET_USE_NAMESPACE - -class QPropertyAnimation; -class QSequentialAnimationGroup; - - -class DragInfoItem : public QObject, public QGraphicsRectItem -{ - Q_OBJECT - Q_PROPERTY(int offset READ readOffset WRITE setOffset) -public: - explicit DragInfoItem(QRectF rect, QGraphicsItem *parent = nullptr); - ~DragInfoItem() override; - void setData(const ScheduleDtailInfo &vScheduleInfo); - ScheduleDtailInfo getData() const; - - void setFont(DFontSizeManager::SizeType type); - void setOffset(const int &offset); - int readOffset() const - { - return m_offset; - } - void setStartValue(const int value); - void setEndValue(const int value); - void startAnimation(); - bool isRunning()const - { - return m_isAnimation; - } -public: - static void setPressFlag(const bool flag); -public slots: - void animationFinished(); -protected: - void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override; - void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override; - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override; -protected: - virtual void paintBackground(QPainter *painter,const QRectF &rect,const int isPixMap = false) =0; -protected: - ScheduleDtailInfo m_vScheduleInfo; - QFont m_font; - bool m_vSelectflag =false; - bool m_vHoverflag = false; - bool m_vHighflag = false; - QRectF m_rect; - bool m_isAnimation = false; - int m_offset = 0; - DFontSizeManager::SizeType m_sizeType = DFontSizeManager::T8; - QPropertyAnimation *m_properAnimationFirst; - QPropertyAnimation *m_properAnimationSecond; - QSequentialAnimationGroup *m_Group; - static bool m_press; - static ScheduleDtailInfo m_HoverInfo; -}; - -#endif // DRAGINFOITEM_H diff -Nru dde-calendar-5.7.0.4/src/exportedinterface.cpp dde-calendar-5.7.0.23/src/exportedinterface.cpp --- dde-calendar-5.7.0.4/src/exportedinterface.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/exportedinterface.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,193 +0,0 @@ -/* -* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. -* -* Author: uniontech -* -* Maintainer: uniontech -* -* 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 -* 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 . -*/ -#include "exportedinterface.h" -#include -#include -#include -#include -#include "scheduledatamanage.h" -#include "calendarmainwindow.h" -ExportedInterface::ExportedInterface(QObject *parent): Dtk::Core::DUtil::DExportedInterface(parent) -{ - m_object = parent; -} - -QVariant ExportedInterface::invoke(const QString &action, const QString ¶meters) const -{ - ScheduleDtailInfo info; - Exportpara para; - QString tstr = parameters; - if (!analysispara(tstr, info, para)) { - return QVariant(false); - } - if (action == "CREATE") { - qint64 tindex = CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->addSchedule(info); - if (tindex < 0) { - return QVariant(false); - } - } else if (action == "VIEW") { - dynamic_cast(m_object)->viewWindow(para.viewType, para.viewTime); - } else if (action == "QUERY") { - QString qstr; - bool flag = CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->queryScheduleInfo(para.ADTitleName, para.ADStartTime, para.ADEndTime, qstr); - Q_UNUSED(flag); - return QVariant(qstr); - } else if (action == "CANCEL") { - QVector out; - bool flag = CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->queryScheduleInfo(para.ADTitleName, para.ADStartTime, para.ADEndTime, out); - if (!flag) return QVariant(false); - - for (int j = 0; j < out.size(); j++) { - QVector scheduleInfolist = out.at(j).vData; - for (int m = 0; m < scheduleInfolist.count(); m++) { - ScheduleDtailInfo newschedule; - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->getScheduleInfoById(scheduleInfolist.at(m).id, newschedule); - newschedule.ignore.append(scheduleInfolist.at(m).beginDateTime); - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo(newschedule); - } - } - } - dynamic_cast(m_object)->UpdateJob(); - return QVariant(true); -} - -bool ExportedInterface::analysispara( QString ¶meters, ScheduleDtailInfo &info, Exportpara ¶) const -{ - QJsonParseError json_error; - QJsonDocument jsonDoc(QJsonDocument::fromJson(parameters.toLocal8Bit(), &json_error)); - - if (json_error.error != QJsonParseError::NoError) { - return false; - } - QJsonObject rootObj = jsonDoc.object(); - //因为是预先定义好的JSON数据格式,所以这里可以这样读取 - if (rootObj.contains("ID")) { - info.id = rootObj.value("ID").toInt(); - } - if (rootObj.contains("AllDay")) { - info.allday = rootObj.value("AllDay").toBool(); - } - if (rootObj.contains("Remind")) { - parsingScheduleRemind(rootObj.value("Remind").toString(), info); - } - if (rootObj.contains("Title")) { - info.titleName = rootObj.value("Title").toString(); - } - if (rootObj.contains("Description")) { - info.description = rootObj.value("Description").toString(); - } - if (rootObj.contains("Type")) { - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->GetType(rootObj.value("Type").toInt(), info.type); - } - if (rootObj.contains("Start")) { - info.beginDateTime = fromconvertData(rootObj.value("Start").toString()); - } - if (rootObj.contains("End")) { - info.endDateTime = fromconvertData(rootObj.value("End").toString()); - } - if (rootObj.contains("RecurID")) { - info.RecurID = rootObj.value("RecurID").toInt(); - } - if (rootObj.contains("RRule")) { - parsingScheduleRRule(rootObj.value("RRule").toString(), info); - } - if (rootObj.contains("Ignore")) { - QJsonArray subArray = rootObj.value("Ignore").toArray(); - for (int i = 0; i < subArray.size(); i++) { - QString subObj = subArray.at(i).toString(); - info.ignore.append(fromconvertData(subObj)); - } - } - if (rootObj.contains("ViewName")) { - // para.viewType = rootObj.value("ViewName").toString().toInt(); - para.viewType = rootObj.value("ViewName").toInt(); - } - if (rootObj.contains("ViewTime")) { - para.viewTime = QDateTime::fromString(rootObj.value("ViewTime").toString(), "yyyy-MM-ddThh:mm:ss"); - } - if (rootObj.contains("ADTitleName")) { - para.ADTitleName = rootObj.value("ADTitleName").toString(); - } - if (rootObj.contains("ADStartTime")) { - para.ADStartTime = QDateTime::fromString(rootObj.value("ADStartTime").toString(), "yyyy-MM-ddThh:mm:ss"); - } - if (rootObj.contains("ADEndTime")) { - para.ADEndTime = QDateTime::fromString(rootObj.value("ADEndTime").toString(), "yyyy-MM-ddThh:mm:ss"); - } - return true; -} -void ExportedInterface::parsingScheduleRemind(QString str, ScheduleDtailInfo &info) const -{ - if (str.isEmpty()) { - info.remind = false; - return; - } - info.remind = true; - if (info.allday) { - QStringList liststr = str.split(";", QString::SkipEmptyParts); - info.remindData.n = liststr.at(0).toInt(); - info.remindData.time = QTime::fromString(liststr.at(1), "hh:mm"); - } else { - info.remindData.n = str.toInt(); - } -} -void ExportedInterface::parsingScheduleRRule(QString str, ScheduleDtailInfo &info) const -{ - if (str.isEmpty()) { - info.rpeat = 0; - return; - } - QString rrulestrs = str; - QStringList rruleslist = rrulestrs.split(";", QString::SkipEmptyParts); - if (rruleslist.count() > 0) { - if (rruleslist.contains("FREQ=DAILY") && rruleslist.contains("BYDAY=MO,TU,WE,TH,FR")) info.rpeat = 2; - else if (rruleslist.contains("FREQ=DAILY") ) { - info.rpeat = 1; - } else if (rruleslist.contains("FREQ=WEEKLY") ) { - info.rpeat = 3; - } else if (rruleslist.contains("FREQ=MONTHLY") ) { - info.rpeat = 4; - } else if (rruleslist.contains("FREQ=YEARLY") ) { - info.rpeat = 5; - } - info.enddata.type = 0; - for (int i = 0; i < rruleslist.count(); i++) { - if (rruleslist.at(i).contains("COUNT=")) { - QStringList liststr = rruleslist.at(i).split("=", QString::SkipEmptyParts); - info.enddata.type = 1; - info.enddata.tcount = liststr.at(1).toInt() - 1; - } - - if (rruleslist.at(i).contains("UNTIL=")) { - QStringList liststr = rruleslist.at(i).split("=", QString::SkipEmptyParts); - info.enddata.type = 2; - info.enddata.date = QDateTime::fromString(liststr.at(1).left(liststr.at(1).count() - 1), "yyyyMMddThhmmss"); - //info.enddata.date = fromconvertData(liststr.at(1)); - info.enddata.date = info.enddata.date.addDays(1); - } - } - } -} -QDateTime ExportedInterface::fromconvertData(QString str) const -{ - QStringList liststr = str.split("+", QString::SkipEmptyParts); - return QDateTime::fromString(liststr.at(0), "yyyy-MM-ddThh:mm:ss"); -} diff -Nru dde-calendar-5.7.0.4/src/exportedinterface.h dde-calendar-5.7.0.23/src/exportedinterface.h --- dde-calendar-5.7.0.4/src/exportedinterface.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/exportedinterface.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -/* -* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. -* -* Author: uniontech -* -* Maintainer: uniontech -* -* 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 -* 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 . -*/ -#ifndef EXPORTEDINTERFACE_H -#define EXPORTEDINTERFACE_H - -#include -#include -#include "schedulestructs.h" -DCORE_USE_NAMESPACE -struct Exportpara { - int viewType; //视图名称:year,month,week,day对应年、月、周、日视图类型 - QDateTime viewTime; //表示需要查看视图上某个时间 - QString ADTitleName; - QDateTime ADStartTime; - QDateTime ADEndTime; -}; -class ExportedInterface : public Dtk::Core::DUtil::DExportedInterface -{ -public: - explicit ExportedInterface(QObject *parent = nullptr); - QVariant invoke(const QString &action, const QString ¶meters) const; -private: - bool analysispara( QString ¶meters, ScheduleDtailInfo &info, Exportpara ¶) const; - void parsingScheduleRRule(QString str, ScheduleDtailInfo &info) const; - void parsingScheduleRemind(QString str, ScheduleDtailInfo &info) const; - QDateTime fromconvertData(QString str) const; -private: - QObject *m_object; -}; - -#endif // EXPORTEDINTERFACE_H diff -Nru dde-calendar-5.7.0.4/src/graphicsview.cpp dde-calendar-5.7.0.23/src/graphicsview.cpp --- dde-calendar-5.7.0.4/src/graphicsview.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/graphicsview.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,861 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#include "graphicsview.h" -#include -#include -#include - -#include "scheduleitem.h" -#include "schedulecoormanage.h" -#include "schceduledlg.h" -#include "scheduledatamanage.h" -#include -#include -#include -#include -#include -#include -#include -#include - -#include "schcedulectrldlg.h" -#include "myschceduleview.h" -#include -#include -DGUI_USE_NAMESPACE -CGraphicsView::CGraphicsView(QWidget *parent, int viewType) - : DragInfoGraphicsView(parent), - m_viewType(viewType) -{ - m_coorManage = new CScheduleCoorManage; - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - m_dayInterval = width(); - m_timeInterval = height() / 24.0; - - m_Scene->setSceneRect(0, 0, width(), height()); - m_LRPen.setColor(QColor(255, 255, 255)); - m_LRPen.setStyle(Qt::SolidLine); - m_TBPen.setColor(QColor(255, 255, 255)); - m_TBPen.setStyle(Qt::SolidLine); - m_LRFlag = true; - m_TBFlag = true; - m_margins = QMargins(0, 0, 0, 0); - - setLineWidth(0); - m_timer = new QTimer(this); - connect(m_timer, SIGNAL(timeout()), this, SLOT(scrollBarValueChangedSlot())); - m_timer->start(60000); - setViewportUpdateMode(QGraphicsView::FullViewportUpdate); - - connect(this->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(scrollBarValueChangedSlot())); - connect(this->verticalScrollBar(), - &QScrollBar::sliderPressed, - this, - &CGraphicsView::slotScrollBar); -} - -CGraphicsView::~CGraphicsView() -{ - m_timer->stop(); - m_timer->deleteLater(); - clearSchdule(); - - delete m_coorManage; - m_coorManage = nullptr; -} - -void CGraphicsView::setMargins(int left, int top, int right, int bottom) -{ - Q_UNUSED(top) - m_margins = QMargins(left, 0, right, bottom); - setViewportMargins(m_margins); -} - -void CGraphicsView::setTheMe(int type) -{ - if (type == 0 || type == 1) { - m_weekcolor = "#00429A"; - m_weekcolor.setAlphaF(0.05); - QColor linecolor = "#000000"; - linecolor.setAlphaF(0.1); - m_LRPen.setColor(linecolor); - m_TBPen.setColor(linecolor); - m_LRPen.setStyle(Qt::SolidLine); - m_TBPen.setStyle(Qt::SolidLine); - - } else if (type == 2) { - m_weekcolor = "#4F9BFF"; - m_weekcolor.setAlphaF(0.1); - QColor linecolor = "#000000"; - linecolor.setAlphaF(0.1); - m_LRPen.setColor(linecolor); - m_TBPen.setColor(linecolor); - } - scene()->update(); - update(); -} - -void CGraphicsView::slotCreate(const QDateTime &date) -{ - emit signalViewtransparentFrame(1); - CSchceduleDlg dlg(1, this); - dlg.setDate(date); - if (dlg.exec() == DDialog::Accepted) { - emit signalsUpdateShcedule(); - } - emit signalViewtransparentFrame(0); -} - -bool CGraphicsView::MeetCreationConditions(const QDateTime &date) -{ - return qAbs(date.daysTo(m_PressDate)<7); -} - -void CGraphicsView::updateHigh() -{ - scene()->update(); - update(); -} - -void CGraphicsView::setRange( int w, int h, QDate begindate, QDate enddate, int rightmagin) -{ - m_MoveDate.setDate(begindate.addMonths(-2)); - m_beginDate = begindate; - m_endDate = enddate; - w = w - rightmagin -2; - m_Scene->setSceneRect(0, 0, w, h); - m_coorManage->setRange(w, h, begindate, enddate, rightmagin); - m_rightmagin = rightmagin; - qint64 totalDay = begindate.daysTo(enddate) + 1; - m_dayInterval = w * 1.0 / totalDay; - m_timeInterval = h / 24.0; - m_totalDay = totalDay; - if (m_viewType ==0) { - int viewWidth = viewport()->width(); - int viewHeight = viewport()->height(); - QPoint newCenter(viewWidth / 2, viewHeight / 2 - 2000); - - centerOnScene(mapToScene(newCenter)); - } -} - -void CGraphicsView::setRange(QDate begin, QDate end) -{ - m_MoveDate.setDate(begin.addMonths(-2)); - m_beginDate = begin; - m_endDate = end; - getCoorManage()->setDateRange(begin, end); -} - -void CGraphicsView::setInfo(const QVector &info) -{ - m_scheduleInfo = info; -} - -bool MScheduleTimeThan(const ScheduleDtailInfo &s1, const ScheduleDtailInfo &s2) -{ -// if (s1.beginDateTime.secsTo(s1.endDateTime) == s2.beginDateTime.secsTo(s2.endDateTime)) { -// return s1.beginDateTime < s2.beginDateTime; -// } else { -// return s1.beginDateTime.secsTo(s1.endDateTime) > s2.beginDateTime.secsTo(s2.endDateTime); -// } - if (s1.beginDateTime.date().daysTo(s1.endDateTime.date())== - s2.beginDateTime.date().daysTo(s2.endDateTime.date())) { - if (s1.beginDateTime == s2.beginDateTime) { - return s1.beginDateTime.secsTo(s1.endDateTime) > s2.beginDateTime.secsTo(s2.endDateTime); - } else { - return s1.beginDateTime < s2.beginDateTime; - } - } else { - return s1.beginDateTime.date().daysTo(s1.endDateTime.date())>s2.beginDateTime.date().daysTo(s2.endDateTime.date()); - } - -} - -void CGraphicsView::upDateInfoShow(const CGraphicsView::DragStatus &status, const ScheduleDtailInfo &info) -{ - clearSchdule(); - QVector vListData; - vListData = m_scheduleInfo; - switch (status) { - case NONE: - Q_UNUSED(info); - break; - case ChangeBegin: - case ChangeEnd: { - int index = vListData.indexOf(info); - if (index >=0) - vListData[index] = info; - } - break; - case ChangeWhole: - vListData.append(info); - break; - case IsCreate: - vListData.append(info); - break; - } - QMap > m_InfoMap; - QDate currentDate; - qint64 count = m_beginDate.daysTo(m_endDate); - qint64 beginoffset = 0, endoffset = 0; - QVector currentInfo; - for (int i = 0; i <= count; ++i) { - currentDate = m_beginDate.addDays(i); - currentInfo.clear(); - for (int j = 0; j 0 && - vListData.at(j).endDateTime.time() ==QTime(0,0,0)) { - continue; - } -// if (beginoffset>0) { -// currentInfo.begindate = QDateTime(currentDate,QTime(0,0,0)); -// } else { -// currentInfo.begindate = vListData.at(j).beginDateTime; -// } - -// if(endoffset>0){ -// currentInfo.enddate = QDateTime(currentDate,QTime(23,59,59)); -// } else { -// currentInfo.enddate = vListData.at(j).endDateTime; -// } - currentInfo.append(vListData.at(j)); - } - std::sort(currentInfo.begin(), currentInfo.end(), MScheduleTimeThan); -// qSort(currentInfo.begin(), currentInfo.end(), MScheduleTimeThan); - if (currentInfo.size()>0) { - m_InfoMap[currentDate] = currentInfo; - QList info; - scheduleClassificationType(currentInfo,info); - - for (int m = 0; m < info.count(); m++) { - int tnum = info.at(m).vData.count(); - if (m_viewType == 0) { - if (tnum > m_sMaxNum) { - tnum = m_sMaxNum; - for (int n = 0; n < tnum - 1; n++) { - addSchduleItem(info.at(m).vData.at(n), currentDate, n + 1, - tnum, 0, m_viewType, m_sMaxNum); - } - ScheduleDtailInfo tdetaliinfo = info.at(m).vData.at(tnum - 2); - tdetaliinfo.titleName = "..."; - tdetaliinfo.type.ID = 3; - addSchduleItem(tdetaliinfo, currentDate, tnum, tnum, 1, - m_viewType, m_sMaxNum); - } else { - for (int n = 0; n < tnum; n++) { - addSchduleItem(info.at(m).vData.at(n), currentDate, n + 1, - tnum, 0, m_viewType, m_sMaxNum); - } - } - - } else { - for (int n = 0; n < tnum; n++) { - addSchduleItem(info.at(m).vData.at(n), currentDate, n + 1, - tnum, 0, m_viewType, m_sMaxNum); - } - } - } - } - - } - -} - -QDateTime CGraphicsView::getPosDate(const QPoint &p) -{ - return TimeRounding(m_coorManage->getDate(mapToScene(p))); -} - -void CGraphicsView::ShowSchedule(DragInfoItem *infoitem) -{ - CScheduleItem *scheduleitem = dynamic_cast(infoitem); - if (scheduleitem->getType() == 1) - return; - DragInfoGraphicsView::ShowSchedule(infoitem); -} - -void CGraphicsView::MoveInfoProcess(ScheduleDtailInfo &info, const QPointF &pos) -{ - Q_UNUSED(pos); - if (!info.allday) { - qint64 offset = m_PressDate.secsTo(m_MoveDate); - info.beginDateTime = info.beginDateTime.addSecs(offset); - info.endDateTime = info.endDateTime.addSecs(offset); - } else { - info.allday = false; - info.remind = false; - info.beginDateTime = m_MoveDate; - info.endDateTime = m_MoveDate.addSecs(3600); - } - info.IsMoveInfo = true; - upDateInfoShow(ChangeWhole,info); -} - -void CGraphicsView::addSchduleItem( const ScheduleDtailInfo &info, QDate date, int index, int totalNum, int type, int viewtype, int maxnum) -{ - CScheduleItem *item = new CScheduleItem( - m_coorManage->getDrawRegion(date, info.beginDateTime, - info.endDateTime, index, totalNum, maxnum, - viewtype), nullptr, type); - m_Scene->addItem(item); - item->setData(info, date, totalNum); - m_vScheduleItem.append(item); - -} - -void CGraphicsView::deleteSchduleItem( CScheduleItem *item ) -{ - int id = item->getData().id; - for (int i = 0; i < m_vScheduleItem.size(); i++) { - if (m_vScheduleItem[i]->getData().id == id) { - m_vScheduleItem.remove(i); - m_Scene->removeItem(item); - delete m_vScheduleItem[i]; - m_vScheduleItem[i] = nullptr; - i--; - } - } -} - -void CGraphicsView::setSelectSchedule(const ScheduleDtailInfo &info) -{ - setTime(info.beginDateTime.time()); - for (int i = 0 ; i < m_vScheduleItem.size(); ++i) { - if (m_vScheduleItem.at(i)->getType() == 1) - continue; - if (m_vScheduleItem.at(i)->hasSelectSchedule(info)) { - m_vScheduleItem.at(i)->setStartValue(0); - m_vScheduleItem.at(i)->setEndValue(10); - m_vScheduleItem.at(i)->startAnimation(); - } - } -} - -void CGraphicsView::clearSchdule() -{ - for (int i = 0; i < m_vScheduleItem.size(); i++) { - m_Scene->removeItem(m_vScheduleItem.at(i)); - delete m_vScheduleItem[i]; - m_vScheduleItem[i] = nullptr; - } - m_vScheduleItem.clear(); - m_updateDflag = true; -} - -void CGraphicsView::scheduleClassificationType(QVector &scheduleInfolist, QList &info) -{ - QVector schedulelist = scheduleInfolist; - if (schedulelist.isEmpty()) - return; - - info.clear(); - std::sort(schedulelist.begin(), schedulelist.end(), MScheduleTimeThan); -// qSort(schedulelist.begin(), schedulelist.end(), MScheduleTimeThan); - QVector containIndex; - - - for (int k = 0; k < schedulelist.count(); k++) { - QDateTime endTime = schedulelist.at(k).endDateTime; - QDateTime begTime = schedulelist.at(k).beginDateTime; - if (begTime.date().daysTo(endTime.date())==0 && begTime.time().secsTo(endTime.time())= info.at(i).begindate && - schedulelist.at(k).beginDateTime <= info.at(i).enddate) || - (endTime >= info.at(i).begindate && - endTime <= info.at(i).enddate) ) { - containIndex.append(i); - } - } - if (containIndex.count()==0) { - ScheduleclassificationInfo firstschedule; - firstschedule.begindate = schedulelist.at(k).beginDateTime; - firstschedule.enddate = endTime; - firstschedule.vData.append(schedulelist.at(k)); - info.append(firstschedule); - } else { - ScheduleclassificationInfo &scheduleInfo = info[containIndex.at(0)]; - int index = 0; - for (int i = 1; i < containIndex.count(); ++i) { - index = containIndex.at(i); - if (info.at(index).begindate < scheduleInfo.begindate) - scheduleInfo.begindate = info.at(index).begindate; - if (info.at(index).enddate>scheduleInfo.enddate) - scheduleInfo.enddate = info.at(index).enddate; - scheduleInfo.vData.append(info.at(index).vData); - } - for (int i = containIndex.count() -1; i >0; --i) { - info.removeAt(containIndex.at(i)); - } - if (schedulelist.at(k).beginDateTime < scheduleInfo.begindate) - scheduleInfo.begindate = schedulelist.at(k).beginDateTime; - if (endTime>scheduleInfo.enddate) - scheduleInfo.enddate = endTime; - scheduleInfo.vData.append(schedulelist.at(k)); - } - } -} - - -void CGraphicsView::mouseDoubleClickEvent( QMouseEvent *event ) -{ - emit signalScheduleShow(false); - DGraphicsView::mouseDoubleClickEvent(event); - CScheduleItem *item = dynamic_cast(itemAt(event->pos())); - if (item == nullptr) { - QPointF senceposs = mapToScene(event->pos()); - emit signalViewtransparentFrame(1); - CSchceduleDlg dlg(1, this); - QDateTime tDatatime = m_coorManage->getDate(senceposs); - dlg.setDate(tDatatime); - if (dlg.exec() == DDialog::Accepted) { - emit signalsUpdateShcedule(); - } - emit signalViewtransparentFrame(0); - return; - } - if (item->getType() == 1) { - emit signalsCurrentScheduleDate(item->getdate()); - return; - } - emit signalViewtransparentFrame(1); - m_updateDflag = false; - CMySchceduleView dlg(item->getData(), this); -// dlg.setSchedules(item->getData()); - connect(&dlg, &CMySchceduleView::signalsEditorDelete, this, &CGraphicsView::slotDoubleEvent); - dlg.exec(); - emit signalViewtransparentFrame(0); - disconnect(&dlg, &CMySchceduleView::signalsEditorDelete, this, &CGraphicsView::slotDoubleEvent); - if (item == nullptr) { - return; - } -} - -void CGraphicsView::mousePressEvent(QMouseEvent *event) -{ - CScheduleItem *item = dynamic_cast(itemAt(event->pos())); - if (item !=nullptr &&item->getType() ==1) { - emit signalScheduleShow(false); - return; - } - DragInfoGraphicsView::mousePressEvent(event); -} - -void CGraphicsView::mouseMoveEvent(QMouseEvent *event) -{ - CScheduleItem *item = dynamic_cast(itemAt(event->pos())); - if (item !=nullptr &&item->getType() ==1) { - setCursor(Qt::ArrowCursor); - DGraphicsView::mouseMoveEvent(event); - return; - } - DragInfoGraphicsView::mouseMoveEvent(event); -} -void CGraphicsView::slotDoubleEvent(int type) -{ - Q_UNUSED(type); - m_updateDflag = true; - emit signalsUpdateShcedule(); -} - -void CGraphicsView::slotDeleteItem() -{ - if (CScheduleDataManage::getScheduleDataManage()->getPressSelectInfo().type.ID <0) { - return; - } - if (CScheduleDataManage::getScheduleDataManage()->getPressSelectInfo().type.ID !=4) { - DeleteItem(CScheduleDataManage::getScheduleDataManage()->getPressSelectInfo()); - } - CScheduleDataManage::getScheduleDataManage()->setPressSelectInfo(ScheduleDtailInfo()); -} - - -void CGraphicsView::slotScrollBar() -{ - emit signalScheduleShow(false); -} - -void CGraphicsView::slotUpdateScene() -{ - this->scene()->update(); -} - -#ifndef QT_NO_WHEELEVENT -/************************************************************************ -Function: wheelEvent() -Description: 鼠标滚轮事件 -Input: event 滚轮事件 -Output: 无 -Return: 无 -Others: 无 -************************************************************************/ -void CGraphicsView::wheelEvent( QWheelEvent *event ) -{ - emit signalScheduleShow(false); - int test = event -> delta(); - int viewWidth = viewport()->width(); - int viewHeight = viewport()->height(); - QPoint newCenter(viewWidth / 2, viewHeight / 2 - test); - QPointF centerpos = mapToScene(newCenter); - centerOnScene(centerpos); -} -#endif - - -/************************************************************************ -Function: resizeEvent() -Description: 窗口大小改变事件 -Input: event 窗口大小改变事件 -Output: 无 -Return: 无 -Others: 无 -************************************************************************/ -void CGraphicsView::resizeEvent( QResizeEvent *event ) -{ - scrollBarValueChangedSlot(); - QGraphicsView::resizeEvent(event); - viewport()->update(); - update(); -} -/************************************************************************ -Function: setLargeScale() -Description: 设置大刻度 -Input: vLRLarge 左右刻度,vTBLarge 上下刻度 -Output: 无 -Return: 无 -Others: 无 -************************************************************************/ -void CGraphicsView::setLargeScale(const QVector &vLRLarge, const QVector &vTBLarge) -{ - m_vLRLarge = vLRLarge; - m_vTBLarge = vTBLarge; - update(); -} - -/************************************************************************ -Function: paintEvent() -Description: 绘制事件 -Input: event 事件 -Output: 无 -Return: 无 -Others: 无 -************************************************************************/ -void CGraphicsView::paintEvent(QPaintEvent *event) -{ - QPainter t_painter(viewport()); - //t_painter.setCompositionMode(QPainter::CompositionMode_Difference ); //设置混合模式 - int t_width = viewport()->width() + 2; -// //绘制垂直线 -// if (m_TBFlag) { -// t_painter.save(); -// t_painter.setPen(m_TBPen); -// for (int i = 0; i < m_vTBLarge.size(); ++i) -// t_painter.drawLine(QPoint(m_vTBLarge[i] - 1, 0), QPoint(m_vTBLarge[i] - 1, t_height)); -// t_painter.restore(); -// if (m_totalDay == 7) { -// t_painter.save(); -// for (int i = 0; i != 7; ++i) { - -// int d = checkDay(i - m_firstWeekDay); - -//// t_painter.setBrush(QBrush(m_weekcolor)); -//// t_painter.setPen(Qt::NoPen); -//// if ( d == 7) { -//// t_painter.drawRect(QRect(0 + i * m_dayInterval, 0, m_dayInterval + 0, t_height)); -//// } -//// if (d == 6 ) { -//// t_painter.drawRect(QRect(0 + i * m_dayInterval, 0, m_dayInterval + 5, t_height)); -//// } -// } -// t_painter.restore(); -// } -// } - //绘制水平线 - if (m_LRFlag) { - if (m_cuttrnttimetype == 0) { - t_painter.save(); - t_painter.setPen(m_LRPen); - for (int i = 0; i < m_vLRLarge.size(); ++i) - t_painter.drawLine(QPoint(0, m_vLRLarge[i] - 1), QPoint(t_width, m_vLRLarge[i] - 1)); - t_painter.restore(); - } else { - t_painter.save(); - t_painter.setPen(m_LRPen); - for (int i = 0; i < m_vLRLarge.size() - 1; ++i) - t_painter.drawLine(QPoint(0, m_vLRLarge[i] - 1), QPoint(t_width, m_vLRLarge[i] - 1)); - t_painter.restore(); - if (m_viewType == 1 && m_coorManage->getBegindate() == QDate::currentDate()) { - t_painter.save(); - QPen pen = m_LRPen; - pen.setColor(m_currenttimecolor); - t_painter.setPen(pen); - int index = m_vLRLarge.count() - 1; - t_painter.drawLine(QPoint(0, m_vLRLarge[index] - 1), QPoint(t_width, m_vLRLarge[index] - 1)); - t_painter.restore(); - } - - } - } - QGraphicsView::paintEvent(event); -} - - - -void CGraphicsView::scrollBarValueChangedSlot() -{ - emit signalScheduleShow(false); - QMutexLocker locker(&m_Mutex); - int viewHeight = viewport()->height(); - //QPoint newCenter(viewWidth / 2, viewHeight / 2 ); - //QPointF centerpos = mapToScene(newCenter); - //setTransformationAnchor(QGraphicsView::AnchorUnderMouse); - //centerOn(centerpos.x(), centerpos.y()); - //setTransformationAnchor(QGraphicsView::AnchorViewCenter); - m_vLRLarge.clear(); - m_vTBLarge.clear(); - QPointF leftToprealPos = mapToScene(QPoint(0, 0)); - QPointF leftBttomrealPos = mapToScene(QPoint(0, viewHeight)); - - for (qreal i = m_dayInterval; i < scene()->width(); i = i + m_dayInterval) { - m_vTBLarge.append(qFloor(i)); - } - qreal beginpos = static_cast(qFloor(leftToprealPos.y() / m_timeInterval) * m_timeInterval); - if (beginpos < leftToprealPos.y()) { - beginpos = (beginpos / m_timeInterval + 1) * m_timeInterval ; - } - QVector vHours; - for (qreal i = beginpos; i < leftBttomrealPos.y(); i = i + m_timeInterval) { - QPoint point = mapFromScene(leftBttomrealPos.x(), i); - m_vLRLarge.append(point.y()); - vHours.append(qFloor(i / m_timeInterval + 0.5)); - } - qreal currentTime = static_cast(m_coorManage->getHeight(QTime::currentTime())); - if (currentTime > beginpos && currentTime < leftBttomrealPos.y()) { - //if (0) { - m_cuttrnttimetype = 1; - QPoint point = mapFromScene(leftBttomrealPos.x(), currentTime); - m_vLRLarge.append(point.y()); - vHours.append(qFloor(currentTime / m_timeInterval + 0.5)); - emit signalsPosHours(m_vLRLarge, vHours, m_cuttrnttimetype); - } else { - m_cuttrnttimetype = 0; - emit signalsPosHours(m_vLRLarge, vHours, m_cuttrnttimetype); - } - scene()->update(); - update(); -} - -int CGraphicsView::checkDay(int weekday) -{ - if (weekday <= 0) - return weekday += 7; - - if (weekday > 7) - return weekday -= 7; - - return weekday; -} - - -CGraphicsView::PosInItem CGraphicsView::getPosInItem(const QPoint &p, const QRectF &itemRect) -{ - QPointF scenePos = this->mapToScene(p); - QPointF itemPos = QPointF(scenePos.x()-itemRect.x(), - scenePos.y()-itemRect.y()); - qreal bottomy = itemRect.height()- itemPos.y(); - if (itemPos.y()<5) { - return TOP; - } - if (bottomy <5) { - return BOTTOM; - } - return MIDDLE; -} - -ScheduleDtailInfo CGraphicsView::getScheduleInfo(const QDateTime &beginDate, const QDateTime &endDate) -{ - ScheduleDtailInfo info; - if (beginDate.secsTo(endDate)>0) { - info.beginDateTime = beginDate; - if (beginDate.secsTo(endDate)<1800) { - info.endDateTime = beginDate.addSecs(1800); - } else { - info.endDateTime = endDate; - } - } else { - if (endDate.secsTo(beginDate)<1800) { - info.beginDateTime = beginDate.addSecs(-1800); - } else { - info.beginDateTime = endDate; - } - info.endDateTime = beginDate; - } - info.titleName = tr("New Event"); - info.allday = false; - info.remind = true; - info.id = 0; - info.remindData.n = 1; - info.remindData.time = QTime(9, 0); - info.RecurID = 0; - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->GetType( - 1, info.type); - info.rpeat = 0; - - return info; -} - -bool CGraphicsView::IsEqualtime(const QDateTime &timeFirst, const QDateTime &timeSecond) -{ - return !(qAbs(timeFirst.secsTo(timeSecond))>100); -// return timeFirst ==timeSecond; -} - -bool CGraphicsView::JudgeIsCreate(const QPointF &pos) -{ - return qAbs(pos.x()-m_PressPos.x())>20 || - qAbs(m_PressDate.secsTo(m_coorManage->getDate(mapToScene(pos.toPoint()))))>300; -} - -void CGraphicsView::RightClickToCreate(QGraphicsItem *listItem, const QPoint &pos) -{ - Q_UNUSED(listItem); - m_rightMenu->clear(); - m_rightMenu->addAction(m_createAction); - QPointF senceposs = mapToScene(pos); - m_createDate =m_coorManage->getDate(senceposs); - m_rightMenu->exec(QCursor::pos()); -} - -QDateTime CGraphicsView::getDragScheduleInfoBeginTime(const QDateTime &moveDateTime) -{ - return moveDateTime.secsTo(m_InfoEndTime)<1800? - m_InfoEndTime.addSecs(-1800): - moveDateTime; -} - -QDateTime CGraphicsView::getDragScheduleInfoEndTime(const QDateTime &moveDateTime) -{ - return m_InfoBeginTime.secsTo(moveDateTime)<1800 ? - m_InfoBeginTime.addSecs(1800): - moveDateTime; -} - -QDateTime CGraphicsView::TimeRounding(const QDateTime &time) -{ - int hours = time.time().hour(); - int minnutes = 0; - - minnutes = time.time().minute() / 15; - return QDateTime(time.date(),QTime(hours,minnutes*15,0)); -} - -void CGraphicsView::centerOnScene(const QPointF &pos) -{ - // view 根据鼠标下的点作为锚点来定位 scene - setTransformationAnchor(QGraphicsView::AnchorUnderMouse); - centerOn(pos); - // scene 在 view 的中心点作为锚点 - setTransformationAnchor(QGraphicsView::AnchorViewCenter); - scrollBarValueChangedSlot(); - setSceneHeightScale(pos); -} - -void CGraphicsView::setSceneHeightScale(const QPointF &pos) -{ - m_sceneHeightScale = pos.y()/this->scene()->height(); -} - -void CGraphicsView::keepCenterOnScene() -{ - QPointF pos; - pos.setX(this->viewport()->width()/2); - pos.setY(this->scene()->height()*m_sceneHeightScale); - centerOnScene(pos); -} - - -/************************************************************************ -Function: setLargeScaleInfo() -Description: 设置大刻度显示 -Input: LRFlag 水平刻度,TBFlag 垂直刻度 -Output: 无 -Return: 无 -Others: 无 -************************************************************************/ -void CGraphicsView::setLargeScaleFlag(const bool &LRFlag, const bool &TBFlag) -{ - m_LRFlag = LRFlag; - m_TBFlag = TBFlag; - scene()->update(); -} - -void CGraphicsView::getLargeScaleFlag(bool &LRFlag, bool &TBFlag) -{ - LRFlag = m_LRFlag; - TBFlag = m_TBFlag; -} - -void CGraphicsView::setLargeScalePen(const QPen &LRPen, const QPen &TBPen) -{ - m_LRPen = LRPen; - m_TBPen = TBPen; - update(); -} - -void CGraphicsView::setFirstWeekday(int weekday) -{ - m_firstWeekDay = weekday; -} - -void CGraphicsView::setTime(QTime time) -{ - int viewWidth = viewport()->width(); - int viewHeight = viewport()->height(); - - QPoint newCenter(viewWidth / 2, viewHeight / 2); - QPointF centerpos = mapToScene(newCenter); - centerpos = QPointF(centerpos.x(), static_cast(m_coorManage->getHeight(time))); - centerOnScene(centerpos); -} - -void CGraphicsView::updateInfo() -{ - switch (m_DragStatus) { - case IsCreate: - upDateInfoShow(IsCreate,m_DragScheduleInfo); - break; - default: - upDateInfoShow(); - break; - } -} diff -Nru dde-calendar-5.7.0.4/src/graphicsview.h dde-calendar-5.7.0.23/src/graphicsview.h --- dde-calendar-5.7.0.4/src/graphicsview.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/graphicsview.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,206 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#ifndef GRAPHICSVIEW_H -#define GRAPHICSVIEW_H - -#include -#include -#include -#include -#include -#include - -#include "schedulestructs.h" -#include "draginfographicsview.h" -DWIDGET_USE_NAMESPACE - -typedef struct _tagScheduleclassificationInfo { - QDateTime begindate; - QDateTime enddate; - QVector vData; - -} ScheduleclassificationInfo; - -class CScheduleCoorManage; -class CScheduleItem; -class CGraphicsView : public DragInfoGraphicsView -{ - Q_OBJECT -public: - CGraphicsView(QWidget *parent, int viewType = 0); - ~CGraphicsView() Q_DECL_OVERRIDE; - void setMargins(int left, int top, int right, int bottom); - QMargins getMargins() - { - return m_margins; - } - void updateHigh(); - void setRange(int w, int h, QDate begindate, QDate enddate, int rightmagin); - void setRange(QDate begin, QDate end); - - CScheduleCoorManage *getCoorManage() - { - return m_coorManage; - } - void setInfo(const QVector &info); - void addSchduleItem(const ScheduleDtailInfo &info, QDate date, int index, int totalNum, int type, int viewtype, int maxnum); - void deleteSchduleItem(CScheduleItem *item); - void setSelectSchedule(const ScheduleDtailInfo &info); - void clearSchdule(); - - void setMinTime(const int &minTime) - { - m_minTime = minTime; - } - void setMaxNum(const int maxnum) - { - m_sMaxNum = maxnum; - } - void keepCenterOnScene(); - - void scheduleClassificationType(QVector &scheduleInfolist, - QList &info); - void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mousePressEvent(QMouseEvent *event) override; - void mouseMoveEvent(QMouseEvent *event) override; - -#ifndef QT_NO_WHEELEVENT - void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE; -#endif - - /************************************************************************ - Function: resizeEvent() - Description: 窗口大小改变事件 - Input: event 窗口大小改变事件 - Output: 无 - Return: 无 - Others: 无 - ************************************************************************/ - void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; - - /************************************************************************ - Function: setLargeScale() - Description: 设置大刻度 - Input: vLRLarge 左右刻度,vTBLarge 上下刻度 - Output: 无 - Return: 无 - Others: 无 - ************************************************************************/ - void setLargeScale(const QVector &vLRLarge, const QVector &vTBLarge); - - /************************************************************************ - Function: setLargeScaleInfo() - Description: 设置大刻度显示 - Input: LRFlag 水平刻度,TBFlag 垂直刻度 - Output: 无 - Return: 无 - Others: 无 - ************************************************************************/ - void setLargeScaleFlag(const bool &LRFlag, const bool &TBFlag); - - /************************************************************************ - Function: getLargeScaleFlag() - Description: 获取大刻度显示 - Input: LRFlag 水平刻度,TBFlag 垂直刻度 - Output: 无 - Return: 无 - Others: 无 - ************************************************************************/ - void getLargeScaleFlag(bool &LRFlag, bool &TBFlag); - - /************************************************************************ - Function: setLargeScaleInfo() - Description: 设置大刻度画笔 - Input: LRPen 水平画笔,TBPen 垂直画笔 - Output: 无 - Return: 无 - Others: 无 - ************************************************************************/ - void setLargeScalePen(const QPen &LRPen, const QPen &TBPen); - void setFirstWeekday(int weekday); - void setTime(QTime time); - void updateInfo(); -protected: - void paintEvent( QPaintEvent *event ) Q_DECL_OVERRIDE; -public slots: - void scrollBarValueChangedSlot(); - void slotDoubleEvent(int type); - void slotDeleteItem(); - void slotScrollBar(); - void slotUpdateScene(); -signals: - void signalsPosHours(QVector vPos, QVector vHours, int cuttrnttimetype = 0); - void signalsCurrentScheduleDate(QDate date); - void signalSceneUpdate(); -private: - int checkDay(int weekday); - void TimeRound(QDateTime &dtime); - QDateTime TimeRounding(const QDateTime &time); - void centerOnScene(const QPointF &pos); - void setSceneHeightScale(const QPointF &pos); -public: - void setTheMe(int type = 0) override; -protected: - void slotCreate(const QDateTime &date) override; - bool MeetCreationConditions(const QDateTime &date) override; - void upDateInfoShow(const DragStatus &status = NONE,const ScheduleDtailInfo &info =ScheduleDtailInfo())override; - QDateTime getPosDate(const QPoint &p) override; - void ShowSchedule(DragInfoItem *infoitem) override; - void MoveInfoProcess(ScheduleDtailInfo &info,const QPointF &pos) override; - PosInItem getPosInItem(const QPoint &p,const QRectF &itemRect) override; - ScheduleDtailInfo getScheduleInfo(const QDateTime &beginDate,const QDateTime &endDate) override; - bool IsEqualtime(const QDateTime &timeFirst,const QDateTime &timeSecond) override; - bool JudgeIsCreate(const QPointF &pos) override; - void RightClickToCreate(QGraphicsItem *listItem,const QPoint &pos) override; - QDateTime getDragScheduleInfoBeginTime(const QDateTime &moveDateTime) override; - QDateTime getDragScheduleInfoEndTime(const QDateTime &moveDateTime) override; -private: - CScheduleCoorManage *m_coorManage; - QVector m_vScheduleItem; - QMargins m_margins; //四周空白 - bool m_LRFlag; //水平线 - QPen m_LRPen; //水平线画笔 - bool m_TBFlag; //垂直线 - QPen m_TBPen; //垂直线画笔 - QVector m_vLRLarge; //大刻度像素位置 - QVector m_vTBLarge; //大刻度像素位置 - qreal m_dayInterval; - qreal m_timeInterval; - int m_firstWeekDay; - qint64 m_totalDay; - qreal m_sceneHeightScale =0; - - QColor m_weekcolor = "#4F9BFF"; - QColor m_currenttimecolor = "#F74444"; - int m_cuttrnttimetype = 0; - QTimer *m_timer; - QMutex m_Mutex; - int m_viewType = 0; - bool m_updateDflag = false; - int m_rightmagin = 0; - - - QVector m_scheduleInfo; - QDate m_beginDate; - QDate m_endDate; - int m_minTime; //最小高度对应的最小时间 - int m_sMaxNum = 4; -}; - -#endif // GRAPHICSVIEW_H diff -Nru dde-calendar-5.7.0.4/src/main.cpp dde-calendar-5.7.0.23/src/main.cpp --- dde-calendar-5.7.0.4/src/main.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/main.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -18,19 +18,20 @@ */ #include "environments.h" +#include "calendarmainwindow.h" +#include "exportedinterface.h" +#include "configsettings.h" +#include "accessible/accessible.h" + +#include +#include +#include #include #include #include #include -#include -#include -#include -#include "calendarmainwindow.h" -//#include "monthwindow.h" -#include "yearwindow.h" -#include "exportedinterface.h" -#include "configsettings.h" + DWIDGET_USE_NAMESPACE DCORE_USE_NAMESPACE /**********************复制部分**************************/ @@ -89,6 +90,7 @@ { QFile file(":/resources/dde-calendar.qss"); bool result = file.open(QFile::ReadOnly); + if (result) { QString content(file.readAll()); file.close(); @@ -101,30 +103,33 @@ #include "schedulesdbus.h" int main(int argc, char *argv[]) { - //DApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); - DApplication::loadDXcbPlugin(); - DApplication a(argc, argv); + //适配deepin-turbo启动加速 + DApplication *app = nullptr; +#if(DTK_VERSION < DTK_VERSION_CHECK(5,4,0,0)) + app = new DApplication(argc,argv); +#else + app = DApplication::globalApplication(argc,argv); +#endif + QAccessible::installFactory(accessibleFactory); g_appPath = QDir::homePath() + QDir::separator() + "." + qApp->applicationName(); QDir t_appDir; t_appDir.mkpath(g_appPath); - a.setOrganizationName("deepin"); - a.setApplicationName("dde-calendar"); - a.loadTranslator(); - //QLocale::setDefault(QLocale(QLocale::C, QLocale::UnitedStates)); - a.setApplicationVersion(VERSION); - //QList localeFallback = QList() << QLocale::system(); + app->setOrganizationName("deepin"); + app->setApplicationName("dde-calendar"); + app->loadTranslator(); + app->setApplicationVersion(VERSION); // meta information that necessary to create the about dialog. - a.setProductName(QApplication::translate("CalendarWindow", "Calendar")); + app->setProductName(QApplication::translate("CalendarWindow", "Calendar")); QIcon t_icon = QIcon::fromTheme("dde-calendar"); - a.setProductIcon(t_icon); - a.setApplicationDescription(QApplication::translate("CalendarWindow", "Calendar is a tool to view dates, and also a smart daily planner to schedule all things in life. ")); - a.setApplicationAcknowledgementPage("https://www.deepin.org/acknowledgments/dde-calendar"); + app->setProductIcon(t_icon); + app->setApplicationDescription(QApplication::translate("CalendarWindow", "Calendar is a tool to view dates, and also a smart daily planner to schedule all things in life. ")); + app->setApplicationAcknowledgementPage("https://www.deepin.org/acknowledgments/dde-calendar"); + DGuiApplicationHelper::setSingleInstanceInterval(-1); - DGuiApplicationHelper::setSingelInstanceInterval(-1); if (!DGuiApplicationHelper::instance()->setSingleInstance( - a.applicationName(), + app->applicationName(), DGuiApplicationHelper::UserScope)) { qDebug() << "there's an dde-calendar instance running."; QProcess::execute("dbus-send --print-reply --dest=com.deepin.Calendar " @@ -132,11 +137,12 @@ return 0; } - a.setAutoActivateWindows(true); + app->setAutoActivateWindows(true); CConfigSettings::init(); // set theme bool isOk = false; int viewtype = CConfigSettings::value("base.view").toInt(&isOk); + if (!isOk) viewtype = 2; DLogManager::registerConsoleAppender(); @@ -153,14 +159,10 @@ QDBusConnection dbus = QDBusConnection::sessionBus(); dbus.registerService("com.deepin.Calendar"); dbus.registerObject("/com/deepin/Calendar", &ww); - //ww.setDate(QDate::currentDate()); ww.slotTheme(getThemeTypeSetting()); ww.viewWindow(viewtype, QDateTime::currentDateTime()); ww.show(); - //QDBusConnection dbus = QDBusConnection::sessionBus(); - //dbus.registerService("com.deepin.Calendar"); - //dbus.registerObject("/com/deepin/Calendar", &ww); //监听当前应用主题切换事件 QObject::connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::paletteTypeChanged, [] (DGuiApplicationHelper::ColorType type) { @@ -169,10 +171,5 @@ saveThemeTypeSetting(type); DGuiApplicationHelper::instance()->setPaletteType(type); }); -// if (dbus.registerService("com.deepin.Calendar"), QDBusConnectionInterface::ReplaceExistingService, QDBusConnectionInterface::AllowReplacement) { - - -// return a.exec(); -// } - return a.exec(); + return app->exec(); } diff -Nru dde-calendar-5.7.0.4/src/monthdayview.cpp dde-calendar-5.7.0.23/src/monthdayview.cpp --- dde-calendar-5.7.0.4/src/monthdayview.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/monthdayview.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,327 +0,0 @@ -/* - * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ - -#include "monthdayview.h" -#include -#include "constants.h" -#include -#include -#include -#include -#include -#include -#include -#include "scheduledatamanage.h" -DGUI_USE_NAMESPACE -CMonthDayView::CMonthDayView(QWidget *parent) : DFrame(parent) -{ - QHBoxLayout *hboxLayout = new QHBoxLayout; - hboxLayout->setMargin(0); - hboxLayout->setSpacing(0); - hboxLayout->setContentsMargins(10, 0, 10, 0); - m_monthWidget = new CMonthWidget(this); - hboxLayout->addWidget(m_monthWidget); - setLayout(hboxLayout); - setFrameRounded(true); - setLineWidth(0); - setWindowFlags(Qt::FramelessWindowHint); - - connect(m_monthWidget, - &CMonthWidget::signalsSelectDate, - this, - &CMonthDayView::signalsSelectDate); -} - -CMonthDayView::~CMonthDayView() -{ -} - -void CMonthDayView::setCurrentDate(const QDate date) -{ - m_selectDate = date; - m_days[5] = m_selectDate; - for (int i(4); i >= 0; i--) { - m_days[4 - i] = m_selectDate.addMonths(-i - 1); - } - for (int i(6); i != 12; ++i) { - m_days[i] = m_selectDate.addMonths(i - 5); - } - update(); - m_monthWidget->setDate(m_days); -} - -void CMonthDayView::setRCurrentDate(const QDate date) -{ - if (m_selectDate == date) return; - - m_selectDate = date; - m_days[5] = m_selectDate; - for (int i(4); i >= 0; i--) { - m_days[4 - i] = m_selectDate.addMonths(-i - 1); - } - for (int i(6); i != 12; ++i) { - m_days[i] = m_selectDate.addMonths(i - 5); - } - m_monthWidget->setDate(m_days); - update(); -} - -void CMonthDayView::setTheMe(int type) -{ - QColor frameclor; - if (type == 0 || type == 1) { - frameclor = "#FFFFFF"; - } else if (type == 2) { - frameclor = "#FFFFFF"; - frameclor.setAlphaF(0.05); - } - - DPalette anipa = palette(); - anipa.setColor(DPalette::Background, frameclor); - setPalette(anipa); - setBackgroundRole(DPalette::Background); - CMonthRect::setTheMe(type); -} - -void CMonthDayView::setwindowFixw(int w, int rw) -{ - m_fixwidth = w; - m_realwidth = rw; -} - -void CMonthDayView::setsearchfalg(bool flag) -{ - m_searchfalg = flag; -} - -CMonthWidget::CMonthWidget(QWidget *parent) - :QWidget(parent) -{ - for (int i = 0; i < 12; ++i) { - CMonthRect *monthrect = new CMonthRect(); - m_MonthItem.append(monthrect); - } -} - -CMonthWidget::~CMonthWidget() -{ - for (int i = 0; i < 12; ++i) { - CMonthRect *monthrect = m_MonthItem.at(i); - delete monthrect; - } - m_MonthItem.clear(); -} - -void CMonthWidget::setDate(const QDate date[12]) -{ - for (int i = 0 ; i <12; ++i) { - m_MonthItem.at(i)->setDate(date[i]); - } - CMonthRect::setSelectRect(m_MonthItem.at(5)); - update(); -} - -void CMonthWidget::resizeEvent(QResizeEvent *event) -{ - Q_UNUSED(event); - updateSize(); -} - -void CMonthWidget::mousePressEvent(QMouseEvent *event) -{ - if (event->button() ==Qt::RightButton) - return; - int itemindex = getMousePosItem(event->pos()); - if (!(itemindex<0)) { - if (m_MonthItem.at(itemindex)->getDate().year()<1900) { - return; - } - CMonthRect::setSelectRect(m_MonthItem.at(itemindex)); - emit signalsSelectDate(m_MonthItem.at(itemindex)->getDate()); - } - update(); -} - -void CMonthWidget::paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event); - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; - for (int i = 0; i < m_MonthItem.size(); ++i) { - m_MonthItem.at(i)->paintItem(&painter, - m_MonthItem.at(i)->rect()); - } - painter.end(); -} - -void CMonthWidget::updateSize() -{ - qreal w= this->width()/m_MonthItem.size(); - for (int i = 0; i < m_MonthItem.size(); ++i) { - m_MonthItem.at(i)->setRect(i*w,0,w,this->height()); - } - update(); -} - -int CMonthWidget::getMousePosItem(const QPointF &pos) -{ - int res =-1; - for (int i = 0 ; i < m_MonthItem.size(); ++i) { - if (m_MonthItem.at(i)->rect().contains(pos)) { - res = i; - break; - } - } - return res; -} - - -int CMonthRect::m_themetype ; -qreal CMonthRect::m_DevicePixelRatio; - -QColor CMonthRect::m_defaultTextColor; -QColor CMonthRect::m_backgrounddefaultColor ; -QColor CMonthRect::m_currentDayTextColor; -QColor CMonthRect::m_backgroundcurrentDayColor; -QColor CMonthRect::m_fillColor; -QFont CMonthRect::m_dayNumFont; -CMonthRect *CMonthRect::m_SelectRect = nullptr; - -CMonthRect::CMonthRect() -{ - m_dayNumFont.setPixelSize(16); - m_dayNumFont.setWeight(QFont::Light); -} - -void CMonthRect::setDate(const QDate &date) -{ - m_Date = date; -} - -QDate CMonthRect::getDate() const -{ - return m_Date; -} - -QRectF CMonthRect::rect() const -{ - return m_rect; -} - -void CMonthRect::setRect(const QRectF &rect) -{ - m_rect = rect; -} - -void CMonthRect::setRect(qreal x, qreal y, qreal w, qreal h) -{ - m_rect.setRect(x,y,w,h); -} - -void CMonthRect::paintItem(QPainter *painter, const QRectF &rect) -{ - m_selectColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); - if (m_Date.year()<1900) - return; - const bool isCurrentDay = (m_Date.month() == QDate::currentDate().month() - && m_Date.year() == QDate::currentDate().year()); - - - painter->setPen(Qt::SolidLine); - - const QString dayNum = QString::number(m_Date.month()); - -// const qreal r = rect.width() > rect.height() ? rect.height() * 0.9 : rect.width() * 0.9 ; -// const qreal x = rect.x()+(rect.width() - r) / 2; -// const qreal y = rect.y()+(rect.height() - r) / 2; -// QRectF fillRect = QRectF(x, y, r, r); - - if (m_SelectRect ==this) { - QRectF fillRect((rect.width() - 36) / 2 +rect.x() + 6, - (rect.height() - 36) / 2 + 7 +rect.y(), - 24, - 24); -// QPixmap pixmap; -// if (m_themetype == 2) -// pixmap = DHiDPIHelper::loadNxPixmap(":/resources/icon/darkchoose30X30_checked .svg"); -// else { -// pixmap = DHiDPIHelper::loadNxPixmap(":/resources/icon/choose30X30_checked .svg"); -// } -// pixmap.setDevicePixelRatio(m_DevicePixelRatio); -// painter->save(); -// painter->setRenderHint(QPainter::Antialiasing); -// painter->setRenderHint(QPainter::HighQualityAntialiasing); -// painter->setRenderHint(QPainter::SmoothPixmapTransform); -// painter->drawPixmap(fillRect.toRect(), pixmap); -// painter->restore(); - painter->setBrush(QBrush(m_selectColor)); - painter->setPen(Qt::NoPen); - painter->drawEllipse(fillRect); - painter->setRenderHint(QPainter::HighQualityAntialiasing); - painter->setPen(m_currentDayTextColor); - painter->setFont(m_dayNumFont); - painter->drawText(rect, Qt::AlignCenter, dayNum); - } else { - if (isCurrentDay) { - painter->setPen(m_backgroundcurrentDayColor); - } else { - painter->setPen(m_defaultTextColor); - } - painter->setFont(m_dayNumFont); - painter->drawText(rect, Qt::AlignCenter, dayNum); - } - -} - -void CMonthRect::setDevicePixelRatio(const qreal pixel) -{ - m_DevicePixelRatio = pixel; -} - -void CMonthRect::setTheMe(int type) -{ - m_themetype = type; - QColor frameclor; - if (type == 0 || type == 1) { - m_defaultTextColor = Qt::black; - m_backgrounddefaultColor = Qt::white; - m_currentDayTextColor = Qt::white; -// m_backgroundcurrentDayColor = "#0081FF"; - m_backgroundcurrentDayColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); - m_fillColor = "#FFFFFF"; - frameclor = m_fillColor; - m_fillColor.setAlphaF(0); - } else if (type == 2) { - m_defaultTextColor = "#C0C6D4"; - QColor framecolor = Qt::black; - framecolor.setAlphaF(0.5); - m_backgrounddefaultColor = framecolor; - m_currentDayTextColor = "#C0C6D4"; - m_backgroundcurrentDayColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); - m_fillColor = "#FFFFFF"; - m_fillColor.setAlphaF(0.05); - frameclor = m_fillColor; - m_fillColor.setAlphaF(0); - } -} - -void CMonthRect::setSelectRect(CMonthRect *selectRect) -{ - m_SelectRect =selectRect; -} diff -Nru dde-calendar-5.7.0.4/src/monthdayview.h dde-calendar-5.7.0.23/src/monthdayview.h --- dde-calendar-5.7.0.4/src/monthdayview.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/monthdayview.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#ifndef MONTHDAYVIEW_H -#define MONTHDAYVIEW_H - -#include -#include -#include - -DWIDGET_USE_NAMESPACE - -class CMonthWidget; -class CMonthDayView : public DFrame -{ - Q_OBJECT -public: - explicit CMonthDayView(QWidget *parent = nullptr); - ~CMonthDayView(); - void setCurrentDate(const QDate date); - void setRCurrentDate(const QDate date); - void setTheMe(int type = 0); - void setwindowFixw(int w, int rw); - void setsearchfalg(bool flag); -signals: - void signalsSelectDate(QDate date); - void signalsCurrentDate(QDate date); -private: - CMonthWidget *m_monthWidget; - QDate m_selectDate; - QDate m_days[12]; - - int m_fixwidth = 200; - int m_realwidth = 100; - bool m_searchfalg = false; - int m_radius = 8; -}; - -class CMonthRect; -class CMonthWidget : public QWidget -{ - Q_OBJECT -public: - CMonthWidget(QWidget *parent = nullptr); - ~CMonthWidget() override; - void setDate(const QDate date[12]); -protected: - void resizeEvent(QResizeEvent *event) override; - void mousePressEvent(QMouseEvent *event) override; - void paintEvent(QPaintEvent *event) override; -private: - void updateSize(); - int getMousePosItem(const QPointF &pos); -signals: - void signalsSelectDate(QDate date); -private: - QVector m_MonthItem; - QDate m_days[12]; - -}; - -class CMonthRect -{ -public: - CMonthRect(); - void setDate(const QDate &date); - QDate getDate()const; - QRectF rect() const; - void setRect(const QRectF &rect); - inline void setRect(qreal x, qreal y, qreal w, qreal h); - void paintItem(QPainter *painter, const QRectF &rect); - void setDevicePixelRatio(const qreal pixel); - static void setTheMe(int type); - static void setSelectRect(CMonthRect *selectRect); -private: - QRectF m_rect; - QDate m_Date; - static int m_themetype ; - static qreal m_DevicePixelRatio; - - static QColor m_defaultTextColor; - static QColor m_backgrounddefaultColor; - static QColor m_currentDayTextColor; - static QColor m_backgroundcurrentDayColor; - static QColor m_fillColor; - static QFont m_dayNumFont; - static CMonthRect *m_SelectRect; - QColor m_selectColor; -}; - -#endif // MONTDAYVIEW_H diff -Nru dde-calendar-5.7.0.4/src/monthgraphiview.cpp dde-calendar-5.7.0.23/src/monthgraphiview.cpp --- dde-calendar-5.7.0.4/src/monthgraphiview.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/monthgraphiview.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,810 +0,0 @@ -/* -* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. -* -* Author: uniontech -* -* Maintainer: uniontech -* -* 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 -* 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 . -*/ -#include "monthgraphiview.h" -#include -#include -#include -#include - -#include "monthschceduleview.h" -#include "schceduledlg.h" -#include "schcedulectrldlg.h" -#include "myschceduleview.h" - - -bool CDayGraphicsItem::m_LunarVisible = false; - -CMonthGraphiview::CMonthGraphiview(QWidget *parent) - : DragInfoGraphicsView (parent) -{ - QShortcut *shortcut = new QShortcut(parent); - shortcut->setKey(QKeySequence(QLatin1String("Delete"))); - connect(shortcut, - &QShortcut::activated, this, - &CMonthGraphiview::slotDeleteItem); - - m_MonthSchceduleView = new CMonthSchceduleView(this,m_Scene); - connect(this,&CMonthGraphiview::signalFontChange, - m_MonthSchceduleView,&CMonthSchceduleView::slotFontChange); - - for (int i = 0; i < 42; ++i) { - CDayGraphicsItem *item = new CDayGraphicsItem(); - item->setZValue(-1); - m_DayItem.append(item); - m_Scene->addItem(item); - } - updateSize(); -} - -CMonthGraphiview::~CMonthGraphiview() -{ - delete m_MonthSchceduleView; - for (int i = 0; i < m_DayItem.size(); ++i) { - CDayGraphicsItem *item = m_DayItem.at(i); - delete item; - item = nullptr; - } - m_DayItem.clear(); -} - -void CMonthGraphiview::setTheMe(int type) -{ - m_themetype = type; - for (int i = 0; i < m_DayItem.size(); ++i) { - m_DayItem.at(i)->setTheMe(type); - } - m_MonthSchceduleView->setTheMe(type); -} - -void CMonthGraphiview::setDate(const QDate date[42]) -{ - if (date[0].day() !=1) { - m_currentMonth = date[0].addMonths(1).month(); - } else { - m_currentMonth = date[0].month(); - } - for (int i = 0; i < m_DayItem.size(); ++i) { - m_DayItem.at(i)->setData(date[i]); - m_DayItem.at(i)->setCurrentMonth(date[i].month() == m_currentMonth); - m_DayItem.at(i)->setStatus(CDayGraphicsItem::HolidayStatus(getFestivalInfoByDate(date[i]))); - } - this->scene()->update(); -} - -void CMonthGraphiview::setLunarInfo(QMap *lunarCache) -{ - m_lunarCache = lunarCache; - updateLunar(); - -} - -void CMonthGraphiview::setLunarVisible(bool visible) -{ - CDayGraphicsItem::m_LunarVisible = visible; -} - -void CMonthGraphiview::setScheduleInfo(const QVector &info) -{ -// qDebug()< mscheduleShowBtn = m_MonthSchceduleView->getScheduleShowItem(); - for (int i = 0; i < mscheduleShowBtn.size(); ++i) { - CMonthSchceduleWidgetItem *item = dynamic_cast(mscheduleShowBtn.at(i)); - if (item == nullptr) continue; - if (scheduleInfo == item->getData()) { - item->setStartValue(0); - item->setEndValue(4); - item->startAnimation(); - } - } -} - -void CMonthGraphiview::updateSize() -{ - m_Scene->setSceneRect(this->viewport()->rect()); - qreal w = m_Scene->width()/7; - qreal h = m_Scene->height()/6; - QRectF rect ; - int w_offset = 0; - int h_offset = 0; - for (int i = 0 ; i < m_DayItem.size(); ++i) { - h_offset = i / 7; - w_offset = i % 7; - rect.setRect(w*w_offset, - h*h_offset, - w, - h); - m_DayItem.at(i)->setRect(rect); - } -} - -void CMonthGraphiview::updateLunar() -{ - QDate date; - CaLunarDayInfo info; - QString lunarStr(""); - for (int i = 0 ; i < m_DayItem.size(); ++i) { - date = m_DayItem.at(i)->getDate(); - if (m_lunarCache->contains(date)) { - info = m_lunarCache->value(date); - if (info.mLunarDayName == "初一") { - info.mLunarDayName = info.mLunarMonthName + info.mLunarDayName; - } - if (info.mTerm.isEmpty()) { - lunarStr = info.mLunarDayName; - } else { - lunarStr = info.mTerm; - } - } else { - lunarStr = ""; - } - m_DayItem.at(i)->setLunar(lunarStr); - } -} - -void CMonthGraphiview::updateInfo() -{ - int h = m_MonthSchceduleView->getSchceduleHeight(); - m_MonthSchceduleView->setallsize(this->viewport()->width(), - this->viewport()->height(), - 0, 0, 0, h); - m_MonthSchceduleView->setData(m_shceludelistdata, 1); - switch (m_DragStatus) { - case IsCreate: - upDateInfoShow(IsCreate,m_DragScheduleInfo); - break; - case ChangeWhole: - upDateInfoShow(ChangeWhole,m_DragScheduleInfo); - break; - default: - - break; - } - update(); -} - -char CMonthGraphiview::getFestivalInfoByDate(const QDate &date) -{ - for (int i = 0; i < m_festivallist.count(); i++) { - for (int j = 0; j < m_festivallist[i].listHoliday.count(); j++) { - - if (m_festivallist[i].listHoliday[j].date == date) { - return m_festivallist[i].listHoliday[j].status; - } - } - } - return 0; -} - -QPointF CMonthGraphiview::getItemPos(const QPoint &p, const QRectF &itemRect) -{ - QPointF scenePos = this->mapToScene(p); - return QPointF(scenePos.x()-itemRect.x(), - scenePos.y()-itemRect.y()); - -} - - - -CMonthGraphiview::PosInItem CMonthGraphiview::getPosInItem(const QPoint &p, const QRectF &itemRect) -{ - QPointF scenePos = this->mapToScene(p); - QPointF itemPos = QPointF(scenePos.x()-itemRect.x(), - scenePos.y()-itemRect.y()); - qreal bottomy = itemRect.width()- itemPos.x(); - - if (itemPos.x()<5) { - return LEFT; - } - if (bottomy <5) { - return RIGHT; - } - return MIDDLE; -} - -QDateTime CMonthGraphiview::getPosDate(const QPoint &p) -{ - if (!this->sceneRect().contains(p)) - return m_MoveDate; - QRectF rect = this->sceneRect(); - qreal x =0; - qreal y = 0; - if (p.x()<0) { - x =0; - } else if (p.x()>(rect.width()-10)) { - x = rect.width()-10; - } else { - x = p.x(); - } - if (p.y()<0) { - y =0; - } else if (p.y()>(rect.height()-10)) { - y = rect.height()-10; - } else { - y = p.y(); - } - int xoffset = qFloor(x/(rect.width()/7))%7; - int yoffset = qFloor(y/(rect.height()/6))%6; - return QDateTime(m_DayItem[xoffset+yoffset*7]->getDate(), - QTime(0,0,0)); -} - -void CMonthGraphiview::upDateInfoShow(const CMonthGraphiview::DragStatus &status, const ScheduleDtailInfo &info) -{ - switch (status) { - case NONE: - Q_UNUSED(info); - break; - case ChangeBegin: - case ChangeEnd: { - m_MonthSchceduleView->changeDate(info); - } - break; - case ChangeWhole: { -// int index = vListData.indexOf(info); -// vListData[index] = info; - } - break; - case IsCreate: - m_MonthSchceduleView->updateDate(info); - break; - } -} - -void CMonthGraphiview::updateScheduleInfo(const ScheduleDtailInfo &info) -{ - if (info.rpeat >0) { - CSchceduleDlg::ChangeRecurInfo(this,info, - m_PressScheduleInfo,m_themetype); - } else { - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo( - info); - } -} - -void CMonthGraphiview::DeleteItem(const ScheduleDtailInfo &info) -{ - emit signalViewtransparentFrame(1); - if (info.rpeat == 0) { - CSchceduleCtrlDlg msgBox(this); - msgBox.setText(tr("You are deleting an event.")); - msgBox.setInformativeText(tr("Are you sure you want to delete this event?")); - /* QAbstractButton *noButton = */msgBox.addPushButton(tr("Cancel"), true); - /*QAbstractButton *yesButton = */msgBox.addWaringButton(tr("Delete"), true); -// msgBox.updatesize(); -// DPalette pa = yesButton->palette(); -// if (m_themetype == 0 || m_themetype == 1) { -// pa.setColor(DPalette::ButtonText, Qt::red); -// } else { -// pa.setColor(DPalette::ButtonText, "#FF5736"); -// } -// yesButton->setPalette(pa); - msgBox.exec(); - - if (msgBox.clickButton() == 0) { - emit signalViewtransparentFrame(0); - return; - } else if (msgBox.clickButton() == 1) { - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->deleteScheduleInfoById(info.id); - } - } else { - if (info.RecurID == 0) { - CSchceduleCtrlDlg msgBox(this); - msgBox.setText(tr("You are deleting an event.")); - msgBox.setInformativeText(tr("Do you want to delete all occurrences of this event, or only the selected occurrence?")); - /*QAbstractButton *noButton = */msgBox.addPushButton(tr("Cancel")); - /*QAbstractButton *yesallbutton = */msgBox.addPushButton(tr("Delete All")); - /*QAbstractButton *yesButton = */msgBox.addsuggestButton(tr("Delete Only This Event")); -// msgBox.updatesize(); -// DPalette pa = yesButton->palette(); -// if (m_themetype == 0 || m_themetype == 1) { -// pa.setColor(DPalette::ButtonText, Qt::white); -// pa.setColor(DPalette::Dark, QColor("#25B7FF")); -// pa.setColor(DPalette::Light, QColor("#0098FF")); -// } else { -// pa.setColor(DPalette::ButtonText, "#B8D3FF"); -// pa.setColor(DPalette::Dark, QColor("#0056C1")); -// pa.setColor(DPalette::Light, QColor("#004C9C")); -// } -// yesButton->setPalette(pa); - msgBox.exec(); - - if (msgBox.clickButton() == 0) { - emit signalViewtransparentFrame(0); - return; - } else if (msgBox.clickButton() == 1) { - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->deleteScheduleInfoById(info.id); - } else if (msgBox.clickButton() == 2) { - - ScheduleDtailInfo newschedule; - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->getScheduleInfoById(info.id, newschedule); - newschedule.ignore.append(info.beginDateTime); - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo(newschedule); - } - } else { - CSchceduleCtrlDlg msgBox(this); - msgBox.setText(tr("You are deleting an event.")); - msgBox.setInformativeText(tr("Do you want to delete this and all future occurrences of this event, or only the selected occurrence?")); - /* QAbstractButton *noButton = */msgBox.addPushButton(tr("Cancel")); - /*QAbstractButton *yesallbutton = */msgBox.addPushButton(tr("Delete All Future Events")); - /* QAbstractButton *yesButton = */msgBox.addsuggestButton(tr("Delete Only This Event")); -// msgBox.updatesize(); -// DPalette pa = yesButton->palette(); -// if (m_themetype == 0 || m_themetype == 1) { -// pa.setColor(DPalette::ButtonText, Qt::white); -// pa.setColor(DPalette::Dark, QColor("#25B7FF")); -// pa.setColor(DPalette::Light, QColor("#0098FF")); -// } else { -// pa.setColor(DPalette::ButtonText, "#B8D3FF"); -// pa.setColor(DPalette::Dark, QColor("#0056C1")); -// pa.setColor(DPalette::Light, QColor("#004C9C")); -// } -// yesButton->setPalette(pa); - msgBox.exec(); - - if (msgBox.clickButton() == 0) { - emit signalViewtransparentFrame(0); - return; - } else if (msgBox.clickButton() == 1) { - ScheduleDtailInfo newschedule; - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->getScheduleInfoById(info.id, newschedule); - newschedule.enddata.type = 2; - newschedule.enddata.date = info.beginDateTime.addDays(-1); - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo(newschedule); - - } else if (msgBox.clickButton() == 2) { - ScheduleDtailInfo newschedule; - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->getScheduleInfoById(info.id, newschedule); - newschedule.ignore.append(info.beginDateTime); - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo(newschedule); - } - } - } - emit signalsUpdateShcedule(); - emit signalViewtransparentFrame(0); -} - -void CMonthGraphiview::setPressSelectInfo(const ScheduleDtailInfo &info) -{ - CScheduleDataManage::getScheduleDataManage()->setPressSelectInfo(info); -} - -void CMonthGraphiview::mouseDoubleClickEvent(QMouseEvent *event) -{ - if (event->button() != Qt::LeftButton) { - return; - } - QGraphicsItem *listItem =itemAt(event->pos()); - CMonthSchceduleNumButton *item = dynamic_cast(listItem); - if (item!= nullptr) { - //双击切换视图 - if (item->getDate().year()>1900) { - emit signalsViewSelectDate(item->getDate()); - } - return; - } - CMonthSchceduleWidgetItem *infoitem = dynamic_cast(listItem); - if (infoitem != nullptr) { - CMySchceduleView dlg(infoitem->getData(), this); - connect(&dlg, &CMySchceduleView::signalsEditorDelete, this, &CMonthGraphiview::signalsUpdateShcedule); -// connect(&dlg, &CMySchceduleView::signalsEditorDelete, this, &CMonthGraphiview::slotdelete); - connect(&dlg, &CMySchceduleView::signalViewtransparentFrame, - this, &CMonthGraphiview::signalViewtransparentFrame); - dlg.exec(); - return; - } - CDayGraphicsItem *Dayitem = dynamic_cast(listItem); - if (Dayitem !=nullptr) { - QPointF point = getItemPos(event->pos(),Dayitem->rect()); - if (point.y()<38) { - //双击切换视图 - if (Dayitem->getDate().year()>1900) { - emit signalsViewSelectDate(Dayitem->getDate()); - } - } else { - //双击新建日程 - slotCreate(QDateTime(Dayitem->getDate(),QTime(0,0,0))); - } - } - -} - - -void CMonthGraphiview::resizeEvent(QResizeEvent *event) -{ - Q_UNUSED(event); - updateSize(); - updateInfo(); -} -void CMonthGraphiview::changeEvent(QEvent *event) -{ - if (event->type() ==QEvent::FontChange) { - emit signalFontChange(); - } -} - -void CMonthGraphiview::wheelEvent(QWheelEvent *e) -{ - Q_UNUSED(e); -} - -void CMonthGraphiview::setDragPixmap(QDrag *drag, DragInfoItem *item) -{ - CMonthSchceduleWidgetItem *infoitem = dynamic_cast(item); - drag->setPixmap(infoitem->getPixmap()); -} - -bool CMonthGraphiview::MeetCreationConditions(const QDateTime &date) -{ - return qAbs(date.daysTo(m_PressDate)<43); -} - -bool CMonthGraphiview::IsEqualtime(const QDateTime &timeFirst, const QDateTime &timeSecond) -{ - return timeFirst.date()==timeSecond.date(); -} - -bool CMonthGraphiview::JudgeIsCreate(const QPointF &pos) -{ - return qAbs(pos.x()-m_PressPos.x())>20 ||qAbs(m_PressDate.daysTo(getPosDate(pos.toPoint())))>0; -} - -void CMonthGraphiview::RightClickToCreate(QGraphicsItem *listItem,const QPoint &pos) -{ - Q_UNUSED(pos); - CDayGraphicsItem *Dayitem = dynamic_cast(listItem); - if (Dayitem != nullptr) { - m_rightMenu->clear(); - m_rightMenu->addAction(m_createAction); - m_createDate.setDate(Dayitem->getDate()); - m_rightMenu->exec(QCursor::pos()); - } -} - -void CMonthGraphiview::MoveInfoProcess(ScheduleDtailInfo &info, const QPointF &pos) -{ - qint64 offset = m_PressDate.daysTo(m_MoveDate); - info.beginDateTime = info.beginDateTime.addDays(offset); - info.endDateTime = info.endDateTime.addDays(offset); - qreal y = 0; - QRectF rect = this->sceneRect(); - if (pos.y()<0) { - y =0; - } else if (pos.y()>rect.height()) { - y = rect.height(); - } else { - y = pos.y(); - } - int yoffset = qFloor(y/(rect.height()/6))%6; - info.IsMoveInfo = true; - m_MonthSchceduleView->updateDate(yoffset,info); -} - -QDateTime CMonthGraphiview::getDragScheduleInfoBeginTime(const QDateTime &moveDateTime) -{ - return moveDateTime.daysTo(m_InfoEndTime)<0 ? - QDateTime(m_InfoEndTime.date(),m_InfoBeginTime.time()): - QDateTime(moveDateTime.date(),m_InfoBeginTime.time()); -} - -QDateTime CMonthGraphiview::getDragScheduleInfoEndTime(const QDateTime &moveDateTime) -{ - return m_InfoBeginTime.daysTo(moveDateTime)<0 ? - QDateTime(m_InfoBeginTime.date(),m_InfoEndTime.time()): - QDateTime(moveDateTime.date(),m_InfoEndTime.time()); -} - -void CMonthGraphiview::slotCreate(const QDateTime &date) -{ - emit signalViewtransparentFrame(1); - CSchceduleDlg dlg(1, this); - QDateTime tDatatime; - tDatatime.setDate(date.date()); - if (date.date() == QDate::currentDate()) { - tDatatime.setTime(QTime::currentTime()); - } else { - tDatatime.setTime(QTime(8, 0)); - } - dlg.setDate(tDatatime); - dlg.setAllDay(true); - if (dlg.exec() == DDialog::Accepted) { - emit signalsUpdateShcedule(); - emit signalsSchceduleUpdate(0); - } - emit signalViewtransparentFrame(0); -} - - -void CMonthGraphiview::slotdelete(const int id) -{ - Q_UNUSED(id); - emit signalsSchceduleUpdate(0); -} - -void CMonthGraphiview::slotDeleteItem() -{ - if (CScheduleDataManage::getScheduleDataManage()->getPressSelectInfo().type.ID <0) { - return; - } - if (CScheduleDataManage::getScheduleDataManage()->getPressSelectInfo().type.ID !=4) { - DeleteItem(CScheduleDataManage::getScheduleDataManage()->getPressSelectInfo()); - } - CScheduleDataManage::getScheduleDataManage()->setPressSelectInfo(ScheduleDtailInfo()); -} - -CDayGraphicsItem::CDayGraphicsItem(QGraphicsItem *parent) - :QGraphicsRectItem(parent), - m_Date(QDate::currentDate()), - m_DayLunar(""), - m_DayStatus(H_NONE) -{ - m_dayNumFont.setPixelSize(24); - m_dayNumFont.setWeight(QFont::Light); - - m_LunerFont.setPixelSize(12); - m_LunerFont.setWeight(QFont::Normal); -} - -CDayGraphicsItem::~CDayGraphicsItem() -{ - -} - -void CDayGraphicsItem::setData(const QDate &date) -{ - m_Date = date; - setLunar(""); -} - -void CDayGraphicsItem::setLunar(const QString &lunar) -{ - m_DayLunar = lunar; -} - -void CDayGraphicsItem::setStatus(const CDayGraphicsItem::HolidayStatus &status) -{ - m_DayStatus = status; -} - -void CDayGraphicsItem::setTheMe(int type) -{ - m_themetype = type; - if (type == 0 || type == 1) { -// m_topBorderColor = Qt::red; -// m_backgroundCircleColor = "#0081FF"; -// m_backgroundShowColor = "#2CA7F8"; -// m_backgroundShowColor.setAlphaF(0.4); - -// m_defaultTextColor = Qt::black; -// m_currentDayTextColor = "#FFFFFF"; -// m_weekendsTextColor = Qt::black; -// m_selectedTextColor = Qt::white; -// m_festivalTextColor = Qt::black; -// m_notCurrentTextColor = "#b2b2b2"; - - -// m_defaultLunarColor = "#5E5E5E"; -// m_defaultLunarColor.setAlphaF(0.5); -// m_currentDayLunarColor = m_currentDayTextColor; -// m_weekendsLunarColor = m_defaultLunarColor; -// m_selectedLunarColor = Qt::white; -// m_festivalLunarColor = m_defaultLunarColor; -// m_notCurrentLunarColor = "#dfdfdf"; -// m_solofestivalLunarColor = "#FF7272"; -// m_solofestivalLunarColor.setAlphaF(0.3); -// m_wrectColor = "#000000"; -// m_wrectColor.setAlphaF(0.05); - - - m_dayNumColor = "#000000"; - m_dayNumCurrentColor = "#FFFFFF"; - - m_LunerColor = "#5E5E5E"; - m_LunerColor.setAlphaF(0.5); - - m_fillColor = Qt::white; - m_banColor = "#FF7171"; - m_banColor.setAlphaF(0.1); - m_xiuColor = "#ADFF71"; - m_xiuColor.setAlphaF(0.1); - - m_BorderColor = "#000000"; - m_BorderColor.setAlphaF(0.05); - - } else if (type == 2) { - -// m_topBorderColor = Qt::red; -// m_backgroundCircleColor = "#0059D2"; -// m_backgroundShowColor = "#002AAF"; -// m_backgroundShowColor.setAlphaF(0.4); - -// m_defaultTextColor = "#C0C6D4"; -// m_currentDayTextColor = "#C0C6D4"; -// m_weekendsTextColor = m_defaultTextColor; -// m_selectedTextColor = "#B8D3FF"; -// m_festivalTextColor = "#C0C6D4"; -// m_notCurrentTextColor = "#C0C6D4"; -// m_notCurrentTextColor.setAlphaF(0.6); - -// m_defaultLunarColor = "#ABDAFF"; -// m_defaultLunarColor.setAlphaF(0.5); -// m_currentDayLunarColor = m_currentDayTextColor; -// m_weekendsLunarColor = m_defaultLunarColor; -// m_selectedLunarColor = Qt::white; -// m_festivalLunarColor = m_defaultLunarColor; -// m_notCurrentLunarColor = "#ABDAFF"; -// m_notCurrentLunarColor.setAlphaF(0.3); -// m_solofestivalLunarColor = "#4DFF7272"; -// QColor wcolor = "#282828"; -// //wcolor.setAlphaF(0.5); -// m_wrectColor = wcolor; - - m_dayNumColor = "#C0C6D4"; - m_dayNumCurrentColor = "#B8D3FF"; - - m_LunerColor = "#ABDAFF"; - m_LunerColor.setAlphaF(0.5); - - m_fillColor = "#000000"; - m_fillColor.setAlphaF(0.05); - m_banColor = "#FF7171"; - m_banColor.setAlphaF(0.1); - m_xiuColor = "#ADFF71"; - m_xiuColor.setAlphaF(0.1); - - m_BorderColor = "#000000"; - m_BorderColor.setAlphaF(0.05); - } - update(); -} - -void CDayGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - Q_UNUSED(option); - Q_UNUSED(widget); - const int hh = 36; - m_currentColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); - painter->setRenderHints(QPainter::Antialiasing); - //绘制背景 - if (m_LunarVisible) { - switch (m_DayStatus) { - case H_WORK: - painter->setBrush(QBrush(m_banColor)); - break; - case H_REST: - painter->setBrush(QBrush(m_xiuColor)); - break; - default: - painter->setBrush(QBrush(m_fillColor)); - break; - } - } else { - painter->setBrush(QBrush(m_fillColor)); - } - - if (!m_IsCurrentMonth) { - painter->setOpacity(0.4); - } - QPen pen; - pen.setWidth(1); - pen.setColor(m_BorderColor); - painter->setPen(pen); - painter->drawRect(this->rect()); - - painter->save(); - painter->restore(); - //绘制日期 - painter->setFont(m_dayNumFont); - QRectF fillRect; - if (m_LunarVisible) { - fillRect.setRect(this->rect().x()+3,this->rect().y()+4, hh, hh); - } else { - fillRect.setRect(this->rect().x(),this->rect().y()+4, this->rect().width(), hh); - } - if (m_Date ==QDate::currentDate()) { - QFont tfont = m_dayNumFont; - tfont.setPixelSize(20); - painter->setFont(tfont); - painter->setPen(m_dayNumCurrentColor); - -// QPixmap pixmap; -// if (m_themetype == 2) -// pixmap = DHiDPIHelper::loadNxPixmap(":/resources/icon/darkchoose30X30_checked .svg"); -// else { -// pixmap = DHiDPIHelper::loadNxPixmap(":/resources/icon/choose30X30_checked .svg"); -// } -// pixmap.setDevicePixelRatio(devicePixelRatioF()); - - painter->save(); - painter->setRenderHint(QPainter::Antialiasing); - painter->setBrush(QBrush(m_currentColor)); - painter->setPen(Qt::NoPen); - if (m_LunarVisible) - painter->drawEllipse(QRectF(this->rect().x() + 6, this->rect().y() + 4, hh - 8, hh - 8)); -// painter->drawPixmap(fillRect.toRect(),pixmap); - else -// painter->drawPixmap(QPointF((this->rect().width() - pixmap.width()) / 2 + this->rect().x(), this->rect().y()), pixmap); - painter->drawEllipse(QRectF((this->rect().width() - hh + 8) / 2 + this->rect().x(), this->rect().y() + 4, hh - 8, hh - 8)); - painter->restore(); - } else { - painter->setPen(m_dayNumColor); - } - fillRect.setY(fillRect.y()-10); - fillRect.setX(fillRect.x()-1); - painter->drawText(fillRect, - Qt::AlignCenter, - QString::number(m_Date.day())); - - painter->save(); - painter->restore(); - - //绘制农历 - if (m_LunarVisible) { - QFontMetrics metrics(m_LunerFont); - int Lunarwidth = metrics.width(m_DayLunar); - qreal filleRectX = this->rect().width()-12-3-(58 +Lunarwidth)/2; - QRectF fillRect(this->rect().x()+filleRectX, - this->rect().y()+9, - 12, - 12); - if (filleRectX>hh) { - painter->setRenderHint(QPainter::Antialiasing); - painter->setRenderHint(QPainter::HighQualityAntialiasing); - painter->setRenderHint(QPainter::SmoothPixmapTransform); - switch (m_DayStatus) { - case H_WORK: { - QPixmap pixmap = DHiDPIHelper::loadNxPixmap(":/resources/icon/ban.svg"); - painter->drawPixmap(fillRect.toRect(), pixmap); - } - - break; - case H_REST: { - QPixmap pixmap = DHiDPIHelper::loadNxPixmap(":/resources/icon/xiu.svg"); - painter->drawPixmap(fillRect.toRect(), pixmap); - } - break; - default: - break; - } - } - painter->setFont(m_LunerFont); - painter->setPen(m_LunerColor); - painter->drawText(QRectF(this->rect().x()+this->rect().width() - 58, - this->rect().y()+6, 58, 18), Qt::AlignCenter, m_DayLunar); - - } - -} diff -Nru dde-calendar-5.7.0.4/src/monthgraphiview.h dde-calendar-5.7.0.23/src/monthgraphiview.h --- dde-calendar-5.7.0.4/src/monthgraphiview.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/monthgraphiview.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,148 +0,0 @@ -/* -* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. -* -* Author: uniontech -* -* Maintainer: uniontech -* -* 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 -* 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 . -*/ -#ifndef MONTHGRAPHIVIEW_H -#define MONTHGRAPHIVIEW_H - -#include -#include -#include -#include -#include -#include - -#include -#include "calendardbus.h" -#include "schedulestructs.h" -#include "draginfographicsview.h" - - - -DWIDGET_USE_NAMESPACE - -class CDayGraphicsItem; -class CMonthSchceduleWidgetItem; -class CMonthSchceduleView; - -class CMonthGraphiview : public DragInfoGraphicsView -{ - Q_OBJECT -public: - explicit CMonthGraphiview(QWidget *parent = nullptr); - ~CMonthGraphiview() override; - void setTheMe(int type = 0) override; -public: - void setDate(const QDate date[42]); - void setFestivalInfo(const QVector &info) - { - m_festivallist = info; - } - void setLunarInfo(QMap *lunarCache); - void setLunarVisible(bool visible); - void setScheduleInfo(const QVector &info); - void setSelectSchedule(const ScheduleDtailInfo &scheduleInfo); -private: - void updateSize(); - void updateLunar(); - void updateInfo(); - char getFestivalInfoByDate(const QDate &date); - QPointF getItemPos(const QPoint &p, const QRectF &itemRect); - void updateScheduleInfo(const ScheduleDtailInfo &info); - void DeleteItem(const ScheduleDtailInfo &info); - void setPressSelectInfo(const ScheduleDtailInfo &info); -protected: - void mouseDoubleClickEvent(QMouseEvent *event) override; - void resizeEvent(QResizeEvent *event) override; - void changeEvent(QEvent *event) override; - void wheelEvent(QWheelEvent *) override; -private: - void setDragPixmap(QDrag *drag,DragInfoItem *item) override; - bool MeetCreationConditions(const QDateTime &date) override; - //判断时间是否相等 - bool IsEqualtime(const QDateTime &timeFirst,const QDateTime &timeSecond) override; - //根据鼠标移动的距离判断是否创建日程 - bool JudgeIsCreate(const QPointF &pos) override; - void RightClickToCreate(QGraphicsItem *listItem,const QPoint &pos) override; - void MoveInfoProcess(ScheduleDtailInfo &info,const QPointF &pos) override; - QDateTime getDragScheduleInfoBeginTime(const QDateTime &moveDateTime) override; - QDateTime getDragScheduleInfoEndTime(const QDateTime &moveDateTime) override; - PosInItem getPosInItem(const QPoint &p,const QRectF &itemRect)override; - QDateTime getPosDate(const QPoint &p)override; - void upDateInfoShow(const DragStatus &status = NONE,const ScheduleDtailInfo &info =ScheduleDtailInfo())override; -signals: - void signalFontChange(); - void signalsViewSelectDate(QDate date); - void signalsSchceduleUpdate(const int id = 0); -public slots: - void slotCreate(const QDateTime &date) override; - void slotdelete(const int id =0); - void slotDeleteItem(); -private: - QVector m_DayItem; - QMap *m_lunarCache; - QVector m_festivallist; - int m_currentMonth; - CMonthSchceduleView *m_MonthSchceduleView; - QVector m_shceludelistdata; -}; - - -class CDayGraphicsItem :public QObject, public QGraphicsRectItem -{ - Q_OBJECT -public: - enum HolidayStatus {H_NONE = 0x00,H_REST = 0x01,H_WORK = 0x02}; - explicit CDayGraphicsItem( QGraphicsItem *parent = nullptr); - ~CDayGraphicsItem() Q_DECL_OVERRIDE; - void setData(const QDate &date); - void setLunar(const QString &lunar); - void setStatus(const HolidayStatus &status); - void setCurrentMonth(bool isCurrent) - { - m_IsCurrentMonth = isCurrent; - } - void setTheMe(int type = 0); - QDate getDate()const - { - return m_Date; - } -protected: - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override; -private: - QDate m_Date; - QString m_DayLunar; - HolidayStatus m_DayStatus; - QFont m_dayNumFont; - QColor m_dayNumColor; - QColor m_dayNumCurrentColor; - QFont m_LunerFont; - QColor m_LunerColor; - QColor m_BorderColor; - bool m_IsCurrentMonth = false; - QColor m_fillColor = Qt::white; - QColor m_banColor = "#FBE9B7"; - QColor m_xiuColor = "#D4FFB3"; - int m_themetype = 0; - QColor m_currentColor; -public: - static bool m_LunarVisible; -}; - -#endif // MONTHGRAPHIVIEW_H diff -Nru dde-calendar-5.7.0.4/src/monthschceduleview.cpp dde-calendar-5.7.0.23/src/monthschceduleview.cpp --- dde-calendar-5.7.0.4/src/monthschceduleview.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/monthschceduleview.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,779 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#include "monthschceduleview.h" -#include -#include -#include -#include -#include -#include -#include -#include "schceduledlg.h" -#include "myschceduleview.h" -#include -#include -#include -#include -#include "schcedulectrldlg.h" -#include -#include -#include -#include -#include "SchecduleRemindWidget.h" -#include "monthview.h" - -#include - -DGUI_USE_NAMESPACE -CMonthSchceduleWidgetItem::CMonthSchceduleWidgetItem(QRect rect, QGraphicsItem *parent /*= nullptr*/, int edittype) - : DragInfoItem(rect,parent), - m_pos(13,5) -{ - Q_UNUSED(edittype); -} - -CMonthSchceduleWidgetItem::~CMonthSchceduleWidgetItem() -{ - -} - - -QPixmap CMonthSchceduleWidgetItem::getPixmap() -{ - QPixmap pixmap(this->rect().size().toSize()); - pixmap.fill(Qt::transparent); - QPainter painter(&pixmap); - paintBackground(&painter,pixmap.rect(),true); - painter.end(); - return pixmap; -} - - - -void CMonthSchceduleWidgetItem::paintBackground(QPainter *painter, const QRectF &rect, const int isPixMap) -{ - qreal labelwidth = rect.width(); - qreal labelheight = rect.height(); - m_font = DFontSizeManager::instance()->get(m_sizeType, m_font); - int themetype = CScheduleDataManage::getScheduleDataManage()->getTheme(); - CSchedulesColor gdcolor = CScheduleDataManage::getScheduleDataManage()->getScheduleColorByType(m_vScheduleInfo.type.ID); - m_vHighflag = CScheduleDataManage::getScheduleDataManage()->getSearchResult(m_vScheduleInfo); - QLinearGradient linearGradient(rect.topLeft().x(), 0, rect.topRight().x(), 0); - QColor color1 = gdcolor.gradientFromC; - QColor color2 = gdcolor.gradientToC; - QColor textcolor = gdcolor.textColor; - - - - if (CScheduleDataManage::getScheduleDataManage()->getPressSelectInfo() == m_vScheduleInfo ) { - if (m_vScheduleInfo.IsMoveInfo == - CScheduleDataManage::getScheduleDataManage()->getPressSelectInfo().IsMoveInfo) { - m_vHighflag = true; - } else { - painter->setOpacity(0.4); - textcolor.setAlphaF(0.4); - } - m_vSelectflag = m_press; - } - if (isPixMap) { - painter->setOpacity(0.6); - textcolor.setAlphaF(0.8); - } - - if (m_vHoverflag) { - color1 = gdcolor.hovergradientFromC; - color2 = gdcolor.hovergradientToC; - } else if (m_vHighflag) { - color1 = gdcolor.hightlightgradientFromC; - color2 = gdcolor.hightlightgradientToC; - } - if (m_vSelectflag) { - color1 = gdcolor.pressgradientFromC; - color2 = gdcolor.pressgradientToC; - textcolor.setAlphaF(0.4); - } - - linearGradient.setColorAt(0, color1); - linearGradient.setColorAt(1, color2); - - QRectF fillRect = QRectF(rect.x()+2, - rect.y()+2, - labelwidth - 2, - labelheight - 2); - painter->save(); - //将直线开始点设为0,终点设为1,然后分段设置颜色 - painter->setBrush(linearGradient); - painter->setPen(Qt::NoPen); - painter->drawRoundedRect(fillRect, - rect.height() / 3, - rect.height() / 3); - painter->restore(); - painter->setFont(m_font); - painter->setPen(textcolor); - QFontMetrics fm = painter->fontMetrics(); - - QString tStitlename = m_vScheduleInfo.titleName; - tStitlename.replace("\n", ""); - QString str = tStitlename; - qreal textWidth = labelwidth - m_pos.x() - m_offset*2; - QString tstr; - for (int i = 0; i < str.count(); i++) { - tstr.append(str.at(i)); - int widthT = fm.width(tstr) + 5; - if (widthT >= textWidth) { - tstr.chop(2); - break; - } - } - if (tstr != str) { - tstr = tstr + "..."; - } - - painter->drawText(QRectF(rect.x()+m_pos.x(), - rect.y()+1, - textWidth, - labelheight - m_pos.y() + 3 ), - Qt::AlignLeft | Qt::AlignVCenter, tstr); - - if (m_vHoverflag && !m_vSelectflag) { - QRectF trect = QRectF(rect.x()+2.5, rect.y()+2.5, labelwidth - 3, labelheight - 3); - painter->save(); - painter->setRenderHints(QPainter::Antialiasing); - QPen pen; - QColor selcolor; - if (themetype == 2) { - selcolor = "#FFFFFF"; - } else { - selcolor = "#000000"; - } - - selcolor.setAlphaF(0.08); - - pen.setColor(selcolor); - pen.setWidthF(1); - pen.setStyle(Qt::SolidLine); - painter->setBrush(Qt::NoBrush); - painter->setPen(pen); - painter->drawRoundedRect(trect, rect.height() / 3, rect.height() / 3); - painter->restore(); - } - if (m_vSelectflag) { - QColor selcolor = "#000000"; - selcolor.setAlphaF(0.05); - painter->setBrush(selcolor); - painter->setPen(Qt::NoPen); - painter->drawRoundedRect(fillRect, rect.height() / 3, rect.height() / 3); - } -} - - -CMonthSchceduleNumButton::CMonthSchceduleNumButton(QGraphicsItem *parent /*= nullptr*/): QGraphicsRectItem (parent) -{ - -} - -CMonthSchceduleNumButton::~CMonthSchceduleNumButton() -{ - -} - -void CMonthSchceduleNumButton::setColor( QColor color1, QColor color2, bool GradientFlag /*= false*/ ) -{ - m_color1 = color1; - m_color2 = color2; - m_GradientFlag = GradientFlag; -} - -void CMonthSchceduleNumButton::setText( QColor tcolor, QFont font, QPoint pos) -{ - Q_UNUSED(pos); - m_textcolor = tcolor; - m_font = font; -// m_pos = pos; -} - -void CMonthSchceduleNumButton::setSizeType(DFontSizeManager::SizeType sizeType) -{ - m_SizeType = sizeType; -} - -void CMonthSchceduleNumButton::setTransparentB(bool t, QColor tcolor) -{ - m_transparentcolor = tcolor; - m_transparentf = t; -} - -void CMonthSchceduleNumButton::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - Q_UNUSED(option); - Q_UNUSED(widget); - qreal labelwidth = this->rect().width(); - qreal labelheight = this->rect().height() - 6; - qreal rectx = this->rect().x(); - qreal recty = this->rect().y(); - m_font = DFontSizeManager::instance()->get(m_SizeType, m_font); - if (m_GradientFlag) { - QLinearGradient linearGradient(0, 0, labelwidth, 0); - linearGradient.setColorAt(0, m_color1); - linearGradient.setColorAt(1, m_color2); - QRectF fillRect = QRectF(rectx+2, recty+1, labelwidth - 2, labelheight - 1); - //将直线开始点设为0,终点设为1,然后分段设置颜色 - painter->setRenderHints(QPainter::HighQualityAntialiasing); - painter->setBrush(linearGradient); - painter->setPen(Qt::NoPen); - painter->drawRoundedRect(fillRect, 3, 2); - - painter->setFont(m_font); - painter->setPen(m_textcolor); - - QString str = QString(tr("%1 more")).arg(m_num) + "..."; - QFont tfont = m_font; - QFontMetrics fm = painter->fontMetrics(); - - QString tstr; - for (int i = 0; i < str.count(); i++) { - tstr.append(str.at(i)); - int widthT = fm.width(tstr) + 5; - if (widthT >= labelwidth - m_pos.x()) { - tstr.chop(2); - break; - } - } - if (tstr != str) { - tstr = tstr + "..."; - } - painter->drawText(QRectF(rectx+m_pos.x(), recty+m_pos.y(), labelwidth - m_pos.x(), labelheight + 4), Qt::AlignCenter, tstr); - - } else { - QRectF fillRect = QRectF(rectx+2, recty+1, labelwidth - 2, labelheight - 1); - //将直线开始点设为0,终点设为1,然后分段设置颜色 - painter->setRenderHints(QPainter::HighQualityAntialiasing); - painter->setBrush(m_color1); - painter->setPen(Qt::NoPen); - painter->drawRoundedRect(fillRect, 3, 2); - - painter->setFont(m_font); - painter->setPen(m_textcolor); - painter->drawText(QRectF(rectx+m_pos.x(), - recty+m_pos.y(), - labelwidth - m_pos.x(), - labelheight + 4), - Qt::AlignLeft, - QString(tr("%1 more")).arg(m_num)); - } -} - -void CMonthSchceduleView::setTheMe(int type) -{ - Q_UNUSED(type); - updateData(); -} - -CMonthSchceduleView::CMonthSchceduleView(QWidget *parent,QGraphicsScene *scene) - : QObject (parent), - m_Scene(scene) -{ - for (int i = 0; i < 6; ++i) { - CWeekScheduleView *weekSchedule = new CWeekScheduleView(this); - m_weekSchedule.append(weekSchedule); - } - slotFontChange(); -} - -CMonthSchceduleView::~CMonthSchceduleView() -{ - -} - -void CMonthSchceduleView::setallsize(int w, int h, int left, int top, int buttom, int itemHeight) -{ - m_width = w; - m_height = h; - m_buttommagin = buttom; - m_leftMagin = left; - m_topMagin = top; - - m_cNum = static_cast(((m_height - m_topMagin - m_buttommagin) / 6.0 + 0.5 - 27) / (itemHeight + 1)); -} - -void CMonthSchceduleView::setData(QVector &data, int currentMonth) -{ - m_data = data; - m_currentMonth = currentMonth; - updateData(); -} - -void CMonthSchceduleView::slotdeleteitem( CMonthSchceduleWidgetItem *item) -{ - emit signalsUpdateShcedule(item->getData().id); -} - -void CMonthSchceduleView::slotedititem(CMonthSchceduleWidgetItem *item, int type) -{ - Q_UNUSED(type); - emit signalsUpdateShcedule(item->getData().id); -} - - -void CMonthSchceduleView::slotFontChange() -{ - QFont font; - DFontSizeManager::instance()->setFontGenericPixelSize( - static_cast(DFontSizeManager::instance()->fontPixelSize(qGuiApp->font()))); - font= DFontSizeManager::instance()->t8(font); - QFontMetrics fm(font); - int h = fm.height(); - if (m_ItemHeight != h) { - m_ItemHeight = h; - updateData(); - } -} - -bool MScheduleDateThan(const MScheduleDateRangeInfo &s1, const MScheduleDateRangeInfo &s2) -{ - if (s1.bdate != s1.edate && s2.bdate == s2.edate) { - return true; - } else if (s1.bdate == s1.edate && s2.bdate != s2.edate) { - return false; - } else if (s1.bdate != s1.edate && s2.bdate != s2.edate) { - if (s1.tData.beginDateTime == s2.tData.beginDateTime) { - return s1.bdate.daysTo(s1.edate) > s2.bdate.daysTo(s2.edate); - } else { - return s1.bdate < s2.bdate; - } - } else { - if (s1.tData.beginDateTime == s2.tData.beginDateTime) { - return s1.tData.titleName < s2.tData.titleName; - } else { - return s1.tData.beginDateTime < s2.tData.beginDateTime; - } - } -} -bool MScheduleDaysThan(const MScheduleDateRangeInfo &s1, const MScheduleDateRangeInfo &s2) -{ - return s1.bdate.daysTo(s1.edate) > s2.bdate.daysTo(s2.edate); -} -void CMonthSchceduleView::updateData() -{ - //保护数据防止越界 - if (m_data.count() != 42 || m_cNum < 1) return; - //开始结束时间 - QDate begindate = m_data.begin()->date; - QDate enddate = m_data[m_data.count() - 1].date; - m_beginDate = begindate; - m_endDate = enddate; - - for (int i = 0 ; i < m_weekSchedule.size(); ++i) { - m_weekSchedule[i]->clearItem(); - m_weekSchedule[i]->setHeight(m_ItemHeight,qRound((m_height - m_topMagin - m_buttommagin) / 6.0-27)); - m_weekSchedule[i]->setData(m_data,i*7,7); - QVector > mSchedule = m_weekSchedule[i]->getMScheduleInfo(); - updateDateShow(mSchedule,m_weekSchedule[i]->getScheduleShowItem()); - } - return; -} - -void CMonthSchceduleView::updateHigh() -{ - for (int j = 0 ; j < m_weekSchedule.size(); ++j) { - for (int i = 0; i < m_weekSchedule[j]->getScheduleShowItem().count(); i++) { - m_weekSchedule[j]->getScheduleShowItem().at(i)->update(); - } - } - -} - -QVector CMonthSchceduleView::getScheduleShowItem() const -{ - QVector m_scheduleShowItem; - for (int j = 0 ; j < m_weekSchedule.size(); ++j) { - for (int i = 0; i < m_weekSchedule[j]->getScheduleShowItem().count(); i++) { - m_scheduleShowItem.append(m_weekSchedule[j]->getScheduleShowItem().at(i)); - } - } - return m_scheduleShowItem; -} - -void CMonthSchceduleView::updateDate(const ScheduleDtailInfo &info) -{ - for (int i = 0 ; i < m_weekSchedule.size(); ++i) { - if (m_weekSchedule.at(i)->addData(info)) { - - } else { - m_weekSchedule[i]->clearItem(); - m_weekSchedule[i]->updateSchedule(true); - }; - QVector > mSchedule = m_weekSchedule[i]->getMScheduleInfo(); - updateDateShow(mSchedule,m_weekSchedule[i]->getScheduleShowItem()); - } -} - -void CMonthSchceduleView::changeDate(const ScheduleDtailInfo &info) -{ - for (int i = 0 ; i < m_weekSchedule.size(); ++i) { - m_weekSchedule.at(i)->changeDate(info); - QVector > mSchedule = m_weekSchedule[i]->getMScheduleInfo(); - updateDateShow(mSchedule,m_weekSchedule[i]->getScheduleShowItem()); - } -} - -void CMonthSchceduleView::updateDate(const int row, const ScheduleDtailInfo &info) -{ - for (int i = 0 ; i < m_weekSchedule.size(); ++i) { - if ( row ==i) { - m_weekSchedule.at(i)->addData(info); - } else { - m_weekSchedule[i]->clearItem(); - m_weekSchedule[i]->updateSchedule(true); - }; - QVector > mSchedule = m_weekSchedule[i]->getMScheduleInfo(); - updateDateShow(mSchedule,m_weekSchedule[i]->getScheduleShowItem()); - } -} -void CMonthSchceduleView::updateDateShow(QVector > &vCMDaySchedule, QVector &schudeleShowItem) -{ - for (int i = 0; i < vCMDaySchedule.count(); i++) { - for (int j = 0; j < vCMDaySchedule[i].count(); j++) { - if (vCMDaySchedule[i].at(j).state) { - createScheduleNumWidget(vCMDaySchedule[i].at(j), i + 1,schudeleShowItem); - } else { - createScheduleItemWidget(vCMDaySchedule[i].at(j), i + 1,schudeleShowItem); - } - } - } -} - -void CMonthSchceduleView::splitSchedule(MScheduleDateRangeInfo &old, QVector &newData) -{ - int brow = static_cast((m_beginDate.daysTo(old.bdate) + 1) / 7); - int erow = static_cast((m_beginDate.daysTo(old.edate) + 1) / 7); - int bcol = (m_beginDate.daysTo(old.bdate) + 1) % 7; - int ecol = (m_beginDate.daysTo(old.edate) + 1) % 7; - if (bcol != 0) brow = brow + 1; - if (ecol != 0) erow = erow + 1; - if (brow > erow) { - return; - } - if (brow == erow) { - newData.append(old); - } else { - bcol = bcol ? bcol : 7; - ecol = ecol ? ecol : 7; - //处理开始 - MScheduleDateRangeInfo bfirst = old; - bfirst.edate = bfirst.bdate.addDays(7 - bcol); - newData.append(bfirst); - //处理中间数据 - for (int i = brow + 1; i < erow; i++) { - MScheduleDateRangeInfo info = old; - info.bdate = m_beginDate.addDays((i - 1) * 7); - info.edate = m_beginDate.addDays((i - 1) * 7 + 6); - newData.append(info); - } - - //处理结束 - MScheduleDateRangeInfo second = old; - second.bdate = second.edate.addDays(-ecol + 1); - newData.append(second); - } -} - -void CMonthSchceduleView::createScheduleItemWidget(MScheduleDateRangeInfo info, int cnum,QVector &schudeleShowItem) -{ - ScheduleDtailInfo gd = info.tData; - QPoint pos; - int fw; - int fh; - computePos(cnum, info.bdate, info.edate, pos, fw, fh); - CMonthSchceduleWidgetItem *gwi = new CMonthSchceduleWidgetItem(QRect(pos.x(),pos.y(),fw,fh),nullptr); - m_Scene->addItem(gwi); - - QFont font; - - gwi->setData(gd); - - - QColor TransparentC = "#000000"; - TransparentC.setAlphaF(0.05); - schudeleShowItem.append(gwi); -} - -void CMonthSchceduleView::createScheduleNumWidget(MScheduleDateRangeInfo info, int cnum,QVector &schudeleShowItem) -{ - int type = CScheduleDataManage::getScheduleDataManage()->getTheme(); - CMonthSchceduleNumButton *gwi = new CMonthSchceduleNumButton(nullptr); - QPoint pos; - int fw; - int fh; - computePos(cnum, info.bdate, info.edate, pos, fw, fh); - QColor gradientFromC = "#000000"; - gradientFromC.setAlphaF(0.00); - gwi->setColor(gradientFromC, gradientFromC, true); - QFont font; - gwi->setSizeType(DFontSizeManager::T8); - if (type == 0 || type == 1) { - QColor tc("#5E5E5E"); - tc.setAlphaF(0.9); - gwi->setText(tc, font, QPoint(13, 3)); - } else { - QColor tc("#798190"); - tc.setAlphaF(1); - gwi->setText(tc, font, QPoint(13, 3)); - } - m_Scene->addItem(gwi); - gwi->setRect(pos.x(), - pos.y(), - fw, - fh); - gwi->setData(info.num); - gwi->setDate(info.bdate); - if (m_currentMonth != info.bdate.month() && m_currentMonth != info.edate.month()) { - QColor TransparentC = "#000000"; - TransparentC.setAlphaF(0.05); - gwi->setTransparentB(true, TransparentC); - } - connect(gwi, &CMonthSchceduleNumButton::signalsCurrentScheduleDate, this, &CMonthSchceduleView::signalsCurrentScheduleDate); - connect(gwi, &CMonthSchceduleNumButton::signalPressScheduleShow, this, &CMonthSchceduleView::signalPressScheduleShow); - - schudeleShowItem.append(gwi); -} - -void CMonthSchceduleView::computePos(int cnum, QDate bgeindate, QDate enddate, QPoint &pos, int &fw, int &fh) -{ - int brow = static_cast((m_beginDate.daysTo(bgeindate)) / 7); - int bcol = (m_beginDate.daysTo(bgeindate) ) % 7; - int ecol = (m_beginDate.daysTo(enddate) ) % 7; - - fw = static_cast((ecol - bcol + 1) * ((m_width - m_leftMagin ) / 7.0) - 11); - fh = m_ItemHeight; - int x =static_cast(m_leftMagin + bcol * ((m_width - m_leftMagin ) / 7.0) + 5); - int y = static_cast(m_topMagin + ((m_height - m_topMagin - m_buttommagin) * brow / 6.0 + 0.5) + 27 + (cnum - 1) * fh + 2.9); - pos = QPoint(x, y); -} - - - -CWeekScheduleView::CWeekScheduleView(QObject *parent) - :QObject (parent), - m_ScheduleHeight(22), - m_DayHeight(47) -{ - setMaxNum(); -} - -CWeekScheduleView::~CWeekScheduleView() -{ - -} - -void CWeekScheduleView::setData(QVector &data, const int position, const int count) -{ - int endPos = position+count; - Q_ASSERT(!(endPos>data.size())); - m_ScheduleInfo.clear(); - for (int i = position; i=0 &&beginDate.daysTo(info.endDateTime.date())>=0) { - clearItem(); - updateSchedule(false,info); - return true; - } - return false; -} - -void CWeekScheduleView::changeDate(const ScheduleDtailInfo &info) -{ - int index = m_ScheduleInfo.indexOf(info); - if (index <0) { - m_ScheduleInfo.append(info); - } else { - m_ScheduleInfo[index] = info; - } - clearItem(); - updateSchedule(true); -} - -void CWeekScheduleView::setHeight(const int ScheduleHeight, const int DayHeigth) -{ - m_ScheduleHeight = ScheduleHeight; - m_DayHeight = DayHeigth; - setMaxNum(); -} - -void CWeekScheduleView::updateSchedule(const bool isNormalDisplay, const ScheduleDtailInfo &info) -{ - QVector schedulev; - schedulev.clear(); - schedulev = m_ScheduleInfo; - if (isNormalDisplay) { - Q_UNUSED(info); - } else { - schedulev.append(info); - } - QDate tbegindate,tenddate; - QVector vMDaySchedule; - m_ColumnScheduleCount.clear(); - m_ColumnScheduleCount.fill(0,m_colum); - for (int i = 0 ; i < schedulev.size(); ++i) { - //日程时间重新标定 - tbegindate = schedulev.at(i).beginDateTime.date(); - tenddate = schedulev.at(i).endDateTime.date(); -// if (tbegindate.daysTo(tenddate)>0 && -// schedulev.at(i).endDateTime.time().hour()<1 && -// schedulev.at(i).endDateTime.time().second()<1) -// tenddate = tenddate.addDays(-1); - if (tenddateendDate) - continue; - if (tbegindate < beginDate) tbegindate = beginDate; - if (tenddate > endDate) tenddate = endDate; - //日程信息 - MScheduleDateRangeInfo info; - info.bdate = tbegindate; - info.edate = tenddate; - info.tData = schedulev.at(i); - info.state = false; - vMDaySchedule.append(info); - qint64 pos = beginDate.daysTo(info.bdate); - qint64 count = info.bdate.daysTo(info.edate); - int j = static_cast(pos); - for (; j < (pos+ count+1); ++j) { - ++m_ColumnScheduleCount[j]; - } - } - std::sort(vMDaySchedule.begin(),vMDaySchedule.end()); -// qSort(vMDaySchedule.begin(),vMDaySchedule.end()); - sortAndFilter(vMDaySchedule); -} - -void CWeekScheduleView::clearItem() -{ - for (int i = 0; i < m_scheduleShowItem.count(); i++) { - - delete m_scheduleShowItem[i]; - } - m_scheduleShowItem.clear(); -} - -void CWeekScheduleView::setMaxNum() -{ - m_MaxNum = m_DayHeight/(m_ScheduleHeight+1); -} - -void CWeekScheduleView::mScheduleClear() -{ - for (int i = 0; i < m_MScheduleInfo.size(); ++i) { - m_MScheduleInfo[i].clear(); - } - m_MScheduleInfo.clear(); -} - -void CWeekScheduleView::sortAndFilter(QVector &vMDaySchedule) -{ - QVector > scheduleFill; - QVector scheduf; - scheduf.fill(false,m_colum); - scheduleFill.fill(scheduf,m_MaxNum); - int postion = 0; - int end = 0; - mScheduleClear(); - - for (int i = 0 ; i < vMDaySchedule.size(); ++i) { - postion = static_cast(beginDate.daysTo(vMDaySchedule.at(i).bdate)); - end = static_cast(beginDate.daysTo(vMDaySchedule.at(i).edate)); - int row = 0; - int pos = postion; - int count = 0; - int scheduleRow = row; - for (; postionm_MaxNum) { - continue; - } - row =0; - pos = postion; - } - while (rowm_MaxNum) &&(row>=m_MaxNum-1)) { - scheduleFill[row][postion] = true; - if (pos !=postion) { - MScheduleDateRangeInfo scheduleInfo; - scheduleInfo.bdate = beginDate.addDays(pos); - scheduleInfo.edate = beginDate.addDays(postion -1); - scheduleInfo.state = false; - scheduleInfo.tData = vMDaySchedule.at(i).tData; - m_MScheduleInfo[row].append(scheduleInfo); - } - - MScheduleDateRangeInfo info; - info.bdate = beginDate.addDays(postion); - info.edate = info.bdate; - info.num = m_ColumnScheduleCount[postion] -m_MaxNum +1; - info.state = true; - m_MScheduleInfo[row].append(info); - - pos = postion +1; - if (pos<7 && pos 6||count==0) { - - } else { - MScheduleDateRangeInfo scheduleInfo; - scheduleInfo.bdate = beginDate.addDays(pos); - scheduleInfo.edate = beginDate.addDays(postion -1); - scheduleInfo.state = false; - scheduleInfo.tData = vMDaySchedule.at(i).tData; - m_MScheduleInfo[scheduleRow].append(scheduleInfo); - } - } -} diff -Nru dde-calendar-5.7.0.4/src/monthschceduleview.h dde-calendar-5.7.0.23/src/monthschceduleview.h --- dde-calendar-5.7.0.4/src/monthschceduleview.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/monthschceduleview.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,192 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#ifndef MONTHSCHCEDULEVIEW_H -#define MONTHSCHCEDULEVIEW_H - -#include -#include -#include -#include -#include -#include -#include - -#include "schedulestructs.h" -#include "scheduledatamanage.h" -#include "draginfoitem.h" - -DWIDGET_USE_NAMESPACE -class CMonthSchceduleWidgetItem; -class QVBoxLayout; -class CMonthSchceduleNumButton; -class SchecduleRemindWidget; -class QPropertyAnimation; -class QSequentialAnimationGroup; -class CWeekScheduleView; -class CMonthSchceduleView : public QObject -{ - Q_OBJECT - -public: - CMonthSchceduleView(QWidget *parent,QGraphicsScene *scene); - ~CMonthSchceduleView(); - void setallsize(int w, int h, int left, int top, int buttom, int itemHeight = 22); - void setData(QVector &data, int currentMonth); - void setTheMe(int type = 0); - void updateData(); - void updateHigh(); - QVector getScheduleShowItem() const; - int getSchceduleHeight() const - { - return m_ItemHeight; - } - void updateDate(const ScheduleDtailInfo &info); - void changeDate(const ScheduleDtailInfo &info); - void updateDate(const int row,const ScheduleDtailInfo &info); -signals: - void signalsUpdateShcedule(int id = 0); - void signalsCurrentScheduleDate(QDate date); - void signalViewtransparentFrame(int type); - void signalUpdateUI(int type); - void signalPressScheduleShow(const bool isShow, const ScheduleDtailInfo &out = ScheduleDtailInfo()); -public slots: - void slotdeleteitem(CMonthSchceduleWidgetItem *item); - void slotedititem(CMonthSchceduleWidgetItem *item, int type = 0); - void slotFontChange(); -private: - void updateDateShow(QVector > &vCMDaySchedule,QVector &schudeleShowItem); - void splitSchedule(MScheduleDateRangeInfo &old, QVector &newData); - void createScheduleItemWidget(MScheduleDateRangeInfo info, int cnum,QVector &schudeleShowItem); - void createScheduleNumWidget(MScheduleDateRangeInfo info, int cnum,QVector &schudeleShowItem); - void computePos(int cnum, QDate bgeindate, QDate enddate, QPoint &pos, int &fw, int &fh); -private: - QVector m_data; - int m_cNum = 2;//日程层数 - QWidget *m_parernt; - int m_currentMonth=0; - QDate m_beginDate; - QDate m_endDate; - int m_width =0; - int m_height=0; - int m_leftMagin=0; - int m_topMagin=0; - int m_buttommagin=0; - QVector m_weekSchedule; - int m_ItemHeight = 22; - QGraphicsScene *m_Scene; - -}; - -class CWeekScheduleView :public QObject -{ - Q_OBJECT - typedef QVector RowScheduleInfo; -public: - CWeekScheduleView(QObject *parent = nullptr); - ~CWeekScheduleView(); -public: - void setData(QVector &data,const int position,const int count =7); - bool addData(const ScheduleDtailInfo &info); - void changeDate(const ScheduleDtailInfo &info); - void setHeight(const int ScheduleHeight,const int DayHeigth); - QVector getMScheduleInfo() const - { - return m_MScheduleInfo; - } - QVector &getScheduleShowItem() - { - return m_scheduleShowItem; - } - void updateSchedule(const bool isNormalDisplay,const ScheduleDtailInfo &info = ScheduleDtailInfo()); - void clearItem(); -private: - void setMaxNum(); - void mScheduleClear(); - void sortAndFilter(QVector &vMDaySchedule); -private: - QVector m_scheduleShowItem; - QVector m_MScheduleInfo; - QVector m_ScheduleInfo; - QVector m_ColumnScheduleCount; - int m_ScheduleHeight=0; - int m_DayHeight=0; - int m_MaxNum=0; - QDate beginDate; - QDate endDate; - int m_colum=0; -}; - - -class CMonthSchceduleNumButton : public QObject, public QGraphicsRectItem -{ - Q_OBJECT - -public: - CMonthSchceduleNumButton(QGraphicsItem *parent = nullptr); - ~CMonthSchceduleNumButton() Q_DECL_OVERRIDE; - void setColor(QColor color1, QColor color2, bool GradientFlag = false); - void setText(QColor tcolor, QFont font, QPoint pos); - void setSizeType(DFontSizeManager::SizeType sizeType); - void setTransparentB(bool t, QColor tcolor); - void setDate(QDate date) - { - m_date = date; - } - QDate getDate()const - { - return m_date; - } - void setData(int num) - { - m_num = num; - } -signals: - void signalsCurrentScheduleDate(QDate date); - void signalPressScheduleShow(const bool isShow, const ScheduleDtailInfo &out = ScheduleDtailInfo()); -protected: - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override; -private: - bool m_GradientFlag; - QColor m_color1; - QColor m_color2; - QColor m_textcolor; - QFont m_font; - QPoint m_pos; - int m_num; - QColor m_transparentcolor; - bool m_transparentf = false; - QDate m_date; - DFontSizeManager::SizeType m_SizeType = DFontSizeManager::T8; -}; - -class CMonthSchceduleWidgetItem :public DragInfoItem -{ - Q_OBJECT -public: - explicit CMonthSchceduleWidgetItem(QRect rect,QGraphicsItem *parent = nullptr, int edittype = 0); - ~CMonthSchceduleWidgetItem() override; - QPixmap getPixmap(); - -private: - void paintBackground(QPainter *painter,const QRectF &rect,const int isPixMap = false) override; -private: - QPoint m_pos; -}; - -#endif // CSHCEDULEDAYVIEW_H diff -Nru dde-calendar-5.7.0.4/src/monthview.cpp dde-calendar-5.7.0.23/src/monthview.cpp --- dde-calendar-5.7.0.4/src/monthview.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/monthview.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,324 +0,0 @@ -/* - * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ - -#include "monthview.h" -#include "calendardbus.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include "schceduledlg.h" -#include "scheduledatamanage.h" -#include -#include -#include -#include -#include - -DGUI_USE_NAMESPACE -void CMonthView::setTheMe(int type) -{ - m_weekIndicator->setTheMe(type); - m_MonthGraphicsView->setTheMe(type); -} - - -CMonthView::CMonthView(QWidget *parent) : DWidget(parent) -{ - m_DBusInter = new CalendarDBus("com.deepin.api.LunarCalendar", - "/com/deepin/api/LunarCalendar", - QDBusConnection::sessionBus(), this); - if (!lunarCache) - lunarCache = new QMap; - - m_weekIndicator = new CMonthWeekView; - m_MonthGraphicsView = new CMonthGraphiview(this); - - connect(m_MonthGraphicsView, - &CMonthGraphiview::signalsViewSelectDate, - this, - &CMonthView::signalsViewSelectDate); - connect(m_MonthGraphicsView, - &CMonthGraphiview::signalsUpdateShcedule, - this, - &CMonthView::slotSchceduleUpdate); - connect(m_MonthGraphicsView, - &CMonthGraphiview::signalsSchceduleUpdate, - this, - &CMonthView::signalsSchceduleUpdate); - connect(m_MonthGraphicsView, - &CMonthGraphiview::signalViewtransparentFrame, - this, - &CMonthView::signalViewtransparentFrame); - connect(m_MonthGraphicsView, - &CMonthGraphiview::signalScheduleShow, - this, - &CMonthView::slotScheduleRemindWidget); - - - - - m_mainLayout = new QVBoxLayout; - m_mainLayout->setMargin(0); - m_mainLayout->setSpacing(0); - m_mainLayout->setContentsMargins(10, 0, 0, 10); - m_mainLayout->addWidget(m_weekIndicator); - m_mainLayout->addWidget(m_MonthGraphicsView); - - setLayout(m_mainLayout); - CScheduleDataCtrl *scheduleDataCtrl = CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl(); - m_createAction = new QAction(tr("New event"), this); - - m_RemindWidget = new SchecduleRemindWidget(this); - - connect(scheduleDataCtrl, &CScheduleDataCtrl::signalsupdatescheduleD, this, &CMonthView::slotsupdatescheduleD); - connect(this, &CMonthView::signalsupdatescheduleD, scheduleDataCtrl, &CScheduleDataCtrl::slotupdatescheduleD); - setMouseTracking(true); - setFocusPolicy(Qt::StrongFocus); -} - -CMonthView::~CMonthView() -{ - if (lunarCache !=nullptr) { - delete lunarCache; - lunarCache = nullptr; - } -} - -void CMonthView::slotSchceduleUpdate() -{ - emit signalsSchceduleUpdate(0); - emit signalsupdatescheduleD(this, m_days[0], m_days[41]); -} - -void CMonthView::slotUpdateUI(int type) -{ - if (type == 0) { - m_sflag = false; - } else { - m_sflag = true; - slotSchceduleUpdate(); - } -} - -void CMonthView::setSelectSchedule(const ScheduleDtailInfo &scheduleInfo) -{ - m_MonthGraphicsView->setSelectSchedule(scheduleInfo); -} - -void CMonthView::slotsupdatescheduleD(QWidget *w, QVector &data) -{ - if (w != this) return; - if (m_sflag) { - m_MonthGraphicsView->setScheduleInfo(data); - } - parentWidget()->setEnabled(true); -} - -void CMonthView::slotdelete(int id) -{ - Q_UNUSED(id); - emit signalsSchceduleUpdate(0); -} - -void CMonthView::slotScheduleRemindWidget(const bool isShow, const ScheduleDtailInfo &out) -{ - if (isShow) { - QPoint pos22 = QCursor::pos(); - CSchedulesColor gdcolor = CScheduleDataManage::getScheduleDataManage()->getScheduleColorByType( - out.type.ID); - m_RemindWidget->setData(out, gdcolor); - m_RemindWidget->show(pos22.x() + 10, pos22.y()); - QDesktopWidget *w = QApplication::desktop(); - if ((pos22.x() + m_RemindWidget->width() + 10) > w->width()) { - m_RemindWidget->setArrowDirection(DArrowRectangle::ArrowRight); - m_RemindWidget->show(pos22.x() - 10, pos22.y()); - } else { - m_RemindWidget->setArrowDirection(DArrowRectangle::ArrowLeft); - m_RemindWidget->show(pos22.x() + 10, pos22.y()); - } - - } else { - m_RemindWidget->hide(); - } -} - -void CMonthView::resizeEvent(QResizeEvent *event) -{ - DWidget::resizeEvent(event); - int leftmagin = 10; - int topmagin = static_cast(height() * 0.0193 + 0.5); - topmagin = 10; - m_leftmaagin = leftmagin; - m_topmagin = topmagin; - m_mainLayout->setContentsMargins(leftmagin, topmagin, 0, 10); - m_weekIndicator->setFixedSize(width()-leftmagin, static_cast(height() * 0.1042 + 0.5)); -} - - -void CMonthView::mousePressEvent(QMouseEvent *event) -{ - Q_UNUSED(event); - slotScheduleRemindWidget(false); -} - -void CMonthView::setFirstWeekday(int weekday) -{ - m_firstWeekDay = weekday; - m_weekIndicator->setList(weekday); - m_weekIndicator->updateWeek(); - updateDate(); -} - -void CMonthView::setCurrentDate(const QDate date) -{ - slotScheduleRemindWidget(false); - qDebug() << "set current date " << date; - if (date.year() < 1900) return; - if (date.month() != m_currentDate.month()) { - m_festivallist.clear(); - m_DBusInter->GetFestivalMonth(date.addMonths(-1).year(), date.addMonths(-1).month(), m_festivallist); - m_DBusInter->GetFestivalMonth(date.year(), date.month(), m_festivallist); - m_DBusInter->GetFestivalMonth(date.addMonths(1).year(), date.addMonths(1).month(), m_festivallist); - } - m_currentDate = date; - m_MonthGraphicsView->setFestivalInfo(m_festivallist); - updateDate(); - getDbusData(); - m_MonthGraphicsView->setLunarInfo(lunarCache); - emit signalcurrentDateChanged(m_currentDate); - m_weekIndicator->updateWeek(); - emit signalsupdatescheduleD(this, m_days[0], m_days[41]); -} - -void CMonthView::setLunarVisible(bool visible) -{ - m_MonthGraphicsView->setLunarVisible(visible); -} - - -int CMonthView::getDateIndex(const QDate &date) const -{ - for (int i = 0; i != 42; ++i) - if (m_days[i] == date) - return i; - - return 0; -} - -void CMonthView::updateDate() -{ - const QDate firstDay(m_currentDate.year(), m_currentDate.month(), 1); - int offset = firstDay.dayOfWeek() % 7 - m_firstWeekDay ; - - const int day = offset <0 ?offset +7:offset; - const int currentIndex = day + m_currentDate.day() - 1; - - if (currentIndex < 0) { - return; - } - for (int i(0); i != 42; ++i) { - m_days[i] = firstDay.addDays(i - day); - } - m_MonthGraphicsView->setDate(m_days); - update(); -} - -void CMonthView::updateCurrentLunar(const CaLunarDayInfo &info) -{ - emit signalcurrentLunarDateChanged(m_currentDate, info, 1); -} - - -ScheduleDtailInfo CMonthView::getScheduleInfo(const QDate &beginDate, const QDate &endDate) -{ - ScheduleDtailInfo info; - if (beginDate.daysTo(endDate)>0) { - info.beginDateTime = QDateTime(beginDate,QTime(0,0,0)); - info.endDateTime = QDateTime(endDate,QTime(23,59,59)); - } else { - info.beginDateTime = QDateTime(endDate,QTime(0,0,0)); - info.endDateTime = QDateTime(beginDate,QTime(23,59,00)); - } - info.titleName = tr("New Event"); - info.allday = true; - info.remind = true; - info.remindData.n = 1; - info.remindData.time = QTime(9, 0); - info.RecurID = 0; - info.id = 0; - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->GetType( - 1, info.type); - info.rpeat = 0; - - return info; -} - -const QDate CMonthView::getCellDate(int pos) -{ - return m_days[pos]; -} - -const CaLunarDayInfo CMonthView::getCaLunarDayInfo(const QDate &date) -{ - return lunarCache->value(date); -} - -void CMonthView::getDbusData() -{ - lunarCache->clear(); - - CaLunarDayInfo currentDayInfo; - bool o1 = true; - QDate getDate = m_currentDate; - for (int i = -1; i < 2; ++i) { - getDate = m_currentDate.addMonths(i); - QDBusReply reply = m_DBusInter->GetLunarMonthCalendar(getDate.year(), - getDate.month(), false, o1); - - QDate cacheDate; - cacheDate.setDate(getDate.year(), getDate.month(), 1); - foreach (const CaLunarDayInfo &dayInfo, reply.value().mCaLunarDayInfo) { -// if (cacheDate == QDate(2020,6,21)) { -// qDebug()<<"mGanZhiYear:"<insert(cacheDate, dayInfo); - cacheDate = cacheDate.addDays(1); - } - } - // refresh lunar info - updateCurrentLunar(lunarCache->value(m_currentDate)); -} - - diff -Nru dde-calendar-5.7.0.4/src/monthview.h dde-calendar-5.7.0.23/src/monthview.h --- dde-calendar-5.7.0.4/src/monthview.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/monthview.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +0,0 @@ -/* - * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ - -#ifndef MONTHVIEW_H -#define MONTHVIEW_H - -#include "monthweekview.h" -#include "constants.h" -#include -#include -#include -#include -#include -#include -#include -#include "calendardbus.h" -#include "SchecduleRemindWidget.h" -#include "monthgraphiview.h" -DWIDGET_USE_NAMESPACE - -class CMonthView: public DWidget -{ - Q_OBJECT -public: - void setTheMe(int type = 0); - bool isDragging()const - { - return m_MonthGraphicsView->getDragStatus() !=4; - } -public: - explicit CMonthView(QWidget *parent = nullptr); - ~CMonthView() Q_DECL_OVERRIDE; - void setFirstWeekday(int weekday); -signals: - void signalcurrentLunarDateChanged(QDate date, CaLunarDayInfo detail, int type = 0); - void signalcurrentDateChanged(QDate date); - void signalsSchceduleUpdate(int id = 0); - void signalsCurrentScheduleDate(QDate date); - void signalViewtransparentFrame(int type); - void signalsViewSelectDate(QDate date); -public slots: - void setCurrentDate(const QDate date); - void setLunarVisible(bool visible); - void slotSchceduleUpdate(); - void slotUpdateUI(int type); - void setSelectSchedule(const ScheduleDtailInfo &scheduleInfo); -public slots: - void slotsupdatescheduleD(QWidget *w, QVector &data); - void slotdelete(int id); - void slotScheduleRemindWidget(const bool isShow, const ScheduleDtailInfo &out = ScheduleDtailInfo()); -signals: - void signalsupdatescheduleD(QWidget *w, QDate begin, QDate end); -protected: - void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; - void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; -private: - int getDateIndex(const QDate &date) const; - const QDate getCellDate(int pos); - const CaLunarDayInfo getCaLunarDayInfo(const QDate &date); - void updateDate(); - void updateCurrentLunar(const CaLunarDayInfo &info); - ScheduleDtailInfo getScheduleInfo(const QDate &beginDate,const QDate &endDate); -private slots: - void getDbusData(); - -private: - CMonthGraphiview *m_MonthGraphicsView; - CalendarDBus *m_DBusInter; - QDate m_days[42]; - QDate m_currentDate; - - - QDate m_createDate; - QMap *lunarCache = nullptr; - QVector m_festivallist; - - - CMonthWeekView *m_weekIndicator; - int m_firstWeekDay =0; - QAction *m_createAction; // 创建日程 - QVBoxLayout *m_mainLayout; - int m_leftmaagin = 0; - int m_topmagin = 0; - bool m_sflag = true; - SchecduleRemindWidget *m_RemindWidget; - - QPoint m_PressPoint; - bool isCreate; - QDate m_PressDate; - QDate m_MoveDate; -}; - -#endif // MYCALENDARWIDGET_H diff -Nru dde-calendar-5.7.0.4/src/monthweekview.cpp dde-calendar-5.7.0.23/src/monthweekview.cpp --- dde-calendar-5.7.0.4/src/monthweekview.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/monthweekview.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,222 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ - -#include "monthweekview.h" - -#include -#include -#include -#include -#include -#include -#include "scheduledatamanage.h" -DGUI_USE_NAMESPACE -CMonthWeekView::CMonthWeekView(QWidget *parent) : DWidget(parent) -{ - m_mainLayout = new QHBoxLayout; - m_mainLayout->setMargin(0); - m_mainLayout->setSpacing(0); - setLayout(m_mainLayout); -} - -void CMonthWeekView::setList(int weekday) -{ - QLayoutItem *child; - while ((child = m_mainLayout->takeAt(0)) != nullptr) { - if (child->widget() != nullptr) { - delete child->widget(); - } - delete child; - } - m_weekData.clear(); - QLocale locale; - for (int i = 0; i != 7; ++i) { - - int d = checkDay(i + weekday); - - QVBoxLayout *hhLayout = new QVBoxLayout; - hhLayout->setMargin(0); - hhLayout->setSpacing(0); - hhLayout->setContentsMargins(0, 0, 0, 0); - - CustomFrame *label = new CustomFrame(); - label->setTextStr(locale.dayName(d ? d : 7, QLocale::ShortFormat)); - label->setContentsMargins(0, 0, 0, 0); - QFont weekfont; -// weekfont.setFamily("SourceHanSansSC"); - weekfont.setWeight(QFont::Medium); - weekfont.setPixelSize(16); - label->setTextFont(weekfont); - if (i ==0) { - label->setRoundState(true, false, false, false); - } else if (i==6) { - label->setRoundState(false, true, false, false); - } - if (d == 0) { - QColor textbC(0, 66, 154); - QColor colorSeven = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); -// label->setTextColor("#0887FF"); - label->setTextColor(colorSeven); - label->setBColor(textbC); - m_weekData.append(qMakePair(label, 1)); -#if 0 - DPalette monthpa = label->palette(); - QColor textC = "#0887FF"; - QColor textbC(0, 66, 154); - textbC.setAlphaF(0.05); - monthpa.setColor(DPalette::WindowText, textC); - monthpa.setColor(DPalette::Background, textbC); - label->setAutoFillBackground(true); - label->setPalette(monthpa); - m_weekData.append(qMakePair(label, 1)); - //label->setStyleSheet("color:#0887FF;background: rgba(0,66,154,0.05);"); -#endif - } else if (d == 6) { - QColor textbC(0, 66, 154); - QColor colorSix = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); -// label->setTextColor("#0887FF"); - label->setTextColor(colorSix); - label->setBColor(textbC); - m_weekData.append(qMakePair(label, 1)); - } else { - QColor textC = Qt::black; - QColor textbC(0, 66, 154); - textbC.setAlphaF(0.05); - label->setTextColor(textC); - label->setBColor(textbC); - m_weekData.append(qMakePair(label, 0)); - //label->setStyleSheet("color:black;background: rgba(0,66,154,0.05);"); - } - if ((i == weekday - 1 && weekday != 0) || i == weekday || (weekday == 0 && i == 6)) { - label->setObjectName("MonthHeaderWeekend"); - } else { - label->setObjectName("MonthHeaderWeekday"); - } - - // label->setAlignment(Qt::AlignCenter); - DHorizontalLine *splitline = new DHorizontalLine; - if (i == 0 || i == 6) { - label->setFixedSize(DDEMonthCalendar::MWeekCellWidth - 1, DDEMonthCalendar::MWeekCellHeight); - splitline->setFixedSize(DDEMonthCalendar::MWeekCellWidth - 1, 2); - } else { - label->setFixedSize(DDEMonthCalendar::MWeekCellWidth - 3, DDEMonthCalendar::MWeekCellHeight); - splitline->setFixedSize(DDEMonthCalendar::MWeekCellWidth - 3, 2); - } - hhLayout->addWidget(label); - hhLayout->addWidget(splitline); - splitline->setAutoFillBackground(true); - m_vline.append(splitline); - splitline->setVisible(false); - m_mainLayout->addLayout(hhLayout); - } -} - -void CMonthWeekView::setTheMe(int type) -{ - if (type == 0 || type == 1) { - for (int i = 0; i < m_weekData.count(); i++) { - if (m_weekData.at(i).second == 1) { -// QColor textC = "#0887FF"; - QColor color = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); - QColor textbC("#75C18E"); - textbC.setAlphaF(0.1); -// m_weekData.at(i).first->setTextColor(textC); - m_weekData.at(i).first->setTextColor(color); - m_weekData.at(i).first->setBColor(textbC); - } else { - QColor textC = "#6F6F6F"; - QColor textbC("#75C18E"); - textbC.setAlphaF(0.1); - m_weekData.at(i).first->setTextColor(textC); - m_weekData.at(i).first->setBColor(textbC); - } - m_vline.at(i)->setBackgroundRole(DPalette::Highlight); - } - - } else if (type == 2) { - for (int i = 0; i < m_weekData.count(); i++) { - if (m_weekData.at(i).second == 1) { -// QColor textC = "#0887FF"; - QColor color = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); - QColor textbC = "#82AEC1"; - textbC.setAlphaF(0.10); -// m_weekData.at(i).first->setTextColor(textC); - m_weekData.at(i).first->setTextColor(color); - m_weekData.at(i).first->setBColor(textbC); - } else { - QColor textC = "#C0C6D4"; - QColor textbC = "#82AEC1"; - textbC.setAlphaF(0.10); - m_weekData.at(i).first->setTextColor(textC); - m_weekData.at(i).first->setBColor(textbC); - } - //DPalette monthpa = m_vline.at(i)->palette(); - //monthpa.setColor(DPalette::Background, "#0059D2"); - //m_vline.at(i)->setPalette(monthpa); - m_vline.at(i)->setBackgroundRole(DPalette::Highlight); - } - } -} - -void CMonthWeekView::updateWeek() -{ - for (int i = 0; i < m_vline.count(); ++i) { - m_vline.at(i)->setVisible(false); - } - QDate date = QDate::currentDate(); - int d = date.dayOfWeek(); - QLocale locale; - QString str = locale.dayName(d ? d : 7, QLocale::ShortFormat); - for (int i = 0; i < m_vline.count(); ++i) { - - if (m_weekData.at(i).first->getTextStr() == str) { - m_vline.at(i)->setVisible(true); - } - } -} - -int CMonthWeekView::checkDay(int weekday) -{ - - // check the week, calculate the correct order in the custom. - -// if (weekday <= 0) -// return weekday += 7; - -// if (weekday > 7) -// return weekday -= 7; - - return weekday % 7; -} - -void CMonthWeekView::resizeEvent(QResizeEvent *event) -{ - int tw = static_cast(width() / 7.0 + 0.5); - int th = height(); - for (int i = 0; i < m_weekData.count(); i++) { - if (m_weekData.at(i).second == 1) { - - m_weekData.at(i).first->setFixedSize(tw, th); - } else { - m_weekData.at(i).first->setFixedSize(tw, th); - } - m_vline.at(i)->setFixedWidth(tw); - } - DWidget::resizeEvent(event); -} diff -Nru dde-calendar-5.7.0.4/src/monthweekview.h dde-calendar-5.7.0.23/src/monthweekview.h --- dde-calendar-5.7.0.4/src/monthweekview.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/monthweekview.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ - -#ifndef MONTHWEEKVIEW_H -#define MONTHWEEKVIEW_H - -#include "constants.h" -#include -#include -#include -#include -#include "customframe.h" -DWIDGET_USE_NAMESPACE -class CMonthWeekView : public DWidget -{ - Q_OBJECT -public: - explicit CMonthWeekView(QWidget *parent = nullptr); - void setList(int weekday); - void setTheMe(int type = 0); - void updateWeek(); -private: - int checkDay(int weekday); -protected: - void resizeEvent(QResizeEvent *event); -private: - QHBoxLayout *m_mainLayout; - QVector > m_weekData; - QVector m_vline; -}; - -#endif // WEEKINDICATOR_H diff -Nru dde-calendar-5.7.0.4/src/monthwindow.cpp dde-calendar-5.7.0.23/src/monthwindow.cpp --- dde-calendar-5.7.0.4/src/monthwindow.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/monthwindow.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,450 +0,0 @@ -/* - * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#include "monthwindow.h" -#include "monthview.h" -#include "monthdayview.h" -#include "constants.h" -#include "calendardbus.h" -#include -#include -#include -#include "schcedulesearchview.h" -#include "todybutton.h" -#include "scheduledatamanage.h" -DGUI_USE_NAMESPACE -CMonthWindow::CMonthWindow(QWidget *parent): QMainWindow (parent) -{ - setContentsMargins(0, 0, 0, 0); - initUI(); - initConnection(); - initLunar(); -} - -CMonthWindow::~CMonthWindow() -{ - disconnect(m_today, &CTodyButton::clicked, this, &CMonthWindow::slottoday); - delete m_monthDayView; - m_monthDayView = nullptr; - delete m_monthView; - m_monthView = nullptr; -} - -void CMonthWindow::setFirstWeekday(int weekday) -{ - m_monthView->setFirstWeekday(weekday); -} - -void CMonthWindow::setDate(QDate date) -{ - if (!date.isValid()) - return; - m_monthDayView->setCurrentDate(date); - if (m_currentdate == date) - return; - m_currentdate = date; - QLocale locale; - if (locale.language() == QLocale::Chinese) { - m_YearLabel->setText(QString::number(date.year()) + tr("Y")); - } else { - m_YearLabel->setText(QString::number(date.year())); - } - m_monthView->setCurrentDate(date); - emit signalCurrentDate(date); -} - -void CMonthWindow::setLunarVisible(bool state) -{ - m_monthView->setLunarVisible(state); - m_YearLunarLabel->setVisible(state); -} - -void CMonthWindow::setTheMe(int type) -{ - if (type == 0 || type == 1) { - DPalette anipa = m_contentBackground->palette(); - anipa.setColor(DPalette::Background, "#F8F8F8"); - m_contentBackground->setPalette(anipa); - m_contentBackground->setBackgroundRole(DPalette::Background); - - QColor todayColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); - DPalette todaypa = m_today->palette(); -// todaypa.setColor(DPalette::ButtonText, QColor("#1D81EC")); - todaypa.setColor(DPalette::ButtonText, todayColor); - todaypa.setColor(DPalette::Dark, Qt::white); - todaypa.setColor(DPalette::Light, Qt::white); - QColor sbcolor("#002A57"); - sbcolor.setAlphaF(0.05); - todaypa.setColor(DPalette::Shadow, sbcolor); - m_today->setPalette(todaypa); - QColor todayhover = "#000000"; - todayhover.setAlphaF(0.1); - QColor todaypress = "#000000"; - todaypress.setAlphaF(0.2); - m_today->setBColor("#FFFFFF", todayhover, todaypress, "#FFFFFF", todayhover, todaypress); -// m_today->setTColor("#1D81EC", "#001A2E", "#0081FF"); - m_today->setTColor(todayColor, "#001A2E", "#0081FF"); - m_today->setshadowColor(sbcolor); - - DPalette pa = m_YearLabel->palette(); - pa.setColor(DPalette::WindowText, QColor("#3B3B3B")); - m_YearLabel->setPalette(pa); - m_YearLabel->setForegroundRole(DPalette::WindowText); - - DPalette Lunapa = m_YearLunarLabel->palette(); - Lunapa.setColor(DPalette::WindowText, QColor("#8A8A8A")); - m_YearLunarLabel->setPalette(Lunapa); - m_YearLunarLabel->setForegroundRole(DPalette::WindowText); - - DPalette gpa = m_gridWidget->palette(); - gpa.setColor(DPalette::Background, "#F8F8F8"); - m_gridWidget->setPalette(gpa); - m_gridWidget->setBackgroundRole(DPalette::Background); - - } else if (type == 2) { - QColor todayColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); - DPalette todaypa = m_today->palette(); -// todaypa.setColor(DPalette::ButtonText, QColor("#0081FF")); - todaypa.setColor(DPalette::ButtonText, todayColor); - todaypa.setColor(DPalette::Light, "#484848"); - todaypa.setColor(DPalette::Dark, "#414141"); - QColor sbcolor("#000000"); - sbcolor.setAlphaF(0.05); - todaypa.setColor(DPalette::Shadow, sbcolor); - m_today->setPalette(todaypa); - - m_today->setBColor("#484848", "#727272", "#242424", "#414141", "#535353", "#282828"); -// m_today->setTColor("#0081FF", "#FFFFFF", "#0081FF"); - m_today->setTColor(todayColor, "#FFFFFF", "#0081FF"); - m_today->setshadowColor(sbcolor); - - DPalette pa = m_YearLabel->palette(); - pa.setColor(DPalette::WindowText, QColor("#C0C6D4")); - m_YearLabel->setPalette(pa); - m_YearLabel->setForegroundRole(DPalette::WindowText); - DPalette Lunapa = m_YearLunarLabel->palette(); - Lunapa.setColor(DPalette::WindowText, QColor("#798BA8")); - m_YearLunarLabel->setPalette(Lunapa); - m_YearLunarLabel->setForegroundRole(DPalette::WindowText); - DPalette anipa = m_contentBackground->palette(); - anipa.setColor(DPalette::Background, "#252525"); - m_contentBackground->setPalette(anipa); - m_contentBackground->setBackgroundRole(DPalette::Background); - - DPalette gpa = m_gridWidget->palette(); - gpa.setColor(DPalette::Background, "#252525"); - m_gridWidget->setPalette(gpa); - m_gridWidget->setBackgroundRole(DPalette::Background); - } - m_monthDayView->setTheMe(type); - m_monthView->setTheMe(type); -} - -void CMonthWindow::previousMonth() -{ - slideMonth(false); -} - -void CMonthWindow::nextMonth() -{ - slideMonth(true); -} - -void CMonthWindow::slotsearchDateSelect(QDate date) -{ - setDate(date); - slotupdateSchedule(); -} - -void CMonthWindow::setSearchWFlag(bool flag) -{ - m_searchfalg = flag; - m_monthDayView->setsearchfalg(flag); - //m_schceduleSearchView->setVisible(flag); -} - -void CMonthWindow::clearSearch() -{ - //m_schceduleSearchView->clearSearch(); -} - -void CMonthWindow::wheelEvent(QWheelEvent *e) -{ - //拖拽时禁用 - if (!m_monthView->isDragging()) { - QPoint numDegrees = e->angleDelta(); - if (numDegrees.y()>0) { - nextMonth(); - } else { - previousMonth(); - } - } - -} - -void CMonthWindow::initUI() -{ - m_contentBackground = new DFrame; - m_contentBackground->setContentsMargins(0, 0, 0, 0); - DPalette anipa = m_contentBackground->palette(); - anipa.setColor(DPalette::Background, "#F8F8F8"); - m_contentBackground->setAutoFillBackground(true); - m_contentBackground->setPalette(anipa); - - m_today = new CTodyButton; - m_today->setText(QCoreApplication::translate("today", "Today", "Today")); - m_today->setFixedSize(DDEMonthCalendar::MTodayWindth, DDEMonthCalendar::MTodayHeight); - QColor todayColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); - DPalette todaypa = m_today->palette(); -// todaypa.setColor(DPalette::ButtonText, QColor("#1D81EC")); - todaypa.setColor(DPalette::ButtonText, todayColor); - todaypa.setColor(DPalette::Dark, Qt::white); - todaypa.setColor(DPalette::Light, Qt::white); - - QColor sbcolor("#002A57"); - sbcolor.setAlphaF(0.05); - todaypa.setColor(DPalette::Shadow, sbcolor); - QFont todayfont; -// todayfont.setFamily("SourceHanSansSC"); - todayfont.setWeight(QFont::Medium); - todayfont.setPixelSize(14); - m_today->setFont(todayfont); - m_today->setPalette(todaypa); - m_YearLabel = new QLabel(); - m_YearLabel->setFixedHeight(DDEMonthCalendar::M_YLableHeight); - m_YearLunarLabel = new QLabel(); - m_YearLunarLabel->setFixedSize(DDEMonthCalendar::M_YLunatLabelWindth, DDEMonthCalendar::M_YLunatLabelHeight); - - QFont ylabelF; -// ylabelF.setFamily("SourceHanSansSC"); - ylabelF.setWeight(QFont::Medium); - ylabelF.setPixelSize(24); - m_YearLabel->setFont(ylabelF); - DPalette pa = m_YearLabel->palette(); - pa.setColor(DPalette::WindowText, QColor("#3B3B3B")); - m_YearLabel->setPalette(pa); - //m_YearLabel->setStyleSheet("color:#3B3B3B;"); - - ylabelF.setPixelSize(14); - m_YearLunarLabel->setFont(ylabelF); - DPalette Lunarpa = m_YearLunarLabel->palette(); - Lunarpa.setColor(DPalette::WindowText, QColor("#8A8A8A")); - m_YearLunarLabel->setPalette(Lunarpa); - - m_monthDayView = new CMonthDayView(this); - - QHBoxLayout *yeartitleLayout = new QHBoxLayout; - yeartitleLayout->setMargin(0); - yeartitleLayout->setSpacing(0); - yeartitleLayout->setContentsMargins(21, 20, 8, 10); - yeartitleLayout->addWidget(m_YearLabel); - - QHBoxLayout *yeartitleLayout1 = new QHBoxLayout; - yeartitleLayout1->setMargin(0); - yeartitleLayout1->setSpacing(0); - yeartitleLayout1->setContentsMargins(14, 9, 0, 7); - yeartitleLayout1->addWidget(m_YearLunarLabel); - yeartitleLayout->addLayout(yeartitleLayout1); - //yeartitleLayout->addSpacing(30); - //m_spaceitem = new QSpacerItem(30, 36, QSizePolicy::Fixed, QSizePolicy::Fixed); - - //yeartitleLayout->addItem(m_spaceitem); - yeartitleLayout->addStretch(); - yeartitleLayout->addWidget(m_monthDayView, 0, Qt::AlignCenter); - yeartitleLayout->addStretch(); - yeartitleLayout->addWidget(m_today, 0, Qt::AlignRight); - - m_monthView = new CMonthView(this); - QVBoxLayout *mhLayout = new QVBoxLayout; - mhLayout->setMargin(0); - mhLayout->setSpacing(0); - // mhLayout->setContentsMargins(10, 2, 10, 10); - mhLayout->addWidget(m_monthView); - - QVBoxLayout *hhLayout = new QVBoxLayout; - hhLayout->setSpacing(0); - hhLayout->setMargin(0); - - hhLayout->addLayout(yeartitleLayout); - m_gridWidget = new DWidget(); - m_gridWidget->setContentsMargins(0, 0, 0, 0); - m_gridWidget->setAutoFillBackground(true); - m_gridWidget->setLayout(mhLayout); - - hhLayout->addWidget(m_gridWidget); - - m_tmainLayout = new QHBoxLayout; - m_tmainLayout->setMargin(0); - m_tmainLayout->setSpacing(0); - m_tmainLayout->setContentsMargins(0, 0, 10, 0); - m_tmainLayout->addLayout(hhLayout); - //mainLayout->addStretch(1); - - //m_schceduleSearchView = new CSchceduleSearchView(this); - //m_schceduleSearchView->setFixedWidth(200); - - QVBoxLayout *ssLayout = new QVBoxLayout; - ssLayout->setMargin(0); - ssLayout->setSpacing(0); - ssLayout->setContentsMargins(0, 10, 0, 10); - //ssLayout->addWidget(m_schceduleSearchView); - m_tmainLayout->addLayout(ssLayout); - //m_schceduleSearchView->setVisible(false); - - m_contentBackground->setLayout(m_tmainLayout); - - // m_animationContainer = new DFrame(m_contentBackground); - // DPalette anipa = m_animationContainer->palette(); - // anipa.setColor(DPalette::Background, Qt::white); - //m_animationContainer->setAutoFillBackground(true); - //m_animationContainer->setPalette(anipa); - //m_animationContainer->setStyleSheet("QFrame { background: rgba(0, 0, 0, 0) }"); - // m_animationContainer->setFixedSize(m_monthView->width(), - // m_monthView->height() - DDEMonthCalendar::MDayCellHeight); - // m_animationContainer->move(10, 130); - // m_animationContainer->hide(); - - setCentralWidget(m_contentBackground); - - -} - -void CMonthWindow::initConnection() -{ - connect(m_today, &DPushButton::clicked, this, &CMonthWindow::slottoday); - connect(m_monthView, &CMonthView::signalcurrentLunarDateChanged, this, &CMonthWindow::slotcurrentDateLunarChanged); - connect(m_monthView, &CMonthView::signalcurrentDateChanged, this, &CMonthWindow::slotcurrentDateChanged); - connect(m_monthDayView, &CMonthDayView::signalsSelectDate, this, &CMonthWindow::slotSelectedMonth); - connect(m_monthView, &CMonthView::signalsSchceduleUpdate, this, &CMonthWindow::slotTransitSchedule); - connect(m_monthDayView, &CMonthDayView::signalsCurrentDate, this, &CMonthWindow::slotSelectedMonth); - connect(m_monthView, &CMonthView::signalsCurrentScheduleDate, this, &CMonthWindow::signalsCurrentScheduleDate); - connect(m_monthView, &CMonthView::signalViewtransparentFrame, this, &CMonthWindow::signalViewtransparentFrame); - connect(m_monthView, &CMonthView::signalsViewSelectDate, this, &CMonthWindow::signalsViewSelectDate); - -} - -void CMonthWindow::initLunar() -{ - m_monthView->setLunarVisible(true); -} - -void CMonthWindow::slideMonth(bool next) -{ - QDate currentDate; - if (next) { - if (m_currentdate.year() == 1900 && m_currentdate.month() == 1) return; - currentDate = m_currentdate.addMonths(-1); - } else { - currentDate = m_currentdate.addMonths(1); - } - setDate(currentDate); - QDate tdate = QDate(m_currentdate.year(), m_currentdate.month(), 1); - emit signalCurrentDate(tdate); -} - -void CMonthWindow::slotReturnTodayUpdate() -{ - setDate(QDate::currentDate()); -} - -void CMonthWindow::slotScheduleHide() -{ - m_monthView->slotScheduleRemindWidget(false); -} - -void CMonthWindow::slotupdateSchedule(int id) -{ - Q_UNUSED(id); - m_monthView->slotSchceduleUpdate(); -} - -void CMonthWindow::slotTransitSchedule(int id) -{ - emit signalsWUpdateShcedule(this, id); -} - -void CMonthWindow::setSelectSchedule(const ScheduleDtailInfo &scheduleInfo) -{ - m_monthView->setSelectSchedule(scheduleInfo); -} - -void CMonthWindow::resizeEvent(QResizeEvent *event) -{ - qreal dw = width() * 0.5023 + 0.5; - int dh = 36; - if (m_searchfalg) { - m_tmainLayout->setContentsMargins(0, 0, 0, 0); - } else { - m_tmainLayout->setContentsMargins(0, 0, 10, 0); - } - if (!m_searchfalg) { - m_monthDayView->setFixedSize(qRound(dw), dh); - //m_monthDayView->setwindowFixw(dw, width()); - } else { - //m_monthDayView->setwindowFixw(dw, width() - 0.2325 * width() + 0.5 - 260); - m_monthDayView->setFixedSize(qRound(dw), dh); - } - //m_schceduleSearchView->setFixedWidth(0.2325 * width() + 0.5); - QMainWindow::resizeEvent(event); -} - -void CMonthWindow::slottoday() -{ - emit signalsReturnTodayUpdate(this); - setDate(QDate::currentDate()); -} - -void CMonthWindow::slotcurrentDateLunarChanged(QDate date, CaLunarDayInfo detail, int type) -{ - QDate currentdate = m_currentdate; - m_currentdate = date; - if (type == 1) { - QLocale locale; - if (locale.language() == QLocale::Chinese) { - m_YearLabel->setText(QString::number(date.year()) + tr("Y")); - } else { - m_YearLabel->setText(QString::number(date.year())); - } - // m_YearLabel->setText(QString::number(date.year()) + tr("Y")); - m_YearLunarLabel->setText("-" + detail.mGanZhiYear + detail.mZodiac + "年-"); - //m_animationContainer->hide(); - - } else if (type == 0) { - if (date.month() != currentdate.month()) { - m_monthDayView->setRCurrentDate(date); - } - } - //m_monthDayView->setRCurrentDate(date); -} - -void CMonthWindow::slotcurrentDateChanged(QDate date) -{ - m_currentdate = date; - if (m_currentdate == QDate::currentDate()) { - m_today->setText(QCoreApplication::translate("today", "Today", "Today")); - } else { - m_today->setText(QCoreApplication::translate("Return Today", "Today", "Return Today")); - } -} - -void CMonthWindow::slotSelectedMonth(QDate date) -{ - m_currentdate = date; - m_monthView->setCurrentDate(date); - emit signalCurrentDate(date); -} diff -Nru dde-calendar-5.7.0.4/src/monthwindow.h dde-calendar-5.7.0.23/src/monthwindow.h --- dde-calendar-5.7.0.4/src/monthwindow.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/monthwindow.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#ifndef MONTHWINDOW_H -#define MONTHWINDOW_H - -#include -#include -#include -#include -#include -#include -#include -#include "calendardbus.h" -#include "SchecduleRemindWidget.h" - - -DWIDGET_USE_NAMESPACE -class CSchceduleSearchView; -class CMonthView; -class CMonthDayView; -class QHBoxLayout; -class CTodyButton; -class CMonthWindow: public QMainWindow -{ - Q_OBJECT -public: - CMonthWindow(QWidget *parent = nullptr); - ~CMonthWindow() Q_DECL_OVERRIDE; - void setFirstWeekday(int weekday); - void setDate(QDate date); - void setLunarVisible(bool state); - void setTheMe(int type = 0); - void setSearchWFlag(bool flag); - void clearSearch(); -public slots: - void previousMonth(); - void nextMonth(); - void slotsearchDateSelect(QDate date); -protected: - void wheelEvent(QWheelEvent *) Q_DECL_OVERRIDE; -private: - void initUI(); - void initConnection(); - void initLunar(); - void slideMonth(bool next); -signals: - void dateSelected(const QDate date, const CaLunarDayInfo &detail) const; - void signalsWUpdateShcedule(QMainWindow *w, int id = 0); - void signalsReturnTodayUpdate(QMainWindow *w); - void signalsCurrentScheduleDate(QDate date); - void signalsViewSelectDate(QDate date); - void signalViewtransparentFrame(int type); - void signalCurrentDate(QDate date); -public slots: - void slotReturnTodayUpdate(); - void slotScheduleHide(); -public slots: - void slotupdateSchedule(int id = 0); - void slotTransitSchedule(int id = 0); - void setSelectSchedule(const ScheduleDtailInfo &scheduleInfo); -protected: - void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; -private slots: - void slottoday(); - void slotcurrentDateLunarChanged(QDate date, CaLunarDayInfo detail, int type = 0); - void slotcurrentDateChanged(QDate date); - void slotSelectedMonth(QDate date); -private: - CMonthView *m_monthView; - CMonthDayView *m_monthDayView; - DFrame *m_contentBackground = nullptr; - CTodyButton *m_today = nullptr; - QDate m_currentdate; - QLabel *m_YearLabel; - QLabel *m_YearLunarLabel; - QSpacerItem *m_spaceitem; - DWidget *m_gridWidget; - bool m_searchfalg = false; - QHBoxLayout *m_tmainLayout; -}; - -#endif // YEARWINDOW_H diff -Nru dde-calendar-5.7.0.4/src/myschceduleview.cpp dde-calendar-5.7.0.23/src/myschceduleview.cpp --- dde-calendar-5.7.0.4/src/myschceduleview.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/myschceduleview.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,600 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#include "myschceduleview.h" -#include -#include "schceduledlg.h" -#include "scheduledatamanage.h" -#include -#include -#include -#include -#include "schcedulectrldlg.h" -#include "cdynamicicon.h" - -#include -#include -#include -#include -DGUI_USE_NAMESPACE -CMySchceduleView::CMySchceduleView(const ScheduleDtailInfo &schduleInfo,QWidget *parent) - : DDialog(parent) -// m_scheduleInfo(ScheduleDtailInfo) -{ - setContentsMargins(0, 0, 0, 0); - m_scheduleInfo = schduleInfo; - initUI(); - initConnection(); - //setTitle(tr("My Schcedule")); - setFixedSize(380, 160); - int themetype = CScheduleDataManage::getScheduleDataManage()->getTheme(); - if (themetype == 2) { - DPalette anipa = palette(); - QColor color = "#191919"; - color.setAlphaF(0.8); - anipa.setColor(DPalette::Background, color); - setPalette(anipa); - } - - AutoFeed(m_scheduleInfo.titleName); - //m_schceduleLabel->setText(info.titleName); - if (m_scheduleInfo.type.ID == 4) { - m_timeLabel->setText(m_scheduleInfo.beginDateTime.toString(("yyyy-MM-dd"))); - } else { - m_timeLabel->setText(m_scheduleInfo.beginDateTime.toString("yyyy-MM-dd hh:mm") + " ~ " + m_scheduleInfo.endDateTime.toString("yyyy-MM-dd hh:mm")); - } - - //setIconPixmap(DHiDPIHelper::loadNxPixmap(":/resources/icon/dde-logo.svg").scaled(QSize(34, 34) * devicePixelRatioF())); -} - -CMySchceduleView::~CMySchceduleView() -{ - emit signalViewtransparentFrame(0); -} -void CMySchceduleView::AutoFeed(QString text) -{ - QString strText = text; - QString resultStr = nullptr; - QFont labelF; -// labelF.setFamily("SourceHanSansSC"); - labelF.setWeight(QFont::Medium); - labelF = DFontSizeManager::instance()->get(DFontSizeManager::T6,labelF); - QFontMetrics fm(labelF); - int titlewidth = fm.width(strText); - QStringList strList; - QString str; - int h = fm.height(); - strList.clear(); - if (titlewidth < 330) { - strList.append(strText); - resultStr += strText; -// m_schceduleLabel->setFixedHeight(h); - } else { - for (int i = 0; i < strText.count(); i++) { - str += strText.at(i); - if (fm.width(str) > 330) { - str.remove(str.count() - 1,1); - strList.append(str); - resultStr += str + "\n"; - str.clear(); - --i; - } - } - strList.append(str); - resultStr += str; -// m_schceduleLabel->setFixedHeight(strList.count() * h + 8); - } - - if (strList.count() * h + 140 > 240) { - area->setFixedHeight(100); - setFixedHeight(250); - } else { - area->setFixedHeight(strList.count() * h); - setFixedHeight(strList.count() * h + 152); - } -// if (strList.count() * h + 140 > 240) { -// qDebug() << "1"; -// setFixedHeight(240); -// } else { -// qDebug() <<"2"; -// setFixedHeight(strList.count() * h + 140); -// } - - m_schceduleLabel->setText(resultStr); -// m_schceduleLabel->adjustSize(); - - - -// QString strText = text; -//// QFont labelF; -//// labelF.setFamily("SourceHanSansSC"); -//// labelF.setWeight(QFont::Medium); -// labelF = DFontSizeManager::instance()->get(DFontSizeManager::T6,labelF); -//// labelF.setPixelSize(14); -// QFontMetrics fm(labelF); -// int row = 0; - -// QString str; -// if (!strText.isEmpty()) { -// QStringList sslist = strText.split("\n"); -// QString result; -// for (int j = 0; j < sslist.count(); j++) { -// QString currentstr = sslist.at(j); -// for (int i = 0; i < currentstr.count(); i++) { -// str.append(currentstr.at(i)); -// int widthT = fm.width(str) + 5; -// if (widthT >= 340) { -// currentstr.insert(i - 1, "\n"); -// i--; -// str.clear(); -// row++; -// } else { - -// } -// } -// if (currentstr.isEmpty()) { -// result += "\n"; -// row++; -// } else { -// if (j != sslist.count() - 1) { -// result += currentstr + "\n"; -// row++; -// } else { -// result += currentstr; -// } - -// } -// } -// strText = result; -// } -//// m_schceduleLabel->setFixedHeight((row + 1) * 24); -// if (((row + 1) * 24) > 100) { -// area->setFixedHeight(100 - 20); -// } else { -// area->setFixedHeight((row + 1 ) * 24); -// } - -// if ((row * 24 + 180) > 240) { -// setFixedHeight(240); -// } else { -// setFixedHeight(row * 24 + 180); -// } -// m_schceduleLabel->setText(strText); -//// m_schceduleLabel->setText(text); -// m_schceduleLabel->adjustSize(); -} - -void CMySchceduleView::showEvent(QShowEvent *event) -{ - Q_UNUSED(event); - emit signalViewtransparentFrame(1); -} - -//void CMySchceduleView::paintEvent(QPaintEvent *event) -//{ - -//} - -bool CMySchceduleView::eventFilter(QObject *o, QEvent *e) -{ -// QWidget *cell = qobject_cast(o); -// if (cell == w && e->type() == QEvent::Paint) { -// paintLabel(cell); -// } - Q_UNUSED(o); - if (e->type() == QEvent::FontChange) { - AutoFeed(m_scheduleInfo.titleName); - } - return false; -} - -//void CMySchceduleView::changeEvent(QEvent *event) -//{ -// if (event->type() == QEvent::FontChange) { -//// AutoFeed(m_scheduleInfo.titleName); -//// update(); -//// qDebug() <getTheme(); -// painter.save(); -// if (themetype == 0 || themetype == 1) { -// color = QColor("#2C4767"); - -// } else { -// color = QColor("#A8B7D1"); -// } -// painter.setPen(color); - -// QString strText = m_scheduleInfo.titleName; -// QFontMetrics fm = painter.fontMetrics(); -// int titlewidth = fm.width(strText); -// QStringList strList; -// QString str; -// int h = fm.height(); -// strList.clear(); -// if (titlewidth < 340) { -// strList.append(strText); -// label->setFixedHeight(h); -// } else { -// for (int i = 0; i < strText.count(); i++) { -// str += strText.at(i); -// if (fm.width(str) > 340) { -// str.remove(str.count() - 1,1); -// strList.append(str); -// str.clear(); -// --i; -// } -// } -// strList.append(str); -// label->setFixedHeight(strList.count() * h + 8); -// } - - -// if (strList.count() * h > 100) { -// area->setFixedHeight(100 - 18); -// } else { -// area->setFixedHeight(strList.count() * h); -// } -// if (strList.count() * h + 182 > 240) { -// setFixedHeight(240); -// } else { -// setFixedHeight(strList.count() + 182); -// } - -// for (int i = 0; i < strList.count(); i++) { -// painter.drawText(QRect(0, h * i, 340, h + 4),Qt::AlignHCenter,strList.at(i)); -// } - -// painter.restore(); -// painter.end(); -//} - -void CMySchceduleView::slotEditBt(int buttonIndex, QString buttonName) -{ - if (buttonIndex != 1 && buttonName != "Edit") - return; - - CSchceduleDlg dlg(0, this); - dlg.setData(m_scheduleInfo); - if (dlg.exec() == DDialog::Accepted) { - accept(); - emit signalsEditorDelete(1); - } -} - -void CMySchceduleView::slotDeleteBt(int buttonIndex, QString buttonName) -{ - if (buttonIndex != 0 && buttonName != "Delete") - return; - - if (m_scheduleInfo.rpeat == 0) { - CSchceduleCtrlDlg msgBox; - //msgBox.setWindowFlags(Qt::FramelessWindowHint); - // msgBox.setIconPixmap(DHiDPIHelper::loadNxPixmap(":/resources/icon/dde-logo.svg").scaled(QSize(34, 34) * devicePixelRatioF())); - msgBox.setText(tr("You are deleting an event.")); - msgBox.setInformativeText(tr("Are you sure you want to delete this event?")); - /*QAbstractButton *noButton = */msgBox.addPushButton(tr("Cancel"), true); - /* QAbstractButton *yesButton = */msgBox.addWaringButton(tr("Delete"), true); -// DPalette pa = yesButton->palette(); - -// if (themetype == 0 || themetype == 1) { -// pa.setColor(DPalette::ButtonText, Qt::red); - -// } else { -// pa.setColor(DPalette::ButtonText, "#FF5736"); - -// } -// yesButton->setPalette(pa); -// msgBox.updatesize(); - msgBox.exec(); - - if (msgBox.clickButton() == 0) { - return; - } else if (msgBox.clickButton() == 1) { - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->deleteScheduleInfoById(m_scheduleInfo.id); - } else { - return; - } - } else { - if (m_scheduleInfo.RecurID == 0) { - CSchceduleCtrlDlg msgBox; - //msgBox.setWindowFlags(Qt::FramelessWindowHint); - //msgBox.setIconPixmap(DHiDPIHelper::loadNxPixmap(":/resources/icon/dde-logo.svg").scaled(QSize(34, 34) * devicePixelRatioF())); - - msgBox.setText(tr("You are deleting an event.")); - msgBox.setInformativeText(tr("Do you want to delete all occurrences of this event, or only the selected occurrence?")); - /*QAbstractButton *noButton = */msgBox.addPushButton(tr("Cancel")); - /*QAbstractButton *yesallbutton = */msgBox.addPushButton(tr("Delete All")); - /*QAbstractButton *yesButton = */msgBox.addsuggestButton(tr("Delete Only This Event")); -// msgBox.updatesize(); -// DPalette pa = yesButton->palette(); -// if (themetype == 0 || themetype == 1) { -// pa.setColor(DPalette::ButtonText, Qt::white); -// pa.setColor(DPalette::Dark, QColor("#25B7FF")); -// pa.setColor(DPalette::Light, QColor("#0098FF")); -// } else { -// pa.setColor(DPalette::ButtonText, "#B8D3FF"); -// pa.setColor(DPalette::Dark, QColor("#0056C1")); -// pa.setColor(DPalette::Light, QColor("#004C9C")); -// } -// yesButton->setPalette(pa); - msgBox.exec(); - - if (msgBox.clickButton() == 0) { - return; - } else if (msgBox.clickButton() == 1) { - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->deleteScheduleInfoById(m_scheduleInfo.id); - } else if (msgBox.clickButton() == 2) { - - ScheduleDtailInfo newschedule; - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->getScheduleInfoById(m_scheduleInfo.id, newschedule); - newschedule.ignore.append(m_scheduleInfo.beginDateTime); - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo(newschedule); - } else { - return; - } - } else { - CSchceduleCtrlDlg msgBox; - //msgBox.setWindowFlags(Qt::FramelessWindowHint); - //msgBox.setIconPixmap(DHiDPIHelper::loadNxPixmap(":/resources/icon/dde-logo.svg").scaled(QSize(34, 34) * devicePixelRatioF())); - msgBox.setText(tr("You are deleting an event.")); - msgBox.setInformativeText(tr("Do you want to delete this and all future occurrences of this event, or only the selected occurrence?")); - /*QAbstractButton *noButton = */msgBox.addPushButton(tr("Cancel")); - /*QAbstractButton *yesallbutton = */msgBox.addPushButton(tr("Delete All Future Events")); - /*QAbstractButton *yesButton = */msgBox.addsuggestButton(tr("Delete Only This Event")); -// msgBox.updatesize(); -// DPalette pa = yesButton->palette(); -// if (themetype == 0 || themetype == 1) { -// pa.setColor(DPalette::ButtonText, Qt::white); -// pa.setColor(DPalette::Dark, QColor("#25B7FF")); -// pa.setColor(DPalette::Light, QColor("#0098FF")); -// } else { -// pa.setColor(DPalette::ButtonText, "#B8D3FF"); -// pa.setColor(DPalette::Dark, QColor("#0056C1")); -// pa.setColor(DPalette::Light, QColor("#004C9C")); -// } -// yesButton->setPalette(pa); - msgBox.exec(); - - if (msgBox.clickButton() == 0) { - return; - } else if (msgBox.clickButton() == 1) { - ScheduleDtailInfo newschedule; - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->getScheduleInfoById(m_scheduleInfo.id, newschedule); - - newschedule.enddata.type = 2; - newschedule.enddata.date = m_scheduleInfo.beginDateTime.addDays(-1); - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo(newschedule); - - } else if (msgBox.clickButton() == 2) { - - ScheduleDtailInfo newschedule; - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->getScheduleInfoById(m_scheduleInfo.id, newschedule); - - newschedule.ignore.append(m_scheduleInfo.beginDateTime); - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo(newschedule); - } else { - return; - } - } - } - accept(); - emit signalsEditorDelete(1); -} - -void CMySchceduleView::initUI() -{ - //m_icon = new QLabel(this); - // m_icon->setFixedSize(30, 30); - //m_icon->setPixmap(DHiDPIHelper::loadNxPixmap(":/resources/icon/dde-logo.svg") - // .scaled(m_icon->size() * devicePixelRatioF())); - //m_icon->move(11, 10); - - //在点击任何对话框上的按钮后不关闭对话框,保证关闭子窗口时不被一起关掉 - setOnButtonClickedClose(false); - - m_Title = new QLabel(this); - m_Title->setFixedSize(108, 51); - m_Title->setAlignment(Qt::AlignCenter | Qt::AlignVCenter); - DFontSizeManager::instance()->bind(m_Title,DFontSizeManager::T5); - QIcon t_icon(CDynamicIcon::getInstance()->getPixmap()); //= QIcon::fromTheme("dde-calendar"); - setIcon(t_icon); - QFont labelTitle; -// labelTitle.setFamily("SourceHanSansSC"); - labelTitle.setWeight(QFont::DemiBold); -// labelTitle.setPixelSize(17); - int themetype = CScheduleDataManage::getScheduleDataManage()->getTheme(); - - DPalette titlepa = m_Title->palette(); - if (themetype == 0 || themetype == 1) { - titlepa.setColor(DPalette::WindowText, QColor("#001A2E")); - - } else { - titlepa.setColor(DPalette::WindowText, QColor("#C0C6D4")); - } - - m_Title->setPalette(titlepa); - m_Title->setFont(labelTitle); - m_Title->setText(tr("My Event")); - m_Title->move(137, 0); - - - - QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->setMargin(0); - mainLayout->setSpacing(0); - // mainLayout->setContentsMargins(10, 10, 10, 10); - - area = new QScrollArea (this); - area->setFrameShape(QFrame::NoFrame); - area->setFixedWidth(363); - DPalette pa = area->palette(); - if (themetype == 0 || themetype == 1) { - pa.setColor(DPalette::WindowText, QColor("#2C4767")); - - } else { - pa.setColor(DPalette::WindowText, QColor("#A8B7D1")); - } - area->setBackgroundRole(QPalette::Background); - area->setPalette(pa); - area->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); - area->setWidgetResizable(true); - area->setAlignment(Qt::AlignCenter); - -// w = new QWidget (this); -// w->setFixedSize(340,24); -// w->installEventFilter(this); - -// area->setWidget(w); -// mainLayout->addWidget(area); - - m_schceduleLabel = new QLabel(this); -// m_schceduleLabel->setWordWrap(true); - m_schceduleLabel->setTextFormat(Qt::PlainText);//纯文本格式 - m_schceduleLabel->installEventFilter(this); - m_schceduleLabel->setFixedWidth(330); - m_schceduleLabel->setAlignment(Qt::AlignCenter); - DFontSizeManager::instance()->bind(m_schceduleLabel,DFontSizeManager::T6); -// QFont labelF; -// labelF.setFamily("SourceHanSansSC"); - labelF.setWeight(QFont::Medium); - DPalette wpa = m_schceduleLabel->palette(); - if (themetype == 0 || themetype == 1) { - wpa.setColor(DPalette::WindowText, QColor("#2C4767")); - - } else { - wpa.setColor(DPalette::WindowText, QColor("#A8B7D1")); - } - m_schceduleLabel->setPalette(wpa); - m_schceduleLabel->setFont(labelF); - - area->setWidget(m_schceduleLabel); - mainLayout->addWidget(area); - -// mainLayout->addWidget(m_schceduleLabel); - - - m_timeLabel = new QLabel(this); - m_timeLabel->setFixedHeight(26); - m_timeLabel->setAlignment(Qt::AlignCenter); - DFontSizeManager::instance()->bind(m_timeLabel,DFontSizeManager::T6); - QFont labelT; -// labelT.setFamily("SourceHanSansSC"); - labelT.setWeight(QFont::Bold); -// labelT.setPixelSize(14); - DPalette tpa = m_timeLabel->palette(); - - - if (themetype == 0 || themetype == 1) { - tpa.setColor(DPalette::WindowText, QColor("#6A829F")); - } else { - tpa.setColor(DPalette::WindowText, QColor("#6A829F")); - } - - - - m_timeLabel->setPalette(tpa); - m_timeLabel->setFont(labelT); - mainLayout->addSpacing(6); - mainLayout->addWidget(m_timeLabel); - - if (m_scheduleInfo.type.ID == 4) { -// QHBoxLayout *h = new QHBoxLayout (); -// m_okBt = new DPushButton (tr("OK")); -// m_okBt->setFocusPolicy(Qt::NoFocus); -// m_okBt->setFixedSize(360,36); -// connect(m_okBt,&DPushButton::clicked,this,&CMySchceduleView::close); -// mainLayout->addSpacing(20); -// h->addStretch(); -// h->addWidget(m_okBt); -// h->addStretch(); -// mainLayout->addLayout(h); - addButton(tr("OK"), false, DDialog::ButtonNormal); - QAbstractButton *button_ok = getButton(0); - button_ok->setFixedSize(360,36); - } else { - addButton(tr("Delete"), false, DDialog::ButtonNormal); - addButton(tr("Edit"), false, DDialog::ButtonRecommend); - for (int i = 0; i < buttonCount(); i++) { - QAbstractButton *button = getButton(i); - button->setFixedSize(165,36); - } -// DVerticalLine *btframe = new DVerticalLine(this); -// btframe->setFixedSize(3, 28); -// QHBoxLayout *hBtLayout = new QHBoxLayout; -// hBtLayout->setMargin(0); -// hBtLayout->setSpacing(0); -// hBtLayout->setContentsMargins(0, 0, 0, 0); -// // hBtLayout->addStretch(); -// m_editBt = new DSuggestButton(tr("Edit")); -//// DPalette pa = m_editBt->palette(); -//// if (themetype == 0 || themetype == 1) { -//// pa.setColor(DPalette::ButtonText, Qt::white); -//// pa.setColor(DPalette::Dark, QColor("#25B7FF")); -//// pa.setColor(DPalette::Light, QColor("#0098FF")); -//// } else { -//// pa.setColor(DPalette::ButtonText, "#B8D3FF"); -//// pa.setColor(DPalette::Dark, QColor("#0056C1")); -//// pa.setColor(DPalette::Light, QColor("#004C9C")); -//// } -//// m_editBt->setPalette(pa); -// m_editBt->setFixedSize(165, 36); -// m_deleteBt = new DPushButton(tr("Delete")); -// m_deleteBt->setFixedSize(165, 36); - -// hBtLayout->addWidget(m_deleteBt); -// hBtLayout->addSpacing(5); -// hBtLayout->addWidget(btframe); -// hBtLayout->addSpacing(5); -// hBtLayout->addWidget(m_editBt); -// mainLayout->addSpacing(20); -// mainLayout->addLayout(hBtLayout); - } - DFrame *gwi = new DFrame(this); - gwi->setContentsMargins(0, 0, 0, 0); - gwi->setLayout(mainLayout); - DPalette anipa = gwi->palette(); - QColor color = "#F8F8F8"; - color.setAlphaF(0.0); - anipa.setColor(DPalette::Background, color); - gwi->setAutoFillBackground(true); - gwi->setPalette(anipa); - gwi->setBackgroundRole(DPalette::Background); - // gwi->setGeometry(0, 51, 380, 110); - addContent(gwi, Qt::AlignCenter); -} - -void CMySchceduleView::initConnection() -{ - if (m_scheduleInfo.type.ID == 4) { - connect(this, &DDialog::buttonClicked, this, &CMySchceduleView::close); - } else { - connect(this, &DDialog::buttonClicked, this, &CMySchceduleView::slotEditBt); - connect(this, &DDialog::buttonClicked, this, &CMySchceduleView::slotDeleteBt); - } - - QShortcut *shortcut = new QShortcut(this); - shortcut->setKey(QKeySequence(QLatin1String("ESC"))); - connect(shortcut, SIGNAL(activated()), this, SLOT(close())); -} diff -Nru dde-calendar-5.7.0.4/src/myschceduleview.h dde-calendar-5.7.0.23/src/myschceduleview.h --- dde-calendar-5.7.0.4/src/myschceduleview.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/myschceduleview.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#ifndef MYSCHCEDULEVIEW_H -#define MYSCHCEDULEVIEW_H - -#include -#include -#include -#include -#include -#include -#include "schedulestructs.h" -#include -#include -#include -DWIDGET_USE_NAMESPACE - -class CMySchceduleView : public DDialog -{ - Q_OBJECT -public: - explicit CMySchceduleView(const ScheduleDtailInfo &schduleInfo,QWidget *parent = nullptr); - ~CMySchceduleView() Q_DECL_OVERRIDE; - ScheduleDtailInfo getSchedules() - { - return m_scheduleInfo; - } -signals: - void signalsEditorDelete(int type = 0); - void signalViewtransparentFrame(int type); -public slots: - void slotEditBt(int buttonIndex, QString buttonName); - void slotDeleteBt(int buttonIndex, QString buttonName); -private: - void initUI(); - void initConnection(); - void AutoFeed(QString text); -protected: - void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; -// void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; - bool eventFilter(QObject *o, QEvent *e) Q_DECL_OVERRIDE; -// void changeEvent(QEvent *event) Q_DECL_OVERRIDE; -private: - QLabel *m_schceduleLabel = nullptr; - QLabel *m_timeLabel = nullptr; - DSuggestButton *m_editBt = nullptr; - DPushButton *m_deleteBt = nullptr; - DPushButton *m_okBt = nullptr; - QLabel *m_icon; - QLabel *m_Title; - ScheduleDtailInfo m_scheduleInfo;//日程 - QScrollArea *area; - QFont labelF; - QWidget *w; -private: -// void paintLabel(QWidget *label); -}; - -#endif // MYSCHCEDULEVIEW_H diff -Nru dde-calendar-5.7.0.4/src/schcedulectrldlg.cpp dde-calendar-5.7.0.23/src/schcedulectrldlg.cpp --- dde-calendar-5.7.0.4/src/schcedulectrldlg.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/schcedulectrldlg.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,344 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#include "schcedulectrldlg.h" -#include -#include -#include -#include -#include -#include - -#include "schceduledlg.h" -#include "scheduledatamanage.h" -#include "cdynamicicon.h" - -DGUI_USE_NAMESPACE -CSchceduleCtrlDlg::CSchceduleCtrlDlg(QWidget *parent) : DDialog(parent) -{ - setContentsMargins(0, 0, 0, 0); - initUI(); - initConnection(); - int themetype = CScheduleDataManage::getScheduleDataManage()->getTheme(); - if (themetype == 2) { - DPalette anipa = palette(); - QColor color = "#191919"; - color.setAlphaF(0.8); - anipa.setColor(DPalette::Background, color); - setPalette(anipa); - } - - //setTitle(tr("My Schcedule")); - resize(380, 260); - setFocusPolicy(Qt::ClickFocus); -} - -void CSchceduleCtrlDlg::initUI() -{ - - //在点击任何对话框上的按钮后不关闭对话框,保证关闭子窗口时不被一起关掉 - setOnButtonClickedClose(false); - - // m_icon = new QLabel(this); - // m_icon->setFixedSize(32, 32); - //m_icon->setPixmap(DHiDPIHelper::loadNxPixmap(":/resources/icon/dde-logo.svg") - //.scaled(m_icon->size() * devicePixelRatioF())); - //m_icon->move(10, 9); - QIcon t_icon(CDynamicIcon::getInstance()->getPixmap());// = QIcon::fromTheme("dde-calendar"); - setIcon(t_icon); - m_Title = new QLabel(this); - m_Title->setFixedHeight(48); - m_Title->setAlignment(Qt::AlignCenter | Qt::AlignVCenter); - - QFont labelTitle; -// labelTitle.setFamily("SourceHanSansSC"); - labelTitle.setWeight(QFont::Bold); - labelTitle.setPixelSize(17); - int themetype = CScheduleDataManage::getScheduleDataManage()->getTheme(); - - DPalette titlepa = m_Title->palette(); - if (themetype == 0 || themetype == 1) { - titlepa.setColor(DPalette::WindowText, QColor("#001A2E")); - - } else { - titlepa.setColor(DPalette::WindowText, QColor("#C0C6D4")); - } - - m_Title->setPalette(titlepa); - m_Title->setFont(labelTitle); - - - m_mainBoxLayout = new QVBoxLayout(); - m_mainBoxLayout->setMargin(0); - m_mainBoxLayout->setSpacing(0); - //m_mainBoxLayout->setContentsMargins(10, 28, 10, 10); - - m_firstLabel = new QLabel(this); - m_firstLabel->setAlignment(Qt::AlignCenter); - m_firstLabel->setFixedWidth(350); -// m_firstLabel->adjustSize(); - m_firstLabel->setWordWrap(true); - labelF.setWeight(QFont::Medium); - DFontSizeManager::instance()->bind(m_firstLabel,DFontSizeManager::T6); - DPalette wpa = m_firstLabel->palette(); - if (themetype == 0 || themetype == 1) { - wpa.setColor(DPalette::WindowText, QColor("#2C4767")); - - } else { - wpa.setColor(DPalette::WindowText, QColor("#A8B7D1")); - } - m_firstLabel->setPalette(wpa); - m_firstLabel->setForegroundRole(DPalette::WindowText); - m_firstLabel->setFont(labelF); - m_mainBoxLayout->addWidget(m_firstLabel); - - - m_seconLabel = new QLabel(this); - m_seconLabel->setFixedWidth(350); - //m_seconLabel->setFixedHeight(26); - m_seconLabel->setAlignment(Qt::AlignCenter); - labelTitle.setWeight(QFont::Bold); - DFontSizeManager::instance()->bind(m_seconLabel,DFontSizeManager::T6); - DPalette tpa = m_seconLabel->palette(); - if (themetype == 0 || themetype == 1) { - tpa.setColor(DPalette::WindowText, QColor("#6A829F")); - } else { - tpa.setColor(DPalette::WindowText, QColor("#6A829F")); - } - m_seconLabel->setPalette(tpa); - m_seconLabel->setForegroundRole(DPalette::WindowText); - m_seconLabel->setFont(labelT); - m_seconLabel->setWordWrap(true); -// m_seconLabel->adjustSize(); - m_mainBoxLayout->addSpacing(3); - m_mainBoxLayout->addWidget(m_seconLabel); -// m_mainBoxLayout->addSpacing(10); -// m_btBoxLayout = new QHBoxLayout; -// m_btBoxLayout->setMargin(0); -// m_btBoxLayout->setSpacing(0); -// m_btBoxLayout->setContentsMargins(0, 0, 0, 0); -// m_Buttongroup = new QButtonGroup(this); -// m_mainBoxLayout->addLayout(m_btBoxLayout); - DFrame *gwi = new DFrame(this); - gwi->setContentsMargins(0, 0, 0, 0); - gwi->setLayout(m_mainBoxLayout); - DPalette anipa = gwi->palette(); - QColor color = "#F8F8F8"; - color.setAlphaF(0.0); - anipa.setColor(DPalette::Background, color); - gwi->setAutoFillBackground(true); - gwi->setPalette(anipa); - gwi->setBackgroundRole(DPalette::Background); - //gwi->setGeometry(0, 51, 380, 110); - addContent(gwi, Qt::AlignCenter); - setFocus(); -} - -void CSchceduleCtrlDlg::initConnection() -{ - connect(this, &DDialog::buttonClicked, this, &CSchceduleCtrlDlg::buttonJudge); - // connect( m_Buttongroup, SIGNAL(buttonClicked (int)), this, SLOT(buttonJudge(int)) );//连接信号和槽 -} - -void CSchceduleCtrlDlg::changeEvent(QEvent *event) -{ - Q_UNUSED(event) - QFont font; - - QFontMetrics font_button(font); - - QFontMetrics font_firstLabel(font); - QFontMetrics font_seconLabel(font); - int height_firstLabel = (font_firstLabel.width(m_firstLabel->text()) / 300 + 1) * font_firstLabel.height(); - int height_seconLabel = (font_seconLabel.width(m_seconLabel->text()) / 300 + 1) * font_seconLabel.height(); - - for (int i = 0; i < buttonCount(); i++) { - QAbstractButton *button = getButton(i); - QString str = str_btName.at(i); - QString text_button = font_button.elidedText(str, Qt::ElideRight, 112); - if (str.count() == 2) { - button->setText(QString().append(str.at(0)).append(QChar::Nbsp).append(str.at(1))); - } else { - button->setText(text_button); - } - } - - setFixedHeight(36 + 48 + height_firstLabel + height_seconLabel + 30); - -} -//void CSchceduleCtrlDlg::updatesize() -//{ -// if (m_buttonlist.count() == 2) { - -// int w = 0; -// for (int i = 0; i < m_buttonlist.count(); i++) { -// if (m_buttonlist.at(i)->width() > w) { -// w = m_buttonlist.at(i)->width(); -// } -// } -// if (w < 170) w = 170; -// for (int i = 0; i < m_buttonlist.count(); i++) { -// m_buttonlist.at(i)->setFixedWidth(w); -// } -// int rw = w * m_buttonlist.count() + (m_buttonlist.count()) * 23 + 20; -// setFixedWidth(rw); - -// } else { -// int w = 0; -// for (int i = 0; i < m_buttonlist.count(); i++) { -// if (m_buttonlist.at(i)->width() > w) { -// w = m_buttonlist.at(i)->width(); -// } -// } -// for (int i = 0; i < m_buttonlist.count(); i++) { -// m_buttonlist.at(i)->setFixedWidth(w); -// } -// int rw = w * m_buttonlist.count() + (m_buttonlist.count() - 1) * 23 + 20; -// setFixedWidth(rw); -// } -// //rect.setHeight(rect.height()); -// //m_firstLabel->setGeometry(rect); // -// m_firstLabel->adjustSize(); -// //rect = m_seconLabel->geometry(); -// //rect.setHeight(rect.height() * 2); -// // m_seconLabel->setGeometry(rect); // -// m_seconLabel->adjustSize(); -//} - -void CSchceduleCtrlDlg::buttonJudge(int id) -{ - m_id = id; - accept(); -} - -QAbstractButton *CSchceduleCtrlDlg::addPushButton(QString btName, bool type) -{ -// QFont labelTitle; -//// labelTitle.setFamily("SourceHanSansSC"); -// labelTitle.setWeight(QFont::Medium); -// labelTitle = DFontSizeManager::instance()->get(DFontSizeManager::T6,labelTitle); -//// labelTitle.setPixelSize(14); -// QFontMetrics fm(labelTitle); -// int w = fm.width(btName); -// if (w > 109) w = w + 18; -// else { -// w = 109; -// } -// button = new DPushButton(btName); -// DFontSizeManager::instance()->bind(button,DFontSizeManager::T6); -// QFontMetrics font_button(labelTitle); -// QString text_button = font_button.elidedText(btName,Qt::ElideRight,112); -// button->setText(text_button); -// button->setToolTip(btName); -// button->setFixedWidth(129); -// button->setFixedHeight(36); -// button->setFont(labelTitle); -// m_Buttongroup->addButton(button, m_Buttongroup->buttons().count()); -// if (m_Buttongroup->buttons().count() > 1) { -// DVerticalLine *btframe = new DVerticalLine(this); -// m_btBoxLayout->addSpacing(4); -// btframe->setFixedSize(3, 28); -// m_btBoxLayout->addWidget(btframe, 0, Qt::AlignCenter); -// if (type == 1) { -// m_btBoxLayout->addSpacing(4); -// } else { -// m_btBoxLayout->addSpacing(4); -// } - -// } - -// m_btBoxLayout->addWidget(button, 0, Qt::AlignCenter); -// m_buttonlist.append(button); - - addButton(btName, false, DDialog::ButtonNormal); - int button_index = getButtonIndexByText(btName); - QAbstractButton *button = getButton(button_index); - if (type) { - button->setFixedHeight(36); - button->setFixedWidth(165); - } else { - button->setFixedHeight(36); - button->setFixedWidth(129); - } - - button->setToolTip(btName); - - str_btName.append(btName); - - return button; -} - -QAbstractButton *CSchceduleCtrlDlg::addsuggestButton(QString btName, bool type) -{ - addButton(btName,false,DDialog::ButtonRecommend); - int button_index = getButtonIndexByText(btName); - QAbstractButton *suggestButton = getButton(button_index); - if (type) { - suggestButton->setFixedHeight(36); - suggestButton->setFixedWidth(165); - } else { - suggestButton->setFixedHeight(36); - suggestButton->setFixedWidth(129); - } - suggestButton->setToolTip(btName); - - str_btName.append(btName); - - return suggestButton; -} - -QAbstractButton *CSchceduleCtrlDlg::addWaringButton(QString btName, bool type) -{ -// m_firstLabel->setFixedWidth(300); - addButton(btName,false,DDialog::ButtonWarning); - int button_index = getButtonIndexByText(btName); - QAbstractButton *suggestButton = getButton(button_index); - if (type) { - suggestButton->setFixedHeight(36); - suggestButton->setFixedWidth(165); - } else { - suggestButton->setFixedHeight(36); - suggestButton->setFixedWidth(129); - } - suggestButton->setToolTip(btName); - - str_btName.append(btName); - - return suggestButton; -} - -void CSchceduleCtrlDlg::setText(QString str) -{ - m_firstLabel->setText(str); - m_firstLabel->setToolTip(str); -} - -void CSchceduleCtrlDlg::setInformativeText(QString str) -{ - m_seconLabel->setText(str); - m_seconLabel->setToolTip(str); -} - -int CSchceduleCtrlDlg::clickButton() -{ -// if (m_id < 0 || m_id > m_buttonlist.count() - 1) return nullptr; -// return m_buttonlist[m_id]; - if (m_id < 0 || m_id > buttonCount() - 1) return buttonCount(); - return m_id; -} - diff -Nru dde-calendar-5.7.0.4/src/schcedulectrldlg.h dde-calendar-5.7.0.23/src/schcedulectrldlg.h --- dde-calendar-5.7.0.4/src/schcedulectrldlg.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/schcedulectrldlg.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#ifndef CSCHCEDULECTRLDLG_H -#define CSCHCEDULECTRLDLG_H - -#include -#include -#include -#include -#include -#include -#include -#include -DWIDGET_USE_NAMESPACE - -class CSchceduleCtrlDlg : public DDialog -{ - Q_OBJECT -public: - explicit CSchceduleCtrlDlg(QWidget *parent = nullptr); - QAbstractButton *addPushButton(QString btName, bool type = false); - QAbstractButton *addsuggestButton(QString btName, bool type = false); - QAbstractButton *addWaringButton(QString btName, bool type = false); - void setTitleName(QString tileName); - void setText(QString str); - void setInformativeText(QString str); - int clickButton(); -// void updatesize(); -private: - void initUI(); - void initConnection(); - -protected: - void changeEvent(QEvent *event) Q_DECL_OVERRIDE; -private slots: - void buttonJudge(int id); -private: - QLabel *m_firstLabel = nullptr; - QLabel *m_seconLabel = nullptr; - QLabel *m_icon; - QLabel *m_Title; - int m_id = -1; - QButtonGroup *m_Buttongroup; - QVector m_buttonlist; - QVBoxLayout *m_mainBoxLayout; - QHBoxLayout *m_btBoxLayout; - QFont labelF; - QFont labelT; - QVector str_btName; -}; - -#endif // MYSCHCEDULEVIEW_H diff -Nru dde-calendar-5.7.0.4/src/schceduledlg.cpp dde-calendar-5.7.0.23/src/schceduledlg.cpp --- dde-calendar-5.7.0.4/src/schceduledlg.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/schceduledlg.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,1239 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#include "schceduledlg.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "schcedulectrldlg.h" -#include "scheduledatamanage.h" -#include "timeedit.h" -DGUI_USE_NAMESPACE -CSchceduleDlg::CSchceduleDlg(int type, QWidget *parent, const bool isAllDay) - : DDialog(parent), m_createAllDay(isAllDay) -{ - setContentsMargins(0, 0, 0, 0); - m_type = type; - initUI(); -// if (m_type == 0 && isAllDay) { -// m_allDayCheckbox->setChecked(true); -// m_beginTimeEdit->setVisible(false); -// m_endTimeEdit->setVisible(false); -// } - initConnection(); - if (type == 1) { - m_titleLabel->setText(tr("New Event")); - m_beginDateEdit->setDate(QDate::currentDate()); - int hours = QTime::currentTime().hour(); - int minnutes = QTime::currentTime().minute() % 15; - if (minnutes != 0) { - minnutes = QTime::currentTime().minute() / 15 * 15 + 15; - } - m_beginTimeEdit->setTime(QTime(hours, minnutes)); - m_endDateEdit->setDate(QDate::currentDate()); - m_endTimeEdit->setTime(QTime(hours, minnutes).addSecs(3600)); - // m_endRepeatDate->setMinimumDate(QDate::currentDate()); - } else { - m_titleLabel->setText(tr("Edit Event")); - } - setFocusPolicy(Qt::WheelFocus); - setFixedSize(438, 470); -} - -CSchceduleDlg::~CSchceduleDlg() -{ - emit signalViewtransparentFrame(0); -} - -void CSchceduleDlg::setData(const ScheduleDtailInfo &info) -{ - m_scheduleDtailInfo = info; - m_typeComBox->setCurrentIndex(info.type.ID - 1); - m_textEdit->setPlainText(info.titleName); - m_beginDateEdit->setDate(info.beginDateTime.date()); - m_beginTimeEdit->setTime(info.beginDateTime.time()); - m_endDateEdit->setDate(info.endDateTime.date()); - m_endTimeEdit->setTime(info.endDateTime.time()); - m_allDayCheckbox->setChecked(info.allday); - m_endRepeatDate->setMinimumDate(info.beginDateTime.date()); - - m_currentDate = info.beginDateTime; - m_EndDate = info.endDateTime; - - slotallDayStateChanged(info.allday); - initRmindRpeatUI(); - - // m_textEdit->setTextCursor() -} - -void CSchceduleDlg::setDate(const QDateTime &date) -{ - m_currentDate = date; - int hours = date.time().hour(); - int minnutes = 0; - if (date.date() == QDate::currentDate()) { - minnutes = date.time().minute() % 15; -// if (minnutes != 0) { - minnutes = (date.time().minute() / 15 + 1) * 15; -// }else { - -// } - } else { - int minnutes = date.time().minute() % 15; - if (minnutes != 0) { - minnutes = (date.time().minute() / 15 + 1) * 15; - } - } - if (minnutes == 60) { - if (hours + 1 == 24) { - m_currentDate.setTime(QTime(0, 0)); - m_currentDate = m_currentDate.addDays(1); - } else { - m_currentDate.setTime(QTime(hours + 1, 0)); - } - } else { - m_currentDate.setTime(QTime(hours, minnutes)); - } - - m_beginDateEdit->setDate(m_currentDate.date()); - m_beginTimeEdit->setTime(m_currentDate.time()); - QDateTime datetime = m_currentDate.addSecs(3600); - m_EndDate = datetime; - m_endDateEdit->setDate(datetime.date()); - m_endTimeEdit->setTime(datetime.time()); - m_endRepeatDate->setMinimumDate(date.date()); -} - -ScheduleDtailInfo CSchceduleDlg::getScheduleData() -{ - return m_scheduleDtailInfo; -} - -void CSchceduleDlg::setAllDay(bool flag) -{ - m_allDayCheckbox->setChecked(flag); -} - -void CSchceduleDlg::slotCancelBt(int buttonIndex, QString buttonName) -{ - if (buttonIndex != 0 && buttonName != "Cancel") - return; - - reject(); -} - -void CSchceduleDlg::slotOkBt(int buttonIndex, QString buttonName) -{ - if (buttonIndex != 1 && buttonName != "Save") - return; - - int themetype = CScheduleDataManage::getScheduleDataManage()->getTheme(); - - ScheduleDtailInfo scheduleDtailInfo = m_scheduleDtailInfo; - QDateTime beginDateTime, endDateTime; - beginDateTime.setDate(m_beginDateEdit->date()); - beginDateTime.setTime(m_beginTimeEdit->getTime()); - endDateTime.setDate(m_endDateEdit->date()); - endDateTime.setTime(m_endTimeEdit->getTime()); - if (m_textEdit->toPlainText().isEmpty()) { - scheduleDtailInfo.titleName = m_textEdit->placeholderText(); - } else { - scheduleDtailInfo.titleName = m_textEdit->toPlainText(); - } - - if (scheduleDtailInfo.titleName.isEmpty()) { - // QMessageBox::warning(this, tr("error"), tr("The event is empty!")); - return; - } - if (beginDateTime > endDateTime) { - // QMessageBox::information(this, (" "), tr("End time must be greater than start - // time")); - DDialog *prompt = new DDialog(this); - prompt->setIcon(QIcon(":/resources/icon/warning.svg")); - prompt->setMessage(tr("End time must be greater than start time")); - prompt->setWindowFlags(prompt->windowFlags() | Qt::WindowStaysOnTopHint); - prompt->addButton(tr("OK"), true, DDialog::ButtonNormal); - prompt->exec(); - return; - } - if (m_type == 1) - scheduleDtailInfo.id = 0; - scheduleDtailInfo.allday = m_allDayCheckbox->isChecked(); - if (m_rmindCombox->currentIndex() == 0) - scheduleDtailInfo.remind = false; - else { - scheduleDtailInfo.remind = true; - } - if (scheduleDtailInfo.allday) { - if (scheduleDtailInfo.remind) { - scheduleDtailInfo.remindData.time = QTime(9, 0); - if (m_rmindCombox->currentIndex() == 1) { - scheduleDtailInfo.remindData.n = 0; - } else if (m_rmindCombox->currentIndex() == 2) { - scheduleDtailInfo.remindData.n = 1; - } else if (m_rmindCombox->currentIndex() == 3) { - scheduleDtailInfo.remindData.n = 2; - } else if (m_rmindCombox->currentIndex() == 4) { - scheduleDtailInfo.remindData.n = 7; - } - } - } else { - if (scheduleDtailInfo.remind) { - if (m_rmindCombox->currentIndex() == 1) { - scheduleDtailInfo.remindData.n = 0; - } else if (m_rmindCombox->currentIndex() == 2) { - scheduleDtailInfo.remindData.n = 15; - } else if (m_rmindCombox->currentIndex() == 3) { - scheduleDtailInfo.remindData.n = 30; - } else if (m_rmindCombox->currentIndex() == 4) { - scheduleDtailInfo.remindData.n = 60; - } else if (m_rmindCombox->currentIndex() == 5) { - scheduleDtailInfo.remindData.n = 1440; - } else if (m_rmindCombox->currentIndex() == 6) { - scheduleDtailInfo.remindData.n = 2880; - } else if (m_rmindCombox->currentIndex() == 7) { - scheduleDtailInfo.remindData.n = 10080; - } - } - } - scheduleDtailInfo.rpeat = m_beginrepeatCombox->currentIndex(); - if (scheduleDtailInfo.rpeat != 0) { - scheduleDtailInfo.enddata.type = m_endrepeatCombox->currentIndex(); - if (m_endrepeatCombox->currentIndex() == 1) { - if (m_endrepeattimes->text().isEmpty()) { - // QMessageBox::warning(this, tr("error"), tr("The end repeat times is null!")); - return; - } - scheduleDtailInfo.enddata.tcount = m_endrepeattimes->text().toInt(); - } else if (m_endrepeatCombox->currentIndex() == 2) { - QDateTime endrpeattime = beginDateTime; - endrpeattime.setDate(m_endRepeatDate->date()); - if (beginDateTime > endrpeattime) { - // QMessageBox::warning(this, tr("error"), tr("The end repeat time less than begin - // time!")); - return; - } - scheduleDtailInfo.enddata.date = endrpeattime; - } - } - - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->GetType( - m_typeComBox->currentIndex() + 1, scheduleDtailInfo.type); - scheduleDtailInfo.beginDateTime = beginDateTime; - scheduleDtailInfo.endDateTime = endDateTime; - - if (m_type == 1) { - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->addSchedule( - scheduleDtailInfo); - } else if (m_type == 0) { - if (m_scheduleDtailInfo.rpeat == 0 && - m_scheduleDtailInfo.rpeat == scheduleDtailInfo.rpeat) { - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo( - scheduleDtailInfo); - - } else { - if (m_scheduleDtailInfo.allday != scheduleDtailInfo.allday) { - CSchceduleCtrlDlg msgBox/*(this)*/; - msgBox.setText( - tr("All occurrences of a repeating event must have the same all-day status.")); - msgBox.setInformativeText(tr("Do you want to change all occurrences?")); - /*QAbstractButton *noButton = */msgBox.addPushButton(tr("Cancel"), true); - /*QAbstractButton *yesButton = */msgBox.addWaringButton(tr("Change All"), true); -// msgBox.updatesize(); -// DPalette pa = yesButton->palette(); -// if (themetype == 0 || themetype == 1) { -// pa.setColor(DPalette::ButtonText, Qt::red); - -// } else { -// pa.setColor(DPalette::ButtonText, "#FF5736"); -// } -// yesButton->setPalette(pa); - msgBox.exec(); - - if (msgBox.clickButton() == 0) { - return; - } else if (msgBox.clickButton() == 1) { -// ScheduleDtailInfo updatescheduleData; -// CScheduleDataManage::getScheduleDataManage() -// ->getscheduleDataCtrl() -// ->getScheduleInfoById(scheduleDtailInfo.id, updatescheduleData); -// scheduleDtailInfo.beginDateTime = updatescheduleData.beginDateTime; -// scheduleDtailInfo.endDateTime = updatescheduleData.endDateTime; -// scheduleDtailInfo.RecurID = updatescheduleData.RecurID; - CScheduleDataManage::getScheduleDataManage() - ->getscheduleDataCtrl() - ->updateScheduleInfo(scheduleDtailInfo); - } - - } else if (m_scheduleDtailInfo.rpeat != scheduleDtailInfo.rpeat) { - CSchceduleCtrlDlg msgBox/*(this)*/; - msgBox.setText(tr("You are changing the repeating rule of this event.")); - msgBox.setInformativeText(tr("Do you want to change all occurrences?")); - /*QAbstractButton *noButton = */msgBox.addPushButton(tr("Cancel"), true); - /*QAbstractButton *yesButton = */msgBox.addWaringButton(tr("Change All"), true); -// msgBox.updatesize(); -// DPalette pa = yesButton->palette(); -// if (themetype == 0 || themetype == 1) { -// pa.setColor(DPalette::ButtonText, Qt::red); - -// } else { -// pa.setColor(DPalette::ButtonText, "#FF5736"); -// } -// yesButton->setPalette(pa); - msgBox.exec(); - - if (msgBox.clickButton() == 0) { - return; - } else if (msgBox.clickButton() == 1) { - CScheduleDataManage::getScheduleDataManage() - ->getscheduleDataCtrl() - ->updateScheduleInfo(scheduleDtailInfo); - } - } else { - ChangeRecurInfo(this,scheduleDtailInfo,m_scheduleDtailInfo,themetype); - } - } - } - accept(); - emit signalScheduleUpdate(); -} - -void CSchceduleDlg::slotTextChange() -{ - QTextCursor cursor = m_textEdit->textCursor(); - QString textContent = m_textEdit->toPlainText(); - int length = textContent.count(); - QString tStitlename = textContent; - if (tStitlename.contains("\n")) { - tStitlename.replace("\n", ""); - m_textEdit->setText(tStitlename); - cursor.movePosition(QTextCursor::End); - m_textEdit->setTextCursor(cursor); - return; - } - int maxLength = 256; // 最大字符数 - if (length > maxLength) { - // QMessageBox::information(this, tr("infomation"), tr("Max length is 256!")); - m_textEdit->setText(m_context); - cursor.movePosition(QTextCursor::End); - m_textEdit->setTextCursor(cursor); - /*textContent = textContent.mid(0, 256); - m_textEdit->setText(textContent); - cursor.movePosition(QTextCursor::End); - //if (cursor.hasSelection()) { - // cursor.clearSelection(); - //} - //cursor.deletePreviousChar(); - //设置当前的光标为更改后的光标 - m_textEdit->setTextCursor(cursor);*/ - } - m_context = m_textEdit->toPlainText(); -} - -void CSchceduleDlg::slotendrepeatTextchange() -{ - QAbstractButton *m_OkBt = getButton(1); - if (m_endrepeattimes->text().isEmpty()) - m_OkBt->setEnabled(false); - else - m_OkBt->setEnabled(true); -} - -void CSchceduleDlg::slotBDateEidtInfo(const QDate &date) -{ - m_beginDateEdit->setDate(date); - m_endRepeatDate->setMinimumDate(date); - m_endDateEdit->setMinimumDate(date); - - QDateTime beginDateTime, endDateTime; - beginDateTime.setDate(m_beginDateEdit->date()); - beginDateTime.setTime(m_beginTimeEdit->getTime()); - endDateTime.setDate(m_endDateEdit->date()); - endDateTime.setTime(m_endTimeEdit->getTime()); - - if (endDateTime < beginDateTime) { - m_endTimeEdit->setTime(m_beginTimeEdit->getTime().addSecs(3600)); - } -} - -void CSchceduleDlg::slotEDateEidtInfo(const QDate &date) -{ - m_endDateEdit->setDate(date); -} - -void CSchceduleDlg::slotallDayStateChanged(int state) -{ - m_rmindCombox->clear(); - if (!state) { - m_rmindCombox->addItem(tr("Never")); - m_rmindCombox->addItem(tr("At time of event")); - m_rmindCombox->addItem(tr("15 minutes before")); - m_rmindCombox->addItem(tr("30 minutes before")); - m_rmindCombox->addItem(tr("1 hour before")); - m_rmindCombox->addItem(tr("1 day before")); - m_rmindCombox->addItem(tr("2 days before")); - m_rmindCombox->addItem(tr("1 week before")); - m_beginTimeEdit->setVisible(true); - m_endTimeEdit->setVisible(true); - if (m_type == 0) { - m_beginDateEdit->setDate(m_scheduleDtailInfo.beginDateTime.date()); - m_beginTimeEdit->setTime(m_scheduleDtailInfo.beginDateTime.time()); - m_endDateEdit->setDate(m_scheduleDtailInfo.endDateTime.date()); - m_endTimeEdit->setTime(m_scheduleDtailInfo.endDateTime.time()); - } else { - m_beginDateEdit->setDate(m_currentDate.date()); - m_beginTimeEdit->setTime(m_currentDate.time()); - m_endDateEdit->setDate(m_EndDate.date()); - m_endTimeEdit->setTime(m_EndDate.time()); - } - } else { - m_rmindCombox->addItem(tr("Never")); - m_rmindCombox->addItem(tr("On start day (9:00 AM)")); - m_rmindCombox->addItem(tr("1 day before")); - m_rmindCombox->addItem(tr("2 days before")); - m_rmindCombox->addItem(tr("1 week before")); - m_beginTimeEdit->setVisible(false); - m_endTimeEdit->setVisible(false); - if (m_type == 0) { - m_beginDateEdit->setDate(m_scheduleDtailInfo.beginDateTime.date()); - m_beginTimeEdit->setTime(QTime(0, 0)); - m_endDateEdit->setDate(m_scheduleDtailInfo.endDateTime.date()); - m_endTimeEdit->setTime(QTime(23, 59)); - } else { - m_beginDateEdit->setDate(m_currentDate.date()); - m_endDateEdit->setDate(m_EndDate.date()); - m_beginTimeEdit->setTime(QTime(0, 0)); - m_endTimeEdit->setTime(QTime(23, 59)); - m_rmindCombox->setCurrentIndex(2); - } - } -} - -void CSchceduleDlg::slotbRpeatactivated(int index) -{ - if (index > 0) { - m_endrepeatWidget->setVisible(true); - setFixedSize(438, 506); - // m_gwi->setGeometry(0, 68, 438, 458); - } else { - m_endrepeatWidget->setVisible(false); - setFixedSize(438, 470); - // m_gwi->setGeometry(0, 68, 438, 412); - } -} - -void CSchceduleDlg::sloteRpeatactivated(int index) -{ - if (index == 0) { - m_endrepeattimesWidget->setVisible(false); - m_endRepeatDate->setVisible(false); - } else if (index == 1) { - m_endrepeattimesWidget->setVisible(true); - m_endRepeatDate->setVisible(false); - } else { - m_endrepeattimesWidget->setVisible(false); - m_endRepeatDate->setVisible(true); - } -} - -bool CSchceduleDlg::eventFilter(QObject *obj, QEvent *pEvent) -{ - if (obj == m_textEdit) { - if (pEvent->type() == QEvent::KeyPress) { - QKeyEvent *keyEvent = static_cast(pEvent); - if (keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Enter) { - return true; - } - if (keyEvent->key() == Qt::Key_Tab) - return true; - /*QString textContent = m_textEdit->toPlainText(); - int length = textContent.count(); - int maxLength = 255; // 最大字符数 - if (length > maxLength) { - - QMessageBox::information(this, tr("infomation"), tr("Max length is 256!")); - return true; - }*/ - } - if (m_type == 1) { - if (pEvent->type() == QEvent::FocusIn) { - //清空编辑框默认占位符 - m_textEdit->setPlaceholderText(""); - } else if (pEvent->type() == QEvent::FocusOut) { - //设置编辑框默认占位符 - m_textEdit->setPlaceholderText(tr("New event")); - } - } - } - return QDialog::eventFilter(obj, pEvent); -} - -void CSchceduleDlg::showEvent(QShowEvent *event) -{ - Q_UNUSED(event); - emit signalViewtransparentFrame(1); -} - -void CSchceduleDlg::changeEvent(QEvent *event) -{ - Q_UNUSED(event); - QFont mlabelF; - mlabelF.setWeight(QFont::Medium); - - QFontMetrics fontWidth_typeLabel(mlabelF); - QString str_typelabel = fontWidth_typeLabel.elidedText(tr("Type:"),Qt::ElideRight,70); - m_typeLabel->setText(str_typelabel); - - QFontMetrics fontWidth_contentlabel(mlabelF); - QString str_contentlabel = fontWidth_contentlabel.elidedText(tr("Description:"),Qt::ElideRight,70); - m_contentLabel->setText(str_contentlabel); - - QFontMetrics fontWidth_allDayLabel(mlabelF); - QString str_allDayLabel = fontWidth_allDayLabel.elidedText(tr("All Day:"), Qt::ElideRight, 70); - m_adllDayLabel->setText(str_allDayLabel); - - QFontMetrics fontWidth_beginTimeLabel(mlabelF); - QString str_beginTimeLabel = fontWidth_beginTimeLabel.elidedText(tr("Starts:"), Qt::ElideRight, 70); - m_beginTimeLabel->setText(str_beginTimeLabel); - - QFontMetrics fontWidth_endTimeLabel(mlabelF); - QString str_endTimeLabel = fontWidth_endTimeLabel.elidedText(tr("Ends:"), Qt::ElideRight, 70); - m_endTimeLabel->setText(str_endTimeLabel); - - QFontMetrics fontWidth_remindSetLabel(mlabelF); - QString str_remindSetLabel = fontWidth_remindSetLabel.elidedText(tr("Remind Me:"),Qt::ElideRight,70); - m_remindSetLabel->setText(str_remindSetLabel); - - QFontMetrics fontWidth_beginRepeatLabel(mlabelF); - QString str_beginRepeatLabel = fontWidth_beginRepeatLabel.elidedText(tr("Repeat:"), Qt::ElideRight, 70); - m_beginrepeatLabel->setText(str_beginRepeatLabel); - - QFontMetrics fontWidth_endrepeatLabel(mlabelF); - QString str_endrepeatLabel = fontWidth_endrepeatLabel.elidedText(tr("End Repeat:"),Qt::ElideRight,70); - m_endrepeatLabel->setText(str_endrepeatLabel); -} - -void CSchceduleDlg::initUI() -{ - //在点击任何对话框上的按钮后不关闭对话框,保证关闭子窗口时不被一起关掉 - setOnButtonClickedClose(false); - - m_titleLabel = new QLabel(this); - QFont titlelabelF; -// titlelabelF.setFamily("SourceHanSansSC"); - titlelabelF.setWeight(QFont::DemiBold); - titlelabelF.setPixelSize(17); - QColor btitleColor = "#000000"; - btitleColor.setAlphaF(0.01); - DPalette titlepa = m_titleLabel->palette(); - int themetype = CScheduleDataManage::getScheduleDataManage()->getTheme(); - if (themetype == 0 || themetype == 1) { - titlepa.setColor(DPalette::WindowText, QColor("#001A2E")); - titlepa.setColor(DPalette::Window, btitleColor); - } else { - titlepa.setColor(DPalette::WindowText, QColor("#C0C6D4")); - titlepa.setColor(DPalette::Window, btitleColor); - } - m_titleLabel->setPalette(titlepa); - m_titleLabel->setFixedSize(148, 51); - m_titleLabel->setAlignment(Qt::AlignCenter | Qt::AlignVCenter); - // m_titleLabel->setGeometry(165, 0, 108, 51); - m_titleLabel->move(145, 0); - m_titleLabel->setFont(titlelabelF); - - setSpacing(0); - QFont mlabelF; -// mlabelF.setFamily("SourceHanSansSC"); - mlabelF.setWeight(QFont::Medium); -// mlabelF.setPixelSize(14); - DPalette pa = m_titleLabel->palette(); - if (themetype == 0 || themetype == 1) { - pa.setColor(DPalette::WindowText, QColor("#414D68")); - } else { - pa.setColor(DPalette::WindowText, QColor("#C0C6D4")); - } - // pa.setColor(DPalette::WindowText, QColor("#414D68")); - - QVBoxLayout *maintlayout = new QVBoxLayout; - maintlayout->setMargin(0); - maintlayout->setSpacing(10); - QHBoxLayout *typelayout = new QHBoxLayout; - typelayout->setSpacing(0); - typelayout->setMargin(0); - // maintlayout->setContentsMargins(20, 0, 20, 10); - m_typeLabel = new QLabel(); - m_typeLabel->setToolTip(tr("Type")); - DFontSizeManager::instance()->bind(m_typeLabel,DFontSizeManager::T6); - QFontMetrics fontWidth_typeLabel(mlabelF); - QString str_typelabel = fontWidth_typeLabel.elidedText(tr("Type:"),Qt::ElideRight,70); - m_typeLabel->setText(str_typelabel); - m_typeLabel->setFont(mlabelF); - m_typeLabel->setPalette(pa); - m_typeLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); - m_typeLabel->setFixedSize(78, 36); - m_typeComBox = new DComboBox(); - m_typeComBox->setFixedSize(319, 36); - m_typeComBox->setIconSize(QSize(24,24)); - m_typeComBox->insertItem(0, - QIcon(DHiDPIHelper::loadNxPixmap(":/resources/icon/icon_type_work.svg") - .scaled(QSize(24, 24) * devicePixelRatioF())), - tr("Work")); - m_typeComBox->insertItem(1, - QIcon(DHiDPIHelper::loadNxPixmap(":/resources/icon/icon_type_life.svg") - .scaled(QSize(24, 24) * devicePixelRatioF())), - tr("Life")); - m_typeComBox->insertItem( - 2, - QIcon(DHiDPIHelper::loadNxPixmap(":/resources/icon/icon_type_other.svg") - .scaled(QSize(24, 24) * devicePixelRatioF())), - tr("Other")); - typelayout->addWidget(m_typeLabel); - typelayout->addWidget(m_typeComBox); - maintlayout->addLayout(typelayout); - - QHBoxLayout *contentLabellayout = new QHBoxLayout; - contentLabellayout->setSpacing(0); - contentLabellayout->setMargin(0); - QVBoxLayout *conttelabellayout = new QVBoxLayout; - conttelabellayout->setSpacing(0); - conttelabellayout->setMargin(0); - m_contentLabel = new QLabel(); - DFontSizeManager::instance()->bind(m_contentLabel,DFontSizeManager::T6); - QFontMetrics fontWidth_contentlabel(mlabelF); - QString str_contentlabel = fontWidth_contentlabel.elidedText(tr("Description:"),Qt::ElideRight,70); - m_contentLabel->setText(str_contentlabel); - m_contentLabel->setFont(mlabelF); - m_contentLabel->setPalette(pa); - m_contentLabel->setToolTip(tr("Description")); - m_contentLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); - m_contentLabel->setFixedWidth(78); - conttelabellayout->addWidget(m_contentLabel); - conttelabellayout->addStretch(); - m_textEdit = new DTextEdit(this); - m_textEdit->setFixedSize(319, 86); - m_textEdit->setAcceptRichText(false); - -#if 0 - m_textEdit->setTextBackgroundColor(Qt::white); - DPalette tpa = m_textEdit->palette(); - if (themetype == 0 || themetype == 1) { - QColor conttelc("#000000"); - conttelc.setAlphaF(0.08); - tpa.setColor(DPalette::Background, conttelc); - } else { - QColor conttelc("#FFFFFF"); - conttelc.setAlphaF(0.15); - tpa.setColor(DPalette::Background, conttelc); - QTextCharFormat fmt; - conttelc.setAlphaF(0.0); - - QTextCursor textcursor = m_textEdit->textCursor(); - fmt = textcursor.charFormat(); - fmt.setBackground(conttelc); - textcursor.setCharFormat(fmt); - m_textEdit->setTextCursor(textcursor); - } - - m_textEdit->setPalette(tpa); -#endif - - // if (m_type == 1) { - m_textEdit->setPlaceholderText(tr("New Event")); - //设置关联控件,用于QTextEdit控件捕获MouseButtonPress等事件 - QWidget *mpContentWidget = m_textEdit->viewport(); - //设置事件过滤器 - m_textEdit->installEventFilter(this); - mpContentWidget->installEventFilter(this); - //} - - contentLabellayout->addLayout(conttelabellayout); - contentLabellayout->addWidget(m_textEdit); - maintlayout->addLayout(contentLabellayout); - - QHBoxLayout *alldayLabellayout = new QHBoxLayout; - alldayLabellayout->setSpacing(0); - alldayLabellayout->setMargin(0); - m_adllDayLabel = new QLabel(); - m_adllDayLabel->setToolTip(tr("All Day")); - DFontSizeManager::instance()->bind(m_adllDayLabel,DFontSizeManager::T6); - QFontMetrics fontWidth_allDayLabel(mlabelF); - QString str_allDayLabel = fontWidth_allDayLabel.elidedText(tr("All Day:"), Qt::ElideRight, 70); - m_adllDayLabel->setText(str_allDayLabel); - m_adllDayLabel->setFont(mlabelF); - m_adllDayLabel->setPalette(pa); - m_adllDayLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); - m_adllDayLabel->setFixedWidth(78); - m_allDayCheckbox = new DCheckBox(this); - alldayLabellayout->addWidget(m_adllDayLabel); - alldayLabellayout->addWidget(m_allDayCheckbox); - maintlayout->addLayout(alldayLabellayout); - - QHBoxLayout *beginLabellayout = new QHBoxLayout; - beginLabellayout->setSpacing(0); - beginLabellayout->setMargin(0); - m_beginTimeLabel = new QLabel(); - m_beginTimeLabel->setToolTip(tr("Starts")); - DFontSizeManager::instance()->bind(m_beginTimeLabel,DFontSizeManager::T6); - QFontMetrics fontWidth_beginTimeLabel(mlabelF); - QString str_beginTimeLabel = fontWidth_beginTimeLabel.elidedText(tr("Starts:"), Qt::ElideRight, 70); - m_beginTimeLabel->setText(str_beginTimeLabel); - m_beginTimeLabel->setFont(mlabelF); - m_beginTimeLabel->setPalette(pa); - m_beginTimeLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); - m_beginTimeLabel->setFixedSize(78, 36); - m_beginDateEdit = new QDateEdit(this); - m_beginDateEdit->setFixedSize(175, 36); - - m_beginTimeEdit = new CTimeEdit(this); - m_beginTimeEdit->setFixedSize(141, 36); - m_beginDateEdit->setCalendarPopup(true); - m_beginDateEdit->setDisplayFormat("yyyy-MM-dd"); - // QHBoxLayout *begintimeelayout = new QHBoxLayout; - // begintimeelayout->addWidget(m_beginDateEdit, 1); - // begintimeelayout->addWidget(m_beginTimeEdit, 1); - // begintimeelayout->setMargin(0); - // begintimeelayout->setSpacing(0); - // begintimeelayout->addStretch(); - beginLabellayout->addWidget(m_beginTimeLabel); - beginLabellayout->addWidget(m_beginDateEdit); - beginLabellayout->addSpacing(8); - beginLabellayout->addWidget(m_beginTimeEdit); - beginLabellayout->addStretch(); - // beginLabellayout->addLayout(begintimeelayout); - maintlayout->addLayout(beginLabellayout); - - QHBoxLayout *enQLabellayout = new QHBoxLayout; - enQLabellayout->setSpacing(0); - enQLabellayout->setMargin(0); - m_endTimeLabel = new QLabel(); - m_endTimeLabel->setToolTip(tr("Ends")); - DFontSizeManager::instance()->bind(m_endTimeLabel,DFontSizeManager::T6); - QFontMetrics fontWidth_endTimeLabel(mlabelF); - QString str_endTimeLabel = fontWidth_endTimeLabel.elidedText(tr("Ends:"), Qt::ElideRight, 70); - m_endTimeLabel->setText(str_endTimeLabel); - m_endTimeLabel->setFont(mlabelF); - m_endTimeLabel->setPalette(pa); - m_endTimeLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); - m_endTimeLabel->setFixedSize(78, 36); - m_endDateEdit = new QDateEdit(this); - m_endDateEdit->setFixedSize(175, 36); - m_endTimeEdit = new CTimeEdit(this); - m_endTimeEdit->setFixedSize(141, 36); - m_endDateEdit->setCalendarPopup(true); - m_endDateEdit->setDisplayFormat("yyyy-MM-dd"); - - enQLabellayout->addWidget(m_endTimeLabel); - enQLabellayout->addWidget(m_endDateEdit); - enQLabellayout->addSpacing(8); - - enQLabellayout->addWidget(m_endTimeEdit); - enQLabellayout->addStretch(); - // enQLabellayout->addLayout(endtimeelayout); - maintlayout->addLayout(enQLabellayout); - - QHBoxLayout *rminQLabellayout = new QHBoxLayout; - rminQLabellayout->setSpacing(0); - rminQLabellayout->setMargin(0); - m_remindSetLabel = new QLabel(); - DFontSizeManager::instance()->bind(m_remindSetLabel,DFontSizeManager::T6); - QFontMetrics fontWidth_remindSetLabel(mlabelF); - QString str_remindSetLabel = fontWidth_remindSetLabel.elidedText(tr("Remind Me:"),Qt::ElideRight,70); - m_remindSetLabel->setToolTip(tr("Remind Me")); - m_remindSetLabel->setText(str_remindSetLabel); - m_remindSetLabel->setFont(mlabelF); - m_remindSetLabel->setPalette(pa); - m_remindSetLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); - m_remindSetLabel->setFixedWidth(78); - - m_rmindCombox = new DComboBox(); - m_rmindCombox->setFixedSize(175, 36); - m_rmindCombox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - rminQLabellayout->addWidget(m_remindSetLabel); - rminQLabellayout->addWidget(m_rmindCombox); - rminQLabellayout->addStretch(); - maintlayout->addLayout(rminQLabellayout); - - QHBoxLayout *repeatLabellayout = new QHBoxLayout; - repeatLabellayout->setSpacing(0); - repeatLabellayout->setMargin(0); - m_beginrepeatLabel = new QLabel(); - m_beginrepeatLabel->setToolTip(tr("Repeat")); - DFontSizeManager::instance()->bind(m_beginrepeatLabel,DFontSizeManager::T6); - QFontMetrics fontWidth_beginRepeatLabel(mlabelF); - QString str_beginRepeatLabel = fontWidth_beginRepeatLabel.elidedText(tr("Repeat:"), Qt::ElideRight, 70); - m_beginrepeatLabel->setText(str_beginRepeatLabel); - m_beginrepeatLabel->setFont(mlabelF); - m_beginrepeatLabel->setPalette(pa); - m_beginrepeatLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); - m_beginrepeatLabel->setFixedWidth(78); - m_beginrepeatCombox = new DComboBox(); - m_beginrepeatCombox->setFixedSize(175, 36); - m_beginrepeatCombox->addItem(tr("Never")); - m_beginrepeatCombox->addItem(tr("Daily")); - m_beginrepeatCombox->addItem(tr("Weekdays")); - m_beginrepeatCombox->addItem(tr("Weekly")); - m_beginrepeatCombox->addItem(tr("Monthly")); - m_beginrepeatCombox->addItem(tr("Yearly")); - repeatLabellayout->addWidget(m_beginrepeatLabel); - repeatLabellayout->addWidget(m_beginrepeatCombox); - repeatLabellayout->addStretch(); - maintlayout->addLayout(repeatLabellayout); - - QHBoxLayout *endrepeatLabellayout = new QHBoxLayout; - endrepeatLabellayout->setSpacing(0); - endrepeatLabellayout->setMargin(0); - m_endrepeatLabel = new QLabel(); - DFontSizeManager::instance()->bind(m_endrepeatLabel,DFontSizeManager::T6); - QFontMetrics fontWidth_endrepeatLabel(mlabelF); - QString str_endrepeatLabel = fontWidth_endrepeatLabel.elidedText(tr("End Repeat:"),Qt::ElideRight,70); - m_endrepeatLabel->setToolTip(tr("End Repeat")); - m_endrepeatLabel->setText(str_endrepeatLabel); - m_endrepeatLabel->setFont(mlabelF); - m_endrepeatLabel->setPalette(pa); - m_endrepeatLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); - m_endrepeatLabel->setFixedWidth(78); - m_endrepeatCombox = new DComboBox(); - m_endrepeatCombox->setFixedSize(175, 36); - m_endrepeatCombox->addItem(tr("Never")); - m_endrepeatCombox->addItem(tr("After")); - m_endrepeatCombox->addItem(tr("On")); - endrepeatLabellayout->addWidget(m_endrepeatLabel); - endrepeatLabellayout->addWidget(m_endrepeatCombox); - endrepeatLabellayout->addSpacing(8); - - QHBoxLayout *endrepeattimeslayout = new QHBoxLayout; - endrepeattimeslayout->setSpacing(0); - endrepeattimeslayout->setMargin(0); - endrepeattimeslayout->setContentsMargins(10, 0, 0, 0); - m_endrepeattimes = new DLineEdit(this); - m_endrepeattimes->setFixedSize(71, 36); - m_endrepeattimes->setText(QString::number(10)); - m_endrepeattimes->setClearButtonEnabled(false); - QRegExp rx("^[1-9]\\d{0,2}$"); - QValidator *validator = new QRegExpValidator(rx, this); - m_endrepeattimes->lineEdit()->setValidator(validator); - m_endrepeattimesLabel = new QLabel(tr("time(s)")); - m_endrepeattimesLabel->setFont(mlabelF); - m_endrepeattimesLabel->setPalette(pa); - m_endrepeattimesLabel->setFixedHeight(36); - endrepeattimeslayout->addWidget(m_endrepeattimes); - endrepeattimeslayout->addWidget(m_endrepeattimesLabel); - m_endrepeattimesWidget = new DWidget; - m_endrepeattimesWidget->setLayout(endrepeattimeslayout); - m_endrepeattimesWidget->setVisible(false); - endrepeatLabellayout->addWidget(m_endrepeattimesWidget); - - m_endRepeatDate = new DDateEdit; - m_endRepeatDate->setCalendarPopup(true); - m_endRepeatDate->setFixedSize(141, 36); - m_endRepeatDate->setDate(QDate::currentDate()); - m_endRepeatDate->setDisplayFormat("yyyy-MM-dd"); - m_endRepeatDate->setCurrentSectionIndex(2); - QFont enddatefont; -// enddatefont.setFamily("SourceHanSansSC"); - enddatefont.setWeight(QFont::Medium); -// enddatefont.setPixelSize(11); - m_endRepeatDate->setFont(enddatefont); - // m_endRepeatDate->setMinimumWidth(150); - // m_endRepeatDate->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - endrepeatLabellayout->addWidget(m_endRepeatDate); - endrepeatLabellayout->addStretch(); - m_endRepeatDate->setVisible(false); - m_endrepeatWidget = new DWidget; - m_endrepeatWidget->setLayout(endrepeatLabellayout); - maintlayout->addWidget(m_endrepeatWidget); - m_endrepeatWidget->setVisible(false); - - addButton(tr("Cancel")); - addButton(tr("Save"), false, DDialog::ButtonRecommend); - for (int i = 0; i < buttonCount(); i++) { - QAbstractButton *button = getButton(i); - button->setFixedSize(189, 36); - } -// QHBoxLayout *downlayout = new QHBoxLayout; -// downlayout->setContentsMargins(0, 0, 0, 0); -// m_cancelBt = new DPushButton(tr("Cancel")); -// m_cancelBt->setFixedSize(189, 36); -// m_OkBt = new DSuggestButton(tr("Save")); -// m_OkBt->setFixedSize(189, 36); -//// DPalette okpa = m_OkBt->palette(); -//// if (themetype == 0 || themetype == 1) { -//// okpa.setColor(DPalette::ButtonText, Qt::white); -//// okpa.setColor(DPalette::Dark, QColor("#25B7FF")); -//// okpa.setColor(DPalette::Light, QColor("#0098FF")); -//// } else { -//// okpa.setColor(DPalette::ButtonText, "#B8D3FF"); -//// okpa.setColor(DPalette::Dark, QColor("#0056C1")); -//// okpa.setColor(DPalette::Light, QColor("#004C9C")); -//// } - -//// m_OkBt->setPalette(okpa); -// downlayout->addWidget(m_cancelBt); -// DVerticalLine *verline = new DVerticalLine(this); -// verline->setFixedSize(3, 28); -// downlayout->addWidget(verline); -// downlayout->addWidget(m_OkBt); - m_gwi = new DFrame(this); - m_gwi->setFrameShape(QFrame::NoFrame); -// maintlayout->addLayout(downlayout); - // maintlayout->addStretch(); - m_gwi->setLayout(maintlayout); - // m_gwi->setGeometry(0, 68, 438, 412); - DPalette anipa = m_gwi->palette(); - QColor color = "#F8F8F8"; - color.setAlphaF(0.0); - anipa.setColor(DPalette::Background, color); - // m_gwi->setAutoFillBackground(true); - // m_gwi->setPalette(anipa); - // m_gwi->setBackgroundRole(DPalette::Background); - addContent(m_gwi, Qt::AlignCenter); - // setLayout(maintlayout); - initDateEdit(); - if (m_type == 1) - slotallDayStateChanged(0); - setFocus(); -} - -void CSchceduleDlg::initConnection() -{ - connect(this, &DDialog::buttonClicked, this, &CSchceduleDlg::slotCancelBt); - connect(this, &DDialog::buttonClicked, this, &CSchceduleDlg::slotOkBt); - connect(m_textEdit, &DTextEdit::textChanged, this, &CSchceduleDlg::slotTextChange); - connect(m_endrepeattimes,&DLineEdit::textChanged, this, &CSchceduleDlg::slotendrepeatTextchange); - - connect(m_allDayCheckbox, &DCheckBox::stateChanged, this, - &CSchceduleDlg::slotallDayStateChanged); - connect(m_beginrepeatCombox, QOverload::of(&QComboBox::activated), this, - &CSchceduleDlg::slotbRpeatactivated); - connect(m_endrepeatCombox, QOverload::of(&QComboBox::activated), this, - &CSchceduleDlg::sloteRpeatactivated); - connect(m_beginDateEdit, &DDateEdit::userDateChanged, this, &CSchceduleDlg::slotBDateEidtInfo); - - // connect(m_eCustomDateW, &CCustomCalendarWidget::signalSetCalendarTime, this, - // &CSchceduleDlg::slotEDateEidtInfo); - - QShortcut *shortcut = new QShortcut(this); - shortcut->setKey(QKeySequence(QLatin1String("ESC"))); - connect(shortcut, SIGNAL(activated()), this, SLOT(close())); -} - -void CSchceduleDlg::initDateEdit() -{ - // m_bCustomDateW = new CCustomCalendarWidget(0); - // m_beginDateEdit->setCalendarWidget(m_bCustomDateW); - m_beginDateEdit->setMinimumDate(QDate(1900, 1, 1)); // 0天 - m_beginDateEdit->setMaximumDate(QDate(9999, 12, 31)); // - // m_beginDateEdit->setContextMenuPolicy(Qt::NoContextMenu); - // m_bCustomDateW->disconnect(SIGNAL(selectionChanged())); - // m_bCustomDateW->disconnect(SIGNAL(clicked(QDate))); - - // m_eCustomDateW = new CCustomCalendarWidget(0); - // m_endDateEdit->setCalendarWidget(m_eCustomDateW); - m_endDateEdit->setMinimumDate(QDate(1900, 1, 1)); // 0天 - m_endDateEdit->setMaximumDate(QDate(9999, 12, 31)); // - // m_endDateEdit->setContextMenuPolicy(Qt::NoContextMenu); - // m_eCustomDateW->disconnect(SIGNAL(selectionChanged())); - // m_eCustomDateW->disconnect(SIGNAL(clicked(QDate))); - return; -#if 0 - int themetype = CScheduleDataManage::getScheduleDataManage()->getTheme(); - - QWidget *view1 = - m_beginDateEdit->calendarWidget()->findChild("qt_calendar_navigationbar"); - if (view1) { - DPalette anipa = view1->palette(); - if (themetype == 2) { - QColor cc = "#FFFFFF"; - cc.setAlphaF(0.1); - anipa.setColor(DPalette::Background, cc); - } else { - anipa.setColor(DPalette::Background, "#FFFFFF"); - } - view1->setPalette(anipa); - view1->setBackgroundRole(DPalette::Background); - } - QToolButton *monthbutton1 = - m_beginDateEdit->calendarWidget()->findChild("qt_calendar_monthbutton"); - if (monthbutton1) { - DPalette anipa = monthbutton1->palette(); - if (themetype == 2) { - anipa.setColor(QPalette::ButtonText, QPalette::Highlight); - } else { - anipa.setColor(QPalette::ButtonText, QPalette::Highlight); - } - monthbutton1->setPalette(anipa); - // monthbutton1->setBackgroundRole(DPalette::ButtonText); - } - QToolButton *yearbutton1 = - m_beginDateEdit->calendarWidget()->findChild("qt_calendar_yearbutton"); - if (yearbutton1) { - DPalette anipa = yearbutton1->palette(); - if (themetype == 2) { - anipa.setColor(QPalette::ButtonText, QPalette::Highlight); - } else { - anipa.setColor(QPalette::ButtonText, QPalette::Highlight); - } - yearbutton1->setPalette(anipa); - } - - QWidget *view2 = - m_endDateEdit->calendarWidget()->findChild("qt_calendar_navigationbar"); - if (view2) { - DPalette anipa = view2->palette(); - if (themetype == 2) { - anipa.setColor(DPalette::Background, "#252525"); - } else { - anipa.setColor(DPalette::Background, "#FFFFFF"); - } - view2->setPalette(anipa); - view2->setBackgroundRole(DPalette::Background); - } - QToolButton *monthbutton2 = - m_beginDateEdit->calendarWidget()->findChild("qt_calendar_monthbutton"); - if (monthbutton2) { - DPalette anipa = monthbutton2->palette(); - if (themetype == 2) { - anipa.setColor(QPalette::ButtonText, QPalette::Highlight); - } else { - anipa.setColor(QPalette::ButtonText, QPalette::Highlight); - } - monthbutton2->setPalette(anipa); - } - QToolButton *yearbutton2 = - m_beginDateEdit->calendarWidget()->findChild("qt_calendar_yearbutton"); - if (yearbutton2) { - DPalette anipa = yearbutton2->palette(); - if (themetype == 2) { - anipa.setColor(QPalette::ButtonText, QPalette::Highlight); - } else { - anipa.setColor(QPalette::ButtonText, QPalette::Highlight); - } - yearbutton2->setPalette(anipa); - } - - QWidget *view3 = - m_endRepeatDate->calendarWidget()->findChild("qt_calendar_navigationbar"); - if (view3) { - DPalette anipa = view3->palette(); - if (themetype == 2) { - anipa.setColor(DPalette::Background, "#252525"); - } else { - anipa.setColor(DPalette::Background, "#FFFFFF"); - } - view3->setPalette(anipa); - view3->setBackgroundRole(DPalette::Background); - } - - QToolButton *monthbutton3 = - m_beginDateEdit->calendarWidget()->findChild("qt_calendar_monthbutton"); - if (monthbutton3) { - DPalette anipa = monthbutton3->palette(); - if (themetype == 2) { - anipa.setColor(QPalette::ButtonText, QPalette::Highlight); - } else { - anipa.setColor(QPalette::ButtonText, QPalette::Highlight); - } - monthbutton3->setPalette(anipa); - } - QToolButton *yearbutton3 = - m_beginDateEdit->calendarWidget()->findChild("qt_calendar_yearbutton"); - if (yearbutton2) { - DPalette anipa = yearbutton3->palette(); - if (themetype == 2) { - anipa.setColor(QPalette::ButtonText, QPalette::Highlight); - } else { - anipa.setColor(QPalette::ButtonText, QPalette::Highlight); - } - yearbutton3->setPalette(anipa); - } -#endif -} - -void CSchceduleDlg::initRmindRpeatUI() -{ - if (m_scheduleDtailInfo.allday) { - if (m_scheduleDtailInfo.remind) { - if (m_scheduleDtailInfo.remindData.n == 0) { - m_rmindCombox->setCurrentIndex(1); - } else if (m_scheduleDtailInfo.remindData.n == 1) { - m_rmindCombox->setCurrentIndex(2); - } else if (m_scheduleDtailInfo.remindData.n == 2) { - m_rmindCombox->setCurrentIndex(3); - } else if (m_scheduleDtailInfo.remindData.n == 7) { - m_rmindCombox->setCurrentIndex(4); - } - } else { - m_rmindCombox->setCurrentIndex(0); - } - - } else { - if (m_scheduleDtailInfo.remind) { - if (m_scheduleDtailInfo.remindData.n == 0) { - m_rmindCombox->setCurrentIndex(1); - } else if (m_scheduleDtailInfo.remindData.n == 15) { - m_rmindCombox->setCurrentIndex(2); - } else if (m_scheduleDtailInfo.remindData.n == 30) { - m_rmindCombox->setCurrentIndex(3); - } else if (m_scheduleDtailInfo.remindData.n == 60) { - m_rmindCombox->setCurrentIndex(4); - } else if (m_scheduleDtailInfo.remindData.n == 1440) { - m_rmindCombox->setCurrentIndex(5); - } else if (m_scheduleDtailInfo.remindData.n == 2880) { - m_rmindCombox->setCurrentIndex(6); - } else if (m_scheduleDtailInfo.remindData.n == 10080) { - m_rmindCombox->setCurrentIndex(7); - } - } else { - m_rmindCombox->setCurrentIndex(0); - } - } - slotbRpeatactivated(m_scheduleDtailInfo.rpeat); - m_beginrepeatCombox->setCurrentIndex(m_scheduleDtailInfo.rpeat); - if (m_scheduleDtailInfo.rpeat != 0) { - if (m_scheduleDtailInfo.enddata.type == 0) { - m_endrepeatCombox->setCurrentIndex(0); - } else if (m_scheduleDtailInfo.enddata.type == 1) { - m_endrepeatCombox->setCurrentIndex(1); - m_endrepeattimes->setText(QString::number(m_scheduleDtailInfo.enddata.tcount)); - } else if (m_scheduleDtailInfo.enddata.type == 2) { - m_endrepeatCombox->setCurrentIndex(2); - m_endRepeatDate->setDate(m_scheduleDtailInfo.enddata.date.date()); - } - m_endrepeatWidget->show(); - sloteRpeatactivated(m_scheduleDtailInfo.enddata.type); - } else { - m_endrepeatWidget->hide(); - } -} - -void CSchceduleDlg::ChangeRecurInfo(QWidget *parent, const ScheduleDtailInfo &newinfo, const ScheduleDtailInfo &oldinfo, int m_themetype) -{ - Q_UNUSED(m_themetype); - Q_UNUSED(parent); - if (newinfo.RecurID == 0) { - CSchceduleCtrlDlg msgBox/*(parent)*/; - msgBox.setText(tr("You are changing a repeating event.")); - msgBox.setInformativeText( - tr("Do you want to change only this occurrence of the event, or all " - "occurrences?")); - /*QAbstractButton *noButton = */msgBox.addPushButton(tr("Cancel")); - /*QAbstractButton *yesallbutton = */msgBox.addPushButton(tr("All")); - /*QAbstractButton *yesButton = */msgBox.addsuggestButton(tr("Only This Event")); -// msgBox.updatesize(); - msgBox.exec(); - if (msgBox.clickButton() == 0) { - return; - } else if (msgBox.clickButton() == 1) { - ScheduleDtailInfo scheduleDtailInfo = newinfo; -// scheduleDtailInfo.ignore.clear(); - if (scheduleDtailInfo.enddata.type ==1 &&scheduleDtailInfo.enddata.tcount<1) { - scheduleDtailInfo.enddata.type =0; - } else if (scheduleDtailInfo.enddata.type ==2 && - scheduleDtailInfo.beginDateTime.daysTo( - scheduleDtailInfo.enddata.date)<0) { - scheduleDtailInfo.enddata.type =0; - scheduleDtailInfo.rpeat = 0; - } - CScheduleDataManage::getScheduleDataManage() - ->getscheduleDataCtrl() - ->updateScheduleInfo(scheduleDtailInfo); - } else if (msgBox.clickButton() == 2) { - ChangeOnlyInfo(newinfo,oldinfo); - } - } else { - CSchceduleCtrlDlg msgBox/*(parent)*/; - msgBox.setText(tr("You are changing a repeating event.")); - msgBox.setInformativeText( - tr("Do you want to change only this occurrence of the event, or this and " - "all future occurrences?")); - /* QAbstractButton *noButton = */msgBox.addPushButton(tr("Cancel")); - /*QAbstractButton *yesallbutton = */msgBox.addPushButton(tr("All Future Events")); - /*QAbstractButton *yesButton = */msgBox.addsuggestButton(tr("Only This Event")); -// msgBox.updatesize(); - msgBox.exec(); - - if (msgBox.clickButton() == 0) { - return; - } else if (msgBox.clickButton() == 1) { - ScheduleDtailInfo newschedule = newinfo; - newschedule.RecurID = 0; - newschedule.id = 0; - if (newschedule.enddata.type ==1) { - newschedule.enddata.tcount = qAbs(newinfo.enddata.tcount - newinfo.RecurID); - if (newschedule.enddata.tcount <1) { - newschedule.enddata.type =0; - newschedule.rpeat = 0; - } - } - CScheduleDataManage::getScheduleDataManage() - ->getscheduleDataCtrl() - ->addSchedule(newschedule); - ScheduleDtailInfo updatescheduleData; - CScheduleDataManage::getScheduleDataManage() - ->getscheduleDataCtrl() - ->getScheduleInfoById(oldinfo.id, updatescheduleData); - if (updatescheduleData.enddata.type == 1) { - updatescheduleData.enddata.tcount = newinfo.RecurID -1; - if (updatescheduleData.enddata.tcount <1) { - updatescheduleData.enddata.type =0; - updatescheduleData.rpeat = 0; - } - } else if (updatescheduleData.enddata.type == 2) { - updatescheduleData.enddata.type = 2; - updatescheduleData.enddata.date = - oldinfo.beginDateTime.addDays(-1); - } - - CScheduleDataManage::getScheduleDataManage() - ->getscheduleDataCtrl() - ->updateScheduleInfo(updatescheduleData); - } else if (msgBox.clickButton() == 2) { - ChangeOnlyInfo(newinfo,oldinfo); - } - } -} - -void CSchceduleDlg::ChangeOnlyInfo(const ScheduleDtailInfo &newinfo, const ScheduleDtailInfo &oldinfo) -{ - ScheduleDtailInfo newschedule = newinfo; - newschedule.rpeat = 0; - newschedule.RecurID = 0; - newschedule.id = 0; - newschedule.ignore.clear(); - CScheduleDataManage::getScheduleDataManage() - ->getscheduleDataCtrl() - ->addSchedule(newschedule); - ScheduleDtailInfo updatescheduleData; - CScheduleDataManage::getScheduleDataManage() - ->getscheduleDataCtrl() - ->getScheduleInfoById(oldinfo.id, updatescheduleData); - updatescheduleData.ignore.append(oldinfo.beginDateTime); - CScheduleDataManage::getScheduleDataManage() - ->getscheduleDataCtrl() - ->updateScheduleInfo(updatescheduleData); -} diff -Nru dde-calendar-5.7.0.4/src/schceduledlg.h dde-calendar-5.7.0.23/src/schceduledlg.h --- dde-calendar-5.7.0.4/src/schceduledlg.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/schceduledlg.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,130 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#ifndef SCHCEDULEDLG_H -#define SCHCEDULEDLG_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#include -#include -#include "schedulestructs.h" -DWIDGET_USE_NAMESPACE -class CTimeEdit; -class CSchceduleDlg : public DDialog -{ - Q_OBJECT -public: - CSchceduleDlg(int type, QWidget *parent = nullptr, const bool isAllDay = true); - ~CSchceduleDlg() Q_DECL_OVERRIDE; - void setData(const ScheduleDtailInfo &info); - void setDate(const QDateTime &date); - ScheduleDtailInfo getScheduleData(); - void setAllDay(bool flag); -signals: - void signalViewtransparentFrame(int type); - void signalScheduleUpdate(int id = 0); -public slots: - void slotCancelBt(int buttonIndex, QString buttonName); - void slotOkBt(int buttonIndex, QString buttonName); - void slotTextChange(); - void slotendrepeatTextchange(); - void slotBDateEidtInfo(const QDate &date); - void slotEDateEidtInfo(const QDate &date); - void slotallDayStateChanged(int state); - void slotbRpeatactivated(int index); - void sloteRpeatactivated(int index); - -protected: -// void focusInEvent(QFocusEvent *event); - bool eventFilter(QObject *obj, QEvent *pEvent) Q_DECL_OVERRIDE; - void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; - void changeEvent(QEvent *event) Q_DECL_OVERRIDE; -private: - void initUI(); - void initConnection(); - void initDateEdit(); - void initRmindRpeatUI(); -public: - static void ChangeRecurInfo(QWidget *parent,const ScheduleDtailInfo &newinfo, - const ScheduleDtailInfo &oldinfo,int m_themetype); - static void ChangeOnlyInfo(const ScheduleDtailInfo &newinfo, - const ScheduleDtailInfo &oldinfo); - -private: - QLabel *m_typeLabel = nullptr; - DComboBox *m_typeComBox = nullptr; - QLabel *m_contentLabel = nullptr; - DTextEdit *m_textEdit = nullptr; - QLabel *m_beginTimeLabel = nullptr; - DDateEdit *m_beginDateEdit = nullptr; - CTimeEdit *m_beginTimeEdit = nullptr; - QLabel *m_endTimeLabel = nullptr; - DDateEdit *m_endDateEdit = nullptr; - CTimeEdit *m_endTimeEdit = nullptr; - - QLabel *m_adllDayLabel = nullptr; - DCheckBox *m_allDayCheckbox = nullptr; - QLabel *m_remindSetLabel = nullptr; - DComboBox *m_rmindCombox = nullptr; - QLabel *m_beginrepeatLabel = nullptr; - DComboBox *m_beginrepeatCombox = nullptr; - QLabel *m_endrepeatLabel = nullptr; - DComboBox *m_endrepeatCombox = nullptr; - DLineEdit *m_endrepeattimes; - QLabel *m_endrepeattimesLabel = nullptr; - DWidget *m_endrepeattimesWidget; - DDateEdit *m_endRepeatDate = nullptr; - DWidget *m_endrepeatWidget; -// DPushButton *m_cancelBt = nullptr; -// DSuggestButton *m_OkBt = nullptr; - // CCalendarTimeEidt *m_bCalendarTimeEidt; - // CCalendarTimeEidt *m_eCalendarTimeEidt; - // CCustomCalendarWidget *m_bCustomDateW; - // CCustomCalendarWidget *m_eCustomDateW; - DFrame *m_gwi; - QLabel *m_titleLabel; - - QString m_context; - const bool m_createAllDay; - -private: -//日程 - ScheduleDtailInfo m_scheduleDtailInfo; - int m_type; // 1新建 0 编辑日程 - QDateTime m_currentDate; - QDateTime m_EndDate; -}; - -#endif // SHCEDULEDLG_H diff -Nru dde-calendar-5.7.0.4/src/schcedulesearchview.cpp dde-calendar-5.7.0.23/src/schcedulesearchview.cpp --- dde-calendar-5.7.0.4/src/schcedulesearchview.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/schcedulesearchview.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,870 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#include "schcedulesearchview.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "schceduledlg.h" -#include "scheduledatamanage.h" -#include -#include -#include -#include -#include -#include "schcedulectrldlg.h" -#include "myschceduleview.h" -DGUI_USE_NAMESPACE -CSchceduleSearchItem::CSchceduleSearchItem( QWidget *parent): - DLabel(parent), - m_rightMenu(new DMenu(this)) -{ - //setMargin(0); - m_editAction = new QAction(tr("Edit"), this); - m_deleteAction = new QAction(tr("Delete"), this); - connect(m_editAction, SIGNAL(triggered(bool)), this, SLOT(slotEdit())); - connect(m_deleteAction, SIGNAL(triggered(bool)), this, SLOT(slotDelete())); - setTheMe(DGuiApplicationHelper::instance()->themeType()); - QObject::connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::paletteTypeChanged, - this, - &CSchceduleSearchItem::setTheMe); - m_mouseStatus = M_NONE; - installEventFilter(this); - //setFlat(true); - -} - -void CSchceduleSearchItem::setBackgroundColor(QColor color1) -{ - m_Backgroundcolor = color1; -} - -void CSchceduleSearchItem::setSplitLineColor(QColor color1) -{ - m_splitlinecolor = color1; -} - -void CSchceduleSearchItem::setText( QColor tcolor, QFont font) -{ - m_ttextcolor = tcolor; - m_tfont = font; -} - -void CSchceduleSearchItem::setTimeC(QColor tcolor, QFont font) -{ - m_timecolor = tcolor; - m_timefont = font; -} - -void CSchceduleSearchItem::setData( ScheduleDtailInfo vScheduleInfo, QDate date) -{ - m_ScheduleInfo = vScheduleInfo; - m_date = date; - //setToolTip(m_ScheduleInfo.titleName); - update(); -} - -void CSchceduleSearchItem::setRoundtype(int rtype) -{ - m_roundtype = rtype; - update(); -} - -void CSchceduleSearchItem::setTheMe(int type) -{ - if (type == 2) { -// m_presscolor.background = "#0059D2"; - m_presscolor.background = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); - m_presscolor.background.setAlphaF(1); - m_presscolor.timeColor = "#FFFFFF"; - m_presscolor.timeColor.setAlphaF(1); - m_presscolor.textColor = "#FFFFFF"; - m_presscolor.textColor.setAlphaF(1); - - m_hovercolor.background= "#FFFFFF"; - m_hovercolor.background.setAlphaF(0.2); - m_hovercolor.timeColor = "#6D7C88"; - m_hovercolor.timeColor.setAlphaF(1); - m_hovercolor.textColor = "#C0C6D4"; - m_hovercolor.textColor.setAlphaF(1); - } else { -// m_presscolor.background = "#0081FF"; - m_presscolor.background = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); - m_presscolor.background.setAlphaF(1); - m_presscolor.timeColor = "#FFFFFF"; - m_presscolor.timeColor.setAlphaF(1); - m_presscolor.textColor = "#FFFFFF"; - m_presscolor.textColor.setAlphaF(1); - - m_hovercolor.background= "#000000"; - m_hovercolor.background.setAlphaF(0.2); - m_hovercolor.timeColor = "#526A7F"; - m_hovercolor.timeColor.setAlphaF(1); - m_hovercolor.textColor = "#414D68"; - m_hovercolor.textColor.setAlphaF(1); - } -} -void CSchceduleSearchItem::slotEdit() -{ - emit signalViewtransparentFrame(1); - CSchceduleDlg dlg(0, this); - dlg.setData(m_ScheduleInfo); - if (dlg.exec() == DDialog::Accepted) { - emit signalsEdit(this); - } - emit signalViewtransparentFrame(0); -} - -void CSchceduleSearchItem::slotDelete() -{ - emit signalViewtransparentFrame(1); -// int themetype = CScheduleDataManage::getScheduleDataManage()->getTheme(); - - if (m_ScheduleInfo.rpeat == 0) { - CSchceduleCtrlDlg msgBox; - - msgBox.setText(tr("You are deleting an event.")); - msgBox.setInformativeText(tr("Are you sure you want to delete this event?")); - /*QAbstractButton *noButton = */msgBox.addPushButton(tr("Cancel"), true); - /*QAbstractButton *yesButton = */msgBox.addWaringButton(tr("Delete"), true); -// msgBox.updatesize(); -// DPalette pa = yesButton->palette(); -// if (themetype == 0 || themetype == 1) { -// pa.setColor(DPalette::ButtonText, Qt::red); - -// } else { -// pa.setColor(DPalette::ButtonText, "#FF5736"); - -// } -// yesButton->setPalette(pa); - msgBox.exec(); - - if (msgBox.clickButton() == 0) { - emit signalViewtransparentFrame(0); - return; - } else if (msgBox.clickButton() == 1) { - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->deleteScheduleInfoById(m_ScheduleInfo.id); - } - } else { - if (m_ScheduleInfo.RecurID == 0) { - CSchceduleCtrlDlg msgBox; - - msgBox.setText(tr("You are deleting an event.")); - msgBox.setInformativeText(tr("Do you want to delete all occurrences of this event, or only the selected occurrence?")); - /*QAbstractButton *noButton = */msgBox.addPushButton(tr("Cancel")); - /*QAbstractButton *yesallbutton = */msgBox.addPushButton(tr("Delete All")); - /*QAbstractButton *yesButton = */msgBox.addsuggestButton(tr("Delete Only This Event")); - - -// msgBox.updatesize(); -// DPalette pa = yesButton->palette(); -// if (themetype == 0 || themetype == 1) { -// pa.setColor(DPalette::ButtonText, Qt::white); -// pa.setColor(DPalette::Dark, QColor("#25B7FF")); -// pa.setColor(DPalette::Light, QColor("#0098FF")); -// } else { -// pa.setColor(DPalette::ButtonText, "#B8D3FF"); -// pa.setColor(DPalette::Dark, QColor("#0056C1")); -// pa.setColor(DPalette::Light, QColor("#004C9C")); -// } -// yesButton->setPalette(pa); - msgBox.exec(); - - if (msgBox.clickButton() == 0) { - emit signalViewtransparentFrame(0); - return; - } else if (msgBox.clickButton() == 1) { - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->deleteScheduleInfoById(m_ScheduleInfo.id); - } else if (msgBox.clickButton() == 2) { - - ScheduleDtailInfo newschedule; - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->getScheduleInfoById(m_ScheduleInfo.id, newschedule); - newschedule.ignore.append(m_ScheduleInfo.beginDateTime); - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo(newschedule); - } - } else { - CSchceduleCtrlDlg msgBox; - msgBox.setText(tr("You are deleting an event.")); - msgBox.setInformativeText(tr("Do you want to delete this and all future occurrences of this event, or only the selected occurrence?")); - /*QAbstractButton *noButton = */msgBox.addPushButton(tr("Cancel")); - /*QAbstractButton *yesallbutton = */msgBox.addPushButton(tr("Delete All Future Events")); - /*QAbstractButton *yesButton =*/ msgBox.addsuggestButton(tr("Delete Only This Event")); -// msgBox.updatesize(); -// DPalette pa = yesButton->palette(); -// if (themetype == 0 || themetype == 1) { -// pa.setColor(DPalette::ButtonText, Qt::white); -// pa.setColor(DPalette::Dark, QColor("#25B7FF")); -// pa.setColor(DPalette::Light, QColor("#0098FF")); -// } else { -// pa.setColor(DPalette::ButtonText, "#B8D3FF"); -// pa.setColor(DPalette::Dark, QColor("#0056C1")); -// pa.setColor(DPalette::Light, QColor("#004C9C")); -// } -// yesButton->setPalette(pa); - msgBox.exec(); - - if (msgBox.clickButton() == 0) { - emit signalViewtransparentFrame(0); - return; - } else if (msgBox.clickButton() == 1) { - ScheduleDtailInfo newschedule; - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->getScheduleInfoById(m_ScheduleInfo.id, newschedule); - newschedule.enddata.type = 2; - newschedule.enddata.date = m_ScheduleInfo.beginDateTime.addDays(-1); - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo(newschedule); - - } else if (msgBox.clickButton() == 2) { - - ScheduleDtailInfo newschedule; - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->getScheduleInfoById(m_ScheduleInfo.id, newschedule); - newschedule.ignore.append(m_ScheduleInfo.beginDateTime); - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo(newschedule); - } - } - } - emit signalViewtransparentFrame(0); - emit signalsDelete(this); - //ScheduleDbManager::deleteScheduleInfoById(m_ScheduleInfo.id); -} - -void CSchceduleSearchItem::slotDoubleEvent(int type) -{ - Q_UNUSED(type); - emit signalsDelete(this); -} - -void CSchceduleSearchItem::paintEvent( QPaintEvent *e ) -{ - Q_UNUSED(e); - int labelwidth = width(); - int labelheight = height(); - QPainter painter(this); - QColor bcolor = m_Backgroundcolor; - QColor textcolor = m_ttextcolor; - QColor timecolor = m_timecolor; - switch (m_mouseStatus) { - case M_NONE: { - bcolor = m_Backgroundcolor; - textcolor = m_ttextcolor; - timecolor = m_timecolor; - } - break; - case M_HOVER: { - bcolor = m_hovercolor.background; - textcolor = m_hovercolor.textColor; - timecolor = m_hovercolor.timeColor; - } - break; - case M_PRESS: { - bcolor = m_presscolor.background; - textcolor = m_presscolor.textColor; - timecolor = m_presscolor.timeColor; - } - break; - } - painter.save(); - painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; - painter.setBrush(QBrush(bcolor)); - painter.setPen(Qt::NoPen); - QPainterPath painterPath; - painterPath.moveTo(m_radius, m_borderframew); - if (m_roundtype == 1 || m_roundtype == 3) { - painterPath.arcTo(QRect(m_borderframew, m_borderframew, m_radius * 2, m_radius * 2), 90, 90); - } else { - painterPath.lineTo(m_borderframew, m_borderframew); - painterPath.lineTo(m_borderframew, m_radius); - } - painterPath.lineTo(0, labelheight - m_radius); - if (m_roundtype == 1 || m_roundtype == 2) { - painterPath.arcTo(QRect(m_borderframew, labelheight - m_radius * 2, m_radius * 2, m_radius * 2), 180, 90); - } else { - painterPath.lineTo(m_borderframew, labelheight); - painterPath.lineTo(m_radius, labelheight); - } - painterPath.lineTo(labelwidth - m_radius, labelheight); - if (m_roundtype == 1 || m_roundtype == 2) { - painterPath.arcTo(QRect(labelwidth - m_radius * 2, labelheight - m_radius * 2, m_radius * 2, m_radius * 2), 270, 90); - } else { - painterPath.lineTo(labelwidth, labelheight); - painterPath.lineTo(labelwidth, labelheight - m_radius); - } - painterPath.lineTo(labelwidth, m_radius); - //painterPath.moveTo(labelwidth, m_radius); - if (m_roundtype == 1 || m_roundtype == 3) { - - painterPath.arcTo(QRect(labelwidth - m_radius * 2, m_borderframew, m_radius * 2, m_radius * 2), 0, 90); - - } else { - painterPath.lineTo(labelwidth, m_borderframew); - painterPath.lineTo(labelwidth - m_radius, m_borderframew); - } - painterPath.lineTo(m_radius, m_borderframew); - painterPath.closeSubpath(); - painter.drawPath(painterPath); - painter.restore(); - -// if (m_selectflag) { -// bcolor.setAlphaF(0.6); -// } - painter.setFont(m_timefont); - painter.setPen(timecolor); - - QDate begindate = m_ScheduleInfo.beginDateTime.date(); - QDate enddate = m_ScheduleInfo.endDateTime.date(); - QString datestr; - if (begindate == enddate) { - datestr = m_ScheduleInfo.beginDateTime.toString("hh:mm") - + "-" + m_ScheduleInfo.endDateTime.toString("hh:mm"); - } else { - datestr = m_ScheduleInfo.beginDateTime.toString("hh:mm") - + "-" + m_ScheduleInfo.endDateTime.toString("hh:mm"); - } - - QFontMetrics fm1(m_timefont); - int durationSize = 0; - durationSize = fm1.horizontalAdvance(datestr); - int flag = Qt::AlignLeft | Qt::AlignVCenter; - if (m_ScheduleInfo.allday) { - datestr = tr("All Day"); - } - painter.drawText(QRect(12, 8, durationSize, labelheight - 16), flag, datestr); - - - painter.save(); - bcolor = m_splitlinecolor; -// if (m_selectflag) { -// bcolor.setAlphaF(0.6); -// } - QPen pen(bcolor); - pen.setWidth(2); - painter.setPen(pen); - painter.drawLine(durationSize + 17, 0, durationSize + 17, labelheight); - painter.restore(); - - painter.setFont(m_tfont); - -// if (m_selectflag) { -// bcolor.setAlphaF(0.6); -// } - painter.setPen(textcolor); - int tilenameW = labelwidth - 91; - QFontMetrics fm = painter.fontMetrics(); - QString tStitlename = m_ScheduleInfo.titleName; - tStitlename.replace("\n", ""); - QString str = tStitlename; - QString tstr; - for (int i = 0; i < str.count(); i++) { - tstr.append(str.at(i)); - int widthT = fm.width(tstr) + 5; - if (widthT >= tilenameW) { - tstr.chop(1); - break; - } - } - if (tstr != str) { - tstr = tstr + "..."; - } - - painter.drawText(QRect(durationSize + 17 + 9, 6, tilenameW, labelheight), Qt::AlignLeft, tstr); - painter.end(); -} -void CSchceduleSearchItem::contextMenuEvent( QContextMenuEvent *event ) -{ - Q_UNUSED(event); - if (m_ScheduleInfo.type.ID == 4) - return; - m_rightMenu->clear(); - m_rightMenu->addAction(m_editAction); - m_rightMenu->addAction(m_deleteAction); - m_rightMenu->exec(QCursor::pos()); -} - -void CSchceduleSearchItem::mouseDoubleClickEvent(QMouseEvent *event) -{ - Q_UNUSED(event); - emit signalViewtransparentFrame(1); - CMySchceduleView dlg(m_ScheduleInfo, this); -// dlg.setSchedules(m_ScheduleInfo); - connect(&dlg, &CMySchceduleView::signalsEditorDelete, this, &CSchceduleSearchItem::slotDoubleEvent); - dlg.exec(); - disconnect(&dlg, &CMySchceduleView::signalsEditorDelete, this, &CSchceduleSearchItem::slotDoubleEvent); - emit signalViewtransparentFrame(0); - -} - -void CSchceduleSearchItem::mousePressEvent(QMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) { -// m_mouseStatus = M_PRESS; -// update(); - emit signalSelectDate(m_date); - emit signalSelectSchedule(m_ScheduleInfo); - } -} - -void CSchceduleSearchItem::mouseReleaseEvent(QMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) { - m_mouseStatus = M_HOVER; - update(); - } -} - -void CSchceduleSearchItem::enterEvent(QEvent *event) -{ - Q_UNUSED(event); - m_mouseStatus = M_HOVER; - update(); -} - -void CSchceduleSearchItem::leaveEvent(QEvent *event) -{ - Q_UNUSED(event); - m_mouseStatus = M_NONE; - update(); -} - -bool CSchceduleSearchItem::eventFilter(QObject *o, QEvent *e) -{ - Q_UNUSED(o); - if (e->type() == QEvent::MouseButtonPress) { - QMouseEvent *m_press = dynamic_cast(e); - if (m_press->button() == Qt::LeftButton) { - m_mouseStatus = M_PRESS; - } - } - update(); - return false; -} -CSchceduleSearchView::CSchceduleSearchView(QWidget *parent) : DWidget(parent) -{ - QVBoxLayout *layout = new QVBoxLayout; - layout->setMargin(0); - layout->setSpacing(0); - m_gradientItemList = new CScheduleListWidget(parent); - m_gradientItemList->setAlternatingRowColors(true); - layout->setContentsMargins(0, 0, 0, 0); - layout->addWidget(m_gradientItemList); - //m_gradientItemList->setSpacing(1); - // set default row - m_gradientItemList->setCurrentRow(0); - setLayout(layout); - setMouseTracking(true); - setFocusPolicy(Qt::StrongFocus); - m_bBackgroundcolor.setAlphaF(0.03); - m_gradientItemList->setLineWidth(0); - m_labellist.clear(); - - connect(m_gradientItemList, - &CScheduleListWidget::signalListWidgetScheduleHide, - this, - &CSchceduleSearchView::signalScheduleHide); -} - -CSchceduleSearchView::~CSchceduleSearchView() -{ - for (int i = 0; i < m_gradientItemList->count(); i++) { - QListWidgetItem *item11 = m_gradientItemList->takeItem(i); - m_gradientItemList->removeItemWidget(item11); - delete item11; - item11 = nullptr; - } - m_gradientItemList->clear(); -} - -void CSchceduleSearchView::setTheMe(int type) -{ - if (type == 0 || type == 1) { - m_bBackgroundcolor = "#000000"; - m_bBackgroundcolor.setAlphaF(0.03); - m_btimecolor = "#526A7F"; - m_bttextcolor = "#414D68"; - m_lBackgroundcolor = Qt::white; - m_ltextcolor = "#001A2E"; - } else if (type == 2) { - m_bBackgroundcolor = "#FFFFFF"; - m_bBackgroundcolor.setAlphaF(0.05); - m_btimecolor = "#6D7C88"; - m_bttextcolor = "#C0C6D4"; - m_lBackgroundcolor = "#FFFFFF"; - m_lBackgroundcolor.setAlphaF(0.0); - m_ltextcolor = "#C0C6D4"; - } - updateDateShow(); -} - -void CSchceduleSearchView::clearSearch() -{ - m_vlistData.clear(); - - //remove - for (int i = 0; i < m_gradientItemList->count(); i++) { - QListWidgetItem *item11 = m_gradientItemList->takeItem(i); - m_gradientItemList->removeItemWidget(item11); - delete item11; - item11 = nullptr; - } - m_labellist.clear(); - m_gradientItemList->clear(); - QVector vScheduleInfo; - CScheduleDataManage::getScheduleDataManage()->setSearchResult(vScheduleInfo); -} - -void CSchceduleSearchView::setMaxWidth(const int w) -{ - m_maxWidth = w; -} - -void CSchceduleSearchView::updateDateShow() -{ - m_currentItem = nullptr; - //remove - for (int i = 0; i < m_gradientItemList->count(); i++) { - QListWidgetItem *item11 = m_gradientItemList->takeItem(i); - m_gradientItemList->removeItemWidget(item11); - delete item11; - item11 = nullptr; - } - m_gradientItemList->clear(); - m_labellist.clear(); - //找最近日程 - QDate tcurrentdata = QDate::currentDate(); - QVector m_showData; - ScheduleDateRangeInfo showData; - qint64 offset = 1000; - QDate topdate = tcurrentdata; - for (int i = 0; i < m_vlistData.size(); ++i) { - qint64 d = qAbs(m_vlistData.at(i).date.daysTo(tcurrentdata)); - - showData.date = m_vlistData.at(i).date; - for (int j = 0 ; j < m_vlistData.at(i).vData.size(); ++j) { - if (m_vlistData.at(i).vData.at(j).beginDateTime.date() == m_vlistData.at(i).date) { - showData.vData.append(m_vlistData.at(i).vData.at(j)); - } - } - if (showData.vData.count() > 0) { - if ( dcount() == 0) { - QListWidgetItem *listItem = new QListWidgetItem(m_gradientItemList); - DLabel *gwi = new DLabel(); - QFont font/*("SourceHanSansSC-Normal")*/; - font.setPixelSize(20); - gwi->setAlignment(Qt::AlignCenter ); - DPalette daypa = gwi->palette(); - QColor textcolor = DPalette::ToolTipText; - int themtype = CScheduleDataManage::getScheduleDataManage()->getTheme(); - if (themtype == 2) { - textcolor = "#C0C6D4"; - textcolor.setAlphaF(0.4); - } else { - textcolor = "#000000"; - textcolor.setAlphaF(0.3); - } - daypa.setColor(DPalette::WindowText, textcolor); - daypa.setColor(DPalette::Window, m_lBackgroundcolor); - gwi->setPalette(daypa); - gwi->setForegroundRole(DPalette::WindowText); - //gwi->setForegroundRole(DPalette::Window); - gwi->setFont(font); - gwi->move(this->width() - 70, this->height() - 196); - gwi->setText(tr("No search results")); - gwi->setFixedSize(m_maxWidth - 20, 450); - listItem->setSizeHint(QSize(m_maxWidth, 450)); //每次改变Item的高度 - //listItem->setBackgroundColor(Qt::white); - listItem->setFlags(Qt::ItemIsTristate ); - m_gradientItemList->addItem(listItem); - m_gradientItemList->setItemWidget(listItem, gwi); - m_labellist.append(gwi); - } - if (m_currentItem != nullptr) { - m_gradientItemList->scrollToItem(m_currentItem, QAbstractItemView::PositionAtTop); - } - -} - -void CSchceduleSearchView::createItemWidget(ScheduleDtailInfo info, QDate date, int rtype) -{ - ScheduleDtailInfo &gd = info; - CSchedulesColor gdcolor = CScheduleDataManage::getScheduleDataManage()->getScheduleColorByType(gd.type.ID); - - CSchceduleSearchItem *gwi = new CSchceduleSearchItem(); - QFont font/*("SourceHanSansSC-Normal")*/; - font.setPixelSize(14); - font.setWeight(QFont::Normal); - gwi->setBackgroundColor(m_bBackgroundcolor); - //gwi->setBackgroundColor(Qt::white); - QColor scolor = gdcolor.Purecolor; - scolor.setAlphaF(1.0); - gwi->setSplitLineColor(gdcolor.splitColor); - gwi->setText(m_bttextcolor, font); - font.setPixelSize(12); - - gwi->setTimeC(m_btimecolor, font); - gwi->setFixedSize(m_maxWidth - 20, 35); - gwi->setData(gd, date); - gwi->setRoundtype(rtype); - connect(gwi, &CSchceduleSearchItem::signalsDelete, this, &CSchceduleSearchView::slotdeleteitem); - connect(gwi, &CSchceduleSearchItem::signalsEdit, this, &CSchceduleSearchView::slotedititem); - connect(gwi, &CSchceduleSearchItem::signalSelectDate, this, &CSchceduleSearchView::slotSelectDate); - connect(gwi, &CSchceduleSearchItem::signalSelectSchedule, this, &CSchceduleSearchView::slotSelectSchedule); - connect(gwi, &CSchceduleSearchItem::signalViewtransparentFrame, this, &CSchceduleSearchView::signalViewtransparentFrame); - - //connect(gwi, SIGNAL(signalsDelete(QDate )), this, SIGNAL(signalDate(QDate ))); - - QListWidgetItem *listItem = new QListWidgetItem; - listItem->setSizeHint(QSize(m_maxWidth - 5, 36)); //每次改变Item的高度 - //listItem->setBackgroundColor(Qt::white); - listItem->setFlags(Qt::ItemIsTristate ); - m_gradientItemList->addItem(listItem); - m_gradientItemList->setItemWidget(listItem, gwi); - m_labellist.append(gwi); -} - -QListWidgetItem *CSchceduleSearchView::createItemWidget(QDate date) -{ - CSchceduleSearchDateItem *gwi = new CSchceduleSearchDateItem(); - QFont font/*("SourceHanSansSC")*/; - font.setWeight(QFont::Medium); - font.setPixelSize(16); - gwi->setBackgroundColor(m_lBackgroundcolor); - gwi->setText(m_ltextcolor, font); - if (date == QDate::currentDate()) { - int themtype = CScheduleDataManage::getScheduleDataManage()->getTheme(); - if (themtype == 2) { -// gwi->setText("#0059D2", font); - gwi->setText(CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(), font); - } else { -// gwi->setText("#0081FF", font); - gwi->setText(CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(), font); - } - - } - gwi->setFixedSize(m_maxWidth - 20, 35); - gwi->setDate(date); - connect(gwi, - &CSchceduleSearchDateItem::signalLabelScheduleHide, - this, - &CSchceduleSearchView::signalScheduleHide); - QListWidgetItem *listItem = new QListWidgetItem; - listItem->setSizeHint(QSize(m_maxWidth - 5, 36)); //每次改变Item的高度 - //listItem->setBackgroundColor(Qt::white); - listItem->setFlags(Qt::ItemIsTristate ); - m_gradientItemList->addItem(listItem); - m_gradientItemList->setItemWidget(listItem, gwi); - m_labellist.append(gwi); - return listItem; -} - -void CSchceduleSearchView::slotdeleteitem( CSchceduleSearchItem *item ) -{ - emit signalsUpdateShcedule(item->getData().id); - updateDateShow(); - update(); -} - -void CSchceduleSearchView::slotedititem(CSchceduleSearchItem *item) -{ - emit signalsUpdateShcedule(item->getData().id); -} - -void CSchceduleSearchView::slotsetSearch(QString str) -{ - if (str.isEmpty()) return; - QDateTime date = QDateTime::currentDateTime(); - - QDateTime bdate = date.addMonths(-6); - if (!bdate.isValid()) { - QDateTime tdate = date; - tdate.setDate(QDate(date.date().year(), date.date().month(), 1)); - bdate = tdate.addMonths(-6); - } - QDateTime edate = date.addMonths(6); - if (!edate.isValid()) { - QDateTime tdate = date; - tdate.setDate(QDate(date.date().year(), date.date().month(), 1)); - edate = tdate.addMonths(7); - edate = edate.addDays(-1); - } - QVector vScheduleInfo; - m_vlistData.clear(); -#if 0 - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->getScheduleInfo(bdate.date(), edate.date(), vScheduleInfo); - for (int i = 0; i < vScheduleInfo.count(); i++) { - QVector vData; - for (int j = 0; j < vScheduleInfo.at(i).vData.count(); j++) { - if (vScheduleInfo.at(i).vData.at(j).titleName.contains(str)) - vData.append(vScheduleInfo.at(i).vData.at(j)); - } - if (!vData.isEmpty()) { - ScheduleDateRangeInfo sinfo; - sinfo.date = vScheduleInfo.at(i).date; - sinfo.vData = vData; - m_vlistData.append(sinfo); - } - } -#else - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->queryScheduleInfo(str, bdate, edate, vScheduleInfo); - m_vlistData = vScheduleInfo; - CScheduleDataManage::getScheduleDataManage()->setSearchResult(vScheduleInfo); -#endif - updateDateShow(); -} - -void CSchceduleSearchView::slotSelectDate(QDate date) -{ - emit signalDate(date); -} - -void CSchceduleSearchView::slotSelectSchedule(const ScheduleDtailInfo &scheduleInfo) -{ - emit signalSelectSchedule(scheduleInfo); -} - -void CSchceduleSearchView::resizeEvent(QResizeEvent *event) -{ - for (int i = 0; i < m_gradientItemList->count(); i++) { - QListWidgetItem *item11 = m_gradientItemList->item(i); - item11->setSizeHint(QSize(m_maxWidth - 5, 36)); //每次改变Item的高度 - } - //remove - for (int i = 0; i < m_labellist.count(); i++) { - m_labellist.at(i)->setFixedSize(m_maxWidth - 20, 35); - m_labellist.at(i)->update(); - } - if (m_gradientItemList->count() == 1) { - QListWidgetItem *item11 = m_gradientItemList->item(0); - item11->setSizeHint(QSize(m_maxWidth, qRound(height() * 0.7978))); //每次改变Item的高度 - m_labellist.at(0)->setFixedSize(m_maxWidth, qRound(height() * 0.7978)); - m_labellist.at(0)->update(); - } - if (m_gradientItemList->count() >1) { - if (m_currentItem != nullptr) { - m_gradientItemList->scrollToItem(m_currentItem, QAbstractItemView::PositionAtTop); - } - } - DWidget::resizeEvent(event); -} - -void CSchceduleSearchView::mousePressEvent(QMouseEvent *event) -{ - DWidget::mousePressEvent(event); -} - -CSchceduleSearchDateItem::CSchceduleSearchDateItem(QWidget *parent): DLabel(parent) -{ - setAutoFillBackground(true); -} - -void CSchceduleSearchDateItem::setBackgroundColor(QColor color1) -{ - m_Backgroundcolor = color1; -} - -void CSchceduleSearchDateItem::setText(QColor tcolor, QFont font) -{ - m_textcolor = tcolor; - m_font = font; -} - -void CSchceduleSearchDateItem::setDate(QDate date) -{ - m_date = date; -} - -void CSchceduleSearchDateItem::paintEvent(QPaintEvent *e) -{ - Q_UNUSED(e); - int labelwidth = width(); - int labelheight = height(); - - QPainter painter(this); - QRect fillRect = QRect(0, 0, labelwidth, labelheight); - painter.setRenderHints(QPainter::HighQualityAntialiasing); - painter.setBrush(QBrush(m_Backgroundcolor)); - painter.setPen(Qt::NoPen); - painter.drawRoundedRect(fillRect, 3, 3); - - painter.setFont(m_font); - painter.setPen(m_textcolor); - - QLocale locale; - QString datestr; - if (locale.language() == QLocale::Chinese) { - datestr = QString::number(m_date.year()) + tr("Y") + QString::number(m_date.month()) + tr("M") + QString::number(m_date.day()) + tr("D"); - } else { - datestr = m_date.toString("yyyy/M/d"); - } - painter.drawText(QRect(12, 8, labelwidth, labelheight - 8), Qt::AlignLeft, datestr); - painter.end(); -} - -void CSchceduleSearchDateItem::mousePressEvent(QMouseEvent *event) -{ - Q_UNUSED(event); - emit signalLabelScheduleHide(); -} - -CScheduleListWidget::CScheduleListWidget(QWidget *parent) - : DListWidget (parent) -{ - -} - -CScheduleListWidget::~CScheduleListWidget() -{ - -} - -void CScheduleListWidget::mousePressEvent(QMouseEvent *event) -{ - DListWidget::mousePressEvent(event); - emit signalListWidgetScheduleHide(); -} diff -Nru dde-calendar-5.7.0.4/src/schcedulesearchview.h dde-calendar-5.7.0.23/src/schcedulesearchview.h --- dde-calendar-5.7.0.4/src/schcedulesearchview.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/schcedulesearchview.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,170 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#ifndef SCHCEDULESEARCHVIEW_H -#define SCHCEDULESEARCHVIEW_H - -#include -#include -#include -#include "schedulestructs.h" -#include -DWIDGET_USE_NAMESPACE -class QVBoxLayout; -class CScheduleListWidget; -class CSchceduleSearchItem; -class CSchceduleSearchDateItem; -class CSchceduleSearchView : public DWidget -{ - Q_OBJECT -public: - CSchceduleSearchView(QWidget *parent = nullptr); - ~CSchceduleSearchView() Q_DECL_OVERRIDE; - void setTheMe(int type = 0); - void clearSearch(); - void setMaxWidth(const int w); -signals: - void signalsUpdateShcedule(int id = 0); - void signalDate(QDate date); - void signalSelectSchedule(const ScheduleDtailInfo &scheduleInfo); - void signalViewtransparentFrame(int type); - void signalScheduleHide(); -public slots: - void slotdeleteitem(CSchceduleSearchItem *item); - void slotedititem(CSchceduleSearchItem *item); - void slotsetSearch(QString str); - void slotSelectDate(QDate date); - void slotSelectSchedule(const ScheduleDtailInfo &scheduleInfo); -protected: - void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; - void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; -private: - void updateDateShow(); - void createItemWidget(ScheduleDtailInfo info, QDate date, int rtype); - QListWidgetItem *createItemWidget(QDate date); -private: - CScheduleListWidget *m_gradientItemList; //下拉列表窗 - bool m_widgetFlag; - QVector m_vlistData; - QVector m_labellist; - int m_type; - QDate m_currentDate; - QColor m_bBackgroundcolor = "#000000"; - QColor m_btimecolor = "#526A7F"; - QColor m_bttextcolor = "#414D68"; - QColor m_lBackgroundcolor = Qt::white; - QColor m_ltextcolor = "#001A2E"; - QListWidgetItem *m_currentItem; - int m_maxWidth =200; -}; - -class CScheduleListWidget : public DListWidget -{ - Q_OBJECT -public: - CScheduleListWidget(QWidget *parent = nullptr); - ~CScheduleListWidget() Q_DECL_OVERRIDE; -signals: - void signalListWidgetScheduleHide(); -protected: - void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; -}; - -class CSchceduleSearchItem : public DLabel -{ - Q_OBJECT - enum MouseStatus {M_NONE,M_PRESS,M_HOVER}; -public: - explicit CSchceduleSearchItem(QWidget *parent = nullptr); - void setBackgroundColor(QColor color1); - void setSplitLineColor(QColor color1); - void setText(QColor tcolor, QFont font); - void setTimeC(QColor tcolor, QFont font); - void setData(ScheduleDtailInfo vScheduleInfo, QDate date); - void setRoundtype(int rtype); - void setTheMe(int type = 0); - const ScheduleDtailInfo &getData() const - { - return m_ScheduleInfo; - } -signals: - void signalsDelete(CSchceduleSearchItem *item); - void signalsEdit(CSchceduleSearchItem *item); - void signalSelectDate(QDate date); - void signalSelectSchedule(const ScheduleDtailInfo &scheduleInfo); - void signalViewtransparentFrame(int type); -public slots: - void slotEdit(); - void slotDelete(); - void slotDoubleEvent(int type = 0); -protected: - void paintEvent ( QPaintEvent *e); - void contextMenuEvent(QContextMenuEvent *event); - void mouseDoubleClickEvent(QMouseEvent *event); - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent (QMouseEvent *event ); - void enterEvent(QEvent *event); - void leaveEvent(QEvent *event); - bool eventFilter(QObject *o, QEvent *e); -private: - struct ColorStatus { - QColor background; - QColor timeColor; - QColor textColor; - }; - ScheduleDtailInfo m_ScheduleInfo; - QAction *m_editAction; - QAction *m_deleteAction; - QColor m_Backgroundcolor; - ColorStatus m_presscolor; - ColorStatus m_hovercolor; - QColor m_timecolor; - QColor m_splitlinecolor; - QFont m_timefont; - QColor m_ttextcolor; - QFont m_tfont; - QDate m_date; - MouseStatus m_mouseStatus; - DMenu *m_rightMenu; -// bool m_selectflag = false; -// bool m_hoverflag = false; - int m_roundtype = 1; - int m_radius = 8; - int m_borderframew = 0; -}; -class CSchceduleSearchDateItem : public DLabel -{ - Q_OBJECT - -public: - explicit CSchceduleSearchDateItem(QWidget *parent = nullptr); - void setBackgroundColor(QColor color1); - void setText(QColor tcolor, QFont font); - void setDate(QDate date); -signals: - void signalLabelScheduleHide(); -protected: - void paintEvent ( QPaintEvent *e); - void mousePressEvent(QMouseEvent *event); -private: - QColor m_Backgroundcolor; - QColor m_textcolor; - QFont m_font; - QDate m_date; -}; -#endif // CSHCEDULEDAYVIEW_H diff -Nru dde-calendar-5.7.0.4/src/SchecduleRemindWidget.cpp dde-calendar-5.7.0.23/src/SchecduleRemindWidget.cpp --- dde-calendar-5.7.0.4/src/SchecduleRemindWidget.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/SchecduleRemindWidget.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,174 +0,0 @@ -/* -* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. -* -* Author: uniontech -* -* Maintainer: uniontech -* -* 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 -* 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 . -*/ -#include "SchecduleRemindWidget.h" -#include -#include -#include -DGUI_USE_NAMESPACE -SchecduleRemindWidget::SchecduleRemindWidget(QWidget *parent) - : DArrowRectangle(DArrowRectangle::ArrowLeft, DArrowRectangle::FloatWindow, parent) - , m_centerWidget(new CenterWidget(this)) -{ - m_centerWidget->setFixedWidth(207); - m_centerWidget->setFixedHeight(57); - setContent(m_centerWidget); - this->resizeWithContent(); - QObject::connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, - m_centerWidget, - &CenterWidget::setTheMe); - m_centerWidget->setTheMe(DGuiApplicationHelper::instance()->themeType()); -} - -SchecduleRemindWidget::~SchecduleRemindWidget() -{ - -} - -void SchecduleRemindWidget::setData(const ScheduleDtailInfo &vScheduleInfo, const CSchedulesColor &gcolor) -{ - m_centerWidget->setData(vScheduleInfo, gcolor); - m_ScheduleInfo = vScheduleInfo; - gdcolor = gcolor; - this->setHeight(m_centerWidget->height() + 10); - -} - -CenterWidget::CenterWidget(DWidget *parent) - : DFrame(parent) -{ -// textfont.setFamily("SourceHanSansSC-Medium"); - textfont.setWeight(QFont::Medium); -// DFontSizeManager::instance()->bind(this,DFontSizeManager::T8); -} - -CenterWidget::~CenterWidget() -{ - -} - -void CenterWidget::setData(const ScheduleDtailInfo &vScheduleInfo, const CSchedulesColor &gcolor) -{ - m_ScheduleInfo = vScheduleInfo; - gdcolor = gcolor; - textfont.setPixelSize(12); -// textfont = DFontSizeManager::instance()->get(DFontSizeManager::T8, textfont); - UpdateTextList(); - update(); -} - -void CenterWidget::setTheMe(const int type) -{ -// DPalette palette; -// textColor = palette.color(DPalette::Normal, DPalette::Text); - if (type == 2) { - timeColor = QColor("#C0C6D4"); - timeColor.setAlphaF(0.7); - textColor = QColor("#C0C6D4"); - textColor.setAlphaF(1); - } else { - timeColor = QColor("#414D68"); - timeColor.setAlphaF(0.7); - textColor = QColor("#414D68"); - textColor.setAlphaF(1); - } - update(); -} - -void CenterWidget::UpdateTextList() -{ - testList.clear(); - QFontMetrics metrics(textfont); - textwidth = metrics.width(m_ScheduleInfo.titleName); - textheight = metrics.height(); - const int h_count = qCeil(textwidth / textRectWidth); - - QString text; - if (h_count < 1) { - testList.append(m_ScheduleInfo.titleName); - } else { - const int text_Max_Height = 108; - const int text_HeightMaxCount = qFloor(text_Max_Height / textheight); - for (int i = 0; i < m_ScheduleInfo.titleName.count(); ++i) { - text += m_ScheduleInfo.titleName.at(i); - if (metrics.width(text) > textRectWidth) { - text.remove(text.count() - 1, 1); - testList.append(text); - text = ""; - if (testList.count() == (text_HeightMaxCount - 1)) { - text = m_ScheduleInfo.titleName.right( m_ScheduleInfo.titleName.count() - i ); - testList.append(metrics.elidedText(text, Qt::ElideRight, textRectWidth)); - break; - } - --i; - } else { - if (i + 1 == m_ScheduleInfo.titleName.count()) { - testList.append(text); - } - } - } - } - this->setFixedHeight(testList.count() * textheight + 30 + 8); -} - -void CenterWidget::paintEvent(QPaintEvent *e) -{ - Q_UNUSED(e); - int diam = 8; - int x = 40 - 13; -// int y = 17 - 5; - QFont timeFont; -// timeFont.setFamily("SourceHanSansSC-Medium"); - timeFont.setPixelSize(12); -// timeFont = DFontSizeManager::instance()->get(DFontSizeManager::T8, timeFont); - QPainter painter(this); - - //draw time - QPen pen; - pen.setColor(timeColor); - painter.setPen(pen); - painter.setFont(timeFont); - QString timestr; - - QLocale locale; - timestr = m_ScheduleInfo.beginDateTime.time().toString("AP h:mm"); - QFontMetrics metrics(timeFont); - if (m_ScheduleInfo.allday) - timestr = tr("All Day"); - int timewidth = metrics.width(timestr); - int timeheight = metrics.height(); - - painter.drawText(QRect( x + 13, 7, timewidth, timeheight), Qt::AlignLeft | Qt::AlignTop, timestr); - - painter.setRenderHints(QPainter::Antialiasing); - painter.setPen(Qt::NoPen); - painter.setBrush(QBrush(gdcolor.dotColor)); - painter.drawEllipse(x, 7 + (timeheight - diam) / 2, diam, diam); - - pen.setColor(textColor); - painter.setPen(pen); - painter.setFont(textfont); - for (int i = 0; i < testList.count(); i++) { - painter.drawText( - QRect(x, 30 + i * textheight, textRectWidth, textheight), - Qt::AlignLeft, testList.at(i)); - } - painter.end(); -} diff -Nru dde-calendar-5.7.0.4/src/SchecduleRemindWidget.h dde-calendar-5.7.0.23/src/SchecduleRemindWidget.h --- dde-calendar-5.7.0.4/src/SchecduleRemindWidget.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/SchecduleRemindWidget.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -/* -* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. -* -* Author: uniontech -* -* Maintainer: uniontech -* -* 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 -* 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 . -*/ -#ifndef SchecduleRemindWidget_H -#define SchecduleRemindWidget_H - -#include -#include -#include -#include "schedulestructs.h" -#include "scheduledatamanage.h" - -DWIDGET_USE_NAMESPACE - -class CenterWidget; - -class SchecduleRemindWidget : public DArrowRectangle -{ - Q_OBJECT - Q_DISABLE_COPY(SchecduleRemindWidget) -public: - explicit SchecduleRemindWidget(QWidget *parent = nullptr); - ~SchecduleRemindWidget() Q_DECL_OVERRIDE; - void setData(const ScheduleDtailInfo &vScheduleInfo, const CSchedulesColor &gcolor); - -signals: - -public slots: -private: - CenterWidget *m_centerWidget; - ScheduleDtailInfo m_ScheduleInfo; - CSchedulesColor gdcolor; -}; - -class CenterWidget : public DFrame -{ - Q_OBJECT - Q_DISABLE_COPY(CenterWidget) -public: - CenterWidget(DWidget *parent = nullptr); - ~CenterWidget() Q_DECL_OVERRIDE; - void setData(const ScheduleDtailInfo &vScheduleInfo, const CSchedulesColor &gcolor); - void setTheMe(const int type = 0); -private: - void UpdateTextList(); -protected: - void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE; -private: - QStringList testList; - QFont textfont; - int textwidth; - int textheight; - const int textRectWidth = 165; - ScheduleDtailInfo m_ScheduleInfo; - CSchedulesColor gdcolor; - QColor textColor; - QColor timeColor; -}; - - - -#endif // SchecduleRemindWidget_H diff -Nru dde-calendar-5.7.0.4/src/schedulecoormanage.cpp dde-calendar-5.7.0.23/src/schedulecoormanage.cpp --- dde-calendar-5.7.0.4/src/schedulecoormanage.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/schedulecoormanage.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,259 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#include "schedulecoormanage.h" -#include -CScheduleCoorManage::CScheduleCoorManage() -{ - -} - -CScheduleCoorManage::~CScheduleCoorManage() -{ - -} - -void CScheduleCoorManage::setRange( int w, int h, QDate begindate, QDate enddate, int rightmagin) -{ - m_width = w; - m_height = h; - m_rightmagin = rightmagin; - m_begindate = begindate; - m_enddate = enddate; - m_totalDay = begindate.daysTo(enddate) + 1; -} - -void CScheduleCoorManage::setSenceRange( int w, int h ) -{ - m_width = w; - m_height = h; -} - -void CScheduleCoorManage::setDateRange( QDate begindate, QDate enddate ) -{ - m_begindate = begindate; - m_enddate = enddate; - m_totalDay = begindate.daysTo(enddate) + 1; -} - -QRectF CScheduleCoorManage::getDrawRegion( QDateTime begintime, QDateTime endtime ) -{ - QRectF rect; - QString bb = begintime.toString("yyyyMMddhhmmsszzz"); - QString ee = endtime.toString("yyyyMMddhhmmsszzz"); - - if (begintime > endtime) return rect; - - - QDate begindate = begintime.date(); - QDate enddate = endtime.date(); - QTime beginzero(0, 0, 0); - QTime beginScheduleT = begintime.time(); - QTime endScheduleT = endtime.time(); - if (begindate < m_begindate || enddate > m_enddate) return rect; - qint64 beginday = m_begindate.daysTo(begindate) + 1; - - qint64 day = begindate.daysTo(enddate) + 1; - int ScheduleBT = beginzero.secsTo(beginScheduleT); - int ScheduleET = beginzero.secsTo(endScheduleT); - - qreal rWidth = m_width * (1.0 * day / m_totalDay); - qreal rHeight = m_height * ((ScheduleET - ScheduleBT) / 86400.0); - qreal posX = m_width * (1.0 * (beginday - 1) / m_totalDay); - qreal posY = m_height * (ScheduleBT / 86400.0); - rect = QRectF(posX, posY, rWidth, rHeight); - return rect; -} - -QRectF CScheduleCoorManage::getDrawRegion(QDateTime begintime, QDateTime endtime, int index, int coount) -{ - QRectF rect; - QString bb = begintime.toString("yyyyMMddhhmmsszzz"); - QString ee = endtime.toString("yyyyMMddhhmmsszzz"); - - if (begintime > endtime) return rect; - - - QDate begindate = begintime.date(); - QDate enddate = endtime.date(); - QTime beginzero(0, 0, 0); - QTime beginScheduleT = begintime.time(); - QTime endScheduleT = endtime.time(); - if (begindate < m_begindate || enddate > m_enddate) return rect; - qint64 beginday = m_begindate.daysTo(begindate) + 1; - - qint64 day = begindate.daysTo(enddate) + 1; - int ScheduleBT = beginzero.secsTo(beginScheduleT); - int ScheduleET = beginzero.secsTo(endScheduleT); - - qreal rWidth = m_width * (1.0 * day / m_totalDay) / coount; - qreal rHeight = m_height * ((ScheduleET - ScheduleBT) / 86400.0); - qreal posX = m_width * (1.0 * (beginday - 1) / m_totalDay) + (index - 1) * rWidth; - qreal posY = m_height * (ScheduleBT / 86400.0); - rect = QRectF(posX, posY, rWidth, rHeight); - return rect; -} - -QRectF CScheduleCoorManage::getDrawRegion(QDate date, QDateTime begintime, QDateTime endtime, int index, int coount, int maxnum, int type) -{ - QRectF rect; - QString bb = begintime.toString("yyyyMMddhhmmsszzz"); - QString ee = endtime.toString("yyyyMMddhhmmsszzz"); - - if (begintime > endtime) return rect; - - - QDate begindate = begintime.date(); - QDate enddate = endtime.date(); - - - QTime beginzero(0, 0, 0); - QTime beginScheduleT = begintime.time(); - QTime endScheduleT = endtime.time(); - - if (begindate < date) { - begindate = date; - beginScheduleT = beginzero; - } - if (enddate > date) { - enddate = date; - endScheduleT = QTime(23, 59, 59); - } - //if (begindate < m_begindate || enddate > m_enddate) return rect; - qint64 beginday = m_begindate.daysTo(begindate) + 1; - - qint64 day = begindate.daysTo(enddate) + 1; - int ScheduleBT = beginzero.secsTo(beginScheduleT); - int ScheduleET = beginzero.secsTo(endScheduleT); - - qreal rWidth = m_width * (1.0 * day / m_totalDay) / coount; - qreal rHeight = m_height * ((ScheduleET - ScheduleBT) / 86400.0); - qreal posX = m_width * (1.0 * (beginday - 1) / m_totalDay) + (index - 1) * rWidth; - qreal posY = m_height * (ScheduleBT / 86400.0); - if (coount > maxnum && type == 0) { - - qreal sscale = 27.0 / (m_width * (1.0 * day / m_totalDay)); - if (index < maxnum + 1) { - rWidth = m_width * (1.0 * day / m_totalDay) * sscale + 0.5; - posX = m_width * (1.0 * (beginday - 1) / m_totalDay) + (index - 1) * rWidth; - } else { - qreal trWidth = m_width * (1.0 * day / m_totalDay) * sscale + 0.5; - rWidth = m_width * (1.0 * day / m_totalDay) - (index - 1) * trWidth; - posX = m_width * (1.0 * (beginday - 1) / m_totalDay) + (index - 1) * trWidth; - } - } - if (rHeight < 20) { - if (posY + 20 > m_height) - posY = m_height - 20; - rHeight = 20; - } - if (posX < 1) { - posX = 1; - rWidth = rWidth - posX; - } - rect = QRectF(posX, posY, rWidth, rHeight); - return rect; -} - -QRectF CScheduleCoorManage::getDrawRegionF( QDateTime begintime, QDateTime endtime ) -{ - QRectF rectf; - if (begintime > endtime) return rectf; - - QDate begindate = begintime.date(); - QDate enddate = endtime.date(); - QTime beginzero(0, 0, 0); - QTime beginScheduleT = begintime.time(); - QTime endScheduleT = endtime.time(); - if (begindate < m_begindate || enddate > m_enddate) return rectf; - qint64 beginday = m_begindate.daysTo(begindate) + 1; - - qint64 day = begindate.daysTo(enddate) + 1; - int ScheduleBT = beginzero.secsTo(beginScheduleT); - int ScheduleET = beginzero.secsTo(endScheduleT); - - qreal rWidth = m_width * (1.0 * day / m_totalDay); - qreal rHeight = m_height * ((ScheduleET - ScheduleBT) / 86400.0); - qreal posX = m_width * (1.0 * (beginday - 1) / m_totalDay); - qreal posY = m_height * (ScheduleBT / 86400.0); - rectf = QRectF(posX, posY, rWidth, rHeight); - return rectf; -} - -QRectF CScheduleCoorManage::getAllDayDrawRegion(QDate begin, QDate end) -{ - QRectF rect; - if (begin > end) return rect; - - QDate begindate = begin; - QDate enddate = end; - - if (begindate < m_begindate) begindate = m_begindate; - if (enddate > m_enddate) enddate = m_enddate; - //if (begindate < m_begindate || enddate > m_enddate) return rect; - qint64 beginday = m_begindate.daysTo(begindate); - - qint64 day = begindate.daysTo(enddate) + 1; - - - qreal rWidth = m_width * (1.0 * day / m_totalDay) - 12; - qreal rHeight = m_height; - qreal posX = m_width * (1.0 * beginday / m_totalDay); - qreal posY = 0; - rect = QRectF(posX + 6, posY, rWidth - m_rightmagin, rHeight); - return rect; -} - -QDateTime CScheduleCoorManage::getDate(QPointF pos) -{ - QDateTime begintime; - qint64 day = static_cast((1.0 * pos.x() / m_width) * m_totalDay); - if (day <0) { - day = 0; - } else if (day >=m_totalDay) { - day = m_totalDay-1; - } - int time =static_cast((1.0 * pos.y() / m_height) * 86400.0); - int hours = time / 3600; - int minutes = (time - 3600 * hours) / 60; - int secss = time - 3600 * hours - 60 * minutes; - QDate date = m_begindate.addDays(day); - begintime.setDate(date); - begintime.setTime(QTime(hours, minutes, secss)); - return begintime; -} - -QDate CScheduleCoorManage::getsDate(QPointF pos) -{ - qint64 day = static_cast((1.0 * pos.x() / m_width) * m_totalDay); - if (day <0) { - day = 0; - } else if (day >=m_totalDay) { - day = m_totalDay-1; - } - QDate date = m_begindate.addDays(day); - return date; -} - -float CScheduleCoorManage::getHeight(QTime time) -{ - QTime beginzero(0, 0, 0); - int ScheduleBT = beginzero.secsTo(time); - float posY = static_cast(m_height * (ScheduleBT / 86400.0)); - return posY; -} diff -Nru dde-calendar-5.7.0.4/src/schedulecoormanage.h dde-calendar-5.7.0.23/src/schedulecoormanage.h --- dde-calendar-5.7.0.4/src/schedulecoormanage.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/schedulecoormanage.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#ifndef SCHEDULECOORMANAGE_H -#define SCHEDULECOORMANAGE_H -#include -#include -#include -class CScheduleCoorManage -{ -public: - CScheduleCoorManage(); - ~CScheduleCoorManage(); - void setRange(int w, int h, QDate begindate, QDate enddate, int rightmagin); - void setSenceRange(int w, int h); - void setDateRange(QDate begindate, QDate enddate); - int getRightMagin()const - { - return m_rightmagin; - } - QRectF getDrawRegion(QDateTime begintime, QDateTime endtime); - QRectF getDrawRegion(QDateTime begintime, QDateTime endtime, int index, int coount); - QRectF getDrawRegion(QDate date, QDateTime begintime, QDateTime endtime, int index, int coount, int maxNum, int type = 0); - QRectF getDrawRegionF(QDateTime begintime, QDateTime endtime); - QRectF getAllDayDrawRegion(QDate begin, QDate end); - QDateTime getDate(QPointF pos); - QDate getsDate(QPointF pos); - float getHeight(QTime time); - QDate getBegindate() - { - return m_begindate; - } -private: - int m_width; - int m_height; - QDate m_begindate; - QDate m_enddate; - qint64 m_totalDay; - int m_rightmagin = 0; -}; - -#endif // SCHEDULECOORMANAGE_H diff -Nru dde-calendar-5.7.0.4/src/scheduledatamanage.cpp dde-calendar-5.7.0.23/src/scheduledatamanage.cpp --- dde-calendar-5.7.0.4/src/scheduledatamanage.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/scheduledatamanage.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,724 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#include "scheduledatamanage.h" - -#include "schedulesdbus.h" -#include "calendardbus.h" -CScheduleDataManage *CScheduleDataManage::m_vscheduleDataManage = new CScheduleDataManage; -CScheduleDataCtrl *CScheduleDataManage::getscheduleDataCtrl() -{ - return m_scheduleDataCtrl; -} - -CHuangliDayDataManage *CScheduleDataManage::getHuangliDayDataManage() -{ - return m_HuangliDayDataManage; -} - -CSchedulesColor CScheduleDataManage::getScheduleColorByType(int type) -{ - CSchedulesColor color; - color.type = -1; - for (int i = 0; i < m_vScheduleColor.count(); i++) { - if (m_vScheduleColor.at(i).type == type) { - color = m_vScheduleColor.at(i); - break; - } - } - return color; -} - -QColor CScheduleDataManage::getSystemActiveColor() -{ - return DGuiApplicationHelper::instance()->applicationPalette().highlight().color(); -} - -void CScheduleDataManage::setSearchResult(QVector &vData) -{ - m_vScheduleInfo = vData; -} - -bool CScheduleDataManage::getSearchResult(ScheduleDtailInfo info) -{ - QDateTime date = QDateTime::currentDateTime(); - - QDateTime bdate = date.addMonths(-6); - if (!bdate.isValid()) { - QDateTime tdate = date; - tdate.setDate(QDate(date.date().year(), date.date().month(), 1)); - bdate = tdate.addMonths(-6); - } - QDateTime edate = date.addMonths(6); - if (!edate.isValid()) { - QDateTime tdate = date; - tdate.setDate(QDate(date.date().year(), date.date().month(), 1)); - edate = tdate.addMonths(7); - edate = edate.addDays(-1); - } - - for (int i = 0; i < m_vScheduleInfo.size(); i++) { - QVector &scheduleInfolist = m_vScheduleInfo[i].vData; - for (int j = 0; j < scheduleInfolist.count(); j++) { - if (scheduleInfolist.at(j) == info) { - if (bdate < info.beginDateTime && edate > info.endDateTime) - return true; - } - } - } - return false; -} - -bool CScheduleDataManage::getSearchResult(QDate date) -{ - for (int i = 0; i < m_vScheduleInfo.size(); i++) { - QVector &scheduleInfolist = m_vScheduleInfo[i].vData; - if (m_vScheduleInfo[i].date == date && !scheduleInfolist.isEmpty()) { - return true; - } - } - return false; -} - -void CScheduleDataManage::setTheMe(int type) -{ - m_theme = type; - m_vScheduleColor.clear(); - if (type == 0 || type == 1) { - CSchedulesColor workC; - workC.type = 1; - workC.dotColor = "#FB2525"; - workC.dotColor.setAlphaF(0.5); - workC.gradientFromC = "#FBCEB7"; - workC.gradientFromC.setAlphaF(0.7); - workC.gradientToC = "#FA9D9A"; - workC.gradientToC.setAlphaF(0.7); - workC.Purecolor = "#F85566"; - workC.Purecolor.setAlphaF(0.2); - workC.shadowcolor = "#FB2525"; - workC.shadowcolor.setAlphaF(0.5); - workC.textColor = "#000000"; - workC.timeColor = "#B54A4B"; - workC.hightlightgradientFromC = "#FFD0B8"; - workC.hightlightgradientToC = "#FF908D"; - QColor workP("#F9AEB8"); - //workP.setAlphaF(0.8); - workC.hightlightPurecolor = workP; - workC.splitColor = "#FB2525"; - workC.splitColor.setAlphaF(0.5); - - workC.hovergradientFromC = "#FFD0B8"; - workC.hovergradientFromC.setAlphaF(0.95); - workC.hovergradientToC = "#FF9D9A"; - workC.hovergradientToC.setAlphaF(0.95); - QColor workhP("#FFB6BD"); - workhP.setAlphaF(0.8); - workC.hoverPurecolor = workhP; - - workC.pressgradientToC = workC.gradientToC; - workC.pressgradientFromC = workC.gradientFromC; - workC.pressPurecolor = workC.Purecolor; - workC.pressgradientToC.setAlphaF(0.8); - workC.pressgradientFromC.setAlphaF(0.8); - workC.pressPurecolor.setAlphaF(0.2); - m_vScheduleColor.append(workC); - - CSchedulesColor lifeC; - lifeC.type = 2; - lifeC.dotColor = "#82D245"; - lifeC.dotColor.setAlphaF(1); - lifeC.gradientFromC = "#B7E6FB"; - lifeC.gradientFromC.setAlphaF(0.7); - lifeC.gradientToC = "#D4FFB3"; - lifeC.gradientToC.setAlphaF(0.7); - lifeC.Purecolor = "#6FFF00"; - lifeC.Purecolor.setAlphaF(0.2); - lifeC.shadowcolor = "#82D245"; - lifeC.textColor = "#000000"; - lifeC.timeColor = "#53A316"; - lifeC.hightlightgradientFromC = "#9AE5FF"; - lifeC.hightlightgradientToC = "#C7FF94"; - QColor lifeP("#C7FF94"); - //lifeP.setAlphaF(0.8); - lifeC.hightlightPurecolor = lifeP; - - lifeC.hovergradientFromC = "#A8E9FF"; - lifeC.hovergradientToC = "#D5FFAF"; - lifeC.hovergradientFromC.setAlphaF(0.95); - lifeC.hovergradientToC.setAlphaF(0.95); - QColor lifehP("#C4FF98"); - lifehP.setAlphaF(0.8); - lifeC.hoverPurecolor = lifehP; - lifeC.splitColor = "#82D245"; - lifeC.pressgradientToC = lifeC.gradientToC; - lifeC.pressgradientFromC = lifeC.gradientFromC; - lifeC.pressPurecolor = lifeC.Purecolor; - lifeC.pressgradientToC.setAlphaF(0.8); - lifeC.pressgradientFromC.setAlphaF(0.8); - lifeC.pressPurecolor.setAlphaF(0.2); - m_vScheduleColor.append(lifeC); - - CSchedulesColor otherC; - otherC.type = 3; - otherC.dotColor = "#BA60FA"; - otherC.dotColor.setAlphaF(1); - otherC.gradientFromC = "#FBE9B7"; - otherC.gradientFromC.setAlphaF(0.7); - otherC.gradientToC = "#DFB3FF"; - otherC.gradientToC.setAlphaF(0.7); - otherC.Purecolor = "#D191FF"; - otherC.Purecolor.setAlphaF(0.2); - otherC.shadowcolor = "#BA60FA"; - otherC.textColor = "#000000"; - otherC.timeColor = "#8548B1"; - otherC.hightlightgradientFromC = "#FFE8AC"; - otherC.hightlightgradientToC = "#FBA5FF"; - QColor otherP("#EAC4FF"); - //otherP.setAlphaF(0.8); - otherC.hightlightPurecolor = otherP; - - otherC.hovergradientFromC = "#FFE8AC"; - otherC.hovergradientToC = "#E2A5FF"; - otherC.hovergradientFromC.setAlphaF(0.95); - otherC.hovergradientToC.setAlphaF(0.95); - QColor otherhP("#E6C5FF"); - otherhP.setAlphaF(0.8); - otherC.hoverPurecolor = otherhP; - otherC.splitColor = "#BA60FA"; - otherC.pressgradientToC = otherC.gradientToC; - otherC.pressgradientFromC = otherC.gradientFromC; - otherC.pressPurecolor = otherC.Purecolor; - otherC.pressgradientToC.setAlphaF(0.8); - otherC.pressgradientFromC.setAlphaF(0.8); - otherC.pressPurecolor.setAlphaF(0.2); - m_vScheduleColor.append(otherC); - - CSchedulesColor solar; - solar.type = 4; - solar.dotColor = "#FF7272"; - solar.dotColor.setAlphaF(1); - solar.gradientFromC = "#FF7272"; - solar.gradientFromC.setAlphaF(0.3); - solar.gradientToC = "#FF7272"; - solar.gradientToC.setAlphaF(0.3); - solar.Purecolor = "#FF7272"; - solar.Purecolor.setAlphaF(0.3); - solar.shadowcolor = "#BA60FA"; - solar.textColor = "#000000"; - solar.timeColor = "#8548B1"; - solar.hightlightgradientFromC = "#F9AAAA"; - solar.hightlightgradientFromC.setAlphaF(1); - solar.hightlightgradientToC = "#F9AAAA"; - solar.hightlightgradientToC.setAlphaF(1); - solar.hightlightPurecolor = "#F9AAAA"; - solar.hightlightPurecolor.setAlphaF(1); - - solar.hovergradientFromC = "#FFB0B1"; - solar.hovergradientToC = "#FFB0B1"; - solar.hovergradientFromC.setAlphaF(0.95); - solar.hovergradientToC.setAlphaF(0.95); - solar.hoverPurecolor = "#FF7272"; - solar.splitColor = "#FF7272"; - solar.pressgradientFromC = "#FF7272"; - solar.pressgradientFromC.setAlphaF(0.3); - solar.pressgradientToC = "#FF7272"; - solar.pressgradientToC.setAlphaF(0.3); - - solar.pressPurecolor = solar.Purecolor; - solar.pressgradientToC.setAlphaF(0.4); - solar.pressgradientFromC.setAlphaF(0.4); - solar.pressPurecolor.setAlphaF(0.1); - m_vScheduleColor.append(solar); - - } else if (type == 2) { - CSchedulesColor workC; - workC.type = 1; - workC.dotColor = "#F85566"; - workC.dotColor.setAlphaF(0.5); - workC.gradientFromC = "#965A26"; - workC.gradientToC = "#8B2521"; - workC.gradientToC.setAlphaF(0.5); - workC.gradientFromC.setAlphaF(0.5); - workC.Purecolor = "#F85566"; - workC.Purecolor.setAlphaF(0.1); - workC.shadowcolor = "#FB2525"; - workC.shadowcolor.setAlphaF(0.5); - workC.textColor = "#C0C6D4"; -// workC.textColor.setAlphaF(1); - workC.timeColor = "#B54A4B"; - workC.hightlightgradientToC = "#992D2A"; - workC.hightlightgradientToC.setAlphaF(0.8); - workC.hightlightgradientFromC = "#8B521F"; - workC.hightlightgradientFromC.setAlphaF(0.8); - QColor workP("#77373E"); - workP.setAlphaF(0.8); - workC.hightlightPurecolor = workP; - - workC.hovergradientFromC = "#965A26"; - workC.hovergradientToC = "#8B2521"; - workC.hovergradientFromC.setAlphaF(0.65); - workC.hovergradientToC.setAlphaF(0.65); - QColor workhP("#F85566"); - workhP.setAlphaF(0.2); - workC.hoverPurecolor = workhP; - workC.splitColor = "#F85566"; - workC.splitColor.setAlphaF(0.5); - workC.pressgradientToC = workC.gradientToC; - workC.pressgradientFromC = workC.gradientFromC; - workC.pressPurecolor = workC.Purecolor; - workC.pressgradientToC.setAlphaF(0.4); - workC.pressgradientFromC.setAlphaF(0.4); - workC.pressPurecolor.setAlphaF(0.15); - m_vScheduleColor.append(workC); - - CSchedulesColor lifeC; - lifeC.type = 2; - lifeC.dotColor = "#59F88D"; - lifeC.dotColor.setAlphaF(0.5); - lifeC.gradientFromC = "#2D6883"; - lifeC.gradientToC = "#5D7D44"; - lifeC.gradientToC.setAlphaF(0.5); - lifeC.gradientFromC.setAlphaF(0.5); - lifeC.Purecolor = "#59F88D"; - lifeC.Purecolor.setAlphaF(0.1); - lifeC.shadowcolor = "#25FA6B"; - lifeC.shadowcolor.setAlphaF(0.5); - lifeC.textColor = "#C0C6D4"; -// lifeC.textColor.setAlphaF(1); - lifeC.timeColor = "#38A35B"; - lifeC.hightlightgradientFromC = "#2D6883"; - lifeC.hightlightgradientFromC.setAlphaF(0.8); - lifeC.hightlightgradientToC = "#5D7D44"; - lifeC.hightlightgradientToC.setAlphaF(0.8); - QColor lifeP("#337044"); - lifeP.setAlphaF(0.8); - lifeC.hightlightPurecolor = lifeP; - lifeC.splitColor = "#25FA6B"; - lifeC.splitColor.setAlphaF(0.3); - lifeC.hovergradientFromC = "#2D6883"; - lifeC.hovergradientToC = "#5D7D44"; - lifeC.hovergradientFromC.setAlphaF(0.65); - lifeC.hovergradientToC.setAlphaF(0.65); - QColor lifehP("#59F88D"); - lifehP.setAlphaF(0.2); - lifeC.hoverPurecolor = lifehP; - lifeC.pressgradientToC = lifeC.gradientToC; - lifeC.pressgradientFromC = lifeC.gradientFromC; - lifeC.pressPurecolor = lifeC.Purecolor; - lifeC.pressgradientToC.setAlphaF(0.4); - lifeC.pressgradientFromC.setAlphaF(0.4); - lifeC.pressPurecolor.setAlphaF(0.15); - m_vScheduleColor.append(lifeC); - - CSchedulesColor otherC; - otherC.type = 3; - otherC.dotColor = "#C155F8"; - otherC.dotColor.setAlphaF(0.7); - otherC.gradientFromC = "#8C4E2C"; - otherC.gradientToC = "#7D37AF"; - otherC.gradientToC.setAlphaF(0.5); - otherC.gradientFromC.setAlphaF(0.5); - otherC.Purecolor = "#C155F8"; - otherC.Purecolor.setAlphaF(0.1); - otherC.shadowcolor = "#BE3DFF"; - otherC.shadowcolor.setAlphaF(0.5); - otherC.textColor = "#C0C6D4"; -// otherC.textColor.setAlphaF(1); - otherC.timeColor = "#9857C8"; - otherC.hightlightgradientFromC = "#8C4E2C"; - otherC.hightlightgradientFromC.setAlphaF(0.8); - otherC.hightlightgradientToC = "#803BAE"; - otherC.hightlightgradientToC.setAlphaF(0.8); - QColor otherP("#613776"); - otherP.setAlphaF(0.8); - otherC.hightlightPurecolor = otherP; - - otherC.hovergradientFromC = "#8C4E2C"; - otherC.hovergradientToC = "#7D37AF"; - otherC.hovergradientFromC.setAlphaF(0.65); - otherC.hovergradientToC.setAlphaF(0.65); - QColor otherhP("#C155F8"); - otherhP.setAlphaF(0.2); - otherC.hoverPurecolor = otherhP; - otherC.splitColor = "#BA32FF"; - otherC.splitColor.setAlphaF(0.5); - otherC.pressgradientToC = otherC.gradientToC; - otherC.pressgradientFromC = otherC.gradientFromC; - otherC.pressPurecolor = otherC.Purecolor; - otherC.pressgradientToC.setAlphaF(0.4); - otherC.pressgradientFromC.setAlphaF(0.4); - otherC.pressPurecolor.setAlphaF(0.15); - m_vScheduleColor.append(otherC); - - CSchedulesColor solar; - solar.type = 4; - solar.dotColor = "#FF7272"; - solar.dotColor.setAlphaF(0.8); - solar.gradientFromC = "#FF7272"; - solar.gradientFromC.setAlphaF(0.3); - solar.gradientToC = "#FF7272"; - solar.gradientToC.setAlphaF(0.3); - solar.Purecolor = "#FF7272"; - solar.Purecolor.setAlphaF(0.3); - solar.shadowcolor = "#BA60FA"; - solar.textColor = "#C0C6D4"; - solar.timeColor = "#8548B1"; - solar.hightlightgradientFromC = "#A24545"; - solar.hightlightgradientFromC.setAlphaF(0.8); - solar.hightlightgradientToC = "#A24545"; - solar.hightlightgradientToC.setAlphaF(0.8); - solar.hightlightPurecolor = "#A24545"; - solar.hightlightPurecolor.setAlphaF(0.8); - - solar.hovergradientFromC = "#E56464"; - solar.hovergradientToC = "#E56464"; - solar.hovergradientFromC.setAlphaF(0.35); - solar.hovergradientToC.setAlphaF(0.35); - solar.hoverPurecolor = "#E56464"; - solar.splitColor = "#FF7272"; - solar.pressgradientFromC = "#FF7272"; - solar.pressgradientFromC.setAlphaF(0.3); - solar.pressgradientToC = solar.pressgradientFromC; -// solar.pressgradientToC = "#000000"; -// solar.pressgradientToC.setAlphaF(0.05); - - solar.pressPurecolor = solar.Purecolor; - solar.pressgradientToC.setAlphaF(0.4); - solar.pressgradientFromC.setAlphaF(0.4); - solar.pressPurecolor.setAlphaF(0.1); - m_vScheduleColor.append(solar); - } -} - -CScheduleDataManage *CScheduleDataManage::getScheduleDataManage() -{ - return m_vscheduleDataManage; -} - -void CScheduleDataManage::clear() -{ - delete m_scheduleDataCtrl; -} - -CScheduleDataManage::CScheduleDataManage () -{ - m_scheduleDataCtrl = new CScheduleDataCtrl; - m_HuangliDayDataManage = new CHuangliDayDataManage; - - m_GetAllYearScheduleInfo = new YearScheduleInfo(); - CSchedulesColor workC; - workC.type = 1; - workC.gradientFromC = "#FBCEB7"; - workC.gradientToC = "#FA9D9A"; - workC.Purecolor = "#F85566"; - workC.Purecolor.setAlphaF(0.2); - workC.shadowcolor = "#FB2525"; - workC.shadowcolor.setAlphaF(0.5); - workC.textColor = "#000000"; - workC.timeColor = "#B54A4B"; - m_vScheduleColor.append(workC); - - CSchedulesColor lifeC; - lifeC.type = 2; - lifeC.gradientFromC = "#B7E6FB"; - lifeC.gradientToC = "#D4FFB3"; - lifeC.Purecolor = "#6FFF00"; - lifeC.Purecolor.setAlphaF(0.2); - lifeC.shadowcolor = "#82D245"; - lifeC.textColor = "#000000"; - lifeC.timeColor = "#53A316"; - m_vScheduleColor.append(lifeC); - - CSchedulesColor otherC; - otherC.type = 3; - otherC.gradientFromC = "#FBE9B7"; - otherC.gradientToC = "#DFB3FF"; - otherC.Purecolor = "#D191FF"; - otherC.Purecolor.setAlphaF(0.2); - otherC.shadowcolor = "#BA60FA"; - otherC.textColor = "#000000"; - otherC.timeColor = "#8548B1"; - m_vScheduleColor.append(otherC); - CSchedulesColor solar; - solar.type = 4; - solar.dotColor = "#FF7272"; - solar.dotColor.setAlphaF(1); - solar.gradientFromC = "#FF7272"; - solar.gradientFromC.setAlphaF(0.3); - solar.gradientToC = "#FF7272"; - solar.gradientToC.setAlphaF(0.3); - solar.Purecolor = "#FF7272"; - solar.Purecolor.setAlphaF(0.3); - solar.shadowcolor = "#BA60FA"; - solar.textColor = "#000000"; - solar.timeColor = "#8548B1"; - m_vScheduleColor.append(solar); -} - -CScheduleDataManage::~CScheduleDataManage() -{ - delete m_scheduleDataCtrl; - delete m_HuangliDayDataManage; - delete m_GetAllYearScheduleInfo; -} - -YearScheduleInfo *CScheduleDataManage::getGetAllYearScheduleInfo() const -{ - return m_GetAllYearScheduleInfo; -} - -int CScheduleDataManage::getFirstWeekDay() const -{ - return m_firstWeekDay; -} - -void CScheduleDataManage::setFirstWeekDay(int firstWeekDay) -{ - m_firstWeekDay = firstWeekDay; -} - -QDate CScheduleDataManage::getFirstOfMonth(const QDate &date) -{ - const QDate firstDay(date.year(), date.month(), 1); - int offset = firstDay.dayOfWeek() % 7 - m_firstWeekDay ; - - const int day = offset <0 ?offset +7:offset; - return firstDay.addDays(0 - day); -} - -void CScheduleDataManage::setCurrentYear(int CurrentYear) -{ - m_CurrentYear = CurrentYear; - m_GetAllYearScheduleInfo->m_year = m_CurrentYear; - for (int i = 1; i < 13; ++i) { - m_GetAllYearScheduleInfo->m_firstDay[i] = - getFirstOfMonth(QDate(m_CurrentYear,i,1)); - } - -} - -ScheduleDtailInfo CScheduleDataManage::getPressSelectInfo() const -{ - return m_PressSelectInfo; -} - -void CScheduleDataManage::setPressSelectInfo(const ScheduleDtailInfo &PressSelectInfo) -{ - m_PressSelectInfo = PressSelectInfo; -} - -CScheduleDataCtrl::CScheduleDataCtrl() -{ - qRegisterMetaType>("QVector"); - m_dbus = new CSchedulesDBus("com.deepin.daemon.Calendar", - "/com/deepin/daemon/Calendar/Scheduler", - QDBusConnection::sessionBus(), this); - m_scheduleDateCache = nullptr; - - if (!m_scheduleDateCache) - m_scheduleDateCache = new QMap; - m_thread = new CDataProcessThread(m_dbus); - connect(m_thread, &CDataProcessThread::signalsDataProcess, this, &CScheduleDataCtrl::slotDataProcess); -} - -CScheduleDataCtrl::~CScheduleDataCtrl() -{ - delete m_scheduleDateCache; - delete m_dbus; - delete m_thread; -} - - - -qint64 CScheduleDataCtrl::addSchedule(const ScheduleDtailInfo &scheduledate) -{ - clearData(); - return m_dbus->CreateJob(scheduledate); -} - -bool CScheduleDataCtrl::getScheduleInfoById(int id, ScheduleDtailInfo &out) -{ - return m_dbus->GetJob(id, out); -} - -bool CScheduleDataCtrl::getScheduleInfo(const QDate bdate, const QDate edate, QVector &out) -{ - return m_dbus->GetJobs(bdate.year(), bdate.month(), bdate.day(), edate.year(), edate.month(), edate.day(), out); -} - -bool CScheduleDataCtrl::queryScheduleInfo(QString key, QDateTime starttime, QDateTime endtime, QVector &out) -{ - return m_dbus->QueryJobs(key, starttime, endtime, out); -} - -bool CScheduleDataCtrl::queryScheduleInfo(QString key, QDateTime starttime, QDateTime endtime, QString &out) -{ - return m_dbus->QueryJobs(key, starttime, endtime, out); -} - -bool CScheduleDataCtrl::updateScheduleInfo(const ScheduleDtailInfo &scheduledate) -{ - clearData(); - return m_dbus->UpdateJob(scheduledate); -} - -bool CScheduleDataCtrl::deleteScheduleInfoById(int id) -{ - clearData(); - return m_dbus->DeleteJob(id); -} - -bool CScheduleDataCtrl::GetType(qint64 jobId, ScheduleType &out) -{ - while (m_thread->isRunning()); - return m_dbus->GetType(jobId, out); -} - -QString CScheduleDataCtrl::InfoToJson(const ScheduleDtailInfo &scheduledate) -{ - return m_dbus->createScheduleDtailInfojson(scheduledate); -} - -ScheduleDtailInfo CScheduleDataCtrl::JsonObjectToInfo(QJsonObject &obj) -{ - return m_dbus->parsingScheduleDtailInfojsonID(obj); -} - -void CScheduleDataCtrl::slotupdatescheduleD(QWidget *w, QDate begin, QDate end) -{ - m_currentWidget = w; - m_begindate = begin; - m_enddate = end; - m_thread->DataProcessStart(begin, end); -} - -void CScheduleDataCtrl::slotDataProcess(QVector out) -{ - emit signalsupdatescheduleD(m_currentWidget, out); -} - -void CScheduleDataCtrl::clearData() -{ - while (m_thread->isRunning()); - m_scheduleDateCache->clear(); -} - -CSchedulesDBus *CScheduleDataCtrl::getDbus() const -{ - return m_dbus; -} - -CDataProcessThread::CDataProcessThread(CSchedulesDBus *_DataManage) - : m_DataManage(_DataManage) - , m_stopFlag(false) -{ - Q_ASSERT(m_DataManage != nullptr); -} - -CDataProcessThread::~CDataProcessThread() -{ - //防止未运行完 - m_mutex.lock(); - m_stopFlag = true; - m_mutex.unlock(); - //是否允许 - while (isRunning()) {} -} - -void CDataProcessThread::DataProcessStart(QDate begin, QDate end) -{ - m_mutex.lock(); - this->m_stopFlag = true; - this->m_begindate = begin; - this->m_enddate = end; - m_mutex.unlock(); - - while (isRunning()) {} - m_mutex.lock(); - m_stopFlag = false; - m_mutex.unlock(); - - start(QThread::NormalPriority); -} - -void CDataProcessThread::run() -{ - forever { - //运行 - m_mutex.lock(); - QDate bdate = m_begindate; - QDate edate = m_enddate; - bool t_stopFlag = m_stopFlag; - m_mutex.unlock(); - if (t_stopFlag) - return; - QVector out; - bool flag = m_DataManage->GetJobs(bdate.year(), bdate.month(), bdate.day(), edate.year(), edate.month(), edate.day(), out); - if (!flag) return; - emit signalsDataProcess(out); - break; - } -} - -CHuangliDayDataManage::CHuangliDayDataManage() -{ - m_DBusInter = new CalendarDBus("com.deepin.api.LunarCalendar", - "/com/deepin/api/LunarCalendar", - QDBusConnection::sessionBus(), this); -} - -CHuangliDayDataManage::~CHuangliDayDataManage() -{ - delete m_DBusInter; -} - -bool CHuangliDayDataManage::getSoloDay(QDate date, QString &str) -{ - CaHuangLiDayInfo scurrentDayinfo; - if (m_DBusInter->GetHuangLiDayCalendar(date.year(), date.month(), date.day(), scurrentDayinfo)) { - if (scurrentDayinfo.mSolarFestival.isEmpty() && scurrentDayinfo.mLunarFestival.isEmpty()) { - str = QString(); - return false; - } else if (!scurrentDayinfo.mSolarFestival.isEmpty() && !scurrentDayinfo.mLunarFestival.isEmpty()) { - str = scurrentDayinfo.mSolarFestival + " " + scurrentDayinfo.mLunarFestival; - return true; - } else { - str = scurrentDayinfo.mSolarFestival + scurrentDayinfo.mLunarFestival; - return true; - } - } - return false; -} - -QVector CHuangliDayDataManage::getDayFlag(QDate date) -{ - QVector vflag; - vflag.resize(42); - vflag.fill(false); - CaHuangLiMonthInfo out; - if (m_DBusInter->GetHuangLiMonthCalendar(date.year(), date.month(), true, out)) { - if (out.mCaLunarDayInfo.count() == 42) { - for (int i = 0; i < 42; i++) { - if (!out.mCaLunarDayInfo.at(i).mSolarFestival.isEmpty() || !out.mCaLunarDayInfo.at(i).mLunarFestival.isEmpty()) { - vflag[i] = true; - } - } - } - } - return vflag; -} diff -Nru dde-calendar-5.7.0.4/src/scheduledatamanage.h dde-calendar-5.7.0.23/src/scheduledatamanage.h --- dde-calendar-5.7.0.4/src/scheduledatamanage.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/scheduledatamanage.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,197 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#ifndef SCHEDULEDATAMANAGE_H -#define SCHEDULEDATAMANAGE_H - -#include -#include -#include -#include - -#include "calendardbus.h" -#include "schedulestructs.h" -#include "dbusdatagetthread.h" - -DGUI_USE_NAMESPACE -struct CSchedulesColor { - int type; - QColor gradientFromC; - QColor gradientToC; - QColor dotColor; - QColor Purecolor; - QColor shadowcolor; - QColor textColor; - QColor timeColor; - QColor hightlightgradientFromC; - QColor hightlightgradientToC; - QColor hightlightPurecolor; - QColor hovergradientFromC; - QColor hovergradientToC; - QColor hoverPurecolor; - QColor splitColor; - QColor pressgradientFromC; - QColor pressgradientToC; - QColor pressPurecolor; -}; - -class CSchedulesDBus; -class CScheduleDataCtrl; -class CHuangliDayDataManage; -class CaLunarMonthInfo; - -class CScheduleDataManage -{ -public: - static CScheduleDataManage *getScheduleDataManage(); - CScheduleDataCtrl *getscheduleDataCtrl(); - CHuangliDayDataManage *getHuangliDayDataManage(); - CSchedulesColor getScheduleColorByType(int type); - QColor getSystemActiveColor(); - void setSearchResult(QVector &vData); - bool getSearchResult(ScheduleDtailInfo info);//true 高亮 - bool getSearchResult(QDate date);//true 高亮 - void setTheMe(int type = 0); - int getTheme() - { - return m_theme; - } - void clear(); - ScheduleDtailInfo getPressSelectInfo() const; - void setPressSelectInfo(const ScheduleDtailInfo &PressSelectInfo); - - void setCurrentYear(int CurrentYear); - QDate getFirstOfMonth(const QDate &date); - int getFirstWeekDay() const; - void setFirstWeekDay(int firstWeekDay); - YearScheduleInfo *getGetAllYearScheduleInfo() const; - -private: - CScheduleDataManage(); - ~CScheduleDataManage(); -private: - CScheduleDataCtrl *m_scheduleDataCtrl; - CHuangliDayDataManage *m_HuangliDayDataManage; - QVector m_vScheduleColor; - QVector m_vScheduleInfo; - ScheduleDtailInfo m_PressSelectInfo; - int m_theme = 0; - int m_CurrentYear; - int m_firstWeekDay =0; - YearScheduleInfo *m_GetAllYearScheduleInfo; - - static CScheduleDataManage *m_vscheduleDataManage; -}; - - -class CDataProcessThread : public QThread -{ - Q_OBJECT - -public: - /****** - 功能:构造函数 - 参数:_DataManage 原始数据管理类 - 返回值:无 - ******/ - CDataProcessThread(CSchedulesDBus *_DataManage); - /****** - 功能:析构函数 - 参数:无 - 返回值:无 - ******/ - ~CDataProcessThread(); - -public: - /****** - 功能:处理数据函数外部调用 - 返回值:无 - ******/ - void DataProcessStart(QDate begin, QDate end); - -signals: - /****** - 功能:发送信号函数 - 返回值:无 - ******/ - void signalsDataProcess(QVector out); - -protected: - /****** - 功能:多线程处理函数 - 参数:无 - 返回值:无 - ******/ - void run(); -private: - CSchedulesDBus *m_DataManage; - //锁 - QMutex m_mutex; - //更新类型 - int m_type; - QDate m_begindate; - QDate m_enddate; - //停止标志 - bool m_stopFlag; -}; -class CScheduleDataCtrl: public QObject -{ - Q_OBJECT -public: - CScheduleDataCtrl(); - ~CScheduleDataCtrl(); - qint64 addSchedule(const ScheduleDtailInfo &scheduledate); - bool getScheduleInfoById(int id, ScheduleDtailInfo &out); - bool getScheduleInfo(const QDate bdate, const QDate edate, QVector &out); - bool queryScheduleInfo(QString key, QDateTime starttime, QDateTime endtime, QVector &out); - bool queryScheduleInfo(QString key, QDateTime starttime, QDateTime endtime, QString &out); - bool updateScheduleInfo(const ScheduleDtailInfo &scheduledate); - bool deleteScheduleInfoById(int id); - bool GetType(qint64 jobId, ScheduleType &out); - QString InfoToJson(const ScheduleDtailInfo &scheduledate); - ScheduleDtailInfo JsonObjectToInfo(QJsonObject &obj); - CSchedulesDBus *getDbus() const; - -public slots: - void slotupdatescheduleD(QWidget *w, QDate begin, QDate end); - void slotDataProcess(QVector out); -signals: - void signalsupdatescheduleD(QWidget *w, QVector &data); -private: - void clearData(); -private: - CSchedulesDBus *m_dbus; - QMap *m_scheduleDateCache; - QDate m_begindate; - QDate m_enddate; - QWidget *m_currentWidget; - CDataProcessThread *m_thread; -}; -class CalendarDBus; -class CHuangliDayDataManage: public QObject -{ -public: - CHuangliDayDataManage(); - ~CHuangliDayDataManage(); - bool getSoloDay(QDate date, QString &str); - //获取节日状态 - QVector getDayFlag(QDate date); -private: - CalendarDBus *m_DBusInter; -}; -#endif // SCHEDULEVIEW_H diff -Nru dde-calendar-5.7.0.4/src/scheduleitem.cpp dde-calendar-5.7.0.23/src/scheduleitem.cpp --- dde-calendar-5.7.0.4/src/scheduleitem.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/scheduleitem.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,295 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#include "scheduleitem.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "schedulecoormanage.h" -#include "scheduledatamanage.h" -#include "SchecduleRemindWidget.h" -#include - -DWIDGET_USE_NAMESPACE - -CScheduleItem::CScheduleItem(QRectF rect, QGraphicsItem *parent, int type) - : DragInfoItem (rect,parent) - , m_type(type) -{ - m_transparentcolor = "#000000"; - m_transparentcolor.setAlphaF(0.05); -} - -CScheduleItem::~CScheduleItem() {} - -void CScheduleItem::setData(const ScheduleDtailInfo &info, QDate date, int totalNum) -{ - m_vScheduleInfo = info; - m_totalNum = totalNum; - m_date = date; - update(); -} - -bool CScheduleItem::hasSelectSchedule(const ScheduleDtailInfo &info) -{ - return info == m_vScheduleInfo; -} - -void CScheduleItem::splitText(QFont font, int w, int h, QString str, QStringList &liststr, QFontMetrics &fontm) -{ - if (str.isEmpty()) - return; - QFontMetrics fontmetris(font); - int heightT = fontm.height(); - - QString tstr; - QStringList tliststr; - for (int i = 0; i < str.count(); i++) { - tstr.append(str.at(i)); - int widthT = fontmetris.width(tstr) + 5; - if (widthT >= w) { - tstr.chop(1); - if (tstr.isEmpty()) - break; - tliststr.append(tstr); - tstr.clear(); - i--; - } - } - tliststr.append(tstr); - if (w < 30) { - QFontMetrics fm_s(fontm); - QFontMetrics f_st(font); - QString s = tliststr.at(0) + "..."; - if (h < 23) { - tliststr.append(""); - } else { - if (tliststr.isEmpty()) { - liststr.append(""); - } else { - QString c = str.at(0); - QString s = c + "..."; - QFontMetrics fm(font); - while (f_st.width(s) > w && f_st.width(s) >24) { - s.chop(1); - } -// if (wi > 72) { -// liststr.append("..."); -// } else { - liststr.append(s); -// } - } - } - } else { - for (int i = 0; i < tliststr.count(); i++) { - if ((i + 1) * heightT <= h - 1) { - liststr.append(tliststr.at(i)); - } else { - if (i == 0) { - break; - } else { - QString s; - QFontMetrics fm_str(fontm); - if (i == tliststr.count()) - s = fontm.elidedText(tliststr.at(i - 1), Qt::ElideRight, w); - else { - s = fontm.elidedText(tliststr.at(i - 1) + "...", Qt::ElideRight, w); - } - liststr.removeAt(i - 1); - liststr.append(s); - break; - } - } - } - } -} - -void CScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, const int isPixMap) -{ - Q_UNUSED(isPixMap); - CSchedulesColor gdcolor = CScheduleDataManage::getScheduleDataManage()->getScheduleColorByType( - m_vScheduleInfo.type.ID); - m_vHighflag = CScheduleDataManage::getScheduleDataManage()->getSearchResult(m_vScheduleInfo); - - if (CScheduleDataManage::getScheduleDataManage()->getPressSelectInfo() == m_vScheduleInfo ) { - if (m_vScheduleInfo.IsMoveInfo == - CScheduleDataManage::getScheduleDataManage()->getPressSelectInfo().IsMoveInfo) { - m_vHighflag = true; - } else { - painter->setOpacity(0.4); - gdcolor.textColor.setAlphaF(0.4); - gdcolor.timeColor.setAlphaF(0.4); - } - m_vSelectflag = m_press; - } - int themetype = CScheduleDataManage::getScheduleDataManage()->getTheme(); - - QColor bcolor = gdcolor.Purecolor; - - QFontMetrics fm = painter->fontMetrics(); - int h = fm.height(); - if (m_vHoverflag) { - bcolor = gdcolor.hoverPurecolor; - } else if (m_vHighflag) { - bcolor = gdcolor.hightlightPurecolor; - } - if (m_vSelectflag) { - bcolor = gdcolor.pressPurecolor; - } - painter->setBrush(bcolor); - painter->setPen(Qt::NoPen); - painter->drawRect(rect); - if (m_vHoverflag && !m_vSelectflag) { - painter->save(); - QRectF trect = QRectF(rect.x() + 0.5, rect.y() + 0.5, rect.width() - 1, rect.height() - 1); - QPen tpen; - QColor cc = "#FFFFFF"; - if (themetype == 2) { - cc = "#FFFFFF"; - } else { - cc = "#000000"; - } - cc.setAlphaF(0.08); - tpen.setColor(cc); - tpen.setWidthF(1); - tpen.setStyle(Qt::SolidLine); - painter->setBrush(Qt::NoBrush); - painter->setPen(tpen); - painter->drawRect(trect); - painter->restore(); - } - if (m_vSelectflag) { - if (themetype == 0 || themetype ==1) { - gdcolor.textColor.setAlphaF(0.4); - gdcolor.timeColor.setAlphaF(0.4); - } else if (themetype ==2) { - gdcolor.textColor.setAlphaF(0.6); - gdcolor.timeColor.setAlphaF(0.6); - } - } - painter->save(); - - QPen pen(gdcolor.shadowcolor); - pen.setWidth(2); - painter->setPen(pen); - painter->drawLine(rect.topLeft(), rect.bottomLeft()); - painter->restore(); - int tmagin = 10; - if (m_totalNum > 1) - tmagin = 5; - if (m_type == 0) { - int timeTextHight = 0; - QFont font/*("SourceHanSansSC")*/; - font.setWeight(QFont::Normal); - - font = DFontSizeManager::instance()->get(DFontSizeManager::T8, font); - - //绘制日程起始时间 - if (m_vScheduleInfo.beginDateTime.date() == m_date) { - painter->save(); - painter->setFont(font); - painter->setPen(gdcolor.timeColor); - QTime stime = m_vScheduleInfo.beginDateTime.time(); - QString str = stime.toString("AP h:mm"); - - QFontMetrics fontmetris(font); - qreal drawTextWidth = rect.width() - m_offset*2; - if (fm.width(str) > drawTextWidth -5) { - QString tstr; - for (int i = 0; i < str.count(); i++) { - tstr.append(str.at(i)); - int widthT = fm.width(tstr) - 5; - if (widthT >= drawTextWidth) { - if (i < 1) { - tstr.chop(1); - } else { - tstr.chop(2); - } - tstr = tstr + "..."; - break; - } - } - QString tstrs = fontmetris.elidedText(str,Qt::ElideRight,qRound(drawTextWidth - 5)); - painter->drawText( - QRectF(rect.topLeft().x() + tmagin, rect.topLeft().y() + 3, drawTextWidth- 5, h), - Qt::AlignLeft, tstrs); - - } else { - painter->drawText( - QRectF(rect.topLeft().x() + tmagin, rect.topLeft().y() + 3, drawTextWidth - 5, h), - Qt::AlignLeft, str); - } - - painter->restore(); - - } else { - timeTextHight = -20; - } - painter->save(); - - //绘制日程标题 - font = DFontSizeManager::instance()->get(DFontSizeManager::T6, font); - font.setLetterSpacing(QFont::PercentageSpacing, 105); - painter->setFont(font); - painter->setPen(gdcolor.textColor); - QStringList liststr; - - QRect textRect = rect.toRect(); - textRect.setWidth(textRect.width() -m_offset*2); - splitText(font, - textRect.width() - tmagin - 8, - textRect.height() - 20, - m_vScheduleInfo.titleName, - liststr, fm); - for (int i = 0; i < liststr.count(); i++) { - if ((20 + timeTextHight + (i + 1) * (h - 3)) > rect.height()) - return; - painter->drawText( - QRect(textRect.topLeft().x() + tmagin, - textRect.topLeft().y() + 20 + timeTextHight + i * (h - 3), - textRect.width() - 2, - h ), - Qt::AlignLeft, liststr.at(i)); - } - painter->restore(); - } else { - painter->save(); - QFont font/*("SourceHanSansSC")*/; - font.setWeight(QFont::Normal); - font = DFontSizeManager::instance()->get(DFontSizeManager::T8, font); -// font.setPixelSize(12); - painter->setFont(font); - painter->setPen(gdcolor.textColor); - painter->drawText(rect, Qt::AlignCenter | Qt::AlignVCenter, "..."); - painter->restore(); - } - if (m_vSelectflag) { - QColor selcolor = m_transparentcolor; - selcolor.setAlphaF(0.05); - painter->setBrush(selcolor); - painter->setPen(Qt::NoPen); - painter->drawRect(rect); - } - -} diff -Nru dde-calendar-5.7.0.4/src/scheduleitem.h dde-calendar-5.7.0.23/src/scheduleitem.h --- dde-calendar-5.7.0.4/src/scheduleitem.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/scheduleitem.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#ifndef SCHEDULEITEM_H -#define SCHEDULEITEM_H - -#include -#include -#include -#include - -#include "schedulestructs.h" -#include "draginfoitem.h" -class CScheduleCoorManage; -class CScheduleItem : public DragInfoItem -{ - Q_OBJECT -public: - CScheduleItem(QRectF rect,QGraphicsItem *parent = nullptr, int type = 0); - ~CScheduleItem() Q_DECL_OVERRIDE; - void setData(const ScheduleDtailInfo &info, QDate date, int totalNum); - bool hasSelectSchedule(const ScheduleDtailInfo &info); - int getType() - { - return m_type; - } - ScheduleDtailInfo getData() const - { - return m_vScheduleInfo; - } - QDate getdate()const - { - return m_date; - } -private: - void splitText(QFont font, int w, int h, QString str, QStringList &liststr, QFontMetrics &fontm); -private: - void paintBackground(QPainter *painter,const QRectF &rect,const int isPixMap = false) override; -private: - QDate m_date; - int m_type = 0; - int m_totalNum; - QColor m_transparentcolor; - -}; - -#endif // SCHEDULEITEM_H diff -Nru dde-calendar-5.7.0.4/src/schedulesdbus.cpp dde-calendar-5.7.0.23/src/schedulesdbus.cpp --- dde-calendar-5.7.0.4/src/schedulesdbus.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/schedulesdbus.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,576 +0,0 @@ -/* - * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ - -/* - * This file was generated by qdbusxml2cpp version 0.8 - * Command line was: qdbusxml2cpp -c DCalendarDBus -p dcalendardbus com.deepin.api.LunarCalendar.xml - * - * qdbusxml2cpp is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). - * - * This is an auto-generated file. - * This file may have been hand-edited. Look for HAND-EDIT comments - * before re-generating it. - */ - -#include "schedulesdbus.h" -#include -#include -#include -/* - * Implementation of interface class DCalendarDBus - */ - -CSchedulesDBus::CSchedulesDBus(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) - : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) -{ - QDBusConnection::sessionBus().connect(this->service(), this->path(), "org.freedesktop.DBus.Properties", "PropertiesChanged", "sa{sv}as", this, SLOT(__propertyChanged__(QDBusMessage))); - -} - -CSchedulesDBus::~CSchedulesDBus() -{ - QDBusConnection::sessionBus().disconnect(service(), path(), "org.freedesktop.DBus.Properties", "PropertiesChanged", "sa{sv}as", this, SLOT(propertyChanged(QDBusMessage))); -} - -QString CSchedulesDBus::createScheduleDtailInfojson(const ScheduleDtailInfo &info) -{ - QJsonObject json; - json.insert("ID", info.id); - json.insert("AllDay", info.allday); - json.insert("Remind", createScheduleRemind(info)); - json.insert("RRule", createScheduleRRule(info)); - json.insert("Title", info.titleName); - json.insert("Description", info.description); - json.insert("Type", info.type.ID); - json.insert("Start", toconvertData(info.beginDateTime)); - json.insert("End", toconvertData(info.endDateTime)); - //json.insert("Start", "2006-01-02T15:04:05+07:00"); - //json.insert("End", "2006-01-02T17:04:05+07:00"); - json.insert("RecurID", info.RecurID); - QJsonArray jsonarry; - for (int i = 0; i < info.ignore.count(); i++) { - jsonarry.append(toconvertData(info.ignore.at(i))); - } - json.insert("Ignore", jsonarry); - // 构建 JSON 文档 - QJsonDocument document; - document.setObject(json); - QByteArray byteArray = document.toJson(QJsonDocument::Compact); - QString strJson(byteArray); - return strJson; -} - -QString CSchedulesDBus::createScheduleTypejson(const ScheduleType &info) -{ - QJsonObject json; - json.insert("ID", info.ID); - json.insert("Name", info.typeName); - QString colorName = QString("#%1%2%3").arg(info.color.red(), 2, 16, QChar('0')).arg(info.color.green(), 2, 16, QChar('0')).arg(info.color.blue(), 2, 16, QChar('0')); - json.insert("Color", info.color.name()); - // 构建 JSON 文档 - QJsonDocument document; - document.setObject(json); - QByteArray byteArray = document.toJson(QJsonDocument::Compact); - QString strJson(byteArray); - return strJson; -} - -ScheduleType CSchedulesDBus::parsingScheduleTypejson(QJsonObject &object) -{ - ScheduleType type; - QJsonObject &rootObj = object; - - //因为是预先定义好的JSON数据格式,所以这里可以这样读取 - if (rootObj.contains("ID")) { - type.ID = rootObj.value("ID").toInt(); - } - if (rootObj.contains("Name")) { - type.typeName = rootObj.value("Name").toString(); - } - if (rootObj.contains("Color")) { - QString str = rootObj.value("Color").toString(); - type.color = QColor(rootObj.value("Color").toString()); - } - return type; -} - -ScheduleDtailInfo CSchedulesDBus::parsingScheduleDtailInfojsonID(QJsonObject &obj) -{ - - ScheduleDtailInfo info; - - QJsonObject &rootObj = obj; - //因为是预先定义好的JSON数据格式,所以这里可以这样读取 - if (rootObj.contains("ID")) { - info.id = rootObj.value("ID").toInt(); - } - if (rootObj.contains("AllDay")) { - info.allday = rootObj.value("AllDay").toBool(); - } - if (rootObj.contains("Remind")) { - parsingScheduleRemind(rootObj.value("Remind").toString(), info); - } - if (rootObj.contains("Title")) { - info.titleName = rootObj.value("Title").toString(); - } - if (rootObj.contains("Description")) { - info.description = rootObj.value("Description").toString(); - } - if (rootObj.contains("Type")) { - GetType(rootObj.value("Type").toInt(), info.type); - } - if (rootObj.contains("Start")) { - info.beginDateTime = fromconvertData(rootObj.value("Start").toString()); - } - if (rootObj.contains("End")) { - info.endDateTime = fromconvertData(rootObj.value("End").toString()); - } - if (rootObj.contains("RecurID")) { - info.RecurID = rootObj.value("RecurID").toInt(); - } - if (rootObj.contains("RRule")) { - parsingScheduleRRule(rootObj.value("RRule").toString(), info); - } - if (rootObj.contains("Ignore")) { - QJsonArray subArray = rootObj.value("Ignore").toArray(); - for (int i = 0; i < subArray.size(); i++) { - QString subObj = subArray.at(i).toString(); - info.ignore.append(fromconvertData(subObj)); - } - } - return info; -} - -QString CSchedulesDBus::createScheduleRRule(const ScheduleDtailInfo &info) -{ - if (info.rpeat == 0) return QString(); - // QString str = "'"; - QString str; - switch (info.rpeat) { - case 1: { - str += "FREQ=DAILY"; - } - break; - case 2: { - str += "FREQ=DAILY;BYDAY=MO,TU,WE,TH,FR"; - } - break; - case 3: { - str += "FREQ=WEEKLY"; - } - break; - case 4: { - str += "FREQ=MONTHLY"; - } - break; - case 5: { - str += "FREQ=YEARLY"; - } - break; - } - switch (info.enddata.type) { - case 1: { - str += QString(";COUNT=%1").arg(info.enddata.tcount + 1); - } - break; - case 2: { - QDateTime datetime = info.enddata.date; - //datetime.setDate(datetime); - str += ";UNTIL=" + datetime.toString("yyyyMMddThhmmss") + "Z"; - // str += ";UNTIL=" + toconvertData(datetime); - } - break; - } - //str += "'"; - return str; -} - -void CSchedulesDBus::parsingScheduleRRule(QString str, ScheduleDtailInfo &info) -{ - if (str.isEmpty()) { - info.rpeat = 0; - return; - } - QString rrulestrs = str; - QStringList rruleslist = rrulestrs.split(";", QString::SkipEmptyParts); - if (rruleslist.count() > 0) { - if (rruleslist.contains("FREQ=DAILY") && rruleslist.contains("BYDAY=MO,TU,WE,TH,FR")) info.rpeat = 2; - else if (rruleslist.contains("FREQ=DAILY") ) { - info.rpeat = 1; - } else if (rruleslist.contains("FREQ=WEEKLY") ) { - info.rpeat = 3; - } else if (rruleslist.contains("FREQ=MONTHLY") ) { - info.rpeat = 4; - } else if (rruleslist.contains("FREQ=YEARLY") ) { - info.rpeat = 5; - } - info.enddata.type = 0; - for (int i = 0; i < rruleslist.count(); i++) { - if (rruleslist.at(i).contains("COUNT=")) { - QStringList liststr = rruleslist.at(i).split("=", QString::SkipEmptyParts); - info.enddata.type = 1; - info.enddata.tcount = liststr.at(1).toInt() - 1; - } - - if (rruleslist.at(i).contains("UNTIL=")) { - QStringList liststr = rruleslist.at(i).split("=", QString::SkipEmptyParts); - info.enddata.type = 2; - info.enddata.date = QDateTime::fromString(liststr.at(1).left(liststr.at(1).count() - 1), "yyyyMMddThhmmss"); - //info.enddata.date = fromconvertData(liststr.at(1)); - info.enddata.date = info.enddata.date; - } - } - } -} - -QString CSchedulesDBus::createScheduleRemind(const ScheduleDtailInfo &info) -{ - if (!info.remind) return QString(); - QString str; - if (info.allday) { - str = QString::number(info.remindData.n) + ";" + info.remindData.time.toString("hh:mm"); - } else { - str = QString::number(info.remindData.n); - } - return str; -} - -void CSchedulesDBus::parsingScheduleRemind(QString str, ScheduleDtailInfo &info) -{ - if (str.isEmpty()) { - info.remind = false; - return; - } - info.remind = true; - if (info.allday) { - QStringList liststr = str.split(";", QString::SkipEmptyParts); - info.remindData.n = liststr.at(0).toInt(); - info.remindData.time = QTime::fromString(liststr.at(1), "hh:mm"); - } else { - info.remindData.n = str.toInt(); - } -} - -QString CSchedulesDBus::toconvertData(QDateTime date) -{ - QDateTime datetimeutc11 = date; - datetimeutc11.setTimeSpec(Qt::UTC); - QString strss = datetimeutc11.toString(Qt::ISODate); - datetimeutc11.setTimeSpec(Qt::OffsetFromUTC); - strss = datetimeutc11.toString(Qt::ISODateWithMs); - QDateTime datetimeutc = QDateTime::fromTime_t(0); - QString str = date.toString("yyyy-MM-ddThh:mm:ss") + "+" + datetimeutc.toString("hh:mm"); - //QString str = date.toString("yyyy-MM-ddThh:mm:ss") + "Z07:00"; - return str; -} - -QDateTime CSchedulesDBus::fromconvertData(QString str) -{ - QStringList liststr = str.split("+", QString::SkipEmptyParts); - return QDateTime::fromString(liststr.at(0), "yyyy-MM-ddThh:mm:ss"); -} - -QString CSchedulesDBus::toconvertIGData(QDateTime date) -{ - QDateTime datetimeutc11 = date; - datetimeutc11.setTimeSpec(Qt::UTC); - QString strss = datetimeutc11.toString(Qt::ISODate); - datetimeutc11.setTimeSpec(Qt::OffsetFromUTC); - strss = datetimeutc11.toString(Qt::ISODateWithMs); - QDateTime datetimeutc = QDateTime::fromTime_t(0); - QString str = date.toString("yyyy-MM-ddThh:mm:ss") + "Z" + datetimeutc.toString("hh:mm"); - //QString str = date.toString("yyyy-MM-ddThh:mm:ss") + "Z07:00"; - return str; -} - -QDateTime CSchedulesDBus::fromconvertiIGData(QString str) -{ - QStringList liststr = str.split("Z", QString::SkipEmptyParts); - return QDateTime::fromString(liststr.at(0), "yyyy-MM-ddThh:mm:ss"); -} - -qint64 CSchedulesDBus::CreateJob(const ScheduleDtailInfo &info) -{ - QList argumentList; - argumentList << QVariant::fromValue(createScheduleDtailInfojson(info)) ; - qDebug() << argumentList.at(0); - QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("CreateJob"), argumentList); - if (reply.type() != QDBusMessage::ReplyMessage ) { - qDebug() << reply; - return -1; - } - QDBusReply id = reply; - - return id.value(); -} - -bool CSchedulesDBus::GetJobs(int startYear, int startMonth, int startDay, int endYear, int endMonth, int endDay, QVector &out) -{ - QList argumentList; - argumentList << QVariant::fromValue(startYear) << QVariant::fromValue(startMonth) << QVariant::fromValue(startDay); - argumentList << QVariant::fromValue(endYear) << QVariant::fromValue(endMonth) << QVariant::fromValue(endDay); - QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetJobs"), argumentList); - if (reply.type() != QDBusMessage::ReplyMessage ) { - return false; - } - QDBusReply jobs = reply; - - if (!jobs.isValid()) return false; - QJsonParseError json_error; - QJsonDocument jsonDoc(QJsonDocument::fromJson(jobs.value().toLocal8Bit(), &json_error)); - - if (json_error.error != QJsonParseError::NoError) { - return false; - } - - QJsonArray rootarry = jsonDoc.array(); - for (int i = 0; i < rootarry.size(); i++) { - - QJsonObject subObj = rootarry.at(i).toObject(); - - ScheduleDateRangeInfo info; - //因为是预先定义好的JSON数据格式,所以这里可以这样读取 - if (subObj.contains("Date")) { - info.date = QDate::fromString(subObj.value("Date").toString(), "yyyy-MM-dd"); - } - if (subObj.contains("Jobs")) { - QJsonArray subarry = subObj.value("Jobs").toArray(); - for (int j = 0; j < subarry.size(); j++) { - QJsonObject ssubObj = subarry.at(j).toObject(); - info.vData.append(parsingScheduleDtailInfojsonID(ssubObj)); - } - } - out.append(info); - } - - return true; -} - -bool CSchedulesDBus::GetJob(qint64 jobId, ScheduleDtailInfo &out) -{ - QList argumentList; - argumentList << QVariant::fromValue(jobId); - QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetJob"), argumentList); - if (reply.type() != QDBusMessage::ReplyMessage ) { - return false; - } - QDBusReply jobs = reply; - - if (!jobs.isValid()) return false; - QJsonParseError json_error; - QJsonDocument jsonDoc(QJsonDocument::fromJson(jobs.value().toLocal8Bit(), &json_error)); - - if (json_error.error != QJsonParseError::NoError) { - return false; - } - - QJsonObject ssubObj = jsonDoc.object(); - out = parsingScheduleDtailInfojsonID(ssubObj); - - return true; -} - -bool CSchedulesDBus::UpdateJob(const ScheduleDtailInfo &info) -{ - QList argumentList; - argumentList << QVariant::fromValue(createScheduleDtailInfojson(info)); - QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("UpdateJob"), argumentList); - if (reply.type() != QDBusMessage::ReplyMessage ) { - return false; - } - //QDBusReply jobs = reply; - - //if (!jobs.isValid()) return false; - - return true; -} - -bool CSchedulesDBus::DeleteJob(qint64 jobId) -{ - QList argumentList; - argumentList << QVariant::fromValue(jobId); - QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("DeleteJob"), argumentList); - if (reply.type() != QDBusMessage::ReplyMessage ) { - return false; - } - - return true; -} - -bool CSchedulesDBus::QueryJobs(QString key, QDateTime starttime, QDateTime endtime, QVector &out) -{ - QJsonObject qjson; - qjson.insert("Key", key); - qjson.insert("Start", toconvertData(starttime)); - qjson.insert("End", toconvertData(endtime)); - // 构建 JSON 文档 - QJsonDocument qdocument; - qdocument.setObject(qjson); - QByteArray qbyteArray = qdocument.toJson(QJsonDocument::Compact); - QString strJson(qbyteArray); - - QList argumentList; - argumentList << QVariant::fromValue(strJson); - QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("QueryJobs"), argumentList); - if (reply.type() != QDBusMessage::ReplyMessage ) { - return false; - } - QDBusReply jobs = reply; - - if (!jobs.isValid()) return false; - QJsonParseError json_error; - QJsonDocument jsonDoc(QJsonDocument::fromJson(jobs.value().toLocal8Bit(), &json_error)); - - if (json_error.error != QJsonParseError::NoError) { - return false; - } - - QJsonArray rootarry = jsonDoc.array(); - for (int i = 0; i < rootarry.size(); i++) { - - QJsonObject subObj = rootarry.at(i).toObject(); - - ScheduleDateRangeInfo info; - //因为是预先定义好的JSON数据格式,所以这里可以这样读取 - if (subObj.contains("Date")) { - info.date = QDate::fromString(subObj.value("Date").toString(), "yyyy-MM-dd"); - } - if (subObj.contains("Jobs")) { - QJsonArray subarry = subObj.value("Jobs").toArray(); - for (int j = 0; j < subarry.size(); j++) { - QJsonObject ssubObj = subarry.at(j).toObject(); - info.vData.append(parsingScheduleDtailInfojsonID(ssubObj)); - } - } - out.append(info); - } - return true; -} - -bool CSchedulesDBus::QueryJobs(QString key, QDateTime starttime, QDateTime endtime, QString &out) -{ - QJsonObject qjson; - qjson.insert("Key", key); - qjson.insert("Start", toconvertData(starttime)); - qjson.insert("End", toconvertData(endtime)); - // 构建 JSON 文档 - QJsonDocument qdocument; - qdocument.setObject(qjson); - QByteArray qbyteArray = qdocument.toJson(QJsonDocument::Compact); - QString strJson(qbyteArray); - - QList argumentList; - argumentList << QVariant::fromValue(strJson); - QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("QueryJobs"), argumentList); - if (reply.type() != QDBusMessage::ReplyMessage ) { - return false; - } - QDBusReply jobs = reply; - - if (!jobs.isValid()) return false; - out = jobs.value().toLocal8Bit(); - return true; -} - -bool CSchedulesDBus::GetTypes(QVector &out) -{ - QList argumentList; - //argumentList << QVariant::fromValue(jobId); - QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetTypes"), argumentList); - if (reply.type() != QDBusMessage::ReplyMessage ) { - return false; - } - QDBusReply jobs = reply; - - if (!jobs.isValid()) return false; - QJsonParseError json_error; - QJsonDocument jsonDoc(QJsonDocument::fromJson(jobs.value().toLocal8Bit(), &json_error)); - - if (json_error.error != QJsonParseError::NoError) { - return false; - } - - QJsonArray rootarry = jsonDoc.array(); - for (int i = 0; i < rootarry.size(); i++) { - - QJsonObject subObj = rootarry.at(i).toObject(); - out.append(parsingScheduleTypejson(subObj)); - } - return true; -} - -bool CSchedulesDBus::GetType(qint64 jobId, ScheduleType &out) -{ - QList argumentList; - argumentList << QVariant::fromValue(jobId); - QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetType"), argumentList); - if (reply.type() != QDBusMessage::ReplyMessage ) { - return false; - } - QDBusReply jobs = reply; - - if (!jobs.isValid()) return false; - QJsonParseError json_error; - QJsonDocument jsonDoc(QJsonDocument::fromJson(jobs.value().toLocal8Bit(), &json_error)); - - if (json_error.error != QJsonParseError::NoError) { - return false; - } - - QJsonObject subObj = jsonDoc.object(); - out = parsingScheduleTypejson(subObj); - return true; -} - -qint64 CSchedulesDBus::CreateType(const ScheduleType &info) -{ - QList argumentList; - argumentList << QVariant::fromValue(createScheduleTypejson(info)) ; - QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("CreateType"), argumentList); - if (reply.type() != QDBusMessage::ReplyMessage ) { - return -1; - } - QDBusReply id = reply; - - return id.value(); -} - -bool CSchedulesDBus::DeleteType(qint64 jobId) -{ - QList argumentList; - argumentList << QVariant::fromValue(jobId); - QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("DeleteType"), argumentList); - if (reply.type() != QDBusMessage::ReplyMessage ) { - return false; - } - return true; -} - -bool CSchedulesDBus::UpdateType(const ScheduleType &info) -{ - QList argumentList; - argumentList << QVariant::fromValue(createScheduleTypejson(info)) ; - QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("UpdateType"), argumentList); - if (reply.type() != QDBusMessage::ReplyMessage ) { - return false; - } - return true; -} - - diff -Nru dde-calendar-5.7.0.4/src/schedulesdbus.h dde-calendar-5.7.0.23/src/schedulesdbus.h --- dde-calendar-5.7.0.4/src/schedulesdbus.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/schedulesdbus.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,118 +0,0 @@ -/* - * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ - -/* - * This file was generated by qdbusxml2cpp version 0.8 - * Command line was: qdbusxml2cpp -c DCalendarDBus -p dcalendardbus com.deepin.api.LunarCalendar.xml - * - * qdbusxml2cpp is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). - * - * This is an auto-generated file. - * Do not edit! All changes made to it will be lost. - */ - -#ifndef SCHEDULESDBUS_H -#define SCHEDULESDBUS_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "schedulestructs.h" - -/* - * Proxy class for interface com.deepin.api.LunarCalendar - */ -class CSchedulesDBus: public QDBusAbstractInterface -{ - Q_OBJECT - - Q_SLOT void __propertyChanged__(const QDBusMessage &msg) - { - QList arguments = msg.arguments(); - if (3 != arguments.count()) - return; - QString interfaceName = msg.arguments().at(0).toString(); - if (interfaceName != "com.deepin.api.LunarCalendar") - return; - QVariantMap changedProps = qdbus_cast(arguments.at(1).value()); - foreach (const QString &prop, changedProps.keys()) { - const QMetaObject *self = metaObject(); - for (int i = self->propertyOffset(); i < self->propertyCount(); ++i) { - QMetaProperty p = self->property(i); - if (p.name() == prop) { - Q_EMIT p.notifySignal().invoke(this); - } - } - } - } -public: - static inline const char *staticInterfaceName() - { - return "com.deepin.daemon.Calendar.Scheduler"; - } - -public: - CSchedulesDBus(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); - - ~CSchedulesDBus(); - QString toconvertIGData(QDateTime date); - QDateTime fromconvertiIGData(QString str); - QString createScheduleDtailInfojson(const ScheduleDtailInfo &info); - ScheduleDtailInfo parsingScheduleDtailInfojsonID(QJsonObject &obj); -private: - QString createScheduleTypejson(const ScheduleType &info); - ScheduleType parsingScheduleTypejson(QJsonObject &object); - - QString createScheduleRRule(const ScheduleDtailInfo &info); - void parsingScheduleRRule(QString str, ScheduleDtailInfo &info); - QString createScheduleRemind(const ScheduleDtailInfo &info); - void parsingScheduleRemind(QString str, ScheduleDtailInfo &info); - QString toconvertData(QDateTime date); - QDateTime fromconvertData(QString str); -public Q_SLOTS: // METHODS - - qint64 CreateJob(const ScheduleDtailInfo &info); - bool GetJobs(int startYear, int startMonth, int startDay, int endYear, int endMonth, int endDay, QVector &out); - bool GetJob(qint64 jobId, ScheduleDtailInfo &out); - bool UpdateJob(const ScheduleDtailInfo &info); - bool DeleteJob(qint64 jobId); - bool QueryJobs(QString key, QDateTime starttime, QDateTime endtime, QVector &out); - bool QueryJobs(QString key, QDateTime starttime, QDateTime endtime, QString &out); - - - bool GetTypes(QVector &out); - bool GetType(qint64 jobId, ScheduleType &out); - qint64 CreateType(const ScheduleType &info); - bool DeleteType(qint64 jobId); - bool UpdateType(const ScheduleType &info); - -Q_SIGNALS: // SIGNALS -// begin property changed signals -}; -#endif diff -Nru dde-calendar-5.7.0.4/src/schedulestructs.h dde-calendar-5.7.0.23/src/schedulestructs.h --- dde-calendar-5.7.0.4/src/schedulestructs.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/schedulestructs.h 2020-11-03 09:03:22.000000000 +0000 @@ -77,6 +77,7 @@ { type.ID = -1; } + bool operator ==(const _tagScheduleDtailInfo &info)const { if (info.type.ID ==4) { @@ -88,6 +89,7 @@ titleName == info.titleName; } } + bool operator <(const _tagScheduleDtailInfo &info)const { if (beginDateTime.date() != endDateTime.date() && @@ -127,6 +129,7 @@ bool state; int num; ScheduleDtailInfo tData; + bool operator <(const _tagMScheduleDateRangeInfo &info)const { if (bdate == info.bdate) { @@ -139,6 +142,7 @@ return bdate - * - * 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 - * 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 . - */ -#include "scheduleview.h" -#include -#include -#include -#include -#include -#include -#include "alldayeventview.h" -#include "graphicsview.h" -#include "schceduledlg.h" -#include "schedulecoormanage.h" -#include "scheduledatamanage.h" -DGUI_USE_NAMESPACE - -static int hourTextWidth = 50; -static int hourTextHeight = 20; -CScheduleView::CScheduleView(QWidget *parent, int viewType) - : DFrame(parent) - , m_viewType(viewType) -{ - setAutoFillBackground(true); - initUI(); - initConnection(); - setFrameRounded(true); - // setFrameShape(QFrame::NoFrame); - setLineWidth(0); -} - -CScheduleView::~CScheduleView() {} - -void CScheduleView::setviewMagin(int left, int top, int right, int bttom) -{ - m_leftMagin = left; - m_topMagin = top; - m_rightmagin = right; - m_layout->setContentsMargins(left,0,0,0); -// m_layout->setMargins(left,0,0,0); - m_graphicsView->setMargins(0, 0, right, bttom); - m_alldaylist->setMargins(0, 0, 0, 0); -} - -void CScheduleView::setRange(int w, int h, QDate begin, QDate end) -{ - Q_UNUSED(h); - if (!(w > 0)) { - return; - } - m_TotalDay = begin.daysTo(end) + 1; - m_graphicsView->setRange(w, scheduleViewHegith(), begin, end, m_rightmagin); - m_alldaylist->setRange(w, 22, m_beginDate, m_endDate, m_rightmagin); - if (m_viewType ==1) - m_currteDate = begin; - update(); -} - -void CScheduleView::setRange(QDate begin, QDate end) -{ - m_TotalDay = begin.daysTo(end) + 1; - m_graphicsView->setRange(begin,end); - m_alldaylist->setRange(begin,end); - m_beginDate = begin; - m_endDate = end; - updateSchedule(); -} - -void CScheduleView::setFirstWeekday(int weekday) -{ - m_firstWeekDay = weekday; - m_graphicsView->setFirstWeekday(weekday); -} - -void CScheduleView::setTheMe(int type) -{ - if (type == 0 || type == 1) { - DPalette palette(this->palette()); - palette.setColor(DPalette::Background, "#FFFFFF"); - this->setPalette(palette); - setBackgroundRole(DPalette::Background); - m_linecolor = "#000000"; - m_linecolor.setAlphaF(0.1); - m_weekColor = "#00429A"; - m_weekColor.setAlphaF(0.05); - m_ALLDayColor = "#303030"; - m_timeColor = "#7D7D7D"; - - } else if (type == 2) { - DPalette palette(this->palette()); - QColor tbcolor = "#282828"; - // tbcolor.setAlphaF(0.05); - palette.setColor(DPalette::Background, tbcolor); - this->setPalette(palette); - setBackgroundRole(DPalette::Background); - m_linecolor = "#000000"; - m_linecolor.setAlphaF(0.1); - m_weekColor = "#4F9BFF"; - m_weekColor.setAlphaF(0.1); - m_ALLDayColor = "#7D7D7D"; - m_timeColor = "#7D7D7D"; - } - m_graphicsView->setTheMe(type); - m_alldaylist->setTheMe(type); - update(); -} - -void CScheduleView::setLunarVisible(bool state) -{ - Q_UNUSED(state); -// m_alldaylist->setLunarVisible(state); -} - -void CScheduleView::setTime(QTime time) -{ - m_graphicsView->setTime(time); -} - -void CScheduleView::setSelectSchedule(const ScheduleDtailInfo &scheduleInfo) -{ - if (scheduleInfo.allday) { - m_alldaylist->setSelectSchedule(scheduleInfo); - } else { - m_graphicsView->setSelectSchedule(scheduleInfo); - } -} - -void CScheduleView::updateHigh() -{ - m_graphicsView->updateHigh(); - m_alldaylist->updateHigh(); -} - -bool CScheduleView::IsDragging() -{ - return (m_graphicsView->getDragStatus()!=4) || (m_alldaylist->getDragStatus()!=4); -} - -void CScheduleView::slotsupdatescheduleD(QVector &data) -{ - updateAllday(); - m_graphicsView->updateInfo(); - m_graphicsView->update(); - m_graphicsView->scene()->update(); - if (m_viewType == 1) { - if (QDate::currentDate() == m_beginDate) { - m_graphicsView->setTime(QTime::currentTime()); - } else { - if (data.isEmpty()) { - m_graphicsView->setTime(QTime(13, 0)); - } else { - QVector scheduleInfolist; - - for (int i = 0; i < data.at(0).vData.count(); i++) { - if (data.at(0).vData.at(i).allday) - continue; - scheduleInfolist.append(data.at(0).vData.at(i)); - } - if (scheduleInfolist.isEmpty()) { - m_graphicsView->setTime(QTime(13, 0)); - } else { -// qSort(scheduleInfolist.begin(),scheduleInfolist.end(), -// [](const ScheduleDtailInfo &s1, const ScheduleDtailInfo &s2) ->bool { -// return s1.beginDateTime < s2.beginDateTime; -// }); - std::sort(scheduleInfolist.begin(),scheduleInfolist.end(), - [](const ScheduleDtailInfo &s1, const ScheduleDtailInfo &s2) ->bool { - return s1.beginDateTime < s2.beginDateTime; - }); - QTime time = scheduleInfolist.at(0).beginDateTime.time(); - if (scheduleInfolist.at(0).beginDateTime.date() != m_beginDate) { - time = QTime(0, 0); - } - if (time.hour() + 4 >= 24) { - time = QTime(20, 0); - } else { - time = time.addSecs(14400); - } - m_graphicsView->setTime(time); - } - } - } - } - setEnabled(true); -} - - -void CScheduleView::setDate(QDate date) -{ - m_currteDate = date; - updateAllday(); -} - -void CScheduleView::slotupdateSchedule() -{ - updateSchedule(); -// if (id !=1) { - emit signalsUpdateShcedule(0); -// } -} - -void CScheduleView::slotPosHours(QVector vPos, QVector vHours, int cuttrnttimetype) -{ - m_vHours = vHours; - m_vPos = vPos; - m_cuttrnttimetype = cuttrnttimetype; - update(); -} - -void CScheduleView::paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event); - QPainter painter(this); - font.setWeight(QFont::Normal); - font.setPixelSize(11); - if (m_vPos.isEmpty()) - return; - QLocale locale; - if (locale.language() == QLocale::Chinese) { - QRect tinrect((m_leftMagin - hourTextWidth) / 2 - 5, - m_topMagin - 8 + m_vPos[m_vPos.count() - 1], hourTextWidth, hourTextHeight); - if (m_cuttrnttimetype == 0) { - painter.save(); - painter.setFont(font); - painter.setPen(m_timeColor); - for (int i = 0; i < m_vPos.size(); i++) { - if (m_vHours[i] == 0) - continue; - if (m_vHours[i] == 24) - continue; - if (m_topMagin - 8 + m_vPos[i] < m_topMagin) - continue; - painter.drawText( - QRect((m_leftMagin - hourTextWidth) / 2 - 5, m_topMagin - 8 + m_vPos[i], - hourTextWidth, hourTextHeight), - /*Qt::AlignRight | */Qt::AlignCenter, QTime(m_vHours[i], 0).toString("AP h 时")); - } - painter.restore(); - } else { - painter.save(); - painter.setFont(font); - painter.setPen(m_timeColor); - for (int i = 0; i < m_vPos.size() - 1; i++) { - if (m_vHours[i] == 0) - continue; - if (m_vHours[i] == 24) - continue; - if (m_topMagin - 8 + m_vPos[i] < m_topMagin) - continue; - QRect rr((m_leftMagin - hourTextWidth) / 2 - 5, m_topMagin - 8 + m_vPos[i], - hourTextWidth, hourTextHeight); - if (rr.intersects(tinrect) && m_viewType == 1 && - m_beginDate == QDate::currentDate()) { - continue; - } - painter.drawText( - QRect((m_leftMagin - hourTextWidth) / 2 - 5, m_topMagin - 8 + m_vPos[i], - hourTextWidth, hourTextHeight), - /*Qt::AlignRight | */Qt::AlignCenter, QTime(m_vHours[i], 0).toString("AP h 时")); - } - painter.restore(); - if (m_viewType == 1 && m_beginDate == QDate::currentDate()) { - painter.save(); - painter.setFont(font); - painter.setPen(m_currenttimecolor); - // QString str = QTime::currentTime().toString("AP HH:mm"); - QString str = QTime::currentTime().toString("AP hh:mm"); - painter.drawText(QRect((m_leftMagin - hourTextWidth) / 2 - 5, - m_topMagin - 8 + m_vPos[m_vPos.count() - 1], hourTextWidth, - hourTextHeight), - /*Qt::AlignRight | */Qt::AlignCenter, str); - painter.restore(); - } - } - } else { - if (m_cuttrnttimetype == 0) { - painter.save(); - painter.setFont(font); - painter.setPen(m_timeColor); - for (int i = 0; i < m_vPos.size(); i++) { - if (m_vHours[i] == 0) - continue; - if (m_vHours[i] == 24) - continue; - if (m_topMagin - 8 + m_vPos[i] < m_topMagin) - continue; - painter.drawText( - QRect((m_leftMagin - hourTextWidth) / 2 - 5, m_topMagin - 8 + m_vPos[i], - hourTextWidth + 2, hourTextHeight), - /*Qt::AlignRight | */Qt::AlignCenter, QTime(m_vHours[i], 0).toString(/*"AP */"HH:mm")); - } - painter.restore(); - } else { - painter.save(); - painter.setFont(font); - painter.setPen(m_timeColor); - QRect tinrect((m_leftMagin - hourTextWidth) / 2 - 5, - m_topMagin - 8 + m_vPos[m_vPos.count() - 1], hourTextWidth + 2, - hourTextHeight); - - for (int i = 0; i < m_vPos.size() - 1; i++) { - if (m_vHours[i] == 0) - continue; - if (m_vHours[i] == 24) - continue; - if (m_topMagin - 8 + m_vPos[i] < m_topMagin) - continue; - QRect rr((m_leftMagin - hourTextWidth) / 2 - 5, m_topMagin - 8 + m_vPos[i], - hourTextWidth + 2, hourTextHeight); - if (rr.intersects(tinrect) && m_viewType == 1 && - m_beginDate == QDate::currentDate()) - continue; - - painter.drawText( - QRect((m_leftMagin - hourTextWidth) / 2 - 5, m_topMagin - 8 + m_vPos[i], - hourTextWidth + 2, hourTextHeight), - /*Qt::AlignRight | */Qt::AlignCenter, QTime(m_vHours[i], 0).toString(/*"AP */"HH:mm")); - } - painter.restore(); - if (m_viewType == 1 && m_beginDate == QDate::currentDate()) { - painter.save(); - painter.setFont(font); - painter.setPen(m_currenttimecolor); - // QString str = QTime::currentTime().toString("AP HH:mm"); - QString str = QTime::currentTime().toString(/*"AP */"hh:mm"); - if (m_topMagin - 8 + m_vPos[m_vPos.count() - 1] >= m_topMagin) - painter.drawText(QRect((m_leftMagin - hourTextWidth) / 2 - 5, - m_topMagin - 8 + m_vPos[m_vPos.count() - 1], - hourTextWidth + 2, hourTextHeight), - /*Qt::AlignRight | */Qt::AlignCenter, str); - painter.restore(); - } - } - } - - painter.save(); - QFont alldayfont; -// alldayfont.setFamily("SourceHanSansSC"); - alldayfont.setWeight(QFont::Medium); - alldayfont.setPixelSize(14); - painter.setFont(alldayfont); - painter.setPen(m_ALLDayColor); - painter.drawText(QRect(0, 0, m_leftMagin - 2, m_topMagin - 2), Qt::AlignCenter, tr("ALL DAY")); - painter.restore(); - - //绘制全天与非全天之间的直线 - painter.setPen(m_linecolor); - painter.drawLine(0,m_topMagin,this->width(),m_topMagin); - - int t_width = width()-2; - qreal intenval = 1.0 * (t_width - m_leftMagin) / m_TotalDay; - if (m_TotalDay > 1) { - painter.save(); - painter.setPen(Qt::SolidLine); - painter.setPen(m_linecolor); - - for (qreal i = intenval; i < width() - m_leftMagin; i = i + intenval) { - painter.drawLine(QPointF(i + m_leftMagin + 1, 1), - QPointF(i + m_leftMagin + 1, this->height() + 1)); - } - - painter.restore(); - painter.save(); - for (int i = 0; i != 7; ++i) { - int d = checkDay(i - m_firstWeekDay); - painter.setBrush(m_weekColor); - painter.setPen(Qt::NoPen); - if (d == 6) { - painter.drawRect(QRectF(m_leftMagin + i * intenval + 1, 0, - width() - m_leftMagin - i * intenval, this->height())); - } - if (d == 7) { - painter.drawRect( - QRectF(m_leftMagin + i * intenval + 2, 0, intenval, this->height())); - } - } - painter.restore(); - } - -// painter.setBrush(Qt::red); -// const qreal radio = 8; -// QPainterPath path; -//// const int path_x = this->x(); -//// const int path_y = this->y(); -//// const int path_ -// path.moveTo(this->x(),this->y()); -// path.lineTo(this->x(),this->height()-radio); -// path.arcTo(QRectF(this->width(), -// this->height()-radio*2, -// radio*2,radio*2),180,90); - -// path.lineTo(this->width(),this->height()); - -// path.lineTo(this->width(),this->y()); -// path.lineTo(this->x(),this->y()); -// painter.drawPath(path); - painter.end(); -} - -void CScheduleView::resizeEvent(QResizeEvent *event) -{ -// int tt = 0.0968 * height() + 0.5; - if (m_viewType == 0) { - m_sMaxNum = ((width() - m_leftMagin) / 7) / 27; -// m_graphicsView->setRange(width() - m_leftMagin, scheduleViewHegith(), m_beginDate, -// m_endDate, 0); -// // m_alldaylist->setFixedSize(width() - m_leftMagin, m_topMagin - 5); -// m_alldaylist->setRange(width() - m_leftMagin, 22, m_beginDate, m_endDate, 0); - } else { -// m_graphicsView->setRange(width() - m_leftMagin, -// scheduleViewHegith(), m_beginDate, m_endDate, m_rightmagin); -// // m_alldaylist->setFixedSize(width() - m_leftMagin, m_topMagin - 10); -// m_alldaylist->setRange(width() - m_leftMagin, 22, m_beginDate, m_endDate, m_rightmagin); - } - m_graphicsView->setMaxNum(m_sMaxNum); - m_graphicsView->setRange(width() - m_leftMagin, - scheduleViewHegith(), m_beginDate, m_endDate, m_rightmagin); - m_alldaylist->setRange(width() - m_leftMagin, 22, m_beginDate, m_endDate, m_rightmagin); - update(); - QFrame::resizeEvent(event); - updateAllday(); - m_graphicsView->updateInfo(); - m_graphicsView->keepCenterOnScene(); -} - -void CScheduleView::initUI() -{ -// DHorizontalLine *m_hline = new DHorizontalLine; - m_layout = new QVBoxLayout; - m_layout->setSpacing(0); - m_layout->setMargin(0); - m_alldaylist = new CAllDayEventWeekView(this, 1); -// m_alldaylist->move(72, 5); - m_layout->addWidget(m_alldaylist); - m_layout->addSpacing(1); -// m_layout->addWidget(m_hline); - m_graphicsView = new CGraphicsView(this, m_viewType); - const int miniHeight = m_viewType ==0 ? 300 : 380; - m_graphicsView->setMinimumHeight(miniHeight); -// m_layout->setContentsMargins(0, m_space, 0, 0); - connect(m_graphicsView, SIGNAL(signalsPosHours(QVector, QVector, int)), this, - SLOT(slotPosHours(QVector, QVector, int))); - m_layout->addWidget(m_graphicsView); - setLayout(m_layout); - m_graphicsView->scrollBarValueChangedSlot(); - - m_ScheduleRemindWidget = new SchecduleRemindWidget(this); -} - -void CScheduleView::initConnection() -{ - connect(m_graphicsView, &CGraphicsView::signalsUpdateShcedule, this, - &CScheduleView::slotupdateSchedule); - // connect(m_graphicsView, &CGraphicsView::signalsUpdateShcedule, this, - // &CScheduleView::signalsUpdateShcedule); - connect(m_alldaylist, &CAllDayEventWeekView::signalsUpdateShcedule, this, - &CScheduleView::slotupdateSchedule); - connect(m_graphicsView, &CGraphicsView::signalsCurrentScheduleDate, this, - &CScheduleView::slotCurrentScheduleDate); - - connect(m_alldaylist, &CAllDayEventWeekView::signalViewtransparentFrame, this, - &CScheduleView::signalViewtransparentFrame); - connect(m_graphicsView, &CGraphicsView::signalViewtransparentFrame, this, - &CScheduleView::signalViewtransparentFrame); - - connect(m_graphicsView - , &CGraphicsView::signalScheduleShow - , this, &CScheduleView::slotScheduleShow); - - connect(m_alldaylist, &CAllDayEventWeekView::signalScheduleShow - , this, &CScheduleView::slotScheduleShow); - - connect(m_alldaylist,&CAllDayEventWeekView::signalUpdatePaint, - this,&CScheduleView::slotUpdatePaint); - connect(m_alldaylist,&CAllDayEventWeekView::signalSceneUpdate, - this,&CScheduleView::slotUpdateScene); - connect(m_graphicsView,&CGraphicsView::signalSceneUpdate, - this,&CScheduleView::slotUpdateScene); - - QShortcut *dshortcut = new QShortcut(this); - dshortcut->setKey(QKeySequence(QLatin1String("Delete"))); - connect(dshortcut, SIGNAL(activated()), this, SLOT(slotDeleteitem())); - - - -} -void CScheduleView::slotCtrlSchceduleUpdate(QDate date, int type) -{ - Q_UNUSED(date); - Q_UNUSED(type); - updateSchedule(); -} - - -void CScheduleView::slotDeleteitem() -{ - m_graphicsView->slotDeleteItem(); - m_alldaylist->slotDeleteItem(); -} - -void CScheduleView::slotCurrentScheduleDate(QDate date) -{ - if (m_viewType == 1) - return; - emit signalsCurrentScheduleDate(date); -} - -void CScheduleView::slotScheduleShow(const bool isShow, const ScheduleDtailInfo &out) -{ - if (isShow) { - QPoint pos22 = QCursor::pos(); - CSchedulesColor gdcolor = CScheduleDataManage::getScheduleDataManage()->getScheduleColorByType( - out.type.ID); - QDesktopWidget *w = QApplication::desktop(); - m_ScheduleRemindWidget->setData(out, gdcolor); - if ((pos22.x() + m_ScheduleRemindWidget->width() + 15) > w->width()) { - m_ScheduleRemindWidget->setArrowDirection(DArrowRectangle::ArrowRight); - m_ScheduleRemindWidget->show(pos22.x() - 15, pos22.y()); - } else { - m_ScheduleRemindWidget->setArrowDirection(DArrowRectangle::ArrowLeft); - m_ScheduleRemindWidget->show(pos22.x() + 15, pos22.y()); - } - } else { - m_ScheduleRemindWidget->hide(); - } -} - -void CScheduleView::slotUpdatePaint(const int topM) -{ - m_topMagin = topM; - update(); -} - -void CScheduleView::slotUpdateScene() -{ - m_graphicsView->slotUpdateScene(); - m_alldaylist->slotUpdateScene(); -} - -void CScheduleView::updateSchedule() -{ - m_graphicsView->clearSchdule(); - CScheduleDataCtrl *scheduleDataCtrl = - CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl(); - QDateTime bdate = QDateTime(m_beginDate); - QDateTime edate = QDateTime(m_endDate); - edate.setTime(QTime(23, 59, 59)); - QVector data; - scheduleDataCtrl->queryScheduleInfo("", bdate, edate, data); - QVector allInfo; - QVector nonAllInfo; - for (int i = 0; i < data.size(); ++i) { - for (int j = 0; j< data.at(i).vData.size(); ++j) { - if (data.at(i).vData.at(j).allday) { - if (!allInfo.contains(data.at(i).vData.at(j))) { - allInfo.append(data.at(i).vData.at(j)); - } - } else { - if (!nonAllInfo.contains(data.at(i).vData.at(j))) { - nonAllInfo.append(data.at(i).vData.at(j)); - } - } - } - } - m_alldaylist->setInfo(allInfo); - m_graphicsView->setInfo(nonAllInfo); - slotsupdatescheduleD(data); -} - -void CScheduleView::updateAllday() -{ -// m_topMagin = m_alldaylist->upDateInfoShow(); - m_alldaylist->updateInfo(); - update(); - m_graphicsView->resize(m_graphicsView->width(),this->height()-m_alldaylist->height()); -} - -int CScheduleView::checkDay(int weekday) -{ - if (weekday <= 0) - return weekday += 7; - - if (weekday > 7) - return weekday -= 7; - - return weekday; -} - -int CScheduleView::scheduleViewHegith() -{ -// rHeight = m_height * ((ScheduleET - ScheduleBT) / 86400.0) - - qreal mheight = 0; - if (m_viewType == 0) { - mheight = 24 * (0.0968 * height() + 0.5); - } else { - mheight = 24 * (0.083 * height() + 0.5); - } - //现在最小高度为20; - mheight = mheight <500? 1035:mheight; - int m_minTime = qRound((20.0/mheight)*86400); - m_graphicsView->setMinTime(m_minTime); - return qRound(mheight); -} diff -Nru dde-calendar-5.7.0.4/src/scheduleview.h dde-calendar-5.7.0.23/src/scheduleview.h --- dde-calendar-5.7.0.4/src/scheduleview.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/scheduleview.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#ifndef SCHEDULEVIEW_H -#define SCHEDULEVIEW_H - - -#include -#include "schedulestructs.h" -#include "SchecduleRemindWidget.h" -#include - -DWIDGET_USE_NAMESPACE - -class CGraphicsView; -class CAllDayEventWeekView; -class QVBoxLayout; -class CScheduleView : public DFrame -{ - Q_OBJECT -public: - CScheduleView(QWidget *parent = nullptr, int viewType = 0); - ~CScheduleView() Q_DECL_OVERRIDE; - void setviewMagin(int left, int top, int right, int bttom); - void setRange(int w, int h, QDate begin, QDate end); - void setRange(QDate begin, QDate end); - void setFirstWeekday(int weekday); - void setTheMe(int type = 0); - void setLunarVisible(bool state); - void setTime(QTime time); - void setSelectSchedule(const ScheduleDtailInfo &scheduleInfo); - void updateHigh(); - bool IsDragging(); -public slots: - void slotsupdatescheduleD( QVector &data); -signals: - void signalsupdatescheduleD(QWidget *w, QDate begin, QDate end); -signals: - void signalsUpdateShcedule(int id = 0); - void signalsCurrentScheduleDate(QDate date); - void signalViewtransparentFrame(int type); -public slots: - void slotPosHours(QVector vPos, QVector vHours, int cuttrnttimetype = 0); - void setDate(QDate date); - void slotupdateSchedule(); - void slotCtrlSchceduleUpdate(QDate date, int type = 0); - void slotDeleteitem(); - void slotCurrentScheduleDate(QDate date); - void slotScheduleShow(const bool isShow, const ScheduleDtailInfo &out = ScheduleDtailInfo()); - void slotUpdatePaint(const int topM); - void slotUpdateScene(); -protected: - void paintEvent( QPaintEvent *event ) Q_DECL_OVERRIDE; - void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; -private: - void initUI(); - void initConnection(); - void updateSchedule(); - void updateAllday(); - int checkDay(int weekday); - int scheduleViewHegith(); -private: - CGraphicsView *m_graphicsView; - QVector m_vPos; - QVector m_vHours; - CAllDayEventWeekView *m_alldaylist; - QVector m_vListSchedule; - int m_leftMagin; - int m_topMagin; - int m_rightmagin = 0; - qint64 m_TotalDay; - QDate m_currteDate; - int m_firstWeekDay; - QDate m_beginDate; - QDate m_endDate; - int m_viewType = 0; - int m_sMaxNum = 4; - QColor m_linecolor = Qt::lightGray; - QColor m_weekColor = "#E6EEF2"; - QColor m_ALLDayColor = "#303030"; - QColor m_timeColor = "#7D7D7D"; - QColor m_currenttimecolor = "#F74444"; - int m_cuttrnttimetype = 0; -// int m_space = 30; - QVBoxLayout *m_layout; - SchecduleRemindWidget *m_ScheduleRemindWidget; - int m_minTime; //最小高度对应的最小时间 - QFont font; -}; - -#endif // SCHEDULEVIEW_H diff -Nru dde-calendar-5.7.0.4/src/shortcut.cpp dde-calendar-5.7.0.23/src/shortcut.cpp --- dde-calendar-5.7.0.4/src/shortcut.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/shortcut.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -19,40 +19,14 @@ #include "shortcut.h" -Shortcut::Shortcut(QObject *parent) : QObject(parent) +Shortcut::Shortcut(QObject *parent) + : QObject(parent) { ShortcutGroup group1; ShortcutGroup group2; ShortcutGroup group3; ShortcutGroup group4; - /*#if 0 - group1.groupName = tr("Start/Calendar"); - //group2.groupName = tr("Search"); - group3.groupName = tr("Schedule Edit"); - group4.groupName = tr("Schedule Content Editing"); - group1.groupItems << - //ShortcutItem(tr("Window Size Toggle"), "Ctrl+Alt+F") << - // ShortcutItem(tr("Close"), "Alt+F4") << - ShortcutItem(tr("Help"), "F1"); - - //group2.groupItems << ShortcutItem(tr("Search"), "Ctrl+F"); - - - group3.groupItems << - //ShortcutItem(tr("New event"), "Ctrl+N") << - ShortcutItem(tr("Delete event"), "Delete") ; - //ShortcutItem(tr("Cancel Dialog"), "Esc");; - - group4.groupItems << - ShortcutItem(tr("Copy"), "Ctrl+C") << - ShortcutItem(tr("Cut"), "Ctrl+X") << - ShortcutItem(tr("Paste"), "Ctrl+V") << - ShortcutItem(tr("Select all"), "Ctrl+A") << - ShortcutItem(tr("Delete"), "Delete"); - m_shortcutGroups << group1 << group3 << group4; - #endif - */ group1.groupName = ""; group1.groupItems << ShortcutItem(tr("Help"), "F1") << ShortcutItem(tr("Delete event"), "Delete"); @@ -70,7 +44,6 @@ QJsonArray jsonGroups; for (auto scg : m_shortcutGroups) { QJsonObject jsonGroup; - // jsonGroup.insert("groupName", scg.groupName); QJsonArray jsonGroupItems; for (auto sci : scg.groupItems) { QJsonObject jsonItem; diff -Nru dde-calendar-5.7.0.4/src/singleton.h dde-calendar-5.7.0.23/src/singleton.h --- dde-calendar-5.7.0.4/src/singleton.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/singleton.h 2020-11-03 09:03:22.000000000 +0000 @@ -24,8 +24,7 @@ using namespace std; -namespace DCalendar -{ +namespace DCalendar { template class DSingleton @@ -33,10 +32,9 @@ public: static inline T *instance() { - static T* _instance = new T; + static T *_instance = new T; return _instance; } - protected: DSingleton(void) {} ~DSingleton(void) {} @@ -47,4 +45,4 @@ } }; -} +} // namespace DCalendar diff -Nru dde-calendar-5.7.0.4/src/timeedit.cpp dde-calendar-5.7.0.23/src/timeedit.cpp --- dde-calendar-5.7.0.4/src/timeedit.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/timeedit.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,240 +0,0 @@ -/* - * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#include "timeedit.h" -#include -#include -//#include "timeverticalscroll.h" -CTimeEdit::CTimeEdit(QWidget *parent) - : DComboBox(parent) -{ - initUI(); - initConnection(); - setFocus(Qt::MouseFocusReason); -} - -CTimeEdit::~CTimeEdit() {} - -void CTimeEdit::setTime(QTime time) -{ - m_time = time; - m_timeEdit->setText(m_time.toString("hh:mm")); -} - -QTime CTimeEdit::getTime() -{ - m_timeEdit->lineEdit()->setInputMask("00:00;#"); - QString timetext = m_timeEdit->text(); - - if (timetext.count() == 1) { - timetext = "00:00"; - } - if (timetext.right(1) == ":") { - timetext = timetext + "00"; - } - if (timetext.left(1) == ":") { - timetext = "00" + timetext; - } - QStringList t_list = timetext.split(":"); - QString firststr = t_list.at(0); - QString secondstr = t_list.at(1); - if (firststr.count() == 1) { - firststr = "0" + firststr; - } - if (secondstr.count() == 1) { - secondstr = "0" + secondstr; - } - timetext = firststr + ":" + secondstr; - - m_time = QTime::fromString(timetext, "hh:mm"); - return m_time; -} - -void CTimeEdit::initUI() -{ - // m_pListWidget = new DListWidget(this); - - m_timeEdit = new DLineEdit(this); - m_timeEdit->lineEdit()->setInputMask("00:00;0"); - m_timeEdit->setClearButtonEnabled(false); - QRegExpValidator *validator = nullptr; - QRegExp rx("0[0-9]:[0-5][0-9]|1[0-9]:[0-5][0-9]|2[0-3]:[0-5][0-9]"); - validator = new QRegExpValidator(rx, this); - m_timeEdit->lineEdit()->setValidator(validator); - setLineEdit(m_timeEdit->lineEdit()); - - QStringList list; - for (int i = 0; i < 24; i++) { - list << QString("%1:%2").arg(i, 2, 10, QLatin1Char('0')).arg(0, 2, 10, QLatin1Char('0')); - list << QString("%1:%2").arg(i, 2, 10, QLatin1Char('0')).arg(30); - } - this->addItems(list); - -#if 0 - setModel(m_pListWidget->model()); - setView(m_pListWidget); - //disconnect(m_timeEdit, &QLineEdit::editingFinished, m_pListWidget, &QListWidget::update); - //[2] 年月日选择控件 - m_pListWidget->setContentsMargins(0, 0, 0, 0); - m_pListWidget->setLineWidth(0); - m_pListWidget->setFixedWidth(131); - m_pitem = new QListWidgetItem(m_pListWidget); - m_pitem->setData(Qt::UserRole, ""); - m_pListWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - m_pListWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - - m_verticalScroll = new CTimeVerticalScroll(); - - m_verticalScroll->setRange(0, 23); - m_timeEdit->lineEdit()->setCursorPosition(1); - m_verticalScroll->setFixedSize(m_pListWidget->width(), 300); - m_pitem->setSizeHint(QSize(m_pListWidget->width(), 300)); - m_pListWidget->addItem(m_pitem); - m_pitem->setFlags(Qt::ItemIsTristate ); - m_pListWidget->setItemWidget(m_pitem, m_verticalScroll); - m_pListWidget->setFocusPolicy(Qt::NoFocus); - m_pListWidget->viewport()->setContentsMargins(0, 0, 0, 0); -#endif -} - -void CTimeEdit::initConnection() -{ -#if 0 - connect(m_verticalScroll, &CTimeVerticalScroll::currentValueChanged, this, &CTimeEdit::slotcurrentValueChanged); - connect(m_verticalScroll, &CTimeVerticalScroll::currentValueChangedClose, this, &CTimeEdit::slotcurrentValueChangedClose); -#endif - // connect(m_timeEdit, &DLineEdit::editingFinished, this, &CTimeEdit::slotEidtChange); - // connect(m_timeEdit, &DLineEdit::returnPressed, this, &CTimeEdit::slotEidtChange); - m_timeEdit->disconnect(SIGNAL(returnPressed())); - m_timeEdit->disconnect(SIGNAL(editingFinished())); - m_timeEdit->disconnect(SIGNAL(selectionChanged())); - m_timeEdit->disconnect(SIGNAL(textChanged(const QString &))); - m_timeEdit->disconnect(SIGNAL(textEdited(const QString &))); - m_timeEdit->disconnect(SIGNAL(cursorPositionChanged(int, int))); - - disconnect(SIGNAL(activated(int))); - disconnect(SIGNAL(activated(const QString &))); - disconnect(SIGNAL(currentIndexChanged(int))); - disconnect(SIGNAL(currentIndexChanged(const QString &))); - disconnect(SIGNAL(currentTextChanged(const QString &))); - disconnect(SIGNAL(editTextChanged(const QString &))); - disconnect(SIGNAL(highlighted(int))); - disconnect(SIGNAL(highlighted(const QString &))); -} - -#if 0 -void CTimeEdit::showPopup() -{ - // QComboBox::showPopup(); - int cc = width() + 32; - //m_pListWidget->setFixedWidth(width() + 12); - m_pos = m_timeEdit->lineEdit()->cursorPosition(); - //m_pitem->setSizeHint(QSize(width() + 12, 300)); - //m_verticalScroll->setFixedWidth(width() + 12); - m_timeEdit->lineEdit()->setInputMask("00:00;#"); - QString timetext = m_timeEdit->text(); - m_timeEdit->lineEdit()->setInputMask("00:00;0"); - if (timetext.count() == 1) { - timetext = "00:00"; - } - if (timetext.right(1) == ":") { - timetext = timetext + "00"; - } - if (timetext.left(1) == ":") { - timetext = "00" + timetext; - } - QStringList t_list = timetext.split(":"); - QString firststr = t_list.at(0); - QString secondstr = t_list.at(1); - if (firststr.count() == 1) { - firststr = "0" + firststr; - } - if (secondstr.count() == 1) { - secondstr = "0" + secondstr; - } - timetext = firststr + ":" + secondstr; - m_time = QTime::fromString(timetext, "hh:mm"); - - if (m_pos < 3) { - m_type = 0; - m_verticalScroll->setRange(0, 23); - m_verticalScroll->setCurrValue(m_time.hour()); - } else { - m_type = 1; - m_verticalScroll->setRange(0, 59); - m_verticalScroll->setCurrValue(m_time.minute()); - } - m_pListWidget->show(); - QComboBox::showPopup(); -} -void CTimeEdit::hidePopup() -{ - QString timetext = m_time.toString("hh:mm"); - m_timeEdit->setText(timetext); - QComboBox::hidePopup(); - return; - // 移除旧item - QListWidgetItem *item = NULL; - int iCount = m_pListWidget->count(); - for (int i = iCount - 1; i >= 1; i--) { - item = m_pListWidget->takeItem(i); - delete item; - } -} - -void CTimeEdit::slotcurrentValueChanged(int value) -{ - if (m_type == 0) { - - QTime time = QTime(value, m_time.minute()); - if (!time.isValid()) return; - m_time = time; - m_timeEdit->setText(m_time.toString("hh:mm")); - } else { - QTime time = QTime(m_time.hour(), value); - if (!time.isValid()) return; - m_time = time; - m_timeEdit->setText(m_time.toString("hh:mm")); - } - m_timeEdit->lineEdit()->setCursorPosition(m_pos); -} - -void CTimeEdit::slotcurrentValueChangedClose(int value) -{ - slotcurrentValueChanged(value); - hidePopup(); -} - -void CTimeEdit::slotEidtChange() -{ - m_timeEdit->lineEdit()->setInputMask("00:00;#"); - //QTime time = QTime(m_time.hour(), value); - QTime time = QTime::fromString(m_timeEdit->text(), "hh:mm"); - m_timeEdit->lineEdit()->setInputMask("00:00;0"); - QListWidgetItem *item = NULL; - int iCount = m_pListWidget->count(); - for (int i = iCount - 1; i >= 1; i--) { - item = m_pListWidget->takeItem(i); - delete item; - } - if (!time.isValid()) return; - m_time = time; - m_timeEdit->setText(m_time.toString("hh:mm")); -} - -#endif diff -Nru dde-calendar-5.7.0.4/src/timeedit.h dde-calendar-5.7.0.23/src/timeedit.h --- dde-calendar-5.7.0.4/src/timeedit.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/timeedit.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#pragma once - -#include -#include -#include -#include -#include -DWIDGET_USE_NAMESPACE -class CTimeEdit : public DComboBox -{ - Q_OBJECT - -public: - CTimeEdit(QWidget *parent = nullptr); - ~CTimeEdit(); - void setTime(QTime time); - QTime getTime(); - -private: - void initUI(); - void initConnection(); -#if 0 - void showPopup() Q_DECL_OVERRIDE; - void hidePopup() Q_DECL_OVERRIDE; - -public slots: - void slotcurrentValueChanged(int value); - void slotcurrentValueChangedClose(int value); - void slotEidtChange(); -#endif - -private: - DLineEdit *m_timeEdit; -#if 0 - CTimeVerticalScroll *m_verticalScroll; - DListWidget *m_pListWidget; - QListWidgetItem *m_pitem; -#endif - int m_type = 0; // 0 h,1 m - int m_pos = 0; - QTime m_time; -}; diff -Nru dde-calendar-5.7.0.4/src/todybutton.cpp dde-calendar-5.7.0.23/src/todybutton.cpp --- dde-calendar-5.7.0.4/src/todybutton.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/todybutton.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,163 +0,0 @@ -/* -* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. -* -* Author: uniontech -* -* Maintainer: uniontech -* -* 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 -* 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 . -*/ -#include "todybutton.h" -#include -#include -DGUI_USE_NAMESPACE -CTodyButton::CTodyButton(QWidget *parent): DPushButton(parent) -{ -// m_font.setFamily("SourceHanSansSC"); - m_font.setWeight(QFont::Medium); - m_font.setPixelSize(14); -} - -void CTodyButton::setBColor(QColor normalC, QColor hoverC, QColor pressc, QColor normalC1, QColor hoverC1, QColor pressc1) -{ - m_bnormalColor = normalC; - m_bhoverColor = hoverC; - m_bPressColor = pressc; - m_dbnormalColor = normalC1; - m_dbhoverColor = hoverC1; - m_dbPressColor = pressc1; - m_shadowColor = m_bnormalColor; -} - -void CTodyButton::setTColor(QColor normalC, QColor hoverC, QColor pressc) -{ - m_tnormalColor = normalC; - m_thoverColor = hoverC; - m_tPressColor = pressc; -} - -void CTodyButton::setshadowColor(QColor sc) -{ - m_shadowColor = sc; -} -/* -void CTodyButton::paintEvent(QPaintEvent *e) -{ - int labelwidth = width(); - int labelheight = height(); - - QPainter painter(this); - QRect fillRect = QRect(0, 0, labelwidth, labelheight); - - QRect trect = fillRect; - trect.setHeight(fillRect.height()); - painter.save(); - painter.setRenderHints(QPainter::Antialiasing); - QPen pen; - pen.setColor(m_shadowColor); - pen.setWidth(1); - painter.setBrush(Qt::NoBrush); - painter.setPen(pen); - painter.drawRoundedRect(trect, 8, 8); - painter.restore(); - - - painter.save(); - QLinearGradient linearGradient(0, 0, labelwidth, 0); - - painter.setRenderHints(QPainter::HighQualityAntialiasing); - if (m_hovertate) { - linearGradient.setColorAt(0, m_bhoverColor); - linearGradient.setColorAt(1, m_dbhoverColor); - } else if (m_pressstate) { - linearGradient.setColorAt(0, m_bPressColor); - linearGradient.setColorAt(1, m_dbPressColor); - } else { - linearGradient.setColorAt(0, m_bnormalColor); - linearGradient.setColorAt(1, m_dbnormalColor); - } - painter.setBrush(linearGradient); - painter.setPen(Qt::NoPen); - painter.drawRoundedRect(fillRect, 8, 8); - painter.restore(); - - painter.save(); - painter.setRenderHints(QPainter::HighQualityAntialiasing); - painter.setFont(m_font); - if (m_hovertate) { - painter.setPen(m_thoverColor); - } else if (m_pressstate) { - painter.setPen(m_tPressColor); - } else { - painter.setPen(m_tnormalColor); - } - painter.setPen(Qt::NoPen); - painter.drawText(fillRect, Qt::AlignCenter, text()); - painter.restore(); -} -*/ -void CTodyButton::mousePressEvent(QMouseEvent *event) -{ - DPalette todaypa = palette(); - todaypa.setColor(DPalette::ButtonText, m_tPressColor); - todaypa.setColor(DPalette::Dark, m_dbPressColor); - todaypa.setColor(DPalette::Light, m_bPressColor); - todaypa.setColor(DPalette::Shadow, m_shadowColor); - setPalette(todaypa); - DPushButton::mousePressEvent(event); -} - -void CTodyButton::mouseReleaseEvent(QMouseEvent *event) -{ - DPalette todaypa = palette(); - todaypa.setColor(DPalette::ButtonText, m_tnormalColor); - todaypa.setColor(DPalette::Dark, m_dbnormalColor); - todaypa.setColor(DPalette::Light, m_bnormalColor); - todaypa.setColor(DPalette::Shadow, m_shadowColor); - setPalette(todaypa); - DPushButton::mouseReleaseEvent(event); -} - -void CTodyButton::focusOutEvent(QFocusEvent *event) -{ - DPalette todaypa = palette(); - todaypa.setColor(DPalette::ButtonText, m_tnormalColor); - todaypa.setColor(DPalette::Dark, m_dbnormalColor); - todaypa.setColor(DPalette::Light, m_bnormalColor); - todaypa.setColor(DPalette::Shadow, m_shadowColor); - setPalette(todaypa); - DPushButton::focusOutEvent(event); -} - -void CTodyButton::enterEvent(QEvent *event) -{ - DPalette todaypa = palette(); - todaypa.setColor(DPalette::ButtonText, m_thoverColor); - todaypa.setColor(DPalette::Dark, m_dbhoverColor); - todaypa.setColor(DPalette::Light, m_bhoverColor); - todaypa.setColor(DPalette::Shadow, m_shadowColor); - setPalette(todaypa); - DPushButton::enterEvent(event); -} - -void CTodyButton::leaveEvent(QEvent *event) -{ - DPalette todaypa = palette(); - todaypa.setColor(DPalette::ButtonText, m_tnormalColor); - todaypa.setColor(DPalette::Dark, m_dbnormalColor); - todaypa.setColor(DPalette::Light, m_bnormalColor); - todaypa.setColor(DPalette::Shadow, m_shadowColor); - setPalette(todaypa); - DPushButton::leaveEvent(event); -} diff -Nru dde-calendar-5.7.0.4/src/todybutton.h dde-calendar-5.7.0.23/src/todybutton.h --- dde-calendar-5.7.0.4/src/todybutton.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/todybutton.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -/* -* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. -* -* Author: uniontech -* -* Maintainer: uniontech -* -* 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 -* 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 . -*/ -#ifndef TODYBUTTON_H -#define TODYBUTTON_H - -#include -DWIDGET_USE_NAMESPACE -class CTodyButton : public DPushButton -{ - Q_OBJECT -public: - CTodyButton(QWidget *parent = nullptr); - void setBColor(QColor normalC, QColor hoverC, QColor pressc, QColor normalC1, QColor hoverC1, QColor pressc1); - void setTColor(QColor normalC, QColor hoverC, QColor pressc); - void setshadowColor(QColor sc); -protected: - // void paintEvent ( QPaintEvent *e); - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void focusOutEvent(QFocusEvent *event); - void enterEvent(QEvent *event); - void leaveEvent(QEvent *event); -private: - QColor m_bnormalColor = "#FFFFFF"; - QColor m_bhoverColor = "#FFFFFF"; - QColor m_bPressColor = "#FFFFFF"; - QColor m_dbnormalColor = "#FFFFFF"; - QColor m_dbhoverColor = "#FFFFFF"; - QColor m_dbPressColor = "#FFFFFF"; - QColor m_tnormalColor = "#000000"; - QColor m_thoverColor = "#000000"; - QColor m_tPressColor = "#000000"; - QColor m_shadowColor = "#FFFFFF"; - QFont m_font; - bool m_pressstate = false; - bool m_hovertate = false; -}; - -#endif // TODYBUTTON_H diff -Nru dde-calendar-5.7.0.4/src/view/alldayeventview.cpp dde-calendar-5.7.0.23/src/view/alldayeventview.cpp --- dde-calendar-5.7.0.4/src/view/alldayeventview.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/view/alldayeventview.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,625 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#include "alldayeventview.h" +#include "schedulecoormanage.h" +#include "schcedulectrldlg.h" +#include "schceduledlg.h" +#include "myschceduleview.h" +#include "scheduledatamanage.h" +#include "constants.h" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +DGUI_USE_NAMESPACE + +CAllDayEventWidgetItem::CAllDayEventWidgetItem(QRectF rect, QGraphicsItem *parent, int edittype) + : DragInfoItem(rect, parent) +{ + Q_UNUSED(edittype); +} + +bool CAllDayEventWidgetItem::hasSelectSchedule(const ScheduleDtailInfo &info) +{ + return info == m_vScheduleInfo; +} + +void CAllDayEventWidgetItem::paintBackground(QPainter *painter, const QRectF &rect, const int isPixMap) +{ + Q_UNUSED(isPixMap); + m_font = DFontSizeManager::instance()->get(m_sizeType, m_font); + painter->setRenderHints(QPainter::Antialiasing); + CSchedulesColor gdcolor = CScheduleDataManage::getScheduleDataManage()->getScheduleColorByType(m_vScheduleInfo.type.ID); + QRectF drawrect = rect; + QLinearGradient linearGradient(drawrect.topLeft().x(), 0, drawrect.topRight().x(), 0); + + QColor color1 = gdcolor.gradientFromC; + QColor color2 = gdcolor.gradientToC; + QColor textcolor = gdcolor.textColor; + + m_vHighflag = CScheduleDataManage::getScheduleDataManage()->getSearchResult(m_vScheduleInfo); + + if (CScheduleDataManage::getScheduleDataManage()->getPressSelectInfo() == m_vScheduleInfo ) { + if (m_vScheduleInfo.IsMoveInfo == + CScheduleDataManage::getScheduleDataManage()->getPressSelectInfo().IsMoveInfo) { + m_vHighflag = true; + } else { + painter->setOpacity(0.4); + textcolor.setAlphaF(0.4); + } + m_vSelectflag = m_press; + } + int themetype = CScheduleDataManage::getScheduleDataManage()->getTheme(); + + if (m_vHoverflag) { + color1 = gdcolor.hovergradientFromC; + color2 = gdcolor.hovergradientToC; + } else if (m_vHighflag) { + color1 = gdcolor.hightlightgradientFromC; + color2 = gdcolor.hightlightgradientToC; + } + if (m_vSelectflag) { + color1 = gdcolor.pressgradientFromC; + color2 = gdcolor.pressgradientToC; + textcolor.setAlphaF(0.4); + } + linearGradient.setColorAt(0, color1); + linearGradient.setColorAt(1, color2); + QRectF fillRect = QRectF(drawrect.x(), + drawrect.y(), + drawrect.width(), + drawrect.height() - 2); + //将直线开始点设为0,终点设为1,然后分段设置颜色 + painter->setBrush(linearGradient); + painter->setPen(Qt::NoPen); + painter->drawRoundedRect(fillRect, rect.height() / 3, rect.height() / 3); + painter->setFont(m_font); + painter->setPen(textcolor); + QFontMetrics fm = painter->fontMetrics(); + QString tStitlename = m_vScheduleInfo.titleName; + tStitlename.replace("\n", ""); + QString str = tStitlename; + QString tstr; + for (int i = 0; i < str.count(); i++) { + tstr.append(str.at(i)); + int widthT = fm.width(tstr) + 5; + if (widthT >= fillRect.width() - 13) { + tstr.chop(2); + break; + } + } + if (tstr != str) { + tstr = tstr + "..."; + } + painter->drawText(QRectF(fillRect.topLeft().x() + 13, fillRect.y(), fillRect.width(), fillRect.height()), + Qt::AlignLeft | Qt::AlignVCenter, tstr); + if (m_vHoverflag && !m_vSelectflag) { + QRectF trect = QRectF(fillRect.x() + 0.5, fillRect.y() + 0.5, fillRect.width() - 1, fillRect.height() - 1); + painter->save(); + + QPen pen; + QColor selcolor; + + if (themetype == 2) { + selcolor = "#FFFFFF"; + } else { + selcolor = "#000000"; + } + selcolor.setAlphaF(0.08); + pen.setColor(selcolor); + pen.setWidthF(1); + pen.setStyle(Qt::SolidLine); + painter->setBrush(Qt::NoBrush); + painter->setPen(pen); + painter->drawRoundedRect(trect, rect.height() / 3, rect.height() / 3); + painter->restore(); + } + if (m_vSelectflag) { + QColor selcolor = "#000000"; + selcolor.setAlphaF(0.05); + painter->setBrush(selcolor); + painter->setPen(Qt::NoPen); + painter->drawRoundedRect(fillRect, rect.height() / 3, rect.height() / 3); + } +} + +void CAllDayEventWeekView::setTheMe(int type) +{ + m_themetype=type; + if (type == 0 || type == 1) { + m_weekColor = "#00429A"; + m_weekColor.setAlphaF(0.05); + } else { + m_weekColor = "#4F9BFF"; + m_weekColor.setAlphaF(0.1); + } + updateDateShow(); +} + +void CAllDayEventWeekView::changeEvent(QEvent *event) +{ + if (event->type() == QEvent::FontChange) { + updateItemHeightByFontSize(); + updateInfo(); + } +} + +bool CAllDayEventWeekView::MeetCreationConditions(const QDateTime &date) +{ + return qAbs(date.daysTo(m_PressDate)<7); +} + +void CAllDayEventWeekView::slotCreate(const QDateTime &date) +{ + emit signalViewtransparentFrame(1); + CSchceduleDlg dlg(1, this); + dlg.setDate(date); + dlg.setAllDay(true); + if (dlg.exec() == DDialog::Accepted) { + emit signalsUpdateShcedule(); + } + emit signalViewtransparentFrame(0); +} + +bool CAllDayEventWeekView::IsEqualtime(const QDateTime &timeFirst, const QDateTime &timeSecond) +{ + return timeFirst.date() == timeSecond.date(); +} + +bool CAllDayEventWeekView::JudgeIsCreate(const QPointF &pos) +{ + return qAbs(pos.x()-m_PressPos.x())>20 || + qAbs(m_PressDate.date().daysTo(m_coorManage->getsDate(mapFrom(this,pos.toPoint()))))>0; +} + +void CAllDayEventWeekView::RightClickToCreate(QGraphicsItem *listItem, const QPoint &pos) +{ + Q_UNUSED(listItem); + m_rightMenu->clear(); + m_rightMenu->addAction(m_createAction); + + m_createDate.setDate(m_coorManage->getsDate(mapFrom(this, pos))); + m_createDate.setTime(QTime::currentTime()); + m_rightMenu->exec(QCursor::pos()); + +} + +void CAllDayEventWeekView::MoveInfoProcess(ScheduleDtailInfo &info, const QPointF &pos) +{ + Q_UNUSED(pos); + if (info.allday) { + qint64 offset = m_PressDate.daysTo(m_MoveDate); + info.beginDateTime = info.beginDateTime.addDays(offset); + info.endDateTime = info.endDateTime.addDays(offset); + } else { + qint64 offset = info.beginDateTime.daysTo(info.endDateTime); + info.allday = true; + info.remind = true; + info.remindData.time = QTime(9, 0); + info.remindData.n = 1; + m_DragScheduleInfo.beginDateTime = QDateTime(m_MoveDate.date(),QTime(0,0,0)); + m_DragScheduleInfo.endDateTime = QDateTime(m_MoveDate.addDays(offset).date(),QTime(23,59,59)); + } + info.IsMoveInfo = true; + upDateInfoShow(ChangeWhole,info); +} + +QDateTime CAllDayEventWeekView::getDragScheduleInfoBeginTime(const QDateTime &moveDateTime) +{ + return moveDateTime.daysTo(m_InfoEndTime)<0 ? + QDateTime(m_InfoEndTime.date(),QTime(0,0,0)): + QDateTime(moveDateTime.date(),QTime(0,0,0)); +} + +QDateTime CAllDayEventWeekView::getDragScheduleInfoEndTime(const QDateTime &moveDateTime) +{ + return m_InfoBeginTime.daysTo(m_MoveDate)<0? + QDateTime(m_InfoBeginTime.date(),QTime(23,59,0)): + QDateTime(moveDateTime.date(),QTime(23,59,0)); +} + +void CAllDayEventWeekView::setRange(int w, int h, QDate begindate, QDate enddate, int rightmagin) +{ + m_MoveDate.setDate(begindate.addMonths(-2)); + m_beginDate = begindate; + m_endDate = enddate; + w -=2; + m_coorManage->setRange(w, h, begindate, enddate, rightmagin); + m_Scene->setSceneRect(0, 0, w, h); + m_rightmagin = rightmagin; + updateDateShow(); +} + +void CAllDayEventWeekView::setRange(QDate begin, QDate end) +{ + m_MoveDate.setDate(begin.addMonths(-2)); + m_beginDate = begin; + m_endDate = end; + getCoorManage()->setDateRange(begin, end); +} + +void CAllDayEventWeekView::updateHigh() +{ + for (int i = 0; i < m_baseShowItem.count(); i++) { + m_baseShowItem.at(i)->update(); + } +} + +void CAllDayEventWeekView::setSelectSchedule(const ScheduleDtailInfo &info) +{ + for (int i = 0; i < m_baseShowItem.size(); ++i) { + CAllDayEventWidgetItem *item = m_baseShowItem.at(i); + if (item->hasSelectSchedule(info)) { + QRectF rect = item->rect(); + centerOn(0, rect.y()); + setTransformationAnchor(QGraphicsView::AnchorViewCenter); + item->setStartValue(0); + item->setEndValue(4); + item->startAnimation(); + } + } +} + +void CAllDayEventWeekView::setMargins(int left, int top, int right, int bottom) +{ + setViewportMargins(QMargins(left, top, right, bottom)); +} + +void CAllDayEventWeekView::updateInfo() +{ + switch (m_DragStatus) { + case IsCreate: + upDateInfoShow(IsCreate,m_DragScheduleInfo); + break; + default: + upDateInfoShow(); + break; + } +} + +void CAllDayEventWeekView::upDateInfoShow(const DragStatus &status, const ScheduleDtailInfo &info) +{ + QVector vListData; + vListData = m_scheduleInfo; + switch (status) { + case NONE: + Q_UNUSED(info); + break; + case ChangeBegin: + case ChangeEnd: { + int index = vListData.indexOf(info); + if (index >=0) + vListData[index] = info; + } + break; + case ChangeWhole: + vListData.append(info); + break; + case IsCreate: + vListData.append(info); + break; + } + + std::sort(vListData.begin(), vListData.end()); + + QVector vMDaySchedule; + for (int i = 0; i < vListData.count(); i++) { + QDate tbegindate = vListData.at(i).beginDateTime.date(); + QDate tenddate = vListData.at(i).endDateTime.date(); + if (tbegindate < m_beginDate) + tbegindate = m_beginDate; + if (tenddate > m_endDate) + tenddate = m_endDate; + MScheduleDateRangeInfo sinfo; + sinfo.bdate = tbegindate; + sinfo.edate = tenddate; + sinfo.tData = vListData.at(i); + sinfo.state = false; + vMDaySchedule.append(sinfo); + } + QVector > vCfillSchedule; + vCfillSchedule.resize(vListData.count()); + int tNum = static_cast(m_beginDate.daysTo(m_endDate) + 1); + for (int i = 0; i < vListData.count(); i++) { + vCfillSchedule[i].resize(tNum); + vCfillSchedule[i].fill(-1); + } + //首先填充跨天日程 + for (int i = 0; i < vMDaySchedule.count(); i++) { + if (vMDaySchedule[i].state) + continue; + int bindex = static_cast(m_beginDate.daysTo(vMDaySchedule[i].bdate)); + int eindex = static_cast(m_beginDate.daysTo(vMDaySchedule[i].edate)); + int c = -1; + for (int k = 0; k < vListData.count(); k++) { + int t = 0; + for (t = bindex; t <= eindex; t++) { + if (vCfillSchedule[k][t] != -1) { + break; + } + } + if (t == eindex + 1) { + c = k; + break; + } + } + if (c == -1) + continue; + + bool flag = false; + for (int sd = bindex; sd <= eindex; sd++) { + if (vCfillSchedule[c][sd] != -1) + continue; + vCfillSchedule[c][sd] = i; + flag = true; + } + if (flag) + vMDaySchedule[i].state = true; + } + QVector > vResultData; + for (int i = 0; i < vListData.count(); i++) { + QVector vId; + for (int j = 0; j < tNum; j++) { + if (vCfillSchedule[i][j] != -1) { + int k = 0; + for (; k < vId.count(); k++) { + if (vId[k] == vCfillSchedule[i][j]) + break; + } + if (k == vId.count()) + vId.append(vCfillSchedule[i][j]); + } + } + QVector tData; + for (int j = 0; j < vId.count(); j++) { + tData.append(vMDaySchedule[vId[j]].tData); + } + if (!tData.isEmpty()) + vResultData.append(tData); + } + + int m_topMagin; + if (vResultData.count() < 2) { + m_topMagin = 32; + } else if (vResultData.count() < 6) { + m_topMagin = 31 + (vResultData.count() - 1) * (itemHeight+1); + + } else { + m_topMagin = 123; + } + setFixedHeight(m_topMagin - 3); + setDayData(vResultData); + update(); + emit signalUpdatePaint(m_topMagin); +} + +CAllDayEventWeekView::CAllDayEventWeekView(QWidget *parent, int edittype) + : DragInfoGraphicsView (parent) +{ + m_editType = edittype; + updateItemHeightByFontSize(); + m_coorManage = new CScheduleCoorManage; +} + +CAllDayEventWeekView::~CAllDayEventWeekView() +{ + delete m_coorManage; + m_coorManage = nullptr; +} + +void CAllDayEventWeekView::setDayData(const QVector > &vlistData) +{ + m_vlistData = vlistData; + updateDateShow(); +} + +void CAllDayEventWeekView::setInfo(const QVector &info) +{ + m_scheduleInfo = info; +} + +void CAllDayEventWeekView::slotDoubleEvent() +{ + m_updateDflag = true; + emit signalsUpdateShcedule(); +} + +void CAllDayEventWeekView::mouseDoubleClickEvent(QMouseEvent *event) +{ + if (event->button() == Qt::RightButton) { + return; + } + emit signalScheduleShow(false); + DGraphicsView::mouseDoubleClickEvent(event); + CAllDayEventWidgetItem *item = dynamic_cast(itemAt(event->pos())); + if (item == nullptr) { + m_createDate.setDate(m_coorManage->getsDate(mapFrom(this, event->pos()))); + m_createDate.setTime(QTime::currentTime()); + slotCreate(m_createDate); + } else { + emit signalViewtransparentFrame(1); + m_updateDflag = false; + CMySchceduleView dlg(item->getData(), this); + connect(&dlg, &CMySchceduleView::signalsEditorDelete, this, &CAllDayEventWeekView::slotDoubleEvent); + dlg.exec(); + emit signalViewtransparentFrame(0); + disconnect(&dlg, &CMySchceduleView::signalsEditorDelete, this, &CAllDayEventWeekView::slotDoubleEvent); + if (item == nullptr) { + return; + } + } +} + +void CAllDayEventWeekView::wheelEvent(QWheelEvent *event) +{ + //若滚轮事件为左右方向则退出 + if(event->orientation() == Qt::Orientation::Horizontal){ + return; + } + emit signalScheduleShow(false); + DGraphicsView::wheelEvent(event); +} + +void CAllDayEventWeekView::paintEvent(QPaintEvent *event) +{ + QPainter painter(viewport()); + //绘制背景 + paintBackground(painter); + painter.end(); + QGraphicsView::paintEvent(event); +} + +void CAllDayEventWeekView::updateDateShow() +{ + m_Scene->setSceneRect(0, + 0, + m_Scene->width(), + (itemHeight + 1)*m_vlistData.size()); + + for (int i = 0; i < m_baseShowItem.count(); i++) { + delete m_baseShowItem[i]; + } + m_baseShowItem.clear(); + for (int i = 0; i < m_vlistData.size(); ++i) { + createItemWidget(i); + } +} + +void CAllDayEventWeekView::createItemWidget(int index, bool average) +{ + Q_UNUSED(average) + for (int i = 0; i < m_vlistData[index].size(); ++i) { + const ScheduleDtailInfo &info = m_vlistData[index].at(i); + QRectF drawrect = m_coorManage->getAllDayDrawRegion(info.beginDateTime.date(), info.endDateTime.date()); + drawrect.setY(2 + (itemHeight + 1) * index); + drawrect.setHeight(itemHeight); + + CAllDayEventWidgetItem *gwi = new CAllDayEventWidgetItem(drawrect, nullptr, m_editType); + gwi->setData(m_vlistData[index].at(i)); + m_Scene->addItem(gwi); + m_baseShowItem.append(gwi); + } +} + +void CAllDayEventWeekView::updateItemHeightByFontSize() +{ + QFont font; + DFontSizeManager::instance()->setFontGenericPixelSize( + static_cast(DFontSizeManager::instance()->fontPixelSize(qGuiApp->font()))); + font = DFontSizeManager::instance()->t8(font); + QFontMetrics fm(font); + int h = fm.height(); + if (itemHeight != h) { + itemHeight = h; + } +} + +void CAllDayEventWeekView::paintBackground(QPainter &painter) +{ + // 绘制Rect的宽度 + const int t_width = viewport()->width() - 2; + // 需要处理的天数 + const qint64 m_TotalDay = m_beginDate.daysTo(m_endDate) + 1; + // 左边距 + const int m_leftMagin = 0; + // 每天的宽度 + const qreal intenval = 1.0 * (t_width - m_leftMagin) / m_TotalDay; + // 每天X坐标点偏移 + const qreal XPointOffset = 1.5; + // 分割线颜色 + QColor m_linecolor = "#000000"; + m_linecolor.setAlphaF(0.1); + if (m_TotalDay > 1) { + painter.save(); + painter.setPen(Qt::SolidLine); + painter.setPen(m_linecolor); + //绘制分割线 + for (int i = 1; i < 7; ++i) { + painter.drawLine(QPointF(i * intenval + m_leftMagin + XPointOffset, 1), + QPointF(i * intenval + m_leftMagin + XPointOffset, this->height())); + } + painter.restore(); + painter.save(); + //绘制周六周日背景色 + painter.setBrush(m_weekColor); + painter.setPen(Qt::NoPen); + painter.setRenderHint(QPainter::Antialiasing); + for (int i = 0; i != 7; ++i) { + int d = m_beginDate.addDays(i).dayOfWeek(); + if (d == 7 || d == 6) { + painter.drawRect( + QRectF(m_leftMagin + i * intenval + XPointOffset, 0, intenval, this->height())); + } + } + painter.restore(); + } +} + +CAllDayEventWeekView::PosInItem CAllDayEventWeekView::getPosInItem(const QPoint &p, const QRectF &itemRect) +{ + QPointF scenePos = this->mapToScene(p); + QPointF itemPos = QPointF(scenePos.x()-itemRect.x(), + scenePos.y()-itemRect.y()); + double bottomy = itemRect.width()- itemPos.x(); + if (itemPos.x()<5) { + return LEFT; + } + if (bottomy <5) { + return RIGHT; + } + return MIDDLE; +} + +QDateTime CAllDayEventWeekView::getPosDate(const QPoint &p) +{ + return QDateTime(m_coorManage->getsDate(mapFrom(this, p)), + QTime(0,0,0)); +} + +void CAllDayEventWeekView::slotDeleteItem() +{ + if (CScheduleDataManage::getScheduleDataManage()->getPressSelectInfo().type.ID <0) { + return; + } + if (CScheduleDataManage::getScheduleDataManage()->getPressSelectInfo().type.ID != DDECalendar::FestivalTypeID) { + DeleteItem(CScheduleDataManage::getScheduleDataManage()->getPressSelectInfo()); + } + CScheduleDataManage::getScheduleDataManage()->setPressSelectInfo(ScheduleDtailInfo()); +} + +void CAllDayEventWeekView::slotUpdateScene() +{ + this->scene()->update(); +} diff -Nru dde-calendar-5.7.0.4/src/view/alldayeventview.h dde-calendar-5.7.0.23/src/view/alldayeventview.h --- dde-calendar-5.7.0.4/src/view/alldayeventview.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/view/alldayeventview.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#ifndef ALLDAYEVENTVIEW_H +#define ALLDAYEVENTVIEW_H + +#include "draginfoitem.h" +#include "draginfographicsview.h" +#include "schedulestructs.h" + +#include +#include +#include +#include +#include +#include + +#include +#include + +DWIDGET_USE_NAMESPACE +class QDrag; +class CAllDayEventWidgetItem; +class CScheduleCoorManage; +class SchecduleRemindWidget; + +class CAllDayEventWeekView : public DragInfoGraphicsView +{ + Q_OBJECT +public: + CAllDayEventWeekView(QWidget *parent = nullptr, int edittype = 0); + ~CAllDayEventWeekView() override; + void setDayData(const QVector > &vlistData); + void setInfo(const QVector &info); + QVector > &getListData() + { + return m_vlistData; + } + void setRange(int w, int h, QDate begindate, QDate enddate, int rightmagin); + void setRange(QDate begin, QDate end); + CScheduleCoorManage *getCoorManage() + { + return m_coorManage; + } + void updateHigh(); + void setSelectSchedule(const ScheduleDtailInfo &info); + void setMargins(int left, int top, int right, int bottom); + void updateInfo(); +signals: + void signalUpdatePaint(const int topM); + void signalSceneUpdate(); +public slots: + void slotDeleteItem(); + void slotUpdateScene(); +private slots: + void slotDoubleEvent(); +public: + void setTheMe(int type = 0) override; +private: + void changeEvent(QEvent *event) override; + bool MeetCreationConditions(const QDateTime &date) override; + void slotCreate(const QDateTime &date) override; + //判断时间是否相等 + bool IsEqualtime(const QDateTime &timeFirst,const QDateTime &timeSecond) override; + //根据鼠标移动的距离判断是否创建日程 + bool JudgeIsCreate(const QPointF &pos) override; + void RightClickToCreate(QGraphicsItem *listItem,const QPoint &pos) override; + void MoveInfoProcess(ScheduleDtailInfo &info,const QPointF &pos) override; + QDateTime getDragScheduleInfoBeginTime(const QDateTime &moveDateTime) override; + QDateTime getDragScheduleInfoEndTime(const QDateTime &moveDateTime) override; + PosInItem getPosInItem(const QPoint &p,const QRectF &itemRect)override; + QDateTime getPosDate(const QPoint &p)override; + void upDateInfoShow(const DragStatus &status = NONE,const ScheduleDtailInfo &info =ScheduleDtailInfo())override; +protected: + void mouseDoubleClickEvent(QMouseEvent *event) override; + void wheelEvent(QWheelEvent *event) override; + /** + * @brief paintEvent 绘制事件 + * @param event 绘制事件的事件参数 + */ + void paintEvent(QPaintEvent *event) override; +private: + void updateDateShow(); + void createItemWidget(int index, bool average = false); + void updateItemHeightByFontSize(); + /** + * @brief paintBackground 绘制背景--周试图周六周天的背景色和每天的分割线 + * @param painter painter对象 + */ + void paintBackground(QPainter &painter); +private: + int itemHeight = 22; + QVector > m_vlistData; + QVector m_scheduleInfo; + QVector m_baseShowItem; + int m_editType = 0; + CScheduleCoorManage *m_coorManage = nullptr; + QDate m_dianjiDay; + int m_rightmagin = 0; + bool m_updateDflag = false; + QDate m_beginDate; + QDate m_endDate; + /** + * @brief m_weekColor 周六周日背景色 + */ + QColor m_weekColor = "#E6EEF2"; +}; + +class CAllDayEventWidgetItem : public DragInfoItem +{ + Q_OBJECT +public: + explicit CAllDayEventWidgetItem(QRectF rect, QGraphicsItem *parent = nullptr, int edittype = 0); + bool hasSelectSchedule(const ScheduleDtailInfo &info); +protected: + void paintBackground(QPainter *painter,const QRectF &rect,const int isPixMap = false) override; +}; +#endif // CSHCEDULEDAYVIEW_H + diff -Nru dde-calendar-5.7.0.4/src/view/draginfographicsview.cpp dde-calendar-5.7.0.23/src/view/draginfographicsview.cpp --- dde-calendar-5.7.0.4/src/view/draginfographicsview.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/view/draginfographicsview.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,583 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "draginfographicsview.h" +#include "schceduledlg.h" +#include "schcedulectrldlg.h" +#include "myschceduleview.h" +#include "constants.h" + +#include + +#include +#include +#include +#include + +DragInfoGraphicsView::DragInfoGraphicsView(DWidget *parent) + : DGraphicsView(parent) + , m_Scene(new QGraphicsScene(this)) + , m_rightMenu(new DMenu(this)) + , m_MoveDate(QDateTime::currentDateTime()) +{ + setFrameShape(QFrame::NoFrame); + setScene(m_Scene); + setContentsMargins(0, 0, 0, 0); + + m_editAction = new QAction(tr("Edit"), this); + m_deleteAction = new QAction(tr("Delete"), this); + m_createAction = new QAction(tr("New event"), this); + connect(m_createAction, &QAction::triggered, this, + static_cast(&DragInfoGraphicsView::slotCreate)); + this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); + this->setViewportMargins(0, 0, 0, 0); + setMouseTracking(true); + viewport()->setMouseTracking(true); + setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); + setAlignment(Qt::AlignLeft | Qt::AlignTop); + setViewportUpdateMode(QGraphicsView::FullViewportUpdate); + m_Drag = new QDrag(this); +} + +DragInfoGraphicsView::~DragInfoGraphicsView() +{ + +} + +void DragInfoGraphicsView::mousePressEvent(QMouseEvent *event) +{ + if (event->button() != Qt::LeftButton) { + return; + } + + setPressSelectInfo(ScheduleDtailInfo()); + QGraphicsItem *listItem =itemAt(event->localPos().toPoint()); + DragInfoItem *infoitem = dynamic_cast(listItem); + + if (infoitem != nullptr) { + setPressSelectInfo(infoitem->getData()); + m_press = true; + DragInfoItem::setPressFlag(true); + } else { + emit signalScheduleShow(false); + } + + DragPressEvent(event->pos(),infoitem); + update(); +} + +void DragInfoGraphicsView::mouseReleaseEvent(QMouseEvent *event) +{ + if (event->button() ==Qt::RightButton) { + return; + } + mouseReleaseScheduleUpdate(); +} + + +void DragInfoGraphicsView::mouseMoveEvent(QMouseEvent *event) +{ + DGraphicsView::mouseMoveEvent(event); + + if (m_press) { + emit signalScheduleShow(false); + m_press = false; + DragInfoItem::setPressFlag(false); + } + + DragInfoItem *item = dynamic_cast(itemAt(event->pos())); + + if (item != nullptr) { + if (item->getData().type.ID != DDECalendar::FestivalTypeID) { + if (m_DragStatus == NONE) { + switch (getPosInItem(event->pos(),item->rect())) { + case LEFT: + case RIGHT: + setCursor(Qt::SplitHCursor); + break; + case TOP: + case BOTTOM: + setCursor(Qt::SplitVCursor); + break; + default: + setCursor(Qt::ArrowCursor); + break; + } + } + } + } else { + if (m_DragStatus == NONE) { + setCursor(Qt::ArrowCursor); + } + } + QDateTime gDate = getPosDate(event->pos()); + + switch (m_DragStatus) { + case IsCreate: + m_isCreate = JudgeIsCreate(event->pos()); + if (m_isCreate) { + if (!IsEqualtime(m_MoveDate,gDate)) { + m_MoveDate = gDate; + m_DragScheduleInfo = getScheduleInfo(m_PressDate,m_MoveDate); + upDateInfoShow(IsCreate,m_DragScheduleInfo); + setPressSelectInfo(m_DragScheduleInfo); + } + } + break; + case ChangeBegin: + if (!IsEqualtime(m_MoveDate,gDate)) { + m_MoveDate = gDate; + m_DragScheduleInfo.beginDateTime = + getDragScheduleInfoBeginTime(m_MoveDate); + m_DragScheduleInfo.endDateTime = m_InfoEndTime; + upDateInfoShow(ChangeBegin,m_DragScheduleInfo); + } + break; + case ChangeEnd: + if (!IsEqualtime(m_MoveDate,gDate)) { + m_MoveDate = gDate; + m_DragScheduleInfo.endDateTime = + getDragScheduleInfoEndTime(m_MoveDate); + m_DragScheduleInfo.beginDateTime =m_InfoBeginTime; + upDateInfoShow(ChangeEnd,m_DragScheduleInfo); + } + break; + case ChangeWhole: { + if (!m_PressRect.contains(event->pos())) { + Qt::DropAction dropaction = m_Drag->exec( Qt::MoveAction); + Q_UNUSED(dropaction); + m_Drag = nullptr; + m_DragStatus = NONE; + setCursor(Qt::ArrowCursor); + m_DragScheduleInfo.IsMoveInfo = false; + setPressSelectInfo(m_DragScheduleInfo); + emit signalsUpdateShcedule(); + } + } + break; + default: + break; + } +} + +void DragInfoGraphicsView::wheelEvent(QWheelEvent *event) +{ + DGraphicsView::wheelEvent(event); +} + +void DragInfoGraphicsView::contextMenuEvent(QContextMenuEvent *event) +{ + DGraphicsView::contextMenuEvent(event); + + if (m_DragStatus ==IsCreate) { + return; + } + emit signalScheduleShow(false); + m_press = false; + m_DragStatus =NONE; + QGraphicsItem *listItem = itemAt(event->pos()); + DragInfoItem *infoitem = dynamic_cast(listItem); + + if (infoitem !=nullptr) { + if (infoitem->getData().type.ID != DDECalendar::FestivalTypeID) { + m_rightMenu->clear(); + m_rightMenu->addAction(m_editAction); + m_rightMenu->addAction(m_deleteAction); + QAction *action_t = m_rightMenu->exec(QCursor::pos()); + + if (action_t == m_editAction) { + emit signalViewtransparentFrame(1); + CSchceduleDlg dlg(0, this); + dlg.setData(infoitem->getData()); + if (dlg.exec() == DDialog::Accepted) { + emit signalsUpdateShcedule(); + } + emit signalViewtransparentFrame(0); + } else if (action_t == m_deleteAction) { + DeleteItem(infoitem->getData()); + } + } else { + emit signalViewtransparentFrame(1); + CMySchceduleView dlg(infoitem->getData(), this); + dlg.exec(); + emit signalViewtransparentFrame(0); + } + } else { + RightClickToCreate(listItem,event->pos()); + } +} + +void DragInfoGraphicsView::dragEnterEvent(QDragEnterEvent *event) +{ + if (event->mimeData()->hasFormat("Info")) { + QJsonParseError json_error; + QString str = event->mimeData()->data("Info"); + QJsonDocument jsonDoc(QJsonDocument::fromJson(str.toLocal8Bit(), &json_error)); + + if (json_error.error != QJsonParseError::NoError) { + event->ignore(); + } + QJsonObject rootobj = jsonDoc.object(); + ScheduleDtailInfo info = + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->JsonObjectToInfo(rootobj); + + if ((event->source() != this && info.rpeat > 0) || info.type.ID == DDECalendar::FestivalTypeID) { + event->ignore(); + } else { + event->accept(); + } + } else { + event->ignore(); + } + +} + +void DragInfoGraphicsView::dragLeaveEvent(QDragLeaveEvent *event) +{ + Q_UNUSED(event); + upDateInfoShow(); + m_MoveDate = m_MoveDate.addMonths(-2); +} + +void DragInfoGraphicsView::dragMoveEvent(QDragMoveEvent *event) +{ + QString str = event->mimeData()->data("Info"); + QDateTime gDate = getPosDate(event->pos()); + QJsonParseError json_error; + QJsonDocument jsonDoc(QJsonDocument::fromJson(str.toLocal8Bit(), &json_error)); + + if (json_error.error != QJsonParseError::NoError) { + return; + } + + if (!IsEqualtime(m_MoveDate,gDate)) { + m_MoveDate = gDate; + QJsonObject rootobj = jsonDoc.object(); + m_DragScheduleInfo = + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->JsonObjectToInfo(rootobj); + + MoveInfoProcess(m_DragScheduleInfo,event->posF()); + setPressSelectInfo(m_DragScheduleInfo); + } +} + +void DragInfoGraphicsView::dropEvent(QDropEvent *event) +{ + if (event->mimeData()->hasFormat("Info")) { + if (event->source()!=this || m_MoveDate !=m_PressDate) { + updateScheduleInfo(m_DragScheduleInfo); + } else { + emit signalsUpdateShcedule(); + } + m_DragStatus = NONE; + m_MoveDate = m_MoveDate.addMonths(-2); + } +} + +bool DragInfoGraphicsView::event(QEvent *e) +{ + if (e->type() ==QEvent::Leave) { + if (m_DragStatus ==IsCreate || + m_DragStatus == ChangeBegin || + m_DragStatus == ChangeEnd) + mouseReleaseScheduleUpdate(); + } + return DGraphicsView::event(e); +} + +void DragInfoGraphicsView::keyPressEvent(QKeyEvent *event) +{ + if (event->key() == Qt::Key_Left || event->key() ==Qt::Key_Right) + return; + DGraphicsView::keyPressEvent(event); +} + +void DragInfoGraphicsView::slotCreate() +{ + slotCreate(m_createDate); +} + +void DragInfoGraphicsView::setPressSelectInfo(const ScheduleDtailInfo &info) +{ + CScheduleDataManage::getScheduleDataManage()->setPressSelectInfo(info); +} + +void DragInfoGraphicsView::updateScheduleInfo(const ScheduleDtailInfo &info) +{ + emit signalViewtransparentFrame(1); + + if (info.rpeat >0) { + CSchceduleDlg::ChangeRecurInfo(this,info, + m_PressScheduleInfo,m_themetype); + } else { + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo( + info); + } + emit signalViewtransparentFrame(0); +} + +void DragInfoGraphicsView::DragPressEvent(const QPoint &pos, DragInfoItem *item) +{ + m_PressPos = pos; + m_PressDate = getPosDate(pos); + m_MoveDate = m_PressDate.addMonths(-2); + + if (item != nullptr) { + PosInItem mpressstatus = getPosInItem(pos,item->boundingRect()); + if (mpressstatus != MIDDLE && item->getData().type.ID == 4) { + return; + } + m_DragScheduleInfo = item->getData(); + m_PressScheduleInfo = item->getData(); + m_InfoBeginTime = m_DragScheduleInfo.beginDateTime; + m_InfoEndTime = m_DragScheduleInfo.endDateTime; + switch (mpressstatus) { + case TOP: + m_DragStatus = ChangeBegin; + setCursor(Qt::SplitVCursor); + break; + case BOTTOM: + m_DragStatus = ChangeEnd; + setCursor(Qt::SplitVCursor); + break; + case LEFT: + m_DragStatus = ChangeBegin; + setCursor(Qt::SplitHCursor); + break; + case RIGHT: + m_DragStatus = ChangeEnd; + setCursor(Qt::SplitHCursor); + break; + default: + ShowSchedule(item); + m_DragStatus = ChangeWhole; + QMimeData *mimeData = new QMimeData(); + mimeData->setText(m_DragScheduleInfo.titleName); + mimeData->setData("Info", + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->InfoToJson(m_DragScheduleInfo).toUtf8()); + + if (m_Drag ==nullptr) { + m_Drag = new QDrag(this); + } + m_Drag->setMimeData(mimeData); + QPointF itemPos = QPointF(pos.x()-item->boundingRect().x(), + pos.y()-item->boundingRect().y()); + m_Drag->setHotSpot(itemPos.toPoint()); + setDragPixmap(m_Drag,item); + break; + } + } else { + m_DragStatus = IsCreate; + m_isCreate = false; + } +} + +void DragInfoGraphicsView::mouseReleaseScheduleUpdate() +{ + setCursor(Qt::ArrowCursor); + m_press = false; + DragInfoItem::setPressFlag(false); + bool isUpdateInfo = false; + + switch (m_DragStatus) { + case IsCreate: + if (MeetCreationConditions(m_MoveDate)) { + //如果不添加会进入leaveEvent事件内的条件 + m_DragStatus = NONE; + + emit signalViewtransparentFrame(1); + CSchceduleDlg dlg(1, this); + dlg.setData(m_DragScheduleInfo); + if (dlg.exec() == DDialog::Accepted) { + } else { + setPressSelectInfo(ScheduleDtailInfo()); + } + emit signalViewtransparentFrame(0); + isUpdateInfo = true; + } + break; + case ChangeBegin: + if (!IsEqualtime(m_MoveDate,m_InfoBeginTime)) { + //如果不添加会进入leaveEvent事件内的条件 + m_DragStatus = NONE; + updateScheduleInfo(m_DragScheduleInfo); + isUpdateInfo = true; + } + break; + case ChangeEnd: + if (!IsEqualtime(m_MoveDate,m_InfoEndTime)) { + //如果不添加会进入leaveEvent事件内的条件 + m_DragStatus = NONE; + updateScheduleInfo(m_DragScheduleInfo); + isUpdateInfo = true; + } + break; + default: + break; + } + m_DragStatus = NONE; + + if (isUpdateInfo) { + emit signalsUpdateShcedule(); + } + update(); +} + +void DragInfoGraphicsView::DeleteItem(const ScheduleDtailInfo &info) +{ + emit signalViewtransparentFrame(1); + + if (info.rpeat == 0) { + CSchceduleCtrlDlg msgBox(this); + msgBox.setText(tr("You are deleting an event.")); + msgBox.setInformativeText(tr("Are you sure you want to delete this event?")); + msgBox.addPushButton(tr("Cancel"), true); + msgBox.addWaringButton(tr("Delete"), true); + msgBox.exec(); + + if (msgBox.clickButton() == 0) { + emit signalViewtransparentFrame(0); + return; + } else if (msgBox.clickButton() == 1) { + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->deleteScheduleInfoById(info.id); + } + } else { + if (info.RecurID == 0) { + CSchceduleCtrlDlg msgBox(this); + msgBox.setText(tr("You are deleting an event.")); + msgBox.setInformativeText(tr("Do you want to delete all occurrences of this event, or only the selected occurrence?")); + msgBox.addPushButton(tr("Cancel")); + msgBox.addPushButton(tr("Delete All")); + msgBox.addWaringButton(tr("Delete Only This Event")); + msgBox.exec(); + + if (msgBox.clickButton() == 0) { + emit signalViewtransparentFrame(0); + return; + } else if (msgBox.clickButton() == 1) { + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->deleteScheduleInfoById(info.id); + } else if (msgBox.clickButton() == 2) { + + ScheduleDtailInfo newschedule; + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->getScheduleInfoById(info.id, newschedule); + newschedule.ignore.append(info.beginDateTime); + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo(newschedule); + } + } else { + CSchceduleCtrlDlg msgBox(this); + msgBox.setText(tr("You are deleting an event.")); + msgBox.setInformativeText(tr("Do you want to delete this and all future occurrences of this event, or only the selected occurrence?")); + msgBox.addPushButton(tr("Cancel")); + msgBox.addPushButton(tr("Delete All Future Events")); + msgBox.addWaringButton(tr("Delete Only This Event")); + msgBox.exec(); + + if (msgBox.clickButton() == 0) { + emit signalViewtransparentFrame(0); + return; + } else if (msgBox.clickButton() == 1) { + ScheduleDtailInfo newschedule; + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->getScheduleInfoById(info.id, newschedule); + newschedule.enddata.type = 2; + newschedule.enddata.date = info.beginDateTime.addDays(-1); + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo(newschedule); + } else if (msgBox.clickButton() == 2) { + ScheduleDtailInfo newschedule; + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->getScheduleInfoById(info.id, newschedule); + newschedule.ignore.append(info.beginDateTime); + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo(newschedule); + } + } + } + emit signalsUpdateShcedule(); + emit signalViewtransparentFrame(0); +} + +void DragInfoGraphicsView::setDragPixmap(QDrag *drag, DragInfoItem *item) +{ + Q_UNUSED(item); + //设置一个1*1的透明图片,要不然关闭窗口特效会有一个小黑点 + QPixmap pixmap(1,1); + pixmap.fill(Qt::transparent); + drag->setPixmap(pixmap); + //设置图标位置为鼠标位置 + drag->setHotSpot(QPoint(0,0)); +} + +void DragInfoGraphicsView::slotCreate(const QDateTime &date) +{ + emit signalViewtransparentFrame(1); + CSchceduleDlg dlg(1, this); + QDateTime tDatatime; + tDatatime.setDate(date.date()); + + if (date.date() == QDate::currentDate()) { + tDatatime.setTime(QTime::currentTime()); + } else { + tDatatime.setTime(QTime(8, 0)); + } + dlg.setDate(tDatatime); + dlg.setAllDay(true); + + if (dlg.exec() == DDialog::Accepted) { + emit signalsUpdateShcedule(); + } + emit signalViewtransparentFrame(0); +} + +ScheduleDtailInfo DragInfoGraphicsView::getScheduleInfo(const QDateTime &beginDate, const QDateTime &endDate) +{ + ScheduleDtailInfo info; + + if (beginDate.daysTo(endDate)>0) { + info.beginDateTime = QDateTime(beginDate.date(),QTime(0,0,0)); + info.endDateTime = QDateTime(endDate.date(),QTime(23,59,59)); + } else { + info.beginDateTime = QDateTime(endDate.date(),QTime(0,0,0)); + info.endDateTime = QDateTime(beginDate.date(),QTime(23,59,00)); + } + info.titleName = tr("New Event"); + info.allday = true; + info.remind = true; + info.id = 0; + info.remindData.n = 1; + info.remindData.time = QTime(9, 0); + info.RecurID = 0; + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->GetType( + 1, info.type); + info.rpeat = 0; + + return info; +} + +void DragInfoGraphicsView::ShowSchedule(DragInfoItem *infoitem) +{ + if (infoitem ==nullptr) + return; + emit signalScheduleShow(true, infoitem->getData()); + +} + +int DragInfoGraphicsView::getDragStatus() const +{ + return m_DragStatus; +} + diff -Nru dde-calendar-5.7.0.4/src/view/draginfographicsview.h dde-calendar-5.7.0.23/src/view/draginfographicsview.h --- dde-calendar-5.7.0.4/src/view/draginfographicsview.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/view/draginfographicsview.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,119 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef DRAGINFOGRAPHICSVIEW_H +#define DRAGINFOGRAPHICSVIEW_H +#include "draginfoitem.h" + +#include + +#include +#include + +DWIDGET_USE_NAMESPACE + +class CScheduleDataManage; +class DragInfoGraphicsView : public DGraphicsView +{ + Q_OBJECT +public: + explicit DragInfoGraphicsView(DWidget *parent = nullptr); + ~DragInfoGraphicsView() override; +public: +//鼠标位置 + enum PosInItem {LEFT,MIDDLE,RIGHT,TOP,BOTTOM}; + //鼠标移动状态 + enum DragStatus {IsCreate =0,ChangeBegin =1,ChangeEnd =2,ChangeWhole =3,NONE =4}; + + int getDragStatus() const; + +protected: + void mousePressEvent(QMouseEvent *event) override; + void mouseReleaseEvent(QMouseEvent *event) override; + void mouseMoveEvent(QMouseEvent *event) override; + void wheelEvent(QWheelEvent *event) override; + void contextMenuEvent(QContextMenuEvent *event) override; + void dragEnterEvent(QDragEnterEvent *event) override; + void dragLeaveEvent(QDragLeaveEvent *event) override; + void dragMoveEvent(QDragMoveEvent *event) override; + void dropEvent(QDropEvent *event) override; + bool event(QEvent *e) override; + void keyPressEvent(QKeyEvent *event) override; +private: + void slotCreate(); + void setPressSelectInfo(const ScheduleDtailInfo &info); + void updateScheduleInfo(const ScheduleDtailInfo &info); + void DragPressEvent(const QPoint &pos,DragInfoItem *item); + void mouseReleaseScheduleUpdate(); +protected: + void DeleteItem(const ScheduleDtailInfo &info); +protected: + virtual void setDragPixmap(QDrag *drag,DragInfoItem *item); + virtual void slotCreate(const QDateTime &date); + //符合创建条件 + virtual bool MeetCreationConditions(const QDateTime &date) =0; + virtual void upDateInfoShow(const DragStatus &status = NONE,const ScheduleDtailInfo &info =ScheduleDtailInfo()) =0; + virtual QDateTime getPosDate(const QPoint &p) =0; + virtual void MoveInfoProcess(ScheduleDtailInfo &info,const QPointF &pos) = 0; + virtual PosInItem getPosInItem(const QPoint &p,const QRectF &itemRect) =0; + virtual ScheduleDtailInfo getScheduleInfo(const QDateTime &beginDate,const QDateTime &endDate); + virtual void ShowSchedule(DragInfoItem *infoitem); + //设置主题 + virtual void setTheMe(int type = 0) =0; + //判断时间是否相等 + virtual bool IsEqualtime(const QDateTime &timeFirst,const QDateTime &timeSecond) =0; + //根据鼠标移动的距离判断是否创建日程 + virtual bool JudgeIsCreate(const QPointF &pos) =0; + virtual void RightClickToCreate(QGraphicsItem *listItem,const QPoint &pos) =0; + // + virtual QDateTime getDragScheduleInfoBeginTime(const QDateTime &moveDateTime) =0; + // + virtual QDateTime getDragScheduleInfoEndTime(const QDateTime &moveDateTime) =0; +signals: + //更新获取日程信息 + void signalsUpdateShcedule(); + void signalViewtransparentFrame(const int id = 0); + void signalScheduleShow(const bool isShow, const ScheduleDtailInfo &out = ScheduleDtailInfo()); +protected: + int m_themetype = 0; + QGraphicsScene *m_Scene = nullptr; + bool m_press = false; + + QAction *m_createAction = nullptr; // 创建日程 + QAction *m_editAction = nullptr; + QAction *m_deleteAction = nullptr; + DMenu *m_rightMenu = nullptr; + + QDateTime m_createDate; + DragStatus m_DragStatus =NONE; + bool m_isCreate; + QDateTime m_PressDate; + QDateTime m_MoveDate; + QPoint m_PressPos; + ScheduleDtailInfo m_DragScheduleInfo; + QDateTime m_InfoBeginTime; + QDateTime m_InfoEndTime; + QDrag *m_Drag = nullptr; + //点击的原始info + ScheduleDtailInfo m_PressScheduleInfo; + QRectF m_PressRect; +}; + +#endif // DRAGINFOGRAPHICSVIEW_H diff -Nru dde-calendar-5.7.0.4/src/view/draginfoitem.cpp dde-calendar-5.7.0.23/src/view/draginfoitem.cpp --- dde-calendar-5.7.0.4/src/view/draginfoitem.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/view/draginfoitem.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,135 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "draginfoitem.h" + +#include +#include +#include + +bool DragInfoItem::m_press = false; +ScheduleDtailInfo DragInfoItem::m_HoverInfo; + +DragInfoItem::DragInfoItem(QRectF rect, QGraphicsItem *parent) + : QGraphicsRectItem(parent) + , m_rect(rect) +{ + setRect(m_rect); + setAcceptHoverEvents(true); + + const int duration = 200; + m_properAnimationFirst = new QPropertyAnimation( this, "offset", this); + m_properAnimationFirst->setObjectName("First"); + m_properAnimationSecond = new QPropertyAnimation( this, "offset", this); + m_properAnimationSecond->setObjectName("Second"); + m_properAnimationFirst->setDuration(duration); + m_properAnimationSecond->setDuration(duration); + m_properAnimationFirst->setEasingCurve(QEasingCurve::InOutQuad); + m_properAnimationSecond->setEasingCurve(QEasingCurve::InOutQuad); + m_Group = new QSequentialAnimationGroup(this); + m_Group->addAnimation(m_properAnimationFirst); + m_Group->addAnimation(m_properAnimationSecond); + connect(m_Group + , &QPropertyAnimation::finished + , this + , &DragInfoItem::animationFinished); +} + +DragInfoItem::~DragInfoItem() +{ + +} + +void DragInfoItem::setData(const ScheduleDtailInfo &vScheduleInfo) +{ + m_vScheduleInfo = vScheduleInfo; +} + +ScheduleDtailInfo DragInfoItem::getData() const +{ + return m_vScheduleInfo; +} + +void DragInfoItem::setPressFlag(const bool flag) +{ + m_press = flag; +} + +void DragInfoItem::setFont(DFontSizeManager::SizeType type) +{ + m_sizeType = type; +} + +void DragInfoItem::setOffset(const int &offset) +{ + m_offset = offset; + setRect(QRectF(m_rect.x() - offset, + m_rect.y() - offset / 2, + m_rect.width() + offset * 2, + m_rect.height() + offset)); + setZValue(offset); +} + +void DragInfoItem::setStartValue(const int value) +{ + m_properAnimationFirst->setStartValue(value); + m_properAnimationSecond->setEndValue(value); +} + +void DragInfoItem::setEndValue(const int value) +{ + m_properAnimationFirst->setEndValue(value); + m_properAnimationSecond->setStartValue(value); + +} + +void DragInfoItem::startAnimation() +{ + if (m_Group->state() != QAnimationGroup::Running) { + m_Group->start(); + } +} + +void DragInfoItem::animationFinished() +{ + m_isAnimation = false; +} + +void DragInfoItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) +{ + Q_UNUSED(event); + m_HoverInfo = m_vScheduleInfo; + update(); +} + +void DragInfoItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) +{ + Q_UNUSED(event); + m_HoverInfo = ScheduleDtailInfo(); + update(); +} + +void DragInfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + Q_UNUSED(option); + Q_UNUSED(widget); + m_vHoverflag = m_HoverInfo == m_vScheduleInfo; + paintBackground(painter,this->rect()); +} diff -Nru dde-calendar-5.7.0.4/src/view/draginfoitem.h dde-calendar-5.7.0.23/src/view/draginfoitem.h --- dde-calendar-5.7.0.4/src/view/draginfoitem.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/view/draginfoitem.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,84 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef DRAGINFOITEM_H +#define DRAGINFOITEM_H +#include "scheduledatamanage.h" + +#include + +#include + +DWIDGET_USE_NAMESPACE + +class QPropertyAnimation; +class QSequentialAnimationGroup; + +class DragInfoItem : public QObject, public QGraphicsRectItem +{ + Q_OBJECT + Q_PROPERTY(int offset READ readOffset WRITE setOffset) +public: + explicit DragInfoItem(QRectF rect, QGraphicsItem *parent = nullptr); + ~DragInfoItem() override; + void setData(const ScheduleDtailInfo &vScheduleInfo); + ScheduleDtailInfo getData() const; + + void setFont(DFontSizeManager::SizeType type); + void setOffset(const int &offset); + int readOffset() const + { + return m_offset; + } + void setStartValue(const int value); + void setEndValue(const int value); + void startAnimation(); + bool isRunning()const + { + return m_isAnimation; + } +public: + static void setPressFlag(const bool flag); +public slots: + void animationFinished(); +protected: + void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override; + void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override; + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override; +protected: + virtual void paintBackground(QPainter *painter,const QRectF &rect,const int isPixMap = false) =0; +protected: + ScheduleDtailInfo m_vScheduleInfo; + QFont m_font; + bool m_vSelectflag =false; + bool m_vHoverflag = false; + bool m_vHighflag = false; + QRectF m_rect; + bool m_isAnimation = false; + int m_offset = 0; + DFontSizeManager::SizeType m_sizeType = DFontSizeManager::T8; + QPropertyAnimation *m_properAnimationFirst = nullptr; + QPropertyAnimation *m_properAnimationSecond = nullptr; + QSequentialAnimationGroup *m_Group = nullptr; + static bool m_press; + static ScheduleDtailInfo m_HoverInfo; +}; + +#endif // DRAGINFOITEM_H diff -Nru dde-calendar-5.7.0.4/src/view/graphicsview.cpp dde-calendar-5.7.0.23/src/view/graphicsview.cpp --- dde-calendar-5.7.0.4/src/view/graphicsview.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/view/graphicsview.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,833 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#include "graphicsview.h" +#include "scheduleitem.h" +#include "schedulecoormanage.h" +#include "schceduledlg.h" +#include "scheduledatamanage.h" +#include "schcedulectrldlg.h" +#include "myschceduleview.h" +#include "constants.h" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +DGUI_USE_NAMESPACE +CGraphicsView::CGraphicsView(QWidget *parent, int viewType) + : DragInfoGraphicsView(parent) + , m_viewType(viewType) +{ + m_coorManage = new CScheduleCoorManage; + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + m_dayInterval = width(); + m_timeInterval = height() / 24.0; + + m_Scene->setSceneRect(0, 0, width(), height()); + m_LRPen.setColor(QColor(255, 255, 255)); + m_LRPen.setStyle(Qt::SolidLine); + m_TBPen.setColor(QColor(255, 255, 255)); + m_TBPen.setStyle(Qt::SolidLine); + m_LRFlag = true; + m_TBFlag = true; + m_margins = QMargins(0, 0, 0, 0); + + setLineWidth(0); + m_timer = new QTimer(this); + connect(m_timer, SIGNAL(timeout()), this, SLOT(scrollBarValueChangedSlot())); + m_timer->start(60000); + setViewportUpdateMode(QGraphicsView::FullViewportUpdate); + + connect(this->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(scrollBarValueChangedSlot())); + connect(this->verticalScrollBar(), + &QScrollBar::sliderPressed, + this, + &CGraphicsView::slotScrollBar); +} + +CGraphicsView::~CGraphicsView() +{ + m_timer->stop(); + m_timer->deleteLater(); + clearSchdule(); + + delete m_coorManage; + m_coorManage = nullptr; +} + +void CGraphicsView::setMargins(int left, int top, int right, int bottom) +{ + Q_UNUSED(top) + m_margins = QMargins(left, 0, right, bottom); + setViewportMargins(m_margins); +} + +void CGraphicsView::setTheMe(int type) +{ + if (type == 0 || type == 1) { + m_weekcolor = "#00429A"; + m_weekcolor.setAlphaF(0.05); + QColor linecolor = "#000000"; + linecolor.setAlphaF(0.1); + m_LRPen.setColor(linecolor); + m_TBPen.setColor(linecolor); + m_LRPen.setStyle(Qt::SolidLine); + m_TBPen.setStyle(Qt::SolidLine); + } else if (type == 2) { + m_weekcolor = "#4F9BFF"; + m_weekcolor.setAlphaF(0.1); + QColor linecolor = "#000000"; + linecolor.setAlphaF(0.1); + m_LRPen.setColor(linecolor); + m_TBPen.setColor(linecolor); + } + scene()->update(); + update(); +} + +void CGraphicsView::slotCreate(const QDateTime &date) +{ + emit signalViewtransparentFrame(1); + CSchceduleDlg dlg(1, this); + dlg.setDate(date); + + if (dlg.exec() == DDialog::Accepted) { + emit signalsUpdateShcedule(); + } + emit signalViewtransparentFrame(0); +} + +bool CGraphicsView::MeetCreationConditions(const QDateTime &date) +{ + return qAbs(date.daysTo(m_PressDate)<7); +} + +void CGraphicsView::updateHigh() +{ + scene()->update(); + update(); +} + +void CGraphicsView::setRange( int w, int h, QDate begindate, QDate enddate, int rightmagin) +{ + m_MoveDate.setDate(begindate.addMonths(-2)); + m_beginDate = begindate; + m_endDate = enddate; + w = w - rightmagin -2; + m_Scene->setSceneRect(0, 0, w, h); + m_coorManage->setRange(w, h, begindate, enddate, rightmagin); + m_rightmagin = rightmagin; + qint64 totalDay = begindate.daysTo(enddate) + 1; + m_dayInterval = w * 1.0 / totalDay; + m_timeInterval = h / 24.0; + m_totalDay = totalDay; + + if (m_viewType ==0) { + int viewWidth = viewport()->width(); + int viewHeight = viewport()->height(); + QPoint newCenter(viewWidth / 2, viewHeight / 2 - 2000); + + centerOnScene(mapToScene(newCenter)); + } +} + +void CGraphicsView::setRange(QDate begin, QDate end) +{ + m_MoveDate.setDate(begin.addMonths(-2)); + m_beginDate = begin; + m_endDate = end; + getCoorManage()->setDateRange(begin, end); +} + +void CGraphicsView::setInfo(const QVector &info) +{ + m_scheduleInfo = info; +} + +bool MScheduleTimeThan(const ScheduleDtailInfo &s1, const ScheduleDtailInfo &s2) +{ + if (s1.beginDateTime.date().daysTo(s1.endDateTime.date())== + s2.beginDateTime.date().daysTo(s2.endDateTime.date())) { + if (s1.beginDateTime == s2.beginDateTime) { + return s1.beginDateTime.secsTo(s1.endDateTime) > s2.beginDateTime.secsTo(s2.endDateTime); + } else { + return s1.beginDateTime < s2.beginDateTime; + } + } else { + return s1.beginDateTime.date().daysTo(s1.endDateTime.date())>s2.beginDateTime.date().daysTo(s2.endDateTime.date()); + } +} + +void CGraphicsView::upDateInfoShow(const CGraphicsView::DragStatus &status, const ScheduleDtailInfo &info) +{ + clearSchdule(); + QVector vListData; + vListData = m_scheduleInfo; + + switch (status) { + case NONE: + Q_UNUSED(info); + break; + case ChangeBegin: + case ChangeEnd: { + int index = vListData.indexOf(info); + if (index >=0) + vListData[index] = info; + } + break; + case ChangeWhole: + vListData.append(info); + break; + case IsCreate: + vListData.append(info); + break; + } + QMap > m_InfoMap; + QDate currentDate; + qint64 count = m_beginDate.daysTo(m_endDate); + qint64 beginoffset = 0, endoffset = 0; + QVector currentInfo; + + for (int i = 0; i <= count; ++i) { + currentDate = m_beginDate.addDays(i); + currentInfo.clear(); + + for (int j = 0; j 0 && + vListData.at(j).endDateTime.time() ==QTime(0,0,0)) { + continue; + } + currentInfo.append(vListData.at(j)); + } + std::sort(currentInfo.begin(), currentInfo.end(), MScheduleTimeThan); + if (currentInfo.size()>0) { + m_InfoMap[currentDate] = currentInfo; + QList info; + scheduleClassificationType(currentInfo,info); + + for (int m = 0; m < info.count(); m++) { + int tnum = info.at(m).vData.count(); + + if (m_viewType == 0) { + if (tnum > m_sMaxNum) { + tnum = m_sMaxNum; + for (int n = 0; n < tnum - 1; n++) { + addSchduleItem(info.at(m).vData.at(n), currentDate, n + 1, + tnum, 0, m_viewType, m_sMaxNum); + } + ScheduleDtailInfo tdetaliinfo = info.at(m).vData.at(tnum - 2); + tdetaliinfo.titleName = "..."; + tdetaliinfo.type.ID = 3; + addSchduleItem(tdetaliinfo, currentDate, tnum, tnum, 1, + m_viewType, m_sMaxNum); + } else { + for (int n = 0; n < tnum; n++) { + addSchduleItem(info.at(m).vData.at(n), currentDate, n + 1, + tnum, 0, m_viewType, m_sMaxNum); + } + } + } else { + for (int n = 0; n < tnum; n++) { + addSchduleItem(info.at(m).vData.at(n), currentDate, n + 1, + tnum, 0, m_viewType, m_sMaxNum); + } + } + } + } + } +} + +QDateTime CGraphicsView::getPosDate(const QPoint &p) +{ + return TimeRounding(m_coorManage->getDate(mapToScene(p))); +} + +void CGraphicsView::ShowSchedule(DragInfoItem *infoitem) +{ + CScheduleItem *scheduleitem = dynamic_cast(infoitem); + if (scheduleitem->getType() == 1) + return; + DragInfoGraphicsView::ShowSchedule(infoitem); +} + +void CGraphicsView::MoveInfoProcess(ScheduleDtailInfo &info, const QPointF &pos) +{ + Q_UNUSED(pos); + + if (!info.allday) { + qint64 offset = m_PressDate.secsTo(m_MoveDate); + info.beginDateTime = info.beginDateTime.addSecs(offset); + info.endDateTime = info.endDateTime.addSecs(offset); + } else { + info.allday = false; + info.remind = false; + info.beginDateTime = m_MoveDate; + info.endDateTime = m_MoveDate.addSecs(3600); + } + info.IsMoveInfo = true; + upDateInfoShow(ChangeWhole,info); +} + +void CGraphicsView::addSchduleItem( const ScheduleDtailInfo &info, QDate date, int index, int totalNum, int type, int viewtype, int maxnum) +{ + CScheduleItem *item = new CScheduleItem( + m_coorManage->getDrawRegion(date, info.beginDateTime, + info.endDateTime, index, totalNum, maxnum, + viewtype), nullptr, type); + m_Scene->addItem(item); + item->setData(info, date, totalNum); + m_vScheduleItem.append(item); + +} + +void CGraphicsView::deleteSchduleItem( CScheduleItem *item ) +{ + int id = item->getData().id; + + for (int i = 0; i < m_vScheduleItem.size(); i++) { + if (m_vScheduleItem[i]->getData().id == id) { + m_vScheduleItem.remove(i); + m_Scene->removeItem(item); + delete m_vScheduleItem[i]; + m_vScheduleItem[i] = nullptr; + i--; + } + } +} + +void CGraphicsView::setSelectSchedule(const ScheduleDtailInfo &info) +{ + setTime(info.beginDateTime.time()); + + for (int i = 0 ; i < m_vScheduleItem.size(); ++i) { + if (m_vScheduleItem.at(i)->getType() == 1) + continue; + if (m_vScheduleItem.at(i)->hasSelectSchedule(info)) { + m_vScheduleItem.at(i)->setStartValue(0); + m_vScheduleItem.at(i)->setEndValue(10); + m_vScheduleItem.at(i)->startAnimation(); + } + } +} + +void CGraphicsView::clearSchdule() +{ + for (int i = 0; i < m_vScheduleItem.size(); i++) { + m_Scene->removeItem(m_vScheduleItem.at(i)); + delete m_vScheduleItem[i]; + m_vScheduleItem[i] = nullptr; + } + m_vScheduleItem.clear(); + m_updateDflag = true; +} + +void CGraphicsView::scheduleClassificationType(QVector &scheduleInfolist, QList &info) +{ + QVector schedulelist = scheduleInfolist; + if (schedulelist.isEmpty()) + return; + + info.clear(); + std::sort(schedulelist.begin(), schedulelist.end(), MScheduleTimeThan); + QVector containIndex; + + for (int k = 0; k < schedulelist.count(); k++) { + QDateTime endTime = schedulelist.at(k).endDateTime; + QDateTime begTime = schedulelist.at(k).beginDateTime; + + if (begTime.date().daysTo(endTime.date())==0 && begTime.time().secsTo(endTime.time())= info.at(i).begindate && + schedulelist.at(k).beginDateTime <= info.at(i).enddate) || + (endTime >= info.at(i).begindate && + endTime <= info.at(i).enddate) ) { + containIndex.append(i); + } + } + if (containIndex.count()==0) { + ScheduleclassificationInfo firstschedule; + firstschedule.begindate = schedulelist.at(k).beginDateTime; + firstschedule.enddate = endTime; + firstschedule.vData.append(schedulelist.at(k)); + info.append(firstschedule); + } else { + ScheduleclassificationInfo &scheduleInfo = info[containIndex.at(0)]; + int index = 0; + + for (int i = 1; i < containIndex.count(); ++i) { + index = containIndex.at(i); + if (info.at(index).begindate < scheduleInfo.begindate) + scheduleInfo.begindate = info.at(index).begindate; + if (info.at(index).enddate>scheduleInfo.enddate) + scheduleInfo.enddate = info.at(index).enddate; + scheduleInfo.vData.append(info.at(index).vData); + } + for (int i = containIndex.count() -1; i >0; --i) { + info.removeAt(containIndex.at(i)); + } + if (schedulelist.at(k).beginDateTime < scheduleInfo.begindate) + scheduleInfo.begindate = schedulelist.at(k).beginDateTime; + if (endTime>scheduleInfo.enddate) + scheduleInfo.enddate = endTime; + scheduleInfo.vData.append(schedulelist.at(k)); + } + } +} + +void CGraphicsView::mouseDoubleClickEvent( QMouseEvent *event ) +{ + emit signalScheduleShow(false); + DGraphicsView::mouseDoubleClickEvent(event); + CScheduleItem *item = dynamic_cast(itemAt(event->pos())); + + if (item == nullptr) { + QPointF senceposs = mapToScene(event->pos()); + emit signalViewtransparentFrame(1); + CSchceduleDlg dlg(1, this); + QDateTime tDatatime = m_coorManage->getDate(senceposs); + dlg.setDate(tDatatime); + if (dlg.exec() == DDialog::Accepted) { + emit signalsUpdateShcedule(); + } + emit signalViewtransparentFrame(0); + return; + } + if (item->getType() == 1) { + emit signalsCurrentScheduleDate(item->getdate()); + return; + } + emit signalViewtransparentFrame(1); + m_updateDflag = false; + CMySchceduleView dlg(item->getData(), this); + connect(&dlg, &CMySchceduleView::signalsEditorDelete, this, &CGraphicsView::slotDoubleEvent); + dlg.exec(); + emit signalViewtransparentFrame(0); + disconnect(&dlg, &CMySchceduleView::signalsEditorDelete, this, &CGraphicsView::slotDoubleEvent); + + if (item == nullptr) { + return; + } +} + +void CGraphicsView::mousePressEvent(QMouseEvent *event) +{ + CScheduleItem *item = dynamic_cast(itemAt(event->pos())); + + if (item !=nullptr &&item->getType() ==1) { + emit signalScheduleShow(false); + return; + } + DragInfoGraphicsView::mousePressEvent(event); +} + +void CGraphicsView::mouseMoveEvent(QMouseEvent *event) +{ + CScheduleItem *item = dynamic_cast(itemAt(event->pos())); + + if (item !=nullptr &&item->getType() ==1) { + setCursor(Qt::ArrowCursor); + DGraphicsView::mouseMoveEvent(event); + return; + } + DragInfoGraphicsView::mouseMoveEvent(event); +} +void CGraphicsView::slotDoubleEvent(int type) +{ + Q_UNUSED(type); + m_updateDflag = true; + emit signalsUpdateShcedule(); +} + +void CGraphicsView::slotDeleteItem() +{ + if (CScheduleDataManage::getScheduleDataManage()->getPressSelectInfo().type.ID <0) { + return; + } + if (CScheduleDataManage::getScheduleDataManage()->getPressSelectInfo().type.ID != DDECalendar::FestivalTypeID) { + DeleteItem(CScheduleDataManage::getScheduleDataManage()->getPressSelectInfo()); + } + CScheduleDataManage::getScheduleDataManage()->setPressSelectInfo(ScheduleDtailInfo()); +} + + +void CGraphicsView::slotScrollBar() +{ + emit signalScheduleShow(false); +} + +void CGraphicsView::slotUpdateScene() +{ + this->scene()->update(); +} + +#ifndef QT_NO_WHEELEVENT +/************************************************************************ +Function: wheelEvent() +Description: 鼠标滚轮事件 +Input: event 滚轮事件 +Output: 无 +Return: 无 +Others: 无 +************************************************************************/ +void CGraphicsView::wheelEvent( QWheelEvent *event ) +{ + emit signalScheduleShow(false); + int test = event -> delta(); + int viewWidth = viewport()->width(); + int viewHeight = viewport()->height(); + QPoint newCenter(viewWidth / 2, viewHeight / 2 - test); + QPointF centerpos = mapToScene(newCenter); + centerOnScene(centerpos); +} +#endif + + +/************************************************************************ +Function: resizeEvent() +Description: 窗口大小改变事件 +Input: event 窗口大小改变事件 +Output: 无 +Return: 无 +Others: 无 +************************************************************************/ +void CGraphicsView::resizeEvent( QResizeEvent *event ) +{ + scrollBarValueChangedSlot(); + QGraphicsView::resizeEvent(event); + viewport()->update(); + update(); +} + +/************************************************************************ +Function: paintEvent() +Description: 绘制事件 +Input: event 事件 +Output: 无 +Return: 无 +Others: 无 +************************************************************************/ +void CGraphicsView::paintEvent(QPaintEvent *event) +{ + QPainter t_painter(viewport()); + //绘制背景 + paintBackground(t_painter); + int t_width = viewport()->width() + 2; + //绘制水平线 + if (m_LRFlag) { + if (m_cuttrnttimetype == 0) { + t_painter.save(); + t_painter.setPen(m_LRPen); + + for (int i = 0; i < m_vLRLarge.size(); ++i) + t_painter.drawLine(QPoint(0, m_vLRLarge[i] - 1), QPoint(t_width, m_vLRLarge[i] - 1)); + t_painter.restore(); + } else { + t_painter.save(); + t_painter.setPen(m_LRPen); + + for (int i = 0; i < m_vLRLarge.size() - 1; ++i) + t_painter.drawLine(QPoint(0, m_vLRLarge[i] - 1), QPoint(t_width, m_vLRLarge[i] - 1)); + t_painter.restore(); + + if (m_viewType == 1 && m_coorManage->getBegindate() == QDate::currentDate()) { + t_painter.save(); + QPen pen = m_LRPen; + pen.setColor(m_currenttimecolor); + t_painter.setPen(pen); + int index = m_vLRLarge.count() - 1; + t_painter.drawLine(QPoint(0, m_vLRLarge[index] - 1), QPoint(t_width, m_vLRLarge[index] - 1)); + t_painter.restore(); + } + + } + } + QGraphicsView::paintEvent(event); +} + +void CGraphicsView::paintBackground(QPainter &painter) +{ + // 绘制Rect的宽度 + const int t_width = viewport()->width() - 2; + // 需要处理的天数 + const qint64 m_TotalDay = m_beginDate.daysTo(m_endDate) + 1; + // 左边距 + const int m_leftMagin = 0; + // 每天的宽度 + const qreal intenval = 1.0 * (t_width - m_leftMagin) / m_TotalDay; + // 每天X坐标点偏移 + const qreal XPointOffset = 1.5; + // 分割线颜色 + QColor m_linecolor = "#000000"; + m_linecolor.setAlphaF(0.1); + if (m_TotalDay > 1) { + painter.save(); + painter.setPen(Qt::SolidLine); + painter.setPen(m_linecolor); + //绘制分割线 + for (int i = 1; i < 7; ++i) { + painter.drawLine(QPointF(i * intenval + m_leftMagin + XPointOffset, 1), + QPointF(i * intenval + m_leftMagin + XPointOffset, this->height())); + } + painter.restore(); + painter.save(); + //绘制周六周日背景色 + painter.setBrush(m_weekcolor); + painter.setPen(Qt::NoPen); + painter.setRenderHint(QPainter::Antialiasing); + for (int i = 0; i != 7; ++i) { + int d = m_beginDate.addDays(i).dayOfWeek(); + if (d == 7 || d == 6) { + painter.drawRect( + QRectF(m_leftMagin + i * intenval + XPointOffset, 0, intenval, this->height())); + } + } + painter.restore(); + } +} + +void CGraphicsView::scrollBarValueChangedSlot() +{ + emit signalScheduleShow(false); + QMutexLocker locker(&m_Mutex); + int viewHeight = viewport()->height(); + m_vLRLarge.clear(); + m_vTBLarge.clear(); + QPointF leftToprealPos = mapToScene(QPoint(0, 0)); + QPointF leftBttomrealPos = mapToScene(QPoint(0, viewHeight)); + + for (qreal i = m_dayInterval; i < scene()->width(); i = i + m_dayInterval) { + m_vTBLarge.append(qFloor(i)); + } + + qreal beginpos = static_cast(qFloor(leftToprealPos.y() / m_timeInterval) * m_timeInterval); + + if (beginpos < leftToprealPos.y()) { + beginpos = (beginpos / m_timeInterval + 1) * m_timeInterval ; + } + + QVector vHours; + + for (qreal i = beginpos; i < leftBttomrealPos.y(); i = i + m_timeInterval) { + QPoint point = mapFromScene(leftBttomrealPos.x(), i); + m_vLRLarge.append(point.y()); + vHours.append(qFloor(i / m_timeInterval + 0.5)); + } + + qreal currentTime = static_cast(m_coorManage->getHeight(QTime::currentTime())); + + if (currentTime > beginpos && currentTime < leftBttomrealPos.y()) { + m_cuttrnttimetype = 1; + QPoint point = mapFromScene(leftBttomrealPos.x(), currentTime); + m_vLRLarge.append(point.y()); + vHours.append(qFloor(currentTime / m_timeInterval + 0.5)); + emit signalsPosHours(m_vLRLarge, vHours, m_cuttrnttimetype); + } else { + m_cuttrnttimetype = 0; + emit signalsPosHours(m_vLRLarge, vHours, m_cuttrnttimetype); + } + scene()->update(); + update(); +} + +int CGraphicsView::checkDay(int weekday) +{ + if (weekday <= 0) + return weekday += 7; + + if (weekday > 7) + return weekday -= 7; + + return weekday; +} + + +CGraphicsView::PosInItem CGraphicsView::getPosInItem(const QPoint &p, const QRectF &itemRect) +{ + QPointF scenePos = this->mapToScene(p); + QPointF itemPos = QPointF(scenePos.x()-itemRect.x(), + scenePos.y()-itemRect.y()); + qreal bottomy = itemRect.height()- itemPos.y(); + + if (itemPos.y()<5) { + return TOP; + } + if (bottomy <5) { + return BOTTOM; + } + + return MIDDLE; +} + +ScheduleDtailInfo CGraphicsView::getScheduleInfo(const QDateTime &beginDate, const QDateTime &endDate) +{ + ScheduleDtailInfo info; + + if (beginDate.secsTo(endDate)>0) { + info.beginDateTime = beginDate; + + if (beginDate.secsTo(endDate) < DDECalendar::ThirtyMinutesWithSec) { + info.endDateTime = beginDate.addSecs(DDECalendar::ThirtyMinutesWithSec); + } else { + info.endDateTime = endDate; + } + } else { + if (endDate.secsTo(beginDate) < DDECalendar::ThirtyMinutesWithSec) { + info.beginDateTime = beginDate.addSecs(-DDECalendar::ThirtyMinutesWithSec); + } else { + info.beginDateTime = endDate; + } + info.endDateTime = beginDate; + } + info.titleName = tr("New Event"); + info.allday = false; + info.remind = true; + info.id = 0; + info.remindData.n = 1; + info.remindData.time = QTime(9, 0); + info.RecurID = 0; + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->GetType( + 1, info.type); + info.rpeat = 0; + + return info; +} + +bool CGraphicsView::IsEqualtime(const QDateTime &timeFirst, const QDateTime &timeSecond) +{ + return !(qAbs(timeFirst.secsTo(timeSecond))>100); +} + +bool CGraphicsView::JudgeIsCreate(const QPointF &pos) +{ + return qAbs(pos.x()-m_PressPos.x())>20 || + qAbs(m_PressDate.secsTo(m_coorManage->getDate(mapToScene(pos.toPoint()))))>300; +} + +void CGraphicsView::RightClickToCreate(QGraphicsItem *listItem, const QPoint &pos) +{ + Q_UNUSED(listItem); + m_rightMenu->clear(); + m_rightMenu->addAction(m_createAction); + QPointF senceposs = mapToScene(pos); + m_createDate =m_coorManage->getDate(senceposs); + m_rightMenu->exec(QCursor::pos()); +} + +QDateTime CGraphicsView::getDragScheduleInfoBeginTime(const QDateTime &moveDateTime) +{ + return moveDateTime.secsTo(m_InfoEndTime) < DDECalendar::ThirtyMinutesWithSec ? m_InfoEndTime.addSecs(-DDECalendar::ThirtyMinutesWithSec) : moveDateTime; +} + +QDateTime CGraphicsView::getDragScheduleInfoEndTime(const QDateTime &moveDateTime) +{ + return m_InfoBeginTime.secsTo(moveDateTime) < DDECalendar::ThirtyMinutesWithSec ? m_InfoBeginTime.addSecs(DDECalendar::ThirtyMinutesWithSec) : moveDateTime; +} + +QDateTime CGraphicsView::TimeRounding(const QDateTime &time) +{ + int hours = time.time().hour(); + int minnutes = 0; + minnutes = time.time().minute() / 15; + + return QDateTime(time.date(),QTime(hours,minnutes*15,0)); +} + +void CGraphicsView::centerOnScene(const QPointF &pos) +{ + // view 根据鼠标下的点作为锚点来定位 scene + setTransformationAnchor(QGraphicsView::AnchorUnderMouse); + centerOn(pos); + // scene 在 view 的中心点作为锚点 + setTransformationAnchor(QGraphicsView::AnchorViewCenter); + scrollBarValueChangedSlot(); + setSceneHeightScale(pos); +} + +void CGraphicsView::setSceneHeightScale(const QPointF &pos) +{ + m_sceneHeightScale = pos.y()/this->scene()->height(); +} + +void CGraphicsView::keepCenterOnScene() +{ + QPointF pos; + pos.setX(this->viewport()->width()/2); + pos.setY(this->scene()->height()*m_sceneHeightScale); + centerOnScene(pos); +} + +void CGraphicsView::getLargeScaleFlag(bool &LRFlag, bool &TBFlag) +{ + LRFlag = m_LRFlag; + TBFlag = m_TBFlag; +} + +void CGraphicsView::setFirstWeekday(int weekday) +{ + m_firstWeekDay = weekday; +} + +void CGraphicsView::setTime(QTime time) +{ + int viewWidth = viewport()->width(); + int viewHeight = viewport()->height(); + + QPoint newCenter(viewWidth / 2, viewHeight / 2); + QPointF centerpos = mapToScene(newCenter); + centerpos = QPointF(centerpos.x(), static_cast(m_coorManage->getHeight(time))); + centerOnScene(centerpos); +} + +void CGraphicsView::updateInfo() +{ + switch (m_DragStatus) { + case IsCreate: + upDateInfoShow(IsCreate,m_DragScheduleInfo); + break; + default: + upDateInfoShow(); + break; + } +} diff -Nru dde-calendar-5.7.0.4/src/view/graphicsview.h dde-calendar-5.7.0.23/src/view/graphicsview.h --- dde-calendar-5.7.0.4/src/view/graphicsview.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/view/graphicsview.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,183 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#ifndef GRAPHICSVIEW_H +#define GRAPHICSVIEW_H + +#include "schedulestructs.h" +#include "draginfographicsview.h" + +#include +#include + +#include +#include +#include +#include + +DWIDGET_USE_NAMESPACE + +typedef struct _tagScheduleclassificationInfo { + QDateTime begindate; + QDateTime enddate; + QVector vData; + +} ScheduleclassificationInfo; + +class CScheduleCoorManage; +class CScheduleItem; +class CGraphicsView : public DragInfoGraphicsView +{ + Q_OBJECT +public: + CGraphicsView(QWidget *parent, int viewType = 0); + ~CGraphicsView() override; + void setMargins(int left, int top, int right, int bottom); + QMargins getMargins() + { + return m_margins; + } + void updateHigh(); + void setRange(int w, int h, QDate begindate, QDate enddate, int rightmagin); + void setRange(QDate begin, QDate end); + + CScheduleCoorManage *getCoorManage() + { + return m_coorManage; + } + void setInfo(const QVector &info); + void addSchduleItem(const ScheduleDtailInfo &info, QDate date, int index, int totalNum, int type, int viewtype, int maxnum); + void deleteSchduleItem(CScheduleItem *item); + void setSelectSchedule(const ScheduleDtailInfo &info); + void clearSchdule(); + + void setMinTime(const int &minTime) + { + m_minTime = minTime; + } + void setMaxNum(const int maxnum) + { + m_sMaxNum = maxnum; + } + void keepCenterOnScene(); + + void scheduleClassificationType(QVector &scheduleInfolist, + QList &info); + void mouseDoubleClickEvent(QMouseEvent *event) override; + void mousePressEvent(QMouseEvent *event) override; + void mouseMoveEvent(QMouseEvent *event) override; + +#ifndef QT_NO_WHEELEVENT + void wheelEvent(QWheelEvent *event) override; +#endif + + /************************************************************************ + Function: resizeEvent() + Description: 窗口大小改变事件 + Input: event 窗口大小改变事件 + Output: 无 + Return: 无 + Others: 无 + ************************************************************************/ + void resizeEvent(QResizeEvent *event) override; + + /************************************************************************ + Function: getLargeScaleFlag() + Description: 获取大刻度显示 + Input: LRFlag 水平刻度,TBFlag 垂直刻度 + Output: 无 + Return: 无 + Others: 无 + ************************************************************************/ + void getLargeScaleFlag(bool &LRFlag, bool &TBFlag); + void setFirstWeekday(int weekday); + void setTime(QTime time); + void updateInfo(); +protected: + void paintEvent(QPaintEvent *event) override; +private: + /** + * @brief paintBackground 绘制背景--周试图周六周天的背景色和每天的分割线 + * @param painter painter对象 + */ + void paintBackground(QPainter &painter); +public slots: + void scrollBarValueChangedSlot(); + void slotDoubleEvent(int type); + void slotDeleteItem(); + void slotScrollBar(); + void slotUpdateScene(); +signals: + void signalsPosHours(QVector vPos, QVector vHours, int cuttrnttimetype = 0); + void signalsCurrentScheduleDate(QDate date); + void signalSceneUpdate(); +private: + int checkDay(int weekday); + void TimeRound(QDateTime &dtime); + QDateTime TimeRounding(const QDateTime &time); + void centerOnScene(const QPointF &pos); + void setSceneHeightScale(const QPointF &pos); +public: + void setTheMe(int type = 0) override; +protected: + void slotCreate(const QDateTime &date) override; + bool MeetCreationConditions(const QDateTime &date) override; + void upDateInfoShow(const DragStatus &status = NONE,const ScheduleDtailInfo &info =ScheduleDtailInfo())override; + QDateTime getPosDate(const QPoint &p) override; + void ShowSchedule(DragInfoItem *infoitem) override; + void MoveInfoProcess(ScheduleDtailInfo &info,const QPointF &pos) override; + PosInItem getPosInItem(const QPoint &p,const QRectF &itemRect) override; + ScheduleDtailInfo getScheduleInfo(const QDateTime &beginDate,const QDateTime &endDate) override; + bool IsEqualtime(const QDateTime &timeFirst,const QDateTime &timeSecond) override; + bool JudgeIsCreate(const QPointF &pos) override; + void RightClickToCreate(QGraphicsItem *listItem,const QPoint &pos) override; + QDateTime getDragScheduleInfoBeginTime(const QDateTime &moveDateTime) override; + QDateTime getDragScheduleInfoEndTime(const QDateTime &moveDateTime) override; +private: + CScheduleCoorManage *m_coorManage = nullptr; + QVector m_vScheduleItem; + QMargins m_margins; //四周空白 + bool m_LRFlag; //水平线 + QPen m_LRPen; //水平线画笔 + bool m_TBFlag; //垂直线 + QPen m_TBPen; //垂直线画笔 + QVector m_vLRLarge; //大刻度像素位置 + QVector m_vTBLarge; //大刻度像素位置 + qreal m_dayInterval; + qreal m_timeInterval; + int m_firstWeekDay; + qint64 m_totalDay; + qreal m_sceneHeightScale =0; + + QColor m_weekcolor = "#4F9BFF"; + QColor m_currenttimecolor = "#F74444"; + int m_cuttrnttimetype = 0; + QTimer *m_timer = nullptr; + QMutex m_Mutex; + int m_viewType = 0; + bool m_updateDflag = false; + int m_rightmagin = 0; + + QVector m_scheduleInfo; + QDate m_beginDate; + QDate m_endDate; + int m_minTime; //最小高度对应的最小时间 + int m_sMaxNum = 4; +}; + +#endif // GRAPHICSVIEW_H diff -Nru dde-calendar-5.7.0.4/src/view/monthgraphiview.cpp dde-calendar-5.7.0.23/src/view/monthgraphiview.cpp --- dde-calendar-5.7.0.4/src/view/monthgraphiview.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/view/monthgraphiview.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,766 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#include "monthgraphiview.h" +#include "../widget/monthWidget/monthschceduleview.h" +#include "../dialog/schceduledlg.h" +#include "../dialog/schcedulectrldlg.h" +#include "../dialog/myschceduleview.h" +#include "constants.h" + +#include + +#include +#include +#include + +bool CDayGraphicsItem::m_LunarVisible = false; + +CMonthGraphiview::CMonthGraphiview(QWidget *parent) + : DragInfoGraphicsView (parent) +{ + QShortcut *shortcut = new QShortcut(parent); + shortcut->setKey(QKeySequence(QLatin1String("Delete"))); + connect(shortcut, + &QShortcut::activated, this, + &CMonthGraphiview::slotDeleteItem); + + m_MonthSchceduleView = new CMonthSchceduleView(this,m_Scene); + connect(this,&CMonthGraphiview::signalFontChange, + m_MonthSchceduleView,&CMonthSchceduleView::slotFontChange); + + for (int i = 0; i < DDEMonthCalendar::ItemSizeofMonthDay; ++i) { + CDayGraphicsItem *item = new CDayGraphicsItem(); + item->setZValue(-1); + m_DayItem.append(item); + m_Scene->addItem(item); + item->setitemnum(i); + } + updateSize(); +} + +CMonthGraphiview::~CMonthGraphiview() +{ + delete m_MonthSchceduleView; + + for (int i = 0; i < m_DayItem.size(); ++i) { + CDayGraphicsItem *item = m_DayItem.at(i); + delete item; + item = nullptr; + } + + m_DayItem.clear(); +} + +void CMonthGraphiview::setTheMe(int type) +{ + m_themetype = type; + + for (int i = 0; i < m_DayItem.size(); ++i) { + m_DayItem.at(i)->setTheMe(type); + } + + m_MonthSchceduleView->setTheMe(type); +} + +void CMonthGraphiview::setDate(const QDate date[42]) +{ + if (date[0].day() !=1) { + m_currentMonth = date[0].addMonths(1).month(); + } else { + m_currentMonth = date[0].month(); + } + + for (int i = 0; i < m_DayItem.size(); ++i) { + m_DayItem.at(i)->setData(date[i]); + m_DayItem.at(i)->setCurrentMonth(date[i].month() == m_currentMonth); + m_DayItem.at(i)->setStatus(CDayGraphicsItem::HolidayStatus(getFestivalInfoByDate(date[i]))); + } + + this->scene()->update(); +} + +void CMonthGraphiview::setLunarInfo(QMap *lunarCache) +{ + m_lunarCache = lunarCache; + updateLunar(); + +} + +void CMonthGraphiview::setLunarVisible(bool visible) +{ + CDayGraphicsItem::m_LunarVisible = visible; +} + +void CMonthGraphiview::setScheduleInfo(const QVector &info) +{ + m_shceludelistdata = info; + updateInfo(); +} + +void CMonthGraphiview::setSelectSchedule(const ScheduleDtailInfo &scheduleInfo) +{ + QVector mscheduleShowBtn = m_MonthSchceduleView->getScheduleShowItem(); + + for (int i = 0; i < mscheduleShowBtn.size(); ++i) { + CMonthSchceduleWidgetItem *item = dynamic_cast(mscheduleShowBtn.at(i)); + + if (item == nullptr) continue; + + if (scheduleInfo == item->getData()) { + item->setStartValue(0); + item->setEndValue(4); + item->startAnimation(); + } + } +} + +void CMonthGraphiview::updateSize() +{ + m_Scene->setSceneRect(this->viewport()->rect()); + qreal w = m_Scene->width() / DDEMonthCalendar::AFewDaysofWeek; + qreal h = m_Scene->height() / DDEMonthCalendar::LinesNumofMonth; + QRectF rect ; + int w_offset = 0; + int h_offset = 0; + + for (int i = 0 ; i < m_DayItem.size(); ++i) { + h_offset = i / DDEMonthCalendar::AFewDaysofWeek; + w_offset = i % DDEMonthCalendar::AFewDaysofWeek; + rect.setRect(w*w_offset, + h*h_offset, + w, + h); + m_DayItem.at(i)->setRect(rect); + } +} + +void CMonthGraphiview::updateLunar() +{ + QDate date; + CaLunarDayInfo info; + QString lunarStr(""); + + for (int i = 0 ; i < m_DayItem.size(); ++i) { + date = m_DayItem.at(i)->getDate(); + if (m_lunarCache->contains(date)) { + info = m_lunarCache->value(date); + + if (info.mLunarDayName == "初一") { + info.mLunarDayName = info.mLunarMonthName + info.mLunarDayName; + } + + if (info.mTerm.isEmpty()) { + lunarStr = info.mLunarDayName; + } else { + lunarStr = info.mTerm; + } + } else { + lunarStr = ""; + } + m_DayItem.at(i)->setLunar(lunarStr); + } +} + +void CMonthGraphiview::updateInfo() +{ + int h = m_MonthSchceduleView->getSchceduleHeight(); + m_MonthSchceduleView->setallsize(this->viewport()->width(), + this->viewport()->height(), + 0, 0, 0, h); + m_MonthSchceduleView->setData(m_shceludelistdata, 1); + + switch (m_DragStatus) { + case IsCreate: + upDateInfoShow(IsCreate,m_DragScheduleInfo); + break; + case ChangeWhole: + upDateInfoShow(ChangeWhole,m_DragScheduleInfo); + break; + default: + + break; + } + update(); +} + +char CMonthGraphiview::getFestivalInfoByDate(const QDate &date) +{ + for (int i = 0; i < m_festivallist.count(); i++) { + for (int j = 0; j < m_festivallist[i].listHoliday.count(); j++) { + if (m_festivallist[i].listHoliday[j].date == date) { + return m_festivallist[i].listHoliday[j].status; + } + } + } + return 0; +} + +QPointF CMonthGraphiview::getItemPos(const QPoint &p, const QRectF &itemRect) +{ + QPointF scenePos = this->mapToScene(p); + return QPointF(scenePos.x()-itemRect.x(), + scenePos.y()-itemRect.y()); +} + +CMonthGraphiview::PosInItem CMonthGraphiview::getPosInItem(const QPoint &p, const QRectF &itemRect) +{ + QPointF scenePos = this->mapToScene(p); + QPointF itemPos = QPointF(scenePos.x()-itemRect.x(), + scenePos.y()-itemRect.y()); + qreal bottomy = itemRect.width()- itemPos.x(); + + if (itemPos.x()<5) { + return LEFT; + } + + if (bottomy <5) { + return RIGHT; + } + + return MIDDLE; +} + +QDateTime CMonthGraphiview::getPosDate(const QPoint &p) +{ + if (!this->sceneRect().contains(p)) + return m_MoveDate; + QRectF rect = this->sceneRect(); + qreal x =0; + qreal y = 0; + + if (p.x()<0) { + x =0; + } else if (p.x()>(rect.width()-10)) { + x = rect.width()-10; + } else { + x = p.x(); + } + + if (p.y()<0) { + y =0; + } else if (p.y()>(rect.height()-10)) { + y = rect.height()-10; + } else { + y = p.y(); + } + + int xoffset = qFloor(x / (rect.width() / DDEMonthCalendar::AFewDaysofWeek)) % DDEMonthCalendar::AFewDaysofWeek; + int yoffset = qFloor(y / (rect.height() / DDEMonthCalendar::LinesNumofMonth)) % DDEMonthCalendar::LinesNumofMonth; + + return QDateTime(m_DayItem[xoffset+yoffset*7]->getDate(), + QTime(0,0,0)); +} + +void CMonthGraphiview::upDateInfoShow(const CMonthGraphiview::DragStatus &status, const ScheduleDtailInfo &info) +{ + switch (status) { + case NONE: + Q_UNUSED(info); + break; + case ChangeBegin: + case ChangeEnd: { + m_MonthSchceduleView->changeDate(info); + } + break; + case ChangeWhole: { + } + break; + case IsCreate: + m_MonthSchceduleView->updateDate(info); + break; + } +} + +void CMonthGraphiview::updateScheduleInfo(const ScheduleDtailInfo &info) +{ + if (info.rpeat >0) { + CSchceduleDlg::ChangeRecurInfo(this,info, + m_PressScheduleInfo,m_themetype); + } else { + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo( + info); + } +} + +void CMonthGraphiview::DeleteItem(const ScheduleDtailInfo &info) +{ + emit signalViewtransparentFrame(1); + + if (info.rpeat == 0) { + CSchceduleCtrlDlg msgBox(this); + msgBox.setText(tr("You are deleting an event.")); + msgBox.setInformativeText(tr("Are you sure you want to delete this event?")); + msgBox.addPushButton(tr("Cancel"), true); + msgBox.addWaringButton(tr("Delete"), true); + msgBox.exec(); + + if (msgBox.clickButton() == 0) { + emit signalViewtransparentFrame(0); + return; + } else if (msgBox.clickButton() == 1) { + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->deleteScheduleInfoById(info.id); + } + } else { + if (info.RecurID == 0) { + CSchceduleCtrlDlg msgBox(this); + msgBox.setText(tr("You are deleting an event.")); + msgBox.setInformativeText(tr("Do you want to delete all occurrences of this event, or only the selected occurrence?")); + msgBox.addPushButton(tr("Cancel")); + msgBox.addPushButton(tr("Delete All")); + msgBox.addWaringButton(tr("Delete Only This Event")); + msgBox.exec(); + + if (msgBox.clickButton() == 0) { + emit signalViewtransparentFrame(0); + return; + } else if (msgBox.clickButton() == 1) { + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->deleteScheduleInfoById(info.id); + } else if (msgBox.clickButton() == 2) { + + ScheduleDtailInfo newschedule; + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->getScheduleInfoById(info.id, newschedule); + newschedule.ignore.append(info.beginDateTime); + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo(newschedule); + } + } else { + CSchceduleCtrlDlg msgBox(this); + msgBox.setText(tr("You are deleting an event.")); + msgBox.setInformativeText(tr("Do you want to delete this and all future occurrences of this event, or only the selected occurrence?")); + msgBox.addPushButton(tr("Cancel")); + msgBox.addPushButton(tr("Delete All Future Events")); + msgBox.addWaringButton(tr("Delete Only This Event")); + msgBox.exec(); + + if (msgBox.clickButton() == 0) { + emit signalViewtransparentFrame(0); + return; + } else if (msgBox.clickButton() == 1) { + ScheduleDtailInfo newschedule; + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->getScheduleInfoById(info.id, newschedule); + newschedule.enddata.type = 2; + newschedule.enddata.date = info.beginDateTime.addDays(-1); + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo(newschedule); + + } else if (msgBox.clickButton() == 2) { + ScheduleDtailInfo newschedule; + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->getScheduleInfoById(info.id, newschedule); + newschedule.ignore.append(info.beginDateTime); + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo(newschedule); + } + } + } + emit signalsUpdateShcedule(); + emit signalViewtransparentFrame(0); +} + +void CMonthGraphiview::setPressSelectInfo(const ScheduleDtailInfo &info) +{ + CScheduleDataManage::getScheduleDataManage()->setPressSelectInfo(info); +} + +void CMonthGraphiview::mouseDoubleClickEvent(QMouseEvent *event) +{ + if (event->button() != Qt::LeftButton) { + return; + } + + QGraphicsItem *listItem =itemAt(event->pos()); + CMonthSchceduleNumButton *item = dynamic_cast(listItem); + + if (item!= nullptr) { + //双击切换视图 + if (item->getDate().year() > DDECalendar::QueryEarliestYear) { + emit signalsViewSelectDate(item->getDate()); + } + return; + } + + CMonthSchceduleWidgetItem *infoitem = dynamic_cast(listItem); + + if (infoitem != nullptr) { + CMySchceduleView dlg(infoitem->getData(), this); + connect(&dlg, &CMySchceduleView::signalsEditorDelete, this, &CMonthGraphiview::signalsUpdateShcedule); + connect(&dlg, &CMySchceduleView::signalViewtransparentFrame, + this, &CMonthGraphiview::signalViewtransparentFrame); + dlg.exec(); + return; + } + + CDayGraphicsItem *Dayitem = dynamic_cast(listItem); + + if (Dayitem !=nullptr) { + QPointF point = getItemPos(event->pos(),Dayitem->rect()); + if (point.y()<38) { + //双击切换视图 + if (Dayitem->getDate().year() > DDECalendar::QueryEarliestYear) { + emit signalsViewSelectDate(Dayitem->getDate()); + } + } else { + //双击新建日程 + slotCreate(QDateTime(Dayitem->getDate(),QTime(0,0,0))); + } + } +} + +void CMonthGraphiview::resizeEvent(QResizeEvent *event) +{ + Q_UNUSED(event); + updateSize(); + updateInfo(); +} +void CMonthGraphiview::changeEvent(QEvent *event) +{ + if (event->type() ==QEvent::FontChange) { + emit signalFontChange(); + } +} + +void CMonthGraphiview::wheelEvent(QWheelEvent *e) +{ + Q_UNUSED(e); +} + +void CMonthGraphiview::setDragPixmap(QDrag *drag, DragInfoItem *item) +{ + CMonthSchceduleWidgetItem *infoitem = dynamic_cast(item); + drag->setPixmap(infoitem->getPixmap()); +} + +bool CMonthGraphiview::MeetCreationConditions(const QDateTime &date) +{ + return qAbs(date.daysTo(m_PressDate)<43); +} + +bool CMonthGraphiview::IsEqualtime(const QDateTime &timeFirst, const QDateTime &timeSecond) +{ + return timeFirst.date()==timeSecond.date(); +} + +bool CMonthGraphiview::JudgeIsCreate(const QPointF &pos) +{ + return qAbs(pos.x()-m_PressPos.x())>20 ||qAbs(m_PressDate.daysTo(getPosDate(pos.toPoint())))>0; +} + +void CMonthGraphiview::RightClickToCreate(QGraphicsItem *listItem,const QPoint &pos) +{ + Q_UNUSED(pos); + CDayGraphicsItem *Dayitem = dynamic_cast(listItem); + + if (Dayitem != nullptr) { + m_rightMenu->clear(); + m_rightMenu->addAction(m_createAction); + m_createDate.setDate(Dayitem->getDate()); + m_rightMenu->exec(QCursor::pos()); + } +} + +void CMonthGraphiview::MoveInfoProcess(ScheduleDtailInfo &info, const QPointF &pos) +{ + qint64 offset = m_PressDate.daysTo(m_MoveDate); + info.beginDateTime = info.beginDateTime.addDays(offset); + info.endDateTime = info.endDateTime.addDays(offset); + qreal y = 0; + QRectF rect = this->sceneRect(); + + if (pos.y()<0) { + y =0; + } else if (pos.y()>rect.height()) { + y = rect.height(); + } else { + y = pos.y(); + } + + int yoffset = qFloor(y / (rect.height() / DDEMonthCalendar::LinesNumofMonth)) % DDEMonthCalendar::LinesNumofMonth; + info.IsMoveInfo = true; + m_MonthSchceduleView->updateDate(yoffset,info); +} + +QDateTime CMonthGraphiview::getDragScheduleInfoBeginTime(const QDateTime &moveDateTime) +{ + return moveDateTime.daysTo(m_InfoEndTime)<0 ? + QDateTime(m_InfoEndTime.date(),m_InfoBeginTime.time()): + QDateTime(moveDateTime.date(),m_InfoBeginTime.time()); +} + +QDateTime CMonthGraphiview::getDragScheduleInfoEndTime(const QDateTime &moveDateTime) +{ + return m_InfoBeginTime.daysTo(moveDateTime)<0 ? + QDateTime(m_InfoBeginTime.date(),m_InfoEndTime.time()): + QDateTime(moveDateTime.date(),m_InfoEndTime.time()); +} + +void CMonthGraphiview::slotCreate(const QDateTime &date) +{ + emit signalViewtransparentFrame(1); + CSchceduleDlg dlg(1, this); + QDateTime tDatatime; + tDatatime.setDate(date.date()); + + if (date.date() == QDate::currentDate()) { + tDatatime.setTime(QTime::currentTime()); + } else { + tDatatime.setTime(QTime(8, 0)); + } + + dlg.setDate(tDatatime); + dlg.setAllDay(true); + + if (dlg.exec() == DDialog::Accepted) { + emit signalsUpdateShcedule(); + emit signalsSchceduleUpdate(0); + } + emit signalViewtransparentFrame(0); +} + + +void CMonthGraphiview::slotdelete(const int id) +{ + Q_UNUSED(id); + emit signalsSchceduleUpdate(0); +} + +void CMonthGraphiview::slotDeleteItem() +{ + if (CScheduleDataManage::getScheduleDataManage()->getPressSelectInfo().type.ID <0) { + return; + } + + if (CScheduleDataManage::getScheduleDataManage()->getPressSelectInfo().type.ID != DDECalendar::FestivalTypeID) { + DeleteItem(CScheduleDataManage::getScheduleDataManage()->getPressSelectInfo()); + } + + CScheduleDataManage::getScheduleDataManage()->setPressSelectInfo(ScheduleDtailInfo()); +} + +CDayGraphicsItem::CDayGraphicsItem(QGraphicsItem *parent) + : QGraphicsRectItem(parent) + , m_Date(QDate::currentDate()) + , m_DayLunar("") + , m_DayStatus(H_NONE) +{ + m_dayNumFont.setPixelSize(DDECalendar::FontSizeTwentyfour); + m_dayNumFont.setWeight(QFont::Light); + + m_LunerFont.setPixelSize(DDECalendar::FontSizeTwelve); + m_LunerFont.setWeight(QFont::Normal); +} + +CDayGraphicsItem::~CDayGraphicsItem() +{ + +} + +void CDayGraphicsItem::setData(const QDate &date) +{ + m_Date = date; + setLunar(""); +} + +void CDayGraphicsItem::setLunar(const QString &lunar) +{ + m_DayLunar = lunar; +} + +void CDayGraphicsItem::setStatus(const CDayGraphicsItem::HolidayStatus &status) +{ + m_DayStatus = status; +} + +void CDayGraphicsItem::setTheMe(int type) +{ + m_themetype = type; + + if (type == 0 || type == 1) { + m_dayNumColor = "#000000"; + m_dayNumCurrentColor = "#FFFFFF"; + + m_LunerColor = "#5E5E5E"; + m_LunerColor.setAlphaF(0.5); + + m_fillColor = Qt::white; + m_banColor = "#FF7171"; + m_banColor.setAlphaF(0.1); + m_xiuColor = "#ADFF71"; + m_xiuColor.setAlphaF(0.1); + + m_BorderColor = "#000000"; + m_BorderColor.setAlphaF(0.05); + } else if (type == 2) { + m_dayNumColor = "#C0C6D4"; + m_dayNumCurrentColor = "#B8D3FF"; + + m_LunerColor = "#ABDAFF"; + m_LunerColor.setAlphaF(0.5); + + m_fillColor = "#000000"; + m_fillColor.setAlphaF(0.05); + m_banColor = "#FF7171"; + m_banColor.setAlphaF(0.1); + m_xiuColor = "#ADFF71"; + m_xiuColor.setAlphaF(0.1); + + m_BorderColor = "#000000"; + m_BorderColor.setAlphaF(0.05); + } + update(); +} + +void CDayGraphicsItem::setitemnum(int num) +{ + m_itemnum = num; +} + +void CDayGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + Q_UNUSED(option); + Q_UNUSED(widget); + const int hh = 36; + m_currentColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); + painter->setRenderHints(QPainter::Antialiasing); + //绘制背景 + if (m_LunarVisible) { + switch (m_DayStatus) { + case H_WORK: + painter->setBrush(QBrush(m_banColor)); + break; + case H_REST: + painter->setBrush(QBrush(m_xiuColor)); + break; + default: + painter->setBrush(QBrush(m_fillColor)); + break; + } + } else { + painter->setBrush(QBrush(m_fillColor)); + } + + if (!m_IsCurrentMonth) { + painter->setOpacity(0.4); + } + QPen pen; + pen.setWidth(1); + pen.setColor(m_BorderColor); + painter->setPen(pen); + + if (m_itemnum == 35) { + QPainterPath painterpath; + painterpath.moveTo(0, this->rect().y()); + painterpath.lineTo(0, this->rect().y() + this->rect().height() - m_radius); + painterpath.arcTo(QRectF(0, + this->rect().y() + this->rect().height() - m_radius * 2, + m_radius * 2, + m_radius * 2), + 180, 90); + painterpath.lineTo(this->rect().width(), this->rect().y() + this->rect().height()); + painterpath.lineTo(this->rect().width(), this->rect().y()); + painterpath.lineTo(0, this->rect().y()); + painter->drawPath(painterpath); + } else if (m_itemnum == 41) { + QPainterPath painterpath; + painterpath.moveTo(this->rect().x(), this->rect().y()); + painterpath.lineTo(this->rect().x(), this->rect().y() + this->rect().height()); + painterpath.lineTo(this->rect().x() + this->rect().width() - m_radius, this->rect().y() + this->rect().height()); + painterpath.arcTo(QRectF(this->rect().x() + this->rect().width() - m_radius * 2, + this->rect().y() + this->rect().height() - m_radius * 2, + m_radius * 2, + m_radius * 2), + 270, 90); + painterpath.lineTo(this->rect().x() + this->rect().width(), this->rect().y()); + painterpath.lineTo(this->rect().y() + this->rect().height(), this->rect().y()); + painter->drawPath(painterpath); + } else { + painter->drawRect(this->rect()); + } + + painter->save(); + painter->restore(); + //绘制日期 + painter->setFont(m_dayNumFont); + QRectF fillRect; + + if (m_LunarVisible) { + fillRect.setRect(this->rect().x()+3,this->rect().y()+4, hh, hh); + } else { + fillRect.setRect(this->rect().x(),this->rect().y()+4, this->rect().width(), hh); + } + + if (m_Date ==QDate::currentDate()) { + QFont tfont = m_dayNumFont; + tfont.setPixelSize(DDECalendar::FontSizeTwenty); + painter->setFont(tfont); + painter->setPen(m_dayNumCurrentColor); + + painter->save(); + painter->setRenderHint(QPainter::Antialiasing); + painter->setBrush(QBrush(m_currentColor)); + painter->setPen(Qt::NoPen); + if (m_LunarVisible) + painter->drawEllipse(QRectF(this->rect().x() + 6, this->rect().y() + 4, hh - 8, hh - 8)); + else + painter->drawEllipse(QRectF((this->rect().width() - hh + 8) / 2 + this->rect().x(), this->rect().y() + 4, hh - 8, hh - 8)); + painter->restore(); + } else { + painter->setPen(m_dayNumColor); + } + + fillRect.setY(fillRect.y()-10); + fillRect.setX(fillRect.x()-1); + painter->drawText(fillRect, + Qt::AlignCenter, + QString::number(m_Date.day())); + + painter->save(); + painter->restore(); + //绘制农历 + if (m_LunarVisible) { + QFontMetrics metrics(m_LunerFont); + int Lunarwidth = metrics.width(m_DayLunar); + qreal filleRectX = this->rect().width()-12-3-(58 +Lunarwidth)/2; + QRectF fillRect(this->rect().x()+filleRectX, + this->rect().y()+9, + 12, + 12); + + if (filleRectX>hh) { + painter->setRenderHint(QPainter::Antialiasing); + painter->setRenderHint(QPainter::HighQualityAntialiasing); + painter->setRenderHint(QPainter::SmoothPixmapTransform); + switch (m_DayStatus) { + case H_WORK: { + QPixmap pixmap = DHiDPIHelper::loadNxPixmap(":/resources/icon/ban.svg"); + painter->drawPixmap(fillRect.toRect(), pixmap); + } + break; + case H_REST: { + QPixmap pixmap = DHiDPIHelper::loadNxPixmap(":/resources/icon/xiu.svg"); + painter->drawPixmap(fillRect.toRect(), pixmap); + } + break; + default: + break; + } + } + painter->setFont(m_LunerFont); + painter->setPen(m_LunerColor); + painter->drawText(QRectF(this->rect().x()+this->rect().width() - 58, + this->rect().y()+6, 58, 18), Qt::AlignCenter, m_DayLunar); + } +} diff -Nru dde-calendar-5.7.0.4/src/view/monthgraphiview.h dde-calendar-5.7.0.23/src/view/monthgraphiview.h --- dde-calendar-5.7.0.4/src/view/monthgraphiview.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/view/monthgraphiview.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,150 @@ +/* +* Copyright (C) 2019 ~ 2020 Uniontech Software Technology Co.,Ltd. +* +* Author: uniontech +* +* Maintainer: uniontech +* +* 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 +* 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 . +*/ +#ifndef MONTHGRAPHIVIEW_H +#define MONTHGRAPHIVIEW_H +#include "calendardbus.h" +#include "schedulestructs.h" +#include "draginfographicsview.h" + +#include +#include + +#include +#include +#include +#include + +#include + +DWIDGET_USE_NAMESPACE + +class CDayGraphicsItem; +class CMonthSchceduleWidgetItem; +class CMonthSchceduleView; + +class CMonthGraphiview : public DragInfoGraphicsView +{ + Q_OBJECT +public: + explicit CMonthGraphiview(QWidget *parent = nullptr); + ~CMonthGraphiview() override; + void setTheMe(int type = 0) override; +public: + void setDate(const QDate date[42]); + void setFestivalInfo(const QVector &info) + { + m_festivallist = info; + } + void setLunarInfo(QMap *lunarCache); + void setLunarVisible(bool visible); + void setScheduleInfo(const QVector &info); + void setSelectSchedule(const ScheduleDtailInfo &scheduleInfo); +private: + void updateSize(); + void updateLunar(); + void updateInfo(); + char getFestivalInfoByDate(const QDate &date); + QPointF getItemPos(const QPoint &p, const QRectF &itemRect); + void updateScheduleInfo(const ScheduleDtailInfo &info); + void DeleteItem(const ScheduleDtailInfo &info); + void setPressSelectInfo(const ScheduleDtailInfo &info); +protected: + void mouseDoubleClickEvent(QMouseEvent *event) override; + void resizeEvent(QResizeEvent *event) override; + void changeEvent(QEvent *event) override; + void wheelEvent(QWheelEvent *) override; +private: + void setDragPixmap(QDrag *drag,DragInfoItem *item) override; + bool MeetCreationConditions(const QDateTime &date) override; + //判断时间是否相等 + bool IsEqualtime(const QDateTime &timeFirst,const QDateTime &timeSecond) override; + //根据鼠标移动的距离判断是否创建日程 + bool JudgeIsCreate(const QPointF &pos) override; + void RightClickToCreate(QGraphicsItem *listItem,const QPoint &pos) override; + void MoveInfoProcess(ScheduleDtailInfo &info,const QPointF &pos) override; + QDateTime getDragScheduleInfoBeginTime(const QDateTime &moveDateTime) override; + QDateTime getDragScheduleInfoEndTime(const QDateTime &moveDateTime) override; + PosInItem getPosInItem(const QPoint &p,const QRectF &itemRect)override; + QDateTime getPosDate(const QPoint &p)override; + void upDateInfoShow(const DragStatus &status = NONE,const ScheduleDtailInfo &info =ScheduleDtailInfo())override; +signals: + void signalFontChange(); + void signalsViewSelectDate(QDate date); + void signalsSchceduleUpdate(const int id = 0); +public slots: + void slotCreate(const QDateTime &date) override; + void slotdelete(const int id =0); + void slotDeleteItem(); +private: + QVector m_DayItem; + QMap *m_lunarCache = nullptr; + QVector m_festivallist; + int m_currentMonth; + CMonthSchceduleView *m_MonthSchceduleView = nullptr; + QVector m_shceludelistdata; +}; + +class CDayGraphicsItem :public QObject, public QGraphicsRectItem +{ + Q_OBJECT +public: + enum HolidayStatus {H_NONE = 0x00,H_REST = 0x01,H_WORK = 0x02}; + explicit CDayGraphicsItem( QGraphicsItem *parent = nullptr); + ~CDayGraphicsItem() override; + void setData(const QDate &date); + void setLunar(const QString &lunar); + void setStatus(const HolidayStatus &status); + void setCurrentMonth(bool isCurrent) + { + m_IsCurrentMonth = isCurrent; + } + void setTheMe(int type = 0); + QDate getDate()const + { + return m_Date; + } + void setitemnum(int num); +protected: + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override; +private: + QDate m_Date; + QString m_DayLunar; + HolidayStatus m_DayStatus; + QFont m_dayNumFont; + QColor m_dayNumColor; + QColor m_dayNumCurrentColor; + QFont m_LunerFont; + QColor m_LunerColor; + QColor m_BorderColor; + bool m_IsCurrentMonth = false; + QColor m_fillColor = Qt::white; + QColor m_banColor = "#FBE9B7"; + QColor m_xiuColor = "#D4FFB3"; + int m_themetype = 0; + QColor m_currentColor; + int m_itemnum = 0; + const int m_radius = 18; + +public: + static bool m_LunarVisible; +}; + +#endif // MONTHGRAPHIVIEW_H diff -Nru dde-calendar-5.7.0.4/src/view/scheduleitem.cpp dde-calendar-5.7.0.23/src/view/scheduleitem.cpp --- dde-calendar-5.7.0.4/src/view/scheduleitem.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/view/scheduleitem.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,300 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#include "scheduleitem.h" +#include "schedulecoormanage.h" +#include "scheduledatamanage.h" +#include "SchecduleRemindWidget.h" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +DWIDGET_USE_NAMESPACE + +CScheduleItem::CScheduleItem(QRectF rect, QGraphicsItem *parent, int type) + : DragInfoItem (rect,parent) + , m_type(type) +{ + m_transparentcolor = "#000000"; + m_transparentcolor.setAlphaF(0.05); +} + +CScheduleItem::~CScheduleItem() {} + +void CScheduleItem::setData(const ScheduleDtailInfo &info, QDate date, int totalNum) +{ + m_vScheduleInfo = info; + m_totalNum = totalNum; + m_date = date; + update(); +} + +bool CScheduleItem::hasSelectSchedule(const ScheduleDtailInfo &info) +{ + return info == m_vScheduleInfo; +} + +void CScheduleItem::splitText(QFont font, int w, int h, QString str, QStringList &liststr, QFontMetrics &fontm) +{ + if (str.isEmpty()) + return; + QFontMetrics fontmetris(font); + int heightT = fontm.height(); + QString tstr; + QStringList tliststr; + + for (int i = 0; i < str.count(); i++) { + tstr.append(str.at(i)); + int widthT = fontmetris.width(tstr) + 5; + + if (widthT >= w) { + tstr.chop(1); + if (tstr.isEmpty()) + break; + tliststr.append(tstr); + tstr.clear(); + i--; + } + } + tliststr.append(tstr); + + if (w < 30) { + QFontMetrics fm_s(fontm); + QFontMetrics f_st(font); + QString s = tliststr.at(0) + "..."; + + if (h < 23) { + tliststr.append(""); + } else { + if (tliststr.isEmpty()) { + liststr.append(""); + } else { + QString c = str.at(0); + QString s = c + "..."; + QFontMetrics fm(font); + while (f_st.width(s) > w && f_st.width(s) >24) { + s.chop(1); + } + liststr.append(s); + } + } + } else { + for (int i = 0; i < tliststr.count(); i++) { + if ((i + 1) * heightT <= h - 1) { + liststr.append(tliststr.at(i)); + } else { + if (i == 0) { + break; + } else { + QString s; + QFontMetrics fm_str(fontm); + + if (i == tliststr.count()) + s = fontm.elidedText(tliststr.at(i - 1), Qt::ElideRight, w); + else { + s = fontm.elidedText(tliststr.at(i - 1) + "...", Qt::ElideRight, w); + } + liststr.removeAt(i - 1); + liststr.append(s); + break; + } + } + } + } +} + +void CScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, const int isPixMap) +{ + Q_UNUSED(isPixMap); + CSchedulesColor gdcolor = CScheduleDataManage::getScheduleDataManage()->getScheduleColorByType( + m_vScheduleInfo.type.ID); + m_vHighflag = CScheduleDataManage::getScheduleDataManage()->getSearchResult(m_vScheduleInfo); + + if (CScheduleDataManage::getScheduleDataManage()->getPressSelectInfo() == m_vScheduleInfo ) { + if (m_vScheduleInfo.IsMoveInfo == + CScheduleDataManage::getScheduleDataManage()->getPressSelectInfo().IsMoveInfo) { + m_vHighflag = true; + } else { + painter->setOpacity(0.4); + gdcolor.textColor.setAlphaF(0.4); + gdcolor.timeColor.setAlphaF(0.4); + } + m_vSelectflag = m_press; + } + + int themetype = CScheduleDataManage::getScheduleDataManage()->getTheme(); + QColor bcolor = gdcolor.Purecolor; + QFontMetrics fm = painter->fontMetrics(); + int h = fm.height(); + + if (m_vHoverflag) { + bcolor = gdcolor.hoverPurecolor; + } else if (m_vHighflag) { + bcolor = gdcolor.hightlightPurecolor; + } + if (m_vSelectflag) { + bcolor = gdcolor.pressPurecolor; + } + painter->setBrush(bcolor); + painter->setPen(Qt::NoPen); + painter->drawRect(rect); + + if (m_vHoverflag && !m_vSelectflag) { + painter->save(); + QRectF trect = QRectF(rect.x() + 0.5, rect.y() + 0.5, rect.width() - 1, rect.height() - 1); + QPen tpen; + QColor cc = "#FFFFFF"; + if (themetype == 2) { + cc = "#FFFFFF"; + } else { + cc = "#000000"; + } + cc.setAlphaF(0.08); + tpen.setColor(cc); + tpen.setWidthF(1); + tpen.setStyle(Qt::SolidLine); + painter->setBrush(Qt::NoBrush); + painter->setPen(tpen); + painter->drawRect(trect); + painter->restore(); + } + if (m_vSelectflag) { + if (themetype == 0 || themetype ==1) { + gdcolor.textColor.setAlphaF(0.4); + gdcolor.timeColor.setAlphaF(0.4); + } else if (themetype ==2) { + gdcolor.textColor.setAlphaF(0.6); + gdcolor.timeColor.setAlphaF(0.6); + } + } + + painter->save(); + QPen pen(gdcolor.shadowcolor); + pen.setWidth(2); + painter->setPen(pen); + painter->drawLine(rect.topLeft(), rect.bottomLeft()); + painter->restore(); + int tmagin = 10; + + if (m_totalNum > 1) + tmagin = 5; + + if (m_type == 0) { + int timeTextHight = 0; + QFont font; + font.setWeight(QFont::Normal); + + font = DFontSizeManager::instance()->get(DFontSizeManager::T8, font); + + //绘制日程起始时间 + if (m_vScheduleInfo.beginDateTime.date() == m_date) { + painter->save(); + painter->setFont(font); + painter->setPen(gdcolor.timeColor); + + QTime stime = m_vScheduleInfo.beginDateTime.time(); + QString str = stime.toString("AP h:mm"); + QFontMetrics fontmetris(font); + qreal drawTextWidth = rect.width() - m_offset*2; + + if (fm.width(str) > drawTextWidth -5) { + QString tstr; + for (int i = 0; i < str.count(); i++) { + tstr.append(str.at(i)); + int widthT = fm.width(tstr) - 5; + + if (widthT >= drawTextWidth) { + if (i < 1) { + tstr.chop(1); + } else { + tstr.chop(2); + } + tstr = tstr + "..."; + break; + } + } + QString tstrs = fontmetris.elidedText(str,Qt::ElideRight,qRound(drawTextWidth - 5)); + painter->drawText( + QRectF(rect.topLeft().x() + tmagin, rect.topLeft().y() + 3, drawTextWidth- 5, h), + Qt::AlignLeft, tstrs); + + } else { + painter->drawText( + QRectF(rect.topLeft().x() + tmagin, rect.topLeft().y() + 3, drawTextWidth - 5, h), + Qt::AlignLeft, str); + } + painter->restore(); + } else { + timeTextHight = -20; + } + painter->save(); + + //绘制日程标题 + font = DFontSizeManager::instance()->get(DFontSizeManager::T6, font); + font.setLetterSpacing(QFont::PercentageSpacing, 105); + painter->setFont(font); + painter->setPen(gdcolor.textColor); + QStringList liststr; + QRect textRect = rect.toRect(); + textRect.setWidth(textRect.width() -m_offset*2); + splitText(font, + textRect.width() - tmagin - 8, + textRect.height() - 20, + m_vScheduleInfo.titleName, + liststr, fm); + + for (int i = 0; i < liststr.count(); i++) { + if ((20 + timeTextHight + (i + 1) * (h - 3)) > rect.height()) + return; + painter->drawText( + QRect(textRect.topLeft().x() + tmagin, + textRect.topLeft().y() + 20 + timeTextHight + i * (h - 3), + textRect.width() - 2, + h ), + Qt::AlignLeft, liststr.at(i)); + } + painter->restore(); + } else { + painter->save(); + QFont font; + font.setWeight(QFont::Normal); + font = DFontSizeManager::instance()->get(DFontSizeManager::T8, font); + painter->setFont(font); + painter->setPen(gdcolor.textColor); + painter->drawText(rect, Qt::AlignCenter | Qt::AlignVCenter, "..."); + painter->restore(); + } + if (m_vSelectflag) { + QColor selcolor = m_transparentcolor; + selcolor.setAlphaF(0.05); + painter->setBrush(selcolor); + painter->setPen(Qt::NoPen); + painter->drawRect(rect); + } + +} diff -Nru dde-calendar-5.7.0.4/src/view/scheduleitem.h dde-calendar-5.7.0.23/src/view/scheduleitem.h --- dde-calendar-5.7.0.4/src/view/scheduleitem.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/view/scheduleitem.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#ifndef SCHEDULEITEM_H +#define SCHEDULEITEM_H + +#include "schedulestructs.h" +#include "draginfoitem.h" + +#include +#include +#include +#include + +class CScheduleCoorManage; +class CScheduleItem : public DragInfoItem +{ + Q_OBJECT +public: + CScheduleItem(QRectF rect,QGraphicsItem *parent = nullptr, int type = 0); + ~CScheduleItem() override; + void setData(const ScheduleDtailInfo &info, QDate date, int totalNum); + bool hasSelectSchedule(const ScheduleDtailInfo &info); + int getType() + { + return m_type; + } + ScheduleDtailInfo getData() const + { + return m_vScheduleInfo; + } + QDate getdate()const + { + return m_date; + } +private: + void splitText(QFont font, int w, int h, QString str, QStringList &liststr, QFontMetrics &fontm); +private: + void paintBackground(QPainter *painter,const QRectF &rect,const int isPixMap = false) override; +private: + QDate m_date; + int m_type = 0; + int m_totalNum; + QColor m_transparentcolor; + +}; + +#endif // SCHEDULEITEM_H diff -Nru dde-calendar-5.7.0.4/src/weekheadview.cpp dde-calendar-5.7.0.23/src/weekheadview.cpp --- dde-calendar-5.7.0.4/src/weekheadview.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/weekheadview.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,693 +0,0 @@ -/* - * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ - -#include "weekheadview.h" -#include "calendardbus.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "customframe.h" -#include "scheduledatamanage.h" -DGUI_USE_NAMESPACE -CWeekHeadView::CWeekHeadView(QWidget *parent) : DFrame(parent) -{ - setContentsMargins(0, 0, 0, 0); - m_DBusInter = new CalendarDBus("com.deepin.api.LunarCalendar", - "/com/deepin/api/LunarCalendar", - QDBusConnection::sessionBus(), this); - if (!queue) - queue = new QQueue; - if (!lunarCache) - lunarCache = new QMap; - if (!emptyCaLunarDayInfo) - emptyCaLunarDayInfo = new CaLunarDayInfo; - -// m_dayNumFont.setFamily("SourceHanSansSC"); - m_dayNumFont.setWeight(QFont::Medium); - m_dayNumFont.setPixelSize(16); -// m_monthFont.setFamily("SourceHanSansSC"); - m_monthFont.setWeight(QFont::Medium); - m_monthFont.setPixelSize(20); - - // cells grid - QHBoxLayout *hboxLayout = new QHBoxLayout; - hboxLayout->setMargin(0); - hboxLayout->setSpacing(0); - - m_monthLabel = new CustomFrame(this); - m_monthLabel->setFixedWidth(DDEWeekCalendar::WMCellHeadrWidth - 5); - m_monthLabel->setRoundState(true, false, false, false); - QFont mlabelF; -// mlabelF.setFamily("SourceHanSansSC"); - mlabelF.setWeight(QFont::Medium); - mlabelF.setPixelSize(20); - m_monthLabel->setTextFont(mlabelF); - hboxLayout->addWidget(m_monthLabel); - hboxLayout->setStretch(0, 0); - hboxLayout->setSpacing(0); - for (int c = 0; c != 7; ++c) { - QWidget *cell = new QWidget(this); - cell->installEventFilter(this); - cell->setFocusPolicy(Qt::ClickFocus); - hboxLayout->addWidget(cell); - m_cellList.append(cell); - } - - setLayout(hboxLayout); - - connect(this, &CWeekHeadView::dateSelected, this, &CWeekHeadView::handleCurrentDateChanged); - setFrameRounded(true); - m_monthList.append( "一月" ); - m_monthList.append( "二月"); - m_monthList.append( "三月" ); - m_monthList.append( "四月" ); - m_monthList.append( "五月" ); - m_monthList.append( "六月" ); - m_monthList.append( "七月" ); - m_monthList.append( "八月"); - m_monthList.append( "九月" ); - m_monthList.append( "十月" ); - m_monthList.append( "十一月"); - m_monthList.append( "十二月"); -} - -CWeekHeadView::~CWeekHeadView() -{ - - if (lunarCache !=nullptr) { - delete lunarCache; - lunarCache = nullptr; - } - if (emptyCaLunarDayInfo != nullptr) { - delete emptyCaLunarDayInfo; - emptyCaLunarDayInfo = nullptr; - } - if (queue != nullptr) { - delete queue; - queue = nullptr; - } -} - -void CWeekHeadView::handleCurrentDateChanged(const QDate date, const CaLunarDayInfo &detail) -{ - Q_UNUSED(detail); - - if (date != m_currentDate) { - setCurrentDate(date); - } -} - -void CWeekHeadView::setFirstWeekday(int weekday) -{ - m_firstWeekDay = weekday; - updateDate(); -} - -int CWeekHeadView::getDateType(const QDate &date) -{ - const int currentIndex = getDateIndex(date); - const CaLunarDayInfo info = getCaLunarDayInfo(currentIndex); - - const int dayOfWeek = date.dayOfWeek(); - bool weekends = dayOfWeek == 6 || dayOfWeek == 7; - bool isCurrentMonth = m_currentDate.month() == date.month(); - bool isFestival = !info.mSolarFestival.isEmpty() || !info.mLunarFestival.isEmpty(); - - int resultFlag = 0; - if (!isCurrentMonth) - resultFlag |= SO_MNotCurrentMonth; - if (isFestival) - resultFlag |= SO_MFestival; - if (weekends) - resultFlag |= SO_MWeekends; - - return resultFlag; -} - -void CWeekHeadView::setTheMe(int type) -{ - m_themetype = type; - if (type == 0 || type == 1) { - - // DPalette monthpa = m_monthLabel->palette(); - QColor textC = "#000000"; - QColor textbC(230, 238, 242); - // monthpa.setColor(DPalette::WindowText, textC); - //monthpa.setColor(DPalette::Background, textbC); - // m_monthLabel->setPalette(monthpa); - // m_monthLabel->setForegroundRole(DPalette::WindowText); - //m_monthLabel->setBackgroundRole(DPalette::Background); - - m_monthLabel->setBColor(textbC); - m_monthLabel->setTextColor(textC); - - m_backgroundCircleColor = "#0081FF"; - m_backgroundShowColor = "#2CA7F8"; - m_backgroundShowColor.setAlphaF(0.4); - - m_defaultTextColor = "#6F6F6F"; - m_currentDayTextColor = "#FFFFFF"; - m_defaultLunarColor = "#898989"; -// m_weekendsTextColor = "#0887FF"; - m_weekendsTextColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); - m_currentMonthColor = "#000000"; - m_backgroudColor = "#E6EEF2"; - m_solofestivalLunarColor = "#4DFF7272"; - - - } else if (type == 2) { - - //DPalette monthpa = m_monthLabel->palette(); - QColor textbC = "#82AEC1"; - textbC.setAlphaF(0.1); - //monthpa.setColor(DPalette::WindowText, "#BF1D63"); - // monthpa.setColor(DPalette::Background, textbC); - //m_monthLabel->setPalette(monthpa); - //m_monthLabel->setForegroundRole(DPalette::WindowText); - //m_monthLabel->setBackgroundRole(DPalette::Background); - m_monthLabel->setBColor(textbC); - m_monthLabel->setTextColor("#BF1D63"); - m_backgroundCircleColor = "#0059D2"; - m_backgroundShowColor = "#002AAF"; - m_backgroundShowColor.setAlphaF(0.4); - - m_defaultTextColor = "#C0C6D4"; - m_currentDayTextColor = "#C0C6D4"; - m_defaultLunarColor = "#6886BA"; -// m_weekendsTextColor = "#0887FF"; - m_weekendsTextColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); - m_currentMonthColor = "#000000"; - m_backgroudColor = "#82AEC1"; - m_backgroudColor.setAlphaF(0.1); - m_solofestivalLunarColor = "#4DFF7272"; - } - for (int i = 0; i != 7; ++i) - m_cellList.at(i)->update(); -} - -void CWeekHeadView::setWeekDay(QVector vDays) -{ - if (vDays.count() != 7) return; - for (int i = 0; i != 7; ++i) - m_days[i] = vDays[i]; -} - -void CWeekHeadView::setMounthLabelWidth(int w, int rw) -{ - m_monthW = w + 1; - m_fixwidth = rw; - /* - int mh = height(); - m_monthLabel->setFixedSize(m_monthW, mh); - - int ww = (width() - m_monthW) * 1.0 / 7 + 0.5; - int h = height(); - for (int i(0); i != 7; ++i) { - m_cellList.at(i)->setFixedSize(w, h); - m_cellList.at(i)->update(); - }*/ -} - -void CWeekHeadView::setCurrentDate(const QDate date) -{ - qDebug() << "set current date " << date; - - if (date == m_currentDate) { - return; - } - - //m_selectedCell = 0; - m_currentDate = date; - - - emit signalcurrentDateChanged(m_currentDate); - // to refresh lunar calendar - updateCurrentLunar(getCaLunarDayInfo(getDateIndex(m_currentDate))); - QLocale locale; - //if (locale.language() == QLocale::Chinese) { - // m_monthLabel->setTextStr(m_monthList.at(date.month() - 1)); - //} else { - m_monthLabel->setTextStr(locale.monthName(date.month(), QLocale::ShortFormat)); - // } - //QLocale locale; - //QString monthName(int month, QLocale::FormatType type = LongFormat) -// m_monthLabel->setTextStr(locale.monthName(date.month(), QLocale::ShortFormat)); - //m_monthLabel->setText(QString::number(date.month()) + tr("Mon")); - -} - -void CWeekHeadView::setLunarVisible(bool visible) -{ - int state = int(m_showState); - - if (visible) - state |= ShowLunar; - else - state &= ~ShowLunar; - - m_showState = ShowState(state); - update(); -} - -void CWeekHeadView::setLunarFestivalHighlight(bool highlight) -{ - highlight = true; - int state = int(m_showState); - // - - if (highlight) - state |= ShowLunarFestivalHighlight; - else - state &= ~ShowLunarFestivalHighlight; - - m_showState = ShowState(state); - update(); -} - -void CWeekHeadView::setCellSelectable(bool selectable) -{ - if (selectable == m_cellSelectable) - return; - m_cellSelectable = selectable; - - emit cellSelectableChanged(m_cellSelectable); -} - -int CWeekHeadView::getDateIndex(const QDate &date) const -{ - for (int i = 0; i != 7; ++i) - if (m_days[i] == date) - return i; - - return 0; -} - -bool CWeekHeadView::eventFilter(QObject *o, QEvent *e) -{ - QWidget *cell = qobject_cast(o); - - if (cell && m_cellList.contains(cell)) { - if (e->type() == QEvent::Paint) { - paintCell(cell); - } else if (e->type() == QEvent::MouseButtonPress) { - //cellClicked(cell); - } else if (e->type() == QEvent::MouseButtonDblClick) { - const int pos = m_cellList.indexOf(cell); - emit signalsViewSelectDate(m_days[pos]); - } - } - - return false; -} - -void CWeekHeadView::updateDate() -{ - const int currentIndex = getDateIndex(m_currentDate); - setSelectedCell(currentIndex); - update(); -} - -void CWeekHeadView::updateCurrentLunar(const CaLunarDayInfo &info) -{ - if (!info.mLunarFestival.isEmpty()) { - emit currentFestivalChanged(info.mLunarFestival); - } else if (!info.mTerm.isEmpty()) { - emit currentFestivalChanged(info.mTerm); - } else if (!info.mSolarFestival.isEmpty()) { - QStringList tmpFestival = info.mSolarFestival.split(" "); - - if (tmpFestival.length() >= 3) { - emit currentFestivalChanged(QString("%1 %2").arg(tmpFestival[0]).arg(tmpFestival[1])); - } else { - emit currentFestivalChanged(info.mSolarFestival); - } - } else { - emit currentFestivalChanged(""); - } - QVector vdate; - QVector vdetail; - for (int i = 0; i < 7; i++) { - vdate.append(m_days[i]); - vdetail.append(getCaLunarDayInfo(getDateIndex(m_days[i]))); - } - emit signalcurrentLunarDateChanged(vdate, vdetail, 1); - //emit signalcurrentLunarDateChanged(m_currentDate, getCaLunarDayInfo(getDateIndex(m_currentDate)), 1); - updateDate(); -} - -const QString CWeekHeadView::getCellDayNum(int pos) -{ - //if (m_days[pos].day() == 1) { - // return QString::number(m_days[pos].month()) + "/" + QString::number(m_days[pos].day()); - //} - return QString::number(m_days[pos].day()); -} - -const QDate CWeekHeadView::getCellDate(int pos) -{ - return m_days[pos]; -} - -const QString CWeekHeadView::getLunar(int pos) -{ - CaLunarDayInfo info = getCaLunarDayInfo(pos); - - if (info.mLunarDayName == "初一") { - info.mLunarDayName = info.mLunarMonthName; - } - - if (info.mTerm.isEmpty()) - return info.mLunarDayName; - - return info.mTerm; -} - -const CaLunarDayInfo CWeekHeadView::getCaLunarDayInfo(int pos) -{ - const QDate date = m_days[pos]; - - if (lunarCache->contains(date)) { - return lunarCache->value(date); - } - - if (lunarCache->size() > 300) - lunarCache->clear(); - -// QTimer::singleShot(500, [this, pos] {getDbusData(pos);}); - queue->push_back(pos); - - QTimer::singleShot(300, this, SLOT(getDbusData())); - - return *emptyCaLunarDayInfo; -} - -void CWeekHeadView::getDbusData() -{ - if (queue->isEmpty()) - return; - - const int pos = queue->head(); - queue->pop_front(); - const QDate date = m_days[pos]; - if (!date.isValid()) { - return; - } - - CaLunarDayInfo currentDayInfo; - if (!lunarCache->contains(date)) { - bool o1 = true; - QDBusReply reply = m_DBusInter->GetLunarMonthCalendar(date.year(), date.month(), false, o1); - - QDate cacheDate; - cacheDate.setDate(date.year(), date.month(), 1); - foreach (const CaLunarDayInfo &dayInfo, reply.value().mCaLunarDayInfo) { - lunarCache->insert(cacheDate, dayInfo); - if (date == m_currentDate) { - currentDayInfo = dayInfo; - } - cacheDate = cacheDate.addDays(1); - } - } else { - currentDayInfo = lunarCache->value(date); - } - - m_cellList.at(pos)->update(); - - // refresh lunar info - if (date == m_currentDate) { - updateCurrentLunar(currentDayInfo); - } -} - -void CWeekHeadView::paintCell(QWidget *cell) -{ - m_weekendsTextColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); - - const QRect rect(0, 0, cell->width(), cell->height()); - - const int pos = m_cellList.indexOf(cell); - - const bool isCurrentDay = getCellDate(pos) == QDate::currentDate(); - // const bool isSelectedCell = pos == m_selectedCell; - const bool isSelectedCell = isCurrentDay; - int d = checkDay(pos - m_firstWeekDay); - - - QPainter painter(cell); - painter.setRenderHint(QPainter::Antialiasing); - painter.setPen(Qt::NoPen); - painter.setBrush(QBrush(m_backgroudColor)); - if (d != 6) { - painter.drawRect(rect);//画矩形 - if (d == 6 || d == 7) painter.drawRect(rect); //画矩形 - } else { - int labelwidth = cell->width(); - int labelheight = cell->height(); - painter.save(); - painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; - painter.setBrush(QBrush(m_backgroudColor)); - painter.setPen(Qt::NoPen); - QPainterPath painterPath; - painterPath.moveTo(m_radius, 0); - - painterPath.lineTo(0, 0); - painterPath.lineTo(0, m_radius); - - painterPath.lineTo(0, labelheight - m_radius); - - painterPath.lineTo(0, labelheight); - painterPath.lineTo(m_radius, labelheight); - - painterPath.lineTo(labelwidth - m_radius, labelheight); - - painterPath.lineTo(labelwidth, labelheight); - painterPath.lineTo(labelwidth, labelheight - m_radius); - - painterPath.lineTo(labelwidth, m_radius); - //painterPath.moveTo(labelwidth, m_radius); - painterPath.arcTo(QRect(labelwidth - m_radius * 2, 0, m_radius * 2, m_radius * 2), 0, 90); - painterPath.lineTo(m_radius, 0); - painterPath.closeSubpath(); - painter.drawPath(painterPath); - painter.drawPath(painterPath); - painter.restore(); - } - - //if (m_days[pos].year() < 1900) return; - int bw = (cell->width() - 104) / 2; - int bh = (cell->height() - 26) / 2; - - if (bw < 0) { - bw = 2; - } - if (bh < 0) { - bh = 2; - } - if (isSelectedCell) { - if (m_showState & ShowLunar) { - QRect fillRect(bw - 2, bh, 26, 26); -// QPixmap pixmap; -// if (m_themetype == 2) -// pixmap = DHiDPIHelper::loadNxPixmap(":/resources/icon/darkchoose30X30_checked .svg"); -// else { -// pixmap = DHiDPIHelper::loadNxPixmap(":/resources/icon/choose30X30_checked .svg"); -// } -// pixmap.setDevicePixelRatio(devicePixelRatioF()); -// painter.save(); -// painter.setRenderHint(QPainter::Antialiasing); -// painter.setRenderHint(QPainter::HighQualityAntialiasing); -// painter.setRenderHint(QPainter::SmoothPixmapTransform); -// painter.drawPixmap(fillRect, pixmap); -// painter.restore(); - painter.save(); - painter.setRenderHint(QPainter::Antialiasing); - painter.setBrush(QBrush(CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor())); - painter.setPen(Qt::NoPen); - painter.drawEllipse(fillRect); - painter.restore(); - } else { - QRect fillRect(cell->width() - (cell->width()/2) + 1, bh - 1, 26, 26); -// QPixmap pixmap; -// if (m_themetype == 2) -// pixmap = DHiDPIHelper::loadNxPixmap(":/resources/icon/darkchoose30X30_checked .svg"); -// else { -// pixmap = DHiDPIHelper::loadNxPixmap(":/resources/icon/choose30X30_checked .svg"); -// } -// pixmap.setDevicePixelRatio(devicePixelRatioF()); -// painter.save(); -// painter.setRenderHint(QPainter::Antialiasing); -// painter.setRenderHint(QPainter::HighQualityAntialiasing); -// painter.setRenderHint(QPainter::SmoothPixmapTransform); -// painter.drawPixmap(fillRect, pixmap); -// painter.restore(); - painter.save(); - painter.setRenderHint(QPainter::Antialiasing); - painter.setBrush(QBrush(CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor())); - painter.setPen(Qt::NoPen); - painter.drawEllipse(fillRect); - painter.restore(); - } - - } - QLocale locale; - const QString dayNum = getCellDayNum(pos); - const QString dayLunar = getLunar(pos); - /*const*/ QString dayWeek = locale.dayName(d ? d : 7, QLocale::ShortFormat); - - painter.save(); - painter.setPen(Qt::SolidLine); - // draw text of day - if (isSelectedCell) { - painter.setPen(m_currentDayTextColor); - } else if (isCurrentDay) { - painter.setPen(m_weekendsTextColor); - } else { - if (d == 6 || d == 7) - painter.setPen(m_weekendsTextColor); - else - painter.setPen(m_defaultTextColor); - } - -// painter.drawRect(rect); - painter.setFont(m_dayNumFont); - if (m_showState & ShowLunar) { - painter.drawText(QRect(bw - 1, bh, 24, 24), Qt::AlignCenter, dayNum); - if (d == 6 || d == 7) - painter.setPen(m_weekendsTextColor); - else - painter.setPen(m_defaultTextColor); - painter.drawText(QRect(bw + 24, bh, 30, 25), Qt::AlignCenter, dayWeek); - - } else { - QFontMetrics fm1 = painter.fontMetrics(); - painter.drawText(QRect(cell->width() - (cell->width()/2) - 4, bh - 1, 36, 26), Qt::AlignCenter, dayNum); - if (d == 6 || d == 7) - painter.setPen(m_weekendsTextColor); - else - painter.setPen(m_defaultTextColor); - - QFontMetrics fm = painter.fontMetrics(); - while (fm.width(dayWeek) > cell->width()/2) - dayWeek.chop(1); - painter.drawText(QRect(0, bh, (cell->width()/2), 26), Qt::AlignRight, dayWeek); - } - // draw text of day type - if (m_showState & ShowLunar) { - if (cell->width() > 100) { - if (d == 6 || d == 7) - painter.setPen(m_weekendsTextColor); - else - painter.setPen(m_defaultLunarColor); - - - if (cell->width() < 132) { - QString str_dayLunar = nullptr; - if (dayLunar.count() > 2) { - for (int i = 0; i < 2; i++) { - str_dayLunar.append(dayLunar.at(i)); - } - str_dayLunar.append("..."); - } else { - str_dayLunar = dayLunar; - } - painter.drawText(QRect(bw + 52 + 10, bh, 50, 25), Qt::AlignLeft, str_dayLunar); - } else { - painter.drawText(QRect(bw + 52 + 10, bh, 50, 25), Qt::AlignLeft, dayLunar); - } - CaLunarDayInfo dayInfo = getCaLunarDayInfo(pos); - //if (!dayInfo.mSolarFestival.isEmpty()) { - if (false) { - QRect fillRect = QRect(2, 39, 106, 15); - painter.setPen(Qt::red); - QFont solofont = m_dayNumFont; - solofont.setPixelSize(10); - painter.setFont(solofont); - QFontMetrics fm = painter.fontMetrics(); - while (fm.width(dayInfo.mSolarFestival) > 108) { - solofont.setPixelSize(solofont.pixelSize() - 1); - painter.setFont(solofont); - fm = painter.fontMetrics(); - } - painter.drawText(fillRect, Qt::AlignRight, dayInfo.mSolarFestival); - } - } - } - painter.restore(); - painter.end(); -} - -void CWeekHeadView::cellClicked(QWidget *cell) -{ - if (!m_cellSelectable) - return; - - const int pos = m_cellList.indexOf(cell); - if (pos == -1) - return; - - setSelectedCell(pos); - - // my gift eggs - static int gift = 0; - if (m_days[pos] == QDate(1993, 7, 28)) - if (++gift == 10) - QMessageBox::about(this, "LinuxDeepin", "by shibowen :P"); -} - -void CWeekHeadView::setSelectedCell(int index) -{ - if (m_selectedCell == index) - return; - - const int prevPos = m_selectedCell; - m_selectedCell = index; - - m_cellList.at(prevPos)->update(); - m_cellList.at(index)->update(); - emit dateSelected(m_days[index], getCaLunarDayInfo(index)); - //emit signalcurrentLunarDateChanged(m_days[index], getCaLunarDayInfo(index), 0); -} -int CWeekHeadView::checkDay(int weekday) -{ - - // check the week, calculate the correct order in the custom. - - if (weekday <= 0) - return weekday += 7; - - if (weekday > 7) - return weekday -= 7; - - return weekday; -} - - -void CWeekHeadView::mousePressEvent(QMouseEvent *event) -{ - Q_UNUSED(event); - emit signaleSchedulHide(); -} diff -Nru dde-calendar-5.7.0.4/src/weekheadview.h dde-calendar-5.7.0.23/src/weekheadview.h --- dde-calendar-5.7.0.4/src/weekheadview.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/weekheadview.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,134 +0,0 @@ -/* - * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ - -#ifndef WEEKHEADVIEW_H -#define WEEKHEADVIEW_H - -#include "constants.h" -#include -#include -#include -#include -#include -#include -#include -#include "calendardbus.h" -DWIDGET_USE_NAMESPACE - -enum CalendarWeekDayType { - SO_MFestival = QStyleOption::SO_CustomBase + 0x01, - SO_MWeekends = QStyleOption::SO_CustomBase + 0x02, - SO_MWeekendsAndFestival = SO_MFestival | SO_MWeekends, - SO_MNotCurrentMonth = 0x04, - SO_MNotCurrentMonthFestival = SO_MNotCurrentMonth | SO_MFestival, - SO_MDefault, -}; -class CustomFrame; -class CWeekHeadView: public DFrame -{ - Q_OBJECT -public: - enum ShowState { - ShowLunar = 0x01, - ShowLunarFestivalHighlight = 0x02, - Normal = ShowLunar | ShowLunarFestivalHighlight, - }; - -public: - explicit CWeekHeadView(QWidget *parent = nullptr); - ~CWeekHeadView(); - void setFirstWeekday(int weekday); - int getDateType(const QDate &date); - inline bool cellSelectable() const - { - return m_cellSelectable; - } - void setTheMe(int type = 0); - void setWeekDay(QVector vDays); - void setMounthLabelWidth(int w, int rw); -signals: - void dateSelected(const QDate date, const CaLunarDayInfo &detail) const; - //void signalcurrentLunarDateChanged(QDate date, CaLunarDayInfo detail, int type = 0); - void signalcurrentLunarDateChanged(QVector vdate, QVector vdetail, int type = 0); - void signalcurrentDateChanged(QDate date); - void currentDateChanged(const int year, const int month); - void currentFestivalChanged(const QString &festival); - void cellSelectableChanged(bool cellSelectable) const; - void signalsViewSelectDate(QDate date); - void signaleSchedulHide(); -public slots: - void setCurrentDate(const QDate date); - void setLunarVisible(bool visible); - void setLunarFestivalHighlight(bool highlight); - void setCellSelectable(bool selectable); - void handleCurrentDateChanged(const QDate date, const CaLunarDayInfo &detail); -private: - int getDateIndex(const QDate &date) const; - const QString getCellDayNum(int pos); - const QDate getCellDate(int pos); - const QString getLunar(int pos); - const CaLunarDayInfo getCaLunarDayInfo(int pos); - void paintCell(QWidget *cell); - bool eventFilter(QObject *o, QEvent *e)Q_DECL_OVERRIDE; - void updateDate(); - void updateCurrentLunar(const CaLunarDayInfo &info); - - int checkDay(int weekday); -protected: - void mousePressEvent(QMouseEvent *event)Q_DECL_OVERRIDE; -private slots: - void cellClicked(QWidget *cell); - void setSelectedCell(int index); - void getDbusData(); -private: - QList m_cellList; - CustomFrame *m_monthLabel; - CalendarDBus *m_DBusInter; - QDate m_days[7]; - QDate m_currentDate; - QStringList m_monthList; - ShowState m_showState = Normal; - int m_selectedCell = 0; - bool m_cellSelectable = true; - - QFont m_dayNumFont; - QFont m_monthFont; - - - QColor m_backgroundCircleColor = "#2ca7f8"; - QColor m_backgroundShowColor = "#2CA7F8"; - - QColor m_defaultTextColor = "#6F6F6F"; - QColor m_currentDayTextColor = "#FFFFFF"; - QColor m_defaultLunarColor = "#898989"; - QColor m_weekendsTextColor = "#0887FF"; - QColor m_currentMonthColor = "#000000"; - QColor m_backgroudColor = "#E6EEF2"; - QColor m_solofestivalLunarColor = "#4DFF7272"; - QQueue *queue = nullptr; - QMap *lunarCache = nullptr; - CaLunarDayInfo *emptyCaLunarDayInfo = nullptr; - int m_firstWeekDay; - int m_themetype = 1; - int m_monthW = 80; - int m_fixwidth = 200; - int m_radius = 8; -}; - -#endif // MYCALENDARWIDGET_H diff -Nru dde-calendar-5.7.0.4/src/weekindicator.cpp dde-calendar-5.7.0.23/src/weekindicator.cpp --- dde-calendar-5.7.0.4/src/weekindicator.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/weekindicator.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ - -#include "weekindicator.h" - - -#include -#include - -WeekIndicator::WeekIndicator(QWidget *parent) : DWidget(parent) -{ - m_mainLayout = new QHBoxLayout; - m_mainLayout->setMargin(0); - m_mainLayout->setSpacing(0); - setLayout(m_mainLayout); -} - -void WeekIndicator::setList(int weekday) -{ - QLayoutItem *child; - while ((child = m_mainLayout->takeAt(0)) != nullptr) { - if (child->widget() != nullptr) { - delete child->widget(); - } - delete child; - } - - QLocale locale; - for (int i = 0; i != 7; ++i) { - - int d = checkDay(i - weekday); - - DLabel *label = new DLabel(locale.dayName(d ? d : 7, QLocale::ShortFormat)); - - if ((i == weekday - 1 && weekday != 0) || i == weekday || (weekday == 0 && i == 6)) { - label->setObjectName("CalendarHeaderWeekend"); - } else { - label->setObjectName("CalendarHeaderWeekday"); - } - - label->setAlignment(Qt::AlignCenter); - label->setFixedSize(DDECalendar::CellWidth, DDECalendar::HeaderItemHeight); - m_mainLayout->addWidget(label, 0, Qt::AlignCenter); - } -} - -int WeekIndicator::checkDay(int weekday) -{ - - // check the week, calculate the correct order in the custom. - - if (weekday <= 0) - return weekday += 7; - - if (weekday > 7) - return weekday -= 7; - - return weekday; -} diff -Nru dde-calendar-5.7.0.4/src/weekindicator.h dde-calendar-5.7.0.23/src/weekindicator.h --- dde-calendar-5.7.0.4/src/weekindicator.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/weekindicator.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ - -#ifndef WEEKINDICATOR_H -#define WEEKINDICATOR_H - -#include "constants.h" -#include -#include -#include -DWIDGET_USE_NAMESPACE -class WeekIndicator : public DWidget -{ - Q_OBJECT -public: - explicit WeekIndicator(QWidget *parent = nullptr); - void setList(int weekday); - -private: - int checkDay(int weekday); - -private: - QHBoxLayout *m_mainLayout; -}; - -#endif // WEEKINDICATOR_H diff -Nru dde-calendar-5.7.0.4/src/weekview.cpp dde-calendar-5.7.0.23/src/weekview.cpp --- dde-calendar-5.7.0.4/src/weekview.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/weekview.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,364 +0,0 @@ -/* - * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ - -#include "weekview.h" -#include -#include "constants.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "scheduledatamanage.h" -DWIDGET_USE_NAMESPACE - -CWeekView::CWeekView(QWidget *parent) : QWidget(parent) -{ -// m_dayNumFont.setFamily("Avenir-Light"); - m_dayNumFont.setPixelSize(16); - m_dayNumFont.setWeight(QFont::Light); - // cells grid - QHBoxLayout *hboxLayout = new QHBoxLayout; - hboxLayout->setMargin(0); - hboxLayout->setSpacing(0); - //hboxLayout->setContentsMargins(4, 0, 4, 0); - for (int c = 0; c != 10; ++c) { - QWidget *cell = new QWidget; - cell->setFixedSize(DDEWeekCalendar::WWeekCellWidth, DDEWeekCalendar::WWeekCellHeight); - cell->installEventFilter(this); - cell->setFocusPolicy(Qt::ClickFocus); - hboxLayout->addWidget(cell); - m_cellList.append(cell); - } - setLayout(hboxLayout); - setMinimumWidth(150); -} - -CWeekView::~CWeekView() -{ - for (int i = 0; i < 10; i++) { - m_cellList.at(i)->removeEventFilter(this); - delete m_cellList.at(i); - } - m_cellList.clear(); -} - -void CWeekView::setFirstWeekDay(int weekday) -{ - m_firstWeekDay = weekday; - updateDate(); -} - -void CWeekView::setCurrentDate(const QDate date) -{ - m_selectDate = date; - m_selectedCell = 0; - updateDate(); - //setSelectedCell(m_selectDate.month() - 1); - update(); -} - -void CWeekView::setTheMe(int type) -{ - m_themetype = type; - if (type == 0 || type == 1) { - m_defaultTextColor = Qt::black; - m_backgrounddefaultColor = Qt::white; - m_currentDayTextColor = Qt::white; -// m_backgroundcurrentDayColor = "#0081FF"; - m_backgroundcurrentDayColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); - m_fillColor = "#FFFFFF"; - } else if (type == 2) { - m_defaultTextColor = "#C0C6D4"; - m_backgrounddefaultColor = "#FFFFFF"; - m_backgrounddefaultColor.setAlphaF(0.05); - m_currentDayTextColor = "#B8D3FF"; -// m_backgroundcurrentDayColor = "#0059D2"; - m_backgroundcurrentDayColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); - m_fillColor = "#000000"; - m_fillColor.setAlphaF(0.05); - } -} - -//void CWeekView::setwindowFixw(int w, int rw) -//{ -// m_fixwidth = w; -// m_realwidth = rw; -// return; -// int w2 = m_fixwidth * 0.1 + 0.5; -// int h = height(); -// for (int c = 0; c != 10; ++c) { -// m_cellList[c]->setFixedSize(w2, h); -// m_cellList[c]->update(); -// } -// if ((m_realwidth < m_fixwidth) && m_searchfalg) { -// int t_num = qRound((m_fixwidth - m_realwidth) / w2 / 2.0); -// QVector vindex; -// vindex.resize(10); -// vindex.fill(true); -// for (int i = 0; i < t_num; i++) { -// vindex[i] = false; -// vindex[9 - i] = false; -// } -// for (int i = 0; i < 10; i++) { -// m_cellList[i]->setVisible(vindex[i]); -// m_cellList[i]->update(); -// } -// } else { -// for (int i = 0; i < 10; i++) { -// m_cellList[i]->setVisible(true); -// m_cellList[i]->update(); -// } -// } -//} - -void CWeekView::setsearchfalg(bool flag) -{ - m_searchfalg = flag; -} -void CWeekView::slotprev() -{ - if (m_selectDate.year() >= 1900) { - QDate date = m_selectDate.addDays(-6); - setCurrentDate(date); - } else { - //QMessageBox::information(this, tr("infomation"), tr("Year less than 1900!")); - } -} - -void CWeekView::slotnext() -{ - QDate date = m_selectDate.addDays(8);; - setCurrentDate(date); -} -void CWeekView::paintCell(QWidget *cell) -{ - const QRect rect(0, 0, cell->width(), cell->height()); - - const int pos = m_cellList.indexOf(cell); - //计算当前日期周数 - int weekNumber = QDate::currentDate().weekNumber(); - //In accordance with ISO 8601, weeks start on Monday and the first - if (QDate::currentDate().dayOfWeek()==7) { - ++weekNumber; - } - - - const bool isCurrentDay = m_days[pos].addDays(3).weekNumber() == weekNumber && - m_days[pos].addDays(3).year() == QDate::currentDate().year(); - - const bool isSelectDay = m_days[pos].addDays(m_weekAddDay).weekNumber() == m_selectDate.addDays(m_weekAddDay).weekNumber(); - - - - QPainter painter(cell); - painter.save(); - - painter.setRenderHints(QPainter::HighQualityAntialiasing); - painter.setBrush(QBrush(m_fillColor)); - painter.setPen(Qt::NoPen); - painter.drawRect(rect);//画矩形 - painter.restore(); - painter.setPen(Qt::SolidLine); - - const QString dayNum = QString::number(m_days[pos].addDays(3).weekNumber()); - if (m_days[pos].year() < 1900 && dayNum != "1") return; - if (isSelectDay) { - - QRect fillRect((cell->width() - 24) / 2, (cell->height() - 32) / 2 + 4, 24, 24); -// QPixmap pixmap; -// if (m_themetype == 2) -// pixmap = DHiDPIHelper::loadNxPixmap(":/resources/icon/darkchoose30X30_checked .svg"); -// else { -// pixmap = DHiDPIHelper::loadNxPixmap(":/resources/icon/choose30X30_checked .svg"); -// } -// pixmap.setDevicePixelRatio(devicePixelRatioF()); -// painter.save(); -// painter.setRenderHint(QPainter::Antialiasing); -// painter.setRenderHint(QPainter::HighQualityAntialiasing); -// painter.setRenderHint(QPainter::SmoothPixmapTransform); -// painter.drawPixmap(fillRect, pixmap); - painter.save(); - painter.setRenderHint(QPainter::Antialiasing); - painter.setBrush(QBrush(CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor())); - painter.setPen(Qt::NoPen); - painter.drawEllipse(fillRect); - painter.restore(); - painter.setRenderHint(QPainter::HighQualityAntialiasing); - painter.setPen(m_currentDayTextColor); - painter.setFont(m_dayNumFont); - painter.drawText(QRect(0, 0, cell->width(), cell->height()), Qt::AlignCenter, dayNum); - } else { - if (isCurrentDay) { - painter.setPen(m_backgroundcurrentDayColor); - } else { - painter.setPen(m_defaultTextColor); - } - painter.setFont(m_dayNumFont); - painter.drawText(QRect(0, 0, cell->width(), cell->height()), Qt::AlignCenter, dayNum); - } - painter.end(); -} - -bool CWeekView::eventFilter(QObject *o, QEvent *e) -{ - QWidget *cell = qobject_cast(o); - - if (cell && m_cellList.contains(cell)) { - if (e->type() == QEvent::Paint) { - paintCell(cell); - } else if (e->type() == QEvent::MouseButtonPress) { - QMouseEvent *mouseEvent = dynamic_cast(e); - if (mouseEvent->button() ==Qt::LeftButton) { - cellClicked(cell); - } - } - } - return false; -} - -void CWeekView::cellClicked(QWidget *cell) -{ - if (!m_cellSelectable) - return; - - const int pos = m_cellList.indexOf(cell); - if (pos == -1) - return; - - setSelectedCell(pos); - update(); -} - -void CWeekView::setSelectedCell(int index) -{ - if (m_selectedCell == index) - return; - - const int prevPos = m_selectedCell; - m_selectedCell = index; - - m_cellList.at(prevPos)->update(); - m_cellList.at(index)->update(); - m_selectDate = m_days[index]; - const QString dayNum = QString::number(m_days[index].addDays(3).weekNumber()); - if (m_days[index].year() < 1900 && dayNum != "1") return; - emit signalsSelectDate(m_days[index], m_days[index].addDays(m_weekAddDay)); -} - -void CWeekView::updateDate() -{ - m_weekAddDay = (m_selectDate.dayOfWeek() + m_firstWeekDay) % 7; - QDate weekfirstDay = m_selectDate.addDays(-m_weekAddDay); - m_days[4] = weekfirstDay; - for (int i(0); i < 4; ++i) { - m_days[i] = weekfirstDay.addDays(-(4 - i) * 7); - } - for (int i(5); i != 10; ++i) { - m_days[i] = weekfirstDay.addDays((i - 4) * 7); - } - - setSelectedCell(4); - update(); -} -void CWeekView::resizeEvent(QResizeEvent *event) -{ -#if 0 - int w = m_fixwidth * 0.1 + 0.5; - int h = height(); - for (int c = 0; c != 10; ++c) { - m_cellList[c]->setFixedSize(w, h); - //m_cellList[c]->setVisible(true); - m_cellList[c]->update(); - } - if ((m_realwidth < m_fixwidth) && m_searchfalg) { - int t_num = qRound((m_fixwidth - m_realwidth ) / w / 2.0); - QVector vindex; - vindex.resize(10); - vindex.fill(true); - for (int i = 0; i < t_num; i++) { - vindex[i] = false; - vindex[9 - i] = false; - } - for (int i = 0; i < 10; i++) { - m_cellList[i]->setVisible(vindex[i]); - m_cellList[i]->update(); - } - } else { - for (int i = 0; i < 10; i++) { - m_cellList[i]->setVisible(true); - m_cellList[i]->update(); - } - } -#else - int w = width() / 10; - int h = height(); - - int ww = 36; - if (w >= ww) { - for (int c = 0; c != 10; ++c) { - m_cellList[c]->setFixedSize(w, h); - //m_cellList[c]->setVisible(true); - m_cellList[c]->update(); - } - for (int i = 0; i < 10; i++) { - m_cellList[i]->setVisible(true); - m_cellList[i]->update(); - } - } else { - for (int c = 0; c != 10; ++c) { - m_cellList[c]->setFixedSize(ww, h); - //m_cellList[c]->setVisible(true); - m_cellList[c]->update(); - } - int t_num = qRound((ww * 10 - width() ) / ww / 2.0); - QVector vindex; - vindex.resize(10); - vindex.fill(true); - for (int i = 0; i < t_num; i++) { - vindex[i] = false; - vindex[9 - i] = false; - } - for (int i = 0; i < 10; i++) { - m_cellList[i]->setVisible(vindex[i]); - m_cellList[i]->update(); - } - } - QWidget::resizeEvent(event); -#endif -} -void CWeekView::wheelEvent(QWheelEvent *event) -{ - Q_UNUSED(event); - bool isDragging = false; - // - emit signalIsDragging(isDragging); - //判断是否是拖拽状态 - if (!isDragging) { - if (event->delta() < 0) { - slotnext(); - } else { - slotprev(); - } - } - -} diff -Nru dde-calendar-5.7.0.4/src/weekview.h dde-calendar-5.7.0.23/src/weekview.h --- dde-calendar-5.7.0.4/src/weekview.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/weekview.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#ifndef WEEKVIEW_H -#define WEEKVIEW_H - -#include -#include -#include -class CWeekView : public QWidget -{ - Q_OBJECT -public: - explicit CWeekView(QWidget *parent = nullptr); - ~CWeekView(); - void setFirstWeekDay(int weekday); - void setCurrentDate(const QDate date); - void setTheMe(int type = 0); -// void setwindowFixw(int w, int rw); - void setsearchfalg(bool flag); -public slots: - void cellClicked(QWidget *cell); - void slotprev(); - void slotnext(); -signals: - void signalsSelectDate(QDate date, QDate currentDate); - void signalIsDragging(bool &isDragging); -protected: - void resizeEvent(QResizeEvent *event); - void wheelEvent(QWheelEvent *event); -private: - void paintCell(QWidget *cell); - bool eventFilter(QObject *o, QEvent *e); - void setSelectedCell(int index); - void updateDate(); -private: - QList m_cellList; - QDate m_selectDate; - QDate m_days[10]; - bool m_cellSelectable = true; - int m_selectedCell = 0; - QFont m_dayNumFont; - - QColor m_defaultTextColor = Qt::black; - QColor m_backgrounddefaultColor = Qt::white; - QColor m_currentDayTextColor = Qt::white; - QColor m_backgroundcurrentDayColor = "#0081FF"; - QColor m_fillColor = Qt::white; - int m_firstWeekDay; - int m_weekAddDay = 0; - int m_themetype = 1; - int m_fixwidth = 200; - int m_realwidth = 100; - bool m_searchfalg = false; -}; - -#endif // MONTDAYVIEW_H diff -Nru dde-calendar-5.7.0.4/src/weekwindow.cpp dde-calendar-5.7.0.23/src/weekwindow.cpp --- dde-calendar-5.7.0.4/src/weekwindow.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/weekwindow.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,585 +0,0 @@ -/* - * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#include "weekwindow.h" -#include "scheduleview.h" -#include "constants.h" -#include "calendardbus.h" -#include "weekheadview.h" -#include "weekview.h" -#include -#include -#include -#include -#include -#include "schcedulesearchview.h" -#include "todybutton.h" -#include - -DGUI_USE_NAMESPACE -CWeekWindow::CWeekWindow(QWidget *parent): QMainWindow (parent) -{ - setContentsMargins(0, 0, 0, 0); - initUI(); - initConnection(); - -} - -CWeekWindow::~CWeekWindow() -{ - -} - -void CWeekWindow::setDate(QDate date) -{ - if (!date.isValid()) return; - m_currentdate = date; - m_weekview->setCurrentDate(date); - update(); - emit signalCurrentDate(date); -} - -void CWeekWindow::setSelectSchedule(const ScheduleDtailInfo &scheduleInfo) -{ - m_scheduleView->setSelectSchedule(scheduleInfo); -} - -void CWeekWindow::setFirstWeekday(int weekday) -{ - m_weekview->setFirstWeekDay(weekday); - m_weekHeadView->setFirstWeekday(weekday); - m_scheduleView->setFirstWeekday(weekday); -} - -void CWeekWindow::setLunarVisible(bool state) -{ - m_weekHeadView->setLunarVisible(state); - m_YearLunarLabel->setVisible(state); - m_scheduleView->setLunarVisible(state); -} - -void CWeekWindow::initUI() -{ - m_contentBackground = new DFrame; - m_contentBackground->setAutoFillBackground(true); - DPalette anipa = m_contentBackground->palette(); - anipa.setColor(DPalette::Background, "#F8F8F8"); - m_contentBackground->setPalette(anipa); - m_contentBackground->setContentsMargins(0, 0, 0, 0); - - m_today = new CTodyButton; - m_today->setText(QCoreApplication::translate("today", "Today", "Today")); - m_today->setFixedSize(DDEWeekCalendar::WTodayWindth, DDEWeekCalendar::WTodayHeight); - DPalette todaypa = m_today->palette(); - QColor todayColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); -// todaypa.setColor(DPalette::ButtonText, QColor("#0098FF")); - todaypa.setColor(DPalette::ButtonText, todayColor); - todaypa.setColor(DPalette::Dark, Qt::white); - todaypa.setColor(DPalette::Light, Qt::white); - QColor sbcolor("#002A57"); - sbcolor.setAlphaF(0.05); - todaypa.setColor(DPalette::Shadow, sbcolor); - QFont todayfont; -// todayfont.setFamily("SourceHanSansSC"); - todayfont.setWeight(QFont::Medium); - todayfont.setPixelSize(14); - m_today->setFont(todayfont); - m_today->setPalette(todaypa); - m_prevButton = new DIconButton(DStyle::SP_ArrowLeft, this); - //m_prevButton->setIconSize(QSize(36, 36)); - //m_prevButton->setIcon(QIcon(DHiDPIHelper::loadNxPixmap(":/resources/icon/previous_normal.svg"))); - //m_prevButton->setArrowDirection(DArrowButton::ArrowLeft); - - m_prevButton->setFixedSize(36, 36); - - m_nextButton = new DIconButton(DStyle::SP_ArrowRight, this); - //m_nextButton->setIconSize(QSize(36, 36)); - //m_nextButton->setIcon(QIcon(DHiDPIHelper::loadNxPixmap(":/resources/icon/next_normal.svg"))); - m_nextButton->setFixedSize(36, 36); - //m_nextButton->setFixedSize(DDEWeekCalendar::WWeekCellWidth, DDEWeekCalendar::WWeekCellHeight); - - m_YearLabel = new QLabel(); - m_YearLabel->setFixedHeight(DDEWeekCalendar::W_YLableHeight); - //m_currentMouth->setStyleSheet("border: 1px solid rgba(0, 0, 0, 0.05);"); - - QFont t_labelF; -// t_labelF.setFamily("SourceHanSansSC"); - t_labelF.setWeight(QFont::Medium); - t_labelF.setPixelSize(24); - m_YearLabel->setFont(t_labelF); - DPalette Lunadpa = m_YearLabel->palette(); - Lunadpa.setColor(DPalette::WindowText, QColor("#3B3B3B")); - m_YearLabel->setPalette(Lunadpa); - //m_YearLabel->setStyleSheet("color:#3B3B3B;"); - - m_YearLunarLabel = new QLabel(m_contentBackground); - m_YearLunarLabel->setFixedSize(DDEWeekCalendar::W_YLunatLabelWindth, DDEWeekCalendar::W_YLunatLabelHeight); - - m_weekview = new CWeekView(this); - // m_weekview->setFixedHeight(DDEWeekCalendar::W_YLunatLabelHeight + 8); - - m_weekLabel = new QLabel(); - m_weekLabel->setFixedHeight(DDEWeekCalendar::W_YLableHeight); - QFont weeklabelF; -// weeklabelF.setFamily("PingFangSC"); - weeklabelF.setWeight(QFont::Medium); - weeklabelF.setPixelSize(14); - m_weekLabel->setFont(weeklabelF); - DPalette wpa = m_weekLabel->palette(); - wpa.setColor(DPalette::WindowText, QColor("#717171")); - m_weekLabel->setPalette(wpa); - m_weekLabel->setText(tr("Week")); - - QFont ylabelF; -// ylabelF.setFamily("SourceHanSansSC"); - ylabelF.setWeight(QFont::Medium); - ylabelF.setPixelSize(14); - m_YearLunarLabel->setFont(ylabelF); - DPalette YearLpa = m_YearLunarLabel->palette(); - YearLpa.setColor(DPalette::WindowText, QColor("#8A8A8A")); - - m_YearLunarLabel->setPalette(YearLpa); - //m_YearLunarLabel->move(116, 27); - - QHBoxLayout *yeartitleLayout = new QHBoxLayout; - yeartitleLayout->setMargin(0); - yeartitleLayout->setSpacing(0); - yeartitleLayout->setContentsMargins(21, 20, 8, 0); - yeartitleLayout->addWidget(m_YearLabel); - - QHBoxLayout *yeartitleLayout1 = new QHBoxLayout; - yeartitleLayout1->setMargin(0); - yeartitleLayout1->setSpacing(0); - yeartitleLayout1->setContentsMargins(14, 9, 0, 7); - yeartitleLayout1->addWidget(m_YearLunarLabel); - yeartitleLayout->addLayout(yeartitleLayout1); - - - - //QHBoxLayout *yeartitleLayout = new QHBoxLayout; - //yeartitleLayout->setMargin(0); - //yeartitleLayout->setSpacing(0); - //yeartitleLayout->setContentsMargins(21, 10, 20, 20); - // yeartitleLayout->addWidget(m_YearLabel); - //yeartitleLayout->addSpacing(14); - //yeartitleLayout->addWidget(m_YearLunarLabel); - //yeartitleLayout->addSpacing(30); - //m_spaceitem = new QSpacerItem(30, 36, QSizePolicy::Fixed, QSizePolicy::Fixed); - - //yeartitleLayout->addItem(m_spaceitem); - yeartitleLayout->addStretch(); - m_todayframe = new CustomFrame; - m_todayframe->setContentsMargins(0, 0, 0, 0); - m_todayframe->setRoundState(true, true, true, true); - m_todayframe->setBColor(Qt::white); - m_todayframe->setFixedHeight(DDEYearCalendar::Y_MLableHeight); - m_todayframe->setboreder(1); - QHBoxLayout *todaylayout = new QHBoxLayout; - todaylayout->setMargin(0); - todaylayout->setSpacing(0); - todaylayout->addWidget(m_prevButton); - todaylayout->addWidget(m_weekview); - todaylayout->addWidget(m_nextButton); - m_todayframe->setLayout(todaylayout); - - yeartitleLayout->addWidget(m_todayframe, 0, Qt::AlignCenter); - yeartitleLayout->addSpacing(10); - yeartitleLayout->addWidget(m_weekLabel, 0, Qt::AlignCenter); - yeartitleLayout->addStretch(); - yeartitleLayout->addWidget(m_today, 0, Qt::AlignRight); - - m_weekHeadView = new CWeekHeadView(this); - m_scheduleView = new CScheduleView(this); - //m_weekHeadView->setFixedWidth(840); - m_scheduleView->setviewMagin(73, 109 + 30, 0, 0); - m_scheduleView->setRange(763, 1032, QDate(2019, 8, 12), QDate(2019, 8, 18)); - //m_scheduleView->setFixedSize(838, 450); - - m_mainhLayout = new QVBoxLayout; - m_mainhLayout->setMargin(0); - m_mainhLayout->setSpacing(0); - m_mainhLayout->setContentsMargins(8, 20, 0, 9); - m_mainhLayout->addWidget(m_weekHeadView); - m_mainhLayout->addWidget(m_scheduleView); - QVBoxLayout *hhLayout = new QVBoxLayout; - hhLayout->setMargin(0); - hhLayout->setSpacing(0); - hhLayout->setContentsMargins(0, 0, 0, 0); - hhLayout->addLayout(yeartitleLayout); - hhLayout->addLayout(m_mainhLayout); - - m_tmainLayout = new QHBoxLayout; - m_tmainLayout->setMargin(0); - m_tmainLayout->setSpacing(0); - m_tmainLayout->setContentsMargins(0, 0, 10, 0); - m_tmainLayout->addLayout(hhLayout); - //mainLayout->addStretch(1); - - //m_schceduleSearchView = new CSchceduleSearchView(this); - //m_schceduleSearchView->setFixedWidth(200); - - QVBoxLayout *ssLayout = new QVBoxLayout; - ssLayout->setMargin(0); - ssLayout->setSpacing(0); - ssLayout->setContentsMargins(0, 0, 0, 10); - //ssLayout->addWidget(m_schceduleSearchView); - m_tmainLayout->addLayout(ssLayout); - //m_schceduleSearchView->setVisible(false); - - m_contentBackground->setLayout(m_tmainLayout); - setCentralWidget(m_contentBackground); -} - -void CWeekWindow::initConnection() -{ - connect(m_prevButton, &DIconButton::clicked, this, &CWeekWindow::slotprev); - connect(m_today, &CTodyButton::clicked, this, &CWeekWindow::slottoday); - connect(m_nextButton, &DIconButton::clicked, this, &CWeekWindow::slotnext); - connect(m_weekview, &CWeekView::signalsSelectDate, this, &CWeekWindow::slotCurrentWeek); - connect(m_weekHeadView, &CWeekHeadView::signalcurrentLunarDateChanged, this, &CWeekWindow::slotcurrentDateLunarChanged); - connect(m_weekHeadView, &CWeekHeadView::signalcurrentDateChanged, this, &CWeekWindow::slotcurrentDateChanged); - connect(m_scheduleView, &CScheduleView::signalsUpdateShcedule, this, &CWeekWindow::slotTransitSchedule); - connect(m_scheduleView, &CScheduleView::signalsCurrentScheduleDate, this, &CWeekWindow::signalsCurrentScheduleDate); - connect(m_scheduleView, &CScheduleView::signalViewtransparentFrame, this, &CWeekWindow::signalViewtransparentFrame); - connect(m_weekHeadView, &CWeekHeadView::signalsViewSelectDate, this, &CWeekWindow::signalsViewSelectDate); - connect(m_weekHeadView, &CWeekHeadView::signaleSchedulHide, this, &CWeekWindow::slotScheduleHide); - connect(m_weekview,&CWeekView::signalIsDragging,this,&CWeekWindow::slotIsDragging); - // connect(m_schceduleSearchView, &CSchceduleSearchView::signalsUpdateShcedule, this, &CWeekWindow::slotTransitSearchSchedule); - // connect(m_schceduleSearchView, &CSchceduleSearchView::signalDate, this, &CWeekWindow::slotsearchDateSelect); - -} - -void CWeekWindow::setTheMe(int type) -{ - if (type == 0 || type == 1) { - DPalette anipa = m_contentBackground->palette(); - anipa.setColor(DPalette::Background, "#F8F8F8"); - m_contentBackground->setPalette(anipa); - m_contentBackground->setBackgroundRole(DPalette::Background); - - DPalette todaypa = m_today->palette(); - QColor todayColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); - todaypa.setColor(DPalette::ButtonText, todayColor); -// todaypa.setColor(DPalette::ButtonText, QColor("#1D81EC")); - todaypa.setColor(DPalette::Dark, Qt::white); - todaypa.setColor(DPalette::Light, Qt::white); - QColor sbcolor("#002A57"); - sbcolor.setAlphaF(0.05); - todaypa.setColor(DPalette::Shadow, sbcolor); - m_today->setPalette(todaypa); - QColor todayhover = "#000000"; - todayhover.setAlphaF(0.1); - QColor todaypress = "#000000"; - todaypress.setAlphaF(0.2); - m_today->setBColor("#FFFFFF", todayhover, todaypress, "#FFFFFF", todayhover, todaypress); -// m_today->setTColor("#1D81EC", "#001A2E", "#0081FF"); - m_today->setTColor(todayColor, "#001A2E", "#0081FF"); - m_today->setshadowColor(sbcolor); - - DPalette prevpa = m_prevButton->palette(); - prevpa.setColor(DPalette::Dark, QColor("#E6E6E6")); - prevpa.setColor(DPalette::Light, QColor("#E3E3E3")); - // m_prevButton->setPalette(prevpa); - - DPalette nextvpa = m_nextButton->palette(); - nextvpa.setColor(DPalette::Dark, QColor("#E6E6E6")); - nextvpa.setColor(DPalette::Light, QColor("#E3E3E3")); - //m_nextButton->setPalette(nextvpa); - m_todayframe->setBColor(Qt::white); - DPalette pa = m_YearLabel->palette(); - pa.setColor(DPalette::WindowText, QColor("#3B3B3B")); - m_YearLabel->setPalette(pa); - m_YearLabel->setForegroundRole(DPalette::WindowText); - DPalette Lunapa = m_YearLunarLabel->palette(); - Lunapa.setColor(DPalette::WindowText, QColor("#8A8A8A")); - m_YearLunarLabel->setPalette(Lunapa); - m_YearLunarLabel->setForegroundRole(DPalette::WindowText); - - DPalette wpa = m_weekLabel->palette(); - wpa.setColor(DPalette::WindowText, QColor("#717171")); - m_weekLabel->setPalette(wpa); - m_weekLabel->setForegroundRole(DPalette::WindowText); - } else if (type == 2) { - DPalette anipa = m_contentBackground->palette(); - anipa.setColor(DPalette::Background, "#252525"); - m_contentBackground->setPalette(anipa); - m_contentBackground->setBackgroundRole(DPalette::Background); - - DPalette todaypa = m_today->palette(); - QColor todayColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); - todaypa.setColor(DPalette::ButtonText, todayColor); -// todaypa.setColor(DPalette::ButtonText, QColor("#0081FF")); - todaypa.setColor(DPalette::Dark, "#414141"); - todaypa.setColor(DPalette::Light, "#484848"); - QColor sbcolor("#000000"); - sbcolor.setAlphaF(0.05); - todaypa.setColor(DPalette::Shadow, sbcolor); - m_today->setPalette(todaypa); - m_today->setBColor("#484848", "#727272", "#242424", "#414141", "#535353", "#282828"); -// m_today->setTColor("#0081FF", "#FFFFFF", "#0081FF"); - m_today->setTColor(todayColor, "#FFFFFF", "#0081FF"); - m_today->setshadowColor(sbcolor); - - DPalette prevpa = m_prevButton->palette(); - prevpa.setColor(DPalette::Dark, QColor("#484848")); - prevpa.setColor(DPalette::Light, QColor("#414141")); - //prevpa.setColor(DPalette::Dark, Qt::black); - //prevpa.setColor(DPalette::Light, Qt::black); - //m_prevButton->setPalette(prevpa); - - DPalette nextvpa = m_nextButton->palette(); - nextvpa.setColor(DPalette::Dark, QColor("#484848")); - nextvpa.setColor(DPalette::Light, QColor("#414141")); - //m_nextButton->setPalette(nextvpa); - QColor bcolor = "#FFFFFF"; - bcolor.setAlphaF(0.05); - m_todayframe->setBColor(bcolor); - - DPalette pa = m_YearLabel->palette(); - pa.setColor(DPalette::WindowText, QColor("#C0C6D4")); - m_YearLabel->setPalette(pa); - m_YearLabel->setForegroundRole(DPalette::WindowText); - DPalette Lunapa = m_YearLunarLabel->palette(); - Lunapa.setColor(DPalette::WindowText, QColor("#798BA8")); - m_YearLunarLabel->setPalette(Lunapa); - m_YearLunarLabel->setForegroundRole(DPalette::WindowText); - DPalette wpa = m_weekLabel->palette(); - wpa.setColor(DPalette::WindowText, QColor("#717171")); - m_weekLabel->setPalette(wpa); - m_weekLabel->setForegroundRole(DPalette::WindowText); - } - m_weekview->setTheMe(type); - m_weekHeadView->setTheMe(type); - m_scheduleView->setTheMe(type); - //m_schceduleSearchView->setTheMe(type); -} - -void CWeekWindow::setTime(QTime time) -{ - m_scheduleView->setTime(time); -} -void CWeekWindow::setSearchWFlag(bool flag) -{ - m_searchfalg = flag; - m_weekview->setsearchfalg(flag); - update(); - //m_schceduleSearchView->setVisible(flag); -} - -void CWeekWindow::clearSearch() -{ - //m_schceduleSearchView->clearSearch(); -} - -void CWeekWindow::setSearchText(QString str) -{ - m_searchText = str; - //m_schceduleSearchView->slotsetSearch(str); -} - -void CWeekWindow::updateHigh() -{ - m_scheduleView->updateHigh(); -} -void CWeekWindow::slotReturnTodayUpdate() -{ - setDate(QDate::currentDate()); -} - -void CWeekWindow::slotIsDragging(bool &isDragging) -{ - isDragging = m_scheduleView->IsDragging(); -} - -void CWeekWindow::slotupdateSchedule(int id) -{ - Q_UNUSED(id); - m_scheduleView->slotupdateSchedule(); - //m_scheduleView->setTime(QTime::currentTime()); -} - -void CWeekWindow::slotTransitSchedule(int id) -{ - //m_schceduleSearchView->slotsetSearch(m_searchText); - emit signalsWUpdateShcedule(this, id); -} - -void CWeekWindow::slotTransitSearchSchedule(int id) -{ - m_scheduleView->slotupdateSchedule(); - // m_schceduleSearchView->slotsetSearch(m_searchText); - emit signalsWUpdateShcedule(this, id); -} - -void CWeekWindow::slotprev() -{ - slotScheduleHide(); - QDate tcurrent = m_currentdate.addDays(-7); - if (tcurrent.year() < 1900) return; - if (m_currentdate.year() >= 1900) { - m_currentdate = tcurrent; - setDate(m_currentdate); - } else { - //QMessageBox::information(this, tr("infomation"), tr("Year less than 1900!")); - } -} - -void CWeekWindow::slotnext() -{ - slotScheduleHide(); - m_currentdate = m_currentdate.addDays(7);; - setDate(m_currentdate); -} - -void CWeekWindow::slottoday() -{ - slotScheduleHide(); - emit signalsReturnTodayUpdate(this); - setDate(QDate::currentDate()); -} - -void CWeekWindow::slotCurrentWeek(QDate date, QDate currentDate) -{ - QVector vDate; - for (int i = 0; i < 7; i++) - vDate.append(date.addDays(i)); - emit signalCurrentDate(vDate[0]); - m_currentdate = currentDate; - m_weekHeadView->setWeekDay(vDate); - m_weekHeadView->setCurrentDate(m_currentdate); - m_scheduleView->setRange(date, date.addDays(6)); - //m_scheduleView->setDate(m_currentdate); -} - -void CWeekWindow::slotcurrentDateLunarChanged(QVector vdate, QVector vdetail, int type) -{ - int offset = 0; - for (int i = 0; i < vdate.count(); ++i) { - if (vdate.at(i) == m_currentdate) { - offset =i; - break; - } - } - if (m_currentdate == QDate::currentDate()) { - m_today->setText(QCoreApplication::translate("today", "Today", "Today")); - } else { - m_today->setText(QCoreApplication::translate("Return Today", "Today", "Return Today")); - //m_today->setText(tr("Return Today")); - } - // if (i == vdate.count()) { - // m_today->setEnabled(true); - // } else { - // m_today->setEnabled(false); - // } - if (!vdate.isEmpty()) { - CaLunarDayInfo detail = vdetail.at(offset); - if (type == 1) { - int yearnum = vdate.at(0).year(); - if (yearnum < 1900) yearnum = 1900; - QLocale locale; - if (locale.language() == QLocale::Chinese) { - - m_YearLabel->setText(QString::number(yearnum) + tr("Y")); - } else { - m_YearLabel->setText(QString::number(yearnum)); - } - //m_YearLabel->setText(QString::number(vdate.at(0).year()) + tr("Y")); - m_YearLunarLabel->setText("-" + detail.mGanZhiYear + detail.mZodiac + "年-"); - } - } -} - -void CWeekWindow::slotcurrentDateChanged(QDate date) -{ - if (m_currentdate == QDate::currentDate()) { - m_today->setText(QCoreApplication::translate("today", "Today", "Today")); - } else { - m_today->setText(QCoreApplication::translate("Return Today", "Today", "Return Today")); - //m_today->setText(tr("Return Today")); - } - //if (date != QDate::currentDate()) { - // m_today->setEnabled(true); - // } else { - // m_today->setEnabled(false); - //} - m_currentdate = date; - m_scheduleView->setDate(date); -} - -void CWeekWindow::slotsearchDateSelect(QDate date) -{ - setDate(date); - slotupdateSchedule(); -} - -void CWeekWindow::slotScheduleHide() -{ - m_scheduleView->slotScheduleShow(false); -} - -void CWeekWindow::resizeEvent(QResizeEvent *event) -{ - qreal sleftMagin = 0.093 * width() + 0.5; - qreal headh = height() * 0.0924 + 0.5; - qreal dw = width() * 0.4186 + 0.5; - int dh = 36; -// int space = (width() - dw) / 2 - 220; - -// int sw = (width() - width() * 0.9802 + 0.5) / 2; - - int winframe = 10; - m_mainhLayout->setContentsMargins(10, 20, 0, 10); - if (m_searchfalg) { - - m_tmainLayout->setContentsMargins(0, 0, 0, 0); - } else { - winframe += 10; - m_tmainLayout->setContentsMargins(0, 0, 10, 0); - } - - - //m_spaceitem->changeSize(space, 36, QSizePolicy::Fixed, QSizePolicy::Fixed); - if (!m_searchfalg) { - m_weekview->setFixedSize(qRound(dw), dh); - } else { - //m_weekview->setwindowFixw(dw, width() - 0.2325 * width() + 0.5 - 220 - 260); - m_weekview->setFixedSize(qRound(dw - 100), dh); - } - //m_weekview->setFixedHeight(dh); - - // m_weekview->setFixedSize(dw, dh); - - //m_weekHeadView->setFixedSize(width() * 0.9802 + 0.5, headh); - m_weekHeadView->setMounthLabelWidth(qRound(sleftMagin + 1), qRound(width() * 0.9802 + 0.5)); - // m_weekHeadView->setFixedHeight(headh); - //m_weekHeadView->setFixedSize(width() * 0.9802 + 0.5, headh); - m_weekHeadView->setFixedSize(width() - winframe, qRound(headh)); -// m_scheduleView->setviewMagin(sleftMagin, stopMagin, 0, 0); - //m_schceduleSearchView->setFixedWidth(0.2325 * width() + 0.5); - //m_scheduleView->setFixedSize(width() * 0.9802 + 0.5, sh); -// m_scheduleView->setFixedSize(width() - winframe, qRound(sh - 10)); - QMainWindow::resizeEvent(event); -} - -void CWeekWindow::mousePressEvent(QMouseEvent *event) -{ - Q_UNUSED(event); - slotScheduleHide(); -} - - diff -Nru dde-calendar-5.7.0.4/src/weekwindow.h dde-calendar-5.7.0.23/src/weekwindow.h --- dde-calendar-5.7.0.4/src/weekwindow.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/weekwindow.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#ifndef WEEKWINDOW_H -#define WEEKWINDOW_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include "calendardbus.h" -#include -#include -#include "customframe.h" -#include "schedulestructs.h" -DWIDGET_USE_NAMESPACE - -class CWeekHeadView; -class CaLunarDayInfo; -class CWeekView; -class CScheduleView; -class CSchceduleSearchView; -class CTodyButton; -class CWeekWindow: public QMainWindow -{ - Q_OBJECT -public: - CWeekWindow(QWidget *parent = nullptr); - ~CWeekWindow() Q_DECL_OVERRIDE; - void setDate(QDate date); - void setSelectSchedule(const ScheduleDtailInfo &scheduleInfo); - void setFirstWeekday(int weekday); - void setLunarVisible(bool state); - void initUI(); - void initConnection(); - void setTheMe(int type = 0); - void setTime(QTime time); - void setSearchWFlag(bool flag); - void clearSearch(); - void setSearchText(QString str); - void updateHigh(); -signals: - void dateSelected(const QDate date, const CaLunarDayInfo &detail) const; - void signalsWUpdateShcedule(QMainWindow *w, int id = 0); - void signalsReturnTodayUpdate(QMainWindow *w); - void signalsCurrentScheduleDate(QDate date); - void signalViewtransparentFrame(int type); - void signalCurrentDate(QDate date); - void signalsViewSelectDate(QDate date); -public slots: - void slotReturnTodayUpdate(); - void slotIsDragging(bool &isDragging); -public slots: - void slotupdateSchedule(int id = 0); - void slotTransitSchedule(int id = 0); - void slotTransitSearchSchedule(int id = 0); - void slotScheduleHide(); -private slots: - void slotprev(); - void slotnext(); - void slottoday(); - void slotCurrentWeek(QDate date, QDate currentDate); - void slotcurrentDateLunarChanged(QVector vdate, QVector vdetail, int type = 0); - void slotcurrentDateChanged(QDate date); - void slotsearchDateSelect(QDate date); - -protected: - void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; - void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; -private: - CWeekHeadView *m_weekHeadView; //周视图头 - DFrame *m_contentBackground = nullptr; - DIconButton *m_prevButton = nullptr; - DIconButton *m_nextButton = nullptr; - CTodyButton *m_today = nullptr; - QDate m_currentdate; - QLabel *m_YearLabel; - QLabel *m_YearLunarLabel; - QLabel *m_weekLabel; - CWeekView *m_weekview = nullptr; - CustomFrame *m_todayframe; - CScheduleView *m_scheduleView; - QSpacerItem *m_spaceitem; - QVBoxLayout *m_mainhLayout; - // CSchceduleSearchView *m_schceduleSearchView; - QString m_searchText; - QHBoxLayout *m_tmainLayout; - bool m_searchfalg = false; -}; - -#endif // YEARWINDOW_H diff -Nru dde-calendar-5.7.0.4/src/widget/calendarmainwindow.cpp dde-calendar-5.7.0.23/src/widget/calendarmainwindow.cpp --- dde-calendar-5.7.0.4/src/widget/calendarmainwindow.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/calendarmainwindow.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,1002 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#include "calendarmainwindow.h" +#include "widget/yearWidget/yearwindow.h" +#include "widget/monthWidget/monthwindow.h" +#include "dbuscalendar_adaptor.h" +#include "widget/weekWidget/weekwindow.h" +#include "widget/dayWidget/daywindow.h" +#include "scheduledatamanage.h" +#include "myschceduleview.h" +#include "creatorparschedule.h" +#include "configsettings.h" +#include "shortcut.h" +#include "schcedulesearchview.h" +#include "cdynamicicon.h" +#include "constants.h" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +DGUI_USE_NAMESPACE +DWIDGET_USE_NAMESPACE + +static const int CalendarMWidth = 860; +static const int CalendarMHeight = 634; + +Calendarmainwindow::Calendarmainwindow(QWidget *w) + : DMainWindow (w) +{ + m_DataGetThread = new DbusDataGetThread(CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->getDbus(), + this); + m_currentdate = QDate::currentDate(); + setContentsMargins(QMargins(0, 0, 0, 0)); + initUI(); + initConnection(); + initLunar(); + setMinimumSize(CalendarMWidth, CalendarMHeight); + setWindowTitle(tr("Calendar")); + new CalendarAdaptor(this); + resize(CalendarMWidth, CalendarMHeight); + + QShortcut *shortcut = new QShortcut(this); + shortcut->setKey(QKeySequence(QLatin1String("Ctrl+F"))); + connect(shortcut, SIGNAL(activated()), this, SLOT(slotSearchEdit())); + + QShortcut *viewshortcut = new QShortcut(this); + viewshortcut->setKey(QKeySequence(QLatin1String("Ctrl+Shift+/"))); + connect(viewshortcut, SIGNAL(activated()), this, SLOT(onViewShortcut())); + + setTitlebarShadowEnabled(true); + setFocusPolicy(Qt::ClickFocus); + QByteArray arrybyte = CConfigSettings::value("base.geometry").toByteArray(); + bool isOk = false; + int state = CConfigSettings::value("base.state").toInt(&isOk); + if (!arrybyte.isEmpty() && isOk) { + Qt::WindowStates winStates = static_cast(state); + setWindowState(winStates); + if (winStates !=Qt::WindowState::WindowMaximized) { + restoreGeometry(arrybyte); + } + } + Dtk::Widget::moveToCenter(this); +} + +Calendarmainwindow::~Calendarmainwindow() +{ + CDynamicIcon::releaseInstance(); +} + +bool Calendarmainwindow::analysisCreate(const QString &content, ScheduleDtailInfo &info) +{ + if (content.isEmpty()) return false; + QJsonParseError json_error; + QJsonDocument jsonDoc(QJsonDocument::fromJson(content.toLocal8Bit(), &json_error)); + + if (json_error.error != QJsonParseError::NoError) { + return false; + } + + QJsonArray rootarry = jsonDoc.array(); + + for (int i = 0; i < rootarry.size(); i++) { + + QJsonObject subObj = rootarry.at(i).toObject(); + if (subObj.value("name").toString() == "content") { + info.titleName = subObj.value("value").toString(); + } + if (subObj.value("name").toString() == "datetime") { + QString ssubObj = subObj.value("normValue").toString(); + QJsonParseError sjson_error; + QJsonDocument sjsonDoc(QJsonDocument::fromJson(ssubObj.toLocal8Bit(), &sjson_error)); + + if (sjson_error.error != QJsonParseError::NoError) { + return false; + } + QJsonObject ssobject = sjsonDoc.object(); + info.beginDateTime = QDateTime::fromString(ssobject.value("datetime").toString(), "yyyy-MM-ddThh:mm:ss"); + } + if (subObj.value("value").toString() == "reminder") { + info.id = 0; + info.rpeat = 0; + info.remind = true; + info.remindData.n = 0; + info.endDateTime = info.beginDateTime.addSecs(3600); + info.allday = false; + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->GetType(1, info.type); + } + } + return true; +} +void Calendarmainwindow::onViewShortcut() +{ + QRect rect = window()->geometry(); + QPoint pos(rect.x() + rect.width() / 2, rect.y() + rect.height() / 2); + Shortcut sc; + QStringList shortcutString; + QString param1 = "-j=" + sc.toStr(); + QString param2 = "-p=" + QString::number(pos.x()) + "," + QString::number(pos.y()); + shortcutString << "-b" << param1 << param2; + + QProcess *shortcutViewProc = new QProcess(this); + shortcutViewProc->startDetached("killall deepin-shortcut-viewer"); + shortcutViewProc->startDetached("deepin-shortcut-viewer", shortcutString); + + connect(shortcutViewProc, SIGNAL(finished(int)), shortcutViewProc, SLOT(deleteLater())); +} + +void Calendarmainwindow::slotGetScheduleInfoSuccess() +{ + m_yearwindow->getScheduleInfo(); +} + +void Calendarmainwindow::slotDynamicIconUpdate() +{ + if (QDate::currentDate() !=CDynamicIcon::getInstance()->getDate()) { + CDynamicIcon::getInstance()->setDate(QDate::currentDate()); + CDynamicIcon::getInstance()->setIcon(); + } +} +void Calendarmainwindow::viewWindow(int type, QDateTime datetime) +{ + if (type < 0 || type > m_stackWidget->count()) { + return; + } + + m_stackWidget->setCurrentIndex(type - 1); + + if (type - 1 != 0) { + m_priindex = type - 1; + } + + switch (type - 1) { + case DDECalendar::CalendarYearWindow: { + m_yearButton->setFocus(); + m_yearButton->setChecked(true); + m_yearwindow->setDate(datetime.date()); + } break; + case DDECalendar::CalendarMonthWindow: { + m_monthButton->setFocus(); + m_monthButton->setChecked(true); + m_monthWindow->setDate(datetime.date()); + m_monthWindow->slotupdateSchedule(0); + } break; + case DDECalendar::CalendarWeekWindow: { + m_weekButton->setFocus(); + m_weekButton->setChecked(true); + m_weekWindow->setDate(datetime.date()); + m_weekWindow->setTime(datetime.time()); + m_weekWindow->slotupdateSchedule(0); + } break; + case DDECalendar::CalendarDayWindow: { + m_dayButton->setFocus(); + m_dayButton->setChecked(true); + m_DayWindow->setDate(datetime.date()); + m_DayWindow->slotupdateSchedule(0); + m_searchflag = true; + } break; + } + CConfigSettings::setOption("base.view", type); +} + +void Calendarmainwindow::UpdateJob() +{ + int index = m_stackWidget->currentIndex(); + + if (index < 0 || index > m_stackWidget->count() - 1) { + + return; + } + + switch (index) { + case DDECalendar::CalendarMonthWindow: { + m_monthWindow->slotupdateSchedule(0); + } break; + case DDECalendar::CalendarWeekWindow: { + m_weekWindow->slotupdateSchedule(0); + } break; + case DDECalendar::CalendarDayWindow: { + m_DayWindow->slotupdateSchedule(0); + } break; + } +} + +void Calendarmainwindow::updateHigh() +{ + int index = m_stackWidget->currentIndex(); + + if (index < 0 || index > m_stackWidget->count() - 1) { + + return; + } + + switch (index) { + case DDECalendar::CalendarYearWindow: { + } break; + case DDECalendar::CalendarMonthWindow: { + } break; + case DDECalendar::CalendarWeekWindow: { + m_weekWindow->updateHigh(); + } break; + case DDECalendar::CalendarDayWindow: { + m_DayWindow->updateHigh(); + } break; + } +} + +void Calendarmainwindow::setSearchWidth(int w) +{ + m_contentBackground->setFixedWidth(w); +} + +void Calendarmainwindow::slotTheme(int type) +{ + if (type == 0) { + type = DGuiApplicationHelper::instance()->themeType(); + } + + if (type == 1) { + + DPalette pl = m_yearButton->palette(); + pl.setColor(DPalette::ButtonText, QColor("#414D68")); + pl.setColor(DPalette::Light, QColor("#E6E6E6")); + pl.setColor(DPalette::Dark, QColor("#E3E3E3")); + QColor sbcolor("#000000"); + sbcolor.setAlphaF(0.08); + pl.setColor(DPalette::Shadow, sbcolor); + m_yearButton->setPalette(pl); + m_monthButton->setPalette(pl); + m_weekButton->setPalette(pl); + m_dayButton->setPalette(pl); + + DPalette anipa = m_contentBackground->palette(); + anipa.setColor(DPalette::Background, "#F8F8F8"); + m_contentBackground->setPalette(anipa); + m_contentBackground->setBackgroundRole(DPalette::Background); + + DPalette tframepa = m_transparentFrame->palette(); + QColor tColor = "#FFFFFF"; + tColor.setAlphaF(0.3); + tframepa.setColor(DPalette::Background, tColor); + m_transparentFrame->setPalette(tframepa); + m_transparentFrame->setBackgroundRole(DPalette::Background); + + } else { + DPalette pl = m_yearButton->palette(); + pl.setColor(DPalette::ButtonText, QColor("#C0C6D4")); + pl.setColor(DPalette::Light, QColor("#484848")); + pl.setColor(DPalette::Dark, QColor("#414141")); + QColor sbcolor("#000000"); + sbcolor.setAlphaF(0.08); + pl.setColor(DPalette::Shadow, sbcolor); + m_yearButton->setPalette(pl); + m_monthButton->setPalette(pl); + m_weekButton->setPalette(pl); + m_dayButton->setPalette(pl); + DPalette anipa = m_contentBackground->palette(); + anipa.setColor(DPalette::Background, "#252525"); + m_contentBackground->setPalette(anipa); + m_contentBackground->setBackgroundRole(DPalette::Background); + + DPalette tframepa = m_transparentFrame->palette(); + QColor tColor = "#000000"; + tColor.setAlphaF(0.3); + tframepa.setColor(DPalette::Background, tColor); + m_transparentFrame->setPalette(tframepa); + m_transparentFrame->setBackgroundRole(DPalette::Background); + } + CScheduleDataManage::getScheduleDataManage()->setTheMe(type); + m_yearwindow->setTheMe(type); + m_monthWindow->setTheMe(type); + m_weekWindow->setTheMe(type); + m_DayWindow->setTheMe(type); + m_schceduleSearchView->setTheMe(type); +} + +void Calendarmainwindow::OpenSchedule(QString job) +{ + if (job.isEmpty()) return; + + ScheduleDtailInfo out; + + if (CreatOrParSchedule::GetJob(job, out)) { + m_dayButton->setFocus(); + m_dayButton->setChecked(true); + m_stackWidget->setCurrentIndex(DDECalendar::CalendarDayWindow); + m_DayWindow->setDate(out.beginDateTime.date()); + m_DayWindow->slotupdateSchedule(0); + CMySchceduleView dlg(out, this); + dlg.exec(); + m_DayWindow->slotupdateSchedule(0); + slotWUpdateShcedule(nullptr,0); + } +} + +void Calendarmainwindow::ActiveWindow() +{ + raise(); +} + +void Calendarmainwindow::RaiseWindow() +{ + raise(); +} +void Calendarmainwindow::initUI() +{ + //设置主窗口辅助技术显示名称和描述 + this->setObjectName("MainWindow"); + this->setAccessibleName("MainWindow"); + this->setAccessibleDescription("This is the main window"); + m_DynamicIconUpdateTimer = new QTimer(this); + m_DynamicIconUpdateTimer->start(3000); + + QFrame *titleframe = new QFrame(this); + titleframe->setAccessibleName("TitleFrame"); + titleframe->setObjectName("titleframe"); + titleframe->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + CDynamicIcon::getInstance()->setTitlebar(this->titlebar()); + CDynamicIcon::getInstance()->setIcon(); + + QStringList titlelist; + titlelist << tr("Y") << tr("M") << tr("W") << tr("D"); + m_buttonBox = new DButtonBox(this); + m_buttonBox->setObjectName("ButtonBox"); + m_buttonBox->setAccessibleName("ButtonBox"); + m_buttonBox->setAccessibleDescription("Year, month, week, day button box"); + + m_yearButton = new DButtonBoxButton(tr("Y"), this); + //设置年辅助技术显示名称 + m_yearButton->setObjectName("YearButton"); + m_yearButton->setAccessibleName("YearButton"); + DPalette pl = m_yearButton->palette(); + pl.setColor(DPalette::ButtonText, QColor("#414D68")); + pl.setColor(DPalette::Light, QColor("#E6E6E6")); + pl.setColor(DPalette::Dark, QColor("#E3E3E3")); + QColor sbcolor("#000000"); + sbcolor.setAlphaF(0.08); + pl.setColor(DPalette::Shadow, sbcolor); + + QFont viewfont; + viewfont.setWeight(QFont::Medium); + viewfont.setPixelSize(DDECalendar::FontSizeFourteen); + + m_yearButton->setFixedSize(50, 36); + m_monthButton = new DButtonBoxButton(tr("M"), this); + //设置月辅助技术显示名称 + m_monthButton->setObjectName("MonthButton"); + m_monthButton->setAccessibleName("MonthButton"); + m_monthButton->setFixedSize(50, 36); + m_weekButton = new DButtonBoxButton(tr("W"), this); + //设置周辅助技术显示名称 + m_weekButton->setObjectName("WeekButton"); + m_weekButton->setAccessibleName("WeekButton"); + m_weekButton->setFixedSize(50, 36); + m_dayButton = new DButtonBoxButton(tr("D"), this); + //设置日辅助技术显示名称 + m_dayButton->setObjectName("DayButton"); + m_dayButton->setAccessibleName("DayButton"); + m_dayButton->setFixedSize(50, 36); + m_yearButton->setPalette(pl); + m_monthButton->setPalette(pl); + m_weekButton->setPalette(pl); + m_dayButton->setPalette(pl); + m_yearButton->setFont(viewfont); + m_monthButton->setFont(viewfont); + m_weekButton->setFont(viewfont); + m_dayButton->setFont(viewfont); + + QList btlist; + btlist.append(m_yearButton); + btlist.append(m_monthButton); + btlist.append(m_weekButton); + btlist.append(m_dayButton); + m_buttonBox->setButtonList(btlist, true); + + m_buttonBox->setId(m_yearButton, DDECalendar::CalendarYearWindow); + m_buttonBox->setId(m_monthButton, DDECalendar::CalendarMonthWindow); + m_buttonBox->setId(m_weekButton, DDECalendar::CalendarWeekWindow); + m_buttonBox->setId(m_dayButton, DDECalendar::CalendarDayWindow); + m_buttonBox->setFixedSize(200, 36); + + QHBoxLayout *titleLayout = new QHBoxLayout; + titleLayout->setMargin(0); + titleLayout->setSpacing(0); + titleLayout->addSpacing(8); + titleLayout->addWidget(m_buttonBox); + titleLayout->addSpacing(52); + m_searchEdit = new DSearchEdit(this); + //设置搜索框辅助技术显示名称 + m_searchEdit->setObjectName("SearchEdit"); + m_searchEdit->setAccessibleName("SearchEdit"); + DFontSizeManager::instance()->bind(m_searchEdit, DFontSizeManager::T6); + m_searchEdit->setFixedHeight(36); + m_searchEdit->setMinimumWidth(240); + m_searchEdit->setMaximumWidth(354); + m_searchEdit->setFont(viewfont); + titleLayout->addStretch(); + titleframe->setLayout(titleLayout); + + DTitlebar *titlebar = this->titlebar(); + titlebar->setObjectName("TitleBar"); + titlebar->setAccessibleName("TitleBar"); + titlebar->setFixedHeight(50); + titlebar->addWidget(titleframe, Qt::AlignLeft | Qt::AlignVCenter); + titlebar->setCustomWidget(m_searchEdit, true); + + m_stackWidget = new AnimationStackedWidget(); + m_stackWidget->setObjectName("StackedWidget"); + m_stackWidget->setAccessibleName("StackedWidget"); + m_stackWidget->setAccessibleDescription("Container for year window, month window, week window and day window"); + m_stackWidget->setContentsMargins(0, 0, 0, 0); + m_stackWidget->setDuration(250); + createview(); + QHBoxLayout *tmainLayout = new QHBoxLayout; + tmainLayout->setMargin(0); + tmainLayout->setSpacing(0); + tmainLayout->setContentsMargins(0, 0, 0, 0); + tmainLayout->addWidget(m_stackWidget); + m_contentBackground = new DFrame; + m_contentBackground->setAccessibleName("ScheduleSearchWidgetBackgroundFrame"); + m_contentBackground->setObjectName("ScheduleSearchWidgetBackgroundFrame"); + m_contentBackground->setContentsMargins(0, 0, 0, 0); + DPalette anipa = m_contentBackground->palette(); + anipa.setColor(DPalette::Background, "#F8F8F8"); + m_contentBackground->setAutoFillBackground(true); + m_contentBackground->setPalette(anipa); + + m_schceduleSearchView = new CSchceduleSearchView(this); + m_schceduleSearchView->setObjectName("ScheduleSearchWidget"); + m_schceduleSearchView->setAccessibleName("ScheduleSearchWidget"); + m_schceduleSearchView->setAccessibleDescription("Window showing search results"); + + QVBoxLayout *ssLayout = new QVBoxLayout; + ssLayout->setMargin(0); + ssLayout->setSpacing(0); + ssLayout->setContentsMargins(0, 10, 0, 10); + ssLayout->addWidget(m_schceduleSearchView); + m_contentBackground->setLayout(ssLayout); + tmainLayout->addWidget(m_contentBackground); + m_contentBackground->setVisible(false); + + DWidget *maincentralWidget = new DWidget(this); + maincentralWidget->setAccessibleName("mainCentralWidget"); + + maincentralWidget->setLayout(tmainLayout); + + setCentralWidget(maincentralWidget); + m_yearButton->setFocus(); + m_yearButton->setChecked(true); + m_transparentFrame = new DFrame(this); + m_transparentFrame->setAutoFillBackground(true); + m_transparentFrame->hide(); + + m_animation = new QPropertyAnimation(this); +} + +void Calendarmainwindow::initConnection() +{ + connect(m_DataGetThread, + &DbusDataGetThread::signalGetScheduleSuccess, + this, + &Calendarmainwindow::slotGetScheduleInfoSuccess); + + connect(m_stackWidget + , &AnimationStackedWidget::signalIsFinished + , this + , &Calendarmainwindow::slotSetButtonBox); + connect(m_buttonBox, &DButtonBox::buttonClicked, this, &Calendarmainwindow::slotstackWClicked); + connect(m_weekWindow, &CWeekWindow::signalsWUpdateShcedule, this, &Calendarmainwindow::slotWUpdateShcedule); + connect(m_monthWindow, &CMonthWindow::signalsWUpdateShcedule, this, &Calendarmainwindow::slotWUpdateShcedule); + connect(m_DayWindow, &CDayWindow::signalsWUpdateShcedule, this, &Calendarmainwindow::slotWUpdateShcedule); + connect(m_searchEdit, &DSearchEdit::returnPressed, this, &Calendarmainwindow::slotSreturnPressed); + connect(m_searchEdit, &DSearchEdit::textChanged, this, &Calendarmainwindow::slotStextChanged); + connect(m_searchEdit, &DSearchEdit::focusChanged, this, &Calendarmainwindow::slotStextfocusChanged); + connect(m_weekWindow, &CWeekWindow::signalsReturnTodayUpdate, this, &Calendarmainwindow::slotReturnTodyUpdate); + connect(m_monthWindow, &CMonthWindow::signalsReturnTodayUpdate, this, &Calendarmainwindow::slotReturnTodyUpdate); + connect(m_DayWindow, &CDayWindow::signalsReturnTodayUpdate, this, &Calendarmainwindow::slotReturnTodyUpdate); + connect(m_yearwindow, &CYearWindow::signalsReturnTodayUpdate, this, &Calendarmainwindow::slotReturnTodyUpdate); + //监听当前应用主题切换事件 + connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &Calendarmainwindow::slotTheme); + + m_dbus = new com::deepin::daemon::calendar::Scheduler("com.deepin.daemon.Calendar", + "/com/deepin/daemon/Calendar/Scheduler", + QDBusConnection::sessionBus(), this); + connect(m_dbus, &com::deepin::daemon::calendar::Scheduler::JobsUpdated, + this, &Calendarmainwindow::slotJobsUpdated); + connect(m_schceduleSearchView, &CSchceduleSearchView::signalsUpdateShcedule, this, &Calendarmainwindow::slotTransitSearchSchedule); + connect(m_schceduleSearchView, &CSchceduleSearchView::signalDate, this, &Calendarmainwindow::slotsearchDateSelect); + connect(m_schceduleSearchView, &CSchceduleSearchView::signalSelectSchedule, + this, &Calendarmainwindow::slotSearchSelectSchedule); + connect(m_schceduleSearchView, &CSchceduleSearchView::signalScheduleHide, + this, &Calendarmainwindow::setScheduleHide); + + connect(m_yearwindow, &CYearWindow::signaldoubleclickDate, this, &Calendarmainwindow::slotdoubleclickDate); + connect(m_yearwindow, &CYearWindow::signalselectWeekwindow, this, &Calendarmainwindow::slotselectWeek); + connect(m_yearwindow, &CYearWindow::signalselectMonth, this, &Calendarmainwindow::slotselectMonth); + + connect(m_monthWindow, &CMonthWindow::signalsViewSelectDate, this, &Calendarmainwindow::slotViewSelectDate); + connect(m_monthWindow, &CMonthWindow::signalsCurrentScheduleDate, this, &Calendarmainwindow::slotCurrentScheduleDate); + connect(m_weekWindow, &CWeekWindow::signalsCurrentScheduleDate, this, &Calendarmainwindow::slotCurrentScheduleDate); + connect(m_weekWindow, &CWeekWindow::signalsViewSelectDate, this, &Calendarmainwindow::slotViewSelectDate); + connect(m_monthWindow, &CMonthWindow::signalViewtransparentFrame, this, &Calendarmainwindow::slotViewtransparentFrame); + connect(m_schceduleSearchView, &CSchceduleSearchView::signalViewtransparentFrame, this, &Calendarmainwindow::slotViewtransparentFrame); + connect(m_weekWindow, &CWeekWindow::signalViewtransparentFrame, this, &Calendarmainwindow::slotViewtransparentFrame); + connect(m_DayWindow, &CDayWindow::signalViewtransparentFrame, this, &Calendarmainwindow::slotViewtransparentFrame); + + connect(m_weekWindow, &CWeekWindow::signalCurrentDate, this, &Calendarmainwindow::slotCurrentDate); + connect(m_monthWindow, &CMonthWindow::signalCurrentDate, this, &Calendarmainwindow::slotCurrentDate); + connect(m_DayWindow, &CDayWindow::signalCurrentDate, this, &Calendarmainwindow::slotCurrentDate); + connect(m_yearwindow, &CYearWindow::signalCurrentDate, this, &Calendarmainwindow::slotCurrentDate); + + connect(m_yearwindow, + &CYearWindow::signalupdateschcedule, + this, + &Calendarmainwindow::getScheduleInfo); + + connect(m_DynamicIconUpdateTimer, + &QTimer::timeout, + this, + &Calendarmainwindow::slotDynamicIconUpdate); +} + +void Calendarmainwindow::initLunar() +{ + QLocale locale; + bool flag = false; + + if (locale.language() == QLocale::Chinese) { + flag = true; + } + + m_yearwindow->setLunarVisible(flag); + m_monthWindow->setLunarVisible(flag); + m_weekWindow->setLunarVisible(flag); + m_DayWindow->setLunarVisible(flag); +} + +void Calendarmainwindow::createview() +{ + CScheduleDataManage::getScheduleDataManage()->setFirstWeekDay(0); + CScheduleDataManage::getScheduleDataManage()->setCurrentYear(QDate::currentDate().year()); + + getScheduleInfo(); + m_yearwindow = new CYearWindow(this); + m_yearwindow->setDate(QDate::currentDate()); + m_stackWidget->addWidget(m_yearwindow); +#if 1 + m_monthWindow = new CMonthWindow; + //0:周日 1~6:周一~周六 + m_monthWindow->setFirstWeekday(0); + m_monthWindow->setDate(QDate::currentDate()); + m_stackWidget->addWidget(m_monthWindow); + + m_weekWindow = new CWeekWindow(this); + m_weekWindow->setFirstWeekday(0); + m_weekWindow->setDate(QDate::currentDate()); + m_weekWindow->slotupdateSchedule(0); + m_stackWidget->addWidget(m_weekWindow); + + m_DayWindow = new CDayWindow; + QTimer::singleShot(500,[=] { + m_DayWindow->setDate(QDate::currentDate()); + }); + m_stackWidget->addWidget(m_DayWindow); +#endif +} + +DPushButton *Calendarmainwindow::createButon(QString name) +{ + DPushButton *button = new DPushButton(); + button->setText(name); + button->setFixedSize(50, 40); + + return button; +} + +void Calendarmainwindow::getScheduleInfo() +{ + YearScheduleInfo *info = CScheduleDataManage::getScheduleDataManage()->getGetAllYearScheduleInfo(); + m_DataGetThread->getScheduleInfo(info); +} + +void Calendarmainwindow::setScheduleHide() +{ + m_yearwindow->slotSetSchceduleHide(); + m_monthWindow->slotScheduleHide(); + m_weekWindow->slotScheduleHide(); + m_DayWindow->slotScheduleHide(); +} + +void Calendarmainwindow::resizeEvent(QResizeEvent *event) +{ + m_transparentFrame->resize(width(), height() - 50); + m_scheduleSearchViewMaxWidth = qRound(0.2325 * width() + 0.5); + m_schceduleSearchView->setMaxWidth(m_scheduleSearchViewMaxWidth); + setSearchWidth(m_scheduleSearchViewMaxWidth); + setScheduleHide(); + DMainWindow::resizeEvent(event); + CConfigSettings::setOption("base.geometry", saveGeometry()); + CConfigSettings::setOption("base.state", int(windowState())); +} + +void Calendarmainwindow::slotstackWClicked(QAbstractButton *bt) +{ + m_buttonBox->setEnabled(false); + setScheduleHide(); + int index = m_buttonBox->id(bt); + + if (index < 0 || index > m_stackWidget->count() - 1) { + + return; + } + m_searchflag = false; + m_stackWidget->setCurrent(index); + + if (index != 0) { + m_priindex = index; + } + + if (m_currentdate.year() < DDECalendar::QueryEarliestYear) + return; + switch (index) { + case DDECalendar::CalendarYearWindow: { + m_yearwindow->setDate(m_currentdate); + } break; + case DDECalendar::CalendarMonthWindow: { + m_monthWindow->setDate(m_currentdate); + m_monthWindow->slotupdateSchedule(0); + } break; + case DDECalendar::CalendarWeekWindow: { + m_weekWindow->setDate(m_currentdate); + m_weekWindow->slotupdateSchedule(1); + } break; + case DDECalendar::CalendarDayWindow: { + m_DayWindow->setDate(m_currentdate); + m_DayWindow->slotupdateSchedule(1); + m_searchflag = true; + } break; + } + CConfigSettings::setOption("base.view", index + 1); +} + +void Calendarmainwindow::slotWUpdateShcedule(QMainWindow *w, int id) +{ + Q_UNUSED(w); + Q_UNUSED(id); + + if (m_opensearchflag && !m_searchEdit->text().isEmpty()) { + m_schceduleSearchView->slotsetSearch(m_searchEdit->text()); + m_yearwindow->slotupdateSchedule(0); + } + updateHigh(); + return; +} + +void Calendarmainwindow::slotReturnTodyUpdate(QMainWindow *w) +{ + if (w != m_weekWindow) + m_weekWindow->slotReturnTodayUpdate(); + if (w != m_monthWindow) + m_monthWindow->slotReturnTodayUpdate(); + if (w != m_DayWindow) + m_DayWindow->slotReturnTodayUpdate(); + if (w != m_yearwindow) + m_yearwindow->slotReturnTodayUpdate(); +} + +void Calendarmainwindow::slotSreturnPressed() +{ +#if 1 + if (!m_opensearchflag && !m_searchEdit->text().isEmpty()) { + m_opensearchflag = true; + m_contentBackground->setVisible(true); + } + m_schceduleSearchView->slotsetSearch(m_searchEdit->text()); + m_yearwindow->setDate(m_currentdate); + updateHigh(); +#endif +} + +void Calendarmainwindow::slotStextChanged() +{ + if (!m_searchEdit->text().isEmpty()) { + m_yearwindow->setSearchWFlag(true); + m_weekWindow->setSearchWFlag(true); + m_monthWindow->setSearchWFlag(true); + m_DayWindow->setSearchWFlag(true); + } else { + m_schceduleSearchView->clearSearch(); + m_yearwindow->setSearchWFlag(false); + m_monthWindow->setSearchWFlag(false); + m_weekWindow->setSearchWFlag(false); + m_DayWindow->setSearchWFlag(false); + m_contentBackground->setVisible(false); + m_opensearchflag = false; + } + updateHigh(); + +} + +void Calendarmainwindow::slotStextfocusChanged(bool onFocus) +{ + if (onFocus) { + setScheduleHide(); + } +} + +void Calendarmainwindow::slotJobsUpdated(const QList &Ids) +{ + Q_UNUSED(Ids); + int index = m_stackWidget->currentIndex(); + + if (index < 0 || index > m_stackWidget->count() - 1) { + return; + } + + switch (index) { + //年窗口截面刷新 + case DDECalendar::CalendarYearWindow: { + //获取数据 + getScheduleInfo(); + m_yearwindow->slotupdateSchedule(0); + }break; + case DDECalendar::CalendarMonthWindow: { + m_monthWindow->slotupdateSchedule(0); + } break; + case DDECalendar::CalendarWeekWindow: { + m_weekWindow->slotupdateSchedule(0); + } break; + case DDECalendar::CalendarDayWindow: { + m_DayWindow->slotupdateSchedule(0); + } break; + } +} + +void Calendarmainwindow::slotSearchEdit() +{ + m_searchEdit->lineEdit()->setFocus(); +} + +void Calendarmainwindow::slotTransitSearchSchedule(int id) +{ + Q_UNUSED(id); + getScheduleInfo(); + + int index = m_stackWidget->currentIndex(); + if (index < 0 || index > m_stackWidget->count() - 1) { + + return; + } + + switch (index) { + case DDECalendar::CalendarYearWindow: { + m_yearwindow->slotupdateSchedule(0); + } break; + case DDECalendar::CalendarMonthWindow: { + m_monthWindow->slotupdateSchedule(0); + } break; + case DDECalendar::CalendarWeekWindow: { + m_weekWindow->slotupdateSchedule(0); + } break; + case DDECalendar::CalendarDayWindow: { + m_DayWindow->slotupdateSchedule(0); + } break; + } + m_schceduleSearchView->slotsetSearch(m_searchEdit->text()); +} + +void Calendarmainwindow::slotsearchDateSelect(QDate date) +{ + setScheduleHide(); + int index = m_stackWidget->currentIndex(); + + if (index < 0 || index > m_stackWidget->count() - 1) { + return; + } + + switch (index) { + case DDECalendar::CalendarYearWindow: { + m_yearwindow->setDate(date); + } break; + case DDECalendar::CalendarMonthWindow: { + m_monthWindow->setDate(date); + } break; + case DDECalendar::CalendarWeekWindow: { + m_weekWindow->setDate(date); + } break; + case DDECalendar::CalendarDayWindow: { + m_DayWindow->setDate(date); + } break; + } +} + +void Calendarmainwindow::slotSearchSelectSchedule(const ScheduleDtailInfo &scheduleInfo) +{ + int index = m_stackWidget->currentIndex(); + + if (index < 0 || index > m_stackWidget->count() - 1) { + return; + } + //等界面刷新完成后进行动作 + QTimer::singleShot(50, [this, index,scheduleInfo] { + switch (index) + { + case DDECalendar::CalendarYearWindow: { + } break; + case DDECalendar::CalendarMonthWindow: { + m_monthWindow->setSelectSchedule(scheduleInfo); + } break; + case DDECalendar::CalendarWeekWindow: { + m_weekWindow->setSelectSchedule(scheduleInfo); + } break; + case DDECalendar::CalendarDayWindow: { + m_DayWindow->setSelectSchedule(scheduleInfo); + } break; + } + }); + +} + +void Calendarmainwindow::slotdoubleclickDate(QDate date) +{ + m_stackWidget->setCurrentIndex(m_priindex); + + switch (m_priindex) { + case DDECalendar::CalendarMonthWindow: { + m_monthButton->setFocus(); + m_monthButton->setChecked(true); + m_monthWindow->setDate(date); + m_monthWindow->slotupdateSchedule(0); + } break; + case DDECalendar::CalendarWeekWindow: { + m_weekButton->setFocus(); + m_weekButton->setChecked(true); + m_weekWindow->setDate(date); + m_weekWindow->setTime(QTime::currentTime()); + m_weekWindow->slotupdateSchedule(0); + } break; + case DDECalendar::CalendarDayWindow: { + m_dayButton->setFocus(); + m_dayButton->setChecked(true); + m_DayWindow->setDate(date); + m_DayWindow->setTime(QTime::currentTime()); + m_DayWindow->slotupdateSchedule(0); + } break; + } + CConfigSettings::setOption("base.view", m_priindex+1); +} + +void Calendarmainwindow::slotselectMonth(QDate date) +{ + qDebug() << date; + viewWindow(DDECalendar::CalendarMonthWindow + 1, QDateTime(date)); +} + +void Calendarmainwindow::slotselectWeek(QDate date) +{ + qDebug() << date; + viewWindow(DDECalendar::CalendarWeekWindow + 1, QDateTime(date)); + CConfigSettings::setOption("base.view", m_priindex + 1); +} + +void Calendarmainwindow::slotCurrentScheduleDate(QDate date) +{ + viewWindow(DDECalendar::CalendarDayWindow + 1, QDateTime(date)); +} + +void Calendarmainwindow::slotViewSelectDate(QDate date) +{ + if (date.year() < DDECalendar::QueryEarliestYear) + return; + viewWindow(DDECalendar::CalendarDayWindow + 1, QDateTime(date)); +} + +void Calendarmainwindow::slotViewtransparentFrame(int type) +{ + static int showFrameCount =0; + + if (type) { + m_transparentFrame->resize(width(), height() - 50); + m_transparentFrame->move(0, 50); + m_transparentFrame->show(); + ++showFrameCount; + } else { + if (showFrameCount==1) + m_transparentFrame->hide(); + --showFrameCount; + } + + int index = m_stackWidget->currentIndex(); + if (index < 0 || index > m_stackWidget->count() - 1) { + + return; + } + + switch (index) { + case DDECalendar::CalendarYearWindow: { + m_yearwindow->setFocus(); + } break; + case DDECalendar::CalendarMonthWindow: { + m_monthWindow->setFocus(); + } break; + case DDECalendar::CalendarWeekWindow: { + m_weekWindow->setFocus(); + } break; + case DDECalendar::CalendarDayWindow: { + m_DayWindow->setFocus(); + } break; + } +} + +void Calendarmainwindow::slotCurrentDate(QDate date) +{ + m_currentdate = date; + CScheduleDataManage::getScheduleDataManage()->setCurrentYear(date.year()); + getScheduleInfo(); +} + +void Calendarmainwindow::slotSetButtonBox() +{ + m_buttonBox->setEnabled(true); +} +void Calendarmainwindow::closeEvent(QCloseEvent *event) +{ + QWidget::closeEvent(event); +} + +void Calendarmainwindow::mouseMoveEvent(QMouseEvent *event) +{ + DMainWindow::mouseMoveEvent(event); + setScheduleHide(); +} + +void Calendarmainwindow::changeEvent(QEvent *event) +{ + DMainWindow::changeEvent(event); + + if (event->type() == QEvent::ActivationChange) { + setScheduleHide(); + } +} + +void Calendarmainwindow::mousePressEvent(QMouseEvent *event) +{ + Q_UNUSED(event); + setScheduleHide(); +} + diff -Nru dde-calendar-5.7.0.4/src/widget/calendarmainwindow.h dde-calendar-5.7.0.23/src/widget/calendarmainwindow.h --- dde-calendar-5.7.0.4/src/widget/calendarmainwindow.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/calendarmainwindow.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ + +#ifndef CALENDARMAINWINDOW_H +#define CALENDARMAINWINDOW_H + +#include "dbusdatagetthread.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +DWIDGET_USE_NAMESPACE +class CYearWindow; +class CMonthWindow; +class CWeekWindow; +class CDayWindow; +class __Scheduler; +class CSchceduleSearchView; +class AnimationStackedWidget; +class CScheduleDataManage; +class Calendarmainwindow : public DMainWindow +{ + Q_OBJECT +public: + explicit Calendarmainwindow(QWidget *w = nullptr); + ~Calendarmainwindow() override; + bool analysisCreate(const QString &content, ScheduleDtailInfo &info); + void viewWindow(int type, QDateTime datetime); + void UpdateJob(); + void updateHigh(); + void setSearchWidth(int w); +public slots: + void slotTheme(int type); + void OpenSchedule(QString job); + void ActiveWindow(); + void RaiseWindow(); + void onViewShortcut(); + void slotGetScheduleInfoSuccess(); + void slotDynamicIconUpdate(); +private: + void initUI(); + void initConnection(); + void initLunar(); + void createview(); + DPushButton *createButon(QString name); + + void getScheduleInfo(); +protected: + void resizeEvent(QResizeEvent *event) override; + void closeEvent(QCloseEvent *event) override; + void mouseMoveEvent(QMouseEvent *event) override; + void changeEvent(QEvent *event) override; + void mousePressEvent(QMouseEvent *event) override; +private slots: + void setScheduleHide(); + void slotstackWClicked(QAbstractButton *bt); + void slotWUpdateShcedule(QMainWindow *w, int id = 0); + void slotReturnTodyUpdate(QMainWindow *w); + void slotSreturnPressed(); + void slotStextChanged(); + void slotStextfocusChanged(bool onFocus); + void slotJobsUpdated(const QList &Ids); + void slotSearchEdit(); + void slotTransitSearchSchedule(int id = 0); + void slotsearchDateSelect(QDate date); + void slotSearchSelectSchedule(const ScheduleDtailInfo &scheduleInfo); + + void slotdoubleclickDate(QDate date); + void slotselectMonth(QDate date); + void slotselectWeek(QDate date); + + void slotCurrentScheduleDate(QDate date); + void slotViewSelectDate(QDate date); + void slotViewtransparentFrame(int type); + void slotCurrentDate(QDate date); + void slotSetButtonBox(); +private: + DLabel *m_icon = nullptr; + AnimationStackedWidget *m_stackWidget = nullptr; + DButtonBox *m_buttonBox = nullptr; + DButtonBoxButton *m_yearButton = nullptr; + DButtonBoxButton *m_monthButton = nullptr; + DButtonBoxButton *m_weekButton = nullptr; + DButtonBoxButton *m_dayButton = nullptr; + DSearchEdit *m_searchEdit = nullptr; + CYearWindow *m_yearwindow = nullptr; + CMonthWindow *m_monthWindow = nullptr; + CWeekWindow *m_weekWindow = nullptr; + CDayWindow *m_DayWindow = nullptr; + __Scheduler *m_dbus = nullptr; + bool m_searchflag = false; + CSchceduleSearchView *m_schceduleSearchView = nullptr; + DFrame *m_contentBackground = nullptr; + int m_priindex = 3; //默认打开日视图双击 + DFrame *m_transparentFrame = nullptr; + bool m_opensearchflag = false; + QDate m_currentdate; + int m_scheduleSearchViewMaxWidth; + QPropertyAnimation *m_animation = nullptr; + DbusDataGetThread *m_DataGetThread = nullptr; + QTimer *m_DynamicIconUpdateTimer = nullptr; +}; + +#endif // CALENDARMAINWINDOW_H diff -Nru dde-calendar-5.7.0.4/src/widget/dayWidget/dayhuangliview.cpp dde-calendar-5.7.0.23/src/widget/dayWidget/dayhuangliview.cpp --- dde-calendar-5.7.0.4/src/widget/dayWidget/dayhuangliview.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/dayWidget/dayhuangliview.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#include "dayhuangliview.h" +#include "schceduledlg.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +CDayHuangLiLabel::CDayHuangLiLabel(QWidget *parent) + : DLabel(parent) +{ + setMargin(0); +} + +void CDayHuangLiLabel::setbackgroundColor(QColor backgroundColor) +{ + m_backgroundColor = backgroundColor; +} + +void CDayHuangLiLabel::setTextInfo(QColor tcolor, QFont font) +{ + m_textcolor = tcolor; + m_font = font; +} + +void CDayHuangLiLabel::setHuangLiText(QStringList vhuangli, int type) +{ + m_vHuangli = vhuangli; + m_type = type; + if (!vhuangli.isEmpty()) { + QString str = vhuangli.at(0); + for (int i = 1; i < vhuangli.count(); i++) { + str += "." + vhuangli.at(i); + } + setToolTip(str); + } else { + setToolTip(QString()); + } + update(); +} +void CDayHuangLiLabel::paintEvent( QPaintEvent *e ) +{ + Q_UNUSED(e); + int labelwidth = width(); + int labelheight = height(); + + QPainter painter(this); + QRect fillRect = QRect(0, 0, labelwidth, labelheight); + painter.setRenderHints(QPainter::HighQualityAntialiasing); + painter.setBrush(QBrush(m_backgroundColor)); + painter.setPen(Qt::NoPen); + painter.drawRoundedRect(fillRect, 12, 12); + QPixmap pixmap; + if (m_type == 0) + pixmap = DHiDPIHelper::loadNxPixmap(":/resources/icon/dde-yi.svg"); + else { + pixmap = DHiDPIHelper::loadNxPixmap(":/resources/icon/dde-ji.svg"); + } + pixmap.setDevicePixelRatio(devicePixelRatioF()); + painter.save(); + painter.setRenderHint(QPainter::Antialiasing); + painter.setRenderHint(QPainter::HighQualityAntialiasing); + painter.setRenderHint(QPainter::SmoothPixmapTransform); + painter.drawPixmap(QRect(m_leftMagin, m_topMagin + 1, 22, 22), pixmap); + painter.restore(); + + painter.setFont(m_font); + painter.setPen(m_textcolor); + int bw = m_leftMagin + 34; + int bh = m_topMagin; + int ss = 14; + for (int i = 0; i < m_vHuangli.count(); i++) { + int currentsw = m_vHuangli.at(i).count() * ss; + if (bw + currentsw + 6 > labelwidth) { + painter.drawText(QRect(bw, bh, labelwidth - bw, 21), Qt::AlignLeft, "..."); + break; + } else { + painter.drawText(QRect(bw, bh, currentsw, 21), Qt::AlignLeft, m_vHuangli.at(i)); + bw += currentsw + 10; + } + } +} + +void CDayHuangLiLabel::resizeEvent(QResizeEvent *event) +{ + m_leftMagin = static_cast(0.0424 * width() + 0.5); + m_topMagin = (height() - 20) / 2; + DLabel::resizeEvent(event); +} + + diff -Nru dde-calendar-5.7.0.4/src/widget/dayWidget/dayhuangliview.h dde-calendar-5.7.0.23/src/widget/dayWidget/dayhuangliview.h --- dde-calendar-5.7.0.4/src/widget/dayWidget/dayhuangliview.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/dayWidget/dayhuangliview.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#ifndef DAYHUANGLILABEL_H +#define DAYHUANGLILABEL_H + +#include + +DWIDGET_USE_NAMESPACE +class CDayHuangLiLabel : public DLabel +{ + Q_OBJECT + +public: + explicit CDayHuangLiLabel(QWidget *parent = nullptr); + void setbackgroundColor(QColor backgroundColor); + void setTextInfo(QColor tcolor, QFont font); + void setHuangLiText(QStringList vhuangli, int type = 0); +protected: + void paintEvent(QPaintEvent *e) override; + void resizeEvent(QResizeEvent *event) override; +private: + QStringList m_vHuangli; + QColor m_backgroundColor; + QColor m_textcolor; + QFont m_font; + int m_type = 0; + int m_leftMagin = 14; + int m_topMagin = 18; +}; + +#endif // DAYHUANGLILABEL_H diff -Nru dde-calendar-5.7.0.4/src/widget/dayWidget/daymonthview.cpp dde-calendar-5.7.0.23/src/widget/dayWidget/daymonthview.cpp --- dde-calendar-5.7.0.4/src/widget/dayWidget/daymonthview.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/dayWidget/daymonthview.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,871 @@ +/* + * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ + +#include "calendardbus.h" +#include "todybutton.h" +#include "scheduledatamanage.h" +#include "daymonthview.h" +#include "constants.h" +#include "dayhuangliview.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +DGUI_USE_NAMESPACE +CDayMonthView::CDayMonthView(QWidget *parent) + : CustomFrame(parent) +{ + m_DBusInter = new CalendarDBus("com.deepin.api.LunarCalendar", + "/com/deepin/api/LunarCalendar", + QDBusConnection::sessionBus(), this); + if (!queue) + queue = new QQueue; + if (!lunarCache) + lunarCache = new QMap; + if (!emptyCaHuangLiDayInfo) + emptyCaHuangLiDayInfo = new CaHuangLiDayInfo; + + m_weeklist.append(tr("Monday")); + m_weeklist.append(tr("Tuesday")); + m_weeklist.append(tr("Wednesday")); + m_weeklist.append(tr("Thursday")); + m_weeklist.append(tr("Friday")); + m_weeklist.append(tr("Saturday")); + m_weeklist.append(tr("Sunday")); + initUI(); + initConnection(); +} + +CDayMonthView::~CDayMonthView() +{ + if (lunarCache !=nullptr) { + delete lunarCache; + lunarCache = nullptr; + } + if ( queue !=nullptr) { + delete queue; + queue = nullptr; + } + if (emptyCaHuangLiDayInfo != nullptr) { + delete emptyCaHuangLiDayInfo; + emptyCaHuangLiDayInfo = nullptr; + } +} +void CDayMonthView::handleCurrentDateChanged(const QDate date, const CaHuangLiDayInfo &detail) +{ + Q_UNUSED(detail); + if (date != m_currentDate) { + setCurrentDate(date); + } +} + +void CDayMonthView::setFirstWeekday(int weekday) +{ + m_firstWeekDay = weekday; + updateDate(); +} +void CDayMonthView::setLunarVisible(bool visible) +{ + m_huanglistate = visible; + m_yiLabel->setVisible(visible); + m_jiLabel->setVisible(visible); + m_currentLuna->setVisible(visible); + m_splitline->setVisible(visible); + update(); +} + +void CDayMonthView::setTheMe(int type) +{ + m_themetype = type; + if (type == 0 || type == 1) { + DPalette anipa = this->palette(); + QColor tbcolor = "#FFFFFF"; + anipa.setColor(DPalette::Background, tbcolor); + setPalette(anipa); + setBackgroundRole(DPalette::Background); + setBColor(tbcolor); + + DPalette todaypa = m_today->palette(); + QColor todayColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); + todaypa.setColor(DPalette::ButtonText, todayColor); + todaypa.setColor(DPalette::Dark, Qt::white); + todaypa.setColor(DPalette::Light, Qt::white); + QColor sbcolor("#002A57"); + sbcolor.setAlphaF(0.05); + todaypa.setColor(DPalette::Shadow, sbcolor); + m_today->setPalette(todaypa); + QColor todayhover = "#000000"; + todayhover.setAlphaF(0.1); + QColor todaypress = "#000000"; + todaypress.setAlphaF(0.2); + m_today->setBColor("#FFFFFF", todayhover, todaypress, "#FFFFFF", todayhover, todaypress); + m_today->setTColor(todayColor, "#001A2E", "#0081FF"); + m_today->setshadowColor(sbcolor); + DPalette prevpa = m_prevButton->palette(); + prevpa.setColor(DPalette::Dark, QColor("#E6E6E6")); + prevpa.setColor(DPalette::Light, QColor("#E3E3E3")); + + DPalette nextvpa = m_nextButton->palette(); + nextvpa.setColor(DPalette::Dark, QColor("#E6E6E6")); + nextvpa.setColor(DPalette::Light, QColor("#E3E3E3")); + + m_currentMouth->setTextColor(QColor("#3B3B3B")); + + m_currentDay->setTextColor(todayColor); + + m_currentWeek->setTextColor(QColor("#414D68")); + + m_currentLuna->setTextColor(QColor("#414D68")); + + m_currentYear->setTextColor(QColor("#414D68")); + + QFont hlabelF; + hlabelF.setPixelSize(DDECalendar::FontSizeFourteen); + + QColor yicolor = QColor("#75C18E"); + yicolor.setAlphaF(0.1); + m_yiLabel->setbackgroundColor(yicolor); + m_yiLabel->setTextInfo(QColor("#7B7B7B"), hlabelF); + m_yiLabel->update(); + + QColor jicolor = QColor("#C17575"); + jicolor.setAlphaF(0.1); + m_jiLabel->setbackgroundColor(jicolor); + m_jiLabel->setTextInfo(QColor("#7B7B7B"), hlabelF); + m_jiLabel->update(); + + m_topBorderColor = Qt::red; + m_backgroundCircleColor = "#0081FF"; + + m_defaultTextColor = Qt::black; + m_currentDayTextColor = todayColor; + m_weekendsTextColor = Qt::black; + m_selectedTextColor = Qt::white; + m_festivalTextColor = Qt::black; + m_notCurrentTextColor = "#b2b2b2"; + m_ceventColor = QColor(255, 93, 0); + } else if (type == 2) { + DPalette anipa = this->palette(); + QColor tbcolor = "#282828"; + anipa.setColor(DPalette::Background, tbcolor); + setPalette(anipa); + setBackgroundRole(DPalette::Background); + setBColor(tbcolor); + + DPalette todaypa = m_today->palette(); + QColor todayColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); + todaypa.setColor(DPalette::ButtonText, todayColor); + todaypa.setColor(DPalette::Light, "#484848"); + todaypa.setColor(DPalette::Dark, "#414141"); + QColor sbcolor("#000000"); + sbcolor.setAlphaF(0.05); + todaypa.setColor(DPalette::Shadow, sbcolor); + m_today->setPalette(todaypa); + m_today->setBColor("#484848", "#727272", "#242424", "#414141", "#535353", "#282828"); + m_today->setTColor(todayColor, "#FFFFFF", "#0081FF"); + m_today->setshadowColor(sbcolor); + DPalette prevpa = m_prevButton->palette(); + prevpa.setColor(DPalette::Dark, QColor("#484848")); + prevpa.setColor(DPalette::Light, QColor("#414141")); + DPalette nextvpa = m_nextButton->palette(); + nextvpa.setColor(DPalette::Dark, QColor("#484848")); + nextvpa.setColor(DPalette::Light, QColor("#414141")); + + m_currentMouth->setTextColor(QColor("#C0C6D4")); + + m_currentDay->setTextColor(todayColor); + + m_currentWeek->setTextColor(QColor("#C0C6D4")); + + m_currentLuna->setTextColor(QColor("#C0C6D4")); + + m_currentYear->setTextColor(QColor("#C0C6D4")); + QFont hlabelF; + hlabelF.setPixelSize(DDECalendar::FontSizeFourteen); + + QColor yicolor = QColor("#2F8C4D"); + yicolor.setAlphaF(0.2); + m_yiLabel->setbackgroundColor(yicolor); + m_yiLabel->setTextInfo(QColor("#C0C6D4"), hlabelF); + m_yiLabel->update(); + + QColor jicolor = QColor("#A43B3B"); + jicolor.setAlphaF(0.2); + m_jiLabel->setbackgroundColor(jicolor); + m_jiLabel->setTextInfo(QColor("#C0C6D4"), hlabelF); + m_jiLabel->update(); + + m_topBorderColor = Qt::red; + m_backgroundCircleColor = "#0059D2"; + + m_defaultTextColor = "#C0C6D4"; + m_currentDayTextColor = todayColor; + m_weekendsTextColor = Qt::black; + m_selectedTextColor = "#B8D3FF"; + m_festivalTextColor = Qt::black; + m_notCurrentTextColor = "#C0C6D4"; + m_notCurrentTextColor.setAlphaF(0.5); + m_ceventColor = QColor(204, 77, 3); + } + + for (int i(0); i != DDEDayCalendar::PainterCellNum; ++i) { + m_cellList.at(i)->update(); + } +} + +void CDayMonthView::setSearchFlag(bool flag) +{ + m_searchflag = flag; + update(); +} + +void CDayMonthView::updateFlag() +{ + getlineflag(); + update(); +} +void CDayMonthView::setCurrentDate(const QDate date, int type) +{ + Q_UNUSED(type); + + if (date.year() < DDECalendar::QueryEarliestYear) + return; + + if (date == m_currentDate) { + return; + } + + if (date == QDate::currentDate()) { + m_today->setText(QCoreApplication::translate("today", "Today", "Today")); + } else { + m_today->setText(QCoreApplication::translate("Return Today", "Today", "Return Today")); + } + + m_currentDate = date; + updateCurrentLunar(); +} + +int CDayMonthView::getDateIndex(const QDate &date) const +{ + for (int i = 0; i != DDEDayCalendar::PainterCellNum; ++i) + if (m_days[i] == date) + return i; + + return 0; +} + +bool CDayMonthView::eventFilter(QObject *o, QEvent *e) +{ + QWidget *cell = qobject_cast(o); + + if (cell && m_cellList.contains(cell)) { + const int pos = m_cellList.indexOf(cell); + QDate date = m_days[pos]; + + if (date.year() < DDECalendar::QueryEarliestYear) + return false; + + if (e->type() == QEvent::Paint) { + paintCell(cell); + } else if (e->type() == QEvent::MouseButtonPress) { + QMouseEvent *mouseEvent = dynamic_cast(e); + if (mouseEvent->button() ==Qt::LeftButton) { + cellClicked(cell); + } + } + } + return false; +} + +void CDayMonthView::updateDate() +{ + const QDate firstDay(m_currentDate.year(), m_currentDate.month(), 1); + const int day = (firstDay.dayOfWeek() + m_firstWeekDay) % 7; + const int currentIndex = day + m_currentDate.day() - 1; + + if (currentIndex < 0) { + return; + } + + for (int i(0); i != DDEDayCalendar::PainterCellNum; ++i) { + m_days[i] = firstDay.addDays(i - day); + } + + setSelectedCell(currentIndex); + getlineflag(); + update(); +} + +void CDayMonthView::getlineflag() +{ + QLocale locale; + CScheduleDataManage *tdataManage = CScheduleDataManage::getScheduleDataManage(); + m_vlineflag.resize(DDEDayCalendar::PainterCellNum); + m_vlineflag.fill(false); + QVector out; + + if (tdataManage->getscheduleDataCtrl()->getScheduleInfo(m_days[0], m_days[41], out)) { + if (out.count() == DDEDayCalendar::PainterCellNum) + for (int i = 0; i < DDEDayCalendar::PainterCellNum; i++) { + if (!out.at(i).vData.isEmpty()) { + m_vlineflag[i] = true; + } + } + } +} + +void CDayMonthView::initUI() +{ + m_dayNumFont.setPixelSize(DDECalendar::FontSizeTwelve); + + m_today = new CTodyButton; + + m_today->setText(QCoreApplication::translate("today", "Today", "Today")); + + m_today->setFixedSize(100, DDEDayCalendar::D_MLableHeight); + DPalette todaypa = m_today->palette(); + QColor todayColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); + todaypa.setColor(DPalette::ButtonText, todayColor); + todaypa.setColor(DPalette::Dark, Qt::white); + todaypa.setColor(DPalette::Light, Qt::white); + QColor sbcolor("#002A57"); + sbcolor.setAlphaF(0.05); + todaypa.setColor(DPalette::Shadow, sbcolor); + QFont todayfont; + todayfont.setPixelSize(DDECalendar::FontSizeFourteen); + m_today->setFont(todayfont); + m_today->setPalette(todaypa); + m_prevButton = new DIconButton(DStyle::SP_ArrowLeft, this); + m_prevButton->setFixedSize(36, 36); + + m_nextButton = new DIconButton(DStyle::SP_ArrowRight, this); + m_nextButton->setFixedSize(36, 36); + + QHBoxLayout *titleLayout = new QHBoxLayout; + titleLayout->setMargin(0); + titleLayout->setSpacing(0); + titleLayout->setContentsMargins(0, 0, 0, 3); + //add separator line + m_currentMouth = new CustomFrame(this); + m_currentMouth->setFixedSize(74, DDEDayCalendar::D_MLableHeight); + QFont mlabelF; + mlabelF.setWeight(QFont::Medium); + mlabelF.setPixelSize(DDECalendar::FontSizeTwentyfour); + m_currentMouth->setTextFont(mlabelF); + m_currentMouth->setTextAlign(Qt::AlignCenter); + titleLayout->addWidget(m_prevButton); + titleLayout->addWidget(m_currentMouth); + titleLayout->addWidget(m_nextButton); + titleLayout->addStretch(); + titleLayout->addWidget(m_today, 0, Qt::AlignRight); + // cells grid + m_gridLayout = new QGridLayout; + m_gridLayout->setMargin(0); + m_gridLayout->setSpacing(0); + + for (int r = 0; r != 6; ++r) { + for (int c = 0; c != 7; ++c) { + QWidget *cell = new QWidget; + cell->setFixedSize(DDEDayCalendar::DCellWidth, DDEDayCalendar::DCellHeight); + cell->installEventFilter(this); + cell->setFocusPolicy(Qt::ClickFocus); + m_gridLayout->addWidget(cell, r, c); + m_cellList.append(cell); + } + } + //上半部分 + m_upLayout = new QVBoxLayout; + m_upLayout->setMargin(0); + m_upLayout->setSpacing(0); + m_upLayout->setContentsMargins(22, 9, 0, 7); + m_upLayout->addLayout(titleLayout); + m_upLayout->addLayout(m_gridLayout); + + //中间部分 + QVBoxLayout *midLayout = new QVBoxLayout; + midLayout->setMargin(0); + midLayout->setSpacing(0); + midLayout->setContentsMargins(0, 0, 0, 20); + m_currentDay = new CustomFrame(this); + m_currentDay->setFixedHeight(DDEDayCalendar::DDLableHeight); + m_currentDay->setMinimumWidth(width()); + m_currentDay->setTextAlign(Qt::AlignCenter); + QFont daylabelF; + daylabelF.setWeight(QFont::Medium); + daylabelF.setPixelSize(DDECalendar::FontSizeOneHundred); + m_currentDay->setTextFont(daylabelF); + midLayout->addWidget(m_currentDay); + + m_currentWeek = new CustomFrame(this); + m_currentWeek->setFixedHeight(DDEDayCalendar::DWLableHeight); + m_currentWeek->setTextAlign(Qt::AlignCenter); + QFont wlabelF; + wlabelF.setPixelSize(DDECalendar::FontSizeSixteen); + m_currentWeek->setTextFont(wlabelF); + midLayout->addWidget(m_currentWeek); + midLayout->addSpacing(2); + + m_currentYear = new CustomFrame(this); + m_currentYear->setFixedHeight(DDEDayCalendar::DWLableHeight); + m_currentYear->setTextAlign(Qt::AlignCenter); + m_currentYear->setTextFont(wlabelF); + midLayout->addWidget(m_currentYear); + midLayout->addSpacing(2); + + m_currentLuna = new CustomFrame(this); + m_currentLuna->setFixedHeight(DDEDayCalendar::DHualiInfoLableHeight); + m_currentLuna->setTextAlign(Qt::AlignCenter); + QFont hlabelF; + hlabelF.setPixelSize(DDECalendar::FontSizeTwelve); + m_currentLuna->setTextFont(hlabelF); + midLayout->addWidget(m_currentLuna); + + m_yidownLayout = new QVBoxLayout; + m_yidownLayout->setMargin(0); + m_yidownLayout->setSpacing(0); + m_yidownLayout->setContentsMargins(10, 5, 10, 0); + hlabelF.setPixelSize(DDECalendar::FontSizeFourteen); + m_yiLabel = new CDayHuangLiLabel(this); + m_yiLabel->setbackgroundColor(QColor("#75C18E")); + m_yiLabel->setTextInfo(QColor("#7B7B7B "), hlabelF); + m_yiLabel->setFixedSize(DDEDayCalendar::DHualiDtailLableWidth, DDEDayCalendar::DHualiDtailLableHeight); + m_yidownLayout->addWidget(m_yiLabel); + + m_jidownLayout = new QVBoxLayout; + m_jidownLayout->setMargin(0); + m_jidownLayout->setSpacing(0); + m_jidownLayout->setContentsMargins(10, 10, 10, 10); + + m_jiLabel = new CDayHuangLiLabel(this); + m_jiLabel->setbackgroundColor(QColor("#C17575")); + m_jiLabel->setTextInfo(QColor("#7B7B7B "), hlabelF); + m_jiLabel->setFixedSize(DDEDayCalendar::DHualiDtailLableWidth, DDEDayCalendar::DHualiDtailLableHeight); + m_jidownLayout->addWidget(m_jiLabel); + + m_hhLayout = new QVBoxLayout; + m_hhLayout->setMargin(0); + m_hhLayout->setSpacing(0); + m_hhLayout->addLayout(m_upLayout); + m_hhLayout->addLayout(midLayout); + + m_splitline = new DHorizontalLine; + + m_splitline->setFixedSize(241, 2); + QHBoxLayout *hlineLayout = new QHBoxLayout; + hlineLayout->setMargin(0); + hlineLayout->setSpacing(0); + hlineLayout->setContentsMargins(0, 0, 0, 3); + hlineLayout->addStretch(1); + hlineLayout->addWidget(m_splitline); + hlineLayout->addStretch(1); + m_hhLayout->addLayout(hlineLayout); + m_hhLayout->addLayout(m_yidownLayout); + m_hhLayout->addLayout(m_jidownLayout); + m_hhLayout->addStretch(); + + setLayout(m_hhLayout); +} + +void CDayMonthView::initConnection() +{ + connect(m_prevButton, &DIconButton::clicked, this, &CDayMonthView::slotprev); + connect(m_today, &CTodyButton::clicked, this, &CDayMonthView::slottoday); + connect(m_nextButton, &DIconButton::clicked, this, &CDayMonthView::slotnext); + connect(this, &CDayMonthView::dateSelected, this, &CDayMonthView::handleCurrentDateChanged); +} + +void CDayMonthView::updateDateShow() +{ + QLocale locale; + m_currentMouth->setTextStr(locale.monthName(m_currentDate.month(), QLocale::ShortFormat)); + m_currentDay->setTextStr(QString::number(m_currentDate.day())); + + if (m_currentDate.dayOfWeek() > 0) + m_currentWeek->setTextStr(m_weeklist.at(m_currentDate.dayOfWeek() - 1)); + m_currentYear->setTextStr(m_currentDate.toString("yyyy/M")); +} + +void CDayMonthView::updateDateLunarDay() +{ + if (!m_huanglistate) return; + CaHuangLiDayInfo info = getCaHuangLiDayInfo(getDateIndex(m_currentDate)); + m_currentLuna->setTextStr(info.mGanZhiYear + "年 " + "【" + info.mZodiac + "年】" + info.mGanZhiMonth + "月 " + info.mGanZhiDay + "日 "); + QStringList yilist = info.mSuit.split(".", QString::SkipEmptyParts); + QStringList jilist = info.mAvoid.split(".", QString::SkipEmptyParts); + m_yiLabel->setHuangLiText(yilist); + m_jiLabel->setHuangLiText(jilist, 1); +} +const QString CDayMonthView::getCellDayNum(int pos) +{ + return QString::number(m_days[pos].day()); +} + +const QDate CDayMonthView::getCellDate(int pos) +{ + return m_days[pos]; +} +void CDayMonthView::paintCell(QWidget *cell) +{ + const QRect rect(0, 0, cellwidth, cellheight); + + const int pos = m_cellList.indexOf(cell); + const bool isSelectedCell = pos == m_selectedCell; + const bool isCurrentDay = getCellDate(pos) == QDate::currentDate(); + + QPainter painter(cell); + + // draw selected cell background circle + if (isSelectedCell) { + int min = 0; + //高度和宽度最小的一个 + min = cell->height() < cell->width() ? cell->height():cell->width(); + //最终rect + QRectF fillRect; + //宽度小于高度时的rect + QRectF rectByWidth = QRectF(cell->width() * 0.15, (cell->height() - cell->width() * 0.75) / 2.0, min * 0.7, min * 0.7); + //高度小于宽度时的rect + QRectF rectByHeight = QRectF((cell->width() - cell->height() * 0.75) / 2.0, cell->height() * 0.15, min * 0.7, min * 0.7); + //判断最终rect是哪一个 + fillRect = cell->height() < cell->width() ? rectByHeight : rectByWidth; + painter.save(); + painter.setRenderHint(QPainter::Antialiasing); + painter.setBrush(QBrush(CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor())); + painter.setPen(Qt::NoPen); + painter.drawEllipse(fillRect); + painter.restore(); + } + + painter.setPen(Qt::SolidLine); + + const QString dayNum = getCellDayNum(pos); + + // draw text of day + if (isSelectedCell) { + painter.setPen(m_selectedTextColor); + } else if (isCurrentDay) { + painter.setPen(m_currentDayTextColor); + } else { + if (m_currentDate.month() == getCellDate(pos).month()) + painter.setPen(m_defaultTextColor); + else + painter.setPen(m_notCurrentTextColor); + } + + QRect test; + painter.setFont(m_dayNumFont); + + painter.drawText(rect, Qt::AlignCenter, dayNum, &test); + + if (m_vlineflag.count() == DDEDayCalendar::PainterCellNum) { + if (m_vlineflag[pos]) { + painter.save(); + painter.setRenderHint(QPainter::Antialiasing); + painter.setRenderHint(QPainter::HighQualityAntialiasing); + painter.setRenderHint(QPainter::SmoothPixmapTransform); + QPen pen; + pen.setWidth(2); + pen.setColor(m_ceventColor); + painter.setPen(pen); + painter.setBrush(QBrush(m_ceventColor)); + painter.setPen(Qt::NoPen); + int r = cell->width() * (4 / 25); + + if (r < 4) { + r = 4; + } else if ( r > 7) { + r = 7; + } + painter.drawEllipse(cell->width() - r - 6, 4, r, r); + painter.restore(); + } + } + + painter.end(); +} + +void CDayMonthView::cellClicked(QWidget *cell) +{ + if (!m_cellSelectable) + return; + + const int pos = m_cellList.indexOf(cell); + + if (pos == -1) + return; + + setSelectedCell(pos); +} + +void CDayMonthView::setSelectedCell(int index) +{ + if (m_selectedCell == index) + return; + + const int prevPos = m_selectedCell; + m_selectedCell = index; + + updateDate(); + m_cellList.at(prevPos)->update(); + m_cellList.at(index)->update(); + + if (m_currentDate.year() < DDECalendar::QueryEarliestYear) + return; + emit signalcurrentDateChanged(m_days[index]); +} +void CDayMonthView::updateCurrentLunar() +{ + updateDate(); + updateDateShow(); + updateDateLunarDay(); + emit signalcurrentLunarDateChanged(m_currentDate, getCaHuangLiDayInfo(getDateIndex(m_currentDate)), 1); +} +const QString CDayMonthView::getLunar(int pos) +{ + CaHuangLiDayInfo info = getCaHuangLiDayInfo(pos); + + if (info.mLunarDayName == "初一") { + info.mLunarDayName = info.mLunarMonthName + info.mLunarDayName; + } + + if (info.mTerm.isEmpty()) + return info.mLunarDayName; + + return info.mTerm; +} + +const CaHuangLiDayInfo CDayMonthView::getCaHuangLiDayInfo(int pos) +{ + const QDate date = m_days[pos]; + + if (lunarCache->contains(date)) { + return lunarCache->value(date); + } + + if (lunarCache->size() > 40) + lunarCache->clear(); + + queue->push_back(pos); + + QTimer::singleShot(300, this, SLOT(getDbusData())); + + return *emptyCaHuangLiDayInfo; +} + +void CDayMonthView::getDbusData() +{ + if (queue->isEmpty()) + return; + + const int pos = queue->head(); + queue->pop_front(); + const QDate date = m_days[pos]; + if (!date.isValid()) { + return; + } + + CaHuangLiDayInfo currentDayInfo; + + if (!lunarCache->contains(date)) { + CaHuangLiDayInfo scurrentDayinfo; + if (m_DBusInter->GetHuangLiDayCalendar(date.year(), date.month(), date.day(), scurrentDayinfo)) { + lunarCache->insert(date, scurrentDayinfo); + currentDayInfo = scurrentDayinfo; + } + + + } else { + currentDayInfo = lunarCache->value(date); + } + + m_cellList.at(pos)->update(); + + // refresh lunar info + if (date == m_currentDate) { + updateCurrentLunar(); + } +} + +void CDayMonthView::resizeEvent(QResizeEvent *event) +{ + Q_UNUSED(event); + cellwidth = qRound(width() * 0.1005 + 0.5); + cellheight = qRound(height() * 0.0496 + 0.5); + m_gridLayout->setHorizontalSpacing(qRound(width() * 0.0287 + 0.5)); + m_gridLayout->setVerticalSpacing(0); + int leftmagin = qRound(width() * 0.0332 + 0.5); + int rightmagin = leftmagin; + int topmagin = qRound(height() * 0.0164 + 0.5); + int buttonmagin = topmagin; + m_upLayout->setContentsMargins(leftmagin, topmagin, rightmagin, buttonmagin); + m_dayNumFont.setPixelSize(qRound(12 + (width() - 347) / 71.66)); + + for (int i(0); i != DDEDayCalendar::PainterCellNum; ++i) { + m_cellList.at(i)->setFixedSize(cellwidth, cellheight); + m_cellList.at(i)->update(); + } + m_splitline->setFixedWidth(qRound(0.6925 * width() + 0.5)); + + int hleftmagin = qRound(width() * 0.026 + 0.5); + int hrightmagin = hleftmagin; + int htopmagin = qRound(height() * 0.01773 + 0.5); + int hbuttonmagin = htopmagin; + int lw = width() - hleftmagin * 2; + int lh = qRound(height() * 0.0992); + m_yiLabel->setFixedSize(lw, lh); + m_yidownLayout->setContentsMargins(hleftmagin, qRound(htopmagin * 0.5), hrightmagin, 0); + m_jiLabel->setFixedSize(lw, lh); + m_jidownLayout->setContentsMargins(hleftmagin, htopmagin, hrightmagin, hbuttonmagin); +} + +void CDayMonthView::wheelEvent(QWheelEvent *event) +{ + //如果是拖拽则退出 + bool isDragging = false; + emit signalIsDragging(isDragging); + + if (isDragging) + return; + if (event->delta() < 0) { + m_currentDate = m_currentDate.addDays(1); + + if (m_currentDate == QDate::currentDate()) { + m_today->setText(QCoreApplication::translate("today", "Today", "Today")); + } else { + m_today->setText(QCoreApplication::translate("Return Today", "Today", "Return Today")); + } + emit signalcurrentDateChanged(m_currentDate); + updateCurrentLunar(); + } else { + QDate t_curret = m_currentDate.addDays(-1); + + if (t_curret.year() < DDECalendar::QueryEarliestYear) + return; + + if (m_currentDate.year() >= DDECalendar::QueryEarliestYear) { + m_currentDate = t_curret; + + if (m_currentDate == QDate::currentDate()) { + m_today->setText(QCoreApplication::translate("today", "Today", "Today")); + } else { + m_today->setText(QCoreApplication::translate("Return Today", "Today", "Return Today")); + } + emit signalcurrentDateChanged(m_currentDate); + updateCurrentLunar(); + } else { + } + } +} + +void CDayMonthView::paintEvent(QPaintEvent *e) +{ + Q_UNUSED(e); + int labelwidth = width(); + int labelheight = height(); + DPalette anipa = this->palette(); + QPainter painter(this); + painter.save(); + painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; + painter.setBrush(anipa.background()); + painter.setPen(Qt::NoPen); + QPainterPath painterPath; + painterPath.moveTo(m_radius, 0); + + painterPath.lineTo(0, 0); + painterPath.lineTo(0, m_radius); + + painterPath.lineTo(0, labelheight - m_radius); + + painterPath.lineTo(0, labelheight); + painterPath.lineTo(m_radius, labelheight); + + painterPath.lineTo(labelwidth - m_radius, labelheight); + + if (!m_searchflag) { + painterPath.arcTo(QRect(labelwidth - m_radius * 2, labelheight - m_radius * 2, m_radius * 2, m_radius * 2), 270, 90); + } else { + painterPath.lineTo(labelwidth, labelheight); + painterPath.lineTo(labelwidth, labelheight - m_radius); + } + painterPath.lineTo(labelwidth, m_radius); + + if (!m_searchflag) { + + painterPath.arcTo(QRect(labelwidth - m_radius * 2, 0, m_radius * 2, m_radius * 2), 0, 90); + + } else { + painterPath.lineTo(labelwidth, 0); + painterPath.lineTo(labelwidth - m_radius, 0); + } + painterPath.lineTo(m_radius, 0); + painterPath.closeSubpath(); + painter.drawPath(painterPath); + painter.restore(); +} +void CDayMonthView::slotprev() +{ + emit signalSchedulHide(); + + if (m_currentDate.year() == DDECalendar::QueryEarliestYear && m_currentDate.month() == 1) + return; + + if (m_currentDate.year() >= DDECalendar::QueryEarliestYear) { + m_currentDate = m_currentDate.addMonths(-1); + + if (m_currentDate == QDate::currentDate()) { + m_today->setText(QCoreApplication::translate("today", "Today", "Today")); + } else { + m_today->setText(QCoreApplication::translate("Return Today", "Today", "Return Today")); + } + emit signalcurrentDateChanged(m_currentDate); + updateCurrentLunar(); + } else { + } +} + +void CDayMonthView::slotnext() +{ + emit signalSchedulHide(); + m_currentDate = m_currentDate.addMonths(1); + + if (m_currentDate == QDate::currentDate()) { + m_today->setText(QCoreApplication::translate("today", "Today", "Today")); + } else { + m_today->setText(QCoreApplication::translate("Return Today", "Today", "Return Today")); + } + emit signalcurrentDateChanged(m_currentDate); + updateCurrentLunar(); +} + +void CDayMonthView::slottoday() +{ + emit signalSchedulHide(); + emit signalsReturnDay(); + setCurrentDate(QDate::currentDate()); +} diff -Nru dde-calendar-5.7.0.4/src/widget/dayWidget/daymonthview.h dde-calendar-5.7.0.23/src/widget/dayWidget/daymonthview.h --- dde-calendar-5.7.0.4/src/widget/dayWidget/daymonthview.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/dayWidget/daymonthview.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,152 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#ifndef DAYMONTHVIEW_H +#define DAYMONTHVIEW_H +#include "customframe.h" +#include "calendardbus.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +DWIDGET_USE_NAMESPACE +class QLabel; +class CDayHuangLiLabel; +class CTodyButton; +class CDayMonthView: public CustomFrame +{ + Q_OBJECT + +public: + explicit CDayMonthView(QWidget *parent = nullptr); + ~CDayMonthView(); + void setFirstWeekday(int weekday); + int getDateType(const QDate &date); + inline bool cellSelectable() const + { + return m_cellSelectable; + } + void updateSelectState(); + void setLunarVisible(bool visible); + QDate getCurrDate() + { + return m_currentDate; + } + void setTheMe(int type = 0); + void setSearchFlag(bool flag); + void updateFlag(); +signals: + void dateSelected(const QDate date, const CaHuangLiDayInfo &detail) const; + void signalcurrentDateChanged(QDate date); + void signalcurrentLunarDateChanged(QDate date, CaHuangLiDayInfo detail, int type = 0); + void cellSelectableChanged(bool cellSelectable) const; + void signalsReturnDay(); + void signalSchedulHide(); + void signalIsDragging(bool &isDragging); +public slots: + void setCurrentDate(const QDate date, int type = 0); + void handleCurrentDateChanged(const QDate date, const CaHuangLiDayInfo &detail); + void slottoday(); +private: + int getDateIndex(const QDate &date) const; + const QString getCellDayNum(int pos); + const QDate getCellDate(int pos); + void paintCell(QWidget *cell); + bool eventFilter(QObject *o, QEvent *e) override; + void updateDate(); + void getlineflag(); + + const QString getLunar(int pos); + const CaHuangLiDayInfo getCaHuangLiDayInfo(int pos); + + void updateCurrentLunar(); + void initUI(); + void initConnection(); + void updateDateShow(); + void updateDateLunarDay(); +private slots: + void cellClicked(QWidget *cell); + void setSelectedCell(int index); + void slotprev(); + void slotnext(); + void getDbusData(); +protected: + void resizeEvent(QResizeEvent *event) override; + void wheelEvent(QWheelEvent *event) override; + void paintEvent(QPaintEvent *e) override; +private: + DIconButton *m_prevButton = nullptr; + DIconButton *m_nextButton = nullptr; + CTodyButton *m_today = nullptr; + CustomFrame *m_currentMouth = nullptr; + CustomFrame *m_currentDay = nullptr; + CustomFrame *m_currentYear = nullptr; + CustomFrame *m_currentWeek = nullptr; + CustomFrame *m_currentLuna = nullptr; + CDayHuangLiLabel *m_yiLabel = nullptr; + CDayHuangLiLabel *m_jiLabel = nullptr; + QList m_cellList; + QDate m_days[42]; + QDate m_currentDate; + CalendarDBus *m_DBusInter = nullptr; + int m_selectedCell = 0; + bool m_cellSelectable = true; + QFont m_dayNumFont; + + QColor m_topBorderColor = Qt::red; + QColor m_backgroundCircleColor = "#2ca7f8"; + QColor m_defaultTextColor = Qt::black; + QColor m_currentDayTextColor = "#2ca7f8"; + QColor m_weekendsTextColor = Qt::black; + QColor m_selectedTextColor = Qt::white; + QColor m_festivalTextColor = Qt::black; + QColor m_notCurrentTextColor = "#b2b2b2"; + + int m_firstWeekDay; + bool m_huanglistate = true; + QGridLayout *m_gridLayout = nullptr; + int cellwidth = 20; + int cellheight = 20; + QVBoxLayout *m_hhLayout = nullptr; + QVBoxLayout *m_upLayout = nullptr; + DHorizontalLine *m_splitline = nullptr; + QVBoxLayout *m_yidownLayout = nullptr; + QVBoxLayout *m_jidownLayout = nullptr; + QStringList m_weeklist; + QQueue *queue = nullptr; + + QMap *lunarCache = nullptr; + CaHuangLiDayInfo *emptyCaHuangLiDayInfo = nullptr; + int m_themetype = 1; + const int m_radius = 8; + bool m_searchflag = false; + QColor m_ceventColor = "#FF5D00"; + QVector m_vlineflag; //节假日和日程标识 +}; + +#endif // YEARVIEW_H diff -Nru dde-calendar-5.7.0.4/src/widget/dayWidget/daywindow.cpp dde-calendar-5.7.0.23/src/widget/dayWidget/daywindow.cpp --- dde-calendar-5.7.0.4/src/widget/dayWidget/daywindow.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/dayWidget/daywindow.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,322 @@ +/* + * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#include "daywindow.h" +#include "constants.h" +#include "customframe.h" +#include "daymonthview.h" +#include "schcedulesearchview.h" +#include "scheduleview.h" + +#include + +#include +#include + +DGUI_USE_NAMESPACE +CDayWindow::CDayWindow(QWidget *parent) + : QMainWindow(parent) +{ + initUI(); + initConnection(); +} + +CDayWindow::~CDayWindow() {} +void CDayWindow::setTheMe(int type) +{ + if (type == 0 || type == 1) { + DPalette anipa = m_contentBackground->palette(); + anipa.setColor(DPalette::Background, "#F8F8F8"); + m_contentBackground->setPalette(anipa); + m_contentBackground->setBackgroundRole(DPalette::Background); + + m_leftground->setBColor("#FFFFFF"); + + DPalette ypa = m_YearLabel->palette(); + ypa.setColor(DPalette::WindowText, QColor("#3B3B3B")); + m_YearLabel->setPalette(ypa); + m_YearLabel->setForegroundRole(DPalette::WindowText); + DPalette lpa = m_LunarLabel->palette(); + lpa.setColor(DPalette::WindowText, QColor("#8A8A8A")); + m_LunarLabel->setPalette(lpa); + m_LunarLabel->setForegroundRole(DPalette::WindowText); + DPalette spa = m_SolarDay->palette(); + spa.setColor(DPalette::WindowText, Qt::red); + m_SolarDay->setPalette(spa); + m_SolarDay->setForegroundRole(DPalette::WindowText); + } else if (type == 2) { + DPalette anipa = m_contentBackground->palette(); + QColor bcolor = "#252525"; + anipa.setColor(DPalette::Background, bcolor); + m_contentBackground->setPalette(anipa); + m_contentBackground->setBackgroundRole(DPalette::Background); + m_leftground->setBColor("#282828"); + + DPalette ypa = m_YearLabel->palette(); + ypa.setColor(DPalette::WindowText, QColor("#C0C6D4")); + m_YearLabel->setPalette(ypa); + m_YearLabel->setForegroundRole(DPalette::WindowText); + DPalette lpa = m_LunarLabel->palette(); + lpa.setColor(DPalette::WindowText, QColor("#798BA8")); + m_LunarLabel->setPalette(lpa); + m_LunarLabel->setForegroundRole(DPalette::WindowText); + DPalette spa = m_SolarDay->palette(); + spa.setColor(DPalette::WindowText, Qt::red); + m_SolarDay->setPalette(spa); + m_SolarDay->setForegroundRole(DPalette::WindowText); + } + m_daymonthView->setTheMe(type); + m_scheduleView->setTheMe(type); +} + +void CDayWindow::setTime(QTime time) +{ + m_scheduleView->setTime(time); +} + +void CDayWindow::updateHigh() +{ + m_scheduleView->updateHigh(); +} +void CDayWindow::setDate(QDate date) +{ + if (!date.isValid()) + return; + + m_currentdate = date; + m_daymonthView->setFirstWeekday(0); + m_daymonthView->setCurrentDate(date); + int w = m_scheduleView->width() - 72; + m_scheduleView->setRange(w, 1032, m_currentdate, m_currentdate); + emit signalCurrentDate(date); +} + +void CDayWindow::setSelectSchedule(const ScheduleDtailInfo &scheduleInfo) +{ + m_scheduleView->setSelectSchedule(scheduleInfo); + +} + +void CDayWindow::setSearchWFlag(bool flag) +{ + m_searchfalg = flag; + m_daymonthView->setSearchFlag(flag); +} + +void CDayWindow::clearSearch() +{ +} + +void CDayWindow::setLunarVisible(bool state) +{ + m_LunarLabel->setVisible(state); + m_SolarDay->setVisible(state); + m_scheduleView->setLunarVisible(state); + m_daymonthView->setLunarVisible(state); +} + +void CDayWindow::initUI() +{ + m_contentBackground = new DFrame; + m_contentBackground->setAutoFillBackground(true); + DPalette anipa = m_contentBackground->palette(); + anipa.setColor(DPalette::Background, "#F8F8F8"); + m_contentBackground->setPalette(anipa); + m_contentBackground->setFrameRounded(true); + m_contentBackground->setLineWidth(0); + + QHBoxLayout *titleLayout = new QHBoxLayout; + titleLayout->setMargin(0); + titleLayout->setSpacing(0); + titleLayout->setContentsMargins(10, 9, 0, 3); + + m_YearLabel = new QLabel(); + m_YearLabel->setMinimumHeight(DDEDayCalendar::D_YLableHeight); + QFont labelF; + labelF.setWeight(QFont::Medium); + labelF.setPixelSize(DDECalendar::FontSizeTwentyfour); + m_YearLabel->setFont(labelF); + DPalette ypa = m_YearLabel->palette(); + ypa.setColor(DPalette::WindowText, QColor("#3B3B3B")); + m_YearLabel->setPalette(ypa); + titleLayout->addWidget(m_YearLabel); + m_LunarLabel = new QLabel(); + titleLayout->addSpacing(15); + m_LunarLabel->setFixedHeight(DDEDayCalendar::D_YLableHeight); + labelF.setPixelSize(DDECalendar::FontSizeFourteen); + m_LunarLabel->setFont(labelF); + m_LunarLabel->setAlignment(Qt::AlignCenter); + DPalette lpa = m_LunarLabel->palette(); + lpa.setColor(DPalette::WindowText, QColor("#8A8A8A")); + m_LunarLabel->setPalette(lpa); + titleLayout->addWidget(m_LunarLabel); + m_SolarDay = new QLabel(); + labelF.setPixelSize(DDECalendar::FontSizeTen); + m_SolarDay->setFixedHeight(DDEDayCalendar::D_YLableHeight); + m_SolarDay->setFont(labelF); + m_SolarDay->setAlignment(Qt::AlignCenter); + DPalette spa = m_SolarDay->palette(); + spa.setColor(DPalette::WindowText, Qt::red); + m_SolarDay->setPalette(spa); + titleLayout->addWidget(m_SolarDay); + titleLayout->addStretch(); + + QVBoxLayout *leftLayout = new QVBoxLayout; + leftLayout->setMargin(0); + leftLayout->setSpacing(0); + m_scheduleView = new CScheduleView(this, 1); + m_scheduleView->setviewMagin(72, 109, 20, 0); + m_scheduleView->setRange(423, 1032, QDate(2019, 8, 12), QDate(2019, 8, 12)); + leftLayout->addLayout(titleLayout); + leftLayout->addWidget(m_scheduleView); + + m_verline = new DVerticalLine; + m_verline->setFixedWidth(2); + + m_daymonthView = new CDayMonthView(this); + + QHBoxLayout *lfetmainLayout = new QHBoxLayout; + lfetmainLayout->setMargin(0); + lfetmainLayout->setSpacing(1); + lfetmainLayout->setContentsMargins(0, 0, 0, 0); + lfetmainLayout->addLayout(leftLayout); + lfetmainLayout->addWidget(m_verline); + + lfetmainLayout->addWidget(m_daymonthView); + m_leftground = new CustomFrame(); + m_leftground->setRoundState(true, true, true, true); + m_leftground->setLayout(lfetmainLayout); + m_leftground->setBColor("#FFFFFF"); + + m_mainLayout = new QHBoxLayout; + m_mainLayout->setMargin(0); + m_mainLayout->setSpacing(0); + m_mainLayout->setContentsMargins(10, 10, 10, 10); + m_mainLayout->addWidget(m_leftground); + + m_contentBackground->setLayout(m_mainLayout); + + setCentralWidget(m_contentBackground); +} + +void CDayWindow::initConnection() +{ + connect(m_daymonthView, &CDayMonthView::signalcurrentLunarDateChanged, this, + &CDayWindow::slotcurrentDateLunarChanged); + connect(m_daymonthView, &CDayMonthView::signalcurrentDateChanged, this, + &CDayWindow::slotcurrentDateChanged); + connect(m_daymonthView, &CDayMonthView::signalsReturnDay, this, + &CDayWindow::slotCurrentReturnDay); + connect(m_scheduleView, &CScheduleView::signalViewtransparentFrame, this, + &CDayWindow::signalViewtransparentFrame); + + connect(m_scheduleView, &CScheduleView::signalsUpdateShcedule, this, + &CDayWindow::slotTransitSchedule); + connect(m_daymonthView, &CDayMonthView::signalSchedulHide + , this, &CDayWindow::slotScheduleHide); + + connect(m_daymonthView,&CDayMonthView::signalIsDragging, + this,&CDayWindow::slotIsDragging); +} + +void CDayWindow::slotupdateSchedule(int id) +{ + Q_UNUSED(id); + m_daymonthView->setCurrentDate(m_currentdate); + m_scheduleView->setRange(m_currentdate, m_currentdate); + m_daymonthView->updateFlag(); +} + +void CDayWindow::slotTransitSchedule(int id) +{ + emit signalsWUpdateShcedule(this, id); + m_daymonthView->updateFlag(); +} + +void CDayWindow::slotTransitSearchSchedule(int id) +{ + m_scheduleView->slotupdateSchedule(); + emit signalsWUpdateShcedule(this, id); +} + +void CDayWindow::slotReturnTodayUpdate() +{ + m_daymonthView->slottoday(); +} + +void CDayWindow::slotCurrentReturnDay() +{ + emit signalsReturnTodayUpdate(this); +} + +void CDayWindow::slotScheduleHide() +{ + m_scheduleView->slotScheduleShow(false); +} + +void CDayWindow::resizeEvent(QResizeEvent *event) +{ + Q_UNUSED(event); + qreal dw = 0.4046 * width(); + int dh = height() - 20; + + if (m_searchfalg) { + m_mainLayout->setContentsMargins(10, 10, 0, 10); + } else { + m_mainLayout->setContentsMargins(10, 10, 10, 10); + } + + if (dw < 350) + dw = 350; + m_daymonthView->setFixedSize(qRound(dw), dh); +} + +void CDayWindow::slotcurrentDateLunarChanged(QDate date, CaHuangLiDayInfo detail, int type) +{ + m_currentdate = date; + + if (type == 1) { + QLocale locale; + + if (locale.language() == QLocale::Chinese) { + m_YearLabel->setText(QString::number(date.year()) + tr("Y") + + QString::number(date.month()) + tr("M") + + QString::number(date.day()) + tr("D")); + } else { + m_YearLabel->setText(locale.toString(date, "yyyy/M/d")); + } + m_LunarLabel->setText(detail.mLunarMonthName + detail.mLunarDayName); + } +} + +void CDayWindow::slotcurrentDateChanged(QDate date) +{ + setDate(date); + slotupdateSchedule(1); +} + +void CDayWindow::slotsearchDateSelect(QDate date) +{ + setDate(date); + slotupdateSchedule(1); +} + +void CDayWindow::slotIsDragging(bool &isDragging) +{ + isDragging = m_scheduleView->IsDragging(); +} diff -Nru dde-calendar-5.7.0.4/src/widget/dayWidget/daywindow.h dde-calendar-5.7.0.23/src/widget/dayWidget/daywindow.h --- dde-calendar-5.7.0.4/src/widget/dayWidget/daywindow.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/dayWidget/daywindow.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#ifndef DAYWINDOW_H +#define DAYWINDOW_H + +#include "calendardbus.h" +#include "schedulestructs.h" + +#include +#include + +#include +#include +#include +DWIDGET_USE_NAMESPACE + +class CDayMonthView; +class CScheduleView; +class CSchceduleSearchView; +class QHBoxLayout; +class CustomFrame; +class CDayWindow: public QMainWindow +{ + Q_OBJECT +public: + CDayWindow(QWidget *parent = nullptr); + ~CDayWindow(); + void setDate(QDate date); + void setSelectSchedule(const ScheduleDtailInfo &scheduleInfo); + void setSearchWFlag(bool flag); + void clearSearch(); + void setLunarVisible(bool state); + void setTheMe(int type = 0); + void setTime(QTime time); + void updateHigh(); +private: + void initUI(); + void initConnection(); +signals: + void dateSelected(const QDate date, const CaLunarDayInfo &detail) const; + void signalsWUpdateShcedule(QMainWindow *w, int id = 0); + void signalsReturnTodayUpdate(QMainWindow *w); + void signalViewtransparentFrame(int type); + void signalCurrentDate(QDate date); +public slots: + void slotupdateSchedule(int id = 0); + void slotTransitSchedule(int id = 0); + void slotTransitSearchSchedule(int id = 0); + void slotReturnTodayUpdate(); + void slotCurrentReturnDay(); + void slotScheduleHide(); +protected: + void resizeEvent(QResizeEvent *event) override; +private slots: + void slotcurrentDateLunarChanged(QDate date, CaHuangLiDayInfo detail, int type = 0); + void slotcurrentDateChanged(QDate date); + void slotsearchDateSelect(QDate date); + void slotIsDragging(bool &isDragging); +private: + CDayMonthView *m_daymonthView = nullptr; + DFrame *m_contentBackground = nullptr; + CustomFrame *m_leftground = nullptr; + DVerticalLine *m_verline = nullptr; + QDate m_currentdate; + QLabel *m_YearLabel = nullptr; + QLabel *m_LunarLabel = nullptr; + QLabel *m_SolarDay = nullptr; + CScheduleView *m_scheduleView = nullptr; + QString m_searchText; + bool m_searchfalg = false; + QHBoxLayout *m_mainLayout = nullptr; +}; + +#endif // YEARWINDOW_H diff -Nru dde-calendar-5.7.0.4/src/widget/monthWidget/monthdayview.cpp dde-calendar-5.7.0.23/src/widget/monthWidget/monthdayview.cpp --- dde-calendar-5.7.0.4/src/widget/monthWidget/monthdayview.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/monthWidget/monthdayview.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,320 @@ +/* + * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ + +#include "monthdayview.h" +#include "scheduledatamanage.h" +#include "constants.h" + +#include +#include + +#include +#include +#include +#include +#include +#include + +DGUI_USE_NAMESPACE +CMonthDayView::CMonthDayView(QWidget *parent) + : DFrame(parent) +{ + QHBoxLayout *hboxLayout = new QHBoxLayout; + hboxLayout->setMargin(0); + hboxLayout->setSpacing(0); + hboxLayout->setContentsMargins(10, 0, 10, 0); + m_monthWidget = new CMonthWidget(this); + hboxLayout->addWidget(m_monthWidget); + setLayout(hboxLayout); + setFrameRounded(true); + setLineWidth(0); + setWindowFlags(Qt::FramelessWindowHint); + + connect(m_monthWidget, + &CMonthWidget::signalsSelectDate, + this, + &CMonthDayView::signalsSelectDate); +} + +CMonthDayView::~CMonthDayView() +{ +} + +void CMonthDayView::setCurrentDate(const QDate date) +{ + m_selectDate = date; + m_days[5] = m_selectDate; + + for (int i(4); i >= 0; i--) { + m_days[4 - i] = m_selectDate.addMonths(-i - 1); + } + for (int i(6); i != DDEMonthCalendar::MonthNumofYear; ++i) { + m_days[i] = m_selectDate.addMonths(i - 5); + } + update(); + m_monthWidget->setDate(m_days); +} + +void CMonthDayView::setRCurrentDate(const QDate date) +{ + if (m_selectDate == date) return; + + m_selectDate = date; + m_days[5] = m_selectDate; + + for (int i(4); i >= 0; i--) { + m_days[4 - i] = m_selectDate.addMonths(-i - 1); + } + + for (int i(6); i != DDEMonthCalendar::MonthNumofYear; ++i) { + m_days[i] = m_selectDate.addMonths(i - 5); + } + + m_monthWidget->setDate(m_days); + update(); +} + +void CMonthDayView::setTheMe(int type) +{ + QColor frameclor; + + if (type == 0 || type == 1) { + frameclor = "#FFFFFF"; + } else if (type == 2) { + frameclor = "#FFFFFF"; + frameclor.setAlphaF(0.05); + } + + DPalette anipa = palette(); + anipa.setColor(DPalette::Background, frameclor); + setPalette(anipa); + setBackgroundRole(DPalette::Background); + CMonthRect::setTheMe(type); +} + +void CMonthDayView::setsearchfalg(bool flag) +{ + m_searchfalg = flag; +} + +CMonthWidget::CMonthWidget(QWidget *parent) + :QWidget(parent) +{ + for (int i = 0; i < DDEMonthCalendar::MonthNumofYear; ++i) { + CMonthRect *monthrect = new CMonthRect(); + m_MonthItem.append(monthrect); + } +} + +CMonthWidget::~CMonthWidget() +{ + for (int i = 0; i < DDEMonthCalendar::MonthNumofYear; ++i) { + CMonthRect *monthrect = m_MonthItem.at(i); + delete monthrect; + } + + m_MonthItem.clear(); +} + +void CMonthWidget::setDate(const QDate date[12]) +{ + for (int i = 0; i < DDEMonthCalendar::MonthNumofYear; ++i) { + m_MonthItem.at(i)->setDate(date[i]); + } + + CMonthRect::setSelectRect(m_MonthItem.at(5)); + update(); +} + +void CMonthWidget::resizeEvent(QResizeEvent *event) +{ + Q_UNUSED(event); + updateSize(); +} + +void CMonthWidget::mousePressEvent(QMouseEvent *event) +{ + if (event->button() ==Qt::RightButton) + return; + + int itemindex = getMousePosItem(event->pos()); + + if (!(itemindex<0)) { + if (m_MonthItem.at(itemindex)->getDate().year() < DDECalendar::QueryEarliestYear) { + return; + } + CMonthRect::setSelectRect(m_MonthItem.at(itemindex)); + emit signalsSelectDate(m_MonthItem.at(itemindex)->getDate()); + } + update(); +} + +void CMonthWidget::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event); + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; + + for (int i = 0; i < m_MonthItem.size(); ++i) { + m_MonthItem.at(i)->paintItem(&painter, + m_MonthItem.at(i)->rect()); + } + painter.end(); +} + +void CMonthWidget::updateSize() +{ + qreal w= this->width()/m_MonthItem.size(); + + for (int i = 0; i < m_MonthItem.size(); ++i) { + m_MonthItem.at(i)->setRect(i*w,0,w,this->height()); + } + update(); +} + +int CMonthWidget::getMousePosItem(const QPointF &pos) +{ + int res =-1; + + for (int i = 0 ; i < m_MonthItem.size(); ++i) { + if (m_MonthItem.at(i)->rect().contains(pos)) { + res = i; + break; + } + } + + return res; +} + + +int CMonthRect::m_themetype ; +qreal CMonthRect::m_DevicePixelRatio; + +QColor CMonthRect::m_defaultTextColor; +QColor CMonthRect::m_backgrounddefaultColor ; +QColor CMonthRect::m_currentDayTextColor; +QColor CMonthRect::m_backgroundcurrentDayColor; +QColor CMonthRect::m_fillColor; +QFont CMonthRect::m_dayNumFont; +CMonthRect *CMonthRect::m_SelectRect = nullptr; + +CMonthRect::CMonthRect() +{ + m_dayNumFont.setPixelSize(DDECalendar::FontSizeSixteen); + m_dayNumFont.setWeight(QFont::Light); +} + +void CMonthRect::setDate(const QDate &date) +{ + m_Date = date; +} + +QDate CMonthRect::getDate() const +{ + return m_Date; +} + +QRectF CMonthRect::rect() const +{ + return m_rect; +} + +void CMonthRect::setRect(const QRectF &rect) +{ + m_rect = rect; +} + +void CMonthRect::setRect(qreal x, qreal y, qreal w, qreal h) +{ + m_rect.setRect(x,y,w,h); +} + +void CMonthRect::paintItem(QPainter *painter, const QRectF &rect) +{ + m_selectColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); + + if (m_Date.year() < DDECalendar::QueryEarliestYear) + return; + const bool isCurrentDay = (m_Date.month() == QDate::currentDate().month() + && m_Date.year() == QDate::currentDate().year()); + + painter->setPen(Qt::SolidLine); + + const QString dayNum = QString::number(m_Date.month()); + + if (m_SelectRect ==this) { + QRectF fillRect((rect.width() - 36) / 2 +rect.x() + 6, + (rect.height() - 36) / 2 + 7 +rect.y(), + 24, + 24); + painter->setBrush(QBrush(m_selectColor)); + painter->setPen(Qt::NoPen); + painter->drawEllipse(fillRect); + painter->setRenderHint(QPainter::HighQualityAntialiasing); + painter->setPen(m_currentDayTextColor); + painter->setFont(m_dayNumFont); + painter->drawText(rect, Qt::AlignCenter, dayNum); + } else { + if (isCurrentDay) { + painter->setPen(m_backgroundcurrentDayColor); + } else { + painter->setPen(m_defaultTextColor); + } + painter->setFont(m_dayNumFont); + painter->drawText(rect, Qt::AlignCenter, dayNum); + } + +} + +void CMonthRect::setDevicePixelRatio(const qreal pixel) +{ + m_DevicePixelRatio = pixel; +} + +void CMonthRect::setTheMe(int type) +{ + m_themetype = type; + QColor frameclor; + + if (type == 0 || type == 1) { + m_defaultTextColor = Qt::black; + m_backgrounddefaultColor = Qt::white; + m_currentDayTextColor = Qt::white; + m_backgroundcurrentDayColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); + m_fillColor = "#FFFFFF"; + frameclor = m_fillColor; + m_fillColor.setAlphaF(0); + } else if (type == 2) { + m_defaultTextColor = "#C0C6D4"; + QColor framecolor = Qt::black; + framecolor.setAlphaF(0.5); + m_backgrounddefaultColor = framecolor; + m_currentDayTextColor = "#C0C6D4"; + m_backgroundcurrentDayColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); + m_fillColor = "#FFFFFF"; + m_fillColor.setAlphaF(0.05); + frameclor = m_fillColor; + m_fillColor.setAlphaF(0); + } +} + +void CMonthRect::setSelectRect(CMonthRect *selectRect) +{ + m_SelectRect =selectRect; +} diff -Nru dde-calendar-5.7.0.4/src/widget/monthWidget/monthdayview.h dde-calendar-5.7.0.23/src/widget/monthWidget/monthdayview.h --- dde-calendar-5.7.0.4/src/widget/monthWidget/monthdayview.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/monthWidget/monthdayview.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#ifndef MONTHDAYVIEW_H +#define MONTHDAYVIEW_H + +#include + +#include +#include + +DWIDGET_USE_NAMESPACE + +class CMonthWidget; +class CMonthDayView : public DFrame +{ + Q_OBJECT +public: + explicit CMonthDayView(QWidget *parent = nullptr); + ~CMonthDayView(); + void setCurrentDate(const QDate date); + void setRCurrentDate(const QDate date); + void setTheMe(int type = 0); + void setsearchfalg(bool flag); +signals: + void signalsSelectDate(QDate date); + void signalsCurrentDate(QDate date); +private: + CMonthWidget *m_monthWidget = nullptr; + QDate m_selectDate; + QDate m_days[12]; + + int m_fixwidth = 200; + int m_realwidth = 100; + bool m_searchfalg = false; +}; + +class CMonthRect; +class CMonthWidget : public QWidget +{ + Q_OBJECT +public: + CMonthWidget(QWidget *parent = nullptr); + ~CMonthWidget() override; + void setDate(const QDate date[12]); +protected: + void resizeEvent(QResizeEvent *event) override; + void mousePressEvent(QMouseEvent *event) override; + void paintEvent(QPaintEvent *event) override; +private: + void updateSize(); + int getMousePosItem(const QPointF &pos); +signals: + void signalsSelectDate(QDate date); +private: + QVector m_MonthItem; + QDate m_days[12]; + +}; + +class CMonthRect +{ +public: + CMonthRect(); + void setDate(const QDate &date); + QDate getDate()const; + QRectF rect() const; + void setRect(const QRectF &rect); + inline void setRect(qreal x, qreal y, qreal w, qreal h); + void paintItem(QPainter *painter, const QRectF &rect); + void setDevicePixelRatio(const qreal pixel); + static void setTheMe(int type); + static void setSelectRect(CMonthRect *selectRect); +private: + QRectF m_rect; + QDate m_Date; + static int m_themetype ; + static qreal m_DevicePixelRatio; + + static QColor m_defaultTextColor; + static QColor m_backgrounddefaultColor; + static QColor m_currentDayTextColor; + static QColor m_backgroundcurrentDayColor; + static QColor m_fillColor; + static QFont m_dayNumFont; + static CMonthRect *m_SelectRect; + QColor m_selectColor; +}; + +#endif // MONTDAYVIEW_H diff -Nru dde-calendar-5.7.0.4/src/widget/monthWidget/monthschceduleview.cpp dde-calendar-5.7.0.23/src/widget/monthWidget/monthschceduleview.cpp --- dde-calendar-5.7.0.4/src/widget/monthWidget/monthschceduleview.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/monthWidget/monthschceduleview.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,749 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#include "monthschceduleview.h" +#include "SchecduleRemindWidget.h" +#include "monthview.h" +#include "schcedulectrldlg.h" +#include "schceduledlg.h" +#include "myschceduleview.h" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +DGUI_USE_NAMESPACE +CMonthSchceduleWidgetItem::CMonthSchceduleWidgetItem(QRect rect, QGraphicsItem *parent, int edittype) + : DragInfoItem(rect, parent) + , m_pos(13, 5) +{ + Q_UNUSED(edittype); +} + +CMonthSchceduleWidgetItem::~CMonthSchceduleWidgetItem() +{ + +} + +QPixmap CMonthSchceduleWidgetItem::getPixmap() +{ + QPixmap pixmap(this->rect().size().toSize()); + pixmap.fill(Qt::transparent); + QPainter painter(&pixmap); + paintBackground(&painter,pixmap.rect(),true); + painter.end(); + + return pixmap; +} + +void CMonthSchceduleWidgetItem::paintBackground(QPainter *painter, const QRectF &rect, const int isPixMap) +{ + qreal labelwidth = rect.width(); + qreal labelheight = rect.height(); + m_font = DFontSizeManager::instance()->get(m_sizeType, m_font); + int themetype = CScheduleDataManage::getScheduleDataManage()->getTheme(); + CSchedulesColor gdcolor = CScheduleDataManage::getScheduleDataManage()->getScheduleColorByType(m_vScheduleInfo.type.ID); + m_vHighflag = CScheduleDataManage::getScheduleDataManage()->getSearchResult(m_vScheduleInfo); + QLinearGradient linearGradient(rect.topLeft().x(), 0, rect.topRight().x(), 0); + QColor color1 = gdcolor.gradientFromC; + QColor color2 = gdcolor.gradientToC; + QColor textcolor = gdcolor.textColor; + + if (CScheduleDataManage::getScheduleDataManage()->getPressSelectInfo() == m_vScheduleInfo ) { + if (m_vScheduleInfo.IsMoveInfo == + CScheduleDataManage::getScheduleDataManage()->getPressSelectInfo().IsMoveInfo) { + m_vHighflag = true; + } else { + painter->setOpacity(0.4); + textcolor.setAlphaF(0.4); + } + m_vSelectflag = m_press; + } + + if (isPixMap) { + painter->setOpacity(0.6); + textcolor.setAlphaF(0.8); + } + + if (m_vHoverflag) { + color1 = gdcolor.hovergradientFromC; + color2 = gdcolor.hovergradientToC; + } else if (m_vHighflag) { + color1 = gdcolor.hightlightgradientFromC; + color2 = gdcolor.hightlightgradientToC; + } + + if (m_vSelectflag) { + color1 = gdcolor.pressgradientFromC; + color2 = gdcolor.pressgradientToC; + textcolor.setAlphaF(0.4); + } + + linearGradient.setColorAt(0, color1); + linearGradient.setColorAt(1, color2); + + QRectF fillRect = QRectF(rect.x()+2, + rect.y()+2, + labelwidth - 2, + labelheight - 2); + painter->save(); + //将直线开始点设为0,终点设为1,然后分段设置颜色 + painter->setBrush(linearGradient); + painter->setPen(Qt::NoPen); + painter->drawRoundedRect(fillRect, + rect.height() / 3, + rect.height() / 3); + painter->restore(); + painter->setFont(m_font); + painter->setPen(textcolor); + QFontMetrics fm = painter->fontMetrics(); + + QString tStitlename = m_vScheduleInfo.titleName; + tStitlename.replace("\n", ""); + QString str = tStitlename; + qreal textWidth = labelwidth - m_pos.x() - m_offset*2; + QString tstr; + + for (int i = 0; i < str.count(); i++) { + tstr.append(str.at(i)); + int widthT = fm.width(tstr) + 5; + if (widthT >= textWidth) { + tstr.chop(2); + break; + } + } + + if (tstr != str) { + tstr = tstr + "..."; + } + + painter->drawText(QRectF(rect.x()+m_pos.x(), + rect.y()+1, + textWidth, + labelheight - m_pos.y() + 3 ), + Qt::AlignLeft | Qt::AlignVCenter, tstr); + + if (m_vHoverflag && !m_vSelectflag) { + QRectF trect = QRectF(rect.x()+2.5, rect.y()+2.5, labelwidth - 3, labelheight - 3); + painter->save(); + painter->setRenderHints(QPainter::Antialiasing); + QPen pen; + QColor selcolor; + + if (themetype == 2) { + selcolor = "#FFFFFF"; + } else { + selcolor = "#000000"; + } + + selcolor.setAlphaF(0.08); + + pen.setColor(selcolor); + pen.setWidthF(1); + pen.setStyle(Qt::SolidLine); + painter->setBrush(Qt::NoBrush); + painter->setPen(pen); + painter->drawRoundedRect(trect, rect.height() / 3, rect.height() / 3); + painter->restore(); + } + + if (m_vSelectflag) { + QColor selcolor = "#000000"; + selcolor.setAlphaF(0.05); + painter->setBrush(selcolor); + painter->setPen(Qt::NoPen); + painter->drawRoundedRect(fillRect, rect.height() / 3, rect.height() / 3); + } +} + +CMonthSchceduleNumButton::CMonthSchceduleNumButton(QGraphicsItem *parent) + : QGraphicsRectItem(parent) +{ + +} + +CMonthSchceduleNumButton::~CMonthSchceduleNumButton() +{ + +} + +void CMonthSchceduleNumButton::setColor(QColor color1, QColor color2, bool GradientFlag) +{ + m_color1 = color1; + m_color2 = color2; + m_GradientFlag = GradientFlag; +} + +void CMonthSchceduleNumButton::setText( QColor tcolor, QFont font, QPoint pos) +{ + Q_UNUSED(pos); + m_textcolor = tcolor; + m_font = font; +} + +void CMonthSchceduleNumButton::setSizeType(DFontSizeManager::SizeType sizeType) +{ + m_SizeType = sizeType; +} + +void CMonthSchceduleNumButton::setTransparentB(bool t, QColor tcolor) +{ + m_transparentcolor = tcolor; + m_transparentf = t; +} + +void CMonthSchceduleNumButton::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + Q_UNUSED(option); + Q_UNUSED(widget); + qreal labelwidth = this->rect().width(); + qreal labelheight = this->rect().height() - 6; + qreal rectx = this->rect().x(); + qreal recty = this->rect().y(); + m_font = DFontSizeManager::instance()->get(m_SizeType, m_font); + + if (m_GradientFlag) { + QLinearGradient linearGradient(0, 0, labelwidth, 0); + linearGradient.setColorAt(0, m_color1); + linearGradient.setColorAt(1, m_color2); + QRectF fillRect = QRectF(rectx+2, recty+1, labelwidth - 2, labelheight - 1); + //将直线开始点设为0,终点设为1,然后分段设置颜色 + painter->setRenderHints(QPainter::HighQualityAntialiasing); + painter->setBrush(linearGradient); + painter->setPen(Qt::NoPen); + painter->drawRoundedRect(fillRect, 3, 2); + painter->setFont(m_font); + painter->setPen(m_textcolor); + + QString str = QString(tr("%1 more")).arg(m_num) + "..."; + QFont tfont = m_font; + QFontMetrics fm = painter->fontMetrics(); + QString tstr; + + for (int i = 0; i < str.count(); i++) { + tstr.append(str.at(i)); + int widthT = fm.width(tstr) + 5; + if (widthT >= labelwidth - m_pos.x()) { + tstr.chop(2); + break; + } + } + + if (tstr != str) { + tstr = tstr + "..."; + } + painter->drawText(QRectF(rectx+m_pos.x(), recty+m_pos.y(), labelwidth - m_pos.x(), labelheight + 4), Qt::AlignCenter, tstr); + } else { + QRectF fillRect = QRectF(rectx+2, recty+1, labelwidth - 2, labelheight - 1); + //将直线开始点设为0,终点设为1,然后分段设置颜色 + painter->setRenderHints(QPainter::HighQualityAntialiasing); + painter->setBrush(m_color1); + painter->setPen(Qt::NoPen); + painter->drawRoundedRect(fillRect, 3, 2); + + painter->setFont(m_font); + painter->setPen(m_textcolor); + painter->drawText(QRectF(rectx+m_pos.x(), + recty+m_pos.y(), + labelwidth - m_pos.x(), + labelheight + 4), + Qt::AlignLeft, + QString(tr("%1 more")).arg(m_num)); + } +} + +void CMonthSchceduleView::setTheMe(int type) +{ + Q_UNUSED(type); + updateData(); +} + +CMonthSchceduleView::CMonthSchceduleView(QWidget *parent, QGraphicsScene *scene) + : QObject(parent) + , m_Scene(scene) +{ + for (int i = 0; i < 6; ++i) { + CWeekScheduleView *weekSchedule = new CWeekScheduleView(this); + m_weekSchedule.append(weekSchedule); + } + slotFontChange(); +} + +CMonthSchceduleView::~CMonthSchceduleView() +{ + +} + +void CMonthSchceduleView::setallsize(int w, int h, int left, int top, int buttom, int itemHeight) +{ + m_width = w; + m_height = h; + m_buttommagin = buttom; + m_leftMagin = left; + m_topMagin = top; + m_cNum = static_cast(((m_height - m_topMagin - m_buttommagin) / 6.0 + 0.5 - 27) / (itemHeight + 1)); +} + +void CMonthSchceduleView::setData(QVector &data, int currentMonth) +{ + m_data = data; + m_currentMonth = currentMonth; + updateData(); +} + +void CMonthSchceduleView::slotdeleteitem( CMonthSchceduleWidgetItem *item) +{ + emit signalsUpdateShcedule(item->getData().id); +} + +void CMonthSchceduleView::slotedititem(CMonthSchceduleWidgetItem *item, int type) +{ + Q_UNUSED(type); + emit signalsUpdateShcedule(item->getData().id); +} + +void CMonthSchceduleView::slotFontChange() +{ + QFont font; + DFontSizeManager::instance()->setFontGenericPixelSize( + static_cast(DFontSizeManager::instance()->fontPixelSize(qGuiApp->font()))); + font= DFontSizeManager::instance()->t8(font); + QFontMetrics fm(font); + int h = fm.height(); + + if (m_ItemHeight != h) { + m_ItemHeight = h; + updateData(); + } +} + +bool MScheduleDateThan(const MScheduleDateRangeInfo &s1, const MScheduleDateRangeInfo &s2) +{ + if (s1.bdate != s1.edate && s2.bdate == s2.edate) { + return true; + } else if (s1.bdate == s1.edate && s2.bdate != s2.edate) { + return false; + } else if (s1.bdate != s1.edate && s2.bdate != s2.edate) { + if (s1.tData.beginDateTime == s2.tData.beginDateTime) { + return s1.bdate.daysTo(s1.edate) > s2.bdate.daysTo(s2.edate); + } else { + return s1.bdate < s2.bdate; + } + } else { + if (s1.tData.beginDateTime == s2.tData.beginDateTime) { + return s1.tData.titleName < s2.tData.titleName; + } else { + return s1.tData.beginDateTime < s2.tData.beginDateTime; + } + } +} +bool MScheduleDaysThan(const MScheduleDateRangeInfo &s1, const MScheduleDateRangeInfo &s2) +{ + return s1.bdate.daysTo(s1.edate) > s2.bdate.daysTo(s2.edate); +} +void CMonthSchceduleView::updateData() +{ + //保护数据防止越界 + if (m_data.count() != DDEMonthCalendar::ItemSizeofMonthDay || m_cNum < 1) + return; + //开始结束时间 + QDate begindate = m_data.begin()->date; + QDate enddate = m_data[m_data.count() - 1].date; + m_beginDate = begindate; + m_endDate = enddate; + + for (int i = 0 ; i < m_weekSchedule.size(); ++i) { + m_weekSchedule[i]->clearItem(); + m_weekSchedule[i]->setHeight(m_ItemHeight,qRound((m_height - m_topMagin - m_buttommagin) / 6.0-27)); + m_weekSchedule[i]->setData(m_data,i*7,7); + QVector > mSchedule = m_weekSchedule[i]->getMScheduleInfo(); + updateDateShow(mSchedule,m_weekSchedule[i]->getScheduleShowItem()); + } + return; +} + +void CMonthSchceduleView::updateHigh() +{ + for (int j = 0 ; j < m_weekSchedule.size(); ++j) { + for (int i = 0; i < m_weekSchedule[j]->getScheduleShowItem().count(); i++) { + m_weekSchedule[j]->getScheduleShowItem().at(i)->update(); + } + } +} + +QVector CMonthSchceduleView::getScheduleShowItem() const +{ + QVector m_scheduleShowItem; + + for (int j = 0 ; j < m_weekSchedule.size(); ++j) { + for (int i = 0; i < m_weekSchedule[j]->getScheduleShowItem().count(); i++) { + m_scheduleShowItem.append(m_weekSchedule[j]->getScheduleShowItem().at(i)); + } + } + + return m_scheduleShowItem; +} + +void CMonthSchceduleView::updateDate(const ScheduleDtailInfo &info) +{ + for (int i = 0 ; i < m_weekSchedule.size(); ++i) { + if (m_weekSchedule.at(i)->addData(info)) { + } else { + m_weekSchedule[i]->clearItem(); + m_weekSchedule[i]->updateSchedule(true); + }; + QVector > mSchedule = m_weekSchedule[i]->getMScheduleInfo(); + updateDateShow(mSchedule,m_weekSchedule[i]->getScheduleShowItem()); + } +} + +void CMonthSchceduleView::changeDate(const ScheduleDtailInfo &info) +{ + for (int i = 0 ; i < m_weekSchedule.size(); ++i) { + m_weekSchedule.at(i)->changeDate(info); + QVector > mSchedule = m_weekSchedule[i]->getMScheduleInfo(); + updateDateShow(mSchedule,m_weekSchedule[i]->getScheduleShowItem()); + } +} + +void CMonthSchceduleView::updateDate(const int row, const ScheduleDtailInfo &info) +{ + for (int i = 0 ; i < m_weekSchedule.size(); ++i) { + if ( row ==i) { + m_weekSchedule.at(i)->addData(info); + } else { + m_weekSchedule[i]->clearItem(); + m_weekSchedule[i]->updateSchedule(true); + }; + QVector > mSchedule = m_weekSchedule[i]->getMScheduleInfo(); + updateDateShow(mSchedule,m_weekSchedule[i]->getScheduleShowItem()); + } +} +void CMonthSchceduleView::updateDateShow(QVector > &vCMDaySchedule, QVector &schudeleShowItem) +{ + for (int i = 0; i < vCMDaySchedule.count(); i++) { + for (int j = 0; j < vCMDaySchedule[i].count(); j++) { + if (vCMDaySchedule[i].at(j).state) { + createScheduleNumWidget(vCMDaySchedule[i].at(j), i + 1,schudeleShowItem); + } else { + createScheduleItemWidget(vCMDaySchedule[i].at(j), i + 1,schudeleShowItem); + } + } + } +} + +void CMonthSchceduleView::createScheduleItemWidget(MScheduleDateRangeInfo info, int cnum,QVector &schudeleShowItem) +{ + ScheduleDtailInfo gd = info.tData; + QPoint pos; + int fw; + int fh; + computePos(cnum, info.bdate, info.edate, pos, fw, fh); + CMonthSchceduleWidgetItem *gwi = new CMonthSchceduleWidgetItem(QRect(pos.x(),pos.y(),fw,fh),nullptr); + m_Scene->addItem(gwi); + + QFont font; + + gwi->setData(gd); + + QColor TransparentC = "#000000"; + TransparentC.setAlphaF(0.05); + schudeleShowItem.append(gwi); +} + +void CMonthSchceduleView::createScheduleNumWidget(MScheduleDateRangeInfo info, int cnum,QVector &schudeleShowItem) +{ + int type = CScheduleDataManage::getScheduleDataManage()->getTheme(); + CMonthSchceduleNumButton *gwi = new CMonthSchceduleNumButton(nullptr); + QPoint pos; + int fw; + int fh; + computePos(cnum, info.bdate, info.edate, pos, fw, fh); + QColor gradientFromC = "#000000"; + gradientFromC.setAlphaF(0.00); + gwi->setColor(gradientFromC, gradientFromC, true); + QFont font; + gwi->setSizeType(DFontSizeManager::T8); + + if (type == 0 || type == 1) { + QColor tc("#5E5E5E"); + tc.setAlphaF(0.9); + gwi->setText(tc, font, QPoint(13, 3)); + } else { + QColor tc("#798190"); + tc.setAlphaF(1); + gwi->setText(tc, font, QPoint(13, 3)); + } + m_Scene->addItem(gwi); + gwi->setRect(pos.x(), + pos.y(), + fw, + fh); + gwi->setData(info.num); + gwi->setDate(info.bdate); + + if (m_currentMonth != info.bdate.month() && m_currentMonth != info.edate.month()) { + QColor TransparentC = "#000000"; + TransparentC.setAlphaF(0.05); + gwi->setTransparentB(true, TransparentC); + } + connect(gwi, &CMonthSchceduleNumButton::signalsCurrentScheduleDate, this, &CMonthSchceduleView::signalsCurrentScheduleDate); + connect(gwi, &CMonthSchceduleNumButton::signalPressScheduleShow, this, &CMonthSchceduleView::signalPressScheduleShow); + + schudeleShowItem.append(gwi); +} + +void CMonthSchceduleView::computePos(int cnum, QDate bgeindate, QDate enddate, QPoint &pos, int &fw, int &fh) +{ + int brow = static_cast((m_beginDate.daysTo(bgeindate)) / DDEMonthCalendar::AFewDaysofWeek); + int bcol = (m_beginDate.daysTo(bgeindate)) % DDEMonthCalendar::AFewDaysofWeek; + int ecol = (m_beginDate.daysTo(enddate)) % DDEMonthCalendar::AFewDaysofWeek; + + fw = static_cast((ecol - bcol + 1) * ((m_width - m_leftMagin ) / 7.0) - 11); + fh = m_ItemHeight; + int x =static_cast(m_leftMagin + bcol * ((m_width - m_leftMagin ) / 7.0) + 5); + int y = static_cast(m_topMagin + ((m_height - m_topMagin - m_buttommagin) * brow / 6.0 + 0.5) + 27 + (cnum - 1) * fh + 2.9); + pos = QPoint(x, y); +} + +CWeekScheduleView::CWeekScheduleView(QObject *parent) + : QObject(parent) + , m_ScheduleHeight(22) + , m_DayHeight(47) +{ + setMaxNum(); +} + +CWeekScheduleView::~CWeekScheduleView() +{ + +} + +void CWeekScheduleView::setData(QVector &data, const int position, const int count) +{ + int endPos = position+count; + Q_ASSERT(!(endPos>data.size())); + m_ScheduleInfo.clear(); + + for (int i = position; i=0 &&beginDate.daysTo(info.endDateTime.date())>=0) { + clearItem(); + updateSchedule(false,info); + return true; + } + + return false; +} + +void CWeekScheduleView::changeDate(const ScheduleDtailInfo &info) +{ + int index = m_ScheduleInfo.indexOf(info); + + if (index <0) { + m_ScheduleInfo.append(info); + } else { + m_ScheduleInfo[index] = info; + } + clearItem(); + updateSchedule(true); +} + +void CWeekScheduleView::setHeight(const int ScheduleHeight, const int DayHeigth) +{ + m_ScheduleHeight = ScheduleHeight; + m_DayHeight = DayHeigth; + setMaxNum(); +} + +void CWeekScheduleView::updateSchedule(const bool isNormalDisplay, const ScheduleDtailInfo &info) +{ + QVector schedulev; + schedulev.clear(); + schedulev = m_ScheduleInfo; + + if (isNormalDisplay) { + Q_UNUSED(info); + } else { + schedulev.append(info); + } + QDate tbegindate,tenddate; + QVector vMDaySchedule; + m_ColumnScheduleCount.clear(); + m_ColumnScheduleCount.fill(0,m_colum); + + for (int i = 0 ; i < schedulev.size(); ++i) { + //日程时间重新标定 + tbegindate = schedulev.at(i).beginDateTime.date(); + tenddate = schedulev.at(i).endDateTime.date(); + + if (tenddateendDate) + continue; + if (tbegindate < beginDate) tbegindate = beginDate; + if (tenddate > endDate) tenddate = endDate; + //日程信息 + MScheduleDateRangeInfo info; + info.bdate = tbegindate; + info.edate = tenddate; + info.tData = schedulev.at(i); + info.state = false; + vMDaySchedule.append(info); + qint64 pos = beginDate.daysTo(info.bdate); + qint64 count = info.bdate.daysTo(info.edate); + int j = static_cast(pos); + + for (; j < (pos+ count+1); ++j) { + ++m_ColumnScheduleCount[j]; + } + } + std::sort(vMDaySchedule.begin(),vMDaySchedule.end()); + sortAndFilter(vMDaySchedule); +} + +void CWeekScheduleView::clearItem() +{ + for (int i = 0; i < m_scheduleShowItem.count(); i++) { + + delete m_scheduleShowItem[i]; + } + m_scheduleShowItem.clear(); +} + +void CWeekScheduleView::setMaxNum() +{ + m_MaxNum = m_DayHeight/(m_ScheduleHeight+1); +} + +void CWeekScheduleView::mScheduleClear() +{ + for (int i = 0; i < m_MScheduleInfo.size(); ++i) { + m_MScheduleInfo[i].clear(); + } + m_MScheduleInfo.clear(); +} + +void CWeekScheduleView::sortAndFilter(QVector &vMDaySchedule) +{ + QVector > scheduleFill; + QVector scheduf; + //初始化 + //m_colum列 + scheduf.fill(false,m_colum); + //m_MaxNum 行 + scheduleFill.fill(scheduf,m_MaxNum); + //标签起始位置 + int postion = 0; + //标签结束位置 + int end = 0; + mScheduleClear(); + for (int i = 0 ; i < vMDaySchedule.size(); ++i) { + postion = static_cast(beginDate.daysTo(vMDaySchedule.at(i).bdate)); + end = static_cast(beginDate.daysTo(vMDaySchedule.at(i).edate)); + //初始化当前行 + int row = 0; + int pos = postion; + int count = 0; + int scheduleRow = row; + + for (; postionm_MaxNum) &&(row>=m_MaxNum-1)) { + //占用该位置 + scheduleFill[row][postion] = true; + //如果该位置不为起始位置 + if (pos !=postion) { + MScheduleDateRangeInfo scheduleInfo; + scheduleInfo.bdate = beginDate.addDays(pos); + scheduleInfo.edate = beginDate.addDays(postion -1); + scheduleInfo.state = false; + scheduleInfo.tData = vMDaySchedule.at(i).tData; + m_MScheduleInfo[row].append(scheduleInfo); + } + //设置还有xxx项 + MScheduleDateRangeInfo info; + info.bdate = beginDate.addDays(postion); + info.edate = info.bdate; + info.num = m_ColumnScheduleCount[postion] -m_MaxNum +1; + info.state = true; + m_MScheduleInfo[row].append(info); + pos = postion +1; + row = 0; + count = 0; + } else { + scheduleFill[row][postion] = true; + ++count; + scheduleRow = row; + } + break; + } else { + ++row; + } + } + } + if (pos>6||count==0) { + } else { + MScheduleDateRangeInfo scheduleInfo; + scheduleInfo.bdate = beginDate.addDays(pos); + scheduleInfo.edate = beginDate.addDays(postion -1); + scheduleInfo.state = false; + scheduleInfo.tData = vMDaySchedule.at(i).tData; + m_MScheduleInfo[scheduleRow].append(scheduleInfo); + } + } +} diff -Nru dde-calendar-5.7.0.4/src/widget/monthWidget/monthschceduleview.h dde-calendar-5.7.0.23/src/widget/monthWidget/monthschceduleview.h --- dde-calendar-5.7.0.4/src/widget/monthWidget/monthschceduleview.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/monthWidget/monthschceduleview.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,192 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#ifndef MONTHSCHCEDULEVIEW_H +#define MONTHSCHCEDULEVIEW_H + +#include "schedulestructs.h" +#include "draginfoitem.h" + +#include +#include +#include +#include + +#include +#include +#include + +DWIDGET_USE_NAMESPACE +class CMonthSchceduleWidgetItem; +class QVBoxLayout; +class CMonthSchceduleNumButton; +class SchecduleRemindWidget; +class QPropertyAnimation; +class QSequentialAnimationGroup; +class CWeekScheduleView; +class CScheduleDataManage; +class CMonthSchceduleView : public QObject +{ + Q_OBJECT + +public: + CMonthSchceduleView(QWidget *parent,QGraphicsScene *scene); + ~CMonthSchceduleView() override; + void setallsize(int w, int h, int left, int top, int buttom, int itemHeight = 22); + void setData(QVector &data, int currentMonth); + void setTheMe(int type = 0); + void updateData(); + void updateHigh(); + QVector getScheduleShowItem() const; + int getSchceduleHeight() const + { + return m_ItemHeight; + } + void updateDate(const ScheduleDtailInfo &info); + void changeDate(const ScheduleDtailInfo &info); + void updateDate(const int row,const ScheduleDtailInfo &info); +signals: + void signalsUpdateShcedule(int id = 0); + void signalsCurrentScheduleDate(QDate date); + void signalViewtransparentFrame(int type); + void signalUpdateUI(int type); + void signalPressScheduleShow(const bool isShow, const ScheduleDtailInfo &out = ScheduleDtailInfo()); +public slots: + void slotdeleteitem(CMonthSchceduleWidgetItem *item); + void slotedititem(CMonthSchceduleWidgetItem *item, int type = 0); + void slotFontChange(); +private: + void updateDateShow(QVector > &vCMDaySchedule,QVector &schudeleShowItem); + void createScheduleItemWidget(MScheduleDateRangeInfo info, int cnum,QVector &schudeleShowItem); + void createScheduleNumWidget(MScheduleDateRangeInfo info, int cnum,QVector &schudeleShowItem); + void computePos(int cnum, QDate bgeindate, QDate enddate, QPoint &pos, int &fw, int &fh); +private: + QVector m_data; + int m_cNum = 2;//日程层数 + QWidget *m_parernt = nullptr; + int m_currentMonth=0; + QDate m_beginDate; + QDate m_endDate; + int m_width =0; + int m_height=0; + int m_leftMagin=0; + int m_topMagin=0; + int m_buttommagin=0; + QVector m_weekSchedule; + int m_ItemHeight = 22; + QGraphicsScene *m_Scene = nullptr; +}; + +class CWeekScheduleView :public QObject +{ + Q_OBJECT + typedef QVector RowScheduleInfo; +public: + CWeekScheduleView(QObject *parent = nullptr); + ~CWeekScheduleView() override; + +public: + void setData(QVector &data,const int position,const int count =7); + bool addData(const ScheduleDtailInfo &info); + void changeDate(const ScheduleDtailInfo &info); + void setHeight(const int ScheduleHeight,const int DayHeigth); + QVector getMScheduleInfo() const + { + return m_MScheduleInfo; + } + QVector &getScheduleShowItem() + { + return m_scheduleShowItem; + } + void updateSchedule(const bool isNormalDisplay,const ScheduleDtailInfo &info = ScheduleDtailInfo()); + void clearItem(); +private: + void setMaxNum(); + void mScheduleClear(); + void sortAndFilter(QVector &vMDaySchedule); +private: + QVector m_scheduleShowItem; + QVector m_MScheduleInfo; + QVector m_ScheduleInfo; + QVector m_ColumnScheduleCount; + int m_ScheduleHeight=0; + int m_DayHeight=0; + int m_MaxNum=0; + QDate beginDate; + QDate endDate; + int m_colum=0; +}; + + +class CMonthSchceduleNumButton : public QObject, public QGraphicsRectItem +{ + Q_OBJECT + +public: + CMonthSchceduleNumButton(QGraphicsItem *parent = nullptr); + ~CMonthSchceduleNumButton() override; + void setColor(QColor color1, QColor color2, bool GradientFlag = false); + void setText(QColor tcolor, QFont font, QPoint pos); + void setSizeType(DFontSizeManager::SizeType sizeType); + void setTransparentB(bool t, QColor tcolor); + void setDate(QDate date) + { + m_date = date; + } + QDate getDate()const + { + return m_date; + } + void setData(int num) + { + m_num = num; + } +signals: + void signalsCurrentScheduleDate(QDate date); + void signalPressScheduleShow(const bool isShow, const ScheduleDtailInfo &out = ScheduleDtailInfo()); +protected: + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override; +private: + bool m_GradientFlag; + QColor m_color1; + QColor m_color2; + QColor m_textcolor; + QFont m_font; + QPoint m_pos; + int m_num; + QColor m_transparentcolor; + bool m_transparentf = false; + QDate m_date; + DFontSizeManager::SizeType m_SizeType = DFontSizeManager::T8; +}; + +class CMonthSchceduleWidgetItem :public DragInfoItem +{ + Q_OBJECT +public: + explicit CMonthSchceduleWidgetItem(QRect rect,QGraphicsItem *parent = nullptr, int edittype = 0); + ~CMonthSchceduleWidgetItem() override; + QPixmap getPixmap(); + +private: + void paintBackground(QPainter *painter,const QRectF &rect,const int isPixMap = false) override; +private: + QPoint m_pos; +}; + +#endif // CSHCEDULEDAYVIEW_H diff -Nru dde-calendar-5.7.0.4/src/widget/monthWidget/monthview.cpp dde-calendar-5.7.0.23/src/widget/monthWidget/monthview.cpp --- dde-calendar-5.7.0.4/src/widget/monthWidget/monthview.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/monthWidget/monthview.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,302 @@ +/* + * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ + +#include "monthview.h" +#include "calendardbus.h" +#include "schceduledlg.h" +#include "scheduledatamanage.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +DGUI_USE_NAMESPACE +void CMonthView::setTheMe(int type) +{ + m_weekIndicator->setTheMe(type); + m_MonthGraphicsView->setTheMe(type); +} + +CMonthView::CMonthView(QWidget *parent) : DWidget(parent) +{ + m_DBusInter = new CalendarDBus("com.deepin.api.LunarCalendar", + "/com/deepin/api/LunarCalendar", + QDBusConnection::sessionBus(), this); + if (!lunarCache) + lunarCache = new QMap; + + m_weekIndicator = new CMonthWeekView; + m_MonthGraphicsView = new CMonthGraphiview(this); + + connect(m_MonthGraphicsView, + &CMonthGraphiview::signalsViewSelectDate, + this, + &CMonthView::signalsViewSelectDate); + connect(m_MonthGraphicsView, + &CMonthGraphiview::signalsUpdateShcedule, + this, + &CMonthView::slotSchceduleUpdate); + connect(m_MonthGraphicsView, + &CMonthGraphiview::signalsSchceduleUpdate, + this, + &CMonthView::signalsSchceduleUpdate); + connect(m_MonthGraphicsView, + &CMonthGraphiview::signalViewtransparentFrame, + this, + &CMonthView::signalViewtransparentFrame); + connect(m_MonthGraphicsView, + &CMonthGraphiview::signalScheduleShow, + this, + &CMonthView::slotScheduleRemindWidget); + + m_mainLayout = new QVBoxLayout; + m_mainLayout->setMargin(0); + m_mainLayout->setSpacing(0); + m_mainLayout->setContentsMargins(10, 0, 0, 10); + m_mainLayout->addWidget(m_weekIndicator); + m_mainLayout->addWidget(m_MonthGraphicsView); + + setLayout(m_mainLayout); + CScheduleDataCtrl *scheduleDataCtrl = CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl(); + m_createAction = new QAction(tr("New event"), this); + + m_RemindWidget = new SchecduleRemindWidget(this); + + connect(scheduleDataCtrl, &CScheduleDataCtrl::signalsupdatescheduleD, this, &CMonthView::slotsupdatescheduleD); + connect(this, &CMonthView::signalsupdatescheduleD, scheduleDataCtrl, &CScheduleDataCtrl::slotupdatescheduleD); + setMouseTracking(true); + setFocusPolicy(Qt::StrongFocus); +} + +CMonthView::~CMonthView() +{ + if (lunarCache !=nullptr) { + delete lunarCache; + lunarCache = nullptr; + } +} + +void CMonthView::slotSchceduleUpdate() +{ + emit signalsSchceduleUpdate(0); + emit signalsupdatescheduleD(this, m_days[0], m_days[41]); +} + +void CMonthView::setSelectSchedule(const ScheduleDtailInfo &scheduleInfo) +{ + m_MonthGraphicsView->setSelectSchedule(scheduleInfo); +} + +void CMonthView::slotsupdatescheduleD(QWidget *w, QVector &data) +{ + if (w != this) return; + if (m_sflag) { + m_MonthGraphicsView->setScheduleInfo(data); + } + parentWidget()->setEnabled(true); +} + +void CMonthView::slotdelete(int id) +{ + Q_UNUSED(id); + emit signalsSchceduleUpdate(0); +} + +void CMonthView::slotScheduleRemindWidget(const bool isShow, const ScheduleDtailInfo &out) +{ + if (isShow) { + QPoint pos22 = QCursor::pos(); + CSchedulesColor gdcolor = CScheduleDataManage::getScheduleDataManage()->getScheduleColorByType( + out.type.ID); + m_RemindWidget->setData(out, gdcolor); + m_RemindWidget->show(pos22.x() + 10, pos22.y()); + QDesktopWidget *w = QApplication::desktop(); + + if ((pos22.x() + m_RemindWidget->width() + 10) > w->width()) { + m_RemindWidget->setArrowDirection(DArrowRectangle::ArrowRight); + m_RemindWidget->show(pos22.x() - 10, pos22.y()); + } else { + m_RemindWidget->setArrowDirection(DArrowRectangle::ArrowLeft); + m_RemindWidget->show(pos22.x() + 10, pos22.y()); + } + } else { + m_RemindWidget->hide(); + } +} + +void CMonthView::resizeEvent(QResizeEvent *event) +{ + DWidget::resizeEvent(event); + int leftmagin = 10; + int topmagin = static_cast(height() * 0.0193 + 0.5); + topmagin = 10; + m_leftmaagin = leftmagin; + m_topmagin = topmagin; + m_mainLayout->setContentsMargins(leftmagin, topmagin, 0, 10); + m_weekIndicator->setFixedSize(width()-leftmagin, static_cast(height() * 0.1042 + 0.5)); +} + + +void CMonthView::mousePressEvent(QMouseEvent *event) +{ + Q_UNUSED(event); + slotScheduleRemindWidget(false); +} + +void CMonthView::setFirstWeekday(int weekday) +{ + m_firstWeekDay = weekday; + m_weekIndicator->setList(weekday); + m_weekIndicator->updateWeek(); + updateDate(); +} + +void CMonthView::setCurrentDate(const QDate date) +{ + slotScheduleRemindWidget(false); + qDebug() << "set current date " << date; + + if (date.year() < DDECalendar::QueryEarliestYear) + return; + + if (date.month() != m_currentDate.month()) { + m_festivallist.clear(); + m_DBusInter->GetFestivalMonth(date.addMonths(-1).year(), date.addMonths(-1).month(), m_festivallist); + m_DBusInter->GetFestivalMonth(date.year(), date.month(), m_festivallist); + m_DBusInter->GetFestivalMonth(date.addMonths(1).year(), date.addMonths(1).month(), m_festivallist); + } + m_currentDate = date; + m_MonthGraphicsView->setFestivalInfo(m_festivallist); + updateDate(); + getDbusData(); + m_MonthGraphicsView->setLunarInfo(lunarCache); + emit signalcurrentDateChanged(m_currentDate); + m_weekIndicator->updateWeek(); + emit signalsupdatescheduleD(this, m_days[0], m_days[41]); +} + +void CMonthView::setLunarVisible(bool visible) +{ + m_MonthGraphicsView->setLunarVisible(visible); +} + + +int CMonthView::getDateIndex(const QDate &date) const +{ + for (int i = 0; i != DDEMonthCalendar::ItemSizeofMonthDay; ++i) + if (m_days[i] == date) + return i; + + return 0; +} + +void CMonthView::updateDate() +{ + const QDate firstDay(m_currentDate.year(), m_currentDate.month(), 1); + int offset = firstDay.dayOfWeek() % DDEMonthCalendar::AFewDaysofWeek - m_firstWeekDay; + const int day = offset < 0 ? offset + DDEMonthCalendar::AFewDaysofWeek : offset; + const int currentIndex = day + m_currentDate.day() - 1; + + if (currentIndex < 0) { + return; + } + + for (int i(0); i != DDEMonthCalendar::ItemSizeofMonthDay; ++i) { + m_days[i] = firstDay.addDays(i - day); + } + m_MonthGraphicsView->setDate(m_days); + update(); +} + +void CMonthView::updateCurrentLunar(const CaLunarDayInfo &info) +{ + emit signalcurrentLunarDateChanged(m_currentDate, info, 1); +} + +ScheduleDtailInfo CMonthView::getScheduleInfo(const QDate &beginDate, const QDate &endDate) +{ + ScheduleDtailInfo info; + + if (beginDate.daysTo(endDate)>0) { + info.beginDateTime = QDateTime(beginDate,QTime(0,0,0)); + info.endDateTime = QDateTime(endDate,QTime(23,59,59)); + } else { + info.beginDateTime = QDateTime(endDate,QTime(0,0,0)); + info.endDateTime = QDateTime(beginDate,QTime(23,59,00)); + } + info.titleName = tr("New Event"); + info.allday = true; + info.remind = true; + info.remindData.n = 1; + info.remindData.time = QTime(9, 0); + info.RecurID = 0; + info.id = 0; + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->GetType( + 1, info.type); + info.rpeat = 0; + + return info; +} + +const QDate CMonthView::getCellDate(int pos) +{ + return m_days[pos]; +} + +const CaLunarDayInfo CMonthView::getCaLunarDayInfo(const QDate &date) +{ + return lunarCache->value(date); +} + +void CMonthView::getDbusData() +{ + lunarCache->clear(); + + CaLunarDayInfo currentDayInfo; + bool o1 = true; + QDate getDate = m_currentDate; + + for (int i = -1; i < 2; ++i) { + getDate = m_currentDate.addMonths(i); + QDBusReply reply = m_DBusInter->GetLunarMonthCalendar(getDate.year(), + getDate.month(), false, o1); + + QDate cacheDate; + cacheDate.setDate(getDate.year(), getDate.month(), 1); + foreach (const CaLunarDayInfo &dayInfo, reply.value().mCaLunarDayInfo) { + lunarCache->insert(cacheDate, dayInfo); + cacheDate = cacheDate.addDays(1); + } + } + // refresh lunar info + updateCurrentLunar(lunarCache->value(m_currentDate)); +} + + diff -Nru dde-calendar-5.7.0.4/src/widget/monthWidget/monthview.h dde-calendar-5.7.0.23/src/widget/monthWidget/monthview.h --- dde-calendar-5.7.0.4/src/widget/monthWidget/monthview.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/monthWidget/monthview.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,201 @@ +/* + * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ + +#ifndef MONTHVIEW_H +#define MONTHVIEW_H + +#include "monthweekview.h" +#include "calendardbus.h" +#include "SchecduleRemindWidget.h" +#include "monthgraphiview.h" + +#include + +#include +#include +#include +#include +#include +#include + +DWIDGET_USE_NAMESPACE + +class CMonthView: public DWidget +{ + Q_OBJECT +public: + /** + * @brief setTheMe 根据系统主题类型设置颜色 + * @param type 系统主题类型 + */ + void setTheMe(int type = 0); + /** + * @brief isDragging 是否可以拖拽 + * @return 是否可以拖拽 + */ + bool isDragging()const + { + return m_MonthGraphicsView->getDragStatus() !=4; + } +public: + /** + * @brief CMonthView 构造函数 + * @param parent 父类 + */ + explicit CMonthView(QWidget *parent = nullptr); + /** + * @brief ~CMonthView 析构函数 + */ + ~CMonthView() override; + /** + * @brief setFirstWeekday 设置每周的第一天是周几 + * @param weekday 周几 + */ + void setFirstWeekday(int weekday); +signals: + /** + * @brief signalcurrentLunarDateChanged 当前时间改变的信号 + * @param date 改变的日期 + * @param detail 阴历信息 + * @param type 是否显示阴历信息 + */ + void signalcurrentLunarDateChanged(QDate date, CaLunarDayInfo detail, int type = 0); + /** + * @brief signalcurrentDateChanged 当前日期改变的信号 + * @param date 日期 + */ + void signalcurrentDateChanged(QDate date); + /** + * @brief signalsSchceduleUpdate 更新日程的信号 + * @param id + */ + void signalsSchceduleUpdate(int id = 0); + /** + * @brief signalsCurrentScheduleDate + * @param date + */ + void signalsCurrentScheduleDate(QDate date); + /** + * @brief signalViewtransparentFrame 设置窗口的焦点 + * @param type + */ + void signalViewtransparentFrame(int type); + /** + * @brief signalsViewSelectDate 切换视图 + * @param date 日期 + */ + void signalsViewSelectDate(QDate date); +public slots: + /** + * @brief setCurrentDate 设置当前的日程 + * @param date 日期 + */ + void setCurrentDate(const QDate date); + /** + * @brief setLunarVisible 设置是否显示阴历信息 + * @param visible 是否显示阴历信息 + */ + void setLunarVisible(bool visible); + /** + * @brief slotSchceduleUpdate 更新日程信息 + */ + void slotSchceduleUpdate(); + /** + * @brief setSelectSchedule 设置选择的日程 + * @param scheduleInfo 日程信息 + */ + void setSelectSchedule(const ScheduleDtailInfo &scheduleInfo); +public slots: + /** + * @brief slotsupdatescheduleD 更新日程 + * @param w 判断是否是当前的widget + * @param data 日程信息 + */ + void slotsupdatescheduleD(QWidget *w, QVector &data); + /** + * @brief slotdelete 发送更新日程的信号 + * @param id + */ + void slotdelete(int id); + /** + * @brief slotScheduleRemindWidget 日程浮框 + * @param isShow 是否显示日程浮框 + * @param out 日程信息 + */ + void slotScheduleRemindWidget(const bool isShow, const ScheduleDtailInfo &out = ScheduleDtailInfo()); +signals: + /** + * @brief signalsupdatescheduleD 更新日程的信号 + * @param w widget + * @param begin 开始日期 + * @param end 结束日期 + */ + void signalsupdatescheduleD(QWidget *w, QDate begin, QDate end); +protected: + /** + * @brief resizeEvent 窗口大小调整 + * @param event 窗口大小调整事件 + */ + void resizeEvent(QResizeEvent *event) override; + /** + * @brief mousePressEvent 鼠标单击 + * @param event 鼠标事件 + */ + void mousePressEvent(QMouseEvent *event) override; +private: + /** + * @brief getDateIndex 获取日期的索引值 + * @param date 日期 + * @return 索引值 + */ + int getDateIndex(const QDate &date) const; + + const QDate getCellDate(int pos); + const CaLunarDayInfo getCaLunarDayInfo(const QDate &date); + void updateDate(); + void updateCurrentLunar(const CaLunarDayInfo &info); + ScheduleDtailInfo getScheduleInfo(const QDate &beginDate,const QDate &endDate); +private slots: + void getDbusData(); +private: + CMonthGraphiview *m_MonthGraphicsView = nullptr; + CalendarDBus *m_DBusInter = nullptr; + QDate m_days[42]; + QDate m_currentDate; + + QDate m_createDate; + QMap *lunarCache = nullptr; + QVector m_festivallist; + + CMonthWeekView *m_weekIndicator = nullptr; + int m_firstWeekDay = 0; + QAction *m_createAction = nullptr; // 创建日程 + QVBoxLayout *m_mainLayout = nullptr; + int m_leftmaagin = 0; + int m_topmagin = 0; + bool m_sflag = true; + SchecduleRemindWidget *m_RemindWidget = nullptr; + + QPoint m_PressPoint; + bool isCreate; + QDate m_PressDate; + QDate m_MoveDate; +}; + +#endif // MYCALENDARWIDGET_H diff -Nru dde-calendar-5.7.0.4/src/widget/monthWidget/monthweekview.cpp dde-calendar-5.7.0.23/src/widget/monthWidget/monthweekview.cpp --- dde-calendar-5.7.0.4/src/widget/monthWidget/monthweekview.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/monthWidget/monthweekview.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,198 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ + +#include "monthweekview.h" +#include "scheduledatamanage.h" + +#include +#include +#include + +#include +#include +#include + +DGUI_USE_NAMESPACE +CMonthWeekView::CMonthWeekView(QWidget *parent) + : DWidget(parent) +{ + m_mainLayout = new QHBoxLayout; + m_mainLayout->setMargin(0); + m_mainLayout->setSpacing(0); + setLayout(m_mainLayout); +} + +void CMonthWeekView::setList(int weekday) +{ + QLayoutItem *child; + + while ((child = m_mainLayout->takeAt(0)) != nullptr) { + if (child->widget() != nullptr) { + delete child->widget(); + } + delete child; + } + m_weekData.clear(); + QLocale locale; + + for (int i = 0; i != DDEMonthCalendar::AFewDaysofWeek; ++i) { + int d = checkDay(i + weekday); + + QVBoxLayout *hhLayout = new QVBoxLayout; + hhLayout->setMargin(0); + hhLayout->setSpacing(0); + hhLayout->setContentsMargins(0, 0, 0, 0); + + CustomFrame *label = new CustomFrame(); + label->setTextStr(locale.dayName(d ? d : DDEMonthCalendar::AFewDaysofWeek, QLocale::ShortFormat)); + label->setContentsMargins(0, 0, 0, 0); + QFont weekfont; + weekfont.setWeight(QFont::Medium); + weekfont.setPixelSize(DDECalendar::FontSizeSixteen); + label->setTextFont(weekfont); + + if (i ==0) { + label->setRoundState(true, false, false, false); + } else if (i == DDEMonthCalendar::AFewDaysofWeek - 1) { + label->setRoundState(false, true, false, false); + } + + if (d == 0) { + QColor textbC(0, 66, 154); + QColor colorSeven = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); + label->setTextColor(colorSeven); + label->setBColor(textbC); + m_weekData.append(qMakePair(label, 1)); + } else if (d == DDEMonthCalendar::AFewDaysofWeek - 1) { + QColor textbC(0, 66, 154); + QColor colorSix = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); + label->setTextColor(colorSix); + label->setBColor(textbC); + m_weekData.append(qMakePair(label, 1)); + } else { + QColor textC = Qt::black; + QColor textbC(0, 66, 154); + textbC.setAlphaF(0.05); + label->setTextColor(textC); + label->setBColor(textbC); + m_weekData.append(qMakePair(label, 0)); + } + + if ((i == weekday - 1 && weekday != 0) || i == weekday || (weekday == 0 && i == 6)) { + label->setObjectName("MonthHeaderWeekend"); + } else { + label->setObjectName("MonthHeaderWeekday"); + } + + DHorizontalLine *splitline = new DHorizontalLine; + + if (i == 0 || i == DDEMonthCalendar::AFewDaysofWeek - 1) { + label->setFixedSize(DDEMonthCalendar::MWeekCellWidth - 1, DDEMonthCalendar::MWeekCellHeight); + splitline->setFixedSize(DDEMonthCalendar::MWeekCellWidth - 1, 2); + } else { + label->setFixedSize(DDEMonthCalendar::MWeekCellWidth - 3, DDEMonthCalendar::MWeekCellHeight); + splitline->setFixedSize(DDEMonthCalendar::MWeekCellWidth - 3, 2); + } + hhLayout->addWidget(label); + hhLayout->addWidget(splitline); + splitline->setAutoFillBackground(true); + m_vline.append(splitline); + splitline->setVisible(false); + m_mainLayout->addLayout(hhLayout); + } +} + +void CMonthWeekView::setTheMe(int type) +{ + if (type == 0 || type == 1) { + for (int i = 0; i < m_weekData.count(); i++) { + if (m_weekData.at(i).second == 1) { + QColor color = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); + QColor textbC("#75C18E"); + textbC.setAlphaF(0.1); + m_weekData.at(i).first->setTextColor(color); + m_weekData.at(i).first->setBColor(textbC); + } else { + QColor textC = "#6F6F6F"; + QColor textbC("#75C18E"); + textbC.setAlphaF(0.1); + m_weekData.at(i).first->setTextColor(textC); + m_weekData.at(i).first->setBColor(textbC); + } + m_vline.at(i)->setBackgroundRole(DPalette::Highlight); + } + + } else if (type == 2) { + for (int i = 0; i < m_weekData.count(); i++) { + if (m_weekData.at(i).second == 1) { + QColor color = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); + QColor textbC = "#82AEC1"; + textbC.setAlphaF(0.10); + m_weekData.at(i).first->setTextColor(color); + m_weekData.at(i).first->setBColor(textbC); + } else { + QColor textC = "#C0C6D4"; + QColor textbC = "#82AEC1"; + textbC.setAlphaF(0.10); + m_weekData.at(i).first->setTextColor(textC); + m_weekData.at(i).first->setBColor(textbC); + } + m_vline.at(i)->setBackgroundRole(DPalette::Highlight); + } + } +} + +void CMonthWeekView::updateWeek() +{ + for (int i = 0; i < m_vline.count(); ++i) { + m_vline.at(i)->setVisible(false); + } + QDate date = QDate::currentDate(); + int d = date.dayOfWeek(); + QLocale locale; + QString str = locale.dayName(d ? d : DDEMonthCalendar::AFewDaysofWeek, QLocale::ShortFormat); + + for (int i = 0; i < m_vline.count(); ++i) { + if (m_weekData.at(i).first->getTextStr() == str) { + m_vline.at(i)->setVisible(true); + } + } +} + +int CMonthWeekView::checkDay(int weekday) +{ + // check the week, calculate the correct order in the custom. + return weekday % DDEMonthCalendar::AFewDaysofWeek; +} + +void CMonthWeekView::resizeEvent(QResizeEvent *event) +{ + int tw = static_cast(width() / 7.0 + 0.5); + int th = height(); + + for (int i = 0; i < m_weekData.count(); i++) { + if (m_weekData.at(i).second == 1) { + m_weekData.at(i).first->setFixedSize(tw, th); + } else { + m_weekData.at(i).first->setFixedSize(tw, th); + } + m_vline.at(i)->setFixedWidth(tw); + } + DWidget::resizeEvent(event); +} diff -Nru dde-calendar-5.7.0.4/src/widget/monthWidget/monthweekview.h dde-calendar-5.7.0.23/src/widget/monthWidget/monthweekview.h --- dde-calendar-5.7.0.4/src/widget/monthWidget/monthweekview.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/monthWidget/monthweekview.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ + +#ifndef MONTHWEEKVIEW_H +#define MONTHWEEKVIEW_H + +#include "constants.h" +#include "customframe.h" + +#include +#include +#include + +#include + +DWIDGET_USE_NAMESPACE +class CMonthWeekView : public DWidget +{ + Q_OBJECT +public: + explicit CMonthWeekView(QWidget *parent = nullptr); + void setList(int weekday); + void setTheMe(int type = 0); + void updateWeek(); +private: + int checkDay(int weekday); +protected: + void resizeEvent(QResizeEvent *event) override; +private: + QHBoxLayout *m_mainLayout = nullptr; + QVector> m_weekData; + QVector m_vline; +}; + +#endif // WEEKINDICATOR_H diff -Nru dde-calendar-5.7.0.4/src/widget/monthWidget/monthwindow.cpp dde-calendar-5.7.0.23/src/widget/monthWidget/monthwindow.cpp --- dde-calendar-5.7.0.4/src/widget/monthWidget/monthwindow.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/monthWidget/monthwindow.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,425 @@ +/* + * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#include "monthwindow.h" +#include "monthview.h" +#include "monthdayview.h" +#include "constants.h" +#include "calendardbus.h" +#include "schcedulesearchview.h" +#include "todybutton.h" +#include "scheduledatamanage.h" + +#include + +#include +#include + +DGUI_USE_NAMESPACE +CMonthWindow::CMonthWindow(QWidget *parent) + : QMainWindow(parent) +{ + setContentsMargins(0, 0, 0, 0); + initUI(); + initConnection(); + initLunar(); +} + +CMonthWindow::~CMonthWindow() +{ + disconnect(m_today, &CTodyButton::clicked, this, &CMonthWindow::slottoday); + delete m_monthDayView; + m_monthDayView = nullptr; + delete m_monthView; + m_monthView = nullptr; +} + +void CMonthWindow::setFirstWeekday(int weekday) +{ + m_monthView->setFirstWeekday(weekday); +} + +void CMonthWindow::setDate(QDate date) +{ + if (!date.isValid()) + return; + + m_monthDayView->setCurrentDate(date); + + if (m_currentdate == date) + return; + + m_currentdate = date; + QLocale locale; + + if (locale.language() == QLocale::Chinese) { + m_YearLabel->setText(QString::number(date.year()) + tr("Y")); + } else { + m_YearLabel->setText(QString::number(date.year())); + } + m_monthView->setCurrentDate(date); + emit signalCurrentDate(date); +} + +void CMonthWindow::setLunarVisible(bool state) +{ + m_monthView->setLunarVisible(state); + m_YearLunarLabel->setVisible(state); +} + +void CMonthWindow::setTheMe(int type) +{ + if (type == 0 || type == 1) { + DPalette anipa = m_contentBackground->palette(); + anipa.setColor(DPalette::Background, "#F8F8F8"); + m_contentBackground->setPalette(anipa); + m_contentBackground->setBackgroundRole(DPalette::Background); + + QColor todayColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); + DPalette todaypa = m_today->palette(); + todaypa.setColor(DPalette::ButtonText, todayColor); + todaypa.setColor(DPalette::Dark, Qt::white); + todaypa.setColor(DPalette::Light, Qt::white); + QColor sbcolor("#002A57"); + sbcolor.setAlphaF(0.05); + todaypa.setColor(DPalette::Shadow, sbcolor); + m_today->setPalette(todaypa); + QColor todayhover = "#000000"; + todayhover.setAlphaF(0.1); + QColor todaypress = "#000000"; + todaypress.setAlphaF(0.2); + m_today->setBColor("#FFFFFF", todayhover, todaypress, "#FFFFFF", todayhover, todaypress); + m_today->setTColor(todayColor, "#001A2E", "#0081FF"); + m_today->setshadowColor(sbcolor); + + DPalette pa = m_YearLabel->palette(); + pa.setColor(DPalette::WindowText, QColor("#3B3B3B")); + m_YearLabel->setPalette(pa); + m_YearLabel->setForegroundRole(DPalette::WindowText); + + DPalette Lunapa = m_YearLunarLabel->palette(); + Lunapa.setColor(DPalette::WindowText, QColor("#8A8A8A")); + m_YearLunarLabel->setPalette(Lunapa); + m_YearLunarLabel->setForegroundRole(DPalette::WindowText); + + DPalette gpa = m_gridWidget->palette(); + gpa.setColor(DPalette::Background, "#F8F8F8"); + m_gridWidget->setPalette(gpa); + m_gridWidget->setBackgroundRole(DPalette::Background); + } else if (type == 2) { + QColor todayColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); + DPalette todaypa = m_today->palette(); + todaypa.setColor(DPalette::ButtonText, todayColor); + todaypa.setColor(DPalette::Light, "#484848"); + todaypa.setColor(DPalette::Dark, "#414141"); + QColor sbcolor("#000000"); + sbcolor.setAlphaF(0.05); + todaypa.setColor(DPalette::Shadow, sbcolor); + m_today->setPalette(todaypa); + + m_today->setBColor("#484848", "#727272", "#242424", "#414141", "#535353", "#282828"); + m_today->setTColor(todayColor, "#FFFFFF", "#0081FF"); + m_today->setshadowColor(sbcolor); + + DPalette pa = m_YearLabel->palette(); + pa.setColor(DPalette::WindowText, QColor("#C0C6D4")); + m_YearLabel->setPalette(pa); + m_YearLabel->setForegroundRole(DPalette::WindowText); + DPalette Lunapa = m_YearLunarLabel->palette(); + Lunapa.setColor(DPalette::WindowText, QColor("#798BA8")); + m_YearLunarLabel->setPalette(Lunapa); + m_YearLunarLabel->setForegroundRole(DPalette::WindowText); + DPalette anipa = m_contentBackground->palette(); + anipa.setColor(DPalette::Background, "#252525"); + m_contentBackground->setPalette(anipa); + m_contentBackground->setBackgroundRole(DPalette::Background); + + DPalette gpa = m_gridWidget->palette(); + gpa.setColor(DPalette::Background, "#252525"); + m_gridWidget->setPalette(gpa); + m_gridWidget->setBackgroundRole(DPalette::Background); + } + m_monthDayView->setTheMe(type); + m_monthView->setTheMe(type); +} + +void CMonthWindow::previousMonth() +{ + slideMonth(false); +} + +void CMonthWindow::nextMonth() +{ + slideMonth(true); +} + +void CMonthWindow::slotsearchDateSelect(QDate date) +{ + setDate(date); + slotupdateSchedule(); +} + +void CMonthWindow::setSearchWFlag(bool flag) +{ + m_searchfalg = flag; + m_monthDayView->setsearchfalg(flag); +} + +void CMonthWindow::clearSearch() +{ +} + +void CMonthWindow::wheelEvent(QWheelEvent *e) +{ + //拖拽时禁用 + if (!m_monthView->isDragging()) { + QPoint numDegrees = e->angleDelta(); + + if (numDegrees.y()>0) { + nextMonth(); + } else { + previousMonth(); + } + } +} + +void CMonthWindow::initUI() +{ + m_contentBackground = new DFrame; + m_contentBackground->setContentsMargins(0, 0, 0, 0); + DPalette anipa = m_contentBackground->palette(); + anipa.setColor(DPalette::Background, "#F8F8F8"); + m_contentBackground->setAutoFillBackground(true); + m_contentBackground->setPalette(anipa); + + m_today = new CTodyButton; + m_today->setText(QCoreApplication::translate("today", "Today", "Today")); + m_today->setFixedSize(DDEMonthCalendar::MTodayWindth, DDEMonthCalendar::MTodayHeight); + QColor todayColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); + DPalette todaypa = m_today->palette(); + todaypa.setColor(DPalette::ButtonText, todayColor); + todaypa.setColor(DPalette::Dark, Qt::white); + todaypa.setColor(DPalette::Light, Qt::white); + + QColor sbcolor("#002A57"); + sbcolor.setAlphaF(0.05); + todaypa.setColor(DPalette::Shadow, sbcolor); + QFont todayfont; + todayfont.setWeight(QFont::Medium); + todayfont.setPixelSize(DDECalendar::FontSizeFourteen); + m_today->setFont(todayfont); + m_today->setPalette(todaypa); + m_YearLabel = new QLabel(); + m_YearLabel->setFixedHeight(DDEMonthCalendar::M_YLableHeight); + m_YearLunarLabel = new QLabel(); + m_YearLunarLabel->setFixedSize(DDEMonthCalendar::M_YLunatLabelWindth, DDEMonthCalendar::M_YLunatLabelHeight); + + QFont ylabelF; + ylabelF.setWeight(QFont::Medium); + ylabelF.setPixelSize(DDECalendar::FontSizeTwentyfour); + m_YearLabel->setFont(ylabelF); + DPalette pa = m_YearLabel->palette(); + pa.setColor(DPalette::WindowText, QColor("#3B3B3B")); + m_YearLabel->setPalette(pa); + + ylabelF.setPixelSize(DDECalendar::FontSizeFourteen); + m_YearLunarLabel->setFont(ylabelF); + DPalette Lunarpa = m_YearLunarLabel->palette(); + Lunarpa.setColor(DPalette::WindowText, QColor("#8A8A8A")); + m_YearLunarLabel->setPalette(Lunarpa); + + m_monthDayView = new CMonthDayView(this); + + QHBoxLayout *yeartitleLayout = new QHBoxLayout; + yeartitleLayout->setMargin(0); + yeartitleLayout->setSpacing(0); + yeartitleLayout->setContentsMargins(21, 20, 8, 10); + yeartitleLayout->addWidget(m_YearLabel); + + QHBoxLayout *yeartitleLayout1 = new QHBoxLayout; + yeartitleLayout1->setMargin(0); + yeartitleLayout1->setSpacing(0); + yeartitleLayout1->setContentsMargins(14, 9, 0, 7); + yeartitleLayout1->addWidget(m_YearLunarLabel); + yeartitleLayout->addLayout(yeartitleLayout1); + + yeartitleLayout->addStretch(); + yeartitleLayout->addWidget(m_monthDayView, 0, Qt::AlignCenter); + yeartitleLayout->addStretch(); + yeartitleLayout->addWidget(m_today, 0, Qt::AlignRight); + + m_monthView = new CMonthView(this); + QVBoxLayout *mhLayout = new QVBoxLayout; + mhLayout->setMargin(0); + mhLayout->setSpacing(0); + mhLayout->addWidget(m_monthView); + + QVBoxLayout *hhLayout = new QVBoxLayout; + hhLayout->setSpacing(0); + hhLayout->setMargin(0); + + hhLayout->addLayout(yeartitleLayout); + m_gridWidget = new DWidget(); + m_gridWidget->setContentsMargins(0, 0, 0, 0); + m_gridWidget->setAutoFillBackground(true); + m_gridWidget->setLayout(mhLayout); + + hhLayout->addWidget(m_gridWidget); + + m_tmainLayout = new QHBoxLayout; + m_tmainLayout->setMargin(0); + m_tmainLayout->setSpacing(0); + m_tmainLayout->setContentsMargins(0, 0, 10, 0); + m_tmainLayout->addLayout(hhLayout); + + QVBoxLayout *ssLayout = new QVBoxLayout; + ssLayout->setMargin(0); + ssLayout->setSpacing(0); + ssLayout->setContentsMargins(0, 10, 0, 10); + m_tmainLayout->addLayout(ssLayout); + + m_contentBackground->setLayout(m_tmainLayout); + + setCentralWidget(m_contentBackground); +} + +void CMonthWindow::initConnection() +{ + connect(m_today, &DPushButton::clicked, this, &CMonthWindow::slottoday); + connect(m_monthView, &CMonthView::signalcurrentLunarDateChanged, this, &CMonthWindow::slotcurrentDateLunarChanged); + connect(m_monthView, &CMonthView::signalcurrentDateChanged, this, &CMonthWindow::slotcurrentDateChanged); + connect(m_monthDayView, &CMonthDayView::signalsSelectDate, this, &CMonthWindow::slotSelectedMonth); + connect(m_monthView, &CMonthView::signalsSchceduleUpdate, this, &CMonthWindow::slotTransitSchedule); + connect(m_monthDayView, &CMonthDayView::signalsCurrentDate, this, &CMonthWindow::slotSelectedMonth); + connect(m_monthView, &CMonthView::signalsCurrentScheduleDate, this, &CMonthWindow::signalsCurrentScheduleDate); + connect(m_monthView, &CMonthView::signalViewtransparentFrame, this, &CMonthWindow::signalViewtransparentFrame); + connect(m_monthView, &CMonthView::signalsViewSelectDate, this, &CMonthWindow::signalsViewSelectDate); +} + +void CMonthWindow::initLunar() +{ + m_monthView->setLunarVisible(true); +} + +void CMonthWindow::slideMonth(bool next) +{ + QDate currentDate; + + if (next) { + if (m_currentdate.year() == DDECalendar::QueryEarliestYear && m_currentdate.month() == 1) + return; + currentDate = m_currentdate.addMonths(-1); + } else { + currentDate = m_currentdate.addMonths(1); + } + + setDate(currentDate); + QDate tdate = QDate(m_currentdate.year(), m_currentdate.month(), 1); + emit signalCurrentDate(tdate); +} + +void CMonthWindow::slotReturnTodayUpdate() +{ + setDate(QDate::currentDate()); +} + +void CMonthWindow::slotScheduleHide() +{ + m_monthView->slotScheduleRemindWidget(false); +} + +void CMonthWindow::slotupdateSchedule(int id) +{ + Q_UNUSED(id); + m_monthView->slotSchceduleUpdate(); +} + +void CMonthWindow::slotTransitSchedule(int id) +{ + emit signalsWUpdateShcedule(this, id); +} + +void CMonthWindow::setSelectSchedule(const ScheduleDtailInfo &scheduleInfo) +{ + m_monthView->setSelectSchedule(scheduleInfo); +} + +void CMonthWindow::resizeEvent(QResizeEvent *event) +{ + qreal dw = width() * 0.5023 + 0.5; + int dh = 36; + + if (m_searchfalg) { + m_tmainLayout->setContentsMargins(0, 0, 0, 0); + } else { + m_tmainLayout->setContentsMargins(0, 0, 10, 0); + } + + if (!m_searchfalg) { + m_monthDayView->setFixedSize(qRound(dw), dh); + } else { + m_monthDayView->setFixedSize(qRound(dw), dh); + } + + QMainWindow::resizeEvent(event); +} + +void CMonthWindow::slottoday() +{ + emit signalsReturnTodayUpdate(this); + setDate(QDate::currentDate()); +} + +void CMonthWindow::slotcurrentDateLunarChanged(QDate date, CaLunarDayInfo detail, int type) +{ + QDate currentdate = m_currentdate; + m_currentdate = date; + + if (type == 1) { + QLocale locale; + + if (locale.language() == QLocale::Chinese) { + m_YearLabel->setText(QString::number(date.year()) + tr("Y")); + } else { + m_YearLabel->setText(QString::number(date.year())); + } + m_YearLunarLabel->setText("-" + detail.mGanZhiYear + detail.mZodiac + "年-"); + } else if (type == 0) { + if (date.month() != currentdate.month()) { + m_monthDayView->setRCurrentDate(date); + } + } +} + +void CMonthWindow::slotcurrentDateChanged(QDate date) +{ + m_currentdate = date; + + if (m_currentdate == QDate::currentDate()) { + m_today->setText(QCoreApplication::translate("today", "Today", "Today")); + } else { + m_today->setText(QCoreApplication::translate("Return Today", "Today", "Return Today")); + } +} + +void CMonthWindow::slotSelectedMonth(QDate date) +{ + m_currentdate = date; + m_monthView->setCurrentDate(date); + emit signalCurrentDate(date); +} diff -Nru dde-calendar-5.7.0.4/src/widget/monthWidget/monthwindow.h dde-calendar-5.7.0.23/src/widget/monthWidget/monthwindow.h --- dde-calendar-5.7.0.4/src/widget/monthWidget/monthwindow.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/monthWidget/monthwindow.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,223 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#ifndef MONTHWINDOW_H +#define MONTHWINDOW_H + +#include "SchecduleRemindWidget.h" + +#include +#include +#include + +#include +#include +#include +#include + +DWIDGET_USE_NAMESPACE +class CSchceduleSearchView; +class CMonthView; +class CMonthDayView; +class QHBoxLayout; +class CTodyButton; +class CMonthWindow: public QMainWindow +{ + Q_OBJECT +public: + /** + * @brief CMonthWindow 构造函数 + * @param parent 父类 + */ + explicit CMonthWindow(QWidget *parent = nullptr); + /** + * @brief ~CMonthWindow 析构函数 + */ + ~CMonthWindow() override; + /** + * @brief setFirstWeekday 设置每周第一天是周几 + * @param weekday 周几 + */ + void setFirstWeekday(int weekday); + /** + * @brief setDate 设置时间 + * @param date 日期 + */ + void setDate(QDate date); + /** + * @brief setLunarVisible 设置是否显示阴历信息 + * @param state 是否显示阴历信息 + */ + void setLunarVisible(bool state); + /** + * @brief setTheMe 根据系统主题类型设置颜色 + * @param type 系统主题类型 + */ + void setTheMe(int type = 0); + /** + * @brief setSearchWFlag 设置是否选择的标志 + * @param flag 是否选择的标志 + */ + void setSearchWFlag(bool flag); + /** + * @brief clearSearch + */ + void clearSearch(); +public slots: + /** + * @brief previousMonth 选择上一个月份 + */ + void previousMonth(); + /** + * @brief nextMonth 选择下一个月份 + */ + void nextMonth(); + /** + * @brief slotsearchDateSelect 选择搜索到的日期 + * @param date 日期 + */ + void slotsearchDateSelect(QDate date); +protected: + /** + * @brief wheelEvent 鼠标滚轮事件 + */ + void wheelEvent(QWheelEvent *) override; +private: + /** + * @brief initUI 初始化界面 + */ + void initUI(); + /** + * @brief initConnection 初始化信号和槽的连接 + */ + void initConnection(); + /** + * @brief initLunar 初始化阴历信息 + */ + void initLunar(); + /** + * @brief slideMonth 切换月份,并更新信息 + * @param next 是否切换到下一个月 + */ + void slideMonth(bool next); +signals: + /** + * @brief dateSelected + * @param date + * @param detail + */ + void dateSelected(const QDate date, const CaLunarDayInfo &detail) const; + /** + * @brief signalsWUpdateShcedule 更新日程的信号 + * @param w unused + * @param id unused + */ + void signalsWUpdateShcedule(QMainWindow *w, int id = 0); + /** + * @brief signalsReturnTodayUpdate 返回今天的按钮的信号 + * @param w 视图 + */ + void signalsReturnTodayUpdate(QMainWindow *w); + /** + * @brief signalsCurrentScheduleDate + * @param date + */ + void signalsCurrentScheduleDate(QDate date); + /** + * @brief signalsViewSelectDate 切换视图的信号 + * @param date 日期 + */ + void signalsViewSelectDate(QDate date); + /** + * @brief signalViewtransparentFrame 获取视图的焦点 + * @param type + */ + void signalViewtransparentFrame(int type); + /** + * @brief signalCurrentDate 设置时间的信号 + * @param date 日期 + */ + void signalCurrentDate(QDate date); +public slots: + /** + * @brief slotReturnTodayUpdate 返回今天 + */ + void slotReturnTodayUpdate(); + /** + * @brief slotScheduleHide 隐藏日程浮框 + */ + void slotScheduleHide(); +public slots: + /** + * @brief slotupdateSchedule 更新日程 + * @param id + */ + void slotupdateSchedule(int id = 0); + /** + * @brief slotTransitSchedule 发送更新日程的信号 + * @param id + */ + void slotTransitSchedule(int id = 0); + /** + * @brief setSelectSchedule 设置选择的日程 + * @param scheduleInfo 选择日程的信息 + */ + void setSelectSchedule(const ScheduleDtailInfo &scheduleInfo); +protected: + /** + * @brief resizeEvent 窗口大小调整 + * @param event 窗口大小调整事件 + */ + void resizeEvent(QResizeEvent *event) override; +private slots: + /** + * @brief slottoday 返回今天 + */ + void slottoday(); + /** + * @brief slotcurrentDateLunarChanged 当前时间改变,更新信息 + * @param date 时间 + * @param detail 阴历信息 + * @param type 是否显示阴历信息 + */ + void slotcurrentDateLunarChanged(QDate date, CaLunarDayInfo detail, int type = 0); + /** + * @brief slotcurrentDateChanged 根据时间变化,返回今天按钮状态变化 + * @param date 时间 + */ + void slotcurrentDateChanged(QDate date); + /** + * @brief slotSelectedMonth 设置选择的月份 + * @param date 日期 + */ + void slotSelectedMonth(QDate date); +private: + CMonthView *m_monthView = nullptr; + CMonthDayView *m_monthDayView = nullptr; + DFrame *m_contentBackground = nullptr; + CTodyButton *m_today = nullptr; + QDate m_currentdate; + QLabel *m_YearLabel = nullptr; + QLabel *m_YearLunarLabel = nullptr; + QSpacerItem *m_spaceitem = nullptr; + DWidget *m_gridWidget = nullptr; + bool m_searchfalg = false; + QHBoxLayout *m_tmainLayout = nullptr; +}; + +#endif // YEARWINDOW_H diff -Nru dde-calendar-5.7.0.4/src/widget/schcedulesearchview.cpp dde-calendar-5.7.0.23/src/widget/schcedulesearchview.cpp --- dde-calendar-5.7.0.4/src/widget/schcedulesearchview.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/schcedulesearchview.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,817 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#include "schcedulesearchview.h" +#include "schcedulectrldlg.h" +#include "myschceduleview.h" +#include "schceduledlg.h" +#include "scheduledatamanage.h" +#include "constants.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +DGUI_USE_NAMESPACE +CSchceduleSearchItem::CSchceduleSearchItem(QWidget *parent) + : DLabel(parent) + , m_rightMenu(new DMenu(this)) +{ + //设置对象名称和辅助显示名称 + this->setObjectName("CScheduleDataItem"); + this->setAccessibleName("CScheduleDataItem"); + m_editAction = new QAction(tr("Edit"), this); + m_deleteAction = new QAction(tr("Delete"), this); + connect(m_editAction, SIGNAL(triggered(bool)), this, SLOT(slotEdit())); + connect(m_deleteAction, SIGNAL(triggered(bool)), this, SLOT(slotDelete())); + setTheMe(DGuiApplicationHelper::instance()->themeType()); + QObject::connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::paletteTypeChanged, + this, + &CSchceduleSearchItem::setTheMe); + m_mouseStatus = M_NONE; + installEventFilter(this); +} + +void CSchceduleSearchItem::setBackgroundColor(QColor color1) +{ + m_Backgroundcolor = color1; +} + +void CSchceduleSearchItem::setSplitLineColor(QColor color1) +{ + m_splitlinecolor = color1; +} + +void CSchceduleSearchItem::setText( QColor tcolor, QFont font) +{ + m_ttextcolor = tcolor; + m_tfont = font; +} + +void CSchceduleSearchItem::setTimeC(QColor tcolor, QFont font) +{ + m_timecolor = tcolor; + m_timefont = font; +} + +void CSchceduleSearchItem::setData( ScheduleDtailInfo vScheduleInfo, QDate date) +{ + m_ScheduleInfo = vScheduleInfo; + m_date = date; + update(); +} + +void CSchceduleSearchItem::setRoundtype(int rtype) +{ + m_roundtype = rtype; + update(); +} + +void CSchceduleSearchItem::setTheMe(int type) +{ + if (type == 2) { + m_presscolor.background = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); + m_presscolor.background.setAlphaF(1); + m_presscolor.timeColor = "#FFFFFF"; + m_presscolor.timeColor.setAlphaF(1); + m_presscolor.textColor = "#FFFFFF"; + m_presscolor.textColor.setAlphaF(1); + + m_hovercolor.background= "#FFFFFF"; + m_hovercolor.background.setAlphaF(0.2); + m_hovercolor.timeColor = "#6D7C88"; + m_hovercolor.timeColor.setAlphaF(1); + m_hovercolor.textColor = "#C0C6D4"; + m_hovercolor.textColor.setAlphaF(1); + } else { + m_presscolor.background = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); + m_presscolor.background.setAlphaF(1); + m_presscolor.timeColor = "#FFFFFF"; + m_presscolor.timeColor.setAlphaF(1); + m_presscolor.textColor = "#FFFFFF"; + m_presscolor.textColor.setAlphaF(1); + + m_hovercolor.background= "#000000"; + m_hovercolor.background.setAlphaF(0.2); + m_hovercolor.timeColor = "#526A7F"; + m_hovercolor.timeColor.setAlphaF(1); + m_hovercolor.textColor = "#414D68"; + m_hovercolor.textColor.setAlphaF(1); + } +} +void CSchceduleSearchItem::slotEdit() +{ + emit signalViewtransparentFrame(1); + CSchceduleDlg dlg(0, this); + dlg.setData(m_ScheduleInfo); + + if (dlg.exec() == DDialog::Accepted) { + emit signalsEdit(this); + } + emit signalViewtransparentFrame(0); +} + +void CSchceduleSearchItem::slotDelete() +{ + emit signalViewtransparentFrame(1); + + if (m_ScheduleInfo.rpeat == 0) { + CSchceduleCtrlDlg msgBox; + + msgBox.setText(tr("You are deleting an event.")); + msgBox.setInformativeText(tr("Are you sure you want to delete this event?")); + msgBox.addPushButton(tr("Cancel"), true); + msgBox.addWaringButton(tr("Delete"), true); + msgBox.exec(); + + if (msgBox.clickButton() == 0) { + emit signalViewtransparentFrame(0); + return; + } else if (msgBox.clickButton() == 1) { + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->deleteScheduleInfoById(m_ScheduleInfo.id); + } + } else { + if (m_ScheduleInfo.RecurID == 0) { + CSchceduleCtrlDlg msgBox; + + msgBox.setText(tr("You are deleting an event.")); + msgBox.setInformativeText(tr("Do you want to delete all occurrences of this event, or only the selected occurrence?")); + msgBox.addPushButton(tr("Cancel")); + msgBox.addPushButton(tr("Delete All")); + msgBox.addsuggestButton(tr("Delete Only This Event")); + msgBox.exec(); + + if (msgBox.clickButton() == 0) { + emit signalViewtransparentFrame(0); + return; + } else if (msgBox.clickButton() == 1) { + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->deleteScheduleInfoById(m_ScheduleInfo.id); + } else if (msgBox.clickButton() == 2) { + + ScheduleDtailInfo newschedule; + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->getScheduleInfoById(m_ScheduleInfo.id, newschedule); + newschedule.ignore.append(m_ScheduleInfo.beginDateTime); + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo(newschedule); + } + } else { + CSchceduleCtrlDlg msgBox; + msgBox.setText(tr("You are deleting an event.")); + msgBox.setInformativeText(tr("Do you want to delete this and all future occurrences of this event, or only the selected occurrence?")); + msgBox.addPushButton(tr("Cancel")); + msgBox.addPushButton(tr("Delete All Future Events")); + msgBox.addsuggestButton(tr("Delete Only This Event")); + msgBox.exec(); + + if (msgBox.clickButton() == 0) { + emit signalViewtransparentFrame(0); + return; + } else if (msgBox.clickButton() == 1) { + ScheduleDtailInfo newschedule; + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->getScheduleInfoById(m_ScheduleInfo.id, newschedule); + newschedule.enddata.type = 2; + newschedule.enddata.date = m_ScheduleInfo.beginDateTime.addDays(-1); + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo(newschedule); + + } else if (msgBox.clickButton() == 2) { + + ScheduleDtailInfo newschedule; + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->getScheduleInfoById(m_ScheduleInfo.id, newschedule); + newschedule.ignore.append(m_ScheduleInfo.beginDateTime); + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->updateScheduleInfo(newschedule); + } + } + } + emit signalViewtransparentFrame(0); + emit signalsDelete(this); +} + +void CSchceduleSearchItem::slotDoubleEvent(int type) +{ + Q_UNUSED(type); + emit signalsDelete(this); +} + +void CSchceduleSearchItem::paintEvent( QPaintEvent *e ) +{ + Q_UNUSED(e); + int labelwidth = width(); + int labelheight = height(); + QPainter painter(this); + QColor bcolor = m_Backgroundcolor; + QColor textcolor = m_ttextcolor; + QColor timecolor = m_timecolor; + + switch (m_mouseStatus) { + case M_NONE: { + bcolor = m_Backgroundcolor; + textcolor = m_ttextcolor; + timecolor = m_timecolor; + } + break; + case M_HOVER: { + bcolor = m_hovercolor.background; + textcolor = m_hovercolor.textColor; + timecolor = m_hovercolor.timeColor; + } + break; + case M_PRESS: { + bcolor = m_presscolor.background; + textcolor = m_presscolor.textColor; + timecolor = m_presscolor.timeColor; + } + break; + } + painter.save(); + painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; + painter.setBrush(QBrush(bcolor)); + painter.setPen(Qt::NoPen); + QPainterPath painterPath; + painterPath.moveTo(m_radius, m_borderframew); + + if (m_roundtype == 1 || m_roundtype == 3) { + painterPath.arcTo(QRect(m_borderframew, m_borderframew, m_radius * 2, m_radius * 2), 90, 90); + } else { + painterPath.lineTo(m_borderframew, m_borderframew); + painterPath.lineTo(m_borderframew, m_radius); + } + painterPath.lineTo(0, labelheight - m_radius); + + if (m_roundtype == 1 || m_roundtype == 2) { + painterPath.arcTo(QRect(m_borderframew, labelheight - m_radius * 2, m_radius * 2, m_radius * 2), 180, 90); + } else { + painterPath.lineTo(m_borderframew, labelheight); + painterPath.lineTo(m_radius, labelheight); + } + painterPath.lineTo(labelwidth - m_radius, labelheight); + + if (m_roundtype == 1 || m_roundtype == 2) { + painterPath.arcTo(QRect(labelwidth - m_radius * 2, labelheight - m_radius * 2, m_radius * 2, m_radius * 2), 270, 90); + } else { + painterPath.lineTo(labelwidth, labelheight); + painterPath.lineTo(labelwidth, labelheight - m_radius); + } + painterPath.lineTo(labelwidth, m_radius); + + if (m_roundtype == 1 || m_roundtype == 3) { + + painterPath.arcTo(QRect(labelwidth - m_radius * 2, m_borderframew, m_radius * 2, m_radius * 2), 0, 90); + + } else { + painterPath.lineTo(labelwidth, m_borderframew); + painterPath.lineTo(labelwidth - m_radius, m_borderframew); + } + + painterPath.lineTo(m_radius, m_borderframew); + painterPath.closeSubpath(); + painter.drawPath(painterPath); + painter.restore(); + + painter.setFont(m_timefont); + painter.setPen(timecolor); + + QDate begindate = m_ScheduleInfo.beginDateTime.date(); + QDate enddate = m_ScheduleInfo.endDateTime.date(); + QString datestr; + + if (begindate == enddate) { + datestr = m_ScheduleInfo.beginDateTime.toString("hh:mm") + + "-" + m_ScheduleInfo.endDateTime.toString("hh:mm"); + } else { + datestr = m_ScheduleInfo.beginDateTime.toString("hh:mm") + + "-" + m_ScheduleInfo.endDateTime.toString("hh:mm"); + } + + QFontMetrics fm1(m_timefont); + int durationSize = 0; + durationSize = fm1.horizontalAdvance(datestr); + int flag = Qt::AlignLeft | Qt::AlignVCenter; + + if (m_ScheduleInfo.allday) { + datestr = tr("All Day"); + } + painter.drawText(QRect(12, 8, durationSize, labelheight - 16), flag, datestr); + + painter.save(); + bcolor = m_splitlinecolor; + QPen pen(bcolor); + pen.setWidth(2); + painter.setPen(pen); + painter.drawLine(durationSize + 17, 0, durationSize + 17, labelheight); + painter.restore(); + + painter.setFont(m_tfont); + painter.setPen(textcolor); + int tilenameW = labelwidth - 91; + QFontMetrics fm = painter.fontMetrics(); + QString tStitlename = m_ScheduleInfo.titleName; + tStitlename.replace("\n", ""); + QString str = tStitlename; + QString tstr; + + for (int i = 0; i < str.count(); i++) { + tstr.append(str.at(i)); + int widthT = fm.width(tstr) + 5; + if (widthT >= tilenameW) { + tstr.chop(1); + break; + } + } + + if (tstr != str) { + tstr = tstr + "..."; + } + + painter.drawText(QRect(durationSize + 17 + 9, 6, tilenameW, labelheight), Qt::AlignLeft, tstr); + painter.end(); +} +void CSchceduleSearchItem::contextMenuEvent( QContextMenuEvent *event ) +{ + Q_UNUSED(event); + + if (m_ScheduleInfo.type.ID == DDECalendar::FestivalTypeID) + return; + m_rightMenu->clear(); + m_rightMenu->addAction(m_editAction); + m_rightMenu->addAction(m_deleteAction); + m_rightMenu->exec(QCursor::pos()); +} + +void CSchceduleSearchItem::mouseDoubleClickEvent(QMouseEvent *event) +{ + Q_UNUSED(event); + emit signalViewtransparentFrame(1); + CMySchceduleView dlg(m_ScheduleInfo, this); + connect(&dlg, &CMySchceduleView::signalsEditorDelete, this, &CSchceduleSearchItem::slotDoubleEvent); + dlg.exec(); + disconnect(&dlg, &CMySchceduleView::signalsEditorDelete, this, &CSchceduleSearchItem::slotDoubleEvent); + emit signalViewtransparentFrame(0); + +} + +void CSchceduleSearchItem::mousePressEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) { + emit signalSelectDate(m_date); + emit signalSelectSchedule(m_ScheduleInfo); + } +} + +void CSchceduleSearchItem::mouseReleaseEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) { + m_mouseStatus = M_HOVER; + update(); + } +} + +void CSchceduleSearchItem::enterEvent(QEvent *event) +{ + Q_UNUSED(event); + m_mouseStatus = M_HOVER; + update(); +} + +void CSchceduleSearchItem::leaveEvent(QEvent *event) +{ + Q_UNUSED(event); + m_mouseStatus = M_NONE; + update(); +} + +bool CSchceduleSearchItem::eventFilter(QObject *o, QEvent *e) +{ + Q_UNUSED(o); + + if (e->type() == QEvent::MouseButtonPress) { + QMouseEvent *m_press = dynamic_cast(e); + if (m_press->button() == Qt::LeftButton) { + m_mouseStatus = M_PRESS; + } + } + update(); + return false; +} +CSchceduleSearchView::CSchceduleSearchView(QWidget *parent) + : DWidget(parent) +{ + QVBoxLayout *layout = new QVBoxLayout; + layout->setMargin(0); + layout->setSpacing(0); + m_gradientItemList = new CScheduleListWidget(parent); + m_gradientItemList->setAlternatingRowColors(true); + layout->setContentsMargins(0, 0, 0, 0); + layout->addWidget(m_gradientItemList); + // set default row + m_gradientItemList->setCurrentRow(0); + setLayout(layout); + setMouseTracking(true); + setFocusPolicy(Qt::StrongFocus); + m_bBackgroundcolor.setAlphaF(0.03); + m_gradientItemList->setLineWidth(0); + m_labellist.clear(); + + connect(m_gradientItemList, + &CScheduleListWidget::signalListWidgetScheduleHide, + this, + &CSchceduleSearchView::signalScheduleHide); +} + +CSchceduleSearchView::~CSchceduleSearchView() +{ + for (int i = 0; i < m_gradientItemList->count(); i++) { + QListWidgetItem *item11 = m_gradientItemList->takeItem(i); + m_gradientItemList->removeItemWidget(item11); + delete item11; + item11 = nullptr; + } + m_gradientItemList->clear(); +} + +void CSchceduleSearchView::setTheMe(int type) +{ + if (type == 0 || type == 1) { + m_bBackgroundcolor = "#000000"; + m_bBackgroundcolor.setAlphaF(0.03); + m_btimecolor = "#526A7F"; + m_bttextcolor = "#414D68"; + m_lBackgroundcolor = Qt::white; + m_ltextcolor = "#001A2E"; + } else if (type == 2) { + m_bBackgroundcolor = "#FFFFFF"; + m_bBackgroundcolor.setAlphaF(0.05); + m_btimecolor = "#6D7C88"; + m_bttextcolor = "#C0C6D4"; + m_lBackgroundcolor = "#FFFFFF"; + m_lBackgroundcolor.setAlphaF(0.0); + m_ltextcolor = "#C0C6D4"; + } + updateDateShow(); +} + +void CSchceduleSearchView::clearSearch() +{ + m_vlistData.clear(); + + for (int i = 0; i < m_gradientItemList->count(); i++) { + QListWidgetItem *item11 = m_gradientItemList->takeItem(i); + m_gradientItemList->removeItemWidget(item11); + delete item11; + item11 = nullptr; + } + m_labellist.clear(); + m_gradientItemList->clear(); + QVector vScheduleInfo; + CScheduleDataManage::getScheduleDataManage()->setSearchResult(vScheduleInfo); +} + +void CSchceduleSearchView::setMaxWidth(const int w) +{ + m_maxWidth = w; +} + +void CSchceduleSearchView::updateDateShow() +{ + m_currentItem = nullptr; + + for (int i = 0; i < m_gradientItemList->count(); i++) { + QListWidgetItem *item11 = m_gradientItemList->takeItem(i); + m_gradientItemList->removeItemWidget(item11); + delete item11; + item11 = nullptr; + } + m_gradientItemList->clear(); + m_labellist.clear(); + //找最近日程 + QDate tcurrentdata = QDate::currentDate(); + QVector m_showData; + ScheduleDateRangeInfo showData; + qint64 offset = 1000; + QDate topdate = tcurrentdata; + + for (int i = 0; i < m_vlistData.size(); ++i) { + qint64 d = qAbs(m_vlistData.at(i).date.daysTo(tcurrentdata)); + + showData.date = m_vlistData.at(i).date; + + for (int j = 0 ; j < m_vlistData.at(i).vData.size(); ++j) { + if (m_vlistData.at(i).vData.at(j).beginDateTime.date() == m_vlistData.at(i).date) { + showData.vData.append(m_vlistData.at(i).vData.at(j)); + } + } + if (showData.vData.count() > 0) { + if ( dcount() == 0) { + QListWidgetItem *listItem = new QListWidgetItem(m_gradientItemList); + DLabel *gwi = new DLabel(); + QFont font; + font.setPixelSize(DDECalendar::FontSizeTwenty); + gwi->setAlignment(Qt::AlignCenter ); + DPalette daypa = gwi->palette(); + QColor textcolor = DPalette::ToolTipText; + int themtype = CScheduleDataManage::getScheduleDataManage()->getTheme(); + if (themtype == 2) { + textcolor = "#C0C6D4"; + textcolor.setAlphaF(0.4); + } else { + textcolor = "#000000"; + textcolor.setAlphaF(0.3); + } + daypa.setColor(DPalette::WindowText, textcolor); + daypa.setColor(DPalette::Window, m_lBackgroundcolor); + gwi->setPalette(daypa); + gwi->setForegroundRole(DPalette::WindowText); + gwi->setFont(font); + gwi->move(this->width() - 70, this->height() - 196); + gwi->setText(tr("No search results")); + gwi->setFixedSize(m_maxWidth - 20, 450); + listItem->setSizeHint(QSize(m_maxWidth, 450)); //每次改变Item的高度 + listItem->setFlags(Qt::ItemIsTristate ); + m_gradientItemList->addItem(listItem); + m_gradientItemList->setItemWidget(listItem, gwi); + m_labellist.append(gwi); + } + if (m_currentItem != nullptr) { + m_gradientItemList->scrollToItem(m_currentItem, QAbstractItemView::PositionAtTop); + } + +} + +void CSchceduleSearchView::createItemWidget(ScheduleDtailInfo info, QDate date, int rtype) +{ + ScheduleDtailInfo &gd = info; + CSchedulesColor gdcolor = CScheduleDataManage::getScheduleDataManage()->getScheduleColorByType(gd.type.ID); + + CSchceduleSearchItem *gwi = new CSchceduleSearchItem(); + QFont font; + font.setPixelSize(DDECalendar::FontSizeFourteen); + font.setWeight(QFont::Normal); + gwi->setBackgroundColor(m_bBackgroundcolor); + QColor scolor = gdcolor.Purecolor; + scolor.setAlphaF(1.0); + gwi->setSplitLineColor(gdcolor.splitColor); + gwi->setText(m_bttextcolor, font); + font.setPixelSize(DDECalendar::FontSizeTwelve); + + gwi->setTimeC(m_btimecolor, font); + gwi->setFixedSize(m_maxWidth - 20, 35); + gwi->setData(gd, date); + gwi->setRoundtype(rtype); + connect(gwi, &CSchceduleSearchItem::signalsDelete, this, &CSchceduleSearchView::slotdeleteitem); + connect(gwi, &CSchceduleSearchItem::signalsEdit, this, &CSchceduleSearchView::slotedititem); + connect(gwi, &CSchceduleSearchItem::signalSelectDate, this, &CSchceduleSearchView::slotSelectDate); + connect(gwi, &CSchceduleSearchItem::signalSelectSchedule, this, &CSchceduleSearchView::slotSelectSchedule); + connect(gwi, &CSchceduleSearchItem::signalViewtransparentFrame, this, &CSchceduleSearchView::signalViewtransparentFrame); + + QListWidgetItem *listItem = new QListWidgetItem; + listItem->setSizeHint(QSize(m_maxWidth - 5, 36)); //每次改变Item的高度 + listItem->setFlags(Qt::ItemIsTristate ); + m_gradientItemList->addItem(listItem); + m_gradientItemList->setItemWidget(listItem, gwi); + m_labellist.append(gwi); +} + +QListWidgetItem *CSchceduleSearchView::createItemWidget(QDate date) +{ + CSchceduleSearchDateItem *gwi = new CSchceduleSearchDateItem(); + QFont font; + font.setWeight(QFont::Medium); + font.setPixelSize(DDECalendar::FontSizeSixteen); + gwi->setBackgroundColor(m_lBackgroundcolor); + gwi->setText(m_ltextcolor, font); + + if (date == QDate::currentDate()) { + int themtype = CScheduleDataManage::getScheduleDataManage()->getTheme(); + if (themtype == 2) { + gwi->setText(CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(), font); + } else { + gwi->setText(CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(), font); + } + + } + gwi->setFixedSize(m_maxWidth - 20, 35); + gwi->setDate(date); + connect(gwi, + &CSchceduleSearchDateItem::signalLabelScheduleHide, + this, + &CSchceduleSearchView::signalScheduleHide); + QListWidgetItem *listItem = new QListWidgetItem; + listItem->setSizeHint(QSize(m_maxWidth - 5, 36)); //每次改变Item的高度 + listItem->setFlags(Qt::ItemIsTristate ); + m_gradientItemList->addItem(listItem); + m_gradientItemList->setItemWidget(listItem, gwi); + m_labellist.append(gwi); + return listItem; +} + +void CSchceduleSearchView::slotdeleteitem( CSchceduleSearchItem *item ) +{ + emit signalsUpdateShcedule(item->getData().id); + updateDateShow(); + update(); +} + +void CSchceduleSearchView::slotedititem(CSchceduleSearchItem *item) +{ + emit signalsUpdateShcedule(item->getData().id); +} + +void CSchceduleSearchView::slotsetSearch(QString str) +{ + if (str.isEmpty()) return; + QDateTime date = QDateTime::currentDateTime(); + QDateTime bdate = date.addMonths(-6); + + if (!bdate.isValid()) { + QDateTime tdate = date; + tdate.setDate(QDate(date.date().year(), date.date().month(), 1)); + bdate = tdate.addMonths(-6); + } + + QDateTime edate = date.addMonths(6); + + if (!edate.isValid()) { + QDateTime tdate = date; + tdate.setDate(QDate(date.date().year(), date.date().month(), 1)); + edate = tdate.addMonths(7); + edate = edate.addDays(-1); + } + QVector vScheduleInfo; + m_vlistData.clear(); + + CScheduleDataManage::getScheduleDataManage()->getscheduleDataCtrl()->queryScheduleInfo(str, bdate, edate, vScheduleInfo); + m_vlistData = vScheduleInfo; + CScheduleDataManage::getScheduleDataManage()->setSearchResult(vScheduleInfo); + updateDateShow(); +} + +void CSchceduleSearchView::slotSelectDate(QDate date) +{ + emit signalDate(date); +} + +void CSchceduleSearchView::slotSelectSchedule(const ScheduleDtailInfo &scheduleInfo) +{ + emit signalSelectSchedule(scheduleInfo); +} + +void CSchceduleSearchView::resizeEvent(QResizeEvent *event) +{ + for (int i = 0; i < m_gradientItemList->count(); i++) { + QListWidgetItem *item11 = m_gradientItemList->item(i); + item11->setSizeHint(QSize(m_maxWidth - 5, 36)); //每次改变Item的高度 + } + for (int i = 0; i < m_labellist.count(); i++) { + m_labellist.at(i)->setFixedSize(m_maxWidth - 20, 35); + m_labellist.at(i)->update(); + } + if (m_gradientItemList->count() == 1) { + QListWidgetItem *item11 = m_gradientItemList->item(0); + item11->setSizeHint(QSize(m_maxWidth, qRound(height() * 0.7978))); //每次改变Item的高度 + m_labellist.at(0)->setFixedSize(m_maxWidth, qRound(height() * 0.7978)); + m_labellist.at(0)->update(); + } + if (m_gradientItemList->count() >1) { + if (m_currentItem != nullptr) { + m_gradientItemList->scrollToItem(m_currentItem, QAbstractItemView::PositionAtTop); + } + } + DWidget::resizeEvent(event); +} + +void CSchceduleSearchView::mousePressEvent(QMouseEvent *event) +{ + DWidget::mousePressEvent(event); +} + +CSchceduleSearchDateItem::CSchceduleSearchDateItem(QWidget *parent) + : DLabel(parent) +{ + //设置对象名称和辅助显示名称 + this->setObjectName("CScheduleDateItem"); + this->setAccessibleName("CScheduleDateItem"); + setAutoFillBackground(true); +} + +void CSchceduleSearchDateItem::setBackgroundColor(QColor color1) +{ + m_Backgroundcolor = color1; +} + +void CSchceduleSearchDateItem::setText(QColor tcolor, QFont font) +{ + m_textcolor = tcolor; + m_font = font; +} + +void CSchceduleSearchDateItem::setDate(QDate date) +{ + m_date = date; +} + +void CSchceduleSearchDateItem::paintEvent(QPaintEvent *e) +{ + Q_UNUSED(e); + int labelwidth = width(); + int labelheight = height(); + + QPainter painter(this); + QRect fillRect = QRect(0, 0, labelwidth, labelheight); + painter.setRenderHints(QPainter::HighQualityAntialiasing); + painter.setBrush(QBrush(m_Backgroundcolor)); + painter.setPen(Qt::NoPen); + painter.drawRoundedRect(fillRect, 3, 3); + + painter.setFont(m_font); + painter.setPen(m_textcolor); + + QLocale locale; + QString datestr; + + if (locale.language() == QLocale::Chinese) { + datestr = QString::number(m_date.year()) + tr("Y") + QString::number(m_date.month()) + tr("M") + QString::number(m_date.day()) + tr("D"); + } else { + datestr = m_date.toString("yyyy/M/d"); + } + painter.drawText(QRect(12, 8, labelwidth, labelheight - 8), Qt::AlignLeft, datestr); + painter.end(); +} + +void CSchceduleSearchDateItem::mousePressEvent(QMouseEvent *event) +{ + Q_UNUSED(event); + emit signalLabelScheduleHide(); +} + +CScheduleListWidget::CScheduleListWidget(QWidget *parent) + : DListWidget (parent) +{ + //设置对象名称和辅助显示名称 + this->setObjectName("CScheduleListWidget"); + this->setAccessibleName("CScheduleListWidget"); +} + +CScheduleListWidget::~CScheduleListWidget() +{ + +} + +void CScheduleListWidget::mousePressEvent(QMouseEvent *event) +{ + DListWidget::mousePressEvent(event); + emit signalListWidgetScheduleHide(); +} diff -Nru dde-calendar-5.7.0.4/src/widget/schcedulesearchview.h dde-calendar-5.7.0.23/src/widget/schcedulesearchview.h --- dde-calendar-5.7.0.4/src/widget/schcedulesearchview.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/schcedulesearchview.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,172 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#ifndef SCHCEDULESEARCHVIEW_H +#define SCHCEDULESEARCHVIEW_H + +#include "schedulestructs.h" + +#include +#include +#include +#include + +DWIDGET_USE_NAMESPACE +class QVBoxLayout; +class CScheduleListWidget; +class CSchceduleSearchItem; +class CSchceduleSearchDateItem; +class CSchceduleSearchView : public DWidget +{ + Q_OBJECT +public: + CSchceduleSearchView(QWidget *parent = nullptr); + ~CSchceduleSearchView() override; + void setTheMe(int type = 0); + void clearSearch(); + void setMaxWidth(const int w); +signals: + void signalsUpdateShcedule(int id = 0); + void signalDate(QDate date); + void signalSelectSchedule(const ScheduleDtailInfo &scheduleInfo); + void signalViewtransparentFrame(int type); + void signalScheduleHide(); +public slots: + void slotdeleteitem(CSchceduleSearchItem *item); + void slotedititem(CSchceduleSearchItem *item); + void slotsetSearch(QString str); + void slotSelectDate(QDate date); + void slotSelectSchedule(const ScheduleDtailInfo &scheduleInfo); +protected: + void resizeEvent(QResizeEvent *event) override; + void mousePressEvent(QMouseEvent *event) override; +private: + void updateDateShow(); + void createItemWidget(ScheduleDtailInfo info, QDate date, int rtype); + QListWidgetItem *createItemWidget(QDate date); +private: + CScheduleListWidget *m_gradientItemList = nullptr; //下拉列表窗 + bool m_widgetFlag; + QVector m_vlistData; + QVector m_labellist; + int m_type; + QDate m_currentDate; + QColor m_bBackgroundcolor = "#000000"; + QColor m_btimecolor = "#526A7F"; + QColor m_bttextcolor = "#414D68"; + QColor m_lBackgroundcolor = Qt::white; + QColor m_ltextcolor = "#001A2E"; + QListWidgetItem *m_currentItem = nullptr; + int m_maxWidth = 200; +}; + +class CScheduleListWidget : public DListWidget +{ + Q_OBJECT +public: + CScheduleListWidget(QWidget *parent = nullptr); + ~CScheduleListWidget() override; +signals: + void signalListWidgetScheduleHide(); +protected: + void mousePressEvent(QMouseEvent *event) override; +}; + +class CSchceduleSearchItem : public DLabel +{ + Q_OBJECT + enum MouseStatus {M_NONE,M_PRESS,M_HOVER}; +public: + explicit CSchceduleSearchItem(QWidget *parent = nullptr); + void setBackgroundColor(QColor color1); + void setSplitLineColor(QColor color1); + void setText(QColor tcolor, QFont font); + void setTimeC(QColor tcolor, QFont font); + void setData(ScheduleDtailInfo vScheduleInfo, QDate date); + void setRoundtype(int rtype); + void setTheMe(int type = 0); + const ScheduleDtailInfo &getData() const + { + return m_ScheduleInfo; + } +signals: + void signalsDelete(CSchceduleSearchItem *item); + void signalsEdit(CSchceduleSearchItem *item); + void signalSelectDate(QDate date); + void signalSelectSchedule(const ScheduleDtailInfo &scheduleInfo); + void signalViewtransparentFrame(int type); +public slots: + void slotEdit(); + void slotDelete(); + void slotDoubleEvent(int type = 0); +protected: + void paintEvent(QPaintEvent *e) override; + void contextMenuEvent(QContextMenuEvent *event) override; + void mouseDoubleClickEvent(QMouseEvent *event) override; + void mousePressEvent(QMouseEvent *event) override; + void mouseReleaseEvent(QMouseEvent *event) override; + void enterEvent(QEvent *event) override; + void leaveEvent(QEvent *event) override; + bool eventFilter(QObject *o, QEvent *e) override; + +private: + struct ColorStatus { + QColor background; + QColor timeColor; + QColor textColor; + }; + ScheduleDtailInfo m_ScheduleInfo; + QAction *m_editAction = nullptr; + QAction *m_deleteAction = nullptr; + QColor m_Backgroundcolor; + ColorStatus m_presscolor; + ColorStatus m_hovercolor; + QColor m_timecolor; + QColor m_splitlinecolor; + QFont m_timefont; + QColor m_ttextcolor; + QFont m_tfont; + QDate m_date; + MouseStatus m_mouseStatus; + DMenu *m_rightMenu = nullptr; + int m_roundtype = 1; + const int m_radius = 8; + const int m_borderframew = 0; +}; +class CSchceduleSearchDateItem : public DLabel +{ + Q_OBJECT + +public: + explicit CSchceduleSearchDateItem(QWidget *parent = nullptr); + void setBackgroundColor(QColor color1); + void setText(QColor tcolor, QFont font); + void setDate(QDate date); +signals: + void signalLabelScheduleHide(); +protected: + void paintEvent(QPaintEvent *e) override; + void mousePressEvent(QMouseEvent *event) override; + +private: + QColor m_Backgroundcolor; + QColor m_textcolor; + QFont m_font; + QDate m_date; +}; +#endif // CSHCEDULEDAYVIEW_H diff -Nru dde-calendar-5.7.0.4/src/widget/weekWidget/weekheadview.cpp dde-calendar-5.7.0.23/src/widget/weekWidget/weekheadview.cpp --- dde-calendar-5.7.0.4/src/widget/weekWidget/weekheadview.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/weekWidget/weekheadview.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,602 @@ +/* + * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ + +#include "weekheadview.h" +#include "calendardbus.h" +#include "customframe.h" +#include "scheduledatamanage.h" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +DGUI_USE_NAMESPACE +CWeekHeadView::CWeekHeadView(QWidget *parent) + : DFrame(parent) +{ + setContentsMargins(0, 0, 0, 0); + m_DBusInter = new CalendarDBus("com.deepin.api.LunarCalendar", + "/com/deepin/api/LunarCalendar", + QDBusConnection::sessionBus(), this); + if (!queue) + queue = new QQueue; + + if (!lunarCache) + lunarCache = new QMap; + + if (!emptyCaLunarDayInfo) + emptyCaLunarDayInfo = new CaLunarDayInfo; + + m_dayNumFont.setWeight(QFont::Medium); + m_dayNumFont.setPixelSize(DDECalendar::FontSizeSixteen); + m_monthFont.setWeight(QFont::Medium); + m_monthFont.setPixelSize(DDECalendar::FontSizeTwenty); + + // cells grid + QHBoxLayout *hboxLayout = new QHBoxLayout; + hboxLayout->setMargin(0); + hboxLayout->setSpacing(0); + + m_monthLabel = new CustomFrame(this); + m_monthLabel->setFixedWidth(DDEWeekCalendar::WMCellHeadrWidth - 5); + m_monthLabel->setRoundState(true, false, false, false); + QFont mlabelF; + mlabelF.setWeight(QFont::Medium); + mlabelF.setPixelSize(DDECalendar::FontSizeTwenty); + m_monthLabel->setTextFont(mlabelF); + hboxLayout->addWidget(m_monthLabel); + hboxLayout->setStretch(0, 0); + hboxLayout->setSpacing(0); + + for (int c = 0; c != DDEWeekCalendar::AFewDaysofWeek; ++c) { + QWidget *cell = new QWidget(this); + cell->installEventFilter(this); + cell->setFocusPolicy(Qt::ClickFocus); + hboxLayout->addWidget(cell); + m_cellList.append(cell); + } + + setLayout(hboxLayout); + + connect(this, &CWeekHeadView::dateSelected, this, &CWeekHeadView::handleCurrentDateChanged); + setFrameRounded(false); + + m_monthList.append( "一月" ); + m_monthList.append( "二月"); + m_monthList.append( "三月" ); + m_monthList.append( "四月" ); + m_monthList.append( "五月" ); + m_monthList.append( "六月" ); + m_monthList.append( "七月" ); + m_monthList.append( "八月"); + m_monthList.append( "九月" ); + m_monthList.append( "十月" ); + m_monthList.append( "十一月"); + m_monthList.append( "十二月"); +} + +CWeekHeadView::~CWeekHeadView() +{ + + if (lunarCache !=nullptr) { + delete lunarCache; + lunarCache = nullptr; + } + if (emptyCaLunarDayInfo != nullptr) { + delete emptyCaLunarDayInfo; + emptyCaLunarDayInfo = nullptr; + } + if (queue != nullptr) { + delete queue; + queue = nullptr; + } +} + +void CWeekHeadView::handleCurrentDateChanged(const QDate date, const CaLunarDayInfo &detail) +{ + Q_UNUSED(detail); + + if (date != m_currentDate) { + setCurrentDate(date); + } +} + +void CWeekHeadView::setFirstWeekday(int weekday) +{ + m_firstWeekDay = weekday; + updateDate(); +} + +int CWeekHeadView::getDateType(const QDate &date) +{ + const int currentIndex = getDateIndex(date); + const CaLunarDayInfo info = getCaLunarDayInfo(currentIndex); + const int dayOfWeek = date.dayOfWeek(); + bool weekends = dayOfWeek == DDEWeekCalendar::FirstDayofWeekend || dayOfWeek == DDEWeekCalendar::AFewDaysofWeek; + bool isCurrentMonth = m_currentDate.month() == date.month(); + bool isFestival = !info.mSolarFestival.isEmpty() || !info.mLunarFestival.isEmpty(); + int resultFlag = 0; + + if (!isCurrentMonth) + resultFlag |= SO_MNotCurrentMonth; + if (isFestival) + resultFlag |= SO_MFestival; + if (weekends) + resultFlag |= SO_MWeekends; + + return resultFlag; +} + +void CWeekHeadView::setTheMe(int type) +{ + m_themetype = type; + + if (type == 0 || type == 1) { + QColor textC = "#000000"; + QColor textbC(230, 238, 242); + + m_monthLabel->setBColor(textbC); + m_monthLabel->setTextColor(textC); + + m_backgroundCircleColor = "#0081FF"; + m_backgroundShowColor = "#2CA7F8"; + m_backgroundShowColor.setAlphaF(0.4); + m_Background_Weekend_Color = "#DAE4ED"; + + m_defaultTextColor = "#6F6F6F"; + m_currentDayTextColor = "#FFFFFF"; + m_defaultLunarColor = "#898989"; + m_weekendsTextColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); + m_currentMonthColor = "#000000"; + m_backgroudColor = "#E6EEF2"; + m_solofestivalLunarColor = "#4DFF7272"; + } else if (type == 2) { + QColor textbC = "#82AEC1"; + textbC.setAlphaF(0.1); + m_monthLabel->setBColor(textbC); + m_monthLabel->setTextColor("#BF1D63"); + m_backgroundCircleColor = "#0059D2"; + m_backgroundShowColor = "#002AAF"; + m_backgroundShowColor.setAlphaF(0.4); + m_Background_Weekend_Color = "#333D4A"; + + m_defaultTextColor = "#C0C6D4"; + m_currentDayTextColor = "#C0C6D4"; + m_defaultLunarColor = "#6886BA"; + m_weekendsTextColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); + m_currentMonthColor = "#000000"; + m_backgroudColor = "#82AEC1"; + m_backgroudColor.setAlphaF(0.1); + m_solofestivalLunarColor = "#4DFF7272"; + } + + for (int i = 0; i != DDEWeekCalendar::AFewDaysofWeek; ++i) + m_cellList.at(i)->update(); +} + +void CWeekHeadView::setWeekDay(QVector vDays) +{ + if (vDays.count() != DDEWeekCalendar::AFewDaysofWeek) + return; + + for (int i = 0; i != DDEWeekCalendar::AFewDaysofWeek; ++i) + m_days[i] = vDays[i]; +} + +void CWeekHeadView::setMounthLabelWidth(int w, int rw) +{ + m_monthW = w + 1; + m_fixwidth = rw; +} + +void CWeekHeadView::setCurrentDate(const QDate date) +{ + qDebug() << "set current date " << date; + + if (date == m_currentDate) { + return; + } + m_currentDate = date; + + emit signalcurrentDateChanged(m_currentDate); + // to refresh lunar calendar + updateCurrentLunar(getCaLunarDayInfo(getDateIndex(m_currentDate))); + QLocale locale; + m_monthLabel->setTextStr(locale.monthName(date.month(), QLocale::ShortFormat)); +} + +void CWeekHeadView::setLunarVisible(bool visible) +{ + int state = int(m_showState); + + if (visible) + state |= ShowLunar; + else + state &= ~ShowLunar; + + m_showState = ShowState(state); + update(); +} + +void CWeekHeadView::setCellSelectable(bool selectable) +{ + if (selectable == m_cellSelectable) + return; + + m_cellSelectable = selectable; + + emit cellSelectableChanged(m_cellSelectable); +} + +int CWeekHeadView::getDateIndex(const QDate &date) const +{ + for (int i = 0; i != DDEWeekCalendar::AFewDaysofWeek; ++i) + if (m_days[i] == date) + return i; + + return 0; +} + +bool CWeekHeadView::eventFilter(QObject *o, QEvent *e) +{ + QWidget *cell = qobject_cast(o); + + if (cell && m_cellList.contains(cell)) { + if (e->type() == QEvent::Paint) { + paintCell(cell); + } else if (e->type() == QEvent::MouseButtonPress) { + } else if (e->type() == QEvent::MouseButtonDblClick) { + const int pos = m_cellList.indexOf(cell); + emit signalsViewSelectDate(m_days[pos]); + } + } + + return false; +} + +void CWeekHeadView::updateDate() +{ + const int currentIndex = getDateIndex(m_currentDate); + setSelectedCell(currentIndex); + update(); +} + +void CWeekHeadView::updateCurrentLunar(const CaLunarDayInfo &info) +{ + if (!info.mLunarFestival.isEmpty()) { + emit currentFestivalChanged(info.mLunarFestival); + } else if (!info.mTerm.isEmpty()) { + emit currentFestivalChanged(info.mTerm); + } else if (!info.mSolarFestival.isEmpty()) { + QStringList tmpFestival = info.mSolarFestival.split(" "); + + if (tmpFestival.length() >= 3) { + emit currentFestivalChanged(QString("%1 %2").arg(tmpFestival[0]).arg(tmpFestival[1])); + } else { + emit currentFestivalChanged(info.mSolarFestival); + } + } else { + emit currentFestivalChanged(""); + } + + QVector vdate; + QVector vdetail; + + for (int i = 0; i < DDEWeekCalendar::AFewDaysofWeek; i++) { + vdate.append(m_days[i]); + vdetail.append(getCaLunarDayInfo(getDateIndex(m_days[i]))); + } + + emit signalcurrentLunarDateChanged(vdate, vdetail, 1); + updateDate(); +} + +const QString CWeekHeadView::getCellDayNum(int pos) +{ + return QString::number(m_days[pos].day()); +} + +const QDate CWeekHeadView::getCellDate(int pos) +{ + return m_days[pos]; +} + +const QString CWeekHeadView::getLunar(int pos) +{ + CaLunarDayInfo info = getCaLunarDayInfo(pos); + + if (info.mLunarDayName == "初一") { + info.mLunarDayName = info.mLunarMonthName; + } + + if (info.mTerm.isEmpty()) + return info.mLunarDayName; + + return info.mTerm; +} + +const CaLunarDayInfo CWeekHeadView::getCaLunarDayInfo(int pos) +{ + const QDate date = m_days[pos]; + + if (lunarCache->contains(date)) { + return lunarCache->value(date); + } + + if (lunarCache->size() > 300) + lunarCache->clear(); + + queue->push_back(pos); + + QTimer::singleShot(300, this, SLOT(getDbusData())); + + return *emptyCaLunarDayInfo; +} + +void CWeekHeadView::getDbusData() +{ + if (queue->isEmpty()) + return; + + const int pos = queue->head(); + queue->pop_front(); + const QDate date = m_days[pos]; + + if (!date.isValid()) { + return; + } + + CaLunarDayInfo currentDayInfo; + + if (!lunarCache->contains(date)) { + bool o1 = true; + QDBusReply reply = m_DBusInter->GetLunarMonthCalendar(date.year(), date.month(), false, o1); + + QDate cacheDate; + cacheDate.setDate(date.year(), date.month(), 1); + foreach (const CaLunarDayInfo &dayInfo, reply.value().mCaLunarDayInfo) { + lunarCache->insert(cacheDate, dayInfo); + + if (date == m_currentDate) { + currentDayInfo = dayInfo; + } + cacheDate = cacheDate.addDays(1); + } + } else { + currentDayInfo = lunarCache->value(date); + } + + m_cellList.at(pos)->update(); + + // refresh lunar info + if (date == m_currentDate) { + updateCurrentLunar(currentDayInfo); + } +} + +void CWeekHeadView::paintCell(QWidget *cell) +{ + m_weekendsTextColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); + const QRect rect(0, 0, cell->width(), cell->height()); + const int pos = m_cellList.indexOf(cell); + const bool isCurrentDay = getCellDate(pos) == QDate::currentDate(); + const bool isSelectedCell = isCurrentDay; + int d = m_days[pos].dayOfWeek(); + + QPainter painter(cell); + painter.setRenderHint(QPainter::Antialiasing); + painter.setPen(Qt::NoPen); + //根据周几设置不一样的背景色 + if (d == DDEWeekCalendar::FirstDayofWeekend || d == DDEWeekCalendar::AFewDaysofWeek) { + painter.setBrush(QBrush(m_Background_Weekend_Color)); + } else { + painter.setBrush(QBrush(m_backgroudColor)); + } + if (d != 6) { + painter.drawRect(rect);//画矩形 + } else { + int labelwidth = cell->width(); + int labelheight = cell->height(); + QPainterPath painterPath; + painterPath.moveTo(m_radius, 0); + + painterPath.lineTo(0, 0); + painterPath.lineTo(0, m_radius); + painterPath.lineTo(0, labelheight - m_radius); + painterPath.lineTo(0, labelheight); + painterPath.lineTo(m_radius, labelheight); + painterPath.lineTo(labelwidth - m_radius, labelheight); + painterPath.lineTo(labelwidth, labelheight); + painterPath.lineTo(labelwidth, labelheight - m_radius); + painterPath.lineTo(labelwidth, m_radius); + painterPath.arcTo(QRect(labelwidth - m_radius * 2, 0, m_radius * 2, m_radius * 2), 0, 90); + painterPath.lineTo(m_radius, 0); + painterPath.closeSubpath(); + painter.drawPath(painterPath); + } + //绘制分割线 + if (d != DDEWeekCalendar::FirstDayofWeekend && d != DDEWeekCalendar::AFewDaysofWeek) { + QPoint point_begin(cell->width(), 0); + QPoint point_end(cell->width(), cell->height()); + painter.save(); + QColor m_linecolor = "#000000"; + m_linecolor.setAlphaF(0.1); + painter.setPen(m_linecolor); + painter.drawLine(point_begin, point_end); + painter.restore(); + } + + int bw = (cell->width() - 104) / 2; + int bh = (cell->height() - 26) / 2; + + if (bw < 0) { + bw = 2; + } + if (bh < 0) { + bh = 2; + } + if (isSelectedCell) { + if (m_showState & ShowLunar) { + QRect fillRect(bw - 2, bh, 26, 26); + painter.save(); + painter.setRenderHint(QPainter::Antialiasing); + painter.setBrush(QBrush(CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor())); + painter.setPen(Qt::NoPen); + painter.drawEllipse(fillRect); + painter.restore(); + } else { + QRect fillRect(cell->width() - (cell->width()/2) + 1, bh - 1, 26, 26); + painter.save(); + painter.setRenderHint(QPainter::Antialiasing); + painter.setBrush(QBrush(CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor())); + painter.setPen(Qt::NoPen); + painter.drawEllipse(fillRect); + painter.restore(); + } + + } + QLocale locale; + const QString dayNum = getCellDayNum(pos); + const QString dayLunar = getLunar(pos); + QString dayWeek = locale.dayName(d ? d : DDEWeekCalendar::AFewDaysofWeek, QLocale::ShortFormat); + + painter.save(); + painter.setPen(Qt::SolidLine); + // draw text of day + if (isSelectedCell) { + painter.setPen(m_currentDayTextColor); + } else if (isCurrentDay) { + painter.setPen(m_weekendsTextColor); + } else { + if (d == DDEWeekCalendar::FirstDayofWeekend || d == DDEWeekCalendar::AFewDaysofWeek) + painter.setPen(m_weekendsTextColor); + else + painter.setPen(m_defaultTextColor); + } + + painter.setFont(m_dayNumFont); + + if (m_showState & ShowLunar) { + painter.drawText(QRect(bw - 1, bh, 24, 24), Qt::AlignCenter, dayNum); + if (d == DDEWeekCalendar::FirstDayofWeekend || d == DDEWeekCalendar::AFewDaysofWeek) + painter.setPen(m_weekendsTextColor); + else + painter.setPen(m_defaultTextColor); + painter.drawText(QRect(bw + 24, bh, 30, 25), Qt::AlignCenter, dayWeek); + } else { + QFontMetrics fm1 = painter.fontMetrics(); + painter.drawText(QRect(cell->width() - (cell->width()/2) - 4, bh - 1, 36, 26), Qt::AlignCenter, dayNum); + if (d == DDEWeekCalendar::FirstDayofWeekend || d == DDEWeekCalendar::AFewDaysofWeek) + painter.setPen(m_weekendsTextColor); + else + painter.setPen(m_defaultTextColor); + + QFontMetrics fm = painter.fontMetrics(); + + while (fm.width(dayWeek) > cell->width()/2) + dayWeek.chop(1); + + painter.drawText(QRect(0, bh, (cell->width()/2), 26), Qt::AlignRight, dayWeek); + } + // draw text of day type + if (m_showState & ShowLunar) { + if (cell->width() > 100) { + if (d == DDEWeekCalendar::FirstDayofWeekend || d == DDEWeekCalendar::AFewDaysofWeek) + painter.setPen(m_weekendsTextColor); + else + painter.setPen(m_defaultLunarColor); + + if (cell->width() < 132) { + QString str_dayLunar = nullptr; + if (dayLunar.count() > 2) { + for (int i = 0; i < 2; i++) { + str_dayLunar.append(dayLunar.at(i)); + } + str_dayLunar.append("..."); + } else { + str_dayLunar = dayLunar; + } + painter.drawText(QRect(bw + 52 + 10, bh, 50, 25), Qt::AlignLeft, str_dayLunar); + } else { + painter.drawText(QRect(bw + 52 + 10, bh, 50, 25), Qt::AlignLeft, dayLunar); + } + CaLunarDayInfo dayInfo = getCaLunarDayInfo(pos); + } + } + painter.restore(); + painter.end(); +} + +void CWeekHeadView::cellClicked(QWidget *cell) +{ + if (!m_cellSelectable) + return; + + const int pos = m_cellList.indexOf(cell); + if (pos == -1) + return; + + setSelectedCell(pos); + + // my gift eggs + static int gift = 0; + + if (m_days[pos] == QDate(1993, 7, 28)) + if (++gift == 10) + QMessageBox::about(this, "LinuxDeepin", "by shibowen :P"); +} + +void CWeekHeadView::setSelectedCell(int index) +{ + if (m_selectedCell == index) + return; + + const int prevPos = m_selectedCell; + m_selectedCell = index; + + m_cellList.at(prevPos)->update(); + m_cellList.at(index)->update(); + emit dateSelected(m_days[index], getCaLunarDayInfo(index)); +} + +int CWeekHeadView::checkDay(int weekday) +{ + // check the week, calculate the correct order in the custom. + if (weekday <= 0) + return weekday += DDEWeekCalendar::AFewDaysofWeek; + + if (weekday > DDEWeekCalendar::AFewDaysofWeek) + return weekday -= DDEWeekCalendar::AFewDaysofWeek; + + return weekday; +} + +void CWeekHeadView::mousePressEvent(QMouseEvent *event) +{ + Q_UNUSED(event); + emit signaleSchedulHide(); +} diff -Nru dde-calendar-5.7.0.4/src/widget/weekWidget/weekheadview.h dde-calendar-5.7.0.23/src/widget/weekWidget/weekheadview.h --- dde-calendar-5.7.0.4/src/widget/weekWidget/weekheadview.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/weekWidget/weekheadview.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,283 @@ +/* + * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ + +#ifndef WEEKHEADVIEW_H +#define WEEKHEADVIEW_H + +#include "constants.h" +#include "calendardbus.h" + +#include +#include + +#include +#include +#include +#include +#include + +DWIDGET_USE_NAMESPACE + +enum CalendarWeekDayType { + SO_MFestival = QStyleOption::SO_CustomBase + 0x01, + SO_MWeekends = QStyleOption::SO_CustomBase + 0x02, + SO_MWeekendsAndFestival = SO_MFestival | SO_MWeekends, + SO_MNotCurrentMonth = 0x04, + SO_MNotCurrentMonthFestival = SO_MNotCurrentMonth | SO_MFestival, + SO_MDefault, +}; +class CustomFrame; +class CWeekHeadView: public DFrame +{ + Q_OBJECT +public: + enum ShowState { + ShowLunar = 0x01, + ShowLunarFestivalHighlight = 0x02, + Normal = ShowLunar | ShowLunarFestivalHighlight, + }; + +public: + /** + * @brief CWeekHeadView 构造函数 + * @param parent 父类 + */ + explicit CWeekHeadView(QWidget *parent = nullptr); + /** + * @brief CWeekHeadView 析构函数 + */ + ~CWeekHeadView() override; + /** + * @brief setFirstWeekday 设置每周的第一天是周几 + * @param weekday 周几 + */ + void setFirstWeekday(int weekday); + /** + * @brief getDateType 获取所给日期的类型CalendarWeekDayType + * @param date 日期 + * @return 类型 + */ + int getDateType(const QDate &date); + /** + * @brief cellSelectable + * @return + */ + inline bool cellSelectable() const + { + return m_cellSelectable; + } + /** + * @brief setTheMe 根据系统主题类型设置颜色 + * @param type 系统主题类型 + */ + void setTheMe(int type = 0); + /** + * @brief setWeekDay 设置一周的时间 + * @param vDays 一周代表的时间 + */ + void setWeekDay(QVector vDays); + /** + * @brief setMounthLabelWidth 设置 + * @param w + * @param rw + */ + void setMounthLabelWidth(int w, int rw); +signals: + /** + * @brief dateSelected 选择时间的信号 + * @param date 时间 + * @param detail 时间的阴历信息 + */ + void dateSelected(const QDate date, const CaLunarDayInfo &detail) const; + /** + * @brief signalcurrentLunarDateChanged 当前周的阴历日期改变的信号 + * @param vdate 一周的日期 + * @param vdetail 一周的阴历信息 + * @param type 是否显示信息 + */ + void signalcurrentLunarDateChanged(QVector vdate, QVector vdetail, int type = 0); + /** + * @brief signalcurrentDateChanged 当前时间改变的信号 + * @param date 当前时间 + */ + void signalcurrentDateChanged(QDate date); + /** + * @brief currentDateChanged + * @param year + * @param month + */ + void currentDateChanged(const int year, const int month); + /** + * @brief currentFestivalChanged 当前的节日信息改变的信号 + * @param festival 节日信息 + */ + void currentFestivalChanged(const QString &festival); + /** + * @brief cellSelectableChanged + * @param cellSelectable + */ + void cellSelectableChanged(bool cellSelectable) const; + /** + * @brief signalsViewSelectDate 选择日期的信号 + * @param date 日期 + */ + void signalsViewSelectDate(QDate date); + /** + * @brief signaleSchedulHide 隐藏日程浮框的信号 + */ + void signaleSchedulHide(); +public slots: + /** + * @brief setCurrentDate 设置当前的时间 + * @param date 日期 + */ + void setCurrentDate(const QDate date); + /** + * @brief setLunarVisible 设置是否显示阴历信息 + * @param visible 是否显示阴历信息 + */ + void setLunarVisible(bool visible); + /** + * @brief setCellSelectable + * @param selectable + */ + void setCellSelectable(bool selectable); + /** + * @brief handleCurrentDateChanged 当前日期改变的信号 + * @param date 日期 + * @param detail unused + */ + void handleCurrentDateChanged(const QDate date, const CaLunarDayInfo &detail); +private: + /** + * @brief getDateIndex 根据日期返回当天的索引 + * @param date 日期 + * @return 日期所在的索引 + */ + int getDateIndex(const QDate &date) const; + /** + * @brief getCellDayNum 根据索引值获取当天是在一个月中的第几天 + * @param pos 索引 + * @return 日期的字符串 + */ + const QString getCellDayNum(int pos); + /** + * @brief getCellDate 根据索引获取当天的日期 + * @param pos 索引值 + * @return 日期 + */ + const QDate getCellDate(int pos); + /** + * @brief getLunar 根据索引值获取当天的阴历信息 + * @param pos 索引值 + * @return 阴历信息字符串 + */ + const QString getLunar(int pos); + /** + * @brief getCaLunarDayInfo 根据索引值获取阴历信息 + * @param pos 索引值 + * @return 阴历信息 + */ + const CaLunarDayInfo getCaLunarDayInfo(int pos); + /** + * @brief paintCell 绘制周信息 + * @param cell 每天所在的widget + */ + void paintCell(QWidget *cell); + /** + * @brief eventFilter 过滤器 + * @param o 事件对象 + * @param e 时间类型 + * @return false + */ + bool eventFilter(QObject *o, QEvent *e) override; + /** + * @brief updateDate 更新数据 + */ + void updateDate(); + /** + * @brief updateCurrentLunar 更新当前的阴历信息 + * @param info 阴历信息 + */ + void updateCurrentLunar(const CaLunarDayInfo &info); + /** + * @brief checkDay 检查周数,在定制中计算正确的顺序。 + * @param weekday 周数 + * @return 周数 + */ + int checkDay(int weekday); +protected: + /** + * @brief mousePressEvent 鼠标单击事件 + * @param event 鼠标事件 + */ + void mousePressEvent(QMouseEvent *event) override; +private slots: + /** + * @brief cellClicked + * @param cell + */ + void cellClicked(QWidget *cell); + /** + * @brief setSelectedCell 设置选择的时间 + * @param index 索引值 + */ + void setSelectedCell(int index); + /** + * @brief getDbusData 获取dbus日期 + */ + void getDbusData(); +private: + QList m_cellList; + CustomFrame *m_monthLabel = nullptr; + CalendarDBus *m_DBusInter = nullptr; + QDate m_days[7]; + QDate m_currentDate; + QStringList m_monthList; + ShowState m_showState = Normal; + int m_selectedCell = 0; + bool m_cellSelectable = true; + + QFont m_dayNumFont; + QFont m_monthFont; + + QColor m_backgroundCircleColor = "#2ca7f8"; + QColor m_backgroundShowColor = "#2CA7F8"; + QColor m_defaultTextColor = "#6F6F6F"; + QColor m_currentDayTextColor = "#FFFFFF"; + QColor m_defaultLunarColor = "#898989"; + QColor m_weekendsTextColor = "#0887FF"; + QColor m_currentMonthColor = "#000000"; + QColor m_backgroudColor = "#E6EEF2"; + /** + * @brief m_Background_Weekend_Color 周六周日背景色 + */ + QColor m_Background_Weekend_Color = "#00429A"; + QColor m_solofestivalLunarColor = "#4DFF7272"; + QQueue *queue = nullptr; + QMap *lunarCache = nullptr; + CaLunarDayInfo *emptyCaLunarDayInfo = nullptr; + int m_firstWeekDay; + int m_themetype = 1; + int m_monthW = 80; + int m_fixwidth = 200; + const int m_radius = 8; +}; + +#endif // MYCALENDARWIDGET_H diff -Nru dde-calendar-5.7.0.4/src/widget/weekWidget/weekindicator.cpp dde-calendar-5.7.0.23/src/widget/weekWidget/weekindicator.cpp --- dde-calendar-5.7.0.4/src/widget/weekWidget/weekindicator.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/weekWidget/weekindicator.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ + +#include "weekindicator.h" + +#include +#include + +WeekIndicator::WeekIndicator(QWidget *parent) + : DWidget(parent) +{ + m_mainLayout = new QHBoxLayout; + m_mainLayout->setMargin(0); + m_mainLayout->setSpacing(0); + setLayout(m_mainLayout); +} + +void WeekIndicator::setList(int weekday) +{ + QLayoutItem *child; + + while ((child = m_mainLayout->takeAt(0)) != nullptr) { + if (child->widget() != nullptr) { + delete child->widget(); + } + delete child; + } + + QLocale locale; + + for (int i = 0; i != DDEWeekCalendar::AFewDaysofWeek; ++i) { + int d = checkDay(i - weekday); + DLabel *label = new DLabel(locale.dayName(d ? d : DDEWeekCalendar::AFewDaysofWeek, QLocale::ShortFormat)); + + if ((i == weekday - 1 && weekday != 0) || i == weekday || (weekday == 0 && i == 6)) { + label->setObjectName("CalendarHeaderWeekend"); + } else { + label->setObjectName("CalendarHeaderWeekday"); + } + + label->setAlignment(Qt::AlignCenter); + label->setFixedSize(DDECalendar::CellWidth, DDECalendar::HeaderItemHeight); + m_mainLayout->addWidget(label, 0, Qt::AlignCenter); + } +} + +int WeekIndicator::checkDay(int weekday) +{ + // check the week, calculate the correct order in the custom. + if (weekday <= 0) + return weekday += DDEWeekCalendar::AFewDaysofWeek; + + if (weekday > DDEWeekCalendar::AFewDaysofWeek) + return weekday -= DDEWeekCalendar::AFewDaysofWeek; + + return weekday; +} diff -Nru dde-calendar-5.7.0.4/src/widget/weekWidget/weekindicator.h dde-calendar-5.7.0.23/src/widget/weekWidget/weekindicator.h --- dde-calendar-5.7.0.4/src/widget/weekWidget/weekindicator.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/weekWidget/weekindicator.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ + +#ifndef WEEKINDICATOR_H +#define WEEKINDICATOR_H + +#include "constants.h" + +#include +#include + +#include +DWIDGET_USE_NAMESPACE +class WeekIndicator : public DWidget +{ + Q_OBJECT +public: + /** + * @brief WeekIndicator 构造函数 + * @param parent 父类 + */ + explicit WeekIndicator(QWidget *parent = nullptr); + /** + * @brief setList 设置周数 + * @param weekday 周数 + */ + void setList(int weekday); +private: + /** + * @brief checkDay 检查周数 + * @param weekday 周数 + * @return 周数 + */ + int checkDay(int weekday); + +private: + QHBoxLayout *m_mainLayout = nullptr; +}; + +#endif // WEEKINDICATOR_H diff -Nru dde-calendar-5.7.0.4/src/widget/weekWidget/weekview.cpp dde-calendar-5.7.0.23/src/widget/weekWidget/weekview.cpp --- dde-calendar-5.7.0.4/src/widget/weekWidget/weekview.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/weekWidget/weekview.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,293 @@ +/* + * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ + +#include "weekview.h" +#include "scheduledatamanage.h" +#include "constants.h" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +DWIDGET_USE_NAMESPACE + +CWeekView::CWeekView(QWidget *parent) + : QWidget(parent) +{ + m_dayNumFont.setPixelSize(DDECalendar::FontSizeSixteen); + m_dayNumFont.setWeight(QFont::Light); + // cells grid + QHBoxLayout *hboxLayout = new QHBoxLayout; + hboxLayout->setMargin(0); + hboxLayout->setSpacing(0); + + for (int c = 0; c != DDEWeekCalendar::NumWeeksDisplayed; ++c) { + QWidget *cell = new QWidget; + cell->setFixedSize(DDEWeekCalendar::WWeekCellWidth, DDEWeekCalendar::WWeekCellHeight); + cell->installEventFilter(this); + cell->setFocusPolicy(Qt::ClickFocus); + hboxLayout->addWidget(cell); + m_cellList.append(cell); + } + setLayout(hboxLayout); + setMinimumWidth(150); +} + +CWeekView::~CWeekView() +{ + for (int i = 0; i < DDEWeekCalendar::NumWeeksDisplayed; i++) { + m_cellList.at(i)->removeEventFilter(this); + delete m_cellList.at(i); + } + m_cellList.clear(); +} + +void CWeekView::setFirstWeekDay(int weekday) +{ + m_firstWeekDay = weekday; + updateDate(); +} + +void CWeekView::setCurrentDate(const QDate date) +{ + m_selectDate = date; + m_selectedCell = 0; + updateDate(); + update(); +} + +void CWeekView::setTheMe(int type) +{ + m_themetype = type; + + if (type == 0 || type == 1) { + m_defaultTextColor = Qt::black; + m_backgrounddefaultColor = Qt::white; + m_currentDayTextColor = Qt::white; + m_backgroundcurrentDayColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); + m_fillColor = "#FFFFFF"; + } else if (type == 2) { + m_defaultTextColor = "#C0C6D4"; + m_backgrounddefaultColor = "#FFFFFF"; + m_backgrounddefaultColor.setAlphaF(0.05); + m_currentDayTextColor = "#B8D3FF"; + m_backgroundcurrentDayColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); + m_fillColor = "#000000"; + m_fillColor.setAlphaF(0.05); + } +} + +void CWeekView::setsearchfalg(bool flag) +{ + m_searchfalg = flag; +} +void CWeekView::slotprev() +{ + if (m_selectDate.year() >= DDECalendar::QueryEarliestYear) { + QDate date = m_selectDate.addDays(-6); + setCurrentDate(date); + } else { + } +} + +void CWeekView::slotnext() +{ + QDate date = m_selectDate.addDays(8);; + setCurrentDate(date); +} +void CWeekView::paintCell(QWidget *cell) +{ + const QRect rect(0, 0, cell->width(), cell->height()); + const int pos = m_cellList.indexOf(cell); + //计算当前日期周数 + int weekNumber = QDate::currentDate().weekNumber(); + //In accordance with ISO 8601, weeks start on Monday and the first + if (QDate::currentDate().dayOfWeek() == DDEWeekCalendar::AFewDaysofWeek) { + ++weekNumber; + } + + const bool isCurrentDay = m_days[pos].addDays(3).weekNumber() == weekNumber && + m_days[pos].addDays(3).year() == QDate::currentDate().year(); + const bool isSelectDay = m_days[pos].addDays(m_weekAddDay).weekNumber() == m_selectDate.addDays(m_weekAddDay).weekNumber(); + + QPainter painter(cell); + + painter.save(); + painter.setRenderHints(QPainter::HighQualityAntialiasing); + painter.setBrush(QBrush(m_fillColor)); + painter.setPen(Qt::NoPen); + painter.drawRect(rect);//画矩形 + painter.restore(); + painter.setPen(Qt::SolidLine); + + const QString dayNum = QString::number(m_days[pos].addDays(3).weekNumber()); + + if (m_days[pos].year() < DDECalendar::QueryEarliestYear && dayNum != "1") + return; + + if (isSelectDay) { + QRect fillRect((cell->width() - 24) / 2, (cell->height() - 32) / 2 + 4, 24, 24); + painter.save(); + painter.setRenderHint(QPainter::Antialiasing); + painter.setBrush(QBrush(CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor())); + painter.setPen(Qt::NoPen); + painter.drawEllipse(fillRect); + painter.restore(); + painter.setRenderHint(QPainter::HighQualityAntialiasing); + painter.setPen(m_currentDayTextColor); + painter.setFont(m_dayNumFont); + painter.drawText(QRect(0, 0, cell->width(), cell->height()), Qt::AlignCenter, dayNum); + } else { + if (isCurrentDay) { + painter.setPen(m_backgroundcurrentDayColor); + } else { + painter.setPen(m_defaultTextColor); + } + painter.setFont(m_dayNumFont); + painter.drawText(QRect(0, 0, cell->width(), cell->height()), Qt::AlignCenter, dayNum); + } + painter.end(); +} + +bool CWeekView::eventFilter(QObject *o, QEvent *e) +{ + QWidget *cell = qobject_cast(o); + + if (cell && m_cellList.contains(cell)) { + if (e->type() == QEvent::Paint) { + paintCell(cell); + } else if (e->type() == QEvent::MouseButtonPress) { + QMouseEvent *mouseEvent = dynamic_cast(e); + if (mouseEvent->button() ==Qt::LeftButton) { + cellClicked(cell); + } + } + } + + return false; +} + +void CWeekView::cellClicked(QWidget *cell) +{ + if (!m_cellSelectable) + return; + + const int pos = m_cellList.indexOf(cell); + + if (pos == -1) + return; + + setSelectedCell(pos); + update(); +} + +void CWeekView::setSelectedCell(int index) +{ + if (m_selectedCell == index) + return; + + const int prevPos = m_selectedCell; + m_selectedCell = index; + + m_cellList.at(prevPos)->update(); + m_cellList.at(index)->update(); + m_selectDate = m_days[index]; + const QString dayNum = QString::number(m_days[index].addDays(3).weekNumber()); + + if (m_days[index].year() < DDECalendar::QueryEarliestYear && dayNum != "1") + return; + + emit signalsSelectDate(m_days[index], m_days[index].addDays(m_weekAddDay)); +} + +void CWeekView::updateDate() +{ + m_weekAddDay = (m_selectDate.dayOfWeek() + m_firstWeekDay) % DDEWeekCalendar::AFewDaysofWeek; + QDate weekfirstDay = m_selectDate.addDays(-m_weekAddDay); + m_days[4] = weekfirstDay; + + for (int i(0); i < 4; ++i) { + m_days[i] = weekfirstDay.addDays(-(4 - i) * DDEWeekCalendar::AFewDaysofWeek); + } + for (int i(5); i != DDEWeekCalendar::NumWeeksDisplayed; ++i) { + m_days[i] = weekfirstDay.addDays((i - 4) * DDEWeekCalendar::AFewDaysofWeek); + } + + setSelectedCell(4); + update(); +} +void CWeekView::resizeEvent(QResizeEvent *event) +{ + int w = width() / DDEWeekCalendar::NumWeeksDisplayed; + int h = height(); + int ww = 36; + + if (w >= ww) { + for (int c = 0; c != DDEWeekCalendar::NumWeeksDisplayed; ++c) { + m_cellList[c]->setFixedSize(w, h); + m_cellList[c]->update(); + } + for (int i = 0; i < DDEWeekCalendar::NumWeeksDisplayed; i++) { + m_cellList[i]->setVisible(true); + m_cellList[i]->update(); + } + } else { + for (int c = 0; c != DDEWeekCalendar::NumWeeksDisplayed; ++c) { + m_cellList[c]->setFixedSize(ww, h); + m_cellList[c]->update(); + } + int t_num = qRound((ww * DDEWeekCalendar::NumWeeksDisplayed - width()) / ww / 2.0); + QVector vindex; + vindex.resize(10); + vindex.fill(true); + + for (int i = 0; i < t_num; i++) { + vindex[i] = false; + vindex[9 - i] = false; + } + for (int i = 0; i < DDEWeekCalendar::NumWeeksDisplayed; i++) { + m_cellList[i]->setVisible(vindex[i]); + m_cellList[i]->update(); + } + } + QWidget::resizeEvent(event); +} +void CWeekView::wheelEvent(QWheelEvent *event) +{ + Q_UNUSED(event); + bool isDragging = false; + // + emit signalIsDragging(isDragging); + //判断是否是拖拽状态 + if (!isDragging) { + if (event->delta() < 0) { + slotnext(); + } else { + slotprev(); + } + } + +} diff -Nru dde-calendar-5.7.0.4/src/widget/weekWidget/weekview.h dde-calendar-5.7.0.23/src/widget/weekWidget/weekview.h --- dde-calendar-5.7.0.4/src/widget/weekWidget/weekview.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/weekWidget/weekview.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#ifndef WEEKVIEW_H +#define WEEKVIEW_H + +#include +#include +#include + +class CWeekView : public QWidget +{ + Q_OBJECT +public: + /** + * @brief CWeekView 构造函数 + * @param parent 父类 + */ + explicit CWeekView(QWidget *parent = nullptr); + /** + * @brief ~CWeekView 析构函数 + */ + ~CWeekView(); + /** + * @brief setFirstWeekDay 设置每周的第一天是周几,并更新 + * @param weekday 周几 + */ + void setFirstWeekDay(int weekday); + /** + * @brief setCurrentDate 设置当天时间,并更新 + * @param date 时间 + */ + void setCurrentDate(const QDate date); + /** + * @brief setTheMe 根据系统主题类型设置颜色 + * @param type 系统主题类型 + */ + void setTheMe(int type = 0); + /** + * @brief setsearchfalg + * @param flag + */ + void setsearchfalg(bool flag); +public slots: + /** + * @brief cellClicked 选择点击的日期 + * @param cell 周数所在的widget + */ + void cellClicked(QWidget *cell); + /** + * @brief slotprev 选择上一周 + */ + void slotprev(); + /** + * @brief slotnext 选择下一周 + */ + void slotnext(); +signals: + /** + * @brief signalsSelectDate 选择日期的信号 + * @param date 选择的日期 + * @param currentDate 今天的时间 + */ + void signalsSelectDate(QDate date, QDate currentDate); + /** + * @brief signalIsDragging 判断是否是拖拽状态 + * @param isDragging 是否是拖拽状态 + */ + void signalIsDragging(bool &isDragging); +protected: + /** + * @brief resizeEvent 调整窗口大小 + * @param event 窗口大小调整事件 + */ + void resizeEvent(QResizeEvent *event) override; + /** + * @brief wheelEvent 鼠标滚轮切换上一周下一周 + * @param event 鼠标滚轮事件 + */ + void wheelEvent(QWheelEvent *event) override; + +private: + /** + * @brief paintCell 绘制周数 + * @param cell 周数所在的widget + */ + void paintCell(QWidget *cell); + /** + * @brief eventFilter 过滤器 + * @param o 事件对象 + * @param e 事件类型 + * @return false + */ + bool eventFilter(QObject *o, QEvent *e) override; + /** + * @brief setSelectedCell 设置被选择的周数 + * @param index 周数所在的索引 + */ + void setSelectedCell(int index); + /** + * @brief updateDate 更新数据 + */ + void updateDate(); +private: + QList m_cellList; + QDate m_selectDate; + QDate m_days[10]; + bool m_cellSelectable = true; + int m_selectedCell = 0; + QFont m_dayNumFont; + + QColor m_defaultTextColor = Qt::black; + QColor m_backgrounddefaultColor = Qt::white; + QColor m_currentDayTextColor = Qt::white; + QColor m_backgroundcurrentDayColor = "#0081FF"; + QColor m_fillColor = Qt::white; + int m_firstWeekDay; + int m_weekAddDay = 0; + int m_themetype = 1; + bool m_searchfalg = false; +}; + +#endif // MONTDAYVIEW_H diff -Nru dde-calendar-5.7.0.4/src/widget/weekWidget/weekwindow.cpp dde-calendar-5.7.0.23/src/widget/weekWidget/weekwindow.cpp --- dde-calendar-5.7.0.4/src/widget/weekWidget/weekwindow.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/weekWidget/weekwindow.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,497 @@ +/* + * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#include "weekwindow.h" +#include "scheduleview.h" +#include "constants.h" +#include "calendardbus.h" +#include "weekheadview.h" +#include "weekview.h" +#include "schcedulesearchview.h" +#include "todybutton.h" +#include + +#include +#include + +#include +#include +#include + +DGUI_USE_NAMESPACE +CWeekWindow::CWeekWindow(QWidget *parent) + : QMainWindow(parent) +{ + setContentsMargins(0, 0, 0, 0); + initUI(); + initConnection(); +} + +CWeekWindow::~CWeekWindow() +{ + +} + +void CWeekWindow::setDate(QDate date) +{ + if (!date.isValid()) return; + + m_currentdate = date; + m_weekview->setCurrentDate(date); + update(); + emit signalCurrentDate(date); +} + +void CWeekWindow::setSelectSchedule(const ScheduleDtailInfo &scheduleInfo) +{ + m_scheduleView->setSelectSchedule(scheduleInfo); +} + +void CWeekWindow::setFirstWeekday(int weekday) +{ + m_weekview->setFirstWeekDay(weekday); + m_weekHeadView->setFirstWeekday(weekday); + m_scheduleView->setFirstWeekday(weekday); +} + +void CWeekWindow::setLunarVisible(bool state) +{ + m_weekHeadView->setLunarVisible(state); + m_YearLunarLabel->setVisible(state); + m_scheduleView->setLunarVisible(state); +} + +void CWeekWindow::initUI() +{ + m_contentBackground = new DFrame; + m_contentBackground->setAutoFillBackground(true); + DPalette anipa = m_contentBackground->palette(); + anipa.setColor(DPalette::Background, "#F8F8F8"); + m_contentBackground->setPalette(anipa); + m_contentBackground->setContentsMargins(0, 0, 0, 0); + + m_today = new CTodyButton; + m_today->setText(QCoreApplication::translate("today", "Today", "Today")); + m_today->setFixedSize(DDEWeekCalendar::WTodayWindth, DDEWeekCalendar::WTodayHeight); + DPalette todaypa = m_today->palette(); + QColor todayColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); + todaypa.setColor(DPalette::ButtonText, todayColor); + todaypa.setColor(DPalette::Dark, Qt::white); + todaypa.setColor(DPalette::Light, Qt::white); + QColor sbcolor("#002A57"); + sbcolor.setAlphaF(0.05); + todaypa.setColor(DPalette::Shadow, sbcolor); + QFont todayfont; + todayfont.setWeight(QFont::Medium); + todayfont.setPixelSize(DDECalendar::FontSizeFourteen); + m_today->setFont(todayfont); + m_today->setPalette(todaypa); + m_prevButton = new DIconButton(DStyle::SP_ArrowLeft, this); + m_prevButton->setFixedSize(36, 36); + m_nextButton = new DIconButton(DStyle::SP_ArrowRight, this); + m_nextButton->setFixedSize(36, 36); + m_YearLabel = new QLabel(); + m_YearLabel->setFixedHeight(DDEWeekCalendar::W_YLableHeight); + + QFont t_labelF; + t_labelF.setWeight(QFont::Medium); + t_labelF.setPixelSize(DDECalendar::FontSizeTwentyfour); + m_YearLabel->setFont(t_labelF); + DPalette Lunadpa = m_YearLabel->palette(); + Lunadpa.setColor(DPalette::WindowText, QColor("#3B3B3B")); + m_YearLabel->setPalette(Lunadpa); + + m_YearLunarLabel = new QLabel(m_contentBackground); + m_YearLunarLabel->setFixedSize(DDEWeekCalendar::W_YLunatLabelWindth, DDEWeekCalendar::W_YLunatLabelHeight); + + m_weekview = new CWeekView(this); + + m_weekLabel = new QLabel(); + m_weekLabel->setFixedHeight(DDEWeekCalendar::W_YLableHeight); + QFont weeklabelF; + weeklabelF.setWeight(QFont::Medium); + weeklabelF.setPixelSize(DDECalendar::FontSizeFourteen); + m_weekLabel->setFont(weeklabelF); + DPalette wpa = m_weekLabel->palette(); + wpa.setColor(DPalette::WindowText, QColor("#717171")); + m_weekLabel->setPalette(wpa); + m_weekLabel->setText(tr("Week")); + + QFont ylabelF; + ylabelF.setWeight(QFont::Medium); + ylabelF.setPixelSize(DDECalendar::FontSizeFourteen); + m_YearLunarLabel->setFont(ylabelF); + DPalette YearLpa = m_YearLunarLabel->palette(); + YearLpa.setColor(DPalette::WindowText, QColor("#8A8A8A")); + + m_YearLunarLabel->setPalette(YearLpa); + + QHBoxLayout *yeartitleLayout = new QHBoxLayout; + yeartitleLayout->setMargin(0); + yeartitleLayout->setSpacing(0); + yeartitleLayout->setContentsMargins(21, 20, 8, 0); + yeartitleLayout->addWidget(m_YearLabel); + + QHBoxLayout *yeartitleLayout1 = new QHBoxLayout; + yeartitleLayout1->setMargin(0); + yeartitleLayout1->setSpacing(0); + yeartitleLayout1->setContentsMargins(14, 9, 0, 7); + yeartitleLayout1->addWidget(m_YearLunarLabel); + yeartitleLayout->addLayout(yeartitleLayout1); + + yeartitleLayout->addStretch(); + m_todayframe = new CustomFrame; + m_todayframe->setContentsMargins(0, 0, 0, 0); + m_todayframe->setRoundState(true, true, true, true); + m_todayframe->setBColor(Qt::white); + m_todayframe->setFixedHeight(DDEYearCalendar::Y_MLableHeight); + m_todayframe->setboreder(1); + QHBoxLayout *todaylayout = new QHBoxLayout; + todaylayout->setMargin(0); + todaylayout->setSpacing(0); + todaylayout->addWidget(m_prevButton); + todaylayout->addWidget(m_weekview); + todaylayout->addWidget(m_nextButton); + m_todayframe->setLayout(todaylayout); + + yeartitleLayout->addWidget(m_todayframe, 0, Qt::AlignCenter); + yeartitleLayout->addSpacing(10); + yeartitleLayout->addWidget(m_weekLabel, 0, Qt::AlignCenter); + yeartitleLayout->addStretch(); + yeartitleLayout->addWidget(m_today, 0, Qt::AlignRight); + + m_weekHeadView = new CWeekHeadView(this); + m_scheduleView = new CScheduleView(this); + m_scheduleView->setviewMagin(73, 109 + 30, 0, 0); + m_scheduleView->setRange(763, 1032, QDate(2019, 8, 12), QDate(2019, 8, 18)); + + m_mainhLayout = new QVBoxLayout; + m_mainhLayout->setMargin(0); + m_mainhLayout->setSpacing(0); + m_mainhLayout->setContentsMargins(8, 20, 0, 9); + m_mainhLayout->addWidget(m_weekHeadView); + m_mainhLayout->addWidget(m_scheduleView); + QVBoxLayout *hhLayout = new QVBoxLayout; + hhLayout->setMargin(0); + hhLayout->setSpacing(0); + hhLayout->setContentsMargins(0, 0, 0, 0); + hhLayout->addLayout(yeartitleLayout); + hhLayout->addLayout(m_mainhLayout); + + m_tmainLayout = new QHBoxLayout; + m_tmainLayout->setMargin(0); + m_tmainLayout->setSpacing(0); + m_tmainLayout->setContentsMargins(0, 0, 10, 0); + m_tmainLayout->addLayout(hhLayout); + + QVBoxLayout *ssLayout = new QVBoxLayout; + ssLayout->setMargin(0); + ssLayout->setSpacing(0); + ssLayout->setContentsMargins(0, 0, 0, 10); + m_tmainLayout->addLayout(ssLayout); + + m_contentBackground->setLayout(m_tmainLayout); + setCentralWidget(m_contentBackground); +} + +void CWeekWindow::initConnection() +{ + connect(m_prevButton, &DIconButton::clicked, this, &CWeekWindow::slotprev); + connect(m_today, &CTodyButton::clicked, this, &CWeekWindow::slottoday); + connect(m_nextButton, &DIconButton::clicked, this, &CWeekWindow::slotnext); + connect(m_weekview, &CWeekView::signalsSelectDate, this, &CWeekWindow::slotCurrentWeek); + connect(m_weekHeadView, &CWeekHeadView::signalcurrentLunarDateChanged, this, &CWeekWindow::slotcurrentDateLunarChanged); + connect(m_weekHeadView, &CWeekHeadView::signalcurrentDateChanged, this, &CWeekWindow::slotcurrentDateChanged); + connect(m_scheduleView, &CScheduleView::signalsUpdateShcedule, this, &CWeekWindow::slotTransitSchedule); + connect(m_scheduleView, &CScheduleView::signalsCurrentScheduleDate, this, &CWeekWindow::signalsCurrentScheduleDate); + connect(m_scheduleView, &CScheduleView::signalViewtransparentFrame, this, &CWeekWindow::signalViewtransparentFrame); + connect(m_weekHeadView, &CWeekHeadView::signalsViewSelectDate, this, &CWeekWindow::signalsViewSelectDate); + connect(m_weekHeadView, &CWeekHeadView::signaleSchedulHide, this, &CWeekWindow::slotScheduleHide); + connect(m_weekview,&CWeekView::signalIsDragging,this,&CWeekWindow::slotIsDragging); +} + +void CWeekWindow::setTheMe(int type) +{ + if (type == 0 || type == 1) { + DPalette anipa = m_contentBackground->palette(); + anipa.setColor(DPalette::Background, "#F8F8F8"); + m_contentBackground->setPalette(anipa); + m_contentBackground->setBackgroundRole(DPalette::Background); + + DPalette todaypa = m_today->palette(); + QColor todayColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); + todaypa.setColor(DPalette::ButtonText, todayColor); + todaypa.setColor(DPalette::Dark, Qt::white); + todaypa.setColor(DPalette::Light, Qt::white); + QColor sbcolor("#002A57"); + sbcolor.setAlphaF(0.05); + todaypa.setColor(DPalette::Shadow, sbcolor); + m_today->setPalette(todaypa); + QColor todayhover = "#000000"; + todayhover.setAlphaF(0.1); + QColor todaypress = "#000000"; + todaypress.setAlphaF(0.2); + m_today->setBColor("#FFFFFF", todayhover, todaypress, "#FFFFFF", todayhover, todaypress); + m_today->setTColor(todayColor, "#001A2E", "#0081FF"); + m_today->setshadowColor(sbcolor); + + DPalette prevpa = m_prevButton->palette(); + prevpa.setColor(DPalette::Dark, QColor("#E6E6E6")); + prevpa.setColor(DPalette::Light, QColor("#E3E3E3")); + + DPalette nextvpa = m_nextButton->palette(); + nextvpa.setColor(DPalette::Dark, QColor("#E6E6E6")); + nextvpa.setColor(DPalette::Light, QColor("#E3E3E3")); + m_todayframe->setBColor(Qt::white); + DPalette pa = m_YearLabel->palette(); + pa.setColor(DPalette::WindowText, QColor("#3B3B3B")); + m_YearLabel->setPalette(pa); + m_YearLabel->setForegroundRole(DPalette::WindowText); + DPalette Lunapa = m_YearLunarLabel->palette(); + Lunapa.setColor(DPalette::WindowText, QColor("#8A8A8A")); + m_YearLunarLabel->setPalette(Lunapa); + m_YearLunarLabel->setForegroundRole(DPalette::WindowText); + + DPalette wpa = m_weekLabel->palette(); + wpa.setColor(DPalette::WindowText, QColor("#717171")); + m_weekLabel->setPalette(wpa); + m_weekLabel->setForegroundRole(DPalette::WindowText); + } else if (type == 2) { + DPalette anipa = m_contentBackground->palette(); + anipa.setColor(DPalette::Background, "#252525"); + m_contentBackground->setPalette(anipa); + m_contentBackground->setBackgroundRole(DPalette::Background); + + DPalette todaypa = m_today->palette(); + QColor todayColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); + todaypa.setColor(DPalette::ButtonText, todayColor); + todaypa.setColor(DPalette::Dark, "#414141"); + todaypa.setColor(DPalette::Light, "#484848"); + QColor sbcolor("#000000"); + sbcolor.setAlphaF(0.05); + todaypa.setColor(DPalette::Shadow, sbcolor); + m_today->setPalette(todaypa); + m_today->setBColor("#484848", "#727272", "#242424", "#414141", "#535353", "#282828"); + m_today->setTColor(todayColor, "#FFFFFF", "#0081FF"); + m_today->setshadowColor(sbcolor); + + DPalette prevpa = m_prevButton->palette(); + prevpa.setColor(DPalette::Dark, QColor("#484848")); + prevpa.setColor(DPalette::Light, QColor("#414141")); + + DPalette nextvpa = m_nextButton->palette(); + nextvpa.setColor(DPalette::Dark, QColor("#484848")); + nextvpa.setColor(DPalette::Light, QColor("#414141")); + QColor bcolor = "#FFFFFF"; + bcolor.setAlphaF(0.05); + m_todayframe->setBColor(bcolor); + + DPalette pa = m_YearLabel->palette(); + pa.setColor(DPalette::WindowText, QColor("#C0C6D4")); + m_YearLabel->setPalette(pa); + m_YearLabel->setForegroundRole(DPalette::WindowText); + DPalette Lunapa = m_YearLunarLabel->palette(); + Lunapa.setColor(DPalette::WindowText, QColor("#798BA8")); + m_YearLunarLabel->setPalette(Lunapa); + m_YearLunarLabel->setForegroundRole(DPalette::WindowText); + DPalette wpa = m_weekLabel->palette(); + wpa.setColor(DPalette::WindowText, QColor("#717171")); + m_weekLabel->setPalette(wpa); + m_weekLabel->setForegroundRole(DPalette::WindowText); + } + m_weekview->setTheMe(type); + m_weekHeadView->setTheMe(type); + m_scheduleView->setTheMe(type); +} + +void CWeekWindow::setTime(QTime time) +{ + m_scheduleView->setTime(time); +} +void CWeekWindow::setSearchWFlag(bool flag) +{ + m_searchfalg = flag; + m_weekview->setsearchfalg(flag); + update(); +} + +void CWeekWindow::clearSearch() +{ +} + +void CWeekWindow::updateHigh() +{ + m_scheduleView->updateHigh(); +} +void CWeekWindow::slotReturnTodayUpdate() +{ + setDate(QDate::currentDate()); +} + +void CWeekWindow::slotIsDragging(bool &isDragging) +{ + isDragging = m_scheduleView->IsDragging(); +} + +void CWeekWindow::slotupdateSchedule(int id) +{ + Q_UNUSED(id); + m_scheduleView->slotupdateSchedule(); +} + +void CWeekWindow::slotTransitSchedule(int id) +{ + emit signalsWUpdateShcedule(this, id); +} + +void CWeekWindow::slotTransitSearchSchedule(int id) +{ + m_scheduleView->slotupdateSchedule(); + emit signalsWUpdateShcedule(this, id); +} + +void CWeekWindow::slotprev() +{ + slotScheduleHide(); + QDate tcurrent = m_currentdate.addDays(-DDEWeekCalendar::AFewDaysofWeek); + + if (tcurrent.year() < DDECalendar::QueryEarliestYear) + return; + if (m_currentdate.year() >= DDECalendar::QueryEarliestYear) { + m_currentdate = tcurrent; + setDate(m_currentdate); + } else { + } +} + +void CWeekWindow::slotnext() +{ + slotScheduleHide(); + m_currentdate = m_currentdate.addDays(DDEWeekCalendar::AFewDaysofWeek); + setDate(m_currentdate); +} + +void CWeekWindow::slottoday() +{ + slotScheduleHide(); + emit signalsReturnTodayUpdate(this); + setDate(QDate::currentDate()); +} + +void CWeekWindow::slotCurrentWeek(QDate date, QDate currentDate) +{ + QVector vDate; + + for (int i = 0; i < DDEWeekCalendar::AFewDaysofWeek; i++) + vDate.append(date.addDays(i)); + emit signalCurrentDate(vDate[0]); + m_currentdate = currentDate; + m_weekHeadView->setWeekDay(vDate); + m_weekHeadView->setCurrentDate(m_currentdate); + m_scheduleView->setRange(date, date.addDays(6)); +} + +void CWeekWindow::slotcurrentDateLunarChanged(QVector vdate, QVector vdetail, int type) +{ + int offset = 0; + + for (int i = 0; i < vdate.count(); ++i) { + if (vdate.at(i) == m_currentdate) { + offset =i; + break; + } + } + if (m_currentdate == QDate::currentDate()) { + m_today->setText(QCoreApplication::translate("today", "Today", "Today")); + } else { + m_today->setText(QCoreApplication::translate("Return Today", "Today", "Return Today")); + } + if (!vdate.isEmpty()) { + CaLunarDayInfo detail = vdetail.at(offset); + if (type == 1) { + int yearnum = vdate.at(0).year(); + if (yearnum < DDECalendar::QueryEarliestYear) + yearnum = DDECalendar::QueryEarliestYear; + QLocale locale; + if (locale.language() == QLocale::Chinese) { + + m_YearLabel->setText(QString::number(yearnum) + tr("Y")); + } else { + m_YearLabel->setText(QString::number(yearnum)); + } + m_YearLunarLabel->setText("-" + detail.mGanZhiYear + detail.mZodiac + "年-"); + } + } +} + +void CWeekWindow::slotcurrentDateChanged(QDate date) +{ + if (m_currentdate == QDate::currentDate()) { + m_today->setText(QCoreApplication::translate("today", "Today", "Today")); + } else { + m_today->setText(QCoreApplication::translate("Return Today", "Today", "Return Today")); + } + m_currentdate = date; + m_scheduleView->setDate(date); +} + +void CWeekWindow::slotsearchDateSelect(QDate date) +{ + setDate(date); + slotupdateSchedule(); +} + +void CWeekWindow::slotScheduleHide() +{ + m_scheduleView->slotScheduleShow(false); +} + +void CWeekWindow::resizeEvent(QResizeEvent *event) +{ + qreal sleftMagin = 0.093 * width() + 0.5; + qreal headh = height() * 0.0924 + 0.5; + qreal dw = width() * 0.4186 + 0.5; + int dh = 36; + int winframe = 10; + m_mainhLayout->setContentsMargins(10, 20, 0, 10); + + if (m_searchfalg) { + m_tmainLayout->setContentsMargins(0, 0, 0, 0); + } else { + winframe += 10; + m_tmainLayout->setContentsMargins(0, 0, 10, 0); + } + + if (!m_searchfalg) { + m_weekview->setFixedSize(qRound(dw), dh); + } else { + m_weekview->setFixedSize(qRound(dw - 100), dh); + } + + m_weekHeadView->setMounthLabelWidth(qRound(sleftMagin + 1), qRound(width() * 0.9802 + 0.5)); + m_weekHeadView->setFixedSize(width() - winframe, qRound(headh)); + QMainWindow::resizeEvent(event); +} + +void CWeekWindow::mousePressEvent(QMouseEvent *event) +{ + Q_UNUSED(event); + slotScheduleHide(); +} + + diff -Nru dde-calendar-5.7.0.4/src/widget/weekWidget/weekwindow.h dde-calendar-5.7.0.23/src/widget/weekWidget/weekwindow.h --- dde-calendar-5.7.0.4/src/widget/weekWidget/weekwindow.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/weekWidget/weekwindow.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,245 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#ifndef WEEKWINDOW_H +#define WEEKWINDOW_H + +#include "customframe.h" +#include "schedulestructs.h" +#include "calendardbus.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +DWIDGET_USE_NAMESPACE + +class CWeekHeadView; +class CaLunarDayInfo; +class CWeekView; +class CScheduleView; +class CSchceduleSearchView; +class CTodyButton; +class CWeekWindow: public QMainWindow +{ + Q_OBJECT +public: + /** + * @brief CWeekWindow 构造函数 + * @param parent 父类 + */ + CWeekWindow(QWidget *parent = nullptr); + /** + *@brief ~CWeekWindow 析构函数 + */ + ~CWeekWindow() override; + /** + * @brief setDate 设置今天的日期 + * @param date 日期 + */ + void setDate(QDate date); + /** + * @brief setSelectSchedule 设置选择的日程 + * @param scheduleInfo 日程信息 + */ + void setSelectSchedule(const ScheduleDtailInfo &scheduleInfo); + /** + * @brief setFirstWeekday 设置每周以周几开始 + * @param weekday 周几 + */ + void setFirstWeekday(int weekday); + /** + * @brief setLunarVisible 设置是否显示阴历信息 + * @param state 是否显示阴历信息 + */ + void setLunarVisible(bool state); + /** + * @brief initUI 初始化界面设置 + */ + void initUI(); + /** + * @brief initConnection 初始化信号和槽的连接 + */ + void initConnection(); + /** + * @brief setTheMe 根据系统主题类型设置颜色 + * @param type 系统主题类型 + */ + void setTheMe(int type = 0); + /** + * @brief setTime 设置CScheduleView的时间 + * @param time 时间 + */ + void setTime(QTime time); + /** + * @brief setSearchWFlag 设置搜索标志 + * @param flag 是否进行了搜索 + */ + void setSearchWFlag(bool flag); + /** + * @brief clearSearch + */ + void clearSearch(); + /** + * @brief updateHigh CScheduleView updateHigh + */ + void updateHigh(); +signals: + /** + * @brief dateSelected + * @param date + * @param detail + */ + void dateSelected(const QDate date, const CaLunarDayInfo &detail) const; + /** + * @brief signalsWUpdateShcedule 更新日程信号 + * @param w + * @param id + */ + void signalsWUpdateShcedule(QMainWindow *w, int id = 0); + /** + * @brief signalsReturnTodayUpdate 返回今天的信号 + * @param w 视图窗口 + */ + void signalsReturnTodayUpdate(QMainWindow *w); + /** + * @brief signalsCurrentScheduleDate 切换窗口的信号 + * @param date 时间 + */ + void signalsCurrentScheduleDate(QDate date); + /** + * @brief signalViewtransparentFrame 窗口转换信号 + * @param type + */ + void signalViewtransparentFrame(int type); + /** + * @brief signalCurrentDate 设置时间信号 + * @param date 时间 + */ + void signalCurrentDate(QDate date); + /** + * @brief signalsViewSelectDate 选择时间的信号 + * @param date 时间 + */ + void signalsViewSelectDate(QDate date); +public slots: + /** + * @brief slotReturnTodayUpdate 返回今天按钮,设置当前时间 + */ + void slotReturnTodayUpdate(); + /** + * @brief slotIsDragging CScheduleView IsDragging,判断是否可以拖拽 + * @param isDragging 是否可以拖拽 + */ + void slotIsDragging(bool &isDragging); +public slots: + /** + * @brief slotupdateSchedule 更新日程 + * @param id + */ + void slotupdateSchedule(int id = 0); + /** + * @brief slotTransitSchedule 发送更新日程的信号 + * @param id + */ + void slotTransitSchedule(int id = 0); + /** + * @brief slotTransitSearchSchedule 更新日程并发送信号 + * @param id + */ + void slotTransitSearchSchedule(int id = 0); + /** + * @brief slotScheduleHide 隐藏日程浮框 + */ + void slotScheduleHide(); +private slots: + /** + * @brief slotprev 切换到上一周,隐藏日程浮框 + */ + void slotprev(); + /** + * @brief slotnext 切换到下一周,隐藏日程浮框 + */ + void slotnext(); + /** + * @brief slottoday 返回到今天,隐藏日程浮框 + */ + void slottoday(); + /** + * @brief slotCurrentWeek 设置每周开始的日期和今天的日期 + * @param date 每周开始的日期 + * @param currentDate 今天的日期 + */ + void slotCurrentWeek(QDate date, QDate currentDate); + /** + * @brief slotcurrentDateLunarChanged 切换显示当天的阴历信息 + * @param vdate 一周的时间 + * @param vdetail 阴历信息 + * @param type 是否显示阴历信息 + */ + void slotcurrentDateLunarChanged(QVector vdate, QVector vdetail, int type = 0); + /** + * @brief slotcurrentDateChanged 切换显示当天的时间,并改变返回今天按钮显示的文字 + * @param date 时间 + */ + void slotcurrentDateChanged(QDate date); + /** + * @brief slotsearchDateSelect 选择选中的日期 + * @param date 日期 + */ + void slotsearchDateSelect(QDate date); +protected: + /** + * @brief resizeEvent 调整周视图窗口 + * @param event 窗口大小调整事件 + */ + void resizeEvent(QResizeEvent *event) override; + /** + * @brief mousePressEvent 鼠标单击隐藏日程浮框 + * @param event 鼠标事件 + */ + void mousePressEvent(QMouseEvent *event) override; +private: + CWeekHeadView *m_weekHeadView = nullptr; //周视图头 + DFrame *m_contentBackground = nullptr; + DIconButton *m_prevButton = nullptr; + DIconButton *m_nextButton = nullptr; + CTodyButton *m_today = nullptr; + QDate m_currentdate; + QLabel *m_YearLabel = nullptr; + QLabel *m_YearLunarLabel = nullptr; + QLabel *m_weekLabel = nullptr; + CWeekView *m_weekview = nullptr; + CustomFrame *m_todayframe = nullptr; + CScheduleView *m_scheduleView = nullptr; + QSpacerItem *m_spaceitem = nullptr; + QVBoxLayout *m_mainhLayout = nullptr; + QString m_searchText; + QHBoxLayout *m_tmainLayout = nullptr; + bool m_searchfalg = false; +}; + +#endif // YEARWINDOW_H diff -Nru dde-calendar-5.7.0.4/src/widget/yearWidget/yearschceduleview.cpp dde-calendar-5.7.0.23/src/widget/yearWidget/yearschceduleview.cpp --- dde-calendar-5.7.0.4/src/widget/yearWidget/yearschceduleview.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/yearWidget/yearschceduleview.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,629 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#include "yearschceduleview.h" +#include "schcedulectrldlg.h" +#include "myschceduleview.h" +#include "schceduledlg.h" +#include "scheduledatamanage.h" +#include "constants.h" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +DGUI_USE_NAMESPACE + +const QString fontfamily = QStringLiteral("SourceHanSansSC-Medium"); + +CYearSchceduleItem::CYearSchceduleItem(QWidget *parent) + : DLabel(parent) +{ + +} + +void CYearSchceduleItem::setBackgroundColor(QColor color1) +{ + m_Backgroundcolor = color1; +} + +void CYearSchceduleItem::setStateColor(QColor color1) +{ + m_Statecolor = color1; +} + +void CYearSchceduleItem::setText( QColor tcolor, QFont font) +{ + m_ttextcolor = tcolor; + m_tfont = font; +} + +void CYearSchceduleItem::setTimeC(QColor tcolor, QFont font) +{ + m_timecolor = tcolor; + m_timefont = font; +} + +void CYearSchceduleItem::setData( ScheduleDtailInfo vScheduleInfo) +{ + m_ScheduleInfo = vScheduleInfo; + update(); +} + +void CYearSchceduleItem::paintEvent( QPaintEvent *e ) +{ + Q_UNUSED(e); + int labelwidth = width(); + int labelheight = height(); + + QPainter painter(this); + QRect fillRect = QRect(0, 0, labelwidth, labelheight); + painter.setRenderHints(QPainter::HighQualityAntialiasing); + QColor bcolor = m_Backgroundcolor; + painter.save(); + painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; + painter.setBrush(QBrush(bcolor)); + painter.setPen(Qt::NoPen); + painter.drawRect(fillRect); + painter.restore(); + //圆点 + painter.save(); + painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; + painter.setBrush(QBrush(m_Statecolor)); + painter.setPen(Qt::NoPen); + painter.drawEllipse(QRect(10, (labelheight - 8) / 2, 8, 8)); + painter.restore(); + + QString str; + //左边文字 + painter.save(); + painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; + painter.setPen(m_ttextcolor); + painter.setFont(m_tfont); + QFontMetrics fm = painter.fontMetrics(); + QString tStitlename = m_ScheduleInfo.titleName; + tStitlename.replace("\n", ""); + str = tStitlename; + int tilenameW = labelwidth - 90; + QString tstr; + + for (int i = 0; i < str.count(); i++) { + tstr.append(str.at(i)); + int widthT = fm.width(tstr) + 5; + if (widthT >= tilenameW) { + tstr.chop(1); + break; + } + } + if (tstr != str) { + tstr = tstr + "..."; + } + + painter.drawText(QRect(28, 0, tilenameW, labelheight - 2), Qt::AlignLeft | Qt::AlignVCenter, tstr); + painter.restore(); + //右边时间 + painter.save(); + painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; + painter.setPen(m_timecolor); + painter.setFont(m_timefont); + QLocale locale; + + if (locale.language() == QLocale::Chinese) { + if (m_ScheduleInfo.allday) { + str = tr("All Day"); + } else { + str = m_ScheduleInfo.beginDateTime.time().toString("ap h") + ("时"); + } + } else { + if (m_ScheduleInfo.allday) { + str = tr("All Day"); + } else { + str = m_ScheduleInfo.beginDateTime.time().toString("ap h:mm"); + } + } + QFontMetrics fm2 = painter.fontMetrics(); + painter.drawText(QRect(labelwidth - 60, 0, 50, labelheight - 2), Qt::AlignRight | Qt::AlignVCenter, str); + painter.restore(); +} + +CYearSchceduleView::CYearSchceduleView(QWidget *parent) + : DWidget(parent) +{ + setContentsMargins(10, 10, 10, 10); + setWindowFlags(Qt::FramelessWindowHint | Qt::Tool); + setAttribute(Qt::WA_TranslucentBackground); +} + +CYearSchceduleView::~CYearSchceduleView() +{ + +} + +void CYearSchceduleView::setSoloDay(QString soloday) +{ + m_soloDay = soloday; +} + +bool YScheduleDateThan(const ScheduleDtailInfo &s1, const ScheduleDtailInfo &s2) +{ + QDate bdate1 = s1.beginDateTime.date(); + QDate edate1 = s1.endDateTime.date(); + QDate bdate2 = s2.beginDateTime.date(); + QDate edate2 = s2.endDateTime.date(); + + if (bdate1 != edate1 && bdate2 == edate2) { + return true; + } else if (bdate1 == edate1 && bdate2 != edate2) { + return false; + } else if (bdate1 != edate1 && bdate2 != edate2) { + return bdate1 < bdate2; + } else { + if (s1.beginDateTime == s2.beginDateTime) { + return s1.titleName < s2.titleName; + } else { + return s1.beginDateTime < s2.beginDateTime; + } + } +} +bool YScheduleDaysThan(const ScheduleDtailInfo &s1, const ScheduleDtailInfo &s2) +{ + return s1.beginDateTime.date().daysTo(s1.endDateTime.date()) > s2.beginDateTime.date().daysTo(s2.endDateTime.date()); +} + +void CYearSchceduleView::setData(QVector &vListData) +{ + QVector valldayListData, vDaylistdata; + + for (int i = 0; i < vListData.count(); i++) { + if (vListData.at(i).allday) { + valldayListData.append(vListData.at(i)); + } else { + vDaylistdata.append(vListData.at(i)); + } + } + + std::sort(valldayListData.begin(), valldayListData.end(), YScheduleDaysThan); + std::sort(valldayListData.begin(), valldayListData.end(), YScheduleDateThan); + std::sort(vDaylistdata.begin(), vDaylistdata.end(), YScheduleDaysThan); + std::sort(vDaylistdata.begin(), vDaylistdata.end(), YScheduleDateThan); + + for (int i = 0; i < valldayListData.count(); i++) { + QVector::iterator iter = valldayListData.begin(); + if (valldayListData.at(i).type.ID == DDECalendar::FestivalTypeID) { + ScheduleDtailInfo moveDate; + moveDate = valldayListData.at(i); + valldayListData.removeAt(i); + valldayListData.insert(iter, moveDate); + } + } + + m_vlistData.clear(); + m_vlistData.append(valldayListData); + m_vlistData.append(vDaylistdata); + + if (m_vlistData.size() > DDEYearCalendar::YearScheduleListMaxcount) { + QVector vTlistData; + for (int i = 0; i < 4; i++) { + if (m_vlistData.at(i).beginDateTime.date() != m_vlistData.at(i).endDateTime.date() && !m_vlistData.at(i).allday) { + if (m_vlistData.at(i).beginDateTime.date() != m_currentDate) { + m_vlistData[i].allday = true; + } + } + vTlistData.append(m_vlistData.at(i)); + } + ScheduleDtailInfo info; + info.titleName = "......"; + info.id = -1; + vTlistData.append(info); + m_vlistData = vTlistData; + } +} + +void CYearSchceduleView::clearData() +{ + m_vlistData.clear(); + m_soloDay.clear(); + return; +} + +int CYearSchceduleView::showWindow() +{ + if (m_soloDay.isEmpty() && m_vlistData.isEmpty()) { + setFixedSize(130, 45); + } else { + setFixedSize(240, 180); + } + updateDateShow(); + + return this->width(); +} + +void CYearSchceduleView::setTheMe(int type) +{ + if (type == 0 || type == 1) { + m_bBackgroundcolor = "#FFFFFF"; + m_bBackgroundcolor.setAlphaF(0.0); + m_btimecolor = "#414D68"; + m_btimecolor.setAlphaF(0.7); + m_bttextcolor = "#414D68"; + m_lBackgroundcolor = "#EBEBEB"; + m_lBackgroundcolor.setAlphaF(0.0); + m_ltextcolor = "#001A2E"; + m_solocolor = "#FF7272"; + m_TBcolor = "#EBEBEB"; + m_borderColor = "#000000"; + m_borderColor.setAlphaF(0.05); + } else if (type == 2) { + m_bBackgroundcolor = "#FFFFFF"; + m_bBackgroundcolor.setAlphaF(0.0); + m_btimecolor = "#C0C6D4"; + m_btimecolor.setAlphaF(0.7); + m_bttextcolor = "#C0C6D4"; + m_lBackgroundcolor = "#191919"; + m_lBackgroundcolor.setAlphaF(0.00); + m_ltextcolor = "#C0C6D4"; + m_solocolor = "#FF7272"; + m_solocolor.setAlphaF(0.8); + m_TBcolor = "#191919"; + m_borderColor = "#FFFFFF"; + m_borderColor.setAlphaF(0.05); + } +} + +void CYearSchceduleView::setDtype(int type, int arrowheight) +{ + m_dtype = type; + m_arrowheight = arrowheight; + update(); +} + +void CYearSchceduleView::setCurrentDate(QDate cdate) +{ + m_currentDate = cdate; +} + +QDate CYearSchceduleView::getCurrentDate() +{ + return m_currentDate; +} + +void CYearSchceduleView::adjustPosition(bool ad) +{ + adjustPos = ad; +} + +void CYearSchceduleView::updateDateShow() +{ + int sviewNum = 0; + + if (!m_soloDay.isEmpty() || !m_vlistData.isEmpty()) { + if (!m_soloDay.isEmpty()) { + if (m_vlistData.size() > 4) { + sviewNum = DDEYearCalendar::YearScheduleListMaxcount; + } else { + sviewNum = m_vlistData.size() + 1; + } + } else { + if (m_vlistData.size() > DDEYearCalendar::YearScheduleListMaxcount) { + sviewNum = DDEYearCalendar::YearScheduleListMaxcount; + } else { + sviewNum = m_vlistData.size(); + } + } + } + + if (!m_soloDay.isEmpty() || !m_vlistData.isEmpty()) + setFixedSize(240, 45 + (sviewNum - 1) * 29); + update(); + + return; +} + +void CYearSchceduleView::createItemWidget(ScheduleDtailInfo info, int type) +{ + ScheduleDtailInfo &gd = info; + CSchedulesColor gdcolor = CScheduleDataManage::getScheduleDataManage()->getScheduleColorByType(gd.type.ID); + CYearSchceduleItem *gwi = new CYearSchceduleItem(); + QFont font; + + font.setWeight(QFont::Medium); + font.setPixelSize(DDECalendar::FontSizeFourteen); + gwi->setBackgroundColor(m_bBackgroundcolor); + QColor scolor = gdcolor.Purecolor; + scolor.setAlphaF(1.0); + + if (type == 0) + gwi->setStateColor(gdcolor.splitColor); + else { + gwi->setStateColor(m_solocolor); + } + gwi->setText(m_bttextcolor, font); + font.setPixelSize(DDECalendar::FontSizeTwelve); + gwi->setTimeC(m_btimecolor, font); + gwi->setFixedSize(m_gradientItemList->width() - 3, 28); + gwi->setData(gd); + + QListWidgetItem *listItem = new QListWidgetItem; + listItem->setSizeHint(QSize(m_gradientItemList->width() - 2, 29)); //每次改变Item的高度 + listItem->setFlags(Qt::ItemIsTristate ); + m_gradientItemList->addItem(listItem); + m_gradientItemList->setItemWidget(listItem, gwi); + m_labellist.append(gwi); +} + +void CYearSchceduleView::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event); + + for (int i = 0; i < m_vlistData.size(); ++i) { + paintItem(m_vlistData.at(i), i, 0); + } + if (m_soloDay.isEmpty() && m_vlistData.isEmpty()) { + paintItem(); + } + adjustPos = false; +} + +void CYearSchceduleView::paintItem(ScheduleDtailInfo info, int index, int type) +{ + int labelwidth = width() - 30; + int bheight = index * 29 + 10; + int labelheight = 28; + ScheduleDtailInfo &gd = info; + CSchedulesColor gdcolor = CScheduleDataManage::getScheduleDataManage()->getScheduleColorByType(gd.type.ID); + QFont font; + + font.setWeight(QFont::Medium); + font.setPixelSize(DDECalendar::FontSizeTwelve); + QColor scolor = gdcolor.Purecolor; + scolor.setAlphaF(1.0); + + QPainter painter(this); + QRect fillRect = QRect(0, 0, width(), height()); + painter.setRenderHints(QPainter::HighQualityAntialiasing); + QColor bcolor = m_bBackgroundcolor; + + painter.save(); + painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; + painter.setBrush(QBrush(bcolor)); + painter.setPen(Qt::NoPen); + painter.drawRect(fillRect); + painter.restore(); + + if (gd.id == -1) { + QString str = "..."; + + painter.save(); + painter.setRenderHint(QPainter::Antialiasing); + painter.setPen(m_btimecolor); + painter.setFont(font); + if (adjustPos) { + painter.drawText(QRect(25 - 18, bheight, labelwidth - 80, labelheight - 2), Qt::AlignLeft | Qt::AlignVCenter, str); + } else { + painter.drawText(QRect(25, bheight, labelwidth - 80, labelheight - 2), Qt::AlignLeft | Qt::AlignVCenter, str); + } + painter.restore(); + } else { + if (info.id != -1) { + //圆点 + painter.save(); + painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; + if (type == 0) + painter.setBrush(QBrush(gdcolor.splitColor)); + else { + + painter.setBrush(QBrush(m_solocolor)); + } + painter.setPen(Qt::NoPen); + + if (adjustPos) { + painter.drawEllipse(QRect(25 - 18, bheight + (labelheight - 8) / 2, 8, 8)); + } else { + painter.drawEllipse(QRect(25, bheight + (labelheight - 8) / 2, 8, 8)); + } + painter.restore(); + } + + QString str; + //左边文字 + painter.save(); + painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; + painter.setPen(m_bttextcolor); + painter.setFont(font); + QFontMetrics fm = painter.fontMetrics(); + QString tStitlename = gd.titleName; + tStitlename.replace("\n", ""); + str = tStitlename; + int tilenameW = labelwidth - 80; + QString tstr; + + for (int i = 0; i < str.count(); i++) { + tstr.append(str.at(i)); + int widthT = fm.width(tstr) + 5; + if (widthT >= tilenameW) { + tstr.chop(1); + break; + } + } + if (tstr != str) { + tstr = tstr + "..."; + } + if (adjustPos) { + painter.drawText(QRect(41 - 18, bheight, tilenameW, labelheight - 2), Qt::AlignLeft | Qt::AlignVCenter, tstr); + } else { + painter.drawText(QRect(41, bheight, tilenameW, labelheight - 2), Qt::AlignLeft | Qt::AlignVCenter, tstr); + } + painter.restore(); + + if (info.id != -1) { + //右边时间 + painter.save(); + painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; + painter.setPen(m_btimecolor); + painter.setFont(font); + QLocale locale; + + if (info.allday) { + str = tr("All Day"); + } else { + if (m_currentDate > info.beginDateTime.date()) { + str = tr("All Day"); + } else { + str = info.beginDateTime.time().toString("hh:mm"); + } + } + + QFontMetrics fm2 = painter.fontMetrics(); + + if (adjustPos) { + painter.drawText(QRect(width() - 70 - 18, bheight, 57, labelheight - 2), Qt::AlignRight | Qt::AlignVCenter, str); + } else { + painter.drawText(QRect(width() - 70, bheight, 57, labelheight - 2), Qt::AlignRight | Qt::AlignVCenter, str); + } + painter.restore(); + } + } +} + +void CYearSchceduleView::paintItem() +{ + QFont font; + font.setPixelSize(DDECalendar::FontSizeTwelve); + QPainter painter(this); + QRect fillRect = QRect(0, 0, width(), height()); + painter.setRenderHints(QPainter::HighQualityAntialiasing); + QColor bcolor = m_bBackgroundcolor; + painter.save(); + painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; + painter.setBrush(QBrush(bcolor)); + painter.setPen(Qt::NoPen); + painter.drawRect(fillRect); + painter.restore(); + + QString str; + //左边文字 + painter.save(); + painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; + painter.setPen(m_bttextcolor); + painter.setFont(font); + QFontMetrics fm = painter.fontMetrics(); + QString tStitlename = tr("No event"); + + painter.drawText(QRect(0, 0, width(), height()), Qt::AlignCenter, tStitlename); + painter.restore(); +} + +CYearSchceduleOutView::CYearSchceduleOutView(QWidget *parent) + : DArrowRectangle(DArrowRectangle::ArrowLeft, parent) +{ + yearschceduleview = new CYearSchceduleView (); + this->setContent(yearschceduleview); +} + +void CYearSchceduleOutView::setSoloDay(QString soloday) +{ + yearschceduleview->setSoloDay(soloday); +} + +void CYearSchceduleOutView::setData(QVector &vListData) +{ + list_count = vListData.size(); + yearschceduleview->setData(vListData); + scheduleinfoList = yearschceduleview->getlistdate(); +} + +void CYearSchceduleOutView::clearData() +{ + yearschceduleview->clearData(); +} + +void CYearSchceduleOutView::showWindow() +{ + int w = yearschceduleview->showWindow(); + this->setFixedSize(w, yearschceduleview->height()); +} + +void CYearSchceduleOutView::setTheMe(int type) +{ + yearschceduleview->setTheMe(type); +} + +void CYearSchceduleOutView::setDtype(int type, int arrowheight) +{ + yearschceduleview->setDtype(type, arrowheight); +} + +void CYearSchceduleOutView::setCurrentDate(QDate cdate) +{ + currentdate = cdate; + yearschceduleview->setCurrentDate(cdate); +} + +void CYearSchceduleOutView::adjustPosition(bool ad) +{ + yearschceduleview->adjustPosition(ad); +} + +void CYearSchceduleOutView::mousePressEvent(QMouseEvent *event) +{ + Q_UNUSED(event); + QPoint pos = QCursor::pos(); + pos = this->mapFromGlobal(pos); + QVector rect_press; + QRect rect(35,50,width() - 50,20); + int listShow = 0; + + if (!scheduleinfoList.isEmpty()) { + if (scheduleinfoList.size() < DDEYearCalendar::YearScheduleListMaxcount) + listShow = scheduleinfoList.size(); + else + listShow = DDEYearCalendar::YearScheduleListMaxcount; + } + for (int i = 0; i < listShow; i++) { + if (this->arrowDirection() == DArrowRectangle::ArrowLeft) + rect_press.append(QRect(35, 20 + i * 30, width() - 50, 20)); + else + rect_press.append(QRect(20, 20 + i * 30, width() - 50, 20)); + } + for (int i = 0; i < listShow; i++) { + if (rect_press.at(i).contains(pos)) { + if (i > 3 && list_count > DDEYearCalendar::YearScheduleListMaxcount) { + emit signalsViewSelectDate(currentdate); + this->hide(); + //跳转到周视图 + } else { + if (scheduleinfoList.at(i).type.ID != DDECalendar::FestivalTypeID) { + CSchceduleDlg dlg(0); + dlg.setData(scheduleinfoList.at(i)); + if (dlg.exec() == DDialog::Accepted) + emit signalupdateschcedule(); + } + } + } + } +} diff -Nru dde-calendar-5.7.0.4/src/widget/yearWidget/yearschceduleview.h dde-calendar-5.7.0.23/src/widget/yearWidget/yearschceduleview.h --- dde-calendar-5.7.0.4/src/widget/yearWidget/yearschceduleview.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/yearWidget/yearschceduleview.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,276 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#ifndef YEARSCHCEDULEVIEW_H +#define YEARSCHCEDULEVIEW_H + +#include "schedulestructs.h" + +#include +#include +#include +#include +#include + +DWIDGET_USE_NAMESPACE +class QVBoxLayout; +class CYearSchceduleItem; +class CYearSchceduleOutView; +class CYearSchceduleView : public DWidget +{ + Q_OBJECT + +public: + /** + * @brief CYearSchceduleView 构造函数 + * @param parent 父类 + */ + explicit CYearSchceduleView(QWidget *parent = nullptr); + /** + * @brief ~CYearSchceduleView 析构函数 + */ + ~CYearSchceduleView(); + /** + * @brief setSoloDay + * @param soloday + */ + void setSoloDay(QString soloday); + /** + * @brief setData 设置日程信息,并全天日程置于非全天日程之前 + * @param vListData 日程信息 + */ + void setData(QVector &vListData); + /** + * @brief getlistdate 获取日程信息 + * @return 日程信息 + */ + QVector getlistdate() + { + return m_vlistData; + } + /** + * @brief clearData 清除日程信息 + */ + void clearData(); + /** + * @brief showWindow 设置日程浮框的大小 + * @return 日程浮框的宽度 + */ + int showWindow(); + /** + * @brief setTheMe 根据系统主题类型设置颜色 + * @param type 系统主题类型 + */ + void setTheMe(int type = 0); + /** + * @brief setDtype + * @param type + * @param arrowheight + */ + void setDtype(int type, int arrowheight); + /** + * @brief setCurrentDate 设置日程所在当天的日期 + * @param cdate 日期 + */ + void setCurrentDate(QDate cdate); + /** + * @brief getCurrentDate 获取日程所在当天的日期 + * @return 日期 + */ + QDate getCurrentDate(); + /** + * @brief adjustPosition 根据日程浮框左右朝向不同,日程显示位置不同 + * @param ad 是否调整显示位置 + */ + void adjustPosition(bool ad); +private: + /** + * @brief updateDateShow 调整最多展示日程为五个,并设置浮框大小 + */ + void updateDateShow(); + /** + * @brief createItemWidget 设置每条日程的具体信息 + * @param info 日程信息 + * @param type 系统主题类型 + */ + void createItemWidget(ScheduleDtailInfo info, int type = 0); +protected: + /** + * @brief paintEvent 绘制日程 + * @param event 绘图事件 + */ + void paintEvent(QPaintEvent *event) override; + /** + * @brief paintItem 绘制日程 + * @param info 日程信息 + * @param index 日程的索引 + * @param type 系统主题类型 + */ + void paintItem(ScheduleDtailInfo info, int index, int type = 0); + /** + * @brief paintItem + */ + void paintItem(); +private: + DListWidget *m_gradientItemList = nullptr; //下拉列表窗 + bool m_widgetFlag; + QVector m_vlistData; + QString m_soloDay; + QVector m_labellist; + int m_type; + QDate m_currentDate; + QColor m_bBackgroundcolor = "#000000"; + QColor m_btimecolor = "#526A7F"; + QColor m_bttextcolor = "#414D68"; + QColor m_lBackgroundcolor = Qt::white; + QColor m_ltextcolor = "#001A2E"; + QColor m_solocolor = "#001A2E"; + QColor m_TBcolor = "#001A2E"; + int m_dtype = 3; + int m_arrowheight = 0; + QColor m_borderColor = "#000000"; + bool adjustPos = false; +}; + +class CYearSchceduleItem : public DLabel +{ + Q_OBJECT + +public: + /** + * @brief CYearSchceduleItem 构造函数 + * @param parent 父类 + */ + explicit CYearSchceduleItem(QWidget *parent = nullptr); + /** + * @brief setBackgroundColor 设置背景颜色 + * @param color1 背景颜色 + */ + void setBackgroundColor(QColor color1); + /** + * @brief setStateColor 设置圆点的颜色 + * @param color1 圆点颜色 + */ + void setStateColor(QColor color1); + /** + * @brief setText 设置文字颜色和字体 + * @param tcolor 文字颜色 + * @param font 文字字体 + */ + void setText(QColor tcolor, QFont font); + /** + * @brief setTimeC 设置时间的颜色和字体 + * @param tcolor 时间的颜色 + * @param font 时间的字体 + */ + void setTimeC(QColor tcolor, QFont font); + /** + * @brief setData 设置日程信息 + * @param vScheduleInfo 日程信息 + */ + void setData(ScheduleDtailInfo vScheduleInfo); +protected: + /** + * @brief paintEvent + * @param e + */ + void paintEvent(QPaintEvent *e) override; +private: + ScheduleDtailInfo m_ScheduleInfo; + QColor m_Backgroundcolor; + QColor m_timecolor; + QColor m_Statecolor; + QFont m_timefont; + QColor m_ttextcolor; + QFont m_tfont; +}; + +class CYearSchceduleOutView : public DArrowRectangle +{ + Q_OBJECT + +public: + /** + * @brief CYearSchceduleOutView 构造函数 + * @param parent 父类 + */ + explicit CYearSchceduleOutView(QWidget *parent = nullptr); + /** + * @brief setSoloDay + * @param soloday + */ + void setSoloDay(QString soloday); + /** + * @brief setData 设置日程信息 + * @param vListData 日程信息 + */ + void setData(QVector &vListData); + /** + * @brief clearData 清楚数据 + */ + void clearData(); + /** + * @brief showWindow 设置日程浮框外边框大小 + */ + void showWindow(); + /** + * @brief setTheMe 设置系统主题颜色 + * @param type 系统主题 + */ + void setTheMe(int type = 0); + /** + * @brief setDtype + * @param type + * @param arrowheight + */ + void setDtype(int type, int arrowheight); + /** + * @brief setCurrentDate 设置日程所在当天的日期 + * @param cdate 日期 + */ + void setCurrentDate(QDate cdate); + /** + * @brief adjustPosition 根据日程浮框左右朝向不同,日程显示位置不同 + * @param ad 是否调整显示位置 + */ + void adjustPosition(bool ad); +signals: + /** + * @brief signalsViewSelectDate 跳转视图信号 + * @param date 当天的时间 + */ + void signalsViewSelectDate(QDate date); + /** + * @brief signalupdateschcedule 更新日程信息的信号 + */ + void signalupdateschcedule(); +private: + CYearSchceduleView *yearschceduleview = nullptr; + QVector scheduleinfoList; + QDate currentdate; + int list_count = 0; + +protected: + /** + * @brief mousePressEvent 鼠标单击事件,单击非节日日程进行编辑,单击”...”区域跳转到周视图。 + * @param event 鼠标事件 + */ + void mousePressEvent(QMouseEvent *event) override; +}; +#endif // CSHCEDULEDAYVIEW_H + diff -Nru dde-calendar-5.7.0.4/src/widget/yearWidget/yearview.cpp dde-calendar-5.7.0.23/src/widget/yearWidget/yearview.cpp --- dde-calendar-5.7.0.4/src/widget/yearWidget/yearview.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/yearWidget/yearview.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,678 @@ + +/* + * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ + +#include "calendardbus.h" +#include "scheduledatamanage.h" +#include "yearschceduleview.h" +#include "yearview.h" +#include "constants.h" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +DGUI_USE_NAMESPACE +CYearSchceduleOutView *CYearView::m_Scheduleview = nullptr; +CMonthDayRect *CMonthDayRect::m_CurrentRect =nullptr; +qreal CMonthDayRect::m_DevicePixelRatio = 0; +QColor CMonthDayRect::m_ceventColor("#FF5D00"); +QColor CMonthDayRect::m_notCurrentTextColor = "#b2b2b2"; +CMonthDayRect::CellColor CMonthDayRect::m_currentColor; +QColor CMonthDayRect::m_defaultTextColor; +QColor CMonthDayRect::m_selectedTextColor; + +CYearView::CYearView(QWidget *parent) + : CustomFrame(parent) +{ + setMouseTracking(true); + //add separator line + m_currentMouth = new CustomFrame(); + m_currentMouth->setFixedHeight(24); + m_currentMouth->setContentsMargins(0, 0, 0, 0); + m_currentMouth->setTextAlign(Qt::AlignLeft); + + m_momthFont.setWeight(QFont::Medium); + m_momthFont.setPixelSize(DDECalendar::FontSizeSixteen); + m_currentMouth->setTextFont(m_momthFont); + + QHBoxLayout *separatorLineLayout = new QHBoxLayout; + separatorLineLayout->setMargin(0); + separatorLineLayout->setSpacing(0); + separatorLineLayout->setContentsMargins(0, 0, 0, 0); + separatorLineLayout->addWidget(m_currentMouth); + separatorLineLayout->addStretch(); + + m_currentMouth->show(); + m_currentMouth->installEventFilter(this); + + m_monthView = new CYearMonthView(this); + connect(m_monthView, + &CYearMonthView::signalPressDate, + this, + &CYearView::slotPressClickDate); + connect(m_monthView, + &CYearMonthView::signalDoubleClickDate, + this, + &CYearView::slotDoubleClickDate); + + m_hhLayout = new QVBoxLayout; + m_hhLayout->addLayout(separatorLineLayout); + m_hhLayout->addWidget(m_monthView); + m_hhLayout->setMargin(0); + m_hhLayout->setSpacing(0); + m_hhLayout->setContentsMargins(13, 10, 10, 10); + + setLayout(m_hhLayout); + createYearSchceduleView(parent); +} + +void CYearView::slotupdateSchedule(const int id) +{ + setCurrentDate(m_currentDate, id); +} + +void CYearView::slotDoubleClickDate(const QDate &date) +{ + if (date.year() < DDECalendar::QueryEarliestYear) + return; + SchceduleViewHide(); + emit signaldoubleclickDate(date); +} + +void CYearView::slotPressClickDate(const QDate &date) +{ + if (date.year() < DDECalendar::QueryEarliestYear) + return; + emit signalcurrentDateChanged(date); + emit signalHideInfo(); + emit signalSelectInfo(true); + m_Scheduleview->setCurrentDate(date); + + for (int i = 0; i < m_DateRangeInfo.size(); ++i) { + if (m_DateRangeInfo.at(i).date ==date) { + m_Scheduleview->setData(m_DateRangeInfo[i].vData); + } + } + QPoint pos22 = QCursor::pos(); + QDesktopWidget *w = QApplication::desktop(); + m_Scheduleview->showWindow(); + + if (pos22.x() + 10 + m_Scheduleview->width() < w->width()) { + m_Scheduleview->setArrowDirection(DArrowRectangle::ArrowLeft); + m_Scheduleview->show(pos22.x() + 10, pos22.y()); + } else { + m_Scheduleview->adjustPosition(true); + m_Scheduleview->setArrowDirection(DArrowRectangle::ArrowRight); + m_Scheduleview->show(pos22.x() - 10, pos22.y()); + } +} + +void CYearView::setFirstWeekday(int weekday) +{ + m_firstWeekDay = weekday; + updateDate(); +} + +void CYearView::setTheMe(int type) +{ + m_themetype = type; + + if (type == 0 || type == 1) { + DPalette bpa = palette(); + bpa.setColor(DPalette::Background, Qt::white); + setPalette(bpa); + setBackgroundRole(DPalette::Background); + m_currentMouth->setTextColor( QColor("#CF0059")); + + m_bnormalColor = "#FFFFFF"; + m_topBorderColor = Qt::red; + m_backgroundCircleColor = "#0081FF"; + m_currentDayTextColor = "#0081FF"; + m_weekendsTextColor = Qt::black; + m_festivalTextColor = Qt::black; + } else if (type == 2) { + m_bnormalColor = "#FFFFFF"; + m_bnormalColor.setAlphaF(0.05); + m_currentMouth->setTextColor( QColor("#BF1D63")); + + m_topBorderColor = Qt::red; + m_backgroundCircleColor = "#0059D2"; + m_currentDayTextColor = "#0059D2"; + m_weekendsTextColor = Qt::black; + m_festivalTextColor = Qt::black; + } + m_monthView->setTheMe(type); + QColor monthcolor = Qt::white; + monthcolor.setAlphaF(0); + m_currentMouth->setBColor(monthcolor); + m_Scheduleview->setTheMe(type); +} + +void CYearView::SchceduleViewHide() +{ + m_Scheduleview->hide(); + m_Scheduleview->clearData(); +} + +void CYearView::getInfoAndSetLineFlag() +{ + CScheduleDataManage *tdataManage = CScheduleDataManage::getScheduleDataManage(); + m_vlineflag.resize(42); + m_vlineflag.fill(false); + + if (tdataManage->getGetAllYearScheduleInfo()->m_monthInfo.size()>0) { + m_DateRangeInfo = tdataManage->getGetAllYearScheduleInfo()->m_monthInfo[m_currentDate.month()]; + if (m_DateRangeInfo.count() == DDEYearCalendar::RectSizeofEveyMonth) { + for (int i = 0; i < DDEYearCalendar::RectSizeofEveyMonth; i++) { + if (!m_DateRangeInfo.at(i).vData.isEmpty()) { + m_vlineflag[i] = true; + } + } + } + } + m_monthView->setLintFlag(m_vlineflag); + m_monthView->update(); +} + +void CYearView::setCurrentDate(const QDate date, int type) +{ + Q_UNUSED(type); + qDebug() << "set current date " << date; + + m_currentDate = date; + QLocale locale; + m_currentMouth->setTextStr(locale.monthName(date.month(), QLocale::ShortFormat)); + updateDate(); + m_monthView->setDate(m_days); +} + +void CYearView::setCellSelectable(bool selectable) +{ + if (selectable == m_cellSelectable) + return; + m_cellSelectable = selectable; +} + +int CYearView::getDateIndex(const QDate &date) const +{ + for (int i = 0; i != DDEYearCalendar::RectSizeofEveyMonth; ++i) + if (m_days[i] == date) + return i; + + return 0; +} +bool CYearView::eventFilter(QObject *o, QEvent *e) +{ + QWidget *cell = qobject_cast(o); + + if (cell == m_currentMouth) { + if (e->type() == QEvent::MouseButtonDblClick) { + emit signalselectMonth(m_currentDate); + } + } + return false; +} +void CYearView::updateDate() +{ + const QDate firstDay(m_currentDate.year(), m_currentDate.month(), 1); + int offset = firstDay.dayOfWeek() % 7 - m_firstWeekDay ; + const int day = offset <0 ?offset +7:offset; + const int currentIndex = day + m_currentDate.day() - 1; + + if (currentIndex < 0) { + return; + } + for (int i(0); i != DDEYearCalendar::RectSizeofEveyMonth; ++i) { + m_days[i] = firstDay.addDays(i - day); + } + update(); +} + +void CYearView::createYearSchceduleView(QWidget *parent) +{ + if (m_Scheduleview == nullptr) { + m_Scheduleview = new CYearSchceduleOutView(parent); + connect(m_Scheduleview, &CYearSchceduleOutView::signalsViewSelectDate, this, &CYearView::signalselectWeekwindow); + connect(m_Scheduleview, &CYearSchceduleOutView::signalupdateschcedule, this, &CYearView::signalupdateschcedule); + } +} + +void CYearView::resizeEvent(QResizeEvent *event) +{ + int leftmagin = qFloor(width() * 0.06435 + 0.5); + int rightmagin = leftmagin; + int topmagin = qFloor(height() * 0.02955 + 0.5); + int buttonmagin = qFloor(height() * 0.044 + 0.5); + + m_hhLayout->setContentsMargins(leftmagin, topmagin, rightmagin, buttonmagin); + m_momthFont.setPixelSize(qFloor(16 + (height() - 159) / 16.75)); + m_currentMouth->setTextFont(m_momthFont); + m_currentMouth->setFixedHeight(24 + (height() - 159) / 12); + m_currentMouth->update(); + + QFrame::resizeEvent(event); +} + +void CYearView::mousePressEvent(QMouseEvent *event) +{ + if (m_selectFlag) return; + + if (event->button() == Qt::LeftButton) { + emit signalHideInfo(); + } + CustomFrame::mousePressEvent(event); +} + + +void CYearView::paintEvent(QPaintEvent *e) +{ + Q_UNUSED(e); + int labelwidth = width() - 2 * m_borderframew; + int labelheight = height() - 2 * m_borderframew; + + QPainter painter(this); + if (1) { + painter.save(); + painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; + painter.setBrush(QBrush(m_bnormalColor)); + painter.setPen(Qt::NoPen); + QPainterPath painterPath; + painterPath.moveTo(m_radius, m_borderframew); + painterPath.arcTo(QRect(m_borderframew, m_borderframew, m_radius * 2, m_radius * 2), 90, 90); + + painterPath.lineTo(0, labelheight - m_radius); + painterPath.arcTo(QRect(m_borderframew, labelheight - m_radius * 2, m_radius * 2, m_radius * 2), 180, 90); + + painterPath.lineTo(labelwidth - m_radius, labelheight); + painterPath.arcTo(QRect(labelwidth - m_radius * 2, labelheight - m_radius * 2, m_radius * 2, m_radius * 2), 270, 90); + + painterPath.lineTo(labelwidth, m_radius); + + painterPath.arcTo(QRect(labelwidth - m_radius * 2, m_borderframew, m_radius * 2, m_radius * 2), 0, 90); + + painterPath.lineTo(m_radius, m_borderframew); + painterPath.closeSubpath(); + painter.drawPath(painterPath); + painter.restore(); + } +} + +CYearMonthView::CYearMonthView(DWidget *parent) + :DWidget (parent) +{ + for (int i = 0; i < DDEYearCalendar::RectSizeofEveyMonth; ++i) { + CMonthDayRect *item = new CMonthDayRect(); + m_DayItem.append(item); + } + setMouseTracking(true); + CMonthDayRect::setDevicePixelRatio(devicePixelRatioF()); +} + +CYearMonthView::~CYearMonthView() +{ + for (int i = 0; i setDate(date[i]); + m_DayItem.at(i)->setIsCurrentMonth(date[i].month() == m_currentMonth); + } +} + +void CYearMonthView::setTheMe(int type) +{ + CMonthDayRect::setTheMe(type); +} + +void CYearMonthView::setLintFlag(const QVector &lineFlag) +{ + m_vlineflag = lineFlag; + + if (m_vlineflag.size() == DDEYearCalendar::RectSizeofEveyMonth) { + for (int i = 0; i < DDEYearCalendar::RectSizeofEveyMonth; i++) { + m_DayItem.at(i)->setLineFlag(m_vlineflag.at(i)); + } + } +} + +void CYearMonthView::updateSize() +{ + qreal w = width()/7; + qreal h = height()/6; + QRectF rect ; + int w_offset = 0; + int h_offset = 0; + + for (int i = 0 ; i < m_DayItem.size(); ++i) { + h_offset = i / 7; + w_offset = i % 7; + rect.setRect(w*w_offset, + h*h_offset, + w, + h); + m_DayItem.at(i)->setRect(rect); + } + update(); +} + +int CYearMonthView::getMousePosItem(const QPointF &pos) +{ + int res =-1; + + for (int i = 0 ; i < m_DayItem.size(); ++i) { + if (m_DayItem.at(i)->rect().contains(pos)) { + res = i; + break; + } + } + return res; +} + +void CYearMonthView::resizeEvent(QResizeEvent *event) +{ + Q_UNUSED(event); + updateSize(); +} + +void CYearMonthView::mousePressEvent(QMouseEvent *event) +{ + int itemindex = getMousePosItem(event->pos()); + + if (!(itemindex<0)) { + m_DayItem.at(itemindex)->setCellEvent(CMonthDayRect::CellPress); + m_press = true; + if ( event->button() ==Qt::LeftButton) { + m_pressIndex = itemindex; + emit signalPressDate(m_DayItem.at(itemindex)->getDate()); + } + } + update(); +} + +void CYearMonthView::mouseDoubleClickEvent(QMouseEvent *event) +{ + int itemindex = getMousePosItem(event->pos()); + + if (!(itemindex<0)) { + if (m_pressIndex == itemindex) { + m_DayItem.at(itemindex)->setCellEvent(CMonthDayRect::CellPress); + m_press = true; + if ( event->button() ==Qt::LeftButton) { + emit signalDoubleClickDate(m_DayItem.at(itemindex)->getDate()); + } + } + } +} + +void CYearMonthView::mouseReleaseEvent(QMouseEvent *event) +{ + m_press = false; + mouseMoveEvent(event); +} + +void CYearMonthView::mouseMoveEvent(QMouseEvent *event) +{ + if (!m_press) { + int itemindex = getMousePosItem(event->pos()); + if (!(itemindex<0)) { + m_DayItem.at(itemindex)->setCellEvent(CMonthDayRect::Cellhover); + } + update(); + } +} + +void CYearMonthView::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event); + QPainter painter(this); + painter.setRenderHints(QPainter::Antialiasing |QPainter::SmoothPixmapTransform); + + for (int i = 0 ; i < m_DayItem.size(); ++i) { + m_DayItem[i]->paintItem(&painter,m_DayItem[i]->rect()); + } + painter.end(); +} + +void CYearMonthView::leaveEvent(QEvent *event) +{ + Q_UNUSED(event); + CMonthDayRect::setCurrentRect(nullptr); + update(); +} + + +CMonthDayRect::CMonthDayRect() + :m_rect(0,0,0,0) +{ + m_dayNumFont.setPixelSize(DDECalendar::FontSizeTwelve); + m_hightFont.setPixelSize(DDECalendar::FontSizeTwelve); +} + +void CMonthDayRect::setTheMe(int type) +{ + if (type ==2) { + m_currentColor.hoverColor = "#FFFFFF"; + m_currentColor.hoverColor.setAlphaF(0.1); + m_currentColor.pressColor = "#252525"; + m_currentColor.pressColor.setAlphaF(1); + m_currentColor.normalColor = "#000000"; + m_currentColor.normalColor.setAlphaF(0.00); + m_ceventColor = QColor(204, 77, 3); + + m_notCurrentTextColor = "#C0C6D4"; + m_notCurrentTextColor.setAlphaF(0.5); + m_defaultTextColor = "#C0C6D4"; + m_selectedTextColor = Qt::white; + } else if (type == 0 || type == 1) { + m_currentColor.hoverColor = "#000000"; + m_currentColor.hoverColor.setAlphaF(0.05); + m_currentColor.pressColor = "#000000"; + m_currentColor.pressColor.setAlphaF(0.2); + m_currentColor.normalColor = "#FFFFFF"; + m_currentColor.normalColor.setAlphaF(1); + m_ceventColor = QColor(255, 93, 0); + + m_selectedTextColor = Qt::white; + m_defaultTextColor = Qt::black; + m_notCurrentTextColor = "#b2b2b2"; + } +} + +CMonthDayRect::~CMonthDayRect() +{ + +} + +void CMonthDayRect::setDate(const QDate &date) +{ + m_date = date; +} + +QDate CMonthDayRect::getDate() const +{ + return m_date; +} + +void CMonthDayRect::setCellEvent(const CMonthDayRect::CellEventType &type) +{ + m_cellEventType = type; + m_CurrentRect = this; +} + +void CMonthDayRect::setIsCurrentMonth(const bool isCurrMonth) +{ + m_isCurrentMonth = isCurrMonth; +} + +QRectF CMonthDayRect::rect() const +{ + return m_rect; +} + +void CMonthDayRect::setRect(const QRectF &rect) +{ + m_rect = rect; +} + +void CMonthDayRect::setRect(qreal x, qreal y, qreal w, qreal h) +{ + m_rect.setRect(x,y,w,h); +} + +void CMonthDayRect::paintItem(QPainter *painter, const QRectF &rect) +{ + m_highColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); + + if (m_date.year() < DDECalendar::QueryEarliestYear) + return; + const bool isCurrentDay = m_date == QDate::currentDate() && m_isCurrentMonth; + bool isSelectedCell = false; + if (isCurrentDay) { + isSelectedCell = true; + } + + const qreal r = rect.width() > rect.height() ? rect.height() * 0.9 : rect.width() * 0.9 ; + int fontsize = qRound(DDECalendar::FontSizeTwelve + (r - 18) * 6 / 17); + + if (fontsize < DDECalendar::FontSizeTwelve) { + fontsize = DDECalendar::FontSizeTwelve; + } + m_dayNumFont.setPixelSize(fontsize); + m_hightFont.setPixelSize(fontsize); + const qreal x = rect.x()+(rect.width() - r) / 2; + const qreal y = rect.y()+(rect.height() - r) / 2; + QRectF fillRect = QRectF(x, y, r, r); + QColor m_cellBackgroundColor; + + if (m_CurrentRect !=this) { + m_cellEventType = CellNormal; + } + if (m_cellEventType == CellPress) { + m_cellBackgroundColor = m_currentColor.pressColor; + } else if (m_cellEventType == Cellhover) { + m_cellBackgroundColor = m_currentColor.hoverColor; + } else { + m_cellBackgroundColor = m_currentColor.normalColor; + } + painter->setBrush(m_cellBackgroundColor); + painter->setPen(Qt::NoPen); + painter->drawEllipse(fillRect); + + bool highflag = false; + + if (m_isCurrentMonth) { + highflag = CScheduleDataManage::getScheduleDataManage()->getSearchResult(m_date); + } + if (highflag) { + painter->setBrush(QBrush(m_highColor)); + painter->setPen(Qt::NoPen); + painter->drawEllipse(fillRect); + painter->setPen(Qt::SolidLine); + painter->setPen(m_highTextColor); + painter->setFont(m_hightFont); + painter->drawText(fillRect, Qt::AlignCenter, QString::number(m_date.day())); + } else { + // draw selected cell background circle + if (isSelectedCell) { + painter->setBrush(QBrush(m_highColor)); + painter->setPen(Qt::NoPen); + painter->drawEllipse(fillRect); + } + painter->setPen(Qt::SolidLine); + + // draw text of day + if (isSelectedCell) { + painter->setPen(m_selectedTextColor); + } else if (isCurrentDay) { + painter->setPen(m_currentDayTextColor); + } else { + if (m_isCurrentMonth) + painter->setPen(m_defaultTextColor); + else + painter->setPen(m_notCurrentTextColor); + } + painter->setFont(m_dayNumFont); + painter->drawText(fillRect, Qt::AlignCenter, QString::number(m_date.day())); + + if (m_vlineflag) { + painter->save(); + painter->setRenderHint(QPainter::Antialiasing); + painter->setRenderHint(QPainter::HighQualityAntialiasing); + painter->setRenderHint(QPainter::SmoothPixmapTransform); + QPen pen; + pen.setWidth(2); + pen.setColor(m_ceventColor); + painter->setPen(pen); + painter->setBrush(QBrush(m_ceventColor)); + painter->setPen(Qt::NoPen); + qreal r = rect.width() * (4 / 25); + if (r < 4) { + r = 4; + } else if ( r > 7) { + r = 7; + } + painter->drawEllipse(QRectF(rect.width() - r+rect.x(), + rect.y(), + r, + r)); + painter->restore(); + } + } +} + +void CMonthDayRect::setLineFlag(const bool flag) +{ + m_vlineflag = flag; +} + +void CMonthDayRect::setDevicePixelRatio(const qreal pixel) +{ + m_DevicePixelRatio = pixel; +} + +void CMonthDayRect::setCurrentRect(CMonthDayRect *currrect) +{ + m_CurrentRect = currrect; +} + diff -Nru dde-calendar-5.7.0.4/src/widget/yearWidget/yearview.h dde-calendar-5.7.0.23/src/widget/yearWidget/yearview.h --- dde-calendar-5.7.0.4/src/widget/yearWidget/yearview.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/yearWidget/yearview.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,424 @@ +#ifndef YEARVIEW_H +#define YEARVIEW_H + +#include "schedulestructs.h" +#include "customframe.h" + +#include +#include + +#include +#include +#include +#include +#include +#include + +DWIDGET_USE_NAMESPACE +class CalendarDBus; +class CaLunarDayInfo; +class QLabel; +class CYearSchceduleView; +class CYearSchceduleOutView; +class WeekIndicator; +/** + * @brief The CalendarYearDayType enum + */ +enum CalendarYearDayType { + SO_YFestival = QStyleOption::SO_CustomBase + 0x01, + SO_YWeekends = QStyleOption::SO_CustomBase + 0x02, + SO_YWeekendsAndFestival = SO_YFestival | SO_YWeekends, + SO_YNotCurrentMonth = 0x04, + SO_YNotCurrentMonthFestival = SO_YNotCurrentMonth | SO_YFestival, + SO_YDefault, +}; +//#define M_FLAG 0; + +class CYearMonthView; +class CYearView: public CustomFrame +{ + Q_OBJECT + + Q_PROPERTY(QColor backgroundCircleColor MEMBER m_backgroundCircleColor DESIGNABLE true SCRIPTABLE true) + Q_PROPERTY(QColor weekendsTextColor MEMBER m_weekendsTextColor DESIGNABLE true SCRIPTABLE true) + Q_PROPERTY(QColor topBorderColor MEMBER m_topBorderColor DESIGNABLE true SCRIPTABLE true) + Q_PROPERTY(bool cellSelectable READ cellSelectable WRITE setCellSelectable NOTIFY cellSelectableChanged) +public: + /** + * @brief CYearView 构造函数 + * @param parent 父类 + */ + explicit CYearView(QWidget *parent = nullptr); + /** + * @brief setFirstWeekday 设置日历每周是以周几开始的 + * @param weekday 星期几 + */ + void setFirstWeekday(int weekday); + /** + * @brief cellSelectable + * @return + */ + inline bool cellSelectable() const + { + return m_cellSelectable; + } + /** + * @brief setTheMe 根据系统主题类型,设置颜色 + * @param type 系统主题类型 + */ + void setTheMe(int type = 0); + /** + * @brief SchceduleViewHide 隐藏日程浮框 + */ + static void SchceduleViewHide(); + /** + * @brief getInfoAndSetLineFlag 获取日程信息,设置是否有日程的标志 + */ + void getInfoAndSetLineFlag(); +signals: + /** + * @brief signalcurrentDateChanged 当前现实日期改变的信号 + * @param date 传递日期参数 + */ + void signalcurrentDateChanged(QDate date); + /** + * @brief cellSelectableChanged + * @param cellSelectable + */ + void cellSelectableChanged(bool cellSelectable) const; + /** + * @brief signaldoubleclickDate 鼠标双击日期的信号 + * @param date 传递日期参数 + */ + void signaldoubleclickDate(QDate date); + /** + * @brief signalselectMonth 鼠标双击月份的信号 + * @param date 传递日期参数 + */ + void signalselectMonth(QDate date); + /** + * @brief signalselectWeekwindow 选择周视图的信号 + * @param date 传递日期参数 + */ + void signalselectWeekwindow(QDate date); + /** + * @brief signalupdateschcedule 更新日程的信号 + */ + void signalupdateschcedule(); + /** + * @brief signalHideInfo 隐藏日程浮框的信号 + */ + void signalHideInfo(); + /** + * @brief signalSelectInfo 设置选择是否选择日期的标志 + * @param flag 是否选择日期 + */ + void signalSelectInfo(bool flag); +public slots: + /** + * @brief setCurrentDate 设置当前的日期 + * @param date 日期 + * @param type + */ + void setCurrentDate(const QDate date, int type = 0); + /** + * @brief setCellSelectable + * @param selectable + */ + void setCellSelectable(bool selectable); + /** + * @brief slotupdateSchedule 设置当前时间 + * @param id + */ + void slotupdateSchedule(const int id); + /** + * @brief slotDoubleClickDate 隐藏日程浮框,并发出鼠标双击的信号 + * @param date 传递时间参数 + */ + void slotDoubleClickDate(const QDate &date); + /** + * @brief slotPressClickDate 鼠标单击日期,显示日程浮框 + * @param date 传递日程参数 + */ + void slotPressClickDate(const QDate &date); +private: + /** + * @brief getDateIndex 根据日期找到在一个月中的位置索引 + * @param date 比较的日期 + * @return 索引 + */ + int getDateIndex(const QDate &date) const; + /** + * @brief eventFilter 过滤器,双击年视图下的月份跳转到月视图。 + * @param o 事件对象 + * @param e 事件类型 + * @return false + */ + bool eventFilter(QObject *o, QEvent *e) override; + /** + * @brief updateDate 更新日期 + */ + void updateDate(); + /** + * @brief createYearSchceduleView 创建日程浮框对象,并连接信号和槽 + * @param parent 父类 + */ + void createYearSchceduleView(QWidget *parent = nullptr); +protected: + /** + * @brief resizeEvent 更新月份框的高度 + * @param event 窗口大小调整事件 + */ + void resizeEvent(QResizeEvent *event) override; + /** + * @brief mousePressEvent 单击鼠标发出隐藏日程浮框信号 + * @param event 鼠标事件 + */ + void mousePressEvent(QMouseEvent *event) override; +protected: + /** + * @brief paintEvent 绘制每个月的背景 + * @param e 绘图事件 + */ + void paintEvent(QPaintEvent *e) override; +private: + CustomFrame *m_currentMouth = nullptr; + QDate m_days[42]; + QDate m_currentDate; + QStringList m_monthList; + int m_selectedCell = -1; + bool m_cellSelectable = true; + + QFont m_momthFont; + QColor m_topBorderColor = Qt::red; + QColor m_backgroundCircleColor = "#2ca7f8"; + QColor m_currentDayTextColor = "#2ca7f8"; + QColor m_weekendsTextColor = Qt::black; + QColor m_festivalTextColor = Qt::black; + QColor m_cellBackgroundColor = "#FFFFFF" ; + + int m_firstWeekDay = 0; + QVBoxLayout *m_hhLayout = nullptr; + int m_themetype = 1; + QColor m_bnormalColor = "#FFFFFF"; + const int m_radius = 8; + const int m_borderframew = 0; + static CYearSchceduleOutView *m_Scheduleview; + bool m_selectFlag = false; + QDate m_selectDate; + QVector m_vlineflag; //节假日和日程标识 + CYearMonthView *m_monthView = nullptr; + QVector m_DateRangeInfo; +}; + +class CMonthDayRect; +class CYearMonthView : public DWidget +{ + Q_OBJECT +public: + /** + * @brief CYearMonthView 构造函数 + * @param parent 父类 + */ + explicit CYearMonthView(DWidget *parent = nullptr); + /** + *@brief ~CYearMonthView 析构函数 + */ + ~CYearMonthView() override; + /** + * @brief setDate 设置每个月的日期 + * @param date 日期 + */ + void setDate(const QDate date[42]); + /** + * @brief setTheMe 根据系统主题设置颜色 + * @param type 系统主题 + */ + void setTheMe(int type = 0); + /** + * @brief setLintFlag 设置是否有日程的标志 + * @param lineFlag 是否有日程的标志 + */ + void setLintFlag(const QVector &lineFlag); +private: + /** + * @brief updateSize 设置每天的日期所在矩形框的大小 + */ + void updateSize(); + /** + * @brief getMousePosItem 获取点击日期的索引 + * @param pos 点击的点 + * @return 索引值 + */ + int getMousePosItem(const QPointF &pos); +protected: + /** + * @brief resizeEvent 设置每天的日期所在矩形框的大小 + * @param event 窗口大小调整函数 + */ + void resizeEvent(QResizeEvent *event) override; + /** + * @brief mousePressEvent 鼠标单击事件,单击日期显示当天的日程和节日。 + * @param event 鼠标事件 + */ + void mousePressEvent(QMouseEvent *event) override; + /** + * @brief mouseDoubleClickEvent 鼠标双击事件,双击跳转到上次打开的视图 + * @param event 鼠标事件 + */ + void mouseDoubleClickEvent(QMouseEvent *event) override; + /** + * @brief mouseReleaseEvent 鼠标释放事件 + * @param event 鼠标事件 + */ + void mouseReleaseEvent(QMouseEvent *event) override; + /** + * @brief mouseMoveEvent 鼠标移动事件,设置hover状态 + * @param event 鼠标事件 + */ + void mouseMoveEvent(QMouseEvent *event) override; + /** + * @brief paintEvent 绘制日期以及当天状态 + * @param event 绘图事件 + */ + void paintEvent(QPaintEvent *event) override; + /** + * @brief leaveEvent 离开事件,设置当前选中的日期为空 + * @param event QT事件 + */ + void leaveEvent(QEvent *event) override; +signals: + /** + * @brief signalPressDate 鼠标点击日期的信号 + * @param date 传递时间参数 + */ + void signalPressDate(const QDate &date); + /** + * @brief signalDoubleClickDate 鼠标双击日期的信号 + * @param date 传递时间参数 + */ + void signalDoubleClickDate(const QDate &date); +private: + QVector m_DayItem; + int m_currentMonth =1; + QVector m_vlineflag; //节假日和日程标识 + bool m_press = false; + int m_pressIndex =0; +}; + + +class CMonthDayRect +{ +public: + /** + * @brief The CellEventType enum + */ + enum CellEventType { + CellNormal = 0, + Cellhover = 1, + CellPress = 2 + }; + /** + * @brief The CellColor struct + */ + struct CellColor { + QColor normalColor; + QColor hoverColor; + QColor pressColor; + }; + /** + * @brief CMonthDayRect 构造函数 + */ + CMonthDayRect(); + /** + * @brief ~CMonthDayRect 析构函数 + */ + ~CMonthDayRect(); + /** + * @brief setDate 设置某一天的时间 + * @param date 时间 + */ + void setDate(const QDate &date); + /** + * @brief getDate 获取某一天的时间 + * @return 时间 + */ + QDate getDate()const; + /** + * @brief setCellEvent 设置某一天的状态,CellEventType + * @param type CellEventType类型 + */ + void setCellEvent(const CellEventType &type); + /** + * @brief setIsCurrentMonth 设置是否是当前月 + * @param isCurrMonth 是否是当前月 + */ + void setIsCurrentMonth(const bool isCurrMonth); + /** + * @brief rect + * @return 当天日期所在的矩形 + */ + QRectF rect() const; + /** + * @brief setRect 设置当天日期的矩形 + * @param rect 矩形 + */ + void setRect(const QRectF &rect); + /** + * @brief setRect 设置当天日期的矩形 + * @param x 设置矩形左上角的x坐标 + * @param y 设置矩形左上角的y坐标 + * @param w 设置矩形的宽度 + * @param h 设置矩形的高度 + */ + inline void setRect(qreal x, qreal y, qreal w, qreal h); + /** + * @brief paintItem 绘制年视图一天的所有状态并展示出来。 + * @param painter QPainter绘画 + * @param rect 年视图中每一天所在的矩形 + */ + void paintItem(QPainter *painter, const QRectF &rect); + /** + * @brief setLineFlag 设置是否有日程的标志 + * @param flag 标志 + */ + void setLineFlag(const bool flag); + /** + * @brief setTheMe 根据系统主题类型设置颜色 + * @param type 系统主题类型 + */ + static void setTheMe(int type = 0); + /** + * @brief setDevicePixelRatio + * @param pixel + */ + static void setDevicePixelRatio(const qreal pixel); + /** + * @brief setCurrentRect 设置当前天 + * @param currrect 当前天 + */ + static void setCurrentRect(CMonthDayRect *currrect); +private: + QFont m_dayNumFont; + QFont m_hightFont; + int m_themetype = 0; + CellEventType m_cellEventType {CellNormal}; + QColor m_highColor = "#0081FF"; + QColor m_highTextColor = "#FFFFFF"; + bool m_vlineflag = false; + QColor m_currentDayTextColor = "#2ca7f8"; + + static QColor m_defaultTextColor; + static QColor m_selectedTextColor; + static QColor m_notCurrentTextColor; + static CellColor m_currentColor; + static QColor m_ceventColor; + static CMonthDayRect *m_CurrentRect; + static qreal m_DevicePixelRatio; + + QRectF m_rect; + QDate m_date; + bool m_isCurrentMonth = false; +}; + +#endif // YEARVIEW_H diff -Nru dde-calendar-5.7.0.4/src/widget/yearWidget/yearwindow.cpp dde-calendar-5.7.0.23/src/widget/yearWidget/yearwindow.cpp --- dde-calendar-5.7.0.4/src/widget/yearWidget/yearwindow.cpp 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/yearWidget/yearwindow.cpp 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,663 @@ +/* + * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#include "yearwindow.h" +#include "yearview.h" +#include "constants.h" +#include "schcedulesearchview.h" +#include "calendardbus.h" + +#include +#include + +#include +#include + +DGUI_USE_NAMESPACE +CYearWindow::CYearWindow(QWidget *parent) + : QMainWindow(parent) +{ + initUI(); + initConnection(); + setWindowFlags(Qt::FramelessWindowHint);//去掉标题 + setContentsMargins(0, 0, 0, 0); +} + +CYearWindow::~CYearWindow() +{ + +} + +bool CYearWindow::eventFilter(QObject *watched, QEvent *event) +{ + if (watched == m_today) { + if (event->type() == QEvent::MouseButtonPress) { + slottoday(); + } + } + return QMainWindow::eventFilter(watched, event); +} + +void CYearWindow::mousePressEvent(QMouseEvent *event) +{ + m_YearWidget->slotHideInfo(); + QMainWindow::mousePressEvent(event); +} + +void CYearWindow::resizeEvent(QResizeEvent *event) +{ + Q_UNUSED(event); + m_topWidget->setGeometry(0, 0, this->width(), DDEMonthCalendar::M_YTopHeight); + + if (m_searchfalg) { + m_tmainLayout->setContentsMargins(10, 0, 2, 0); + m_topWidget->setContentsMargins(10, 0, 2, 0); + } else { + m_tmainLayout->setContentsMargins(10, 0, 10, 0); + m_topWidget->setContentsMargins(10, 0, 10, 0); + } +} + +void CYearWindow::setDate(QDate date) +{ + if (!date.isValid()) return; + + m_YearWidget->setDate(date); + m_YearWidget->slotcurrentDateChanged(date); + emit signalCurrentDate(date); + slotUpdateCurrentDate(date); +} + +void CYearWindow::initUI() +{ + m_contentBackground = new DFrame(this); + + DPalette anipa = m_contentBackground->palette(); + anipa.setColor(DPalette::Background, "#F8F8F8"); + m_contentBackground->setAutoFillBackground(true); + m_contentBackground->setPalette(anipa); + m_today = new QLabel(this); + m_today->installEventFilter(this); + + QFont todayfont; + todayfont.setPixelSize(DDECalendar::FontSizeSixteen); + m_today->setFont(todayfont); + m_today->setAlignment(Qt::AlignCenter); + m_today->setText(QCoreApplication::translate("today", "Today", "Today")); + m_today->setFixedWidth(88); + m_today->setAutoFillBackground(true); + m_today->setFixedHeight(DDEYearCalendar::Y_MLableHeight - 4); + m_prevButton = new DIconButton(DStyle::SP_ArrowLeft, this); + //设置对象名称和辅助显示名称 + m_prevButton->setObjectName("PrevButton"); + m_prevButton->setAccessibleName("PrevButton"); + m_prevButton->setFixedWidth(DDEYearCalendar::Y_MLableHeight); + m_prevButton->setFixedHeight(DDEYearCalendar::Y_MLableHeight); + + m_nextButton = new DIconButton(DStyle::SP_ArrowRight, this); + //设置对象名称和辅助显示名称 + m_nextButton->setObjectName("NextButton"); + m_nextButton->setAccessibleName("NextButton"); + m_nextButton->setFixedWidth(DDEYearCalendar::Y_MLableHeight); + m_nextButton->setFixedHeight(DDEYearCalendar::Y_MLableHeight); + + m_YearLabel = new QLabel(this); + m_YearLabel->setFixedHeight(DDEYearCalendar::Y_YLableHeight); + + QFont t_labelF; + t_labelF.setWeight(QFont::Medium); + t_labelF.setPixelSize(DDECalendar::FontSizeTwentyfour); + m_YearLabel->setFont(t_labelF); + DPalette pa = m_YearLabel->palette(); + pa.setColor(DPalette::WindowText, QColor("#3B3B3B")); + m_YearLabel->setPalette(pa); + + m_YearLunarLabel = new QLabel(m_contentBackground); + m_YearLunarLabel->setFixedSize(DDEMonthCalendar::M_YLunatLabelWindth, DDEMonthCalendar::M_YLunatLabelHeight); + + QFont ylabelF; + ylabelF.setWeight(QFont::Medium); + ylabelF.setPixelSize(DDECalendar::FontSizeFourteen); + m_YearLunarLabel->setFont(ylabelF); + DPalette Lunapa = m_YearLunarLabel->palette(); + Lunapa.setColor(DPalette::WindowText, QColor("#8A8A8A")); + m_YearLunarLabel->setPalette(Lunapa); + + m_YearLunarDayLabel = new QLabel(m_contentBackground); + m_YearLunarDayLabel->setFixedSize(108, DDEMonthCalendar::M_YLunatLabelHeight); + m_YearLunarDayLabel->setFont(ylabelF); + m_YearLunarDayLabel->setPalette(Lunapa); + m_YearLunarDayLabel->setAlignment(Qt::AlignRight); + + QHBoxLayout *yeartitleLayout = new QHBoxLayout; + yeartitleLayout->setMargin(0); + yeartitleLayout->setSpacing(0); + yeartitleLayout->setContentsMargins(11, 12, 8, 10); + yeartitleLayout->addWidget(m_YearLabel); + + QHBoxLayout *yeartitleLayout1 = new QHBoxLayout; + yeartitleLayout1->setMargin(0); + yeartitleLayout1->setSpacing(0); + yeartitleLayout1->setContentsMargins(4, 9, 0, 7); + yeartitleLayout1->addWidget(m_YearLunarLabel); + yeartitleLayout1->addSpacing(390); + yeartitleLayout1->addStretch(); + yeartitleLayout1->addWidget(m_YearLunarDayLabel, 0, Qt::AlignVCenter); + + m_todayframe = new CustomFrame(this); + m_todayframe->setContentsMargins(0, 0, 0, 0); + m_todayframe->setRoundState(true, true, true, true); + m_todayframe->setBColor(Qt::white); + m_todayframe->setFixedHeight(DDEYearCalendar::Y_MLableHeight); + m_todayframe->setboreder(1); + QHBoxLayout *todaylayout = new QHBoxLayout; + todaylayout->setMargin(0); + todaylayout->setSpacing(0); + todaylayout->addWidget(m_prevButton); + todaylayout->addWidget(m_today, 0, Qt::AlignCenter); + todaylayout->addWidget(m_nextButton); + m_todayframe->setLayout(todaylayout); + yeartitleLayout1->addSpacing(10); + yeartitleLayout1->addWidget(m_todayframe); + yeartitleLayout->addLayout(yeartitleLayout1); + + m_topWidget = new DWidget(this); + m_topWidget->setLayout(yeartitleLayout); + + YearWidget_First = new YearFrame(); + YearWidget_Second = new YearFrame(); + + m_StackedWidget = new AnimationStackedWidget(AnimationStackedWidget::TB); + m_StackedWidget->addWidget(YearWidget_First); + m_StackedWidget->addWidget(YearWidget_Second); + m_StackedWidget->setContentsMargins(0, 0, 0, 0); + m_StackedWidget->setDuration(600); + + m_YearWidget = qobject_cast(m_StackedWidget->widget(0)); + QVBoxLayout *hhLayout = new QVBoxLayout; + hhLayout->setMargin(0); + hhLayout->setSpacing(0); + hhLayout->setContentsMargins(0, 0, 0, 0); + hhLayout->addWidget(m_StackedWidget); + + m_tmainLayout = new QHBoxLayout; + m_tmainLayout->setMargin(0); + m_tmainLayout->setSpacing(0); + m_tmainLayout->setContentsMargins(10, 0, 10, 0); + m_tmainLayout->addLayout(hhLayout); + + m_contentBackground->setContentsMargins(0, 0, 0, 0); + m_contentBackground->setLayout(m_tmainLayout); + + setCentralWidget(m_contentBackground); +} + +void CYearWindow::initConnection() +{ + connect(m_prevButton, &DIconButton::clicked, this, &CYearWindow::slotprev); + connect(m_nextButton, &DIconButton::clicked, this, &CYearWindow::slotnext); + connect(YearWidget_First, + &YearFrame::signaldoubleclickDate, + this, + &CYearWindow::signaldoubleclickDate); + connect(YearWidget_Second, + &YearFrame::signaldoubleclickDate, + this, + &CYearWindow::signaldoubleclickDate); + + connect(YearWidget_First, + &YearFrame::signalselectMonth, + this, + &CYearWindow::signalselectMonth); + + connect(YearWidget_Second, + &YearFrame::signalselectMonth, + this, + &CYearWindow::signalselectMonth); + connect(YearWidget_First, + &YearFrame::signalselectWeekwindow, + this, + &CYearWindow::signalselectWeekwindow); + + connect(YearWidget_Second, + &YearFrame::signalselectWeekwindow, + this, + &CYearWindow::signalselectWeekwindow); + + connect(YearWidget_First, + &YearFrame::signalUpdateYearDate, + this, + &CYearWindow::slotUpdateCurrentDate); + connect(YearWidget_Second, + &YearFrame::signalUpdateYearDate, + this, + &CYearWindow::slotUpdateCurrentDate); + connect(YearWidget_First, + &YearFrame::signalupdateschcedule, + this, + &CYearWindow::signalupdateschcedule); + + connect(m_StackedWidget, + &AnimationStackedWidget::signalIsFinished, + this, + &CYearWindow::setYearData); +} + +void CYearWindow::setLunarVisible(bool state) +{ + m_YearLunarLabel->setVisible(state); + m_YearLunarDayLabel->setVisible(state); +} + +void CYearWindow::setTheMe(int type) +{ + if (type == 0 || type == 1) { + DPalette anipa = m_contentBackground->palette(); + anipa.setColor(DPalette::Background, "#F8F8F8"); + m_contentBackground->setPalette(anipa); + m_contentBackground->setBackgroundRole(DPalette::Background); + + DPalette todaypa = m_today->palette(); + todaypa.setColor(DPalette::WindowText, QColor("#000000")); + todaypa.setColor(DPalette::Background, Qt::white); + m_today->setPalette(todaypa); + m_today->setForegroundRole(DPalette::WindowText); + m_today->setBackgroundRole(DPalette::Background); + + m_todayframe->setBColor(Qt::white); + + DPalette pa = m_YearLabel->palette(); + pa.setColor(DPalette::WindowText, QColor("#3B3B3B")); + m_YearLabel->setPalette(pa); + m_YearLabel->setForegroundRole(DPalette::WindowText); + + DPalette Lunapa = m_YearLunarLabel->palette(); + Lunapa.setColor(DPalette::WindowText, QColor("#8A8A8A")); + m_YearLunarLabel->setPalette(Lunapa); + m_YearLunarLabel->setForegroundRole(DPalette::WindowText); + + m_YearLunarDayLabel->setPalette(Lunapa); + m_YearLunarDayLabel->setForegroundRole(DPalette::WindowText); + } else if (type == 2) { + DPalette anipa = m_contentBackground->palette(); + anipa.setColor(DPalette::Background, "#252525"); + m_contentBackground->setPalette(anipa); + m_contentBackground->setBackgroundRole(DPalette::Background); + + DPalette todaypa = m_today->palette(); + todaypa.setColor(DPalette::WindowText, QColor("#C0C6D4")); + QColor tbcolor = "#414141"; + tbcolor.setAlphaF(0.0); + todaypa.setColor(DPalette::Background, tbcolor); + m_today->setPalette(todaypa); + m_today->setForegroundRole(DPalette::WindowText); + m_today->setBackgroundRole(DPalette::Background); + QColor tbcolor2 = "#414141"; + tbcolor2.setAlphaF(0.3); + m_todayframe->setBColor(tbcolor2); + DPalette pa = m_YearLabel->palette(); + pa.setColor(DPalette::WindowText, QColor("#C0C6D4")); + m_YearLabel->setPalette(pa); + m_YearLabel->setForegroundRole(DPalette::WindowText); + DPalette Lunapa = m_YearLunarLabel->palette(); + Lunapa.setColor(DPalette::WindowText, QColor("#798BA8")); + m_YearLunarLabel->setPalette(Lunapa); + m_YearLunarLabel->setForegroundRole(DPalette::WindowText); + m_YearLunarDayLabel->setPalette(Lunapa); + m_YearLunarDayLabel->setForegroundRole(DPalette::WindowText); + } + YearWidget_First->setTheMe(type); + YearWidget_Second->setTheMe(type); + + DPalette palette = m_topWidget->palette(); + palette.setBrush(DPalette::WindowText, palette.color(DPalette::Window)); + m_topWidget->setAutoFillBackground(true); + m_topWidget->setPalette(palette); +} +void CYearWindow::setSearchWFlag(bool flag) +{ + m_searchfalg = flag; + m_YearWidget->setSearchWFlag(flag); +} + +void CYearWindow::clearSearch() +{ +} + +void CYearWindow::getScheduleInfo() +{ + m_YearWidget->getInfoAndSetLineFlag(); +} + +void CYearWindow::slotTransitSearchSchedule(int id) +{ + emit signalsWUpdateShcedule(this, id); +} + +void CYearWindow::slotSetSchceduleHide() +{ + m_YearWidget->slotHideInfo(); +} + +void CYearWindow::slotprev() +{ + m_YearWidget->slotHideInfo(); + + if (m_currentdate.year() == DDECalendar::QueryEarliestYear) + return; + + if (m_StackedWidget->IsRunning()) return; + + QDate tcurrent = QDate(m_currentdate.year() - 1, m_currentdate.month(), m_currentdate.day()); + + if (!tcurrent.isValid()) { + m_currentdate = QDate(m_currentdate.year() - 1, m_currentdate.month(), 1); + } else { + m_currentdate = tcurrent; + } + if (m_currentdate.year() >= DDECalendar::QueryEarliestYear) { + int index = m_StackedWidget->currentIndex(); + index = qAbs(index - 1) % 2; + m_YearWidget = qobject_cast(m_StackedWidget->widget(index)); + m_YearWidget->setDate(m_currentdate); + m_StackedWidget->setPre(); + emit signalCurrentDate(m_currentdate); + } else { + } +} + +void CYearWindow::slotnext() +{ + m_YearWidget->slotHideInfo(); + + if (m_StackedWidget->IsRunning()) return; + QDate tcurrent = QDate(m_currentdate.year() + 1, m_currentdate.month(), m_currentdate.day()); + + if (!tcurrent.isValid()) { + m_currentdate = QDate(m_currentdate.year() + 1, m_currentdate.month(), 1); + } else { + m_currentdate = tcurrent; + } + int index = m_StackedWidget->currentIndex(); + index = (index + 1) % 2; + m_YearWidget = qobject_cast(m_StackedWidget->widget(index)); + m_YearWidget->setDate(m_currentdate); + m_StackedWidget->setNext(); + emit signalCurrentDate(m_currentdate); +} + +void CYearWindow::slottoday() +{ + m_YearWidget->slotHideInfo(); + emit signalsReturnTodayUpdate(this); + setDate(QDate::currentDate()); +} + +void CYearWindow::slotReturnTodayUpdate() +{ +} + +void CYearWindow::slotupdateSchedule(const int id) +{ + m_YearWidget->slotupdateSchedule(id); +} + +void CYearWindow::slotUpdateCurrentDate(const QDate &date) +{ + m_currentdate = date; + setYearData(); +} + +void CYearWindow::setYearData() +{ + if (m_currentdate == QDate::currentDate()) { + m_today->setText(QCoreApplication::translate("today", "Today", "Today")); + } else { + m_today->setText(QCoreApplication::translate("Return", "Today", "Return")); + } + QLocale locale; + + if (locale.language() == QLocale::Chinese) { + m_YearLabel->setText(QString::number(m_currentdate.year()) + tr("Y")); + } else { + m_YearLabel->setText(QString::number(m_currentdate.year())); + } + m_YearLunarLabel->setText(m_YearWidget->getLunarYear()); + m_YearLunarDayLabel->setText(m_YearWidget->getLunarDay()); +} +void CYearWindow::slotsearchDateSelect(QDate date) +{ + setDate(date); +} + +void CYearWindow::wheelEvent(QWheelEvent *event) +{ + if (event->delta() < 0) { + slotnext(); + } else { + slotprev(); + } +} + +YearFrame::YearFrame(DWidget *parent) + : DFrame(parent) +{ + m_DBusInter = new CalendarDBus("com.deepin.api.LunarCalendar", + "/com/deepin/api/LunarCalendar", + QDBusConnection::sessionBus(), this); + QGridLayout *gridLayout = new QGridLayout; + gridLayout->setMargin(0); + gridLayout->setSpacing(8); + gridLayout->setContentsMargins(0, 0, 0, 0); + + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 4; j++) { + CYearView *view = new CYearView(this); + connect(view, &CYearView::signalcurrentDateChanged, this, &YearFrame::slotcurrentDateChanged); + connect(view, &CYearView::signaldoubleclickDate, this, &YearFrame::signaldoubleclickDate); + connect(view, &CYearView::signalselectWeekwindow, this, &YearFrame::signalselectWeekwindow); + connect(view, &CYearView::signalupdateschcedule, this, &YearFrame::signalupdateschcedule); + connect(view, &CYearView::signalselectMonth, this, &YearFrame::signalselectMonth); + connect(view, &CYearView::signalHideInfo, this, &YearFrame::slotHideInfo); + connect(view, &CYearView::signalSelectInfo, this, &YearFrame::slotSelectInfo); + gridLayout->addWidget(view, i, j); + m_monthViewList.append(view); + } + } + + m_YearLabel = new QLabel(this); + m_YearLabel->setFixedHeight(DDEYearCalendar::Y_YLableHeight); + + QFont t_labelF; + t_labelF.setWeight(QFont::Medium); + t_labelF.setPixelSize(DDECalendar::FontSizeTwentyfour); + m_YearLabel->setFont(t_labelF); + DPalette pa = m_YearLabel->palette(); + pa.setColor(DPalette::WindowText, QColor("#3B3B3B")); + m_YearLabel->setPalette(pa); + + m_YearLunarLabel = new QLabel(); + m_YearLunarLabel->setFixedSize(DDEMonthCalendar::M_YLunatLabelWindth, DDEMonthCalendar::M_YLunatLabelHeight); + + QFont ylabelF; + ylabelF.setWeight(QFont::Medium); + ylabelF.setPixelSize(DDECalendar::FontSizeFourteen); + m_YearLunarLabel->setFont(ylabelF); + DPalette Lunapa = m_YearLunarLabel->palette(); + Lunapa.setColor(DPalette::WindowText, QColor("#8A8A8A")); + m_YearLunarLabel->setPalette(Lunapa); + + QHBoxLayout *yeartitleLayout = new QHBoxLayout; + yeartitleLayout->setMargin(0); + yeartitleLayout->setSpacing(0); + yeartitleLayout->setContentsMargins(11, 12, 8, 10); + yeartitleLayout->addWidget(m_YearLabel); + + QHBoxLayout *yeartitleLayout1 = new QHBoxLayout; + yeartitleLayout1->setMargin(0); + yeartitleLayout1->setSpacing(0); + yeartitleLayout1->setContentsMargins(4, 9, 0, 7); + yeartitleLayout1->addWidget(m_YearLunarLabel); + yeartitleLayout1->addSpacing(390); + yeartitleLayout1->addStretch(); + yeartitleLayout1->addSpacing(10); + yeartitleLayout->addLayout(yeartitleLayout1); + + m_topWidget = new DWidget(); + m_topWidget->setLayout(yeartitleLayout); + m_topWidget->setFixedHeight(DDEMonthCalendar::M_YTopHeight); + QVBoxLayout *hhLayout = new QVBoxLayout; + hhLayout->setMargin(0); + hhLayout->setSpacing(0); + hhLayout->setContentsMargins(0, 0, 0, 0); + hhLayout->addWidget(m_topWidget); + hhLayout->addLayout(gridLayout); + this->setLayout(hhLayout); + setContentsMargins(0, 0, 0, 10); + setFrameRounded(true); +} + +YearFrame::~YearFrame() +{ + +} + +void YearFrame::setDate(QDate &date) +{ + if (!date.isValid()) return; + m_currentdate = date; + + for (int i = 0; i < DDEYearCalendar::FrameSizeofEveryYear; i++) { + QDate tdate(m_currentdate.year(), i + 1, 1); + m_monthViewList.at(i)->setCurrentDate(tdate, 0); + } + for (int i = 0; i < DDEYearCalendar::FrameSizeofEveryYear; i++) { + QDate tdate(m_currentdate.year(), i + 1, 1); + if (date.year() == tdate.year() && date.month() == tdate.month()) { + m_monthViewList.at(i)->setCurrentDate(date, 1); + break; + } + } + getLunarData(); +} + +void YearFrame::getInfoAndSetLineFlag() +{ + for (int i = 0; i < DDEYearCalendar::FrameSizeofEveryYear; i++) { + m_monthViewList.at(i)->getInfoAndSetLineFlag(); + } +} + +void YearFrame::setTheMe(int type) +{ + if (type == 0 || type == 1) { + DPalette gpa = palette(); + gpa.setColor(DPalette::Background, "#F8F8F8"); + setPalette(gpa); + setBackgroundRole(DPalette::Background); + + DPalette pa = m_YearLabel->palette(); + pa.setColor(DPalette::WindowText, QColor("#3B3B3B")); + m_YearLabel->setPalette(pa); + m_YearLabel->setForegroundRole(DPalette::WindowText); + + DPalette Lunapa = m_YearLunarLabel->palette(); + Lunapa.setColor(DPalette::WindowText, QColor("#8A8A8A")); + m_YearLunarLabel->setPalette(Lunapa); + m_YearLunarLabel->setForegroundRole(DPalette::WindowText); + } else if (type == 2) { + DPalette gpa = palette(); + gpa.setColor(DPalette::Background, "#252525"); + setPalette(gpa); + setBackgroundRole(DPalette::Background); + + DPalette pa = m_YearLabel->palette(); + pa.setColor(DPalette::WindowText, QColor("#C0C6D4")); + m_YearLabel->setPalette(pa); + m_YearLabel->setForegroundRole(DPalette::WindowText); + DPalette Lunapa = m_YearLunarLabel->palette(); + Lunapa.setColor(DPalette::WindowText, QColor("#798BA8")); + m_YearLunarLabel->setPalette(Lunapa); + m_YearLunarLabel->setForegroundRole(DPalette::WindowText); + } + + for (int i = 0; i < DDEYearCalendar::FrameSizeofEveryYear; i++) { + m_monthViewList.at(i)->setTheMe(type); + } +} + +void YearFrame::setSearchWFlag(bool flag) +{ + m_searchfalg = flag; +} + +void YearFrame::getLunarData() +{ + bool o1 = true; + QDBusReply replydd = m_DBusInter->GetLunarInfoBySolar(m_currentdate.year(), m_currentdate.month(), m_currentdate.day(), o1); + CaLunarDayInfo currentDayInfo = replydd.value(); + m_LunarYear = QString("-%0%1年-").arg(currentDayInfo.mGanZhiYear).arg(currentDayInfo.mZodiac); + m_LunarDay = QString("-农历%0%1-").arg(currentDayInfo.mLunarMonthName).arg(currentDayInfo.mLunarDayName); + QLocale locale; + + if (locale.language() == QLocale::Chinese) { + m_YearLabel->setText(QString::number(m_currentdate.year()) + tr("Y")); + m_YearLunarLabel->setText(m_LunarYear); + } else { + m_YearLabel->setText(QString::number(m_currentdate.year())); + m_YearLunarLabel->setText(""); + } + +} + +void YearFrame::mousePressEvent(QMouseEvent *event) +{ + if (m_selectFlag) return; + if (event->button() == Qt::LeftButton) { + slotHideInfo(); + } +} + +void YearFrame::slotcurrentDateChanged(QDate date) +{ + m_currentdate = date; + getLunarData(); + emit signalUpdateYearDate(date); +} + +void YearFrame::slotHideInfo() +{ + CYearView::SchceduleViewHide(); +} + +void YearFrame::slotSelectInfo(bool flag) +{ + m_selectFlag = flag; +} + +void YearFrame::slotupdateSchedule(const int id) +{ + for (int i =0; i < m_monthViewList.size(); ++i) { + m_monthViewList.at(i)->slotupdateSchedule(id); + } +} + +void YearFrame::slotSetSchceduleHide() +{ + CYearView::SchceduleViewHide(); +} diff -Nru dde-calendar-5.7.0.4/src/widget/yearWidget/yearwindow.h dde-calendar-5.7.0.23/src/widget/yearWidget/yearwindow.h --- dde-calendar-5.7.0.4/src/widget/yearWidget/yearwindow.h 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/src/widget/yearWidget/yearwindow.h 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,337 @@ +/* + * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. + * + * Author: kirigaya + * + * 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 + * 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 . + */ +#ifndef YEARWINDOW_H +#define YEARWINDOW_H + +#include "animationstackedwidget.h" +#include "calendardbus.h" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +DWIDGET_USE_NAMESPACE + +class CYearView; +class CaLunarDayInfo; +class CSchceduleSearchView; +class YearFrame; +class CustomFrame; +class CYearWindow: public QMainWindow +{ + Q_OBJECT +public: + explicit CYearWindow(QWidget *parent = nullptr); + ~CYearWindow() override; + /** + * @brief setDate 设置年视图当前显示的时间 + * @param date 年视图当前显示的时间 + */ + void setDate(QDate date); + /** + * @brief initUI 初始化年视图的界面显示 + */ + void initUI(); + /** + * @brief initConnection 初始化信号和槽的连接 + */ + void initConnection(); + /** + * @brief setLunarVisible 设置年视图是否显示阴历信息 + * @param state 是否显示阴历信息 + */ + void setLunarVisible(bool state); + /** + * @brief setTheMe 设置系统主题 + * @param type 主题类型 + */ + void setTheMe(int type = 0); + /** + * @brief setSearchWFlag 设置是否在进行搜索 + * @param flag 是否所搜的标志 + */ + void setSearchWFlag(bool flag); + /** + * @brief clearSearch + */ + void clearSearch(); + /** + * @brief getScheduleInfo 判断一年中每一天是否有日程信息 + */ + void getScheduleInfo(); +signals: + /** + * @brief dateSelected + * @param date + * @param detail + */ + void dateSelected(const QDate date, const CaLunarDayInfo &detail) const; + /** + * @brief signalsReturnTodayUpdate 点击返回今天按钮发出信号 + * @param w 年视图窗口 + */ + void signalsReturnTodayUpdate(QMainWindow *w); + /** + * @brief signalsWUpdateShcedule + * @param w + * @param id + */ + void signalsWUpdateShcedule(QMainWindow *w, int id = 0); + /** + * @brief signaldoubleclickDate 双击鼠标发出信号 + * @param date 双击的日期 + */ + void signaldoubleclickDate(QDate date); + /** + * @brief signalselectMonth 鼠标选择的日期信号 + * @param date 选择的日期 + */ + void signalselectMonth(QDate date); + /** + * @brief signalselectWeekwindow 选择周视图的信号 + * @param date 选择的日期 + */ + void signalselectWeekwindow(QDate date); + /** + * @brief signalCurrentDate 设置当前时间的信号 + * @param date 当前时间 + */ + void signalCurrentDate(QDate date); + /** + * @brief signalupdateschcedule 更新日程的信号 + */ + void signalupdateschcedule(); +private slots: + /** + * @brief slotprev 通过鼠标点击左箭头切换到上一年,刷新年视图下的所有内容,并隐藏日程展示浮窗。 + */ + void slotprev(); + /** + * @brief slotnext 通过鼠标点击右箭头切换到下一年,并刷新年视图下的所有内容,并隐藏日程展示浮窗。 + */ + void slotnext(); + /** + * @brief slottoday 通过鼠标点击返回今天按钮返回到今天,并刷新年视图下的所有内容,并隐藏日程展示浮窗。 + */ + void slottoday(); + /** + * @brief slotsearchDateSelect 设置选择的时间 + * @param date 时间 + */ + void slotsearchDateSelect(QDate date); + /** + * @brief slotTransitSearchSchedule + * @param id + */ + void slotTransitSearchSchedule(int id = 0); +public slots: + /** + * @brief slotSetSchceduleHide 隐藏日程浮框 + */ + void slotSetSchceduleHide(); + /** + * @brief slotReturnTodayUpdate + */ + void slotReturnTodayUpdate(); + /** + * @brief slotupdateSchedule 更新当前时间 + * @param id + */ + void slotupdateSchedule(const int id); + /** + * @brief setYearData 设置年视图阴历和按钮信息 + */ + void setYearData(); + /** + * @brief slotUpdateCurrentDate 设置年视图当前时间的信息 + * @param date 时间 + */ + void slotUpdateCurrentDate(const QDate &date); +protected: + /** + * @brief wheelEvent 通过鼠标中间的滚轮滚动切换年份,并刷新年视图下的所有内容。 + * @param event 鼠标滚轮事件 + */ + void wheelEvent(QWheelEvent *event) override; + /** + * @brief eventFilter 过滤器,过滤返回今天的按钮事件 + * @param watched 事件对象 + * @param event 事件类型 + * @return false + */ + bool eventFilter(QObject *watched, QEvent *event) override; + /** + * @brief mousePressEvent 鼠标单击事件,单击日期区域外,隐藏日程浮框 + * @param event 鼠标事件 + */ + void mousePressEvent(QMouseEvent *event) override; + /** + * @brief resizeEvent 窗口大小调整事件,搜索时,调整边框大小 + * @param event 窗口大小调整事件 + */ + void resizeEvent(QResizeEvent *event) override; +private: + DFrame *m_contentBackground = nullptr; + DIconButton *m_prevButton = nullptr; + DIconButton *m_nextButton = nullptr; + QLabel *m_today = nullptr; + QDate m_currentdate; + QLabel *m_YearLabel = nullptr; + QLabel *m_YearLunarLabel = nullptr; + QLabel *m_YearLunarDayLabel = nullptr; + YearFrame *m_YearWidget = nullptr; + YearFrame *YearWidget_First = nullptr; + YearFrame *YearWidget_Second = nullptr; + CustomFrame *m_todayframe = nullptr; + AnimationStackedWidget *m_StackedWidget = nullptr; + QHBoxLayout *m_tmainLayout = nullptr; + QString m_searchText; + bool m_searchfalg = false; + DWidget *m_topWidget = nullptr; +}; + +class YearFrame : public DFrame +{ + Q_OBJECT +public: + /** + * @brief YearFrame 构造函数 + * @param parent 父类 + */ + explicit YearFrame(DWidget *parent = nullptr); + /** + *@brief ~YearFrame 析构函数 + */ + ~YearFrame() override; + /** + * @brief setDate 设置当前时间 + * @param date 时间 + */ + void setDate(QDate &date); + /** + * @brief getInfoAndSetLineFlag 获取日程信息,设置是否有日程的标志 + */ + void getInfoAndSetLineFlag(); + /** + * @brief setTheMe 根据系统主题类型设置颜色 + * @param type 系统主题类型 + */ + void setTheMe(int type = 0); + /** + * @brief setSearchWFlag 设置搜索的标志 + * @param flag 是否进行了搜索 + */ + void setSearchWFlag(bool flag); + /** + * @brief getLunarYear 获取阴历年信息 + * @return 阴历年信息字符串 + */ + QString getLunarYear()const + { + return m_LunarYear; + } + /** + * @brief getLunarDay 获取阴历日信息 + * @return 阴历日信息字符串 + */ + QString getLunarDay()const + { + return m_LunarDay; + } + /** + * @brief getLunarData 更新当天的农历年份数据。 + */ + void getLunarData(); +protected: + /** + * @brief mousePressEvent 鼠标单击日期区域外隐藏日程浮框 + * @param event 鼠标单击事件 + */ + void mousePressEvent(QMouseEvent *event) override; +signals: + /** + * @brief signaldoubleclickDate 鼠标双击的信号 + * @param date 传递日期参数 + */ + void signaldoubleclickDate(QDate date); + /** + * @brief signalselectWeekwindow 选择周视图的信号 + * @param date 传递日期参数 + */ + void signalselectWeekwindow(QDate date); + /** + * @brief signalselectMonth 选择月视图的信号 + * @param date 传递日期参数 + */ + void signalselectMonth(QDate date); + /** + * @brief signalUpdateYearDate 更新年视图的信号 + * @param date 传递日期参数 + */ + void signalUpdateYearDate(const QDate &date); + /** + * @brief signalupdateschcedule 更新日程的信号 + */ + void signalupdateschcedule(); +public slots: + /** + * @brief slotHideInfo 隐藏日程浮框 + */ + void slotHideInfo(); + /** + * @brief slotSelectInfo 设置是否选择了日期的标志 + * @param flag 是否选择了如期 + */ + void slotSelectInfo(bool flag); + /** + * @brief slotupdateSchedule 更新日程 + * @param id + */ + void slotupdateSchedule(const int id); + /** + * @brief slotSetSchceduleHide 隐藏日程浮框 + */ + void slotSetSchceduleHide(); + /** + * @brief slotcurrentDateChanged 设置当前时间 + * @param date 时间 + */ + void slotcurrentDateChanged(QDate date); +private: + QList m_monthViewList; + QLabel *m_YearLabel = nullptr; + QLabel *m_YearLunarLabel = nullptr; + CalendarDBus *m_DBusInter = nullptr; + QDate m_currentdate; + bool m_searchfalg = false; + bool m_selectFlag = false; + QString m_LunarYear; + QString m_LunarDay; + DWidget *m_topWidget = nullptr; +}; + +#endif // YEARWINDOW_H diff -Nru dde-calendar-5.7.0.4/src/yearschceduleview.cpp dde-calendar-5.7.0.23/src/yearschceduleview.cpp --- dde-calendar-5.7.0.4/src/yearschceduleview.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/yearschceduleview.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,1026 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#include "yearschceduleview.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "schceduledlg.h" -#include "scheduledatamanage.h" -#include -#include -#include -#include -#include "schcedulectrldlg.h" -#include "myschceduleview.h" -DGUI_USE_NAMESPACE - -const int fontsize = 12; -const QString fontfamily = QStringLiteral("SourceHanSansSC-Medium"); - -CYearSchceduleItem::CYearSchceduleItem( QWidget *parent /*= nullptr*/ ): DLabel(parent) -{ - -} - -void CYearSchceduleItem::setBackgroundColor(QColor color1) -{ - m_Backgroundcolor = color1; -} - -void CYearSchceduleItem::setStateColor(QColor color1) -{ - m_Statecolor = color1; -} - -void CYearSchceduleItem::setText( QColor tcolor, QFont font) -{ - m_ttextcolor = tcolor; - m_tfont = font; -} - -void CYearSchceduleItem::setTimeC(QColor tcolor, QFont font) -{ - m_timecolor = tcolor; - m_timefont = font; -} - -void CYearSchceduleItem::setData( ScheduleDtailInfo vScheduleInfo) -{ - m_ScheduleInfo = vScheduleInfo; - //setToolTip(m_ScheduleInfo.titleName); - update(); -} - -void CYearSchceduleItem::paintEvent( QPaintEvent *e ) -{ - Q_UNUSED(e); - int labelwidth = width(); - int labelheight = height(); - - QPainter painter(this); - QRect fillRect = QRect(0, 0, labelwidth, labelheight); - painter.setRenderHints(QPainter::HighQualityAntialiasing); - QColor bcolor = m_Backgroundcolor; - painter.save(); - painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; - painter.setBrush(QBrush(bcolor)); - painter.setPen(Qt::NoPen); - painter.drawRect(fillRect); - painter.restore(); - //圆点 - painter.save(); - painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; - painter.setBrush(QBrush(m_Statecolor)); - painter.setPen(Qt::NoPen); - painter.drawEllipse(QRect(10, (labelheight - 8) / 2, 8, 8)); - painter.restore(); - - - QString str; - //左边文字 - painter.save(); - painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; - painter.setPen(m_ttextcolor); - painter.setFont(m_tfont); - QFontMetrics fm = painter.fontMetrics(); - QString tStitlename = m_ScheduleInfo.titleName; - tStitlename.replace("\n", ""); - str = tStitlename; - int tilenameW = labelwidth - 90; - QString tstr; - for (int i = 0; i < str.count(); i++) { - tstr.append(str.at(i)); - int widthT = fm.width(tstr) + 5; - if (widthT >= tilenameW) { - tstr.chop(1); - break; - } - } - if (tstr != str) { - tstr = tstr + "..."; - } - - painter.drawText(QRect(28, 0, tilenameW, labelheight - 2), Qt::AlignLeft | Qt::AlignVCenter, tstr); - painter.restore(); - //右边时间 - painter.save(); - painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; - painter.setPen(m_timecolor); - painter.setFont(m_timefont); - QLocale locale; - if (locale.language() == QLocale::Chinese) { - if (m_ScheduleInfo.allday) { - str = tr("All Day"); - } else { - str = m_ScheduleInfo.beginDateTime.time().toString("ap h") + ("时"); - } - } else { - if (m_ScheduleInfo.allday) { - str = tr("All Day"); - } else { - str = m_ScheduleInfo.beginDateTime.time().toString("ap h:mm"); - } - } - QFontMetrics fm2 = painter.fontMetrics(); - painter.drawText(QRect(labelwidth - 60, 0, 50, labelheight - 2), Qt::AlignRight | Qt::AlignVCenter, str); - painter.restore(); -} - -CYearSchceduleView::CYearSchceduleView(QWidget *parent) : DWidget(parent) -{ - setContentsMargins(10, 10, 10, 10); - setWindowFlags(Qt::FramelessWindowHint | Qt::Tool); - /*QVBoxLayout *layout = new QVBoxLayout; - layout->setMargin(0); - layout->setSpacing(0); - m_gradientItemList = new DListWidget(parent); - m_gradientItemList->setAutoFillBackground(true); - // m_gradientItemList->setAlternatingRowColors(true); - //layout->setContentsMargins(10, 10, 10, 10); - layout->addWidget(m_gradientItemList); - //m_gradientItemList->setSpacing(1); - // set default row - m_gradientItemList->setCurrentRow(0); - setLayout(layout); - setMouseTracking(true); - setFocusPolicy(Qt::StrongFocus); - m_bBackgroundcolor.setAlphaF(0.03); - // m_gradientItemList->setLineWidth(0); - m_gradientItemList->setFrameShape(QListWidget::NoFrame); - m_labellist.clear();*/ - setAttribute(Qt::WA_TranslucentBackground); -} - -CYearSchceduleView::~CYearSchceduleView() -{ - -} - -void CYearSchceduleView::setSoloDay(QString soloday) -{ - m_soloDay = soloday; -} - -bool YScheduleDateThan(const ScheduleDtailInfo &s1, const ScheduleDtailInfo &s2) -{ - QDate bdate1 = s1.beginDateTime.date(); - QDate edate1 = s1.endDateTime.date(); - QDate bdate2 = s2.beginDateTime.date(); - QDate edate2 = s2.endDateTime.date(); - if (bdate1 != edate1 && bdate2 == edate2) { - return true; - } else if (bdate1 == edate1 && bdate2 != edate2) { - return false; - } else if (bdate1 != edate1 && bdate2 != edate2) { - return bdate1 < bdate2; - } else { - if (s1.beginDateTime == s2.beginDateTime) { - return s1.titleName < s2.titleName; - } else { - return s1.beginDateTime < s2.beginDateTime; - } - } -} -bool YScheduleDaysThan(const ScheduleDtailInfo &s1, const ScheduleDtailInfo &s2) -{ - return s1.beginDateTime.date().daysTo(s1.endDateTime.date()) > s2.beginDateTime.date().daysTo(s2.endDateTime.date()); -} - -void CYearSchceduleView::setData(QVector &vListData) -{ - QVector valldayListData, vDaylistdata; - for (int i = 0; i < vListData.count(); i++) { - if (vListData.at(i).allday) { - valldayListData.append(vListData.at(i)); - } else { - vDaylistdata.append(vListData.at(i)); - } - } - - std::sort(valldayListData.begin(), valldayListData.end(), YScheduleDaysThan); - std::sort(valldayListData.begin(), valldayListData.end(), YScheduleDateThan); - std::sort(vDaylistdata.begin(), vDaylistdata.end(), YScheduleDaysThan); - std::sort(vDaylistdata.begin(), vDaylistdata.end(), YScheduleDateThan); -// qSort(valldayListData.begin(), valldayListData.end(), YScheduleDaysThan); -// qSort(valldayListData.begin(), valldayListData.end(), YScheduleDateThan); -// qSort(vDaylistdata.begin(), vDaylistdata.end(), YScheduleDaysThan); -// qSort(vDaylistdata.begin(), vDaylistdata.end(), YScheduleDateThan); - - for (int i = 0; i < valldayListData.count(); i++) { - QVector::iterator iter = valldayListData.begin(); - if (valldayListData.at(i).type.ID == 4) { - ScheduleDtailInfo moveDate; - moveDate = valldayListData.at(i); - valldayListData.removeAt(i); - valldayListData.insert(iter, moveDate); - } - } - - - - m_vlistData.clear(); - m_vlistData.append(valldayListData); - m_vlistData.append(vDaylistdata); -// if (!m_soloDay.isEmpty() || !m_vlistData.isEmpty()) { -// if (!m_soloDay.isEmpty()) { -// if (m_vlistData.size() > 4) { -// QVector vTlistData; -// for (int i = 0; i < 3; i++) { -// if (m_vlistData.at(i).beginDateTime.date() != m_vlistData.at(i).endDateTime.date() && !m_vlistData.at(i).allday) { -// if (m_vlistData.at(i).beginDateTime.date() != m_currentDate) { -// m_vlistData[i].allday = true; -// } -// } -// vTlistData.append(m_vlistData.at(i)); -// } -// ScheduleDtailInfo info; -// info.titleName = "......"; -// info.id = -1; -// vTlistData.append(info); -// m_vlistData = vTlistData; -// } -// } else { - if (m_vlistData.size() > 5) { - QVector vTlistData; - for (int i = 0; i < 4; i++) { - if (m_vlistData.at(i).beginDateTime.date() != m_vlistData.at(i).endDateTime.date() && !m_vlistData.at(i).allday) { - if (m_vlistData.at(i).beginDateTime.date() != m_currentDate) { - m_vlistData[i].allday = true; - } - } - vTlistData.append(m_vlistData.at(i)); - } - ScheduleDtailInfo info; - info.titleName = "......"; - info.id = -1; - vTlistData.append(info); - m_vlistData = vTlistData; - } -// } -// } -} - -void CYearSchceduleView::clearData() -{ - m_vlistData.clear(); - m_soloDay.clear(); - return; -} - -int CYearSchceduleView::showWindow() -{ - if (m_soloDay.isEmpty() && m_vlistData.isEmpty()) { - setFixedSize(130, 45); - //m_gradientItemList->setFixedSize(110, 60); - } else { - setFixedSize(240, 180); - //m_gradientItemList->setFixedSize(220, 160); - } - //show(); - updateDateShow(); - return this->width(); -} - -void CYearSchceduleView::setTheMe(int type) -{ - if (type == 0 || type == 1) { - m_bBackgroundcolor = "#FFFFFF"; - m_bBackgroundcolor.setAlphaF(0.0); - m_btimecolor = "#414D68"; - m_btimecolor.setAlphaF(0.7); - m_bttextcolor = "#414D68"; - m_lBackgroundcolor = "#EBEBEB"; - m_lBackgroundcolor.setAlphaF(0.0); - m_ltextcolor = "#001A2E"; - m_solocolor = "#FF7272"; - m_TBcolor = "#EBEBEB"; - // m_TBcolor.setAlphaF(0.7); - m_borderColor = "#000000"; - m_borderColor.setAlphaF(0.05); - - } else if (type == 2) { - m_bBackgroundcolor = "#FFFFFF"; - m_bBackgroundcolor.setAlphaF(0.0); - m_btimecolor = "#C0C6D4"; - m_btimecolor.setAlphaF(0.7); - m_bttextcolor = "#C0C6D4"; - m_lBackgroundcolor = "#191919"; - m_lBackgroundcolor.setAlphaF(0.00); - m_ltextcolor = "#C0C6D4"; - m_solocolor = "#FF7272"; - m_solocolor.setAlphaF(0.8); - m_TBcolor = "#191919"; - m_borderColor = "#FFFFFF"; - m_borderColor.setAlphaF(0.05); - } - // DPalette bpa = m_gradientItemList->palette(); - // bpa.setColor(DPalette::Base, m_TBcolor); - // m_gradientItemList->setPalette(bpa); -} - -void CYearSchceduleView::setDtype(int type, int arrowheight) -{ - m_dtype = type; - m_arrowheight = arrowheight; - update(); -} - -void CYearSchceduleView::setCurrentDate(QDate cdate) -{ - m_currentDate = cdate; -} - -QDate CYearSchceduleView::getCurrentDate() -{ - return m_currentDate; -} - -void CYearSchceduleView::adjustPosition(bool ad) -{ - adjustPos = ad; -} - -void CYearSchceduleView::updateDateShow() -{ - int sviewNum = 0; - if (!m_soloDay.isEmpty() || !m_vlistData.isEmpty()) { - if (!m_soloDay.isEmpty()) { - if (m_vlistData.size() > 4) { - sviewNum = 5; - } else { - sviewNum = m_vlistData.size() + 1; - } - } else { - if (m_vlistData.size() > 5) { - sviewNum = 5; - } else { - sviewNum = m_vlistData.size(); - } - } - } - if (!m_soloDay.isEmpty() || !m_vlistData.isEmpty()) - setFixedSize(240, 45 + (sviewNum - 1) * 29); - update(); - return; - //remove -// for (int i = 0; i < m_gradientItemList->count(); i++) { -// QListWidgetItem *item11 = m_gradientItemList->takeItem(i); -// m_gradientItemList->removeItemWidget(item11); -// } -// m_gradientItemList->clear(); -// m_labellist.clear(); - -//// if (!m_soloDay.isEmpty()) { -//// ScheduleDtailInfo info; -//// info.titleName = m_soloDay; -//// info.allday = true; -//// createItemWidget(info, 1); -//// } -// sviewNum = 0; -//// if (!m_soloDay.isEmpty()) { -//// if (m_vlistData.size() > 5) { -//// sviewNum = 5; -//// setFixedSize(240, 180); -//// } else { -//// sviewNum = m_vlistData.size(); -//// setFixedSize(95 + (sviewNum + 1) * 29, 180); -//// } -//// } else { -// if (m_vlistData.size() > 6) { -// sviewNum = 6; -// setFixedSize(240, 180); -// } else { -// sviewNum = m_vlistData.size(); -// setFixedSize(95 + sviewNum * 29, 180); -// } -//// } - -// for (int i = 0; i < sviewNum; ++i) { -// createItemWidget(m_vlistData.at(i), 0); -// } - -// if (m_gradientItemList->count() == 0) { -// QListWidgetItem *listItem = new QListWidgetItem; -// DLabel *gwi = new DLabel(); -// QFont font("SourceHanSansSC-Normal"); -// font.setPixelSize(12); -// gwi->setAlignment(Qt::AlignCenter | Qt::AlignVCenter); -// DPalette daypa = gwi->palette(); -// daypa.setColor(DPalette::WindowText, m_bttextcolor); -// daypa.setColor(DPalette::Window, m_lBackgroundcolor); -// gwi->setPalette(daypa); -// gwi->setForegroundRole(DPalette::WindowText); -// gwi->setBackgroundRole(DPalette::Window); -// gwi->setFont(font); -// gwi->setText(tr("No event")); -// gwi->setFixedSize(m_gradientItemList->width(), 48); -// listItem->setSizeHint(QSize(m_gradientItemList->width(), 49)); //每次改变Item的高度 -// //listItem->setBackgroundColor(Qt::white); -// listItem->setFlags(Qt::ItemIsTristate ); -// m_gradientItemList->addItem(listItem); -// m_gradientItemList->setItemWidget(listItem, gwi); -// m_labellist.append(gwi); -// } -} - -void CYearSchceduleView::createItemWidget(ScheduleDtailInfo info, int type) -{ - ScheduleDtailInfo &gd = info; - CSchedulesColor gdcolor = CScheduleDataManage::getScheduleDataManage()->getScheduleColorByType(gd.type.ID); - - CYearSchceduleItem *gwi = new CYearSchceduleItem(); - QFont font/*("SourceHanSansSC")*/; - font.setWeight(QFont::Medium); - font.setPixelSize(14); - gwi->setBackgroundColor(m_bBackgroundcolor); - //gwi->setBackgroundColor(Qt::white); - QColor scolor = gdcolor.Purecolor; - scolor.setAlphaF(1.0); - if (type == 0) - gwi->setStateColor(gdcolor.splitColor); - else { - gwi->setStateColor(m_solocolor); - } - gwi->setText(m_bttextcolor, font); - font.setPixelSize(12); - gwi->setTimeC(m_btimecolor, font); - gwi->setFixedSize(m_gradientItemList->width() - 3, 28); - gwi->setData(gd); - - QListWidgetItem *listItem = new QListWidgetItem; - listItem->setSizeHint(QSize(m_gradientItemList->width() - 2, 29)); //每次改变Item的高度 - //listItem->setBackgroundColor(Qt::white); - listItem->setFlags(Qt::ItemIsTristate ); - m_gradientItemList->addItem(listItem); - m_gradientItemList->setItemWidget(listItem, gwi); - m_labellist.append(gwi); -} - -void CYearSchceduleView::paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event); -#if 0 - QPainter painter(this); - painter.setRenderHints(QPainter::Antialia if (!m_soloDay.isEmpty()) { - ScheduleDtailInfo info; - info.titleName = m_soloDay; - info.allday = true; - createItemWidget(info, 1); - } - int sviewNum = 0; - if (!m_soloDay.isEmpty()) { - if (m_vlistData.size() > 5) { - sviewNum = 5; - } else { - sviewNum = m_vlistData.size(); - } - } else { - if (m_vlistData.size() > 6) { - sviewNum = 6; - } else { - sviewNum = m_vlistData.size(); - } - } - - for (int i = 0; i < sviewNum; ++i) { - createItemWidget(m_vlistData.at(i), 0); - } - - if (m_gradientItemList->count() == 0) { - QListWidgetItem *listItem = new QListWidgetItem; - DLabel *gwi = new DLabel(); - QFont font("SourceHanSansSC-Normal"); - font.setPixelSize(12); - gwi->setAlignment(Qt::AlignCenter | Qt::AlignVCenter); - DPalette daypa = gwi->palette(); - daypa.setColor(DPalette::WindowText, m_bttextcolor); - daypa.setColor(DPalette::Window, m_lBackgroundcolor); - gwi->setPalette(daypa); - gwi->setForegroundRole(DPalette::WindowText); - gwi->setBackgroundRole(DPalette::Window); - gwi->setFont(font); - gwi->setText(tr("No event")); - gwi->setFixedSize(m_gradientItemList->width(), 48); - listItem->setSizeHint(QSize(m_gradientItemList->width(), 49)); //每次改变Item的高度 - //listItem->setBackgroundColor(Qt::white); - listItem->setFlags(Qt::ItemIsTristate ); - m_gradientItemList->addItem(listItem); - m_gradientItemList->setItemWidget(listItem, gwi); - m_labellist.append(gwi); - } - sing | QPainter::HighQualityAntialiasing); - QPainterPath path; - - auto palette = this->palette(); - - auto penWidthf = 1.0; - auto background = m_TBcolor; - auto borderColor = m_TBcolor; - - const qreal radius = 10; - - - switch (m_dtype) { - case 0: { - const qreal triHeight = 12; - const qreal triWidth = 16; - const qreal height = this->height() - triHeight; - const qreal width = this->width(); - QRectF topRightRect(QPointF(0, 0), - QPointF(2 * radius, 2 * radius)); - QRectF bottomRightRect(QPointF(0, height - 2 * tr("No event")radius), - QPointF(2 * radius, height)); - QRectF topLeftRect(QPointF(width, 0), - QPointF(width - 2 * radius, 2 * radius)); - QRectF bottomLeftRect(QPointF(width, height), - QPointF(width - 2 * radius, height - 2 * radius)); - path.moveTo(radius, 0.0); - path.lineTo(width - radius, 0.0); - path.arcTo(topLeftRect, 90.0, 90.0); - path.lineTo(width, height - radius); - path.arcTo(bottomLeftRect, 180.0, -90.0); - path.lineTo(width / 2 + triWidth / 2, height); - path.lineTo(width / 2, height + triHeight); - path.lineTo(width / 2 - triWidth / 2, height); - path.lineTo(radius, height); - - path.arcTo(bottomRightRect, 270.0, -90.0); - path.lineTo(0.0, radius); - - path.arcTo(topRightRect, 180.0, -90.0); - path.lineTo(radius, 0.0); - } - break; - case 1: { - const qreal triHeight = 12; - const qreal triWidth = 16; - const qreal height = this->height() - triHeight; - const qreal width = this->width(); - - QRectF topRightRect(QPointF(0, triHeight), - QPointF(2 * radius, 2 * radius + triHeight)); - QRectF bottomRightRect(QPointF(0, this->height() - 2 * radius), - QPointF(2 * radius, this->height())); - QRectF topLeftRect(QPointF(width, triHeight), - QPointF(width - 2 * radius, 2 * radius + triHeight)); - QRectF bottomLeftRect(QPointF(width, this->height()), - QPointF(width - 2 * radius, this->height() - 2 * radius)); - path.moveTo(radius, triHeight); - path.lineTo(width / 2 - triWidth / 2, triHeight); - path.lineTo(width / 2, 0); - path.lineTo(width / 2 + triWidth / 2, triHeight); - path.lineTo(width - radius, triHeight); - path.arcTo(topLeftRect, 90.0, 90.0); - tr("No event") - path.lineTo(width, this->height() - radius); - path.arcTo(bottomLeftRect, 180.0, -90.0); - path.lineTo(radius, this->height()); - path.arcTo(bottomRightRect, 270.0, -90.0); - path.lineTo(0.0, radius); - path.arcTo(topRightRect, 180.0, -90.0); - path.lineTo(radius, 0.0); - } - break; - case 2: { - const qreal triHeight = 16; - const qreal triWidth = 12; - const qreal height = this->height(); - const qreal width = this->width() - triWidth; - - QRectF topRightRect(QPointF(triWidth, 0), - QPointF(2 * radius + triWidth, 2 * radius)); - QRectF bottomRightRect(QPointF(triWidth, this->height() - 2 * radius), - QPointF(2 * radius + triWidth, this->height())); - QRectF topLeftRect(QPointF(this->width(), 0), - QPointF(this->width() - 2 * radius, 2 * radius)); - QRectF bottomLeftRect(QPointF(this->width(), this->height()), - QPointF(this->width() - 2 * radius, this->height() - 2 * radius)); - - path.moveTo(radius + triWidth, 0); - path.lineTo(this->width() - radius, 0.0); - m_bttextcolor - path.arcTo(topLeftRect, 90.0, 90.0); - path.lineTo(this->width(), height - radius); - path.arcTo(bottomLeftRect, 180.0, -90.0); - path.lineTo(radius, this->height()); - path.arcTo(bottomRightRect, 270.0, -90.0); - path.lineTo(triWidth, height / 2 + triHeight / 2); - path.lineTo(0, height / 2 ); - path.lineTo(triWidth, height / 2 - triHeight / 2); - path.lineTo(triWidth, radius); - path.arcTo(topRightRect, 180.0, -90.0); - path.lineTo(radius + triWidth, 0.0); - } - break; - case 3: { - const qreal triHeight = 16; - const qreal triWidth = 12; - const qreal height = this->height(); - const qreal width = this->width(); - - QRectF topRightRect(QPointF(0, 0), - QPointF(2 * radius, 2 * radius)); - QRectF bottomRightRect(QPointF(0, this->height() - 2 * radius), - QPointF(2 * radius, this->height())); - QRectF topLeftRect(QPointF(width - triWidth, 0), - QPointF(width - triWidth - 2 * radius, 2 * radius)); - QRectF bottomLeftRect(QPointF(width - triWidth, this->height()), - QPointF(width - triWidth - 2 * radius, this->height() - 2 * radius)); - - path.moveTo(radius, 0); - path.lineTo(this->width() - triWidth - radius, 0.0); - path.arcTo(topLeftRect, 90.0, 90.0); - path.lineTo(width - triWidth, height / 2 - triHeight / 2); - path.lineTo(width, height / 2 ); - path.lineTo(width - triWidth, height / 2 + triHeight / 2); - path.lineTo(width - triWidth, height - radius); - path.arcTo(bottomLeftRect, 180.0, -90.0); - path.lineTo(radius, this->height()); - path.arcTo(bottomRightRect, 270.0, -90.0); - path.lineTo(0.0, radius); - path.arcTo(topRightRect, 180.0, -90.0); - path.lineTo(radius, 0.0); - } - break; - } - - painter.fillPath(path, background); - - QPainter painter(this); - painter.setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing); - QPainterPath path; - - //auto palette = m_gradientItemList->palette(); - - auto penWidthf = 1.0; - auto background = m_TBcolor; - auto borderColor = m_TBcolor; - - const qreal radius = 10; - - - switch (m_dtype) { - case 0: { - const qreal triHeight = 16; - const qreal triWidth = 12; - const qreal height = this->height(); - const qreal width = this->width() - triWidth; - - QRectF topRightRect(QPointF(triWidth, 0), - QPointF(2 * radius + triWidth, 2 * radius)); - QRectF bottomRightRect(QPointF(triWidth, this->height() - 2 * radius), - QPointF(2 * radius + triWidth, this->height())); - QRectF topLeftRect(QPointF(this->width(), 0), - QPointF(this->width() - 2 * radius, 2 * radius)); - QRectF bottomLeftRect(QPointF(this->width(), this->height()), - QPointF(this->width() - 2 * radius, this->height() - 2 * radius)); - - path.moveTo(radius + triWidth, 0); - path.lineTo(this->width() - radius, 0.0); - path.arcTo(topLeftRect, 90.0, 90.0); - path.lineTo(this->width(), height - radius); - path.arcTo(bottomLeftRect, 180.0, -90.0); - path.lineTo(radius, this->height()); - path.arcTo(bottomRightRect, 270.0, -90.0); - path.lineTo(triWidth, m_arrowheight + triHeight / 2); - path.lineTo(0, m_arrowheight ); - path.lineTo(triWidth, m_arrowheight - triHeight / 2); - path.lineTo(triWidth, radius); - path.arcTo(topRightRect, 180.0, -90.0); - path.lineTo(radius + triWidth, 0.0); - } - break; - case 1: { - const qreal triHeight = 16; - const qreal triWidth = 12; - const qreal height = this->height(); - const qreal width = this->width(); - - QRectF topRightRect(QPointF(0, 0), - QPointF(2 * radius, 2 * radius)); - QRectF bottomRightRect(QPointF(0, this->height() - 2 * radius), - QPointF(2 * radius, this->height())); - QRectF topLeftRect(QPointF(width - triWidth, 0), - QPointF(width - triWidth - 2 * radius, 2 * radius)); - QRectF bottomLeftRect(QPointF(width - triWidth, this->height()), - QPointF(width - triWidth - 2 * radius, this->height() - 2 * radius)); - - path.moveTo(radius, 0); - path.lineTo(this->width() - triWidth - radius, 0.0); - path.arcTo(topLeftRect, 90.0, 90.0); - path.lineTo(width - triWidth, m_arrowheight - triHeight / 2); - path.lineTo(width, m_arrowheight ); - path.lineTo(width - triWidth, m_arrowheight + triHeight / 2); - path.lineTo(width - triWidth, height - radius); - path.arcTo(bottomLeftRect, 180.0, -90.0); - path.lineTo(radius, this->height()); - path.arcTo(bottomRightRect, 270.0, -90.0); - path.lineTo(0.0, radius); - path.arcTo(topRightRect, 180.0, -90.0); - path.lineTo(radius, 0.0); - } - break; - } - - painter.fillPath(path, background); - - painter.save(); - painter.setRenderHints(QPainter::Antialiasing); - QPen pen; - pen.setColor(m_borderColor); - pen.setWidthF(1); - pen.setStyle(Qt::SolidLine); - painter.setBrush(Qt::NoBrush); - painter.setPen(pen); - painter.drawPath(path); - painter.restore(); -#endif -// if (!m_soloDay.isEmpty()) { -// ScheduleDtailInfo info; -// info.titleName = m_soloDay; -// info.allday = true; -// info.id = 4; -// paintItem(info, 0, 1); -// } - - for (int i = 0; i < m_vlistData.size(); ++i) { -// if (!m_soloDay.isEmpty()) { -// paintItem(m_vlistData.at(i), i + 1, 0); -// } else { - paintItem(m_vlistData.at(i), i, 0); -// } - } - if (m_soloDay.isEmpty() && m_vlistData.isEmpty()) { - paintItem(); - } - adjustPos = false; -} - -void CYearSchceduleView::paintItem(ScheduleDtailInfo info, int index, int type) -{ - int labelwidth = width() - 30; - int bheight = index * 29 + 10; - int labelheight = 28; - ScheduleDtailInfo &gd = info; - CSchedulesColor gdcolor = CScheduleDataManage::getScheduleDataManage()->getScheduleColorByType(gd.type.ID); - - QFont font/*(fontfamily)*/; - font.setWeight(QFont::Medium); - font.setPixelSize(fontsize); - //gwi->setBackgroundColor(Qt::white); - QColor scolor = gdcolor.Purecolor; - scolor.setAlphaF(1.0); - - - QPainter painter(this); - QRect fillRect = QRect(0, 0, width(), height()); - painter.setRenderHints(QPainter::HighQualityAntialiasing); - QColor bcolor = m_bBackgroundcolor; - painter.save(); - painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; - painter.setBrush(QBrush(bcolor)); - painter.setPen(Qt::NoPen); - painter.drawRect(fillRect); - painter.restore(); - if (gd.id == -1) { - - QString str = "..."; - - painter.save(); - painter.setRenderHint(QPainter::Antialiasing); - painter.setPen(m_btimecolor); - painter.setFont(font); - if (adjustPos) { - painter.drawText(QRect(25 - 18, bheight, labelwidth - 80, labelheight - 2), Qt::AlignLeft | Qt::AlignVCenter, str); - } else { - painter.drawText(QRect(25, bheight, labelwidth - 80, labelheight - 2), Qt::AlignLeft | Qt::AlignVCenter, str); - } - painter.restore(); - } else { - if (info.id != -1) { - //圆点 - painter.save(); - painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; - if (type == 0) - - painter.setBrush(QBrush(gdcolor.splitColor)); - else { - - painter.setBrush(QBrush(m_solocolor)); - } - - painter.setPen(Qt::NoPen); - if (adjustPos) { - painter.drawEllipse(QRect(25 - 18, bheight + (labelheight - 8) / 2, 8, 8)); - } else { - painter.drawEllipse(QRect(25, bheight + (labelheight - 8) / 2, 8, 8)); - } -// painter.drawEllipse(QRect(25, bheight + (labelheight - 8) / 2, 8, 8)); - painter.restore(); - } - - QString str; - //左边文字 - painter.save(); - painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; - painter.setPen(m_bttextcolor); - painter.setFont(font); - QFontMetrics fm = painter.fontMetrics(); - QString tStitlename = gd.titleName; - tStitlename.replace("\n", ""); - str = tStitlename; - int tilenameW = labelwidth - 80; - QString tstr; - for (int i = 0; i < str.count(); i++) { - tstr.append(str.at(i)); - int widthT = fm.width(tstr) + 5; - if (widthT >= tilenameW) { - tstr.chop(1); - break; - } - } - if (tstr != str) { - tstr = tstr + "..."; - } - - if (adjustPos) { - painter.drawText(QRect(41 - 18, bheight, tilenameW, labelheight - 2), Qt::AlignLeft | Qt::AlignVCenter, tstr); - } else { - painter.drawText(QRect(41, bheight, tilenameW, labelheight - 2), Qt::AlignLeft | Qt::AlignVCenter, tstr); - } -// painter.drawText(QRect(41, bheight, tilenameW, labelheight - 2), Qt::AlignLeft | Qt::AlignVCenter, tstr); - painter.restore(); - if (info.id != -1) { - //右边时间 - painter.save(); - painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; - painter.setPen(m_btimecolor); - painter.setFont(font); - QLocale locale; - - if (info.allday) { - str = tr("All Day"); - } else { - if (m_currentDate > info.beginDateTime.date()) { - str = tr("All Day"); - } else { - str = info.beginDateTime.time().toString("hh:mm"); - } - } - - QFontMetrics fm2 = painter.fontMetrics(); - if (adjustPos) { - painter.drawText(QRect(width() - 70 - 18, bheight, 57, labelheight - 2), Qt::AlignRight | Qt::AlignVCenter, str); - } else { - painter.drawText(QRect(width() - 70, bheight, 57, labelheight - 2), Qt::AlignRight | Qt::AlignVCenter, str); - } -// painter.drawText(QRect(width() - 70, bheight, 57, labelheight - 2), Qt::AlignRight | Qt::AlignVCenter, str); - painter.restore(); - } - } -} - -void CYearSchceduleView::paintItem() -{ -// int labelwidth = width() - 40; -// int labelheight = 45; - - QFont font/*(fontfamily)*/; - font.setPixelSize(fontsize); - QPainter painter(this); - QRect fillRect = QRect(0, 0, width(), height()); - painter.setRenderHints(QPainter::HighQualityAntialiasing); - QColor bcolor = m_bBackgroundcolor; - painter.save(); - painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; - painter.setBrush(QBrush(bcolor)); - painter.setPen(Qt::NoPen); - painter.drawRect(fillRect); - painter.restore(); - - - - QString str; - //左边文字 - painter.save(); - painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; - painter.setPen(m_bttextcolor); - painter.setFont(font); - QFontMetrics fm = painter.fontMetrics(); - QString tStitlename = tr("No event"); - - - painter.drawText(QRect(0, 0, width(), height()), Qt::AlignCenter, tStitlename); - painter.restore(); - -} - -CYearSchceduleOutView::CYearSchceduleOutView(QWidget *parent) - : DArrowRectangle(DArrowRectangle::ArrowLeft, parent) -{ - yearschceduleview = new CYearSchceduleView (); - this->setContent(yearschceduleview); -} - -void CYearSchceduleOutView::setSoloDay(QString soloday) -{ - yearschceduleview->setSoloDay(soloday); -} - -void CYearSchceduleOutView::setData(QVector &vListData) -{ - list_count = vListData.size(); - yearschceduleview->setData(vListData); - scheduleinfoList = yearschceduleview->getlistdate(); -} - -void CYearSchceduleOutView::clearData() -{ - yearschceduleview->clearData(); -} - -void CYearSchceduleOutView::showWindow() -{ - int w = yearschceduleview->showWindow(); - this->setFixedSize(w, yearschceduleview->height()); -} - -void CYearSchceduleOutView::setTheMe(int type) -{ - yearschceduleview->setTheMe(type); -} - -void CYearSchceduleOutView::setDtype(int type, int arrowheight) -{ - yearschceduleview->setDtype(type, arrowheight); -} - -void CYearSchceduleOutView::setCurrentDate(QDate cdate) -{ - currentdate = cdate; - yearschceduleview->setCurrentDate(cdate); -} - -void CYearSchceduleOutView::adjustPosition(bool ad) -{ - yearschceduleview->adjustPosition(ad); -} - -void CYearSchceduleOutView::mousePressEvent(QMouseEvent *event) -{ - Q_UNUSED(event); - QPoint pos = QCursor::pos(); - pos = this->mapFromGlobal(pos); - QVector rect_press; - QRect rect(35,50,width() - 50,20); - int listShow = 0; - if (!scheduleinfoList.isEmpty()) { - if (scheduleinfoList.size() < 5) - listShow = scheduleinfoList.size(); - else - listShow = 5; - } - for (int i = 0; i < listShow; i++) { - if (this->arrowDirection() == DArrowRectangle::ArrowLeft) - rect_press.append(QRect(35, 20 + i * 30, width() - 50, 20)); - else - rect_press.append(QRect(20, 20 + i * 30, width() - 50, 20)); - } - for (int i = 0; i < listShow; i++) { - if (rect_press.at(i).contains(pos)) { - if (i > 3 && list_count > 5) { - emit signalsViewSelectDate(currentdate); - this->hide(); - //跳转到周视图 - } else { - if (scheduleinfoList.at(i).type.ID != 4) { - CSchceduleDlg dlg(0); - dlg.setData(scheduleinfoList.at(i)); - if (dlg.exec() == DDialog::Accepted) - emit signalupdateschcedule(); - } - } - } - } -} diff -Nru dde-calendar-5.7.0.4/src/yearschceduleview.h dde-calendar-5.7.0.23/src/yearschceduleview.h --- dde-calendar-5.7.0.4/src/yearschceduleview.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/yearschceduleview.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,130 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#ifndef YEARSCHCEDULEVIEW_H -#define YEARSCHCEDULEVIEW_H - -#include -#include -#include "schedulestructs.h" -#include -#include -#include -#include "yearwindow.h" -DWIDGET_USE_NAMESPACE -class QVBoxLayout; -class CYearSchceduleItem; -class CYearSchceduleOutView; -class CYearSchceduleView : public DWidget -{ - Q_OBJECT - -public: - CYearSchceduleView(QWidget *parent = nullptr); - ~CYearSchceduleView(); - void setSoloDay(QString soloday); - void setData(QVector &vListData); - QVector getlistdate() - { - return m_vlistData; - } - void clearData(); - int showWindow(); - void setTheMe(int type = 0); - void setDtype(int type, int arrowheight); - void setCurrentDate(QDate cdate); - QDate getCurrentDate(); - void adjustPosition(bool ad); -private: - void updateDateShow(); - void createItemWidget(ScheduleDtailInfo info, int type = 0); -protected: - void paintEvent(QPaintEvent *event); - void paintItem(ScheduleDtailInfo info, int index, int type = 0); - void paintItem(); -private: - DListWidget *m_gradientItemList; //下拉列表窗 - bool m_widgetFlag; - QVector m_vlistData; - QString m_soloDay; - QVector m_labellist; - int m_type; - QDate m_currentDate; - QColor m_bBackgroundcolor = "#000000"; - QColor m_btimecolor = "#526A7F"; - QColor m_bttextcolor = "#414D68"; - QColor m_lBackgroundcolor = Qt::white; - QColor m_ltextcolor = "#001A2E"; - QColor m_solocolor = "#001A2E"; - QColor m_TBcolor = "#001A2E"; - int m_dtype = 3; - int m_arrowheight = 0; - QColor m_borderColor = "#000000"; - bool adjustPos = false; -}; - -class CYearSchceduleItem : public DLabel -{ - Q_OBJECT - -public: - explicit CYearSchceduleItem(QWidget *parent = nullptr); - void setBackgroundColor(QColor color1); - void setStateColor(QColor color1); - void setText(QColor tcolor, QFont font); - void setTimeC(QColor tcolor, QFont font); - void setData(ScheduleDtailInfo vScheduleInfo); -protected: - void paintEvent ( QPaintEvent *e); -private: - ScheduleDtailInfo m_ScheduleInfo; - QColor m_Backgroundcolor; - QColor m_timecolor; - QColor m_Statecolor; - QFont m_timefont; - QColor m_ttextcolor; - QFont m_tfont; -}; - -class CYearSchceduleOutView : public DArrowRectangle -{ - Q_OBJECT - -public: - explicit CYearSchceduleOutView(QWidget *parent = nullptr); - void setSoloDay(QString soloday); - void setData(QVector &vListData); - void clearData(); - void showWindow(); - void setTheMe(int type = 0); - void setDtype(int type, int arrowheight); - void setCurrentDate(QDate cdate); - void adjustPosition(bool ad); -signals: - void signalsViewSelectDate(QDate date); - void signalupdateschcedule(); -private: - CYearSchceduleView *yearschceduleview; - QVector scheduleinfoList; - QDate currentdate; - int list_count = 0; -protected: - void mousePressEvent(QMouseEvent *event); -}; -#endif // CSHCEDULEDAYVIEW_H - diff -Nru dde-calendar-5.7.0.4/src/yearview.cpp dde-calendar-5.7.0.23/src/yearview.cpp --- dde-calendar-5.7.0.4/src/yearview.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/yearview.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,720 +0,0 @@ - -/* - * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ - -#include "calendardbus.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include "yearview.h" -#include -#include -#include -#include -#include "scheduledatamanage.h" -#include "yearschceduleview.h" -#include -#include - -#include - -#include -DGUI_USE_NAMESPACE -CYearSchceduleOutView *CYearView::m_Scheduleview = nullptr; -CMonthDayRect *CMonthDayRect::m_CurrentRect =nullptr; -qreal CMonthDayRect::m_DevicePixelRatio = 0; -QColor CMonthDayRect::m_ceventColor("#FF5D00"); -QColor CMonthDayRect::m_notCurrentTextColor = "#b2b2b2"; -CMonthDayRect::CellColor CMonthDayRect::m_currentColor; -QColor CMonthDayRect::m_defaultTextColor; -QColor CMonthDayRect::m_selectedTextColor; - - -CYearView::CYearView(QWidget *parent) : CustomFrame(parent) -{ -// m_dayNumFont.setFamily("Helvetica"); - - setMouseTracking(true); - //m_dayNumFont.setWeight(QFont::Light); - - //add separator line - m_currentMouth = new CustomFrame(); - m_currentMouth->setFixedHeight(24); - m_currentMouth->setContentsMargins(0, 0, 0, 0); - //m_currentMouth->setMinimumWidth(100); - m_currentMouth->setTextAlign(Qt::AlignLeft); - //m_currentMouth->setStyleSheet("border: 1px solid rgba(0, 0, 0, 0.05);"); - -// m_momthFont.setFamily("SourceHanSansSC"); - m_momthFont.setWeight(QFont::Medium); - m_momthFont.setPixelSize(16); - m_currentMouth->setTextFont(m_momthFont); - - QHBoxLayout *separatorLineLayout = new QHBoxLayout; - separatorLineLayout->setMargin(0); - separatorLineLayout->setSpacing(0); - separatorLineLayout->setContentsMargins(0, 0, 0, 0); - //separatorLineLayout->addSpacing(13); - separatorLineLayout->addWidget(m_currentMouth); - separatorLineLayout->addStretch(); - // QSpacerItem *t_spaceitem = new QSpacerItem(30, 32, QSizePolicy::Expanding, QSizePolicy::Fixed); - //separatorLineLayout->addSpacerItem(t_spaceitem); - - m_currentMouth->show(); - m_currentMouth->installEventFilter(this); - - - m_monthView = new CYearMonthView(this); - connect(m_monthView, - &CYearMonthView::signalPressDate, - this, - &CYearView::slotPressClickDate); - connect(m_monthView, - &CYearMonthView::signalDoubleClickDate, - this, - &CYearView::slotDoubleClickDate); - - m_hhLayout = new QVBoxLayout; - m_hhLayout->addLayout(separatorLineLayout); - m_hhLayout->addWidget(m_monthView); - m_hhLayout->setMargin(0); - m_hhLayout->setSpacing(0); - m_hhLayout->setContentsMargins(13, 10, 10, 10); - - setLayout(m_hhLayout); - createYearSchceduleView(parent); -} - -void CYearView::updateInfoWIndow(bool flag) -{ - if (flag) { - m_Scheduleview->show(0, 0); - } else { - m_Scheduleview->hide(); - } -} - -void CYearView::slotupdateSchedule(const int id) -{ - setCurrentDate(m_currentDate, id); -} - -void CYearView::slotDoubleClickDate(const QDate &date) -{ - if (date.year()<1900) - return; - SchceduleViewHide(); - emit signaldoubleclickDate(date); -} - -void CYearView::slotPressClickDate(const QDate &date) -{ - if (date.year()<1900) - return; - emit signalcurrentDateChanged(date); - emit signalHideInfo(); - emit signalSelectInfo(true); - m_Scheduleview->setCurrentDate(date); - for (int i = 0; i < m_DateRangeInfo.size(); ++i) { - if (m_DateRangeInfo.at(i).date ==date) { - m_Scheduleview->setData(m_DateRangeInfo[i].vData); - } - } - QPoint pos22 = QCursor::pos(); - QDesktopWidget *w = QApplication::desktop(); - m_Scheduleview->showWindow(); - - if (pos22.x() + 10 + m_Scheduleview->width() < w->width()) { - m_Scheduleview->setArrowDirection(DArrowRectangle::ArrowLeft); - m_Scheduleview->show(pos22.x() + 10, pos22.y()); - } else { - m_Scheduleview->adjustPosition(true); - m_Scheduleview->setArrowDirection(DArrowRectangle::ArrowRight); - m_Scheduleview->show(pos22.x() - 10, pos22.y()); - } -} - -void CYearView::setFirstWeekday(int weekday) -{ - m_firstWeekDay = weekday; - updateDate(); -} - - -void CYearView::setTheMe(int type) -{ - m_themetype = type; - if (type == 0 || type == 1) { - DPalette bpa = palette(); - bpa.setColor(DPalette::Background, Qt::white); - setPalette(bpa); - setBackgroundRole(DPalette::Background); - m_currentMouth->setTextColor( QColor("#CF0059")); - - m_bnormalColor = "#FFFFFF"; - m_topBorderColor = Qt::red; - m_backgroundCircleColor = "#0081FF"; - m_currentDayTextColor = "#0081FF"; - m_weekendsTextColor = Qt::black; - m_festivalTextColor = Qt::black; - - } else if (type == 2) { - m_bnormalColor = "#FFFFFF"; - m_bnormalColor.setAlphaF(0.05); - m_currentMouth->setTextColor( QColor("#BF1D63")); - - m_topBorderColor = Qt::red; - m_backgroundCircleColor = "#0059D2"; - - - m_currentDayTextColor = "#0059D2"; - m_weekendsTextColor = Qt::black; - - m_festivalTextColor = Qt::black; - - } - m_monthView->setTheMe(type); - QColor monthcolor = Qt::white; - monthcolor.setAlphaF(0); - m_currentMouth->setBColor(monthcolor); - m_Scheduleview->setTheMe(type); -} - - -void CYearView::SchceduleViewHide() -{ - m_Scheduleview->hide(); - m_Scheduleview->clearData(); -} - -void CYearView::getInfoAndSetLineFlag() -{ - CScheduleDataManage *tdataManage = CScheduleDataManage::getScheduleDataManage(); - m_vlineflag.resize(42); - m_vlineflag.fill(false); - if (tdataManage->getGetAllYearScheduleInfo()->m_monthInfo.size()>0) { - m_DateRangeInfo = tdataManage->getGetAllYearScheduleInfo()->m_monthInfo[m_currentDate.month()]; - if (m_DateRangeInfo.count() == 42) { - for (int i = 0; i < 42; i++) { - if (!m_DateRangeInfo.at(i).vData.isEmpty()) { - m_vlineflag[i] = true; - } - } - } - } - m_monthView->setLintFlag(m_vlineflag); - m_monthView->update(); -} - -void CYearView::setCurrentDate(const QDate date, int type) -{ - Q_UNUSED(type); - qDebug() << "set current date " << date; - - //if (date == m_currentDate) { - // return; - // } - - m_currentDate = date; - QLocale locale; - m_currentMouth->setTextStr(locale.monthName(date.month(), QLocale::ShortFormat)); - updateDate(); - m_monthView->setDate(m_days); -// getInfoAndSetLineFlag(); -} - -void CYearView::setCellSelectable(bool selectable) -{ - if (selectable == m_cellSelectable) - return; - m_cellSelectable = selectable; -} - -int CYearView::getDateIndex(const QDate &date) const -{ - for (int i = 0; i != 42; ++i) - if (m_days[i] == date) - return i; - - return 0; -} -bool CYearView::eventFilter(QObject *o, QEvent *e) -{ - QWidget *cell = qobject_cast(o); - if (cell == m_currentMouth) { - if (e->type() == QEvent::MouseButtonDblClick) { - emit signalselectMonth(m_currentDate); - } - } - return false; -} -void CYearView::updateDate() -{ - const QDate firstDay(m_currentDate.year(), m_currentDate.month(), 1); - int offset = firstDay.dayOfWeek() % 7 - m_firstWeekDay ; - - const int day = offset <0 ?offset +7:offset; - const int currentIndex = day + m_currentDate.day() - 1; - - if (currentIndex < 0) { - return; - } - for (int i(0); i != 42; ++i) { - m_days[i] = firstDay.addDays(i - day); - } - update(); -} - -void CYearView::createYearSchceduleView(QWidget *parent) -{ - if (m_Scheduleview == nullptr) { - m_Scheduleview = new CYearSchceduleOutView(parent); - connect(m_Scheduleview, &CYearSchceduleOutView::signalsViewSelectDate, this, &CYearView::signalselectWeekwindow); - connect(m_Scheduleview, &CYearSchceduleOutView::signalupdateschcedule, this, &CYearView::signalupdateschcedule); - } -} - -void CYearView::resizeEvent(QResizeEvent *event) -{ - int leftmagin = qFloor(width() * 0.06435 + 0.5); - int rightmagin = leftmagin; - int topmagin = qFloor(height() * 0.02955 + 0.5); - int buttonmagin = qFloor(height() * 0.044 + 0.5); - - m_hhLayout->setContentsMargins(leftmagin, topmagin, rightmagin, buttonmagin); - - m_momthFont.setPixelSize(qFloor(16 + (height() - 159) / 16.75)); - m_currentMouth->setTextFont(m_momthFont); - m_currentMouth->setFixedHeight(24 + (height() - 159) / 12); - m_currentMouth->update(); - - QFrame::resizeEvent(event); -} - -void CYearView::mousePressEvent(QMouseEvent *event) -{ - if (m_selectFlag) return; - if (event->button() == Qt::LeftButton) { - emit signalHideInfo(); - } - CustomFrame::mousePressEvent(event); -} - - -void CYearView::paintEvent(QPaintEvent *e) -{ - Q_UNUSED(e); - int labelwidth = width() - 2 * m_borderframew; - int labelheight = height() - 2 * m_borderframew; - - QPainter painter(this); - if (1) { - painter.save(); - painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; - painter.setBrush(QBrush(m_bnormalColor)); - painter.setPen(Qt::NoPen); - QPainterPath painterPath; - painterPath.moveTo(m_radius, m_borderframew); - painterPath.arcTo(QRect(m_borderframew, m_borderframew, m_radius * 2, m_radius * 2), 90, 90); - - painterPath.lineTo(0, labelheight - m_radius); - painterPath.arcTo(QRect(m_borderframew, labelheight - m_radius * 2, m_radius * 2, m_radius * 2), 180, 90); - - painterPath.lineTo(labelwidth - m_radius, labelheight); - painterPath.arcTo(QRect(labelwidth - m_radius * 2, labelheight - m_radius * 2, m_radius * 2, m_radius * 2), 270, 90); - - painterPath.lineTo(labelwidth, m_radius); - - painterPath.arcTo(QRect(labelwidth - m_radius * 2, m_borderframew, m_radius * 2, m_radius * 2), 0, 90); - - painterPath.lineTo(m_radius, m_borderframew); - painterPath.closeSubpath(); - painter.drawPath(painterPath); - painter.restore(); - } -} - -CYearMonthView::CYearMonthView(DWidget *parent) - :DWidget (parent) -{ - for (int i = 0; i < 42; ++i) { - CMonthDayRect *item = new CMonthDayRect(); - m_DayItem.append(item); - } - setMouseTracking(true); - CMonthDayRect::setDevicePixelRatio(devicePixelRatioF()); -} - -CYearMonthView::~CYearMonthView() -{ - for (int i = 0; i setDate(date[i]); - m_DayItem.at(i)->setIsCurrentMonth(date[i].month() == m_currentMonth); - } - -} - -void CYearMonthView::setTheMe(int type) -{ - CMonthDayRect::setTheMe(type); -} - -void CYearMonthView::setLintFlag(const QVector &lineFlag) -{ - m_vlineflag = lineFlag; - if (m_vlineflag.size() == 42) { - for (int i = 0; i < 42; i++) { - m_DayItem.at(i)->setLineFlag(m_vlineflag.at(i)); - } - } -} - -void CYearMonthView::updateSize() -{ - qreal w = width()/7; - qreal h = height()/6; - QRectF rect ; - int w_offset = 0; - int h_offset = 0; - for (int i = 0 ; i < m_DayItem.size(); ++i) { - h_offset = i / 7; - w_offset = i % 7; - rect.setRect(w*w_offset, - h*h_offset, - w, - h); - m_DayItem.at(i)->setRect(rect); - } - update(); -} - -int CYearMonthView::getMousePosItem(const QPointF &pos) -{ - int res =-1; - for (int i = 0 ; i < m_DayItem.size(); ++i) { - if (m_DayItem.at(i)->rect().contains(pos)) { - res = i; - break; - } - } - return res; -} - -void CYearMonthView::resizeEvent(QResizeEvent *event) -{ - Q_UNUSED(event); - updateSize(); -} - -void CYearMonthView::mousePressEvent(QMouseEvent *event) -{ - int itemindex = getMousePosItem(event->pos()); - if (!(itemindex<0)) { - m_DayItem.at(itemindex)->setCellEvent(CMonthDayRect::CellPress); - m_press = true; - if ( event->button() ==Qt::LeftButton) { - m_pressIndex = itemindex; - emit signalPressDate(m_DayItem.at(itemindex)->getDate()); - } - } - update(); -} - -void CYearMonthView::mouseDoubleClickEvent(QMouseEvent *event) -{ - int itemindex = getMousePosItem(event->pos()); - if (!(itemindex<0)) { - if (m_pressIndex == itemindex) { - m_DayItem.at(itemindex)->setCellEvent(CMonthDayRect::CellPress); - m_press = true; - if ( event->button() ==Qt::LeftButton) { - emit signalDoubleClickDate(m_DayItem.at(itemindex)->getDate()); - } - } - } -} - -void CYearMonthView::mouseReleaseEvent(QMouseEvent *event) -{ - m_press = false; - mouseMoveEvent(event); -} - -void CYearMonthView::mouseMoveEvent(QMouseEvent *event) -{ - if (!m_press) { - int itemindex = getMousePosItem(event->pos()); - if (!(itemindex<0)) { - m_DayItem.at(itemindex)->setCellEvent(CMonthDayRect::Cellhover); - } - update(); - } - -} - -void CYearMonthView::paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event); - QPainter painter(this); - painter.setRenderHints(QPainter::Antialiasing |QPainter::SmoothPixmapTransform); - for (int i = 0 ; i < m_DayItem.size(); ++i) { - m_DayItem[i]->paintItem(&painter,m_DayItem[i]->rect()); - } - painter.end(); -} - -void CYearMonthView::leaveEvent(QEvent *event) -{ - Q_UNUSED(event); - CMonthDayRect::setCurrentRect(nullptr); - update(); -} - - -CMonthDayRect::CMonthDayRect() - :m_rect(0,0,0,0) -{ - m_dayNumFont.setPixelSize(12); - m_hightFont.setPixelSize(12); -} - -void CMonthDayRect::setTheMe(int type) -{ - if (type ==2) { - m_currentColor.hoverColor = "#FFFFFF"; - m_currentColor.hoverColor.setAlphaF(0.1); - m_currentColor.pressColor = "#252525"; - m_currentColor.pressColor.setAlphaF(1); - m_currentColor.normalColor = "#000000"; - m_currentColor.normalColor.setAlphaF(0.00); - m_ceventColor = QColor(204, 77, 3); - - m_notCurrentTextColor = "#C0C6D4"; - m_notCurrentTextColor.setAlphaF(0.5); - m_defaultTextColor = "#C0C6D4"; - m_selectedTextColor = Qt::white; - - } else if (type == 0 || type == 1) { - m_currentColor.hoverColor = "#000000"; - m_currentColor.hoverColor.setAlphaF(0.05); - m_currentColor.pressColor = "#000000"; - m_currentColor.pressColor.setAlphaF(0.2); - m_currentColor.normalColor = "#FFFFFF"; - m_currentColor.normalColor.setAlphaF(1); - m_ceventColor = QColor(255, 93, 0); - - m_selectedTextColor = Qt::white; - m_defaultTextColor = Qt::black; - m_notCurrentTextColor = "#b2b2b2"; - } - - -} - -CMonthDayRect::~CMonthDayRect() -{ - -} - -void CMonthDayRect::setDate(const QDate &date) -{ - m_date = date; -} - -QDate CMonthDayRect::getDate() const -{ - return m_date; -} - -void CMonthDayRect::setCellEvent(const CMonthDayRect::CellEventType &type) -{ - m_cellEventType = type; - m_CurrentRect = this; -} - -void CMonthDayRect::setIsCurrentMonth(const bool isCurrMonth) -{ - m_isCurrentMonth = isCurrMonth; -} - -QRectF CMonthDayRect::rect() const -{ - return m_rect; -} - -void CMonthDayRect::setRect(const QRectF &rect) -{ - m_rect = rect; -} - -void CMonthDayRect::setRect(qreal x, qreal y, qreal w, qreal h) -{ - m_rect.setRect(x,y,w,h); -} - -void CMonthDayRect::paintItem(QPainter *painter, const QRectF &rect) -{ - m_highColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); - if (m_date.year()<1900) - return; - const bool isCurrentDay = m_date == QDate::currentDate() && m_isCurrentMonth; - bool isSelectedCell = false; - if (isCurrentDay) { - isSelectedCell = true; - } - - - const qreal r = rect.width() > rect.height() ? rect.height() * 0.9 : rect.width() * 0.9 ; - int fontsize = qRound(12 + (r - 18) *6/ 17); - if (fontsize <12) { - fontsize = 12; - } - m_dayNumFont.setPixelSize(fontsize); - m_hightFont.setPixelSize(fontsize); - const qreal x = rect.x()+(rect.width() - r) / 2; - const qreal y = rect.y()+(rect.height() - r) / 2; - QRectF fillRect = QRectF(x, y, r, r); - - QColor m_cellBackgroundColor; - if (m_CurrentRect !=this) { - m_cellEventType = CellNormal; - } - if (m_cellEventType == CellPress) { - m_cellBackgroundColor = m_currentColor.pressColor; - } else if (m_cellEventType == Cellhover) { - m_cellBackgroundColor = m_currentColor.hoverColor; - } else { - m_cellBackgroundColor = m_currentColor.normalColor; - } - painter->setBrush(m_cellBackgroundColor); - painter->setPen(Qt::NoPen); - painter->drawEllipse(fillRect); - - bool highflag = false; - if (m_isCurrentMonth) { - highflag = CScheduleDataManage::getScheduleDataManage()->getSearchResult(m_date); - } - if (highflag) { - painter->setBrush(QBrush(m_highColor)); - painter->setPen(Qt::NoPen); - painter->drawEllipse(fillRect); - painter->setPen(Qt::SolidLine); - painter->setPen(m_highTextColor); - painter->setFont(m_hightFont); - painter->drawText(fillRect, Qt::AlignCenter, QString::number(m_date.day())); - - } else { - // draw selected cell background circle - if (isSelectedCell) { -// QRectF pixmapRect(QRectF(fillRect.x()-3, -// fillRect.y(), -// fillRect.width()+6, -// fillRect.height()+6)); -// QPixmap pixmap; -// if (m_themetype == 2) -// pixmap = DHiDPIHelper::loadNxPixmap(":/resources/icon/darkchoose30X30_checked .svg"); -// else { -// pixmap = DHiDPIHelper::loadNxPixmap(":/resources/icon/choose30X30_checked .svg"); -// } -// pixmap.setDevicePixelRatio(m_DevicePixelRatio); -// painter->save(); -// painter->setRenderHint(QPainter::Antialiasing); -// painter->setRenderHint(QPainter::HighQualityAntialiasing); -// painter->setRenderHint(QPainter::SmoothPixmapTransform); -// painter->drawPixmap(pixmapRect.toRect(), pixmap); -// painter->restore(); - painter->setBrush(QBrush(m_highColor)); - painter->setPen(Qt::NoPen); - painter->drawEllipse(fillRect); - } - painter->setPen(Qt::SolidLine); - - // draw text of day - if (isSelectedCell) { - painter->setPen(m_selectedTextColor); - } else if (isCurrentDay) { - painter->setPen(m_currentDayTextColor); - } else { - if (m_isCurrentMonth) - painter->setPen(m_defaultTextColor); - else - painter->setPen(m_notCurrentTextColor); - } - painter->setFont(m_dayNumFont); - painter->drawText(fillRect, Qt::AlignCenter, QString::number(m_date.day())); - if (m_vlineflag) { - painter->save(); - painter->setRenderHint(QPainter::Antialiasing); - painter->setRenderHint(QPainter::HighQualityAntialiasing); - painter->setRenderHint(QPainter::SmoothPixmapTransform); - QPen pen; - pen.setWidth(2); - pen.setColor(m_ceventColor); - painter->setPen(pen); - painter->setBrush(QBrush(m_ceventColor)); - painter->setPen(Qt::NoPen); - qreal r = rect.width() * (4 / 25); - if (r < 4) { - r = 4; - } else if ( r > 7) { - r = 7; - } - painter->drawEllipse(QRectF(rect.width() - r+rect.x(), - rect.y(), - r, - r)); - painter->restore(); - } - } -} - -void CMonthDayRect::setLineFlag(const bool flag) -{ - m_vlineflag = flag; -} - -void CMonthDayRect::setDevicePixelRatio(const qreal pixel) -{ - m_DevicePixelRatio = pixel; -} - -void CMonthDayRect::setCurrentRect(CMonthDayRect *currrect) -{ - m_CurrentRect = currrect; -} - diff -Nru dde-calendar-5.7.0.4/src/yearview.h dde-calendar-5.7.0.23/src/yearview.h --- dde-calendar-5.7.0.4/src/yearview.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/yearview.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,200 +0,0 @@ -#ifndef YEARVIEW_H -#define YEARVIEW_H -#include "weekindicator.h" -#include "constants.h" -#include -#include -#include -#include -#include -#include -#include - -#include "calendardbus.h" -#include "schedulestructs.h" -#include "customframe.h" -DWIDGET_USE_NAMESPACE -class CalendarDBus; -class CaLunarDayInfo; -class QLabel; -class CYearSchceduleView; -class CYearSchceduleOutView; -enum CalendarYearDayType { - SO_YFestival = QStyleOption::SO_CustomBase + 0x01, - SO_YWeekends = QStyleOption::SO_CustomBase + 0x02, - SO_YWeekendsAndFestival = SO_YFestival | SO_YWeekends, - SO_YNotCurrentMonth = 0x04, - SO_YNotCurrentMonthFestival = SO_YNotCurrentMonth | SO_YFestival, - SO_YDefault, -}; -//#define M_FLAG 0; - -class CYearMonthView; -class CYearView: public CustomFrame -{ - Q_OBJECT - - Q_PROPERTY(QColor backgroundCircleColor MEMBER m_backgroundCircleColor DESIGNABLE true SCRIPTABLE true) - Q_PROPERTY(QColor weekendsTextColor MEMBER m_weekendsTextColor DESIGNABLE true SCRIPTABLE true) - Q_PROPERTY(QColor topBorderColor MEMBER m_topBorderColor DESIGNABLE true SCRIPTABLE true) - Q_PROPERTY(bool cellSelectable READ cellSelectable WRITE setCellSelectable NOTIFY cellSelectableChanged) -public: - explicit CYearView(QWidget *parent = nullptr); - void setFirstWeekday(int weekday); - int getDateType(const QDate &date); - inline bool cellSelectable() const - { - return m_cellSelectable; - } - void setTheMe(int type = 0); - static void SchceduleViewHide(); - void getInfoAndSetLineFlag(); -signals: - void signalcurrentDateChanged(QDate date); - void cellSelectableChanged(bool cellSelectable) const; - void signaldoubleclickDate(QDate date); - void signalselectMonth(QDate date); - void signalselectWeekwindow(QDate date); - void signalupdateschcedule(); - void signalHideInfo(); - void signalSelectInfo(bool flag); -public slots: - void setCurrentDate(const QDate date, int type = 0); - void setCellSelectable(bool selectable); - void updateInfoWIndow(bool flag); - void slotupdateSchedule(const int id); - void slotDoubleClickDate(const QDate &date); - void slotPressClickDate(const QDate &date); -private: - int getDateIndex(const QDate &date) const; - bool eventFilter(QObject *o, QEvent *e) Q_DECL_OVERRIDE; - void updateDate(); - void createYearSchceduleView(QWidget *parent = nullptr); -protected: - void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; - void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; -protected: - void paintEvent ( QPaintEvent *e) Q_DECL_OVERRIDE; -private: - CustomFrame *m_currentMouth; - QDate m_days[42]; - QDate m_currentDate; - QStringList m_monthList; - int m_selectedCell = -1; - bool m_cellSelectable = true; - - QFont m_momthFont; - - QColor m_topBorderColor = Qt::red; - QColor m_backgroundCircleColor = "#2ca7f8"; - - - QColor m_currentDayTextColor = "#2ca7f8"; - QColor m_weekendsTextColor = Qt::black; - QColor m_festivalTextColor = Qt::black; - - QColor m_cellBackgroundColor = "#FFFFFF" ; - int m_firstWeekDay = 0; - int cellwidth = 20; - int cellheight = 20; - QVBoxLayout *m_hhLayout; - int m_themetype = 1; - - QColor m_bnormalColor = "#FFFFFF"; - int m_radius = 8; - int m_borderframew = 0; - static CYearSchceduleOutView *m_Scheduleview; - bool m_selectFlag = false; - QDate m_selectDate; - - QVector m_vlineflag; //节假日和日程标识 - - CYearMonthView *m_monthView; - QVector m_DateRangeInfo; -}; - -class CMonthDayRect; -class CYearMonthView : public DWidget -{ - Q_OBJECT -public: - CYearMonthView(DWidget *parent = nullptr); - ~CYearMonthView() override; - void setDate(const QDate date[42]); - void setTheMe(int type = 0); - void setLintFlag(const QVector &lineFlag); -private: - void updateSize(); - int getMousePosItem(const QPointF &pos); -protected: - void resizeEvent(QResizeEvent *event) override; - void mousePressEvent(QMouseEvent *event) override; - void mouseDoubleClickEvent(QMouseEvent *event) override; - void mouseReleaseEvent(QMouseEvent *event) override; - void mouseMoveEvent(QMouseEvent *event) override; - void paintEvent(QPaintEvent *event) override; - void leaveEvent(QEvent *event) override; -signals: - void signalPressDate(const QDate &date); - void signalDoubleClickDate(const QDate &date); -private: - QVector m_DayItem; - int m_currentMonth =1; - QVector m_vlineflag; //节假日和日程标识 - bool m_press = false; - int m_pressIndex =0; -}; - - -class CMonthDayRect -{ -public: - enum CellEventType { - CellNormal = 0, - Cellhover = 1, - CellPress = 2 - }; - struct CellColor { - QColor normalColor; - QColor hoverColor; - QColor pressColor; - }; - CMonthDayRect(); - ~CMonthDayRect(); - void setDate(const QDate &date); - QDate getDate()const; - void setCellEvent(const CellEventType &type); - void setIsCurrentMonth(const bool isCurrMonth); - QRectF rect() const; - void setRect(const QRectF &rect); - inline void setRect(qreal x, qreal y, qreal w, qreal h); - void paintItem(QPainter *painter, const QRectF &rect); - void setLineFlag(const bool flag); - - static void setTheMe(int type = 0); - static void setDevicePixelRatio(const qreal pixel); - static void setCurrentRect(CMonthDayRect *currrect); -private: - QFont m_dayNumFont; - QFont m_hightFont; - int m_themetype = 0; - CellEventType m_cellEventType {CellNormal}; - QColor m_highColor = "#0081FF"; - QColor m_highTextColor = "#FFFFFF"; - bool m_vlineflag = false; - QColor m_currentDayTextColor = "#2ca7f8"; - - static QColor m_defaultTextColor; - static QColor m_selectedTextColor; - static QColor m_notCurrentTextColor; - static CellColor m_currentColor; - static QColor m_ceventColor; - static CMonthDayRect *m_CurrentRect; - static qreal m_DevicePixelRatio; - - QRectF m_rect; - QDate m_date; - bool m_isCurrentMonth = false; -}; - -#endif // YEARVIEW_H diff -Nru dde-calendar-5.7.0.4/src/yearwindow.cpp dde-calendar-5.7.0.23/src/yearwindow.cpp --- dde-calendar-5.7.0.4/src/yearwindow.cpp 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/yearwindow.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,687 +0,0 @@ -/* - * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#include "yearwindow.h" -#include "yearview.h" -#include "constants.h" -#include "calendardbus.h" -#include -#include -#include -#include -#include "schcedulesearchview.h" -DGUI_USE_NAMESPACE -CYearWindow::CYearWindow(QWidget *parent): QMainWindow (parent) -{ - initUI(); - initConnection(); - setWindowFlags(Qt::FramelessWindowHint);//去掉标题 - setContentsMargins(0, 0, 0, 0); -} - -CYearWindow::~CYearWindow() -{ - -} - -bool CYearWindow::eventFilter(QObject *watched, QEvent *event) -{ - if (watched == m_today) { - if (event->type() == QEvent::MouseButtonPress) { - slottoday(); - } - } - return QMainWindow::eventFilter(watched, event); -} - -void CYearWindow::mousePressEvent(QMouseEvent *event) -{ - m_YearWidget->slotHideInfo(); - QMainWindow::mousePressEvent(event); -} - -void CYearWindow::resizeEvent(QResizeEvent *event) -{ - Q_UNUSED(event); - m_topWidget->setGeometry(0, 0, this->width(), DDEMonthCalendar::M_YTopHeight); - - if (m_searchfalg) { - m_tmainLayout->setContentsMargins(10, 0, 2, 0); - m_topWidget->setContentsMargins(10, 0, 2, 0); - } else { - m_tmainLayout->setContentsMargins(10, 0, 10, 0); - m_topWidget->setContentsMargins(10, 0, 10, 0); - } -} - -void CYearWindow::setDate(QDate date) -{ - if (!date.isValid()) return; - m_YearWidget->setDate(date); - m_YearWidget->slotcurrentDateChanged(date); - emit signalCurrentDate(date); - slotUpdateCurrentDate(date); -} - -void CYearWindow::initUI() -{ - m_contentBackground = new DFrame(this); - - DPalette anipa = m_contentBackground->palette(); - anipa.setColor(DPalette::Background, "#F8F8F8"); - m_contentBackground->setAutoFillBackground(true); - m_contentBackground->setPalette(anipa); - m_today = new QLabel(this); - m_today->installEventFilter(this); - - QFont todayfont/*("SourceHanSansSC-Normal")*/; - todayfont.setPixelSize(16); - m_today->setFont(todayfont); - m_today->setAlignment(Qt::AlignCenter); - - m_today->setText(QCoreApplication::translate("today", "Today", "Today")); - m_today->setFixedWidth(88); - m_today->setAutoFillBackground(true); - m_today->setFixedHeight(DDEYearCalendar::Y_MLableHeight - 4); - m_prevButton = new DIconButton(DStyle::SP_ArrowLeft, this); - m_prevButton->setFixedWidth(DDEYearCalendar::Y_MLableHeight); - m_prevButton->setFixedHeight(DDEYearCalendar::Y_MLableHeight); - - - m_nextButton = new DIconButton(DStyle::SP_ArrowRight, this); - m_nextButton->setFixedWidth(DDEYearCalendar::Y_MLableHeight); - m_nextButton->setFixedHeight(DDEYearCalendar::Y_MLableHeight); - - m_YearLabel = new QLabel(this); - m_YearLabel->setFixedHeight(DDEYearCalendar::Y_YLableHeight); - //m_currentMouth->setStyleSheet("border: 1px solid rgba(0, 0, 0, 0.05);"); - - QFont t_labelF; -// t_labelF.setFamily("SourceHanSansSC"); - t_labelF.setWeight(QFont::Medium); - t_labelF.setPixelSize(24); - m_YearLabel->setFont(t_labelF); - DPalette pa = m_YearLabel->palette(); - pa.setColor(DPalette::WindowText, QColor("#3B3B3B")); - m_YearLabel->setPalette(pa); - - m_YearLunarLabel = new QLabel(m_contentBackground); - m_YearLunarLabel->setFixedSize(DDEMonthCalendar::M_YLunatLabelWindth, DDEMonthCalendar::M_YLunatLabelHeight); - - QFont ylabelF; -// ylabelF.setFamily("SourceHanSansSC"); - ylabelF.setWeight(QFont::Medium); - ylabelF.setPixelSize(14); - m_YearLunarLabel->setFont(ylabelF); - DPalette Lunapa = m_YearLunarLabel->palette(); - Lunapa.setColor(DPalette::WindowText, QColor("#8A8A8A")); - m_YearLunarLabel->setPalette(Lunapa); - //m_YearLunarLabel->move(116, 27); - - m_YearLunarDayLabel = new QLabel(m_contentBackground); - m_YearLunarDayLabel->setFixedSize(108, DDEMonthCalendar::M_YLunatLabelHeight); - m_YearLunarDayLabel->setFont(ylabelF); - m_YearLunarDayLabel->setPalette(Lunapa); - m_YearLunarDayLabel->setAlignment(Qt::AlignRight); - - - QHBoxLayout *yeartitleLayout = new QHBoxLayout; - yeartitleLayout->setMargin(0); - yeartitleLayout->setSpacing(0); - //yeartitleLayout->setContentsMargins(2, 10, 2, 0); - yeartitleLayout->setContentsMargins(11, 12, 8, 10); - yeartitleLayout->addWidget(m_YearLabel); - - QHBoxLayout *yeartitleLayout1 = new QHBoxLayout; - yeartitleLayout1->setMargin(0); - yeartitleLayout1->setSpacing(0); - //yeartitleLayout1->setContentsMargins(0, 10, 8, 5); - yeartitleLayout1->setContentsMargins(4, 9, 0, 7); - yeartitleLayout1->addWidget(m_YearLunarLabel); - yeartitleLayout1->addSpacing(390); - yeartitleLayout1->addStretch(); - yeartitleLayout1->addWidget(m_YearLunarDayLabel, 0, Qt::AlignVCenter); - - m_todayframe = new CustomFrame(this); - m_todayframe->setContentsMargins(0, 0, 0, 0); - m_todayframe->setRoundState(true, true, true, true); - m_todayframe->setBColor(Qt::white); - m_todayframe->setFixedHeight(DDEYearCalendar::Y_MLableHeight); - m_todayframe->setboreder(1); - QHBoxLayout *todaylayout = new QHBoxLayout; - todaylayout->setMargin(0); - todaylayout->setSpacing(0); - todaylayout->addWidget(m_prevButton); - todaylayout->addWidget(m_today, 0, Qt::AlignCenter); - todaylayout->addWidget(m_nextButton); - m_todayframe->setLayout(todaylayout); - yeartitleLayout1->addSpacing(10); - yeartitleLayout1->addWidget(m_todayframe); - yeartitleLayout->addLayout(yeartitleLayout1); - - m_topWidget = new DWidget(this); - m_topWidget->setLayout(yeartitleLayout); - - - YearWidget_First = new YearFrame(); - YearWidget_Second = new YearFrame(); - - m_StackedWidget = new AnimationStackedWidget(AnimationStackedWidget::TB); - m_StackedWidget->addWidget(YearWidget_First); - m_StackedWidget->addWidget(YearWidget_Second); - m_StackedWidget->setContentsMargins(0, 0, 0, 0); - m_StackedWidget->setDuration(600); - - m_YearWidget = qobject_cast(m_StackedWidget->widget(0)); - QVBoxLayout *hhLayout = new QVBoxLayout; - hhLayout->setMargin(0); - hhLayout->setSpacing(0); - hhLayout->setContentsMargins(0, 0, 0, 0); - hhLayout->addWidget(m_StackedWidget); - - - m_tmainLayout = new QHBoxLayout; - m_tmainLayout->setMargin(0); - m_tmainLayout->setSpacing(0); - m_tmainLayout->setContentsMargins(10, 0, 10, 0); - m_tmainLayout->addLayout(hhLayout); - - m_contentBackground->setContentsMargins(0, 0, 0, 0); - m_contentBackground->setLayout(m_tmainLayout); - - //menuBar()->hide(); - setCentralWidget(m_contentBackground); - -} - -void CYearWindow::initConnection() -{ - connect(m_prevButton, &DIconButton::clicked, this, &CYearWindow::slotprev); - //connect(m_today, &DPushButton::clicked, this, &CYearWindow::slottoday); - connect(m_nextButton, &DIconButton::clicked, this, &CYearWindow::slotnext); - //connect(m_schceduleSearchView, &CSchceduleSearchView::signalsUpdateShcedule, this, &CYearWindow::slotTransitSearchSchedule); - // connect(m_schceduleSearchView, &CSchceduleSearchView::signalDate, this, &CYearWindow::slotsearchDateSelect); - connect(YearWidget_First, - &YearFrame::signaldoubleclickDate, - this, - &CYearWindow::signaldoubleclickDate); - connect(YearWidget_Second, - &YearFrame::signaldoubleclickDate, - this, - &CYearWindow::signaldoubleclickDate); - - connect(YearWidget_First, - &YearFrame::signalselectMonth, - this, - &CYearWindow::signalselectMonth); - - connect(YearWidget_Second, - &YearFrame::signalselectMonth, - this, - &CYearWindow::signalselectMonth); - connect(YearWidget_First, - &YearFrame::signalselectWeekwindow, - this, - &CYearWindow::signalselectWeekwindow); - - connect(YearWidget_Second, - &YearFrame::signalselectWeekwindow, - this, - &CYearWindow::signalselectWeekwindow); - - connect(YearWidget_First, - &YearFrame::signalUpdateYearDate, - this, - &CYearWindow::slotUpdateCurrentDate); - connect(YearWidget_Second, - &YearFrame::signalUpdateYearDate, - this, - &CYearWindow::slotUpdateCurrentDate); - connect(YearWidget_First, - &YearFrame::signalupdateschcedule, - this, - &CYearWindow::signalupdateschcedule); - - connect(m_StackedWidget, - &AnimationStackedWidget::signalIsFinished, - this, - &CYearWindow::setYearData); -} - -void CYearWindow::setLunarVisible(bool state) -{ - m_YearLunarLabel->setVisible(state); - m_YearLunarDayLabel->setVisible(state); -} - -void CYearWindow::setTheMe(int type) -{ - if (type == 0 || type == 1) { - DPalette anipa = m_contentBackground->palette(); - anipa.setColor(DPalette::Background, "#F8F8F8"); - m_contentBackground->setPalette(anipa); - m_contentBackground->setBackgroundRole(DPalette::Background); - - DPalette todaypa = m_today->palette(); - todaypa.setColor(DPalette::WindowText, QColor("#000000")); - todaypa.setColor(DPalette::Background, Qt::white); - //todaypa.setColor(DPalette::Light, Qt::white); - m_today->setPalette(todaypa); - m_today->setForegroundRole(DPalette::WindowText); - m_today->setBackgroundRole(DPalette::Background); - - m_todayframe->setBColor(Qt::white); - - DPalette pa = m_YearLabel->palette(); - pa.setColor(DPalette::WindowText, QColor("#3B3B3B")); - m_YearLabel->setPalette(pa); - m_YearLabel->setForegroundRole(DPalette::WindowText); - - DPalette Lunapa = m_YearLunarLabel->palette(); - Lunapa.setColor(DPalette::WindowText, QColor("#8A8A8A")); - m_YearLunarLabel->setPalette(Lunapa); - m_YearLunarLabel->setForegroundRole(DPalette::WindowText); - - m_YearLunarDayLabel->setPalette(Lunapa); - m_YearLunarDayLabel->setForegroundRole(DPalette::WindowText); - - } else if (type == 2) { - DPalette anipa = m_contentBackground->palette(); - anipa.setColor(DPalette::Background, "#252525"); - m_contentBackground->setPalette(anipa); - m_contentBackground->setBackgroundRole(DPalette::Background); - - DPalette todaypa = m_today->palette(); - todaypa.setColor(DPalette::WindowText, QColor("#C0C6D4")); - //todaypa.setColor(DPalette::Dark, "#414141"); - QColor tbcolor = "#414141"; - tbcolor.setAlphaF(0.0); - todaypa.setColor(DPalette::Background, tbcolor); - m_today->setPalette(todaypa); - m_today->setForegroundRole(DPalette::WindowText); - m_today->setBackgroundRole(DPalette::Background); - QColor tbcolor2 = "#414141"; - tbcolor2.setAlphaF(0.3); - m_todayframe->setBColor(tbcolor2); - DPalette pa = m_YearLabel->palette(); - pa.setColor(DPalette::WindowText, QColor("#C0C6D4")); - m_YearLabel->setPalette(pa); - m_YearLabel->setForegroundRole(DPalette::WindowText); - DPalette Lunapa = m_YearLunarLabel->palette(); - Lunapa.setColor(DPalette::WindowText, QColor("#798BA8")); - m_YearLunarLabel->setPalette(Lunapa); - m_YearLunarLabel->setForegroundRole(DPalette::WindowText); - m_YearLunarDayLabel->setPalette(Lunapa); - m_YearLunarDayLabel->setForegroundRole(DPalette::WindowText); - } - YearWidget_First->setTheMe(type); - YearWidget_Second->setTheMe(type); - - DPalette palette = m_topWidget->palette(); - palette.setBrush(DPalette::WindowText, palette.color(DPalette::Window)); - m_topWidget->setAutoFillBackground(true); - m_topWidget->setPalette(palette); -} -void CYearWindow::setSearchWFlag(bool flag) -{ - m_searchfalg = flag; - m_YearWidget->setSearchWFlag(flag); -} - -void CYearWindow::clearSearch() -{ - //m_schceduleSearchView->clearSearch(); -} - -void CYearWindow::setSearchText(QString str) -{ - m_searchText = str; - // m_schceduleSearchView->slotsetSearch(str); -} - -void CYearWindow::getScheduleInfo() -{ - m_YearWidget->getInfoAndSetLineFlag(); -} - -void CYearWindow::slotTransitSearchSchedule(int id) -{ - // m_schceduleSearchView->slotsetSearch(m_searchText); - emit signalsWUpdateShcedule(this, id); -} - -void CYearWindow::slotSetSchceduleHide() -{ - m_YearWidget->slotHideInfo(); -} - - -void CYearWindow::slotprev() -{ - m_YearWidget->slotHideInfo(); - if (m_currentdate.year() == 1900) return; - if (m_StackedWidget->IsRunning()) return; - QDate tcurrent = QDate(m_currentdate.year() - 1, m_currentdate.month(), m_currentdate.day()); - if (!tcurrent.isValid()) { - m_currentdate = QDate(m_currentdate.year() - 1, m_currentdate.month(), 1); - } else { - m_currentdate = tcurrent; - } - if (m_currentdate.year() >= 1900) { - //m_currentdate = QDate(m_currentdate.year() - 1, m_currentdate.month(), m_currentdate.day()); - int index = m_StackedWidget->currentIndex(); - index = qAbs(index - 1) % 2; - m_YearWidget = qobject_cast(m_StackedWidget->widget(index)); - m_YearWidget->setDate(m_currentdate); - m_StackedWidget->setPre(); - emit signalCurrentDate(m_currentdate); - } else { - //QMessageBox::information(this, tr("infomation"), tr("Year less than 1900!")); - } -} - -void CYearWindow::slotnext() -{ - m_YearWidget->slotHideInfo(); - if (m_StackedWidget->IsRunning()) return; - QDate tcurrent = QDate(m_currentdate.year() + 1, m_currentdate.month(), m_currentdate.day()); - if (!tcurrent.isValid()) { - m_currentdate = QDate(m_currentdate.year() + 1, m_currentdate.month(), 1); - } else { - m_currentdate = tcurrent; - } - int index = m_StackedWidget->currentIndex(); - index = (index + 1) % 2; - m_YearWidget = qobject_cast(m_StackedWidget->widget(index)); - m_YearWidget->setDate(m_currentdate); - m_StackedWidget->setNext(); - emit signalCurrentDate(m_currentdate); - -} - -void CYearWindow::slottoday() -{ - m_YearWidget->slotHideInfo(); - emit signalsReturnTodayUpdate(this); - setDate(QDate::currentDate()); -} - -void CYearWindow::slotReturnTodayUpdate() -{ -} - -void CYearWindow::slotupdateSchedule(const int id) -{ - m_YearWidget->slotupdateSchedule(id); -} - -void CYearWindow::slotUpdateCurrentDate(const QDate &date) -{ - m_currentdate = date; - setYearData(); -} - -void CYearWindow::setYearData() -{ - - if (m_currentdate == QDate::currentDate()) { - m_today->setText(QCoreApplication::translate("today", "Today", "Today")); - } else { - m_today->setText(QCoreApplication::translate("Return", "Today", "Return")); - } - QLocale locale; - if (locale.language() == QLocale::Chinese) { - m_YearLabel->setText(QString::number(m_currentdate.year()) + tr("Y")); - } else { - m_YearLabel->setText(QString::number(m_currentdate.year())); - } - m_YearLunarLabel->setText(m_YearWidget->getLunarYear()); - m_YearLunarDayLabel->setText(m_YearWidget->getLunarDay()); -} -void CYearWindow::slotsearchDateSelect(QDate date) -{ - setDate(date); -} - - -void CYearWindow::wheelEvent(QWheelEvent *event) -{ -// for (int i = 0; i < 12; i++) { -// m_monthViewList.at(i)->updateInfoWIndow(false); -// } - if (event->delta() < 0) { - slotnext(); - } else { - slotprev(); - } -} - -YearFrame::YearFrame(DWidget *parent): DFrame (parent) -{ - m_DBusInter = new CalendarDBus("com.deepin.api.LunarCalendar", - "/com/deepin/api/LunarCalendar", - QDBusConnection::sessionBus(), this); - - - QGridLayout *gridLayout = new QGridLayout; - gridLayout->setMargin(0); - gridLayout->setSpacing(8); - gridLayout->setContentsMargins(0, 0, 0, 0); - for (int i = 0; i < 3; i++) { - for (int j = 0; j < 4; j++) { - CYearView *view = new CYearView(this); - connect(view, &CYearView::signalcurrentDateChanged, this, &YearFrame::slotcurrentDateChanged); - connect(view, &CYearView::signaldoubleclickDate, this, &YearFrame::signaldoubleclickDate); - connect(view, &CYearView::signalselectWeekwindow, this, &YearFrame::signalselectWeekwindow); - connect(view, &CYearView::signalupdateschcedule, this, &YearFrame::signalupdateschcedule); - connect(view, &CYearView::signalselectMonth, this, &YearFrame::signalselectMonth); - connect(view, &CYearView::signalHideInfo, this, &YearFrame::slotHideInfo); - connect(view, &CYearView::signalSelectInfo, this, &YearFrame::slotSelectInfo); - gridLayout->addWidget(view, i, j); - m_monthViewList.append(view); - } - } - - m_YearLabel = new QLabel(this); - m_YearLabel->setFixedHeight(DDEYearCalendar::Y_YLableHeight); - //m_currentMouth->setStyleSheet("border: 1px solid rgba(0, 0, 0, 0.05);"); - - QFont t_labelF; -// t_labelF.setFamily("SourceHanSansSC"); - t_labelF.setWeight(QFont::Medium); - t_labelF.setPixelSize(24); - m_YearLabel->setFont(t_labelF); - DPalette pa = m_YearLabel->palette(); - pa.setColor(DPalette::WindowText, QColor("#3B3B3B")); - m_YearLabel->setPalette(pa); - - m_YearLunarLabel = new QLabel(); - m_YearLunarLabel->setFixedSize(DDEMonthCalendar::M_YLunatLabelWindth, DDEMonthCalendar::M_YLunatLabelHeight); - - QFont ylabelF; -// ylabelF.setFamily("SourceHanSansSC"); - ylabelF.setWeight(QFont::Medium); - ylabelF.setPixelSize(14); - m_YearLunarLabel->setFont(ylabelF); - DPalette Lunapa = m_YearLunarLabel->palette(); - Lunapa.setColor(DPalette::WindowText, QColor("#8A8A8A")); - m_YearLunarLabel->setPalette(Lunapa); - - - QHBoxLayout *yeartitleLayout = new QHBoxLayout; - yeartitleLayout->setMargin(0); - yeartitleLayout->setSpacing(0); - //yeartitleLayout->setContentsMargins(2, 10, 2, 0); - yeartitleLayout->setContentsMargins(11, 12, 8, 10); - yeartitleLayout->addWidget(m_YearLabel); - - QHBoxLayout *yeartitleLayout1 = new QHBoxLayout; - yeartitleLayout1->setMargin(0); - yeartitleLayout1->setSpacing(0); - //yeartitleLayout1->setContentsMargins(0, 10, 8, 5); - yeartitleLayout1->setContentsMargins(4, 9, 0, 7); - yeartitleLayout1->addWidget(m_YearLunarLabel); - yeartitleLayout1->addSpacing(390); - yeartitleLayout1->addStretch(); - yeartitleLayout1->addSpacing(10); - yeartitleLayout->addLayout(yeartitleLayout1); - - m_topWidget = new DWidget(); - m_topWidget->setLayout(yeartitleLayout); - m_topWidget->setFixedHeight(DDEMonthCalendar::M_YTopHeight); - QVBoxLayout *hhLayout = new QVBoxLayout; - hhLayout->setMargin(0); - hhLayout->setSpacing(0); - hhLayout->setContentsMargins(0, 0, 0, 0); - hhLayout->addWidget(m_topWidget); - hhLayout->addLayout(gridLayout); - this->setLayout(hhLayout); - setContentsMargins(0, 0, 0, 10); - setFrameRounded(true); -// m_topWidget->hide(); -} - -YearFrame::~YearFrame() -{ - -} - -void YearFrame::setDate(QDate &date) -{ - if (!date.isValid()) return; - m_currentdate = date; - for (int i = 0; i < 12; i++) { - QDate tdate(m_currentdate.year(), i + 1, 1); - m_monthViewList.at(i)->setCurrentDate(tdate, 0); - } - for (int i = 0; i < 12; i++) { - QDate tdate(m_currentdate.year(), i + 1, 1); - if (date.year() == tdate.year() && date.month() == tdate.month()) { - m_monthViewList.at(i)->setCurrentDate(date, 1); - break; - } - } - getLunarData(); -} - -void YearFrame::getInfoAndSetLineFlag() -{ - for (int i = 0; i < 12; i++) { - m_monthViewList.at(i)->getInfoAndSetLineFlag(); - } -} - -void YearFrame::setTheMe(int type) -{ - if (type == 0 || type == 1) { - DPalette gpa = palette(); - gpa.setColor(DPalette::Background, "#F8F8F8"); - setPalette(gpa); - setBackgroundRole(DPalette::Background); - - DPalette pa = m_YearLabel->palette(); - pa.setColor(DPalette::WindowText, QColor("#3B3B3B")); - m_YearLabel->setPalette(pa); - m_YearLabel->setForegroundRole(DPalette::WindowText); - - DPalette Lunapa = m_YearLunarLabel->palette(); - Lunapa.setColor(DPalette::WindowText, QColor("#8A8A8A")); - m_YearLunarLabel->setPalette(Lunapa); - m_YearLunarLabel->setForegroundRole(DPalette::WindowText); - - } else if (type == 2) { - DPalette gpa = palette(); - gpa.setColor(DPalette::Background, "#252525"); - setPalette(gpa); - setBackgroundRole(DPalette::Background); - - DPalette pa = m_YearLabel->palette(); - pa.setColor(DPalette::WindowText, QColor("#C0C6D4")); - m_YearLabel->setPalette(pa); - m_YearLabel->setForegroundRole(DPalette::WindowText); - DPalette Lunapa = m_YearLunarLabel->palette(); - Lunapa.setColor(DPalette::WindowText, QColor("#798BA8")); - m_YearLunarLabel->setPalette(Lunapa); - m_YearLunarLabel->setForegroundRole(DPalette::WindowText); - } - for (int i = 0; i < 12; i++) { - m_monthViewList.at(i)->setTheMe(type); - } - -} - -void YearFrame::setSearchWFlag(bool flag) -{ - m_searchfalg = flag; -} - -void YearFrame::getLunarData() -{ - bool o1 = true; - QDBusReply replydd = m_DBusInter->GetLunarInfoBySolar(m_currentdate.year(), m_currentdate.month(), m_currentdate.day(), o1); - CaLunarDayInfo currentDayInfo = replydd.value(); - m_LunarYear = QString("-%0%1年-").arg(currentDayInfo.mGanZhiYear).arg(currentDayInfo.mZodiac); - m_LunarDay = QString("-农历%0%1-").arg(currentDayInfo.mLunarMonthName).arg(currentDayInfo.mLunarDayName); - QLocale locale; - if (locale.language() == QLocale::Chinese) { - m_YearLabel->setText(QString::number(m_currentdate.year()) + tr("Y")); - m_YearLunarLabel->setText(m_LunarYear); - } else { - m_YearLabel->setText(QString::number(m_currentdate.year())); - m_YearLunarLabel->setText(""); - } - -} - -void YearFrame::mousePressEvent(QMouseEvent *event) -{ - if (m_selectFlag) return; - if (event->button() == Qt::LeftButton) { - slotHideInfo(); - } -} - -void YearFrame::slotcurrentDateChanged(QDate date) -{ - m_currentdate = date; - getLunarData(); - emit signalUpdateYearDate(date); -} - - -void YearFrame::slotHideInfo() -{ - CYearView::SchceduleViewHide(); -} - -void YearFrame::slotSelectInfo(bool flag) -{ - m_selectFlag = flag; -} - -void YearFrame::slotupdateSchedule(const int id) -{ - for (int i =0; i < m_monthViewList.size(); ++i) { - m_monthViewList.at(i)->slotupdateSchedule(id); - } -} - -void YearFrame::slotSetSchceduleHide() -{ - CYearView::SchceduleViewHide(); -} diff -Nru dde-calendar-5.7.0.4/src/yearwindow.h dde-calendar-5.7.0.23/src/yearwindow.h --- dde-calendar-5.7.0.4/src/yearwindow.h 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/src/yearwindow.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,149 +0,0 @@ -/* - * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: kirigaya - * - * 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 - * 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 . - */ -#ifndef YEARWINDOW_H -#define YEARWINDOW_H - -#include -#include -#include -#include -#include -#include -#include -#include "calendardbus.h" -#include -#include -#include -#include "customframe.h" -#include "animationstackedwidget.h" -DWIDGET_USE_NAMESPACE - -class CYearView; -class CaLunarDayInfo; -class CSchceduleSearchView; -class YearFrame; -class CYearWindow: public QMainWindow -{ - Q_OBJECT -public: - CYearWindow(QWidget *parent = nullptr); - ~CYearWindow() Q_DECL_OVERRIDE; - void setDate(QDate date); - void initUI(); - void initConnection(); - void setLunarVisible(bool state); - void setTheMe(int type = 0); - void setSearchWFlag(bool flag); - void clearSearch(); - void setSearchText(QString str); - void getScheduleInfo(); -signals: - void dateSelected(const QDate date, const CaLunarDayInfo &detail) const; - void signalsReturnTodayUpdate(QMainWindow *w); - void signalsWUpdateShcedule(QMainWindow *w, int id = 0); - void signaldoubleclickDate(QDate date); - void signalselectMonth(QDate date); - void signalselectWeekwindow(QDate date); - void signalCurrentDate(QDate date); - void signalupdateschcedule(); -private slots: - void slotprev(); - void slotnext(); - void slottoday(); - void slotsearchDateSelect(QDate date); - void slotTransitSearchSchedule(int id = 0); -public slots: - void slotSetSchceduleHide(); - void slotReturnTodayUpdate(); - void slotupdateSchedule(const int id); - void setYearData(); - void slotUpdateCurrentDate(const QDate &date); -protected: - void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE; - bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE; - void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; -private: - DFrame *m_contentBackground = nullptr; - DIconButton *m_prevButton = nullptr; - DIconButton *m_nextButton = nullptr; - QLabel *m_today = nullptr; - QDate m_currentdate; - QLabel *m_YearLabel; - QLabel *m_YearLunarLabel; - QLabel *m_YearLunarDayLabel; - YearFrame *m_YearWidget; - YearFrame *YearWidget_First; - YearFrame *YearWidget_Second; - CustomFrame *m_todayframe; - AnimationStackedWidget *m_StackedWidget; - //CSchceduleSearchView *m_schceduleSearchView; - QHBoxLayout *m_tmainLayout; - QString m_searchText; - bool m_searchfalg = false; - DWidget *m_topWidget; -}; - -class YearFrame : public DFrame -{ - Q_OBJECT -public: - explicit YearFrame(DWidget *parent = nullptr); - ~YearFrame() Q_DECL_OVERRIDE; - void setDate(QDate &date); - void getInfoAndSetLineFlag(); - void setTheMe(int type = 0); - void setSearchWFlag(bool flag); - QString getLunarYear()const - { - return m_LunarYear; - } - QString getLunarDay()const - { - return m_LunarDay; - } - void getLunarData(); -protected: - void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; -signals: - void signaldoubleclickDate(QDate date); - void signalselectWeekwindow(QDate date); - void signalselectMonth(QDate date); - void signalUpdateYearDate(const QDate &date); - void signalupdateschcedule(); -public slots: - void slotHideInfo(); - void slotSelectInfo(bool flag); - void slotupdateSchedule(const int id); - void slotSetSchceduleHide(); - void slotcurrentDateChanged(QDate date); -private: - QList m_monthViewList; - QLabel *m_YearLabel; - QLabel *m_YearLunarLabel; - CalendarDBus *m_DBusInter; - QDate m_currentdate; - bool m_searchfalg = false; - bool m_selectFlag = false; - QString m_LunarYear; - QString m_LunarDay; - DWidget *m_topWidget; -}; - -#endif // YEARWINDOW_H diff -Nru dde-calendar-5.7.0.4/.transifexrc dde-calendar-5.7.0.23/.transifexrc --- dde-calendar-5.7.0.4/.transifexrc 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/.transifexrc 2020-11-03 09:03:22.000000000 +0000 @@ -1,6 +1,6 @@ [https://www.transifex.com] api_hostname = https://api.transifex.com hostname = https://www.transifex.com -password = 1/fed29a347a3f79abfe438d15d1af9dceac2ba39d +password = 1/2847330938c2eebc627c8dd113ba4f58aeb3fd3d username = api diff -Nru dde-calendar-5.7.0.4/translations/dde-calendar_bo.ts dde-calendar-5.7.0.23/translations/dde-calendar_bo.ts --- dde-calendar-5.7.0.4/translations/dde-calendar_bo.ts 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/translations/dde-calendar_bo.ts 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1,651 @@ + + + CDayMonthView + + Monday + གཟའ་ཟླ་བ། + + + Tuesday + གཟའ་མིག་དམར། + + + Wednesday + གཟའ་ལྷག་པ། + + + Thursday + གཟའ་ཕུར་བུ། + + + Friday + གཟའ་པ་སངས། + + + Saturday + གཟའ་སྤེན་པ། + + + Sunday + གཟའ་ཉི་མ། + + + + CDayWindow + + Y + ལོ། + + + M + ཟླ། + + + D + ཚེས། + + + + CGraphicsView + + New Event + ལས་རིམ་གསར་པ། + + + + CMonthGraphiview + + Delete + སུབ་པ། + + + You are deleting an event. + ཁྱེད་ཀྱིས་ལས་རིམ་སུབ་བཞིན་ཡོད། + + + Are you sure you want to delete this event? + ཁྱེད་ཀྱིས་ལས་རིམ་འདི་དངོས་གནས་སུབ་བམ། + + + Cancel + ཕྱིར་འཐེན། + + + Do you want to delete all occurrences of this event, or only the selected occurrence? + ཁྱེད་ཀྱིས་ལས་རིམ་འདིའི་བསྐྱར་ཟློས་ཚང་མ་སུབ་དགོས། ཡང་ན་བདམས་པའི་བསྐྱར་ཟློས་སལ་རིམ་སུབ་དགོས། + + + Delete All + ཚང་མ་སུབ་པ། + + + Delete Only This Event + ལས་རིམ་འདི་གཅིག་པུ་སུབ་དགོས། + + + Do you want to delete this and all future occurrences of this event, or only the selected occurrence? + ཁྱེད་ཀྱིས་ལས་རིམ་འདིའི་བསྐྱར་ཟློས་འདི་དང་ཕྱིན་ཆད་ཀྱི་བསྐྱར་ཟློས་ཚང་མ་སུབ་དགོས། ཡང་ན་བདམས་པའི་བསྐྱར་ཟློས་ལས་རིམ་སུབ་དགོས། + + + Delete All Future Events + མ་འོང་གི་ལས་རིམ་ཚང་མ་སུབ་དགོས། + + + + CMonthSchceduleNumButton + + %1 more + ད་དུང་%1ཡོད། + + + + CMonthView + + New event + ལས་རིམ་གསར་པ། + + + New Event + ལས་རིམ་གསར་པ། + + + + CMonthWindow + + Y + ལོ། + + + + CMySchceduleView + + You are deleting an event. + ཁྱེད་ཀྱིས་ལས་རིམ་སུབ་བཞིན་ཡོད། + + + Are you sure you want to delete this event? + ཁྱེད་ཀྱིས་ལས་རིམ་འདི་དངོས་གནས་སུབ་བམ། + + + Cancel + ཕྱིར་འཐེན། + + + Delete + སུབ་པ། + + + Do you want to delete all occurrences of this event, or only the selected occurrence? + ཁྱེད་ཀྱིས་ལས་རིམ་འདིའི་བསྐྱར་ཟློས་ཚང་མ་སུབ་དགོས། ཡང་ན་བདམས་པའི་བསྐྱར་ཟློས་ལས་རིམ་སུབ་དགོས། + + + Delete All + ཚང་མ་སུབ་པ། + + + Delete Only This Event + ལས་རིམ་འདི་གཅིག་པུ་སུབ་དགོས། + + + Do you want to delete this and all future occurrences of this event, or only the selected occurrence? + ཁྱེད་ཀྱིས་ལས་རིམ་འདིའི་བསྐྱར་ཟློས་འདི་དང་ཕྱིན་ཆད་ཀྱི་བསྐྱར་ཟློས་ཚང་མ་སུབ་དགོས། ཡང་ན་བདམས་པའི་བསྐྱར་ཟློས་ལས་རིམ་སུབ་དགོས། + + + My Event + ངའི་ལས་རིམ། + + + Edit + རྩོམ་སྒྲིག + + + OK + གཏན་ཁེལ། + + + Delete All Future Events + མ་འོང་གི་ལས་རིམ་ཚང་མ་སུབ་དགོས། + + + + CSchceduleDlg + + New Event + ལས་རིམ་གསར་པ། + + + Edit Event + ལས་རིམ་རྩོམ་སྒྲིག + + + All occurrences of a repeating event must have the same all-day status. + བསྐྱར་ཟློས་ཡིན་པའི་ལས་རིམ་ཚང་མ་ཉིན་གང་གི་གནས་ཚུལ་གཅིག་པ་ཡིན་དགོས། + + + Do you want to change all occurrences? + ཁྱེད་ཀྱིས་བསྐྱར་ཟློས་ཚང་མ་སྒྱུར་དགོས་སམ། + + + Cancel + ཕྱིར་འཐེན། + + + Change All + ཚང་མ་སྒྱུར་བ། + + + You are changing the repeating rule of this event. + ཁྱེད་ཀྱིས་བསྐྱར་ཟློས་ཡིན་པའི་ལས་རིམ་གྱི་སྒྲིག་སྲོལ་སྒྱུར་བཞིན་ཡོད། + + + You are changing a repeating event. + ཁྱེད་ཀྱིས་བསྐྱར་ཟློས་ཡིན་པའི་ལས་རིམ་སྒྱུར་བཞིན་ཡོད། + + + Do you want to change only this occurrence of the event, or all occurrences? + ཁྱེད་ཀྱིས་ལས་རིམ་འདིའི་བསྐྱར་ཟློས་གཅིག་པུ་འདི་སྒྱུར་དགོས་སམ། ཡང་ན་དེའི་བསྐྱར་ཟློས་ཚང་མ་སྒྱུར་དགོས། + + + All + ཚང་མ། + + + Only This Event + ལས་རིམ་འདི་གཅིག་པུ། + + + Do you want to change only this occurrence of the event, or this and all future occurrences? + ཁྱེད་ཀྱིས་ལས་རིམ་འདིའི་བསྐྱར་ཟློས་འདི་དང་ཕྱིན་ཆད་ཀྱི་བསྐྱར་ཟློས་ཚང་མ་སྒྱུར་དགོས་སམ། ཡང་ན་བདམས་པའི་བསྐྱར་ཟློས་སྒྱུར་དགོས། + + + All Future Events + མ་འོངས་ཀྱི་ལས་རིམ་ཚང་མ། + + + Never + ནམ་ཡང་མིན། + + + At time of event + ལས་རིམ་འགོ་འཛུགས་དུས། + + + 15 minutes before + སྐར་མ་15སྔོན་ལ། + + + 30 minutes before + སྐར་མ་30སྔོན་ལ། + + + 1 hour before + ཆུ་ཚོད་1སྔོན་ལ། + + + 1 day before + ཉིན་1སྔོན་ལ། + + + 2 days before + ཉིན་2སྔོན་ལ། + + + 1 week before + གཟའ་འཁོར་1སྔོན་ལ། + + + On start day (9:00 AM) + ལས་རིམ་འགོ་ཚུགས་པའི་ཉིན།(སྔ་དྲོའི་ཆུ་ཚོད་9པ།) + + + Type: + རིགས་གྲས། + + + All Day: + ཉིན་གང་། + + + Remind Me: + དྲན་སྐུལ། + + + Repeat: + བསྐྱར་ཟློས། + + + Daily + ཉིན་རེ། + + + Weekdays + ལས་ཀའི་ཉིན་གྲངས། + + + Weekly + བདུན་རེ། + + + Monthly + ཟླ་རེ། + + + Yearly + ལོ་རེ། + + + End Repeat: + བསྐྱར་ཟློས་མཇུག་འགྲིལ་བ། + + + After + རྗེས་ལ། + + + On + ལ། + + + time(s) + ཐེངས་གྲངས། + + + Save + ཉར་གསོག་ + + + New event + ལས་རིམ་གསར་པ། + + + End time must be greater than start time + མཇུག་འགྲིལ་བའི་དུས་ཚོད་འགོ་འཛུགས་དུས་ཚོད་ལས་འཕྱི་བ་དགོས། + + + OK + གཏན་ཁེལ། + + + Type + རིགས་གྲས། + + + All Day + ཉིན་གང་། + + + Starts + འགོ་འཛུགས་དུས་ཚོད། + + + Ends + མཇུག་སྒྲིལ་དུས་ཚོད། + + + Remind Me + དྲན་སྐུལ། + + + Repeat + བསྐྲར་ཟློས། + + + End Repeat + བསྐྱར་ཟློས་མཇུག་འགྲིལ་བ། + + + Ends: + མཇུག་སྒྲིལ་དུས་ཚོད། + + + Description: + ནང་དོན། + + + Description + ནང་དོན། + + + Starts: + འགོ་འཛུགས་དུས་ཚོད། + + + Work + ལས་ཀ + + + Life + འཆོ་བ། + + + Other + གཞན་དག + + + + CSchceduleSearchDateItem + + Y + ལོ། + + + M + ཟླ། + + + D + ཉིན། + + + + CSchceduleSearchItem + + Edit + རྩོམ་སྒྲིག + + + Delete + སུབ་པ། + + + You are deleting an event. + ཁྱེད་ཀྱིས་ལས་རིམ་སུབ་བཞིན་ཡོད། + + + Are you sure you want to delete this event? + ཁྱེད་ཀྱིས་ལས་རིམ་འདི་དངོས་གནས་སུབ་བམ། + + + Cancel + ཕྱིར་འཐེན། + + + Do you want to delete all occurrences of this event, or only the selected occurrence? + ཁྱེད་ཀྱིས་ལས་རིམ་འདིའི་བསྐྱར་ཟློས་ཚང་མ་སུབ་དགོས། ཡང་ན་བདམས་པའི་བསྐྱར་ཟློས་སལ་རིམ་སུབ་དགོས། + + + Delete All + ཚང་མ་སུབ་པ། + + + Delete Only This Event + ལས་རིམ་འདི་གཅིག་པུ་སུབ་དགོས། + + + Do you want to delete this and all future occurrences of this event, or only the selected occurrence? + ཁྱེད་ཀྱིས་ལས་རིམ་འདིའི་བསྐྱར་ཟློས་འདི་དང་ཕྱིན་ཆད་ཀྱི་བསྐྱར་ཟློས་ཚང་མ་སུབ་དགོས། ཡང་ན་བདམས་པའི་བསྐྱར་ཟློས་ལས་རིམ་སུབ་དགོས། + + + Delete All Future Events + མ་འོང་གི་ལས་རིམ་ཚང་མ་སུབ་དགོས། + + + All Day + ཉིན་གང་། + + + + CSchceduleSearchView + + No search results + འཚོལ་ཞིབ་བྱས་འབྲས་མེད། + + + + CScheduleView + + ALL DAY + ཉིན་གང་། + + + + CWeekWindow + + Week + གཟའ་འཁོར། + + + Y + ལོ། + + + + CYearSchceduleItem + + All Day + ཉིན་གང་། + + + + CYearSchceduleView + + All Day + ཉིན་གང་། + + + No event + ལས་རིམ་མེད། + + + + CYearWindow + + Y + ལོ། + + + + CalendarWindow + + Calendar + ལོ་ཐོ། + + + Calendar is a tool to view dates, and also a smart daily planner to schedule all things in life. + ལོ་ཐོ་ནི་ཚེས་གྲངས་བལྟ་བ་དང་ལས་རིམ་དོ་དམ་བྱེད་པའི་ཡོ་བྱད་ཆུང་ཆུང་ཞིག་རེད། + + + + Calendarmainwindow + + Calendar + ལོ་ཐོ། + + + Y + ལོ། + + + M + ཟླ། + + + W + གཟའ། + + + D + ཉིན། + + + + CenterWidget + + All Day + ཉིན་གང་། + + + + DragInfoGraphicsView + + Edit + རྩོམ་སྒྲིག + + + Delete + སུབ་པ། + + + New event + ལས་རིམ་གསར་པ། + + + You are deleting an event. + ཁྱེད་ཀྱིས་ལས་རིམ་སུབ་བཞིན་ཡོད། + + + Are you sure you want to delete this event? + ཁྱེད་ཀྱིས་ལས་རིམ་འདི་དངོས་གནས་སུབ་བམ། + + + Cancel + ཕྱིར་འཐེན། + + + Do you want to delete all occurrences of this event, or only the selected occurrence? + ཁྱེད་ཀྱིས་ལས་རིམ་འདིའི་བསྐྱར་ཟློས་ཚང་མ་སུབ་དགོས། ཡང་ན་བདམས་པའི་བསྐྱར་ཟློས་སལ་རིམ་སུབ་དགོས། + + + Delete All + ཚང་མ་སུབ་པ། + + + Delete Only This Event + ལས་རིམ་འདི་གཅིག་པུ་སུབ་དགོས། + + + Do you want to delete this and all future occurrences of this event, or only the selected occurrence? + ཁྱེད་ཀྱིས་ལས་རིམ་འདིའི་བསྐྱར་ཟློས་འདི་དང་ཕྱིན་ཆད་ཀྱི་བསྐྱར་ཟློས་ཚང་མ་སུབ་དགོས། ཡང་ན་བདམས་པའི་བསྐྱར་ཟློས་ལས་རིམ་སུབ་དགོས། + + + Delete All Future Events + མ་འོང་གི་ལས་རིམ་ཚང་མ་སུབ་དགོས། + + + New Event + ལས་རིམ་གསར་པ། + + + + Return + + Today + Return + དེ་རིང་། + + + + Return Today + + Today + Return Today + དེ་རིང་། + + + + Shortcut + + Help + རོགས་རམ། + + + Delete event + ལས་རིམ་སུབ་པ། + + + Copy + མཁོ་ཕབ། + + + Cut + དྲས་གཏུབ། + + + Paste + སྦྱར་བ། + + + Select all + ཡོངས་འདེམས། + + + Delete + སུབ་པ། + + + + YearFrame + + Y + ལོ། + + + + today + + Today + Today + དེ་རིང་། + + + \ No newline at end of file diff -Nru dde-calendar-5.7.0.4/translations/dde-calendar_ca.ts dde-calendar-5.7.0.23/translations/dde-calendar_ca.ts --- dde-calendar-5.7.0.4/translations/dde-calendar_ca.ts 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/translations/dde-calendar_ca.ts 2020-11-03 09:03:22.000000000 +0000 @@ -124,7 +124,7 @@ Are you sure you want to delete this event? - Esteu segur que voleu suprimir aquest esdeveniment? + Segur que voleu eliminar aquest esdeveniment? Cancel @@ -413,7 +413,7 @@ Are you sure you want to delete this event? - Esteu segur que voleu suprimir aquest esdeveniment? + Segur que voleu eliminar aquest esdeveniment? Cancel diff -Nru dde-calendar-5.7.0.4/translations/dde-calendar_cs.ts dde-calendar-5.7.0.23/translations/dde-calendar_cs.ts --- dde-calendar-5.7.0.4/translations/dde-calendar_cs.ts 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/translations/dde-calendar_cs.ts 2020-11-03 09:03:22.000000000 +0000 @@ -68,7 +68,7 @@ Cancel - Storno + Zrušit Do you want to delete all occurrences of this event, or only the selected occurrence? @@ -128,7 +128,7 @@ Cancel - Storno + Zrušit Delete @@ -187,7 +187,7 @@ Cancel - Storno + Zrušit Change All @@ -417,7 +417,7 @@ Cancel - Storno + Zrušit Do you want to delete all occurrences of this event, or only the selected occurrence? @@ -502,7 +502,7 @@ Calendar is a tool to view dates, and also a smart daily planner to schedule all things in life. - Kalendář slouží k zobrazování datumů a také jako chytrý každodenní plánovač všeho v životě. + Kalendář slouží k zobrazování dat a také jako chytrý každodenní plánovač všeho v životě. @@ -559,7 +559,7 @@ Cancel - Storno + Zrušit Do you want to delete all occurrences of this event, or only the selected occurrence? diff -Nru dde-calendar-5.7.0.4/translations/dde-calendar_en_AU.ts dde-calendar-5.7.0.23/translations/dde-calendar_en_AU.ts --- dde-calendar-5.7.0.4/translations/dde-calendar_en_AU.ts 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/translations/dde-calendar_en_AU.ts 2020-11-03 09:03:22.000000000 +0000 @@ -1,132 +1,130 @@ - - - + CDayMonthView Monday - + Monday Tuesday - + Tuesday Wednesday - + Wednesday Thursday - + Thursday Friday - + Friday Saturday - + Saturday Sunday - + Sunday CDayWindow Y - + Y M - + M D - + D CGraphicsView New Event - + New Event CMonthGraphiview Delete - Delete + Delete You are deleting an event. - + You are deleting an event. Are you sure you want to delete this event? - + Are you sure you want to delete this event? Cancel - Cancel + Cancel Do you want to delete all occurrences of this event, or only the selected occurrence? - + Do you want to delete all occurrences of this event, or only the selected occurrence? Delete All - + Delete All Delete Only This Event - + Delete Only This Event Do you want to delete this and all future occurrences of this event, or only the selected occurrence? - + Do you want to delete this and all future occurrences of this event, or only the selected occurrence? Delete All Future Events - + Delete All Future Events CMonthSchceduleNumButton %1 more - + %1 more CMonthView New event - + New event New Event - + New Event CMonthWindow Y - + Y CMySchceduleView You are deleting an event. - + You are deleting an event. Are you sure you want to delete this event? - + Are you sure you want to delete this event? Cancel @@ -138,23 +136,23 @@ Do you want to delete all occurrences of this event, or only the selected occurrence? - + Do you want to delete all occurrences of this event, or only the selected occurrence? Delete All - + Delete All Delete Only This Event - + Delete Only This Event Do you want to delete this and all future occurrences of this event, or only the selected occurrence? - + Do you want to delete this and all future occurrences of this event, or only the selected occurrence? My Event - + My Event Edit @@ -166,26 +164,26 @@ Delete All Future Events - + Delete All Future Events CSchceduleDlg New Event - + New Event Edit Event - + Edit Event All occurrences of a repeating event must have the same all-day status. - + All occurrences of a repeating event must have the same all-day status. Do you want to change all occurrences? - + Do you want to change all occurrences? Cancel @@ -193,35 +191,35 @@ Change All - + Change All You are changing the repeating rule of this event. - + You are changing the repeating rule of this event. You are changing a repeating event. - + You are changing a repeating event. Do you want to change only this occurrence of the event, or all occurrences? - + Do you want to change only this occurrence of the event, or all occurrences? All - + All Only This Event - + Only This Event Do you want to change only this occurrence of the event, or this and all future occurrences? - + Do you want to change only this occurrence of the event, or this and all future occurrences? All Future Events - + All Future Events Never @@ -229,35 +227,35 @@ At time of event - + At time of event 15 minutes before - + 15 minutes before 30 minutes before - + 30 minutes before 1 hour before - + 1 hour before 1 day before - + 1 day before 2 days before - + 2 days before 1 week before - + 1 week before On start day (9:00 AM) - + On start day (9:00 AM) Type: @@ -265,43 +263,43 @@ All Day: - + All Day: Remind Me: - + Remind Me: Repeat: - + Repeat: Daily - + Daily Weekdays - + Weekdays Weekly - + Weekly Monthly - + Monthly Yearly - + Yearly End Repeat: - + End Repeat: After - + After On @@ -309,7 +307,7 @@ time(s) - + time(s) Save @@ -317,11 +315,11 @@ New event - + New event End time must be greater than start time - + End time must be greater than start time OK @@ -333,19 +331,19 @@ All Day - + All Day Starts - + Starts Ends - + Ends Remind Me - + Remind Me Repeat @@ -353,23 +351,23 @@ End Repeat - + End Repeat Ends: - + Ends: Description: - + Description: Description - + Description Starts: - + Starts: Work @@ -388,15 +386,15 @@ CSchceduleSearchDateItem Y - + Y M - + M D - + D @@ -411,11 +409,11 @@ You are deleting an event. - + You are deleting an event. Are you sure you want to delete this event? - + Are you sure you want to delete this event? Cancel @@ -423,27 +421,27 @@ Do you want to delete all occurrences of this event, or only the selected occurrence? - + Do you want to delete all occurrences of this event, or only the selected occurrence? Delete All - + Delete All Delete Only This Event - + Delete Only This Event Do you want to delete this and all future occurrences of this event, or only the selected occurrence? - + Do you want to delete this and all future occurrences of this event, or only the selected occurrence? Delete All Future Events - + Delete All Future Events All Day - + All Day @@ -457,43 +455,43 @@ CScheduleView ALL DAY - + ALL DAY CWeekWindow Week - + Week Y - + Y CYearSchceduleItem All Day - + All Day CYearSchceduleView All Day - + All Day No event - + No event CYearWindow Y - + Y @@ -504,7 +502,7 @@ Calendar is a tool to view dates, and also a smart daily planner to schedule all things in life. - + Calendar is a tool to view dates, and also a smart daily planner to schedule all things in life. @@ -515,77 +513,77 @@ Y - + Y M - + M W - + W D - + D CenterWidget All Day - + All Day DragInfoGraphicsView Edit - Edit + Edit Delete - Delete + Delete New event - + New event You are deleting an event. - + You are deleting an event. Are you sure you want to delete this event? - + Are you sure you want to delete this event? Cancel - Cancel + Cancel Do you want to delete all occurrences of this event, or only the selected occurrence? - + Do you want to delete all occurrences of this event, or only the selected occurrence? Delete All - + Delete All Delete Only This Event - + Delete Only This Event Do you want to delete this and all future occurrences of this event, or only the selected occurrence? - + Do you want to delete this and all future occurrences of this event, or only the selected occurrence? Delete All Future Events - + Delete All Future Events New Event - + New Event @@ -608,11 +606,11 @@ Shortcut Help - + Help Delete event - + Delete event Copy @@ -639,7 +637,7 @@ YearFrame Y - + Y @@ -650,4 +648,4 @@ Today - + \ No newline at end of file diff -Nru dde-calendar-5.7.0.4/translations/dde-calendar_en_GB.ts dde-calendar-5.7.0.23/translations/dde-calendar_en_GB.ts --- dde-calendar-5.7.0.4/translations/dde-calendar_en_GB.ts 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/translations/dde-calendar_en_GB.ts 2020-11-03 09:03:22.000000000 +0000 @@ -1,6 +1,4 @@ - - - + CDayMonthView @@ -51,53 +49,53 @@ CGraphicsView New Event - New Event + New Event CMonthGraphiview Delete - Delete + Delete You are deleting an event. - You are deleting an event. + You are deleting an event. Are you sure you want to delete this event? - Are you sure you want to delete this event? + Are you sure you want to delete this event? Cancel - Cancel + Cancel Do you want to delete all occurrences of this event, or only the selected occurrence? - Do you want to delete all occurrences of this event, or only the selected occurrence? + Do you want to delete all occurrences of this event, or only the selected occurrence? Delete All - Delete All + Delete All Delete Only This Event - Delete Only This Event + Delete Only This Event Do you want to delete this and all future occurrences of this event, or only the selected occurrence? - Do you want to delete this and all future occurrences of this event, or only the selected occurrence? + Do you want to delete this and all future occurrences of this event, or only the selected occurrence? Delete All Future Events - Delete All Future Events + Delete All Future Events CMonthSchceduleNumButton %1 more - %1 more + %1 more @@ -108,7 +106,7 @@ New Event - New Event + New Event @@ -193,135 +191,135 @@ Change All - + Change All You are changing the repeating rule of this event. - + You are changing the repeating rule of this event. You are changing a repeating event. - + You are changing a repeating event. Do you want to change only this occurrence of the event, or all occurrences? - + Do you want to change only this occurrence of the event, or all occurrences? All - + All Only This Event - + Only This Event Do you want to change only this occurrence of the event, or this and all future occurrences? - + Do you want to change the occurrence of the event, or this and all future occurrences All Future Events - + All Future Events Never - + Never At time of event - + At time of event 15 minutes before - + 15 minutes before 30 minutes before - + 30 minutes before 1 hour before - + 1 hour before 1 day before - + 1 day before 2 days before - + 2 days before 1 week before - + 1 week before On start day (9:00 AM) - + On start day (9:00 AM) Type: - + Type: All Day: - + All Day: Remind Me: - + Remind Me: Repeat: - + Repeat: Daily - + Daily Weekdays - + Weekdays Weekly - + Weekly Monthly - + Monthly Yearly - + Yearly End Repeat: - + End Repeat: After - + After On - + On time(s) - + time(s) Save - + Save New event - New event + New event End time must be greater than start time - + End time must be greater than start time OK @@ -329,74 +327,74 @@ Type - + Type All Day - + All Day Starts - + Starts Ends - + Ends Remind Me - + Remind Me Repeat - + Repeat End Repeat - + End Repeat Ends: - + Ends: Description: - + Description: Description - + Dscription Starts: - + Starts: Work - + Work Life - + Life Other - + Other CSchceduleSearchDateItem Y - Y + Y M - M + M D - D + D @@ -411,11 +409,11 @@ You are deleting an event. - You are deleting an event. + You are deleting an event. Are you sure you want to delete this event? - Are you sure you want to delete this event? + Are you sure you want to delete this event? Cancel @@ -423,27 +421,27 @@ Do you want to delete all occurrences of this event, or only the selected occurrence? - Do you want to delete all occurrences of this event, or only the selected occurrence? + Do you want to delete the occurrence of this event, or the selected occurrence? Delete All - Delete All + Delete All Delete Only This Event - Delete Only This Event + Delete Only This Event Do you want to delete this and all future occurrences of this event, or only the selected occurrence? - Do you want to delete this and all future occurrences of this event, or only the selected occurrence? + Do you want to delete this and all future occurrences of this event, or only the selected occurrence? Delete All Future Events - Delete All Future Events + Delete All Future Events All Day - + All Day @@ -457,135 +455,135 @@ CScheduleView ALL DAY - + ALL DAY CWeekWindow Week - + Week Y - Y + Y CYearSchceduleItem All Day - + All Day CYearSchceduleView All Day - + All Day No event - + No event CYearWindow Y - Y + Y CalendarWindow Calendar - + Calendar Calendar is a tool to view dates, and also a smart daily planner to schedule all things in life. - + Calendar is a tool to view dates, and also a smart daily planner to schedule all things in life. Calendarmainwindow Calendar - + Calendar Y - Y + Y M - M + M W - + W D - D + D CenterWidget All Day - + All Day DragInfoGraphicsView Edit - Edit + Edit Delete - Delete + Delete New event - New event + New event You are deleting an event. - You are deleting an event. + You are deleting an event. Are you sure you want to delete this event? - Are you sure you want to delete this event? + Are you sure you want to delete this event? Cancel - Cancel + Cancel Do you want to delete all occurrences of this event, or only the selected occurrence? - Do you want to delete all occurrences of this event, or only the selected occurrence? + Do you want to delete all occurrences of this event, or only the selected occurrence? Delete All - Delete All + Delete All Delete Only This Event - Delete Only This Event + Delete Only This Event Do you want to delete this and all future occurrences of this event, or only the selected occurrence? - Do you want to delete this and all future occurrences of this event, or only the selected occurrence? + Do you want to delete this and all future occurrences of this event, or only the selected occurrence? Delete All Future Events - Delete All Future Events + Delete All Future Events New Event - New Event + New Event @@ -612,7 +610,7 @@ Delete event - + Delete event Copy @@ -620,15 +618,15 @@ Cut - + Cut Paste - + Paste Select all - + Select all Delete @@ -650,4 +648,4 @@ Today - + \ No newline at end of file diff -Nru dde-calendar-5.7.0.4/translations/dde-calendar_es.ts dde-calendar-5.7.0.23/translations/dde-calendar_es.ts --- dde-calendar-5.7.0.4/translations/dde-calendar_es.ts 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/translations/dde-calendar_es.ts 2020-11-03 09:03:22.000000000 +0000 @@ -375,7 +375,7 @@ Life - Vida + Personal Other @@ -502,7 +502,7 @@ Calendar is a tool to view dates, and also a smart daily planner to schedule all things in life. - Calendario es una herramienta para ver fechas, y también un inteligente planificador para programar todas las cosas en la vida. + Calendario de Deepin es una herramienta para consultar fechas, y un conveniente planificador para agendar sus reuniones y eventos. @@ -521,7 +521,7 @@ W - W + S D diff -Nru dde-calendar-5.7.0.4/translations/dde-calendar_fr.ts dde-calendar-5.7.0.23/translations/dde-calendar_fr.ts --- dde-calendar-5.7.0.4/translations/dde-calendar_fr.ts 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/translations/dde-calendar_fr.ts 2020-11-03 09:03:22.000000000 +0000 @@ -259,19 +259,19 @@ Type: - Type: + Type : All Day: - Toute la journée: + Toute la journée : Remind Me: - Rappelez-moi: + Rappelez-moi : Repeat: - Répéter: + Répéter : Daily @@ -295,7 +295,7 @@ End Repeat: - Fin de répétition: + Fin de répétition : After @@ -355,11 +355,11 @@ Ends: - Fin: + Fin : Description: - Description: + Description : Description @@ -367,7 +367,7 @@ Starts: - Départs: + Départs : Work diff -Nru dde-calendar-5.7.0.4/translations/dde-calendar_gl_ES.ts dde-calendar-5.7.0.23/translations/dde-calendar_gl_ES.ts --- dde-calendar-5.7.0.4/translations/dde-calendar_gl_ES.ts 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/translations/dde-calendar_gl_ES.ts 2020-11-03 09:03:22.000000000 +0000 @@ -1,35 +1,33 @@ - - - + CDayMonthView Monday - + Luns Tuesday - + Martes Wednesday - + Mércores Thursday - + Xoves Friday - + Venres Saturday - + Sábado Sunday - + Domingo @@ -44,71 +42,71 @@ D - + D CGraphicsView New Event - + Novo evento CMonthGraphiview Delete - Eliminar + Eliminar You are deleting an event. - + Estás eliminando un evento Are you sure you want to delete this event? - + Está seguro de que quere eliminar este evento? Cancel - Cancelar + Cancelar Do you want to delete all occurrences of this event, or only the selected occurrence? - + Quere eliminar todas as ocorrencias deste evento, ou só a ocorrencia seleccionada? Delete All - + Eliminar todo Delete Only This Event - + Eliminar só este evento Do you want to delete this and all future occurrences of this event, or only the selected occurrence? - + Quere eliminar esta e todas as ocurrencias futuras deste evento, ou só a ocorrencia seleccionada? Delete All Future Events - + Eliminar todo os eventos futuros CMonthSchceduleNumButton %1 more - + %1 máis CMonthView New event - + Novo evento New Event - + Novo evento @@ -122,11 +120,11 @@ CMySchceduleView You are deleting an event. - + Estás eliminando un evento Are you sure you want to delete this event? - + Está seguro de que quere eliminar este evento? Cancel @@ -138,23 +136,23 @@ Do you want to delete all occurrences of this event, or only the selected occurrence? - + Quere eliminar todas as ocorrencias deste evento, ou só a ocorrencia seleccionada? Delete All - + Eliminar todo Delete Only This Event - + Eliminar só este evento Do you want to delete this and all future occurrences of this event, or only the selected occurrence? - + Quere eliminar esta e todas as ocurrencias futuras deste evento, ou só a ocorrencia seleccionada? My Event - + O meu evento Edit @@ -166,26 +164,26 @@ Delete All Future Events - + Eliminar todo os eventos futuros CSchceduleDlg New Event - + Novo evento Edit Event - + Editar evento All occurrences of a repeating event must have the same all-day status. - + Todas as ocorrencias dun evento que se repite deben ter o mesmo estado durante todo o día. Do you want to change all occurrences? - + Quere cambiar todas as ocorrencias? Cancel @@ -193,35 +191,35 @@ Change All - + Cambiar todo You are changing the repeating rule of this event. - + Estás a cambiar a regra deste evento. You are changing a repeating event. - + Está a cambiar un evento que se repite. Do you want to change only this occurrence of the event, or all occurrences? - + Queres cambiar só esta ocorrencia do evento ou todas as ocorrencias? All - + Todo Only This Event - + Só este evento Do you want to change only this occurrence of the event, or this and all future occurrences? - + Quere cambiar só esta ocorrencia do evento, ou esta e todas as futuras ocorrencias? All Future Events - + Todos os eventos futuros Never @@ -229,35 +227,35 @@ At time of event - + No momento do evento 15 minutes before - + 15 minutos antes 30 minutes before - + 30 minutos antes 1 hour before - + 1 hora antes 1 day before - + 1 día antes 2 days before - + 2 días antes 1 week before - + 1 semana antes On start day (9:00 AM) - + O día de inicio (9:00) Type: @@ -265,43 +263,43 @@ All Day: - + Todo o día: Remind Me: - + Recórdame: Repeat: - + Repetir: Daily - + Diariamente Weekdays - + Días da semana Weekly - + Semanalmente Monthly - + Mensualmente Yearly - + Anualmente End Repeat: - + Finalizar a repetición: After - + Despois On @@ -309,7 +307,7 @@ time(s) - + vez(ces) Save @@ -317,11 +315,11 @@ New event - + Novo evento End time must be greater than start time - + O tempo de finalización debe ser maior que o de inicio OK @@ -333,19 +331,19 @@ All Day - + Todo o día Starts - + Comeza Ends - + Acaba Remind Me - + Recórdame Repeat @@ -353,15 +351,15 @@ End Repeat - + Finalizar a repetición: Ends: - + Acaba: Description: - + Descrición: Description @@ -369,15 +367,15 @@ Starts: - + Comeza: Work - + Traballo Life - + Vida Other @@ -396,7 +394,7 @@ D - + D @@ -411,11 +409,11 @@ You are deleting an event. - + Estás eliminando un evento Are you sure you want to delete this event? - + Está seguro de que quere eliminar este evento? Cancel @@ -423,27 +421,27 @@ Do you want to delete all occurrences of this event, or only the selected occurrence? - + Quere eliminar todas as ocorrencias deste evento, ou só a ocorrencia seleccionada? Delete All - + Eliminar todo Delete Only This Event - + Eliminar só este evento Do you want to delete this and all future occurrences of this event, or only the selected occurrence? - + Quere eliminar esta e todas as ocurrencias futuras deste evento, ou só a ocorrencia seleccionada? Delete All Future Events - + Eliminar todo os eventos futuros All Day - + Todo o día @@ -457,14 +455,14 @@ CScheduleView ALL DAY - + Todo o día CWeekWindow Week - + Semana Y @@ -475,18 +473,18 @@ CYearSchceduleItem All Day - + Todo o día CYearSchceduleView All Day - + Todo o día No event - + Non hai eventos @@ -504,7 +502,7 @@ Calendar is a tool to view dates, and also a smart daily planner to schedule all things in life. - + O calendario é unha ferramenta para ver as datas e tamén un planificador diario intelixente para programar todas as cousas da vida. @@ -523,69 +521,69 @@ W - + W D - + D CenterWidget All Day - + Todo o día DragInfoGraphicsView Edit - Editar + Editar Delete - Eliminar + Eliminar New event - + Novo evento You are deleting an event. - + Estás eliminando un evento Are you sure you want to delete this event? - + Está seguro de que quere eliminar este evento? Cancel - Cancelar + Cancelar Do you want to delete all occurrences of this event, or only the selected occurrence? - + Quere eliminar todas as ocorrencias deste evento, ou só a ocorrencia seleccionada? Delete All - + Eliminar todo Delete Only This Event - + Eliminar só este evento Do you want to delete this and all future occurrences of this event, or only the selected occurrence? - + Quere eliminar esta e todas as ocurrencias futuras deste evento, ou só a ocorrencia seleccionada? Delete All Future Events - + Eliminar todo os eventos futuros New Event - + Novo evento @@ -612,7 +610,7 @@ Delete event - + Eliminar evento Copy @@ -650,4 +648,4 @@ Hoxe - + \ No newline at end of file diff -Nru dde-calendar-5.7.0.4/translations/dde-calendar_hu.ts dde-calendar-5.7.0.23/translations/dde-calendar_hu.ts --- dde-calendar-5.7.0.4/translations/dde-calendar_hu.ts 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/translations/dde-calendar_hu.ts 2020-11-03 09:03:22.000000000 +0000 @@ -1,42 +1,40 @@ - - - + CDayMonthView Monday - + Hétfő Tuesday - + Kedd Wednesday - + Szerda Thursday - + Csütörtök Friday - + Péntek Saturday - + Szombat Sunday - + Vasárnap CDayWindow Y - Y + É M @@ -44,89 +42,89 @@ D - + N CGraphicsView New Event - + Új esemény CMonthGraphiview Delete - Törlés + Törlés You are deleting an event. - + Ön töröl egy eseményt. Are you sure you want to delete this event? - + Biztos benne, hogy törli ezt az eseményt? Cancel - Mégsem + Mégsem Do you want to delete all occurrences of this event, or only the selected occurrence? - + Az esemény minden ismétlődését szeretné törölni, vagy csak a kiválasztott alkalmakat? Delete All - + Összes törlése Delete Only This Event - + Csak ezen esemény törlése Do you want to delete this and all future occurrences of this event, or only the selected occurrence? - + Az eseményt és minden jövőbeli ismétlődését szeretné törölni, vagy csak a kiválasztott alkalmakat? Delete All Future Events - + Összes jövőbeli esemény törlése CMonthSchceduleNumButton %1 more - + %1 több CMonthView New event - + Új esemény New Event - + Új esemény CMonthWindow Y - Y + É CMySchceduleView You are deleting an event. - + Ön töröl egy eseményt. Are you sure you want to delete this event? - + Biztos benne, hogy törli ezt az eseményt? Cancel @@ -138,23 +136,23 @@ Do you want to delete all occurrences of this event, or only the selected occurrence? - + Az esemény minden ismétlődését szeretné törölni, vagy csak a kiválasztott alkalmakat? Delete All - + Összes törlése Delete Only This Event - + Csak ezen esemény törlése Do you want to delete this and all future occurrences of this event, or only the selected occurrence? - + Az eseményt és minden jövőbeli ismétlődését szeretné törölni, vagy csak a kiválasztott alkalmakat? My Event - + Eseményem Edit @@ -166,26 +164,26 @@ Delete All Future Events - + Összes jövőbeli esemény törlése CSchceduleDlg New Event - + Új esemény Edit Event - + Esemény szerkesztése All occurrences of a repeating event must have the same all-day status. - + Az ismétlődő események valamennyiének "egész nap" állapotúnak kell lennie. Do you want to change all occurrences? - + Minden alkalmat módosítani szeretne? Cancel @@ -193,35 +191,35 @@ Change All - + Összes módosítása You are changing the repeating rule of this event. - + Módosítja az esemény ismétlődési szabályát. You are changing a repeating event. - + Ön egy ismétlődő eseményt módosít. Do you want to change only this occurrence of the event, or all occurrences? - + Csak az esemény ezen előfordulását akarja megváltoztatni, vagy az összes jövőbeni eseményt? All - + Összes Only This Event - + Csak ezen esemény Do you want to change only this occurrence of the event, or this and all future occurrences? - + Csak az esemény ezen előfordulását akarja megváltoztatni, vagy ezt és az összes jövőbeni eseményt? All Future Events - + Minden jövőbeli esemény Never @@ -229,35 +227,35 @@ At time of event - + Esemény idején 15 minutes before - + 15 perccel előtte 30 minutes before - + 30 perccel előtte 1 hour before - + 1 órával előtte 1 day before - + 1 nappal előtte 2 days before - + 2 nappal előtte 1 week before - + 1 héttel előtte On start day (9:00 AM) - + Esemény kezdete napján (09:00) Type: @@ -265,43 +263,43 @@ All Day: - + Egész nap: Remind Me: - + Emlékeztessen: Repeat: - + Ismétlés: Daily - + Naponta Weekdays - + Hétköznapokon Weekly - + Hetente Monthly - + Havonta Yearly - + Évente End Repeat: - + Ismétlés vége: After - + Után On @@ -309,19 +307,19 @@ time(s) - + időpont(ok) Save - Ment + Mentés New event - + Új esemény End time must be greater than start time - + A befejezés időpontjának a kezdés időpontjánál későbbre kell esnie OK @@ -333,19 +331,19 @@ All Day - + Egész nap Starts - + Kezdés Ends - + Befejezés Remind Me - + Emlékeztessen Repeat @@ -353,15 +351,15 @@ End Repeat - + Ismétlés vége Ends: - + Befejezés: Description: - + Leírás: Description @@ -369,7 +367,7 @@ Starts: - + Kezdés: Work @@ -388,7 +386,7 @@ CSchceduleSearchDateItem Y - Y + É M @@ -396,7 +394,7 @@ D - + N @@ -411,11 +409,11 @@ You are deleting an event. - + Ön töröl egy eseményt. Are you sure you want to delete this event? - + Biztos benne, hogy törli ezt az eseményt? Cancel @@ -423,77 +421,77 @@ Do you want to delete all occurrences of this event, or only the selected occurrence? - + Az esemény minden ismétlődését szeretné törölni, vagy csak a kiválasztott alkalmakat? Delete All - + Összes törlése Delete Only This Event - + Csak ezen esemény törlése Do you want to delete this and all future occurrences of this event, or only the selected occurrence? - + Az eseményt és minden jövőbeli ismétlődését szeretné törölni, vagy csak a kiválasztott alkalmakat? Delete All Future Events - + Összes jövőbeli esemény törlése All Day - + Egész nap CSchceduleSearchView No search results - Nincs találat + Nincs keresési eredmény CScheduleView ALL DAY - + EGÉSZ NAP CWeekWindow Week - + Hét Y - Y + É CYearSchceduleItem All Day - + Egész nap CYearSchceduleView All Day - + Egész nap No event - + Nincs esemény CYearWindow Y - Y + É @@ -504,7 +502,7 @@ Calendar is a tool to view dates, and also a smart daily planner to schedule all things in life. - + A Naptár egy eszköz a dátumok megtekintésére, valamint egy intelligens napi tervező az élet minden dolgának ütemezéséhez. @@ -515,7 +513,7 @@ Y - Y + É M @@ -523,69 +521,69 @@ W - + H D - + N CenterWidget All Day - + Egész nap DragInfoGraphicsView Edit - Szerkesztés + Szerkesztés Delete - Törlés + Törlés New event - + Új esemény You are deleting an event. - + Ön töröl egy eseményt. Are you sure you want to delete this event? - + Biztos benne, hogy törli ezt az eseményt? Cancel - Mégsem + Mégsem Do you want to delete all occurrences of this event, or only the selected occurrence? - + Az esemény minden ismétlődését szeretné törölni, vagy csak a kiválasztott alkalmakat? Delete All - + Összes törlése Delete Only This Event - + Csak ezen esemény törlése Do you want to delete this and all future occurrences of this event, or only the selected occurrence? - + Az eseményt és minden jövőbeli ismétlődését szeretné törölni, vagy csak a kiválasztott alkalmakat? Delete All Future Events - + Összes jövőbeli esemény törlése New Event - + Új esemény @@ -608,11 +606,11 @@ Shortcut Help - Súgó + Segítség Delete event - + Esemény törlése Copy @@ -639,7 +637,7 @@ YearFrame Y - Y + É @@ -650,4 +648,4 @@ Ma - + \ No newline at end of file diff -Nru dde-calendar-5.7.0.4/translations/dde-calendar_nl.ts dde-calendar-5.7.0.23/translations/dde-calendar_nl.ts --- dde-calendar-5.7.0.4/translations/dde-calendar_nl.ts 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/translations/dde-calendar_nl.ts 2020-11-03 09:03:22.000000000 +0000 @@ -60,11 +60,11 @@ You are deleting an event. - Je verwijdert een afspraak + Je verwijdert een afspraak. Are you sure you want to delete this event? - Ben je zeker dat je deze afspraak wil verwijderen? + Weet je zeker dat je deze afspraak wilt verwijderen? Cancel @@ -72,37 +72,37 @@ Do you want to delete all occurrences of this event, or only the selected occurrence? - Dit is een herhalende afspraak. Wil je alle afspraken verwijderen of enkel deze? + Wil je alle afspraken in de reeks verwijderen of enkel deze? Delete All - Verwijder ze allemaal + Reeks verwijderen Delete Only This Event - Verwijder enkel deze afspraak + Deze afspraak verwijderen Do you want to delete this and all future occurrences of this event, or only the selected occurrence? - Wil je deze én toekomstige afspraken verwijderen, of enkel deze? + Wil je deze en toekomstige afspraken verwijderen of enkel deze? Delete All Future Events - Verwijder alle toekomstige afspraken + Toekomstige afspraken verwijderen CMonthSchceduleNumButton %1 more - %1 meer + Nog %1 andere CMonthView New event - Nieuwe gebeurtenis + Nieuwe afspraak New Event @@ -120,11 +120,11 @@ CMySchceduleView You are deleting an event. - Je verwijdert een afspraak + Je verwijdert een afspraak. Are you sure you want to delete this event? - Ben je zeker dat je deze afspraak wil verwijderen? + Weet je zeker dat je deze afspraak wilt verwijderen? Cancel @@ -136,19 +136,19 @@ Do you want to delete all occurrences of this event, or only the selected occurrence? - Dit is een herhalende afspraak. Wil je alle afspraken verwijderen of enkel deze? + Wil je alle afspraken in de reeks verwijderen of enkel deze? Delete All - Verwijder ze allemaal + Reeks verwijderen Delete Only This Event - Verwijder enkel deze afspraak + Deze afspraak verwijderen Do you want to delete this and all future occurrences of this event, or only the selected occurrence? - Wil je deze én toekomstige afspraken verwijderen, of enkel deze? + Wil je deze en toekomstige afspraken verwijderen of enkel deze? My Event @@ -156,7 +156,7 @@ Edit - Bewerken + Aanpassen OK @@ -164,7 +164,7 @@ Delete All Future Events - Verwijder alle toekomstige afspraken + Toekomstige afspraken verwijderen @@ -175,15 +175,15 @@ Edit Event - Afspraak bewerken + Afspraak aanpassen All occurrences of a repeating event must have the same all-day status. - Alle herhalende afspraken moeten dezelfde 'hele dag' status hebben + Alle afspraken in reeks moeten voorzien zijn van de status 'hele dag'. Do you want to change all occurrences? - Wil je alle herhalende afspraken wijzigen? + Wil je alle afspraken in de reeks aanpassen? Cancel @@ -191,35 +191,35 @@ Change All - Wijzig alle + Reeks aanpassen You are changing the repeating rule of this event. - Je wijzigt de herhaalinstellingen voor deze afspraak + Je past de herhaalinstellingen van deze afspraak aan. You are changing a repeating event. - Je wijzigt een herhalende afspraak. + Je past een reeks afspraken aan. Do you want to change only this occurrence of the event, or all occurrences? - Wil je deze én toekomstige afspraken wijzigen, of enkel de deze? + Wil je deze en toekomstige afspraken aanpassen of enkel deze? All - Alle afspraken + Reeks Only This Event - Enkel deze afspraak + Deze afspraak Do you want to change only this occurrence of the event, or this and all future occurrences? - Wil je deze én toekomstige afspraken wijzigen, of enkel deze? + Wil je deze en toekomstige afspraken aanpassen of enkel deze? All Future Events - Alle toekomstige afspraken + Toekomstige afspraken Never @@ -227,31 +227,31 @@ At time of event - Bij de start + Bij aanvang 15 minutes before - 15 minuten voordien + 15 minuten van tevoren 30 minutes before - 30 minuten voordien + 30 minuten van tevoren 1 hour before - 1 uur voordien + 1 uur van tevoren 1 day before - 1 dag voordien + 1 dag van tevoren 2 days before - 2 dagen voordien + 2 dagen van tevoren 1 week before - 1 week voordien + 1 week van tevoren On start day (9:00 AM) @@ -267,11 +267,11 @@ Remind Me: - Herinner me: + Herinneren: Repeat: - Herhaal: + Herhalen: Daily @@ -279,7 +279,7 @@ Weekdays - Weekdagen + Werkdagen Weekly @@ -295,7 +295,7 @@ End Repeat: - Stop herhaling: + Herhaling eindigt op: After @@ -303,7 +303,7 @@ On - Aan + Op time(s) @@ -315,11 +315,11 @@ New event - Nieuwe gebeurtenis + Nieuwe afspraak End time must be greater than start time - Eindtijd moet later zijn dan begintijd + De eindtijd moet later zijn dan de begintijd OK @@ -327,7 +327,7 @@ Type - Type + Soort All Day @@ -335,15 +335,15 @@ Starts - Begin + Begint om Ends - einde + Eindigt om Remind Me - Herinner me + Herinneren Repeat @@ -351,7 +351,7 @@ End Repeat - Stop herhaling + Herhaling stoppen Ends: @@ -401,7 +401,7 @@ CSchceduleSearchItem Edit - Bewerken + Aanpassen Delete @@ -409,11 +409,11 @@ You are deleting an event. - Je verwijdert een afspraak + Je verwijdert een afspraak. Are you sure you want to delete this event? - Ben je zeker dat je deze afspraak wil verwijderen? + Weet je zeker dat je deze afspraak wilt verwijderen? Cancel @@ -421,23 +421,23 @@ Do you want to delete all occurrences of this event, or only the selected occurrence? - Dit is een terugkerende afspraak. Wil je alle afspraken verwijderen of enkel deze? + Wil je alle afspraken in de reeks verwijderen of enkel deze? Delete All - Verwijder ze allemaal + Reeks verwijderen Delete Only This Event - Verwijder enkel deze afspraak + Deze afspraak verwijderen Do you want to delete this and all future occurrences of this event, or only the selected occurrence? - Wil je deze én toekomstige afspraken verwijderen, of enkel de deze? + Wil je deze en toekomstige afspraken verwijderen of enkel de deze? Delete All Future Events - Verwijder alle toekomstige afspraken + Toekomstige afspraken verwijderen All Day @@ -502,7 +502,7 @@ Calendar is a tool to view dates, and also a smart daily planner to schedule all things in life. - Calendar is een applicatie om je afspraken en planning te beheren, voor je werk én privé. + Met Kalender kun je je afspraken en planning beheren, zowel werk als privé. @@ -539,7 +539,7 @@ DragInfoGraphicsView Edit - Bewerken + Aanpassen Delete @@ -547,15 +547,15 @@ New event - Nieuwe gebeurtenis + Nieuwe afspraak You are deleting an event. - Je verwijdert een afspraak + Je verwijdert een afspraak. Are you sure you want to delete this event? - Ben je zeker dat je deze afspraak wil verwijderen? + Weet je zeker dat je deze afspraak wilt verwijderen? Cancel @@ -563,23 +563,23 @@ Do you want to delete all occurrences of this event, or only the selected occurrence? - Dit is een herhalende afspraak. Wil je alle afspraken verwijderen of enkel deze? + Wil je alle afspraken in de reeks verwijderen of enkel deze? Delete All - Verwijder ze allemaal + Reeks verwijderen Delete Only This Event - Verwijder enkel deze afspraak + Deze afspraak verwijderen Do you want to delete this and all future occurrences of this event, or only the selected occurrence? - Wil je deze én toekomstige afspraken verwijderen, of enkel deze? + Wil je deze en toekomstige afspraken verwijderen of enkel deze? Delete All Future Events - Verwijder alle toekomstige afspraken + Toekomstige afspraken verwijderen New Event @@ -610,7 +610,7 @@ Delete event - Verwijder afspraak + Afspraak verwijderen Copy diff -Nru dde-calendar-5.7.0.4/translations/dde-calendar_ru.ts dde-calendar-5.7.0.23/translations/dde-calendar_ru.ts --- dde-calendar-5.7.0.4/translations/dde-calendar_ru.ts 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/translations/dde-calendar_ru.ts 2020-11-03 09:03:22.000000000 +0000 @@ -335,11 +335,11 @@ Starts - Начинается + Начало Ends - Заканчивается + Завершение Remind Me diff -Nru dde-calendar-5.7.0.4/translations/dde-calendar_zh_CN.ts dde-calendar-5.7.0.23/translations/dde-calendar_zh_CN.ts --- dde-calendar-5.7.0.4/translations/dde-calendar_zh_CN.ts 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/translations/dde-calendar_zh_CN.ts 2020-11-03 09:03:22.000000000 +0000 @@ -27,7 +27,7 @@ Sunday - 星期日 + 星期天 diff -Nru dde-calendar-5.7.0.4/translations/dde-calendar_zh_HK.ts dde-calendar-5.7.0.23/translations/dde-calendar_zh_HK.ts --- dde-calendar-5.7.0.4/translations/dde-calendar_zh_HK.ts 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/translations/dde-calendar_zh_HK.ts 2020-11-03 09:03:22.000000000 +0000 @@ -379,7 +379,7 @@ Other - 其它 + 其他 @@ -606,7 +606,7 @@ Shortcut Help - 協助 + 幫助 Delete event diff -Nru dde-calendar-5.7.0.4/translations/dde-calendar_zh_TW.ts dde-calendar-5.7.0.23/translations/dde-calendar_zh_TW.ts --- dde-calendar-5.7.0.4/translations/dde-calendar_zh_TW.ts 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/translations/dde-calendar_zh_TW.ts 2020-11-03 09:03:22.000000000 +0000 @@ -247,7 +247,7 @@ 2 days before - 1天前 + 2天前 1 week before @@ -303,7 +303,7 @@ On - 開啟 + 於日期 time(s) @@ -379,7 +379,7 @@ Other - 其它 + 其他 @@ -591,7 +591,7 @@ Today Return - 同一日 + 今天 @@ -599,7 +599,7 @@ Today Return Today - 同一日 + 今天 @@ -645,7 +645,7 @@ Today Today - 同一日 + 今天 \ No newline at end of file diff -Nru dde-calendar-5.7.0.4/translations/desktop/desktop_bo.ts dde-calendar-5.7.0.23/translations/desktop/desktop_bo.ts --- dde-calendar-5.7.0.4/translations/desktop/desktop_bo.ts 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/translations/desktop/desktop_bo.ts 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1 @@ +desktopCalendarལོ་ཐོ།Calendar is a date tool.ལོ་ཐོ་ནི་ཚེས་གྲངས་ལྟ་བའི་ཡོ་བྱད་ཆུང་ཆུང་ཞིག་རེད།Deepin Calendarགྲ་རྒྱས་པའི་ལོ་ཐོ། \ No newline at end of file diff -Nru dde-calendar-5.7.0.4/translations/desktop/desktop_cs.ts dde-calendar-5.7.0.23/translations/desktop/desktop_cs.ts --- dde-calendar-5.7.0.4/translations/desktop/desktop_cs.ts 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/translations/desktop/desktop_cs.ts 2020-11-03 09:03:22.000000000 +0000 @@ -1 +1 @@ -desktopCalendarKalendářCalendar is a date tool.Kalendář je nástroj pro práci s datumy.Deepin CalendarDeepin Kalendář \ No newline at end of file +desktopCalendarKalendářCalendar is a date tool.Kalendář je nástroj pro práci s daty.Deepin CalendarKalendář \ No newline at end of file diff -Nru dde-calendar-5.7.0.4/translations/desktop/desktop_en_GB.ts dde-calendar-5.7.0.23/translations/desktop/desktop_en_GB.ts --- dde-calendar-5.7.0.4/translations/desktop/desktop_en_GB.ts 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/translations/desktop/desktop_en_GB.ts 2020-11-03 09:03:22.000000000 +0000 @@ -1 +1 @@ -desktopCalendarCalendar is a date tool.Calendar is a date toolDeepin CalendarDeepin Calendar \ No newline at end of file +desktopCalendarCalendarCalendar is a date tool.Calendar is a date toolDeepin CalendarDeepin Calendar \ No newline at end of file diff -Nru dde-calendar-5.7.0.4/translations/desktop/desktop_es.ts dde-calendar-5.7.0.23/translations/desktop/desktop_es.ts --- dde-calendar-5.7.0.4/translations/desktop/desktop_es.ts 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/translations/desktop/desktop_es.ts 2020-11-03 09:03:22.000000000 +0000 @@ -1 +1 @@ -desktopCalendarCalendarioCalendar is a date tool.Calendario es una herramienta de gestión de fechas.Deepin CalendarCalendario Deepin \ No newline at end of file +desktopCalendarCalendarioCalendar is a date tool.Calendario de Deepin es una herramienta de gestión de eventos.Deepin CalendarCalendario \ No newline at end of file diff -Nru dde-calendar-5.7.0.4/translations/desktop/desktop_fa.ts dde-calendar-5.7.0.23/translations/desktop/desktop_fa.ts --- dde-calendar-5.7.0.4/translations/desktop/desktop_fa.ts 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/translations/desktop/desktop_fa.ts 2020-11-03 09:03:22.000000000 +0000 @@ -1 +1 @@ -desktopCalendarCalendar is a date tool.تقویم یک ابزار تاریخ است.Deepin Calendarتقویم Deepin \ No newline at end of file +desktopCalendarتقویمCalendar is a date tool.تقویم یک ابزار تاریخ است.Deepin Calendarتقویم Deepin \ No newline at end of file diff -Nru dde-calendar-5.7.0.4/translations/desktop/desktop_fr.ts dde-calendar-5.7.0.23/translations/desktop/desktop_fr.ts --- dde-calendar-5.7.0.4/translations/desktop/desktop_fr.ts 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/translations/desktop/desktop_fr.ts 2020-11-03 09:03:22.000000000 +0000 @@ -1 +1 @@ -desktopCalendarCalendrierCalendar is a date tool.Simple calendrier.Deepin CalendarDeepin Calendrier \ No newline at end of file +desktopCalendarCalendrierCalendar is a date tool.Simple calendrier.Deepin CalendarCalendrier Deepin \ No newline at end of file diff -Nru dde-calendar-5.7.0.4/translations/desktop/desktop_hi_IN.ts dde-calendar-5.7.0.23/translations/desktop/desktop_hi_IN.ts --- dde-calendar-5.7.0.4/translations/desktop/desktop_hi_IN.ts 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/translations/desktop/desktop_hi_IN.ts 2020-11-03 09:03:22.000000000 +0000 @@ -1 +1 @@ -desktopCalendarकलेंडरCalendar is a date tool.दिनदर्शिका दिनांक हेतु एक साधन है।Deepin Calendarडीपिन दिनदर्शिका \ No newline at end of file +desktopCalendarदिनदर्शिकाCalendar is a date tool.दिनदर्शिका तिथि हेतु एक साधन है।Deepin Calendarडीपिन दिनदर्शिका \ No newline at end of file diff -Nru dde-calendar-5.7.0.4/translations/desktop/desktop_hu.ts dde-calendar-5.7.0.23/translations/desktop/desktop_hu.ts --- dde-calendar-5.7.0.4/translations/desktop/desktop_hu.ts 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/translations/desktop/desktop_hu.ts 2020-11-03 09:03:22.000000000 +0000 @@ -1 +1 @@ -desktopCalendarNaptárCalendar is a date tool.Naptár alkalmazásDeepin CalendarDeepin Naptár \ No newline at end of file +desktopCalendarNaptárCalendar is a date tool.A Naptár egy dátum megjelenítő eszköz.Deepin CalendarDeepin Naptár \ No newline at end of file diff -Nru dde-calendar-5.7.0.4/translations/desktop/desktop_ko.ts dde-calendar-5.7.0.23/translations/desktop/desktop_ko.ts --- dde-calendar-5.7.0.4/translations/desktop/desktop_ko.ts 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/translations/desktop/desktop_ko.ts 2020-11-03 09:03:22.000000000 +0000 @@ -1 +1 @@ -desktopCalendar달력Calendar is a date tool.Calendar는 일정 관리도구입니다.Deepin CalendarDeepin Calendar \ No newline at end of file +desktopCalendar달력Calendar is a date tool.달력은 날짜 도구입니다.Deepin CalendarDeepin 달력 \ No newline at end of file diff -Nru dde-calendar-5.7.0.4/translations/desktop/desktop_pt_BR.ts dde-calendar-5.7.0.23/translations/desktop/desktop_pt_BR.ts --- dde-calendar-5.7.0.4/translations/desktop/desktop_pt_BR.ts 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/translations/desktop/desktop_pt_BR.ts 2020-11-03 09:03:22.000000000 +0000 @@ -1 +1 @@ -desktopCalendarCalendárioCalendar is a date tool.Calendário é uma ferramenta de data.Deepin CalendarCalendário \ No newline at end of file +desktopCalendarCalendárioCalendar is a date tool.O Calendário é uma ferramenta que permite agendar e visualizar eventos.Deepin Calendardeepin Calendário \ No newline at end of file diff -Nru dde-calendar-5.7.0.4/translations/desktop/desktop_pt.ts dde-calendar-5.7.0.23/translations/desktop/desktop_pt.ts --- dde-calendar-5.7.0.4/translations/desktop/desktop_pt.ts 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/translations/desktop/desktop_pt.ts 2020-11-03 09:03:22.000000000 +0000 @@ -1 +1 @@ -desktopCalendarCalendárioCalendar is a date tool.O Calendário é uma ferramenta de agendamento.Deepin CalendarDeepin Calendar \ No newline at end of file +desktopCalendarCalendárioCalendar is a date tool.O Calendário é uma ferramenta de data.Deepin CalendarCalendário Deepin \ No newline at end of file diff -Nru dde-calendar-5.7.0.4/translations/desktop/desktop_si.ts dde-calendar-5.7.0.23/translations/desktop/desktop_si.ts --- dde-calendar-5.7.0.4/translations/desktop/desktop_si.ts 1970-01-01 00:00:00.000000000 +0000 +++ dde-calendar-5.7.0.23/translations/desktop/desktop_si.ts 2020-11-03 09:03:22.000000000 +0000 @@ -0,0 +1 @@ +desktopCalendarදින දසුනCalendar is a date tool.දින දසුන දින මෙවලමකි.Deepin CalendarDeepin දින දසුන \ No newline at end of file diff -Nru dde-calendar-5.7.0.4/translations/desktop/desktop_ug.ts dde-calendar-5.7.0.23/translations/desktop/desktop_ug.ts --- dde-calendar-5.7.0.4/translations/desktop/desktop_ug.ts 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/translations/desktop/desktop_ug.ts 2020-11-03 09:03:22.000000000 +0000 @@ -1 +1 @@ -desktopCalendarCalendar is a date tool.كالىندار ئۇ ۋاقىت قۇرالىDeepin CalendarDeepin كالىندارى \ No newline at end of file +desktopCalendarكالىندار Calendar is a date tool.كالىندار ئۇ ۋاقىت قۇرالىDeepin CalendarDeepin كالىندارى \ No newline at end of file diff -Nru dde-calendar-5.7.0.4/translations/desktop/desktop_zh_CN.ts dde-calendar-5.7.0.23/translations/desktop/desktop_zh_CN.ts --- dde-calendar-5.7.0.4/translations/desktop/desktop_zh_CN.ts 2020-07-10 09:08:38.000000000 +0000 +++ dde-calendar-5.7.0.23/translations/desktop/desktop_zh_CN.ts 2020-11-03 09:03:22.000000000 +0000 @@ -1,762 +1 @@ - - - - - CCalendarTimeEidt - - AM - 上午 - - - PM - 下午 - - - - CCustomCalendarWidget - - M - - - - Y - - - - - CDayMonthView - - Monday - 星期一 - - - Tuesday - 星期二 - - - Wednesday - 星期三 - - - Thursday - 星期四 - - - Friday - 星期五 - - - Saturday - 星期六 - - - Sunday - 星期天 - - - Return today - 返回今天 - - - mon - - - - Y - - - - M - - - - D - - - - 【 - - - - Y】 - 年】 - - - infomation - 提示 - - - Year less than 1900! - 年少于1900年! - - - - CDayWindow - - Y - - - - D - - - - M - - - - - CGraphicsView - - Edit - 编辑 - - - Delete - 删除 - - - Create - 新建日程 - - - You are deleted schedule. - 您正在删除日程。 - - - Are you sure you want to delete this schedule? - 您确定要删除此日程吗? - - - Cancel - 取消 - - - Delete Schedule - 删除日程 - - - You want to delete all repeat of the schedule, or just delete the selected repeat? - 您要删除这个日程的所有重复,还是只删除所选重复? - - - All Deleted - 全部删除 - - - Just Delete Schedule - 仅删除该日程 - - - You want to delete the schedule of this repetition and all repeat in the future, or just delete all repeat? - 您是要删除此日程的这个重复和所有将来重复,还是只删除所选重复? - - - Delete all schedule in the future - 删除所有将来日程 - - - - CMonthView - - Create - 新建日程 - - - - CMonthWindow - - Y - - - - Return today - 返回今天 - - - - CMySchceduleView - - My Schcedule - 我的日程 - - - You are deleted schedule. - 您正在删除日程。 - - - Are you sure you want to delete this schedule? - 您确定要删除此日程吗? - - - Cancel - 取消 - - - Delete Schedule - 删除日程 - - - You want to delete all repeat of the schedule, or just delete the selected repeat? - 您要删除这个日程的所有重复,还是只删除所选重复? - - - All Deleted - 全部删除 - - - Just Delete Schedule - 仅删除该日程 - - - You want to delete the schedule of this repetition and all repeat in the future, or just delete all repeat? - 您是要删除此日程的这个重复和所有将来重复,还是只删除所选重复? - - - Delete all schedule in the future - 删除所有将来日程 - - - Edit - 编辑 - - - Delete - 删除 - - - - CSchceduleAllDayView - - Create - 新建日程 - - - - CSchceduleAllNumButton - - There is %1 schedule - 还有 %1 项 - - - - CSchceduleAllWidgetItem - - Edit - 编辑 - - - Delete - 删除 - - - You are deleted schedule. - 您正在删除日程。 - - - Are you sure you want to delete this schedule? - 您确定要删除此日程吗? - - - Cancel - 取消 - - - Delete Schedule - 删除日程 - - - You want to delete all repeat of the schedule, or just delete the selected repeat? - 您要删除这个日程的所有重复,还是只删除所选重复? - - - All Deleted - 全部删除 - - - Just Delete Schedule - 仅删除该日程 - - - You want to delete the schedule of this repetition and all repeat in the future, or just delete all repeat? - 您是要删除此日程的这个重复和所有将来重复,还是只删除所选重复? - - - Delete all schedule in the future - 删除所有将来日程 - - - - CSchceduleDayView - - Create - 新建日程 - - - - CSchceduleDlg - - Create Schcedule - 创建日程 - - - Edit Schcedule - 编辑日程 - - - error - 错误 - - - Schcedule is empty! - 日程不存在! - - - The end time less than begin time! - 终止时间小于起始时间! - - - The end repeat times is null! - 请输入结束重复次数! - - - The end repeat time less than begin time! - 结束的重复结束时间大于日程的起始时间! - - - Repetitive schedule of all must have the same throughout the state. - 重复日程的所有重复必须具有相同的全天状态。 - - - Repetitive schedule of all must have the same not throughout the state. - 重复日程的所有重复必须具有相同的非全天状态。 - - - Would you like to change all repeat? - 您要更改所有重复? - - - All Changes - 全部更改 - - - You are changing the schedule again. - 您正在更改重复日程。 - - - You are to change the schedule only the repeat, to repeat or change it all? - 您是要更改该日程的仅这一个重复,还是更改它的所有重复? - - - ALL - 全部 - - - Only Schedule - 仅此日程 - - - Do you want to change the schedule only is this a repeat, besides it also changes the schedule all repeat in the future? - 您是要更改该日程的仅这一个重复,还是除它以外还更改该日程的所有将来重复? - - - All future Schedule - 所有将来日程 - - - infomation - 提示 - - - Max length is 256! - 日程最大长度256字符! - - - Type: - 类型: - - - Work - 工作 - - - Life - 生活 - - - Other - 其他 - - - Content: - 内容: - - - Begin Time: - 开始时间: - - - End Time: - 终止时间: - - - Remind Set: - 提醒设置: - - - Cancel - 取消 - - - None - - - - Schedule occurs - 日程发生时 - - - 15 minutes ago - 15分钟前 - - - 30 minutes ago - 30分钟前 - - - 1 hour ago - 1小时前 - - - 1 day ago - 1天前 - - - 2 day ago - 2天前 - - - schedule of the day(At 9 am) - 日程发生当天(上午9时) - - - 1 day ago(At 9 am) - 1天前(上午9时) - - - 2 day ago(At 9 am) - 2天前(上午9时) - - - A week ago - 1周前 - - - All Day: - 全天: - - - Repeat: - 重复: - - - Every day - 每天 - - - Every working day - 每工作日 - - - Once a week - 每周 - - - A month - 每月 - - - Every year - 每年 - - - End Repeat: - 结束重复: - - - never - 永不 - - - in - - - - On the date - 于日期 - - - After time - 次后 - - - OK - 确定 - - - - CSchceduleNumButton - - There is %1 schedule - 还有 %1 项 - - - - CSchceduleSearchDateItem - - Y - - - - M - - - - D - - - - - CSchceduleSearchItem - - Edit - 编辑 - - - Delete - 删除 - - - You are deleted schedule. - 您正在删除日程。 - - - Are you sure you want to delete this schedule? - 您确定要删除此日程吗? - - - Cancel - 取消 - - - Delete Schedule - 删除日程 - - - You want to delete all repeat of the schedule, or just delete the selected repeat? - 您要删除这个日程的所有重复,还是只删除所选重复? - - - All Deleted - 全部删除 - - - Just Delete Schedule - 仅删除该日程 - - - You want to delete the schedule of this repetition and all repeat in the future, or just delete all repeat? - 您是要删除此日程的这个重复和所有将来重复,还是只删除所选重复? - - - Delete all schedule in the future - 删除所有将来日程 - - - - CSchceduleSearchView - - No search results - 无搜索结果 - - - - CSchceduleWidgetItem - - Edit - 编辑 - - - Delete - 删除 - - - You are deleted schedule. - 您正在删除日程。 - - - Are you sure you want to delete this schedule? - 您确定要删除此日程吗? - - - Cancel - 取消 - - - Delete Schedule - 删除日程 - - - You want to delete all repeat of the schedule, or just delete the selected repeat? - 您要删除这个日程的所有重复,还是只删除所选重复? - - - All Deleted - 全部删除 - - - Just Delete Schedule - 仅删除该日程 - - - You want to delete the schedule of this repetition and all repeat in the future, or just delete all repeat? - 您是要删除此日程的这个重复和所有将来重复,还是只删除所选重复? - - - Delete all schedule in the future - 删除所有将来日程 - - - - CScheduleView - - PM - 下午 - - - h - - - - AM - 上午 - - - ALL DAY - 全天 - - - - CWeekHeadView - - Mon - - - - - CWeekWindow - - Return today - 返回今天 - - - Week - - - - infomation - 提示 - - - Year less than 1900! - 年少于1900年! - - - Y - - - - - CYearView - - Mon - - - - - CYearWindow - - Return today - 返回今天 - - - infomation - 提示 - - - Year less than 1900! - 年少于1900年! - - - Y - - - - Lunar - 农历 - - - Today - 今天 - - - Return Today - 返回今天 - - - - CalendarWindow - - First Day of Week - 周第一天 - - - Deepin Calendar - 深度日历 - - - Calendar is a date tool. - 日历是一个时间工具. - - - - Calendarmainwindow - - Deepin Calendar - 深度日历 - - - Y - - - - M - - - - W - - - - D - - - - - InfoView - - Today - 今天 - - - +desktopCalendar日历Calendar is a date tool.日历是一款查看日期的小工具。Deepin Calendar深度日历 \ No newline at end of file