Commit 685fdb3a authored by Stefano Crocco's avatar Stefano Crocco Committed by David Faure
Browse files

Add some documentation

parent a67a2def
Pipeline #158767 passed with stage
in 7 minutes and 52 seconds
......@@ -610,10 +610,6 @@ void KonqMainWindow::openUrl(KonqView *_view, const QUrl &_url,
void KonqMainWindow::urlLoaderFinished(UrlLoader* loader)
{
//TODO Remove KonqRun: see which of the things below only need to be done if loader->isAsync. In the original code,
//this function (slotRunFinished) was only called when using a KonqRun but now it's always called.
if (loader->hasError()) { // we had an error
QDBusMessage message = QDBusMessage::createSignal(KONQ_MAIN_PATH, QStringLiteral("org.kde.Konqueror.Main"), QStringLiteral("removeFromCombo"));
message << loader->url().toDisplayString();
......
......@@ -30,6 +30,22 @@ namespace KIO {
class KonqMainWindow;
class KonqView;
/**
* @brief Class which takes care of finding out what to do with an URL and carries out the chosen action
*
* Depending on whether the mimetype of the URL is already known and on whether the URL is a local or remote
* file, this class can work in a synchronous or asynchronous way. This should be mostly transparent to the user.
*
* This class is meant to be used in the following way:
* - create an instance, passing it the known information about the URL to load
* - connect to the finished() signal to be notified when the URL has been loaded
* - call start(): this will attempt to determine the synchronously determine mimetype and, if successful, will
* decide what to do with it
* - call viewToUse() to find out where the URL should be opened. If needed, create a new view and call setView()
* passing the new view
* - call goOn(): this will asynchronously determine the mimetype and the action to carry out, if not already done,
* and perform the action itself
*/
class UrlLoader : public QObject
{
Q_OBJECT
......@@ -38,7 +54,13 @@ public:
/**
* Constructor
*
* @param parent TODO
* @param mainWindow the KonqMainWindow which asked to load the URL
* @param view the view which asked to open the URL. It can be `nullptr`
* @param url the URL to load
* @param mimeType the mimetype of the URL or an empty string if not known
* @param req the object containing information about the URL loading request
* @param trustedSource whether the source of the URL is trusted
* @param forceOpen tells never to embed the URL
*/
UrlLoader(KonqMainWindow *mainWindow, KonqView *view, const QUrl &url, const QString &mimeType, const KonqOpenURLRequest &req, bool trustedSource, bool forceOpen=false);
~UrlLoader();
......@@ -60,10 +82,40 @@ public:
NewTab /**< Create a new tab and use its view */
};
/**
* @brief Determines what to do with the URL if its mimetype can be determined without using an `OpenUrlJob`.
*
* When the mimetype can be determined without using an `OpenUrlJob`, this function calls decideAction() to
* determine what should be done with the URL. In this case, subsequent calls to isReady() will return `true`.
* If the mimetype can't be determined without using an `OpenUrlJob`, calls to isReady() will return `false`,
* because `OpenUrlJob` works asynchronously.
*
* The mimetype can be determined without using an `OpenUrlJob` in the following situations:
* - a mimetype different from `application/octet-stream` is passed to the constructor
* - the URL is a local file
* - the URL scheme is `http` and the URL hasn't yet been processed by the default HTML engine (in this case,
* a fake `text/html` mimetype will be used and the HTML engine will take care of determining the mimetype)
*
* @note This function *doesn't* create or start the `OpenUrlJob`, even if it will be needed.
*/
void start();
void performAction();
/**
* @brief Performs the required action on the URL, using an `OpenUrlJob` to determine its mimetype if needed.
*
* If start() had been able to determine the action to carry out, this function simply calls performAction()
* to perform the chosen action. In all other cases (that is, if the mimetype is still unknown), it launches
* an `OpenUrlJob` to determine the mimetype. When the job has determined the mimetype, this function will
* call decideAction() to decide what to do with the URL and then call performAction() to carry out the chosen
* action.
*/
void goOn();
/**
* @brief Carries out the requested action
*/
void performAction();
void abort();
QString mimeType() const;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment