[ktexteditor] src: remove highlighting download dialog

Christoph Cullmann null at kde.org
Tue Aug 14 13:44:06 BST 2018


Git commit 705f8e0419c441ecb618d35b70b4373be453a94e by Christoph Cullmann.
Committed on 14/08/2018 at 12:44.
Pushed by cullmann into branch 'master'.

remove highlighting download dialog

Summary:
rational:

1) there is one frameworks release per month that already provides a stream of hl updates
2) often new highlightings anyways need a new frameworks version
3) one can easily update only a part of the files which leads to broken other highlighting that include parts of them
4) the updates might easily break the non-downloadable indenters

GUI: highlighting download dialog removed

Test Plan:
make
make test

Reviewers: dhaumann

Reviewed By: dhaumann

Subscribers: kwrite-devel, kde-frameworks-devel

Tags: #kate, #frameworks

Differential Revision: https://phabricator.kde.org/D14828

M  +0    -24   src/dialogs/filetypeconfigwidget.ui
M  +0    -165  src/dialogs/katedialogs.cpp
M  +0    -20   src/dialogs/katedialogs.h
M  +0    -7    src/mode/katemodeconfigpage.cpp
M  +0    -1    src/mode/katemodeconfigpage.h

https://commits.kde.org/ktexteditor/705f8e0419c441ecb618d35b70b4373be453a94e

diff --git a/src/dialogs/filetypeconfigwidget.ui b/src/dialogs/filetypeconfigwidget.ui
index 3e52c18a..2c1aa022 100644
--- a/src/dialogs/filetypeconfigwidget.ui
+++ b/src/dialogs/filetypeconfigwidget.ui
@@ -211,30 +211,6 @@
      </layout>
     </widget>
    </item>
-   <item>
-    <layout class="QHBoxLayout">
-     <item>
-      <spacer>
-       <property name="orientation">
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="sizeHint" stdset="0">
-        <size>
-         <width>1</width>
-         <height>0</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
-     <item>
-      <widget class="QPushButton" name="btnDownload">
-       <property name="text">
-        <string>Download Highlighting Files...</string>
-       </property>
-      </widget>
-     </item>
-    </layout>
-   </item>
    <item>
     <spacer>
      <property name="orientation">
diff --git a/src/dialogs/katedialogs.cpp b/src/dialogs/katedialogs.cpp
index 1ae00c18..c5af272c 100644
--- a/src/dialogs/katedialogs.cpp
+++ b/src/dialogs/katedialogs.cpp
@@ -94,9 +94,6 @@
 #include <QWhatsThis>
 #include <QDomDocument>
 
-// trailing slash is important
-#define HLDOWNLOADPATH QStringLiteral("http://kate.kde.org/syntax/")
-
 //END
 
 //BEGIN KateIndentConfigTab
@@ -1056,168 +1053,6 @@ QIcon KateSaveConfigTab::icon() const
 
 //END KateSaveConfigTab
 
-//BEGIN KateHlDownloadDialog
-KateHlDownloadDialog::KateHlDownloadDialog(QWidget *parent, const char *name, bool modal)
-    : QDialog(parent)
-{
-    setWindowTitle(i18n("Highlight Download"));
-    setObjectName(QString::fromUtf8(name));
-    setModal(modal);
-
-    QVBoxLayout *mainLayout = new QVBoxLayout;
-    setLayout(mainLayout);
-
-    QLabel *label = new QLabel(i18n("Select the syntax highlighting files you want to update:"), this);
-    mainLayout->addWidget(label);
-
-    list = new QTreeWidget(this);
-    list->setColumnCount(4);
-    list->setHeaderLabels({ QString(), i18n("Name"), i18n("Installed"), i18n("Latest") });
-    list->setSelectionMode(QAbstractItemView::MultiSelection);
-    list->setAllColumnsShowFocus(true);
-    list->setRootIsDecorated(false);
-    list->setColumnWidth(0, 22);
-    mainLayout->addWidget(list);
-
-    label = new QLabel(i18n("<b>Note:</b> New versions are selected automatically."), this);
-    mainLayout->addWidget(label);
-
-    // buttons
-    QDialogButtonBox *buttons = new QDialogButtonBox(this);
-    mainLayout->addWidget(buttons);
-
-    m_installButton = new QPushButton(QIcon::fromTheme(QStringLiteral("dialog-ok")), i18n("&Install"));
-    m_installButton->setDefault(true);
-    buttons->addButton(m_installButton, QDialogButtonBox::AcceptRole);
-    connect(m_installButton, SIGNAL(clicked()), this, SLOT(slotInstall()));
-
-    QPushButton *closeButton = new QPushButton;
-    KGuiItem::assign(closeButton, KStandardGuiItem::cancel());
-    buttons->addButton(closeButton, QDialogButtonBox::RejectRole);
-    connect(closeButton, SIGNAL(clicked()), this, SLOT(reject()));
-
-    transferJob = KIO::get(QUrl(QStringLiteral("%1update-%2.%3.xml").arg(HLDOWNLOADPATH).arg(KTEXTEDITOR_VERSION_MAJOR).arg(KTEXTEDITOR_VERSION_MINOR)), KIO::Reload);
-    connect(transferJob, SIGNAL(data(KIO::Job*,QByteArray)),
-            this, SLOT(listDataReceived(KIO::Job*,QByteArray)));
-//        void data( KIO::Job *, const QByteArray &data);
-
-    resize(450, 400);
-}
-
-KateHlDownloadDialog::~KateHlDownloadDialog() {}
-
-/// Split typical version string (\c major.minor.patch) into
-/// numeric components, convert 'em to \c unsigned and form a
-/// single value that can be compared w/ other versions
-/// using relation operators.
-/// \note It takes into account only first 3 numbers
-unsigned KateHlDownloadDialog::parseVersion(const QString &version_string)
-{
-    unsigned vn[3] = {0, 0, 0};
-    unsigned idx = 0;
-    foreach (const QString &n, version_string.split(QLatin1Char('.'))) {
-        vn[idx++] = n.toUInt();
-        if (idx == sizeof(vn)) {
-            break;
-        }
-    }
-    return (((vn[0]) << 16) | ((vn[1]) << 8) | (vn[2]));
-}
-
-void KateHlDownloadDialog::listDataReceived(KIO::Job *, const QByteArray &data)
-{
-    if (!transferJob || transferJob->isErrorPage()) {
-        m_installButton->setEnabled(false);
-        if (data.size() == 0) {
-            KMessageBox::error(this, i18n("The list of highlightings could not be found on / retrieved from the server"));
-        }
-        return;
-    }
-
-    listData += QLatin1String(data);
-    qCDebug(LOG_KTE) << QStringLiteral("CurrentListData: ") << listData;
-    qCDebug(LOG_KTE) << QStringLiteral("Data length: %1").arg(data.size());
-    qCDebug(LOG_KTE) << QStringLiteral("listData length: %1").arg(listData.length());
-    if (data.size() == 0) {
-        if (listData.length() > 0) {
-            QString installedVersion;
-            QDomDocument doc;
-            doc.setContent(listData);
-            QDomElement DocElem = doc.documentElement();
-            QDomNode n = DocElem.firstChild();
-
-            if (n.isNull()) {
-                qCDebug(LOG_KTE) << QStringLiteral("There is no usable childnode");
-            }
-            while (!n.isNull()) {
-                installedVersion = QStringLiteral("    --");
-
-                QDomElement e = n.toElement();
-                if (!e.isNull()) {
-                    qCDebug(LOG_KTE) << QStringLiteral("NAME: ") << e.tagName() << QStringLiteral(" - ") << e.attribute(QStringLiteral("name"));
-                }
-                n = n.nextSibling();
-
-                QString Name = e.attribute(QStringLiteral("name"));
-                QString version;
-                for (const auto &hl : KateHlManager::self()->modeList()) {
-                    if (hl.name() == Name) {
-                        version = QString::number(hl.version());
-                        installedVersion = QLatin1String("    ") + version;
-                        break;
-                    }
-                }
-
-                // autoselect entry if new or updated.
-                QTreeWidgetItem *entry = new QTreeWidgetItem(list);
-                entry->setText(0, QString());
-                entry->setText(1, e.attribute(QStringLiteral("name")));
-                entry->setText(2, installedVersion);
-                entry->setText(3, e.attribute(QStringLiteral("version")));
-                entry->setText(4, e.attribute(QStringLiteral("url")));
-
-                bool is_fresh = false;
-                if (!version.isEmpty()) {
-                    unsigned prev_version = parseVersion(version);
-                    unsigned next_version = parseVersion(e.attribute(QStringLiteral("version")));
-                    is_fresh = prev_version < next_version;
-                } else {
-                    is_fresh = true;
-                }
-                if (is_fresh) {
-                    entry->treeWidget()->setItemSelected(entry, true);
-                    entry->setIcon(0, QIcon::fromTheme((QStringLiteral("get-hot-new-stuff"))));
-                }
-            }
-            list->resizeColumnToContents(1);
-            list->sortItems(1, Qt::AscendingOrder);
-        }
-    }
-}
-
-void KateHlDownloadDialog::slotInstall()
-{
-    const QString destdir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/org.kde.syntax-highlighting/syntax/");
-    QDir(destdir).mkpath(QStringLiteral(".")); // make sure the dir is there
-
-    foreach (QTreeWidgetItem *it, list->selectedItems()) {
-        QUrl src(it->text(4));
-        QString filename = src.fileName();
-
-        // if there is no fileName construct at least something
-        if (filename.isEmpty()) {
-            filename = src.path().replace(QLatin1Char('/'), QLatin1Char('_'));
-        }
-
-        QUrl dest = QUrl::fromLocalFile(destdir + filename);
-
-        KIO::FileCopyJob *job = KIO::file_copy(src, dest);
-        KJobWidgets::setWindow(job, this);
-        job->exec();
-    }
-}
-//END KateHlDownloadDialog
-
 //BEGIN KateGotoBar
 KateGotoBar::KateGotoBar(KTextEditor::View *view, QWidget *parent)
     : KateViewBarWidget(true, parent)
diff --git a/src/dialogs/katedialogs.h b/src/dialogs/katedialogs.h
index 13aa6d19..cfb5cd51 100644
--- a/src/dialogs/katedialogs.h
+++ b/src/dialogs/katedialogs.h
@@ -305,26 +305,6 @@ private:
     ModeConfigPage *modeConfigPage;
 };
 
-class KateHlDownloadDialog: public QDialog
-{
-    Q_OBJECT
-
-public:
-    KateHlDownloadDialog(QWidget *parent, const char *name, bool modal);
-    ~KateHlDownloadDialog();
-
-private:
-    static unsigned parseVersion(const QString &);
-    class QTreeWidget  *list;
-    class QString listData;
-    KIO::TransferJob *transferJob;
-    QPushButton *m_installButton;
-
-private Q_SLOTS:
-    void listDataReceived(KIO::Job *, const QByteArray &data);
-    void slotInstall();
-};
-
 /**
  * This dialog will prompt the user for what do with a file that is
  * modified on disk.
diff --git a/src/mode/katemodeconfigpage.cpp b/src/mode/katemodeconfigpage.cpp
index c638a9ea..d0eeac54 100644
--- a/src/mode/katemodeconfigpage.cpp
+++ b/src/mode/katemodeconfigpage.cpp
@@ -75,7 +75,6 @@ ModeConfigPage::ModeConfigPage(QWidget *parent)
     connect(ui->btnDelete, SIGNAL(clicked()), this, SLOT(deleteType()));
     ui->btnMimeTypes->setIcon(QIcon::fromTheme(QStringLiteral("tools-wizard")));
     connect(ui->btnMimeTypes, SIGNAL(clicked()), this, SLOT(showMTDlg()));
-    connect(ui->btnDownload, SIGNAL(clicked()), this, SLOT(hlDownload()));
 
     reload();
 
@@ -294,12 +293,6 @@ void ModeConfigPage::showMTDlg()
     }
 }
 
-void ModeConfigPage::hlDownload()
-{
-    KateHlDownloadDialog diag(this, "hlDownload", true);
-    diag.exec();
-}
-
 QString ModeConfigPage::name() const
 {
     return i18n("Modes && Filetypes");
diff --git a/src/mode/katemodeconfigpage.h b/src/mode/katemodeconfigpage.h
index 47d65fc7..7b9d40c0 100644
--- a/src/mode/katemodeconfigpage.h
+++ b/src/mode/katemodeconfigpage.h
@@ -54,7 +54,6 @@ private Q_SLOTS:
     void typeChanged(int type);
     void showMTDlg();
     void save();
-    void hlDownload();
 
 private:
     Ui::FileTypeConfigWidget *ui;


More information about the kde-doc-english mailing list