/* * Copyright (C) 2015 Christian Mollekopf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "folder.h" #include #include #include #include #include #include "../resultset.h" #include "../index.h" #include "../storage.h" #include "../log.h" #include "../propertymapper.h" #include "../query.h" #include "../definitions.h" #include "../typeindex.h" #include "entitybuffer.h" #include "datastorequery.h" #include "entity_generated.h" #include "folder_generated.h" SINK_DEBUG_AREA("folder"); static QMutex sMutex; using namespace Sink::ApplicationDomain; void TypeImplementation::configureIndex(TypeIndex &index) { index.addProperty(Folder::Parent::name); index.addProperty(Folder::Name::name); } static TypeIndex &getIndex() { QMutexLocker locker(&sMutex); static TypeIndex *index = 0; if (!index) { index = new TypeIndex("folder"); TypeImplementation::configureIndex(*index); } return *index; } void TypeImplementation::index(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Sink::Storage::DataStore::Transaction &transaction) { SinkTrace() << "Indexing " << identifier; getIndex().add(identifier, bufferAdaptor, transaction); } void TypeImplementation::removeIndex(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Sink::Storage::DataStore::Transaction &transaction) { getIndex().remove(identifier, bufferAdaptor, transaction); } QSharedPointer::Buffer> > TypeImplementation::initializeReadPropertyMapper() { auto propertyMapper = QSharedPointer >::create(); propertyMapper->addMapping(&Buffer::parent); propertyMapper->addMapping(&Buffer::name); propertyMapper->addMapping(&Buffer::icon); propertyMapper->addMapping(&Buffer::specialpurpose); return propertyMapper; } QSharedPointer::BufferBuilder> > TypeImplementation::initializeWritePropertyMapper() { auto propertyMapper = QSharedPointer >::create(); propertyMapper->addMapping(&BufferBuilder::add_parent); propertyMapper->addMapping(&BufferBuilder::add_name); propertyMapper->addMapping(&BufferBuilder::add_icon); propertyMapper->addMapping(&BufferBuilder::add_specialpurpose); return propertyMapper; }