forked from linuxdeepin/dde-calendar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathckeyenabledeal.cpp
More file actions
90 lines (85 loc) · 3.57 KB
/
ckeyenabledeal.cpp
File metadata and controls
90 lines (85 loc) · 3.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// SPDX-FileCopyrightText: 2019 - 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later
#include "ckeyenabledeal.h"
#include "cgraphicsscene.h"
#include "scheduledlg.h"
#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";
}
/**
* @brief CKeyEnableDeal::focusItemDeal 焦点项处理
* @param item
* @param scene
* @return
*/
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;
//设置创建时间
createDateTime.setDate(backgroundItem->getDate());
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;
}
/**
* @brief CKeyEnableDeal::createSchedule 创建日程
* @param createDate
* @param parent
*/
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);
dlg.exec();
}