Mercurial > projects > qtd
comparison demos/interview/model.d @ 198:cab015969047
don't need these changes in D1
author | eldar |
---|---|
date | Mon, 13 Jul 2009 11:41:33 +0000 |
parents | 4536633518e1 |
children | 57c3714ed282 |
comparison
equal
deleted
inserted
replaced
197:4536633518e1 | 198:cab015969047 |
---|---|
79 file = iconProvider.icon(QFileIconProvider.File); | 79 file = iconProvider.icon(QFileIconProvider.File); |
80 services = new QIcon(":/images/services.png"); | 80 services = new QIcon(":/images/services.png"); |
81 } | 81 } |
82 | 82 |
83 | 83 |
84 QModelIndex index(int row, int column, const QModelIndex parent) | 84 QModelIndex index(int row, int column, QModelIndex parent) |
85 { | 85 { |
86 if (row < rc && row >= 0 && column < cc && column >= 0) { | 86 if (row < rc && row >= 0 && column < cc && column >= 0) { |
87 Node p = cast(Node) parent.internalPointer(); | 87 Node p = cast(Node) parent.internalPointer(); |
88 Node n = getNode(row, p); | 88 Node n = getNode(row, p); |
89 if (n !is null) | 89 if (n !is null) |
90 return createIndex(row, column, cast(void*)n); | 90 return createIndex(row, column, cast(void*)n); |
91 } | 91 } |
92 return QModelIndex(); | 92 return QModelIndex(); |
93 } | 93 } |
94 | 94 |
95 QModelIndex parent(const QModelIndex child) | 95 QModelIndex parent(QModelIndex child) |
96 { | 96 { |
97 if (child.isValid()) { | 97 if (child.isValid()) { |
98 Node n = cast(Node) child.internalPointer(); | 98 Node n = cast(Node) child.internalPointer(); |
99 Node p = parent(n); | 99 Node p = parent(n); |
100 if (p !is null) | 100 if (p !is null) |
101 return createIndex(row(p), 0, cast(void*)p); | 101 return createIndex(row(p), 0, cast(void*)p); |
102 } | 102 } |
103 return QModelIndex(); | 103 return QModelIndex(); |
104 } | 104 } |
105 | 105 |
106 int rowCount(const QModelIndex parent) | 106 int rowCount(QModelIndex parent) |
107 { | 107 { |
108 return (parent.isValid() && parent.column() != 0) ? 0 : rc; | 108 return (parent.isValid() && parent.column() != 0) ? 0 : rc; |
109 } | 109 } |
110 | 110 |
111 int columnCount(const QModelIndex parent) | 111 int columnCount(QModelIndex parent) |
112 { | 112 { |
113 return cc; | 113 return cc; |
114 } | 114 } |
115 | 115 |
116 QVariant data(const QModelIndex index, int role) | 116 QVariant data(QModelIndex index, int role) |
117 { | 117 { |
118 if (!index.isValid) | 118 if (!index.isValid) |
119 return new QVariant; | 119 return new QVariant; |
120 if (role == Qt.DisplayRole) | 120 if (role == Qt.DisplayRole) |
121 return new QVariant("Item " ~ Integer.toString(index.row) ~ ":" ~ Integer.toString(index.column)); | 121 return new QVariant("Item " ~ Integer.toString(index.row) ~ ":" ~ Integer.toString(index.column)); |
135 if (role == Qt.DecorationRole) | 135 if (role == Qt.DecorationRole) |
136 return services.toVariant; | 136 return services.toVariant; |
137 return QAbstractItemModel.headerData(section, orientation, role); | 137 return QAbstractItemModel.headerData(section, orientation, role); |
138 } | 138 } |
139 | 139 |
140 bool hasChildren(const QModelIndex parent) | 140 bool hasChildren(QModelIndex parent) |
141 { | 141 { |
142 if (parent.isValid && parent.column != 0) | 142 if (parent.isValid && parent.column != 0) |
143 return false; | 143 return false; |
144 return rc > 0 && cc > 0; | 144 return rc > 0 && cc > 0; |
145 } | 145 } |
146 | 146 |
147 int flags(const QModelIndex index) | 147 int flags(QModelIndex index) |
148 { | 148 { |
149 if (!index.isValid) | 149 if (!index.isValid) |
150 return 0; | 150 return 0; |
151 return (Qt.ItemIsDragEnabled | Qt.ItemIsSelectable | Qt.ItemIsEnabled); | 151 return (Qt.ItemIsDragEnabled | Qt.ItemIsSelectable | Qt.ItemIsEnabled); |
152 } | 152 } |