QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
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
34QWidget *MetadataUrlItemDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const
35{
36 if ( index.column() == 1 )
37 {
38 // Type
39 QComboBox *typeEditor = new QComboBox( parent );
40 QStringList types;
41 types << QString() << u"FGDC"_s << u"TC211"_s;
42 QStringListModel *model = new QStringListModel( parent );
43 model->setStringList( types );
44 typeEditor->setModel( model );
45 return typeEditor;
46 }
47 else if ( index.column() == 2 )
48 {
49 // Format
50 QComboBox *typeFormat = new QComboBox( parent );
51 QStringList formats;
52 formats << QString() << u"text/plain"_s << u"text/xml"_s;
53 QStringListModel *model = new QStringListModel( parent );
54 model->setStringList( formats );
55 typeFormat->setModel( model );
56 return typeFormat;
57 }
58
59 return QStyledItemDelegate::createEditor( parent, option, index );
60}