1 /* Copyright (C) 2003-2006 Jesper K. Pedersen <blackie@kde.org>
3 This program is free software; you can redistribute it and/or
4 modify it under the terms of the GNU General Public
5 License as published by the Free Software Foundation; either
6 version 2 of the License, or (at your option) any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; see the file COPYING. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
19 #ifndef XMLDB_DATABSE_H
20 #define XMLDB_DATABSE_H
21 #include "IdNameMapper.h"
22 #include "DB/ImageSearchInfo.h"
23 #include "DB/ImageInfoList.h"
24 #include <qstringlist.h>
25 #include "DB/MemberMap.h"
26 #include "DB/ImageDB.h"
27 #include "DB/Category.h"
28 #include "DB/CategoryCollection.h"
29 #include "XMLCategoryCollection.h"
30 #include "DB/MD5Map.h"
39 class Database
:public DB::ImageDB
44 OVERRIDE
bool operator==(const DB::ImageDB
& other
) const;
45 OVERRIDE uint
totalCount() const;
46 OVERRIDE
DB::Result
search(
47 const DB::ImageSearchInfo
&,
48 bool requireOnDisk
=false) const;
49 OVERRIDE
void renameCategory( const QString
& oldName
, const QString newName
);
51 OVERRIDE QMap
<QString
,uint
> classify( const DB::ImageSearchInfo
& info
, const QString
&category
, DB::MediaType typemask
);
52 OVERRIDE
DB::Result
images();
53 OVERRIDE
void addImages( const DB::ImageInfoList
& images
);
54 OVERRIDE
void renameImage( DB::ImageInfoPtr info
, const QString
& newName
);
56 OVERRIDE
void addToBlockList(const DB::Result
& list
);
57 OVERRIDE
bool isBlocking( const QString
& fileName
);
58 OVERRIDE
void deleteList(const DB::Result
& list
);
59 OVERRIDE
DB::ImageInfoPtr
info( const QString
& fileName
, DB::PathType
) const;
60 OVERRIDE
DB::ImageInfoPtr
info( const DB::ResultId
& ) const;
61 OVERRIDE
DB::MemberMap
& memberMap();
62 OVERRIDE
void save( const QString
& fileName
, bool isAutoSave
);
63 OVERRIDE
DB::MD5Map
* md5Map();
64 OVERRIDE
void sortAndMergeBackIn(const DB::Result
& idList
);
65 OVERRIDE
DB::CategoryCollection
* categoryCollection();
66 OVERRIDE KSharedPtr
<DB::ImageDateCollection
> rangeCollection();
67 OVERRIDE
void reorder(
68 const DB::ResultId
& item
,
69 const DB::Result
& cutList
,
72 static DB::ImageInfoPtr
createImageInfo( const QString
& fileName
, const QDomElement
& elm
, Database
* db
= 0 );
73 static void possibleLoadCompressedCategories( const QDomElement
& , DB::ImageInfoPtr info
, Database
* db
);
74 OVERRIDE
bool stack(const DB::Result
& items
);
75 OVERRIDE
void unstack(const DB::Result
& images
);
76 OVERRIDE
DB::Result
getStackFor(const DB::ResultId
& referenceId
) const;
78 OVERRIDE QStringList
CONVERT(const DB::Result
&);
79 OVERRIDE
DB::ResultId
ID_FOR_FILE( const QString
& ) const;
82 DB::Result
searchPrivate(
83 const DB::ImageSearchInfo
&,
85 bool onlyItemsMatchingRange
) const;
86 bool rangeInclude( DB::ImageInfoPtr info
) const;
88 DB::ImageInfoList
takeImagesFromSelection(const DB::Result
& list
);
89 DB::Result
insertList( const DB::ResultId
& id
, const DB::ImageInfoList
& list
, bool after
);
90 static void readOptions( DB::ImageInfoPtr info
, QDomElement elm
);
94 void renameItem( DB::Category
* category
, const QString
& oldName
, const QString
& newName
);
95 void deleteItem( DB::Category
* category
, const QString
& option
);
96 void lockDB( bool lock
, bool exclude
);
99 friend class DB::ImageDB
;
100 friend class FileReader
;
101 friend class FileWriter
;
103 Database( const QString
& configFile
);
106 DB::ImageInfoList _images
;
107 QStringList _blockList
;
108 DB::ImageInfoList _missingTimes
;
109 XMLCategoryCollection _categoryCollection
;
110 DB::MemberMap _members
;
113 DB::StackID _nextStackId
;
114 typedef QMap
<DB::StackID
, DB::Result
> StackMap
;
115 mutable StackMap _stackMap
;
117 // used for checking if any images are without image attribute from the database.
118 static bool _anyImageWithEmptySize
;
120 DB::IdNameMapper _idMapper
;
123 class StackSortHelper
{
124 const Database
* const _db
;
126 StackSortHelper( const Database
* const db
);
127 int operator()( const QString
& a
, const QString
& b
) const;
132 #endif /* XMLDB_DATABSE_H */