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