File indexing completed on 2025-01-19 03:57:44
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2010-03-20 0007 * Description : sub class of QStandardItem to represent the images 0008 * 0009 * SPDX-FileCopyrightText: 2010 by Michael G. Hansen <mike at mghansen dot de> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #include "myimageitem.h" 0016 0017 MyImageItem::MyImageItem(const QUrl& url, const GeoCoordinates& itemCoordinates) 0018 : QTreeWidgetItem(), 0019 coordinates (itemCoordinates), 0020 imageUrl (url) 0021 { 0022 } 0023 0024 MyImageItem::~MyImageItem() 0025 { 0026 } 0027 0028 QVariant MyImageItem::data(int column, int role) const 0029 { 0030 if (role == RoleCoordinates) 0031 { 0032 return QVariant::fromValue(coordinates); 0033 } 0034 else if (role == Qt::DisplayRole) 0035 { 0036 switch (column) 0037 { 0038 case 0: 0039 { 0040 return imageUrl.fileName(); 0041 } 0042 0043 case 1: 0044 { 0045 return coordinates.geoUrl(); 0046 } 0047 0048 default: 0049 { 0050 return QVariant(); 0051 } 0052 } 0053 } 0054 0055 return QTreeWidgetItem::data(column, role); 0056 } 0057 0058 void MyImageItem::setData(int column, int role, const QVariant& value) 0059 { 0060 if (role == RoleCoordinates) 0061 { 0062 if (value.canConvert<GeoCoordinates>()) 0063 { 0064 coordinates = value.value<GeoCoordinates>(); 0065 emitDataChanged(); 0066 } 0067 0068 return; 0069 } 0070 0071 QTreeWidgetItem::setData(column, role, value); 0072 }