-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.qml
305 lines (238 loc) · 7.11 KB
/
main.qml
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
import QtQuick 2.13
import QtQuick.Window 2.13 // ApplicationWindow
import QtQuick.Controls 2.13 // SplitView
import QtQuick.Layouts 1.3 // Required for Layouts of SplitView
import QtQuick.Dialogs 1.2 // Dialog
import QtQml.Models 2.12 // DelegateModel
import MainWindowLogic 1.0
import ChannelModel 1.0
import ProxyChannelModel 1.0
// Main Window
ApplicationWindow {
// ------------------------------------------------------------------------
// ID
id: mainWindow_id
// Visibility
visible: true
// Width
width: 640
// Height
height: 480
// Title
title: qsTr("Q-RSSReader")
// Name (used due to id can't be used as string).
property string name: "mainWindow"
// ------------------------------------------------------------------------
// Logic
MainWindowLogic {
// ID
id: mainWindowLogic
} /// Logic
// ------------------------------------------------------------------------
// Show UrlDialog
function showUrlDialog( )
{
if ( !urlInputDialog.visible )
urlInputDialog.open( );
} /// showUrlDialog
/**
* Shows Open-FileDialog to RSS file.
*
* If file exists, pass it to ChannelModel,
* which parse it & update data.
**/
function showOpenFileRSSDialog( )
{
// Show File-Dialog for RSS-File
if ( !openFSSFileDialog_id.visible )
openFSSFileDialog_id.open( );
} /// showOpenFileRSSDialog
/**
* Tries to open RSS-File using ChannelModel.
* If RSS data has been read, ChannelModel updates.
**/
function openRSSFile( rssFileUrl )
{
// Parse RSS File.
rssModel.parseRSSFile( rssFileUrl );
} /// openRSSFile
/**
* Shows AboutAppDialog.
**/
function showAboutAppDialog( )
{
// Show AboutAppDialog
if ( !about_DialogID.visible )
about_DialogID.open( );
} /// showAboutAppDialog
// ------------------------------------------------------------------------
// DelegateModel for Channels ListView
DelegateModel {
// ID
id: channelsListViewDelegateModel_id
// Model
model: rssModel
// Delegate
delegate: ChannelListItem {
//
channelViewWidth: rssListViews_id.channelsWidth - 16
//
channelViewHeight: channelViewWidth / 3
//
imageSource: image
//
channelTitle: title
//
channelDescription: description
// Mouse-Area
MouseArea {
// ID
id: rssChannelsView_MouseArea_id
// Anchors
anchors.fill: parent
// OnClick
onClicked: {
// Highlight Item.
rssListViews_id.channelsListIndex = index;
// Set Selected Channel.
proxyRssModel.setSelectedChannelIndex( link );
} /// OnClick
} /// Mouse-Area
} /// Delegate
} /// DelegateModel for Channels ListView
// DelegateModel for Channel' Items ListView
DelegateModel {
// ID
id: channelItemsListViewDelegateModel_id
// Model
model: proxyRssModel
delegate: ChannelItemView {
// Container View-Width
width: rssListViews_id.itemsWidth
// Container View-Height
height: width / 4
// Title
titleValue: title
// Description
descriptionValue: description
// Visibility
visible: true
// Mouse-Area
MouseArea {
// ID
id: rssItemView_MouseArea_id
// Anchors
anchors.fill: parent
// OnClick
onClicked: {
// Highlight Item.
rssListViews_id.itemsListIndex = index;
} /// OnClick
} /// Mouse-Area
} /// Delegate
}
/// DelegateModel for Channel' Items ListView
// RSS View
RSSSplitListView {
// ID
id: rssListViews_id
// Channels Container Width
channelsWidth: mainWindow_id.width / 3
// Channel' Items Container Width
itemsWidth: mainWindow_id.width - channelsWidth
// Height
rssHeight: mainWindow_id.height
// Channels ListView Model
channelsModel: channelsListViewDelegateModel_id
// Channel' Items ListView Model
channelItemsModel: channelItemsListViewDelegateModel_id
}
/// RSS View
// ------------------------------------------------------------------------
// Menu [QtQuickControls 2.5]
menuBar: MenuBar {
// ID
id: menuBar_id
// Visibility
visible: true
// Application
Menu {
// ID
id: menuBar_applicationMenu_id
// Title
title: "App"
Action {
text: "Open URL"
onTriggered: showUrlDialog( )
}
Action {
text: "Open File"
onTriggered: showOpenFileRSSDialog( )
}
Action {
text: "About"
onTriggered: showAboutAppDialog( )
}
Action {
text: "Quit"
onTriggered: Qt.quit( );
}
} /// Application
}
/// Menu
// ------------------------------------------------------------------------
// AboutAppDialog
AboutAppDialog {
// ID
id: about_DialogID
// Visibility
visible: false
} /// AboutAppDialog
// ------------------------------------------------------------------------
// Open FileDialog for RSS
FileDialog {
// ID
id: openFSSFileDialog_id
// Title
title: "Open RSS"
// Default Path
folder: shortcuts.home
// Filters
nameFilters: [ "RSS (*.rss *.xml)" ]
// Modality
modality: Qt.Dialog
// Visibility
visible: false
// Multi-Selection
selectMultiple: false
// Select Exisitin
selectExisting: true
// File-Only
selectFolder: false
// OnAccepted
onAccepted: openRSSFile( openFSSFileDialog_id.fileUrl )
// OnRejected
//onRejected: openFSSFileDialog_id.close( )
} /// Open FileDialog for RSS
// ------------------------------------------------------------------------
// Url Input Dialog
TextInputDialog {
// Title
title: "RSS"
// ID
id: urlInputDialog
// Visibility
visible: false
// OK
//onAccepted: {
//} /// OK
}
/// Url Input Dialog
// ------------------------------------------------------------------------
// onCompleted
onSceneGraphInitialized: mainWindowLogic.onReady( )
// onClosing
onClosing: Qt.quit( )
// onDestruction
Component.onDestruction: mainWindowLogic.onClose( )
} /// Main Window