QGIS API Documentation 3.99.0-Master (d270888f95f)
Loading...
Searching...
No Matches
qgsmetadataurlitemdelegate.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsmetadataurlitemdelegate.cpp
3 ------------------
4 begin : June 21, 2021
5 copyright : (C) 2021 by Etienne Trimaille
6 email : etrimaille at 3liz dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
19
20#include <QComboBox>
21#include <QString>
22#include <QStringListModel>
23
24#include "moc_qgsmetadataurlitemdelegate.cpp"
25
26using namespace Qt::StringLiterals;
27
29
30MetadataUrlItemDelegate::MetadataUrlItemDelegate( QObject *parent )
31 : QStyledItemDelegate( parent )
32{
33}
34
35QWidget *MetadataUrlItemDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const
36{
37 if ( index.column() == 1 )
38 {
39 // Type
40 QComboBox *typeEditor = new QComboBox( parent );
41 QStringList types;
42 types << QString() << u"FGDC"_s << u"TC211"_s;
43 QStringListModel *model = new QStringListModel( parent );
44 model->setStringList( types );
45 typeEditor->setModel( model );
46 return typeEditor;
47 }
48 else if ( index.column() == 2 )
49 {
50 // Format
51 QComboBox *typeFormat = new QComboBox( parent );
52 QStringList formats;
53 formats << QString() << u"text/plain"_s << u"text/xml"_s;
54 QStringListModel *model = new QStringListModel( parent );
55 model->setStringList( formats );
56 typeFormat->setModel( model );
57 return typeFormat;
58 }
59
60 return QStyledItemDelegate::createEditor( parent, option, index );
61}