krop's commit fixes my problem in a better way, reverting
[kdepim.git] / kmail / editorwatcher.h
blob2797c2f9a07833b2f905442765dde50414b3b80e
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 KMAIL_EDITORWATCHER_H
20 #define KMAIL_EDITORWATCHER_H
22 #include <kurl.h>
24 #include <qdatetime.h>
25 #include <qobject.h>
26 #include <qtimer.h>
28 class KProcess;
30 namespace KMail {
32 /**
33 Starts an editor for the given URL and emits an signal when
34 editing has been finished. Both, the editor process as well
35 as the edited file are watched to work with as many as possible
36 editors.
38 class EditorWatcher : public QObject
40 Q_OBJECT
41 public:
43 /**
44 * Constructs an EditorWatcher.
45 * @param parent the parent object of this EditorWatcher, which will take care of deleting
46 * this EditorWatcher if the parent is deleted.
47 * @param parentWidget the parent widget of this EditorWatcher, which will be used as the parent
48 * widget for message dialogs.
50 EditorWatcher( const KUrl &url, const QString &mimeType, bool openWith,
51 QObject *parent, QWidget *parentWidget );
53 bool start();
54 bool fileChanged() const { return mFileModified; }
55 signals:
56 void editDone( KMail::EditorWatcher* watcher );
58 private slots:
59 void editorExited();
60 void inotifyEvent();
61 void checkEditDone();
63 private:
64 KUrl mUrl;
65 QString mMimeType;
66 bool mOpenWith;
67 KProcess *mEditor;
68 QWidget *mParentWidget;
70 int mInotifyFd;
71 int mInotifyWatch;
72 bool mHaveInotify;
74 bool mFileOpen;
75 bool mEditorRunning;
77 bool mFileModified;
79 QTimer mTimer;
80 QTime mEditTime;
82 bool mError;
83 bool mDone;
88 #endif