summaryrefslogtreecommitdiffstats
path: root/kate
diff options
context:
space:
mode:
Diffstat (limited to 'kate')
-rw-r--r--kate/AUTHORS33
-rw-r--r--kate/CMakeLists.txt12
-rw-r--r--kate/COPYING.LIB481
-rw-r--r--kate/ChangeLog286
-rw-r--r--kate/DESIGN13
-rw-r--r--kate/Mainpage.dox9
-rw-r--r--kate/Makefile.am12
-rw-r--r--kate/NEWS23
-rw-r--r--kate/README24
-rw-r--r--kate/TODO1
-rw-r--r--kate/app/CMakeLists.txt71
-rw-r--r--kate/app/Makefile.am29
-rw-r--r--kate/app/kateapp.cpp403
-rw-r--r--kate/app/kateapp.h243
-rw-r--r--kate/app/kateappIface.cpp104
-rw-r--r--kate/app/kateappIface.h94
-rw-r--r--kate/app/kateconfigdialog.cpp476
-rw-r--r--kate/app/kateconfigdialog.h85
-rw-r--r--kate/app/kateconfigplugindialogpage.cpp121
-rw-r--r--kate/app/kateconfigplugindialogpage.h69
-rw-r--r--kate/app/kateconsole.cpp143
-rw-r--r--kate/app/kateconsole.h116
-rw-r--r--kate/app/katedocmanager.cpp612
-rw-r--r--kate/app/katedocmanager.h157
-rw-r--r--kate/app/katedocmanageriface.cpp131
-rw-r--r--kate/app/katedocmanageriface.h62
-rw-r--r--kate/app/kateexternaltools.cpp873
-rw-r--r--kate/app/kateexternaltools.h229
-rw-r--r--kate/app/katefilelist.cpp749
-rw-r--r--kate/app/katefilelist.h199
-rw-r--r--kate/app/katefileselector.cpp722
-rw-r--r--kate/app/katefileselector.h172
-rw-r--r--kate/app/kategrepdialog.cpp544
-rw-r--r--kate/app/kategrepdialog.h97
-rw-r--r--kate/app/katemailfilesdialog.cpp112
-rw-r--r--kate/app/katemailfilesdialog.h59
-rw-r--r--kate/app/katemain.cpp267
-rw-r--r--kate/app/katemain.h70
-rw-r--r--kate/app/katemainwindow.cpp860
-rw-r--r--kate/app/katemainwindow.h218
-rw-r--r--kate/app/katemainwindowiface.cpp27
-rw-r--r--kate/app/katemainwindowiface.h41
-rw-r--r--kate/app/katemdi.cpp970
-rw-r--r--kate/app/katemdi.h448
-rw-r--r--kate/app/katemwmodonhddialog.cpp281
-rw-r--r--kate/app/katemwmodonhddialog.h61
-rw-r--r--kate/app/katepluginmanager.cpp220
-rw-r--r--kate/app/katepluginmanager.h90
-rw-r--r--kate/app/katesavemodifieddialog.cpp226
-rw-r--r--kate/app/katesavemodifieddialog.h48
-rw-r--r--kate/app/katesession.cpp920
-rw-r--r--kate/app/katesession.h418
-rw-r--r--kate/app/katetabwidget.cpp161
-rw-r--r--kate/app/katetabwidget.h69
-rw-r--r--kate/app/kateviewmanager.cpp514
-rw-r--r--kate/app/kateviewmanager.h154
-rw-r--r--kate/app/kateviewspace.cpp423
-rw-r--r--kate/app/kateviewspace.h121
-rw-r--r--kate/app/kateviewspacecontainer.cpp758
-rw-r--r--kate/app/kateviewspacecontainer.h161
-rw-r--r--kate/app/kbookmarkhandler.cpp98
-rw-r--r--kate/app/kbookmarkhandler.h72
-rw-r--r--kate/app/kwritemain.cpp716
-rw-r--r--kate/app/kwritemain.h140
-rw-r--r--kate/data/CMakeLists.txt19
-rw-r--r--kate/data/Makefile.am18
-rw-r--r--kate/data/externaltools77
-rw-r--r--kate/data/kate-2.4.upd7
-rw-r--r--kate/data/kate.desktop96
-rw-r--r--kate/data/kateplugin.desktop89
-rw-r--r--kate/data/katerc2
-rw-r--r--kate/data/kateui.rc171
-rw-r--r--kate/data/kwrite.desktop111
-rw-r--r--kate/data/kwriteui.rc95
-rw-r--r--kate/data/tips122
-rw-r--r--kate/interfaces/CMakeLists.txt47
-rw-r--r--kate/interfaces/Makefile.am14
-rw-r--r--kate/interfaces/application.cpp97
-rw-r--r--kate/interfaces/application.h79
-rw-r--r--kate/interfaces/documentmanager.cpp120
-rw-r--r--kate/interfaces/documentmanager.h111
-rw-r--r--kate/interfaces/mainwindow.cpp82
-rw-r--r--kate/interfaces/mainwindow.h65
-rw-r--r--kate/interfaces/plugin.cpp106
-rw-r--r--kate/interfaces/plugin.h87
-rw-r--r--kate/interfaces/pluginconfiginterface.cpp63
-rw-r--r--kate/interfaces/pluginconfiginterface.h63
-rw-r--r--kate/interfaces/pluginconfiginterfaceextension.cpp68
-rw-r--r--kate/interfaces/pluginconfiginterfaceextension.h104
-rw-r--r--kate/interfaces/pluginmanager.cpp78
-rw-r--r--kate/interfaces/pluginmanager.h70
-rw-r--r--kate/interfaces/toolviewmanager.cpp85
-rw-r--r--kate/interfaces/toolviewmanager.h96
-rw-r--r--kate/interfaces/viewmanager.cpp73
-rw-r--r--kate/interfaces/viewmanager.h89
-rw-r--r--kate/pics/CMakeLists.txt16
-rw-r--r--kate/pics/Makefile.am6
-rw-r--r--kate/pics/actions/CMakeLists.txt12
-rw-r--r--kate/pics/actions/Makefile.am2
-rw-r--r--kate/pics/actions/cr16-action-curfiledir.pngbin0 -> 656 bytes
-rw-r--r--kate/pics/actions/cr16-action-highlighting.pngbin0 -> 845 bytes
-rw-r--r--kate/pics/actions/cr16-action-modified.pngbin0 -> 838 bytes
-rw-r--r--kate/pics/actions/cr16-action-modmod.pngbin0 -> 784 bytes
-rw-r--r--kate/pics/actions/cr16-action-modonhd.pngbin0 -> 748 bytes
-rw-r--r--kate/pics/actions/cr16-action-null.pngbin0 -> 85 bytes
-rw-r--r--kate/pics/actions/cr32-action-highlighting.pngbin0 -> 1618 bytes
-rw-r--r--kate/pics/actions/lo16-action-curfiledir.pngbin0 -> 214 bytes
-rw-r--r--kate/pics/actions/lo16-action-indent.pngbin0 -> 381 bytes
-rw-r--r--kate/pics/actions/lo16-action-modified.pngbin0 -> 313 bytes
-rw-r--r--kate/pics/actions/lo16-action-modmod.pngbin0 -> 313 bytes
-rw-r--r--kate/pics/actions/lo16-action-modonhd.pngbin0 -> 324 bytes
-rw-r--r--kate/pics/actions/lo16-action-null.pngbin0 -> 85 bytes
-rw-r--r--kate/pics/actions/lo16-action-unindent.pngbin0 -> 381 bytes
-rw-r--r--kate/pics/actions/lo22-action-indent.pngbin0 -> 510 bytes
-rw-r--r--kate/pics/actions/lo22-action-unindent.pngbin0 -> 511 bytes
-rw-r--r--kate/pics/hi128-app-kate.pngbin0 -> 20365 bytes
-rw-r--r--kate/pics/hi128-app-kwrite.pngbin0 -> 20365 bytes
-rw-r--r--kate/pics/hi16-app-kate.pngbin0 -> 976 bytes
-rw-r--r--kate/pics/hi16-app-kwrite.pngbin0 -> 976 bytes
-rw-r--r--kate/pics/hi22-app-kate.pngbin0 -> 1661 bytes
-rw-r--r--kate/pics/hi22-app-kwrite.pngbin0 -> 1661 bytes
-rw-r--r--kate/pics/hi32-app-kate.pngbin0 -> 2693 bytes
-rw-r--r--kate/pics/hi32-app-kwrite.pngbin0 -> 2693 bytes
-rw-r--r--kate/pics/hi48-app-kate.pngbin0 -> 5434 bytes
-rw-r--r--kate/pics/hi48-app-kwrite.pngbin0 -> 5434 bytes
-rw-r--r--kate/pics/hi64-app-kate.pngbin0 -> 8202 bytes
-rw-r--r--kate/pics/hi64-app-kwrite.pngbin0 -> 8202 bytes
-rw-r--r--kate/pics/hisc-app-kate2.svgzbin0 -> 10519 bytes
-rw-r--r--kate/pics/hisc-app-kwrite2.svgzbin0 -> 10519 bytes
-rw-r--r--kate/pics/sessionchooser.pngbin0 -> 21628 bytes
-rw-r--r--kate/pics/sessionchooser.xcfbin0 -> 56887 bytes
-rw-r--r--kate/utils/CMakeLists.txt40
-rw-r--r--kate/utils/Makefile.am16
-rw-r--r--kate/utils/README29
-rw-r--r--kate/utils/dockviewbase.cpp102
-rw-r--r--kate/utils/dockviewbase.h102
-rw-r--r--kate/utils/listboxview.cpp57
-rw-r--r--kate/utils/listboxview.h44
-rw-r--r--kate/utils/messageview.cpp46
-rw-r--r--kate/utils/messageview.h72
140 files changed, 19066 insertions, 0 deletions
diff --git a/kate/AUTHORS b/kate/AUTHORS
new file mode 100644
index 000000000..c2e6cb35e
--- /dev/null
+++ b/kate/AUTHORS
@@ -0,0 +1,33 @@
+Kate/KWrite Team:
+- Christoph Cullmann <cullmann@kde.org>
+ (Maintainer)
+
+- Joseph Wenninger <jowenn@kde.org>
+ (highlight guy + big bug hunter)
+
+- Anders Lund <anders@alweb.dk>
+ (very cool split view + much more)
+
+- Waldo Bastian <bastian@kde.org>
+ (improved buffer handling)
+
+- Michael Bartl <michael.bartl1@chello.at>
+ (first one who really helped out :)
+
+- Phlip <phlip_cpp@my-deja.com>
+ (project stuff)
+
+- Matt Newell <newellm@proaxis.com>
+
+- Michael McCallum <gholam@xtra.co.nz>
+
+- John Firebaugh <jfire@uclink.berkeley.edu>
+
+- Jochen Wilhelmy <digisnap@cs.tu-berlin.de>
+ (original author of kwrite in kde 1.x until kde 2.1)
+
+- Glen Parker <glenebob@nwlink.com>
+ (undo history, tdespell-integration)
+
+- Michael Koch <koch@kde.org>
+ (port to KParts)
diff --git a/kate/CMakeLists.txt b/kate/CMakeLists.txt
new file mode 100644
index 000000000..2946821d1
--- /dev/null
+++ b/kate/CMakeLists.txt
@@ -0,0 +1,12 @@
+project( kate )
+
+add_subdirectory( utils )
+add_subdirectory( interfaces )
+add_subdirectory( app )
+add_subdirectory( data )
+add_subdirectory( pics )
+
+
+##### install import cmake modules ###############
+
+tde_install_export( )
diff --git a/kate/COPYING.LIB b/kate/COPYING.LIB
new file mode 100644
index 000000000..789c31eee
--- /dev/null
+++ b/kate/COPYING.LIB
@@ -0,0 +1,481 @@
+ GNU LIBRARY GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1991 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor
+ Boston, MA 02110-1301, USA.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the library GPL. It is
+ numbered 2 because it goes with version 2 of the ordinary GPL.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Library General Public License, applies to some
+specially designated Free Software Foundation software, and to any
+other libraries whose authors decide to use it. You can use it for
+your libraries, 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 library, or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link a program with the library, you must provide
+complete object files to the recipients so that they can relink them
+with the library, after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ Our method of protecting your rights has two steps: (1) copyright
+the library, and (2) offer you this license which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ Also, for each distributor's protection, we want to make certain
+that everyone understands that there is no warranty for this free
+library. If the library is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original
+version, 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 companies distributing free
+software will individually obtain patent licenses, thus in effect
+transforming the program into proprietary software. To prevent this,
+we have made it clear that any patent must be licensed for everyone's
+free use or not licensed at all.
+
+ Most GNU software, including some libraries, is covered by the ordinary
+GNU General Public License, which was designed for utility programs. This
+license, the GNU Library General Public License, applies to certain
+designated libraries. This license is quite different from the ordinary
+one; be sure to read it in full, and don't assume that anything in it is
+the same as in the ordinary license.
+
+ The reason we have a separate public license for some libraries is that
+they blur the distinction we usually make between modifying or adding to a
+program and simply using it. Linking a program with a library, without
+changing the library, is in some sense simply using the library, and is
+analogous to running a utility program or application program. However, in
+a textual and legal sense, the linked executable is a combined work, a
+derivative of the original library, and the ordinary General Public License
+treats it as such.
+
+ Because of this blurred distinction, using the ordinary General
+Public License for libraries did not effectively promote software
+sharing, because most developers did not use the libraries. We
+concluded that weaker conditions might promote sharing better.
+
+ However, unrestricted linking of non-free programs would deprive the
+users of those programs of all benefit from the free status of the
+libraries themselves. This Library General Public License is intended to
+permit developers of non-free programs to use free libraries, while
+preserving your freedom as a user of such programs to change the free
+libraries that are incorporated in them. (We have not seen how to achieve
+this as regards changes in header files, but we have achieved it as regards
+changes in the actual functions of the Library.) The hope is that this
+will lead to faster development of free libraries.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, while the latter only
+works together with the library.
+
+ Note that it is possible for a library to be covered by the ordinary
+General Public License rather than by this special one.
+
+ GNU LIBRARY GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library which
+contains a notice placed by the copyright holder or other authorized
+party saying it may be distributed under the terms of this Library
+General Public License (also called "this License"). Each licensee is
+addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, 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 library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete 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 distribute a copy of this License along with the
+Library.
+
+ 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 Library or any portion
+of it, thus forming a work based on the Library, 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) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+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 Library, 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 Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you 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.
+
+ If distribution of 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 satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also compile or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ c) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ d) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. 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.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library 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.
+
+ 9. 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 Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+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.
+
+ 11. 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 Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library 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 Library.
+
+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.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library 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.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Library 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 Library
+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 Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+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
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "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
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. 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 LIBRARY 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
+LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), 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 Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. 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 library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
diff --git a/kate/ChangeLog b/kate/ChangeLog
new file mode 100644
index 000000000..533f15e85
--- /dev/null
+++ b/kate/ChangeLog
@@ -0,0 +1,286 @@
+2004-04-22 Christoph Cullmann <cullmann@kde.org>
+ * kate switched over to katemdi, even smaller replacement for tdemdi2 :)
+
+2004-10-06 Christoph Cullmann <cullmann@kde.org>
+ * kate switched over to tdemdi2, a slim version of old tdemdi
+ which allows only IDEA mode, but should be much less buggy
+ beside this, we now allow tabbing thx to the new tdemdi stuff
+ and therefor should now be really feature complete at least mdi
+ wise, having the features to allow multiple main windows,
+ tabbing, splitters, widget stacks for the views, now only missing thingy
+ would be to allow non kate view's to be embeded, like a tdehtml widget for
+ documentation browsing or something like that
+
+2003-08-28 Christoph Cullmann <cullmann@kde.org>
+ * jowenn switch kate over to use tdemdi, seems to work well
+ for the first port, but still needs some fixes ;)
+
+2002-07-19 Christoph Cullmann <cullmann@kde.org>
+ * new interface structure implemented
+ this is BIC and source incompatible to 2.x and 3.0.x plugins
+
+2002-01-04 Christoph Cullmann <cullmann@kde.org>
+ * the search stuff in the katedocument is rewritten now, should work mostly,
+ only search for whole words is just a mess :(
+
+2002-01-03 Christoph Cullmann <cullmann@kde.org>
+ * kate app and kwrite app now use the katepart via libloader and link only
+ to the kateinterfaces (which will soon be splitted into katepartinterfaces
+ and kateinterfaces
+ * new framework for the configpages of the katepart accessible through the
+ interfaces
+ * KSpell works again ;) my god, what a buggy thingy
+
+2001-12-01 Christoph Cullmann <cullmann@kde.org>
+ * speedup for insert/removeText/Line
+ * new editStart/editEnd/editAddUndo functions to make the undo/redo + update
+ after edit function calls easier to understand an use in katedocument.*
+
+2001-11-30 Joseph Wenninger <jowenn@kde.org>
+ * I hopefully fixed the CSS highlighting finally. It used
+ deprecated syntax and there was a bug in the highlighting code,
+ for handling weakDeliminiators. Who renamed them, once they where
+ called weakDelimiters, which I think is the correct pronounciation.
+
+2001-11-29 Joseph Wenninger <jowenn@kde.org>
+ * KWrite/Kate use different font settings for printing and viewing now
+ * Fixed a small crash in my tdevelop->kate port of the codecompletion interface
+
+2001-11-26 Christoph Cullmann <cullmann@kde.org>
+ * backspace bug fixed
+ * more cleanups in doc/view
+
+2001-11-24 Christoph Cullmann <cullmann@kde.org>
+ * the docID is now called documentNumber and is in the KTextEditor lib ;)
+ * new print and mark interfaces ;)
+ * bugfixes for some stuff in kateview/document.*
+ * move more of the document stuff from the view to the document
+ (old kwritedoc/view was very mixed, no real seperation, but that should be nearly done)
+
+2001-11-17 Christoph Cullmann <cullmann@kde.org>
+ * new selection code (bit buggy at the moment, but better than the old way
+ of storing the selection in the attributes
+
+2001-10-29 Joseph Wenninger <jowenn@kde.org>
+ * Highlighting definitions support now #stay and #pop as context values
+ * Some highlighting definitions ported
+
+2001-10-27 Christoph Cullmann <cullmann@kde.org>
+ * undo/redo works now without errors
+ * fix many memleaks + some crashs in buffer + hl
+ * fix ctx managment (almost)
+
+2001-10-27 Joseph Wenninger <jowenn@kde.org
+ * Highlighting isn't updated completely yet (should be fixed now), but uses:
+ * I have to do some nasty workaround because the overloaded ==
+ operator in QMemArray crashes, if one or both of the arrays has
+ a size of 0 (I think this is a bug in QT, but it could be that
+ this is intended behaviour. Who knows ?)
+
+2001-10-26 Joseph Wenninger <jowenn@kde.org>
+ * The stacked highlighting shoul almost work now.
+ Using old description files it will use quite a lot memory, but
+ they should work.
+ Problems:
+ * It's leaking like a sieve on destruction, because the
+ memarrays aren't deleted correctly yet (They need to be pointers and not
+ references, otherwise there are out of memory errors in qgarray)
+ * Highlighting isn't updated completely yet
+ * I have to do some nasty workaround because the overloaded ==
+ operator in QMemArray crashes, if one or both of the arrays has
+ a size of 0 (I think this is a bug in QT, but it could be that
+ this is intended behaviour. Who knows ?)
+
+2001-10-20 Christoph Cullmann <cullmann@kde.org>
+ * new undo/redo stuff, should work now already fine (mostly ;)
+
+2001-10-14 Christoph Cullmann <cullmann@kde.org>
+ * new interfaces
+ * fixed some bugs (or better mistakes) in EditInterface
+ * fix bugs and even more bugs
+
+2001-10-14 Christoph Cullmann <cullmann@kde.org>
+ * implementing and enhancing the new KTextEditor interfaces
+ * rewrite the whole internal document/view stuff ;) (hope will be finished
+ soon with that old crap !
+ * reconstruction of whole katelibs + dirs
+
+2001-10-06 Christoph Cullmann <cullmann@kde.org>
+ * myself back again ;)
+ * now kate is clean (only qt3), no backports ;)
+
+2001-08-24 christian@kdevelop.org
+ * reimplement the commenting of selections on some languages
+
+2001-08-19 christian@kdevelop.org
+ * added back Sather highlighting support
+ * improved Eiffel language syntax highlighting support
+ * added Eiffel language comment directive in eiffel.xml
+ * added Ada language comment directive in ada.xml
+
+2001-08-15 christian@kdevelop.org
+ * committed Eiffel language syntax highlighting support
+
+2001-08-08 rokrau@yahoo.com
+ * committed changes to Kate's API necessary for integration of kate as
+ a kpart into tdevelop
+
+2001-05-13 Christoph Cullmann <cullmann@kde.org>
+ * after some time of learning for my "Abitur" now again some fixes ;):
+ textlines stuff rewritten, selection fixed + +/- font zoom buttons in the part
+
+2001-04-27 Christoph Cullmann <cullmann@kde.org>
+ * now the pluginconfig pages work ;)
+
+2001-04-24 Joseph Wenninger <jowenn@kde.org>
+ * now <keywords> and <types> is replaced by <list name="XXXX">
+
+2001-04-20 Christoph Cullmann <cullmann@kde.org>
+ * new configdialog
+ * enhanced pluginIface to supports configdialogpages
+
+2001-04-14 Christoph Cullmann <cullmann@kde.org>
+ * now kateview has in iconborder too (without real function at the moment)
+
+2001-04-10 Christoph Cullmann <cullmann@kde.org>
+ * bugfixes for drawBuffer stuff, next/prev viewspace, restoreView
+
+2001-04-08 Christoph Cullmann <cullmann@kde.org>
+ * now encoding for files can be selected at settings dialog (not only UTF8, all possible encodings)
+ * dropped old code -> use Waldo's code ;)
+
+2001-04-07 Joseph Wenninger <jowenn@kde.org>
+ * Activated Waldo Bastian's NEW_CODE
+ * Ported Highlighting to it
+
+2001-04-05 Joseph Wenninger <jowenn@kde.org>
+ * Highlighting Configuration is now in kate/kwrite settings too
+ * Made a cleanup of no longer used classes
+
+2001-04-04 Christoph Cullmann <cullmann@kde.org>
+ * sidebar now again restores config
+
+2001-04-03 Joseph Wenninger <jowenn@kde.org>
+ * Cristi Dumitrescu's PHP keyword / type list added
+
+2001-04-01 Joseph Wenninger <jowenn@kde.org>
+ * Added a new widget KateStackTabWidget
+ Now you can chose between tabbed or an
+ KOffice Workspace like view for the file sidebar
+ --> You can change this behaviour in the config dialog
+ * Not implemented:
+ restore sidebar page on startup
+ remove page not implemented yet
+ (will be fixed soon)
+ * Added a backport of QT3's QRegExp I got from Scott Manson
+ wit one addtion (see qt3back/README)
+ hopefully this will give us more flexibility for syntax
+ highlighting
+
+2001-03-27 Christoph Cullmann <cullmann@kde.org>
+ * console disabled per default
+ * console only loaded if enabled
+
+2001-03-28 Joseph Wenninger <jowenn@kde.org>
+ * -n in kate.desktop removed, now config settings are used
+
+2001-03-27 Christoph Cullmann <cullmann@kde.org>
+ * interfaces extended (mainly for projectmanager)
+ * piper moved to plugins/projectmanager/piper
+ * a piper Makefile.am created
+
+2001-03-26 Joseph Wenninger <jowenn@kde.org>
+ * 2 reimplemented highlighing configs
+ * 1 experimental highlighting config
+ * preparations for an highlighting editing dialog
+
+2001-03-25 Christoph Cullmann <cullmann@kde.org>
+ * rewrite of plugin API and manager, now loading/unloading nice
+
+2001-03-22 Joseph Wenninger <jowenn@kde.org>
+ * single / multi instance mode configurable
+ Cullmann's -n option forces a new instance
+ Otherwise it uses the configuration from
+ the settings dialog. At the moment -n is
+ default start option
+
+2001-03-21 Christoph Cullmann <cullmann@kde.org>
+ * QPopupMenu for filelist
+
+2001-03-20 Christoph Cullmann <cullmann@kde.org>
+ * kate is now a normal TDEApplication
+
+2001-03-18 Christoph Cullmann <cullmann@kde.org>
+ * big location changes of source files
+ * KateFactory now in use by hole Kate app
+ * KatePartView/Doc merged with KateView/Doc (make life more easy)
+
+2001-03-18 Joseph Wenninger <jowenn@kde.org>
+ * openheader plugin opens the corresponding
+ .h file for .cpp or .c, and vice versa
+ * Hopefully fixed highlighting dialog for now.
+
+2001-03-17 Joseph Wenninger <jowenn@kde.org>
+ * Syntaxhighlighting is now defined in cpp.xml, c.xml html.xml ...
+ instead of a global syntax.xml.
+ (Not ported completely yet)
+ * Some simple reg expression work (see html.xml)
+
+2001-03-17 Christoph Cullmann <cullmann@kde.org>
+ * moved textfilter stuff to a own plugin "textfilter"
+ * cleaned up katemainwindow.*
+
+2001-03-16 Christoph Cullmann <cullmann@kde.org>
+ * search dialog comes up with selected text
+ * backport of some KDevelop KWrite patches ;)
+
+2001-03-15 Christoph Cullmann <cullmann@kde.org>
+ * katepart finished
+ * new kwrite using katepart
+ * removed old kwrite and kwritepart !
+ * fixed menu and toolbar problems of the new KWrite app
+
+2001-03-11 Christoph Cullmann <cullmann@kde.org>
+ * kwrite stuff merged into kate !!!!!
+
+2001-03-04 Christoph Cullmann <cullmann@kde.org>
+ * mutiple mainwindows
+ * fileist, sync for all mainwindows, all open docs listed
+
+2001-03-03 Christoph Cullmann <cullmann@kde.org>
+ * session managment (Anders Lund)
+ * removed some debug stuff
+
+2001-02-26 Joseph Wenninger <jowenn@kde.org>
+ * First step for a plugin management dialog page
+ Soon to come
+
+2001-02-26 Christoph Cullmann <cullmann@kde.org>
+ * Kate is a part of tdebase :)
+ sourceforge.net CVS won't be used in the future
+
+2001-02-24 Phlip <phlip_cpp@my-deja.com>
+ * HTML button - select text, hit <Ctrl+Dash>, and enter the fields
+ for an SGML tag. Don't enter the < > or closing tag. We put these
+ around the selected text, and [try to] re-select that text so you can add
+ another nested tag right away. We are now the first HTML editor
+ that's actually better than Notepad! Hours of fun.
+
+ * Filter - select text, hit <Ctrl+Backslash>, and enter an OS command.
+ we pipe the selected text thru that command, such as "sort", and then
+ replace the selection with the result. Impress your friends.
+
+2001-02-21 Joseph Wenninger <jowenn@kde.org>
+ * Makefile.am's : correction for linking
+ * katemenuitem.h : Improved menu items added doc-list
+ * katelistboxitem.h : Improved listboxitem files-list
+
+2001-02-19 Christoph Cullmann <cullmann@kde.org>
+ * kateconsole.* konsole/* : add kateconsole widget
+
+2001-02-16 Anders Lund <anders@alweb.dk>
+ * katemainwindow.cpp :fixing read/write options to use maindockwindow functions.
+
+2001-02-15 Joseph Wenninger <jowenn@kde.org>
+ * kateview.cpp : Tab doesn't jump to next widget anymore, but inserts a tab into the text
+ * katemainwindow.* : F8 / SHIFT-F8 jumps to next / previous widget
diff --git a/kate/DESIGN b/kate/DESIGN
new file mode 100644
index 000000000..0fa65c0a5
--- /dev/null
+++ b/kate/DESIGN
@@ -0,0 +1,13 @@
+KateApp
+ - KatePluginManager
+ one plugin manager per app
+
+ - KateDocManager
+ one doc manager per app
+
+ - KateMainWindow
+ mutliple mainwindows per app possible
+
+ - KateViewManager
+ one view manager per mainwin
+ \ No newline at end of file
diff --git a/kate/Mainpage.dox b/kate/Mainpage.dox
new file mode 100644
index 000000000..5f237c04b
--- /dev/null
+++ b/kate/Mainpage.dox
@@ -0,0 +1,9 @@
+/** @mainpage Kate
+*
+* Kate is the KDE Advanced Text Editor. This section describes
+* the internal classes used to create Kate. It should not be
+* used as a public API.
+*
+* For a public API, see the text editor interface in tdelibs.
+*
+*/
diff --git a/kate/Makefile.am b/kate/Makefile.am
new file mode 100644
index 000000000..4a8b97f91
--- /dev/null
+++ b/kate/Makefile.am
@@ -0,0 +1,12 @@
+SUBDIRS = utils interfaces app data pics
+EXTRA_DIST = AUTHORS COPYING.LIB ChangeLog DESIGN NEWS README TODO
+
+messages:
+ rm -f tips.txt
+ (cd data && $(PREPARETIPS) > ../tips.txt)
+ $(EXTRACTRC) ./*/*.rc >> ./rc.cpp
+ $(XGETTEXT) `find . -name "*.cpp" -o -name "*.txt"` -o $(podir)/kate.pot
+ rm -f tips.txt
+
+include ../admin/Doxyfile.am
+
diff --git a/kate/NEWS b/kate/NEWS
new file mode 100644
index 000000000..994c83eac
--- /dev/null
+++ b/kate/NEWS
@@ -0,0 +1,23 @@
+2003-08-28
+ Kate uses KMdi ;)
+
+2002-07-19
+ New Plugin Interfaces finished (hopefully)
+
+2002-01-03
+ Kate App and Part seperated
+
+2001-11-24
+ KTextEditor interfaces are near completion ;)
+
+2001-06-11
+ Little Cullmann got his little Abitur with 1.zero ;)
+
+2001-05-12
+ juhu, my abi is over ;) (just must type a news item ;)
+
+2001-04-01
+ Kant -> Kate
+
+2001-03-01
+ Kant is now official part of KDEBASE ;-)
diff --git a/kate/README b/kate/README
new file mode 100644
index 000000000..67eb04be6
--- /dev/null
+++ b/kate/README
@@ -0,0 +1,24 @@
+ *** Kate ***
+Kate is a fast texteditor for the KDE destop with an Emacs-style document interface.
+I hope it works well and improves workspeed on many little textfiles. ;-)
+Our new buffer managment will allow it to open 50MB files ++ in less than 5 seconds
+(at least on my 400Mhz P2 ;) It is thought as a more powerful replacement for the old
+KWrite app, which will still keep alive for the existing userbase and because it is
+just a lot smaller and therefor faster on launch than kate.
+For Kate Plugins, Kate provides the Kate Interfaces, which allow deeper access
+to the Kate app and its features.
+
+ *** KWrite ***
+The KWrite app is based on the KWrite of KDE 2.0 written by Jochen Wilhelmy
+but now it uses the Kate part or any other KTextEditor compatible part.
+The most stuff has been rewritten since the old KDE 2.x days.
+
+Homepage: http://kate.kde.org
+
+Licensing:
+The Kate app/utils/interfaces and KWrite app are licensed under the LGPL VERSION 2.
+
+ *** Undocumented features in Kate version 2.5.2 ***
+* The KateApplication DCOP interface has a function QString session() that
+returns the name of the active session (which might be an empty string).
+(but hey, documentation of the DCOP interface is missing completely) \ No newline at end of file
diff --git a/kate/TODO b/kate/TODO
new file mode 100644
index 000000000..bc60bf4b0
--- /dev/null
+++ b/kate/TODO
@@ -0,0 +1 @@
+TODO:
diff --git a/kate/app/CMakeLists.txt b/kate/app/CMakeLists.txt
new file mode 100644
index 000000000..7adea8ea3
--- /dev/null
+++ b/kate/app/CMakeLists.txt
@@ -0,0 +1,71 @@
+#################################################
+#
+# (C) 2010-2011 Serghei Amelian
+# serghei (DOT) amelian (AT) gmail.com
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+add_definitions(
+ -include tqt.h
+)
+
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}
+ ${TDE_INCLUDE_DIR}
+ ${TQT_INCLUDE_DIRS}
+)
+
+link_directories(
+ ${TQT_LIBRARY_DIRS}
+)
+
+
+##### kateinterfaces (shared lib) ###############
+
+set( target kateinterfaces )
+
+set( ${target}_SRCS
+ kateapp.cpp kateconfigdialog.cpp kateconfigplugindialogpage.cpp
+ kateconsole.cpp katedocmanager.cpp katefilelist.cpp
+ katefileselector.cpp katemainwindow.cpp katepluginmanager.cpp
+ kateviewmanager.cpp kateviewspace.cpp katemainwindowiface.skel
+ katemainwindowiface.cpp kategrepdialog.cpp katemailfilesdialog.cpp
+ kbookmarkhandler.cpp katedocmanageriface.skel kateappIface.cpp
+ kateappIface.skel katedocmanageriface.cpp kateexternaltools.cpp
+ katesavemodifieddialog.cpp kateviewspacecontainer.cpp
+ katemwmodonhddialog.cpp katesession.cpp katemdi.cpp
+ katetabwidget.cpp
+)
+
+tde_add_library( ${target} SHARED AUTOMOC
+ SOURCES ${${target}_SRCS}
+ VERSION 0.0.0
+ EMBED kateinterfacesprivate-static
+ LINK tdeutils-shared
+ DESTINATION ${LIB_INSTALL_DIR}
+)
+
+
+##### kate (tdeinit) ############################
+
+set( target kate )
+
+tde_add_tdeinit_executable( ${target}
+ SOURCES katemain.cpp
+ LINK kateinterfaces-shared
+)
+
+
+##### kwrite (tdeinit) ##########################
+
+set( target kwrite )
+
+tde_add_tdeinit_executable( ${target} AUTOMOC
+ SOURCES kwritemain.cpp
+ LINK kateinterfaces-shared katepartinterfaces-shared
+)
diff --git a/kate/app/Makefile.am b/kate/app/Makefile.am
new file mode 100644
index 000000000..de2258630
--- /dev/null
+++ b/kate/app/Makefile.am
@@ -0,0 +1,29 @@
+lib_LTLIBRARIES = libkateinterfaces.la
+bin_PROGRAMS =
+tdeinit_LTLIBRARIES = kate.la kwrite.la
+
+libkateinterfaces_la_SOURCES = kateapp.cpp kateconfigdialog.cpp kateconfigplugindialogpage.cpp \
+ kateconsole.cpp katedocmanager.cpp katefilelist.cpp katefileselector.cpp \
+ katemainwindow.cpp katepluginmanager.cpp \
+ kateviewmanager.cpp kateviewspace.cpp \
+ katemainwindowiface.skel katemainwindowiface.cpp kategrepdialog.cpp \
+ katemailfilesdialog.cpp kbookmarkhandler.cpp \
+ katedocmanageriface.skel kateappIface.cpp kateappIface.skel katedocmanageriface.cpp \
+ kateexternaltools.cpp katesavemodifieddialog.cpp kateviewspacecontainer.cpp \
+ katemwmodonhddialog.cpp katesession.cpp katemdi.cpp katetabwidget.cpp
+
+libkateinterfaces_la_LIBADD = ../interfaces/libkateinterfacesprivate.la $(LIB_TDEUTILS) ../utils/libkateutils.la
+
+libkateinterfaces_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -no-undefined
+
+kate_la_SOURCES = katemain.cpp
+kate_la_LIBADD = libkateinterfaces.la
+kate_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -module -avoid-version
+
+kwrite_la_SOURCES = kwritemain.cpp
+kwrite_la_LIBADD = -lkatepartinterfaces ../utils/libkateutils.la
+kwrite_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -module -avoid-version
+
+METASOURCES = AUTO
+
+INCLUDES= -I../interfaces -I$(srcdir)/../lib $(all_includes)
diff --git a/kate/app/kateapp.cpp b/kate/app/kateapp.cpp
new file mode 100644
index 000000000..9cba61cc6
--- /dev/null
+++ b/kate/app/kateapp.cpp
@@ -0,0 +1,403 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "kateapp.h"
+#include "kateapp.moc"
+
+#include "katedocmanager.h"
+#include "katepluginmanager.h"
+#include "kateviewmanager.h"
+#include "kateappIface.h"
+#include "katesession.h"
+#include "katemainwindow.h"
+
+#include "../interfaces/application.h"
+
+#include <tdeversion.h>
+#include <tdecmdlineargs.h>
+#include <dcopclient.h>
+#include <tdeconfig.h>
+#include <twin.h>
+#include <ktip.h>
+#include <kdebug.h>
+#include <klibloader.h>
+#include <tdemessagebox.h>
+#include <tdelocale.h>
+#include <ksimpleconfig.h>
+#include <tdestartupinfo.h>
+
+#include <tqfile.h>
+#include <tqtimer.h>
+#include <tqdir.h>
+#include <tqtextcodec.h>
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+KateApp::KateApp (TDECmdLineArgs *args)
+ : TDEApplication ()
+ , m_args (args)
+ , m_shouldExit (false)
+{
+ // Don't handle DCOP requests yet
+ dcopClient()->suspend();
+
+ // insert right translations for the katepart
+ TDEGlobal::locale()->insertCatalogue("katepart");
+
+ // some global default
+ Kate::Document::setFileChangedDialogsActivated (true);
+
+ // application interface
+ m_application = new Kate::Application (this);
+
+ // doc + project man
+ m_docManager = new KateDocManager (TQT_TQOBJECT(this));
+
+ // init all normal plugins
+ m_pluginManager = new KatePluginManager (TQT_TQOBJECT(this));
+
+ // session manager up
+ m_sessionManager = new KateSessionManager (TQT_TQOBJECT(this));
+
+ // application dcop interface
+ m_obj = new KateAppDCOPIface (this);
+
+ kdDebug()<<"Setting KATE_PID: '"<<getpid()<<"'"<<endl;
+ ::setenv( "KATE_PID", TQString(TQString("%1").arg(getpid())).latin1(), 1 );
+
+ // handle restore different
+ if (isRestored())
+ {
+ restoreKate ();
+ }
+ else
+ {
+ // let us handle our command line args and co ;)
+ // we can exit here if session chooser decides
+ if (!startupKate ())
+ {
+ m_shouldExit = true;
+ return;
+ }
+ }
+
+ // Ok. We are ready for DCOP requests.
+ dcopClient()->resume();
+}
+
+KateApp::~KateApp ()
+{
+ // cu dcop interface
+ delete m_obj;
+
+ // cu plugin manager
+ delete m_pluginManager;
+
+ // delete this now, or we crash
+ delete m_docManager;
+}
+
+KateApp *KateApp::self ()
+{
+ return (KateApp *) kapp;
+}
+
+Kate::Application *KateApp::application ()
+{
+ return m_application;
+}
+
+/**
+ * Has always been the Kate Versioning Scheme:
+ * KDE X.Y.Z contains Kate X-1.Y.Z
+ */
+TQString KateApp::kateVersion (bool fullVersion)
+{
+// return fullVersion ? TQString ("%1.%2.%3").arg(KDE::versionMajor() - 1).arg(KDE::versionMinor()).arg(KDE::versionRelease())
+// : TQString ("%1.%2").arg(KDE::versionMajor() - 1).arg(KDE::versionMinor());
+ /** The previous version computation scheme (commented out above) worked fine in the 3.5.x days.
+ With the new Trinity Rx.y.z scheme the version number gets weird.
+ We now hard-code the first two numbers to match the 3.5.x days and only update the last number. */
+ return fullVersion ? TQString ("2.5.%1").arg(KDE::versionMajor()) : TQString ("%1.%2").arg(2.5);
+}
+
+void KateApp::restoreKate ()
+{
+ // restore the nice files ;) we need it
+ Kate::Document::setOpenErrorDialogsActivated (false);
+
+ // activate again correct session!!!
+ sessionConfig()->setGroup("General");
+ TQString lastSession (sessionConfig()->readEntry ("Last Session", "default.katesession"));
+ sessionManager()->activateSession (new KateSession (sessionManager(), lastSession, ""), false, false, false);
+
+ m_docManager->restoreDocumentList (sessionConfig());
+
+ Kate::Document::setOpenErrorDialogsActivated (true);
+
+ // restore all windows ;)
+ for (int n=1; TDEMainWindow::canBeRestored(n); n++)
+ newMainWindow(sessionConfig(), TQString ("%1").arg(n));
+
+ // oh, no mainwindow, create one, should not happen, but make sure ;)
+ if (mainWindows() == 0)
+ newMainWindow ();
+
+ // Do not notify about start there: this makes kicker crazy and kate go to a wrong desktop.
+ // TDEStartupInfo::setNewStartupId( activeMainWindow(), startupId());
+}
+
+bool KateApp::startupKate ()
+{
+ // user specified session to open
+ if (m_args->isSet ("start"))
+ {
+ sessionManager()->activateSession (sessionManager()->giveSession (TQString::fromLocal8Bit(m_args->getOption("start"))), false, false);
+ }
+ else
+ {
+ // let the user choose session if possible
+ if (!sessionManager()->chooseSession ())
+ {
+ // we will exit kate now, notify the rest of the world we are done
+ TDEStartupInfo::appStarted (startupId());
+ return false;
+ }
+ }
+
+ // oh, no mainwindow, create one, should not happen, but make sure ;)
+ if (mainWindows() == 0)
+ newMainWindow ();
+
+ // notify about start
+ TDEStartupInfo::setNewStartupId( activeMainWindow(), startupId());
+
+ TQTextCodec *codec = m_args->isSet("encoding") ? TQTextCodec::codecForName(m_args->getOption("encoding")) : 0;
+
+ bool tempfileSet = TDECmdLineArgs::isTempFileSet();
+
+ Kate::Document::setOpenErrorDialogsActivated (false);
+ uint id = 0;
+ for (int z=0; z<m_args->count(); z++)
+ {
+ // this file is no local dir, open it, else warn
+ bool noDir = !m_args->url(z).isLocalFile() || !TQDir (m_args->url(z).path()).exists();
+
+ if (noDir)
+ {
+ // open a normal file
+ if (codec)
+ id = activeMainWindow()->viewManager()->openURL( m_args->url(z), codec->name(), false, tempfileSet );
+ else
+ id = activeMainWindow()->viewManager()->openURL( m_args->url(z), TQString::null, false, tempfileSet );
+ }
+ else
+ KMessageBox::sorry( activeMainWindow(),
+ i18n("The file '%1' could not be opened: it is not a normal file, it is a folder.").arg(m_args->url(z).url()) );
+ }
+
+ Kate::Document::setOpenErrorDialogsActivated (true);
+
+ // handle stdin input
+ if( m_args->isSet( "stdin" ) )
+ {
+ TQTextIStream input(stdin);
+
+ // set chosen codec
+ if (codec)
+ input.setCodec (codec);
+
+ TQString line;
+ TQString text;
+
+ do
+ {
+ line = input.readLine();
+ text.append( line + "\n" );
+ } while( !line.isNull() );
+
+ openInput (text);
+ }
+ else if ( id )
+ activeMainWindow()->viewManager()->activateView( id );
+
+ if ( activeMainWindow()->viewManager()->viewCount () == 0 )
+ activeMainWindow()->viewManager()->activateView(m_docManager->firstDocument()->documentNumber());
+
+ int line = 0;
+ int column = 0;
+ bool nav = false;
+
+ if (m_args->isSet ("line"))
+ {
+ line = m_args->getOption ("line").toInt();
+ nav = true;
+ }
+
+ if (m_args->isSet ("column"))
+ {
+ column = m_args->getOption ("column").toInt();
+ nav = true;
+ }
+
+ if (nav)
+ activeMainWindow()->viewManager()->activeView ()->setCursorPosition (line, column);
+
+ // show the nice tips
+ KTipDialog::showTip(activeMainWindow());
+
+ return true;
+}
+
+void KateApp::shutdownKate (KateMainWindow *win)
+{
+ if (!win->queryClose_internal())
+ return;
+
+ sessionManager()->saveActiveSession(true, true);
+
+ // detach the dcopClient
+ dcopClient()->detach();
+
+ // cu main windows
+ while (!m_mainWindows.isEmpty())
+ delete m_mainWindows[0];
+
+ quit ();
+}
+
+KatePluginManager *KateApp::pluginManager()
+{
+ return m_pluginManager;
+}
+
+KateDocManager *KateApp::documentManager ()
+{
+ return m_docManager;
+}
+
+KateSessionManager *KateApp::sessionManager ()
+{
+ return m_sessionManager;
+}
+
+bool KateApp::openURL (const KURL &url, const TQString &encoding, bool isTempFile)
+{
+ KateMainWindow *mainWindow = activeMainWindow ();
+
+ if (!mainWindow)
+ return false;
+
+ TQTextCodec *codec = encoding.isEmpty() ? 0 : TQTextCodec::codecForName(encoding.latin1());
+
+ kdDebug () << "OPEN URL "<< encoding << endl;
+
+ // this file is no local dir, open it, else warn
+ bool noDir = !url.isLocalFile() || !TQDir (url.path()).exists();
+
+ if (noDir)
+ {
+ // open a normal file
+ if (codec)
+ mainWindow->viewManager()->openURL( url, codec->name(), true, isTempFile );
+ else
+ mainWindow->viewManager()->openURL( url, TQString::null, true, isTempFile );
+ }
+ else
+ KMessageBox::sorry( mainWindow,
+ i18n("The file '%1' could not be opened: it is not a normal file, it is a folder.").arg(url.url()) );
+
+ return true;
+}
+
+bool KateApp::setCursor (int line, int column)
+{
+ KateMainWindow *mainWindow = activeMainWindow ();
+
+ if (!mainWindow)
+ return false;
+
+ mainWindow->viewManager()->activeView ()->setCursorPosition (line, column);
+
+ return true;
+}
+
+bool KateApp::openInput (const TQString &text)
+{
+ activeMainWindow()->viewManager()->openURL( "", "", true );
+
+ if (!activeMainWindow()->viewManager()->activeView ())
+ return false;
+
+ activeMainWindow()->viewManager()->activeView ()->getDoc()->setText (text);
+
+ return true;
+}
+
+KateMainWindow *KateApp::newMainWindow (TDEConfig *sconfig, const TQString &sgroup)
+{
+ KateMainWindow *mainWindow = new KateMainWindow (sconfig, sgroup);
+ m_mainWindows.push_back (mainWindow);
+
+ if ((mainWindows() > 1) && m_mainWindows[m_mainWindows.count()-2]->viewManager()->activeView())
+ mainWindow->viewManager()->activateView ( m_mainWindows[m_mainWindows.count()-2]->viewManager()->activeView()->getDoc()->documentNumber() );
+ else if ((mainWindows() > 1) && (m_docManager->documents() > 0))
+ mainWindow->viewManager()->activateView ( (m_docManager->document(m_docManager->documents()-1))->documentNumber() );
+ else if ((mainWindows() > 1) && (m_docManager->documents() < 1))
+ mainWindow->viewManager()->openURL ( KURL() );
+
+ mainWindow->show ();
+
+ return mainWindow;
+}
+
+void KateApp::removeMainWindow (KateMainWindow *mainWindow)
+{
+ m_mainWindows.remove (mainWindow);
+}
+
+KateMainWindow *KateApp::activeMainWindow ()
+{
+ if (m_mainWindows.isEmpty())
+ return 0;
+
+ int n = m_mainWindows.findIndex ((KateMainWindow *)activeWindow());
+
+ if (n < 0)
+ n=0;
+
+ return m_mainWindows[n];
+}
+
+uint KateApp::mainWindows () const
+{
+ return m_mainWindows.size();
+}
+
+KateMainWindow *KateApp::mainWindow (uint n)
+{
+ if (n < m_mainWindows.size())
+ return m_mainWindows[n];
+
+ return 0;
+}
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/kateapp.h b/kate/app/kateapp.h
new file mode 100644
index 000000000..05d09a7fe
--- /dev/null
+++ b/kate/app/kateapp.h
@@ -0,0 +1,243 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __KATE_APP_H__
+#define __KATE_APP_H__
+
+#include "katemain.h"
+
+#include <tdeapplication.h>
+
+#include <tqvaluelist.h>
+
+class KateSessionManager;
+class KateAppDCOPIface;
+
+namespace Kate {
+ class Application;
+}
+
+class TDECmdLineArgs;
+
+/**
+ * Kate Application
+ * This class represents the core kate application object
+ */
+class KDE_EXPORT KateApp : public TDEApplication
+{
+ Q_OBJECT
+
+ /**
+ * constructors & accessor to app object + plugin interface for it
+ */
+ public:
+ /**
+ * application constructor
+ * @param args parsed command line args
+ */
+ KateApp (TDECmdLineArgs *args);
+
+ /**
+ * application destructor
+ */
+ ~KateApp ();
+
+ /**
+ * static accessor to avoid casting ;)
+ * @return app instance
+ */
+ static KateApp *self ();
+
+ /**
+ * accessor to the Kate::Application plugin interface
+ * @return application plugin interface
+ */
+ Kate::Application *application ();
+
+ /**
+ * Returns the current Kate version (X.Y) or (X.Y.Z)
+ * @param fullVersion should full version be returned?
+ * @return Kate version
+ */
+ static TQString kateVersion (bool fullVersion = true);
+
+ /**
+ * kate init
+ */
+ private:
+ /**
+ * restore a old kate session
+ */
+ void restoreKate ();
+
+ /**
+ * try to start kate
+ * @return success, if false, kate should exit
+ */
+ bool startupKate ();
+
+ /**
+ * kate shutdown
+ */
+ public:
+ /**
+ * shutdown kate application
+ * @param win mainwindow which is used for dialogs
+ */
+ void shutdownKate (KateMainWindow *win);
+
+ /**
+ * application should exit
+ * @return should we exit?
+ */
+ bool shouldExit () { return m_shouldExit; }
+
+ /**
+ * other accessors for global unique instances
+ */
+ public:
+ /**
+ * accessor to plugin manager
+ * @return plugin manager instance
+ */
+ KatePluginManager *pluginManager();
+
+ /**
+ * accessor to document manager
+ * @return document manager instance
+ */
+ KateDocManager *documentManager ();
+
+ /**
+ * accessor to session manager
+ * @return session manager instance
+ */
+ KateSessionManager *sessionManager ();
+
+ /**
+ * window management
+ */
+ public:
+ /**
+ * create a new main window, use given config if any for restore
+ * @param sconfig session config object
+ * @param sgroup session group for this window
+ * @return new constructed main window
+ */
+ KateMainWindow *newMainWindow (TDEConfig *sconfig = 0, const TQString &sgroup = "");
+
+ /**
+ * removes the mainwindow given, DOES NOT DELETE IT
+ * @param mainWindow window to remove
+ */
+ void removeMainWindow (KateMainWindow *mainWindow);
+
+ /**
+ * give back current active main window
+ * can only be 0 at app start or exit
+ * @return current active main window
+ */
+ KateMainWindow *activeMainWindow ();
+
+ /**
+ * give back number of existing main windows
+ * @return number of main windows
+ */
+ uint mainWindows () const;
+
+ /**
+ * give back the window you want
+ * @param n window index
+ * @return requested main window
+ */
+ KateMainWindow *mainWindow (uint n);
+
+ /**
+ * some stuff for the dcop API
+ */
+ public:
+ /**
+ * open url with given encoding
+ * used by kate if --use given
+ * @param url filename
+ * @param encoding encoding name
+ * @param isTempFile if set to true and the file is a local file, it will be deleted when the document is closed.
+ * @return success
+ */
+ bool openURL (const KURL &url, const TQString &encoding, bool isTempFile );
+
+ /**
+ * position cursor in current active view
+ * @param line line to set
+ * @param column column to set
+ * @return success
+ */
+ bool setCursor (int line, int column);
+
+ /**
+ * helper to handle stdin input
+ * open a new document/view, fill it with the text given
+ * @param text text to fill in the new doc/view
+ * @return success
+ */
+ bool openInput (const TQString &text);
+
+ private:
+ /**
+ * kate's command line args
+ */
+ TDECmdLineArgs *m_args;
+
+ /**
+ * plugin interface
+ */
+ Kate::Application *m_application;
+
+ /**
+ * document manager
+ */
+ KateDocManager *m_docManager;
+
+ /**
+ * plugin manager
+ */
+ KatePluginManager *m_pluginManager;
+
+ /**
+ * session manager
+ */
+ KateSessionManager *m_sessionManager;
+
+ /**
+ * known main windows
+ */
+ TQValueList<KateMainWindow*> m_mainWindows;
+
+ /**
+ * dcop interface
+ */
+ KateAppDCOPIface *m_obj;
+
+ /**
+ * should exit flag
+ */
+ bool m_shouldExit;
+};
+
+#endif
diff --git a/kate/app/kateappIface.cpp b/kate/app/kateappIface.cpp
new file mode 100644
index 000000000..259e48b89
--- /dev/null
+++ b/kate/app/kateappIface.cpp
@@ -0,0 +1,104 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "kateappIface.h"
+
+#include "kateapp.h"
+#include "katesession.h"
+#include "katedocmanager.h"
+#include "katemainwindow.h"
+
+KateAppDCOPIface::KateAppDCOPIface (KateApp *app) : DCOPObject ("KateApplication")
+ , m_app (app)
+{
+}
+
+DCOPRef KateAppDCOPIface::documentManager ()
+{
+ return DCOPRef (m_app->documentManager()->dcopObject ());
+}
+
+DCOPRef KateAppDCOPIface::activeMainWindow ()
+{
+ KateMainWindow *win = m_app->activeMainWindow();
+
+ if (win)
+ return DCOPRef (win->dcopObject ());
+
+ return DCOPRef ();
+}
+
+uint KateAppDCOPIface::activeMainWindowNumber ()
+{
+ KateMainWindow *win = m_app->activeMainWindow();
+
+ if (win)
+ return win->mainWindowNumber ();
+
+ return 0;
+}
+
+
+uint KateAppDCOPIface::mainWindows ()
+{
+ return m_app->mainWindows ();
+}
+
+DCOPRef KateAppDCOPIface::mainWindow (uint n)
+{
+ KateMainWindow *win = m_app->mainWindow(n);
+
+ if (win)
+ return DCOPRef (win->dcopObject ());
+
+ return DCOPRef ();
+}
+
+bool KateAppDCOPIface::openURL (KURL url, TQString encoding)
+{
+ return m_app->openURL (url, encoding, false);
+}
+
+bool KateAppDCOPIface::openURL (KURL url, TQString encoding, bool isTempFile)
+{
+ return m_app->openURL (url, encoding, isTempFile);
+}
+
+bool KateAppDCOPIface::setCursor (int line, int column)
+{
+ return m_app->setCursor (line, column);
+}
+
+bool KateAppDCOPIface::openInput (TQString text)
+{
+ return m_app->openInput (text);
+}
+
+bool KateAppDCOPIface::activateSession (TQString session)
+{
+ m_app->sessionManager()->activateSession (m_app->sessionManager()->giveSession (session));
+
+ return true;
+}
+
+const TQString & KateAppDCOPIface::session() const
+{
+ return m_app->sessionManager()->activeSession()->sessionName();
+}
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/kateappIface.h b/kate/app/kateappIface.h
new file mode 100644
index 000000000..c57e788c8
--- /dev/null
+++ b/kate/app/kateappIface.h
@@ -0,0 +1,94 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _kateapp_Iface_h_
+#define _kateapp_Iface_h_
+
+#include <dcopobject.h>
+#include <dcopref.h>
+#include <kurl.h>
+
+class KateApp;
+
+class KateAppDCOPIface : public DCOPObject
+{
+ K_DCOP
+
+ public:
+ KateAppDCOPIface (KateApp *app);
+
+ k_dcop:
+ DCOPRef documentManager ();
+
+ DCOPRef activeMainWindow ();
+
+ uint activeMainWindowNumber ();
+
+ uint mainWindows ();
+ DCOPRef mainWindow (uint n = 0);
+
+ /**
+ * open a file with given url and encoding
+ * will get view created
+ * @param url url of the file
+ * @param encoding encoding name
+ * @return success
+ */
+ bool openURL (KURL url, TQString encoding);
+
+ /**
+ * Like the above, but adds an option to let the documentManager know
+ * if the file should be deleted when closed.
+ * @p isTempFile should be set to true with the --tempfile option set ONLY,
+ * files opened with this set to true will be deleted when closed.
+ */
+ bool openURL(KURL url, TQString encoding, bool isTempFile);
+
+ /**
+ * set cursor of active view in active main window
+ * @param line line for cursor
+ * @param column column for cursor
+ * @return success
+ */
+ bool setCursor (int line, int column);
+
+ /**
+ * helper to handle stdin input
+ * open a new document/view, fill it with the text given
+ * @param text text to fill in the new doc/view
+ * @return success
+ */
+ bool openInput (TQString text);
+
+ /**
+ * activate a given session
+ * @param session session name
+ * @return success
+ */
+ bool activateSession (TQString session);
+
+ /**
+ * @return the name of the active session
+ */
+ const TQString & session() const;
+
+ private:
+ KateApp *m_app;
+};
+
+#endif
diff --git a/kate/app/kateconfigdialog.cpp b/kate/app/kateconfigdialog.cpp
new file mode 100644
index 000000000..697e46644
--- /dev/null
+++ b/kate/app/kateconfigdialog.cpp
@@ -0,0 +1,476 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "kateconfigdialog.h"
+#include "kateconfigdialog.moc"
+
+#include "katemainwindow.h"
+
+#include "kateconsole.h"
+#include "katedocmanager.h"
+#include "katepluginmanager.h"
+#include "kateconfigplugindialogpage.h"
+#include "kateviewmanager.h"
+#include "kateapp.h"
+#include "katefileselector.h"
+#include "katefilelist.h"
+#include "kateexternaltools.h"
+
+#include <tqbuttongroup.h>
+#include <tqcheckbox.h>
+#include <tqhbox.h>
+#include <tqlabel.h>
+#include <tqlayout.h>
+#include <tqpushbutton.h>
+#include <tqradiobutton.h>
+#include <tqspinbox.h>
+#include <tqvbox.h>
+#include <tqwhatsthis.h>
+#include <tqcombobox.h>
+
+#include <kinstance.h>
+#include <kdebug.h>
+#include <kdialogbase.h>
+#include <kglobalaccel.h>
+#include <tdeglobal.h>
+#include <tdeglobalsettings.h>
+#include <kiconloader.h>
+#include <kkeydialog.h>
+#include <tdelistbox.h>
+#include <tdelocale.h>
+#include <ksimpleconfig.h>
+#include <kstdaction.h>
+#include <kstandarddirs.h>
+#include <twin.h>
+#include <kseparator.h>
+
+KateConfigDialog::KateConfigDialog ( KateMainWindow *parent, Kate::View *view )
+ : KDialogBase ( KDialogBase::TreeList,
+ i18n("Configure"),
+ KDialogBase::Ok | KDialogBase::Apply|KDialogBase::Cancel | KDialogBase::Help,
+ KDialogBase::Ok,
+ parent,
+ "configdialog" )
+{
+ TDEConfig *config = KateApp::self()->config();
+
+ KWin::setIcons( winId(), KateApp::self()->icon(), KateApp::self()->miniIcon() );
+
+ actionButton( KDialogBase::Apply)->setEnabled( false );
+
+ mainWindow = parent;
+
+ setMinimumSize(600,400);
+
+ v = view;
+
+ pluginPages.setAutoDelete (false);
+ editorPages.setAutoDelete (false);
+
+ TQStringList path;
+
+ setShowIconsInTreeList(true);
+
+ path.clear();
+ path << i18n("Application");
+ setFolderIcon (path, SmallIcon("kate", TDEIcon::SizeSmall));
+
+ path.clear();
+
+ //BEGIN General page
+ path << i18n("Application") << i18n("General");
+ TQFrame* frGeneral = addPage(path, i18n("General Options"), BarIcon("gohome", TDEIcon::SizeSmall));
+
+ TQVBoxLayout *lo = new TQVBoxLayout( frGeneral );
+ lo->setSpacing(KDialog::spacingHint());
+ config->setGroup("General");
+
+ // GROUP with the one below: "Appearance"
+ TQButtonGroup *bgStartup = new TQButtonGroup( 1, Qt::Horizontal, i18n("&Appearance"), frGeneral );
+ lo->addWidget( bgStartup );
+
+ // show full path in title
+ config->setGroup("General");
+ cb_fullPath = new TQCheckBox( i18n("&Show full path in title"), bgStartup);
+ cb_fullPath->setChecked( mainWindow->viewManager()->getShowFullPath() );
+ TQWhatsThis::add(cb_fullPath,i18n("If this option is checked, the full document path will be shown in the window caption."));
+ connect( cb_fullPath, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotChanged() ) );
+
+ // sort filelist if desired
+ cb_sortFiles = new TQCheckBox(bgStartup);
+ cb_sortFiles->setText(i18n("Sort &files alphabetically in the file list"));
+ cb_sortFiles->setChecked(parent->filelist->sortType() == KateFileList::sortByName);
+ TQWhatsThis::add( cb_sortFiles, i18n(
+ "If this is checked, the files in the file list will be sorted alphabetically.") );
+ connect( cb_sortFiles, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotChanged() ) );
+
+ // GROUP with the one below: "Behavior"
+ bgStartup = new TQButtonGroup( 1, Qt::Horizontal, i18n("&Behavior"), frGeneral );
+ lo->addWidget( bgStartup );
+
+ // number of recent files
+ TQHBox *hbNrf = new TQHBox( bgStartup );
+ TQLabel *lNrf = new TQLabel( i18n("&Number of recent files:"), hbNrf );
+ sb_numRecentFiles = new TQSpinBox( 0, 1000, 1, hbNrf );
+ sb_numRecentFiles->setValue( mainWindow->fileOpenRecent->maxItems() );
+ lNrf->setBuddy( sb_numRecentFiles );
+ TQString numRecentFileHelpString ( i18n(
+ "<qt>Sets the number of recent files remembered by Kate.<p><strong>NOTE: </strong>"
+ "If you set this lower than the current value, the list will be truncated and "
+ "some items forgotten.</qt>") );
+ TQWhatsThis::add( lNrf, numRecentFileHelpString );
+ TQWhatsThis::add( sb_numRecentFiles, numRecentFileHelpString );
+ connect( sb_numRecentFiles, TQT_SIGNAL( valueChanged ( int ) ), this, TQT_SLOT( slotChanged() ) );
+
+ // Use only one instance of kate (MDI) ?
+ cb_useInstance = new TQCheckBox(bgStartup);
+ cb_useInstance->setText(i18n("Always use the current instance of kate to open new files"));
+ cb_useInstance->setChecked(parent->useInstance);
+ TQWhatsThis::add( cb_useInstance, i18n(
+ "When checked, all files opened from outside of Kate will only use the "
+ "currently opened instance of Kate.") );
+ connect( cb_useInstance, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotChanged() ) );
+
+ // sync the konsole ?
+ cb_syncKonsole = new TQCheckBox(bgStartup);
+ cb_syncKonsole->setText(i18n("Sync &terminal emulator with active document"));
+ cb_syncKonsole->setChecked(parent->syncKonsole);
+ TQWhatsThis::add( cb_syncKonsole, i18n(
+ "If this is checked, the built in Konsole will <code>cd</code> to the directory "
+ "of the active document when started and whenever the active document changes, "
+ "if the document is a local file.") );
+ connect( cb_syncKonsole, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotChanged() ) );
+
+ // modified files notification
+ cb_modNotifications = new TQCheckBox(
+ i18n("Wa&rn about files modified by foreign processes"), bgStartup );
+ cb_modNotifications->setChecked( parent->modNotification );
+ TQWhatsThis::add( cb_modNotifications, i18n(
+ "If enabled, when Kate receives focus you will be asked what to do with "
+ "files that have been modified on the hard disk. If not enabled, you will "
+ "be asked what to do with a file that has been modified on the hard disk only "
+ "when that file gains focus inside Kate.") );
+ connect( cb_modNotifications, TQT_SIGNAL( toggled( bool ) ),
+ this, TQT_SLOT( slotChanged() ) );
+
+ // GROUP with the one below: "Meta-informations"
+ bgStartup = new TQButtonGroup( 2, Qt::Horizontal, i18n("Meta-Information"), frGeneral );
+ lo->addWidget( bgStartup );
+
+ // save meta infos
+ cb_saveMetaInfos = new TQCheckBox( bgStartup );
+ cb_saveMetaInfos->setText(i18n("Keep &meta-information past sessions"));
+ cb_saveMetaInfos->setChecked(KateDocManager::self()->getSaveMetaInfos());
+ TQWhatsThis::add(cb_saveMetaInfos, i18n(
+ "Check this if you want document configuration like for example "
+ "bookmarks to be saved past editor sessions. The configuration will be "
+ "restored if the document has not changed when reopened."));
+ connect( cb_saveMetaInfos, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotChanged() ) );
+
+ // meta infos days
+ TQHBox *hbDmf = new TQHBox( bgStartup );
+ hbDmf->setEnabled(KateDocManager::self()->getSaveMetaInfos());
+ TQLabel *lDmf = new TQLabel( i18n("&Delete unused meta-information after:"), hbDmf );
+ sb_daysMetaInfos = new TQSpinBox( 0, 180, 1, hbDmf );
+ sb_daysMetaInfos->setSpecialValueText(i18n("(never)"));
+ sb_daysMetaInfos->setSuffix(i18n(" day(s)"));
+ sb_daysMetaInfos->setValue( KateDocManager::self()->getDaysMetaInfos() );
+ lDmf->setBuddy( sb_daysMetaInfos );
+ connect( cb_saveMetaInfos, TQT_SIGNAL( toggled( bool ) ), hbDmf, TQT_SLOT( setEnabled( bool ) ) );
+ connect( sb_daysMetaInfos, TQT_SIGNAL( valueChanged ( int ) ), this, TQT_SLOT( slotChanged() ) );
+
+ lo->addStretch(1); // :-] works correct without autoadd
+ //END General page
+
+ path.clear();
+
+ //BEGIN Session page
+ path << i18n("Application") << i18n("Sessions");
+ TQFrame* frSessions = addPage(path, i18n("Session Management"), BarIcon("history", TDEIcon::SizeSmall));
+
+ lo = new TQVBoxLayout( frSessions );
+ lo->setSpacing(KDialog::spacingHint());
+
+ // GROUP with the one below: "Startup"
+ bgStartup = new TQButtonGroup( 1, Qt::Horizontal, i18n("Elements of Sessions"), frSessions );
+ lo->addWidget( bgStartup );
+
+ // restore view config
+ cb_restoreVC = new TQCheckBox( bgStartup );
+ cb_restoreVC->setText(i18n("Include &window configuration"));
+ config->setGroup("General");
+ cb_restoreVC->setChecked( config->readBoolEntry("Restore Window Configuration", true) );
+ TQWhatsThis::add(cb_restoreVC, i18n(
+ "Check this if you want all your views and frames restored each time you open Kate"));
+ connect( cb_restoreVC, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotChanged() ) );
+
+ TQRadioButton *rb1, *rb2, *rb3;
+
+ sessions_start = new TQButtonGroup( 1, Qt::Horizontal, i18n("Behavior on Application Startup"), frSessions );
+ lo->add (sessions_start);
+
+ sessions_start->setRadioButtonExclusive( true );
+ sessions_start->insert( rb1=new TQRadioButton( i18n("&Start new session"), sessions_start ), 0 );
+ sessions_start->insert( rb2=new TQRadioButton( i18n("&Load last-used session"), sessions_start ), 1 );
+ sessions_start->insert( rb3=new TQRadioButton( i18n("&Manually choose a session"), sessions_start ), 2 );
+
+ config->setGroup("General");
+ TQString sesStart (config->readEntry ("Startup Session", "manual"));
+ if (sesStart == "new")
+ sessions_start->setButton (0);
+ else if (sesStart == "last")
+ sessions_start->setButton (1);
+ else
+ sessions_start->setButton (2);
+
+ connect(rb1, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotChanged()));
+ connect(rb2, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotChanged()));
+ connect(rb3, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotChanged()));
+
+ sessions_exit = new TQButtonGroup( 1, Qt::Horizontal, i18n("Behavior on Application Exit or Session Switch"), frSessions );
+ lo->add (sessions_exit);
+
+ sessions_exit->setRadioButtonExclusive( true );
+ sessions_exit->insert( rb1=new TQRadioButton( i18n("&Do not save session"), sessions_exit ), 0 );
+ sessions_exit->insert( rb2=new TQRadioButton( i18n("&Save session"), sessions_exit ), 1 );
+ sessions_exit->insert( rb3=new TQRadioButton( i18n("&Ask user"), sessions_exit ), 2 );
+
+ config->setGroup("General");
+ TQString sesExit (config->readEntry ("Session Exit", "save"));
+ if (sesExit == "discard")
+ sessions_exit->setButton (0);
+ else if (sesExit == "save")
+ sessions_exit->setButton (1);
+ else
+ sessions_exit->setButton (2);
+
+ connect(rb1, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotChanged()));
+ connect(rb2, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotChanged()));
+ connect(rb3, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotChanged()));
+
+ lo->addStretch(1); // :-] works correct without autoadd
+ //END Session page
+
+ path.clear();
+
+ // file selector page
+ path << i18n("Application") << i18n("File Selector");
+
+ TQVBox *page = addVBoxPage( path, i18n("File Selector Settings"),
+ BarIcon("fileopen", TDEIcon::SizeSmall) );
+ fileSelConfigPage = new KFSConfigPage( page, "file selector config page",
+ mainWindow->fileselector );
+ connect( fileSelConfigPage, TQT_SIGNAL( changed() ), this, TQT_SLOT( slotChanged() ) );
+ path.clear();
+
+ path << i18n("Application") << i18n("Document List");
+ page = addVBoxPage( path, i18n("Document List Settings"),
+ BarIcon("view_text", TDEIcon::SizeSmall) );
+ filelistConfigPage = new KFLConfigPage( page, "file list config page",
+ mainWindow->filelist );
+ connect( filelistConfigPage, TQT_SIGNAL( changed() ), this, TQT_SLOT( slotChanged() ) );
+ path.clear();
+
+ path << i18n("Application") << i18n("Plugins");
+ /*TQVBox **/page=addVBoxPage(path,i18n("Plugin Manager"),
+ BarIcon("connect_established",TDEIcon::SizeSmall));
+ KateConfigPluginPage *configPluginPage = new KateConfigPluginPage(page, this);
+ connect( configPluginPage, TQT_SIGNAL( changed() ), TQT_TQOBJECT(this), TQT_SLOT( slotChanged() ) );
+
+ // Tools->External Tools menu
+ path.clear();
+ path << i18n("Application") << i18n("External Tools");
+ page = addVBoxPage( path, i18n("External Tools"),
+ BarIcon("configure", TDEIcon::SizeSmall) );
+ configExternalToolsPage = new KateExternalToolsConfigWidget(page, "external tools config page");
+ connect( configExternalToolsPage, TQT_SIGNAL(changed()), TQT_TQOBJECT(this), TQT_SLOT(slotChanged()) );
+
+ // editor widgets from kwrite/kwdialog
+ path.clear();
+ path << i18n("Editor");
+ setFolderIcon (path, SmallIcon("edit", TDEIcon::SizeSmall));
+
+ for (uint i = 0; i < KTextEditor::configInterfaceExtension (v->document())->configPages (); i++)
+ {
+ path.clear();
+ path << i18n("Editor") << KTextEditor::configInterfaceExtension (v->document())->configPageName (i);
+ /*TQVBox **/page = addVBoxPage(path, KTextEditor::configInterfaceExtension (v->document())->configPageFullName (i),
+ KTextEditor::configInterfaceExtension (v->document())->configPagePixmap(i, TDEIcon::SizeSmall) );
+
+ KTextEditor::ConfigPage *cPage = KTextEditor::configInterfaceExtension (v->document())->configPage(i, page);
+ connect( cPage, TQT_SIGNAL( changed() ), this, TQT_SLOT( slotChanged() ) );
+ editorPages.append (cPage);
+ }
+
+ KatePluginList &pluginList (KatePluginManager::self()->pluginList());
+ for (unsigned int i=0; i < pluginList.size(); ++i)
+ {
+ if ( pluginList[i].load
+ && Kate::pluginConfigInterfaceExtension(pluginList[i].plugin) )
+ addPluginPage (pluginList[i].plugin);
+ }
+
+ enableButtonSeparator(true);
+ dataChanged = false;
+ unfoldTreeList ();
+}
+
+KateConfigDialog::~KateConfigDialog()
+{
+}
+
+void KateConfigDialog::addPluginPage (Kate::Plugin *plugin)
+{
+ if (!Kate::pluginConfigInterfaceExtension(plugin))
+ return;
+
+ for (uint i=0; i<Kate::pluginConfigInterfaceExtension(plugin)->configPages(); i++)
+ {
+ TQStringList path;
+ path.clear();
+ path << i18n("Application")<<i18n("Plugins") << Kate::pluginConfigInterfaceExtension(plugin)->configPageName(i);
+ TQVBox *page=addVBoxPage(path, Kate::pluginConfigInterfaceExtension(plugin)->configPageFullName(i), Kate::pluginConfigInterfaceExtension(plugin)->configPagePixmap(i, TDEIcon::SizeSmall));
+
+ PluginPageListItem *info=new PluginPageListItem;
+ info->plugin = plugin;
+ info->page = Kate::pluginConfigInterfaceExtension(plugin)->configPage (i, page);
+ connect( info->page, TQT_SIGNAL( changed() ), this, TQT_SLOT( slotChanged() ) );
+ pluginPages.append(info);
+ }
+}
+
+void KateConfigDialog::removePluginPage (Kate::Plugin *plugin)
+{
+ if (!Kate::pluginConfigInterfaceExtension(plugin))
+ return;
+
+ for (uint i=0; i<pluginPages.count(); i++)
+ {
+ if ( pluginPages.at(i)->plugin == plugin )
+ {
+ TQWidget *w = pluginPages.at(i)->page->parentWidget();
+ delete pluginPages.at(i)->page;
+ delete w;
+ pluginPages.remove(pluginPages.at(i));
+ i--;
+ }
+ }
+}
+
+void KateConfigDialog::slotOk()
+{
+ slotApply();
+ accept();
+}
+
+void KateConfigDialog::slotApply()
+{
+ TDEConfig *config = KateApp::self()->config();
+
+ // if data changed apply the kate app stuff
+ if( dataChanged )
+ {
+ config->setGroup("General");
+
+ config->writeEntry("Restore Window Configuration", cb_restoreVC->isChecked());
+
+ int bu = sessions_start->id (sessions_start->selected());
+
+ if (bu == 0)
+ config->writeEntry ("Startup Session", "new");
+ else if (bu == 1)
+ config->writeEntry ("Startup Session", "last");
+ else
+ config->writeEntry ("Startup Session", "manual");
+
+ bu = sessions_exit->id (sessions_exit->selected());
+
+ if (bu == 0)
+ config->writeEntry ("Session Exit", "discard");
+ else if (bu == 1)
+ config->writeEntry ("Session Exit", "save");
+ else
+ config->writeEntry ("Session Exit", "ask");
+
+ config->writeEntry("Save Meta Infos", cb_saveMetaInfos->isChecked());
+ KateDocManager::self()->setSaveMetaInfos(cb_saveMetaInfos->isChecked());
+
+ config->writeEntry("Days Meta Infos", sb_daysMetaInfos->value() );
+ KateDocManager::self()->setDaysMetaInfos(sb_daysMetaInfos->value());
+
+ config->writeEntry("Modified Notification", cb_modNotifications->isChecked());
+ mainWindow->modNotification = cb_modNotifications->isChecked();
+
+ mainWindow->syncKonsole = cb_syncKonsole->isChecked();
+ mainWindow->useInstance = cb_useInstance->isChecked();
+ mainWindow->filelist->setSortType(cb_sortFiles->isChecked() ? KateFileList::sortByName : KateFileList::sortByID);
+
+ config->writeEntry( "Number of recent files", sb_numRecentFiles->value() );
+ mainWindow->fileOpenRecent->setMaxItems( sb_numRecentFiles->value() );
+
+ fileSelConfigPage->apply();
+
+ filelistConfigPage->apply();
+
+ configExternalToolsPage->apply();
+ KateExternalToolsCommand::self()->reload();
+ for (uint i=0; i < KateApp::self()->mainWindows(); i++)
+ {
+ KateMainWindow *win = KateApp::self()->mainWindow (i);
+ win->externalTools->reload();
+ }
+ //mainWindow->externalTools->reload();
+
+ mainWindow->viewManager()->setShowFullPath( cb_fullPath->isChecked() ); // hm, stored 2 places :(
+
+ mainWindow->saveOptions ();
+
+ // save plugin config !!
+ KateApp::self()->pluginManager()->writeConfig ();
+ }
+
+ //
+ // editor config ! (the apply() methode will check the changed state internally)
+ //
+ for (uint i=0; i<editorPages.count(); i++)
+ {
+ editorPages.at(i)->apply();
+ }
+
+ v->getDoc()->writeConfig(config);
+
+ //
+ // plugins config ! (the apply() methode SHOULD check the changed state internally)
+ //
+ for (uint i=0; i<pluginPages.count(); i++)
+ {
+ pluginPages.at(i)->page->apply();
+ }
+
+ config->sync();
+
+ dataChanged = false;
+ actionButton( KDialogBase::Apply)->setEnabled( false );
+}
+
+void KateConfigDialog::slotChanged()
+{
+ dataChanged = true;
+ actionButton( KDialogBase::Apply)->setEnabled( true );
+}
diff --git a/kate/app/kateconfigdialog.h b/kate/app/kateconfigdialog.h
new file mode 100644
index 000000000..5bbfc526d
--- /dev/null
+++ b/kate/app/kateconfigdialog.h
@@ -0,0 +1,85 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __kate_configdialog_h__
+#define __kate_configdialog_h__
+
+#include "katemain.h"
+
+#include "../interfaces/plugin.h"
+#include "../interfaces/pluginconfiginterface.h"
+#include "../interfaces/pluginconfiginterfaceextension.h"
+
+#include <kate/document.h>
+#include <tdetexteditor/configinterfaceextension.h>
+
+#include <kdialogbase.h>
+
+class TQCheckBox;
+class TQSpinBox;
+class TQButtonGroup;
+
+struct PluginPageListItem
+{
+ Kate::Plugin *plugin;
+ Kate::PluginConfigPage *page;
+};
+
+class KateConfigDialog : public KDialogBase
+{
+ Q_OBJECT
+
+ public:
+ KateConfigDialog (KateMainWindow *parent, Kate::View *view);
+ ~KateConfigDialog ();
+
+ public:
+ void addPluginPage (Kate::Plugin *plugin);
+ void removePluginPage (Kate::Plugin *plugin);
+
+ protected slots:
+ void slotOk();
+ void slotApply();
+ void slotChanged();
+
+ private:
+ KateMainWindow *mainWindow;
+
+ Kate::View* v;
+ bool dataChanged;
+
+ TQCheckBox *cb_fullPath;
+ TQCheckBox *cb_syncKonsole;
+ TQCheckBox *cb_useInstance;
+ TQCheckBox *cb_sortFiles;
+ TQSpinBox *sb_numRecentFiles;
+ TQCheckBox *cb_modNotifications;
+ TQCheckBox *cb_saveMetaInfos;
+ TQSpinBox *sb_daysMetaInfos;
+ TQCheckBox* cb_restoreVC;
+ TQButtonGroup *sessions_start;
+ TQButtonGroup *sessions_exit;
+ Kate::ConfigPage *fileSelConfigPage;
+ Kate::ConfigPage *filelistConfigPage;
+ Kate::ConfigPage *configExternalToolsPage;
+ TQPtrList<PluginPageListItem> pluginPages;
+ TQPtrList<KTextEditor::ConfigPage> editorPages;
+};
+
+#endif
diff --git a/kate/app/kateconfigplugindialogpage.cpp b/kate/app/kateconfigplugindialogpage.cpp
new file mode 100644
index 000000000..90d7262e5
--- /dev/null
+++ b/kate/app/kateconfigplugindialogpage.cpp
@@ -0,0 +1,121 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "kateconfigplugindialogpage.h"
+#include "kateconfigplugindialogpage.moc"
+
+#include "katepluginmanager.h"
+#include "kateconfigdialog.h"
+#include <tdelistbox.h>
+#include "kateapp.h"
+#include <tqstringlist.h>
+#include <tqhbox.h>
+#include <tqlabel.h>
+#include <tdelocale.h>
+#include <tqpushbutton.h>
+#include <tqtooltip.h>
+#include <kiconloader.h>
+#include <tqwhatsthis.h>
+
+class KatePluginListItem : public TQCheckListItem
+{
+ public:
+ KatePluginListItem(bool checked, KatePluginInfo *info, TQListView *parent);
+ KatePluginInfo *info() const { return mInfo; }
+
+ protected:
+ void stateChange(bool);
+
+ private:
+ KatePluginInfo *mInfo;
+ bool silentStateChange;
+};
+
+KatePluginListItem::KatePluginListItem(bool checked, KatePluginInfo *info, TQListView *parent)
+ : TQCheckListItem(parent, info->service->name(), CheckBox)
+ , mInfo(info)
+ , silentStateChange(false)
+{
+ silentStateChange = true;
+ setOn(checked);
+ silentStateChange = false;
+}
+
+void KatePluginListItem::stateChange(bool b)
+{
+ if(!silentStateChange)
+ static_cast<KatePluginListView *>(listView())->stateChanged(this, b);
+}
+
+KatePluginListView::KatePluginListView(TQWidget *parent, const char *name)
+ : TDEListView(parent, name)
+{
+}
+
+void KatePluginListView::stateChanged(KatePluginListItem *item, bool b)
+{
+ emit stateChange(item, b);
+}
+
+KateConfigPluginPage::KateConfigPluginPage(TQWidget *parent, KateConfigDialog *dialog):TQVBox(parent)
+{
+ myDialog=dialog;
+
+ KatePluginListView* listView = new KatePluginListView(this);
+ listView->addColumn(i18n("Name"));
+ listView->addColumn(i18n("Comment"));
+ TQWhatsThis::add(listView,i18n("Here you can see all available Kate plugins. Those with a check mark are loaded, and will be loaded again the next time Kate is started."));
+
+ connect(listView, TQT_SIGNAL(stateChange(KatePluginListItem *, bool)), this, TQT_SLOT(stateChange(KatePluginListItem *, bool)));
+
+ KatePluginList &pluginList (KatePluginManager::self()->pluginList());
+ for (unsigned int i=0; i < pluginList.size(); ++i)
+ {
+ KatePluginListItem *item = new KatePluginListItem(pluginList[i].load, &pluginList[i], listView);
+ item->setText(0, pluginList[i].service->name());
+ item->setText(1, pluginList[i].service->comment());
+ }
+}
+
+ void KateConfigPluginPage::stateChange(KatePluginListItem *item, bool b)
+{
+ if(b)
+ loadPlugin(item);
+ else
+ unloadPlugin(item);
+
+ emit changed();
+}
+
+void KateConfigPluginPage::loadPlugin (KatePluginListItem *item)
+{
+ KatePluginManager::self()->loadPlugin (item->info());
+ KatePluginManager::self()->enablePluginGUI (item->info());
+ myDialog->addPluginPage (item->info()->plugin);
+
+ item->setOn(true);
+}
+
+void KateConfigPluginPage::unloadPlugin (KatePluginListItem *item)
+{
+ myDialog->removePluginPage (item->info()->plugin);
+ KatePluginManager::self()->unloadPlugin (item->info());
+
+ item->setOn(false);
+}
diff --git a/kate/app/kateconfigplugindialogpage.h b/kate/app/kateconfigplugindialogpage.h
new file mode 100644
index 000000000..009f30739
--- /dev/null
+++ b/kate/app/kateconfigplugindialogpage.h
@@ -0,0 +1,69 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __KATE_CONFIGPLUGINDIALOGPAGE_H__
+#define __KATE_CONFIGPLUGINDIALOGPAGE_H__
+
+#include "katemain.h"
+#include "katepluginmanager.h"
+
+#include <tdelistview.h>
+
+#include <tqvbox.h>
+
+class KatePluginListItem;
+
+class KatePluginListView : public TDEListView
+{
+ Q_OBJECT
+
+ friend class KatePluginListItem;
+
+ public:
+ KatePluginListView (TQWidget *parent = 0, const char *name = 0);
+
+ signals:
+ void stateChange(KatePluginListItem *, bool);
+
+ private:
+ void stateChanged(KatePluginListItem *, bool);
+};
+
+class KateConfigPluginPage: public TQVBox
+{
+ Q_OBJECT
+
+ public:
+ KateConfigPluginPage(TQWidget *parent, class KateConfigDialog *dialog);
+ ~KateConfigPluginPage(){;};
+
+ private:
+ class KateConfigDialog *myDialog;
+
+ signals:
+ void changed();
+
+ private slots:
+ void stateChange(KatePluginListItem *, bool);
+
+ void loadPlugin (KatePluginListItem *);
+ void unloadPlugin (KatePluginListItem *);
+};
+
+#endif
diff --git a/kate/app/kateconsole.cpp b/kate/app/kateconsole.cpp
new file mode 100644
index 000000000..cb49ef16e
--- /dev/null
+++ b/kate/app/kateconsole.cpp
@@ -0,0 +1,143 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org>
+ Copyright (C) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "kateconsole.h"
+#include "kateconsole.moc"
+
+#include "katemain.h"
+#include "katemdi.h"
+#include "katemainwindow.h"
+#include "kateviewmanager.h"
+
+#include <kate/view.h>
+#include <kate/document.h>
+
+#include <kde_terminal_interface.h>
+
+#include <tdeparts/part.h>
+
+#include <kurl.h>
+#include <klibloader.h>
+#include <tdelocale.h>
+#include <kdebug.h>
+#include <tdemessagebox.h>
+
+KateConsole::KateConsole (KateMainWindow *mw, KateMDI::ToolView* parent)
+ : TQVBox (parent)
+ , m_part (0)
+ , m_mw (mw)
+ , m_toolView (parent)
+{
+}
+
+KateConsole::~KateConsole ()
+{
+ if (m_part)
+ disconnect ( m_part, TQT_SIGNAL(destroyed()), this, TQT_SLOT(slotDestroyed()) );
+}
+
+void KateConsole::loadConsoleIfNeeded()
+{
+ if (m_part) return;
+
+ if (!topLevelWidget() || !parentWidget()) return;
+ if (!topLevelWidget() || !isVisibleTo(topLevelWidget())) return;
+
+ KLibFactory *factory = KLibLoader::self()->factory("libkonsolepart");
+
+ if (!factory) return;
+
+ m_part = static_cast<KParts::ReadOnlyPart *>(factory->create(TQT_TQOBJECT(this),"libkonsolepart", "KParts::ReadOnlyPart"));
+
+ if (!m_part) return;
+
+ setFocusProxy(m_part->widget());
+
+ TDEGlobal::locale()->insertCatalogue("konsole");
+
+ m_part->widget()->show();
+
+ connect ( m_part, TQT_SIGNAL(destroyed()), this, TQT_SLOT(slotDestroyed()) );
+
+ if (m_mw->viewManager()->activeView())
+ if (m_mw->viewManager()->activeView()->getDoc()->url().isValid())
+ cd(KURL( m_mw->viewManager()->activeView()->getDoc()->url().path() ));
+}
+
+void KateConsole::slotDestroyed ()
+{
+ m_part = 0;
+
+ // hide the dockwidget
+ if (parentWidget())
+ {
+ m_mw->hideToolView (m_toolView);
+ m_mw->centralWidget()->setFocus ();
+ }
+}
+
+void KateConsole::showEvent(TQShowEvent *)
+{
+ if (m_part) return;
+
+ loadConsoleIfNeeded();
+}
+
+void KateConsole::cd (const KURL &url)
+{
+ loadConsoleIfNeeded();
+
+ if (!m_part) return;
+
+ m_part->openURL (url);
+}
+
+void KateConsole::sendInput( const TQString& text )
+{
+ loadConsoleIfNeeded();
+
+ if (!m_part) return;
+
+ TerminalInterface *t = static_cast<TerminalInterface*>( m_part->tqt_cast( "TerminalInterface" ) );
+
+ if (!t) return;
+
+ t->sendInput (text);
+}
+
+void KateConsole::slotPipeToConsole ()
+{
+ if (KMessageBox::warningContinueCancel
+ (m_mw
+ , i18n ("Do you really want to pipe the text to the console? This will execute any contained commands with your user rights.")
+ , i18n ("Pipe to Console?")
+ , i18n("Pipe to Console"), "Pipe To Console Warning") != KMessageBox::Continue)
+ return;
+
+ Kate::View *v = m_mw->viewManager()->activeView();
+
+ if (!v)
+ return;
+
+ if (v->getDoc()->hasSelection ())
+ sendInput (v->getDoc()->selection());
+ else
+ sendInput (v->getDoc()->text());
+}
diff --git a/kate/app/kateconsole.h b/kate/app/kateconsole.h
new file mode 100644
index 000000000..dabfda38d
--- /dev/null
+++ b/kate/app/kateconsole.h
@@ -0,0 +1,116 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org>
+ Copyright (C) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __KATE_CONSOLE_H__
+#define __KATE_CONSOLE_H__
+
+#include "katemain.h"
+
+#include <kurl.h>
+
+#include <tqvbox.h>
+
+namespace KParts {
+ class ReadOnlyPart;
+}
+
+namespace KateMDI {
+ class ToolView;
+}
+
+class KateMainWindow;
+
+/**
+ * KateConsole
+ * This class is used for the internal terminal emulator
+ * It uses internally the konsole part, thx to konsole devs :)
+ */
+class KateConsole : public TQVBox
+{
+ Q_OBJECT
+
+ public:
+ /**
+ * construct us
+ * @param mw main window
+ * @param parent toolview
+ */
+ KateConsole (KateMainWindow *mw, KateMDI::ToolView* parent);
+
+ /**
+ * destruct us
+ */
+ ~KateConsole ();
+
+ /**
+ * cd to dir
+ * @param url given dir
+ */
+ void cd (const KURL &url);
+
+ /**
+ * send given text to console
+ * @param text commands for console
+ */
+ void sendInput( const TQString& text );
+
+ public slots:
+ /**
+ * pipe current document to console
+ */
+ void slotPipeToConsole ();
+
+ private slots:
+ /**
+ * the konsole exited ;)
+ * handle that, hide the dock
+ */
+ void slotDestroyed ();
+
+ /**
+ * construct console if needed
+ */
+ void loadConsoleIfNeeded();
+
+ protected:
+ /**
+ * the konsole get shown
+ * @param ev show event
+ */
+ void showEvent(TQShowEvent *ev);
+
+ private:
+ /**
+ * console part
+ */
+ KParts::ReadOnlyPart *m_part;
+
+ /**
+ * main window of this console
+ */
+ KateMainWindow *m_mw;
+
+ /**
+ * toolview for this console
+ */
+ KateMDI::ToolView *m_toolView;
+};
+
+#endif
diff --git a/kate/app/katedocmanager.cpp b/kate/app/katedocmanager.cpp
new file mode 100644
index 000000000..6cca9efe0
--- /dev/null
+++ b/kate/app/katedocmanager.cpp
@@ -0,0 +1,612 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "katedocmanager.h"
+#include "katedocmanager.moc"
+#include "kateapp.h"
+#include "katemainwindow.h"
+#include "kateviewmanager.h"
+#include "katedocmanageriface.h"
+#include "kateexternaltools.h"
+#include "kateviewspacecontainer.h"
+
+#include <kate/view.h>
+
+#include <tdetexteditor/encodinginterface.h>
+
+#include <tdeparts/factory.h>
+
+#include <tdelocale.h>
+#include <kdebug.h>
+#include <tdeconfig.h>
+#include <klibloader.h>
+#include <kmdcodec.h>
+#include <tdemessagebox.h>
+#include <kencodingfiledialog.h>
+#include <tdeio/job.h>
+#include <twin.h>
+
+#include <tqdatetime.h>
+#include <tqtextcodec.h>
+#include <tqprogressdialog.h>
+
+KateDocManager::KateDocManager (TQObject *parent)
+ : TQObject (parent)
+ , m_saveMetaInfos(true)
+ , m_daysMetaInfos(0)
+{
+ m_factory = (KParts::Factory *) KLibLoader::self()->factory ("libkatepart");
+
+ m_documentManager = new Kate::DocumentManager (this);
+ m_docList.setAutoDelete(true);
+ m_docDict.setAutoDelete(false);
+ m_docInfos.setAutoDelete(true);
+
+ m_dcop = new KateDocManagerDCOPIface (this);
+
+ m_metaInfos = new TDEConfig("metainfos", false, false, "appdata");
+
+ createDoc ();
+}
+
+KateDocManager::~KateDocManager ()
+{
+ // save config
+ if (!m_docList.isEmpty())
+ m_docList.at(0)->writeConfig(KateApp::self()->config());
+
+ if (m_saveMetaInfos)
+ {
+ // saving meta-infos when file is saved is not enough, we need to do it once more at the end
+ for (Kate::Document *doc = m_docList.first(); doc; doc = m_docList.next())
+ saveMetaInfos(doc);
+
+ // purge saved filesessions
+ if (m_daysMetaInfos > 0)
+ {
+ TQStringList groups = m_metaInfos->groupList();
+ TQDateTime *def = new TQDateTime(TQDate(1970, 1, 1));
+ for (TQStringList::Iterator it = groups.begin(); it != groups.end(); ++it)
+ {
+ m_metaInfos->setGroup(*it);
+ TQDateTime last = m_metaInfos->readDateTimeEntry("Time", def);
+ if (last.daysTo(TQDateTime::currentDateTime()) > m_daysMetaInfos)
+ m_metaInfos->deleteGroup(*it);
+ }
+ delete def;
+ }
+ }
+
+ delete m_dcop;
+ delete m_metaInfos;
+}
+
+KateDocManager *KateDocManager::self ()
+{
+ return KateApp::self()->documentManager ();
+}
+
+Kate::Document *KateDocManager::createDoc ()
+{
+ KTextEditor::Document *doc = (KTextEditor::Document *) m_factory->createPart (0, "", this, "", "KTextEditor::Document");
+
+ m_docList.append((Kate::Document *)doc);
+ m_docDict.insert (doc->documentNumber(), (Kate::Document *)doc);
+ m_docInfos.insert (doc, new KateDocumentInfo ());
+
+ if (m_docList.count() < 2)
+ ((Kate::Document *)doc)->readConfig(KateApp::self()->config());
+
+ emit documentCreated ((Kate::Document *)doc);
+ emit m_documentManager->documentCreated ((Kate::Document *)doc);
+
+ connect(doc,TQT_SIGNAL(modifiedOnDisc(Kate::Document *, bool, unsigned char)),this,TQT_SLOT(slotModifiedOnDisc(Kate::Document *, bool, unsigned char)));
+ return (Kate::Document *)doc;
+}
+
+void KateDocManager::deleteDoc (Kate::Document *doc)
+{
+ uint id = doc->documentNumber();
+ uint activeId = 0;
+ if (m_currentDoc)
+ activeId = m_currentDoc->documentNumber ();
+
+ if (m_docList.count() < 2)
+ doc->writeConfig(KateApp::self()->config());
+
+ m_docInfos.remove (doc);
+ m_docDict.remove (id);
+ m_docList.remove (doc);
+
+ emit documentDeleted (id);
+ emit m_documentManager->documentDeleted (id);
+
+ // ohh, current doc was deleted
+ if (activeId == id)
+ {
+ // special case of documentChanged, no longer any doc here !
+ m_currentDoc = 0;
+
+ emit documentChanged ();
+ emit m_documentManager->documentChanged ();
+ }
+}
+
+Kate::Document *KateDocManager::document (uint n)
+{
+ return m_docList.at(n);
+}
+
+Kate::Document *KateDocManager::activeDocument ()
+{
+ return m_currentDoc;
+}
+
+void KateDocManager::setActiveDocument (Kate::Document *doc)
+{
+ if (!doc)
+ return;
+
+ if (m_currentDoc && (m_currentDoc->documentNumber() == doc->documentNumber()))
+ return;
+
+ m_currentDoc = doc;
+
+ emit documentChanged ();
+ emit m_documentManager->documentChanged ();
+}
+
+Kate::Document *KateDocManager::firstDocument ()
+{
+ return m_docList.first();
+}
+
+Kate::Document *KateDocManager::nextDocument ()
+{
+ return m_docList.next();
+}
+
+Kate::Document *KateDocManager::documentWithID (uint id)
+{
+ return m_docDict[id];
+}
+
+const KateDocumentInfo *KateDocManager::documentInfo (Kate::Document *doc)
+{
+ return m_docInfos[doc];
+}
+
+int KateDocManager::findDocument (Kate::Document *doc)
+{
+ return m_docList.find (doc);
+}
+
+uint KateDocManager::documents ()
+{
+ return m_docList.count ();
+}
+
+int KateDocManager::findDocument ( KURL url )
+{
+ TQPtrListIterator<Kate::Document> it(m_docList);
+
+ for (; it.current(); ++it)
+ {
+ if ( it.current()->url() == url)
+ return it.current()->documentNumber();
+ }
+ return -1;
+}
+
+Kate::Document *KateDocManager::findDocumentByUrl( KURL url )
+{
+ for (TQPtrListIterator<Kate::Document> it(m_docList); it.current(); ++it)
+ {
+ if ( it.current()->url() == url)
+ return it.current();
+ }
+
+ return 0L;
+}
+
+bool KateDocManager::isOpen(KURL url)
+{
+ // return just if we found some document with this url
+ return findDocumentByUrl (url) != 0;
+}
+
+Kate::Document *KateDocManager::openURL (const KURL& url,const TQString &encoding, uint *id, bool isTempFile)
+{
+ // special handling if still only the first initial doc is there
+ if (!documentList().isEmpty() && (documentList().count() == 1) && (!documentList().at(0)->isModified() && documentList().at(0)->url().isEmpty()))
+ {
+ Kate::Document* doc = documentList().getFirst();
+
+ doc->setEncoding(encoding);
+
+ if (!loadMetaInfos(doc, url))
+ doc->openURL (url);
+
+ if (id)
+ *id=doc->documentNumber();
+
+ if ( isTempFile && !url.isEmpty() && url.isLocalFile() )
+ {
+ TQFileInfo fi( url.path() );
+ if ( fi.exists() )
+ {
+ m_tempFiles[ doc->documentNumber() ] = qMakePair(url, fi.lastModified());
+ kdDebug(13001)<<"temporary file will be deleted after use unless modified: "<<url.prettyURL()<<endl;
+ }
+ }
+
+ connect(doc, TQT_SIGNAL(modStateChanged(Kate::Document *)), this, TQT_SLOT(slotModChanged(Kate::Document *)));
+
+ emit initialDocumentReplaced();
+
+ return doc;
+ }
+
+ Kate::Document *doc = findDocumentByUrl (url);
+ if ( !doc )
+ {
+ doc = (Kate::Document *)createDoc ();
+
+ doc->setEncoding(encoding.isNull() ? Kate::Document::defaultEncoding() : encoding);
+
+ if (!loadMetaInfos(doc, url))
+ doc->openURL (url);
+ }
+
+ if (id)
+ *id=doc->documentNumber();
+
+ if ( isTempFile && !url.isEmpty() && url.isLocalFile() )
+ {
+ TQFileInfo fi( url.path() );
+ if ( fi.exists() )
+ {
+ m_tempFiles[ doc->documentNumber() ] = qMakePair(url, fi.lastModified());
+ kdDebug(13001)<<"temporary file will be deleted after use unless modified: "<<url.prettyURL()<<endl;
+ }
+ }
+
+ return doc;
+}
+
+bool KateDocManager::closeDocument(class Kate::Document *doc,bool closeURL)
+{
+ if (!doc) return false;
+
+ saveMetaInfos(doc);
+ if (closeURL)
+ if (!doc->closeURL()) return false;
+
+ TQPtrList<Kate::View> closeList;
+ uint documentNumber = doc->documentNumber();
+
+ for (uint i=0; i < KateApp::self()->mainWindows (); i++ )
+ {
+ KateApp::self()->mainWindow(i)->viewManager()->closeViews(documentNumber);
+ }
+
+ if ( closeURL && m_tempFiles.contains( documentNumber ) )
+ {
+ TQFileInfo fi( m_tempFiles[ documentNumber ].first.path() );
+ if ( fi.lastModified() <= m_tempFiles[ documentNumber ].second /*||
+ KMessageBox::questionYesNo( KateApp::self()->activeMainWindow(),
+ i18n("The supposedly temporary file %1 has been modified. "
+ "Do you want to delete it anyway?").arg(m_tempFiles[ documentNumber ].first.prettyURL()),
+ i18n("Delete File?") ) == KMessageBox::Yes*/ )
+ {
+ TDEIO::del( m_tempFiles[ documentNumber ].first, false, false );
+ kdDebug(13001)<<"Deleted temporary file "<<m_tempFiles[ documentNumber ].first<<endl;
+ m_tempFiles.remove( documentNumber );
+ }
+ else
+ kdWarning(13001)<<"The supposedly temporary file "<<m_tempFiles[ documentNumber ].first.prettyURL()<<" have been modified since loaded, and has not been deleted."<<endl;
+ }
+
+ deleteDoc (doc);
+
+ // never ever empty the whole document list
+ if (m_docList.isEmpty())
+ createDoc ();
+
+ return true;
+}
+
+bool KateDocManager::closeDocument(uint n)
+{
+ return closeDocument(document(n));
+}
+
+bool KateDocManager::closeDocumentWithID(uint id)
+{
+ return closeDocument(documentWithID(id));
+}
+
+bool KateDocManager::closeAllDocuments(bool closeURL)
+{
+ bool res = true;
+
+ TQPtrList<Kate::Document> docs = m_docList;
+
+ for (uint i=0; i < KateApp::self()->mainWindows (); i++ )
+ {
+ KateApp::self()->mainWindow(i)->viewManager()->setViewActivationBlocked(true);
+ }
+
+ while (!docs.isEmpty() && res)
+ if (! closeDocument(docs.at(0),closeURL) )
+ res = false;
+ else
+ docs.remove ((uint)0);
+
+ for (uint i=0; i < KateApp::self()->mainWindows (); i++ )
+ {
+ KateApp::self()->mainWindow(i)->viewManager()->setViewActivationBlocked(false);
+
+ for (uint s=0; s < KateApp::self()->mainWindow(i)->viewManager()->containers()->count(); s++)
+ KateApp::self()->mainWindow(i)->viewManager()->containers()->at(s)->activateView (m_docList.at(0)->documentNumber());
+ }
+
+ return res;
+}
+
+TQPtrList<Kate::Document> KateDocManager::modifiedDocumentList() {
+ TQPtrList<Kate::Document> modified;
+ for (TQPtrListIterator<Kate::Document> it(m_docList); it.current(); ++it) {
+ Kate::Document *doc = it.current();
+ if (doc->isModified()) {
+ modified.append(doc);
+ }
+ }
+ return modified;
+}
+
+
+bool KateDocManager::queryCloseDocuments(KateMainWindow *w)
+{
+ uint docCount = m_docList.count();
+ for (TQPtrListIterator<Kate::Document> it(m_docList); it.current(); ++it)
+ {
+ Kate::Document *doc = it.current();
+
+ if (doc->url().isEmpty() && doc->isModified())
+ {
+ int msgres=KMessageBox::warningYesNoCancel( w,
+ i18n("<p>The document '%1' has been modified, but not saved."
+ "<p>Do you want to save your changes or discard them?").arg( doc->docName() ),
+ i18n("Close Document"), KStdGuiItem::save(), KStdGuiItem::discard() );
+
+ if (msgres==KMessageBox::Cancel)
+ return false;
+
+ if (msgres==KMessageBox::Yes)
+ {
+ KEncodingFileDialog::Result r=KEncodingFileDialog::getSaveURLAndEncoding(
+ KTextEditor::encodingInterface(doc)->encoding(),TQString::null,TQString::null,w,i18n("Save As"));
+
+ doc->setEncoding( r.encoding );
+
+ if (!r.URLs.isEmpty())
+ {
+ KURL tmp = r.URLs.first();
+
+ if ( !doc->saveAs( tmp ) )
+ return false;
+ }
+ else
+ return false;
+ }
+ }
+ else
+ {
+ if (!doc->queryClose())
+ return false;
+ }
+ }
+
+ // document count changed while queryClose, abort and notify user
+ if (m_docList.count() > docCount)
+ {
+ KMessageBox::information (w,
+ i18n ("New file opened while trying to close Kate, closing aborted."),
+ i18n ("Closing Aborted"));
+ return false;
+ }
+
+ return true;
+}
+
+
+void KateDocManager::saveAll()
+{
+ for (TQPtrListIterator<Kate::Document> it(m_docList); it.current(); ++it)
+ if ( it.current()->isModified() && it.current()->views().count() )
+ ((Kate::View*)it.current()->views().first())->save();
+}
+
+void KateDocManager::saveDocumentList (TDEConfig* config)
+{
+ TQString prevGrp=config->group();
+ config->setGroup ("Open Documents");
+ TQString grp = config->group();
+
+ config->writeEntry ("Count", m_docList.count());
+
+ int i=0;
+ for ( Kate::Document *doc = m_docList.first(); doc; doc = m_docList.next() )
+ {
+ long docListPos = doc->documentListPosition();
+ config->setGroup(TQString("Document %1").arg((docListPos<0)?i:docListPos));
+ doc->writeSessionConfig(config);
+ config->setGroup(grp);
+
+ i++;
+ }
+
+ config->setGroup(prevGrp);
+}
+
+void KateDocManager::restoreDocumentList (TDEConfig* config)
+{
+ TQString prevGrp=config->group();
+ config->setGroup ("Open Documents");
+ TQString grp = config->group();
+
+ unsigned int count = config->readUnsignedNumEntry("Count", 0);
+
+ if (count == 0)
+ {
+ config->setGroup(prevGrp);
+ return;
+ }
+
+ TQProgressDialog *pd = new TQProgressDialog(
+ i18n("Reopening files from the last session..."),
+ TQString::null,
+ count,
+ 0,
+ "openprog");
+
+ KWin::setOnDesktop(pd->winId(), KWin::currentDesktop());
+ pd->setCaption (KateApp::self()->makeStdCaption(i18n("Starting Up")));
+
+ bool first = true;
+ for (unsigned int i=0; i < count; i++)
+ {
+ config->setGroup(TQString("Document %1").arg(i));
+ Kate::Document *doc = 0;
+
+ if (first)
+ {
+ first = false;
+ doc = document (0);
+ }
+ else
+ doc = createDoc ();
+
+ doc->readSessionConfig(config);
+ config->setGroup (grp);
+
+ pd->setProgress(pd->progress()+1);
+ KateApp::self()->processEvents();
+ }
+
+ delete pd;
+
+ config->setGroup(prevGrp);
+}
+
+void KateDocManager::slotModifiedOnDisc (Kate::Document *doc, bool b, unsigned char reason)
+{
+ if (m_docInfos[doc])
+ {
+ m_docInfos[doc]->modifiedOnDisc = b;
+ m_docInfos[doc]->modifiedOnDiscReason = reason;
+ }
+}
+
+void KateDocManager::slotModChanged(Kate::Document *doc)
+{
+ saveMetaInfos(doc);
+}
+
+/**
+ * Load file and file' meta-informations iif the MD5 didn't change since last time.
+ */
+bool KateDocManager::loadMetaInfos(Kate::Document *doc, const KURL &url)
+{
+ if (!m_saveMetaInfos)
+ return false;
+
+ if (!m_metaInfos->hasGroup(url.prettyURL()))
+ return false;
+
+ TQCString md5;
+ bool ok = true;
+
+ if (computeUrlMD5(url, md5))
+ {
+ m_metaInfos->setGroup(url.prettyURL());
+ TQString old_md5 = m_metaInfos->readEntry("MD5");
+
+ if ((const char *)md5 == old_md5)
+ doc->readSessionConfig(m_metaInfos);
+ else
+ {
+ m_metaInfos->deleteGroup(url.prettyURL());
+ ok = false;
+ }
+
+ m_metaInfos->sync();
+ }
+
+ return ok && doc->url() == url;
+}
+
+/**
+ * Save file' meta-informations iif doc is in 'unmodified' state
+ */
+void KateDocManager::saveMetaInfos(Kate::Document *doc)
+{
+ TQCString md5;
+
+ if (!m_saveMetaInfos)
+ return;
+
+ if (doc->isModified())
+ {
+// kdDebug (13020) << "DOC MODIFIED: no meta data saved" << endl;
+ return;
+ }
+
+ if (computeUrlMD5(doc->url(), md5))
+ {
+ m_metaInfos->setGroup(doc->url().prettyURL());
+ doc->writeSessionConfig(m_metaInfos);
+ m_metaInfos->writeEntry("MD5", (const char *)md5);
+ m_metaInfos->writeEntry("Time", TQDateTime::currentDateTime());
+ m_metaInfos->sync();
+ }
+}
+
+bool KateDocManager::computeUrlMD5(const KURL &url, TQCString &result)
+{
+ TQFile f(url.path());
+
+ if (f.open(IO_ReadOnly))
+ {
+ KMD5 md5;
+
+ if (!md5.update(TQT_TQIODEVICE_OBJECT(f)))
+ return false;
+
+ md5.hexDigest(result);
+ f.close();
+ }
+ else
+ return false;
+
+ return true;
+}
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/katedocmanager.h b/kate/app/katedocmanager.h
new file mode 100644
index 000000000..1eaef7f99
--- /dev/null
+++ b/kate/app/katedocmanager.h
@@ -0,0 +1,157 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __KATE_DOCMANAGER_H__
+#define __KATE_DOCMANAGER_H__
+
+#include "katemain.h"
+#include "../interfaces/documentmanager.h"
+
+#include <kate/document.h>
+
+#include <tqdatetime.h>
+#include <tqguardedptr.h>
+#include <tqptrlist.h>
+#include <tqobject.h>
+#include <tqptrdict.h>
+#include <tqintdict.h>
+#include <tqmap.h>
+#include <tqpair.h>
+
+namespace KParts { class Factory; }
+
+class TDEConfig;
+class DCOPObject;
+
+class KateDocumentInfo
+{
+ public:
+ KateDocumentInfo ()
+ : modifiedOnDisc (false),
+ modifiedOnDiscReason (0)
+ {
+ }
+
+ bool modifiedOnDisc;
+ unsigned char modifiedOnDiscReason;
+};
+
+typedef QPair<KURL,TQDateTime> TPair;
+
+class KateDocManager : public TQObject
+{
+ Q_OBJECT
+
+ public:
+ KateDocManager (TQObject *parent);
+ ~KateDocManager ();
+
+ static KateDocManager *self ();
+
+ Kate::DocumentManager *documentManager () { return m_documentManager; };
+
+ Kate::Document *createDoc ();
+ void deleteDoc (Kate::Document *doc);
+
+ Kate::Document *document (uint n);
+
+ Kate::Document *activeDocument ();
+ void setActiveDocument (Kate::Document *doc);
+
+ Kate::Document *firstDocument ();
+ Kate::Document *nextDocument ();
+
+ // search document with right documentNumber()
+ Kate::Document *documentWithID (uint id);
+
+ const KateDocumentInfo *documentInfo (Kate::Document *doc);
+
+ int findDocument (Kate::Document *doc);
+ /** Returns the documentNumber of the doc with url URL or -1 if no such doc is found */
+ int findDocument (KURL url);
+ // Anders: The above is not currently stable ?
+ Kate::Document *findDocumentByUrl( KURL url );
+
+ bool isOpen(KURL url);
+
+ uint documents ();
+
+ TQPtrList<Kate::Document> &documentList () { return m_docList; };
+
+ Kate::Document *openURL(const KURL&,const TQString &encoding=TQString::null,uint *id =0,bool isTempFile=false);
+
+ bool closeDocument(class Kate::Document *,bool closeURL=true);
+ bool closeDocument(uint);
+ bool closeDocumentWithID(uint);
+ bool closeAllDocuments(bool closeURL=true);
+
+ TQPtrList<Kate::Document> modifiedDocumentList();
+ bool queryCloseDocuments(KateMainWindow *w);
+
+ void saveDocumentList (class TDEConfig *config);
+ void restoreDocumentList (class TDEConfig *config);
+
+ DCOPObject *dcopObject () { return m_dcop; };
+
+ inline bool getSaveMetaInfos() { return m_saveMetaInfos; };
+ inline void setSaveMetaInfos(bool b) { m_saveMetaInfos = b; };
+
+ inline int getDaysMetaInfos() { return m_daysMetaInfos; };
+ inline void setDaysMetaInfos(int i) { m_daysMetaInfos = i; };
+
+ public slots:
+ /**
+ * saves all documents that has at least one view.
+ * documents with no views are ignored :P
+ */
+ void saveAll();
+
+ signals:
+ void documentCreated (Kate::Document *doc);
+ void documentDeleted (uint documentNumber);
+ void documentChanged ();
+ void initialDocumentReplaced ();
+
+ private slots:
+ void slotModifiedOnDisc (Kate::Document *doc, bool b, unsigned char reason);
+ void slotModChanged(Kate::Document *doc);
+
+ private:
+ bool loadMetaInfos(Kate::Document *doc, const KURL &url);
+ void saveMetaInfos(Kate::Document *doc);
+ bool computeUrlMD5(const KURL &url, TQCString &result);
+
+ Kate::DocumentManager *m_documentManager;
+ TQPtrList<Kate::Document> m_docList;
+ TQIntDict<Kate::Document> m_docDict;
+ TQPtrDict<KateDocumentInfo> m_docInfos;
+ TQMap<uint,TPair> m_tempFiles;
+ TQGuardedPtr<Kate::Document> m_currentDoc;
+ TDEConfig *m_metaInfos;
+ bool m_saveMetaInfos;
+ int m_daysMetaInfos;
+
+ DCOPObject *m_dcop;
+
+ KParts::Factory *m_factory;
+
+};
+
+#endif
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/katedocmanageriface.cpp b/kate/app/katedocmanageriface.cpp
new file mode 100644
index 000000000..034c5aa03
--- /dev/null
+++ b/kate/app/katedocmanageriface.cpp
@@ -0,0 +1,131 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Ian Reinhart Geiser <geiseri@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "katedocmanageriface.h"
+
+#include "katedocmanager.h"
+
+#include <kdebug.h>
+
+KateDocManagerDCOPIface::KateDocManagerDCOPIface (KateDocManager *dm) : DCOPObject ("KateDocumentManager"), m_dm (dm)
+{
+
+}
+
+// bit more error save than the forcing c cast ;()
+DCOPRef KateDocManagerDCOPIface::document (uint n)
+{
+ Kate::Document *doc = m_dm->document(n);
+
+ if (!doc)
+ return DCOPRef ();
+
+ DCOPObject *obj = static_cast<DCOPObject*>(doc->tqt_cast("DCOPObject"));
+
+ if (!obj)
+ return DCOPRef ();
+
+ return DCOPRef (obj);
+}
+
+DCOPRef KateDocManagerDCOPIface::activeDocument ()
+{
+ Kate::Document *doc = m_dm->activeDocument();
+
+ if (!doc)
+ return DCOPRef ();
+
+ DCOPObject *obj = static_cast<DCOPObject*>(doc->tqt_cast("DCOPObject"));
+
+ if (!obj)
+ return DCOPRef ();
+
+ return DCOPRef (obj);
+}
+
+uint KateDocManagerDCOPIface::activeDocumentNumber ()
+{
+ Kate::Document *doc = m_dm->activeDocument();
+
+ if (doc)
+ return doc->documentNumber ();
+
+ return 0;
+}
+
+DCOPRef KateDocManagerDCOPIface::documentWithID (uint id)
+{
+ Kate::Document *doc = m_dm->documentWithID (id);
+
+ if (!doc)
+ return DCOPRef ();
+
+ DCOPObject *obj = static_cast<DCOPObject*>(doc->tqt_cast("DCOPObject"));
+
+ if (!obj)
+ return DCOPRef ();
+
+ return DCOPRef (obj);
+}
+
+DCOPRef KateDocManagerDCOPIface::openURL (KURL url, TQString encoding)
+{
+ Kate::Document *doc = m_dm->openURL (url, encoding);
+
+ if (!doc)
+ return DCOPRef ();
+
+ DCOPObject *obj = static_cast<DCOPObject*>(doc->tqt_cast("DCOPObject"));
+
+ if (!obj)
+ return DCOPRef ();
+
+ return DCOPRef (obj);
+}
+
+bool KateDocManagerDCOPIface::closeDocument(uint n)
+{
+ return m_dm->closeDocument(n);
+}
+
+bool KateDocManagerDCOPIface::closeDocumentWithID(uint id)
+{
+ return m_dm->closeDocumentWithID (id);
+}
+
+bool KateDocManagerDCOPIface::closeAllDocuments()
+{
+ return m_dm->closeAllDocuments();
+}
+
+bool KateDocManagerDCOPIface::isOpen(KURL url)
+{
+ return m_dm->isOpen (url);
+}
+
+uint KateDocManagerDCOPIface::documents ()
+{
+ return m_dm->documents();
+}
+
+int KateDocManagerDCOPIface::findDocument (KURL url)
+{
+ return m_dm->findDocument (url);
+}
+
+
diff --git a/kate/app/katedocmanageriface.h b/kate/app/katedocmanageriface.h
new file mode 100644
index 000000000..353818c03
--- /dev/null
+++ b/kate/app/katedocmanageriface.h
@@ -0,0 +1,62 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Ian Reinhart Geiser <geiseri@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _katedocmanager_Iface_h_
+#define _katedocmanager_Iface_h_
+
+#include <dcopobject.h>
+#include <dcopref.h>
+
+#include <kurl.h>
+
+class KateDocManager;
+
+class KateDocManagerDCOPIface : public DCOPObject
+{
+ K_DCOP
+
+ public:
+ KateDocManagerDCOPIface (KateDocManager *dm);
+
+ k_dcop:
+ DCOPRef document (uint n);
+
+ DCOPRef activeDocument ();
+
+ uint activeDocumentNumber ();
+
+ DCOPRef documentWithID (uint id);
+
+ int findDocument (KURL url);
+
+ bool isOpen (KURL url);
+
+ uint documents ();
+
+ DCOPRef openURL (KURL url, TQString encoding);
+
+ bool closeDocument (uint n);
+
+ bool closeDocumentWithID (uint id);
+
+ bool closeAllDocuments ();
+
+ private:
+ KateDocManager *m_dm;
+};
+#endif
diff --git a/kate/app/kateexternaltools.cpp b/kate/app/kateexternaltools.cpp
new file mode 100644
index 000000000..e0057fb2c
--- /dev/null
+++ b/kate/app/kateexternaltools.cpp
@@ -0,0 +1,873 @@
+/*
+ This file is part of the Kate text editor of the KDE project.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+ ---
+ Copyright (C) 2004, Anders Lund <anders@alweb.dk>
+*/
+// TODO
+// Icons
+// Direct shortcut setting
+//BEGIN Includes
+#include "kateexternaltools.h"
+#include "kateexternaltools.moc"
+#include "katedocmanager.h"
+#include "kateviewmanager.h"
+#include "kateapp.h"
+
+#include "katemainwindow.h"
+
+#include <kate/view.h>
+#include <kate/document.h>
+
+#include <tdelistbox.h>
+#include <tdelocale.h>
+#include <kiconloader.h>
+#include <tdemessagebox.h>
+#include <kmimetypechooser.h>
+#include <tdeconfig.h>
+#include <krun.h>
+#include <kicondialog.h>
+#include <tdepopupmenu.h>
+#include <kdebug.h>
+
+#include <tqbitmap.h>
+#include <tqcombobox.h>
+#include <tqfile.h>
+#include <tqpushbutton.h>
+#include <tqlineedit.h>
+#include <tqlayout.h>
+#include <tqlabel.h>
+#include <tqlistbox.h>
+#include <tqmap.h>
+#include <tqregexp.h>
+#include <tqtextedit.h>
+#include <tqtoolbutton.h>
+#include <tqwhatsthis.h>
+
+#include <stdlib.h>
+#include <unistd.h>
+//END Includes
+
+KateExternalToolsCommand *KateExternalToolsCommand::s_self=0;
+
+//BEGIN KateExternalTool
+KateExternalTool::KateExternalTool( const TQString &name,
+ const TQString &command,
+ const TQString &icon,
+ const TQString &tryexec,
+ const TQStringList &mimetypes,
+ const TQString &acname,
+ const TQString &cmdname,
+ int save )
+ : name ( name ),
+ command ( command ),
+ icon ( icon ),
+ tryexec ( tryexec ),
+ mimetypes ( mimetypes ),
+ acname ( acname ),
+ cmdname ( cmdname ),
+ save ( save )
+{
+ //if ( ! tryexec.isEmpty() )
+ hasexec = checkExec();
+}
+
+bool KateExternalTool::checkExec()
+{
+ // if tryexec is empty, it is the first word of command
+ if ( tryexec.isEmpty() )
+ tryexec = command.section( " ", 0, 0, TQString::SectionSkipEmpty );
+
+ // NOTE this code is modified taken from kdesktopfile.cpp, from KDesktopFile::tryExec()
+ if (!tryexec.isEmpty()) {
+ if (tryexec[0] == '/') {
+ if (::access(TQFile::encodeName(tryexec), R_OK | X_OK))
+ return false;
+
+ m_exec = tryexec;
+ } else {
+ // !!! Sergey A. Sukiyazov <corwin@micom.don.ru> !!!
+ // Environment PATH may contain filenames in 8bit locale cpecified
+ // encoding (Like a filenames).
+ TQStringList dirs = TQStringList::split(':', TQFile::decodeName(::getenv("PATH")));
+ TQStringList::Iterator it(dirs.begin());
+ bool match = false;
+ for (; it != dirs.end(); ++it)
+ {
+ TQString fName = *it + "/" + tryexec;
+ if (::access(TQFile::encodeName(fName), R_OK | X_OK) == 0)
+ {
+ match = true;
+ m_exec = fName;
+ break;
+ }
+ }
+ // didn't match at all
+ if (!match)
+ return false;
+ }
+ return true;
+ }
+ return false;
+}
+
+bool KateExternalTool::valid( const TQString &mt ) const
+{
+ return mimetypes.isEmpty() || mimetypes.contains( mt );
+}
+//END KateExternalTool
+
+//BEGIN KateExternalToolsCommand
+KateExternalToolsCommand::KateExternalToolsCommand() : Kate::Command() {
+ m_inited=false;
+ reload();
+}
+
+TQStringList KateExternalToolsCommand::cmds () {
+ return m_list;
+}
+
+KateExternalToolsCommand *KateExternalToolsCommand::self () {
+ if (s_self) return s_self;
+ s_self=new KateExternalToolsCommand;
+ return s_self;
+}
+
+void KateExternalToolsCommand::reload () {
+ m_list.clear();
+ m_map.clear();
+
+ TDEConfig config("externaltools", false, false, "appdata");
+ config.setGroup("Global");
+ TQStringList tools = config.readListEntry("tools");
+
+
+ for( TQStringList::Iterator it = tools.begin(); it != tools.end(); ++it )
+ {
+ if ( *it == "---" )
+ continue;
+
+
+ config.setGroup( *it );
+
+ KateExternalTool t = KateExternalTool(
+ config.readEntry( "name", "" ),
+ config.readEntry( "command", ""),
+ config.readEntry( "icon", ""),
+ config.readEntry( "executable", ""),
+ config.readListEntry( "mimetypes" ),
+ config.readEntry( "acname", "" ),
+ config.readEntry( "cmdname", "" ) );
+ // FIXME test for a command name first!
+ if ( t.hasexec && (!t.cmdname.isEmpty())) {
+ m_list.append("exttool-"+t.cmdname);
+ m_map.insert("exttool-"+t.cmdname,t.acname);
+ }
+ }
+ if (m_inited) {
+ Kate::Document::unregisterCommand(this);
+ Kate::Document::registerCommand(this);
+ }
+ else m_inited=true;
+}
+
+bool KateExternalToolsCommand::exec (Kate::View *view, const TQString &cmd, TQString &) {
+ TQWidget *wv=tqt_dynamic_cast<TQWidget*>(view);
+ if (!wv) {
+// kdDebug(13001)<<"KateExternalToolsCommand::exec: Could not get view widget"<<endl;
+ return false;
+ }
+ KateMDI::MainWindow *dmw=tqt_dynamic_cast<KateMDI::MainWindow*>(wv->topLevelWidget());
+ if (!dmw) {
+// kdDebug(13001)<<"KateExternalToolsCommand::exec: Could not get main window"<<endl;
+ return false;
+ }
+// kdDebug(13001)<<"cmd="<<cmd.stripWhiteSpace()<<endl;
+ TQString actionName=m_map[cmd.stripWhiteSpace()];
+ if (actionName.isEmpty()) return false;
+// kdDebug(13001)<<"actionName is not empty:"<<actionName<<endl;
+ KateExternalToolsMenuAction *a=
+ tqt_dynamic_cast<KateExternalToolsMenuAction*>(dmw->action("tools_external"));
+ if (!a) return false;
+// kdDebug(13001)<<"trying to find action"<<endl;
+ TDEAction *a1=a->actionCollection()->action(static_cast<const char *>(actionName.utf8()));
+ if (!a1) return false;
+// kdDebug(13001)<<"activating action"<<endl;
+ a1->activate();
+ return true;
+}
+
+bool KateExternalToolsCommand::help (Kate::View *, const TQString &, TQString &) {
+ return false;
+}
+//END KateExternalToolsCommand
+
+//BEGIN KateExternalToolAction
+KateExternalToolAction::KateExternalToolAction( TQObject *parent,
+ const char *name, KateExternalTool *t)
+ : TDEAction( parent, name ),
+ tool ( t )
+{
+ setText( t->name );
+ if ( ! t->icon.isEmpty() )
+ setIconSet( SmallIconSet( t->icon ) );
+
+ connect( this ,TQT_SIGNAL(activated()), this, TQT_SLOT(slotRun()) );
+}
+
+bool KateExternalToolAction::expandMacro( const TQString &str, TQStringList &ret )
+{
+ KateMainWindow *mw = (KateMainWindow*)parent()->parent();
+
+ Kate::View *view = mw->viewManager()->activeView();
+ if ( ! view ) return false;
+
+
+ if ( str == "URL" )
+ ret += mw->activeDocumentUrl().url();
+ else if ( str == "directory" ) // directory of current doc
+ ret += mw->activeDocumentUrl().directory();
+ else if ( str == "filename" )
+ ret += mw->activeDocumentUrl().fileName();
+ else if ( str == "line" ) // cursor line of current doc
+ ret += TQString::number( view->cursorLine() );
+ else if ( str == "col" ) // cursor col of current doc
+ ret += TQString::number( view->cursorColumn() );
+ else if ( str == "selection" ) // selection of current doc if any
+ ret += view->getDoc()->selection();
+ else if ( str == "text" ) // text of current doc
+ ret += view->getDoc()->text();
+ else if ( str == "URLs" ) {
+ for( Kate::Document *doc = KateDocManager::self()->firstDocument(); doc; doc = KateDocManager::self()->nextDocument() )
+ if ( ! doc->url().isEmpty() )
+ ret += doc->url().url();
+ } else
+ return false;
+ return true;
+}
+
+KateExternalToolAction::~KateExternalToolAction() {
+ delete(tool);
+}
+
+void KateExternalToolAction::slotRun()
+{
+ // expand the macros in command if any,
+ // and construct a command with an absolute path
+ TQString cmd = tool->command;
+
+ if ( ! expandMacrosShellQuote( cmd ) )
+ {
+ KMessageBox::sorry( (KateMainWindow*)parent()->parent(),
+ i18n("Failed to expand the command '%1'.").arg( cmd ),
+ i18n( "Kate External Tools") );
+ return;
+ }
+ kdDebug(13001)<<"externaltools: Running command: "<<cmd<<endl;
+
+ // save documents if requested
+ KateMainWindow *mw = (KateMainWindow*)parent()->parent();
+ if ( tool->save == 1 )
+ mw->viewManager()->activeView()->document()->save();
+ else if ( tool->save == 2 )
+ mw->actionCollection()->action("file_save_all")->activate();
+
+ KRun::runCommand( cmd, tool->tryexec, tool->icon );
+}
+//END KateExternalToolAction
+
+//BEGIN KateExternalToolsMenuAction
+KateExternalToolsMenuAction::KateExternalToolsMenuAction( const TQString &text,
+ TQObject *parent,
+ const char* name,
+ KateMainWindow *mw )
+ : TDEActionMenu( text, parent, name ),
+ mainwindow( mw )
+{
+
+ m_actionCollection = new TDEActionCollection( mainwindow );
+
+ connect(KateDocManager::self(),TQT_SIGNAL(documentChanged()),this,TQT_SLOT(slotDocumentChanged()));
+
+ reload();
+}
+
+void KateExternalToolsMenuAction::reload()
+{
+ m_actionCollection->clear ();
+ popupMenu()->clear();
+
+ // load all the tools, and create a action for each of them
+ TDEConfig *config = new TDEConfig( "externaltools", false, false, "appdata" );
+ config->setGroup( "Global" );
+ TQStringList tools = config->readListEntry( "tools" );
+
+ // if there are tools that are present but not explicitly removed,
+ // add them to the end of the list
+ config->setReadDefaults( true );
+ TQStringList dtools = config->readListEntry( "tools" );
+ int gver = config->readNumEntry( "version", 1 );
+ config->setReadDefaults( false );
+
+ int ver = config->readNumEntry( "version" );
+ if ( ver <= gver )
+ {
+ TQStringList removed = config->readListEntry( "removed" );
+ bool sepadded = false;
+ for (TQStringList::iterator itg = dtools.begin(); itg != dtools.end(); ++itg )
+ {
+ if ( ! tools.contains( *itg ) &&
+ ! removed.contains( *itg ) )
+ {
+ if ( ! sepadded )
+ {
+ tools << "---";
+ sepadded = true;
+ }
+ tools << *itg;
+ }
+ }
+
+ config->writeEntry( "tools", tools );
+ config->sync();
+ config->writeEntry( "version", gver );
+ }
+
+ for( TQStringList::Iterator it = tools.begin(); it != tools.end(); ++it )
+ {
+ if ( *it == "---" )
+ {
+ popupMenu()->insertSeparator();
+ // a separator
+ continue;
+ }
+
+ config->setGroup( *it );
+
+ KateExternalTool *t = new KateExternalTool(
+ config->readEntry( "name", "" ),
+ config->readEntry( "command", ""),
+ config->readEntry( "icon", ""),
+ config->readEntry( "executable", ""),
+ config->readListEntry( "mimetypes" ),
+ config->readEntry( "acname", "" ),
+ config->readEntry( "cmdname", "" ),
+ config->readNumEntry( "save", 0 ) );
+
+ if ( t->hasexec )
+ insert( new KateExternalToolAction( m_actionCollection, t->acname.ascii(), t ) );
+ }
+
+ m_actionCollection->readShortcutSettings( "Shortcuts", config );
+ slotDocumentChanged();
+ delete config;
+}
+
+void KateExternalToolsMenuAction::slotDocumentChanged()
+{
+ // try to enable/disable to match current mime type
+ Kate::DocumentExt *de = documentExt( KateDocManager::self()->activeDocument() );
+ if ( de )
+ {
+ TQString mt = de->mimeType();
+ TQStringList l;
+ bool b;
+
+ TDEActionPtrList actions = m_actionCollection->actions();
+ for (TDEActionPtrList::iterator it = actions.begin(); it != actions.end(); ++it )
+ {
+ KateExternalToolAction *action = tqt_dynamic_cast<KateExternalToolAction*>(*it);
+ if ( action )
+ {
+ l = action->tool->mimetypes;
+ b = ( ! l.count() || l.contains( mt ) );
+ action->setEnabled( b );
+ }
+ }
+ }
+}
+//END KateExternalToolsMenuAction
+
+//BEGIN ToolItem
+/**
+ * This is a TQListBoxItem, that has a KateExternalTool. The text is the Name
+ * of the tool.
+ */
+class ToolItem : public TQListBoxPixmap
+{
+ public:
+ ToolItem( TQListBox *lb, const TQPixmap &icon, KateExternalTool *tool )
+ : TQListBoxPixmap( lb, icon, tool->name ),
+ tool ( tool )
+ {;}
+
+ ~ToolItem() {};
+
+ KateExternalTool *tool;
+};
+//END ToolItem
+
+//BEGIN KateExternalToolServiceEditor
+KateExternalToolServiceEditor::KateExternalToolServiceEditor( KateExternalTool *tool,
+ TQWidget *parent, const char *name )
+ : KDialogBase( parent, name, true, i18n("Edit External Tool"), KDialogBase::Ok|KDialogBase::Cancel ),
+ tool( tool )
+{
+ // create a entry for each property
+ // fill in the values from the service if available
+ TQWidget *w = new TQWidget( this );
+ setMainWidget( w );
+ TQGridLayout *lo = new TQGridLayout( w );
+ lo->setSpacing( KDialogBase::spacingHint() );
+
+ TQLabel *l;
+
+ leName = new TQLineEdit( w );
+ lo->addWidget( leName, 1, 2 );
+ l = new TQLabel( leName, i18n("&Label:"), w );
+ l->setAlignment( l->alignment()|Qt::AlignRight );
+ lo->addWidget( l, 1, 1 );
+ if ( tool ) leName->setText( tool->name );
+ TQWhatsThis::add( leName, i18n(
+ "The name will be displayed in the 'Tools->External' menu") );
+
+ btnIcon = new TDEIconButton( w );
+ btnIcon->setIconSize( TDEIcon::SizeSmall );
+ lo->addWidget( btnIcon, 1, 3 );
+ if ( tool && !tool->icon.isEmpty() )
+ btnIcon->setIcon( tool->icon );
+
+ teCommand = new TQTextEdit( w );
+ lo->addMultiCellWidget( teCommand, 2, 2, 2, 3 );
+ l = new TQLabel( teCommand, i18n("S&cript:"), w );
+ l->setAlignment( Qt::AlignTop|Qt::AlignRight );
+ lo->addWidget( l, 2, 1 );
+ if ( tool ) teCommand->setText( tool->command );
+ TQWhatsThis::add( teCommand, i18n(
+ "<p>The script to execute to invoke the tool. The script is passed "
+ "to /bin/sh for execution. The following macros "
+ "will be expanded:</p>"
+ "<ul><li><code>%URL</code> - the URL of the current document."
+ "<li><code>%URLs</code> - a list of the URLs of all open documents."
+ "<li><code>%directory</code> - the URL of the directory containing "
+ "the current document."
+ "<li><code>%filename</code> - the filename of the current document."
+ "<li><code>%line</code> - the current line of the text cursor in the "
+ "current view."
+ "<li><code>%column</code> - the column of the text cursor in the "
+ "current view."
+ "<li><code>%selection</code> - the selected text in the current view."
+ "<li><code>%text</code> - the text of the current document.</ul>" ) );
+
+
+ leExecutable = new TQLineEdit( w );
+ lo->addMultiCellWidget( leExecutable, 3, 3, 2, 3 );
+ l = new TQLabel( leExecutable, i18n("&Executable:"), w );
+ l->setAlignment( l->alignment()|Qt::AlignRight );
+ lo->addWidget( l, 3, 1 );
+ if ( tool ) leExecutable->setText( tool->tryexec );
+ TQWhatsThis::add( leExecutable, i18n(
+ "The executable used by the command. This is used to check if a tool "
+ "should be displayed; if not set, the first word of <em>command</em> "
+ "will be used.") );
+
+ leMimetypes = new TQLineEdit( w );
+ lo->addWidget( leMimetypes, 4, 2 );
+ l = new TQLabel( leMimetypes, i18n("&Mime types:"), w );
+ l->setAlignment( l->alignment()|Qt::AlignRight );
+ lo->addWidget( l, 4, 1 );
+ if ( tool ) leMimetypes->setText( tool->mimetypes.join("; ") );
+ TQWhatsThis::add( leMimetypes, i18n(
+ "A semicolon-separated list of mime types for which this tool should "
+ "be available; if this is left empty, the tool is always available. "
+ "To choose from known mimetypes, press the button on the right.") );
+
+ TQToolButton *btnMTW = new TQToolButton(w);
+ lo->addWidget( btnMTW, 4, 3 );
+ btnMTW->setIconSet(TQIconSet(SmallIcon("wizard")));
+ connect(btnMTW, TQT_SIGNAL(clicked()), this, TQT_SLOT(showMTDlg()));
+ TQWhatsThis::add( btnMTW, i18n(
+ "Click for a dialog that can help you creating a list of mimetypes.") );
+
+ cmbSave = new TQComboBox(w);
+ lo->addMultiCellWidget( cmbSave, 5, 5, 2, 3 );
+ l = new TQLabel( cmbSave, i18n("&Save:"), w );
+ l->setAlignment( l->alignment()|Qt::AlignRight );
+ lo->addWidget( l, 5, 1 );
+ TQStringList sl;
+ sl << i18n("None") << i18n("Current Document") << i18n("All Documents");
+ cmbSave->insertStringList( sl );
+ if ( tool ) cmbSave->setCurrentItem( tool->save );
+ TQWhatsThis::add( cmbSave, i18n(
+ "You can elect to save the current or all [modified] documents prior to "
+ "running the command. This is helpful if you want to pass URLs to "
+ "an application like, for example, an FTP client.") );
+
+
+ leCmdLine = new TQLineEdit( w );
+ lo->addMultiCellWidget( leCmdLine, 6, 6, 2, 3 );
+ l = new TQLabel( leCmdLine, i18n("&Command line name:"), w );
+ l->setAlignment( l->alignment()|Qt::AlignRight );
+ lo->addWidget( l, 6, 1 );
+ if ( tool ) leCmdLine->setText( tool->cmdname );
+ TQWhatsThis::add( leCmdLine, i18n(
+ "If you specify a name here, you can invoke the command from the view "
+ "command lines with exttool-the_name_you_specified_here. "
+ "Please do not use spaces or tabs in the name."));
+
+}
+
+void KateExternalToolServiceEditor::slotOk()
+{
+ if ( leName->text().isEmpty() ||
+ teCommand->text().isEmpty() )
+ {
+ KMessageBox::information( this, i18n("You must specify at least a name and a command") );
+ return;
+ }
+
+ KDialogBase::slotOk();
+}
+
+void KateExternalToolServiceEditor::showMTDlg()
+{
+ TQString text = i18n("Select the MimeTypes for which to enable this tool.");
+ TQStringList list = TQStringList::split( TQRegExp("\\s*;\\s*"), leMimetypes->text() );
+ KMimeTypeChooserDialog d( i18n("Select Mime Types"), text, list, "text", this );
+ if ( d.exec() == KDialogBase::Accepted ) {
+ leMimetypes->setText( d.chooser()->mimeTypes().join(";") );
+ }
+}
+//END KateExternalToolServiceEditor
+
+//BEGIN KateExternalToolsConfigWidget
+KateExternalToolsConfigWidget::KateExternalToolsConfigWidget( TQWidget *parent, const char* name )
+ : Kate::ConfigPage( parent, name ),
+ m_changed( false )
+{
+ TQGridLayout *lo = new TQGridLayout( this, 5, 5, 0, KDialog::spacingHint() );
+
+ lbTools = new TDEListBox( this );
+ lo->addMultiCellWidget( lbTools, 1, 4, 0, 3 );
+ connect( lbTools, TQT_SIGNAL(selectionChanged()), this, TQT_SLOT(slotSelectionChanged()) );
+
+ btnNew = new TQPushButton( i18n("&New..."), this );
+ lo->addWidget( btnNew, 5, 0 );
+ connect( btnNew, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotNew()) );
+
+ btnRemove = new TQPushButton( i18n("&Remove"), this );
+ lo->addWidget( btnRemove, 5, 2 );
+ connect( btnRemove, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotRemove()) );
+
+ btnEdit = new TQPushButton( i18n("&Edit..."), this );
+ lo->addWidget( btnEdit, 5, 1 );
+ connect( btnEdit, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotEdit()) );
+
+ TQPushButton *b = new TQPushButton( i18n("Insert &Separator"), this );
+ lo->addWidget( b, 5, 3 );
+ connect( b, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotInsertSeparator()) );
+
+ btnMoveUp = new TQPushButton( SmallIconSet("up"), "", this );
+ lo->addWidget( btnMoveUp, 2, 4 );
+ connect( btnMoveUp, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotMoveUp()) );
+
+ btnMoveDwn = new TQPushButton( SmallIconSet("down"), "", this );
+ lo->addWidget( btnMoveDwn, 3, 4 );
+ connect( btnMoveDwn, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotMoveDown()) );
+
+ connect( lbTools, TQT_SIGNAL( doubleClicked ( TQListBoxItem * ) ), this, TQT_SLOT( slotEdit() ) );
+
+ lo->setRowStretch( 1, 1 );
+ lo->setRowStretch( 4, 1 );
+ lo->setColStretch( 0, 1 );
+ lo->setColStretch( 1, 1 );
+ lo->setColStretch( 2, 1 );
+
+
+ TQWhatsThis::add( lbTools, i18n(
+ "This list shows all the configured tools, represented by their menu text.") );
+
+ config = new TDEConfig("externaltools", false, false, "appdata");
+ reload();
+ slotSelectionChanged();
+}
+
+KateExternalToolsConfigWidget::~KateExternalToolsConfigWidget()
+{
+ delete config;
+}
+
+void KateExternalToolsConfigWidget::reload()
+{
+ //m_tools.clear();
+ lbTools->clear();
+
+ // load the files from a TDEConfig
+ config->setGroup( "Global" );
+ TQStringList tools = config->readListEntry("tools");
+
+ for( TQStringList::Iterator it = tools.begin(); it != tools.end(); ++it )
+ {
+ if ( *it == "---" )
+ {
+ new TQListBoxText( lbTools, "---" );
+ }
+ else
+ {
+ config->setGroup( *it );
+
+ KateExternalTool *t = new KateExternalTool(
+ config->readEntry( "name", "" ),
+ config->readEntry( "command", ""),
+ config->readEntry( "icon", ""),
+ config->readEntry( "executable", ""),
+ config->readListEntry( "mimetypes" ),
+ config->readEntry( "acname" ),
+ config->readEntry( "cmdname"),
+ config->readNumEntry( "save", 0 ) );
+
+ if ( t->hasexec ) // we only show tools that are also in the menu.
+ new ToolItem( lbTools, t->icon.isEmpty() ? blankIcon() : SmallIcon( t->icon ), t );
+ }
+ }
+ m_changed = false;
+}
+
+TQPixmap KateExternalToolsConfigWidget::blankIcon()
+{
+ TQPixmap pm( TDEIcon::SizeSmall, TDEIcon::SizeSmall );
+ pm.fill();
+ pm.setMask( pm.createHeuristicMask() );
+ return pm;
+}
+
+void KateExternalToolsConfigWidget::apply()
+{
+ if ( ! m_changed )
+ return;
+ m_changed = false;
+
+ // save a new list
+ // save each item
+ TQStringList tools;
+ for ( uint i = 0; i < lbTools->count(); i++ )
+ {
+ if ( lbTools->text( i ) == "---" )
+ {
+ tools << "---";
+ continue;
+ }
+ KateExternalTool *t = ((ToolItem*)lbTools->item( i ))->tool;
+// kdDebug(13001)<<"adding tool: "<<t->name<<endl;
+ tools << t->acname;
+
+ config->setGroup( t->acname );
+ config->writeEntry( "name", t->name );
+ config->writeEntry( "command", t->command );
+ config->writeEntry( "icon", t->icon );
+ config->writeEntry( "executable", t->tryexec );
+ config->writeEntry( "mimetypes", t->mimetypes );
+ config->writeEntry( "acname", t->acname );
+ config->writeEntry( "cmdname", t->cmdname );
+ config->writeEntry( "save", t->save );
+ }
+
+ config->setGroup("Global");
+ config->writeEntry( "tools", tools );
+
+ // if any tools was removed, try to delete their groups, and
+ // add the group names to the list of removed items.
+ if ( m_removed.count() )
+ {
+ for ( TQStringList::iterator it = m_removed.begin(); it != m_removed.end(); ++it )
+ {
+ if ( config->hasGroup( *it ) )
+ config->deleteGroup( *it );
+ }
+ TQStringList removed = config->readListEntry( "removed" );
+ removed += m_removed;
+
+ // clean up the list of removed items, so that it does not contain
+ // non-existing groups (we can't remove groups from a non-owned global file).
+ config->sync();
+ TQStringList::iterator it1 = removed.begin();
+ while( it1 != removed.end() )
+ {
+ if ( ! config->hasGroup( *it1 ) )
+ it1 = removed.remove( it1 );
+ else
+ ++it1;
+ }
+ config->writeEntry( "removed", removed );
+ }
+
+ config->sync();
+}
+
+void KateExternalToolsConfigWidget::slotSelectionChanged()
+{
+ // update button state
+ bool hs = lbTools->selectedItem() != 0;
+ btnEdit->setEnabled( hs && dynamic_cast<ToolItem*>(lbTools->selectedItem()) );
+ btnRemove->setEnabled( hs );
+ btnMoveUp->setEnabled( ( lbTools->currentItem() > 0 ) && hs );
+ btnMoveDwn->setEnabled( ( lbTools->currentItem() < (int)lbTools->count()-1 )&&hs );
+}
+
+void KateExternalToolsConfigWidget::slotNew()
+{
+ // display a editor, and if it is OK'd, create a new tool and
+ // create a listbox item for it
+ KateExternalToolServiceEditor editor( 0, this );
+
+ if ( editor.exec() )
+ {
+ KateExternalTool *t = new KateExternalTool(
+ editor.leName->text(),
+ editor.teCommand->text(),
+ editor.btnIcon->icon(),
+ editor.leExecutable->text(),
+ TQStringList::split( TQRegExp("\\s*;\\s*"), editor.leMimetypes->text() ) );
+
+ // This is sticky, it does not change again, so that shortcuts sticks
+ // TODO check for dups
+ t->acname = "externaltool_" + TQString(t->name).replace( TQRegExp("\\W+"), "" );
+
+ new ToolItem ( lbTools, t->icon.isEmpty() ? blankIcon() : SmallIcon( t->icon ), t );
+
+ slotChanged();
+ m_changed = true;
+ }
+}
+
+void KateExternalToolsConfigWidget::slotRemove()
+{
+ // add the tool action name to a list of removed items,
+ // remove the current listbox item
+ if ( lbTools->currentItem() > -1 ) {
+ ToolItem *i = dynamic_cast<ToolItem*>(lbTools->selectedItem());
+ if ( i )
+ m_removed << i->tool->acname;
+
+ lbTools->removeItem( lbTools->currentItem() );
+ slotChanged();
+ m_changed = true;
+ }
+}
+
+void KateExternalToolsConfigWidget::slotEdit()
+{
+ if( !dynamic_cast<ToolItem*>(lbTools->selectedItem()) ) return;
+ // show the item in an editor
+ KateExternalTool *t = ((ToolItem*)lbTools->selectedItem())->tool;
+ KateExternalToolServiceEditor editor( t, this);
+ config->setGroup( "Editor" );
+ editor.resize( config->readSizeEntry( "Size" ) );
+ if ( editor.exec() /*== KDialogBase::Ok*/ )
+ {
+
+ bool elementChanged = ( ( editor.btnIcon->icon() != t->icon ) || (editor.leName->text() != t->name ) ) ;
+
+ t->name = editor.leName->text();
+ t->cmdname = editor.leCmdLine->text();
+ t->command = editor.teCommand->text();
+ t->icon = editor.btnIcon->icon();
+ t->tryexec = editor.leExecutable->text();
+ t->mimetypes = TQStringList::split( TQRegExp("\\s*;\\s*"), editor.leMimetypes->text() );
+ t->save = editor.cmbSave->currentItem();
+
+ //if the icon has changed or name changed, I have to renew the listbox item :S
+ if ( elementChanged )
+ {
+ int idx = lbTools->index( lbTools->selectedItem() );
+ lbTools->removeItem( idx );
+ lbTools->insertItem( new ToolItem( 0, t->icon.isEmpty() ? blankIcon() : SmallIcon( t->icon ), t ), idx );
+ }
+
+ slotChanged();
+ m_changed = true;
+ }
+
+ config->setGroup( "Editor" );
+ config->writeEntry( "Size", editor.size() );
+ config->sync();
+}
+
+void KateExternalToolsConfigWidget::slotInsertSeparator()
+{
+ lbTools->insertItem( "---", lbTools->currentItem()+1 );
+ slotChanged();
+ m_changed = true;
+}
+
+void KateExternalToolsConfigWidget::slotMoveUp()
+{
+ // move the current item in the listbox upwards if possible
+ TQListBoxItem *item = lbTools->selectedItem();
+ if ( ! item ) return;
+
+ int idx = lbTools->index( item );
+
+ if ( idx < 1 ) return;
+
+ if ( dynamic_cast<ToolItem*>(item) )
+ {
+ KateExternalTool *tool = ((ToolItem*)item)->tool;
+ lbTools->removeItem( idx );
+ lbTools->insertItem( new ToolItem( 0, tool->icon.isEmpty() ? blankIcon() : SmallIcon( tool->icon ), tool ), idx-1 );
+ }
+ else // a separator!
+ {
+ lbTools->removeItem( idx );
+ lbTools->insertItem( new TQListBoxText( 0, "---" ), idx-1 );
+ }
+
+ lbTools->setCurrentItem( idx - 1 );
+ slotSelectionChanged();
+ slotChanged();
+ m_changed = true;
+}
+
+void KateExternalToolsConfigWidget::slotMoveDown()
+{
+ // move the current item in the listbox downwards if possible
+ TQListBoxItem *item = lbTools->selectedItem();
+ if ( ! item ) return;
+
+ uint idx = lbTools->index( item );
+
+ if ( idx > lbTools->count()-1 ) return;
+
+ if ( dynamic_cast<ToolItem*>(item) )
+ {
+ KateExternalTool *tool = ((ToolItem*)item)->tool;
+ lbTools->removeItem( idx );
+ lbTools->insertItem( new ToolItem( 0, tool->icon.isEmpty() ? blankIcon() : SmallIcon( tool->icon ), tool ), idx+1 );
+ }
+ else // a separator!
+ {
+ lbTools->removeItem( idx );
+ lbTools->insertItem( new TQListBoxText( 0, "---" ), idx+1 );
+ }
+
+ lbTools->setCurrentItem( idx+1 );
+ slotSelectionChanged();
+ slotChanged();
+ m_changed = true;
+}
+//END KateExternalToolsConfigWidget
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/kateexternaltools.h b/kate/app/kateexternaltools.h
new file mode 100644
index 000000000..ef3a9e9fd
--- /dev/null
+++ b/kate/app/kateexternaltools.h
@@ -0,0 +1,229 @@
+/*
+ This file is part of the Kate text editor of the KDE project.
+ It describes a "external tools" action for kate and provides a dialog
+ page to configure that.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+ ---
+ Copyright (C) 2004, Anders Lund <anders@alweb.dk>
+*/
+
+#ifndef _KATE_EXTERNAL_TOOLS_H_
+#define _KATE_EXTERNAL_TOOLS_H_
+
+#include <tdeaction.h>
+#include <kdialogbase.h>
+#include <kate/document.h>
+#include <kmacroexpander.h>
+#include <tqpixmap.h>
+
+/**
+ * The external tools action
+ * This action creates a menu, in which each item will launch a process
+ * with the provided arguments, which may include the following macros:
+ * - %URLS: the URLs of all open documents.
+ * - %URL: The URL of the active document.
+ * - %filedir: The directory of the current document, if that is a local file.
+ * - %selection: The selection of the active document.
+ * - %text: The text of the active document.
+ * - %line: The line number of the cursor in the active view.
+ * - %column: The column of the cursor in the active view.
+ *
+ * Each item has the following properties:
+ * - Name: The friendly text for the menu
+ * - Exec: The command to execute, including arguments.
+ * - TryExec: the name of the executable, if not available, the
+ * item will not be displayed.
+ * - MimeTypes: An optional list of mimetypes. The item will be disabled or
+ * hidden if the current file is not of one of the indicated types.
+ *
+ */
+class KateExternalToolsMenuAction : public TDEActionMenu
+{
+ friend class KateExternalToolAction;
+
+ Q_OBJECT
+ public:
+ KateExternalToolsMenuAction( const TQString &text=TQString::null, TQObject *parent=0, const char* name=0, class KateMainWindow *mw=0 );
+ ~KateExternalToolsMenuAction() {};
+
+ /**
+ * This will load all the confiured services.
+ */
+ void reload();
+
+ class TDEActionCollection *actionCollection() { return m_actionCollection; }
+
+ private slots:
+ void slotDocumentChanged();
+
+ private:
+ class TDEActionCollection *m_actionCollection;
+ class KateMainWindow *mainwindow; // for the actions to access view/doc managers
+};
+
+/**
+ * This Action contains a KateExternalTool
+ */
+class KateExternalToolAction : public TDEAction, public KWordMacroExpander
+{
+ Q_OBJECT
+ public:
+ KateExternalToolAction( TQObject *parent, const char *name, class KateExternalTool *t );
+ ~KateExternalToolAction();
+ protected:
+ virtual bool expandMacro( const TQString &str, TQStringList &ret );
+
+ private slots:
+ void slotRun();
+
+ public:
+ class KateExternalTool *tool;
+};
+
+/**
+ * This class defines a single external tool.
+ */
+class KateExternalTool
+{
+ public:
+ KateExternalTool( const TQString &name=TQString::null,
+ const TQString &command=TQString::null,
+ const TQString &icon=TQString::null,
+ const TQString &tryexec=TQString::null,
+ const TQStringList &mimetypes=TQStringList(),
+ const TQString &acname=TQString::null,
+ const TQString &cmdname=TQString::null,
+ int save=0 );
+ ~KateExternalTool() {};
+
+ TQString name; ///< The name used in the menu.
+ TQString command; ///< The command to execute.
+ TQString icon; ///< the icon to use in the menu.
+ TQString tryexec; ///< The name or path of the executable.
+ TQStringList mimetypes; ///< Optional list of mimetypes for which this action is valid.
+ bool hasexec; ///< This is set by the constructor by calling checkExec(), if a value is present.
+ TQString acname; ///< The name for the action. This is generated first time the action is is created.
+ TQString cmdname; ///< The name for the commandline.
+ int save; ///< We can save documents prior to activating the tool command: 0 = nothing, 1 = current document, 2 = all documents.
+
+ /**
+ * @return true if mimetypes is empty, or the @p mimetype matches.
+ */
+ bool valid( const TQString &mimetype ) const;
+ /**
+ * @return true if "tryexec" exists and has the executable bit set, or is
+ * empty.
+ * This is run at least once, and the tool is disabled if it fails.
+ */
+ bool checkExec();
+
+ private:
+ TQString m_exec; ///< The fully qualified path of the executable.
+};
+
+/**
+ * The config widget.
+ * The config widget allows the user to view a list of services of the type
+ * "Kate/ExternalTool" and add, remove or edit them.
+ */
+class KateExternalToolsConfigWidget : public Kate::ConfigPage
+{
+ Q_OBJECT
+ public:
+ KateExternalToolsConfigWidget( TQWidget *parent, const char* name);
+ virtual ~KateExternalToolsConfigWidget();
+
+ virtual void apply();
+ virtual void reload();
+ virtual void reset() { reload(); } // sigh
+ virtual void defaults() { reload(); } // double sigh
+
+ private slots:
+ void slotNew();
+ void slotEdit();
+ void slotRemove();
+ void slotInsertSeparator();
+
+ void slotMoveUp();
+ void slotMoveDown();
+
+ void slotSelectionChanged();
+
+ private:
+ TQPixmap blankIcon();
+
+ TQStringList m_removed;
+
+ class TDEListBox *lbTools;
+ class TQPushButton *btnNew, *btnRemove, *btnEdit, *btnMoveUp, *btnMoveDwn;
+
+ class TDEConfig *config;
+
+ bool m_changed;
+};
+
+/**
+ * A Singleton class for invoking external tools with the view command line
+ */
+ class KateExternalToolsCommand : public Kate::Command {
+ public:
+ KateExternalToolsCommand ();
+ virtual ~KateExternalToolsCommand () {};
+ static KateExternalToolsCommand *self();
+ void reload();
+ public:
+ virtual TQStringList cmds ();
+ virtual bool exec (Kate::View *view, const TQString &cmd, TQString &msg);
+ virtual bool help (Kate::View *view, const TQString &cmd, TQString &msg);
+ private:
+ static KateExternalToolsCommand *s_self;
+ TQStringList m_list;
+ TQMap<TQString,TQString> m_map;
+ bool m_inited;
+ };
+
+/**
+ * A Dialog to edit a single KateExternalTool object
+ */
+class KateExternalToolServiceEditor : public KDialogBase
+{
+ Q_OBJECT
+
+ public:
+
+ KateExternalToolServiceEditor( KateExternalTool *tool=0,
+ TQWidget *parent=0, const char *name=0 );
+
+ class TQLineEdit *leName, *leExecutable, *leMimetypes,*leCmdLine;
+ class TQTextEdit *teCommand;
+ class TDEIconButton *btnIcon;
+ class TQComboBox *cmbSave;
+
+ private slots:
+ /**
+ * Run when the OK button is clicked, to ensure critical values are provided
+ */
+ void slotOk();
+ /**
+ * show a mimetype chooser dialog
+ */
+ void showMTDlg();
+
+ private:
+ KateExternalTool *tool;
+};
+#endif //_KATE_EXTERNAL_TOOLS_H_
diff --git a/kate/app/katefilelist.cpp b/kate/app/katefilelist.cpp
new file mode 100644
index 000000000..98857b3c3
--- /dev/null
+++ b/kate/app/katefilelist.cpp
@@ -0,0 +1,749 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
+ Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+//BEGIN Includes
+#include "katefilelist.h"
+#include "katefilelist.moc"
+
+#include "katedocmanager.h"
+#include "kateviewmanager.h"
+#include "katemainwindow.h"
+
+#include <tqapplication.h>
+#include <tqpainter.h>
+#include <tqpopupmenu.h>
+#include <tqheader.h>
+#include <tqcolor.h>
+#include <tqcheckbox.h>
+#include <tqhbox.h>
+#include <tqlayout.h>
+#include <tqgroupbox.h>
+#include <tqlabel.h>
+#include <tqwhatsthis.h>
+
+#include <kiconloader.h>
+#include <tdeconfig.h>
+#include <tdelocale.h>
+#include <tdeglobalsettings.h>
+#include <kpassivepopup.h>
+#include <kdebug.h>
+#include <tdeapplication.h>
+#include <kstringhandler.h>
+#include <kcolorbutton.h>
+#include <kdialog.h>
+//END Includes
+
+//BEGIN ToolTip
+class ToolTip : public TQToolTip
+{
+ public:
+ ToolTip( TQWidget *parent, KateFileList *lv )
+ : TQToolTip( parent ),
+ m_listView( lv )
+ {
+ }
+ virtual ~ToolTip() {};
+
+ void maybeTip( const TQPoint &pos )
+ {
+ TQListViewItem *i = m_listView->itemAt( pos );
+ if ( ! i ) return;
+
+ KateFileListItem *item = ((KateFileListItem*)i);
+ if ( ! item ) return;
+
+ tip( m_listView->itemRect( i ), m_listView->tooltip( item, 0 ) );
+
+ }
+
+ private:
+ KateFileList *m_listView;
+};
+
+//END ToolTip
+
+//BEGIN KateFileList
+KateFileList::KateFileList (KateMainWindow *main,
+ KateViewManager *_viewManager,
+ TQWidget * parent, const char * name )
+ : TDEListView (parent, name)
+ , m_sort( KateFileList::sortByID )
+{
+ m_main = main;
+ m_tooltip = new ToolTip( viewport(), this );
+
+ // default colors
+ m_viewShade = TQColor( 51, 204, 255 );
+ m_editShade = TQColor( 255, 102, 153 );
+ m_enableBgShading = false;
+
+ setFocusPolicy ( TQ_NoFocus );
+
+ viewManager = _viewManager;
+
+ header()->hide();
+ addColumn("Document Name");
+
+ setSelectionMode( TQListView::Single );
+ setSortType(KateFileList::sortByID);
+ setShowToolTips( false );
+
+ setupActions ();
+
+ connect(this,TQT_SIGNAL(moved()),this,TQT_SLOT(updateFileListLocations()));
+
+ for (uint i = 0; i < KateDocManager::self()->documents(); i++)
+ {
+ slotDocumentCreated (KateDocManager::self()->document(i));
+ slotModChanged (KateDocManager::self()->document(i));
+ }
+
+ connect(KateDocManager::self(),TQT_SIGNAL(documentCreated(Kate::Document *)),
+ this,TQT_SLOT(slotDocumentCreated(Kate::Document *)));
+ connect(KateDocManager::self(),TQT_SIGNAL(documentDeleted(uint)),
+ this,TQT_SLOT(slotDocumentDeleted(uint)));
+
+ // don't Honour KDE single/double click setting, this files are already open,
+ // no need for hassle of considering double-click
+ connect(this,TQT_SIGNAL(selectionChanged(TQListViewItem *)),
+ this,TQT_SLOT(slotActivateView(TQListViewItem *)));
+ connect(viewManager,TQT_SIGNAL(viewChanged()), this,TQT_SLOT(slotViewChanged()));
+ connect(this,TQT_SIGNAL(contextMenuRequested( TQListViewItem *, const TQPoint &, int )),
+ this,TQT_SLOT(slotMenu ( TQListViewItem *, const TQPoint &, int )));
+}
+
+KateFileList::~KateFileList ()
+{
+ delete m_tooltip;
+}
+
+void KateFileList::setupActions ()
+{
+ windowNext = KStdAction::back(TQT_TQOBJECT(this), TQT_SLOT(slotPrevDocument()), m_main->actionCollection());
+ windowPrev = KStdAction::forward(TQT_TQOBJECT(this), TQT_SLOT(slotNextDocument()), m_main->actionCollection());
+ sortAction = new TDESelectAction( i18n("Sort &By"), 0,
+ m_main->actionCollection(), "filelist_sortby" );
+ listMoveFileUp = new TDEAction( i18n("Move File Up"), 0, m_main->actionCollection(), "filelist_move_up" );
+ //listMoveFileUp->setShortcut(TDEShortcut(CTRL + SHIFT + Key_Comma));
+ listMoveFileDown = new TDEAction( i18n("Move File Down"), 0, m_main->actionCollection(), "filelist_move_down" );
+ //listMoveFileDown->setShortcut(TDEShortcut(CTRL + SHIFT + Key_Period));
+ connect( listMoveFileUp, TQT_SIGNAL(activated()), TQT_TQOBJECT(this), TQT_SLOT(moveFileUp()) );
+ connect( listMoveFileDown, TQT_SIGNAL(activated()), TQT_TQOBJECT(this), TQT_SLOT(moveFileDown()) );
+ TQStringList l;
+ l << i18n("Opening Order") << i18n("Document Name") << i18n("URL") << i18n("Manual Placement");
+ sortAction->setItems( l );
+ connect( sortAction, TQT_SIGNAL(activated(int)), TQT_TQOBJECT(this), TQT_SLOT(setSortType(int)) );
+}
+
+void KateFileList::updateActions ()
+{
+ windowNext->setEnabled(KateDocManager::self()->documents() > 1);
+ windowPrev->setEnabled(KateDocManager::self()->documents() > 1);
+}
+
+void KateFileList::keyPressEvent(TQKeyEvent *e) {
+ if ( ( e->key() == Key_Return ) || ( e->key() == Key_Enter ) )
+ {
+ e->accept();
+ slotActivateView( currentItem() );
+ }
+ else
+ {
+ TDEListView::keyPressEvent(e);
+ }
+}
+
+// Protect single mode selection: don't let them
+// leftclick outside items.
+// ### if we get to accept keyboard navigation, set focus before
+// returning
+void KateFileList::contentsMousePressEvent( TQMouseEvent *e )
+{
+ if ( ! itemAt( contentsToViewport( e->pos() ) ) )
+ return;
+
+ TDEListView::contentsMousePressEvent( e );
+}
+
+void KateFileList::resizeEvent( TQResizeEvent *e )
+{
+ TDEListView::resizeEvent( e );
+
+ // ### We may want to actually calculate the widest field,
+ // since it's not automatically scrinked. If I add support for
+ // tree or marks, the changes of the required width will vary
+ // a lot with opening/closing of files and display changes for
+ // the mark branches.
+ int w = viewport()->width();
+ if ( columnWidth( 0 ) < w )
+ setColumnWidth( 0, w );
+}
+
+void KateFileList::slotNextDocument()
+{
+ if ( ! currentItem() || childCount() == 0 )
+ return;
+
+ // ### more checking once more item types are added
+
+ if ( currentItem()->nextSibling() )
+ viewManager->activateView( ((KateFileListItem*)currentItem()->nextSibling())->documentNumber() );
+ else
+ viewManager->activateView( ((KateFileListItem *)firstChild())->documentNumber() );
+}
+
+void KateFileList::slotPrevDocument()
+{
+ if ( ! currentItem() || childCount() == 0 )
+ return;
+
+ // ### more checking once more item types are added
+
+ if ( currentItem()->itemAbove() )
+ viewManager->activateView( ((KateFileListItem*)currentItem()->itemAbove())->documentNumber() );
+ else
+ viewManager->activateView( ((KateFileListItem *)lastItem())->documentNumber() );
+}
+
+void KateFileList::slotDocumentCreated (Kate::Document *doc)
+{
+ new KateFileListItem( this, doc/*, doc->documentNumber()*/ );
+ connect(doc,TQT_SIGNAL(modStateChanged(Kate::Document *)),this,TQT_SLOT(slotModChanged(Kate::Document *)));
+ connect(doc,TQT_SIGNAL(nameChanged(Kate::Document *)),this,TQT_SLOT(slotNameChanged(Kate::Document *)));
+ connect(doc,TQT_SIGNAL(modifiedOnDisc(Kate::Document *, bool, unsigned char)),this,TQT_SLOT(slotModifiedOnDisc(Kate::Document *, bool, unsigned char)));
+
+ sort();
+ updateFileListLocations();
+ updateActions ();
+}
+
+void KateFileList::slotDocumentDeleted (uint documentNumber)
+{
+ TQListViewItem * item = firstChild();
+ while( item ) {
+ if ( ((KateFileListItem *)item)->documentNumber() == documentNumber )
+ {
+// m_viewHistory.removeRef( (KateFileListItem *)item );
+// m_editHistory.removeRef( (KateFileListItem *)item );
+
+ removeItem( item );
+
+ break;
+ }
+ item = item->nextSibling();
+ }
+
+ updateFileListLocations();
+ updateActions ();
+}
+
+void KateFileList::slotActivateView( TQListViewItem *item )
+{
+ if ( ! item || item->rtti() != RTTI_KateFileListItem )
+ return;
+
+ viewManager->activateView( ((KateFileListItem *)item)->documentNumber() );
+}
+
+void KateFileList::slotModChanged (Kate::Document *doc)
+{
+ if (!doc) return;
+
+ TQListViewItem * item = firstChild();
+ while( item )
+ {
+ if ( ((KateFileListItem *)item)->documentNumber() == doc->documentNumber() )
+ break;
+
+ item = item->nextSibling();
+ }
+
+ if ( ((KateFileListItem *)item)->document()->isModified() )
+ {
+ m_editHistory.removeRef( (KateFileListItem *)item );
+ m_editHistory.prepend( (KateFileListItem *)item );
+
+ for ( uint i=0; i < m_editHistory.count(); i++ )
+ {
+ m_editHistory.at( i )->setEditHistPos( i+1 );
+ repaintItem( m_editHistory.at( i ) );
+ }
+ }
+ else
+ repaintItem( item );
+}
+
+void KateFileList::slotModifiedOnDisc (Kate::Document *doc, bool, unsigned char)
+{
+ slotModChanged( doc );
+}
+
+void KateFileList::slotNameChanged (Kate::Document *doc)
+{
+ if (!doc) return;
+
+ // ### using nextSibling to *only* look at toplevel items.
+ // child items could be marks for example
+ TQListViewItem * item = firstChild();
+ while( item ) {
+ if ( ((KateFileListItem*)item)->document() == doc )
+ {
+ item->setText( 0, doc->docName() );
+ repaintItem( item );
+ break;
+ }
+ item = item->nextSibling();
+ }
+ updateSort();
+}
+
+void KateFileList::slotViewChanged ()
+{
+ if (!viewManager->activeView()) return;
+
+ Kate::View *view = viewManager->activeView();
+ uint dn = view->getDoc()->documentNumber();
+
+ TQListViewItem * i = firstChild();
+ while( i ) {
+ if ( ((KateFileListItem *)i)->documentNumber() == dn )
+ {
+ break;
+ }
+ i = i->nextSibling();
+ }
+
+ if ( ! i )
+ return;
+
+ KateFileListItem *item = (KateFileListItem*)i;
+ setCurrentItem( item );
+
+ // ### During load of file lists, all the loaded views gets active.
+ // Do something to avoid shading them -- maybe not creating views, just
+ // open the documents???
+
+
+// int p = 0;
+// if ( m_viewHistory.count() )
+// {
+// int p = m_viewHistory.findRef( item ); // only repaint items that needs it
+// }
+
+ m_viewHistory.removeRef( item );
+ m_viewHistory.prepend( item );
+
+ for ( uint i=0; i < m_viewHistory.count(); i++ )
+ {
+ m_viewHistory.at( i )->setViewHistPos( i+1 );
+ repaintItem( m_viewHistory.at( i ) );
+ }
+
+ updateFileListLocations();
+}
+
+void KateFileList::updateFileListLocations()
+{
+ TQListViewItem* item = firstChild();
+ int i=0;
+ while (item) {
+ Kate::Document* itemDocument = ((KateFileListItem *)item)->document();
+ if (m_sort == KateFileList::sortManual) {
+ if (KateDocManager::self()->findDocument(itemDocument) >= 0) {
+ itemDocument->setDocumentListPosition(i);
+ }
+ }
+ else {
+ if (KateDocManager::self()->findDocument(itemDocument) >= 0) {
+ itemDocument->setDocumentListPosition(-1);
+ }
+ }
+ item = item->itemBelow();
+ i++;
+ }
+}
+
+void KateFileList::slotMenu ( TQListViewItem *item, const TQPoint &p, int /*col*/ )
+{
+ if (!item)
+ return;
+
+ m_clickedMenuItem = item;
+ if (m_clickedMenuItem->itemAbove()) {
+ listMoveFileUp->setEnabled(true);
+ }
+ else {
+ listMoveFileUp->setEnabled(false);
+ }
+ if (m_clickedMenuItem->itemBelow()) {
+ listMoveFileDown->setEnabled(true);
+ }
+ else {
+ listMoveFileDown->setEnabled(false);
+ }
+
+ TQPopupMenu *menu = (TQPopupMenu*) ((viewManager->mainWindow())->factory()->container("filelist_popup", viewManager->mainWindow()));
+
+ if (menu) {
+ menu->exec(p);
+ }
+}
+
+TQString KateFileList::tooltip( TQListViewItem *item, int )
+{
+ KateFileListItem *i = ((KateFileListItem*)item);
+ if ( ! i ) return TQString::null;
+
+ TQString str;
+ const KateDocumentInfo *info = KateDocManager::self()->documentInfo(i->document());
+
+ if (info && info->modifiedOnDisc)
+ {
+ if (info->modifiedOnDiscReason == 1)
+ str += i18n("<b>This file was changed (modified) on disk by another program.</b><br />");
+ else if (info->modifiedOnDiscReason == 2)
+ str += i18n("<b>This file was changed (created) on disk by another program.</b><br />");
+ else if (info->modifiedOnDiscReason == 3)
+ str += i18n("<b>This file was changed (deleted) on disk by another program.</b><br />");
+ }
+
+ str += i->document()->url().prettyURL();
+ return str;
+}
+
+
+void KateFileList::setSortType (int s)
+{
+ m_sort = s;
+ if (m_sort == KateFileList::sortManual) {
+ setSorting( -1, true );
+ setDragEnabled(true);
+ setAcceptDrops(true);
+ }
+ else {
+ setSorting( 0, true );
+ setDragEnabled(false);
+ setAcceptDrops(false);
+ updateSort ();
+ }
+}
+
+void KateFileList::moveFileUp()
+{
+ if (m_clickedMenuItem) {
+ sortAction->setCurrentItem(KateFileList::sortManual);
+ setSortType(KateFileList::sortManual);
+ TQListViewItem* nitemabove = m_clickedMenuItem->itemAbove();
+ if (nitemabove) {
+ nitemabove = nitemabove->itemAbove();
+ if (nitemabove) {
+ m_clickedMenuItem->moveItem(nitemabove);
+ }
+ else {
+ // Qt made this hard
+ nitemabove = m_clickedMenuItem->itemAbove();
+ nitemabove->moveItem(m_clickedMenuItem);
+ }
+ }
+ }
+ updateFileListLocations();
+}
+
+void KateFileList::moveFileDown()
+{
+ if (m_clickedMenuItem) {
+ sortAction->setCurrentItem(KateFileList::sortManual);
+ setSortType(KateFileList::sortManual);
+ TQListViewItem* nitemabove = m_clickedMenuItem->itemBelow();
+ if (nitemabove) {
+ m_clickedMenuItem->moveItem(nitemabove);
+ }
+ }
+ updateFileListLocations();
+}
+
+void KateFileList::updateSort ()
+{
+ sort ();
+ updateFileListLocations();
+}
+
+void KateFileList::readConfig( TDEConfig *config, const TQString &group )
+{
+ TQString oldgroup = config->group();
+ config->setGroup( group );
+
+ setSortType( config->readNumEntry( "Sort Type", sortByID ) );
+ m_viewShade = config->readColorEntry( "View Shade", &m_viewShade );
+ m_editShade = config->readColorEntry( "Edit Shade", &m_editShade );
+ m_enableBgShading = config->readBoolEntry( "Shading Enabled", &m_enableBgShading );
+
+ sortAction->setCurrentItem( sortType() );
+
+ config->setGroup( oldgroup );
+}
+
+void KateFileList::writeConfig( TDEConfig *config, const TQString &group )
+{
+ TQString oldgroup = config->group();
+ config->setGroup( group );
+
+ config->writeEntry( "Sort Type", m_sort );
+ config->writeEntry( "View Shade", m_viewShade );
+ config->writeEntry( "Edit Shade", m_editShade );
+ config->writeEntry( "Shading Enabled", m_enableBgShading );
+
+ config->setGroup( oldgroup );
+}
+
+void KateFileList::takeItem( TQListViewItem *item )
+{
+ if ( item->rtti() == RTTI_KateFileListItem )
+ {
+ m_editHistory.removeRef( (KateFileListItem*)item );
+ m_viewHistory.removeRef( (KateFileListItem*)item );
+ }
+ TQListView::takeItem( item );
+}
+//END KateFileList
+
+//BEGIN KateFileListItem
+KateFileListItem::KateFileListItem( TQListView* lv,
+ Kate::Document *_doc )
+ : TQListViewItem( lv, _doc->docName() ),
+ doc( _doc ),
+ m_viewhistpos( 0 ),
+ m_edithistpos( 0 ),
+ m_docNumber( _doc->documentNumber() )
+{
+ // Move this document to the end of the list where it belongs
+ TQListViewItem* lastitem = lv->lastItem();
+ if (lastitem) {
+ moveItem(lastitem);
+ }
+}
+
+KateFileListItem::~KateFileListItem()
+{
+}
+
+const TQPixmap *KateFileListItem::pixmap ( int column ) const
+{
+ if ( column == 0) {
+ static TQPixmap noPm = SmallIcon ("null");
+ static TQPixmap modPm = SmallIcon("modified");
+ static TQPixmap discPm = SmallIcon("modonhd");
+ static TQPixmap modmodPm = SmallIcon("modmod");
+
+ const KateDocumentInfo *info = KateDocManager::self()->documentInfo(doc);
+
+ if (info && info->modifiedOnDisc)
+ return doc->isModified() ? &modmodPm : &discPm;
+ else
+ return doc->isModified() ? &modPm : &noPm;
+ }
+
+ return 0;
+}
+
+void KateFileListItem::paintCell( TQPainter *painter, const TQColorGroup & cg, int column, int width, int align )
+{
+ KateFileList *fl = (KateFileList*)listView();
+ if ( ! fl ) return;
+
+ if ( column == 0 )
+ {
+ TQColorGroup cgNew = cg;
+
+ // replace the base color with a different shading if necessary...
+ if ( fl->shadingEnabled() && m_viewhistpos > 1 )
+ {
+ TQColor b( cg.base() );
+
+ TQColor shade = fl->viewShade();
+ TQColor eshade = fl->editShade();
+ int hc = fl->histCount();
+ // If this file is in the edit history, blend in the eshade
+ // color. The blend is weighted by the position in the editing history
+ if ( fl->shadingEnabled() && m_edithistpos > 0 )
+ {
+ int ec = fl->editHistCount();
+ int v = hc-m_viewhistpos;
+ int e = ec-m_edithistpos+1;
+ e = e*e;
+ int n = TQMAX(v + e, 1);
+ shade.setRgb(
+ ((shade.red()*v) + (eshade.red()*e))/n,
+ ((shade.green()*v) + (eshade.green()*e))/n,
+ ((shade.blue()*v) + (eshade.blue()*e))/n
+ );
+ }
+ // blend in the shade color.
+ // max transperancy < .5, latest is most colored.
+ float t = (0.5/hc)*(hc-m_viewhistpos+1);
+ b.setRgb(
+ (int)((b.red()*(1-t)) + (shade.red()*t)),
+ (int)((b.green()*(1-t)) + (shade.green()*t)),
+ (int)((b.blue()*(1-t)) + (shade.blue()*t))
+ );
+
+ cgNew.setColor(TQColorGroup::Base, b);
+ }
+
+ TQListViewItem::paintCell( painter, cgNew, column, width, align );
+ }
+ else
+ TQListViewItem::paintCell( painter, cg, column, width, align );
+}
+
+int KateFileListItem::compare ( TQListViewItem * i, int col, bool ascending ) const
+{
+ if ( i->rtti() == RTTI_KateFileListItem )
+ {
+ switch( ((KateFileList*)listView())->sortType() )
+ {
+ case KateFileList::sortByID:
+ {
+
+ int d = (int)doc->documentNumber() - ((KateFileListItem*)i)->documentNumber();
+ return ascending ? d : -d;
+ break;
+ }
+ case KateFileList::sortByURL:
+ return doc->url().prettyURL().compare( ((KateFileListItem*)i)->document()->url().prettyURL() );
+ break;
+ default:
+ return TQListViewItem::compare( i, col, ascending );
+ }
+ }
+ return 0;
+}
+//END KateFileListItem
+
+//BEGIN KFLConfigPage
+KFLConfigPage::KFLConfigPage( TQWidget* parent, const char *name, KateFileList *fl )
+ : Kate::ConfigPage( parent, name ),
+ m_filelist( fl ),
+ m_changed( false )
+{
+ TQVBoxLayout *lo1 = new TQVBoxLayout( this );
+ int spacing = KDialog::spacingHint();
+ lo1->setSpacing( spacing );
+
+ TQGroupBox *gb = new TQGroupBox( 1, Qt::Horizontal, i18n("Background Shading"), this );
+ lo1->addWidget( gb );
+
+ TQWidget *g = new TQWidget( gb );
+ TQGridLayout *lo = new TQGridLayout( g, 2, 2 );
+ lo->setSpacing( KDialog::spacingHint() );
+ cbEnableShading = new TQCheckBox( i18n("&Enable background shading"), g );
+ lo->addMultiCellWidget( cbEnableShading, 1, 1, 0, 1 );
+
+ kcbViewShade = new KColorButton( g );
+ lViewShade = new TQLabel( kcbViewShade, i18n("&Viewed documents' shade:"), g );
+ lo->addWidget( lViewShade, 2, 0 );
+ lo->addWidget( kcbViewShade, 2, 1 );
+
+ kcbEditShade = new KColorButton( g );
+ lEditShade = new TQLabel( kcbEditShade, i18n("&Modified documents' shade:"), g );
+ lo->addWidget( lEditShade, 3, 0 );
+ lo->addWidget( kcbEditShade, 3, 1 );
+
+ // sorting
+ TQHBox *hbSorting = new TQHBox( this );
+ lo1->addWidget( hbSorting );
+ lSort = new TQLabel( i18n("&Sort by:"), hbSorting );
+ cmbSort = new TQComboBox( hbSorting );
+ lSort->setBuddy( cmbSort );
+ TQStringList l;
+ l << i18n("Opening Order") << i18n("Document Name") << i18n("URL");
+ cmbSort->insertStringList( l );
+
+ lo1->insertStretch( -1, 10 );
+
+ TQWhatsThis::add( cbEnableShading, i18n(
+ "When background shading is enabled, documents that have been viewed "
+ "or edited within the current session will have a shaded background. "
+ "The most recent documents have the strongest shade.") );
+ TQWhatsThis::add( kcbViewShade, i18n(
+ "Set the color for shading viewed documents.") );
+ TQWhatsThis::add( kcbEditShade, i18n(
+ "Set the color for modified documents. This color is blended into "
+ "the color for viewed files. The most recently edited documents get "
+ "most of this color.") );
+
+ TQWhatsThis::add( cmbSort, i18n(
+ "Set the sorting method for the documents.") );
+
+ reload();
+
+ slotEnableChanged();
+ connect( cbEnableShading, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotMyChanged()) );
+ connect( cbEnableShading, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotEnableChanged()) );
+ connect( kcbViewShade, TQT_SIGNAL(changed(const TQColor&)), this, TQT_SLOT(slotMyChanged()) );
+ connect( kcbEditShade, TQT_SIGNAL(changed(const TQColor&)), this, TQT_SLOT(slotMyChanged()) );
+ connect( cmbSort, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotMyChanged()) );
+}
+
+void KFLConfigPage::apply()
+{
+ if ( ! m_changed )
+ return;
+ m_changed = false;
+
+ // Change settings in the filelist
+ m_filelist->m_viewShade = kcbViewShade->color();
+ m_filelist->m_editShade = kcbEditShade->color();
+ m_filelist->m_enableBgShading = cbEnableShading->isChecked();
+ m_filelist->setSortType( cmbSort->currentItem() );
+ // repaint the affected items
+ m_filelist->triggerUpdate();
+}
+
+void KFLConfigPage::reload()
+{
+ // read in from config file
+ TDEConfig *config = kapp->config();
+ config->setGroup( "Filelist" );
+ cbEnableShading->setChecked( config->readBoolEntry("Shading Enabled", &m_filelist->m_enableBgShading ) );
+ kcbViewShade->setColor( config->readColorEntry("View Shade", &m_filelist->m_viewShade ) );
+ kcbEditShade->setColor( config->readColorEntry("Edit Shade", &m_filelist->m_editShade ) );
+ cmbSort->setCurrentItem( m_filelist->sortType() );
+ m_changed = false;
+}
+
+void KFLConfigPage::slotEnableChanged()
+{
+ kcbViewShade->setEnabled( cbEnableShading->isChecked() );
+ kcbEditShade->setEnabled( cbEnableShading->isChecked() );
+ lViewShade->setEnabled( cbEnableShading->isChecked() );
+ lEditShade->setEnabled( cbEnableShading->isChecked() );
+}
+
+void KFLConfigPage::slotMyChanged()
+{
+ m_changed = true;
+ slotChanged();
+}
+
+//END KFLConfigPage
+
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/katefilelist.h b/kate/app/katefilelist.h
new file mode 100644
index 000000000..49987edd1
--- /dev/null
+++ b/kate/app/katefilelist.h
@@ -0,0 +1,199 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
+ Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __KATE_FILELIST_H__
+#define __KATE_FILELIST_H__
+
+#include "katemain.h"
+
+#include <kate/document.h>
+
+#include <tdelistview.h>
+
+#include <tqtooltip.h>
+#include <tqcolor.h>
+#include <tqptrlist.h>
+
+#define RTTI_KateFileListItem 1001
+
+class KateMainWindow;
+
+class TDEAction;
+class TDESelectAction;
+
+class KateFileListItem : public TQListViewItem
+{
+ public:
+ KateFileListItem( TQListView *lv,
+ Kate::Document *doc );
+ ~KateFileListItem();
+
+ inline uint documentNumber () { return m_docNumber; }
+ inline Kate::Document * document() { return doc; }
+
+ int rtti() const { return RTTI_KateFileListItem; }
+
+ /**
+ * Sets the view history position.
+ */
+ void setViewHistPos( int p ) { m_viewhistpos = p; }
+ /**
+ * Sets the edit history position.
+ */
+ void setEditHistPos( int p ) { m_edithistpos = p; }
+
+ protected:
+ virtual const TQPixmap *pixmap ( int column ) const;
+ void paintCell( TQPainter *painter, const TQColorGroup & cg, int column, int width, int align );
+ /**
+ * Reimplemented so we can sort by a number of different document properties.
+ */
+ int compare ( TQListViewItem * i, int col, bool ascending ) const;
+
+ private:
+ Kate::Document *doc;
+ int m_viewhistpos; ///< this gets set by the list as needed
+ int m_edithistpos; ///< this gets set by the list as needed
+ uint m_docNumber;
+};
+
+class KateFileList : public TDEListView
+{
+ Q_OBJECT
+
+ friend class KFLConfigPage;
+
+ public:
+ KateFileList (KateMainWindow *main, KateViewManager *_viewManager, TQWidget * parent = 0, const char * name = 0 );
+ ~KateFileList ();
+
+ int sortType () const { return m_sort; };
+ void updateSort ();
+
+ enum sorting {
+ sortByID = 0,
+ sortByName = 1,
+ sortByURL = 2,
+ sortManual = 3
+ };
+
+ TQString tooltip( TQListViewItem *item, int );
+
+ uint histCount() const { return m_viewHistory.count(); }
+ uint editHistCount() const { return m_editHistory.count(); }
+ TQColor editShade() const { return m_editShade; }
+ TQColor viewShade() const { return m_viewShade; }
+ bool shadingEnabled() { return m_enableBgShading; }
+
+ void readConfig( class TDEConfig *config, const TQString &group );
+ void writeConfig( class TDEConfig *config, const TQString &group );
+
+ /**
+ * reimplemented to remove the item from the history stacks
+ */
+ void takeItem( TQListViewItem * );
+
+ public slots:
+ void setSortType (int s);
+ void moveFileUp();
+ void moveFileDown();
+ void slotNextDocument();
+ void slotPrevDocument();
+
+ private slots:
+ void slotDocumentCreated (Kate::Document *doc);
+ void slotDocumentDeleted (uint documentNumber);
+ void slotActivateView( TQListViewItem *item );
+ void slotModChanged (Kate::Document *doc);
+ void slotModifiedOnDisc (Kate::Document *doc, bool b, unsigned char reason);
+ void slotNameChanged (Kate::Document *doc);
+ void slotViewChanged ();
+ void slotMenu ( TQListViewItem *item, const TQPoint &p, int col );
+ void updateFileListLocations();
+
+ protected:
+ virtual void keyPressEvent( TQKeyEvent *e );
+ /**
+ * Reimplemented to force Single mode for real:
+ * don't let a mouse click outside items deselect.
+ */
+ virtual void contentsMousePressEvent( TQMouseEvent *e );
+ /**
+ * Reimplemented to make sure the first (and only) column is at least
+ * the width of the viewport
+ */
+ virtual void resizeEvent( TQResizeEvent *e );
+
+ private:
+ void setupActions ();
+ void updateActions ();
+
+ private:
+ KateMainWindow *m_main;
+ KateViewManager *viewManager;
+
+ int m_sort;
+ bool notify;
+
+ TDEAction* windowNext;
+ TDEAction* windowPrev;
+ TDESelectAction* sortAction;
+ TDEAction* listMoveFileUp;
+ TDEAction* listMoveFileDown;
+
+ TQPtrList<KateFileListItem> m_viewHistory;
+ TQPtrList<KateFileListItem> m_editHistory;
+
+ TQColor m_viewShade, m_editShade;
+ bool m_enableBgShading;
+
+ TQListViewItem *m_clickedMenuItem;
+
+ class ToolTip *m_tooltip;
+};
+
+class KFLConfigPage : public Kate::ConfigPage {
+ Q_OBJECT
+ public:
+ KFLConfigPage( TQWidget* parent=0, const char *name=0, KateFileList *fl=0 );
+ virtual ~KFLConfigPage() {};
+
+ virtual void apply();
+ virtual void reload();
+
+ public slots:
+ void slotEnableChanged();
+
+ private slots:
+ void slotMyChanged();
+
+ private:
+ class TQCheckBox *cbEnableShading;
+ class KColorButton *kcbViewShade, *kcbEditShade;
+ class TQLabel *lEditShade, *lViewShade, *lSort;
+ class TQComboBox *cmbSort;
+ KateFileList *m_filelist;
+
+ bool m_changed;
+};
+
+
+#endif
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/katefileselector.cpp b/kate/app/katefileselector.cpp
new file mode 100644
index 000000000..c4b107912
--- /dev/null
+++ b/kate/app/katefileselector.cpp
@@ -0,0 +1,722 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
+ Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+//BEGIN Includes
+#include "katefileselector.h"
+#include "katefileselector.moc"
+
+#include "katemainwindow.h"
+#include "kateviewmanager.h"
+#include "kbookmarkhandler.h"
+
+#include "tdeactionselector.h"
+
+#include <tqlayout.h>
+#include <tqtoolbutton.h>
+#include <tqhbox.h>
+#include <tqvbox.h>
+#include <tqlabel.h>
+#include <tqstrlist.h>
+#include <tqtooltip.h>
+#include <tqwhatsthis.h>
+#include <tqapplication.h>
+#include <tqlistbox.h>
+#include <tqscrollbar.h>
+#include <tqspinbox.h>
+#include <tqgroupbox.h>
+#include <tqcheckbox.h>
+#include <tqregexp.h>
+#include <tqdockarea.h>
+#include <tqtimer.h>
+#include <tqdir.h>
+
+#include <tdeapplication.h>
+#include <kiconloader.h>
+#include <kurlcombobox.h>
+#include <kurlcompletion.h>
+#include <kprotocolinfo.h>
+#include <tdediroperator.h>
+#include <tdeconfig.h>
+#include <tdelocale.h>
+#include <kcombobox.h>
+#include <tdeaction.h>
+#include <tdemessagebox.h>
+#include <tdetoolbarbutton.h>
+#include <tqtoolbar.h>
+#include <tdepopupmenu.h>
+#include <kdialog.h>
+#include <kdebug.h>
+//END Includes
+
+//BEGIN Toolbar
+ // from tdefiledialog.cpp - avoid qt warning in STDERR (~/.xsessionerrors)
+static void silenceQToolBar(TQtMsgType, const char *){}
+
+// helper classes to be able to have a toolbar without move handle
+KateFileSelectorToolBar::KateFileSelectorToolBar(TQWidget *parent)
+ : TDEToolBar( parent, "Kate FileSelector Toolbar", true )
+{
+ setMinimumWidth(10);
+}
+
+KateFileSelectorToolBar::~KateFileSelectorToolBar(){}
+
+void KateFileSelectorToolBar::setMovingEnabled( bool)
+{
+ TDEToolBar::setMovingEnabled(false);
+}
+
+
+KateFileSelectorToolBarParent::KateFileSelectorToolBarParent(TQWidget *parent)
+ :TQFrame(parent),m_tb(0){}
+KateFileSelectorToolBarParent::~KateFileSelectorToolBarParent(){}
+void KateFileSelectorToolBarParent::setToolBar(KateFileSelectorToolBar *tb)
+{
+ m_tb=tb;
+}
+
+void KateFileSelectorToolBarParent::resizeEvent ( TQResizeEvent * )
+{
+ if (m_tb)
+ {
+ setMinimumHeight(m_tb->sizeHint().height());
+ m_tb->resize(width(),height());
+ }
+}
+//END
+
+//BEGIN Constructor/destructor
+
+KateFileSelector::KateFileSelector( KateMainWindow *mainWindow,
+ KateViewManager *viewManager,
+ TQWidget * parent, const char * name )
+ : TQVBox (parent, name),
+ mainwin(mainWindow),
+ viewmanager(viewManager)
+{
+ mActionCollection = new TDEActionCollection( this );
+
+ TQtMsgHandler oldHandler = tqInstallMsgHandler( silenceQToolBar );
+
+ KateFileSelectorToolBarParent *tbp=new KateFileSelectorToolBarParent(this);
+ toolbar = new KateFileSelectorToolBar(tbp);
+ tbp->setToolBar(toolbar);
+ toolbar->setMovingEnabled(false);
+ toolbar->setFlat(true);
+ tqInstallMsgHandler( oldHandler );
+
+ cmbPath = new KURLComboBox( KURLComboBox::Directories, true, this, "path combo" );
+ cmbPath->setSizePolicy( TQSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Fixed ));
+ KURLCompletion* cmpl = new KURLCompletion(KURLCompletion::DirCompletion);
+ cmbPath->setCompletionObject( cmpl );
+ cmbPath->setAutoDeleteCompletionObject( true );
+ cmbPath->listBox()->installEventFilter( this );
+
+ dir = new KDirOperator(KURL(), this, "operator");
+ dir->setView(KFile::/* Simple */Detail);
+ dir->view()->setSelectionMode(KFile::Extended);
+ connect ( dir, TQT_SIGNAL( viewChanged(KFileView *) ),
+ this, TQT_SLOT( selectorViewChanged(KFileView *) ) );
+ setStretchFactor(dir, 2);
+
+ TDEActionCollection *coll = dir->actionCollection();
+ // some shortcuts of diroperator that clashes with Kate
+ coll->action( "delete" )->setShortcut( TDEShortcut( ALT + Key_Delete ) );
+ coll->action( "reload" )->setShortcut( TDEShortcut( ALT + Key_F5 ) );
+ coll->action( "back" )->setShortcut( TDEShortcut( ALT + SHIFT + Key_Left ) );
+ coll->action( "forward" )->setShortcut( TDEShortcut( ALT + SHIFT + Key_Right ) );
+ // some consistency - reset up for dir too
+ coll->action( "up" )->setShortcut( TDEShortcut( ALT + SHIFT + Key_Up ) );
+ coll->action( "home" )->setShortcut( TDEShortcut( CTRL + ALT + Key_Home ) );
+
+ // bookmarks action!
+ TDEActionMenu *acmBookmarks = new TDEActionMenu( i18n("Bookmarks"), "bookmark",
+ mActionCollection, "bookmarks" );
+ acmBookmarks->setDelayed( false );
+ bookmarkHandler = new KBookmarkHandler( this, acmBookmarks->popupMenu() );
+ TQHBox* filterBox = new TQHBox(this);
+
+ btnFilter = new TQToolButton( filterBox );
+ btnFilter->setIconSet( SmallIconSet("filter" ) );
+ btnFilter->setToggleButton( true );
+ filter = new KHistoryCombo( true, filterBox, "filter");
+ filter->setSizePolicy( TQSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Fixed ));
+ filterBox->setStretchFactor(filter, 2);
+ connect( btnFilter, TQT_SIGNAL( clicked() ), this, TQT_SLOT( btnFilterClick() ) );
+
+ connect( filter, TQT_SIGNAL( activated(const TQString&) ),
+ TQT_SLOT( slotFilterChange(const TQString&) ) );
+ connect( filter, TQT_SIGNAL( returnPressed(const TQString&) ),
+ filter, TQT_SLOT( addToHistory(const TQString&) ) );
+
+ // tdeaction for the dir sync method
+ acSyncDir = new TDEAction( i18n("Current Document Folder"), "curfiledir", 0,
+ TQT_TQOBJECT(this), TQT_SLOT( setActiveDocumentDir() ), mActionCollection, "sync_dir" );
+ toolbar->setIconText( TDEToolBar::IconOnly );
+ toolbar->setIconSize( 16 );
+ toolbar->setEnableContextMenu( false );
+
+ connect( cmbPath, TQT_SIGNAL( urlActivated( const KURL& )),
+ this, TQT_SLOT( cmbPathActivated( const KURL& ) ));
+ connect( cmbPath, TQT_SIGNAL( returnPressed( const TQString& )),
+ this, TQT_SLOT( cmbPathReturnPressed( const TQString& ) ));
+ connect(dir, TQT_SIGNAL(urlEntered(const KURL&)),
+ this, TQT_SLOT(dirUrlEntered(const KURL&)) );
+
+ connect(dir, TQT_SIGNAL(finishedLoading()),
+ this, TQT_SLOT(dirFinishedLoading()) );
+
+ // enable dir sync button if current doc has a valid URL
+ connect ( viewmanager, TQT_SIGNAL( viewChanged() ),
+ this, TQT_SLOT( kateViewChanged() ) );
+
+ // Connect the bookmark handler
+ connect( bookmarkHandler, TQT_SIGNAL( openURL( const TQString& )),
+ this, TQT_SLOT( setDir( const TQString& ) ) );
+
+ waitingUrl = TQString::null;
+
+ // whatsthis help
+ TQWhatsThis::add( cmbPath,
+ i18n("<p>Here you can enter a path for a folder to display."
+ "<p>To go to a folder previously entered, press the arrow on "
+ "the right and choose one. <p>The entry has folder "
+ "completion. Right-click to choose how completion should behave.") );
+ TQWhatsThis::add( filter,
+ i18n("<p>Here you can enter a name filter to limit which files are displayed."
+ "<p>To clear the filter, toggle off the filter button to the left."
+ "<p>To reapply the last filter used, toggle on the filter button." ) );
+ TQWhatsThis::add( btnFilter,
+ i18n("<p>This button clears the name filter when toggled off, or "
+ "reapplies the last filter used when toggled on.") );
+
+}
+
+KateFileSelector::~KateFileSelector()
+{
+}
+//END Constroctor/Destrctor
+
+//BEGIN Public Methods
+
+void KateFileSelector::readConfig(TDEConfig *config, const TQString & name)
+{
+ dir->setViewConfig( config, name + ":view" );
+ dir->readConfig(config, name + ":dir");
+ dir->setView( KFile::Default );
+ dir->view()->setSelectionMode(KFile::Extended);
+ config->setGroup( name );
+
+ // set up the toolbar
+ setupToolbar( config );
+
+ cmbPath->setMaxItems( config->readNumEntry( "pathcombo history len", 9 ) );
+ cmbPath->setURLs( config->readPathListEntry( "dir history" ) );
+ // if we restore history
+ if ( config->readBoolEntry( "restore location", true ) || kapp->isRestored() ) {
+ TQString loc( config->readPathEntry( "location" ) );
+ if ( ! loc.isEmpty() ) {
+// waitingDir = loc;
+// TQTimer::singleShot(0, this, TQT_SLOT(initialDirChangeHack()));
+ setDir( loc );
+ }
+ }
+
+ // else is automatic, as cmpPath->setURL is called when a location is entered.
+
+ filter->setMaxCount( config->readNumEntry( "filter history len", 9 ) );
+ filter->setHistoryItems( config->readListEntry("filter history"), true );
+ lastFilter = config->readEntry( "last filter" );
+ TQString flt("");
+ if ( config->readBoolEntry( "restore last filter", true ) || kapp->isRestored() )
+ flt = config->readEntry("current filter");
+ filter->lineEdit()->setText( flt );
+ slotFilterChange( flt );
+
+ autoSyncEvents = config->readNumEntry( "AutoSyncEvents", 0 );
+}
+
+void KateFileSelector::initialDirChangeHack()
+{
+ setDir( waitingDir );
+}
+
+void KateFileSelector::setupToolbar( TDEConfig *config )
+{
+ toolbar->clear();
+ TQStringList tbactions = config->readListEntry( "toolbar actions", ',' );
+ if ( tbactions.isEmpty() ) {
+ // reasonable collection for default toolbar
+ tbactions << "up" << "back" << "forward" << "home" <<
+ "short view" << "detailed view" <<
+ "bookmarks" << "sync_dir";
+ }
+ TDEAction *ac;
+ for ( TQStringList::Iterator it=tbactions.begin(); it != tbactions.end(); ++it ) {
+ if ( *it == "bookmarks" || *it == "sync_dir" )
+ ac = mActionCollection->action( (*it).latin1() );
+ else
+ ac = dir->actionCollection()->action( (*it).latin1() );
+ if ( ac )
+ ac->plug( toolbar );
+ }
+}
+
+void KateFileSelector::writeConfig(TDEConfig *config, const TQString & name)
+{
+ dir->writeConfig(config,name + ":dir");
+
+ config->setGroup( name );
+ config->writeEntry( "pathcombo history len", cmbPath->maxItems() );
+ TQStringList l;
+ for (int i = 0; i < cmbPath->count(); i++) {
+ l.append( cmbPath->text( i ) );
+ }
+ config->writePathEntry( "dir history", l );
+ config->writePathEntry( "location", cmbPath->currentText() );
+
+ config->writeEntry( "filter history len", filter->maxCount() );
+ config->writeEntry( "filter history", filter->historyItems() );
+ config->writeEntry( "current filter", filter->currentText() );
+ config->writeEntry( "last filter", lastFilter );
+ config->writeEntry( "AutoSyncEvents", autoSyncEvents );
+}
+
+void KateFileSelector::setView(KFile::FileView view)
+{
+ dir->setView(view);
+ dir->view()->setSelectionMode(KFile::Extended);
+}
+
+//END Public Methods
+
+//BEGIN Public Slots
+
+void KateFileSelector::slotFilterChange( const TQString & nf )
+{
+ TQString f = nf.stripWhiteSpace();
+ bool empty = f.isEmpty() || f == "*";
+ TQToolTip::remove( btnFilter );
+ if ( empty ) {
+ dir->clearFilter();
+ filter->lineEdit()->setText( TQString::null );
+ TQToolTip::add( btnFilter,
+ TQString( i18n("Apply last filter (\"%1\")") ).arg( lastFilter ) );
+ }
+ else {
+ dir->setNameFilter( f );
+ lastFilter = f;
+ TQToolTip::add( btnFilter, i18n("Clear filter") );
+ }
+ btnFilter->setOn( !empty );
+ dir->updateDir();
+ // this will be never true after the filter has been used;)
+ btnFilter->setEnabled( !( empty && lastFilter.isEmpty() ) );
+
+}
+
+bool kateFileSelectorIsReadable ( const KURL& url )
+{
+ if ( !url.isLocalFile() )
+ return true; // what else can we say?
+
+ TQDir dir (url.path());
+ return dir.exists ();
+}
+
+void KateFileSelector::setDir( KURL u )
+{
+ KURL newurl;
+
+ if ( !u.isValid() )
+ newurl.setPath( TQDir::homeDirPath() );
+ else
+ newurl = u;
+
+ TQString pathstr = newurl.path(+1);
+ newurl.setPath(pathstr);
+
+ if ( !kateFileSelectorIsReadable ( newurl ) )
+ newurl.cd(TQString::fromLatin1(".."));
+
+ if ( !kateFileSelectorIsReadable (newurl) )
+ newurl.setPath( TQDir::homeDirPath() );
+
+ dir->setURL(newurl, true);
+}
+
+//END Public Slots
+
+//BEGIN Private Slots
+
+void KateFileSelector::cmbPathActivated( const KURL& u )
+{
+ cmbPathReturnPressed( u.url() );
+}
+
+void KateFileSelector::cmbPathReturnPressed( const TQString& u )
+{
+ KURL typedURL( u );
+ if ( typedURL.hasPass() )
+ typedURL.setPass( TQString::null );
+
+ TQStringList urls = cmbPath->urls();
+ urls.remove( typedURL.url() );
+ urls.prepend( typedURL.url() );
+ cmbPath->setURLs( urls, KURLComboBox::RemoveBottom );
+ dir->setFocus();
+ dir->setURL( KURL(u), true );
+}
+
+void KateFileSelector::dirUrlEntered( const KURL& u )
+{
+ cmbPath->setURL( u );
+}
+
+void KateFileSelector::dirFinishedLoading()
+{
+}
+
+
+/*
+ When the button in the filter box toggles:
+ If off:
+ If the name filer is anything but "" or "*", reset it.
+ If on:
+ Set last filter.
+*/
+void KateFileSelector::btnFilterClick()
+{
+ if ( !btnFilter->isOn() ) {
+ slotFilterChange( TQString::null );
+ }
+ else {
+ filter->lineEdit()->setText( lastFilter );
+ slotFilterChange( lastFilter );
+ }
+}
+
+//FIXME crash on shutdown
+void KateFileSelector::setActiveDocumentDir()
+{
+// kdDebug(13001)<<"KateFileSelector::setActiveDocumentDir()"<<endl;
+ KURL u = mainwin->activeDocumentUrl();
+// kdDebug(13001)<<"URL: "<<u.prettyURL()<<endl;
+ if (!u.isEmpty())
+ setDir( u.upURL() );
+// kdDebug(13001)<<"... setActiveDocumentDir() DONE!"<<endl;
+}
+
+void KateFileSelector::kateViewChanged()
+{
+ if ( autoSyncEvents & DocumentChanged )
+ {
+// kdDebug(13001)<<"KateFileSelector::do a sync ()"<<endl;
+ // if visible, sync
+ if ( isVisible() ) {
+ setActiveDocumentDir();
+ waitingUrl = TQString::null;
+ }
+ // else set waiting url
+ else {
+ KURL u = mainwin->activeDocumentUrl();
+ if (!u.isEmpty())
+ waitingUrl = u.directory();
+ }
+ }
+
+ // TODO: make sure the button is disabled if the directory is unreadable, eg
+ // the document URL has protocol http
+ acSyncDir->setEnabled( ! mainwin->activeDocumentUrl().directory().isEmpty() );
+}
+
+void KateFileSelector::selectorViewChanged( KFileView * newView )
+{
+ newView->setSelectionMode(KFile::Extended);
+}
+
+//END Private Slots
+
+//BEGIN Protected
+
+void KateFileSelector::focusInEvent( TQFocusEvent * )
+{
+ dir->setFocus();
+}
+
+void KateFileSelector::showEvent( TQShowEvent * )
+{
+ // sync if we should
+ if ( autoSyncEvents & GotVisible ) {
+// kdDebug(13001)<<"syncing fs on show"<<endl;
+ setActiveDocumentDir();
+ waitingUrl = TQString::null;
+ }
+ // else, if we have a waiting URL set it
+ else if ( ! waitingUrl.isEmpty() ) {
+ setDir( waitingUrl );
+ waitingUrl = TQString::null;
+ }
+}
+
+bool KateFileSelector::eventFilter( TQObject* o, TQEvent *e )
+{
+ /*
+ This is rather unfortunate, but:
+ TQComboBox does not support setting the size of the listbox to something
+ reasonable. Even using listbox->setVariableWidth() does not yield a
+ satisfying result, something is wrong with the handling of the sizehint.
+ And the popup is rather useless, if the paths are only partly visible.
+ */
+ TQListBox *lb = cmbPath->listBox();
+ if ( TQT_BASE_OBJECT(o) == TQT_BASE_OBJECT(lb) && e->type() == TQEvent::Show ) {
+ int add = lb->height() < lb->contentsHeight() ? lb->verticalScrollBar()->width() : 0;
+ int w = TQMIN( mainwin->width(), lb->contentsWidth() + add );
+ lb->resize( w, lb->height() );
+ // TODO - move the listbox to a suitable place if nessecary
+ // TODO - decide if it is worth caching the size while untill the contents
+ // are changed.
+ }
+ // TODO - same thing for the completion popup?
+ return TQWidget::eventFilter( o, e );
+}
+
+//END Protected
+
+//BEGIN ACtionLBItem
+/*
+ QListboxItem that can store and return a string,
+ used for the toolbar action selector.
+*/
+class ActionLBItem : public TQListBoxPixmap {
+ public:
+ ActionLBItem( TQListBox *lb=0,
+ const TQPixmap &pm = TQPixmap(),
+ const TQString &text=TQString::null,
+ const TQString &str=TQString::null ) :
+ TQListBoxPixmap( lb, pm, text ),
+ _str(str) {};
+ TQString idstring() { return _str; };
+ private:
+ TQString _str;
+};
+//END ActionLBItem
+
+//BEGIN KFSConfigPage
+////////////////////////////////////////////////////////////////////////////////
+// KFSConfigPage implementation
+////////////////////////////////////////////////////////////////////////////////
+KFSConfigPage::KFSConfigPage( TQWidget *parent, const char *name, KateFileSelector *kfs )
+ : Kate::ConfigPage( parent, name ),
+ fileSelector( kfs ),
+ m_changed( false )
+{
+ TQVBoxLayout *lo = new TQVBoxLayout( this );
+ int spacing = KDialog::spacingHint();
+ lo->setSpacing( spacing );
+
+ // Toolbar - a lot for a little...
+ TQGroupBox *gbToolbar = new TQGroupBox( 1, Qt::Vertical, i18n("Toolbar"), this );
+ acSel = new TDEActionSelector( gbToolbar );
+ acSel->setAvailableLabel( i18n("A&vailable actions:") );
+ acSel->setSelectedLabel( i18n("S&elected actions:") );
+ lo->addWidget( gbToolbar );
+ connect( acSel, TQT_SIGNAL( added( TQListBoxItem * ) ), this, TQT_SLOT( slotMyChanged() ) );
+ connect( acSel, TQT_SIGNAL( removed( TQListBoxItem * ) ), this, TQT_SLOT( slotMyChanged() ) );
+ connect( acSel, TQT_SIGNAL( movedUp( TQListBoxItem * ) ), this, TQT_SLOT( slotMyChanged() ) );
+ connect( acSel, TQT_SIGNAL( movedDown( TQListBoxItem * ) ), this, TQT_SLOT( slotMyChanged() ) );
+
+ // Sync
+ TQGroupBox *gbSync = new TQGroupBox( 1, Qt::Horizontal, i18n("Auto Synchronization"), this );
+ cbSyncActive = new TQCheckBox( i18n("When a docu&ment becomes active"), gbSync );
+ cbSyncShow = new TQCheckBox( i18n("When the file selector becomes visible"), gbSync );
+ lo->addWidget( gbSync );
+ connect( cbSyncActive, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotMyChanged() ) );
+ connect( cbSyncShow, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotMyChanged() ) );
+
+ // Histories
+ TQHBox *hbPathHist = new TQHBox ( this );
+ TQLabel *lbPathHist = new TQLabel( i18n("Remember &locations:"), hbPathHist );
+ sbPathHistLength = new TQSpinBox( hbPathHist );
+ lbPathHist->setBuddy( sbPathHistLength );
+ lo->addWidget( hbPathHist );
+ connect( sbPathHistLength, TQT_SIGNAL( valueChanged ( int ) ), this, TQT_SLOT( slotMyChanged() ) );
+
+ TQHBox *hbFilterHist = new TQHBox ( this );
+ TQLabel *lbFilterHist = new TQLabel( i18n("Remember &filters:"), hbFilterHist );
+ sbFilterHistLength = new TQSpinBox( hbFilterHist );
+ lbFilterHist->setBuddy( sbFilterHistLength );
+ lo->addWidget( hbFilterHist );
+ connect( sbFilterHistLength, TQT_SIGNAL( valueChanged ( int ) ), this, TQT_SLOT( slotMyChanged() ) );
+
+ // Session
+ TQGroupBox *gbSession = new TQGroupBox( 1, Qt::Horizontal, i18n("Session"), this );
+ cbSesLocation = new TQCheckBox( i18n("Restore loca&tion"), gbSession );
+ cbSesFilter = new TQCheckBox( i18n("Restore last f&ilter"), gbSession );
+ lo->addWidget( gbSession );
+ connect( cbSesLocation, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotMyChanged() ) );
+ connect( cbSesFilter, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotMyChanged() ) );
+
+ // make it look nice
+ lo->addStretch( 1 );
+
+ // be helpfull
+ /*
+ TQWhatsThis::add( lbAvailableActions, i18n(
+ "<p>Available actions for the toolbar. To add an action, select it here "
+ "and press the add (<strong>-&gt;</strong>) button" ) );
+ TQWhatsThis::add( lbUsedActions, i18n(
+ "<p>Actions used in the toolbar. To remove an action, select it and "
+ "press the remove (<strong>&lt;-</strong>) button."
+ "<p>To change the order of the actions, use the Up and Down buttons to "
+ "move the selected action.") );
+ */
+ TQString lhwt( i18n(
+ "<p>Decides how many locations to keep in the history of the location "
+ "combo box.") );
+ TQWhatsThis::add( lbPathHist, lhwt );
+ TQWhatsThis::add( sbPathHistLength, lhwt );
+ TQString fhwt( i18n(
+ "<p>Decides how many filters to keep in the history of the filter "
+ "combo box.") );
+ TQWhatsThis::add( lbFilterHist, fhwt );
+ TQWhatsThis::add( sbFilterHistLength, fhwt );
+ TQString synwt( i18n(
+ "<p>These options allow you to have the File Selector automatically "
+ "change location to the folder of the active document on certain "
+ "events."
+ "<p>Auto synchronization is <em>lazy</em>, meaning it will not take "
+ "effect until the file selector is visible."
+ "<p>None of these are enabled by default, but you can always sync the "
+ "location by pressing the sync button in the toolbar.") );
+ TQWhatsThis::add( gbSync, synwt );
+ TQWhatsThis::add( cbSesLocation, i18n(
+ "<p>If this option is enabled (default), the location will be restored "
+ "when you start Kate.<p><strong>Note</strong> that if the session is "
+ "handled by the TDE session manager, the location is always restored.") );
+ TQWhatsThis::add( cbSesFilter, i18n(
+ "<p>If this option is enabled (default), the current filter will be "
+ "restored when you start Kate.<p><strong>Note</strong> that if the "
+ "session is handled by the TDE session manager, the filter is always "
+ "restored."
+ "<p><strong>Note</strong> that some of the autosync settings may "
+ "override the restored location if on.") );
+
+ init();
+
+}
+
+void KFSConfigPage::apply()
+{
+ if ( ! m_changed )
+ return;
+
+ m_changed = false;
+
+ TDEConfig *config = kapp->config();
+ config->setGroup( "fileselector" );
+ // toolbar
+ TQStringList l;
+ TQListBoxItem *item = acSel->selectedListBox()->firstItem();
+ ActionLBItem *aItem;
+ while ( item )
+ {
+ aItem = (ActionLBItem*)item;
+ if ( aItem )
+ {
+ l << aItem->idstring();
+ }
+ item = item->next();
+ }
+ config->writeEntry( "toolbar actions", l );
+ fileSelector->setupToolbar( config );
+ // sync
+ int s = 0;
+ if ( cbSyncActive->isChecked() )
+ s |= KateFileSelector::DocumentChanged;
+ if ( cbSyncShow->isChecked() )
+ s |= KateFileSelector::GotVisible;
+ fileSelector->autoSyncEvents = s;
+
+ // histories
+ fileSelector->cmbPath->setMaxItems( sbPathHistLength->value() );
+ fileSelector->filter->setMaxCount( sbFilterHistLength->value() );
+ // session - theese are read/written directly to the app config,
+ // as they are not needed during operation.
+ config->writeEntry( "restore location", cbSesLocation->isChecked() );
+ config->writeEntry( "restore last filter", cbSesFilter->isChecked() );
+}
+
+void KFSConfigPage::reload()
+{
+ // hmm, what is this supposed to do, actually??
+ init();
+ m_changed = false;
+}
+void KFSConfigPage::init()
+{
+ TDEConfig *config = kapp->config();
+ config->setGroup( "fileselector" );
+ // toolbar
+ TQStringList l = config->readListEntry( "toolbar actions", ',' );
+ if ( l.isEmpty() ) // default toolbar
+ l << "up" << "back" << "forward" << "home" <<
+ "short view" << "detailed view" <<
+ "bookmarks" << "sync_dir";
+
+ // actions from diroperator + two of our own
+ TQStringList allActions;
+ allActions << "up" << "back" << "forward" << "home" <<
+ "reload" << "mkdir" << "delete" <<
+ "short view" << "detailed view" /*<< "view menu" <<
+ "show hidden" << "properties"*/ <<
+ "bookmarks" << "sync_dir";
+ TQRegExp re("&(?=[^&])");
+ TDEAction *ac;
+ TQListBox *lb;
+ for ( TQStringList::Iterator it=allActions.begin(); it != allActions.end(); ++it ) {
+ lb = l.contains( *it ) ? acSel->selectedListBox() : acSel->availableListBox();
+ if ( *it == "bookmarks" || *it == "sync_dir" )
+ ac = fileSelector->actionCollection()->action( (*it).latin1() );
+ else
+ ac = fileSelector->dirOperator()->actionCollection()->action( (*it).latin1() );
+ if ( ac )
+ new ActionLBItem( lb, SmallIcon( ac->icon() ), ac->text().replace( re, "" ), *it );
+ }
+
+ // sync
+ int s = fileSelector->autoSyncEvents;
+ cbSyncActive->setChecked( s & KateFileSelector::DocumentChanged );
+ cbSyncShow->setChecked( s & KateFileSelector::GotVisible );
+ // histories
+ sbPathHistLength->setValue( fileSelector->cmbPath->maxItems() );
+ sbFilterHistLength->setValue( fileSelector->filter->maxCount() );
+ // session
+ cbSesLocation->setChecked( config->readBoolEntry( "restore location", true ) );
+ cbSesFilter->setChecked( config->readBoolEntry( "restore last filter", true ) );
+}
+
+void KFSConfigPage::slotMyChanged()
+{
+ m_changed = true;
+ slotChanged();
+}
+//END KFSConfigPage
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/katefileselector.h b/kate/app/katefileselector.h
new file mode 100644
index 000000000..33482faba
--- /dev/null
+++ b/kate/app/katefileselector.h
@@ -0,0 +1,172 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
+ Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __KATE_FILESELECTOR_H__
+#define __KATE_FILESELECTOR_H__
+
+#include "katemain.h"
+#include "katedocmanager.h"
+#include <kate/document.h>
+
+#include <tqvbox.h>
+#include <tdefile.h>
+#include <kurl.h>
+#include <tdetoolbar.h>
+#include <tqframe.h>
+
+class KateMainWindow;
+class KateViewManager;
+class TDEActionCollection;
+class TDEActionSelector;
+class KFileView;
+
+/*
+ The kate file selector presents a directory view, in which the default action is
+ to open the activated file.
+ Additinally, a toolbar for managing the kdiroperator widget + sync that to
+ the directory of the current file is available, as well as a filter widget
+ allowing to filter the displayed files using a name filter.
+*/
+
+/* I think this fix for not moving toolbars is better */
+class KateFileSelectorToolBar: public TDEToolBar
+{
+ Q_OBJECT
+public:
+ KateFileSelectorToolBar(TQWidget *parent);
+ virtual ~KateFileSelectorToolBar();
+
+ virtual void setMovingEnabled( bool b );
+};
+
+class KateFileSelectorToolBarParent: public TQFrame
+{
+ Q_OBJECT
+public:
+ KateFileSelectorToolBarParent(TQWidget *parent);
+ ~KateFileSelectorToolBarParent();
+ void setToolBar(KateFileSelectorToolBar *tb);
+private:
+ KateFileSelectorToolBar *m_tb;
+protected:
+ virtual void resizeEvent ( TQResizeEvent * );
+};
+
+class KateFileSelector : public TQVBox
+{
+ Q_OBJECT
+
+ friend class KFSConfigPage;
+
+ public:
+ /* When to sync to current document directory */
+ enum AutoSyncEvent { DocumentChanged=1, GotVisible=2 };
+
+ KateFileSelector( KateMainWindow *mainWindow=0, KateViewManager *viewManager=0,
+ TQWidget * parent = 0, const char * name = 0 );
+ ~KateFileSelector();
+
+ void readConfig( TDEConfig *, const TQString & );
+ void writeConfig( TDEConfig *, const TQString & );
+ void setupToolbar( TDEConfig * );
+ void setView( KFile::FileView );
+ KDirOperator *dirOperator(){ return dir; }
+ TDEActionCollection *actionCollection() { return mActionCollection; };
+
+ public slots:
+ void slotFilterChange(const TQString&);
+ void setDir(KURL);
+ void setDir( const TQString& url ) { setDir( KURL( url ) ); };
+ void kateViewChanged();
+ void selectorViewChanged( KFileView * );
+
+ private slots:
+ void cmbPathActivated( const KURL& u );
+ void cmbPathReturnPressed( const TQString& u );
+ void dirUrlEntered( const KURL& u );
+ void dirFinishedLoading();
+ void setActiveDocumentDir();
+ void btnFilterClick();
+
+ protected:
+ void focusInEvent( TQFocusEvent * );
+ void showEvent( TQShowEvent * );
+ bool eventFilter( TQObject *, TQEvent * );
+ void initialDirChangeHack();
+
+ private:
+ class KateFileSelectorToolBar *toolbar;
+ TDEActionCollection *mActionCollection;
+ class KBookmarkHandler *bookmarkHandler;
+ KURLComboBox *cmbPath;
+ KDirOperator * dir;
+ class TDEAction *acSyncDir;
+ KHistoryCombo * filter;
+ class TQToolButton *btnFilter;
+
+ KateMainWindow *mainwin;
+ KateViewManager *viewmanager;
+
+ TQString lastFilter;
+ int autoSyncEvents; // enabled autosync events
+ TQString waitingUrl; // maybe display when we gets visible
+ TQString waitingDir;
+};
+
+/* TODO anders
+ KFSFilterHelper
+ A popup widget presenting a listbox with checkable items
+ representing the mime types available in the current directory, and
+ providing a name filter based on those.
+*/
+
+/*
+ Config page for file selector.
+ Allows for configuring the toolbar, the history length
+ of the path and file filter combos, and how to handle
+ user closed session.
+*/
+class KFSConfigPage : public Kate::ConfigPage {
+ Q_OBJECT
+ public:
+ KFSConfigPage( TQWidget* parent=0, const char *name=0, KateFileSelector *kfs=0);
+ virtual ~KFSConfigPage() {};
+
+ virtual void apply();
+ virtual void reload();
+
+ private slots:
+ void slotMyChanged();
+
+ private:
+ void init();
+
+ KateFileSelector *fileSelector;
+ TDEActionSelector *acSel;
+ class TQSpinBox *sbPathHistLength, *sbFilterHistLength;
+ class TQCheckBox *cbSyncActive, *cbSyncShow;
+ class TQCheckBox *cbSesLocation, *cbSesFilter;
+
+ bool m_changed;
+};
+
+
+#endif //__KATE_FILESELECTOR_H__
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/kategrepdialog.cpp b/kate/app/kategrepdialog.cpp
new file mode 100644
index 000000000..b180fd516
--- /dev/null
+++ b/kate/app/kategrepdialog.cpp
@@ -0,0 +1,544 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
+ Copyright (C) 2001, 2004 Anders Lund <anders.lund@lund.tdcadsl.dk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "kategrepdialog.h"
+#include "katemainwindow.h"
+
+#include <tqobject.h>
+#include <tqlayout.h>
+#include <tqlabel.h>
+#include <tqcheckbox.h>
+#include <tqevent.h>
+#include <tqlistbox.h>
+#include <tqregexp.h>
+#include <tqwhatsthis.h>
+#include <tqcursor.h>
+
+#include <tdeapplication.h>
+#include <tdeaccelmanager.h>
+#include <kbuttonbox.h>
+#include <tdefiledialog.h>
+#include <kprocess.h>
+#include <tdeapplication.h>
+#include <tdelocale.h>
+#include <kiconloader.h>
+#include <tdemessagebox.h>
+#include <kpushbutton.h>
+#include <kurlrequester.h>
+#include <kurlcompletion.h>
+#include <kcombobox.h>
+#include <klineedit.h>
+
+const char *template_desc[] = {
+ "normal",
+ "assignment",
+ "->MEMBER(",
+ "class::MEMBER(",
+ "OBJECT->member(",
+ 0
+};
+
+const char *strTemplate[] = {
+ "%s",
+ "\\<%s\\>[\t ]*=[^=]",
+ "\\->[\\t ]*\\<%s\\>[\\t ]*(",
+ "[a-z0-9_$]\\+[\\t ]*::[\\t ]*\\<%s\\>[\\t ]*(",
+ "\\<%s\\>[\\t ]*\\->[\\t ]*[a-z0-9_$]\\+[\\t ]*(",
+ 0
+};
+
+
+GrepTool::GrepTool(TQWidget *parent, const char *name)
+ : TQWidget(parent, name/*, false*/), m_fixFocus(true), childproc(0)
+{
+ setCaption(i18n("Find in Files"));
+ config = TDEGlobal::config();
+ config->setGroup("GrepTool");
+ lastSearchItems = config->readListEntry("LastSearchItems");
+ lastSearchPaths = config->readListEntry("LastSearchPaths");
+ lastSearchFiles = config->readListEntry("LastSearchFiles");
+
+ if( lastSearchFiles.isEmpty() )
+ {
+ // if there are no entries, most probably the first Kate start.
+ // Initialize with default values.
+ lastSearchFiles << "*.h,*.hxx,*.cpp,*.cc,*.C,*.cxx,*.idl,*.c"
+ << "*.cpp,*.cc,*.C,*.cxx,*.c"
+ << "*.h,*.hxx,*.idl"
+ << "*";
+ }
+
+ TQGridLayout *layout = new TQGridLayout(this, 6, 3, 4, 4);
+ layout->setColStretch(0, 10);
+ layout->addColSpacing(1, 10);
+ layout->setColStretch(1, 0);
+ layout->setColStretch(2, 1);
+ layout->setRowStretch(1, 0);
+ layout->setRowStretch(2, 10);
+ layout->setRowStretch(4, 0);
+
+ TQGridLayout *loInput = new TQGridLayout(4, 2, 4);
+ layout->addLayout(loInput, 0, 0);
+ loInput->setColStretch(0, 0);
+ loInput->setColStretch(1, 20);
+
+ TQLabel *lPattern = new TQLabel(i18n("Pattern:"), this);
+ lPattern->setFixedSize(lPattern->sizeHint());
+ loInput->addWidget(lPattern, 0, 0, Qt::AlignRight | Qt::AlignVCenter);
+
+ TQBoxLayout *loPattern = new TQHBoxLayout( 4 );
+ loInput->addLayout( loPattern, 0, 1 );
+ cmbPattern = new KComboBox(true, this);
+ cmbPattern->setDuplicatesEnabled(false);
+ cmbPattern->insertStringList(lastSearchItems);
+ cmbPattern->setEditText(TQString::null);
+ cmbPattern->setInsertionPolicy(TQComboBox::NoInsertion);
+ lPattern->setBuddy(cmbPattern);
+ cmbPattern->setFocus();
+ cmbPattern->setMinimumSize(cmbPattern->sizeHint());
+ loPattern->addWidget( cmbPattern );
+
+ cbCasesensitive = new TQCheckBox(i18n("Case sensitive"), this);
+ cbCasesensitive->setMinimumWidth(cbCasesensitive->sizeHint().width());
+ cbCasesensitive->setChecked(config->readBoolEntry("CaseSensitive", true));
+ loPattern->addWidget(cbCasesensitive);
+
+ cbRegex = new TQCheckBox( i18n("Regular expression"), this );
+ cbRegex->setMinimumWidth( cbRegex->sizeHint().width() );
+ cbRegex->setChecked( config->readBoolEntry( "Regex", true ) );
+ loPattern->addWidget( cbRegex );
+ loPattern->setStretchFactor( cmbPattern, 100 );
+
+ TQLabel *lTemplate = new TQLabel(i18n("Template:"), this);
+ lTemplate->setFixedSize(lTemplate->sizeHint());
+ loInput->addWidget(lTemplate, 1, 0, Qt::AlignRight | Qt::AlignVCenter);
+
+ TQBoxLayout *loTemplate = new TQHBoxLayout(4);
+ loInput->addLayout(loTemplate, 1, 1);
+
+ leTemplate = new KLineEdit(this);
+ lTemplate->setBuddy(leTemplate);
+ leTemplate->setText(strTemplate[0]);
+ leTemplate->setMinimumSize(leTemplate->sizeHint());
+ loTemplate->addWidget(leTemplate);
+
+ KComboBox *cmbTemplate = new KComboBox(false, this);
+ cmbTemplate->insertStrList(template_desc);
+ cmbTemplate->adjustSize();
+ cmbTemplate->setFixedSize(cmbTemplate->size());
+ loTemplate->addWidget(cmbTemplate);
+
+ TQLabel *lFiles = new TQLabel(i18n("Files:"), this);
+ lFiles->setFixedSize(lFiles->sizeHint());
+ loInput->addWidget(lFiles, 2, 0, Qt::AlignRight | Qt::AlignVCenter);
+
+ cmbFiles = new KComboBox(true, this);
+ lFiles->setBuddy(TQT_TQWIDGET(cmbFiles->focusProxy()));
+ cmbFiles->setMinimumSize(cmbFiles->sizeHint());
+ cmbFiles->setInsertionPolicy(TQComboBox::NoInsertion);
+ cmbFiles->setDuplicatesEnabled(false);
+ cmbFiles->insertStringList(lastSearchFiles);
+ loInput->addWidget(cmbFiles, 2, 1);
+
+ TQLabel *lDir = new TQLabel(i18n("Folder:"), this);
+ lDir->setFixedSize(lDir->sizeHint());
+ loInput->addWidget(lDir, 3, 0, Qt::AlignRight | Qt::AlignVCenter);
+
+ TQBoxLayout *loDir = new TQHBoxLayout(3);
+ loInput->addLayout(loDir, 3, 1);
+
+ KComboBox* cmbUrl = new KComboBox(true, this);
+ cmbUrl->setMinimumWidth(80); // make sure that 800x600 res works
+ cmbUrl->setDuplicatesEnabled(false);
+ cmbUrl->setInsertionPolicy(TQComboBox::NoInsertion);
+ cmbDir = new KURLRequester( cmbUrl, this, "dir combo" );
+ cmbDir->completionObject()->setMode(KURLCompletion::DirCompletion);
+ cmbDir->comboBox()->insertStringList(lastSearchPaths);
+ cmbDir->setMode( KFile::Directory|KFile::LocalOnly );
+ loDir->addWidget(cmbDir, 1);
+ lDir->setBuddy(cmbDir);
+
+ cbRecursive = new TQCheckBox(i18n("Recursive"), this);
+ cbRecursive->setMinimumWidth(cbRecursive->sizeHint().width());
+ cbRecursive->setChecked(config->readBoolEntry("Recursive", true));
+ loDir->addWidget(cbRecursive);
+
+ KButtonBox *actionbox = new KButtonBox(this, Qt::Vertical);
+ layout->addWidget(actionbox, 0, 2);
+ actionbox->addStretch();
+ btnSearch = static_cast<KPushButton*>(actionbox->addButton(KGuiItem(i18n("Find"),"find")));
+ btnSearch->setDefault(true);
+ btnClear = static_cast<KPushButton*>(actionbox->addButton( KStdGuiItem::clear() ));
+ actionbox->addStretch();
+ actionbox->layout();
+
+ lbResult = new TQListBox(this);
+ TQFontMetrics rb_fm(lbResult->fontMetrics());
+ layout->addMultiCellWidget(lbResult, 2, 2, 0, 2);
+
+ layout->activate();
+
+ TDEAcceleratorManager::manage( this );
+
+ TQWhatsThis::add(lPattern,
+ i18n("<p>Enter the expression you want to search for here."
+ "<p>If 'regular expression' is unchecked, any non-space letters in your "
+ "expression will be escaped with a backslash character."
+ "<p>Possible meta characters are:<br>"
+ "<b>.</b> - Matches any character<br>"
+ "<b>^</b> - Matches the beginning of a line<br>"
+ "<b>$</b> - Matches the end of a line<br>"
+ "<b>\\&lt;</b> - Matches the beginning of a word<br>"
+ "<b>\\&gt;</b> - Matches the end of a word"
+ "<p>The following repetition operators exist:<br>"
+ "<b>?</b> - The preceding item is matched at most once<br>"
+ "<b>*</b> - The preceding item is matched zero or more times<br>"
+ "<b>+</b> - The preceding item is matched one or more times<br>"
+ "<b>{<i>n</i>}</b> - The preceding item is matched exactly <i>n</i> times<br>"
+ "<b>{<i>n</i>,}</b> - The preceding item is matched <i>n</i> or more times<br>"
+ "<b>{,<i>n</i>}</b> - The preceding item is matched at most <i>n</i> times<br>"
+ "<b>{<i>n</i>,<i>m</i>}</b> - The preceding item is matched at least <i>n</i>, "
+ "but at most <i>m</i> times."
+ "<p>Furthermore, backreferences to bracketed subexpressions are available "
+ "via the notation <code>\\#</code>."
+ "<p>See the grep(1) documentation for the full documentation."
+ ));
+ TQWhatsThis::add(lFiles,
+ i18n("Enter the file name pattern of the files to search here.\n"
+ "You may give several patterns separated by commas."));
+ TQWhatsThis::add(lTemplate,
+ i18n("You can choose a template for the pattern from the combo box\n"
+ "and edit it here. The string %s in the template is replaced\n"
+ "by the pattern input field, resulting in the regular expression\n"
+ "to search for."));
+ TQWhatsThis::add(lDir,
+ i18n("Enter the folder which contains the files in which you want to search."));
+ TQWhatsThis::add(cbRecursive,
+ i18n("Check this box to search in all subfolders."));
+ TQWhatsThis::add(cbCasesensitive,
+ i18n("If this option is enabled (the default), the search will be case sensitive."));
+ TQWhatsThis::add( cbRegex, i18n(
+ "<p>If this is enabled, your pattern will be passed unmodified to "
+ "<em>grep(1)</em>. Otherwise, all characters that are not letters will be "
+ "escaped using a backslash character to prevent grep from interpreting "
+ "them as part of the expression.") );
+ TQWhatsThis::add(lbResult,
+ i18n("The results of the grep run are listed here. Select a\n"
+ "filename/line number combination and press Enter or doubleclick\n"
+ "on the item to show the respective line in the editor."));
+
+ // event filter, do something relevant for RETURN
+ cmbPattern->installEventFilter( this );
+ leTemplate->installEventFilter( this );
+ cmbFiles->installEventFilter( this );
+ cmbDir->comboBox()->installEventFilter( this );
+
+ connect( cmbTemplate, TQT_SIGNAL(activated(int)),
+ TQT_SLOT(templateActivated(int)) );
+ connect( lbResult, TQT_SIGNAL(selected(const TQString&)),
+ TQT_SLOT(itemSelected(const TQString&)) );
+ connect( btnSearch, TQT_SIGNAL(clicked()),
+ TQT_SLOT(slotSearch()) );
+ connect( btnClear, TQT_SIGNAL(clicked()),
+ TQT_SLOT(slotClear()) );
+ connect( cmbPattern->lineEdit(), TQT_SIGNAL(textChanged ( const TQString & )),
+ TQT_SLOT( patternTextChanged( const TQString & )));
+
+ patternTextChanged( cmbPattern->lineEdit()->text());
+}
+
+
+GrepTool::~GrepTool()
+{
+ delete childproc;
+}
+
+void GrepTool::patternTextChanged( const TQString & _text)
+{
+ btnSearch->setEnabled( !_text.isEmpty() );
+}
+
+void GrepTool::templateActivated(int index)
+{
+ leTemplate->setText(strTemplate[index]);
+}
+
+void GrepTool::itemSelected(const TQString& item)
+{
+ int pos;
+ TQString filename, linenumber;
+
+ TQString str = item;
+ if ( (pos = str.find(':')) != -1)
+ {
+ filename = str.left(pos);
+ str = str.mid(pos+1);
+ if ( (pos = str.find(':')) != -1)
+ {
+ filename = m_workingDir + TQDir::separator() + filename;
+ linenumber = str.left(pos);
+ emit itemSelected(filename,linenumber.toInt()-1);
+ }
+ }
+}
+
+void GrepTool::processOutput()
+{
+ int pos;
+ while ( (pos = buf.find('\n')) != -1)
+ {
+ TQString item = buf.mid(2,pos-2);
+ if (!item.isEmpty())
+ lbResult->insertItem(item);
+ buf = buf.mid(pos+1);
+ }
+ kapp->processEvents();
+}
+
+void GrepTool::slotSearch()
+{
+ if ( cmbPattern->currentText().isEmpty() )
+ {
+ cmbPattern->setFocus();
+ return;
+ }
+
+ if ( cmbDir->url().isEmpty() || ! TQDir(cmbDir->url()).exists() )
+ {
+ cmbDir->setFocus();
+ KMessageBox::information( this, i18n(
+ "You must enter an existing local folder in the 'Folder' entry."),
+ i18n("Invalid Folder"), "Kate grep tool: invalid folder" );
+ return;
+ }
+
+ if ( ! leTemplate->text().contains("%s") )
+ {
+ leTemplate->setFocus();
+ return;
+ }
+
+ if ( childproc && childproc->isRunning() )
+ {
+ childproc->kill();
+ return;
+ }
+
+ slotClear ();
+
+ m_workingDir = cmbDir->url();
+
+ TQString s = cmbPattern->currentText();
+ if ( ! cbRegex->isChecked() )
+ s.replace( TQRegExp( "([^\\w'()<>])" ), "\\\\1" );
+ TQString pattern = leTemplate->text();
+ pattern.replace( "%s", s );
+
+ childproc = new TDEProcess();
+ childproc->setWorkingDirectory( m_workingDir );
+ *childproc << "find" << ".";
+ if (!cbRecursive->isChecked())
+ *childproc << "-maxdepth" << "1";
+ if (!cmbFiles->currentText().isEmpty() )
+ {
+ TQStringList files = TQStringList::split ( ",", cmbFiles->currentText(), FALSE );
+ *childproc << "(";
+ bool first = true;
+ for ( TQStringList::Iterator it = files.begin(); it != files.end(); ++it )
+ {
+ if (!first)
+ *childproc << "-o";
+ *childproc << "-name" << (*it);
+ first = false;
+ }
+ *childproc << ")";
+ }
+ *childproc << "-exec" << "grep";
+ if (!cbCasesensitive->isChecked())
+ *childproc << "-i";
+ *childproc << "-n" << "-e" << pattern << "{}";
+ *childproc << "/dev/null"; //trick to have grep always display the filename
+ *childproc << ";";
+
+ connect( childproc, TQT_SIGNAL(processExited(TDEProcess *)),
+ TQT_SLOT(childExited()) );
+ connect( childproc, TQT_SIGNAL(receivedStdout(TDEProcess *, char *, int)),
+ TQT_SLOT(receivedOutput(TDEProcess *, char *, int)) );
+ connect( childproc, TQT_SIGNAL(receivedStderr(TDEProcess *, char *, int)),
+ TQT_SLOT(receivedErrOutput(TDEProcess *, char *, int)) );
+
+ // actually it should be checked whether the process was started successfully
+ lbResult->setCursor( TQCursor(Qt::WaitCursor) );
+ btnClear->setEnabled( false );
+ btnSearch->setGuiItem( KGuiItem(i18n("Cancel"), "button_cancel"));
+ childproc->start(TDEProcess::NotifyOnExit, TDEProcess::AllOutput);
+}
+
+void GrepTool::slotSearchFor(const TQString &pattern)
+{
+ slotClear();
+ cmbPattern->setEditText(pattern);
+ slotSearch();
+}
+
+void GrepTool::finish()
+{
+ btnSearch->setEnabled( !cmbPattern->lineEdit()->text().isEmpty() );
+
+ buf += '\n';
+ processOutput();
+ delete childproc;
+ childproc = 0;
+
+ config->setGroup("GrepTool");
+
+ TQString cmbText = cmbPattern->currentText();
+ bool itemsRemoved = lastSearchItems.remove(cmbText) > 0;
+ lastSearchItems.prepend(cmbText);
+ if (itemsRemoved)
+ {
+ cmbPattern->removeItem(cmbPattern->currentItem());
+ }
+ cmbPattern->insertItem(cmbText, 0);
+ cmbPattern->setCurrentItem(0);
+ if (lastSearchItems.count() > 10) {
+ lastSearchItems.pop_back();
+ cmbPattern->removeItem(cmbPattern->count() - 1);
+ }
+ config->writeEntry("LastSearchItems", lastSearchItems);
+
+
+ cmbText = cmbDir->url();
+ itemsRemoved = lastSearchPaths.remove(cmbText) > 0;
+ lastSearchPaths.prepend(cmbText);
+ if (itemsRemoved)
+ {
+ cmbDir->comboBox()->removeItem(cmbDir->comboBox()->currentItem());
+ }
+ cmbDir->comboBox()->insertItem(cmbText, 0);
+ cmbDir->comboBox()->setCurrentItem(0);
+ if (lastSearchPaths.count() > 10)
+ {
+ lastSearchPaths.pop_back();
+ cmbDir->comboBox()->removeItem(cmbDir->comboBox()->count() - 1);
+ }
+ config->writeEntry("LastSearchPaths", lastSearchPaths);
+
+
+ cmbText = cmbFiles->currentText();
+ itemsRemoved = lastSearchFiles.remove(cmbText) > 0;
+ lastSearchFiles.prepend(cmbText);
+ if (itemsRemoved)
+ {
+ cmbFiles->removeItem(cmbFiles->currentItem());
+ }
+ cmbFiles->insertItem(cmbText, 0);
+ cmbFiles->setCurrentItem(0);
+ if (lastSearchFiles.count() > 10) {
+ lastSearchFiles.pop_back();
+ cmbFiles->removeItem(cmbFiles->count() - 1);
+ }
+ config->writeEntry("LastSearchFiles", lastSearchFiles);
+
+ config->writeEntry("Recursive", cbRecursive->isChecked());
+ config->writeEntry("CaseSensitive", cbCasesensitive->isChecked());
+ config->writeEntry("Regex", cbRegex->isChecked());
+}
+
+void GrepTool::slotCancel()
+{
+ finish();
+}
+
+void GrepTool::childExited()
+{
+// int status = childproc->exitStatus();
+ lbResult->unsetCursor();
+ btnClear->setEnabled( true );
+ btnSearch->setGuiItem( KGuiItem(i18n("Find"), "find") );
+
+ if ( ! errbuf.isEmpty() )
+ {
+ KMessageBox::information( parentWidget(), i18n("<strong>Error:</strong><p>") + errbuf, i18n("Grep Tool Error") );
+ errbuf.truncate(0);
+ }
+ else
+ finish();
+}
+
+void GrepTool::receivedOutput(TDEProcess */*proc*/, char *buffer, int buflen)
+{
+ buf += TQCString(buffer, buflen+1);
+ processOutput();
+}
+
+void GrepTool::receivedErrOutput(TDEProcess */*proc*/, char *buffer, int buflen)
+{
+ errbuf += TQCString( buffer, buflen + 1 );
+}
+
+void GrepTool::slotClear()
+{
+ finish();
+ lbResult->clear();
+}
+
+void GrepTool::updateDirName(const TQString &dir)
+{
+ if (m_lastUpdatedDir != dir)
+ {
+ setDirName (dir);
+ m_lastUpdatedDir = dir;
+ }
+}
+
+void GrepTool::setDirName(const TQString &dir){
+ cmbDir->setURL(dir);
+}
+
+bool GrepTool::eventFilter( TQObject *o, TQEvent *e )
+{
+ if ( e->type() == TQEvent::KeyPress && (
+ ((TQKeyEvent*)e)->key() == Qt::Key_Return ||
+ ((TQKeyEvent*)e)->key() == Qt::Key_Enter ) )
+ {
+ slotSearch();
+ return true;
+ }
+
+ return TQWidget::eventFilter( o, e );
+}
+
+void GrepTool::focusInEvent ( TQFocusEvent * ev )
+{
+ TQWidget::focusInEvent(ev);
+ if (m_fixFocus) {
+ m_fixFocus = false;
+ cmbPattern->setFocus();
+ }
+}
+
+void GrepTool::showEvent( TQShowEvent * ev )
+{
+ TQWidget::showEvent(ev);
+ m_fixFocus = true;
+}
+
+#include "kategrepdialog.moc"
diff --git a/kate/app/kategrepdialog.h b/kate/app/kategrepdialog.h
new file mode 100644
index 000000000..a3cbbc871
--- /dev/null
+++ b/kate/app/kategrepdialog.h
@@ -0,0 +1,97 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
+ Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _GREPDIALOG_H_
+#define _GREPDIALOG_H_
+
+#include <kdialog.h>
+#include <tqstringlist.h>
+
+class TQLineEdit;
+class KComboBox;
+class TQCheckBox;
+class TQListBox;
+class KPushButton;
+class TQLabel;
+class TDEProcess;
+class TDEConfig;
+class KURLRequester;
+class TQEvent;
+
+class GrepTool : public TQWidget
+{
+ Q_OBJECT
+
+public:
+ GrepTool(TQWidget *parent, const char *name=0);
+ ~GrepTool();
+
+ // only updates if the dir you give to it differs from the last one given to it !
+ void updateDirName(const TQString &);
+
+ void setDirName(const TQString &);
+
+
+signals:
+ void itemSelected(const TQString &abs_filename, int line);
+
+public slots:
+ void slotSearchFor(const TQString &pattern);
+
+protected:
+ bool eventFilter( TQObject *, TQEvent * );
+ void focusInEvent ( TQFocusEvent * );
+ void showEvent( TQShowEvent * );
+ bool m_fixFocus;
+
+private slots:
+ void templateActivated(int index);
+ void childExited();
+ void receivedOutput(TDEProcess *proc, char *buffer, int buflen);
+ void receivedErrOutput(TDEProcess *proc, char *buffer, int buflen);
+ void itemSelected(const TQString&);
+ void slotSearch();
+ void slotCancel();
+ void slotClear();
+ void patternTextChanged( const TQString &);
+private:
+ void processOutput();
+ void finish();
+
+ TQLineEdit *leTemplate;
+ KComboBox *cmbFiles, *cmbPattern;
+ KURLRequester *cmbDir;
+ TQCheckBox *cbRecursive;
+ TQCheckBox *cbCasesensitive, *cbRegex;
+ TQListBox *lbResult;
+ KPushButton *btnSearch, *btnClear;
+ TDEProcess *childproc;
+ TQString buf;
+ TQString errbuf;
+ TDEConfig* config;
+ TQStringList lastSearchItems;
+ TQStringList lastSearchPaths;
+ TQStringList lastSearchFiles;
+ TQString m_lastUpdatedDir;
+ TQString m_workingDir;
+};
+
+
+#endif
diff --git a/kate/app/katemailfilesdialog.cpp b/kate/app/katemailfilesdialog.cpp
new file mode 100644
index 000000000..858caa5f1
--- /dev/null
+++ b/kate/app/katemailfilesdialog.cpp
@@ -0,0 +1,112 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "katemailfilesdialog.h"
+#include "katemainwindow.h"
+#include "kateviewmanager.h"
+#include "katedocmanager.h"
+
+#include <tdelistview.h>
+#include <tdelocale.h>
+#include <kurl.h>
+
+#include <tqevent.h>
+#include <tqlabel.h>
+#include <tqstringlist.h>
+#include <tqvbox.h>
+
+/* a private check list item, that can store a Kate::Document*. */
+class KateDocCheckItem : public TQCheckListItem {
+ public:
+ KateDocCheckItem( TQListView *parent, const TQString& text, Kate::Document *d )
+ : TQCheckListItem( parent, text, TQCheckListItem::CheckBox ), mdoc(d) {};
+ Kate::Document *doc() { return mdoc; };
+ private:
+ Kate::Document *mdoc;
+};
+
+///////////////////////////////////////////////////////////////////////////
+// KateMailDialog implementation
+///////////////////////////////////////////////////////////////////////////
+KateMailDialog::KateMailDialog( TQWidget *parent, KateMainWindow *mainwin )
+ : KDialogBase( parent, "kate mail dialog", true, i18n("Email Files"),
+ Ok|Cancel|User1, Ok, false,
+ KGuiItem( i18n("&Show All Documents >>") ) ),
+ mainWindow( mainwin )
+{
+ setButtonGuiItem( KDialogBase::Ok, KGuiItem( i18n("&Mail..."), "mail_send") );
+ mw = makeVBoxMainWidget();
+ mw->installEventFilter( this );
+
+ lInfo = new TQLabel( i18n(
+ "<p>Press <strong>Mail...</strong> to email the current document."
+ "<p>To select more documents to send, press <strong>Show All Documents&nbsp;&gt;&gt;</strong>."), mw );
+ // TODO avoid untill needed - later
+ list = new TDEListView( mw );
+ list->addColumn( i18n("Name") );
+ list->addColumn( i18n("URL") );
+ Kate::Document *currentDoc = mainWindow->viewManager()->activeView()->getDoc();
+ uint n = KateDocManager::self()->documents();
+ uint i = 0;
+ TQCheckListItem *item;
+ while ( i < n ) {
+ Kate::Document *doc = KateDocManager::self()->document( i );
+ if ( doc ) {
+ item = new KateDocCheckItem( list, doc->docName(), doc );
+ item->setText( 1, doc->url().prettyURL() );
+ if ( doc == currentDoc ) {
+ item->setOn( true );
+ item->setSelected( true );
+ }
+ }
+ i++;
+ }
+ list->hide();
+ connect( this, TQT_SIGNAL(user1Clicked()), this, TQT_SLOT(slotShowButton()) );
+ mw->setMinimumSize( lInfo->sizeHint() );
+}
+
+TQPtrList<Kate::Document> KateMailDialog::selectedDocs()
+{
+ TQPtrList<Kate::Document> l;
+ TQListViewItem *item = list->firstChild();
+ while ( item ) {
+ if ( ((KateDocCheckItem*)item)->isOn() )
+ l.append( ((KateDocCheckItem*)item)->doc() );
+ item = item->nextSibling();
+ }
+ return l;
+}
+
+void KateMailDialog::slotShowButton()
+{
+ if ( list->isVisible() ) {
+ setButtonText( User1, i18n("&Show All Documents >>") );
+ list->hide();
+ }
+ else {
+ list->show();
+ setButtonText( User1, i18n("&Hide Document List <<") );
+ lInfo->setText( i18n("Press <strong>Mail...</strong> to send selected documents") );
+
+ }
+ mw->setMinimumSize( TQSize( lInfo->sizeHint().width(), mw->sizeHint().height()) );
+ setMinimumSize( calculateSize( mw->minimumSize().width(), mw->sizeHint().height() ) );
+ resize( width(), minimumHeight() );
+}
+#include "katemailfilesdialog.moc"
diff --git a/kate/app/katemailfilesdialog.h b/kate/app/katemailfilesdialog.h
new file mode 100644
index 000000000..a2de4e504
--- /dev/null
+++ b/kate/app/katemailfilesdialog.h
@@ -0,0 +1,59 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _KATE_MAILFILES_DIALOG_H_
+#define _KATE_MAILFILES_DIALOG_H_
+
+#include <kate/document.h>
+
+#include <kdialogbase.h>
+#include <kurl.h>
+#include <tqptrlist.h>
+
+class TQString;
+class TQStringList;
+class KateMainWindow;
+
+/**
+ This is a dialog for choosing which of the open files to mail.
+ The current file is selected by default, the dialog can be expanded
+ to display all the files if required.
+
+*/
+class KateMailDialog : public KDialogBase {
+ Q_OBJECT
+ public:
+ KateMailDialog( TQWidget *parent=0,
+ KateMainWindow *mainwin=0 );
+ ~KateMailDialog() {};
+
+ /**
+ @return a list of the selected docs.
+ */
+ TQPtrList<Kate::Document> selectedDocs();
+ private slots:
+ void slotShowButton();
+ private:
+ class TDEListView *list;
+ class TQLabel *lInfo;
+ KateMainWindow *mainWindow;
+ class TQVBox *mw;
+
+};
+
+#endif // _KATE_MAILFILES_DIALOG_H_
diff --git a/kate/app/katemain.cpp b/kate/app/katemain.cpp
new file mode 100644
index 000000000..7b9903d5e
--- /dev/null
+++ b/kate/app/katemain.cpp
@@ -0,0 +1,267 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "kateapp.h"
+
+#include <kstandarddirs.h>
+#include <tdelocale.h>
+#include <tdecmdlineargs.h>
+#include <tdeaboutdata.h>
+#include <tdeglobal.h>
+#include <tdeconfig.h>
+#include <kinstance.h>
+#include <tdestartupinfo.h>
+#include <dcopclient.h>
+#include <dcopref.h>
+#include <kdebug.h>
+
+#include <tqtextcodec.h>
+
+#include <stdlib.h>
+
+static TDECmdLineOptions options[] =
+{
+ { "s", 0 , 0 },
+ { "start <name>", I18N_NOOP("Start Kate with a given session"), 0 },
+ { "u", 0, 0 },
+ { "use", I18N_NOOP("Use a already running kate instance (if possible)"), 0 },
+ { "f", 0, 0 },
+ { "force-sdi", I18N_NOOP("Force single document mode if the MDI setting is enabled."), 0 },
+ { "p", 0, 0 },
+ { "pid <pid>", I18N_NOOP("Only try to reuse kate instance with this pid"), 0 },
+ { "e", 0, 0 },
+ { "encoding <name>", I18N_NOOP("Set encoding for the file to open"), 0 },
+ { "l", 0, 0 },
+ { "line <line>", I18N_NOOP("Navigate to this line"), 0 },
+ { "c", 0, 0 },
+ { "column <column>", I18N_NOOP("Navigate to this column"), 0 },
+ { "i", 0, 0 },
+ { "stdin", I18N_NOOP("Read the contents of stdin"), 0 },
+ { "+[URL]", I18N_NOOP("Document to open"), 0 },
+ TDECmdLineLastOption
+};
+
+extern "C" KDE_EXPORT int kdemain( int argc, char **argv )
+{
+ TDEConfig * config = NULL;
+ bool alwaysUseInstance;
+ // here we go, construct the Kate version
+ TQString kateVersion = KateApp::kateVersion();
+
+ TDEAboutData aboutData ("kate", I18N_NOOP("Kate"), kateVersion.latin1(),
+ I18N_NOOP( "Kate - Advanced Text Editor" ), TDEAboutData::License_LGPL_V2,
+ I18N_NOOP( "(c) 2000-2005 The Kate Authors" ), 0, "http://kate.kde.org");
+
+ aboutData.addAuthor ("Christoph Cullmann", I18N_NOOP("Maintainer"), "cullmann@kde.org", "http://www.babylon2k.de");
+ aboutData.addAuthor ("Anders Lund", I18N_NOOP("Core Developer"), "anders@alweb.dk", "http://www.alweb.dk");
+ aboutData.addAuthor ("Joseph Wenninger", I18N_NOOP("Core Developer"), "jowenn@kde.org","http://stud3.tuwien.ac.at/~e9925371");
+ aboutData.addAuthor ("Hamish Rodda",I18N_NOOP("Core Developer"), "rodda@kde.org");
+ aboutData.addAuthor ("Waldo Bastian", I18N_NOOP( "The cool buffersystem" ), "bastian@kde.org" );
+ aboutData.addAuthor ("Charles Samuels", I18N_NOOP("The Editing Commands"), "charles@kde.org");
+ aboutData.addAuthor ("Matt Newell", I18N_NOOP("Testing, ..."), "newellm@proaxis.com");
+ aboutData.addAuthor ("Michael Bartl", I18N_NOOP("Former Core Developer"), "michael.bartl1@chello.at");
+ aboutData.addAuthor ("Michael McCallum", I18N_NOOP("Core Developer"), "gholam@xtra.co.nz");
+ aboutData.addAuthor ("Jochen Wilhemly", I18N_NOOP( "KWrite Author" ), "digisnap@cs.tu-berlin.de" );
+ aboutData.addAuthor ("Michael Koch",I18N_NOOP("KWrite port to KParts"), "koch@kde.org");
+ aboutData.addAuthor ("Christian Gebauer", 0, "gebauer@kde.org" );
+ aboutData.addAuthor ("Simon Hausmann", 0, "hausmann@kde.org" );
+ aboutData.addAuthor ("Glen Parker",I18N_NOOP("KWrite Undo History, Kspell integration"), "glenebob@nwlink.com");
+ aboutData.addAuthor ("Scott Manson",I18N_NOOP("KWrite XML Syntax highlighting support"), "sdmanson@alltel.net");
+ aboutData.addAuthor ("John Firebaugh",I18N_NOOP("Patches and more"), "jfirebaugh@kde.org");
+ aboutData.addAuthor ("Dominik Haumann", I18N_NOOP("Developer & Highlight wizard"), "dhdev@gmx.de");
+
+ aboutData.addCredit ("Matteo Merli",I18N_NOOP("Highlighting for RPM Spec-Files, Perl, Diff and more"), "merlim@libero.it");
+ aboutData.addCredit ("Rocky Scaletta",I18N_NOOP("Highlighting for VHDL"), "rocky@purdue.edu");
+ aboutData.addCredit ("Yury Lebedev",I18N_NOOP("Highlighting for SQL"),"");
+ aboutData.addCredit ("Chris Ross",I18N_NOOP("Highlighting for Ferite"),"");
+ aboutData.addCredit ("Nick Roux",I18N_NOOP("Highlighting for ILERPG"),"");
+ aboutData.addCredit ("Carsten Niehaus", I18N_NOOP("Highlighting for LaTeX"),"");
+ aboutData.addCredit ("Per Wigren", I18N_NOOP("Highlighting for Makefiles, Python"),"");
+ aboutData.addCredit ("Jan Fritz", I18N_NOOP("Highlighting for Python"),"");
+ aboutData.addCredit ("Daniel Naber","","");
+ aboutData.addCredit ("Roland Pabel",I18N_NOOP("Highlighting for Scheme"),"");
+ aboutData.addCredit ("Cristi Dumitrescu",I18N_NOOP("PHP Keyword/Datatype list"),"");
+ aboutData.addCredit ("Carsten Pfeiffer", I18N_NOOP("Very nice help"), "");
+ aboutData.addCredit (I18N_NOOP("All people who have contributed and I have forgotten to mention"),"","");
+
+ aboutData.setTranslator(I18N_NOOP2("NAME OF TRANSLATORS","Your names"), I18N_NOOP2("EMAIL OF TRANSLATORS","Your emails"));
+
+ TDEInstance instance( &aboutData );
+
+ // command line args init and co
+ TDECmdLineArgs::init (argc, argv, &aboutData);
+ TDECmdLineArgs::addCmdLineOptions (options);
+ TDECmdLineArgs::addTempFileOption();
+ KateApp::addCmdLineOptions ();
+
+ // get our command line args ;)
+ TDECmdLineArgs* args = TDECmdLineArgs::parsedArgs();
+
+ config = TDEGlobal::config();
+ config->setGroup("General");
+ alwaysUseInstance = config->readBoolEntry("UseInstance");
+
+// now, first try to contact running kate instance if needed
+ if ( ((args->isSet("use") || alwaysUseInstance) &&
+ !(args->isSet("force-sdi"))) || (::getenv("KATE_PID")!=0) )
+ {
+ DCOPClient client;
+ client.attach ();
+
+ // get all attached clients ;)
+ QCStringList allClients = client.registeredApplications();
+
+ // search for a kate app client, use the first found
+ TQCString kateApp;
+
+ if ( args->isSet("start") )
+ {
+ for (unsigned int i=0; i < allClients.count(); i++)
+ {
+ if (allClients[i] == "kate" || allClients[i].left(5) == "kate-")
+ {
+ DCOPRef ref( allClients[i], "KateApplication" );
+ TQString s = ref.call( "session" );
+ if ( TQString(args->getOption("start")) == s )
+ {
+ kateApp = allClients[i];
+ break;
+ }
+ }
+ }
+ }
+ else if ( (args->isSet("pid")) || (::getenv("KATE_PID") !=0 ) )
+ {
+ TQCString tryApp;
+ if ( args->isSet("pid") )
+ tryApp = args->getOption("pid");
+ else
+ tryApp = ::getenv("KATE_PID");
+
+ if ( client.isApplicationRegistered( tryApp.prepend("kate-") ) )
+ kateApp = tryApp;
+ }
+ else
+ {
+ for (unsigned int i=0; i < allClients.count(); ++i)
+ {
+ if (allClients[i] == "kate" || allClients[i].left(5) == "kate-")
+ {
+ kateApp = allClients[i];
+ break;
+ }
+ }
+ }
+
+ // found a matching kate client ;)
+ if (!kateApp.isEmpty())
+ {
+ kdDebug () << "kate app: " << kateApp << endl;
+ // make tdeinit happy
+ client.registerAs( "kate" );
+
+ DCOPRef kRef (kateApp, "KateApplication");
+
+ if (args->isSet ("start"))
+ kRef.call( "activateSession", TQString (args->getOption("start")) );
+
+ TQString enc = args->isSet("encoding") ? args->getOption("encoding") : TQCString("");
+
+ bool tempfileSet = TDECmdLineArgs::isTempFileSet();
+
+ for (int z=0; z<args->count(); z++)
+ kRef.call( "openURL", args->url(z), enc, tempfileSet );
+
+ if( args->isSet( "stdin" ) )
+ {
+ TQTextIStream input(stdin);
+
+ // set chosen codec
+ TQTextCodec *codec = args->isSet("encoding") ? TQTextCodec::codecForName(args->getOption("encoding")) : 0;
+
+ if (codec)
+ input.setCodec (codec);
+
+ TQString line;
+ TQString text;
+
+ do
+ {
+ line = input.readLine();
+ text.append( line + "\n" );
+ } while( !line.isNull() );
+
+ kRef.call( "openInput", text );
+ }
+
+ int line = 0;
+ int column = 0;
+ bool nav = false;
+
+ if (args->isSet ("line"))
+ {
+ line = args->getOption ("line").toInt();
+ nav = true;
+ }
+
+ if (args->isSet ("column"))
+ {
+ column = args->getOption ("column").toInt();
+ nav = true;
+ }
+
+ if (nav)
+ kRef.call( "setCursor", line, column );
+
+ // since the user tried to open a document, let us assume [s]he
+ // wants to see that document.
+ // ### what to do about the infamous focus stealing prevention?
+ uint mwn = kRef.call("activeMainWindowNumber");
+ TQCString smwn;
+ DCOPRef wRef( kateApp, TQCString( "__KateMainWindow#") + smwn.setNum(mwn) );
+ if ( wRef.call("minimized") )
+ {
+ if ( wRef.call( "maximized" ) )
+ wRef.call( "maximize" );
+ else
+ wRef.call("restore");
+ }
+ wRef.call( "setActiveWindowFocused" );
+
+ // stop startup notification
+ TDEStartupInfo::appStarted( );
+
+ return 0;
+ }
+ }
+
+ // construct the real kate app object ;)
+ KateApp app (args);
+
+ // app execution should already end :)
+ if (app.shouldExit())
+ {
+ return 0;
+ }
+
+ // execute ourself ;)
+ return app.exec();
+}
+
+// kate: space-indent on; indent-width 2; replace-tabs on; mixed-indent off;
diff --git a/kate/app/katemain.h b/kate/app/katemain.h
new file mode 100644
index 000000000..374b834cc
--- /dev/null
+++ b/kate/app/katemain.h
@@ -0,0 +1,70 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
+ Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __KATE_MAIN_H__
+#define __KATE_MAIN_H__
+
+#include <config.h>
+
+class TQComboBox;
+class TQDateTime;
+class TQEvent;
+class TQFileInfo;
+class TQGridLayout;
+class TQLabel;
+class TQListBox;
+class TQObject;
+class TQPixmap;
+class TQVBoxLayout;
+class TQString;
+class TQWidgetStack;
+
+class TDEAction;
+class TDEActionMenu;
+class TDEConfig;
+class KDirOperator;
+class KEditToolbar;
+class KFileViewItem;
+class KHistoryCombo;
+class KLineEdit;
+class TDEListBox;
+class TDEProcess;
+class KPushButton;
+class TDERecentFilesAction;
+class TDESelectAction;
+class KStatusBar;
+class TDEToggleAction;
+class KURL;
+class KURLComboBox;
+
+class KateApp;
+class KateConfigDlg;
+class KateConsole;
+class KateDocManager;
+class KateFileList;
+class KateFileSelector;
+class KateMainWindow;
+class KatePluginIface;
+class KatePluginManager;
+class KateSidebar;
+class KateViewManager;
+class KateViewSpace;
+
+#endif
diff --git a/kate/app/katemainwindow.cpp b/kate/app/katemainwindow.cpp
new file mode 100644
index 000000000..4cd3c358e
--- /dev/null
+++ b/kate/app/katemainwindow.cpp
@@ -0,0 +1,860 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
+ Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+//BEGIN Includes
+#include "katemainwindow.h"
+#include "katemainwindow.moc"
+
+#include "kateconfigdialog.h"
+#include "kateconsole.h"
+#include "katedocmanager.h"
+#include "katepluginmanager.h"
+#include "kateconfigplugindialogpage.h"
+#include "kateviewmanager.h"
+#include "kateapp.h"
+#include "katefileselector.h"
+#include "katefilelist.h"
+#include "kategrepdialog.h"
+#include "katemailfilesdialog.h"
+#include "katemainwindowiface.h"
+#include "kateexternaltools.h"
+#include "katesavemodifieddialog.h"
+#include "katemwmodonhddialog.h"
+#include "katesession.h"
+#include "katetabwidget.h"
+
+#include "../interfaces/mainwindow.h"
+#include "../interfaces/toolviewmanager.h"
+
+#include <dcopclient.h>
+#include <kinstance.h>
+#include <tdeaboutdata.h>
+#include <tdeaction.h>
+#include <tdecmdlineargs.h>
+#include <kdebug.h>
+#include <kdialogbase.h>
+#include <tdediroperator.h>
+#include <kdockwidget.h>
+#include <kedittoolbar.h>
+#include <tdefiledialog.h>
+#include <kglobalaccel.h>
+#include <tdeglobal.h>
+#include <tdeglobalsettings.h>
+#include <kiconloader.h>
+#include <kkeydialog.h>
+#include <tdelocale.h>
+#include <tdemessagebox.h>
+#include <kmimetype.h>
+#include <kopenwith.h>
+#include <tdepopupmenu.h>
+#include <ksimpleconfig.h>
+#include <kstatusbar.h>
+#include <kstdaction.h>
+#include <kstandarddirs.h>
+#include <ktrader.h>
+#include <kuniqueapplication.h>
+#include <kurldrag.h>
+#include <kdesktopfile.h>
+#include <khelpmenu.h>
+#include <tdemultitabbar.h>
+#include <ktip.h>
+#include <tdemenubar.h>
+#include <kstringhandler.h>
+#include <tqlayout.h>
+#include <tqptrvector.h>
+
+#include <assert.h>
+#include <unistd.h>
+//END
+
+uint KateMainWindow::uniqueID = 1;
+
+KateMainWindow::KateMainWindow (TDEConfig *sconfig, const TQString &sgroup)
+ : KateMDI::MainWindow (0,(TQString(TQString("__KateMainWindow#%1").arg(uniqueID))).latin1())
+{
+ // first the very important id
+ myID = uniqueID;
+ uniqueID++;
+
+ m_modignore = false;
+
+ console = 0;
+ greptool = 0;
+
+ // here we go, set some usable default sizes
+ if (!initialGeometrySet())
+ {
+ int scnum = TQApplication::desktop()->screenNumber(parentWidget());
+ TQRect desk = TQApplication::desktop()->screenGeometry(scnum);
+
+ TQSize size;
+
+ // try to load size
+ if (sconfig)
+ {
+ sconfig->setGroup (sgroup);
+ size.setWidth (sconfig->readNumEntry( TQString::fromLatin1("Width %1").arg(desk.width()), 0 ));
+ size.setHeight (sconfig->readNumEntry( TQString::fromLatin1("Height %1").arg(desk.height()), 0 ));
+ }
+
+ // if thats fails, try to reuse size
+ if (size.isEmpty())
+ {
+ // first try to reuse size known from current or last created main window ;=)
+ if (KateApp::self()->mainWindows () > 0)
+ {
+ KateMainWindow *win = KateApp::self()->activeMainWindow ();
+
+ if (!win)
+ win = KateApp::self()->mainWindow (KateApp::self()->mainWindows ()-1);
+
+ size = win->size();
+ }
+ else // now fallback to hard defaults ;)
+ {
+ // first try global app config
+ KateApp::self()->config()->setGroup ("MainWindow");
+ size.setWidth (KateApp::self()->config()->readNumEntry( TQString::fromLatin1("Width %1").arg(desk.width()), 0 ));
+ size.setHeight (KateApp::self()->config()->readNumEntry( TQString::fromLatin1("Height %1").arg(desk.height()), 0 ));
+
+ if (size.isEmpty())
+ size = TQSize (kMin (700, desk.width()), kMin(480, desk.height()));
+ }
+
+ resize (size);
+ }
+ }
+
+ // start session restore if needed
+ startRestore (sconfig, sgroup);
+
+ m_mainWindow = new Kate::MainWindow (this);
+ m_toolViewManager = new Kate::ToolViewManager (this);
+
+ m_dcop = new KateMainWindowDCOPIface (this);
+
+ // setup the most important widgets
+ setupMainWindow();
+
+ // setup the actions
+ setupActions();
+
+ setStandardToolBarMenuEnabled( true );
+ setXMLFile( "kateui.rc" );
+ createShellGUI ( true );
+
+ KatePluginManager::self()->enableAllPluginsGUI (this);
+
+ if ( KateApp::self()->authorize("shell_access") )
+ Kate::Document::registerCommand(KateExternalToolsCommand::self());
+
+ // connect documents menu aboutToshow
+ documentMenu = (TQPopupMenu*)factory()->container("documents", this);
+ connect(documentMenu, TQT_SIGNAL(aboutToShow()), this, TQT_SLOT(documentMenuAboutToShow()));
+
+ // caption update
+ for (uint i = 0; i < KateDocManager::self()->documents(); i++)
+ slotDocumentCreated (KateDocManager::self()->document(i));
+
+ connect(KateDocManager::self(),TQT_SIGNAL(documentCreated(Kate::Document *)),this,TQT_SLOT(slotDocumentCreated(Kate::Document *)));
+
+ readOptions();
+
+ if (sconfig)
+ m_viewManager->restoreViewConfiguration (sconfig, sgroup);
+
+ finishRestore ();
+
+ setAcceptDrops(true);
+}
+
+KateMainWindow::~KateMainWindow()
+{
+ // first, save our fallback window size ;)
+ KateApp::self()->config()->setGroup ("MainWindow");
+ saveWindowSize (KateApp::self()->config());
+
+ // save other options ;=)
+ saveOptions();
+
+ KateApp::self()->removeMainWindow (this);
+
+ KatePluginManager::self()->disableAllPluginsGUI (this);
+
+ delete m_dcop;
+}
+
+void KateMainWindow::setupMainWindow ()
+{
+ setToolViewStyle( KMultiTabBar::KDEV3ICON );
+
+ m_tabWidget = new KateTabWidget (centralWidget());
+
+ m_viewManager = new KateViewManager (this);
+
+ KateMDI::ToolView *ft = createToolView("kate_filelist", KMultiTabBar::Left, SmallIcon("tdemultiple"), i18n("Documents"));
+ filelist = new KateFileList (this, m_viewManager, ft, "filelist");
+ filelist->readConfig(KateApp::self()->config(), "Filelist");
+
+ KateMDI::ToolView *t = createToolView("kate_fileselector", KMultiTabBar::Left, SmallIcon("fileopen"), i18n("Filesystem Browser"));
+ fileselector = new KateFileSelector( this, m_viewManager, t, "operator");
+ connect(fileselector->dirOperator(),TQT_SIGNAL(fileSelected(const KFileItem*)),this,TQT_SLOT(fileSelected(const KFileItem*)));
+
+ // ONLY ALLOW SHELL ACCESS IF ALLOWED ;)
+ if (KateApp::self()->authorize("shell_access"))
+ {
+ t = createToolView("kate_greptool", KMultiTabBar::Bottom, SmallIcon("filefind"), i18n("Find in Files") );
+ greptool = new GrepTool( t, "greptool" );
+ connect(greptool, TQT_SIGNAL(itemSelected(const TQString &,int)), this, TQT_SLOT(slotGrepToolItemSelected(const TQString &,int)));
+ connect(t,TQT_SIGNAL(visibleChanged(bool)),this, TQT_SLOT(updateGrepDir (bool)));
+ // WARNING HACK - anders: showing the greptool seems to make the menu accels work
+ greptool->show();
+
+ t = createToolView("kate_console", KMultiTabBar::Bottom, SmallIcon("konsole"), i18n("Terminal"));
+ console = new KateConsole (this, t);
+ }
+
+ // make per default the filelist visible, if we are in session restore, katemdi will skip this ;)
+ showToolView (ft);
+}
+
+void KateMainWindow::setupActions()
+{
+ TDEAction *a;
+
+ KStdAction::openNew( TQT_TQOBJECT(m_viewManager), TQT_SLOT( slotDocumentNew() ), actionCollection(), "file_new" )->setWhatsThis(i18n("Create a new document"));
+ KStdAction::open( TQT_TQOBJECT(m_viewManager), TQT_SLOT( slotDocumentOpen() ), actionCollection(), "file_open" )->setWhatsThis(i18n("Open an existing document for editing"));
+
+ fileOpenRecent = KStdAction::openRecent (TQT_TQOBJECT(m_viewManager), TQT_SLOT(openURL (const KURL&)), actionCollection());
+ fileOpenRecent->setWhatsThis(i18n("This lists files which you have opened recently, and allows you to easily open them again."));
+
+ a=new TDEAction( i18n("Save A&ll"),"save_all", CTRL+Key_L, KateDocManager::self(), TQT_SLOT( saveAll() ), actionCollection(), "file_save_all" );
+ a->setWhatsThis(i18n("Save all open, modified documents to disk."));
+
+ KStdAction::close( TQT_TQOBJECT(m_viewManager), TQT_SLOT( slotDocumentClose() ), actionCollection(), "file_close" )->setWhatsThis(i18n("Close the current document."));
+
+ a=new TDEAction( i18n( "Clos&e All" ), 0, TQT_TQOBJECT(this), TQT_SLOT( slotDocumentCloseAll() ), actionCollection(), "file_close_all" );
+ a->setWhatsThis(i18n("Close all open documents."));
+
+ KStdAction::mail( TQT_TQOBJECT(this), TQT_SLOT(slotMail()), actionCollection() )->setWhatsThis(i18n("Send one or more of the open documents as email attachments."));
+
+ KStdAction::quit( TQT_TQOBJECT(this), TQT_SLOT( slotFileQuit() ), actionCollection(), "file_quit" )->setWhatsThis(i18n("Close this window"));
+
+ a=new TDEAction(i18n("&New Window"), "window_new", 0, TQT_TQOBJECT(this), TQT_SLOT(newWindow()), actionCollection(), "view_new_view");
+ a->setWhatsThis(i18n("Create a new Kate view (a new window with the same document list)."));
+
+ if ( KateApp::self()->authorize("shell_access") )
+ {
+ externalTools = new KateExternalToolsMenuAction( i18n("External Tools"), actionCollection(), "tools_external", this );
+ externalTools->setWhatsThis( i18n("Launch external helper applications") );
+ }
+
+ TDEToggleAction* showFullScreenAction = KStdAction::fullScreen( 0, 0, actionCollection(),this);
+ connect( showFullScreenAction,TQT_SIGNAL(toggled(bool)), this,TQT_SLOT(slotFullScreen(bool)));
+
+ documentOpenWith = new TDEActionMenu(i18n("Open W&ith"), actionCollection(), "file_open_with");
+ documentOpenWith->setWhatsThis(i18n("Open the current document using another application registered for its file type, or an application of your choice."));
+ connect(documentOpenWith->popupMenu(), TQT_SIGNAL(aboutToShow()), this, TQT_SLOT(mSlotFixOpenWithMenu()));
+ connect(documentOpenWith->popupMenu(), TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotOpenWithMenuAction(int)));
+
+ a=KStdAction::keyBindings(TQT_TQOBJECT(this), TQT_SLOT(editKeys()), actionCollection());
+ a->setWhatsThis(i18n("Configure the application's keyboard shortcut assignments."));
+
+ a=KStdAction::configureToolbars(TQT_TQOBJECT(this), TQT_SLOT(slotEditToolbars()), actionCollection());
+ a->setWhatsThis(i18n("Configure which items should appear in the toolbar(s)."));
+
+ TDEAction* settingsConfigure = KStdAction::preferences(TQT_TQOBJECT(this), TQT_SLOT(slotConfigure()), actionCollection(), "settings_configure");
+ settingsConfigure->setWhatsThis(i18n("Configure various aspects of this application and the editing component."));
+
+ // pipe to terminal action
+ if (KateApp::self()->authorize("shell_access"))
+ new TDEAction(i18n("&Pipe to Console"), "pipe", 0, TQT_TQOBJECT(console), TQT_SLOT(slotPipeToConsole()), actionCollection(), "tools_pipe_to_terminal");
+
+ // tip of the day :-)
+ KStdAction::tipOfDay( TQT_TQOBJECT(this), TQT_SLOT( tipOfTheDay() ), actionCollection() )->setWhatsThis(i18n("This shows useful tips on the use of this application."));
+
+ if (KatePluginManager::self()->pluginList().count() > 0)
+ {
+ a=new TDEAction(i18n("&Plugins Handbook"), 0, TQT_TQOBJECT(this), TQT_SLOT(pluginHelp()), actionCollection(), "help_plugins_contents");
+ a->setWhatsThis(i18n("This shows help files for various available plugins."));
+ }
+
+ connect(m_viewManager,TQT_SIGNAL(viewChanged()),TQT_TQOBJECT(this),TQT_SLOT(slotWindowActivated()));
+ connect(m_viewManager,TQT_SIGNAL(viewChanged()),TQT_TQOBJECT(this),TQT_SLOT(slotUpdateOpenWith()));
+
+ slotWindowActivated ();
+
+ // session actions
+ new TDEAction(i18n("Menu entry Session->New", "&New"), "filenew", 0, TQT_TQOBJECT(KateSessionManager::self()), TQT_SLOT(sessionNew()), actionCollection(), "sessions_new");
+ new TDEAction(i18n("&Open..."), "fileopen", 0, TQT_TQOBJECT(KateSessionManager::self()), TQT_SLOT(sessionOpen()), actionCollection(), "sessions_open");
+ new TDEAction(i18n("&Save"), "filesave", 0, TQT_TQOBJECT(KateSessionManager::self()), TQT_SLOT(sessionSave()), actionCollection(), "sessions_save");
+ new TDEAction(i18n("Save &As..."), "filesaveas", 0, TQT_TQOBJECT(KateSessionManager::self()), TQT_SLOT(sessionSaveAs()), actionCollection(), "sessions_save_as");
+ new TDEAction(i18n("&Manage..."), "view_choose", 0, TQT_TQOBJECT(KateSessionManager::self()), TQT_SLOT(sessionManage()), actionCollection(), "sessions_manage");
+
+ // quick open menu ;)
+ new KateSessionsAction (i18n("&Quick Open"), actionCollection(), "sessions_list");
+}
+
+KateTabWidget *KateMainWindow::tabWidget ()
+{
+ return m_tabWidget;
+}
+
+void KateMainWindow::slotDocumentCloseAll() {
+ if (queryClose_internal())
+ KateDocManager::self()->closeAllDocuments(false);
+}
+
+bool KateMainWindow::queryClose_internal() {
+ uint documentCount=KateDocManager::self()->documents();
+
+ if ( ! showModOnDiskPrompt() )
+ return false;
+
+ TQPtrList<Kate::Document> modifiedDocuments=KateDocManager::self()->modifiedDocumentList();
+ bool shutdown=(modifiedDocuments.count()==0);
+
+ if (!shutdown) {
+ shutdown=KateSaveModifiedDialog::queryClose(this,modifiedDocuments);
+ }
+
+ if ( KateDocManager::self()->documents() > documentCount ) {
+ KMessageBox::information (this,
+ i18n ("New file opened while trying to close Kate, closing aborted."),
+ i18n ("Closing Aborted"));
+ shutdown=false;
+ }
+
+ return shutdown;
+}
+
+/**
+ * queryClose(), take care that after the last mainwindow the stuff is closed
+ */
+bool KateMainWindow::queryClose()
+{
+ // session saving, can we close all views ?
+ // just test, not close them actually
+ if (KateApp::self()->sessionSaving())
+ {
+ return queryClose_internal ();
+ }
+
+ // normal closing of window
+ // allow to close all windows until the last without restrictions
+ if ( KateApp::self()->mainWindows () > 1 )
+ return true;
+
+ // last one: check if we can close all documents, try run
+ // and save docs if we really close down !
+ if ( queryClose_internal () )
+ {
+ KateApp::self()->sessionManager()->saveActiveSession(true, true);
+
+ // detach the dcopClient
+ KateApp::self()->dcopClient()->detach();
+
+ return true;
+ }
+
+ return false;
+}
+
+void KateMainWindow::newWindow ()
+{
+ KateApp::self()->newMainWindow ();
+}
+
+void KateMainWindow::slotEditToolbars()
+{
+ saveMainWindowSettings( KateApp::self()->config(), "MainWindow" );
+ KEditToolbar dlg( factory() );
+ connect( &dlg, TQT_SIGNAL(newToolbarConfig()), this, TQT_SLOT(slotNewToolbarConfig()) );
+ dlg.exec();
+}
+
+void KateMainWindow::slotNewToolbarConfig()
+{
+ applyMainWindowSettings( KateApp::self()->config(), "MainWindow" );
+}
+
+void KateMainWindow::slotFileQuit()
+{
+ KateApp::self()->shutdownKate (this);
+}
+
+void KateMainWindow::readOptions ()
+{
+ TDEConfig *config = KateApp::self()->config ();
+
+ config->setGroup("General");
+ syncKonsole = config->readBoolEntry("Sync Konsole", true);
+ useInstance = config->readBoolEntry("UseInstance", false);
+ modNotification = config->readBoolEntry("Modified Notification", false);
+ KateDocManager::self()->setSaveMetaInfos(config->readBoolEntry("Save Meta Infos", true));
+ KateDocManager::self()->setDaysMetaInfos(config->readNumEntry("Days Meta Infos", 30));
+
+ m_viewManager->setShowFullPath(config->readBoolEntry("Show Full Path in Title", false));
+
+ fileOpenRecent->setMaxItems( config->readNumEntry("Number of recent files", fileOpenRecent->maxItems() ) );
+ fileOpenRecent->loadEntries(config, "Recent Files");
+
+ fileselector->readConfig(config, "fileselector");
+}
+
+void KateMainWindow::saveOptions ()
+{
+ TDEConfig *config = KateApp::self()->config ();
+ config->setGroup("General");
+
+ if (console)
+ config->writeEntry("Show Console", console->isVisible());
+ else
+ config->writeEntry("Show Console", false);
+
+ config->writeEntry("Save Meta Infos", KateDocManager::self()->getSaveMetaInfos());
+ config->writeEntry("Days Meta Infos", KateDocManager::self()->getDaysMetaInfos());
+ config->writeEntry("Show Full Path in Title", m_viewManager->getShowFullPath());
+ config->writeEntry("Sync Konsole", syncKonsole);
+ config->writeEntry("UseInstance", useInstance);
+
+ fileOpenRecent->saveEntries(config, "Recent Files");
+ fileselector->writeConfig(config, "fileselector");
+ filelist->writeConfig(config, "Filelist");
+
+ config->sync();
+}
+
+void KateMainWindow::slotWindowActivated ()
+{
+ if (m_viewManager->activeView())
+ {
+ if (console && syncKonsole)
+ {
+ static TQString path;
+ TQString newPath = m_viewManager->activeView()->getDoc()->url().directory();
+
+ if ( newPath != path )
+ {
+ path = newPath;
+ console->cd (KURL( path ));
+ }
+ }
+
+ updateCaption (m_viewManager->activeView()->getDoc());
+ }
+
+ // update proxy
+ centralWidget()->setFocusProxy (m_viewManager->activeView());
+}
+
+void KateMainWindow::slotUpdateOpenWith()
+{
+ if (m_viewManager->activeView())
+ documentOpenWith->setEnabled(!m_viewManager->activeView()->document()->url().isEmpty());
+ else
+ documentOpenWith->setEnabled(false);
+}
+
+void KateMainWindow::documentMenuAboutToShow()
+{
+ // remove documents
+ while (documentMenu->count() > 3)
+ documentMenu->removeItemAt (3);
+
+ TQListViewItem * item = filelist->firstChild();
+ while( item ) {
+ // would it be saner to use the screen width as a limit that some random number??
+ TQString name = KStringHandler::rsqueeze( ((KateFileListItem *)item)->document()->docName(), 150 );
+ Kate::Document* doc = ((KateFileListItem *)item)->document();
+ documentMenu->insertItem (
+ doc->isModified() ? i18n("'document name [*]', [*] means modified", "%1 [*]").arg(name) : name,
+ m_viewManager, TQT_SLOT (activateView (int)), 0,
+ ((KateFileListItem *)item)->documentNumber () );
+
+ item = item->nextSibling();
+ }
+ if (m_viewManager->activeView())
+ documentMenu->setItemChecked ( m_viewManager->activeView()->getDoc()->documentNumber(), true);
+}
+
+void KateMainWindow::slotGrepToolItemSelected(const TQString &filename,int linenumber)
+{
+ KURL fileURL;
+ fileURL.setPath( filename );
+ m_viewManager->openURL( fileURL );
+ if ( m_viewManager->activeView() == 0 ) return;
+ m_viewManager->activeView()->gotoLineNumber( linenumber );
+ raise();
+ setActiveWindow();
+}
+
+void KateMainWindow::dragEnterEvent( TQDragEnterEvent *event )
+{
+ event->accept(KURLDrag::canDecode(event));
+}
+
+void KateMainWindow::dropEvent( TQDropEvent *event )
+{
+ slotDropEvent(event);
+}
+
+void KateMainWindow::slotDropEvent( TQDropEvent * event )
+{
+ KURL::List textlist;
+ if (!KURLDrag::decode(event, textlist)) return;
+
+ for (KURL::List::Iterator i=textlist.begin(); i != textlist.end(); ++i)
+ {
+ m_viewManager->openURL (*i);
+ }
+}
+
+void KateMainWindow::editKeys()
+{
+ KKeyDialog dlg ( false, this );
+
+ TQPtrList<KXMLGUIClient> clients = guiFactory()->clients();
+
+ for( TQPtrListIterator<KXMLGUIClient> it( clients ); it.current(); ++it )
+ dlg.insert ( (*it)->actionCollection(), (*it)->instance()->aboutData()->programName() );
+
+ dlg.insert( externalTools->actionCollection(), i18n("External Tools") );
+
+ dlg.configure();
+
+ TQPtrList<Kate::Document> l=KateDocManager::self()->documentList();
+ for (uint i=0;i<l.count();i++) {
+// kdDebug(13001)<<"reloading Keysettings for document "<<i<<endl;
+ l.at(i)->reloadXML();
+ TQPtrList<class KTextEditor::View> l1=l.at(i)->views ();//KTextEditor::Document
+ for (uint i1=0;i1<l1.count();i1++) {
+ l1.at(i1)->reloadXML();
+// kdDebug(13001)<<"reloading Keysettings for view "<<i<<"/"<<i1<<endl;
+ }
+ }
+
+ externalTools->actionCollection()->writeShortcutSettings( "Shortcuts", new TDEConfig("externaltools", false, false, "appdata") );
+}
+
+void KateMainWindow::openURL (const TQString &name)
+{
+ m_viewManager->openURL (KURL(name));
+}
+
+void KateMainWindow::slotConfigure()
+{
+ if (!m_viewManager->activeView())
+ return;
+
+ KateConfigDialog* dlg = new KateConfigDialog (this, m_viewManager->activeView());
+ dlg->exec();
+
+ delete dlg;
+}
+
+KURL KateMainWindow::activeDocumentUrl()
+{
+ // anders: i make this one safe, as it may be called during
+ // startup (by the file selector)
+ Kate::View *v = m_viewManager->activeView();
+ if ( v )
+ return v->getDoc()->url();
+ return KURL();
+}
+
+void KateMainWindow::fileSelected(const KFileItem * /*file*/)
+{
+ const KFileItemList *list=fileselector->dirOperator()->selectedItems();
+ KFileItem *tmp;
+ for (KFileItemListIterator it(*list); (tmp = it.current()); ++it)
+ {
+ m_viewManager->openURL(tmp->url());
+ fileselector->dirOperator()->view()->setSelected(tmp,false);
+ }
+}
+
+// TODO make this work
+void KateMainWindow::mSlotFixOpenWithMenu()
+{
+ //kdDebug(13001)<<"13000"<<"fixing open with menu"<<endl;
+ documentOpenWith->popupMenu()->clear();
+ // get a list of appropriate services.
+ KMimeType::Ptr mime = KMimeType::findByURL( m_viewManager->activeView()->getDoc()->url() );
+ //kdDebug(13001)<<"13000"<<"url: "<<m_viewManager->activeView()->getDoc()->url().prettyURL()<<"mime type: "<<mime->name()<<endl;
+ // some checking goes here...
+ TDETrader::OfferList offers = TDETrader::self()->query(mime->name(), "Type == 'Application'");
+ // for each one, insert a menu item...
+ for(TDETrader::OfferList::Iterator it = offers.begin(); it != offers.end(); ++it) {
+ if ((*it)->name() == "Kate") continue;
+ documentOpenWith->popupMenu()->insertItem( SmallIcon( (*it)->icon() ), (*it)->name() );
+ }
+ // append "Other..." to call the TDE "open with" dialog.
+ documentOpenWith->popupMenu()->insertItem(i18n("&Other..."));
+}
+
+void KateMainWindow::slotOpenWithMenuAction(int idx)
+{
+ KURL::List list;
+ list.append( m_viewManager->activeView()->getDoc()->url() );
+ TQString appname = documentOpenWith->popupMenu()->text(idx);
+
+ appname = appname.remove('&'); //Remove a possible accelerator ... otherwise the application might not get found.
+ if ( appname.compare(i18n("Other...")) == 0 ) {
+ // display "open with" dialog
+ KOpenWithDlg dlg(list);
+ if (dlg.exec())
+ KRun::run(*dlg.service(), list);
+ return;
+ }
+
+ TQString qry = TQString("((Type == 'Application') and (Name == '%1'))").arg( appname.latin1() );
+ KMimeType::Ptr mime = KMimeType::findByURL( m_viewManager->activeView()->getDoc()->url() );
+ TDETrader::OfferList offers = TDETrader::self()->query(mime->name(), qry);
+
+ if (!offers.isEmpty()) {
+ KService::Ptr app = offers.first();
+ KRun::run(*app, list);
+ }
+ else
+ KMessageBox::error(this, i18n("Application '%1' not found!").arg(appname.latin1()), i18n("Application Not Found!"));
+}
+
+void KateMainWindow::pluginHelp()
+{
+ KateApp::self()->invokeHelp (TQString::null, "kate-plugins");
+}
+
+void KateMainWindow::slotMail()
+{
+ KateMailDialog *d = new KateMailDialog(this, this);
+ if ( ! d->exec() )
+ {
+ delete d;
+ return;
+ }
+ TQPtrList<Kate::Document> attDocs = d->selectedDocs();
+ delete d;
+ // Check that all selected files are saved (or shouldn't be)
+ TQStringList urls; // to atthatch
+ Kate::Document *doc;
+ TQPtrListIterator<Kate::Document> it(attDocs);
+ for ( ; it.current(); ++it ) {
+ doc = it.current();
+ if (!doc) continue;
+ if ( doc->url().isEmpty() ) {
+ // unsaved document. back out unless it gets saved
+ int r = KMessageBox::questionYesNo( this,
+ i18n("<p>The current document has not been saved, and "
+ "cannot be attached to an email message."
+ "<p>Do you want to save it and proceed?"),
+ i18n("Cannot Send Unsaved File"),KStdGuiItem::saveAs(),KStdGuiItem::cancel() );
+ if ( r == KMessageBox::Yes ) {
+ Kate::View *v = (Kate::View*)doc->views().first();
+ int sr = v->saveAs();
+ if ( sr == Kate::View::SAVE_OK ) { ;
+ }
+ else {
+ if ( sr != Kate::View::SAVE_CANCEL ) // ERROR or RETRY(?)
+ KMessageBox::sorry( this, i18n("The file could not be saved. Please check "
+ "if you have write permission.") );
+ continue;
+ }
+ }
+ else
+ continue;
+ }
+ if ( doc->isModified() ) {
+ // warn that document is modified and offer to save it before proceeding.
+ int r = KMessageBox::warningYesNoCancel( this,
+ i18n("<p>The current file:<br><strong>%1</strong><br>has been "
+ "modified. Modifications will not be available in the attachment."
+ "<p>Do you want to save it before sending it?").arg(doc->url().prettyURL()),
+ i18n("Save Before Sending?"), KStdGuiItem::save(), i18n("Do Not Save") );
+ switch ( r ) {
+ case KMessageBox::Cancel:
+ continue;
+ case KMessageBox::Yes:
+ doc->save();
+ if ( doc->isModified() ) { // read-only docs ends here, if modified. Hmm.
+ KMessageBox::sorry( this, i18n("The file could not be saved. Please check "
+ "if you have write permission.") );
+ continue;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ // finally call the mailer
+ urls << doc->url().url();
+ } // check selected docs done
+ if ( ! urls.count() )
+ return;
+ KateApp::self()->invokeMailer( TQString::null, // to
+ TQString::null, // cc
+ TQString::null, // bcc
+ TQString::null, // subject
+ TQString::null, // body
+ TQString::null, // msgfile
+ urls // urls to atthatch
+ );
+}
+void KateMainWindow::tipOfTheDay()
+{
+ KTipDialog::showTip( /*0*/this, TQString::null, true );
+}
+
+void KateMainWindow::slotFullScreen(bool t)
+{
+ if (t)
+ showFullScreen();
+ else
+ showNormal();
+}
+
+void KateMainWindow::updateGrepDir (bool visible)
+{
+ // grepdlg gets hidden
+ if (!visible)
+ return;
+
+ if ( m_viewManager->activeView() )
+ {
+ if ( m_viewManager->activeView()->getDoc()->url().isLocalFile() )
+ {
+ greptool->updateDirName( m_viewManager->activeView()->getDoc()->url().directory() );
+ }
+ }
+}
+
+bool KateMainWindow::event( TQEvent *e )
+{
+ uint type = e->type();
+ if ( type == TQEvent::WindowActivate && modNotification )
+ {
+ showModOnDiskPrompt();
+ }
+ return KateMDI::MainWindow::event( e );
+}
+
+bool KateMainWindow::showModOnDiskPrompt()
+{
+ Kate::Document *doc;
+
+ DocVector list( KateDocManager::self()->documents() );
+ uint cnt = 0;
+ for( doc = KateDocManager::self()->firstDocument(); doc; doc = KateDocManager::self()->nextDocument() )
+ {
+ if ( KateDocManager::self()->documentInfo( doc )->modifiedOnDisc )
+ {
+ list.insert( cnt, doc );
+ cnt++;
+ }
+ }
+
+ if ( cnt && !m_modignore )
+ {
+ list.resize( cnt );
+ KateMwModOnHdDialog mhdlg( list, this );
+ m_modignore = true;
+ bool res = mhdlg.exec();
+ m_modignore = false;
+
+ return res;
+ }
+ return true;
+}
+
+void KateMainWindow::slotDocumentCreated (Kate::Document *doc)
+{
+ connect(doc,TQT_SIGNAL(modStateChanged(Kate::Document *)),this,TQT_SLOT(updateCaption(Kate::Document *)));
+ connect(doc,TQT_SIGNAL(nameChanged(Kate::Document *)),this,TQT_SLOT(slotNameChanged(Kate::Document *)));
+ connect(doc,TQT_SIGNAL(nameChanged(Kate::Document *)),this,TQT_SLOT(slotUpdateOpenWith()));
+
+ updateCaption (doc);
+}
+
+void KateMainWindow::slotNameChanged(Kate::Document *doc)
+{
+ updateCaption(doc);
+ if (!doc->url().isEmpty())
+ fileOpenRecent->addURL(doc->url());
+}
+
+void KateMainWindow::updateCaption (Kate::Document *doc)
+{
+ if (!m_viewManager->activeView())
+ {
+ setCaption ("", false);
+ return;
+ }
+
+ if (!(m_viewManager->activeView()->getDoc() == doc))
+ return;
+
+ TQString c;
+ if (m_viewManager->activeView()->getDoc()->url().isEmpty() || (!m_viewManager->getShowFullPath()))
+ {
+ c = m_viewManager->activeView()->getDoc()->docName();
+ }
+ else
+ {
+ c = m_viewManager->activeView()->getDoc()->url().prettyURL();
+ }
+
+ TQString sessName = KateApp::self()->sessionManager()->activeSession()->sessionName();
+ if ( !sessName.isEmpty() )
+ sessName = TQString("%1: ").arg( sessName );
+
+ setCaption( sessName + KStringHandler::lsqueeze(c,64),
+ m_viewManager->activeView()->getDoc()->isModified());
+}
+
+void KateMainWindow::saveProperties(TDEConfig *config)
+{
+ TQString grp=config->group();
+
+ saveSession(config, grp);
+ m_viewManager->saveViewConfiguration (config, grp);
+
+ config->setGroup(grp);
+}
+
+void KateMainWindow::readProperties(TDEConfig *config)
+{
+ TQString grp=config->group();
+
+ startRestore(config, grp);
+ finishRestore ();
+ m_viewManager->restoreViewConfiguration (config, grp);
+
+ config->setGroup(grp);
+}
+
+void KateMainWindow::saveGlobalProperties( TDEConfig* sessionConfig )
+{
+ KateDocManager::self()->saveDocumentList (sessionConfig);
+
+ sessionConfig->setGroup("General");
+ sessionConfig->writeEntry ("Last Session", KateApp::self()->sessionManager()->activeSession()->sessionFileRelative());
+}
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/katemainwindow.h b/kate/app/katemainwindow.h
new file mode 100644
index 000000000..157b4e57d
--- /dev/null
+++ b/kate/app/katemainwindow.h
@@ -0,0 +1,218 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
+ Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __KATE_MAINWINDOW_H__
+#define __KATE_MAINWINDOW_H__
+
+#include "katemain.h"
+#include "katemdi.h"
+
+#include <kate/view.h>
+#include <kate/document.h>
+
+#include <tdeparts/part.h>
+
+#include <tdeaction.h>
+
+class KateTabWidget;
+class GrepTool;
+
+namespace Kate {
+ class MainWindow;
+ class ToolViewManager;
+}
+
+class KFileItem;
+class TDERecentFilesAction;
+class DCOPObject;
+
+class KateExternalToolsMenuAction;
+
+class KateMainWindow : public KateMDI::MainWindow, virtual public KParts::PartBase
+{
+ Q_OBJECT
+
+ friend class KateConfigDialog;
+ friend class KateViewManager;
+
+ public:
+ /**
+ * Construct the window and restore it's state from given config if any
+ * @param sconfig session config for this window, 0 if none
+ * @param sgroup session config group to use
+ */
+ KateMainWindow (TDEConfig *sconfig, const TQString &sgroup);
+
+ /**
+ * Destruct the nice window
+ */
+ ~KateMainWindow();
+
+ /**
+ * Accessor methodes for interface and child objects
+ */
+ public:
+ Kate::MainWindow *mainWindow () { return m_mainWindow; }
+ Kate::ToolViewManager *toolViewManager () { return m_toolViewManager; }
+
+ KateViewManager *viewManager () { return m_viewManager; }
+
+ DCOPObject *dcopObject () { return m_dcop; }
+
+ /**
+ * various methodes to get some little info out of this
+ */
+ public:
+ /** Returns the URL of the current document.
+ * anders: I add this for use from the file selector. */
+ KURL activeDocumentUrl();
+
+ uint mainWindowNumber () const { return myID; }
+
+ /**
+ * Prompts the user for what to do with files that are modified on disk if any.
+ * This is optionally run when the window receives focus, and when the last
+ * window is closed.
+ * @return true if no documents are modified on disk, or all documents were
+ * handled by the dialog; otherwise (the dialog was canceled) false.
+ */
+ bool showModOnDiskPrompt();
+
+ /**
+ * central tabwidget ;)
+ * @return tab widget
+ */
+ KateTabWidget *tabWidget ();
+
+ public:
+ void readProperties(TDEConfig *config);
+ void saveProperties(TDEConfig *config);
+ void saveGlobalProperties( TDEConfig* sessionConfig );
+
+ public:
+ bool queryClose_internal();
+
+ private:
+ void setupMainWindow();
+ void setupActions();
+ bool queryClose();
+
+ /**
+ * read some global options from katerc
+ */
+ void readOptions();
+
+ /**
+ * save some global options to katerc
+ */
+ void saveOptions();
+
+ void dragEnterEvent( TQDragEnterEvent * );
+ void dropEvent( TQDropEvent * );
+
+ /**
+ * slots used for actions in the menus/toolbars
+ * or internal signal connections
+ */
+ private slots:
+ void newWindow ();
+
+ void slotConfigure();
+
+ void slotOpenWithMenuAction(int idx);
+
+ void slotGrepToolItemSelected ( const TQString &filename, int linenumber );
+ void slotMail();
+
+ void slotFileQuit();
+ void slotEditToolbars();
+ void slotNewToolbarConfig();
+ void slotWindowActivated ();
+ void slotUpdateOpenWith();
+ void documentMenuAboutToShow();
+ void slotDropEvent(TQDropEvent *);
+ void editKeys();
+ void mSlotFixOpenWithMenu();
+
+ void fileSelected(const KFileItem *file);
+
+ void tipOfTheDay();
+
+ /* to update the caption */
+ void slotDocumentCreated(Kate::Document *doc);
+ void slotNameChanged(Kate::Document *doc);
+ void updateCaption(Kate::Document *doc);
+
+ void pluginHelp();
+ void slotFullScreen(bool);
+
+ public:
+ void openURL (const TQString &name=0L);
+
+ private slots:
+ void updateGrepDir (bool visible);
+
+ protected:
+ bool event( TQEvent * );
+
+ private slots:
+ void slotDocumentCloseAll();
+
+ private:
+ static uint uniqueID;
+ uint myID;
+
+ Kate::MainWindow *m_mainWindow;
+ Kate::ToolViewManager *m_toolViewManager;
+
+ bool syncKonsole;
+ bool useInstance;
+ bool modNotification;
+
+ DCOPObject *m_dcop;
+
+ // console
+ KateConsole *console;
+
+ // management items
+ KateViewManager *m_viewManager;
+
+ TDERecentFilesAction *fileOpenRecent;
+
+ KateFileList *filelist;
+ KateFileSelector *fileselector;
+
+ TDEActionMenu* documentOpenWith;
+
+ TQPopupMenu *documentMenu;
+
+ TDEToggleAction* settingsShowFilelist;
+ TDEToggleAction* settingsShowFileselector;
+
+ KateExternalToolsMenuAction *externalTools;
+ GrepTool * greptool;
+ bool m_modignore, m_grrr;
+
+ KateTabWidget *m_tabWidget;
+};
+
+#endif
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/katemainwindowiface.cpp b/kate/app/katemainwindowiface.cpp
new file mode 100644
index 000000000..af3c74ed2
--- /dev/null
+++ b/kate/app/katemainwindowiface.cpp
@@ -0,0 +1,27 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Ian Reinhart Geiser <geiseri@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "katemainwindowiface.h"
+
+#include "katemainwindow.h"
+
+#include <kdebug.h>
+
+KateMainWindowDCOPIface::KateMainWindowDCOPIface (KateMainWindow *w) : DCOPObject (TQString(TQString("KateMainWindow#%1").arg(w->mainWindowNumber())).latin1()), m_w (w)
+{
+}
diff --git a/kate/app/katemainwindowiface.h b/kate/app/katemainwindowiface.h
new file mode 100644
index 000000000..3292d1b15
--- /dev/null
+++ b/kate/app/katemainwindowiface.h
@@ -0,0 +1,41 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Ian Reinhart Geiser <geiseri@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _katemainwindow_Iface_h_
+#define _katemainwindow_Iface_h_
+
+#include <dcopobject.h>
+#include <dcopref.h>
+
+#include <kurl.h>
+
+class KateMainWindow;
+
+class KateMainWindowDCOPIface : public DCOPObject
+{
+ K_DCOP
+
+ public:
+ KateMainWindowDCOPIface (KateMainWindow *w);
+
+ k_dcop:
+
+ private:
+ KateMainWindow *m_w;
+};
+#endif
diff --git a/kate/app/katemdi.cpp b/kate/app/katemdi.cpp
new file mode 100644
index 000000000..a6c657e2c
--- /dev/null
+++ b/kate/app/katemdi.cpp
@@ -0,0 +1,970 @@
+/* This file is part of the KDE libraries
+ Copyright (C) 2005 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2002, 2003 Joseph Wenninger <jowenn@kde.org>
+
+ GUIClient partly based on tdetoolbarhandler.cpp: Copyright (C) 2002 Simon Hausmann <hausmann@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "katemdi.h"
+#include "katemdi.moc"
+
+#include <tdeaction.h>
+#include <kdebug.h>
+#include <tdeglobal.h>
+#include <tdeglobalsettings.h>
+#include <tdeapplication.h>
+#include <tdelocale.h>
+#include <tdeconfig.h>
+#include <kiconloader.h>
+#include <tdepopupmenu.h>
+#include <tdemessagebox.h>
+
+#include <tqvbox.h>
+#include <tqhbox.h>
+#include <tqevent.h>
+
+namespace KateMDI {
+
+//BEGIN SPLITTER
+
+Splitter::Splitter(Orientation o, TQWidget* parent, const char* name)
+ : TQSplitter(o, parent, name)
+{
+}
+
+Splitter::~Splitter()
+{
+}
+
+bool Splitter::isLastChild(TQWidget* w) const
+{
+ return ( idAfter( w ) == 0 );
+}
+
+int Splitter::idAfter ( TQWidget * w ) const
+{
+ return TQSplitter::idAfter (w);
+}
+
+//END SPLITTER
+
+
+//BEGIN TOGGLETOOLVIEWACTION
+
+ToggleToolViewAction::ToggleToolViewAction ( const TQString& text, const TDEShortcut& cut, ToolView *tv,
+ TQObject* parent, const char* name )
+ : TDEToggleAction(text,cut,parent,name)
+ , m_tv(tv)
+{
+ connect(this,TQT_SIGNAL(toggled(bool)),this,TQT_SLOT(slotToggled(bool)));
+ connect(m_tv,TQT_SIGNAL(visibleChanged(bool)),this,TQT_SLOT(visibleChanged(bool)));
+
+ setChecked(m_tv->visible());
+}
+
+ToggleToolViewAction::~ToggleToolViewAction()
+{
+ unplugAll();
+}
+
+void ToggleToolViewAction::visibleChanged(bool)
+{
+ if (isChecked() != m_tv->visible())
+ setChecked (m_tv->visible());
+}
+
+void ToggleToolViewAction::slotToggled(bool t)
+{
+ if (t)
+ {
+ m_tv->mainWindow()->showToolView (m_tv);
+ m_tv->setFocus ();
+ }
+ else
+ {
+ m_tv->mainWindow()->hideToolView (m_tv);
+ m_tv->mainWindow()->centralWidget()->setFocus ();
+ }
+}
+
+//END TOGGLETOOLVIEWACTION
+
+
+//BEGIN GUICLIENT
+
+static const char *actionListName = "kate_mdi_window_actions";
+
+static const char *guiDescription = ""
+ "<!DOCTYPE kpartgui><kpartgui name=\"kate_mdi_window_actions\">"
+ "<MenuBar>"
+ " <Menu name=\"window\">"
+ " <ActionList name=\"%1\" />"
+ " </Menu>"
+ "</MenuBar>"
+ "</kpartgui>";
+
+GUIClient::GUIClient ( MainWindow *mw )
+ : TQObject ( mw )
+ , KXMLGUIClient ( mw )
+ , m_mw (mw)
+{
+ connect( m_mw->guiFactory(), TQT_SIGNAL( clientAdded( KXMLGUIClient * ) ),
+ this, TQT_SLOT( clientAdded( KXMLGUIClient * ) ) );
+
+ if ( domDocument().documentElement().isNull() )
+ {
+ TQString completeDescription = TQString::fromLatin1( guiDescription )
+ .arg( actionListName );
+
+ setXML( completeDescription, false /*merge*/ );
+ }
+
+ if (actionCollection()->tdeaccel()==0)
+ actionCollection()->setWidget(m_mw);
+
+ m_toolMenu = new TDEActionMenu(i18n("Tool &Views"),actionCollection(),"kate_mdi_toolview_menu");
+ m_showSidebarsAction = new TDEToggleAction( i18n("Show Side&bars"),
+ CTRL|ALT|SHIFT|Key_F, actionCollection(), "kate_mdi_sidebar_visibility" );
+ m_showSidebarsAction->setCheckedState(i18n("Hide Side&bars"));
+ m_showSidebarsAction->setChecked( m_mw->sidebarsVisible() );
+ connect( m_showSidebarsAction, TQT_SIGNAL( toggled( bool ) ),
+ m_mw, TQT_SLOT( setSidebarsVisible( bool ) ) );
+
+ m_toolMenu->insert( m_showSidebarsAction );
+ m_toolMenu->insert( new TDEActionSeparator( m_toolMenu ) );
+
+ // read shortcuts
+ actionCollection()->readShortcutSettings( "Shortcuts", kapp->config() );
+}
+
+GUIClient::~GUIClient()
+{
+}
+
+void GUIClient::updateSidebarsVisibleAction()
+{
+ m_showSidebarsAction->setChecked( m_mw->sidebarsVisible() );
+}
+
+void GUIClient::registerToolView (ToolView *tv)
+{
+ TQString aname = TQString("kate_mdi_toolview_") + tv->id;
+
+ // try to read the action shortcut
+ TDEShortcut sc;
+ TDEConfig *cfg = kapp->config();
+ TQString _grp = cfg->group();
+ cfg->setGroup("Shortcuts");
+ sc = TDEShortcut( cfg->readEntry( aname, "" ) );
+ cfg->setGroup( _grp );
+
+ TDEToggleAction *a = new ToggleToolViewAction(i18n("Show %1").arg(tv->text),
+ sc,tv, actionCollection(), aname.latin1() );
+
+ a->setCheckedState(TQString(i18n("Hide %1").arg(tv->text)));
+
+ m_toolViewActions.append(a);
+ m_toolMenu->insert(a);
+
+ m_toolToAction.insert (tv, a);
+
+ updateActions();
+}
+
+void GUIClient::unregisterToolView (ToolView *tv)
+{
+ TDEAction *a = m_toolToAction[tv];
+
+ if (!a)
+ return;
+
+ m_toolViewActions.remove(a);
+ delete a;
+
+ m_toolToAction.remove (tv);
+
+ updateActions();
+}
+
+void GUIClient::clientAdded( KXMLGUIClient *client )
+{
+ if ( client == this )
+ updateActions();
+}
+
+void GUIClient::updateActions()
+{
+ if ( !factory() )
+ return;
+
+ unplugActionList( actionListName );
+
+ TQPtrList<TDEAction> addList;
+ addList.append(m_toolMenu);
+
+ plugActionList( actionListName, addList );
+}
+
+//END GUICLIENT
+
+
+//BEGIN TOOLVIEW
+
+ToolView::ToolView (MainWindow *mainwin, Sidebar *sidebar, TQWidget *parent)
+ : TQVBox (parent)
+ , m_mainWin (mainwin)
+ , m_sidebar (sidebar)
+ , m_visible (false)
+ , persistent (false)
+{
+}
+
+ToolView::~ToolView ()
+{
+ m_mainWin->toolViewDeleted (this);
+}
+
+void ToolView::setVisible (bool vis)
+{
+ if (m_visible == vis)
+ return;
+
+ m_visible = vis;
+ emit visibleChanged (m_visible);
+}
+
+bool ToolView::visible () const
+{
+ return m_visible;
+}
+
+void ToolView::childEvent ( TQChildEvent *ev )
+{
+ // set the widget to be focus proxy if possible
+ if (ev->inserted() && ev->child() && TQT_TQOBJECT(ev->child())->tqt_cast(TQWIDGET_OBJECT_NAME_STRING)) {
+ setFocusProxy (::tqqt_cast<QWidget*>(TQT_TQOBJECT(ev->child())));
+}
+
+ TQVBox::childEvent (ev);
+}
+
+//END TOOLVIEW
+
+
+//BEGIN SIDEBAR
+
+Sidebar::Sidebar (KMultiTabBar::KMultiTabBarPosition pos, MainWindow *mainwin, TQWidget *parent)
+ : KMultiTabBar ((pos == KMultiTabBar::Top || pos == KMultiTabBar::Bottom) ? KMultiTabBar::Horizontal : KMultiTabBar::Vertical, parent)
+ , m_mainWin (mainwin)
+ , m_splitter (0)
+ , m_ownSplit (0)
+ , m_lastSize (0)
+{
+ setPosition( pos );
+ hide ();
+}
+
+Sidebar::~Sidebar ()
+{
+}
+
+void Sidebar::setSplitter (Splitter *sp)
+{
+ m_splitter = sp;
+ m_ownSplit = new Splitter ((position() == KMultiTabBar::Top || position() == KMultiTabBar::Bottom) ? Qt::Horizontal : Qt::Vertical, m_splitter);
+ m_ownSplit->setOpaqueResize( TDEGlobalSettings::opaqueResize() );
+ m_ownSplit->setChildrenCollapsible( false );
+ m_splitter->setResizeMode( m_ownSplit, TQSplitter::KeepSize );
+ m_ownSplit->hide ();
+}
+
+ToolView *Sidebar::addWidget (const TQPixmap &icon, const TQString &text, ToolView *widget)
+{
+ static int id = 0;
+
+ if (widget)
+ {
+ if (widget->sidebar() == this)
+ return widget;
+
+ widget->sidebar()->removeWidget (widget);
+ }
+
+ int newId = ++id;
+
+ appendTab (icon, newId, text);
+
+ if (!widget)
+ {
+ widget = new ToolView (m_mainWin, this, m_ownSplit);
+ widget->hide ();
+ widget->icon = icon;
+ widget->text = text;
+ }
+ else
+ {
+ widget->hide ();
+ widget->reparent (m_ownSplit, 0, TQPoint());
+ widget->m_sidebar = this;
+ }
+
+ // save it's pos ;)
+ widget->persistent = false;
+
+ m_idToWidget.insert (newId, widget);
+ m_widgetToId.insert (widget, newId);
+ m_toolviews.push_back (widget);
+
+ show ();
+
+ connect(tab(newId),TQT_SIGNAL(clicked(int)),this,TQT_SLOT(tabClicked(int)));
+ tab(newId)->installEventFilter(this);
+
+ return widget;
+}
+
+bool Sidebar::removeWidget (ToolView *widget)
+{
+ if (!m_widgetToId.contains(widget))
+ return false;
+
+ removeTab(m_widgetToId[widget]);
+
+ m_idToWidget.remove (m_widgetToId[widget]);
+ m_widgetToId.remove (widget);
+ m_toolviews.remove (widget);
+
+ bool anyVis = false;
+ TQIntDictIterator<ToolView> it( m_idToWidget );
+ for ( ; it.current(); ++it )
+ {
+ if (!anyVis)
+ anyVis = it.current()->isVisible();
+ }
+
+ if (m_idToWidget.isEmpty())
+ {
+ m_ownSplit->hide ();
+ hide ();
+ }
+ else if (!anyVis)
+ m_ownSplit->hide ();
+
+ return true;
+}
+
+bool Sidebar::showWidget (ToolView *widget)
+{
+ if (!m_widgetToId.contains(widget))
+ return false;
+
+ // hide other non-persistent views
+ TQIntDictIterator<ToolView> it( m_idToWidget );
+ for ( ; it.current(); ++it )
+ if ((it.current() != widget) && !it.current()->persistent)
+ {
+ it.current()->hide();
+ setTab (it.currentKey(), false);
+ it.current()->setVisible(false);
+ }
+
+ setTab (m_widgetToId[widget], true);
+
+ m_ownSplit->show ();
+ widget->show ();
+
+ widget->setVisible (true);
+
+ return true;
+}
+
+bool Sidebar::hideWidget (ToolView *widget)
+{
+ if (!m_widgetToId.contains(widget))
+ return false;
+
+ bool anyVis = false;
+
+ updateLastSize ();
+
+ for ( TQIntDictIterator<ToolView> it( m_idToWidget ); it.current(); ++it )
+ {
+ if (it.current() == widget)
+ {
+ it.current()->hide();
+ continue;
+ }
+
+ if (!anyVis)
+ anyVis = it.current()->isVisible();
+ }
+
+ // lower tab
+ setTab (m_widgetToId[widget], false);
+
+ if (!anyVis)
+ m_ownSplit->hide ();
+
+ widget->setVisible (false);
+
+ return true;
+}
+
+void Sidebar::tabClicked(int i)
+{
+ ToolView *w = m_idToWidget[i];
+
+ if (!w)
+ return;
+
+ if (isTabRaised(i))
+ {
+ showWidget (w);
+ w->setFocus ();
+ }
+ else
+ {
+ hideWidget (w);
+ m_mainWin->centralWidget()->setFocus ();
+ }
+}
+
+bool Sidebar::eventFilter(TQObject *obj, TQEvent *ev)
+{
+ if (ev->type()==TQEvent::ContextMenu)
+ {
+ TQContextMenuEvent *e = (TQContextMenuEvent *) ev;
+ KMultiTabBarTab *bt = tqt_dynamic_cast<KMultiTabBarTab*>(obj);
+ if (bt)
+ {
+ kdDebug()<<"Request for popup"<<endl;
+
+ m_popupButton = bt->id();
+
+ ToolView *w = m_idToWidget[m_popupButton];
+
+ if (w)
+ {
+ TDEPopupMenu *p = new TDEPopupMenu (this);
+
+ p->insertTitle(SmallIcon("view_remove"), i18n("Behavior"), 50);
+
+ p->insertItem(w->persistent ? SmallIconSet("window_nofullscreen") : SmallIconSet("window_fullscreen"), w->persistent ? i18n("Make Non-Persistent") : i18n("Make Persistent"), 10);
+
+ p->insertTitle(SmallIcon("move"), i18n("Move To"), 51);
+
+ if (position() != 0)
+ p->insertItem(SmallIconSet("back"), i18n("Left Sidebar"),0);
+
+ if (position() != 1)
+ p->insertItem(SmallIconSet("forward"), i18n("Right Sidebar"),1);
+
+ if (position() != 2)
+ p->insertItem(SmallIconSet("up"), i18n("Top Sidebar"),2);
+
+ if (position() != 3)
+ p->insertItem(SmallIconSet("down"), i18n("Bottom Sidebar"),3);
+
+ connect(p, TQT_SIGNAL(activated(int)),
+ this, TQT_SLOT(buttonPopupActivate(int)));
+
+ p->exec(e->globalPos());
+ delete p;
+
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+void Sidebar::show()
+{
+ if (m_idToWidget.isEmpty() || !m_mainWin->sidebarsVisible() )
+ return;
+
+ KMultiTabBar::show( );
+}
+
+void Sidebar::buttonPopupActivate (int id)
+{
+ ToolView *w = m_idToWidget[m_popupButton];
+
+ if (!w)
+ return;
+
+ // move ids
+ if (id < 4)
+ {
+ // move + show ;)
+ m_mainWin->moveToolView (w, (KMultiTabBar::KMultiTabBarPosition) id);
+ m_mainWin->showToolView (w);
+ }
+
+ // toggle persistent
+ if (id == 10)
+ w->persistent = !w->persistent;
+}
+
+void Sidebar::updateLastSize ()
+{
+ TQValueList<int> s = m_splitter->sizes ();
+
+ int i = 0;
+ if ((position() == KMultiTabBar::Right || position() == KMultiTabBar::Bottom))
+ i = 2;
+
+ // little threshold
+ if (s[i] > 2)
+ m_lastSize = s[i];
+}
+
+class TmpToolViewSorter
+{
+ public:
+ ToolView *tv;
+ unsigned int pos;
+};
+
+void Sidebar::restoreSession (TDEConfig *config)
+{
+ // get the last correct placed toolview
+ unsigned int firstWrong = 0;
+ for ( ; firstWrong < m_toolviews.size(); ++firstWrong )
+ {
+ ToolView *tv = m_toolviews[firstWrong];
+
+ unsigned int pos = config->readUnsignedNumEntry (TQString ("Kate-MDI-ToolView-%1-Sidebar-Position").arg(tv->id), firstWrong);
+
+ if (pos != firstWrong)
+ break;
+ }
+
+ // we need to reshuffle, ahhh :(
+ if (firstWrong < m_toolviews.size())
+ {
+ // first: collect the items to reshuffle
+ TQValueList<TmpToolViewSorter> toSort;
+ for (unsigned int i=firstWrong; i < m_toolviews.size(); ++i)
+ {
+ TmpToolViewSorter s;
+ s.tv = m_toolviews[i];
+ s.pos = config->readUnsignedNumEntry (TQString ("Kate-MDI-ToolView-%1-Sidebar-Position").arg(m_toolviews[i]->id), i);
+ toSort.push_back (s);
+ }
+
+ // now: sort the stuff we need to reshuffle
+ for (unsigned int m=0; m < toSort.size(); ++m)
+ for (unsigned int n=m+1; n < toSort.size(); ++n)
+ if (toSort[n].pos < toSort[m].pos)
+ {
+ TmpToolViewSorter tmp = toSort[n];
+ toSort[n] = toSort[m];
+ toSort[m] = tmp;
+ }
+
+ // then: remove this items from the button bar
+ // do this backwards, to minimize the relayout efforts
+ for (int i=m_toolviews.size()-1; i >= (int)firstWrong; --i)
+ {
+ removeTab (m_widgetToId[m_toolviews[i]]);
+ }
+
+ // insert the reshuffled things in order :)
+ for (unsigned int i=0; i < toSort.size(); ++i)
+ {
+ ToolView *tv = toSort[i].tv;
+
+ m_toolviews[firstWrong+i] = tv;
+
+ // readd the button
+ int newId = m_widgetToId[tv];
+ appendTab (tv->icon, newId, tv->text);
+ connect(tab(newId),TQT_SIGNAL(clicked(int)),this,TQT_SLOT(tabClicked(int)));
+ tab(newId)->installEventFilter(this);
+
+ // reshuffle in splitter
+ m_ownSplit->moveToLast (tv);
+ }
+ }
+
+ // update last size if needed
+ updateLastSize ();
+
+ // restore the own splitter sizes
+ TQValueList<int> s = config->readIntListEntry (TQString ("Kate-MDI-Sidebar-%1-Splitter").arg(position()));
+ m_ownSplit->setSizes (s);
+
+ // show only correct toolviews, remember persistent values ;)
+ bool anyVis = false;
+ for ( unsigned int i=0; i < m_toolviews.size(); ++i )
+ {
+ ToolView *tv = m_toolviews[i];
+
+ tv->persistent = config->readBoolEntry (TQString ("Kate-MDI-ToolView-%1-Persistent").arg(tv->id), false);
+ tv->setVisible (config->readBoolEntry (TQString ("Kate-MDI-ToolView-%1-Visible").arg(tv->id), false));
+
+ if (!anyVis)
+ anyVis = tv->visible();
+
+ setTab (m_widgetToId[tv],tv->visible());
+
+ if (tv->visible())
+ tv->show();
+ else
+ tv->hide ();
+ }
+
+ if (anyVis)
+ m_ownSplit->show();
+ else
+ m_ownSplit->hide();
+}
+
+void Sidebar::saveSession (TDEConfig *config)
+{
+ // store the own splitter sizes
+ TQValueList<int> s = m_ownSplit->sizes();
+ config->writeEntry (TQString ("Kate-MDI-Sidebar-%1-Splitter").arg(position()), s);
+
+ // store the data about all toolviews in this sidebar ;)
+ for ( unsigned int i=0; i < m_toolviews.size(); ++i )
+ {
+ ToolView *tv = m_toolviews[i];
+
+ config->writeEntry (TQString ("Kate-MDI-ToolView-%1-Position").arg(tv->id), tv->sidebar()->position());
+ config->writeEntry (TQString ("Kate-MDI-ToolView-%1-Sidebar-Position").arg(tv->id), i);
+ config->writeEntry (TQString ("Kate-MDI-ToolView-%1-Visible").arg(tv->id), tv->visible());
+ config->writeEntry (TQString ("Kate-MDI-ToolView-%1-Persistent").arg(tv->id), tv->persistent);
+ }
+}
+
+//END SIDEBAR
+
+
+//BEGIN MAIN WINDOW
+
+MainWindow::MainWindow (TQWidget* parentWidget, const char* name)
+ : KParts::MainWindow( parentWidget, name)
+ , m_sidebarsVisible(true)
+ , m_restoreConfig (0)
+ , m_guiClient (new GUIClient (this))
+{
+ // init the internal widgets
+ TQHBox *hb = new TQHBox (this);
+ setCentralWidget(hb);
+
+ m_sidebars[KMultiTabBar::Left] = new Sidebar (KMultiTabBar::Left, this, hb);
+
+ m_hSplitter = new Splitter (Qt::Horizontal, hb);
+ m_hSplitter->setOpaqueResize( TDEGlobalSettings::opaqueResize() );
+
+ m_sidebars[KMultiTabBar::Left]->setSplitter (m_hSplitter);
+
+ TQVBox *vb = new TQVBox (m_hSplitter);
+ m_hSplitter->setCollapsible(vb, false);
+
+ m_sidebars[KMultiTabBar::Top] = new Sidebar (KMultiTabBar::Top, this, vb);
+
+ m_vSplitter = new Splitter (Qt::Vertical, vb);
+ m_vSplitter->setOpaqueResize( TDEGlobalSettings::opaqueResize() );
+
+ m_sidebars[KMultiTabBar::Top]->setSplitter (m_vSplitter);
+
+ m_centralWidget = new TQVBox (m_vSplitter);
+ m_vSplitter->setCollapsible(m_centralWidget, false);
+
+ m_sidebars[KMultiTabBar::Bottom] = new Sidebar (KMultiTabBar::Bottom, this, vb);
+ m_sidebars[KMultiTabBar::Bottom]->setSplitter (m_vSplitter);
+
+ m_sidebars[KMultiTabBar::Right] = new Sidebar (KMultiTabBar::Right, this, hb);
+ m_sidebars[KMultiTabBar::Right]->setSplitter (m_hSplitter);
+}
+
+MainWindow::~MainWindow ()
+{
+ // cu toolviews
+ while (!m_toolviews.isEmpty())
+ delete m_toolviews[0];
+
+ // seems like we really should delete this by hand ;)
+ delete m_centralWidget;
+
+ for (unsigned int i=0; i < 4; ++i)
+ delete m_sidebars[i];
+}
+
+TQWidget *MainWindow::centralWidget () const
+{
+ return m_centralWidget;
+}
+
+ToolView *MainWindow::createToolView (const TQString &identifier, KMultiTabBar::KMultiTabBarPosition pos, const TQPixmap &icon, const TQString &text)
+{
+ if (m_idToWidget[identifier])
+ return 0;
+
+ // try the restore config to figure out real pos
+ if (m_restoreConfig && m_restoreConfig->hasGroup (m_restoreGroup))
+ {
+ m_restoreConfig->setGroup (m_restoreGroup);
+ pos = (KMultiTabBar::KMultiTabBarPosition) m_restoreConfig->readNumEntry (TQString ("Kate-MDI-ToolView-%1-Position").arg(identifier), pos);
+ }
+
+ ToolView *v = m_sidebars[pos]->addWidget (icon, text, 0);
+ v->id = identifier;
+
+ m_idToWidget.insert (identifier, v);
+ m_toolviews.push_back (v);
+
+ // register for menu stuff
+ m_guiClient->registerToolView (v);
+
+ return v;
+}
+
+ToolView *MainWindow::toolView (const TQString &identifier) const
+{
+ return m_idToWidget[identifier];
+}
+
+void MainWindow::toolViewDeleted (ToolView *widget)
+{
+ if (!widget)
+ return;
+
+ if (widget->mainWindow() != this)
+ return;
+
+ // unregister from menu stuff
+ m_guiClient->unregisterToolView (widget);
+
+ widget->sidebar()->removeWidget (widget);
+
+ m_idToWidget.remove (widget->id);
+ m_toolviews.remove (widget);
+}
+
+void MainWindow::setSidebarsVisible( bool visible )
+{
+ m_sidebarsVisible = visible;
+
+ m_sidebars[0]->setShown(visible);
+ m_sidebars[1]->setShown(visible);
+ m_sidebars[2]->setShown(visible);
+ m_sidebars[3]->setShown(visible);
+
+ m_guiClient->updateSidebarsVisibleAction();
+
+ // show information message box, if the users hides the sidebars
+ if( !m_sidebarsVisible )
+ {
+ KMessageBox::information( this,
+ i18n("<qt>You are about to hide the sidebars. With "
+ "hidden sidebars it is not possible to directly "
+ "access the tool views with the mouse anymore, "
+ "so if you need to access the sidebars again "
+ "invoke <b>Window &gt; Tool Views &gt; Show Sidebars</b> "
+ "in the menu. It is still possible to show/hide "
+ "the tool views with the assigned shortcuts.</qt>"),
+ TQString::null, "Kate hide sidebars notification message" );
+ }
+}
+
+bool MainWindow::sidebarsVisible() const
+{
+ return m_sidebarsVisible;
+}
+
+void MainWindow::setToolViewStyle (KMultiTabBar::KMultiTabBarStyle style)
+{
+ m_sidebars[0]->setStyle(style);
+ m_sidebars[1]->setStyle(style);
+ m_sidebars[2]->setStyle(style);
+ m_sidebars[3]->setStyle(style);
+}
+
+KMultiTabBar::KMultiTabBarStyle MainWindow::toolViewStyle () const
+{
+ // all sidebars have the same style, so just take Top
+ return m_sidebars[KMultiTabBar::Top]->tabStyle();
+}
+
+bool MainWindow::moveToolView (ToolView *widget, KMultiTabBar::KMultiTabBarPosition pos)
+{
+ if (!widget || widget->mainWindow() != this)
+ return false;
+
+ // try the restore config to figure out real pos
+ if (m_restoreConfig && m_restoreConfig->hasGroup (m_restoreGroup))
+ {
+ m_restoreConfig->setGroup (m_restoreGroup);
+ pos = (KMultiTabBar::KMultiTabBarPosition) m_restoreConfig->readNumEntry (TQString ("Kate-MDI-ToolView-%1-Position").arg(widget->id), pos);
+ }
+
+ m_sidebars[pos]->addWidget (widget->icon, widget->text, widget);
+
+ return true;
+}
+
+bool MainWindow::showToolView (ToolView *widget)
+{
+ if (!widget || widget->mainWindow() != this)
+ return false;
+
+ // skip this if happens during restoring, or we will just see flicker
+ if (m_restoreConfig && m_restoreConfig->hasGroup (m_restoreGroup))
+ return true;
+
+ return widget->sidebar()->showWidget (widget);
+}
+
+bool MainWindow::hideToolView (ToolView *widget)
+{
+ if (!widget || widget->mainWindow() != this)
+ return false;
+
+ // skip this if happens during restoring, or we will just see flicker
+ if (m_restoreConfig && m_restoreConfig->hasGroup (m_restoreGroup))
+ return true;
+
+ return widget->sidebar()->hideWidget (widget);
+}
+
+void MainWindow::startRestore (TDEConfig *config, const TQString &group)
+{
+ // first save this stuff
+ m_restoreConfig = config;
+ m_restoreGroup = group;
+
+ if (!m_restoreConfig || !m_restoreConfig->hasGroup (m_restoreGroup))
+ {
+ // set sane default sizes
+ TQValueList<int> hs;
+ hs << 200 << 100 << 200;
+ TQValueList<int> vs;
+ vs << 150 << 100 << 200;
+
+ m_sidebars[0]->setLastSize (hs[0]);
+ m_sidebars[1]->setLastSize (hs[2]);
+ m_sidebars[2]->setLastSize (vs[0]);
+ m_sidebars[3]->setLastSize (vs[2]);
+
+ m_hSplitter->setSizes(hs);
+ m_vSplitter->setSizes(vs);
+ return;
+ }
+
+ // apply size once, to get sizes ready ;)
+ m_restoreConfig->setGroup (m_restoreGroup);
+ restoreWindowSize (m_restoreConfig);
+
+ m_restoreConfig->setGroup (m_restoreGroup);
+
+ // get main splitter sizes ;)
+ TQValueList<int> hs = m_restoreConfig->readIntListEntry ("Kate-MDI-H-Splitter");
+ TQValueList<int> vs = m_restoreConfig->readIntListEntry ("Kate-MDI-V-Splitter");
+
+ m_sidebars[0]->setLastSize (hs[0]);
+ m_sidebars[1]->setLastSize (hs[2]);
+ m_sidebars[2]->setLastSize (vs[0]);
+ m_sidebars[3]->setLastSize (vs[2]);
+
+ m_hSplitter->setSizes(hs);
+ m_vSplitter->setSizes(vs);
+
+ setToolViewStyle( (KMultiTabBar::KMultiTabBarStyle)m_restoreConfig->readNumEntry ("Kate-MDI-Sidebar-Style", (int)toolViewStyle()) );
+
+ // after reading m_sidebarsVisible, update the GUI toggle action
+ m_sidebarsVisible = m_restoreConfig->readBoolEntry ("Kate-MDI-Sidebar-Visible", true );
+ m_guiClient->updateSidebarsVisibleAction();
+}
+
+void MainWindow::finishRestore ()
+{
+ if (!m_restoreConfig)
+ return;
+
+ if (m_restoreConfig->hasGroup (m_restoreGroup))
+ {
+ // apply all settings, like toolbar pos and more ;)
+ applyMainWindowSettings(m_restoreConfig, m_restoreGroup);
+
+ // reshuffle toolviews only if needed
+ m_restoreConfig->setGroup (m_restoreGroup);
+ for ( unsigned int i=0; i < m_toolviews.size(); ++i )
+ {
+ KMultiTabBar::KMultiTabBarPosition newPos = (KMultiTabBar::KMultiTabBarPosition) m_restoreConfig->readNumEntry (TQString ("Kate-MDI-ToolView-%1-Position").arg(m_toolviews[i]->id), m_toolviews[i]->sidebar()->position());
+
+ if (m_toolviews[i]->sidebar()->position() != newPos)
+ {
+ moveToolView (m_toolviews[i], newPos);
+ }
+ }
+
+ // restore the sidebars
+ m_restoreConfig->setGroup (m_restoreGroup);
+ for (unsigned int i=0; i < 4; ++i)
+ m_sidebars[i]->restoreSession (m_restoreConfig);
+ }
+
+ // clear this stuff, we are done ;)
+ m_restoreConfig = 0;
+ m_restoreGroup = "";
+}
+
+void MainWindow::saveSession (TDEConfig *config, const TQString &group)
+{
+ if (!config)
+ return;
+
+ saveMainWindowSettings (config, group);
+
+ config->setGroup (group);
+
+ // save main splitter sizes ;)
+ TQValueList<int> hs = m_hSplitter->sizes();
+ TQValueList<int> vs = m_vSplitter->sizes();
+
+ if (hs[0] <= 2 && !m_sidebars[0]->splitterVisible ())
+ hs[0] = m_sidebars[0]->lastSize();
+ if (hs[2] <= 2 && !m_sidebars[1]->splitterVisible ())
+ hs[2] = m_sidebars[1]->lastSize();
+ if (vs[0] <= 2 && !m_sidebars[2]->splitterVisible ())
+ vs[0] = m_sidebars[2]->lastSize();
+ if (vs[2] <= 2 && !m_sidebars[3]->splitterVisible ())
+ vs[2] = m_sidebars[3]->lastSize();
+
+ config->writeEntry ("Kate-MDI-H-Splitter", hs);
+ config->writeEntry ("Kate-MDI-V-Splitter", vs);
+
+ // save sidebar style
+ config->writeEntry ("Kate-MDI-Sidebar-Style", (int)toolViewStyle());
+ config->writeEntry ("Kate-MDI-Sidebar-Visible", m_sidebarsVisible );
+
+ // save the sidebars
+ for (unsigned int i=0; i < 4; ++i)
+ m_sidebars[i]->saveSession (config);
+}
+
+//END MAIN WINDOW
+
+} // namespace KateMDI
+
+// kate: space-indent on; indent-width 2;
diff --git a/kate/app/katemdi.h b/kate/app/katemdi.h
new file mode 100644
index 000000000..a291ebb8c
--- /dev/null
+++ b/kate/app/katemdi.h
@@ -0,0 +1,448 @@
+/* This file is part of the KDE libraries
+ Copyright (C) 2005 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2002, 2003 Joseph Wenninger <jowenn@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __KATE_MDI_H__
+#define __KATE_MDI_H__
+
+#include <tdeparts/mainwindow.h>
+
+#include <tdemultitabbar.h>
+#include <kxmlguiclient.h>
+#include <tdeaction.h>
+
+#include <tqdict.h>
+#include <tqintdict.h>
+#include <tqmap.h>
+#include <tqsplitter.h>
+#include <tqpixmap.h>
+#include <tqptrlist.h>
+
+namespace KateMDI {
+
+
+/** This class is needed because TQSplitter cant return an index for a widget. */
+class Splitter : public TQSplitter
+{
+ Q_OBJECT
+
+
+ public:
+ Splitter(Orientation o, TQWidget* parent=0, const char* name=0);
+ ~Splitter();
+
+ /** Since there is supposed to be only 2 childs of a katesplitter,
+ * any child other than the last is the first.
+ * This method uses TQSplitter::idAfter(widget) which
+ * returns 0 if there is no widget after this one.
+ * This results in an error if widget is not a child
+ * in this splitter */
+ bool isLastChild(TQWidget* w) const;
+
+ int idAfter ( TQWidget * w ) const;
+};
+
+class ToggleToolViewAction : public TDEToggleAction
+{
+ Q_OBJECT
+
+
+ public:
+ ToggleToolViewAction ( const TQString& text, const TDEShortcut& cut,
+ class ToolView *tv, TQObject* parent = 0, const char* name = 0 );
+
+ virtual ~ToggleToolViewAction();
+
+ protected slots:
+ void slotToggled(bool);
+ void visibleChanged(bool);
+
+ private:
+ ToolView *m_tv;
+};
+
+class GUIClient : public TQObject, public KXMLGUIClient
+{
+ Q_OBJECT
+
+
+ public:
+ GUIClient ( class MainWindow *mw );
+ virtual ~GUIClient();
+
+ void registerToolView (ToolView *tv);
+ void unregisterToolView (ToolView *tv);
+ void updateSidebarsVisibleAction();
+
+ private slots:
+ void clientAdded( KXMLGUIClient *client );
+ void updateActions();
+
+ private:
+ MainWindow *m_mw;
+ TDEToggleAction *m_showSidebarsAction;
+ TQPtrList<TDEAction> m_toolViewActions;
+ TQMap<ToolView*, TDEAction*> m_toolToAction;
+ TDEActionMenu *m_toolMenu;
+};
+
+class ToolView : public TQVBox
+{
+ Q_OBJECT
+
+
+ friend class Sidebar;
+ friend class MainWindow;
+ friend class GUIClient;
+ friend class ToggleToolViewAction;
+
+ protected:
+ /**
+ * ToolView
+ * Objects of this clas represent a toolview in the mainwindow
+ * you should only add one widget as child to this toolview, it will
+ * be automatically set to be the focus proxy of the toolview
+ * @param mainwin main window for this toolview
+ * @param sidebar sidebar of this toolview
+ * @param parent parent widget, e.g. the splitter of one of the sidebars
+ */
+ ToolView (class MainWindow *mainwin, class Sidebar *sidebar, TQWidget *parent);
+
+ public:
+ /**
+ * destuct me, this is allowed for all, will care itself that the toolview is removed
+ * from the mainwindow and sidebar
+ */
+ virtual ~ToolView ();
+
+ signals:
+ /**
+ * toolview hidden or shown
+ * @param bool is this toolview made visible?
+ */
+ void visibleChanged (bool visible);
+
+ /**
+ * some internal methodes needed by the main window and the sidebars
+ */
+ protected:
+ MainWindow *mainWindow () { return m_mainWin; }
+
+ Sidebar *sidebar () { return m_sidebar; }
+
+ void setVisible (bool vis);
+
+ public:
+ bool visible () const;
+
+ protected:
+ void childEvent ( TQChildEvent *ev );
+
+ private:
+ MainWindow *m_mainWin;
+ Sidebar *m_sidebar;
+
+ /**
+ * unique id
+ */
+ TQString id;
+
+ /**
+ * is visible in sidebar
+ */
+ bool m_visible;
+
+ /**
+ * is this view persistent?
+ */
+ bool persistent;
+
+ TQPixmap icon;
+ TQString text;
+};
+
+class Sidebar : public KMultiTabBar
+{
+ Q_OBJECT
+
+
+ public:
+ Sidebar (KMultiTabBar::KMultiTabBarPosition pos, class MainWindow *mainwin, TQWidget *parent);
+ virtual ~Sidebar ();
+
+ void setSplitter (Splitter *sp);
+
+ public:
+ ToolView *addWidget (const TQPixmap &icon, const TQString &text, ToolView *widget);
+ bool removeWidget (ToolView *widget);
+
+ bool showWidget (ToolView *widget);
+ bool hideWidget (ToolView *widget);
+
+ void setLastSize (int s) { m_lastSize = s; }
+ int lastSize () const { return m_lastSize; }
+ void updateLastSize ();
+
+ bool splitterVisible () const { return m_ownSplit->isVisible(); }
+
+ void restoreSession ();
+
+ /**
+ * restore the current session config from given object, use current group
+ * @param config config object to use
+ */
+ void restoreSession (TDEConfig *config);
+
+ /**
+ * save the current session config to given object, use current group
+ * @param config config object to use
+ */
+ void saveSession (TDEConfig *config);
+
+ public slots:
+ // reimplemented, to block a show() call if we have no children or if
+ // all sidebars are forced hidden.
+ virtual void show();
+
+ private slots:
+ void tabClicked(int);
+
+ protected:
+ bool eventFilter(TQObject *obj, TQEvent *ev);
+
+ private slots:
+ void buttonPopupActivate (int id);
+
+ private:
+ MainWindow *m_mainWin;
+
+ KMultiTabBar::KMultiTabBarPosition m_pos;
+ Splitter *m_splitter;
+ KMultiTabBar *m_tabBar;
+ Splitter *m_ownSplit;
+
+ TQIntDict<ToolView> m_idToWidget;
+ TQMap<ToolView*, int> m_widgetToId;
+
+ /**
+ * list of all toolviews around in this sidebar
+ */
+ TQValueList<ToolView*> m_toolviews;
+
+ int m_lastSize;
+
+ int m_popupButton;
+};
+
+class MainWindow : public KParts::MainWindow
+{
+ Q_OBJECT
+
+
+ friend class ToolView;
+
+ //
+ // Constructor area
+ //
+ public:
+ /**
+ * Constructor
+ */
+ MainWindow (TQWidget* parentWidget = 0, const char* name = 0);
+
+ /**
+ * Destructor
+ */
+ virtual ~MainWindow ();
+
+ //
+ // public interfaces
+ //
+ public:
+ /**
+ * central widget ;)
+ * use this as parent for your content
+ * this widget will get focus if a toolview is hidden
+ * @return central widget
+ */
+ TQWidget *centralWidget () const;
+
+ /**
+ * add a given widget to the given sidebar if possible, name is very important
+ * @param identifier unique identifier for this toolview
+ * @param pos position for the toolview, if we are in session restore, this is only a preference
+ * @param icon icon to use for the toolview
+ * @param text text to use in addition to icon
+ * @return created toolview on success or 0
+ */
+ ToolView *createToolView (const TQString &identifier, KMultiTabBar::KMultiTabBarPosition pos, const TQPixmap &icon, const TQString &text);
+
+ /**
+ * give you handle to toolview for the given name, 0 if no toolview around
+ * @param identifier toolview name
+ * @return toolview if existing, else 0
+ */
+ ToolView *toolView (const TQString &identifier) const;
+
+ /**
+ * set the toolview's tabbar style.
+ * @param style the tabbar style.
+ */
+ void setToolViewStyle (KMultiTabBar::KMultiTabBarStyle style);
+
+ /**
+ * get the toolview's tabbar style. Call this before @p startRestore(),
+ * otherwise you overwrite the usersettings.
+ * @return toolview's tabbar style
+ */
+ KMultiTabBar::KMultiTabBarStyle toolViewStyle () const;
+
+ /**
+ * get the sidebars' visibility.
+ * @return false, if the sidebars' visibility is forced hidden, otherwise true
+ */
+ bool sidebarsVisible() const;
+
+ public slots:
+ /**
+ * set the sidebars' visibility to @p visible. If false, the sidebars
+ * are @e always hidden. Usually you do not have to call this because
+ * the user can set this in the menu.
+ * @param visible sidebars visibility
+ */
+ void setSidebarsVisible( bool visible );
+
+ protected:
+ /**
+ * called by toolview destructor
+ * @param widget toolview which is destroyed
+ */
+ void toolViewDeleted (ToolView *widget);
+
+ /**
+ * modifiers for existing toolviews
+ */
+ public:
+ /**
+ * move a toolview around
+ * @param widget toolview to move
+ * @param pos position to move too, during session restore, only preference
+ * @return success
+ */
+ bool moveToolView (ToolView *widget, KMultiTabBar::KMultiTabBarPosition pos);
+
+ /**
+ * show given toolview, discarded while session restore
+ * @param widget toolview to show
+ * @return success
+ */
+ bool showToolView (ToolView *widget);
+
+ /**
+ * hide given toolview, discarded while session restore
+ * @param widget toolview to hide
+ * @return success
+ */
+ bool hideToolView (ToolView *widget);
+
+ /**
+ * session saving and restore stuff
+ */
+ public:
+ /**
+ * start the restore
+ * @param config config object to use
+ * @param group config group to use
+ */
+ void startRestore (TDEConfig *config, const TQString &group);
+
+ /**
+ * finish the restore
+ */
+ void finishRestore ();
+
+ /**
+ * save the current session config to given object and group
+ * @param config config object to use
+ * @param group config group to use
+ */
+ void saveSession (TDEConfig *config, const TQString &group);
+
+ /**
+ * internal data ;)
+ */
+ private:
+ /**
+ * map identifiers to widgets
+ */
+ TQDict<ToolView> m_idToWidget;
+
+ /**
+ * list of all toolviews around
+ */
+ TQValueList<ToolView*> m_toolviews;
+
+ /**
+ * widget, which is the central part of the
+ * main window ;)
+ */
+ TQWidget *m_centralWidget;
+
+ /**
+ * horizontal splitter
+ */
+ Splitter *m_hSplitter;
+
+ /**
+ * vertical splitter
+ */
+ Splitter *m_vSplitter;
+
+ /**
+ * sidebars for the four sides
+ */
+ Sidebar *m_sidebars[4];
+
+ /**
+ * sidebars state.
+ */
+ bool m_sidebarsVisible;
+
+ /**
+ * config object for session restore, only valid between
+ * start and finish restore calls
+ */
+ TDEConfig *m_restoreConfig;
+
+ /**
+ * restore group
+ */
+ TQString m_restoreGroup;
+
+ /**
+ * out guiclient
+ */
+ GUIClient *m_guiClient;
+};
+
+}
+
+#endif
+
+// kate: space-indent on; indent-width 2;
diff --git a/kate/app/katemwmodonhddialog.cpp b/kate/app/katemwmodonhddialog.cpp
new file mode 100644
index 000000000..ab1418477
--- /dev/null
+++ b/kate/app/katemwmodonhddialog.cpp
@@ -0,0 +1,281 @@
+/*
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+ ---
+ Copyright (C) 2004, Anders Lund <anders@alweb.dk>
+*/
+
+#include "katemwmodonhddialog.h"
+#include "katemwmodonhddialog.moc"
+
+#include "katedocmanager.h"
+
+#include <kate/document.h>
+
+#include <kiconloader.h>
+#include <tdelistview.h>
+#include <tdelocale.h>
+#include <tdemessagebox.h>
+#include <kprocio.h>
+#include <krun.h>
+#include <tdetempfile.h>
+#include <kpushbutton.h>
+
+#include <tqlabel.h>
+#include <tqlistview.h>
+#include <tqlayout.h>
+#include <tqpushbutton.h>
+#include <tqwhatsthis.h>
+#include <tqvbox.h>
+
+class KateDocItem : public TQCheckListItem
+{
+ public:
+ KateDocItem( Kate::Document *doc, const TQString &status, TDEListView *lv )
+ : TQCheckListItem( lv, doc->url().prettyURL(), CheckBox ),
+ document( doc )
+ {
+ setText( 1, status );
+ if ( ! doc->isModified() )
+ setOn( On );
+ }
+ ~KateDocItem() {};
+
+ Kate::Document *document;
+};
+
+
+KateMwModOnHdDialog::KateMwModOnHdDialog( DocVector docs, TQWidget *parent, const char *name )
+ : KDialogBase( parent, name, true, i18n("Documents Modified on Disk"),
+ User1|User2|User3, User3, false,
+ KGuiItem (i18n("&Ignore"), "fileclose"),
+ KGuiItem (i18n("&Overwrite"), "filesave"),
+ KGuiItem (i18n("&Reload"), "reload") )
+{
+ setButtonWhatsThis( User1, i18n(
+ "Removes the modified flag from the selected documents and closes the "
+ "dialog if there are no more unhandled documents.") );
+ setButtonWhatsThis( User2, i18n(
+ "Overwrite selected documents, discarding the disk changes and closes the "
+ "dialog if there are no more unhandled documents.") );
+ setButtonWhatsThis( User3, i18n(
+ "Reloads the selected documents from disk and closes the dialog if there "
+ "are no more unhandled documents.") );
+
+ TQVBox *w = makeVBoxMainWidget();
+ w->setSpacing( KDialog::spacingHint() );
+
+ TQHBox *lo1 = new TQHBox( w );
+
+ // dialog text
+ TQLabel *icon = new TQLabel( lo1 );
+ icon->setPixmap( DesktopIcon("messagebox_warning") );
+
+ TQLabel *t = new TQLabel( i18n(
+ "<qt>The documents listed below has changed on disk.<p>Select one "
+ "or more at the time and press an action button until the list is empty.</qt>"), lo1 );
+ lo1->setStretchFactor( t, 1000 );
+
+ // document list
+ lvDocuments = new TDEListView( w );
+ lvDocuments->addColumn( i18n("Filename") );
+ lvDocuments->addColumn( i18n("Status on Disk") );
+ lvDocuments->setSelectionMode( TQListView::Single );
+
+ TQStringList l;
+ l << "" << i18n("Modified") << i18n("Created") << i18n("Deleted");
+ for ( uint i=0; i < docs.size(); i++ )
+ new KateDocItem( docs[i], l[ (uint)KateDocManager::self()->documentInfo( docs[i] )->modifiedOnDiscReason ], lvDocuments );
+
+ connect( lvDocuments, TQT_SIGNAL(selectionChanged()), this, TQT_SLOT(slotSelectionChanged()) );
+
+ // diff button
+ TQHBox *lo2 = new TQHBox ( w );
+ TQWidget *d = new TQWidget (lo2);
+ lo2->setStretchFactor (d, 2);
+ btnDiff = new KPushButton( KGuiItem (i18n("&View Difference"), "edit"), lo2 );
+
+ TQWhatsThis::add( btnDiff, i18n(
+ "Calculates the difference between the the editor contents and the disk "
+ "file for the selected document, and shows the difference with the "
+ "default application. Requires diff(1).") );
+ connect( btnDiff, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotDiff()) );
+
+ slotSelectionChanged();
+ m_tmpfile = 0;
+}
+
+KateMwModOnHdDialog::~KateMwModOnHdDialog()
+{
+}
+
+void KateMwModOnHdDialog::slotUser1()
+{
+ handleSelected( Ignore );
+}
+
+void KateMwModOnHdDialog::slotUser2()
+{
+ handleSelected( Overwrite );
+}
+
+void KateMwModOnHdDialog::slotUser3()
+{
+ handleSelected( Reload );
+}
+
+void KateMwModOnHdDialog::handleSelected( int action )
+{
+ // collect all items we can remove
+ TQValueList<TQListViewItem *> itemsToDelete;
+ for ( TQListViewItemIterator it ( lvDocuments ); it.current(); ++it )
+ {
+ KateDocItem *item = static_cast<KateDocItem *>(it.current());
+
+ if ( item->isOn() )
+ {
+ int reason = (int)KateDocManager::self()->documentInfo( item->document )->modifiedOnDiscReason;
+ bool succes = true;
+
+ Kate::DocumentExt *dext = documentExt( item->document );
+ if ( ! dext ) continue;
+
+ dext->setModifiedOnDisk( 0 );
+ switch ( action )
+ {
+ case Overwrite:
+ succes = item->document->save();
+ if ( ! succes )
+ {
+ KMessageBox::sorry( this,
+ i18n("Could not save the document \n'%1'").
+ arg( item->document->url().prettyURL() ) );
+ }
+ break;
+
+ case Reload:
+ item->document->reloadFile();
+ break;
+
+ default:
+ break;
+ }
+
+ if ( succes )
+ itemsToDelete.append (item);
+ else
+ dext->setModifiedOnDisk( reason );
+ }
+ }
+
+ // remove the marked items
+ for (unsigned int i=0; i < itemsToDelete.count(); ++i)
+ delete itemsToDelete[i];
+
+ // any documents left unhandled?
+ if ( ! lvDocuments->childCount() )
+ done( Ok );
+}
+
+void KateMwModOnHdDialog::slotSelectionChanged()
+{
+ // set the diff button enabled
+ btnDiff->setEnabled( lvDocuments->currentItem() &&
+ KateDocManager::self()->documentInfo( ((KateDocItem*)lvDocuments->currentItem())->document )->modifiedOnDiscReason != 3 );
+}
+
+// ### the code below is slightly modified from tdelibs/kate/part/katedialogs,
+// class KateModOnHdPrompt.
+void KateMwModOnHdDialog::slotDiff()
+{
+ if ( m_tmpfile ) // we are allready somewhere in this process.
+ return;
+
+ if ( ! lvDocuments->currentItem() )
+ return;
+
+ Kate::Document *doc = ((KateDocItem*)lvDocuments->currentItem())->document;
+
+ // don't try o diff a deleted file
+ if ( KateDocManager::self()->documentInfo( doc )->modifiedOnDiscReason == 3 )
+ return;
+
+ // Start a TDEProcess that creates a diff
+ KProcIO *p = new KProcIO();
+ p->setComm( TDEProcess::All );
+ *p << "diff" << "-u" << "-" << doc->url().path();
+ connect( p, TQT_SIGNAL(processExited(TDEProcess*)), this, TQT_SLOT(slotPDone(TDEProcess*)) );
+ connect( p, TQT_SIGNAL(readReady(KProcIO*)), this, TQT_SLOT(slotPRead(KProcIO*)) );
+
+ setCursor( WaitCursor );
+
+ p->start( TDEProcess::NotifyOnExit, true );
+
+ uint lastln = doc->numLines();
+ for ( uint l = 0; l < lastln; l++ )
+ p->writeStdin( doc->textLine( l ), l < lastln );
+
+ p->closeWhenDone();
+}
+
+void KateMwModOnHdDialog::slotPRead( KProcIO *p)
+{
+ // create a file for the diff if we haven't one allready
+ if ( ! m_tmpfile )
+ m_tmpfile = new KTempFile();
+ // put all the data we have in it
+ TQString stmp;
+ bool dataRead = false;
+ while ( p->readln( stmp, false ) > -1 ) {
+ *m_tmpfile->textStream() << stmp << endl;
+ dataRead = true;
+ }
+
+ if (dataRead)
+ p->ackRead();
+}
+
+void KateMwModOnHdDialog::slotPDone( TDEProcess *p )
+{
+ setCursor( ArrowCursor );
+ if( ! m_tmpfile )
+ {
+ // dominik: there were only whitespace changes, so that the diff returned by
+ // diff(1) has 0 bytes. So slotPRead() is never called, as there is
+ // no data, so that m_tmpfile was never created and thus is NULL.
+ // NOTE: would be nice, if we could produce a fake-diff, so that kompare
+ // tells us "The files are identical". Right now, we get an ugly
+ // "Could not parse diff output".
+ m_tmpfile = new KTempFile();
+ }
+ m_tmpfile->close();
+
+ if ( ! p->normalExit() /*|| p->exitStatus()*/ )
+ {
+ KMessageBox::sorry( this,
+ i18n("The diff command failed. Please make sure that "
+ "diff(1) is installed and in your PATH."),
+ i18n("Error Creating Diff") );
+ delete m_tmpfile;
+ m_tmpfile = 0;
+ return;
+ }
+
+ KRun::runURL( m_tmpfile->name(), "text/x-diff", true );
+ delete m_tmpfile;
+ m_tmpfile = 0;
+}
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/katemwmodonhddialog.h b/kate/app/katemwmodonhddialog.h
new file mode 100644
index 000000000..3ae4d072a
--- /dev/null
+++ b/kate/app/katemwmodonhddialog.h
@@ -0,0 +1,61 @@
+/*
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+ ---
+ Copyright (C) 2004, Anders Lund <anders@alweb.dk>
+*/
+
+#ifndef _KATE_MW_MODONHD_DIALOG_H_
+#define _KATE_MW_MODONHD_DIALOG_H_
+
+#include <kdialogbase.h>
+#include <tqptrvector.h>
+#include <kate/document.h>
+
+typedef TQPtrVector<Kate::Document> DocVector;
+class KProcIO;
+class TDEProcess;
+/**
+ * A dialog for handling multiple documents modified on disk
+ * from within KateMainWindow
+ */
+class KateMwModOnHdDialog : public KDialogBase
+{
+ Q_OBJECT
+ public:
+ KateMwModOnHdDialog( DocVector docs, TQWidget *parent=0, const char *name=0 );
+ ~KateMwModOnHdDialog();
+
+ protected slots:
+ void slotUser1();
+ void slotUser2();
+ void slotUser3();
+
+ private slots:
+ void slotDiff();
+ void slotSelectionChanged();
+ void slotPRead(KProcIO*);
+ void slotPDone(TDEProcess*);
+
+ private:
+ enum Action { Ignore, Overwrite, Reload };
+ void handleSelected( int action );
+ class TDEListView *lvDocuments;
+ class TQPushButton *btnDiff;
+ class KTempFile *m_tmpfile;
+};
+
+#endif // _KATE_MW_MODONHD_DIALOG_H_
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/katepluginmanager.cpp b/kate/app/katepluginmanager.cpp
new file mode 100644
index 000000000..3e0a93f69
--- /dev/null
+++ b/kate/app/katepluginmanager.cpp
@@ -0,0 +1,220 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
+ Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "katepluginmanager.h"
+#include "katepluginmanager.moc"
+
+#include "kateapp.h"
+#include "katemainwindow.h"
+
+#include "../interfaces/application.h"
+
+#include <tdeconfig.h>
+#include <tqstringlist.h>
+#include <tdemessagebox.h>
+#include <kdebug.h>
+#include <tqfile.h>
+
+KatePluginManager::KatePluginManager(TQObject *parent) : TQObject (parent)
+{
+ m_pluginManager = new Kate::PluginManager (this);
+ setupPluginList ();
+
+ loadConfig ();
+ loadAllEnabledPlugins ();
+}
+
+KatePluginManager::~KatePluginManager()
+{
+ // first write config
+ writeConfig ();
+
+ // than unload the plugins
+ unloadAllPlugins ();
+}
+
+KatePluginManager *KatePluginManager::self()
+{
+ return KateApp::self()->pluginManager ();
+}
+
+void KatePluginManager::setupPluginList ()
+{
+ TQValueList<KService::Ptr> traderList= TDETrader::self()->query("Kate/Plugin", "(not ('Kate/ProjectPlugin' in ServiceTypes)) and (not ('Kate/InitPlugin' in ServiceTypes))");
+
+ for(TDETrader::OfferList::Iterator it(traderList.begin()); it != traderList.end(); ++it)
+ {
+ KService::Ptr ptr = (*it);
+
+ TQString pVersion = ptr->property("X-Kate-Version").toString();
+
+ if (pVersion == "2.5")
+ {
+ KatePluginInfo info;
+
+ info.load = false;
+ info.service = ptr;
+ info.plugin = 0L;
+
+ m_pluginList.push_back (info);
+ }
+ }
+}
+
+void KatePluginManager::loadConfig ()
+{
+ KateApp::self()->config()->setGroup("Kate Plugins");
+
+ for (unsigned int i=0; i < m_pluginList.size(); ++i)
+ m_pluginList[i].load = KateApp::self()->config()->readBoolEntry (m_pluginList[i].service->library(), false) ||
+ KateApp::self()->config()->readBoolEntry (m_pluginList[i].service->property("X-Kate-PluginName").toString(),false);
+}
+
+void KatePluginManager::writeConfig ()
+{
+ KateApp::self()->config()->setGroup("Kate Plugins");
+
+ for (unsigned int i=0; i < m_pluginList.size(); ++i)
+ {
+ TQString saveName=m_pluginList[i].service->property("X-Kate-PluginName").toString();
+
+ if (saveName.isEmpty())
+ saveName = m_pluginList[i].service->library();
+
+ KateApp::self()->config()->writeEntry (saveName, m_pluginList[i].load);
+ }
+}
+
+void KatePluginManager::loadAllEnabledPlugins ()
+{
+ for (unsigned int i=0; i < m_pluginList.size(); ++i)
+ {
+ if (m_pluginList[i].load)
+ loadPlugin (&m_pluginList[i]);
+ else
+ unloadPlugin (&m_pluginList[i]);
+ }
+}
+
+void KatePluginManager::unloadAllPlugins ()
+{
+ for (unsigned int i=0; i < m_pluginList.size(); ++i)
+ {
+ if (m_pluginList[i].plugin)
+ unloadPlugin (&m_pluginList[i]);
+ }
+}
+
+void KatePluginManager::enableAllPluginsGUI (KateMainWindow *win)
+{
+ for (unsigned int i=0; i < m_pluginList.size(); ++i)
+ {
+ if (m_pluginList[i].load)
+ enablePluginGUI (&m_pluginList[i], win);
+ }
+}
+
+void KatePluginManager::disableAllPluginsGUI (KateMainWindow *win)
+{
+ for (unsigned int i=0; i < m_pluginList.size(); ++i)
+ {
+ if (m_pluginList[i].load)
+ disablePluginGUI (&m_pluginList[i], win);
+ }
+}
+
+void KatePluginManager::loadPlugin (KatePluginInfo *item)
+{
+ TQString pluginName=item->service->property("X-Kate-PluginName").toString();
+
+ if (pluginName.isEmpty())
+ pluginName=item->service->library();
+
+ item->load = (item->plugin = Kate::createPlugin (TQFile::encodeName(item->service->library()), Kate::application(), 0, pluginName));
+}
+
+void KatePluginManager::unloadPlugin (KatePluginInfo *item)
+{
+ disablePluginGUI (item);
+ if (item->plugin) delete item->plugin;
+ item->plugin = 0L;
+ item->load = false;
+}
+
+void KatePluginManager::enablePluginGUI (KatePluginInfo *item, KateMainWindow *win)
+{
+ if (!item->plugin) return;
+ if (!Kate::pluginViewInterface(item->plugin)) return;
+
+ Kate::pluginViewInterface(item->plugin)->addView(win->mainWindow());
+}
+
+void KatePluginManager::enablePluginGUI (KatePluginInfo *item)
+{
+ if (!item->plugin) return;
+ if (!Kate::pluginViewInterface(item->plugin)) return;
+
+ for (uint i=0; i< KateApp::self()->mainWindows(); i++)
+ {
+ Kate::pluginViewInterface(item->plugin)->addView(KateApp::self()->mainWindow(i)->mainWindow());
+ }
+}
+
+void KatePluginManager::disablePluginGUI (KatePluginInfo *item, KateMainWindow *win)
+{
+ if (!item->plugin) return;
+ if (!Kate::pluginViewInterface(item->plugin)) return;
+
+ Kate::pluginViewInterface(item->plugin)->removeView(win->mainWindow());
+}
+
+void KatePluginManager::disablePluginGUI (KatePluginInfo *item)
+{
+ if (!item->plugin) return;
+ if (!Kate::pluginViewInterface(item->plugin)) return;
+
+ for (uint i=0; i< KateApp::self()->mainWindows(); i++)
+ {
+ Kate::pluginViewInterface(item->plugin)->removeView(KateApp::self()->mainWindow(i)->mainWindow());
+ }
+}
+
+Kate::Plugin *KatePluginManager::plugin(const TQString &name)
+{
+ for (unsigned int i=0; i < m_pluginList.size(); ++i)
+ {
+ KatePluginInfo *info = &m_pluginList[i];
+ TQString pluginName=info->service->property("X-Kate-PluginName").toString();
+ if (pluginName.isEmpty())
+ pluginName=info->service->library();
+ if (pluginName==name)
+ {
+ if (info->plugin)
+ return info->plugin;
+ else
+ break;
+ }
+ }
+ return 0;
+}
+
+bool KatePluginManager::pluginAvailable(const TQString &){return false;}
+class Kate::Plugin *KatePluginManager::loadPlugin(const TQString &,bool ){return 0;}
+void KatePluginManager::unloadPlugin(const TQString &,bool){;}
diff --git a/kate/app/katepluginmanager.h b/kate/app/katepluginmanager.h
new file mode 100644
index 000000000..1617c5501
--- /dev/null
+++ b/kate/app/katepluginmanager.h
@@ -0,0 +1,90 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
+ Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __KATE_PLUGINMANAGER_H__
+#define __KATE_PLUGINMANAGER_H__
+
+#include "katemain.h"
+
+#include "../interfaces/plugin.h"
+#include "../interfaces/pluginmanager.h"
+
+#include <ktrader.h>
+
+#include <tqobject.h>
+#include <tqvaluelist.h>
+
+class KatePluginInfo
+{
+ public:
+ bool load;
+ KService::Ptr service;
+ Kate::Plugin *plugin;
+};
+
+typedef TQValueList<KatePluginInfo> KatePluginList;
+
+class KatePluginManager : public TQObject
+{
+ Q_OBJECT
+
+ public:
+ KatePluginManager(TQObject *parent);
+ ~KatePluginManager();
+
+ static KatePluginManager *self();
+
+ Kate::PluginManager *pluginManager () const { return m_pluginManager; };
+
+ void loadAllEnabledPlugins ();
+ void unloadAllPlugins ();
+
+ void enableAllPluginsGUI (KateMainWindow *win);
+ void disableAllPluginsGUI (KateMainWindow *win);
+
+ void loadConfig ();
+ void writeConfig ();
+
+ void loadPlugin (KatePluginInfo *item);
+ void unloadPlugin (KatePluginInfo *item);
+
+ void enablePluginGUI (KatePluginInfo *item, KateMainWindow *win);
+ void enablePluginGUI (KatePluginInfo *item);
+
+ void disablePluginGUI (KatePluginInfo *item, KateMainWindow *win);
+ void disablePluginGUI (KatePluginInfo *item);
+
+ inline KatePluginList & pluginList () { return m_pluginList; };
+
+ Kate::Plugin *plugin (const TQString &name);
+ bool pluginAvailable (const TQString &name);
+
+ Kate::Plugin *loadPlugin (const TQString &name, bool permanent=true);
+ void unloadPlugin (const TQString &name, bool permanent=true);
+
+ private:
+ Kate::PluginManager *m_pluginManager;
+
+ void setupPluginList ();
+
+ KatePluginList m_pluginList;
+};
+
+#endif
diff --git a/kate/app/katesavemodifieddialog.cpp b/kate/app/katesavemodifieddialog.cpp
new file mode 100644
index 000000000..a89fe57f8
--- /dev/null
+++ b/kate/app/katesavemodifieddialog.cpp
@@ -0,0 +1,226 @@
+/* This file is part of the KDE project
+ Copyright (C) 2004 Joseph Wenninger <jowenn@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "katesavemodifieddialog.h"
+#include "katesavemodifieddialog.moc"
+
+#include <tdelocale.h>
+#include <tqlistview.h>
+#include <tdelistview.h>
+#include <kguiitem.h>
+#include <kactivelabel.h>
+#include <kstdguiitem.h>
+#include <tqvbox.h>
+#include <tqlabel.h>
+#include <tqpushbutton.h>
+#include <kiconloader.h>
+#include <tdemessagebox.h>
+#include <kdebug.h>
+#include <kencodingfiledialog.h>
+#include <tdetexteditor/encodinginterface.h>
+
+class AbstractKateSaveModifiedDialogCheckListItem:public TQCheckListItem {
+public:
+ AbstractKateSaveModifiedDialogCheckListItem(TQListViewItem *parent,const TQString& title, const TQString& url):TQCheckListItem(parent,title,TQCheckListItem::CheckBox) {
+ setText(1,url);
+ setOn(true);
+ setState(InitialState);
+ }
+ virtual ~AbstractKateSaveModifiedDialogCheckListItem() {
+ }
+ virtual bool synchronousSave(TQWidget *dialogParent)=0;
+ enum STATE{InitialState,SaveOKState,SaveFailedState};
+ STATE state() const { return m_state;}
+ void setState(enum STATE state) {
+ m_state=state;
+ TDEIconLoader *loader = TDEGlobal::instance()->iconLoader();
+ switch (state) {
+ case InitialState:
+ setPixmap(0,TQPixmap());
+ break;
+ case SaveOKState:
+ setPixmap(0,loader->loadIcon("ok",TDEIcon::NoGroup,height()));
+ break;
+ case SaveFailedState:
+ setPixmap(0,loader->loadIcon("cancel",TDEIcon::NoGroup,height()));
+ break;
+ }
+ }
+private:
+ STATE m_state;
+};
+
+class KateSaveModifiedDocumentCheckListItem:public AbstractKateSaveModifiedDialogCheckListItem {
+public:
+ KateSaveModifiedDocumentCheckListItem(TQListViewItem *parent,Kate::Document *document):AbstractKateSaveModifiedDialogCheckListItem(parent,document->docName(),document->url().prettyURL()){
+ m_document=document;
+ }
+ virtual ~KateSaveModifiedDocumentCheckListItem() {
+ }
+ virtual bool synchronousSave(TQWidget *dialogParent) {
+ if (m_document->url().isEmpty() ) {
+ KEncodingFileDialog::Result r=KEncodingFileDialog::getSaveURLAndEncoding(
+ KTextEditor::encodingInterface(m_document)->encoding(),TQString::null,TQString::null,dialogParent,i18n("Save As (%1)").arg(m_document->docName()));
+
+ m_document->setEncoding( r.encoding );
+ if (!r.URLs.isEmpty()) {
+ KURL tmp = r.URLs.first();
+ if ( !m_document->saveAs( tmp ) ) {
+ setState(SaveFailedState);
+ setText(1,m_document->url().prettyURL());
+ return false;
+ } else {
+ bool sc=m_document->waitSaveComplete();
+ setText(1,m_document->url().prettyURL());
+ if (!sc) {
+ setState(SaveFailedState);
+ return false;
+ } else {
+ setState(SaveOKState);
+ return true;
+ }
+ }
+ } else {
+ setState(SaveFailedState);
+ return false;
+ }
+ } else { //document has an exising location
+ if ( !m_document->save() ) {
+ setState(SaveFailedState);
+ setText(1,m_document->url().prettyURL());
+ return false;
+ } else {
+ bool sc=m_document->waitSaveComplete();
+ setText(1,m_document->url().prettyURL());
+ if (!sc) {
+ setState(SaveFailedState);
+ return false;
+ } else {
+ setState(SaveOKState);
+ return true;
+ }
+ }
+
+ }
+
+ return false;
+
+ }
+private:
+ Kate::Document *m_document;
+};
+
+KateSaveModifiedDialog::KateSaveModifiedDialog(TQWidget *parent, TQPtrList<Kate::Document> documents):
+ KDialogBase( parent, "KateSaveModifiedDialog", true, i18n("Save Documents"), Yes | No | Cancel) {
+
+ KGuiItem saveItem=KStdGuiItem::save();
+ saveItem.setText(i18n("&Save Selected"));
+ setButtonGuiItem(KDialogBase::Yes,saveItem);
+
+ setButtonGuiItem(KDialogBase::No,KStdGuiItem::dontSave());
+
+ KGuiItem cancelItem=KStdGuiItem::cancel();
+ cancelItem.setText(i18n("&Abort Closing"));
+ setButtonGuiItem(KDialogBase::Cancel,cancelItem);
+
+ TQVBox *box=makeVBoxMainWidget();
+ new KActiveLabel(i18n("<qt>The following documents have been modified. Do you want to save them before closing?</qt>"),box);
+ m_list=new TDEListView(box);
+ m_list->addColumn(i18n("Title"));
+ m_list->addColumn(i18n("Location"));
+ m_list->setRootIsDecorated(true);
+ m_list->setResizeMode(TQListView::LastColumn);
+ if (0) {
+ m_projectRoot=new TQListViewItem(m_list,i18n("Projects"));
+ } else m_projectRoot=0;
+ if (documents.count()>0) {
+ m_documentRoot=new TQListViewItem(m_list,i18n("Documents"));
+ const uint docCnt=documents.count();
+ for (uint i=0;i<docCnt;i++) {
+ new KateSaveModifiedDocumentCheckListItem(m_documentRoot,documents.at(i));
+ }
+ m_documentRoot->setOpen(true);
+ } else m_documentRoot=0;
+ //FIXME - Is this the best way?
+ connect(m_list, TQT_SIGNAL(clicked(TQListViewItem *)), TQT_SLOT(slotItemSelected()));
+ connect(m_list, TQT_SIGNAL(doubleClicked(TQListViewItem *)), TQT_SLOT(slotItemSelected()));
+ connect(m_list, TQT_SIGNAL(spacePressed(TQListViewItem *)), TQT_SLOT(slotItemSelected()));
+ if(documents.count()>3) { //For 3 or less, it would be quicker just to tick or untick them yourself, so don't clutter the gui.
+ connect(new TQPushButton(i18n("Se&lect All"),box),TQT_SIGNAL(clicked()),this,TQT_SLOT(slotSelectAll()));
+ }
+}
+
+KateSaveModifiedDialog::~KateSaveModifiedDialog() {
+}
+
+void KateSaveModifiedDialog::slotItemSelected() {
+ kdDebug(13001) << "slotItemSelected()" << endl;
+
+ for(TQListViewItem *it=m_documentRoot->firstChild();it;it=it->nextSibling()) {
+ if(((TQCheckListItem*)it)->isOn()) {
+ enableButton(KDialogBase::Yes, true);
+ return;
+ }
+ }
+ enableButton(KDialogBase::Yes, false);
+}
+
+static void selectItems(TQListViewItem *root) {
+ if (!root) return;
+ for (TQListViewItem *it=root->firstChild();it;it=it->nextSibling()) {
+ ((TQCheckListItem*)it)->setOn(true);
+ }
+}
+
+void KateSaveModifiedDialog::slotSelectAll() {
+ selectItems(m_documentRoot);
+ slotItemSelected();
+}
+
+
+void KateSaveModifiedDialog::slotUser2() {
+ kdDebug(13001)<<"KateSaveModifiedDialog::slotYes()"<<endl;
+ if (doSave(m_documentRoot)) done(TQDialog::Accepted);
+}
+
+void KateSaveModifiedDialog::slotUser1() {
+ done(TQDialog::Accepted);
+}
+
+bool KateSaveModifiedDialog::doSave(TQListViewItem *root) {
+ if (root) {
+ for (TQListViewItem *it=root->firstChild();it;it=it->nextSibling()) {
+ AbstractKateSaveModifiedDialogCheckListItem *cit= (AbstractKateSaveModifiedDialogCheckListItem*)it;
+ if (cit->isOn() && (cit->state()!=AbstractKateSaveModifiedDialogCheckListItem::SaveOKState)) {
+ if (!cit->synchronousSave(this /*perhaps that should be the kate mainwindow*/)) {
+ KMessageBox::sorry( this, i18n("Data you requested to be saved could not be written. Please choose how you want to proceed."));
+ return false;
+ }
+ } else if ((!cit->isOn()) && (cit->state()==AbstractKateSaveModifiedDialogCheckListItem::SaveFailedState)) {
+ cit->setState(AbstractKateSaveModifiedDialogCheckListItem::InitialState);
+ }
+
+ }
+ }
+ return true;
+}
+
+bool KateSaveModifiedDialog::queryClose(TQWidget *parent,TQPtrList<Kate::Document> documents) {
+ KateSaveModifiedDialog d(parent,documents);
+ return (d.exec()!=TQDialog::Rejected);
+}
diff --git a/kate/app/katesavemodifieddialog.h b/kate/app/katesavemodifieddialog.h
new file mode 100644
index 000000000..92036c63c
--- /dev/null
+++ b/kate/app/katesavemodifieddialog.h
@@ -0,0 +1,48 @@
+/* This file is part of the KDE project
+ Copyright (C) 2004 Joseph Wenninger <jowenn@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _KATE_SAVE_MODIFIED_DIALOG_
+#define _KATE_SAVE_MODIFIED_DIALOG_
+
+#include <kdialogbase.h>
+#include <kate/document.h>
+
+class TQListViewItem;
+class TDEListView;
+
+class KateSaveModifiedDialog: public KDialogBase {
+ Q_OBJECT
+public:
+ KateSaveModifiedDialog(TQWidget *parent, TQPtrList<Kate::Document> documents);
+ virtual ~KateSaveModifiedDialog();
+ static bool queryClose(TQWidget *parent,TQPtrList<Kate::Document> documents);
+protected:
+ virtual void slotUser2();
+ virtual void slotUser1();
+ bool doSave(TQListViewItem *root);
+protected slots:
+ void slotSelectAll();
+ void slotItemSelected();
+
+private:
+ TQListViewItem *m_projectRoot;
+ TQListViewItem *m_documentRoot;
+ TDEListView *m_list;
+};
+
+#endif
diff --git a/kate/app/katesession.cpp b/kate/app/katesession.cpp
new file mode 100644
index 000000000..ed6ee3f95
--- /dev/null
+++ b/kate/app/katesession.cpp
@@ -0,0 +1,920 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Christoph Cullmann <cullmann@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "katesession.h"
+#include "katesession.moc"
+
+#include "kateapp.h"
+#include "katemainwindow.h"
+#include "katedocmanager.h"
+
+#include <kstandarddirs.h>
+#include <tdelocale.h>
+#include <kdebug.h>
+#include <kdirwatch.h>
+#include <tdelistview.h>
+#include <kinputdialog.h>
+#include <kiconloader.h>
+#include <tdemessagebox.h>
+#include <kmdcodec.h>
+#include <kstdguiitem.h>
+#include <kpushbutton.h>
+#include <tdepopupmenu.h>
+
+#include <tqdir.h>
+#include <tqlabel.h>
+#include <tqlayout.h>
+#include <tqvbox.h>
+#include <tqhbox.h>
+#include <tqcheckbox.h>
+#include <tqdatetime.h>
+#include <tqmap.h>
+
+#include <unistd.h>
+#include <time.h>
+
+bool operator<( const KateSession::Ptr& a, const KateSession::Ptr& b )
+{
+ return a->sessionName().lower() < b->sessionName().lower();
+}
+
+KateSession::KateSession (KateSessionManager *manager, const TQString &fileName, const TQString &name)
+ : m_sessionFileRel (fileName)
+ , m_sessionName (name)
+ , m_documents (0)
+ , m_manager (manager)
+ , m_readConfig (0)
+ , m_writeConfig (0)
+{
+ init ();
+}
+
+void KateSession::init ()
+{
+ // given file exists, use it to load some stuff ;)
+ if (!m_sessionFileRel.isEmpty() && TDEGlobal::dirs()->exists(sessionFile ()))
+ {
+ KSimpleConfig config (sessionFile (), true);
+
+ if (m_sessionName.isEmpty())
+ {
+ // get the name out of the file
+ if (m_sessionFileRel == "default.katesession")
+ m_sessionName = i18n("Default Session");
+ else
+ {
+ config.setGroup ("General");
+ m_sessionName = config.readEntry ("Name", i18n ("Unnamed Session"));
+ }
+ }
+
+ // get the document count
+ config.setGroup ("Open Documents");
+ m_documents = config.readUnsignedNumEntry("Count", 0);
+
+ return;
+ }
+
+ // filename not empty, create the file
+ // anders: When will this ever happen???
+ if (!m_sessionFileRel.isEmpty())
+ {
+ kdDebug(13001)<<"Kate::Session: initializing unexisting file!"<<endl;
+ // uhh, no name given
+ if (m_sessionName.isEmpty())
+ {
+ if (m_sessionFileRel == "default.katesession")
+ m_sessionName = i18n("Default Session");
+ else
+ m_sessionName = i18n("Session (%1)").arg(TQTime::currentTime().toString(Qt::LocalDate));
+ }
+
+ // create the file, write name to it!
+ KSimpleConfig config (sessionFile ());
+ config.setGroup ("General");
+ config.writeEntry ("Name", m_sessionName);
+
+ config.sync ();
+ }
+}
+
+KateSession::~KateSession ()
+{
+ delete m_readConfig;
+ delete m_writeConfig;
+}
+
+TQString KateSession::sessionFile () const
+{
+ return m_manager->sessionsDir() + "/" + m_sessionFileRel;
+}
+
+bool KateSession::create (const TQString &name, bool force)
+{
+ if (!force && (name.isEmpty() || !m_sessionFileRel.isEmpty()))
+ return false;
+
+ delete m_writeConfig;
+ m_writeConfig = 0;
+
+ delete m_readConfig;
+ m_readConfig = 0;
+
+ m_sessionName = name;
+
+ // get a usable filename
+ int s = time(0);
+ TQCString tname;
+ while (true)
+ {
+ tname.setNum (s++);
+ KMD5 md5 (tname);
+ m_sessionFileRel = TQString ("%1.katesession").arg (md5.hexDigest().data());
+
+ if (!TDEGlobal::dirs()->exists(sessionFile ()))
+ break;
+ }
+
+ // create the file, write name to it!
+ KSimpleConfig config (sessionFile ());
+ config.setGroup ("General");
+ config.writeEntry ("Name", m_sessionName);
+ config.sync ();
+
+ // reinit ourselfs ;)
+ init ();
+
+ return true;
+}
+
+bool KateSession::rename (const TQString &name)
+{
+ if (name.isEmpty () || m_sessionFileRel.isEmpty() || m_sessionFileRel == "default.katesession")
+ return false;
+
+ m_sessionName = name;
+
+ TDEConfig config (sessionFile (), false, false);
+ config.setGroup ("General");
+ config.writeEntry ("Name", m_sessionName);
+ config.sync ();
+
+ return true;
+}
+
+TDEConfig *KateSession::configRead ()
+{
+ if (m_sessionFileRel.isEmpty())
+ return 0;
+
+ if (m_readConfig)
+ return m_readConfig;
+
+ return m_readConfig = new KSimpleConfig (sessionFile (), true);
+}
+
+TDEConfig *KateSession::configWrite ()
+{
+ if (m_sessionFileRel.isEmpty())
+ return 0;
+
+ if (m_writeConfig)
+ return m_writeConfig;
+
+ m_writeConfig = new KSimpleConfig (sessionFile ());
+ m_writeConfig->setGroup ("General");
+ m_writeConfig->writeEntry ("Name", m_sessionName);
+
+ return m_writeConfig;
+}
+
+KateSessionManager::KateSessionManager (TQObject *parent)
+ : TQObject (parent)
+ , m_sessionsDir (locateLocal( "data", "kate/sessions"))
+ , m_activeSession (new KateSession (this, "", ""))
+{
+ kdDebug() << "LOCAL SESSION DIR: " << m_sessionsDir << endl;
+
+ // create dir if needed
+ TDEGlobal::dirs()->makeDir (m_sessionsDir);
+}
+
+KateSessionManager::~KateSessionManager()
+{
+}
+
+KateSessionManager *KateSessionManager::self()
+{
+ return KateApp::self()->sessionManager ();
+}
+
+void KateSessionManager::dirty (const TQString &)
+{
+ updateSessionList ();
+}
+
+void KateSessionManager::updateSessionList ()
+{
+ m_sessionList.clear ();
+
+ // Let's get a list of all session we have atm
+ TQDir dir (m_sessionsDir, "*.katesession");
+
+ bool foundDefault = false;
+ for (unsigned int i=0; i < dir.count(); ++i)
+ {
+ KateSession *session = new KateSession (this, dir[i], "");
+ m_sessionList.append (session);
+
+ kdDebug () << "FOUND SESSION: " << session->sessionName() << " FILE: " << session->sessionFile() << endl;
+
+ if (!foundDefault && (dir[i] == "default.katesession"))
+ foundDefault = true;
+ }
+
+ // add default session, if not there
+ if (!foundDefault)
+ m_sessionList.append (new KateSession (this, "default.katesession", i18n("Default Session")));
+
+ qHeapSort(m_sessionList);
+}
+
+void KateSessionManager::activateSession (KateSession::Ptr session, bool closeLast, bool saveLast, bool loadNew)
+{
+ // don't reload.
+ // ### comparing the pointers directly is b0rk3d :(
+ if ( ! session->sessionName().isEmpty() && session->sessionName() == m_activeSession->sessionName() )
+ return;
+ // try to close last session
+ if (closeLast)
+ {
+ if (KateApp::self()->activeMainWindow())
+ {
+ if (!KateApp::self()->activeMainWindow()->queryClose_internal())
+ return;
+ }
+ }
+
+ // save last session or not?
+ if (saveLast)
+ saveActiveSession (true);
+
+ // really close last
+ if (closeLast)
+ {
+ KateDocManager::self()->closeAllDocuments ();
+ }
+
+ // set the new session
+ m_activeSession = session;
+
+ if (loadNew)
+ {
+ // open the new session
+ Kate::Document::setOpenErrorDialogsActivated (false);
+
+ TDEConfig *sc = activeSession()->configRead();
+
+ if (sc)
+ KateApp::self()->documentManager()->restoreDocumentList (sc);
+
+ // if we have no session config object, try to load the default
+ // (anonymous/unnamed sessions)
+ if ( ! sc )
+ sc = new KSimpleConfig( sessionsDir() + "/default.katesession" );
+
+ // window config
+ if (sc)
+ {
+ TDEConfig *c = KateApp::self()->config();
+ c->setGroup("General");
+
+ if (c->readBoolEntry("Restore Window Configuration", true))
+ {
+ // a new, named session, read settings of the default session.
+ if ( ! sc->hasGroup("Open MainWindows") )
+ sc = new KSimpleConfig( sessionsDir() + "/default.katesession" );
+
+ sc->setGroup ("Open MainWindows");
+ unsigned int wCount = sc->readUnsignedNumEntry("Count", 1);
+
+ for (unsigned int i=0; i < wCount; ++i)
+ {
+ if (i >= KateApp::self()->mainWindows())
+ {
+ KateApp::self()->newMainWindow(sc, TQString ("MainWindow%1").arg(i));
+ }
+ else
+ {
+ sc->setGroup(TQString ("MainWindow%1").arg(i));
+ KateApp::self()->mainWindow(i)->readProperties (sc);
+ }
+ }
+
+ if (wCount > 0)
+ {
+ while (wCount < KateApp::self()->mainWindows())
+ {
+ KateMainWindow *w = KateApp::self()->mainWindow(KateApp::self()->mainWindows()-1);
+ KateApp::self()->removeMainWindow (w);
+ delete w;
+ }
+ }
+ }
+ }
+
+ Kate::Document::setOpenErrorDialogsActivated (true);
+ }
+}
+
+KateSession::Ptr KateSessionManager::createSession (const TQString &name)
+{
+ KateSession::Ptr s = new KateSession (this, "", "");
+ s->create (name);
+
+ return s;
+}
+
+KateSession::Ptr KateSessionManager::giveSession (const TQString &name)
+{
+ if (name.isEmpty())
+ return new KateSession (this, "", "");
+
+ updateSessionList();
+
+ for (unsigned int i=0; i < m_sessionList.count(); ++i)
+ {
+ if (m_sessionList[i]->sessionName() == name)
+ return m_sessionList[i];
+ }
+
+ return createSession (name);
+}
+
+bool KateSessionManager::saveActiveSession (bool tryAsk, bool rememberAsLast)
+{
+ if (tryAsk)
+ {
+ // app config
+ TDEConfig *c = KateApp::self()->config();
+ c->setGroup("General");
+
+ TQString sesExit (c->readEntry ("Session Exit", "save"));
+
+ if (sesExit == "discard")
+ return true;
+
+ if (sesExit == "ask")
+ {
+ KDialogBase* dlg = new KDialogBase(i18n ("Save Session?")
+ , KDialogBase::Yes | KDialogBase::No
+ , KDialogBase::Yes, KDialogBase::No
+ );
+
+ bool dontAgain = false;
+ int res = KMessageBox::createKMessageBox(dlg, TQMessageBox::Question,
+ i18n("Save current session?"), TQStringList(),
+ i18n("Do not ask again"), &dontAgain, KMessageBox::Notify);
+
+ // remember to not ask again with right setting
+ if (dontAgain)
+ {
+ c->setGroup("General");
+
+ if (res == KDialogBase::No)
+ c->writeEntry ("Session Exit", "discard");
+ else
+ c->writeEntry ("Session Exit", "save");
+ }
+
+ if (res == KDialogBase::No)
+ return true;
+ }
+ }
+
+ TDEConfig *sc = activeSession()->configWrite();
+
+ if (!sc)
+ return false;
+
+ KateDocManager::self()->saveDocumentList (sc);
+
+ sc->setGroup ("Open MainWindows");
+ sc->writeEntry ("Count", KateApp::self()->mainWindows ());
+
+ // save config for all windows around ;)
+ for (unsigned int i=0; i < KateApp::self()->mainWindows (); ++i )
+ {
+ sc->setGroup(TQString ("MainWindow%1").arg(i));
+ KateApp::self()->mainWindow(i)->saveProperties (sc);
+ }
+
+ sc->sync();
+
+ if (rememberAsLast)
+ {
+ TDEConfig *c = KateApp::self()->config();
+ c->setGroup("General");
+ c->writeEntry ("Last Session", activeSession()->sessionFileRelative());
+ c->sync ();
+ }
+
+ return true;
+}
+
+bool KateSessionManager::chooseSession ()
+{
+ bool success = true;
+
+ // app config
+ TDEConfig *c = KateApp::self()->config();
+ c->setGroup("General");
+
+ // get last used session, default to default session
+ TQString lastSession (c->readEntry ("Last Session", "default.katesession"));
+ TQString sesStart (c->readEntry ("Startup Session", "manual"));
+
+ // uhh, just open last used session, show no chooser
+ if (sesStart == "last")
+ {
+ activateSession (new KateSession (this, lastSession, ""), false, false);
+ return success;
+ }
+
+ // start with empty new session
+ if (sesStart == "new")
+ {
+ activateSession (new KateSession (this, "", ""), false, false);
+ return success;
+ }
+
+ KateSessionChooser *chooser = new KateSessionChooser (0, lastSession);
+
+ bool retry = true;
+ int res = 0;
+ while (retry)
+ {
+ res = chooser->exec ();
+
+ switch (res)
+ {
+ case KateSessionChooser::resultOpen:
+ {
+ KateSession::Ptr s = chooser->selectedSession ();
+
+ if (!s)
+ {
+ KMessageBox::error (chooser, i18n("No session selected to open."), i18n ("No Session Selected"));
+ break;
+ }
+
+ activateSession (s, false, false);
+ retry = false;
+ break;
+ }
+
+ // exit the app lateron
+ case KateSessionChooser::resultQuit:
+ success = false;
+ retry = false;
+ break;
+
+ default:
+ activateSession (new KateSession (this, "", ""), false, false);
+ retry = false;
+ break;
+ }
+ }
+
+ // write back our nice boolean :)
+ if (success && chooser->reopenLastSession ())
+ {
+ c->setGroup("General");
+
+ if (res == KateSessionChooser::resultOpen)
+ c->writeEntry ("Startup Session", "last");
+ else if (res == KateSessionChooser::resultNew)
+ c->writeEntry ("Startup Session", "new");
+
+ c->sync ();
+ }
+
+ delete chooser;
+
+ return success;
+}
+
+void KateSessionManager::sessionNew ()
+{
+ activateSession (new KateSession (this, "", ""));
+}
+
+void KateSessionManager::sessionOpen ()
+{
+ KateSessionOpenDialog *chooser = new KateSessionOpenDialog (0);
+
+ int res = chooser->exec ();
+
+ if (res == KateSessionOpenDialog::resultCancel)
+ {
+ delete chooser;
+ return;
+ }
+
+ KateSession::Ptr s = chooser->selectedSession ();
+
+ if (s)
+ activateSession (s);
+
+ delete chooser;
+}
+
+void KateSessionManager::sessionSave ()
+{
+ // if the active session is valid, just save it :)
+ if (saveActiveSession ())
+ return;
+
+ bool ok = false;
+ TQString name = KInputDialog::getText (i18n("Specify Name for Current Session"), i18n("Session name:"), "", &ok);
+
+ if (!ok)
+ return;
+
+ if (name.isEmpty())
+ {
+ KMessageBox::error (0, i18n("To save a new session, you must specify a name."), i18n ("Missing Session Name"));
+ return;
+ }
+
+ activeSession()->create (name);
+ saveActiveSession ();
+}
+
+void KateSessionManager::sessionSaveAs ()
+{
+ bool ok = false;
+ TQString name = KInputDialog::getText (i18n("Specify New Name for Current Session"), i18n("Session name:"), "", &ok);
+
+ if (!ok)
+ return;
+
+ if (name.isEmpty())
+ {
+ KMessageBox::error (0, i18n("To save a session, you must specify a name."), i18n ("Missing Session Name"));
+ return;
+ }
+
+ activeSession()->create (name, true);
+ saveActiveSession ();
+}
+
+
+void KateSessionManager::sessionManage ()
+{
+ KateSessionManageDialog *dlg = new KateSessionManageDialog (0);
+
+ dlg->exec ();
+
+ delete dlg;
+}
+
+//BEGIN CHOOSER DIALOG
+
+class KateSessionChooserItem : public TQListViewItem
+{
+ public:
+ KateSessionChooserItem (TDEListView *lv, KateSession::Ptr s)
+ : TQListViewItem (lv, s->sessionName())
+ , session (s)
+ {
+ TQString docs;
+ docs.setNum (s->documents());
+ setText (1, docs);
+ }
+
+ KateSession::Ptr session;
+};
+
+KateSessionChooser::KateSessionChooser (TQWidget *parent, const TQString &lastSession)
+ : KDialogBase ( parent
+ , ""
+ , true
+ , i18n ("Session Chooser")
+ , KDialogBase::User1 | KDialogBase::User2 | KDialogBase::User3
+ , KDialogBase::User2
+ , true
+ , KStdGuiItem::quit ()
+ , KGuiItem (i18n ("Open Session"), "fileopen")
+ , KGuiItem (i18n ("New Session"), "filenew")
+ )
+{
+ TQHBox *page = new TQHBox (this);
+ page->setMinimumSize (400, 200);
+ setMainWidget(page);
+
+ TQHBox *hb = new TQHBox (page);
+ hb->setSpacing (KDialog::spacingHint());
+
+ TQLabel *label = new TQLabel (hb);
+ label->setPixmap (UserIcon("sessionchooser"));
+ label->setFrameStyle (TQFrame::Panel | TQFrame::Sunken);
+
+ TQVBox *vb = new TQVBox (hb);
+ vb->setSpacing (KDialog::spacingHint());
+
+ m_sessions = new TDEListView (vb);
+ m_sessions->addColumn (i18n("Session Name"));
+ m_sessions->addColumn (i18n("Open Documents"));
+ m_sessions->setResizeMode (TQListView::AllColumns);
+ m_sessions->setSelectionMode (TQListView::Single);
+ m_sessions->setAllColumnsShowFocus (true);
+
+ connect (m_sessions, TQT_SIGNAL(selectionChanged()), this, TQT_SLOT(selectionChanged()));
+ connect (m_sessions, TQT_SIGNAL(doubleClicked(TQListViewItem *, const TQPoint &, int)), this, TQT_SLOT(slotUser2()));
+
+ KateSessionList &slist (KateSessionManager::self()->sessionList());
+ for (unsigned int i=0; i < slist.count(); ++i)
+ {
+ KateSessionChooserItem *item = new KateSessionChooserItem (m_sessions, slist[i]);
+
+ if (slist[i]->sessionFileRelative() == lastSession)
+ m_sessions->setSelected (item, true);
+ }
+
+ m_useLast = new TQCheckBox (i18n ("&Always use this choice"), vb);
+
+ setResult (resultNone);
+
+ // trigger action update
+ selectionChanged ();
+}
+
+KateSessionChooser::~KateSessionChooser ()
+{
+}
+
+KateSession::Ptr KateSessionChooser::selectedSession ()
+{
+ KateSessionChooserItem *item = (KateSessionChooserItem *) m_sessions->selectedItem ();
+
+ if (!item)
+ return 0;
+
+ return item->session;
+}
+
+bool KateSessionChooser::reopenLastSession ()
+{
+ return m_useLast->isChecked ();
+}
+
+void KateSessionChooser::slotUser2 ()
+{
+ done (resultOpen);
+}
+
+void KateSessionChooser::slotUser3 ()
+{
+ done (resultNew);
+}
+
+void KateSessionChooser::slotUser1 ()
+{
+ done (resultQuit);
+}
+
+void KateSessionChooser::selectionChanged ()
+{
+ enableButton (KDialogBase::User2, m_sessions->selectedItem ());
+}
+
+//END CHOOSER DIALOG
+
+//BEGIN OPEN DIALOG
+
+KateSessionOpenDialog::KateSessionOpenDialog (TQWidget *parent)
+ : KDialogBase ( parent
+ , ""
+ , true
+ , i18n ("Open Session")
+ , KDialogBase::User1 | KDialogBase::User2
+ , KDialogBase::User2
+ , false
+ , KStdGuiItem::cancel ()
+ , KGuiItem( i18n("&Open"), "fileopen")
+ )
+{
+ TQHBox *page = new TQHBox (this);
+ page->setMinimumSize (400, 200);
+ setMainWidget(page);
+
+ TQHBox *hb = new TQHBox (page);
+
+ TQVBox *vb = new TQVBox (hb);
+
+ m_sessions = new TDEListView (vb);
+ m_sessions->addColumn (i18n("Session Name"));
+ m_sessions->addColumn (i18n("Open Documents"));
+ m_sessions->setResizeMode (TQListView::AllColumns);
+ m_sessions->setSelectionMode (TQListView::Single);
+ m_sessions->setAllColumnsShowFocus (true);
+
+ connect (m_sessions, TQT_SIGNAL(doubleClicked(TQListViewItem *, const TQPoint &, int)), this, TQT_SLOT(slotUser2()));
+
+ KateSessionList &slist (KateSessionManager::self()->sessionList());
+ for (unsigned int i=0; i < slist.count(); ++i)
+ {
+ new KateSessionChooserItem (m_sessions, slist[i]);
+ }
+
+ setResult (resultCancel);
+}
+
+KateSessionOpenDialog::~KateSessionOpenDialog ()
+{
+}
+
+KateSession::Ptr KateSessionOpenDialog::selectedSession ()
+{
+ KateSessionChooserItem *item = (KateSessionChooserItem *) m_sessions->selectedItem ();
+
+ if (!item)
+ return 0;
+
+ return item->session;
+}
+
+void KateSessionOpenDialog::slotUser1 ()
+{
+ done (resultCancel);
+}
+
+void KateSessionOpenDialog::slotUser2 ()
+{
+ done (resultOk);
+}
+
+//END OPEN DIALOG
+
+//BEGIN MANAGE DIALOG
+
+KateSessionManageDialog::KateSessionManageDialog (TQWidget *parent)
+ : KDialogBase ( parent
+ , ""
+ , true
+ , i18n ("Manage Sessions")
+ , KDialogBase::User1
+ , KDialogBase::User1
+ , false
+ , KStdGuiItem::close ()
+ )
+{
+ TQHBox *page = new TQHBox (this);
+ page->setMinimumSize (400, 200);
+ setMainWidget(page);
+
+ TQHBox *hb = new TQHBox (page);
+ hb->setSpacing (KDialog::spacingHint());
+
+ m_sessions = new TDEListView (hb);
+ m_sessions->addColumn (i18n("Session Name"));
+ m_sessions->addColumn (i18n("Open Documents"));
+ m_sessions->setResizeMode (TQListView::AllColumns);
+ m_sessions->setSelectionMode (TQListView::Single);
+ m_sessions->setAllColumnsShowFocus (true);
+
+ connect (m_sessions, TQT_SIGNAL(selectionChanged()), this, TQT_SLOT(selectionChanged()));
+
+ updateSessionList ();
+
+ TQWidget *vb = new TQWidget (hb);
+ TQVBoxLayout *vbl = new TQVBoxLayout (vb);
+ vbl->setSpacing (KDialog::spacingHint());
+
+ m_rename = new KPushButton (i18n("&Rename..."), vb);
+ connect (m_rename, TQT_SIGNAL(clicked()), this, TQT_SLOT(rename()));
+ vbl->addWidget (m_rename);
+
+ m_del = new KPushButton (KStdGuiItem::del (), vb);
+ connect (m_del, TQT_SIGNAL(clicked()), this, TQT_SLOT(del()));
+ vbl->addWidget (m_del);
+
+ vbl->addStretch ();
+
+ // trigger action update
+ selectionChanged ();
+}
+
+KateSessionManageDialog::~KateSessionManageDialog ()
+{
+}
+
+void KateSessionManageDialog::slotUser1 ()
+{
+ done (0);
+}
+
+
+void KateSessionManageDialog::selectionChanged ()
+{
+ KateSessionChooserItem *item = (KateSessionChooserItem *) m_sessions->selectedItem ();
+
+ m_rename->setEnabled (item && item->session->sessionFileRelative() != "default.katesession");
+ m_del->setEnabled (item && item->session->sessionFileRelative() != "default.katesession");
+}
+
+void KateSessionManageDialog::rename ()
+{
+ KateSessionChooserItem *item = (KateSessionChooserItem *) m_sessions->selectedItem ();
+
+ if (!item || item->session->sessionFileRelative() == "default.katesession")
+ return;
+
+ bool ok = false;
+ TQString name = KInputDialog::getText (i18n("Specify New Name for Session"), i18n("Session name:"), item->session->sessionName(), &ok);
+
+ if (!ok)
+ return;
+
+ if (name.isEmpty())
+ {
+ KMessageBox::error (0, i18n("To save a session, you must specify a name."), i18n ("Missing Session Name"));
+ return;
+ }
+
+ item->session->rename (name);
+ updateSessionList ();
+}
+
+void KateSessionManageDialog::del ()
+{
+ KateSessionChooserItem *item = (KateSessionChooserItem *) m_sessions->selectedItem ();
+
+ if (!item || item->session->sessionFileRelative() == "default.katesession")
+ return;
+
+ TQFile::remove (item->session->sessionFile());
+ KateSessionManager::self()->updateSessionList ();
+ updateSessionList ();
+}
+
+void KateSessionManageDialog::updateSessionList ()
+{
+ m_sessions->clear ();
+
+ KateSessionList &slist (KateSessionManager::self()->sessionList());
+ for (unsigned int i=0; i < slist.count(); ++i)
+ {
+ new KateSessionChooserItem (m_sessions, slist[i]);
+ }
+}
+
+//END MANAGE DIALOG
+
+
+KateSessionsAction::KateSessionsAction(const TQString& text, TQObject* parent, const char* name )
+ : TDEActionMenu(text, parent, name)
+{
+ connect(popupMenu(),TQT_SIGNAL(aboutToShow()),this,TQT_SLOT(slotAboutToShow()));
+}
+
+void KateSessionsAction::slotAboutToShow()
+{
+ popupMenu()->clear ();
+
+ KateSessionList &slist (KateSessionManager::self()->sessionList());
+ for (unsigned int i=0; i < slist.count(); ++i)
+ {
+ popupMenu()->insertItem (
+ slist[i]->sessionName(),
+ this, TQT_SLOT (openSession (int)), 0,
+ i );
+ }
+}
+
+void KateSessionsAction::openSession (int i)
+{
+ KateSessionList &slist (KateSessionManager::self()->sessionList());
+
+ if ((uint)i >= slist.count())
+ return;
+
+ KateSessionManager::self()->activateSession(slist[(uint)i]);
+}
+// kate: space-indent on; indent-width 2; replace-tabs on; mixed-indent off;
diff --git a/kate/app/katesession.h b/kate/app/katesession.h
new file mode 100644
index 000000000..b62e72a48
--- /dev/null
+++ b/kate/app/katesession.h
@@ -0,0 +1,418 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Christoph Cullmann <cullmann@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __KATE_SESSION_H__
+#define __KATE_SESSION_H__
+
+#include "katemain.h"
+
+#include <kdialogbase.h>
+#include <ksimpleconfig.h>
+#include <ksharedptr.h>
+#include <tdeaction.h>
+
+#include <tqobject.h>
+#include <tqvaluelist.h>
+
+class KateSessionManager;
+
+class KDirWatch;
+class TDEListView;
+class KPushButton;
+
+class TQCheckBox;
+
+class KateSession : public TDEShared
+{
+ public:
+ /**
+ * Define a Shared-Pointer type
+ */
+ typedef TDESharedPtr<KateSession> Ptr;
+
+ public:
+ /**
+ * create a session from given file
+ * @param fileName session filename, relative
+ * @param name session name
+ * @param manager pointer to the manager
+ */
+ KateSession (KateSessionManager *manager, const TQString &fileName, const TQString &name);
+
+ /**
+ * init the session object, after construction or create
+ */
+ void init ();
+
+ /**
+ * destruct me
+ */
+ ~KateSession ();
+
+ /**
+ * session filename, absolute, calculated out of relative filename + session dir
+ * @return absolute path to session file
+ */
+ TQString sessionFile () const;
+
+ /**
+ * relative session filename
+ * @return relative filename for this session
+ */
+ const TQString &sessionFileRelative () const { return m_sessionFileRel; }
+
+ /**
+ * session name
+ * @return name for this session
+ */
+ const TQString &sessionName () const { return m_sessionName; }
+
+ /**
+ * is this a valid session? if not, don't use any session if this is
+ * the active one
+ */
+ bool isNew () const { return m_sessionName.isEmpty(); }
+
+ /**
+ * create the session file, if not existing
+ * @param name name for this session
+ * @param force force to create new file
+ * @return true if created, false if no creation needed
+ */
+ bool create (const TQString &name, bool force = false);
+
+ /**
+ * rename this session
+ * @param name new name
+ * @return success
+ */
+ bool rename (const TQString &name);
+
+ /**
+ * config to read
+ * on first access, will create the config object, delete will be done automagic
+ * return 0 if we have no file to read config from atm
+ * @return config to read from
+ */
+ TDEConfig *configRead ();
+
+ /**
+ * config to write
+ * on first access, will create the config object, delete will be done automagic
+ * return 0 if we have no file to write config to atm
+ * @return config to write from
+ */
+ TDEConfig *configWrite ();
+
+ /**
+ * count of documents in this session
+ * @return documents count
+ */
+ unsigned int documents () const { return m_documents; }
+
+ private:
+ /**
+ * session filename, in local location we can write to
+ * relative filename to the session dirs :)
+ */
+ TQString m_sessionFileRel;
+
+ /**
+ * session name, extracted from the file, to display to the user
+ */
+ TQString m_sessionName;
+
+ /**
+ * number of document of this session
+ */
+ unsigned int m_documents;
+
+ /**
+ * KateSessionMananger
+ */
+ KateSessionManager *m_manager;
+
+ /**
+ * simpleconfig to read from
+ */
+ KSimpleConfig *m_readConfig;
+
+ /**
+ * simpleconfig to write to
+ */
+ KSimpleConfig *m_writeConfig;
+};
+
+typedef TQValueList<KateSession::Ptr> KateSessionList;
+
+class KateSessionManager : public TQObject
+{
+ Q_OBJECT
+
+ public:
+ KateSessionManager(TQObject *parent);
+ ~KateSessionManager();
+
+ /**
+ * allow access to this :)
+ * @return instance of the session manager
+ */
+ static KateSessionManager *self();
+
+ /**
+ * allow access to the session list
+ * kept up to date by watching the dir
+ */
+ inline KateSessionList & sessionList () { updateSessionList (); return m_sessionList; }
+
+ /**
+ * activate a session
+ * first, it will look if a session with this name exists in list
+ * if yes, it will use this session, else it will create a new session file
+ * @param session session to activate
+ * @param closeLast try to close last session or not?
+ * @param saveLast try to save last session or not?
+ * @param loadNew load new session stuff?
+ */
+ void activateSession (KateSession::Ptr session, bool closeLast = true, bool saveLast = true, bool loadNew = true);
+
+ /**
+ * create a new session
+ * @param name session name
+ */
+ KateSession::Ptr createSession (const TQString &name);
+
+ /**
+ * return session with given name
+ * if no existing session matches, create new one with this name
+ * @param name session name
+ */
+ KateSession::Ptr giveSession (const TQString &name);
+
+ /**
+ * save current session
+ * for sessions without filename: save nothing
+ * @param tryAsk should we ask user if needed?
+ * @param rememberAsLast remember this session as last used?
+ * @return success
+ */
+ bool saveActiveSession (bool tryAsk = false, bool rememberAsLast = false);
+
+ /**
+ * return the current active session
+ * sessionFile == empty means we have no session around for this instance of kate
+ * @return session active atm
+ */
+ inline KateSession::Ptr activeSession () { return m_activeSession; }
+
+ /**
+ * session dir
+ * @return global session dir
+ */
+ inline const TQString &sessionsDir () const { return m_sessionsDir; }
+
+ /**
+ * initial session chooser, on app start
+ * @return success, if false, app should exit
+ */
+ bool chooseSession ();
+
+ public slots:
+ /**
+ * try to start a new session
+ * asks user first for name
+ */
+ void sessionNew ();
+
+ /**
+ * try to open a existing session
+ */
+ void sessionOpen ();
+
+ /**
+ * try to save current session
+ */
+ void sessionSave ();
+
+ /**
+ * try to save as current session
+ */
+ void sessionSaveAs ();
+
+ /**
+ * show dialog to manage our sessions
+ */
+ void sessionManage ();
+
+ private slots:
+ void dirty (const TQString &path);
+
+ public:
+ /**
+ * trigger update of session list
+ */
+ void updateSessionList ();
+
+ private:
+ /**
+ * absolute path to dir in home dir where to store the sessions
+ */
+ TQString m_sessionsDir;
+
+ /**
+ * list of current available sessions
+ */
+ KateSessionList m_sessionList;
+
+ /**
+ * current active session
+ */
+ KateSession::Ptr m_activeSession;
+};
+
+class KateSessionChooser : public KDialogBase
+{
+ Q_OBJECT
+
+ public:
+ KateSessionChooser (TQWidget *parent, const TQString &lastSession);
+ ~KateSessionChooser ();
+
+ KateSession::Ptr selectedSession ();
+
+ bool reopenLastSession ();
+
+ enum {
+ resultQuit = TQDialog::Rejected,
+ resultOpen,
+ resultNew,
+ resultNone
+ };
+
+ protected slots:
+ /**
+ * open session
+ */
+ void slotUser1 ();
+
+ /**
+ * new session
+ */
+ void slotUser2 ();
+
+ /**
+ * quit kate
+ */
+ void slotUser3 ();
+
+ /**
+ * selection has changed
+ */
+ void selectionChanged ();
+
+ private:
+ TDEListView *m_sessions;
+ TQCheckBox *m_useLast;
+};
+
+class KateSessionOpenDialog : public KDialogBase
+{
+ Q_OBJECT
+
+ public:
+ KateSessionOpenDialog (TQWidget *parent);
+ ~KateSessionOpenDialog ();
+
+ KateSession::Ptr selectedSession ();
+
+ enum {
+ resultOk,
+ resultCancel
+ };
+
+ protected slots:
+ /**
+ * cancel pressed
+ */
+ void slotUser1 ();
+
+ /**
+ * ok pressed
+ */
+ void slotUser2 ();
+
+ private:
+ TDEListView *m_sessions;
+};
+
+class KateSessionManageDialog : public KDialogBase
+{
+ Q_OBJECT
+
+ public:
+ KateSessionManageDialog (TQWidget *parent);
+ ~KateSessionManageDialog ();
+
+ protected slots:
+ /**
+ * close pressed
+ */
+ void slotUser1 ();
+
+ /**
+ * selection has changed
+ */
+ void selectionChanged ();
+
+ /**
+ * try to rename session
+ */
+ void rename ();
+
+ /**
+ * try to delete session
+ */
+ void del ();
+
+ private:
+ /**
+ * update our list
+ */
+ void updateSessionList ();
+
+ private:
+ TDEListView *m_sessions;
+ KPushButton *m_rename;
+ KPushButton *m_del;
+};
+
+class KateSessionsAction : public TDEActionMenu
+{
+ Q_OBJECT
+
+ public:
+ KateSessionsAction(const TQString& text, TQObject* parent = 0, const char* name = 0);
+ ~KateSessionsAction (){;};
+
+ public slots:
+ void slotAboutToShow();
+
+ void openSession (int i);
+};
+
+#endif
diff --git a/kate/app/katetabwidget.cpp b/kate/app/katetabwidget.cpp
new file mode 100644
index 000000000..e2ac7e8b3
--- /dev/null
+++ b/kate/app/katetabwidget.cpp
@@ -0,0 +1,161 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2002,2003 Joseph Wenninger <jowenn@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "katetabwidget.h"
+#include "katetabwidget.moc"
+
+#include <tqtabbar.h>
+
+//BEGIN KateTabWidget
+
+KateTabWidget::KateTabWidget(TQWidget* parent, const char* name)
+ : KTabWidget(parent,name)
+ , m_visibility (ShowWhenMoreThanOneTab)
+{
+ tabBar()->hide();
+
+ setHoverCloseButton(true);
+
+ connect(this, TQT_SIGNAL(closeRequest(TQWidget*)), this, TQT_SLOT(closeTab(TQWidget*)));
+}
+
+KateTabWidget::~KateTabWidget()
+{
+}
+
+void KateTabWidget::closeTab(TQWidget* w)
+{
+ w->close();
+}
+
+void KateTabWidget::addTab ( TQWidget * child, const TQString & label )
+{
+ KTabWidget::addTab(child,label);
+ showPage(child);
+ maybeShow();
+}
+
+void KateTabWidget::addTab ( TQWidget * child, const TQIconSet & iconset, const TQString & label )
+{
+ KTabWidget::addTab(child,iconset,label);
+ showPage(child);
+ maybeShow();
+}
+
+void KateTabWidget::addTab ( TQWidget * child, TQTab * tab )
+{
+ KTabWidget::addTab(child,tab);
+ showPage(child);
+ maybeShow();
+}
+
+void KateTabWidget::insertTab ( TQWidget * child, const TQString & label, int index)
+{
+ KTabWidget::insertTab(child,label,index);
+ showPage(child);
+ maybeShow();
+ tabBar()->repaint();
+}
+
+void KateTabWidget::insertTab ( TQWidget * child, const TQIconSet & iconset, const TQString & label, int index )
+{
+ KTabWidget::insertTab(child,iconset,label,index);
+ showPage(child);
+ maybeShow();
+ tabBar()->repaint();
+}
+
+void KateTabWidget::insertTab ( TQWidget * child, TQTab * tab, int index)
+{
+ KTabWidget::insertTab(child,tab,index);
+ showPage(child);
+ maybeShow();
+ tabBar()->repaint();
+}
+
+void KateTabWidget::removePage ( TQWidget * w )
+{
+ KTabWidget::removePage(w);
+ maybeShow();
+}
+
+void KateTabWidget::maybeShow()
+{
+ switch (m_visibility)
+ {
+ case AlwaysShowTabs:
+ tabBar()->show();
+
+ // show/hide corner widgets
+ if (count() == 0)
+ setCornerWidgetVisibility(false);
+ else
+ setCornerWidgetVisibility(true);
+
+ break;
+
+ case ShowWhenMoreThanOneTab:
+ if (count()<2) tabBar()->hide();
+ else tabBar()->show();
+
+ // show/hide corner widgets
+ if (count() < 2)
+ setCornerWidgetVisibility(false);
+ else
+ setCornerWidgetVisibility(true);
+
+ break;
+
+ case NeverShowTabs:
+ tabBar()->hide();
+ break;
+ }
+}
+
+void KateTabWidget::setCornerWidgetVisibility(bool visible)
+{
+ // there are two corner widgets: on TopLeft and on TopTight!
+
+ if (cornerWidget(TQt::TopLeft) ) {
+ if (visible)
+ cornerWidget(TQt::TopLeft)->show();
+ else
+ cornerWidget(TQt::TopLeft)->hide();
+ }
+
+ if (cornerWidget(TQt::TopRight) ) {
+ if (visible)
+ cornerWidget(TQt::TopRight)->show();
+ else
+ cornerWidget(TQt::TopRight)->hide();
+ }
+}
+
+void KateTabWidget::setTabWidgetVisibility( TabWidgetVisibility visibility )
+{
+ m_visibility = visibility;
+ maybeShow();
+}
+
+KateTabWidget::TabWidgetVisibility KateTabWidget::tabWidgetVisibility( ) const
+{
+ return m_visibility;
+}
+
+//END KateTabWidget
diff --git a/kate/app/katetabwidget.h b/kate/app/katetabwidget.h
new file mode 100644
index 000000000..7e4327595
--- /dev/null
+++ b/kate/app/katetabwidget.h
@@ -0,0 +1,69 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2002,2003 Joseph Wenninger <jowenn@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __KATE_TABWIDGET_H__
+#define __KATE_TABWIDGET_H__
+
+#include <ktabwidget.h>
+
+class KateTabWidget : public KTabWidget
+{
+ Q_OBJECT
+
+ public:
+ enum TabWidgetVisibility {
+ AlwaysShowTabs = 0,
+ ShowWhenMoreThanOneTab = 1,
+ NeverShowTabs = 2
+ };
+
+ public:
+ KateTabWidget(TQWidget* parent, const char* name=0);
+ virtual ~KateTabWidget();
+
+ virtual void addTab ( TQWidget * child, const TQString & label );
+
+ virtual void addTab ( TQWidget * child, const TQIconSet & iconset, const TQString & label );
+
+ virtual void addTab ( TQWidget * child, TQTab * tab );
+
+ virtual void insertTab ( TQWidget * child, const TQString & label, int index = -1 );
+
+ virtual void insertTab ( TQWidget * child, const TQIconSet & iconset, const TQString & label, int index = -1 );
+
+ virtual void insertTab ( TQWidget * child, TQTab * tab, int index = -1 );
+
+ virtual void removePage ( TQWidget * w );
+
+ TabWidgetVisibility tabWidgetVisibility() const;
+
+ void setTabWidgetVisibility( TabWidgetVisibility );
+
+ private slots:
+ void closeTab(TQWidget* w);
+
+ private:
+ void maybeShow();
+ void setCornerWidgetVisibility(bool visible);
+
+ private:
+ TabWidgetVisibility m_visibility;
+};
+
+#endif
diff --git a/kate/app/kateviewmanager.cpp b/kate/app/kateviewmanager.cpp
new file mode 100644
index 000000000..ca361232a
--- /dev/null
+++ b/kate/app/kateviewmanager.cpp
@@ -0,0 +1,514 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
+ Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+//BEGIN Includes
+#include "kateviewmanager.h"
+#include "kateviewmanager.moc"
+
+#include "katemainwindow.h"
+#include "katedocmanager.h"
+#include "kateviewspacecontainer.h"
+#include "katetabwidget.h"
+
+#include <dcopclient.h>
+#include <tdeaction.h>
+#include <tdecmdlineargs.h>
+#include <kdebug.h>
+#include <tdediroperator.h>
+#include <kdockwidget.h>
+#include <kencodingfiledialog.h>
+#include <kiconloader.h>
+#include <tdeglobal.h>
+#include <tdelocale.h>
+#include <tdetoolbar.h>
+#include <tdemessagebox.h>
+#include <ksimpleconfig.h>
+#include <kstdaction.h>
+#include <kstandarddirs.h>
+#include <tdeglobalsettings.h>
+#include <tdestdaccel.h>
+
+#include <tdetexteditor/encodinginterface.h>
+
+#include <tqobjectlist.h>
+#include <tqstringlist.h>
+#include <tqfileinfo.h>
+#include <tqtoolbutton.h>
+#include <tqtooltip.h>
+//END Includes
+
+KateViewManager::KateViewManager (KateMainWindow *parent)
+ : TQObject (parent),
+ showFullPath(false), m_mainWindow(parent)
+{
+ // while init
+ m_init=true;
+
+ // some stuff for the tabwidget
+ m_mainWindow->tabWidget()->setTabReorderingEnabled( true );
+
+ // important, set them up, as we use them in other methodes
+ setupActions ();
+
+ guiMergedView=0;
+
+ m_viewManager = new Kate::ViewManager (this);
+ m_currentContainer=0;
+ connect(m_mainWindow->tabWidget(),TQT_SIGNAL(currentChanged(TQWidget*)),this,TQT_SLOT(tabChanged(TQWidget*)));
+ slotNewTab();
+ tabChanged(m_mainWindow->tabWidget()->currentPage());
+
+ // no memleaks
+ m_viewSpaceContainerList.setAutoDelete(true);
+
+ // init done
+ m_init=false;
+}
+
+KateViewManager::~KateViewManager ()
+{
+ m_viewSpaceContainerList.setAutoDelete(false);
+}
+
+void KateViewManager::setupActions ()
+{
+ TDEAction *a;
+
+ /**
+ * tabbing
+ */
+ a=new TDEAction ( i18n("New Tab"),"tab_new", 0, TQT_TQOBJECT(this), TQT_SLOT(slotNewTab()),
+ m_mainWindow->actionCollection(), "view_new_tab" );
+
+ m_closeTab = new TDEAction ( i18n("Close Current Tab"),"tab_remove",0,TQT_TQOBJECT(this),TQT_SLOT(slotCloseTab()),
+ m_mainWindow->actionCollection(),"view_close_tab");
+
+ m_activateNextTab
+ = new TDEAction( i18n( "Activate Next Tab" ),
+ TQApplication::reverseLayout() ? TDEStdAccel::tabPrev() : TDEStdAccel::tabNext(),
+ TQT_TQOBJECT(this), TQT_SLOT( activateNextTab() ), m_mainWindow->actionCollection(), "view_next_tab" );
+
+ m_activatePrevTab
+ = new TDEAction( i18n( "Activate Previous Tab" ),
+ TQApplication::reverseLayout() ? TDEStdAccel::tabNext() : TDEStdAccel::tabPrev(),
+ TQT_TQOBJECT(this), TQT_SLOT( activatePrevTab() ), m_mainWindow->actionCollection(), "view_prev_tab" );
+
+ /**
+ * view splitting
+ */
+ a=new TDEAction ( i18n("Split Ve&rtical"), "view_right", CTRL+SHIFT+Key_L, TQT_TQOBJECT(this), TQT_SLOT(
+ slotSplitViewSpaceVert() ), m_mainWindow->actionCollection(), "view_split_vert");
+
+ a->setWhatsThis(i18n("Split the currently active view vertically into two views."));
+
+ a=new TDEAction ( i18n("Split &Horizontal"), "view_bottom", CTRL+SHIFT+Key_T, TQT_TQOBJECT(this), TQT_SLOT(
+ slotSplitViewSpaceHoriz() ), m_mainWindow->actionCollection(), "view_split_horiz");
+
+ a->setWhatsThis(i18n("Split the currently active view horizontally into two views."));
+
+ m_closeView = new TDEAction ( i18n("Cl&ose Current View"), "view_remove", CTRL+SHIFT+Key_R, TQT_TQOBJECT(this),
+ TQT_SLOT( slotCloseCurrentViewSpace() ), m_mainWindow->actionCollection(),
+ "view_close_current_space" );
+
+ m_closeView->setWhatsThis(i18n("Close the currently active splitted view"));
+
+ goNext=new TDEAction(i18n("Next View"),Key_F8,TQT_TQOBJECT(this),
+ TQT_SLOT(activateNextView()),m_mainWindow->actionCollection(),"go_next");
+
+ goNext->setWhatsThis(i18n("Make the next split view the active one."));
+
+ goPrev=new TDEAction(i18n("Previous View"),SHIFT+Key_F8, TQT_TQOBJECT(this), TQT_SLOT(activatePrevView()),m_mainWindow->actionCollection(),"go_prev");
+
+ goPrev->setWhatsThis(i18n("Make the previous split view the active one."));
+
+ /**
+ * buttons for tabbing
+ */
+ TQToolButton *b = new TQToolButton( m_mainWindow->tabWidget() );
+ connect( b, TQT_SIGNAL( clicked() ),
+ this, TQT_SLOT( slotNewTab() ) );
+ b->setIconSet( SmallIcon( "tab_new" ) );
+ b->adjustSize();
+ TQToolTip::add(b, i18n("Open a new tab"));
+ m_mainWindow->tabWidget()->setCornerWidget( b, TopLeft );
+
+ b = m_closeTabButton = new TQToolButton( m_mainWindow->tabWidget() );
+ connect( b, TQT_SIGNAL( clicked() ),
+ this, TQT_SLOT( slotCloseTab() ) );
+ b->setIconSet( SmallIcon( "tab_remove" ) );
+ b->adjustSize();
+ TQToolTip::add(b, i18n("Close the current tab"));
+ m_mainWindow->tabWidget()->setCornerWidget( b, TopRight );
+}
+
+void KateViewManager::updateViewSpaceActions ()
+{
+ if (!m_currentContainer) return;
+
+ m_closeView->setEnabled (m_currentContainer->viewSpaceCount() > 1);
+ goNext->setEnabled (m_currentContainer->viewSpaceCount() > 1);
+ goPrev->setEnabled (m_currentContainer->viewSpaceCount() > 1);
+}
+
+void KateViewManager::tabChanged(TQWidget* widget) {
+ KateViewSpaceContainer *container=static_cast<KateViewSpaceContainer*>(widget->tqt_cast("KateViewSpaceContainer"));
+ Q_ASSERT(container);
+ m_currentContainer=container;
+
+ if (container) {
+ container->reactivateActiveView();
+
+ }
+
+ m_closeTab->setEnabled(m_mainWindow->tabWidget()->count() > 1);
+ m_activateNextTab->setEnabled(m_mainWindow->tabWidget()->count() > 1);
+ m_activatePrevTab->setEnabled(m_mainWindow->tabWidget()->count() > 1);
+ m_closeTabButton->setEnabled (m_mainWindow->tabWidget()->count() > 1);
+
+ updateViewSpaceActions ();
+}
+
+void KateViewManager::slotNewTab()
+{
+ uint documentNumber=0;
+
+ if (m_currentContainer)
+ {
+ if (m_currentContainer->activeView())
+ documentNumber = m_currentContainer->activeView()->getDoc()->documentNumber();
+ }
+
+ KateViewSpaceContainer *container=new KateViewSpaceContainer (m_mainWindow->tabWidget(), this);
+ m_viewSpaceContainerList.append(container);
+ m_mainWindow->tabWidget()->addTab (container, "");
+
+ connect(container,TQT_SIGNAL(viewChanged()),this,TQT_SIGNAL(viewChanged()));
+ connect(container,TQT_SIGNAL(viewChanged()),m_viewManager,TQT_SIGNAL(viewChanged()));
+
+ if (!m_init)
+ {
+ container->activateView(documentNumber);
+ container->setShowFullPath(showFullPath);
+ m_mainWindow->slotWindowActivated ();
+ }
+}
+
+void KateViewManager::slotCloseTab()
+{
+ if (m_viewSpaceContainerList.count() <= 1) return;
+ if (!m_currentContainer) return;
+
+ int pos = m_viewSpaceContainerList.find (m_currentContainer);
+
+ if (pos == -1)
+ return;
+
+ if (guiMergedView)
+ m_mainWindow->guiFactory()->removeClient (guiMergedView );
+
+ m_viewSpaceContainerList.remove (pos);
+
+ if ((uint)pos >= m_viewSpaceContainerList.count())
+ pos = m_viewSpaceContainerList.count()-1;
+
+ tabChanged(m_viewSpaceContainerList.at (pos));
+}
+
+void KateViewManager::activateNextTab()
+{
+ if( m_mainWindow->tabWidget()->count() <= 1 ) return;
+
+ int iTab = m_mainWindow->tabWidget()->currentPageIndex();
+
+ iTab++;
+
+ if( iTab == m_mainWindow->tabWidget()->count() )
+ iTab = 0;
+
+ m_mainWindow->tabWidget()->setCurrentPage( iTab );
+}
+
+void KateViewManager::activatePrevTab()
+{
+ if( m_mainWindow->tabWidget()->count() <= 1 ) return;
+
+ int iTab = m_mainWindow->tabWidget()->currentPageIndex();
+
+ iTab--;
+
+ if( iTab == -1 )
+ iTab = m_mainWindow->tabWidget()->count() - 1;
+
+ m_mainWindow->tabWidget()->setCurrentPage( iTab );
+}
+
+void KateViewManager::activateSpace (Kate::View* v)
+{
+ if (m_currentContainer) {
+ m_currentContainer->activateSpace(v);
+ }
+}
+
+void KateViewManager::activateView ( Kate::View *view ) {
+ if (m_currentContainer) {
+ m_currentContainer->activateView(view);
+ }
+}
+
+KateViewSpace* KateViewManager::activeViewSpace ()
+{
+ if (m_currentContainer) {
+ return m_currentContainer->activeViewSpace();
+ }
+ return 0L;
+}
+
+Kate::View* KateViewManager::activeView ()
+{
+ if (m_currentContainer) {
+ return m_currentContainer->activeView();
+ }
+ return 0L;
+}
+
+void KateViewManager::setActiveSpace ( KateViewSpace* vs )
+{
+ if (m_currentContainer) {
+ m_currentContainer->setActiveSpace(vs);
+ }
+
+}
+
+void KateViewManager::setActiveView ( Kate::View* view )
+{
+ if (m_currentContainer) {
+ m_currentContainer->setActiveView(view);
+ }
+
+}
+
+
+void KateViewManager::activateView( uint documentNumber )
+{
+ if (m_currentContainer) {
+ m_currentContainer->activateView(documentNumber);
+ }
+}
+
+uint KateViewManager::viewCount ()
+{
+ uint viewCount=0;
+ for (uint i=0;i<m_viewSpaceContainerList.count();i++) {
+ viewCount+=m_viewSpaceContainerList.at(i)->viewCount();
+ }
+ return viewCount;
+
+}
+
+uint KateViewManager::viewSpaceCount ()
+{
+ uint viewSpaceCount=0;
+ for (uint i=0;i<m_viewSpaceContainerList.count();i++) {
+ viewSpaceCount+=m_viewSpaceContainerList.at(i)->viewSpaceCount();
+ }
+ return viewSpaceCount;
+}
+
+void KateViewManager::setViewActivationBlocked (bool block)
+{
+ for (uint i=0;i<m_viewSpaceContainerList.count();i++)
+ m_viewSpaceContainerList.at(i)->m_blockViewCreationAndActivation=block;
+}
+
+void KateViewManager::activateNextView()
+{
+ if (m_currentContainer) {
+ m_currentContainer->activateNextView();
+ }
+}
+
+void KateViewManager::activatePrevView()
+{
+ if (m_currentContainer) {
+ m_currentContainer->activatePrevView();
+ }
+}
+
+void KateViewManager::closeViews(uint documentNumber)
+{
+ for (uint i=0;i<m_viewSpaceContainerList.count();i++) {
+ m_viewSpaceContainerList.at(i)->closeViews(documentNumber);
+ }
+ tabChanged(m_currentContainer);
+}
+
+void KateViewManager::slotDocumentNew ()
+{
+ if (m_currentContainer) m_currentContainer->createView ();
+}
+
+void KateViewManager::slotDocumentOpen ()
+{
+ Kate::View *cv = activeView();
+
+ if (cv) {
+ KEncodingFileDialog::Result r=KEncodingFileDialog::getOpenURLsAndEncoding(
+ (cv ? KTextEditor::encodingInterface(cv->document())->encoding() : Kate::Document::defaultEncoding()),
+ (cv ? cv->document()->url().url() : TQString::null),
+ TQString::null,m_mainWindow,i18n("Open File"));
+
+ uint lastID = 0;
+ for (KURL::List::Iterator i=r.URLs.begin(); i != r.URLs.end(); ++i)
+ lastID = openURL( *i, r.encoding, false );
+
+ if (lastID > 0)
+ activateView (lastID);
+ }
+}
+
+void KateViewManager::slotDocumentClose ()
+{
+ // no active view, do nothing
+ if (!activeView()) return;
+
+ // prevent close document if only one view alive and the document of
+ // it is not modified and empty !!!
+ if ( (KateDocManager::self()->documents() == 1)
+ && !activeView()->getDoc()->isModified()
+ && activeView()->getDoc()->url().isEmpty()
+ && (activeView()->getDoc()->length() == 0) )
+ {
+ activeView()->getDoc()->closeURL();
+ return;
+ }
+
+ // close document
+ KateDocManager::self()->closeDocument (activeView()->getDoc());
+}
+
+uint KateViewManager::openURL (const KURL &url, const TQString& encoding, bool activate, bool isTempFile )
+{
+ uint id = 0;
+ Kate::Document *doc = KateDocManager::self()->openURL (url, encoding, &id, isTempFile );
+
+ if (!doc->url().isEmpty())
+ m_mainWindow->fileOpenRecent->addURL( doc->url() );
+
+ if (activate)
+ activateView( id );
+
+ return id;
+}
+
+void KateViewManager::openURL (const KURL &url)
+{
+ openURL (url, TQString::null);
+}
+
+void KateViewManager::removeViewSpace (KateViewSpace *viewspace)
+{
+ if (m_currentContainer) {
+ m_currentContainer->removeViewSpace(viewspace);
+ }
+}
+
+void KateViewManager::slotCloseCurrentViewSpace()
+{
+ if (m_currentContainer) {
+ m_currentContainer->slotCloseCurrentViewSpace();
+ }
+}
+
+void KateViewManager::slotSplitViewSpaceVert()
+{
+ if (m_currentContainer) {
+ m_currentContainer->slotSplitViewSpaceVert();
+ }
+}
+
+void KateViewManager::slotSplitViewSpaceHoriz()
+{
+ if (m_currentContainer) {
+ m_currentContainer->slotSplitViewSpaceHoriz();
+ }
+}
+
+void KateViewManager::setShowFullPath( bool enable )
+{
+ showFullPath=enable;
+ for (uint i=0;i<m_viewSpaceContainerList.count();i++) {
+ m_viewSpaceContainerList.at(i)->setShowFullPath(enable);
+ }
+ m_mainWindow->slotWindowActivated ();
+ }
+
+/**
+ * session config functions
+ */
+// FIXME 3.0 - make those config goups more streamlined: "objN:objN..."
+void KateViewManager::saveViewConfiguration(TDEConfig *config,const TQString& grp)
+{
+ // Use the same group name for view configuration as usual for sessions.
+ // (When called by session manager grp is a 1-based index for the main window)
+ TQString group = grp;
+ bool ok = false;
+ int n = group.toInt( &ok );
+ if ( ok )
+ group = TQString( "MainWindow%1" ).arg( n-1 );
+
+ config->setGroup(group);
+ config->writeEntry("ViewSpaceContainers",m_viewSpaceContainerList.count());
+ config->writeEntry("Active ViewSpaceContainer", m_mainWindow->tabWidget()->currentPageIndex());
+ for (uint i=0;i<m_viewSpaceContainerList.count();i++) {
+ m_viewSpaceContainerList.at(i)->saveViewConfiguration(config,group+TQString(":ViewSpaceContainer-%1:").arg(i));
+ }
+}
+
+void KateViewManager::restoreViewConfiguration (TDEConfig *config, const TQString& grp)
+{
+ // Use the same group name for view configuration as usual for sessions.
+ // (When called by session manager grp is a 1-based index for the main window)
+ TQString group = grp;
+ bool ok = false;
+ int n = group.toInt( &ok );
+ if ( ok )
+ group = TQString( "MainWindow%1" ).arg( n-1 );
+
+ config->setGroup(group);
+ uint tabCount=config->readNumEntry("ViewSpaceContainers",0);
+ int activeOne=config->readNumEntry("Active ViewSpaceContainer",0);
+ if (tabCount==0) return;
+ m_viewSpaceContainerList.at(0)->restoreViewConfiguration(config,group+TQString(":ViewSpaceContainer-0:"));
+ for (uint i=1;i<tabCount;i++) {
+ slotNewTab();
+ m_viewSpaceContainerList.at(i)->restoreViewConfiguration(config,group+TQString(":ViewSpaceContainer-%1:").arg(i));
+ }
+
+ if (activeOne != m_mainWindow->tabWidget()->currentPageIndex())
+ m_mainWindow->tabWidget()->setCurrentPage (activeOne);
+
+ updateViewSpaceActions();
+}
+
+KateMainWindow *KateViewManager::mainWindow() {
+ return m_mainWindow;
+}
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/kateviewmanager.h b/kate/app/kateviewmanager.h
new file mode 100644
index 000000000..d16b59dc2
--- /dev/null
+++ b/kate/app/kateviewmanager.h
@@ -0,0 +1,154 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
+ Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __KATE_VIEWMANAGER_H__
+#define __KATE_VIEWMANAGER_H__
+
+#include "katemain.h"
+#include "../interfaces/viewmanager.h"
+
+#include <kate/view.h>
+#include <kate/document.h>
+#include <tqguardedptr.h>
+
+class KateMainWindow;
+class KateViewSpaceContainer;
+
+class TDEConfig;
+class TDEAction;
+
+class TQToolButton;
+
+class KateViewManager : public TQObject
+{
+ Q_OBJECT
+
+ public:
+ KateViewManager (KateMainWindow *parent);
+ ~KateViewManager ();
+
+ Kate::ViewManager *viewManager () const { return m_viewManager; };
+
+ KateViewSpaceContainer *activeContainer () { return m_currentContainer; }
+
+ TQPtrList<KateViewSpaceContainer> *containers() { return &m_viewSpaceContainerList; }
+
+ void updateViewSpaceActions ();
+
+ private:
+ /**
+ * create all actions needed for the view manager
+ */
+ void setupActions ();
+
+ public:
+ /* This will save the splitter configuration */
+ void saveViewConfiguration(TDEConfig *config,const TQString& group);
+
+ /* restore it */
+ void restoreViewConfiguration (TDEConfig *config,const TQString& group);
+
+ uint openURL (const KURL &url, const TQString& encoding, bool activate = true, bool isTempFile=false);
+
+ public slots:
+ void openURL (const KURL &url);
+
+ private:
+ void removeViewSpace (KateViewSpace *viewspace);
+
+ bool showFullPath;
+
+ public:
+ Kate::View* activeView ();
+ KateViewSpace* activeViewSpace ();
+
+ uint viewCount ();
+ uint viewSpaceCount ();
+
+ void setViewActivationBlocked (bool block);
+
+ public:
+ void closeViews(uint documentNumber);
+ KateMainWindow *mainWindow();
+
+ private slots:
+ void activateView ( Kate::View *view );
+ void activateSpace ( Kate::View* v );
+
+ void tabChanged(TQWidget*);
+
+ public slots:
+ bool getShowFullPath() const { return showFullPath; }
+
+ void activateView ( uint documentNumber );
+ void activateView ( int documentNumber ) { activateView((uint) documentNumber); };
+
+ void slotDocumentNew ();
+ void slotDocumentOpen ();
+ void slotDocumentClose ();
+
+ /** Splits the active viewspace horizontally */
+ void slotSplitViewSpaceHoriz ();
+ /** Splits the active viewspace vertically */
+ void slotSplitViewSpaceVert ();
+
+ void slotNewTab();
+ void slotCloseTab ();
+ void activateNextTab ();
+ void activatePrevTab ();
+
+ void slotCloseCurrentViewSpace();
+
+ void setActiveSpace ( KateViewSpace* vs );
+ void setActiveView ( Kate::View* view );
+
+ void setShowFullPath(bool enable);
+
+ void activateNextView();
+ void activatePrevView();
+
+ protected:
+ friend class KateViewSpaceContainer;
+
+ TQGuardedPtr<Kate::View> guiMergedView;
+
+ signals:
+ void statusChanged (Kate::View *, int, int, int, bool, int, const TQString &);
+ void statChanged ();
+ void viewChanged ();
+
+ private:
+ Kate::ViewManager *m_viewManager;
+ TQPtrList<KateViewSpaceContainer> m_viewSpaceContainerList;
+ KateViewSpaceContainer *m_currentContainer;
+
+ KateMainWindow *m_mainWindow;
+ bool m_init;
+
+ TQToolButton *m_closeTabButton;
+ TDEAction *m_closeView;
+ TDEAction *m_closeTab;
+ TDEAction *m_activateNextTab;
+ TDEAction *m_activatePrevTab;
+ TDEAction *goNext;
+ TDEAction *goPrev;
+};
+
+#endif
diff --git a/kate/app/kateviewspace.cpp b/kate/app/kateviewspace.cpp
new file mode 100644
index 000000000..ebc7a3b97
--- /dev/null
+++ b/kate/app/kateviewspace.cpp
@@ -0,0 +1,423 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
+ Copyright (C) 2001, 2005 Anders Lund <anders.lund@lund.tdcadsl.dk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "kateviewspace.h"
+#include "kateviewspace.moc"
+
+#include "katemainwindow.h"
+#include "kateviewspacecontainer.h"
+#include "katedocmanager.h"
+#include "kateapp.h"
+#include "katesession.h"
+
+#include <kiconloader.h>
+#include <tdelocale.h>
+#include <ksqueezedtextlabel.h>
+#include <tdeconfig.h>
+#include <kdebug.h>
+
+#include <tqwidgetstack.h>
+#include <tqpainter.h>
+#include <tqlabel.h>
+#include <tqcursor.h>
+#include <tqpopupmenu.h>
+#include <tqpixmap.h>
+
+//BEGIN KVSSBSep
+/*
+ "KateViewSpaceStatusBarSeparator"
+ A 2 px line to separate the statusbar from the view.
+ It is here to compensate for the lack of a frame in the view,
+ I think Kate looks very nice this way, as TQScrollView with frame
+ looks slightly clumsy...
+ Slight 3D effect. I looked for suitable TQStyle props or methods,
+ but found none, though maybe it should use TQStyle::PM_DefaultFrameWidth
+ for height (TRY!).
+ It does look a bit funny with flat styles (Light, .Net) as is,
+ but there are on methods to paint panel lines separately. And,
+ those styles tends to look funny on their own, as a light line
+ in a 3D frame next to a light contents widget is not functional.
+ Also, TQStatusBar is up to now completely ignorant to style.
+ -anders
+*/
+class KVSSBSep : public TQWidget {
+public:
+ KVSSBSep( KateViewSpace *parent=0) : TQWidget(parent)
+ {
+ setFixedHeight( 2 );
+ }
+protected:
+ void paintEvent( TQPaintEvent *e )
+ {
+ TQPainter p( this );
+ p.setPen( colorGroup().shadow() );
+ p.drawLine( e->rect().left(), 0, e->rect().right(), 0 );
+ p.setPen( ((KateViewSpace*)parentWidget())->isActiveSpace() ? colorGroup().light() : colorGroup().midlight() );
+ p.drawLine( e->rect().left(), 1, e->rect().right(), 1 );
+ }
+};
+//END KVSSBSep
+
+//BEGIN KateViewSpace
+KateViewSpace::KateViewSpace( KateViewSpaceContainer *viewManager,
+ TQWidget* parent, const char* name )
+ : TQVBox(parent, name),
+ m_viewManager( viewManager )
+{
+ mViewList.setAutoDelete(false);
+
+ stack = new TQWidgetStack( this );
+ setStretchFactor(stack, 1);
+ stack->setFocus();
+ //sep = new KVSSBSep( this );
+ mStatusBar = new KateVSStatusBar(this);
+ mIsActiveSpace = false;
+ mViewCount = 0;
+
+ setMinimumWidth (mStatusBar->minimumWidth());
+ m_group = TQString::null;
+}
+
+KateViewSpace::~KateViewSpace()
+{
+}
+
+void KateViewSpace::polish()
+{
+ mStatusBar->show();
+}
+
+void KateViewSpace::addView(Kate::View* v, bool show)
+{
+ // restore the config of this view if possible
+ if ( !m_group.isEmpty() )
+ {
+ TQString fn = v->getDoc()->url().prettyURL();
+ if ( ! fn.isEmpty() )
+ {
+ TQString vgroup = TQString("%1 %2").arg(m_group).arg(fn);
+
+ KateSession::Ptr as = KateSessionManager::self()->activeSession ();
+ if ( as->configRead() && as->configRead()->hasGroup( vgroup ) )
+ {
+ as->configRead()->setGroup( vgroup );
+ v->readSessionConfig ( as->configRead() );
+ }
+ }
+ }
+
+ uint id = mViewList.count();
+ stack->addWidget(v, id);
+ if (show) {
+ mViewList.append(v);
+ showView( v );
+ }
+ else {
+ Kate::View* c = mViewList.current();
+ mViewList.prepend( v );
+ showView( c );
+ }
+}
+
+void KateViewSpace::removeView(Kate::View* v)
+{
+ disconnect( v->getDoc(), TQT_SIGNAL(modifiedChanged()),
+ mStatusBar, TQT_SLOT(modifiedChanged()) );
+
+ bool active = ( v == currentView() );
+
+ mViewList.remove (v);
+ stack->removeWidget (v);
+
+ if ( ! active )
+ return;
+
+ if (currentView() != 0L)
+ showView(mViewList.current());
+ else if (mViewList.count() > 0)
+ showView(mViewList.last());
+}
+
+bool KateViewSpace::showView(Kate::View* v)
+{
+ return showView( v->getDoc()->documentNumber() );
+}
+
+bool KateViewSpace::showView(uint documentNumber)
+{
+ TQPtrListIterator<Kate::View> it (mViewList);
+ it.toLast();
+ for( ; it.current(); --it ) {
+ if (((Kate::Document*)it.current()->getDoc())->documentNumber() == documentNumber) {
+ if ( currentView() )
+ disconnect( currentView()->getDoc(), TQT_SIGNAL(modifiedChanged()),
+ mStatusBar, TQT_SLOT(modifiedChanged()) );
+
+ Kate::View* kv = it.current();
+ connect( kv->getDoc(), TQT_SIGNAL(modifiedChanged()),
+ mStatusBar, TQT_SLOT(modifiedChanged()) );
+
+ mViewList.removeRef( kv );
+ mViewList.append( kv );
+ stack->raiseWidget( kv );
+ kv->show();
+ mStatusBar->modifiedChanged();
+ return true;
+ }
+ }
+ return false;
+}
+
+
+Kate::View* KateViewSpace::currentView()
+{
+ if (mViewList.count() > 0)
+ return (Kate::View*)stack->visibleWidget();
+
+ return 0L;
+}
+
+bool KateViewSpace::isActiveSpace()
+{
+ return mIsActiveSpace;
+}
+
+void KateViewSpace::setActive( bool active, bool )
+{
+ mIsActiveSpace = active;
+
+ // change the statusbar palette and make sure it gets updated
+ TQPalette pal( palette() );
+ if ( ! active )
+ {
+ pal.setColor( TQColorGroup::Background, pal.active().mid() );
+ pal.setColor( TQColorGroup::Light, pal.active().midlight() );
+ }
+
+ mStatusBar->setPalette( pal );
+ mStatusBar->update();
+ //sep->update();
+}
+
+bool KateViewSpace::event( TQEvent *e )
+{
+ if ( e->type() == TQEvent::PaletteChange )
+ {
+ setActive( mIsActiveSpace );
+ return true;
+ }
+ return TQVBox::event( e );
+}
+
+void KateViewSpace::slotStatusChanged (Kate::View *view, int r, int c, int ovr, bool block, int mod, const TQString &msg)
+{
+ if ((TQWidgetStack *)view->parentWidget() != stack)
+ return;
+ mStatusBar->setStatus( r, c, ovr, block, mod, msg );
+}
+
+void KateViewSpace::saveConfig ( TDEConfig* config, int myIndex ,const TQString& viewConfGrp)
+{
+// kdDebug()<<"KateViewSpace::saveConfig("<<myIndex<<", "<<viewConfGrp<<") - currentView: "<<currentView()<<")"<<endl;
+ TQString group = TQString(viewConfGrp+"-ViewSpace %1").arg( myIndex );
+
+ config->setGroup (group);
+ config->writeEntry ("Count", mViewList.count());
+
+ if (currentView())
+ config->writeEntry( "Active View", currentView()->getDoc()->url().prettyURL() );
+
+ // Save file list, including cursor position in this instance.
+ TQPtrListIterator<Kate::View> it(mViewList);
+
+ int idx = 0;
+ for (; it.current(); ++it)
+ {
+ if ( !it.current()->getDoc()->url().isEmpty() )
+ {
+ long docListPos = it.current()->getDoc()->documentListPosition();
+ config->setGroup( group );
+ config->writeEntry( TQString("View %1").arg( (docListPos<0)?idx:docListPos ), it.current()->getDoc()->url().prettyURL() );
+
+ // view config, group: "ViewSpace <n> url"
+ TQString vgroup = TQString("%1 %2").arg(group).arg(it.current()->getDoc()->url().prettyURL());
+ config->setGroup( vgroup );
+ it.current()->writeSessionConfig( config );
+ }
+
+ idx++;
+ }
+}
+
+void KateViewSpace::modifiedOnDisc(Kate::Document *, bool, unsigned char)
+{
+ if ( currentView() )
+ mStatusBar->updateMod( currentView()->getDoc()->isModified() );
+}
+
+void KateViewSpace::restoreConfig ( KateViewSpaceContainer *viewMan, TDEConfig* config, const TQString &group )
+{
+ config->setGroup (group);
+ TQString fn = config->readEntry( "Active View" );
+
+ if ( !fn.isEmpty() )
+ {
+ Kate::Document *doc = KateDocManager::self()->findDocumentByUrl (KURL(fn));
+
+ if (doc)
+ {
+ // view config, group: "ViewSpace <n> url"
+ TQString vgroup = TQString("%1 %2").arg(group).arg(fn);
+ config->setGroup( vgroup );
+
+ viewMan->createView (doc);
+
+ Kate::View *v = viewMan->activeView ();
+
+ if (v)
+ v->readSessionConfig( config );
+ }
+ }
+
+ if (mViewList.isEmpty())
+ viewMan->createView (KateDocManager::self()->document(0));
+
+ m_group = group; // used for restroing view configs later
+}
+//END KateViewSpace
+
+//BEGIN KateVSStatusBar
+KateVSStatusBar::KateVSStatusBar ( KateViewSpace *parent, const char *name )
+ : KStatusBar( parent, name ),
+ m_viewSpace( parent )
+{
+ m_lineColLabel = new TQLabel( this );
+ addWidget( m_lineColLabel, 0, false );
+ m_lineColLabel->setAlignment( Qt::AlignCenter );
+ m_lineColLabel->installEventFilter( this );
+
+ m_modifiedLabel = new TQLabel( TQString(" "), this );
+ addWidget( m_modifiedLabel, 0, false );
+ m_modifiedLabel->setAlignment( Qt::AlignCenter );
+ m_modifiedLabel->installEventFilter( this );
+
+ m_insertModeLabel = new TQLabel( i18n(" INS "), this );
+ addWidget( m_insertModeLabel, 0, false );
+ m_insertModeLabel->setAlignment( Qt::AlignCenter );
+ m_insertModeLabel->installEventFilter( this );
+
+ m_selectModeLabel = new TQLabel( i18n(" NORM "), this );
+ addWidget( m_selectModeLabel, 0, false );
+ m_selectModeLabel->setAlignment( Qt::AlignCenter );
+ m_selectModeLabel->installEventFilter( this );
+
+ m_fileNameLabel=new KSqueezedTextLabel( this );
+ addWidget( m_fileNameLabel, 1, true );
+ m_fileNameLabel->setMinimumSize( 0, 0 );
+ m_fileNameLabel->setSizePolicy(TQSizePolicy( TQSizePolicy::Ignored, TQSizePolicy::Fixed ));
+ m_fileNameLabel->setAlignment( /*Qt::AlignRight*/Qt::AlignLeft );
+ m_fileNameLabel->installEventFilter( this );
+
+ installEventFilter( this );
+ m_modPm = SmallIcon("modified");
+ m_modDiscPm = SmallIcon("modonhd");
+ m_modmodPm = SmallIcon("modmod");
+ m_noPm = SmallIcon("null");
+}
+
+KateVSStatusBar::~KateVSStatusBar ()
+{
+}
+
+void KateVSStatusBar::setStatus( int r, int c, int ovr, bool block, int, const TQString &msg )
+{
+ m_lineColLabel->setText(
+ i18n(" Line: %1 Col: %2 ").arg(TDEGlobal::locale()->formatNumber(r+1, 0))
+ .arg(TDEGlobal::locale()->formatNumber(c+1, 0)) );
+
+ if (ovr == 0)
+ m_insertModeLabel->setText( i18n(" R/O ") );
+ else if (ovr == 1)
+ m_insertModeLabel->setText( i18n(" OVR ") );
+ else if (ovr == 2)
+ m_insertModeLabel->setText( i18n(" INS ") );
+
+// updateMod( mod );
+
+ m_selectModeLabel->setText( block ? i18n(" BLK ") : i18n(" NORM ") );
+
+ m_fileNameLabel->setText( msg );
+}
+
+void KateVSStatusBar::updateMod( bool mod )
+{
+ Kate::View *v = m_viewSpace->currentView();
+ if ( v )
+ {
+ const KateDocumentInfo *info
+ = KateDocManager::self()->documentInfo ( v->getDoc() );
+
+ bool modOnHD = info && info->modifiedOnDisc;
+
+ m_modifiedLabel->setPixmap(
+ mod ?
+ info && modOnHD ?
+ m_modmodPm :
+ m_modPm :
+ info && modOnHD ?
+ m_modDiscPm :
+ m_noPm
+ );
+ }
+}
+
+void KateVSStatusBar::modifiedChanged()
+{
+ Kate::View *v = m_viewSpace->currentView();
+ if ( v )
+ updateMod( v->getDoc()->isModified() );
+}
+
+void KateVSStatusBar::showMenu()
+{
+ TDEMainWindow* mainWindow = static_cast<TDEMainWindow*>( topLevelWidget() );
+ TQPopupMenu* menu = static_cast<TQPopupMenu*>( mainWindow->factory()->container("viewspace_popup", mainWindow ) );
+
+ if (menu)
+ menu->exec(TQCursor::pos());
+}
+
+bool KateVSStatusBar::eventFilter(TQObject*,TQEvent *e)
+{
+ if (e->type()==TQEvent::MouseButtonPress)
+ {
+ if ( m_viewSpace->currentView() )
+ m_viewSpace->currentView()->setFocus();
+
+ if ( ((TQMouseEvent*)e)->button()==Qt::RightButton)
+ showMenu();
+
+ return true;
+ }
+
+ return false;
+}
+//END KateVSStatusBar
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/kateviewspace.h b/kate/app/kateviewspace.h
new file mode 100644
index 000000000..0407d35fe
--- /dev/null
+++ b/kate/app/kateviewspace.h
@@ -0,0 +1,121 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
+ Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __KATE_VIEWSPACE_H__
+#define __KATE_VIEWSPACE_H__
+
+#include "katemain.h"
+
+#include <kate/view.h>
+#include <kate/document.h>
+
+#include <tqptrlist.h>
+#include <tqwidget.h>
+#include <tqvbox.h>
+#include <kstatusbar.h>
+
+class KVSSBSep;
+
+class TDEConfig;
+class KSqueezedTextLabel;
+class KateViewSpaceContainer;
+
+class KateVSStatusBar : public KStatusBar
+{
+ Q_OBJECT
+
+ public:
+ KateVSStatusBar ( KateViewSpace *parent = 0L, const char *name = 0L );
+ virtual ~KateVSStatusBar ();
+
+ public slots:
+ void setStatus( int r, int c, int ovr, bool block, int mod, const TQString &msg );
+ void updateMod( bool );
+ /**
+ * changed the modified icon according to document state.
+ * @since Kate 2.4
+ */
+ void modifiedChanged();
+
+ protected:
+ virtual bool eventFilter (TQObject*,TQEvent *);
+ virtual void showMenu ();
+
+ private:
+ TQLabel* m_lineColLabel;
+ TQLabel* m_modifiedLabel;
+ TQLabel* m_insertModeLabel;
+ TQLabel* m_selectModeLabel;
+ KSqueezedTextLabel* m_fileNameLabel;
+ TQPixmap m_modPm, m_modDiscPm, m_modmodPm, m_noPm;
+ class KateViewSpace *m_viewSpace;
+};
+
+class KateViewSpace : public TQVBox
+{
+ friend class KateViewSpaceContainer;
+ friend class KateVSStatusBar;
+
+ Q_OBJECT
+
+ public:
+ KateViewSpace(KateViewSpaceContainer *, TQWidget* parent=0, const char* name=0);
+ ~KateViewSpace();
+ bool isActiveSpace();
+ void setActive(bool b, bool showled=false);
+ TQWidgetStack* stack;
+ void addView(Kate::View* v, bool show=true);
+ void removeView(Kate::View* v);
+ bool showView(Kate::View* v);
+ bool showView(uint docID);
+ Kate::View* currentView();
+ int viewCount() const { return mViewList.count(); }
+
+ void saveConfig (TDEConfig* config, int myIndex,const TQString& viewConfGrp);
+ void restoreConfig ( class KateViewSpaceContainer *viewMan, TDEConfig* config, const TQString &group );
+
+
+ protected:
+ /** reimplemented to catch TQEvent::PaletteChange,
+ since we use a modified palette for the statusbar */
+ bool event( TQEvent * );
+
+ private:
+ bool mIsActiveSpace;
+ KateVSStatusBar* mStatusBar;
+ TQLabel* l;
+ TQPixmap i_active;
+ TQPixmap i_empty;
+ TQPtrList<Kate::View> mViewList;
+ int mViewCount;
+ KVSSBSep *sep;
+ KateViewSpaceContainer *m_viewManager;
+ TQString m_group;
+
+ private slots:
+ void slotStatusChanged (Kate::View *view, int r, int c, int ovr, bool block, int mod, const TQString &msg);
+
+ public slots:
+ void polish();
+ void modifiedOnDisc(Kate::Document *, bool, unsigned char);
+};
+
+#endif
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/kateviewspacecontainer.cpp b/kate/app/kateviewspacecontainer.cpp
new file mode 100644
index 000000000..de9309f5e
--- /dev/null
+++ b/kate/app/kateviewspacecontainer.cpp
@@ -0,0 +1,758 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
+ Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+//BEGIN Includes
+#include "kateviewspacecontainer.h"
+#include "kateviewspacecontainer.moc"
+
+#include "katetabwidget.h"
+#include "katemainwindow.h"
+#include "katedocmanager.h"
+#include "kateviewmanager.h"
+#include "kateviewspace.h"
+
+#include <dcopclient.h>
+#include <tdeaction.h>
+#include <tdecmdlineargs.h>
+#include <kdebug.h>
+#include <tdediroperator.h>
+#include <kdockwidget.h>
+#include <kencodingfiledialog.h>
+#include <kiconloader.h>
+#include <tdeglobal.h>
+#include <tdelocale.h>
+#include <tdetoolbar.h>
+#include <tdemessagebox.h>
+#include <ksimpleconfig.h>
+#include <kstdaction.h>
+#include <kstandarddirs.h>
+#include <tdeglobalsettings.h>
+#include <kstringhandler.h>
+
+#include <tdetexteditor/encodinginterface.h>
+
+#include <tqlayout.h>
+#include <tqobjectlist.h>
+#include <tqstringlist.h>
+#include <tqvbox.h>
+#include <tqtimer.h>
+#include <tqfileinfo.h>
+
+//END Includes
+
+KateViewSpaceContainer::KateViewSpaceContainer (TQWidget *parent, KateViewManager *viewManager)
+ : TQVBox (parent)
+ , m_viewManager(viewManager)
+ , m_blockViewCreationAndActivation (false)
+ , m_activeViewRunning (false)
+ , m_pendingViewCreation(false)
+{
+ // no memleaks
+ m_viewList.setAutoDelete(true);
+ m_viewSpaceList.setAutoDelete(true);
+
+ KateViewSpace* vs = new KateViewSpace( this, this );
+ connect(this, TQT_SIGNAL(statusChanged(Kate::View *, int, int, int, bool, int, const TQString&)), vs, TQT_SLOT(slotStatusChanged(Kate::View *, int, int, int, bool, int, const TQString&)));
+ vs->setActive( true );
+ m_viewSpaceList.append(vs);
+ connect( this, TQT_SIGNAL(viewChanged()), this, TQT_SLOT(slotViewChanged()) );
+ connect(KateDocManager::self(), TQT_SIGNAL(initialDocumentReplaced()), this, TQT_SIGNAL(viewChanged()));
+
+ connect(KateDocManager::self(),TQT_SIGNAL(documentCreated(Kate::Document *)),this,TQT_SLOT(documentCreated(Kate::Document *)));
+ connect(KateDocManager::self(),TQT_SIGNAL(documentDeleted(uint)),this,TQT_SLOT(documentDeleted(uint)));
+}
+
+KateViewSpaceContainer::~KateViewSpaceContainer ()
+{
+ m_viewList.setAutoDelete(false);
+ m_viewSpaceList.setAutoDelete(false);
+}
+
+void KateViewSpaceContainer::documentCreated (Kate::Document *doc)
+{
+ if (m_blockViewCreationAndActivation) return;
+
+ if (!activeView())
+ activateView (doc->documentNumber());
+}
+
+void KateViewSpaceContainer::documentDeleted (uint)
+{
+ if (m_blockViewCreationAndActivation) return;
+
+ // just for the case we close a document out of many and this was the active one
+ // if all docs are closed, this will be handled by the documentCreated
+ if (!activeView() && (KateDocManager::self()->documents() > 0))
+ createView (KateDocManager::self()->document(KateDocManager::self()->documents()-1));
+}
+
+bool KateViewSpaceContainer::createView ( Kate::Document *doc )
+{
+ if (m_blockViewCreationAndActivation) return false;
+
+ // create doc
+ if (!doc)
+ doc = KateDocManager::self()->createDoc ();
+
+ // create view
+ Kate::View *view = (Kate::View *) doc->createView (this, 0L);
+
+ m_viewList.append (view);
+
+ // disable settings dialog action
+ view->actionCollection()->remove (view->actionCollection()->action( "set_confdlg" ));
+
+ // popup menu
+ view->installPopup ((TQPopupMenu*)(mainWindow()->factory()->container("tdetexteditor_popup", mainWindow())) );
+
+ connect(view->getDoc(),TQT_SIGNAL(nameChanged(Kate::Document *)),this,TQT_SLOT(statusMsg()));
+ connect(view,TQT_SIGNAL(cursorPositionChanged()),this,TQT_SLOT(statusMsg()));
+ connect(view,TQT_SIGNAL(newStatus()),this,TQT_SLOT(statusMsg()));
+ connect(view->getDoc(), TQT_SIGNAL(undoChanged()), this, TQT_SLOT(statusMsg()));
+ connect(view,TQT_SIGNAL(dropEventPass(TQDropEvent *)), mainWindow(),TQT_SLOT(slotDropEvent(TQDropEvent *)));
+ connect(view,TQT_SIGNAL(gotFocus(Kate::View *)),this,TQT_SLOT(activateSpace(Kate::View *)));
+
+ activeViewSpace()->addView( view );
+ activateView( view );
+ connect( doc, TQT_SIGNAL(modifiedOnDisc(Kate::Document *, bool, unsigned char)),
+ activeViewSpace(), TQT_SLOT(modifiedOnDisc(Kate::Document *, bool, unsigned char)) );
+
+ return true;
+}
+
+bool KateViewSpaceContainer::deleteView (Kate::View *view, bool delViewSpace)
+{
+ if (!view) return true;
+
+ KateViewSpace *viewspace = (KateViewSpace *)view->parentWidget()->parentWidget();
+
+ viewspace->removeView (view);
+
+ mainWindow()->guiFactory ()->removeClient (view);
+
+ // remove view from list and memory !!
+ m_viewList.remove (view);
+
+ if (delViewSpace)
+ if ( viewspace->viewCount() == 0 )
+ removeViewSpace( viewspace );
+
+ return true;
+}
+
+KateViewSpace* KateViewSpaceContainer::activeViewSpace ()
+{
+ TQPtrListIterator<KateViewSpace> it(m_viewSpaceList);
+
+ for (; it.current(); ++it)
+ {
+ if ( it.current()->isActiveSpace() )
+ return it.current();
+ }
+
+ if (m_viewSpaceList.count() > 0)
+ {
+ m_viewSpaceList.first()->setActive( true );
+ return m_viewSpaceList.first();
+ }
+
+ return 0L;
+}
+
+Kate::View* KateViewSpaceContainer::activeView ()
+{
+ if (m_activeViewRunning)
+ return 0L;
+
+ m_activeViewRunning = true;
+
+ for (TQPtrListIterator<Kate::View> it(m_viewList); it.current(); ++it)
+ {
+ if ( it.current()->isActive() )
+ {
+ m_activeViewRunning = false;
+ return it.current();
+ }
+ }
+
+ // if we get to here, no view isActive()
+ // first, try to get one from activeViewSpace()
+ KateViewSpace* vs;
+ if ( (vs = activeViewSpace()) )
+ {
+ if ( vs->currentView() )
+ {
+ activateView (vs->currentView());
+
+ m_activeViewRunning = false;
+ return vs->currentView();
+ }
+ }
+
+ // last attempt: just pick first
+ if (m_viewList.count() > 0)
+ {
+ activateView (m_viewList.first());
+
+ m_activeViewRunning = false;
+ return m_viewList.first();
+ }
+
+ m_activeViewRunning = false;
+
+ // no views exists!
+ return 0L;
+}
+
+void KateViewSpaceContainer::setActiveSpace ( KateViewSpace* vs )
+{
+ if (activeViewSpace())
+ activeViewSpace()->setActive( false );
+
+ vs->setActive( true, viewSpaceCount() > 1 );
+}
+
+void KateViewSpaceContainer::setActiveView ( Kate::View* view )
+{
+ if (activeView())
+ activeView()->setActive( false );
+
+ view->setActive( true );
+}
+
+void KateViewSpaceContainer::activateSpace (Kate::View* v)
+{
+ if (!v) return;
+
+ KateViewSpace* vs = (KateViewSpace*)v->parentWidget()->parentWidget();
+
+ if (!vs->isActiveSpace()) {
+ setActiveSpace (vs);
+ activateView(v);
+ }
+}
+
+void KateViewSpaceContainer::reactivateActiveView() {
+ Kate::View *view=activeView();
+ if (view) {
+ view->setActive(false);
+ activateView(view);
+ } else if (m_pendingViewCreation) {
+ m_pendingViewCreation=false;
+ disconnect(m_pendingDocument,TQT_SIGNAL(nameChanged(Kate::Document *)),this,TQT_SLOT(slotPendingDocumentNameChanged()));
+ createView(m_pendingDocument);
+ }
+}
+
+void KateViewSpaceContainer::activateView ( Kate::View *view )
+{
+ if (!view) return;
+
+ if (!view->isActive())
+ {
+ if ( !activeViewSpace()->showView (view) )
+ {
+ // since it wasn't found, give'em a new one
+ createView ( view->getDoc() );
+ return;
+ }
+
+ setActiveView (view);
+ m_viewList.findRef (view);
+
+ mainWindow()->toolBar ()->setUpdatesEnabled (false);
+
+ if (m_viewManager->guiMergedView)
+ mainWindow()->guiFactory()->removeClient (m_viewManager->guiMergedView );
+
+ m_viewManager->guiMergedView = view;
+
+ if (!m_blockViewCreationAndActivation)
+ mainWindow()->guiFactory ()->addClient( view );
+
+ mainWindow()->toolBar ()->setUpdatesEnabled (true);
+
+ statusMsg();
+
+ emit viewChanged ();
+ }
+
+ KateDocManager::self()->setActiveDocument(view->getDoc());
+}
+
+void KateViewSpaceContainer::activateView( uint documentNumber )
+{
+ if ( activeViewSpace()->showView(documentNumber) ) {
+ activateView( activeViewSpace()->currentView() );
+ }
+ else
+ {
+ TQPtrListIterator<Kate::View> it(m_viewList);
+ for ( ;it.current(); ++it)
+ {
+ if ( it.current()->getDoc()->documentNumber() == documentNumber )
+ {
+ createView( it.current()->getDoc() );
+ return;
+ }
+ }
+
+ Kate::Document *d = (Kate::Document *)KateDocManager::self()->documentWithID(documentNumber);
+ createView (d);
+ }
+}
+
+uint KateViewSpaceContainer::viewCount ()
+{
+ return m_viewList.count();
+}
+
+uint KateViewSpaceContainer::viewSpaceCount ()
+{
+ return m_viewSpaceList.count();
+}
+
+void KateViewSpaceContainer::slotViewChanged()
+{
+ if ( activeView() && !activeView()->hasFocus())
+ activeView()->setFocus();
+}
+
+void KateViewSpaceContainer::activateNextView()
+{
+ uint i = m_viewSpaceList.find (activeViewSpace())+1;
+
+ if (i >= m_viewSpaceList.count())
+ i=0;
+
+ setActiveSpace (m_viewSpaceList.at(i));
+ activateView(m_viewSpaceList.at(i)->currentView());
+}
+
+void KateViewSpaceContainer::activatePrevView()
+{
+ int i = m_viewSpaceList.find (activeViewSpace())-1;
+
+ if (i < 0)
+ i=m_viewSpaceList.count()-1;
+
+ setActiveSpace (m_viewSpaceList.at(i));
+ activateView(m_viewSpaceList.at(i)->currentView());
+}
+
+void KateViewSpaceContainer::closeViews(uint documentNumber)
+{
+ TQPtrList<Kate::View> closeList;
+
+ for (uint z=0 ; z < m_viewList.count(); z++)
+ {
+ Kate::View* current = m_viewList.at(z);
+ if ( current->getDoc()->documentNumber() == documentNumber )
+ {
+ closeList.append (current);
+ }
+ }
+
+ while ( !closeList.isEmpty() )
+ {
+ Kate::View *view = closeList.first();
+ deleteView (view, true);
+ closeList.removeFirst();
+ }
+
+ if (m_blockViewCreationAndActivation) return;
+ TQTimer::singleShot(0,this,TQT_SIGNAL(viewChanged()));
+ //emit m_viewManager->viewChanged ();
+}
+
+void KateViewSpaceContainer::slotPendingDocumentNameChanged() {
+ TQString c;
+ if (m_pendingDocument->url().isEmpty() || (!showFullPath))
+ {
+ c = m_pendingDocument->docName();
+ }
+ else
+ {
+ c = m_pendingDocument->url().prettyURL();
+ }
+ setCaption(KStringHandler::lsqueeze(c,32));
+}
+
+void KateViewSpaceContainer::statusMsg ()
+{
+ if (!activeView()) return;
+
+ Kate::View* v = activeView();
+
+ bool readOnly = !v->getDoc()->isReadWrite();
+ uint config = v->getDoc()->configFlags();
+
+ int ovr = 0;
+ if (readOnly)
+ ovr = 0;
+ else
+ {
+ if (config & Kate::Document::cfOvr)
+ {
+ ovr=1;
+ }
+ else
+ {
+ ovr=2;
+ }
+ }
+
+ int mod = (int)v->getDoc()->isModified();
+ bool block=v->getDoc()->blockSelectionMode();
+
+ TQString c;
+ if (v->getDoc()->url().isEmpty() || (!showFullPath))
+ {
+ c = v->getDoc()->docName();
+ }
+ else
+ {
+ c = v->getDoc()->url().prettyURL();
+ }
+
+ m_viewManager->mainWindow()->tabWidget()->changeTab (this, KStringHandler::lsqueeze(c,32));
+ emit statusChanged (v, v->cursorLine(), v->cursorColumn(), ovr,block, mod, KStringHandler::lsqueeze(c,64));
+ emit statChanged ();
+}
+
+void KateViewSpaceContainer::splitViewSpace( KateViewSpace* vs,
+ bool isHoriz,
+ bool atTop)
+{
+// kdDebug(13001)<<"splitViewSpace()"<<endl;
+
+ if (!activeView()) return;
+ if (!vs) vs = activeViewSpace();
+
+ bool isFirstTime = vs->parentWidget() == this;
+
+ TQValueList<int> psizes;
+ if ( ! isFirstTime )
+ if ( TQSplitter *ps = static_cast<TQSplitter*>(vs->parentWidget()->tqt_cast(TQSPLITTER_OBJECT_NAME_STRING)) )
+ psizes = ps->sizes();
+
+ Qt::Orientation o = isHoriz ? Qt::Vertical : Qt::Horizontal;
+ KateMDI::Splitter* s = new KateMDI::Splitter(o, vs->parentWidget());
+ s->setOpaqueResize( TDEGlobalSettings::opaqueResize() );
+
+ if (! isFirstTime) {
+ // anders: make sure the split' viewspace is always
+ // correctly positioned.
+ // If viewSpace is the first child, the new splitter must be moveToFirst'd
+ if ( !((KateMDI::Splitter*)vs->parentWidget())->isLastChild( vs ) )
+ ((KateMDI::Splitter*)s->parentWidget())->moveToFirst( s );
+ }
+ vs->reparent( s, 0, TQPoint(), true );
+ KateViewSpace* vsNew = new KateViewSpace( this, s );
+
+ if (atTop)
+ s->moveToFirst( vsNew );
+
+ if (!isFirstTime)
+ if (TQSplitter *ps = static_cast<TQSplitter*>(s->parentWidget()->tqt_cast(TQSPLITTER_OBJECT_NAME_STRING)) )
+ ps->setSizes( psizes );
+
+ s->show();
+
+ TQValueList<int> sizes;
+ int space = 50;//isHoriz ? s->parentWidget()->height()/2 : s->parentWidget()->width()/2;
+ sizes << space << space;
+ s->setSizes( sizes );
+
+ connect(this, TQT_SIGNAL(statusChanged(Kate::View *, int, int, int, bool, int, const TQString &)), vsNew, TQT_SLOT(slotStatusChanged(Kate::View *, int, int,int, bool, int, const TQString &)));
+ m_viewSpaceList.append( vsNew );
+ activeViewSpace()->setActive( false );
+ vsNew->setActive( true, true );
+ vsNew->show();
+
+ createView (activeView()->getDoc());
+
+ if (this == m_viewManager->activeContainer())
+ m_viewManager->updateViewSpaceActions ();
+
+// kdDebug(13001)<<"splitViewSpace() - DONE!"<<endl;
+}
+
+void KateViewSpaceContainer::removeViewSpace (KateViewSpace *viewspace)
+{
+ // abort if viewspace is 0
+ if (!viewspace) return;
+
+ // abort if this is the last viewspace
+ if (m_viewSpaceList.count() < 2) return;
+
+ KateMDI::Splitter* p = (KateMDI::Splitter*)viewspace->parentWidget();
+
+ // find out if it is the first child for repositioning
+ // see below
+ bool pIsFirst = false;
+
+ // save some size information
+ KateMDI::Splitter* pp=0L;
+ TQValueList<int> ppsizes;
+ if (m_viewSpaceList.count() > 2 && p->parentWidget() != this)
+ {
+ pp = (KateMDI::Splitter*)p->parentWidget();
+ ppsizes = pp->sizes();
+ pIsFirst = !pp->isLastChild( p ); // simple logic, right-
+ }
+
+ // Figure out where to put views that are still needed
+ KateViewSpace* next;
+ if (m_viewSpaceList.find(viewspace) == 0)
+ next = m_viewSpaceList.next();
+ else
+ next = m_viewSpaceList.prev();
+
+ // Reparent views in viewspace that are last views, delete the rest.
+ int vsvc = viewspace->viewCount();
+ while (vsvc > 0)
+ {
+ if (viewspace->currentView())
+ {
+ Kate::View* v = viewspace->currentView();
+
+ if (v->isLastView())
+ {
+ viewspace->removeView(v);
+ next->addView( v, false );
+ }
+ else
+ {
+ deleteView( v, false );
+ }
+ }
+ vsvc = viewspace->viewCount();
+ }
+
+ m_viewSpaceList.remove( viewspace );
+
+ // reparent the other sibling of the parent.
+ while (!p->childrenListObject().isEmpty())
+ {
+ TQWidget* other = ((TQWidget *)(( TQPtrList<TQObject>)p->childrenListObject()).first());
+
+ other->reparent( p->parentWidget(), 0, TQPoint(), true );
+ // We also need to find the right viewspace to become active
+ if (pIsFirst)
+ ((KateMDI::Splitter*)p->parentWidget())->moveToFirst( other );
+ if ( other->isA("KateViewSpace") ) {
+ setActiveSpace( (KateViewSpace*)other );
+ }
+ else {
+ TQObjectList* l = other->queryList( "KateViewSpace" );
+ if ( l->first() != 0 ) { // I REALLY hope so!
+ setActiveSpace( (KateViewSpace*)l->first() );
+ }
+ delete l;
+ }
+ }
+
+ delete p;
+
+ if (!ppsizes.isEmpty())
+ pp->setSizes( ppsizes );
+
+ // find the view that is now active.
+ Kate::View* v = activeViewSpace()->currentView();
+ if ( v )
+ activateView( v );
+
+ if (this == m_viewManager->activeContainer())
+ m_viewManager->updateViewSpaceActions ();
+
+ emit viewChanged();
+}
+
+void KateViewSpaceContainer::slotCloseCurrentViewSpace()
+{
+ removeViewSpace(activeViewSpace());
+}
+
+void KateViewSpaceContainer::setShowFullPath( bool enable )
+{
+ showFullPath = enable;
+ statusMsg ();
+ //m_mainWindow->slotWindowActivated ();
+}
+
+/**
+ * session config functions
+ */
+
+void KateViewSpaceContainer::saveViewConfiguration(TDEConfig *config,const TQString& group)
+{
+ bool weHaveSplittersAlive (viewSpaceCount() > 1);
+
+ config->setGroup (group); //"View Configuration");
+ config->writeEntry ("Splitters", weHaveSplittersAlive);
+
+ // no splitters around
+ if (!weHaveSplittersAlive)
+ {
+ config->writeEntry("Active Viewspace", 0);
+ m_viewSpaceList.first()->saveConfig ( config, 0,group );
+
+ return;
+ }
+
+ // I need the first splitter, the one which has this as parent.
+ KateMDI::Splitter* s;
+ TQObjectList *l = queryList("KateMDI::Splitter", 0, false, false);
+ TQObjectListIt it( *l );
+
+ if ( (s = (KateMDI::Splitter*)it.current()) != 0 )
+ saveSplitterConfig( s, 0, config , group);
+
+ delete l;
+}
+
+void KateViewSpaceContainer::restoreViewConfiguration (TDEConfig *config, const TQString& group)
+{
+ config->setGroup(group);
+ //config->setGroup ("View Configuration");
+
+ // no splitters around, ohhh :()
+ if (!config->readBoolEntry ("Splitters"))
+ {
+ // only add the new views needed, let the old stay, won't hurt if one around
+ m_viewSpaceList.first ()->restoreConfig (this, config, TQString(group+"-ViewSpace 0"));
+ }
+ else
+ {
+ // send all views + their gui to **** ;)
+ for (uint i=0; i < m_viewList.count(); i++)
+ mainWindow()->guiFactory ()->removeClient (m_viewList.at(i));
+
+ m_viewList.clear ();
+
+ // cu viewspaces
+ m_viewSpaceList.clear();
+
+ // call restoreSplitter for Splitter 0
+ restoreSplitter( config, TQString(group+"-Splitter 0"), this,group );
+ }
+
+ // finally, make the correct view active.
+ config->setGroup (group);
+/*
+ KateViewSpace *vs = m_viewSpaceList.at( config->readNumEntry("Active ViewSpace") );
+ if ( vs )
+ activateSpace( vs->currentView() );
+ */
+}
+
+
+void KateViewSpaceContainer::saveSplitterConfig( KateMDI::Splitter* s, int idx, TDEConfig* config, const TQString& viewConfGrp )
+{
+ TQString grp = TQString(viewConfGrp+"-Splitter %1").arg(idx);
+ config->setGroup(grp);
+
+ // Save sizes, orient, children for this splitter
+ config->writeEntry( "Sizes", s->sizes() );
+ config->writeEntry( "Orientation", s->orientation() );
+
+ TQStringList childList;
+ // a katesplitter has two children, of which one may be a KateSplitter.
+ const TQObjectList l = s->childrenListObject();
+ TQObjectListIt it( l );
+ TQObject* obj;
+ for (; it.current(); ++it) {
+ obj = it.current();
+ TQString n; // name for child list, see below
+ // For KateViewSpaces, ask them to save the file list.
+ if ( obj->isA("KateViewSpace") ) {
+ n = TQString(viewConfGrp+"-ViewSpace %1").arg( m_viewSpaceList.find((KateViewSpace*)obj) );
+ ((KateViewSpace*)obj)->saveConfig ( config, m_viewSpaceList.find((KateViewSpace*)obj), viewConfGrp);
+ // save active viewspace
+ if ( ((KateViewSpace*)obj)->isActiveSpace() ) {
+ config->setGroup(viewConfGrp);
+ config->writeEntry("Active Viewspace", m_viewSpaceList.find((KateViewSpace*)obj) );
+ }
+ }
+ // For KateSplitters, recurse
+ else if ( obj->isA("KateMDI::Splitter") ) {
+ idx++;
+ saveSplitterConfig( (KateMDI::Splitter*)obj, idx, config,viewConfGrp);
+ n = TQString(viewConfGrp+"-Splitter %1").arg( idx );
+ }
+ // make sure list goes in right place!
+ if (!n.isEmpty()) {
+ if ( childList.count() > 0 && ! s->isLastChild( (TQWidget*)obj ) )
+ childList.prepend( n );
+ else
+ childList.append( n );
+ }
+ }
+
+ // reset config group.
+ config->setGroup(grp);
+ config->writeEntry("Children", childList);
+}
+
+void KateViewSpaceContainer::restoreSplitter( TDEConfig* config, const TQString &group, TQWidget* parent, const TQString& viewConfGrp)
+{
+ config->setGroup( group );
+
+ KateMDI::Splitter* s = new KateMDI::Splitter((Qt::Orientation)config->readNumEntry("Orientation"), parent);
+
+ TQStringList children = config->readListEntry( "Children" );
+ for (TQStringList::Iterator it=children.begin(); it!=children.end(); ++it)
+ {
+ // for a viewspace, create it and open all documents therein.
+ if ( (*it).startsWith(viewConfGrp+"-ViewSpace") )
+ {
+ KateViewSpace* vs = new KateViewSpace( this, s );
+
+ connect(this, TQT_SIGNAL(statusChanged(Kate::View *, int, int, int, bool, int, const TQString &)), vs, TQT_SLOT(slotStatusChanged(Kate::View *, int, int, int, bool, int, const TQString &)));
+
+ if (m_viewSpaceList.isEmpty())
+ vs->setActive (true);
+
+ m_viewSpaceList.append( vs );
+
+ vs->show();
+ setActiveSpace( vs );
+
+ vs->restoreConfig (this, config, *it);
+ }
+ else
+ {
+ // for a splitter, recurse.
+ restoreSplitter( config, TQString(*it), s, viewConfGrp );
+ }
+ }
+
+ // set sizes
+ config->setGroup( group );
+ s->setSizes( config->readIntListEntry("Sizes") );
+ s->show();
+}
+
+KateMainWindow *KateViewSpaceContainer::mainWindow() {
+ return m_viewManager->mainWindow();
+}
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/app/kateviewspacecontainer.h b/kate/app/kateviewspacecontainer.h
new file mode 100644
index 000000000..2f1fa5372
--- /dev/null
+++ b/kate/app/kateviewspacecontainer.h
@@ -0,0 +1,161 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
+ Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __KATE_VIEWSPACE_CONTAINER_H__
+#define __KATE_VIEWSPACE_CONTAINER_H__
+
+#include "katemain.h"
+#include "../interfaces/viewmanager.h"
+
+#include <kate/view.h>
+#include <kate/document.h>
+
+#include "katemdi.h"
+
+class TDEConfig;
+class KateMainWindow;
+
+class KateViewSpaceContainer: public TQVBox
+{
+ Q_OBJECT
+
+ friend class KateViewSpace;
+ friend class KateVSStatusBar;
+
+ public:
+ KateViewSpaceContainer (TQWidget *parent, KateViewManager *viewManager);
+
+ ~KateViewSpaceContainer ();
+
+ inline TQPtrList<Kate::View> &viewList () { return m_viewList; };
+
+ public:
+ /* This will save the splitter configuration */
+ void saveViewConfiguration(TDEConfig *config,const TQString& group);
+
+ /* restore it */
+ void restoreViewConfiguration (TDEConfig *config,const TQString& group);
+
+ private:
+ /**
+ * create and activate a new view for doc, if doc == 0, then
+ * create a new document
+ */
+ bool createView ( Kate::Document *doc =0L );
+
+ bool deleteView ( Kate::View *view, bool delViewSpace = true);
+
+ void moveViewtoSplit (Kate::View *view);
+ void moveViewtoStack (Kate::View *view);
+
+ /* Save the configuration of a single splitter.
+ * If child splitters are found, it calls it self with those as the argument.
+ * If a viewspace child is found, it is asked to save its filelist.
+ */
+ void saveSplitterConfig(KateMDI::Splitter* s, int idx=0, TDEConfig* config=0L, const TQString& viewConfGrp="");
+
+ /** Restore a single splitter.
+ * This is all the work is done for @see saveSplitterConfig()
+ */
+ void restoreSplitter ( TDEConfig* config, const TQString &group, TQWidget* parent , const TQString& viewConfGrp);
+
+ void removeViewSpace (KateViewSpace *viewspace);
+
+ bool showFullPath;
+
+ public:
+ Kate::View* activeView ();
+ KateViewSpace* activeViewSpace ();
+
+ uint viewCount ();
+ uint viewSpaceCount ();
+
+ bool isViewActivationBlocked(){return m_blockViewCreationAndActivation;};
+
+ public:
+ void closeViews(uint documentNumber);
+ KateMainWindow *mainWindow();
+ friend class KateViewManager;
+
+ private slots:
+ void activateView ( Kate::View *view );
+ void activateSpace ( Kate::View* v );
+ void slotViewChanged();
+ void reactivateActiveView();
+ void slotPendingDocumentNameChanged();
+
+ void documentCreated (Kate::Document *doc);
+ void documentDeleted (uint docNumber);
+
+ public slots:
+ /* Splits a KateViewSpace into two.
+ * The operation is performed by creating a KateMDI::Splitter in the parent of the KateViewSpace to be split,
+ * which is then moved to that splitter. Then a new KateViewSpace is created and added to the splitter,
+ * and a KateView is created to populate the new viewspace. The new KateView is made the active one,
+ * because createView() does that.
+ * If no viewspace is provided, the result of activeViewSpace() is used.
+ * The isHoriz, true pr default, decides the orientation of the splitting action.
+ * If atTop is true, the new viewspace will be moved to the first position in the new splitter.
+ * If a newViewUrl is provided, the new view will show the document in that URL if any, otherwise
+ * the document of the current view in the viewspace to be split is used.
+ */
+ void splitViewSpace( KateViewSpace* vs=0L, bool isHoriz=true, bool atTop=false );
+
+ bool getShowFullPath() const { return showFullPath; }
+
+ void activateView ( uint documentNumber );
+ void activateView ( int documentNumber ) { activateView((uint) documentNumber); };
+
+ /** Splits the active viewspace horizontally */
+ void slotSplitViewSpaceHoriz () { splitViewSpace(); }
+ /** Splits the active viewspace vertically */
+ void slotSplitViewSpaceVert () { splitViewSpace( 0L, false ); }
+
+ void slotCloseCurrentViewSpace();
+
+ void statusMsg ();
+
+ void setActiveSpace ( KateViewSpace* vs );
+ void setActiveView ( Kate::View* view );
+
+ void setShowFullPath(bool enable);
+
+ void activateNextView();
+ void activatePrevView();
+
+ signals:
+ void statusChanged (Kate::View *, int, int, int, bool, int, const TQString &);
+ void statChanged ();
+ void viewChanged ();
+
+ private:
+ KateViewManager *m_viewManager;
+ TQPtrList<KateViewSpace> m_viewSpaceList;
+ TQPtrList<Kate::View> m_viewList;
+
+ bool m_blockViewCreationAndActivation;
+
+ bool m_activeViewRunning;
+
+ bool m_pendingViewCreation;
+ TQGuardedPtr<Kate::Document> m_pendingDocument;
+};
+
+#endif
diff --git a/kate/app/kbookmarkhandler.cpp b/kate/app/kbookmarkhandler.cpp
new file mode 100644
index 000000000..8dbf8461d
--- /dev/null
+++ b/kate/app/kbookmarkhandler.cpp
@@ -0,0 +1,98 @@
+/* This file is part of the KDE project
+ Copyright (C) xxxx KFile Authors
+ Copyright (C) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "katefileselector.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <tqtextstream.h>
+
+#include <kbookmarkimporter.h>
+#include <tdepopupmenu.h>
+#include <ksavefile.h>
+#include <kstandarddirs.h>
+#include <tdediroperator.h>
+#include <tdeaction.h>
+
+#include "kbookmarkhandler.h"
+#include "kbookmarkhandler.moc"
+
+
+KBookmarkHandler::KBookmarkHandler( KateFileSelector *parent, TDEPopupMenu* tdepopupmenu )
+ : TQObject( parent, "KBookmarkHandler" ),
+ KBookmarkOwner(),
+ mParent( parent ),
+ m_menu( tdepopupmenu ),
+ m_importStream( 0L )
+{
+ if (!m_menu)
+ m_menu = new TDEPopupMenu( parent, "bookmark menu" );
+
+ TQString file = locate( "data", "kate/fsbookmarks.xml" );
+ if ( file.isEmpty() )
+ file = locateLocal( "data", "kate/fsbookmarks.xml" );
+
+ KBookmarkManager *manager = KBookmarkManager::managerForFile( file, false);
+ manager->setUpdate( true );
+ manager->setShowNSBookmarks( false );
+
+ m_bookmarkMenu = new KBookmarkMenu( manager, this, m_menu, 0, true );
+}
+
+KBookmarkHandler::~KBookmarkHandler()
+{
+ // delete m_bookmarkMenu; ###
+}
+
+TQString KBookmarkHandler::currentURL() const
+{
+ return mParent->dirOperator()->url().url();
+}
+
+
+void KBookmarkHandler::slotNewBookmark( const TQString& /*text*/,
+ const TQCString& url,
+ const TQString& additionalInfo )
+{
+ *m_importStream << "<bookmark icon=\"" << KMimeType::iconForURL( KURL( url ) );
+ *m_importStream << "\" href=\"" << TQString::fromUtf8(url) << "\">\n";
+ *m_importStream << "<title>" << (additionalInfo.isEmpty() ? TQString(TQString::fromUtf8(url)) : additionalInfo) << "</title>\n</bookmark>\n";
+}
+
+void KBookmarkHandler::slotNewFolder( const TQString& text, bool /*open*/,
+ const TQString& /*additionalInfo*/ )
+{
+ *m_importStream << "<folder icon=\"bookmark_folder\">\n<title=\"";
+ *m_importStream << text << "\">\n";
+}
+
+void KBookmarkHandler::newSeparator()
+{
+ *m_importStream << "<separator/>\n";
+}
+
+void KBookmarkHandler::endFolder()
+{
+ *m_importStream << "</folder>\n";
+}
+
+void KBookmarkHandler::virtual_hook( int id, void* data )
+{ KBookmarkOwner::virtual_hook( id, data ); }
+
diff --git a/kate/app/kbookmarkhandler.h b/kate/app/kbookmarkhandler.h
new file mode 100644
index 000000000..612c15a18
--- /dev/null
+++ b/kate/app/kbookmarkhandler.h
@@ -0,0 +1,72 @@
+/* This file is part of the KDE project
+ Copyright (C) xxxx KFile Authors
+ Copyright (C) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _KBOOKMARKHANDLER_H_
+#define _KBOOKMARKHANDLER_H_
+
+#include <kbookmarkmanager.h>
+#include <kbookmarkmenu.h>
+
+class KateFileSelector;
+
+class TDEActionMenu;
+
+class TQTextStream;
+class TDEPopupMenu;
+
+class KBookmarkHandler : public TQObject, public KBookmarkOwner
+{
+ Q_OBJECT
+
+public:
+ KBookmarkHandler( KateFileSelector *parent, TDEPopupMenu *tdepopupmenu=0 );
+ ~KBookmarkHandler();
+
+ // KBookmarkOwner interface:
+ virtual void openBookmarkURL( const TQString& url ) { emit openURL( url ); }
+ virtual TQString currentURL() const;
+
+ TDEPopupMenu *menu() const { return m_menu; }
+
+signals:
+ void openURL( const TQString& url );
+
+private slots:
+ void slotNewBookmark( const TQString& text, const TQCString& url,
+ const TQString& additionalInfo );
+ void slotNewFolder( const TQString& text, bool open,
+ const TQString& additionalInfo );
+ void newSeparator();
+ void endFolder();
+
+protected:
+ virtual void virtual_hook( int id, void* data );
+
+private:
+ KateFileSelector *mParent;
+ TDEPopupMenu *m_menu;
+ KBookmarkMenu *m_bookmarkMenu;
+
+ TQTextStream *m_importStream;
+
+ //class KBookmarkHandlerPrivate *d;
+};
+
+
+#endif // _KBOOKMARKHANDLER_H_
diff --git a/kate/app/kwritemain.cpp b/kate/app/kwritemain.cpp
new file mode 100644
index 000000000..75d494832
--- /dev/null
+++ b/kate/app/kwritemain.cpp
@@ -0,0 +1,716 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
+ Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "kwritemain.h"
+#include "kwritemain.moc"
+
+#include <kate/document.h>
+#include <kate/view.h>
+
+#include <tdetexteditor/configinterface.h>
+#include <tdetexteditor/sessionconfiginterface.h>
+#include <tdetexteditor/viewcursorinterface.h>
+#include <tdetexteditor/printinterface.h>
+#include <tdetexteditor/encodinginterface.h>
+#include <tdetexteditor/editorchooser.h>
+#include <tdetexteditor/popupmenuinterface.h>
+
+#include <tdeio/netaccess.h>
+
+#include <tdeversion.h>
+#include <dcopclient.h>
+#include <kurldrag.h>
+#include <kencodingfiledialog.h>
+#include <tdediroperator.h>
+#include <kiconloader.h>
+#include <tdeaboutdata.h>
+#include <kstatusbar.h>
+#include <kstdaction.h>
+#include <tdeaction.h>
+#include <kdebug.h>
+#include <tdeglobal.h>
+#include <tdeapplication.h>
+#include <tdelocale.h>
+#include <kurl.h>
+#include <tdeconfig.h>
+#include <tdecmdlineargs.h>
+#include <tdemessagebox.h>
+#include <kkeydialog.h>
+#include <kedittoolbar.h>
+#include <tdeparts/event.h>
+#include <tdemenubar.h>
+
+#include <tqdropsite.h>
+#include <tqdragobject.h>
+#include <tqvbox.h>
+#include <tqtextcodec.h>
+#include <tqlayout.h>
+
+// StatusBar field IDs
+#define KWRITE_ID_GEN 1
+
+TQPtrList<KTextEditor::Document> KWrite::docList;
+TQPtrList<KWrite> KWrite::winList;
+
+KWrite::KWrite (KTextEditor::Document *doc)
+ : m_view(0),
+ m_recentFiles(0),
+ m_paShowPath(0),
+ m_paShowStatusBar(0)
+{
+ if ( !doc )
+ {
+ if ( !(doc = KTextEditor::EditorChooser::createDocument(0,"KTextEditor::Document")) )
+ {
+ KMessageBox::error(this, i18n("A TDE text-editor component could not be found;\n"
+ "please check your TDE installation."));
+ kapp->exit(1);
+ }
+
+ docList.append(doc);
+ }
+
+ m_view = doc->createView (this, 0L);
+
+ setCentralWidget(m_view);
+
+ setupActions();
+ setupStatusBar();
+
+ setAcceptDrops(true);
+
+ connect(m_view,TQT_SIGNAL(newStatus()),this,TQT_SLOT(newCaption()));
+ connect(m_view,TQT_SIGNAL(viewStatusMsg(const TQString &)),this,TQT_SLOT(newStatus(const TQString &)));
+ connect(m_view->document(),TQT_SIGNAL(fileNameChanged()),this,TQT_SLOT(newCaption()));
+ connect(m_view->document(),TQT_SIGNAL(fileNameChanged()),this,TQT_SLOT(slotFileNameChanged()));
+ connect(m_view,TQT_SIGNAL(dropEventPass(TQDropEvent *)),this,TQT_SLOT(slotDropEvent(TQDropEvent *)));
+
+ setXMLFile( "kwriteui.rc" );
+ createShellGUI( true );
+ guiFactory()->addClient( m_view );
+
+ // install a working kate part popup dialog thingy
+ if (static_cast<Kate::View*>(m_view->tqt_cast("Kate::View")))
+ static_cast<Kate::View*>(m_view->tqt_cast("Kate::View"))->installPopup ((TQPopupMenu*)(factory()->container("tdetexteditor_popup", this)) );
+
+ // init with more usefull size, stolen from konq :)
+ if (!initialGeometrySet())
+ resize( TQSize(700, 480).expandedTo(minimumSizeHint()));
+
+ // call it as last thing, must be sure everything is already set up ;)
+ setAutoSaveSettings ();
+
+ readConfig ();
+
+ winList.append (this);
+
+ show ();
+}
+
+KWrite::~KWrite()
+{
+ winList.remove (this);
+
+ if (m_view->document()->views().count() == 1)
+ {
+ docList.remove(m_view->document());
+ delete m_view->document();
+ }
+
+ kapp->config()->sync ();
+}
+
+void KWrite::setupActions()
+{
+ KStdAction::close( TQT_TQOBJECT(this), TQT_SLOT(slotFlush()), actionCollection(), "file_close" )->setWhatsThis(i18n("Use this to close the current document"));
+
+ // setup File menu
+ KStdAction::print(TQT_TQOBJECT(this), TQT_SLOT(printDlg()), actionCollection())->setWhatsThis(i18n("Use this command to print the current document"));
+ KStdAction::openNew( TQT_TQOBJECT(this), TQT_SLOT(slotNew()), actionCollection(), "file_new" )->setWhatsThis(i18n("Use this command to create a new document"));
+ KStdAction::open( TQT_TQOBJECT(this), TQT_SLOT( slotOpen() ), actionCollection(), "file_open" )->setWhatsThis(i18n("Use this command to open an existing document for editing"));
+
+ m_recentFiles = KStdAction::openRecent(TQT_TQOBJECT(this), TQT_SLOT(slotOpen(const KURL&)),
+ actionCollection());
+ m_recentFiles->setWhatsThis(i18n("This lists files which you have opened recently, and allows you to easily open them again."));
+
+ TDEAction *a=new TDEAction(i18n("&New Window"), "window_new", 0, TQT_TQOBJECT(this), TQT_SLOT(newView()),
+ actionCollection(), "view_new_view");
+ a->setWhatsThis(i18n("Create another view containing the current document"));
+
+ a=new TDEAction(i18n("Choose Editor Component..."),0,TQT_TQOBJECT(this),TQT_SLOT(changeEditor()),
+ actionCollection(),"settings_choose_editor");
+ a->setWhatsThis(i18n("Override the system wide setting for the default editing component"));
+
+ KStdAction::quit(TQT_TQOBJECT(this), TQT_SLOT(close()), actionCollection())->setWhatsThis(i18n("Close the current document view"));
+
+ // setup Settings menu
+ setStandardToolBarMenuEnabled(true);
+
+ m_paShowStatusBar = KStdAction::showStatusbar(TQT_TQOBJECT(this), TQT_SLOT(toggleStatusBar()), actionCollection(), "settings_show_statusbar");
+ m_paShowStatusBar->setWhatsThis(i18n("Use this command to show or hide the view's statusbar"));
+
+ m_paShowPath = new TDEToggleAction(i18n("Sho&w Path"), 0, TQT_TQOBJECT(this), TQT_SLOT(newCaption()),
+ actionCollection(), "set_showPath");
+ m_paShowPath->setCheckedState(i18n("Hide Path"));
+ m_paShowPath->setWhatsThis(i18n("Show the complete document path in the window caption"));
+ a=KStdAction::keyBindings(TQT_TQOBJECT(this), TQT_SLOT(editKeys()), actionCollection());
+ a->setWhatsThis(i18n("Configure the application's keyboard shortcut assignments."));
+
+ a=KStdAction::configureToolbars(TQT_TQOBJECT(this), TQT_SLOT(editToolbars()), actionCollection());
+ a->setWhatsThis(i18n("Configure which items should appear in the toolbar(s)."));
+}
+
+void KWrite::setupStatusBar()
+{
+ statusBar()->insertItem("", KWRITE_ID_GEN);
+}
+
+// load on url
+void KWrite::loadURL(const KURL &url)
+{
+ m_view->document()->openURL(url);
+}
+
+// is closing the window wanted by user ?
+bool KWrite::queryClose()
+{
+ if (m_view->document()->views().count() > 1)
+ return true;
+
+ if (m_view->document()->queryClose())
+ {
+ writeConfig();
+
+ return true;
+ }
+
+ return false;
+}
+
+void KWrite::changeEditor()
+{
+ KWriteEditorChooser choose(this);
+ choose.exec();
+}
+
+void KWrite::slotFlush ()
+{
+ m_view->document()->closeURL();
+}
+
+void KWrite::slotNew()
+{
+ new KWrite();
+}
+
+void KWrite::slotOpen()
+{
+ if (KTextEditor::encodingInterface(m_view->document()))
+ {
+ KEncodingFileDialog::Result r=KEncodingFileDialog::getOpenURLsAndEncoding(
+ KTextEditor::encodingInterface(m_view->document())->encoding(),
+ m_view->document()->url().url(),TQString::null,this,i18n("Open File"));
+
+ for (KURL::List::Iterator i=r.URLs.begin(); i != r.URLs.end(); ++i)
+ {
+ encoding = r.encoding;
+ slotOpen ( *i );
+ }
+ }
+ else
+ {
+ KURL::List l=KFileDialog::getOpenURLs(m_view->document()->url().url(),TQString::null,this,TQString::null);
+ for (KURL::List::Iterator i=l.begin(); i != l.end(); ++i)
+ {
+ slotOpen ( *i );
+ }
+ }
+}
+
+void KWrite::slotOpen( const KURL& url )
+{
+ if (url.isEmpty()) return;
+
+ if (!TDEIO::NetAccess::exists(url, true, this))
+ {
+ KMessageBox::error (this, i18n("The given file could not be read, check if it exists or if it is readable for the current user."));
+ return;
+ }
+
+ if (m_view->document()->isModified() || !m_view->document()->url().isEmpty())
+ {
+ KWrite *t = new KWrite();
+ if (KTextEditor::encodingInterface(t->m_view->document())) KTextEditor::encodingInterface(t->m_view->document())->setEncoding(encoding);
+ t->loadURL(url);
+ }
+ else
+ {
+ if (KTextEditor::encodingInterface(m_view->document())) KTextEditor::encodingInterface(m_view->document())->setEncoding(encoding);
+ loadURL(url);
+ }
+}
+
+void KWrite::slotFileNameChanged()
+{
+ if ( ! m_view->document()->url().isEmpty() )
+ m_recentFiles->addURL( m_view->document()->url() );
+}
+
+void KWrite::newView()
+{
+ new KWrite(m_view->document());
+}
+
+void KWrite::toggleStatusBar()
+{
+ if( m_paShowStatusBar->isChecked() )
+ statusBar()->show();
+ else
+ statusBar()->hide();
+}
+
+void KWrite::editKeys()
+{
+ KKeyDialog dlg;
+ dlg.insert(actionCollection());
+ if( m_view )
+ dlg.insert(m_view->actionCollection());
+ dlg.configure();
+}
+
+void KWrite::editToolbars()
+{
+ saveMainWindowSettings( kapp->config(), "MainWindow" );
+ KEditToolbar *dlg = new KEditToolbar(guiFactory());
+ connect( dlg, TQT_SIGNAL(newToolbarConfig()), this, TQT_SLOT(slotNewToolbarConfig()) );
+ dlg->exec();
+ delete dlg;
+}
+
+void KWrite::slotNewToolbarConfig()
+{
+ applyMainWindowSettings( kapp->config(), "MainWindow" );
+}
+
+
+void KWrite::printNow()
+{
+ KTextEditor::printInterface(m_view->document())->print ();
+}
+
+void KWrite::printDlg()
+{
+ KTextEditor::printInterface(m_view->document())->printDialog ();
+}
+
+void KWrite::newStatus(const TQString &msg)
+{
+ newCaption();
+
+ statusBar()->changeItem(msg,KWRITE_ID_GEN);
+}
+
+void KWrite::newCaption()
+{
+ if (m_view->document()->url().isEmpty()) {
+ setCaption(i18n("Untitled"),m_view->document()->isModified());
+ }
+ else
+ {
+ TQString c;
+ if (!m_paShowPath->isChecked())
+ {
+ c = m_view->document()->url().fileName();
+
+ //File name shouldn't be too long - Maciek
+ if (c.length() > 64)
+ c = c.left(64) + "...";
+ }
+ else
+ {
+ c = m_view->document()->url().prettyURL();
+
+ //File name shouldn't be too long - Maciek
+ if (c.length() > 64)
+ c = "..." + c.right(64);
+ }
+
+ setCaption (c, m_view->document()->isModified());
+ }
+}
+
+void KWrite::dragEnterEvent( TQDragEnterEvent *event )
+{
+ event->accept(KURLDrag::canDecode(event));
+}
+
+void KWrite::dropEvent( TQDropEvent *event )
+{
+ slotDropEvent(event);
+}
+
+void KWrite::slotDropEvent( TQDropEvent *event )
+{
+ KURL::List textlist;
+
+ if (!KURLDrag::decode(event, textlist))
+ return;
+
+ for (KURL::List::Iterator i=textlist.begin(); i != textlist.end(); ++i)
+ slotOpen (*i);
+}
+
+void KWrite::slotEnableActions( bool enable )
+{
+ TQValueList<TDEAction *> actions = actionCollection()->actions();
+ TQValueList<TDEAction *>::ConstIterator it = actions.begin();
+ TQValueList<TDEAction *>::ConstIterator end = actions.end();
+
+ for (; it != end; ++it )
+ (*it)->setEnabled( enable );
+
+ actions = m_view->actionCollection()->actions();
+ it = actions.begin();
+ end = actions.end();
+
+ for (; it != end; ++it )
+ (*it)->setEnabled( enable );
+}
+
+//common config
+void KWrite::readConfig(TDEConfig *config)
+{
+ config->setGroup("General Options");
+
+ m_paShowStatusBar->setChecked( config->readBoolEntry("ShowStatusBar") );
+ m_paShowPath->setChecked( config->readBoolEntry("ShowPath") );
+
+ m_recentFiles->loadEntries(config, "Recent Files");
+
+ if (m_view && KTextEditor::configInterface(m_view->document()))
+ KTextEditor::configInterface(m_view->document())->readConfig(config);
+
+ if( m_paShowStatusBar->isChecked() )
+ statusBar()->show();
+ else
+ statusBar()->hide();
+}
+
+void KWrite::writeConfig(TDEConfig *config)
+{
+ config->setGroup("General Options");
+
+ config->writeEntry("ShowStatusBar",m_paShowStatusBar->isChecked());
+ config->writeEntry("ShowPath",m_paShowPath->isChecked());
+
+ m_recentFiles->saveEntries(config, "Recent Files");
+
+ if (m_view && KTextEditor::configInterface(m_view->document()))
+ KTextEditor::configInterface(m_view->document())->writeConfig(config);
+
+ config->sync ();
+}
+
+//config file
+void KWrite::readConfig()
+{
+ TDEConfig *config = kapp->config();
+ readConfig(config);
+}
+
+void KWrite::writeConfig()
+{
+ TDEConfig *config = kapp->config();
+ writeConfig(config);
+}
+
+// session management
+void KWrite::restore(TDEConfig *config, int n)
+{
+ readPropertiesInternal(config, n);
+}
+
+void KWrite::readProperties(TDEConfig *config)
+{
+ readConfig(config);
+
+ if (KTextEditor::sessionConfigInterface(m_view))
+ KTextEditor::sessionConfigInterface(m_view)->readSessionConfig(config);
+}
+
+void KWrite::saveProperties(TDEConfig *config)
+{
+ writeConfig(config);
+ config->writeEntry("DocumentNumber",docList.find(m_view->document()) + 1);
+
+ if (KTextEditor::sessionConfigInterface(m_view))
+ KTextEditor::sessionConfigInterface(m_view)->writeSessionConfig(config);
+}
+
+void KWrite::saveGlobalProperties(TDEConfig *config) //save documents
+{
+ config->setGroup("Number");
+ config->writeEntry("NumberOfDocuments",docList.count());
+
+ for (uint z = 1; z <= docList.count(); z++)
+ {
+ TQString buf = TQString("Document %1").arg(z);
+ config->setGroup(buf);
+
+ KTextEditor::Document *doc = docList.at(z - 1);
+
+ if (KTextEditor::configInterface(doc))
+ KTextEditor::configInterface(doc)->writeSessionConfig(config);
+ }
+
+ for (uint z = 1; z <= winList.count(); z++)
+ {
+ TQString buf = TQString("Window %1").arg(z);
+ config->setGroup(buf);
+
+ config->writeEntry("DocumentNumber",docList.find(winList.at(z-1)->view()->document()) + 1);
+ }
+}
+
+//restore session
+void KWrite::restore()
+{
+ TDEConfig *config = kapp->sessionConfig();
+
+ if (!config)
+ return;
+
+ int docs, windows;
+ TQString buf;
+ KTextEditor::Document *doc;
+ KWrite *t;
+
+ config->setGroup("Number");
+ docs = config->readNumEntry("NumberOfDocuments");
+ windows = config->readNumEntry("NumberOfWindows");
+
+ for (int z = 1; z <= docs; z++)
+ {
+ buf = TQString("Document %1").arg(z);
+ config->setGroup(buf);
+ doc=KTextEditor::EditorChooser::createDocument(0,"KTextEditor::Document");
+
+ if (KTextEditor::configInterface(doc))
+ KTextEditor::configInterface(doc)->readSessionConfig(config);
+ docList.append(doc);
+ }
+
+ for (int z = 1; z <= windows; z++)
+ {
+ buf = TQString("Window %1").arg(z);
+ config->setGroup(buf);
+ t = new KWrite(docList.at(config->readNumEntry("DocumentNumber") - 1));
+ t->restore(config,z);
+ }
+}
+
+static TDECmdLineOptions options[] =
+{
+ { "stdin", I18N_NOOP("Read the contents of stdin"), 0},
+ { "encoding <argument>", I18N_NOOP("Set encoding for the file to open"), 0 },
+ { "line <argument>", I18N_NOOP("Navigate to this line"), 0 },
+ { "column <argument>", I18N_NOOP("Navigate to this column"), 0 },
+ { "+[URL]", I18N_NOOP("Document to open"), 0 },
+ TDECmdLineLastOption
+};
+
+extern "C" KDE_EXPORT int kdemain(int argc, char **argv)
+{
+ Kate::Document::setFileChangedDialogsActivated (true);
+
+ TDELocale::setMainCatalogue("kate"); //lukas: set this to have the kwritepart translated using kate message catalog
+
+ // here we go, construct the KWrite version
+ // TQString kWriteVersion = TQString ("%1.%2.%3").arg(KDE::versionMajor() + 1).arg(KDE::versionMinor()).arg(KDE::versionRelease());
+ /** The previous version computation scheme (commented out above) worked fine in the 3.5.x days.
+ With the new Trinity Rx.y.z scheme the version number gets weird.
+ We now hard-code the first two numbers to match the 3.5.x days and only update the last number. */
+ TQString kWriteVersion = TQString ("4.5.%1").arg(KDE::versionMajor());
+
+ TDEAboutData aboutData ( "kwrite",
+ I18N_NOOP("KWrite"),
+ kWriteVersion.latin1(),
+ I18N_NOOP( "KWrite - Text Editor" ), TDEAboutData::License_LGPL_V2,
+ I18N_NOOP( "(c) 2000-2005 The Kate Authors" ), 0, "http://kate.kde.org" );
+
+ aboutData.addAuthor ("Christoph Cullmann", I18N_NOOP("Maintainer"), "cullmann@kde.org", "http://www.babylon2k.de");
+ aboutData.addAuthor ("Anders Lund", I18N_NOOP("Core Developer"), "anders@alweb.dk", "http://www.alweb.dk");
+ aboutData.addAuthor ("Joseph Wenninger", I18N_NOOP("Core Developer"), "jowenn@kde.org","http://stud3.tuwien.ac.at/~e9925371");
+ aboutData.addAuthor ("Hamish Rodda",I18N_NOOP("Core Developer"), "rodda@kde.org");
+ aboutData.addAuthor ("Waldo Bastian", I18N_NOOP( "The cool buffersystem" ), "bastian@kde.org" );
+ aboutData.addAuthor ("Charles Samuels", I18N_NOOP("The Editing Commands"), "charles@kde.org");
+ aboutData.addAuthor ("Matt Newell", I18N_NOOP("Testing, ..."), "newellm@proaxis.com");
+ aboutData.addAuthor ("Michael Bartl", I18N_NOOP("Former Core Developer"), "michael.bartl1@chello.at");
+ aboutData.addAuthor ("Michael McCallum", I18N_NOOP("Core Developer"), "gholam@xtra.co.nz");
+ aboutData.addAuthor ("Jochen Wilhemly", I18N_NOOP( "KWrite Author" ), "digisnap@cs.tu-berlin.de" );
+ aboutData.addAuthor ("Michael Koch",I18N_NOOP("KWrite port to KParts"), "koch@kde.org");
+ aboutData.addAuthor ("Christian Gebauer", 0, "gebauer@kde.org" );
+ aboutData.addAuthor ("Simon Hausmann", 0, "hausmann@kde.org" );
+ aboutData.addAuthor ("Glen Parker",I18N_NOOP("KWrite Undo History, Kspell integration"), "glenebob@nwlink.com");
+ aboutData.addAuthor ("Scott Manson",I18N_NOOP("KWrite XML Syntax highlighting support"), "sdmanson@alltel.net");
+ aboutData.addAuthor ("John Firebaugh",I18N_NOOP("Patches and more"), "jfirebaugh@kde.org");
+
+ aboutData.addCredit ("Matteo Merli",I18N_NOOP("Highlighting for RPM Spec-Files, Perl, Diff and more"), "merlim@libero.it");
+ aboutData.addCredit ("Rocky Scaletta",I18N_NOOP("Highlighting for VHDL"), "rocky@purdue.edu");
+ aboutData.addCredit ("Yury Lebedev",I18N_NOOP("Highlighting for SQL"),"");
+ aboutData.addCredit ("Chris Ross",I18N_NOOP("Highlighting for Ferite"),"");
+ aboutData.addCredit ("Nick Roux",I18N_NOOP("Highlighting for ILERPG"),"");
+ aboutData.addCredit ("Carsten Niehaus", I18N_NOOP("Highlighting for LaTeX"),"");
+ aboutData.addCredit ("Per Wigren", I18N_NOOP("Highlighting for Makefiles, Python"),"");
+ aboutData.addCredit ("Jan Fritz", I18N_NOOP("Highlighting for Python"),"");
+ aboutData.addCredit ("Daniel Naber","","");
+ aboutData.addCredit ("Roland Pabel",I18N_NOOP("Highlighting for Scheme"),"");
+ aboutData.addCredit ("Cristi Dumitrescu",I18N_NOOP("PHP Keyword/Datatype list"),"");
+ aboutData.addCredit ("Carsten Pfeiffer", I18N_NOOP("Very nice help"), "");
+ aboutData.addCredit (I18N_NOOP("All people who have contributed and I have forgotten to mention"),"","");
+
+ aboutData.setTranslator(I18N_NOOP("_: NAME OF TRANSLATORS\nYour names"), I18N_NOOP("_: EMAIL OF TRANSLATORS\nYour emails"));
+
+ TDECmdLineArgs::init( argc, argv, &aboutData );
+ TDECmdLineArgs::addCmdLineOptions( options );
+
+ TDEApplication a;
+
+ TDEGlobal::locale()->insertCatalogue("katepart");
+
+ DCOPClient *client = kapp->dcopClient();
+ if (!client->isRegistered())
+ {
+ client->attach();
+ client->registerAs("kwrite");
+ }
+
+ TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
+
+ if (kapp->isRestored())
+ {
+ KWrite::restore();
+ }
+ else
+ {
+ bool nav = false;
+ int line = 0, column = 0;
+
+ TQTextCodec *codec = args->isSet("encoding") ? TQTextCodec::codecForName(args->getOption("encoding")) : 0;
+
+ if (args->isSet ("line"))
+ {
+ line = args->getOption ("line").toInt();
+ nav = true;
+ }
+
+ if (args->isSet ("column"))
+ {
+ column = args->getOption ("column").toInt();
+ nav = true;
+ }
+
+ if ( args->count() == 0 )
+ {
+ KWrite *t = new KWrite;
+
+ if( args->isSet( "stdin" ) )
+ {
+ TQTextIStream input(stdin);
+
+ // set chosen codec
+ if (codec)
+ input.setCodec (codec);
+
+ TQString line;
+ TQString text;
+
+ do
+ {
+ line = input.readLine();
+ text.append( line + "\n" );
+ } while( !line.isNull() );
+
+
+ KTextEditor::EditInterface *doc = KTextEditor::editInterface (t->view()->document());
+ if( doc )
+ doc->setText( text );
+ }
+
+ if (nav && KTextEditor::viewCursorInterface(t->view()))
+ KTextEditor::viewCursorInterface(t->view())->setCursorPosition (line, column);
+ }
+ else
+ {
+ for ( int z = 0; z < args->count(); z++ )
+ {
+ KWrite *t = new KWrite();
+
+ // this file is no local dir, open it, else warn
+ bool noDir = !args->url(z).isLocalFile() || !TQDir (args->url(z).path()).exists();
+
+ if (noDir)
+ {
+ if (Kate::document (t->view()->document()))
+ Kate::Document::setOpenErrorDialogsActivated (false);
+
+ if (codec && KTextEditor::encodingInterface(t->view()->document()))
+ KTextEditor::encodingInterface(t->view()->document())->setEncoding(codec->name());
+
+ t->loadURL( args->url( z ) );
+
+ if (Kate::document (t->view()->document()))
+ Kate::Document::setOpenErrorDialogsActivated (true);
+
+ if (nav && KTextEditor::viewCursorInterface(t->view()))
+ KTextEditor::viewCursorInterface(t->view())->setCursorPosition (line, column);
+ }
+ else
+ KMessageBox::sorry( t, i18n("The file '%1' could not be opened: it is not a normal file, it is a folder.").arg(args->url(z).url()) );
+ }
+ }
+ }
+
+ // no window there, uh, ohh, for example borked session config !!!
+ // create at least one !!
+ if (KWrite::noWindows())
+ new KWrite();
+
+ return a.exec ();
+}
+
+KWriteEditorChooser::KWriteEditorChooser(TQWidget *):
+ KDialogBase(KDialogBase::Plain,i18n("Choose Editor Component"),KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Cancel)
+{
+ (new TQVBoxLayout(plainPage()))->setAutoAdd(true);
+ m_chooser=new KTextEditor::EditorChooser(plainPage(),"Editor Chooser");
+ setMainWidget(m_chooser);
+ m_chooser->readAppSetting();
+}
+
+KWriteEditorChooser::~KWriteEditorChooser() {
+;
+}
+
+void KWriteEditorChooser::slotOk() {
+ m_chooser->writeAppSetting();
+ KDialogBase::slotOk();
+}
+// kate: space-indent on; indent-width 2; replace-tabs on; mixed-indent off;
diff --git a/kate/app/kwritemain.h b/kate/app/kwritemain.h
new file mode 100644
index 000000000..fc47c6522
--- /dev/null
+++ b/kate/app/kwritemain.h
@@ -0,0 +1,140 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
+ Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __KWRITE_MAIN_H__
+#define __KWRITE_MAIN_H__
+
+#include <tdetexteditor/view.h>
+#include <tdetexteditor/document.h>
+
+#include <tdeparts/mainwindow.h>
+
+#include <kdialogbase.h>
+
+namespace KTextEditor { class EditorChooser; }
+
+class TDEAction;
+class TDEToggleAction;
+class TDESelectAction;
+class TDERecentFilesAction;
+
+class KWrite : public KParts::MainWindow
+{
+ Q_OBJECT
+
+
+ public:
+ KWrite(KTextEditor::Document * = 0L);
+ ~KWrite();
+
+ void loadURL(const KURL &url);
+
+ KTextEditor::View *view() const { return m_view; }
+
+ static bool noWindows () { return winList.isEmpty(); }
+
+ private:
+ void setupActions();
+ void setupStatusBar();
+
+ bool queryClose();
+
+ void dragEnterEvent( TQDragEnterEvent * );
+ void dropEvent( TQDropEvent * );
+
+ public slots:
+ void slotNew();
+ void slotFlush ();
+ void slotOpen();
+ void slotOpen( const KURL& url);
+ void newView();
+ void toggleStatusBar();
+ void editKeys();
+ void editToolbars();
+ void changeEditor();
+
+ private slots:
+ void slotNewToolbarConfig();
+
+ public slots:
+ void printNow();
+ void printDlg();
+
+ void newStatus(const TQString &msg);
+ void newCaption();
+
+ void slotDropEvent(TQDropEvent *);
+
+ void slotEnableActions( bool enable );
+
+ /**
+ * adds a changed URL to the recent files
+ */
+ void slotFileNameChanged();
+
+ //config file functions
+ public:
+ void readConfig (TDEConfig *);
+ void writeConfig (TDEConfig *);
+
+ void readConfig ();
+ void writeConfig ();
+
+ //session management
+ public:
+ void restore(TDEConfig *,int);
+ static void restore();
+
+ private:
+ void readProperties(TDEConfig *);
+ void saveProperties(TDEConfig *);
+ void saveGlobalProperties(TDEConfig *);
+
+ private:
+ KTextEditor::View * m_view;
+
+ TDERecentFilesAction * m_recentFiles;
+ TDEToggleAction * m_paShowPath;
+ TDEToggleAction * m_paShowStatusBar;
+
+ TQString encoding;
+
+ static TQPtrList<KTextEditor::Document> docList;
+ static TQPtrList<KWrite> winList;
+};
+
+class KWriteEditorChooser: public KDialogBase
+{
+ Q_OBJECT
+
+
+ public:
+ KWriteEditorChooser(TQWidget *parent);
+ virtual ~KWriteEditorChooser();
+
+ private:
+ KTextEditor::EditorChooser *m_chooser;
+
+ protected slots:
+ void slotOk();
+};
+
+#endif
+// kate: space-indent on; indent-width 2; replace-tabs on; mixed-indent off;
diff --git a/kate/data/CMakeLists.txt b/kate/data/CMakeLists.txt
new file mode 100644
index 000000000..b81ead948
--- /dev/null
+++ b/kate/data/CMakeLists.txt
@@ -0,0 +1,19 @@
+#################################################
+#
+# (C) 2010-2011 Serghei Amelian
+# serghei (DOT) amelian (AT) gmail.com
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+##### other data ################################
+
+install( FILES kateplugin.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR} )
+install( FILES kate.desktop kwrite.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} )
+install( FILES kateui.rc externaltools tips DESTINATION ${DATA_INSTALL_DIR}/kate )
+install( FILES kwriteui.rc DESTINATION ${DATA_INSTALL_DIR}/kwrite )
+install( FILES kate-2.4.upd DESTINATION ${DATA_INSTALL_DIR}/tdeconf_update )
+install( FILES katerc DESTINATION ${CONFIG_INSTALL_DIR} )
diff --git a/kate/data/Makefile.am b/kate/data/Makefile.am
new file mode 100644
index 000000000..149406426
--- /dev/null
+++ b/kate/data/Makefile.am
@@ -0,0 +1,18 @@
+servicetypedir = $(kde_servicetypesdir)
+servicetype_DATA = kateplugin.desktop
+
+xdg_apps_DATA = kate.desktop kwrite.desktop
+
+rckatedir = $(kde_datadir)/kate
+rckate_DATA = kateui.rc externaltools
+
+rckwritedir = $(kde_datadir)/kwrite
+rckwrite_DATA = kwriteui.rc
+
+tipdir = $(kde_datadir)/kate
+tip_DATA = tips
+
+updatedir = $(kde_datadir)/tdeconf_update
+update_DATA = kate-2.4.upd
+
+kde_conf_DATA = katerc
diff --git a/kate/data/externaltools b/kate/data/externaltools
new file mode 100644
index 000000000..9057b7340
--- /dev/null
+++ b/kate/data/externaltools
@@ -0,0 +1,77 @@
+[Global]
+tools=externaltool_CVSLogforCurrentDocument,externaltool_CervisiaDirectoryofCurrentDocument,externaltool_CompareCurrentDocumenttoCVS,externaltool_CompareDirectoryofCurrentDocumenttoCVS,externaltool_EmailCVSDiffforCurrentDocument,---,externaltool_RunScript,---,externaltool_GoogleSelection
+
+[Shortcuts]
+externaltool_CVSLogforCurrentDocument=Shift+F10
+externaltool_CompareCurrentDocumenttoCVS=Shift+F11
+externaltool_RunScript=Ctrl+Shift+X
+
+[externaltool_CVSLogforCurrentDocument]
+acname=externaltool_CVSLogforCurrentDocument
+cmdname=cvs-log
+command=if grep %filename %directory/CVS/Entries 2>&1>/dev/null ; then\n cd %directory && cervisia -log %filename\nelse\n kdialog --title Error --msgbox "The file '%filename' is not in CVS."\nfi
+executable=cervisia
+icon=cervisia
+mimetypes=
+name=CVS Log for Current Document
+save=0
+
+[externaltool_CervisiaDirectoryofCurrentDocument]
+acname=externaltool_CervisiaDirectoryofCurrentDocument
+cmdname=cvs-directory
+command=if [ -d %directory/CVS ] ; then\n cervisia %directory\nelse\n kdialog --title Error --msgbox "The directory '%directory' does not appear to be a CVS sandbox."\nfi
+executable=cervisia
+icon=cervisia
+mimetypes=
+name=Cervisia (Directory of Current Document)
+save=0
+
+[externaltool_CompareCurrentDocumenttoCVS]
+acname=externaltool_CompareCurrentDocumenttoCVS
+cmdname=cvs-diff
+command=cd %directory\nif [ -d CVS ] && grep %filename CVS/Entries 2>&1 >/dev/null ; then\n cvs diff %filename|kompare -o -\nelse\n kdialog --title Error --msgbox "The file '%filename' is not in CVS."\nfi
+executable=kompare
+icon=kompare
+mimetypes=
+name=Compare Current Document to CVS
+save=1
+
+[externaltool_EmailCVSDiffforCurrentDocument]
+acname=externaltool_EmailCVSDiffforCurrentDocument
+cmdname=
+command=cd %directory\nif [ -d CVS ] && grep %filename CVS/Entries > /dev/null ; then\n cvs diff -ubB %filename > $(tde-config --path tmp)%filename.diff \n kmail --composer --attach $(tde-config --path tmp)%filename.diff\nelse\n kdialog --title Error -msgbox "The file '%filename' is not in CVS"\nfi
+executable=kmail
+icon=kmail
+mimetypes=
+name=Email CVS Diff for Current Document
+save=1
+
+[externaltool_GoogleSelection]
+acname=externaltool_GoogleSelection
+cmdname=google-selection
+command=[ -n "%selection" ] && kfmclient openURL "gg:%selection"
+executable=kfmclient
+icon=globe
+mimetypes=
+name=Google Selection
+save=0
+
+[externaltool_RunScript]
+acname=externaltool_RunScript
+cmdname=runscript
+command=cd "%directory" && chmod u+x "%filename" && konsole -e "./%filename"
+executable=konsole
+icon=run
+mimetypes=
+name=Run Script
+save=1
+
+[externaltool_CompareDirectoryofCurrentDocumenttoCVS]
+acname=externaltool_CompareDirectoryofCurrentDocumenttoCVS
+cmdname=
+command=cd %directory\nif [ -d CVS ] ; then\n cvs diff -ub |kompare -o -\nelse\n kdialog --title Error --msgbox "The directory '%directory' does not appear to be a cvs sandbox."\nfi
+executable=kompare
+icon=kompare
+mimetypes=
+name=Compare Directory of Current Document to CVS
+save=0 \ No newline at end of file
diff --git a/kate/data/kate-2.4.upd b/kate/data/kate-2.4.upd
new file mode 100644
index 000000000..98e4537e1
--- /dev/null
+++ b/kate/data/kate-2.4.upd
@@ -0,0 +1,7 @@
+# kate-2.4.upd
+# Update the katerc config file for v 2.4
+Id=kate2.4
+File=katerc
+# Move the file list sort option into the Filelist group
+Group=General,Filelist
+Key=Sort Type of File List,Sort Type \ No newline at end of file
diff --git a/kate/data/kate.desktop b/kate/data/kate.desktop
new file mode 100644
index 000000000..6c176b7d5
--- /dev/null
+++ b/kate/data/kate.desktop
@@ -0,0 +1,96 @@
+[Desktop Entry]
+GenericName=Advanced Text Editor
+GenericName[af]=Gevorderde Teks Redigeerder
+GenericName[ar]=محرر النصوص المتقدم
+GenericName[az]=Səciyyəvi Mətn Editoru
+GenericName[be]=Адмысловы рэдактар тэксту
+GenericName[bg]=Текстов редактор
+GenericName[bn]=উন্নত টেক্সট সম্পাদক
+GenericName[br]=Aozer skrid barek
+GenericName[bs]=Napredni editor teksta
+GenericName[ca]=Editor de text avançat
+GenericName[cs]=Pokročilý textový editor
+GenericName[csb]=Awansowóny editora tekstu
+GenericName[cy]=Golygydd Testun Uwch
+GenericName[da]= Avanceret teksteditor
+GenericName[de]=Erweiterter Texteditor
+GenericName[el]=Προχωρημένος επεξεργαστής κειμένου
+GenericName[eo]=Pli bona Tekstredaktilo
+GenericName[es]=Editor de texto avanzado
+GenericName[et]=Võimas tekstiredaktor
+GenericName[eu]=Testu editore aurreratua
+GenericName[fa]=ویرایشگر متن پیشرفته
+GenericName[fi]=Kehittynyt tekstieditori
+GenericName[fr]=Éditeur de texte avancé
+GenericName[fy]=avansearre tekstbewurker
+GenericName[ga]=Ardeagarthóir Téacs
+GenericName[gl]=Editor Avanzado de Textos
+GenericName[he]=עורך טקסט מתקדם
+GenericName[hi]=विकसित पाठ संपादक
+GenericName[hr]=Napredni uređivač teksta
+GenericName[hu]=Szövegszerkesztő
+GenericName[is]=Þróaður textaritill
+GenericName[it]=Editor di testi avanzato
+GenericName[ja]=高度なテキストエディタ
+GenericName[ka]=გაუმჯობესებული ტექსტური რედაქტორი
+GenericName[kk]=Үздік мәтін редакторы
+GenericName[km]=កម្មវិធី​វាយ​អត្ថបទ​កម្រិត​ខ្ពស់
+GenericName[lt]=Sudėtingesnis teksto redaktorius
+GenericName[lv]=Teksta Redaktors
+GenericName[mk]=Напреден уредувач на текст
+GenericName[mn]=Текст боловсруулагч
+GenericName[ms]=Editor Teks Lanjutan
+GenericName[mt]=Editur tat-test avvanzat
+GenericName[nb]=Avansert skriveprogram
+GenericName[nds]=Verwiedert Text-Editor
+GenericName[ne]=उन्नत पाठ सम्पादक
+GenericName[nl]=Geavanceerde teksteditor
+GenericName[nn]=Avansert skriveprogram
+GenericName[pa]=ਤਕਨੀਕੀ ਪਾਠ ਦਰਸ਼ਕ
+GenericName[pl]=Zaawansowany edytor tekstu
+GenericName[pt]=Editor de Texto Avançado
+GenericName[pt_BR]=Editor de Texto Avançado
+GenericName[ro]=Editor avansat de text
+GenericName[ru]=Улучшенный текстовый редактор
+GenericName[rw]=Muhinduzi Ihanitse y'Umwandiko
+GenericName[se]=Erenoamáš čállinprográmma
+GenericName[sk]=Pokročilý textový editor
+GenericName[sl]=Napredni urejevalnik besedil
+GenericName[sr]=Напредни уређивач текста
+GenericName[sr@Latn]=Napredni uređivač teksta
+GenericName[sv]=Avancerad texteditor
+GenericName[ta]=மேம்படுத்த்ப்பட்ட உரை திருத்துபவர்
+GenericName[te]=ఆధునిక వచన ఎడిటర్
+GenericName[tg]=Муҳаррири матни пешрафта
+GenericName[th]=โปรแกรมแก้ไขข้อความแบบขั้นสูง
+GenericName[tr]=Gelişmiş Metin Düzenleyici
+GenericName[tt]=Yaqşırtılğan Mäten-Tözätkeç
+GenericName[uk]=Редактор текстів
+GenericName[uz]=Kengaytirilgan matn tahrirchi
+GenericName[uz@cyrillic]=Кенгайтирилган матн таҳрирчи
+GenericName[vi]=Trình soạn văn bản nâng cao
+GenericName[wa]=Aspougneu di tecse avancî
+GenericName[zh_CN]=高级文本编辑器
+GenericName[zh_TW]=進階文字編輯器
+Name=Kate
+Name[bn]=কেট
+Name[eo]=Kodredaktilo
+Name[hi]=के-एटीई
+Name[ka]=რედაქტორი Kate
+Name[kk]=Kate редакторы
+Name[mk]=Кате
+Name[ne]=क्येट
+Name[pa]=ਕੇਟ
+Name[te]=కేట్
+MimeType=text/plain;
+Exec=kate --use %U
+X-TDE-StartupNotify=true
+X-TDE-HasTempFileOption=true
+Icon=kate
+Path=
+DocPath=kate/index.html
+Type=Application
+Terminal=false
+InitialPreference=8
+X-DCOP-ServiceType=Multi
+Categories=Qt;TDE;TextEditor;
diff --git a/kate/data/kateplugin.desktop b/kate/data/kateplugin.desktop
new file mode 100644
index 000000000..63cea7821
--- /dev/null
+++ b/kate/data/kateplugin.desktop
@@ -0,0 +1,89 @@
+[Desktop Entry]
+Type=ServiceType
+X-TDE-ServiceType=Kate/Plugin
+X-TDE-Derived=
+Comment=Kate Plugin
+Comment[af]=Kate Inplak
+Comment[az]=Kate Əlavəsi
+Comment[be]=Утулка для Kate
+Comment[bg]=Приставка за Kate
+Comment[bn]=কেট প্লাগ-ইন
+Comment[br]=Lugent Kate
+Comment[bs]=Kate dodatak
+Comment[ca]=Connector per a Kate
+Comment[cs]=Modul aplikace Kate
+Comment[csb]=Plugins Kate
+Comment[cy]=Ategyn Kate
+Comment[da]=Kate-plugin
+Comment[de]=Kate-Plugin
+Comment[el]=Πρόσθετο Kate
+Comment[eo]=Kodredaktila kromaĵo
+Comment[es]=Complemento de Kate
+Comment[et]=Kate plugin
+Comment[eu]=Kate plugina
+Comment[fa]=وصلۀ Kate
+Comment[fi]=Kate-liitännäinen
+Comment[fo]=Kate-ístingur
+Comment[fr]=Module de Kate
+Comment[fy]=Kate-plugin
+Comment[ga]=Breiseán Kate
+Comment[gl]=Plugin de Kate
+Comment[he]=תוסף ל־Kate
+Comment[hi]=के-एटीई प्लगइन
+Comment[hr]=Kate dodatak
+Comment[hu]=Kate bővítőmodul
+Comment[is]=Kate íforrit
+Comment[it]=Plugin di Kate
+Comment[ja]=Kate プラグイン
+Comment[ka]=Kate–ს პლაგინი
+Comment[kk]=Kate модулі
+Comment[km]=កម្មវិធី​ជំនួយ Kate
+Comment[ko]=셸 명령 플러그인
+Comment[lo]=ປັລກອິນຂອງ Kate
+Comment[lt]=Kate priedas
+Comment[lv]=Kate spraudnis
+Comment[mk]=Приклучок за Кате
+Comment[mn]=Kate-Plugin
+Comment[ms]=Plugin Kate
+Comment[mt]=Plagin ta' Kate
+Comment[nb]=Kate-programtillegg
+Comment[nds]=Kate-Plugin
+Comment[ne]=क्येट प्लगइन
+Comment[nl]=Kate-plugin
+Comment[nn]=Kate-programtillegg
+Comment[nso]=Tsenyo ya Kate
+Comment[pa]=ਕੇਟ ਪਲੱਗਇਨ
+Comment[pl]=Wtyczka Kate
+Comment[pt]='Plugin' do Kate
+Comment[pt_BR]=Plug-in do Kate
+Comment[ro]=Modul Kate
+Comment[ru]=Модуль Kate
+Comment[rw]=Icomeka rya Kate
+Comment[se]=Kate-lassemoduvla
+Comment[sk]=Modul Kate
+Comment[sl]=Vstavek za Kate
+Comment[sr]=Kate-ин прикључак
+Comment[sr@Latn]=Kate-in priključak
+Comment[ss]=I-plugin ye Kate
+Comment[sv]=Kate-insticksprogram
+Comment[ta]=Kபதிப்பான் செருகல்
+Comment[te]=కేట్ ప్లగిన్
+Comment[tg]=Мутассалкунандаи Kate
+Comment[th]=ปลั้กอินของ Kate
+Comment[tr]=Kate Eklentisi
+Comment[tt]=Kate Östämäse
+Comment[uk]=Втулок Kate
+Comment[uz]=Kate uchun plagin
+Comment[uz@cyrillic]=Kate учун плагин
+Comment[vi]=Trình bổ sung cho Kate
+Comment[wa]=Tchôke divins di Kate
+Comment[xh]=Iplagi efakiweyo ye Kate
+Comment[zh_CN]=Kate 插件
+Comment[zh_TW]=Kate 外掛程式
+Comment[zu]=I-Plugin ye-Kate
+
+[PropertyDef::X-Kate-Version]
+Type=TQString
+
+[PropertyDef::X-Kate-PluginName]
+Type=TQString
diff --git a/kate/data/katerc b/kate/data/katerc
new file mode 100644
index 000000000..331a30496
--- /dev/null
+++ b/kate/data/katerc
@@ -0,0 +1,2 @@
+[KNewStuff]
+ProvidersUrl=http://kate.kde.org/share/providers.xml \ No newline at end of file
diff --git a/kate/data/kateui.rc b/kate/data/kateui.rc
new file mode 100644
index 000000000..5368c26c4
--- /dev/null
+++ b/kate/data/kateui.rc
@@ -0,0 +1,171 @@
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
+<kpartgui name="kate" version="49">
+
+<MenuBar noMerge="1">
+ <Menu name="file"><text>&amp;File</text>
+ <Action name="file_new" />
+ <DefineGroup name="new_merge" />
+ <Separator />
+
+ <Action name="file_open"/>
+ <Action name="file_open_recent"/>
+ <Action name="file_open_with"/>
+ <DefineGroup name="open_merge" />
+ <Separator />
+
+ <DefineGroup name="save_merge" />
+ <Action name="file_save_all" />
+ <Separator />
+
+ <DefineGroup name="revert_merge" />
+ <DefineGroup name="print_merge" />
+ <Action name="file_mail" />
+ <Separator />
+
+ <Action name="file_close"/>
+ <Action name="file_close_all"/>
+ <Separator />
+
+ <Action name="file_quit"/>
+ </Menu>
+
+ <Menu name="edit"><text>&amp;Edit</text>
+ <DefineGroup name="edit_undo_merge" />
+ <Separator group="edit_undo_merge" />
+ <DefineGroup name="edit_paste_merge" />
+ <Separator />
+ <DefineGroup name="edit_select_merge" />
+ <Separator />
+ <DefineGroup name="edit_find_merge" />
+ <Separator />
+ </Menu>
+
+ <Menu name="documents"><text>&amp;Document</text>
+ <Action name="go_back"/>
+ <Action name="go_forward"/>
+ <Separator />
+ </Menu>
+
+ <Menu name="view"><text>&amp;View</text>
+ <DefineGroup name="view_operations" />
+ </Menu>
+
+ <Merge/>
+
+ <Menu name="tools"><text>&amp;Tools</text>
+ <Action name="tools_pipe_to_terminal"/>
+ <Action name="tools_external" />
+ <Separator />
+ <DefineGroup name="tools_operations" />
+ </Menu>
+
+ <Menu name="sessions"><text>Sess&amp;ions</text>
+ <Action name="sessions_new"/>
+ <Action name="sessions_open"/>
+ <Action name="sessions_list"/>
+ <Separator />
+ <Action name="sessions_save"/>
+ <Action name="sessions_save_as"/>
+ <Separator />
+ <Action name="sessions_manage"/>
+ </Menu>
+
+ <Menu name="settings"><text>&amp;Settings</text>
+ <Merge name="StandardToolBarMenuHandler"/>
+ <DefineGroup name="show_merge" />
+ <DefineGroup name="configure_merge" />
+ <Separator />
+ <Action name="fullscreen" />
+ <Separator />
+ <Action name="options_configure_keybinding"/>
+ <Action name="options_configure_toolbars"/>
+ <Action name="settings_configure" />
+ </Menu>
+
+ <Menu name="window"><text>&amp;Window</text>
+ <Action name="view_new_view" />
+ <Separator />
+<!-- <Action name="view_new_tab"/>
+ <Action name="view_close_tab"/>
+ <Separator />
+ <Action name="view_next_tab"/>
+ <Action name="view_prev_tab"/>
+ <Separator />-->
+ <Action name="view_split_vert"/>
+ <Action name="view_split_horiz"/>
+ <Action name="view_close_current_space" />
+ <Separator />
+ <Action name="go_next"/>
+ <Action name="go_prev"/>
+ <Separator/>
+ <Merge name="kate_mdi_window_actions"/>
+ </Menu>
+
+ <Menu name="help"><text>&amp;Help</text>
+ <Action name="help_contents"/>
+ <Action name="help_plugins_contents"/>
+ <Action name="help_whats_this"/>
+ <Action name="help_show_tip" />
+ <Separator/>
+ <Action name="help_report_bug"/>
+ <Separator/>
+ <Action name="help_about_app"/>
+ <Action name="help_about_kde"/>
+ </Menu>
+</MenuBar>
+
+<ToolBar name="mainToolBar" noMerge="1"><text>Main Toolbar</text>
+ <DefineGroup name="file_open" />
+ <Action name="file_new" group="file_open" />
+ <Action name="file_open" group="file_open" />
+ <Separator />
+ <Action name="go_back" />
+ <Action name="go_forward" />
+ <Separator />
+ <DefineGroup name="file_operations" />
+ <Separator />
+ <DefineGroup name="print_merge" />
+ <Separator />
+ <Action name="file_close" />
+ <Separator />
+ <DefineGroup name="edit_operations" />
+ <Separator />
+ <DefineGroup name="find_operations" />
+ <Separator />
+ <DefineGroup name="zoom_operations" />
+</ToolBar>
+
+<Menu name="tdetexteditor_popup" noMerge="1">
+ <DefineGroup name="popup_operations" />
+</Menu>
+
+<Menu name="viewspace_popup" noMerge="1">
+ <Action name="view_split_vert"/>
+ <Action name="view_split_horiz"/>
+ <Separator />
+ <Action name="view_close_current_space" />
+ <Separator />
+ <Action name="go_back"/>
+ <Action name="go_forward"/>
+ <Action name="doc_list"/>
+</Menu>
+
+<Menu name="filelist_popup" noMerge="1">
+ <DefineGroup name="save_merge" />
+ <Action name="file_save_all"/>
+ <Separator/>
+ <DefineGroup name="revert_merge" />
+ <Action name="file_open_with" />
+ <Separator/>
+ <DefineGroup name="print_merge" />
+ <Separator/>
+ <Action name="file_close"/>
+ <Action name="file_close_all"/>
+ <Separator/>
+ <Action name="filelist_move_up"/>
+ <Action name="filelist_move_down"/>
+ <Separator/>
+ <Action name="filelist_sortby"/>
+</Menu>
+
+</kpartgui>
diff --git a/kate/data/kwrite.desktop b/kate/data/kwrite.desktop
new file mode 100644
index 000000000..6bbdf70c6
--- /dev/null
+++ b/kate/data/kwrite.desktop
@@ -0,0 +1,111 @@
+[Desktop Entry]
+GenericName=Text Editor
+GenericName[af]=Teks Redigeerder
+GenericName[az]=Mətn Editoru
+GenericName[be]=Тэкставы рэдактар
+GenericName[bg]=Текстов редактор
+GenericName[bn]=টেক্সট সম্পাদক
+GenericName[br]=Aozer skrid
+GenericName[bs]=Tekst editor
+GenericName[ca]=Editor de text
+GenericName[cs]=Textový editor
+GenericName[csb]=Tekstowi editora
+GenericName[cy]=Golygydd Testun
+GenericName[da]= Teksteditor
+GenericName[de]=Texteditor
+GenericName[el]=Επεξεργαστής κειμένου
+GenericName[eo]=Tekstredaktilo
+GenericName[es]=Editor de texto
+GenericName[et]=Tekstiredaktor
+GenericName[eu]=Testu editorea
+GenericName[fa]=ویرایشگر متن
+GenericName[fi]=Tekstieditori
+GenericName[fo]=Tekstritil
+GenericName[fr]=Éditeur de texte
+GenericName[fy]=Tekstbewurker
+GenericName[ga]=Eagarthóir Téacs
+GenericName[gl]=Editor de Textos
+GenericName[he]=עורך טקסט
+GenericName[hi]=पाठ संपादक
+GenericName[hr]=Uređivač teksta
+GenericName[hsb]=Wobdźěłar tekstow
+GenericName[hu]=Szövegszerkesztő
+GenericName[is]=Textaritill
+GenericName[it]=Editor di testi
+GenericName[ja]=テキストエディタ
+GenericName[ka]=ტექსტური რედაქტორი
+GenericName[kk]=Мәтін редакторы
+GenericName[km]=កម្មវិធី​វាយ​អត្ថបទ
+GenericName[ko]=텍스트 편집기
+GenericName[lo]=ເຄື່ອງມືແກ້ໄຂຂໍ້ຄວາມ
+GenericName[lt]=Teksto redaktorius
+GenericName[lv]=Teksta Redaktors
+GenericName[mk]=Уредувач на текст
+GenericName[mn]=Текст боловсруулагч
+GenericName[ms]=Penyunting Teks
+GenericName[mt]=Editur tat-test
+GenericName[nb]=Skriveprogram
+GenericName[nds]=Texteditor
+GenericName[ne]=पाठ सम्पादक
+GenericName[nl]=Teksteditor
+GenericName[nn]=Skriveprogram
+GenericName[nso]=Mofetosi wa Sengwalwana
+GenericName[pa]=ਪਾਠ ਸੰਪਾਦਕ
+GenericName[pl]=Edytor tekstu
+GenericName[pt]=Editor de Texto
+GenericName[pt_BR]=Editor de Texto
+GenericName[ro]=Editor de text
+GenericName[ru]=Текстовый редактор
+GenericName[rw]=Muhinduzi Umwandiko
+GenericName[se]=Čállinprográmma
+GenericName[sk]=Textový editor
+GenericName[sl]=Urejevalnik besedil
+GenericName[sr]=Уређивач текста
+GenericName[sr@Latn]=Uređivač teksta
+GenericName[ss]=Sihleli sembhalo
+GenericName[sv]=Texteditor
+GenericName[ta]=உரை தொகுப்பாளர்
+GenericName[te]=వచన ఎడిటర్
+GenericName[tg]=Муҳаррири матн
+GenericName[th]=โปรแกรมแก้ไขข้อความ
+GenericName[tr]=Metin Düzenleyici
+GenericName[tt]=Mäten Tözätkeçe
+GenericName[uk]=Редактор текстів
+GenericName[uz]=Matn tahrirchi
+GenericName[uz@cyrillic]=Матн таҳрирчи
+GenericName[ven]=Musengulusi wa Manwalwa
+GenericName[vi]=Trình soạn văn bản
+GenericName[wa]=Aspougneu di tecse
+GenericName[xh]=Umhleli Wombhalo
+GenericName[zh_CN]=文本编辑器
+GenericName[zh_TW]=文字編輯器
+GenericName[zu]=Umlungisi wombhalo
+Name=KWrite
+Name[af]=Kskryf
+Name[bn]=কে-রাইট
+Name[eo]=Malnova simpla kodredaktilo
+Name[fo]=KSkriva
+Name[hi]=के-राइट
+Name[ka]=რედაქტორი KWrite
+Name[kk]=KWrite редакторы
+Name[lo]=Kwrite
+Name[mn]=Кврайт
+Name[ne]=केडीई राइट
+Name[nso]=KNgwala
+Name[pa]=ਕੇ-ਲੇਖਕ
+Name[rw]=K-Kwandika
+Name[sv]=Kwrite
+Name[te]=కెవ్రైట్
+Name[tg]=Навиштори K
+Name[ven]=Nwala ha K
+MimeType=text/plain;
+Exec=kwrite %U
+X-TDE-StartupNotify=true
+Icon=kwrite
+Path=
+DocPath=kwrite/index.html
+Type=Application
+Terminal=false
+InitialPreference=8
+X-DCOP-ServiceType=Multi
+Categories=Qt;TDE;TextEditor;
diff --git a/kate/data/kwriteui.rc b/kate/data/kwriteui.rc
new file mode 100644
index 000000000..9a41f43d1
--- /dev/null
+++ b/kate/data/kwriteui.rc
@@ -0,0 +1,95 @@
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
+<kpartgui name="kwrite" version="16">
+
+<MenuBar>
+ <Menu name="file" noMerge="1"><text>&amp;File</text>
+ <Action name="file_new"/>
+ <Separator/>
+
+ <Action name="file_open"/>
+ <Action name="file_open_recent"/>
+ <Separator/>
+
+ <DefineGroup name="save_merge" append="save_merge" />
+ <Separator/>
+
+ <DefineGroup name="revert_merge" append="revert_merge"/>
+ <DefineGroup name="print_merge" append="print_merge"/>
+ <Separator/>
+
+ <Action name="file_close"/>
+ <DefineGroup name="close_merge" append="close_merge"/>
+ <Separator/>
+
+ <Action name="file_quit"/>
+ </Menu>
+
+ <Menu name="edit" noMerge="1"><text>&amp;Edit</text>
+ <DefineGroup name="edit_undo_merge"/>
+ <Separator/>
+ <DefineGroup name="edit_paste_merge"/>
+ <Separator/>
+ <DefineGroup name="edit_select_merge"/>
+ <Separator/>
+ <DefineGroup name="edit_find_merge"/>
+ <Separator/>
+ <Merge/>
+ </Menu>
+
+ <Menu name="view" noMerge="1"><text>&amp;View</text>
+ <Action name="view_new_view" />
+ <Separator />
+ <DefineGroup name="view_operations" />
+ </Menu>
+
+ <Menu name="tools" noMerge="1"><text>&amp;Tools</text>
+ <DefineGroup name="tools_operations" />
+ </Menu>
+
+ <Merge/>
+
+ <Menu name="settings"><text>&amp;Settings</text>
+ <Merge name="StandardToolBarMenuHandler" />
+ <DefineGroup name="show_toolbar_merge" />
+ <Action name="settings_show_statusbar" append="show_merge"/>
+ <Action name="set_showPath" append="show_merge"/>
+ <DefineGroup name="show_merge" />
+ <DefineGroup name="configure_merge" append="save_merge"/>
+ <Action name="options_configure_toolbars" />
+ <Action name="settings_configure" append="configure_merge"/>
+ <Action name="settings_choose_editor" append="save_merge"/>
+ </Menu>
+
+ <Menu name="help" noMerge="1"><text>&amp;Help</text>
+ <Action name="help_contents"/>
+ <Action name="help_whats_this"/>
+ <Separator/>
+ <Action name="help_report_bug"/>
+ <Separator/>
+ <Action name="help_about_app"/>
+ <Action name="help_about_kde"/>
+ </Menu>
+</MenuBar>
+
+<ToolBar name="mainToolBar" noMerge="1"><text>Main Toolbar</text>
+ <Action name="file_new" />
+ <Action name="file_open" />
+ <Separator />
+ <DefineGroup name="file_operations" />
+ <Separator />
+ <DefineGroup name="print_merge" />
+ <Separator />
+ <Action name="file_close" />
+ <Separator />
+ <DefineGroup name="edit_operations" />
+ <Separator />
+ <DefineGroup name="find_operations" />
+ <Separator />
+ <DefineGroup name="zoom_operations" />
+</ToolBar>
+
+<Menu name="tdetexteditor_popup" noMerge="1">
+ <DefineGroup name="popup_operations" />
+</Menu>
+
+</kpartgui>
diff --git a/kate/data/tips b/kate/data/tips
new file mode 100644
index 000000000..aaee34424
--- /dev/null
+++ b/kate/data/tips
@@ -0,0 +1,122 @@
+<tip category="Kate|app">
+<html>
+<p>Kate comes with a nice set of plugins, providing simple
+and advanced features of all sorts.</p>
+<p>You can enable/disable plugins to suit your needs in the configuration dialog,
+choose <strong>Settings -&gt;configure</strong> to launch that.</p>
+</html>
+</tip>
+<tip category="Kate|part">
+<html>
+<p>You can swap the characters on each side of the cursor just by pressing
+<strong>Ctrl+T</strong></p>
+</html>
+</tip>
+<tip category="Kate|part">
+<html>
+<p>You can export the current document as a HTML file, including
+syntax highlighting.</p>
+<p>Just choose <strong>File -&gt; Export -&gt; HTML...</strong></p>
+</html>
+</tip>
+<tip category="Kate|app">
+<html>
+<p>You can split the Kate editor as many times as you like and
+in either direction. Each frame has its own status bar and
+can display any open document.</p>
+<p>Just choose <br><strong>View -&gt; Split [ Horizontal | Vertical ]</strong></p>
+</html>
+</tip>
+<tip category="Kate|app">
+<html>
+<p>You can drag the Tool views (<em>File List</em> and <em>File Selector</em>)
+to any side that you want them in Kate, or stack them, or even tear them off the
+main window.</p>
+</html>
+</tip>
+<tip category="Kate|app">
+<html>
+<p>Kate has a built-in terminal emulator, just click on <strong>"Terminal"</strong> at
+the bottom to show or hide it as you desire.</p>
+</html>
+</tip>
+<tip category="Kate|part">
+<html>
+<p>Kate can highlight the current line with a
+<table bgcolor="yellow" border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td>different
+background color.<strong>|</strong></td></tr></table></p>
+<p>You can set the color in the <em>Colors</em> page of the configuration
+dialog.</p>
+</html>
+</tip>
+<tip category="Kate|app">
+<html>
+<p>You can open the currently edited file in any other application from within
+Kate.</p>
+<p>Choose <strong>File -&gt; Open With</strong> for the list of programs
+configured
+for the document type. There is also an option <strong>Other...</strong> to
+choose any application on your system.</p>
+</html>
+</tip>
+<tip category="Kate|part">
+<html>
+<p>You can configure the editor to always display the line numbers and/or
+bookmark panes when started from the <strong>View Defaults</strong> page of the
+configuration dialog.</p>
+</html>
+</tip>
+<tip category="Kate|part">
+<html>
+<p>You can download new or updated <em>Syntax highlight definitions</em> from
+the <strong>Highlighting</strong> page in the configuration dialog.</p>
+<p>Just click the <em>Download...</em> button on the <em>Highlight Modes</em>
+tab (You have to be online, of course...).</p>
+</html>
+</tip>
+<tip category="Kate|app">
+<html>
+<p>You can cycle through all open documents by pressing <strong>Alt+Left</strong>
+or <strong>Alt+Right</strong>. The next/previous document will immediately be displayed
+in the active frame.</p>
+</html>
+</tip>
+<tip category="Kate|part">
+<html>
+<p>You can do cool sed-like regular expression replacements using <em>Command Line</em>.</p>
+<p>For example, press <strong>F7</strong> and enter <code>s /oldtext/newtext/g</code>
+to replace &quot;oldtext&quot; with &quot;newtext&quot; throughout the current
+line.</p>
+</html>
+</tip>
+<tip category="Kate|part">
+<html>
+<p>You can repeat your last search by just pressing <strong>F3</strong>, or
+<strong>Shift+F3</strong> if you want to search backwards.</p>
+</html>
+</tip>
+<tip category="Kate|app">
+<html>
+<p>You can filter the files displayed in the <em>File Selector</em> tool view.
+</p>
+<p>Simply enter your filter in the filter entry at the bottom, for example:
+<code>*.html *.php</code> if you only want to see HTML and PHP files in the
+current folder.</p>
+<p>The File Selector will even remember your filters for you.</strong></p>
+</html>
+</tip>
+<tip category="Kate|app">
+<html>
+<p>You can have two views - or even more - of the same document in Kate. Editing
+in either will be reflected in both.</p>
+<p>So if you find yourself scrolling up and down to look at text at the other
+end of a document, just press <strong>Ctrl+Shift+T</strong> to split
+horizontally.</p>
+</html>
+</tip>
+<tip category="kate|app">
+<html>
+<p>Press <strong>F8</strong> or <strong>Shift+F8</strong> to switch to the
+next/previous frame.</p>
+</html>
+</tip>
diff --git a/kate/interfaces/CMakeLists.txt b/kate/interfaces/CMakeLists.txt
new file mode 100644
index 000000000..eb7577394
--- /dev/null
+++ b/kate/interfaces/CMakeLists.txt
@@ -0,0 +1,47 @@
+#################################################
+#
+# (C) 2010-2011 Serghei Amelian
+# serghei (DOT) amelian (AT) gmail.com
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}
+ ${TDE_INCLUDE_DIR}
+ ${TQT_INCLUDE_DIRS}
+)
+
+link_directories(
+ ${TQT_LIBRARY_DIRS}
+)
+
+##### headers ###################################
+
+install( FILES
+ application.h documentmanager.h mainwindow.h
+ plugin.h viewmanager.h pluginconfiginterface.h
+ pluginconfiginterfaceextension.h toolviewmanager.h
+ pluginmanager.h
+ DESTINATION ${INCLUDE_INSTALL_DIR}/kate )
+
+
+##### kateinterfacesprivate (static lib) ########
+
+set( target kateinterfacesprivate )
+
+set( ${target}_SRCS
+ application.cpp mainwindow.cpp documentmanager.cpp
+ viewmanager.cpp toolviewmanager.cpp pluginmanager.cpp
+ plugin.cpp pluginconfiginterface.cpp
+ pluginconfiginterfaceextension.cpp
+)
+
+tde_add_library( ${target} STATIC_PIC AUTOMOC
+ SOURCES ${${target}_SRCS}
+ LINK katepartinterfaces-shared
+)
diff --git a/kate/interfaces/Makefile.am b/kate/interfaces/Makefile.am
new file mode 100644
index 000000000..57901370b
--- /dev/null
+++ b/kate/interfaces/Makefile.am
@@ -0,0 +1,14 @@
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libkateinterfacesprivate.la
+
+libkateinterfacesprivate_la_SOURCES = application.cpp mainwindow.cpp documentmanager.cpp viewmanager.cpp toolviewmanager.cpp \
+ pluginmanager.cpp plugin.cpp pluginconfiginterface.cpp pluginconfiginterfaceextension.cpp
+
+libkateinterfacesprivate_la_LIBADD = -lkatepartinterfaces
+libkateinterfacesprivate_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor
+
+kateinclude_HEADERS = application.h documentmanager.h mainwindow.h plugin.h viewmanager.h pluginconfiginterface.h pluginconfiginterfaceextension.h toolviewmanager.h pluginmanager.h
+kateincludedir = $(includedir)/kate
+
+INCLUDES= $(all_includes)
diff --git a/kate/interfaces/application.cpp b/kate/interfaces/application.cpp
new file mode 100644
index 000000000..5aded5505
--- /dev/null
+++ b/kate/interfaces/application.cpp
@@ -0,0 +1,97 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "application.h"
+#include "application.moc"
+
+#include "documentmanager.h"
+#include "mainwindow.h"
+#include "pluginmanager.h"
+
+#include "../app/kateapp.h"
+#include "../app/katedocmanager.h"
+#include "../app/katepluginmanager.h"
+#include "../app/katemainwindow.h"
+
+namespace Kate
+{
+
+class PrivateApplication
+ {
+ public:
+ PrivateApplication ()
+ {
+ }
+
+ ~PrivateApplication ()
+ {
+
+ }
+
+ KateApp *app;
+ };
+
+Application::Application (void *application) : TQObject ((KateApp *) application)
+{
+ d = new PrivateApplication;
+ d->app = (KateApp *) application;
+}
+
+Application::~Application ()
+{
+ delete d;
+}
+
+DocumentManager *Application::documentManager ()
+{
+ return d->app->documentManager ()->documentManager ();
+}
+
+PluginManager *Application::pluginManager ()
+{
+ return d->app->pluginManager ()->pluginManager ();
+}
+
+MainWindow *Application::activeMainWindow ()
+{
+ if (!d->app->activeMainWindow())
+ return 0;
+
+ return d->app->activeMainWindow()->mainWindow();
+}
+
+uint Application::mainWindows ()
+{
+ return d->app->mainWindows ();
+}
+
+MainWindow *Application::mainWindow (uint n)
+{
+ if (n < mainWindows ())
+ return d->app->mainWindow (n)->mainWindow();
+
+ return 0;
+}
+
+Application *application ()
+{
+ return KateApp::self()->application ();
+}
+
+}
+
diff --git a/kate/interfaces/application.h b/kate/interfaces/application.h
new file mode 100644
index 000000000..52eb129d5
--- /dev/null
+++ b/kate/interfaces/application.h
@@ -0,0 +1,79 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _KATE_APPLICATION_INCLUDE_
+#define _KATE_APPLICATION_INCLUDE_
+
+#include <tqobject.h>
+#include <kurl.h>
+
+namespace Kate
+{
+
+class DocumentManager;
+class PluginManager;
+class InitPluginManager;
+class MainWindow;
+
+/**
+ * Interface to the application, beside some global methodes to access
+ * other objects like document/projectmanager, ... no way goes around this
+ * central interface
+ */
+class KDE_EXPORT Application : public TQObject
+{
+ friend class PrivateApplication;
+
+ Q_OBJECT
+
+ public:
+ /**
+ * Construtor, should not interest, internal usage
+ */
+ Application (void *application);
+
+ /**
+ * Desctructor
+ */
+ virtual ~Application ();
+
+ public:
+ /** Returns a pointer to the document manager
+ */
+ Kate::DocumentManager *documentManager ();
+
+ Kate::PluginManager *pluginManager ();
+
+ Kate::MainWindow *activeMainWindow ();
+
+ uint mainWindows ();
+ Kate::MainWindow *mainWindow (uint n = 0);
+
+ private:
+ class PrivateApplication *d;
+};
+
+/**
+ * Returns the application object
+ * @return Application application object
+ */
+KDE_EXPORT Application *application ();
+
+}
+
+#endif
diff --git a/kate/interfaces/documentmanager.cpp b/kate/interfaces/documentmanager.cpp
new file mode 100644
index 000000000..750839781
--- /dev/null
+++ b/kate/interfaces/documentmanager.cpp
@@ -0,0 +1,120 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "documentmanager.h"
+#include "documentmanager.moc"
+
+#include "plugin.h"
+#include "viewmanager.h"
+#include "toolviewmanager.h"
+#include "pluginmanager.h"
+
+#include "application.h"
+
+#include "../app/katedocmanager.h"
+
+namespace Kate
+{
+
+class PrivateDocumentManager
+ {
+ public:
+ PrivateDocumentManager ()
+ {
+ }
+
+ ~PrivateDocumentManager ()
+ {
+ }
+
+ KateDocManager *docMan;
+ };
+
+DocumentManager::DocumentManager (void *documentManager) : TQObject ((KateDocManager*) documentManager)
+{
+ d = new PrivateDocumentManager ();
+ d->docMan = (KateDocManager*) documentManager;
+}
+
+DocumentManager::~DocumentManager ()
+{
+ delete d;
+}
+
+Document *DocumentManager::document (uint n)
+{
+ return d->docMan->document (n);
+}
+
+Document *DocumentManager::activeDocument ()
+{
+ return d->docMan->activeDocument ();
+}
+
+Document *DocumentManager::documentWithID (uint id)
+{
+ return d->docMan->documentWithID (id);
+}
+
+int DocumentManager::findDocument (const KURL &url)
+{
+ return d->docMan->findDocument (url);
+}
+
+bool DocumentManager::isOpen (const KURL &url)
+{
+ return d->docMan->isOpen (url);
+}
+
+uint DocumentManager::documents ()
+{
+ return d->docMan->documents ();
+}
+
+Document *DocumentManager::openURL(const KURL&url,const TQString &encoding,uint *id)
+{
+ return d->docMan->openURL (url, encoding, id);
+}
+
+bool DocumentManager::closeDocument(Document *document)
+{
+ return d->docMan->closeDocument (document);
+}
+
+bool DocumentManager::closeDocument(uint n)
+{
+ return d->docMan->closeDocument (n);
+}
+
+bool DocumentManager::closeDocumentWithID(uint id)
+{
+ return d->docMan->closeDocument (id);
+}
+
+bool DocumentManager::closeAllDocuments()
+{
+ return d->docMan->closeAllDocuments ();
+}
+
+DocumentManager *documentManager ()
+{
+ return application()->documentManager ();
+}
+
+}
+
diff --git a/kate/interfaces/documentmanager.h b/kate/interfaces/documentmanager.h
new file mode 100644
index 000000000..8b5f554af
--- /dev/null
+++ b/kate/interfaces/documentmanager.h
@@ -0,0 +1,111 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _KATE_DOCMANAGER_INCLUDE_
+#define _KATE_DOCMANAGER_INCLUDE_
+
+#include <tqobject.h>
+#include <kurl.h>
+
+namespace Kate
+{
+/** This interface provides access to the Kate Document Manager.
+*/
+class KDE_EXPORT DocumentManager : public TQObject
+{
+ friend class PrivateDocumentManager;
+
+ Q_OBJECT
+
+ public:
+ DocumentManager ( void *documentManager );
+ virtual ~DocumentManager ();
+
+ public:
+ /** Returns a pointer to the document indexed by n in the managers internal list.
+ */
+ class Document *document (uint n = 0);
+ /** Returns a pointer to the currently active document or NULL if no document is open.
+ */
+ class Document *activeDocument ();
+ /** Returns a pointer to the document with the given ID or NULL if no such document exists.
+ */
+ class Document *documentWithID (uint id);
+
+ /** Returns the ID of the document located at url if such a document is known by the manager.
+ */
+ int findDocument (const KURL &url);
+ /** Returns true if the document located at url is open, otherwise false.
+ */
+ bool isOpen (const KURL &url);
+
+ /** returns the number of documents managed by this manager.
+ */
+ uint documents ();
+
+ /** open a document and return a pointer to the document, if you specify a pointer != 0 to the id parameter
+ * you will get the document id returned too
+ */
+ class Document *openURL(const KURL&url,const TQString &encoding=TQString::null,uint *id =0);
+ /** close a document by pointer
+ */
+ bool closeDocument(class Document *document);
+ /** close a document identified by the index
+ */
+ bool closeDocument(uint n = 0);
+ /** close a document identified by the ID
+ */
+ bool closeDocumentWithID(uint id);
+ /** close all documents
+ */
+ bool closeAllDocuments();
+
+ #undef signals
+ #define signals public
+ signals:
+ #undef signals
+ #define signals protected
+
+ /**
+ * emitted if the current doc changes (there need not to be a active document)
+ */
+ void documentChanged ();
+
+ /**
+ * this document has now been created
+ */
+ void documentCreated (Kate::Document *document);
+
+ /**
+ * the document with this number was deleted
+ */
+ void documentDeleted (uint documentNumber);
+
+ private:
+ class PrivateDocumentManager *d;
+};
+
+/**
+ * Returns the document manager object
+ * @return DocumentManager document manager object
+ */
+KDE_EXPORT DocumentManager *documentManager ();
+
+}
+
+#endif
diff --git a/kate/interfaces/mainwindow.cpp b/kate/interfaces/mainwindow.cpp
new file mode 100644
index 000000000..4596cacb5
--- /dev/null
+++ b/kate/interfaces/mainwindow.cpp
@@ -0,0 +1,82 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "mainwindow.h"
+#include "mainwindow.moc"
+
+#include "documentmanager.h"
+#include "plugin.h"
+#include "viewmanager.h"
+#include "toolviewmanager.h"
+#include "pluginmanager.h"
+
+#include "../app/katemainwindow.h"
+#include "../app/kateviewmanager.h"
+
+namespace Kate
+{
+
+class PrivateMainWindow
+ {
+ public:
+ PrivateMainWindow ()
+ {
+ }
+
+ ~PrivateMainWindow ()
+ {
+
+ }
+
+ KateMainWindow *win;
+ };
+
+MainWindow::MainWindow (void *mainWindow) : TQObject ((KateMainWindow*) mainWindow)
+{
+ d = new PrivateMainWindow;
+ d->win = (KateMainWindow*) mainWindow;
+}
+
+MainWindow::~MainWindow ()
+{
+ delete d;
+}
+
+KXMLGUIFactory *MainWindow::guiFactory() const
+{
+ return d->win->guiFactory();
+}
+
+ViewManager *MainWindow::viewManager () const
+{
+ return d->win->viewManager ()->viewManager ();
+}
+
+class TQWidget *MainWindow::centralWidget() const
+{
+ return d->win->centralWidget();
+}
+
+ToolViewManager *MainWindow::toolViewManager () const
+{
+ return d->win->toolViewManager ();
+}
+
+}
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/interfaces/mainwindow.h b/kate/interfaces/mainwindow.h
new file mode 100644
index 000000000..bb40ffb9c
--- /dev/null
+++ b/kate/interfaces/mainwindow.h
@@ -0,0 +1,65 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _KATE_MAINWINDOW_INCLUDE_
+#define _KATE_MAINWINDOW_INCLUDE_
+
+#include <tqobject.h>
+
+#include <kxmlguifactory.h>
+#include <kurl.h>
+
+namespace Kate
+{
+
+class ViewManager;
+
+class KDE_EXPORT MainWindow : public TQObject
+{
+ friend class PrivateMainWindow;
+
+ Q_OBJECT
+
+ public:
+ MainWindow (void *mainWindow);
+ virtual ~MainWindow ();
+
+ public: /*these are slots for kjs*/
+ KXMLGUIFactory *guiFactory() const;
+
+ public slots:
+ Kate::ViewManager *viewManager () const;
+
+ public :
+ /**
+ * Access the widget (in the middle of the 4 sidebars) in which the editor
+ * component and the KateTabBar are embedded. This widget is a TQVBox, so
+ * other child widgets can be embedded unter the editor widget.
+ */
+ class TQWidget *centralWidget() const;
+ class ToolViewManager *toolViewManager() const;
+
+ private:
+ class PrivateMainWindow *d;
+};
+
+}
+
+#endif
+
+// kate: space-indent on; indent-width 2; replace-tabs on;
diff --git a/kate/interfaces/plugin.cpp b/kate/interfaces/plugin.cpp
new file mode 100644
index 000000000..d68724549
--- /dev/null
+++ b/kate/interfaces/plugin.cpp
@@ -0,0 +1,106 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+ #include "application.h"
+
+#include "plugin.h"
+#include "plugin.moc"
+
+#include <tdeparts/componentfactory.h>
+
+namespace Kate
+{
+
+ class PrivatePlugin
+ {
+ public:
+ PrivatePlugin ()
+ {
+ }
+
+ ~PrivatePlugin ()
+ {
+ }
+ };
+
+ class PrivatePluginViewInterface
+ {
+ public:
+ PrivatePluginViewInterface ()
+ {
+ }
+
+ ~PrivatePluginViewInterface ()
+ {
+ }
+
+ };
+
+unsigned int Plugin::globalPluginNumber = 0;
+unsigned int PluginViewInterface::globalPluginViewInterfaceNumber = 0;
+
+Plugin::Plugin( Application *application, const char *name ) : TQObject (application, name )
+{
+ globalPluginNumber++;
+ myPluginNumber = globalPluginNumber;
+}
+
+Plugin::~Plugin()
+{
+}
+
+unsigned int Plugin::pluginNumber () const
+{
+ return myPluginNumber;
+}
+
+Application *Plugin::application () const
+{
+ return Kate::application();
+}
+
+PluginViewInterface::PluginViewInterface()
+{
+ globalPluginViewInterfaceNumber++;
+ myPluginViewInterfaceNumber = globalPluginViewInterfaceNumber;
+}
+
+PluginViewInterface::~PluginViewInterface()
+{
+}
+
+unsigned int PluginViewInterface::pluginViewInterfaceNumber () const
+{
+ return myPluginViewInterfaceNumber;
+}
+
+Plugin *createPlugin ( const char* libname, Application *application, const char *name, const TQStringList &args )
+{
+ return KParts::ComponentFactory::createInstanceFromLibrary<Plugin>( libname, application, name, args);
+}
+
+PluginViewInterface *pluginViewInterface (Plugin *plugin)
+{
+ if (!plugin)
+ return 0;
+
+ return static_cast<PluginViewInterface*>(plugin->tqt_cast("Kate::PluginViewInterface"));
+}
+
+}
+
diff --git a/kate/interfaces/plugin.h b/kate/interfaces/plugin.h
new file mode 100644
index 000000000..00932c5ff
--- /dev/null
+++ b/kate/interfaces/plugin.h
@@ -0,0 +1,87 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _KATE_PLUGIN_INCLUDE_
+#define _KATE_PLUGIN_INCLUDE_
+
+#include <tqwidget.h>
+#include <tqpixmap.h>
+#include <kicontheme.h>
+
+#include <kurl.h>
+
+namespace Kate
+{
+
+class Application;
+class MainWindow;
+
+class KDE_EXPORT Plugin : public TQObject
+{
+ friend class PrivatePlugin;
+
+ Q_OBJECT
+
+ public:
+ Plugin (Application *application = 0, const char *name = 0 );
+ virtual ~Plugin ();
+
+ unsigned int pluginNumber () const;
+
+ Application *application() const;
+
+ private:
+ class PrivatePlugin *d;
+ static unsigned int globalPluginNumber;
+ unsigned int myPluginNumber;
+};
+
+KDE_EXPORT Plugin *createPlugin ( const char* libname, Application *application = 0, const char *name = 0,const TQStringList &args = TQStringList() );
+
+/*
+ * view plugin class
+ * this plugin will be bound to a tdetexteditor::view
+ */
+class KDE_EXPORT PluginViewInterface
+{
+ friend class PrivatePluginViewInterface;
+
+ public:
+ PluginViewInterface ();
+ virtual ~PluginViewInterface ();
+
+ unsigned int pluginViewInterfaceNumber () const;
+
+ /*
+ * will be called from the part to bound the plugin to a view
+ */
+ virtual void addView (MainWindow *) = 0;
+ virtual void removeView (MainWindow *) = 0;
+
+ private:
+ class PrivatePluginViewInterface *d;
+ static unsigned int globalPluginViewInterfaceNumber;
+ unsigned int myPluginViewInterfaceNumber;
+};
+
+KDE_EXPORT PluginViewInterface *pluginViewInterface (Plugin *plugin);
+
+}
+
+#endif
diff --git a/kate/interfaces/pluginconfiginterface.cpp b/kate/interfaces/pluginconfiginterface.cpp
new file mode 100644
index 000000000..ab6c7d736
--- /dev/null
+++ b/kate/interfaces/pluginconfiginterface.cpp
@@ -0,0 +1,63 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "pluginconfiginterface.h"
+
+#include "plugin.h"
+
+namespace Kate
+{
+
+class PrivatePluginConfigInterface
+{
+ public:
+ PrivatePluginConfigInterface() {}
+ ~PrivatePluginConfigInterface() {}
+};
+
+}
+
+using namespace Kate;
+
+unsigned int PluginConfigInterface::globalPluginConfigInterfaceNumber = 0;
+
+PluginConfigInterface::PluginConfigInterface()
+{
+ globalPluginConfigInterfaceNumber++;
+ myPluginConfigInterfaceNumber = globalPluginConfigInterfaceNumber++;
+
+ d = new PrivatePluginConfigInterface();
+}
+
+PluginConfigInterface::~PluginConfigInterface()
+{
+ delete d;
+}
+
+unsigned int PluginConfigInterface::pluginConfigInterfaceNumber () const
+{
+ return myPluginConfigInterfaceNumber;
+}
+
+PluginConfigInterface *Kate::pluginConfigInterface (Plugin *plugin)
+{
+ if (!plugin)
+ return 0;
+
+ return static_cast<PluginConfigInterface*>(plugin->tqt_cast("Kate::PluginConfigInterface"));
+}
diff --git a/kate/interfaces/pluginconfiginterface.h b/kate/interfaces/pluginconfiginterface.h
new file mode 100644
index 000000000..f626b1cde
--- /dev/null
+++ b/kate/interfaces/pluginconfiginterface.h
@@ -0,0 +1,63 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __kate_pluginconfiginterface_h__
+#define __kate_pluginconfiginterface_h__
+
+#include <kdemacros.h>
+
+namespace Kate
+{
+
+/*
+* This is an interface for the KTextEditor::Document/Plugin/ViewPlugin classes !!!
+*/
+class KDE_EXPORT PluginConfigInterface
+{
+ friend class PrivatePluginConfigInterface;
+
+ public:
+ PluginConfigInterface();
+ virtual ~PluginConfigInterface();
+
+ unsigned int pluginConfigInterfaceNumber () const;
+
+ //
+ // slots !!!
+ //
+ public:
+ /**
+ Read/Write the config to the standard place where this editor
+ part saves it config, say: read/save default values for that
+ editor part
+ */
+ virtual void readConfig () = 0;
+ virtual void writeConfig () = 0;
+
+ private:
+ class PrivatePluginConfigInterface *d;
+ static unsigned int globalPluginConfigInterfaceNumber;
+ unsigned int myPluginConfigInterfaceNumber;
+};
+
+class Plugin;
+KDE_EXPORT PluginConfigInterface *pluginConfigInterface (Plugin *plugin);
+
+}
+
+#endif
diff --git a/kate/interfaces/pluginconfiginterfaceextension.cpp b/kate/interfaces/pluginconfiginterfaceextension.cpp
new file mode 100644
index 000000000..68b7b8ec1
--- /dev/null
+++ b/kate/interfaces/pluginconfiginterfaceextension.cpp
@@ -0,0 +1,68 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "pluginconfiginterfaceextension.h"
+#include "pluginconfiginterfaceextension.moc"
+
+#include "plugin.h"
+
+namespace Kate
+{
+
+class PrivatePluginConfigInterfaceExtension
+{
+ public:
+ PrivatePluginConfigInterfaceExtension() {}
+ ~PrivatePluginConfigInterfaceExtension() {}
+};
+
+}
+
+using namespace Kate;
+
+PluginConfigPage::PluginConfigPage ( TQWidget *parent, const char *name ) : TQWidget (parent, name) { }
+
+PluginConfigPage::~PluginConfigPage () { }
+
+unsigned int PluginConfigInterfaceExtension::globalPluginConfigInterfaceExtensionNumber = 0;
+
+PluginConfigInterfaceExtension::PluginConfigInterfaceExtension()
+{
+ globalPluginConfigInterfaceExtensionNumber++;
+ myPluginConfigInterfaceExtensionNumber = globalPluginConfigInterfaceExtensionNumber++;
+
+ d = new PrivatePluginConfigInterfaceExtension();
+}
+
+PluginConfigInterfaceExtension::~PluginConfigInterfaceExtension()
+{
+ delete d;
+}
+
+unsigned int PluginConfigInterfaceExtension::pluginConfigInterfaceExtensionNumber () const
+{
+ return myPluginConfigInterfaceExtensionNumber;
+}
+
+PluginConfigInterfaceExtension *Kate::pluginConfigInterfaceExtension (Plugin *plugin)
+{
+ if (!plugin)
+ return 0;
+
+ return static_cast<PluginConfigInterfaceExtension*>(plugin->tqt_cast("Kate::PluginConfigInterfaceExtension"));
+}
diff --git a/kate/interfaces/pluginconfiginterfaceextension.h b/kate/interfaces/pluginconfiginterfaceextension.h
new file mode 100644
index 000000000..8a64ec090
--- /dev/null
+++ b/kate/interfaces/pluginconfiginterfaceextension.h
@@ -0,0 +1,104 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __kate_pluginconfiginterfaceextension_h__
+#define __kate_pluginconfiginterfaceextension_h__
+
+#include <tqwidget.h>
+#include <tqpixmap.h>
+#include <kicontheme.h>
+
+namespace Kate
+{
+
+class KDE_EXPORT PluginConfigPage : public TQWidget
+{
+ Q_OBJECT
+
+ public:
+ PluginConfigPage ( TQWidget *parent=0, const char *name=0 );
+ virtual ~PluginConfigPage ();
+
+ //
+ // slots !!!
+ //
+ public:
+ /**
+ Applies the changes to the document
+ */
+ virtual void apply () = 0;
+
+ /**
+ Reset the changes
+ */
+ virtual void reset () = 0;
+
+ /**
+ Sets default options
+ */
+ virtual void defaults () = 0;
+
+ signals:
+ void changed();
+};
+
+/*
+* This is an interface for the KTextEditor::Document/Plugin/ViewPlugin classes !!!
+*/
+class KDE_EXPORT PluginConfigInterfaceExtension
+{
+ friend class PrivatePluginConfigInterfaceExtension;
+
+ public:
+ PluginConfigInterfaceExtension();
+ virtual ~PluginConfigInterfaceExtension();
+
+ unsigned int pluginConfigInterfaceExtensionNumber () const;
+
+ //
+ // slots !!!
+ //
+ public:
+ /**
+ Number of available config pages
+ */
+ virtual uint configPages () const = 0;
+
+ /**
+ returns config page with the given number,
+ config pages from 0 to configPages()-1 are available
+ if configPages() > 0
+ */
+ virtual PluginConfigPage *configPage (uint number = 0, TQWidget *parent = 0, const char *name=0 ) = 0;
+
+ virtual TQString configPageName (uint number = 0) const = 0;
+ virtual TQString configPageFullName (uint number = 0) const = 0;
+ virtual TQPixmap configPagePixmap (uint number = 0, int size = TDEIcon::SizeSmall) const = 0;
+
+ private:
+ class PrivatePluginConfigInterfaceExtension *d;
+ static unsigned int globalPluginConfigInterfaceExtensionNumber;
+ unsigned int myPluginConfigInterfaceExtensionNumber;
+};
+
+class Plugin;
+KDE_EXPORT PluginConfigInterfaceExtension *pluginConfigInterfaceExtension (Plugin *plugin);
+
+}
+
+#endif
diff --git a/kate/interfaces/pluginmanager.cpp b/kate/interfaces/pluginmanager.cpp
new file mode 100644
index 000000000..8d4f13f7c
--- /dev/null
+++ b/kate/interfaces/pluginmanager.cpp
@@ -0,0 +1,78 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "pluginmanager.moc"
+
+#include "plugin.h"
+#include "documentmanager.h"
+#include "toolviewmanager.h"
+#include "pluginmanager.h"
+
+#include "../app/katepluginmanager.h"
+#include "../app/kateapp.h"
+
+namespace Kate
+{
+
+class PrivatePluginManager
+ {
+ public:
+ PrivatePluginManager ()
+ {
+ }
+
+ ~PrivatePluginManager ()
+ {
+ }
+
+ KatePluginManager *pluginMan;
+ };
+
+PluginManager::PluginManager (void *pluginManager) : TQObject ((KatePluginManager*) pluginManager)
+{
+ d = new PrivatePluginManager ();
+ d->pluginMan = (KatePluginManager*) pluginManager;
+}
+
+PluginManager::~PluginManager ()
+{
+ delete d;
+}
+
+Plugin *PluginManager::plugin(const TQString &name)
+{
+ return d->pluginMan->plugin(name);
+}
+
+bool PluginManager::pluginAvailable(const TQString &name)
+{
+ return d->pluginMan->pluginAvailable (name);
+}
+
+Plugin *PluginManager::loadPlugin(const TQString &name,bool permanent)
+{
+ return d->pluginMan->loadPlugin (name, permanent);
+}
+
+void PluginManager::unloadPlugin(const TQString &name,bool permanent)
+{
+ d->pluginMan->unloadPlugin (name, permanent);
+}
+
+}
+
diff --git a/kate/interfaces/pluginmanager.h b/kate/interfaces/pluginmanager.h
new file mode 100644
index 000000000..0aeb7785e
--- /dev/null
+++ b/kate/interfaces/pluginmanager.h
@@ -0,0 +1,70 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+ Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _KATE_PLUGINMANAGER_INCLUDE_
+#define _KATE_PLUGINMANAGER_INCLUDE_
+
+#include <tqobject.h>
+#include <kurl.h>
+
+namespace Kate
+{
+/** This interface provides access to the Kate Plugin Manager.
+*/
+class KDE_EXPORT PluginManager : public TQObject
+{
+ friend class PrivatePluginManager;
+
+ Q_OBJECT
+
+ public:
+ PluginManager ( void *pluginManager );
+ virtual ~PluginManager ();
+
+ public:
+ /** if the plugin with the library name "name" is loaded, a pointer to that plugin is returned */
+ class Plugin *plugin(const TQString &name);
+
+ /** return true, if plugin is known to kate (either loaded or not loaded)
+ *
+ * This method is not used yet
+ */
+ bool pluginAvailable(const TQString &name);
+
+ /** tries loading the specified plugin and returns a pointer to the new plugin or 0
+ * if permanent is true (default value) the plugin will be loaded at the next kate startup
+ *
+ * This method is not used yet
+ */
+ class Plugin *loadPlugin(const TQString &name,bool permanent=true);
+
+ /** unload the specified plugin. If the value permanent is true (default value), the plugin will not be
+ * loaded on kate's next startup. Even if it had been loaded with permanent=true.
+ *
+ * This method is not used yet
+ */
+ void unloadPlugin(const TQString &name,bool permanent=true);
+
+ private:
+ class PrivatePluginManager *d;
+};
+
+}
+
+#endif
diff --git a/kate/interfaces/toolviewmanager.cpp b/kate/interfaces/toolviewmanager.cpp
new file mode 100644
index 000000000..1447cde84
--- /dev/null
+++ b/kate/interfaces/toolviewmanager.cpp
@@ -0,0 +1,85 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "toolviewmanager.h"
+#include "toolviewmanager.moc"
+
+#include "plugin.h"
+#include "documentmanager.h"
+#include "pluginmanager.h"
+
+#include "../app/katemainwindow.h"
+
+namespace Kate
+{
+
+class PrivateToolViewManager
+ {
+ public:
+ PrivateToolViewManager ()
+ {
+ }
+
+ ~PrivateToolViewManager ()
+ {
+ }
+
+ KateMainWindow *toolViewMan;
+ };
+
+ToolViewManager::ToolViewManager (void *toolViewManager) : TQObject ((KateMainWindow*) toolViewManager)
+{
+ d = new PrivateToolViewManager ();
+ d->toolViewMan = (KateMainWindow*) toolViewManager;
+}
+
+ToolViewManager::~ToolViewManager ()
+{
+ delete d;
+}
+
+TQWidget *ToolViewManager::createToolView (const TQString &identifier, ToolViewManager::Position pos, const TQPixmap &icon, const TQString &text)
+{
+ return d->toolViewMan->createToolView (identifier, (KMultiTabBar::KMultiTabBarPosition)pos, icon, text);
+}
+
+bool ToolViewManager::moveToolView (TQWidget *widget, ToolViewManager::Position pos)
+{
+ if (!widget || !widget->tqt_cast("KateMDI::ToolView"))
+ return false;
+
+ return d->toolViewMan->moveToolView (static_cast<KateMDI::ToolView*>(widget), (KMultiTabBar::KMultiTabBarPosition)pos);
+}
+
+bool ToolViewManager::showToolView(TQWidget *widget)
+{
+ if (!widget || !widget->tqt_cast("KateMDI::ToolView"))
+ return false;
+
+ return d->toolViewMan->showToolView (static_cast<KateMDI::ToolView*>(widget));
+}
+
+bool ToolViewManager::hideToolView(TQWidget *widget)
+{
+ if (!widget || !widget->tqt_cast("KateMDI::ToolView"))
+ return false;
+
+ return d->toolViewMan->hideToolView (static_cast<KateMDI::ToolView*>(widget));
+}
+
+}
diff --git a/kate/interfaces/toolviewmanager.h b/kate/interfaces/toolviewmanager.h
new file mode 100644
index 000000000..88a669476
--- /dev/null
+++ b/kate/interfaces/toolviewmanager.h
@@ -0,0 +1,96 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org>
+ Copyright (C) 2002 Christoph Cullmann <cullmann@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _KATE_TOOLVIEWMANAGER_INCLUDE_
+#define _KATE_TOOLVIEWMANAGER_INCLUDE_
+
+#include <tqwidget.h>
+#include <kurl.h>
+
+namespace Kate
+{
+
+/**
+ Interface to the toolviewmanager
+ */
+class KDE_EXPORT ToolViewManager : public TQObject
+{
+ friend class PrivateToolViewManager;
+
+ Q_OBJECT
+
+ public:
+ /**
+ * Construtor, should not interest, internal usage
+ */
+ ToolViewManager (void *toolViewManager);
+
+ /**
+ * Desctructor
+ */
+ virtual ~ToolViewManager ();
+
+ public:
+ /**
+ * positions
+ */
+ enum Position {Left, Right, Top, Bottom};
+
+ /**
+ * add a given widget to the given sidebar if possible, name is very important
+ * @param identifier unique identifier for this toolview
+ * @param pos position for the toolview, if we are in session restore, this is only a preference
+ * @param icon icon to use for the toolview
+ * @param text text to use in addition to icon
+ * @return created toolview on success or 0
+ */
+ TQWidget *createToolView (const TQString &identifier, ToolViewManager::Position pos, const TQPixmap &icon, const TQString &text);
+
+ /**
+ * Move the toolview
+ * @param widget to show, widget given must be widget constructed by createToolView
+ * @param pos position to move widget to
+ * @return bool success
+ */
+ bool moveToolView (TQWidget *widget, ToolViewManager::Position pos);
+
+ /**
+ * Show the toolview
+ * @param widget to show, widget given must be widget constructed by createToolView
+ * @return bool success
+ */
+ bool showToolView (TQWidget *widget);
+
+ /**
+ * Hide the toolview
+ * @param widget to hide, widget given must be widget constructed by createToolView
+ * @return bool success
+ */
+ bool hideToolView (TQWidget *widget);
+
+ private:
+ /**
+ * REALLY PRIVATE ;)
+ */
+ class PrivateToolViewManager *d;
+};
+
+}
+
+#endif
diff --git a/kate/interfaces/viewmanager.cpp b/kate/interfaces/viewmanager.cpp
new file mode 100644
index 000000000..d365f514e
--- /dev/null
+++ b/kate/interfaces/viewmanager.cpp
@@ -0,0 +1,73 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "viewmanager.h"
+#include "viewmanager.moc"
+
+#include "plugin.h"
+#include "documentmanager.h"
+#include "toolviewmanager.h"
+#include "pluginmanager.h"
+
+#include "../app/kateviewmanager.h"
+
+namespace Kate
+{
+
+class PrivateViewManager
+ {
+ public:
+ PrivateViewManager ()
+ {
+ }
+
+ ~PrivateViewManager ()
+ {
+ }
+
+ KateViewManager *viewMan;
+ };
+
+ViewManager::ViewManager (void *viewManager) : TQObject ((KateViewManager*) viewManager)
+{
+ d = new PrivateViewManager ();
+ d->viewMan = (KateViewManager*) viewManager;
+}
+
+ViewManager::~ViewManager ()
+{
+ delete d;
+}
+
+View *ViewManager::activeView()
+{
+ return d->viewMan->activeView();
+}
+
+void ViewManager::activateView ( uint documentNumber )
+{
+ d->viewMan->activateView( documentNumber );
+}
+
+void ViewManager::openURL (const KURL &url)
+{
+ d->viewMan->openURL (url, TQString::null, true);
+}
+
+}
+
diff --git a/kate/interfaces/viewmanager.h b/kate/interfaces/viewmanager.h
new file mode 100644
index 000000000..15eb61312
--- /dev/null
+++ b/kate/interfaces/viewmanager.h
@@ -0,0 +1,89 @@
+/* This file is part of the KDE project
+ Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _KATE_VIEWMANAGER_INCLUDE_
+#define _KATE_VIEWMANAGER_INCLUDE_
+
+#include <tqobject.h>
+#include <kurl.h>
+
+namespace Kate
+{
+
+class View;
+
+/**
+ * Interface to the viewmanager
+ */
+class KDE_EXPORT ViewManager : public TQObject
+{
+ friend class PrivateViewManager;
+
+ Q_OBJECT
+
+ public:
+ /**
+ * Construtor, should not interest, internal usage
+ */
+ ViewManager (void *viewManager);
+
+ /**
+ * Desctructor
+ */
+ virtual ~ViewManager ();
+
+ public slots: /*these are slots for kjs*/
+ /**
+ * Returns a pointer to the currently active view
+ * @return View active view
+ */
+ Kate::View *activeView ();
+
+ /**
+ * Activates the view with the corresponding documentNumber
+ * @param documentNumber the document's number
+ */
+ void activateView ( uint documentNumber );
+
+ /**
+ * Opens the file pointed to by URL
+ * @param url url to the file
+ */
+ void openURL (const KURL &url);
+
+ #undef signals
+ #define signals public
+ signals:
+ #undef signals
+ #define signals protected
+
+ /**
+ * Active view has changed
+ */
+ void viewChanged ();
+
+ private:
+ /**
+ * REALLY PRIVATE ;)
+ */
+ class PrivateViewManager *d;
+};
+
+}
+
+#endif
diff --git a/kate/pics/CMakeLists.txt b/kate/pics/CMakeLists.txt
new file mode 100644
index 000000000..ba4693ba2
--- /dev/null
+++ b/kate/pics/CMakeLists.txt
@@ -0,0 +1,16 @@
+#################################################
+#
+# (C) 2010-2011 Serghei Amelian
+# serghei (DOT) amelian (AT) gmail.com
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+add_subdirectory( actions )
+
+tde_install_icons( )
+
+install( FILES sessionchooser.png DESTINATION ${DATA_INSTALL_DIR}/kate/pics )
diff --git a/kate/pics/Makefile.am b/kate/pics/Makefile.am
new file mode 100644
index 000000000..d42127e99
--- /dev/null
+++ b/kate/pics/Makefile.am
@@ -0,0 +1,6 @@
+KDE_ICON = AUTO
+
+SUBDIRS = actions
+
+kate_pics_data_DATA = sessionchooser.png
+kate_pics_datadir = $(kde_datadir)/kate/pics \ No newline at end of file
diff --git a/kate/pics/actions/CMakeLists.txt b/kate/pics/actions/CMakeLists.txt
new file mode 100644
index 000000000..11c93f672
--- /dev/null
+++ b/kate/pics/actions/CMakeLists.txt
@@ -0,0 +1,12 @@
+#################################################
+#
+# (C) 2010-2011 Serghei Amelian
+# serghei (DOT) amelian (AT) gmail.com
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+tde_install_icons( DESTINATION ${DATA_INSTALL_DIR}/kate/icons )
diff --git a/kate/pics/actions/Makefile.am b/kate/pics/actions/Makefile.am
new file mode 100644
index 000000000..6e254a421
--- /dev/null
+++ b/kate/pics/actions/Makefile.am
@@ -0,0 +1,2 @@
+kateiconsdir = $(kde_datadir)/kate/icons
+kateicons_ICON = AUTO
diff --git a/kate/pics/actions/cr16-action-curfiledir.png b/kate/pics/actions/cr16-action-curfiledir.png
new file mode 100644
index 000000000..9b85f8c9f
--- /dev/null
+++ b/kate/pics/actions/cr16-action-curfiledir.png
Binary files differ
diff --git a/kate/pics/actions/cr16-action-highlighting.png b/kate/pics/actions/cr16-action-highlighting.png
new file mode 100644
index 000000000..a204bfddf
--- /dev/null
+++ b/kate/pics/actions/cr16-action-highlighting.png
Binary files differ
diff --git a/kate/pics/actions/cr16-action-modified.png b/kate/pics/actions/cr16-action-modified.png
new file mode 100644
index 000000000..41b3f4367
--- /dev/null
+++ b/kate/pics/actions/cr16-action-modified.png
Binary files differ
diff --git a/kate/pics/actions/cr16-action-modmod.png b/kate/pics/actions/cr16-action-modmod.png
new file mode 100644
index 000000000..888024d07
--- /dev/null
+++ b/kate/pics/actions/cr16-action-modmod.png
Binary files differ
diff --git a/kate/pics/actions/cr16-action-modonhd.png b/kate/pics/actions/cr16-action-modonhd.png
new file mode 100644
index 000000000..4ffdef7f3
--- /dev/null
+++ b/kate/pics/actions/cr16-action-modonhd.png
Binary files differ
diff --git a/kate/pics/actions/cr16-action-null.png b/kate/pics/actions/cr16-action-null.png
new file mode 100644
index 000000000..021451f7f
--- /dev/null
+++ b/kate/pics/actions/cr16-action-null.png
Binary files differ
diff --git a/kate/pics/actions/cr32-action-highlighting.png b/kate/pics/actions/cr32-action-highlighting.png
new file mode 100644
index 000000000..5c8232f79
--- /dev/null
+++ b/kate/pics/actions/cr32-action-highlighting.png
Binary files differ
diff --git a/kate/pics/actions/lo16-action-curfiledir.png b/kate/pics/actions/lo16-action-curfiledir.png
new file mode 100644
index 000000000..b68a03b17
--- /dev/null
+++ b/kate/pics/actions/lo16-action-curfiledir.png
Binary files differ
diff --git a/kate/pics/actions/lo16-action-indent.png b/kate/pics/actions/lo16-action-indent.png
new file mode 100644
index 000000000..ab7ee7593
--- /dev/null
+++ b/kate/pics/actions/lo16-action-indent.png
Binary files differ
diff --git a/kate/pics/actions/lo16-action-modified.png b/kate/pics/actions/lo16-action-modified.png
new file mode 100644
index 000000000..6edb6969f
--- /dev/null
+++ b/kate/pics/actions/lo16-action-modified.png
Binary files differ
diff --git a/kate/pics/actions/lo16-action-modmod.png b/kate/pics/actions/lo16-action-modmod.png
new file mode 100644
index 000000000..652d87d26
--- /dev/null
+++ b/kate/pics/actions/lo16-action-modmod.png
Binary files differ
diff --git a/kate/pics/actions/lo16-action-modonhd.png b/kate/pics/actions/lo16-action-modonhd.png
new file mode 100644
index 000000000..79e5791c6
--- /dev/null
+++ b/kate/pics/actions/lo16-action-modonhd.png
Binary files differ
diff --git a/kate/pics/actions/lo16-action-null.png b/kate/pics/actions/lo16-action-null.png
new file mode 100644
index 000000000..021451f7f
--- /dev/null
+++ b/kate/pics/actions/lo16-action-null.png
Binary files differ
diff --git a/kate/pics/actions/lo16-action-unindent.png b/kate/pics/actions/lo16-action-unindent.png
new file mode 100644
index 000000000..119e76344
--- /dev/null
+++ b/kate/pics/actions/lo16-action-unindent.png
Binary files differ
diff --git a/kate/pics/actions/lo22-action-indent.png b/kate/pics/actions/lo22-action-indent.png
new file mode 100644
index 000000000..8eba60153
--- /dev/null
+++ b/kate/pics/actions/lo22-action-indent.png
Binary files differ
diff --git a/kate/pics/actions/lo22-action-unindent.png b/kate/pics/actions/lo22-action-unindent.png
new file mode 100644
index 000000000..26a013d7f
--- /dev/null
+++ b/kate/pics/actions/lo22-action-unindent.png
Binary files differ
diff --git a/kate/pics/hi128-app-kate.png b/kate/pics/hi128-app-kate.png
new file mode 100644
index 000000000..dfa6aec3f
--- /dev/null
+++ b/kate/pics/hi128-app-kate.png
Binary files differ
diff --git a/kate/pics/hi128-app-kwrite.png b/kate/pics/hi128-app-kwrite.png
new file mode 100644
index 000000000..fd4db26dc
--- /dev/null
+++ b/kate/pics/hi128-app-kwrite.png
Binary files differ
diff --git a/kate/pics/hi16-app-kate.png b/kate/pics/hi16-app-kate.png
new file mode 100644
index 000000000..3c939e637
--- /dev/null
+++ b/kate/pics/hi16-app-kate.png
Binary files differ
diff --git a/kate/pics/hi16-app-kwrite.png b/kate/pics/hi16-app-kwrite.png
new file mode 100644
index 000000000..3c939e637
--- /dev/null
+++ b/kate/pics/hi16-app-kwrite.png
Binary files differ
diff --git a/kate/pics/hi22-app-kate.png b/kate/pics/hi22-app-kate.png
new file mode 100644
index 000000000..29c225bea
--- /dev/null
+++ b/kate/pics/hi22-app-kate.png
Binary files differ
diff --git a/kate/pics/hi22-app-kwrite.png b/kate/pics/hi22-app-kwrite.png
new file mode 100644
index 000000000..29c225bea
--- /dev/null
+++ b/kate/pics/hi22-app-kwrite.png
Binary files differ
diff --git a/kate/pics/hi32-app-kate.png b/kate/pics/hi32-app-kate.png
new file mode 100644
index 000000000..e4185bfe6
--- /dev/null
+++ b/kate/pics/hi32-app-kate.png
Binary files differ
diff --git a/kate/pics/hi32-app-kwrite.png b/kate/pics/hi32-app-kwrite.png
new file mode 100644
index 000000000..e4185bfe6
--- /dev/null
+++ b/kate/pics/hi32-app-kwrite.png
Binary files differ
diff --git a/kate/pics/hi48-app-kate.png b/kate/pics/hi48-app-kate.png
new file mode 100644
index 000000000..08c72efab
--- /dev/null
+++ b/kate/pics/hi48-app-kate.png
Binary files differ
diff --git a/kate/pics/hi48-app-kwrite.png b/kate/pics/hi48-app-kwrite.png
new file mode 100644
index 000000000..08c72efab
--- /dev/null
+++ b/kate/pics/hi48-app-kwrite.png
Binary files differ
diff --git a/kate/pics/hi64-app-kate.png b/kate/pics/hi64-app-kate.png
new file mode 100644
index 000000000..c553a93c2
--- /dev/null
+++ b/kate/pics/hi64-app-kate.png
Binary files differ
diff --git a/kate/pics/hi64-app-kwrite.png b/kate/pics/hi64-app-kwrite.png
new file mode 100644
index 000000000..c553a93c2
--- /dev/null
+++ b/kate/pics/hi64-app-kwrite.png
Binary files differ
diff --git a/kate/pics/hisc-app-kate2.svgz b/kate/pics/hisc-app-kate2.svgz
new file mode 100644
index 000000000..241e081d1
--- /dev/null
+++ b/kate/pics/hisc-app-kate2.svgz
Binary files differ
diff --git a/kate/pics/hisc-app-kwrite2.svgz b/kate/pics/hisc-app-kwrite2.svgz
new file mode 100644
index 000000000..241e081d1
--- /dev/null
+++ b/kate/pics/hisc-app-kwrite2.svgz
Binary files differ
diff --git a/kate/pics/sessionchooser.png b/kate/pics/sessionchooser.png
new file mode 100644
index 000000000..4dde4794c
--- /dev/null
+++ b/kate/pics/sessionchooser.png
Binary files differ
diff --git a/kate/pics/sessionchooser.xcf b/kate/pics/sessionchooser.xcf
new file mode 100644
index 000000000..a5f23ae32
--- /dev/null
+++ b/kate/pics/sessionchooser.xcf
Binary files differ
diff --git a/kate/utils/CMakeLists.txt b/kate/utils/CMakeLists.txt
new file mode 100644
index 000000000..f2fe04e14
--- /dev/null
+++ b/kate/utils/CMakeLists.txt
@@ -0,0 +1,40 @@
+#################################################
+#
+# (C) 2010-2011 Serghei Amelian
+# serghei (DOT) amelian (AT) gmail.com
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${TDE_INCLUDE_DIR}
+ ${TQT_INCLUDE_DIRS}
+)
+
+link_directories(
+ ${TQT_LIBRARY_DIRS}
+)
+
+##### headers ###################################
+
+install( FILES
+ dockviewbase.h messageview.h listboxview.h
+ DESTINATION ${INCLUDE_INSTALL_DIR}/kate/utils )
+
+
+##### kateutils (shared lib) ####################
+
+set( target kateutils )
+
+set( ${target}_SRCS
+ dockviewbase.cpp messageview.cpp listboxview.cpp )
+
+tde_add_library( ${target} SHARED AUTOMOC
+ SOURCES ${${target}_SRCS}
+ VERSION 0.0.0
+ LINK tdeui-shared
+ DESTINATION ${LIB_INSTALL_DIR} )
diff --git a/kate/utils/Makefile.am b/kate/utils/Makefile.am
new file mode 100644
index 000000000..a17038638
--- /dev/null
+++ b/kate/utils/Makefile.am
@@ -0,0 +1,16 @@
+INCLUDES = -I$(top_srcdir)/kate/utils $(all_includes)
+
+EXTRA_DIST = README
+
+lib_LTLIBRARIES = libkateutils.la
+
+libkateutils_la_SOURCES = dockviewbase.cpp messageview.cpp listboxview.cpp
+
+libkateutils_la_LDFLAGS = $(all_libraries) -no-undefined
+
+libkateutils_la_LIBADD = $(LIB_TDEUI) $(LIB_TDECORE) $(LIB_TDEIO)
+
+libkateutils_la_METASOURCES = AUTO
+
+kateutilsinclude_HEADERS = dockviewbase.h messageview.h listboxview.h
+kateutilsincludedir = $(includedir)/kate/utils
diff --git a/kate/utils/README b/kate/utils/README
new file mode 100644
index 000000000..262b108f0
--- /dev/null
+++ b/kate/utils/README
@@ -0,0 +1,29 @@
+README for libkateutils
+
+Contents:
+* What it is
+* Maintainer
+
+What it is
+==========
+
+This library is a container for classes that may be usefull for
+Kate and for kate plugins. If you have a class that you think would
+be usefull for other plugins, ask the maintainer of this library
+to put it here.
+
+If you find a class in a plugin (ore even elsewhere) that you need to
+copy in order to use it inside kate or a kate plugin, consider debating with
+the author of that class to move it here.
+
+To fit in, the class must be generic enough that it can be usefull for
+many purposes.
+
+Apart from the convenience (and avoided copies of code) putting classes in this
+library will help us maintain a common feel of how kate works.
+
+Maintainer
+==========
+
+This library was started in july 2002 and is maintained by
+Anders Lund <anders@alweb.dk>
diff --git a/kate/utils/dockviewbase.cpp b/kate/utils/dockviewbase.cpp
new file mode 100644
index 000000000..76e5844ed
--- /dev/null
+++ b/kate/utils/dockviewbase.cpp
@@ -0,0 +1,102 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "dockviewbase.h"
+#include "dockviewbase.moc"
+
+#include <tqlabel.h>
+#include <tqlayout.h>
+
+//#include <kdebug.h>
+
+namespace Kate {
+
+// data storage
+class DockViewBasePrivate {
+ public:
+ TQWidget *header;
+ TQLabel *lTitle;
+ TQLabel *lPrefix;
+};
+
+}
+
+Kate::DockViewBase::DockViewBase( TQWidget* parent, const char* name )
+ : TQVBox( parent, name ),
+ d ( new Kate::DockViewBasePrivate )
+{
+ init( TQString::null, TQString::null );
+}
+
+Kate::DockViewBase::DockViewBase( const TQString &prefix, const TQString &title, TQWidget* parent, const char* name )
+ : TQVBox( parent, name ),
+ d ( new Kate::DockViewBasePrivate )
+{
+ init( prefix, title );
+}
+
+Kate::DockViewBase::~DockViewBase()
+{
+ delete d;
+}
+
+void Kate::DockViewBase::setTitlePrefix( const TQString &prefix )
+{
+ d->lPrefix->setText( prefix );
+ d->lPrefix->show();
+}
+
+TQString Kate::DockViewBase::titlePrefix() const
+{
+ return d->lPrefix->text();
+}
+
+void Kate::DockViewBase::setTitle( const TQString &title )
+{
+ d->lTitle->setText( title );
+ d->lTitle->show();
+}
+
+TQString Kate::DockViewBase::title() const
+{
+ return d->lTitle->text();
+}
+
+void Kate::DockViewBase::setTitle( const TQString &prefix, const TQString &title )
+{
+ setTitlePrefix( prefix );
+ setTitle( title );
+}
+
+void Kate::DockViewBase::init( const TQString &prefix, const TQString &title )
+{
+ setSpacing( 4 );
+ d->header = new TQWidget( this );
+ d->header->setSizePolicy( TQSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Fixed, true ) );
+ TQHBoxLayout *lo = new TQHBoxLayout( d->header );
+ lo->setSpacing( 6 );
+ lo->insertSpacing( 0, 6 );
+ d->lPrefix = new TQLabel( title, d->header );
+ lo->addWidget( d->lPrefix );
+ d->lTitle = new TQLabel( title, d->header );
+ lo->addWidget( d->lTitle );
+ lo->setStretchFactor( d->lTitle, 1 );
+ lo->insertSpacing( -1, 6 );
+ if ( prefix.isEmpty() ) d->lPrefix->hide();
+ if ( title.isEmpty() ) d->lTitle->hide();
+}
diff --git a/kate/utils/dockviewbase.h b/kate/utils/dockviewbase.h
new file mode 100644
index 000000000..73d564e04
--- /dev/null
+++ b/kate/utils/dockviewbase.h
@@ -0,0 +1,102 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _KATE_DOCKVIEW_BASE_H_
+#define _KATE_DOCKVIEW_BASE_H_
+
+#include <tqvbox.h>
+
+/**
+* Namespace collecting as much of the internal Kate classes as we
+* can manage.
+*/
+namespace Kate
+{
+
+/**
+ Base class for dockwidget views
+ This class creates a widget meant to be set as the main widget
+ for a KDockWidget.
+
+ This class provides a title in two parts, titlePrefix and title. The
+ size policies are set so that neither will prevent resizing the view to
+ a width smaller than the texts, the titlePrefix (on the left) will remain
+ fully visible for as long as possible.
+
+ Use the titlePrefix to describe the nature of the view contents, for
+ example "Messages".
+
+ Use the title to inform the user what is currently in the view,
+ for example the name of a related file, a command or similar.
+
+ To add widgets, just create them with this as the parent.
+
+ @author Anders Lund <anders@alweb.dk>
+*/
+
+
+class DockViewBase : public TQVBox {
+ Q_OBJECT
+ public:
+ /**
+ Create a KateDockViewBase.
+ */
+ DockViewBase( TQWidget *parent=0, const char *name=0 );
+
+ /**
+ Create a KateDockViewBase with the title prefix @p prefix
+ and the title @p title.
+ */
+ DockViewBase( const TQString &prefix, const TQString &title, TQWidget *parent=0, const char *name=0 );
+
+ ~DockViewBase();
+
+ /**
+ Set the title prefix to @p prefix.
+ */
+ void setTitlePrefix( const TQString &prefix );
+
+ /**
+ @return The title prefix.
+ */
+ TQString titlePrefix() const;
+
+ /**
+ Set the title to @p title
+ */
+ void setTitle( const TQString &title );
+
+ /**
+ Convenience method, sets both the prefix and title
+ */
+ void setTitle( const TQString &prefix, const TQString &title );
+
+ /**
+ @return the title of the KateDockViewBase
+ */
+ TQString title() const;
+
+ private:
+ /** Private initialization */
+ void init( const TQString &, const TQString &);
+ class DockViewBasePrivate *d;
+};
+
+}
+
+#endif // _KATE_DOCKVIEW_BASE_H_
diff --git a/kate/utils/listboxview.cpp b/kate/utils/listboxview.cpp
new file mode 100644
index 000000000..3cbdd8a06
--- /dev/null
+++ b/kate/utils/listboxview.cpp
@@ -0,0 +1,57 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "listboxview.h"
+#include "listboxview.moc"
+
+#include <tdelistbox.h>
+
+namespace Kate {
+
+// private storage
+class ListboxViewPrivate {
+ public:
+ TDEListBox *listbox;
+};
+
+}
+
+Kate::ListboxView::ListboxView( TQWidget *parent, const char *name )
+ : Kate::DockViewBase( parent, name),
+ d( new Kate::ListboxViewPrivate)
+{
+ d->listbox = new TDEListBox( this );
+}
+
+Kate::ListboxView::ListboxView( const TQString &titlePrefix, const TQString &title, TQWidget *parent, const char *name )
+ : Kate::DockViewBase( titlePrefix, title, parent, name),
+ d( new Kate::ListboxViewPrivate)
+{
+ d->listbox = new TDEListBox( this );
+}
+
+Kate::ListboxView::~ListboxView()
+{
+ delete d;
+}
+
+TDEListBox *Kate::ListboxView::listbox()
+{
+ return d->listbox;
+}
+
diff --git a/kate/utils/listboxview.h b/kate/utils/listboxview.h
new file mode 100644
index 000000000..a9194632d
--- /dev/null
+++ b/kate/utils/listboxview.h
@@ -0,0 +1,44 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _KATE_LISTBOX_VIEW_H_
+#define _KATE_LISTBOX_VIEW_H_
+
+#include "dockviewbase.h"
+
+class TDEListBox;
+
+namespace Kate
+{
+
+class ListboxView : public DockViewBase {
+ Q_OBJECT
+ public:
+ ListboxView( TQWidget *parent=0, const char *name=0 );
+ ListboxView( const TQString &titlePrefix, const TQString &title, TQWidget *parent=0, const char *name=0 );
+ ~ListboxView();
+
+ TDEListBox * listbox();
+
+ private:
+ class ListboxViewPrivate *d;
+};
+
+}
+
+#endif // _KATE_LISTBOX_VIEW_H_
diff --git a/kate/utils/messageview.cpp b/kate/utils/messageview.cpp
new file mode 100644
index 000000000..40155f959
--- /dev/null
+++ b/kate/utils/messageview.cpp
@@ -0,0 +1,46 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "messageview.h"
+#include "messageview.moc"
+
+#include <tqtextbrowser.h>
+
+Kate::MessageView::MessageView( TQWidget *parent, const char *name )
+ : Kate::DockViewBase( parent, name )
+{
+ m_view = new TQTextBrowser( this );
+ // m_view->setFormat( Qt::richText ); // should be!!
+ connect( m_view, TQT_SIGNAL( linkClicked( const TQString & ) ),
+ TQT_SIGNAL( linkClicked( const TQString & ) ) );
+}
+
+Kate::MessageView::~MessageView()
+{
+}
+
+void Kate::MessageView::addMessage( const TQString &msg )
+{
+ m_view->append( msg );
+ m_view->scrollToBottom();
+}
+
+void Kate::MessageView::clear()
+{
+ m_view->clear();
+}
diff --git a/kate/utils/messageview.h b/kate/utils/messageview.h
new file mode 100644
index 000000000..1bf406d6a
--- /dev/null
+++ b/kate/utils/messageview.h
@@ -0,0 +1,72 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _KATE_MESSAGE_VIEW_H_
+#define _KATE_MESSAGE_VIEW_H_
+
+#include "dockviewbase.h"
+
+/**
+ A simple message view for Kate plugins.
+
+ This is a message view for displaying output from processes.
+
+ It uses a TQTextEdit in _ mode to display the text.
+
+ You can use HTML links, for example to allow the user to go
+ to a line in a precessed document.
+
+ Connect to the linkClicked() signal to process the links.
+
+ @section Usage
+
+ To use it in the intended way:
+ @li Create a TDEProcess (or derived class)
+ @li As the output of the process arrives, hand it over
+ using addText(). The view will add it to the end and
+ make sure it is scrolled to the end.
+
+ Each time you restart the process, clear() the view.
+*/
+
+class TQTextBrowser;
+
+namespace Kate
+{
+
+class MessageView : public DockViewBase {
+ Q_OBJECT
+ public:
+ MessageView( TQWidget *parent=0, const char *name=0 );
+ ~MessageView();
+
+ public slots:
+ void addMessage( const TQString &msg );
+ void clear();
+
+ signals:
+ void linkClicked( const TQString & href );
+
+ private:
+ TQTextBrowser *m_view;
+};
+
+}
+
+#endif // _KATE_MESSAGE_VIEW_H_
+