Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
Kalendar
Commits
95b2a5f5
Commit
95b2a5f5
authored
Nov 12, 2021
by
Claudio Cambra
Browse files
Dragged incidences now correctly return to where they were when dragged into non-droparea space
parent
8663afd7
Pipeline
#96645
canceled with stage
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/contents/ui/MonthView.qml
View file @
95b2a5f5
...
...
@@ -151,6 +151,7 @@ Kirigami.Page {
width
:
pathView
.
width
height
:
pathView
.
height
model
:
monthViewModel
// from monthPage model
isCurrentView
:
viewLoader
.
isCurrentItem
startDate
:
viewLoader
.
startDate
currentDate
:
monthPage
.
currentDate
...
...
src/contents/ui/MultiDayView.qml
View file @
95b2a5f5
...
...
@@ -44,6 +44,7 @@ Item {
property
Component
weekHeaderDelegate
property
int
month
property
alias
bgLoader
:
backgroundLoader
.
item
property
bool
isCurrentView
:
true
//Internal
property
int
numberOfLinesShown
:
0
...
...
@@ -157,19 +158,19 @@ Item {
id
:
incidenceDropArea
anchors.fill
:
parent
z
:
9999
onDropped
:
{
onDropped
:
if
(
root
.
isCurrentView
)
{
const
pos
=
mapToItem
(
root
,
backgroundRectangle
.
x
,
backgroundRectangle
.
y
);
drop
.
source
.
caughtX
=
pos
.
x
+
root
.
listViewSpacing
;
drop
.
source
.
caughtY
=
root
.
showDayIndicator
?
pos
.
y
+
Kirigami
.
Units
.
gridUnit
+
Kirigami
.
Units
.
largeSpacing
*
1.5
:
pos
.
y
;
drop
.
source
.
caught
=
true
;
const
incidenceWrapper
=
Qt
.
createQmlObject
(
'
import org.kde.kalendar 1.0; IncidenceWrapper {id: incidence}
'
,
incidenceDropArea
,
"
incidence
"
);
incidenceWrapper
.
incidencePtr
=
drop
.
source
.
incidencePtr
;
incidenceWrapper
.
collectionId
=
drop
.
source
.
collectionId
;
incidenceWrapper
.
setIncidenceStartDate
(
backgroundDayMouseArea
.
addDate
.
getDate
(),
backgroundDayMouseArea
.
addDate
.
getMonth
()
+
1
,
backgroundDayMouseArea
.
addDate
.
getFullYear
());
Kalendar
.
CalendarManager
.
editIncidence
(
incidenceWrapper
);
const
pos
=
mapToItem
(
root
,
backgroundRectangle
.
x
,
backgroundRectangle
.
y
);
drop
.
source
.
x
=
pos
.
x
+
root
.
listViewSpacing
;
drop
.
source
.
y
=
root
.
showDayIndicator
?
pos
.
y
+
Kirigami
.
Units
.
gridUnit
+
Kirigami
.
Units
.
largeSpacing
*
1.5
:
pos
.
y
;
drop
.
source
.
opacity
=
0
;
}
}
}
...
...
@@ -306,17 +307,24 @@ Item {
Drag.active
:
mouseArea
.
drag
.
active
Connections
{
target
:
incidenceDelegate
.
mouseArea
.
drag
function
onActiveChanged
()
{
// We can destructively set a bunch of properties as the model
// will reset anyway. If you change the model behaviour you WILL
// need to change how this works.
incidenceDelegate
.
parent
=
root
;
incidenceDelegate
.
repositionAnimationEnabled
=
true
;
incidenceDelegate
.
isOpenOccurrence
=
true
;
states
:
[
State
{
when
:
incidenceDelegate
.
mouseArea
.
drag
.
active
ParentChange
{
target
:
incidenceDelegate
;
parent
:
root
}
PropertyChanges
{
target
:
incidenceDelegate
;
isOpenOccurrence
:
true
}
},
State
{
when
:
incidenceDelegate
.
caught
ParentChange
{
target
:
incidenceDelegate
;
parent
:
root
}
PropertyChanges
{
target
:
incidenceDelegate
repositionAnimationEnabled
:
true
x
:
caughtX
y
:
caughtY
opacity
:
0
}
}
}
]
}
}
}
...
...
src/contents/ui/MultiDayViewIncidenceDelegate.qml
View file @
95b2a5f5
...
...
@@ -57,6 +57,9 @@ Rectangle {
property
var
incidencePtr
:
modelData
.
incidencePtr
property
var
collectionId
:
modelData
.
collectionId
property
bool
repositionAnimationEnabled
:
false
property
bool
caught
:
false
property
real
caughtX
:
0
property
real
caughtY
:
0
IncidenceBackground
{
id
:
incidenceBackground
...
...
src/contents/ui/ScheduleView.qml
View file @
95b2a5f5
...
...
@@ -224,7 +224,12 @@ Kirigami.Page {
id
:
incidenceDropArea
anchors.fill
:
parent
z
:
9999
onDropped
:
{
onDropped
:
if
(
viewLoader
.
isCurrentItem
)
{
const
pos
=
mapToItem
(
root
,
backgroundRectangle
.
x
,
backgroundRectangle
.
y
);
drop
.
source
.
caughtX
=
pos
.
x
+
dayGrid
.
dayLabelWidth
+
Kirigami
.
Units
.
largeSpacing
;
drop
.
source
.
caughtY
=
pos
.
y
+
dayColumn
.
spacing
+
Kirigami
.
Units
.
largeSpacing
;
drop
.
source
.
caught
=
true
;
root
.
selectedDate
=
dayMouseArea
.
addDate
;
const
incidenceWrapper
=
Qt
.
createQmlObject
(
'
import org.kde.kalendar 1.0; IncidenceWrapper {id: incidence}
'
,
incidenceDropArea
,
"
incidence
"
);
...
...
@@ -232,11 +237,6 @@ Kirigami.Page {
incidenceWrapper
.
collectionId
=
drop
.
source
.
collectionId
;
incidenceWrapper
.
setIncidenceStartDate
(
dayMouseArea
.
addDate
.
getDate
(),
dayMouseArea
.
addDate
.
getMonth
()
+
1
,
dayMouseArea
.
addDate
.
getFullYear
());
Kalendar
.
CalendarManager
.
editIncidence
(
incidenceWrapper
);
const
pos
=
mapToItem
(
root
,
backgroundRectangle
.
x
,
backgroundRectangle
.
y
);
drop
.
source
.
x
=
pos
.
x
+
dayGrid
.
dayLabelWidth
+
Kirigami
.
Units
.
largeSpacing
;
drop
.
source
.
y
=
pos
.
y
+
dayColumn
.
spacing
+
Kirigami
.
Units
.
largeSpacing
;
drop
.
source
.
opacity
=
0
;
}
}
...
...
@@ -374,6 +374,9 @@ Kirigami.Page {
property
var
incidencePtr
:
modelData
.
incidencePtr
property
var
collectionId
:
modelData
.
collectionId
property
bool
repositionAnimationEnabled
:
false
property
bool
caught
:
false
property
real
caughtX
:
0
property
real
caughtY
:
0
Layout.fillWidth
:
true
topPadding
:
paddingSize
...
...
@@ -407,17 +410,24 @@ Kirigami.Page {
Drag.active
:
mouseArea
.
drag
.
active
Connections
{
target
:
incidenceCard
.
mouseArea
.
drag
function
onActiveChanged
()
{
// We can destructively set a bunch of properties as the model
// will reset anyway. If you change the model behaviour you WILL
// need to change how this works.
incidenceCard
.
parent
=
root
;
incidenceCard
.
repositionAnimationEnabled
=
true
;
incidenceCard
.
isOpenOccurrence
=
true
;
states
:
[
State
{
when
:
incidenceCard
.
mouseArea
.
drag
.
active
ParentChange
{
target
:
incidenceCard
;
parent
:
root
}
PropertyChanges
{
target
:
incidenceCard
;
isOpenOccurrence
:
true
}
},
State
{
when
:
incidenceCard
.
caught
ParentChange
{
target
:
incidenceCard
;
parent
:
root
}
PropertyChanges
{
target
:
incidenceCard
repositionAnimationEnabled
:
true
x
:
caughtX
y
:
caughtY
opacity
:
0
}
}
}
]
contentItem
:
GridLayout
{
id
:
cardContents
...
...
src/contents/ui/WeekView.qml
View file @
95b2a5f5
...
...
@@ -431,17 +431,17 @@ Kirigami.Page {
id
:
incidenceDropArea
anchors.fill
:
parent
z
:
9999
onDropped
:
{
onDropped
:
if
(
viewLoader
.
isCurrentItem
)
{
const
pos
=
mapToItem
(
root
,
x
,
y
);
drop
.
source
.
caughtX
=
pos
.
x
+
root
.
incidenceSpacing
;
drop
.
source
.
caughtY
=
pos
.
y
;
drop
.
source
.
caught
=
true
;
const
incidenceWrapper
=
Qt
.
createQmlObject
(
'
import org.kde.kalendar 1.0; IncidenceWrapper {id: incidence}
'
,
incidenceDropArea
,
"
incidence
"
);
incidenceWrapper
.
incidencePtr
=
drop
.
source
.
incidencePtr
;
incidenceWrapper
.
collectionId
=
drop
.
source
.
collectionId
;
incidenceWrapper
.
setIncidenceStartDate
(
listViewMenu
.
addDate
.
getDate
(),
listViewMenu
.
addDate
.
getMonth
()
+
1
,
listViewMenu
.
addDate
.
getFullYear
());
Kalendar
.
CalendarManager
.
editIncidence
(
incidenceWrapper
);
const
pos
=
mapToItem
(
root
,
x
,
y
);
drop
.
source
.
x
=
pos
.
x
+
root
.
incidenceSpacing
;
drop
.
source
.
y
=
pos
.
y
;
drop
.
source
.
opacity
=
0
;
}
}
}
...
...
@@ -473,17 +473,23 @@ Kirigami.Page {
Drag.active
:
mouseArea
.
drag
.
active
Connections
{
target
:
incidenceDelegate
.
mouseArea
.
drag
function
onActiveChanged
()
{
// We can destructively set a bunch of properties as the model
// will reset anyway. If you change the model behaviour you WILL
// need to change how this works.
incidenceDelegate
.
parent
=
root
;
incidenceDelegate
.
repositionAnimationEnabled
=
true
;
incidenceDelegate
.
isOpenOccurrence
=
true
;
states
:
[
State
{
when
:
incidenceDelegate
.
mouseArea
.
drag
.
active
ParentChange
{
target
:
incidenceDelegate
;
parent
:
root
}
PropertyChanges
{
target
:
incidenceDelegate
;
isOpenOccurrence
:
true
}
},
State
{
when
:
incidenceDelegate
.
caught
ParentChange
{
target
:
incidenceDelegate
;
parent
:
root
}
PropertyChanges
{
target
:
incidenceDelegate
repositionAnimationEnabled
:
true
x
:
caughtX
y
:
caughtY
}
}
}
]
}
}
}
...
...
@@ -721,18 +727,18 @@ Kirigami.Page {
Layout.fillWidth
:
true
Layout.fillHeight
:
true
z
:
9999
onDropped
:
{
onDropped
:
if
(
viewLoader
.
isCurrentItem
)
{
const
pos
=
mapToItem
(
root
,
dropAreaHighlightRectangle
.
x
,
dropAreaHighlightRectangle
.
y
);
drop
.
source
.
caughtX
=
pos
.
x
+
incidenceSpacing
;
drop
.
source
.
caughtY
=
pos
.
y
+
incidenceSpacing
;
drop
.
source
.
caught
=
true
;
let
incidenceWrapper
=
Qt
.
createQmlObject
(
'
import org.kde.kalendar 1.0; IncidenceWrapper {id: incidence}
'
,
incidenceDropArea
,
"
incidence
"
);
incidenceWrapper
.
incidencePtr
=
drop
.
source
.
incidencePtr
;
incidenceWrapper
.
collectionId
=
drop
.
source
.
collectionId
;
incidenceWrapper
.
setIncidenceStartDate
(
backgroundDayMouseArea
.
addDate
.
getDate
(),
backgroundDayMouseArea
.
addDate
.
getMonth
()
+
1
,
backgroundDayMouseArea
.
addDate
.
getFullYear
());
incidenceWrapper
.
setIncidenceStartTime
(
backgroundRectangle
.
index
,
dropAreaRepeater
.
minutes
*
index
)
Kalendar
.
CalendarManager
.
editIncidence
(
incidenceWrapper
);
const
pos
=
mapToItem
(
root
,
dropAreaHighlightRectangle
.
x
,
dropAreaHighlightRectangle
.
y
);
//drop.source.parent = this;
drop
.
source
.
x
=
pos
.
x
+
incidenceSpacing
;
drop
.
source
.
y
=
pos
.
y
+
incidenceSpacing
;
}
Rectangle
{
...
...
@@ -779,6 +785,9 @@ Kirigami.Page {
property
var
incidencePtr
:
modelData
.
incidencePtr
property
var
collectionId
:
modelData
.
collectionId
property
bool
repositionAnimationEnabled
:
false
property
bool
caught
:
false
property
real
caughtX
:
0
property
real
caughtY
:
0
// Drag reposition animations -- when the incidence goes to the correct cell of the monthgrid
Behavior
on
x
{
...
...
@@ -797,6 +806,24 @@ Kirigami.Page {
}
}
states
:
[
State
{
when
:
incidenceDelegate
.
mouseArea
.
drag
.
active
ParentChange
{
target
:
incidenceDelegate
;
parent
:
root
}
PropertyChanges
{
target
:
incidenceDelegate
;
isOpenOccurrence
:
true
}
},
State
{
when
:
incidenceDelegate
.
caught
ParentChange
{
target
:
incidenceDelegate
;
parent
:
root
}
PropertyChanges
{
target
:
incidenceDelegate
repositionAnimationEnabled
:
true
x
:
caughtX
y
:
caughtY
}
}
]
IncidenceBackground
{
id
:
incidenceBackground
isOpenOccurrence
:
parent
.
isOpenOccurrence
...
...
@@ -882,18 +909,6 @@ Kirigami.Page {
}
Drag.active
:
mouseArea
.
drag
.
active
Connections
{
target
:
incidenceDelegate
.
mouseArea
.
drag
function
onActiveChanged
()
{
// We can destructively set a bunch of properties as the model
// will reset anyway. If you change the model behaviour you WILL
// need to change how this works.
incidenceDelegate
.
parent
=
root
;
incidenceDelegate
.
repositionAnimationEnabled
=
true
;
incidenceDelegate
.
isOpenOccurrence
=
true
;
}
}
}
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment