diff --git a/calendar-client/src/KeyPress/calldaykeyleftdeal.cpp b/calendar-client/src/KeyPress/calldaykeyleftdeal.cpp index b3a097ae2..ae912f24b 100644 --- a/calendar-client/src/KeyPress/calldaykeyleftdeal.cpp +++ b/calendar-client/src/KeyPress/calldaykeyleftdeal.cpp @@ -6,21 +6,26 @@ #include "graphicsItem/cweekdaybackgrounditem.h" #include "cgraphicsscene.h" +#include "commondef.h" CAllDayKeyLeftDeal::CAllDayKeyLeftDeal(QGraphicsScene *scene) : CKeyPressDealBase(Qt::Key_Left, scene) { + qCDebug(ClientLogger) << "CAllDayKeyLeftDeal constructor initialized"; } bool CAllDayKeyLeftDeal::focusItemDeal(CSceneBackgroundItem *item, CGraphicsScene *scene) { + qCDebug(ClientLogger) << "CAllDayKeyLeftDeal::focusItemDeal - Processing left key for date:" << item->getDate(); CWeekDayBackgroundItem *backgroundItem = dynamic_cast(item); backgroundItem->initState(); //如果是第一个则切换时间 scene->setActiveSwitching(true); if (backgroundItem->getLeftItem() == nullptr) { + qCDebug(ClientLogger) << "Left item is null, switching to previous page"; scene->setPrePage(item->getDate().addDays(-1), true); } else { + qCDebug(ClientLogger) << "Switching view to previous day"; scene->signalSwitchView(backgroundItem->getDate().addDays(-1), true); } return true; diff --git a/calendar-client/src/KeyPress/calldaykeyrightdeal.cpp b/calendar-client/src/KeyPress/calldaykeyrightdeal.cpp index aadf1a0d2..f0ec4d57f 100644 --- a/calendar-client/src/KeyPress/calldaykeyrightdeal.cpp +++ b/calendar-client/src/KeyPress/calldaykeyrightdeal.cpp @@ -6,21 +6,26 @@ #include "graphicsItem/cweekdaybackgrounditem.h" #include "cgraphicsscene.h" +#include "commondef.h" CAllDayKeyRightDeal::CAllDayKeyRightDeal(QGraphicsScene *scene) : CKeyPressDealBase(Qt::Key_Right, scene) { + qCDebug(ClientLogger) << "CAllDayKeyRightDeal constructor initialized"; } bool CAllDayKeyRightDeal::focusItemDeal(CSceneBackgroundItem *item, CGraphicsScene *scene) { + qCDebug(ClientLogger) << "CAllDayKeyRightDeal::focusItemDeal - Processing right key for date:" << item->getDate(); CWeekDayBackgroundItem *backgroundItem = dynamic_cast(item); backgroundItem->initState(); //如果没有下一个则切换时间 scene->setActiveSwitching(true); if (backgroundItem->getRightItem() == nullptr) { + qCDebug(ClientLogger) << "Right item is null, switching to next page"; scene->setNextPage(item->getDate().addDays(1), true); } else { + qCDebug(ClientLogger) << "Switching view to next day"; scene->signalSwitchView(backgroundItem->getDate().addDays(1), true); } return true; diff --git a/calendar-client/src/KeyPress/ckeydowndeal.cpp b/calendar-client/src/KeyPress/ckeydowndeal.cpp index d87f6bd72..f199b865c 100644 --- a/calendar-client/src/KeyPress/ckeydowndeal.cpp +++ b/calendar-client/src/KeyPress/ckeydowndeal.cpp @@ -6,21 +6,26 @@ #include "graphicsItem/cscenebackgrounditem.h" #include "cgraphicsscene.h" +#include "commondef.h" #include CKeyDownDeal::CKeyDownDeal(QGraphicsScene *scene) : CKeyPressDealBase(Qt::Key_Down, scene) { + qCDebug(ClientLogger) << "CKeyDownDeal constructor initialized"; } bool CKeyDownDeal::focusItemDeal(CSceneBackgroundItem *item, CGraphicsScene *scene) { + qCDebug(ClientLogger) << "CKeyDownDeal::focusItemDeal - Processing down key for date:" << item->getDate(); item->initState(); if (item->getDownItem() != nullptr) { + qCDebug(ClientLogger) << "Down item exists, setting focus to down item"; scene->setCurrentFocusItem(item->getDownItem()); item->getDownItem()->setItemFocus(true); } else { + qCDebug(ClientLogger) << "Down item is null, switching to next week"; scene->setNextPage(item->getDate().addDays(7)); } return true; diff --git a/calendar-client/src/KeyPress/ckeyenabledeal.cpp b/calendar-client/src/KeyPress/ckeyenabledeal.cpp index 996c9e689..45123ebad 100644 --- a/calendar-client/src/KeyPress/ckeyenabledeal.cpp +++ b/calendar-client/src/KeyPress/ckeyenabledeal.cpp @@ -8,12 +8,14 @@ #include "graphicsItem/cscenebackgrounditem.h" #include "graphicsItem/draginfoitem.h" #include "myscheduleview.h" +#include "commondef.h" #include CKeyEnableDeal::CKeyEnableDeal(QGraphicsScene *scene) : CKeyPressDealBase(Qt::Key_Return, scene) { + qCDebug(ClientLogger) << "CKeyEnableDeal constructor initialized"; } /** @@ -24,13 +26,16 @@ CKeyEnableDeal::CKeyEnableDeal(QGraphicsScene *scene) */ bool CKeyEnableDeal::focusItemDeal(CSceneBackgroundItem *item, CGraphicsScene *scene) { + qCDebug(ClientLogger) << "CKeyEnableDeal::focusItemDeal - Processing return key for date:" << item->getDate(); bool result = false; CFocusItem *focusItem = item->getFocusItem(); if (focusItem != nullptr) { + qCDebug(ClientLogger) << "Focus item exists, type:" << focusItem->getItemType(); result = true; QWidget *parentWidget = scene->views().at(0); switch (focusItem->getItemType()) { case CFocusItem::CBACK: { + qCDebug(ClientLogger) << "Processing background item type"; CSceneBackgroundItem *backgroundItem = dynamic_cast(focusItem); if (backgroundItem != nullptr) { QDateTime createDateTime; @@ -39,11 +44,14 @@ bool CKeyEnableDeal::focusItemDeal(CSceneBackgroundItem *item, CGraphicsScene *s createDateTime.setTime(QTime(0, 0, 0)); //如果为月视图背景则根据是否为当前时间设置不一样的创建时间 if (backgroundItem->getItemOfView() == CSceneBackgroundItem::OnMonthView) { + qCDebug(ClientLogger) << "Month view background item detected"; QDateTime currentDateTime = QDateTime::currentDateTime(); //如果为当前时间则设置创建开始时间为当前时间 if (backgroundItem->getDate() == currentDateTime.date()) { + qCDebug(ClientLogger) << "Setting create time to current time"; createDateTime.setTime(currentDateTime.time()); } else { + qCDebug(ClientLogger) << "Setting create time to 8:00"; createDateTime.setTime(QTime(8, 0, 0)); } } @@ -51,14 +59,18 @@ bool CKeyEnableDeal::focusItemDeal(CSceneBackgroundItem *item, CGraphicsScene *s } } break; case CFocusItem::CITEM: { + qCDebug(ClientLogger) << "Processing schedule item type"; DragInfoItem *scheduleItem = dynamic_cast(focusItem); CMyScheduleView dlg(scheduleItem->getData(), parentWidget); dlg.exec(); } break; default: { + qCDebug(ClientLogger) << "Processing default item type, going to day view for date:" << focusItem->getDate(); scene->signalGotoDayView(focusItem->getDate()); } break; } + } else { + qCDebug(ClientLogger) << "No focus item found"; } return result; } @@ -70,6 +82,7 @@ bool CKeyEnableDeal::focusItemDeal(CSceneBackgroundItem *item, CGraphicsScene *s */ void CKeyEnableDeal::createSchedule(const QDateTime &createDate, QWidget *parent) { + qCDebug(ClientLogger) << "CKeyEnableDeal::createSchedule - Creating schedule for datetime:" << createDate; CScheduleDlg dlg(1, parent); dlg.setDate(createDate); dlg.setAllDay(true); diff --git a/calendar-client/src/KeyPress/ckeyleftdeal.cpp b/calendar-client/src/KeyPress/ckeyleftdeal.cpp index da265e62d..e951fe3c8 100644 --- a/calendar-client/src/KeyPress/ckeyleftdeal.cpp +++ b/calendar-client/src/KeyPress/ckeyleftdeal.cpp @@ -6,21 +6,26 @@ #include "graphicsItem/cscenebackgrounditem.h" #include "cgraphicsscene.h" +#include "commondef.h" #include CKeyLeftDeal::CKeyLeftDeal(QGraphicsScene *scene) : CKeyPressDealBase(Qt::Key_Left, scene) { + qCDebug(ClientLogger) << "CKeyLeftDeal constructor initialized"; } bool CKeyLeftDeal::focusItemDeal(CSceneBackgroundItem *item, CGraphicsScene *scene) { + qCDebug(ClientLogger) << "CKeyLeftDeal::focusItemDeal - Processing left key for date:" << item->getDate(); item->initState(); if (item->getLeftItem() != nullptr) { + qCDebug(ClientLogger) << "Left item exists, setting focus to left item"; scene->setCurrentFocusItem(item->getLeftItem()); item->getLeftItem()->setItemFocus(true); } else { + qCDebug(ClientLogger) << "Left item is null, switching to previous day"; scene->setPrePage(item->getDate().addDays(-1)); } return true; diff --git a/calendar-client/src/KeyPress/ckeypressdealbase.cpp b/calendar-client/src/KeyPress/ckeypressdealbase.cpp index a63a1bbb4..9395c34e4 100644 --- a/calendar-client/src/KeyPress/ckeypressdealbase.cpp +++ b/calendar-client/src/KeyPress/ckeypressdealbase.cpp @@ -6,15 +6,18 @@ #include "cgraphicsscene.h" #include "graphicsItem/cscenebackgrounditem.h" +#include "commondef.h" CKeyPressDealBase::CKeyPressDealBase(Qt::Key key, QGraphicsScene *scene) : m_key(key) , m_scene(scene) { + qCDebug(ClientLogger) << "CKeyPressDealBase constructor initialized with key:" << key; } CKeyPressDealBase::~CKeyPressDealBase() { + qCDebug(ClientLogger) << "CKeyPressDealBase destructor called for key:" << m_key; } /** @@ -28,14 +31,18 @@ Qt::Key CKeyPressDealBase::getKey() const bool CKeyPressDealBase::dealEvent() { + qCDebug(ClientLogger) << "CKeyPressDealBase::dealEvent - Processing key event for key:" << m_key; CGraphicsScene *scene = qobject_cast(m_scene); if (scene != nullptr) { CSceneBackgroundItem *item = dynamic_cast(scene->getCurrentFocusItem()); if (item != nullptr) { + qCDebug(ClientLogger) << "Found focus item, delegating to focusItemDeal for date:" << item->getDate(); return focusItemDeal(item, scene); } else { + qCDebug(ClientLogger) << "No focus item found"; return false; } } + qCDebug(ClientLogger) << "Scene is null"; return false; } diff --git a/calendar-client/src/KeyPress/ckeypressprxy.cpp b/calendar-client/src/KeyPress/ckeypressprxy.cpp index 1d8b2583e..fc87b367f 100644 --- a/calendar-client/src/KeyPress/ckeypressprxy.cpp +++ b/calendar-client/src/KeyPress/ckeypressprxy.cpp @@ -3,15 +3,18 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "ckeypressprxy.h" +#include "commondef.h" #include CKeyPressPrxy::CKeyPressPrxy() { + qCDebug(ClientLogger) << "CKeyPressPrxy constructor initialized"; } CKeyPressPrxy::~CKeyPressPrxy() { + qCDebug(ClientLogger) << "CKeyPressPrxy destructor called, cleaning up" << m_keyEventMap.size() << "key handlers"; QMap::iterator iter = m_keyEventMap.begin(); for (; iter != m_keyEventMap.end(); ++iter) { delete iter.value(); @@ -26,10 +29,14 @@ CKeyPressPrxy::~CKeyPressPrxy() */ bool CKeyPressPrxy::keyPressDeal(int key) { + qCDebug(ClientLogger) << "CKeyPressPrxy::keyPressDeal - Processing key:" << key; bool result = m_keyEventMap.contains(key); if (result) { //如果有注册对应的key事件 开始处理 + qCDebug(ClientLogger) << "Found registered handler for key, delegating to handler"; result = m_keyEventMap[key]->dealEvent(); + } else { + qCDebug(ClientLogger) << "No handler registered for key:" << key; } return result; } @@ -40,8 +47,12 @@ bool CKeyPressPrxy::keyPressDeal(int key) */ void CKeyPressPrxy::addkeyPressDeal(CKeyPressDealBase *deal) { - if (deal != nullptr) + if (deal != nullptr) { + qCDebug(ClientLogger) << "CKeyPressPrxy::addkeyPressDeal - Adding handler for key:" << deal->getKey(); m_keyEventMap[deal->getKey()] = deal; + } else { + qCDebug(ClientLogger) << "CKeyPressPrxy::addkeyPressDeal - Attempted to add null handler"; + } } /** @@ -50,8 +61,16 @@ void CKeyPressPrxy::addkeyPressDeal(CKeyPressDealBase *deal) */ void CKeyPressPrxy::removeDeal(CKeyPressDealBase *deal) { - if (m_keyEventMap.contains(deal->getKey())) { - m_keyEventMap.remove(deal->getKey()); - delete deal; + if (deal != nullptr) { + qCDebug(ClientLogger) << "CKeyPressPrxy::removeDeal - Removing handler for key:" << deal->getKey(); + if (m_keyEventMap.contains(deal->getKey())) { + m_keyEventMap.remove(deal->getKey()); + delete deal; + qCDebug(ClientLogger) << "Handler removed and deleted"; + } else { + qCDebug(ClientLogger) << "No handler found for key:" << deal->getKey(); + } + } else { + qCDebug(ClientLogger) << "CKeyPressPrxy::removeDeal - Attempted to remove null handler"; } } diff --git a/calendar-client/src/KeyPress/ckeyrightdeal.cpp b/calendar-client/src/KeyPress/ckeyrightdeal.cpp index 286254fec..ad00dd6fd 100644 --- a/calendar-client/src/KeyPress/ckeyrightdeal.cpp +++ b/calendar-client/src/KeyPress/ckeyrightdeal.cpp @@ -6,21 +6,26 @@ #include "graphicsItem/cscenebackgrounditem.h" #include "cgraphicsscene.h" +#include "commondef.h" #include CKeyRightDeal::CKeyRightDeal(QGraphicsScene *scene) : CKeyPressDealBase(Qt::Key_Right, scene) { + qCDebug(ClientLogger) << "CKeyRightDeal constructor initialized"; } bool CKeyRightDeal::focusItemDeal(CSceneBackgroundItem *item, CGraphicsScene *scene) { + qCDebug(ClientLogger) << "CKeyRightDeal::focusItemDeal - Processing right key for date:" << item->getDate(); item->initState(); if (item->getRightItem() != nullptr) { + qCDebug(ClientLogger) << "Right item exists, setting focus to right item"; scene->setCurrentFocusItem(item->getRightItem()); item->getRightItem()->setItemFocus(true); } else { + qCDebug(ClientLogger) << "Right item is null, switching to next day"; scene->setNextPage(item->getDate().addDays(1)); } return true; diff --git a/calendar-client/src/KeyPress/ckeyupdeal.cpp b/calendar-client/src/KeyPress/ckeyupdeal.cpp index 8378f59a2..153759cfd 100644 --- a/calendar-client/src/KeyPress/ckeyupdeal.cpp +++ b/calendar-client/src/KeyPress/ckeyupdeal.cpp @@ -6,21 +6,26 @@ #include "graphicsItem/cscenebackgrounditem.h" #include "cgraphicsscene.h" +#include "commondef.h" #include CKeyUpDeal::CKeyUpDeal(QGraphicsScene *scene) : CKeyPressDealBase(Qt::Key_Up, scene) { + qCDebug(ClientLogger) << "CKeyUpDeal constructor initialized"; } bool CKeyUpDeal::focusItemDeal(CSceneBackgroundItem *item, CGraphicsScene *scene) { + qCDebug(ClientLogger) << "CKeyUpDeal::focusItemDeal - Processing up key for date:" << item->getDate(); item->initState(); if (item->getUpItem() != nullptr) { + qCDebug(ClientLogger) << "Up item exists, setting focus to up item"; scene->setCurrentFocusItem(item->getUpItem()); item->getUpItem()->setItemFocus(true); } else { + qCDebug(ClientLogger) << "Up item is null, switching to previous week"; scene->setPrePage(item->getDate().addDays(-7)); } return true; diff --git a/calendar-client/src/KeyPress/cscenetabkeydeal.cpp b/calendar-client/src/KeyPress/cscenetabkeydeal.cpp index b138905d5..1a5ac4736 100644 --- a/calendar-client/src/KeyPress/cscenetabkeydeal.cpp +++ b/calendar-client/src/KeyPress/cscenetabkeydeal.cpp @@ -6,6 +6,7 @@ #include "graphicsItem/cscenebackgrounditem.h" #include "cgraphicsscene.h" +#include "commondef.h" #include #include @@ -13,19 +14,24 @@ CSceneTabKeyDeal::CSceneTabKeyDeal(QGraphicsScene *scene) : CKeyPressDealBase(Qt::Key_Tab, scene) { + qCDebug(ClientLogger) << "CSceneTabKeyDeal constructor initialized"; } bool CSceneTabKeyDeal::focusItemDeal(CSceneBackgroundItem *item, CGraphicsScene *scene) { + qCDebug(ClientLogger) << "CSceneTabKeyDeal::focusItemDeal - Processing tab key for date:" << item->getDate(); CSceneBackgroundItem *nextItem = qobject_cast(item->setNextItemFocusAndGetNextItem()); if (nextItem == nullptr) { + qCDebug(ClientLogger) << "No next item found, clearing focus"; scene->setCurrentFocusItem(nullptr); item->setItemFocus(false); return false; } else { + qCDebug(ClientLogger) << "Found next item for date:" << nextItem->getDate(); CFocusItem *focusItem = nextItem->getFocusItem(); //如果当前焦点显示不为背景则定位到当前焦点item位置 if (focusItem->getItemType() != CFocusItem::CBACK) { + qCDebug(ClientLogger) << "Focus item is not background, centering view on item"; QGraphicsView *view = scene->views().at(0); QPointF point(scene->width() / 2, focusItem->rect().y()); view->centerOn(point); diff --git a/calendar-client/src/KeyPress/cweekdayscenetabkeydeal.cpp b/calendar-client/src/KeyPress/cweekdayscenetabkeydeal.cpp index b3bba8241..50d17de19 100644 --- a/calendar-client/src/KeyPress/cweekdayscenetabkeydeal.cpp +++ b/calendar-client/src/KeyPress/cweekdayscenetabkeydeal.cpp @@ -6,18 +6,22 @@ #include "graphicsItem/cweekdaybackgrounditem.h" #include "cgraphicsscene.h" +#include "commondef.h" CWeekDaySceneTabKeyDeal::CWeekDaySceneTabKeyDeal(QGraphicsScene *scene) : CSceneTabKeyDeal(scene) { + qCDebug(ClientLogger) << "CWeekDaySceneTabKeyDeal constructor initialized"; } bool CWeekDaySceneTabKeyDeal::focusItemDeal(CSceneBackgroundItem *item, CGraphicsScene *scene) { + qCDebug(ClientLogger) << "CWeekDaySceneTabKeyDeal::focusItemDeal - Processing tab key for date:" << item->getDate(); CWeekDayBackgroundItem *focusItem = dynamic_cast(item); if (focusItem != nullptr) { //如果当前背景是焦点显示则切换到另一个视图 if (focusItem->getItemFocus()) { + qCDebug(ClientLogger) << "Background item has focus, switching to another view"; focusItem->setItemFocus(false); scene->setActiveSwitching(true); scene->signalSwitchView(focusItem->getDate()); @@ -25,14 +29,18 @@ bool CWeekDaySceneTabKeyDeal::focusItemDeal(CSceneBackgroundItem *item, CGraphic } else { //如果该背景上还有切换显示的日程标签 if (focusItem->hasNextSubItem() || focusItem->showFocus()) { + qCDebug(ClientLogger) << "Background item has sub-items, delegating to parent handler"; return CSceneTabKeyDeal::focusItemDeal(item, scene); } else { + qCDebug(ClientLogger) << "No sub-items, initializing state and switching view"; focusItem->initState(); scene->setActiveSwitching(true); scene->signalSwitchView(focusItem->getDate()); return true; } } + } else { + qCDebug(ClientLogger) << "Failed to cast to CWeekDayBackgroundItem"; } return false; } diff --git a/calendar-client/src/calendarglobalenv.cpp b/calendar-client/src/calendarglobalenv.cpp index 0bed551c9..780a6adbb 100644 --- a/calendar-client/src/calendarglobalenv.cpp +++ b/calendar-client/src/calendarglobalenv.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "calendarglobalenv.h" +#include "commondef.h" CalendarGlobalEnv *CalendarGlobalEnv::getGlobalEnv() { @@ -18,48 +19,60 @@ CalendarGlobalEnv *CalendarGlobalEnv::operator->() const //注册关键字 bool CalendarGlobalEnv::registerKey(const QString &key, const QVariant &variant) { + qCDebug(ClientLogger) << "CalendarGlobalEnv::registerKey - Registering key:" << key; //如果不包含则添加 if (!m_GlobalEnv.contains(key)) { m_GlobalEnv[key] = variant; + qCDebug(ClientLogger) << "Key registered successfully"; return true; } + qCDebug(ClientLogger) << "Key already exists, registration failed"; return false; } //修改值 bool CalendarGlobalEnv::reviseValue(const QString &key, const QVariant &variant) { + qCDebug(ClientLogger) << "CalendarGlobalEnv::reviseValue - Revising value for key:" << key; //如果包含,则修改 if (m_GlobalEnv.contains(key)) { m_GlobalEnv[key] = variant; + qCDebug(ClientLogger) << "Value revised successfully"; return true; } + qCDebug(ClientLogger) << "Key not found, revision failed"; return false; } //移除注册的关键字 bool CalendarGlobalEnv::removeKey(const QString &key) { + qCDebug(ClientLogger) << "CalendarGlobalEnv::removeKey - Removing key:" << key; //如果包含则移除 if (m_GlobalEnv.contains(key)) { m_GlobalEnv.remove(key); + qCDebug(ClientLogger) << "Key removed successfully"; return true; } + qCDebug(ClientLogger) << "Key not found, removal failed"; return false; } //根据关键字获取对应的值 bool CalendarGlobalEnv::getValueByKey(const QString &key, QVariant &variant) { + qCDebug(ClientLogger) << "CalendarGlobalEnv::getValueByKey - Getting value for key:" << key; if (m_GlobalEnv.contains(key)) { variant = m_GlobalEnv.value(key); + qCDebug(ClientLogger) << "Value retrieved successfully"; return true; } + qCDebug(ClientLogger) << "Key not found, retrieval failed"; return false; } CalendarGlobalEnv::CalendarGlobalEnv() : m_GlobalEnv{} { - + qCDebug(ClientLogger) << "CalendarGlobalEnv constructor initialized"; } diff --git a/calendar-client/src/configsettings.cpp b/calendar-client/src/configsettings.cpp index 6e3d6a340..ff04294d3 100644 --- a/calendar-client/src/configsettings.cpp +++ b/calendar-client/src/configsettings.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "configsettings.h" +#include "commondef.h" #include #include @@ -11,19 +12,23 @@ DCORE_USE_NAMESPACE; CConfigSettings::CConfigSettings() { + qCDebug(ClientLogger) << "CConfigSettings constructor initialized"; init(); } CConfigSettings::~CConfigSettings() { + qCDebug(ClientLogger) << "CConfigSettings destructor called"; releaseInstance(); } void CConfigSettings::init() { + qCDebug(ClientLogger) << "CConfigSettings::init - Initializing settings"; //如果为空则创建 if (m_settings == nullptr) { auto configFilepath = DStandardPaths::standardLocations(QStandardPaths::AppConfigLocation).value(0) + "/config.ini"; + qCDebug(ClientLogger) << "Creating settings with config file:" << configFilepath; m_settings = new QSettings(configFilepath, QSettings::IniFormat); } initSetting(); @@ -31,6 +36,7 @@ void CConfigSettings::init() void CConfigSettings::initSetting() { + qCDebug(ClientLogger) << "CConfigSettings::initSetting - Loading initial settings"; m_userSidebarStatus = value("userSidebarStatus", true).toBool(); } @@ -39,6 +45,7 @@ void CConfigSettings::initSetting() */ void CConfigSettings::releaseInstance() { + qCDebug(ClientLogger) << "CConfigSettings::releaseInstance - Releasing settings instance"; delete m_settings; m_settings = nullptr; } @@ -51,30 +58,37 @@ CConfigSettings *CConfigSettings::getInstance() void CConfigSettings::sync() { + // qCDebug(ClientLogger) << "CConfigSettings::sync - Syncing settings to disk"; m_settings->sync(); } QVariant CConfigSettings::value(const QString &key, const QVariant &defaultValue) { - return m_settings->value(key, defaultValue); + QVariant result = m_settings->value(key, defaultValue); + // qCDebug(ClientLogger) << "CConfigSettings::value - Getting value for key:" << key << "Result:" << result; + return result; } //设置对应key的值 void CConfigSettings::setOption(const QString &key, const QVariant &value) { + // qCDebug(ClientLogger) << "CConfigSettings::setOption - Setting key:" << key << "to value:" << value; m_settings->setValue(key, value); } //移除对应的配置信息 void CConfigSettings::remove(const QString &key) { + // qCDebug(ClientLogger) << "CConfigSettings::remove - Removing key:" << key; m_settings->remove(key); } //判断是否包含对应的key bool CConfigSettings::contains(const QString &key) const { - return m_settings->contains(key); + bool result = m_settings->contains(key); + // qCDebug(ClientLogger) << "CConfigSettings::contains - Checking if contains key:" << key << "Result:" << result; + return result; } CConfigSettings *CConfigSettings::operator->() const @@ -84,11 +98,13 @@ CConfigSettings *CConfigSettings::operator->() const bool CConfigSettings::getUserSidebarStatus() { + // qCDebug(ClientLogger) << "CConfigSettings::getUserSidebarStatus - Current status:" << m_userSidebarStatus; return m_userSidebarStatus; } void CConfigSettings::setUserSidebarStatus(bool status) { + // qCDebug(ClientLogger) << "CConfigSettings::setUserSidebarStatus - Setting status to:" << status; m_userSidebarStatus = status; setOption("userSidebarStatus", m_userSidebarStatus); } diff --git a/calendar-client/src/customWidget/animationstackedwidget.cpp b/calendar-client/src/customWidget/animationstackedwidget.cpp index b504ac178..7be7d3c22 100644 --- a/calendar-client/src/customWidget/animationstackedwidget.cpp +++ b/calendar-client/src/customWidget/animationstackedwidget.cpp @@ -13,12 +13,14 @@ AnimationStackedWidget::AnimationStackedWidget(const AnimationOri ori, QWidget * , m_animationOri(ori) , m_Animation(new QPropertyAnimation(this, "offset", this)) { + qCDebug(ClientLogger) << "AnimationStackedWidget constructor initialized with orientation:" << ori; setDuration(1000); connect(m_Animation, &QPropertyAnimation::finished, this, &AnimationStackedWidget::animationFinished); } AnimationStackedWidget::~AnimationStackedWidget() { + qCDebug(ClientLogger) << "AnimationStackedWidget destructor called"; delete m_Animation; } @@ -86,15 +88,18 @@ void AnimationStackedWidget::setCurrent(int index) */ void AnimationStackedWidget::setPre() { + qCDebug(ClientLogger) << "AnimationStackedWidget::setPre - Setting previous widget"; //获取堆窗口数 const int count = this->count(); switch (m_animationOri) { case LR: { m_moveOri = LeftToRight; + qCDebug(ClientLogger) << "Animation direction: LeftToRight"; } break; case TB: { m_moveOri = TopToBottom; + qCDebug(ClientLogger) << "Animation direction: TopToBottom"; } break; } @@ -103,6 +108,7 @@ void AnimationStackedWidget::setPre() if (nextIndex < 0) { nextIndex = nextIndex + count; } + qCDebug(ClientLogger) << "Current index:" << currentIndex() << "Next index:" << nextIndex; setCurrentWidget(nextIndex, getBeginValue()); } @@ -111,20 +117,24 @@ void AnimationStackedWidget::setPre() */ void AnimationStackedWidget::setNext() { + qCDebug(ClientLogger) << "AnimationStackedWidget::setNext - Setting next widget"; //获取堆窗口数 const int count = this->count(); switch (m_animationOri) { case LR: { m_moveOri = RightToLeft; + qCDebug(ClientLogger) << "Animation direction: RightToLeft"; } break; case TB: { m_moveOri = BottomToTop; + qCDebug(ClientLogger) << "Animation direction: BottomToTop"; } break; } //获取下一个窗口编号 int nextIndex = (currentIndex() + 1) % count; + qCDebug(ClientLogger) << "Current index:" << currentIndex() << "Next index:" << nextIndex; setCurrentWidget(nextIndex, getBeginValue()); } @@ -135,6 +145,7 @@ void AnimationStackedWidget::setNext() */ void AnimationStackedWidget::setCurrentWidget(int &index, int beginWidth) { + qCDebug(ClientLogger) << "AnimationStackedWidget::setCurrentWidget - Setting widget index:" << index << "with begin width:" << beginWidth; //如果正在动画,那么退出 if (m_IsAnimation) { qCDebug(ClientLogger) << "Animation in progress, queueing index:" << index; @@ -154,6 +165,7 @@ void AnimationStackedWidget::setCurrentWidget(int &index, int beginWidth) m_Animation->setStartValue(beginWidth); m_Animation->setEndValue(0); m_Animation->setDuration(m_Duration); + qCDebug(ClientLogger) << "Starting animation from" << beginWidth << "to 0 with duration:" << m_Duration; m_Animation->start(); } @@ -163,6 +175,7 @@ void AnimationStackedWidget::setCurrentWidget(int &index, int beginWidth) */ int AnimationStackedWidget::getBeginValue() { + // qCDebug(ClientLogger) << "AnimationStackedWidget::getBeginValue - Getting begin value"; //存储窗口高度或宽度 int value {0}; //获取窗口矩阵 @@ -187,15 +200,18 @@ int AnimationStackedWidget::getBeginValue() */ AnimationStackedWidget::MoveOrientation AnimationStackedWidget::getMoveOrientation(const int currIndex, const int nextIndex) { + qCDebug(ClientLogger) << "AnimationStackedWidget::getMoveOrientation - Current index:" << currIndex << "Next index:" << nextIndex; MoveOrientation moveOri{LeftToRight}; if (nextIndex < currIndex) { switch (m_animationOri) { case LR: { moveOri = LeftToRight; + qCDebug(ClientLogger) << "Selected orientation: LeftToRight"; } break; case TB: { moveOri = TopToBottom; + qCDebug(ClientLogger) << "Selected orientation: TopToBottom"; } break; } @@ -203,10 +219,12 @@ AnimationStackedWidget::MoveOrientation AnimationStackedWidget::getMoveOrientati switch (m_animationOri) { case LR: { moveOri = RightToLeft; + qCDebug(ClientLogger) << "Selected orientation: RightToLeft"; } break; case TB: { moveOri = BottomToTop; + qCDebug(ClientLogger) << "Selected orientation: BottomToTop"; } break; } @@ -221,6 +239,7 @@ AnimationStackedWidget::MoveOrientation AnimationStackedWidget::getMoveOrientati */ void AnimationStackedWidget::paintCurrentWidget(QPainter &paint, int currentIndex) { + // qCDebug(ClientLogger) << "AnimationStackedWidget::paintCurrentWidget - Painting current widget"; //获得当前页面的Widget QWidget *currentWidget = widget(currentIndex); QPixmap currentPixmap(currentWidget->size()); @@ -237,21 +256,25 @@ void AnimationStackedWidget::paintCurrentWidget(QPainter &paint, int currentInde QRectF sourceRect; switch (m_moveOri) { case LeftToRight: { + // qCDebug(ClientLogger) << "AnimationStackedWidget::paintCurrentWidget - Painting current widget"; targetRect = QRectF(widgetWidth - value, 0, value, widgetHeight); sourceRect = QRectF(0.0, 0.0, value, widgetHeight); } break; case RightToLeft: { + // qCDebug(ClientLogger) << "AnimationStackedWidget::paintCurrentWidget - Painting current widget"; targetRect = QRectF(0.0, 0.0, value, widgetHeight); sourceRect = QRectF(widgetWidth - value, 0, value, widgetHeight); } break; case TopToBottom: { + // qCDebug(ClientLogger) << "AnimationStackedWidget::paintCurrentWidget - Painting current widget"; targetRect = QRectF(0.0, widgetHeight - value, widgetWidth, value); sourceRect = QRectF(0.0, 0.0, widgetWidth, value); } break; case BottomToTop: { + // qCDebug(ClientLogger) << "AnimationStackedWidget::paintCurrentWidget - Painting current widget"; targetRect = QRectF(0.0, 0.0, widgetWidth, value); sourceRect = QRectF(0, widgetHeight - value, widgetWidth, value); } @@ -266,6 +289,7 @@ void AnimationStackedWidget::paintCurrentWidget(QPainter &paint, int currentInde */ void AnimationStackedWidget::paintNextWidget(QPainter &paint, int nextIndex) { + // qCDebug(ClientLogger) << "AnimationStackedWidget::paintNextWidget - Painting next widget"; QWidget *nextWidget = widget(nextIndex); QRect widgetRect = this->rect(); //设置下一个窗口的大小 @@ -281,21 +305,25 @@ void AnimationStackedWidget::paintNextWidget(QPainter &paint, int nextIndex) QRectF sourceRect; switch (m_moveOri) { case LeftToRight: { + // qCDebug(ClientLogger) << "AnimationStackedWidget::paintNextWidget - Painting next widget"; targetRect = QRectF(0.0, 0.0, widgetWidth - value, widgetHeight); sourceRect = QRectF(value, 0.0, widgetWidth - value, widgetHeight); } break; case RightToLeft: { + // qCDebug(ClientLogger) << "AnimationStackedWidget::paintNextWidget - Painting next widget"; targetRect = QRectF(value, 0.0, widgetWidth - value, widgetHeight); sourceRect = QRectF(0.0, 0.0, widgetWidth - value, widgetHeight); } break; case TopToBottom: { + // qCDebug(ClientLogger) << "AnimationStackedWidget::paintNextWidget - Painting next widget"; targetRect = QRectF(0.0, 0.0, widgetWidth, widgetHeight - value); sourceRect = QRectF(0.0, value, widgetWidth, widgetHeight - value); } break; case BottomToTop: { + // qCDebug(ClientLogger) << "AnimationStackedWidget::paintNextWidget - Painting next widget"; targetRect = QRectF(0.0, value, widgetWidth, widgetHeight - value); sourceRect = QRectF(0.0, 0.0, widgetWidth, widgetHeight - value); } @@ -309,6 +337,7 @@ void AnimationStackedWidget::paintNextWidget(QPainter &paint, int nextIndex) */ double AnimationStackedWidget::offset() const { + // qCDebug(ClientLogger) << "AnimationStackedWidget::offset - Getting offset"; return m_offset; } @@ -318,6 +347,7 @@ double AnimationStackedWidget::offset() const */ void AnimationStackedWidget::setOffset(double offset) { + // qCDebug(ClientLogger) << "AnimationStackedWidget::setOffset - Setting offset to:" << offset; m_offset = offset; update(); } diff --git a/calendar-client/src/customWidget/cbuttonbox.cpp b/calendar-client/src/customWidget/cbuttonbox.cpp index a1d854b2a..fa670ce41 100644 --- a/calendar-client/src/customWidget/cbuttonbox.cpp +++ b/calendar-client/src/customWidget/cbuttonbox.cpp @@ -3,21 +3,25 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "cbuttonbox.h" +#include "commondef.h" #include CButtonBox::CButtonBox(QWidget *parent) : DButtonBox(parent) { + // qCDebug(ClientLogger) << "CButtonBox constructor initialized"; //设置接受tab焦点切换 this->setFocusPolicy(Qt::TabFocus); } void CButtonBox::focusInEvent(QFocusEvent *event) { + // qCDebug(ClientLogger) << "CButtonBox::focusInEvent - Focus reason:" << event->reason(); DButtonBox::focusInEvent(event); //窗口激活时,不设置Button焦点显示 if (event->reason() != Qt::ActiveWindowFocusReason) { + // qCDebug(ClientLogger) << "Setting focus to button with checked ID:" << checkedId(); //设置当前选中项为焦点 this->button(checkedId())->setFocus(); } @@ -25,9 +29,11 @@ void CButtonBox::focusInEvent(QFocusEvent *event) void CButtonBox::focusOutEvent(QFocusEvent *event) { + // qCDebug(ClientLogger) << "CButtonBox::focusOutEvent - Focus reason:" << event->reason(); DButtonBox::focusOutEvent(event); //当tab离开当前buttonbox窗口时,设置选中项为焦点 if (event->reason() == Qt::TabFocusReason) { + // qCDebug(ClientLogger) << "TabFocusReason, setting focus to button with checked ID:" << checkedId(); //设置当前选中项为焦点 this->button(checkedId())->setFocus(); } diff --git a/calendar-client/src/customWidget/ccustomtimeedit.cpp b/calendar-client/src/customWidget/ccustomtimeedit.cpp index 2125d2ccb..b96753ef9 100644 --- a/calendar-client/src/customWidget/ccustomtimeedit.cpp +++ b/calendar-client/src/customWidget/ccustomtimeedit.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "ccustomtimeedit.h" +#include "commondef.h" #include #include @@ -11,6 +12,7 @@ CCustomTimeEdit::CCustomTimeEdit(QWidget *parent) : QTimeEdit(parent) { + qCDebug(ClientLogger) << "CCustomTimeEdit constructor initialized"; //设置edit最大宽度,不影响其他控件使用 setMaximumWidth(80); setButtonSymbols(QTimeEdit::NoButtons); @@ -22,25 +24,30 @@ CCustomTimeEdit::CCustomTimeEdit(QWidget *parent) */ QLineEdit *CCustomTimeEdit::getLineEdit() { + // qCDebug(ClientLogger) << "CCustomTimeEdit::getLineEdit - Returning line edit"; return lineEdit(); } void CCustomTimeEdit::focusInEvent(QFocusEvent *event) { + // qCDebug(ClientLogger) << "CCustomTimeEdit::focusInEvent - Focus reason:" << event->reason(); QTimeEdit::focusInEvent(event); emit signalUpdateFocus(true); } void CCustomTimeEdit::focusOutEvent(QFocusEvent *event) { + // qCDebug(ClientLogger) << "CCustomTimeEdit::focusOutEvent - Focus reason:" << event->reason(); QTimeEdit::focusOutEvent(event); emit signalUpdateFocus(false); } void CCustomTimeEdit::mousePressEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "CCustomTimeEdit::mousePressEvent - Position:" << event->pos(); //设置父类widget焦点 if (parentWidget() != nullptr) { + // qCDebug(ClientLogger) << "Setting focus to parent widget"; parentWidget()->setFocus(Qt::TabFocusReason); } //设置点击位置的光标 @@ -50,9 +57,11 @@ void CCustomTimeEdit::mousePressEvent(QMouseEvent *event) void CCustomTimeEdit::keyPressEvent(QKeyEvent *event) { + // qCDebug(ClientLogger) << "CCustomTimeEdit::keyPressEvent - Key:" << event->key(); QTimeEdit::keyPressEvent(event); //鼠标左右键,切换光标位置 if (event->key() == Qt::Key_Left || event->key() == Qt::Key_Right) { + // qCDebug(ClientLogger) << "Left/Right key pressed, setting focus to parent and updating cursor position"; if (parentWidget() != nullptr) { parentWidget()->setFocus(Qt::TabFocusReason); } @@ -62,7 +71,9 @@ void CCustomTimeEdit::keyPressEvent(QKeyEvent *event) void CCustomTimeEdit::mouseDoubleClickEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "CCustomTimeEdit::mouseDoubleClickEvent - Position:" << event->pos(); QTimeEdit::mouseDoubleClickEvent(event); //鼠标双击,选中section + // qCDebug(ClientLogger) << "Double click detected, selecting section:" << currentSection(); setSelectedSection(currentSection()); } diff --git a/calendar-client/src/customWidget/cdateedit.cpp b/calendar-client/src/customWidget/cdateedit.cpp index 4c50585e3..9c4bbc193 100644 --- a/calendar-client/src/customWidget/cdateedit.cpp +++ b/calendar-client/src/customWidget/cdateedit.cpp @@ -28,10 +28,12 @@ CDateEdit::CDateEdit(QWidget *parent) : QDateEdit(parent) void CDateEdit::setDate(QDate date) { + qCDebug(ClientLogger) << "CDateEdit::setDate - Setting date to:" << date; QDateEdit::setDate(date); //只有在农历日程时,才需要获取农历信息 QString dtFormat = m_showLunarCalendar ? m_format + getLunarName(date) : m_format; m_strCurrrentDate = date.toString(dtFormat); + qCDebug(ClientLogger) << "Updated current date string:" << m_strCurrrentDate; } void CDateEdit::setDisplayFormat(QString format) @@ -44,6 +46,7 @@ void CDateEdit::setDisplayFormat(QString format) QString CDateEdit::displayFormat() { + qCDebug(ClientLogger) << "CDateEdit::displayFormat - Returning format:" << m_format; return m_format; } @@ -59,6 +62,7 @@ void CDateEdit::setLunarCalendarStatus(bool status) void CDateEdit::setLunarTextFormat(QTextCharFormat format) { + qCDebug(ClientLogger) << "CDateEdit::setLunarTextFormat - Setting lunar text format"; m_lunarTextFormat = format; //刷新文本样式 slotRefreshLineEditTextFormat(text()); @@ -66,6 +70,7 @@ void CDateEdit::setLunarTextFormat(QTextCharFormat format) QTextCharFormat CDateEdit::getsetLunarTextFormat() { + // qCDebug(ClientLogger) << "CDateEdit::getsetLunarTextFormat - Returning lunar text format"; return m_lunarTextFormat; } @@ -79,9 +84,11 @@ void CDateEdit::setCalendarPopup(bool enable) void CDateEdit::slotDateEidtInfo(const QDate &date) { + qCDebug(ClientLogger) << "CDateEdit::slotDateEidtInfo - Setting date edit info for date:" << date; QString format = m_format; if (m_showLunarCalendar) { + qCDebug(ClientLogger) << "CDateEdit::slotDateEidtInfo - Showing lunar calendar"; if (!showGongli()) { qCDebug(ClientLogger) << "Hiding Gregorian calendar due to space constraints"; format = "yyyy/"; @@ -112,8 +119,10 @@ void CDateEdit::slotDateEidtInfo(const QDate &date) //恢复原状 if (hasSelected) { + qCDebug(ClientLogger) << "Restoring selection state, section:" << section; setSelectedSection(section); //设置选中节 } else { + qCDebug(ClientLogger) << "Restoring cursor position:" << cPos; lineEdit()->setCursorPosition(cPos); //设置光标位置 } //刷新文本样式 @@ -123,6 +132,7 @@ void CDateEdit::slotDateEidtInfo(const QDate &date) void CDateEdit::slotRefreshLineEditTextFormat(const QString &text) { + qCDebug(ClientLogger) << "CDateEdit::slotRefreshLineEditTextFormat - Refreshing line edit text format for text:" << text; QFont font = lineEdit()->font(); QFontMetrics fm(font); int textWidth = fm.horizontalAdvance(text); @@ -135,6 +145,7 @@ void CDateEdit::slotRefreshLineEditTextFormat(const QString &text) //不显示农历时无需处理 if (!m_showLunarCalendar) { + qCDebug(ClientLogger) << "CDateEdit::slotRefreshLineEditTextFormat - Not showing lunar calendar, returning"; return; } @@ -152,8 +163,10 @@ void CDateEdit::slotRefreshLineEditTextFormat(const QString &text) void CDateEdit::slotCursorPositionChanged(int oldPos, int newPos) { + qCDebug(ClientLogger) << "CDateEdit::slotCursorPositionChanged - Cursor position changed from:" << oldPos << "to:" << newPos; //不显示农历时无需处理 if (!m_showLunarCalendar) { + qCDebug(ClientLogger) << "CDateEdit::slotCursorPositionChanged - Not showing lunar calendar, returning"; return; } Q_UNUSED(oldPos); @@ -182,8 +195,10 @@ void CDateEdit::slotCursorPositionChanged(int oldPos, int newPos) void CDateEdit::slotSelectionChanged() { + qCDebug(ClientLogger) << "CDateEdit::slotSelectionChanged - Selection changed"; //不显示农历时无需处理 if (!m_showLunarCalendar) { + qCDebug(ClientLogger) << "CDateEdit::slotSelectionChanged - Not showing lunar calendar, returning"; return; } //全选时重新设置为只选择时间不选择农历 @@ -195,12 +210,16 @@ void CDateEdit::slotSelectionChanged() QString CDateEdit::getLunarName(const QDate &date) { - return gLunarManager->getHuangLiShortName(date); + QString lunarName = gLunarManager->getHuangLiShortName(date); + // qCDebug(ClientLogger) << "CDateEdit::getLunarName - Date:" << date << "Lunar name:" << lunarName; + return lunarName; } void CDateEdit::setLineEditTextFormat(QLineEdit *lineEdit, const QList &formats) { + qCDebug(ClientLogger) << "CDateEdit::setLineEditTextFormat - Setting text format for line edit"; if (!lineEdit) { + qCDebug(ClientLogger) << "Line edit is null, returning"; return; } QList attributes; @@ -216,36 +235,45 @@ void CDateEdit::setLineEditTextFormat(QLineEdit *lineEdit, const QListtype() == QEvent::FontChange && m_showLunarCalendar) { + qCDebug(ClientLogger) << "CDateEdit::changeEvent - Font change detected, refreshing date info"; slotDateEidtInfo(date()); } } bool CDateEdit::showGongli() { + qCDebug(ClientLogger) << "CDateEdit::showGongli - Current date:" << m_strCurrrentDate; QString str = m_strCurrrentDate; QFontMetrics fontMetrice(lineEdit()->font()); if (fontMetrice.horizontalAdvance(str) > lineEdit()->width() - 20) { + qCDebug(ClientLogger) << "CDateEdit::showGongli - Current date width is greater than line edit width, returning false"; return false; } + qCDebug(ClientLogger) << "CDateEdit::showGongli - Current date width is less than line edit width, returning true"; return true; } void CDateEdit::updateCalendarWidget() { + qCDebug(ClientLogger) << "CDateEdit::updateCalendarWidget - Calendar popup:" << calendarPopup() + << "Show lunar calendar:" << m_showLunarCalendar; if (calendarPopup()) { //setCalendarWidget: //The editor does not automatically take ownership of the calendar widget. if (m_showLunarCalendar) { + qCDebug(ClientLogger) << "Creating and setting lunar calendar widget"; setCalendarWidget(new LunarCalendarWidget(this)); } else { + qCDebug(ClientLogger) << "Creating and setting standard calendar widget"; setCalendarWidget(new QCalendarWidget(this)); } } @@ -253,8 +281,10 @@ void CDateEdit::updateCalendarWidget() void CDateEdit::setEditCursorPos(int pos) { + qCDebug(ClientLogger) << "CDateEdit::setEditCursorPos - Setting cursor position to:" << pos; QLineEdit *edit = lineEdit(); if (nullptr != edit) { + qCDebug(ClientLogger) << "CDateEdit::setEditCursorPos - Line edit is not null, setting cursor position to:" << pos; edit->setCursorPosition(pos); } } diff --git a/calendar-client/src/customWidget/cdialogiconbutton.cpp b/calendar-client/src/customWidget/cdialogiconbutton.cpp index 3a2895cd9..72fc244f2 100644 --- a/calendar-client/src/customWidget/cdialogiconbutton.cpp +++ b/calendar-client/src/customWidget/cdialogiconbutton.cpp @@ -4,15 +4,18 @@ #include "cdialogiconbutton.h" #include "cschedulebasewidget.h" +#include "commondef.h" CDialogIconButton::CDialogIconButton(QWidget *parent) : DIconButton(parent) { + qCDebug(ClientLogger) << "CDialogIconButton constructor initialized"; initView(); connect(this, &DIconButton::clicked, this, &CDialogIconButton::slotIconClicked); } void CDialogIconButton::initView() { + qCDebug(ClientLogger) << "CDialogIconButton::initView - Setting up button and dialog"; setIcon(DStyle::SP_ArrowDown); m_dialog = new TimeJumpDialog(DArrowRectangle::ArrowTop, this); setFlat(true); @@ -20,6 +23,7 @@ void CDialogIconButton::initView() void CDialogIconButton::slotIconClicked() { + qCDebug(ClientLogger) << "CDialogIconButton::slotIconClicked - Button clicked, showing popup"; //获取全局时间并显示弹窗 m_dialog->showPopup(CScheduleBaseWidget::getSelectDate(), mapToGlobal(QPoint(width()/2, height()))); } diff --git a/calendar-client/src/customWidget/cdynamicicon.cpp b/calendar-client/src/customWidget/cdynamicicon.cpp index fe303af99..22c24e9a4 100644 --- a/calendar-client/src/customWidget/cdynamicicon.cpp +++ b/calendar-client/src/customWidget/cdynamicicon.cpp @@ -3,7 +3,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "cdynamicicon.h" - +#include "commondef.h" #include #include @@ -39,6 +39,7 @@ CDynamicIcon::CDynamicIcon(int width, int height) , m_backgroundrenderer(new QSvgRenderer()) { + qCDebug(ClientLogger) << "CDynamicIcon constructor initialized with size:" << width << "x" << height; m_pixmap->fill(Qt::transparent); m_Date = QDate::currentDate(); setDate(m_Date); @@ -46,6 +47,7 @@ CDynamicIcon::CDynamicIcon(int width, int height) CDynamicIcon::~CDynamicIcon() { + qCDebug(ClientLogger) << "CDynamicIcon destructor called"; delete m_pixmap; m_pixmap = nullptr; @@ -65,7 +67,9 @@ CDynamicIcon::~CDynamicIcon() CDynamicIcon *CDynamicIcon::getInstance() { + qCDebug(ClientLogger) << "CDynamicIcon::getInstance - Getting singleton instance"; if (nullptr == m_Icon) { + qCDebug(ClientLogger) << "Creating new CDynamicIcon instance"; m_Icon = new CDynamicIcon(512, 512); } return m_Icon; @@ -73,6 +77,7 @@ CDynamicIcon *CDynamicIcon::getInstance() void CDynamicIcon::releaseInstance() { + qCDebug(ClientLogger) << "CDynamicIcon::releaseInstance - Releasing singleton instance"; if (m_Icon != nullptr) { delete m_Icon; m_Icon = nullptr; @@ -81,18 +86,22 @@ void CDynamicIcon::releaseInstance() void CDynamicIcon::setDate(const QDate &date) { + // qCDebug(ClientLogger) << "CDynamicIcon::setDate - Setting date to:" << 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()); + // qCDebug(ClientLogger) << "Loading week SVG:" << weekfile; m_Weekrenderer->load(weekfile); QString monthfile = QString(":/resources/DynamicIcon/month%1.svg").arg(date.month()); + // qCDebug(ClientLogger) << "Loading month SVG:" << monthfile; m_Monthrenderer->load(monthfile); QString backgroundfile(":/resources/DynamicIcon/calendar_bg.svg"); + // qCDebug(ClientLogger) << "Loading background SVG:" << backgroundfile; m_backgroundrenderer->load(backgroundfile); //draw pixmap @@ -102,23 +111,28 @@ void CDynamicIcon::setDate(const QDate &date) void CDynamicIcon::setIcon() { + // qCDebug(ClientLogger) << "CDynamicIcon::setIcon - Setting application icon"; QIcon icon(this->getPixmap()); qApp->setProductIcon(icon); qApp->setWindowIcon(icon); - if (qApp->aboutDialog() != nullptr) + if (qApp->aboutDialog() != nullptr) { + // qCDebug(ClientLogger) << "Setting about dialog icon"; qApp->aboutDialog()->setProductIcon(icon); + } m_Titlebar->setIcon(icon); } void CDynamicIcon::setTitlebar(DTitlebar *titlebar) { + // qCDebug(ClientLogger) << "CDynamicIcon::setTitlebar - Setting titlebar"; m_Titlebar = titlebar; } void CDynamicIcon::paintPixmap(QPixmap *pixmap) { + // qCDebug(ClientLogger) << "CDynamicIcon::paintPixmap - Painting icon with size:" << pixmap->size(); QPainter painter(pixmap); //draw background diff --git a/calendar-client/src/customWidget/colorWidget/colorlabel.cpp b/calendar-client/src/customWidget/colorWidget/colorlabel.cpp index a920e38bd..c6c64e75d 100644 --- a/calendar-client/src/customWidget/colorWidget/colorlabel.cpp +++ b/calendar-client/src/customWidget/colorWidget/colorlabel.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "colorlabel.h" +#include "commondef.h" #include #include @@ -14,6 +15,7 @@ ColorLabel::ColorLabel(DWidget *parent) : DLabel(parent) , m_pressed(false) { + qCDebug(ClientLogger) << "ColorLabel constructor initialized"; setMouseTracking(true); m_dotCursor = pickColorCursor(); } @@ -21,6 +23,7 @@ ColorLabel::ColorLabel(DWidget *parent) //h∈(0, 360), s∈(0, 1), v∈(0, 1) QColor ColorLabel::getColor(qreal h, qreal s, qreal v) { + // qCDebug(ClientLogger) << "ColorLabel::getColor - h:" << h << "s:" << s << "v:" << v; int hi = int(h / 60) % 6; qreal f = h / 60 - hi; @@ -28,31 +31,36 @@ QColor ColorLabel::getColor(qreal h, qreal s, qreal v) qreal q = v * (1 - f * s); qreal t = v * (1 - (1 - f) * s); + QColor result; if (hi == 0) { - return QColor(std::min(int(255 * p), 255), std::min(int(255 * q), 255), std::min(int(255 * v), 255)); + result = QColor(std::min(int(255 * p), 255), std::min(int(255 * q), 255), std::min(int(255 * v), 255)); } else if (hi == 1) { - return QColor(std::min(int(255 * t), 255), std::min(int(255 * p), 255), std::min(int(255 * v), 255)); + result = QColor(std::min(int(255 * t), 255), std::min(int(255 * p), 255), std::min(int(255 * v), 255)); } else if (hi == 2) { - return QColor(std::min(int(255 * v), 255), std::min(int(255 * p), 255), int(255 * q)); + result = QColor(std::min(int(255 * v), 255), std::min(int(255 * p), 255), int(255 * q)); } else if (hi == 3) { - return QColor(std::min(int(255 * v), 255), std::min(int(255 * t), 255), std::min(int(255 * p), 255)); + result = QColor(std::min(int(255 * v), 255), std::min(int(255 * t), 255), std::min(int(255 * p), 255)); } else if (hi == 4) { - return QColor(std::min(int(255 * q), 255), std::min(int(255 * v), 255), std::min(int(255 * p), 255)); + result = QColor(std::min(int(255 * q), 255), std::min(int(255 * v), 255), std::min(int(255 * p), 255)); } else { - return QColor(std::min(int(255 * p), 255), std::min(int(255 * v), 255), std::min(int(255 * t), 255)); + result = QColor(std::min(int(255 * p), 255), std::min(int(255 * v), 255), std::min(int(255 * t), 255)); } - + qCDebug(ClientLogger) << "Calculated color:" << result; + return result; } void ColorLabel::setHue(int hue) { + qCDebug(ClientLogger) << "ColorLabel::setHue - Setting hue to:" << hue; m_hue = hue; update(); } void ColorLabel::pickColor(QPoint pos, bool picked) { + qCDebug(ClientLogger) << "ColorLabel::pickColor - Position:" << pos << "Picked:" << picked; if (!rect().contains(pos)) { + qCDebug(ClientLogger) << "Position outside label bounds, ignoring"; return; } @@ -63,22 +71,29 @@ void ColorLabel::pickColor(QPoint pos, bool picked) if (!pickImg.isNull()) { QRgb pickRgb = pickImg.pixel(pos); m_pickedColor = QColor(qRed(pickRgb), qGreen(pickRgb), qBlue(pickRgb)); + qCDebug(ClientLogger) << "Picked color:" << m_pickedColor; } else { + qCDebug(ClientLogger) << "Image is null, defaulting to black"; m_pickedColor = QColor(0, 0, 0); } if (picked) { + qCDebug(ClientLogger) << "Emitting picked color signal"; emit signalpickedColor(m_pickedColor); } else { + qCDebug(ClientLogger) << "Emitting preview color signal"; emit signalPreViewColor(m_pickedColor); } } void ColorLabel::paintEvent(QPaintEvent *) { + // qCDebug(ClientLogger) << "ColorLabel::paintEvent - Entered:" << m_entered; if (m_entered) { + // qCDebug(ClientLogger) << "ColorLabel::paintEvent - Setting cursor to dot cursor"; setCursor(m_dotCursor); } else { + // qCDebug(ClientLogger) << "ColorLabel::paintEvent - Setting cursor to default cursor"; setCursor(QCursor()); } @@ -113,6 +128,7 @@ void ColorLabel::paintEvent(QPaintEvent *) void ColorLabel::mousePressEvent(QMouseEvent *e) { + // qCDebug(ClientLogger) << "ColorLabel::mousePressEvent - Position:" << e->pos(); m_pressed = true; pickColor(e->pos(), m_pressed); QLabel::mousePressEvent(e); @@ -120,6 +136,7 @@ void ColorLabel::mousePressEvent(QMouseEvent *e) void ColorLabel::mouseMoveEvent(QMouseEvent *e) { + // qCDebug(ClientLogger) << "ColorLabel::mouseMoveEvent - Position:" << e->pos(); if (rect().contains(e->pos())) { m_entered = true; } else { @@ -133,7 +150,9 @@ void ColorLabel::mouseMoveEvent(QMouseEvent *e) void ColorLabel::mouseReleaseEvent(QMouseEvent *e) { + // qCDebug(ClientLogger) << "ColorLabel::mouseReleaseEvent - Position:" << e->pos(); if (m_pressed && rect().contains(e->pos())) { + qCDebug(ClientLogger) << "Click detected, emitting clicked signal"; emit clicked(); } m_pressed = false; @@ -142,6 +161,7 @@ void ColorLabel::mouseReleaseEvent(QMouseEvent *e) QCursor ColorLabel::pickColorCursor() { + // qCDebug(ClientLogger) << "ColorLabel::pickColorCursor - Creating custom cursor"; int tipWidth = 11; QPixmap cursorPix = QPixmap(QSize(tipWidth, tipWidth)); cursorPix.fill(QColor(Qt::transparent)); diff --git a/calendar-client/src/customWidget/colorWidget/colorpickerWidget.cpp b/calendar-client/src/customWidget/colorWidget/colorpickerWidget.cpp index 7a024e690..58e6baf38 100644 --- a/calendar-client/src/customWidget/colorWidget/colorpickerWidget.cpp +++ b/calendar-client/src/customWidget/colorWidget/colorpickerWidget.cpp @@ -4,6 +4,7 @@ #include "colorpickerWidget.h" #include "tabletconfig.h" +#include "commondef.h" #include #include @@ -27,6 +28,7 @@ CColorPickerWidget::CColorPickerWidget(QWidget *parent) , m_cancelBtn(new DPushButton(this)) , m_enterBtn(new DSuggestButton(this)) { + qCDebug(ClientLogger) << "CColorPickerWidget constructor initialized"; initUI(); setColorHexLineEdit(); moveToCenter(); @@ -36,16 +38,19 @@ CColorPickerWidget::CColorPickerWidget(QWidget *parent) connect(m_colorLabel, &ColorLabel::signalpickedColor, this, &CColorPickerWidget::slotUpdateColor); connect(m_colHexLineEdit, &DLineEdit::textChanged, this, &CColorPickerWidget::slotHexLineEditChange); connect(m_colorSlider, &ColorSlider::valueChanged, this, [this](int val) { + qCDebug(ClientLogger) << "Color slider value changed to:" << val; m_colorLabel->setHue(val); }); } CColorPickerWidget::~CColorPickerWidget() { + qCDebug(ClientLogger) << "CColorPickerWidget destructor called"; } void CColorPickerWidget::setColorHexLineEdit() { + qCDebug(ClientLogger) << "CColorPickerWidget::setColorHexLineEdit - Setting up hex line edit"; m_colHexLineEdit->setText(""); //确认按钮初始置灰 m_enterBtn->setDisabled(true); @@ -60,6 +65,7 @@ void CColorPickerWidget::setColorHexLineEdit() */ void CColorPickerWidget::initUI() { + qCDebug(ClientLogger) << "CColorPickerWidget::initUI - Initializing UI components"; QFont mlabelTitle; QFont mlabelContext; mlabelTitle.setWeight(QFont::Bold); @@ -103,34 +109,42 @@ void CColorPickerWidget::initUI() btnLayout->addWidget(m_enterBtn); mLayout->addLayout(btnLayout); this->setLayout(mLayout); - setLabelText(); + setLabelText(); this->setFocusPolicy(Qt::TabFocus); setTabOrder(m_colHexLineEdit, m_cancelBtn); setTabOrder(m_cancelBtn, m_enterBtn); setTabOrder(m_enterBtn, m_colorSlider); + qCDebug(ClientLogger) << "UI initialization completed"; } void CColorPickerWidget::setLabelText() { + qCDebug(ClientLogger) << "CColorPickerWidget::setLabelText - Setting label text based on locale"; QLocale local; if(local.language() == QLocale::Chinese) { + qCDebug(ClientLogger) << "Chinese locale detected, keeping original text"; return; } - QString str = m_strColorLabel; + QString str = m_strColorLabel; QFontMetrics fontMetrice(m_wordLabel->font()); if(fontMetrice.horizontalAdvance(str) > (m_wordLabel->width()+4)) { - str = fontMetrice.elidedText(str,Qt::ElideRight,m_wordLabel->width()); + qCDebug(ClientLogger) << "Text too long, applying elision"; + str = fontMetrice.elidedText(str, Qt::ElideRight, m_wordLabel->width()); } m_wordLabel->setText(str); } -void CColorPickerWidget::changeEvent(QEvent *e) { +void CColorPickerWidget::changeEvent(QEvent *e) { + // qCDebug(ClientLogger) << "CColorPickerWidget::changeEvent"; QWidget::changeEvent(e); if(e->type() == QEvent::FontChange) { + // qCDebug(ClientLogger) << "CColorPickerWidget::changeEvent - Font changed, updating label text"; setLabelText(); } } + void CColorPickerWidget::slotHexLineEditChange(const QString &text) { + qCDebug(ClientLogger) << "CColorPickerWidget::slotHexLineEditChange - Text changed to:" << text; QString lowerText = text.toLower(); if (lowerText == text) { #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -142,36 +156,47 @@ void CColorPickerWidget::slotHexLineEditChange(const QString &text) #endif } else { + qCDebug(ClientLogger) << "Converting text to lowercase"; m_colHexLineEdit->setText(lowerText); } } QColor CColorPickerWidget::getSelectedColor() { + // qCDebug(ClientLogger) << "CColorPickerWidget::getSelectedColor"; return QColor("#" + m_colHexLineEdit->text()); } void CColorPickerWidget::slotUpdateColor(const QColor &color) { + qCDebug(ClientLogger) << "CColorPickerWidget::slotUpdateColor - Updating color to:" << color; if (color.isValid()) { - this->m_colHexLineEdit->setText(color.name().remove("#")); + QString colorName = color.name().remove("#"); + qCDebug(ClientLogger) << "Setting hex edit text to:" << colorName; + this->m_colHexLineEdit->setText(colorName); + } else { + qCDebug(ClientLogger) << "Invalid color provided"; } } void CColorPickerWidget::slotCancelBtnClicked() { + qCDebug(ClientLogger) << "CColorPickerWidget::slotCancelBtnClicked - Cancel button clicked, rejecting dialog"; reject(); } void CColorPickerWidget::slotEnterBtnClicked() { + qCDebug(ClientLogger) << "CColorPickerWidget::slotEnterBtnClicked - Enter button clicked, accepting dialog"; accept(); } void CColorPickerWidget::keyPressEvent(QKeyEvent *e) { + // qCDebug(ClientLogger) << "CColorPickerWidget::keyPressEvent - Key pressed:" << e->key(); //键盘有两个Enter按键,一个为Enter一个为Return if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) { + // qCDebug(ClientLogger) << "Enter/Return key pressed, not handling"; //暂时不处理回车事件 } else { DAbstractDialog::keyPressEvent(e); diff --git a/calendar-client/src/customWidget/colorWidget/colorslider.cpp b/calendar-client/src/customWidget/colorWidget/colorslider.cpp index 9127f64c3..7fe7ddc59 100644 --- a/calendar-client/src/customWidget/colorWidget/colorslider.cpp +++ b/calendar-client/src/customWidget/colorWidget/colorslider.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "colorslider.h" +#include "commondef.h" #include #include @@ -14,12 +15,14 @@ const int IMAGE_HEIGHT = 10; ColorSlider::ColorSlider(QWidget *parent) : QSlider(parent) { + qCDebug(ClientLogger) << "ColorSlider constructor initialized"; setMinimum(0); setMaximum(359); setOrientation(Qt::Horizontal); QRect rect = this->rect(); m_backgroundImage = QImage(rect.width(), IMAGE_HEIGHT, QImage::Format_ARGB32); + qCDebug(ClientLogger) << "Creating background image with dimensions:" << rect.width() << "x" << IMAGE_HEIGHT; for (qreal s = 0; s < m_backgroundImage.width(); s++) { for (qreal v = 1; v <= m_backgroundImage.height() ; v++) { @@ -36,11 +39,13 @@ ColorSlider::ColorSlider(QWidget *parent) ColorSlider::~ColorSlider() { + qCDebug(ClientLogger) << "ColorSlider destructor called"; } //h∈(0, 360), s∈(0, 1), v∈(0, 1) QColor ColorSlider::getColor(qreal h, qreal s, qreal v) { + // qCDebug(ClientLogger) << "ColorSlider::getColor - h:" << h << "s:" << s << "v:" << v; int hi = int(h / 60) % 6; qreal f = h / 60 - hi; @@ -55,11 +60,11 @@ QColor ColorSlider::getColor(qreal h, qreal s, qreal v) QColor color; if (hi == 0) { - color = QColor(std::min(int(255 * p), 255), std::min(int(255 * q), 255), std::min(int(255 * v), 255)); + color = QColor(std::min(int(255 * p), 255), std::min(int(255 * q), 255), std::min(int(255 * v), 255)); } else if (hi == 1) { - color = QColor(std::min(int(255 * t), 255), std::min(int(255 * p), 255), std::min(int(255 * v), 255)); + color = QColor(std::min(int(255 * t), 255), std::min(int(255 * p), 255), std::min(int(255 * v), 255)); } else if (hi == 2) { - color = QColor(std::min(int(255 * v), 255), std::min(int(255 * p), 255), int(255 * q)); + color = QColor(std::min(int(255 * v), 255), std::min(int(255 * p), 255), int(255 * q)); } else if (hi == 3) { color = QColor(std::min(int(255 * v), 255), std::min(int(255 * t), 255), std::min(int(255 * p), 255)); } else if (hi == 4) { @@ -68,11 +73,13 @@ QColor ColorSlider::getColor(qreal h, qreal s, qreal v) color = QColor(std::min(int(255 * p), 255), std::min(int(255 * v), 255), std::min(int(255 * t), 255)); } + qCDebug(ClientLogger) << "Calculated color:" << color; return color; } void ColorSlider::paintEvent(QPaintEvent *ev) { + // qCDebug(ClientLogger) << "ColorSlider::paintEvent"; Q_UNUSED(ev) QRect rect = this->rect(); diff --git a/calendar-client/src/customWidget/colorseletorwidget.cpp b/calendar-client/src/customWidget/colorseletorwidget.cpp index 3fcedc13d..1e181149a 100644 --- a/calendar-client/src/customWidget/colorseletorwidget.cpp +++ b/calendar-client/src/customWidget/colorseletorwidget.cpp @@ -5,50 +5,61 @@ #include "colorseletorwidget.h" #include "configsettings.h" #include "units.h" +#include "commondef.h" #include ColorSeletorWidget::ColorSeletorWidget(QWidget *parent) : QWidget(parent) { + qCDebug(ClientLogger) << "ColorSeletorWidget constructor initialized"; init(); } void ColorSeletorWidget::init() { + qCDebug(ClientLogger) << "ColorSeletorWidget::init - Initializing widget"; initView(); m_colorGroup = new QButtonGroup(this); m_colorGroup->setExclusive(true); connect(m_colorGroup, &QButtonGroup::idClicked, this, &ColorSeletorWidget::slotButtonClicked); m_colorInfo.reset(new DTypeColor()); + qCDebug(ClientLogger) << "ColorSeletorWidget initialization completed"; } void ColorSeletorWidget::resetColorButton(const AccountItem::Ptr &account) { + qCDebug(ClientLogger) << "ColorSeletorWidget::resetColorButton - Resetting color buttons"; reset(); if (nullptr == account) { + qCDebug(ClientLogger) << "Account is null, returning"; return; } - DTypeColor::List colorList = account->getColorTypeList(); + DTypeColor::List colorList = account->getColorTypeList(); + qCDebug(ClientLogger) << "Got color list with" << colorList.size() << "colors"; //添加默认颜色控件 for (DTypeColor::Ptr &var : colorList) { if (DTypeColor::PriSystem == var->privilege()) { + // qCDebug(ClientLogger) << "Adding system color:" << var->colorCode(); addColor(var); } } //自定义控件单独添加 + qCDebug(ClientLogger) << "Adding user color button with ID:" << m_userColorBtnId; m_colorGroup->addButton(m_userColorBtn, m_userColorBtnId); m_colorLayout->addWidget(m_userColorBtn); if (m_colorGroup->buttons().size() > 0) { + qCDebug(ClientLogger) << "Clicking first button"; m_colorGroup->buttons().at(0)->click(); } } void ColorSeletorWidget::reset() { + qCDebug(ClientLogger) << "ColorSeletorWidget::reset - Clearing color entities and widgets"; //清空所有的色彩实体和控件 m_colorEntityMap.clear(); QList buttons = m_colorGroup->buttons(); @@ -57,23 +68,26 @@ void ColorSeletorWidget::reset() m_colorLayout->removeWidget(btn); //自定义控件内存不释放 if (btn == m_userColorBtn) { + // qCDebug(ClientLogger) << "Skipping user color button"; continue; } delete btn; btn = nullptr; } if (nullptr == m_userColorBtn) { + qCDebug(ClientLogger) << "Creating new user color button"; m_userColorBtn = new CRadioButton(this); m_userColorBtn->setFixedSize(18, 18); - } m_userColorBtn->hide(); + qCDebug(ClientLogger) << "Reset completed"; } void ColorSeletorWidget::addColor(const DTypeColor::Ptr &cInfo) { static int count = 0; //静态变量,充当色彩控件id count++; + qCDebug(ClientLogger) << "ColorSeletorWidget::addColor - Adding color with ID:" << count << "Color:" << cInfo->colorCode(); m_colorEntityMap.insert(count, cInfo); //映射id与控件,从1开始 CRadioButton *radio = new CRadioButton(this); radio->setColor(QColor(cInfo->colorCode())); //设置控件颜色 @@ -84,9 +98,12 @@ void ColorSeletorWidget::addColor(const DTypeColor::Ptr &cInfo) DTypeColor::Ptr ColorSeletorWidget::getSelectedColorInfo() { - if ( m_colorInfo->privilege() == DTypeColor::PriSystem) { + qCDebug(ClientLogger) << "ColorSeletorWidget::getSelectedColorInfo - Getting selected color info"; + if (m_colorInfo->privilege() == DTypeColor::PriSystem) { + qCDebug(ClientLogger) << "System color selected, saving color ID:" << m_colorInfo->colorID(); CConfigSettings::getInstance()->setOption("LastSysColorTypeNo", m_colorInfo->colorID()); - } else if (!m_colorInfo->colorCode().isEmpty() ){ + } else if (!m_colorInfo->colorCode().isEmpty()) { + qCDebug(ClientLogger) << "User color selected, saving color code:" << m_colorInfo->colorCode(); CConfigSettings::getInstance()->setOption("LastUserColor", m_colorInfo->colorCode()); CConfigSettings::getInstance()->setOption("LastSysColorTypeNo", ""); } @@ -95,23 +112,30 @@ DTypeColor::Ptr ColorSeletorWidget::getSelectedColorInfo() void ColorSeletorWidget::setSelectedColorByIndex(int index) { + qCDebug(ClientLogger) << "ColorSeletorWidget::setSelectedColorByIndex - Setting color by index:" << index; if (index >= 0 && index < m_colorGroup->buttons().size()) { QAbstractButton *but = m_colorGroup->buttons().at(index); if (nullptr != but) { + qCDebug(ClientLogger) << "Clicking button at index:" << index; but->click(); } + } else { + qCDebug(ClientLogger) << "Index out of range"; } } void ColorSeletorWidget::setSelectedColorById(int colorId) { + qCDebug(ClientLogger) << "ColorSeletorWidget::setSelectedColorById - Setting color by ID:" << colorId; //默认选择第一个 - if( colorId < 0 ) { + if (colorId < 0) { + qCDebug(ClientLogger) << "Invalid color ID, selecting first button"; if (m_colorGroup->buttons().size() > 0) { m_colorGroup->buttons().at(0)->click(); } return; - } else if ( colorId == 9 ) { + } else if (colorId == 9) { + qCDebug(ClientLogger) << "User color ID detected, clicking user color button"; m_userColorBtn->click(); return; } @@ -122,19 +146,25 @@ void ColorSeletorWidget::setSelectedColorById(int colorId) } else { ++colorId; } + qCDebug(ClientLogger) << "Adjusted color ID:" << colorId; if (m_colorGroup->buttons().size() > colorId) { - m_colorGroup->buttons().at(colorId)->click(); + qCDebug(ClientLogger) << "Clicking button at adjusted ID"; + m_colorGroup->buttons().at(colorId)->click(); + } else { + qCDebug(ClientLogger) << "Adjusted ID out of range"; } } void ColorSeletorWidget::setSelectedColor(const DTypeColor &colorInfo) { + qCDebug(ClientLogger) << "ColorSeletorWidget::setSelectedColor - Setting color with ID:" << colorInfo.colorID(); bool finding = false; auto iterator = m_colorEntityMap.begin(); while (iterator != m_colorEntityMap.end()) { if (iterator.value()->colorID() == colorInfo.colorID()) { QAbstractButton *btn = m_colorGroup->button(iterator.key()); if (btn) { + qCDebug(ClientLogger) << "Found matching color, clicking button with key:" << iterator.key(); btn->click(); finding = true; } @@ -143,6 +173,7 @@ void ColorSeletorWidget::setSelectedColor(const DTypeColor &colorInfo) iterator++; } if (!finding) { + qCDebug(ClientLogger) << "Color not found, creating user color"; DTypeColor::Ptr ptr; ptr.reset(new DTypeColor(colorInfo)); setUserColor(ptr); @@ -151,6 +182,7 @@ void ColorSeletorWidget::setSelectedColor(const DTypeColor &colorInfo) void ColorSeletorWidget::initView() { + qCDebug(ClientLogger) << "ColorSeletorWidget::initView - Initializing view"; m_colorLayout = new QHBoxLayout(); QHBoxLayout *hLayout = new QHBoxLayout(); @@ -170,44 +202,58 @@ void ColorSeletorWidget::initView() this->setLayout(hLayout); connect(addColorBut, &QPushButton::clicked, this, &ColorSeletorWidget::slotAddColorButClicked); + qCDebug(ClientLogger) << "View initialization completed"; } void ColorSeletorWidget::slotButtonClicked(int butId) { + qCDebug(ClientLogger) << "ColorSeletorWidget::slotButtonClicked - Button clicked with ID:" << butId; auto it = m_colorEntityMap.find(butId); if (m_colorEntityMap.end() == it) { + qCDebug(ClientLogger) << "Button ID not found in color map"; return; } DTypeColor::Ptr info = it.value(); if (info->colorCode() != m_colorInfo->colorCode()) { + qCDebug(ClientLogger) << "Color changed from" << m_colorInfo->colorCode() << "to" << info->colorCode(); m_colorInfo = info; emit signalColorChange(info); + } else { + qCDebug(ClientLogger) << "Color unchanged"; } } void ColorSeletorWidget::slotAddColorButClicked() { + qCDebug(ClientLogger) << "ColorSeletorWidget::slotAddColorButClicked - Add color button clicked"; CColorPickerWidget colorPicker; if (colorPicker.exec()) { + qCDebug(ClientLogger) << "Color picker returned color:" << colorPicker.getSelectedColor().name(); DTypeColor::Ptr typeColor; typeColor.reset(new DTypeColor()); typeColor->setColorCode(colorPicker.getSelectedColor().name()); typeColor->setPrivilege(DTypeColor::PriUser); setUserColor(typeColor); m_userColorBtn->click(); + } else { + qCDebug(ClientLogger) << "Color picker cancelled"; } } void ColorSeletorWidget::setUserColor(const DTypeColor::Ptr &colorInfo) { + // qCDebug(ClientLogger) << "ColorSeletorWidget::setUserColor - Setting user color:" << colorInfo->colorCode(); if (nullptr == m_userColorBtn || DTypeColor::PriUser != colorInfo->privilege()) { + qCDebug(ClientLogger) << "Invalid user color button or privilege"; return; } if (!m_userColorBtn->isVisible()) { + qCDebug(ClientLogger) << "Showing user color button"; m_userColorBtn->show(); } m_userColorBtn->setColor(colorInfo->colorCode()); m_colorEntityMap[m_userColorBtnId] = colorInfo; + qCDebug(ClientLogger) << "Clicking user color button"; m_userColorBtn->click(); } diff --git a/calendar-client/src/customWidget/cpushbutton.cpp b/calendar-client/src/customWidget/cpushbutton.cpp index 7b3ecd387..2ef0d0541 100644 --- a/calendar-client/src/customWidget/cpushbutton.cpp +++ b/calendar-client/src/customWidget/cpushbutton.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "cpushbutton.h" +#include "commondef.h" #include #include @@ -13,6 +14,7 @@ CPushButton::CPushButton(QWidget *parent) : QWidget(parent) { + qCDebug(ClientLogger) << "CPushButton constructor initialized"; QHBoxLayout *layoutAddType = new QHBoxLayout(); m_textLabel = new QLabel(tr("New event type")); @@ -33,8 +35,10 @@ CPushButton::CPushButton(QWidget *parent) : QWidget(parent) //设置深浅色主题下正常状态时的文本颜色,与下拉框颜色对其 if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::DarkType) { + qCDebug(ClientLogger) << "Dark theme detected, setting text color to white"; pa.setBrush(QPalette::WindowText, QColor("#FFFFFF")); } else { + qCDebug(ClientLogger) << "Light theme detected, setting text color to black"; pa.setBrush(QPalette::WindowText, QColor("#000000")); } m_textLabel->setPalette(pa); @@ -45,11 +49,14 @@ CPushButton::CPushButton(QWidget *parent) : QWidget(parent) layoutAddType->addWidget(m_textLabel); setFixedHeight(34); setLayout(layoutAddType); + qCDebug(ClientLogger) << "CPushButton initialization completed"; } void CPushButton::setHighlight(bool status) { + qCDebug(ClientLogger) << "CPushButton::setHighlight - Setting highlight status to:" << status; if (status == m_Highlighted) { + qCDebug(ClientLogger) << "Highlight status unchanged, returning"; return; } m_Highlighted = status; @@ -58,18 +65,22 @@ void CPushButton::setHighlight(bool status) bool CPushButton::isHighlight() { + qCDebug(ClientLogger) << "CPushButton::isHighlight - Current status:" << m_Highlighted; return m_Highlighted; } void CPushButton::mousePressEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "CPushButton::mousePressEvent - Position:" << event->pos(); Q_UNUSED(event); m_pressed = true; } void CPushButton::mouseReleaseEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "CPushButton::mouseReleaseEvent - Position:" << event->pos(); if (m_pressed && rect().contains(event->pos())){ + qCDebug(ClientLogger) << "Mouse released within button bounds, emitting clicked signal"; emit clicked(); } m_pressed = false; @@ -86,11 +97,13 @@ void CPushButton::paintEvent(QPaintEvent *event) m_iconButton->setIcon(QIcon::fromTheme("dde_calendar_create")); if (m_Highlighted) { + // qCDebug(ClientLogger) << "Button is highlighted, setting highlight appearance"; //背景设置为高亮色 m_iconButton->setIcon(QIcon(":/icons/deepin/builtin/dark/icons/dde_calendar_create_32px.svg")); painter.setBrush(palette.highlight()); m_textLabel->setBackgroundRole(QPalette::Highlight); } else { + // qCDebug(ClientLogger) << "Button is not highlighted, setting normal appearance"; //背景透明 painter.setBrush(QBrush("#00000000")); m_textLabel->setBackgroundRole(QPalette::Window); diff --git a/calendar-client/src/customWidget/cradiobutton.cpp b/calendar-client/src/customWidget/cradiobutton.cpp index 8aa29765e..e14ef24a8 100644 --- a/calendar-client/src/customWidget/cradiobutton.cpp +++ b/calendar-client/src/customWidget/cradiobutton.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "cradiobutton.h" +#include "commondef.h" #include #include #include @@ -11,20 +12,24 @@ DWIDGET_USE_NAMESPACE CRadioButton::CRadioButton(QWidget *parent) : QRadioButton(parent) { + qCDebug(ClientLogger) << "CRadioButton constructor initialized"; } void CRadioButton::setColor(const QColor &color) { + // qCDebug(ClientLogger) << "CRadioButton::setColor - Setting color to:" << color; m_color = color; } QColor CRadioButton::getColor() { + // qCDebug(ClientLogger) << "CRadioButton::getColor - Returning color:" << m_color; return m_color; } void CRadioButton::paintEvent(QPaintEvent *event) { + // qCDebug(ClientLogger) << "CRadioButton::paintEvent"; Q_UNUSED(event); QPainter painter(this); @@ -36,6 +41,7 @@ void CRadioButton::paintEvent(QPaintEvent *event) int h = height(); if (!isChecked()) { + // qCDebug(ClientLogger) << "CRadioButton::paintEvent - Drawing unchecked state"; // 设置画刷颜色 painter.setBrush(m_color); // 绘制圆 @@ -49,6 +55,7 @@ void CRadioButton::paintEvent(QPaintEvent *event) painter.setBrush(c); painter.drawPath(path); } else { + // qCDebug(ClientLogger) << "CRadioButton::paintEvent - Drawing checked state"; DPalette palette = DPaletteHelper::instance()->palette(this); QPainterPath path; path.addEllipse(0, 0, w, h); diff --git a/calendar-client/src/customWidget/ctimelineedit.cpp b/calendar-client/src/customWidget/ctimelineedit.cpp index 84595d5c0..9602fe18d 100644 --- a/calendar-client/src/customWidget/ctimelineedit.cpp +++ b/calendar-client/src/customWidget/ctimelineedit.cpp @@ -5,10 +5,12 @@ #include "ctimelineedit.h" #include #include +#include "commondef.h" CTimeLineEdit::CTimeLineEdit(int id, QWidget *parent) : DSpinBox(parent) , m_id(id) { + qCDebug(ClientLogger) << "CTimeLineEdit constructor, id:" << id; initView(); connect(this, &CTimeLineEdit::editingFinished, this, &CTimeLineEdit::slotEditingFinished); connect(this->lineEdit(), &QLineEdit::textEdited, this, &CTimeLineEdit::slotTextEdited); @@ -16,6 +18,7 @@ CTimeLineEdit::CTimeLineEdit(int id, QWidget *parent) : DSpinBox(parent) void CTimeLineEdit::initView() { + qCDebug(ClientLogger) << "CTimeLineEdit::initView"; //启用嵌入式的样式 setEnabledEmbedStyle(true); // QString str = this->styleSheet(); @@ -33,6 +36,7 @@ void CTimeLineEdit::initView() */ void CTimeLineEdit::setRange(int min, int max) { + qCDebug(ClientLogger) << "CTimeLineEdit::setRange min:" << min << "max:" << max; DSpinBox::setRange(min, max); } @@ -43,6 +47,7 @@ void CTimeLineEdit::setRange(int min, int max) */ void CTimeLineEdit::setStepEnabled(CTimeLineEdit::StepEnabled enable) { + qCDebug(ClientLogger) << "CTimeLineEdit::setStepEnabled enable:" << enable; m_stepEnable = enable; } @@ -53,6 +58,7 @@ void CTimeLineEdit::setStepEnabled(CTimeLineEdit::StepEnabled enable) */ void CTimeLineEdit::setNum(int num) { + qCDebug(ClientLogger) << "CTimeLineEdit::setNum num:" << num; m_num = num; m_num = m_num > minimum()? m_num:minimum(); m_num = m_num < maximum()? m_num:maximum(); @@ -68,6 +74,7 @@ void CTimeLineEdit::setNum(int num) */ void CTimeLineEdit::setNum(int num, bool canCarry) { + qCDebug(ClientLogger) << "CTimeLineEdit::setNum num:" << num << "canCarry:" << canCarry; if (!canCarry) { setNum(num); return; @@ -82,16 +89,19 @@ void CTimeLineEdit::setNum(int num, bool canCarry) } //发送时间跳转信号, num-m_num: 时间差 + qCDebug(ClientLogger) << "CTimeLineEdit: Emitting date jump signal, jump value:" << (num - m_num); emit signalDateJump(m_id, num - m_num); } void CTimeLineEdit::slotEditingFinished() { + qCDebug(ClientLogger) << "CTimeLineEdit::slotEditingFinished value:" << value(); setNum(value()); } void CTimeLineEdit::slotTextEdited(const QString &text) { + qCDebug(ClientLogger) << "CTimeLineEdit::slotTextEdited text:" << text; //过滤掉非数字字符 QString value = ""; for (QChar c : text) { @@ -116,6 +126,7 @@ void CTimeLineEdit::slotTextEdited(const QString &text) */ CTimeLineEdit::StepEnabled CTimeLineEdit::stepEnabled() const { + qCDebug(ClientLogger) << "CTimeLineEdit::stepEnabled returning:" << m_stepEnable; return m_stepEnable; } @@ -126,6 +137,7 @@ CTimeLineEdit::StepEnabled CTimeLineEdit::stepEnabled() const */ void CTimeLineEdit::stepBy(int steps) { + qCDebug(ClientLogger) << "CTimeLineEdit::stepBy steps:" << steps; setNum(value() + steps, true); //因为已自定义处理步长,因此再次调用父类的方法实现默认效果,并将其步长传入0 DSpinBox::stepBy(0); diff --git a/calendar-client/src/customWidget/ctitlewidget.cpp b/calendar-client/src/customWidget/ctitlewidget.cpp index c9b0d3a56..63dab546b 100644 --- a/calendar-client/src/customWidget/ctitlewidget.cpp +++ b/calendar-client/src/customWidget/ctitlewidget.cpp @@ -6,6 +6,7 @@ #include "constants.h" #include "configsettings.h" +#include "commondef.h" #include @@ -17,6 +18,7 @@ CTitleWidget::CTitleWidget(QWidget *parent) : QWidget(parent) { + qCDebug(ClientLogger) << "CTitleWidget constructor"; m_sidebarIcon = new DIconButton(this); m_sidebarIcon->setFixedSize(QSize(36, 36)); m_sidebarIcon->setIconSize(QSize(19, 15)); @@ -137,12 +139,14 @@ CTitleWidget::CTitleWidget(QWidget *parent) void CTitleWidget::setShowState(CTitleWidget::Title_State state) { + qCDebug(ClientLogger) << "CTitleWidget::setShowState state:" << state; m_showState = state; stateUpdate(); } void CTitleWidget::setSidebarStatus(bool status) { + qCDebug(ClientLogger) << "CTitleWidget::setSidebarStatus status:" << status; m_sidebarstatus = status; updateSidebarIconStatus(); m_clickShowLeft = status; @@ -153,11 +157,13 @@ void CTitleWidget::setSidebarStatus(bool status) void CTitleWidget::setSidebarCanDisplay(bool can) { + qCDebug(ClientLogger) << "CTitleWidget::setSidebarCanDisplay can:" << can; m_sidebarCanDisplay = can; } bool CTitleWidget::getSidevarStatus() { + qCDebug(ClientLogger) << "CTitleWidget::getSidevarStatus returning:" << m_sidebarstatus; return m_sidebarstatus; } @@ -178,6 +184,7 @@ DIconButton *CTitleWidget::newScheduleBtn() const void CTitleWidget::stateUpdate() { + qCDebug(ClientLogger) << "CTitleWidget::stateUpdate showState:" << m_showState; switch (m_showState) { case Title_State_Mini: { //如果搜索框没有焦点且搜索框内没有内容则隐藏搜索框显示搜索图标按钮 @@ -202,6 +209,7 @@ void CTitleWidget::stateUpdate() void CTitleWidget::miniStateShowSearchEdit() { + qCDebug(ClientLogger) << "CTitleWidget::miniStateShowSearchEdit"; m_buttonBox->hide(); m_searchPush->hide(); m_searchEdit->setMaximumWidth(width()); @@ -213,6 +221,7 @@ void CTitleWidget::miniStateShowSearchEdit() void CTitleWidget::normalStateUpdateSearchEditWidth() { + qCDebug(ClientLogger) << "CTitleWidget::normalStateUpdateSearchEditWidth"; int padding = qMax(m_buttonBox->width(), m_newScheduleBtn->width()); //更加widget宽度设置搜索框宽度 int searchWidth = width() - 2 * padding; @@ -229,11 +238,13 @@ void CTitleWidget::normalStateUpdateSearchEditWidth() void CTitleWidget::updateSidebarIconStatus() { + qCDebug(ClientLogger) << "CTitleWidget::updateSidebarIconStatus"; m_sidebarIcon->setIcon(QIcon::fromTheme("dde_calendar_sidebar")); } void CTitleWidget::resizeEvent(QResizeEvent *event) { + // qCDebug(ClientLogger) << "CTitleWidget::resizeEvent"; QWidget::resizeEvent(event); if (m_showState == Title_State_Normal) { normalStateUpdateSearchEditWidth(); @@ -253,6 +264,7 @@ void CTitleWidget::resizeEvent(QResizeEvent *event) void CTitleWidget::changeEvent(QEvent *e) { + // qCDebug(ClientLogger) << "CTitleWidget::changeEvent"; QWidget::changeEvent(e); if (e->type() == QEvent::FontChange) { updateSearchEditPlaceHolder(); @@ -261,6 +273,7 @@ void CTitleWidget::changeEvent(QEvent *e) void CTitleWidget::updateSearchEditPlaceHolder() { + qCDebug(ClientLogger) << "CTitleWidget::updateSearchEditPlaceHolder"; QString str = m_strPlaceHolder; QFontMetrics fontMetrice(m_searchEdit->font()); if (fontMetrice.horizontalAdvance(str) > (m_searchEdit->width() - 30)) { @@ -275,10 +288,12 @@ void CTitleWidget::updateSearchEditPlaceHolder() bool CTitleWidget::eventFilter(QObject *o, QEvent *e) { + // qCDebug(ClientLogger) << "CTitleWidget::eventFilter"; DButtonBoxButton *btn = qobject_cast(o); if (btn != nullptr && e->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = dynamic_cast(e); if (keyEvent != nullptr && (keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Space)) { + qCDebug(ClientLogger) << "CTitleWidget::eventFilter button key press:" << keyEvent->key(); emit signalSetButtonFocus(); } } @@ -288,6 +303,7 @@ bool CTitleWidget::eventFilter(QObject *o, QEvent *e) QFocusEvent *focusOutEvent = dynamic_cast(e); //如果为tab切换焦点则发送焦点切换信号 if (focusOutEvent->reason() == Qt::TabFocusReason) { + qCDebug(ClientLogger) << "CTitleWidget::eventFilter search edit tab focus out"; emit signalSearchFocusSwitch(); } //根据焦点离开原因,决定是否隐藏搜索框 @@ -302,6 +318,7 @@ bool CTitleWidget::eventFilter(QObject *o, QEvent *e) void CTitleWidget::slotShowSearchEdit() { + qCDebug(ClientLogger) << "CTitleWidget::slotShowSearchEdit"; miniStateShowSearchEdit(); m_searchEdit->setFocus(); @@ -309,8 +326,10 @@ void CTitleWidget::slotShowSearchEdit() void CTitleWidget::slotSearchEditFocusChanged(bool onFocus) { + qCDebug(ClientLogger) << "CTitleWidget::slotSearchEditFocusChanged onFocus:" << onFocus; //如果获取焦点,或者搜索编辑框内容不为空则不处理 if (onFocus || !m_searchEdit->text().isEmpty()) { + qCDebug(ClientLogger) << "CTitleWidget::slotSearchEditFocusChanged onFocus or search edit text is not empty, returning"; return; } //如果为小窗口模式则隐藏部分控件 @@ -323,6 +342,7 @@ void CTitleWidget::slotSearchEditFocusChanged(bool onFocus) void CTitleWidget::slotSidebarIconClicked() { + qCDebug(ClientLogger) << "CTitleWidget::slotSidebarIconClicked"; //获取当前侧边栏显示状态 bool display = m_sidebarCanDisplay & m_sidebarstatus; //点击按钮后侧边栏状态重新恢复为可显示状态 diff --git a/calendar-client/src/customWidget/customframe.cpp b/calendar-client/src/customWidget/customframe.cpp index 13070b233..2ea9abc69 100644 --- a/calendar-client/src/customWidget/customframe.cpp +++ b/calendar-client/src/customWidget/customframe.cpp @@ -4,6 +4,7 @@ #include "customframe.h" #include "constants.h" +#include "commondef.h" #include @@ -15,6 +16,7 @@ DGUI_USE_NAMESPACE CustomFrame::CustomFrame(QWidget *parent) : QFrame(parent) { + qCDebug(ClientLogger) << "CustomFrame constructor"; m_font.setWeight(QFont::Medium); m_font.setPixelSize(DDECalendar::FontSizeFourteen); this->setAttribute(Qt::WA_TranslucentBackground);//设置窗口背景透明 @@ -24,6 +26,7 @@ CustomFrame::CustomFrame(QWidget *parent) void CustomFrame::setBColor(QColor normalC) { + qCDebug(ClientLogger) << "CustomFrame::setBColor"; m_bnormalColor = normalC; m_bflag = true; update(); @@ -31,6 +34,8 @@ void CustomFrame::setBColor(QColor normalC) void CustomFrame::setRoundState(bool lstate, bool tstate, bool rstate, bool bstate) { + qCDebug(ClientLogger) << "CustomFrame::setRoundState lstate:" << lstate << "tstate:" << tstate + << "rstate:" << rstate << "bstate:" << bstate; m_lstate = lstate; m_tstate = tstate; m_rstate = rstate; @@ -39,6 +44,7 @@ void CustomFrame::setRoundState(bool lstate, bool tstate, bool rstate, bool bsta void CustomFrame::setTextStr(const QFont &font, const QColor &tc, const QString &strc, int flag) { + qCDebug(ClientLogger) << "CustomFrame::setTextStr text:" << strc << "flag:" << flag; m_font = font; m_tnormalColor = tc; m_text = strc; @@ -47,6 +53,7 @@ void CustomFrame::setTextStr(const QFont &font, const QColor &tc, const QString void CustomFrame::setTextStr(const QString &strc) { + qCDebug(ClientLogger) << "CustomFrame::setTextStr text:" << strc; m_text = strc; if (!m_fixsizeflag) { @@ -59,12 +66,14 @@ void CustomFrame::setTextStr(const QString &strc) void CustomFrame::setTextColor(QColor tc) { + qCDebug(ClientLogger) << "CustomFrame::setTextColor"; m_tnormalColor = tc; update(); } void CustomFrame::setTextFont(const QFont &font) { + qCDebug(ClientLogger) << "CustomFrame::setTextFont"; m_font = font; if (!m_fixsizeflag) { @@ -76,27 +85,32 @@ void CustomFrame::setTextFont(const QFont &font) void CustomFrame::setTextAlign(int flag) { + qCDebug(ClientLogger) << "CustomFrame::setTextAlign flag:" << flag; m_textflag = flag; } void CustomFrame::setRadius(int radius) { + qCDebug(ClientLogger) << "CustomFrame::setRadius radius:" << radius; m_radius = radius; } void CustomFrame::setboreder(int framew) { + qCDebug(ClientLogger) << "CustomFrame::setboreder framew:" << framew; m_borderframew = framew; } void CustomFrame::setFixedSize(int w, int h) { + qCDebug(ClientLogger) << "CustomFrame::setFixedSize w:" << w << "h:" << h; m_fixsizeflag = true; QFrame::setFixedSize(w, h); } void CustomFrame::paintEvent(QPaintEvent *e) { + // qCDebug(ClientLogger) << "CustomFrame::paintEvent"; int labelwidth = width() - 2 * m_borderframew; int labelheight = height() - 2 * m_borderframew; @@ -104,6 +118,7 @@ void CustomFrame::paintEvent(QPaintEvent *e) QRect fillRect = QRect(m_borderframew, m_borderframew, labelwidth, labelheight); if (m_bflag) { + // qCDebug(ClientLogger) << "CustomFrame::paintEvent - Drawing background"; painter.save(); painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; painter.setBrush(QBrush(m_bnormalColor)); @@ -148,6 +163,7 @@ void CustomFrame::paintEvent(QPaintEvent *e) } if (!m_text.isEmpty()) { + // qCDebug(ClientLogger) << "CustomFrame::paintEvent - Drawing text"; painter.save(); painter.setRenderHints(QPainter::Antialiasing); painter.setFont(m_font); diff --git a/calendar-client/src/customWidget/cweekwidget.cpp b/calendar-client/src/customWidget/cweekwidget.cpp index 39337286b..9fff22fd9 100644 --- a/calendar-client/src/customWidget/cweekwidget.cpp +++ b/calendar-client/src/customWidget/cweekwidget.cpp @@ -5,6 +5,7 @@ #include "cweekwidget.h" #include "calendarmanage.h" #include "constants.h" +#include "commondef.h" #include #include #include @@ -12,6 +13,7 @@ CWeekWidget::CWeekWidget(QWidget *parent) : QPushButton(parent) , m_firstDay(CalendarManager::getInstance()->getFirstDayOfWeek()) { + qCDebug(ClientLogger) << "CWeekWidget constructor"; setMinimumHeight(10); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); setFocusPolicy(Qt::NoFocus); @@ -19,22 +21,26 @@ CWeekWidget::CWeekWidget(QWidget *parent) : QPushButton(parent) void CWeekWidget::setFirstDay(Qt::DayOfWeek first) { + qCDebug(ClientLogger) << "CWeekWidget::setFirstDay first:" << first; m_firstDay = first; setAutoFirstDay(true); } void CWeekWidget::setAutoFirstDay(bool is) { + qCDebug(ClientLogger) << "CWeekWidget::setAutoFirstDay is:" << is; m_autoFirstDay = is; } void CWeekWidget::setAutoFontSizeByWindow(bool is) { + qCDebug(ClientLogger) << "CWeekWidget::setAutoFontSizeByWindow is:" << is; m_autoFontSizeByWindow = is; } void CWeekWidget::paintEvent(QPaintEvent *event) { + // qCDebug(ClientLogger) << "CWeekWidget::paintEvent"; QWidget::paintEvent(event); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); @@ -42,12 +48,14 @@ void CWeekWidget::paintEvent(QPaintEvent *event) QFont font; if (m_autoFontSizeByWindow) { + // qCDebug(ClientLogger) << "CWeekWidget::paintEvent - Auto font size by window"; //字体跟随界面大小 qreal w = this->width() / 7; qreal h = this->height(); qreal r = w > h ? h : w ; if (QLocale::system().language() == QLocale::English) { + // qCDebug(ClientLogger) << "CWeekWidget::paintEvent - English locale, reducing font size"; r*=0.8; } @@ -56,6 +64,7 @@ void CWeekWidget::paintEvent(QPaintEvent *event) font.setPixelSize(int(r/20.0*12)); } else { + // qCDebug(ClientLogger) << "CWeekWidget::paintEvent - Fixed font size"; font.setPixelSize(DDECalendar::FontSizeTwelve); } @@ -66,6 +75,7 @@ void CWeekWidget::paintEvent(QPaintEvent *event) //获取一周首日 int firstDay = m_firstDay; if (m_autoFirstDay) { + // qCDebug(ClientLogger) << "CWeekWidget::paintEvent - Auto first day"; firstDay = CalendarManager::getInstance()->getFirstDayOfWeek(); } diff --git a/calendar-client/src/customWidget/jobtypecombobox.cpp b/calendar-client/src/customWidget/jobtypecombobox.cpp index 3380efbcd..9e3a9599a 100644 --- a/calendar-client/src/customWidget/jobtypecombobox.cpp +++ b/calendar-client/src/customWidget/jobtypecombobox.cpp @@ -4,6 +4,7 @@ #include "jobtypecombobox.h" +#include "commondef.h" #include #include @@ -17,6 +18,7 @@ JobTypeComboBox::JobTypeComboBox(QWidget *parent) : DComboBox(parent) { + qCDebug(ClientLogger) << "JobTypeComboBox::JobTypeComboBox"; initUI(); //不启用自动匹配 setCompleter(nullptr); @@ -31,12 +33,15 @@ JobTypeComboBox::JobTypeComboBox(QWidget *parent) : DComboBox(parent) JobTypeComboBox::~JobTypeComboBox() { + qCDebug(ClientLogger) << "JobTypeComboBox::~JobTypeComboBox"; return; } QString JobTypeComboBox::getCurrentJobTypeNo() { + qCDebug(ClientLogger) << "JobTypeComboBox::getCurrentJobTypeNo"; if (this->currentIndex() < 0 || this->currentIndex() >= m_lstJobType.size()) { + qCDebug(ClientLogger) << "Current index is out of bounds"; return QString(); } return m_lstJobType[this->currentIndex()]->typeID(); @@ -44,8 +49,10 @@ QString JobTypeComboBox::getCurrentJobTypeNo() void JobTypeComboBox::setCurrentJobTypeNo(const QString &strJobTypeNo) { + qCDebug(ClientLogger) << "JobTypeComboBox::setCurrentJobTypeNo, jobTypeNo:" << strJobTypeNo; for (int i = 0; i < m_lstJobType.size(); i++) { if (strJobTypeNo == m_lstJobType[i]->typeID()) { + // qCDebug(ClientLogger) << "Found job type at index:" << i; this->setCurrentIndex(i); break; } @@ -55,7 +62,9 @@ void JobTypeComboBox::setCurrentJobTypeNo(const QString &strJobTypeNo) void JobTypeComboBox::setAlert(bool isAlert) { + qCDebug(ClientLogger) << "JobTypeComboBox::setAlert, isAlert:" << isAlert; if (m_control) { + qCDebug(ClientLogger) << "m_control is valid, setting alert"; //输入框未显示警告色? m_control->setAlert(isAlert); } @@ -63,51 +72,65 @@ void JobTypeComboBox::setAlert(bool isAlert) bool JobTypeComboBox::isAlert() const { + qCDebug(ClientLogger) << "JobTypeComboBox::isAlert"; if (m_control) { + qCDebug(ClientLogger) << "m_control is valid, returning alert status"; return m_control->isAlert(); } + qCDebug(ClientLogger) << "m_control is null, returning false"; return false; } void JobTypeComboBox::showAlertMessage(const QString &text, int duration) { + qCDebug(ClientLogger) << "JobTypeComboBox::showAlertMessage, text:" << text << "duration:" << duration; showAlertMessage(text, nullptr, duration); } void JobTypeComboBox::showAlertMessage(const QString &text, QWidget *follower, int duration) { + qCDebug(ClientLogger) << "JobTypeComboBox::showAlertMessage, text:" << text << "duration:" << duration; if (m_control) { + qCDebug(ClientLogger) << "m_control is valid, showing alert message"; m_control->showAlertMessage(text, follower ? follower : this, duration); } } void JobTypeComboBox::setAlertMessageAlignment(Qt::Alignment alignment) { + qCDebug(ClientLogger) << "JobTypeComboBox::setAlertMessageAlignment"; if (m_control) { + qCDebug(ClientLogger) << "m_control is valid, setting message alignment"; m_control->setMessageAlignment(alignment); } } void JobTypeComboBox::hideAlertMessage() { + qCDebug(ClientLogger) << "JobTypeComboBox::hideAlertMessage"; if (m_control) { + qCDebug(ClientLogger) << "m_control is valid, hiding alert message"; m_control->hideAlertMessage(); } } int JobTypeComboBox::getCurrentEditPosition() const { + qCDebug(ClientLogger) << "JobTypeComboBox::getCurrentEditPosition"; return m_newPos; } void JobTypeComboBox::updateJobType(const AccountItem::Ptr& account) { + qCDebug(ClientLogger) << "JobTypeComboBox::updateJobType"; if (nullptr == account) { + qCDebug(ClientLogger) << "account is null, returning"; return; } //将自定义控件内存是否并置空,保存初始展示时能够进入高度调整 if (m_customWidget) { + qCDebug(ClientLogger) << "m_customWidget is valid, deleting it"; m_addBtn->deleteLater(); m_customWidget->deleteLater(); m_addBtn = nullptr; @@ -117,6 +140,7 @@ void JobTypeComboBox::updateJobType(const AccountItem::Ptr& account) //切换账号重置选项后需重置view的高度限制和大小策略,使其在初次显示时能跟随列表项数量动态调整高度 QFrame *viewContainer = findChild(); if (viewContainer) { + qCDebug(ClientLogger) << "viewContainer is valid, resetting height and size policy"; viewContainer->setMinimumHeight(0); viewContainer->setMaximumHeight(16777215); viewContainer->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); @@ -127,6 +151,7 @@ void JobTypeComboBox::updateJobType(const AccountItem::Ptr& account) QString text = currentText(); m_lstJobType = account->getScheduleTypeList(); clear(); //更新前先清空原有列表 + qCDebug(ClientLogger) << "Updating job types, count:" << m_lstJobType.size(); for (m_itemNumIndex = 0; m_itemNumIndex < m_lstJobType.size(); m_itemNumIndex++) { addJobTypeItem(m_itemNumIndex, m_lstJobType[m_itemNumIndex]->getColorCode(), m_lstJobType[m_itemNumIndex]->displayName()); } @@ -140,6 +165,7 @@ void JobTypeComboBox::updateJobType(const AccountItem::Ptr& account) void JobTypeComboBox::addJobTypeItem(int idx, QString strColorHex, QString strJobType) { + // qCDebug(ClientLogger) << "JobTypeComboBox::addJobTypeItem, idx:" << idx << "color:" << strColorHex << "type:" << strJobType; //绘制的pixmap为基准大小的4倍,防止缩放时出现齿距 QSize size(64, 64); QPixmap pixmap(size); @@ -162,13 +188,16 @@ void JobTypeComboBox::addJobTypeItem(int idx, QString strColorHex, QString strJo void JobTypeComboBox::initUI() { + qCDebug(ClientLogger) << "JobTypeComboBox::initUI"; setEditable(false); setIconSize(QSize(16, 16)); } void JobTypeComboBox::setItemSelectable(bool status) { + qCDebug(ClientLogger) << "JobTypeComboBox::setItemSelectable, status:" << status; if (-1 == m_hoverSelectedIndex) { + qCDebug(ClientLogger) << "m_hoverSelectedIndex is -1, returning"; return; } //更改当前列表框里的高亮项的可选择状态设置,将其设置为不可选中状态可实现失去选中效果,待聚焦后再恢复过来 @@ -177,14 +206,18 @@ void JobTypeComboBox::setItemSelectable(bool status) //设置“添加按键”按钮的高亮状态 if (nullptr != m_addBtn) { + qCDebug(ClientLogger) << "m_addBtn is valid, setting highlight"; m_addBtn->setHighlight(!status); } } void JobTypeComboBox::addCustomWidget(QFrame *viewContainer) { + qCDebug(ClientLogger) << "JobTypeComboBox::addCustomWidget"; if (viewContainer) { + qCDebug(ClientLogger) << "viewContainer is valid"; if (nullptr == m_customWidget) { + qCDebug(ClientLogger) << "m_customWidget is null, creating it"; //获取原控件布局 QBoxLayout *layout = qobject_cast(viewContainer->layout()); //自定义控件 @@ -216,15 +249,19 @@ void JobTypeComboBox::addCustomWidget(QFrame *viewContainer) void JobTypeComboBox::showPopup() { + qCDebug(ClientLogger) << "JobTypeComboBox::showPopup"; //重置icon大小 setIconSize(QSize(16, 16)); setItemSelectable(true); - if (currentIndex() < 0) + if (currentIndex() < 0) { + qCDebug(ClientLogger) << "Current index < 0, setting to 0"; setCurrentIndex(0); + } //设置为不可编辑模式 setEditable(false); //下拉模式取消信号关联,并释放警报控制 if (m_control) { + qCDebug(ClientLogger) << "m_control is valid, disconnecting and deleting"; disconnect(m_control, &DAlertControl::alertChanged, this, &JobTypeComboBox::alertChanged); delete m_control; m_control = nullptr; @@ -237,16 +274,19 @@ void JobTypeComboBox::showPopup() QFrame *viewContainer = findChild(); if (nullptr == m_customWidget) { + qCDebug(ClientLogger) << "m_customWidget is null, adding custom widget"; //添加自定义布局 addCustomWidget(viewContainer); } if (m_customWidget && m_lstJobType.size() >= 20) { + qCDebug(ClientLogger) << "Hiding custom widget, too many items"; m_customWidget->hide(); } //设置最大高度为400 - if (viewContainer->height() > 400) { + if (viewContainer && viewContainer->height() > 400) { + qCDebug(ClientLogger) << "View container height > 400, setting to 400"; viewContainer->setFixedHeight(400); } //重新调整选中项的位置 @@ -256,43 +296,56 @@ void JobTypeComboBox::showPopup() bool JobTypeComboBox::eventFilter(QObject *obj, QEvent *event) { + // qCDebug(ClientLogger) << "JobTypeComboBox::eventFilter, obj:" << (obj ? obj->objectName() : "null") << "event type:" << event->type(); if (view() == obj && (event->type() == QEvent::Enter)) { + // qCDebug(ClientLogger) << "Mouse enter view"; view()->setFocus(); } else if (m_addBtn == obj && (event->type() == QEvent::Enter)) { + // qCDebug(ClientLogger) << "Mouse enter add button"; m_addBtn->setFocus(); } else if (view() == obj && event->type() == QEvent::FocusIn) { + // qCDebug(ClientLogger) << "View focus in"; //列表框控件焦点进入事件 setItemSelectable(true); } else if (m_addBtn == obj && event->type() == QEvent::FocusIn) { + // qCDebug(ClientLogger) << "Add button focus in"; //“添加按键”控件焦点进入事件 setItemSelectable(false); } else if (event->type() == QEvent::KeyPress) { + // qCDebug(ClientLogger) << "KeyPress event"; QKeyEvent *kEvent = dynamic_cast(event); if (view() == obj && kEvent->key() == Qt::Key_Down) { + // qCDebug(ClientLogger) << "Key_Down on view"; //焦点在列表框时的下方向按键按下事件 - if (m_addBtn->isHighlight()) { + if (m_addBtn && m_addBtn->isHighlight()) { + // qCDebug(ClientLogger) << "Add button is highlighted, returning true"; return true; } if (m_hoverSelectedIndex == m_itemNumIndex - 1) { + qCDebug(ClientLogger) << "Reached last item, moving focus to add button"; //列表框到达最后一项时的下方向按键按下事件 //将焦点转移到“添加按键”控件上 m_addBtn->setFocus(); } } else if (m_addBtn == obj && kEvent->key() == Qt::Key_Up) { + // qCDebug(ClientLogger) << "Key_Up on add button"; //焦点在m_addBtn时的上方向按键按下事件 if (m_addBtn->isHighlight()) { + qCDebug(ClientLogger) << "Add button is highlighted, moving focus to view"; //将焦点转移到列表控件上 view()->setFocus(); } - } else if (m_addBtn->isHighlight() && kEvent->key() == Qt::Key_Return) { + } else if (m_addBtn && m_addBtn->isHighlight() && kEvent->key() == Qt::Key_Return) { + qCDebug(ClientLogger) << "Key_Return on highlighted add button"; //回车事件 slotBtnAddItemClicked(); } //过滤掉m_addBtn的所有按键事件 if (m_addBtn == obj) { + qCDebug(ClientLogger) << "Filtering key event for add button"; return true; } } @@ -301,6 +354,7 @@ bool JobTypeComboBox::eventFilter(QObject *obj, QEvent *event) void JobTypeComboBox::slotBtnAddItemClicked() { + qCDebug(ClientLogger) << "JobTypeComboBox::slotBtnAddItemClicked"; JobTypeComboBox::hidePopup(); setIconSize(QSize(0, 0)); //设置没有选中, @@ -318,6 +372,7 @@ void JobTypeComboBox::slotBtnAddItemClicked() void JobTypeComboBox::slotEditingFinished() { + qCDebug(ClientLogger) << "JobTypeComboBox::slotEditingFinished"; //TODO:待优化,由于上下按键会匹配下拉列表内容,导致会调整lineEdit显示位置 //当前先改回设置显示图标的方法 // int oldPos = m_newPos; @@ -330,6 +385,7 @@ void JobTypeComboBox::slotEditingFinished() void JobTypeComboBox::slotEditCursorPositionChanged(int oldPos, int newPos) { + qCDebug(ClientLogger) << "JobTypeComboBox::slotEditCursorPositionChanged, oldPos:" << oldPos << "newPos:" << newPos; m_oldPos = oldPos; m_newPos = newPos; } diff --git a/calendar-client/src/customWidget/jobtypelistview.cpp b/calendar-client/src/customWidget/jobtypelistview.cpp index 05182c7f5..67600816f 100644 --- a/calendar-client/src/customWidget/jobtypelistview.cpp +++ b/calendar-client/src/customWidget/jobtypelistview.cpp @@ -31,16 +31,19 @@ static const int RoleJobTypeLine = Qt::UserRole + 4; JobTypeListView::JobTypeListView(QWidget *parent) : QTableView(parent) { + qCDebug(ClientLogger) << "JobTypeListView constructor"; initUI(); } JobTypeListView::~JobTypeListView() { + qCDebug(ClientLogger) << "JobTypeListView destructor"; // JobTypeInfoManager::instance()->removeFromNoticeBill(this); } void JobTypeListView::initUI() { + qCDebug(ClientLogger) << "JobTypeListView::initUI"; m_modelJobType = new QStandardItemModel(this); setModel(m_modelJobType); setFrameStyle(QFrame::NoFrame); @@ -86,6 +89,7 @@ bool JobTypeListView::viewportEvent(QEvent *event) int indexCurrentHover; if (QEvent::HoverLeave == event->type()) { + qCDebug(ClientLogger) << "JobTypeListView::viewportEvent HoverLeave"; QStandardItemModel *itemModel = qobject_cast(model()); if (nullptr == itemModel) { return true; @@ -108,6 +112,7 @@ bool JobTypeListView::viewportEvent(QEvent *event) indexCurrentHover = indexAt(static_cast(event)->pos()).row(); if (indexCurrentHover != m_iIndexCurrentHover) { + qCDebug(ClientLogger) << "JobTypeListView::viewportEvent hover index changed to:" << indexCurrentHover; DStandardItem *itemJobType; //隐藏此前鼠标悬浮行的图标 @@ -146,6 +151,7 @@ bool JobTypeListView::viewportEvent(QEvent *event) connect(actionExport, &QAction::triggered, this, &JobTypeListView::slotExportScheduleType); if (!itemJobType->data(RoleJobTypeEditable).toBool()) { if (!itemJobType->data(RoleJobTypeLine).toBool()) { + qCDebug(ClientLogger) << "JobTypeListView: Adding export action to non-editable item"; itemJobType->setActionList(Qt::Edge::RightEdge, { actionExport }); } return true; @@ -160,6 +166,7 @@ bool JobTypeListView::viewportEvent(QEvent *event) actionDelete->setParent(this); connect(actionDelete, &QAction::triggered, this, &JobTypeListView::slotDeleteJobType); + qCDebug(ClientLogger) << "JobTypeListView: Adding edit, delete, and export actions to editable item"; itemJobType->setActionList(Qt::Edge::RightEdge, {actionEdit, actionDelete, actionExport}); } } @@ -167,8 +174,10 @@ bool JobTypeListView::viewportEvent(QEvent *event) } return true; } + bool JobTypeListView::updateJobType() { + qCDebug(ClientLogger) << "JobTypeListView::updateJobType for account:" << m_account_id; AccountItem::Ptr account = gAccountManager->getAccountItemByAccountId(m_account_id); if (!account) { qCWarning(ClientLogger) << "Failed to update job types: Account not found for id" << m_account_id; @@ -178,6 +187,7 @@ bool JobTypeListView::updateJobType() m_iIndexCurrentHover = -1; DScheduleType::List lstJobType = account->getScheduleTypeList(); + qCDebug(ClientLogger) << "JobTypeListView::updateJobType found" << lstJobType.size() << "schedule types"; int viewHeight = 0; for (int i = 0; i < lstJobType.size(); i++) { viewHeight += addJobTypeItem(*lstJobType[i]); @@ -190,12 +200,14 @@ bool JobTypeListView::updateJobType() void JobTypeListView::updateCalendarAccount(QString account_id) { + qCDebug(ClientLogger) << "JobTypeListView::updateCalendarAccount account_id:" << account_id; m_account_id = account_id; updateJobType(); } void JobTypeListView::slotAddScheduleType() { + qCDebug(ClientLogger) << "JobTypeListView::slotAddScheduleType"; AccountItem::Ptr account = gAccountManager->getAccountItemByAccountId(m_account_id); if (!account) { qCWarning(ClientLogger) << "Failed to add schedule type: Account not found for id" << m_account_id; @@ -214,6 +226,7 @@ void JobTypeListView::slotAddScheduleType() void JobTypeListView::slotImportScheduleType() { + qCDebug(ClientLogger) << "JobTypeListView::slotImportScheduleType"; // 选择ICS文件 auto docDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); auto filename = QFileDialog::getOpenFileName(nullptr, tr("import ICS file"), docDir, "ICS (*.ics)"); @@ -301,6 +314,7 @@ void JobTypeListView::slotImportScheduleType() void JobTypeListView::slotExportScheduleType() { + qCDebug(ClientLogger) << "JobTypeListView::slotExportScheduleType"; DStandardItem *item = dynamic_cast(m_modelJobType->item(m_iIndexCurrentHover)); if (!item) { qCWarning(ClientLogger) << "Export failed: No item selected"; @@ -346,11 +360,14 @@ bool JobTypeListView::canAdd() return false; //最多20个类型 - return account->getScheduleTypeList().count() < 20; + int count = account->getScheduleTypeList().count(); + qCDebug(ClientLogger) << "JobTypeListView::canAdd checking if can add more types, current count:" << count; + return count < 20; } void JobTypeListView::setItemEnabled(bool b) { + qCDebug(ClientLogger) << "JobTypeListView::setItemEnabled enabled:" << b; if (!m_modelJobType) return; for (int i = 0; i < m_modelJobType->rowCount(); ++i) { @@ -361,6 +378,7 @@ void JobTypeListView::setItemEnabled(bool b) int JobTypeListView::addJobTypeItem(const DScheduleType &info) { + qCDebug(ClientLogger) << "JobTypeListView::addJobTypeItem adding type:" << info.displayName() << "ID:" << info.typeID(); int itemHeight = 0; DStandardItem *item = new DStandardItem; item->setData(QVariant::fromValue(info), RoleJobTypeInfo); @@ -389,6 +407,7 @@ int JobTypeListView::addJobTypeItem(const DScheduleType &info) void JobTypeListView::slotUpdateJobType() { + qCDebug(ClientLogger) << "JobTypeListView::slotUpdateJobType"; int index = indexAt(mapFromGlobal(QCursor::pos())).row(); if (index < 0 || index >= m_modelJobType->rowCount()) { qCWarning(ClientLogger) << "Update failed: Invalid index" << index; @@ -426,6 +445,7 @@ void JobTypeListView::slotUpdateJobType() void JobTypeListView::slotDeleteJobType() { + qCDebug(ClientLogger) << "JobTypeListView::slotDeleteJobType"; DStandardItem *item = dynamic_cast(m_modelJobType->item(m_iIndexCurrentHover)); if (!item) { qCWarning(ClientLogger) << "Delete failed: No item selected"; @@ -469,11 +489,13 @@ void JobTypeListView::slotDeleteJobType() void JobTypeListViewStyle::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { + // qCDebug(ClientLogger) << "JobTypeListViewStyle::paint"; QStyleOptionViewItem opt = option; //draw line bool isDrawLine = index.data(RoleJobTypeLine).toBool(); if (isDrawLine) { + // qCDebug(ClientLogger) << "JobTypeListViewStyle::paint draw line"; int y = opt.rect.y() + opt.rect.height() / 2; int x = opt.rect.x(); int w = x + opt.rect.width(); diff --git a/calendar-client/src/customWidget/labelwidget.cpp b/calendar-client/src/customWidget/labelwidget.cpp index 741158c1b..102ad7a33 100644 --- a/calendar-client/src/customWidget/labelwidget.cpp +++ b/calendar-client/src/customWidget/labelwidget.cpp @@ -3,25 +3,28 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "labelwidget.h" +#include "commondef.h" #include #include LabelWidget::LabelWidget(QWidget *parent) : QLabel(parent) { + // qCDebug(ClientLogger) << "LabelWidget constructor"; //设置焦点选中类型 setFocusPolicy(Qt::FocusPolicy::TabFocus); } LabelWidget::~LabelWidget() { - + // qCDebug(ClientLogger) << "LabelWidget destructor"; } void LabelWidget::paintEvent(QPaintEvent *ev) { QPainter painter(this); if (hasFocus()) { + // qCDebug(ClientLogger) << "LabelWidget paintEvent: has focus, drawing focus rect"; //有焦点,绘制焦点 QStyleOptionFocusRect option; option.initFrom(this); diff --git a/calendar-client/src/customWidget/lunarcalendarwidget.cpp b/calendar-client/src/customWidget/lunarcalendarwidget.cpp index 1165585f4..7b085f336 100644 --- a/calendar-client/src/customWidget/lunarcalendarwidget.cpp +++ b/calendar-client/src/customWidget/lunarcalendarwidget.cpp @@ -4,6 +4,7 @@ #include "lunarcalendarwidget.h" #include "lunarmanager.h" +#include "commondef.h" #include #include @@ -92,17 +93,20 @@ class CalenderStyle : public QProxyStyle QColor CalenderStyle::getColor(const QStyleOption *option, DPalette::ColorType type, const QWidget *widget) const { + // qCDebug(ClientLogger) << "CalenderStyle::getColor - DPalette::ColorType" << type; const DPalette &pa = DPaletteHelper::instance()->palette(widget, option->palette); return pa.brush(type).color(); } QColor CalenderStyle::getColor(const QStyleOption *option, QPalette::ColorRole role) const { + // qCDebug(ClientLogger) << "CalenderStyle::getColor - QPalette::ColorRole" << role; return option->palette.brush(role).color(); } void CalenderStyle::drawCalenderEllipse(QPainter *p, const QRect &rect, int offset) const { + // qCDebug(ClientLogger) << "CalenderStyle::drawCalenderEllipse with offset:" << offset; int d = (rect.height() - 7) / 2; int h = d + 7; QRect r = rect.adjusted(0, 0, 0, -(rect.height() - h)); @@ -115,7 +119,9 @@ void CalenderStyle::drawCalenderEllipse(QPainter *p, const QRect &rect, int offs void CalenderStyle::drawItemViewSelected(QPainter *p, const QStyleOption *opt) const { + // qCDebug(ClientLogger) << "CalenderStyle::drawItemViewSelected"; if (opt->state & QStyle::State_Selected) { + // qCDebug(ClientLogger) << "Drawing selected item view"; QRect rect = opt->rect; int d = (rect.height() - 7) / 2; @@ -134,9 +140,12 @@ void CalenderStyle::drawItemViewSelected(QPainter *p, const QStyleOption *opt) c void CalenderStyle::drawItemViewFocus(QPainter *p, const QStyleOption *opt, const QWidget *w) const { + // qCDebug(ClientLogger) << "CalenderStyle::drawItemViewFocus"; const QColor &focus_color = getColor(opt, QPalette::Highlight); - if (!focus_color.isValid() || focus_color.alpha() == 0) + if (!focus_color.isValid() || focus_color.alpha() == 0) { + qCDebug(ClientLogger) << "Focus color invalid or transparent, returning"; return; + } p->setRenderHint(QPainter::Antialiasing); QPen pen; @@ -146,6 +155,7 @@ void CalenderStyle::drawItemViewFocus(QPainter *p, const QStyleOption *opt, cons p->setBrush(Qt::NoBrush); bool calendar = w && (w->objectName() == "qt_calendar_calendarview"); + // qCDebug(ClientLogger) << "Is calendar view:" << calendar; pen.setWidth(2); int offset = 1; @@ -153,6 +163,7 @@ void CalenderStyle::drawItemViewFocus(QPainter *p, const QStyleOption *opt, cons pen.setColor(getColor(opt, QPalette::Base)); p->setPen(pen); if (calendar) { + // qCDebug(ClientLogger) << "Drawing inner frame for calendar"; pen.setWidth(3); p->setPen(pen); offset = 2; @@ -163,6 +174,7 @@ void CalenderStyle::drawItemViewFocus(QPainter *p, const QStyleOption *opt, cons pen.setColor(focus_color); p->setPen(pen); if (calendar) { + // qCDebug(ClientLogger) << "Drawing outer frame for calendar"; pen.setWidth(2); p->setPen(pen); offset = 1; @@ -172,6 +184,7 @@ void CalenderStyle::drawItemViewFocus(QPainter *p, const QStyleOption *opt, cons QString CalenderStyle::getLunarDayName(const QDate &date) const { + qCDebug(ClientLogger) << "CalenderStyle::getLunarDayName for date:" << date.toString(); updateLunarInfo(date); CaHuangLiDayInfo &info = m_caHuangLiDayMap[date]; @@ -180,6 +193,7 @@ QString CalenderStyle::getLunarDayName(const QDate &date) const QString CalenderStyle::getLunarYearDesc(const QDate &date) const { + qCDebug(ClientLogger) << "CalenderStyle::getLunarYearDesc for date:" << date.toString(); updateLunarInfo(date); CaHuangLiDayInfo &info = m_caHuangLiDayMap[date]; @@ -188,10 +202,14 @@ QString CalenderStyle::getLunarYearDesc(const QDate &date) const void CalenderStyle::updateLunarInfo(const QDate &date) const { - if (m_caHuangLiDayMap.count() > 100) + qCDebug(ClientLogger) << "CalenderStyle::updateLunarInfo for date:" << date.toString(); + if (m_caHuangLiDayMap.count() > 100) { + qCDebug(ClientLogger) << "Map size exceeds 100, clearing cache"; m_caHuangLiDayMap.clear(); + } if (!m_caHuangLiDayMap.contains(date)) { + qCDebug(ClientLogger) << "Date not in cache, fetching lunar info"; CaHuangLiDayInfo info = gLunarManager->getHuangLiDay(date); m_caHuangLiDayMap[date] = info; } @@ -199,20 +217,26 @@ void CalenderStyle::updateLunarInfo(const QDate &date) const void CalenderStyle::drawControl(QStyle::ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const { + qCDebug(ClientLogger) << "CalenderStyle::drawControl element:" << element; const QWidget *w = widget; const QStyleOption *opt = option; QPainter *p = painter; while (element == CE_ItemViewItem) { if (w && w->objectName() == "qt_calendar_calendarview") { + // qCDebug(ClientLogger) << "Drawing calendar view item"; if (const QStyleOptionViewItem *vopt = qstyleoption_cast(opt)) { LunarCalendarWidget *calendar = qobject_cast(w->parent()); - if (!calendar) + if (!calendar) { + qCDebug(ClientLogger) << "Calendar widget not found, breaking"; break; + } const QAbstractTableModel *model = qobject_cast(vopt->index.model()); - if (!model) + if (!model) { + qCDebug(ClientLogger) << "Model not found, breaking"; break; + } //获取阳历和阴历 QString dayName; @@ -221,17 +245,21 @@ void CalenderStyle::drawControl(QStyle::ControlElement element, const QStyleOpti int day = vopt->index.data().toInt(); //该item的时间 QDate curDate = QDate(calendar->yearShown(), calendar->monthShown(), 1); + // qCDebug(ClientLogger) << "Processing item with day:" << day << "initial date:" << curDate.toString(); //显示天的item需要获取每个item的显示时间 if (day > 0) { //如果是第一行会显示上个月的日期 if (vopt->index.row() < 2 && day > 20) { + // qCDebug(ClientLogger) << "Adjusting to previous month"; curDate = curDate.addMonths(-1); } else if (vopt->index.row() > 3 && day < 15) { //如果显示行数大于3且显示的天小于15则表示是下个月 + // qCDebug(ClientLogger) << "Adjusting to next month"; curDate = curDate.addMonths(1); } curDate.setDate(curDate.year(), curDate.month(), day); dayName = getLunarDayName(curDate); + // qCDebug(ClientLogger) << "Final date:" << curDate.toString() << "lunar day:" << dayName; //更新阴历年描述 int selectedYear = calendar->yearShown(); @@ -239,6 +267,7 @@ void CalenderStyle::drawControl(QStyle::ControlElement element, const QStyleOpti //如果为焦点状态,则根据该item的日期设置年份时间 if (vopt->state & QStyle::State_HasFocus) { + // qCDebug(ClientLogger) << "Item has focus, updating lunar year text"; QDate selectedDate = QDate(selectedYear, selectedMonth, day); calendar->setLunarYearText(getLunarYearDesc(selectedDate)); } @@ -249,6 +278,7 @@ void CalenderStyle::drawControl(QStyle::ControlElement element, const QStyleOpti //绘制禁用项 if (!(vopt->state & QStyle::State_Enabled)) { + // qCDebug(ClientLogger) << "Drawing disabled item"; p->save(); p->setPen(Qt::NoPen); p->setBrush(getColor(vopt, DPalette::Window)); @@ -261,6 +291,7 @@ void CalenderStyle::drawControl(QStyle::ControlElement element, const QStyleOpti // draw the text if (!vopt->text.isEmpty()) { + // qCDebug(ClientLogger) << "Drawing text:" << vopt->text; QPalette::ColorGroup cg = (vopt->state & QStyle::State_Enabled) ? QPalette::Normal : QPalette::Disabled; @@ -279,9 +310,11 @@ void CalenderStyle::drawControl(QStyle::ControlElement element, const QStyleOpti const QRect rect = vopt->rect; int d = (rect.height() - 7) / 2; if (vopt->index.row() == 0) { + // qCDebug(ClientLogger) << "Drawing header row text"; p->setPen(colorOrg); p->drawText(vopt->rect, Qt::AlignCenter, dayNumber); } else { + // qCDebug(ClientLogger) << "Drawing day number and lunar day"; int h = d + 7; p->setPen(colorOrg); p->drawText(rect.adjusted(0, 0, 0, -(rect.height() - h)), Qt::AlignCenter, dayNumber); @@ -294,6 +327,7 @@ void CalenderStyle::drawControl(QStyle::ControlElement element, const QStyleOpti //绘制日历分割线 if (vopt->index.row() == 0) { + // qCDebug(ClientLogger) << "Drawing calendar separator line for column:" << vopt->index.column(); p->save(); QColor color = getColor(vopt, DPalette::FrameBorder, w); color.setAlpha(static_cast(255 * 0.05)); @@ -314,6 +348,7 @@ void CalenderStyle::drawControl(QStyle::ControlElement element, const QStyleOpti // draw the focus rect if (vopt->state & QStyle::State_HasFocus) { + // qCDebug(ClientLogger) << "Drawing focus rectangle"; QStyleOptionFocusRect o; o.QStyleOption::operator=(*vopt); o.rect = proxy()->subElementRect(SE_ItemViewItemFocusRect, vopt, w); @@ -339,6 +374,7 @@ LunarCalendarWidget::LunarCalendarWidget(QWidget *parent) : QCalendarWidget(parent) , m_style(new CalenderStyle) { + qCDebug(ClientLogger) << "LunarCalendarWidget constructor"; QWidget *w = findChild("qt_calendar_calendarview"); if (w) w->setStyle(m_style); @@ -362,6 +398,7 @@ LunarCalendarWidget::LunarCalendarWidget(QWidget *parent) LunarCalendarWidget::~LunarCalendarWidget() { + qCDebug(ClientLogger) << "LunarCalendarWidget destructor"; //Sets the widget's GUI style to style. The ownership of the style object is not transferred. //需手动删除 delete m_style; @@ -369,27 +406,36 @@ LunarCalendarWidget::~LunarCalendarWidget() void LunarCalendarWidget::setLunarYearText(const QString &text) { + qCDebug(ClientLogger) << "LunarCalendarWidget::setLunarYearText:" << text; if (m_lunarLabel->text() != text) m_lunarLabel->setText(text); } QString LunarCalendarWidget::lunarYearText() { + qCDebug(ClientLogger) << "LunarCalendarWidget::lunarYearText"; return m_lunarLabel->text(); } QSize LunarCalendarWidget::minimumSizeHint() const { + qCDebug(ClientLogger) << "LunarCalendarWidget::minimumSizeHint"; QTableView *view = findChild("qt_calendar_calendarview"); - if (!view) + if (!view) { + qCDebug(ClientLogger) << "Calendar view not found, returning empty size"; return QSize(); + } QAbstractItemModel *model = view->model(); - if (!model) + if (!model) { + qCDebug(ClientLogger) << "Model not found, returning empty size"; return QSize(); + } QWidget *navigationbar = findChild("qt_calendar_navigationbar"); - if (!navigationbar) + if (!navigationbar) { + qCDebug(ClientLogger) << "Navigation bar not found, returning empty size"; return QSize(); + } int rowcount = model->rowCount(); int hf = QFontMetrics(this->font()).height(); @@ -407,5 +453,6 @@ QSize LunarCalendarWidget::minimumSizeHint() const //底部留空 h += BottomSpacing; + qCDebug(ClientLogger) << "Calculated minimum size:" << QSize(w, h); return QSize(w, h); } diff --git a/calendar-client/src/customWidget/monthbrefwidget.cpp b/calendar-client/src/customWidget/monthbrefwidget.cpp index b1abbe347..58ec3f673 100644 --- a/calendar-client/src/customWidget/monthbrefwidget.cpp +++ b/calendar-client/src/customWidget/monthbrefwidget.cpp @@ -6,6 +6,7 @@ #include "constants.h" #include "scheduledatamanage.h" #include "calendarglobalenv.h" +#include "commondef.h" #include #include @@ -20,6 +21,7 @@ MonthBrefWidget::MonthBrefWidget(QWidget *parent) : QWidget(parent) , m_globalData(new GlobalData) { + qCDebug(ClientLogger) << "MonthBrefWidget constructor"; QGridLayout *gridLayout = new QGridLayout(this); gridLayout->setSpacing(0); gridLayout->setContentsMargins(0, 0, 0, 0); @@ -38,6 +40,7 @@ MonthBrefWidget::MonthBrefWidget(QWidget *parent) MonthBrefWidget::~MonthBrefWidget() { + qCDebug(ClientLogger) << "MonthBrefWidget destructor"; delete m_globalData; } @@ -48,12 +51,14 @@ MonthBrefWidget::~MonthBrefWidget() */ void MonthBrefWidget::setShowMonthDate(const QDate& monthDate) { + qCDebug(ClientLogger) << "MonthBrefWidget::setShowMonthDate:" << monthDate.toString(); //获取当月第一天 QDate date = QDate(monthDate.year(), monthDate.month(), 1); int firstday = CalendarManager::getInstance()->getFirstDayOfWeek(); int day = date.dayOfWeek(); //计算当前月日历第一天该显示的时间 date = date.addDays(-(day-firstday+7)%7); + qCDebug(ClientLogger) << "First day to display:" << date.toString(); for (int i = 0; i < m_DayItem.size(); ++i) { m_DayItem.at(i)->setDate(date); date = date.addDays(1); @@ -70,6 +75,7 @@ void MonthBrefWidget::setShowMonthDate(const QDate& monthDate) */ void MonthBrefWidget::setHasScheduleDateSet(const QSet &hasScheduleSet) { + qCDebug(ClientLogger) << "MonthBrefWidget::setHasScheduleDateSet, size:" << hasScheduleSet.size(); //清空原有标识 for (int i = 0; i < 32; ++i) { m_globalData->m_scheduleDateFlag[i] = false; @@ -77,6 +83,7 @@ void MonthBrefWidget::setHasScheduleDateSet(const QSet &hasScheduleSet) //根据日程所在天设置标识 for (QDate date:hasScheduleSet) { if (m_globalData->isBelongMonth(date)) { + // qCDebug(ClientLogger) << "Setting schedule flag for date:" << date.toString(); m_globalData->m_scheduleDateFlag[date.day()] = true; } } @@ -90,6 +97,7 @@ void MonthBrefWidget::setHasScheduleDateSet(const QSet &hasScheduleSet) */ void MonthBrefWidget::setHasSearchScheduleSet(const QSet &hasScheduleSet) { + qCDebug(ClientLogger) << "MonthBrefWidget::setHasSearchScheduleSet, size:" << hasScheduleSet.size(); //清空原有标识 for (int i = 0; i < 32; ++i) { m_globalData->m_searchedDateFlag[i] = false; @@ -97,6 +105,7 @@ void MonthBrefWidget::setHasSearchScheduleSet(const QSet &hasScheduleSet) //根据日程所在天设置标识 for (QDate date:hasScheduleSet) { if (m_globalData->isBelongMonth(date)) { + // qCDebug(ClientLogger) << "Setting search flag for date:" << date.toString(); m_globalData->m_searchedDateFlag[date.day()] = true; } } @@ -110,7 +119,9 @@ void MonthBrefWidget::setHasSearchScheduleSet(const QSet &hasScheduleSet) */ void MonthBrefWidget::mousePressEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "MonthBrefWidget::mousePressEvent"; if (event->source() == Qt::MouseEventSynthesizedByQt) { + qCDebug(ClientLogger) << "MonthBrefWidget::mousePressEvent - touch event detected"; //如果为触摸转换则设置触摸状态和触摸开始坐标 m_touchState = 1; m_touchBeginPoint = event->pos(); @@ -124,7 +135,9 @@ void MonthBrefWidget::mousePressEvent(QMouseEvent *event) */ void MonthBrefWidget::mouseReleaseEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "MonthBrefWidget::mouseReleaseEvent"; if (event->source() == Qt::MouseEventSynthesizedByQt) { + qCDebug(ClientLogger) << "MonthBrefWidget::mouseReleaseEvent - touch event released"; m_touchState = 0; QWidget::mouseReleaseEvent(event); } @@ -137,10 +150,12 @@ void MonthBrefWidget::mouseReleaseEvent(QMouseEvent *event) */ void MonthBrefWidget::mouseMoveEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "MonthBrefWidget::mouseMoveEvent"; if (event->source() == Qt::MouseEventSynthesizedByQt) { QPoint currentPoint = event->pos(); //如果移动距离大与5则为触摸移动状态 if (QLineF(m_touchBeginPoint, currentPoint).length() > 5) { + qCDebug(ClientLogger) << "MonthBrefWidget::mouseMoveEvent - touch movement detected"; m_touchState = 2; } QWidget::mouseMoveEvent(event); @@ -150,6 +165,7 @@ void MonthBrefWidget::mouseMoveEvent(QMouseEvent *event) CMonthDayRectWidget::CMonthDayRectWidget(MonthBrefWidget::GlobalData* globalData, QWidget *parent) : QPushButton(parent) , m_globaldata(globalData) { + qCDebug(ClientLogger) << "CMonthDayRectWidget constructor"; setMinimumSize(10, 10); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); setFocusPolicy(Qt::NoFocus); @@ -166,10 +182,13 @@ CMonthDayRectWidget::CMonthDayRectWidget(MonthBrefWidget::GlobalData* globalData */ void CMonthDayRectWidget::setTheMe(int type) { + qCDebug(ClientLogger) << "CMonthDayRectWidget::setTheMe with type:" << type; CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); if (type == 0 || type == 1) { + qCDebug(ClientLogger) << "Setting light theme color"; m_ceventColor = QColor(255, 93, 0); } else if (type == 2) { + qCDebug(ClientLogger) << "Setting dark theme color"; m_ceventColor = QColor(204, 77, 3); } update(); @@ -182,6 +201,7 @@ void CMonthDayRectWidget::setTheMe(int type) */ void CMonthDayRectWidget::setDate(const QDate &date) { + // qCDebug(ClientLogger) << "CMonthDayRectWidget::setDate:" << date.toString(); m_date = date; } @@ -192,6 +212,7 @@ void CMonthDayRectWidget::setDate(const QDate &date) */ QDate CMonthDayRectWidget::getDate() const { + // qCDebug(ClientLogger) << "CMonthDayRectWidget::getDate:" << m_date.toString(); return m_date; } @@ -202,8 +223,10 @@ QDate CMonthDayRectWidget::getDate() const */ void CMonthDayRectWidget::mousePressEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "CMonthDayRectWidget::mousePressEvent for date:" << m_date.toString(); //因双击会产生两次按下事件,第二次按下事件触发在双击事件触发后,双击后要跳转页面,因此在按下时判断本控件是否出现显示状态再进行处理 if (event->button() == Qt::LeftButton && isVisible()) { + qCDebug(ClientLogger) << "Left button clicked and widget visible"; m_pressed = true; //保存日程悬浮框显示位置 CalendarGlobalEnv::getGlobalEnv()->reviseValue(DDECalendar::CursorPointKey, mapToGlobal(QPoint(width()/2,height()/2))); @@ -220,7 +243,9 @@ void CMonthDayRectWidget::mousePressEvent(QMouseEvent *event) */ void CMonthDayRectWidget::mouseDoubleClickEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "CMonthDayRectWidget::mouseDoubleClickEvent for date:" << m_date.toString(); if (event->button() == Qt::LeftButton) { + qCDebug(ClientLogger) << "Double click with left button, emitting signal"; emit signalDoubleClick(m_date); } QWidget::mouseDoubleClickEvent(event); @@ -233,7 +258,9 @@ void CMonthDayRectWidget::mouseDoubleClickEvent(QMouseEvent *event) */ void CMonthDayRectWidget::mouseReleaseEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "CMonthDayRectWidget::mouseReleaseEvent for date:" << m_date.toString(); if (event->button() == Qt::LeftButton) { + qCDebug(ClientLogger) << "Left button released"; m_pressed = false; } update(); @@ -247,6 +274,7 @@ void CMonthDayRectWidget::mouseReleaseEvent(QMouseEvent *event) */ void CMonthDayRectWidget::paintEvent(QPaintEvent *event) { + // qCDebug(ClientLogger) << "CMonthDayRectWidget::paintEvent for date:" << m_date.toString(); //获取待绘制的文字 QString text = QString::number(m_date.day()); @@ -266,6 +294,7 @@ void CMonthDayRectWidget::paintEvent(QPaintEvent *event) QColor highColor = DPaletteHelper::instance()->palette(this).highlight().color(); if (m_date == QDate::currentDate() && m_globaldata->isBelongMonth(m_date)) { + // qCDebug(ClientLogger) << "Painting current date"; //当天日期 painter.setBrush(highColor); painter.setPen(Qt::NoPen); @@ -273,6 +302,7 @@ void CMonthDayRectWidget::paintEvent(QPaintEvent *event) painter.setPen(DPaletteHelper::instance()->palette(this).highlightedText().color()); painter.drawText(rectf, Qt::AlignCenter, text); } else if (m_globaldata->isSelectedDate(m_date)) { + // qCDebug(ClientLogger) << "Painting selected date"; //被选中的日期 painter.setBrush(highColor); painter.setPen(Qt::NoPen); @@ -282,13 +312,16 @@ void CMonthDayRectWidget::paintEvent(QPaintEvent *event) painter.setOpacity(1); painter.drawText(rectf, Qt::AlignCenter, text); } else if (m_globaldata->isHasSearchedByDate(m_date)) { + // qCDebug(ClientLogger) << "Painting date with search results"; //有被搜索日程,绘制文字 painter.setPen(highColor); painter.setOpacity(1); painter.drawText(rectf, Qt::AlignCenter, text); } else { + // qCDebug(ClientLogger) << "Painting normal date"; //绘制默认文字 if (!m_globaldata->isBelongMonth(m_date)) { + // qCDebug(ClientLogger) << "Date not in current month, setting opacity"; //置灰日期 painter.setOpacity(0.3); } @@ -296,6 +329,7 @@ void CMonthDayRectWidget::paintEvent(QPaintEvent *event) } if (m_globaldata->isHasSearchedByDate(m_date)) { + // qCDebug(ClientLogger) << "Drawing search indicator circle"; //有被搜索日程,绘制圆圈 QPainterPath path; path.addEllipse(rectf); @@ -306,26 +340,31 @@ void CMonthDayRectWidget::paintEvent(QPaintEvent *event) } if (m_globaldata->isHasScheduleByDate(m_date)) { + // qCDebug(ClientLogger) << "Drawing schedule indicator dot"; //有日程,绘制日程圆点 painter.setBrush(QBrush(m_ceventColor)); painter.setPen(Qt::NoPen); painter.setOpacity(1); qreal ellipse_r = r * (4.0 / 25); if (ellipse_r < 4) { + // qCDebug(ClientLogger) << "Adjusting dot size to minimum"; ellipse_r = 4; } else if (ellipse_r > 7) { + // qCDebug(ClientLogger) << "Adjusting dot size to maximum"; ellipse_r = 7; } painter.drawEllipse(QRectF(rectf.x() + rectf.width() - ellipse_r, rectf.y() + rect().y(), ellipse_r, ellipse_r)); } if (m_pressed) { + // qCDebug(ClientLogger) << "Drawing pressed state"; //按下状态,绘制点击效果 painter.setBrush(DPaletteHelper::instance()->palette(this).text()); painter.setPen(Qt::NoPen); painter.setOpacity(0.3); painter.drawEllipse(rectf); } else if (m_hovered) { + // qCDebug(ClientLogger) << "Drawing hover state"; //悬浮状态,绘制悬浮效果 painter.setBrush(DPaletteHelper::instance()->palette(this).text()); painter.setOpacity(0.2); @@ -346,6 +385,7 @@ void CMonthDayRectWidget::enterEvent(QEnterEvent *event) void CMonthDayRectWidget::enterEvent(QEvent *event) #endif { + // qCDebug(ClientLogger) << "CMonthDayRectWidget::enterEvent for date:" << m_date.toString(); m_hovered = true; QWidget::enterEvent(event); } @@ -356,6 +396,7 @@ void CMonthDayRectWidget::enterEvent(QEvent *event) */ void CMonthDayRectWidget::leaveEvent(QEvent *event) { + // qCDebug(ClientLogger) << "CMonthDayRectWidget::leaveEvent for date:" << m_date.toString(); m_hovered = false; QWidget::leaveEvent(event); } diff --git a/calendar-client/src/customWidget/scheduleRemindWidget.cpp b/calendar-client/src/customWidget/scheduleRemindWidget.cpp index a931f0da2..c7ec9a71a 100644 --- a/calendar-client/src/customWidget/scheduleRemindWidget.cpp +++ b/calendar-client/src/customWidget/scheduleRemindWidget.cpp @@ -4,6 +4,7 @@ #include "scheduleRemindWidget.h" #include "constants.h" +#include "commondef.h" #include @@ -15,6 +16,7 @@ ScheduleRemindWidget::ScheduleRemindWidget(QWidget *parent) : DArrowRectangle(DArrowRectangle::ArrowLeft, DArrowRectangle::FloatWidget, parent) , m_centerWidget(new CenterWidget(this)) { + qCDebug(ClientLogger) << "ScheduleRemindWidget constructor"; //如果dtk版本为5.3以上则使用新接口 #if (DTK_VERSION > DTK_VERSION_CHECK(5, 3, 0, 0)) //设置显示圆角 @@ -34,11 +36,12 @@ ScheduleRemindWidget::ScheduleRemindWidget(QWidget *parent) ScheduleRemindWidget::~ScheduleRemindWidget() { - + qCDebug(ClientLogger) << "ScheduleRemindWidget destructor"; } void ScheduleRemindWidget::setData(const DSchedule::Ptr &vScheduleInfo, const CSchedulesColor &gcolor) { + qCDebug(ClientLogger) << "ScheduleRemindWidget::setData for schedule:" << vScheduleInfo->uid(); m_centerWidget->setData(vScheduleInfo, gcolor); m_ScheduleInfo = vScheduleInfo; gdcolor = gcolor; @@ -51,6 +54,7 @@ void ScheduleRemindWidget::setData(const DSchedule::Ptr &vScheduleInfo, const CS */ void ScheduleRemindWidget::setDirection(DArrowRectangle::ArrowDirection value) { + qCDebug(ClientLogger) << "ScheduleRemindWidget::setDirection:" << value; //设置箭头方向 this->setArrowDirection(value); //设置内容窗口 @@ -63,6 +67,7 @@ void ScheduleRemindWidget::setDirection(DArrowRectangle::ArrowDirection value) */ void ScheduleRemindWidget::setTimeFormat(QString timeformat) { + qCDebug(ClientLogger) << "ScheduleRemindWidget::setTimeFormat:" << timeformat; m_centerWidget->setTimeFormat(timeformat); } @@ -71,16 +76,18 @@ CenterWidget::CenterWidget(DWidget *parent) , textwidth(0) , textheight(0) { + qCDebug(ClientLogger) << "CenterWidget constructor"; textfont.setWeight(QFont::Medium); } CenterWidget::~CenterWidget() { - + qCDebug(ClientLogger) << "CenterWidget destructor"; } void CenterWidget::setData(const DSchedule::Ptr &vScheduleInfo, const CSchedulesColor &gcolor) { + qCDebug(ClientLogger) << "CenterWidget::setData for schedule:" << vScheduleInfo->uid(); m_ScheduleInfo = vScheduleInfo; gdcolor = gcolor; textfont.setPixelSize(DDECalendar::FontSizeTwelve); @@ -90,12 +97,15 @@ void CenterWidget::setData(const DSchedule::Ptr &vScheduleInfo, const CSchedules void CenterWidget::setTheMe(const int type) { + qCDebug(ClientLogger) << "CenterWidget::setTheMe with type:" << type; if (type == 2) { + qCDebug(ClientLogger) << "Setting dark theme colors"; timeColor = QColor("#C0C6D4"); timeColor.setAlphaF(0.7); textColor = QColor("#C0C6D4"); textColor.setAlphaF(1); } else { + qCDebug(ClientLogger) << "Setting light theme colors"; timeColor = QColor("#414D68"); timeColor.setAlphaF(0.7); textColor = QColor("#414D68"); @@ -110,12 +120,14 @@ void CenterWidget::setTheMe(const int type) */ void CenterWidget::setTimeFormat(QString timeFormat) { + qCDebug(ClientLogger) << "CenterWidget::setTimeFormat:" << timeFormat; m_timeFormat = timeFormat; update(); } void CenterWidget::UpdateTextList() { + qCDebug(ClientLogger) << "CenterWidget::UpdateTextList"; testList.clear(); QFontMetrics metrics(textfont); textwidth = metrics.horizontalAdvance(m_ScheduleInfo->summary()); @@ -124,8 +136,10 @@ void CenterWidget::UpdateTextList() QString text; if (h_count < 1) { + qCDebug(ClientLogger) << "Text fits in one line"; testList.append(m_ScheduleInfo->summary()); } else { + qCDebug(ClientLogger) << "Text needs multiple lines, h_count:" << h_count; const int text_Max_Height = 108; const int text_HeightMaxCount = qFloor(text_Max_Height / textheight); @@ -137,6 +151,7 @@ void CenterWidget::UpdateTextList() text = ""; if (testList.count() == (text_HeightMaxCount - 1)) { + qCDebug(ClientLogger) << "Reached maximum line count, adding elided text"; text = m_ScheduleInfo->summary().right(m_ScheduleInfo->summary().count() - i); testList.append(metrics.elidedText(text, Qt::ElideRight, textRectWidth)); break; @@ -144,17 +159,20 @@ void CenterWidget::UpdateTextList() --i; } else { if (i + 1 == m_ScheduleInfo->summary().count()) { + // qCDebug(ClientLogger) << "Adding final line of text"; testList.append(text); } } } } + qCDebug(ClientLogger) << "Final text list has" << testList.count() << "lines"; this->setFixedHeight(testList.count() * textheight + 30 + 8); } void CenterWidget::paintEvent(QPaintEvent *e) { + // qCDebug(ClientLogger) << "CenterWidget::paintEvent"; Q_UNUSED(e); int diam = 8; int x = 40 - 13; @@ -170,8 +188,12 @@ void CenterWidget::paintEvent(QPaintEvent *e) timestr = m_ScheduleInfo->dtStart().time().toString(m_timeFormat); QFontMetrics metrics(timeFont); - if (m_ScheduleInfo->allDay()) + if (m_ScheduleInfo->allDay()) { + // qCDebug(ClientLogger) << "All day event"; timestr = tr("All Day"); + } else { + // qCDebug(ClientLogger) << "Time-specific event:" << timestr; + } int timewidth = metrics.horizontalAdvance(timestr); int timeheight = metrics.height(); @@ -184,6 +206,7 @@ void CenterWidget::paintEvent(QPaintEvent *e) painter.setPen(pen); painter.setFont(textfont); + // qCDebug(ClientLogger) << "Drawing" << testList.count() << "lines of text"; for (int i = 0; i < testList.count(); i++) { painter.drawText( QRect(x, 30 + i * textheight, textRectWidth, textheight), diff --git a/calendar-client/src/customWidget/scheduleview.cpp b/calendar-client/src/customWidget/scheduleview.cpp index cb9c11253..50a0d5062 100644 --- a/calendar-client/src/customWidget/scheduleview.cpp +++ b/calendar-client/src/customWidget/scheduleview.cpp @@ -11,6 +11,7 @@ #include "constants.h" #include "calendarmanage.h" #include "calendarglobalenv.h" +#include "commondef.h" #include #include @@ -34,6 +35,7 @@ CScheduleView::CScheduleView(QWidget *parent, ScheduleViewPos viewType) , m_touchGesture(this) , m_timeFormat(CalendarManager::getInstance()->getTimeFormat()) { + qCDebug(ClientLogger) << "Creating CScheduleView with viewType:" << viewType; initUI(); initConnection(); setLineWidth(0); @@ -42,10 +44,12 @@ CScheduleView::CScheduleView(QWidget *parent, ScheduleViewPos viewType) CScheduleView::~CScheduleView() { + qCDebug(ClientLogger) << "Destroying CScheduleView"; } void CScheduleView::setviewMargin(int left, int top, int right, int bottom) { + qCDebug(ClientLogger) << "Setting view margins:" << left << top << right << bottom; m_leftMargin = left; m_topMargin = top; m_rightMargin = right; @@ -58,7 +62,9 @@ void CScheduleView::setRange(int w, int h, QDate begin, QDate end) { Q_UNUSED(h); + qCDebug(ClientLogger) << "Setting range with width:" << w << "begin date:" << begin << "end date:" << end; if (!(w > 0)) { + qCDebug(ClientLogger) << "Invalid width, returning"; return; } m_beginDate = begin; @@ -74,6 +80,7 @@ void CScheduleView::setRange(int w, int h, QDate begin, QDate end) void CScheduleView::setRange(QDate begin, QDate end) { + qCDebug(ClientLogger) << "Setting date range:" << begin << "to" << end; m_TotalDay = begin.daysTo(end) + 1; m_graphicsView->setRange(begin, end); m_alldaylist->setRange(begin, end); @@ -84,12 +91,15 @@ void CScheduleView::setRange(QDate begin, QDate end) void CScheduleView::setTheMe(int type) { + qCDebug(ClientLogger) << "Setting theme type:" << type; if (type == 0 || type == 1) { + qCDebug(ClientLogger) << "Setting light theme colors"; m_linecolor = "#000000"; m_linecolor.setAlphaF(0.1); m_ALLDayColor = "#303030"; m_timeColor = "#7D7D7D"; } else if (type == 2) { + qCDebug(ClientLogger) << "Setting dark theme colors"; m_linecolor = "#000000"; m_linecolor.setAlphaF(0.1); m_ALLDayColor = "#7D7D7D"; @@ -105,36 +115,45 @@ void CScheduleView::setTheMe(int type) void CScheduleView::setLunarVisible(bool state) { + // qCDebug(ClientLogger) << "Setting lunar visible:" << state; Q_UNUSED(state); } void CScheduleView::setTime(QTime time) { + // qCDebug(ClientLogger) << "Setting time:" << time; m_graphicsView->setTime(time); } void CScheduleView::setSelectSchedule(const DSchedule::Ptr &scheduleInfo) { + qCDebug(ClientLogger) << "Setting selected schedule ID:" << scheduleInfo->uid(); if (scheduleInfo->allDay()) { + qCDebug(ClientLogger) << "Schedule is all day event"; m_alldaylist->setSelectSearchSchedule(scheduleInfo); } else { + qCDebug(ClientLogger) << "Schedule is not all day event"; m_graphicsView->setSelectSearchSchedule(scheduleInfo); } } void CScheduleView::updateHeight() { + qCDebug(ClientLogger) << "Updating height"; m_graphicsView->updateHeight(); m_alldaylist->updateHeight(); } bool CScheduleView::IsDragging() { - return (m_graphicsView->getDragStatus() != 4) || (m_alldaylist->getDragStatus() != 4); + bool isDragging = (m_graphicsView->getDragStatus() != 4) || (m_alldaylist->getDragStatus() != 4); + qCDebug(ClientLogger) << "Checking drag status:" << isDragging; + return isDragging; } void CScheduleView::setCurrentDate(const QDateTime ¤tDate) { + qCDebug(ClientLogger) << "Setting current date:" << currentDate; m_graphicsView->setCurrentDate(currentDate); } @@ -144,6 +163,7 @@ void CScheduleView::setCurrentDate(const QDateTime ¤tDate) */ void CScheduleView::setShowScheduleInfo(const QMap &scheduleInfo) { + qCDebug(ClientLogger) << "Setting show schedule info with" << scheduleInfo.size() << "dates"; m_showSchedule = scheduleInfo; updateSchedule(); } @@ -154,23 +174,27 @@ void CScheduleView::setShowScheduleInfo(const QMap &sche */ void CScheduleView::setTimeFormat(QString timeformat) { + qCDebug(ClientLogger) << "Setting time format:" << timeformat; m_timeFormat = timeformat; m_ScheduleRemindWidget->setTimeFormat(timeformat); } void CScheduleView::setDate(QDate date) { + qCDebug(ClientLogger) << "Setting date:" << date; m_currteDate = date; updateAllday(); } void CScheduleView::slotupdateSchedule() { + qCDebug(ClientLogger) << "Slot update schedule called"; updateSchedule(); } void CScheduleView::slotPosHours(QVector vPos, QVector vHours, int currentTimeType) { + qCDebug(ClientLogger) << "Setting position hours, time type:" << currentTimeType; m_vHours = vHours; m_vPos = vPos; m_currentTimeType = currentTimeType; @@ -179,6 +203,7 @@ void CScheduleView::slotPosHours(QVector vPos, QVector vHours, int cur void CScheduleView::paintEvent(QPaintEvent *event) { + // qCDebug(ClientLogger) << "Paint event triggered"; DFrame::paintEvent(event); QPainter painter(this); font.setWeight(QFont::Normal); @@ -188,10 +213,12 @@ void CScheduleView::paintEvent(QPaintEvent *event) QLocale locale; if (locale.language() == QLocale::Chinese) { + // qDebug() << "Chinese"; QRect tinrect((m_leftMargin - hourTextWidth) / 2 - 5, m_topMargin - 8 + m_vPos[m_vPos.count() - 1], hourTextWidth, hourTextHeight); if (m_currentTimeType == 0) { + // qDebug() << "Chinese current time type 0"; painter.save(); painter.setFont(font); painter.setPen(m_timeColor); @@ -209,6 +236,7 @@ void CScheduleView::paintEvent(QPaintEvent *event) } painter.restore(); } else { + // qDebug() << "Chinese current time type 1"; painter.save(); painter.setFont(font); painter.setPen(m_timeColor); @@ -233,6 +261,7 @@ void CScheduleView::paintEvent(QPaintEvent *event) painter.restore(); if (m_viewPos == ScheduleViewPos::DayPos && m_beginDate == QDate::currentDate()) { + // qDebug() << "Chinese current time type 1 draw current time"; painter.save(); painter.setFont(font); painter.setPen(m_currenttimecolor); @@ -245,6 +274,7 @@ void CScheduleView::paintEvent(QPaintEvent *event) } } } else { + // qDebug() << "English"; if (m_currentTimeType == 0) { painter.save(); painter.setFont(font); @@ -264,6 +294,7 @@ void CScheduleView::paintEvent(QPaintEvent *event) } painter.restore(); } else { + // qDebug() << "English current time type 1"; painter.save(); painter.setFont(font); painter.setPen(m_timeColor); @@ -327,6 +358,7 @@ void CScheduleView::paintEvent(QPaintEvent *event) painter.drawRect(QRectF(0, point_y, this->width() - m_rightMargin - 2, 1)); painter.restore(); if (m_viewPos == ScheduleViewPos::WeekPos) { + // qDebug() << "WeekPos"; //如果为周视图绘制右侧背景色(否则会有一个竖线的白色背景,不协调) painter.setPen(Qt::NoPen); painter.setBrush(m_outerBorderColor); @@ -339,13 +371,16 @@ void CScheduleView::paintEvent(QPaintEvent *event) path.lineTo(0, 0); painter.fillPath(path, palette().color(backgroundRole())); } + // qDebug() << "Paint event end"; } void CScheduleView::resizeEvent(QResizeEvent *event) { + // qCDebug(ClientLogger) << "Resize event triggered, new size:" << width() << "x" << height(); if (m_viewPos == ScheduleViewPos::WeekPos) { m_sMaxNum = ((width() - m_leftMargin) / 7) / 27; if (m_sMaxNum < 4) { + // qCDebug(ClientLogger) << "Adjusting m_sMaxNum to minimum value 4"; m_sMaxNum = 4; } } @@ -362,6 +397,7 @@ void CScheduleView::resizeEvent(QResizeEvent *event) void CScheduleView::wheelEvent(QWheelEvent *e) { + // qCDebug(ClientLogger) << "Wheel event, delta x:" << e->angleDelta().x(); if (e->angleDelta().x() != 0) { emit signalAngleDelta(e->angleDelta().x()); } @@ -369,27 +405,35 @@ void CScheduleView::wheelEvent(QWheelEvent *e) bool CScheduleView::event(QEvent *e) { + // qDebug() << "Event"; if (m_touchGesture.event(e)) { + // qCDebug(ClientLogger) << "Touch gesture event detected"; //获取触摸状态 switch (m_touchGesture.getTouchState()) { case touchGestureOperation::T_SLIDE: { + qCDebug(ClientLogger) << "Touch slide state detected"; //在滑动状态如果可以更新数据则切换月份 if (m_touchGesture.isUpdate()) { + qCDebug(ClientLogger) << "Touch gesture update is true"; m_touchGesture.setUpdate(false); switch (m_touchGesture.getMovingDir()) { case touchGestureOperation::T_LEFT: + qCDebug(ClientLogger) << "Touch moving left"; emit signalAngleDelta(-1); break; case touchGestureOperation::T_RIGHT: + qCDebug(ClientLogger) << "Touch moving right"; emit signalAngleDelta(1); break; default: + qCDebug(ClientLogger) << "Touch moving in other direction"; break; } } break; } default: + // qCDebug(ClientLogger) << "Other touch state detected"; break; } return true; @@ -400,6 +444,7 @@ bool CScheduleView::event(QEvent *e) void CScheduleView::initUI() { + qCDebug(ClientLogger) << "Initializing UI"; m_layout = new QVBoxLayout; m_layout->setSpacing(0); m_layout->setContentsMargins(0, 0, 0, 0); @@ -408,6 +453,7 @@ void CScheduleView::initUI() m_layout->addSpacing(1); m_graphicsView = new CGraphicsView(this, m_viewPos); const int miniHeight = m_viewPos == ScheduleViewPos::WeekPos ? 300 : 380; + qCDebug(ClientLogger) << "Setting minimum height:" << miniHeight; m_graphicsView->setMinimumHeight(miniHeight); connect(m_graphicsView, SIGNAL(signalsPosHours(QVector, QVector, int)), this, SLOT(slotPosHours(QVector, QVector, int))); @@ -422,6 +468,7 @@ void CScheduleView::initUI() void CScheduleView::initConnection() { + qCDebug(ClientLogger) << "Initializing connections"; connect(m_graphicsView, &CGraphicsView::signalsUpdateSchedule, this, &CScheduleView::slotupdateSchedule); connect(m_alldaylist, &CAllDayEventWeekView::signalsUpdateSchedule, this, @@ -463,6 +510,7 @@ void CScheduleView::initConnection() */ void CScheduleView::slotDeleteitem() { + qCDebug(ClientLogger) << "Delete item slot called"; //"delete"快捷键删除日程,因为只有一个点击选中日程所以全天或非全天只需要有一个删除就可以了 m_graphicsView->slotDeleteItem(); //因添加了对焦点选中item的快捷删除,添加对全天选中日程的删除 @@ -471,14 +519,19 @@ void CScheduleView::slotDeleteitem() void CScheduleView::slotCurrentScheduleDate(QDate date) { - if (m_viewPos == ScheduleViewPos::DayPos) + qCDebug(ClientLogger) << "Current schedule date slot called with date:" << date; + if (m_viewPos == ScheduleViewPos::DayPos) { + qCDebug(ClientLogger) << "In day position, returning"; return; + } emit signalsCurrentScheduleDate(date); } void CScheduleView::slotScheduleShow(const bool isShow, const DSchedule::Ptr &out) { + // qCDebug(ClientLogger) << "Schedule show slot called, isShow:" << isShow; if (isShow) { + qCDebug(ClientLogger) << "Showing schedule with ID:" << out->uid(); QVariant variant; CalendarGlobalEnv::getGlobalEnv()->getValueByKey(DDECalendar::CursorPointKey, variant); QPoint pos22 = variant.value(); @@ -496,25 +549,30 @@ void CScheduleView::slotScheduleShow(const bool isShow, const DSchedule::Ptr &ou m_ScheduleRemindWidget->setData(out, gdColor); if ((pos22.x() + m_ScheduleRemindWidget->width() + 15) > screenGeometry.width()) { + qCDebug(ClientLogger) << "Positioning widget to the right"; m_ScheduleRemindWidget->setDirection(DArrowRectangle::ArrowRight); m_ScheduleRemindWidget->show(pos22.x() - 15, pos22.y()); } else { + qCDebug(ClientLogger) << "Positioning widget to the left"; m_ScheduleRemindWidget->setDirection(DArrowRectangle::ArrowLeft); m_ScheduleRemindWidget->show(pos22.x() + 15, pos22.y()); } } else { + // qCDebug(ClientLogger) << "Hiding schedule widget"; m_ScheduleRemindWidget->hide(); } } void CScheduleView::slotUpdatePaint(const int topM) { + qCDebug(ClientLogger) << "Update paint slot called with topMargin:" << topM; m_topMargin = topM; update(); } void CScheduleView::slotUpdateScene() { + qCDebug(ClientLogger) << "Update scene slot called"; m_graphicsView->slotUpdateScene(); m_alldaylist->slotUpdateScene(); } @@ -525,10 +583,13 @@ void CScheduleView::slotUpdateScene() */ void CScheduleView::slotSwitchView(const QDate &focusDate, CWeekDayGraphicsview::ViewType viewtype, bool setItemFocus) { + qCDebug(ClientLogger) << "Switch view slot called with date:" << focusDate << "viewtype:" << viewtype << "setItemFocus:" << setItemFocus; if (viewtype == CWeekDayGraphicsview::ALLDayView) { + qCDebug(ClientLogger) << "Switching to all day view"; m_alldaylist->setCurrentFocusItem(focusDate, setItemFocus); m_alldaylist->setFocus(Qt::TabFocusReason); } else { + qCDebug(ClientLogger) << "Switching to regular view"; m_graphicsView->setCurrentFocusItem(focusDate, setItemFocus); m_graphicsView->setFocus(Qt::TabFocusReason); } @@ -539,6 +600,7 @@ void CScheduleView::slotSwitchView(const QDate &focusDate, CWeekDayGraphicsview: */ void CScheduleView::updateSchedule() { + qCDebug(ClientLogger) << "Updating schedule"; //获取一个月的日程信息 m_graphicsView->clearSchedule(); DSchedule::List allInfo; @@ -550,17 +612,21 @@ void CScheduleView::updateSchedule() if (_iterator.value().at(i)->allDay()) { //过滤 if (!allInfo.contains(_iterator.value().at(i))) { + // qCDebug(ClientLogger) << "Adding all-day schedule with ID:" << _iterator.value().at(i)->uid(); allInfo.append(_iterator.value().at(i)); } } else { //过滤 if (!nonAllInfo.contains(_iterator.value().at(i))) { + // qCDebug(ClientLogger) << "Adding non-all-day schedule with ID:" << _iterator.value().at(i)->uid(); nonAllInfo.append(_iterator.value().at(i)); } } } } + qCDebug(ClientLogger) << "Setting all-day info with" << allInfo.size() << "schedules"; m_alldaylist->setInfo(allInfo); + qCDebug(ClientLogger) << "Setting non-all-day info with" << nonAllInfo.size() << "schedules"; m_graphicsView->setInfo(nonAllInfo); updateAllday(); m_graphicsView->updateInfo(); @@ -570,6 +636,7 @@ void CScheduleView::updateSchedule() void CScheduleView::updateAllday() { + qCDebug(ClientLogger) << "Updating all day view"; m_alldaylist->updateInfo(); update(); m_graphicsView->resize(m_graphicsView->width(), this->height() - m_alldaylist->height()); @@ -577,6 +644,7 @@ void CScheduleView::updateAllday() int CScheduleView::scheduleViewHeight() { + qCDebug(ClientLogger) << "Calculating schedule view height"; qreal mHeight = 0; if (m_viewPos == ScheduleViewPos::DayPos) { @@ -588,5 +656,6 @@ int CScheduleView::scheduleViewHeight() mHeight = mHeight < 500 ? 1035 : mHeight; int m_minTime = qRound((20.0 / mHeight) * 86400); m_graphicsView->setMinTime(m_minTime); + qCDebug(ClientLogger) << "Calculated height:" << qRound(mHeight) << "minTime:" << m_minTime; return qRound(mHeight); } diff --git a/calendar-client/src/customWidget/timeedit.cpp b/calendar-client/src/customWidget/timeedit.cpp index ff9d9b0ee..169621884 100644 --- a/calendar-client/src/customWidget/timeedit.cpp +++ b/calendar-client/src/customWidget/timeedit.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "timeedit.h" +#include "commondef.h" #include #include @@ -21,22 +22,26 @@ CTimeEdit::CTimeEdit(QWidget *parent) , m_hasFocus(false) , m_miniTime(QTime(0, 0, 0)) { + qCDebug(ClientLogger) << "Creating CTimeEdit"; initUI(); initConnection(); } CTimeEdit::~CTimeEdit() { + qCDebug(ClientLogger) << "Destroying CTimeEdit"; delete m_timeEdit; } void CTimeEdit::setMineTime(const QTime &mineTime) { + qCDebug(ClientLogger) << "Setting minimum time:" << mineTime.toString(); m_miniTime = mineTime; } void CTimeEdit::setTime(const QTime &time) { + qCDebug(ClientLogger) << "Setting time:" << time.toString(); m_time = time; setSelectItem(m_time); m_timeEdit->getLineEdit()->setText(time.toString(m_timeFormat)); @@ -48,14 +53,17 @@ QTime CTimeEdit::getTime() QString timetext = m_timeEdit->getLineEdit()->displayText(); //将text转换为时间 m_time = QTime::fromString(timetext, m_timeFormat); + qCDebug(ClientLogger) << "Getting time:" << m_time.toString(); return m_time; } void CTimeEdit::updateListItem(bool isShowTimeInterval) { + qCDebug(ClientLogger) << "Updating list items, show time interval:" << isShowTimeInterval; m_isShowTimeInterval = isShowTimeInterval; QTime topTimer(m_miniTime); if (!m_isShowTimeInterval) { + qCDebug(ClientLogger) << "Time interval not shown, setting top timer"; // 根据开始时间的分钟数设置结束时间下拉列表的分钟数,当前默认为0,故先注释 // int m = m_miniTime.minute() >= 30 ? m_miniTime.minute() - 30 : m_miniTime.minute(); int m = 0; @@ -81,16 +89,20 @@ void CTimeEdit::updateListItem(bool isShowTimeInterval) QString showStr = userData + timeIntervalStr; addItem(showStr, userData); } + qCDebug(ClientLogger) << "Added" << count() << "time items to list"; } void CTimeEdit::setTimeFormat(int value) { + qCDebug(ClientLogger) << "Setting time format value:" << value; //获取edit的当前时间 QTime editCurrentTime = getTime(); //根据value值,设置时间显示格式 if (value) { + qCDebug(ClientLogger) << "Setting 24-hour format"; m_timeFormat = "hh:mm"; } else { + qCDebug(ClientLogger) << "Setting 12-hour format"; m_timeFormat = "h:mm"; } //先更新列表信息,更新列表信息后再设置编辑框显示时间 @@ -102,12 +114,14 @@ void CTimeEdit::setTimeFormat(int value) void CTimeEdit::slotFocusDraw(bool showFocus) { + qCDebug(ClientLogger) << "Focus draw slot called, show focus:" << showFocus; m_hasFocus = showFocus; update(); } void CTimeEdit::setSelectItem(const QTime &time) { + qCDebug(ClientLogger) << "Setting select item for time:" << time.toString(); //若有则设置选中,若没有则取消选中设置定位到相近值附近 int similarNumber = -1; int diff = 24 * 60 * 60 * 1000; @@ -124,8 +138,10 @@ void CTimeEdit::setSelectItem(const QTime &time) } } if (diff == 0) { + qCDebug(ClientLogger) << "Exact time match found at index:" << similarNumber; setCurrentIndex(similarNumber); } else { + qCDebug(ClientLogger) << "No exact match, closest time at index:" << similarNumber << "with diff:" << diff; setCurrentIndex(-1); } scrollPosition = this->model()->index(similarNumber, 0); @@ -133,28 +149,34 @@ void CTimeEdit::setSelectItem(const QTime &time) void CTimeEdit::slotSetPlainText(const QString &arg) { + qCDebug(ClientLogger) << "Setting plain text:" << arg; QString userData = currentData().toString(); if (userData.isEmpty()) { + qCDebug(ClientLogger) << "User data is empty, using arg text"; this->lineEdit()->setText(arg); } else { + qCDebug(ClientLogger) << "Using user data text:" << userData; this->lineEdit()->setText(userData); } } void CTimeEdit::slotActivated(const QString &arg) { + qCDebug(ClientLogger) << "Activated slot called with:" << arg; slotSetPlainText(arg); emit signaleditingFinished(); } void CTimeEdit::slotEditingFinished() { + qCDebug(ClientLogger) << "Editing finished slot called"; setTime(m_timeEdit->time()); emit signaleditingFinished(); } void CTimeEdit::initUI() { + qCDebug(ClientLogger) << "Initializing UI"; //关闭自动补全 this->setCompleter(nullptr); //设置edit的宽度 @@ -168,6 +190,7 @@ void CTimeEdit::initUI() void CTimeEdit::initConnection() { + qCDebug(ClientLogger) << "Initializing connections"; connect(CalendarManager::getInstance(), &CalendarManager::signalTimeFormatChanged, this, &CTimeEdit::setTimeFormat); connect(m_timeEdit, &CCustomTimeEdit::signalUpdateFocus, this, &CTimeEdit::slotFocusDraw); @@ -179,10 +202,12 @@ void CTimeEdit::initConnection() void CTimeEdit::showPopup() { + qCDebug(ClientLogger) << "Showing popup"; DComboBox::showPopup(); //获取下拉视图容器 QFrame *viewContainer = this->findChild(); if (viewContainer) { + qCDebug(ClientLogger) << "View container found, configuring"; //移动前先隐藏 viewContainer->hide(); //如果显示视图容器则设置高度 @@ -206,21 +231,27 @@ void CTimeEdit::showPopup() viewContainer->move(showPoint.x(), showPoint.y()); //显示 viewContainer->show(); + qCDebug(ClientLogger) << "View container positioned at:" << showPoint << "with size:" << viewContainer->size(); + } else { + qCDebug(ClientLogger) << "View container not found"; } //因改变了容器的高度,所以需要重新定位当前位置 if (this->view()->currentIndex() == scrollPosition) { + qCDebug(ClientLogger) << "Scrolling to current position at center"; this->view()->scrollTo(scrollPosition, QAbstractItemView::PositionAtCenter); } else { + qCDebug(ClientLogger) << "Scrolling to position at top"; this->view()->scrollTo(scrollPosition, QAbstractItemView::PositionAtTop); } - } void CTimeEdit::focusInEvent(QFocusEvent *event) { + // qCDebug(ClientLogger) << "Focus in event, reason:" << event->reason(); DComboBox::focusInEvent(event); // 如果为tab焦点进入则选中时间 if (event->reason() == Qt::TabFocusReason) { + // qCDebug(ClientLogger) << "Tab focus, setting focus to line edit"; lineEdit()->setFocus(Qt::TabFocusReason); } } @@ -230,6 +261,7 @@ void CTimeEdit::paintEvent(QPaintEvent *e) DComboBox::paintEvent(e); //如果有焦点则设置焦点显示效果 if (m_hasFocus) { + // qCDebug(ClientLogger) << "Painting focus rectangle"; QPainter painter(this); QStyleOptionFocusRect option; option.initFrom(this); @@ -240,6 +272,7 @@ void CTimeEdit::paintEvent(QPaintEvent *e) void CTimeEdit::resizeEvent(QResizeEvent *e) { + // qCDebug(ClientLogger) << "Resize event, new size:" << size(); DComboBox::resizeEvent(e); m_timeEdit->setFixedHeight(this->height()); } diff --git a/calendar-client/src/customWidget/todaybutton.cpp b/calendar-client/src/customWidget/todaybutton.cpp index 25218f627..d0887176b 100644 --- a/calendar-client/src/customWidget/todaybutton.cpp +++ b/calendar-client/src/customWidget/todaybutton.cpp @@ -4,6 +4,7 @@ #include "todaybutton.h" #include "constants.h" +#include "commondef.h" #include @@ -14,16 +15,15 @@ DGUI_USE_NAMESPACE CTodayButton::CTodayButton(QWidget *parent) : DPushButton(parent) { + qCDebug(ClientLogger) << "Creating CTodayButton"; } - - - - void CTodayButton::keyPressEvent(QKeyEvent *event) { + // qCDebug(ClientLogger) << "Key press event, key:" << event->key(); //添加回车点击效果处理 if (event->key() == Qt::Key_Return) { + qCDebug(ClientLogger) << "Return key pressed, emitting click"; click(); } DPushButton::keyPressEvent(event); diff --git a/calendar-client/src/dataManage/accountitem.cpp b/calendar-client/src/dataManage/accountitem.cpp index 14bc942cc..dc48eab67 100644 --- a/calendar-client/src/dataManage/accountitem.cpp +++ b/calendar-client/src/dataManage/accountitem.cpp @@ -11,11 +11,13 @@ AccountItem::AccountItem(const DAccount::Ptr &account, QObject *parent) , m_account(account) , m_dbusRequest(new DbusAccountRequest(account->dbusPath(), account->dbusInterface(), this)) { + qCDebug(ClientLogger) << "Creating AccountItem for account:" << account->accountName() << "type:" << account->accountType(); initConnect(); } void AccountItem::initConnect() { + qCDebug(ClientLogger) << "Initializing connections for account:" << m_account->accountName(); connect(m_dbusRequest, &DbusAccountRequest::signalGetAccountInfoFinish, this, &AccountItem::slotGetAccountInfoFinish); connect(m_dbusRequest, &DbusAccountRequest::signalGetScheduleTypeListFinish, this, &AccountItem::slotGetScheduleTypeListFinish); connect(m_dbusRequest, &DbusAccountRequest::signalGetScheduleListFinish, this, &AccountItem::slotGetScheduleListFinish); @@ -36,12 +38,25 @@ void AccountItem::initConnect() */ QString AccountItem::getSyncMsg(DAccount::AccountSyncState code) { + qCDebug(ClientLogger) << "Getting sync message for state code:" << code; QString msg = ""; switch (code) { - case DAccount::Sync_Normal: msg = tr("Sync successful"); break; - case DAccount::Sync_NetworkAnomaly: msg = tr("Network error"); break; - case DAccount::Sync_ServerException: msg = tr("Server exception"); break; - case DAccount::Sync_StorageFull: msg = tr("Storage full"); break; + case DAccount::Sync_Normal: + qCDebug(ClientLogger) << "Sync state: Normal"; + msg = tr("Sync successful"); + break; + case DAccount::Sync_NetworkAnomaly: + qCDebug(ClientLogger) << "Sync state: Network anomaly"; + msg = tr("Network error"); + break; + case DAccount::Sync_ServerException: + qCDebug(ClientLogger) << "Sync state: Server exception"; + msg = tr("Server exception"); + break; + case DAccount::Sync_StorageFull: + qCDebug(ClientLogger) << "Sync state: Storage full"; + msg = tr("Storage full"); + break; } return msg; } @@ -71,11 +86,13 @@ DAccount::Ptr AccountItem::getAccount() //获取日程 QMap AccountItem::getScheduleMap() { + // qCDebug(ClientLogger) << "Getting schedule map with" << m_scheduleMap.size() << "dates for account:" << m_account->accountName(); return m_scheduleMap; } QMap AccountItem::getSearchScheduleMap() { + // qCDebug(ClientLogger) << "Getting search schedule map with" << m_searchedScheduleMap.size() << "dates for account:" << m_account->accountName(); return m_searchedScheduleMap; } @@ -85,38 +102,47 @@ QMap AccountItem::getSearchScheduleMap() */ DScheduleType::List AccountItem::getScheduleTypeList() { + qCDebug(ClientLogger) << "Getting schedule type list for account:" << m_account->accountName(); DScheduleType::List list; for (DScheduleType::Ptr p : m_scheduleTypeList) { if (p->privilege() != DScheduleType::None) { list.push_back(p); } } + qCDebug(ClientLogger) << "Returning" << list.size() << "schedule types"; return list; } //根据类型ID获取日程类型 DScheduleType::Ptr AccountItem::getScheduleTypeByID(const QString &typeID) { + qCDebug(ClientLogger) << "Getting schedule type by ID:" << typeID; for (DScheduleType::Ptr p : m_scheduleTypeList) { if (p->typeID() == typeID) { + qCDebug(ClientLogger) << "Found schedule type:" << p->displayName(); return p; } } + qCDebug(ClientLogger) << "Schedule type not found for ID:" << typeID; return nullptr; } DScheduleType::Ptr AccountItem::getScheduleTypeByName(const QString &typeName) { + qCDebug(ClientLogger) << "Getting schedule type by name:" << typeName; for (DScheduleType::Ptr p : m_scheduleTypeList) { if (p->typeName() == typeName || p->displayName() == typeName) { + qCDebug(ClientLogger) << "Found schedule type with ID:" << p->typeID(); return p; } } + qCDebug(ClientLogger) << "Schedule type not found for name:" << typeName; return nullptr; } DTypeColor::List AccountItem::getColorTypeList() { + // qCDebug(ClientLogger) << "Getting color type list with" << m_typeColorList.size() << "colors"; return m_typeColorList; } @@ -127,12 +153,16 @@ DTypeColor::List AccountItem::getColorTypeList() */ bool AccountItem::isCanSyncShedule() { + qCDebug(ClientLogger) << "Checking if can sync schedule for account:" << m_account->accountName(); if (getAccount()->accountType() != DAccount::Account_UnionID) { + qCDebug(ClientLogger) << "Not a UnionID account, can sync schedule"; return true; } DOANetWorkDBus netManger; - return getAccount()->accountState().testFlag(DAccount::Account_Calendar) + bool canSync = getAccount()->accountState().testFlag(DAccount::Account_Calendar) && getAccount()->accountState().testFlag(DAccount::Account_Open) && netManger.getNetWorkState() == DOANetWorkDBus::Active; + qCDebug(ClientLogger) << "Can sync schedule:" << canSync; + return canSync; } /** @@ -142,22 +172,30 @@ bool AccountItem::isCanSyncShedule() */ bool AccountItem::isCanSyncSetting() { + qCDebug(ClientLogger) << "Checking if can sync settings for account:" << m_account->accountName(); if (!getAccount().isNull() && getAccount()->accountType() != DAccount::Account_UnionID) { + qCDebug(ClientLogger) << "Not a UnionID account, can sync settings"; return true; } DOANetWorkDBus netManger; - return getAccount()->accountState().testFlag(DAccount::Account_Setting) + bool canSync = getAccount()->accountState().testFlag(DAccount::Account_Setting) && getAccount()->accountState().testFlag(DAccount::Account_Open) && netManger.getNetWorkState() == DOANetWorkDBus::Active; + qCDebug(ClientLogger) << "Can sync settings:" << canSync; + return canSync; } bool AccountItem::isEnableForUosAccount() { + qCDebug(ClientLogger) << "Checking if account is enabled for UOS account:" << m_account->accountName(); if (getAccount()->accountType() != DAccount::Account_UnionID) { + qCDebug(ClientLogger) << "Not a UnionID account, not enabled for UOS"; return false; } DOANetWorkDBus netManger; - return getAccount()->accountState().testFlag(DAccount::Account_Open) && netManger.getNetWorkState() == DOANetWorkDBus::Active; + bool isEnabled = getAccount()->accountState().testFlag(DAccount::Account_Open) && netManger.getNetWorkState() == DOANetWorkDBus::Active; + qCDebug(ClientLogger) << "Is enabled for UOS account:" << isEnabled; + return isEnabled; } /** @@ -167,12 +205,14 @@ bool AccountItem::isEnableForUosAccount() */ void AccountItem::setAccountExpandStatus(bool expandStatus) { + qCDebug(ClientLogger) << "Setting account expand status to:" << expandStatus << "for account:" << m_account->accountName(); m_account->setIsExpandDisplay(expandStatus); m_dbusRequest->setAccountExpandStatus(expandStatus); } void AccountItem::setAccountState(DAccount::AccountStates state) { + qCDebug(ClientLogger) << "Setting account state to:" << state << "for account:" << m_account->accountName(); m_account->setAccountState(state); m_dbusRequest->setAccountState(state); emit signalAccountStateChange(); @@ -180,6 +220,7 @@ void AccountItem::setAccountState(DAccount::AccountStates state) void AccountItem::setSyncFreq(DAccount::SyncFreqType freq) { + qCDebug(ClientLogger) << "Setting sync frequency to:" << freq << "for account:" << m_account->accountName(); m_account->setSyncFreq(freq); QString syncFreq = DAccount::syncFreqToJsonString(m_account); m_dbusRequest->setSyncFreq(syncFreq); @@ -187,18 +228,24 @@ void AccountItem::setSyncFreq(DAccount::SyncFreqType freq) DAccount::AccountStates AccountItem::getAccountState() { - return m_dbusRequest->getAccountState(); + DAccount::AccountStates state = m_dbusRequest->getAccountState(); + // qCDebug(ClientLogger) << "Getting account state:" << state << "for account:" << m_account->accountName(); + return state; } bool AccountItem::getSyncState() { - return m_dbusRequest->getSyncState(); + bool syncState = m_dbusRequest->getSyncState(); + // qCDebug(ClientLogger) << "Getting sync state:" << syncState << "for account:" << m_account->accountName(); + return syncState; } DAccount::SyncFreqType AccountItem::getSyncFreq() { + qCDebug(ClientLogger) << "Getting sync frequency for account:" << m_account->accountName(); QString syncFreq = m_dbusRequest->getSyncFreq(); DAccount::syncFreqFromJsonString(m_account, syncFreq); + qCDebug(ClientLogger) << "Sync frequency:" << m_account->syncFreq(); return m_account->syncFreq(); } @@ -263,7 +310,10 @@ void AccountItem::deleteScheduleTypeByID(const QString &typeID, CallbackFunc cal */ bool AccountItem::scheduleTypeIsUsed(const QString &typeID) { - return m_dbusRequest->scheduleTypeByUsed(typeID); + qCDebug(ClientLogger) << "Checking if schedule type is used, ID:" << typeID; + bool isUsed = m_dbusRequest->scheduleTypeByUsed(typeID); + qCDebug(ClientLogger) << "Schedule type is used:" << isUsed; + return isUsed; } /** @@ -294,6 +344,7 @@ void AccountItem::updateSchedule(const DSchedule::Ptr &scheduleInfo, CallbackFun DSchedule::Ptr AccountItem::getScheduleByScheduleID(const QString &scheduleID) { + // qCDebug(ClientLogger) << "Getting schedule by ID:" << scheduleID; return m_dbusRequest->getScheduleByScheduleID(scheduleID); } @@ -367,6 +418,7 @@ void AccountItem::querySchedulesWithParameter(const DScheduleQueryPar::Ptr ¶ QString AccountItem::querySchedulesByExternal(const QString &key, const QDateTime &start, const QDateTime &end) { + qCDebug(ClientLogger) << "Querying schedules by external with key:" << key << "from" << start.toString() << "to" << end.toString() << "for account:" << m_account->accountName(); DScheduleQueryPar::Ptr ptr; ptr.reset(new DScheduleQueryPar); ptr->setKey(key); @@ -379,6 +431,7 @@ QString AccountItem::querySchedulesByExternal(const QString &key, const QDateTim bool AccountItem::querySchedulesByExternal(const QString &key, const QDateTime &start, const QDateTime &end, QMap &out) { + qCDebug(ClientLogger) << "Querying schedules by external with key:" << key << "from" << start.toString() << "to" << end.toString() << "for account:" << m_account->accountName(); DScheduleQueryPar::Ptr ptr; ptr.reset(new DScheduleQueryPar); ptr->setKey(key); @@ -387,8 +440,10 @@ bool AccountItem::querySchedulesByExternal(const QString &key, const QDateTime & QString json; if (m_dbusRequest->querySchedulesByExternal(ptr, json)) { out = DSchedule::fromMapString(json); + qCDebug(ClientLogger) << "Successfully queried external schedules, got" << out.size() << "dates"; return true; } + qCDebug(ClientLogger) << "Failed to query external schedules"; return false; } @@ -423,6 +478,7 @@ void AccountItem::slotGetScheduleTypeListFinish(DScheduleType::List scheduleType */ void AccountItem::slotGetScheduleListFinish(QMap map) { + qCDebug(ClientLogger) << "Received schedule list with" << map.size() << "dates for account:" << m_account->accountName(); m_scheduleMap = map; emit signalScheduleUpdate(); } @@ -434,6 +490,7 @@ void AccountItem::slotGetScheduleListFinish(QMap map) */ void AccountItem::slotSearchScheduleListFinish(QMap map) { + qCDebug(ClientLogger) << "Received search schedule list with" << map.size() << "dates for account:" << m_account->accountName(); m_searchedScheduleMap = map; emit signalSearchScheduleUpdate(); } @@ -444,6 +501,7 @@ void AccountItem::slotSearchScheduleListFinish(QMap map) */ void AccountItem::slotGetSysColorsFinish(DTypeColor::List typeColorList) { + qCDebug(ClientLogger) << "Received" << typeColorList.size() << "system colors for account:" << m_account->accountName(); m_typeColorList = typeColorList; } @@ -456,13 +514,16 @@ void AccountItem::slotAccountStateChange(DAccount::AccountStates state) void AccountItem::slotSyncStateChange(DAccount::AccountSyncState state) { + qCDebug(ClientLogger) << "Sync state changed to:" << state << "for account:" << m_account->accountName(); getAccount()->setSyncState(state); emit signalSyncStateChange(state); } QString AccountItem::getDtLastUpdate() { - return m_dbusRequest->getDtLastUpdate(); + QString lastUpdate = m_dbusRequest->getDtLastUpdate(); + // qCDebug(ClientLogger) << "Getting last update time:" << lastUpdate << "for account:" << m_account->accountName(); + return lastUpdate; } void AccountItem::slotSearchUpdata() diff --git a/calendar-client/src/dataManage/accountmanager.cpp b/calendar-client/src/dataManage/accountmanager.cpp index e6b99f271..042a55701 100644 --- a/calendar-client/src/dataManage/accountmanager.cpp +++ b/calendar-client/src/dataManage/accountmanager.cpp @@ -3,12 +3,14 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "accountmanager.h" +#include "commondef.h" AccountManager *AccountManager::m_accountManager = nullptr; AccountManager::AccountManager(QObject *parent) : QObject(parent) , m_dbusRequest(new DbusAccountManagerRequest(this)) { + qCDebug(ClientLogger) << "Creating AccountManager"; initConnect(); m_dbusRequest->clientIsShow(true); m_isSupportUid = m_dbusRequest->getIsSupportUid(); @@ -16,22 +18,26 @@ AccountManager::AccountManager(QObject *parent) void AccountManager::initConnect() { + qCDebug(ClientLogger) << "Initializing connections"; connect(m_dbusRequest, &DbusAccountManagerRequest::signalGetAccountListFinish, this, &AccountManager::slotGetAccountListFinish); connect(m_dbusRequest, &DbusAccountManagerRequest::signalGetGeneralSettingsFinish, this, &AccountManager::slotGetGeneralSettingsFinish); } bool AccountManager::getIsSupportUid() const { + qCDebug(ClientLogger) << "Getting isSupportUid:" << m_isSupportUid; return m_isSupportUid; } AccountManager::~AccountManager() { + qCDebug(ClientLogger) << "Destroying AccountManager"; m_dbusRequest->clientIsShow(false); } AccountManager *AccountManager::getInstance() { + qCDebug(ClientLogger) << "Getting AccountManager instance"; static AccountManager m_accountManager; return &m_accountManager; } @@ -43,14 +49,18 @@ AccountManager *AccountManager::getInstance() */ QList AccountManager::getAccountList() { + qCDebug(ClientLogger) << "Getting account list"; QList> accountList; if (nullptr != m_localAccountItem.data()) { + qCDebug(ClientLogger) << "Adding local account to list"; accountList.append(m_localAccountItem); } if (nullptr != m_unionAccountItem.data()) { + qCDebug(ClientLogger) << "Adding union account to list"; accountList.append(m_unionAccountItem); } + qCDebug(ClientLogger) << "Returning" << accountList.size() << "accounts"; return accountList; } @@ -61,6 +71,7 @@ QList AccountManager::getAccountList() */ AccountItem::Ptr AccountManager::getLocalAccountItem() { + // qCDebug(ClientLogger) << "Getting local account item"; return m_localAccountItem; } @@ -71,56 +82,76 @@ AccountItem::Ptr AccountManager::getLocalAccountItem() */ AccountItem::Ptr AccountManager::getUnionAccountItem() { + // qCDebug(ClientLogger) << "Getting union account item"; return m_unionAccountItem; } DScheduleType::Ptr AccountManager::getScheduleTypeByScheduleTypeId(const QString &schduleTypeId) { + qCDebug(ClientLogger) << "Getting schedule type by ID:" << schduleTypeId; DScheduleType::Ptr type = nullptr; for (AccountItem::Ptr p : gAccountManager->getAccountList()) { type = p->getScheduleTypeByID(schduleTypeId); if (nullptr != type) { + qCDebug(ClientLogger) << "Found schedule type:" << type->displayName() << "in account:" << p->getAccount()->accountName(); break; } } + if (type == nullptr) { + qCDebug(ClientLogger) << "Schedule type not found for ID:" << schduleTypeId; + } return type; } AccountItem::Ptr AccountManager::getAccountItemByScheduleTypeId(const QString &schduleTypeId) { + qCDebug(ClientLogger) << "Getting account item by schedule type ID:" << schduleTypeId; DScheduleType::Ptr type = getScheduleTypeByScheduleTypeId(schduleTypeId); if (nullptr == type) { + qCDebug(ClientLogger) << "Schedule type not found for ID:" << schduleTypeId; return nullptr; } + qCDebug(ClientLogger) << "Getting account by account ID:" << type->accountID(); return getAccountItemByAccountId(type->accountID()); } AccountItem::Ptr AccountManager::getAccountItemByAccountId(const QString &accountId) { + qCDebug(ClientLogger) << "Getting account item by account ID:" << accountId; AccountItem::Ptr account = nullptr; for (AccountItem::Ptr p : gAccountManager->getAccountList()) { if (p->getAccount()->accountID() == accountId) { + qCDebug(ClientLogger) << "Found account:" << p->getAccount()->accountName(); account = p; break; } } + if (account == nullptr) { + qCDebug(ClientLogger) << "Account not found for ID:" << accountId; + } return account; } AccountItem::Ptr AccountManager::getAccountItemByAccountName(const QString &accountName) { + qCDebug(ClientLogger) << "Getting account item by account name:" << accountName; AccountItem::Ptr account = nullptr; for (AccountItem::Ptr p : gAccountManager->getAccountList()) { if (p->getAccount()->accountName() == accountName) { + qCDebug(ClientLogger) << "Found account with ID:" << p->getAccount()->accountID(); account = p; break; } } + if (account == nullptr) { + qCDebug(ClientLogger) << "Account not found for name:" << accountName; + } return account; } DCalendarGeneralSettings::Ptr AccountManager::getGeneralSettings() { + qCDebug(ClientLogger) << "Getting general settings"; return m_settings; } @@ -130,6 +161,7 @@ DCalendarGeneralSettings::Ptr AccountManager::getGeneralSettings() */ void AccountManager::resetAccount() { + qCDebug(ClientLogger) << "Resetting account information"; m_localAccountItem.clear(); m_unionAccountItem.clear(); m_dbusRequest->getAccountList(); @@ -144,6 +176,7 @@ void AccountManager::resetAccount() */ void AccountManager::downloadByAccountID(const QString &accountID, CallbackFunc callback) { + qCDebug(ClientLogger) << "Downloading data for account ID:" << accountID; emit signalSyncNum(); m_dbusRequest->setCallbackFunc(callback); m_dbusRequest->downloadByAccountID(accountID); @@ -156,18 +189,21 @@ void AccountManager::downloadByAccountID(const QString &accountID, CallbackFunc */ void AccountManager::uploadNetWorkAccountData(CallbackFunc callback) { + qCDebug(ClientLogger) << "Uploading network account data"; m_dbusRequest->setCallbackFunc(callback); m_dbusRequest->uploadNetWorkAccountData(); } void AccountManager::setFirstDayofWeek(int value) { + qCDebug(ClientLogger) << "Setting first day of week to:" << value; m_settings->setFirstDayOfWeek(static_cast(value)); m_dbusRequest->setFirstDayofWeek(value); } void AccountManager::setTimeFormatType(int value) { + qCDebug(ClientLogger) << "Setting time format type to:" << value; m_settings->setTimeShowType(static_cast(value)); m_dbusRequest->setTimeFormatType(value); } @@ -175,26 +211,32 @@ void AccountManager::setTimeFormatType(int value) // 设置一周首日来源 void AccountManager::setFirstDayofWeekSource(DCalendarGeneralSettings::GeneralSettingSource value) { + // qCDebug(ClientLogger) << "Setting first day of week source to:" << value; m_dbusRequest->setFirstDayofWeekSource(value); -}; +} // 设置时间显示格式来源 void AccountManager::setTimeFormatTypeSource(DCalendarGeneralSettings::GeneralSettingSource value) { + // qCDebug(ClientLogger) << "Setting time format type source to:" << value; m_dbusRequest->setTimeFormatTypeSource(value); -}; +} // 获取一周首日来源 DCalendarGeneralSettings::GeneralSettingSource AccountManager::getFirstDayofWeekSource() { - return m_dbusRequest->getFirstDayofWeekSource(); -}; + DCalendarGeneralSettings::GeneralSettingSource source = m_dbusRequest->getFirstDayofWeekSource(); + // qCDebug(ClientLogger) << "Getting first day of week source:" << source; + return source; +} // 获取时间显示格式来源 DCalendarGeneralSettings::GeneralSettingSource AccountManager::getTimeFormatTypeSource() { - return m_dbusRequest->getTimeFormatTypeSource(); -}; + DCalendarGeneralSettings::GeneralSettingSource source = m_dbusRequest->getTimeFormatTypeSource(); + // qCDebug(ClientLogger) << "Getting time format type source:" << source; + return source; +} /** * @brief login @@ -202,6 +244,7 @@ DCalendarGeneralSettings::GeneralSettingSource AccountManager::getTimeFormatType */ void AccountManager::login() { + qCDebug(ClientLogger) << "Logging in"; m_dbusRequest->login(); } @@ -211,6 +254,7 @@ void AccountManager::login() */ void AccountManager::loginout() { + qCDebug(ClientLogger) << "Logging out"; m_dbusRequest->logout(); } @@ -221,25 +265,32 @@ void AccountManager::loginout() */ void AccountManager::slotGetAccountListFinish(DAccount::List accountList) { + qCDebug(ClientLogger) << "Received account list with" << accountList.size() << "accounts"; bool hasUnionAccount = false; for (DAccount::Ptr account : accountList) { if (account->accountType() == DAccount::Account_Local) { + qCDebug(ClientLogger) << "Processing local account"; QString localName = tr("Local account"); if (!gAccountManager->getIsSupportUid()) { + qCDebug(ClientLogger) << "UID not supported, using 'Event types' as local name"; localName = tr("Event types"); } account->setAccountName(localName); if (!m_localAccountItem) { + qCDebug(ClientLogger) << "Creating new local account item"; m_localAccountItem.reset(new AccountItem(account, this)); } m_localAccountItem->resetAccount(); } else if (account->accountType() == DAccount::Account_UnionID) { + qCDebug(ClientLogger) << "Processing UnionID account:" << account->accountName(); hasUnionAccount = true; if (!m_unionAccountItem) { + qCDebug(ClientLogger) << "Creating new union account item"; m_unionAccountItem.reset(new AccountItem(account, this)); m_unionAccountItem->resetAccount(); } else if (m_unionAccountItem && m_unionAccountItem->getAccount()->accountID() != account->accountID()) { + qCDebug(ClientLogger) << "Union account ID changed, creating new union account item"; emit m_unionAccountItem->signalLogout(m_unionAccountItem->getAccount()->accountType()); m_unionAccountItem.reset(new AccountItem(account, this)); m_unionAccountItem->resetAccount(); @@ -247,11 +298,13 @@ void AccountManager::slotGetAccountListFinish(DAccount::List accountList) } } if (!hasUnionAccount && m_unionAccountItem) { + qCDebug(ClientLogger) << "No union account in list but union account item exists, clearing it"; emit m_unionAccountItem->signalLogout(m_unionAccountItem->getAccount()->accountType()); m_unionAccountItem.reset(nullptr); } for (AccountItem::Ptr p : getAccountList()) { + qCDebug(ClientLogger) << "Setting up connections for account:" << p->getAccount()->accountName(); connect(p.data(), &AccountItem::signalScheduleUpdate, this, &AccountManager::signalScheduleUpdate); connect(p.data(), &AccountItem::signalSearchScheduleUpdate, this, &AccountManager::signalSearchScheduleUpdate); connect(p.data(), &AccountItem::signalScheduleTypeUpdate, this, &AccountManager::signalScheduleTypeUpdate); @@ -269,6 +322,7 @@ void AccountManager::slotGetAccountListFinish(DAccount::List accountList) */ void AccountManager::slotGetGeneralSettingsFinish(DCalendarGeneralSettings::Ptr ptr) { + qCDebug(ClientLogger) << "Received general settings"; m_settings = ptr; emit signalDataInitFinished(); emit signalGeneralSettingsUpdate(); diff --git a/calendar-client/src/dataManage/calendarmanage.cpp b/calendar-client/src/dataManage/calendarmanage.cpp index 989449090..cb2b0560a 100644 --- a/calendar-client/src/dataManage/calendarmanage.cpp +++ b/calendar-client/src/dataManage/calendarmanage.cpp @@ -12,6 +12,7 @@ CalendarManager *CalendarManager::m_scheduleManager = nullptr; CalendarManager *CalendarManager::getInstance() { + qCDebug(ClientLogger) << "Getting CalendarManager instance"; CaHuangLiDayInfo::registerMetaType(); if (m_scheduleManager == nullptr) { m_scheduleManager = new CalendarManager; @@ -24,6 +25,7 @@ CalendarManager *CalendarManager::getInstance() void CalendarManager::releaseInstance() { + qCDebug(ClientLogger) << "Releasing CalendarManager instance"; if (m_scheduleManager != nullptr) { delete m_scheduleManager; m_scheduleManager = nullptr; @@ -44,16 +46,19 @@ void CalendarManager::setSelectDate(const QDate &selectDate, bool isSwitchYear) //获取选择时间 QDate CalendarManager::getSelectDate() const { + // qCDebug(ClientLogger) << "Getting select date:" << m_selectDate.toString(); return m_selectDate; } //设置当前时间 void CalendarManager::setCurrentDateTime(const QDateTime ¤tDateTime) { + // qCDebug(ClientLogger) << "Setting current date time to:" << currentDateTime.toString(); m_currentDateTime = currentDateTime; } //获取当前时间 QDateTime CalendarManager::getCurrentDate() const { + // qCDebug(ClientLogger) << "Getting current date time:" << m_currentDateTime.toString(); return m_currentDateTime; } @@ -101,29 +106,37 @@ void CalendarManager::setWeekDayFormatByID(const int &weekDayFormatID) //获取周显示格式 QString CalendarManager::getWeekDayFormat() const { + // qCDebug(ClientLogger) << "Getting week day format:" << m_weekDayFormat; return m_weekDayFormat; } //返回显示的年份,开始和结束时间 ShowDateRange CalendarManager::getShowDateRange() const { + // qCDebug(ClientLogger) << "Getting show date range for year:" << m_showDateRange.showYear + // << "from" << m_showDateRange.startDate.toString() + // << "to" << m_showDateRange.stopDate.toString(); return m_showDateRange; } //根据日期获取当前周第一天的日期 QDate CalendarManager::getFirstDayOfWeek(const QDate &date) { + qCDebug(ClientLogger) << "Calculating first day of week for date:" << date.toString(); //根据选择时间周工作日和每周第一天的周工作日得到偏移量 int _offset = date.dayOfWeek() - getFirstDayOfWeek(); //根据偏移量获取需要添加还有减去的偏移天数 const int _offsetDay = (_offset + 7) % 7; //返回这周第一天的日期 - return date.addDays(-_offsetDay); + QDate firstDay = date.addDays(-_offsetDay); + qCDebug(ClientLogger) << "First day of week is:" << firstDay.toString(); + return firstDay; } //根据日期获取该日期处于该年第多少周 int CalendarManager::getWeekNumOfYear(const QDate &date) { + qCDebug(ClientLogger) << "Calculating week number of year for date:" << date.toString(); int _weekNum {0}; //获取选择时间所在周的最后一天 const QDate _laseDateInWeekBySelectDate = getInstance()->getFirstDayOfWeek(date).addDays(6); @@ -134,6 +147,7 @@ int CalendarManager::getWeekNumOfYear(const QDate &date) //处于该年显示第多少天,0为第一天 const qint64 _dayOfShowYear = _firstShowDayOfYear.daysTo(_firstDayOfYear) + _laseDateInWeekBySelectDate.dayOfYear() - 1; _weekNum = qFloor(_dayOfShowYear / 7) + 1; + qCDebug(ClientLogger) << "Week number is:" << _weekNum; return _weekNum; } @@ -188,6 +202,7 @@ void CalendarManager::setDateFormatChanged(int value) QString CalendarManager::getTimeFormat() const { + // qCDebug(ClientLogger) << "Getting time format:" << m_timeFormat; return m_timeFormat; } @@ -202,11 +217,13 @@ void CalendarManager::setTimeShowType(int value, bool update) int CalendarManager::getTimeShowType() const { + // qCDebug(ClientLogger) << "Getting time show type:" << m_timeShowType; return m_timeShowType; } QString CalendarManager::getDateFormat() const { + // qCDebug(ClientLogger) << "Getting date format:" << m_dateFormat; return m_dateFormat; } @@ -237,6 +254,7 @@ void CalendarManager::setYearBeginAndEndDate(const int year) */ void CalendarManager::addShowWidget(CScheduleBaseWidget *showWidget) { + // qCDebug(ClientLogger) << "Adding show widget:" << showWidget; m_showWidget.append(showWidget); } @@ -246,6 +264,7 @@ void CalendarManager::addShowWidget(CScheduleBaseWidget *showWidget) */ void CalendarManager::removeShowWidget(CScheduleBaseWidget *showWidget) { + // qCDebug(ClientLogger) << "Removing show widget:" << showWidget; m_showWidget.removeOne(showWidget); } @@ -256,7 +275,9 @@ void CalendarManager::removeShowWidget(CScheduleBaseWidget *showWidget) */ CScheduleBaseWidget *CalendarManager::getShowWidget(const int index) { + qCDebug(ClientLogger) << "Getting show widget at index:" << index; if (index < 0 || index >= m_showWidget.size()) { + qCDebug(ClientLogger) << "Invalid index, returning nullptr"; return nullptr; } return m_showWidget.at(index); @@ -268,6 +289,7 @@ CScheduleBaseWidget *CalendarManager::getShowWidget(const int index) */ int CalendarManager::getShowWidgetSize() { + // qCDebug(ClientLogger) << "Getting show widget size:" << m_showWidget.size(); return m_showWidget.size(); } @@ -277,6 +299,7 @@ int CalendarManager::getShowWidgetSize() */ bool CalendarManager::getShowLunar() const { + // qCDebug(ClientLogger) << "Getting show lunar flag:" << m_showLunar; return m_showLunar; } @@ -286,6 +309,7 @@ bool CalendarManager::getShowLunar() const */ Qt::DayOfWeek CalendarManager::getFirstDayOfWeek() { + // qCDebug(ClientLogger) << "Getting first day of week:" << m_firstDayOfWeek; return Qt::DayOfWeek(m_firstDayOfWeek); } @@ -316,13 +340,14 @@ CalendarManager::CalendarManager(QObject *parent) , m_selectDate(m_currentDateTime.date()) , m_weekDayFormat("ddd") { + qCDebug(ClientLogger) << "Creating CalendarManager"; initConnection(); initData(); } CalendarManager::~CalendarManager() { - + qCDebug(ClientLogger) << "Destroying CalendarManager"; } /** @@ -330,11 +355,14 @@ CalendarManager::~CalendarManager() */ void CalendarManager::initData() { + qCDebug(ClientLogger) << "Initializing calendar data"; //获取本地语言判断是否为中文 m_showLunar = QLocale::system().language() == QLocale::Chinese; + qCDebug(ClientLogger) << "Show lunar set to:" << m_showLunar << "based on system language"; //获取时间日期格式 const int _timeFormat = m_timeDateDbus->shortTimeFormat(); const int _dateFormat = m_timeDateDbus->shortDateFormat(); + qCDebug(ClientLogger) << "System time format:" << _timeFormat << "date format:" << _dateFormat; setYearBeginAndEndDate(m_selectDate.year()); //设置时间日期格式 setTimeFormatChanged(_timeFormat); @@ -347,6 +375,7 @@ void CalendarManager::initData() */ void CalendarManager::initConnection() { + qCDebug(ClientLogger) << "Initializing calendar connections"; connect(gAccountManager, &AccountManager::signalGeneralSettingsUpdate, this, &CalendarManager::slotGeneralSettingsUpdate); connect(m_timeDateDbus, &DaemonTimeDate::ShortTimeFormatChanged, this, &CalendarManager::signalTimeFormatChanged); connect(m_timeDateDbus, &DaemonTimeDate::ShortTimeFormatChanged, this, &CalendarManager::slotTimeFormatChanged); // add time format slot. @@ -360,6 +389,7 @@ void CalendarManager::initConnection() */ void CalendarManager::weekBeginsChanged(int value) { + qCDebug(ClientLogger) << "Week begins changed to:" << value; setFirstDayOfWeek(value); } @@ -368,6 +398,7 @@ void CalendarManager::weekBeginsChanged(int value) */ void CalendarManager::slotGetLunarSuccess() { + qCDebug(ClientLogger) << "Lunar data updated successfully"; //更新显示界面 for (int i = 0; i < m_showWidget.size(); ++i) { m_showWidget.at(i)->updateShowLunar(); @@ -376,11 +407,13 @@ void CalendarManager::slotGetLunarSuccess() void CalendarManager::slotGeneralSettingsUpdate() { + qCDebug(ClientLogger) << "Updating from general settings"; DCalendarGeneralSettings::Ptr setting = gAccountManager->getGeneralSettings(); if (!setting) { qCWarning(ClientLogger) << "Failed to get general settings"; return; } + qCDebug(ClientLogger) << "Setting first day of week to:" << setting->firstDayOfWeek() << "and time show type to:" << setting->timeShowType(); setFirstDayOfWeek(setting->firstDayOfWeek()); setTimeShowType(setting->timeShowType()); } @@ -391,10 +424,12 @@ void CalendarManager::slotGeneralSettingsUpdate() */ void CalendarManager::slotDateFormatChanged(int value) { + qCDebug(ClientLogger) << "Date format changed to:" << value; setDateFormatChanged(value); } void CalendarManager::slotTimeFormatChanged(int value) { + qCDebug(ClientLogger) << "Time format changed to:" << value; setTimeFormatChanged(value); } diff --git a/calendar-client/src/dataManage/lunarmanager.cpp b/calendar-client/src/dataManage/lunarmanager.cpp index 92bec29bd..e2866c898 100644 --- a/calendar-client/src/dataManage/lunarmanager.cpp +++ b/calendar-client/src/dataManage/lunarmanager.cpp @@ -3,15 +3,17 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "lunarmanager.h" +#include "commondef.h" LunarManager::LunarManager(QObject *parent) : QObject(parent) , m_dbusRequest(new DbusHuangLiRequest) { - + qCDebug(ClientLogger) << "Creating LunarManager"; } LunarManager* LunarManager::getInstace() { + // qCDebug(ClientLogger) << "Getting LunarManager instance"; static LunarManager lunarManager; return &lunarManager; } @@ -26,7 +28,10 @@ LunarManager* LunarManager::getInstace() */ bool LunarManager::getFestivalMonth(quint32 year, quint32 month, FestivalInfo& festivalInfo) { - return m_dbusRequest->getFestivalMonth(year, month, festivalInfo); + // qCDebug(ClientLogger) << "Getting festival month for year:" << year << "month:" << month; + bool result = m_dbusRequest->getFestivalMonth(year, month, festivalInfo); + // qCDebug(ClientLogger) << "Get festival month result:" << result << "with" << festivalInfo.listHoliday.size() << "holidays"; + return result; } /** @@ -38,6 +43,7 @@ bool LunarManager::getFestivalMonth(quint32 year, quint32 month, FestivalInfo& f */ bool LunarManager::getFestivalMonth(const QDate &date, FestivalInfo& festivalInfo) { + // qCDebug(ClientLogger) << "Getting festival month for date:" << date.toString(); return m_dbusRequest->getFestivalMonth(quint32(date.year()), quint32(date.month()), festivalInfo); } @@ -52,7 +58,10 @@ bool LunarManager::getFestivalMonth(const QDate &date, FestivalInfo& festivalInf */ bool LunarManager::getHuangLiDay(quint32 year, quint32 month, quint32 day, CaHuangLiDayInfo &info) { - return m_dbusRequest->getHuangLiDay(year, month, day, info); + // qCDebug(ClientLogger) << "Getting HuangLi day for year:" << year << "month:" << month << "day:" << day; + bool result = m_dbusRequest->getHuangLiDay(year, month, day, info); + // qCDebug(ClientLogger) << "Get HuangLi day result:" << result; + return result; } /** @@ -64,6 +73,7 @@ bool LunarManager::getHuangLiDay(quint32 year, quint32 month, quint32 day, CaHua */ bool LunarManager::getHuangLiDay(const QDate &date, CaHuangLiDayInfo &info) { + // qCDebug(ClientLogger) << "Getting HuangLi day for date:" << date.toString(); return getHuangLiDay(quint32(date.year()), quint32(date.month()), quint32(date.day()), info); } @@ -78,7 +88,10 @@ bool LunarManager::getHuangLiDay(const QDate &date, CaHuangLiDayInfo &info) */ bool LunarManager::getHuangLiMonth(quint32 year, quint32 month, CaHuangLiMonthInfo &info, bool fill) { - return m_dbusRequest->getHuangLiMonth(year, month, fill, info); + // qCDebug(ClientLogger) << "Getting HuangLi month for year:" << year << "month:" << month << "fill:" << fill; + bool result = m_dbusRequest->getHuangLiMonth(year, month, fill, info); + // qCDebug(ClientLogger) << "Get HuangLi month result:" << result << "with" << info.mDays << "days"; + return result; } /** @@ -90,6 +103,7 @@ bool LunarManager::getHuangLiMonth(quint32 year, quint32 month, CaHuangLiMonthIn */ bool LunarManager::getHuangLiMonth(const QDate &date, CaHuangLiMonthInfo &info, bool fill) { + // qCDebug(ClientLogger) << "Getting HuangLi month for date:" << date.toString() << "fill:" << fill; return getHuangLiMonth(quint32(date.year()), quint32(date.month()), info, fill); } @@ -101,8 +115,11 @@ bool LunarManager::getHuangLiMonth(const QDate &date, CaHuangLiMonthInfo &info, */ QString LunarManager::getHuangLiShortName(const QDate &date) { + qCDebug(ClientLogger) << "Getting HuangLi short name for date:" << date.toString(); CaHuangLiDayInfo info = getHuangLiDay(date); - return info.mLunarMonthName + info.mLunarDayName; + QString shortName = info.mLunarMonthName + info.mLunarDayName; + qCDebug(ClientLogger) << "HuangLi short name:" << shortName; + return shortName; } /** @@ -113,13 +130,16 @@ QString LunarManager::getHuangLiShortName(const QDate &date) */ void LunarManager::queryLunarInfo(const QDate &startDate, const QDate &stopDate) { + qCDebug(ClientLogger) << "Querying lunar info from" << startDate.toString() << "to" << stopDate.toString(); QMap lunarInfoMap; CaHuangLiMonthInfo monthInfo; const int offsetMonth = (stopDate.year() - startDate.year()) * 12 + stopDate.month() - startDate.month(); + qCDebug(ClientLogger) << "Offset months:" << offsetMonth; //获取开始时间至结束时间所在月的农历和节假日信息 for (int i = 0; i <= offsetMonth; ++i) { monthInfo.clear(); QDate beginDate = startDate.addMonths(i); + // qCDebug(ClientLogger) << "Getting HuangLi month for:" << beginDate.toString(); getHuangLiMonth(beginDate, monthInfo); QDate getDate(beginDate.year(), beginDate.month(), 1); @@ -127,6 +147,7 @@ void LunarManager::queryLunarInfo(const QDate &startDate, const QDate &stopDate) lunarInfoMap[getDate.addDays(j)] = monthInfo.mCaLunarDayInfo.at(j); } } + qCDebug(ClientLogger) << "Lunar info query completed with" << lunarInfoMap.size() << "days"; m_lunarInfoMap = lunarInfoMap; } @@ -138,24 +159,29 @@ void LunarManager::queryLunarInfo(const QDate &startDate, const QDate &stopDate) */ void LunarManager::queryFestivalInfo(const QDate &startDate, const QDate &stopDate) { + qCDebug(ClientLogger) << "Querying festival info from" << startDate.toString() << "to" << stopDate.toString(); QVector festivallist{}; const int offsetMonth = (stopDate.year() - startDate.year()) * 12 + stopDate.month() - startDate.month(); + qCDebug(ClientLogger) << "Offset months:" << offsetMonth; for (int i = 0; i <= offsetMonth; ++i) { FestivalInfo info; QDate beginDate = startDate.addMonths(i); + // qCDebug(ClientLogger) << "Getting festival month for:" << beginDate.toString(); if (getFestivalMonth(beginDate, info)) { festivallist.push_back(info); } } + qCDebug(ClientLogger) << "Festival info query completed with" << festivallist.size() << "months"; m_festivalDateMap.clear(); for (FestivalInfo info : festivallist) { for (HolidayInfo h : info.listHoliday) { m_festivalDateMap[h.date] = h.status; } } + qCDebug(ClientLogger) << "Festival date map updated with" << m_festivalDateMap.size() << "days"; } /** @@ -166,11 +192,14 @@ void LunarManager::queryFestivalInfo(const QDate &startDate, const QDate &stopDa */ CaHuangLiDayInfo LunarManager::getHuangLiDay(const QDate &date) { + qCDebug(ClientLogger) << "Getting HuangLi day info for date:" << date.toString(); //首先在缓存中查找是否存在该日期的农历信息,没有则通过dbus获取 CaHuangLiDayInfo info; if (m_lunarInfoMap.contains(date)) { + qCDebug(ClientLogger) << "Found HuangLi day info in cache"; info = m_lunarInfoMap[date]; } else { + qCDebug(ClientLogger) << "HuangLi day info not in cache, fetching via dbus"; getHuangLiDay(date, info); } return info; @@ -185,6 +214,7 @@ CaHuangLiDayInfo LunarManager::getHuangLiDay(const QDate &date) */ QMap LunarManager::getHuangLiDayMap(const QDate &startDate, const QDate &stopDate) { + qCDebug(ClientLogger) << "Getting HuangLi day map from" << startDate.toString() << "to" << stopDate.toString(); QMap lunarInfoMap; auto iterator = m_lunarInfoMap.begin(); while(iterator != m_lunarInfoMap.end()) { @@ -194,6 +224,7 @@ QMap LunarManager::getHuangLiDayMap(const QDate &startD } iterator++; } + qCDebug(ClientLogger) << "HuangLi day map contains" << lunarInfoMap.size() << "days"; return lunarInfoMap; } @@ -206,6 +237,7 @@ QMap LunarManager::getHuangLiDayMap(const QDate &startD */ QMap LunarManager::getFestivalInfoDateMap(const QDate &startDate, const QDate &stopDate) { + qCDebug(ClientLogger) << "Getting festival info date map from" << startDate.toString() << "to" << stopDate.toString(); QMap festivalDateMap; auto iterator = m_festivalDateMap.begin(); while(iterator != m_festivalDateMap.end()) { @@ -215,5 +247,6 @@ QMap LunarManager::getFestivalInfoDateMap(const QDate &startDate, co } iterator++; } + qCDebug(ClientLogger) << "Festival date map contains" << festivalDateMap.size() << "days"; return festivalDateMap; } diff --git a/calendar-client/src/dataManage/schedulecoormanage.cpp b/calendar-client/src/dataManage/schedulecoormanage.cpp index 35764ff87..861c824fb 100644 --- a/calendar-client/src/dataManage/schedulecoormanage.cpp +++ b/calendar-client/src/dataManage/schedulecoormanage.cpp @@ -3,42 +3,52 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "schedulecoormanage.h" +#include "commondef.h" #include CScheduleCoorManage::CScheduleCoorManage() { + qCDebug(ClientLogger) << "Creating CScheduleCoorManage"; } CScheduleCoorManage::~CScheduleCoorManage() { + qCDebug(ClientLogger) << "Destroying CScheduleCoorManage"; } void CScheduleCoorManage::setRange(int w, int h, QDate begindate, QDate enddate, int rightmagin) { + qCDebug(ClientLogger) << "Setting range with width:" << w << "height:" << h << "begin date:" << begindate.toString() << "end date:" << enddate.toString() << "right margin:" << rightmagin; m_width = w; m_height = h; m_rightmagin = rightmagin; m_begindate = begindate; m_enddate = enddate; m_totalDay = begindate.daysTo(enddate) + 1; + qCDebug(ClientLogger) << "Total days:" << m_totalDay; } void CScheduleCoorManage::setDateRange(QDate begindate, QDate enddate) { + qCDebug(ClientLogger) << "Setting date range from:" << begindate.toString() << "to:" << enddate.toString(); m_begindate = begindate; m_enddate = enddate; m_totalDay = begindate.daysTo(enddate) + 1; + qCDebug(ClientLogger) << "Total days:" << m_totalDay; } QRectF CScheduleCoorManage::getDrawRegion(QDateTime begintime, QDateTime endtime) { + qCDebug(ClientLogger) << "Getting draw region from:" << begintime.toString() << "to:" << endtime.toString(); QRectF rect; QString bb = begintime.toString("yyyyMMddhhmmsszzz"); QString ee = endtime.toString("yyyyMMddhhmmsszzz"); - if (begintime > endtime) + if (begintime > endtime) { + qCDebug(ClientLogger) << "Begin time is after end time, returning empty rect"; return rect; + } QDate begindate = begintime.date(); QDate enddate = endtime.date(); @@ -46,8 +56,10 @@ QRectF CScheduleCoorManage::getDrawRegion(QDateTime begintime, QDateTime endtime QTime beginScheduleT = begintime.time(); QTime endScheduleT = endtime.time(); - if (begindate < m_begindate || enddate > m_enddate) + if (begindate < m_begindate || enddate > m_enddate) { + qCDebug(ClientLogger) << "Date out of range, returning empty rect"; return rect; + } qint64 beginday = m_begindate.daysTo(begindate) + 1; qint64 day = begindate.daysTo(enddate) + 1; @@ -59,17 +71,21 @@ QRectF CScheduleCoorManage::getDrawRegion(QDateTime begintime, QDateTime endtime qreal posY = m_height * (ScheduleBT / 86400.0); rect = QRectF(posX, posY, rWidth, rHeight); + qCDebug(ClientLogger) << "Draw region calculated:" << rect; return rect; } QRectF CScheduleCoorManage::getDrawRegion(QDateTime begintime, QDateTime endtime, int index, int coount) { + qCDebug(ClientLogger) << "Getting draw region from:" << begintime.toString() << "to:" << endtime.toString() << "index:" << index << "count:" << coount; QRectF rect; QString bb = begintime.toString("yyyyMMddhhmmsszzz"); QString ee = endtime.toString("yyyyMMddhhmmsszzz"); - if (begintime > endtime) + if (begintime > endtime) { + qCDebug(ClientLogger) << "Begin time is after end time, returning empty rect"; return rect; + } QDate begindate = begintime.date(); QDate enddate = endtime.date(); @@ -77,8 +93,10 @@ QRectF CScheduleCoorManage::getDrawRegion(QDateTime begintime, QDateTime endtime QTime beginScheduleT = begintime.time(); QTime endScheduleT = endtime.time(); - if (begindate < m_begindate || enddate > m_enddate) + if (begindate < m_begindate || enddate > m_enddate) { + qCDebug(ClientLogger) << "Date out of range, returning empty rect"; return rect; + } qint64 beginday = m_begindate.daysTo(begindate) + 1; qint64 day = begindate.daysTo(enddate) + 1; int ScheduleBT = beginzero.secsTo(beginScheduleT); @@ -89,17 +107,22 @@ QRectF CScheduleCoorManage::getDrawRegion(QDateTime begintime, QDateTime endtime qreal posY = m_height * (ScheduleBT / 86400.0); rect = QRectF(posX, posY, rWidth, rHeight); + qCDebug(ClientLogger) << "Draw region calculated:" << rect; return rect; } QRectF CScheduleCoorManage::getDrawRegion(QDate date, QDateTime begintime, QDateTime endtime, int index, int coount, int maxNum, int type) { + qCDebug(ClientLogger) << "Getting draw region for date:" << date.toString() << "from:" << begintime.toString() << "to:" << endtime.toString() + << "index:" << index << "count:" << coount << "maxNum:" << maxNum << "type:" << type; QRectF rect; QString bb = begintime.toString("yyyyMMddhhmmsszzz"); QString ee = endtime.toString("yyyyMMddhhmmsszzz"); - if (begintime > endtime) + if (begintime > endtime) { + qCDebug(ClientLogger) << "Begin time is after end time, returning empty rect"; return rect; + } QDate begindate = begintime.date(); QDate enddate = endtime.date(); @@ -108,10 +131,12 @@ QRectF CScheduleCoorManage::getDrawRegion(QDate date, QDateTime begintime, QDate QTime endScheduleT = endtime.time(); if (begindate < date) { + qCDebug(ClientLogger) << "Begin date is before target date, adjusting"; begindate = date; beginScheduleT = beginzero; } if (enddate > date) { + qCDebug(ClientLogger) << "End date is after target date, adjusting"; enddate = date; endScheduleT = QTime(23, 59, 59); } @@ -126,12 +151,15 @@ QRectF CScheduleCoorManage::getDrawRegion(QDate date, QDateTime begintime, QDate qreal posY = m_height * (ScheduleBT / 86400.0); if (coount > maxNum && type == 0) { + qCDebug(ClientLogger) << "Count exceeds maxNum, adjusting width"; qreal sscale = 27.0 / (m_width * (1.0 * day / m_totalDay)); if (index < maxNum + 1) { + qCDebug(ClientLogger) << "Index within maxNum range"; rWidth = m_width * (1.0 * day / m_totalDay) * sscale + 0.5; posX = m_width * (1.0 * (beginday - 1) / m_totalDay) + (index - 1) * rWidth; } else { + qCDebug(ClientLogger) << "Index outside maxNum range"; 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; @@ -139,27 +167,32 @@ QRectF CScheduleCoorManage::getDrawRegion(QDate date, QDateTime begintime, QDate } if (rHeight < 20) { + qCDebug(ClientLogger) << "Height too small, adjusting to minimum"; if (posY + 20 > m_height) posY = m_height - 20; rHeight = 20; } if (posX < 1) { + qCDebug(ClientLogger) << "X position too small, adjusting to minimum"; posX = 1; rWidth = rWidth - posX; } rect = QRectF(posX, posY, rWidth, rHeight); - + qCDebug(ClientLogger) << "Draw region calculated:" << rect; return rect; } QRectF CScheduleCoorManage::getDrawRegionF(QDateTime begintime, QDateTime endtime) { + qCDebug(ClientLogger) << "Getting draw region F from:" << begintime.toString() << "to:" << endtime.toString(); QRectF rectf; - if (begintime > endtime) + if (begintime > endtime) { + qCDebug(ClientLogger) << "Begin time is after end time, returning empty rect"; return rectf; + } QDate begindate = begintime.date(); QDate enddate = endtime.date(); @@ -167,8 +200,10 @@ QRectF CScheduleCoorManage::getDrawRegionF(QDateTime begintime, QDateTime endtim QTime beginScheduleT = begintime.time(); QTime endScheduleT = endtime.time(); - if (begindate < m_begindate || enddate > m_enddate) + if (begindate < m_begindate || enddate > m_enddate) { + qCDebug(ClientLogger) << "Date out of range, returning empty rect"; return rectf; + } qint64 beginday = m_begindate.daysTo(begindate) + 1; qint64 day = begindate.daysTo(enddate) + 1; @@ -180,22 +215,30 @@ QRectF CScheduleCoorManage::getDrawRegionF(QDateTime begintime, QDateTime endtim qreal posY = m_height * (ScheduleBT / 86400.0); rectf = QRectF(posX, posY, rWidth, rHeight); + qCDebug(ClientLogger) << "Draw region F calculated:" << rectf; return rectf; } QRectF CScheduleCoorManage::getAllDayDrawRegion(QDate begin, QDate end) { + qCDebug(ClientLogger) << "Getting all day draw region from:" << begin.toString() << "to:" << end.toString(); QRectF rect; - if (begin > end) + if (begin > end) { + qCDebug(ClientLogger) << "Begin date is after end date, returning empty rect"; return rect; + } QDate begindate = begin; QDate enddate = end; - if (begindate < m_begindate) + if (begindate < m_begindate) { + qCDebug(ClientLogger) << "Begin date is before range, adjusting"; begindate = m_begindate; - if (enddate > m_enddate) + } + if (enddate > m_enddate) { + qCDebug(ClientLogger) << "End date is after range, adjusting"; enddate = m_enddate; + } qint64 beginday = m_begindate.daysTo(begindate); qint64 day = begindate.daysTo(enddate) + 1; @@ -205,17 +248,21 @@ QRectF CScheduleCoorManage::getAllDayDrawRegion(QDate begin, QDate end) qreal posY = 0; rect = QRectF(posX + 6, posY, rWidth - m_rightmagin, rHeight); + qCDebug(ClientLogger) << "All day draw region calculated:" << rect; return rect; } QDateTime CScheduleCoorManage::getDate(QPointF pos) { + qCDebug(ClientLogger) << "Getting date from position:" << pos; QDateTime begintime; qint64 day = static_cast((1.0 * pos.x() / m_width) * m_totalDay); if (day < 0) { + qCDebug(ClientLogger) << "Day out of range (negative), adjusting to 0"; day = 0; } else if (day >= m_totalDay) { + qCDebug(ClientLogger) << "Day out of range (too large), adjusting to max"; day = m_totalDay - 1; } int time = static_cast((1.0 * pos.y() / m_height) * 86400.0); @@ -226,28 +273,35 @@ QDateTime CScheduleCoorManage::getDate(QPointF pos) begintime.setDate(date); begintime.setTime(QTime(hours, minutes, secss)); + qCDebug(ClientLogger) << "Calculated date time:" << begintime.toString(); return begintime; } QDate CScheduleCoorManage::getsDate(QPointF pos) { + qCDebug(ClientLogger) << "Getting date from position:" << pos; qint64 day = static_cast((1.0 * pos.x() / m_width) * m_totalDay); if (day < 0) { + qCDebug(ClientLogger) << "Day out of range (negative), adjusting to 0"; day = 0; } else if (day >= m_totalDay) { + qCDebug(ClientLogger) << "Day out of range (too large), adjusting to max"; day = m_totalDay - 1; } QDate date = m_begindate.addDays(day); + qCDebug(ClientLogger) << "Calculated date:" << date.toString(); return date; } float CScheduleCoorManage::getHeight(const QTime &time) const { + qCDebug(ClientLogger) << "Getting height for time:" << time.toString(); QTime beginzero(0, 0, 0); int ScheduleBT = beginzero.secsTo(time); float posY = static_cast(m_height * (ScheduleBT / 86400.0)); + qCDebug(ClientLogger) << "Calculated height:" << posY; return posY; } diff --git a/calendar-client/src/dataManage/scheduledatamanage.cpp b/calendar-client/src/dataManage/scheduledatamanage.cpp index 0e26513f4..314ef6633 100644 --- a/calendar-client/src/dataManage/scheduledatamanage.cpp +++ b/calendar-client/src/dataManage/scheduledatamanage.cpp @@ -6,6 +6,7 @@ #include "accountmanager.h" #include "cscheduleoperation.h" #include "accountmanager.h" +#include "commondef.h" #include #include @@ -15,14 +16,17 @@ CScheduleDataManage *CScheduleDataManage::m_vscheduleDataManage = nullptr; // CSchedulesColor CScheduleDataManage::getScheduleColorByType(const QString &typeId) { + qCDebug(ClientLogger) << "Getting schedule color for type ID:" << typeId; CSchedulesColor color; DScheduleType::Ptr type = gAccountManager->getScheduleTypeByScheduleTypeId(typeId); QColor typeColor; if (nullptr != type) { typeColor = type->typeColor().colorCode(); + qCDebug(ClientLogger) << "Found type color:" << typeColor.name(); } else if (typeId =="other"){ //如果类型不存在则设置一个默认颜色 typeColor = QColor("#BA60FA"); + qCDebug(ClientLogger) << "Using default color for 'other' type:" << typeColor.name(); } color.orginalColor = typeColor; @@ -37,27 +41,35 @@ CSchedulesColor CScheduleDataManage::getScheduleColorByType(const QString &typeI color.hightColor = color.orginalColor; color.hightColor.setAlphaF(0.35); + qCDebug(ClientLogger) << "Returning schedule colors with original color:" << color.orginalColor.name(); return color; } QColor CScheduleDataManage::getSystemActiveColor() { - return DGuiApplicationHelper::instance()->applicationPalette().highlight().color(); + QColor color = DGuiApplicationHelper::instance()->applicationPalette().highlight().color(); + // qCDebug(ClientLogger) << "Getting system active color:" << color.name(); + return color; } QColor CScheduleDataManage::getTextColor() { - return DGuiApplicationHelper::instance()->applicationPalette().text().color(); + QColor color = DGuiApplicationHelper::instance()->applicationPalette().text().color(); + // qCDebug(ClientLogger) << "Getting text color:" << color.name(); + return color; } void CScheduleDataManage::setTheMe(int type) { + // qCDebug(ClientLogger) << "Setting theme to:" << type; m_theme = type; } CScheduleDataManage *CScheduleDataManage::getScheduleDataManage() { + // qCDebug(ClientLogger) << "Getting schedule data manage instance"; if (nullptr == m_vscheduleDataManage) { + qCDebug(ClientLogger) << "Creating new schedule data manage instance"; m_vscheduleDataManage = new CScheduleDataManage(); } return m_vscheduleDataManage; @@ -66,8 +78,10 @@ CScheduleDataManage *CScheduleDataManage::getScheduleDataManage() CScheduleDataManage::CScheduleDataManage(QObject *parent) : QObject(parent) { + qCDebug(ClientLogger) << "CScheduleDataManage constructor"; } CScheduleDataManage::~CScheduleDataManage() { + qCDebug(ClientLogger) << "CScheduleDataManage destructor"; } diff --git a/calendar-client/src/dataManage/schedulemanager.cpp b/calendar-client/src/dataManage/schedulemanager.cpp index 195043f32..a075242bf 100644 --- a/calendar-client/src/dataManage/schedulemanager.cpp +++ b/calendar-client/src/dataManage/schedulemanager.cpp @@ -3,20 +3,24 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "schedulemanager.h" +#include "commondef.h" ScheduleManager::ScheduleManager(QObject *parent) : QObject(parent) { + qCDebug(ClientLogger) << "ScheduleManager constructor"; initconnect(); } ScheduleManager *ScheduleManager::getInstace() { + qCDebug(ClientLogger) << "Getting ScheduleManager instance"; static ScheduleManager manager; return &manager; } void ScheduleManager::initconnect() { + qCDebug(ClientLogger) << "Initializing ScheduleManager connections"; connect(gAccountManager, &AccountManager::signalScheduleUpdate, this, &ScheduleManager::slotScheduleUpdate); connect(gAccountManager, &AccountManager::signalSearchScheduleUpdate, this, &ScheduleManager::slotSearchUpdate); } @@ -28,6 +32,7 @@ void ScheduleManager::initconnect() */ void ScheduleManager::resetSchedule(int year) { + qCDebug(ClientLogger) << "Resetting schedule for year:" << year; for (AccountItem::Ptr p : gAccountManager->getAccountList()) { p->querySchedulesWithParameter(year); } @@ -35,6 +40,7 @@ void ScheduleManager::resetSchedule(int year) void ScheduleManager::resetSchedule(const QDateTime &start, const QDateTime &end) { + qCDebug(ClientLogger) << "Resetting schedule from" << start << "to" << end; for (AccountItem::Ptr p : gAccountManager->getAccountList()) { p->querySchedulesWithParameter(start, end); } @@ -46,12 +52,15 @@ void ScheduleManager::resetSchedule(const QDateTime &start, const QDateTime &end */ void ScheduleManager::updateSchedule() { + qCDebug(ClientLogger) << "Updating schedule data"; m_scheduleMap.clear(); if (nullptr != gAccountManager->getLocalAccountItem()) { + qCDebug(ClientLogger) << "Getting schedule map from local account"; m_scheduleMap = gAccountManager->getLocalAccountItem()->getScheduleMap(); } if (nullptr != gAccountManager->getUnionAccountItem()) { + qCDebug(ClientLogger) << "Getting schedule map from union account"; QMap scheduleMap = gAccountManager->getUnionAccountItem()->getScheduleMap(); if (m_scheduleMap.size() == 0) { m_scheduleMap = scheduleMap; @@ -65,6 +74,7 @@ void ScheduleManager::updateSchedule() } } } + qCDebug(ClientLogger) << "Schedule update complete with" << m_scheduleMap.size() << "dates"; emit signalScheduleUpdate(); } @@ -74,11 +84,14 @@ void ScheduleManager::updateSchedule() */ void ScheduleManager::updateSearchSchedule() { + qCDebug(ClientLogger) << "Updating search schedule data"; m_searchScheduleMap.clear(); if (nullptr != gLocalAccountItem) { + qCDebug(ClientLogger) << "Getting search schedule map from local account"; m_searchScheduleMap = gLocalAccountItem->getSearchScheduleMap(); } if (nullptr != gUosAccountItem) { + qCDebug(ClientLogger) << "Getting search schedule map from UOS account"; QMap scheduleMap = gUosAccountItem->getSearchScheduleMap(); if (m_searchScheduleMap.size() == 0) { m_searchScheduleMap = scheduleMap; @@ -92,6 +105,7 @@ void ScheduleManager::updateSearchSchedule() } } } + qCDebug(ClientLogger) << "Search schedule update complete with" << m_searchScheduleMap.size() << "dates"; emit signalSearchScheduleUpdate(); } @@ -101,11 +115,13 @@ void ScheduleManager::updateSearchSchedule() */ void ScheduleManager::slotScheduleUpdate() { + qCDebug(ClientLogger) << "Schedule update slot triggered"; updateSchedule(); } void ScheduleManager::slotSearchUpdate() { + qCDebug(ClientLogger) << "Search update slot triggered"; updateSearchSchedule(); } @@ -116,6 +132,7 @@ void ScheduleManager::slotSearchUpdate() */ QMap ScheduleManager::getAllScheduleMap() { + qCDebug(ClientLogger) << "Getting all schedule map with" << m_scheduleMap.size() << "dates"; return m_scheduleMap; } @@ -128,6 +145,7 @@ QMap ScheduleManager::getAllScheduleMap() */ QMap ScheduleManager::getScheduleMap(const QDate &startDate, const QDate &stopDate) const { + qCDebug(ClientLogger) << "Getting schedule map from" << startDate << "to" << stopDate; QMap map; QDate date = startDate; while (date != stopDate) { @@ -140,6 +158,7 @@ QMap ScheduleManager::getScheduleMap(const QDate &startD if (m_scheduleMap.contains(date)) { map[date] = m_scheduleMap[date]; } + qCDebug(ClientLogger) << "Found schedules for" << map.size() << "dates in the requested range"; return map; } @@ -150,6 +169,7 @@ QMap ScheduleManager::getScheduleMap(const QDate &startD */ QMap ScheduleManager::getAllSearchedScheduleMap() { + qCDebug(ClientLogger) << "Getting all searched schedule map with" << m_searchScheduleMap.size() << "dates"; return m_searchScheduleMap; } @@ -160,10 +180,12 @@ QMap ScheduleManager::getAllSearchedScheduleMap() */ DSchedule::List ScheduleManager::getAllSearchedScheduleList() { + qCDebug(ClientLogger) << "Getting all searched schedule list"; DSchedule::List list; for (DSchedule::List l : m_searchScheduleMap.values()) { list.append(l); } + qCDebug(ClientLogger) << "Found" << list.size() << "searched schedules"; return list; } @@ -174,10 +196,12 @@ DSchedule::List ScheduleManager::getAllSearchedScheduleList() */ QSet ScheduleManager::getAllScheduleDate() { + qCDebug(ClientLogger) << "Getting all schedule dates"; QSet set; for (QDate date : m_scheduleMap.keys()) { set.insert(date); } + qCDebug(ClientLogger) << "Found" << set.size() << "dates with schedules"; return set; } @@ -188,10 +212,12 @@ QSet ScheduleManager::getAllScheduleDate() */ QSet ScheduleManager::getAllSearchedScheduleDate() { + qCDebug(ClientLogger) << "Getting all searched schedule dates"; QSet set; for (QDate date : m_searchScheduleMap.keys()) { set.insert(date); } + qCDebug(ClientLogger) << "Found" << set.size() << "dates with searched schedules"; return set; } @@ -203,9 +229,12 @@ QSet ScheduleManager::getAllSearchedScheduleDate() */ DSchedule::List ScheduleManager::getScheduleByDay(QDate date) { + qCDebug(ClientLogger) << "Getting schedules for date:" << date; if (m_scheduleMap.contains(date)) { + qCDebug(ClientLogger) << "Found" << m_scheduleMap[date].size() << "schedules for" << date; return m_scheduleMap[date]; } + qCDebug(ClientLogger) << "No schedules found for" << date; return DSchedule::List(); } @@ -217,13 +246,18 @@ DSchedule::List ScheduleManager::getScheduleByDay(QDate date) */ DScheduleType::Ptr ScheduleManager::getScheduleTypeByScheduleId(const QString &id) { + qCDebug(ClientLogger) << "Getting schedule type by schedule ID:" << id; DScheduleType::Ptr type = nullptr; for (AccountItem::Ptr p : gAccountManager->getAccountList()) { type = p->getScheduleTypeByID(id); if (nullptr != type) { + qCDebug(ClientLogger) << "Found schedule type for ID:" << id; break; } } + if (type == nullptr) { + qCDebug(ClientLogger) << "No schedule type found for ID:" << id; + } return type; } @@ -236,6 +270,7 @@ DScheduleType::Ptr ScheduleManager::getScheduleTypeByScheduleId(const QString &i */ void ScheduleManager::searchSchedule(const QString &key, const QDateTime &startTime, const QDateTime &endTime) { + qCDebug(ClientLogger) << "Searching schedules with key:" << key << "from" << startTime << "to" << endTime; m_searchScheduleMap.clear(); static int count = 0; count = 0; @@ -245,11 +280,13 @@ void ScheduleManager::searchSchedule(const QString &key, const QDateTime &startT m_searchQuery->setDtStart(startTime); m_searchQuery->setDtEnd(endTime); for (AccountItem::Ptr p : gAccountManager->getAccountList()) { - count ++; + count++; + // qCDebug(ClientLogger) << "Querying account for schedules"; p->querySchedulesWithParameter(m_searchQuery, [&](CallMessge) { count--; if (count == 0) { - this->updateSearchSchedule(); + // qCDebug(ClientLogger) << "All account queries completed, updating search schedule"; + updateSearchSchedule(); } }); } @@ -261,6 +298,7 @@ void ScheduleManager::searchSchedule(const QString &key, const QDateTime &startT */ void ScheduleManager::clearSearchSchedule() { + qCDebug(ClientLogger) << "Clearing search schedule"; m_searchScheduleMap.clear(); m_searchQuery.reset(nullptr); emit signalSearchScheduleUpdate(); diff --git a/calendar-client/src/dbus/exportedinterface.cpp b/calendar-client/src/dbus/exportedinterface.cpp index df1adc34f..d17d198a5 100644 --- a/calendar-client/src/dbus/exportedinterface.cpp +++ b/calendar-client/src/dbus/exportedinterface.cpp @@ -41,14 +41,13 @@ QVariant ExportedInterface::invoke(const QString &action, const QString ¶met qCWarning(ClientLogger) << "Invalid schedule info for CREATE action"; return QVariant(false); } - qCDebug(ClientLogger) << "Creating schedule with title:" << info->summary(); + qCDebug(ClientLogger) << "Creating schedule"; bool _createSucc = _scheduleOperation.createSchedule(info); //如果创建失败 if (!_createSucc) { - qCWarning(ClientLogger) << "Failed to create schedule:" << info->summary(); + qCWarning(ClientLogger) << "Failed to create schedule"; return QVariant(false); } - qCDebug(ClientLogger) << "Successfully created schedule:" << info->summary(); } else if (action == "VIEW") { qCDebug(ClientLogger) << "Viewing calendar with type:" << para.viewType; dynamic_cast(m_object)->viewWindow(para.viewType); diff --git a/calendar-client/src/dialog/dcalendarddialog.cpp b/calendar-client/src/dialog/dcalendarddialog.cpp index c6f16d9e7..ad3c94da5 100644 --- a/calendar-client/src/dialog/dcalendarddialog.cpp +++ b/calendar-client/src/dialog/dcalendarddialog.cpp @@ -3,7 +3,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "dcalendarddialog.h" - +#include "commondef.h" #include "constants.h" #include "calendarmanage.h" #include "tabletconfig.h" @@ -14,13 +14,17 @@ DCalendarDDialog::DCalendarDDialog(QWidget *parent) , m_timeFormat(CalendarManager::getInstance()->getTimeFormat()) , m_dateFormat(CalendarManager::getInstance()->getDateFormat()) { + qCDebug(ClientLogger) << "DCalendarDDialog constructor"; connect(CalendarManager::getInstance(), &CalendarManager::signalTimeFormatChanged, this, &DCalendarDDialog::setTimeFormat); connect(CalendarManager::getInstance(), &CalendarManager::signalDateFormatChanged, this, &DCalendarDDialog::setDateFormat); //获取ddialog的标题栏 DTitlebar *titlebar = findChild(); if (titlebar != nullptr) { + qCDebug(ClientLogger) << "Setting focus proxy to titlebar"; //设置ddialog的焦点代理为标题栏 this->setFocusProxy(titlebar); + } else { + qCDebug(ClientLogger) << "Titlebar not found"; } } @@ -28,35 +32,43 @@ void DCalendarDDialog::mouseMoveEvent(QMouseEvent *event) { //如果为平板模式使其不可移动 if (TabletConfig::isTablet()) { + // qCDebug(ClientLogger) << "Mouse move event ignored in tablet mode"; Q_UNUSED(event); } else { + // qCDebug(ClientLogger) << "Processing mouse move event in desktop mode"; DDialog::mouseMoveEvent(event); } } void DCalendarDDialog::keyPressEvent(QKeyEvent *event) { + // qCDebug(ClientLogger) << "Key press event with key:" << event->key(); //如果dtk版本在5.3.0以下调用QDialog 以上调用DDialog #if (DTK_VERSION < DTK_VERSION_CHECK(5, 3, 0, 0)) + // qCDebug(ClientLogger) << "Using QDialog::keyPressEvent for DTK < 5.3.0"; return QDialog::keyPressEvent(event); #else + // qCDebug(ClientLogger) << "Using DDialog::keyPressEvent for DTK >= 5.3.0"; return DDialog::keyPressEvent(event); #endif } bool DCalendarDDialog::eventFilter(QObject *o, QEvent *e) { + // qCDebug(ClientLogger) << "Event filter for event type:" << e->type(); //如果dtk版本在5.3.0以下调用QDialog 以上调用DDialog #if (DTK_VERSION < DTK_VERSION_CHECK(5, 3, 0, 0)) + // qCDebug(ClientLogger) << "Using QDialog::eventFilter for DTK < 5.3.0"; return QDialog::eventFilter(o, e); #else + // qCDebug(ClientLogger) << "Using DDialog::eventFilter for DTK >= 5.3.0"; return DDialog::eventFilter(o, e); #endif } void DCalendarDDialog::updateDateTimeFormat() { - + qCDebug(ClientLogger) << "Updating date time format, date format:" << m_dateFormat << "time format:" << m_timeFormat; } /** @@ -64,11 +76,13 @@ void DCalendarDDialog::updateDateTimeFormat() */ void DCalendarDDialog::setTimeFormat(int value) { + qCDebug(ClientLogger) << "Setting time format with value:" << value; if (value) { m_timeFormat = "hh:mm"; } else { m_timeFormat = "h:mm"; } + qCDebug(ClientLogger) << "Time format set to:" << m_timeFormat; updateDateTimeFormat(); } @@ -77,6 +91,7 @@ void DCalendarDDialog::setTimeFormat(int value) */ void DCalendarDDialog::setDateFormat(int value) { + qCDebug(ClientLogger) << "Setting date format with value:" << value; switch (value) { case 0: { m_dateFormat = "yyyy/M/d"; @@ -109,5 +124,6 @@ void DCalendarDDialog::setDateFormat(int value) m_dateFormat = "yyyy-MM-dd"; } break; } + qCDebug(ClientLogger) << "Date format set to:" << m_dateFormat; updateDateTimeFormat(); } diff --git a/calendar-client/src/dialog/myscheduleview.cpp b/calendar-client/src/dialog/myscheduleview.cpp index a8bfcafc7..c985a6360 100644 --- a/calendar-client/src/dialog/myscheduleview.cpp +++ b/calendar-client/src/dialog/myscheduleview.cpp @@ -24,6 +24,7 @@ DGUI_USE_NAMESPACE CMyScheduleView::CMyScheduleView(const DSchedule::Ptr &schduleInfo, QWidget *parent) : DCalendarDDialog(parent) { + qCDebug(ClientLogger) << "CMyScheduleView constructor with schedule:" << schduleInfo->summary(); setContentsMargins(0, 0, 0, 0); m_scheduleInfo = schduleInfo; initUI(); @@ -39,11 +40,13 @@ CMyScheduleView::CMyScheduleView(const DSchedule::Ptr &schduleInfo, QWidget *par void CMyScheduleView::setSchedules(const DSchedule::Ptr &schduleInfo) { + qCDebug(ClientLogger) << "Setting schedule to:" << schduleInfo->summary(); m_scheduleInfo = schduleInfo; } void CMyScheduleView::updateFormat() { + qCDebug(ClientLogger) << "Updating format for schedule:" << m_scheduleInfo->summary(); updateDateTimeFormat(); slotAccountStateChange(); } @@ -54,6 +57,7 @@ void CMyScheduleView::updateFormat() */ void CMyScheduleView::slotAutoFeed(const QFont &font) { + qCDebug(ClientLogger) << "Auto-adjusting text layout for schedule:" << m_scheduleInfo->summary(); Q_UNUSED(font) if (nullptr == m_timeLabel || nullptr == m_scheduleLabel) { qCWarning(ClientLogger) << "Time label or schedule label is null"; @@ -114,23 +118,28 @@ void CMyScheduleView::slotAutoFeed(const QFont &font) if (textWidth > m_timeLabel->width()) { timeName[index - 1] = '\n'; m_timeLabelH = 58; + qCDebug(ClientLogger) << "Adjusting time label height to 58 for lunar calendar"; } else { m_timeLabelH = 26; + qCDebug(ClientLogger) << "Setting time label height to 26 for lunar calendar"; } } m_timeLabel->setText(timeName); } else { m_timeLabelH = 26; + qCDebug(ClientLogger) << "Setting time label height to 26 for standard calendar"; } //更新控件高度 m_timeLabel->setFixedHeight(m_timeLabelH); //更新界面高度 setFixedHeight(m_defaultH + m_timeLabelH + m_scheduleLabelH); + qCDebug(ClientLogger) << "Updated view height to:" << (m_defaultH + m_timeLabelH + m_scheduleLabelH); } void CMyScheduleView::slotAccountStateChange() { + qCDebug(ClientLogger) << "Account state changed for schedule:" << m_scheduleInfo->summary(); AccountItem::Ptr item = gAccountManager->getAccountItemByScheduleTypeId(m_scheduleInfo->scheduleTypeID()); if (!item) { qCWarning(ClientLogger) << "No account found for schedule type ID:" << m_scheduleInfo->scheduleTypeID(); @@ -149,6 +158,7 @@ void CMyScheduleView::slotAccountStateChange() */ void CMyScheduleView::setLabelTextColor(const int type) { + qCDebug(ClientLogger) << "Setting label text colors for theme type:" << type; //标题显示颜色 QColor titleColor; //日程显示颜色 @@ -160,12 +170,14 @@ void CMyScheduleView::setLabelTextColor(const int type) scheduleTitleColor = "#FFFFFF"; timeColor = "#FFFFFF"; timeColor.setAlphaF(0.7); + qCDebug(ClientLogger) << "Using dark theme colors"; } else { titleColor = "#001A2E"; scheduleTitleColor = "#000000"; scheduleTitleColor.setAlphaF(0.9); timeColor = "#000000"; timeColor.setAlphaF(0.6); + qCDebug(ClientLogger) << "Using light theme colors"; } //设置颜色 setPaletteTextColor(m_Title, titleColor); @@ -180,9 +192,12 @@ void CMyScheduleView::setLabelTextColor(const int type) */ void CMyScheduleView::setPaletteTextColor(QWidget *widget, QColor textColor) { + qCDebug(ClientLogger) << "Setting palette text color:" << textColor.name(); //如果为空指针则退出 - if (nullptr == widget) + if (nullptr == widget) { + qCWarning(ClientLogger) << "Widget is null, cannot set palette color"; return; + } DPalette palette = widget->palette(); //设置文字显示颜色 palette.setColor(DPalette::WindowText, textColor); @@ -194,9 +209,11 @@ void CMyScheduleView::setPaletteTextColor(QWidget *widget, QColor textColor) */ void CMyScheduleView::updateDateTimeFormat() { + qCDebug(ClientLogger) << "Updating date time format for schedule:" << m_scheduleInfo->summary(); //如果为节假日 if (CScheduleOperation::isFestival(m_scheduleInfo)) { m_timeLabel->setText(m_scheduleInfo->dtStart().toString(m_dateFormat)); + qCDebug(ClientLogger) << "Festival schedule date format:" << m_scheduleInfo->dtStart().toString(m_dateFormat); } else { QString showTime; QString beginName, endName; @@ -224,10 +241,12 @@ void CMyScheduleView::updateDateTimeFormat() QString CMyScheduleView::getDataByFormat(const QDate &date, QString format) { + qCDebug(ClientLogger) << "Getting formatted date for:" << date << "with format:" << format; QString name = date.toString(format); if (m_scheduleInfo->lunnar()) { //接入农历时间 name += gLunarManager->getHuangLiShortName(date); + qCDebug(ClientLogger) << "Added lunar calendar info to date:" << name; } return name; } @@ -239,6 +258,7 @@ QString CMyScheduleView::getDataByFormat(const QDate &date, QString format) */ void CMyScheduleView::slotBtClick(int buttonIndex, const QString &buttonName) { + qCDebug(ClientLogger) << "Button clicked: index=" << buttonIndex << "name=" << buttonName; Q_UNUSED(buttonName); if (buttonIndex == 0) { qCDebug(ClientLogger) << "Delete button clicked for schedule:" << m_scheduleInfo->summary(); @@ -271,6 +291,7 @@ void CMyScheduleView::slotBtClick(int buttonIndex, const QString &buttonName) */ void CMyScheduleView::initUI() { + qCDebug(ClientLogger) << "Initializing UI for schedule view"; //在点击任何对话框上的按钮后不关闭对话框,保证关闭子窗口时不被一起关掉 setOnButtonClickedClose(false); @@ -347,18 +368,22 @@ void CMyScheduleView::initUI() centerWidget->setPalette(centerWidgetPalette); //添加窗口为剧中对齐 addContent(centerWidget, Qt::AlignCenter); + qCDebug(ClientLogger) << "UI initialization complete"; } void CMyScheduleView::initConnection() { + qCDebug(ClientLogger) << "Initializing connections for schedule view"; //关联主题改变事件 QObject::connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &CMyScheduleView::setLabelTextColor); //如果为节假日日程 if (CScheduleOperation::isFestival(m_scheduleInfo)) { + qCDebug(ClientLogger) << "Adding close button for festival schedule"; connect(this, &DDialog::buttonClicked, this, &CMyScheduleView::close); } else { + qCDebug(ClientLogger) << "Adding delete and edit buttons for regular schedule"; connect(this, &DDialog::buttonClicked, this, &CMyScheduleView::slotBtClick); } QObject::connect(qGuiApp, &DApplication::fontChanged, this, &CMyScheduleView::slotAutoFeed); diff --git a/calendar-client/src/dialog/schedulectrldlg.cpp b/calendar-client/src/dialog/schedulectrldlg.cpp index 83547f852..a660cf0e2 100644 --- a/calendar-client/src/dialog/schedulectrldlg.cpp +++ b/calendar-client/src/dialog/schedulectrldlg.cpp @@ -7,6 +7,7 @@ #include "scheduledatamanage.h" #include "cdynamicicon.h" #include "constants.h" +#include "commondef.h" #include #include @@ -21,6 +22,7 @@ DGUI_USE_NAMESPACE CScheduleCtrlDlg::CScheduleCtrlDlg(QWidget *parent) : DCalendarDDialog(parent) { + qCDebug(ClientLogger) << "CScheduleCtrlDlg constructor"; setContentsMargins(0, 0, 0, 0); initUI(); initConnection(); @@ -30,6 +32,7 @@ CScheduleCtrlDlg::CScheduleCtrlDlg(QWidget *parent) void CScheduleCtrlDlg::initUI() { + qCDebug(ClientLogger) << "Initializing UI for schedule control dialog"; //在点击任何对话框上的按钮后不关闭对话框,保证关闭子窗口时不被一起关掉 setOnButtonClickedClose(false); QIcon t_icon(CDynamicIcon::getInstance()->getPixmap());// = QIcon::fromTheme("dde-calendar"); @@ -72,10 +75,12 @@ void CScheduleCtrlDlg::initUI() gwi->setPalette(anipa); gwi->setBackgroundRole(DPalette::Window); addContent(gwi, Qt::AlignCenter); + qCDebug(ClientLogger) << "UI initialization complete"; } void CScheduleCtrlDlg::initConnection() { + qCDebug(ClientLogger) << "Initializing connections for schedule control dialog"; //关联主题信号 QObject::connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, @@ -85,6 +90,7 @@ void CScheduleCtrlDlg::initConnection() void CScheduleCtrlDlg::setTheMe(const int type) { + qCDebug(ClientLogger) << "Setting theme for schedule control dialog with type:" << type; //标题文字颜色 QColor titleColor; //提示内容文字颜色 @@ -94,11 +100,13 @@ void CScheduleCtrlDlg::setTheMe(const int type) titleColor.setAlphaF(0.9); contentColor = "#FFFFFF"; contentColor.setAlphaF(0.7); + qCDebug(ClientLogger) << "Using dark theme colors"; } else { titleColor = "#000000"; titleColor.setAlphaF(0.9); contentColor = "#000000"; contentColor.setAlphaF(0.7); + qCDebug(ClientLogger) << "Using light theme colors"; } setPaletteTextColor(m_firstLabel, titleColor); setPaletteTextColor(m_seconLabel, contentColor); @@ -106,9 +114,12 @@ void CScheduleCtrlDlg::setTheMe(const int type) void CScheduleCtrlDlg::setPaletteTextColor(QWidget *widget, QColor textColor) { + qCDebug(ClientLogger) << "Setting palette text color:" << textColor.name(); //如果为空指针则退出 - if (nullptr == widget) + if (nullptr == widget) { + qCWarning(ClientLogger) << "Widget is null, cannot set palette color"; return; + } DPalette palette = widget->palette(); //设置文字显示颜色 palette.setColor(DPalette::WindowText, textColor); @@ -117,6 +128,7 @@ void CScheduleCtrlDlg::setPaletteTextColor(QWidget *widget, QColor textColor) void CScheduleCtrlDlg::changeEvent(QEvent *event) { + qCDebug(ClientLogger) << "Change event with type:" << event->type(); Q_UNUSED(event) QFont font; QFontMetrics font_button(font); @@ -139,6 +151,7 @@ void CScheduleCtrlDlg::changeEvent(QEvent *event) // 在changeEvent里使用setFixedHeight会导致弹出的确认对话框会显示在左上角 // 推测是窗口的问题, 先通过延迟在应用层临时解决 QTimer::singleShot(10, this, [this, height_firstLabel, height_seconLabel]{ + qCDebug(ClientLogger) << "Adjusting dialog height to:" << (36 + 48 + height_firstLabel + height_seconLabel + 30); setFixedHeight(36 + 48 + height_firstLabel + height_seconLabel + 30); gwi->setFixedHeight(height_firstLabel + height_seconLabel); }); @@ -146,12 +159,14 @@ void CScheduleCtrlDlg::changeEvent(QEvent *event) void CScheduleCtrlDlg::buttonJudge(int id) { + qCDebug(ClientLogger) << "Button clicked with id:" << id; m_id = id; accept(); } QAbstractButton *CScheduleCtrlDlg::addPushButton(QString btName, bool type) { + qCDebug(ClientLogger) << "Adding push button:" << btName << "with type:" << type; addButton(btName, false, DDialog::ButtonNormal); int button_index = getButtonIndexByText(btName); QAbstractButton *button = getButton(button_index); @@ -172,6 +187,7 @@ QAbstractButton *CScheduleCtrlDlg::addPushButton(QString btName, bool type) QAbstractButton *CScheduleCtrlDlg::addsuggestButton(QString btName, bool type) { + qCDebug(ClientLogger) << "Adding suggest button:" << btName << "with type:" << type; addButton(btName, false, DDialog::ButtonRecommend); int button_index = getButtonIndexByText(btName); QAbstractButton *suggestButton = getButton(button_index); @@ -192,6 +208,7 @@ QAbstractButton *CScheduleCtrlDlg::addsuggestButton(QString btName, bool type) QAbstractButton *CScheduleCtrlDlg::addWaringButton(QString btName, bool type) { + qCDebug(ClientLogger) << "Adding warning button:" << btName << "with type:" << type; addButton(btName, false, DDialog::ButtonWarning); int button_index = getButtonIndexByText(btName); QAbstractButton *suggestButton = getButton(button_index); @@ -212,18 +229,21 @@ QAbstractButton *CScheduleCtrlDlg::addWaringButton(QString btName, bool type) void CScheduleCtrlDlg::setText(QString str) { + qCDebug(ClientLogger) << "Setting text:" << str; m_firstLabel->setText(str); m_firstLabel->setToolTip(str); } void CScheduleCtrlDlg::setInformativeText(QString str) { + qCDebug(ClientLogger) << "Setting informative text:" << str; m_seconLabel->setText(str); m_seconLabel->setToolTip(str); } int CScheduleCtrlDlg::clickButton() { + qCDebug(ClientLogger) << "Getting clicked button id:" << m_id; if (m_id < 0 || m_id > buttonCount() - 1) return buttonCount(); return m_id; } diff --git a/calendar-client/src/dialog/scheduledlg.cpp b/calendar-client/src/dialog/scheduledlg.cpp index 85075bf86..b77dc62ca 100644 --- a/calendar-client/src/dialog/scheduledlg.cpp +++ b/calendar-client/src/dialog/scheduledlg.cpp @@ -34,6 +34,7 @@ CScheduleDlg::CScheduleDlg(int type, QWidget *parent, const bool isAllDay) : DCalendarDDialog(parent) , m_createAllDay(isAllDay) { + qCDebug(ClientLogger) << "CScheduleDlg::CScheduleDlg, type:" << type << "isAllDay:" << isAllDay; setContentsMargins(0, 0, 0, 0); m_type = type; initUI(); @@ -61,6 +62,7 @@ CScheduleDlg::CScheduleDlg(int type, QWidget *parent, const bool isAllDay) } setFixedSize(dialog_width, 561); if (!gAccountManager->getIsSupportUid()) { + qCDebug(ClientLogger) << "UID not supported, adjusting dialog size"; setFixedSize(dialog_width, 561 - 36); } @@ -70,6 +72,7 @@ CScheduleDlg::CScheduleDlg(int type, QWidget *parent, const bool isAllDay) CScheduleDlg::~CScheduleDlg() { + qCDebug(ClientLogger) << "CScheduleDlg::~CScheduleDlg"; } void CScheduleDlg::setData(const DSchedule::Ptr &info) @@ -104,6 +107,7 @@ void CScheduleDlg::setData(const DSchedule::Ptr &info) } if (m_scheduleDataInfo) { + qCDebug(ClientLogger) << "Setting job type number from schedule data"; m_typeComBox->setCurrentJobTypeNo(m_scheduleDataInfo->scheduleTypeID()); } @@ -134,6 +138,7 @@ void CScheduleDlg::setData(const DSchedule::Ptr &info) void CScheduleDlg::setDate(const QDateTime &date) { + qCDebug(ClientLogger) << "CScheduleDlg::setDate, date:" << date; m_currentDate = date; int hours = date.time().hour(); int minnutes = 0; @@ -144,9 +149,11 @@ void CScheduleDlg::setDate(const QDateTime &date) minnutes = minnutes + (date.time().minute() % DDECalendar::QuarterOfAnhourWithMinute == 0 ? 0 : 15); if (minnutes == 60) { if (hours + 1 == 24) { + qCDebug(ClientLogger) << "Minute is 60, hour is 23, rolling over to next day"; m_currentDate.setTime(QTime(0, 0)); m_currentDate = m_currentDate.addDays(1); } else { + qCDebug(ClientLogger) << "Minute is 60, incrementing hour"; m_currentDate.setTime(QTime(hours + 1, 0)); } } else { @@ -166,6 +173,7 @@ void CScheduleDlg::setDate(const QDateTime &date) void CScheduleDlg::setAllDay(bool flag) { + qCDebug(ClientLogger) << "CScheduleDlg::setAllDay, flag:" << flag; m_allDayCheckbox->setChecked(flag); } @@ -175,6 +183,7 @@ void CScheduleDlg::setAllDay(bool flag) */ bool CScheduleDlg::clickOkBtn() { + qCDebug(ClientLogger) << "CScheduleDlg::clickOkBtn"; return selectScheduleType(); } @@ -185,8 +194,10 @@ bool CScheduleDlg::clickOkBtn() */ bool CScheduleDlg::selectScheduleType() { + qCDebug(ClientLogger) << "CScheduleDlg::selectScheduleType"; //编辑状态,需要创建日程 if (m_typeComBox->isEditable()) { + qCDebug(ClientLogger) << "Type combobox is editable, creating new schedule type"; DScheduleType::Ptr type; type.reset(new DScheduleType()); type->setTypeID("0"); @@ -197,9 +208,11 @@ bool CScheduleDlg::selectScheduleType() //创建日程类型,等待回调 m_accountItem->createJobType(type, [&](CallMessge call) { if (call.code == 0) { + qCDebug(ClientLogger) << "Successfully created job type, creating schedule with new type"; //返回值为日程类型id createSchedule(call.msg.toString()); } else { + qCWarning(ClientLogger) << "Failed to create job type, error code:" << call.code; m_bCanCreateType = true; } //关闭本弹窗 @@ -208,9 +221,11 @@ bool CScheduleDlg::selectScheduleType() } } else if (m_typeComBox->currentIndex() >= 0) { + qCDebug(ClientLogger) << "Type combobox is not editable, using existing schedule type"; //选择已有日程,直接创建日程 return createSchedule(m_typeComBox->getCurrentJobTypeNo()); } + qCWarning(ClientLogger) << "No schedule type selected, cannot create schedule"; return false; } @@ -253,8 +268,10 @@ bool CScheduleDlg::createSchedule(const QString &scheduleTypeId) } if (m_textEdit->toPlainText().isEmpty()) { + qCDebug(ClientLogger) << "Using placeholder text for summary"; schedule->setSummary(m_textEdit->placeholderText()); } else { + qCDebug(ClientLogger) << "Using user-entered text for summary"; schedule->setSummary(m_textEdit->toPlainText().trimmed()); } @@ -342,6 +359,7 @@ bool CScheduleDlg::createSchedule(const QString &scheduleTypeId) qCDebug(ClientLogger) << "Updating existing schedule:" << schedule->summary(); //如果有重复规则则将原来数据的忽略列表添加进来 if (schedule->recurs() && m_scheduleDataInfo->recurs()) { + qCDebug(ClientLogger) << "Copying exDates from old schedule"; schedule->recurrence()->setExDateTimes(m_scheduleDataInfo->recurrence()->exDateTimes()); } res = _scheduleOperation.changeSchedule(schedule, m_scheduleDataInfo); @@ -351,6 +369,7 @@ bool CScheduleDlg::createSchedule(const QString &scheduleTypeId) void CScheduleDlg::updateEndTimeListAndTimeDiff(const QDateTime &begin, const QDateTime &end) { + qCDebug(ClientLogger) << "CScheduleDlg::updateEndTimeListAndTimeDiff, begin:" << begin << "end:" << end; //更新是否超过一天标识 updateIsOneMoreDay(begin, end); m_timeDiff = begin.msecsTo(end); @@ -361,14 +380,18 @@ void CScheduleDlg::updateEndTimeListAndTimeDiff(const QDateTime &begin, const QD void CScheduleDlg::updateEndTimeList(const QTime &begin, bool isShowTimeInterval) { + qCDebug(ClientLogger) << "CScheduleDlg::updateEndTimeList, begin time:" << begin << "show interval:" << isShowTimeInterval; m_endTimeEdit->setMineTime(begin); m_endTimeEdit->updateListItem(isShowTimeInterval); } void CScheduleDlg::slotBeginTimeChange() { - if (m_currentDate.time() == m_beginTimeEdit->getTime()) + qCDebug(ClientLogger) << "CScheduleDlg::slotBeginTimeChange"; + if (m_currentDate.time() == m_beginTimeEdit->getTime()) { + qCDebug(ClientLogger) << "Begin time not changed, returning"; return; + } //根据联动修改结束时间下拉列表内容和结束时间 m_currentDate.setTime(m_beginTimeEdit->getTime()); m_EndDate = m_currentDate.addMSecs(m_timeDiff); @@ -382,7 +405,9 @@ void CScheduleDlg::slotBeginTimeChange() void CScheduleDlg::slotEndTimeChange() { + qCDebug(ClientLogger) << "CScheduleDlg::slotEndTimeChange"; if (m_EndDate.time() == m_endTimeEdit->getTime()) { + qCDebug(ClientLogger) << "End time not changed, returning"; return; } m_EndDate.setTime(m_endTimeEdit->getTime()); @@ -392,8 +417,10 @@ void CScheduleDlg::slotEndTimeChange() //如果时间小于一天则需要根据结束时间(time)是否大于开始时间判断计算结束日期 QTime endTime = m_endTimeEdit->getTime(); if (endTime < m_currentDate.time()) { + qCDebug(ClientLogger) << "End time is earlier than start time, setting end date to next day"; m_EndDate.setDate(m_currentDate.date().addDays(1)); } else { + qCDebug(ClientLogger) << "End time is on the same day as start time"; m_EndDate.setDate(m_currentDate.date()); } m_endDateEdit->setDate(m_EndDate.date()); @@ -403,12 +430,16 @@ void CScheduleDlg::slotEndTimeChange() void CScheduleDlg::slotEndDateChange(const QDate &date) { - if (m_EndDate.date() == date) + qCDebug(ClientLogger) << "CScheduleDlg::slotEndDateChange, date:" << date; + if (m_EndDate.date() == date) { + qCDebug(ClientLogger) << "End date not changed, returning"; return; + } //修改联动时间和结束时间下拉列表内容 m_EndDate.setDate(date); // 如果开始时间晚于结束时间,则将结束时间修改为开始时间 if (m_currentDate.msecsTo(m_EndDate) < 0) { + qCDebug(ClientLogger) << "End date is before start date, adjusting end datetime"; m_EndDate = m_currentDate; } updateEndTimeListAndTimeDiff(m_currentDate, m_EndDate); @@ -416,11 +447,13 @@ void CScheduleDlg::slotEndDateChange(const QDate &date) void CScheduleDlg::slotBtClick(int buttonIndex, const QString &buttonName) { + qCDebug(ClientLogger) << "CScheduleDlg::slotBtClick, buttonIndex:" << buttonIndex << "buttonName:" << buttonName; Q_UNUSED(buttonName) //是否隐藏对话框 switch (buttonIndex) { case 0: { //取消 + qCDebug(ClientLogger) << "Cancel button clicked"; close(); break; } @@ -429,6 +462,7 @@ void CScheduleDlg::slotBtClick(int buttonIndex, const QString &buttonName) //自动化测试会出现短时间内按钮click2次的情况。添加第一次触发后将保存按钮置灰的设置。 //若保存按钮不启用则不处理 if (getButton(1)->isEnabled() && !this->isHidden()) { + qCDebug(ClientLogger) << "OK button clicked"; m_setAccept = clickOkBtn(); //若新建或编辑成功则将保存按钮置灰 getButton(1)->setEnabled(!m_setAccept); @@ -450,6 +484,7 @@ void CScheduleDlg::slotBtClick(int buttonIndex, const QString &buttonName) void CScheduleDlg::slotTextChange() { + qCDebug(ClientLogger) << "Text content changed"; QString textContent = m_textEdit->toPlainText(); int length = textContent.count(); QString tStitlename = textContent; @@ -457,6 +492,7 @@ void CScheduleDlg::slotTextChange() int maxLength = 256; // 最大字符数 //去除回车字符 if (tStitlename.contains("\n")) { + qCDebug(ClientLogger) << "Removing newline characters from text"; //设置纯文本显示原始内容 tStitlename.replace("\n", ""); m_textEdit->setPlainText(tStitlename); @@ -467,6 +503,7 @@ void CScheduleDlg::slotTextChange() } //如果长度大于最大长度则显示原来的字符 if (length > maxLength) { + qCWarning(ClientLogger) << "Text exceeds maximum length:" << length << ">" << maxLength; m_textEdit->setPlainText(m_context); //将焦点移动到最后 m_textEdit->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor); @@ -480,17 +517,20 @@ void CScheduleDlg::slotTextChange() void CScheduleDlg::slotendrepeatTextchange() { + qCDebug(ClientLogger) << "Repeat end text changed"; setOkBtnEnabled(); } void CScheduleDlg::slotBDateEidtInfo(const QDate &date) { + qCDebug(ClientLogger) << "Begin date changed to:" << date; m_endRepeatDate->setMinimumDate(date); m_endDateEdit->setMinimumDate(date); m_currentDate.setDate(m_beginDateEdit->date()); m_EndDate.setDate(m_endDateEdit->date()); if (m_EndDate < m_currentDate) { + qCDebug(ClientLogger) << "End date < begin date, adjusting end time"; m_endTimeEdit->setTime(m_beginTimeEdit->getTime().addSecs(3600)); m_EndDate.setTime(m_endTimeEdit->getTime()); } @@ -500,9 +540,11 @@ void CScheduleDlg::slotBDateEidtInfo(const QDate &date) void CScheduleDlg::slotallDayStateChanged(int state) { + qCDebug(ClientLogger) << "All day state changed to:" << state; m_rmindCombox->clear(); if (!state) { + qCDebug(ClientLogger) << "Setting up time-specific reminder options"; m_rmindCombox->addItem(tr("Never")); m_rmindCombox->addItem(tr("At time of event")); m_rmindCombox->addItem(tr("15 minutes before")); @@ -516,22 +558,26 @@ void CScheduleDlg::slotallDayStateChanged(int state) m_endTimeEdit->setVisible(true); if (m_type == 0) { + qCDebug(ClientLogger) << "Restoring edit mode time values"; m_beginDateEdit->setDate(m_scheduleDataInfo->dtStart().date()); m_beginTimeEdit->setTime(m_scheduleDataInfo->dtStart().time()); m_endDateEdit->setDate(m_scheduleDataInfo->dtEnd().date()); m_endTimeEdit->setTime(m_scheduleDataInfo->dtEnd().time()); if (m_scheduleDataInfo->dtStart().time() == m_scheduleDataInfo->dtEnd().time() && m_scheduleDataInfo->dtEnd().time().toString() == "00:00:00") { + qCDebug(ClientLogger) << "Adjusting end time to end of day for zero time"; m_endTimeEdit->setTime(QTime(23, 59, 59)); } } else { + qCDebug(ClientLogger) << "Setting new mode time values"; 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 { + qCDebug(ClientLogger) << "Setting up all-day reminder options"; m_rmindCombox->addItem(tr("Never")); m_rmindCombox->addItem(tr("On start day (9:00 AM)")); m_rmindCombox->addItem(tr("1 day before")); @@ -542,11 +588,13 @@ void CScheduleDlg::slotallDayStateChanged(int state) m_endTimeEdit->setVisible(false); if (m_type == 0) { + qCDebug(ClientLogger) << "Setting edit mode all-day time values"; m_beginDateEdit->setDate(m_scheduleDataInfo->dtStart().date()); m_beginTimeEdit->setTime(QTime(0, 0)); m_endDateEdit->setDate(m_scheduleDataInfo->dtEnd().date()); m_endTimeEdit->setTime(QTime(23, 59)); } else { + qCDebug(ClientLogger) << "Setting new mode all-day time values"; m_beginDateEdit->setDate(m_currentDate.date()); m_endDateEdit->setDate(m_EndDate.date()); m_beginTimeEdit->setTime(QTime(0, 0)); @@ -557,9 +605,12 @@ void CScheduleDlg::slotallDayStateChanged(int state) void CScheduleDlg::slotbRpeatactivated(int index) { + qCDebug(ClientLogger) << "Begin repeat activated with index:" << index; if (index > 0) { + qCDebug(ClientLogger) << "Showing end repeat widget for repeat mode"; m_endrepeatWidget->setVisible(true); } else { + qCDebug(ClientLogger) << "Hiding end repeat widget for no-repeat mode"; m_endrepeatWidget->setVisible(false); } //不论重复日程选哪种模式,结束重复都是从不 @@ -571,10 +622,13 @@ void CScheduleDlg::slotbRpeatactivated(int index) void CScheduleDlg::sloteRpeatactivated(int index) { + qCDebug(ClientLogger) << "End repeat activated with index:" << index; if (index == 0) { + qCDebug(ClientLogger) << "Hiding repeat time settings for never-end mode"; m_endrepeattimesWidget->setVisible(false); m_endRepeatDate->setVisible(false); } else if (index == 1) { + qCDebug(ClientLogger) << "Showing repeat count settings for count-based end mode"; m_endrepeattimesWidget->setVisible(true); m_endRepeatDate->setVisible(false); QFont mlabelF; @@ -584,6 +638,7 @@ void CScheduleDlg::sloteRpeatactivated(int index) m_endrepeattimesLabel->width()); m_endrepeattimesLabel->setText(endrepeattimesStr); } else { + qCDebug(ClientLogger) << "Showing date picker for date-based end mode"; m_endrepeattimesWidget->setVisible(false); m_endRepeatDate->setVisible(true); m_endRepeatDate->setEditCursorPos(0); @@ -593,8 +648,10 @@ void CScheduleDlg::sloteRpeatactivated(int index) void CScheduleDlg::slotJobComboBoxEditingFinished() { + qCDebug(ClientLogger) << "Job combo box editing finished"; if (m_typeComBox->lineEdit()->text().isEmpty()) { //名称为空 + qCDebug(ClientLogger) << "Empty job name, showing alert"; m_typeComBox->showAlertMessage(tr("Enter a name please")); m_typeComBox->setAlert(true); } @@ -602,6 +659,7 @@ void CScheduleDlg::slotJobComboBoxEditingFinished() void CScheduleDlg::slotAccoutBoxActivated(const QString &text) { + qCDebug(ClientLogger) << "Account selected:" << text; m_accountItem = gAccountManager->getAccountItemByAccountName(text); m_typeComBox->updateJobType(m_accountItem); resetColor(m_accountItem); @@ -629,12 +687,15 @@ void CScheduleDlg::signalLogout(DAccount::Type type) void CScheduleDlg::slotTypeRpeatactivated(int index) { + qCDebug(ClientLogger) << "CScheduleDlg::slotTypeRpeatactivated, index:" << index; Q_UNUSED(index); if (m_typeComBox->isEditable()) { + qCDebug(ClientLogger) << "Type combobox is editable, showing color selector"; m_typeComBox->setIconSize(QSize(0, 0)); m_colorSeletorWideget->show(); } else { //若下拉选择隐藏提醒消息 + qCDebug(ClientLogger) << "Type combobox is not editable, hiding color selector"; m_typeComBox->hideAlertMessage(); m_typeComBox->setIconSize(QSize(16, 16)); m_typeEditStatus = false; @@ -647,8 +708,10 @@ void CScheduleDlg::slotTypeRpeatactivated(int index) void CScheduleDlg::slotRadioBtnClicked(int btnId) { + qCDebug(ClientLogger) << "CScheduleDlg::slotRadioBtnClicked, btnId:" << btnId; //与上一次选项一致不做重置处理 if (m_prevCheckRadioID == btnId) { + qCDebug(ClientLogger) << "Radio button not changed, returning"; return; } m_prevCheckRadioID = btnId; @@ -660,6 +723,7 @@ void CScheduleDlg::slotRadioBtnClicked(int btnId) void CScheduleDlg::slotBtnAddItemClicked() { + qCDebug(ClientLogger) << "CScheduleDlg::slotBtnAddItemClicked"; m_colorSeletorWideget->show(); m_typeEditStatus = true; //添加日程类型的时候需要判断保存按钮是否可用 @@ -669,12 +733,15 @@ void CScheduleDlg::slotBtnAddItemClicked() void CScheduleDlg::slotTypeEditTextChanged(const QString &text) { + qCDebug(ClientLogger) << "CScheduleDlg::slotTypeEditTextChanged, text:" << text; if (!m_typeEditStatus) { + qCDebug(ClientLogger) << "Type edit not active, returning"; return; } QString tStitlename = text; //去除回车字符 if (tStitlename.contains("\n")) { + qCDebug(ClientLogger) << "Removing newline from type text"; //设置纯文本显示原始内容 tStitlename.replace("\n", ""); m_typeComBox->setEditText(tStitlename); @@ -682,6 +749,7 @@ void CScheduleDlg::slotTypeEditTextChanged(const QString &text) } //最大限制20个字符,超出后过滤掉 if (tStitlename.length() > 20) { + qCWarning(ClientLogger) << "Type text exceeds max length, reverting"; m_typeComBox->setEditText(m_TypeContext); return; } else { @@ -689,12 +757,14 @@ void CScheduleDlg::slotTypeEditTextChanged(const QString &text) } //如果内容不为空且去除空格内容为空表示为全空格 if (!tStitlename.isEmpty() && tStitlename.trimmed().isEmpty()) { + qCDebug(ClientLogger) << "Type text contains only whitespace, showing alert"; //名称为全空格,返回 m_typeComBox->showAlertMessage(tr("The name can not only contain whitespaces")); m_typeComBox->setAlert(true); } else { //如果日程类型编辑框存在焦点(没有编辑结束)且有警告则取消警告和提示信息 if (m_typeComBox->hasFocus() && m_typeComBox->isAlert()) { + qCDebug(ClientLogger) << "Hiding type combobox alert"; m_typeComBox->hideAlertMessage(); m_typeComBox->setAlert(false); } @@ -723,6 +793,7 @@ bool CScheduleDlg::eventFilter(QObject *obj, QEvent *pEvent) void CScheduleDlg::showEvent(QShowEvent *event) { + // qCDebug(ClientLogger) << "CScheduleDlg::showEvent"; DDialog::showEvent(event); //更新窗口大小 resize(); @@ -730,17 +801,21 @@ void CScheduleDlg::showEvent(QShowEvent *event) void CScheduleDlg::closeEvent(QCloseEvent *event) { + // qCDebug(ClientLogger) << "CScheduleDlg::closeEvent"; DDialog::closeEvent(event); //如果为true 这设置返回值为Accepted 否则设置为Rejected if (m_setAccept) { + qCDebug(ClientLogger) << "Dialog accepted"; accept(); } else { + qCDebug(ClientLogger) << "Dialog rejected"; reject(); } } void CScheduleDlg::changeEvent(QEvent *event) { + // qCDebug(ClientLogger) << "CScheduleDlg::changeEvent, type:" << event->type(); Q_UNUSED(event); QFont mlabelF; mlabelF.setWeight(QFont::Medium); @@ -799,6 +874,7 @@ void CScheduleDlg::changeEvent(QEvent *event) */ void CScheduleDlg::updateDateTimeFormat() { + qCDebug(ClientLogger) << "CScheduleDlg::updateDateTimeFormat"; m_beginDateEdit->setDisplayFormat(m_dateFormat); m_endDateEdit->setDisplayFormat(m_dateFormat); m_endRepeatDate->setDisplayFormat(m_dateFormat); @@ -806,6 +882,7 @@ void CScheduleDlg::updateDateTimeFormat() void CScheduleDlg::initUI() { + qCDebug(ClientLogger) << "CScheduleDlg::initUI"; const int label_Fixed_Width = 78; const int item_Fixed_Height = 36; @@ -854,6 +931,7 @@ void CScheduleDlg::initUI() widget->setFixedHeight(item_Fixed_Height); maintlayout->addWidget(widget); if (!gAccountManager->getIsSupportUid()) { + qCDebug(ClientLogger) << "UID not supported, hiding account widget"; widget->hide(); } } @@ -1247,6 +1325,7 @@ void CScheduleDlg::initUI() void CScheduleDlg::initConnection() { + qCDebug(ClientLogger) << "CScheduleDlg::initConnection"; QObject::connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &CScheduleDlg::setTheMe); @@ -1284,6 +1363,7 @@ void CScheduleDlg::initConnection() void CScheduleDlg::slotAccountUpdate() { + qCDebug(ClientLogger) << "CScheduleDlg::slotAccountUpdate"; m_accountComBox->clear(); QList accountList = gAccountManager->getAccountList(); for (AccountItem::Ptr p : accountList) { @@ -1298,11 +1378,13 @@ void CScheduleDlg::slotAccountUpdate() */ void CScheduleDlg::slotAccountStateChange() { + qCDebug(ClientLogger) << "CScheduleDlg::slotAccountStateChange"; setShowState(m_lunarRadioBtn->isChecked()); } void CScheduleDlg::initDateEdit() { + qCDebug(ClientLogger) << "CScheduleDlg::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天 @@ -1312,6 +1394,7 @@ void CScheduleDlg::initDateEdit() void CScheduleDlg::initJobTypeComboBox() { + qCDebug(ClientLogger) << "CScheduleDlg::initJobTypeComboBox"; m_accountItem = gAccountManager->getAccountItemByAccountName(m_accountComBox->currentText()); m_typeComBox->updateJobType(m_accountItem); resetColor(m_accountItem); @@ -1319,15 +1402,19 @@ void CScheduleDlg::initJobTypeComboBox() void CScheduleDlg::initRmindRpeatUI() { + qCDebug(ClientLogger) << "CScheduleDlg::initRmindRpeatUI"; //提醒规则 if (m_scheduleDataInfo->allDay()) { + qCDebug(ClientLogger) << "Setting reminder for all-day event"; m_rmindCombox->setCurrentIndex(m_scheduleDataInfo->getAlarmType() - 8); } else { + qCDebug(ClientLogger) << "Setting reminder for timed event"; m_rmindCombox->setCurrentIndex(m_scheduleDataInfo->getAlarmType()); } //重复规则 if (m_scheduleDataInfo->lunnar()) { + qCDebug(ClientLogger) << "Setting repeat rule for lunar event"; //如果为农历 switch (m_scheduleDataInfo->getRRuleType()) { case DSchedule::RRule_Month: @@ -1342,18 +1429,22 @@ void CScheduleDlg::initRmindRpeatUI() } } else { + qCDebug(ClientLogger) << "Setting repeat rule for solar event"; //如果为公历 m_beginrepeatCombox->setCurrentIndex(m_scheduleDataInfo->getRRuleType()); } slotbRpeatactivated(m_beginrepeatCombox->currentIndex()); if (m_scheduleDataInfo->recurrence()->duration() < 0) { + qCDebug(ClientLogger) << "Setting repeat end to 'Never'"; //永不 m_endrepeatCombox->setCurrentIndex(0); } else if (m_scheduleDataInfo->recurrence()->duration() == 0) { + qCDebug(ClientLogger) << "Setting repeat end to date"; //结束于日期 m_endrepeatCombox->setCurrentIndex(2); m_endRepeatDate->setDate(m_scheduleDataInfo->recurrence()->endDateTime().date()); } else { + qCDebug(ClientLogger) << "Setting repeat end to count"; //结束与次数 m_endrepeatCombox->setCurrentIndex(1); m_endrepeattimes->setText(QString::number(m_scheduleDataInfo->recurrence()->duration() - 1)); @@ -1363,11 +1454,14 @@ void CScheduleDlg::initRmindRpeatUI() void CScheduleDlg::setTheMe(const int type) { + qCDebug(ClientLogger) << "CScheduleDlg::setTheMe, theme type:" << type; //日程标题编辑框文字颜色 QColor titleColor; if (type == 2) { + qCDebug(ClientLogger) << "Using dark theme text color"; titleColor = "#C0C6D4"; } else { + qCDebug(ClientLogger) << "Using light theme text color"; titleColor = "#414D68"; } DPalette pa = m_textEdit->palette(); @@ -1382,6 +1476,7 @@ void CScheduleDlg::setTheMe(const int type) */ void CScheduleDlg::setTabFouseOrder() { + qCDebug(ClientLogger) << "CScheduleDlg::setTabFouseOrder"; setTabOrder(m_typeComBox, m_textEdit); setTabOrder(m_textEdit, m_allDayCheckbox); setTabOrder(m_allDayCheckbox, m_solarRadioBtn); @@ -1396,10 +1491,13 @@ void CScheduleDlg::setTabFouseOrder() //结束于次数,设置tab顺序 //如果为重复日程 if (!m_scheduleDataInfo.isNull() && m_scheduleDataInfo->getRRuleType() != DSchedule::RRule_None) { + qCDebug(ClientLogger) << "Setting tab order for repeat schedule"; //如果为结束于次数 if (m_scheduleDataInfo->recurrence()->duration() > 0) { + qCDebug(ClientLogger) << "Setting tab order for repeat count"; setTabOrder(m_endrepeatCombox, m_endrepeattimes); } else if (m_scheduleDataInfo->recurrence()->duration() == 0) { + qCDebug(ClientLogger) << "Setting tab order for repeat end date"; setTabOrder(m_endrepeatCombox, m_endRepeatDate); } } @@ -1407,22 +1505,28 @@ void CScheduleDlg::setTabFouseOrder() void CScheduleDlg::updateIsOneMoreDay(const QDateTime &begin, const QDateTime &end) { + qCDebug(ClientLogger) << "Checking if event spans more than one day"; // 一天毫秒数 static qint64 oneDayMses = 24 * 60 * 60 * 1000; m_isMoreThenOneDay = begin.msecsTo(end) >= oneDayMses; + qCDebug(ClientLogger) << "Event spans more than one day:" << m_isMoreThenOneDay; } void CScheduleDlg::updateRepeatCombox(bool isLunar) { + qCDebug(ClientLogger) << "Updating repeat combo box for lunar mode:" << isLunar; if (nullptr == m_beginrepeatCombox) { + qCWarning(ClientLogger) << "Repeat combo box is null, cannot update"; return; } m_beginrepeatCombox->clear(); if (isLunar) { + qCDebug(ClientLogger) << "Setting lunar repeat options"; m_beginrepeatCombox->addItem(tr("Never")); m_beginrepeatCombox->addItem(tr("Monthly")); m_beginrepeatCombox->addItem(tr("Yearly")); } else { + qCDebug(ClientLogger) << "Setting solar repeat options"; m_beginrepeatCombox->addItem(tr("Never")); m_beginrepeatCombox->addItem(tr("Daily")); m_beginrepeatCombox->addItem(tr("Weekdays")); @@ -1442,7 +1546,9 @@ void CScheduleDlg::updateRepeatCombox(bool isLunar) */ bool CScheduleDlg::isShowLunar() { - return QLocale::system().name().startsWith("zh_"); + bool result = QLocale::system().name().startsWith("zh_"); + // qCDebug(ClientLogger) << "Checking if lunar calendar should be shown based on locale:" << result; + return result; } /** @@ -1453,24 +1559,28 @@ bool CScheduleDlg::isShowLunar() */ void CScheduleDlg::setShowState(bool jobIsLunar) { + qCDebug(ClientLogger) << "Setting show state for lunar mode:" << jobIsLunar; m_solarRadioBtn->setEnabled(true); m_lunarRadioBtn->setEnabled(true); setWidgetEnabled(true); getButton(1)->setEnabled(true); if (!m_accountItem || !m_accountItem->isCanSyncShedule()) { //不可同步日程,除帐户选择外其他的控件都置灰 + qCDebug(ClientLogger) << "Account cannot sync schedule, disabling controls"; m_solarRadioBtn->setEnabled(false); m_lunarRadioBtn->setEnabled(false); setWidgetEnabled(false); getButton(1)->setEnabled(false); } else if (isShowLunar()) { //如果不显示农历 + qCDebug(ClientLogger) << "Locale supports lunar calendar, enabling lunar radio button"; m_lunarRadioBtn->setEnabled(true); m_beginDateEdit->setLunarCalendarStatus(jobIsLunar); m_endDateEdit->setLunarCalendarStatus(jobIsLunar); m_endRepeatDate->setLunarCalendarStatus(jobIsLunar); } else { //在不显示农历环境下,取消农历显示 + qCDebug(ClientLogger) << "Locale doesn't support lunar calendar, disabling lunar features"; m_beginDateEdit->setLunarCalendarStatus(false); m_endDateEdit->setLunarCalendarStatus(false); m_endRepeatDate->setLunarCalendarStatus(false); @@ -1484,15 +1594,18 @@ void CScheduleDlg::setShowState(bool jobIsLunar) if (jobIsLunar) { //为农历日程 + qCDebug(ClientLogger) << "Setting lunar radio button checked"; m_lunarRadioBtn->setChecked(true); } else { //公历日程 + qCDebug(ClientLogger) << "Setting solar radio button checked"; m_solarRadioBtn->setChecked(true); } } void CScheduleDlg::setWidgetEnabled(bool isEnabled) { + qCDebug(ClientLogger) << "Setting all form widgets enabled:" << isEnabled; m_typeComBox->setEnabled(isEnabled); m_textEdit->setEnabled(isEnabled); m_allDayCheckbox->setEnabled(isEnabled); @@ -1509,10 +1622,12 @@ void CScheduleDlg::setWidgetEnabled(bool isEnabled) void CScheduleDlg::resetColor(const AccountItem::Ptr &account) { + qCDebug(ClientLogger) << "Resetting color selector for account"; m_colorSeletorWideget->resetColorButton(account); //将用户上一次选择的自定义颜色添加进去 QString colorName = CConfigSettings::getInstance()->value("LastUserColor", "").toString(); if (!colorName.isEmpty()) { + qCDebug(ClientLogger) << "Setting last user custom color:" << colorName; //设置颜色 DTypeColor::Ptr typeColor; typeColor.reset(new DTypeColor); @@ -1520,21 +1635,26 @@ void CScheduleDlg::resetColor(const AccountItem::Ptr &account) typeColor->setPrivilege(DTypeColor::PriUser); m_colorSeletorWideget->setUserColor(typeColor); } + //选中上一次选中的颜色 QVariant colorId = CConfigSettings::getInstance()->value("LastSysColorTypeNo", -1); int colorNum = 0; if (colorId.type() == QVariant::Int) { //如果是int型表示为旧颜色编号 colorNum = colorId.toInt(); + qCDebug(ClientLogger) << "Using legacy color number:" << colorNum; } else { QString &&colorIdStr = colorId.toString(); //如果都为空表示为初始状态,则选中第一个 if (colorName.isEmpty() && colorIdStr.isEmpty()) { + qCDebug(ClientLogger) << "No saved color preferences, using default color"; colorNum = -1; } else if (!colorIdStr.isEmpty()) { //如果颜色id不为空则表示颜色为内置颜色 colorNum = GTypeColor.keys().indexOf(colorIdStr); + qCDebug(ClientLogger) << "Using built-in color with ID:" << colorIdStr << "index:" << colorNum; } else { + qCDebug(ClientLogger) << "Using user custom color (index 9)"; colorNum = 9; } } @@ -1543,30 +1663,37 @@ void CScheduleDlg::resetColor(const AccountItem::Ptr &account) void CScheduleDlg::resize() { + qCDebug(ClientLogger) << "Resizing dialog based on visible widgets"; int h = 0; if (m_endrepeatWidget->isVisible()) { + qCDebug(ClientLogger) << "End repeat widget visible, adding height"; h += 36 + 10; } if (m_colorSeletorWideget->isVisible()) { + qCDebug(ClientLogger) << "Color selector widget visible, adding height"; h += 18 + 10; } if (!gAccountManager->getIsSupportUid()) { + qCDebug(ClientLogger) << "UID not supported, reducing height"; h -= 36; } //573: 默认界面高度, h: 新增控件高度 + qCDebug(ClientLogger) << "Setting dialog size:" << dialog_width << "x" << (573 + h); setFixedSize(dialog_width, 573 + h); } void CScheduleDlg::setOkBtnEnabled() { + qCDebug(ClientLogger) << "Checking if OK button should be enabled"; QAbstractButton *m_OkBt = getButton(1); //根据类型输入框的内容判断保存按钮是否有效 if (m_OkBt != nullptr && m_typeComBox->lineEdit() != nullptr) { const QString &typeStr = m_typeComBox->lineEdit()->text(); if (typeStr.isEmpty() || typeStr.trimmed().isEmpty()) { + qCDebug(ClientLogger) << "Type text is empty, disabling OK button"; m_OkBt->setEnabled(false); //若内容无效直接退出,不判断结束次数是否为空 return; @@ -1576,15 +1703,20 @@ void CScheduleDlg::setOkBtnEnabled() } //如果结束与次数为空,则保存按钮置灰 if (m_beginrepeatCombox->currentIndex() > 0 && m_endrepeatCombox->currentIndex() == 1) { - m_OkBt->setEnabled(!m_endrepeattimes->text().isEmpty()); + bool enabled = !m_endrepeattimes->text().isEmpty(); + qCDebug(ClientLogger) << "Repeat count mode, setting OK button enabled:" << enabled; + m_OkBt->setEnabled(enabled); } else { //日期 //永不 + qCDebug(ClientLogger) << "Repeat date/never mode, enabling OK button"; m_OkBt->setEnabled(true); } if (!m_textEdit->toPlainText().isEmpty() && m_textEdit->toPlainText().trimmed().isEmpty()) { + qCDebug(ClientLogger) << "Description text contains only whitespace, disabling OK button"; m_OkBt->setEnabled(false); } else { + qCDebug(ClientLogger) << "Description text valid, enabling OK button"; m_OkBt->setEnabled(true); } } diff --git a/calendar-client/src/dialog/scheduletypeeditdlg.cpp b/calendar-client/src/dialog/scheduletypeeditdlg.cpp index 7c333ed7a..0f7fddb3a 100644 --- a/calendar-client/src/dialog/scheduletypeeditdlg.cpp +++ b/calendar-client/src/dialog/scheduletypeeditdlg.cpp @@ -22,6 +22,7 @@ ScheduleTypeEditDlg::ScheduleTypeEditDlg(QWidget *parent) , m_title(tr("New event type")) , m_dialogType(DialogNewType) { + qCDebug(ClientLogger) << "Creating new schedule type dialog"; init(); } @@ -32,6 +33,7 @@ ScheduleTypeEditDlg::ScheduleTypeEditDlg(const DScheduleType &jobTypeOld, QWidge , m_title(tr("Edit event type")) , m_dialogType(DialogEditType) { + qCDebug(ClientLogger) << "Creating edit schedule type dialog for:" << jobTypeOld.displayName(); init(); } @@ -114,6 +116,7 @@ void ScheduleTypeEditDlg::setAccount(AccountItem::Ptr account) void ScheduleTypeEditDlg::init() { + qCDebug(ClientLogger) << "Initializing schedule type dialog"; initView(); initData(); //默认焦点在日程名称输入框中 @@ -125,10 +128,12 @@ void ScheduleTypeEditDlg::init() // 在编辑框变动时,设置确认按钮状态 connect(m_lineEdit, &DLineEdit::textChanged, this, &ScheduleTypeEditDlg::slotCheckConfirmBtn); connect(m_fileEdit, &DLineEdit::textChanged, this, &ScheduleTypeEditDlg::slotCheckConfirmBtn); + qCDebug(ClientLogger) << "Schedule type dialog initialized"; } void ScheduleTypeEditDlg::initView() { + qCDebug(ClientLogger) << "Initializing schedule type dialog view"; setFixedSize(QSize(400, 220)); m_titleLabel = new QLabel(this); @@ -152,6 +157,7 @@ void ScheduleTypeEditDlg::initView() formLayout->addRow(tr("Color:"), m_colorSeletor); if (m_dialogType == DialogImportType){ + qCDebug(ClientLogger) << "Setting up ICS import form"; setFixedSize(QSize(400, 300)); auto icsLabel = new QLabel(tr("ICS File:"), this); icsLabel->setOpenExternalLinks(true); @@ -172,14 +178,19 @@ void ScheduleTypeEditDlg::initView() } connect(this->getButton(0), &QPushButton::clicked, this, &ScheduleTypeEditDlg::slotBtnCancel); connect(this->getButton(1), &QPushButton::clicked, this, &ScheduleTypeEditDlg::slotBtnNext); + qCDebug(ClientLogger) << "Schedule type dialog view initialized"; } void ScheduleTypeEditDlg::initData() { + qCDebug(ClientLogger) << "Initializing schedule type dialog data"; m_titleLabel->setText(m_title); m_lineEdit->setText(m_jobTypeOld.displayName()); m_typeText = m_jobTypeOld.displayName(); //编辑时要初始化数据 - this->getButton(1)->setEnabled(!m_jobTypeOld.displayName().isEmpty()); //如果是新增,则保存按钮默认不可用 + + bool saveEnabled = !m_jobTypeOld.displayName().isEmpty(); + this->getButton(1)->setEnabled(saveEnabled); //如果是新增,则保存按钮默认不可用 + qCDebug(ClientLogger) << "Save button initial state:" << (saveEnabled ? "enabled" : "disabled"); } void ScheduleTypeEditDlg::slotEditTextChanged(const QString &strName) @@ -230,8 +241,10 @@ void ScheduleTypeEditDlg::slotEditTextChanged(const QString &strName) void ScheduleTypeEditDlg::slotFocusChanged(bool onFocus) { + qCDebug(ClientLogger) << "Focus changed, has focus:" << onFocus; //如果焦点移出,且输入内容为空 if (!onFocus && m_lineEdit->text().isEmpty()) { + qCDebug(ClientLogger) << "Focus lost with empty text, triggering editing finished"; // emit m_lineEdit->textChanged(""); emit m_lineEdit->editingFinished(); } @@ -239,19 +252,23 @@ void ScheduleTypeEditDlg::slotFocusChanged(bool onFocus) void ScheduleTypeEditDlg::slotBtnCancel() { + qCDebug(ClientLogger) << "Cancel button clicked, rejecting dialog"; this->reject(); } void ScheduleTypeEditDlg::slotBtnNext() { + qCDebug(ClientLogger) << "Save button clicked, setting color and accepting dialog"; m_jobTypeNew.setTypeColor(*m_colorSeletor->getSelectedColorInfo()); this->accept(); } void ScheduleTypeEditDlg::slotEditingFinished() { + qCDebug(ClientLogger) << "Editing finished, checking content"; //如果编辑结束后内容为空则提示 if (m_lineEdit->text().isEmpty()) { + qCDebug(ClientLogger) << "Empty name after editing finished, showing alert"; //名称为空,返回 m_lineEdit->showAlertMessage(tr("Enter a name please")); m_lineEdit->setAlert(true); @@ -261,16 +278,19 @@ void ScheduleTypeEditDlg::slotEditingFinished() // 获取ICS文件路径 QString ScheduleTypeEditDlg::getIcsFile() { + qCDebug(ClientLogger) << "Getting selected ICS file path:" << m_fileEdit->text(); return m_fileEdit->text(); } // 检查并设置‘确认按钮’的状态 void ScheduleTypeEditDlg::slotCheckConfirmBtn() { + qCDebug(ClientLogger) << "Checking confirm button state"; auto confirmBtn = this->getButton(1); if (m_lineEdit->text().isEmpty() || m_lineEdit->isAlert()) { + qCDebug(ClientLogger) << "Name field empty or has alert, disabling confirm button"; confirmBtn->setEnabled(false); return; } @@ -278,10 +298,12 @@ void ScheduleTypeEditDlg::slotCheckConfirmBtn() { if (m_fileEdit->text().isEmpty() || m_fileEdit->isAlert()) { + qCDebug(ClientLogger) << "File field empty or has alert, disabling confirm button"; confirmBtn->setEnabled(false); return; } } + qCDebug(ClientLogger) << "All validations passed, enabling confirm button"; confirmBtn->setEnabled(true); } diff --git a/calendar-client/src/dialog/settingdialog.cpp b/calendar-client/src/dialog/settingdialog.cpp index fca5fc132..9147ac336 100644 --- a/calendar-client/src/dialog/settingdialog.cpp +++ b/calendar-client/src/dialog/settingdialog.cpp @@ -158,6 +158,7 @@ static CalendarSettingSetting setting_general = { }; CSettingDialog::CSettingDialog(QWidget *parent) : DSettingsDialog(parent) { + qCDebug(ClientLogger) << "Creating settings dialog"; m_controlCenterProxy = new ControlCenterProxy(ControlCenterDBusName, ControlCenterDBusPath, QDBusConnection::sessionBus(), @@ -167,10 +168,12 @@ CSettingDialog::CSettingDialog(QWidget *parent) : DSettingsDialog(parent) initData(); initWidgetDisplayStatus(); initView(); + qCDebug(ClientLogger) << "Settings dialog initialization complete"; } void CSettingDialog::initView() { + qCDebug(ClientLogger) << "Initializing settings dialog view"; setIcon(CDynamicIcon::getInstance()->getPixmap()); setFixedSize(682, 506); widgetFactory()->registerWidget("login", UserloginWidget::createloginButton); @@ -182,6 +185,7 @@ void CSettingDialog::initView() widgetFactory()->registerWidget("SyncTagRadioButton", std::bind(&CSettingDialog::createSyncTagRadioButton, this, std::placeholders::_1)); widgetFactory()->registerWidget("SyncTimeCombobox", std::bind(&CSettingDialog::createSyncFreqCombobox, this, std::placeholders::_1)); widgetFactory()->registerWidget("ManualSyncButton", std::bind(&CSettingDialog::createManualSyncButton, this, std::placeholders::_1)); + qCDebug(ClientLogger) << "Registered all custom widgets"; QString strJson; CalendarSettingSettings calendarSettings; @@ -271,6 +275,7 @@ void CSettingDialog::initView() void CSettingDialog::initWidget() { + qCDebug(ClientLogger) << "Initializing settings dialog widgets"; initFirstDayofWeekWidget(); initTimeTypeWidget(); initAccountComboBoxWidget(); @@ -278,10 +283,12 @@ void CSettingDialog::initWidget() initTypeAddWidget(); initSyncFreqWidget(); initManualSyncButton(); + qCDebug(ClientLogger) << "Settings dialog widgets initialized"; } void CSettingDialog::initConnect() { + qCDebug(ClientLogger) << "Initializing settings dialog connections"; connect(gAccountManager, &AccountManager::signalGeneralSettingsUpdate, this, &CSettingDialog::slotGeneralSettingsUpdate); connect(gAccountManager, &AccountManager::signalAccountUpdate, this, &CSettingDialog::slotAccountUpdate); connect(gAccountManager, &AccountManager::signalLogout, this, &CSettingDialog::slotLogout); @@ -298,6 +305,7 @@ void CSettingDialog::initConnect() connect(m_syncFreqComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, &CSettingDialog::slotSetUosSyncFreq); connect(m_syncBtn, &QPushButton::clicked, this, &CSettingDialog::slotUosManualSync); connect(m_ptrNetworkState, &DOANetWorkDBus::sign_NetWorkChange, this, &CSettingDialog::slotNetworkStateChange); + qCDebug(ClientLogger) << "Settings dialog connections initialized"; } void CSettingDialog::slotNetworkStateChange(DOANetWorkDBus::NetWorkState state) @@ -313,6 +321,7 @@ void CSettingDialog::slotNetworkStateChange(DOANetWorkDBus::NetWorkState state) void CSettingDialog::initData() { + qCDebug(ClientLogger) << "Initializing settings dialog data"; //通用设置数据初始化 slotGeneralSettingsUpdate(); //初始化账户信息 @@ -320,15 +329,18 @@ void CSettingDialog::initData() //日程类型添加按钮初始化 m_typeAddBtn->setEnabled(m_scheduleTypeWidget->canAdd()); m_typeImportBtn->setEnabled(m_scheduleTypeWidget->canAdd()); + qCDebug(ClientLogger) << "Schedule type add button enabled:" << m_scheduleTypeWidget->canAdd(); //同步频率数据初始化 { int index = 0; if (gUosAccountItem) { index = m_syncFreqComboBox->findData(gUosAccountItem->getAccount()->syncFreq()); + qCDebug(ClientLogger) << "Setting sync frequency index to:" << index << "for account ID:" << gUosAccountItem->getAccount()->accountID(); } m_syncFreqComboBox->setCurrentIndex(index); } slotAccountStateChange(); + qCDebug(ClientLogger) << "Settings dialog data initialized"; } void CSettingDialog::initWidgetDisplayStatus() @@ -496,14 +508,18 @@ void CSettingDialog::slotTimeTypeCurrentChanged(int index) void CSettingDialog::slotAccountCurrentChanged(int index) { + qCDebug(ClientLogger) << "Account changed to index:" << index; if (m_scheduleTypeWidget) { - m_scheduleTypeWidget->updateCalendarAccount(m_accountComboBox->itemData(index).toString()); + QString accountId = m_accountComboBox->itemData(index).toString(); + qCDebug(ClientLogger) << "Updating calendar account to ID:" << accountId; + m_scheduleTypeWidget->updateCalendarAccount(accountId); setTypeEnable(index); } } void CSettingDialog::slotTypeAddBtnClickded() { + qCDebug(ClientLogger) << "Add schedule type button clicked"; if (m_scheduleTypeWidget) { m_scheduleTypeWidget->slotAddScheduleType(); } @@ -511,6 +527,7 @@ void CSettingDialog::slotTypeAddBtnClickded() void CSettingDialog::slotTypeImportBtnClickded() { + qCDebug(ClientLogger) << "Import schedule type button clicked"; if (m_scheduleTypeWidget) { m_scheduleTypeWidget->slotImportScheduleType(); } @@ -518,9 +535,12 @@ void CSettingDialog::slotTypeImportBtnClickded() void CSettingDialog::slotSetUosSyncFreq(int freq) { + qCDebug(ClientLogger) << "Setting UOS sync frequency to:" << freq; QComboBox *com = qobject_cast(sender()); - if (!com || !gUosAccountItem) + if (!com || !gUosAccountItem) { + qCDebug(ClientLogger) << "No combo box or UOS account item, skipping sync frequency update"; return; + } qCDebug(ClientLogger) << "Setting UOS sync frequency to:" << freq; gUosAccountItem->setSyncFreq(DAccount::SyncFreqType(com->itemData(freq).toInt())); @@ -528,16 +548,22 @@ void CSettingDialog::slotSetUosSyncFreq(int freq) void CSettingDialog::slotUosManualSync() { - if (!gUosAccountItem) + qCDebug(ClientLogger) << "Manual sync requested"; + if (!gUosAccountItem) { + qCDebug(ClientLogger) << "No UOS account item, skipping manual sync"; return; + } qCDebug(ClientLogger) << "Manual sync requested for account:" << gUosAccountItem->getAccount()->accountID(); gAccountManager->downloadByAccountID(gUosAccountItem->getAccount()->accountID()); } void CSettingDialog::slotSyncTagButtonUpdate() { - if (!gUosAccountItem) + qCDebug(ClientLogger) << "Updating sync tag buttons"; + if (!gUosAccountItem) { + qCDebug(ClientLogger) << "No UOS account item, skipping sync tag button update"; return; + } auto state = gUosAccountItem->getAccount()->accountState(); qCDebug(ClientLogger) << "Updating sync tag buttons for account state:" << state; @@ -550,8 +576,11 @@ void CSettingDialog::slotSyncTagButtonUpdate() void CSettingDialog::slotSyncAccountStateUpdate(bool status) { - if (!gUosAccountItem) + qCDebug(ClientLogger) << "Updating sync account state"; + if (!gUosAccountItem) { + qCDebug(ClientLogger) << "No UOS account item, skipping sync account state update"; return; + } auto state = gUosAccountItem->getAccountState(); @@ -567,6 +596,7 @@ void CSettingDialog::slotSyncAccountStateUpdate(bool status) gUosAccountItem->setAccountState(state); if (status) { + qCDebug(ClientLogger) << "Manual sync requested"; slotUosManualSync(); } } @@ -588,7 +618,9 @@ void CSettingDialog::slotLastSyncTimeUpdate(const QString &datetime) void CSettingDialog::slotAccountStateChange() { + qCDebug(ClientLogger) << "Updating account state change"; if (!gUosAccountItem) { + qCDebug(ClientLogger) << "No UOS account item, skipping account state change"; return; } if (m_syncBtn) { @@ -607,24 +639,31 @@ void CSettingDialog::slotAccountStateChange() } } if (m_accountComboBox && m_typeAddBtn) { + qCDebug(ClientLogger) << "Updating type enable"; setTypeEnable(m_accountComboBox->currentIndex()); } } void CSettingDialog::setFirstDayofWeek(int value) { + qCDebug(ClientLogger) << "Setting first day of week"; if (!m_firstDayofWeekCombobox) { + qCDebug(ClientLogger) << "No first day of week combobox, skipping"; return; } auto sourceSystem = gAccountManager->getFirstDayofWeekSource() == DCalendarGeneralSettings::Source_System; if (sourceSystem) { + qCDebug(ClientLogger) << "Setting first day of week to system default"; m_firstDayofWeekCombobox->setCurrentIndex(m_firstDayofWeekCombobox->count() - 1); } else { + qCDebug(ClientLogger) << "Setting first day of week to:" << value; if (value == 1) { + qCDebug(ClientLogger) << "Setting first day of week to Monday"; m_firstDayofWeekCombobox->setCurrentIndex(1); } else { + qCDebug(ClientLogger) << "Setting first day of week to Sunday"; m_firstDayofWeekCombobox->setCurrentIndex(0); } } @@ -634,18 +673,23 @@ void CSettingDialog::setFirstDayofWeek(int value) void CSettingDialog::setTimeType(int value) { + qCDebug(ClientLogger) << "Setting time type"; if (!m_timeTypeCombobox) { + qCDebug(ClientLogger) << "No time type combobox, skipping"; return; } if (value > 1 || value < 0) { + qCDebug(ClientLogger) << "Invalid time type, setting to 0"; value = 0; } auto sourceSystem = gAccountManager->getTimeFormatTypeSource() == DCalendarGeneralSettings::Source_System; // 设置时间显示格式并刷新界面 if (sourceSystem) { + qCDebug(ClientLogger) << "Setting time type to system default"; m_timeTypeCombobox->setCurrentIndex(m_firstDayofWeekCombobox->count() - 1); } else { + qCDebug(ClientLogger) << "Setting time type to:" << value; m_timeTypeCombobox->setCurrentIndex(value); } gCalendarManager->setTimeShowType(value, true); @@ -653,39 +697,53 @@ void CSettingDialog::setTimeType(int value) void CSettingDialog::accountUpdate() { + qCDebug(ClientLogger) << "Updating account list in settings dialog"; if (nullptr == m_accountComboBox) { + qCWarning(ClientLogger) << "Account combo box is null, cannot update"; return; } QVariant oldAccountID = m_accountComboBox->currentData(); + qCDebug(ClientLogger) << "Current account ID:" << oldAccountID; m_accountComboBox->blockSignals(true); m_accountComboBox->clear(); for (auto account : gAccountManager->getAccountList()) { + // qCDebug(ClientLogger) << "Adding account:" << account->getAccount()->accountName() << "ID:" << account->getAccount()->accountID(); m_accountComboBox->addItem(account->getAccount()->accountName(), account->getAccount()->accountID()); } m_accountComboBox->setCurrentIndex(m_accountComboBox->findData(oldAccountID)); - if (m_accountComboBox->currentIndex() < 0) + if (m_accountComboBox->currentIndex() < 0) { + qCDebug(ClientLogger) << "Previous account not found, resetting to first account"; m_accountComboBox->setCurrentIndex(0); + } m_accountComboBox->blockSignals(false); m_syncFreqComboBox->setCurrentIndex(1); //每次登录的时候 默认15分钟 slotAccountCurrentChanged(m_accountComboBox->currentIndex()); + qCDebug(ClientLogger) << "Account list updated successfully"; } void CSettingDialog::setTypeEnable(int index) { - if (!gUosAccountItem) return; + qCDebug(ClientLogger) << "Setting type enable for account index:" << index; + if (!gUosAccountItem) { + qCDebug(ClientLogger) << "No UOS account item, cannot enable type editing"; + return; + } QString accountId = m_accountComboBox->itemData(index).toString(); + qCDebug(ClientLogger) << "Account ID:" << accountId; AccountItem::Ptr account = gAccountManager->getAccountItemByAccountId(accountId); if (account->getAccount()->accountType() == DAccount::Account_Local || gUosAccountItem->isCanSyncShedule()) { if (account->getScheduleTypeList().count() < 20) { + qCDebug(ClientLogger) << "Schedule type count below limit, enabling editing"; m_typeAddBtn->setEnabled(true); m_typeImportBtn->setEnabled(true); m_scheduleTypeWidget->setItemEnabled(true); } } else { + qCDebug(ClientLogger) << "Non-local account or sync disabled, disabling type editing"; m_typeAddBtn->setEnabled(false); m_typeImportBtn->setEnabled(false); m_scheduleTypeWidget->setItemEnabled(false); @@ -694,6 +752,7 @@ void CSettingDialog::setTypeEnable(int index) QPair CSettingDialog::createFirstDayofWeekWidget(QObject *obj) { + qCDebug(ClientLogger) << "Creating first day of week widget"; auto option = qobject_cast(obj); QPair optionWidget = DSettingsWidgetFactory::createStandardItem(QByteArray(), option, m_firstDayofWeekWidget); @@ -704,6 +763,7 @@ QPair CSettingDialog::createFirstDayofWeekWidget(QObject * QPair CSettingDialog::createTimeTypeWidget(QObject *obj) { + qCDebug(ClientLogger) << "Creating time type widget"; auto option = qobject_cast(obj); QPair optionWidget = DSettingsWidgetFactory::createStandardItem(QByteArray(), option, m_timeTypeWidget); // 获取初始值 @@ -713,6 +773,7 @@ QPair CSettingDialog::createTimeTypeWidget(QObject *obj) QPair CSettingDialog::createAccountCombobox(QObject *obj) { + qCDebug(ClientLogger) << "Creating account combobox"; auto option = qobject_cast(obj); QPair optionWidget = DSettingsWidgetFactory::createStandardItem(QByteArray(), option, m_accountComboBox); return optionWidget; @@ -720,6 +781,7 @@ QPair CSettingDialog::createAccountCombobox(QObject *obj) QPair CSettingDialog::createSyncFreqCombobox(QObject *obj) { + qCDebug(ClientLogger) << "Creating sync frequency combobox"; auto option = qobject_cast(obj); QPair optionWidget = DSettingsWidgetFactory::createStandardItem(QByteArray(), option, m_syncFreqComboBox); return optionWidget; @@ -727,6 +789,7 @@ QPair CSettingDialog::createSyncFreqCombobox(QObject *obj) QPair CSettingDialog::createSyncTagRadioButton(QObject *obj) { + qCDebug(ClientLogger) << "Creating sync tag radio button"; auto option = qobject_cast(obj); DAccount::AccountState type = DAccount::Account_Calendar; if (option->key().endsWith("Account_Calendar")) @@ -761,21 +824,25 @@ QPair CSettingDialog::createSyncTagRadioButton(QObject *ob QWidget *CSettingDialog::createManualSyncButton(QObject *obj) { + // qCDebug(ClientLogger) << "Creating manual sync button"; return m_manualSyncWidget; } QWidget *CSettingDialog::createJobTypeListView(QObject *) { + // qCDebug(ClientLogger) << "Creating job type list view"; return m_scheduleTypeWidget; } DIconButton *CSettingDialog::createTypeAddButton() { + // qCDebug(ClientLogger) << "Creating type add button"; return m_typeAddBtn; } QWidget *CSettingDialog::createControlCenterLink(QObject *obj) { + qCDebug(ClientLogger) << "Creating control center link"; DLabel *myLabel = new DLabel(tr("Please go to the Control Center to change system settings"), this); myLabel->setTextFormat(Qt::RichText); myLabel->setFixedHeight(36); diff --git a/calendar-client/src/dialog/timejumpdialog.cpp b/calendar-client/src/dialog/timejumpdialog.cpp index b27a648b5..f9b31ece7 100644 --- a/calendar-client/src/dialog/timejumpdialog.cpp +++ b/calendar-client/src/dialog/timejumpdialog.cpp @@ -4,11 +4,13 @@ #include "timejumpdialog.h" #include "cschedulebasewidget.h" +#include "commondef.h" #include #include TimeJumpDialog::TimeJumpDialog(ArrowDirection direction, QWidget *parent) : DArrowRectangle(direction, DArrowRectangle::FloatWindow, parent) { + qCDebug(ClientLogger) << "Creating time jump dialog"; setWindowFlags(Qt::Popup); initView(); initConnect(); @@ -16,6 +18,7 @@ TimeJumpDialog::TimeJumpDialog(ArrowDirection direction, QWidget *parent) : DArr void TimeJumpDialog::initView() { + qCDebug(ClientLogger) << "Initializing time jump dialog view"; setRadius(16); //设置圆角大小 setArrowWidth(60); //设置箭头宽度 setArrowHeight(30); //设置箭头高度 @@ -45,11 +48,12 @@ void TimeJumpDialog::initView() QWidget *wgt = new QWidget(); wgt->setLayout(hLayout); setContent(wgt); - + qCDebug(ClientLogger) << "Time jump dialog view initialized"; } void TimeJumpDialog::initConnect() { + qCDebug(ClientLogger) << "Initializing time jump dialog connections"; connect(m_yearEdit, &CTimeLineEdit::signalNumChange, this, &TimeJumpDialog::slotEditNumChange); connect(m_monthEdit, &CTimeLineEdit::signalNumChange, this, &TimeJumpDialog::slotEditNumChange); connect(m_dayEdit, &CTimeLineEdit::signalNumChange, this, &TimeJumpDialog::slotEditNumChange); @@ -57,10 +61,12 @@ void TimeJumpDialog::initConnect() connect(m_monthEdit, &CTimeLineEdit::signalDateJump, this, &TimeJumpDialog::slotDateJump); connect(m_dayEdit, &CTimeLineEdit::signalDateJump, this, &TimeJumpDialog::slotDateJump); connect(m_jumpButton, &QPushButton::clicked, this, &TimeJumpDialog::slotJumpButtonClicked); + qCDebug(ClientLogger) << "Time jump dialog connections initialized"; } void TimeJumpDialog::initData() { + qCDebug(ClientLogger) << "Initializing time jump dialog data"; m_yearEdit->setRange(1900, 2100); m_monthEdit->setRange(1, 12); //设置天编辑器限制范围 @@ -79,6 +85,7 @@ void TimeJumpDialog::initData() */ void TimeJumpDialog::showPopup(const QDate &date, const QPoint &pos) { + qCDebug(ClientLogger) << "Showing time jump dialog"; showPopup(date, pos.x(), pos.y()); } @@ -91,6 +98,7 @@ void TimeJumpDialog::showPopup(const QDate &date, const QPoint &pos) */ void TimeJumpDialog::showPopup(const QDate &date, int x, int y) { + qCDebug(ClientLogger) << "Showing time jump dialog at position:" << x << "," << y; //保存时间 m_date = date; //初始化数据 @@ -110,9 +118,11 @@ void TimeJumpDialog::showPopup(const QDate &date, int x, int y) */ int TimeJumpDialog::getMaxDayNum() { + qCDebug(ClientLogger) << "Getting maximum day number for month:" << m_date.month(); static int dayNum[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int maxDay = dayNum[m_date.month() - 1]; if (m_date.month() == 2 && QDate::isLeapYear(m_date.year())) { + qCDebug(ClientLogger) << "Leap year"; maxDay = 29; } return maxDay; @@ -124,6 +134,7 @@ int TimeJumpDialog::getMaxDayNum() */ void TimeJumpDialog::resetEdietStepEnable() { + qCDebug(ClientLogger) << "Resetting editor step enable"; //将所有编辑器调整为可上下编辑状态 m_yearEdit->setStepEnabled(CTimeLineEdit::StepUpEnabled | CTimeLineEdit::StepDownEnabled); m_monthEdit->setStepEnabled(CTimeLineEdit::StepUpEnabled | CTimeLineEdit::StepDownEnabled); @@ -131,16 +142,20 @@ void TimeJumpDialog::resetEdietStepEnable() //根据每一级当前值设置上下编辑状态 if (m_yearEdit->value() == m_yearEdit->minimum()) { + qCDebug(ClientLogger) << "Year edit minimum"; m_yearEdit->setStepEnabled(CTimeLineEdit::StepUpEnabled); if (m_monthEdit->value() == m_monthEdit->minimum()) { + qCDebug(ClientLogger) << "Month edit minimum"; m_monthEdit->setStepEnabled(CTimeLineEdit::StepUpEnabled); if (m_dayEdit->value() == m_dayEdit->minimum()) { m_dayEdit->setStepEnabled(CTimeLineEdit::StepUpEnabled); } } } else if (m_yearEdit->value() == m_yearEdit->maximum()) { + qCDebug(ClientLogger) << "Year edit maximum"; m_yearEdit->setStepEnabled(CTimeLineEdit::StepDownEnabled); if (m_monthEdit->value() == m_monthEdit->maximum()) { + qCDebug(ClientLogger) << "Month edit maximum"; m_monthEdit->setStepEnabled(CTimeLineEdit::StepDownEnabled); if (m_dayEdit->value() == m_dayEdit->maximum()) { m_dayEdit->setStepEnabled(CTimeLineEdit::StepDownEnabled); @@ -157,10 +172,12 @@ void TimeJumpDialog::resetEdietStepEnable() */ void TimeJumpDialog::slotEditNumChange(int id, int num) { + qCDebug(ClientLogger) << "Editing number changed:" << id << "," << num; switch (id) { case EditYear: //更改年 { + qCDebug(ClientLogger) << "Year changed:" << num; //因直接设置一年的年月日可能会造成更改月或年后该日期不存在导致的日期错误, //所以变化年或者月时先将日变为1,后续再根据实际情况更改日日期 int day = m_date.day(); @@ -174,6 +191,7 @@ void TimeJumpDialog::slotEditNumChange(int id, int num) case EditMonth: //更改月 { + qCDebug(ClientLogger) << "Month changed:" << num; int day = m_date.day(); m_date.setDate(m_date.year(), num, 1); int maxDay = getMaxDayNum(); @@ -184,9 +202,11 @@ void TimeJumpDialog::slotEditNumChange(int id, int num) break; case EditDay: //更改日 + qCDebug(ClientLogger) << "Day changed:" << num; m_date.setDate(m_date.year(), m_date.month(), num); break; } + qCDebug(ClientLogger) << "Resetting editor step enable"; resetEdietStepEnable(); } @@ -198,14 +218,18 @@ void TimeJumpDialog::slotEditNumChange(int id, int num) */ void TimeJumpDialog::slotDateJump(int id, int num) { + qCDebug(ClientLogger) << "Date jump:" << id << "," << num; switch (id) { case EditYear: + qCDebug(ClientLogger) << "Year jump:" << num; m_date = m_date.addYears(num); break; case EditMonth: + qCDebug(ClientLogger) << "Month jump:" << num; m_date = m_date.addMonths(num); break; case EditDay: + qCDebug(ClientLogger) << "Day jump:" << num; m_date = m_date.addDays(num); break; } @@ -219,6 +243,7 @@ void TimeJumpDialog::slotDateJump(int id, int num) */ void TimeJumpDialog::slotJumpButtonClicked() { + qCDebug(ClientLogger) << "Jump button clicked"; //将焦点转移到button控件上,使在跳转时间前正在编辑的edit控件触发finished事件 m_jumpButton->setFocus(); //设置全局时间 diff --git a/calendar-client/src/shortcut.cpp b/calendar-client/src/shortcut.cpp index 7bfe13a34..5012bca80 100644 --- a/calendar-client/src/shortcut.cpp +++ b/calendar-client/src/shortcut.cpp @@ -3,10 +3,12 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "shortcut.h" +#include "commondef.h" Shortcut::Shortcut(QObject *parent) : QObject(parent) { + qCDebug(ClientLogger) << "Shortcut constructor start"; ShortcutGroup group1; ShortcutGroup group2; ShortcutGroup group3; @@ -40,9 +42,12 @@ Shortcut::Shortcut(QObject *parent) jsonGroups.append(jsonGroup); } m_shortcutObj.insert("shortcut", jsonGroups); + qCDebug(ClientLogger) << "Shortcut constructor end"; } + QString Shortcut::toStr() { + // qCDebug(ClientLogger) << "Converting shortcut object to JSON string"; QJsonDocument doc(m_shortcutObj); return doc.toJson().data(); } diff --git a/calendar-client/src/tabletconfig.cpp b/calendar-client/src/tabletconfig.cpp index 676a29797..b00cf9bc4 100644 --- a/calendar-client/src/tabletconfig.cpp +++ b/calendar-client/src/tabletconfig.cpp @@ -3,20 +3,24 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "tabletconfig.h" +#include "commondef.h" //默认不为平板模式 bool TabletConfig::m_isTablet = false; TabletConfig::TabletConfig(QObject *parent) : QObject(parent) { + // qCDebug(ClientLogger) << "TabletConfig constructor"; } bool TabletConfig::isTablet() { + // qCDebug(ClientLogger) << "TabletConfig::isTablet called, current state:" << m_isTablet; return m_isTablet; } void TabletConfig::setIsTablet(bool isTablet) { + // qCDebug(ClientLogger) << "TabletConfig::setIsTablet called, old state:" << m_isTablet << "new state:" << isTablet; m_isTablet = isTablet; } diff --git a/calendar-client/src/view/alldayeventview.cpp b/calendar-client/src/view/alldayeventview.cpp index 9c513a088..6971c81ab 100644 --- a/calendar-client/src/view/alldayeventview.cpp +++ b/calendar-client/src/view/alldayeventview.cpp @@ -10,6 +10,7 @@ #include "scheduledatamanage.h" #include "constants.h" #include "scheduledaterangeinfo.h" +#include "commondef.h" #include @@ -32,12 +33,15 @@ DWIDGET_USE_NAMESPACE void CAllDayEventWeekView::setTheMe(int type) { + qCDebug(ClientLogger) << "CAllDayEventWeekView::setTheMe called with type:" << type; CWeekDayGraphicsview::setTheMe(type); } void CAllDayEventWeekView::changeEvent(QEvent *event) { + // qCDebug(ClientLogger) << "CAllDayEventWeekView::changeEvent called with event type:" << event->type(); if (event->type() == QEvent::FontChange) { + qCDebug(ClientLogger) << "Font change event received, updating item height"; updateItemHeightByFontSize(); updateInfo(); } @@ -45,50 +49,67 @@ void CAllDayEventWeekView::changeEvent(QEvent *event) bool CAllDayEventWeekView::MeetCreationConditions(const QDateTime &date) { - return qAbs(date.daysTo(m_PressDate)) < 7; + bool result = qAbs(date.daysTo(m_PressDate)) < 7; + // qCDebug(ClientLogger) << "CAllDayEventWeekView::MeetCreationConditions called, date:" << date + // << "m_PressDate:" << m_PressDate << "result:" << result; + return result; } void CAllDayEventWeekView::slotCreate(const QDateTime &date) { + qCDebug(ClientLogger) << "CAllDayEventWeekView::slotCreate called with date:" << date; CScheduleDlg dlg(1, this); dlg.setDate(date); dlg.setAllDay(true); if (dlg.exec() == DDialog::Accepted) { + qCDebug(ClientLogger) << "Schedule creation accepted, updating schedule"; emit signalsUpdateSchedule(); slotStateChange(true); + } else { + qCDebug(ClientLogger) << "Schedule creation cancelled"; } } bool CAllDayEventWeekView::IsEqualtime(const QDateTime &timeFirst, const QDateTime &timeSecond) { - return timeFirst.date() == timeSecond.date(); + bool result = timeFirst.date() == timeSecond.date(); + // qCDebug(ClientLogger) << "CAllDayEventWeekView::IsEqualtime called, comparing dates:" + // << timeFirst.date() << "and" << timeSecond.date() << "result:" << result; + return result; } 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; + bool result = qAbs(pos.x() - m_PressPos.x()) > 20 || qAbs(m_PressDate.date().daysTo(m_coorManage->getsDate(mapFrom(this, pos.toPoint())))) > 0; + // qCDebug(ClientLogger) << "CAllDayEventWeekView::JudgeIsCreate called, result:" << result; + return result; } void CAllDayEventWeekView::RightClickToCreate(QGraphicsItem *listItem, const QPoint &pos) { + qCDebug(ClientLogger) << "CAllDayEventWeekView::RightClickToCreate called at position:" << 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()); + qCDebug(ClientLogger) << "Right click menu prepared with create date:" << m_createDate; m_rightMenu->exec(QCursor::pos()); } void CAllDayEventWeekView::MoveInfoProcess(DSchedule::Ptr &info, const QPointF &pos) { + // qCDebug(ClientLogger) << "CAllDayEventWeekView::MoveInfoProcess called"; Q_UNUSED(pos); if (info->allDay()) { qint64 offset = m_PressDate.daysTo(m_MoveDate); + qCDebug(ClientLogger) << "Processing all-day schedule move with offset days:" << offset; info->setDtStart(info->dtStart().addDays(offset)); info->setDtEnd(info->dtEnd().addDays(offset)); } else { qint64 offset = info->dtStart().daysTo(info->dtEnd()); + qCDebug(ClientLogger) << "Converting non-all-day schedule to all-day with day span:" << offset; info->setAllDay(true); info->setAlarmType(DSchedule::Alarm_15Hour_Front); m_DragScheduleInfo->setDtStart(QDateTime(m_MoveDate.date(), QTime(0, 0, 0))); @@ -99,16 +120,21 @@ void CAllDayEventWeekView::MoveInfoProcess(DSchedule::Ptr &info, const QPointF & 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 result = moveDateTime.daysTo(m_InfoEndTime) < 0 ? QDateTime(m_InfoEndTime.date(), QTime(0, 0, 0)) : QDateTime(moveDateTime.date(), QTime(0, 0, 0)); + // qCDebug(ClientLogger) << "CAllDayEventWeekView::getDragScheduleInfoBeginTime called, result:" << result; + return result; } 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)); + QDateTime result = m_InfoBeginTime.daysTo(m_MoveDate) < 0 ? QDateTime(m_InfoBeginTime.date(), QTime(23, 59, 0)) : QDateTime(moveDateTime.date(), QTime(23, 59, 0)); + // qCDebug(ClientLogger) << "CAllDayEventWeekView::getDragScheduleInfoEndTime called, result:" << result; + return result; } void CAllDayEventWeekView::updateHeight() { + qCDebug(ClientLogger) << "CAllDayEventWeekView::updateHeight called for" << m_baseShowItem.count() << "items"; for (int i = 0; i < m_baseShowItem.count(); i++) { m_baseShowItem.at(i)->update(); } @@ -120,10 +146,12 @@ void CAllDayEventWeekView::updateHeight() */ void CAllDayEventWeekView::setSelectSearchSchedule(const DSchedule::Ptr &info) { + qCDebug(ClientLogger) << "CAllDayEventWeekView::setSelectSearchSchedule called for schedule"; DragInfoGraphicsView::setSelectSearchSchedule(info); for (int i = 0; i < m_baseShowItem.size(); ++i) { CAllDayScheduleItem *item = m_baseShowItem.at(i); if (item->hasSelectSchedule(info)) { + qCDebug(ClientLogger) << "Found matching schedule item, starting animation"; QRectF rect = item->rect(); centerOn(0, rect.y()); setTransformationAnchor(QGraphicsView::AnchorViewCenter); @@ -136,6 +164,7 @@ void CAllDayEventWeekView::setSelectSearchSchedule(const DSchedule::Ptr &info) void CAllDayEventWeekView::setMargins(int left, int top, int right, int bottom) { + qCDebug(ClientLogger) << "CAllDayEventWeekView::setMargins called with:" << left << top << right << bottom; setViewportMargins(QMargins(left, top, right, bottom)); } @@ -144,12 +173,15 @@ void CAllDayEventWeekView::setMargins(int left, int top, int right, int bottom) */ void CAllDayEventWeekView::updateInfo() { + qCDebug(ClientLogger) << "CAllDayEventWeekView::updateInfo called, drag status:" << m_DragStatus; DragInfoGraphicsView::updateInfo(); switch (m_DragStatus) { case IsCreate: + qCDebug(ClientLogger) << "Updating info in IsCreate mode"; upDateInfoShow(IsCreate, m_DragScheduleInfo); break; default: + qCDebug(ClientLogger) << "Updating info in default mode"; upDateInfoShow(); break; } @@ -157,22 +189,27 @@ void CAllDayEventWeekView::updateInfo() void CAllDayEventWeekView::upDateInfoShow(const DragStatus &status, const DSchedule::Ptr &info) { + qCDebug(ClientLogger) << "CAllDayEventWeekView::upDateInfoShow called with status:" << status; DSchedule::List vListData; vListData = m_scheduleInfo; switch (status) { case NONE: + qCDebug(ClientLogger) << "Status: NONE"; Q_UNUSED(info); break; case ChangeBegin: case ChangeEnd: { + qCDebug(ClientLogger) << "Status: ChangeBegin/ChangeEnd for schedule"; int index = vListData.indexOf(info); if (index >= 0) vListData[index] = info; } break; case ChangeWhole: + qCDebug(ClientLogger) << "Status: ChangeWhole, adding schedule to list"; vListData.append(info); break; case IsCreate: + qCDebug(ClientLogger) << "Status: IsCreate, adding schedule to list"; vListData.append(info); break; } @@ -268,6 +305,7 @@ void CAllDayEventWeekView::upDateInfoShow(const DragStatus &status, const DSched } else { m_topMagin = 123; } + qCDebug(ClientLogger) << "Setting view height based on result data count:" << vResultData.count() << "top margin:" << m_topMagin; setFixedHeight(m_topMagin - 3); setDayData(vResultData); update(); @@ -277,49 +315,61 @@ void CAllDayEventWeekView::upDateInfoShow(const DragStatus &status, const DSched CAllDayEventWeekView::CAllDayEventWeekView(QWidget *parent, ViewPosition type) : CWeekDayGraphicsview(parent, type, ViewType::ALLDayView) { + qCDebug(ClientLogger) << "CAllDayEventWeekView constructor called with view position type:" << type; updateItemHeightByFontSize(); connect(this, &CAllDayEventWeekView::sigStateChange, this, &CAllDayEventWeekView::slotStateChange, Qt::DirectConnection); } CAllDayEventWeekView::~CAllDayEventWeekView() { + // qCDebug(ClientLogger) << "CAllDayEventWeekView destructor called"; } void CAllDayEventWeekView::setDayData(const QVector &vlistData) { + qCDebug(ClientLogger) << "CAllDayEventWeekView::setDayData called with" << vlistData.size() << "schedule lists"; m_vlistData = vlistData; updateDateShow(); } void CAllDayEventWeekView::setInfo(const DSchedule::List &info) { + // qCDebug(ClientLogger) << "CAllDayEventWeekView::setInfo called with" << info.size() << "schedules"; m_scheduleInfo = info; } void CAllDayEventWeekView::slotDoubleEvent() { + qCDebug(ClientLogger) << "CAllDayEventWeekView::slotDoubleEvent called"; m_updateDflag = true; emit signalsUpdateSchedule(); } void CAllDayEventWeekView::mouseDoubleClickEvent(QMouseEvent *event) { + qCDebug(ClientLogger) << "CAllDayEventWeekView::mouseDoubleClickEvent at position:" << event->pos(); if (event->button() == Qt::RightButton) { + qCDebug(ClientLogger) << "Right button double click ignored"; return; } emit signalScheduleShow(false); DGraphicsView::mouseDoubleClickEvent(event); CAllDayScheduleItem *item = dynamic_cast(itemAt(event->pos())); if (item == nullptr) { + qCDebug(ClientLogger) << "No item at position, creating new schedule"; m_createDate.setDate(m_coorManage->getsDate(mapFrom(this, event->pos()))); m_createDate.setTime(QTime::currentTime()); slotCreate(m_createDate); } else { + qCDebug(ClientLogger) << "Item found, showing schedule view dialog"; m_updateDflag = false; CMyScheduleView dlg(item->getData(), this); connect(&dlg, &CMyScheduleView::signalsEditorDelete, this, &CAllDayEventWeekView::slotDoubleEvent); if (dlg.exec() == DDialog::Accepted){ + qCDebug(ClientLogger) << "Schedule view dialog accepted"; slotStateChange(true); + } else { + qCDebug(ClientLogger) << "Schedule view dialog cancelled"; } disconnect(&dlg, &CMyScheduleView::signalsEditorDelete, this, &CAllDayEventWeekView::slotDoubleEvent); } @@ -327,8 +377,10 @@ void CAllDayEventWeekView::mouseDoubleClickEvent(QMouseEvent *event) void CAllDayEventWeekView::wheelEvent(QWheelEvent *event) { + // qCDebug(ClientLogger) << "CAllDayEventWeekView::wheelEvent with angle delta:" << event->angleDelta(); //若滚轮事件为左右方向则退出 if (event->angleDelta().x() != 0 ) { + qCDebug(ClientLogger) << "Horizontal wheel event, ignoring"; return; } emit signalScheduleShow(false); @@ -337,6 +389,7 @@ void CAllDayEventWeekView::wheelEvent(QWheelEvent *event) void CAllDayEventWeekView::updateDateShow() { + qCDebug(ClientLogger) << "CAllDayEventWeekView::updateDateShow called"; qreal sceneHeight; qreal itemsHeight = (itemHeight + 1) * m_vlistData.size(); if (itemsHeight < 32) { @@ -346,12 +399,14 @@ void CAllDayEventWeekView::updateDateShow() } //如果设置场景的高度小于viewport的高度则设置场景的高度为viewport的高度 sceneHeight = sceneHeight < viewport()->height() ? viewport()->height() : sceneHeight; + qCDebug(ClientLogger) << "Setting scene rect with height:" << sceneHeight; setSceneRect(0, 0, m_Scene->width(), sceneHeight); for (int i = 0; i < m_baseShowItem.count(); i++) { delete m_baseShowItem[i]; } m_baseShowItem.clear(); + qCDebug(ClientLogger) << "Creating" << m_vlistData.size() << "item widgets"; for (int i = 0; i < m_vlistData.size(); ++i) { createItemWidget(i); } @@ -361,6 +416,7 @@ void CAllDayEventWeekView::updateDateShow() void CAllDayEventWeekView::createItemWidget(int index, bool average) { + qCDebug(ClientLogger) << "CAllDayEventWeekView::createItemWidget called for index:" << index; Q_UNUSED(average) for (int i = 0; i < m_vlistData[index].size(); ++i) { const DSchedule::Ptr &info = m_vlistData[index].at(i); @@ -373,11 +429,14 @@ void CAllDayEventWeekView::createItemWidget(int index, bool average) m_Scene->addItem(gwi); m_baseShowItem.append(gwi); } + qCDebug(ClientLogger) << "Created" << m_vlistData[index].size() << "schedule items for index" << index; } void CAllDayEventWeekView::slotStateChange(bool bState) { + qCDebug(ClientLogger) << "CAllDayEventWeekView::slotStateChange called with state:" << bState; if(bState) { + qCDebug(ClientLogger) << "Hiding" << m_baseShowItem.count() << "schedule items"; for (int i = 0; i < m_baseShowItem.count(); i++) { m_baseShowItem[i]->setVisible(false); } @@ -386,6 +445,7 @@ void CAllDayEventWeekView::slotStateChange(bool bState) void CAllDayEventWeekView::updateItemHeightByFontSize() { + qCDebug(ClientLogger) << "CAllDayEventWeekView::updateItemHeightByFontSize called"; QFont font; DFontSizeManager::instance()->setFontGenericPixelSize( static_cast(DFontSizeManager::instance()->fontPixelSize(qGuiApp->font()))); @@ -393,6 +453,7 @@ void CAllDayEventWeekView::updateItemHeightByFontSize() QFontMetrics fm(font); int h = fm.height(); if (itemHeight != h) { + qCDebug(ClientLogger) << "Item height updated from" << itemHeight << "to" << h; itemHeight = h; } } @@ -403,21 +464,27 @@ CAllDayEventWeekView::PosInItem CAllDayEventWeekView::getPosInItem(const QPoint QPointF itemPos = QPointF(scenePos.x() - itemRect.x(), scenePos.y() - itemRect.y()); double bottomy = itemRect.width() - itemPos.x(); + PosInItem result; if (itemPos.x() < 5) { - return LEFT; - } - if (bottomy < 5) { - return RIGHT; + result = LEFT; + } else if (bottomy < 5) { + result = RIGHT; + } else { + result = MIDDLE; } - return MIDDLE; + // qCDebug(ClientLogger) << "CAllDayEventWeekView::getPosInItem result:" << result; + return result; } QDateTime CAllDayEventWeekView::getPosDate(const QPoint &p) { - return QDateTime(m_coorManage->getsDate(mapFrom(this, p)), QTime(0, 0, 0)); + QDateTime result = QDateTime(m_coorManage->getsDate(mapFrom(this, p)), QTime(0, 0, 0)); + // qCDebug(ClientLogger) << "CAllDayEventWeekView::getPosDate called, result:" << result; + return result; } void CAllDayEventWeekView::slotUpdateScene() { + // qCDebug(ClientLogger) << "CAllDayEventWeekView::slotUpdateScene called"; this->scene()->update(); } diff --git a/calendar-client/src/view/cgraphicsscene.cpp b/calendar-client/src/view/cgraphicsscene.cpp index d2d3fe338..510a109e2 100644 --- a/calendar-client/src/view/cgraphicsscene.cpp +++ b/calendar-client/src/view/cgraphicsscene.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "cgraphicsscene.h" +#include "commondef.h" #include "graphicsItem/cscenebackgrounditem.h" @@ -20,43 +21,52 @@ CGraphicsScene::CGraphicsScene(QObject *parent) , m_isContextMenu(false) , m_isShowCurrentItem(false) { + // qCDebug(ClientLogger) << "CGraphicsScene constructor"; } CGraphicsScene::~CGraphicsScene() { + // qCDebug(ClientLogger) << "CGraphicsScene destructor"; if (m_keyPrxy != nullptr) delete m_keyPrxy; } void CGraphicsScene::setFirstFocusItem(QGraphicsItem *item) { + // qCDebug(ClientLogger) << "CGraphicsScene::setFirstFocusItem called, item:" << (item ? "set" : "nullptr"); firstfocusItem = item; } QGraphicsItem *CGraphicsScene::getFirstFocusItem() const { + // qCDebug(ClientLogger) << "CGraphicsScene::getFirstFocusItem called, returning:" << (firstfocusItem ? "item" : "nullptr"); return firstfocusItem; } void CGraphicsScene::setCurrentFocusItem(QGraphicsItem *item) { + // qCDebug(ClientLogger) << "CGraphicsScene::setCurrentFocusItem called, item:" << (item ? "set" : "nullptr"); currentFocusItem = item; } QGraphicsItem *CGraphicsScene::getCurrentFocusItem() const { + // qCDebug(ClientLogger) << "CGraphicsScene::getCurrentFocusItem called, returning:" << (currentFocusItem ? "item" : "nullptr"); return currentFocusItem; } void CGraphicsScene::setKeyPressPrxy(CKeyPressPrxy *keyPrxy) { + // qCDebug(ClientLogger) << "CGraphicsScene::setKeyPressPrxy called, keyPrxy:" << (keyPrxy ? "set" : "nullptr"); m_keyPrxy = keyPrxy; } void CGraphicsScene::currentFocusItemUpdate() { + // qCDebug(ClientLogger) << "CGraphicsScene::currentFocusItemUpdate called"; if (currentFocusItem != nullptr) { CFocusItem *item = dynamic_cast(currentFocusItem); + // qCDebug(ClientLogger) << "Updating focus state for current item"; item->setItemFocus(true); } } @@ -68,6 +78,7 @@ void CGraphicsScene::currentFocusItemUpdate() */ void CGraphicsScene::setPrePage(const QDate &focusDate, bool isSwitchView) { + qCDebug(ClientLogger) << "CGraphicsScene::setPrePage called with date:" << focusDate << "switchView:" << isSwitchView; emit signalSwitchPrePage(focusDate, isSwitchView); } @@ -78,24 +89,31 @@ void CGraphicsScene::setPrePage(const QDate &focusDate, bool isSwitchView) */ void CGraphicsScene::setNextPage(const QDate &focusDate, bool isSwitchView) { + qCDebug(ClientLogger) << "CGraphicsScene::setNextPage called with date:" << focusDate << "switchView:" << isSwitchView; emit signalSwitchNextPage(focusDate, isSwitchView); } bool CGraphicsScene::event(QEvent *event) { + // qCDebug(ClientLogger) << "CGraphicsScene::event called with event type:" << event->type(); bool dealResult = false; if (event->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = dynamic_cast(event); + qCDebug(ClientLogger) << "CGraphicsScene::event - KeyPress event with key:" << keyEvent->key(); if (m_keyPrxy != nullptr && m_keyPrxy->keyPressDeal(keyEvent->key())) { + qCDebug(ClientLogger) << "Key press handled by proxy"; dealResult = true; } //如果为左右键处理则设置为true if (dealResult == false && (keyEvent->key() == Qt::Key_Left || keyEvent->key() == Qt::Key_Right)) { + qCDebug(ClientLogger) << "Left/Right key press detected, marking as handled"; dealResult = true; } if (keyEvent->modifiers() == Qt::ALT && keyEvent->key() == Qt::Key_M) { + qCDebug(ClientLogger) << "Alt+M key combination detected"; CSceneBackgroundItem *item = dynamic_cast(currentFocusItem); if (item != nullptr && item->getFocusItem()->getItemType() == CFocusItem::CITEM) { + qCDebug(ClientLogger) << "Emitting context menu signal for focus item"; dealResult = true; emit signalContextMenu(item->getFocusItem()); } @@ -103,10 +121,12 @@ bool CGraphicsScene::event(QEvent *event) } if (event->type() == QEvent::FocusIn) { + // qCDebug(ClientLogger) << "CGraphicsScene::event - FocusIn event"; dealResult = focusInDeal(event); } if (event->type() == QEvent::FocusOut) { + // qCDebug(ClientLogger) << "CGraphicsScene::event - FocusOut event"; dealResult = focusOutDeal(event); } return dealResult ? true : QGraphicsScene::event(event); @@ -114,24 +134,30 @@ bool CGraphicsScene::event(QEvent *event) bool CGraphicsScene::focusInDeal(QEvent *event) { + qCDebug(ClientLogger) << "CGraphicsScene::focusInDeal called"; bool dealResult = true; QFocusEvent *focusEvent = dynamic_cast(event); if (firstfocusItem != nullptr && (Qt::TabFocusReason == focusEvent->reason() || Qt::BacktabFocusReason == focusEvent->reason())) { + qCDebug(ClientLogger) << "Focus in with Tab/Backtab reason, showCurrentItem:" << m_isShowCurrentItem; if (m_isShowCurrentItem || currentFocusItem == nullptr) { if (currentFocusItem == nullptr) { + qCDebug(ClientLogger) << "No current focus item, using first focus item"; currentFocusItem = firstfocusItem; } CFocusItem *item = dynamic_cast(currentFocusItem); item->setItemFocus(true); } else { + qCDebug(ClientLogger) << "Handling Tab key press via proxy"; dealResult = m_keyPrxy->keyPressDeal(Qt::Key_Tab); //如果切换过来需要设置下一个item焦点,但是已经没有下一个item时,发送焦点切换信号 if (currentFocusItem == nullptr) { + qCDebug(ClientLogger) << "No more items, emitting next focus signal"; emit signalsetNextFocus(); } } } if (currentFocusItem != nullptr && Qt::ActiveWindowFocusReason == focusEvent->reason()) { + qCDebug(ClientLogger) << "Focus in with ActiveWindow reason"; CFocusItem *item = dynamic_cast(currentFocusItem); item->setItemFocus(true); } @@ -140,23 +166,29 @@ bool CGraphicsScene::focusInDeal(QEvent *event) bool CGraphicsScene::focusOutDeal(QEvent *event) { + qCDebug(ClientLogger) << "CGraphicsScene::focusOutDeal called"; QFocusEvent *focusEvent = dynamic_cast(event); if (currentFocusItem != nullptr) { CSceneBackgroundItem *item = dynamic_cast(currentFocusItem); if (Qt::ActiveWindowFocusReason == focusEvent->reason()) { + qCDebug(ClientLogger) << "Focus out with ActiveWindow reason, setting item focus to false"; item->setItemFocus(false); } else { //如果为右击菜单则更新焦点显示效果 if (m_isContextMenu) { + qCDebug(ClientLogger) << "Focus out with context menu active, setting item focus to false"; item->setItemFocus(false); } else { + qCDebug(ClientLogger) << "Focus out, initializing item state"; item->initState(); //如果为被动切换焦点则初始化当前焦点item if (getActiveSwitching() == false) { + qCDebug(ClientLogger) << "Passive focus switching, clearing current focus item"; currentFocusItem = nullptr; //通知另外一个视图初始化状态,因为全天和非全天之间tab切换保存了当前item信息 emit signalViewFocusInit(); } else { + qCDebug(ClientLogger) << "Active focus switching, resetting active switching flag"; setActiveSwitching(false); } } @@ -167,19 +199,23 @@ bool CGraphicsScene::focusOutDeal(QEvent *event) void CGraphicsScene::setIsContextMenu(bool isContextMenu) { + // qCDebug(ClientLogger) << "CGraphicsScene::setIsContextMenu called with value:" << isContextMenu; m_isContextMenu = isContextMenu; } void CGraphicsScene::setIsShowCurrentItem(bool isShowCurrentItem) { + // qCDebug(ClientLogger) << "CGraphicsScene::setIsShowCurrentItem called with value:" << isShowCurrentItem; m_isShowCurrentItem = isShowCurrentItem; } void CGraphicsScene::currentItemInit() { + // qCDebug(ClientLogger) << "CGraphicsScene::currentItemInit called"; if (currentFocusItem != nullptr) { CSceneBackgroundItem *item = dynamic_cast(currentFocusItem); if (item != nullptr) { + // qCDebug(ClientLogger) << "Initializing current item state"; item->initState(); } currentFocusItem = nullptr; @@ -188,10 +224,12 @@ void CGraphicsScene::currentItemInit() bool CGraphicsScene::getActiveSwitching() const { + // qCDebug(ClientLogger) << "CGraphicsScene::getActiveSwitching called, returning:" << m_activeSwitching; return m_activeSwitching; } void CGraphicsScene::setActiveSwitching(bool activeSwitching) { + // qCDebug(ClientLogger) << "CGraphicsScene::setActiveSwitching called with value:" << activeSwitching; m_activeSwitching = activeSwitching; } diff --git a/calendar-client/src/view/cweekdaygraphicsview.cpp b/calendar-client/src/view/cweekdaygraphicsview.cpp index 94d569806..8a3c98ea7 100644 --- a/calendar-client/src/view/cweekdaygraphicsview.cpp +++ b/calendar-client/src/view/cweekdaygraphicsview.cpp @@ -23,6 +23,7 @@ CWeekDayGraphicsview::CWeekDayGraphicsview(QWidget *parent, ViewPosition viewPos , m_coorManage(new CScheduleCoorManage) , m_rightmagin(0) { + qCDebug(ClientLogger) << "CWeekDayGraphicsview constructor - viewPos:" << viewPos << "viewType:" << viewtype; createBackgroundItem(); m_Scene->setFirstFocusItem(m_backgroundItem.first()); //添加键盘事件处理 @@ -30,9 +31,11 @@ CWeekDayGraphicsview::CWeekDayGraphicsview(QWidget *parent, ViewPosition viewPos m_keyPrxy->addkeyPressDeal(new CWeekDaySceneTabKeyDeal(m_Scene)); m_keyPrxy->addkeyPressDeal(new CKeyEnableDeal(m_Scene)); if (m_viewType == ALLDayView) { + qCDebug(ClientLogger) << "Adding ALL day key handlers"; m_keyPrxy->addkeyPressDeal(new CAllDayKeyLeftDeal(m_Scene)); m_keyPrxy->addkeyPressDeal(new CAllDayKeyRightDeal(m_Scene)); } else { + qCDebug(ClientLogger) << "Adding part time key handlers"; m_keyPrxy->addkeyPressDeal(new CKeyLeftDeal(m_Scene)); m_keyPrxy->addkeyPressDeal(new CKeyRightDeal(m_Scene)); } @@ -43,19 +46,24 @@ CWeekDayGraphicsview::CWeekDayGraphicsview(QWidget *parent, ViewPosition viewPos CWeekDayGraphicsview::~CWeekDayGraphicsview() { + qCDebug(ClientLogger) << "CWeekDayGraphicsview destructor"; delete m_coorManage; m_coorManage = nullptr; } void CWeekDayGraphicsview::setRange(int w, int h, QDate begindate, QDate enddate, int rightmagin) { + qCDebug(ClientLogger) << "CWeekDayGraphicsview::setRange - w:" << w << "h:" << h + << "begindate:" << begindate << "enddate:" << enddate << "rightmagin:" << rightmagin; m_MoveDate.setDate(begindate.addMonths(-2)); m_beginDate = begindate; m_endDate = enddate; //如果为全天区域 if (m_viewType == ALLDayView) { + qCDebug(ClientLogger) << "Adjusting width for ALL day view"; w -= 2; } else { + qCDebug(ClientLogger) << "Adjusting width for part time view"; w = w - rightmagin - 2; } setBackgroundDate(); @@ -66,6 +74,7 @@ void CWeekDayGraphicsview::setRange(int w, int h, QDate begindate, QDate enddate void CWeekDayGraphicsview::setRange(QDate begin, QDate end) { + qCDebug(ClientLogger) << "CWeekDayGraphicsview::setRange - begin:" << begin << "end:" << end; m_MoveDate.setDate(begin.addMonths(-2)); m_beginDate = begin; m_endDate = end; @@ -76,6 +85,7 @@ void CWeekDayGraphicsview::setRange(QDate begin, QDate end) void CWeekDayGraphicsview::setTheMe(int type) { + qCDebug(ClientLogger) << "CWeekDayGraphicsview::setTheMe - type:" << type; for (int i = 0; i < m_backgroundItem.size(); ++i) { m_backgroundItem.at(i)->setTheMe(type); } @@ -85,13 +95,17 @@ void CWeekDayGraphicsview::setTheMe(int type) CScheduleCoorManage *CWeekDayGraphicsview::getCoorManage() const { + qCDebug(ClientLogger) << "CWeekDayGraphicsview::getCoorManage called"; return m_coorManage; } void CWeekDayGraphicsview::setCurrentFocusItem(const QDate &focusDate, bool setItemFocus) { + qCDebug(ClientLogger) << "CWeekDayGraphicsview::setCurrentFocusItem - focusDate:" << focusDate + << "setItemFocus:" << setItemFocus; qint64 offset = m_backgroundItem.first()->getDate().daysTo(focusDate); if (offset >= 0 && offset < m_backgroundItem.size()) { + qCDebug(ClientLogger) << "Setting current focus item at offset:" << offset; m_Scene->setCurrentFocusItem(m_backgroundItem.at(static_cast(offset))); m_Scene->setIsShowCurrentItem(setItemFocus); } else { @@ -104,9 +118,12 @@ void CWeekDayGraphicsview::setCurrentFocusItem(const QDate &focusDate, bool setI void CWeekDayGraphicsview::setSceneRect(qreal x, qreal y, qreal w, qreal h) { + qCDebug(ClientLogger) << "CWeekDayGraphicsview::setSceneRect - x:" << x << "y:" << y << "w:" << w << "h:" << h; m_Scene->setSceneRect(x, y, w, h); const qreal backgroundItemHeight = h; const qreal backgroundItemWidth = w / m_backgroundItem.size(); + qCDebug(ClientLogger) << "Setting background item dimensions - width:" << backgroundItemWidth + << "height:" << backgroundItemHeight; for (int i = 0; i < m_backgroundItem.size(); ++i) { m_backgroundItem.at(i)->setDate(m_beginDate.addDays(i)); m_backgroundItem.at(i)->setRect(x + backgroundItemWidth * i, 0, backgroundItemWidth, backgroundItemHeight); @@ -115,8 +132,10 @@ void CWeekDayGraphicsview::setSceneRect(qreal x, qreal y, qreal w, qreal h) void CWeekDayGraphicsview::createBackgroundItem() { + qCDebug(ClientLogger) << "CWeekDayGraphicsview::createBackgroundItem called - viewPos:" << m_viewPos; if (m_viewPos == DayPos) { //日视图 + qCDebug(ClientLogger) << "Creating day view background item"; CWeekDayBackgroundItem *backgroundItem = new CWeekDayBackgroundItem(); connect(backgroundItem, &CWeekDayBackgroundItem::signalPosOnView, this, &CWeekDayGraphicsview::slotPosOnView); backgroundItem->setZValue(-1); @@ -124,18 +143,21 @@ void CWeekDayGraphicsview::createBackgroundItem() m_Scene->addItem(backgroundItem); //如果为非全天则设置背景焦点获取显示 if (m_viewType == PartTimeView) { + qCDebug(ClientLogger) << "Setting part time view focus for day view"; backgroundItem->setShowFocus(true); } //设置编号 backgroundItem->setBackgroundNum(0); } else { //周视图 + qCDebug(ClientLogger) << "Creating week view background items"; for (int i = 0; i < DDEWeekCalendar::AFewDaysofWeek; ++i) { CWeekDayBackgroundItem *item = new CWeekDayBackgroundItem(); connect(item, &CWeekDayBackgroundItem::signalPosOnView, this, &CWeekDayGraphicsview::slotPosOnView); item->setZValue(-1); if (m_backgroundItem.size() > 0) { - //设置对应左右和下一个 关系 + //设置对应左右和下一个关系 + qCDebug(ClientLogger) << "Setting navigation relationships for background item" << i; m_backgroundItem.last()->setNextFocusItem(item); m_backgroundItem.last()->setRightItem(item); item->setLeftItem(m_backgroundItem.last()); @@ -144,6 +166,7 @@ void CWeekDayGraphicsview::createBackgroundItem() item->setDrawDividingLine(true); //如果为非全天则设置背景焦点获取显示 if (m_viewType == PartTimeView) { + qCDebug(ClientLogger) << "Setting part time view focus for week item" << i; item->setShowFocus(true); } //设置编号 @@ -152,12 +175,15 @@ void CWeekDayGraphicsview::createBackgroundItem() m_Scene->addItem(item); } } + qCDebug(ClientLogger) << "Created" << m_backgroundItem.size() << "background items"; } void CWeekDayGraphicsview::setSceneCurrentItemFocus(const QDate &focusDate) { + qCDebug(ClientLogger) << "CWeekDayGraphicsview::setSceneCurrentItemFocus - focusDate:" << focusDate; int offset = static_cast(m_backgroundItem.first()->getDate().daysTo(focusDate)); if (offset >= 0 && offset < m_backgroundItem.size()) { + qCDebug(ClientLogger) << "Setting scene current focus item at offset:" << offset; m_Scene->setCurrentFocusItem(m_backgroundItem.at(offset)); m_Scene->currentFocusItemUpdate(); } else { @@ -173,6 +199,7 @@ void CWeekDayGraphicsview::setSceneCurrentItemFocus(const QDate &focusDate) */ void CWeekDayGraphicsview::updateBackgroundShowItem() { + qCDebug(ClientLogger) << "CWeekDayGraphicsview::updateBackgroundShowItem called"; for (int i = 0; i < m_backgroundItem.size(); ++i) { m_backgroundItem.at(i)->updateShowItem(); } @@ -183,6 +210,7 @@ void CWeekDayGraphicsview::updateBackgroundShowItem() */ void CWeekDayGraphicsview::setBackgroundDate() { + qCDebug(ClientLogger) << "CWeekDayGraphicsview::setBackgroundDate called"; for (int i = 0; i < m_backgroundItem.size(); ++i) { m_backgroundItem.at(i)->setDate(m_beginDate.addDays(i)); } @@ -190,20 +218,26 @@ void CWeekDayGraphicsview::setBackgroundDate() void CWeekDayGraphicsview::slotSwitchView(const QDate &focusDate, bool setItemFocus) { + qCDebug(ClientLogger) << "CWeekDayGraphicsview::slotSwitchView - focusDate:" << focusDate + << "setItemFocus:" << setItemFocus << "current viewType:" << m_viewType; if (m_viewType == ALLDayView) { + qCDebug(ClientLogger) << "Switching from ALLDayView to PartTimeView"; emit signaleSwitchToView(focusDate, PartTimeView, setItemFocus); } else { + qCDebug(ClientLogger) << "Switching from PartTimeView to ALLDayView"; emit signaleSwitchToView(focusDate, ALLDayView, setItemFocus); } } void CWeekDayGraphicsview::slotViewInit() { + qCDebug(ClientLogger) << "CWeekDayGraphicsview::slotViewInit called"; m_Scene->currentItemInit(); } void CWeekDayGraphicsview::slotPosOnView(const qreal y) { + qCDebug(ClientLogger) << "CWeekDayGraphicsview::slotPosOnView - y:" << y; //定位到当前焦点的item QPointF point(m_Scene->width() / 2, y); centerOn(point); diff --git a/calendar-client/src/view/draginfographicsview.cpp b/calendar-client/src/view/draginfographicsview.cpp index 023b56c41..1f68bf14c 100644 --- a/calendar-client/src/view/draginfographicsview.cpp +++ b/calendar-client/src/view/draginfographicsview.cpp @@ -41,6 +41,7 @@ DragInfoGraphicsView::DragInfoGraphicsView(DWidget *parent) , m_rightMenu(new DMenu(this)) , m_MoveDate(QDateTime::currentDateTime()) { + qCDebug(ClientLogger) << "DragInfoGraphicsView constructor"; setFrameShape(QFrame::NoFrame); setScene(m_Scene); setContentsMargins(0, 0, 0, 0); @@ -86,16 +87,20 @@ DragInfoGraphicsView::DragInfoGraphicsView(DWidget *parent) DragInfoGraphicsView::~DragInfoGraphicsView() { + qCDebug(ClientLogger) << "DragInfoGraphicsView destructor"; } void DragInfoGraphicsView::mousePressEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::mousePressEvent at" << event->pos(); if (event->button() != Qt::LeftButton) { + qCDebug(ClientLogger) << "Not left button, ignoring press event"; return; } stopTouchAnimation(); if (event->source() == Qt::MouseEventSynthesizedByQt) { //如果为触摸点击则记录相关状态并改变触摸状态 + qCDebug(ClientLogger) << "Touch event detected"; DGraphicsView::mousePressEvent(event); m_TouchBeginPoint = event->pos(); m_TouchBeginTime = QDateTime::currentDateTime().toMSecsSinceEpoch(); @@ -110,12 +115,16 @@ void DragInfoGraphicsView::mousePressEvent(QMouseEvent *event) void DragInfoGraphicsView::mouseReleaseEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::mouseReleaseEvent at" << event->pos(); if (event->button() == Qt::RightButton) { + qCDebug(ClientLogger) << "Right button release, ignoring"; return; } if (event->source() == Qt::MouseEventSynthesizedByQt) { + qCDebug(ClientLogger) << "Touch event release, current state:" << m_touchState; //如果为触摸点击状态则调用左击事件处理 if (m_touchState == TS_PRESS) { + qCDebug(ClientLogger) << "Processing touch press as mouse press"; mousePress(m_TouchBeginPoint.toPoint()); } if (m_touchState == TS_SLIDE) { @@ -123,11 +132,13 @@ void DragInfoGraphicsView::mouseReleaseEvent(QMouseEvent *event) const qint64 timeOffset = QDateTime::currentDateTime().toMSecsSinceEpoch() - m_TouchBeginTime; //如果为快速滑动则开启滑动动画效果 if (timeOffset < 150) { + qCDebug(ClientLogger) << "Fast slide detected, starting animation"; m_touchAnimation->setStartValue(verticalScrollBar()->sliderPosition()); m_touchAnimation->setEndValue(verticalScrollBar()->minimum()); switch (m_touchMovingDir) { case touchGestureOperation::T_TOP: { //如果手势往上 + qCDebug(ClientLogger) << "Gesture direction: UP"; m_touchAnimation->setStartValue(verticalScrollBar()->sliderPosition()); m_touchAnimation->setEndValue(verticalScrollBar()->maximum()); m_touchAnimation->start(); @@ -135,6 +146,7 @@ void DragInfoGraphicsView::mouseReleaseEvent(QMouseEvent *event) } case touchGestureOperation::T_BOTTOM: { //如果手势往下 + qCDebug(ClientLogger) << "Gesture direction: DOWN"; m_touchAnimation->setStartValue(verticalScrollBar()->sliderPosition()); m_touchAnimation->setEndValue(verticalScrollBar()->minimum()); m_touchAnimation->start(); @@ -155,9 +167,11 @@ void DragInfoGraphicsView::mouseReleaseEvent(QMouseEvent *event) void DragInfoGraphicsView::mouseMoveEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::mouseMoveEvent at" << event->pos(); //移动偏移 const int lengthOffset = 5; if (event->source() == Qt::MouseEventSynthesizedByQt) { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::mouseMoveEvent - Touch move event, current state:" << m_touchState; m_touchMovingDir = touchGestureOperation::T_MOVE_NONE; switch (m_touchState) { case TS_NONE: { @@ -171,11 +185,13 @@ void DragInfoGraphicsView::mouseMoveEvent(QMouseEvent *event) qreal movingLength = QLineF(m_TouchBeginPoint, event->pos()).length(); //如果移动距离小于5且点击时间大于250毫秒小于900毫秒则为拖拽移动状态 if (movingLength < lengthOffset && (timeOffset > 250 && timeOffset < 900)) { + qCDebug(ClientLogger) << "Changing touch state to drag move"; m_touchState = TS_DRAG_MOVE; m_touchDragMoveState = 1; } //如果移动距离大于5则为滑动状态 if (movingLength > lengthOffset) { + qCDebug(ClientLogger) << "Changing touch state to slide"; m_touchState = TS_SLIDE; } break; @@ -187,10 +203,12 @@ void DragInfoGraphicsView::mouseMoveEvent(QMouseEvent *event) qreal movingLength = QLineF(m_TouchBeginPoint, event->pos()).length(); //如果移动距离小于5且点击时间大于900毫秒则为长按状态 if (movingLength < lengthOffset && (timeOffset > 900)) { + qCDebug(ClientLogger) << "Changing touch state to long press"; m_touchState = TS_LONG_PRESS; } if (movingLength > lengthOffset) { if (m_touchDragMoveState == 1) { + qCDebug(ClientLogger) << "Processing touch drag as mouse press"; mousePress(m_TouchBeginPoint.toPoint()); } m_touchDragMoveState = 2; @@ -200,6 +218,7 @@ void DragInfoGraphicsView::mouseMoveEvent(QMouseEvent *event) case TS_SLIDE: { //3 滑动 QPointF _currentPoint = event->pos(); + qCDebug(ClientLogger) << "Processing slide event"; slideEvent(m_TouchBeginPoint, _currentPoint); break; } @@ -209,6 +228,7 @@ void DragInfoGraphicsView::mouseMoveEvent(QMouseEvent *event) } if (m_press) { + qCDebug(ClientLogger) << "Mouse moved while pressed, hiding schedule and resetting press state"; emit signalScheduleShow(false); m_press = false; DragInfoItem::setPressFlag(false); @@ -219,7 +239,9 @@ void DragInfoGraphicsView::mouseMoveEvent(QMouseEvent *event) if (item != nullptr) { if (isCanDragge(item->getData())) { if (m_DragStatus == NONE) { - switch (getPosInItem(event->pos(), item->rect())) { + PosInItem position = getPosInItem(event->pos(), item->rect()); + qCDebug(ClientLogger) << "Mouse over draggable item, position:" << position; + switch (position) { case LEFT: case RIGHT: setCursor(Qt::SplitHCursor); @@ -241,6 +263,7 @@ void DragInfoGraphicsView::mouseMoveEvent(QMouseEvent *event) } } else { QDateTime gDate = getPosDate(event->pos()); + qCDebug(ClientLogger) << "Mouse move with drag status:" << m_DragStatus << "at date:" << gDate; switch (m_DragStatus) { case IsCreate: if (gDate.date().year() >= DDECalendar::QueryEarliestYear && gDate.date().year() <= DDECalendar::QueryLatestYear) { @@ -248,6 +271,7 @@ void DragInfoGraphicsView::mouseMoveEvent(QMouseEvent *event) //如果拖拽创建为false则判断是否可被创建。如果为true则不需要判断 m_isCreate = m_isCreate ? m_isCreate : JudgeIsCreate(event->pos()); if (m_isCreate) { + qCDebug(ClientLogger) << "Creating schedule via drag"; if (!IsEqualtime(m_MoveDate, gDate)) { m_MoveDate = gDate; m_DragScheduleInfo = getScheduleInfo(m_PressDate, m_MoveDate); @@ -262,6 +286,7 @@ void DragInfoGraphicsView::mouseMoveEvent(QMouseEvent *event) break; case ChangeBegin: if (!IsEqualtime(m_MoveDate, gDate)) { + qCDebug(ClientLogger) << "Changing schedule begin time to:" << gDate; m_MoveDate = gDate; //获取日程开始时间 QDateTime _beginTime = getDragScheduleInfoBeginTime(m_MoveDate); @@ -272,6 +297,7 @@ void DragInfoGraphicsView::mouseMoveEvent(QMouseEvent *event) break; case ChangeEnd: if (!IsEqualtime(m_MoveDate, gDate)) { + qCDebug(ClientLogger) << "Changing schedule end time to:" << gDate; m_MoveDate = gDate; m_DragScheduleInfo->setDtStart(m_InfoBeginTime); //获取结束时间 @@ -282,6 +308,7 @@ void DragInfoGraphicsView::mouseMoveEvent(QMouseEvent *event) break; case ChangeWhole: { if (!m_PressRect.contains(event->pos())) { + qCDebug(ClientLogger) << "Schedule dragged outside press rect, executing drag operation"; //拖拽前设置是否已经更新日程界面标志为否 m_hasUpdateMark = false; m_Drag->exec(Qt::MoveAction); @@ -290,6 +317,7 @@ void DragInfoGraphicsView::mouseMoveEvent(QMouseEvent *event) setCursor(Qt::ArrowCursor); //如果拖拽结束后没有修改日程则更新下界面日程显示 if (!m_hasUpdateMark) { + qCDebug(ClientLogger) << "No update mark after drag, updating info display"; updateInfo(); } } @@ -304,15 +332,18 @@ void DragInfoGraphicsView::mouseMoveEvent(QMouseEvent *event) void DragInfoGraphicsView::wheelEvent(QWheelEvent *event) { + qCDebug(ClientLogger) << "DragInfoGraphicsView::wheelEvent - angle delta:" << event->angleDelta(); stopTouchAnimation(); DGraphicsView::wheelEvent(event); } void DragInfoGraphicsView::contextMenuEvent(QContextMenuEvent *event) { + qCDebug(ClientLogger) << "DragInfoGraphicsView::contextMenuEvent at" << event->pos(); DGraphicsView::contextMenuEvent(event); //如果不为默认状态则不执行右击事件 if (m_DragStatus != NONE) { + qCDebug(ClientLogger) << "Not in NONE drag status, ignoring context menu event"; return; } emit signalScheduleShow(false); @@ -325,6 +356,7 @@ void DragInfoGraphicsView::contextMenuEvent(QContextMenuEvent *event) CScheduleItem *tt = dynamic_cast(listItem); if (tt != nullptr && tt->getType() != 0) { + qCDebug(ClientLogger) << "Schedule item with non-zero type, ignoring context menu"; return; } if (infoitem != nullptr && infoitem->isVisible()) { @@ -338,7 +370,9 @@ void DragInfoGraphicsView::contextMenuEvent(QContextMenuEvent *event) m_rightMenu->addAction(m_editAction); m_rightMenu->addAction(m_deleteAction); //如果日程是不可修改的则设置删除按钮无效 - m_deleteAction->setEnabled(!CScheduleOperation::scheduleIsInvariant(schData)); + bool canDelete = !CScheduleOperation::scheduleIsInvariant(schData); + qCDebug(ClientLogger) << "Schedule can be deleted:" << canDelete; + m_deleteAction->setEnabled(canDelete); QAction *action_t = m_rightMenu->exec(QCursor::pos()); @@ -347,13 +381,19 @@ void DragInfoGraphicsView::contextMenuEvent(QContextMenuEvent *event) CScheduleDlg dlg(0, this); dlg.setData(schData); if (dlg.exec() == DDialog::Accepted) { + qCDebug(ClientLogger) << "Schedule edit accepted, updating"; emit signalsUpdateSchedule(); emit sigStateChange(true); + } else { + qCDebug(ClientLogger) << "Schedule edit cancelled"; } } else if (action_t == m_deleteAction) { qCDebug(ClientLogger) << "Deleting schedule:" << schData->summary(); if(DeleteItem(schData)) { + qCDebug(ClientLogger) << "Schedule deleted, updating state"; emit sigStateChange(true); + } else { + qCDebug(ClientLogger) << "Schedule delete failed or cancelled"; } } } else { @@ -362,37 +402,44 @@ void DragInfoGraphicsView::contextMenuEvent(QContextMenuEvent *event) dlg.exec(); } } else { + qCDebug(ClientLogger) << "No info item at position, creating context menu for background"; RightClickToCreate(listItem, event->pos()); } } void DragInfoGraphicsView::dragEnterEvent(QDragEnterEvent *event) { + qCDebug(ClientLogger) << "DragInfoGraphicsView::dragEnterEvent with mime types:" << event->mimeData()->formats(); if (event->mimeData()->hasFormat("Info")) { QString str = event->mimeData()->data("Info"); DSchedule::Ptr info; DSchedule::fromJsonString(info, str); if (info.isNull()) { + qCDebug(ClientLogger) << "Invalid schedule info in drag data, ignoring"; event->ignore(); } //如果该日程是不能被拖拽的则忽略不接受 //重复日程不能被切换全天和非全天 if ((event->source() != this && info->recurs()) || !isCanDragge(info)) { + qCDebug(ClientLogger) << "Schedule cannot be dragged (recurring or non-draggable)"; event->ignore(); } else { + qCDebug(ClientLogger) << "Accepting drag for schedule"; event->accept(); //设置被修改的日程原始信息 m_PressScheduleInfo = info; } } else { + qCDebug(ClientLogger) << "Drag data does not have Info format, ignoring"; event->ignore(); } } void DragInfoGraphicsView::dragLeaveEvent(QDragLeaveEvent *event) { + qCDebug(ClientLogger) << "DragInfoGraphicsView::dragLeaveEvent"; Q_UNUSED(event); upDateInfoShow(); m_MoveDate = m_MoveDate.addMonths(-2); @@ -400,6 +447,7 @@ void DragInfoGraphicsView::dragLeaveEvent(QDragLeaveEvent *event) void DragInfoGraphicsView::dragMoveEvent(QDragMoveEvent *event) { + qCDebug(ClientLogger) << "DragInfoGraphicsView::dragMoveEvent at" << event->pos(); QString str = event->mimeData()->data("Info"); QDateTime gDate = getPosDate(event->pos()); QJsonParseError json_error; @@ -410,6 +458,7 @@ void DragInfoGraphicsView::dragMoveEvent(QDragMoveEvent *event) } if (!IsEqualtime(m_MoveDate, gDate)) { + qCDebug(ClientLogger) << "Move date changed to:" << gDate; m_MoveDate = gDate; QJsonObject rootobj = jsonDoc.object(); DSchedule::fromJsonString(m_DragScheduleInfo, str); @@ -421,17 +470,22 @@ void DragInfoGraphicsView::dragMoveEvent(QDragMoveEvent *event) void DragInfoGraphicsView::dropEvent(QDropEvent *event) { + qCDebug(ClientLogger) << "DragInfoGraphicsView::dropEvent at" << event->pos(); if (event->mimeData()->hasFormat("Info")) { if (event->source() != this || m_MoveDate != m_PressDate) { + qCDebug(ClientLogger) << "Schedule dropped, source:" << event->source() + << "move date:" << m_MoveDate << "press date:" << m_PressDate; //后面方法出现模态框,阻塞,导致拖拽图片不消失,手动先调用取消接口解决 QDrag::cancel(); auto startDate = m_DragScheduleInfo->dtStart(); auto endDate = m_DragScheduleInfo->dtEnd(); if (startDate.date().year() >= DDECalendar::QueryEarliestYear && endDate.date().year() <= DDECalendar::QueryLatestYear) { + qCDebug(ClientLogger) << "Schedule dates within valid range, updating schedule"; emit sigStateChange(true); updateScheduleInfo(m_DragScheduleInfo); } else { + qCDebug(ClientLogger) << "Schedule dates outside valid range, just updating display"; emit signalsUpdateSchedule(); } m_DragStatus = NONE; @@ -443,6 +497,7 @@ void DragInfoGraphicsView::dropEvent(QDropEvent *event) bool DragInfoGraphicsView::event(QEvent *e) { if (e->type() == QEvent::Leave) { + // qCDebug(ClientLogger) << "Mouse left view area, checking for schedule update"; if (m_DragStatus == IsCreate || m_DragStatus == ChangeBegin || m_DragStatus == ChangeEnd) @@ -453,11 +508,13 @@ bool DragInfoGraphicsView::event(QEvent *e) void DragInfoGraphicsView::keyPressEvent(QKeyEvent *event) { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::keyPressEvent with key:" << event->key(); DGraphicsView::keyPressEvent(event); } void DragInfoGraphicsView::paintEvent(QPaintEvent *event) { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::paintEvent"; DGraphicsView::paintEvent(event); //绘制圆角效果 QPainter painter(viewport()); @@ -466,6 +523,7 @@ void DragInfoGraphicsView::paintEvent(QPaintEvent *event) painter.setBrush(m_outerBorderColor); //左下角绘制圆角补角,颜色与外框背景色一致 if (m_leftShowRadius) { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::paintEvent - Left show radius"; QPainterPath _leftPath; _leftPath.moveTo(0, this->height() - m_radius); _leftPath.arcTo(0, this->height() - m_radius * 2, m_radius * 2, m_radius * 2, 180, 90); @@ -475,6 +533,7 @@ void DragInfoGraphicsView::paintEvent(QPaintEvent *event) } //右下角绘制圆角补角 if (m_rightShowRadius) { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::paintEvent - Right show radius"; QPainterPath _rightPath; _rightPath.moveTo(this->width() - m_radius, this->height()); _rightPath.arcTo(this->width() - m_radius * 2, this->height() - m_radius * 2, m_radius * 2, m_radius * 2, 270, 90); @@ -487,6 +546,7 @@ void DragInfoGraphicsView::paintEvent(QPaintEvent *event) void DragInfoGraphicsView::showEvent(QShowEvent *event) { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::showEvent"; //显示时重置大小 resize(this->width(), this->height()); DGraphicsView::showEvent(event); @@ -494,6 +554,7 @@ void DragInfoGraphicsView::showEvent(QShowEvent *event) void DragInfoGraphicsView::slotCreate() { + qCDebug(ClientLogger) << "DragInfoGraphicsView::slotCreate"; slotCreate(m_createDate); } @@ -503,6 +564,7 @@ void DragInfoGraphicsView::slotCreate() */ void DragInfoGraphicsView::setPressSelectInfo(const DSchedule::Ptr &info) { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::setPressSelectInfo with info"; DragInfoItem::setPressSchedule(info); } @@ -512,6 +574,7 @@ void DragInfoGraphicsView::setPressSelectInfo(const DSchedule::Ptr &info) */ void DragInfoGraphicsView::updateScheduleInfo(const DSchedule::Ptr &info) { + qCDebug(ClientLogger) << "DragInfoGraphicsView::updateScheduleInfo with info"; QVariant variant; //获取主窗口指针 CalendarGlobalEnv::getGlobalEnv()->getValueByKey("MainWindow", variant); @@ -519,6 +582,7 @@ void DragInfoGraphicsView::updateScheduleInfo(const DSchedule::Ptr &info) //设置父类为主窗口 CScheduleOperation _scheduleOperation(info->scheduleTypeID(), qobject_cast(parent)); if (_scheduleOperation.changeSchedule(info, m_PressScheduleInfo)) { + qCDebug(ClientLogger) << "DragInfoGraphicsView::updateScheduleInfo - Schedule changed successfully"; //如果日程修改成功则更新更新标志 m_hasUpdateMark = true; } else { @@ -529,6 +593,7 @@ void DragInfoGraphicsView::updateScheduleInfo(const DSchedule::Ptr &info) void DragInfoGraphicsView::DragPressEvent(const QPoint &pos, DragInfoItem *item) { + qCDebug(ClientLogger) << "DragInfoGraphicsView::DragPressEvent with pos:" << pos; m_PressPos = pos; m_PressDate = getPosDate(pos); m_MoveDate = m_PressDate.addMonths(-2); @@ -538,6 +603,7 @@ void DragInfoGraphicsView::DragPressEvent(const QPoint &pos, DragInfoItem *item) if (item != nullptr) { PosInItem mpressstatus = getPosInItem(pos, item->boundingRect()); if (mpressstatus != MIDDLE && !isCanDragge(item->getData())) { + qCDebug(ClientLogger) << "DragInfoGraphicsView::DragPressEvent - Item cannot be dragged"; return; } //拖拽使用副本,不更改原始日程 @@ -547,22 +613,27 @@ void DragInfoGraphicsView::DragPressEvent(const QPoint &pos, DragInfoItem *item) m_InfoEndTime = m_DragScheduleInfo->dtEnd(); switch (mpressstatus) { case TOP: + qCDebug(ClientLogger) << "DragInfoGraphicsView::DragPressEvent - Top"; m_DragStatus = ChangeBegin; setCursor(Qt::SplitVCursor); break; case BOTTOM: + qCDebug(ClientLogger) << "DragInfoGraphicsView::DragPressEvent - Bottom"; m_DragStatus = ChangeEnd; setCursor(Qt::SplitVCursor); break; case LEFT: + qCDebug(ClientLogger) << "DragInfoGraphicsView::DragPressEvent - Left"; m_DragStatus = ChangeBegin; setCursor(Qt::SplitHCursor); break; case RIGHT: + qCDebug(ClientLogger) << "DragInfoGraphicsView::DragPressEvent - Right"; m_DragStatus = ChangeEnd; setCursor(Qt::SplitHCursor); break; default: + qCDebug(ClientLogger) << "DragInfoGraphicsView::DragPressEvent - Default"; ShowSchedule(item); m_DragStatus = ChangeWhole; QMimeData *mimeData = new QMimeData(); @@ -593,12 +664,14 @@ void DragInfoGraphicsView::DragPressEvent(const QPoint &pos, DragInfoItem *item) */ void DragInfoGraphicsView::mouseReleaseScheduleUpdate() { + qCDebug(ClientLogger) << "DragInfoGraphicsView::mouseReleaseScheduleUpdate"; setCursor(Qt::ArrowCursor); m_press = false; DragInfoItem::setPressFlag(false); switch (m_DragStatus) { case IsCreate: + qCDebug(ClientLogger) << "DragInfoGraphicsView::mouseReleaseScheduleUpdate - IsCreate"; if (MeetCreationConditions(m_MoveDate)) { //如果不添加会进入leaveEvent事件内的条件 m_DragStatus = NONE; @@ -615,6 +688,7 @@ void DragInfoGraphicsView::mouseReleaseScheduleUpdate() } break; case ChangeBegin: + qCDebug(ClientLogger) << "DragInfoGraphicsView::mouseReleaseScheduleUpdate - ChangeBegin"; if (!IsEqualtime(m_MoveDate, m_InfoBeginTime)) { //如果不添加会进入leaveEvent事件内的条件 m_DragStatus = NONE; @@ -622,6 +696,7 @@ void DragInfoGraphicsView::mouseReleaseScheduleUpdate() } break; case ChangeEnd: + qCDebug(ClientLogger) << "DragInfoGraphicsView::mouseReleaseScheduleUpdate - ChangeEnd"; if (!IsEqualtime(m_MoveDate, m_InfoEndTime)) { //如果不添加会进入leaveEvent事件内的条件 m_DragStatus = NONE; @@ -637,6 +712,7 @@ void DragInfoGraphicsView::mouseReleaseScheduleUpdate() void DragInfoGraphicsView::mousePress(const QPoint &point) { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::mousePress with point:" << point; setPressSelectInfo(DSchedule::Ptr()); //设置拖拽日程为无效日程 m_DragScheduleInfo = DSchedule::Ptr(); @@ -645,14 +721,17 @@ void DragInfoGraphicsView::mousePress(const QPoint &point) DragInfoItem *infoitem = dynamic_cast(listItem); //不满足拖拽条件的日程不进行拖拽事件 if (infoitem) { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::mousePress - Infoitem found"; setPressSelectInfo(infoitem->getData()); m_PressScheduleInfo = infoitem->getData(); m_press = true; if (isCanDragge(infoitem->getData())) { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::mousePress - Can drag"; //满足拖拽条件 DragInfoItem::setPressFlag(true); DragPressEvent(point, infoitem); } else { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::mousePress - Cannot drag"; //不满足拖拽条件,只展示信息弹窗 m_PressPos = point; m_PressDate = getPosDate(point); @@ -660,6 +739,7 @@ void DragInfoGraphicsView::mousePress(const QPoint &point) ShowSchedule(infoitem); } } else { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::mousePress - No infoitem"; //没有日程信息,可滑动 emit signalScheduleShow(false); DragPressEvent(point, infoitem); @@ -670,17 +750,20 @@ void DragInfoGraphicsView::mousePress(const QPoint &point) int DragInfoGraphicsView::getSlidePos() const { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::getSlidePos"; return m_touchSlidePos; } void DragInfoGraphicsView::setSlidePos(int pos) { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::setSlidePos with pos:" << pos; m_touchSlidePos = pos; verticalScrollBar()->setValue(m_touchSlidePos); } void DragInfoGraphicsView::stopTouchAnimation() { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::stopTouchAnimation"; m_touchAnimation->stop(); } @@ -690,13 +773,12 @@ void DragInfoGraphicsView::stopTouchAnimation() */ bool DragInfoGraphicsView::DeleteItem(const DSchedule::Ptr &info) { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::DeleteItem with info"; if (info.isNull()) { qCWarning(ClientLogger) << "Cannot delete null schedule"; return false; } - qCDebug(ClientLogger) << "Deleting schedule" - << "summary:" << info->summary() - << "type:" << info->scheduleTypeID(); + qCDebug(ClientLogger) << "Deleting schedule"; CScheduleOperation _scheduleOperation(info->scheduleTypeID(), this); return _scheduleOperation.deleteSchedule(info); } @@ -707,11 +789,13 @@ bool DragInfoGraphicsView::DeleteItem(const DSchedule::Ptr &info) */ void DragInfoGraphicsView::setSelectSearchSchedule(const DSchedule::Ptr &scheduleInfo) { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::setSelectSearchSchedule with scheduleInfo:" << scheduleInfo->summary(); setPressSelectInfo(scheduleInfo); } void DragInfoGraphicsView::setDragPixmap(QDrag *drag, DragInfoItem *item) { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::setDragPixmap with item:" << item->getData()->summary(); Q_UNUSED(item); //设置一个1*1的透明图片,要不然关闭窗口特效会有一个小黑点 QPixmap pixmap(1, 1); @@ -747,6 +831,7 @@ void DragInfoGraphicsView::slotCreate(const QDateTime &date) DSchedule::Ptr DragInfoGraphicsView::getScheduleInfo(const QDateTime &beginDate, const QDateTime &endDate) { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::getScheduleInfo with beginDate:" << beginDate << "endDate:" << endDate; DSchedule::Ptr info; info.reset(new DSchedule()); if (beginDate.daysTo(endDate) > 0) { @@ -767,6 +852,7 @@ DSchedule::Ptr DragInfoGraphicsView::getScheduleInfo(const QDateTime &beginDate, void DragInfoGraphicsView::ShowSchedule(DragInfoItem *infoitem) { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::ShowSchedule with infoitem:" << infoitem->getData()->summary(); if (infoitem == nullptr) return; emit signalScheduleShow(true, infoitem->getData()); @@ -775,6 +861,7 @@ void DragInfoGraphicsView::ShowSchedule(DragInfoItem *infoitem) void DragInfoGraphicsView::setTheMe(int type) { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::setTheMe with type:" << type; Q_UNUSED(type); DPalette _painte; //获取外框背景色 @@ -783,6 +870,7 @@ void DragInfoGraphicsView::setTheMe(int type) void DragInfoGraphicsView::slideEvent(QPointF &startPoint, QPointF &stopPort) { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::slideEvent with startPoint:" << startPoint << "stopPort:" << stopPort; qreal _movingLine {0}; //获取滑动方向 touchGestureOperation::TouchMovingDirection _touchMovingDir = @@ -795,12 +883,14 @@ void DragInfoGraphicsView::slideEvent(QPointF &startPoint, QPointF &stopPort) switch (_touchMovingDir) { case touchGestureOperation::T_TOP: case touchGestureOperation::T_BOTTOM: { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::slideEvent - Top or Bottom"; const int pos_Diff_Y = qFloor(stopPort.y() - startPoint.y()); verticalScrollBar()->setValue(verticalScrollBar()->sliderPosition() - pos_Diff_Y); startPoint = stopPort; break; } case touchGestureOperation::T_LEFT: { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::slideEvent - Left"; if (_movingLine > moveOffset) { delta = 1; startPoint = stopPort; @@ -808,6 +898,7 @@ void DragInfoGraphicsView::slideEvent(QPointF &startPoint, QPointF &stopPort) break; } case touchGestureOperation::T_RIGHT: { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::slideEvent - Right"; if (_movingLine > moveOffset) { delta = -1; startPoint = stopPort; @@ -827,8 +918,10 @@ void DragInfoGraphicsView::slideEvent(QPointF &startPoint, QPointF &stopPort) */ void DragInfoGraphicsView::updateInfo() { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::updateInfo"; //如果拖拽日程有效则更新为不是移动日程 if (m_DragScheduleInfo && m_DragScheduleInfo->isValid() && m_DragScheduleInfo->uid() != "0") { + qCDebug(ClientLogger) << "DragInfoGraphicsView::updateInfo - Update schedule data"; m_DragScheduleInfo->setMoved(false); //设置选择日程状态 setPressSelectInfo(m_DragScheduleInfo); @@ -837,17 +930,20 @@ void DragInfoGraphicsView::updateInfo() int DragInfoGraphicsView::getDragStatus() const { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::getDragStatus"; return m_DragStatus; } void DragInfoGraphicsView::setShowRadius(bool leftShow, bool rightShow) { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::setShowRadius with leftShow:" << leftShow << "rightShow:" << rightShow; m_leftShowRadius = leftShow; m_rightShowRadius = rightShow; } bool DragInfoGraphicsView::isCanDragge(const DSchedule::Ptr &info) { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::isCanDragge with info"; if (info.isNull() || info->scheduleTypeID().isEmpty()) return false; //是否为节假日日程判断 @@ -867,6 +963,7 @@ bool DragInfoGraphicsView::isCanDragge(const DSchedule::Ptr &info) */ void DragInfoGraphicsView::slotDeleteItem() { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::slotDeleteItem"; //获取选中日程 DSchedule::Ptr _pressSchedule = DragInfoItem::getPressSchedule(); @@ -886,6 +983,7 @@ void DragInfoGraphicsView::slotDeleteItem() if (!_pressSchedule.isNull() && _pressSchedule->isValid() && !CScheduleOperation::isFestival(_pressSchedule) && !CScheduleOperation::scheduleIsInvariant(_pressSchedule)) { + qCDebug(ClientLogger) << "DragInfoGraphicsView::slotDeleteItem - Delete schedule"; CScheduleOperation _scheduleOperation(_pressSchedule->scheduleTypeID(), this); _scheduleOperation.deleteSchedule(_pressSchedule); //设置选择日程为无效日程 @@ -897,27 +995,34 @@ void DragInfoGraphicsView::slotDeleteItem() void DragInfoGraphicsView::slotSwitchPrePage(const QDate &focusDate, bool isSwitchView) { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::slotSwitchPrePage with focusDate:" << focusDate << "isSwitchView:" << isSwitchView; emit signalSwitchPrePage(); if (isSwitchView) { + qCDebug(ClientLogger) << "DragInfoGraphicsView::slotSwitchPrePage - Switch view"; m_Scene->signalSwitchView(focusDate, true); } else { + qCDebug(ClientLogger) << "DragInfoGraphicsView::slotSwitchPrePage - Set scene current item focus"; setSceneCurrentItemFocus(focusDate); } } void DragInfoGraphicsView::slotSwitchNextPage(const QDate &focusDate, bool isSwitchView) { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::slotSwitchNextPage with focusDate:" << focusDate << "isSwitchView:" << isSwitchView; emit signalSwitchNextPage(); //如果需要切换视图则 if (isSwitchView) { + qCDebug(ClientLogger) << "DragInfoGraphicsView::slotSwitchNextPage - Switch view"; m_Scene->signalSwitchView(focusDate, true); } else { + qCDebug(ClientLogger) << "DragInfoGraphicsView::slotSwitchNextPage - Set scene current item focus"; setSceneCurrentItemFocus(focusDate); } } void DragInfoGraphicsView::slotContextMenu(CFocusItem *item) { + qCDebug(ClientLogger) << "DragInfoGraphicsView::slotContextMenu"; DragInfoItem *infoitem = dynamic_cast(item); if (infoitem != nullptr && infoitem->isVisible()) { DSchedule::Ptr schData = infoitem->getData(); @@ -945,12 +1050,14 @@ void DragInfoGraphicsView::slotContextMenu(CFocusItem *item) CScheduleDlg dlg(0, this); dlg.setData(schData); if (dlg.exec() == DDialog::Accepted) { + qCDebug(ClientLogger) << "DragInfoGraphicsView::slotContextMenu - Edit schedule successfully"; emit signalsUpdateSchedule(); emit sigStateChange(true); } } else if (action_t == m_deleteAction) { qCDebug(ClientLogger) << "Deleting focused schedule:" << schData->summary(); if(DeleteItem(schData)) { + qCDebug(ClientLogger) << "DragInfoGraphicsView::slotContextMenu - Delete schedule successfully"; emit sigStateChange(true); } } @@ -964,11 +1071,13 @@ void DragInfoGraphicsView::slotContextMenu(CFocusItem *item) */ void DragInfoGraphicsView::slotsetNextFocus() { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::slotsetNextFocus"; focusNextPrevChild(true); } void DragInfoGraphicsView::setSceneCurrentItemFocus(const QDate &focusDate) { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::setSceneCurrentItemFocus with focusDate:" << focusDate; Q_UNUSED(focusDate); } @@ -977,15 +1086,18 @@ void DragInfoGraphicsView::setSceneCurrentItemFocus(const QDate &focusDate) */ void DragInfoGraphicsView::pressScheduleInit() { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::pressScheduleInit"; m_PressScheduleInfo = DSchedule::Ptr(); } QDate DragInfoGraphicsView::getCurrentDate() const { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::getCurrentDate"; return m_currentDate; } void DragInfoGraphicsView::setCurrentDate(const QDate ¤tDate) { + // qCDebug(ClientLogger) << "DragInfoGraphicsView::setCurrentDate with currentDate:" << currentDate; m_currentDate = currentDate; } diff --git a/calendar-client/src/view/graphicsItem/calldayscheduleitem.cpp b/calendar-client/src/view/graphicsItem/calldayscheduleitem.cpp index a4ca3fe3b..d4ee9a29e 100644 --- a/calendar-client/src/view/graphicsItem/calldayscheduleitem.cpp +++ b/calendar-client/src/view/graphicsItem/calldayscheduleitem.cpp @@ -3,21 +3,25 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "calldayscheduleitem.h" +#include "commondef.h" #include CAllDayScheduleItem::CAllDayScheduleItem(QRectF rect, QGraphicsItem *parent) : DragInfoItem(rect, parent) { + qCDebug(ClientLogger) << "CAllDayScheduleItem constructor - rect:" << rect; } bool CAllDayScheduleItem::hasSelectSchedule(const DSchedule::Ptr &info) { + // qCDebug(ClientLogger) << "CAllDayScheduleItem::hasSelectSchedule"; return info == m_vScheduleInfo; } void CAllDayScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, const bool isPixMap) { + // qCDebug(ClientLogger) << "CAllDayScheduleItem::paintBackground - rect:" << rect; Q_UNUSED(isPixMap); m_font = DFontSizeManager::instance()->get(m_sizeType, m_font); painter->setRenderHints(QPainter::Antialiasing); @@ -29,23 +33,30 @@ void CAllDayScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, //判断是否为选中日程 if (m_vScheduleInfo == m_pressInfo) { + // qCDebug(ClientLogger) << "Schedule is pressed schedule"; //判断当前日程是否为拖拽移动日程 if (m_vScheduleInfo->isMoved() == m_pressInfo->isMoved()) { + // qCDebug(ClientLogger) << "Setting high flag to true"; m_vHighflag = true; } else { + // qCDebug(ClientLogger) << "Setting opacity to 0.4"; painter->setOpacity(0.4); textcolor.setAlphaF(0.4); } m_vSelectflag = m_press; } int themetype = CScheduleDataManage::getScheduleDataManage()->getTheme(); + // qCDebug(ClientLogger) << "Current theme type:" << themetype; QColor brushColor = gdColor.normalColor; if (m_vHoverflag) { + // qCDebug(ClientLogger) << "Schedule is hovered, using hover color"; brushColor = gdColor.hoverColor; } else if (m_vHighflag) { + // qCDebug(ClientLogger) << "Schedule is highlighted, using press color"; brushColor = gdColor.pressColor; } else if (m_vSelectflag) { + // qCDebug(ClientLogger) << "Schedule is selected, using press color with reduced opacity"; brushColor = gdColor.pressColor; textcolor.setAlphaF(0.4); } @@ -56,6 +67,7 @@ void CAllDayScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, //将直线开始点设为0,终点设为1,然后分段设置颜色 painter->setBrush(brushColor); if (getItemFocus() && isPixMap == false) { + // qCDebug(ClientLogger) << "Item has focus, drawing frame with system active color"; QPen framePen; framePen.setWidth(2); framePen.setColor(getSystemActiveColor()); @@ -74,8 +86,10 @@ void CAllDayScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, int _rightOffset = fm.horizontalAdvance("..."); //显示宽度 左侧偏移13右侧偏移8 qreal _showWidth = fillRect.width() - 13 - 8 - m_offset * 2; + // qCDebug(ClientLogger) << "Schedule title:" << str << "available width:" << _showWidth; //如果标题总长度大于显示长度则显示长度须减去"..."的长度 if (fm.horizontalAdvance(str) > _showWidth) { + // qCDebug(ClientLogger) << "Title too long, truncating"; _showWidth -= _rightOffset; for (int i = 0; i < str.count(); i++) { tStr.append(str.at(i)); @@ -92,10 +106,12 @@ void CAllDayScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, } else { tStr = str; } + // qCDebug(ClientLogger) << "Final display text:" << tStr; painter->drawText(QRectF(fillRect.topLeft().x() + 13, fillRect.y(), fillRect.width(), fillRect.height()), Qt::AlignLeft | Qt::AlignVCenter, tStr); if (m_vHoverflag && !m_vSelectflag) { + // qCDebug(ClientLogger) << "Drawing hover effect"; QRectF tRect = QRectF(fillRect.x() + 0.5, fillRect.y() + 0.5, fillRect.width() - 1, fillRect.height() - 1); painter->save(); @@ -117,6 +133,7 @@ void CAllDayScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, painter->restore(); } if (m_vSelectflag) { + // qCDebug(ClientLogger) << "Drawing selection effect"; QColor selcolor = "#000000"; selcolor.setAlphaF(0.05); painter->setBrush(selcolor); diff --git a/calendar-client/src/view/graphicsItem/cfocusitem.cpp b/calendar-client/src/view/graphicsItem/cfocusitem.cpp index bf0d2115d..3d5614e69 100644 --- a/calendar-client/src/view/graphicsItem/cfocusitem.cpp +++ b/calendar-client/src/view/graphicsItem/cfocusitem.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "cfocusitem.h" +#include "commondef.h" #include "scheduledatamanage.h" @@ -15,6 +16,7 @@ CFocusItem::CFocusItem(QGraphicsItem *parent) , m_itemType(CITEM) , m_isFocus(false) { + qCDebug(ClientLogger) << "CFocusItem constructor"; } /** @@ -23,6 +25,7 @@ CFocusItem::CFocusItem(QGraphicsItem *parent) */ void CFocusItem::setNextFocusItem(CFocusItem *nextFocusItem) { + // qCDebug(ClientLogger) << "CFocusItem::setNextFocusItem - next item:" << (nextFocusItem ? "set" : "null"); m_NextFocusItem = nextFocusItem; } @@ -32,6 +35,7 @@ void CFocusItem::setNextFocusItem(CFocusItem *nextFocusItem) */ void CFocusItem::setItemFocus(bool isFocus) { + // qCDebug(ClientLogger) << "CFocusItem::setItemFocus - isFocus:" << isFocus; m_isFocus = isFocus; this->scene()->update(); } @@ -42,6 +46,7 @@ void CFocusItem::setItemFocus(bool isFocus) */ bool CFocusItem::getItemFocus() const { + // qCDebug(ClientLogger) << "CFocusItem::getItemFocus - returning:" << m_isFocus; return m_isFocus; } @@ -51,6 +56,7 @@ bool CFocusItem::getItemFocus() const */ void CFocusItem::setItemType(CFocusItem::CItemType itemType) { + // qCDebug(ClientLogger) << "CFocusItem::setItemType - itemType:" << itemType; m_itemType = itemType; } @@ -60,6 +66,7 @@ void CFocusItem::setItemType(CFocusItem::CItemType itemType) */ CFocusItem::CItemType CFocusItem::getItemType() const { + // qCDebug(ClientLogger) << "CFocusItem::getItemType - returning:" << m_itemType; return m_itemType; } @@ -69,9 +76,13 @@ CFocusItem::CItemType CFocusItem::getItemType() const */ CFocusItem *CFocusItem::setNextItemFocusAndGetNextItem() { + qCDebug(ClientLogger) << "CFocusItem::setNextItemFocusAndGetNextItem called"; if (m_NextFocusItem != nullptr) { + qCDebug(ClientLogger) << "Setting focus to next item"; m_isFocus = false; m_NextFocusItem->setItemFocus(true); + } else { + qCDebug(ClientLogger) << "No next focus item available"; } return m_NextFocusItem; } @@ -82,10 +93,13 @@ CFocusItem *CFocusItem::setNextItemFocusAndGetNextItem() */ QColor CFocusItem::getSystemActiveColor() { - return CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); + QColor color = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); + // qCDebug(ClientLogger) << "CFocusItem::getSystemActiveColor - returning:" << color; + return color; } void CFocusItem::setDate(const QDate &date) { + // qCDebug(ClientLogger) << "CFocusItem::setDate - date:" << date; m_Date = date; } diff --git a/calendar-client/src/view/graphicsItem/cmonthdayitem.cpp b/calendar-client/src/view/graphicsItem/cmonthdayitem.cpp index 5d4fff463..038d8e1b0 100644 --- a/calendar-client/src/view/graphicsItem/cmonthdayitem.cpp +++ b/calendar-client/src/view/graphicsItem/cmonthdayitem.cpp @@ -5,6 +5,7 @@ #include "cmonthdayitem.h" #include "constants.h" #include "scheduledatamanage.h" +#include "commondef.h" #include @@ -17,6 +18,7 @@ CMonthDayItem::CMonthDayItem(QGraphicsItem *parent) , m_DayLunar("") , m_DayStatus(H_NONE) { + qCDebug(ClientLogger) << "CMonthDayItem constructor"; //设置字体 m_dayNumFont.setPixelSize(DDECalendar::FontSizeTwentyfour); m_dayNumFont.setWeight(QFont::Light); @@ -27,6 +29,7 @@ CMonthDayItem::CMonthDayItem(QGraphicsItem *parent) CMonthDayItem::~CMonthDayItem() { + qCDebug(ClientLogger) << "CMonthDayItem destructor"; } /** @@ -35,6 +38,7 @@ CMonthDayItem::~CMonthDayItem() */ void CMonthDayItem::setLunar(const QString &lunar) { + // qCDebug(ClientLogger) << "CMonthDayItem::setLunar - lunar:" << lunar; m_DayLunar = lunar; } @@ -44,6 +48,7 @@ void CMonthDayItem::setLunar(const QString &lunar) */ void CMonthDayItem::setStatus(const CMonthDayItem::HolidayStatus &status) { + // qCDebug(ClientLogger) << "CMonthDayItem::setStatus - status:" << status; m_DayStatus = status; } @@ -53,9 +58,11 @@ void CMonthDayItem::setStatus(const CMonthDayItem::HolidayStatus &status) */ void CMonthDayItem::setTheMe(int type) { + qCDebug(ClientLogger) << "CMonthDayItem::setTheMe - type:" << type; m_themetype = type; if (type == 0 || type == 1) { + qCDebug(ClientLogger) << "Setting light theme colors"; m_dayNumColor = "#000000"; m_dayNumCurrentColor = "#FFFFFF"; @@ -71,6 +78,7 @@ void CMonthDayItem::setTheMe(int type) m_BorderColor = "#000000"; m_BorderColor.setAlphaF(0.05); } else if (type == 2) { + qCDebug(ClientLogger) << "Setting dark theme colors"; m_dayNumColor = "#C0C6D4"; m_dayNumCurrentColor = "#B8D3FF"; @@ -92,6 +100,7 @@ void CMonthDayItem::setTheMe(int type) void CMonthDayItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { + // qCDebug(ClientLogger) << "CMonthDayItem::paint - date:" << m_Date << "isCurrentMonth:" << m_IsCurrentMonth; Q_UNUSED(option) Q_UNUSED(widget) const int hh = 36; @@ -101,20 +110,25 @@ void CMonthDayItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt if (m_LunarVisible) { switch (m_DayStatus) { case H_WORK: + // qCDebug(ClientLogger) << "Drawing work day background"; painter->setBrush(QBrush(m_banColor)); break; case H_REST: + // qCDebug(ClientLogger) << "Drawing rest day background"; painter->setBrush(QBrush(m_xiuColor)); break; default: + // qCDebug(ClientLogger) << "Drawing normal day background"; painter->setBrush(QBrush(m_fillColor)); break; } } else { + // qCDebug(ClientLogger) << "Lunar not visible, drawing normal background"; painter->setBrush(QBrush(m_fillColor)); } if (!m_IsCurrentMonth) { + // qCDebug(ClientLogger) << "Not current month, setting opacity to 0.4"; painter->setOpacity(0.4); } QPen pen; @@ -133,6 +147,7 @@ void CMonthDayItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt } //如果为当前时间 if (m_Date == QDate::currentDate()) { + // qCDebug(ClientLogger) << "Drawing current date highlight"; //设置不透明度为1 painter->setOpacity(1); QFont tFont = m_dayNumFont; @@ -159,6 +174,7 @@ void CMonthDayItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt painter->restore(); //绘制农历 if (m_LunarVisible) { + // qCDebug(ClientLogger) << "Drawing lunar text:" << m_DayLunar; QFontMetrics metrics(m_LunerFont); int Lunarwidth = metrics.horizontalAdvance(m_DayLunar); qreal filleRectX = this->rect().width() - 12 - 3 - (58 + Lunarwidth) / 2; @@ -170,10 +186,12 @@ void CMonthDayItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt // Use QIcon replace DIcon in order to fix image non-clear issue switch (m_DayStatus) { case H_WORK: { + // qCDebug(ClientLogger) << "Drawing work day icon"; QPixmap pixmap = QIcon(":/icons/deepin/builtin/icons/dde_calendar_ban_32px.svg").pixmap(iconSize); painter->drawPixmap(fillRectT, pixmap); } break; case H_REST: { + // qCDebug(ClientLogger) << "Drawing rest day icon"; QPixmap pixmap = QIcon(":/icons/deepin/builtin/icons/dde_calendar_xiu.svg").pixmap(iconSize); painter->drawPixmap(fillRectT, pixmap); } break; @@ -189,6 +207,7 @@ void CMonthDayItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt } //如果有焦点则绘制焦点效果 if (getItemFocus()) { + // qCDebug(ClientLogger) << "Drawing focus effect for day item at position:" << getBackgroundNum(); const int offset = 1; //获取tab图形 QRectF drawRect(rect().x() + offset, rect().y() + offset, rect().width() - offset * 2, rect().height() - offset * 2); @@ -209,6 +228,7 @@ void CMonthDayItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt path.moveTo(drawRect.x(), drawRect.y()); //如果为左下角则绘制圆角 if (this->getBackgroundNum() == 35) { + // qCDebug(ClientLogger) << "Drawing bottom-left corner with rounded edge"; path.lineTo(drawRect.x(), drawRect.y() + drawRect.height() - radius); QRectF arcRect(drawRect.x(), drawRect.y() + drawRect.height() - diameter, diameter, diameter); path.arcTo(arcRect, 180, 90); @@ -217,6 +237,7 @@ void CMonthDayItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt } //如果为右下角则绘制圆角 if (this->getBackgroundNum() == 41) { + // qCDebug(ClientLogger) << "Drawing bottom-right corner with rounded edge"; path.lineTo(drawRect.x() + drawRect.width() - radius, drawRect.y() + drawRect.height()); QRectF arcRect(drawRect.x() + drawRect.width() - diameter, drawRect.y() + drawRect.height() - diameter, diameter, diameter); path.arcTo(arcRect, 270, 90); diff --git a/calendar-client/src/view/graphicsItem/cmonthscheduleitem.cpp b/calendar-client/src/view/graphicsItem/cmonthscheduleitem.cpp index 7eb60b9b8..08007be39 100644 --- a/calendar-client/src/view/graphicsItem/cmonthscheduleitem.cpp +++ b/calendar-client/src/view/graphicsItem/cmonthscheduleitem.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "cmonthscheduleitem.h" +#include "commondef.h" #include @@ -10,15 +11,18 @@ CMonthScheduleItem::CMonthScheduleItem(QRect rect, QGraphicsItem *parent, int ed : DragInfoItem(rect, parent) , m_pos(13, 5) { + qCDebug(ClientLogger) << "CMonthScheduleItem constructor - rect:" << rect << "edittype:" << edittype; Q_UNUSED(edittype); } CMonthScheduleItem::~CMonthScheduleItem() { + qCDebug(ClientLogger) << "CMonthScheduleItem destructor"; } QPixmap CMonthScheduleItem::getPixmap() { + // qCDebug(ClientLogger) << "CMonthScheduleItem::getPixmap called"; QPixmap pixmap(this->rect().size().toSize()); pixmap.fill(Qt::transparent); QPainter painter(&pixmap); @@ -28,6 +32,10 @@ QPixmap CMonthScheduleItem::getPixmap() void CMonthScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, const bool isPixMap) { + // qCDebug(ClientLogger) << "CMonthScheduleItem::paintBackground - rect:" << rect + // << "isPixMap:" << isPixMap + // << "schedule:" << (m_vScheduleInfo ? m_vScheduleInfo->summary() : "null"); + qreal labelwidth = rect.width(); qreal labelheight = rect.height(); m_font = DFontSizeManager::instance()->get(m_sizeType, m_font); @@ -39,10 +47,13 @@ void CMonthScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, //判断是否为选中日程 if (!m_vScheduleInfo.isNull() && m_vScheduleInfo == m_pressInfo) { + // qCDebug(ClientLogger) << "Schedule is pressed schedule"; //判断当前日程是否为拖拽移动日程 if (m_vScheduleInfo->isMoved() == m_pressInfo->isMoved()) { + // qCDebug(ClientLogger) << "Setting high flag to true"; m_vHighflag = true; } else { + // qCDebug(ClientLogger) << "Setting opacity to 0.4"; painter->setOpacity(0.4); textcolor.setAlphaF(0.4); } @@ -50,22 +61,27 @@ void CMonthScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, } if (isPixMap) { + // qCDebug(ClientLogger) << "Drawing as pixmap, setting opacity to 0.6"; painter->setOpacity(0.6); textcolor.setAlphaF(0.8); } if (m_vSelectflag) { + // qCDebug(ClientLogger) << "Schedule is selected, using press color with reduced opacity"; brushColor = gdColor.pressColor; textcolor.setAlphaF(0.4); } else if (m_vHoverflag) { + // qCDebug(ClientLogger) << "Schedule is hovered, using hover color"; brushColor = gdColor.hoverColor; } else if (m_vHighflag) { + // qCDebug(ClientLogger) << "Schedule is highlighted, using press color"; brushColor = gdColor.pressColor; } // increase the height of the rectangle to make it look better QFontMetrics fm = painter->fontMetrics(); if (fm.height() > labelheight) { + // qCDebug(ClientLogger) << "Adjusting height for text - new height:" << (fm.height() + 2); labelheight = fm.height() + 2; } @@ -73,10 +89,12 @@ void CMonthScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, rect.y() + 2, labelwidth - 2, labelheight - 2); + // qCDebug(ClientLogger) << "Fill rect for schedule:" << fillRect; painter->save(); //将直线开始点设为0,终点设为1,然后分段设置颜色 painter->setBrush(brushColor); if (getItemFocus() && isPixMap == false) { + // qCDebug(ClientLogger) << "Item has focus, drawing frame with system active color"; QPen framePen; framePen.setWidth(2); framePen.setColor(getSystemActiveColor()); @@ -100,8 +118,10 @@ void CMonthScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, int _rightOffset = fm.horizontalAdvance("..."); //显示宽度 左侧偏移13右侧偏移8 qreal _showWidth = textWidth; + // qCDebug(ClientLogger) << "Schedule title:" << str << "available width:" << _showWidth; //如果标题总长度大于显示长度则显示长度须减去"..."的长度 if (fm.horizontalAdvance(str) > _showWidth) { + // qCDebug(ClientLogger) << "Title too long, truncating"; _showWidth -= _rightOffset; for (int i = 0; i < str.count(); i++) { tStr.append(str.at(i)); @@ -118,6 +138,7 @@ void CMonthScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, } else { tStr = str; } + // qCDebug(ClientLogger) << "Final display text:" << tStr; painter->drawText(QRectF(rect.x() + m_pos.x(), rect.y() + 1, @@ -126,6 +147,7 @@ void CMonthScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, Qt::AlignLeft | Qt::AlignVCenter, tStr); if (m_vHoverflag && !m_vSelectflag) { + // qCDebug(ClientLogger) << "Drawing hover effect"; QRectF tRect = QRectF(rect.x() + 2.5, rect.y() + 2.5, labelwidth - 3, labelheight - 3); painter->save(); painter->setRenderHints(QPainter::Antialiasing); @@ -150,6 +172,7 @@ void CMonthScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, } if (m_vSelectflag) { + // qCDebug(ClientLogger) << "Drawing selection effect"; QColor selcolor = "#000000"; selcolor.setAlphaF(0.05); painter->setBrush(selcolor); diff --git a/calendar-client/src/view/graphicsItem/cmonthschedulenumitem.cpp b/calendar-client/src/view/graphicsItem/cmonthschedulenumitem.cpp index a3d81e872..631484ad6 100644 --- a/calendar-client/src/view/graphicsItem/cmonthschedulenumitem.cpp +++ b/calendar-client/src/view/graphicsItem/cmonthschedulenumitem.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "cmonthschedulenumitem.h" +#include "commondef.h" #include @@ -10,11 +11,13 @@ CMonthScheduleNumItem::CMonthScheduleNumItem(QGraphicsItem *parent) : CFocusItem(parent) , m_num(0) { + qCDebug(ClientLogger) << "CMonthScheduleNumItem constructor"; setItemType(COTHER); } CMonthScheduleNumItem::~CMonthScheduleNumItem() { + qCDebug(ClientLogger) << "CMonthScheduleNumItem destructor"; } /** @@ -24,6 +27,7 @@ CMonthScheduleNumItem::~CMonthScheduleNumItem() */ void CMonthScheduleNumItem::setColor(QColor color1, QColor color2) { + qCDebug(ClientLogger) << "CMonthScheduleNumItem::setColor - color1:" << color1 << "color2:" << color2; m_color1 = color1; m_color2 = color2; } @@ -35,6 +39,7 @@ void CMonthScheduleNumItem::setColor(QColor color1, QColor color2) */ void CMonthScheduleNumItem::setText(QColor tColor, QFont font) { + qCDebug(ClientLogger) << "CMonthScheduleNumItem::setText - textColor:" << tColor << "font family:" << font.family(); m_textcolor = tColor; m_font = font; } @@ -45,11 +50,13 @@ void CMonthScheduleNumItem::setText(QColor tColor, QFont font) */ void CMonthScheduleNumItem::setSizeType(DFontSizeManager::SizeType sizeType) { + qCDebug(ClientLogger) << "CMonthScheduleNumItem::setSizeType - sizeType:" << sizeType; m_SizeType = sizeType; } void CMonthScheduleNumItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { + // qCDebug(ClientLogger) << "CMonthScheduleNumItem::paint - num:" << m_num << "focus:" << getItemFocus(); Q_UNUSED(option); Q_UNUSED(widget); qreal labelwidth = this->rect().width(); @@ -66,6 +73,7 @@ void CMonthScheduleNumItem::paint(QPainter *painter, const QStyleOptionGraphicsI painter->setRenderHints(QPainter::Antialiasing); painter->setBrush(linearGradient); if (getItemFocus()) { + // qCDebug(ClientLogger) << "Item has focus, drawing frame with system active color"; QPen framePen; framePen.setWidth(2); framePen.setColor(getSystemActiveColor()); @@ -78,6 +86,7 @@ void CMonthScheduleNumItem::paint(QPainter *painter, const QStyleOptionGraphicsI painter->setFont(m_font); painter->setPen(m_textcolor); QString str = QString(tr("%1 more")).arg(m_num) + "..."; + // qCDebug(ClientLogger) << "Original text:" << str; QFontMetrics fm = painter->fontMetrics(); QString tStr; for (int i = 0; i < str.count(); i++) { @@ -91,5 +100,6 @@ void CMonthScheduleNumItem::paint(QPainter *painter, const QStyleOptionGraphicsI if (tStr != str) { tStr = tStr + "..."; } + // qCDebug(ClientLogger) << "Final display text:" << tStr; painter->drawText(QRectF(rectX, rectY, labelwidth, labelheight + 4), Qt::AlignCenter, tStr); } diff --git a/calendar-client/src/view/graphicsItem/cscenebackgrounditem.cpp b/calendar-client/src/view/graphicsItem/cscenebackgrounditem.cpp index a596d93f6..4feb78804 100644 --- a/calendar-client/src/view/graphicsItem/cscenebackgrounditem.cpp +++ b/calendar-client/src/view/graphicsItem/cscenebackgrounditem.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "cscenebackgrounditem.h" +#include "commondef.h" #include #include @@ -19,6 +20,7 @@ CSceneBackgroundItem::CSceneBackgroundItem(ItemOnView view, QGraphicsItem *paren , m_showItemIndex(-1) , m_itemOfView(view) { + qCDebug(ClientLogger) << "CSceneBackgroundItem constructor - view:" << view; //设置item类型为背景显示 setItemType(CBACK); } @@ -29,12 +31,16 @@ CSceneBackgroundItem::CSceneBackgroundItem(ItemOnView view, QGraphicsItem *paren */ CFocusItem *CSceneBackgroundItem::setNextItemFocusAndGetNextItem() { + qCDebug(ClientLogger) << "CSceneBackgroundItem::setNextItemFocusAndGetNextItem - current showItemIndex:" << m_showItemIndex + << "items count:" << m_item.size(); CFocusItem *NextFocus = this; //若该区域没有item if (m_showItemIndex < 0 && m_item.size() == 0) { + qCDebug(ClientLogger) << "No items in this area, moving focus to next background item"; NextFocus = CFocusItem::setNextItemFocusAndGetNextItem(); } else if (m_showItemIndex == m_item.size() - 1) { //若切换到最后一个item + qCDebug(ClientLogger) << "At last item, resetting showItemIndex and moving focus to next background item"; m_item.at(m_showItemIndex)->setItemFocus(false); m_showItemIndex = -1; NextFocus = CFocusItem::setNextItemFocusAndGetNextItem(); @@ -42,14 +48,17 @@ CFocusItem *CSceneBackgroundItem::setNextItemFocusAndGetNextItem() //若该背景上有显示的item //若显示的item未设置focus则取消背景focus效果 if (m_showItemIndex == -1 && getItemFocus()) { + qCDebug(ClientLogger) << "No item has focus but background does, removing background focus"; this->setItemFocus(false); } //若显示的item有设置focus则取消该item focus效果 if (m_showItemIndex >= 0) { + qCDebug(ClientLogger) << "Removing focus from current item at index:" << m_showItemIndex; m_item.at(m_showItemIndex)->setItemFocus(false); } //当前显示的item编号+1并这是focus效果 ++m_showItemIndex; + qCDebug(ClientLogger) << "Setting focus to next item at index:" << m_showItemIndex; m_item.at(m_showItemIndex)->setItemFocus(true); } return NextFocus; @@ -63,19 +72,26 @@ CFocusItem *CSceneBackgroundItem::setNextItemFocusAndGetNextItem() */ bool compareItemData(const CFocusItem *itemfirst, const CFocusItem *itemsecond) { + qCDebug(ClientLogger) << "CSceneBackgroundItem::compareItemData - itemfirst:" << itemfirst->rect() + << "itemsecond:" << itemsecond->rect(); if (itemfirst->rect() == itemsecond->rect()) { + qCDebug(ClientLogger) << "CSceneBackgroundItem::compareItemData - itemfirst and itemsecond have the same rect"; return false; } //根据从上倒下从左至右的规则对矩阵的x,y坐标进行对比排序 if (qAbs(itemfirst->rect().y() - itemsecond->rect().y()) < 0.01) { if (itemfirst->rect().x() < itemsecond->rect().x()) { + qCDebug(ClientLogger) << "CSceneBackgroundItem::compareItemData - itemfirst is left of itemsecond"; return true; } else { + qCDebug(ClientLogger) << "CSceneBackgroundItem::compareItemData - itemfirst is right of itemsecond"; return false; } } else if (itemfirst->rect().y() < itemsecond->rect().y()) { + qCDebug(ClientLogger) << "CSceneBackgroundItem::compareItemData - itemfirst is above itemsecond"; return true; } else { + qCDebug(ClientLogger) << "CSceneBackgroundItem::compareItemData - itemfirst is below itemsecond"; return false; } } @@ -84,22 +100,26 @@ bool compareItemData(const CFocusItem *itemfirst, const CFocusItem *itemsecond) */ void CSceneBackgroundItem::updateShowItem() { + qCDebug(ClientLogger) << "CSceneBackgroundItem::updateShowItem for background:" << m_backgroundNum; m_item.clear(); //缩小背景矩阵,防止获取到其他背景上的item QRectF offsetRect = this->rect().marginsRemoved(QMarginsF(1, 1, 1, 1)); QList mlistitem = this->scene()->items(offsetRect); + qCDebug(ClientLogger) << "Found" << mlistitem.count() << "items in background area"; for (int i = 0; i < mlistitem.count(); ++i) { CFocusItem *item = dynamic_cast(mlistitem.at(i)); if (item != nullptr && item->getItemType() != CBACK) { m_item.append(item); } } + qCDebug(ClientLogger) << "Added" << m_item.size() << "focus items to background"; std::sort(m_item.begin(), m_item.end(), compareItemData); updateCurrentItemShow(); } int CSceneBackgroundItem::getShowItemCount() { + qCDebug(ClientLogger) << "CSceneBackgroundItem::getShowItemCount returning:" << m_item.size(); return m_item.size(); } @@ -109,6 +129,7 @@ int CSceneBackgroundItem::getShowItemCount() */ void CSceneBackgroundItem::setBackgroundNum(int num) { + // qCDebug(ClientLogger) << "CSceneBackgroundItem::setBackgroundNum - num:" << num; m_backgroundNum = num; } @@ -118,6 +139,7 @@ void CSceneBackgroundItem::setBackgroundNum(int num) */ int CSceneBackgroundItem::getBackgroundNum() const { + // qCDebug(ClientLogger) << "CSceneBackgroundItem::getBackgroundNum - returning:" << m_backgroundNum; return m_backgroundNum; } @@ -127,10 +149,14 @@ int CSceneBackgroundItem::getBackgroundNum() const */ void CSceneBackgroundItem::setItemFocus(bool isFocus) { + qCDebug(ClientLogger) << "CSceneBackgroundItem::setItemFocus - isFocus:" << isFocus + << "showItemIndex:" << m_showItemIndex; if (m_showItemIndex < 0) { + qCDebug(ClientLogger) << "Setting focus on background item itself"; CFocusItem::setItemFocus(isFocus); } else { if (m_showItemIndex < m_item.size()) { + qCDebug(ClientLogger) << "Setting focus on child item at index:" << m_showItemIndex; m_item.at(m_showItemIndex)->setItemFocus(isFocus); } } @@ -141,10 +167,13 @@ void CSceneBackgroundItem::setItemFocus(bool isFocus) */ void CSceneBackgroundItem::initState() { + qCDebug(ClientLogger) << "CSceneBackgroundItem::initState called"; if (getItemFocus()) { + qCDebug(ClientLogger) << "Removing focus from background item"; setItemFocus(false); } if (m_showItemIndex > -1 && m_showItemIndex < m_item.size()) { + qCDebug(ClientLogger) << "Removing focus from child item at index:" << m_showItemIndex; m_item.at(m_showItemIndex)->setItemFocus(false); } m_showItemIndex = -1; @@ -156,60 +185,83 @@ void CSceneBackgroundItem::initState() */ CFocusItem *CSceneBackgroundItem::getFocusItem() { + qCDebug(ClientLogger) << "CSceneBackgroundItem::getFocusItem - showItemIndex:" << m_showItemIndex; if (m_showItemIndex < 0) { + qCDebug(ClientLogger) << "CSceneBackgroundItem::getFocusItem - returning background item"; return this; } else { + qCDebug(ClientLogger) << "CSceneBackgroundItem::getFocusItem - returning child item at index:" << m_showItemIndex; return m_item.at(m_showItemIndex); } } CSceneBackgroundItem *CSceneBackgroundItem::getLeftItem() const { + // qCDebug(ClientLogger) << "CSceneBackgroundItem::getLeftItem - returning:" + // << (m_leftItem ? "item" : "nullptr"); return m_leftItem; } void CSceneBackgroundItem::setLeftItem(CSceneBackgroundItem *leftItem) { + // qCDebug(ClientLogger) << "CSceneBackgroundItem::setLeftItem - item:" + // << (leftItem ? "set" : "nullptr"); m_leftItem = leftItem; } CSceneBackgroundItem *CSceneBackgroundItem::getRightItem() const { + // qCDebug(ClientLogger) << "CSceneBackgroundItem::getRightItem - returning:" + // << (m_rightItem ? "item" : "nullptr"); return m_rightItem; } void CSceneBackgroundItem::setRightItem(CSceneBackgroundItem *rightItem) { + // qCDebug(ClientLogger) << "CSceneBackgroundItem::setRightItem - item:" + // << (rightItem ? "set" : "nullptr"); m_rightItem = rightItem; } CSceneBackgroundItem *CSceneBackgroundItem::getUpItem() const { + // qCDebug(ClientLogger) << "CSceneBackgroundItem::getUpItem - returning:" + // << (m_upItem ? "item" : "nullptr"); return m_upItem; } void CSceneBackgroundItem::setUpItem(CSceneBackgroundItem *upItem) { + // qCDebug(ClientLogger) << "CSceneBackgroundItem::setUpItem - item:" + // << (upItem ? "set" : "nullptr"); m_upItem = upItem; } CSceneBackgroundItem *CSceneBackgroundItem::getDownItem() const { + // qCDebug(ClientLogger) << "CSceneBackgroundItem::getDownItem - returning:" + // << (m_downItem ? "item" : "nullptr"); return m_downItem; } void CSceneBackgroundItem::setDownItem(CSceneBackgroundItem *downItem) { + // qCDebug(ClientLogger) << "CSceneBackgroundItem::setDownItem - item:" + // << (downItem ? "set" : "nullptr"); m_downItem = downItem; } void CSceneBackgroundItem::updateCurrentItemShow() { + qCDebug(ClientLogger) << "CSceneBackgroundItem::updateCurrentItemShow - showItemIndex:" << m_showItemIndex + << "items count:" << m_item.size(); if (m_showItemIndex >= 0) { if (m_item.size() > 0) { + qCDebug(ClientLogger) << "Setting focus to item at index:" << m_showItemIndex; m_showItemIndex = m_showItemIndex < m_item.size() ? m_showItemIndex : 0; m_item.at(m_showItemIndex)->setItemFocus(true); } else { + qCDebug(ClientLogger) << "No items available, setting focus to background"; m_showItemIndex = -1; setItemFocus(true); } @@ -218,5 +270,6 @@ void CSceneBackgroundItem::updateCurrentItemShow() CSceneBackgroundItem::ItemOnView CSceneBackgroundItem::getItemOfView() const { + // qCDebug(ClientLogger) << "CSceneBackgroundItem::getItemOfView - returning:" << m_itemOfView; return m_itemOfView; } diff --git a/calendar-client/src/view/graphicsItem/cweekdaybackgrounditem.cpp b/calendar-client/src/view/graphicsItem/cweekdaybackgrounditem.cpp index f109cdc1c..a5fab5bd2 100644 --- a/calendar-client/src/view/graphicsItem/cweekdaybackgrounditem.cpp +++ b/calendar-client/src/view/graphicsItem/cweekdaybackgrounditem.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "cweekdaybackgrounditem.h" +#include "commondef.h" #include #include @@ -13,14 +14,18 @@ CWeekDayBackgroundItem::CWeekDayBackgroundItem(QGraphicsItem *parent) , m_drawDividingLine(false) , m_showFocus(false) { + qCDebug(ClientLogger) << "CWeekDayBackgroundItem constructor"; } void CWeekDayBackgroundItem::setTheMe(int type) { + qCDebug(ClientLogger) << "CWeekDayBackgroundItem::setTheMe - type:" << type; if (type == 0 || type == 1) { + qCDebug(ClientLogger) << "Setting light theme colors"; m_weekColor = "#00429A"; m_weekColor.setAlphaF(0.05); } else { + qCDebug(ClientLogger) << "Setting dark theme colors"; m_weekColor = "#4F9BFF"; m_weekColor.setAlphaF(0.1); } @@ -28,12 +33,17 @@ void CWeekDayBackgroundItem::setTheMe(int type) void CWeekDayBackgroundItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { + // qCDebug(ClientLogger) << "CWeekDayBackgroundItem::paint - date:" << m_Date + // << "backgroundNum:" << getBackgroundNum() + // << "showFocus:" << m_showFocus + // << "hasFocus:" << getItemFocus(); Q_UNUSED(option) Q_UNUSED(widget) painter->setRenderHint(QPainter::Antialiasing); if (m_drawDividingLine) { //绘制分割线 if (this->getBackgroundNum() != 6) { + // qCDebug(ClientLogger) << "Drawing dividing line for day column"; // 分割线颜色 QColor m_linecolor = "#000000"; m_linecolor.setAlphaF(0.05); @@ -43,12 +53,14 @@ void CWeekDayBackgroundItem::paint(QPainter *painter, const QStyleOptionGraphics } //绘制周六周日背景 if (m_Date.dayOfWeek() > 5) { + // qCDebug(ClientLogger) << "Drawing weekend background for day:" << m_Date.dayOfWeek(); painter->setBrush(m_weekColor); painter->setPen(Qt::NoPen); painter->drawRect(this->rect()); } } if (m_showFocus && getItemFocus()) { + // qCDebug(ClientLogger) << "Drawing focus frame for background item"; QPen framePen; //设置边框宽度 framePen.setWidth(2); @@ -63,13 +75,17 @@ void CWeekDayBackgroundItem::paint(QPainter *painter, const QStyleOptionGraphics void CWeekDayBackgroundItem::updateCurrentItemShow() { + // qCDebug(ClientLogger) << "CWeekDayBackgroundItem::updateCurrentItemShow - showItemIndex:" << m_showItemIndex + // << "items count:" << m_item.size(); if (m_showItemIndex >= 0) { if (m_item.size() > 0) { m_showItemIndex = m_showItemIndex < m_item.size() ? m_showItemIndex : 0; m_item.at(m_showItemIndex)->setItemFocus(true); //定位到当前焦点item + // qCDebug(ClientLogger) << "Emitting signalPosOnView with position:" << m_item.at(m_showItemIndex)->rect().y(); emit signalPosOnView(m_item.at(m_showItemIndex)->rect().y()); } else { + // qCDebug(ClientLogger) << "No items available, setting focus to background"; m_showItemIndex = -1; setItemFocus(true); } @@ -78,23 +94,30 @@ void CWeekDayBackgroundItem::updateCurrentItemShow() bool CWeekDayBackgroundItem::showFocus() const { + // qCDebug(ClientLogger) << "CWeekDayBackgroundItem::showFocus returning:" << m_showFocus; return m_showFocus; } void CWeekDayBackgroundItem::setShowFocus(bool showFocus) { + // qCDebug(ClientLogger) << "CWeekDayBackgroundItem::setShowFocus - showFocus:" << showFocus; m_showFocus = showFocus; } void CWeekDayBackgroundItem::setItemFocus(bool isFocus) { + // qCDebug(ClientLogger) << "CWeekDayBackgroundItem::setItemFocus - isFocus:" << isFocus + // << "showFocus:" << m_showFocus + // << "showItemIndex:" << m_showItemIndex; //如果改背景不接受焦点切第一次设置进入该背景则设置该背景上第一个item接收focus if (m_showFocus == false && m_showItemIndex < 0) { if (hasNextSubItem()) { ++m_showItemIndex; + qCDebug(ClientLogger) << "Background doesn't accept focus, setting focus to first item at index:" << m_showItemIndex; m_item.at(m_showItemIndex)->setItemFocus(isFocus); } } else { + qCDebug(ClientLogger) << "Delegating focus setting to parent class"; CSceneBackgroundItem::setItemFocus(isFocus); } } @@ -103,20 +126,25 @@ bool CWeekDayBackgroundItem::hasNextSubItem() { bool result = true; if (m_showItemIndex < 0 && getShowItemCount() == 0) { + qCDebug(ClientLogger) << "No sub items available"; return false; } if (m_showItemIndex == getShowItemCount() - 1) { + qCDebug(ClientLogger) << "At last sub item"; return false; } + qCDebug(ClientLogger) << "Has next sub item"; return result; } bool CWeekDayBackgroundItem::drawDividingLine() const { + // qCDebug(ClientLogger) << "CWeekDayBackgroundItem::drawDividingLine returning:" << m_drawDividingLine; return m_drawDividingLine; } void CWeekDayBackgroundItem::setDrawDividingLine(bool drawDividingLine) { + // qCDebug(ClientLogger) << "CWeekDayBackgroundItem::setDrawDividingLine - drawDividingLine:" << drawDividingLine; m_drawDividingLine = drawDividingLine; } diff --git a/calendar-client/src/view/graphicsItem/draginfoitem.cpp b/calendar-client/src/view/graphicsItem/draginfoitem.cpp index ddc617b79..1366891fa 100644 --- a/calendar-client/src/view/graphicsItem/draginfoitem.cpp +++ b/calendar-client/src/view/graphicsItem/draginfoitem.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "draginfoitem.h" +#include "commondef.h" #include #include @@ -18,6 +19,7 @@ DragInfoItem::DragInfoItem(QRectF rect, QGraphicsItem *parent) : CFocusItem(parent) , m_rect(rect) { + qCDebug(ClientLogger) << "DragInfoItem constructor - rect:" << rect; setRect(m_rect); setAcceptHoverEvents(true); const int duration = 200; @@ -41,11 +43,12 @@ DragInfoItem::DragInfoItem(QRectF rect, QGraphicsItem *parent) DragInfoItem::~DragInfoItem() { - + qCDebug(ClientLogger) << "DragInfoItem destructor"; } void DragInfoItem::setData(const DSchedule::Ptr &vScheduleInfo) { + // qCDebug(ClientLogger) << "DragInfoItem::setData - schedule:" << (vScheduleInfo ? vScheduleInfo->summary() : "null"); QMutexLocker locker(&m_Mutex); m_vScheduleInfo = vScheduleInfo; } @@ -53,11 +56,13 @@ void DragInfoItem::setData(const DSchedule::Ptr &vScheduleInfo) DSchedule::Ptr DragInfoItem::getData() { QMutexLocker locker(&m_Mutex); + // qCDebug(ClientLogger) << "DragInfoItem::getData - returning schedule:" << (m_vScheduleInfo ? m_vScheduleInfo->summary() : "null"); return m_vScheduleInfo; } void DragInfoItem::setPressFlag(const bool flag) { + // qCDebug(ClientLogger) << "DragInfoItem::setPressFlag - flag:" << flag; m_press = flag; } @@ -67,6 +72,7 @@ void DragInfoItem::setPressFlag(const bool flag) */ void DragInfoItem::setPressSchedule(const DSchedule::Ptr &pressSchedule) { + // qCDebug(ClientLogger) << "DragInfoItem::setPressSchedule - schedule:" << (pressSchedule ? pressSchedule->summary() : "null"); m_pressInfo = pressSchedule; } @@ -76,6 +82,7 @@ void DragInfoItem::setPressSchedule(const DSchedule::Ptr &pressSchedule) */ DSchedule::Ptr DragInfoItem::getPressSchedule() { + // qCDebug(ClientLogger) << "DragInfoItem::getPressSchedule - returning schedule:" << (m_pressInfo ? m_pressInfo->summary() : "null"); return m_pressInfo; } @@ -85,16 +92,19 @@ DSchedule::Ptr DragInfoItem::getPressSchedule() */ void DragInfoItem::setSearchScheduleInfo(const DSchedule::List &searchScheduleInfo) { + // qCDebug(ClientLogger) << "DragInfoItem::setSearchScheduleInfo - count:" << searchScheduleInfo.size(); m_searchScheduleInfo = searchScheduleInfo; } void DragInfoItem::setFont(DFontSizeManager::SizeType type) { + // qCDebug(ClientLogger) << "DragInfoItem::setFont - type:" << type; m_sizeType = type; } void DragInfoItem::setOffset(const int &offset) { + qCDebug(ClientLogger) << "DragInfoItem::setOffset - offset:" << offset; m_offset = offset; setRect(QRectF(m_rect.x() - offset, m_rect.y() - offset / 2, @@ -105,31 +115,36 @@ void DragInfoItem::setOffset(const int &offset) void DragInfoItem::setStartValue(const int value) { + qCDebug(ClientLogger) << "DragInfoItem::setStartValue - value:" << value; m_properAnimationFirst->setStartValue(value); m_properAnimationSecond->setEndValue(value); } void DragInfoItem::setEndValue(const int value) { + qCDebug(ClientLogger) << "DragInfoItem::setEndValue - value:" << value; m_properAnimationFirst->setEndValue(value); m_properAnimationSecond->setStartValue(value); - } void DragInfoItem::startAnimation() { + qCDebug(ClientLogger) << "DragInfoItem::startAnimation - current state:" << m_Group->state(); if (m_Group->state() != QAnimationGroup::Running) { + qCDebug(ClientLogger) << "Starting animation"; m_Group->start(); } } void DragInfoItem::animationFinished() { + // qCDebug(ClientLogger) << "DragInfoItem::animationFinished"; m_isAnimation = false; } void DragInfoItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { + // qCDebug(ClientLogger) << "DragInfoItem::hoverEnterEvent"; QMutexLocker locker(&m_Mutex); Q_UNUSED(event); m_HoverInfo = m_vScheduleInfo; @@ -138,6 +153,7 @@ void DragInfoItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void DragInfoItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { + // qCDebug(ClientLogger) << "DragInfoItem::hoverLeaveEvent"; QMutexLocker locker(&m_Mutex); Q_UNUSED(event); m_HoverInfo = DSchedule::Ptr(); @@ -146,6 +162,8 @@ void DragInfoItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) void DragInfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { + // qCDebug(ClientLogger) << "DragInfoItem::paint - schedule:" + // << (m_vScheduleInfo ? m_vScheduleInfo->summary() : "null"); QMutexLocker locker(&m_Mutex); Q_UNUSED(option); Q_UNUSED(widget); diff --git a/calendar-client/src/view/graphicsItem/scheduleitem.cpp b/calendar-client/src/view/graphicsItem/scheduleitem.cpp index a36a51deb..11d562cc4 100644 --- a/calendar-client/src/view/graphicsItem/scheduleitem.cpp +++ b/calendar-client/src/view/graphicsItem/scheduleitem.cpp @@ -6,6 +6,7 @@ #include "schedulecoormanage.h" #include "scheduledatamanage.h" #include "calendarmanage.h" +#include "commondef.h" #include @@ -28,12 +29,14 @@ CScheduleItem::CScheduleItem(QRectF rect, QGraphicsItem *parent, int type) , m_transparentcolor("#000000") , m_timeFormat(CalendarManager::getInstance()->getTimeFormat()) { + qCDebug(ClientLogger) << "CScheduleItem constructor - rect:" << rect << "type:" << type; m_transparentcolor.setAlphaF(0.05); connect(CalendarManager::getInstance(), &CalendarManager::signalTimeFormatChanged, this, &CScheduleItem::timeFormatChanged); } CScheduleItem::~CScheduleItem() { + qCDebug(ClientLogger) << "CScheduleItem destructor"; } /** @@ -44,6 +47,8 @@ CScheduleItem::~CScheduleItem() */ void CScheduleItem::setData(const DSchedule::Ptr &info, QDate date, int totalNum) { + // qCDebug(ClientLogger) << "CScheduleItem::setData - schedule:" << (info ? info->summary() : "null") + // << "date:" << date << "totalNum:" << totalNum; m_vScheduleInfo = info; m_totalNum = totalNum; setDate(date); @@ -57,7 +62,10 @@ void CScheduleItem::setData(const DSchedule::Ptr &info, QDate date, int totalNum */ bool CScheduleItem::hasSelectSchedule(const DSchedule::Ptr &info) { - return info == m_vScheduleInfo; + bool result = (info == m_vScheduleInfo); + // qCDebug(ClientLogger) << "CScheduleItem::hasSelectSchedule - schedule:" << (info ? info->summary() : "null") + // << "result:" << result; + return result; } /** @@ -71,8 +79,12 @@ bool CScheduleItem::hasSelectSchedule(const DSchedule::Ptr &info) */ void CScheduleItem::splitText(QFont font, int w, int h, QString str, QStringList &listStr, QFontMetrics &fontM) { - if (str.isEmpty()) + // qCDebug(ClientLogger) << "CScheduleItem::splitText - width:" << w << "height:" << h + // << "text:" << str; + if (str.isEmpty()) { + qCDebug(ClientLogger) << "CScheduleItem::splitText - Text is empty, returning"; return; + } QFontMetrics fontMetrics(font); int heightT = fontM.height(); QString tStr; @@ -94,6 +106,7 @@ void CScheduleItem::splitText(QFont font, int w, int h, QString str, QStringList tListStr.append(tStr); if (w < 30) { + qCDebug(ClientLogger) << "Width too small (< 30), special handling for text"; QFontMetrics fm_s(fontM); QFontMetrics f_st(font); QString s = tListStr.at(0) + "..."; @@ -114,6 +127,7 @@ void CScheduleItem::splitText(QFont font, int w, int h, QString str, QStringList } } } else { + qCDebug(ClientLogger) << "Normal width handling for text"; for (int i = 0; i < tListStr.count(); i++) { if ((i + 1) * heightT <= h - 1) { listStr.append(tListStr.at(i)); @@ -136,6 +150,7 @@ void CScheduleItem::splitText(QFont font, int w, int h, QString str, QStringList } } } + qCDebug(ClientLogger) << "Final text split into" << listStr.count() << "lines"; } /** @@ -143,6 +158,7 @@ void CScheduleItem::splitText(QFont font, int w, int h, QString str, QStringList */ void CScheduleItem::timeFormatChanged(int value) { + qCDebug(ClientLogger) << "CScheduleItem::timeFormatChanged - value:" << value; if (value) { m_timeFormat = "hh:mm"; } else { @@ -159,6 +175,9 @@ void CScheduleItem::timeFormatChanged(int value) */ void CScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, const bool isPixMap) { + // qCDebug(ClientLogger) << "CScheduleItem::paintBackground - rect:" << rect + // << "isPixMap:" << isPixMap + // << "schedule:" << (m_vScheduleInfo ? m_vScheduleInfo->summary() : "null"); Q_UNUSED(isPixMap); //根据日程类型获取颜色 CSchedulesColor gdColor = CScheduleDataManage::getScheduleDataManage()->getScheduleColorByType(m_vScheduleInfo->scheduleTypeID()); @@ -166,10 +185,13 @@ void CScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, const QColor textPenColor = CScheduleDataManage::getScheduleDataManage()->getTextColor(); //判断是否为选中日程 if (m_vScheduleInfo == m_pressInfo) { + // qCDebug(ClientLogger) << "Schedule is selected"; //判断当前日程是否为拖拽移动日程 if (m_vScheduleInfo->isMoved() == m_pressInfo->isMoved()) { + // qCDebug(ClientLogger) << "Schedule is highlighted"; m_vHighflag = true; } else { + // qCDebug(ClientLogger) << "Schedule is dimmed (opacity 0.4)"; painter->setOpacity(0.4); textPenColor.setAlphaF(0.4); gdColor.orginalColor.setAlphaF(0.4); @@ -184,10 +206,13 @@ void CScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, const int h = fm.height(); if (m_vHoverflag) { + // qCDebug(ClientLogger) << "Schedule is hovered"; bColor = gdColor.hoverColor; } else if (m_vHighflag) { + // qCDebug(ClientLogger) << "Schedule is highlighted"; bColor = gdColor.hightColor; } else if (m_vSelectflag) { + // qCDebug(ClientLogger) << "Schedule is selected"; bColor = gdColor.pressColor; } painter->setBrush(bColor); @@ -195,6 +220,7 @@ void CScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, const painter->drawRect(rect); if (m_vHoverflag && !m_vSelectflag) { + // qCDebug(ClientLogger) << "Drawing hover effect"; painter->save(); QRectF tRect = QRectF(rect.x() + 0.5, rect.y() + 0.5, rect.width() - 1, rect.height() - 1); QPen tPen; @@ -214,6 +240,7 @@ void CScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, const painter->restore(); } if (m_vSelectflag) { + // qCDebug(ClientLogger) << "Adjusting opacity for selected schedule"; if (themetype == 0 || themetype == 1) { textPenColor.setAlphaF(0.4); gdColor.orginalColor.setAlphaF(0.4); @@ -238,6 +265,7 @@ void CScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, const tMargin = 5; if (m_type == 0) { + // qCDebug(ClientLogger) << "Drawing normal schedule item"; int timeTextHight = 0; QFont font; font.setWeight(QFont::Normal); @@ -246,16 +274,19 @@ void CScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, const //绘制日程起始时间 if (m_vScheduleInfo->dtStart().date() == getDate()) { + // qCDebug(ClientLogger) << "Drawing start time for schedule"; painter->save(); painter->setFont(font); painter->setPen(gdColor.orginalColor); QTime stime = m_vScheduleInfo->dtStart().time(); QString str = stime.toString((CalendarManager::getInstance()->getTimeShowType() ? "AP " : "") + m_timeFormat); + // qCDebug(ClientLogger) << "Start time text:" << str; QFontMetrics fontMetrics(font); qreal drawTextWidth = rect.width() - m_offset * 2; if (fm.horizontalAdvance(str) > drawTextWidth - 5) { + // qCDebug(ClientLogger) << "Time text too long, truncating"; QString tStr; for (int i = 0; i < str.count(); i++) { tStr.append(str.at(i)); @@ -272,6 +303,7 @@ void CScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, const } } QString tStrs = fontMetrics.elidedText(str, Qt::ElideRight, qRound(drawTextWidth - 5)); + // qCDebug(ClientLogger) << "Final time text:" << tStrs; painter->drawText( QRectF(rect.topLeft().x() + tMargin, rect.topLeft().y() + 3, drawTextWidth - 5, h), Qt::AlignLeft, tStrs); @@ -283,11 +315,13 @@ void CScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, const } painter->restore(); } else { + // qCDebug(ClientLogger) << "Not drawing start time (different date)"; timeTextHight = -20; } painter->save(); //绘制日程标题 + // qCDebug(ClientLogger) << "Drawing schedule title"; font = DFontSizeManager::instance()->get(DFontSizeManager::T6, font); font.setLetterSpacing(QFont::PercentageSpacing, 105); painter->setFont(font); @@ -304,6 +338,7 @@ void CScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, const for (int i = 0; i < liststr.count(); i++) { if ((20 + timeTextHight + (i + 1) * (h - 3)) > rect.height()) return; + // qCDebug(ClientLogger) << "Drawing title line" << i+1 << ":" << liststr.at(i); painter->drawText( QRect(textRect.topLeft().x() + tMargin, textRect.topLeft().y() + 20 + timeTextHight + i * (h - 3), @@ -313,6 +348,7 @@ void CScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, const } painter->restore(); } else { + // qCDebug(ClientLogger) << "Drawing more item indicator"; painter->save(); QFont font; font.setWeight(QFont::Normal); @@ -323,6 +359,7 @@ void CScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, const painter->restore(); } if (m_vSelectflag) { + // qCDebug(ClientLogger) << "Drawing selection overlay"; QColor selcolor = m_transparentcolor; selcolor.setAlphaF(0.05); painter->setBrush(selcolor); @@ -330,6 +367,7 @@ void CScheduleItem::paintBackground(QPainter *painter, const QRectF &rect, const painter->drawRect(rect); } if (getItemFocus()) { + // qCDebug(ClientLogger) << "Drawing focus frame"; //获取tab图形 QRectF drawRect = rect.marginsRemoved(QMarginsF(1, 1, 1, 1)); painter->setBrush(Qt::NoBrush); diff --git a/calendar-client/src/view/graphicsview.cpp b/calendar-client/src/view/graphicsview.cpp index c31d7db1f..4f1de1e80 100644 --- a/calendar-client/src/view/graphicsview.cpp +++ b/calendar-client/src/view/graphicsview.cpp @@ -11,6 +11,7 @@ #include "commondef.h" #include "myscheduleview.h" #include "constants.h" +#include "commondef.h" #include @@ -31,6 +32,7 @@ DGUI_USE_NAMESPACE CGraphicsView::CGraphicsView(QWidget *parent, ViewPosition Type) : CWeekDayGraphicsview(parent, Type, ViewType::PartTimeView) { + qCDebug(ClientLogger) << "CGraphicsView constructor - Type:" << Type; setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_timeInterval = height() / 24.0; @@ -56,6 +58,7 @@ CGraphicsView::CGraphicsView(QWidget *parent, ViewPosition Type) //如果为周视图 if (m_viewPos == WeekPos) { + qCDebug(ClientLogger) << "Week view detected, setting corner radius"; //设置显示右下角圆角 setShowRadius(false, true); } @@ -63,6 +66,7 @@ CGraphicsView::CGraphicsView(QWidget *parent, ViewPosition Type) CGraphicsView::~CGraphicsView() { + qCDebug(ClientLogger) << "CGraphicsView destructor"; m_timer->stop(); m_timer->deleteLater(); clearSchedule(); @@ -70,6 +74,8 @@ CGraphicsView::~CGraphicsView() void CGraphicsView::setMargins(int left, int top, int right, int bottom) { + qCDebug(ClientLogger) << "CGraphicsView::setMargins - left:" << left << "top:" << top + << "right:" << right << "bottom:" << bottom; Q_UNUSED(top) m_margins = QMargins(left, 0, right, bottom); setViewportMargins(m_margins); @@ -79,6 +85,7 @@ void CGraphicsView::setTheMe(int type) { qCDebug(ClientLogger) << "Setting theme" << "type:" << type; if (type == 0 || type == 1) { + qCDebug(ClientLogger) << "Setting light theme colors"; m_weekcolor = "#00429A"; m_weekcolor.setAlphaF(0.05); QColor linecolor = "#000000"; @@ -89,6 +96,7 @@ void CGraphicsView::setTheMe(int type) m_LRPen.setStyle(Qt::SolidLine); m_TBPen.setStyle(Qt::SolidLine); } else if (type == 2) { + qCDebug(ClientLogger) << "Setting dark theme colors"; m_weekcolor = "#4F9BFF"; m_weekcolor.setAlphaF(0.1); QColor linecolor = "#000000"; @@ -115,23 +123,27 @@ void CGraphicsView::slotCreate(const QDateTime &date) bool CGraphicsView::MeetCreationConditions(const QDateTime &date) { + // qCDebug(ClientLogger) << "CGraphicsView::MeetCreationConditions - date:" << date; return qAbs(date.daysTo(m_PressDate)) < 7; } void CGraphicsView::updateHeight() { + // qCDebug(ClientLogger) << "CGraphicsView::updateHeight"; scene()->update(); update(); } void CGraphicsView::setCurrentDate(const QDateTime ¤tDate) { + qCDebug(ClientLogger) << "CGraphicsView::setCurrentDate - date:" << currentDate; m_currentDateTime = currentDate; scrollBarValueChangedSlot(); } void CGraphicsView::setInfo(const DSchedule::List &info) { + // qCDebug(ClientLogger) << "CGraphicsView::setInfo - count:" << info.size(); m_scheduleInfo = info; } @@ -145,6 +157,7 @@ void CGraphicsView::upDateInfoShow(const CGraphicsView::DragStatus &status, cons switch (status) { case NONE: Q_UNUSED(info); + qCDebug(ClientLogger) << "Status: NONE, no action needed"; break; case ChangeBegin: case ChangeEnd: { @@ -169,6 +182,8 @@ void CGraphicsView::upDateInfoShow(const CGraphicsView::DragStatus &status, cons qint64 beginoffset = 0, endoffset = 0; DSchedule::List currentInfo; + // qCDebug(ClientLogger) << "Processing date range from" << m_beginDate << "to" << m_endDate + // << "(" << count << "days)"; for (int i = 0; i <= count; ++i) { currentDate = m_beginDate.addDays(i); currentInfo.clear(); @@ -192,6 +207,7 @@ void CGraphicsView::upDateInfoShow(const CGraphicsView::DragStatus &status, cons } std::sort(currentInfo.begin(), currentInfo.end()); if (currentInfo.size() > 0) { + qCDebug(ClientLogger) << "Found" << currentInfo.size() << "schedules for date" << currentDate; m_InfoMap[currentDate] = currentInfo; QList info; scheduleClassificationType(currentInfo, info); @@ -201,6 +217,8 @@ void CGraphicsView::upDateInfoShow(const CGraphicsView::DragStatus &status, cons //如果为周视图则要显示一个位置显示日程的数目 if (m_viewPos == WeekPos) { if (tNum > m_sMaxNum) { + // qCDebug(ClientLogger) << "Week view: too many schedules (" << tNum + // << "), showing only" << m_sMaxNum; tNum = m_sMaxNum; for (int n = 0; n < tNum - 1; n++) { addScheduleItem(info.at(m).vData.at(n), currentDate, n + 1, @@ -219,12 +237,14 @@ void CGraphicsView::upDateInfoShow(const CGraphicsView::DragStatus &status, cons addScheduleItem(tdetaliinfo, currentDate, tNum, tNum, 1, m_viewType, m_sMaxNum); } else { + qCDebug(ClientLogger) << "Week view: adding" << tNum << "schedules"; for (int n = 0; n < tNum; n++) { addScheduleItem(info.at(m).vData.at(n), currentDate, n + 1, tNum, 0, m_viewType, m_sMaxNum); } } } else { + qCDebug(ClientLogger) << "Day view: adding" << tNum << "schedules"; for (int n = 0; n < tNum; n++) { addScheduleItem(info.at(m).vData.at(n), currentDate, n + 1, tNum, 0, m_viewType, m_sMaxNum); @@ -234,31 +254,41 @@ void CGraphicsView::upDateInfoShow(const CGraphicsView::DragStatus &status, cons } } //更新每个背景上的日程标签 + qCDebug(ClientLogger) << "Updating background show items"; updateBackgroundShowItem(); } QDateTime CGraphicsView::getPosDate(const QPoint &p) { - return TimeRounding(m_coorManage->getDate(mapToScene(p))); + QDateTime result = TimeRounding(m_coorManage->getDate(mapToScene(p))); + // qCDebug(ClientLogger) << "CGraphicsView::getPosDate - point:" << p << "date:" << result; + return result; } void CGraphicsView::ShowSchedule(DragInfoItem *infoitem) { + qCDebug(ClientLogger) << "CGraphicsView::ShowSchedule - checking schedule type"; CScheduleItem *scheduleitem = dynamic_cast(infoitem); - if (scheduleitem->getType() == 1) + if (scheduleitem->getType() == 1) { + qCDebug(ClientLogger) << "Schedule is type 1, skipping show"; return; + } + qCDebug(ClientLogger) << "Showing schedule in parent view"; DragInfoGraphicsView::ShowSchedule(infoitem); } void CGraphicsView::MoveInfoProcess(DSchedule::Ptr &info, const QPointF &pos) { + qCDebug(ClientLogger) << "CGraphicsView::MoveInfoProcess - pos:" << pos; Q_UNUSED(pos); if (!info->allDay()) { qint64 offset = m_PressDate.secsTo(m_MoveDate); + qCDebug(ClientLogger) << "Moving schedule by" << offset << "seconds"; info->setDtStart(info->dtStart().addSecs(offset)); info->setDtEnd(info->dtEnd().addSecs(offset)); } else { + qCDebug(ClientLogger) << "Converting all-day schedule to timed schedule"; info->setAllDay(false); //提醒规则 info->setRRuleType(DSchedule::RRule_None); @@ -281,6 +311,7 @@ void CGraphicsView::addScheduleItem(const DSchedule::Ptr &info, QDate date, int viewtype), nullptr, type); if (type == 1) { + qCDebug(ClientLogger) << "Setting item type to COTHER"; item->setItemType(CFocusItem::COTHER); } m_Scene->addItem(item); @@ -294,21 +325,24 @@ void CGraphicsView::addScheduleItem(const DSchedule::Ptr &info, QDate date, int */ void CGraphicsView::setSelectSearchSchedule(const DSchedule::Ptr &info) { - qCDebug(ClientLogger) << "Setting selected search schedule" - << "summary:" << info->summary() - << "start:" << info->dtStart(); + qCDebug(ClientLogger) << "Setting selected search schedule"; DragInfoGraphicsView::setSelectSearchSchedule(info); setTime(info->dtStart().time()); + + int animatedCount = 0; for (int i = 0; i < m_vScheduleItem.size(); ++i) { if (m_vScheduleItem.at(i)->getType() == 1) continue; //判断是否为选中日程 if (m_vScheduleItem.at(i)->hasSelectSchedule(info)) { + // qCDebug(ClientLogger) << "Found matching schedule item at index" << i << ", starting animation"; m_vScheduleItem.at(i)->setStartValue(0); m_vScheduleItem.at(i)->setEndValue(10); m_vScheduleItem.at(i)->startAnimation(); + animatedCount++; } } + qCDebug(ClientLogger) << "Started animations for" << animatedCount << "matching schedule items"; } void CGraphicsView::clearSchedule() @@ -325,6 +359,7 @@ void CGraphicsView::clearSchedule() void CGraphicsView::scheduleClassificationType(DSchedule::List &scheduleInfolist, QList &info) { + qCDebug(ClientLogger) << "CGraphicsView::scheduleClassificationType - count:" << scheduleInfolist.size(); DSchedule::List schedulelist = scheduleInfolist; if (schedulelist.isEmpty()) return; @@ -338,9 +373,11 @@ void CGraphicsView::scheduleClassificationType(DSchedule::List &scheduleInfolist QDateTime begTime = schedulelist.at(k)->dtStart(); if (begTime.date().daysTo(endTime.date()) == 0 && begTime.time().secsTo(endTime.time()) < m_minTime) { + qCDebug(ClientLogger) << "Schedule too short, extending end time"; endTime = begTime.addSecs(m_minTime); } if (endTime.time().hour() == 0 && endTime.time().second() == 0) { + qCDebug(ClientLogger) << "End time is midnight, subtracting 1 second"; endTime = endTime.addSecs(-1); } containIndex.clear(); @@ -351,12 +388,14 @@ void CGraphicsView::scheduleClassificationType(DSchedule::List &scheduleInfolist } } if (containIndex.count() == 0) { + qCDebug(ClientLogger) << "Creating new classification group for schedule" << k; ScheduleclassificationInfo firstschedule; firstschedule.begindate = schedulelist.at(k)->dtStart(); firstschedule.enddate = endTime; firstschedule.vData.append(schedulelist.at(k)); info.append(firstschedule); } else { + qCDebug(ClientLogger) << "Adding schedule" << k << "to existing classification group" << containIndex.at(0); ScheduleclassificationInfo &scheduleInfo = info[containIndex.at(0)]; int index = 0; @@ -378,10 +417,12 @@ void CGraphicsView::scheduleClassificationType(DSchedule::List &scheduleInfolist scheduleInfo.vData.append(schedulelist.at(k)); } } + qCDebug(ClientLogger) << "Classification complete, created" << info.size() << "groups"; } void CGraphicsView::mouseDoubleClickEvent(QMouseEvent *event) { + qCDebug(ClientLogger) << "CGraphicsView::mouseDoubleClickEvent"; emit signalScheduleShow(false); DGraphicsView::mouseDoubleClickEvent(event); CScheduleItem *item = dynamic_cast(itemAt(event->pos())); @@ -417,9 +458,11 @@ void CGraphicsView::mouseDoubleClickEvent(QMouseEvent *event) void CGraphicsView::mousePressEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "CGraphicsView::mousePressEvent - pos:" << event->pos(); CScheduleItem *item = dynamic_cast(itemAt(event->pos())); if (item != nullptr && item->getType() == 1) { + // qCDebug(ClientLogger) << "Clicked on '...' item, hiding schedule"; emit signalScheduleShow(false); return; } @@ -428,10 +471,12 @@ void CGraphicsView::mousePressEvent(QMouseEvent *event) void CGraphicsView::mouseMoveEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "CGraphicsView::mouseMoveEvent - pos:" << event->pos(); if (m_DragStatus == NONE) { CScheduleItem *item = dynamic_cast(itemAt(event->pos())); if (item != nullptr && item->getType() == 1) { + // qCDebug(ClientLogger) << "Mouse over '...' item, showing arrow cursor"; setCursor(Qt::ArrowCursor); DGraphicsView::mouseMoveEvent(event); return; @@ -442,6 +487,7 @@ void CGraphicsView::mouseMoveEvent(QMouseEvent *event) } void CGraphicsView::slotDoubleEvent(int type) { + qCDebug(ClientLogger) << "CGraphicsView::slotDoubleEvent - type:" << type; Q_UNUSED(type); m_updateDflag = true; emit signalsUpdateSchedule(); @@ -449,11 +495,13 @@ void CGraphicsView::slotDoubleEvent(int type) void CGraphicsView::slotScrollBar() { + // qCDebug(ClientLogger) << "CGraphicsView::slotScrollBar"; emit signalScheduleShow(false); } void CGraphicsView::slotUpdateScene() { + // qCDebug(ClientLogger) << "CGraphicsView::slotUpdateScene"; this->scene()->update(); } @@ -461,6 +509,7 @@ void CGraphicsView::slotStateChange(bool bState) { qCDebug(ClientLogger) << "State change" << "state:" << bState; if(bState) { + // qCDebug(ClientLogger) << "State change to true, hiding all schedule items"; for (int i = 0; i < m_vScheduleItem.size(); i++) { m_vScheduleItem[i]->setVisible(false); } @@ -478,6 +527,7 @@ Others: 无 ************************************************************************/ void CGraphicsView::wheelEvent(QWheelEvent *event) { + // qCDebug(ClientLogger) << "CGraphicsView::wheelEvent"; emit signalScheduleShow(false); //非全天部分如果滚动为左右则退出 if (event->angleDelta().x() != 0 ) { @@ -502,6 +552,7 @@ Others: 无 ************************************************************************/ void CGraphicsView::resizeEvent(QResizeEvent *event) { + // qCDebug(ClientLogger) << "CGraphicsView::resizeEvent"; scrollBarValueChangedSlot(); QGraphicsView::resizeEvent(event); viewport()->update(); @@ -518,11 +569,14 @@ Others: 无 ************************************************************************/ void CGraphicsView::paintEvent(QPaintEvent *event) { + // qCDebug(ClientLogger) << "CGraphicsView::paintEvent"; QPainter t_painter(viewport()); int t_width = viewport()->width() + 2; //绘制水平线 if (m_LRFlag) { + // qCDebug(ClientLogger) << "Drawing horizontal lines"; if (m_currentTimeType == 0) { + // qCDebug(ClientLogger) << "Drawing horizontal lines for current time type 0"; t_painter.save(); t_painter.setPen(m_LRPen); @@ -530,6 +584,7 @@ void CGraphicsView::paintEvent(QPaintEvent *event) t_painter.drawLine(QPoint(0, m_vLRLarge[i] - 1), QPoint(t_width, m_vLRLarge[i] - 1)); t_painter.restore(); } else { + // qCDebug(ClientLogger) << "Drawing horizontal lines for current time type 1"; t_painter.save(); t_painter.setPen(m_LRPen); @@ -553,6 +608,7 @@ void CGraphicsView::paintEvent(QPaintEvent *event) void CGraphicsView::scrollBarValueChangedSlot() { + // qCDebug(ClientLogger) << "CGraphicsView::scrollBarValueChangedSlot"; QMutexLocker locker(&m_Mutex); int viewHeight = viewport()->height(); m_vLRLarge.clear(); @@ -591,6 +647,7 @@ void CGraphicsView::scrollBarValueChangedSlot() CGraphicsView::PosInItem CGraphicsView::getPosInItem(const QPoint &p, const QRectF &itemRect) { + // qCDebug(ClientLogger) << "CGraphicsView::getPosInItem - pos:" << p << "itemRect:" << itemRect; QPointF scenePos = this->mapToScene(p); QPointF itemPos = QPointF(scenePos.x() - itemRect.x(), scenePos.y() - itemRect.y()); @@ -608,6 +665,7 @@ CGraphicsView::PosInItem CGraphicsView::getPosInItem(const QPoint &p, const QRec DSchedule::Ptr CGraphicsView::getScheduleInfo(const QDateTime &beginDate, const QDateTime &endDate) { + // qCDebug(ClientLogger) << "CGraphicsView::getScheduleInfo - beginDate:" << beginDate << "endDate:" << endDate; DSchedule::Ptr info(new DSchedule); if (beginDate.secsTo(endDate) > 0) { info->setDtStart(beginDate); @@ -635,16 +693,19 @@ DSchedule::Ptr CGraphicsView::getScheduleInfo(const QDateTime &beginDate, const bool CGraphicsView::IsEqualtime(const QDateTime &timeFirst, const QDateTime &timeSecond) { + // qCDebug(ClientLogger) << "CGraphicsView::IsEqualtime - timeFirst:" << timeFirst << "timeSecond:" << timeSecond; return !(qAbs(timeFirst.secsTo(timeSecond)) > 100); } bool CGraphicsView::JudgeIsCreate(const QPointF &pos) { + // qCDebug(ClientLogger) << "CGraphicsView::JudgeIsCreate - pos:" << 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) { + // qCDebug(ClientLogger) << "CGraphicsView::RightClickToCreate - listItem:" << listItem << "pos:" << pos; Q_UNUSED(listItem); m_rightMenu->clear(); m_rightMenu->addAction(m_createAction); @@ -655,16 +716,19 @@ void CGraphicsView::RightClickToCreate(QGraphicsItem *listItem, const QPoint &po QDateTime CGraphicsView::getDragScheduleInfoBeginTime(const QDateTime &moveDateTime) { + // qCDebug(ClientLogger) << "CGraphicsView::getDragScheduleInfoBeginTime - moveDateTime:" << moveDateTime; return moveDateTime.secsTo(m_InfoEndTime) < DDECalendar::ThirtyMinutesWithSec ? m_InfoEndTime.addSecs(-DDECalendar::ThirtyMinutesWithSec) : moveDateTime; } QDateTime CGraphicsView::getDragScheduleInfoEndTime(const QDateTime &moveDateTime) { + // qCDebug(ClientLogger) << "CGraphicsView::getDragScheduleInfoEndTime - moveDateTime:" << moveDateTime; return m_InfoBeginTime.secsTo(moveDateTime) < DDECalendar::ThirtyMinutesWithSec ? m_InfoBeginTime.addSecs(DDECalendar::ThirtyMinutesWithSec) : moveDateTime; } QDateTime CGraphicsView::TimeRounding(const QDateTime &time) { + // qCDebug(ClientLogger) << "CGraphicsView::TimeRounding - time:" << time; int hours = time.time().hour(); int minnutes = 0; minnutes = time.time().minute() / 15; @@ -674,6 +738,7 @@ QDateTime CGraphicsView::TimeRounding(const QDateTime &time) void CGraphicsView::centerOnScene(const QPointF &pos) { + // qCDebug(ClientLogger) << "CGraphicsView::centerOnScene - pos:" << pos; // view 根据鼠标下的点作为锚点来定位 scene setTransformationAnchor(QGraphicsView::AnchorUnderMouse); centerOn(pos); @@ -685,11 +750,13 @@ void CGraphicsView::centerOnScene(const QPointF &pos) void CGraphicsView::setSceneHeightScale(const QPointF &pos) { + // qCDebug(ClientLogger) << "CGraphicsView::setSceneHeightScale - pos:" << pos; m_sceneHeightScale = pos.y() / this->scene()->height(); } void CGraphicsView::keepCenterOnScene() { + // qCDebug(ClientLogger) << "CGraphicsView::keepCenterOnScene"; QPointF pos; pos.setX(this->viewport()->width() / 2); pos.setY(this->scene()->height() * m_sceneHeightScale); @@ -698,6 +765,7 @@ void CGraphicsView::keepCenterOnScene() void CGraphicsView::setTime(QTime time) { + // qCDebug(ClientLogger) << "CGraphicsView::setTime - time:" << time; int viewWidth = viewport()->width(); int viewHeight = viewport()->height(); QPoint newCenter(viewWidth / 2, viewHeight / 2); @@ -711,13 +779,16 @@ void CGraphicsView::setTime(QTime time) */ void CGraphicsView::updateInfo() { + // qCDebug(ClientLogger) << "CGraphicsView::updateInfo"; //更新选择日程状态 DragInfoGraphicsView::updateInfo(); switch (m_DragStatus) { case IsCreate: + // qCDebug(ClientLogger) << "Updating info show for create"; upDateInfoShow(IsCreate, m_DragScheduleInfo); break; default: + // qCDebug(ClientLogger) << "Updating info show for default"; upDateInfoShow(); break; } diff --git a/calendar-client/src/view/monthgraphiview.cpp b/calendar-client/src/view/monthgraphiview.cpp index 16764ab2f..174e73be0 100644 --- a/calendar-client/src/view/monthgraphiview.cpp +++ b/calendar-client/src/view/monthgraphiview.cpp @@ -16,6 +16,7 @@ #include "ckeyrightdeal.h" #include "ckeyupdeal.h" #include "ckeydowndeal.h" +#include "commondef.h" #include #include @@ -23,6 +24,7 @@ CMonthGraphicsview::CMonthGraphicsview(QWidget *parent) : DragInfoGraphicsView(parent) { + qCDebug(ClientLogger) << "CMonthGraphicsview constructor"; //设置显示左右下角圆角 setShowRadius(true, true); @@ -30,6 +32,7 @@ CMonthGraphicsview::CMonthGraphicsview(QWidget *parent) connect(this, &CMonthGraphicsview::sigStateChange, m_MonthScheduleView, &CMonthScheduleView::slotStateChange, Qt::DirectConnection); connect(this, &CMonthGraphicsview::signalFontChange, m_MonthScheduleView, &CMonthScheduleView::slotFontChange); + qCDebug(ClientLogger) << "Creating month day items"; for (int i = 0; i < DDEMonthCalendar::ItemSizeOfMonthDay; ++i) { CMonthDayItem *item = new CMonthDayItem(); item->setZValue(-1); @@ -52,6 +55,7 @@ CMonthGraphicsview::CMonthGraphicsview(QWidget *parent) } updateSize(); m_Scene->setFirstFocusItem(m_DayItem.first()); + qCDebug(ClientLogger) << "Setting up keyboard event handling"; //添加键盘事件处理 CKeyPressPrxy *m_keyPrxy = new CKeyPressPrxy(); m_keyPrxy->addkeyPressDeal(new CSceneTabKeyDeal(m_Scene)); @@ -65,6 +69,7 @@ CMonthGraphicsview::CMonthGraphicsview(QWidget *parent) CMonthGraphicsview::~CMonthGraphicsview() { + qCDebug(ClientLogger) << "CMonthGraphicsview destructor"; m_DayItem.clear(); } @@ -81,6 +86,7 @@ void CMonthGraphicsview::setTheMe(int type) void CMonthGraphicsview::setDate(const QVector &showDate) { + qCDebug(ClientLogger) << "Setting month view dates" << "first date:" << showDate.at(0); Q_ASSERT(showDate.size() == 42); if (showDate.at(0).day() != 1) { m_currentMonth = showDate.at(0).addMonths(1).month(); @@ -96,6 +102,7 @@ void CMonthGraphicsview::setDate(const QVector &showDate) currentIndex = i; } } + qCDebug(ClientLogger) << "Setting focus to current date at index" << currentIndex; m_Scene->setFirstFocusItem(m_DayItem.at(currentIndex)); m_schedulelistdata.clear(); this->scene()->update(); @@ -148,6 +155,7 @@ void CMonthGraphicsview::setSelectSearchSchedule(const DSchedule::Ptr &scheduleI //获取所有的日程item QVector mScheduleShowBtn = m_MonthScheduleView->getScheduleShowItem(); + int animatedCount = 0; for (int i = 0; i < mScheduleShowBtn.size(); ++i) { CMonthScheduleItem *item = dynamic_cast(mScheduleShowBtn.at(i)); @@ -158,8 +166,10 @@ void CMonthGraphicsview::setSelectSearchSchedule(const DSchedule::Ptr &scheduleI item->setStartValue(0); item->setEndValue(4); item->startAnimation(); + animatedCount++; } } + qCDebug(ClientLogger) << "Started animations for" << animatedCount << "matching schedule items"; } /** @@ -183,11 +193,11 @@ void CMonthGraphicsview::updateSize() m_Scene->setSceneRect(sceneRect); qreal w = m_Scene->width() / DDEMonthCalendar::AFewDaysOfWeek; qreal h = m_Scene->height() / DDEMonthCalendar::LinesNumOfMonth; - QRectF rect ; + QRectF rect; int w_offset = 0; int h_offset = 0; - for (int i = 0 ; i < m_DayItem.size(); ++i) { + for (int i = 0; i < m_DayItem.size(); ++i) { h_offset = i / DDEMonthCalendar::AFewDaysOfWeek; w_offset = i % DDEMonthCalendar::AFewDaysOfWeek; rect.setRect(w * w_offset, @@ -205,7 +215,7 @@ void CMonthGraphicsview::updateLunar() CaHuangLiDayInfo info; QString lunarStr(""); - for (int i = 0 ; i < m_DayItem.size(); ++i) { + 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); @@ -254,7 +264,7 @@ void CMonthGraphicsview::updateInfo() upDateInfoShow(ChangeWhole, m_DragScheduleInfo); break; default: - + qCDebug(ClientLogger) << "No drag operation in progress"; break; } viewport()->update(); @@ -266,30 +276,39 @@ void CMonthGraphicsview::updateInfo() QPointF CMonthGraphicsview::getItemPos(const QPoint &p, const QRectF &itemRect) { QPointF scenePos = this->mapToScene(p); - return QPointF(scenePos.x() - itemRect.x(), - scenePos.y() - itemRect.y()); + QPointF result = QPointF(scenePos.x() - itemRect.x(), scenePos.y() - itemRect.y()); + // qCDebug(ClientLogger) << "CMonthGraphicsview::getItemPos - point:" << p << "item rect:" << itemRect << "result:" << result; + return result; } CMonthGraphicsview::PosInItem CMonthGraphicsview::getPosInItem(const QPoint &p, const QRectF &itemRect) { QPointF scenePos = this->mapToScene(p); - QPointF itemPos = QPointF(scenePos.x() - itemRect.x(), - scenePos.y() - itemRect.y()); + QPointF itemPos = QPointF(scenePos.x() - itemRect.x(), scenePos.y() - itemRect.y()); qreal bottomY = itemRect.width() - itemPos.x(); + PosInItem result; if (itemPos.x() < 5) { - return LEFT; - } - if (bottomY < 5) { - return RIGHT; + result = LEFT; + } else if (bottomY < 5) { + result = RIGHT; + } else { + result = MIDDLE; } - return MIDDLE; + + // qCDebug(ClientLogger) << "CMonthGraphicsview::getPosInItem - point:" << p + // << "item rect:" << itemRect + // << "item pos:" << itemPos + // << "result:" << result; + return result; } QDateTime CMonthGraphicsview::getPosDate(const QPoint &p) { - if (!this->sceneRect().contains(p)) + if (!this->sceneRect().contains(p)) { + qCDebug(ClientLogger) << "Point outside scene rect, returning move date:" << m_MoveDate; return m_MoveDate; + } QRectF rect = this->sceneRect(); qreal x = 0; qreal y = 0; @@ -313,25 +332,35 @@ QDateTime CMonthGraphicsview::getPosDate(const QPoint &p) 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)); + QDateTime result = QDateTime(m_DayItem[xoffset + yoffset * 7]->getDate(), QTime(0, 0, 0)); + qCDebug(ClientLogger) << "CMonthGraphicsview::getPosDate - point:" << p + << "x:" << x << "y:" << y + << "offsets:" << xoffset << yoffset + << "result:" << result; + return result; } void CMonthGraphicsview::upDateInfoShow(const CMonthGraphicsview::DragStatus &status, const DSchedule::Ptr &info) { + qCDebug(ClientLogger) << "CMonthGraphicsview::upDateInfoShow - status:" << status + << "schedule:" << (info ? info->summary() : "null"); switch (status) { case NONE: Q_UNUSED(info); + qCDebug(ClientLogger) << "Status: NONE, no action needed"; break; case ChangeBegin: case ChangeEnd: { + qCDebug(ClientLogger) << "Changing date in month schedule view"; m_MonthScheduleView->changeDate(info); } break; case ChangeWhole: { + qCDebug(ClientLogger) << "Handling whole schedule change"; } break; case IsCreate: + qCDebug(ClientLogger) << "Updating date for new schedule"; m_MonthScheduleView->updateDate(info); break; } @@ -339,6 +368,7 @@ void CMonthGraphicsview::upDateInfoShow(const CMonthGraphicsview::DragStatus &st void CMonthGraphicsview::slideEvent(QPointF &startPoint, QPointF &stopPort) { + qCDebug(ClientLogger) << "CMonthGraphicsview::slideEvent - start:" << startPoint << "stop:" << stopPort; qreal _movingLine {0}; touchGestureOperation::TouchMovingDirection _touchMovingDir = touchGestureOperation::getTouchMovingDir(startPoint, stopPort, _movingLine); @@ -349,6 +379,7 @@ void CMonthGraphicsview::slideEvent(QPointF &startPoint, QPointF &stopPort) switch (_touchMovingDir) { case touchGestureOperation::T_TOP: { if (_movingLine > moveOffset) { + qCDebug(ClientLogger) << "Slide up detected, moving to previous month"; delta = -1; startPoint = stopPort; } @@ -356,6 +387,7 @@ void CMonthGraphicsview::slideEvent(QPointF &startPoint, QPointF &stopPort) } case touchGestureOperation::T_BOTTOM: { if (_movingLine > moveOffset) { + qCDebug(ClientLogger) << "Slide down detected, moving to next month"; delta = 1; startPoint = stopPort; } @@ -365,13 +397,16 @@ void CMonthGraphicsview::slideEvent(QPointF &startPoint, QPointF &stopPort) break; } if (delta != 0) { + qCDebug(ClientLogger) << "Emitting angle delta signal:" << delta; emit signalAngleDelta(delta); } } void CMonthGraphicsview::mouseDoubleClickEvent(QMouseEvent *event) { + qCDebug(ClientLogger) << "CMonthGraphicsview::mouseDoubleClickEvent - pos:" << event->pos() << "button:" << event->button(); if (event->button() != Qt::LeftButton) { + qCDebug(ClientLogger) << "Mouse double click event, but not left button"; return; } @@ -379,6 +414,7 @@ void CMonthGraphicsview::mouseDoubleClickEvent(QMouseEvent *event) CMonthScheduleNumItem *item = dynamic_cast(listItem); if (item != nullptr) { + // qCDebug(ClientLogger) << "Double click on schedule num item, switching view to date:" << item->getDate(); //双击切换视图 if (item->getDate().year() > DDECalendar::QueryEarliestYear) { qCDebug(ClientLogger) << "Double click on schedule num item, switching view to date:" << item->getDate(); @@ -403,6 +439,7 @@ void CMonthGraphicsview::mouseDoubleClickEvent(QMouseEvent *event) CMonthDayItem *Dayitem = dynamic_cast(listItem); if (Dayitem != nullptr) { + // qCDebug(ClientLogger) << "Double click on day item, getting item pos"; QPointF point = getItemPos(event->pos(), Dayitem->rect()); if (point.y() < 38) { //双击切换视图 @@ -424,19 +461,23 @@ void CMonthGraphicsview::mouseDoubleClickEvent(QMouseEvent *event) void CMonthGraphicsview::resizeEvent(QResizeEvent *event) { + // qCDebug(ClientLogger) << "CMonthGraphicsview::resizeEvent - size:" << event->size(); DragInfoGraphicsView::resizeEvent(event); updateSize(); updateInfo(); } void CMonthGraphicsview::changeEvent(QEvent *event) { + // qCDebug(ClientLogger) << "CMonthGraphicsview::changeEvent - type:" << event->type(); if (event->type() == QEvent::FontChange) { + // qCDebug(ClientLogger) << "Font changed, emitting signalFontChange"; emit signalFontChange(); } } void CMonthGraphicsview::wheelEvent(QWheelEvent *e) { + // qCDebug(ClientLogger) << "CMonthGraphicsview::wheelEvent - angle delta:" << e->angleDelta(); //如果滚动为上下则发送信号 if (e->angleDelta().y() != 0) { emit signalAngleDelta(e->angleDelta().y()); @@ -448,6 +489,7 @@ void CMonthGraphicsview::wheelEvent(QWheelEvent *e) */ void CMonthGraphicsview::updateBackgroundShowItem() { + // qCDebug(ClientLogger) << "CMonthGraphicsview::updateBackgroundShowItem"; for (int i = 0; i < m_DayItem.size(); ++i) { m_DayItem.at(i)->updateShowItem(); } @@ -455,6 +497,7 @@ void CMonthGraphicsview::updateBackgroundShowItem() void CMonthGraphicsview::setSceneCurrentItemFocus(const QDate &focusDate) { + // qCDebug(ClientLogger) << "CMonthGraphicsview::setSceneCurrentItemFocus - focus date:" << focusDate; int offset = static_cast(m_DayItem.first()->getDate().daysTo(focusDate)); if (offset >= 0 && offset < m_DayItem.size()) { qCDebug(ClientLogger) << "Setting scene current item focus" @@ -472,31 +515,37 @@ void CMonthGraphicsview::setSceneCurrentItemFocus(const QDate &focusDate) void CMonthGraphicsview::setDragPixmap(QDrag *drag, DragInfoItem *item) { + // qCDebug(ClientLogger) << "CMonthGraphicsview::setDragPixmap - item:" << item; CMonthScheduleItem *infoitem = dynamic_cast(item); drag->setPixmap(infoitem->getPixmap()); } bool CMonthGraphicsview::MeetCreationConditions(const QDateTime &date) { + // qCDebug(ClientLogger) << "CMonthGraphicsview::MeetCreationConditions - date:" << date; return qAbs(date.daysTo(m_PressDate)) < 43; } bool CMonthGraphicsview::IsEqualtime(const QDateTime &timeFirst, const QDateTime &timeSecond) { + // qCDebug(ClientLogger) << "CMonthGraphicsview::IsEqualtime - timeFirst:" << timeFirst << "timeSecond:" << timeSecond; return timeFirst.date() == timeSecond.date(); } bool CMonthGraphicsview::JudgeIsCreate(const QPointF &pos) { + // qCDebug(ClientLogger) << "CMonthGraphicsview::JudgeIsCreate - pos:" << pos; return qAbs(pos.x() - m_PressPos.x()) > 20 || qAbs(m_PressDate.daysTo(getPosDate(pos.toPoint()))) > 0; } void CMonthGraphicsview::RightClickToCreate(QGraphicsItem *listItem, const QPoint &pos) { + // qCDebug(ClientLogger) << "CMonthGraphicsview::RightClickToCreate - listItem:" << listItem << "pos:" << pos; Q_UNUSED(pos); CMonthDayItem *Dayitem = dynamic_cast(listItem); if (Dayitem != nullptr) { + // qCDebug(ClientLogger) << "Right click on day item, showing create action"; m_rightMenu->clear(); m_rightMenu->addAction(m_createAction); m_createDate.setDate(Dayitem->getDate()); @@ -506,6 +555,7 @@ void CMonthGraphicsview::RightClickToCreate(QGraphicsItem *listItem, const QPoin void CMonthGraphicsview::MoveInfoProcess(DSchedule::Ptr &info, const QPointF &pos) { + // qCDebug(ClientLogger) << "CMonthGraphicsview::MoveInfoProcess - info:" << info << "pos:" << pos; qint64 offset = m_PressDate.daysTo(m_MoveDate); info->setDtStart(info->dtStart().addDays(offset)); info->setDtEnd(info->dtEnd().addDays(offset)); @@ -531,6 +581,7 @@ void CMonthGraphicsview::MoveInfoProcess(DSchedule::Ptr &info, const QPointF &po */ QDateTime CMonthGraphicsview::getDragScheduleInfoBeginTime(const QDateTime &moveDateTime) { + // qCDebug(ClientLogger) << "CMonthGraphicsview::getDragScheduleInfoBeginTime - moveDateTime:" << moveDateTime; //获取移动开始时间 QDateTime _beginTime = moveDateTime.daysTo(m_InfoEndTime) < 0 ? QDateTime(m_InfoEndTime.date(), m_InfoBeginTime.time()) : @@ -547,6 +598,7 @@ QDateTime CMonthGraphicsview::getDragScheduleInfoBeginTime(const QDateTime &move */ QDateTime CMonthGraphicsview::getDragScheduleInfoEndTime(const QDateTime &moveDateTime) { + // qCDebug(ClientLogger) << "CMonthGraphicsview::getDragScheduleInfoEndTime - moveDateTime:" << moveDateTime; //获取结束时间 QDateTime _endTime = m_InfoBeginTime.daysTo(moveDateTime) < 0 ? QDateTime(m_InfoBeginTime.date(), m_InfoEndTime.time()) : diff --git a/calendar-client/src/widget/calendarmainwindow.cpp b/calendar-client/src/widget/calendarmainwindow.cpp index a41e87cf3..e4d379856 100644 --- a/calendar-client/src/widget/calendarmainwindow.cpp +++ b/calendar-client/src/widget/calendarmainwindow.cpp @@ -81,6 +81,7 @@ Calendarmainwindow::Calendarmainwindow(int index, QWidget *w) : DMainWindow(w) , m_defaultIndex(index) { + qCDebug(ClientLogger) << "Calendarmainwindow::Calendarmainwindow, index:" << index; setContentsMargins(QMargins(0, 0, 0, 0)); initUI(); initConnection(); @@ -114,8 +115,10 @@ Calendarmainwindow::Calendarmainwindow(int index, QWidget *w) int state = CConfigSettings::getInstance()->value("base.state").toInt(&isOk); Qt::WindowStates winStates = static_cast(state); if (winStates.testFlag(Qt::WindowMaximized)) { + qCDebug(ClientLogger) << "Window was maximized"; showMaximized(); } else { + qCDebug(ClientLogger) << "Restoring window geometry"; restoreGeometry(arrayByte); Dtk::Widget::moveToCenter(this); } @@ -146,11 +149,13 @@ Calendarmainwindow::Calendarmainwindow(int index, QWidget *w) Calendarmainwindow::~Calendarmainwindow() { + qCDebug(ClientLogger) << "Calendarmainwindow::~Calendarmainwindow"; CDynamicIcon::releaseInstance(); } void Calendarmainwindow::slotViewShortcut() { + qCDebug(ClientLogger) << "Calendarmainwindow::slotViewShortcut"; QRect rect = window()->geometry(); QPoint pos(rect.x() + rect.width() / 2, rect.y() + rect.height() / 2); Shortcut sc; @@ -170,6 +175,7 @@ void Calendarmainwindow::slotViewShortcut() */ void Calendarmainwindow::slotCurrentDateUpdate() { + // qCDebug(ClientLogger) << "Calendarmainwindow::slotCurrentDateUpdate"; //获取当前时间 const QDateTime _currentDate = QDateTime::currentDateTime(); //设置当前时间 @@ -196,6 +202,7 @@ void Calendarmainwindow::slotCurrentDateUpdate() */ void Calendarmainwindow::slotSetSearchFocus() { + qCDebug(ClientLogger) << "Calendarmainwindow::slotSetSearchFocus"; //设置输入框获取焦点 slotSearchEdit(); } @@ -219,6 +226,7 @@ void Calendarmainwindow::viewWindow(int type, const bool showAnimation) } if (m_buttonBox->checkedId() != type) { //设置选中 + qCDebug(ClientLogger) << "Setting button box checked to:" << type; m_buttonBox->button(type)->setChecked(true); } switch (type) { @@ -245,6 +253,7 @@ void Calendarmainwindow::viewWindow(int type, const bool showAnimation) void Calendarmainwindow::updateHeight() { + // qCDebug(ClientLogger) << "Calendarmainwindow::updateHeight"; int index = m_stackWidget->currentIndex(); if (index < 0 || index > m_stackWidget->count() - 1) { @@ -268,6 +277,7 @@ void Calendarmainwindow::updateHeight() void Calendarmainwindow::setSearchWidth(int w) { + // qCDebug(ClientLogger) << "Calendarmainwindow::setSearchWidth, width:" << w; m_contentBackground->setFixedWidth(w); } @@ -337,17 +347,22 @@ void Calendarmainwindow::slotOpenSchedule(QString job) m_DayWindow->setTime(out->dtStart().time()); //弹出编辑对话框 if (m_dlg == Q_NULLPTR) { + qCDebug(ClientLogger) << "Creating new CMyScheduleView dialog"; m_dlg = new CMyScheduleView(out, this); } else { + qCDebug(ClientLogger) << "Updating existing CMyScheduleView dialog"; m_dlg->setSchedules(out); m_dlg->updateFormat(); } - if (m_dlg->isHidden()) + if (m_dlg->isHidden()) { + qCDebug(ClientLogger) << "Showing schedule view dialog"; m_dlg->exec(); + } slotWUpdateSchedule(); } void Calendarmainwindow::initUI() { + qCDebug(ClientLogger) << "Calendarmainwindow::initUI"; //设置主窗口辅助技术显示名称和描述 this->setObjectName("MainWindow"); this->setAccessibleName("MainWindow"); @@ -452,6 +467,7 @@ void Calendarmainwindow::initUI() void Calendarmainwindow::initConnection() { + qCDebug(ClientLogger) << "Calendarmainwindow::initConnection"; connect(m_stackWidget, &AnimationStackedWidget::signalIsFinished, this, &Calendarmainwindow::slotSetButtonBox); connect(m_buttonBox, &DButtonBox::buttonClicked, this, &Calendarmainwindow::slotstackWClicked); @@ -488,6 +504,7 @@ void Calendarmainwindow::initConnection() void Calendarmainwindow::initData() { + qCDebug(ClientLogger) << "Calendarmainwindow::initData"; //根据配置设置侧边栏状态 m_titleWidget->setSidebarStatus(gSetting->getUserSidebarStatus()); } @@ -497,6 +514,7 @@ void Calendarmainwindow::initData() */ void Calendarmainwindow::createview() { + qCDebug(ClientLogger) << "Calendarmainwindow::createview"; m_yearwindow = new CYearWindow(this); m_yearwindow->setObjectName("yearwindow"); m_yearwindow->setAccessibleName("yearwindow"); @@ -525,12 +543,14 @@ void Calendarmainwindow::createview() m_buttonBox->button(m_defaultIndex)->setChecked(true); //如果为日视图则设置非全天时间定位 if (m_defaultIndex == DDECalendar::CalendarDayWindow) { + qCDebug(ClientLogger) << "Default view is DayWindow, setting time"; m_DayWindow->setTime(); } } void Calendarmainwindow::resizeView() { + // qCDebug(ClientLogger) << "Calendarmainwindow::resizeView"; //帐户列表窗口(A),视图窗口(B),搜索结果窗口(C) //窗口由大变小先隐藏A,在隐藏B //窗口由小变大先显示B,在显示A @@ -544,9 +564,11 @@ void Calendarmainwindow::resizeView() int minWidth = m_opensearchflag ? 984 : 826 ; if (width() < minWidth) { + // qCDebug(ClientLogger) << "Window too narrow, hiding sidebar"; m_titleWidget->setSidebarCanDisplay(false); m_sidebarView->setVisible(false); } else if (width() > minWidth) { + // qCDebug(ClientLogger) << "Window wide enough, showing sidebar"; m_titleWidget->setSidebarCanDisplay(true); m_sidebarView->setVisible(true); } @@ -555,8 +577,10 @@ void Calendarmainwindow::resizeView() m_transparentFrame->resize(width(), height() - 50); if (width() < CalendarSwitchWidth) { + // qCDebug(ClientLogger) << "Switching to mini title state"; m_titleWidget->setShowState(CTitleWidget::Title_State_Mini); } else { + // qCDebug(ClientLogger) << "Switching to normal title state"; m_titleWidget->setShowState(CTitleWidget::Title_State_Normal); } @@ -565,12 +589,14 @@ void Calendarmainwindow::resizeView() sidWidth = m_sidebarView->width(); } if (width() < CalendarViewSwitchWidth + sidWidth) { + // qCDebug(ClientLogger) << "Switching to narrow view layout"; m_isNormalStateShow = false; m_stackWidget->setVisible(!m_contentBackground->isVisible()); // 如果是隐藏的状态,不需要多减去sidewidth sidWidth = sidWidth == 0 ? 0 : sidWidth + 10; m_scheduleSearchViewMaxWidth = this->width() - sidWidth; } else { + // qCDebug(ClientLogger) << "Switching to normal view layout"; m_scheduleSearchViewMaxWidth = qRound(0.2325 * (width()) + 0.5); m_isNormalStateShow = true; m_stackWidget->setVisible(true); @@ -587,6 +613,7 @@ void Calendarmainwindow::resizeView() */ void Calendarmainwindow::setScheduleHide() { + // qCDebug(ClientLogger) << "Calendarmainwindow::setScheduleHide"; m_yearwindow->slotSetScheduleHide(); m_monthWindow->slotScheduleHide(); m_weekWindow->slotScheduleHide(); @@ -610,6 +637,7 @@ void Calendarmainwindow::resizeEvent(QResizeEvent *event) */ void Calendarmainwindow::slotstackWClicked(QAbstractButton *bt) { + qCDebug(ClientLogger) << "Calendarmainwindow::slotstackWClicked"; setScheduleHide(); int index = m_buttonBox->id(bt); viewWindow(index, true); @@ -617,6 +645,7 @@ void Calendarmainwindow::slotstackWClicked(QAbstractButton *bt) void Calendarmainwindow::slotWUpdateSchedule() { + qCDebug(ClientLogger) << "Calendarmainwindow::slotWUpdateSchedule"; if (m_opensearchflag && !m_searchEdit->text().isEmpty()) { m_scheduleSearchView->slotsetSearch(m_searchEdit->text()); } @@ -626,7 +655,9 @@ void Calendarmainwindow::slotWUpdateSchedule() void Calendarmainwindow::slotSreturnPressed() { + qCDebug(ClientLogger) << "Calendarmainwindow::slotSreturnPressed"; if (!m_opensearchflag && !m_searchEdit->text().isEmpty()) { + qCDebug(ClientLogger) << "Entering search mode"; m_opensearchflag = true; } //如果为搜索状态 @@ -639,12 +670,15 @@ void Calendarmainwindow::slotSreturnPressed() void Calendarmainwindow::slotStextChanged() { + qCDebug(ClientLogger) << "Calendarmainwindow::slotStextChanged"; if (!m_searchEdit->text().isEmpty()) { + qCDebug(ClientLogger) << "Search text not empty, enabling search flags"; m_yearwindow->setSearchWFlag(true); m_weekWindow->setSearchWFlag(true); m_monthWindow->setSearchWFlag(true); m_DayWindow->setSearchWFlag(true); } else { + qCDebug(ClientLogger) << "Search text empty, clearing search"; m_scheduleSearchView->clearSearch(); m_yearwindow->setSearchWFlag(false); m_monthWindow->setSearchWFlag(false); @@ -664,6 +698,7 @@ void Calendarmainwindow::slotStextChanged() */ void Calendarmainwindow::slotStextfocusChanged(bool onFocus) { + qCDebug(ClientLogger) << "Calendarmainwindow::slotStextfocusChanged, onFocus:" << onFocus; if (onFocus) { setScheduleHide(); } @@ -671,6 +706,7 @@ void Calendarmainwindow::slotStextfocusChanged(bool onFocus) void Calendarmainwindow::slotSearchEdit() { + qCDebug(ClientLogger) << "Calendarmainwindow::slotSearchEdit"; m_searchEdit->lineEdit()->setFocus(); } @@ -680,14 +716,17 @@ void Calendarmainwindow::slotSearchEdit() */ void Calendarmainwindow::slotSearchSelectSchedule(const DSchedule::Ptr &scheduleInfo) { + qCDebug(ClientLogger) << "Calendarmainwindow::slotSearchSelectSchedule"; //如果小尺寸显示模式,在显示搜索窗口的时候,左侧视图会被隐藏 //如果点击一个搜索结果则隐藏搜索窗口,展示左侧视图 if (!m_isNormalStateShow) { + qCDebug(ClientLogger) << "In narrow mode, handling search selection"; QVariant variant; CalendarGlobalEnv::getGlobalEnv()->getValueByKey("SearchItemEvent", variant); QString searchItemEvent = variant.toString(); //如果为鼠标点击操作 if (searchItemEvent == "MousePress") { + qCDebug(ClientLogger) << "Search item clicked, showing stack widget and hiding search results"; m_stackWidget->setVisible(true); m_contentBackground->setVisible(false); } @@ -695,11 +734,13 @@ void Calendarmainwindow::slotSearchSelectSchedule(const DSchedule::Ptr &schedule //获取当前视图编号 CScheduleBaseWidget *_showWidget = dynamic_cast(m_stackWidget->currentWidget()); if (_showWidget) { + qCDebug(ClientLogger) << "Updating view with selected schedule"; //如果日程开始时间年份与选择时间年份不一样则切换年份显示 bool changeYear = _showWidget->getSelectDate().year() != scheduleInfo->dtStart().date().year(); //设置选择时间 if (_showWidget->setSelectDate(scheduleInfo->dtStart().date(), changeYear)) { //更新显示数据 + qCDebug(ClientLogger) << "Date changed, updating data and setting animation"; _showWidget->updateData(); //设置年份信息显示 _showWidget->setYearData(); @@ -710,6 +751,7 @@ void Calendarmainwindow::slotSearchSelectSchedule(const DSchedule::Ptr &schedule } //如果当前界面不为年试图则更新年视图数据 if (_showWidget != m_yearwindow) { + qCDebug(ClientLogger) << "Current view is not year view, updating year window data"; m_yearwindow->updateData(); } } @@ -721,6 +763,7 @@ void Calendarmainwindow::slotSearchSelectSchedule(const DSchedule::Ptr &schedule */ void Calendarmainwindow::slotViewtransparentFrame(const bool isShow) { + qCDebug(ClientLogger) << "Calendarmainwindow::slotViewtransparentFrame, isShow:" << isShow; if (isShow) { m_transparentFrame->resize(width(), height() - 50); m_transparentFrame->move(0, 50); @@ -735,8 +778,10 @@ void Calendarmainwindow::slotViewtransparentFrame(const bool isShow) */ void Calendarmainwindow::slotSetButtonBox() { + qCDebug(ClientLogger) << "Calendarmainwindow::slotSetButtonBox"; //如果为键盘操作则切换后设置焦点 if (m_setButtonFocus) { + qCDebug(ClientLogger) << "Setting focus on button box"; //获取焦点 m_buttonBox->button(m_buttonBox->checkedId())->setFocus(); } @@ -749,6 +794,7 @@ void Calendarmainwindow::slotSetButtonBox() */ void Calendarmainwindow::slotSwitchView(const int viewIndex) { + qCDebug(ClientLogger) << "Calendarmainwindow::slotSwitchView, viewIndex:" << viewIndex; // 0:跳转上一个视图 1:月视图 2:周视图 3:日视图 switch (viewIndex) { case 0: { @@ -779,6 +825,7 @@ void Calendarmainwindow::slotSwitchView(const int viewIndex) */ void Calendarmainwindow::slotNewSchedule() { + qCDebug(ClientLogger) << "Calendarmainwindow::slotNewSchedule"; //设置日程开始时间 QDateTime _beginTime(m_yearwindow->getSelectDate(), QTime::currentTime()); //新建日程对话框 @@ -792,10 +839,12 @@ void Calendarmainwindow::slotDeleteitem() { qCDebug(ClientLogger) << "Deleting selected item"; if (m_scheduleSearchView->getHasScheduleShow() && m_scheduleSearchView->getScheduleStatus()) { + qCDebug(ClientLogger) << "Deleting selected schedule from search view"; //删除选中的schedule m_scheduleSearchView->deleteSchedule(); } else { //获取当前的 + qCDebug(ClientLogger) << "Deleting selected schedule from current view"; CScheduleBaseWidget *widget = qobject_cast(m_stackWidget->currentWidget()); if (widget) { widget->deleteselectSchedule(); @@ -819,26 +868,32 @@ void Calendarmainwindow::slotSetMaxSize() //设置最大尺寸为屏幕尺寸 setMaximumSize(deskSize); if (TabletConfig::isTablet()) { + qCDebug(ClientLogger) << "Tablet mode detected, setting fixed size"; setFixedSize(deskSize); } } void Calendarmainwindow::slotSearchFocusSwitch() { + qCDebug(ClientLogger) << "Calendarmainwindow::slotSearchFocusSwitch"; //设置搜索日程展示列表焦点 if (m_contentBackground->isVisible() && m_scheduleSearchView->getHasScheduleShow()) { + qCDebug(ClientLogger) << "Setting focus on search view"; m_scheduleSearchView->setFocus(Qt::TabFocusReason); } } void Calendarmainwindow::slotSidebarStatusChange(bool status) { + qCDebug(ClientLogger) << "Calendarmainwindow::slotSidebarStatusChange, status:" << status; //先显示再调整窗口大小 m_sidebarView->setVisible(status); if (status) { + qCDebug(ClientLogger) << "Sidebar is visible, resizing window if necessary"; //如果显示搜索窗口,若需要显示帐户列表则界面的最小尺寸需要984,否则为826 int minWidth = m_opensearchflag ? 984 : 826 ; if (width() < minWidth) { + qCDebug(ClientLogger) << "Resizing window to accommodate sidebar"; resize(minWidth, height()); } } @@ -890,6 +945,7 @@ bool Calendarmainwindow::event(QEvent *event) void Calendarmainwindow::slotapplicationStateChanged(Qt::ApplicationState state) { + qCDebug(ClientLogger) << "Calendarmainwindow::slotapplicationStateChanged, state:" << state; static QDateTime currentDateTime = QDateTime::currentDateTime(); //TODO:目前没有找到窗口显示不是激活状态的原因(会先激活然后为非激活状态)。 //当间隔时间少于10毫秒且状态为非激活时,将窗口设置显示在最顶端并设置激活状态 @@ -898,16 +954,19 @@ void Calendarmainwindow::slotapplicationStateChanged(Qt::ApplicationState state) QDateTime currentTime = QDateTime::currentDateTime(); //考虑到会修改系统时间的情况,时间差在0~30毫秒内才会设置 if (currentDateTime.msecsTo(currentTime) < 30 && currentDateTime.msecsTo(currentTime) >= 0) { + qCDebug(ClientLogger) << "Re-activating window due to quick inactive state change"; activateWindow(); raise(); } //断开信号连接 + qCDebug(ClientLogger) << "Disconnecting applicationStateChanged signal"; disconnect(qApp, &QGuiApplication::applicationStateChanged, this, &Calendarmainwindow::slotapplicationStateChanged); } } void Calendarmainwindow::slotOpenSettingDialog() { + qCDebug(ClientLogger) << "Calendarmainwindow::slotOpenSettingDialog"; m_dsdSetting = new CSettingDialog(this); //内容定位到顶端 m_dsdSetting->exec(); @@ -919,6 +978,7 @@ void Calendarmainwindow::slotOpenSettingDialog() void Calendarmainwindow::slotShowPrivacy() { + qCDebug(ClientLogger) << "Calendarmainwindow::slotShowPrivacy"; QString url = ""; QLocale locale; QLocale::Country country = locale.country(); @@ -936,11 +996,13 @@ void Calendarmainwindow::slotShowPrivacy() url = "https://www.uniontech.com/agreement/privacy-en"; } } + qCDebug(ClientLogger) << "Opening privacy policy URL:" << url; QDesktopServices::openUrl(url); } void Calendarmainwindow::removeSyncToast() { + qCDebug(ClientLogger) << "Calendarmainwindow::removeSyncToast"; QWidget *content = this->window()->findChild("_d_message_manager_content", Qt::FindDirectChildrenOnly); if (nullptr == content) return; for (DFloatingMessage *message : content->findChildren(QString(), Qt::FindDirectChildrenOnly)) { @@ -958,6 +1020,7 @@ void Calendarmainwindow::slotShowSyncToast(int syncNum) if (preSyncNum != syncNum && syncNum == -1) { preSyncNum = -1; //同步中 + qCDebug(ClientLogger) << "Showing 'Syncing...' toast"; removeSyncToast(); DMessageManager::instance()->sendMessage(this->window(), QIcon::fromTheme(":/icons/deepin/builtin/icons/dde_calendar_spinner_32px.svg"), tr("Syncing...")); return; diff --git a/calendar-client/src/widget/cschedulebasewidget.cpp b/calendar-client/src/widget/cschedulebasewidget.cpp index 38b310007..ce44c07b1 100644 --- a/calendar-client/src/widget/cschedulebasewidget.cpp +++ b/calendar-client/src/widget/cschedulebasewidget.cpp @@ -4,14 +4,18 @@ #include "cschedulebasewidget.h" #include "monthbrefwidget.h" +#include "commondef.h" + CalendarManager *CScheduleBaseWidget::m_calendarManager = nullptr; CScheduleBaseWidget::CScheduleBaseWidget(QWidget *parent) : QWidget(parent) { + qCDebug(ClientLogger) << "CScheduleBaseWidget::CScheduleBaseWidget"; m_dialogIconButton = new CDialogIconButton(this); m_dialogIconButton->setFixedSize(QSize(16, 16)); initConnect(); if (m_calendarManager == nullptr) { + qCDebug(ClientLogger) << "CalendarManager is null, creating new instance"; m_calendarManager = CalendarManager::getInstance(); //获取一年的日程信息 updateDBusData(); @@ -21,8 +25,10 @@ CScheduleBaseWidget::CScheduleBaseWidget(QWidget *parent) CScheduleBaseWidget::~CScheduleBaseWidget() { + qCDebug(ClientLogger) << "CScheduleBaseWidget::~CScheduleBaseWidget"; m_calendarManager->removeShowWidget(this); if (m_calendarManager->getShowWidgetSize() == 0) { + qCDebug(ClientLogger) << "No more show widgets, releasing CalendarManager instance"; CalendarManager::releaseInstance(); m_calendarManager = nullptr; } @@ -30,6 +36,7 @@ CScheduleBaseWidget::~CScheduleBaseWidget() void CScheduleBaseWidget::initConnect() { + qCDebug(ClientLogger) << "CScheduleBaseWidget::initConnect"; connect(ScheduleManager::getInstace(), &ScheduleManager::signalScheduleUpdate, this, &CScheduleBaseWidget::slotScheduleUpdate); connect(ScheduleManager::getInstace(), &ScheduleManager::signalSearchScheduleUpdate, this, &CScheduleBaseWidget::slotSearchedScheduleUpdate); } @@ -40,24 +47,31 @@ void CScheduleBaseWidget::initConnect() */ bool CScheduleBaseWidget::setSelectDate(const QDate &selectDate, const bool isSwitchYear, const QWidget *widget) { + qCDebug(ClientLogger) << "CScheduleBaseWidget::setSelectDate, date:" << selectDate << "switchYear:" << isSwitchYear; bool _result = false; //选择时间必须大于等于1900年小于2100年 if (selectDate.year() >= 1900 && selectDate.year() <=2100) { + qCDebug(ClientLogger) << "Selected date is valid"; m_calendarManager->setSelectDate(selectDate, isSwitchYear); _result = true; //更新其它视图界面显示 for (int i = 0; i < m_calendarManager->getShowWidgetSize(); ++i) { //如果为当前视图则不更新 - if (m_calendarManager->getShowWidget(i) == nullptr || m_calendarManager->getShowWidget(i) == widget) + if (m_calendarManager->getShowWidget(i) == nullptr || m_calendarManager->getShowWidget(i) == widget) { + // qCDebug(ClientLogger) << "Skipping update for current or null widget"; continue; + } m_calendarManager->getShowWidget(i)->setYearData(); m_calendarManager->getShowWidget(i)->updateShowDate(); } + } else { + qCWarning(ClientLogger) << "Selected date is out of range:" << selectDate; } return _result; } bool CScheduleBaseWidget::setSelectDate(const QDate &selectDate, const QWidget *widget) { + qCDebug(ClientLogger) << "CScheduleBaseWidget::setSelectDate (without switchYear), date:" << selectDate; return setSelectDate(selectDate, false, widget); } @@ -67,6 +81,7 @@ bool CScheduleBaseWidget::setSelectDate(const QDate &selectDate, const QWidget * */ QDate CScheduleBaseWidget::getSelectDate() { + qCDebug(ClientLogger) << "CScheduleBaseWidget::getSelectDate"; return m_calendarManager->getSelectDate(); } @@ -76,6 +91,7 @@ QDate CScheduleBaseWidget::getSelectDate() */ void CScheduleBaseWidget::setCurrentDateTime(const QDateTime ¤tDate) { + qCDebug(ClientLogger) << "CScheduleBaseWidget::setCurrentDateTime, date:" << currentDate; m_calendarManager->setCurrentDateTime(currentDate); } @@ -85,6 +101,7 @@ void CScheduleBaseWidget::setCurrentDateTime(const QDateTime ¤tDate) */ QDateTime CScheduleBaseWidget::getCurrendDateTime() const { + qCDebug(ClientLogger) << "CScheduleBaseWidget::getCurrendDateTime"; return m_calendarManager->getCurrentDate(); } @@ -94,6 +111,7 @@ QDateTime CScheduleBaseWidget::getCurrendDateTime() const */ bool CScheduleBaseWidget::getShowLunar() { + qCDebug(ClientLogger) << "CScheduleBaseWidget::getShowLunar"; return m_calendarManager->getShowLunar(); } @@ -102,10 +120,12 @@ bool CScheduleBaseWidget::getShowLunar() */ void CScheduleBaseWidget::updateData() { + qCDebug(ClientLogger) << "CScheduleBaseWidget::updateData"; updateShowDate(); updateShowSchedule(); //如果为中午环境则更新农历信息 if ( getShowLunar() ) { + qCDebug(ClientLogger) << "Updating lunar data"; updateShowLunar(); } updateSearchScheduleInfo(); @@ -116,6 +136,7 @@ void CScheduleBaseWidget::updateData() */ void CScheduleBaseWidget::updateDBusData() { + qCDebug(ClientLogger) << "CScheduleBaseWidget::updateDBusData"; // ShowDateRange _showDateRange = m_calendarManager->getShowDateRange(); // //如果缓存中不包含开始或结束时间则更新dbus数据 // if (!m_calendarManager->getScheduleTask()->hasScheduleInfo(_showDateRange.startDate, _showDateRange.stopDate)) { @@ -138,12 +159,12 @@ void CScheduleBaseWidget::updateDBusData() */ void CScheduleBaseWidget::updateSearchScheduleInfo() { - + qCDebug(ClientLogger) << "CScheduleBaseWidget::updateSearchScheduleInfo (empty base implementation)"; } void CScheduleBaseWidget::deleteselectSchedule() { - + qCDebug(ClientLogger) << "CScheduleBaseWidget::deleteselectSchedule (empty base implementation)"; } /** @@ -152,6 +173,7 @@ void CScheduleBaseWidget::deleteselectSchedule() */ CaHuangLiDayInfo CScheduleBaseWidget::getLunarInfo() { + qCDebug(ClientLogger) << "CScheduleBaseWidget::getLunarInfo"; CaHuangLiDayInfo huangLiInfo = gLunarManager->getHuangLiDay(getSelectDate()); m_lunarYear = QString("-%0%1年-").arg(huangLiInfo.mGanZhiYear).arg(huangLiInfo.mZodiac); m_lunarDay = QString("-农历%0%1-").arg(huangLiInfo.mLunarMonthName).arg(huangLiInfo.mLunarDayName); @@ -160,6 +182,7 @@ CaHuangLiDayInfo CScheduleBaseWidget::getLunarInfo() void CScheduleBaseWidget::slotScheduleUpdate() { + qCDebug(ClientLogger) << "CScheduleBaseWidget::slotScheduleUpdate"; updateShowSchedule(); //刷新日程的同时也要刷新被搜索的日程,保证有搜索日程时显示正常 updateSearchScheduleInfo(); @@ -167,5 +190,6 @@ void CScheduleBaseWidget::slotScheduleUpdate() void CScheduleBaseWidget::slotSearchedScheduleUpdate() { + qCDebug(ClientLogger) << "CScheduleBaseWidget::slotSearchedScheduleUpdate"; updateSearchScheduleInfo(); } diff --git a/calendar-client/src/widget/dayWidget/dayhuangliview.cpp b/calendar-client/src/widget/dayWidget/dayhuangliview.cpp index bf5ed587d..2e15d88c9 100644 --- a/calendar-client/src/widget/dayWidget/dayhuangliview.cpp +++ b/calendar-client/src/widget/dayWidget/dayhuangliview.cpp @@ -1,9 +1,10 @@ -// SPDX-FileCopyrightText: 2017 - 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2019 - 2022 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: LGPL-3.0-or-later #include "dayhuangliview.h" #include "scheduledlg.h" +#include "commondef.h" #include @@ -18,37 +19,45 @@ CDayHuangLiLabel::CDayHuangLiLabel(QWidget *parent) : DLabel(parent) { + qCDebug(ClientLogger) << "CDayHuangLiLabel::CDayHuangLiLabel"; setContentsMargins(0, 0, 0, 0); } void CDayHuangLiLabel::setbackgroundColor(QColor backgroundColor) { + qCDebug(ClientLogger) << "CDayHuangLiLabel::setbackgroundColor, color:" << backgroundColor; m_backgroundColor = backgroundColor; } void CDayHuangLiLabel::setTextInfo(QColor tcolor, QFont font) { + qCDebug(ClientLogger) << "CDayHuangLiLabel::setTextInfo, color:" << tcolor; m_textcolor = tcolor; m_font = font; } void CDayHuangLiLabel::setHuangLiText(QStringList vhuangli, int type) { + qCDebug(ClientLogger) << "CDayHuangLiLabel::setHuangLiText, type:" << type; m_vHuangli = vhuangli; m_type = type; if (!vhuangli.isEmpty()) { + qCDebug(ClientLogger) << "Setting tooltip for Huangli text"; QString str = vhuangli.at(0); for (int i = 1; i < vhuangli.count(); i++) { str += "." + vhuangli.at(i); } setToolTip(str); } else { + qCDebug(ClientLogger) << "Clearing tooltip for empty Huangli text"; setToolTip(QString()); } update(); } void CDayHuangLiLabel::paintEvent(QPaintEvent *e) { + // This function is called frequently, so logging is commented out. + // qCDebug(ClientLogger) << "CDayHuangLiLabel::paintEvent"; Q_UNUSED(e); int labelwidth = width(); int labelheight = height(); @@ -95,6 +104,8 @@ void CDayHuangLiLabel::paintEvent(QPaintEvent *e) void CDayHuangLiLabel::resizeEvent(QResizeEvent *event) { + // This function is called frequently, so logging is commented out. + // qCDebug(ClientLogger) << "CDayHuangLiLabel::resizeEvent"; m_leftMagin = static_cast(0.0424 * width() + 0.5); m_topMagin = (height() - 20) / 2; DLabel::resizeEvent(event); diff --git a/calendar-client/src/widget/dayWidget/daymonthview.cpp b/calendar-client/src/widget/dayWidget/daymonthview.cpp index 6ee3aafa9..ba9762480 100644 --- a/calendar-client/src/widget/dayWidget/daymonthview.cpp +++ b/calendar-client/src/widget/dayWidget/daymonthview.cpp @@ -10,6 +10,7 @@ #include "configsettings.h" #include "calendarglobalenv.h" #include "scheduledlg.h" +#include "commondef.h" #include #include @@ -30,6 +31,7 @@ DGUI_USE_NAMESPACE CDayMonthView::CDayMonthView(QWidget *parent) : CustomFrame(parent) { + qCDebug(ClientLogger) << "CDayMonthView::CDayMonthView"; m_weeklist.append(tr("Monday")); m_weeklist.append(tr("Tuesday")); m_weeklist.append(tr("Wednesday")); @@ -43,10 +45,12 @@ CDayMonthView::CDayMonthView(QWidget *parent) CDayMonthView::~CDayMonthView() { + qCDebug(ClientLogger) << "CDayMonthView::~CDayMonthView"; } void CDayMonthView::setShowDate(const QVector &showDate, const QDate &selectDate, const QDate ¤tDate) { + qCDebug(ClientLogger) << "CDayMonthView::setShowDate, selectDate:" << selectDate; m_selectDate = selectDate; m_currentDate = currentDate; m_dayMonthWidget->setShowDate(showDate, selectDate, currentDate); @@ -56,6 +60,7 @@ void CDayMonthView::setShowDate(const QVector &showDate, const QDate &sel void CDayMonthView::setLunarVisible(bool visible) { + qCDebug(ClientLogger) << "CDayMonthView::setLunarVisible, visible:" << visible; m_huanglistate = visible; m_yiLabel->setVisible(visible); m_jiLabel->setVisible(visible); @@ -66,9 +71,11 @@ void CDayMonthView::setLunarVisible(bool visible) void CDayMonthView::setTheMe(int type) { + qCDebug(ClientLogger) << "CDayMonthView::setTheMe, type:" << type; QColor todayColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); m_dayMonthWidget->setTheMe(type); if (type == 0 || type == 1) { + qCDebug(ClientLogger) << "Applying light theme"; DPalette aniPa = this->palette(); QColor tbColor = "#FFFFFF"; aniPa.setColor(DPalette::Window, tbColor); @@ -117,6 +124,7 @@ void CDayMonthView::setTheMe(int type) m_festivalTextColor = Qt::black; } else if (type == 2) { + qCDebug(ClientLogger) << "Applying dark theme"; DPalette aniPa = this->palette(); QColor tbColor = "#282828"; aniPa.setColor(DPalette::Window, tbColor); @@ -163,6 +171,7 @@ void CDayMonthView::setTheMe(int type) void CDayMonthView::setSearchFlag(bool flag) { + qCDebug(ClientLogger) << "CDayMonthView::setSearchFlag, flag:" << flag; m_searchflag = flag; update(); } @@ -173,17 +182,20 @@ void CDayMonthView::setSearchFlag(bool flag) */ void CDayMonthView::setHuangLiInfo(const CaHuangLiDayInfo &huangLiInfo) { + qCDebug(ClientLogger) << "CDayMonthView::setHuangLiInfo"; m_huangLiInfo = huangLiInfo; updateDateLunarDay(); } void CDayMonthView::setHasScheduleFlag(const QVector &hasScheduleFlag) { + qCDebug(ClientLogger) << "CDayMonthView::setHasScheduleFlag"; m_dayMonthWidget->setHasScheduleFlag(hasScheduleFlag); } void CDayMonthView::initUI() { + qCDebug(ClientLogger) << "CDayMonthView::initUI"; m_today = new CTodayButton; m_today->setText(QCoreApplication::translate("today", "Today", "Today")); m_today->setFixedSize(80, DDEDayCalendar::D_MLabelHeight); @@ -314,6 +326,7 @@ void CDayMonthView::initUI() void CDayMonthView::initConnection() { + qCDebug(ClientLogger) << "CDayMonthView::initConnection"; connect(m_prevButton, &DIconButton::clicked, this, &CDayMonthView::slotprev); connect(m_today, &CTodayButton::clicked, this, &CDayMonthView::slottoday); connect(m_nextButton, &DIconButton::clicked, this, &CDayMonthView::slotnext); @@ -325,6 +338,7 @@ void CDayMonthView::initConnection() */ void CDayMonthView::updateDateShow() { + qCDebug(ClientLogger) << "CDayMonthView::updateDateShow"; QLocale locale; m_currentMouth->setTextStr(locale.monthName(m_selectDate.month(), QLocale::ShortFormat)); m_currentDay->setTextStr(QString::number(m_selectDate.day())); @@ -345,7 +359,11 @@ void CDayMonthView::updateDateShow() */ void CDayMonthView::updateDateLunarDay() { - if (!m_huanglistate) return; + qCDebug(ClientLogger) << "CDayMonthView::updateDateLunarDay"; + if (!m_huanglistate) { + qCDebug(ClientLogger) << "Huangli state is false, returning"; + return; + } m_currentLuna->setTextStr(m_huangLiInfo.mGanZhiYear + "年 " + "【" + m_huangLiInfo.mZodiac + "年】" + m_huangLiInfo.mGanZhiMonth + "月 " + m_huangLiInfo.mGanZhiDay + "日 "); QStringList yiList = m_huangLiInfo.mSuit.split(".", Qt::SkipEmptyParts); QStringList jiList = m_huangLiInfo.mAvoid.split(".", Qt::SkipEmptyParts); @@ -355,20 +373,24 @@ void CDayMonthView::updateDateLunarDay() void CDayMonthView::changeSelectDate(const QDate &date) { + qCDebug(ClientLogger) << "CDayMonthView::changeSelectDate, date:" << date; emit signalChangeSelectDate(date); } void CDayMonthView::wheelEvent(QWheelEvent *event) { + // qCDebug(ClientLogger) << "CDayMonthView::wheelEvent"; //如果是拖拽则退出 bool isDragging = false; emit signalIsDragging(isDragging); if (isDragging) return; if (event->angleDelta().y() < 0) { + // qCDebug(ClientLogger) << "Wheeling down, changing to next day"; //切换前一天 changeSelectDate(m_selectDate.addDays(1)); } else { + // qCDebug(ClientLogger) << "Wheeling up, changing to previous day"; //切换后一天 changeSelectDate(m_selectDate.addDays(-1)); } @@ -376,6 +398,7 @@ void CDayMonthView::wheelEvent(QWheelEvent *event) void CDayMonthView::paintEvent(QPaintEvent *e) { + // qCDebug(ClientLogger) << "CDayMonthView::paintEvent"; Q_UNUSED(e); int labelwidth = width(); int labelheight = height(); @@ -406,16 +429,19 @@ void CDayMonthView::paintEvent(QPaintEvent *e) void CDayMonthView::slotprev() { + qCDebug(ClientLogger) << "CDayMonthView::slotprev"; changeSelectDate(m_selectDate.addMonths(-1)); } void CDayMonthView::slotnext() { + qCDebug(ClientLogger) << "CDayMonthView::slotnext"; changeSelectDate(m_selectDate.addMonths(1)); } void CDayMonthView::slottoday() { + qCDebug(ClientLogger) << "CDayMonthView::slottoday"; changeSelectDate(m_currentDate); } @@ -423,6 +449,7 @@ CDayMonthWidget::CDayMonthWidget(QWidget *parent) : QWidget(parent) , m_isFocus(false) { + qCDebug(ClientLogger) << "CDayMonthWidget::CDayMonthWidget"; m_gridLayout = new QGridLayout; m_gridLayout->setContentsMargins(0, 0, 0, 0); m_gridLayout->setSpacing(0); @@ -443,17 +470,21 @@ CDayMonthWidget::CDayMonthWidget(QWidget *parent) CDayMonthWidget::~CDayMonthWidget() { + qCDebug(ClientLogger) << "CDayMonthWidget::~CDayMonthWidget"; } void CDayMonthWidget::setTheMe(int type) { + qCDebug(ClientLogger) << "CDayMonthWidget::setTheMe, type:" << type; m_currentDayTextColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); if (type == 0 || type == 1) { + qCDebug(ClientLogger) << "Applying light theme"; m_defaultTextColor = Qt::black; m_selectedTextColor = Qt::white; m_notCurrentTextColor = "#b2b2b2"; m_ceventColor = QColor(255, 93, 0); } else if (type == 2) { + qCDebug(ClientLogger) << "Applying dark theme"; m_defaultTextColor = "#C0C6D4"; m_selectedTextColor = "#B8D3FF"; m_notCurrentTextColor = "#C0C6D4"; @@ -465,6 +496,7 @@ void CDayMonthWidget::setTheMe(int type) void CDayMonthWidget::setShowDate(const QVector &showDate, const QDate &selectDate, const QDate ¤tDate) { + qCDebug(ClientLogger) << "CDayMonthWidget::setShowDate, selectDate:" << selectDate; m_showDays = showDate; m_selectDate = selectDate; m_currentDate = currentDate; @@ -475,22 +507,26 @@ void CDayMonthWidget::setShowDate(const QVector &showDate, const QDate &s void CDayMonthWidget::setHasScheduleFlag(const QVector &hasScheduleFlag) { + qCDebug(ClientLogger) << "CDayMonthWidget::setHasScheduleFlag"; m_vlineflag = hasScheduleFlag; update(); } const QString CDayMonthWidget::getCellDayNum(int pos) { + // qCDebug(ClientLogger) << "CDayMonthWidget::getCellDayNum, pos:" << pos; return QString::number(m_showDays[pos].day()); } const QDate CDayMonthWidget::getCellDate(int pos) { + // qCDebug(ClientLogger) << "CDayMonthWidget::getCellDate, pos:" << pos; return m_showDays[pos]; } void CDayMonthWidget::paintCell(QWidget *cell) { + // qCDebug(ClientLogger) << "CDayMonthWidget::paintCell"; const QRect rect = cell->rect(); const int pos = m_cellList.indexOf(cell); const bool isSelectedCell = pos == m_selectedCell; @@ -547,6 +583,7 @@ void CDayMonthWidget::paintCell(QWidget *cell) if (m_vlineflag.count() == DDEDayCalendar::PainterCellNum) { if (m_vlineflag[pos]) { if (m_selectDate.month() == getCellDate(pos).month()) { + // qCDebug(ClientLogger) << "Drawing schedule indicator for cell:" << pos; painter.save(); QPen pen; pen.setWidth(2); @@ -569,6 +606,7 @@ void CDayMonthWidget::paintCell(QWidget *cell) bool CDayMonthWidget::eventFilter(QObject *o, QEvent *e) { + // qCDebug(ClientLogger) << "CDayMonthWidget::eventFilter, event type:" << e->type(); if (m_showDays.size() != 42) return false; QWidget *cell = qobject_cast(o); @@ -581,6 +619,7 @@ bool CDayMonthWidget::eventFilter(QObject *o, QEvent *e) if (e->type() == QEvent::Paint) { paintCell(cell); } else if (e->type() == QEvent::MouseButtonPress) { + // qCDebug(ClientLogger) << "Mouse press on cell:" << pos; m_dayMouseState = 1; } else if (e->type() == QEvent::MouseMove) { if (m_dayMouseState == 1) { @@ -593,6 +632,7 @@ bool CDayMonthWidget::eventFilter(QObject *o, QEvent *e) //如果m_dayCreateState为0需要判断是否离开了选择区域,否则不需要判断 if (m_dayCreateState == 0 && !cell->rect().contains(mouseEvent->pos())) { //如果离开选择日期区域则修改鼠标显示 + // qCDebug(ClientLogger) << "Mouse moved out of cell, setting cursor to ClosedHandCursor"; setCursor(Qt::ClosedHandCursor); m_dayCreateState = 1; } @@ -606,9 +646,11 @@ bool CDayMonthWidget::eventFilter(QObject *o, QEvent *e) QRect rect = widget->geometry(); if (rect.contains(globalPoint)) { + // qCDebug(ClientLogger) << "Mouse is within active window"; setCursor(Qt::ClosedHandCursor); m_dayCreateState = 1; } else { + // qCDebug(ClientLogger) << "Mouse is outside active window"; setCursor(Qt::ForbiddenCursor); m_dayCreateState = 2; } @@ -616,9 +658,11 @@ bool CDayMonthWidget::eventFilter(QObject *o, QEvent *e) } } } else if (e->type() == QEvent::MouseButtonRelease) { + // qCDebug(ClientLogger) << "Mouse release on cell:" << pos; QMouseEvent *mouseEvent = dynamic_cast(e); // if (m_dayCreateState == 1) { + // qCDebug(ClientLogger) << "Creating new schedule on release"; //新建日程 const int pos = m_cellList.indexOf(cell); QDate date = m_showDays.at(pos); @@ -634,6 +678,7 @@ bool CDayMonthWidget::eventFilter(QObject *o, QEvent *e) //如果不在点击区域内则不跳转日期 //跳转日期 if (mouseEvent->button() == Qt::LeftButton && cell->rect().contains(mouseEvent->pos())) { + // qCDebug(ClientLogger) << "Cell clicked, changing selection"; cellClicked(cell); } } @@ -648,6 +693,7 @@ bool CDayMonthWidget::eventFilter(QObject *o, QEvent *e) void CDayMonthWidget::resizeEvent(QResizeEvent *event) { + // qCDebug(ClientLogger) << "CDayMonthWidget::resizeEvent"; //获取每个时间widget的高度和宽度 qreal width = this->width() / 7; qreal height = this->height() / 6; @@ -659,6 +705,7 @@ void CDayMonthWidget::resizeEvent(QResizeEvent *event) void CDayMonthWidget::focusInEvent(QFocusEvent *event) { + // qCDebug(ClientLogger) << "CDayMonthWidget::focusInEvent, reason:" << event->reason(); switch (event->reason()) { case Qt::TabFocusReason: case Qt::BacktabFocusReason: @@ -674,6 +721,7 @@ void CDayMonthWidget::focusInEvent(QFocusEvent *event) void CDayMonthWidget::focusOutEvent(QFocusEvent *event) { + // qCDebug(ClientLogger) << "CDayMonthWidget::focusOutEvent"; Q_UNUSED(event) m_isFocus = false; update(); @@ -681,18 +729,23 @@ void CDayMonthWidget::focusOutEvent(QFocusEvent *event) void CDayMonthWidget::keyPressEvent(QKeyEvent *event) { + // qCDebug(ClientLogger) << "CDayMonthWidget::keyPressEvent, key:" << event->key(); if (m_isFocus) { switch (event->key()) { case Qt::Key_Left: + qCDebug(ClientLogger) << "Moving to previous day"; emit signalChangeSelectDate(m_selectDate.addDays(-1)); break; case Qt::Key_Right: + qCDebug(ClientLogger) << "Moving to next day"; emit signalChangeSelectDate(m_selectDate.addDays(1)); break; case Qt::Key_Up: + qCDebug(ClientLogger) << "Moving to previous week"; emit signalChangeSelectDate(m_selectDate.addDays(-7)); break; case Qt::Key_Down: + qCDebug(ClientLogger) << "Moving to next week"; emit signalChangeSelectDate(m_selectDate.addDays(7)); break; default: @@ -705,6 +758,7 @@ void CDayMonthWidget::keyPressEvent(QKeyEvent *event) void CDayMonthWidget::mousePressEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "CDayMonthWidget::mousePressEvent"; QWidget::mousePressEvent(event); m_isFocus = false; if (event->button() & Qt::LeftButton) @@ -713,15 +767,21 @@ void CDayMonthWidget::mousePressEvent(QMouseEvent *event) void CDayMonthWidget::cellClicked(QWidget *cell) { + qCDebug(ClientLogger) << "CDayMonthWidget::cellClicked"; const int pos = m_cellList.indexOf(cell); - if (pos == -1) + if (pos == -1) { + qCWarning(ClientLogger) << "Invalid cell clicked"; return; + } setSelectedCell(pos); } void CDayMonthWidget::setSelectedCell(int index) { - if (m_selectedCell == index) + qCDebug(ClientLogger) << "CDayMonthWidget::setSelectedCell, index:" << index; + if (m_selectedCell == index) { + qCDebug(ClientLogger) << "Cell already selected, returning"; return; + } emit signalChangeSelectDate(m_showDays.at(index)); } diff --git a/calendar-client/src/widget/dayWidget/daywindow.cpp b/calendar-client/src/widget/dayWidget/daywindow.cpp index ae82b55b9..be822b9f2 100644 --- a/calendar-client/src/widget/dayWidget/daywindow.cpp +++ b/calendar-client/src/widget/dayWidget/daywindow.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2015 - 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2019 - 2022 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: LGPL-3.0-or-later @@ -8,6 +8,7 @@ #include "daymonthview.h" #include "schedulesearchview.h" #include "scheduleview.h" +#include "commondef.h" #include @@ -20,15 +21,21 @@ DGUI_USE_NAMESPACE CDayWindow::CDayWindow(QWidget *parent) : CScheduleBaseWidget(parent) { + qCDebug(ClientLogger) << "CDayWindow::CDayWindow"; initUI(); initConnection(); setLunarVisible(m_calendarManager->getShowLunar()); } -CDayWindow::~CDayWindow() {} +CDayWindow::~CDayWindow() +{ + qCDebug(ClientLogger) << "CDayWindow::~CDayWindow"; +} void CDayWindow::setTheMe(int type) { + qCDebug(ClientLogger) << "CDayWindow::setTheMe, type:" << type; if (type == 0 || type == 1) { + qCDebug(ClientLogger) << "Applying light theme"; m_leftground->setBColor("#FFFFFF"); DPalette ypa = m_YearLabel->palette(); @@ -44,6 +51,7 @@ void CDayWindow::setTheMe(int type) m_SolarDay->setPalette(spa); m_SolarDay->setForegroundRole(DPalette::WindowText); } else if (type == 2) { + qCDebug(ClientLogger) << "Applying dark theme"; m_leftground->setBColor("#282828"); DPalette ypa = m_YearLabel->palette(); @@ -69,13 +77,17 @@ void CDayWindow::setTheMe(int type) */ void CDayWindow::setTime(const QTime time) { + qCDebug(ClientLogger) << "CDayWindow::setTime, time:" << time; if (time.isValid()) { + qCDebug(ClientLogger) << "Time is valid, setting it"; //如果时间有效 m_scheduleView->setTime(time); } else { if (getSelectDate() == getCurrendDateTime().date()) { + qCDebug(ClientLogger) << "Setting to current time"; m_scheduleView->setTime(getCurrendDateTime().time()); } else { + qCDebug(ClientLogger) << "Setting to make time"; m_scheduleView->setTime(m_makeTime); } } @@ -86,6 +98,7 @@ void CDayWindow::setTime(const QTime time) */ void CDayWindow::updateHeight() { + qCDebug(ClientLogger) << "CDayWindow::updateHeight"; m_scheduleView->updateHeight(); } @@ -95,6 +108,7 @@ void CDayWindow::updateHeight() */ void CDayWindow::setCurrentDateTime(const QDateTime ¤tDate) { + qCDebug(ClientLogger) << "CDayWindow::setCurrentDateTime, date:" << currentDate; //设置当前时间 CScheduleBaseWidget::setCurrentDateTime(currentDate); //更新当前时间 @@ -106,6 +120,7 @@ void CDayWindow::setCurrentDateTime(const QDateTime ¤tDate) */ void CDayWindow::setYearData() { + qCDebug(ClientLogger) << "CDayWindow::setYearData"; QLocale locale; //判断是否为中文环境 if (getShowLunar()) { @@ -123,6 +138,7 @@ void CDayWindow::setYearData() */ void CDayWindow::updateShowDate(const bool isUpdateBar) { + qCDebug(ClientLogger) << "CDayWindow::updateShowDate, isUpdateBar:" << isUpdateBar; Q_UNUSED(isUpdateBar) setYearData(); int w = m_scheduleView->width() - 72; @@ -133,8 +149,10 @@ void CDayWindow::updateShowDate(const bool isUpdateBar) QVector _monthDate = m_calendarManager->getMonthDate(getSelectDate().year(), getSelectDate().month()); m_daymonthView->setShowDate(_monthDate, getSelectDate(), getCurrendDateTime().date()); //如果为中文环境则显示农历信息 - if (getShowLunar()) + if (getShowLunar()) { + qCDebug(ClientLogger) << "Showing lunar, updating lunar info"; updateShowLunar(); + } updateShowSchedule(); } @@ -143,6 +161,7 @@ void CDayWindow::updateShowDate(const bool isUpdateBar) */ void CDayWindow::updateShowSchedule() { + qCDebug(ClientLogger) << "CDayWindow::updateShowSchedule"; //获取一天的日程信息 QMap _weekScheduleInfo = gScheduleManager->getScheduleMap(getSelectDate(), getSelectDate()); //设置显示日程信息 @@ -166,6 +185,7 @@ void CDayWindow::updateShowSchedule() */ void CDayWindow::updateShowLunar() { + qCDebug(ClientLogger) << "CDayWindow::updateShowLunar"; CaHuangLiDayInfo _huangLiInfo = getLunarInfo(); m_LunarLabel->setText(tr("Lunar") + _huangLiInfo.mLunarMonthName + _huangLiInfo.mLunarDayName); m_daymonthView->setHuangLiInfo(_huangLiInfo); @@ -173,6 +193,7 @@ void CDayWindow::updateShowLunar() void CDayWindow::updateSearchScheduleInfo() { + qCDebug(ClientLogger) << "CDayWindow::updateSearchScheduleInfo"; m_scheduleView->slotUpdateScene(); } @@ -182,9 +203,12 @@ void CDayWindow::updateSearchScheduleInfo() */ void CDayWindow::setSelectSearchScheduleInfo(const DSchedule::Ptr &info) { + qCDebug(ClientLogger) << "CDayWindow::setSelectSearchScheduleInfo"; if (info->allDay()) { + qCDebug(ClientLogger) << "All day event, setting default time"; setTime(); } else { + qCDebug(ClientLogger) << "Timed event, setting specific time"; m_scheduleView->setTime(info->dtStart().time()); } @@ -196,17 +220,20 @@ void CDayWindow::setSelectSearchScheduleInfo(const DSchedule::Ptr &info) */ void CDayWindow::deleteselectSchedule() { + qCDebug(ClientLogger) << "CDayWindow::deleteselectSchedule"; m_scheduleView->slotDeleteitem(); } void CDayWindow::setSearchWFlag(bool flag) { + qCDebug(ClientLogger) << "CDayWindow::setSearchWFlag, flag:" << flag; m_searchFlag = flag; m_daymonthView->setSearchFlag(flag); } void CDayWindow::setLunarVisible(bool state) { + qCDebug(ClientLogger) << "CDayWindow::setLunarVisible, state:" << state; m_LunarLabel->setVisible(state); m_SolarDay->setVisible(state); m_scheduleView->setLunarVisible(state); @@ -215,6 +242,7 @@ void CDayWindow::setLunarVisible(bool state) void CDayWindow::initUI() { + qCDebug(ClientLogger) << "CDayWindow::initUI"; QHBoxLayout *titleLayout = new QHBoxLayout; titleLayout->setContentsMargins(0, 0, 0, 0); titleLayout->setSpacing(0); @@ -294,6 +322,7 @@ void CDayWindow::initUI() void CDayWindow::initConnection() { + qCDebug(ClientLogger) << "CDayWindow::initConnection"; connect(m_daymonthView, &CDayMonthView::signalIsDragging, this, &CDayWindow::slotIsDragging); connect(m_daymonthView, &CDayMonthView::signalChangeSelectDate, this, &CDayWindow::slotChangeSelectDate); connect(m_scheduleView, &CScheduleView::signalSwitchPrePage, this, &CDayWindow::slotSwitchPrePage); @@ -306,6 +335,7 @@ void CDayWindow::initConnection() */ void CDayWindow::setMakeTime(QMap &info) { + qCDebug(ClientLogger) << "CDayWindow::setMakeTime"; if (info.contains(getSelectDate())) { DSchedule::List _scheduleVector = info[getSelectDate()]; //设置当前第一个非全天默认时间 @@ -320,8 +350,10 @@ void CDayWindow::setMakeTime(QMap &info) } //如果为默认时间则表示当天没有非全天日程 if (firstscheduleBeginTime.date() > getSelectDate()) { + qCDebug(ClientLogger) << "No non-all-day events, setting default time"; m_makeTime.setHMS(12, 30, 0, 0); } else if (firstscheduleBeginTime.date() == getSelectDate()) { + qCDebug(ClientLogger) << "Found non-all-day events, setting make time"; m_makeTime = firstscheduleBeginTime.time(); //设置定位的时间位置,原始时间太靠下,现向上偏移2小时 QTime onTime = m_makeTime; @@ -332,9 +364,11 @@ void CDayWindow::setMakeTime(QMap &info) } m_makeTime = onTime; } else { + qCDebug(ClientLogger) << "Setting default make time"; m_makeTime.setHMS(0, 0, 0, 0); } } else { + qCDebug(ClientLogger) << "No schedules for selected date, setting default time"; //将定位的默认时间显示出8点 m_makeTime.setHMS(12, 30, 0, 0); } @@ -342,6 +376,7 @@ void CDayWindow::setMakeTime(QMap &info) void CDayWindow::slotScheduleHide() { + qCDebug(ClientLogger) << "CDayWindow::slotScheduleHide"; m_scheduleView->slotScheduleShow(false); } @@ -351,7 +386,9 @@ void CDayWindow::slotScheduleHide() */ void CDayWindow::slotChangeSelectDate(const QDate &date) { + qCDebug(ClientLogger) << "CDayWindow::slotChangeSelectDate, date:" << date; if (setSelectDate(date, true)) { + qCDebug(ClientLogger) << "Date set successfully, updating view"; //隐藏日程悬浮框 slotScheduleHide(); updateShowDate(); @@ -361,6 +398,7 @@ void CDayWindow::slotChangeSelectDate(const QDate &date) void CDayWindow::slotIsDragging(bool &isDragging) { + qCDebug(ClientLogger) << "CDayWindow::slotIsDragging"; isDragging = m_scheduleView->IsDragging(); } @@ -369,6 +407,7 @@ void CDayWindow::slotIsDragging(bool &isDragging) */ void CDayWindow::slotSwitchPrePage() { + qCDebug(ClientLogger) << "CDayWindow::slotSwitchPrePage"; slotChangeSelectDate(getSelectDate().addDays(-1)); } @@ -377,5 +416,6 @@ void CDayWindow::slotSwitchPrePage() */ void CDayWindow::slotSwitchNextPage() { + qCDebug(ClientLogger) << "CDayWindow::slotSwitchNextPage"; slotChangeSelectDate(getSelectDate().addDays(1)); } diff --git a/calendar-client/src/widget/monthWidget/monthdayview.cpp b/calendar-client/src/widget/monthWidget/monthdayview.cpp index 8e2a474ff..3d9548efb 100644 --- a/calendar-client/src/widget/monthWidget/monthdayview.cpp +++ b/calendar-client/src/widget/monthWidget/monthdayview.cpp @@ -6,6 +6,7 @@ #include "scheduledatamanage.h" #include "constants.h" #include "units.h" +#include "commondef.h" #include @@ -23,6 +24,7 @@ CMonthDayView::CMonthDayView(QWidget *parent) : DFrame(parent) , m_touchGesture(this) { + qCDebug(ClientLogger) << "CMonthDayView::CMonthDayView"; QHBoxLayout *hBoxLayout = new QHBoxLayout; hBoxLayout->setContentsMargins(0, 0, 0, 0); hBoxLayout->setSpacing(0); @@ -38,6 +40,7 @@ CMonthDayView::CMonthDayView(QWidget *parent) CMonthDayView::~CMonthDayView() { + qCDebug(ClientLogger) << "CMonthDayView::~CMonthDayView"; } /** @@ -46,6 +49,7 @@ CMonthDayView::~CMonthDayView() */ void CMonthDayView::setSelectDate(const QDate &date) { + qCDebug(ClientLogger) << "CMonthDayView::setSelectDate, date:" << date; m_selectDate = date; for (int i = 0; i < DDEMonthCalendar::MonthNumOfYear; ++i) { m_days[i] = m_selectDate.addMonths(i - 5); @@ -60,10 +64,13 @@ void CMonthDayView::setSelectDate(const QDate &date) */ void CMonthDayView::setTheMe(int type) { + qCDebug(ClientLogger) << "CMonthDayView::setTheMe, type:" << type; QColor frameColor; if (type == 0 || type == 1) { + qCDebug(ClientLogger) << "Applying light theme"; frameColor = "#FFFFFF"; } else if (type == 2) { + qCDebug(ClientLogger) << "Applying dark theme"; frameColor = "#FFFFFF"; frameColor.setAlphaF(0.05); } @@ -76,33 +83,41 @@ void CMonthDayView::setTheMe(int type) void CMonthDayView::setSearchflag(bool flag) { + qCDebug(ClientLogger) << "CMonthDayView::setSearchflag, flag:" << flag; m_searchFlag = flag; } void CMonthDayView::wheelEvent(QWheelEvent *e) { + // qCDebug(ClientLogger) << "CMonthDayView::wheelEvent"; //如果滚动为左右则触发信号 if (e->angleDelta().x() != 0) { + // qCDebug(ClientLogger) << "Moving horizontally"; emit signalAngleDelta(e->angleDelta().x()); } else { + // qCDebug(ClientLogger) << "Moving vertically"; emit signalAngleDelta(e->angleDelta().y()); } } bool CMonthDayView::event(QEvent *e) { + // qCDebug(ClientLogger) << "CMonthDayView::event"; if (m_touchGesture.event(e)) { //获取触摸状态 switch (m_touchGesture.getTouchState()) { case touchGestureOperation::T_SLIDE: { + // qCDebug(ClientLogger) << "Sliding gesture detected"; //在滑动状态如果可以更新数据则切换月份 if (m_touchGesture.isUpdate()) { m_touchGesture.setUpdate(false); switch (m_touchGesture.getMovingDir()) { case touchGestureOperation::T_LEFT: + qCDebug(ClientLogger) << "Moving to previous month"; emit signalAngleDelta(-1); break; case touchGestureOperation::T_RIGHT: + qCDebug(ClientLogger) << "Moving to next month"; emit signalAngleDelta(1); break; default: @@ -127,6 +142,7 @@ CMonthWidget::CMonthWidget(QWidget *parent) : QWidget(parent) , m_isFocus(false) { + qCDebug(ClientLogger) << "CMonthWidget::CMonthWidget"; for (int i = 0; i < DDEMonthCalendar::MonthNumOfYear; ++i) { CMonthRect *monthrect = new CMonthRect(this); m_MonthItem.append(monthrect); @@ -137,6 +153,7 @@ CMonthWidget::CMonthWidget(QWidget *parent) CMonthWidget::~CMonthWidget() { + qCDebug(ClientLogger) << "CMonthWidget::~CMonthWidget"; for (int i = 0; i < DDEMonthCalendar::MonthNumOfYear; ++i) { CMonthRect *monthrect = m_MonthItem.at(i); delete monthrect; @@ -147,6 +164,7 @@ CMonthWidget::~CMonthWidget() void CMonthWidget::setDate(const QDate date[12]) { + qCDebug(ClientLogger) << "CMonthWidget::setDate"; for (int i = 0; i < DDEMonthCalendar::MonthNumOfYear; ++i) { m_MonthItem.at(i)->setDate(date[i]); } @@ -156,12 +174,14 @@ void CMonthWidget::setDate(const QDate date[12]) void CMonthWidget::resizeEvent(QResizeEvent *event) { + // qCDebug(ClientLogger) << "CMonthWidget::resizeEvent"; Q_UNUSED(event); updateSize(); } void CMonthWidget::mousePressEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "CMonthWidget::mousePressEvent"; if (event->source() == Qt::MouseEventSynthesizedByQt) { //如果为触摸转换则设置触摸状态和触摸开始坐标 m_touchState = 1; @@ -177,6 +197,7 @@ void CMonthWidget::mousePressEvent(QMouseEvent *event) void CMonthWidget::paintEvent(QPaintEvent *event) { + // qCDebug(ClientLogger) << "CMonthWidget::paintEvent"; Q_UNUSED(event); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; @@ -188,6 +209,7 @@ void CMonthWidget::paintEvent(QPaintEvent *event) void CMonthWidget::mouseReleaseEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "CMonthWidget::mouseReleaseEvent"; if (event->source() == Qt::MouseEventSynthesizedByQt) { if (m_touchState == 1) { //如果为触摸且状态为点击则为触摸点击 @@ -200,6 +222,7 @@ void CMonthWidget::mouseReleaseEvent(QMouseEvent *event) void CMonthWidget::mouseMoveEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "CMonthWidget::mouseMoveEvent"; if (event->source() == Qt::MouseEventSynthesizedByQt) { QPoint currentPoint = event->pos(); //如果移动距离大与5则为触摸移动状态 @@ -212,21 +235,25 @@ void CMonthWidget::mouseMoveEvent(QMouseEvent *event) void CMonthWidget::keyPressEvent(QKeyEvent *event) { + // qCDebug(ClientLogger) << "CMonthWidget::keyPressEvent, key:" << event->key(); //获取当前选择时间 QDate selectDate = CMonthRect::getSelectRect()->getDate(); //初始化需要设置的时间 QDate setdate = selectDate; switch (event->key()) { case Qt::Key_Left: { + // qCDebug(ClientLogger) << "Moving to previous month"; setdate = selectDate.addMonths(-1); } break; case Qt::Key_Right: { + // qCDebug(ClientLogger) << "Moving to next month"; setdate = selectDate.addMonths(1); } break; default: QWidget::keyPressEvent(event); } if (selectDate != setdate) { + // qCDebug(ClientLogger) << "Date changed by key press, updating view"; //更新时间 updateShowDate(setdate); //设置更新后的时间并更新界面 @@ -237,14 +264,17 @@ void CMonthWidget::keyPressEvent(QKeyEvent *event) void CMonthWidget::focusInEvent(QFocusEvent *event) { + // qCDebug(ClientLogger) << "CMonthWidget::focusInEvent, reason:" << event->reason(); QWidget::focusInEvent(event); switch (event->reason()) { case Qt::TabFocusReason: case Qt::BacktabFocusReason: case Qt::ActiveWindowFocusReason: + // qCDebug(ClientLogger) << "Focus in"; m_isFocus = true; break; default: + // qCDebug(ClientLogger) << "Focus out"; m_isFocus = false; break; }; @@ -253,6 +283,7 @@ void CMonthWidget::focusInEvent(QFocusEvent *event) void CMonthWidget::focusOutEvent(QFocusEvent *event) { + // qCDebug(ClientLogger) << "CMonthWidget::focusOutEvent"; QWidget::focusOutEvent(event); m_isFocus = false; update(); @@ -260,9 +291,12 @@ void CMonthWidget::focusOutEvent(QFocusEvent *event) void CMonthWidget::mousePress(const QPoint &point) { + // qCDebug(ClientLogger) << "CMonthWidget::mousePress, point:" << point; int itemindex = getMousePosItem(point); if (!(itemindex < 0)) { + // qCDebug(ClientLogger) << "Clicked on item:" << itemindex; if (!withinTimeFrame(m_MonthItem.at(itemindex)->getDate())) { + qCDebug(ClientLogger) << "Clicked item is out of valid time frame"; return; } CMonthRect::setSelectRect(m_MonthItem.at(itemindex)); @@ -275,6 +309,7 @@ void CMonthWidget::mousePress(const QPoint &point) */ void CMonthWidget::updateSize() { + qCDebug(ClientLogger) << "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()); @@ -289,6 +324,7 @@ void CMonthWidget::updateSize() */ int CMonthWidget::getMousePosItem(const QPointF &pos) { + // qCDebug(ClientLogger) << "CMonthWidget::getMousePosItem, pos:" << pos; int res = -1; for (int i = 0 ; i < m_MonthItem.size(); ++i) { @@ -307,6 +343,7 @@ int CMonthWidget::getMousePosItem(const QPointF &pos) */ void CMonthWidget::updateShowDate(const QDate &selectDate) { + qCDebug(ClientLogger) << "CMonthWidget::updateShowDate, selectDate:" << selectDate; for (int i = 0; i < DDEMonthCalendar::MonthNumOfYear; ++i) { m_days[i] = selectDate.addMonths(i - 5); } @@ -326,6 +363,7 @@ CMonthRect *CMonthRect::m_SelectRect = nullptr; CMonthRect::CMonthRect(QWidget *parent) : m_parentWidget(parent) { + qCDebug(ClientLogger) << "CMonthRect::CMonthRect"; m_dayNumFont.setPixelSize(DDECalendar::FontSizeSixteen); m_dayNumFont.setWeight(QFont::Light); } @@ -336,6 +374,7 @@ CMonthRect::CMonthRect(QWidget *parent) */ void CMonthRect::setDate(const QDate &date) { + // qCDebug(ClientLogger) << "CMonthRect::setDate, date:" << date; m_Date = date; } @@ -345,6 +384,7 @@ void CMonthRect::setDate(const QDate &date) */ QDate CMonthRect::getDate() const { + // qCDebug(ClientLogger) << "CMonthRect::getDate"; return m_Date; } @@ -354,6 +394,7 @@ QDate CMonthRect::getDate() const */ QRectF CMonthRect::rect() const { + // qCDebug(ClientLogger) << "CMonthRect::rect"; return m_rect; } @@ -363,6 +404,7 @@ QRectF CMonthRect::rect() const */ void CMonthRect::setRect(const QRectF &rect) { + // qCDebug(ClientLogger) << "CMonthRect::setRect, rect:" << rect; m_rect = rect; } @@ -375,6 +417,7 @@ void CMonthRect::setRect(const QRectF &rect) */ void CMonthRect::setRect(qreal x, qreal y, qreal w, qreal h) { + // qCDebug(ClientLogger) << "CMonthRect::setRect, x:" << x << "y:" << y << "w:" << w << "h:" << h; m_rect.setRect(x, y, w, h); } @@ -385,6 +428,7 @@ void CMonthRect::setRect(qreal x, qreal y, qreal w, qreal h) */ void CMonthRect::paintItem(QPainter *painter, const QRectF &rect, bool drawFocus) { + // qCDebug(ClientLogger) << "CMonthRect::paintItem"; m_selectColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); if ( !withinTimeFrame(m_Date)) @@ -397,6 +441,7 @@ void CMonthRect::paintItem(QPainter *painter, const QRectF &rect, bool drawFocus const QString dayNum = QString::number(m_Date.month()); if (m_SelectRect == this) { + // qCDebug(ClientLogger) << "Drawing selected month"; QRectF fillRect((rect.width() - 36) / 2 + rect.x() + 6, (rect.height() - 36) / 2 + 7 + rect.y(), 24, @@ -406,6 +451,7 @@ void CMonthRect::paintItem(QPainter *painter, const QRectF &rect, bool drawFocus painter->drawEllipse(fillRect); //如果有焦点,绘制tab选中效果 if (drawFocus) { + // qCDebug(ClientLogger) << "Drawing focus rect"; QPen pen; pen.setWidth(2); pen.setColor(m_selectColor); @@ -420,6 +466,7 @@ void CMonthRect::paintItem(QPainter *painter, const QRectF &rect, bool drawFocus painter->setFont(m_dayNumFont); painter->drawText(rect, Qt::AlignCenter, dayNum); } else { + // qCDebug(ClientLogger) << "Drawing normal month"; if (isCurrentDay) { painter->setPen(m_backgroundcurrentDayColor); } else { @@ -436,6 +483,7 @@ void CMonthRect::paintItem(QPainter *painter, const QRectF &rect, bool drawFocus */ void CMonthRect::setDevicePixelRatio(const qreal pixel) { + // qCDebug(ClientLogger) << "CMonthRect::setDevicePixelRatio, pixel:" << pixel; m_DevicePixelRatio = pixel; } @@ -445,10 +493,12 @@ void CMonthRect::setDevicePixelRatio(const qreal pixel) */ void CMonthRect::setTheMe(int type) { + qCDebug(ClientLogger) << "CMonthRect::setTheMe, type:" << type; m_themetype = type; QColor frameColor; if (type == 0 || type == 1) { + qCDebug(ClientLogger) << "Applying light theme"; m_defaultTextColor = Qt::black; m_backgrounddefaultColor = Qt::white; m_currentDayTextColor = Qt::white; @@ -457,6 +507,7 @@ void CMonthRect::setTheMe(int type) frameColor = m_fillColor; m_fillColor.setAlphaF(0); } else if (type == 2) { + qCDebug(ClientLogger) << "Applying dark theme"; m_defaultTextColor = "#C0C6D4"; QColor framecolor = Qt::black; framecolor.setAlphaF(0.5); @@ -476,6 +527,7 @@ void CMonthRect::setTheMe(int type) */ void CMonthRect::setSelectRect(CMonthRect *selectRect) { + // qCDebug(ClientLogger) << "CMonthRect::setSelectRect"; m_SelectRect = selectRect; } @@ -485,5 +537,6 @@ void CMonthRect::setSelectRect(CMonthRect *selectRect) */ CMonthRect *CMonthRect::getSelectRect() { + // qCDebug(ClientLogger) << "CMonthRect::getSelectRect"; return m_SelectRect; } diff --git a/calendar-client/src/widget/monthWidget/monthscheduleview.cpp b/calendar-client/src/widget/monthWidget/monthscheduleview.cpp index adb5c5991..a776f5543 100644 --- a/calendar-client/src/widget/monthWidget/monthscheduleview.cpp +++ b/calendar-client/src/widget/monthWidget/monthscheduleview.cpp @@ -8,6 +8,7 @@ #include "scheduledlg.h" #include "myscheduleview.h" #include "graphicsItem/cmonthschedulenumitem.h" +#include "commondef.h" @@ -26,6 +27,7 @@ CMonthScheduleView::CMonthScheduleView(QWidget *parent, QGraphicsScene *scene) : QObject(parent) , m_Scene(scene) { + qCDebug(ClientLogger) << "CMonthScheduleView::CMonthScheduleView"; for (int i = 0; i < 6; ++i) { CWeekScheduleView *weekSchedule = new CWeekScheduleView(this); m_weekSchedule.append(weekSchedule); @@ -35,10 +37,12 @@ CMonthScheduleView::CMonthScheduleView(QWidget *parent, QGraphicsScene *scene) CMonthScheduleView::~CMonthScheduleView() { + qCDebug(ClientLogger) << "CMonthScheduleView::~CMonthScheduleView"; } void CMonthScheduleView::setallsize(int w, int h, int left, int top, int buttom, int itemHeight) { + qCDebug(ClientLogger) << "CMonthScheduleView::setallsize, width:" << w << "height:" << h; m_width = w; m_height = h; m_bottomMargin = buttom; @@ -49,6 +53,7 @@ void CMonthScheduleView::setallsize(int w, int h, int left, int top, int buttom, void CMonthScheduleView::setData(QMap &data, int currentMonth) { + qCDebug(ClientLogger) << "CMonthScheduleView::setData, data count:" << data.count() << "currentMonth:" << currentMonth; m_data = data; m_currentMonth = currentMonth; updateData(); @@ -56,6 +61,7 @@ void CMonthScheduleView::setData(QMap &data, int current void CMonthScheduleView::slotFontChange() { + qCDebug(ClientLogger) << "CMonthScheduleView::slotFontChange"; QFont font; DFontSizeManager::instance()->setFontGenericPixelSize( static_cast(DFontSizeManager::instance()->fontPixelSize(qGuiApp->font()))); @@ -64,6 +70,7 @@ void CMonthScheduleView::slotFontChange() int h = fm.height(); if (m_ItemHeight != h) { + qCDebug(ClientLogger) << "Font height changed, updating data"; m_ItemHeight = h; updateData(); } @@ -71,7 +78,9 @@ void CMonthScheduleView::slotFontChange() void CMonthScheduleView::slotStateChange(bool bState) { + qCDebug(ClientLogger) << "CMonthScheduleView::slotStateChange, state:" << bState; if(bState) { + qCDebug(ClientLogger) << "Hiding schedule items"; //日程显示 for (int i = 0; i < m_weekSchedule.size(); ++i) { m_weekSchedule[i]->hideItem(); @@ -85,13 +94,16 @@ void CMonthScheduleView::slotStateChange(bool bState) */ void CMonthScheduleView::updateData() { + qCDebug(ClientLogger) << "CMonthScheduleView::updateData"; //清空日程显示 for (int i = 0; i < m_weekSchedule.size(); ++i) { m_weekSchedule[i]->clearItem(); } //保护数据防止越界 - if (m_data.count() != DDEMonthCalendar::ItemSizeOfMonthDay || m_cNum < 1) + if (m_data.count() != DDEMonthCalendar::ItemSizeOfMonthDay || m_cNum < 1) { + qCWarning(ClientLogger) << "Data count or cNum is invalid, returning"; return; + } //开始结束时间 QMap::iterator _iter = m_data.begin(); QDate begindate = _iter.key(); @@ -109,6 +121,7 @@ void CMonthScheduleView::updateData() void CMonthScheduleView::updateHeight() { + qCDebug(ClientLogger) << "CMonthScheduleView::updateHeight"; 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(); @@ -118,6 +131,7 @@ void CMonthScheduleView::updateHeight() QVector CMonthScheduleView::getScheduleShowItem() const { + qCDebug(ClientLogger) << "CMonthScheduleView::getScheduleShowItem"; QVector m_scheduleShowItem; for (int j = 0; j < m_weekSchedule.size(); ++j) { @@ -131,9 +145,12 @@ QVector CMonthScheduleView::getScheduleShowItem() const void CMonthScheduleView::updateDate(const DSchedule::Ptr &info) { + qCDebug(ClientLogger) << "CMonthScheduleView::updateDate"; for (int i = 0; i < m_weekSchedule.size(); ++i) { if (m_weekSchedule.at(i)->addData(info)) { + qCDebug(ClientLogger) << "Added data to week" << i; } else { + qCDebug(ClientLogger) << "Failed to add data to week" << i << ", clearing and updating"; m_weekSchedule[i]->clearItem(); m_weekSchedule[i]->updateSchedule(true); }; @@ -144,6 +161,7 @@ void CMonthScheduleView::updateDate(const DSchedule::Ptr &info) void CMonthScheduleView::changeDate(const DSchedule::Ptr &info) { + qCDebug(ClientLogger) << "CMonthScheduleView::changeDate"; for (int i = 0; i < m_weekSchedule.size(); ++i) { m_weekSchedule.at(i)->changeDate(info); QVector> mSchedule = m_weekSchedule[i]->getMScheduleInfo(); @@ -153,6 +171,7 @@ void CMonthScheduleView::changeDate(const DSchedule::Ptr &info) void CMonthScheduleView::updateDate(const int row, const DSchedule::Ptr &info) { + qCDebug(ClientLogger) << "CMonthScheduleView::updateDate, row:" << row; for (int i = 0; i < m_weekSchedule.size(); ++i) { if (row == i) { m_weekSchedule.at(i)->addData(info); @@ -166,6 +185,7 @@ void CMonthScheduleView::updateDate(const int row, const DSchedule::Ptr &info) } void CMonthScheduleView::updateDateShow(QVector> &vCMDaySchedule, QVector &scheduleShowItem) { + // qCDebug(ClientLogger) << "CMonthScheduleView::updateDateShow"; for (int i = 0; i < vCMDaySchedule.count(); i++) { for (int j = 0; j < vCMDaySchedule[i].count(); j++) { if (vCMDaySchedule[i].at(j).state) { @@ -179,6 +199,7 @@ void CMonthScheduleView::updateDateShow(QVector> void CMonthScheduleView::createScheduleItemWidget(MScheduleDateRangeInfo info, int cNum, QVector &scheduleShowItem) { + // qCDebug(ClientLogger) << "CMonthScheduleView::createScheduleItemWidget"; DSchedule::Ptr gd = info.tData; QPoint pos; int fw; @@ -196,6 +217,7 @@ void CMonthScheduleView::createScheduleItemWidget(MScheduleDateRangeInfo info, i void CMonthScheduleView::createScheduleNumWidget(MScheduleDateRangeInfo info, int cNum, QVector &scheduleShowItem) { + // qCDebug(ClientLogger) << "CMonthScheduleView::createScheduleNumWidget"; int type = CScheduleDataManage::getScheduleDataManage()->getTheme(); CMonthScheduleNumItem *gwi = new CMonthScheduleNumItem(nullptr); QPoint pos; @@ -226,6 +248,7 @@ void CMonthScheduleView::createScheduleNumWidget(MScheduleDateRangeInfo info, in void CMonthScheduleView::computePos(int cNum, QDate bgeindate, QDate enddate, QPoint &pos, int &fw, int &fh) { + // qCDebug(ClientLogger) << "CMonthScheduleView::computePos"; 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; @@ -243,15 +266,18 @@ CWeekScheduleView::CWeekScheduleView(QObject *parent) , m_ScheduleHeight(22) , m_DayHeight(47) { + qCDebug(ClientLogger) << "CWeekScheduleView::CWeekScheduleView"; setMaxNum(); } CWeekScheduleView::~CWeekScheduleView() { + qCDebug(ClientLogger) << "CWeekScheduleView::~CWeekScheduleView"; } void CWeekScheduleView::setData(QMap &data, const QDate &startDate, const QDate &stopDate) { + qCDebug(ClientLogger) << "CWeekScheduleView::setData, from" << startDate << "to" << stopDate; //显示一周的日程 Q_ASSERT(startDate.daysTo(stopDate) == 6); m_ScheduleInfo.clear(); @@ -280,23 +306,32 @@ void CWeekScheduleView::setData(QMap &data, const QDate bool CWeekScheduleView::addData(const DSchedule::Ptr &info) { - if(info.isNull()) return false; + qCDebug(ClientLogger) << "CWeekScheduleView::addData"; + if(info.isNull()) { + qCWarning(ClientLogger) << "Info is null, returning false"; + return false; + } if (info->dtStart().date().daysTo(endDate) >= 0 && beginDate.daysTo(info->dtEnd().date()) >= 0) { + qCDebug(ClientLogger) << "Schedule is within date range, updating view"; clearItem(); updateSchedule(false, info); return true; } + qCDebug(ClientLogger) << "Schedule is outside date range, returning false"; return false; } void CWeekScheduleView::changeDate(const DSchedule::Ptr &info) { + qCDebug(ClientLogger) << "CWeekScheduleView::changeDate"; int index = m_ScheduleInfo.indexOf(info); if (index < 0) { + qCDebug(ClientLogger) << "Info not found, appending to schedule list"; m_ScheduleInfo.append(info); } else { + qCDebug(ClientLogger) << "Info found, updating schedule at index" << index; m_ScheduleInfo[index] = info; } clearItem(); @@ -305,6 +340,7 @@ void CWeekScheduleView::changeDate(const DSchedule::Ptr &info) void CWeekScheduleView::setHeight(const int ScheduleHeight, const int dayHeight) { + qCDebug(ClientLogger) << "CWeekScheduleView::setHeight, scheduleHeight:" << ScheduleHeight << "dayHeight:" << dayHeight; m_ScheduleHeight = ScheduleHeight; m_DayHeight = dayHeight; setMaxNum(); @@ -312,6 +348,7 @@ void CWeekScheduleView::setHeight(const int ScheduleHeight, const int dayHeight) void CWeekScheduleView::updateSchedule(const bool isNormalDisplay, const DSchedule::Ptr &info) { + qCDebug(ClientLogger) << "CWeekScheduleView::updateSchedule, isNormalDisplay:" << isNormalDisplay; DSchedule::List schedulev; schedulev.clear(); schedulev = m_ScheduleInfo; @@ -357,6 +394,7 @@ void CWeekScheduleView::updateSchedule(const bool isNormalDisplay, const DSchedu void CWeekScheduleView::clearItem() { + qCDebug(ClientLogger) << "CWeekScheduleView::clearItem"; for (int i = 0; i < m_scheduleShowItem.count(); i++) { delete m_scheduleShowItem[i]; } @@ -365,6 +403,7 @@ void CWeekScheduleView::clearItem() void CWeekScheduleView::hideItem() { + qCDebug(ClientLogger) << "CWeekScheduleView::hideItem"; for (int i = 0; i < m_scheduleShowItem.count(); i++) { m_scheduleShowItem[i]->setVisible(false); } @@ -373,11 +412,13 @@ void CWeekScheduleView::hideItem() void CWeekScheduleView::setMaxNum() { + qCDebug(ClientLogger) << "CWeekScheduleView::setMaxNum"; m_MaxNum = m_DayHeight / (m_ScheduleHeight + 1); } void CWeekScheduleView::mScheduleClear() { + qCDebug(ClientLogger) << "CWeekScheduleView::mScheduleClear"; for (int i = 0; i < m_MScheduleInfo.size(); ++i) { m_MScheduleInfo[i].clear(); } @@ -386,6 +427,7 @@ void CWeekScheduleView::mScheduleClear() void CWeekScheduleView::sortAndFilter(QVector &vMDaySchedule) { + qCDebug(ClientLogger) << "CWeekScheduleView::sortAndFilter"; QVector> scheduleFill; QVector scheduf; //初始化 @@ -474,6 +516,7 @@ void CWeekScheduleView::sortAndFilter(QVector &vMDaySche void CWeekScheduleView::addShowSchedule(const int &startPos, const int &endPos, const int &addRow, const DSchedule::Ptr &addInfo) { + qCDebug(ClientLogger) << "CWeekScheduleView::addShowSchedule, startPos:" << startPos << "endPos:" << endPos << "row:" << addRow; MScheduleDateRangeInfo scheduleInfo; //设置显示的开始日期 scheduleInfo.bdate = beginDate.addDays(startPos); diff --git a/calendar-client/src/widget/monthWidget/monthview.cpp b/calendar-client/src/widget/monthWidget/monthview.cpp index 4b173139d..01cdd5e9a 100644 --- a/calendar-client/src/widget/monthWidget/monthview.cpp +++ b/calendar-client/src/widget/monthWidget/monthview.cpp @@ -24,12 +24,14 @@ DGUI_USE_NAMESPACE */ void CMonthView::setTheMe(int type) { + qCDebug(ClientLogger) << "CMonthView::setTheMe, type:" << type; m_weekIndicator->setTheMe(type); m_monthGraphicsView->setTheMe(type); } CMonthView::CMonthView(QWidget *parent) : DWidget(parent) { + qCDebug(ClientLogger) << "CMonthView::CMonthView"; m_weekIndicator = new CMonthWeekView; m_monthGraphicsView = new CMonthGraphicsview(this); @@ -55,15 +57,18 @@ CMonthView::CMonthView(QWidget *parent) : DWidget(parent) CMonthView::~CMonthView() { + qCDebug(ClientLogger) << "CMonthView::~CMonthView"; } void CMonthView::setSelectSchedule(const DSchedule::Ptr &scheduleInfo) { + qCDebug(ClientLogger) << "CMonthView::setSelectSchedule"; m_monthGraphicsView->setSelectSearchSchedule(scheduleInfo); } void CMonthView::slotScheduleRemindWidget(const bool isShow, const DSchedule::Ptr &out) { + // qCDebug(ClientLogger) << "CMonthView::slotScheduleRemindWidget, isShow:" << isShow; if (isShow) { qCDebug(ClientLogger) << "Showing schedule reminder widget" << "summary:" << out->summary() @@ -84,21 +89,24 @@ void CMonthView::slotScheduleRemindWidget(const bool isShow, const DSchedule::Pt << "widget width:" << m_remindWidget->width(); if (rPos.x() < this->window()->width() / 2) { // 显示到右侧 + qCDebug(ClientLogger) << "Showing reminder to the right"; m_remindWidget->setDirection(DArrowRectangle::ArrowLeft); m_remindWidget->show(rPos.x()+10, rPos.y()); } else { // 显示到左侧 + qCDebug(ClientLogger) << "Showing reminder to the left"; m_remindWidget->setDirection(DArrowRectangle::ArrowRight); m_remindWidget->show(rPos.x()-10, rPos.y()); } } else { - qCDebug(ClientLogger) << "Hiding schedule reminder widget"; + // qCDebug(ClientLogger) << "Hiding schedule reminder widget"; m_remindWidget->hide(); } } void CMonthView::resizeEvent(QResizeEvent *event) { + // qCDebug(ClientLogger) << "CMonthView::resizeEvent"; DWidget::resizeEvent(event); QMargins margins = m_mainLayout->contentsMargins(); m_weekIndicator->setFixedSize(width() - margins.left(), static_cast(height() * 0.1042 + 0.5)); @@ -106,12 +114,14 @@ void CMonthView::resizeEvent(QResizeEvent *event) void CMonthView::mousePressEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "CMonthView::mousePressEvent"; Q_UNUSED(event); slotScheduleRemindWidget(false); } bool CMonthView::event(QEvent *event) { + // qCDebug(ClientLogger) << "CMonthView::event, type:" << event->type(); if (event->type() == QEvent::FocusIn) { m_monthGraphicsView->setFocus(Qt::TabFocusReason); return true; diff --git a/calendar-client/src/widget/monthWidget/monthweekview.cpp b/calendar-client/src/widget/monthWidget/monthweekview.cpp index ff55ce88f..2bc507b90 100644 --- a/calendar-client/src/widget/monthWidget/monthweekview.cpp +++ b/calendar-client/src/widget/monthWidget/monthweekview.cpp @@ -4,6 +4,7 @@ #include "monthweekview.h" #include "scheduledatamanage.h" +#include "commondef.h" #include @@ -16,6 +17,7 @@ DGUI_USE_NAMESPACE CMonthWeekView::CMonthWeekView(QWidget *parent) : DWidget(parent) { + qCDebug(ClientLogger) << "CMonthWeekView::CMonthWeekView"; for (int i = 0 ; i < 7 ; ++i) { m_weekRect.append(new WeekRect()); } @@ -23,6 +25,7 @@ CMonthWeekView::CMonthWeekView(QWidget *parent) CMonthWeekView::~CMonthWeekView() { + qCDebug(ClientLogger) << "CMonthWeekView::~CMonthWeekView"; for (int i = 0 ; i < 7 ; ++i) { WeekRect *weekRect = m_weekRect.at(i); delete weekRect; @@ -32,16 +35,20 @@ CMonthWeekView::~CMonthWeekView() void CMonthWeekView::setFirstDay(const Qt::DayOfWeek weekday) { + qCDebug(ClientLogger) << "CMonthWeekView::setFirstDay, weekday:" << weekday; m_firstWeek = weekday; updateWeek(); } void CMonthWeekView::setTheMe(int type) { + qCDebug(ClientLogger) << "CMonthWeekView::setTheMe, type:" << type; if (type == 0 || type == 1) { + qCDebug(ClientLogger) << "Applying light theme"; m_backgroundColor = "#E6EEF2"; } else if (type == 2) { + qCDebug(ClientLogger) << "Applying dark theme"; m_backgroundColor = "#82AEC1"; m_backgroundColor.setAlphaF(0.10); } @@ -52,6 +59,7 @@ void CMonthWeekView::setTheMe(int type) void CMonthWeekView::updateWeek() { + qCDebug(ClientLogger) << "CMonthWeekView::updateWeek"; Qt::DayOfWeek _setWeek; bool _showLine{false}; for (int i = 0; i < m_weekRect.size(); ++i) { @@ -74,12 +82,14 @@ void CMonthWeekView::updateWeek() */ void CMonthWeekView::setCurrentDate(const QDate ¤tDate) { + qCDebug(ClientLogger) << "CMonthWeekView::setCurrentDate, date:" << currentDate; m_currentWeek = static_cast(currentDate.dayOfWeek()); updateWeek(); } void CMonthWeekView::resizeEvent(QResizeEvent *event) { + // qCDebug(ClientLogger) << "CMonthWeekView::resizeEvent"; qreal weekRectWith = width() / 7; QRectF _rectF; for (int i = 0 ; i < m_weekRect.size(); ++i) { @@ -91,6 +101,7 @@ void CMonthWeekView::resizeEvent(QResizeEvent *event) void CMonthWeekView::paintEvent(QPaintEvent *event) { + // qCDebug(ClientLogger) << "CMonthWeekView::paintEvent"; Q_UNUSED(event); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); @@ -114,12 +125,14 @@ void CMonthWeekView::paintEvent(QPaintEvent *event) WeekRect::WeekRect() : m_showLine(false) { + qCDebug(ClientLogger) << "WeekRect::WeekRect"; m_font.setWeight(QFont::Medium); m_font.setPixelSize(DDECalendar::FontSizeSixteen); } void WeekRect::setWeek(const Qt::DayOfWeek &showWeek, const bool &showLine) { + // qCDebug(ClientLogger) << "WeekRect::setWeek, week:" << showWeek << "showLine:" << showLine; m_showWeek = showWeek; m_showLine = showLine; QLocale locale; @@ -128,11 +141,13 @@ void WeekRect::setWeek(const Qt::DayOfWeek &showWeek, const bool &showLine) void WeekRect::setRect(const QRectF &rectF) { + // qCDebug(ClientLogger) << "WeekRect::setRect, rect:" << rectF; m_rectF = rectF; } void WeekRect::paintRect(QPainter &painter) { + // qCDebug(ClientLogger) << "WeekRect::paintRect"; //绘制文字 painter.save(); painter.setFont(m_font); @@ -144,6 +159,7 @@ void WeekRect::paintRect(QPainter &painter) painter.drawText(m_rectF, Qt::AlignCenter, m_weekStr); painter.restore(); if (m_showLine) { + // qCDebug(ClientLogger) << "Drawing line for current week"; //绘制横线 painter.save(); painter.setPen(Qt::NoPen); @@ -156,10 +172,13 @@ void WeekRect::paintRect(QPainter &painter) void WeekRect::setTheMe(int type) { + qCDebug(ClientLogger) << "WeekRect::setTheMe, type:" << type; m_activeColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); if (type == 0 || type == 1) { + qCDebug(ClientLogger) << "Applying light theme"; m_testColor = "#6F6F6F"; } else { + qCDebug(ClientLogger) << "Applying dark theme"; m_testColor = "#C0C6D4"; } } diff --git a/calendar-client/src/widget/monthWidget/monthwindow.cpp b/calendar-client/src/widget/monthWidget/monthwindow.cpp index 444f6906e..12af397d1 100644 --- a/calendar-client/src/widget/monthWidget/monthwindow.cpp +++ b/calendar-client/src/widget/monthWidget/monthwindow.cpp @@ -9,6 +9,7 @@ #include "schedulesearchview.h" #include "todaybutton.h" #include "scheduledatamanage.h" +#include "commondef.h" #include @@ -19,6 +20,7 @@ DGUI_USE_NAMESPACE CMonthWindow::CMonthWindow(QWidget *parent) : CScheduleBaseWidget(parent) { + qCDebug(ClientLogger) << "CMonthWindow::CMonthWindow"; initUI(); initConnection(); setLunarVisible(m_calendarManager->getShowLunar()); @@ -26,6 +28,7 @@ CMonthWindow::CMonthWindow(QWidget *parent) CMonthWindow::~CMonthWindow() { + qCDebug(ClientLogger) << "CMonthWindow::~CMonthWindow"; disconnect(m_today, &CTodayButton::clicked, this, &CMonthWindow::slottoday); delete m_monthDayView; m_monthDayView = nullptr; @@ -39,6 +42,7 @@ CMonthWindow::~CMonthWindow() */ void CMonthWindow::setLunarVisible(bool state) { + qCDebug(ClientLogger) << "CMonthWindow::setLunarVisible, state:" << state; m_monthView->setLunarVisible(state); m_YearLunarLabel->setVisible(state); } @@ -49,9 +53,9 @@ void CMonthWindow::setLunarVisible(bool state) */ void CMonthWindow::setTheMe(int type) { + qCDebug(ClientLogger) << "CMonthWindow::setTheMe, type:" << type; if (type == 0 || type == 1) { - - + qCDebug(ClientLogger) << "Applying light theme"; DPalette pa = m_YearLabel->palette(); pa.setColor(DPalette::WindowText, QColor("#3B3B3B")); m_YearLabel->setPalette(pa); @@ -67,8 +71,7 @@ void CMonthWindow::setTheMe(int type) m_gridWidget->setPalette(gpa); m_gridWidget->setBackgroundRole(DPalette::Window); } else if (type == 2) { - - + qCDebug(ClientLogger) << "Applying dark theme"; DPalette pa = m_YearLabel->palette(); pa.setColor(DPalette::WindowText, QColor("#C0C6D4")); m_YearLabel->setPalette(pa); @@ -89,6 +92,7 @@ void CMonthWindow::setTheMe(int type) void CMonthWindow::setYearData() { + qCDebug(ClientLogger) << "CMonthWindow::setYearData"; if (getSelectDate() == getCurrendDateTime().date()) { m_today->setText(QCoreApplication::translate("today", "Today", "Today")); } else { @@ -107,6 +111,7 @@ void CMonthWindow::setYearData() */ void CMonthWindow::updateShowDate(const bool isUpdateBar) { + qCDebug(ClientLogger) << "CMonthWindow::updateShowDate, isUpdateBar:" << isUpdateBar; setYearData(); const QDate _selectDate = m_calendarManager->getSelectDate(); Qt::DayOfWeek _firstWeek = m_calendarManager->getFirstDayOfWeek(); @@ -120,6 +125,7 @@ void CMonthWindow::updateShowDate(const bool isUpdateBar) m_monthDayView->setSelectDate(_selectDate); //设置12个月份显示 //如果为中文环境则显示班休和农历信息 if (getShowLunar()) { + qCDebug(ClientLogger) << "Updating lunar info"; updateShowLunar(); } //切换月份须更新显示日程 @@ -132,6 +138,7 @@ void CMonthWindow::updateShowDate(const bool isUpdateBar) */ void CMonthWindow::setCurrentDateTime(const QDateTime ¤tDate) { + qCDebug(ClientLogger) << "CMonthWindow::setCurrentDateTime, date:" << currentDate; CScheduleBaseWidget::setCurrentDateTime(currentDate); //更新当前时间 m_monthView->setCurrentDate(currentDate.date()); @@ -142,6 +149,7 @@ void CMonthWindow::setCurrentDateTime(const QDateTime ¤tDate) */ void CMonthWindow::updateShowSchedule() { + qCDebug(ClientLogger) << "CMonthWindow::updateShowSchedule"; QMap map = gScheduleManager->getScheduleMap(m_startDate, m_stopDate); //因获取的日程中只有有日程的项,数量不等于开始时间到结束时间的天数, //但是视图显示要求数量为开始时间到结束时间的天数,所以在没有日程的时间中添加空日期列表 @@ -161,6 +169,7 @@ void CMonthWindow::updateShowSchedule() */ void CMonthWindow::updateShowLunar() { + qCDebug(ClientLogger) << "CMonthWindow::updateShowLunar"; getLunarInfo(); m_YearLunarLabel->setText(m_lunarYear); QMap _monthFestivalInfo = gLunarManager->getFestivalInfoDateMap(m_startDate, m_stopDate); @@ -174,6 +183,7 @@ void CMonthWindow::updateShowLunar() */ void CMonthWindow::updateSearchScheduleInfo() { + qCDebug(ClientLogger) << "CMonthWindow::updateSearchScheduleInfo"; //获取搜索日程信息 m_monthView->setSearchScheduleInfo(gScheduleManager->getAllSearchedScheduleList()); } @@ -184,6 +194,7 @@ void CMonthWindow::updateSearchScheduleInfo() */ void CMonthWindow::setSelectSearchScheduleInfo(const DSchedule::Ptr &info) { + qCDebug(ClientLogger) << "CMonthWindow::setSelectSearchScheduleInfo"; m_monthView->setSelectSchedule(info); } @@ -193,6 +204,7 @@ void CMonthWindow::setSelectSearchScheduleInfo(const DSchedule::Ptr &info) */ void CMonthWindow::setSearchWFlag(bool flag) { + qCDebug(ClientLogger) << "CMonthWindow::setSearchWFlag, flag:" << flag; m_searchFlag = flag; m_monthDayView->setSearchflag(flag); } @@ -202,6 +214,7 @@ void CMonthWindow::setSearchWFlag(bool flag) */ void CMonthWindow::deleteselectSchedule() { + qCDebug(ClientLogger) << "CMonthWindow::deleteselectSchedule"; m_monthView->deleteSelectSchedule(); } @@ -210,6 +223,7 @@ void CMonthWindow::deleteselectSchedule() */ void CMonthWindow::previousMonth() { + qCDebug(ClientLogger) << "CMonthWindow::previousMonth"; slideMonth(false); } @@ -218,6 +232,7 @@ void CMonthWindow::previousMonth() */ void CMonthWindow::nextMonth() { + qCDebug(ClientLogger) << "CMonthWindow::nextMonth"; slideMonth(true); } @@ -226,6 +241,7 @@ void CMonthWindow::nextMonth() */ void CMonthWindow::initUI() { + qCDebug(ClientLogger) << "CMonthWindow::initUI"; m_today = new CTodayButton; m_today->setText(QCoreApplication::translate("today", "Today", "Today")); m_today->setFixedSize(DDEMonthCalendar::MTodayWindth, DDEMonthCalendar::MTodayHeight); @@ -318,6 +334,7 @@ void CMonthWindow::initUI() */ void CMonthWindow::initConnection() { + qCDebug(ClientLogger) << "CMonthWindow::initConnection"; connect(m_today, &DPushButton::clicked, this, &CMonthWindow::slottoday); connect(m_monthDayView, &CMonthDayView::signalsSelectDate, this, &CMonthWindow::slotSetSelectDate); //双击时间修改选择时间和切换到日视图 @@ -335,10 +352,14 @@ void CMonthWindow::initConnection() */ void CMonthWindow::slideMonth(bool next) { + qCDebug(ClientLogger) << "CMonthWindow::slideMonth, next:" << next; slotScheduleHide(); if (m_isSwitchStatus) + { + qCDebug(ClientLogger) << "Already switching, returning"; return; + } m_isSwitchStatus = true; @@ -360,6 +381,7 @@ void CMonthWindow::slideMonth(bool next) */ void CMonthWindow::slotScheduleHide() { + qCDebug(ClientLogger) << "CMonthWindow::slotScheduleHide"; m_monthView->slotScheduleRemindWidget(false); } @@ -369,6 +391,7 @@ void CMonthWindow::slotScheduleHide() */ void CMonthWindow::slotAngleDelta(int delta) { + qCDebug(ClientLogger) << "CMonthWindow::slotAngleDelta, delta:" << delta; //拖拽时禁用 if (!m_monthView->isDragging()) { if (delta > 0) { @@ -387,6 +410,7 @@ void CMonthWindow::slotAngleDelta(int delta) */ void CMonthWindow::slotViewSelectDate(const QDate &date) { + qCDebug(ClientLogger) << "CMonthWindow::slotViewSelectDate, date:" << date; slotScheduleHide(); if (setSelectDate(date, true)) { //更新界面 @@ -397,11 +421,13 @@ void CMonthWindow::slotViewSelectDate(const QDate &date) void CMonthWindow::slotSwitchPrePage() { + qCDebug(ClientLogger) << "CMonthWindow::slotSwitchPrePage"; nextMonth(); } void CMonthWindow::slotSwitchNextPage() { + qCDebug(ClientLogger) << "CMonthWindow::slotSwitchNextPage"; previousMonth(); } @@ -411,6 +437,7 @@ void CMonthWindow::slotSwitchNextPage() */ void CMonthWindow::resizeEvent(QResizeEvent *event) { + // qCDebug(ClientLogger) << "CMonthWindow::resizeEvent"; qreal dw = width() * 0.5023 + 0.5; int dh = 36; m_monthDayView->setFixedSize(qRound(dw), dh); @@ -422,6 +449,7 @@ void CMonthWindow::resizeEvent(QResizeEvent *event) */ void CMonthWindow::slottoday() { + qCDebug(ClientLogger) << "CMonthWindow::slottoday"; //隐藏提示框 slotScheduleHide(); setSelectDate(getCurrendDateTime().date(), true); @@ -434,6 +462,7 @@ void CMonthWindow::slottoday() */ void CMonthWindow::slotSetSelectDate(const QDate &date) { + qCDebug(ClientLogger) << "CMonthWindow::slotSetSelectDate, date:" << date; slotScheduleHide(); if (setSelectDate(date, true)) { updateShowDate(false); diff --git a/calendar-client/src/widget/schedulesearchview.cpp b/calendar-client/src/widget/schedulesearchview.cpp index d69fc19fe..70b7e9646 100644 --- a/calendar-client/src/widget/schedulesearchview.cpp +++ b/calendar-client/src/widget/schedulesearchview.cpp @@ -12,6 +12,7 @@ #include "scheduledaterangeinfo.h" #include "calendarmanage.h" #include "calendarglobalenv.h" +#include "commondef.h" #include @@ -35,6 +36,7 @@ CScheduleSearchItem::CScheduleSearchItem(QWidget *parent) , m_rightMenu(new DMenu(this)) , m_timeFormat(CalendarManager::getInstance()->getTimeFormat()) { + qCDebug(ClientLogger) << "CScheduleSearchItem::CScheduleSearchItem"; //设置对象名称和辅助显示名称 this->setObjectName("CScheduleDataItem"); this->setAccessibleName("CScheduleDataItem"); @@ -57,11 +59,13 @@ CScheduleSearchItem::CScheduleSearchItem(QWidget *parent) void CScheduleSearchItem::setBackgroundColor(QColor color1) { + qCDebug(ClientLogger) << "CScheduleSearchItem::setBackgroundColor, color:" << color1; m_Backgroundcolor = color1; } void CScheduleSearchItem::setText(QColor tColor, QFont font) { + qCDebug(ClientLogger) << "CScheduleSearchItem::setText, color:" << tColor; m_tTextColor = tColor; m_tFont = font; //设置时间显示宽度 @@ -70,12 +74,14 @@ void CScheduleSearchItem::setText(QColor tColor, QFont font) void CScheduleSearchItem::setTimeC(QColor tColor, QFont font) { + qCDebug(ClientLogger) << "CScheduleSearchItem::setTimeC, color:" << tColor; m_timecolor = tColor; m_timefont = font; } void CScheduleSearchItem::setData(DSchedule::Ptr vScheduleInfo, QDate date) { + qCDebug(ClientLogger) << "CScheduleSearchItem::setData, date:" << date; m_ScheduleInfo = vScheduleInfo; m_date = date; update(); @@ -83,13 +89,16 @@ void CScheduleSearchItem::setData(DSchedule::Ptr vScheduleInfo, QDate date) void CScheduleSearchItem::setRoundtype(int rtype) { + qCDebug(ClientLogger) << "CScheduleSearchItem::setRoundtype, rtype:" << rtype; m_roundtype = rtype; update(); } void CScheduleSearchItem::setTheMe(int type) { + qCDebug(ClientLogger) << "CScheduleSearchItem::setTheMe, type:" << type; if (type == 2) { + qCDebug(ClientLogger) << "Applying dark theme"; m_presscolor.background = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); m_presscolor.background.setAlphaF(1); m_presscolor.timeColor = "#FFFFFF"; @@ -104,6 +113,7 @@ void CScheduleSearchItem::setTheMe(int type) m_hovercolor.textColor = "#C0C6D4"; m_hovercolor.textColor.setAlphaF(1); } else { + qCDebug(ClientLogger) << "Applying light theme"; m_presscolor.background = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); m_presscolor.background.setAlphaF(1); m_presscolor.timeColor = "#FFFFFF"; @@ -125,6 +135,7 @@ void CScheduleSearchItem::setTheMe(int type) */ void CScheduleSearchItem::setDurationSize(QFont font) { + qCDebug(ClientLogger) << "CScheduleSearchItem::setDurationSize"; QFontMetrics fm1(font); QString currentTimeStr = QTime::currentTime().toString("hh:mm"); //设置时间显示最大宽度 @@ -132,6 +143,7 @@ void CScheduleSearchItem::setDurationSize(QFont font) } void CScheduleSearchItem::slotEdit() { + qCDebug(ClientLogger) << "CScheduleSearchItem::slotEdit"; CScheduleDlg dlg(0, this); dlg.setData(m_ScheduleInfo); dlg.exec(); @@ -139,13 +151,16 @@ void CScheduleSearchItem::slotEdit() void CScheduleSearchItem::slotDelete() { + qCDebug(ClientLogger) << "CScheduleSearchItem::slotDelete"; //删除日程 CScheduleOperation _scheduleOperation(m_ScheduleInfo->scheduleTypeID(), this); bool _isDelete = _scheduleOperation.deleteSchedule(m_ScheduleInfo); //删除日程后,将焦点设置给父类 if (_isDelete) { + qCDebug(ClientLogger) << "Schedule deleted, setting focus to parent"; parentWidget()->setFocus(Qt::TabFocusReason); } else { + qCDebug(ClientLogger) << "Failed to delete schedule, keeping focus"; this->setFocus(); } } @@ -155,6 +170,7 @@ void CScheduleSearchItem::slotDelete() */ void CScheduleSearchItem::slotTimeFormatChanged(int value) { + qCDebug(ClientLogger) << "CScheduleSearchItem::slotTimeFormatChanged, value:" << value; if (value) { m_timeFormat = "hh:mm"; } else { @@ -165,11 +181,14 @@ void CScheduleSearchItem::slotTimeFormatChanged(int value) void CScheduleSearchItem::slotSchotCutClicked() { + qCDebug(ClientLogger) << "CScheduleSearchItem::slotSchotCutClicked"; //选中该item时才可以使用快捷键 if (m_tabFocus) { //节日日程不能使用 - if (CScheduleOperation::isFestival(m_ScheduleInfo)) + if (CScheduleOperation::isFestival(m_ScheduleInfo)) { + qCDebug(ClientLogger) << "Festival schedule, cannot use shortcut"; return; + } m_rightMenu->clear(); m_rightMenu->addAction(m_editAction); m_rightMenu->addAction(m_deleteAction); @@ -183,6 +202,7 @@ void CScheduleSearchItem::slotSchotCutClicked() void CScheduleSearchItem::paintEvent(QPaintEvent *e) { + // qCDebug(ClientLogger) << "CScheduleSearchItem::paintEvent"; Q_UNUSED(e); int labelRightX = width() - 2; //绘制区域x方向右边界坐标点 int labelBottomY = height(); //绘制区域y方向下边界坐标点 @@ -324,10 +344,13 @@ void CScheduleSearchItem::paintEvent(QPaintEvent *e) } void CScheduleSearchItem::contextMenuEvent(QContextMenuEvent *event) { + qCDebug(ClientLogger) << "CScheduleSearchItem::contextMenuEvent"; Q_UNUSED(event); //判断是否为节假日日程 - if (CScheduleOperation::isFestival(m_ScheduleInfo)) + if (CScheduleOperation::isFestival(m_ScheduleInfo)) { + qCDebug(ClientLogger) << "Festival schedule, no context menu"; return; + } //在有些环境中弹出右击菜单不会触发leaveEvent,主动更新leave对应的事件处理 m_mouseStatus = M_NONE; update(); @@ -343,6 +366,7 @@ void CScheduleSearchItem::contextMenuEvent(QContextMenuEvent *event) void CScheduleSearchItem::mouseDoubleClickEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "CScheduleSearchItem::mouseDoubleClickEvent"; Q_UNUSED(event); CMyScheduleView dlg(m_ScheduleInfo, this); dlg.exec(); @@ -350,6 +374,7 @@ void CScheduleSearchItem::mouseDoubleClickEvent(QMouseEvent *event) void CScheduleSearchItem::mousePressEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "CScheduleSearchItem::mousePressEvent"; //鼠标点击取消焦点显示 m_tabFocus = false; if (event->button() == Qt::LeftButton) { @@ -364,6 +389,7 @@ void CScheduleSearchItem::mousePressEvent(QMouseEvent *event) void CScheduleSearchItem::mouseReleaseEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "CScheduleSearchItem::mouseReleaseEvent"; if (event->button() == Qt::LeftButton) { m_mouseStatus = M_HOVER; update(); @@ -376,6 +402,7 @@ void CScheduleSearchItem::enterEvent(QEnterEvent *event) void CScheduleSearchItem::enterEvent(QEvent *event) #endif { + // qCDebug(ClientLogger) << "CScheduleSearchItem::enterEvent"; DLabel::enterEvent(event); m_mouseStatus = M_HOVER; update(); @@ -383,6 +410,7 @@ void CScheduleSearchItem::enterEvent(QEvent *event) void CScheduleSearchItem::leaveEvent(QEvent *event) { + // qCDebug(ClientLogger) << "CScheduleSearchItem::leaveEvent"; DLabel::leaveEvent(event); m_mouseStatus = M_NONE; update(); @@ -390,6 +418,7 @@ void CScheduleSearchItem::leaveEvent(QEvent *event) bool CScheduleSearchItem::eventFilter(QObject *o, QEvent *e) { + // qCDebug(ClientLogger) << "CScheduleSearchItem::eventFilter, event type:" << e->type(); Q_UNUSED(o); if (e->type() == QEvent::MouseButtonPress) { @@ -404,6 +433,7 @@ bool CScheduleSearchItem::eventFilter(QObject *o, QEvent *e) void CScheduleSearchItem::focusInEvent(QFocusEvent *e) { + // qCDebug(ClientLogger) << "CScheduleSearchItem::focusInEvent, reason:" << e->reason(); if (e->reason() == Qt::TabFocusReason) { //注册为键盘操作 if (!CalendarGlobalEnv::getGlobalEnv()->registerKey("SearchItemEvent", "Keyboard")) { @@ -421,6 +451,7 @@ void CScheduleSearchItem::focusInEvent(QFocusEvent *e) void CScheduleSearchItem::focusOutEvent(QFocusEvent *e) { + // qCDebug(ClientLogger) << "CScheduleSearchItem::focusOutEvent, reason:" << e->reason(); //只针对tab的情况生效 if (e->reason() == Qt::TabFocusReason){ emit signalSelectCurrentItem(this, true); @@ -432,6 +463,7 @@ void CScheduleSearchItem::focusOutEvent(QFocusEvent *e) void CScheduleSearchItem::keyPressEvent(QKeyEvent *event) { + // qCDebug(ClientLogger) << "CScheduleSearchItem::keyPressEvent, key:" << event->key(); //回车显示我的日程详情 if (event->key() == Qt::Key_Return) { CMyScheduleView dlg(m_ScheduleInfo, this); @@ -447,6 +479,7 @@ void CScheduleSearchItem::keyPressEvent(QKeyEvent *event) CScheduleSearchView::CScheduleSearchView(QWidget *parent) : DWidget(parent) { + qCDebug(ClientLogger) << "CScheduleSearchView::CScheduleSearchView"; QVBoxLayout *layout = new QVBoxLayout; layout->setSpacing(0); m_gradientItemList = new CScheduleListWidget(parent); @@ -467,6 +500,7 @@ CScheduleSearchView::CScheduleSearchView(QWidget *parent) CScheduleSearchView::~CScheduleSearchView() { + qCDebug(ClientLogger) << "CScheduleSearchView::~CScheduleSearchView"; for (int i = 0; i < m_gradientItemList->count(); i++) { QListWidgetItem *item11 = m_gradientItemList->takeItem(i); m_gradientItemList->removeItemWidget(item11); @@ -478,7 +512,9 @@ CScheduleSearchView::~CScheduleSearchView() void CScheduleSearchView::setTheMe(int type) { + qCDebug(ClientLogger) << "CScheduleSearchView::setTheMe, type:" << type; if (type == 0 || type == 1) { + qCDebug(ClientLogger) << "Applying light theme"; m_bBackgroundcolor = "#000000"; m_bBackgroundcolor.setAlphaF(0.03); m_btimecolor = "#526A7F"; @@ -486,6 +522,7 @@ void CScheduleSearchView::setTheMe(int type) m_lBackgroundcolor = Qt::white; m_lTextColor = "#001A2E"; } else if (type == 2) { + qCDebug(ClientLogger) << "Applying dark theme"; m_bBackgroundcolor = "#FFFFFF"; m_bBackgroundcolor.setAlphaF(0.05); m_btimecolor = "#6D7C88"; @@ -502,6 +539,7 @@ void CScheduleSearchView::setTheMe(int type) */ void CScheduleSearchView::clearSearch() { + qCDebug(ClientLogger) << "CScheduleSearchView::clearSearch"; m_searchStr.clear(); m_vlistData.clear(); m_scheduleSearchItem.clear(); @@ -522,6 +560,7 @@ void CScheduleSearchView::clearSearch() void CScheduleSearchView::setMaxWidth(const int w) { + // qCDebug(ClientLogger) << "CScheduleSearchView::setMaxWidth, width:" << w; m_maxWidth = w; } @@ -530,6 +569,7 @@ void CScheduleSearchView::setMaxWidth(const int w) */ bool CScheduleSearchView::getHasScheduleShow() { + // qCDebug(ClientLogger) << "CScheduleSearchView::getHasScheduleShow, hasScheduleShow:" << hasScheduleShow; return hasScheduleShow; } @@ -538,6 +578,7 @@ bool CScheduleSearchView::getHasScheduleShow() */ bool CScheduleSearchView::getScheduleStatus() { + // qCDebug(ClientLogger) << "CScheduleSearchView::getScheduleStatus"; return m_scheduleSearchItem.contains(m_selectItem); } @@ -546,9 +587,11 @@ bool CScheduleSearchView::getScheduleStatus() */ void CScheduleSearchView::deleteSchedule() { + qCDebug(ClientLogger) << "CScheduleSearchView::deleteSchedule"; currentDItemIndex = m_scheduleSearchItem.indexOf(m_selectItem); //如果存在该item且为节日日程不可操作 if (currentDItemIndex >= 0 && !CScheduleOperation::isFestival(m_selectItem->getData())) { + qCDebug(ClientLogger) << "Deleting item at index:" << currentDItemIndex; m_selectItem->slotDelete(); } } @@ -558,6 +601,7 @@ void CScheduleSearchView::deleteSchedule() */ void CScheduleSearchView::updateDateShow() { + qCDebug(ClientLogger) << "CScheduleSearchView::updateDateShow"; m_currentItem = nullptr; //是否搜索到日程标志 hasScheduleShow = true; @@ -590,6 +634,7 @@ void CScheduleSearchView::updateDateShow() } } if (_showInfo.size() > 0) { + // qCDebug(ClientLogger) << "Found" << _showInfo.size() << "schedules for date" << _iterator.key(); //获取跟当前时间最近的日程时间 if (d < offset) { offset = d; @@ -622,6 +667,7 @@ void CScheduleSearchView::updateDateShow() } } if (m_gradientItemList->count() == 0) { + qCDebug(ClientLogger) << "No search results"; hasScheduleShow = false; QListWidgetItem *listItem = new QListWidgetItem(m_gradientItemList); DLabel *gwi = new DLabel(); @@ -659,6 +705,7 @@ void CScheduleSearchView::updateDateShow() } if (currentDItemIndex >= 0 && m_scheduleSearchItem.size() > 0) { + qCDebug(ClientLogger) << "Restoring focus after deletion"; //删除日程后,重新设置焦点 if (currentDItemIndex < m_scheduleSearchItem.size()) { m_scheduleSearchItem.at(currentDItemIndex)->setFocus(Qt::TabFocusReason); @@ -673,6 +720,7 @@ void CScheduleSearchView::updateDateShow() void CScheduleSearchView::createItemWidget(DSchedule::Ptr info, QDate date, int rtype) { + qCDebug(ClientLogger) << "CScheduleSearchView::createItemWidget (schedule), date:" << date << "rtype:" << rtype; DSchedule::Ptr &gd = info; CScheduleSearchItem *gwi = new CScheduleSearchItem(this); @@ -702,6 +750,7 @@ void CScheduleSearchView::createItemWidget(DSchedule::Ptr info, QDate date, int QListWidgetItem *CScheduleSearchView::createItemWidget(QDate date) { + qCDebug(ClientLogger) << "CScheduleSearchView::createItemWidget (date), date:" << date; CScheduleSearchDateItem *gwi = new CScheduleSearchDateItem(); QFont font; font.setWeight(QFont::Medium); @@ -733,6 +782,7 @@ QListWidgetItem *CScheduleSearchView::createItemWidget(QDate date) */ void CScheduleSearchView::slotsetSearch(QString str) { + qCDebug(ClientLogger) << "CScheduleSearchView::slotsetSearch, search string:" << str; if (str.isEmpty()) return; m_searchStr = str; @@ -740,6 +790,7 @@ void CScheduleSearchView::slotsetSearch(QString str) QDateTime bDate = date.addMonths(-6); if (bDate.date() < QDate(1900, 1, 1)) { + qCWarning(ClientLogger) << "Start date is before 1900, adjusting to 1900-01-01"; bDate.setDate(QDate(1900, 1, 1)); } QDateTime eDate = date.addMonths(6); @@ -749,12 +800,14 @@ void CScheduleSearchView::slotsetSearch(QString str) void CScheduleSearchView::slotScearedScheduleUpdate() { + qCDebug(ClientLogger) << "CScheduleSearchView::slotScearedScheduleUpdate"; m_vlistData = gScheduleManager->getAllSearchedScheduleMap(); updateDateShow(); } void CScheduleSearchView::slotSelectSchedule(const DSchedule::Ptr &scheduleInfo) { + qCDebug(ClientLogger) << "CScheduleSearchView::slotSelectSchedule"; emit signalSelectSchedule(scheduleInfo); } @@ -763,7 +816,9 @@ void CScheduleSearchView::slotSelectSchedule(const DSchedule::Ptr &scheduleInfo) */ void CScheduleSearchView::updateSearch() { + qCDebug(ClientLogger) << "CScheduleSearchView::updateSearch"; if (isVisible()) { + qCDebug(ClientLogger) << "View is visible, performing search"; slotsetSearch(m_searchStr); } } @@ -775,6 +830,7 @@ void CScheduleSearchView::updateSearch() */ void CScheduleSearchView::slotSelectCurrentItem(CScheduleSearchItem *item, bool itemFocusOut) { + qCDebug(ClientLogger) << "CScheduleSearchView::slotSelectCurrentItem, itemFocusOut:" << itemFocusOut; for (int i = 0; i < m_gradientItemList->count(); i++) { QListWidgetItem *cItem = m_gradientItemList->item(i); if (item == m_gradientItemList->itemWidget(cItem)) { @@ -783,6 +839,7 @@ void CScheduleSearchView::slotSelectCurrentItem(CScheduleSearchItem *item, bool m_gradientItemList->scrollToItem(cItem, QAbstractItemView::PositionAtTop); if (i == m_gradientItemList->count() - 1 && itemFocusOut && !keyPressUP) { //最后一个item,发送信号将焦点传递给搜索框 + qCDebug(ClientLogger) << "Last item focus out, emitting signal"; emit signalSelectCurrentItem(); } } @@ -796,6 +853,7 @@ void CScheduleSearchView::slotSelectCurrentItem(CScheduleSearchItem *item, bool */ void CScheduleSearchView::slotListWidgetClicked() { + qCDebug(ClientLogger) << "CScheduleSearchView::slotListWidgetClicked"; //取消当前tab选中item m_selectItem = nullptr; emit signalScheduleHide(); @@ -803,6 +861,7 @@ void CScheduleSearchView::slotListWidgetClicked() void CScheduleSearchView::resizeEvent(QResizeEvent *event) { + // qCDebug(ClientLogger) << "CScheduleSearchView::resizeEvent"; for (int i = 0; i < m_gradientItemList->count(); i++) { QListWidgetItem *item11 = m_gradientItemList->item(i); item11->setSizeHint(QSize(m_maxWidth - 5, 36)); //每次改变Item的高度 @@ -827,11 +886,13 @@ void CScheduleSearchView::resizeEvent(QResizeEvent *event) void CScheduleSearchView::mousePressEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "CScheduleSearchView::mousePressEvent"; DWidget::mousePressEvent(event); } void CScheduleSearchView::keyPressEvent(QKeyEvent *event) { + // qCDebug(ClientLogger) << "CScheduleSearchView::keyPressEvent, key:" << event->key(); if (event->key() == Qt::Key_Up) { //上键,选中上一个item keyPressUP = true; @@ -850,6 +911,7 @@ void CScheduleSearchView::keyPressEvent(QKeyEvent *event) void CScheduleSearchView::focusInEvent(QFocusEvent *e) { + // qCDebug(ClientLogger) << "CScheduleSearchView::focusInEvent, reason:" << e->reason(); DWidget::focusInEvent(e); if (e->reason() == Qt::TabFocusReason) { if (m_scheduleSearchItem.size() > 0) { @@ -861,6 +923,7 @@ void CScheduleSearchView::focusInEvent(QFocusEvent *e) CScheduleSearchDateItem::CScheduleSearchDateItem(QWidget *parent) : DLabel(parent) { + // qCDebug(ClientLogger) << "CScheduleSearchDateItem::CScheduleSearchDateItem"; //设置对象名称和辅助显示名称 this->setObjectName("CScheduleDateItem"); this->setAccessibleName("CScheduleDateItem"); @@ -869,22 +932,26 @@ CScheduleSearchDateItem::CScheduleSearchDateItem(QWidget *parent) void CScheduleSearchDateItem::setBackgroundColor(QColor color1) { + // qCDebug(ClientLogger) << "CScheduleSearchDateItem::setBackgroundColor, color:" << color1; m_Backgroundcolor = color1; } void CScheduleSearchDateItem::setText(QColor tColor, QFont font) { + // qCDebug(ClientLogger) << "CScheduleSearchDateItem::setText, color:" << tColor; m_textcolor = tColor; m_font = font; } void CScheduleSearchDateItem::setDate(QDate date) { + // qCDebug(ClientLogger) << "CScheduleSearchDateItem::setDate, date:" << date; m_date = date; } void CScheduleSearchDateItem::paintEvent(QPaintEvent *e) { + // qCDebug(ClientLogger) << "CScheduleSearchDateItem::paintEvent"; Q_UNUSED(e); int labelwidth = width(); int labelheight = height(); @@ -912,6 +979,7 @@ void CScheduleSearchDateItem::paintEvent(QPaintEvent *e) void CScheduleSearchDateItem::mousePressEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "CScheduleSearchDateItem::mousePressEvent"; emit signalLabelScheduleHide(); DLabel::mousePressEvent(event); } @@ -919,6 +987,7 @@ void CScheduleSearchDateItem::mousePressEvent(QMouseEvent *event) CScheduleListWidget::CScheduleListWidget(QWidget *parent) : DListWidget(parent) { + qCDebug(ClientLogger) << "CScheduleListWidget::CScheduleListWidget"; //设置对象名称和辅助显示名称 this->setObjectName("CScheduleListWidget"); this->setAccessibleName("CScheduleListWidget"); @@ -937,16 +1006,19 @@ CScheduleListWidget::CScheduleListWidget(QWidget *parent) CScheduleListWidget::~CScheduleListWidget() { + qCDebug(ClientLogger) << "CScheduleListWidget::~CScheduleListWidget"; } void CScheduleListWidget::mousePressEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "CScheduleListWidget::mousePressEvent"; DListWidget::mousePressEvent(event); emit signalListWidgetClicked(); } void CScheduleListWidget::paintEvent(QPaintEvent *e) { + // qCDebug(ClientLogger) << "CScheduleListWidget::paintEvent"; DListWidget::paintEvent(e); QPainter painter(this->viewport()); painter.setRenderHint(QPainter::Antialiasing); diff --git a/calendar-client/src/widget/settingWidget/settingwidgets.cpp b/calendar-client/src/widget/settingWidget/settingwidgets.cpp index 1a1a710da..26f2379aa 100644 --- a/calendar-client/src/widget/settingWidget/settingwidgets.cpp +++ b/calendar-client/src/widget/settingWidget/settingwidgets.cpp @@ -6,6 +6,7 @@ #include "accountmanager.h" #include "calendarmanage.h" #include "units.h" +#include "commondef.h" #include #include @@ -18,12 +19,14 @@ using namespace SettingWidget; SettingWidgets::SettingWidgets(QWidget *parent) : QObject(parent) { + qCDebug(ClientLogger) << "SettingWidgets constructed"; } SyncTagRadioButton::SyncTagRadioButton(QWidget *parent) : QWidget(parent) { + qCDebug(ClientLogger) << "SyncTagRadioButton constructed"; } bool SyncTagRadioButton::isChecked() @@ -37,6 +40,7 @@ void SyncTagRadioButton::setChecked(bool checked) return; m_checked = checked; + qCDebug(ClientLogger) << "SyncTagRadioButton checked state changed to:" << checked; update(); } @@ -53,49 +57,69 @@ void SyncTagRadioButton::paintEvent(QPaintEvent *event) void SyncTagRadioButton::mouseReleaseEvent(QMouseEvent *event) { QWidget::mouseReleaseEvent(event); + // qCDebug(ClientLogger) << "SyncTagRadioButton mouse released, toggling state"; setChecked(!m_checked); emit clicked(isChecked()); } void CalendarSettingSettings::removeGroup(const QString &groupName, const QString &groupName2) { + qCDebug(ClientLogger) << "Removing group:" << groupName << "and subgroup:" << groupName2; int index = this->indexOf(*this, groupName); - if (index < 0) + if (index < 0) { + qCDebug(ClientLogger) << "Group not found:" << groupName; return; + } CalendarSettingGroups &groups = this->operator[](index)._groups; { int index = indexOf(groups, groupName2); - if (index < 0) + if (index < 0) { + qCDebug(ClientLogger) << "Subgroup not found:" << groupName2; return; + } groups.removeAt(index); + qCDebug(ClientLogger) << "Subgroup removed:" << groupName2; } if (groups.isEmpty()) { this->removeAt(index); + qCDebug(ClientLogger) << "Group also removed (empty):" << groupName; } } void CalendarSettingSettings::removeGroup(const QString &groupName) { + qCDebug(ClientLogger) << "Removing group:" << groupName; int index = this->indexOf(*this, groupName); - if (index < 0) + if (index < 0) { + qCDebug(ClientLogger) << "Group not found:" << groupName; return; + } this->removeAt(index); + qCDebug(ClientLogger) << "Group removed:" << groupName; } int CalendarSettingSettings::indexOf(const CalendarSettingGroups &groups, const QString groupName) { + qCDebug(ClientLogger) << "Searching for subgroup:" << groupName; for (int k = 0; k < groups.count(); k++) { - if (groups[k]._key == groupName) + if (groups[k]._key == groupName) { + qCDebug(ClientLogger) << "Subgroup found:" << groupName; return k; + } } + qCDebug(ClientLogger) << "Subgroup not found:" << groupName; return -1; } int CalendarSettingSettings::indexOf(const CalendarSettingSettings &groups, const QString groupName) { + qCDebug(ClientLogger) << "Searching for group:" << groupName; for (int k = 0; k < groups.count(); k++) { - if (groups[k]._key == groupName) + if (groups[k]._key == groupName) { + qCDebug(ClientLogger) << "Group found:" << groupName; return k; + } } + qCDebug(ClientLogger) << "Group not found:" << groupName; return -1; } diff --git a/calendar-client/src/widget/settingWidget/userloginwidget.cpp b/calendar-client/src/widget/settingWidget/userloginwidget.cpp index 6333c38db..3d062320d 100644 --- a/calendar-client/src/widget/settingWidget/userloginwidget.cpp +++ b/calendar-client/src/widget/settingWidget/userloginwidget.cpp @@ -5,6 +5,7 @@ #include "userloginwidget.h" #include "accountmanager.h" #include "doanetworkdbus.h" +#include "commondef.h" #include #include #include @@ -15,6 +16,7 @@ UserloginWidget::UserloginWidget(QWidget *parent) : QWidget(parent) , m_loginStatus(false) { + qCDebug(ClientLogger) << "UserloginWidget constructed"; initView(); initConnect(); slotAccountUpdate(); @@ -22,11 +24,12 @@ UserloginWidget::UserloginWidget(QWidget *parent) UserloginWidget::~UserloginWidget() { - + qCDebug(ClientLogger) << "UserloginWidget destroyed"; } void UserloginWidget::initView() { + qCDebug(ClientLogger) << "Initializing UserloginWidget view"; m_userNameLabel = new DLabel(); m_userNameLabel->setElideMode(Qt::ElideMiddle); m_userNameLabel->setTextFormat(Qt::PlainText); @@ -53,9 +56,11 @@ void UserloginWidget::initView() this->layout()->setAlignment(Qt::AlignLeft); m_ptrDoaNetwork = new DOANetWorkDBus(this); if (m_ptrDoaNetwork->getNetWorkState() == DOANetWorkDBus::NetWorkState::Active) { + qCDebug(ClientLogger) << "Network is active, enabling login/logout buttons"; m_buttonLoginOut->setEnabled(true); m_buttonLogin->setEnabled(true); } else { + qCDebug(ClientLogger) << "Network is not active, disabling login/logout buttons"; m_buttonLogin->setEnabled(false); m_buttonLoginOut->setEnabled(false); } @@ -65,6 +70,7 @@ void UserloginWidget::initView() void UserloginWidget::initConnect() { + qCDebug(ClientLogger) << "Initializing UserloginWidget connections"; connect(m_buttonLogin, &QPushButton::clicked, this, &UserloginWidget::slotLoginBtnClicked); connect(m_buttonLoginOut, &QPushButton::clicked, this, &UserloginWidget::slotLogoutBtnClicked); connect(gAccountManager, &AccountManager::signalAccountUpdate, this, &UserloginWidget::slotAccountUpdate); @@ -74,6 +80,7 @@ void UserloginWidget::initConnect() QPixmap UserloginWidget::pixmapToRound(const QPixmap &src, int radius) { + qCDebug(ClientLogger) << "Converting pixmap to round with radius:" << radius; QSize size(2 * radius, 2 * radius); QPixmap pic(size); pic.fill(Qt::transparent); @@ -93,10 +100,13 @@ QPixmap UserloginWidget::pixmapToRound(const QPixmap &src, int radius) void UserloginWidget::slotNetworkStateChange(DOANetWorkDBus::NetWorkState state) { + qCDebug(ClientLogger) << "Network state changed to:" << static_cast(state); if (DOANetWorkDBus::NetWorkState::Disconnect == state) { + qCDebug(ClientLogger) << "Network disconnected, disabling login/logout buttons"; m_buttonLogin->setEnabled(false); m_buttonLoginOut->setEnabled(false); } else if (DOANetWorkDBus::NetWorkState::Active == state) { + qCDebug(ClientLogger) << "Network active, enabling login/logout buttons"; m_buttonLoginOut->setEnabled(true); m_buttonLogin->setEnabled(true); } @@ -104,18 +114,22 @@ void UserloginWidget::slotNetworkStateChange(DOANetWorkDBus::NetWorkState state) void UserloginWidget::slotLoginBtnClicked() { + qCDebug(ClientLogger) << "Login button clicked, initiating login"; gAccountManager->login(); } void UserloginWidget::slotLogoutBtnClicked() { + qCDebug(ClientLogger) << "Logout button clicked, initiating logout"; gAccountManager->loginout(); } void UserloginWidget::slotAccountUpdate() { + qCDebug(ClientLogger) << "Account update received"; if (gUosAccountItem) { //账户为登录状态 + qCDebug(ClientLogger) << "Account is logged in"; m_buttonLogin->hide(); m_buttonLoginOut->show(); DAccount::Ptr account = gUosAccountItem->getAccount(); @@ -125,6 +139,7 @@ void UserloginWidget::slotAccountUpdate() m_networkManager->get(QNetworkRequest(account->avatar())); } else { //账户为未登录状态 + qCDebug(ClientLogger) << "Account is logged out"; m_buttonLoginOut->hide(); m_buttonLogin->show(); m_userNameLabel->setText(""); @@ -135,22 +150,27 @@ void UserloginWidget::slotAccountUpdate() void UserloginWidget::slotReplyPixmapLoad(QNetworkReply *reply) { + qCDebug(ClientLogger) << "Network reply received for avatar"; QPixmap pixmap; //因自定义头像路径拿到的不是真实路径,需要从请求头中拿取到真实路径再次发起请求 QUrl url = reply->header(QNetworkRequest::LocationHeader).toUrl(); if (url.url().isEmpty()) { + qCDebug(ClientLogger) << "Using direct avatar data from reply"; pixmap.loadFromData(reply->readAll()); } else { + qCDebug(ClientLogger) << "Found redirect URL for avatar:" << url.toString(); m_networkManager->get(QNetworkRequest(url.url())); } if (!pixmap.isNull()) { + qCDebug(ClientLogger) << "Avatar loaded successfully, updating UI"; m_buttonImg->setIcon(pixmapToRound(pixmap, 32)); } } QPair UserloginWidget::createloginButton(QObject *obj) { + qCDebug(ClientLogger) << "Creating login button for settings"; auto option = qobject_cast(obj); QPair optionWidget = DSettingsWidgetFactory::createStandardItem(QByteArray(), option, new UserloginWidget()); diff --git a/calendar-client/src/widget/sidebarWidget/sidebarcalendarwidget.cpp b/calendar-client/src/widget/sidebarWidget/sidebarcalendarwidget.cpp index 571d7c7f7..e789fbf41 100644 --- a/calendar-client/src/widget/sidebarWidget/sidebarcalendarwidget.cpp +++ b/calendar-client/src/widget/sidebarWidget/sidebarcalendarwidget.cpp @@ -6,6 +6,7 @@ #include "cschedulebasewidget.h" #include "constants.h" #include "units.h" +#include "commondef.h" #include #include @@ -16,6 +17,7 @@ QDate SidebarCalendarKeyButton::m_displayedMonth = QDate(); SidebarCalendarWidget::SidebarCalendarWidget(QWidget *parent) : QWidget(parent) { + qCDebug(ClientLogger) << "SidebarCalendarWidget constructed"; initView(); initConnection(); initData(); @@ -23,6 +25,7 @@ SidebarCalendarWidget::SidebarCalendarWidget(QWidget *parent) : QWidget(parent) void SidebarCalendarWidget::initView() { + qCDebug(ClientLogger) << "Initializing SidebarCalendarWidget view"; m_dateLabel = new QLabel(); QFont font = m_dateLabel->font(); font.setPixelSize(DDECalendar::FontSizeTwelve); @@ -62,6 +65,7 @@ void SidebarCalendarWidget::initView() m_keyLayout->setSpacing(0); m_keyWidget->setLayout(m_keyLayout); //循坏实例化6*7个日期按键 + qCDebug(ClientLogger) << "Creating date buttons for calendar"; for (int i = 0; i < 42; ++i) { SidebarCalendarKeyButton *button = new SidebarCalendarKeyButton(); button->setFocusPolicy(Qt::NoFocus); @@ -85,6 +89,7 @@ void SidebarCalendarWidget::initView() */ void SidebarCalendarWidget::initConnection() { + qCDebug(ClientLogger) << "Initializing SidebarCalendarWidget connections"; connect(m_nextPage, &QPushButton::clicked, this, &SidebarCalendarWidget::slotNextPageClicked); connect(m_previousPage, &QPushButton::clicked, this, &SidebarCalendarWidget::slotPreviousPageClicked); connect(CalendarManager::getInstance(), &CalendarManager::sigNotifySidebarFirstDayChanged, this, &SidebarCalendarWidget::slotFirstDayChanged); @@ -96,6 +101,7 @@ void SidebarCalendarWidget::initConnection() */ void SidebarCalendarWidget::initData() { + qCDebug(ClientLogger) << "Initializing SidebarCalendarWidget data"; m_firstday = CalendarManager::getInstance()->getFirstDayOfWeek(); QDate date = QDate::currentDate(); setDate(date); @@ -108,6 +114,7 @@ void SidebarCalendarWidget::initData() */ void SidebarCalendarWidget::setDate(QDate& date) { + qCDebug(ClientLogger) << "Setting sidebar calendar date to:" << date.toString(); SidebarCalendarKeyButton::setSelectedDate(date); setKeyDate(date); } @@ -119,7 +126,9 @@ void SidebarCalendarWidget::setDate(QDate& date) */ void SidebarCalendarWidget::setKeyDate(QDate date) { + qCDebug(ClientLogger) << "Setting key date for calendar display to:" << date.toString(); if(!withinTimeFrame(date)){ + qCDebug(ClientLogger) << "Date" << date.toString() << "not within time frame, ignoring"; return; } QString fd = ""; @@ -133,6 +142,7 @@ void SidebarCalendarWidget::setKeyDate(QDate date) int day = date.dayOfWeek(); //计算当前月日历第一天该显示的时间 date = date.addDays(-(day - m_firstday + 7) % 7); + qCDebug(ClientLogger) << "First date to display in calendar grid:" << date.toString(); for (SidebarCalendarKeyButton* btn : m_keyButtonList) { btn->setDate(date); date = date.addDays(1); @@ -148,14 +158,18 @@ void SidebarCalendarWidget::setKeyDate(QDate date) void SidebarCalendarWidget::slotKeyButtonClicked(SidebarCalendarKeyButton* keyButton) { QDate date = keyButton->getSelectedDate(); + qCDebug(ClientLogger) << "Date button clicked, selected date:" << date.toString(); if(!withinTimeFrame(date)){ + qCDebug(ClientLogger) << "Selected date not within time frame, ignoring"; return; } if (date.year() ==keyButton->getDisplayedMonth().year() && date.month() == keyButton->getDisplayedMonth().month()) { //未切换月份,只刷新界面显示 + qCDebug(ClientLogger) << "Date is in current month, only updating display"; update(); } else { //已切换月份,重新设置选中的日期 + qCDebug(ClientLogger) << "Date is in different month, changing displayed month"; setDate(date); } CScheduleBaseWidget::setSelectDate(date); @@ -167,8 +181,10 @@ void SidebarCalendarWidget::slotKeyButtonClicked(SidebarCalendarKeyButton* keyBu */ void SidebarCalendarWidget::slotNextPageClicked() { + qCDebug(ClientLogger) << "Next month button clicked"; //设置显示月份日期 QDate date = SidebarCalendarKeyButton::getDisplayedMonth().addMonths(+1); + qCDebug(ClientLogger) << "Changing displayed month to:" << date.toString("yyyy-MM"); //设置显示的日期范围 setKeyDate(date); } @@ -179,14 +195,17 @@ void SidebarCalendarWidget::slotNextPageClicked() */ void SidebarCalendarWidget::slotPreviousPageClicked() { + qCDebug(ClientLogger) << "Previous month button clicked"; //设置显示月份日期 QDate date = SidebarCalendarKeyButton::getDisplayedMonth().addMonths(-1); + qCDebug(ClientLogger) << "Changing displayed month to:" << date.toString("yyyy-MM"); //设置显示的日期范围 setKeyDate(date); } void SidebarCalendarWidget::slotFirstDayChanged(int value) { + qCDebug(ClientLogger) << "First day of week changed to:" << value; m_firstday = value; setKeyDate(SidebarCalendarKeyButton::getSelectedDate()); } @@ -194,6 +213,7 @@ void SidebarCalendarWidget::slotFirstDayChanged(int value) SidebarCalendarKeyButton::SidebarCalendarKeyButton(QWidget *parent) : QPushButton(parent) { + qCDebug(ClientLogger) << "SidebarCalendarKeyButton constructed"; setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); setMinimumSize(QSize(10, 10)); } @@ -205,6 +225,7 @@ SidebarCalendarKeyButton::SidebarCalendarKeyButton(QWidget *parent) */ void SidebarCalendarKeyButton::setSelectedDate(const QDate& date) { + // qCDebug(ClientLogger) << "Setting static selected date to:" << date.toString(); m_selectedData = date; } @@ -214,6 +235,7 @@ void SidebarCalendarKeyButton::setSelectedDate(const QDate& date) */ QDate SidebarCalendarKeyButton::getSelectedDate() { + // qCDebug(ClientLogger) << "Getting static selected date"; return m_selectedData; } @@ -224,6 +246,7 @@ QDate SidebarCalendarKeyButton::getSelectedDate() */ void SidebarCalendarKeyButton::setDisplayedMonth(const QDate& date) { + // qCDebug(ClientLogger) << "Setting static displayed month to:" << date.toString("yyyy-MM"); m_displayedMonth = date; } @@ -233,6 +256,7 @@ void SidebarCalendarKeyButton::setDisplayedMonth(const QDate& date) */ QDate SidebarCalendarKeyButton::getDisplayedMonth() { + // qCDebug(ClientLogger) << "Getting static displayed month"; return m_displayedMonth; } @@ -243,6 +267,7 @@ QDate SidebarCalendarKeyButton::getDisplayedMonth() */ void SidebarCalendarKeyButton::setDate(const QDate& date) { + // qCDebug(ClientLogger) << "Setting static displayed date to:" << date.toString(); this->m_displayedDate = date; update(); } @@ -253,6 +278,7 @@ void SidebarCalendarKeyButton::setDate(const QDate& date) */ QDate SidebarCalendarKeyButton::getDate() { + // qCDebug(ClientLogger) << "Getting static displayed date"; return m_displayedDate; } @@ -262,7 +288,9 @@ QDate SidebarCalendarKeyButton::getDate() */ void SidebarCalendarKeyButton::click() { + qCDebug(ClientLogger) << "Calendar key button clicked, date:" << m_displayedDate.toString(); if(!withinTimeFrame(m_displayedDate)){ + qCDebug(ClientLogger) << "Date not within time frame, ignoring click"; return; } m_selectedData = m_displayedDate; @@ -271,6 +299,7 @@ void SidebarCalendarKeyButton::click() void SidebarCalendarKeyButton::mousePressEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "Calendar key button mouse pressed, date:" << m_displayedDate.toString(); //判断鼠标左键按下事件 if (event->button() == Qt::LeftButton) { this->pressed = true; @@ -280,6 +309,7 @@ void SidebarCalendarKeyButton::mousePressEvent(QMouseEvent *event) void SidebarCalendarKeyButton::mouseReleaseEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "Calendar key button mouse released, date:" << m_displayedDate.toString(); //判断鼠标左键释放事件 if (pressed && event->button() == Qt::LeftButton && rect().contains(event->pos())) { click(); @@ -293,6 +323,7 @@ void SidebarCalendarKeyButton::mouseReleaseEvent(QMouseEvent *event) void SidebarCalendarKeyButton::mouseMoveEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "Calendar key button mouse moved, date:" << m_displayedDate.toString(); //判断鼠标左键移动事件 if (event->button() == Qt::LeftButton && rect().contains(event->pos())) { pressed = true; @@ -303,6 +334,7 @@ void SidebarCalendarKeyButton::mouseMoveEvent(QMouseEvent *event) void SidebarCalendarKeyButton::paintEvent(QPaintEvent *event) { + // qCDebug(ClientLogger) << "Calendar key button paint event, date:" << m_displayedDate.toString(); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); @@ -317,6 +349,7 @@ void SidebarCalendarKeyButton::paintEvent(QPaintEvent *event) painter.setFont(font); if (m_displayedDate == m_selectedData && withinTimeFrame(m_displayedDate)) { + // qCDebug(ClientLogger) << "Calendar key button paint event, date:" << m_displayedDate.toString() << "is selected"; painter.setPen(Qt::NoPen); painter.setBrush(DPaletteHelper::instance()->palette(this).highlight()); //绘制高亮背景 @@ -324,6 +357,7 @@ void SidebarCalendarKeyButton::paintEvent(QPaintEvent *event) //设置高亮下的字体颜色 painter.setPen(DPaletteHelper::instance()->palette(this).highlightedText().color()); } else if (!(m_displayedDate.year() == m_displayedMonth.year() && m_displayedDate.month() == m_displayedMonth.month())){ + // qCDebug(ClientLogger) << "Calendar key button paint event, date:" << m_displayedDate.toString() << "is not selected"; //设置正常显示状态下的字体颜色 painter.setOpacity(0.3); } diff --git a/calendar-client/src/widget/sidebarWidget/sidebaritemwidget.cpp b/calendar-client/src/widget/sidebarWidget/sidebaritemwidget.cpp index 2e4553664..b6f975355 100644 --- a/calendar-client/src/widget/sidebarWidget/sidebaritemwidget.cpp +++ b/calendar-client/src/widget/sidebarWidget/sidebaritemwidget.cpp @@ -4,6 +4,7 @@ #include "sidebaritemwidget.h" #include "accountmanager.h" +#include "commondef.h" #include #include #include @@ -13,11 +14,13 @@ SidebarItemWidget::SidebarItemWidget(QWidget *parent) : QWidget(parent) { + qCDebug(ClientLogger) << "SidebarItemWidget constructed"; setFixedWidth(170); } SidebarItemWidget *SidebarItemWidget::getAccountItemWidget(AccountItem::Ptr ptr) { + qCDebug(ClientLogger) << "Creating account item widget for account ID:" << ptr->getAccount()->accountID(); return new SidebarAccountItemWidget(ptr); } @@ -29,6 +32,8 @@ SidebarItemWidget *SidebarItemWidget::getAccountItemWidget(AccountItem::Ptr ptr) */ SidebarItemWidget *SidebarItemWidget::getTypeItemWidget(DScheduleType::Ptr ptr) { + qCDebug(ClientLogger) << "Creating type item widget for schedule type:" << ptr->displayName() + << "with ID:" << ptr->typeID(); return new SidebarTypeItemWidget(ptr); } @@ -40,14 +45,17 @@ SidebarItemWidget *SidebarItemWidget::getTypeItemWidget(DScheduleType::Ptr ptr) void SidebarItemWidget::setSelectStatus(bool status) { if (status == m_selectStatus && m_item && status == m_item->isExpanded()) { + qCDebug(ClientLogger) << "Select status unchanged for item with ID:" << m_id; return; } + qCDebug(ClientLogger) << "Setting select status to:" << status << "for item with ID:" << m_id; m_selectStatus = status; //根据控件类型设置响应控件状态 updateStatus(); if (m_item && m_item->isExpanded() != status) { //设置列表展开状态 + qCDebug(ClientLogger) << "Setting tree item expanded state to:" << status; m_item->setExpanded(status); } emit signalStatusChange(m_selectStatus, m_id); @@ -60,6 +68,7 @@ void SidebarItemWidget::setSelectStatus(bool status) */ bool SidebarItemWidget::getSelectStatus() { + // qCDebug(ClientLogger) << "Getting select status for item with ID:" << m_id; return m_selectStatus; } @@ -69,6 +78,7 @@ bool SidebarItemWidget::getSelectStatus() */ void SidebarItemWidget::switchState() { + // qCDebug(ClientLogger) << "Switching select state for item with ID:" << m_id; setSelectStatus(!m_selectStatus); } @@ -79,6 +89,7 @@ void SidebarItemWidget::switchState() */ void SidebarItemWidget::setItem(QTreeWidgetItem *item) { + // qCDebug(ClientLogger) << "Setting tree item for sidebar item with ID:" << m_id; m_item = item; } @@ -90,6 +101,7 @@ QTreeWidgetItem *SidebarItemWidget::getTreeItem() void SidebarItemWidget::mouseDoubleClickEvent(QMouseEvent *event) { Q_UNUSED(event) + // qCDebug(ClientLogger) << "Double-click event on sidebar item with ID:" << m_id; switchState(); } @@ -102,12 +114,14 @@ SidebarTypeItemWidget::SidebarTypeItemWidget(DScheduleType::Ptr ptr, QWidget *pa : SidebarItemWidget(parent) , m_scheduleType(ptr) { + qCDebug(ClientLogger) << "SidebarTypeItemWidget constructed for type:" << ptr->displayName(); initView(); m_id = m_scheduleType->accountID(); } void SidebarTypeItemWidget::initView() { + qCDebug(ClientLogger) << "Initializing SidebarTypeItemWidget view for type ID:" << m_scheduleType->typeID(); QHBoxLayout *vLayout = new QHBoxLayout(this); vLayout->setContentsMargins(5, 0, 0, 0); vLayout->setSpacing(0); @@ -118,6 +132,8 @@ void SidebarTypeItemWidget::initView() m_checkBox->setFocusPolicy(Qt::NoFocus); setSelectStatus((m_scheduleType->showState() == DScheduleType::Show)); connect(m_checkBox, &QCheckBox::clicked, this, [this]() { + qCDebug(ClientLogger) << "Checkbox clicked, new state:" << m_checkBox->isChecked() + << "for type:" << m_scheduleType->displayName(); setSelectStatus(m_checkBox->isChecked()); }); @@ -144,9 +160,13 @@ void SidebarTypeItemWidget::initView() void SidebarTypeItemWidget::updateStatus() { + qCDebug(ClientLogger) << "Updating type item status for type:" << m_scheduleType->displayName() + << "with ID:" << m_scheduleType->typeID(); AccountItem::Ptr account = gAccountManager->getAccountItemByAccountId(m_scheduleType->accountID()); if (account) { if (m_selectStatus != (m_scheduleType->showState() == DScheduleType::Show)) { + qCDebug(ClientLogger) << "Changing schedule type show state to:" + << (m_selectStatus ? "Show" : "Hide"); m_scheduleType->setShowState(m_selectStatus ? DScheduleType::Show : DScheduleType::Hide); account->updateScheduleTypeShowState(m_scheduleType); } @@ -158,12 +178,16 @@ SidebarAccountItemWidget::SidebarAccountItemWidget(AccountItem::Ptr ptr, QWidget : SidebarItemWidget(parent) , m_accountItem(ptr) { + qCDebug(ClientLogger) << "SidebarAccountItemWidget constructed for account:" + << ptr->getAccount()->accountName(); initView(); initConnect(); } void SidebarAccountItemWidget::initView() { + qCDebug(ClientLogger) << "Initializing SidebarAccountItemWidget view for account:" + << m_accountItem->getAccount()->accountName(); QHBoxLayout *hLayout = new QHBoxLayout(this); hLayout->setContentsMargins(0, 0, 0, 0); hLayout->setSpacing(0); @@ -175,6 +199,8 @@ void SidebarAccountItemWidget::initView() m_headIconButton->setFocusPolicy(Qt::NoFocus); connect(m_headIconButton, &DIconButton::clicked, this, [this]() { + qCDebug(ClientLogger) << "Head icon button clicked for account:" + << m_accountItem->getAccount()->accountName(); setSelectStatus(!m_selectStatus); }); m_ptrDoaNetwork = new DOANetWorkDBus(this); @@ -214,9 +240,11 @@ void SidebarAccountItemWidget::initView() this->setLayout(hLayout); if (m_accountItem->getAccount()->accountType() == DAccount::Account_UnionID) { + qCDebug(ClientLogger) << "Account is UnionID type, initializing sync button"; resetRearIconButton(); } else { //尾部控件隐藏 + qCDebug(ClientLogger) << "Account is not UnionID type, hiding sync buttons"; m_syncIconButton->hide(); m_warningLabel->hide(); } @@ -225,6 +253,7 @@ void SidebarAccountItemWidget::initView() void SidebarAccountItemWidget::initConnect() { + qCDebug(ClientLogger) << "Initializing SidebarAccountItemWidget connections"; connect(m_syncIconButton, &DIconButton::clicked, this, &SidebarAccountItemWidget::slotRearIconClicked); connect(m_accountItem.data(), &AccountItem::signalSyncStateChange, this, &SidebarAccountItemWidget::slotSyncStatusChange); connect(gAccountManager, &AccountManager::signalAccountStateChange, this, &SidebarAccountItemWidget::slotAccountStateChange); @@ -233,20 +262,27 @@ void SidebarAccountItemWidget::initConnect() void SidebarAccountItemWidget::slotNetworkStateChange(DOANetWorkDBus::NetWorkState state) { + qCDebug(ClientLogger) << "Network state changed to:" << static_cast(state); //控件不显示则不处理 if (!m_accountItem || m_accountItem->getAccount()->accountType() != DAccount::Account_UnionID) { + qCDebug(ClientLogger) << "Account is not UnionID type, ignoring network change"; return; } if (DOANetWorkDBus::NetWorkState::Disconnect == state) { + qCDebug(ClientLogger) << "Network disconnected, showing warning label for account:" + << m_accountItem->getAccount()->accountName(); m_syncIconButton->hide(); m_warningLabel->show(); QString msg = m_accountItem->getSyncMsg(DAccount::AccountSyncState::Sync_NetworkAnomaly); m_warningLabel->setToolTip(msg); } else if (DOANetWorkDBus::NetWorkState::Active == state) { + qCDebug(ClientLogger) << "Network active for account:" << m_accountItem->getAccount()->accountName(); m_warningLabel->hide(); if (m_accountItem->isCanSyncSetting() || m_accountItem->isCanSyncShedule()) { + qCDebug(ClientLogger) << "Account can sync, showing sync button"; m_syncIconButton->show(); } else { + qCDebug(ClientLogger) << "Account cannot sync, hiding sync button"; m_syncIconButton->hide(); } } @@ -254,20 +290,29 @@ void SidebarAccountItemWidget::slotNetworkStateChange(DOANetWorkDBus::NetWorkSta void SidebarAccountItemWidget::resetRearIconButton() { + qCDebug(ClientLogger) << "Resetting rear icon button for account:" + << m_accountItem->getAccount()->accountName(); //控件不显示则不处理 if (m_accountItem->getAccount()->accountType() != DAccount::Account_UnionID) { + qCDebug(ClientLogger) << "Account is not UnionID type, skipping reset"; return; } if (m_accountItem) { if (m_accountItem->getAccount()->syncState() == 0) { + qCDebug(ClientLogger) << "Account sync state is normal"; m_warningLabel->hide(); if (m_accountItem->isCanSyncSetting() || m_accountItem->isCanSyncShedule()) { + qCDebug(ClientLogger) << "Account can sync, showing sync button"; m_syncIconButton->show(); } else { + qCDebug(ClientLogger) << "Account cannot sync, hiding sync button"; m_syncIconButton->hide(); } } else { + qCDebug(ClientLogger) << "Account has sync issues (state:" + << m_accountItem->getAccount()->syncState() + << "), showing warning"; m_syncIconButton->hide(); m_warningLabel->show(); QString msg = m_accountItem->getSyncMsg(m_accountItem->getAccount()->syncState()); @@ -283,6 +328,9 @@ AccountItem::Ptr SidebarAccountItemWidget::getAccountItem() void SidebarAccountItemWidget::updateStatus() { + qCDebug(ClientLogger) << "Updating account item status for:" + << m_accountItem->getAccount()->accountName() + << "to:" << (m_selectStatus ? "expanded" : "collapsed"); m_accountItem->setAccountExpandStatus(m_selectStatus); if (m_selectStatus) { m_headIconButton->setIcon(DStyle::SP_ArrowDown); @@ -294,18 +342,22 @@ void SidebarAccountItemWidget::updateStatus() //尾部图标控件点击事件 void SidebarAccountItemWidget::slotRearIconClicked() { + qCDebug(ClientLogger) << "Sync button clicked for account:" << m_accountItem->getAccount()->accountName(); gAccountManager->downloadByAccountID(m_accountItem->getAccount()->accountID()); } //同步状态改变事件 void SidebarAccountItemWidget::slotSyncStatusChange(DAccount::AccountSyncState state) { + qCDebug(ClientLogger) << "Sync status changed to:" << static_cast(state) + << "for account:" << m_accountItem->getAccount()->accountName(); m_accountItem->getAccount()->setSyncState(state); resetRearIconButton(); } void SidebarAccountItemWidget::slotAccountStateChange() { + qCDebug(ClientLogger) << "Account state changed for:" << m_accountItem->getAccount()->accountName(); resetRearIconButton(); } diff --git a/calendar-client/src/widget/sidebarWidget/sidebartreewidgetitemdelegate.cpp b/calendar-client/src/widget/sidebarWidget/sidebartreewidgetitemdelegate.cpp index e3b48d3f3..763195913 100644 --- a/calendar-client/src/widget/sidebarWidget/sidebartreewidgetitemdelegate.cpp +++ b/calendar-client/src/widget/sidebarWidget/sidebartreewidgetitemdelegate.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "sidebartreewidgetitemdelegate.h" +#include "commondef.h" #include #include @@ -10,12 +11,13 @@ SideBarTreeWidgetItemDelegate::SideBarTreeWidgetItemDelegate() { - + qCDebug(ClientLogger) << "SideBarTreeWidgetItemDelegate constructed"; } void SideBarTreeWidgetItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { if (!index.isValid()) { + // qCDebug(ClientLogger) << "Invalid index for tree item delegate, using default painting"; QStyledItemDelegate::paint(painter, option, index); return; } @@ -28,12 +30,14 @@ void SideBarTreeWidgetItemDelegate::paint(QPainter *painter, const QStyleOptionV QPainterPath path, clipPath; switch (opt.viewItemPosition) { case QStyleOptionViewItem::OnlyOne: { + // qCDebug(ClientLogger) << "Painting tree item as OnlyOne at row:" << index.row(); // 左间距 rect.setX(rect.x() + 8); // 右间距 rect.setWidth(rect.width() - 8); } break; default: { + // qCDebug(ClientLogger) << "Unsupported view item position for tree item delegate, using default painting"; QStyledItemDelegate::paint(painter, option, index); return; } @@ -45,6 +49,7 @@ void SideBarTreeWidgetItemDelegate::paint(QPainter *painter, const QStyleOptionV painter->setClipPath(clipPath); if (option.state & QStyle::State_MouseOver) { + // qCDebug(ClientLogger) << "Tree item has mouse over state, highlighting"; painter->fillRect(painter->clipBoundingRect(), option.palette.midlight()); } } diff --git a/calendar-client/src/widget/sidebarWidget/sidebarview.cpp b/calendar-client/src/widget/sidebarWidget/sidebarview.cpp index 780d79661..f2a5094e0 100644 --- a/calendar-client/src/widget/sidebarWidget/sidebarview.cpp +++ b/calendar-client/src/widget/sidebarWidget/sidebarview.cpp @@ -6,11 +6,13 @@ #include "calendarmanage.h" #include "widget/monthWidget/monthdayview.h" #include "widget/dayWidget/daymonthview.h" +#include "commondef.h" #include #include SidebarView::SidebarView(QWidget *parent) : QWidget(parent) { + qCDebug(ClientLogger) << "SidebarView constructed"; initView(); initConnection(); //初始化数据 @@ -23,6 +25,7 @@ SidebarView::SidebarView(QWidget *parent) : QWidget(parent) */ void SidebarView::initView() { + qCDebug(ClientLogger) << "Initializing SidebarView"; QVBoxLayout *vLayout = new QVBoxLayout(this); vLayout->setContentsMargins(0, 8, 0, 10); vLayout->setSpacing(0); @@ -60,6 +63,7 @@ void SidebarView::initView() void SidebarView::initConnection() { + qCDebug(ClientLogger) << "Initializing SidebarView connections"; //监听日程类型更新事件 connect(gAccountManager, &AccountManager::signalAccountUpdate, this, &SidebarView::slotAccountUpdate); connect(gAccountManager, &AccountManager::signalScheduleTypeUpdate, this, &SidebarView::slotScheduleTypeUpdate); @@ -72,6 +76,7 @@ void SidebarView::initConnection() */ void SidebarView::initData() { + qCDebug(ClientLogger) << "Initializing SidebarView data"; m_treeWidget->clear(); initLocalAccountItem(); @@ -86,6 +91,7 @@ void SidebarView::initData() */ void SidebarView::initExpandStatus() { + qCDebug(ClientLogger) << "Initializing expand status for sidebar items"; //初始化列表展开状态 QList itemWidget; itemWidget << m_localItemWidget << m_unionItemWidget; @@ -93,6 +99,9 @@ void SidebarView::initExpandStatus() if (widget != nullptr) { //先进行一次反的展开状态目的是解决使用widget填充item时添加列表项后最后一项的widget没有隐藏问题 bool ret = widget->getAccountItem()->getAccount()->isExpandDisplay(); + // qCDebug(ClientLogger) << "Setting expand status for account:" + // << widget->getAccountItem()->getAccount()->accountName() + // << "to:" << ret; widget->getTreeItem()->setExpanded(!ret); widget->setSelectStatus(ret); } @@ -105,6 +114,7 @@ void SidebarView::initExpandStatus() */ void SidebarView::initLocalAccountItem() { + qCDebug(ClientLogger) << "Initializing local account item"; if (nullptr != m_localItemWidget) { // m_localItemWidget->deleteLater(); delete m_localItemWidget; @@ -112,11 +122,13 @@ void SidebarView::initLocalAccountItem() } QSharedPointer localAccount = gAccountManager->getLocalAccountItem(); if (nullptr == localAccount) { + qCDebug(ClientLogger) << "No local account found"; return; } QTreeWidgetItem *localItem = new QTreeWidgetItem(); m_treeWidget->addTopLevelItem(localItem); QString localName = localAccount->getAccount()->accountName(); + qCDebug(ClientLogger) << "Added local account:" << localName; m_localItemWidget = new SidebarAccountItemWidget(localAccount); m_treeWidget->setItemWidget(localItem, 0, m_localItemWidget); @@ -129,14 +141,17 @@ void SidebarView::initLocalAccountItem() */ void SidebarView::initUnionAccountItem() { + qCDebug(ClientLogger) << "Initializing UnionID account item"; QSharedPointer unionAccount = gAccountManager->getUnionAccountItem(); if (nullptr == unionAccount) { + qCDebug(ClientLogger) << "No UnionID account found"; return; } QTreeWidgetItem *unionItem = new QTreeWidgetItem(); m_treeWidget->addTopLevelItem(unionItem); QString unionName = unionAccount->getAccount()->accountName(); + qCDebug(ClientLogger) << "Added UnionID account:" << unionName; m_unionItemWidget = new SidebarAccountItemWidget(unionAccount); m_treeWidget->setItemWidget(unionItem, 0, m_unionItemWidget); unionItem->setToolTip(0,unionName); @@ -151,10 +166,14 @@ void SidebarView::initUnionAccountItem() void SidebarView::resetJobTypeChildItem(SidebarAccountItemWidget *parentItemWidget) { if (nullptr == parentItemWidget) { + qCDebug(ClientLogger) << "Parent item widget is null, cannot reset job types"; return; } + // qCDebug(ClientLogger) << "Resetting job type items for account:" + // << parentItemWidget->getAccountItem()->getAccount()->accountName(); QTreeWidgetItem *parentItem = parentItemWidget->getTreeItem(); int itemChildrenCounts = parentItem->childCount(); + qCDebug(ClientLogger) << "Removing" << itemChildrenCounts << "existing child items"; while(itemChildrenCounts--) { QTreeWidgetItem * child = parentItem->child(itemChildrenCounts); //index从大到小区做删除处理 @@ -164,6 +183,7 @@ void SidebarView::resetJobTypeChildItem(SidebarAccountItemWidget *parentItemWidg } DScheduleType::List typeList = parentItemWidget->getAccountItem()->getScheduleTypeList(); + qCDebug(ClientLogger) << "Adding" << typeList.size() << "schedule type items"; QTreeWidgetItem *item; for (DScheduleType::Ptr p : typeList) { if (nullptr != p) { @@ -173,6 +193,7 @@ void SidebarView::resetJobTypeChildItem(SidebarAccountItemWidget *parentItemWidg parentItem->addChild(item); SidebarItemWidget *widget = new SidebarTypeItemWidget(p, this); m_treeWidget->setItemWidget(item, 0, widget); + // qCDebug(ClientLogger) << "Added schedule type:" << p->displayName() << "with ID:" << p->typeID(); connect(widget,&SidebarItemWidget::signalStatusChange,this,[&](bool status, QString id){ Q_UNUSED(id) Q_UNUSED(status) @@ -190,7 +211,9 @@ void SidebarView::resetJobTypeChildItem(SidebarAccountItemWidget *parentItemWidg */ void SidebarView::resetTreeItemPos(QTreeWidgetItem *item) { + // qCDebug(ClientLogger) << "Resetting tree item positions for" << item->childCount() << "children"; if (nullptr == item) { + qCDebug(ClientLogger) << "Tree item is null, cannot reset positions"; return; } QWidget* ptmpWidget = nullptr; @@ -211,6 +234,7 @@ void SidebarView::resetTreeItemPos(QTreeWidgetItem *item) */ void SidebarView::slotAccountUpdate() { + qCDebug(ClientLogger) << "Account update received, reinitializing data"; initData(); } @@ -220,6 +244,7 @@ void SidebarView::slotAccountUpdate() */ void SidebarView::slotScheduleTypeUpdate() { + qCDebug(ClientLogger) << "Schedule type update received"; //初始化列表数据 resetJobTypeChildItem(m_localItemWidget); resetJobTypeChildItem(m_unionItemWidget); @@ -234,9 +259,11 @@ void SidebarView::slotScheduleTypeUpdate() */ void SidebarView::signalLogout(DAccount::Type accountType) { + qCDebug(ClientLogger) << "Account logout received for type:" << accountType; //先清空列表 m_treeWidget->clear(); if (DAccount::Account_UnionID == accountType){ + qCDebug(ClientLogger) << "UnionID account logged out, reinitializing local account"; if (m_unionItemWidget) { //清空数据 m_unionItemWidget->getAccountItem().reset(nullptr); @@ -251,6 +278,7 @@ void SidebarView::signalLogout(DAccount::Type accountType) void SidebarView::paintEvent(QPaintEvent *event) { + // qCDebug(ClientLogger) << "SidebarView::paintEvent"; //绘制背景 QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); diff --git a/calendar-client/src/widget/touchgestureoperation.cpp b/calendar-client/src/widget/touchgestureoperation.cpp index 737760cf5..2b34237fe 100644 --- a/calendar-client/src/widget/touchgestureoperation.cpp +++ b/calendar-client/src/widget/touchgestureoperation.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "touchgestureoperation.h" +#include "commondef.h" #include #include @@ -12,12 +13,14 @@ touchGestureOperation::touchGestureOperation(QWidget *parent) : m_parentWidget(parent) { + qCDebug(ClientLogger) << "touchGestureOperation constructed"; if (m_parentWidget) { m_parentWidget->setAttribute(Qt::WA_AcceptTouchEvents); //截获相应的gesture手势 m_parentWidget->grabGesture(Qt::TapGesture); m_parentWidget->grabGesture(Qt::TapAndHoldGesture); m_parentWidget->grabGesture(Qt::PanGesture); + qCDebug(ClientLogger) << "Touch gestures grabbed for widget"; } } @@ -26,11 +29,13 @@ bool touchGestureOperation::event(QEvent *e) bool _result {false}; if (e->type() == QEvent::Gesture) { //手势触发 + // qCDebug(ClientLogger) << "Gesture event received"; _result = gestureEvent(dynamic_cast(e)); } QMouseEvent *mouseEvent = dynamic_cast(e); if (e->type() == QEvent::MouseButtonPress && mouseEvent->source() == Qt::MouseEventSynthesizedByQt) { //触摸点击转换鼠标点击事件 + // qCDebug(ClientLogger) << "Touch press detected at:" << mouseEvent->pos(); m_mouseState = M_PRESS; m_beginTouchPoint = mouseEvent->pos(); _result = true; @@ -44,6 +49,7 @@ bool touchGestureOperation::event(QEvent *e) //如果为单指点击状态则转换为滑动状态 switch (m_touchState) { case T_SINGLE_CLICK: { + // qCDebug(ClientLogger) << "Touch state changed from single click to slide"; m_touchState = T_SLIDE; break; } @@ -52,6 +58,8 @@ bool touchGestureOperation::event(QEvent *e) calculateAzimuthAngle(m_beginTouchPoint, currentPoint); //如果移动距离大于15则更新 if (m_movelenght > 15) { + // qCDebug(ClientLogger) << "Touch slide significant movement detected, direction:" + // << m_movingDir << "distance:" << m_movelenght; m_update = true; m_beginTouchPoint = currentPoint; } @@ -64,6 +72,7 @@ bool touchGestureOperation::event(QEvent *e) _result = true; } if (e->type() == QEvent::MouseButtonRelease && mouseEvent->source() == Qt::MouseEventSynthesizedByQt) { + // qCDebug(ClientLogger) << "Touch release detected at:" << mouseEvent->pos(); m_mouseState = M_NONE; _result = true; } @@ -77,21 +86,25 @@ bool touchGestureOperation::isUpdate() const void touchGestureOperation::setUpdate(bool b) { + // qCDebug(ClientLogger) << "Setting update state to:" << b; m_update = b; } touchGestureOperation::TouchState touchGestureOperation::getTouchState() const { + // qCDebug(ClientLogger) << "Getting touch state:" << m_touchState; return m_touchState; } touchGestureOperation::TouchMovingDirection touchGestureOperation::getMovingDir() const { + // qCDebug(ClientLogger) << "Getting moving direction:" << m_movingDir; return m_movingDir; } touchGestureOperation::TouchMovingDirection touchGestureOperation::getTouchMovingDir(QPointF &startPoint, QPointF &stopPoint, qreal &movingLine) { + qCDebug(ClientLogger) << "Getting touch moving direction"; TouchMovingDirection _result {T_MOVE_NONE}; qreal angle = 0.0000; qreal dx = stopPoint.rx() - startPoint.rx(); @@ -101,6 +114,7 @@ touchGestureOperation::TouchMovingDirection touchGestureOperation::getTouchMovin qreal line = qSqrt(dx * dx + dy * dy); //如果移动距离大于10则有效 if (line > 10) { + qCDebug(ClientLogger) << "Getting touch moving direction, angle:" << angle; if ((angle <= -45) && (angle >= -135)) { _result = TouchMovingDirection::T_TOP; } else if ((angle > -45) && (angle < 45)) { @@ -117,6 +131,7 @@ touchGestureOperation::TouchMovingDirection touchGestureOperation::getTouchMovin bool touchGestureOperation::gestureEvent(QGestureEvent *event) { + // qCDebug(ClientLogger) << "Gesture event received"; if (QGesture *tap = event->gesture(Qt::TapGesture)) tapGestureTriggered(dynamic_cast(tap)); if (QGesture *pan = event->gesture(Qt::PanGesture)) @@ -126,6 +141,7 @@ bool touchGestureOperation::gestureEvent(QGestureEvent *event) void touchGestureOperation::tapGestureTriggered(QTapGesture *tap) { + qCDebug(ClientLogger) << "Tap gesture triggered with state:" << tap->state(); switch (tap->state()) { case Qt::NoGesture: { break; @@ -133,43 +149,54 @@ void touchGestureOperation::tapGestureTriggered(QTapGesture *tap) case Qt::GestureStarted: { m_beginTouchTime = QDateTime::currentDateTime().toMSecsSinceEpoch(); m_touchState = T_SINGLE_CLICK; + qCDebug(ClientLogger) << "Tap gesture started, setting touch state to single click"; break; } case Qt::GestureUpdated: { + qCDebug(ClientLogger) << "Tap gesture updated"; break; } case Qt::GestureFinished: { + qCDebug(ClientLogger) << "Tap gesture finished"; break; } default: { //GestureCanceled + qCDebug(ClientLogger) << "Tap gesture canceled"; } } } void touchGestureOperation::panTriggered(QPanGesture *pan) { + qCDebug(ClientLogger) << "Pan gesture triggered with state:" << pan->state(); switch (pan->state()) { case Qt::NoGesture: { + qCDebug(ClientLogger) << "Pan gesture no gesture"; break; } case Qt::GestureStarted: { + qCDebug(ClientLogger) << "Pan gesture started"; break; } case Qt::GestureUpdated: { m_touchState = T_SLIDE; + qCDebug(ClientLogger) << "Pan gesture updated, setting touch state to slide"; break; } case Qt::GestureFinished: { + qCDebug(ClientLogger) << "Pan gesture finished"; break; } default: //GestureCanceled + qCDebug(ClientLogger) << "Pan gesture canceled"; break; } } void touchGestureOperation::calculateAzimuthAngle(QPointF &startPoint, QPointF &stopPoint) { + // qCDebug(ClientLogger) << "Calculating azimuth angle"; m_movingDir = getTouchMovingDir(startPoint, stopPoint, m_movelenght); } diff --git a/calendar-client/src/widget/weekWidget/weekheadview.cpp b/calendar-client/src/widget/weekWidget/weekheadview.cpp index 234d884bc..0254e388b 100644 --- a/calendar-client/src/widget/weekWidget/weekheadview.cpp +++ b/calendar-client/src/widget/weekWidget/weekheadview.cpp @@ -5,6 +5,7 @@ #include "weekheadview.h" #include "customframe.h" #include "scheduledatamanage.h" +#include "commondef.h" #include @@ -26,6 +27,7 @@ CWeekHeadView::CWeekHeadView(QWidget *parent) : DWidget(parent) , m_touchGesture(this) { + qCDebug(ClientLogger) << "CWeekHeadView constructed"; setContentsMargins(0, 0, 0, 0); m_dayNumFont.setWeight(QFont::Medium); @@ -49,6 +51,7 @@ CWeekHeadView::CWeekHeadView(QWidget *parent) hBoxLayout->setStretch(0, 0); hBoxLayout->setSpacing(0); + qCDebug(ClientLogger) << "Creating week day cells"; for (int c = 0; c != DDEWeekCalendar::AFewDaysofWeek; ++c) { QWidget *cell = new QWidget(this); cell->installEventFilter(this); @@ -62,7 +65,7 @@ CWeekHeadView::CWeekHeadView(QWidget *parent) CWeekHeadView::~CWeekHeadView() { - + qCDebug(ClientLogger) << "CWeekHeadView destroyed"; } /** @@ -71,9 +74,11 @@ CWeekHeadView::~CWeekHeadView() */ void CWeekHeadView::setTheMe(int type) { + qCDebug(ClientLogger) << "Setting theme to type:" << type; m_themetype = type; if (type == 0 || type == 1) { + qCDebug(ClientLogger) << "Setting theme to light"; QColor textC = "#000000"; QColor textBC(230, 238, 242); @@ -92,6 +97,7 @@ void CWeekHeadView::setTheMe(int type) m_backgroundColor = "#E6EEF2"; m_solofestivalLunarColor = "#4DFF7272"; } else if (type == 2) { + qCDebug(ClientLogger) << "Setting theme to dark"; QColor textBC = "#82AEC1"; textBC.setAlphaF(0.1); m_monthLabel->setBColor(textBC); @@ -121,6 +127,8 @@ void CWeekHeadView::setTheMe(int type) */ void CWeekHeadView::setWeekDay(QVector vDays, const QDate &selectDate) { + qCDebug(ClientLogger) << "Setting week days from" << vDays.first().toString() << "to" << vDays.last().toString() + << "with selected date:" << selectDate.toString(); if (vDays.count() != DDEWeekCalendar::AFewDaysofWeek) return; m_days = vDays; @@ -134,6 +142,7 @@ void CWeekHeadView::setWeekDay(QVector vDays, const QDate &selectDate) */ void CWeekHeadView::setHunagLiInfo(const QMap &huangLiInfo) { + qCDebug(ClientLogger) << "Setting Huangli information for" << huangLiInfo.size() << "days"; m_huangLiInfo = huangLiInfo; update(); } @@ -144,6 +153,7 @@ void CWeekHeadView::setHunagLiInfo(const QMap &huangLiI */ void CWeekHeadView::setLunarVisible(bool visible) { + qCDebug(ClientLogger) << "Setting lunar visibility to:" << visible; int state = int(m_showState); if (visible) @@ -163,13 +173,17 @@ void CWeekHeadView::setLunarVisible(bool visible) */ bool CWeekHeadView::eventFilter(QObject *o, QEvent *e) { + // qCDebug(ClientLogger) << "Event filter received for object:" << o->objectName() << "with event type:" << e->type(); QWidget *cell = qobject_cast(o); if (cell && m_cellList.contains(cell)) { + // qCDebug(ClientLogger) << "Event filter received for cell:" << cell->objectName() << "with event type:" << e->type(); if (e->type() == QEvent::Paint) { + // qCDebug(ClientLogger) << "Painting cell for date:" << m_days[m_cellList.indexOf(cell)].toString(); paintCell(cell); } else if (e->type() == QEvent::MouseButtonDblClick) { const int pos = m_cellList.indexOf(cell); + // qCDebug(ClientLogger) << "Cell double-clicked for date:" << m_days[pos].toString(); emit signalsViewSelectDate(m_days[pos]); } } @@ -183,6 +197,7 @@ bool CWeekHeadView::eventFilter(QObject *o, QEvent *e) */ const QString CWeekHeadView::getCellDayNum(int pos) { + // qCDebug(ClientLogger) << "Getting cell day number for position:" << pos; return QString::number(m_days[pos].day()); } @@ -193,6 +208,7 @@ const QString CWeekHeadView::getCellDayNum(int pos) */ const QDate CWeekHeadView::getCellDate(int pos) { + // qCDebug(ClientLogger) << "Getting cell date for position:" << pos; return m_days[pos]; } @@ -203,6 +219,7 @@ const QDate CWeekHeadView::getCellDate(int pos) */ const QString CWeekHeadView::getLunar(int pos) { + // qCDebug(ClientLogger) << "Getting lunar information for position:" << pos; CaHuangLiDayInfo info ; if (pos >= 0 && pos < m_days.size()) { info = m_huangLiInfo[m_days[pos]]; @@ -221,6 +238,7 @@ const QString CWeekHeadView::getLunar(int pos) */ void CWeekHeadView::paintCell(QWidget *cell) { + // qCDebug(ClientLogger) << "Painting cell"; m_weekendsTextColor = CScheduleDataManage::getScheduleDataManage()->getSystemActiveColor(); const QRect rect(0, 0, cell->width(), cell->height()); const int pos = m_cellList.indexOf(cell); @@ -363,26 +381,32 @@ void CWeekHeadView::paintCell(QWidget *cell) void CWeekHeadView::wheelEvent(QWheelEvent *e) { + // qCDebug(ClientLogger) << "Wheel event received"; //如果滚轮为左右方向则触发信号 if (e->angleDelta().x() != 0) { + qCDebug(ClientLogger) << "Wheel event with horizontal delta:" << e->angleDelta().x(); emit signalAngleDelta(e->angleDelta().x()); } } bool CWeekHeadView::event(QEvent *e) { + // qCDebug(ClientLogger) << "Event received"; if (m_touchGesture.event(e)) { //获取触摸状态 switch (m_touchGesture.getTouchState()) { case touchGestureOperation::T_SLIDE: { + // qCDebug(ClientLogger) << "Touch gesture detected: slide"; //在滑动状态如果可以更新数据则切换月份 if (m_touchGesture.isUpdate()) { m_touchGesture.setUpdate(false); switch (m_touchGesture.getMovingDir()) { case touchGestureOperation::T_LEFT: + qCDebug(ClientLogger) << "Touch gesture detected: slide left"; emit signalAngleDelta(-1); break; case touchGestureOperation::T_RIGHT: + qCDebug(ClientLogger) << "Touch gesture detected: slide right"; emit signalAngleDelta(1); break; default: diff --git a/calendar-client/src/widget/weekWidget/weekview.cpp b/calendar-client/src/widget/weekWidget/weekview.cpp index b9e381d9c..b31c7fdac 100644 --- a/calendar-client/src/widget/weekWidget/weekview.cpp +++ b/calendar-client/src/widget/weekWidget/weekview.cpp @@ -6,6 +6,7 @@ #include "scheduledatamanage.h" #include "constants.h" #include "units.h" +#include "commondef.h" #include @@ -27,6 +28,7 @@ CWeekView::CWeekView(const GetWeekNumOfYear &getWeekNumOfYear, QWidget *parent) , m_touchGesture(this) , m_weekNumWidget(nullptr) { + qCDebug(ClientLogger) << "CWeekView constructed"; QHBoxLayout *hBoxLayout = new QHBoxLayout; hBoxLayout->setContentsMargins(0, 0, 0, 0); hBoxLayout->setSpacing(0); @@ -55,6 +57,7 @@ CWeekView::CWeekView(const GetWeekNumOfYear &getWeekNumOfYear, QWidget *parent) CWeekView::~CWeekView() { + qCDebug(ClientLogger) << "CWeekView destroyed"; } /** @@ -63,6 +66,7 @@ CWeekView::~CWeekView() */ void CWeekView::setSelectDate(const QDate date) { + qCDebug(ClientLogger) << "Setting select date to:" << date.toString(); m_weekNumWidget->setSelectDate(date); } @@ -72,6 +76,7 @@ void CWeekView::setSelectDate(const QDate date) */ void CWeekView::setCurrent(const QDateTime &dateTime) { + qCDebug(ClientLogger) << "Setting current date/time to:" << dateTime.toString(); m_weekNumWidget->setCurrent(dateTime); } @@ -81,6 +86,7 @@ void CWeekView::setCurrent(const QDateTime &dateTime) */ void CWeekView::setTheMe(int type) { + qCDebug(ClientLogger) << "Setting theme to:" << type; m_weekNumWidget->setTheMe(type); } @@ -90,6 +96,7 @@ void CWeekView::setTheMe(int type) */ void CWeekView::wheelEvent(QWheelEvent *event) { + // qCDebug(ClientLogger) << "Wheel event detected with delta:" << event->angleDelta(); bool isDragging = false; emit signalIsDragging(isDragging); //判断是否是拖拽状态 @@ -97,9 +104,11 @@ void CWeekView::wheelEvent(QWheelEvent *event) //左移切换上周,右移切换下周 if (event->angleDelta().y() > 0) { //上一周 + qCDebug(ClientLogger) << "Wheel event triggers previous week"; signalBtnPrev(); } else { //下一周 + qCDebug(ClientLogger) << "Wheel event triggers next week"; signalBtnNext(); } } @@ -107,20 +116,25 @@ void CWeekView::wheelEvent(QWheelEvent *event) bool CWeekView::event(QEvent *e) { + // qCDebug(ClientLogger) << "Event received"; if (m_touchGesture.event(e)) { + // qCDebug(ClientLogger) << "Touch gesture detected"; //获取触摸状态 switch (m_touchGesture.getTouchState()) { case touchGestureOperation::T_SLIDE: { + // qCDebug(ClientLogger) << "Touch gesture detected: slide"; //在滑动状态如果可以更新数据则切换月份 if (m_touchGesture.isUpdate()) { m_touchGesture.setUpdate(false); switch (m_touchGesture.getMovingDir()) { case touchGestureOperation::T_LEFT: //切换下周 + qCDebug(ClientLogger) << "Touch gesture detected: slide left, triggering next week"; signalBtnNext(); break; case touchGestureOperation::T_RIGHT: //切换上周 + qCDebug(ClientLogger) << "Touch gesture detected: slide right, triggering previous week"; signalBtnPrev(); break; default: @@ -143,6 +157,7 @@ CWeekNumWidget::CWeekNumWidget(const GetWeekNumOfYear &getWeekNumOfYear, QWidget , m_getWeekNumOfYear(getWeekNumOfYear) , m_isFocus(false) { + qCDebug(ClientLogger) << "CWeekNumWidget constructed"; m_dayNumFont.setPixelSize(DDECalendar::FontSizeSixteen); m_dayNumFont.setWeight(QFont::Light); setFocusPolicy(Qt::StrongFocus); @@ -151,6 +166,7 @@ CWeekNumWidget::CWeekNumWidget(const GetWeekNumOfYear &getWeekNumOfYear, QWidget hBoxLayout->setSpacing(0); hBoxLayout->setContentsMargins(0, 0, 0, 0); //显示周数的widget + qCDebug(ClientLogger) << "Creating week number cells"; for (int c = 0; c != DDEWeekCalendar::NumWeeksDisplayed; ++c) { QWidget *cell = new QWidget; //设置事件过滤器 @@ -163,21 +179,25 @@ CWeekNumWidget::CWeekNumWidget(const GetWeekNumOfYear &getWeekNumOfYear, QWidget CWeekNumWidget::~CWeekNumWidget() { + qCDebug(ClientLogger) << "CWeekNumWidget destroyed"; } void CWeekNumWidget::setSelectDate(const QDate date) { + qCDebug(ClientLogger) << "Setting select date in CWeekNumWidget to:" << date.toString(); m_selectDate = date; updateDate(); } void CWeekNumWidget::setCurrent(const QDateTime &dateTime) { + qCDebug(ClientLogger) << "Setting current date/time in CWeekNumWidget to:" << dateTime.toString(); m_currentDate = dateTime; } void CWeekNumWidget::setTheMe(int type) { + qCDebug(ClientLogger) << "Setting theme in CWeekNumWidget to:" << type; if (type == 0 || type == 1) { m_defaultTextColor = Qt::black; m_backgrounddefaultColor = Qt::white; @@ -197,6 +217,7 @@ void CWeekNumWidget::setTheMe(int type) void CWeekNumWidget::resizeEvent(QResizeEvent *event) { + // qCDebug(ClientLogger) << "CWeekNumWidget resize event with size:" << event->size(); //获取当前所有cell的宽度 const int _allCellWidth = width(); //获取当前cell的宽度 @@ -209,6 +230,7 @@ void CWeekNumWidget::resizeEvent(QResizeEvent *event) if (w < _minWidget) { //计算前后需要隐藏的个数 int t_num = qRound((_minWidget * DDEWeekCalendar::NumWeeksDisplayed - _allCellWidth) / _minWidget / 2.0); + // qCDebug(ClientLogger) << "Cell width too small, hiding" << t_num << "cells from each side"; for (int i = 0; i < t_num; i++) { vIndex[i] = false; vIndex[9 - i] = false; @@ -225,11 +247,13 @@ void CWeekNumWidget::resizeEvent(QResizeEvent *event) void CWeekNumWidget::focusInEvent(QFocusEvent *event) { + // qCDebug(ClientLogger) << "CWeekNumWidget focus in event with reason:" << event->reason(); QWidget::focusInEvent(event); switch (event->reason()) { case Qt::TabFocusReason: case Qt::BacktabFocusReason: case Qt::ActiveWindowFocusReason: + // qCDebug(ClientLogger) << "CWeekNumWidget focus in event with reason: TabFocusReason"; m_isFocus = true; break; default: @@ -241,6 +265,7 @@ void CWeekNumWidget::focusInEvent(QFocusEvent *event) void CWeekNumWidget::focusOutEvent(QFocusEvent *event) { + // qCDebug(ClientLogger) << "CWeekNumWidget focus out event"; QWidget::focusOutEvent(event); m_isFocus = false; update(); @@ -248,6 +273,7 @@ void CWeekNumWidget::focusOutEvent(QFocusEvent *event) void CWeekNumWidget::paintCell(QWidget *cell) { + // qCDebug(ClientLogger) << "Painting cell"; const QRect rect(0, 0, cell->width(), cell->height()); const int pos = m_cellList.indexOf(cell); //计算当前日期周数 @@ -269,6 +295,7 @@ void CWeekNumWidget::paintCell(QWidget *cell) const QString dayNum = QString::number(_showWeekNum); if (isSelectDay) { + // qCDebug(ClientLogger) << "Painting selected day cell"; QRect fillRect((cell->width() - 24) / 2, (cell->height() - 32) / 2 + 4, 24, 24); painter.save(); painter.setRenderHint(QPainter::Antialiasing); @@ -293,6 +320,7 @@ void CWeekNumWidget::paintCell(QWidget *cell) painter.drawText(QRect(0, 0, cell->width(), cell->height()), Qt::AlignCenter, dayNum); } else { + // qCDebug(ClientLogger) << "Painting non-selected day cell"; if (isCurrentDay) { painter.setPen(m_backgroundcurrentDayColor); } else { @@ -306,17 +334,21 @@ void CWeekNumWidget::paintCell(QWidget *cell) bool CWeekNumWidget::eventFilter(QObject *o, QEvent *e) { + // qCDebug(ClientLogger) << "Event filter received for object:" << o->objectName() << "with event type:" << e->type(); QWidget *cell = qobject_cast(o); if (cell && m_cellList.contains(cell)) { const int pos = m_cellList.indexOf(cell); //获取每个cell的时间,如果小于1900年则过滤显示和点击操作 - if (!withinTimeFrame( m_days[pos])) + if (!withinTimeFrame(m_days[pos])) { + // qCDebug(ClientLogger) << "Cell is out of time frame, skipping painting"; 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) { + qCDebug(ClientLogger) << "Week number cell clicked at position:" << pos; cellClicked(cell); } } @@ -326,6 +358,7 @@ bool CWeekNumWidget::eventFilter(QObject *o, QEvent *e) void CWeekNumWidget::mousePressEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "Mouse press event received"; QWidget::mousePressEvent(event); m_isFocus = false; } @@ -336,9 +369,13 @@ void CWeekNumWidget::mousePressEvent(QMouseEvent *event) */ void CWeekNumWidget::setSelectedCell(int index) { - if (m_selectedCell == index) + qCDebug(ClientLogger) << "Setting selected cell to index:" << index; + if (m_selectedCell == index) { + qCDebug(ClientLogger) << "Selected cell is already at index:" << index; return; + } + qCDebug(ClientLogger) << "Setting selected cell to index:" << index; const int prevPos = m_selectedCell; m_selectedCell = index; @@ -346,15 +383,19 @@ void CWeekNumWidget::setSelectedCell(int index) m_cellList.at(index)->update(); m_selectDate = m_days[index]; const QString dayNum = QString::number(m_getWeekNumOfYear(m_selectDate)); - if (m_days[index].year() < DDECalendar::QueryEarliestYear && dayNum != "1") + if (m_days[index].year() < DDECalendar::QueryEarliestYear && dayNum != "1") { + qCDebug(ClientLogger) << "Selected date is earlier than earliest queryable year:" << DDECalendar::QueryEarliestYear; return; + } + qCDebug(ClientLogger) << "Emitting signalsSelectDate with date:" << m_days[index].toString(); emit signalsSelectDate(m_days[index]); } void CWeekNumWidget::updateDate() { + qCDebug(ClientLogger) << "Updating dates in CWeekNumWidget based on selected date:" << m_selectDate.toString(); for (int i = 0 ; i < DDEWeekCalendar::NumWeeksDisplayed; ++i) { - m_days[i] = m_selectDate.addDays((i - 4) * DDEWeekCalendar::AFewDaysofWeek); + m_days[i] = m_selectDate.addDays((i - 4) * DDEWeekCalendar::AFewDaysofWeek); if (m_days[i] == m_selectDate) m_selectedCell = i; } @@ -363,15 +404,18 @@ void CWeekNumWidget::updateDate() bool CWeekNumWidget::event(QEvent *e) { + // qCDebug(ClientLogger) << "Event received"; if (e->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = dynamic_cast(e); if (focusWidget() == this) { //如果焦点在该widget上,可以左右键切换时间 if (keyEvent->key() == Qt::Key_Left) { + qCDebug(ClientLogger) << "Left key pressed, triggering previous week"; emit signalBtnPrev(); } if (keyEvent->key() == Qt::Key_Right) { + qCDebug(ClientLogger) << "Right key pressed, triggering next week"; emit signalBtnNext(); } } @@ -381,11 +425,15 @@ bool CWeekNumWidget::event(QEvent *e) void CWeekNumWidget::cellClicked(QWidget *cell) { + // qCDebug(ClientLogger) << "Cell clicked"; const int pos = m_cellList.indexOf(cell); - if (pos == -1) + if (pos == -1) { + qCDebug(ClientLogger) << "Cell clicked at position:" << pos << "is invalid"; return; + } + qCDebug(ClientLogger) << "Cell clicked at position:" << pos << "with date:" << m_days[pos].toString(); setSelectedCell(pos); update(); } diff --git a/calendar-client/src/widget/weekWidget/weekwindow.cpp b/calendar-client/src/widget/weekWidget/weekwindow.cpp index 5eb4f2a6e..f577b3307 100644 --- a/calendar-client/src/widget/weekWidget/weekwindow.cpp +++ b/calendar-client/src/widget/weekWidget/weekwindow.cpp @@ -26,6 +26,7 @@ CWeekWindow::CWeekWindow(QWidget *parent) : CScheduleBaseWidget(parent) , m_today(new CTodayButton) { + qCDebug(ClientLogger) << "CWeekWindow constructed"; setContentsMargins(0, 0, 0, 0); initUI(); initConnection(); @@ -34,7 +35,7 @@ CWeekWindow::CWeekWindow(QWidget *parent) CWeekWindow::~CWeekWindow() { - + qCDebug(ClientLogger) << "CWeekWindow destroyed"; } /** @@ -54,6 +55,7 @@ void CWeekWindow::setLunarVisible(bool state) */ void CWeekWindow::initUI() { + qCDebug(ClientLogger) << "Initializing UI for CWeekWindow"; m_today->setText(QCoreApplication::translate("today", "Today", "Today")); m_today->setFixedSize(DDEWeekCalendar::WTodayWindth, DDEWeekCalendar::WTodayHeight); @@ -162,6 +164,7 @@ void CWeekWindow::initUI() setTabOrder(m_weekview, m_today); setTabOrder(m_today, m_scheduleView); + qCDebug(ClientLogger) << "UI initialization completed for CWeekWindow"; } /** @@ -169,6 +172,7 @@ void CWeekWindow::initUI() */ void CWeekWindow::initConnection() { + qCDebug(ClientLogger) << "Initializing connections for CWeekWindow"; connect(m_today, &CTodayButton::clicked, this, &CWeekWindow::slottoday); //周数信息区域前按钮点击事件关联触发前一周 connect(m_weekview, &CWeekView::signalBtnPrev, this, &CWeekWindow::slotprev); @@ -263,6 +267,7 @@ void CWeekWindow::setSearchWFlag(bool flag) */ void CWeekWindow::updateHeight() { + qCDebug(ClientLogger) << "Updating schedule view height"; m_scheduleView->updateHeight(); } @@ -271,6 +276,7 @@ void CWeekWindow::updateHeight() */ void CWeekWindow::setYearData() { + qCDebug(ClientLogger) << "Setting year data"; if (getSelectDate() == getCurrendDateTime().date()) { m_today->setText(QCoreApplication::translate("today", "Today", "Today")); } else { @@ -321,6 +327,7 @@ void CWeekWindow::updateShowDate(const bool isUpdateBar) */ void CWeekWindow::updateShowSchedule() { + qCDebug(ClientLogger) << "Updating show schedule from" << m_startDate.toString() << "to" << m_stopDate.toString(); m_scheduleView->setShowScheduleInfo(gScheduleManager->getScheduleMap(m_startDate, m_stopDate)); } @@ -329,6 +336,7 @@ void CWeekWindow::updateShowSchedule() */ void CWeekWindow::updateShowLunar() { + qCDebug(ClientLogger) << "Updating show lunar information"; getLunarInfo(); m_YearLunarLabel->setText(m_lunarYear); QMap weekHuangLiInfo = gLunarManager->getHuangLiDayMap(m_startDate, m_stopDate); @@ -337,6 +345,7 @@ void CWeekWindow::updateShowLunar() void CWeekWindow::updateSearchScheduleInfo() { + qCDebug(ClientLogger) << "Updating search schedule information"; m_scheduleView->slotUpdateScene(); } @@ -346,9 +355,7 @@ void CWeekWindow::updateSearchScheduleInfo() */ void CWeekWindow::setSelectSearchScheduleInfo(const DSchedule::Ptr &info) { - qCDebug(ClientLogger) << "Setting selected search schedule" - << "summary:" << info->summary() - << "start:" << info->dtStart(); + qCDebug(ClientLogger) << "Setting selected search schedule"; m_scheduleView->setSelectSchedule(info); } @@ -357,6 +364,7 @@ void CWeekWindow::setSelectSearchScheduleInfo(const DSchedule::Ptr &info) */ void CWeekWindow::deleteselectSchedule() { + qCDebug(ClientLogger) << "Deleting selected schedule"; m_scheduleView->slotDeleteitem(); } @@ -385,11 +393,13 @@ void CWeekWindow::slotViewSelectDate(const QDate &date) void CWeekWindow::slotSwitchPrePage() { + qCDebug(ClientLogger) << "Switching to previous page"; slotprev(); } void CWeekWindow::slotSwitchNextPage() { + qCDebug(ClientLogger) << "Switching to next page"; slotnext(); } @@ -398,8 +408,11 @@ void CWeekWindow::slotSwitchNextPage() */ void CWeekWindow::slotprev() { - if (m_isSwitchStatus) + qCDebug(ClientLogger) << "Switching to previous week"; + if (m_isSwitchStatus) { + qCDebug(ClientLogger) << "Switching to previous week is already in progress"; return; + } qCDebug(ClientLogger) << "Switching to previous week"; m_isSwitchStatus = true; @@ -415,8 +428,11 @@ void CWeekWindow::slotprev() */ void CWeekWindow::slotnext() { - if (m_isSwitchStatus) + qCDebug(ClientLogger) << "Switching to next week"; + if (m_isSwitchStatus) { + qCDebug(ClientLogger) << "Switching to next week is already in progress"; return; + } qCDebug(ClientLogger) << "Switching to next week"; m_isSwitchStatus = true; @@ -457,7 +473,9 @@ void CWeekWindow::slotAngleDelta(int delta) qCDebug(ClientLogger) << "Handling angle delta" << "delta:" << delta; //如果为拖拽状态则退出 if (!m_scheduleView->IsDragging()) { + qCDebug(ClientLogger) << "Not dragging, handling angle delta"; if (delta > 0) { + qCDebug(ClientLogger) << "Delta is positive, switching to previous week"; slotprev(); } else if (delta < 0) { slotnext(); @@ -476,6 +494,7 @@ void CWeekWindow::switchDate(const QDate &date) slotScheduleHide(); //设置选择时间 if (setSelectDate(date, true)) { + qCDebug(ClientLogger) << "Switching date successfully, updating data"; updateData(); } } @@ -495,13 +514,16 @@ void CWeekWindow::slotScheduleHide() */ void CWeekWindow::resizeEvent(QResizeEvent *event) { + // qCDebug(ClientLogger) << "Week window resize event" << "size:" << event->size(); qreal dw = width() * 0.4186 + 0.5; int dh = 36; //添加1个按钮的宽度 36。原来m_weekview 不包含前后按钮(若加2个按钮的宽度,会导致窗口缩小的时候按钮显示不全) if (!m_searchFlag) { + // qCDebug(ClientLogger) << "Setting week view size to:" << qRound(dw + 36) << "x" << dh; m_weekview->setFixedSize(qRound(dw + 36), dh); } else { + // qCDebug(ClientLogger) << "Setting week view size to:" << qRound(dw - 100 + 36) << "x" << dh; m_weekview->setFixedSize(qRound(dw - 100 + 36), dh); } QWidget::resizeEvent(event); @@ -513,6 +535,7 @@ void CWeekWindow::resizeEvent(QResizeEvent *event) */ void CWeekWindow::mousePressEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "Mouse press event received"; Q_UNUSED(event); slotScheduleHide(); } diff --git a/calendar-client/src/widget/yearWidget/yearscheduleview.cpp b/calendar-client/src/widget/yearWidget/yearscheduleview.cpp index d798316a8..acd21982f 100644 --- a/calendar-client/src/widget/yearWidget/yearscheduleview.cpp +++ b/calendar-client/src/widget/yearWidget/yearscheduleview.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include "yearscheduleview.h" +#include "commondef.h" #include "scheduledlg.h" #include "scheduledatamanage.h" @@ -19,16 +20,19 @@ DGUI_USE_NAMESPACE CYearScheduleView::CYearScheduleView(QWidget *parent) : DWidget(parent) { + qCDebug(ClientLogger) << "CYearScheduleView constructed"; m_textfont.setWeight(QFont::Medium); m_textfont.setPixelSize(DDECalendar::FontSizeTwelve); } CYearScheduleView::~CYearScheduleView() { + qCDebug(ClientLogger) << "CYearScheduleView destroyed"; } bool YScheduleDateThan(const DSchedule::Ptr &s1, const DSchedule::Ptr &s2) { + // qCDebug(ClientLogger) << "Comparing schedule dates"; QDate bDate1 = s1->dtStart().date(); QDate eDate1 = s1->dtEnd().date(); QDate bDate2 = s2->dtStart().date(); @@ -50,11 +54,13 @@ bool YScheduleDateThan(const DSchedule::Ptr &s1, const DSchedule::Ptr &s2) } bool YScheduleDaysThan(const DSchedule::Ptr &s1, const DSchedule::Ptr &s2) { + // qCDebug(ClientLogger) << "Comparing schedule days"; return s1->dtStart().date().daysTo(s1->dtEnd().date()) > s2->dtStart().date().daysTo(s2->dtEnd().date()); } void CYearScheduleView::setData(DSchedule::List &vListData) { + qCDebug(ClientLogger) << "Setting data with" << vListData.size() << "schedules"; DSchedule::List valldayListData, vDaylistdata; for (int i = 0; i < vListData.count(); i++) { @@ -74,22 +80,38 @@ void CYearScheduleView::setData(DSchedule::List &vListData) std::sort(vDaylistdata.begin(), vDaylistdata.end(), YScheduleDaysThan); std::sort(vDaylistdata.begin(), vDaylistdata.end(), YScheduleDateThan); + // Fixed: Use a safer approach to move festival schedules to the front + // Collect festival schedules first, then reorganize the list + DSchedule::List festivalSchedules; + DSchedule::List nonFestivalSchedules; + + qCDebug(ClientLogger) << "Processing" << valldayListData.count() << "all-day schedules for festival reorganization"; + for (int i = 0; i < valldayListData.count(); i++) { - DSchedule::List::iterator iter = valldayListData.begin(); - //如果为节假日日程 - if (CScheduleOperation::isFestival(valldayListData.at(i))) { - DSchedule::Ptr moveDate; - moveDate = valldayListData.at(i); - valldayListData.removeAt(i); - valldayListData.insert(iter, moveDate); + DSchedule::Ptr schedule = valldayListData.at(i); + if (CScheduleOperation::isFestival(schedule)) { + //如果为节假日日程 + festivalSchedules.append(schedule); + qCDebug(ClientLogger) << "Found festival schedule, i=" << i; + } else { + nonFestivalSchedules.append(schedule); + qCDebug(ClientLogger) << "Found non-festival schedule, i=" << i; } } + // Rebuild the list with festival schedules at the front + valldayListData.clear(); + valldayListData.append(festivalSchedules); + valldayListData.append(nonFestivalSchedules); + + qCDebug(ClientLogger) << "Reorganized schedules:" << festivalSchedules.count() << "festival schedules moved to front," << nonFestivalSchedules.count() << "regular schedules follow"; + m_vlistData.clear(); m_vlistData.append(valldayListData); m_vlistData.append(vDaylistdata); if (m_vlistData.size() > DDEYearCalendar::YearScheduleListMaxcount) { + qCDebug(ClientLogger) << "Schedule list exceeds max count, truncating to" << DDEYearCalendar::YearScheduleListMaxcount; DSchedule::List vTListData; for (int i = 0; i < 4; i++) { if (m_vlistData.at(i)->dtStart().date() != m_vlistData.at(i)->dtEnd().date() && !m_vlistData.at(i)->allDay()) { @@ -110,25 +132,32 @@ void CYearScheduleView::setData(DSchedule::List &vListData) void CYearScheduleView::clearData() { + qCDebug(ClientLogger) << "Clearing schedule data"; m_vlistData.clear(); } void CYearScheduleView::showWindow() { + qCDebug(ClientLogger) << "Showing window with" << m_vlistData.size() << "schedules"; if (m_vlistData.isEmpty()) { + // qCDebug(ClientLogger) << "Setting fixed size to: 130x45"; setFixedSize(130, 45); } else { + // qCDebug(ClientLogger) << "Updating date show"; updateDateShow(); } } void CYearScheduleView::setTheMe(int type) { + qCDebug(ClientLogger) << "Setting theme to type:" << type; if (type == 0 || type == 1) { + qCDebug(ClientLogger) << "Setting theme to light"; m_btimecolor = "#414D68"; m_btimecolor.setAlphaF(0.7); m_btTextColor = "#414D68"; } else if (type == 2) { + qCDebug(ClientLogger) << "Setting theme to dark"; m_btimecolor = "#C0C6D4"; m_btimecolor.setAlphaF(0.7); m_btTextColor = "#C0C6D4"; @@ -137,22 +166,26 @@ void CYearScheduleView::setTheMe(int type) void CYearScheduleView::setCurrentDate(const QDate &cdate) { + // qCDebug(ClientLogger) << "Setting current date to:" << cdate.toString(); m_currentDate = cdate; } QDate CYearScheduleView::getCurrentDate() { + // qCDebug(ClientLogger) << "Getting current date"; return m_currentDate; } void CYearScheduleView::setTimeFormat(const QString &format) { + // qCDebug(ClientLogger) << "Setting time format to:" << format; m_timeFormat = format; update(); } int CYearScheduleView::getPressScheduleIndex() { + // qCDebug(ClientLogger) << "Getting press schedule index"; int resutle = -1; //获取全局坐标 QPoint currentPos = QCursor::pos(); @@ -165,11 +198,13 @@ int CYearScheduleView::getPressScheduleIndex() break; } } + qCDebug(ClientLogger) << "Press schedule index:" << resutle; return resutle; } void CYearScheduleView::updateDateShow() { + qCDebug(ClientLogger) << "Updating date show"; int sViewNum = 0; if (!m_vlistData.isEmpty()) { if (m_vlistData.size() > DDEYearCalendar::YearScheduleListMaxcount) { @@ -191,12 +226,15 @@ void CYearScheduleView::updateDateShow() void CYearScheduleView::paintEvent(QPaintEvent *event) { + // qCDebug(ClientLogger) << "Paint event received"; Q_UNUSED(event); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; if (m_vlistData.isEmpty()) { + // qCDebug(ClientLogger) << "Painting empty schedule"; paintItem(painter); } else { + // qCDebug(ClientLogger) << "Painting schedule"; for (int i = 0; i < m_vlistData.size(); ++i) { paintItem(painter, m_vlistData.at(i), i); } @@ -205,12 +243,14 @@ void CYearScheduleView::paintEvent(QPaintEvent *event) void CYearScheduleView::paintItem(QPainter &painter, DSchedule::Ptr info, int index) { + // qCDebug(ClientLogger) << "Painting schedule item"; int labelwidth = width() - 30; int bHeight = index * 29 + 10; int labelheight = 28; DSchedule::Ptr &gd = info; if (info->uid() == "-1") { + // qCDebug(ClientLogger) << "Painting '...' item"; QString str = "..."; painter.save(); painter.setPen(m_btimecolor); @@ -218,6 +258,7 @@ void CYearScheduleView::paintItem(QPainter &painter, DSchedule::Ptr info, int in painter.drawText(QRect(25, bHeight, labelwidth - 80, labelheight - 2), Qt::AlignLeft | Qt::AlignVCenter, str); painter.restore(); } else { + // qCDebug(ClientLogger) << "Painting schedule item"; if (info->uid() != "-1") { //圆点m_solocolor QColor gdColor; @@ -281,6 +322,7 @@ void CYearScheduleView::paintItem(QPainter &painter, DSchedule::Ptr info, int in void CYearScheduleView::paintItem(QPainter &painter) { + // qCDebug(ClientLogger) << "Painting empty schedule"; //左边文字 painter.save(); painter.setPen(m_btTextColor); @@ -293,6 +335,7 @@ void CYearScheduleView::paintItem(QPainter &painter) CYearScheduleOutView::CYearScheduleOutView(QWidget *parent) : DArrowRectangle(DArrowRectangle::ArrowLeft, DArrowRectangle::FloatWidget, parent) { + qCDebug(ClientLogger) << "CYearScheduleOutView constructed"; //如果dtk版本为5.3以上则使用新接口 #if (DTK_VERSION > DTK_VERSION_CHECK(5, 3, 0, 0)) //设置显示圆角 @@ -306,6 +349,7 @@ CYearScheduleOutView::CYearScheduleOutView(QWidget *parent) void CYearScheduleOutView::setData(DSchedule::List &vListData) { + qCDebug(ClientLogger) << "Setting data with" << vListData.size() << "schedules in CYearScheduleOutView"; list_count = vListData.size(); yearscheduleview->setData(vListData); yearscheduleview->showWindow(); @@ -319,11 +363,13 @@ void CYearScheduleOutView::setData(DSchedule::List &vListData) void CYearScheduleOutView::clearData() { + qCDebug(ClientLogger) << "Clearing schedule data in CYearScheduleOutView"; yearscheduleview->clearData(); } void CYearScheduleOutView::setTheMe(int type) { + qCDebug(ClientLogger) << "Setting theme to type:" << type << "in CYearScheduleOutView"; yearscheduleview->setTheMe(type); //根据主题设备不一样的背景色 if (type == 2) { @@ -335,6 +381,7 @@ void CYearScheduleOutView::setTheMe(int type) void CYearScheduleOutView::setCurrentDate(const QDate &cDate) { + qCDebug(ClientLogger) << "Setting current date to:" << cDate.toString() << "in CYearScheduleOutView"; currentdate = cDate; yearscheduleview->setCurrentDate(cDate); } @@ -345,6 +392,7 @@ void CYearScheduleOutView::setCurrentDate(const QDate &cDate) */ void CYearScheduleOutView::setDirection(DArrowRectangle::ArrowDirection value) { + qCDebug(ClientLogger) << "Setting arrow direction to:" << value; //设置箭头方向 this->setArrowDirection(value); //设置内容窗口 @@ -353,6 +401,7 @@ void CYearScheduleOutView::setDirection(DArrowRectangle::ArrowDirection value) void CYearScheduleOutView::setTimeFormat(const QString &format) { + qCDebug(ClientLogger) << "Setting time format to:" << format << "in CYearScheduleOutView"; yearscheduleview->setTimeFormat(format); } @@ -361,15 +410,18 @@ void CYearScheduleOutView::mousePressEvent(QMouseEvent *event) Q_UNUSED(event) //获取当前点击的标签编号 int currentIndex = yearscheduleview->getPressScheduleIndex(); + // qCDebug(ClientLogger) << "Mouse press event in CYearScheduleOutView, index:" << currentIndex; if (currentIndex > -1 && currentIndex < scheduleinfoList.size()) { if (currentIndex > 3 && list_count > DDEYearCalendar::YearScheduleListMaxcount) { + qCDebug(ClientLogger) << "Clicked on '...' item, switching to week view for date:" << currentdate.toString(); emit signalsViewSelectDate(currentdate); this->hide(); //跳转到周视图 } else { //如果日程类型不为节假日或纪念日则显示编辑框 if (!CScheduleOperation::isFestival(scheduleinfoList.at(currentIndex))) { + qCDebug(ClientLogger) << "Opening schedule dialog for schedule:" << scheduleinfoList.at(currentIndex)->summary(); //因为提示框会消失,所以设置CScheduleDlg的父类为主窗口 CScheduleDlg dlg(0, qobject_cast(this->parent())); dlg.setData(scheduleinfoList.at(currentIndex)); diff --git a/calendar-client/src/widget/yearWidget/yearview.cpp b/calendar-client/src/widget/yearWidget/yearview.cpp index 94149df6a..ce268516a 100644 --- a/calendar-client/src/widget/yearWidget/yearview.cpp +++ b/calendar-client/src/widget/yearWidget/yearview.cpp @@ -5,6 +5,7 @@ #include "yearview.h" #include "constants.h" #include "configsettings.h" +#include "commondef.h" #include @@ -23,6 +24,7 @@ DGUI_USE_NAMESPACE CYearView::CYearView(QWidget *parent) : CustomFrame(parent) { + qCDebug(ClientLogger) << "CYearView constructed"; //设置焦点类型 setFocusPolicy(Qt::FocusPolicy::TabFocus); setMouseTracking(true); @@ -76,6 +78,7 @@ CYearView::CYearView(QWidget *parent) */ void CYearView::slotDoubleClickDate(const QDate &date) { + qCDebug(ClientLogger) << "Double click on date:" << date.toString(); emit signalMousePress(date, 1); } @@ -85,6 +88,7 @@ void CYearView::slotDoubleClickDate(const QDate &date) */ void CYearView::slotPressClickDate(const QDate &date) { + qCDebug(ClientLogger) << "Press click on date:" << date.toString(); emit signalMousePress(date, 0); } @@ -94,6 +98,7 @@ void CYearView::slotPressClickDate(const QDate &date) */ void CYearView::setTheMe(int type) { + qCDebug(ClientLogger) << "Setting theme to type:" << type; m_themetype = type; if (type == 0 || type == 1) { @@ -112,6 +117,7 @@ void CYearView::setTheMe(int type) void CYearView::setShowMonthDate(const QDate &showMonth) { + qCDebug(ClientLogger) << "Setting show month date to:" << showMonth.toString(); m_showMonthDate = QDate(showMonth.year(), showMonth.month(), 1); m_currentMouth->setTextStr(QLocale::system().monthName(m_showMonthDate.month(), QLocale::ShortFormat)); m_monthView->setShowMonthDate(m_showMonthDate); @@ -130,11 +136,13 @@ QDate CYearView::getShowMonthDate() */ void CYearView::setHasScheduleSet(const QSet &hasScheduleSet) { + qCDebug(ClientLogger) << "Setting has schedule set with" << hasScheduleSet.size() << "dates"; m_monthView->setHasScheduleDateSet(hasScheduleSet); } void CYearView::setHasSearchScheduleSet(const QSet &hasScheduleSet) { + qCDebug(ClientLogger) << "Setting has search schedule set with" << hasScheduleSet.size() << "dates"; m_monthView->setHasSearchScheduleSet(hasScheduleSet); } @@ -149,6 +157,7 @@ bool CYearView::getStartAndStopDate(QDate &startDate, QDate &stopDate) startDate = m_showMonthDate; stopDate = m_showMonthDate.addMonths(1); stopDate = stopDate.addDays(-1); + qCDebug(ClientLogger) << "Getting start and stop date:" << startDate.toString() << "to" << stopDate.toString(); return true; } @@ -160,10 +169,12 @@ bool CYearView::getStartAndStopDate(QDate &startDate, QDate &stopDate) */ bool CYearView::eventFilter(QObject *o, QEvent *e) { + // qCDebug(ClientLogger) << "Event filter received for object:" << o->objectName() << "with event type:" << e->type(); QWidget *cell = qobject_cast(o); if (cell == m_currentMouth) { if (e->type() == QEvent::MouseButtonDblClick) { + qCDebug(ClientLogger) << "Double click on month header, switching to month view for:" << m_showMonthDate.toString(); emit signalMousePress(m_showMonthDate, 2); } } @@ -176,6 +187,7 @@ bool CYearView::eventFilter(QObject *o, QEvent *e) */ void CYearView::resizeEvent(QResizeEvent *event) { + // qCDebug(ClientLogger) << "Resize event with size:" << event->size(); int leftmagin = qFloor(width() * 0.06435 + 0.5); int rightmagin = leftmagin; int topmagin = qFloor(height() * 0.02955 + 0.5); @@ -195,6 +207,7 @@ void CYearView::resizeEvent(QResizeEvent *event) */ void CYearView::paintEvent(QPaintEvent *e) { + // qCDebug(ClientLogger) << "Paint event received"; Q_UNUSED(e); int labelwidth = width() - 2 * m_borderframew; int labelheight = height() - 2 * m_borderframew; @@ -221,6 +234,7 @@ void CYearView::paintEvent(QPaintEvent *e) painter.drawPath(painterPath); if (hasFocus()) { + // qCDebug(ClientLogger) << "Has focus, drawing focus"; //有焦点,绘制焦点 QStyleOptionFocusRect option; option.initFrom(this); diff --git a/calendar-client/src/widget/yearWidget/yearwindow.cpp b/calendar-client/src/widget/yearWidget/yearwindow.cpp index 356bf390c..a05cae6b1 100644 --- a/calendar-client/src/widget/yearWidget/yearwindow.cpp +++ b/calendar-client/src/widget/yearWidget/yearwindow.cpp @@ -8,6 +8,7 @@ #include "schedulesearchview.h" #include "yearscheduleview.h" #include "calendarglobalenv.h" +#include "commondef.h" #include @@ -21,6 +22,7 @@ DGUI_USE_NAMESPACE CYearWindow::CYearWindow(QWidget *parent) : CScheduleBaseWidget(parent) { + qCDebug(ClientLogger) << "CYearWindow constructed"; initUI(); initConnection(); setContentsMargins(0, 0, 0, 0); @@ -36,7 +38,7 @@ CYearWindow::CYearWindow(QWidget *parent) CYearWindow::~CYearWindow() { - + qCDebug(ClientLogger) << "CYearWindow destroyed"; } /** @@ -47,8 +49,10 @@ CYearWindow::~CYearWindow() */ bool CYearWindow::eventFilter(QObject *watched, QEvent *event) { + // qCDebug(ClientLogger) << "Event filter received for object:" << watched->objectName() << "with event type:" << event->type(); if (watched == m_today) { if (event->type() == QEvent::MouseButtonPress) { + qCDebug(ClientLogger) << "Today button pressed"; slottoday(); } if (event->type() == QEvent::KeyPress) { @@ -56,6 +60,7 @@ bool CYearWindow::eventFilter(QObject *watched, QEvent *event) QKeyEvent *key = dynamic_cast(event); if (key->key() == Qt::Key_Return) { //返回今天 + qCDebug(ClientLogger) << "Return key pressed on today button"; slottoday(); } } @@ -65,9 +70,11 @@ bool CYearWindow::eventFilter(QObject *watched, QEvent *event) QKeyEvent *key = dynamic_cast(event); if (key->key() == Qt::Key_Up) { //上一年 + qCDebug(ClientLogger) << "Up key pressed on year widget, switching to previous year"; slotprev(); } else if (key->key() == Qt::Key_Down) { //下一年 + qCDebug(ClientLogger) << "Down key pressed on year widget, switching to next year"; slotnext(); } } @@ -81,8 +88,10 @@ bool CYearWindow::eventFilter(QObject *watched, QEvent *event) */ void CYearWindow::mousePressEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "Mouse press event received"; if (event->source() == Qt::MouseEventSynthesizedByQt) { //如果为触摸点击则记录开始坐标 + // qCDebug(ClientLogger) << "Touch press detected at:" << event->pos(); m_touchBeginPoint = event->pos(); } QWidget::mousePressEvent(event); @@ -94,13 +103,16 @@ void CYearWindow::mousePressEvent(QMouseEvent *event) */ void CYearWindow::resizeEvent(QResizeEvent *event) { + // qCDebug(ClientLogger) << "Year window resize event with size:" << event->size(); Q_UNUSED(event); m_topWidget->setGeometry(0, 0, this->width(), DDEMonthCalendar::M_YTopHeight); } void CYearWindow::mouseMoveEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "Mouse move event received"; if (event->source() == Qt::MouseEventSynthesizedByQt) { + // qCDebug(ClientLogger) << "Touch move detected at:" << event->pos(); return; } QWidget::mouseMoveEvent(event); @@ -108,20 +120,24 @@ void CYearWindow::mouseMoveEvent(QMouseEvent *event) void CYearWindow::mouseReleaseEvent(QMouseEvent *event) { + // qCDebug(ClientLogger) << "Mouse release event received"; if (event->source() == Qt::MouseEventSynthesizedByQt) { //如果为触摸移动状态 if (m_touchState == 2) { //获取停止位置 QPointF stopPoint = event->pos(); + qCDebug(ClientLogger) << "Touch release detected at:" << stopPoint << "with touch state:" << m_touchState; //计算出移动状态 TouchGestureData touchGData = calculateAzimuthAngle(m_touchBeginPoint, stopPoint); //如果方向为上下则切换年份 switch (touchGData.movingDirection) { case TouchGestureData::T_TOP: { + qCDebug(ClientLogger) << "Touch gesture detected: swipe up, switching to next year"; slotnext(); break; } case TouchGestureData::T_BOTTOM: { + qCDebug(ClientLogger) << "Touch gesture detected: swipe down, switching to previous year"; slotprev(); break; } @@ -135,6 +151,7 @@ void CYearWindow::mouseReleaseEvent(QMouseEvent *event) bool CYearWindow::event(QEvent *e) { + // qCDebug(ClientLogger) << "Event received with type:" << e->type(); if (e->type() == QEvent::Gesture) return gestureEvent(dynamic_cast(e)); return QWidget::event(e); @@ -147,6 +164,7 @@ bool CYearWindow::event(QEvent *e) */ bool CYearWindow::gestureEvent(QGestureEvent *event) { + qCDebug(ClientLogger) << "Gesture event received"; if (QGesture *tap = event->gesture(Qt::TapGesture)) tapGestureTriggered(dynamic_cast(tap)); if (QGesture *pan = event->gesture(Qt::PanGesture)) @@ -160,19 +178,24 @@ bool CYearWindow::gestureEvent(QGestureEvent *event) */ void CYearWindow::tapGestureTriggered(QTapGesture *tap) { + qCDebug(ClientLogger) << "Tap gesture triggered with state:" << tap->state(); switch (tap->state()) { case Qt::NoGesture: { + qCDebug(ClientLogger) << "Tap gesture no gesture"; break; } case Qt::GestureStarted: { + qCDebug(ClientLogger) << "Tap gesture started"; m_touchState = 1; break; } case Qt::GestureUpdated: { + qCDebug(ClientLogger) << "Tap gesture updated"; m_touchState = 2; break; } case Qt::GestureFinished: { + qCDebug(ClientLogger) << "Tap gesture finished"; break; } default: { @@ -187,6 +210,7 @@ void CYearWindow::tapGestureTriggered(QTapGesture *tap) */ void CYearWindow::panTriggered(QPanGesture *pan) { + qCDebug(ClientLogger) << "Pan gesture triggered with state:" << pan->state(); switch (pan->state()) { case Qt::GestureFinished: { QPointF zeroPoint(0, 0); @@ -194,10 +218,12 @@ void CYearWindow::panTriggered(QPanGesture *pan) TouchGestureData touchGData = calculateAzimuthAngle(zeroPoint, offset); switch (touchGData.movingDirection) { case TouchGestureData::T_TOP: { + qCDebug(ClientLogger) << "Pan gesture detected: upward movement, switching to next year"; slotnext(); break; } case TouchGestureData::T_BOTTOM: { + qCDebug(ClientLogger) << "Pan gesture detected: downward movement, switching to previous year"; slotprev(); break; } @@ -220,6 +246,7 @@ void CYearWindow::panTriggered(QPanGesture *pan) */ TouchGestureData CYearWindow::calculateAzimuthAngle(QPointF &startPoint, QPointF &stopPoint) { + qCDebug(ClientLogger) << "Calculating azimuth angle from:" << startPoint << "to:" << stopPoint; TouchGestureData _result{}; qreal angle = 0.0000; qreal dx = stopPoint.rx() - startPoint.rx(); @@ -249,6 +276,7 @@ TouchGestureData CYearWindow::calculateAzimuthAngle(QPointF &startPoint, QPoint */ void CYearWindow::initUI() { + qCDebug(ClientLogger) << "Initializing UI for CYearWindow"; m_today = new LabelWidget(this); m_today->setObjectName("yearToDay"); m_today->setAccessibleName("yearToDay"); @@ -371,6 +399,7 @@ void CYearWindow::initUI() m_topWidget->setLayout(yeartitleLayout); m_scheduleView = new CYearScheduleOutView(this); + qCDebug(ClientLogger) << "UI initialization completed for CYearWindow"; } /** @@ -378,6 +407,7 @@ void CYearWindow::initUI() */ void CYearWindow::initConnection() { + qCDebug(ClientLogger) << "Initializing connections for CYearWindow"; connect(m_prevButton, &DIconButton::clicked, this, &CYearWindow::slotprev); connect(m_nextButton, &DIconButton::clicked, this, &CYearWindow::slotnext); connect(m_StackedWidget, &AnimationStackedWidget::signalIsFinished, this, &CYearWindow::setYearData); @@ -392,7 +422,9 @@ void CYearWindow::initConnection() */ void CYearWindow::setTheMe(int type) { + qCDebug(ClientLogger) << "Setting theme to type:" << type; if (type == 0 || type == 1) { + qCDebug(ClientLogger) << "Setting theme to light"; DPalette todayPa = m_today->palette(); todayPa.setColor(DPalette::WindowText, QColor("#000000")); todayPa.setColor(DPalette::Window, Qt::white); @@ -415,6 +447,7 @@ void CYearWindow::setTheMe(int type) m_yearLunarDayLabel->setPalette(LunaPa); m_yearLunarDayLabel->setForegroundRole(DPalette::WindowText); } else if (type == 2) { + qCDebug(ClientLogger) << "Setting theme to dark"; DPalette todayPa = m_today->palette(); todayPa.setColor(DPalette::WindowText, QColor("#C0C6D4")); QColor tbColor = "#414141"; @@ -454,6 +487,7 @@ void CYearWindow::setTheMe(int type) */ void CYearWindow::setSearchWFlag(bool flag) { + // qCDebug(ClientLogger) << "Setting search flag to:" << flag; m_searchFlag = flag; } @@ -462,6 +496,7 @@ void CYearWindow::setSearchWFlag(bool flag) */ void CYearWindow::updateShowDate(const bool isUpdateBar) { + qCDebug(ClientLogger) << "Updating show date, isUpdateBar:" << isUpdateBar; Q_UNUSED(isUpdateBar); m_scheduleView->setTimeFormat((m_calendarManager->getTimeShowType()?"AP ":"") + m_calendarManager->getTimeFormat()); m_yearWidget->setShowDate(getSelectDate()); @@ -472,6 +507,7 @@ void CYearWindow::updateShowDate(const bool isUpdateBar) */ void CYearWindow::updateShowSchedule() { + qCDebug(ClientLogger) << "Updating show schedule data"; //获取显示日期中是否包含日程信息标志 m_yearWidget->setDateHasScheduleSign(ScheduleManager::getInstace()->getAllScheduleDate()); @@ -482,6 +518,7 @@ void CYearWindow::updateShowSchedule() */ void CYearWindow::updateShowLunar() { + qCDebug(ClientLogger) << "Updating show lunar information"; //获取农历信息 getLunarInfo(); m_yearWidget->setLunarYearDate(m_lunarYear); @@ -496,6 +533,7 @@ void CYearWindow::updateShowLunar() */ void CYearWindow::updateSearchScheduleInfo() { + qCDebug(ClientLogger) << "Updating search schedule information"; //获取搜索日程信息 m_yearWidget->setSearchSchedule(gScheduleManager->getAllSearchedScheduleDate()); } @@ -506,6 +544,7 @@ void CYearWindow::updateSearchScheduleInfo() */ void CYearWindow::setSelectSearchScheduleInfo(const DSchedule::Ptr &info) { + // qCDebug(ClientLogger) << "Setting selected search schedule info:" << (info ? info->uid() : "null"); Q_UNUSED(info); } @@ -514,6 +553,7 @@ void CYearWindow::setSelectSearchScheduleInfo(const DSchedule::Ptr &info) */ void CYearWindow::slotSetScheduleHide() { + // qCDebug(ClientLogger) << "Hiding schedule view"; m_scheduleView->hide(); } @@ -522,6 +562,7 @@ void CYearWindow::slotSetScheduleHide() */ void CYearWindow::slotprev() { + qCDebug(ClientLogger) << "Switching to previous year"; QDate minYear = getSelectDate(); if (minYear.year() > 1900) { @@ -534,6 +575,7 @@ void CYearWindow::slotprev() */ void CYearWindow::slotnext() { + qCDebug(ClientLogger) << "Switching to next year"; QDate maxYear = getSelectDate(); if (maxYear.year() < 2100) { @@ -546,6 +588,7 @@ void CYearWindow::slotnext() */ void CYearWindow::slottoday() { + qCDebug(ClientLogger) << "Returning to today"; //隐藏提示 slotSetScheduleHide(); //设置选择时间为当前时间,切换年份信息 @@ -561,6 +604,7 @@ void CYearWindow::slottoday() */ void CYearWindow::switchYear(const int offsetYear) { + qCDebug(ClientLogger) << "Switching year with offset:" << offsetYear; slotSetScheduleHide(); //获取选择时间 QDate _selectData = getSelectDate(); @@ -595,6 +639,7 @@ void CYearWindow::switchYear(const int offsetYear) */ void CYearWindow::setLunarShow() { + qCDebug(ClientLogger) << "Setting lunar show with year:" << m_lunarYear << "day:" << m_lunarDay; m_yearLunarLabel->setText(m_lunarYear); m_yearLunarDayLabel->setText(m_lunarDay); } @@ -604,6 +649,7 @@ void CYearWindow::setLunarShow() */ void CYearWindow::setYearData() { + qCDebug(ClientLogger) << "Setting year data for date:" << getSelectDate().toString(); //如果选择日期为本地时间日期则显示今天,否则显示返回当天 if (getSelectDate() == getCurrendDateTime().date()) { m_today->setText(QCoreApplication::translate("today", "Today", "Today")); @@ -630,6 +676,7 @@ void CYearWindow::setYearData() */ void CYearWindow::slotMousePress(const QDate &selectDate, const int pressType) { + qCDebug(ClientLogger) << "Mouse press on date:" << selectDate.toString() << "with press type:" << pressType; slotSetScheduleHide(); if (!selectDate.isValid()) return; @@ -639,6 +686,7 @@ void CYearWindow::slotMousePress(const QDate &selectDate, const int pressType) switch (pressType) { case 0: { // 0:单击 + qCDebug(ClientLogger) << "Single click, showing schedule view"; DSchedule::List _scheduleInfo {}; //获取选择日期的日程信息 _scheduleInfo = gScheduleManager->getScheduleByDay(selectDate); @@ -654,10 +702,12 @@ void CYearWindow::slotMousePress(const QDate &selectDate, const int pressType) // 根据鼠标位置,决定悬浮框显示位置 if (rPos.x() < this->width() / 2) { // 显示到右侧 + qCDebug(ClientLogger) << "Showing schedule view on right side"; m_scheduleView->setDirection(DArrowRectangle::ArrowLeft); m_scheduleView->show(rPos.x()+10, rPos.y()); } else { // 显示到左侧 + qCDebug(ClientLogger) << "Showing schedule view on left side"; m_scheduleView->setDirection(DArrowRectangle::ArrowRight); m_scheduleView->show(rPos.x()-10, rPos.y()); } @@ -666,16 +716,19 @@ void CYearWindow::slotMousePress(const QDate &selectDate, const int pressType) } case 1: { // 1:双击时间 + qCDebug(ClientLogger) << "Double click on date, switching to day view"; signalSwitchView(); break; } case 2: { // 2: 双击月 + qCDebug(ClientLogger) << "Double click on month, switching to month view"; signalSwitchView(1); break; } case 3: { // 3: 提示框跳转周视图 + qCDebug(ClientLogger) << "Schedule view action, switching to week view"; signalSwitchView(2); break; } @@ -690,12 +743,17 @@ void CYearWindow::slotMousePress(const QDate &selectDate, const int pressType) */ void CYearWindow::wheelEvent(QWheelEvent *event) { + // qCDebug(ClientLogger) << "Wheel event with delta y:" << event->angleDelta().y(); //如果为左右方向则退出 - if (event->angleDelta().x() != 0 ) + if (event->angleDelta().x() != 0 ) { + // qCDebug(ClientLogger) << "return from Wheel event with delta x:" << event->angleDelta().x(); return; + } if (event->angleDelta().y() < 0) { + qCDebug(ClientLogger) << "Wheel event next"; slotnext(); } else { + qCDebug(ClientLogger) << "Wheel event prev"; slotprev(); } } @@ -703,6 +761,7 @@ void CYearWindow::wheelEvent(QWheelEvent *event) YearFrame::YearFrame(DWidget *parent) : QWidget(parent) { + qCDebug(ClientLogger) << "YearFrame constructed"; QGridLayout *gridLayout = new QGridLayout; gridLayout->setContentsMargins(0, 0, 0, 0); gridLayout->setSpacing(8); @@ -769,7 +828,7 @@ YearFrame::YearFrame(DWidget *parent) YearFrame::~YearFrame() { - + qCDebug(ClientLogger) << "YearFrame destroyed"; } /** @@ -779,6 +838,7 @@ YearFrame::~YearFrame() */ void YearFrame::setShowDate(const QDate &selectDate) { + qCDebug(ClientLogger) << "Setting show date for YearFrame to:" << selectDate.toString(); QDate _showMonth(selectDate.year(), 1, 1); for (int i = 0; i < DDEYearCalendar::FrameSizeOfEveryYear; i++) { QDate _setShowMonth = _showMonth.addMonths(i); @@ -797,6 +857,7 @@ void YearFrame::setShowDate(const QDate &selectDate) */ void YearFrame::setLunarYearDate(const QString &lunar) { + qCDebug(ClientLogger) << "Setting lunar year date to:" << lunar; m_YearLunarLabel->setText(lunar); } @@ -806,6 +867,7 @@ void YearFrame::setLunarYearDate(const QString &lunar) */ void YearFrame::setDateHasScheduleSign(const QSet &hasSchedule) { + qCDebug(ClientLogger) << "Setting date has schedule sign with" << hasSchedule.size() << "dates"; QDate _startDate; QDate _stopDate; QDate _getDate; @@ -833,7 +895,9 @@ void YearFrame::setDateHasScheduleSign(const QSet &hasSchedule) */ void YearFrame::setTheMe(int type) { + qCDebug(ClientLogger) << "Setting theme for YearFrame to type:" << type; if (type == 0 || type == 1) { + qCDebug(ClientLogger) << "Setting theme to light"; DPalette gpa = palette(); gpa.setColor(DPalette::Window, "#F8F8F8"); setPalette(gpa); @@ -849,6 +913,7 @@ void YearFrame::setTheMe(int type) m_YearLunarLabel->setPalette(LunaPa); m_YearLunarLabel->setForegroundRole(DPalette::WindowText); } else if (type == 2) { + qCDebug(ClientLogger) << "Setting theme to dark"; DPalette gpa = palette(); gpa.setColor(DPalette::Window, "#252525"); setPalette(gpa); @@ -875,6 +940,7 @@ void YearFrame::setTheMe(int type) */ void YearFrame::setSearchSchedule(const QSet &hasSchedule) { + qCDebug(ClientLogger) << "Setting search schedule with" << hasSchedule.size() << "dates"; QDate _startDate; QDate _stopDate; QDate _getDate; @@ -904,6 +970,7 @@ void YearFrame::setSearchSchedule(const QSet &hasSchedule) */ void YearFrame::setViewFocus(int index) { + qCDebug(ClientLogger) << "Setting view focus to index:" << index; if (index >= 0 && index < m_monthViewList.size()) { //设置选中view的焦点类型 m_monthViewList.at(index)->setFocus(Qt::FocusReason::TabFocusReason); @@ -916,6 +983,7 @@ void YearFrame::setViewFocus(int index) */ int YearFrame::getViewFocusIndex() { + // qCDebug(ClientLogger) << "Getting view focus index:" << currentFocusView; return currentFocusView; } @@ -924,10 +992,13 @@ int YearFrame::getViewFocusIndex() */ void YearFrame::setYearShow() { + qCDebug(ClientLogger) << "Setting year show for year:" << m_selectDate.year(); if (QLocale::system().language() == QLocale::Chinese) { + qCDebug(ClientLogger) << "Setting year show for year:" << m_selectDate.year() << "in Chinese"; m_YearLabel->setText(QString::number(m_selectDate.year()) + tr("Y")); m_YearLunarLabel->setText(m_LunarYear); } else { + qCDebug(ClientLogger) << "Setting year show for year:" << m_selectDate.year() << "in English"; m_YearLabel->setText(QString::number(m_selectDate.year())); m_YearLunarLabel->setText(""); } @@ -938,13 +1009,16 @@ void YearFrame::setYearShow() */ bool YearFrame::eventFilter(QObject *watched, QEvent *event) { + // qCDebug(ClientLogger) << "Event filter received for object:" << watched->objectName() << "with event type:" << event->type(); //返回当前活动窗口中的焦点小部件 CYearView *monthview = qobject_cast(QApplication::focusWidget()); //焦点小部件是否为12个月份中的一个 if (m_monthViewList.contains(monthview)) { //焦点小部件在list中的index currentFocusView = m_monthViewList.indexOf(monthview); + // qCDebug(ClientLogger) << "Focus changed to month view index:" << currentFocusView; } else { + // qCDebug(ClientLogger) << "Focus changed to none"; currentFocusView = -1; } return QWidget::eventFilter(watched, event); diff --git a/calendar-common/src/dschedulequerypar.cpp b/calendar-common/src/dschedulequerypar.cpp index 3f8c06dee..931d86fcc 100644 --- a/calendar-common/src/dschedulequerypar.cpp +++ b/calendar-common/src/dschedulequerypar.cpp @@ -116,9 +116,11 @@ QString DScheduleQueryPar::toJsonString(const DScheduleQueryPar::Ptr &queryPar) jsonObj.insert("queryType", queryPar->queryType()); switch (queryPar->queryType()) { case Query_Top: + // qCDebug(CommonLogger) << "Querying top" << queryPar->queryTop(); jsonObj.insert("queryTop", queryPar->queryTop()); break; case Query_RRule: + // qCDebug(CommonLogger) << "Querying rrule" << queryPar->rruleType(); jsonObj.insert("queryRRule", queryPar->rruleType()); break; default: