QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
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
18#include <QComboBox>
19#include <QStringListModel>
20
22
24
25MetadataUrlItemDelegate::MetadataUrlItemDelegate( QObject *parent )
26 : QStyledItemDelegate( parent )
27{
28
29}
30
31QWidget *MetadataUrlItemDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const
32{
33 if ( index.column() == 1 )
34 {
35 // Type
36 QComboBox *typeEditor = new QComboBox( parent );
37 QStringList types;
38 types << QString( ) << QStringLiteral( "FGDC" ) << QStringLiteral( "TC211" );
39 QStringListModel *model = new QStringListModel( parent );
40 model->setStringList( types );
41 typeEditor->setModel( model );
42 return typeEditor;
43 }
44 else if ( index.column() == 2 )
45 {
46 // Format
47 QComboBox *typeFormat = new QComboBox( parent );
48 QStringList formats;
49 formats << QString( ) << QStringLiteral( "text/plain" ) << QStringLiteral( "text/xml" );
50 QStringListModel *model = new QStringListModel( parent );
51 model->setStringList( formats );
52 typeFormat->setModel( model );
53 return typeFormat;
54 }
55
56 return QStyledItemDelegate::createEditor( parent, option, index );
57}