-
Notifications
You must be signed in to change notification settings - Fork 0
/
nor-calculator.rb
125 lines (90 loc) · 2.92 KB
/
nor-calculator.rb
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
#!/usr/bin/ruby
require 'rubygems'
require 'Qt'
require 'launchy'
require "i18n"
require_relative "iof_result_list_reader"
require_relative "points_calculator"
require_relative "standard_html_result_report"
I18n.load_path = Dir.glob("config/locales/*.yml")
I18n.locale = "de"
WIDTH = 400
HEIGHT = 150
class QtApp < Qt::Widget
slots 'on_calculate()' ,
'setOpenFileName()'
def initialize
super
setWindowTitle "NOR-Punkte Berechnung"
resize WIDTH, HEIGHT
init_ui
center
show
end
def center
qdw = Qt::DesktopWidget.new
screenWidth = qdw.width
screenHeight = qdw.height
x = (screenWidth - WIDTH) / 2
y = (screenHeight - HEIGHT) / 2
move x, y
end
def createButton(text, member)
button = Qt::PushButton.new(text)
connect(button, SIGNAL('clicked()'), self, member)
return button
end
def init_ui
dx = 80
dy = 30
frameStyle = Qt::Frame::Sunken | Qt::Frame::Panel
label = Qt::Label.new
label.setText "Ergebnisdatei:"
@openFileNameLabel = Qt::Label.new
@openFileNameLabel.frameStyle = frameStyle
openFileNameButton = Qt::PushButton.new(tr("&Laden"))
connect(openFileNameButton, SIGNAL('clicked()'), self, SLOT('setOpenFileName()'))
vbox = Qt::VBoxLayout.new self
hbox_file = Qt::HBoxLayout.new
hbox_file.addWidget label, 0, Qt::AlignLeft
hbox_file.addWidget @openFileNameLabel
hbox_file.addWidget openFileNameButton
vbox.addStretch 1
vbox.addLayout hbox_file
vbox.addStretch 1
treeview = Qt::TreeView.new
#treeview.model = model
treeview.windowTitle = "Simple Tree Model"
vbox.addStretch 1
@calculateButton = createButton(tr("Be&rechnen"), SLOT('on_calculate()'))
@quitButton = createButton(tr("&Beenden"), SLOT('close()'))
hbox_action = Qt::HBoxLayout.new
hbox_action.addWidget @calculateButton, 1, Qt::AlignLeft
hbox_action.addWidget @quitButton, 1, Qt::AlignRight
vbox.addLayout hbox_action
end
def on_changed text
@label.setText text
end
def on_calculate
iof_result_list_reader = IofResultListReader.new([@openFileNameLabel.text], true)
PointsCalculator.new(iof_result_list_reader.events, :nor, true)
iof_result_list_reader.simple_output(true)
reports = StandardHtmlResultReport.new(iof_result_list_reader, true, nil, nil)
reports.results.each do |result|
Launchy.open(result)
end
end
def setOpenFileName()
fileName = Qt::FileDialog.getOpenFileName(self,
tr("Ergebnisdatei"),
@openFileNameLabel.text,
tr("XML-Files (*.xml)"))
if !fileName.nil?
@openFileNameLabel.text = fileName
end
end
end
app = Qt::Application.new ARGV
QtApp.new
app.exec