File indexing completed on 2024-04-21 04:58:20

0001 /* This file is part of the KDE project
0002     SPDX-FileCopyrightText: 2000-2007 David Faure <faure@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef __konqopenurlrequest_h
0008 #define __konqopenurlrequest_h
0009 
0010 #include "konqprivate_export.h"
0011 
0012 #include <QStringList>
0013 
0014 #include "kf5compat.h" //For NavigationExtension
0015 #include "browserarguments.h"
0016 
0017 namespace KParts {
0018     class ReadOnlyPart;
0019 }
0020 
0021 struct KONQ_TESTS_EXPORT KonqOpenURLRequest {
0022 
0023     KonqOpenURLRequest() = default;
0024 
0025     KonqOpenURLRequest(const QString &url) : typedUrl(url) {}
0026 
0027     KonqOpenURLRequest(const KParts::OpenUrlArguments &_args, const BrowserArguments &_browserArgs,
0028                        KParts::ReadOnlyPart *_requestingPart, bool _letPartPerformDownload=false, quint32 _downloadId=-1) {
0029         args = _args;
0030         browserArgs = _browserArgs;
0031         requestingPart = _requestingPart;
0032         letPartPerformDownload = _letPartPerformDownload;
0033         downloadId = _downloadId;
0034     };
0035 
0036     QString debug() const
0037     {
0038 #ifndef NDEBUG
0039         QStringList s;
0040         if (!browserArgs.frameName.isEmpty()) {
0041             s << "frameName=" + browserArgs.frameName;
0042         }
0043         if (browserArgs.newTab()) {
0044             s << QStringLiteral("newTab");
0045         }
0046         if (!nameFilter.isEmpty()) {
0047             s << "nameFilter=" + nameFilter;
0048         }
0049         if (!typedUrl.isEmpty()) {
0050             s << "typedUrl=" + typedUrl;
0051         }
0052         if (!serviceName.isEmpty()) {
0053             s << "serviceName=" + serviceName;
0054         }
0055         if (followMode) {
0056             s << QStringLiteral("followMode");
0057         }
0058         if (newTabInFront) {
0059             s << QStringLiteral("newTabInFront");
0060         }
0061         if (openAfterCurrentPage) {
0062             s << QStringLiteral("openAfterCurrentPage");
0063         }
0064         if (forceAutoEmbed) {
0065             s << QStringLiteral("forceAutoEmbed");
0066         }
0067         if (tempFile) {
0068             s << QStringLiteral("tempFile");
0069         }
0070         if (userRequestedReload) {
0071             s << QStringLiteral("userRequestedReload");
0072         }
0073         return "[" + s.join(QStringLiteral(" ")) + "]";
0074 #else
0075         return QString();
0076 #endif
0077     }
0078 
0079     QString typedUrl; ///< empty if URL wasn't typed manually
0080     QString nameFilter; ///< like `*.cpp`, extracted from the URL
0081     QString serviceName; ///< to force the use of a given part (e.g. khtml or kwebkitpart)
0082     bool followMode = false; ///< `true` if following another view - avoids loops
0083     bool newTabInFront = false; ///< new tab in front or back (when browserArgs.newTab() == true)
0084     bool openAfterCurrentPage = false; ///< open the URL after the current tab
0085     bool forceAutoEmbed = false; ///< if `true`, override the user's FMSettings for embedding
0086     bool tempFile = false; ///< if true, the URL should be deleted after use
0087     bool userRequestedReload = false; ///< `args.reload` because the user requested it, not a website
0088     KParts::OpenUrlArguments args;
0089     BrowserArguments browserArgs;
0090     QList<QUrl> filesToSelect; ///< files to select in a konqdirpart
0091     QString suggestedFileName; ///< The suggested name when saving an URL
0092     KParts::ReadOnlyPart *requestingPart = nullptr; ///< The part which requested the download of an URL
0093     /**
0094      * @brief The download of the URL should be made by the part, not by Konqueror
0095      *
0096      * If this is `true`, #requestingPart should be a part having a KonqInterfaces::DownloaderExtension
0097      */
0098     bool letPartPerformDownload = false;
0099     /**
0100      * @brief A value to pass back to a part which wants to download the URL by itself
0101      *
0102      * The meaning of this value is part-specific.
0103      *
0104      * This is ignored if #letPartPerformDownload is `false`.
0105      */
0106     qint32 downloadId = -1;
0107 
0108     static KonqOpenURLRequest null;
0109 };
0110 
0111 #endif