1 /* 2 This file is part of the KDE project 3 SPDX-FileCopyrightText: 1999 Simon Hausmann <hausmann@kde.org> 4 SPDX-FileCopyrightText: 1999 David Faure <faure@kde.org> 5 6 SPDX-License-Identifier: LGPL-2.0-or-later 7 */ 8 9 #include "browserarguments.h" 10 11 using namespace KParts; 12 13 namespace KParts 14 { 15 struct BrowserArgumentsPrivate { 16 QString contentType; // for POST 17 bool doPost = false; 18 bool redirectedRequest = false; 19 bool lockHistory = false; 20 bool newTab = false; 21 bool forcesNewWindow = false; 22 }; 23 24 } 25 BrowserArguments()26BrowserArguments::BrowserArguments() 27 { 28 softReload = false; 29 trustedSource = false; 30 d = nullptr; // Let's build it on demand for now 31 } 32 BrowserArguments(const BrowserArguments & args)33BrowserArguments::BrowserArguments(const BrowserArguments &args) 34 { 35 d = nullptr; 36 (*this) = args; 37 } 38 operator =(const BrowserArguments & args)39BrowserArguments &BrowserArguments::operator=(const BrowserArguments &args) 40 { 41 if (this == &args) { 42 return *this; 43 } 44 45 delete d; 46 d = nullptr; 47 48 softReload = args.softReload; 49 postData = args.postData; 50 frameName = args.frameName; 51 docState = args.docState; 52 trustedSource = args.trustedSource; 53 54 if (args.d) { 55 d = new BrowserArgumentsPrivate(*args.d); 56 } 57 58 return *this; 59 } 60 ~BrowserArguments()61BrowserArguments::~BrowserArguments() 62 { 63 delete d; 64 d = nullptr; 65 } 66 setContentType(const QString & contentType)67void BrowserArguments::setContentType(const QString &contentType) 68 { 69 if (!d) { 70 d = new BrowserArgumentsPrivate; 71 } 72 d->contentType = contentType; 73 } 74 setRedirectedRequest(bool redirected)75void BrowserArguments::setRedirectedRequest(bool redirected) 76 { 77 if (!d) { 78 d = new BrowserArgumentsPrivate; 79 } 80 d->redirectedRequest = redirected; 81 } 82 redirectedRequest() const83bool BrowserArguments::redirectedRequest() const 84 { 85 return d ? d->redirectedRequest : false; 86 } 87 contentType() const88QString BrowserArguments::contentType() const 89 { 90 return d ? d->contentType : QString(); 91 } 92 setDoPost(bool enable)93void BrowserArguments::setDoPost(bool enable) 94 { 95 if (!d) { 96 d = new BrowserArgumentsPrivate; 97 } 98 d->doPost = enable; 99 } 100 doPost() const101bool BrowserArguments::doPost() const 102 { 103 return d ? d->doPost : false; 104 } 105 setLockHistory(bool lock)106void BrowserArguments::setLockHistory(bool lock) 107 { 108 if (!d) { 109 d = new BrowserArgumentsPrivate; 110 } 111 d->lockHistory = lock; 112 } 113 lockHistory() const114bool BrowserArguments::lockHistory() const 115 { 116 return d ? d->lockHistory : false; 117 } 118 setNewTab(bool newTab)119void BrowserArguments::setNewTab(bool newTab) 120 { 121 if (!d) { 122 d = new BrowserArgumentsPrivate; 123 } 124 d->newTab = newTab; 125 } 126 newTab() const127bool BrowserArguments::newTab() const 128 { 129 return d ? d->newTab : false; 130 } 131 setForcesNewWindow(bool forcesNewWindow)132void BrowserArguments::setForcesNewWindow(bool forcesNewWindow) 133 { 134 if (!d) { 135 d = new BrowserArgumentsPrivate; 136 } 137 d->forcesNewWindow = forcesNewWindow; 138 } 139 forcesNewWindow() const140bool BrowserArguments::forcesNewWindow() const 141 { 142 return d ? d->forcesNewWindow : false; 143 } 144