QGIS API Documentation 4.3.0-Master (389d690bb77)
Loading...
Searching...
No Matches
qgsstacitemcollection.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsstacitemcollection.cpp
3 ---------------------
4 begin : August 2024
5 copyright : (C) 2024 by Stefanos Natsis
6 email : uclaros at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
17
18#include "qgsstacitem.h"
19
20#include <QString>
21
22using namespace Qt::StringLiterals;
23
24QgsStacItemCollection::QgsStacItemCollection( const QVector< QgsStacItem * > &items, const QVector< QgsStacLink > &links, int numberMatched )
25 : mItems( items )
26 , mLinks( links )
27 , mNumberMatched( numberMatched )
28{
29 for ( const QgsStacLink &link : mLinks )
30 {
31 if ( link.relation() == "self"_L1 || link.relation() == "root"_L1 || link.relation() == "parent"_L1 || link.relation() == "collection"_L1 || link.relation() == "next"_L1 )
32 mUrls.insert( link.relation(), link.href() );
33 }
34}
35
37{
38 qDeleteAll( mItems );
39}
40
41QVector< QgsStacItem * > QgsStacItemCollection::items() const
42{
43 return mItems;
44}
45
46QVector< QgsStacItem * > QgsStacItemCollection::takeItems()
47{
48 QVector< QgsStacItem * > items = mItems;
49 mItems.clear(); // detach
50 return items;
51}
52
54{
55 return QUrl( mUrls.value( u"self"_s, QString() ) );
56}
57
59{
60 return QUrl( mUrls.value( u"root"_s, QString() ) );
61}
62
64{
65 return QUrl( mUrls.value( u"parent"_s, QString() ) );
66}
67
69{
70 return QUrl( mUrls.value( u"collection"_s, QString() ) );
71}
72
74{
75 return QUrl( mUrls.value( u"next"_s, QString() ) );
76}
77
79{
80 return mItems.size();
81}
82
84{
85 return mNumberMatched;
86}
int numberReturned() const
Returns the number of items in the collection.
QUrl parentUrl() const
Returns the url of the item collection's "parent" link.
QVector< QgsStacItem * > items() const
Returns the items in the collection Ownership is not transferred.
QUrl nextUrl() const
Returns the url of the item collection's "next" link.
int numberMatched() const
Returns the total number of items in the parent collection If this information was not available by t...
QgsStacItemCollection()=delete
Default constructor deleted, use the variant with required parameters.
QUrl rootUrl() const
Returns the url of the item collection's "root" link.
QUrl url() const
Returns the url of the item collection's "self" link.
QVector< QgsStacItem * > takeItems()
Returns the items in the collection Caller takes ownership of the returned items.
QUrl collectionUrl() const
Returns the url of the item collection's "collection" link.