File indexing completed on 2024-04-28 15:29:23

0001 /*
0002     This file is part of the KDE project
0003     SPDX-FileCopyrightText: 1999 Simon Hausmann <hausmann@kde.org>
0004     SPDX-FileCopyrightText: 1999-2005 David Faure <faure@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #ifndef _KPARTS_READONLYPART_P_H
0010 #define _KPARTS_READONLYPART_P_H
0011 
0012 #include "openurlarguments.h"
0013 #include "part_p.h"
0014 #include "readonlypart.h"
0015 
0016 namespace KIO
0017 {
0018 class FileCopyJob;
0019 class StatJob;
0020 }
0021 
0022 namespace KParts
0023 {
0024 class ReadOnlyPartPrivate : public PartPrivate
0025 {
0026 public:
0027     Q_DECLARE_PUBLIC(ReadOnlyPart)
0028 
0029     explicit ReadOnlyPartPrivate(ReadOnlyPart *qq)
0030         : PartPrivate(qq)
0031     {
0032         m_job = nullptr;
0033         m_statJob = nullptr;
0034         m_uploadJob = nullptr;
0035         m_showProgressInfo = true;
0036         m_saveOk = false;
0037         m_waitForSave = false;
0038         m_duringSaveAs = false;
0039         m_bTemp = false;
0040         m_bAutoDetectedMime = false;
0041         m_closeUrlFromOpenUrl = false;
0042         m_closeUrlFromDestructor = false;
0043     }
0044 
0045     ~ReadOnlyPartPrivate() override
0046     {
0047     }
0048 
0049     void slotJobFinished(KJob *job);
0050     void slotStatJobFinished(KJob *job);
0051     void slotGotMimeType(KIO::Job *job, const QString &mime);
0052     bool openLocalFile();
0053     void openRemoteFile();
0054 
0055     KIO::FileCopyJob *m_job;
0056     KIO::StatJob *m_statJob;
0057     KIO::FileCopyJob *m_uploadJob;
0058     QUrl m_originalURL; // for saveAs
0059     QString m_originalFilePath; // for saveAs
0060     bool m_showProgressInfo : 1;
0061     bool m_saveOk : 1;
0062     bool m_waitForSave : 1;
0063     bool m_duringSaveAs : 1;
0064 
0065     /**
0066      * If @p true, @p m_file is a temporary file that needs to be deleted later.
0067      */
0068     bool m_bTemp : 1;
0069 
0070     // whether the mimetype in the arguments was detected by the part itself
0071     bool m_bAutoDetectedMime : 1;
0072     // Whether we are calling closeUrl() from openUrl().
0073     bool m_closeUrlFromOpenUrl;
0074     // Whether we are calling closeUrl() from ~ReadOnlyPart().
0075     bool m_closeUrlFromDestructor;
0076 
0077     /**
0078      * Remote (or local) url - the one displayed to the user.
0079      */
0080     QUrl m_url;
0081 
0082     /**
0083      * Local file - the only one the part implementation should deal with.
0084      */
0085     QString m_file;
0086 
0087     OpenUrlArguments m_arguments;
0088 };
0089 
0090 } // namespace
0091 
0092 #endif