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

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 using namespace KParts;
0012 
0013 namespace KParts
0014 {
0015 struct BrowserArgumentsPrivate {
0016     QString contentType; // for POST
0017     bool doPost = false;
0018     bool redirectedRequest = false;
0019     bool lockHistory = false;
0020     bool newTab = false;
0021     bool forcesNewWindow = false;
0022 };
0023 
0024 }
0025 
0026 BrowserArguments::BrowserArguments()
0027 {
0028     softReload = false;
0029     trustedSource = false;
0030     d = nullptr; // Let's build it on demand for now
0031 }
0032 
0033 BrowserArguments::BrowserArguments(const BrowserArguments &args)
0034 {
0035     d = nullptr;
0036     (*this) = args;
0037 }
0038 
0039 BrowserArguments &BrowserArguments::operator=(const BrowserArguments &args)
0040 {
0041     if (this == &args) {
0042         return *this;
0043     }
0044 
0045     delete d;
0046     d = nullptr;
0047 
0048     softReload = args.softReload;
0049     postData = args.postData;
0050     frameName = args.frameName;
0051     docState = args.docState;
0052     trustedSource = args.trustedSource;
0053 
0054     if (args.d) {
0055         d = new BrowserArgumentsPrivate(*args.d);
0056     }
0057 
0058     return *this;
0059 }
0060 
0061 BrowserArguments::~BrowserArguments()
0062 {
0063     delete d;
0064     d = nullptr;
0065 }
0066 
0067 void BrowserArguments::setContentType(const QString &contentType)
0068 {
0069     if (!d) {
0070         d = new BrowserArgumentsPrivate;
0071     }
0072     d->contentType = contentType;
0073 }
0074 
0075 void BrowserArguments::setRedirectedRequest(bool redirected)
0076 {
0077     if (!d) {
0078         d = new BrowserArgumentsPrivate;
0079     }
0080     d->redirectedRequest = redirected;
0081 }
0082 
0083 bool BrowserArguments::redirectedRequest() const
0084 {
0085     return d ? d->redirectedRequest : false;
0086 }
0087 
0088 QString BrowserArguments::contentType() const
0089 {
0090     return d ? d->contentType : QString();
0091 }
0092 
0093 void BrowserArguments::setDoPost(bool enable)
0094 {
0095     if (!d) {
0096         d = new BrowserArgumentsPrivate;
0097     }
0098     d->doPost = enable;
0099 }
0100 
0101 bool BrowserArguments::doPost() const
0102 {
0103     return d ? d->doPost : false;
0104 }
0105 
0106 void BrowserArguments::setLockHistory(bool lock)
0107 {
0108     if (!d) {
0109         d = new BrowserArgumentsPrivate;
0110     }
0111     d->lockHistory = lock;
0112 }
0113 
0114 bool BrowserArguments::lockHistory() const
0115 {
0116     return d ? d->lockHistory : false;
0117 }
0118 
0119 void BrowserArguments::setNewTab(bool newTab)
0120 {
0121     if (!d) {
0122         d = new BrowserArgumentsPrivate;
0123     }
0124     d->newTab = newTab;
0125 }
0126 
0127 bool BrowserArguments::newTab() const
0128 {
0129     return d ? d->newTab : false;
0130 }
0131 
0132 void BrowserArguments::setForcesNewWindow(bool forcesNewWindow)
0133 {
0134     if (!d) {
0135         d = new BrowserArgumentsPrivate;
0136     }
0137     d->forcesNewWindow = forcesNewWindow;
0138 }
0139 
0140 bool BrowserArguments::forcesNewWindow() const
0141 {
0142     return d ? d->forcesNewWindow : false;
0143 }