mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Having subsurface-core as a directory name really messes with autocomplete and is obviously redundant. Simmilarly, qt-mobile caused an autocomplete conflict and also was inconsistent with the desktop-widget name for the directory containing the "other" UI. And while cleaning up the resulting change in the path name for include files, I decided to clean up those even more to make them consistent overall. This could have been handled in more commits, but since this requires a make clean before the build, it seemed more sensible to do it all in one. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
		
			
				
	
	
		
			71 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			71 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| #include "qt-models/divecomputerextradatamodel.h"
 | |
| #include "core/dive.h"
 | |
| #include "core/metrics.h"
 | |
| 
 | |
| 
 | |
| ExtraDataModel::ExtraDataModel(QObject *parent) : CleanerTableModel(parent),
 | |
| 	rows(0)
 | |
| {
 | |
| 	//enum Column {KEY, VALUE};
 | |
| 	setHeaderDataStrings(QStringList() << tr("Key") << tr("Value"));
 | |
| }
 | |
| 
 | |
| void ExtraDataModel::clear()
 | |
| {
 | |
| 	if (rows > 0) {
 | |
| 		beginRemoveRows(QModelIndex(), 0, rows - 1);
 | |
| 		endRemoveRows();
 | |
| 	}
 | |
| }
 | |
| 
 | |
| QVariant ExtraDataModel::data(const QModelIndex &index, int role) const
 | |
| {
 | |
| 	QVariant ret;
 | |
| 	struct extra_data *ed = get_dive_dc(&displayed_dive, dc_number)->extra_data;
 | |
| 	int i = -1;
 | |
| 	while (ed && ++i < index.row())
 | |
| 		ed = ed->next;
 | |
| 	if (!ed)
 | |
| 		return ret;
 | |
| 
 | |
| 	switch (role) {
 | |
| 	case Qt::FontRole:
 | |
| 		ret = defaultModelFont();
 | |
| 		break;
 | |
| 	case Qt::TextAlignmentRole:
 | |
| 		ret = int(Qt::AlignLeft | Qt::AlignVCenter);
 | |
| 		break;
 | |
| 	case Qt::DisplayRole:
 | |
| 		switch (index.column()) {
 | |
| 		case KEY:
 | |
| 			ret = QString(ed->key);
 | |
| 			break;
 | |
| 		case VALUE:
 | |
| 			ret = QString(ed->value);
 | |
| 			break;
 | |
| 		}
 | |
| 		break;
 | |
| 	}
 | |
| 	return ret;
 | |
| }
 | |
| 
 | |
| int ExtraDataModel::rowCount(const QModelIndex &parent) const
 | |
| {
 | |
| 	Q_UNUSED(parent);
 | |
| 	return rows;
 | |
| }
 | |
| 
 | |
| void ExtraDataModel::updateDive()
 | |
| {
 | |
| 	clear();
 | |
| 	rows = 0;
 | |
| 	struct extra_data *ed = get_dive_dc(&displayed_dive, dc_number)->extra_data;
 | |
| 	while (ed) {
 | |
| 		rows++;
 | |
| 		ed = ed->next;
 | |
| 	}
 | |
| 	if (rows > 0) {
 | |
| 		beginInsertRows(QModelIndex(), 0, rows - 1);
 | |
| 		endInsertRows();
 | |
| 	}
 | |
| }
 |