File indexing completed on 2024-04-28 04:58:10

0001 /*
0002     This file is part of the KDE project
0003     SPDX-FileCopyrightText: 1999 Simon Hausmann <hausmann@kde.org>
0004     SPDX-FileCopyrightText: 1999 David Faure <faure@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #include "browserarguments.h"
0010 
0011 # if QT_VERSION_MAJOR == 6
0012 
0013 struct BrowserArgumentsPrivate {
0014     QString contentType; // for POST
0015     bool doPost = false;
0016     bool redirectedRequest = false;
0017     bool lockHistory = false;
0018     bool newTab = false;
0019     bool forcesNewWindow = false;
0020 };
0021 
0022 BrowserArguments::BrowserArguments()
0023 {
0024     softReload = false;
0025     trustedSource = false;
0026     d = nullptr; // Let's build it on demand for now
0027 }
0028 
0029 BrowserArguments::BrowserArguments(const BrowserArguments &args)
0030 {
0031     d = nullptr;
0032     (*this) = args;
0033 }
0034 
0035 BrowserArguments &BrowserArguments::operator=(const BrowserArguments &args)
0036 {
0037     if (this == &args) {
0038         return *this;
0039     }
0040 
0041     delete d;
0042     d = nullptr;
0043 
0044     softReload = args.softReload;
0045     postData = args.postData;
0046     frameName = args.frameName;
0047     docState = args.docState;
0048     trustedSource = args.trustedSource;
0049 
0050     if (args.d) {
0051         d = new BrowserArgumentsPrivate(*args.d);
0052     }
0053 
0054     return *this;
0055 }
0056 
0057 BrowserArguments::~BrowserArguments()
0058 {
0059     delete d;
0060     d = nullptr;
0061 }
0062 
0063 void BrowserArguments::setContentType(const QString &contentType)
0064 {
0065     if (!d) {
0066         d = new BrowserArgumentsPrivate;
0067     }
0068     d->contentType = contentType;
0069 }
0070 
0071 void BrowserArguments::setRedirectedRequest(bool redirected)
0072 {
0073     if (!d) {
0074         d = new BrowserArgumentsPrivate;
0075     }
0076     d->redirectedRequest = redirected;
0077 }
0078 
0079 bool BrowserArguments::redirectedRequest() const
0080 {
0081     return d ? d->redirectedRequest : false;
0082 }
0083 
0084 QString BrowserArguments::contentType() const
0085 {
0086     return d ? d->contentType : QString();
0087 }
0088 
0089 void BrowserArguments::setDoPost(bool enable)
0090 {
0091     if (!d) {
0092         d = new BrowserArgumentsPrivate;
0093     }
0094     d->doPost = enable;
0095 }
0096 
0097 bool BrowserArguments::doPost() const
0098 {
0099     return d ? d->doPost : false;
0100 }
0101 
0102 void BrowserArguments::setLockHistory(bool lock)
0103 {
0104     if (!d) {
0105         d = new BrowserArgumentsPrivate;
0106     }
0107     d->lockHistory = lock;
0108 }
0109 
0110 bool BrowserArguments::lockHistory() const
0111 {
0112     return d ? d->lockHistory : false;
0113 }
0114 
0115 void BrowserArguments::setNewTab(bool newTab)
0116 {
0117     if (!d) {
0118         d = new BrowserArgumentsPrivate;
0119     }
0120     d->newTab = newTab;
0121 }
0122 
0123 bool BrowserArguments::newTab() const
0124 {
0125     return d ? d->newTab : false;
0126 }
0127 
0128 void BrowserArguments::setForcesNewWindow(bool forcesNewWindow)
0129 {
0130     if (!d) {
0131         d = new BrowserArgumentsPrivate;
0132     }
0133     d->forcesNewWindow = forcesNewWindow;
0134 }
0135 
0136 bool BrowserArguments::forcesNewWindow() const
0137 {
0138     return d ? d->forcesNewWindow : false;
0139 }
0140 
0141 #endif