Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions calendar-client/src/KeyPress/calldaykeyleftdeal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,28 @@

#include "calldaykeyleftdeal.h"

#include "graphicsItem/cweekdaybackgrounditem.h"

Check warning on line 7 in calendar-client/src/KeyPress/calldaykeyleftdeal.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "graphicsItem/cweekdaybackgrounditem.h" not found.

Check warning on line 7 in calendar-client/src/KeyPress/calldaykeyleftdeal.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "graphicsItem/cweekdaybackgrounditem.h" not found.
#include "cgraphicsscene.h"

Check warning on line 8 in calendar-client/src/KeyPress/calldaykeyleftdeal.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "cgraphicsscene.h" not found.

Check warning on line 8 in calendar-client/src/KeyPress/calldaykeyleftdeal.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "cgraphicsscene.h" not found.
#include "commondef.h"

Check warning on line 9 in calendar-client/src/KeyPress/calldaykeyleftdeal.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "commondef.h" not found.

Check warning on line 9 in calendar-client/src/KeyPress/calldaykeyleftdeal.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "commondef.h" not found.

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<CWeekDayBackgroundItem *>(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;
Expand Down
5 changes: 5 additions & 0 deletions calendar-client/src/KeyPress/calldaykeyrightdeal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,28 @@

#include "calldaykeyrightdeal.h"

#include "graphicsItem/cweekdaybackgrounditem.h"

Check warning on line 7 in calendar-client/src/KeyPress/calldaykeyrightdeal.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "graphicsItem/cweekdaybackgrounditem.h" not found.

Check warning on line 7 in calendar-client/src/KeyPress/calldaykeyrightdeal.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "graphicsItem/cweekdaybackgrounditem.h" not found.
#include "cgraphicsscene.h"

Check warning on line 8 in calendar-client/src/KeyPress/calldaykeyrightdeal.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "cgraphicsscene.h" not found.

Check warning on line 8 in calendar-client/src/KeyPress/calldaykeyrightdeal.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "cgraphicsscene.h" not found.
#include "commondef.h"

Check warning on line 9 in calendar-client/src/KeyPress/calldaykeyrightdeal.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "commondef.h" not found.

Check warning on line 9 in calendar-client/src/KeyPress/calldaykeyrightdeal.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "commondef.h" not found.

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<CWeekDayBackgroundItem *>(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;
Expand Down
5 changes: 5 additions & 0 deletions calendar-client/src/KeyPress/ckeydowndeal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,28 @@

#include "ckeydowndeal.h"

#include "graphicsItem/cscenebackgrounditem.h"

Check warning on line 7 in calendar-client/src/KeyPress/ckeydowndeal.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "graphicsItem/cscenebackgrounditem.h" not found.

Check warning on line 7 in calendar-client/src/KeyPress/ckeydowndeal.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "graphicsItem/cscenebackgrounditem.h" not found.
#include "cgraphicsscene.h"

Check warning on line 8 in calendar-client/src/KeyPress/ckeydowndeal.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "cgraphicsscene.h" not found.

Check warning on line 8 in calendar-client/src/KeyPress/ckeydowndeal.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "cgraphicsscene.h" not found.
#include "commondef.h"

Check warning on line 9 in calendar-client/src/KeyPress/ckeydowndeal.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "commondef.h" not found.

Check warning on line 9 in calendar-client/src/KeyPress/ckeydowndeal.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "commondef.h" not found.

#include <QDebug>

Check warning on line 11 in calendar-client/src/KeyPress/ckeydowndeal.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDebug> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 11 in calendar-client/src/KeyPress/ckeydowndeal.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QDebug> not found. Please note: Cppcheck does not need standard library headers to get proper results.

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;
Expand Down
13 changes: 13 additions & 0 deletions calendar-client/src/KeyPress/ckeyenabledeal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
#include "graphicsItem/cscenebackgrounditem.h"
#include "graphicsItem/draginfoitem.h"
#include "myscheduleview.h"
#include "commondef.h"

#include <QGraphicsView>

CKeyEnableDeal::CKeyEnableDeal(QGraphicsScene *scene)
: CKeyPressDealBase(Qt::Key_Return, scene)
{
qCDebug(ClientLogger) << "CKeyEnableDeal constructor initialized";
}

/**
Expand All @@ -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<CSceneBackgroundItem *>(focusItem);
if (backgroundItem != nullptr) {
QDateTime createDateTime;
Expand All @@ -39,26 +44,33 @@ 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));
}
}
createSchedule(createDateTime, parentWidget);
}
} break;
case CFocusItem::CITEM: {
qCDebug(ClientLogger) << "Processing schedule item type";
DragInfoItem *scheduleItem = dynamic_cast<DragInfoItem *>(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;
}
Expand All @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions calendar-client/src/KeyPress/ckeyleftdeal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,26 @@

#include "graphicsItem/cscenebackgrounditem.h"
#include "cgraphicsscene.h"
#include "commondef.h"

#include <QDebug>

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;
Expand Down
7 changes: 7 additions & 0 deletions calendar-client/src/KeyPress/ckeypressdealbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand All @@ -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<CGraphicsScene *>(m_scene);
if (scene != nullptr) {
CSceneBackgroundItem *item = dynamic_cast<CSceneBackgroundItem *>(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;
}
27 changes: 23 additions & 4 deletions calendar-client/src/KeyPress/ckeypressprxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "ckeypressprxy.h"
#include "commondef.h"

#include <QDebug>

CKeyPressPrxy::CKeyPressPrxy()
{
qCDebug(ClientLogger) << "CKeyPressPrxy constructor initialized";
}

CKeyPressPrxy::~CKeyPressPrxy()
{
qCDebug(ClientLogger) << "CKeyPressPrxy destructor called, cleaning up" << m_keyEventMap.size() << "key handlers";
QMap<int, CKeyPressDealBase *>::iterator iter = m_keyEventMap.begin();
for (; iter != m_keyEventMap.end(); ++iter) {
delete iter.value();
Expand All @@ -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;
}
Expand All @@ -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";
}
}

/**
Expand All @@ -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";
}
}
5 changes: 5 additions & 0 deletions calendar-client/src/KeyPress/ckeyrightdeal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,26 @@

#include "graphicsItem/cscenebackgrounditem.h"
#include "cgraphicsscene.h"
#include "commondef.h"

#include <QDebug>

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;
Expand Down
5 changes: 5 additions & 0 deletions calendar-client/src/KeyPress/ckeyupdeal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,26 @@

#include "graphicsItem/cscenebackgrounditem.h"
#include "cgraphicsscene.h"
#include "commondef.h"

#include <QDebug>

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;
Expand Down
6 changes: 6 additions & 0 deletions calendar-client/src/KeyPress/cscenetabkeydeal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,32 @@

#include "graphicsItem/cscenebackgrounditem.h"
#include "cgraphicsscene.h"
#include "commondef.h"

#include <QDebug>
#include <QGraphicsView>

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<CSceneBackgroundItem *>(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);
Expand Down
Loading
Loading