mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Alternate background colors for dive list
This was written with massive hand-holding by Tomaz - actually, this was mostly proposed via IRC by Tomaz and then implemented by me... Right now because of the list-of-lists nature of the model we have the small issue that every trip starts with a dark background dive, even if the trip itself has a dark background. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									c4e2c322a3
								
							
						
					
					
						commit
						021ef8ad09
					
				
					 2 changed files with 9 additions and 3 deletions
				
			
		|  | @ -15,14 +15,16 @@ void StarWidgetsDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o | ||||||
| 
 | 
 | ||||||
| 	QVariant value = index.model()->data(index, Qt::DisplayRole); | 	QVariant value = index.model()->data(index, Qt::DisplayRole); | ||||||
| 
 | 
 | ||||||
|  | 	if(option.state & QStyle::State_Selected) | ||||||
|  | 		painter->fillRect(option.rect, option.palette.highlight()); | ||||||
|  | 	else | ||||||
|  | 		painter->fillRect(option.rect, index.model()->data(index, Qt::BackgroundRole).value<QBrush>()); | ||||||
|  | 
 | ||||||
| 	if (!value.isValid()) | 	if (!value.isValid()) | ||||||
| 		return; | 		return; | ||||||
| 
 | 
 | ||||||
| 	int rating = value.toInt(); | 	int rating = value.toInt(); | ||||||
| 
 | 
 | ||||||
| 	if(option.state & QStyle::State_Selected) |  | ||||||
| 		painter->fillRect(option.rect, option.palette.highlight()); |  | ||||||
| 
 |  | ||||||
| 	painter->save(); | 	painter->save(); | ||||||
| 	painter->setRenderHint(QPainter::Antialiasing, true); | 	painter->setRenderHint(QPainter::Antialiasing, true); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -7,6 +7,8 @@ | ||||||
| #include "models.h" | #include "models.h" | ||||||
| #include <QCoreApplication> | #include <QCoreApplication> | ||||||
| #include <QDebug> | #include <QDebug> | ||||||
|  | #include <QColor> | ||||||
|  | #include <QBrush> | ||||||
| 
 | 
 | ||||||
| extern struct tank_info tank_info[100]; | extern struct tank_info tank_info[100]; | ||||||
| 
 | 
 | ||||||
|  | @ -599,6 +601,8 @@ QVariant DiveTripModel::data(const QModelIndex& index, int role) const | ||||||
| 	if (!index.isValid()) | 	if (!index.isValid()) | ||||||
| 		return QVariant(); | 		return QVariant(); | ||||||
| 
 | 
 | ||||||
|  | 	if (role == Qt::BackgroundRole) | ||||||
|  | 		return QBrush(QColor(index.row() % 2 ? Qt::white : QColor(Qt::lightGray).lighter(120))); | ||||||
| 
 | 
 | ||||||
| 	TreeItemDT* item = static_cast<TreeItemDT*>(index.internalPointer()); | 	TreeItemDT* item = static_cast<TreeItemDT*>(index.internalPointer()); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue