Sha256: a39150592fb81e26d1bee18aa04885b71226038da43ace0e033a59591b9e0466

Contents?: true

Size: 1.2 KB

Versions: 10

Compression:

Stored size: 1.2 KB

Contents

module UIC; end
class UIC::GUI::AppAttributesModel < Qt::AbstractItemModel
	INVALIDINDEX = Qt::ModelIndex.new
	NODATA       = Qt::Variant.new
	def initialize(qtparent,el)
		super(qtparent)
		@indexes = {} # indexed by [row,col]
		@root    = Qt::ModelIndex.new
		@el      = el
		el.properties.values.sort_by{ |p| p.formal.downcase }.each.with_index do |prop,i|
			@indexes[[i,0]] = createIndex( i, 0, Qt::Variant.new(prop.formal) )
			@indexes[[i,1]] = createIndex( i, 1, Qt::Variant.new(el[prop.name,0].to_s) )
		end
	end

	def columnCount( *any )
		2
	end

	def index( row, col, parent=INVALIDINDEX )
		@indexes[[row,col]]
	end

	def headerData(section, orientation, role=Qt::DisplayRole)
		if orientation==Qt::Horizontal && role==Qt::DisplayRole
			case section
				when 0; Qt::Variant.new(tr("Attribute"))
				when 1; Qt::Variant.new(tr("Value"))
				else  ; NODATA
			end
		else
			NODATA
		end
	end

	def parent(child)
		child.valid? ? @root : @INVALIDINDEX
	end

	def rowCount( parent=INVALIDINDEX )
		@rowcount ||= @el.properties.length
	end

	def data(index, role)
		if index.valid? && role == Qt::DisplayRole
			index.internal_pointer
		else
			NODATA
		end
	end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
RUIC-0.6.1 gui/appattributesmodel.rb
RUIC-0.4.6 gui/appattributesmodel.rb
RUIC-0.4.5 gui/appattributesmodel.rb
RUIC-0.4.2 gui/appattributesmodel.rb
RUIC-0.4.0 gui/appattributesmodel.rb
RUIC-0.3.0 gui/appattributesmodel.rb
RUIC-0.2.6 gui/appattributesmodel.rb
RUIC-0.2.5 gui/appattributesmodel.rb
RUIC-0.2.0 gui/appattributesmodel.rb
RUIC-0.1.0 gui/appattributesmodel.rb