Framework for looking up contacts directly in nepomuk in addition to going through...
[kdepim.git] / messageviewer / editorwatcher.h
blob52c6778b783d1d780c3331f6f8a465da313fd8b5
1 /*
2 Copyright (c) 2007 Volker Krause <vkrause@kde.org>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #ifndef MESSAGEVIEWER_EDITORWATCHER_H
20 #define MESSAGEVIEWER_EDITORWATCHER_H
22 #include "messageviewer_export.h"
23 #include <kurl.h>
25 #include <qobject.h>
26 #include <qtimer.h>
27 #include <QTime>
28 class KProcess;
30 namespace MessageViewer {
33 /**
34 Starts an editor for the given URL and emits an signal when
35 editing has been finished. Both, the editor process as well
36 as the edited file are watched to work with as many as possible
37 editors.
39 class MESSAGEVIEWER_EXPORT EditorWatcher : public QObject
41 Q_OBJECT
42 public:
44 /**
45 * Constructs an EditorWatcher.
46 * @param parent the parent object of this EditorWatcher, which will take care of deleting
47 * this EditorWatcher if the parent is deleted.
48 * @param parentWidget the parent widget of this EditorWatcher, which will be used as the parent
49 * widget for message dialogs.
51 EditorWatcher( const KUrl &url, const QString &mimeType, bool openWith,
52 QObject *parent, QWidget *parentWidget );
54 bool start();
55 bool fileChanged() const { return mFileModified; }
56 KUrl url() { return mUrl;}
57 signals:
58 void editDone( MessageViewer::EditorWatcher* watcher );
60 private slots:
61 void editorExited();
62 void inotifyEvent();
63 void checkEditDone();
65 private:
66 KUrl mUrl;
67 QString mMimeType;
68 bool mOpenWith;
69 KProcess *mEditor;
70 QWidget *mParentWidget;
72 int mInotifyFd;
73 int mInotifyWatch;
74 bool mHaveInotify;
76 bool mFileOpen;
77 bool mEditorRunning;
79 bool mFileModified;
81 QTimer mTimer;
82 QTime mEditTime;
84 bool mError;
85 bool mDone;
90 #endif