summaryrefslogtreecommitdiffstats
path: root/parts/snippet
diff options
context:
space:
mode:
Diffstat (limited to 'parts/snippet')
-rw-r--r--parts/snippet/COPYING340
-rw-r--r--parts/snippet/Makefile.am17
-rw-r--r--parts/snippet/README3
-rw-r--r--parts/snippet/README.dox16
-rw-r--r--parts/snippet/kdevpart_snippet.rc8
-rw-r--r--parts/snippet/kdevsnippet.desktop102
-rw-r--r--parts/snippet/snippet_part.cpp155
-rw-r--r--parts/snippet/snippet_part.h50
-rw-r--r--parts/snippet/snippet_widget.cpp970
-rw-r--r--parts/snippet/snippet_widget.h90
-rw-r--r--parts/snippet/snippetconfig.cpp20
-rw-r--r--parts/snippet/snippetconfig.h56
-rw-r--r--parts/snippet/snippetdlg.ui214
-rw-r--r--parts/snippet/snippetdlg.ui.h21
-rw-r--r--parts/snippet/snippetitem.cpp127
-rw-r--r--parts/snippet/snippetitem.h70
-rw-r--r--parts/snippet/snippetsettings.cpp52
-rw-r--r--parts/snippet/snippetsettings.h41
-rw-r--r--parts/snippet/snippetsettingsbase.ui228
19 files changed, 2580 insertions, 0 deletions
diff --git a/parts/snippet/COPYING b/parts/snippet/COPYING
new file mode 100644
index 00000000..5b6e7c66
--- /dev/null
+++ b/parts/snippet/COPYING
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/parts/snippet/Makefile.am b/parts/snippet/Makefile.am
new file mode 100644
index 00000000..10ad8b0d
--- /dev/null
+++ b/parts/snippet/Makefile.am
@@ -0,0 +1,17 @@
+INCLUDES = -I$(top_srcdir)/lib/interfaces -I$(top_srcdir)/lib/util $(all_includes)
+
+kde_module_LTLIBRARIES = libkdevsnippet.la
+libkdevsnippet_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN)
+libkdevsnippet_la_LIBADD = $(top_builddir)/lib/libkdevelop.la
+
+libkdevsnippet_la_SOURCES = snippet_part.cpp snippet_widget.cpp snippetdlg.ui snippetitem.cpp snippetsettingsbase.ui snippetsettings.cpp snippetconfig.cpp
+
+METASOURCES = AUTO
+
+servicedir = $(kde_servicesdir)
+service_DATA = kdevsnippet.desktop
+
+rc_DATA = kdevpart_snippet.rc
+rcdir = $(kde_datadir)/kdevsnippet
+
+noinst_HEADERS = snippetdlg.h snippetitem.h snippetsettingsbase.h snippetsettings.h snippetconfig.h
diff --git a/parts/snippet/README b/parts/snippet/README
new file mode 100644
index 00000000..731741e1
--- /dev/null
+++ b/parts/snippet/README
@@ -0,0 +1,3 @@
+Please read the on-line, automaticaly updated KDevelop API documentation at:
+http://www.kdevelop.org
+or read the README.dox file.
diff --git a/parts/snippet/README.dox b/parts/snippet/README.dox
new file mode 100644
index 00000000..4d5d80de
--- /dev/null
+++ b/parts/snippet/README.dox
@@ -0,0 +1,16 @@
+/** \class SnippetPart
+This plugin provides a tool view for CodeSnippets which can be easily inserted into any KDevelop sourcecode file.
+
+\authors <a href="mailto:rgruber@users.sourceforge.net">Robert Gruber</a>
+
+\maintainer <a href="mailto:rgruber@users.sourceforge.net">Robert Gruber</a>
+
+\feature Provides a tooltree view for easy access to your CodeSnippets
+\feature You can use variables in Snippets
+\feature Tooltips show the content of the snippets
+\feature Snippets are saved based on the user who created them
+
+\requirement KDE >= 3.1.3
+
+\todo Add features
+*/
diff --git a/parts/snippet/kdevpart_snippet.rc b/parts/snippet/kdevpart_snippet.rc
new file mode 100644
index 00000000..4f34ec50
--- /dev/null
+++ b/parts/snippet/kdevpart_snippet.rc
@@ -0,0 +1,8 @@
+<!DOCTYPE kpartgui>
+<kpartplugin name="snippet" library="libkdevsnippet" version="3">
+ <MenuBar>
+ </MenuBar>
+ <Menu name="hidden">
+ <Action name="snippet_showview"/>
+ </Menu>
+</kpartplugin>
diff --git a/parts/snippet/kdevsnippet.desktop b/parts/snippet/kdevsnippet.desktop
new file mode 100644
index 00000000..481f4559
--- /dev/null
+++ b/parts/snippet/kdevsnippet.desktop
@@ -0,0 +1,102 @@
+[Desktop Entry]
+Type=Service
+Exec=
+Comment=This plugin allows you to store code snippets and add them to your code
+Comment[ca]=Aquest connector permet guardar trossos de codi i afegir-los més tard al vostre codi
+Comment[da]=Dette plugin tillader dig at opbevare kodestumper og tilføje dem til din kode
+Comment[de]=Dieses Modul erlaubt das Abspeichern und Wiederverwenden von Quelltext-Schnipseln
+Comment[el]=Αυτό το πρόσθετο σας επιτρέπει να αποθηκεύσετε δείγματα κώδικα και να τα προσθέσετε στον κώδικά σας
+Comment[es]=Este complemento permite almacenar trozos de código y añadirlos a su código fuente
+Comment[et]=See plugin võimaldab salvestada koodijuppe ja neid koodi lisada
+Comment[eu]=Plugin honek kode zatiak gordetzeo eta zure kodeari gehitzeko aukera eskeintzen dizu
+Comment[fa]=این وصله، اجازۀ ذخیرۀ تکه‌های کد و افزودن آنها را به کدتان می‌دهد
+Comment[fr]=Ce module externe permet de stocker des fragments de code et de les ajouter à votre code
+Comment[gl]=Esta extensión permite almacenar fragmentos de código e engadilos ao seu código
+Comment[hu]=Ez a modul kódrészletek eltárolását és programkódba való beillesztését teszi lehetővé
+Comment[it]=Questo plugin consente di memorizzare frammenti di codice e di aggiungerli al tuo codice
+Comment[ja]=このプラグインはコード断片を格納し、あなたのコードにそれらを加えることを可能にします。
+Comment[ms]=Plugin ini membenarkan anda untuk menyimpan petikan kod dan menambahkannya ke dalam kod anda
+Comment[nds]=Dit Moduul stellt dat Sekern un Tofögen vun Kode-Snippels praat.
+Comment[ne]=यो प्लगइनले तपाईँलाई सङ्केत स्निपेट्स भण्डारण गर्न र तपाईँको सङ्केतमा तिनीहरूलाई थप्न अनुमति दिन्छ
+Comment[nl]=Deze plugin staat u toe om tekstblokken op te slaan en deze toe te voegen aan uw code
+Comment[pl]=Wtyczka umożliwiająca zapisanie fragmentów kodu i wstawianie ich później do kodu
+Comment[pt]=Este 'plugin' permite-lhe guardar pedaços de códigos e adicioná-los ao seu código
+Comment[pt_BR]=Este plug-in permite a você armazenar os pedaços de código e adicioná-los em seu código
+Comment[ru]=Модуль сохранения часто используемых частей кода в одно место для быстрого доступа к ним
+Comment[sk]=Modul umožní uložiť si výňatky kódu a ich vkladať
+Comment[sr]=Овај прикључак вам омогућава да чувате исечке кôда и додајете их у сопствени кôд
+Comment[sr@Latn]=Ovaj priključak vam omogućava da čuvate isečke kôda i dodajete ih u sopstveni kôd
+Comment[sv]=Det här insticksprogrammet gör det möjligt att lagra kodsnuttar och lägga till dem i din kod
+Comment[ta]=இந்த உள்ளீடுகள் ஸ்னிப்பட் குறியீடுகளை சேமிக்கவும் மற்றும் அக்குறியீட்டை சேர்க்கவும் வழிவகுக்கிறது
+Comment[tg]=Нигоҳ дории модул баъзан истифодашавии як қисми код дар як ҷой барои зуд роҳ гирифтан ба он ҷо
+Comment[tr]=Bu eklenti kod parçalarını saklamanızı ve onları kodunuza eklemenizi sağlar
+Comment[zh_CN]=这个插件允许您保存代码片段并将这些片段插入到您的代码中
+Comment[zh_TW]=此外掛程式讓您儲存程式碼片段,並可以加入您的程式碼中
+Name=Code Snippets
+Name[ca]=Trossos de codi
+Name[da]=Kodestumper
+Name[de]=Quelltext-Schnipsel
+Name[el]=Δείγματα κώδικα
+Name[es]=Trozos de código
+Name[et]=Koodijupid
+Name[eu]=Kode zatiak
+Name[fa]=تکه‌های کد
+Name[fr]=Fragments de code
+Name[ga]=Blúirí Cóid
+Name[hu]=Kódrészletek
+Name[it]=Frammenti di codice
+Name[ja]=コード Snippet
+Name[ms]=Petikan Kod
+Name[nds]=Kode-Snippels
+Name[ne]=सङ्केत स्निपेट्स
+Name[pl]=Fragmenty kodu
+Name[pt]=Pedaços de Código
+Name[pt_BR]=Pedaços de Código
+Name[ru]=Заготовки кода
+Name[sk]=Výňatky kódu
+Name[sl]=Odseki kode
+Name[sv]=Kodsnuttar
+Name[ta]=ஸ்னிப்பட் குறியீடுகள்
+Name[tg]=Тайёр намудани код
+Name[tr]=Kod Parçacıkları
+Name[zh_CN]=代码片段
+Name[zh_TW]=程式碼片段
+GenericName=Code Snippets
+GenericName[ca]=Trossos de codi
+GenericName[da]=Kodestumper
+GenericName[de]=Quelltext-Schnipsel
+GenericName[el]=Δείγματα κώδικα
+GenericName[es]=Trozos de código
+GenericName[et]=Koodijupid
+GenericName[eu]=Kode zatiak
+GenericName[fa]=تکه‌های کد
+GenericName[fr]=Fragments de code
+GenericName[ga]=Blúirí Cóid
+GenericName[gl]=Fragmentos de código
+GenericName[hu]=Kódrészletek
+GenericName[it]=Frammenti di codice
+GenericName[ja]=コード Snippet
+GenericName[ms]=Petikan Kod
+GenericName[nds]=Kode-Snippels
+GenericName[ne]=सङ्केत स्निपेट्स
+GenericName[nl]=Tekstblokken
+GenericName[pl]=Fragmenty kodu
+GenericName[pt]=Pedaços de Código
+GenericName[pt_BR]=Pedaços de código
+GenericName[ru]=Заготовки кода
+GenericName[sk]=Výňatky kódu
+GenericName[sl]=Odseki kode
+GenericName[sr]=Исечци кôда
+GenericName[sr@Latn]=Isečci kôda
+GenericName[sv]=Kodsnuttar
+GenericName[ta]=ஸ்ப்பட் குறியீடு
+GenericName[tg]=Тайёр намудани кодҳо
+GenericName[tr]=Kod Parçacıkları
+GenericName[zh_CN]=代码片段
+GenericName[zh_TW]=程式碼片段
+Icon=editcut
+ServiceTypes=KDevelop/Plugin
+X-KDevelop-Scope=Global
+X-KDE-Library=libkdevsnippet
+X-KDevelop-Version=5
+X-KDevelop-Properties=CodeEditing
diff --git a/parts/snippet/snippet_part.cpp b/parts/snippet/snippet_part.cpp
new file mode 100644
index 00000000..f7564109
--- /dev/null
+++ b/parts/snippet/snippet_part.cpp
@@ -0,0 +1,155 @@
+/*
+ * File : snippet_part.cpp
+ *
+ * Author: Robert Gruber <rgruber@users.sourceforge.net>
+ *
+ * Copyright: See COPYING file that comes with this distribution
+ */
+#include "snippet_part.h"
+
+#include <qwhatsthis.h>
+
+#include <kaction.h>
+#include <kiconloader.h>
+#include <klocale.h>
+#include <kaboutdata.h>
+#include <qvbox.h>
+#include <kdialogbase.h>
+#include <klineedit.h>
+#include <qcheckbox.h>
+#include <qbuttongroup.h>
+#include <ktrader.h>
+
+#include "kdevcore.h"
+#include <kdevproject.h>
+#include "kdevmainwindow.h"
+#include <kdevgenericfactory.h>
+#include <kdevplugininfo.h>
+
+#include <kdebug.h>
+
+#include "snippet_widget.h"
+#include "snippetitem.h"
+#include "snippetsettings.h"
+#include "snippetconfig.h"
+
+static const KDevPluginInfo data("kdevsnippet");
+typedef KDevGenericFactory<SnippetPart> snippetFactory;
+K_EXPORT_COMPONENT_FACTORY( libkdevsnippet, snippetFactory( data ) )
+
+SnippetPart::SnippetPart(QObject *parent, const char *name, const QStringList& )
+ : KDevPlugin(&data, parent, name ? name : "SnippetPart" )
+{
+ setInstance(snippetFactory::instance());
+ setXMLFile("kdevpart_snippet.rc");
+
+ m_widget = new SnippetWidget(this);
+ m_widget->setCaption(i18n("Code Snippets"));
+ m_widget->setIcon(SmallIcon( info()->icon() ));
+
+ QWhatsThis::add(m_widget, i18n("<b>Code Snippet</b><p>This is a list of available snippets."));
+
+ mainWindow()->embedSelectViewRight( m_widget, i18n("Code Snippets"), i18n("Insert a code snippet") );
+
+ connect( core(), SIGNAL( configWidget( KDialogBase * ) ), this, SLOT( slotConfigWidget( KDialogBase * ) ) );
+
+ /*The next two connects are used to check if certain SnippetGroups need to be opened
+ according to the languages supported by this project*/
+ connect( core(), SIGNAL( projectOpened() ), m_widget, SLOT( languageChanged() ) );
+ connect( core(), SIGNAL( languageChanged() ), m_widget, SLOT( languageChanged() ) );
+
+ setupActions();
+}
+
+SnippetPart::~SnippetPart()
+{
+ if ( m_widget )
+ {
+ mainWindow()->removeView( m_widget );
+ }
+
+ delete m_widget;
+}
+
+void SnippetPart::setupActions()
+{
+ new KAction( i18n("Show Snippet Tree"), CTRL+ALT+SHIFT+Key_S, this, SLOT(slotShowView()), actionCollection(), "snippet_showview");
+}
+
+/*!
+ \fn SnippetPart::aboutData()
+ */
+KAboutData* SnippetPart::aboutData()
+{
+ KAboutData *data = new KAboutData ("snippetpart", I18N_NOOP("SnippetPart"), "1.1",
+ I18N_NOOP( "SnippetPart for KDevelop" ),
+ KAboutData::License_LGPL_V2,
+ I18N_NOOP( "(c) 2003" ), 0, "http://www.kdevelop.org");
+ data->addAuthor ("Robert Gruber", I18N_NOOP("Author"), "rgruber@users.sourceforge.net", "http://kmp3indexer.sf.net");
+
+
+ return data;
+}
+
+
+/*!
+ \fn SnippetPart::slotConfigWidget( KDialogBase *dlg )
+ */
+void SnippetPart::slotConfigWidget( KDialogBase *dlg )
+{
+ QVBox *vbox = dlg->addVBoxPage( i18n("Code Snippets"), i18n("Code Snippets"), BarIcon( info()->icon(), KIcon::SizeMedium ) );
+
+ SnippetSettings * w = new SnippetSettings( m_widget, vbox );
+
+ w->btnGroup->setButton(m_widget->getSnippetConfig()->getInputMethod());
+ w->leDelimiter->setText(m_widget->getSnippetConfig()->getDelimiter());
+ w->cbToolTip->setChecked(m_widget->getSnippetConfig()->useToolTips());
+ w->btnGroupAutoOpen->setButton(m_widget->getSnippetConfig()->getAutoOpenGroups());
+ connect( dlg, SIGNAL(okClicked()), w, SLOT(slotOKClicked()) );
+}
+
+
+QStringList SnippetPart::getAllLanguages()
+{
+ KTrader::OfferList languageSupportOffers =
+ KTrader::self()->query(QString::fromLatin1("KDevelop/LanguageSupport"),
+ QString::fromLatin1("[X-KDevelop-Version] == %1"
+ ).arg( KDEVELOP_PLUGIN_VERSION ));
+
+ QStringList languages;
+
+ for (KTrader::OfferList::ConstIterator it = languageSupportOffers.begin(); it != languageSupportOffers.end(); ++it)
+ {
+ QString language = (*it)->property("X-KDevelop-Language").toString();
+ languages.append(language);
+
+ kdDebug(9035) << "Found language: " << (*it)->property("X-KDevelop-Language").toString() << endl <<
+ "genericName(): " <<(*it)->genericName() << endl <<
+ "comment(): " <<(*it)->comment() << endl << endl;
+ }
+
+ return languages;
+}
+
+
+QStringList SnippetPart::getProjectLanguages()
+{
+ QStringList languages;
+ if (!projectDom())
+ return languages;
+
+ QDomDocument m_projectDom = *projectDom();
+
+ if (m_widget->getSnippetConfig()->getAutoOpenGroups() == 1)
+ languages = DomUtil::readListEntry(m_projectDom, "/general/secondaryLanguages", "language");
+ languages.prepend( DomUtil::readEntry(m_projectDom, "/general/primarylanguage") );
+ return languages;
+}
+
+void SnippetPart::slotShowView()
+{
+ mainWindow()->raiseView( m_widget );
+}
+
+
+#include "snippet_part.moc"
diff --git a/parts/snippet/snippet_part.h b/parts/snippet/snippet_part.h
new file mode 100644
index 00000000..98c3b252
--- /dev/null
+++ b/parts/snippet/snippet_part.h
@@ -0,0 +1,50 @@
+/*
+ * File : snippet_part.h
+ *
+ * Author: Robert Gruber <rgruber@users.sourceforge.net>
+ *
+ * Copyright: See COPYING file that comes with this distribution
+ */
+
+
+#ifndef __KDEVPART_SNIPPET_H__
+#define __KDEVPART_SNIPPET_H__
+
+
+#include <qguardedptr.h>
+#include <kdevplugin.h>
+
+
+class SnippetWidget;
+class KAboutData;
+class KDialogBase;
+
+/*
+This is the KDevPlugin for the CodeSnippet feature
+For more info read the README.dox file
+@author Robert Gruber
+*/
+class SnippetPart : public KDevPlugin
+{
+ Q_OBJECT
+
+public:
+
+ SnippetPart(QObject *parent, const char *name, const QStringList &);
+ ~SnippetPart();
+ KAboutData * aboutData();
+ QStringList getAllLanguages();
+ QStringList getProjectLanguages();
+
+private:
+ void setupActions();
+
+ QGuardedPtr<SnippetWidget> m_widget;
+
+public slots:
+ void slotConfigWidget( KDialogBase *dlg );
+ void slotShowView();
+};
+
+
+#endif
diff --git a/parts/snippet/snippet_widget.cpp b/parts/snippet/snippet_widget.cpp
new file mode 100644
index 00000000..98d61505
--- /dev/null
+++ b/parts/snippet/snippet_widget.cpp
@@ -0,0 +1,970 @@
+/*
+ * File : snippet_widget.cpp
+ *
+ * Author: Robert Gruber <rgruber@users.sourceforge.net>
+ *
+ * Copyright: See COPYING file that comes with this distribution
+ */
+
+#include <kparts/part.h>
+#include <klibloader.h>
+#include <kurl.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <qlayout.h>
+#include <kpushbutton.h>
+#include <klistview.h>
+#include <qheader.h>
+#include <klineedit.h>
+#include <ktextedit.h>
+#include <kmessagebox.h>
+#include <qsplitter.h>
+#include <ktexteditor/editinterface.h>
+#include <ktexteditor/editor.h>
+#include <ktexteditor/viewcursorinterface.h>
+#include <ktexteditor/document.h>
+#include <kconfig.h>
+#include <qtooltip.h>
+#include <kpopupmenu.h>
+#include <qregexp.h>
+#include <qinputdialog.h>
+#include <qlabel.h>
+#include <qcheckbox.h>
+#include <qwhatsthis.h>
+#include <qdragobject.h>
+#include <qtimer.h>
+#include <kcombobox.h>
+#include <kdeversion.h>
+
+#include <kdevcore.h>
+#include <kdevproject.h>
+#include <kdevpartcontroller.h>
+
+#include "snippetdlg.h"
+#include "snippetitem.h"
+
+#include "snippet_part.h"
+#include "snippet_widget.h"
+
+SnippetWidget::SnippetWidget(SnippetPart *part)
+ : KListView(0, "snippet widget"), QToolTip( viewport() ),
+ m_part( part )
+{
+ // init the QPtrList
+ _list.setAutoDelete(TRUE);
+
+ // init the KListView
+ setSorting( -1 );
+ addColumn( "" );
+ setFullWidth(true);
+ header()->hide();
+ setAcceptDrops(true);
+ setDragEnabled(false);
+ setDropVisualizer(false);
+ setRootIsDecorated(true);
+
+ //connect the signals
+ connect( this, SIGNAL( contextMenuRequested ( QListViewItem *, const QPoint & , int ) ),
+ this, SLOT( showPopupMenu(QListViewItem *, const QPoint & , int ) ) );
+
+ connect( this, SIGNAL( executed (QListViewItem *) ),
+ this, SLOT( slotExecuted( QListViewItem *) ) );
+ connect( this, SIGNAL( returnPressed (QListViewItem *) ),
+ this, SLOT( slotExecuted( QListViewItem *) ) );
+
+ connect( this, SIGNAL( dropped(QDropEvent *, QListViewItem *) ),
+ this, SLOT( slotDropped(QDropEvent *, QListViewItem *) ) );
+
+ _cfg = 0;
+
+ QTimer::singleShot(0, this, SLOT(initConfig()));
+}
+
+SnippetWidget::~SnippetWidget()
+{
+ writeConfig();
+ delete _cfg;
+
+ /* We need to delete the child items before the parent items
+ otherwise KDevelop would crash on exiting */
+ SnippetItem * item;
+ while (_list.count() > 0) {
+ for (item=_list.first(); item; item=_list.next()) {
+ if (item->childCount() == 0)
+ _list.remove(item);
+ }
+ }
+}
+
+
+/*!
+ \fn SnippetWidget::slotAdd()
+ Opens the didalog to add a snippet
+ */
+void SnippetWidget::slotAdd()
+{
+ kdDebug(9035) << "Ender slotAdd()" << endl;
+ SnippetDlg dlg(this, "SnippetDlg", true);
+
+ /*check if the user clicked a SnippetGroup
+ If not, we set the group variable to the SnippetGroup
+ which the selected item is a child of*/
+ SnippetGroup * group = dynamic_cast<SnippetGroup*>(selectedItem());
+ if (!group)
+ group = dynamic_cast<SnippetGroup*>(selectedItem()->parent());
+
+ /*fill the combobox with the names of all SnippetGroup entries*/
+ for (SnippetItem *it=_list.first(); it; it=_list.next()) {
+ if (dynamic_cast<SnippetGroup*>(it)) {
+ dlg.cbGroup->insertItem(it->getName());
+ }
+ }
+ dlg.cbGroup->setCurrentText(group->getName());
+
+ if (dlg.exec() == QDialog::Accepted) {
+ group = dynamic_cast<SnippetGroup*>(SnippetItem::findItemByName(dlg.cbGroup->currentText(), _list));
+ _list.append( new SnippetItem(group, dlg.snippetName->text(), dlg.snippetText->text()) );
+ }
+}
+
+
+/*!
+ \fn SnippetWidget::slotAddGroup()
+ Opens the didalog to add a snippet
+ */
+void SnippetWidget::slotAddGroup()
+{
+ kdDebug(9035) << "Ender slotAddGroup()" << endl;
+ SnippetDlg dlg(this, "SnippetDlg", true);
+ dlg.snippetText->setEnabled(false);
+ dlg.snippetText->setText("GROUP");
+ dlg.setCaption(i18n("Add Group"));
+ dlg.cbGroup->insertItem(i18n("All"));
+ dlg.cbGroup->insertStringList(m_part->getAllLanguages());
+ dlg.cbGroup->setCurrentText(i18n("All"));
+ dlg.textLabelGroup->setText(i18n("Language:"));
+
+ if (dlg.exec() == QDialog::Accepted) {
+ _list.append( new SnippetGroup(this, dlg.snippetName->text(), SnippetGroup::getMaxId(), dlg.cbGroup->currentText()) );
+ }
+}
+
+
+/*!
+ \fn SnippetWidget::slotRemove()
+ Removes the selected snippet
+ */
+void SnippetWidget::slotRemove()
+{
+ //get current data
+ QListViewItem * item = currentItem();
+ SnippetItem *snip = dynamic_cast<SnippetItem*>( item );
+ SnippetGroup *group = dynamic_cast<SnippetGroup*>( item );
+ if (!snip)
+ return;
+
+ if (group) {
+ if (group->childCount() > 0 &&
+ KMessageBox::warningContinueCancel(this, i18n("Do you really want to remove this group and all its snippets?"),QString::null,KStdGuiItem::del())
+ == KMessageBox::Cancel)
+ return;
+
+ for (SnippetItem *it=_list.first(); it; it=_list.next()) {
+ if (it->getParent() == group->getId()) {
+ kdDebug(9035) << "remove " << it->getName() << endl;
+ _list.remove(it);
+ }
+ }
+ }
+
+ kdDebug(9035) << "remove " << snip->getName() << endl;
+ _list.remove(snip);
+}
+
+
+
+/*!
+ \fn SnippetWidget::slotEdit()
+ Opens the dialog of editing the selected snippet
+ */
+void SnippetWidget::slotEdit()
+{
+ //get current data
+ QListViewItem * item = currentItem();
+
+ SnippetGroup *pGroup = dynamic_cast<SnippetGroup*>(item);
+ SnippetItem *pSnippet = dynamic_cast<SnippetItem*>( item );
+ if (!pSnippet || pGroup) /*selected item must be a SnippetItem but MUST not be a SnippetGroup*/
+ return;
+
+ //init the dialog
+ SnippetDlg dlg(this, "SnippetDlg", true);
+ dlg.snippetName->setText(pSnippet->getName());
+ dlg.snippetText->setText(pSnippet->getText());
+ dlg.btnAdd->setText(i18n("&Apply"));
+
+ dlg.setCaption(i18n("Edit Snippet"));
+ /*fill the combobox with the names of all SnippetGroup entries*/
+ for (SnippetItem *it=_list.first(); it; it=_list.next()) {
+ if (dynamic_cast<SnippetGroup*>(it)) {
+ dlg.cbGroup->insertItem(it->getName());
+ }
+ }
+ dlg.cbGroup->setCurrentText(SnippetItem::findGroupById(pSnippet->getParent(), _list)->getName());
+
+ if (dlg.exec() == QDialog::Accepted) {
+ //update the KListView and the SnippetItem
+ item->setText( 0, dlg.snippetName->text() );
+ pSnippet->setName( dlg.snippetName->text() );
+ pSnippet->setText( dlg.snippetText->text() );
+
+ /* if the user changed the parent we need to move the snippet */
+ if ( SnippetItem::findGroupById(pSnippet->getParent(), _list)->getName() != dlg.cbGroup->currentText() ) {
+ SnippetGroup * newGroup = dynamic_cast<SnippetGroup*>(SnippetItem::findItemByName(dlg.cbGroup->currentText(), _list));
+ pSnippet->parent()->takeItem(pSnippet);
+ newGroup->insertItem(pSnippet);
+ pSnippet->resetParent();
+ }
+
+ setSelected(item, TRUE);
+ }
+}
+
+/*!
+ \fn SnippetWidget::slotEditGroup()
+ Opens the dialog of editing the selected snippet-group
+ */
+void SnippetWidget::slotEditGroup()
+{
+ //get current data
+ QListViewItem * item = currentItem();
+
+ SnippetGroup *pGroup = dynamic_cast<SnippetGroup*>( item );
+ if (!pGroup) /*selected item MUST be a SnippetGroup*/
+ return;
+
+ //init the dialog
+ SnippetDlg dlg(this, "SnippetDlg", true);
+ dlg.snippetName->setText(pGroup->getName());
+ dlg.snippetText->setText(pGroup->getText());
+ dlg.btnAdd->setText(i18n("&Apply"));
+ dlg.snippetText->setEnabled(FALSE);
+ dlg.setCaption(i18n("Edit Group"));
+ dlg.cbGroup->insertItem(i18n("All"));
+ dlg.cbGroup->insertStringList(m_part->getAllLanguages());
+ dlg.cbGroup->setCurrentText(pGroup->getLanguage());
+ dlg.textLabelGroup->setText(i18n("Language:"));
+
+ if (dlg.exec() == QDialog::Accepted) {
+ //update the KListView and the SnippetGroup
+ item->setText( 0, dlg.snippetName->text() );
+ pGroup->setName( dlg.snippetName->text() );
+ pGroup->setLanguage(dlg.cbGroup->currentText());
+
+ setSelected(item, TRUE);
+ }
+}
+
+void SnippetWidget::slotExecuted(QListViewItem * item)
+{
+ SnippetItem *pSnippet = dynamic_cast<SnippetItem*>( item );
+ if (!pSnippet || dynamic_cast<SnippetGroup*>(item))
+ return;
+
+ //process variables if any, then insert into the active view
+ insertIntoActiveView( parseText(pSnippet->getText(), _SnippetConfig.getDelimiter()) );
+}
+
+
+/*!
+ \fn SnippetWidget::insertIntoActiveView(QString text)
+ Inserts the parameter text into the activ view
+ */
+void SnippetWidget::insertIntoActiveView(QString text)
+{
+ //get the interfaces for the KTexteditor parts
+ KTextEditor::ViewCursorInterface *cursorIface
+ = dynamic_cast<KTextEditor::ViewCursorInterface*>(m_part->partController()->activeWidget());
+
+ if (!cursorIface)
+ return;
+
+ KTextEditor::EditInterface* editIface
+ = dynamic_cast<KTextEditor::EditInterface*>( m_part->partController()->activePart() );
+
+ if (!editIface)
+ return;
+
+ uint line, col;
+ cursorIface->cursorPositionReal(&line, &col);
+
+ editIface->insertText( line, col , text );
+}
+
+
+/*!
+ \fn SnippetWidget::writeConfig()
+ Write the cofig file
+ */
+void SnippetWidget::writeConfig()
+{
+ if( !_cfg )
+ return;
+ _cfg->deleteGroup("SnippetPart"); //this is neccessary otherwise delete entries will stay in list until
+ //they get overwritten by a more recent entry
+ _cfg->setGroup("SnippetPart");
+
+ SnippetItem *item;
+ QString strKeyName="";
+ QString strKeyText="";
+ QString strKeyId="";
+
+ int iSnipCount = 0;
+ int iGroupCount = 0;
+
+ for ( item = _list.first(); item; item = _list.next() ) { //write the snippet-list
+ kdDebug(9035) << "SnippetWidget::writeConfig() " << item->getName() << endl;
+ SnippetGroup * group = dynamic_cast<SnippetGroup*>(item);
+ if (group) {
+ kdDebug(9035) << "-->GROUP " << item->getName() << group->getId() << " " << iGroupCount<< endl;
+ strKeyName=QString("snippetGroupName_%1").arg(iGroupCount);
+ strKeyId=QString("snippetGroupId_%1").arg(iGroupCount);
+ strKeyText=QString("snippetGroupLang_%1").arg(iGroupCount);
+
+ _cfg->writeEntry(strKeyName, group->getName());
+ _cfg->writeEntry(strKeyId, group->getId());
+ _cfg->writeEntry(strKeyText, group->getLanguage());
+ iGroupCount++;
+ } else if (dynamic_cast<SnippetItem*>(item)) {
+ kdDebug(9035) << "-->ITEM " << item->getName() << item->getParent() << " " << iSnipCount << endl;
+ strKeyName=QString("snippetName_%1").arg(iSnipCount);
+ strKeyText=QString("snippetText_%1").arg(iSnipCount);
+ strKeyId=QString("snippetParent_%1").arg(iSnipCount);
+
+ _cfg->writeEntry(strKeyName, item->getName());
+ _cfg->writeEntry(strKeyText, item->getText());
+ _cfg->writeEntry(strKeyId, item->getParent());
+ iSnipCount++;
+ } else {
+ kdDebug(9035) << "-->ERROR " << item->getName() << endl;
+ }
+ }
+ _cfg->writeEntry("snippetCount", iSnipCount);
+ _cfg->writeEntry("snippetGroupCount", iGroupCount);
+
+ int iCount = 1;
+ QMap<QString, QString>::Iterator it;
+ for ( it = _mapSaved.begin(); it != _mapSaved.end(); ++it ) { //write the saved variable values
+ if (it.data().length()<=0) continue; //is the saved value has no length -> no need to save it
+
+ strKeyName=QString("snippetSavedName_%1").arg(iCount);
+ strKeyText=QString("snippetSavedVal_%1").arg(iCount);
+
+ _cfg->writeEntry(strKeyName, it.key());
+ _cfg->writeEntry(strKeyText, it.data());
+
+ iCount++;
+ }
+ _cfg->writeEntry("snippetSavedCount", iCount-1);
+
+
+ _cfg->writeEntry( "snippetDelimiter", _SnippetConfig.getDelimiter() );
+ _cfg->writeEntry( "snippetVarInput", _SnippetConfig.getInputMethod() );
+ _cfg->writeEntry( "snippetToolTips", _SnippetConfig.useToolTips() );
+ _cfg->writeEntry( "snippetGroupAutoOpen", _SnippetConfig.getAutoOpenGroups() );
+
+ _cfg->writeEntry("snippetSingleRect", _SnippetConfig.getSingleRect() );
+ _cfg->writeEntry("snippetMultiRect", _SnippetConfig.getMultiRect() );
+
+ _cfg->sync();
+}
+
+
+/*!
+ This function was introduced together with the grouping-feature.
+ As far as some guys might have some snippets stored in the "old" way
+ we need to create a "DEFAULT" group into which we can import all snippets
+ */
+void SnippetWidget::initConfigOldVersion(KConfig *cfg)
+{
+ SnippetGroup * group = new SnippetGroup(this, "DEFAULT", 1);
+ _list.append(group);
+
+ int iCount = cfg->readNumEntry("snippetCount", 0);
+ QString strKeyName="";
+ QString strKeyText="";
+ for ( int i=0; i<iCount; i++) { //read the snippet-list
+ strKeyName=QString("snippetName_%1").arg(i);
+ strKeyText=QString("snippetText_%1").arg(i);
+
+ QString strNameVal="";
+ QString strTextVal="";
+
+ strNameVal = cfg->readEntry(strKeyName, "");
+ strTextVal = cfg->readEntry(strKeyText, "");
+
+ if (strNameVal != "" && strTextVal != "") {
+ SnippetItem * item = new SnippetItem(group, strNameVal, strTextVal);
+ _list.append(item);
+ }
+ }
+}
+
+
+/*!
+ \fn SnippetWidget::initConfig()
+ Initial read the cofig file
+ */
+void SnippetWidget::initConfig()
+{
+ if (_cfg == NULL)
+ _cfg = new KConfig("kdevsnippetrc", false, false);
+
+ _cfg->setGroup("SnippetPart");
+
+ QString strKeyName="";
+ QString strKeyText="";
+ QString strKeyId="";
+ SnippetItem *item;
+ SnippetGroup *group;
+
+ kdDebug(9035) << "SnippetWidget::initConfig() " << endl;
+
+ //if entry doesn't get found, this will return -1 which we will need a bit later
+ int iCount = _cfg->readNumEntry("snippetGroupCount", -1);
+
+ for ( int i=0; i<iCount; i++) { //read the group-list
+ strKeyName=QString("snippetGroupName_%1").arg(i);
+ strKeyId=QString("snippetGroupId_%1").arg(i);
+ strKeyText=QString("snippetGroupLang_%1").arg(i);
+
+ QString strNameVal="";
+ int iIdVal=-1;
+ QString strLangVal="";
+
+ strNameVal = _cfg->readEntry(strKeyName, "");
+ iIdVal = _cfg->readNumEntry(strKeyId, -1);
+ strLangVal = _cfg->readEntry(strKeyText, i18n("All"));
+ kdDebug(9035) << "Read group " << strNameVal << " " << iIdVal << endl;
+
+ if (strNameVal != "" && iIdVal != -1 && strLangVal != "") {
+ group = new SnippetGroup(this, strNameVal, iIdVal, strLangVal);
+ kdDebug(9035) << "Created group " << group->getName() << " " << group->getId() << endl;
+ _list.append(group);
+ if (group->getLanguage() == i18n("All"))
+ group->setOpen(TRUE);
+ else
+ group->setOpen(FALSE); //groups assigned to certain languages get handled later
+ }
+ }
+
+ /* Check if the snippetGroupCount property has been found
+ if iCount is -1 this means, that the user has his snippets
+ stored without groups. Therefore we will call the
+ initConfigOldVersion() function below */
+ if (iCount != -1) {
+ iCount = _cfg->readNumEntry("snippetCount", 0);
+ for ( int i=0; i<iCount; i++) { //read the snippet-list
+ strKeyName=QString("snippetName_%1").arg(i);
+ strKeyText=QString("snippetText_%1").arg(i);
+ strKeyId=QString("snippetParent_%1").arg(i);
+
+ QString strNameVal="";
+ QString strTextVal="";
+ int iParentVal = -1;
+
+ strNameVal = _cfg->readEntry(strKeyName, "");
+ strTextVal = _cfg->readEntry(strKeyText, "");
+ iParentVal = _cfg->readNumEntry(strKeyId, -1);
+ kdDebug(9035) << "Read item " << strNameVal << " " << iParentVal << endl;
+
+ if (strNameVal != "" && strTextVal != "" && iParentVal != -1) {
+ item = new SnippetItem(SnippetItem::findGroupById(iParentVal, _list), strNameVal, strTextVal);
+ kdDebug(9035) << "Created item " << item->getName() << " " << item->getParent() << endl;
+ _list.append(item);
+ }
+ }
+ } else {
+ kdDebug(9035) << "found old version of snippet-configfile" << endl;
+ initConfigOldVersion(_cfg);
+ }
+
+ iCount = _cfg->readNumEntry("snippetSavedCount", 0);
+
+ for ( int i=1; i<=iCount; i++) { //read the saved-values and store in QMap
+ strKeyName=QString("snippetSavedName_%1").arg(i);
+ strKeyText=QString("snippetSavedVal_%1").arg(i);
+
+ QString strNameVal="";
+ QString strTextVal="";
+
+ strNameVal = _cfg->readEntry(strKeyName, "");
+ strTextVal = _cfg->readEntry(strKeyText, "");
+
+ if (strNameVal != "" && strTextVal != "") {
+ _mapSaved[strNameVal] = strTextVal;
+ }
+ }
+
+
+ _SnippetConfig.setDelimiter( _cfg->readEntry("snippetDelimiter", "$") );
+ _SnippetConfig.setInputMethod( _cfg->readNumEntry("snippetVarInput", 0) );
+ _SnippetConfig.setToolTips( _cfg->readBoolEntry("snippetToolTips", true) );
+ _SnippetConfig.setAutoOpenGroups( _cfg->readNumEntry("snippetGroupAutoOpen", 1) );
+
+ _SnippetConfig.setSingleRect( _cfg->readRectEntry("snippetSingleRect", 0L) );
+ _SnippetConfig.setMultiRect( _cfg->readRectEntry("snippetMultiRect", 0L) );
+}
+
+/*!
+ \fn SnippetWidget::maybeTip( const QPoint & p )
+ Shows the Snippet-Text as ToolTip
+ */
+void SnippetWidget::maybeTip( const QPoint & p )
+{
+ SnippetItem * item = dynamic_cast<SnippetItem*>( itemAt( p ) );
+ if (!item)
+ return;
+
+ QRect r = itemRect( item );
+
+ if (r.isValid() &&
+ _SnippetConfig.useToolTips() )
+ {
+ if (dynamic_cast<SnippetGroup*>(item)) {
+ tip( r, i18n("Language:")+((SnippetGroup*)item)->getLanguage() ); //show the group's language
+ } else {
+ tip( r, item->getText() ); //show the snippet's text
+ }
+ }
+}
+
+/*!
+ \fn SnippetWidget::showPopupMenu( QListViewItem * item, const QPoint & p, int )
+ Shows the Popup-Menu depending item is a valid pointer
+*/
+void SnippetWidget::showPopupMenu( QListViewItem * item, const QPoint & p, int )
+{
+ KPopupMenu popup;
+
+ SnippetItem * selectedItem = static_cast<SnippetItem *>(item);
+ if ( item ) {
+ popup.insertTitle( selectedItem->getName() );
+
+ popup.insertItem( i18n("Add Item..."), this, SLOT( slotAdd() ) );
+ popup.insertItem( i18n("Add Group..."), this, SLOT( slotAddGroup() ) );
+ if (dynamic_cast<SnippetGroup*>(item)) {
+ popup.insertItem( i18n("Edit..."), this, SLOT( slotEditGroup() ) );
+ } else {
+ popup.insertItem( i18n("Edit..."), this, SLOT( slotEdit() ) );
+ }
+ popup.insertItem( i18n("Remove"), this, SLOT( slotRemove() ) );
+
+ } else {
+ popup.insertTitle(i18n("Code Snippets"));
+
+ popup.insertItem( i18n("Add Group..."), this, SLOT( slotAddGroup() ) );
+ }
+
+ popup.exec(p);
+}
+
+
+// fn SnippetWidget::parseText(QString text, QString del)
+/*!
+ This function is used to parse the given QString for variables. If found the user will be prompted
+ for a replacement value. It returns the string text with all replacements made
+ */
+QString SnippetWidget::parseText(QString text, QString del)
+{
+ QString str = text;
+ QString strName = "";
+ QString strNew = "";
+ QString strMsg="";
+ int iFound = -1;
+ int iEnd = -1;
+ QMap<QString, QString> mapVar;
+ int iInMeth = _SnippetConfig.getInputMethod();
+ QRect rSingle = _SnippetConfig.getSingleRect();
+ QRect rMulti = _SnippetConfig.getMultiRect();
+
+ do {
+ iFound = text.find(QRegExp("\\"+del+"[A-Za-z-_0-9\\s]*\\"+del), iEnd+1); //find the next variable by this QRegExp
+ if (iFound >= 0) {
+ iEnd = text.find(del, iFound+1)+1;
+ strName = text.mid(iFound, iEnd-iFound);
+
+ if ( strName != del+del ) { //if not doubel-delimiter
+ if (iInMeth == 0) { //if input-method "single" is selected
+ if ( mapVar[strName].length() <= 0 ) { // and not already in map
+ strMsg=i18n("Please enter the value for <b>%1</b>:").arg(strName);
+ strNew = showSingleVarDialog( strName, &_mapSaved, rSingle );
+ if (strNew=="")
+ return ""; //user clicked Cancle
+ } else {
+ continue; //we have already handled this variable
+ }
+ } else {
+ strNew = ""; //for inputmode "multi" just reset new valaue
+ }
+ } else {
+ strNew = del; //if double-delimiter -> replace by single character
+ }
+
+ if (iInMeth == 0) { //if input-method "single" is selected
+ str.replace(strName, strNew);
+ }
+
+ mapVar[strName] = strNew;
+ }
+ } while (iFound != -1);
+
+ if (iInMeth == 1) { //check config, if input-method "multi" is selected
+ int w, bh, oh;
+ w = rMulti.width();
+ bh = rMulti.height();
+ oh = rMulti.top();
+ if (showMultiVarDialog( &mapVar, &_mapSaved, w, bh, oh )) { //generate and show the dialog
+ QMap<QString, QString>::Iterator it;
+ for ( it = mapVar.begin(); it != mapVar.end(); ++it ) { //walk through the map and do the replacement
+ str.replace(it.key(), it.data());
+ }
+ } else {
+ return "";
+ }
+
+ rMulti.setWidth(w); //this is a hack to save the dialog's dimensions in only one QRect
+ rMulti.setHeight(bh);
+ rMulti.setTop(oh);
+ rMulti.setLeft(0);
+ _SnippetConfig.setMultiRect(rMulti);
+ }
+
+ _SnippetConfig.setSingleRect(rSingle);
+
+ return str;
+}
+
+
+// fn SnippetWidget::showMultiVarDialog()
+/*!
+ This function constructs a dialog which contains a label and a linedit for every
+ variable that is stored in the given map except the double-delimiter entry
+ It return true if everything was ok and false if the user hit cancel
+ */
+bool SnippetWidget::showMultiVarDialog(QMap<QString, QString> * map, QMap<QString, QString> * mapSave,
+ int & iWidth, int & iBasicHeight, int & iOneHeight)
+{
+ //if no var -> no need to show
+ if (map->count() == 0)
+ return true;
+
+ //if only var is the double-delimiter -> no need to show
+ QMap<QString, QString>::Iterator it = map->begin();
+ if ( map->count() == 1 && it.data()==_SnippetConfig.getDelimiter()+_SnippetConfig.getDelimiter() )
+ return true;
+
+ QMap<QString, KTextEdit *> mapVar2Te; //this map will help keeping track which TEXTEDIT goes with which variable
+ QMap<QString, QCheckBox *> mapVar2Cb; //this map will help keeping track which CHECKBOX goes with which variable
+
+ // --BEGIN-- building a dynamic dialog
+ QDialog dlg(this);
+ dlg.setCaption(i18n("Enter Values for Variables"));
+
+ QGridLayout * layout = new QGridLayout( &dlg, 1, 1, 11, 6, "layout");
+ QGridLayout * layoutTop = new QGridLayout( 0, 1, 1, 0, 6, "layoutTop");
+ QGridLayout * layoutVar = new QGridLayout( 0, 1, 1, 0, 6, "layoutVar");
+ QGridLayout * layoutBtn = new QGridLayout( 0, 1, 1, 0, 6, "layoutBtn");
+
+ KTextEdit *te = NULL;
+ QLabel * labTop = NULL;
+ QCheckBox * cb = NULL;
+
+ labTop = new QLabel( &dlg, "label" );
+ labTop->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, 0, 0,
+ labTop->sizePolicy().hasHeightForWidth() ) );
+ labTop->setText(i18n("Enter the replacement values for these variables:"));
+ layoutTop->addWidget(labTop, 0, 0);
+ layout->addMultiCellLayout( layoutTop, 0, 0, 0, 1 );
+
+
+ int i = 0; //walk through the variable map and add
+ for ( it = map->begin(); it != map->end(); ++it ) { //a checkbox, a lable and a lineedit to the main layout
+ if (it.key() == _SnippetConfig.getDelimiter() + _SnippetConfig.getDelimiter())
+ continue;
+
+ cb = new QCheckBox( &dlg, "cbVar" );
+ cb->setChecked( FALSE );
+ cb->setText(it.key());
+ layoutVar->addWidget( cb, i ,0, Qt::AlignTop );
+
+ te = new KTextEdit( &dlg, "teVar" );
+ layoutVar->addWidget( te, i, 1, Qt::AlignTop );
+
+ if ((*mapSave)[it.key()].length() > 0) {
+ cb->setChecked( TRUE );
+ te->setText((*mapSave)[it.key()]);
+ }
+
+ mapVar2Te[it.key()] = te;
+ mapVar2Cb[it.key()] = cb;
+
+ QToolTip::add( cb, i18n("Enable this to save the value entered to the right as the default value for this variable") );
+ QWhatsThis::add( cb, i18n("If you enable this option, the value entered to the right will be saved. "
+ "If you use the same variable later, even in another snippet, the value entered to the right "
+ "will be the default value for that variable.") );
+
+ i++;
+ }
+ layout->addMultiCellLayout( layoutVar, 1, 1, 0, 1 );
+
+ KPushButton * btn1 = new KPushButton( &dlg, "pushButton1" );
+ btn1->setText(i18n("&Cancel"));
+ btn1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, 0, 0,
+ btn1->sizePolicy().hasHeightForWidth() ) );
+ layoutBtn->addWidget( btn1, 0, 0 );
+
+ KPushButton * btn2 = new KPushButton( &dlg, "pushButton2" );
+ btn2->setText(i18n("&Apply"));
+ btn2->setDefault( TRUE );
+ btn2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, 0, 0,
+ btn2->sizePolicy().hasHeightForWidth() ) );
+ layoutBtn->addWidget( btn2, 0, 1 );
+
+ layout->addMultiCellLayout( layoutBtn, 2, 2, 0, 1 );
+ // --END-- building a dynamic dialog
+
+ //connect the buttons to the QDialog default slots
+ connect(btn1, SIGNAL(clicked()), &dlg, SLOT(reject()) );
+ connect(btn2, SIGNAL(clicked()), &dlg, SLOT(accept()) );
+
+ //prepare to execute the dialog
+ bool bReturn = false;
+ //resize the textedits
+ if (iWidth > 1) {
+ QRect r = dlg.geometry();
+ r.setHeight(iBasicHeight + iOneHeight*mapVar2Te.count());
+ r.setWidth(iWidth);
+ dlg.setGeometry(r);
+ }
+ if ( i > 0 && // only if there are any variables
+ dlg.exec() == QDialog::Accepted ) {
+
+ QMap<QString, KTextEdit *>::Iterator it2;
+ for ( it2 = mapVar2Te.begin(); it2 != mapVar2Te.end(); ++it2 ) {
+ if (it2.key() == _SnippetConfig.getDelimiter() + _SnippetConfig.getDelimiter())
+ continue;
+ (*map)[it2.key()] = it2.data()->text(); //copy the entered values back to the given map
+
+ if (mapVar2Cb[it2.key()]->isChecked()) //if the checkbox is on; save the values for later
+ (*mapSave)[it2.key()] = it2.data()->text();
+ else
+ (*mapSave).erase(it2.key());
+ }
+ bReturn = true;
+
+ iBasicHeight = dlg.geometry().height() - layoutVar->geometry().height();
+ iOneHeight = layoutVar->geometry().height() / mapVar2Te.count();
+ iWidth = dlg.geometry().width();
+ }
+
+ //do some cleanup
+ QMap<QString, KTextEdit *>::Iterator it1;
+ for (it1 = mapVar2Te.begin(); it1 != mapVar2Te.end(); ++it1)
+ delete it1.data();
+ mapVar2Te.clear();
+ QMap<QString, QCheckBox *>::Iterator it2;
+ for (it2 = mapVar2Cb.begin(); it2 != mapVar2Cb.end(); ++it2)
+ delete it2.data();
+ mapVar2Cb.clear();
+ delete layoutTop;
+ delete layoutVar;
+ delete layoutBtn;
+ delete layout;
+
+ if (i==0) //if nothing happened this means, that there are no variables to translate
+ return true; //.. so just return OK
+
+ return bReturn;
+}
+
+
+// fn SnippetWidget::showSingleVarDialog(QString var, QMap<QString, QString> * mapSave)
+/*!
+ This function constructs a dialog which contains a label and a linedit for the given variable
+ It return either the entered value or an empty string if the user hit cancel
+ */
+QString SnippetWidget::showSingleVarDialog(QString var, QMap<QString, QString> * mapSave, QRect & dlgSize)
+{
+ // --BEGIN-- building a dynamic dialog
+ QDialog dlg(this);
+ dlg.setCaption(i18n("Enter Values for Variables"));
+
+ QGridLayout * layout = new QGridLayout( &dlg, 1, 1, 11, 6, "layout");
+ QGridLayout * layoutTop = new QGridLayout( 0, 1, 1, 0, 6, "layoutTop");
+ QGridLayout * layoutVar = new QGridLayout( 0, 1, 1, 0, 6, "layoutVar");
+ QGridLayout * layoutBtn = new QGridLayout( 0, 2, 1, 0, 6, "layoutBtn");
+
+ KTextEdit *te = NULL;
+ QLabel * labTop = NULL;
+ QCheckBox * cb = NULL;
+
+ labTop = new QLabel( &dlg, "label" );
+ layoutTop->addWidget(labTop, 0, 0);
+ labTop->setText(i18n("Enter the replacement values for %1:").arg( var ));
+ layout->addMultiCellLayout( layoutTop, 0, 0, 0, 1 );
+
+
+ cb = new QCheckBox( &dlg, "cbVar" );
+ cb->setChecked( FALSE );
+ cb->setText(i18n( "Make value &default" ));
+
+ te = new KTextEdit( &dlg, "teVar" );
+ layoutVar->addWidget( te, 0, 1, Qt::AlignTop);
+ layoutVar->addWidget( cb, 1, 1, Qt::AlignTop);
+ if ((*mapSave)[var].length() > 0) {
+ cb->setChecked( TRUE );
+ te->setText((*mapSave)[var]);
+ }
+
+ QToolTip::add( cb, i18n("Enable this to save the value entered to the right as the default value for this variable") );
+ QWhatsThis::add( cb, i18n("If you enable this option, the value entered to the right will be saved. "
+ "If you use the same variable later, even in another snippet, the value entered to the right "
+ "will be the default value for that variable.") );
+
+ layout->addMultiCellLayout( layoutVar, 1, 1, 0, 1 );
+
+ KPushButton * btn1 = new KPushButton( &dlg, "pushButton1" );
+ btn1->setText(i18n("&Cancel"));
+ layoutBtn->addWidget( btn1, 0, 0 );
+
+ KPushButton * btn2 = new KPushButton( &dlg, "pushButton2" );
+ btn2->setText(i18n("&Apply"));
+ btn2->setDefault( TRUE );
+ layoutBtn->addWidget( btn2, 0, 1 );
+
+ layout->addMultiCellLayout( layoutBtn, 2, 2, 0, 1 );
+ te->setFocus();
+ // --END-- building a dynamic dialog
+
+ //connect the buttons to the QDialog default slots
+ connect(btn1, SIGNAL(clicked()), &dlg, SLOT(reject()) );
+ connect(btn2, SIGNAL(clicked()), &dlg, SLOT(accept()) );
+
+ //execute the dialog
+ QString strReturn = "";
+ if (dlgSize.isValid())
+ dlg.setGeometry(dlgSize);
+ if ( dlg.exec() == QDialog::Accepted ) {
+ if (cb->isChecked()) //if the checkbox is on; save the values for later
+ (*mapSave)[var] = te->text();
+ else
+ (*mapSave).erase(var);
+
+ strReturn = te->text(); //copy the entered values back the the given map
+
+ dlgSize = dlg.geometry();
+ }
+
+ //do some cleanup
+ delete cb;
+ delete te;
+ delete labTop;
+ delete btn1;
+ delete btn2;
+ delete layoutTop;
+ delete layoutVar;
+ delete layoutBtn;
+ delete layout;
+
+ return strReturn;
+}
+
+// fn SnippetWidget::acceptDrag (QDropEvent *event) const
+/*!
+ Reimplementation from KListView.
+ Check here if the data the user is about to drop fits our restrictions.
+ We only accept dropps of plaintext, because from the dropped text
+ we will create a snippet.
+ */
+bool SnippetWidget::acceptDrag (QDropEvent *event) const
+{
+ kdDebug(9035) << "Format: " << event->format() << "" << event->pos() << endl;
+
+ QListViewItem * item = itemAt(event->pos());
+
+ if (item &&
+ QString(event->format()).startsWith("text/plain") &&
+ static_cast<SnippetWidget *>(event->source()) != this) {
+ kdDebug(9035) << "returning TRUE " << endl;
+ return TRUE;
+ } else {
+ kdDebug(9035) << "returning FALSE" << endl;
+ event->acceptAction(FALSE);
+ return FALSE;
+ }
+}
+
+// fn SnippetWidget::slotDropped(QDropEvent *e, QListViewItem *after)
+/*!
+ This slot is connected to the dropped signal.
+ If it is emitted, we need to construct a new snippet entry with
+ the data given
+ */
+void SnippetWidget::slotDropped(QDropEvent *e, QListViewItem *)
+{
+ QListViewItem * item2 = itemAt(e->pos());
+
+ SnippetGroup *group = dynamic_cast<SnippetGroup *>(item2);
+ if (!group)
+ group = dynamic_cast<SnippetGroup *>(item2->parent());
+
+ QCString dropped;
+ QByteArray data = e->encodedData("text/plain");
+ if ( e->provides("text/plain") && data.size()>0 ) {
+ //get the data from the event...
+ QString encData(data.data());
+ kdDebug(9035) << "encData: " << encData << endl;
+
+ //... then fill the dialog with the given data
+ SnippetDlg dlg(this, "SnippetDlg", true);
+ dlg.snippetName->clear();
+ dlg.snippetText->setText(encData);
+
+ /*fill the combobox with the names of all SnippetGroup entries*/
+ for (SnippetItem *it=_list.first(); it; it=_list.next()) {
+ if (dynamic_cast<SnippetGroup*>(it)) {
+ dlg.cbGroup->insertItem(it->getName());
+ }
+ }
+ dlg.cbGroup->setCurrentText(group->getName());
+
+ if (dlg.exec() == QDialog::Accepted) {
+ /* get the group that the user selected with the combobox */
+ group = dynamic_cast<SnippetGroup*>(SnippetItem::findItemByName(dlg.cbGroup->currentText(), _list));
+ _list.append( new SnippetItem(group, dlg.snippetName->text(), dlg.snippetText->text()) );
+ }
+ }
+}
+
+
+/*!
+ \fn SnippetWidget::languageChanged()
+ */
+void SnippetWidget::languageChanged()
+{
+ QStringList langs = m_part->getProjectLanguages();
+
+ for (SnippetItem *it=_list.first(); it; it=_list.next()) {
+ SnippetGroup * group = dynamic_cast<SnippetGroup*>(it);
+ if (group) {
+ if (group->getLanguage() == i18n("All") || langs.contains(group->getLanguage())) {
+ group->setOpen(TRUE);
+ } else {
+ group->setOpen(FALSE);
+ }
+ }
+ }
+}
+
+#include "snippet_widget.moc"
diff --git a/parts/snippet/snippet_widget.h b/parts/snippet/snippet_widget.h
new file mode 100644
index 00000000..84df7a6f
--- /dev/null
+++ b/parts/snippet/snippet_widget.h
@@ -0,0 +1,90 @@
+/*
+ * File : snippet_widget.h
+ *
+ * Author: Robert Gruber <rgruber@users.sourceforge.net>
+ *
+ * Copyright: See COPYING file that comes with this distribution
+ */
+
+#ifndef __SNIPPET_WIDGET_H__
+#define __SNIPPET_WIDGET_H__
+
+#include <qwidget.h>
+#include <qstring.h>
+#include <klistview.h>
+#include <qtooltip.h>
+#include <qrect.h>
+
+#include <ktexteditor/editinterface.h>
+#include <ktexteditor/view.h>
+#include "snippetconfig.h"
+
+class KDevProject;
+class SnippetPart;
+class QPushButton;
+class KListView;
+class QListViewItem;
+class QPoint;
+class SnippetDlg;
+class SnippetItem;
+class KTextEdit;
+class KConfig;
+
+
+/**
+This is the widget which gets added to the right TreeToolView.
+It inherits KListView and QToolTip which is needed for showing the
+tooltips which contains the text of the snippet
+@author Robert Gruber
+*/
+class SnippetWidget : public KListView, public QToolTip
+{
+ Q_OBJECT
+
+ friend class SnippetSettings; //to allow SnippetSettings to call languageChanged()
+
+public:
+ SnippetWidget(SnippetPart *part);
+ ~SnippetWidget();
+ QPtrList<SnippetItem> * getList() { return (&_list); }
+ void writeConfig();
+ void initConfigOldVersion(KConfig *cfg);
+ SnippetConfig * getSnippetConfig() { return (&_SnippetConfig); }
+
+
+private slots:
+ void initConfig();
+ void languageChanged();
+
+protected:
+ SnippetPart * m_part;
+ void maybeTip( const QPoint & );
+ bool acceptDrag (QDropEvent *event) const;
+
+private:
+ void insertIntoActiveView(QString text);
+ QString parseText(QString text, QString del="$");
+ bool showMultiVarDialog(QMap<QString, QString> * map, QMap<QString, QString> * mapSave,
+ int & iWidth, int & iBasicHeight, int & iOneHeight);
+ QString showSingleVarDialog(QString var, QMap<QString, QString> * mapSave, QRect & dlgSize);
+
+ QPtrList<SnippetItem> _list;
+ QMap<QString, QString> _mapSaved;
+ KConfig * _cfg;
+ SnippetConfig _SnippetConfig;
+
+public slots:
+ void slotRemove();
+ void slotEdit();
+ void slotEditGroup();
+ void slotAdd();
+ void slotAddGroup();
+
+protected slots:
+ void showPopupMenu( QListViewItem * item, const QPoint & p, int );
+ void slotExecuted(QListViewItem * item);
+ void slotDropped(QDropEvent *e, QListViewItem *after);
+};
+
+
+#endif
diff --git a/parts/snippet/snippetconfig.cpp b/parts/snippet/snippetconfig.cpp
new file mode 100644
index 00000000..23186d05
--- /dev/null
+++ b/parts/snippet/snippetconfig.cpp
@@ -0,0 +1,20 @@
+/*
+ * File : snippetconfig.cpp
+ *
+ * Author: Robert Gruber <rgruber@users.sourceforge.net>
+ *
+ * Copyright: See COPYING file that comes with this distribution
+ */
+
+#include "snippetconfig.h"
+
+SnippetConfig::SnippetConfig()
+{
+}
+
+
+SnippetConfig::~SnippetConfig()
+{
+}
+
+
diff --git a/parts/snippet/snippetconfig.h b/parts/snippet/snippetconfig.h
new file mode 100644
index 00000000..89fe00e0
--- /dev/null
+++ b/parts/snippet/snippetconfig.h
@@ -0,0 +1,56 @@
+/*
+ * File : snippetconfig.h
+ *
+ * Author: Robert Gruber <rgruber@users.sourceforge.net>
+ *
+ * Copyright: See COPYING file that comes with this distribution
+ */
+
+#ifndef SNIPPETCONFIG_H
+#define SNIPPETCONFIG_H
+
+#include <qstring.h>
+#include <qrect.h>
+
+
+/**
+This class stores the values that can be configured via the
+KDevelop settings dialog
+@author Robert Gruber
+*/
+class SnippetConfig{
+public:
+ SnippetConfig();
+
+ ~SnippetConfig();
+
+ bool useToolTips() { return (bToolTip); };
+ int getInputMethod() { return (iInputMethod); };
+ QString getDelimiter() { return (strDelimiter); };
+ QRect getSingleRect() { return (rSingle); };
+ QRect getMultiRect() { return (rMulti); };
+ int getAutoOpenGroups() { return iAutoOpenGroups; }
+
+ void setToolTips(bool b) { bToolTip=b; };
+ void setInputMethod(int i) { iInputMethod=i; };
+ void setDelimiter(QString s) { strDelimiter=s; };
+ void setSingleRect(QRect r) {
+ rSingle = (r.isValid())?r:QRect();
+ }
+ void setMultiRect(QRect r) {
+ rMulti = (r.isValid())?r:QRect();
+ }
+ void setAutoOpenGroups(int autoopen) { iAutoOpenGroups = autoopen; }
+
+protected:
+ bool bToolTip;
+ int iInputMethod;
+ QString strDelimiter;
+ QRect rSingle;
+ QRect rMulti;
+ int iMultiBasicHeight;
+ int iMultiCount;
+ int iAutoOpenGroups;
+};
+
+#endif
diff --git a/parts/snippet/snippetdlg.ui b/parts/snippet/snippetdlg.ui
new file mode 100644
index 00000000..a7d4530b
--- /dev/null
+++ b/parts/snippet/snippetdlg.ui
@@ -0,0 +1,214 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>SnippetDlg</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>SnippetDlg</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>344</width>
+ <height>289</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Add Snippet</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget" row="1" column="0">
+ <property name="name">
+ <cstring>layout5</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>btnAdd</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Add</string>
+ </property>
+ </widget>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>btnCancel</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout3</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KLineEdit" row="0" column="1">
+ <property name="name">
+ <cstring>snippetName</cstring>
+ </property>
+ <property name="font">
+ <font>
+ <family>Courier</family>
+ <pointsize>11</pointsize>
+ </font>
+ </property>
+ </widget>
+ <spacer row="4" column="0">
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>80</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Name:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>snippetName</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Snippet:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignTop</set>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>snippetText</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabelGroup</cstring>
+ </property>
+ <property name="text">
+ <string>Group:</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" row="3" column="0">
+ <property name="name">
+ <cstring>toolBtnHelp</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="iconSet">
+ <iconset>image0</iconset>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Click here to get to know how to use variables in a snippet</string>
+ </property>
+ </widget>
+ <widget class="KComboBox" row="1" column="1">
+ <property name="name">
+ <cstring>cbGroup</cstring>
+ </property>
+ </widget>
+ <widget class="KTextEdit" row="2" column="1" rowspan="3" colspan="1">
+ <property name="name">
+ <cstring>snippetText</cstring>
+ </property>
+ <property name="font">
+ <font>
+ <family>Courier</family>
+ <pointsize>11</pointsize>
+ </font>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+</widget>
+<images>
+ <image name="image0">
+ <data format="XPM.GZ" length="720">789c85d0c94ec3301006e07b9ec24a6e15729bb5b12a1e01c4110971182f6dbaa43b07847877f27bec1424a43a87f8fb331edb994ec4ebcb93984c93cb95ae6b234c476731b11f7dfff9f6fef895a47923f25614b9c8d3872495c288e7c3de61ae877936f3032466d9d60466918de79e59cd98cbc879096e022ba663d6b35683a7c05a55a01d69c02e50310d58a8363735781969c15d60cd5c83a56a15b307ab5c85e243a4f5adb6605d28c55c810d1159ff378ee0bc24e71af00cb6da14ce7f95c3c8088fd67a98878c8c1d6c9d46cad972d541b4767873b6d96a3f68e7c62c33f82ef5b2bfd56972e827f7875b9d0e4b8f273d661cd2d9ef1433e9ab388ae7c311fd9e38f42dcb2e9dfe738fd812d19d4c1271f4bb9fbff3fdb5fff68b914cbf17c90f9b96abef</data>
+ </image>
+</images>
+<connections>
+ <connection>
+ <sender>btnAdd</sender>
+ <signal>clicked()</signal>
+ <receiver>SnippetDlg</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>btnCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>SnippetDlg</receiver>
+ <slot>reject()</slot>
+ </connection>
+ <connection>
+ <sender>toolBtnHelp</sender>
+ <signal>clicked()</signal>
+ <receiver>SnippetDlg</receiver>
+ <slot>slotHelp()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>snippetName</tabstop>
+ <tabstop>cbGroup</tabstop>
+ <tabstop>snippetText</tabstop>
+ <tabstop>btnAdd</tabstop>
+ <tabstop>btnCancel</tabstop>
+</tabstops>
+<includes>
+ <include location="local" impldecl="in implementation">snippetdlg.ui.h</include>
+</includes>
+<slots>
+ <slot>slotHelp()</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kcombobox.h</includehint>
+ <includehint>ktextedit.h</includehint>
+</includehints>
+</UI>
diff --git a/parts/snippet/snippetdlg.ui.h b/parts/snippet/snippetdlg.ui.h
new file mode 100644
index 00000000..41ad9d8c
--- /dev/null
+++ b/parts/snippet/snippetdlg.ui.h
@@ -0,0 +1,21 @@
+/*
+ * File : snippetdlg.ui.h
+ *
+ * Author: Robert Gruber <rgruber@users.sourceforge.net>
+ *
+ * Copyright: See COPYING file that comes with this distribution
+ */
+/****************************************************************************
+** 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.
+*****************************************************************************/
+#include <kmessagebox.h>
+
+void SnippetDlg::slotHelp()
+{
+ KMessageBox::information(this, i18n("To use variables in a snippet, you just have to enclose the variablename with $-characters. When you use the snippet, you will then be asked for a value for this variable. \nExample snippet: This is a $VAR$\nWhen you use this snippet you will be prompted for a value for the variable $VAR$. Any occurrences of $VAR$ will then be replaced with whatever you have entered.\nIf you need a single $-character in a snippet, which is not used to enclose a variable, type $$ (two dollar characters) instead. They will automatically be replaced with a single $-character when you use the snippet.\nIf you want to change the default delimiter to anything different, please use the settings dialog to do so."), i18n("Snippet help"));
+}
diff --git a/parts/snippet/snippetitem.cpp b/parts/snippet/snippetitem.cpp
new file mode 100644
index 00000000..7548ad16
--- /dev/null
+++ b/parts/snippet/snippetitem.cpp
@@ -0,0 +1,127 @@
+/*
+ * File : snippetitem.cpp
+ *
+ * Author: Robert Gruber <rgruber@users.sourceforge.net>
+ *
+ * Copyright: See COPYING file that comes with this distribution
+ */
+
+#include <qstring.h>
+
+
+#include "snippetitem.h"
+
+SnippetItem::SnippetItem(QListView * parent, QString name, QString text )
+ : QListViewItem( parent, name )
+{
+ strName = name;
+ strText = text;
+ iParent = -1;
+}
+
+SnippetItem::SnippetItem(QListViewItem * parent, QString name, QString text)
+ : QListViewItem( parent, name )
+{
+ strName = name;
+ strText = text;
+ iParent = ((SnippetGroup *)parent)->getId();
+}
+
+SnippetItem::~SnippetItem()
+{
+}
+
+
+/*!
+ \fn SnippetItem::getName()
+ */
+QString SnippetItem::getName()
+{
+ return strName;
+}
+
+
+/*!
+ \fn SnippetItem::getText
+ */
+QString SnippetItem::getText()
+{
+ return strText;
+}
+
+
+/*!
+ \fn SnippetItem::setText(QString text)
+ */
+void SnippetItem::setText(QString text)
+{
+ strText = text;
+}
+
+
+/*!
+ \fn SnippetItem::setName(QString name)
+ */
+void SnippetItem::setName(QString name)
+{
+ strName = name;
+}
+
+void SnippetItem::resetParent()
+{
+ SnippetGroup * group = dynamic_cast<SnippetGroup*>(parent());
+ if (group)
+ iParent = group->getId();
+}
+
+SnippetItem * SnippetItem::findItemByName(QString name, QPtrList<SnippetItem> &list)
+{
+ for ( SnippetItem * item = list.first(); item; item = list.next() ) { //write the snippet-list
+ if (item->getName() == name)
+ return item;
+ }
+ return NULL;
+}
+
+SnippetGroup * SnippetItem::findGroupById(int id, QPtrList<SnippetItem> &list)
+{
+ for ( SnippetItem * item = list.first(); item; item = list.next() ) { //write the snippet-list
+ SnippetGroup * group = dynamic_cast<SnippetGroup*>(item);
+ if (group && group->getId() == id)
+ return group;
+ }
+ return NULL;
+}
+
+
+/* * * * * * * * * * * * * * * * * * * *
+Deklaration for class SnippetGroup
+* * * * * * * * * * * * * * * * * * * */
+
+int SnippetGroup::iMaxId = 1;
+
+SnippetGroup::SnippetGroup(QListView * parent, QString name, int id, QString lang)
+ : SnippetItem(parent, name, "GROUP")
+{
+ if (id > 0) {
+ iId = id;
+ if (id >= iMaxId)
+ iMaxId = id+1;
+ } else {
+ iId = iMaxId;
+ iMaxId++;
+ }
+
+ strLanguage = lang;
+}
+
+SnippetGroup::~SnippetGroup()
+{
+}
+
+void SnippetGroup::setId(int id)
+{
+ iId = id;
+ if (iId >= iMaxId)
+ iMaxId = iId+1;
+}
diff --git a/parts/snippet/snippetitem.h b/parts/snippet/snippetitem.h
new file mode 100644
index 00000000..ac6fb416
--- /dev/null
+++ b/parts/snippet/snippetitem.h
@@ -0,0 +1,70 @@
+/*
+ * File : snippetitem.h
+ *
+ * Author: Robert Gruber <rgruber@users.sourceforge.net>
+ *
+ * Copyright: See COPYING file that comes with this distribution
+ */
+
+#ifndef SNIPPETITEM_H
+#define SNIPPETITEM_H
+
+#include <klistview.h>
+#include <klocale.h>
+
+class QString;
+
+class SnippetGroup;
+
+/**
+This class represents one CodeSnippet-Item in the listview.
+It also holds the needed data for one snippet.
+@author Robert Gruber
+*/
+class SnippetItem : public QListViewItem {
+friend class SnippetGroup;
+public:
+ SnippetItem(QListViewItem * parent, QString name, QString text);
+
+ ~SnippetItem();
+ QString getName();
+ QString getText();
+ int getParent() { return iParent; }
+ void resetParent();
+ void setText(QString text);
+ void setName(QString name);
+ static SnippetItem * findItemByName(QString name, QPtrList<SnippetItem> &list);
+ static SnippetGroup * findGroupById(int id, QPtrList<SnippetItem> &list);
+
+private:
+ SnippetItem(QListView * parent, QString name, QString text);
+ QString strName;
+ QString strText;
+ int iParent;
+};
+
+/**
+This class represents one group in the listview.
+It is derived from SnippetItem in order to allow storing
+it in the main QPtrList<SnippetItem>.
+@author Robert Gruber
+*/
+class SnippetGroup : public SnippetItem {
+public:
+ SnippetGroup(QListView * parent, QString name, int id, QString lang=i18n("All"));
+ ~SnippetGroup();
+
+ int getId() { return iId; }
+ static int getMaxId() { return iMaxId; }
+ QString getLanguage() { return strLanguage; }
+
+ void setId(int id);
+ void setLanguage(QString lang) { strLanguage = lang; }
+
+private:
+ static int iMaxId;
+ int iId;
+ QString strLanguage;
+};
+
+#endif
diff --git a/parts/snippet/snippetsettings.cpp b/parts/snippet/snippetsettings.cpp
new file mode 100644
index 00000000..f0f9348b
--- /dev/null
+++ b/parts/snippet/snippetsettings.cpp
@@ -0,0 +1,52 @@
+/*
+ * File : snippetsettings.cpp
+ *
+ * Author: Robert Gruber <rgruber@users.sourceforge.net>
+ *
+ * Copyright: See COPYING file that comes with this distribution
+ */
+
+#include <qstring.h>
+#include <klineedit.h>
+#include <qcheckbox.h>
+#include <qbuttongroup.h>
+
+#include "snippetsettings.h"
+#include "snippet_widget.h"
+
+
+SnippetSettings::SnippetSettings(QWidget *parent, const char *name)
+ : SnippetSettingsBase(parent, name)
+{
+ _widget = NULL;
+}
+
+SnippetSettings::SnippetSettings(SnippetWidget * w, QWidget *parent, const char *name)
+ : SnippetSettingsBase(parent, name)
+{
+ _cfg = w->getSnippetConfig();
+ _widget = w;
+}
+
+
+SnippetSettings::~SnippetSettings()
+{
+}
+
+
+/*!
+ \fn SnippetSettings::slotOKClicked()
+ */
+void SnippetSettings::slotOKClicked()
+{
+ _cfg->setToolTips(cbToolTip->isChecked());
+ _cfg->setDelimiter(leDelimiter->text());
+ _cfg->setInputMethod(btnGroup->selectedId());
+ _cfg->setAutoOpenGroups(btnGroupAutoOpen->selectedId());
+
+ if (_widget)
+ _widget->languageChanged();
+}
+
+
+#include "snippetsettings.moc"
diff --git a/parts/snippet/snippetsettings.h b/parts/snippet/snippetsettings.h
new file mode 100644
index 00000000..ef4a019a
--- /dev/null
+++ b/parts/snippet/snippetsettings.h
@@ -0,0 +1,41 @@
+/*
+ * File : snippetsettings.h
+ *
+ * Author: Robert Gruber <rgruber@users.sourceforge.net>
+ *
+ * Copyright: See COPYING file that comes with this distribution
+ */
+
+#ifndef SNIPPETSETTINGS_H
+#define SNIPPETSETTINGS_H
+
+#include "snippetsettingsbase.h"
+
+class SnippetWidget;
+class SnippetConfig;
+
+/**
+This class is the widget that is showen in the
+KDevelop settings dialog. It inherits the
+class SnippetSettingsBase which is created by the
+same named .ui file
+@author Robert Gruber
+*/
+class SnippetSettings : public SnippetSettingsBase
+{
+Q_OBJECT
+public:
+ SnippetSettings(QWidget *parent = 0, const char *name = 0);
+ SnippetSettings(SnippetWidget * w, QWidget *parent = 0, const char *name = 0);
+
+ ~SnippetSettings();
+
+public slots:
+ void slotOKClicked();
+
+private:
+ SnippetConfig * _cfg;
+ SnippetWidget * _widget;
+};
+
+#endif
diff --git a/parts/snippet/snippetsettingsbase.ui b/parts/snippet/snippetsettingsbase.ui
new file mode 100644
index 00000000..54b8c325
--- /dev/null
+++ b/parts/snippet/snippetsettingsbase.ui
@@ -0,0 +1,228 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>SnippetSettingsBase</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>SnippetSettingsBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>574</width>
+ <height>398</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Snippet Settings</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QGroupBox" row="0" column="0">
+ <property name="name">
+ <cstring>groupBox1</cstring>
+ </property>
+ <property name="title">
+ <string>Tooltips</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox" row="0" column="0">
+ <property name="name">
+ <cstring>cbToolTip</cstring>
+ </property>
+ <property name="text">
+ <string>Show snippet's text in &amp;tooltip</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Decides if a tooltip should be shown containing text from the bookmarked line</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <spacer row="3" column="0">
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>70</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QButtonGroup" row="1" column="0">
+ <property name="name">
+ <cstring>buttonGroup1</cstring>
+ </property>
+ <property name="title">
+ <string>Variables</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QButtonGroup" row="1" column="0">
+ <property name="name">
+ <cstring>btnGroup</cstring>
+ </property>
+ <property name="title">
+ <string>Input Method for Variables</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QRadioButton" row="0" column="0">
+ <property name="name">
+ <cstring>rbSingle</cstring>
+ </property>
+ <property name="text">
+ <string>Single dialog for each variable within a snippet</string>
+ </property>
+ <property name="accel">
+ <string></string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>An input dialog will be displayed for every variable within a snippet</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton" row="1" column="0">
+ <property name="name">
+ <cstring>rbAll</cstring>
+ </property>
+ <property name="text">
+ <string>One dialog for all variables within a snippet</string>
+ </property>
+ <property name="accel">
+ <string></string>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>A single dialog will be displayed where you can enter the values for all variables within a snippet</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QLayoutWidget" row="0" column="0">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Delimiter:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>kLineEdit1</cstring>
+ </property>
+ </widget>
+ <widget class="KLineEdit">
+ <property name="name">
+ <cstring>leDelimiter</cstring>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>40</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <property name="maxLength">
+ <number>1</number>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QButtonGroup" row="2" column="0">
+ <property name="name">
+ <cstring>btnGroupAutoOpen</cstring>
+ </property>
+ <property name="title">
+ <string>Automatically Open Groups</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QRadioButton" row="0" column="0">
+ <property name="name">
+ <cstring>rbOpenOnActiv</cstring>
+ </property>
+ <property name="text">
+ <string>The group's language is the project's primary language</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>&lt;qt&gt;If the group's language is the same as the project's primary language, the group will be automatically opened.&lt;/qt&gt;</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton" row="1" column="0">
+ <property name="name">
+ <cstring>rbOpenOnSupported</cstring>
+ </property>
+ <property name="text">
+ <string>The group's language is supported by the project</string>
+ </property>
+ <property name="accel">
+ <string></string>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>&lt;qt&gt;Groups having a language which is supported by the current project will be opened automatically. &lt;br&gt;Even if the group's language is not the same as the project's primary language.&lt;/qt&gt;</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>klineedit.h</includehint>
+</includehints>
+</UI>