1 /*
2     This file is part of the KDE project
3     SPDX-FileCopyrightText: 1999 Simon Hausmann <hausmann@kde.org>
4     SPDX-FileCopyrightText: 1999-2005 David Faure <faure@kde.org>
5 
6     SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8 
9 #ifndef _KPARTS_READONLYPART_P_H
10 #define _KPARTS_READONLYPART_P_H
11 
12 #include "openurlarguments.h"
13 #include "part_p.h"
14 #include "readonlypart.h"
15 
16 namespace KIO
17 {
18 class FileCopyJob;
19 class StatJob;
20 }
21 
22 namespace KParts
23 {
24 class ReadOnlyPartPrivate : public PartPrivate
25 {
26 public:
Q_DECLARE_PUBLIC(ReadOnlyPart)27     Q_DECLARE_PUBLIC(ReadOnlyPart)
28 
29     explicit ReadOnlyPartPrivate(ReadOnlyPart *qq)
30         : PartPrivate(qq)
31     {
32         m_job = nullptr;
33         m_statJob = nullptr;
34         m_uploadJob = nullptr;
35         m_showProgressInfo = true;
36         m_saveOk = false;
37         m_waitForSave = false;
38         m_duringSaveAs = false;
39         m_bTemp = false;
40         m_bAutoDetectedMime = false;
41         m_closeUrlFromOpenUrl = false;
42     }
43 
~ReadOnlyPartPrivate()44     ~ReadOnlyPartPrivate() override
45     {
46     }
47 
48     void slotJobFinished(KJob *job);
49     void slotStatJobFinished(KJob *job);
50     void slotGotMimeType(KIO::Job *job, const QString &mime);
51     bool openLocalFile();
52     void openRemoteFile();
53 
54     KIO::FileCopyJob *m_job;
55     KIO::StatJob *m_statJob;
56     KIO::FileCopyJob *m_uploadJob;
57     QUrl m_originalURL; // for saveAs
58     QString m_originalFilePath; // for saveAs
59     bool m_showProgressInfo : 1;
60     bool m_saveOk : 1;
61     bool m_waitForSave : 1;
62     bool m_duringSaveAs : 1;
63 
64     /**
65      * If @p true, @p m_file is a temporary file that needs to be deleted later.
66      */
67     bool m_bTemp : 1;
68 
69     // whether the mimetype in the arguments was detected by the part itself
70     bool m_bAutoDetectedMime : 1;
71     // Whether we are calling closeUrl() from openUrl().
72     bool m_closeUrlFromOpenUrl;
73 
74     /**
75      * Remote (or local) url - the one displayed to the user.
76      */
77     QUrl m_url;
78 
79     /**
80      * Local file - the only one the part implementation should deal with.
81      */
82     QString m_file;
83 
84     OpenUrlArguments m_arguments;
85 };
86 
87 } // namespace
88 
89 #endif
90