mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Merge branch 'RenderStarsOnTable' of https://github.com/tcanabrava/subsurface into Qt
This commit is contained in:
		
						commit
						0794f03b5e
					
				
					 5 changed files with 4 additions and 10 deletions
				
			
		|  | @ -11,4 +11,5 @@ | |||
| DiveListView::DiveListView(QWidget *parent) : QTreeView(parent) | ||||
| { | ||||
| 	setUniformRowHeights(true); | ||||
| 	setItemDelegateForColumn(DiveTripModel::RATING, new StarWidgetsDelegate()); | ||||
| } | ||||
|  |  | |||
|  | @ -69,7 +69,7 @@ void MainWindow::on_actionOpen_triggered() | |||
| 	model->deleteLater(); | ||||
| 	model = new DiveTripModel(this); | ||||
| 	sortModel->setSourceModel(model); | ||||
| 	ui->ListWidget->setItemDelegateForColumn(DiveTripModel::RATING, new StarWidgetsDelegate()); | ||||
| 	ui->ListWidget->sortByColumn(0, Qt::DescendingOrder); | ||||
| } | ||||
| 
 | ||||
| void MainWindow::on_actionSave_triggered() | ||||
|  |  | |||
|  | @ -6,6 +6,7 @@ | |||
| 
 | ||||
| #include <QtDebug> | ||||
| #include <QPainter> | ||||
| #include <QSortFilterProxyModel> | ||||
| 
 | ||||
| void StarWidgetsDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const | ||||
| { | ||||
|  | @ -13,7 +14,7 @@ void StarWidgetsDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o | |||
| 		return; | ||||
| 	} | ||||
| 
 | ||||
| 	int rating = index.model()->data(index, DiveTripModel::DelegatesRole).toInt(); | ||||
| 	int rating = index.model()->data(index, Qt::DisplayRole).toInt(); | ||||
| 
 | ||||
| 	if (option.state & QStyle::State_Selected) | ||||
|          painter->fillRect(option.rect, option.palette.highlight()); | ||||
|  |  | |||
|  | @ -496,13 +496,6 @@ QVariant DiveTripModel::data(const QModelIndex &index, int role) const | |||
| 				break; | ||||
| 		} | ||||
| 	} | ||||
| 	if (role == DelegatesRole){ | ||||
| 		switch(index.column()){ | ||||
| 			case RATING: | ||||
| 				retVal = item->diveRating(); | ||||
| 				break; | ||||
| 		} | ||||
| 	} | ||||
| 	return retVal; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -79,7 +79,6 @@ class DiveTripModel : public QAbstractItemModel | |||
| { | ||||
| public: | ||||
| 	enum Column {NR, DATE, RATING, DEPTH, DURATION, TEMPERATURE, TOTALWEIGHT, SUIT, CYLINDER, NITROX, SAC, OTU, MAXCNS, LOCATION, COLUMNS }; | ||||
| 	enum { DelegatesRole = Qt::UserRole }; | ||||
| 
 | ||||
| 	DiveTripModel(QObject *parent = 0); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue