<commit_before>$:.unshift '.'
require 'cells'
require 'Qt4'

# A simple model class.
# Imagine some interesting domain logic here.
class Model
	cell :content
	def initialize
		self.content = "Hello World."
	end
end

# A simple view to match our simple model.
class View < Qt::Widget
	def initialize(model)
		super()

		self.window_title = 'Testing ruby-cells with a model/view application'
		resize(500,100)
		add_action(Qt::Action.new(self) do
			self.shortcuts = Qt::KeySequence.Quit
			connect(SIGNAL :triggered) { Qt::Application.instance.quit }
		end)

		input = Qt::LineEdit.new(model.content) do
			connect(SIGNAL "textChanged(QString)") { model.content = text }
		end
		output = Qt::Label.new do
			# This is the interesting bit:
			calculate(:text) { "+++" + model.content + "+++" }
		end

		self.layout = Qt::VBoxLayout.new do
			add_widget input
			add_widget output
		end
	end
end

Qt::Application.new(ARGV) do
	demo = View.new(Model.new)
	demo.show
	exec
end

<commit_msg>Slightly less trivial model/view example.<commit_after>$:.unshift '.'
require 'cells'
require 'Qt4'

# A simple model class.
# Imagine some interesting domain logic here.
class Model
	cell :name, :email
	def initialize
		self.name = "<NAME>"
		self.email = "<EMAIL>"
	end
end

# A simple view to match our simple model.
class View < Qt::Widget
	def initialize(model)
		super()

		self.window_title = 'Testing ruby-cells with a model/view application'
		resize(500,100)
		add_action(Qt::Action.new(self) do
			self.shortcuts = Qt::KeySequence.Quit
			connect(SIGNAL :triggered) { Qt::Application.instance.quit }
		end)

		input_name = Qt::LineEdit.new(model.name) do
			connect(SIGNAL "textChanged(QString)") { model.name = text }
		end
		input_email = Qt::LineEdit.new(model.email) do
			connect(SIGNAL "textChanged(QString)") { model.email = text }
		end
		output = Qt::Label.new do
			# This is the interesting bit:
			calculate(:text) { "From: #{model.name} <#{model.email}>" }
		end

		self.layout = Qt::VBoxLayout.new do
			add_widget input_name
			add_widget input_email
			add_widget output
		end
	end
end

Qt::Application.new(ARGV) do
	demo = View.new(Model.new)
	demo.show
	exec
end


{'fraction_non_alphanumeric': 0.12213039485766758, 'fraction_numerical': 0.006427915518824609, 'mean_word_length': 3.929864253393665, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3545535', 'n_tokens_mistral': 824, 'n_tokens_neox': 739, 'n_words': 202}