2
<one line to give the library's name and an idea of what it does.>
3
Copyright (C) 2012 Vishesh Handa <me@vhanda.in>
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Lesser General Public
7
License as published by the Free Software Foundation; either
8
version 2.1 of the License, or (at your option) any later version.
10
This library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Lesser General Public License for more details.
15
You should have received a copy of the GNU Lesser General Public
16
License along with this library; if not, write to the Free Software
17
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
#ifndef BASICINDEXINGQUEUE_H
22
#define BASICINDEXINGQUEUE_H
24
#include "indexingqueue.h"
25
#include "filemapping.h"
29
#include <QMimeDatabase>
38
class FileIndexerConfig;
42
* No flags, only used to make code more readable
47
* The folder should be updated recursive
49
UpdateRecursive = 0x1,
52
* The folder has been scheduled to update by the
53
* update system, not by a call to updateDir
55
AutoUpdateFolder = 0x2,
58
* The files in the folder should be updated regardless
63
Q_DECLARE_FLAGS(UpdateDirFlags, UpdateDirFlag)
66
* This class represents a simple queue that iterates over the file system tree
67
* and indexes each file which meets certain critera. The indexing performed by this
68
* queue is very basic. It just pushes the mimetype, url and stat results of the file.
70
class BasicIndexingQueue: public IndexingQueue
74
explicit BasicIndexingQueue(Database* db, FileIndexerConfig* config, QObject* parent = 0);
76
virtual bool isEmpty();
79
void newDocument(unsigned id, Xapian::Document doc);
82
void enqueue(const FileMapping& file);
83
void enqueue(const FileMapping& file, UpdateDirFlags flags);
86
void clear(const QString& path);
89
virtual void processNextIteration();
93
* This method does not need to be synchronous. The indexing operation may be started
94
* and on completion, the finishedIndexing method should be called
96
void index(const FileMapping& file, const QString& mimetype);
98
bool shouldIndex(FileMapping& file, const QString& mimetype) const;
99
bool shouldIndexContents(const QString& dir);
102
* Check if the \p path needs to be indexed based on the \p flags
103
* and the path. If it needs to be indexed, then start indexing
106
* \return \c true the path is being indexed
107
* \return \c false the path did not meet the criteria
109
bool process(FileMapping& file, UpdateDirFlags flags);
111
QStack< QPair<FileMapping, UpdateDirFlags> > m_paths;
114
FileIndexerConfig* m_config;
115
QMimeDatabase m_mimeDb;
120
Q_DECLARE_OPERATORS_FOR_FLAGS(Baloo::UpdateDirFlags)
122
#endif // BASICINDEXINGQUEUE_H