1
00:00:00,150 --> 00:00:01,680
Well, hello, dear friends.

2
00:00:02,640 --> 00:00:04,590
And here we are in the next video, what are we going to do?

3
00:00:05,280 --> 00:00:10,110
Well, we're going to handle them, modify and delete options for an employee.

4
00:00:12,670 --> 00:00:17,950
So, for example, if you right click around the table will get a context menu, right, containing

5
00:00:17,950 --> 00:00:20,500
two actions, which would be delete and modify.

6
00:00:21,520 --> 00:00:27,250
So this is going to be shown at the position of the cursor, because we've clicked it right now in order

7
00:00:27,250 --> 00:00:29,020
to be able to display that.

8
00:00:29,320 --> 00:00:32,230
We have to install something called event filter.

9
00:00:33,150 --> 00:00:40,620
And to override the method which enables us to create the context menu at a specified position for the

10
00:00:40,620 --> 00:00:41,460
table with you.

11
00:00:42,510 --> 00:00:50,400
So let me show you what I mean by actually installing the event filter, self-taught UI table widget.

12
00:00:51,720 --> 00:00:58,800
Now, here, we need to access review port and install event filter of self.

13
00:01:03,700 --> 00:01:05,200
Now we need to override the method.

14
00:01:06,270 --> 00:01:09,750
So let's go to manage employee and to find that method event filter.

15
00:01:15,880 --> 00:01:21,880
Deaf event filter, which receives as arguments and objects and an event.

16
00:01:26,650 --> 00:01:29,860
So now the arguments represent the following.

17
00:01:31,630 --> 00:01:38,950
The object will be the viewport from the table widget and event will be the event which has.

18
00:01:39,990 --> 00:01:40,950
Subsequently occurred.

19
00:01:42,450 --> 00:01:49,590
For example, mouse button press or any other event that can occur on that specific viewport.

20
00:01:50,720 --> 00:01:59,840
Now we've cleared that up, we'll just make sure that we can check if the object so if object is equal

21
00:01:59,840 --> 00:02:09,620
to the viewport from the table widget, self-taught UI event type is equal queue event, mouse button

22
00:02:09,620 --> 00:02:10,190
press.

23
00:02:15,280 --> 00:02:15,610
Yes.

24
00:02:15,820 --> 00:02:16,660
Yes, okay.

25
00:02:16,690 --> 00:02:22,120
If this condition is satisfied and we can check the mouse button, press is actually right click because

26
00:02:22,120 --> 00:02:28,120
we don't need to display the context menu of the left click in point of fact.

27
00:02:29,980 --> 00:02:33,850
If event button equals cute, right button.

28
00:02:37,260 --> 00:02:42,960
So we have to stop the show at which the current cursor is positioned, right, so let's say.

29
00:02:43,970 --> 00:02:51,200
Index is itself, not UI dot table widget, dot index at event.

30
00:02:51,290 --> 00:02:52,760
That position.

31
00:02:55,790 --> 00:03:01,130
In case we are not their position, which is valid, for example, we don't have enough rose.

32
00:03:01,520 --> 00:03:05,930
Click on the empty space between or below the rows from the table, whatever.

33
00:03:06,350 --> 00:03:10,790
The index will not be valid, of course, and we wouldn't be able to modify it or lead anything.

34
00:03:10,800 --> 00:03:12,140
So let's just make sure that.

35
00:03:13,700 --> 00:03:17,810
So we're going to check to see and make sure that index is valid.

36
00:03:17,820 --> 00:03:18,080
Right.

37
00:03:18,200 --> 00:03:21,290
So if index is valid, pass.

38
00:03:22,920 --> 00:03:25,350
In which case we can display the context menu.

39
00:03:27,140 --> 00:03:33,080
Now, let's just pass this and include everything that will need for the code that we just wrote, so.

40
00:03:38,260 --> 00:03:42,220
From Pie Cuty five dot curry core.

41
00:03:45,010 --> 00:03:53,050
Now we will need to import the event cuty because we access Cuddie of the right click and queue object.

42
00:03:54,670 --> 00:03:58,960
Now, if you do forget to import all of these, there's really not much of a problem because you are

43
00:03:58,960 --> 00:04:03,190
going to get an error when you execute the program and it's going to tell you exactly what you need

44
00:04:03,190 --> 00:04:03,810
to import.

45
00:04:03,830 --> 00:04:07,990
But you can always preempt that error.

46
00:04:08,170 --> 00:04:10,240
Some people just don't like seeing errors.

47
00:04:13,910 --> 00:04:18,860
OK, so we need to restart returns something, and that's the main window.

48
00:04:20,210 --> 00:04:25,220
Return Keu main window DOTT event, filter's self object event.

49
00:04:27,510 --> 00:04:33,690
And as arguments, we can pass this subject of the object and the event, which is a Devall behavior

50
00:04:33,690 --> 00:04:34,470
for the event.

51
00:04:35,490 --> 00:04:40,050
But it feels like we're not going to really be modifying anything in that specific return code.

52
00:04:40,470 --> 00:04:42,120
So let me just go check it out.

53
00:04:43,020 --> 00:04:43,380
I'm right.

54
00:04:43,380 --> 00:04:44,550
Clicking this row.

55
00:04:44,580 --> 00:04:46,630
Nothing happens, of course.

56
00:04:46,650 --> 00:04:47,370
That's right.

57
00:04:47,370 --> 00:04:50,700
Because we haven't actually written any code for that.

58
00:04:51,210 --> 00:04:56,910
So if the index is Vallon, let's create some actions that we want to delete.

59
00:04:57,420 --> 00:05:00,840
So delete action is a cue action.

60
00:05:03,530 --> 00:05:07,940
So this has it text delete, it also receives a parent, which is self.

61
00:05:08,690 --> 00:05:17,000
Now, when the delete action is clicked because it's going to be a context menu with two so-called buttons,

62
00:05:17,600 --> 00:05:18,830
we're going to need something to happen.

63
00:05:19,370 --> 00:05:26,570
So we need to correct the no slot mechanism.

64
00:05:27,110 --> 00:05:28,250
Have you done that before?

65
00:05:28,280 --> 00:05:29,000
I don't know.

66
00:05:29,030 --> 00:05:29,960
Let's do it now.

67
00:05:31,250 --> 00:05:33,140
Delete action, dot triggered.

68
00:05:34,160 --> 00:05:36,890
Because this is not conflict.

69
00:05:37,640 --> 00:05:40,130
This is something different from Q action.

70
00:05:41,020 --> 00:05:46,810
Dot connect and create the function self dot delete action triggered.

71
00:05:52,820 --> 00:05:54,140
So let's create that right here.

72
00:05:58,790 --> 00:06:07,610
Define and pass for now, and the other action we want to create is modify actions, so modify action

73
00:06:07,610 --> 00:06:14,270
is equal to Q action, modify as a text and self as a parent.

74
00:06:17,690 --> 00:06:23,000
And modify action triggered connect, self-taught, modify, action trigger.

75
00:06:28,430 --> 00:06:32,480
And create that function also to find and pass.

76
00:06:34,820 --> 00:06:38,750
So now that we have the actions created, we can create the context menu.

77
00:06:39,380 --> 00:06:40,580
Don't let's forget about that.

78
00:06:40,850 --> 00:06:45,050
So context menu is equal to a menu.

79
00:06:46,250 --> 00:06:47,870
Which receives this parent.

80
00:06:48,650 --> 00:06:54,910
And we have to add the actions and execute the context menu at the time that the right button gets clicked.

81
00:06:54,920 --> 00:06:55,190
Right.

82
00:06:55,760 --> 00:06:59,210
So context menu, add action, delete action.

83
00:07:04,370 --> 00:07:07,160
Context menu, add action, modify action.

84
00:07:11,930 --> 00:07:14,150
And so execute it, just run him.

85
00:07:15,130 --> 00:07:17,260
Context menu, dot execute.

86
00:07:18,960 --> 00:07:24,660
And as an argument, we'll need to pass a global position where we are right now, and for that we'll

87
00:07:24,660 --> 00:07:28,050
have to call the event that global position.

88
00:07:29,920 --> 00:07:36,040
So this is going to return the position where the mouse is right at the moment of the right click.

89
00:07:37,790 --> 00:07:39,650
So I would just see what happens in the program.

90
00:07:40,070 --> 00:07:45,980
Right click, and you can see that here are the delete and modify option showing up.

91
00:07:49,030 --> 00:07:52,870
So even though this Rossana highlighted the context menu is showing, right?

92
00:07:53,880 --> 00:07:59,340
So when we click down, well, nothing happens because we were just passing.

93
00:08:00,630 --> 00:08:06,930
When the function calls, but let's try to create something out, let's say print, delete.

94
00:08:08,300 --> 00:08:14,180
Just to know that the signal SWAT mechanism is working and print modifying.

95
00:08:17,590 --> 00:08:21,430
So let's run the program, tried out again, and there's a result.

96
00:08:26,350 --> 00:08:28,720
Now we can try to trigger this action.

97
00:08:30,530 --> 00:08:37,640
But actually, in this program, we're going to use the modify action for adding an employee leave to

98
00:08:37,640 --> 00:08:38,660
our employee.

99
00:08:39,320 --> 00:08:44,600
But really what's important to us is that we need to have that information for one specific user.

100
00:08:45,320 --> 00:08:51,830
So the current function, which connects the modify action to the modify action trigger is not have

101
00:08:51,830 --> 00:08:56,120
one additional parameter which can hold information about the user.

102
00:08:56,900 --> 00:08:57,170
Right.

103
00:08:59,880 --> 00:09:06,000
So, for example, the index that Roe, which identifies a user from our table.

104
00:09:07,050 --> 00:09:08,320
That's what we need.

105
00:09:08,340 --> 00:09:14,640
So now in order to solve this problem, we can just set the object name for modify action.

106
00:09:15,980 --> 00:09:17,600
So let's just.

107
00:09:17,810 --> 00:09:19,280
Well, let me just show you how.

108
00:09:20,280 --> 00:09:30,450
Modify action that set object name and the object name will be set to a string of index dot row, which

109
00:09:30,450 --> 00:09:33,690
will be the row index for this specific mouse cursor.

110
00:09:34,440 --> 00:09:38,790
OK, so now in the modify action trigger function, we can still print, modify.

111
00:09:40,290 --> 00:09:45,990
And in the slot, we can identify the signal, which is the modify action, which has sent the event

112
00:09:45,990 --> 00:09:46,950
to call the slot.

113
00:09:50,080 --> 00:09:57,610
In order to do that, we can access row equals queue object center of self-taught object name.

114
00:10:02,530 --> 00:10:06,280
Because we need the object name from the modify action.

115
00:10:06,940 --> 00:10:07,470
OK.

116
00:10:07,560 --> 00:10:07,750
Hey.

117
00:10:08,840 --> 00:10:13,160
Now we need to cast this to an end because, well, that's the string word.

118
00:10:14,860 --> 00:10:21,910
Now we can get the idea easily because we have the table widgets, so self-doubt, Eweida table widget

119
00:10:21,910 --> 00:10:25,060
that item at that specific row.

120
00:10:25,660 --> 00:10:30,730
And we know that the idea is always placed at the Xeros column, that text.

121
00:10:32,190 --> 00:10:39,300
And now what we need to do is just create a window and instantiate it by passing the constructor an

122
00:10:39,300 --> 00:10:42,590
additional parameter which would be ready.

123
00:10:42,600 --> 00:10:45,240
So self-taught employee info window.

124
00:10:46,290 --> 00:10:52,470
Because that's how we're going to call our new window from the leave screen is new employee info window,

125
00:10:52,470 --> 00:10:59,250
which has an argument the I.D. and all we need to do is show it.

126
00:11:01,300 --> 00:11:02,500
Now we need to import it.

127
00:11:09,010 --> 00:11:12,520
So from leave screen import employee info window.

128
00:11:18,180 --> 00:11:19,920
Now is created, so.

129
00:11:20,850 --> 00:11:23,130
Class employee info window.

130
00:11:32,120 --> 00:11:34,920
Which inherits from Kudi Widget's.

131
00:11:35,900 --> 00:11:36,770
Main window.

132
00:11:37,760 --> 00:11:40,130
And let's define the init function.

133
00:11:42,100 --> 00:11:43,510
Death in itself.

134
00:11:47,830 --> 00:11:55,330
And we have to call the super constructor, so that means employee info window and self-taught in it.

135
00:11:56,650 --> 00:12:00,070
Now we can initialize the UI, so.

136
00:12:02,680 --> 00:12:07,180
Self-taught UI is equal to a UI main window.

137
00:12:10,160 --> 00:12:14,090
Self-taught UI taught set up UI of self.

138
00:12:15,260 --> 00:12:22,940
Now need to receive the I.D. as well, so that's an argument, self-taught ID is an I.D..

139
00:12:25,590 --> 00:12:28,830
Very cool, so now let's go back to manage employees.

140
00:12:43,940 --> 00:12:46,070
And that should be all done now, so we'll.

141
00:12:48,970 --> 00:12:52,510
Run this and modify see the windows shown up.

142
00:12:54,050 --> 00:12:54,650
Very cool.

143
00:12:54,980 --> 00:12:55,640
So that's it.

144
00:12:55,670 --> 00:13:01,460
We've now created a context menu where we have a delete and modify action.

145
00:13:02,670 --> 00:13:05,070
So I want to see in the next lesson we'll continue from here.

146
00:13:05,190 --> 00:13:05,550
All right.
