~ubuntu-branches/ubuntu/quantal/kde-runtime/quantal

« back to all changes in this revision

Viewing changes to nepomuk/services/filewatch/metadatamover.h

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2012-06-03 21:50:00 UTC
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: package-import@ubuntu.com-20120603215000-vn7oarsq0ynrydj5
Tags: upstream-4.8.80
Import upstream version 4.8.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* This file is part of the KDE Project
2
 
   Copyright (c) 2009-2011 Sebastian Trueg <trueg@kde.org>
3
 
 
4
 
   This library is free software; you can redistribute it and/or
5
 
   modify it under the terms of the GNU Library General Public
6
 
   License version 2 as published by the Free Software Foundation.
7
 
 
8
 
   This library 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
 
   Library General Public License for more details.
12
 
 
13
 
   You should have received a copy of the GNU Library General Public License
14
 
   along with this library; see the file COPYING.LIB.  If not, write to
15
 
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16
 
   Boston, MA 02110-1301, USA.
17
 
*/
18
 
 
19
 
#ifndef _NEPOMUK_METADATA_MOVER_H_
20
 
#define _NEPOMUK_METADATA_MOVER_H_
21
 
 
22
 
#include <QtCore/QMutex>
23
 
#include <QtCore/QQueue>
24
 
#include <QtCore/QSet>
25
 
#include <QtCore/QDateTime>
26
 
 
27
 
#include <KUrl>
28
 
 
29
 
#include "updaterequest.h"
30
 
 
31
 
class QTimer;
32
 
 
33
 
namespace Soprano {
34
 
    class Model;
35
 
}
36
 
 
37
 
namespace Nepomuk {
38
 
    class MetadataMover : public QObject
39
 
    {
40
 
        Q_OBJECT
41
 
 
42
 
    public:
43
 
        MetadataMover( Soprano::Model* model, QObject* parent = 0 );
44
 
        ~MetadataMover();
45
 
 
46
 
    public Q_SLOTS:
47
 
        void moveFileMetadata( const KUrl& from, const KUrl& to );
48
 
        void removeFileMetadata( const KUrl& file );
49
 
        void removeFileMetadata( const KUrl::List& files );
50
 
 
51
 
    Q_SIGNALS:
52
 
        /**
53
 
         * Emitted for files (and folders) that have been moved but
54
 
         * do not have metadata to be moved. This allows the file indexer
55
 
         * service to pick them up in case they are of interest. The
56
 
         * typical example would be moving a file from a non-indexed into
57
 
         * an indexed folder.
58
 
         */
59
 
        void movedWithoutData( const QString& path );
60
 
 
61
 
    private Q_SLOTS:
62
 
        void slotClearRecentlyFinishedRequests();
63
 
        void slotWorkUpdateQueue();
64
 
 
65
 
        /**
66
 
         * Start the update queue from the main thread.
67
 
         */
68
 
        void slotStartUpdateTimer();
69
 
 
70
 
    private:
71
 
        /**
72
 
         * Remove the metadata for file \p url
73
 
         */
74
 
        void removeMetadata( const KUrl& url );
75
 
 
76
 
        /**
77
 
         * Recursively update the nie:url and nie:isPartOf properties
78
 
         * of the resource describing \p from.
79
 
         */
80
 
        void updateMetadata( const KUrl& from, const KUrl& to );
81
 
 
82
 
        // if the second url is empty, just delete the metadata
83
 
        QQueue<UpdateRequest> m_updateQueue;
84
 
 
85
 
        // we use several systems to watch for file operations.
86
 
        // Thus, we can get the same request more than once. We then
87
 
        // need a way to determine if we have already handled it.
88
 
        // (otherwise we would remove the previously moved data.)
89
 
        // The only way to do that is to keep a list of all requests
90
 
        // that have been handled in the last N seconds.
91
 
        QSet<UpdateRequest> m_recentlyFinishedRequests;
92
 
 
93
 
        QMutex m_queueMutex;
94
 
 
95
 
        QTimer* m_queueTimer;
96
 
        QTimer* m_recentlyFinishedRequestsTimer;
97
 
 
98
 
        Soprano::Model* m_model;
99
 
    };
100
 
}
101
 
 
102
 
#endif