Mercurial > projects > qtd
comparison demos/browser/history.d @ 85:5c8c9c5d9ee1
more porting
author | mandel |
---|---|
date | Mon, 25 May 2009 14:10:44 +0000 |
parents | 85c59c4e5f19 |
children | 87bb4e622f9e |
comparison
equal
deleted
inserted
replaced
84:2edf95ad41e5 | 85:5c8c9c5d9ee1 |
---|---|
80 { | 80 { |
81 public: | 81 public: |
82 | 82 |
83 this() {} | 83 this() {} |
84 | 84 |
85 this(string u, QDateTime d = QDateTime(), string t = null) | 85 this(string u, QDateTime d = null, string t = null) |
86 { | 86 { |
87 title = t; | 87 title = t; |
88 url = u; | 88 url = u; |
89 dateTime = d; | 89 dateTime = d ? d : new QDateTime(); |
90 } | 90 } |
91 | 91 |
92 //bool operator==(HistoryItem &other) | 92 //bool operator==(HistoryItem &other) |
93 int opEquals(HistoryItem other) | 93 int opEquals(HistoryItem other) |
94 { | 94 { |
671 return QModelIndex(); | 671 return QModelIndex(); |
672 | 672 |
673 return createIndex(row, column, m_sourceRow[row]); | 673 return createIndex(row, column, m_sourceRow[row]); |
674 } | 674 } |
675 | 675 |
676 QModelIndex parent(QModelIndex index= QModelIndex()) | 676 QModelIndex parent(QModelIndex index = QModelIndex()) |
677 { | 677 { |
678 return QModelIndex(); | 678 return QModelIndex(); |
679 } | 679 } |
680 | 680 |
681 /* | 681 /* |
1036 if (row < 0 || row >= rowCount(parent) || column < 0 || column >= columnCount(parent)) | 1036 if (row < 0 || row >= rowCount(parent) || column < 0 || column >= columnCount(parent)) |
1037 return QModelIndex(); | 1037 return QModelIndex(); |
1038 return createIndex(row, column, 0); | 1038 return createIndex(row, column, 0); |
1039 } | 1039 } |
1040 | 1040 |
1041 QModelIndex parent(QModelIndex index= QModelIndex()) | 1041 QModelIndex parent(QModelIndex index = QModelIndex()) |
1042 { | 1042 { |
1043 return QModelIndex(); | 1043 return QModelIndex(); |
1044 } | 1044 } |
1045 | 1045 |
1046 void setSourceModel(QAbstractItemModel sourceModel) | 1046 void setSourceModel(QAbstractItemModel sourceModel) |
1155 return QModelIndex(); | 1155 return QModelIndex(); |
1156 | 1156 |
1157 if (m_sourceRowCache.length == 0) | 1157 if (m_sourceRowCache.length == 0) |
1158 rowCount(QModelIndex()); | 1158 rowCount(QModelIndex()); |
1159 | 1159 |
1160 int[].iterator it; | 1160 //int[].iterator it; |
1161 it = qLowerBound(m_sourceRowCache.begin(), m_sourceRowCache.end(), sourceIndex.row()); | 1161 //it = qLowerBound(m_sourceRowCache.begin(), m_sourceRowCache.end(), sourceIndex.row()); |
1162 if (*it != sourceIndex.row()) | 1162 int it = 0; |
1163 it = qLowerBound(m_sourceRowCache, sourceIndex.row()); | |
1164 if (it != sourceIndex.row()) | |
1163 --it; | 1165 --it; |
1164 int dateRow = qMax(0, it - m_sourceRowCache.begin()); | 1166 int dateRow = qMax(0, it); |
1165 int row = sourceIndex.row() - m_sourceRowCache[dateRow]; | 1167 int row = sourceIndex.row() - m_sourceRowCache[dateRow]; |
1166 return createIndex(row, sourceIndex.column(), dateRow + 1); | 1168 return createIndex(row, sourceIndex.column(), dateRow + 1); |
1167 } | 1169 } |
1168 | 1170 |
1169 QModelIndex mapToSource(QModelIndex proxyIndex) | 1171 QModelIndex mapToSource(QModelIndex proxyIndex) |
1288 { | 1290 { |
1289 assert(!parent.isValid()); | 1291 assert(!parent.isValid()); |
1290 if (m_sourceRowCache.length == 0) | 1292 if (m_sourceRowCache.length == 0) |
1291 return; | 1293 return; |
1292 for (int i = end; i >= start;) { | 1294 for (int i = end; i >= start;) { |
1293 int[]::iterator it; | 1295 //int[]::iterator it; |
1294 it = qLowerBound(m_sourceRowCache.begin(), m_sourceRowCache.end(), i); | 1296 //it = qLowerBound(m_sourceRowCache.begin(), m_sourceRowCache.end(), i); |
1297 int it; | |
1298 it = qLowerBound(m_sourceRowCache, i); | |
1295 // playing it safe | 1299 // playing it safe |
1296 if (it == m_sourceRowCache.end()) { | 1300 if (it == m_sourceRowCache.length) { |
1297 m_sourceRowCache = null; | 1301 m_sourceRowCache.length = 0; |
1298 reset(); | 1302 reset(); |
1299 return; | 1303 return; |
1300 } | 1304 } |
1301 | 1305 |
1302 if (*it != i) | 1306 if (it != i) |
1303 --it; | 1307 --it; |
1304 int row = qMax(0, it - m_sourceRowCache.begin()); | 1308 int row = qMax(0, it); |
1305 int offset = m_sourceRowCache[row]; | 1309 int offset = m_sourceRowCache[row]; |
1306 QModelIndex dateParent = index(row, 0); | 1310 QModelIndex dateParent = index(row, 0); |
1307 // If we can remove all the rows in the date do that and skip over them | 1311 // If we can remove all the rows in the date do that and skip over them |
1308 int rc = rowCount(dateParent); | 1312 int rc = rowCount(dateParent); |
1309 if (i - rc + 1 == offset && start <= i - rc + 1) { | 1313 if (i - rc + 1 == offset && start <= i - rc + 1) { |
1400 int header = fm.width(QLatin1Char('m')) * 40; | 1404 int header = fm.width(QLatin1Char('m')) * 40; |
1401 tree.header().resizeSection(0, header); | 1405 tree.header().resizeSection(0, header); |
1402 tree.header().setStretchLastSection(true); | 1406 tree.header().setStretchLastSection(true); |
1403 tree.activated(QModelIndex).connect(this.open); | 1407 tree.activated(QModelIndex).connect(this.open); |
1404 tree.setContextMenuPolicy(Qt.CustomContextMenu); | 1408 tree.setContextMenuPolicy(Qt.CustomContextMenu); |
1405 tree.customContextMenuRequested(QPoint).connect(&this.customContextMenuRequested(QPoint)); | 1409 tree.customContextMenuRequested.connect(&this.customContextMenuRequested); |
1406 } | 1410 } |
1407 | 1411 |
1408 private: | 1412 private: |
1409 | 1413 |
1410 void customContextMenuRequested(QPoint pos) | 1414 void customContextMenuRequested(QPoint pos) |