Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Krita
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tusooa Zhu
Krita
Commits
7ba3ffcf
Commit
7ba3ffcf
authored
Jun 29, 2018
by
Boudewijn Rempt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement skeleton tag iterators
parent
6f3e934c
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
205 additions
and
5 deletions
+205
-5
libs/resources/KisAbrStorage.cpp
libs/resources/KisAbrStorage.cpp
+26
-0
libs/resources/KisAbrStorage.h
libs/resources/KisAbrStorage.h
+1
-0
libs/resources/KisAslStorage.cpp
libs/resources/KisAslStorage.cpp
+28
-0
libs/resources/KisAslStorage.h
libs/resources/KisAslStorage.h
+1
-1
libs/resources/KisBundleStorage.cpp
libs/resources/KisBundleStorage.cpp
+30
-1
libs/resources/KisBundleStorage.h
libs/resources/KisBundleStorage.h
+1
-0
libs/resources/KisFolderStorage.cpp
libs/resources/KisFolderStorage.cpp
+38
-3
libs/resources/KisFolderStorage.h
libs/resources/KisFolderStorage.h
+2
-0
libs/resources/KisResourceStorage.h
libs/resources/KisResourceStorage.h
+14
-0
libs/resources/KisStoragePlugin.h
libs/resources/KisStoragePlugin.h
+1
-0
libs/resources/KisTagLoader.cpp
libs/resources/KisTagLoader.cpp
+25
-0
libs/resources/KisTagLoader.h
libs/resources/KisTagLoader.h
+38
-0
No files found.
libs/resources/KisAbrStorage.cpp
View file @
7ba3ffcf
...
...
@@ -20,6 +20,27 @@
#include "KisAbrStorage.h"
#include "KisResourceStorage.h"
class
AbrTagIterator
:
public
KisResourceStorage
::
TagIterator
{
public:
AbrTagIterator
(
const
QString
&
location
,
const
QString
&
resourceType
)
:
m_location
(
location
)
,
m_resourceType
(
resourceType
)
{}
bool
hasNext
()
const
override
{
return
false
;
}
void
next
()
const
override
{}
QString
url
()
const
override
{
return
QString
();
}
QString
name
()
const
override
{
return
QString
();
}
QString
comment
()
const
override
{
return
QString
();
}
private:
QString
m_location
;
QString
m_resourceType
;
};
class
AbrIterator
:
public
KisResourceStorage
::
ResourceIterator
{
public:
...
...
@@ -61,3 +82,8 @@ QSharedPointer<KisResourceStorage::ResourceIterator> KisAbrStorage::resources(co
{
return
QSharedPointer
<
KisResourceStorage
::
ResourceIterator
>
(
new
AbrIterator
);
}
QSharedPointer
<
KisResourceStorage
::
TagIterator
>
KisAbrStorage
::
tags
(
const
QString
&
resourceType
)
{
return
QSharedPointer
<
KisResourceStorage
::
TagIterator
>
(
new
AbrTagIterator
(
location
(),
resourceType
));
}
libs/resources/KisAbrStorage.h
View file @
7ba3ffcf
...
...
@@ -32,6 +32,7 @@ public:
KoResourceSP
resource
(
const
QString
&
url
)
override
;
QSharedPointer
<
KisResourceStorage
::
ResourceIterator
>
resources
(
const
QString
&
resourceType
)
override
;
QSharedPointer
<
KisResourceStorage
::
TagIterator
>
tags
(
const
QString
&
resourceType
)
override
;
};
...
...
libs/resources/KisAslStorage.cpp
View file @
7ba3ffcf
...
...
@@ -20,6 +20,29 @@
#include "KisAslStorage.h"
#include <KisResourceStorage.h>
class
AslTagIterator
:
public
KisResourceStorage
::
TagIterator
{
public:
AslTagIterator
(
const
QString
&
location
,
const
QString
&
resourceType
)
:
m_location
(
location
)
,
m_resourceType
(
resourceType
)
{}
bool
hasNext
()
const
override
{
return
false
;
}
void
next
()
const
override
{}
QString
url
()
const
override
{
return
QString
();
}
QString
name
()
const
override
{
return
QString
();
}
QString
comment
()
const
override
{
return
QString
();
}
private:
QString
m_location
;
QString
m_resourceType
;
};
class
AslIterator
:
public
KisResourceStorage
::
ResourceIterator
{
public:
...
...
@@ -60,3 +83,8 @@ QSharedPointer<KisResourceStorage::ResourceIterator> KisAslStorage::resources(co
{
return
QSharedPointer
<
KisResourceStorage
::
ResourceIterator
>
(
new
AslIterator
);
}
QSharedPointer
<
KisResourceStorage
::
TagIterator
>
KisAslStorage
::
tags
(
const
QString
&
resourceType
)
{
return
QSharedPointer
<
KisResourceStorage
::
TagIterator
>
(
new
AslTagIterator
(
location
(),
resourceType
));
}
libs/resources/KisAslStorage.h
View file @
7ba3ffcf
...
...
@@ -31,7 +31,7 @@ public:
KisResourceStorage
::
ResourceItem
resourceItem
(
const
QString
&
url
)
override
;
KoResourceSP
resource
(
const
QString
&
url
)
override
;
QSharedPointer
<
KisResourceStorage
::
ResourceIterator
>
resources
(
const
QString
&
resourceType
)
override
;
QSharedPointer
<
KisResourceStorage
::
TagIterator
>
tags
(
const
QString
&
resourceType
)
override
;
};
#endif // KISASLSTORAGE_H
libs/resources/KisBundleStorage.cpp
View file @
7ba3ffcf
...
...
@@ -21,6 +21,29 @@
#include "KisResourceStorage.h"
class
BundleTagIterator
:
public
KisResourceStorage
::
TagIterator
{
public:
BundleTagIterator
(
const
QString
&
location
,
const
QString
&
resourceType
)
:
m_location
(
location
)
,
m_resourceType
(
resourceType
)
{}
bool
hasNext
()
const
override
{
return
false
;
}
void
next
()
const
override
{}
QString
url
()
const
override
{
return
QString
();
}
QString
name
()
const
override
{
return
QString
();
}
QString
comment
()
const
override
{
return
QString
();
}
private:
QString
m_location
;
QString
m_resourceType
;
};
class
BundleIterator
:
public
KisResourceStorage
::
ResourceIterator
{
public:
...
...
@@ -57,5 +80,11 @@ KoResourceSP KisBundleStorage::resource(const QString &url)
QSharedPointer
<
KisResourceStorage
::
ResourceIterator
>
KisBundleStorage
::
resources
(
const
QString
&
resourceType
)
{
return
QSharedPointer
<
KisResourceStorage
::
ResourceIterator
>
(
new
BundleIterator
);
return
QSharedPointer
<
KisResourceStorage
::
ResourceIterator
>
(
new
BundleIterator
);
}
QSharedPointer
<
KisResourceStorage
::
TagIterator
>
KisBundleStorage
::
tags
(
const
QString
&
resourceType
)
{
return
QSharedPointer
<
KisResourceStorage
::
TagIterator
>
(
new
BundleTagIterator
(
location
(),
resourceType
));
}
libs/resources/KisBundleStorage.h
View file @
7ba3ffcf
...
...
@@ -31,6 +31,7 @@ public:
KisResourceStorage
::
ResourceItem
resourceItem
(
const
QString
&
url
)
override
;
KoResourceSP
resource
(
const
QString
&
url
)
override
;
QSharedPointer
<
KisResourceStorage
::
ResourceIterator
>
resources
(
const
QString
&
resourceType
)
override
;
QSharedPointer
<
KisResourceStorage
::
TagIterator
>
tags
(
const
QString
&
resourceType
)
override
;
};
#endif // KISBUNDLESTORAGE_H
libs/resources/KisFolderStorage.cpp
View file @
7ba3ffcf
...
...
@@ -25,6 +25,36 @@
#include <KisResourceLoaderRegistry.h>
class
FolderTagIterator
:
public
KisResourceStorage
::
TagIterator
{
public:
FolderTagIterator
(
const
QString
&
location
,
const
QString
&
resourceType
)
:
m_location
(
location
)
,
m_resourceType
(
resourceType
)
{
m_dirIterator
.
reset
(
new
QDirIterator
(
location
+
'/'
+
resourceType
,
QStringList
()
<<
"*.tag"
,
QDir
::
Files
|
QDir
::
Readable
,
QDirIterator
::
Subdirectories
));
}
bool
hasNext
()
const
override
{
return
false
;
}
void
next
()
const
override
{}
QString
url
()
const
override
{
return
QString
();
}
QString
name
()
const
override
{
return
QString
();
}
QString
comment
()
const
override
{
return
QString
();
}
private:
QScopedPointer
<
QDirIterator
>
m_dirIterator
;
QString
m_location
;
QString
m_resourceType
;
};
class
FolderItem
:
public
KisResourceStorage
::
ResourceItem
{
public:
...
...
@@ -54,9 +84,9 @@ public:
,
m_resourceType
(
resourceType
)
{
m_dirIterator
.
reset
(
new
QDirIterator
(
location
+
'/'
+
resourceType
,
KisResourceLoaderRegistry
::
instance
()
->
filters
(
resourceType
),
QDir
::
Files
|
QDir
::
Readable
,
QDirIterator
::
Subdirectories
));
KisResourceLoaderRegistry
::
instance
()
->
filters
(
resourceType
),
QDir
::
Files
|
QDir
::
Readable
,
QDirIterator
::
Subdirectories
));
}
~
FolderIterator
()
override
{}
...
...
@@ -164,3 +194,8 @@ QSharedPointer<KisResourceStorage::ResourceIterator> KisFolderStorage::resources
{
return
QSharedPointer
<
KisResourceStorage
::
ResourceIterator
>
(
new
FolderIterator
(
location
(),
resourceType
));
}
QSharedPointer
<
KisResourceStorage
::
TagIterator
>
KisFolderStorage
::
tags
(
const
QString
&
resourceType
)
{
return
QSharedPointer
<
KisResourceStorage
::
TagIterator
>
(
new
FolderTagIterator
(
location
(),
resourceType
));
}
libs/resources/KisFolderStorage.h
View file @
7ba3ffcf
...
...
@@ -33,6 +33,8 @@ public:
KisResourceStorage
::
ResourceItem
resourceItem
(
const
QString
&
url
)
override
;
KoResourceSP
resource
(
const
QString
&
url
)
override
;
QSharedPointer
<
KisResourceStorage
::
ResourceIterator
>
resources
(
const
QString
&
resourceType
)
override
;
QSharedPointer
<
KisResourceStorage
::
TagIterator
>
tags
(
const
QString
&
resourceType
)
override
;
};
...
...
libs/resources/KisResourceStorage.h
View file @
7ba3ffcf
...
...
@@ -53,6 +53,20 @@ public:
virtual
QByteArray
md5sum
()
const
{
return
QByteArray
();}
};
class
TagIterator
{
public:
virtual
~
TagIterator
()
{}
virtual
bool
hasNext
()
const
=
0
;
virtual
void
next
()
const
=
0
;
/// The untranslated name of the tag, to be used for making connections to resources
virtual
QString
url
()
const
=
0
;
/// The translated name of the tag, to be shown in the GUI
virtual
QString
name
()
const
=
0
;
/// An extra, optional comment for the tag
virtual
QString
comment
()
const
=
0
;
};
class
ResourceIterator
{
...
...
libs/resources/KisStoragePlugin.h
View file @
7ba3ffcf
...
...
@@ -41,6 +41,7 @@ public:
virtual
KisResourceStorage
::
ResourceItem
resourceItem
(
const
QString
&
url
)
=
0
;
virtual
KoResourceSP
resource
(
const
QString
&
url
)
=
0
;
virtual
QSharedPointer
<
KisResourceStorage
::
ResourceIterator
>
resources
(
const
QString
&
resourceType
)
=
0
;
virtual
QSharedPointer
<
KisResourceStorage
::
TagIterator
>
tags
(
const
QString
&
resourceType
)
=
0
;
protected:
QString
location
()
const
;
...
...
libs/resources/KisTagLoader.cpp
0 → 100644
View file @
7ba3ffcf
/*
* Copyright (C) 2018 Boudewijn Rempt <boud@valdyas.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "KisTagLoader.h"
KisTagLoader
::
KisTagLoader
()
{
}
libs/resources/KisTagLoader.h
0 → 100644
View file @
7ba3ffcf
/*
* Copyright (C) 2018 Boudewijn Rempt <boud@valdyas.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KISTAGLOADER_H
#define KISTAGLOADER_H
/**
* @brief The KisTagLoader loads a tag from a .tag file.
* A .tag file is a .desktop file. The following fields
* are important:
*
* name: the name of the tag, which can be translated
* comment: a tooltip for the tag, which can be translagted
* url: the untranslated name of the tag
*/
class
KisTagLoader
{
public:
KisTagLoader
();
};
#endif // KISTAGLOADER_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment