diff --git a/src/dialogs/filetypeconfigwidget.ui b/src/dialogs/filetypeconfigwidget.ui --- a/src/dialogs/filetypeconfigwidget.ui +++ b/src/dialogs/filetypeconfigwidget.ui @@ -211,30 +211,6 @@ - - - - - - Qt::Horizontal - - - - 1 - 0 - - - - - - - - Download Highlighting Files... - - - - - diff --git a/src/dialogs/katedialogs.h b/src/dialogs/katedialogs.h --- a/src/dialogs/katedialogs.h +++ b/src/dialogs/katedialogs.h @@ -305,26 +305,6 @@ 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/dialogs/katedialogs.cpp b/src/dialogs/katedialogs.cpp --- a/src/dialogs/katedialogs.cpp +++ b/src/dialogs/katedialogs.cpp @@ -94,9 +94,6 @@ #include #include -// trailing slash is important -#define HLDOWNLOADPATH QStringLiteral("http://kate.kde.org/syntax/") - //END //BEGIN KateIndentConfigTab @@ -1056,168 +1053,6 @@ //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("Note: 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/mode/katemodeconfigpage.h b/src/mode/katemodeconfigpage.h --- a/src/mode/katemodeconfigpage.h +++ b/src/mode/katemodeconfigpage.h @@ -54,7 +54,6 @@ void typeChanged(int type); void showMTDlg(); void save(); - void hlDownload(); private: Ui::FileTypeConfigWidget *ui; diff --git a/src/mode/katemodeconfigpage.cpp b/src/mode/katemodeconfigpage.cpp --- a/src/mode/katemodeconfigpage.cpp +++ b/src/mode/katemodeconfigpage.cpp @@ -75,7 +75,6 @@ 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::hlDownload() -{ - KateHlDownloadDialog diag(this, "hlDownload", true); - diag.exec(); -} - QString ModeConfigPage::name() const { return i18n("Modes && Filetypes");