Skip to content

Commit d293c5d

Browse files
committed
Code shuffle to avoid duplicate code
1 parent 99faf06 commit d293c5d

26 files changed

+404
-980
lines changed

python/core/core_auto.sip

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,10 @@
169169
%Include layout/qgslayoututils.sip
170170
%Include layout/qgsreportsectionfieldgroup.sip
171171
%Include layout/qgsreportsectionlayout.sip
172+
%Include metadata/qgsabstractmetadatabase.sip
172173
%Include metadata/qgslayermetadata.sip
173174
%Include metadata/qgslayermetadatavalidator.sip
174175
%Include metadata/qgslayermetadataformatter.sip
175-
%Include metadata/qgsmetadatabase.sip
176176
%Include metadata/qgsprojectmetadata.sip
177177
%Include processing/qgsprocessing.sip
178178
%Include processing/qgsprocessingalgorithm.sip

python/core/metadata/qgsmetadatabase.sip.in renamed to python/core/metadata/qgsabstractmetadatabase.sip.in

+56-38
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/************************************************************************
22
* This file has been generated automatically from *
33
* *
4-
* src/core/metadata/qgsmetadatabase.h *
4+
* src/core/metadata/qgsabstractmetadatabase.h *
55
* *
66
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
77
************************************************************************/
@@ -10,38 +10,39 @@
1010

1111

1212

13-
class QgsMetadataBase
13+
class QgsAbstractMetadataBase
1414
{
1515
%Docstring
16-
A base class for metadata stores.
16+
An abstract base class for metadata stores.
1717

18-
QgsMetadataBase is the base class for handling storage and management of the metadata
18+
QgsAbstractMetadataBase is the base class for handling storage and management of the metadata
1919
for various map related assets. This class is an internal QGIS format with a common
2020
metadata structure. It is subclassed by layer and project specific metadata classes,
21-
QgsLayerMetadata and QgsProjectMetadata.
21+
such as QgsLayerMetadata and QgsProjectMetadata.
2222

2323
The metadata store is designed to be compatible with the Dublin Core metadata
2424
specifications, and will be expanded to allow compatibility with ISO specifications
2525
in future releases. However, the QGIS internal schema does not represent a superset
2626
of all existing metadata schemas and accordingly conversion from specific
27-
metadata formats to QgsMetadataBase may result in a loss of information.
27+
metadata formats to QgsAbstractMetadataBase may result in a loss of information.
2828

2929
This class is designed to follow the specifications detailed in
3030
the schema definition available at resources/qgis-resource-metadata.xsd
3131
within the QGIS source code.
3232

33-
Metadata can be validated through the use of QgsMetadataBaseValidator
33+
Metadata can be validated through the use of QgsAbstractMetadataBaseValidator
3434
subclasses. E.g. validating against the native QGIS metadata schema can be performed
3535
using QgsNativeMetadataValidator.
3636

3737
.. versionadded:: 3.2
3838
%End
3939

4040
%TypeHeaderCode
41-
#include "qgsmetadatabase.h"
41+
#include "qgsabstractmetadatabase.h"
4242
%End
4343
public:
4444

45+
4546
typedef QMap< QString, QStringList > KeywordMap;
4647

4748
struct Address
@@ -64,7 +65,7 @@ Constructor for Address.
6465

6566
QString country;
6667

67-
bool operator==( const QgsMetadataBase::Address &other ) const;
68+
bool operator==( const QgsAbstractMetadataBase::Address &other ) const;
6869
};
6970

7071
struct Contact
@@ -81,7 +82,7 @@ Constructor for Contact.
8182

8283
QString position;
8384

84-
QList< QgsMetadataBase::Address > addresses;
85+
QList< QgsAbstractMetadataBase::Address > addresses;
8586

8687
QString voice;
8788

@@ -91,10 +92,10 @@ Constructor for Contact.
9192

9293
QString role;
9394

94-
bool operator==( const QgsMetadataBase::Contact &other ) const;
95+
bool operator==( const QgsAbstractMetadataBase::Contact &other ) const;
9596
};
9697

97-
typedef QList< QgsMetadataBase::Contact > ContactList;
98+
typedef QList< QgsAbstractMetadataBase::Contact > ContactList;
9899

99100

100101
struct Link
@@ -119,17 +120,12 @@ Constructor for Link.
119120

120121
QString size;
121122

122-
bool operator==( const QgsMetadataBase::Link &other ) const;
123+
bool operator==( const QgsAbstractMetadataBase::Link &other ) const;
123124
};
124125

125-
typedef QList< QgsMetadataBase::Link > LinkList;
126+
typedef QList< QgsAbstractMetadataBase::Link > LinkList;
126127

127-
QgsMetadataBase();
128-
%Docstring
129-
Constructor for QgsMetadataBase.
130-
%End
131-
132-
virtual ~QgsMetadataBase();
128+
virtual ~QgsAbstractMetadataBase();
133129

134130
QString identifier() const;
135131
%Docstring
@@ -250,7 +246,7 @@ Adds a single history ``text`` to the end of the existing history list.
250246
.. seealso:: :py:func:`setHistory`
251247
%End
252248

253-
KeywordMap keywords() const;
249+
QgsAbstractMetadataBase::KeywordMap keywords() const;
254250
%Docstring
255251
Returns the keywords map, which is a set of descriptive keywords associated with the resource.
256252

@@ -264,7 +260,7 @@ associated with keyword list.
264260
.. seealso:: :py:func:`keywordVocabularies`
265261
%End
266262

267-
void setKeywords( const KeywordMap &keywords );
263+
void setKeywords( const QgsAbstractMetadataBase::KeywordMap &keywords );
268264
%Docstring
269265
Sets the ``keywords`` map, which is a set of descriptive keywords associated with the resource.
270266

@@ -338,14 +334,14 @@ Categories are stored using a special vocabulary 'gmd:topicCategory' in keywords
338334
.. seealso:: :py:func:`keywords`
339335
%End
340336

341-
QgsMetadataBase::ContactList contacts() const;
337+
QgsAbstractMetadataBase::ContactList contacts() const;
342338
%Docstring
343339
Returns a list of contact persons or entities associated with the resource.
344340

345341
.. seealso:: :py:func:`setContacts`
346342
%End
347343

348-
void setContacts( const QgsMetadataBase::ContactList &contacts );
344+
void setContacts( const QgsAbstractMetadataBase::ContactList &contacts );
349345
%Docstring
350346
Sets the list of ``contacts`` or entities associated with the resource. Any existing contacts
351347
will be replaced.
@@ -355,7 +351,7 @@ will be replaced.
355351
.. seealso:: :py:func:`addContact`
356352
%End
357353

358-
void addContact( const QgsMetadataBase::Contact &contact );
354+
void addContact( const QgsAbstractMetadataBase::Contact &contact );
359355
%Docstring
360356
Adds an individual ``contact`` to the existing contacts.
361357

@@ -364,14 +360,14 @@ Adds an individual ``contact`` to the existing contacts.
364360
.. seealso:: :py:func:`setContacts`
365361
%End
366362

367-
QgsMetadataBase::LinkList links() const;
363+
QgsAbstractMetadataBase::LinkList links() const;
368364
%Docstring
369365
Returns a list of online resources associated with the resource.
370366

371367
.. seealso:: :py:func:`setLinks`
372368
%End
373369

374-
void setLinks( const QgsMetadataBase::LinkList &links );
370+
void setLinks( const QgsAbstractMetadataBase::LinkList &links );
375371
%Docstring
376372
Sets the list of online resources associated with the resource. Any existing links
377373
will be replaced.
@@ -381,7 +377,7 @@ will be replaced.
381377
.. seealso:: :py:func:`addLink`
382378
%End
383379

384-
void addLink( const QgsMetadataBase::Link &link );
380+
void addLink( const QgsAbstractMetadataBase::Link &link );
385381
%Docstring
386382
Adds an individual ``link`` to the existing links.
387383

@@ -390,43 +386,65 @@ Adds an individual ``link`` to the existing links.
390386
.. seealso:: :py:func:`setLinks`
391387
%End
392388

393-
bool readMetadataXml( const QDomElement &metadataElement );
389+
virtual bool readMetadataXml( const QDomElement &metadataElement );
394390
%Docstring
395-
Sets state from Dom document
391+
Sets state from DOM document.
396392

397-
:param metadataElement: The Dom element corresponding to ``resourceMetadata'' tag
393+
:param metadataElement: The DOM element corresponding to ``resourceMetadata'' tag
398394

399395
:return: true if successful
396+
397+
Subclasses which override this method should take care to also call the base
398+
class method in order to read common metadata properties.
400399
%End
401400

402-
bool writeMetadataXml( QDomElement &metadataElement, QDomDocument &document ) const;
401+
virtual bool writeMetadataXml( QDomElement &metadataElement, QDomDocument &document ) const;
403402
%Docstring
404-
Stores state in Dom node
403+
Stores state in a DOM node.
405404

406-
:param metadataElement: is a Dom element corresponding to ``resourceMetadata'' tag
407-
:param document: is a the dom document being written
405+
:param metadataElement: is a DOM element corresponding to ``resourceMetadata'' tag
406+
:param document: is a the DOM document being written
408407

409408
:return: true if successful
410-
%End
411409

412-
bool operator==( const QgsMetadataBase &metadataOther ) const;
410+
Subclasses which override this method should take care to also call the base
411+
class method in order to write common metadata properties.
412+
%End
413413

414414
protected:
415415

416+
QgsAbstractMetadataBase();
417+
%Docstring
418+
Constructor for QgsAbstractMetadataBase.
419+
420+
QgsAbstractMetadataBase cannot be instantiated directly, it must be subclassed.
421+
%End
422+
423+
416424

417425

418426

419427

420428

421429

422430

431+
bool equals( const QgsAbstractMetadataBase &other ) const;
432+
%Docstring
433+
Tests whether the common metadata fields in this object are equal to ``other``.
434+
435+
Subclasses should utilise this method from their equality operators to test
436+
equality of base class members.
437+
438+
.. versionadded:: 3.2
439+
%End
440+
423441
};
424442

425443

426444
/************************************************************************
427445
* This file has been generated automatically from *
428446
* *
429-
* src/core/metadata/qgsmetadatabase.h *
447+
* src/core/metadata/qgsabstractmetadatabase.h *
430448
* *
431449
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
432450
************************************************************************/

python/core/metadata/qgslayermetadata.sip.in

+3-35
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212

13-
class QgsLayerMetadata : QgsMetadataBase
13+
class QgsLayerMetadata : QgsAbstractMetadataBase
1414
{
1515
%Docstring
1616
A structured metadata store for a map layer.
@@ -42,9 +42,6 @@ using QgsNativeMetadataValidator.
4242
%End
4343
public:
4444

45-
46-
typedef QgsMetadataBase::KeywordMap KeywordMap;
47-
4845
struct SpatialExtent
4946
{
5047

@@ -113,21 +110,6 @@ Constructor for Constraint.
113110

114111
typedef QList< QgsLayerMetadata::Constraint > ConstraintList;
115112

116-
117-
typedef QgsMetadataBase::Address Address;
118-
119-
120-
typedef QgsMetadataBase::Contact Contact;
121-
122-
123-
typedef QgsMetadataBase::ContactList ContactList;
124-
125-
126-
typedef QgsMetadataBase::Link Link;
127-
128-
129-
typedef QgsMetadataBase::LinkList LinkList;
130-
131113
QgsLayerMetadata();
132114
%Docstring
133115
Constructor for QgsLayerMetadata.
@@ -286,24 +268,10 @@ Reads the metadata state from a ``layer``'s custom properties (see QgsMapLayer.c
286268
.. seealso:: :py:func:`saveToLayer`
287269
%End
288270

289-
bool readMetadataXml( const QDomElement &metadataElement );
290-
%Docstring
291-
Sets state from Dom document
271+
virtual bool readMetadataXml( const QDomElement &metadataElement );
292272

293-
:param metadataElement: The Dom element corresponding to ``resourceMetadata'' tag
294-
295-
:return: true if successful
296-
%End
273+
virtual bool writeMetadataXml( QDomElement &metadataElement, QDomDocument &document ) const;
297274

298-
bool writeMetadataXml( QDomElement &metadataElement, QDomDocument &document ) const;
299-
%Docstring
300-
Stores state in Dom node
301-
302-
:param metadataElement: is a Dom element corresponding to ``resourceMetadata'' tag
303-
:param document: is a the dom document being written
304-
305-
:return: true if successful
306-
%End
307275

308276
bool operator==( const QgsLayerMetadata &metadataOther ) const;
309277

python/core/metadata/qgslayermetadatavalidator.sip.in

+7-7
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313

14-
class QgsMetadataValidator
14+
class QgsAbstractMetadataBaseValidator
1515
{
1616
%Docstring
1717
Abstract base class for metadata validators.
@@ -39,9 +39,9 @@ Constructor for ValidationResult.
3939
QString note;
4040
};
4141

42-
virtual ~QgsMetadataValidator();
42+
virtual ~QgsAbstractMetadataBaseValidator();
4343

44-
virtual bool validate( const QgsMetadataBase *metadata, QList< QgsMetadataValidator::ValidationResult > &results /Out/ ) const = 0;
44+
virtual bool validate( const QgsAbstractMetadataBase *metadata, QList< QgsAbstractMetadataBaseValidator::ValidationResult > &results /Out/ ) const = 0;
4545
%Docstring
4646
Validates a ``metadata`` object, and returns true if the
4747
metadata is considered valid.
@@ -53,7 +53,7 @@ to fix the metadata.
5353
};
5454

5555

56-
class QgsNativeMetadataBaseValidator : QgsMetadataValidator
56+
class QgsNativeMetadataBaseValidator : QgsAbstractMetadataBaseValidator
5757
{
5858
%Docstring
5959
A validator for the native base QGIS metadata schema definition.
@@ -71,7 +71,7 @@ class QgsNativeMetadataBaseValidator : QgsMetadataValidator
7171
Constructor for QgsNativeMetadataBaseValidator.
7272
%End
7373

74-
virtual bool validate( const QgsMetadataBase *metadata, QList< QgsMetadataValidator::ValidationResult > &results /Out/ ) const;
74+
virtual bool validate( const QgsAbstractMetadataBase *metadata, QList< QgsAbstractMetadataBaseValidator::ValidationResult > &results /Out/ ) const;
7575

7676

7777
};
@@ -96,7 +96,7 @@ class QgsNativeMetadataValidator : QgsNativeMetadataBaseValidator
9696
Constructor for QgsNativeMetadataValidator.
9797
%End
9898

99-
virtual bool validate( const QgsMetadataBase *metadata, QList< QgsMetadataValidator::ValidationResult > &results /Out/ ) const;
99+
virtual bool validate( const QgsAbstractMetadataBase *metadata, QList< QgsAbstractMetadataBaseValidator::ValidationResult > &results /Out/ ) const;
100100

101101

102102
};
@@ -120,7 +120,7 @@ class QgsNativeProjectMetadataValidator : QgsNativeMetadataBaseValidator
120120
Constructor for QgsNativeProjectMetadataValidator.
121121
%End
122122

123-
virtual bool validate( const QgsMetadataBase *metadata, QList< QgsMetadataValidator::ValidationResult > &results /Out/ ) const;
123+
virtual bool validate( const QgsAbstractMetadataBase *metadata, QList< QgsAbstractMetadataBaseValidator::ValidationResult > &results /Out/ ) const;
124124

125125

126126
};

0 commit comments

Comments
 (0)