From 84da08d7b7fcda12c85caeb5a10b4903770a6f69 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeaddons@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kate/snippets/CWidgetSnippetsBase.ui | 214 ++++++++++++++++++++++ kate/snippets/CWidgetSnippetsBase.ui.h | 28 +++ kate/snippets/Makefile.am | 17 ++ kate/snippets/csnippet.cpp | 17 ++ kate/snippets/csnippet.h | 39 ++++ kate/snippets/cwidgetsnippets.cpp | 22 +++ kate/snippets/cwidgetsnippets.h | 26 +++ kate/snippets/katesnippets.desktop | 101 +++++++++++ kate/snippets/plugin_katesnippets.cpp | 321 +++++++++++++++++++++++++++++++++ kate/snippets/plugin_katesnippets.h | 78 ++++++++ kate/snippets/plugin_katesnippets.rc | 11 ++ 11 files changed, 874 insertions(+) create mode 100644 kate/snippets/CWidgetSnippetsBase.ui create mode 100644 kate/snippets/CWidgetSnippetsBase.ui.h create mode 100644 kate/snippets/Makefile.am create mode 100644 kate/snippets/csnippet.cpp create mode 100644 kate/snippets/csnippet.h create mode 100644 kate/snippets/cwidgetsnippets.cpp create mode 100644 kate/snippets/cwidgetsnippets.h create mode 100644 kate/snippets/katesnippets.desktop create mode 100644 kate/snippets/plugin_katesnippets.cpp create mode 100644 kate/snippets/plugin_katesnippets.h create mode 100644 kate/snippets/plugin_katesnippets.rc (limited to 'kate/snippets') diff --git a/kate/snippets/CWidgetSnippetsBase.ui b/kate/snippets/CWidgetSnippetsBase.ui new file mode 100644 index 0000000..7f370f9 --- /dev/null +++ b/kate/snippets/CWidgetSnippetsBase.ui @@ -0,0 +1,214 @@ + +CWidgetSnippetsBase + + + CWidgetSnippetsBase + + + true + + + + 0 + 0 + 531 + 740 + + + + Snippets + Snippets for Kate + + + image0 + + + + unnamed + + + 0 + + + + splitter13 + + + Vertical + + + + + Snippet + + + true + + + false + + + + lvSnippets + + + 13 + + + false + + + 2 + + + 0 + + + Manual + + + true + + + true + + + true + + + AllColumns + + + 20 + + + Accept + + + A list of Snippets + + + A list of Snippets, what else + + + + + layout24 + + + + unnamed + + + 0 + + + + layout11 + + + + unnamed + + + 0 + + + + btnNew + + + + + + image1 + + + + + btnSave + + + + + + image2 + + + + + btnDelete + + + + + + image3 + + + + + spacer1_2 + + + Horizontal + + + Expanding + + + + 200 + 20 + + + + + + + + teSnippetText + + + true + + + PlainText + + + false + + + + + + + + + + 789c7dd4476fdb401005e0bb7e05e1bd19c158ec5c0439b897b8c9dd0e725816c94d6e926b90ff9ed9d9478a0e83686d409fe6f189c2aeb430ef9dedef78f30bbdc9d44caf0aafb8344fde7cf93c1ebffff8f9ed576fcecf3cfe4b032f98fbd29b1b4cbdc2dbbdbfab2c4831545f1ee2657196e8c488f7acfd7e52c21bb5d3d05a0dad031debc8cd2bebd00fb2c0f5ddc2057ce49cf9995c4f191cc363b10efb8116dfc111bcef9ce92c177fb78efcc6723f9189faa12f367004af386b5f47e2dc3a0e78eefa3f9cb5d685f8596c1a3f582781f18dbbfe526ce2129fffcab99917700cbf58a761e2c7b219740f6bb86cecfaa67089f9b538e7fd707eb7cec2348697600df71b4b9faae0fafa35715ecf6913aef73b74ce7ce4d71bbbf9161ca39fac75d4cc0f60cce9acb63b3fb4036b78575c6465eaf6f3d059fb706c9d470656aa36cecf051c637f13d8c0917511e709f6f35c5ce606fba3adcb38aff3a9739118c92b533b77f347715504e85b84eb7e1fae70bd9c878ab7af28c5396c9ce9585c9549ee1cc006ef770a57452c7eb21e268d4f9cab007d03980f9078049b52beffaaac5d25327f150f9bebb79d8701e66f8dddefc7044ee055d80c5dfe06e687fbf121e5d6603a5b64289fbde67e97a8a092aad9ab9c18d2882e3bb92bbaa61bba95d631dd71e686d77d27f7c07d765271ea919e68229a7672cfd267d70be75ee94d9ebfd7f74d0ab90ff4d98ec5a66f89df7ff9536e057dabb4d6ea5be7dcc65fb99233139e6fb6fab63a7ddfb96f9bd788765a7dbbecbd4fb97dee1bd180d741abefb0d377c47dc77442a77486be73fe14179dfbb3c93ef91450c87d1167624a28edf4d995f167d5fc44d19a322a57852a3fdf5f730eb85355dc75c4d7d4ffcbed5c93ccd49067aabbeadcec6cfd7bcd72ff4fb673ed64fbc4ca79f9fdb5f707a32dabb2 + + + 789c5dd24b6fe2301000e03bbf222237b4a22d2259a2d51e80044a5b28ed69a5d51efc248f8600061a5aed7fdf8cc793a28da3c8df783cb623dff4bc5feba5d7bbe998233b66c213293b783d792acbcbef3f3f3f3bddbbd06bde61f3ed7eeb74fb9ef056d55641bf6cfafe773e0a2201fc20b221903b46c87720139c09093c00f990281c1592116500f42da51820f78e21f20c148160d2ee6ae6a8904f9692b824aa10b846ca018e268e218ec64019105347867c6969e7be5a2a1add39ba85b29636b940aa01b202aa6619e485a8eddc8d23436a4b45cc1d15f204d421718bd403ad8147475759b5b4a3c65247c1ed2db0768c9013a408915347869448cdb0d4d851df8d808fc48001e7c47000bc278e38f08118d99bb320727b375644bc2acf44bc0c6f44dc46bf797c868d377d8a89e6dfeb4d9a09fe15f3a554f9a6c87c9f7fe5bd2995e75956f2925fe76df36a97ee0f25c58c39aafc541467f68e79a6eed7469a3abf6467dfffb07f773c31e3b1998e4d9ccc667b9737bf5f2c1e1eeb2c4de2a7a5ab67a6abe78929b2348de3f575debc866012ff576f97256d1eacab4d5d14e94b1c5fedafaa8a62f7dad68373e41a826d3d88c139a975fffee8fc0371b41110 + + + 789c5dd44b53db301007f07b3e8507df980e58b625dbd3e9018815de2101c2a3d3c35a9209818400e1d9e9776f76572a505fe2df7f572b3913677d353a3f3a8856d73b8f0b585c9bc88ce1215ab54fd3e9dbcf5f3f7e7756848a4411a93c122bdf3a2b6b91890eef660eeff5f23e4ee84296c4322905b1468a44e4a244a6c43270e059328f9169224c46bbec11abb44c2be433321359921113642e322353e41911f25211f3c0b2413aa6945c554899caa4c89085a764021164c5cde61f0129032b83cc3c2d3346aa545a6ebe662ac13c0ce4e67d22280939b2f2acf8cca7815c1d228bac10406b0f884d219923cfaaa1e62d4fcb7c419659e011b3148d4576894d29993b9e15731b59e5953012f9ee29991744132890b0fca20dadbd241a00663fd052f32bb2c9c1311f988d62be116d03967e66b748231bc79c324dea1472e2a9988f441b78efe9980ba495069863a64d1d4d7ef254cc19d105ce3d817917d8d2a82b4fc7d50da453d66f74eee9b8f984e9fcbebd40ae369e8ab9ebe9d75aa20bd54d4f7f8c1b64dbb6d0b6c8d6b365aef92bf69f9f3268ccffd9f271daf86b06576e39ca7ccee2f135cd8f3f329898f6864213b2f8763a89db9bd9dd6c7e1f73060fb7f03831f78ba7f9fcf9855fa1d737b0307e8f9b8dcde7ad6e4d7f3253e8f51ad8de31bb7bfb0775975e266d7bfd9e85a3adc170587779deb19e9ff47b7d189e8eea33edf7d5fabc777139381cd589d6da9f4febbe48b351adf547b60c07b9acd5976c19eed485fe9aade9b2c2009ff7cff7ce5fcf2134c0 + + + 789c5dd1514fdb301007f0f77e8aa879aba6423b9a0d211e70431b284c7b44427b70ec334e89db244da165da77c7e7b393322791fcf3fd7d4e94b351f4f4fb311a9d0d762d6f0b1109cd9b6824f7c61c9fff5cff1d0c274964ef8bf36832fc36188e2311fdda6e00e78d9dc73fbeff9c5c0ae4bb631e283c67c41b2417792224f20d995f04724f20e68172868c1d65e09628a6c4bd6742fc408a99e0c47947f7ceb79e405c38cac07ba29c12d3404890779e09551f02a9aa917216987972e2c61388b52304161d5d67438429f188842470e59910db40e55abd7872a27204e0142e03a95a7902f1405453e22b52d96394422e89a1baebe8aae0991099a33ab703b9262a4e55e9a988e371cce31c1f31c6416bf68f817ad10517fd5a2cd7f05a9a4dbc155f725555178d68c4696e57b5b5debfbd9fe60e87a3f9e0377d8e31bbb9652c8e9b2eb766ac2c199bcff77d0e76cc0e9dde2efa7eb0ac18cbb2bb74f15faec8749af6fda0c4bdb5d6f77d6ec9d8cad8dd0fbaefc7586b4c6d4f39c955ed6a658acc36ecfae17786cbaefdbb1a7c029001f396 + + + + CWidgetSnippetsBase.ui.h + + + lalala() + + + init() + + + insertItem( const QString& name, bool bRename ) + + + diff --git a/kate/snippets/CWidgetSnippetsBase.ui.h b/kate/snippets/CWidgetSnippetsBase.ui.h new file mode 100644 index 0000000..816d7d8 --- /dev/null +++ b/kate/snippets/CWidgetSnippetsBase.ui.h @@ -0,0 +1,28 @@ +/**************************************************************************** +** ui.h extension file, included from the uic-generated form implementation. +** +** If you wish to add, delete or rename functions or slots use +** Qt Designer which will update this file, preserving your code. Create an +** init() function in place of a constructor, and a destroy() function in +** place of a destructor. +*****************************************************************************/ + + + +void CWidgetSnippetsBase::init() +{ + +} + + +QListViewItem* CWidgetSnippetsBase::insertItem( const QString& name, bool bRename ) +{ + QListViewItem *item = new QListViewItem(lvSnippets, name); + item->setRenameEnabled(0,true); + lvSnippets->setSelected( item, true ); + if ( bRename ) { + teSnippetText->clear(); + item->startRename (0); + } + return item; +} diff --git a/kate/snippets/Makefile.am b/kate/snippets/Makefile.am new file mode 100644 index 0000000..23bc3cf --- /dev/null +++ b/kate/snippets/Makefile.am @@ -0,0 +1,17 @@ +INCLUDES = $(all_includes) +METASOURCES = AUTO + +# Install this plugin in the KDE modules directory +kde_module_LTLIBRARIES = katesnippetsplugin.la + +katesnippetsplugin_la_SOURCES = plugin_katesnippets.cpp CWidgetSnippetsBase.ui cwidgetsnippets.h cwidgetsnippets.cpp csnippet.h csnippet.cpp CWidgetSnippetsBase.ui.h +katesnippetsplugin_la_LIBADD = -lkateinterfaces +katesnippetsplugin_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) + +pluginsdir = $(kde_datadir)/kate/plugins/katesnippets +plugins_DATA = plugin_katesnippets.rc + +kde_services_DATA = katesnippets.desktop + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/katesnippets.pot diff --git a/kate/snippets/csnippet.cpp b/kate/snippets/csnippet.cpp new file mode 100644 index 0000000..fc7d7e7 --- /dev/null +++ b/kate/snippets/csnippet.cpp @@ -0,0 +1,17 @@ +/*************************************************************************** + * Copyright (C) 2004 by Stephan Mres * + * Erdling@gmx.net * + * * + * 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. * + ***************************************************************************/ +#include "csnippet.h" + +CSnippet::CSnippet(QString sKey, QString sValue, QListViewItem *lvi, QObject *parent, const char *name) + : QObject(parent, name), _sKey(sKey), _sValue(sValue), _lvi(lvi) {} + +CSnippet::~CSnippet() {} + +#include "csnippet.moc" diff --git a/kate/snippets/csnippet.h b/kate/snippets/csnippet.h new file mode 100644 index 0000000..a139f03 --- /dev/null +++ b/kate/snippets/csnippet.h @@ -0,0 +1,39 @@ +/*************************************************************************** + * Copyright (C) 2004 by Stephan Mres * + * Erdling@gmx.net * + * * + * 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. * + ***************************************************************************/ +#ifndef CSNIPPET_H +#define CSNIPPET_H + +#include +#include +#include +#include + +/** +@author Stephan Mres +*/ + +class CSnippet : public QObject { + Q_OBJECT +public: + CSnippet(QString sKey, QString sValue, QListViewItem *lvi, QObject *parent = 0, const char *name = 0); + ~CSnippet(); + QString getKey() { return _sKey; } + QString getValue() { return _sValue; } + QListViewItem* getListViewItem() const { return _lvi; } + void setKey(const QString& sKey) { _sKey = sKey; } + void setValue(const QString& sValue) { _sValue = sValue; } + +protected: + QString _sKey; + QString _sValue; + QListViewItem *_lvi; +}; + +#endif diff --git a/kate/snippets/cwidgetsnippets.cpp b/kate/snippets/cwidgetsnippets.cpp new file mode 100644 index 0000000..cf44319 --- /dev/null +++ b/kate/snippets/cwidgetsnippets.cpp @@ -0,0 +1,22 @@ +/*************************************************************************** + * Copyright (C) 2004 by Stephan Mres * + * Erdling@gmx.net * + * * + * 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. * + ***************************************************************************/ +#include "cwidgetsnippets.h" + +CWidgetSnippets::CWidgetSnippets( QWidget* parent, const char* name, WFlags fl) + : CWidgetSnippetsBase(parent, name, fl) +{ +} + + +CWidgetSnippets::~CWidgetSnippets() +{ +} + + diff --git a/kate/snippets/cwidgetsnippets.h b/kate/snippets/cwidgetsnippets.h new file mode 100644 index 0000000..6d246c3 --- /dev/null +++ b/kate/snippets/cwidgetsnippets.h @@ -0,0 +1,26 @@ +/*************************************************************************** + * Copyright (C) 2004 by Stephan Mres * + * Erdling@gmx.net * + * * + * 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. * + ***************************************************************************/ +#ifndef CWIDGETSNIPPETS_H +#define CWIDGETSNIPPETS_H + +#include + +/** +@author Stephan Mres +*/ +class CWidgetSnippets : public CWidgetSnippetsBase { +public: + CWidgetSnippets( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + + ~CWidgetSnippets(); + +}; + +#endif diff --git a/kate/snippets/katesnippets.desktop b/kate/snippets/katesnippets.desktop new file mode 100644 index 0000000..4479b06 --- /dev/null +++ b/kate/snippets/katesnippets.desktop @@ -0,0 +1,101 @@ +[Desktop Entry] +Type=Service +ServiceTypes=Kate/Plugin +X-KDE-Library=katesnippetsplugin +X-Kate-Version=2.5 +Name=Kate Snippets +Name[ca]=Retalls del Kate +Name[cs]=Kate útržky +Name[da]=Kate-Stumper +Name[de]=Kate-Schnipsel +Name[el]=Δείγματα Kate +Name[eo]=Erilo por Kodredaktilo +Name[es]=Recorte de Kate +Name[et]=Kate koodijupid +Name[fa]=تکه‌های Kate +Name[fi]=Kate tekstipalat +Name[fr]=Fragments de codes pour Kate +Name[fy]=Kate-fragminten +Name[ga]=Blúirí Kate +Name[gl]=Anacos para Kate +Name[he]=טקעי קוד של Kate +Name[hr]=Kate isječci +Name[hu]=Kate-kódrészletek +Name[is]=Kate úrklippur +Name[it]=Frammenti di testo di Kate +Name[ja]=Kate 定型表現 +Name[ka]=Kate ფრაგმენტები +Name[km]=អត្ថបទ​ខ្លីៗ​របស់ Kate +Name[lt]=Kate teksto fragmentai +Name[mk]=Парчиња за Кате +Name[nb]=Kate-biter +Name[nds]=Kate-Snippets +Name[ne]=केट स्निपेट +Name[nl]=Kate-fragmenten +Name[nn]=Kate-snuttar +Name[pa]=ਕੇਟ ਸਨੇਪਿੱਟ +Name[pl]=Fragmenty kodu dla Kate +Name[pt]=Pedaços do Kate +Name[pt_BR]=Trechos de Código (snippets) do Kate +Name[ru]=Фрагменты текста Kate +Name[sk]=Kate štipka +Name[sl]=Odsek za Kate +Name[sr]=Исечци за Kate +Name[sr@Latn]=Isečci za Kate +Name[sv]=Kate-snuttar +Name[ta]=கேட் சிறுகுறிப்புகள் +Name[tr]=Kate Parçacıkları +Name[uk]=Kate-Snippets +Name[vi]=Đoạn Kate +Name[zh_CN]=Kate 段 +Comment=Configurable Text-Snippets for Kate +Comment[bg]=Потребителски текстови пасажи за Kate +Comment[ca]=Retalls de text configurables per al Kate +Comment[cs]=Nastavitelné textové útržky v Kate +Comment[da]=Indstillelige tekststumper for Kate +Comment[de]=Konfigurierbare Textschnipsel für Kate +Comment[el]=Ρυθμιζόμενα δείγματα κειμένου για το Kate +Comment[eo]=Agordeblaj tekseroj por Kodredaktilo +Comment[es]=Recortes de texto para Kate +Comment[et]=Kate seadistatavad tekstijupid +Comment[eu]=Text-Snippets konfiguragarria Katerako +Comment[fa]=تکه‌های متن قابل پیکربندی برای Kate +Comment[fi]=Aseteltavia tekstipaloja Kateen +Comment[fr]=Fragments de codes configurables pour Kate +Comment[fy]=Ynstelbere tekstfragminten foar Kate +Comment[ga]=Blúirí Inchumraithe Téacs do Kate +Comment[gl]=Pedazos de Texto Configurábeis para Kate +Comment[he]=הגדרת קטעי קוד עבור Kate +Comment[hi]=केएटीई हेतु कॉन्फ़िगर करने योग्य टैक्स्ट-स्निपेट्स +Comment[hr]=Konfigurabilni tekstualni isječci za Kate +Comment[hu]=Beállítható szövegrészletek a Kate-hez +Comment[is]=Stillanlegar texta úrklippur fyrir Kate +Comment[it]=Frammenti di testo configurabili per Kate +Comment[ja]=よく使う表現を登録しておきます +Comment[ka]=კონფიგურირებადი ტექსტის ფრაგმენტები Kate-სთვის +Comment[kk]=Бапталатын Kate мәтін-фрагменттері +Comment[km]=អត្ថបទ​ខ្លីៗ​​ដែល​អាច​កំណត់​រចនា​សម្ព័ន្ធ​បាន​សម្រាប់ Kate +Comment[lt]=Konfigūruoti Kate teksto fragmentų priedą +Comment[mk]=Конфигурабилни парчиња текст за Кате +Comment[ms]=Teks-Snippets boleh konfigur untuk Kate +Comment[nb]=Innstillbare tekstbiter til Kate +Comment[nds]=Instellbor Textsnippels för Kate +Comment[ne]=केटका लागि कन्फिगर योग्य पाठ- खण्ड +Comment[nl]=Instelbare tekstfragmenten voor Kate +Comment[nn]=Tilpassbare tekstsnuttar til Kate +Comment[pl]=Konfigurowalne fragmenty kodu dla Kate +Comment[pt]=Pedaços de Texto Configuráveis para o Kate +Comment[pt_BR]=Snippets configuráveis para o Kate +Comment[ru]=Настраиваемые фрагменты текста для Kate +Comment[sk]=Konfigurovateľná textová štipka pre Kate +Comment[sl]=nastavljivi besedilni odseki za Kate +Comment[sr]=Подесиви исечци текста за Kate +Comment[sr@Latn]=Podesivi isečci teksta za Kate +Comment[sv]=Anpassningsbara textsnuttar för Kate +Comment[ta]=வடிவமைக்கக்கூடிய கேட்டுக்கான உரை-குறிப்புகள் +Comment[tr]=Kate için Yapılandırılabilir Kod Parçacıkları +Comment[uk]=Текстові уривки для Kate, які можна налаштовувати +Comment[vi]=Đoạn văn bản có thể cấu hình cho Kate +Comment[zh_CN]=可配置的 Kate 文本段 +Comment[zh_TW]=設定 Kate Text-Snippets +author=Stephan Möres, Erdling@gmx.net diff --git a/kate/snippets/plugin_katesnippets.cpp b/kate/snippets/plugin_katesnippets.cpp new file mode 100644 index 0000000..07cba2b --- /dev/null +++ b/kate/snippets/plugin_katesnippets.cpp @@ -0,0 +1,321 @@ +/* + * Copyright (C) 2004 Stephan Mres + */ + +#include "plugin_katesnippets.h" + +#include +#include +#include +#include + + +// let the world know ... +K_EXPORT_COMPONENT_FACTORY(katesnippetsplugin, KGenericFactory( "katesnippets" ) ) + + +// < IMPLEMENTAIONS for KatePluginSnippetsView > +// +// + +/** + * ctor KatePluginSnippetsView + * @param w + * @return + */ +KatePluginSnippetsView::KatePluginSnippetsView(Kate::MainWindow *w, QWidget *dock) : CWidgetSnippets(dock,"snippetswidget") + , dock (dock) +{ + setInstance (new KInstance("kate")); + setXMLFile("plugins/katesnippets/plugin_katesnippets.rc"); + + w->guiFactory()->addClient (this); + win = w; + + + // + connect ( + lvSnippets, SIGNAL( selectionChanged(QListViewItem *) ), + this, SLOT( slot_lvSnippetsSelectionChanged(QListViewItem *) ) + ); + connect ( + lvSnippets, SIGNAL( doubleClicked (QListViewItem *) ), + this, SLOT( slot_lvSnippetsClicked(QListViewItem *) ) + ); + connect ( + lvSnippets, SIGNAL( itemRenamed(QListViewItem *, int, const QString &) ), + this, SLOT( slot_lvSnippetsItemRenamed(QListViewItem *, int, const QString &) ) + ); + + connect ( + btnNew, SIGNAL( clicked () ), + this, SLOT( slot_btnNewClicked() ) + ); + connect ( + btnSave, SIGNAL( clicked () ), + this, SLOT( slot_btnSaveClicked() ) + ); + connect ( + btnDelete, SIGNAL( clicked () ), + this, SLOT( slot_btnDeleteClicked() ) + ); + // + + lSnippets.setAutoDelete( TRUE ); // the list owns the objects + + config = new KConfig("katesnippetspluginrc"); + readConfig(); + + // set text of selected item at startup + slot_lvSnippetsSelectionChanged(lvSnippets->selectedItem() ); +} + + +/** + * dtor KatePluginSnippetsView + * @return + */ +KatePluginSnippetsView::~ KatePluginSnippetsView() { + writeConfig(); + + win->guiFactory()->removeClient(this); +} + + +// +// +// < IMPLEMENTAIONS for KatePluginSnippetsView > + + + + +// < IMPLEMENTAIONS for KatePluginSnippets > +// +// + +/** + * ctor KatePluginSnippets + * @param parent + * @param name + * @return + */ +KatePluginSnippets::KatePluginSnippets( QObject* parent, const char* name, const QStringList& ) + : Kate::Plugin ( (Kate::Application*)parent, name ) {} + +/** + * dtor KatePluginSnippets + * @return + */ +KatePluginSnippets::~KatePluginSnippets() {} + +/** + * + * @param win + */ +void KatePluginSnippets::addView(Kate::MainWindow *win) +{ + QWidget *dock = win->toolViewManager()->createToolView( + "kate_plugin_snippets", + Kate::ToolViewManager::Left, + SmallIcon("contents"), + i18n("Snippets")); + + KatePluginSnippetsView *view = new KatePluginSnippetsView (win,dock); + m_views.append(view); +} + + +/** + * + * @param win + */ +void KatePluginSnippets::removeView(Kate::MainWindow *win) { + for (uint z=0; z < m_views.count(); z++) + if (m_views.at(z)->win == win) { + KatePluginSnippetsView *view = m_views.at(z); + m_views.remove (view); + delete view->dock; + } +} + +/** + * + * @param item + */ +void KatePluginSnippetsView::slot_lvSnippetsSelectionChanged(QListViewItem * item) { + CSnippet *snippet; + if ( (snippet = findSnippetByListViewItem(item))!= NULL ) { + teSnippetText->setText(snippet->getValue()); + } + +} + + +/** + * Special meaning of and ... + * @param item + */ +void KatePluginSnippetsView::slot_lvSnippetsClicked (QListViewItem * item) { + Kate::View *kv = win->viewManager()->activeView(); + CSnippet *snippet; + + if (kv) { + if ( (snippet = findSnippetByListViewItem(item))!= NULL ) { + QString sText = snippet->getValue(); + QString sSelection = ""; + + if ( kv->getDoc()->hasSelection() ) { + sSelection = kv->getDoc()->selection(); + // clear selection + kv->keyDelete(); + } + + sText.replace( QRegExp(""), sSelection ); + sText.replace( QRegExp(""), QDate::currentDate().toString(Qt::LocalDate) ); + sText.replace( QRegExp("