2 Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com>
3 (c) 2007 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
11 #include "repository.h"
13 Repository::Repository()
16 void Repository::addComponent(const QString
& path
, ComponentPtr component
) {
17 if (m_components
.contains(path
))
18 kError() << "NOT replacing component" << path
<<
19 "in component" << component
->objectName();
21 m_components
[path
] = component
;
24 ComponentPtr
Repository::getComponent(const QString
& path
) const {
25 ComponentPtr res
= m_components
.value(path
);
27 res
= m_proxy
->getComponent(path
);
31 ComponentPtr
Repository::takeComponent(const QString
& path
) {
32 return m_components
.take(path
);
35 Repository::ComponentMap
Repository::listComponents(QString path
) const {
36 if (!path
.endsWith("/")) path
+= "/";
39 ComponentMap::const_iterator it
= m_components
.lowerBound(path
);
40 ComponentMap::const_iterator end
= m_components
.end();
42 for ( ; it
!= end
; ++it
) {
43 if (it
.key().startsWith(path
))
44 res
[it
.key().mid(path
.size())] = it
.value();
50 res
= res
.unite(m_proxy
->listComponents(path
));
55 void Repository::setProxy(Repository
* proxy
) {