diff --git a/doc/konqueror/index.docbook b/doc/konqueror/index.docbook --- a/doc/konqueror/index.docbook +++ b/doc/konqueror/index.docbook @@ -2251,7 +2251,7 @@ Browser Mode - - HTML Settings (KHTML view) Select ToolsHTML diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -8,7 +8,6 @@ add_subdirectory( dirfilter ) # TODO add_subdirectory( uachanger ) add_subdirectory( babelfish ) -add_subdirectory( validators ) add_subdirectory( webarchiver ) if (Qt5TextToSpeech_FOUND) diff --git a/plugins/validators/CMakeLists.txt b/plugins/validators/CMakeLists.txt deleted file mode 100644 --- a/plugins/validators/CMakeLists.txt +++ /dev/null @@ -1,64 +0,0 @@ -add_definitions(-DTRANSLATION_DOMAIN=\"validatorsplugin\") -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}) - -find_package(LibTidy) -find_package(KF5 REQUIRED KHtml WidgetsAddons IconThemes) -set_package_properties(LibTidy PROPERTIES DESCRIPTION "HTML Tidy" - URL "http://www.html-tidy.org/" - TYPE OPTIONAL - PURPOSE "Gives the Konqueror validators plugin the ability to validate HTML" - ) - -macro_bool_to_01(LIBTIDY_FOUND HAVE_TIDY) - -configure_file(config-konq-validator.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-konq-validator.h) - - -if (LIBTIDY_FOUND) - include_directories(${LIBTIDY_INCLUDE_DIR}) -endif (LIBTIDY_FOUND) - -add_subdirectory(pics) - -########### next target ############### - -set(validatorsplugin_PART_SRCS - clickiconlabel.cpp - plugin_validators.cpp - validatorsdialog.cpp -) -if (LIBTIDY_FOUND) - set(validatorsplugin_PART_SRCS ${validatorsplugin_PART_SRCS} - reportdialog.cpp - tidy_validator.cpp - ) -endif (LIBTIDY_FOUND) - -ki18n_wrap_ui(validatorsplugin_PART_SRCS - internalvalidator.ui - remotevalidators.ui - reportwidget.ui -) - -kconfig_add_kcfg_files(validatorsplugin_PART_SRCS settings.kcfgc) - -add_library(validatorsplugin MODULE ${validatorsplugin_PART_SRCS}) - - - -target_link_libraries(validatorsplugin KF5::Parts KF5::KHtml KF5::WidgetsAddons KF5::KDELibs4Support KF5::IconThemes) -if (LIBTIDY_FOUND) - target_link_libraries(validatorsplugin ${LIBTIDY_LIBRARIES}) -endif (LIBTIDY_FOUND) - -install(TARGETS validatorsplugin DESTINATION ${KDE_INSTALL_PLUGINDIR} ) - - -########### install files ############### - -install( FILES plugin_validators.rc plugin_validators.desktop DESTINATION ${KDE_INSTALL_DATADIR}/khtml/kpartplugins ) - -install( FILES plugin_validators.rc plugin_validators.desktop DESTINATION ${KDE_INSTALL_DATADIR}/kwebkitpart/kpartplugins ) -install( FILES plugin_validators.rc plugin_validators.desktop DESTINATION ${KDE_INSTALL_DATADIR}/webenginepart/kpartplugins ) - -install(FILES validators.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR}) diff --git a/plugins/validators/FindLibTidy.cmake b/plugins/validators/FindLibTidy.cmake deleted file mode 100644 --- a/plugins/validators/FindLibTidy.cmake +++ /dev/null @@ -1,72 +0,0 @@ -# Try to find the HTML Tidy lib -# Once done this will define: -# -# LIBTIDY_FOUND - system has LIBTIDY -# LIBTIDY_INCLUDE_DIR - the LIBTIDY include directory -# LIBTIDY_LIBRARIES - The libraries needed to use LIBTIDY -# LIBTIDY_ULONG_VERSION_FOUND - To deal with source incompatible versions -# -# Copyright (c) 2007, Paulo Moura Guedes, -# -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. - - -if (LIBTIDY_INCLUDE_DIR) - # Already in cache, be silent - set(LibTidy_FIND_QUIETLY TRUE) -endif (LIBTIDY_INCLUDE_DIR) - -FIND_PATH(LIBTIDY_INCLUDE_DIR tidy.h) - -if( NOT LIBTIDY_INCLUDE_DIR ) - find_path(LIBTIDY_INCLUDE_DIR tidy.h PATH_SUFFIXES tidy) - #now tidy.h was inside a tidy subdirectory so we need to - #add that to the include dir - set(LIBTIDY_INCLUDE_DIR ${LIBTIDY_INCLUDE_DIR}/tidy CACHE PATH "Libtidy include directory") -endif( NOT LIBTIDY_INCLUDE_DIR ) - - - -FIND_LIBRARY(LIBTIDY_LIBRARIES NAMES tidy) - -if (LIBTIDY_INCLUDE_DIR AND LIBTIDY_LIBRARIES) - set(LIBTIDY_FOUND TRUE) -endif (LIBTIDY_INCLUDE_DIR AND LIBTIDY_LIBRARIES) - - -if (LIBTIDY_FOUND) - if (NOT LibTidy_FIND_QUIETLY) - message(STATUS "Found Tidy: ${LIBTIDY_LIBRARIES}") - endif (NOT LibTidy_FIND_QUIETLY) - - SET(CHECK_TIDY_ULONG_SOURCE_CODE " -#include <${LIBTIDY_INCLUDE_DIR}/tidy.h> - -int main() -{ - ulong l; - TidyInputSource s; - s.sourceData = l; -} -") - - CHECK_CXX_SOURCE_COMPILES("${CHECK_TIDY_ULONG_SOURCE_CODE}" TIDY_ULONG_VERSION) - if(TIDY_ULONG_VERSION) - SET(LIBTIDY_ULONG_VERSION_FOUND TRUE) - else(TIDY_ULONG_VERSION) - SET(LIBTIDY_ULONG_VERSION_FOUND FALSE) - endif(TIDY_ULONG_VERSION) - - macro_bool_to_01(TIDY_ULONG_VERSION HAVE_TIDY_ULONG_VERSION) - -else (LIBTIDY_FOUND) - if (LibTidy_FIND_REQUIRED) - message(FATAL_ERROR "Could NOT find LIBTIDY") - else (LibTidy_FIND_REQUIRED) - message(STATUS "Could NOT find LIBTIDY") - endif (LibTidy_FIND_REQUIRED) -endif (LIBTIDY_FOUND) - -MARK_AS_ADVANCED(LIBTIDY_INCLUDE_DIR LIBTIDY_LIBRARIES) - diff --git a/plugins/validators/Messages.sh b/plugins/validators/Messages.sh deleted file mode 100644 --- a/plugins/validators/Messages.sh +++ /dev/null @@ -1,3 +0,0 @@ -#! /bin/sh -$EXTRACTRC *.rc *.ui *.kcfg >> rc.cpp -$XGETTEXT *.cpp -o $podir/validatorsplugin.pot diff --git a/plugins/validators/clickiconlabel.h b/plugins/validators/clickiconlabel.h deleted file mode 100644 --- a/plugins/validators/clickiconlabel.h +++ /dev/null @@ -1,50 +0,0 @@ -/* This file is part of Validators - * - * Copyright (C) 2008 by Pino Toscano - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - **/ - -#ifndef CLICKICONLABEL_H -#define CLICKICONLABEL_H - -#include - -class QLabel; - -class ClickIconLabel : public QWidget -{ - Q_OBJECT -public: - ClickIconLabel(QWidget *parent = nullptr); - - void setText(const QString &text); - void setPixmap(const QPixmap &pixmap); - -signals: - void leftClicked(); - void rightClicked(); - void midClicked(); - -protected: - void changeEvent(QEvent *event) override; - void mouseReleaseEvent(QMouseEvent *event) override; - -private: - QLabel *m_text; - QLabel *m_pixmap; -}; - -#endif diff --git a/plugins/validators/clickiconlabel.cpp b/plugins/validators/clickiconlabel.cpp deleted file mode 100644 --- a/plugins/validators/clickiconlabel.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* This file is part of Validators - * - * Copyright (C) 2008 by Pino Toscano - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - **/ - -#include "clickiconlabel.h" - -#include -#include -#include - -ClickIconLabel::ClickIconLabel(QWidget *parent) - : QWidget(parent) -{ - QHBoxLayout *lay = new QHBoxLayout(this); - lay->setContentsMargins(0, 0, 0, 0); - lay->setSpacing(3); - m_pixmap = new QLabel(this); - lay->addWidget(m_pixmap); - m_pixmap->show(); - m_text = new QLabel(this); - lay->addWidget(m_text); - m_text->show(); -} - -void ClickIconLabel::setText(const QString &text) -{ - m_text->setText(text); -} - -void ClickIconLabel::setPixmap(const QPixmap &pixmap) -{ - m_pixmap->setPixmap(pixmap); -} - -void ClickIconLabel::changeEvent(QEvent *event) -{ - QWidget::changeEvent(event); -#if QT_VERSION < 0x040500 - switch (event->type()) { - case QEvent::PaletteChange: - m_text->setPalette(palette()); - break; - default: - break; - } -#endif -} - -void ClickIconLabel::mouseReleaseEvent(QMouseEvent *event) -{ - switch (event->button()) { - case Qt::LeftButton: - emit leftClicked(); - break; - case Qt::MidButton: - emit midClicked(); - break; - case Qt::RightButton: - emit rightClicked(); - break; - default: - break; - } -} - diff --git a/plugins/validators/config-konq-validator.h.cmake b/plugins/validators/config-konq-validator.h.cmake deleted file mode 100644 --- a/plugins/validators/config-konq-validator.h.cmake +++ /dev/null @@ -1,2 +0,0 @@ -#cmakedefine HAVE_TIDY 1 -#cmakedefine HAVE_TIDY_ULONG_VERSION 1 diff --git a/plugins/validators/internalvalidator.ui b/plugins/validators/internalvalidator.ui deleted file mode 100644 --- a/plugins/validators/internalvalidator.ui +++ /dev/null @@ -1,82 +0,0 @@ - - InternalValidator - - - - 0 - 0 - 402 - 79 - - - - - - - - - Accessibility validation level: - - - - - - - - 0 (No check) - - - - - 1 - - - - - 2 - - - - - 3 - - - - - - - - If this option is enabled, the internal HTML validator is executed after a webpage has been loaded. - - - Run after loading - - - - - - - - - Qt::Vertical - - - - 20 - 2 - - - - - - - - - KComboBox - QComboBox -
kcombobox.h
-
-
- - -
diff --git a/plugins/validators/pics/16-actions-cssvalidator.png b/plugins/validators/pics/16-actions-cssvalidator.png deleted file mode 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 GIT binary patch literal 0 Hc$@ - * Andreas Schlapbach - * Copyright (C) 2008-2009 by Pino Toscano - * - * for information how to write your own plugin see: - * http://developer.kde.org/documentation/tutorials/dot/writing-plugins.html - * - * 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 __plugin_validators_h -#define __plugin_validators_h - -#include "validatorsdialog.h" - -#include -#include - -#include - - -class KActionMenu; - -namespace KIO -{ -class Job; -} -namespace KParts -{ -class ReadOnlyPart; -class StatusBarExtension; -} -class ClickIconLabel; -struct ValidationResult; - -class PluginValidators : public KParts::Plugin -{ - Q_OBJECT -public: - PluginValidators(QObject *parent, - const QVariantList &); - ~PluginValidators() override; - - static const char s_boundary[]; - static const char s_CRLF[]; - -public slots: - void slotValidateHtmlByUri(); - void slotValidateHtmlByUpload(); - void slotValidateCssByUri(); - void slotValidateCssByUpload(); - void slotValidateLinks(); - void slotConfigure(); - -private slots: - void slotStarted(KIO::Job *); - void slotCompleted(); - void slotContextMenu(); - void slotTidyValidation(); - void slotShowTidyValidationReport(); - void setURLs(); - -private: - KActionMenu *m_menu; - QPointer m_configDialog; // | - // +-> Order dependency. - KParts::ReadOnlyPart *m_part; // | - - QUrl m_WWWValidatorUrl, m_WWWValidatorUploadUrl; - QUrl m_CSSValidatorUrl, m_CSSValidatorUploadUrl; - QUrl m_linkValidatorUrl; - - QAction *m_validateHtmlUri, *m_validateHtmlUpload; - QAction *m_validateCssUri, *m_validateCssUpload; - QAction *m_validateLinks; - QAction *m_localValidation, *m_localValidationReport; - - ClickIconLabel *m_icon; - KParts::StatusBarExtension *m_statusBarExt; - QList m_lastResults; - - bool canValidateByUri() const; - bool canValidateByUpload() const; - bool canValidateLocally() const; - QString documentSource() const; - void validateByUri(const QUrl &url); - void validateByUpload(const QUrl &url, const QList > &formData); - bool doExternalValidationChecks(); - void addStatusBarIcon(); - void removeStatusBarIcon(); -}; - -#endif diff --git a/plugins/validators/plugin_validators.cpp b/plugins/validators/plugin_validators.cpp deleted file mode 100644 --- a/plugins/validators/plugin_validators.cpp +++ /dev/null @@ -1,582 +0,0 @@ -/* This file is part of Validators - * - * It's a merge of the HTML- and the CSSValidator - * - * Copyright (C) 2001 by Richard Moore - * Andreas Schlapbach - * Copyright (C) 2008-2009 by Pino Toscano - * - * for information how to write your own plugin see: - * http://developer.kde.org/documentation/tutorials/dot/writing-plugins.html - * - * 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. - **/ - -#include "plugin_validators.h" - -#include "clickiconlabel.h" -#include "settings.h" - -#include - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#ifdef HAVE_TIDY -#include "tidy_validator.h" -#include "reportdialog.h" -#endif - -K_PLUGIN_FACTORY(PluginValidatorsFactory, registerPlugin();) - -const char PluginValidators::s_boundary[] = "KonquerorValidatorPlugin"; -const char PluginValidators::s_CRLF[] = "\r\n"; - -static QByteArray createPostData(const QList > &formData) -{ - QByteArray postData; - QList >::ConstIterator it = formData.constBegin(), itEnd = formData.constEnd(); - const QByteArray dash("--"); - for (; it != itEnd; ++it) { - postData += dash + PluginValidators::s_boundary + PluginValidators::s_CRLF - + "Content-Disposition: form-data; name=\"" + it->first + "\"" - + PluginValidators::s_CRLF + PluginValidators::s_CRLF - + it->second + PluginValidators::s_CRLF; - - } - postData += dash + PluginValidators::s_boundary + dash; - return postData; -} - -bool acceptHTMLFrame(const QString &name) -{ - // skip Google's advertising (i)frames - if (name.startsWith(QLatin1String("google_ads_frame")) - || name.startsWith(QLatin1String("google_ads_iframe")) - ) { - return false; - } - - return true; -} - -#ifdef HAVE_TIDY -static void recursiveKHTMLValidation(KHTMLPart *part, QList *results) -{ - const QStringList frameNames = part->frameNames(); - int i = 0; - Q_FOREACH (KParts::ReadOnlyPart *frame, part->frames()) { - if (KHTMLPart *khtmlpart = qobject_cast(frame)) { - if (acceptHTMLFrame(frameNames.at(i))) { - ValidationResult *res = new ValidationResult(); - res->frameName = frameNames.at(i); - { - TidyValidator v(part->documentSource().toUtf8()); - res->errors = v.errors(); - res->warnings = v.warnings(); - res->accesswarns = v.accessibilityWarnings(); - } - results->append(res); - - recursiveKHTMLValidation(khtmlpart, results); - } - } - ++i; - } -} -#endif - -PluginValidators::PluginValidators(QObject *parent, - const QVariantList &) - : Plugin(parent), m_configDialog(nullptr), m_part(nullptr) - , m_localValidation(nullptr), m_localValidationReport(nullptr) - , m_icon(nullptr), m_statusBarExt(nullptr) -{ - - m_menu = new KActionMenu(QIcon::fromTheme(QStringLiteral("validators")), i18n("&Validate Web Page"), - actionCollection()); - actionCollection()->addAction(QStringLiteral("validateWebpage"), m_menu); - m_menu->setDelayed(false); - - m_validateHtmlUri = m_menu->menu()->addAction(QIcon::fromTheme(QStringLiteral("htmlvalidator")), - i18n("Validate HTML (by URI)"), - this, SLOT(slotValidateHtmlByUri())); - - m_validateHtmlUpload = m_menu->menu()->addAction(QIcon::fromTheme(QStringLiteral("htmlvalidator")), - i18n("Validate HTML (by Upload)"), - this, SLOT(slotValidateHtmlByUpload())); - - m_validateCssUri = m_menu->menu()->addAction(QIcon::fromTheme(QStringLiteral("cssvalidator")), - i18n("Validate CSS (by URI)"), - this, SLOT(slotValidateCssByUri())); - - m_validateCssUpload = m_menu->menu()->addAction(QIcon::fromTheme(QStringLiteral("cssvalidator")), - i18n("Validate CSS (by Upload)"), - this, SLOT(slotValidateCssByUpload())); - // FIXME temporary disabled, as it does not work - m_validateCssUpload->setVisible(false); - - m_validateLinks = m_menu->menu()->addAction(i18n("Validate &Links"), this, SLOT(slotValidateLinks())); - -#ifdef HAVE_TIDY - m_menu->menu()->addSeparator(); - - m_localValidation = m_menu->menu()->addAction(QIcon::fromTheme("validators"), - i18n("Validate Page"), - this, SLOT(slotTidyValidation())); - - m_localValidationReport = m_menu->menu()->addAction(QIcon::fromTheme("document-properties"), - i18n("View Validator Report"), - this, SLOT(slotShowTidyValidationReport())); -#endif - - if (parent) { - m_menu->menu()->addSeparator(); - - m_menu->menu()->addAction(QIcon::fromTheme(QStringLiteral("configure")), i18n("C&onfigure Validator..."), - this, SLOT(slotConfigure())); - - m_part = qobject_cast(parent); - m_configDialog = new ValidatorsDialog(m_part->widget()); - connect(m_configDialog, SIGNAL(configChanged()), this, SLOT(setURLs())); - setURLs(); - - connect(m_part, SIGNAL(started(KIO::Job*)), this, - SLOT(slotStarted(KIO::Job*))); - connect(m_part, SIGNAL(completed()), this, SLOT(slotCompleted())); - } -} - -PluginValidators::~PluginValidators() -{ - removeStatusBarIcon(); - delete m_configDialog; -#ifdef HAVE_TIDY - qDeleteAll(m_lastResults); -#endif -// Dont' delete the action. KActionCollection as parent does the job already -// and not deleting it at this point also ensures that in case we are not unplugged -// from the GUI yet and the ~KXMLGUIClient destructor will do so it won't hit a -// dead pointer. The kxmlgui factory keeps references to the actions, but it does not -// connect to their destroyed() signal, yet (need to find an elegant solution for that -// as it can easily increase the memory usage significantly) . That's why actions must -// persist as long as the plugin is plugged into the GUI. -// delete m_menu; -} - -QString elementOfList(const QStringList &list, uint index) -{ - return static_cast(index) >= list.count() ? QString() : list.at(index); -} - -QString getWWWValidatorUrl() -{ - return elementOfList(ValidatorsSettings::wWWValidatorUrl(), ValidatorsSettings::wWWValidatorUrlIndex()); -} - -QString getWWWValidatorUploadUrl() -{ - return elementOfList(ValidatorsSettings::wWWValidatorUploadUrl(), ValidatorsSettings::wWWValidatorUploadUrlIndex()); -} - -QString getCSSValidatorUrl() -{ - return elementOfList(ValidatorsSettings::cSSValidatorUrl(), ValidatorsSettings::cSSValidatorUrlIndex()); -} - -QString getCSSValidatorUploadUrl() -{ - return elementOfList(ValidatorsSettings::cSSValidatorUploadUrl(), ValidatorsSettings::cSSValidatorUploadUrlIndex()); -} - -QString getLinkValidatorUrl() -{ - return elementOfList(ValidatorsSettings::linkValidatorUrl(), ValidatorsSettings::linkValidatorUrlIndex()); -} - -void PluginValidators::setURLs() -{ - m_WWWValidatorUrl = QUrl(getWWWValidatorUrl()); - m_CSSValidatorUrl = QUrl(getCSSValidatorUrl()); - m_WWWValidatorUploadUrl = QUrl(getWWWValidatorUploadUrl()); - m_CSSValidatorUploadUrl = QUrl(getCSSValidatorUploadUrl()); - m_linkValidatorUrl = QUrl(getLinkValidatorUrl()); -} - -void PluginValidators::slotStarted(KIO::Job *) -{ - removeStatusBarIcon(); - - const bool byUri = canValidateByUri(); - const bool byUpload = canValidateByUpload(); - m_validateHtmlUri->setEnabled(byUri); - m_validateHtmlUpload->setEnabled(byUpload); - m_validateCssUri->setEnabled(byUri); - m_validateCssUpload->setEnabled(byUpload); - m_validateLinks->setEnabled(byUri); -#ifdef HAVE_TIDY - m_localValidation->setEnabled(false); - m_localValidationReport->setEnabled(false); -#endif -} - -void PluginValidators::slotCompleted() -{ - const bool byUri = canValidateByUri(); - const bool byUpload = canValidateByUpload(); - const bool locally = canValidateLocally(); - m_validateHtmlUri->setEnabled(byUri); - m_validateHtmlUpload->setEnabled(byUpload); - m_validateCssUri->setEnabled(byUri); - m_validateCssUpload->setEnabled(byUpload); - m_validateLinks->setEnabled(byUri); -#ifdef HAVE_TIDY - m_localValidation->setEnabled(locally); - m_localValidationReport->setEnabled(false); -#endif - - addStatusBarIcon(); - -#ifdef HAVE_TIDY - if (ValidatorsSettings::runAfterLoading() && locally) { - slotTidyValidation(); - } -#endif -} - -void PluginValidators::slotValidateHtmlByUri() -{ - validateByUri(m_WWWValidatorUrl); -} - -void PluginValidators::slotValidateHtmlByUpload() -{ - if (!m_WWWValidatorUploadUrl.isValid()) { - return; - } - - QList > postData; - postData.append(QPair("fragment", documentSource().split('\n').join(QLatin1String(s_CRLF)).toUtf8())); - postData.append(QPair("prefill", "0")); - postData.append(QPair("doctype", "Inline")); - postData.append(QPair("prefill_doctype", "html401")); - postData.append(QPair("group", "0")); - validateByUpload(m_WWWValidatorUploadUrl, postData); -} - -void PluginValidators::slotValidateCssByUri() -{ - validateByUri(m_CSSValidatorUrl); -} - -void PluginValidators::slotValidateCssByUpload() -{ -} - -void PluginValidators::slotValidateLinks() -{ - validateByUri(m_linkValidatorUrl); -} - -void PluginValidators::slotContextMenu() -{ - QMenu menu(m_part->widget()); - menu.setTitle(i18n("Remote Validation")); - menu.addAction(m_validateHtmlUri); - menu.addAction(m_validateHtmlUpload); - menu.addAction(m_validateCssUri); - menu.addAction(m_validateCssUpload); - menu.addAction(m_validateLinks); -#ifdef HAVE_TIDY - menu.setTitle(i18n("Local Validation")); - menu.addAction(m_localValidation); - menu.addAction(m_localValidationReport); -#endif - menu.exec(QCursor::pos()); -} - -void PluginValidators::slotTidyValidation() -{ -#ifdef HAVE_TIDY - qDeleteAll(m_lastResults); - m_lastResults.clear(); - if (KHTMLPart *khtmlpart = qobject_cast(m_part)) { - ValidationResult *res = new ValidationResult(); - { - TidyValidator v(khtmlpart->documentSource().toUtf8()); - res->errors = v.errors(); - res->warnings = v.warnings(); - res->accesswarns = v.accessibilityWarnings(); - } - m_lastResults.append(res); - - recursiveKHTMLValidation(khtmlpart, &m_lastResults); - } else { - return; - } - QList::ConstIterator vIt = m_lastResults.constBegin(), vItEnd = m_lastResults.constEnd(); - int errorCount = 0; - int warningCount = 0; - int a11yWarningCount = 0; - for (; vIt != vItEnd; ++vIt) { - ValidationResult *res = *vIt; - errorCount += res->errors.count(); - warningCount += res->warnings.count(); - a11yWarningCount += res->accesswarns.count(); - } - - const QString errorCountString = i18np("1 error", "%1 errors", errorCount); - const QString warningCountString = i18np("1 warning", "%1 warnings", warningCount); - const QString a11yWarningCountString = i18np("1 accessibility warning", "%1 accessibility warnings", a11yWarningCount); - m_icon->setText(i18nc("%1 is the error count string, %2 the warning count string", - "%1, %2", errorCountString, warningCountString)); - QStringList results; - results.append(i18n("HTML tidy results:") + QLatin1String("\n")); - if (m_lastResults.count() == 1) { - results.append(errorCountString); - results.append(warningCountString); - if (ValidatorsSettings::accessibilityLevel()) { - results.append(a11yWarningCountString); - } - } else if (m_lastResults.count() > 1) { - vIt = m_lastResults.constBegin(); - if (ValidatorsSettings::accessibilityLevel()) - results.append(i18nc("%1 is the error count string, %2 the warning count string, " - "%3 the accessibility warning string", - "Page: %1, %2, %3", - i18np("1 error", "%1 errors", (*vIt)->errors.count()), - i18np("1 warning", "%1 warnings", (*vIt)->warnings.count()), - i18np("1 accessibility warning", "%1 accessibility warnings", (*vIt)->accesswarns.count()))); - else - results.append(i18nc("%1 is the error count string, %2 the warning count string", - "Page: %1, %2", - i18np("1 error", "%1 errors", (*vIt)->errors.count()), - i18np("1 warning", "%1 warnings", (*vIt)->warnings.count()))); - ++vIt; - for (; vIt != vItEnd; ++vIt) { - ValidationResult *res = *vIt; - if (ValidatorsSettings::accessibilityLevel()) - results.append(i18nc("%1 is the HTML frame name, %2 is the error count string, " - "%3 the warning count string, %4 the accessibility warning string", - "Frame '%1': %2, %3, %4", - res->frameName.toHtmlEscaped(), - i18np("1 error", "%1 errors", (*vIt)->errors.count()), - i18np("1 warning", "%1 warnings", (*vIt)->warnings.count()), - i18np("1 accessibility warning", "%1 accessibility warnings", (*vIt)->accesswarns.count()))); - else - results.append(i18nc("%1 is the HTML frame name, %2 is the error count string, " - "%3 the warning count string", - "Frame '%1': %2, %3", - res->frameName.toHtmlEscaped(), - i18np("1 error", "%1 errors", (*vIt)->errors.count()), - i18np("1 warning", "%1 warnings", (*vIt)->warnings.count()))); - } - } - m_icon->setToolTip(results.join(QLatin1String("\n"))); - QPalette pal = m_icon->palette(); - if (errorCount > 0) { - KColorScheme::adjustBackground(pal, KColorScheme::NegativeBackground, QPalette::Window); - KColorScheme::adjustForeground(pal, KColorScheme::NegativeText, QPalette::WindowText); - } else if (warningCount > 0) { - KColorScheme::adjustBackground(pal, KColorScheme::NeutralBackground, QPalette::Window); - KColorScheme::adjustForeground(pal, KColorScheme::NeutralText, QPalette::WindowText); - } else { - KColorScheme::adjustBackground(pal, KColorScheme::PositiveBackground, QPalette::Window); - KColorScheme::adjustForeground(pal, KColorScheme::PositiveText, QPalette::WindowText); - } - m_icon->setPalette(pal); - m_localValidationReport->setEnabled(true); -#endif -} - -void PluginValidators::slotShowTidyValidationReport() -{ -#ifdef HAVE_TIDY - ReportDialog *reportDialog = new ReportDialog(m_lastResults, nullptr); - reportDialog->setAttribute(Qt::WA_DeleteOnClose); - reportDialog->show(); -#endif -} - -void PluginValidators::slotConfigure() -{ - m_configDialog->show(); -} - -void PluginValidators::validateByUri(const QUrl &url) -{ - if (!doExternalValidationChecks()) { - return; - } - - QUrl partUrl = m_part->url(); - QUrl validatorUrl(url); - if (!partUrl.password().isEmpty()) { - KMessageBox::sorry( - m_part->widget(), - i18n("The selected URL cannot be verified because it contains " - "a password. Sending this URL to %1 would put the security " - "of %2 at risk.", - validatorUrl.host(), partUrl.host())); - return; - } - // Set entered URL as a parameter - validatorUrl.addQueryItem(QStringLiteral("uri"), partUrl.url()); - kDebug(90120) << "final URL: " << validatorUrl.url(); - KParts::BrowserExtension *ext = KParts::BrowserExtension::childObject(m_part); - KParts::OpenUrlArguments urlArgs; - KParts::BrowserArguments browserArgs; - browserArgs.setNewTab(true); - emit ext->openUrlRequest(validatorUrl, urlArgs, browserArgs); -} - -void PluginValidators::validateByUpload(const QUrl &validatorUrl, const QList > &formData) -{ - KParts::BrowserExtension *ext = KParts::BrowserExtension::childObject(m_part); - KParts::OpenUrlArguments urlArgs; - KParts::BrowserArguments browserArgs; - browserArgs.setNewTab(true); - browserArgs.setContentType(QStringLiteral("Content-Type: multipart/form-data; Boundary=%1").arg(PluginValidators::s_boundary)); - browserArgs.postData = createPostData(formData); - browserArgs.setDoPost(true); - browserArgs.setRedirectedRequest(true); - emit ext->openUrlRequest(validatorUrl, urlArgs, browserArgs); -} - -bool PluginValidators::canValidateByUri() const -{ - return m_part->url().scheme() == QLatin1String("http"); -} - -bool PluginValidators::canValidateByUpload() const -{ - return canValidateLocally(); -} - -bool PluginValidators::canValidateLocally() const -{ - // we can track only HTML renderer components - if (!parent()->inherits("KHTMLPart")) { - return false; - } - - static const char *exclude_protocols[] = { - "about", - "bookmarks", - nullptr // keep it as last! - }; - const QByteArray proto = m_part->url().scheme().toAscii(); - for (const char **protoIt = exclude_protocols; *protoIt; ++protoIt) { - if (proto == *protoIt) { - return false; - } - } - - return true; -} - -QString PluginValidators::documentSource() const -{ - if (KHTMLPart *khtmlpart = qobject_cast(m_part)) { - return khtmlpart->documentSource(); - } - return QString(); -} - -bool PluginValidators::doExternalValidationChecks() -{ - if (!parent()->inherits("KHTMLPart") && !parent()->inherits("KWebKitPart")) { - const QString title = i18nc("@title:window", "Cannot Validate Source"); - const QString text = i18n("You cannot validate anything except web pages with " - "this plugin."); - - KMessageBox::sorry(nullptr, text, title); - return false; - } - - // Get URL - QUrl partUrl = m_part->url(); - if (!partUrl.isValid()) { // Just in case ;) - const QString title = i18nc("@title:window", "Malformed URL"); - const QString text = i18n("The URL you entered is not valid, please " - "correct it and try again."); - KMessageBox::sorry(nullptr, text, title); - return false; - } - - return true; -} - -void PluginValidators::addStatusBarIcon() -{ - // already an icon placed - if (m_icon) { - return; - } - - if (!canValidateLocally()) { - return; - } - - m_statusBarExt = KParts::StatusBarExtension::childObject(m_part); - if (!m_statusBarExt) { - return; - } - - m_icon = new ClickIconLabel(m_statusBarExt->statusBar()); - m_icon->setFixedHeight(KIconLoader::global()->currentSize(KIconLoader::Small)); - m_icon->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); - m_icon->setPixmap(KIconLoader::global()->loadIcon(QStringLiteral("htmlvalidator"), KIconLoader::Small)); - m_icon->setToolTip(i18n("Validation")); - m_icon->setAutoFillBackground(true); - connect(m_icon, SIGNAL(leftClicked()), this, SLOT(slotContextMenu())); - m_statusBarExt->addStatusBarItem(m_icon, 0, true); -} - -void PluginValidators::removeStatusBarIcon() -{ - if (!m_icon) { - return; - } - - m_statusBarExt = KParts::StatusBarExtension::childObject(m_part); - if (!m_statusBarExt) { - return; - } - - m_statusBarExt->removeStatusBarItem(m_icon); - delete m_icon; - m_icon = nullptr; -} - -#include diff --git a/plugins/validators/plugin_validators.desktop b/plugins/validators/plugin_validators.desktop deleted file mode 100644 --- a/plugins/validators/plugin_validators.desktop +++ /dev/null @@ -1,136 +0,0 @@ -[Desktop Entry] -X-KDE-Library=validators -X-KDE-PluginInfo-Author=Richard Moore, Andreas Schlapbach -X-KDE-PluginInfo-Email=rich@kde.org, schlpbch@iam.unibe.ch -X-KDE-PluginInfo-Name=validators -X-KDE-PluginInfo-Version=3.3 -X-KDE-PluginInfo-Website= -X-KDE-PluginInfo-Category=Tools -X-KDE-PluginInfo-Depends= -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=false -Name=Website Validators -Name[ar]=مصدقات المواقع الويب -Name[ast]=Validadores de sitios web -Name[bg]=Валидиране на сайтове -Name[bs]=Overivači veb sajtova -Name[ca]=Validadors de llocs web -Name[ca@valencia]=Validadors de llocs web -Name[cs]=Validátory webových stránek -Name[da]=Validering af websider -Name[de]=Webseiten-Überprüfung -Name[el]=Ελεγκτές εγκυρότητας ιστοσελίδων -Name[en_GB]=Website Validators -Name[es]=Validadores de sitios web -Name[et]=Veebilehekülje kontrollijad -Name[eu]=Webgune balidatzaileak -Name[fi]=Verkkosivuvalidaattorit -Name[fr]=Validateurs de sites web -Name[ga]=Bailíochtóirí Suímh Ghréasáin -Name[gl]=Validadores de páxinas web -Name[he]=מוודאי תקינות אתר אינטרנט -Name[hne]=वेबसाइट वेलिडेटर्स -Name[hr]=Provjeravači valjanosti web stranica -Name[hu]=Weboldal érvényesség-ellenőrzők -Name[ia]=Validatores de sito web -Name[id]=Validator Situs Web -Name[is]=Fullgilding vefsvæða -Name[it]=Convalidatori di siti web -Name[ja]=ウェブサイト検証ツール -Name[kk]=Вебсайт тексергіші -Name[km]=កម្មវិធី​ធ្វើ​ឲ្យ​តំបន់​បណ្ដាញ​មាន​សុពលភាព -Name[ko]=웹 사이트 검증 도구 -Name[ku]=Erêkerên Malperê -Name[lt]=Web sričių tikrinimo priemonės -Name[lv]=Tīmekļa lapu korektuma pārbaudītājs -Name[mr]=वेबसाईट व्हेलिडेटर्स -Name[nb]=Nettstedsvalidering -Name[nds]=Nettsieden-Prööv -Name[nl]=Website-validatieprogramma -Name[nn]=Nettsidevalidering -Name[pa]=ਵੈੱਬ-ਸਟਾਈ ਵਾਇਲੀਡੇਟਰ -Name[pl]=Zatwierdzający strony internetowe -Name[pt]=Validação da Página Web -Name[pt_BR]=Validador de página da Internet -Name[ro]=Validatori de website -Name[ru]=Проверка веб-сайтов относительно веб-стандартов -Name[sk]=Overovači webových strániek -Name[sl]=Potrjevalniki veljavnosti spletnih strani -Name[sr]=Оверивачи веб сајтова -Name[sr@ijekavian]=Овјеривачи веб сајтова -Name[sr@ijekavianlatin]=Ovjerivači veb sajtova -Name[sr@latin]=Overivači veb sajtova -Name[sv]=Validering av webbplatser -Name[tg]=Муайянкунандаи интернетӣ -Name[th]=ตรวจความถูกต้องของไวยากรณ์บนเว็บไซต์ -Name[tr]=Website Geçerlilik Doğrulayıcısı -Name[ug]=تور بېكەت دەلىللىگۈچ -Name[uk]=Перевірка вебсайтів -Name[wa]=Valideu d' waibe -Name[x-test]=xxWebsite Validatorsxx -Name[zh_CN]=网站验证器 -Name[zh_TW]=網站確認器 -Comment=CSS and HTML validation tools -Comment[ar]=أدوات تصديق HTML و CSS -Comment[ast]=Ferramientes de validación de CSS y HTML -Comment[bg]=Инструменти за валидиране на CSS и HTML -Comment[bs]=Alatke za ovjeru CSS‑a i HTML‑a -Comment[ca]=Eines de validació de CSS i HTML -Comment[ca@valencia]=Eines de validació de CSS i HTML -Comment[cs]=Nástroje pro kontrolu HTML a CSS -Comment[da]=Valideringsværktøjer til CSS og HTML -Comment[de]=CSS- und HTML-Überprüfungswerkzeuge -Comment[el]=Εργαλεία ελέγχου εγκυρότητας CSS και HTML -Comment[en_GB]=CSS and HTML validation tools -Comment[es]=Herramientas de validación CSS y HTML -Comment[et]=CSS-i ja HTML-i kontrollimine vahendid -Comment[eu]=CSS eta HTML balidatzeko tresnak -Comment[fi]=CSS- ja HTML-validaattorit -Comment[fr]=Outils de validation CSS et HTML -Comment[ga]=Uirlisí Bailíochtaithe CSS agus HTML -Comment[gl]=Ferramentas de validación de CSS e HTML -Comment[he]=כלים לבדיקת תקינות של CSS ו־HTML -Comment[hne]=सीएसएस अउ एचटीएमएल वेलिडेसन औजार -Comment[hr]=Alati za provjeru valjanosti CSS-a i HTML-a -Comment[hu]=CSS és HTML érvényesség-ellenőrző eszközök -Comment[ia]=Instrumentos de validate de CSS e HTML -Comment[id]=Alat validasi CSS dan HTML -Comment[is]=Prófunartól fyrir CSS og HTML -Comment[it]=Strumenti di convalida CSS e HTML -Comment[ja]=CSS と HTML を検証します -Comment[kk]=CSS және HTML тексеру құралы -Comment[km]=ឧបករណ៍​ធ្វើ​ឲ្យ​មាន​សុពលភាព CSS និង HTML -Comment[ko]=CSS와 HTML 검증 도구 -Comment[ku]=Amûrên erêkirina CSS û HTML -Comment[lt]=CSS ir HTML tikrinimo įrankiai -Comment[lv]=CSS un HTML korektuma pārbaudes rīki -Comment[mr]=CSS व HTML व्हेलिडेशन साधने -Comment[nb]=Verktøy for validering av CSS og HTML -Comment[nds]=CSS- un HTML-Pröövwarktüüch -Comment[nl]=CSS- en HTML-validatiehulpmiddellen -Comment[nn]=Verktøy for validering av CSS og HTML -Comment[pa]=CSS ਅਤੇ HTML ਵੈਧਤਾ ਟੂਲ -Comment[pl]=Narzędzia zatwierdzające CSS i HTML -Comment[pt]='Plugins' de validação de CSS e HTML -Comment[pt_BR]=Ferramentas de validação de CSS e HTML -Comment[ro]=Utilitare de validare CSS și HTML -Comment[ru]=Инструменты проверки CSS и HTML -Comment[sk]=Nástroje pre kontrolu HTML a CSS -Comment[sl]=Orodja za potrjevanje veljavnosti CSS in HTML -Comment[sr]=Алатке за оверу ЦСС‑а и ХТМЛ‑а -Comment[sr@ijekavian]=Алатке за овјеру ЦСС‑а и ХТМЛ‑а -Comment[sr@ijekavianlatin]=Alatke za ovjeru CSS‑a i HTML‑a -Comment[sr@latin]=Alatke za overu CSS‑a i HTML‑a -Comment[sv]=CSS- och HTML-valideringsverktyg -Comment[tg]=Асбобҳои муайянкунии CSS ва HTML -Comment[th]=เครื่องมือตรวจความถูกต้องของไวยากรณ์แบบ CSS และ HTML -Comment[tr]=CSS ve HTML geçerlilik doğrulama araçları -Comment[ug]=CSS ۋە HTML دەلىللىگۈچ قورالى -Comment[uk]=Засоби перевірки CSS і HTML -Comment[wa]=Usteyes di validåcion CSS eyet HTML -Comment[x-test]=xxCSS and HTML validation toolsxx -Comment[zh_CN]=CSS 和 HTML 验证工具 -Comment[zh_TW]=CSS 與 HTML 的確認工具 -Icon=validators -X-KDE-ParentApp=konqueror -DocPath=konq-plugins/validators/index.html diff --git a/plugins/validators/plugin_validators.rc b/plugins/validators/plugin_validators.rc deleted file mode 100644 --- a/plugins/validators/plugin_validators.rc +++ /dev/null @@ -1,11 +0,0 @@ - - - - &Tools - - - -Extra Toolbar - - - diff --git a/plugins/validators/remotevalidators.ui b/plugins/validators/remotevalidators.ui deleted file mode 100644 --- a/plugins/validators/remotevalidators.ui +++ /dev/null @@ -1,164 +0,0 @@ - - RemoteValidators - - - - 0 - 0 - 477 - 286 - - - - - - - HTML/XML Validator - - - - - - URL: - - - - - - - - 0 - 0 - - - - true - - - - - - - Upload: - - - - - - - - 0 - 0 - - - - true - - - - - - - - - - CSS Validator - - - - - - URL: - - - - - - - - 0 - 0 - - - - true - - - - - - - Upload: - - - - - - - - 0 - 0 - - - - true - - - - - - - - - - Link Validator - - - - - - URL: - - - - - - - - 0 - 0 - - - - true - - - - - - - - - - Qt::Vertical - - - - 20 - 2 - - - - - - - - - KComboBox - QComboBox -
kcombobox.h
-
-
- - -
diff --git a/plugins/validators/reportdialog.h b/plugins/validators/reportdialog.h deleted file mode 100644 --- a/plugins/validators/reportdialog.h +++ /dev/null @@ -1,41 +0,0 @@ -/* This file is part of Validators - * - * Copyright (C) 2008 by Pino Toscano - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - **/ - -#ifndef REPORTDIALOG_H -#define REPORTDIALOG_H - -#include - -#include "ui_reportwidget.h" - -struct ValidationResult; - -class ReportDialog : public KDialog -{ - Q_OBJECT -public: - ReportDialog(const QList &results, QWidget *parent); - - QSize sizeHint() const override; - -private: - Ui::ReportWidget m_ui; -}; - -#endif diff --git a/plugins/validators/reportdialog.cpp b/plugins/validators/reportdialog.cpp deleted file mode 100644 --- a/plugins/validators/reportdialog.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* This file is part of Validators - * - * Copyright (C) 2008 by Pino Toscano - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - **/ - -#include "reportdialog.h" - -#include "tidy_validator.h" - -#include - -#include - -#include - -static const int FrameNumberRole = Qt::UserRole + 1; - -static bool compare_report_items(QTreeWidgetItem *a, QTreeWidgetItem *b) -{ - int val1 = a->data(0, FrameNumberRole).toInt(); - int val2 = b->data(0, FrameNumberRole).toInt(); - if (val1 != val2) { - return val1 < val2; - } - val1 = a->text(2).toInt(); - val2 = b->text(2).toInt(); - if (val1 != val2) { - return val1 < val2; - } - val1 = a->text(3).toInt(); - val2 = b->text(3).toInt(); - return val1 < val2; -} - -QTreeWidgetItem *createItemFromReport(const TidyReport &report, const QIcon &icon, const QString &iconToolTip, - const QString &frameName, int frameNumber) -{ - QTreeWidgetItem *item = new QTreeWidgetItem(); - item->setIcon(0, icon); - item->setText(1, frameName); - item->setText(2, QString::number(report.line)); - item->setText(3, QString::number(report.col)); - item->setText(4, report.msg); - item->setToolTip(0, iconToolTip); - item->setData(0, FrameNumberRole, frameNumber); - return item; -} - -ReportDialog::ReportDialog(const QList &results, QWidget *parent) - : KDialog(parent) -{ - setButtons(KDialog::Close); - setCaption(i18nc("@title:window", "Validation Report")); - - m_ui.setupUi(mainWidget()); - mainWidget()->layout()->setContentsMargins(0, 0, 0, 0); - QHeaderView *header = m_ui.reportsView->header(); - header->setResizeMode(0, QHeaderView::ResizeToContents); - header->setResizeMode(1, QHeaderView::ResizeToContents); - header->setResizeMode(2, QHeaderView::ResizeToContents); - header->setResizeMode(3, QHeaderView::ResizeToContents); - QList items; - int i = 0; - Q_FOREACH (ValidationResult *res, results) { - const QIcon errorIcon = QIcon::fromTheme("dialog-error"); - const QString errorStatus = i18nc("Validation status", "Error"); - Q_FOREACH (const TidyReport &r, res->errors) { - QTreeWidgetItem *item = createItemFromReport( - r, errorIcon, errorStatus, res->frameName, i); - items.append(item); - } - const QIcon warningIcon = QIcon::fromTheme("dialog-warning"); - const QString warningStatus = i18nc("Validation status", "Warning"); - Q_FOREACH (const TidyReport &r, res->warnings) { - QTreeWidgetItem *item = createItemFromReport( - r, warningIcon, warningStatus, res->frameName, i); - items.append(item); - } - const QIcon a11yWarningIcon = QIcon::fromTheme("preferences-desktop-accessibility"); - const QString a11yWarningStatus = i18nc("Validation status", "Accessibility warning"); - Q_FOREACH (const TidyReport &r, res->accesswarns) { - QTreeWidgetItem *item = createItemFromReport( - r, a11yWarningIcon, a11yWarningStatus, res->frameName, i); - items.append(item); - } - ++i; - } - std::stable_sort(items.begin(), items.end(), compare_report_items); - m_ui.reportsView->addTopLevelItems(items); - if (results.count() == 1) { - header->setSectionHidden(1, true); - } -} - -QSize ReportDialog::sizeHint() const -{ - return QSize(500, 400); -} - diff --git a/plugins/validators/reportwidget.ui b/plugins/validators/reportwidget.ui deleted file mode 100644 --- a/plugins/validators/reportwidget.ui +++ /dev/null @@ -1,58 +0,0 @@ - - ReportWidget - - - - 0 - 0 - 400 - 300 - - - - - - - true - - - false - - - false - - - false - - - - - - - - - Frame - - - - - Row - - - - - Column - - - - - Message - - - - - - - - - diff --git a/plugins/validators/settings.kcfgc b/plugins/validators/settings.kcfgc deleted file mode 100644 --- a/plugins/validators/settings.kcfgc +++ /dev/null @@ -1,4 +0,0 @@ -ClassName=ValidatorsSettings -File=validators.kcfg -Mutators=true -Singleton=true diff --git a/plugins/validators/tidy_validator.h b/plugins/validators/tidy_validator.h deleted file mode 100644 --- a/plugins/validators/tidy_validator.h +++ /dev/null @@ -1,95 +0,0 @@ -/* This file is part of Validators - * - * Copyright (C) 2008 by Pino Toscano - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - **/ - -#ifndef TIDY_VALIDATOR_H -#define TIDY_VALIDATOR_H - -#include -#include - -struct TidyReport { - TidyReport(const QString &m, uint l, uint c) - : msg(m), line(l), col(c) - {} - - QString msg; - uint line; - uint col; -}; - -struct ValidationResult { - QString frameName; - QList errors; - QList warnings; - QList accesswarns; -}; - -class TidyValidator -{ -public: - TidyValidator(const QString &fileName); - TidyValidator(const QByteArray &fileContent); - - int errorCount() const - { - return d.errors.count(); - } - TidyReport error(int i) const - { - return d.errors.at(i); - } - QList errors() const - { - return d.errors; - } - int warningCount() const - { - return d.warnings.count(); - } - TidyReport warning(int i) const - { - return d.warnings.at(i); - } - QList warnings() const - { - return d.warnings; - } - int accessibilityWarningCount() const - { - return d.accesswarns.count(); - } - TidyReport accessibilityWarning(int i) const - { - return d.accesswarns.at(i); - } - QList accessibilityWarnings() const - { - return d.accesswarns; - } - - struct Data { - QList errors; - QList warnings; - QList accesswarns; - }; -private: - TidyValidator::Data d; -}; - -#endif diff --git a/plugins/validators/tidy_validator.cpp b/plugins/validators/tidy_validator.cpp deleted file mode 100644 --- a/plugins/validators/tidy_validator.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* This file is part of Validators - * - * Copyright (C) 2008 by Pino Toscano - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - **/ - -#include "tidy_validator.h" - -#include "settings.h" - -#include - -#include - -#include -#include - -#include - -static Bool tidy_report_filter(TidyDoc tdoc, TidyReportLevel lvl, - uint line, uint col, ctmbstr msg) -{ - TidyValidator::Data *d = reinterpret_cast(tidyGetAppData(tdoc)); - Q_ASSERT(d); - switch (lvl) { - case TidyInfo: - break; - case TidyWarning: - d->warnings.append(TidyReport(QString::fromLocal8Bit(msg), line, col)); - break; - case TidyAccess: - d->accesswarns.append(TidyReport(QString::fromLocal8Bit(msg), line, col)); - break; - case TidyError: - d->errors.append(TidyReport(QString::fromLocal8Bit(msg), line, col)); - break; - default:; - } - return yes; -} - -TidyValidator::TidyValidator(const QString &fileName) -{ - TidyBuffer errbuf; - int rc = -1; - TidyDoc tdoc = tidyCreate(); -#ifdef HAVE_TIDY_ULONG_VERSION - tidySetAppData(tdoc, (ulong)&d); -#else - tidySetAppData(tdoc, &d); -#endif - tidyBufInit(&errbuf); - tidySetErrorBuffer(tdoc, &errbuf); - tidySetReportFilter(tdoc, tidy_report_filter); - tidyOptSetInt(tdoc, TidyAccessibilityCheckLevel, ValidatorsSettings::accessibilityLevel()); - rc = tidyParseFile(tdoc, QFile::encodeName(fileName)); - - tidyBufFree(&errbuf); - tidyRelease(tdoc); -} - -TidyValidator::TidyValidator(const QByteArray &fileContent) -{ - TidyBuffer errbuf; - int rc = -1; - TidyDoc tdoc = tidyCreate(); -#ifdef HAVE_TIDY_ULONG_VERSION - tidySetAppData(tdoc, (ulong)&d); -#else - tidySetAppData(tdoc, &d); -#endif - tidyBufInit(&errbuf); - tidySetErrorBuffer(tdoc, &errbuf); - tidySetReportFilter(tdoc, tidy_report_filter); - tidyOptSetInt(tdoc, TidyAccessibilityCheckLevel, ValidatorsSettings::accessibilityLevel()); - rc = tidyParseString(tdoc, fileContent); - - tidyBufFree(&errbuf); - tidyRelease(tdoc); -} diff --git a/plugins/validators/validators.kcfg b/plugins/validators/validators.kcfg deleted file mode 100644 --- a/plugins/validators/validators.kcfg +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - http://validator.w3.org/check - - - 0 - - - http://validator.w3.org/check - - - 0 - - - http://jigsaw.w3.org/css-validator/validator - - - 0 - - - http://jigsaw.w3.org/css-validator/validator-upload.html - - - 0 - - - http://validator.w3.org/checklink - - - 0 - - - - - 0 - 3 - - - false - - - diff --git a/plugins/validators/validatorsdialog.h b/plugins/validators/validatorsdialog.h deleted file mode 100644 --- a/plugins/validators/validatorsdialog.h +++ /dev/null @@ -1,59 +0,0 @@ -/* This file is part of the KDE project - - Copyright (C) 2001 Andreas Schlapbach - Copyright (C) 2008 Pino Toscano - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - 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 __validatorsdialog_h -#define __validatorsdialog_h - -#include - -#include "ui_remotevalidators.h" - -#include - -#ifdef HAVE_TIDY -#include "ui_internalvalidator.h" -#endif - -class ValidatorsDialog : public KPageDialog -{ - Q_OBJECT - -public: - explicit ValidatorsDialog(QWidget *parent = nullptr); - ~ValidatorsDialog() override; - -signals: - void configChanged(); - -protected slots: - void slotOk(); - void slotCancel(); - -private: - void load(); - void save(); - - Ui::RemoteValidators m_remoteUi; -#ifdef HAVE_TIDY - Ui::InternalValidator m_internalUi; -#endif -}; - -#endif diff --git a/plugins/validators/validatorsdialog.cpp b/plugins/validators/validatorsdialog.cpp deleted file mode 100644 --- a/plugins/validators/validatorsdialog.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/* This file is part of the KDE project - - Copyright (C) 2001 Andreas Schlapbach - Copyright (C) 2008 Pino Toscano - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - 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. -*/ - -#include "validatorsdialog.h" - -#include "settings.h" - - -#include - -#include - -ValidatorsDialog::ValidatorsDialog(QWidget *parent) - : KPageDialog(parent) -{ - setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); - setModal(false); - setWindowTitle(i18nc("@title:window", "Configure Validator Plugin")); - setMinimumWidth(400); - -#ifdef HAVE_TIDY - QWidget *internalConfiguration = new QWidget(); - m_internalUi.setupUi(internalConfiguration); - internalConfiguration->layout()->setContentsMargins(0, 0, 0, 0); - KPageWidgetItem *internalConfigurationItem = addPage(internalConfiguration, i18n("Internal Validation")); - internalConfigurationItem->setIcon(QIcon::fromTheme("validators")); -#endif - - QWidget *remoteConfiguration = new QWidget(); - m_remoteUi.setupUi(remoteConfiguration); - remoteConfiguration->layout()->setContentsMargins(0, 0, 0, 0); - KPageWidgetItem *remoteConfigurationItem = addPage(remoteConfiguration, i18n("Remote Validation")); - remoteConfigurationItem->setIcon(QIcon::fromTheme(QStringLiteral("validators"))); - - connect(this, SIGNAL(okClicked()), this, SLOT(slotOk())); - connect(this, SIGNAL(cancelClicked()), this, SLOT(slotCancel())); - load(); -} - -ValidatorsDialog::~ValidatorsDialog() -{ -} - -void ValidatorsDialog::load() -{ - m_remoteUi.m_WWWValidatorCB->addItems(ValidatorsSettings::wWWValidatorUrl()); - m_remoteUi.m_WWWValidatorCB->setCurrentIndex(ValidatorsSettings::wWWValidatorUrlIndex()); - - m_remoteUi.m_CSSValidatorCB->addItems(ValidatorsSettings::cSSValidatorUrl()); - m_remoteUi.m_CSSValidatorCB->setCurrentIndex(ValidatorsSettings::cSSValidatorUrlIndex()); - - m_remoteUi.m_linkValidatorCB->addItems(ValidatorsSettings::linkValidatorUrl()); - m_remoteUi.m_linkValidatorCB->setCurrentIndex(ValidatorsSettings::linkValidatorUrlIndex()); - - m_remoteUi.m_WWWValidatorUploadCB->addItems(ValidatorsSettings::wWWValidatorUploadUrl()); - m_remoteUi.m_WWWValidatorUploadCB->setCurrentIndex(ValidatorsSettings::wWWValidatorUploadUrlIndex()); - - m_remoteUi.m_CSSValidatorUploadCB->addItems(ValidatorsSettings::cSSValidatorUploadUrl()); - m_remoteUi.m_CSSValidatorUploadCB->setCurrentIndex(ValidatorsSettings::cSSValidatorUploadUrlIndex()); - -#ifdef HAVE_TIDY - m_internalUi.accessibilityLevel->setCurrentIndex(ValidatorsSettings::accessibilityLevel()); - m_internalUi.runAfterLoading->setChecked(ValidatorsSettings::runAfterLoading()); -#endif -} - -void ValidatorsDialog::save() -{ - QStringList strList; - for (int i = 0; i < m_remoteUi.m_WWWValidatorCB->count(); i++) { - strList.append(m_remoteUi.m_WWWValidatorCB->itemText(i)); - } - ValidatorsSettings::setWWWValidatorUrl(strList); - strList.clear(); - for (int i = 0; i < m_remoteUi.m_CSSValidatorCB->count(); i++) { - strList.append(m_remoteUi.m_CSSValidatorCB->itemText(i)); - } - ValidatorsSettings::setCSSValidatorUrl(strList); - strList.clear(); - for (int i = 0; i < m_remoteUi.m_linkValidatorCB->count(); i++) { - strList.append(m_remoteUi.m_linkValidatorCB->itemText(i)); - } - ValidatorsSettings::setLinkValidatorUrl(strList); - strList.clear(); - for (int i = 0; i < m_remoteUi.m_WWWValidatorUploadCB->count(); i++) { - strList.append(m_remoteUi.m_WWWValidatorUploadCB->itemText(i)); - } - ValidatorsSettings::setWWWValidatorUploadUrl(strList); - strList.clear(); - for (int i = 0; i < m_remoteUi.m_CSSValidatorUploadCB->count(); i++) { - strList.append(m_remoteUi.m_CSSValidatorUploadCB->itemText(i)); - } - ValidatorsSettings::setCSSValidatorUploadUrl(strList); - - ValidatorsSettings::setWWWValidatorUrlIndex(m_remoteUi.m_WWWValidatorCB->currentIndex()); - ValidatorsSettings::setCSSValidatorUrlIndex(m_remoteUi.m_CSSValidatorCB->currentIndex()); - ValidatorsSettings::setLinkValidatorUrlIndex(m_remoteUi.m_linkValidatorCB->currentIndex()); - ValidatorsSettings::setWWWValidatorUploadUrlIndex(m_remoteUi.m_WWWValidatorUploadCB->currentIndex()); - ValidatorsSettings::setCSSValidatorUploadUrlIndex(m_remoteUi.m_CSSValidatorUploadCB->currentIndex()); - -#ifdef HAVE_TIDY - ValidatorsSettings::setAccessibilityLevel(m_internalUi.accessibilityLevel->currentIndex()); - ValidatorsSettings::setRunAfterLoading(m_internalUi.runAfterLoading->isChecked()); -#endif - - ValidatorsSettings::self()->save(); - - emit configChanged(); -} - -void ValidatorsDialog::slotOk() -{ - save(); - hide(); -} - -void ValidatorsDialog::slotCancel() -{ - load(); - hide(); -} -