ryanmelt/qtbindings — pull request #62 by Raven24 (2013-09-27 18:42:24+00:00)
Title: add functions for setting and gettin role names

for subclasses of QAbstractItemModel - for use with QtQuick/QML

see also the [report on KDE bugtracker](https://bugs.kde.org/show_bug.cgi?id=305515)

this makes it possible to set and get the role names of a model as a ruby hash.

```ruby
# example: subclassing a QListModel
class TestModel < Qt::ListModel
def initialize
super
set_role_names({ 1000 => "user_role", 1001 => "another_role"})
# or
#setRoleNames({ 1000 => "user_role", 1001 => "another_role"})
end

def rowCount(parent)
x
end

# yes, a list doesn't have columns, but for some reason it needs this method
# to be implemented. just humor me here...
def columnCount(parent)
1
end

def data(idx, role)
return Qt::Variant.new("something") if role == 1000
return Qt::Variant.new("otherthing") if role == 1001
end
end
```

```ruby
# example: exposing the model instance to QML
@model = TestModel.new
@qmlview = Qt::DeclarativeView.new
@ctx = @qmlview.root_context
@ctx.set_context_property("test_model", @model)
```

closes #60