source: trunk/dsa_messenger/client-chat_windows.adb

Last change on this file was 10, checked in by vadim.godunko, 12 years ago

Rename packages.

File size: 2.9 KB
Line 
1with Qt4.Line_Edits.Constructors;
2with Qt4.Objects;
3with Qt4.List_Views.Constructors;
4with Qt4.Plain_Text_Edits.Constructors;
5with Qt4.Push_Buttons.Constructors;
6with Qt4.H_Box_Layouts.Constructors;
7with Qt4.V_Box_Layouts.Constructors;
8
9with Client.Chat_Windows.Moc;
10with Server.Logon_Manager;
11
12package body Client.Chat_Windows is
13
14 function "-" (Item : String) return Qt4.Strings.Q_String
15 renames Qt4.Strings.From_Utf_8;
16
17 ------------------
18 -- Constructors --
19 ------------------
20
21 package body Constructors is
22
23 function Create return not null Chat_Window_Access is
24 H_Layout : Qt4.H_Box_Layouts.Q_H_Box_Layout_Access;
25 V_Layout : Qt4.V_Box_Layouts.Q_V_Box_Layout_Access;
26 Button : Qt4.Push_Buttons.Q_Push_Button_Access;
27 View : Qt4.List_Views.Q_List_View_Access;
28
29 begin
30 return Self : not null Chat_Window_Access := new Chat_Window do
31 Qt4.Widgets.Directors.Constructors.Initialize (Self);
32
33 Self.Users := Client.User_List_Models.Constructors.Create (Self);
34
35 H_Layout := Qt4.H_Box_Layouts.Constructors.Create;
36 Self.Set_Layout (H_Layout);
37
38 V_Layout := Qt4.V_Box_Layouts.Constructors.Create;
39 H_Layout.Add_Layout (V_Layout);
40
41 Self.Text := Qt4.Plain_Text_Edits.Constructors.Create;
42 Self.Text.Set_Read_Only (True);
43 V_Layout.Add_Widget (Self.Text);
44
45 Self.Input := Qt4.Line_Edits.Constructors.Create;
46 V_Layout.Add_Widget (Self.Input);
47
48 Button := Qt4.Push_Buttons.Constructors.Create (-"Send");
49 V_Layout.Add_Widget (Button);
50 Qt4.Objects.Connect
51 (Button, Qt4.Signal ("clicked()"), Self, Qt4.Slot ("send()"));
52
53 View := Qt4.List_Views.Constructors.Create;
54 View.Set_Model (Self.Users);
55 H_Layout.Add_Widget (View);
56 end return;
57 end Create;
58
59 end Constructors;
60
61 -------------
62 -- Receive --
63 -------------
64
65 procedure Receive
66 (Self : not null access Chat_Window'Class;
67 From : Qt4.Strings.Q_String;
68 Text : Qt4.Strings.Q_String) is
69 begin
70 Self.Text.Append_Plain_Text (Text);
71 end Receive;
72
73 ----------
74 -- Send --
75 ----------
76
77 procedure Send (Self : not null access Chat_Window'Class) is
78 begin
79 Server.Logon_Manager.Send ("me", "me", Self.Input.Text.To_Utf_8);
80 Self.Input.Clear;
81 end Send;
82
83 --------------------
84 -- User_Connected --
85 --------------------
86
87 procedure User_Connected
88 (Self : not null access Chat_Window'Class;
89 Name : Qt4.Strings.Q_String) is
90 begin
91 Self.Users.Insert (Name);
92 end User_Connected;
93
94 -----------------------
95 -- User_Disconnected --
96 -----------------------
97
98 procedure User_Disconnected
99 (Self : not null access Chat_Window'Class;
100 Name : Qt4.Strings.Q_String) is
101 begin
102 Self.Users.Remove (Name);
103 end User_Disconnected;
104
105end Client.Chat_Windows;
Note: See TracBrowser for help on using the repository browser.