1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
/* This file is part of the KDE project
* Copyright (C) 2013 Aman Madaan <madaan.amanmadaan@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef LINKINSERTDIALOG
#define LINKINSERTDIALOG
#include <ui_LinkInsertionDialog.h>
#include <QDialog>
#include <QNetworkReply>
#include <QNetworkAccessManager>
#include <QWidget>
#include <QTimer>
#include <KoBookmarkManager.h>
#include <KoTextRangeManager.h>
#include <KoTextDocument.h>
#include <QListWidget>
#define FETCH_TIMEOUT 5000
class LinkInsertionDialog : public QDialog
{
Q_OBJECT
public :
explicit LinkInsertionDialog(KoTextEditor *editor, QWidget *parent = 0);
virtual ~LinkInsertionDialog();
private Q_SLOTS:
void insertLink();
public Q_SLOTS:
void fetchTitleFromURL();
void replyFinished();
void fetchTitleError(QNetworkReply::NetworkError);
void updateTitleDownloadProgress(qint64, qint64);
void fetchTitleTimeout();
/**
* Verifies the text entered in the four line edits : Weblink URL, Weblink text,
* Bookmark name and Bookmark text. The "Ok" button is enabled only if the input
* is valid.
* @param text is the text to be verified.
*/
void enableDisableButtons(QString text);
/**
* Once all the line edits for a tab have been verified, the OK button is enabled.
* If the tab is switched, the validity of OK should be recalculated for the new tab.
* @param text is the current active tab.
*/
void checkInsertEnableValidity(int);
private :
Ui::LinkInsertionDialog dlg;
KoTextEditor *m_editor;
const KoBookmarkManager *m_bookmarkManager;
QStringList m_bookmarkList;
QNetworkReply *m_reply;
QNetworkAccessManager *m_networkAccessManager;
QUrl m_linkURL;
QTimer m_timeoutTimer;
void accept();
void sendRequest();
void insertBookmarkLink(const QString &URL, const QString &text);
void insertHyperlink(QString &linkURL, const QString &linkText);
void displayInlineWarning(const QString &title, QLabel *label) const;
bool exists(const QString &) const;
};
#endif
|