mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-24 10:52:51 +00:00
kate: remove non-operational feature to download highlight files
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
e9e8bddd9b
commit
0271c00f24
5 changed files with 0 additions and 211 deletions
|
@ -111,9 +111,6 @@
|
||||||
#include <QtGui/qevent.h>
|
#include <QtGui/qevent.h>
|
||||||
#include <QtXml/qdom.h>
|
#include <QtXml/qdom.h>
|
||||||
|
|
||||||
// trailing slash is important
|
|
||||||
#define HLDOWNLOADPATH "http://kate.kde.org/syntax/"
|
|
||||||
|
|
||||||
//END
|
//END
|
||||||
|
|
||||||
//BEGIN KateConfigPage
|
//BEGIN KateConfigPage
|
||||||
|
@ -990,160 +987,6 @@ void KatePartPluginConfigPage::defaults ()
|
||||||
}
|
}
|
||||||
//END KatePartPluginConfigPage
|
//END KatePartPluginConfigPage
|
||||||
|
|
||||||
|
|
||||||
//BEGIN KateHlDownloadDialog
|
|
||||||
KateHlDownloadDialog::KateHlDownloadDialog(QWidget *parent, const char *name, bool modal)
|
|
||||||
: KDialog( parent )
|
|
||||||
{
|
|
||||||
setCaption( i18n("Highlight Download") );
|
|
||||||
setButtons( User1 | Close );
|
|
||||||
setButtonGuiItem( User1, KGuiItem(i18n("&Install")) );
|
|
||||||
setDefaultButton( User1 );
|
|
||||||
setObjectName( name );
|
|
||||||
setModal( modal );
|
|
||||||
|
|
||||||
KVBox* vbox = new KVBox(this);
|
|
||||||
setMainWidget(vbox);
|
|
||||||
vbox->setSpacing(-1);
|
|
||||||
new QLabel(i18n("Select the syntax highlighting files you want to update:"), vbox);
|
|
||||||
list = new QTreeWidget(vbox);
|
|
||||||
list->setColumnCount(4);
|
|
||||||
list->setHeaderLabels(QStringList() << "" << i18n("Name") << i18n("Installed") << i18n("Latest"));
|
|
||||||
list->setSelectionMode(QAbstractItemView::MultiSelection);
|
|
||||||
list->setAllColumnsShowFocus(true);
|
|
||||||
list->setRootIsDecorated(false);
|
|
||||||
list->setColumnWidth(0, 22);
|
|
||||||
|
|
||||||
new QLabel(i18n("<b>Note:</b> New versions are selected automatically."), vbox);
|
|
||||||
setButtonIcon(User1, KIcon("dialog-ok"));
|
|
||||||
|
|
||||||
transferJob = KIO::get(
|
|
||||||
KUrl(QString(HLDOWNLOADPATH)
|
|
||||||
+ QString("update-")
|
|
||||||
+ KateGlobal::katePartVersion()
|
|
||||||
+ QString(".xml")), 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);
|
|
||||||
connect(this,SIGNAL(user1Clicked()),this,SLOT(slotUser1()));
|
|
||||||
}
|
|
||||||
|
|
||||||
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("."))
|
|
||||||
{
|
|
||||||
vn[idx++] = n.toUInt();
|
|
||||||
if (idx == sizeof(vn))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return KDE_MAKE_VERSION(vn[0], vn[1], vn[2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void KateHlDownloadDialog::listDataReceived(KIO::Job *, const QByteArray &data)
|
|
||||||
{
|
|
||||||
if (!transferJob || transferJob->error() != 0)
|
|
||||||
{
|
|
||||||
enableButton( User1, false );
|
|
||||||
if (data.size()==0)
|
|
||||||
KMessageBox::error(this,i18n("The list of highlightings could not be found on / retrieved from the server"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
listData+=QString(data);
|
|
||||||
kDebug(13000)<<QString("CurrentListData: ")<<listData;
|
|
||||||
kDebug(13000)<<QString("Data length: %1").arg(data.size());
|
|
||||||
kDebug(13000)<<QString("listData length: %1").arg(listData.length());
|
|
||||||
if (data.size()==0)
|
|
||||||
{
|
|
||||||
if (listData.length()>0)
|
|
||||||
{
|
|
||||||
QString installedVersion;
|
|
||||||
KateHlManager *hlm=KateHlManager::self();
|
|
||||||
QDomDocument doc;
|
|
||||||
doc.setContent(listData);
|
|
||||||
QDomElement DocElem=doc.documentElement();
|
|
||||||
QDomNode n=DocElem.firstChild();
|
|
||||||
KateHighlighting *hl = 0;
|
|
||||||
|
|
||||||
if (n.isNull()) kDebug(13000)<<"There is no usable childnode";
|
|
||||||
while (!n.isNull())
|
|
||||||
{
|
|
||||||
installedVersion=" --";
|
|
||||||
|
|
||||||
QDomElement e=n.toElement();
|
|
||||||
if (!e.isNull())
|
|
||||||
kDebug(13000)<<QString("NAME: ")<<e.tagName()<<QString(" - ")<<e.attribute("name");
|
|
||||||
n=n.nextSibling();
|
|
||||||
|
|
||||||
QString Name=e.attribute("name");
|
|
||||||
|
|
||||||
for (int i=0;i<hlm->highlights();i++)
|
|
||||||
{
|
|
||||||
hl=hlm->getHl(i);
|
|
||||||
if (hl && hl->name()==Name)
|
|
||||||
{
|
|
||||||
installedVersion=" "+hl->version();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else hl = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// autoselect entry if new or updated.
|
|
||||||
QTreeWidgetItem* entry = new QTreeWidgetItem(list);
|
|
||||||
entry->setText(0, "");
|
|
||||||
entry->setText(1, e.attribute("name"));
|
|
||||||
entry->setText(2, installedVersion);
|
|
||||||
entry->setText(3, e.attribute("version"));
|
|
||||||
entry->setText(4, e.attribute("url"));
|
|
||||||
|
|
||||||
bool is_fresh = false;
|
|
||||||
if (hl)
|
|
||||||
{
|
|
||||||
unsigned prev_version = parseVersion(hl->version());
|
|
||||||
unsigned next_version = parseVersion(e.attribute("version"));
|
|
||||||
is_fresh = prev_version < next_version;
|
|
||||||
}
|
|
||||||
else is_fresh = true;
|
|
||||||
if (is_fresh)
|
|
||||||
{
|
|
||||||
entry->treeWidget()->setItemSelected(entry, true);
|
|
||||||
entry->setIcon(0, SmallIcon(("get-hot-new-stuff")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
list->resizeColumnToContents(1);
|
|
||||||
list->sortItems(1, Qt::AscendingOrder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void KateHlDownloadDialog::slotUser1()
|
|
||||||
{
|
|
||||||
QString destdir=KGlobal::dirs()->saveLocation("data","katepart/syntax/");
|
|
||||||
foreach (QTreeWidgetItem *it, list->selectedItems())
|
|
||||||
{
|
|
||||||
KUrl src(it->text(4));
|
|
||||||
QString filename=src.fileName(KUrl::ObeyTrailingSlash);
|
|
||||||
QString dest = destdir+filename;
|
|
||||||
|
|
||||||
KIO::NetAccess::download(src,dest, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// update Config !!
|
|
||||||
// this rewrites the cache....
|
|
||||||
KateSyntaxDocument doc (KateHlManager::self()->getKConfig(), true);
|
|
||||||
}
|
|
||||||
//END KateHlDownloadDialog
|
|
||||||
|
|
||||||
//BEGIN KateGotoBar
|
//BEGIN KateGotoBar
|
||||||
KateGotoBar::KateGotoBar(KTextEditor::View *view, QWidget *parent)
|
KateGotoBar::KateGotoBar(KTextEditor::View *view, QWidget *parent)
|
||||||
: KateViewBarWidget( true, parent )
|
: KateViewBarWidget( true, parent )
|
||||||
|
|
|
@ -341,28 +341,6 @@ class KatePartPluginConfigPage : public KateConfigPage
|
||||||
QList<KPluginInfo> plugins;
|
QList<KPluginInfo> plugins;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class KateHlDownloadDialog: public KDialog
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
|
||||||
void listDataReceived(KIO::Job *, const QByteArray &data);
|
|
||||||
|
|
||||||
public Q_SLOTS:
|
|
||||||
void slotUser1();
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This dialog will prompt the user for what do with a file that is
|
* This dialog will prompt the user for what do with a file that is
|
||||||
* modified on disk.
|
* modified on disk.
|
||||||
|
|
|
@ -211,30 +211,6 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
<item>
|
||||||
<spacer>
|
<spacer>
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|
|
@ -87,7 +87,6 @@ ModeConfigPage::ModeConfigPage( QWidget *parent )
|
||||||
connect( ui->btnDelete, SIGNAL(clicked()), this, SLOT(deleteType()) );
|
connect( ui->btnDelete, SIGNAL(clicked()), this, SLOT(deleteType()) );
|
||||||
ui->btnMimeTypes->setIcon(KIcon("tools-wizard"));
|
ui->btnMimeTypes->setIcon(KIcon("tools-wizard"));
|
||||||
connect(ui->btnMimeTypes, SIGNAL(clicked()), this, SLOT(showMTDlg()));
|
connect(ui->btnMimeTypes, SIGNAL(clicked()), this, SLOT(showMTDlg()));
|
||||||
connect( ui->btnDownload, SIGNAL(clicked()), this, SLOT(hlDownload()) );
|
|
||||||
|
|
||||||
reload();
|
reload();
|
||||||
|
|
||||||
|
@ -311,10 +310,4 @@ void ModeConfigPage::showMTDlg()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModeConfigPage::hlDownload()
|
|
||||||
{
|
|
||||||
KateHlDownloadDialog diag(this,"hlDownload",true);
|
|
||||||
diag.exec();
|
|
||||||
}
|
|
||||||
|
|
||||||
// kate: space-indent on; indent-width 2; replace-tabs on;
|
// kate: space-indent on; indent-width 2; replace-tabs on;
|
||||||
|
|
|
@ -56,7 +56,6 @@ class ModeConfigPage : public KateConfigPage
|
||||||
void typeChanged (int type);
|
void typeChanged (int type);
|
||||||
void showMTDlg();
|
void showMTDlg();
|
||||||
void save ();
|
void save ();
|
||||||
void hlDownload ();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::FileTypeConfigWidget *ui;
|
Ui::FileTypeConfigWidget *ui;
|
||||||
|
|
Loading…
Add table
Reference in a new issue