commit d62c8c002c51fb7c36487839eeeb4ac89f044dee Author: Slávek Banko Date: Sat Mar 26 13:50:43 2016 +0100 Initial import of kxmleditor 1.1.4 diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..5e0ccde --- /dev/null +++ b/AUTHORS @@ -0,0 +1,4 @@ +Lumir Vanek +Olaf Hartig +Mateusz Korniak +Adam Charytoniuk \ No newline at end of file diff --git a/CODING b/CODING new file mode 100644 index 0000000..6946486 --- /dev/null +++ b/CODING @@ -0,0 +1,91 @@ +NAMING CONVENTIONS +================== + +CLASS NAMES + +Class names follow Qt and KDE schema, with KXE or KXMLEditor prefix: +KXE....Dialog, KXE....View, KXE....Command for longer names. +examples: KXESpecProcInstrDialog + +or + +KXMLEditor.... for short names +examples: KXMLEditorShell, KXMLEditorShellIface, KXMLEditorAboutData, +KXMLEditorPart + + +VARIABLES + +(1) prefixes for variable names +p - for pointer +psz - for "char *" and "const char *" (zero-terminated usally) +str - for QString objects +b - for booleans +i - for integers +dlg - for dialogs +pDlg - for pointers to dialogs +cmd - for commands +pCmd - for pointers to commands + +(2) prefixes for member variables +Member variables should use the prefixes defined above but should additionally +be prefixed with "m_" or "s_", if they are static. + +Example: + m_pDlgConfig - the member variable is a pointer to a dialog + +(3) prefixes for member functions +sig - for signals +slot - for (normal) slots +slotAct - for slots connected to actions + +COMMENTS + +Comments in header files should stick to the rules for KDoc / Doxygen. +Comments in CPP-files should use only the new C++-style comments // to make +it possible to comment whole functions by using the C-style comments /* ... */. + +SOURCE FORMAT + +The source should be formatted in ANSI style and should be intended with tabs, +like in the following example (use the "Show tabs" option or something similar +in your editor to see the tabs): + +namespace foospace +{ + int Foo() + { + if (isBar) + { + bar(); // this is a + // very long comment + return 1; + } + else + return 0; + } +} + +ADDING NEW FILES +================ + +Adding a new file to our project requires the following: + +* creating it in our source tree +* adding it to the file Makefile.am in the subdirectory of the new file + - all files have to be added to the EXTRA_DIST variable + - all *.cpp and *.ui files have to be added to the *_SOURCES variable + - all *.h files have to be added to the noinst_HEADERS variable +* remove old dependencies + Normally removing the .deps and .libs subdirectories should do. If the application + crashs later due to missing symbols, you have to come back to this point and do + make clean + make distclean +* in the project's root dir call + make -f Makefile.dist + ./configure + make + make install (as root) +* test the application +* add the new file to CVS +* commit the new file to CVS diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..c7aea18 --- /dev/null +++ b/COPYING @@ -0,0 +1,280 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..ceece31 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,1269 @@ + + +********************************************************************* +* * +* 1.1.4 Stable released * +* * +********************************************************************* + +12.12.2004, Lumir Vanek +======================= +1) Updated /admin with latest kde-common/admin contents + +12.11.2004, Olaf Hartig +======================= +1) Switched the default item insert point to "at bottom" for the "New Element", "New Proc.Instr." and "New CData" dialogs. + +21.10.2004, Olaf Hartig +======================= +1) Implemented feature request #1044396 "Reload function". + +20.10.2004, Olaf Hartig +======================= +1) Fixed a little usability bug. Tabbing between the widgets work (better) now (all unvisible widgets reject focus on tab). +2) Fixed the bug mentioned in feature request #1049159 "Keyboard shortcut for closing the "Edit XML as raw text" win". + +19.10.2004, Olaf Hartig +======================= +1) Implemented feature request #1048738 "F2 button for editing text content". + +14.09.2004, Lumir Vanek +======================= +1) Added fix_paths script to fix hardcoded paths in files generated by dcopidl2cpp + +********************************************************************* +* * +* 1.1.3 Stable released * +* * +********************************************************************* + +12.09.2004, Lumir Vanek +======================= +1) Added french translation maded by Christophe Crier, www.heolys.com +2) Fixed bug [ 988587 ] Non-existent files from cmdline cause silent quit + +18.08.2004, Lumir Vanek +======================= +1) Removed check for special characters in KXECharDataDialog::checkContents + +********************************************************************* +* * +* 1.1.2 Stable released * +* * +********************************************************************* + +08.08.2004, Lumir Vanek +======================= +1) Set raw XML editboxes to PlainText, instead to Auto, to avoid + unnecessary special character conversions. +2) Moved rest of actions and KCommandHistory from doc to part. + +08.08.2004, Lumir Vanek +======================= +1) Moved actions for Save/SaveAs, Cut/Copy/Paste from Shell to Part, + where is better place for them. Started testing Quanta plugin. + + +********************************************************************* +* * +* 1.1.1 Stable released * +* * +********************************************************************* + +08.07.2004, Lumir Vanek +======================= +1) Added Wrap on/off to text view configuration page + +17.07.2004, Lumir Vanek +======================= +1) Applied patch kxmleditor-1.1.0-gcc34.patch, Bugzilla Bug 57019 kxmleditor 1.1.0 fails + (http://bugs.gentoo.org/show_bug.cgi?id=57019) + +11.07.2004, Lumir Vanek +======================= +1) Applied patch #988560 Default to UTF-8 for new files +2) Applied patch #988558 Desktop entry cleanup +3) Applied patch #958302 Avoid warning on startup +4) Applied patch #958301 Avoid deprecation warnings +5) Changed 4 occurence of SLOT(0) to 0 in KXEShellManager *KXMLEditorShell + +********************************************************************* +* * +* 1.1.0 Stable released * +* * +********************************************************************* + + +09.07.2004, Lumir Vanek +======================= +1) Updated version info in .ui files to 3.3 +2) Commented time meassuring in KXMLEditorPart::slotDocOpened() + +06.07.2004, Lumir Vanek +======================= +1) Fixed bug reported by Robin Rosenberg : when opened XML without specified encoding, default must be used (UTF-8) + +01.06.2004, Lumir Vanek +======================= +1) Minor fixes in documentation +2) Fixed bug [ 946229 ] Element name cannot start with 'xml' or 'XML'? + +28.04.2004, Lumir Vanek +======================= +1) Added support for opening compressed SVG - svgz files to KXEDocument::open(...) + +27.04.2004, Lumir Vanek +======================= +1) Improved syntax highlighter to highlight multiline comment +2) Increased max KXmlEditorComboAction items count from 5 to 15 +3) Added *.svg to supported file types + +11.04.2003, Lumir Vanek +======================= +1) Set active target +2) Added check to KXMLEditorShell::setPart, last line connecting to NULL variable m_windowMenu + +26.03.2004, Olaf Hartig +======================= +1) Changed the code in KXE_TreeView::updateNodeMoved to remove the calls of + KListViewItem::moveItem, because this function is marked as deprecated + in the KDE API. +2) Implemented the "create tree view items on demand" feature, that speeds + the loading of deep nested XML documents. This feature can be enabled/disabled + in the configuration dialog. Take a look at KXMLEditorPart::slotDocOpened to + learn about measuring the feature's advantage in loading time. +3) Fixed a performance bug with opening documents in KXEDocument::open and + (temporary) introduced code to measure the difference. + +19.02.2004, Adam Charytoniuk +======================= +1) Introduction of document/view model. Started... +2) New shell actions and new menu "Window". +3) Updated pl.po file + +18.02.2004, Olaf Hartig +======================= +1) Finished the german localization. + +12.02.2003, Lumir Vanek +======================= +1) Removed kxmledtor.kdevprj from Makefile.am. + +10.02.2004, Olaf Hartig +======================= +1) Switched the project to be a KDevelop 3 project. + +08.02.2003, Adam Charytoniuk +======================= +1) Update of pl.po translation file + +05.02.2004, Olaf Hartig +======================= +1) Fixed a usability problem with a useless messagebox appearing, when the users wants to edit the properties of the special proc.instr. +2) Removed several inconsisties with tooltips and What's This help in dialogs and configuration pages. + +04.02.2004, Adam Charytoniuk +======================== +1) Added file for polish translation, translation started. + +02.02.2004, Olaf Hartig +======================= +1) Fixed the problems with our/KDE's localization framework. +2) Added a file for the german translation. + +********************************************************************* +* * +* 1.0.0 Stable released * +* * +********************************************************************* + + +24.01.2003, Adam Charytoniuk +======================= +1) New icons for application +2) TODO updated + +25.01.2003, Lumir Vanek +======================= +1) Used KTempFile when compressed file open, instead of temporary.tmp + +20.01.2003, Lumir Vanek +======================= +1) Touched dialogs and tested compiling and making RPM on KDE 3.2 RC1. Successfull. + +17.01.2003, Lumir Vanek +======================= +1) Added Element indentation to text view setting +2) Adjusted columns in KXE_ViewAttributes::slotChange + +10.01.2003, Lumir Vanek +======================= +1) Applyied patch [ 827616 ] "freedesktop.org desktop entry tweak" to kxmleditor.desktop + +********************************************************************* +* * +* 0.9.2 Beta released * +* * +********************************************************************* + + +10.01.2003, Lumir Vanek +======================= +1) Renamed following dialogs in .kdevprj file: + ./part/kxeelementdialogbase.ui + ./part/kxeattributedialogbase.ui + ./part/kxechardatadialogbase.ui + ./part/kxesearchdialogbase.ui + ./part/kxechoosestringdialogbase.ui + ./part/kxeprocinstrdialogbase.ui + ./part/kxespecprocinstrdialogbase.ui +2) Checked those dialogs if What's This help exist, and added it, if not. + +06.01.2004, Olaf Hartig +======================= +1) Removed the old configuration framework and the corresponding files: + ./part/confpage_defaults.ui + ./part/confpage_text_editor.ui + ./part/confpage_print.ui + ./part/confpage_treeview.ui + ./part/confpage_targzext.ui + ./part/confpage_xml.ui + ./part/dlgconfiguration.h + ./part/dlgconfiguration.cpp + +********************************************************************* +* * +* 0.9.1 Beta released * +* * +********************************************************************* + +03.01.2003, Lumir Vanek +======================= +1) Disabled m_pActEditRawXml when element is not selected +2) Allowed to paste element with subtree to empty document +3) Fixed bug in KXE_TreeViewItem. It's destructor not inform your nextSibling about deleting *this*, + and siblings m_pPrevSibling pointed to deleted KXE_TreeViewItem. I hope, this fixing bug #858730. +4) Fixed another bug in KXE_TreeViewItem::lastChild(). It returned 0, if more than one lastChild() exists. +5) Registered renamed files in KDevelop project +6) Attribute name invalid characters set same as element + +02.01.2004, Adam Charytoniuk +============================== +1) Small compiler warnings removal started. + +31.12.2003, Olaf Hartig +======================= +1) Added What's This help to the configuration dialog's pages. + +30.12.2003, Olaf Hartig +======================= +1) Split the tree view configuration setting "enable drag and drop" to "enable dragging" and "enable dropping" and implemented the usage of these settings in the tree view. +2) Updated the .cvsignore files. + +29.12.2003, Olaf Hartig +======================= +1) Renamed the files (containing stuff for dialog classes) + ./part/dlgxmlprocinstrbase.ui + ./part/dlgxmlprocinstr.h + ./part/dlgxmlprocinstr.cpp + ./part/dlgsearchbase.ui + ./part/dlgsearch.h + ./part/dlgsearch.cpp + ./part/dlgxmlspecprocinstrbase.ui + ./part/dlgxmlspecprocinstr.h + ./part/dlgxmlspecprocinstr.cpp + ./part/dlgxmlelementbase.ui + ./part/dlgxmlelement.h + ./part/dlgxmlelement.cpp + ./part/dlgxmlattributebase.ui + ./part/dlgxmlattribute.h + ./part/dlgxmlattribute.cpp + ./part/dlgxmlchardatabase.ui + ./part/dlgxmlchardata.h + ./part/dlgxmlchardata.cpp + ./part/dlgxmlattachbase.ui + ./part/dlgchoosestringbase.ui + ./part/dlgchoosestring.h + ./part/dlgchoosestring.cpp + ./part/dlgfilenew.h + ./part/dlgfilenew.cpp + to + ./part/kxeprocinstrdialogbase.ui + ./part/kxeprocinstrdialog.h + ./part/kxeprocinstrdialog.cpp + ./part/kxesearchdialogbase.ui + ./part/kxesearchdialog.h + ./part/kxesearchdialog.cpp + ./part/kxespecprocinstrdialogbase.ui + ./part/kxespecprocinstrdialog.h + ./part/kxespecprocinstrdialog.cpp + ./part/kxeelementdialogbase.ui + ./part/kxeelementdialog.h + ./part/kxeelementdialog.cpp + ./part/kxeattributedialogbase.ui + ./part/kxeattributedialog.h + ./part/kxeattributedialog.cpp + ./part/kxechardatadialogbase.ui + ./part/kxechardatadialog.h + ./part/kxechardatadialog.cpp + ./part/kxeattachdialogbase.ui + ./part/kxechoosestringdialogbase.ui + ./part/kxechoosestringdialog.h + ./part/kxechoosestringdialog.cpp + ./part/kxefilenewdialog.h + ./part/kxefilenewdialog.cpp + +28.12.2003, Adam Charytoniuk +============================= +1) Warning free code in kxmleditorpart.cpp file + +28.12.2003, Olaf Hartig +======================= +1) Added the function updatePage to all configuration setting groups and fixed a little bug that occured during the creation of their pages. +2) Implemented the missing case of using the new configuration framework (see yesterdays entry). + +27.12.2003, Olaf Hartig +======================= +1) Implemented usage of the new configuration framework in all cases except one (this one is a little bit more difficult - I'm working on it). + +24.12.2003, Lumir Vanek +======================= +1) Registered KXE...Settings files in KDevelop + +23.12.2003, Olaf Hartig +======================= +1) Added the following classes for the new configuration framework: + - KXEConfiguration (files: kxeconfiguration.h, kxeconfiguration.cpp) + - KXESettings (files: kxesettings.h, kxesettings.cpp) + - KXETreeViewSettingsPage (files: kxetreeviewsettingspage.ui) + - KXETreeViewSettings (files: kxetreeviewsettings.h, kxetreeviewsettings.cpp) + - KXENewFileSettingsPage (files: kxenewfilesettingspage.ui) + - KXENewFileSettings (files: kxenewfilesettings.h kxenewfilesettings.cpp) + - KXEPrintSettingsPage (files: kxeprintsettingspage.ui) + - KXEPrintSettings (files: kxeprintsettings.h, kxeprintsettings.cpp) + - KXEArchiveExtsSettingsPage (files: kxearchiveextssettingspage.ui) + - KXEArchiveExtsSettings (files: kxearchiveextssettings.h, kxearchiveextssettings.cpp) +2) Implemented the initialization of the new conf. framework in our factory. +3) Added the configuration settings group for the text view and the corresponding dialog page. New classes: + - KXETextViewSettingsPage (file: kxetextviewsettingspage.ui) + - KXETextViewSettings (files: kxetextviewsettings.h, kxetextviewsettings.cpp) + +********************************************************************* +* * +* 0.9.0 Beta released * +* * +********************************************************************* + + +22.12.2003, Lumir Vanek +======================= +1) Finished KXESyntaxHighlighter +2) Updated documentation +3) Added "new" symbol to char data icons +4) Incremented version to 0.9 + +21.12.2003, Adam Charytoniuk +=============================== +1) Positions of splitters are saved and restored from config. +2) inserting element action is disabled when processing instruction is selected +3) splitters are working smoothly + +21.12.2003, Lumir Vanek +======================= +1) Enhanced KXESyntaxHighlighter +2) Removed ConfPage_SpecChars from project +3) Added ConfPage_TextEditor to project + +20.12.2003, Lumir Vanek +======================= +1) Finished KXEEditRawXmlCommand +2) Finished KXETextEditorDialog + +20.12.2003, Adam Charytoniuk +=============================== +1) Adding kxmleditorpart actions to configurable shortcut dialog. +2) Mailing documents action added. +3) Correcting background in a path toolbar label + +16.12.2003, Lumir Vanek +======================= +1) Added kxesyntaxhighlighter.cpp to Makefile.am + +16.12.2003, Adam Charytoniuk +============================ +1) correction of Makefile.am in part directory +2) KXEDeleteNodeCommand remembers it's sibling node now + +15.11.2003, Olaf Hartig +======================= +1) Appended the section "ADDING NEW FILES" to ./CODING +2) Fixed bug in KXMLEditorShell::slotFileSaveAs resulting in wrong filename extensions. +3) Moved of the filter for file dialogs from the header- to the sourcefile. + +14.12.2003, Lumir Vanek +======================= +1) Started implementing KXETextEditorDialog and KXESyntaxHighlighter + +********************************************************************* +* * +* 0.8.5 Beta released * +* * +********************************************************************* + + +13.12.2003, Adam Charytoniuk +============================ +1) bug with enabling Paste instead of Print action in shell contructor corrected. +2) Apropriate captions for Insert Text, Insert CDATA, Insert Comment dialogs. +3) slotTextChanged and slotFindInChanged in KXESearchDialog changed into virtual (like in base class) + +13.12.2003, Lumir Vanek +======================= +1) Added attribute checking, KXEAttributeDialog::slotNameChanged, ... +2) Changed XML path information to more like XPATH standart +3) Added new types to File Open/Save dialogs +4) Resolved problem with proc. instr. in path bar + +12.12.2003, Lumir Vanek +======================= +1) Added character data checking, KXECharDataDialog::checkContents +2) Added proc. instr. checking, KXEProcInstrDialog::slotTargetChanged, slotDataChanged + +09.12.2003, Adam Charytoniuk +============================ +1) New actions for Insert Text, Insert CDATA, Insert Comment + +07.12.2003, Lumir Vanek +======================= +1) Renamed dialog classes, incremented version number +2) Implemented paste Commands +3) Implemented d&d undo/redo +4) Added element name checking: KXEElementDialog::checkElementName +5) Added element name checking to inplace element editing + +06.12.2003, Lumir Vanek +======================= +1) Implemented KXEEditCharDataCommand, KXEEditProcInstrCommand, KXEEditElementCommand +2) Implemented KXEEditAttrNameCommand, KXEEditAttrValueCommand, KXEDeleteAllAttribCommand + +02.12.2003, Adam Charytoniuk +============================= +1) Implemented KXEVersionEncodingCommand + +30.11.2003, Lumir Vanek +======================= +1) Implemented KXEDeleteNodeCommand, KXEDeleteAttrCommand, KXEUpCommand, KXEDownCommand + +29.11.2003, Lumir Vanek +======================= +1) Added comands.h/cpp files to KDevelop project file (register it) to + display class names in tree +2) Fixed bug in KXEStylesheetDetachCommand. Code for execute was mistakely placed + to destructor, and code for unexecute was in execute. +3) Implemented KXEElementCommand, KXECharDataCommand, KXEProcInstrCommand, KXEAttributeCommand. + + +26.11.2003, Lumir Vanek +======================= +1) Changes message "Pleasse use menu item XML -> Version and encoding ..." to "... File -> ..." + +24.11.2003, Adam Charytoniuk +============================ +1) Undo/Redo framework added. KCommandHistory is now used in kxmleditorpart. + +24.11.2003, Adam Charytoniuk +============================ +1) error in updateActions() detected & corrected - this was cause of crash when working in read-only mode. +2) actions rearranged + +********************************************************************* +* * +* 0.8.4 Beta released * +* * +********************************************************************* + +20.11.2003, Adam Charytoniuk +============================ +1) Updating some actions in XML menu after file is opened. +2) Corrected Makefile.am in icons directory (previously also icons from local source directory were removed during uninstall) + +16.11.2003, Olaf Hartig +======================= +1) Removed the default name "Untitled" for new documents and changed the checks + for it. They use KURL::isEmpty now (it's more standard). +2) Chanced the dates in the copyright notes in every sourcefile (*.h, *.cpp). + +15.11.2003, Lumir Vanek +======================= +1) Fixed KXMLEditorPart::openFile() and saveFile() - opening and saving compressed files. + New KOffice use KZip instead of KTarGz for storing files. +2) Added Adam to developers list and increment version to 0.8.4 + +13.11.2003, Adam Charytoniuk +============================ +1) Controls on some dialogs have been rearranged, Tab order was corrected +2) The order in which top-level processing instructions are enetered is as follows: + // special proc instruction + // whatever top-level proc instruction, e.g. + + +13.11.2003, Olaf Hartig +======================= +1) Changed the behavior of opening a file to the SDI paradigm. This means, if the current shell doesn't contain a new and unmodified part, a new shell is created to open the file in. +2) Fixed bug [ 835971 ] opening files is blocked + ( I left the test for being modified in KXMLEditorPart::openFile, but due to new behavior of opening files this test should never succeed. ) + +11.11.2003, Olaf Hartig +======================= +1) Since KXMLEditorShell::slotFileNew always crashed (for me), I changed it. Additional advantage of the new code: the declaration of our part isn't needed (explicitly) in the shells definition anymore. +2) Added the file CODING, which defines coding guidelines (these are conventions for variable names, comments and source format). + +10.11.2003, Adam Charytoniuk +============================ +1) Attaching / detaching schemas for xml files +2) Attaching / detaching stylesheets (XSL/XSLT) for xml files +3) Configuring behaviour when new files are created in kxmleditor configuration + +09.11.2003, Adam Charytoniuk +============================ +1) Support for File->New added + + +********************************************************************* +* * +* 0.8.3 Beta released * +* * +********************************************************************* + + +09.11.2003, Lumir Vanek +======================= +1) Fixed bug [ 819229 ] annoying behaviour when adding new attributes +2) Fixed bug [ 726776 ] bad xml encoding + +03.11.2003, Lumir Vanek +======================= +1) Fixed main menu, not contained "Delete Attribute" item. +2) Join toolbar icon "Delete Attribute" to function "Delete Attribute" istead of "Delete all Attributes" +3) Added question before deleting all attributes +4) Implemented in-place attribute names editing + +03.11.2003, Olaf Hartig +======================= +1) Added keyboard accelerators to our dialogs. +2) Added the possibility to edit proc. instructions with double click (analog to the problem resolved by Lumir on 01.11.2003) + +01.11.2003, Lumir Vanek +======================= +1) Resolved problem "Double click for editing character data" + +29.07.2003, Olaf Hartig +======================= +1) Fixed the toolbar problems. + +23.07.2003, Lumir Vanek +======================= +1) Trying to fix problem with configuring main toolbar. I will continue discovery this problem + +13.07.2003, Lumir Vanek +======================= +1) Finished dialog DlgXMLSpecProcInstr for editing spec. proc. instr. + +10.07.2003, Lumir Vanek +======================= +1) Updated /admin for KDevelop 2.1.5 + +06.07.2003, Lumir Vanek +======================= +1) Created dialog DlgXMLSpecProcInstr for proc. instruction: + + +********************************************************************* +* * +* 0.8.1 Beta released * +* * +********************************************************************* + + +13.01.2003, Lumir Vanek +======================= +Fixed some losted edit lines in dialogs. Qt designer bug ? + +02.12.2002, Lumir Vanek +======================= +1) Fixed some compilation warnings + +07.11.2002, Olaf Hartig +======================= +1) Implemented the possibility to use namespaces for XML elements. + +14.10.2002, Lumir Vanek +======================= +1) Fixed dlgsearchbase.ui layout + +10.09.2002, Olaf Hartig +======================= +1) Fixed g++ 3.2 compile problem (#605853 - see sourceforge project page), removed the default arguments from ./part/dlgxmlattribute.cpp + +20.08.2002, Olaf Hartig +======================= +1) Added the possibility to have proc.instr. as root nodes. +2) Added the write-actions to the tree views context menus. + +02.08.2002, Lumir Vanek +======================= +1) Inserted Find icon to toolbar +2) After opening XML file, pathbar combo is cleared +3) After selecting nonexists item in pathbar combo, item is removed from combo +4) Fixed KXMLEditorPart::slotXmlElementDelete(). After deleting root element, Insert Element was disabled + + +********************************************************************* +* * +* 0.8 Beta released * +* * +********************************************************************* + +25.07.2002, Olaf Hartig +======================= +1) Added the files ./part/actions.h and ./part/actions.cpp to the KDevelop project file. + + +23.07.2002, Olaf Hartig +======================= +1) Forgot to remove ./kxmleditor/kxmleditorui.rc from ./kxmleditor/Makefile.am + +22.07.2002, Lumir Vanek +======================= +1) Removed rest of debugging code from DlgXMLElement::fillElement +2) Changed version number to 0.8 + +22.07.2002, Olaf Hartig +======================= +1) Removed the old KXMLEditor code. Therefore removed the following files from CVS: + ./kxmleditor/actions.cpp + ./kxmleditor/actions.h + ./kxmleditor/choosestringdlg.cpp + ./kxmleditor/choosestringdlg.h + ./kxmleditor/choosestringdlgbase.ui + ./kxmleditor/dcopiface_app.cpp + ./kxmleditor/dcopiface_app.h + ./kxmleditor/kxmleditor.cpp + ./kxmleditor/kxmleditor.h + ./kxmleditor/kxmleditoractions.h + ./kxmleditor/kxmleditordoc.cpp + ./kxmleditor/kxmleditordoc.h + ./kxmleditor/kxmleditorui.rc + ./kxmleditor/kxmleditorview.cpp + ./kxmleditor/kxmleditorview.h + ./kxmleditor/optionsdialog.cpp + ./kxmleditor/optionsdialog.h + ./kxmleditor/searchdlg.cpp + ./kxmleditor/searchdlg.h + ./kxmleditor/searchdlgbase.ui + ./kxmleditor/tablewidget.cpp + ./kxmleditor/tablewidget.h + ./kxmleditor/xml_base.cpp + ./kxmleditor/xml_base.h + ./kxmleditor/xmlattributedlg.cpp + ./kxmleditor/xmlattributedlg.h + ./kxmleditor/xmlattributedlgbase.ui + ./kxmleditor/xmlcontentsdlg.cpp + ./kxmleditor/xmlcontentsdlg.h + ./kxmleditor/xmlcontentsdlgbase.ui + ./kxmleditor/xmlelementdlg.cpp + ./kxmleditor/xmlelementdlg.h + ./kxmleditor/xmlelementdlgbase.ui + ./kxmleditor/xmlprocinsdlgbase.ui + ./kxmleditor/xmlprocinstrdlg.cpp + ./kxmleditor/xmlprocinstrdlg.h + ./kxmleditor/xmlstructureparser.cpp + ./kxmleditor/xmlstructureparser.h + ./kxmleditor/xmltreeview.cpp + ./kxmleditor/xmltreeview.h + +22.07.2002, Lumir Vanek +======================= +1) Documentation updated +2) Modified KXMLEditorPart::saveFile() for several encodings + +19.07.2002, Olaf Hartig +======================= +1) Added inplace editing for attribute values to the attribute view (KXE_ViewAttributes). + +18.07.2002, Olaf Hartig +======================= +1) Implemented the dialog for defining XML attributes (class: DlgXMLAttribute) +2) Implemented the possiblity to add attributes to XML elements. +3) Added the possibility to request context menus to the part (KXMLEditorPart::slotContextMenuRequested). +4) Added context menus to the attributes view. +5) Modified the tree view (KXE_TreeView) to use the parts new context menu request possibility. +6) Added the action "Delete All Attributes" to the part. +7) Added the action "Delete Attribute" to the part. + +12.07.2002, Olaf Hartig +======================= +1) Added the files + ./part/dlgxmlattributebase.ui + ./part/dlgxmlattribute.h + ./part/dlgxmlattribute.cpp + +11.07.2002, Olaf Hartig +======================= +1) Removed KXE_TreeView::sigItemRenamedInplace since it's useless. +2) Implemented the read only stuff for the attributes view (KXE_ViewAttributes). + +10.07.2002, Olaf Hartig +======================= +1) Fixed little issues: + - the shell doesn't has to know exactly about it's part (it's simply a KParts::ReadWritePart) + - changed the type of KXMLEditorShell::m_pPart to KParts::ReadWritePart* + +04.07.2002, Lumir Vanek +======================= +1) Fixed bug in drap&drop - moved item wasn't properly deleted + +28.06.2002, Lumir Vanek +======================= +1) Handle with Untitled document + +25.06.2002, Olaf Hartig +======================= +1) Updated ./part/pics/Makefile.am for Lumirs new icons. + +25.06.2002, Lumir Vanek +======================= +1) Finished implementing Save/Save As +2) Painted icons for bookmarked items and use it +3) Found bug - pressing "Prev bookbark" on first bookmarked item caused crash. + Fixed two KXE_TreeViewItem constructors to initialize m_pPrevSibling = 0. + +24.06.2002, Olaf Hartig +======================= +1) Added the files + - ./part/dlgchoosestringbase.ui + - ./part/dlgchoosestring.h + - ./part/dlgchoosestring.cpp + +24.06.2002, Lumir Vanek +======================= +1) Started implementing Save/Save As +2) Modified Open code for compressed files + +20.06.2002, Lumir Vanek +======================= +1) Continue implementing Cut/Copy/Paste +2) Started implementing Drag&Drop + +14.06.2002, Olaf Hartig +======================= +1) Commented everything for the XML and the special characters page in the parts configuration dialog because it is not needed for the part using only DOM parser. + +13.06.2002, Olaf Hartig +======================= +2) Implemented the correct behaviour for changing elements tag names via inplace-renaming in the parts tree view. + +13.06.2002, Lumir Vanek +======================= +1) Implemented KXMLEditorPart::slotEditCopy() +2) Extended the KXMLEditorBrowserExtension class and implemented KXMLEditorShell to serve this browser extension as templates the actions "Edit Paste" without really implementing these actions. +3) Implemented Cut/Copy/Paste for XML elements + + +13.06.2002, Olaf Hartig +======================= +1) Fixed several little problems/bugs with the part + - quitting the app didn't care about modified documents (./kxmleditor/kxmleditorshell.cpp) + - merging in the shells main toolbar (./kxmleditor/kxmleditorshell.rc) and in ./part/kxmleditorpartBrowseUI.rc + - disabled word wraping for editboxes in the dialogs DlgXMLCharData (./part/dlgxmlchardatabase.ui) and DlgXMLProcInstr (./part/dlgxmlprocinstrbase.ui) + - changed the contents and proc.instruction view from QMultiLineEdit to QTextEdit (since QMultiLineEdit is obsolete in Qt3) and disabled wordwraping (./part/kxmleditorpart.cpp ./part/kxmleditorpart.h ) + - changing a content element or a proc.instruction didn't updated the corresponding view immediately (./part/kxmleditorpart.cpp) + +12.06.2002, Olaf Hartig +======================= +1) Extended the KXMLEditorBrowserExtension class and implemented KXMLEditorShell to serve this browser extension as templates the actions "Edit Cut" and "Edit Copy" without really implementing these actions. +2) Changed the proc.instruction view from KXE_ViewProcInstr to QMultiLineEdit. + therefore removed the files + ./part/kxe_viewprocinstr.cpp + ./part/kxe_viewprocinstr.h +3) Changed the dialog DlgXMLProcInstr to use a multiline editbox for the processing instruction. +4) Little change to the tree items representing porc.instructions - they now show only the target. +5) Little bugfix - the icon for proc.instruction wasn't installed. + +9.6.2002, Lumir Vanek +===================== +1) Fixed problem with saving mixed elements + texts, xml_base.cpp - XmlElement::save. Bug reported by Ralf Ruth + + +28.05.2002, Olaf Hartig +======================= +1) Applied patch (#559922 - see sourceforge project page) from Robin Green to fix gcc 3.1 compile problems. +2) Fixed bug (#556148 - see sourceforge project page) reported by R.F.Pels which removes the undefined symbol DlgXMLProcInstr::fillProcInstr +3) Fixed a bug causing the part to crash in read only mode + +06.05.2002, Olaf Hartig +======================= +1) Added the actions "Move XML Node Up" and "Move XML Node Down" to the part +2) Added automatic selection of created/changed/moved tree view items to the part +3) Added enabling/disabling of the XML actions depending on the selected node + + +********************************************************************* +* * +* 0.7.2 Beta released (USE_KPART 0) * +* * +********************************************************************* + + +06.05.2002, Olaf Hartig +======================= +1) Implemented the class DlgXMLCharData +2) Added the actions "Insert New Character Data", "Edit Character Data" and "Delete Character Data" to the part +3) Fixed two little bugs with comment nodes + +25.04.2002, Olaf Hartig +======================= +1) Added the files + - ./part/dlgxmlchardatabase.ui + - ./part/dlgxmlchardata.h + - ./part/dlgxmlchardata.cpp + +24.04.2002, Olaf Hartig +======================= +1) Added the files + - ./part/dlgxmlprocinstrbase.ui + - ./part/dlgxmlprocinstr.h + - ./part/dlgxmlprocinstr.cpp +2) Implemented the class DlgXMLProcInstr +3) Changed the tab sequence of the parts XML element dialog +4) Changed the tab sequence of the parts proc. instruction dialog +5) Added the actions "Insert New Proc.Instruction", "Edit Proc.Instruction" and "Delete Proc.Instruction" to the part + +23.04.2002, Olaf Hartig +======================= +1) Developed the new slots + - KXE_TreeView::slotUpdateNodeChanged + - KXE_TreeView::slotUpdateNodeCreated + - KXE_TreeView::slotUpdateClear + which change or create new treeview items. +2) Changed the code implementation of the "Insert New Element" and "Edit Element" actions, to use the new slots. +3) Developed the new slot + - KXE_TreeView::slotUpdateNodeDeleted + which deletes treeview items corresponding to the deleted nodes. +4) Added the "Delete Element" action to the part +5) Slightly changed KXE_TreeView::selectNode + +19.04.2002, Olaf Hartig +======================= +1) Added parameter checking to DlgXMLElement functions to prevent crashes + +18.04.2002, Olaf Hartig +======================= +1) Extended DlgXMLElement dialog to append elements autonomous to their parents. + +17.04.2002, Olaf Hartig +======================= +1) Created a dialog for editing of XML elements for the part + New files: + - ./part/dlgxmlelementbase.ui + - ./part/dlgxmlelement.h + - ./part/dlgxmlelement.cpp +2) Added the "Insert New Element" action to the part +3) Slightly changed DlgXMLElement and commented this class +4) Changed the name of KXMLEditorPart::slotXmlInsertElement to KXMLEditorPart::slotXmlElementInsert + (more consistent in my eyes) +5) Fixed a little bug in KXMLEditorPart::slotXmlElementInsert + (Even pressing cancel in the XML element dialog made the document modified) +6) Added the "Edit Element" action to the part +7) Implemented window caption change (when the document was modified) to the part + +16.04.2002, Olaf Hartig +======================= +1) Splitted the XMLGUI resource file for the part (old name: ./part/kxmleditorpart.rc) into + ./part/kxmleditorpartBrowseUI.rc (with the read only actions) and + ./part/kxmleditorpartEditUI.rc (with the additionally write actions). + If the part is constructed as read/write part these files are merged. + +13.4.2002, Lumir Vanek +======================= +1) Added error detection, when XML is opened using QDomDocument::setContent(...) + +11.4.2002, Lumir Vanek +======================= +1) Version changed to 0.7.2, nonpublic release for KDE 3 with USE_KPART 0 + +9.4.2002, Lumir Vanek +====================== +1) Updated /admin subdirectory for build on KDE 3 + +07.04.2002, Olaf Hartig +======================= +1) Changed the parts baseclass to KParts::ReadWritePart to start implementing write functionality. + +06.04.2002, Olaf Hartig +======================= +1) Added a statusbar to the shell. +2) Added saving of window settings to the shell. +3) Added the possibility to toggle the status- and the toolbar to the shell. +4) Added the OpenRecentFiles action to the shell. +5) Added the possibility to specify several files to be opened as command line arguments for the shell. +6) Added session management to the shell. +7) Added the possibility to configure key bindings and toolbars to the shell. + +02.04.2002, Olaf Hartig +======================= +1) (Re)Implemented different element display modes (no attributes, attribute names only, attribute names and values) to treeview of the part + +21.01.2002, Olaf Hartig +======================= +1) Included several Qt- and KDE-header files and changed the base class of KXMLEditorFactory (from KLibFactory to KParts::Factory) to make the whole project be compileable with KDE3 + +20.01.2002, Olaf Hartig +======================= +1) (Re)Implemented the parts configuration dialog +2) Removed ./config.h.in from CVS because it's not needed here + +19.1.2002, Lumir Vanek +====================== +1) Decrease size of pixmap "locationbar_erase" on toobar to 16x16 in KXMLEditorPart::KXMLEditorPart, to make look uniform with Konqueror + +16.01.2001, Lumir Vanek +======================= +1) Fixed bug in, kxmleditorshell.cpp, KXMLEditorShell::KXMLEditorShell(). + ...->factory("libkxmleditorpart") instead of "libkxmleditor". + Now application not crash after start when compiled with USE_KPART 1 + +10.01.2002, Olaf Hartig +======================= +1) (Re)Implemented next/prev.bookmark action for the part. +2) (Re)Implemented the possibility for the part to select a tree item by giving a path +3) Added the action "Deselect" to the tree views context menus (popup menus) + +07.01.2002, Olaf Hartig +======================= +1) (Re)Implemented toggle bookmark action for the part. + +06.01.2002, Olaf Hartig +======================= +1) (Re)Implemented find and find next actions for the part. Moved the functionality from the tree view to the part itself. +2) Added possibility to disable "Find"-button at the parts search dialog (DlgSearch) if no search-area (Find in...) is given. +3) Removed service type "Browser/View" from ./part/kxmleditorpart.desktop + +05.01.2002, Olaf Hartig +======================= +1) Changed the parts search dialog classes (DlgSearchBase, DlgSearch) to reduce memory usage +2) Added the functions domTool_nextNode and domTool_match (see ./part/qdom_add.h, ./part/qdom_add.cpp) for further implementation of find(next) actions to the part + +21.12.2001, Olaf Hartig +======================= +1) Fixed some issues due to yesterdays renaming of the part's class OptionsDialog to DlgConfiguration +2) Renamed the part's class to DlgSearchBase (from SearchDlgBase) +3) Renamed the part's class SearchDlg to DlgSearch +4) Added the files in ./part/ to the KDevelop project file +5) (Re)implemented KXE_TreeView::getSelectedPath() +6) Moved the following files from ./part/ to ./part/icons/ + lo16-app-kxmleditor.png + lo32-app-kxmleditor.png + hi32-app-kxmleditor.png + hi48-app-kxmleditor.png + +20.12.2001, Olaf Hartig +======================= +1) Removed ./kxmleditor/kxmleditorabout.h + now ./kxmleditor/main.cpp uses ./part/kxmleditorabout.h instead +2) Renamed the following files: + ./part/searchdlg.cpp to ./part/dlgsearch.cpp + ./part/searchdlg.h to ./part/dlgsearch.h + ./part/searchdlgbase.ui to ./part/dlgsearchbase.ui + ./part/optionsdialog.h to ./part/dlgconfiguration.h + ./part/optionsdialog.cpp to ./part/dlgconfiguration.cpp + +18.12.2001, Lumir Vanek +======================= +1) Fixed bug: #487883 Doesn't remember filename after save as +2) Fixed bug: #487859 Window title says [modified] after save +3) Fixed bug: #487860 After cmdline start, win title wrong + +14.12.2001, Olaf Hartig +======================= +BIG CHANGES +1) I rewrote the whole part stuff to have the internal data structures based on QDom. There are still some things open (marked with TODO) but it compiles and (surprise :-) works (at least here). +2) I restructured the directory structure (new directory ./part/ now) and reworked the build system (automake stuff). + +07.12.2001, Olaf Hartig +======================= +1) Slightly changed ./kxmleditor/action.cpp to make it independend of KXMLEditor classes + +29.11.2001, Mateusz Korniak +=========================== +1) Some changes in lodaing files specified by argument + - checking validity of given path + - fix loading local files ( 'kxmleditor file.xml' ) + +31.10.2001, Olaf Hartig +======================= +1) Added statusbar texts to some actions of the kpart +2) Slightly changed order of functions in ./kxmleditor/kxmleditorpart.cpp + +31.10.2001, Mateusz Korniak +=========================== +1) Few changes corresponding to valuable Ole suggestions. + +30.10.2001, Olaf Hartig +======================= +1) Changed the following things corresponding to my remarks about Mateusz first commits (see thread "Remarks to current DCOP implementations" from 2001-10-30 21:50) + - added KXE_TreeView::getSelectedPath + - added KXMLEditorPart::getSelectedPath + - changed return type of KXMLEditorPart::slotPathSelected from bool to void (because its a slot) + - removed all calls of KXMLEditorPart::m_pDCOPIface functions in the part, except constructor and destructor + - Slightly changed KXMLEditorPartIfaceReadOnly::selectNode and KXMLEditorPartIfaceReadOnly::currentNode to use KXMLEditorPart::getSelectedPath +2) Fixed bug in ./kxmleditor/kxmleditorshell.rc + +28.10.2001, Lumir Vanek +======================= +1) XMLEditorDoc::openDOM(QFile) - Fix for nonlatin1 symbols. + + +28.10.2001, Mateusz Korniak +=========================== +1) First code update heading for DCOP. +2) DCOP functions proposals for: quit, loadURL, selectNode, currentNode. + +********************************************************************* +* * +* 0.7.1 Beta released * +* * +********************************************************************* + + +25.10.2001, Lumir Vanek +======================= +1) Option "Append CR LF at end of line" moved to XML page, "Miscelaneous" page renamed to "Tree View". + + +24.10.2001, Lumir Vanek +======================= +1) Modifyied script make_rpm for creating RPM from command line. Is possible to use + this script for create RPM instead of KDevelop. + +24.10.2001, Olaf Hartig +======================= +1) Added the following new files for DCOP interface implementation: + - ./kxmleditor/dcopiface_app.h + - ./kxmleditor/dcopiface_app.cpp + +23.10.2001, Olaf Hartig +======================= +1) Added the following new files for DCOP interface implementation: + - ./kxmleditor/dcopiface_part_ro.h + - ./kxmleditor/dcopiface_part_ro.cpp + - ./kxmleditor/dcopiface_shell.h + - ./kxmleditor/dcopiface_shell.cpp + +18.10.2001, Olaf Hartig +======================= +1) Added a shell (new class KXMLEditorShell) which embeds our kpart + +15.10.2001, Olaf Hartig +======================= +1) Added slots for the actions to the kpart itself +2) Splitted KXmlEditorComboAction::slotClearEdit to slotFocusEdit and slotClearEdit +3) Added deselect action to the kpart +4) Added path toolbar to the kpart +5) Added possibility to show proc.instr. attributes (new class KXE_ViewProcInstr) to kpart +6) Added view of plain XML text for selected XML elements to kpart (new class KXE_ViewElement) + +12.10.2001, Olaf Hartig +======================= +1) Added configure action to the kpart + +11.10.2001, Olaf Hartig +======================= +1) Improved the behaviour of the OptionsDialog + - Added direct reading/saving of the configuration from/to the config file in OptionsDialog (new static functions: OptionsDialog::readConfiguration, OptionsDialog::saveConfiguration) + - Made the static members in OptionsDialog (the options itself) protected and added accessor functions + - Changed several files to use these new accessor functions +2) Fixed a bug in OptionsDialog::slotApply + Changes made on an currently invisible page weren't applied, now they are +3) Added saving of configuration to config file directly after changing it (see KXMLEditorApp::slotConfigurationChanged) + +7.10.2001, Lumir Vanek +====================== +1) Replaced all files in /admin subdirectory with new ones, generated KDevelop 2.0.1 + User manual creation now use meinproc instead of kdb2html. Index.docbook file updated. + Install libxml-1.8.11-53 or newer for creating doc (libxml2.rpm is available on www.suse.com). + +5.10.2001, Olaf Hartig +====================== +1) Changed copyright notes for every source file + +********************************************************************* +* * +* 0.7 Beta released * +* * +********************************************************************* + +4.10.2001, Olaf Hartig +====================== +1) Added treeitem_up action to the kpart +2) Added enabling/disabling of actions depending on status to the kpart +3) Added treeitem_expand and treeitem_collapse actions to the KPart treeview's context menus + +3.10.2001, Olaf Hartig +====================== +1) Added context menus to the KPart's treeview + +29.9.2001, Olaf Hartig +====================== +1) Added find and find_next actions to the kpart + +28.9.2001, Olaf Hartig +====================== +1) Removed KXMLEditorApp::slotExpandNodeAboutToShow and KXMLEditorApp::slotCollapseNodeAboutToShow and moved their functionality to KXMLEditorApp::initActions, because it's enough to initialize the popupmenus once +2) Fixed bug: Expanding/Collapsing treeviewitems to level 1 is now possible +3) Minimal changes in KXMLEditorApp to use the id of the menuitems of expand/collapse popupmenus +4) Added expand/collapse node actions to the kpart + +27.9.2001, Olaf Hartig +====================== +1) Added the 3 bookmark actions and its functionality to the kpart + +26.9.2001, Olaf Hartig +====================== +1) Added new file ./kxmleditor/kxmleditorpart.rc + +25.9.2001, Olaf Hartig +====================== +1) New class KXMLEditorAboutData, + - see kxmleditorabout.h + - use of this new class in KXMLEditorFactory::instance and in main +2) Added creation of attributes and contents view in the part + - KXMLEditorPart::m_pViewAttributes + - KXMLEditorPart::m_pViewContents +3) Cosmetic changes in tablewidget.h and tablewidget.cpp +4) Added functionality to update the attributes/contents view in the part depending on the selected treeitem + - KXE_TreeView::slotSelectionChanged + - KXE_TreeView::sigSelectionChanged( XmlElement * ); + - KXE_TreeView::sigSelectionChanged( XmlContentsItem * ) + - KXE_TreeView::sigSelectionChanged( XmlProcessingInstruction * ) + - KXMLEditorPart::slotTreeSelectionChanged( XmlElement * pItem ) + - KXMLEditorPart::slotTreeSelectionChanged( XmlContentsItem * ) + - KXMLEditorPart::slotTreeSelectionChanged( XmlProcessingInstruction * ) + - TableWidget::slotChange +5) Removed ./libtool from CVS , because it isn't needed there + +25.9.2001, Lumir Vanek +====================== +1) Removed KXMLEditorView::m_pSplitterVertical + +24.9.2001, Olaf Hartig +====================== +1) Changed the type of XmlStructureParser::m_pListWiew from XmlTreeView * to KListView * and the corresponding constructor parameter for XmlStructureParser, XmlProcessingInstruction, XmlContentsItem and XmlElement +2) Added first KParts code: + - added the files kxe_treeview.h, kxe_treeview.cpp, kxmleditorfactory.h, kxmleditorfactory.cpp, kxmleditorpart.h, kxmleditorpart.cpp and kxmleditorabout.h + - added lines to ./kxmleditor/kxmleditor.desktop + - changed ./kxmleditor/Makefile.am to make the shared library (libkxmleditor.la) and a binary (kxmleditor) + - changed the KDevelop Projekt Settings (./kxmleditor.kdevprj) to NOT modify the makefiles, because KDevelop can't handle making a shared lib and a binary in one project +3) Removed the following files from CVS, because they aren't needed there: + ./doc/Makefile + ./doc/Makefile.in + ./doc/en/Makefile + ./doc/en/Makefile.in + ./po/Makefile + ./po/Makefile.in + ./kxmleditor/.deps + +23.9.2001, Lumir Vanek +====================== +1) Implemented using DOM parser for opening XML + + +22.9.2001, Lumir Vanek +====================== +1) Prepared for using DOM parser + +********************************************************************* +* * +* 0.6 Beta released * +* * +********************************************************************* + +1.9.2001, Lumir Vanek +====================== +1) Added feature: #449114 Show attributes in tree view + +26.8.2001, Lumir Vanek +====================== +1) Fixed bug: #451510 element delete bug when Dragdrop +2) Added feature: #449139 Open xmlfile with specified element +3) Added feature: #449124 Shrunk mulitlined contents in tree-view + +26.7.2001, Lumir Vanek +====================== +1) Changed KXMLEditorApp::m_pActions (pointer) to m_Actions (stardart member) + +25.7.2001, Olaf Hartig +====================== +1) Renamed all actions in KXMLEditorApp to make them uniform +2) Added the structure KXMLEditorActions (new file: kxmleditoractions) and moved the pointers to the actions to it. Changed KXMLEditorApp to use this new structure. (This is useful, because i want to move some of the functionality from the mainwindow to the view). + +24.7.2001, Olaf Hartig +====================== +1) Clearing the path (location) bar with the toolbar button unselects the currently selected element. + +24.7.2001, Lumir Vanek +====================== +1) Added special characters support. This allow define list of spec. chars, that are not converted + using codec, when file is saved, but it's saved as hexa string. For example french oe ligature + is saved as œ + +23.7.2001, Lumir Vanek +====================== +1) Fixed session management bug. Now XML editor load file properly, when session is restored. + +2) In KXmlEditorComboAction::~KXmlEditorComboAction() comented deleting m_pCombo, because + this cause crash every time, when app. exiting. + +21.7.2001, Olaf Hartig +====================== +1) Merged the signals + KXMLEditorView::documentStateChanged and KXMLEditorView::selectedTreeItemChanged + to + KXMLEditorView::sigSelectedElementChanged + and the corresponding slots + KXMLEditorApp::slotDocumentStateChanged and KXMLEditorApp::slotSelectedTreeItemChanged + to + KXMLEditorApp::slotSelectedElementChanged + +2) Changed the information flow about the modification of the document + (added KXMLEditorDoc::sigModified and KXMLEditorApp::slotDocumentModified) + +20.7.2001, Olaf Hartig +====================== +1) KXmlEditorComboAction handles its combobox now on its own. + +2) I removed the special handling of bookmarked elements in the path combobox. + I removed the signals KXMLEditorView::comboInsertPath and KXMLEditorView::comboRemovePath, + cause there's no need for them anymore. + +3) I renamed the actions in the path toolbar to make them uniform. Now they are: + path_clear + path_label + path_combo + The file $KDEHOME/share/apps/kxmleditor/kxmleditorui.rc needs to be removed by + the users. + +18.7.2001, Lumir Vanek +====================== +1) Added support for XML encoding. While saving, codec selected based on + proc. instruction . + +2) Transparent KOffice files handling. Added page to Configure dialog, for + editing list of extensions, that is TarGz files. + +********************************************************************* +* * +* Alpha * +* * +********************************************************************* + diff --git a/Doxyfile b/Doxyfile new file mode 100644 index 0000000..c5fe786 --- /dev/null +++ b/Doxyfile @@ -0,0 +1,266 @@ +# Doxyfile 1.3.7-KDevelop + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = kxmleditor.kdevelop +PROJECT_NUMBER = $VERSION$ +OUTPUT_DIRECTORY = +CREATE_SUBDIRS = NO +OUTPUT_LANGUAGE = English +USE_WINDOWS_ENCODING = NO +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = YES +STRIP_FROM_PATH = /home/lvanek/Projects/Own/kpogre/ +STRIP_FROM_INC_PATH = +SHORT_NAMES = NO +JAVADOC_AUTOBRIEF = NO +MULTILINE_CPP_IS_BRIEF = NO +DETAILS_AT_TOP = NO +INHERIT_DOCS = YES +DISTRIBUTE_GROUP_DOC = NO +TAB_SIZE = 8 +ALIASES = +OPTIMIZE_OUTPUT_FOR_C = NO +OPTIMIZE_OUTPUT_JAVA = NO +SUBGROUPING = YES +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- +EXTRACT_ALL = NO +EXTRACT_PRIVATE = NO +EXTRACT_STATIC = NO +EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_METHODS = NO +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = NO +CASE_SENSE_NAMES = YES +HIDE_SCOPE_NAMES = NO +SHOW_INCLUDE_FILES = YES +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +SORT_BRIEF_DOCS = NO +SORT_BY_SCOPE_NAME = NO +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +GENERATE_DEPRECATEDLIST= YES +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = YES +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_FORMAT = "$file:$line: $text" +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = /home/lvanek/Projects/Own/kxmleditor +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.idl \ + *.odl \ + *.cs \ + *.php \ + *.php3 \ + *.inc \ + *.m \ + *.mm \ + *.C \ + *.CC \ + *.C++ \ + *.II \ + *.I++ \ + *.H \ + *.HH \ + *.H++ \ + *.CS \ + *.PHP \ + *.PHP3 \ + *.M \ + *.MM \ + *.C \ + *.H \ + *.tlh \ + *.diff \ + *.patch \ + *.moc \ + *.xpm \ + *.dox +RECURSIVE = yes +EXCLUDE = +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = * +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_SOURCE_FILES = NO +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = NO +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = YES +REFERENCES_RELATION = YES +VERBATIM_HEADERS = YES +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = NO +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_ALIGN_MEMBERS = YES +GENERATE_HTMLHELP = NO +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +BINARY_TOC = NO +TOC_EXPAND = NO +DISABLE_INDEX = NO +ENUM_VALUES_PER_LINE = 4 +GENERATE_TREEVIEW = NO +TREEVIEW_WIDTH = 250 +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = YES +LATEX_OUTPUT = latex +LATEX_CMD_NAME = latex +MAKEINDEX_CMD_NAME = makeindex +COMPACT_LATEX = NO +PAPER_TYPE = a4wide +EXTRA_PACKAGES = +LATEX_HEADER = +PDF_HYPERLINKS = NO +USE_PDFLATEX = NO +LATEX_BATCHMODE = NO +LATEX_HIDE_INDICES = NO +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = rtf +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = yes +XML_OUTPUT = xml +XML_SCHEMA = +XML_DTD = +XML_PROGRAMLISTING = YES +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = NO +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- +TAGFILES = +GENERATE_TAGFILE = kxmleditor.tag +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +PERL_PATH = /usr/bin/perl +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = YES +HIDE_UNDOC_RELATIONS = YES +HAVE_DOT = NO +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +UML_LOOK = NO +TEMPLATE_RELATIONS = NO +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +CALL_GRAPH = NO +GRAPHICAL_HIERARCHY = YES +DOT_IMAGE_FORMAT = png +DOT_PATH = +DOTFILE_DIRS = +MAX_DOT_GRAPH_WIDTH = 1024 +MAX_DOT_GRAPH_HEIGHT = 1024 +MAX_DOT_GRAPH_DEPTH = 1000 +GENERATE_LEGEND = YES +DOT_CLEANUP = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- +SEARCHENGINE = NO diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..02a4a07 --- /dev/null +++ b/INSTALL @@ -0,0 +1,167 @@ +Basic Installation +================== + + These are generic installation instructions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, a file +`config.cache' that saves the results of its tests to speed up +reconfiguring, and a file `config.log' containing compiler output +(useful mainly for debugging `configure'). + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If at some point `config.cache' +contains results you don't want to keep, you may remove or edit it. + + The file `configure.in' is used to create `configure' by a program +called `autoconf'. You only need `configure.in' if you want to change +it or regenerate `configure' using a newer version of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. If you're + using `csh' on an old version of System V, you might need to type + `sh ./configure' instead to prevent `csh' from trying to execute + `configure' itself. + + Running `configure' takes a while. While running, it prints some + messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Type `make install' to install the programs and any data files and + documentation. + + 4. You can remove the program binaries and object files from the + source code directory by typing `make clean'. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. You can give `configure' +initial values for variables by setting them in the environment. Using +a Bourne-compatible shell, you can do that on the command line like +this: + CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure + +Or on systems that have the `env' program, you can do it like this: + env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you must use a version of `make' that +supports the `VPATH' variable, such as GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + If you have to use a `make' that does not supports the `VPATH' +variable, you have to compile the package for one architecture at a time +in the source code directory. After you have installed the package for +one architecture, use `make distclean' before reconfiguring for another +architecture. + +Installation Names +================== + + By default, `make install' will install the package's files in +`/usr/local/bin', `/usr/local/man', etc. You can specify an +installation prefix other than `/usr/local' by giving `configure' the +option `--prefix=PATH'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +give `configure' the option `--exec-prefix=PATH', the package will use +PATH as the prefix for installing programs and libraries. +Documentation and other data files will still use the regular prefix. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + + There may be some features `configure' can not figure out +automatically, but needs to determine by the type of host the package +will run on. Usually `configure' can figure that out, but if it prints +a message saying it can not guess the host type, give it the +`--host=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name with three fields: + CPU-COMPANY-SYSTEM + +See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the host type. + + If you are building compiler tools for cross-compiling, you can also +use the `--target=TYPE' option to select the type of system they will +produce code for and the `--build=TYPE' option to select the type of +system on which you are compiling the package. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Operation Controls +================== + + `configure' recognizes the following options to control how it +operates. + +`--cache-file=FILE' + Use and save the results of the tests in FILE instead of + `./config.cache'. Set FILE to `/dev/null' to disable caching, for + debugging `configure'. + +`--help' + Print a summary of the options to `configure', and exit. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`--version' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`configure' also accepts some other, not widely useful, options. + diff --git a/KXMLEditor.flw b/KXMLEditor.flw new file mode 100644 index 0000000..9a2d854 Binary files /dev/null and b/KXMLEditor.flw differ diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..1fa9998 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,29 @@ +####### kdevelop will overwrite this part!!! (begin)########## + +SUBDIRS = part kxmleditor po doc + +EXTRA_DIST = AUTHORS COPYING ChangeLog INSTALL README TODO kxmleditor.lsm admin + +####### kdevelop will overwrite this part!!! (end)############ +# not a GNU package. You can remove this line, if +# have all needed files, that a GNU package needs +AUTOMAKE_OPTIONS = foreign + +$(top_srcdir)/configure.in: configure.in.in $(top_srcdir)/subdirs + cd $(top_srcdir) && $(MAKE) -f admin/Makefile.common configure.in ; + +$(top_srcdir)/subdirs: + cd $(top_srcdir) && $(MAKE) -f admin/Makefile.common subdirs + +$(top_srcdir)/acinclude.m4: $(top_srcdir)/admin/acinclude.m4.in $(top_srcdir)/admin/libtool.m4.in + @cd $(top_srcdir) && cat admin/acinclude.m4.in admin/libtool.m4.in > acinclude.m4 + +MAINTAINERCLEANFILES = subdirs configure.in acinclude.m4 configure.files + +package-messages: + $(MAKE) -f admin/Makefile.common package-messages + $(MAKE) -C po merge + +dist-hook: + cd $(top_distdir) && perl admin/am_edit -padmin + cd $(top_distdir) && $(MAKE) -f admin/Makefile.common subdirs diff --git a/Makefile.dist b/Makefile.dist new file mode 100644 index 0000000..be59a86 --- /dev/null +++ b/Makefile.dist @@ -0,0 +1,14 @@ +all: + @echo "This Makefile is only for the CVS repository" + @echo "This will be deleted before making the distribution" + @echo "" + @if test ! -d admin; then \ + echo "Please recheckout this module!" ;\ + echo "for cvs: use checkout once and after that update again" ;\ + echo "for cvsup: checkout kde-common from cvsup and" ;\ + echo " link kde-common/admin to ./admin" ;\ + exit 1 ;\ + fi + $(MAKE) -f admin/Makefile.common cvs + +.SILENT: diff --git a/README b/README new file mode 100644 index 0000000..58af37c --- /dev/null +++ b/README @@ -0,0 +1,22 @@ +Thank you for downloading KXML Editor ! + +KXML Editor is Open Source Software and developed under the GPL (see COPYING for details). + +==================================================================== + +KXML Editor is KParts application, and it must be installed properly to KDE directories. + +Before ./configure, make and make install process, use + +export KDEDIR=/opt/kde3 +export QTDIR=/usr/lib/qt3 + +Of course look where is KDE and Qt path in your system and use correct directories. + +If you experience startup crash, check if library libxmleditorpart.so.1.0.0 +is exists in KDEDIR/lib directory. + +======================================================================= + +Lumir Vanek +lvanek@users.sourceforge.net \ No newline at end of file diff --git a/TODO b/TODO new file mode 100644 index 0000000..a116bd7 --- /dev/null +++ b/TODO @@ -0,0 +1,2 @@ +Need fix: ++ documents with namespaces in attributes are not displayed properly when opened again diff --git a/configure.files b/configure.files new file mode 100644 index 0000000..030bce8 --- /dev/null +++ b/configure.files @@ -0,0 +1,2 @@ +./admin/configure.in.min +configure.in.in diff --git a/configure.in.in b/configure.in.in new file mode 100644 index 0000000..9a5fee9 --- /dev/null +++ b/configure.in.in @@ -0,0 +1,4 @@ +#MIN_CONFIG + +AM_INIT_AUTOMAKE(kxmleditor,1.1.4) + diff --git a/doc/Makefile.am b/doc/Makefile.am new file mode 100644 index 0000000..05a9fba --- /dev/null +++ b/doc/Makefile.am @@ -0,0 +1,6 @@ +####### kdevelop will overwrite this part!!! (begin)########## + +SUBDIRS = en + +####### kdevelop will overwrite this part!!! (end)############ + diff --git a/doc/en/Makefile.am b/doc/en/Makefile.am new file mode 100644 index 0000000..e1a4f66 --- /dev/null +++ b/doc/en/Makefile.am @@ -0,0 +1,10 @@ +####### kdevelop will overwrite this part!!! (begin)########## + + +EXTRA_DIST = index.docbook screenshot.png xml.png setuptargz.png setupprintout.png setupdefaults.png setuptexteditor.png setuptreeview.png specprocinstrdlg.png texteditor.png kparts.png + +####### kdevelop will overwrite this part!!! (end)############ + +KDE_LANG = en +KDE_DOCS = kxmleditor + diff --git a/doc/en/index.docbook b/doc/en/index.docbook new file mode 100644 index 0000000..8785a5d --- /dev/null +++ b/doc/en/index.docbook @@ -0,0 +1,1502 @@ + +KXML Editor" > + + + +]> + + + + + + + + + + +The KXML Editor Handbook + + + +Lumir + +Vanek + +
lvanek@users.sourceforge.net
+
+
+
+ + + +2004 +Lumir Vanek + + + +&FDLNotice; + + + +07/08/2004 +1.11 + + + + + +KXML Editor is an application for browsing and editing XML files. + + + +This document describes KXML Editor version 1.0. + + + + + + + +KDE +KXML Editor + + +
+ + + + + + + + + + +Some Fundamentals + +Extensible Markup Language (XML) is wide standart for exchanging and +transferring data in application development. XML stores character data +in a structured way, using tags placed within the data representing its structure. +An XML document has a tree structure, where "XML element" tags comprise the nodes. +The "root element", begets all the other elements in the tree. All elements except the root +have a single parent. Elements may contain character data - "XML contents". +An element node may also own a list of "attributes". + + + + +XML structure + + + + + + + + + +You may obtain more informations + about XML on Web. + + + + + + + + + + + +Introduction + + + + +KXML Editor is a program that lets you browse and edit XML files. Main window is divided +to two windows. + + + +Left side contain tree widget with XML structure. XML document has tree structute, one (and only one) +element is root. Every element may own one or more childs elements or contents items. + + + +Right side contain detail for selected item. If XML element is selectected in left side, +attributes list and raw XML are displayied. If XML contents is selectected in left side, edit widget with full +context is displayied. + + + + + + +Here's a screenshot of &kxmleditor; + + + + + + + + + + +KXML Editor contain two toolbars with buttons - one with standart commands and second with +commands for edit XML document. Third toolbar contain Konqueror-like path bar, that display +path of selected XML item. + + +The Pathbar shows the path to the selected XML item, +You can type a path here and press Enter to go to it. +You may use combobox in path bar for select bookmarked item. +The black icon at the left hand end of the Pathbar clears the text entry box. + + + + + + + + + + + + +Edit XML document + + +User may edit XML document using menu commands, or using drag and drop. + + + +Moving elements using clipboard or drag and drop has one side effect to +bookmarks system. Moving elements and their subtrees leave its paths in +Pathbar combobox nonvalid. + +When you cut/copy and paste items with bookmarks, or drag and drop it, bookmarks are not +transfered. + + + + +Using clipboard + +To copy a XML element or contents item you can: + + + + +If the item is selected you can use the +Copy button on the Toolbar or the Menubar +Edit Copy +item, or the CtrlC +hotkey. + +Then select item, where you can copy XML element. + +Finally, use Paste button or the Menubar Edit +Paste option or the CtrlV hotkey. + + + + +Moving a XML element or contents item can be done in the same +way as copying, except that you choose the Cut option +or CtrlX +instead of Copy. + + +You can also exchange XML between &kxmleditor; and text editor using clipboard. Of course, +when you paste XML element, clipboard must contain well formed XML. + + + + + +Using Drag 'n Drop + +&kxmleditor; supports Drag and Drop copying and moving of elements and +contents items. + + +Set the tree view to show the item you wish to move. If you can copy, +press Ctrl button and hold it. + +Position the mouse pointer over source item name or icon then, holding the &LMB; +pressed, drag it over to the tree view and position the +mouse pointer over the target item. Release the mouse button and Ctrl if you +made copy. + + + + +You can also drag and drop between different instances of &kxmleditor;. Also is possible drag from +&kxmleditor; and drop into text editor. + + + + + +Encoding + +&kxmleditor; supports XML document encoding. + + +When file is loaded, parser get information about encoding from processing instruction + <?xml encoding="xxxx" ?> and convert XML to Unicode. + + + +&kxmleditor; works internally with Unicode strings. + + + +While saving, &kxmleditor; convert XML from Unicode to encoding that depends on processing +instruction <?xml encoding="xxxx" ?>, where xxxx may be ISO-8859-1, ISO-8859-2, UTF-8 etc. +If you change encoding, you change codec, that is used while saving. + + + + + +KParts + +&kxmleditor; supports KParts technology. + + +If you browse directory using Konqueror, you may select XML file and click on it by right +mouse button. Then you may choose menu item Preview in +and KXML Editor that starts KXML editor inside Konqueror +main window. + + +Special processing instruction dialog + + + + + + + + + + + + + + + + + + + + + + + + +The Menu Entries + + + +The <guimenu>File</guimenu> Menu + + + + +CtrlN +File +New + +Creates a new XML document. If there is a current document +with unsaved changes the user is given a chance to save it. Program show dialog for +special processing instruction, you may choose XML version and encoding. + + + + +Special processing instruction dialog + + + + + + + + + + + + +CtrlO +File +Open + + + +This command opens a file. It does this by means of a dialog box +which allows the user to navigate the file system. The dialog operates +like a small file manager. Clicking on directories displayed in the +central window directs the dialog to enter that directory - displaying its +contents. There is an entry/dropdown box which can be used to type in +directly the location and name of the file or by clicking the arrow at the +side choose from a dropdown list of recently used locations. Below this is +a filter which similarly may have data entered directly or chosen from a +dropdown list of recent filter types. The filter facility lets only files +that meet its specifications be displayed in the central window. If the +filter contained text such as *.xml then only files +with the txt extension would be visible in the selection window. Below the filter +is a status bar giving information about the number of files and subdirectories +within the current directory. + + +The toolbar, which is located at the top of the dialog, has left and right +arrow buttons that let the user move back and forth through previously selected +directories as well as an up arrow button for moving up the directory tree. The +button with the little house takes the user to his or her home directory and the one +with the two arrows curved in on each other updates the view of the current +directory. The flag button lets the user set a new bookmark at the current directory +or go to one that was previously set. + + The last button on the toolbar allows you to create a new +directory, and finally there is dropdown box with a list of some commonly +frequented directories. + + + + + + + +File +OpenRecent + + +This is a shortcut to open recently saved documents. Clicking on +this item opens a list to the side of the menu with several of the most recently +saved files. Clicking on a specific file will open it in &kxmleditor; - if the file +still resides at the same location. + + + + + +CtrlS +File +Save + + +This saves the current document. If there has already been a save of the document then this will overwrite the previously +saved file without asking for the user's consent. If it is the first save of a new document the save as dialog +(described below) will be invoked. + + + + + +File +Save As + + +This allows a document to be saved with a new file name. This is +done by means of the file dialog box described above in the Open + section of this help file. + + + + + +File +Mail + + +This allows mail document using your mail client. + + + + + +File +Version & Encoding + + +Program show dialog for special processing instruction, you may choose XML version and encoding. + + + + + +File +Attach Schema + + +This allow to attach DTD schema file. + + + + + +File +Detach Schema + + +This allow to remove DTD schema file. + + + + + +File +Attach Stylesheet + + +This allow to insert processing instruction for ataching schema (obviously .xsl or .xslt) file. + + + + + +File +Detach Stylesheet + + +This allow to remove processing instruction for ataching schema. + + + + + +File +Print + + +This allow print document. + + + + + +CtrlQ +File +Quit + +Quits &kxmleditor; + + + + + + + + +The <guimenu>Edit</guimenu> Menu + + + + +CtrlZ +Edit +Undo + + +This is used to eliminate or reverse the most recent user action or operation. + + + + + + +CtrlShiftZ +Edit +Redo + + +This will reverse the most recent change (if any) made using Undo + + + + + + +Edit->Undo/Redo History + + + +This will call a display box showing a list of the most recent actions on the left and another list of actions which have been 'undone' on the right. +There are also three buttons at the right of the box labeled Undo, Redo, and Close. +Clicking on the Undo button will cause the action at the top of the Undo list to be reversed which will place that particular action at the top of the Redo list. +Likewise, clicking on the Redo button will reinstate the reversed action and move it back to the top of the Undo list. Clicking on an item below the top item in either +list will select all the items from the top down to that point. A subsequent click on the corresponding button will cause all the selected actions to be undone or redone accordingly. +This would be particularly useful when the user knows precisely the point to which she or he would like to proceed - making it unnecessary to go through a series of single undo or redo actions. + + + + + + +CtrlX +Edit +Cut + + +This command deletes the current selection and places it on the clipboard. The +clipboard is a feature of KDE that works invisibly to provide a way to transfer data between +applications. + + + + + +CtrlC +Edit +Copy + +This copies the currently selected text to the clipboard so that it may be +pasted elsewhere. The clipboard is a feature of KDE that works invisibly to +provide a way to transfer data between applications. + + + + + +CtrlV +Edit +Paste + + +This will insert the contents of the clipboard at the cursor position. The +clipboard is feature of KDE that works invisibly to provide a way to transfer +data between applications. + + + + + +Del +Edit +Delete + + +This will delete selected XML node, including their child subtree, if any + + + + + +Edit +Delete all attributes + + +This will delete all attributes that contain selected XML element + + + + + +Edit +Move Up + + +Move selected node Up, in their parent list + + + + + +Edit +Move Down + + +Move selected node Down, in their parent list + + + + + +CtrlE +Edit +Deselect node + + +This unselect node + + + + + +CtrlF +Edit +Find + +This opens the find dialog which is used to specify the Text to +Find in the document. There is small text box for entering the search +pattern. Other +parameters are included to make the search more efficient. Selecting +Case Sensitive will limit finds to entries that match the +case (upper or lower) of each of the characters in the search +pattern. + + + + + + +F3 +Edit +Find Next + +This repeats the last find operation, if any, without calling the find +dialog box. + + + + + +Edit +Properties + + + +Display dialog which allows the user to change selected node properties. Dialog type +depends on selected item type. + + + + + + +Edit +Edit raw XML + + + +Display dialog which allows the user to edit selected element as raw XML. + + + +Special processing instruction dialog + + + + + + + + +You may press Validate button for checking, if XML is well formed. + + + + + + + + + + + +The <guimenu>View</guimenu> Menu + + + + +AltUp Arrow +View +To P arent node + +Go up a level in the tree hierarchy. Select parent node. + + + + +CtrlPlus +View +Expand node + + + +Expand selected XML element and show entire child subtree. + + +Tip: You may expand node to choosed level. Press button for this function on toolbar, +hold mouse pressed for small anmount of time. Program show menu, which allows the user to +expand node to selected level. + + + + + + +CtrlMinus +View +Collapse node + + + +Collapse selected XML element and hide entire child subtree. + + +Tip: You may collapse node from choosed level. Press button for this function on toolbar, +hold mouse pressed for small anmount of time. Program show menu, which allows the user to +collapse node from selected level. + + + + + + + + + +The <guimenu>Insert</guimenu> Menu + + + + +CtrlShiftE +Insert +Element + + + +Insert new XML element into tree. Display dialog which allows the user to enter element name. +If you have void document, new element becomes root. If you have selected any existing element, +new element becomes child of this element. You may decide, if new element will be placed to +begin or end of childs items list. + + + + + + +CtrlShiftA +Insert +Attribute + + + +Insert new XML attribute for selected XML element. Display dialog which allows the user to enter +attribute name and value. Attribute name is checked for duplicity before inserting into +attribute list. + + + + + + +CtrlShiftT +Insert +Text + + + +Insert new XML text item into tree. Display dialog which allows the user to enter contents text. +New item becomes child of celected XML element. You may decide, if new item will be +placed to begin or end of childs items list. + + + + + + +CtrlShiftD +Insert +CDATA + + + +Insert new XML CDATA item into tree. Display dialog which allows the user to enter contents text. +New item becomes child of celected XML element. You may decide, if new item will be +placed to begin or end of childs items list. + + + + + + +CtrlShiftC +Insert +Comment + + + +Insert new XML comment item into tree. Display dialog which allows the user to enter contents text. +New item becomes child of celected XML element. You may decide, if new item will be +placed to begin or end of childs items list. + + + + + + +CtrlShiftP +XML +Insert proc. instruction + + + +Insert new XML processing instruction into tree. Display dialog which allows +the user to enter target and data. + + + + + + + + + + + +The <guimenu>Bookmarks</guimenu> Menu + + + + +CtrlB +Bookmark +Toggle bookmark + + +This creates a marker in the document at the selected item. Bookmarked item path as added +into Pathbar combo. User may traverse bookmarks using +Previous or Next Bookmark command, +or directly select bookmarked item in Pathbar combobox. + + + + + + +ShiftF5 +Bookmark +Previous bookmark + + +Move selection to previous bookmark in document, relative to selected item. Bookmarked items, +that are closed is skipped. + + + + + + +F5 +Bookmark +Next bookmark + + +Move selection to next bookmark in document, relative to selected item. Bookmarked items, +that are closed is skipped. + + + + + + + + + +The <guimenu>Settings</guimenu> Menu + + + + +Settings +Show Toolbar + + + +When checked, this displays a movable toolbar containing buttons used to +initiate frequently used commands. When unchecked the toolbar is hidden. + + + + + +Settings +Show Statusbar + + +When checked, this displays a small bar at the bottom of the main window +containing information about the status of the current document. When unchecked +the statusbar is hidden. + + + + + +SettingsConfigure Shortcuts + +This command opens a dialog box whereby the key bindings may be changed. +A display window at +the top of the dialog box shows the list of commands (actions) that can have +keyboard shortcuts. Below the display are three radio buttons. The user may choose +between No Key, Default Key, and Custom Key. (Note that a set of radio buttons only +allows the selection of one of the offered items - in the way that buttons on a car +radio only offer the selection of one preset station. Also, the Default Key +selection is only available for those commands that actually have a 'default' +shortcut.) Selecting the Custom Key option activates the three check boxes and key +button at the bottom of the dialog. The user may then select a key +combination for the command in question by means of the check boxes and key +button. For example, with the About KDE command selected in the display window, +the user could select Ctrl and Alt, click on +the key button, and then press the K key on the keyboard. This +would mean that anytime he or she held down the Ctrl and +Alt buttons and pressed K (while using +&kxmleditor;) the About KDE display box would be called. + + + + + +Settings +Configure Toolbars + +This will open the dialog whereby the toolbars configuration may +be changed. The user can choose which shortcut buttons should appear on the +toolbar. A display window on the left lists the commands available to placed +on the toolbar. A display on the right lists those commands already on the +toolbar. A set of four arrow buttons between the two displays manipulates the +selections. The right pointing arrow places any command selected in the left +pane onto the right pane, i.e., it is added to the toolbar. +The left arrow does just the opposite, removing any action selected in the right +window from the toolbar. The up and down pointing arrows change the position of +an action selected in the right window which changes the position of its button +in the toolbar. + + + + +Settings +Configure &kxmleditor; + + +This menu item opens a dialog whereby several different settings may be adjusted. + + + + + + + + +The <guimenuitem>Help</guimenuitem> Menu + + + + +F1 +Help +Contents + + +This invokes the KDE help system starting at the &kxmleditor; help pages (this document). + + + + + + +ShiftF1 +Help +What's This? + + + +This changes the mouse cursor to a combination arrow and question mark. +Clicking on items within &kxmleditor; with this arrow will open a help window (if +one exists for the particular item) explaining the item's function. + + + + + + +Help +Report Bug + + + +This calls a dialog box to help +the user help the KDE team to track down and solve any +problems(bugs) in the program. The dialog attempts to do this by +means of email using the information given by the user. + + + + + + +Help +About KXML Editor + + +This will display version and author information. + + + + + +HelpAbout KDE + +This displays the KDE version and other basic information. + + + + + + + + + + + + + + + + +Configure &kxmleditor; + +Selecting +SettingsConfigure +KXML Editor from the menu brings up the Configure-KXML Editor +dialog box. This dialog can be used to alter application settings. By means of four buttons +along the bottom of the box the user can control the process. She or he may invoke +the Help system, accept the current settings pressing Apply button, +accept the current settings and close the dialog by means of the OK button, or +Cancel the process. + + + + +Tree View +This category deals with following properties detailed below. + + + +TarGz Extensions + + + + + + + + + + + +Set root element decorated + + +Set the root element in tree view decorated. +Sets this view to show open/close sign on root item. + + + + +Default expand level + + +Set the default expand level for tree view. + + + + +Enable drag & drop + + +Enables or disables drag & drop. Disabling it may be useful, when X-Window client +and server is not on the same machine and respond time is slow, that may cause unnecesary +drag & drop operation caused while selecting in tree view. + + + + +Show... + +This option allow display XML attributes for each element in left side tree window. +You may choose one of this options: Show only element name or Element, attribute name +or Element, attributes names and its value. + + + + + + + + + +Defaults +This category allow set default XML version, encoding and program behavior +while creating new document + + + +Defaults + + + + + + + + + + + + +XML version + + +Default XML version for new documents. + + + + +Encoding + + +Default XML encoding for new documents. + + + + +Creating new files + + +Behavior when creating new XML documents. + + + + + + + + + + +Printout +This category allow set parameters for printing XML document + + + +Printout + + + + + + + + + + + + +Font family + + +Choose font family for printing document. + + + + +Font size + + +Choose font size for printing document. + + + + +Element intendation + + +Choose element intendation for printing document. + + + + +Print header + + +Choose if you can print header when printing document. + + + + +Print footer + + +Choose if you can print footer when printing document. + + + + + + + + + + +TarGz Extensions +This category allow set list of XML files, that is TarGz archives. +This allow open and save those files transparently. This may be useful +for browsing KOffice files. + + + +TarGz Extensions + + + + + + + + + + + + +Archive files extensions + + +You may edit list of files extension using New and Delete buttons. +Actually selected item may be changed using edit line. + + + + + + + + + +Text Editor +This category allow set text edior syntax highlighting + + + +Text Editor + + + + + + + + + + + + +Syntax highlighting + + +You may choose various colors for different XML syntax. + + + + +Element intendation + + +Choose element intendation for raw XML editing. This intendation is used also for saving document. + + + + +Wrap, instead of Hrz. Scroll bar + + +Disable horizontal srcrollbar and set word wrap ON for raw XML view and editing. + + + + + + + + + + + + + + + + + + + + +Credits and License + + +&kxmleditor; Program copyright 2001-2003 the &kxmleditor; developers: + + + + + +Lumir Vanek lvanek@users.sourceforge.net +Developer and maintainer + + + +Olaf Hartig hartig@users.sourceforge.net +Developer + + + +Adam Charytoniuk a_charytoniuk@users.sourceforge.net +Developer + + + + + +Documentation copyright 2003 Lumir Vanek lvanek@users.sourceforge.net + + + + +&underFDL; + + + +&underGPL; + + + + + + + + + + +Installation + + +How to obtain KXML Editor + + +You may obtain &kxmleditor; from URL: +http://sourceforge.net/projects/kxmleditor. + + + + +Requirements + + + + +In order to successfully use &kxmleditor;, you need KDE 3.1.x or higher. +For instructions on acquiring &kde; please see http://www.kde.org. + + + + + +Compilation and installation + + +In order to compile and install &kxmleditor; on your system, type the following in the base +directory: + +% ./configure +% make +% make install + + + +Since &kxmleditor; uses autoconf and automake you should have not trouble compiling it. +Should you run into problems please report them to author. + + + + + +&documentation.index; +
+ diff --git a/doc/en/kparts.png b/doc/en/kparts.png new file mode 100644 index 0000000..b6c1663 Binary files /dev/null and b/doc/en/kparts.png differ diff --git a/doc/en/screenshot.png b/doc/en/screenshot.png new file mode 100644 index 0000000..7a965ff Binary files /dev/null and b/doc/en/screenshot.png differ diff --git a/doc/en/setupdefaults.png b/doc/en/setupdefaults.png new file mode 100644 index 0000000..59e1917 Binary files /dev/null and b/doc/en/setupdefaults.png differ diff --git a/doc/en/setupprintout.png b/doc/en/setupprintout.png new file mode 100644 index 0000000..0d4b083 Binary files /dev/null and b/doc/en/setupprintout.png differ diff --git a/doc/en/setuptargz.png b/doc/en/setuptargz.png new file mode 100644 index 0000000..623c817 Binary files /dev/null and b/doc/en/setuptargz.png differ diff --git a/doc/en/setuptexteditor.png b/doc/en/setuptexteditor.png new file mode 100644 index 0000000..8e26888 Binary files /dev/null and b/doc/en/setuptexteditor.png differ diff --git a/doc/en/setuptreeview.png b/doc/en/setuptreeview.png new file mode 100644 index 0000000..ce50d83 Binary files /dev/null and b/doc/en/setuptreeview.png differ diff --git a/doc/en/specprocinstrdlg.png b/doc/en/specprocinstrdlg.png new file mode 100644 index 0000000..2acd515 Binary files /dev/null and b/doc/en/specprocinstrdlg.png differ diff --git a/doc/en/texteditor.png b/doc/en/texteditor.png new file mode 100644 index 0000000..8f3ad21 Binary files /dev/null and b/doc/en/texteditor.png differ diff --git a/doc/en/xml.png b/doc/en/xml.png new file mode 100644 index 0000000..5be8cdd Binary files /dev/null and b/doc/en/xml.png differ diff --git a/kxmleditor.lsm b/kxmleditor.lsm new file mode 100644 index 0000000..bef9475 --- /dev/null +++ b/kxmleditor.lsm @@ -0,0 +1,14 @@ +Begin3 +Title: KXMLEditor +Version: 0.7 +Entered-date: +Description: XML files editor for KDE +Keywords: KDE, XML +Author: Lumir Vanek, Olaf Hartig, Mateusz Korniak +Maintained-by: Lumir Vanek +Primary-site: http://kxmleditor.sourceforge.net +Home-page: http://kxmleditor.sourceforge.net +Original-site: +Platforms: Linux and other Unices +Copying-policy: GNU Public License +End diff --git a/kxmleditor.spec b/kxmleditor.spec new file mode 100644 index 0000000..b89b00a --- /dev/null +++ b/kxmleditor.spec @@ -0,0 +1,45 @@ +Summary: KXML Editor for KDE 3.x +Name: kxmleditor +Version: 1.1.4 +Release: 0.1 +Copyright: GPL +Vendor: Lumir Vanek +Url: http://kxmleditor.sourceforge.net +Packager: Lumir Vanek +Group: Development/Tools +Source: kxmleditor-1.1.4.tar.gz +BuildRoot: %{_tmppath}/%{name}-buildroot + +%description +XML Editor for KDE. + +%prep +%setup +CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" ./configure \ + \ + $LOCALFLAGS +%build +# Setup for parallel builds +numprocs=`egrep -c ^cpu[0-9]+ /proc/stat || :` +if [ "$numprocs" = "0" ]; then + numprocs=1 +fi + +make -j$numprocs + +%install +make install-strip DESTDIR=$RPM_BUILD_ROOT + +cd $RPM_BUILD_ROOT +find . -type d | sed '1,2d;s,^\.,\%attr(-\,root\,root) \%dir ,' > $RPM_BUILD_DIR/file.list.kxmleditor +find . -type f | sed 's,^\.,\%attr(-\,root\,root) ,' >> $RPM_BUILD_DIR/file.list.kxmleditor +find . -type l | sed 's,^\.,\%attr(-\,root\,root) ,' >> $RPM_BUILD_DIR/file.list.kxmleditor + +%clean +rm -rf $RPM_BUILD_ROOT/* +rm -rf $RPM_BUILD_DIR/kxmleditor +rm -rf ../file.list.kxmleditor + + +%files -f ../file.list.kxmleditor + diff --git a/kxmleditor/Makefile.am b/kxmleditor/Makefile.am new file mode 100644 index 0000000..58a534c --- /dev/null +++ b/kxmleditor/Makefile.am @@ -0,0 +1,51 @@ +####### kdevelop will overwrite this part!!! (begin)########## + +bin_PROGRAMS = kxmleditor + +kxmleditor_SOURCES = dcopiface_shell.skel dcopiface_shell.cpp kxmleditorshell.cpp main.cpp kxeshellmanager.cpp +kxmleditor_LDFLAGS = $(all_libraries) $(KDE_RPATH) +kxmleditor_LDADD = $(LIB_KPARTS) $(LIB_KFILE) $(LIB_KDEUI) $(LIB_KDECORE) $(LIB_QT) $(LIBSOCKET) + +EXTRA_DIST = main.cpp \ + kxmleditor.desktop \ + kxmleditorshell.cpp kxmleditorshell.h kxmleditorshell.rc \ + dcopiface_shell.cpp dcopiface_shell.h + +install-data-local: + $(mkinstalldirs) $(kde_appsdir)/Applications/ + $(INSTALL_DATA) $(srcdir)/kxmleditor.desktop $(kde_appsdir)/Applications/kxmleditor.desktop + +uninstall-local: + -rm -f $(kde_appsdir)/Applications/kxmleditor.desktop + -rmdir $(kde_appsdir)/Applications + +####### kdevelop will overwrite this part!!! (end)############ +# this 10 paths are KDE specific. Use them: +# kde_htmldir Where your docs should go to. (contains lang subdirs) +# kde_appsdir Where your application file (.kdelnk) should go to. +# kde_icondir Where your icon should go to. +# kde_minidir Where your mini icon should go to. +# kde_datadir Where you install application data. (Use a subdir) +# kde_locale Where translation files should go to.(contains lang subdirs) +# kde_cgidir Where cgi-bin executables should go to. +# kde_confdir Where config files should go to. +# kde_mimedir Where mimetypes should go to. +# kde_toolbardir Where general toolbar icons should go to. +# kde_wallpaperdir Where general wallpapers should go to. + +# set the include path for X, qt and KDE +INCLUDES= $(all_includes) + +METASOURCES = AUTO + +rcdir = $(kde_datadir)/kxmleditor +rc_DATA = kxmleditorshell.rc + +messages: rc.cpp + LIST=`find . -name \*.h -o -name \*.hh -o -name \*.H -o -name \*.hxx -o -name \*.hpp -o -name \*.cpp -o -name \*.cc -o -name \*.cxx -o -name \*.ecpp -o -name \*.C`; \ + if test -n "$$LIST"; then \ + if ! test -e $(podir)/kxmleditor.pot; then touch $(podir)/kxmleditor.pot; fi; \ + $(XGETTEXT) -j $$LIST -o $(podir)/kxmleditor.pot; \ + fi + +noinst_HEADERS = kxeshellmanager.h diff --git a/kxmleditor/dcopiface_shell.cpp b/kxmleditor/dcopiface_shell.cpp new file mode 100644 index 0000000..a03d149 --- /dev/null +++ b/kxmleditor/dcopiface_shell.cpp @@ -0,0 +1,39 @@ +/*************************************************************************** + dcopiface_shell.cpp - description + ------------------- + begin : Tue Oct 23 2001 + copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team + email : lvanek@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "dcopiface_shell.h" +#include "kxmleditorshell.h" + +QString +KXMLEditorShellIface::Quit() +{ +// m_pKXEShell->close(); + m_KXEShell.close(); + return ""; + +} + + +void +KXMLEditorShellIface::FileOpen() +{ + m_KXEShell.slotFileOpen(); +} + + + + diff --git a/kxmleditor/dcopiface_shell.h b/kxmleditor/dcopiface_shell.h new file mode 100644 index 0000000..63a0f8c --- /dev/null +++ b/kxmleditor/dcopiface_shell.h @@ -0,0 +1,70 @@ +/*************************************************************************** + dcopiface_shell.h - description + ------------------- + begin : Tue Oct 23 2001 + copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team + email : lvanek@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#ifndef DCOPIFACE_SHELL_H +#define DCOPIFACE_SHELL_H + +#include +#include + +/** + *@short DCOP inteface for Kpart based kxmleditor shell. + *@author The KXMLEditor Team + * See the shell iface as an user, who can perform the _shell_ actions a live user can. + * This means opening a file via an fileopen dialog and not by giving a filename/url (this is up to the part's iface - but read on, I'll come back to it later). This means your openURL function should simply "open" and should show the file open dialog. + */ +class KXMLEditorShell; + +class KXMLEditorShellIface + :virtual public DCOPObject +{ + K_DCOP +protected: + /** + Pointer to @ref KXMLEditorShell which iface manages. + **/ + KXMLEditorShell & m_KXEShell; +public: + /** + * Default constructor with default name of DCOP object used by @ref KXMLEditorShell + **/ + KXMLEditorShellIface(KXMLEditorShell & KXEShell, const char * szDCOPObjectName = "KXMLEditorShellIface") + :DCOPObject(szDCOPObjectName) + ,m_KXEShell(KXEShell) + { +// m_pKXEShell = pKXEShell; + } +k_dcop: + + /** + * Closes entire KXMLEditor. + * + * @returns Error description or empty string if program closed. + **/ + QString Quit(); + + + /** + * Calls and shows open file dialog. + **/ + + ASYNC FileOpen(); + + +}; + +#endif // DCOPIFACE_SHELL_H + diff --git a/kxmleditor/kxeshellmanager.cpp b/kxmleditor/kxeshellmanager.cpp new file mode 100644 index 0000000..b20b1af --- /dev/null +++ b/kxmleditor/kxeshellmanager.cpp @@ -0,0 +1,55 @@ +// +// C++ Implementation: kxeshellmanager +// +// Description: +// +// +// Author: Adam Charytoniuk , (C) 2004 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#include "kxeshellmanager.h" +#include "kxmleditorshell.h" + +#include + +KXEShellManager::KXEShellManager() +{ +} + +KXEShellManager::~KXEShellManager() +{ +} + +void KXEShellManager::addShell(KXMLEditorShell* pShell) +{ +/* + for (unsigned int i=0; islotShellAdded(pShell); + pShell->slotShellAdded(m_shells.at(i)); + } + */ + m_shells.append(pShell); +} + +void KXEShellManager::removeShell(KXMLEditorShell* pShell) +{ + m_shells.remove(pShell); + /* + for (unsigned int i=0; islotShellRemoved(pShell); + } + */ +} + + +/*! + \fn KXEShellManager::shells() + */ +QPtrList* KXEShellManager::shells() +{ + return &m_shells; +} diff --git a/kxmleditor/kxeshellmanager.h b/kxmleditor/kxeshellmanager.h new file mode 100644 index 0000000..0eeff8e --- /dev/null +++ b/kxmleditor/kxeshellmanager.h @@ -0,0 +1,65 @@ +// +// C++ Interface: kxeshellmanager +// +// Description: +// +// +// Author: Adam Charytoniuk , (C) 2004 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#ifndef KXESHELLMANAGER_H +#define KXESHELLMANAGER_H +/** +@file +*/ + +#include + +class KXMLEditorShell; + +/** +@short Available shell list + +Stores and dispatches informations about all KXMLEditorShell windows currently opened. +Only one instance of this class is created. Eeach shell adds itself into this manager. + +@sa KXMLEditorShell + +@author Adam Charytoniuk +*/ +class KXEShellManager{ +public: + /** @short Constructor */ + KXEShellManager(); + + /** @short Destructor */ + ~KXEShellManager(); + + /** @short Adds given part to the manager. + + All opened Shells will be informed about that event by KXMLEditorShell::slotShellAdded() + method. In addition, newly added shell will be informed about presence of each of all existing + shells with the same method. + @param pShell newly added shell + */ + void addShell(KXMLEditorShell* pShell); + + /** @short Removes given part from manager. + + All opened Shells will be informed about that event by KXMLEditorShell::slotShellRemoved() + method. + @param pShell to be removed (closed) + */ + void removeShell(KXMLEditorShell* pShell); + + /** @short Returns list of currently opened shells. */ + QPtrList *shells(); + +private: + /** @short Internally stores list of available shells. */ + QPtrList m_shells; +}; + +#endif diff --git a/kxmleditor/kxmleditor.desktop b/kxmleditor/kxmleditor.desktop new file mode 100644 index 0000000..556f62a --- /dev/null +++ b/kxmleditor/kxmleditor.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Type=Application +Exec=kxmleditor -caption "%c" %i %m +Icon=kxmleditor.png +DocPath=kxmleditor/index.html +Comment=XML editor +Comment[fi]=XML-editori +Terminal=false +Name=KXML Editor +MimeType=text/xml; +Encoding=UTF-8 +Categories=Application;Development;TextEditor;KDE; diff --git a/kxmleditor/kxmleditorshell.cpp b/kxmleditor/kxmleditorshell.cpp new file mode 100644 index 0000000..bbb6f02 --- /dev/null +++ b/kxmleditor/kxmleditorshell.cpp @@ -0,0 +1,495 @@ +/*************************************************************************** + kxmleditorshell.cpp - description + ------------------- + begin : Thu Oct 18 2001 + copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team + email : lvanek@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + /** + @file + */ + +#include "kxmleditorshell.h" +#include "kxeshellmanager.h" +#include "../part/kxmleditorpart.h" +#include "../part/kxedocument.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include "dcopiface_shell.h" + + +KXEShellManager *KXMLEditorShell::s_manager=0L; + +KXMLEditorShell::KXMLEditorShell( const char * name, WFlags f ) + : KParts::MainWindow( name, f ), + m_pPart(0), + m_pKXEShellIface(0) +{ + ////////////////////////////// + // CREATE ACTIONS + ////////////////////////////// + + setXMLFile("kxmleditorshell.rc"); + + KStdAction::openNew( this,SLOT(slotActFileNew()),actionCollection() ); + KStdAction::open( this, SLOT(slotFileOpen()), actionCollection() ); + m_pActFileOpenRecent = KStdAction::openRecent( this, SLOT(slotFileOpenRecent(const KURL&)), actionCollection() ); + m_pActFileOpenRecent->loadEntries( instance()->config() ); + m_pActReload = new KAction( i18n("Reloa&d"), "reload", Key_F5, this, SLOT(slotFileReload()), actionCollection(), "reload" ); + + KToggleAction * pActToggleMainToolBar = KStdAction::showToolbar( this, SLOT(slotToggleMainToolBar()), actionCollection() ); + KToggleAction * pActToggleStatusBar = KStdAction::showStatusbar( this, SLOT(slotToggleStatusBar()), actionCollection() ); + KStdAction::keyBindings( this, SLOT(slotConfigureKeys()), actionCollection() ); + KStdAction::configureToolbars( this, SLOT(slotConfigureToolbars()), actionCollection() ); + + KStdAction::mail( this, SLOT(mail()), actionCollection() ); + KStdAction::close( this, SLOT(slotActClose()), actionCollection() ); + KStdAction::quit( this, SLOT(close()), actionCollection()); + + // L.V. moved to part pActPrint = KStdAction::print( 0, 0, actionCollection(), "print" ); + + pActCloseW = new KAction( i18n("&Close"), 0, 0, this,SLOT(slotActWindowClose()), actionCollection(), "window_close" ); + pActCloseAllW = new KAction( i18n("Close &all"), 0, 0, this,SLOT(slotActWindowCloseAll()), actionCollection(), "window_close_all" ); + pActCloseAllO = new KAction( i18n("Close all &others"), 0, 0, this,SLOT(slotActWindowCloseAllOthers()), actionCollection(), "window_close_all_others" ); + + ////////////////////////////// + // CREATE STATUSBAR + ////////////////////////////// + statusBar()->message( i18n("Ready.") ); + + ////////////////////////////// + // MISC. INITIALIZATION + ////////////////////////////// + + manager()->addShell(this); + + setAutoSaveSettings(); + pActToggleMainToolBar->setChecked( ! toolBar()->isHidden() ); + pActToggleStatusBar->setChecked( ! statusBar()->isHidden() ); + + m_pKXEShellIface = new KXMLEditorShellIface(*this); + + statusBar()->setSizeGripEnabled(true); + + setPart(0L); // start empty + +} + +KXMLEditorShell::~KXMLEditorShell() +{ + if (m_pKXEShellIface) + delete m_pKXEShellIface; + + manager()->removeShell(this); +} + +///////////////////////////////////////////////////////////////////// +// ACTION SLOTS +///////////////////////////////////////////////////////////////////// + +void KXMLEditorShell::slotFileOpen() +{ + statusBar()->message( i18n("Opening file...") ); + + KURL url = KFileDialog::getOpenURL( QString::null, + i18n(FILE_DIALOG_FILTER), + this ); + openURL(url); + + // L.V.: tried to meve save functionality to Part + //m_pActFileSave->setEnabled(true); // TODO: L.V. Why File Save ? Why not Save as... ? + + statusBar()->message( i18n("Ready.") ); +} + +void KXMLEditorShell::slotFileOpenRecent(const KURL & url) +{ + statusBar()->message( i18n("Opening file...") ); + + openURL(url); + + statusBar()->message( i18n("Ready.") ); +} + +void KXMLEditorShell::slotFileReload() +{ + statusBar()->message( i18n("Reloading file...") ); + + // Try to (re)open the file. + // In case the file is modified, a Save/Discard/Cancel message box pops up. + if ( part() && ! part()->url().isEmpty() ) + part()->openURL( part()->url() ); + + statusBar()->message( i18n("Ready.") ); +} + +void KXMLEditorShell::slotToggleMainToolBar() +{ + statusBar()->message( i18n("Toggle the toolbar...") ); + + if( toolBar()->isHidden() ) + toolBar()->show(); + else + toolBar()->hide(); + + statusBar()->message( i18n("Ready.") ); +} + + +void KXMLEditorShell::slotToggleStatusBar() +{ + statusBar()->message( i18n("Toggle the statusbar...") ); + + if( statusBar()->isHidden() ) + statusBar()->show(); + else + statusBar()->hide(); + + statusBar()->message( i18n("Ready.") ); +} + +void KXMLEditorShell::slotConfigureKeys() +{ + KKeyDialog dlg; + dlg.insert(part()->actionCollection()); + dlg.insert(actionCollection()); + dlg.configure(); +} + +void KXMLEditorShell::slotConfigureToolbars() +{ + KEditToolbar dlg( factory() ); + if ( dlg.exec() ) + createGUI( part() ); +} + +///////////////////////////////////////////////////////////////////// +// ADDITIONAL FUNCTIONS +///////////////////////////////////////////////////////////////////// + +bool KXMLEditorShell::openURL( const KURL & url ) +{ + if ( url.isEmpty() ) + return false; + + // About this function, the style guide ( + // http://developer.kde.org/documentation/standards/kde/style/basics/index.html ) + // says that it should open a new window if the document is _not_ + // in its initial state. This is what we do here. + + // If there is no part yet created, create new one... + if (!part()) + { + setPart(createXMLPart(this)); + } + + // We have to differenciate, if this shell could + // be used or a new one has to be created. + if ( part()->url().isEmpty() && ! part()->isModified() ) + { + // this one can be used - try to open the file in it + if ( ! part()->openURL(url) ) + return false; + } + else + { + // a new one has to be created + KXMLEditorShell * pShell = new KXMLEditorShell; + // and a new part too... + pShell->setPart(createXMLPart(pShell)); + + // try to open the file in the shell + if ( ! pShell->part()->openURL(url) ) + return false; + + // show the new shell + pShell->show(); + } + + // on success, the URL could be added to our list of recent files + m_pActFileOpenRecent->addURL(url); + + return true; +} + +bool KXMLEditorShell::queryClose() +{ + if ( part() && ! part()->closeURL() ) + return false; + + m_pActFileOpenRecent->saveEntries( instance()->config() ); + + return KParts::MainWindow::queryClose(); +} + +void KXMLEditorShell::saveProperties( KConfig * pConfig ) +{ + if (part()) + { + pConfig->writeEntry( "CurrentURL", part()->url().url() ); + } + KParts::MainWindow::saveProperties(pConfig); +} + +void KXMLEditorShell::readProperties( KConfig * pConfig ) +{ + KParts::MainWindow::readProperties(pConfig); + +/// @todo Check if ths is a deadcode +// QString strURL = pConfig->readEntry( "CurrentURL", "" ); +// if ( strURL.isEmpty()) +// part()->openURL( strURL ); +} + +void KXMLEditorShell::slotEnableBrowserExtActions( const char * pszName, bool bEnabled ) +{ + KAction * pAct = actionCollection()->action( pszName ); + if ( pAct ) + pAct->setEnabled( bEnabled ); + else + kdDebug() << "KXMLEditor " << k_funcinfo << " unknown action (" << pszName << ")" << endl; +} + +// Set main window caption (by using the base class functionality), +// Enables/disables Save button (corresponding to the parts modified status) +void KXMLEditorShell::setCaption( const QString & strCaption ) +{ + if (part()) + { + KParts::MainWindow::setCaption( strCaption, part()->isModified() ); // base class functionality + } +} + + +// +// Called when creating new file is requested. +// +void KXMLEditorShell::slotActFileNew() +{ + + // About this function, the style guide ( + // http://developer.kde.org/documentation/standards/kde/style/basics/index.html ) + // says that it should open a new window if the document is _not_ + // in its initial state. This is what we do here.. + KXMLEditorShell * pShell; + KParts::ReadWritePart* pPart; + + // 1. This shell is empty + if (!part()) + { + pPart = createXMLPart(this); + pShell=this; + } + // 2. The shell contains modified part + else if (! part()->url().isEmpty() || part()->isModified() ) + { + pShell = new KXMLEditorShell; + pPart = createXMLPart(pShell); + pShell->show(); + } + // 3. The shell contains part, and it is empty and not modified + else + { + pPart=part(); + pShell=this; + } + + pShell->setPart(pPart); + // if there is a way to determine in KXMLEditorPart that it was created "for new file" then + // this part should be changed. + ((KXMLEditorPart *)pPart)->document()->newFile(); +} + +void KXMLEditorShell::mail() +{ + // L.V.: tried to meve save functionality to Part + //slotFileSave(); + + // first - our XML file have to be saved. + part()->save(); + + if (!part()->url().isEmpty()) + { + QStringList urls(part()->url().url()); // we can prepare then list of attachments (1 element in the list) + QString theSubject(part()->url().fileName(false)); // and set the mail subject + kapp->invokeMailer(QString::null, // finally we can compose e-mail (addressed to no-one) out of that + QString::null, + QString::null, + theSubject, // subject + QString::null, // body + QString::null, + urls); // attachments + } +} + +void KXMLEditorShell::setPart(KParts::ReadWritePart* pPart) +{ + if (pPart==m_pPart) + return; // nothing to do here... + else + { + if(pPart) + { + connect(static_cast (pPart), SIGNAL(sigAddRecentURL(const KURL &)), + this, SLOT(slotAddRecentURL(const KURL &)) ); + } + } + + if (m_pPart) + { + factory()->removeClient(m_pPart); + delete m_pPart; + } + m_pPart = pPart; + if (pPart) + { + // get the parts browser extension and connect additional actions to it + KParts::BrowserExtension * pBrowserExt = 0; + if ( (pBrowserExt = KParts::BrowserExtension::childObject(pPart)) ) // if there is one + { + connect( pBrowserExt, SIGNAL(enableAction( const char *, bool )), this, SLOT(slotEnableBrowserExtActions( const char *, bool )) ); + + // L.V. moved to part. connect(pActPrint,SIGNAL(activated()),pBrowserExt, SLOT(print())); + //pActPrint->setEnabled(pBrowserExt->isActionEnabled("print")); + } + + createGUI(pPart); + setCentralWidget(pPart->widget() ); + pPart->widget()->show(); + stateChanged("part"); + } + else + { + createGUI(0L); + setCentralWidget(0L); + stateChanged("empty"); + } + + // keep pointer to window menu + m_windowMenu = static_cast(factory()->container("window", this)); + if(!m_windowMenu) + kdDebug() << "KXMLEditorShell::setPart - m_windowMenu is NULL" << endl; + else + connect(m_windowMenu,SIGNAL(aboutToShow()),this,SLOT(slotBeforeWindowMenuShown())); +} + +KParts::ReadWritePart* KXMLEditorShell::createXMLPart(QObject *parent) +{ + return createPart(parent,"libkxmleditorpart", "KParts::ReadWritePart"); +} + +KParts::ReadWritePart* KXMLEditorShell::createPart(QObject *parent, const QString& libName, const QString& className) +{ + KParts::ReadWritePart* newPart = 0L; + KLibFactory * pFactory = KLibLoader::self()->factory(libName); + if (pFactory) + newPart = static_cast ( pFactory->create( parent, "KXMLEditor view", className ) ); + else + kdFatal() << "KXMLEditorShell::KXMLEditorShell no " << libName << " found" << endl; + return newPart; +} + +void KXMLEditorShell::slotActClose() +{ + if (part() && part()->queryClose()) + setPart(0L); +} + +void KXMLEditorShell::close() +{ + if (queryClose()) + { + if (KMainWindow::memberList->count()==1) + kapp->deref(); + delete this; + } +} + +void KXMLEditorShell::slotActWindowCloseAllOthers() +{ + QPtrListIterator it(*KMainWindow::memberList); + for (it.toFirst();it.current();++it) + { + if (it.current()!=this) + it.current()->close(); + } +} + + void KXMLEditorShell::slotActWindowClose() +{ + this->close(); +} + +void KXMLEditorShell::slotActWindowCloseAll() +{ + slotActWindowCloseAllOthers(); + slotActWindowClose(); +} + +KXEShellManager* KXMLEditorShell::manager() +{ + if (!s_manager) + { + s_manager = new KXEShellManager(); + } + return s_manager; +} + +void KXMLEditorShell::slotBeforeWindowMenuShown() +{ + // first we have to clean all shell items... + m_windowMenu->clear(); + + // then we plug-in neccessary actions... + pActCloseW->plug(m_windowMenu); + pActCloseAllW->plug(m_windowMenu); + pActCloseAllO->plug(m_windowMenu); + m_windowMenu->insertSeparator(); + + // and then we can add entries for all shells + // that are registered in Shell Manager... + QPtrListIterator it (*(manager()->shells())); + for (it.toFirst(); it.current();++it) + { + int id = m_windowMenu->insertItem(it.current()->caption(),it.current(),SLOT(slotActivate())); + m_windowMenu->setItemChecked(id,it.current()==this); + } +} + +void KXMLEditorShell::slotActivate() +{ + /// @todo windows have to be activated over EWMH + showNormal(); // show it if it's minimized + raise(); // bring that to front +} + +// Add URL to recent file list +void KXMLEditorShell::slotAddRecentURL(const KURL &url) +{ + m_pActFileOpenRecent->addURL(url); +} diff --git a/kxmleditor/kxmleditorshell.h b/kxmleditor/kxmleditorshell.h new file mode 100644 index 0000000..848e47a --- /dev/null +++ b/kxmleditor/kxmleditorshell.h @@ -0,0 +1,178 @@ +/*************************************************************************** + kxmleditorshell.h - description + ------------------- + begin : Thu Oct 18 2001 + copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team + email : lvanek@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + /** + @file + */ + + +#ifndef KXMLEDITORSHELL_H +#define KXMLEDITORSHELL_H + +#include + +class KParts::ReadWritePart; +class KXMLEditorShellIface; +class KAction; +class KXEShellManager; + + +/** + @short The shell, which can contain our #KXMLEditorPart. + + It is the window that owns main user interface elements. +*/ +class KXMLEditorShell : public KParts::MainWindow +{ + Q_OBJECT + public: + /** @short Constructor + + Creates shell and adds it into one global instance of KXEShellManager. + @sa KXEShellManager + */ + KXMLEditorShell( const char * name = 0L, WFlags f = WDestructiveClose ); + + /** @short Destructor + + Destroys shell. Performs also removing given shell from global instance + of KXEShellManager. + */ + virtual ~KXMLEditorShell(); + + /** @short Opens new file and shows it in the current shell. */ + bool openURL( const KURL & url ) ; + + /** @short Closes this shell. */ + virtual void close(); + + /** @short Returns part manager object */ + KXEShellManager* manager(); + + /** @short Creates new part which can be shown in the shell. + @param parent parent object for the part*/ + static KParts::ReadWritePart* createXMLPart(QObject *parent) ; + + static KParts::ReadWritePart* createPart(QObject *parent, const QString& libName, const QString& className); + + /** @short Changes currenly shown part. */ + void setPart(KParts::ReadWritePart* pPart); + + public slots: + /** @short Slot connected to File->New action. */ + void slotActFileNew(); + + /** @short Slot connected to File->Open action. */ + void slotFileOpen(); + + void slotFileOpenRecent( const KURL & url ); + + /** @short Slot connected to File->Reload action. */ + void slotFileReload(); + + /** @short Slot connected to action responsible for showing and hiding main toolbar.*/ + void slotToggleMainToolBar(); + + /** @short Slot connected to action responsible for showing and hiding status bar.*/ + void slotToggleStatusBar(); + + /** @short Slot connected to action. Shows shortcut configuration dialog.*/ + void slotConfigureKeys(); + + /** @short Slot connected to action. Shows toolbar configuration dialog.*/ + void slotConfigureToolbars(); + + /** @short Changes shell caption.*/ + virtual void setCaption( const QString & strCaption ); + + /** @short Sends currently opened XML file over e-mail. + + The application will try to start default mail client and prepare + new empty mail with currently opened file as an attachment. + The file have to be saved first on a disc. + @sa KApplication::invokeMailer() + */ + void mail(); + + /** @short Connected to File->Close action + + Closes currently opened file, but not the shell itself. The shell + remaines empty but active, so it's possible for the user + to open another file in it.*/ + void slotActClose(); + + /** @short slot connected to Window->Close action. + @sa close() */ + void slotActWindowClose(); + + /** @short slot connected to Window->Close All action. */ + void slotActWindowCloseAll(); + + /** @short slot connected to Window->Close All Others action. */ + void slotActWindowCloseAllOthers(); + + void slotActivate(); + + protected: + virtual bool queryClose(); + virtual void saveProperties( KConfig * ); + virtual void readProperties( KConfig * ); + + /** @short Stores pointer to currenly shown part. */ + KParts::ReadWritePart * m_pPart; + + /** @short Action for recently opened files. */ + KRecentFilesAction * m_pActFileOpenRecent; + + /** @short Action for reloading the document currently open. */ + KAction * m_pActReload; + + /** @short Action for printing complete XML files.*/ + // L.V. moved to part. KAction* pActPrint; + + KAction* pActCloseW; + KAction* pActCloseAllW; + KAction* pActCloseAllO; + + /** @short DCOP interface pointer (if no such iface pointer == 0).*/ + KXMLEditorShellIface * m_pKXEShellIface; + + /** @short Stores pointer to window menu. + + This menu is expanded everytime new shell is shown. */ + KPopupMenu* m_windowMenu; + + /** @short Returns currently shown part. */ + KParts::ReadWritePart* part() const {return m_pPart;} + + /** @short Adds this shell window to part manager for monitoring */ +// void addToManager(); + + protected slots: + /** To enable/disable actions, the way the parts browser extension wishes. */ + void slotEnableBrowserExtActions( const char * pszName, bool bEnabled ); + + void slotBeforeWindowMenuShown(); + + // Add URL to recent file list + void slotAddRecentURL(const KURL &); + + private: + /** @short Stores pointer to global instance of #KParts::PartManager */ + static KXEShellManager *s_manager; +}; + +#endif diff --git a/kxmleditor/kxmleditorshell.rc b/kxmleditor/kxmleditorshell.rc new file mode 100644 index 0000000..2ddfba2 --- /dev/null +++ b/kxmleditor/kxmleditorshell.rc @@ -0,0 +1,31 @@ + + + + + &File + + + + + + + + &Window + + + + + &Help + + + +Main Toolbar + + + + + + + + + diff --git a/kxmleditor/main.cpp b/kxmleditor/main.cpp new file mode 100644 index 0000000..23b1f8a --- /dev/null +++ b/kxmleditor/main.cpp @@ -0,0 +1,139 @@ +/*************************************************************************** + main.cpp - description + ------------------- + begin : � �c 10 12:39:26 CEST 2001 + copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team + email : lvanek@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include + +//#include "kxmleditor.h" +#include "../part/kxmleditorabout.h" +#include "kxmleditorshell.h" + + +static KCmdLineOptions options[] = +{ + { "+[File(s)]", I18N_NOOP("XML file(s) to open"), 0 }, + { 0, 0, 0 } +}; + +#define USE_KPART 1 + // if set to true makes kxmleditor to be kpart based (currently developement version only) + +/** @short Main application function that starts-up the application */ +int main(int argc, char *argv[]) +{ + KCmdLineArgs::init( argc, argv, new KXMLEditorAboutData() ); + KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. + + KApplication app; + + // comment the following lines to use KXMLEditorShell instead of KXMLEditorApp +#if ! USE_KPART + if (app.isRestored()) + { RESTORE(KXMLEditorApp); + } + else + { + KXMLEditorApp *kxmleditor = new KXMLEditorApp(); + kxmleditor->show(); + + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + + if(args->count()) + { QString strPath; + + if(args->count() > 1) + { strPath = args->arg(1); + } + KURL url(args->arg(0)); + if ( ! url.isValid() ) + { // probably user entered just filename + url.setProtocol("file"); + url.setPath(args->arg(0)); + } + kxmleditor->openDocumentFile(url, strPath); + } + else + { kxmleditor->openDocumentFile(); + } + args->clear(); + } +#else // USE_KPART + + if (app.isRestored()) + { + RESTORE(KXMLEditorShell); + } + else + { + KCmdLineArgs * pArgs = KCmdLineArgs::parsedArgs(); + KXMLEditorShell * pShell; + bool bNoCorrectInstance = true; + if ( pArgs->count() > 0 ) + { + for( int i = 0; i < pArgs->count(); i++ ) + { + KURL url(pArgs->arg(i)); + if ( ! url.isValid() ) + { + url.setProtocol("file"); + url.setPath(pArgs->arg(i)); + } + pShell = new KXMLEditorShell(); + if ( pShell->openURL(url) ) + { + pShell->show(); + bNoCorrectInstance = false; + } + else + { + kdDebug() << "Couldn't open file " << url.path() << endl; + KMessageBox::sorry(0, i18n("Couldn't open file !") + "\n" + url.path()); + delete pShell; + } + } + } + else + { + pShell = new KXMLEditorShell(); + KParts::ReadWritePart* pPart = KXMLEditorShell::createXMLPart(pShell); + pShell->setPart(pPart); + pShell->show(); + bNoCorrectInstance = false; + } + pArgs->clear(); + + if ( bNoCorrectInstance ) + return FALSE; + } + + // registration as multi-instance DCOP client + DCOPClient *client = app.dcopClient(); + client->attach(); + client->registerAs(kapp->name()); + + // uncomment end +#endif // USE_KPART + + int iRetVal = app.exec(); + return iRetVal; +} + diff --git a/part/Makefile.am b/part/Makefile.am new file mode 100644 index 0000000..3a1e59a --- /dev/null +++ b/part/Makefile.am @@ -0,0 +1,53 @@ +####### kdevelop will overwrite this part!!! (begin)########## + +lib_LTLIBRARIES = libkxmleditorpart.la + +libkxmleditorpart_la_SOURCES = kxesearchdialogbase.ui kxesearchdialog.cpp kxeprocinstrdialogbase.ui kxeprocinstrdialog.cpp kxespecprocinstrdialogbase.ui kxespecprocinstrdialog.cpp kxeelementdialogbase.ui kxeelementdialog.cpp kxeattributedialogbase.ui kxeattributedialog.cpp kxechardatadialogbase.ui kxechardatadialog.cpp kxeattachdialogbase.ui kxechoosestringdialogbase.ui kxechoosestringdialog.cpp kxefilenewdialog.cpp kxeconfiguration.cpp kxesettings.cpp kxetreeviewsettingspage.ui kxetreeviewsettings.cpp kxenewfilesettingspage.ui kxenewfilesettings.cpp kxeprintsettingspage.ui kxeprintsettings.cpp kxearchiveextssettingspage.ui kxearchiveextssettings.cpp kxetextviewsettingspage.ui kxetextviewsettings.cpp kxe_treeviewitem.cpp kxe_treeview.cpp kxe_viewelement.cpp kxe_viewattributes.cpp kxesyntaxhighlighter.cpp kxetexteditordialogbase.ui kxetexteditordialog.cpp actions.cpp qdom_add.cpp kxecommand.cpp commands_file.cpp commands_edit.cpp commands_insert.cpp kxmleditorpart.cpp kxmleditorfactory.cpp dcopiface_part_ro.skel dcopiface_part_ro.cpp kxedocument.cpp + +libkxmleditorpart_la_LDFLAGS = -module $(all_libraries) -version-info 1:0:0 +libkxmleditorpart_la_LIBADD = $(LIB_KDEPRINT) $(LIB_KPARTS) $(LIB_KFILE) $(LIB_KDEUI) $(LIB_KDECORE) $(LIB_QT) + +SUBDIRS = pics icons + +EXTRA_DIST = kxmleditorpartBrowseUI.rc kxmleditorpartEditUI.rc kxedocument.rc kxmleditorpart.desktop + + +install-data-local: + $(mkinstalldirs) $(kde_servicesdir) + $(INSTALL_DATA) $(srcdir)/kxmleditorpart.desktop $(kde_servicesdir)/kxmleditorpart.desktop + +uninstall-local: + -rm -f $(kde_servicesdir)/kxmleditorpart.desktop + -rmdir $(kde_servicesdir) + +####### kdevelop will overwrite this part!!! (end)############ +# this 10 paths are KDE specific. Use them: +# kde_htmldir Where your docs should go to. (contains lang subdirs) +# kde_appsdir Where your application file (.kdelnk) should go to. +# kde_icondir Where your icon should go to. +# kde_minidir Where your mini icon should go to. +# kde_datadir Where you install application data. (Use a subdir) +# kde_locale Where translation files should go to.(contains lang subdirs) +# kde_cgidir Where cgi-bin executables should go to. +# kde_confdir Where config files should go to. +# kde_mimedir Where mimetypes should go to. +# kde_toolbardir Where general toolbar icons should go to. +# kde_wallpaperdir Where general wallpapers should go to. + +# set the include path for X, qt and KDE +INCLUDES= $(all_includes) + +METASOURCES = AUTO + +rcdir = $(kde_datadir)/kxmleditor +rc_DATA = kxmleditorpartBrowseUI.rc kxmleditorpartEditUI.rc kxedocument.rc + +messages: rc.cpp + LIST=`find . -name \*.h -o -name \*.hh -o -name \*.H -o -name \*.hxx -o -name \*.hpp -o -name \*.cpp -o -name \*.cc -o -name \*.cxx -o -name \*.ecpp -o -name \*.C`; \ + if test -n "$$LIST"; then \ + if ! test -e $(podir)/kxmleditor.pot; then touch $(podir)/kxmleditor.pot; fi; \ + $(XGETTEXT) -j $$LIST -o $(podir)/kxmleditor.pot; \ + fi + + +noinst_HEADERS = kxesearchdialog.h kxeprocinstrdialog.h kxespecprocinstrdialog.h kxeelementdialog.h kxeattributedialog.h kxechardatadialog.h kxechoosestringdialog.h kxefilenewdialog.h kxeconfiguration.h kxesettings.h kxetreeviewsettings.h kxenewfilesettings.h kxeprintsettings.h kxearchiveextssettings.h kxetextviewsettings.h kxe_treeviewitem.h kxe_treeview.h kxe_viewelement.h kxe_viewattributes.h kxesyntaxhighlighter.h kxetexteditordialog.h actions.h qdom_add.h kxecommand.h commands_file.h commands_edit.h commands_insert.h kxmleditorabout.h kxmleditorpart.h kxmleditorfactory.h dcopiface_part_ro.h kxedocument.h diff --git a/part/actions.cpp b/part/actions.cpp new file mode 100644 index 0000000..8b6abcb --- /dev/null +++ b/part/actions.cpp @@ -0,0 +1,229 @@ +/*************************************************************************** + actions.cpp - description + ------------------- + begin : Tue Jul 10 2001 + copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team + email : lvanek@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "actions.h" + +// include files for QT + +#include +#include +#include +#include + +// include files for KDE +#include +#include +#include +#include + +//------------------------------------------------------------------- +// +// KXmlEditorComboAction member functions +// +//------------------------------------------------------------------- + +KXmlEditorComboAction::KXmlEditorComboAction(const QString& text, + int accel, + const QObject *receiver, + const char *member, + QObject* parent, + const char* name) + : KAction(text, accel, parent, name), + m_pCombo(0) +{ + m_receiver = receiver; + m_member = member; +} + +KXmlEditorComboAction::~KXmlEditorComboAction() +{ + //delete m_pCombo; // L.V. this cause crash !!! +} + +QComboBox* KXmlEditorComboAction::comboBox() +{ + return m_pCombo; +} + +int KXmlEditorComboAction::plug(QWidget *w, int index) +{ + // if ( !w->inherits( "KToolBar" ) ); + // return -1; + + KToolBar *toolBar = (KToolBar *) w; + + int id = KAction::getToolButtonID(); + //kdDebug() << "KXmlEditorComboAction::plug id=" << id << endl; + + m_pCombo = new QComboBox( toolBar, "Path Combo" ); + m_pCombo->setEditable(true); + m_pCombo->setInsertionPolicy(QComboBox::NoInsertion); + toolBar->insertWidget( id, 70, m_pCombo, index ); + connect( m_pCombo, SIGNAL(activated(const QString&)), m_receiver, m_member ); + + addContainer( toolBar, id ); + + connect(toolBar, SIGNAL(destroyed()), this, SLOT(slotDestroyed())); + + toolBar->setItemAutoSized(id, true); + + QWhatsThis::add( m_pCombo, whatsThis() ); + + return containerCount() - 1; +} + +void KXmlEditorComboAction::unplug(QWidget *w) +{ +// if ( !w->inherits( "KToolBar" ) ) +// return; + + KToolBar *toolBar = (KToolBar *)w; + + int idx = findContainer( w ); + //kdDebug() << "KXmlEditorComboAction::unplug idx=" << idx << " menuId=" << menuId(idx) << endl; + + toolBar->removeItem( menuId( idx ) ); + + removeContainer( idx ); + m_pCombo = 0; +} + +void KXmlEditorComboAction::slotClear() +{ + if ( containerCount() == 0 ) + { + kdWarning() << "[KXmlEditorComboAction::slotClear] action not plugged" << endl; + return; + } + + m_pCombo->clear(); +} + +void KXmlEditorComboAction::slotClearEdit() +{ + if ( containerCount() == 0 ) + { + kdWarning() << "[KXmlEditorComboAction::slotClearEdit] action not plugged" << endl; + return; + } + + m_pCombo->clearEdit(); +} + +void KXmlEditorComboAction::slotFocusEdit() +{ + if ( containerCount() == 0 ) + { + kdWarning() << "[KXmlEditorComboAction::slotFocusEdit] action not plugged" << endl; + return; + } + + m_pCombo->setFocus(); +} + +QString KXmlEditorComboAction::currentText() const +{ + if ( containerCount() == 0 ) + { + kdWarning() << "[KXmlEditorComboAction::currentText] action not plugged" << endl; + return QString::null; + } + + return m_pCombo->currentText(); +} + +const QPixmap * KXmlEditorComboAction::currentPixmap() const +{ + if ( containerCount() == 0 ) + { + kdWarning() << "[KXmlEditorComboAction::currentPixmap] action not plugged" << endl; + return 0; + } + + return m_pCombo->pixmap( m_pCombo->currentItem() ); +} + +void KXmlEditorComboAction::insertItem( const QPixmap & pixmap, const QString & text ) +{ + if ( containerCount() == 0 ) + { + kdWarning() << "[KXmlEditorComboAction::insertItem] action not plugged" << endl; + return; + } + + if ( text.isEmpty() ) + kdWarning() << "[KXmlEditorComboAction::insertItem] empty string as parameter" << endl; + + int nIndex = findItem(text); + if ( nIndex != -1 ) + m_pCombo->removeItem(nIndex); + + m_pCombo->insertItem( pixmap, text, 0 ); + m_pCombo->setCurrentItem(0); + + if ( m_pCombo->count() > 15 ) + m_pCombo->removeItem(15); +} + +void KXmlEditorComboAction::removeItem( const QString & text ) +{ + if ( containerCount() == 0 ) + { + kdWarning() << "[KXmlEditorComboAction::removeItem] action not plugged" << endl; + return; + } + + int nIndex = findItem(text); + if ( nIndex == -1 ) + { + kdDebug() << "KXmlEditorComboAction::removeItem] item not found" << endl; + return; + } + + m_pCombo->removeItem(nIndex); +} + +int KXmlEditorComboAction::findItem( const QString & text ) +{ + if ( containerCount() == 0 ) + { + kdWarning() << "[KXmlEditorComboAction::findItem] action not plugged" << endl; + return -1; + } + + int nIndex = -1; + int i=0; + while ( ( i < m_pCombo->count() ) && ( nIndex == -1 ) ) + { + if ( m_pCombo->text(i) == text ) + nIndex = i; + i++; + } + + return nIndex; +} + +ToolbarLabel::ToolbarLabel( const QString& text ) + : QLabel( text, 0L, "kde toolbar widget" ) // Use this name for it to be styled! +// , m_mw(mw) +{ + setBackgroundMode( Qt::PaletteButton ); + setAlignment( (QApplication::reverseLayout() ? Qt::AlignRight : Qt::AlignLeft) | + Qt::AlignVCenter | Qt::ShowPrefix ); + adjustSize(); + } + diff --git a/part/actions.h b/part/actions.h new file mode 100644 index 0000000..43d0967 --- /dev/null +++ b/part/actions.h @@ -0,0 +1,88 @@ +/*************************************************************************** + actions.h - description + ------------------- + begin : Tue Jul 10 2001 + copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team + email : lvanek@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef ACTIONS_H +#define ACTIONS_H + +#include +#include +class QComboBox; + +/** + *@author Lumir Vanek + */ + +class KXmlEditorComboAction : public KAction +{ + Q_OBJECT +public: + KXmlEditorComboAction(const QString& text, int accel, const QObject *receiver, const char *member, QObject* parent, const char* name); + ~KXmlEditorComboAction(); + + virtual int plug(QWidget *w, int index = -1); + + virtual void unplug(QWidget *w); + + /** Returns the text from the combobox' editline (@ref QComboBox::currentText). */ + QString currentText() const; + + /** Returns the current pixmap or 0, if there isn't any (see @ref QComboBox::pixmap). */ + const QPixmap * currentPixmap() const; + + /** + * Inserts the given item as the first. + * Deletes the old entry, if the item was already in the list. + */ + void insertItem( const QPixmap & pixmap, const QString & text ); + + /** Tries to remove the item with the given text. */ + void removeItem( const QString & text ); + + /** returns combo box */ + QComboBox *comboBox(); + +public slots: + /** Clears the whole combobox using @ref QComboBox::clear. */ + void slotClear(); + /** Clears the combobox' editline. */ + void slotClearEdit(); + /** Gives focus to the combobox' editline. */ + void slotFocusEdit(); + +protected: + /** + * Tries to find an item with the given text. If it finds it, + * the items id is returned, otherwise -1. + */ + virtual int findItem( const QString & text ); + +private: + const QObject *m_receiver; + const char *m_member; + QComboBox * m_pCombo; +}; + + +class ToolbarLabel : public QLabel +{ + Q_OBJECT +public: + ToolbarLabel( const QString & text ); +}; + + +#endif diff --git a/part/commands_edit.cpp b/part/commands_edit.cpp new file mode 100644 index 0000000..ba298b0 --- /dev/null +++ b/part/commands_edit.cpp @@ -0,0 +1,778 @@ +/*************************************************************************** + commands_edit - description + ------------------- + begin : Wed Nov 26 2003 + copyright : (C) 2003 by The KXMLEditor Team + email : a_charytoniuk@user.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#include "commands_edit.h" + +#include + +////////////////////////////////////////////////////////////////////////////////////////// +/////////// Cutting element to clipboard ////////// +////////////////////////////////////////////////////////////////////////////////////////// + +KXECutCommand::KXECutCommand(KXEDocument *pDocument, QDomNode &domNode) + : KXEDeleteNodeCommand(pDocument, domNode) +{ +} + +KXECutCommand::~KXECutCommand() +{ +} + +////////////////////////////////////////////////////////////////////////////////////////// +/////////// Pasting node from clipboard to document ////////// +////////////////////////////////////////////////////////////////////////////////////////// + +KXEPasteToDocumentCommand::KXEPasteToDocumentCommand( + KXEDocument *pDocument, + QDomDocument *pDomTargetDoc, + QDomElement &domSourceElement + ) + : KXECommand(pDocument) +{ + if ( pDomTargetDoc == 0 ) + kdError() << "KXEPasteToDocumentCommand::KXEPasteToDocumentCommand the given XML document object is empty." << endl; + + m_pDomTargetDoc = pDomTargetDoc; + m_domSourceElement = domSourceElement; +} + +KXEPasteToDocumentCommand::~KXEPasteToDocumentCommand() +{ +} + +void KXEPasteToDocumentCommand::execute() +{ + // Insert root element + QDomNode newNode = m_pDomTargetDoc->importNode(m_domSourceElement, true); + m_pDomTargetDoc->appendChild(newNode); + m_pDocument->updateNodeCreated(newNode); +} + +void KXEPasteToDocumentCommand::unexecute() +{ + QDomNode removedNode = m_pDomTargetDoc->removeChild( m_pDomTargetDoc->documentElement()); + + if ( removedNode.isNull() ) + kdError() << "KXEPasteToDocumentCommand::unexecute error removing node." << endl; + else + { + m_pDocument->updateNodeDeleted(removedNode); + } +} + +////////////////////////////////////////////////////////////////////////////////////////// +/////////// Pasting node from clipboard to element ////////// +////////////////////////////////////////////////////////////////////////////////////////// + +KXEPasteToElementCommand::KXEPasteToElementCommand( + KXEDocument *pDocument, + QDomElement & domTargetElement, + QDomNode &domSourceNode + ) + : KXECommand(pDocument) +{ + if ( domTargetElement.isNull() ) + kdError() << "KXEPasteCommand::KXEPasteCommand the given XML element object is empty." << endl; + + m_domTargetElement = domTargetElement; + m_domSourceNode = domSourceNode; +} + +KXEPasteToElementCommand::~KXEPasteToElementCommand() +{ +} + +void KXEPasteToElementCommand::execute() +{ + m_domTargetElement.appendChild(m_domSourceNode); + m_pDocument->updateNodeCreated(m_domSourceNode); +} + +void KXEPasteToElementCommand::unexecute() +{ + if ( m_domSourceNode.parentNode().removeChild( m_domSourceNode ).isNull() ) + kdError() << "KXEPasteToElementCommand::unexecute error removing the node." << endl; + else + { + m_pDocument->updateNodeDeleted(m_domSourceNode); + } +} + +////////////////////////////////////////////////////////////////////////////////////////// +/////////// Pasting proc.instr from clipboard to proc.instr ////////// +////////////////////////////////////////////////////////////////////////////////////////// + +KXEPasteToProcInstrCommand::KXEPasteToProcInstrCommand( + KXEDocument *pDocument, + QDomProcessingInstruction &domTargetProcInstr, + QDomProcessingInstruction &domSourceProcInstr + ) + : KXECommand(pDocument) +{ + if ( domTargetProcInstr.isNull() ) + kdError() << "KXEPasteToProcInstrCommand::KXEPasteToProcInstrCommand the given object is empty." << endl; + + if ( domSourceProcInstr.isNull() ) + kdError() << "KXEPasteToProcInstrCommand::KXEPasteToProcInstrCommand the given object is empty." << endl; + + m_domTargetProcInstr = domTargetProcInstr; + m_strNewData = domSourceProcInstr.data(); +} + +KXEPasteToProcInstrCommand::~KXEPasteToProcInstrCommand() +{ +} + +void KXEPasteToProcInstrCommand::execute() +{ + // Replace contents of selected proc. instr. + m_strOldData = m_domTargetProcInstr.data(); + m_domTargetProcInstr.setData(m_strNewData); + m_pDocument->updateNodeChanged(m_domTargetProcInstr); +} + +void KXEPasteToProcInstrCommand::unexecute() +{ + // Rverse action. + m_domTargetProcInstr.setData(m_strOldData); + m_pDocument->updateNodeChanged(m_domTargetProcInstr); +} + +////////////////////////////////////////////////////////////////////////////////////////// +/////////// Pasting char. data from clipboard to char. data ////////// +////////////////////////////////////////////////////////////////////////////////////////// + + +KXEPasteToCharDataCommand::KXEPasteToCharDataCommand( + KXEDocument *pDocument, + QDomCharacterData &domTargetCharData, + QDomCharacterData &domSourceCharData + ) + : KXECommand(pDocument) +{ + if ( domTargetCharData.isNull() ) + kdError() << "KXEPasteToCharDataCommand::KXEPasteToCharDataCommand the given object is empty." << endl; + + if ( domSourceCharData.isNull() ) + kdError() << "KXEPasteToCharDataCommand::KXEPasteToCharDataCommand the given object is empty." << endl; + + m_domTargetCharData = domTargetCharData; + m_strNewData = domSourceCharData.data(); +} + +KXEPasteToCharDataCommand::~KXEPasteToCharDataCommand() +{ +} + +void KXEPasteToCharDataCommand::execute() +{ + // replace target contents with source + m_strOldData = m_domTargetCharData.data(); + m_domTargetCharData.setData(m_strNewData); + m_pDocument->updateNodeChanged(m_domTargetCharData); +} + +void KXEPasteToCharDataCommand::unexecute() +{ + m_domTargetCharData.setData(m_strOldData); + m_pDocument->updateNodeChanged(m_domTargetCharData); +} + +////////////////////////////////////////////////////////////////////////////////////////// +/////////// Drag & drop node ////////// +////////////////////////////////////////////////////////////////////////////////////////// + +KXEDragDropMoveCommand::KXEDragDropMoveCommand( + KXEDocument *pDocument, + QDomElement & domTargetElement, + QDomNode &domSourceNode + ) + : KXECommand(pDocument) +{ + if ( domTargetElement.isNull() ) + kdError() << "KXEDragDropMoveCommand::KXEDragDropMoveCommand the given XML element object is empty." << endl; + + m_domTargetElement = domTargetElement; + m_domSourceNode = domSourceNode; + m_domPreviousParentNode = m_domSourceNode.parentNode(); +} + +KXEDragDropMoveCommand::~KXEDragDropMoveCommand() +{ +} + +void KXEDragDropMoveCommand::execute() +{ + // 1st, remove source node from its parent + if( m_domPreviousParentNode.removeChild( m_domSourceNode ).isNull() ) + kdError() << "KXEDocument::slotXmlElementDelete error removing the selected node." << endl; + else + m_pDocument->updateNodeDeleted(m_domSourceNode); + + // 2nd, append moved node to new parent + m_domTargetElement.appendChild(m_domSourceNode); + m_pDocument->updateNodeCreated(m_domSourceNode); +} + +void KXEDragDropMoveCommand::unexecute() +{ + // 1st, remove source node from its parent + if ( m_domTargetElement.removeChild( m_domSourceNode ).isNull() ) + kdError() << "KXEPasteToElementCommand::unexecute error removing the node." << endl; + else + { + m_pDocument->updateNodeDeleted(m_domSourceNode); + } + + // 2nd, append moved node to previous parent + m_domPreviousParentNode.appendChild(m_domSourceNode); + m_pDocument->updateNodeCreated(m_domSourceNode); +} + + +////////////////////////////////////////////////////////////////////////////////////////// +/////////// Deleting node ////////// +////////////////////////////////////////////////////////////////////////////////////////// + +KXEDeleteNodeCommand::KXEDeleteNodeCommand(KXEDocument *pDocument, QDomNode &domNode) + : KXECommand(pDocument) +{ + m_domNode = domNode; + m_domParentNode = m_domNode.parentNode(); + m_afterNode = m_domNode.previousSibling(); + + if ( m_domParentNode.isNull() ) + kdError() << "KXEDeleteNodeCommand::KXEDeleteNodeCommand selected nodes parent node is empty." << endl; +} + +KXEDeleteNodeCommand::~KXEDeleteNodeCommand() +{ +} + +void KXEDeleteNodeCommand::execute() +{ + if ( m_domParentNode.removeChild( m_domNode ).isNull() ) + kdError() << "KXEDeleteNodeCommand::execute error removing the selected node." << endl; + else + { + m_pDocument->updateNodeDeleted(m_domNode); + } +} + +void KXEDeleteNodeCommand::unexecute() +{ + if (m_afterNode.isNull()) + m_domParentNode.insertBefore(m_domNode,m_afterNode); + else + m_domParentNode.insertAfter( m_domNode,m_afterNode ); + m_pDocument->updateNodeCreated(m_domNode); +} + +////////////////////////////////////////////////////////////////////////////////////////// +/////////// Deleting one attribute ////////// +////////////////////////////////////////////////////////////////////////////////////////// + + +KXEDeleteAttrCommand::KXEDeleteAttrCommand( + KXEDocument *pDocument, + QDomElement &domOwnerElement, + QDomAttr &domAttr + ) + : KXECommand(pDocument) +{ + m_domOwnerElement = domOwnerElement; + m_domAttr = domAttr; +} + +KXEDeleteAttrCommand::~KXEDeleteAttrCommand() +{ +} + +void KXEDeleteAttrCommand::execute() +{ + m_domOwnerElement.removeAttributeNode(m_domAttr); + m_pDocument->updateNodeChanged(m_domOwnerElement); +} + +void KXEDeleteAttrCommand::unexecute() +{ + m_domOwnerElement.setAttributeNode( m_domAttr ); + m_pDocument->updateNodeChanged( m_domOwnerElement ) ; +} + +////////////////////////////////////////////////////////////////////////////////////////// +/////////// Deleting all attributes ////////// +////////////////////////////////////////////////////////////////////////////////////////// + +KXEDeleteAllAttribCommand::KXEDeleteAllAttribCommand( + KXEDocument *pDocument, + QDomElement &domOwnerElement + ) + : KXECommand(pDocument) +{ + m_domOwnerElement = domOwnerElement; + m_listRemovedAttributes.setAutoDelete( true ); // the list owns the objects +} + +KXEDeleteAllAttribCommand::~KXEDeleteAllAttribCommand() +{ +} + +void KXEDeleteAllAttribCommand::execute() +{ + QDomNamedNodeMap mapAttributes = m_domOwnerElement.attributes(); + uint nAttributes = mapAttributes.count(); + + if( nAttributes == 0 ) + return; + + for( uint nRow = nAttributes; nRow > 0; nRow-- ) + { + QDomNode node = mapAttributes.item(nRow-1); + if ( node.isAttr() ) + { QDomAttr domAttr = node.toAttr(); + + QDomAttr *pNodeCloned = new QDomAttr(domAttr.cloneNode(true).toAttr()); + + m_listRemovedAttributes.append(pNodeCloned); + m_domOwnerElement.removeAttributeNode(node.toAttr()); + } + else + kdDebug() << "KXMLEditor " << k_funcinfo << " node is not an attribute (but should be)" << node.nodeName() << endl; + } + + m_pDocument->updateNodeChanged(m_domOwnerElement); +} + +void KXEDeleteAllAttribCommand::unexecute() +{ + QDomNamedNodeMap mapAttributes = m_domOwnerElement.attributes(); + uint nAttributes = m_listRemovedAttributes.count(); + + if ( nAttributes == 0 ) + return; + + QDomAttr *pDomAttr; + for ( pDomAttr = m_listRemovedAttributes.first(); pDomAttr; pDomAttr = m_listRemovedAttributes.next() ) + { + if(!pDomAttr->namespaceURI().isEmpty()) + m_domOwnerElement.setAttribute(pDomAttr->name(), pDomAttr->value()); + else + m_domOwnerElement.setAttributeNS(pDomAttr->namespaceURI(), pDomAttr->name(), pDomAttr->value()); + } + + m_listRemovedAttributes.clear(); + + m_pDocument->updateNodeChanged(m_domOwnerElement); +} + +////////////////////////////////////////////////////////////////////////////////////////// +/////////// Moving node up ////////// +////////////////////////////////////////////////////////////////////////////////////////// + +KXEUpCommand::KXEUpCommand(KXEDocument *pDocument, QDomNode &domNode) + : KXECommand(pDocument) +{ + m_domNode = domNode; + m_domParentNode = m_domNode.parentNode(); + + if ( m_domParentNode.isNull() ) + kdError() << "KXEUpCommand::KXEUpCommand selected nodes parent node is empty." << endl; +} + +KXEUpCommand::~KXEUpCommand() +{ +} + +void KXEUpCommand::execute() +{ + QDomNode domPrevSibling = m_domNode.previousSibling(); + if ( domPrevSibling.isNull() ) + { + kdError() << "KXEUpCommand::execute selected node doesn't seem to have a previous sibling." << endl; + return; + } + + QDomNode domNode = m_domParentNode.removeChild( m_domNode ); + if ( domNode.isNull() ) + kdError() << "KXEUpCommand::execute can't remove child node." << endl; + else + { + domNode = m_domParentNode.insertBefore( domNode, domPrevSibling ); + if ( domNode.isNull() ) + kdError() << "KXEUpCommand::execute can't insert child node." << endl; + else + { + m_pDocument->updateNodeMoved(domNode); + } + } +} + +void KXEUpCommand::unexecute() +{ + QDomNode domNextSibling = m_domNode.nextSibling(); + if ( domNextSibling.isNull() ) + { + kdError() << "KXEUpCommand::unexecute selected node doesn't seem to have a next sibling." << endl; + return; + } + + QDomNode domNode = m_domParentNode.removeChild( m_domNode ); + if ( domNode.isNull() ) + kdError() << "KXEUpCommand::unexecute can't remove child node." << endl; + else + { + domNode = m_domParentNode.insertAfter( domNode, domNextSibling ); + if ( domNode.isNull() ) + kdError() << "KXEUpCommand::unexecute can't insert child node." << endl; + else + { + m_pDocument->updateNodeMoved(domNode); + } + } +} + +////////////////////////////////////////////////////////////////////////////////////////// +/////////// Moving node down ////////// +////////////////////////////////////////////////////////////////////////////////////////// + +KXEDownCommand::KXEDownCommand(KXEDocument *pDocument, QDomNode &domNode) + : KXECommand(pDocument) +{ + m_domNode = domNode; + m_domParentNode = m_domNode.parentNode(); + + if ( m_domParentNode.isNull() ) + kdError() << "KXEDownCommand::KXEDownCommand selected nodes parent node is empty." << endl; +} + +KXEDownCommand::~KXEDownCommand() +{ +} + +void KXEDownCommand::execute() +{ + QDomNode domNextSibling = m_domNode.nextSibling(); + if ( domNextSibling.isNull() ) + { + kdError() << "KXEDownCommand::execute selected node doesn't seem to have a next sibling." << endl; + return; + } + + QDomNode domNode = m_domParentNode.removeChild( m_domNode ); + if ( domNode.isNull() ) + kdError() << "KXEDownCommand::execute can't remove child node." << endl; + else + { + domNode = m_domParentNode.insertAfter( domNode, domNextSibling ); + if ( domNode.isNull() ) + kdError() << "KXEDownCommand::execute can't insert child node." << endl; + else + { + m_pDocument->updateNodeMoved(domNode); + } + } +} + +void KXEDownCommand::unexecute() +{ + QDomNode domPrevSibling = m_domNode.previousSibling(); + if ( domPrevSibling.isNull() ) + { + kdError() << "KXEDownCommand::unexecute selected node doesn't seem to have a previous sibling." << endl; + return; + } + + QDomNode domNode = m_domParentNode.removeChild( m_domNode ); + if ( domNode.isNull() ) + kdError() << "KXEDownCommand::unexecute can't remove child node." << endl; + else + { + domNode = m_domParentNode.insertBefore( domNode, domPrevSibling ); + if ( domNode.isNull() ) + kdError() << "KXEDownCommand::unexecute can't insert child node." << endl; + else + { + m_pDocument->updateNodeMoved(domNode); + } + } +} + +////////////////////////////////////////////////////////////////////////////////////////// +/////////// Editing char. data properties ////////// +////////////////////////////////////////////////////////////////////////////////////////// + +KXEEditCharDataCommand::KXEEditCharDataCommand( + KXEDocument *pDocument, + QDomCharacterData &domCharacterData, + const QString strNewContents + ) + : KXECommand(pDocument) +{ + m_domCharacterData = domCharacterData; + m_strNewContents = strNewContents; +} + +KXEEditCharDataCommand::~KXEEditCharDataCommand() +{ +} + +void KXEEditCharDataCommand::execute() +{ + m_strOldContents = m_domCharacterData.data(); + m_domCharacterData.setData( m_strNewContents ); + m_pDocument->updateNodeChanged( m_domCharacterData ); +} + +void KXEEditCharDataCommand::unexecute() +{ + m_domCharacterData.setData( m_strOldContents ); + m_pDocument->updateNodeChanged( m_domCharacterData ); +} + +////////////////////////////////////////////////////////////////////////////////////////// +/////////// Editing proc. instr properties ////////// +////////////////////////////////////////////////////////////////////////////////////////// + +KXEEditProcInstrCommand::KXEEditProcInstrCommand( + KXEDocument *pDocument, + QDomProcessingInstruction &domProcInstr, + const QString strNewData + ) + : KXECommand(pDocument) +{ + m_domProcInstr = domProcInstr; + m_strNewData = strNewData; +} + +KXEEditProcInstrCommand::~KXEEditProcInstrCommand() +{ +} + +void KXEEditProcInstrCommand::execute() +{ + m_strOldData = m_domProcInstr.data(); + m_domProcInstr.setData( m_strNewData ); + m_pDocument->updateNodeChanged( m_domProcInstr ); +} + +void KXEEditProcInstrCommand::unexecute() +{ + m_domProcInstr.setData( m_strOldData ); + m_pDocument->updateNodeChanged( m_domProcInstr ); +} + +////////////////////////////////////////////////////////////////////////////////////////// +/////////// Editing element data properties ////////// +////////////////////////////////////////////////////////////////////////////////////////// + +KXEEditElementCommand::KXEEditElementCommand( + KXEDocument *pDocument, + QDomElement &domElement, + const QString strNewPrefix, + const QString strNewName + ) + : KXECommand(pDocument) +{ + m_domElement = domElement; + m_strNewPrefix = strNewPrefix; + m_strNewName = strNewName; +} + +KXEEditElementCommand::~KXEEditElementCommand() +{ +} + +void KXEEditElementCommand::execute() +{ + m_strOldPrefix = m_domElement.prefix(); + m_strOldName = m_domElement.tagName(); + + + if ( ! m_domElement.namespaceURI().isNull() ) + m_domElement.setPrefix( m_strNewPrefix ); + + m_domElement.setTagName( m_strNewName ); + + m_pDocument->updateNodeChanged( m_domElement ); +} + +void KXEEditElementCommand::unexecute() +{ + if ( ! m_domElement.namespaceURI().isNull() ) + m_domElement.setPrefix( m_strOldPrefix ); + + m_domElement.setTagName( m_strOldName ); + + m_pDocument->updateNodeChanged( m_domElement ); +} + +////////////////////////////////////////////////////////////////////////////////////////// +/////////// Edit attribute value ////////// +////////////////////////////////////////////////////////////////////////////////////////// + + +KXEEditAttrValueCommand::KXEEditAttrValueCommand( + KXEDocument *pDocument, + const QDomAttr &domAttr, + const QString strNewValue + ) + : KXECommand(pDocument) +{ + m_domAttr = domAttr; + m_strNewValue = strNewValue; +} + +KXEEditAttrValueCommand::~KXEEditAttrValueCommand() +{ +} + +void KXEEditAttrValueCommand::execute() +{ + m_strOldValue = m_domAttr.value(); + m_domAttr.setValue( m_strNewValue ); + + m_pDocument->updateNodeChanged(m_domAttr.ownerElement()); +} + +void KXEEditAttrValueCommand::unexecute() +{ + m_domAttr.setValue( m_strOldValue ); + + m_pDocument->updateNodeChanged(m_domAttr.ownerElement()); +} + +////////////////////////////////////////////////////////////////////////////////////////// +/////////// Edit attribute name ////////// +////////////////////////////////////////////////////////////////////////////////////////// + + +KXEEditAttrNameCommand::KXEEditAttrNameCommand( + KXEDocument *pDocument, + const QDomAttr &domOldAttr, + const QString strNewName + ) + : KXECommand(pDocument) +{ + m_strNewName = strNewName; + m_strOldName = domOldAttr.name(); + m_strValue = domOldAttr.value(); + + if(!domOldAttr.namespaceURI().isEmpty()) + m_strNamespaceURI = domOldAttr.namespaceURI(); + + m_domOwnerElement = domOldAttr.ownerElement(); +} + +KXEEditAttrNameCommand::~KXEEditAttrNameCommand() +{ +} + +void KXEEditAttrNameCommand::execute() +{ + // it's not possible to change name. Must delete attribute and create new one + if(m_strNamespaceURI.isEmpty()) + { + m_domOwnerElement.setAttribute(m_strNewName, m_strValue); + m_domOwnerElement.attributes().removeNamedItem(m_strOldName); + } + else + { + m_domOwnerElement.setAttributeNS( m_strNamespaceURI, m_strNewName, m_strValue); + m_domOwnerElement.attributes().removeNamedItemNS (m_strNamespaceURI, m_strOldName); + } + + m_pDocument->updateNodeChanged(m_domOwnerElement); +} + +void KXEEditAttrNameCommand::unexecute() +{ + // it's not possible to change name. Must delete attribute and create new one + if(m_strNamespaceURI.isEmpty()) + { + m_domOwnerElement.setAttribute(m_strOldName, m_strValue); + m_domOwnerElement.attributes().removeNamedItem(m_strNewName); + + } + else + { + m_domOwnerElement.setAttributeNS( m_strNamespaceURI, m_strOldName, m_strValue); + m_domOwnerElement.attributes().removeNamedItemNS (m_strNamespaceURI, m_strNewName); + } + + m_pDocument->updateNodeChanged(m_domOwnerElement); +} + +////////////////////////////////////////////////////////////////////////////////////////// +/////////// Editing element and its subtree as raw XML ////////// +////////////////////////////////////////////////////////////////////////////////////////// + +KXEEditRawXmlCommand::KXEEditRawXmlCommand( + KXEDocument *pDocument, + QDomElement &domOldElement, + QDomElement &domNewElement + ) + : KXECommand(pDocument) +{ + m_domOldElement = domOldElement; + m_domNewElement = domNewElement; + m_domParentNode = domOldElement.parentNode(); + m_afterNode = domOldElement.previousSibling(); + + if ( m_domParentNode.isNull() ) + kdError() << "KXEEditRawXmlCommand::KXEEditRawXmlCommand selected nodes parent node is empty." << endl; + +} + +KXEEditRawXmlCommand::~KXEEditRawXmlCommand() +{ +} + +void KXEEditRawXmlCommand::execute() +{ + // first delete node + if ( m_domParentNode.removeChild( m_domOldElement ).isNull() ) + kdError() << "KXEEditRawXmlCommand::execute error removing the selected node." << endl; + else + { + m_pDocument->updateNodeDeleted(m_domOldElement); + } + + // then insert new node + if (m_afterNode.isNull()) + m_domParentNode.insertBefore(m_domNewElement, m_afterNode); + else + m_domParentNode.insertAfter( m_domNewElement, m_afterNode ); + m_pDocument->updateNodeCreated(m_domNewElement); +} + +void KXEEditRawXmlCommand::unexecute() +{ + // first delete node + if ( m_domParentNode.removeChild( m_domNewElement ).isNull() ) + kdError() << "KXEEditRawXmlCommand::unexecute error removing the selected node." << endl; + else + { + m_pDocument->updateNodeDeleted(m_domNewElement); + } + + // then insert new node + if (m_afterNode.isNull()) + m_domParentNode.insertBefore(m_domOldElement, m_afterNode); + else + m_domParentNode.insertAfter( m_domOldElement, m_afterNode ); + m_pDocument->updateNodeCreated(m_domOldElement); +} diff --git a/part/commands_edit.h b/part/commands_edit.h new file mode 100644 index 0000000..c713861 --- /dev/null +++ b/part/commands_edit.h @@ -0,0 +1,346 @@ +/*************************************************************************** + commands_edit - description + ------------------- + begin : Wed Nov 26 2003 + copyright : (C) 2003 by The KXMLEditor Team + email : a_charytoniuk@user.sourceforge.net + ***************************************************************************/ + + /*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#ifndef COMMANDS_EDIT_H +#define COMMANDS_EDIT_H + +#include "kxecommand.h" + +#include + +#include + +/** +@file +@author The KXMLEditor Team +*/ + +/** + @brief Command for removing any kind of nodes. +*/ +class KXEDeleteNodeCommand : public KXECommand +{ + public: + /** @brief Constructor */ + KXEDeleteNodeCommand(KXEDocument*, QDomNode &); + /** @brief Destructor */ + ~KXEDeleteNodeCommand(); + /** @brief Performs node removal.*/ + virtual void execute(); + /** @brief Node removal rollback.*/ + virtual void unexecute(); + virtual QString name() const { return i18n("Delete node"); } + protected: + /** @short Stores infromation about parent node of the node to be deleted. */ + QDomNode m_domParentNode; + /** @short Stores infromation the node to be deleted. */ + QDomNode m_domNode; + /** @short Stores infromation about sibling node of the node to be deleted. */ + QDomNode m_afterNode; +}; +/** + @short Command for removing element attributes. +*/ +class KXEDeleteAttrCommand : public KXECommand +{ + public: + /** @brief Constructor */ + KXEDeleteAttrCommand(KXEDocument*, QDomElement &, QDomAttr &); + /** @brief Destructor */ + ~KXEDeleteAttrCommand(); + /** @brief Preforms attributte removal. */ + virtual void execute(); + /** @brief Attributte removal rollback. */ + virtual void unexecute(); + virtual QString name() const { return i18n("Delete attribute"); } + protected: + /** @brief Stores attribute owner. */ + QDomElement m_domOwnerElement; + /** @brief Attribute about to be removed. */ + QDomAttr m_domAttr; +}; + +/** + @short Command for removing all element attributes. +*/ +class KXEDeleteAllAttribCommand : public KXECommand +{ + public: + /** @brief Constructor */ + KXEDeleteAllAttribCommand(KXEDocument*, QDomElement &); + /** @brief Destructor */ + ~KXEDeleteAllAttribCommand(); + virtual void execute(); + virtual void unexecute(); + virtual QString name() const { return i18n("Delete all attributes"); } + protected: + QDomElement m_domOwnerElement; + QPtrList m_listRemovedAttributes; +}; + +/** + @short Command for cutting element to clipboard. +*/ +class KXECutCommand : public KXEDeleteNodeCommand +{ + public: + /** @brief Constructor */ + KXECutCommand(KXEDocument*, QDomNode &); + /** @brief Destructor */ + ~KXECutCommand(); + virtual QString name() const { return i18n("Cut node"); } +}; + +/** + @short Command for pasting to document from clipboard. +*/ +class KXEPasteToDocumentCommand : public KXECommand +{ + public: + /** @brief Constructor */ + KXEPasteToDocumentCommand(KXEDocument*, QDomDocument *, QDomElement &); + /** @brief Destructor */ + ~KXEPasteToDocumentCommand(); + virtual void execute(); + virtual void unexecute(); + virtual QString name() const { return i18n("Paste node to document"); } + protected: + QDomDocument * m_pDomTargetDoc; + QDomElement m_domSourceElement; +}; + +/** + @short Command for pasting element from clipboard. +*/ +class KXEPasteToElementCommand : public KXECommand +{ + public: + /** @brief Constructor */ + KXEPasteToElementCommand(KXEDocument*, QDomElement &, QDomNode &); + /** @brief Destructor */ + ~KXEPasteToElementCommand(); + virtual void execute(); + virtual void unexecute(); + virtual QString name() const { return i18n("Paste node to element"); } + protected: + QDomElement m_domTargetElement; + QDomNode m_domSourceNode; +}; + +class KXEPasteToProcInstrCommand : public KXECommand +{ + public: + /** @brief Constructor */ + KXEPasteToProcInstrCommand(KXEDocument*, QDomProcessingInstruction &, QDomProcessingInstruction &); + /** @brief Destructor */ + ~KXEPasteToProcInstrCommand(); + virtual void execute(); + virtual void unexecute(); + virtual QString name() const { return i18n("Paste node to proc. instruction"); } + protected: + QDomProcessingInstruction m_domTargetProcInstr; + QString m_strNewData; + QString m_strOldData; +}; + +class KXEPasteToCharDataCommand : public KXECommand +{ + public: + /** @brief Constructor */ + KXEPasteToCharDataCommand(KXEDocument*, QDomCharacterData &, QDomCharacterData &); + /** @brief Destructor */ + ~KXEPasteToCharDataCommand(); + virtual void execute(); + virtual void unexecute(); + virtual QString name() const { return i18n("Paste node to char. data"); } + protected: + QDomCharacterData m_domTargetCharData; + QString m_strNewData; + QString m_strOldData; +}; + +/** + @short Command for Drag & Drop. +*/ +class KXEDragDropMoveCommand : public KXECommand +{ + public: + /** @brief Constructor */ + KXEDragDropMoveCommand(KXEDocument*, QDomElement &, QDomNode &); + /** @brief Destructor */ + ~KXEDragDropMoveCommand(); + virtual void execute(); + virtual void unexecute(); + virtual QString name() const { return i18n("Drag&&drop node"); } + protected: + QDomElement m_domTargetElement; + QDomNode m_domSourceNode; + QDomNode m_domPreviousParentNode; +}; + +/** + @short Command for moving selected node up. +*/ +class KXEUpCommand : public KXECommand +{ + public: + /** @brief Constructor */ + KXEUpCommand(KXEDocument*, QDomNode &); + /** @brief Destructor */ + ~KXEUpCommand(); + virtual void execute(); + virtual void unexecute(); + virtual QString name() const { return i18n("Move node up"); } + protected: + QDomNode m_domParentNode; + QDomNode m_domNode; +}; + +/** + @short Command for moving selected node down. +*/ +class KXEDownCommand : public KXECommand +{ + public: + /** @brief Constructor */ + KXEDownCommand(KXEDocument*, QDomNode &); + /** @brief Destructor */ + ~KXEDownCommand(); + virtual void execute(); + virtual void unexecute(); + virtual QString name() const { return i18n("Move node down"); } + protected: + QDomNode m_domParentNode; + QDomNode m_domNode; +}; + +class KXEEditCharDataCommand : public KXECommand +{ + public: + /** @brief Constructor */ + KXEEditCharDataCommand(KXEDocument*, QDomCharacterData &, const QString); + /** @brief Destructor */ + ~KXEEditCharDataCommand(); + virtual void execute(); + virtual void unexecute(); + virtual QString name() const { return i18n("Editing character data"); } + protected: + QDomCharacterData m_domCharacterData; + QString m_strNewContents; + QString m_strOldContents; +}; + +/** + @short Command for editing selected processing instruction. +*/ +class KXEEditProcInstrCommand : public KXECommand +{ + public: + /** @brief Constructor */ + KXEEditProcInstrCommand(KXEDocument*, QDomProcessingInstruction &, const QString); + /** @brief Destructor */ + ~KXEEditProcInstrCommand(); + virtual void execute(); + virtual void unexecute(); + virtual QString name() const { return i18n("Editing proc. instruction"); } + protected: + QDomProcessingInstruction m_domProcInstr; + QString m_strNewData; + QString m_strOldData; +}; + +/** + @short Command for editing selected XML element. +*/ +class KXEEditElementCommand : public KXECommand +{ + public: + /** @brief Constructor */ + KXEEditElementCommand(KXEDocument*, QDomElement &, const QString, const QString); + /** @brief Destructor */ + ~KXEEditElementCommand(); + virtual void execute(); + virtual void unexecute(); + virtual QString name() const { return i18n("Editing element"); } + protected: + QDomElement m_domElement; + QString m_strNewPrefix; + QString m_strNewName; + QString m_strOldPrefix; + QString m_strOldName; +}; + +/** + @short Command for editing element attribute value. +*/ +class KXEEditAttrValueCommand : public KXECommand +{ + public: + /** @brief Constructor */ + KXEEditAttrValueCommand(KXEDocument*, const QDomAttr &, const QString); + /** @brief Destructor */ + ~KXEEditAttrValueCommand(); + virtual void execute(); + virtual void unexecute(); + virtual QString name() const { return i18n("Edit attribute value"); } + protected: + QDomAttr m_domAttr; + QString m_strNewValue; + QString m_strOldValue; +}; + +/** + @short Command for editing element attribute names. +*/ +class KXEEditAttrNameCommand : public KXECommand +{ + public: + /** @brief Constructor */ + KXEEditAttrNameCommand(KXEDocument*, const QDomAttr &, const QString); + /** @brief Destructor */ + ~KXEEditAttrNameCommand(); + virtual void execute(); + virtual void unexecute(); + virtual QString name() const { return i18n("Edit attribute name"); } + protected: + QDomElement m_domOwnerElement; + QString m_strNewName; + QString m_strOldName; + QString m_strValue; + QString m_strNamespaceURI; +}; + +/** + @short Command for editing XML element as text. +*/ +class KXEEditRawXmlCommand : public KXECommand +{ + public: + /** @brief Constructor */ + KXEEditRawXmlCommand(KXEDocument*, QDomElement &, QDomElement &); + /** @brief Destructor */ + ~KXEEditRawXmlCommand(); + virtual void execute(); + virtual void unexecute(); + virtual QString name() const { return i18n("Editing raw XML"); } + protected: + QDomElement m_domOldElement; + QDomNode m_domParentNode; + QDomElement m_domNewElement; + QDomNode m_afterNode; +}; + +#endif diff --git a/part/commands_file.cpp b/part/commands_file.cpp new file mode 100644 index 0000000..f30ff2d --- /dev/null +++ b/part/commands_file.cpp @@ -0,0 +1,158 @@ +/*************************************************************************** + commands_file - description + ------------------- + begin : Wed Nov 26 2003 + copyright : (C) 2003 by The KXMLEditor Team + email : a_charytoniuk@user.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#include "commands_file.h" +#include +#include +#include +////////////////////////////////////////////////////////////////////////////////////////// +/////////// Setting Version & Encoding ////////// +////////////////////////////////////////////////////////////////////////////////////////// + +KXEVersionEncodingCommand::KXEVersionEncodingCommand(KXEDocument* pDocument, const QString& oldData, const QString &newData) + : KXECommand(pDocument) +{ + m_strOldData = oldData; + m_strNewData = newData; +} + +KXEVersionEncodingCommand::~KXEVersionEncodingCommand() +{ +} + +void KXEVersionEncodingCommand::execute() +{ + m_pDocument->setSpecProcInstr("xml",m_strNewData); +} + +void KXEVersionEncodingCommand::unexecute() +{ + m_pDocument->setSpecProcInstr("xml",m_strOldData); +} + +////////////////////////////////////////////////////////////////////////////////////////// +/////////// Attaching stylesheet ////////// +////////////////////////////////////////////////////////////////////////////////////////// + +KXEStylesheetAttachCommand::KXEStylesheetAttachCommand(KXEDocument* pDocument,const QString& prevStylesheet,const QString& newStylesheet) + : KXECommand(pDocument) +{ + m_strNewStylesheet = newStylesheet; + m_strPrevStylesheet = prevStylesheet; +} + +KXEStylesheetAttachCommand::~KXEStylesheetAttachCommand() +{ +} + +void KXEStylesheetAttachCommand::execute() +{ + m_pDocument->detachStylesheet(); + m_pDocument->attachStylesheet(KURL(m_strNewStylesheet)); +} + +void KXEStylesheetAttachCommand::unexecute() +{ + m_pDocument->detachStylesheet(); + if(!m_strPrevStylesheet.isEmpty()) + m_pDocument->attachStylesheet(KURL(m_strPrevStylesheet)); +} + +////////////////////////////////////////////////////////////////////////////////////////// +/////////// Detaching Stylesheet ////////// +////////////////////////////////////////////////////////////////////////////////////////// + +KXEStylesheetDetachCommand::KXEStylesheetDetachCommand(KXEDocument* pDocument,const QString& prevStylesheet) + : KXECommand(pDocument) +{ + m_strPrevStylesheet = prevStylesheet; +} + +KXEStylesheetDetachCommand::~KXEStylesheetDetachCommand() +{ +} + +void KXEStylesheetDetachCommand::execute() +{ + m_pDocument->detachStylesheet(); +} + +void KXEStylesheetDetachCommand::unexecute() +{ + if (!m_strPrevStylesheet.isEmpty()) + m_pDocument->attachStylesheet(KURL(m_strPrevStylesheet)); +} + +////////////////////////////////////////////////////////////////////////////////////////// +/////////// Attaching Schema ////////// +////////////////////////////////////////////////////////////////////////////////////////// + +KXESchemaAttachCommand::KXESchemaAttachCommand(KXEDocument *pDocument,const QString& newSchema) + : KXECommand(pDocument) +{ + m_pDocument = pDocument; + m_strNewSchema = newSchema; + m_strPrevSchema = ""; +} +KXESchemaAttachCommand::KXESchemaAttachCommand(KXEDocument *pDocument,const QString& newSchema,const QString& prevSchema) + : KXECommand(pDocument) +{ + m_strNewSchema = newSchema; + m_strPrevSchema = prevSchema; +} + +KXESchemaAttachCommand::~KXESchemaAttachCommand() +{ +} + +void KXESchemaAttachCommand::execute() +{ + m_pDocument->detachSchema(); // old schema is removed + m_pDocument->attachSchema(KURL(m_strNewSchema)); // new schema is applited +} + +void KXESchemaAttachCommand::unexecute() +{ + m_pDocument->detachSchema(); // new schema is removed + if (!m_strPrevSchema.isEmpty()) + m_pDocument->attachSchema(KURL(m_strPrevSchema)); // old schema is applied +} + +////////////////////////////////////////////////////////////////////////////////////////// +/////////// Detaching schema ////////// +////////////////////////////////////////////////////////////////////////////////////////// + +KXESchemaDetachCommand::KXESchemaDetachCommand(KXEDocument* pDocument, const QString& schema) + : KXECommand(pDocument) +{ + m_schema = schema; +} + +KXESchemaDetachCommand::~KXESchemaDetachCommand() +{ +} + +void KXESchemaDetachCommand::execute() +{ + m_pDocument->detachSchema(); +} + +void KXESchemaDetachCommand::unexecute() +{ + if (!m_schema.isEmpty()) + m_pDocument->attachSchema(KURL(m_schema)); +} + diff --git a/part/commands_file.h b/part/commands_file.h new file mode 100644 index 0000000..00dc484 --- /dev/null +++ b/part/commands_file.h @@ -0,0 +1,102 @@ +/*************************************************************************** + commands_file - description + ------------------- + begin : Wed Nov 26 2003 + copyright : (C) 2003 by The KXMLEditor Team + email : a_charytoniuk@user.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#ifndef COMMANDS_FILE_H +#define COMMANDS_FILE_H + +#include "kxecommand.h" +#include + +/** @file + This file contains all commands taken from menu File which + can effect our edited document. These commans allows to have + undo/redo functionality. +*/ + +/** +Command for setting version and encoding to XML file. + +@author The KXMLEditor Team +*/ + +class KXEDocument; +class QString; + +class KXEVersionEncodingCommand : public KXECommand +{ + public: + KXEVersionEncodingCommand(KXEDocument* pDocument, const QString& oldData, const QString &newData); + virtual void execute(); + virtual void unexecute(); + virtual QString name() const { return i18n("Changing version and encoding"); } + ~KXEVersionEncodingCommand(); + protected: + QString m_strOldData; + QString m_strNewData; +}; + +class KXEStylesheetAttachCommand : public KXECommand +{ + public: + KXEStylesheetAttachCommand(KXEDocument* pDocument,const QString& prevStylesheet,const QString& newStylesheet); + virtual void execute(); + virtual void unexecute(); + virtual QString name() const { return i18n("Attaching stylesheet ")+m_strNewStylesheet; } + ~KXEStylesheetAttachCommand(); + protected: + QString m_strPrevStylesheet; + QString m_strNewStylesheet; +}; + +class KXEStylesheetDetachCommand : public KXECommand +{ + public: + KXEStylesheetDetachCommand(KXEDocument* pDocument,const QString& prevStylesheet); + virtual void execute(); + virtual void unexecute(); + virtual QString name() const { return i18n("Detaching stylesheet ")+m_strPrevStylesheet; } + ~KXEStylesheetDetachCommand(); + protected: + QString m_strPrevStylesheet; +}; + +class KXESchemaAttachCommand : public KXECommand +{ + public: + KXESchemaAttachCommand(KXEDocument *pDocument,const QString& newSchema); + KXESchemaAttachCommand(KXEDocument *pDocument,const QString& newSchema, const QString& prevSchema); + virtual void execute(); + virtual void unexecute(); + virtual QString name() const { return i18n("Attaching schema ")+m_strNewSchema; } + ~KXESchemaAttachCommand(); + protected: + QString m_strNewSchema; + QString m_strPrevSchema; +}; + +class KXESchemaDetachCommand : public KXECommand +{ + public: + KXESchemaDetachCommand(KXEDocument* pDocument, const QString& schema); + virtual void execute(); + virtual void unexecute(); + virtual QString name() const { return i18n("Detaching schema ")+m_schema; } + ~KXESchemaDetachCommand(); + protected: + QString m_schema; +}; + +#endif diff --git a/part/commands_insert.cpp b/part/commands_insert.cpp new file mode 100644 index 0000000..9f17d51 --- /dev/null +++ b/part/commands_insert.cpp @@ -0,0 +1,329 @@ +/*************************************************************************** + commands_insert - description + ------------------- + begin : Wed Nov 26 2003 + copyright : (C) 2003 by The KXMLEditor Team + email : lvanek@user.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#include "commands_insert.h" + +#include + +#include + +////////////////////////////////////////////////////////////////////////////////////////// +/////////// Inserting new XML element ////////// +////////////////////////////////////////////////////////////////////////////////////////// + +KXEElementCommand::KXEElementCommand( + KXEDocument *pDocument, + QDomDocument * pDomDoc, + QString strNsURI, + QString strPrefix, + QString strName + ) + : KXECommand(pDocument) +{ + if ( pDomDoc == 0 ) + kdError() << "KXEElementCommand::KXEElementCommand the given XML document object is empty." << endl; + + m_pDomDoc = pDomDoc; + + if ( strNsURI.isEmpty() ) + m_domElement = m_pDomDoc->createElement( strName ); + else + m_domElement = m_pDomDoc->createElementNS( strNsURI, strPrefix + ":" + strName ); +} + +KXEElementCommand::KXEElementCommand( + KXEDocument *pDocument, + QDomElement & domParentElement, + QString strNsURI, + QString strPrefix, + QString strName, + bool bAtTop + ) + : KXECommand(pDocument) +{ + if ( domParentElement.isNull() ) + kdError() << "KXEElementCommand::KXEElementCommand the given XML element object is empty." << endl; + + m_domParentElement = domParentElement; + m_pDomDoc = 0; + m_bAtTop = bAtTop; + + if ( strNsURI.isEmpty() ) + m_domElement = m_domParentElement.ownerDocument().createElement( strName ); + else + m_domElement = m_domParentElement.ownerDocument().createElementNS( strNsURI, strPrefix + ":" + strName ); +} + +KXEElementCommand::~KXEElementCommand() +{ +} + +void KXEElementCommand::execute() +{ + if ( m_pDomDoc ) + { + // Insert root element + m_pDomDoc->appendChild( m_domElement ); + } + else + { + if( !m_domParentElement.isNull() ) + { + // Insert child element + if ( m_bAtTop ) + { // insert as first child + QDomNode domFirstChildNode = m_domParentElement.firstChild(); + if ( domFirstChildNode.isNull() ) + m_domParentElement.appendChild( m_domElement ); // no childs yet -> simply append + else + m_domParentElement.insertBefore( m_domElement, domFirstChildNode ); + } + else // insert as last child + m_domParentElement.appendChild( m_domElement ); + } + else + { + kdError() << "KXEElementCommand::execute document and element object is empty." << endl; + } + } + m_pDocument->updateNodeCreated(m_domElement); +} + +void KXEElementCommand::unexecute() +{ + if ( m_domElement.parentNode().removeChild( m_domElement ).isNull() ) + kdError() << "KXEElementCommand::unexecute error removing the selected node." << endl; + else + { + m_pDocument->updateNodeDeleted(m_domElement); + } +} + +////////////////////////////////////////////////////////////////////////////////////////// +/////////// inserting new attribute ////////// +////////////////////////////////////////////////////////////////////////////////////////// + +KXEAttributeCommand::KXEAttributeCommand( + KXEDocument *pDocument, + QDomElement &domOwnerElement, + QString strNamespace, + QString strQName, + QString strValue + ) + : KXECommand(pDocument) +{ + if ( domOwnerElement.isNull() ) + { + kdError() << k_funcinfo << "KXEAttributeCommand::KXEAttributeCommand - The given owner element is empty." << endl; + return; + } + + m_domOwnerElement = domOwnerElement; + m_strNamespace = strNamespace; + m_strQName = strQName; + m_strValue = strValue; +} + +KXEAttributeCommand::~KXEAttributeCommand() +{ +} + +void KXEAttributeCommand::execute() +{ + if ( m_strNamespace.isEmpty() ) + m_domOwnerElement.setAttribute( m_strQName, m_strValue ); + else + m_domOwnerElement.setAttributeNS( m_strNamespace, m_strQName, m_strValue ); + + m_pDocument->updateNodeChanged( m_domOwnerElement ) ; +} + +void KXEAttributeCommand::unexecute() +{ + if ( m_strNamespace.isEmpty() ) + m_domOwnerElement.removeAttribute(m_strQName); + else + m_domOwnerElement.removeAttributeNS(m_strNamespace, m_strQName); + + m_pDocument->updateNodeChanged( m_domOwnerElement ) ; +} + +////////////////////////////////////////////////////////////////////////////////////////// +/////////// Inserting new character data ////////// +////////////////////////////////////////////////////////////////////////////////////////// + +KXECharDataCommand::KXECharDataCommand( + KXEDocument *pDocument, + QDomElement & domParentElement, + bool bAtTop, + CharDataKind eCharDataKind, + QString strContents + ) + : KXECommand(pDocument) +{ + if ( domParentElement.isNull() ) + { + kdError() << k_funcinfo << "KXECharDataCommand::KXECharDataCommand - The given parent object is empty." << endl; + return; + } + + m_domParentElement = domParentElement; + m_bAtTop = bAtTop; + + switch ( eCharDataKind ) + { + case CharDataTextNode: + m_domCharData = domParentElement.ownerDocument().createTextNode( strContents ); + break; + + case CharDataCDATASection: + m_domCharData = domParentElement.ownerDocument().createCDATASection( strContents ); + break; + + case CharDataComment: + m_domCharData = domParentElement.ownerDocument().createComment( strContents ); + break; + + default: + kdError() << "KXECharDataCommand::KXECharDataCommand unrecognized char. data type." << endl; + break; + } +} + +KXECharDataCommand::~KXECharDataCommand() +{ +} + +void KXECharDataCommand::execute() +{ + if ( m_bAtTop ) + { // insert as first child + QDomNode domFirstChildNode = m_domParentElement.firstChild(); + if ( domFirstChildNode.isNull() ) + m_domParentElement.appendChild( m_domCharData ); // no childs yet -> simply append + else + m_domParentElement.insertBefore( m_domCharData, domFirstChildNode ); + } + else // insert as last child + m_domParentElement.appendChild( m_domCharData ); + + m_pDocument->updateNodeCreated(m_domCharData); +} + +void KXECharDataCommand::unexecute() +{ + if ( m_domCharData.parentNode().removeChild( m_domCharData ).isNull() ) + kdError() << "KXECharDataCommand::unexecute error removing the selected node." << endl; + else + { + m_pDocument->updateNodeDeleted(m_domCharData); + } +} + +////////////////////////////////////////////////////////////////////////////////////////// +/////////// Inserting new proc instr. ////////// +////////////////////////////////////////////////////////////////////////////////////////// + +KXEProcInstrCommand::KXEProcInstrCommand( + KXEDocument *pDocument, + QDomDocument * pDomDoc, + bool bAtTop, + QString strTarget, + QString strData + ) + : KXECommand(pDocument) +{ + if ( pDomDoc == 0 ) + { + kdError() << k_funcinfo << "KXEProcInstrCommand::KXEProcInstrCommand - The given parent object is empty." << endl; + return; + } + + m_pDomDoc = pDomDoc; + m_bAtTop = bAtTop; + + m_domProcInstr = pDomDoc->createProcessingInstruction( strTarget, strData ); +} + +KXEProcInstrCommand::KXEProcInstrCommand( + KXEDocument *pDocument, + QDomElement & domParentElement, + bool bAtTop, + QString strTarget, + QString strData + ) + : KXECommand(pDocument) +{ + if ( domParentElement.isNull() ) + { + kdError() << k_funcinfo << "KXEProcInstrCommand::KXEProcInstrCommand - The given parent object is empty." << endl; + return; + } + + m_domParentElement = domParentElement; + m_pDomDoc = 0; + m_bAtTop = bAtTop; + + m_domProcInstr = domParentElement.ownerDocument().createProcessingInstruction( strTarget, strData ); +} + + +KXEProcInstrCommand::~KXEProcInstrCommand() +{ +} + +void KXEProcInstrCommand::execute() +{ + if ( m_pDomDoc ) + { + // Insert root proc. instr + m_pDomDoc->appendChild( m_domProcInstr ); + } + else + { + if( !m_domParentElement.isNull() ) + { + // Insert child proc. instr + if ( m_bAtTop ) + { // insert as first child + QDomNode domFirstChildNode = m_domParentElement.firstChild(); + if ( domFirstChildNode.isNull() ) + m_domParentElement.appendChild( m_domProcInstr ); // no childs yet -> simply append + else + m_domParentElement.insertBefore( m_domProcInstr, domFirstChildNode ); + } + else // insert as last child + m_domParentElement.appendChild( m_domProcInstr ); + } + else + { + kdError() << "KXEElementCommand::execute document and element object is empty." << endl; + } + } + m_pDocument->updateNodeCreated(m_domProcInstr); +} + +void KXEProcInstrCommand::unexecute() +{ + if ( m_domProcInstr.parentNode().removeChild( m_domProcInstr ).isNull() ) + kdError() << "KXEProcInstrCommand::unexecute error removing the selected node." << endl; + else + { + m_pDocument->updateNodeDeleted(m_domProcInstr); + } +} + + diff --git a/part/commands_insert.h b/part/commands_insert.h new file mode 100644 index 0000000..4d9da8d --- /dev/null +++ b/part/commands_insert.h @@ -0,0 +1,94 @@ +/*************************************************************************** + commands_insert - description + ------------------- + begin : Wed Nov 26 2003 + copyright : (C) 2003 by The KXMLEditor Team + email : lvanek.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#ifndef COMMANDS_INSERT_H +#define COMMANDS_INSERT_H + +#include + +#include "kxecommand.h" +#include "kxechardatadialog.h" + +/** +@author The KXMLEditor Team +*/ +class KXEElementCommand : public KXECommand +{ + public: + KXEElementCommand(KXEDocument*, QDomDocument *, QString, QString, QString); + KXEElementCommand(KXEDocument*, QDomElement &, QString, QString, QString, bool); + ~KXEElementCommand(); + virtual void execute(); + virtual void unexecute(); + virtual QString name() const { return i18n("Insert element"); } + + protected: + QDomDocument * m_pDomDoc; + QDomElement m_domParentElement; + bool m_bAtTop; + QDomElement m_domElement; +}; + +class KXEAttributeCommand : public KXECommand +{ + public: + KXEAttributeCommand(KXEDocument*, QDomElement &, QString, QString, QString); + ~KXEAttributeCommand(); + virtual void execute(); + virtual void unexecute(); + virtual QString name() const { return i18n("Insert attribute"); } + + protected: + QString m_strNamespace; + QString m_strQName; + QString m_strValue; + QDomElement m_domOwnerElement; +}; + +class KXECharDataCommand : public KXECommand +{ + public: + KXECharDataCommand(KXEDocument*, QDomElement &, bool, CharDataKind, QString); + ~KXECharDataCommand(); + virtual void execute(); + virtual void unexecute(); + virtual QString name() const { return i18n("Insert char data"); } + + protected: + + bool m_bAtTop; + QDomElement m_domParentElement; + QDomCharacterData m_domCharData; +}; + +class KXEProcInstrCommand : public KXECommand +{ + public: + KXEProcInstrCommand(KXEDocument*, QDomDocument *, bool, QString, QString); + KXEProcInstrCommand(KXEDocument*, QDomElement &, bool, QString, QString); + ~KXEProcInstrCommand(); + virtual void execute(); + virtual void unexecute(); + virtual QString name() const { return i18n("Insert proc. instr."); } + + protected: + QDomDocument * m_pDomDoc; + QDomElement m_domParentElement; + bool m_bAtTop; + QDomProcessingInstruction m_domProcInstr; +}; + +#endif diff --git a/part/dcopiface_part_ro.cpp b/part/dcopiface_part_ro.cpp new file mode 100644 index 0000000..c2794d0 --- /dev/null +++ b/part/dcopiface_part_ro.cpp @@ -0,0 +1,67 @@ +/*************************************************************************** + dcopiface_part_ro.cpp - description + ------------------- + begin : Tue Oct 23 2001 + copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team + email : lvanek@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#include "dcopiface_part_ro.h" +#include "kxmleditorpart.h" +//--------------------------------------------------------------------------- +// KXMLEditorPartIfaceReadOnly +//--------------------------------------------------------------------------- +QString +KXMLEditorPartIfaceReadOnly::saveAsFile(const QString & ) +{ + return "Not implemented."; +} + +QString +KXMLEditorPartIfaceReadOnly::selectNode(const QString & szPathToNode) +{ + m_pKXEPart->slotPathSelected(szPathToNode); + + if ( m_pKXEPart->getSelectedPath() == szPathToNode ) + return "Selecting node failed."; + + return QString(); +} + +QString +KXMLEditorPartIfaceReadOnly::currentNode() const +{ + return m_pKXEPart->getSelectedPath(); +} + + +//--------------------------------------------------------------------------- +// KXMLEditorPartIface +//--------------------------------------------------------------------------- +QString +KXMLEditorPartIfaceReadWrite::openURL(const QString & szURL) +{ + KURL url(szURL); + if (! url.isValid () ) + return "URL is not valid."; + if ( m_pKXEPart->openURL(url) ) + return QString(); + else + return "Opening URL failed."; +} + + +QString +KXMLEditorPartIfaceReadWrite::close() +{ + return "Not implemented."; +} + diff --git a/part/dcopiface_part_ro.h b/part/dcopiface_part_ro.h new file mode 100644 index 0000000..90f5982 --- /dev/null +++ b/part/dcopiface_part_ro.h @@ -0,0 +1,124 @@ +/*************************************************************************** + dcopiface_part_ro.h - description + ------------------- + begin : Tue Oct 23 2001 + copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team + email : lvanek@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef DCOPIFACE_PART_RO_H +#define DCOPIFACE_PART_RO_H + +#include + + +class KXMLEditorPart; + /** + * Allows perform action on represetntaion of XML file via DCOP protocol. + * behavies as interface to @ref KXMLEditorPart and to it adresses most of requestests received by DCOP + * + *@see KXMLEditorPart + * + *@short Read only DCOP interface for XML document Kpart based kxmleditor. + * + *@author The KXMLEditor Team (matkor@users.sourceforge.net) + **/ + +class KXMLEditorPartIfaceReadOnly + :virtual public DCOPObject +{ + K_DCOP + +protected: + /** @ref KXMLEditorPart which Iface represensts **/ + KXMLEditorPart * m_pKXEPart; + +public: + /** + * Default constructor + * + * @param kxe_part Specifies on what @ref KXMLEditorPart will interface operate. + **/ + KXMLEditorPartIfaceReadOnly(KXMLEditorPart * kxe_part,const char * dcop_name = "KXMLEditorPartIface") + : DCOPObject(dcop_name) + { + m_pKXEPart = kxe_part; + } + virtual ~KXMLEditorPartIfaceReadOnly() + {}; +k_dcop: + /** + * Saves document as file + * + * @returns Error description or empty string if file succesfully saved. + **/ + + QString saveAsFile(const QString & path_to_file); + + /** Tries to change current node + * @param pathToNode Path to new node + * @returns Empty string if selection OK otherwise error description + **/ + QString selectNode(const QString & pathToNode); + + /** Returns path to current node + * @returns If error empty string + **/ + QString currentNode() const; + +}; + + + + /** + *@short Read/Write DCOP inteface for Kpart based kxmleditor. + *@author The KXMLEditor Team + **/ +// +class KXMLEditorPartIfaceReadWrite + :public KXMLEditorPartIfaceReadOnly +{ + K_DCOP + /** + * Default constructor + * + * @param kxe_part Specifies on what @ref KXMLEditorPart will interface operate. + **/ +public: + KXMLEditorPartIfaceReadWrite(KXMLEditorPart * kxe_part,const char * dcop_name = "KXMLEditorPartIface") + : DCOPObject(dcop_name) + ,KXMLEditorPartIfaceReadOnly(kxe_part,dcop_name) + {} + virtual ~KXMLEditorPartIfaceReadWrite() + {}; +k_dcop: + + /** + * Opens given file + * + * @returns Error description or empty string if file succesfully loaded. + **/ + QString openURL(const QString & szURL); + + /** + * Closes object behind interface. + * In curent implementation it means closing entire KXMLEditor. + * + * @returns Error description or empty string if program closed. + **/ + QString close(); + + +}; + + +#endif // DCOPIFACE_PART_RO_H diff --git a/part/icons/Makefile.am b/part/icons/Makefile.am new file mode 100644 index 0000000..41028ae --- /dev/null +++ b/part/icons/Makefile.am @@ -0,0 +1,155 @@ + +EXTRA_DIST = hi16-action-bookmark_next.png hi16-action-xml_cdata.png hi16-action-xml_comment.png hi16-action-xml_text.png hi16-action-bookmark_prev.png hi16-action-collapse_node.png hi16-action-expand_node.png hi16-action-xml_delete_attribute.png hi16-action-xml_delete_contents.png hi16-action-xml_delete_element.png hi16-action-xml_delete_procins.png hi16-action-xml_edit_attribute.png hi16-action-xml_edit_contents.png hi16-action-xml_edit_element.png hi16-action-xml_edit_procins.png hi16-action-xml_insert_attribute.png hi16-action-xml_insert_contents.png hi16-action-xml_insert_element.png hi16-action-xml_insert_procins.png hi16-action-xml_move_item_down.png hi16-action-xml_move_item_up.png hi22-action-bookmark_next.png hi22-action-bookmark_prev.png hi22-action-collapse_node.png hi22-action-expand_node.png hi22-action-xml_delete_attribute.png hi22-action-xml_delete_contents.png hi22-action-xml_delete_element.png hi22-action-xml_delete_procins.png hi22-action-xml_edit_attribute.png hi22-action-xml_edit_contents.png hi22-action-xml_edit_element.png hi22-action-xml_edit_procins.png hi22-action-xml_insert_attribute.png hi22-action-xml_insert_contents.png hi22-action-xml_insert_element.png hi22-action-xml_insert_procins.png hi22-action-xml_move_item_down.png hi22-action-xml_move_item_up.png hi32-action-bookmark_next.png hi32-action-bookmark_prev.png hi32-action-xml_move_item_down.png hi32-action-xml_move_item_up.png lo16-action-bookmark_next.png lo16-action-bookmark_prev.png lo16-action-collapse_node.png lo16-action-expand_node.png lo16-action-xml_delete_attribute.png lo16-action-xml_delete_contents.png lo16-action-xml_delete_element.png lo16-action-xml_delete_procins.png lo16-action-xml_edit_attribute.png lo16-action-xml_edit_contents.png lo16-action-xml_edit_element.png lo16-action-xml_edit_procins.png lo16-action-xml_insert_attribute.png lo16-action-xml_insert_contents.png lo16-action-xml_insert_element.png lo16-action-xml_insert_procins.png lo16-action-xml_move_item_down.png lo16-action-xml_move_item_up.png \ + lo32-app-kxmleditor.png lo16-app-kxmleditor.png \ + hi32-app-kxmleditor.png hi48-app-kxmleditor.png + +install-data-local: + $(mkinstalldirs) $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/ + $(INSTALL_DATA) $(srcdir)/hi16-action-bookmark_next.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/bookmark_next.png + $(INSTALL_DATA) $(srcdir)/hi16-action-bookmark_prev.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/bookmark_prev.png + $(INSTALL_DATA) $(srcdir)/hi16-action-collapse_node.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/collapse_node.png + $(INSTALL_DATA) $(srcdir)/hi16-action-expand_node.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/expand_node.png + $(INSTALL_DATA) $(srcdir)/hi16-action-xml_delete_attribute.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_delete_attribute.png + $(INSTALL_DATA) $(srcdir)/hi16-action-xml_delete_contents.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_delete_contents.png + $(INSTALL_DATA) $(srcdir)/hi16-action-xml_delete_element.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_delete_element.png + $(INSTALL_DATA) $(srcdir)/hi16-action-xml_delete_procins.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_delete_procins.png + $(INSTALL_DATA) $(srcdir)/hi16-action-xml_edit_attribute.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_edit_attribute.png + $(INSTALL_DATA) $(srcdir)/hi16-action-xml_edit_contents.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_edit_contents.png + $(INSTALL_DATA) $(srcdir)/hi16-action-xml_edit_element.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_edit_element.png + $(INSTALL_DATA) $(srcdir)/hi16-action-xml_edit_procins.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_edit_procins.png + $(INSTALL_DATA) $(srcdir)/hi16-action-xml_insert_attribute.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_insert_attribute.png + $(INSTALL_DATA) $(srcdir)/hi16-action-xml_insert_contents.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_insert_contents.png + $(INSTALL_DATA) $(srcdir)/hi16-action-xml_insert_element.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_insert_element.png + $(INSTALL_DATA) $(srcdir)/hi16-action-xml_insert_procins.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_insert_procins.png + $(INSTALL_DATA) $(srcdir)/hi16-action-xml_move_item_down.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_move_item_down.png + $(INSTALL_DATA) $(srcdir)/hi16-action-xml_move_item_up.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_move_item_up.png + $(INSTALL_DATA) $(srcdir)/hi16-action-xml_text.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_text.png + $(INSTALL_DATA) $(srcdir)/hi16-action-xml_cdata.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_cdata.png + $(INSTALL_DATA) $(srcdir)/hi16-action-xml_comment.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_comment.png + $(mkinstalldirs) $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/ + $(INSTALL_DATA) $(srcdir)/hi22-action-bookmark_next.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/bookmark_next.png + $(INSTALL_DATA) $(srcdir)/hi22-action-bookmark_prev.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/bookmark_prev.png + $(INSTALL_DATA) $(srcdir)/hi22-action-collapse_node.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/collapse_node.png + $(INSTALL_DATA) $(srcdir)/hi22-action-expand_node.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/expand_node.png + $(INSTALL_DATA) $(srcdir)/hi22-action-xml_delete_attribute.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_delete_attribute.png + $(INSTALL_DATA) $(srcdir)/hi22-action-xml_delete_contents.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_delete_contents.png + $(INSTALL_DATA) $(srcdir)/hi22-action-xml_delete_element.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_delete_element.png + $(INSTALL_DATA) $(srcdir)/hi22-action-xml_delete_procins.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_delete_procins.png + $(INSTALL_DATA) $(srcdir)/hi22-action-xml_edit_attribute.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_edit_attribute.png + $(INSTALL_DATA) $(srcdir)/hi22-action-xml_edit_contents.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_edit_contents.png + $(INSTALL_DATA) $(srcdir)/hi22-action-xml_edit_element.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_edit_element.png + $(INSTALL_DATA) $(srcdir)/hi22-action-xml_edit_procins.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_edit_procins.png + $(INSTALL_DATA) $(srcdir)/hi22-action-xml_insert_attribute.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_insert_attribute.png + $(INSTALL_DATA) $(srcdir)/hi22-action-xml_insert_contents.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_insert_contents.png + $(INSTALL_DATA) $(srcdir)/hi22-action-xml_insert_element.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_insert_element.png + $(INSTALL_DATA) $(srcdir)/hi22-action-xml_insert_procins.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_insert_procins.png + $(INSTALL_DATA) $(srcdir)/hi22-action-xml_move_item_down.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_move_item_down.png + $(INSTALL_DATA) $(srcdir)/hi22-action-xml_move_item_up.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_move_item_up.png + $(mkinstalldirs) $(kde_datadir)/kxmleditor/icons/hicolor/32x32/actions/ + $(INSTALL_DATA) $(srcdir)/hi32-action-bookmark_next.png $(kde_datadir)/kxmleditor/icons/hicolor/32x32/actions/bookmark_next.png + $(INSTALL_DATA) $(srcdir)/hi32-action-bookmark_prev.png $(kde_datadir)/kxmleditor/icons/hicolor/32x32/actions/bookmark_prev.png + $(INSTALL_DATA) $(srcdir)/hi32-action-xml_move_item_down.png $(kde_datadir)/kxmleditor/icons/hicolor/32x32/actions/xml_move_item_down.png + $(INSTALL_DATA) $(srcdir)/hi32-action-xml_move_item_up.png $(kde_datadir)/kxmleditor/icons/hicolor/32x32/actions/xml_move_item_up.png + $(mkinstalldirs) $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/ + $(INSTALL_DATA) $(srcdir)/lo16-action-bookmark_next.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/bookmark_next.png + $(INSTALL_DATA) $(srcdir)/lo16-action-bookmark_prev.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/bookmark_prev.png + $(INSTALL_DATA) $(srcdir)/lo16-action-collapse_node.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/collapse_node.png + $(INSTALL_DATA) $(srcdir)/lo16-action-expand_node.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/expand_node.png + $(INSTALL_DATA) $(srcdir)/lo16-action-xml_delete_attribute.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_delete_attribute.png + $(INSTALL_DATA) $(srcdir)/lo16-action-xml_delete_contents.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_delete_contents.png + $(INSTALL_DATA) $(srcdir)/lo16-action-xml_delete_element.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_delete_element.png + $(INSTALL_DATA) $(srcdir)/lo16-action-xml_delete_procins.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_delete_procins.png + $(INSTALL_DATA) $(srcdir)/lo16-action-xml_edit_attribute.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_edit_attribute.png + $(INSTALL_DATA) $(srcdir)/lo16-action-xml_edit_contents.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_edit_contents.png + $(INSTALL_DATA) $(srcdir)/lo16-action-xml_edit_element.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_edit_element.png + $(INSTALL_DATA) $(srcdir)/lo16-action-xml_edit_procins.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_edit_procins.png + $(INSTALL_DATA) $(srcdir)/lo16-action-xml_insert_attribute.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_insert_attribute.png + $(INSTALL_DATA) $(srcdir)/lo16-action-xml_insert_contents.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_insert_contents.png + $(INSTALL_DATA) $(srcdir)/lo16-action-xml_insert_element.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_insert_element.png + $(INSTALL_DATA) $(srcdir)/lo16-action-xml_insert_procins.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_insert_procins.png + $(INSTALL_DATA) $(srcdir)/lo16-action-xml_move_item_down.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_move_item_down.png + $(INSTALL_DATA) $(srcdir)/lo16-action-xml_move_item_up.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_move_item_up.png + $(mkinstalldirs) $(kde_icondir)/locolor/32x32/apps/ + $(INSTALL_DATA) $(srcdir)/lo32-app-kxmleditor.png $(kde_icondir)/locolor/32x32/apps/kxmleditor.png + $(mkinstalldirs) $(kde_icondir)/locolor/16x16/apps/ + $(INSTALL_DATA) $(srcdir)/lo16-app-kxmleditor.png $(kde_icondir)/locolor/16x16/apps/kxmleditor.png + $(mkinstalldirs) $(kde_icondir)/hicolor/32x32/apps/ + $(INSTALL_DATA) $(srcdir)/hi32-app-kxmleditor.png $(kde_icondir)/hicolor/32x32/apps/kxmleditor.png + $(mkinstalldirs) $(kde_icondir)/hicolor/48x48/apps/ + $(INSTALL_DATA) $(srcdir)/hi48-app-kxmleditor.png $(kde_icondir)/hicolor/48x48/apps/kxmleditor.png + + +uninstall-local: + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/bookmark_next.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/bookmark_prev.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/collapse_node.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/expand_node.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_delete_attribute.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_delete_contents.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_delete_element.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_delete_procins.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_edit_attribute.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_edit_contents.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_edit_element.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_edit_procins.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_insert_attribute.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_insert_contents.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_insert_element.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_insert_procins.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_move_item_down.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_move_item_up.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/bookmark_next.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/bookmark_prev.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/collapse_node.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/expand_node.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_delete_attribute.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_delete_contents.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_delete_element.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_delete_procins.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_edit_attribute.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_edit_contents.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_edit_element.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_edit_procins.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_insert_attribute.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_insert_contents.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_insert_element.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_insert_procins.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_move_item_down.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_move_item_up.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/32x32/actions/bookmark_next.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/32x32/actions/bookmark_prev.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/32x32/actions/xml_move_item_down.png + -rm -f $(kde_datadir)/kxmleditor/icons/hicolor/32x32/actions/xml_move_item_up.png + -rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_text.png + -rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_cdata.png + -rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_comment.png + -rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/bookmark_next.png + -rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/bookmark_prev.png + -rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/collapse_node.png + -rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/expand_node.png + -rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_delete_attribute.png + -rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_delete_contents.png + -rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_delete_element.png + -rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_delete_procins.png + -rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_edit_attribute.png + -rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_edit_contents.png + -rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_edit_element.png + -rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_edit_procins.png + -rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_insert_attribute.png + -rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_insert_contents.png + -rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_insert_element.png + -rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_insert_procins.png + -rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_move_item_down.png + -rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_move_item_up.png + -rmdir $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/ + -rmdir $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/ + -rmdir $(kde_datadir)/kxmleditor/icons/hicolor/32x32/actions/ + -rmdir $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/ + -rm -f $(kde_icondir)/locolor/32x32/apps/kxmleditor.png + -rmdir $(kde_icondir)/locolor/32x32/apps/ + -rm -f $(kde_icondir)/locolor/16x16/apps/kxmleditor.png + -rmdir $(kde_icondir)/locolor/16x16/apps/ + -rm -f $(kde_icondir)/hicolor/32x32/apps/kxmleditor.png + -rmdir $(kde_icondir)/hicolor/32x32/apps/ + -rm -f $(kde_icondir)/hicolor/48x48/apps/kxmleditor.png + -rmdir $(kde_icondir)/hicolor/48x48/apps/ diff --git a/part/icons/hi16-action-bookmark_next.png b/part/icons/hi16-action-bookmark_next.png new file mode 100644 index 0000000..12b6893 Binary files /dev/null and b/part/icons/hi16-action-bookmark_next.png differ diff --git a/part/icons/hi16-action-bookmark_prev.png b/part/icons/hi16-action-bookmark_prev.png new file mode 100644 index 0000000..32cbc7a Binary files /dev/null and b/part/icons/hi16-action-bookmark_prev.png differ diff --git a/part/icons/hi16-action-collapse_node.png b/part/icons/hi16-action-collapse_node.png new file mode 100644 index 0000000..9efc36a Binary files /dev/null and b/part/icons/hi16-action-collapse_node.png differ diff --git a/part/icons/hi16-action-expand_node.png b/part/icons/hi16-action-expand_node.png new file mode 100644 index 0000000..f8354df Binary files /dev/null and b/part/icons/hi16-action-expand_node.png differ diff --git a/part/icons/hi16-action-xml_cdata.png b/part/icons/hi16-action-xml_cdata.png new file mode 100644 index 0000000..ba70ca1 Binary files /dev/null and b/part/icons/hi16-action-xml_cdata.png differ diff --git a/part/icons/hi16-action-xml_comment.png b/part/icons/hi16-action-xml_comment.png new file mode 100644 index 0000000..1acd578 Binary files /dev/null and b/part/icons/hi16-action-xml_comment.png differ diff --git a/part/icons/hi16-action-xml_delete_attribute.png b/part/icons/hi16-action-xml_delete_attribute.png new file mode 100644 index 0000000..671da71 Binary files /dev/null and b/part/icons/hi16-action-xml_delete_attribute.png differ diff --git a/part/icons/hi16-action-xml_delete_contents.png b/part/icons/hi16-action-xml_delete_contents.png new file mode 100644 index 0000000..00f1416 Binary files /dev/null and b/part/icons/hi16-action-xml_delete_contents.png differ diff --git a/part/icons/hi16-action-xml_delete_element.png b/part/icons/hi16-action-xml_delete_element.png new file mode 100644 index 0000000..4122060 Binary files /dev/null and b/part/icons/hi16-action-xml_delete_element.png differ diff --git a/part/icons/hi16-action-xml_delete_procins.png b/part/icons/hi16-action-xml_delete_procins.png new file mode 100644 index 0000000..184cba6 Binary files /dev/null and b/part/icons/hi16-action-xml_delete_procins.png differ diff --git a/part/icons/hi16-action-xml_edit_attribute.png b/part/icons/hi16-action-xml_edit_attribute.png new file mode 100644 index 0000000..10e5940 Binary files /dev/null and b/part/icons/hi16-action-xml_edit_attribute.png differ diff --git a/part/icons/hi16-action-xml_edit_contents.png b/part/icons/hi16-action-xml_edit_contents.png new file mode 100644 index 0000000..e67bcf4 Binary files /dev/null and b/part/icons/hi16-action-xml_edit_contents.png differ diff --git a/part/icons/hi16-action-xml_edit_element.png b/part/icons/hi16-action-xml_edit_element.png new file mode 100644 index 0000000..256a24e Binary files /dev/null and b/part/icons/hi16-action-xml_edit_element.png differ diff --git a/part/icons/hi16-action-xml_edit_procins.png b/part/icons/hi16-action-xml_edit_procins.png new file mode 100644 index 0000000..1773cda Binary files /dev/null and b/part/icons/hi16-action-xml_edit_procins.png differ diff --git a/part/icons/hi16-action-xml_insert_attribute.png b/part/icons/hi16-action-xml_insert_attribute.png new file mode 100644 index 0000000..b02f1e0 Binary files /dev/null and b/part/icons/hi16-action-xml_insert_attribute.png differ diff --git a/part/icons/hi16-action-xml_insert_contents.png b/part/icons/hi16-action-xml_insert_contents.png new file mode 100644 index 0000000..c5cda99 Binary files /dev/null and b/part/icons/hi16-action-xml_insert_contents.png differ diff --git a/part/icons/hi16-action-xml_insert_element.png b/part/icons/hi16-action-xml_insert_element.png new file mode 100644 index 0000000..fcc234f Binary files /dev/null and b/part/icons/hi16-action-xml_insert_element.png differ diff --git a/part/icons/hi16-action-xml_insert_procins.png b/part/icons/hi16-action-xml_insert_procins.png new file mode 100644 index 0000000..824ee57 Binary files /dev/null and b/part/icons/hi16-action-xml_insert_procins.png differ diff --git a/part/icons/hi16-action-xml_move_item_down.png b/part/icons/hi16-action-xml_move_item_down.png new file mode 100644 index 0000000..30e0602 Binary files /dev/null and b/part/icons/hi16-action-xml_move_item_down.png differ diff --git a/part/icons/hi16-action-xml_move_item_up.png b/part/icons/hi16-action-xml_move_item_up.png new file mode 100644 index 0000000..7bb1b68 Binary files /dev/null and b/part/icons/hi16-action-xml_move_item_up.png differ diff --git a/part/icons/hi16-action-xml_text.png b/part/icons/hi16-action-xml_text.png new file mode 100644 index 0000000..fb485a3 Binary files /dev/null and b/part/icons/hi16-action-xml_text.png differ diff --git a/part/icons/hi22-action-bookmark_next.png b/part/icons/hi22-action-bookmark_next.png new file mode 100644 index 0000000..d685663 Binary files /dev/null and b/part/icons/hi22-action-bookmark_next.png differ diff --git a/part/icons/hi22-action-bookmark_prev.png b/part/icons/hi22-action-bookmark_prev.png new file mode 100644 index 0000000..33ecf83 Binary files /dev/null and b/part/icons/hi22-action-bookmark_prev.png differ diff --git a/part/icons/hi22-action-collapse_node.png b/part/icons/hi22-action-collapse_node.png new file mode 100644 index 0000000..234711f Binary files /dev/null and b/part/icons/hi22-action-collapse_node.png differ diff --git a/part/icons/hi22-action-expand_node.png b/part/icons/hi22-action-expand_node.png new file mode 100644 index 0000000..5738150 Binary files /dev/null and b/part/icons/hi22-action-expand_node.png differ diff --git a/part/icons/hi22-action-xml_delete_attribute.png b/part/icons/hi22-action-xml_delete_attribute.png new file mode 100644 index 0000000..caef038 Binary files /dev/null and b/part/icons/hi22-action-xml_delete_attribute.png differ diff --git a/part/icons/hi22-action-xml_delete_contents.png b/part/icons/hi22-action-xml_delete_contents.png new file mode 100644 index 0000000..3fe3eb6 Binary files /dev/null and b/part/icons/hi22-action-xml_delete_contents.png differ diff --git a/part/icons/hi22-action-xml_delete_element.png b/part/icons/hi22-action-xml_delete_element.png new file mode 100644 index 0000000..c161c78 Binary files /dev/null and b/part/icons/hi22-action-xml_delete_element.png differ diff --git a/part/icons/hi22-action-xml_delete_procins.png b/part/icons/hi22-action-xml_delete_procins.png new file mode 100644 index 0000000..df8f911 Binary files /dev/null and b/part/icons/hi22-action-xml_delete_procins.png differ diff --git a/part/icons/hi22-action-xml_edit_attribute.png b/part/icons/hi22-action-xml_edit_attribute.png new file mode 100644 index 0000000..83da5de Binary files /dev/null and b/part/icons/hi22-action-xml_edit_attribute.png differ diff --git a/part/icons/hi22-action-xml_edit_contents.png b/part/icons/hi22-action-xml_edit_contents.png new file mode 100644 index 0000000..0cae376 Binary files /dev/null and b/part/icons/hi22-action-xml_edit_contents.png differ diff --git a/part/icons/hi22-action-xml_edit_element.png b/part/icons/hi22-action-xml_edit_element.png new file mode 100644 index 0000000..ffa4149 Binary files /dev/null and b/part/icons/hi22-action-xml_edit_element.png differ diff --git a/part/icons/hi22-action-xml_edit_procins.png b/part/icons/hi22-action-xml_edit_procins.png new file mode 100644 index 0000000..ca5ac18 Binary files /dev/null and b/part/icons/hi22-action-xml_edit_procins.png differ diff --git a/part/icons/hi22-action-xml_insert_attribute.png b/part/icons/hi22-action-xml_insert_attribute.png new file mode 100644 index 0000000..e074c58 Binary files /dev/null and b/part/icons/hi22-action-xml_insert_attribute.png differ diff --git a/part/icons/hi22-action-xml_insert_contents.png b/part/icons/hi22-action-xml_insert_contents.png new file mode 100644 index 0000000..8b463b1 Binary files /dev/null and b/part/icons/hi22-action-xml_insert_contents.png differ diff --git a/part/icons/hi22-action-xml_insert_element.png b/part/icons/hi22-action-xml_insert_element.png new file mode 100644 index 0000000..83b71cb Binary files /dev/null and b/part/icons/hi22-action-xml_insert_element.png differ diff --git a/part/icons/hi22-action-xml_insert_procins.png b/part/icons/hi22-action-xml_insert_procins.png new file mode 100644 index 0000000..f861003 Binary files /dev/null and b/part/icons/hi22-action-xml_insert_procins.png differ diff --git a/part/icons/hi22-action-xml_move_item_down.png b/part/icons/hi22-action-xml_move_item_down.png new file mode 100644 index 0000000..f5c0c69 Binary files /dev/null and b/part/icons/hi22-action-xml_move_item_down.png differ diff --git a/part/icons/hi22-action-xml_move_item_up.png b/part/icons/hi22-action-xml_move_item_up.png new file mode 100644 index 0000000..b3784ef Binary files /dev/null and b/part/icons/hi22-action-xml_move_item_up.png differ diff --git a/part/icons/hi32-action-bookmark_next.png b/part/icons/hi32-action-bookmark_next.png new file mode 100644 index 0000000..4332ea8 Binary files /dev/null and b/part/icons/hi32-action-bookmark_next.png differ diff --git a/part/icons/hi32-action-bookmark_prev.png b/part/icons/hi32-action-bookmark_prev.png new file mode 100644 index 0000000..5e1dd5d Binary files /dev/null and b/part/icons/hi32-action-bookmark_prev.png differ diff --git a/part/icons/hi32-action-xml_move_item_down.png b/part/icons/hi32-action-xml_move_item_down.png new file mode 100644 index 0000000..e7230c1 Binary files /dev/null and b/part/icons/hi32-action-xml_move_item_down.png differ diff --git a/part/icons/hi32-action-xml_move_item_up.png b/part/icons/hi32-action-xml_move_item_up.png new file mode 100644 index 0000000..046b99b Binary files /dev/null and b/part/icons/hi32-action-xml_move_item_up.png differ diff --git a/part/icons/hi32-app-kxmleditor.png b/part/icons/hi32-app-kxmleditor.png new file mode 100644 index 0000000..763034d Binary files /dev/null and b/part/icons/hi32-app-kxmleditor.png differ diff --git a/part/icons/hi48-app-kxmleditor.png b/part/icons/hi48-app-kxmleditor.png new file mode 100644 index 0000000..50fe869 Binary files /dev/null and b/part/icons/hi48-app-kxmleditor.png differ diff --git a/part/icons/lo16-action-bookmark_next.png b/part/icons/lo16-action-bookmark_next.png new file mode 100644 index 0000000..12c0854 Binary files /dev/null and b/part/icons/lo16-action-bookmark_next.png differ diff --git a/part/icons/lo16-action-bookmark_prev.png b/part/icons/lo16-action-bookmark_prev.png new file mode 100644 index 0000000..4278292 Binary files /dev/null and b/part/icons/lo16-action-bookmark_prev.png differ diff --git a/part/icons/lo16-action-collapse_node.png b/part/icons/lo16-action-collapse_node.png new file mode 100644 index 0000000..3fa8bff Binary files /dev/null and b/part/icons/lo16-action-collapse_node.png differ diff --git a/part/icons/lo16-action-expand_node.png b/part/icons/lo16-action-expand_node.png new file mode 100644 index 0000000..82ee7ec Binary files /dev/null and b/part/icons/lo16-action-expand_node.png differ diff --git a/part/icons/lo16-action-xml_delete_attribute.png b/part/icons/lo16-action-xml_delete_attribute.png new file mode 100644 index 0000000..d63db43 Binary files /dev/null and b/part/icons/lo16-action-xml_delete_attribute.png differ diff --git a/part/icons/lo16-action-xml_delete_contents.png b/part/icons/lo16-action-xml_delete_contents.png new file mode 100644 index 0000000..da87e2a Binary files /dev/null and b/part/icons/lo16-action-xml_delete_contents.png differ diff --git a/part/icons/lo16-action-xml_delete_element.png b/part/icons/lo16-action-xml_delete_element.png new file mode 100644 index 0000000..4122060 Binary files /dev/null and b/part/icons/lo16-action-xml_delete_element.png differ diff --git a/part/icons/lo16-action-xml_delete_procins.png b/part/icons/lo16-action-xml_delete_procins.png new file mode 100644 index 0000000..ae65ec0 Binary files /dev/null and b/part/icons/lo16-action-xml_delete_procins.png differ diff --git a/part/icons/lo16-action-xml_edit_attribute.png b/part/icons/lo16-action-xml_edit_attribute.png new file mode 100644 index 0000000..aa176b1 Binary files /dev/null and b/part/icons/lo16-action-xml_edit_attribute.png differ diff --git a/part/icons/lo16-action-xml_edit_contents.png b/part/icons/lo16-action-xml_edit_contents.png new file mode 100644 index 0000000..770d7d8 Binary files /dev/null and b/part/icons/lo16-action-xml_edit_contents.png differ diff --git a/part/icons/lo16-action-xml_edit_element.png b/part/icons/lo16-action-xml_edit_element.png new file mode 100644 index 0000000..2a60632 Binary files /dev/null and b/part/icons/lo16-action-xml_edit_element.png differ diff --git a/part/icons/lo16-action-xml_edit_procins.png b/part/icons/lo16-action-xml_edit_procins.png new file mode 100644 index 0000000..080db82 Binary files /dev/null and b/part/icons/lo16-action-xml_edit_procins.png differ diff --git a/part/icons/lo16-action-xml_insert_attribute.png b/part/icons/lo16-action-xml_insert_attribute.png new file mode 100644 index 0000000..b87786c Binary files /dev/null and b/part/icons/lo16-action-xml_insert_attribute.png differ diff --git a/part/icons/lo16-action-xml_insert_contents.png b/part/icons/lo16-action-xml_insert_contents.png new file mode 100644 index 0000000..5a768fd Binary files /dev/null and b/part/icons/lo16-action-xml_insert_contents.png differ diff --git a/part/icons/lo16-action-xml_insert_element.png b/part/icons/lo16-action-xml_insert_element.png new file mode 100644 index 0000000..9421231 Binary files /dev/null and b/part/icons/lo16-action-xml_insert_element.png differ diff --git a/part/icons/lo16-action-xml_insert_procins.png b/part/icons/lo16-action-xml_insert_procins.png new file mode 100644 index 0000000..799e93a Binary files /dev/null and b/part/icons/lo16-action-xml_insert_procins.png differ diff --git a/part/icons/lo16-action-xml_move_item_down.png b/part/icons/lo16-action-xml_move_item_down.png new file mode 100644 index 0000000..30e0602 Binary files /dev/null and b/part/icons/lo16-action-xml_move_item_down.png differ diff --git a/part/icons/lo16-action-xml_move_item_up.png b/part/icons/lo16-action-xml_move_item_up.png new file mode 100644 index 0000000..7bb1b68 Binary files /dev/null and b/part/icons/lo16-action-xml_move_item_up.png differ diff --git a/part/icons/lo16-app-kxmleditor.png b/part/icons/lo16-app-kxmleditor.png new file mode 100644 index 0000000..5f8c3f2 Binary files /dev/null and b/part/icons/lo16-app-kxmleditor.png differ diff --git a/part/icons/lo32-app-kxmleditor.png b/part/icons/lo32-app-kxmleditor.png new file mode 100644 index 0000000..be1dac8 Binary files /dev/null and b/part/icons/lo32-app-kxmleditor.png differ diff --git a/part/kxe_treeview.cpp b/part/kxe_treeview.cpp new file mode 100644 index 0000000..f5bd08c --- /dev/null +++ b/part/kxe_treeview.cpp @@ -0,0 +1,909 @@ +/*************************************************************************** + kxe_treeview.cpp - description + ------------------- + begin : Thu Sep 20 2001 + copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team + email : OleBowle@gmx.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "kxe_treeview.h" +#include "kxe_treeviewitem.h" +#include "kxesearchdialog.h" +#include "kxmleditorpart.h" + +#include "kxmleditorfactory.h" +#include "kxeconfiguration.h" +#include "kxetreeviewsettings.h" + +#include +#include +#include +#include +#include +#include +#include + +// include files for Qt +#include "qdom_add.h" +#include +#include +#include +#include +#include +#include + +static const int autoOpenTimeout = 750; + + +KXE_TreeView::KXE_TreeView( KXMLGUIClient * pGUIClient, QWidget * pParent, const char * pszName ) + : KListView(pParent,pszName), + m_pGUIClient(pGUIClient), + m_nBookmarkedItems(0) +{ + setSorting(-1); // no sorting + + addColumn(i18n("Qualified name")); + + setSelectionMode(QListView::Single); + + connect( this, SIGNAL(selectionChanged()), this, SLOT(slotSelectionChanged()) ); + connect( this, SIGNAL(expanded(QListViewItem*)), this, SLOT(slotItemExpanded(QListViewItem*)) ); + + setReadWrite(false); + + m_bDrag = false; + m_pCurrentBeforeDropItem = 0; + m_pDropItem = 0; + + m_autoOpenTimer = new QTimer(this); + connect(m_autoOpenTimer, SIGNAL(timeout()), this, SLOT(slotAutoOpenFolder())); + + // Apply current configuration + slotTreeViewSettingsChanged(); + // and make sure to be informed about its changes. + connect( KXMLEditorFactory::configuration()->treeview(), SIGNAL(sigChanged()), this, SLOT(slotTreeViewSettingsChanged()) ); +} + +void KXE_TreeView::setReadWrite( bool fReadWrite ) +{ + setItemsRenameable( fReadWrite ); + setRenameable( 0, fReadWrite ); + + if ( fReadWrite ) // If the widget enters read/write mode, then enable/disable + { // dropping (according to the configuration data). + setAcceptDrops( KXMLEditorFactory::configuration()->treeview()->enableDropping() ); + viewport()->setAcceptDrops( KXMLEditorFactory::configuration()->treeview()->enableDropping() ); + } + else // If the widget enter read only mode, + { // then disable dropping. + setAcceptDrops( false ); + viewport()->setAcceptDrops( false ); + } +} + +////////////////////////////////////////////////////////////// +// configuration slots +////////////////////////////////////////////////////////////// + +void KXE_TreeView::slotTreeViewSettingsChanged() +{ + setRootIsDecorated( KXMLEditorFactory::configuration()->treeview()->decorateRoot() ); + + if ( KXMLEditorFactory::configuration()->treeview()->elemDisplMode() == KXETreeViewSettings::NoAttributes ) + { + if ( columns() > 1 ) + removeColumn(1); + } + else + { + if ( columns() < 2 ) + addColumn( i18n("Attributes") ); + } + + KXE_TreeViewItem * pItem = static_cast (firstChild()); + while (pItem) + { + pItem->setTexts(); + pItem = pItem->nextItem(); + } + + if ( itemsRenameable() ) // If the widget is in read/write mode, then enable/disable + { // dropping (according to the configuration data). + setAcceptDrops( KXMLEditorFactory::configuration()->treeview()->enableDropping() ); + viewport()->setAcceptDrops( KXMLEditorFactory::configuration()->treeview()->enableDropping() ); + } + +} + +////////////////////////////////////////////////////////////// +// action slots +////////////////////////////////////////////////////////////// + +void KXE_TreeView::editDeselect() +{ + clearSelection(); +} + +void KXE_TreeView::viewNodeUp() +{ + // get selected item from tree view + QListViewItem * pSelItem = selectedItem(); + if ( ! pSelItem ) + { + kdDebug() << "KXE_TreeView::slotViewNodeUp no item selected" << endl; + return; + } + + // get parent item + QListViewItem * pParentItem = pSelItem->parent(); + + // select parent item in tree view + if (pParentItem) + { + setCurrentItem(pParentItem); + ensureItemVisible(pParentItem); + } +} + +void KXE_TreeView::viewExpNode( int nLevel ) +{ + // get selected item from tree view (if any) + QListViewItem * pSelItem = selectedItem(); + if ( ! pSelItem ) + { + kdDebug() << "KXE_TreeView::slotViewExpNode no item selected" << endl; + return; + } + + // expand node + KXE_TreeViewItem * pSelTreeItem = static_cast (pSelItem); + pSelTreeItem->expandSubTree(nLevel); +} + +void KXE_TreeView::viewColNode( int nLevel ) +{ + // get selected item from tree view (if any) + QListViewItem * pSelItem = selectedItem(); + if ( ! pSelItem ) + { + kdDebug() << "KXE_TreeView::slotViewColNode no item selected" << endl; + return; + } + + // expand node + KXE_TreeViewItem * pSelTreeItem = static_cast (pSelItem); + pSelTreeItem->collapseSubTree(nLevel); +} + +void KXE_TreeView::bookmarksToggle() +{ + // get selected item from tree view + KXE_TreeViewItem * pSelItem = static_cast (selectedItem()); + if ( ! pSelItem ) + { + kdDebug() << "KXE_TreeView::bookmarksToggle: no item selected" << endl; + return; + } + + // toggle bookmark on selected item + if(pSelItem->toggleBookmark()) + m_nBookmarkedItems++; + else + m_nBookmarkedItems--; +} + +void KXE_TreeView::bookmarksPrev() +{ + if ( childCount() < 1 ) + { + kdDebug() << "KXE_TreeView::bookmarksPrev: internal error - this tree view is empty" << endl; + return; + } + + // get selected item from tree view + KXE_TreeViewItem * pSelItem = static_cast (selectedItem()); + if ( ! pSelItem ) // If there is no item selected we take + { // the last root items last grand child. + QListViewItem * pTmpItem = firstChild(); // Take first child and + while ( pTmpItem->nextSibling() ) // find last child by + pTmpItem = pTmpItem->nextSibling(); // traversing all childs + + pSelItem = static_cast (pTmpItem); // this is the last root item + while ( pSelItem->lastChild() ) // find its last + pSelItem = pSelItem->lastChild(); // grand child + + if ( pSelItem->isBookmarked() ) // We have to check its + { // bookmarked-status + selectItem(pSelItem); // and select it, in case + return; // it is bookmarked. + } + } + + // Search items above the selected one + while ( (pSelItem = pSelItem->prevItem()) != 0 ) + { + if ( pSelItem->isBookmarked() ) + { + selectItem(pSelItem); + return; + } + } +} + +void KXE_TreeView::bookmarksNext() +{ + if ( childCount() < 1 ) + { + kdDebug() << "KXE_TreeView::bookmarksNext: internal error - this tree view is empty" << endl; + return; + } + + // get selected item from tree view + KXE_TreeViewItem * pSelItem = static_cast (selectedItem()); + if ( ! pSelItem ) + { // If there is no item selected + pSelItem = static_cast (firstChild()); // we take the first root item, + if ( pSelItem->isBookmarked() ) // but we have to check its + { // bookmarked-status + selectItem(pSelItem); // and select it, in case + return; // it is bookmarked. + } + } + + // Search items below the selected one + while ( (pSelItem = pSelItem->nextItem()) != 0 ) + { + if ( pSelItem->isBookmarked() ) + { + selectItem(pSelItem); + return; + } + } +} + +void KXE_TreeView::selectItem( KXE_TreeViewItem * const pItem ) +{ + if ( ! pItem ) + { + kdDebug() << "KXE_TreeView::selectItem: the given pointer is a null pointer" << endl; + return; + } + + setSelected( pItem, true ); + setCurrentItem( pItem ); + ensureItemVisible( pItem ); +} + +bool KXE_TreeView::selectNode( const QDomNode & node ) +{ + if ( node.isNull() ) + { + kdError() << "KXE_TreeView::selectNode: the given node is an empty one" << endl; + return false; + } + + KXE_TreeViewItem * pItem = findCorrespondingItem(node); + + if ( ! pItem ) // can't find the corresponding item + { + kdError() << "KXE_TreeView::selectNode can't find an item to the given node." << endl; + return false; + } + + selectItem(pItem); + return true; +} + +QDomNode * KXE_TreeView::getSelectedNode() const +{ + // get selected item from tree view + QListViewItem * pSelItem = selectedItem(); + if ( ! pSelItem ) + return 0; + + KXE_TreeViewItem * pSelTreeItem = static_cast (pSelItem); + return pSelTreeItem->xmlNode(); +} + +QDomNode * KXE_TreeView::getSpecProcInstrNode(const QString& target) const +{ + KXE_TreeViewItem * pTreeItem = static_cast (firstChild()); + while ( pTreeItem ) + { + if (pTreeItem->xmlNode()->isProcessingInstruction()) + { + QDomProcessingInstruction domProcInstr = pTreeItem->xmlNode()->toProcessingInstruction(); + if(domProcInstr.target() == target) + return pTreeItem->xmlNode(); + } + + pTreeItem = pTreeItem->nextItem(); + } + + return 0; +} + +// Return info, is root element is already created +bool KXE_TreeView::hasRootNode() +{ + KXE_TreeViewItem * pTreeItem = static_cast (firstChild()); + while ( pTreeItem ) + { + if (pTreeItem->xmlNode()->isElement()) + { + return true; + } + + pTreeItem = pTreeItem->nextItem(); + } + + return false; +} + + +QString KXE_TreeView::getSelectedPath() const +{ + // get selected item from tree view + QListViewItem * pSelItem = selectedItem(); + if ( ! pSelItem ) + return QString(); + + KXE_TreeViewItem * pSelTreeItem = static_cast (pSelItem); + return domTool_getPath( * pSelTreeItem->xmlNode() ); +} + +void KXE_TreeView::contentsMousePressEvent( QMouseEvent * pEvent ) +{ + KListView::contentsMousePressEvent(pEvent); + + if ( pEvent->button() == RightButton ) + { + QString szMenuName; + + QListViewItem * pItem = itemAt( contentsToViewport(pEvent->pos()) ); + if (pItem) + { + KXE_TreeViewItem * pTreeItem = static_cast (pItem); + switch( pTreeItem->xmlNode()->nodeType() ) + { + case QDomNode::ElementNode: + szMenuName = "popupXmlElement"; + break; + case QDomNode::TextNode: + case QDomNode::CDATASectionNode: + case QDomNode::CommentNode: + szMenuName = "popupXmlContent"; + break; + case QDomNode::ProcessingInstructionNode: + szMenuName = "popupXmlProcInstr"; + break; + default: + kdDebug() << "KXE_TreeView::contentsMousePressEvent unknown item type" << endl; + return; + } + } + else + szMenuName = "popupXmlTree"; + + emit sigContextMenuRequested( szMenuName, QCursor::pos() ); + return; + } + + //--- Drag & Drop ------------------------------------------------------ + QPoint p(contentsToViewport(pEvent->pos())); + QListViewItem *i = itemAt(p); + + if(pEvent->button() == LeftButton && i) + { // if the user clicked into the root decoration of the item, don't try to start a drag! + if(p.x() > header()->cellPos(header()->mapToActual(0)) + + treeStepSize() * ( i->depth() + (rootIsDecorated() ? 1 : 0)) + itemMargin() || + p.x() < header()->cellPos(header()->mapToActual(0))) + { + m_dragPos = pEvent->pos(); + m_bDrag = true; + } + } +} + +void KXE_TreeView::slotSelectionChanged() +{ + KXE_TreeViewItem * pItem = static_cast (selectedItem()); + + if ( ! pItem ) + emit sigSelectionCleared(hasRootNode()); + else + { + QDomNode selectedNode = * ( pItem->xmlNode() ); // uses QDomNode copy constructor + + // choose appropriate object kind + switch ( selectedNode.nodeType() ) + { + case QDomNode::ElementNode: + emit sigSelectionChanged( selectedNode.toElement()); + break; + + case QDomNode::TextNode: + case QDomNode::CDATASectionNode: + case QDomNode::CommentNode: + emit sigSelectionChanged( selectedNode.toCharacterData()); + break; + + case QDomNode::ProcessingInstructionNode: + emit sigSelectionChanged( selectedNode.toProcessingInstruction()); + break; + + default: + kdDebug() << "KXE_TreeView::slotSelectionChanged unknown object type selected" << endl; + return; + } + } +} + + +void KXE_TreeView::slotItemExpanded( QListViewItem * pItem ) +{ + KXE_TreeViewItem * pTreeViewItem = static_cast (pItem); + pTreeViewItem->ensureGrandChildItemsCreated(); +} + + +////////////////////////////////////////////////////////////// +// update slots +////////////////////////////////////////////////////////////// + +void KXE_TreeView::updateNodeCreated( const QDomNode & node ) +{ + if ( node.isNull() ) + { + kdError() << "KXE_TreeView::slotUpdateNodeCreated the given node is an empty one." << endl; + return; + } + + KXE_TreeViewItem * pNewItem; + if ( node.parentNode().isDocument() ) // the new nodes parent is the document itself, + { + // so we have to create a root item. + // Now it depends: either it's a processing instruction, or element + if (node.isProcessingInstruction()) + // Tree looks much nicer if root processing instructions are ont the top... + { + QDomNode *pNode = getSpecProcInstrNode("xml"); + if (pNode) + pNewItem = new KXE_TreeViewItem( node, this,findCorrespondingItem(*pNode)); + else + pNewItem = new KXE_TreeViewItem( node, this); + } + else + // ...and root element is placed at the bottom. + pNewItem = new KXE_TreeViewItem( node, this,lastChild()); +// pNewItem = new KXE_TreeViewItem( node, this); + + if ( ! rootIsDecorated() ) + pNewItem->setOpen(true); + } + else + { + if ( node.parentNode().isNull() ) + { + kdError() << "KXE_TreeView::slotUpdateNodeCreated the given node has no parent node (but should)." << endl; + return; + } + + // To create the new item, we need (1st) the item corresponding to the parent node of the given one. + QDomNode parentNode = node.parentNode(); + // Because the currently selected item is very likely (in many cases) the correct one, try it first. + KXE_TreeViewItem * pParentItem = static_cast (selectedItem()); + if ( (!pParentItem) || ( *(pParentItem->xmlNode()) != parentNode ) ) + { // no strike :-( + pParentItem = findCorrespondingItem(parentNode); // do it the "long" way + } + + if ( ! pParentItem ) // can't find the corresponding item + { + kdError() << "KXE_TreeView::slotUpdateNodeCreated can't find an item to the given nodes parent node." << endl; + return; + } + + // Now we need (2nd) the item corresponding to the previous sibling of the given one, + // because, the new item has to be inserted behind the given one. + QDomNode prevNode = node.previousSibling(); + if ( prevNode.isNull() ) + { // it seems to be the first child node, so create a first child item + pNewItem = new KXE_TreeViewItem( node, pParentItem ); + } + else + { + KXE_TreeViewItem * pPrevItem = findCorrespondingItem(prevNode); + if ( ! pParentItem ) // can't find the corresponding item :-( + { + kdError() << "KXE_TreeView::slotUpdateNodeCreated can't find an item to the given nodes previous sibling." << endl; + return; + } + // everything's alright, let's create the new item + pNewItem = new KXE_TreeViewItem( node, pParentItem, pPrevItem ); + } + + } + + setSelected( pNewItem, true ); + ensureItemVisible( pNewItem ); +} + +void KXE_TreeView::updateNodeChanged( const QDomNode & node ) +{ + if ( node.isNull() ) + { + kdError() << "KXE_TreeView::slotUpdateNodeChanged the given node is an empty one." << endl; + return; + } + + // To change the item, we have to find it. + // Because the currently selected item is very likely (in many cases) the correct one, try it first. + KXE_TreeViewItem * pItem = static_cast (selectedItem()); + if ( (!pItem) || ( *(pItem->xmlNode()) != node ) ) // no strike :-( + pItem = findCorrespondingItem(node); // do it the "long" way + + if ( ! pItem ) // can't find the corresponding item + { + kdError() << "KXE_TreeView::slotUpdateNodeChanged can't find an item to the given node." << endl; + return; + } + + pItem->setTexts(); // update the item + + setSelected( pItem, true ); + ensureItemVisible( pItem ); +} + +void KXE_TreeView::updateNodeDeleted( const QDomNode & node ) +{ + if ( node.isNull() ) + { + kdError() << "KXE_TreeView::slotUpdateNodeDeleted the given node is an empty one." << endl; + return; + } + + // To remove the item, we have to find it. + // Because the currently selected item is very likely (in many cases) the correct one, try it first. + KXE_TreeViewItem * pItem = static_cast (selectedItem()); + if ( (!pItem) || ( *(pItem->xmlNode()) != node ) ) // no strike :-( + pItem = findCorrespondingItem(node); // do it the "long" way + + if ( ! pItem ) // can't find the corresponding item + { + kdError() << "KXE_TreeView::slotUpdateNodeDeleted can't find an item to the given node." << endl; + return; + } + + clearSelection(); + + delete pItem; + + emit sigSelectionCleared(hasRootNode()); +} + +void KXE_TreeView::updateNodeMoved( const QDomNode & node ) +{ + if ( node.isNull() ) + { + kdError() << "KXE_TreeView::slotUpdateNodeMoved the given node is an empty one." << endl; + return; + } + + // To move the item, we have to find it. + // Because the currently selected item is very likely (in many cases) the correct one, try it first. + KXE_TreeViewItem * pItem = static_cast (selectedItem()); + if ( (!pItem) || ( *(pItem->xmlNode()) != node ) ) // no strike :-( + pItem = findCorrespondingItem(node); // do it the "long" way + + if ( ! pItem ) // can't find the corresponding item + { + kdError() << "KXE_TreeView::slotUpdateNodeMoved can't find an item to the given node." << endl; + return; + } + + // Now we can move the item (of the moved node). + // We have to differenciate between the following 2 cases. + if ( node.previousSibling().isNull() ) + { + // The node does not has a previous sibling. This means, it has been moved + // to be its parent first child. In this case, we have to find the tree + // view item of the node's next sibling to swap them. + // It's very likely the previous sibling of the item corresponding to the + // moved node. + KXE_TreeViewItem * pOldPrevItem = pItem->prevSibling(); + // Was it really? + if ( ! pOldPrevItem || ( *(pOldPrevItem->xmlNode()) != node.nextSibling() ) ) + // It wasn't (how can it be?) - we have to find it using the "long" way. + pOldPrevItem = findCorrespondingItem( node.nextSibling() ); + + if ( ! pOldPrevItem ) // something went wrong + { + kdError() << "KXE_TreeView::slotUpdateNodeMoved can't find the item to the given node's next sibling." << endl; + return; + } + + // Now we can swap them (make the old previous item the new next item of + // the moved node's item). + pOldPrevItem->moveItem( pItem ); + } + else + { + // The node has a previous sibling. In this case we have to find the + // corresponding tree view item to swap it with the item corresponding to + // the moved node. + KXE_TreeViewItem * pNewPrevItem = findCorrespondingItem( node.previousSibling() ); + if ( ! pNewPrevItem ) + { + kdError() << "KXE_TreeView::slotUpdateNodeMoved can't find the new prev.item to the given nodes prev.node." << endl; + return; + } + + // swap them (move the moved node's item after the previous sibling's item) + pItem->moveItem( pNewPrevItem ); + } + + setSelected( pItem, true ); + ensureItemVisible( pItem ); +} + +void KXE_TreeView::updateClear() +{ + clear(); +} + +void KXE_TreeView::rename( QListViewItem * pItem, int nColumn ) +{ + if ( nColumn != 0 ) // inplace editing only + return; // for the first column + + KXE_TreeViewItem * pXMLItem = static_cast (pItem); + if ( pXMLItem->xmlNode()->isElement() ) // inplace-renaming only for items representing XML elements + KListView::rename( pItem, nColumn ); // inplace-renaming via base class functionality + + else if(pXMLItem->xmlNode()->isCharacterData()) // launch dialog for editing text nodes + (dynamic_cast (m_pGUIClient))->slotXmlCharDataEdit(); + + else if(pXMLItem->xmlNode()->isProcessingInstruction()) // launch dialog for editing proc.instr. + (dynamic_cast (m_pGUIClient))->slotXmlProcInstrEdit(); +} + +////////////////////////////////////////////////////////////// +// misc functions +////////////////////////////////////////////////////////////// + +KXE_TreeViewItem * KXE_TreeView::findCorrespondingItem( const QDomNode & node ) +{ + KXE_TreeViewItem * pItem = static_cast (firstChild()); + while ( pItem ) + { + if ( *(pItem->xmlNode()) == node ) + return pItem; + pItem = pItem->nextItem(); + } + + return 0; +} + +////////////////////////////////////////////////////////////// +// Drag & Drop +////////////////////////////////////////////////////////////// + +/** Overrides KListView::contentsMouseMoveEvent */ +void KXE_TreeView::contentsMouseMoveEvent(QMouseEvent *e) +{ + KListView::contentsMouseMoveEvent(e); + + // exit, if dragging is disabled + if ( ! KXMLEditorFactory::configuration()->treeview()->enableDragging() ) + return; + + if(!m_bDrag || (e->pos() - m_dragPos).manhattanLength() <= KGlobalSettings::dndEventDelay()) + return; + + m_bDrag = false; + + QListViewItem *item = itemAt(contentsToViewport(m_dragPos)); + + if(!item || !item->isSelectable()) + return; + + // copy item into clipboard + KXE_TreeViewItem *pXmlTreeItem = static_cast (item); + QTextDrag *pDrag = (dynamic_cast (m_pGUIClient))->copyNode(pXmlTreeItem->xmlNode()); + + + // Start a drag + const QPixmap *pix = item->pixmap(0); + if(pix && pDrag->pixmap().isNull()) + { QPoint hotspot(pix->width() / 2, pix->height() / 2); + pDrag->setPixmap(*pix, hotspot); + } + + pDrag->drag(); +} + +/** Overrides KListView::contentsMouseReleaseEvent */ +void KXE_TreeView::contentsMouseReleaseEvent(QMouseEvent *e) +{ + KListView::contentsMouseReleaseEvent(e); + m_bDrag = false; +} + +/** Overrides QScrollView::contentsDragEnterEvent */ +void KXE_TreeView::contentsDragEnterEvent(QDragEnterEvent *e) +{ + m_pDropItem = 0; + m_pCurrentBeforeDropItem = selectedItem(); + + // Save the available formats + m_lstDropFormats.clear(); + for(int i = 0; e->format(i); i++) + { if(*(e->format(i))) + { m_lstDropFormats.append(e->format(i)); + } + } +} + +/** Overrides QScrollView::contentsDragMoveEvent */ +void KXE_TreeView::contentsDragMoveEvent(QDragMoveEvent *e) +{ + QListViewItem *item = itemAt(contentsToViewport(e->pos())); + + // Accept drops on the background, if Texts + if(!item && (m_lstDropFormats.contains("text/"))) + { m_pDropItem = 0; + e->acceptAction(); + if(selectedItem()) + setSelected(selectedItem(), false); // no item selected + return; + } + + if(!item || !item->isSelectable()) + { m_pDropItem = 0; + m_autoOpenTimer->stop(); + e->ignore(); + return; + } + + e->acceptAction(); + + setSelected(item, true); + + if(item != m_pDropItem ) + { m_autoOpenTimer->stop(); + m_pDropItem = item; + m_autoOpenTimer->start(autoOpenTimeout); + } +} + +/** Overrides QScrollView::contentsDragLeaveEvent */ +void KXE_TreeView::contentsDragLeaveEvent(QDragLeaveEvent *e) +{ + e=e; + // Restore the current item to what it was before the dragging (#17070) + if(m_pCurrentBeforeDropItem) + setSelected(m_pCurrentBeforeDropItem, true); + else + setSelected(m_pDropItem, false); // no item selected + + m_pCurrentBeforeDropItem = 0; + m_pDropItem = 0; + m_lstDropFormats.clear(); +} + +/** Overrides QScrollView::contentsDropEvent */ +void KXE_TreeView::contentsDropEvent(QDropEvent *pDropEvent) +{ + m_autoOpenTimer->stop(); + + drop(selectedItem(), pDropEvent); +} + +/** Called, when m_autoOpenTimer timeout occured */ +void KXE_TreeView::slotAutoOpenFolder() +{ + m_autoOpenTimer->stop(); + + if(!m_pDropItem || m_pDropItem->isOpen()) + return; + + m_pDropItem->setOpen( true ); + m_pDropItem->repaint(); +} + +/** Drop or paste text into item */ +bool KXE_TreeView::drop(QListViewItem *pItem, QDropEvent *pDropEvent) +{ + KXE_TreeViewItem* pTreeItem = 0; + if(pItem) + pTreeItem = static_cast (pItem); + + QDomNode *pTargetNode = pTreeItem->xmlNode(); + + // First, make check, if moved item is not moved to their children + if((pDropEvent->source() == this) && (pDropEvent->action() == QDropEvent::Move)) + { // make check, if moved item is not moved to itself + if(m_pCurrentBeforeDropItem && pTreeItem && (m_pCurrentBeforeDropItem == pTreeItem)) + { return false; + } + + if(m_pCurrentBeforeDropItem && pTreeItem && + static_cast (m_pCurrentBeforeDropItem)->isMyChildren(pTreeItem)) + { KMessageBox::sorry(0, i18n("An XML element can't be moved to its own subtree.")); + return false; + } + + if (pTreeItem->xmlNode()->isProcessingInstruction()) + { + KMessageBox::sorry(0, i18n("An XML node can't be moved in a processing instruction.")); + return false; + } + + QDomNode * pNode = static_cast (m_pCurrentBeforeDropItem)->xmlNode(); + if (pNode->isProcessingInstruction()) + { + QDomProcessingInstruction domProcInstr = pNode->toProcessingInstruction(); + + if(domProcInstr.target() == "xml") + { KMessageBox::sorry(0, i18n("This processing instruction cannot be moved !")); + return false; + } + } + } + + //-- If Move from same instance of this widget + if((pDropEvent->source() == this) && (pDropEvent->action() == QDropEvent::Move) && (m_pCurrentBeforeDropItem) && pTargetNode->isElement()) + { + // remove source item + QDomNode * pSourceNode = static_cast (m_pCurrentBeforeDropItem)->xmlNode(); + QDomElement domTargetElement = pTargetNode->toElement(); + + if((dynamic_cast (m_pGUIClient))->dropMoveNode(domTargetElement, *pSourceNode)) + { + pDropEvent->acceptAction(); + return true; + } + } + else + { + //-- If Copy, do standart Paste function + if((dynamic_cast (m_pGUIClient))->pasteNode(pTargetNode, pDropEvent)) + { + pDropEvent->acceptAction(); + return true; + } + } + return false; +} + + +// +// returns last child on the tree (top-level) +// +KXE_TreeViewItem* KXE_TreeView::lastChild() +{ + QListViewItem* pItem = firstChild(); + if (pItem && pItem->nextSibling()) + do + pItem = pItem->nextSibling(); + while (pItem->nextSibling()); + + // here we have it... + return (KXE_TreeViewItem*) pItem; +} + +void KXE_TreeView::keyPressEvent(QKeyEvent *e) +{ + KListView::keyPressEvent(e); + emit sigKeyPressed(e); +} diff --git a/part/kxe_treeview.h b/part/kxe_treeview.h new file mode 100644 index 0000000..0ba2c86 --- /dev/null +++ b/part/kxe_treeview.h @@ -0,0 +1,235 @@ +/*************************************************************************** + kxe_treeview.h - description + ------------------- + begin : Thu Sep 20 2001 + copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team + email : OleBowle@gmx.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef KXE_TREEVIEW_H +#define KXE_TREEVIEW_H + +#include +#include + +class KXESearchDialog; + +class QDomDocument; +class QDomNode; +class QDomElement; +class QDomCharacterData; +class QDomProcessingInstruction; + +class QMouseEvent; +class QTimer; +class QKeyEvent; +class KXMLGUIClient; +class KXE_TreeViewItem; + +/** + * This is a listview, which displays the XML tree structure. + * @short shows XML tree + */ +class KXE_TreeView : public KListView +{ + Q_OBJECT + +public: + KXE_TreeView( KXMLGUIClient * pGUIClient, QWidget * pParent = 0, const char * pszName = 0 ); + + /** Changes the behaviour of this view to readonly or readwrite. */ + void setReadWrite( bool fReadWrite ); + + /** Selects the given item. */ + void selectItem( KXE_TreeViewItem * const pItem ); + + /** Selects the item corresponding to the given node. + * Returns true on success, false otherwise. */ + bool selectNode( const QDomNode & node ); + + /** Returns the a pointer to the selected items node or a null pointer (if no item is selected). */ + QDomNode * getSelectedNode() const; + + /** Returns the a pointer to the special processing instruction or a null pointer for (if no item is exists). */ + QDomNode * getSpecProcInstrNode(const QString& target) const; + + /** Returns the selected items path or an empty string, if no item is selected. */ + QString getSelectedPath() const; + + /** Returns true, if this tree view contains bookmarked tree items and false otherwise. */ + bool containsBookmarkedItems() const { return (m_nBookmarkedItems>0); } + + /** Drop or paste text into item */ + bool drop(QListViewItem *, QDropEvent *); + + /** toggles bookmark on the selected item */ + void bookmarksToggle(); + + /** searches for the next bookmarked item */ + void bookmarksPrev(); + + /** searches for the previous bookmarked item */ + void bookmarksNext(); + + /** deselects currently selected item */ + void editDeselect(); + + /** Selects the selected item's parent item. */ + void viewNodeUp(); + + /** Expands the selected tree item's subtree to the given level (see @ref KXE_TreeViewItem::expandSubTree). */ + void viewExpNode( int nLevel ); + + /** Collapses the selected tree item's subtree to the given level (see @ref KXE_TreeViewItem::collapseSubTree). */ + void viewColNode( int nLevel ); + + /** + * Creates new item(s) to the given node (and its child nodes) + * and inserts it (or them) in the tree. + */ + void updateNodeCreated( const QDomNode & node ); + + /** Changes the item corresponding to the given node. */ + void updateNodeChanged( const QDomNode & node ); + + /** Removes the item corresponding to the given node. */ + void updateNodeDeleted( const QDomNode & node ); + + /** Moves the item corresponding to the given node. */ + void updateNodeMoved( const QDomNode & node ); + + /** Clears the whole tree. */ + void updateClear(); + + /** + * Handles inplace-renaming of items, because in our case + * only items representing XML elements are to be renameable. + * For the actual renaming of the items text, the base + * class functionality is used and the signal + * @ref sigItemRenamedInplace emitted. + */ + virtual void rename( QListViewItem * pItem, int nColumn ); + + /** Returns info, is root element is already created */ + bool hasRootNode(); + /** Returns last top-level child on the tree. If there are no chold in the tree, null is returned. */ + KXE_TreeViewItem* lastChild(); + +public slots: + + // configuration slots + ////////////////////////////////////////////////////////////// + + /** + * Changes this tree view's settings according to the current + * configuration. + */ + void slotTreeViewSettingsChanged(); + +signals: + /** emitted, when no item is selected */ + void sigSelectionCleared(bool); + + /** emitted, when an XML element item is selected */ + void sigSelectionChanged( const QDomElement & ); + + /** emitted, when an XML Content item is selected */ + void sigSelectionChanged( const QDomCharacterData & ); + + /** emitted, when an XML proc.instr. item is selected */ + void sigSelectionChanged( const QDomProcessingInstruction & ); + + /** + * Signals the change of bookmark status. + * true - item(s) bookmarked + * false - no item bookmarked + */ + void sigNewBookmarkStatus( bool fStatus ); + + /** Emitted, when a context menu is requested */ + void sigContextMenuRequested( const QString & szMenuName, const QPoint & pos ); + /** Emitted when user presses a key. */ + void sigKeyPressed(QKeyEvent* e); + +protected: + /** if RMB shows the popupmenu corresponding to the selected item */ + void contentsMousePressEvent( QMouseEvent * ); + + /** Finds the corresponding treeview item to the given node. */ + KXE_TreeViewItem * findCorrespondingItem( const QDomNode & node ); + + /** Overrides KListView::contentsMouseReleaseEvent */ + void contentsMouseReleaseEvent(QMouseEvent *); + + /** Overrides KListView::contentsMouseMoveEvent */ + void contentsMouseMoveEvent(QMouseEvent *); + + /** Overrides QScrollView::contentsDragEnterEvent */ + void contentsDragEnterEvent(QDragEnterEvent *); + + /** Overrides QScrollView::contentsDragMoveEvent */ + void contentsDragMoveEvent(QDragMoveEvent *); + + /** Overrides QScrollView::contentsDragLeaveEvent */ + void contentsDragLeaveEvent(QDragLeaveEvent *); + + /** Overrides QScrollView::contentsDropEvent */ + void contentsDropEvent(QDropEvent *); + virtual void keyPressEvent(QKeyEvent *e); + +protected slots: + /** Checks, which type of item was selected an emits the corresponding signal. */ + void slotSelectionChanged(); + /** + * Ensures that the expanded item's grandchild items are created. + * This is very important for the "create items on demand" mode. But even in + * "create all items while loading" mode, this function has to be executed, + * because KXMLEditor could have been in "create items on demand" mode during + * the opening of the document. + * + * To be connected to the signal QListView::expanded(QListViewItem*). + */ + void slotItemExpanded( QListViewItem * ); + +private slots: + + /** Called, when m_autoOpenTimer timeout occured */ + void slotAutoOpenFolder(); + +protected: + + /** the GUI client, needed for the popupmenus */ + KXMLGUIClient * m_pGUIClient; + + /** number of bookmarked items */ + unsigned int m_nBookmarkedItems; + + /** True if drag&drop operation started, otherwise is false */ + bool m_bDrag; + + /** Contain mouse position of drag operation */ + QPoint m_dragPos; + + /** The item that was current before the drag-enter event happened */ + QListViewItem *m_pCurrentBeforeDropItem; + + /** The item we are moving the mouse over (during a drag) */ + QListViewItem *m_pDropItem; + + /** List of avalilable drop formats */ + QStrList m_lstDropFormats; + + /** Timer for counting time to auto open fselected folder while drag */ + QTimer *m_autoOpenTimer; +}; + +#endif diff --git a/part/kxe_treeviewitem.cpp b/part/kxe_treeviewitem.cpp new file mode 100644 index 0000000..0107bee --- /dev/null +++ b/part/kxe_treeviewitem.cpp @@ -0,0 +1,330 @@ +/*************************************************************************** + kxe_treeviewitem.cpp - description + ------------------- + begin : Wed Nov 21 2001 + copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team + email : lvanek@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "kxe_treeviewitem.h" + +#include "kxmleditorfactory.h" +#include "kxeconfiguration.h" +#include "kxetreeviewsettings.h" + +#include "qdom_add.h" + +#include + +#include +#include +#include + +KXE_TreeViewItem::KXE_TreeViewItem( const QDomNode & xmlNode, QListViewItem * pParent ) + : QListViewItem(pParent), + m_xmlNode(xmlNode), + m_pPrevSibling(0), + m_bBookmarked(false), + m_bChildsCreated(false), + m_bGrandChildsCreated(false) +{ + init(); + initChilds(); +} + +KXE_TreeViewItem::KXE_TreeViewItem( const QDomNode & xmlNode, KListView * pParent, QListViewItem* pAfter) + : QListViewItem(pParent,pAfter), + m_xmlNode(xmlNode), + m_pPrevSibling(0), + m_bBookmarked(false), + m_bChildsCreated(false), + m_bGrandChildsCreated(false) +{ + init(); + initChilds(); +} + +KXE_TreeViewItem::KXE_TreeViewItem( const QDomNode & xmlNode, QListViewItem * pParent, QListViewItem * pAfter ) + : QListViewItem( pParent, pAfter ), + m_xmlNode(xmlNode), + m_pPrevSibling(0), + m_bBookmarked(false), + m_bChildsCreated(false), + m_bGrandChildsCreated(false) +{ + init(); + initChilds(); +} + +KXE_TreeViewItem::~KXE_TreeViewItem() +{ + // inform the next sibling (if there's any) about destroying this item (as its previous sibling) + KXE_TreeViewItem * pNextItem = static_cast (nextSibling()); + if ( pNextItem ) + { pNextItem->setPrevSibling(m_pPrevSibling); + } +} + +void KXE_TreeViewItem::init() +{ + // A tree view item can only be in-place renameable, if it represents an XML element + // (the final check occurs in KXE_TreeViewItem::startRename). + if ( m_xmlNode.isElement() ) + setRenameEnabled( 0, true ); + + // inform the next sibling (if there's any) about this item (as its previous sibling) + KXE_TreeViewItem * pNextItem = static_cast (nextSibling()); + if ( pNextItem ) + pNextItem->setPrevSibling(this); + + setPixmap(0, domTool_getIconForNodeType(m_xmlNode.nodeType(), false)); + + if ( domTool_getLevel(m_xmlNode) < (unsigned int)KXMLEditorFactory::configuration()->treeview()->dfltExpLevel() ) + setOpen(true); + + setTexts(); +} + +void KXE_TreeViewItem::setTexts() +{ + switch ( m_xmlNode.nodeType() ) + { + case QDomNode::ElementNode: + + setText( 0, m_xmlNode.toElement().nodeName() ); + + if ( KXMLEditorFactory::configuration()->treeview()->elemDisplMode() == KXETreeViewSettings::NoAttributes ) + setText( 1, QString() ); + else + { + // parse all attributes to fill the second column + QString str2ndCol; + for ( uint i=0; i < m_xmlNode.toElement().attributes().length(); i++ ) + { + if ( i > 0 ) + str2ndCol += ", "; + str2ndCol += m_xmlNode.toElement().attributes().item(i).toAttr().name(); + if ( KXMLEditorFactory::configuration()->treeview()->elemDisplMode() == KXETreeViewSettings::NamesAndValues ) + str2ndCol += '=' + m_xmlNode.toElement().attributes().item(i).toAttr().value(); + } + setText( 1, str2ndCol ); + } + break; + + case QDomNode::TextNode: + case QDomNode::CDATASectionNode: + case QDomNode::CommentNode: + { + // set name + QString strText = m_xmlNode.toCharacterData().data(); + strText = strText.replace( QRegExp("\n"), " " ); // replace every newline by a space + strText = strText.replace( QRegExp("\t"), "" ); // removes every tab + strText = strText.replace( QRegExp("\r"), "" ); // removes every return + strText = strText.simplifyWhiteSpace(); + if( strText.length() > 30 ) // reduce name length, if necessary + strText = strText.left(30) + "..."; + setText( 0, strText ); + + break; + } + + case QDomNode::ProcessingInstructionNode: + + setText( 0, m_xmlNode.toProcessingInstruction().target() ); + break; + + default: + kdDebug() << "KXE_TreeViewItem::init: unknown node type (" << m_xmlNode.nodeType() << ")" << endl; + } +} + +void KXE_TreeViewItem::initChilds() +{ + if ( ! KXMLEditorFactory::configuration()->treeview()->createItemsOnDemand() || + ( ! m_bChildsCreated && + ( ! parent() || ( parent() && parent()->isOpen() ) ) + ) + ) + ensureChildItemsCreated(); +} + +bool KXE_TreeViewItem::toggleBookmark() +{ + m_bBookmarked = ! m_bBookmarked; + + setPixmap(0, domTool_getIconForNodeType(m_xmlNode.nodeType(), m_bBookmarked)); + + return m_bBookmarked; +} + +KXE_TreeViewItem * KXE_TreeViewItem::lastChild() const +{ + // take the first child + QListViewItem * pTmpItem = firstChild(); + // if there are no childs return 0 + if ( ! pTmpItem ) + return 0; + + QListViewItem * pTmpItem2; + while ( (pTmpItem2 = pTmpItem->nextSibling()) != 0 ) // traversing all childs + { + pTmpItem = pTmpItem2; + } + + return static_cast (pTmpItem); +} + +KXE_TreeViewItem * KXE_TreeViewItem::prevItem() +{ + if ( m_pPrevSibling ) // if there is a prev. sibling + { // return its last grand child (if there is any) + KXE_TreeViewItem * pPrevItem = m_pPrevSibling; + KXE_TreeViewItem * pTmpItem; + while ( (pTmpItem=pPrevItem->lastChild()) ) + pPrevItem = pTmpItem; + return pPrevItem; + } + else // if there is no prev. sibling, + return static_cast (parent()); // return this' parent (if there is any) +} + +KXE_TreeViewItem * KXE_TreeViewItem::nextItem() +{ + // checking for a child + QListViewItem * pTmp = firstChild(); + if (pTmp) + return static_cast (pTmp); + + // there is no child -> checking for the next sibling + pTmp = nextSibling(); + if (pTmp) + return static_cast (pTmp); + + // there is no next sibling -> checking for parents' next sibling(s) + QListViewItem * pParent = parent(); + while (pParent) + { + pTmp = pParent->nextSibling(); + if (pTmp) + return static_cast (pTmp); + pParent = pParent->parent(); + } + return 0; +} + +void KXE_TreeViewItem::expandSubTree( int iLevel ) +{ + setOpen(true); // expand this item + + if ( iLevel == 0 ) // return, if we are deep enough + return; + + // expand childs (recursive) + int iNewLevel = ( iLevel == -1 ) ? -1 : iLevel-1; + KXE_TreeViewItem * pChild = static_cast ( firstChild() ); + while ( pChild ) + { + pChild->expandSubTree(iNewLevel); + pChild = static_cast ( pChild->nextSibling() ); + } +} + +void KXE_TreeViewItem::collapseSubTree( int iLevel ) +{ + if ( iLevel < 0 ) + { + kdDebug() << "KXE_TreeViewItem::collapseSubTree: wrong level given (iLevel=" << iLevel << ")" << endl; + return; + } + + int iNewLevel; + if (iLevel==0) // collapse this item, + { // because we are deep enough + setOpen(false); + iNewLevel = 0; + } + else + iNewLevel = iLevel - 1; + + // collapsing in childs (recursive) + KXE_TreeViewItem * pChild = static_cast ( firstChild() ); + while ( pChild ) + { + pChild->collapseSubTree( iNewLevel ); + pChild = static_cast ( pChild->nextSibling() ); + } +} + +/** Test, if item in parameter is my direct or indirect child item */ +bool KXE_TreeViewItem::isMyChildren(const KXE_TreeViewItem *pTestItem) +{ + KXE_TreeViewItem* pChildXmlTreeItem = (KXE_TreeViewItem*) firstChild(); + while(pChildXmlTreeItem) + { if(pChildXmlTreeItem == pTestItem) + return true; + + // test child item childrens + if(pChildXmlTreeItem->isMyChildren(pTestItem)) + return true; + + pChildXmlTreeItem = (KXE_TreeViewItem*) pChildXmlTreeItem->nextSibling(); + } + return false; +} + + +void KXE_TreeViewItem::ensureChildItemsCreated() +{ + if ( ! m_bChildsCreated ) + { + QDomNode tmpNode = m_xmlNode.lastChild(); + + while ( ! tmpNode.isNull() ) + { + new KXE_TreeViewItem( tmpNode, this ); + tmpNode = tmpNode.previousSibling(); + } + + m_bChildsCreated = true; + } +} + + +void KXE_TreeViewItem::ensureGrandChildItemsCreated() +{ + if ( ! m_bGrandChildsCreated ) + { + // ensure, that all child items of this item are created + if ( ! m_bChildsCreated ) + ensureChildItemsCreated(); + + // Iterate over all children now and ensure their child items + // (this' grandchildrens) are created. + KXE_TreeViewItem * pChild = static_cast ( firstChild() ); + while ( pChild ) + { + pChild->ensureChildItemsCreated(); + pChild = static_cast ( pChild->nextSibling() ); + } + + m_bGrandChildsCreated = true; + } +} + +void KXE_TreeViewItem::startRename( int iCol ) +{ + // If the given column is set to be in-place renameable in this item's view, + // we can start renaming in-place. + // Remember: This function is only reached for items representing XML elements. + if ( (reinterpret_cast ( listView() ))->isRenameable( iCol ) ) + QListViewItem::startRename( iCol ); +} diff --git a/part/kxe_treeviewitem.h b/part/kxe_treeviewitem.h new file mode 100644 index 0000000..c24b99f --- /dev/null +++ b/part/kxe_treeviewitem.h @@ -0,0 +1,125 @@ +/*************************************************************************** + kxe_treeviewitem.h - description + ------------------- + begin : Wed Nov 21 2001 + copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team + email : lvanek@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef KXE_TREEVIEWITEM_H +#define KXE_TREEVIEWITEM_H + +#include +#include +#include + +class KListView; + +/** + * This is a tree item, which represents one XML node (see @ref QDomNode and its childclasses). + * @short tree item + * @author The KXMLEditor Team + */ +class KXE_TreeViewItem : public QListViewItem +{ + public: + + KXE_TreeViewItem( const QDomNode & xmlNode, KListView * pParent, QListViewItem* pAfter=NULL); + KXE_TreeViewItem( const QDomNode & xmlNode, QListViewItem * pParent ); + KXE_TreeViewItem( const QDomNode & xmlNode, QListViewItem * pParent, QListViewItem * pAfter ); + ~KXE_TreeViewItem(); + + /** + * (Re)sets the texts of the columns of this listitem + * depending on type of corresponding XML node and + * element display mode, which is stored in the configuration + * (@ref KXETreeViewSettings::elemDisplMode). + */ + void setTexts(); + + /** Returns the corresponding XML node, e.g. the XML node represented by this tree item. */ + QDomNode * xmlNode() { return & m_xmlNode; } + + /** Returns true, if this tree item is bookmarked (false otherwise). */ + bool isBookmarked() const { return m_bBookmarked; } + + /** Changes this items bookmark status (see @ref KXE_TreeViewItem::m_bBookmarked) and returns the new one. */ + bool toggleBookmark(); + + /** Returns this items last child or a null pointer if there are no childs at all. */ + KXE_TreeViewItem * lastChild() const; + + /** Sets this items previous sibling. */ + void setPrevSibling( KXE_TreeViewItem * const pPrevSibling ) { m_pPrevSibling = pPrevSibling; } + + /** Returns this items previous sibling. */ + KXE_TreeViewItem * prevSibling() const { return m_pPrevSibling; } + + /** + * Does the same like @ref QListViewItem::itemAbove but the parent items doesn't need to be open. + * Returns this items previous siblings last grand child, if there is one. + * Otherwise it returns this items previous sibling or, + * if there are no sibling above, it returns this items parent or + * a null pointer (if there is no parent). + */ + KXE_TreeViewItem * prevItem(); + + /** + * Does the same like @ref QListViewItem::itemBelow but the parent items doesn't need to be open. + * Returns a pointer to the next item of this or a null pointer if this is the last item. + * This will be it's first child, + * if there are no childs, it will be the next sibling + * and if there are no siblings below, it will be this' parents next sibling ... + */ + KXE_TreeViewItem * nextItem(); + + /** Expands this items child tree up to the given level or expands the entire child tree, if iLevel == -1. */ + void expandSubTree( int iLevel = -1 ); + + /** Collapses this items child tree to the given level or collapses the entire child tree, if iLevel == 0. */ + void collapseSubTree( int iLevel = 0 ); + + /** Test, if item in parameter is my direct or indirect child item */ + bool isMyChildren(const KXE_TreeViewItem *); + + /** + * If the child items aren't created (initialized) yet + * (i.e. if m_bChildsCreated is false), it is done now. + */ + void ensureChildItemsCreated(); + /** + * If the grandchilds (child items of this item's childs) aren't created (initialized) + * yet (i.e. if m_bGrandChildsCreated is false), it is done now. + */ + void ensureGrandChildItemsCreated(); + + /** + * Starts in-place renaming, if the given column is set to be in-place + * renameable in the item's view + */ + virtual void startRename( int iCol ); + +protected: + + QDomNode m_xmlNode; + KXE_TreeViewItem * m_pPrevSibling; + bool m_bBookmarked; + bool m_bChildsCreated; + bool m_bGrandChildsCreated; + +private: + + void init(); + void initChilds(); +}; + +#endif diff --git a/part/kxe_viewattributes.cpp b/part/kxe_viewattributes.cpp new file mode 100644 index 0000000..ec6bffe --- /dev/null +++ b/part/kxe_viewattributes.cpp @@ -0,0 +1,157 @@ +/*************************************************************************** + kxe_viewattributes.cpp - description + ------------------- + begin : Thu Nov 22 2001 + copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team + email : lvanek@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "kxe_viewattributes.h" + +#include "kxeattributedialog.h" + +#include +#include +#include + +KXE_ViewAttributes::KXE_ViewAttributes( QWidget * pParent, const char * pszName ) + : QTable( 0, 3, pParent, pszName ) +{ + horizontalHeader()->setLabel( 0, i18n("Namespace") ); + horizontalHeader()->setLabel( 1, i18n("Name") ); + horizontalHeader()->setLabel( 2, i18n("Value") ); + + setColumnReadOnly( 0, true ); + setColumnReadOnly( 1, true ); + setColumnReadOnly( 2, true ); + + connect( this, SIGNAL(valueChanged(int,int)), this, SLOT(slotItemRenamedInplace(int,int)) ); +} + +QDomAttr KXE_ViewAttributes::getSelectedAttribute() const +{ + if ( currentRow() == -1 ) + return QDomAttr(); + + if ( m_domElement.attributes().item(currentRow()).isAttr() ) + { + return m_domElement.attributes().item(currentRow()).toAttr(); + } + else + return QDomAttr(); +} + +void KXE_ViewAttributes::setReadWrite( bool fReadWrite ) +{ + setColumnReadOnly( 1, ! fReadWrite ); + setColumnReadOnly( 2, ! fReadWrite ); + + if ( fReadWrite ) + connect( this, SIGNAL(contextMenuRequested(int,int,const QPoint&)), this, SLOT(slotContextMenuRequested(int,int,const QPoint&)) ); + else + disconnect( this, SIGNAL(contextMenuRequested(int,int,const QPoint&)), this, SLOT(slotContextMenuRequested(int,int,const QPoint&)) ); +} + +void KXE_ViewAttributes::slotContextMenuRequested( int nRow, int nCol, const QPoint & pos ) +{ + nCol = nCol; + QString szMenuName = ( nRow == -1 ) ? "popupXmlAttributes" : "popupXmlAttribute"; + emit sigContextMenuRequested( szMenuName, pos ); +} + +void KXE_ViewAttributes::slotChange( const QDomElement & element ) +{ + m_domElement = element; + + uint iLength = m_domElement.attributes().length(); + setNumRows( iLength ); + + if ( iLength > 0 ) + { + for ( uint iRow = 0; iRow < iLength; iRow++ ) + { + QDomNode node = m_domElement.attributes().item(iRow); + if ( node.isAttr() ) + { + setText( iRow, 0, node.toAttr().namespaceURI() ); + setText( iRow, 1, node.toAttr().name() ); + setText( iRow, 2, node.toAttr().value() ); + adjustRow( iRow ); + } + else + kdError() << "KXE_ViewAttributes::slotChange: node is not an attribute (but should be)" << endl; + } + + adjustColumn(0); + adjustColumn(1); + adjustColumn(2); + } +} + +void KXE_ViewAttributes::slotItemRenamedInplace( int nRow, int nCol ) +{ + if ( nCol < 1) // only attributes names and values are changeable + { + kdError() << "KXMLEditor " << k_funcinfo << " column " << nCol << " should be unchangeable" << endl; + return; + } + + QDomNode node = m_domElement.attributes().item(nRow); + if ( node.isAttr() ) + { if (nCol == 1) + { + // check if name is OK + QString strMessage = KXEAttributeDialog::checkName(text(nRow,nCol)); + if(strMessage.length() > 0) + { + // restore old name + setText( nRow, 1, node.toAttr().name() ); // set old name + KMessageBox::sorry(this, strMessage); + return; + } + + // check, if new name not exists in attributes list + if(m_domElement.attributes().contains(text(nRow,nCol)) == false) + { + if ( node.toAttr().name() != text(nRow,nCol) ) // only if the name really was changed + { + emit sigAttributeNameChangedInplace(node.toAttr(), text(nRow,nCol) ); + } + } + else + { + KMessageBox::sorry(this, i18n("Attribute name already exists !")); + setText( nRow, 1, node.toAttr().name() ); // set old name + return; + } + } + else + { + if ( node.toAttr().value() != text(nRow,nCol) ) // only if the value really was changed + { + // check if value is OK + QString strMessage = KXEAttributeDialog::checkValue(text(nRow,nCol)); + if(strMessage.length() > 0) + { + // restore old value + setText( nRow, 2, node.toAttr().value() ); // set old value + KMessageBox::sorry(this, strMessage); + return; + } + + emit sigAttributeValueChangedInplace( node.toAttr(), text(nRow, nCol) ); + } + } + } + else + kdError() << "KXMLEditor " << k_funcinfo << " node is not an attribute (but should be)" << endl; +} diff --git a/part/kxe_viewattributes.h b/part/kxe_viewattributes.h new file mode 100644 index 0000000..c314c56 --- /dev/null +++ b/part/kxe_viewattributes.h @@ -0,0 +1,71 @@ +/*************************************************************************** + kxe_viewattributes.h - description + ------------------- + begin : Thu Nov 22 2001 + copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team + email : lvanek@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef KXE_VIEWATTRIBUTES_H +#define KXE_VIEWATTRIBUTES_H + +#include +#include + +/** + * @author The KXMLEditor Team + */ +class KXE_ViewAttributes : public QTable +{ + Q_OBJECT + + public: + + KXE_ViewAttributes( QWidget * pParent = 0, const char * pszName = 0 ); + + /** Returns a pointer to the currently selected attribute or a null pointer. */ + QDomAttr getSelectedAttribute() const; + + /** Changes the behaviour of this view to readonly or readwrite. */ + void setReadWrite( bool fReadWrite ); + + public slots: + + /** Changes/Rebuilds the whole table according to the given element's attributes. */ + void slotChange( const QDomElement & element ); + + protected: + + /** the currently selected node */ + QDomElement m_domElement; + + protected slots: + + /** Called, when a context menu was requested (connected to @ref QTable::contextMenuRequested). */ + void slotContextMenuRequested( int nRow, int nCol, const QPoint & pos ); + + /** Called, when an item was changed via inplace editing. */ + void slotItemRenamedInplace( int nRow, int nCol ); + + signals: + + /** Emitted, when a context menu is requested */ + void sigContextMenuRequested( const QString & szMenuName, const QPoint & pos ); + + /** Emitted, when an attributes value was renamed via inplace editing. */ + void sigAttributeNameChangedInplace( const QDomAttr &, const QString ); + + /** Emitted, when an attributes value was renamed via inplace editing. */ + void sigAttributeValueChangedInplace( const QDomAttr &, const QString ); +}; + +#endif diff --git a/part/kxe_viewelement.cpp b/part/kxe_viewelement.cpp new file mode 100644 index 0000000..2bae53c --- /dev/null +++ b/part/kxe_viewelement.cpp @@ -0,0 +1,126 @@ +/*************************************************************************** + kxe_viewelement.cpp - description + ------------------- + begin : Mon Oct 15 2001 + copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team + email : lvanek@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "kxe_viewelement.h" +#include "kxe_viewattributes.h" +#include "kxesyntaxhighlighter.h" + +#include "kxmleditorfactory.h" +#include "kxeconfiguration.h" +#include "kxetextviewsettings.h" + +#include +#include + +#include +#include +#include + + +#include "qdom_add.h" + +#define CONFIG_SPLITTER_SIZES "View Element splitter sizes" + +KXE_ViewElement::KXE_ViewElement( QWidget * pParent, KConfig *pConfig, const char * pszName ) + : QSplitter( Qt::Vertical, pParent, pszName ) +{ + setOpaqueResize(true); + m_pConfig = pConfig; + m_pViewAttributes = new KXE_ViewAttributes( this, "table of element attributes"); + connect( m_pViewAttributes, SIGNAL(sigContextMenuRequested(const QString&,const QPoint&)), this, SIGNAL(sigContextMenuRequested(const QString&,const QPoint&)) ); + + connect( m_pViewAttributes, SIGNAL(sigAttributeNameChangedInplace(const QDomAttr&, const QString)), this, SIGNAL(sigAttributeNameChangedInplace(const QDomAttr&, const QString)) ); + connect( m_pViewAttributes, SIGNAL(sigAttributeValueChangedInplace(const QDomAttr&, const QString)), this, SIGNAL(sigAttributeValueChangedInplace(const QDomAttr&, const QString)) ); + + m_pViewPlainXML = new KTextEdit( this, "plain XML" ); + m_pViewPlainXML->setReadOnly(true); + m_pViewPlainXML->setTextFormat(KTextEdit::PlainText); + m_pViewPlainXML->setPaletteBackgroundColor(pParent->palette().active().base()); // Owerwrite read-only background color + m_pViewPlainXML->setWordWrap( QTextEdit::NoWrap ); + m_pSyntaxHighlighter = new KXESyntaxHighlighter(m_pViewPlainXML); + + // configuring splitter sizes + if (m_pConfig) + { + QValueList list = m_pConfig->readIntListEntry(CONFIG_SPLITTER_SIZES); + if (!list.isEmpty()) + setSizes(list); + } + + // Apply current configuration + slotTextViewSettingsChanged(); + // and make sure to be informed about its changes. + connect( KXMLEditorFactory::configuration()->textview(), SIGNAL(sigChanged()), this, SLOT(slotTextViewSettingsChanged()) ); +} + +KXE_ViewElement::~KXE_ViewElement() +{ + // saving splitter sizes + if (m_pConfig) + m_pConfig->writeEntry( CONFIG_SPLITTER_SIZES, sizes() ); + + delete m_pSyntaxHighlighter; +} + +QDomAttr KXE_ViewElement::getSelectedAttribute() const +{ + return m_pViewAttributes->getSelectedAttribute(); +} + +void KXE_ViewElement::setReadWrite( bool fReadWrite ) +{ + m_pViewAttributes->setReadWrite(fReadWrite); +} + +void KXE_ViewElement::slotChange( const QDomElement & element ) +{ + // change attribute view + m_pViewAttributes->slotChange(element); + + int iIndent = KXMLEditorFactory::configuration()->textview()->indentSteps(); + + // change plain XML view + m_pViewPlainXML->setText( domTool_save(element, iIndent) ); +} + +////////////////////////////////////////////////////////////// +// configuration slots +////////////////////////////////////////////////////////////// + +void KXE_ViewElement::slotTextViewSettingsChanged() +{ + m_pSyntaxHighlighter->setColorDefaultText( KXMLEditorFactory::configuration()->textview()->colorDfltText() ); + m_pSyntaxHighlighter->setColorElementNames( KXMLEditorFactory::configuration()->textview()->colorElemNames() ); + m_pSyntaxHighlighter->setColorAttributeNames( KXMLEditorFactory::configuration()->textview()->colorAttrNames() ); + m_pSyntaxHighlighter->setColorAttributeValues( KXMLEditorFactory::configuration()->textview()->colorAttrValues() ); + m_pSyntaxHighlighter->setColorXmlSyntaxChars( KXMLEditorFactory::configuration()->textview()->colorSyntaxChars() ); + m_pSyntaxHighlighter->setColorComments( KXMLEditorFactory::configuration()->textview()->colorComments() ); + m_pSyntaxHighlighter->setColorSyntaxError( KXMLEditorFactory::configuration()->textview()->colorErrors() ); + + if(KXMLEditorFactory::configuration()->textview()->isWrapOn()) + { + m_pViewPlainXML->setHScrollBarMode(QScrollView::AlwaysOff); + m_pViewPlainXML->setWordWrap(QTextEdit::WidgetWidth); + } + else + { + m_pViewPlainXML->setHScrollBarMode(QScrollView::Auto); + m_pViewPlainXML->setWordWrap(QTextEdit::NoWrap); + } + + m_pSyntaxHighlighter->rehighlight(); +} diff --git a/part/kxe_viewelement.h b/part/kxe_viewelement.h new file mode 100644 index 0000000..bac7669 --- /dev/null +++ b/part/kxe_viewelement.h @@ -0,0 +1,94 @@ +/*************************************************************************** + kxe_viewelement.h - description + ------------------- + begin : Mon Oct 15 2001 + copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team + email : lvanek@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef KXE_VIEWELEMENT_H +#define KXE_VIEWELEMENT_H + +#include + +#include + +// forward declarations +class KXE_ViewAttributes; +class KTextEdit; +class KConfig; +class KXESyntaxHighlighter; + + +/** + * This widget shows a table of XML elements attributes + * and plain XML text of this element and its children. + * + * @short Widget for XML elements. + */ +class KXE_ViewElement : public QSplitter +{ + Q_OBJECT + + public: + + KXE_ViewElement( QWidget * pParent, KConfig *pConfig, const char * pszName = 0 ); + ~KXE_ViewElement(); + + /** Returns a pointer to the currently selected attribute or a null pointer. */ + QDomAttr getSelectedAttribute() const; + + /** Changes the behaviour of this view to readonly or readwrite. */ + void setReadWrite( bool fReadWrite ); + + public slots: + + /** Changes/Rebuilds the whole widget according to the given element. */ + void slotChange( const QDomElement & ); + + /** + * Changes syntax highlighting colors. + */ + void slotTextViewSettingsChanged(); + + protected: + + /** table widget to display XML attributes */ + KXE_ViewAttributes * m_pViewAttributes; + /** edit widget for plain XML */ + KTextEdit * m_pViewPlainXML; + + /** configuration used to store splitter sizes */ + KConfig *m_pConfig; + + /** Syntax highlighter for m_pViewPlainXML */ + KXESyntaxHighlighter *m_pSyntaxHighlighter; + + signals: + + /** Emitted, when a context menu is requested (see @ref KXE_ViewAttributes::sigContextMenuRequested) */ + void sigContextMenuRequested( const QString & szMenuName, const QPoint & pos ); + + /** + * Emitted, when an attributes name was renamed via inplace editing + * (see @ref KXE_ViewAttributes::sigAttributeChangedInplace). + */ + void sigAttributeNameChangedInplace( const QDomAttr &, const QString ); + + /** + * Emitted, when an attributes value was renamed via inplace editing + * (see @ref KXE_ViewAttributes::sigAttributeChangedInplace). + */ + void sigAttributeValueChangedInplace( const QDomAttr &, const QString ); +}; + +#endif diff --git a/part/kxearchiveextssettings.cpp b/part/kxearchiveextssettings.cpp new file mode 100644 index 0000000..ec800c6 --- /dev/null +++ b/part/kxearchiveextssettings.cpp @@ -0,0 +1,153 @@ +/*************************************************************************** + kxearchiveextssettings.cpp + -------------------- + begin : Tue Dec 02 2003 + copyright : (C) 2003 by The KXMLEditor Team + email : hartig@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "kxearchiveextssettings.h" +#include "kxearchiveextssettingspage.h" + +#include +#include + +#include +#include +#include +#include + +#define CONF_ENTRY_NAME_EXTS_TARGZ "Extensions" + +KXEArchiveExtsSettings::KXEArchiveExtsSettings( QObject * pParent, const char * pszName ) + : KXESettings( "TarGz Extensions", pParent, pszName ), + m_pDialogPage(0) +{ +} + + +void KXEArchiveExtsSettings::write( KConfig * pConfig ) const +{ + pConfig->writeEntry( CONF_ENTRY_NAME_EXTS_TARGZ, m_lstExtensions ); +} + + +void KXEArchiveExtsSettings::read( const KConfig * pConfig ) +{ + m_lstExtensions = pConfig->readListEntry( CONF_ENTRY_NAME_EXTS_TARGZ ); +} + +QString KXEArchiveExtsSettings::dialogPageName() const +{ + return i18n( "Archive Extensions" ); +} + +QString KXEArchiveExtsSettings::dialogPageHeader() const +{ + return i18n( "Specify Archive Extensions" ); +} + +QString KXEArchiveExtsSettings::dialogPageIcon() const +{ + return "filetypes"; +} + +QWidget * KXEArchiveExtsSettings::dialogPage( QFrame * pParent ) +{ + if ( ! m_pDialogPage ) + { + // create the page if necessary + m_pDialogPage = new KXEArchiveExtsSettingsPage( pParent, "archive extensions config.dialog page" ); + + // and fill its widgets with the corresponding values + updatePage(); + + connect( m_pDialogPage->m_pExtensions, SIGNAL(highlighted(const QString&)), this, SLOT(slotPageEditExtension(const QString&)) ); + connect( m_pDialogPage->m_pBtnNew, SIGNAL(clicked()), this, SLOT(slotPageAddExtension()) ); + connect( m_pDialogPage->m_pBtnDelete, SIGNAL(clicked()), this, SLOT(slotPageDeleteExtension()) ); + connect( m_pDialogPage->m_pExtension, SIGNAL(textChanged(const QString&)), this, SLOT(slotPageUpdateExtension(const QString&)) ); + + connect( m_pDialogPage->m_pBtnNew, SIGNAL(clicked()), this, SIGNAL(sigDialogPageChanged()) ); + connect( m_pDialogPage->m_pBtnDelete, SIGNAL(clicked()), this, SIGNAL(sigDialogPageChanged()) ); + } + + return m_pDialogPage; +} + + +void KXEArchiveExtsSettings::setFromPage() +{ + if ( m_pDialogPage ) + { + m_lstExtensions.clear(); + QListBoxItem * pTmpItem = m_pDialogPage->m_pExtensions->firstItem(); + while ( pTmpItem ) + { + m_lstExtensions << pTmpItem->text(); + pTmpItem = pTmpItem->next(); + } + } +} + +void KXEArchiveExtsSettings::updatePage() const +{ + if ( m_pDialogPage ) + { + m_pDialogPage->m_pExtensions->clear(); + m_pDialogPage->m_pExtensions->insertStringList( m_lstExtensions ); + m_pDialogPage->m_pExtension->setDisabled( true ); + } +} + + +////////////////////////////////////////////////////////////////////// +// additional slots for the corresponding configuration dialog page // +////////////////////////////////////////////////////////////////////// + +void KXEArchiveExtsSettings::slotPageEditExtension( const QString & strText ) +{ + m_pDialogPage->m_pExtension->setText( strText ); + m_pDialogPage->m_pExtension->setEnabled( true ); + m_pDialogPage->m_pExtension->setFocus(); +} + +void KXEArchiveExtsSettings::slotPageAddExtension() +{ + m_pDialogPage->m_pExtensions->insertItem( "zip", 0 ); + m_pDialogPage->m_pExtensions->setCurrentItem( 0 ); + m_pDialogPage->m_pExtension->selectAll(); + m_pDialogPage->m_pExtension->setFocus(); + m_pDialogPage->m_pExtension->setEnabled( true ); +} + +void KXEArchiveExtsSettings::slotPageDeleteExtension() +{ + m_pDialogPage->m_pExtensions->removeItem( m_pDialogPage->m_pExtensions->currentItem() ); + + if ( m_pDialogPage->m_pExtensions->count() == 0 ) + { + m_pDialogPage->m_pExtension->clear(); + m_pDialogPage->m_pExtension->setDisabled( true ); + } + else + m_pDialogPage->m_pExtensions->setSelected( m_pDialogPage->m_pExtensions->currentItem(), true ); +} + +void KXEArchiveExtsSettings::slotPageUpdateExtension( const QString & strText ) +{ + if ( ( m_pDialogPage->m_pExtensions->count() > 0 ) && + ( m_pDialogPage->m_pExtensions->currentText() != m_pDialogPage->m_pExtension->text() ) ) + { + m_pDialogPage->m_pExtensions->changeItem( strText, m_pDialogPage->m_pExtensions->currentItem() ); + emit sigDialogPageChanged(); + } +} diff --git a/part/kxearchiveextssettings.h b/part/kxearchiveextssettings.h new file mode 100644 index 0000000..ad2f212 --- /dev/null +++ b/part/kxearchiveextssettings.h @@ -0,0 +1,113 @@ +/*************************************************************************** + kxearchiveextssettings.h + ------------------ + begin : Tue Dec 02 2003 + copyright : (C) 2003 by The KXMLEditor Team + email : hartig@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef KXEARCHIVEEXTSSETTINGS_H +#define KXEARCHIVEEXTSSETTINGS_H + +#include "kxesettings.h" + +#include + +class KXEArchiveExtsSettingsPage; + +/** + * This class represents the group of configuration settings for the + * archive extensions. + * + * @author Olaf Hartig + */ +class KXEArchiveExtsSettings : public KXESettings +{ + Q_OBJECT + + public: + + KXEArchiveExtsSettings( QObject * pParent = 0, const char * pszName = 0 ); + + // The following function(s) can be used to access this object's settings. + const QStringList & extensions() const { return m_lstExtensions; } + + /** + * Derived from @ref KXESettings + */ + virtual QString dialogPageName() const; + /** + * Derived from @ref KXESettings + */ + virtual QString dialogPageHeader() const; + /** + * Derived from @ref KXESettings + */ + virtual QString dialogPageIcon() const; + /** + * Derived from @ref KXESettings + */ + virtual QWidget * dialogPage( QFrame * pParent ); + + protected: + + /** + * Derived from @ref KXESettings + */ + virtual void write( KConfig * ) const; + /** + * Derived from @ref KXESettings + */ + virtual void read( const KConfig * ); + /** + * Derived from @ref KXESettings + */ + virtual void setFromPage(); + /** + * Derived from @ref KXESettings + */ + virtual void updatePage() const; + + // the settings itself + QStringList m_lstExtensions; + + /** + * the corresponding configuration dialog page + * It is created on demand by @ref dialogPage. + */ + KXEArchiveExtsSettingsPage * m_pDialogPage; + + protected slots: + + // The following slots contain additional functionality + // for the corresponding configuration dialog page. + + /** + * Copies the selected item's extension to the editline. + */ + void slotPageEditExtension( const QString & ); + /** + * Creates a new (empty) item/ extension in the listbox and selects it. + */ + void slotPageAddExtension(); + /** + * Removes the currently selected item / extension from the listbox. + */ + void slotPageDeleteExtension(); + /** + * Copies the lineedit's current text to the currently selected item. + */ + void slotPageUpdateExtension( const QString & ); + +}; + +#endif diff --git a/part/kxearchiveextssettingspage.ui b/part/kxearchiveextssettingspage.ui new file mode 100644 index 0000000..0936850 --- /dev/null +++ b/part/kxearchiveextssettingspage.ui @@ -0,0 +1,175 @@ + +KXEArchiveExtsSettingsPage + + + KXEArchiveExtsSettingsPage + + + + 0 + 0 + 293 + 187 + + + + Archive Exts Settings Page + + + + unnamed + + + + m_pLblExtensions + + + Extensions of archive &files: + + + m_pExtensions + + + <b>Extensions of archive files</b> +<br> +This list contains the known extensions for archive files.<br> +You can choose one to edit or remove it with the dialog widgets below. + + + + + m_pExtensions + + + + 0 + 80 + + + + <b>Extensions of archive files</b> +<br> +This list contains the known extensions for archive files. + + + + + layout2 + + + + unnamed + + + + m_pLblExtension + + + &Extension: + + + m_pExtension + + + <b>Extension</b> +<br> +Change the selected extension here. + + + + + m_pExtension + + + <b>Extension</b> +<br> +Change the selected extension here. + + + + + spacer2 + + + Horizontal + + + Expanding + + + + 71 + 20 + + + + + + layout1 + + + + unnamed + + + + m_pBtnNew + + + &New + + + Alt+N + + + <b>New</b> +<br> +You can create a new item for another known extension in the list above. + + + + + m_pBtnDelete + + + &Delete + + + Alt+D + + + <b>Delete</b> +<br> +You can delete the selected extension from the list above. + + + + + spacer1 + + + Horizontal + + + Expanding + + + + 41 + 20 + + + + + + + + + + + slotUpdateExtension( const QString & ) + slotDeleteExtension() + slotAddExtension() + + + diff --git a/part/kxeattachdialogbase.ui b/part/kxeattachdialogbase.ui new file mode 100644 index 0000000..447ac9f --- /dev/null +++ b/part/kxeattachdialogbase.ui @@ -0,0 +1,144 @@ + +KXEAttachDialogBase + + + KXEAttachDialogBase + + + + 0 + 0 + 319 + 105 + + + + Attach to XML + + + true + + + + unnamed + + + + Label + + + attachment URI: + + + + + attachURI + + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + buttonHelp + + + &Help + + + F1 + + + true + + + + + Horizontal Spacing2 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + buttonOk + + + &OK + + + + + + true + + + true + + + + + buttonCancel + + + &Cancel + + + + + + true + + + + + + + + + buttonOk + clicked() + KXEAttachDialogBase + accept() + + + buttonCancel + clicked() + KXEAttachDialogBase + reject() + + + + attachURI + buttonOk + buttonCancel + buttonHelp + + + + kurlrequester.h + klineedit.h + kpushbutton.h + + diff --git a/part/kxeattributedialog.cpp b/part/kxeattributedialog.cpp new file mode 100644 index 0000000..d64b796 --- /dev/null +++ b/part/kxeattributedialog.cpp @@ -0,0 +1,179 @@ +/*************************************************************************** + kxeattributedialog.cpp - description + ---------------------- + begin : Fre Jul 12 2002 + copyright : (C) 2002, 2003 by The KXMLEditor Team + email : lvanek@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "kxeattributedialog.h" + +#include +#include +#include + +#include +#include + +KXEAttributeDialog::KXEAttributeDialog( QWidget * pParent, const char * pszName, bool fModal, WFlags fl ) + : KXEAttributeDialogBase( pParent, pszName, fModal, fl ) +{ + connect( m_pEditNamespace, SIGNAL(textChanged(const QString &)), this, SLOT(slotNamespaceChanged(const QString &)) ); + connect( m_pEditQName, SIGNAL(textChanged(const QString &)), this, SLOT(slotNameChanged(const QString &)) ); + connect( m_pEditValue, SIGNAL(textChanged(const QString &)), this, SLOT(slotValueChanged(const QString &)) ); +} + +void KXEAttributeDialog::clearDialog() +{ + m_pEditNamespace->clear(); + m_pEditQName->clear(); + m_pEditValue->clear(); +} + +int KXEAttributeDialog::exec() +{ + clearDialog(); + + m_pBtnOK->setEnabled(false); + + m_pEditQName->setFocus(); + m_pBtnOK->setDefault(true); + + int iReturn = KXEAttributeDialogBase::exec(); + if ( iReturn == Accepted ) + { + m_strNamespace = m_pEditNamespace->text(); + m_strQName = m_pEditQName->text(); + m_strValue = m_pEditValue->text(); + } + + return iReturn; +} + +void KXEAttributeDialog::slotNameChanged(const QString & strNewName) +{ + QString strMessage = checkName(strNewName); + if(strMessage.isEmpty()) + { + strMessage = checkNamespace(m_pEditNamespace->text()); + if(strMessage.isEmpty()) + strMessage = checkValue(m_pEditValue->text()); + } + + m_pTextLabelMessage->setText(strMessage); + + if ( strNewName.isEmpty() || (strMessage.length() > 0) ) + m_pBtnOK->setEnabled(false); + else + m_pBtnOK->setEnabled(true); +} + +void KXEAttributeDialog::slotValueChanged(const QString & strNewValue) +{ + QString strMessage = checkName(m_pEditQName->text()); + if(strMessage.isEmpty()) + { + strMessage = checkNamespace(m_pEditNamespace->text()); + if(strMessage.isEmpty()) + strMessage = checkValue(strNewValue); + } + + m_pTextLabelMessage->setText(strMessage); + + if ( m_pEditQName->text().isEmpty() || (strMessage.length() > 0) ) + m_pBtnOK->setEnabled(false); + else + m_pBtnOK->setEnabled(true); +} + +void KXEAttributeDialog::slotNamespaceChanged(const QString & strNewNamespace) +{ + QString strMessage = checkName(m_pEditQName->text()); + if(strMessage.isEmpty()) + { + strMessage = checkNamespace(strNewNamespace); + if(strMessage.isEmpty()) + strMessage = checkValue(m_pEditValue->text()); + } + + m_pTextLabelMessage->setText(strMessage); + + if ( m_pEditQName->text().isEmpty() || (strMessage.length() > 0) ) + m_pBtnOK->setEnabled(false); + else + m_pBtnOK->setEnabled(true); +} + +// Check, if XML attribute name is OK +QString KXEAttributeDialog::checkNamespace(const QString strAtttributeName) +{ + if(strAtttributeName.length() == 0) + return ""; + + // test for space + if(strAtttributeName.find(' ') >= 0) + return i18n("Atttribute namespace cannot contain space !"); + + // Forbidden characters + QString strForbiddenChars("<>\"'"); + for(unsigned int i = 0; i < strForbiddenChars.length(); i++) + { + QChar ch = strForbiddenChars[i]; + + if(strAtttributeName.find(ch) >= 0) + return i18n("Atttribute namespace cannot contain character: %1 !").arg(ch); + } + + return ""; +} + +// Check, if XML attribute name is OK +QString KXEAttributeDialog::checkName(const QString strAtttributeName) +{ + if(strAtttributeName.length() == 0) + return ""; + + // test for space + if(strAtttributeName.find(' ') >= 0) + return i18n("Atttribute name cannot contain space !"); + + // Forbidden characters + QString strForbiddenChars("&@#$%^()%+?=:<>;\"'*"); + for(unsigned int i = 0; i < strForbiddenChars.length(); i++) + { + QChar ch = strForbiddenChars[i]; + + if(strAtttributeName.find(ch) >= 0) + return i18n("Atttribute name cannot contain character: %1 !").arg(ch); + } + + return ""; +} + +// Check, if XML attribute value is OK +QString KXEAttributeDialog::checkValue(const QString strData) +{ + if(strData.length() == 0) + return ""; + + // Forbidden characters + QString strForbiddenChars("<>\""); + for(unsigned int i = 0; i < strForbiddenChars.length(); i++) + { + QChar ch = strForbiddenChars[i]; + + if(strData.find(ch) >= 0) + return i18n("Attribute value cannot contain character: %1 !").arg(ch); + } + + return ""; +} diff --git a/part/kxeattributedialog.h b/part/kxeattributedialog.h new file mode 100644 index 0000000..e2019b9 --- /dev/null +++ b/part/kxeattributedialog.h @@ -0,0 +1,82 @@ +/*************************************************************************** + kxeattributedialog.h - description + -------------------- + begin : Fre Jul 12 2002 + copyright : (C) 2002, 2003 by The KXMLEditor Team + email : lvanek@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef KXEATTRIBUTEDIALOG_H +#define KXEATTRIBUTEDIALOG_H + +#include "kxeattributedialogbase.h" + +#include + +class KXEAttributeDialog : public KXEAttributeDialogBase +{ + Q_OBJECT + + public: + KXEAttributeDialog( QWidget * pParent = 0, const char * pszName = 0, bool fModal = true, WFlags fl = 0 ); + + const QString attributeNamespace() const { return m_strNamespace; } + const QString QName() const { return m_strQName; } + const QString Value() const { return m_strValue; } + + /** + * To be used for adding an attribute to new XML element. + * + * @return see @ref QDialog::exec + */ + int exec( ); + + /** + * Clears the dialogs widgets. + */ + void clearDialog(); + + // Check, if XML attribute name is OK + static QString checkName(const QString); + + // Check, if XML attribute value is OK + static QString checkValue(const QString); + + // Check, if XML attribute namespace is OK + static QString checkNamespace(const QString); + + protected slots: + /** + * Called, when user change attribute name. + * Disables the OK button, if user input is wrong or incomplete. + */ + void slotNameChanged(const QString &); + + /** + * Called, when user change attribute value. + * Disables the OK button, if user input is wrong or incomplete. + */ + void slotValueChanged(const QString &); + + /** + * Called, when user change attribute namespace. + * Disables the OK button, if user input is wrong or incomplete. + */ + void slotNamespaceChanged(const QString &); + + protected: + QString m_strNamespace; + QString m_strQName; + QString m_strValue; +}; + +#endif diff --git a/part/kxeattributedialogbase.ui b/part/kxeattributedialogbase.ui new file mode 100644 index 0000000..d03b8eb --- /dev/null +++ b/part/kxeattributedialogbase.ui @@ -0,0 +1,263 @@ + +KXEAttributeDialogBase + + + KXEAttributeDialogBase + + + + 0 + 0 + 339 + 262 + + + + XML Attribute + + + true + + + + unnamed + + + 11 + + + 6 + + + + Spacer3 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + + Spacer4 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + + Spacer4_2 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + + m_pEditNamespace + + + <b>Namespace URI</b> +<br/> +Enter the namespace URI for this attribute here. + + + + + m_pEditValue + + + <b>Value</b> +<br/> +Enter the attribute's value here. + + + + + m_pEditQName + + + <b>Qualified Name</b> +<br/> +Enter a qualified name for the attribute here. + + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + Horizontal Spacing2 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + m_pBtnOK + + + &OK + + + Alt+O + + + true + + + true + + + + + m_pBtnCancel + + + &Cancel + + + Alt+C + + + true + + + + + + + m_pLblValue + + + &Value: + + + m_pEditValue + + + <b>Value</b> +<br/> +Enter the attribute's value here. + + + + + m_pLblQName + + + Qualified &Name: + + + m_pEditQName + + + <b>Qualified Name</b> +<br/> +Enter a qualified name for the attribute here. + + + + + m_pLblNamespace + + + Namespace &URI: + + + m_pEditNamespace + + + <b>Namespace URI</b> +<br/> +Enter the namespace URI for this attribute here. + + + + + m_pTextLabelMessage + + + + 255 + 0 + 0 + + + + PlainText + + + + + + + m_pBtnOK + clicked() + KXEAttributeDialogBase + accept() + + + m_pBtnCancel + clicked() + KXEAttributeDialogBase + reject() + + + + m_pEditQName + m_pEditValue + m_pBtnOK + m_pBtnCancel + m_pEditNamespace + + + diff --git a/part/kxechardatadialog.cpp b/part/kxechardatadialog.cpp new file mode 100644 index 0000000..fb74ad4 --- /dev/null +++ b/part/kxechardatadialog.cpp @@ -0,0 +1,119 @@ +/*************************************************************************** + kxechardatadialog.cpp - description + --------------------- + begin : Don Apr 25 2002 + copyright : (C) 2002, 2003 by The KXMLEditor Team + email : lvanek@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "kxechardatadialog.h" + +#include +#include +#include +#include + +#include +#include + +KXECharDataDialog::KXECharDataDialog( QWidget * pParent, const char * pszName, bool fModal, WFlags fl ) + : KXECharDataDialogBase( pParent, pszName, fModal, fl ) +{ + connect( m_pEditData, SIGNAL(textChanged()), this, SLOT(slotDataChanged()) ); +} + +void KXECharDataDialog::clearDialog() +{ + m_pEditData->clear(); +} + +int KXECharDataDialog::exec( bool bEditExisting ) +{ + if(bEditExisting) + { + m_pComboInsert->hide(); + m_pComboInsert->setDisabled(true); + m_pLblInsert->hide(); + m_pLblInsert->setDisabled(true); + +// m_pComboType->setDisabled(true); + + m_pEditData->setText( m_strContents ); +// m_pComboType->setCurrentItem(m_eCharDataKind); + } + else + { +// m_pComboType->setEnabled(true); + clearDialog(); + } + + int iReturn = exec(); + if ( iReturn == Accepted ) + { + m_strContents = m_pEditData->text(); + m_bAtTop = ( m_pComboInsert->currentItem() == 0 ); +// m_eCharDataKind = (CharDataKind) m_pComboType->currentItem(); + } + + return iReturn; +} + +int KXECharDataDialog::exec() +{ + if ( m_pEditData->text().isEmpty() ) + m_pBtnOK->setEnabled(false); + else + m_pBtnOK->setEnabled(true); + + m_pEditData->setFocus(); + m_pBtnOK->setDefault(true); + + return KXECharDataDialogBase::exec(); +} + +void KXECharDataDialog::slotDataChanged() +{ + QString strMessage = checkContents(m_pEditData->text()); + + m_pTextLabelMessage->setText(strMessage); + + if ( m_pEditData->text().isEmpty() || (strMessage.length() > 0)) + m_pBtnOK->setEnabled(false); + else + m_pBtnOK->setEnabled(true); +} + +// Check, if XML chardata contents is OK +QString KXECharDataDialog::checkContents(const QString strData) +{ + if(strData.length() == 0) + return ""; + + // Forbidden characters + /*QString strForbiddenChars("<>"); + for(unsigned int i = 0; i < strForbiddenChars.length(); i++) + { + QChar ch = strForbiddenChars[i]; + + if(strData.find(ch) >= 0) + return i18n("Contents cannot contain character: %1 !").arg(ch); + } + + L.V. Removed this check, bacause QDomCharacterData.setData() escapec special + charactesr and data() unescapes it back to original string + + */ + + return ""; +} + + diff --git a/part/kxechardatadialog.h b/part/kxechardatadialog.h new file mode 100644 index 0000000..7e1507b --- /dev/null +++ b/part/kxechardatadialog.h @@ -0,0 +1,83 @@ +/*************************************************************************** + kxechardatadialog.h - description + ------------------- + begin : Don Apr 25 2002 + copyright : (C) 2002, 2003 by The KXMLEditor Team + email : lvanek@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef KXECHARDATADIALOG_H +#define KXECHARDATADIALOG_H + +#include "kxechardatadialogbase.h" + +enum CharDataKind + { + CharDataTextNode = 0, + CharDataCDATASection, + CharDataComment + }; + +class KXECharDataDialog : public KXECharDataDialogBase +{ + Q_OBJECT + + public: + KXECharDataDialog( QWidget * pParent = 0, const char * pszName = 0, bool fModal = true, WFlags fl = 0 ); + +// const CharDataKind charDataKind() const { return m_eCharDataKind; } + const bool atTop() const { return m_bAtTop; } + const QString contents() const { return m_strContents; } + + void setContents(const QString strContents) { m_strContents = strContents; } +// void setCharDataKind(const CharDataKind eCharDataKind) { m_eCharDataKind = eCharDataKind; } + + public: + + /** + * To be used for inserting the given XML character data as child + * of the given parent element. + * + * @return see @ref QDialog::exec + */ + int exec( bool ); + + /** + * Clears the dialogs widgets. + */ + void clearDialog(); + + // check contents + static QString checkContents(const QString); + + protected: + /** + * Don't use this function directly, it's for internal use only. + * Use one of the other @ref DlgXMLCharData::exec functions instead. + */ + int exec(); + + protected slots: + /** + * Called, when the data in the text edit @ref DlgXMLCharDataBase::m_pEditData + * is changed. + * Disables the OK button, if the given string is empty. + */ + void slotDataChanged(); + + protected: + //CharDataKind m_eCharDataKind; + bool m_bAtTop; + QString m_strContents; +}; + +#endif diff --git a/part/kxechardatadialogbase.ui b/part/kxechardatadialogbase.ui new file mode 100644 index 0000000..7f8b874 --- /dev/null +++ b/part/kxechardatadialogbase.ui @@ -0,0 +1,213 @@ + +KXECharDataDialogBase + + + KXECharDataDialogBase + + + + 0 + 0 + 389 + 289 + + + + XML Character Data + + + true + + + + unnamed + + + 11 + + + 6 + + + + Layout4 + + + + unnamed + + + 0 + + + 6 + + + + m_pLblInsert + + + &Insert: + + + m_pComboInsert + + + <b>Insert</b> +<br/> +Choose, where to place this XML character data in the XML elements list of childnodes. + + + + + + at bottom + + + + + at top + + + + m_pComboInsert + + + <b>Insert</b> +<br/> +Choose, where to place this XML character data in the XML elements list of childnodes. + + + + + Spacer6 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + + + m_pEditData + + + PlainText + + + NoWrap + + + You can edit the XML character data in this editor. + + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + Horizontal Spacing2 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + m_pBtnOK + + + &OK + + + Alt+O + + + true + + + true + + + + + m_pBtnCancel + + + &Cancel + + + true + + + + + + + m_pTextLabelMessage + + + + 255 + 0 + 0 + + + + PlainText + + + + + + + m_pBtnOK + clicked() + KXECharDataDialogBase + accept() + + + m_pBtnCancel + clicked() + KXECharDataDialogBase + reject() + + + + m_pEditData + m_pBtnOK + m_pBtnCancel + m_pComboInsert + + + diff --git a/part/kxechoosestringdialog.cpp b/part/kxechoosestringdialog.cpp new file mode 100644 index 0000000..d36ed68 --- /dev/null +++ b/part/kxechoosestringdialog.cpp @@ -0,0 +1,42 @@ +/*************************************************************************** + kxechoosestringdialog.cpp - description + ------------------------- + begin : Fri Jul 20 2001 + copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team + email : lvanek@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "kxechoosestringdialog.h" + +#include +#include +#include + +KXEChooseStringDialog::KXEChooseStringDialog(QWidget *parent, + const char *name, + const char *szCaption, + const char *szPrompt) + : KXEChooseStringDialogBase(parent, name, true) +{ + m_pComboBox->setEditable(true); + m_pComboBox->setFocus(); + m_pPushButtonOk->setDefault(true); + setCaption(szCaption); + m_pTextLabel->setText(szPrompt); +} + +/** Called, when user press OK button */ +void KXEChooseStringDialog::slotOk() +{ + m_strChoosedText = m_pComboBox->currentText(); + accept(); +} diff --git a/part/kxechoosestringdialog.h b/part/kxechoosestringdialog.h new file mode 100644 index 0000000..2065e3a --- /dev/null +++ b/part/kxechoosestringdialog.h @@ -0,0 +1,44 @@ +/*************************************************************************** + kxechoosestringdialog.h - description + ----------------------- + begin : Fri Jul 20 2001 + copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team + email : lvanek@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef KXECHOOSESTRINGDIALOG_H +#define KXECHOOSESTRINGDIALOG_H + +#include "kxechoosestringdialogbase.h" + +#include + +/**Dialog with combobox that allow enter +or select any string + *@author Lumir Vanek + */ + +class KXEChooseStringDialog : public KXEChooseStringDialogBase +{ + Q_OBJECT +public: + KXEChooseStringDialog(QWidget *, const char *, const char *, const char *); + +protected slots: // Protected slots + /** Called, when user press OK button */ + void slotOk(); +public: // Public attributes + /** Contain text choosed by user */ + QString m_strChoosedText; +}; + +#endif diff --git a/part/kxechoosestringdialogbase.ui b/part/kxechoosestringdialogbase.ui new file mode 100644 index 0000000..5fb8079 --- /dev/null +++ b/part/kxechoosestringdialogbase.ui @@ -0,0 +1,143 @@ + +KXEChooseStringDialogBase +Dialog with combobox that allow enter +or select any string +Lumir Vanek + + + KXEChooseStringDialogBase + + + + 0 + 0 + 228 + 137 + + + + Choose string + + + + unnamed + + + 11 + + + 6 + + + + m_pComboBox + + + <b>Enter string<b/> +<br/> +Enter or choose string, that you want. + + + + + Layout3 + + + + unnamed + + + 0 + + + 6 + + + + Spacer4 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + m_pPushButtonOk + + + &OK + + + + + m_pPushButtonCancel + + + &Cancel + + + + + + + m_pTextLabel + + + &Enter string: + + + m_pComboBox + + + <b>Enter string<b/> +<br/> +Enter or choose string, that you want. + + + + + Spacer1 + + + Horizontal + + + Expanding + + + + 117 + 20 + + + + + + + + m_pPushButtonCancel + clicked() + KXEChooseStringDialogBase + reject() + + + m_pPushButtonOk + clicked() + KXEChooseStringDialogBase + slotOk() + + + + slotOk() + + + diff --git a/part/kxecommand.cpp b/part/kxecommand.cpp new file mode 100644 index 0000000..f197fc3 --- /dev/null +++ b/part/kxecommand.cpp @@ -0,0 +1,25 @@ +// +// C++ Implementation: kxecommand +// +// Description: +// +// +// Author: Adam Charytoniuk , (C) 2003 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#include "kxecommand.h" + +KXECommand::KXECommand(KXEDocument* pDocument) +:KCommand() +{ + m_pDocument = pDocument;; +} + + +KXECommand::~KXECommand() +{ +} + + diff --git a/part/kxecommand.h b/part/kxecommand.h new file mode 100644 index 0000000..8d05ebd --- /dev/null +++ b/part/kxecommand.h @@ -0,0 +1,37 @@ +// +// C++ Interface: kxecommand +// +// Description: +// +// +// Author: Adam Charytoniuk , (C) 2003 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#ifndef KXECOMMAND_H +#define KXECOMMAND_H + +#include +#include "kxedocument.h" + +/** +This is a base class for undoable commands in our application + +@author Adam Charytoniuk +*/ +class KXECommand : public KCommand +{ +public: + /** Constructor. Commands refer only to KXEDocument, not parts or views. + The KXEDocument is a class that owns KCommandHistory objcect. + */ + KXECommand(KXEDocument* pDocument); + + ~KXECommand(); + +protected: + KXEDocument* m_pDocument; +}; + +#endif diff --git a/part/kxeconfiguration.cpp b/part/kxeconfiguration.cpp new file mode 100644 index 0000000..d780add --- /dev/null +++ b/part/kxeconfiguration.cpp @@ -0,0 +1,181 @@ +/*************************************************************************** + kxeconfiguration.cpp + -------------------- + begin : Tue Dec 02 2003 + copyright : (C) 2003 by The KXMLEditor Team + email : hartig@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "kxeconfiguration.h" +#include "kxetreeviewsettings.h" +#include "kxetextviewsettings.h" +#include "kxenewfilesettings.h" +#include "kxeprintsettings.h" +#include "kxearchiveextssettings.h" + +#include +#include +#include +#include + +#include + + +KXEConfiguration::KXEConfiguration() + : QObject( 0, "KXMLEditor's configuration (KXEConfiguration)" ), + m_pDialog( 0 ) +{ + // initialize all setting group objects + m_pTreeView = new KXETreeViewSettings( this, "tree view config. settings" ); + m_pTextView = new KXETextViewSettings( this, "text view config. settings" ); + m_pNewFile = new KXENewFileSettings( this, "new file config. settings" ); + m_pPrint = new KXEPrintSettings( this, "printing config. settings" ); + m_pArcExts = new KXEArchiveExtsSettings( this, "archive extension config. settings" ); + + // restore the settings from our config file + restore(); +} + +KXEConfiguration::~KXEConfiguration() +{ + if ( m_pDialog ) + delete m_pDialog; +} + +void KXEConfiguration::store( KConfig * pConfig ) const +{ + if ( ! pConfig ) + pConfig = KGlobal::config(); + + m_pTreeView->store( pConfig ); + m_pTextView->store( pConfig ); + m_pNewFile->store( pConfig ); + m_pPrint->store( pConfig ); + m_pArcExts->store( pConfig ); +} + + +void KXEConfiguration::restore( KConfig * pConfig ) +{ + if ( ! pConfig ) + pConfig = KGlobal::config(); + + m_pTreeView->restore( pConfig ); + m_pTextView->restore( pConfig ); + m_pNewFile->restore( pConfig ); + m_pPrint->restore( pConfig ); + m_pArcExts->restore( pConfig ); +} + + +void KXEConfiguration::showDialog() +{ + if ( ! m_pDialog ) // if there is no dialog yet, + { + // create one + m_pDialog = new KDialogBase( KDialogBase::IconList, // dialog face + i18n("Configure KXMLEditor"), // caption + KDialogBase::Apply | KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Help, // buttons + KDialogBase::Ok, // default button + 0, // parent + "configuration dialog", // name + false, // not modal + true ); // show separator + connect( m_pDialog, SIGNAL(applyClicked()), this, SLOT(slotDlgApplied()) ); + connect( m_pDialog, SIGNAL(okClicked()), this, SLOT(slotDlgApplied()) ); + + // and add the pages + QFrame * pFrame; + QWidget * pPage; + QVBoxLayout * pLayout; + + // - tree view properties page + pFrame = m_pDialog->addPage( m_pTreeView->dialogPageName(), + m_pTreeView->dialogPageHeader(), + KGlobal::instance()->iconLoader()->loadIcon( m_pTreeView->dialogPageIcon(), KIcon::NoGroup, KIcon::SizeMedium ) ); + pLayout = new QVBoxLayout( pFrame ); + pPage = m_pTreeView->dialogPage( pFrame ); + pLayout->addWidget( pPage ); + connect( m_pTreeView, SIGNAL(sigDialogPageChanged()), this, SLOT(slotDlgChanged()) ); + + // - text view properties page + pFrame = m_pDialog->addPage( m_pTextView->dialogPageName(), + m_pTextView->dialogPageHeader(), + KGlobal::instance()->iconLoader()->loadIcon( m_pTextView->dialogPageIcon(), KIcon::NoGroup, KIcon::SizeMedium ) ); + pLayout = new QVBoxLayout( pFrame ); + pPage = m_pTextView->dialogPage( pFrame ); + pLayout->addWidget( pPage ); + connect( m_pTextView, SIGNAL(sigDialogPageChanged()), this, SLOT(slotDlgChanged()) ); + + // - new file settings page + pFrame = m_pDialog->addPage( m_pNewFile->dialogPageName(), + m_pNewFile->dialogPageHeader(), + KGlobal::instance()->iconLoader()->loadIcon( m_pNewFile->dialogPageIcon(), KIcon::NoGroup, KIcon::SizeMedium ) ); + pLayout = new QVBoxLayout( pFrame ); + pPage = m_pNewFile->dialogPage( pFrame ); + pLayout->addWidget( pPage ); + connect( m_pNewFile, SIGNAL(sigDialogPageChanged()), this, SLOT(slotDlgChanged()) ); + + // - printing's settings page + pFrame = m_pDialog->addPage( m_pPrint->dialogPageName(), + m_pPrint->dialogPageHeader(), + KGlobal::instance()->iconLoader()->loadIcon( m_pPrint->dialogPageIcon(), KIcon::NoGroup, KIcon::SizeMedium ) ); + pLayout = new QVBoxLayout( pFrame ); + pPage = m_pPrint->dialogPage( pFrame ); + pLayout->addWidget( pPage ); + connect( m_pPrint, SIGNAL(sigDialogPageChanged()), this, SLOT(slotDlgChanged()) ); + + // - archive extensions page + pFrame = m_pDialog->addPage( m_pArcExts->dialogPageName(), + m_pArcExts->dialogPageHeader(), + KGlobal::instance()->iconLoader()->loadIcon( m_pArcExts->dialogPageIcon(), KIcon::NoGroup, KIcon::SizeMedium ) ); + pLayout = new QVBoxLayout( pFrame ); + pPage = m_pArcExts->dialogPage( pFrame ); + pLayout->addWidget( pPage ); + connect( m_pArcExts, SIGNAL(sigDialogPageChanged()), this, SLOT(slotDlgChanged()) ); + } + + if ( m_pDialog->isVisible() ) // If the dialog is visible (probably opened by + { // another part), it has to be hidden to make + m_pDialog->hide(); // it appear on the current desktop by the later + } // call of show. + else // If the dialog is not visible, it's + { // Apply- and Ok-buttons have to be + m_pDialog->enableButtonApply( false ); // disabled (until something is changed + m_pDialog->enableButtonOK( false ); // within the dialog). + } + + m_pDialog->show(); // show our configuration dialog +} + +void KXEConfiguration::slotDlgApplied() +{ + // reset configuration dialog + m_pDialog->enableButtonApply( false ); + m_pDialog->enableButtonOK( false ); + + // apply the page's data to the corresponding setting groups + m_pTreeView->apply(); + m_pTextView->apply(); + m_pNewFile->apply(); + m_pPrint->apply(); + m_pArcExts->apply(); + + // store the applied data to our config file + store(); +} + +void KXEConfiguration::slotDlgChanged() +{ + m_pDialog->enableButtonApply( true ); + m_pDialog->enableButtonOK( true ); +} diff --git a/part/kxeconfiguration.h b/part/kxeconfiguration.h new file mode 100644 index 0000000..3afd8b2 --- /dev/null +++ b/part/kxeconfiguration.h @@ -0,0 +1,123 @@ +/*************************************************************************** + kxeconfiguration.h + ------------------ + begin : Tue Dec 02 2003 + copyright : (C) 2003 by The KXMLEditor Team + email : hartig@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef KXECONFIGURATION_H +#define KXECONFIGURATION_H + +#include + +class KXETreeViewSettings; +class KXETextViewSettings; +class KXENewFileSettings; +class KXEPrintSettings; +class KXEArchiveExtsSettings; + +class KConfig; +class KDialogBase; + +/** + * This class is a container for KXMLEditor's configuration data. + * It consists of objects for the different groups of settings + * (objects of child classes of KXESettings) and manages the configuration + * dialog (@ref m_pDialog). This dialog consists of one page per settings + * group, that are initialized by them (using their dialogPage* functions). + * + * @short container for KXMLEditor's configuration data + * @author Olaf Hartig + */ +class KXEConfiguration : public QObject +{ + Q_OBJECT + + public: + + /** + * The constructor initializes the configuration setting groups + * (objects of KXESettings' child classes) and restores the + * configuration data from the config file by calling @ref restore. + */ + KXEConfiguration(); + /** + * The destructor deletes the configuration dialog, if there is one. + */ + ~KXEConfiguration(); + + /** + * Stores all configuration to the given @ref KConfig object by + * using @ref KXESettings's @ref store function. + * If no @ref KConfig object is given, @ref KGlobal::config is + * used. + */ + void store( KConfig * pConfig = 0 ) const; + /** + * Restores all configuration from the given @ref KConfig object + * by using @ref KXESettings's @ref restore function. + * If no @ref KConfig object is given, @ref KGlobal::config is + * used. + */ + void restore( KConfig * pConfig = 0 ); + /** + * Shows the configuration dialog. + * If there is no one yet, it is created by. + */ + void showDialog(); + + // The following functions return pointers to the configuration setting + // groups (objects of KXESettings' child classes), that can be used to + // access their data (or to connect to their signals). + + KXETreeViewSettings * const treeview() const { return m_pTreeView; } + KXETextViewSettings * const textview() const { return m_pTextView; } + KXENewFileSettings * const newfile() const { return m_pNewFile; } + KXEPrintSettings * const print() const { return m_pPrint; } + KXEArchiveExtsSettings * const archexts() const { return m_pArcExts; } + + protected slots: + + /** + * Applies the new data in the dialog's pages to our setting groups + * by using @ref KXESettings's @ref apply function and stores + * all settings with @ref store. + * After applying, the dialog's state is reseted (disabled Apply- and + * OK-buttons). + */ + void slotDlgApplied(); + /** + * Enables the configuration dialog's Apply- and OK-button. + */ + void slotDlgChanged(); + + protected: + + // The following members are the configuration setting + // groups (objects of KXESettings' child classes). + + KXETreeViewSettings * m_pTreeView; + KXETextViewSettings * m_pTextView; + KXENewFileSettings * m_pNewFile; + KXEPrintSettings * m_pPrint; + KXEArchiveExtsSettings * m_pArcExts; + + /** + * This is a pointer to our configuration dialog. + * The dialog itself is created on demand in @ref showDialog. + * It consists of one page per settings group. + */ + KDialogBase * m_pDialog; +}; + +#endif diff --git a/part/kxedocument.cpp b/part/kxedocument.cpp new file mode 100644 index 0000000..c3775c5 --- /dev/null +++ b/part/kxedocument.cpp @@ -0,0 +1,631 @@ +// +// C++ Implementation: kxedocument +// +// Description: +// +// +// Author: Adam Charytoniuk , (C) 2004 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#include "kxedocument.h" + +#include "kxmleditorfactory.h" +#include "kxeconfiguration.h" +#include "kxenewfilesettings.h" +#include "kxearchiveextssettings.h" +#include "kxeprintsettings.h" +#include "kxetextviewsettings.h" +#include "kxechoosestringdialog.h" +#include "kxeattachdialogbase.h" +#include "kxespecprocinstrdialog.h" +#include "kxefilenewdialog.h" +#include "commands_file.h" + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +KXEDocument::KXEDocument(QObject *parent, const char *name) + :QObject (parent,name), + QDomDocument(), + KXMLGUIClient() +{ + m_bDocIsCompressed = false; + m_bIsModified = false; + m_strCompressedTarEntryName = ""; + m_url = ""; + + //setXMLFile("kxedocument.rc"); +} + + +KXEDocument::~KXEDocument() +{ +} + + +bool KXEDocument::save(const QString &strFileName) +{ + if (this->documentElement().isNull() && + KMessageBox::warningContinueCancel(0, + i18n("Your file doesn't have root element defined. \n\ + Continue saving?"))==KMessageBox::Cancel ) + { + return false; + } + + QString strXML; + + QTextStream streamXML(&strXML, IO_WriteOnly); + int iIndent = KXMLEditorFactory::configuration()->textview()->indentSteps(); + ((QDomDocument*)this)->save(streamXML, iIndent); + + QString strEncoding; + QTextCodec *pTextCodec; + + // find encoding info + if(strXML.left(5) == " 0) + { + // info about encoding found; + iStart += 8; // skip encoding + + // search " or ' after encoding + if((iStart = strXML.find(QRegExp("[\"']"), iStart)) > 0) + { + QChar ch = strXML[iStart]; + iStart++; // skip ch + if((iEnd = strXML.find(ch, iStart)) > 0) + { + strEncoding = strXML.mid(iStart, iEnd - iStart); + } + } + } + } + + if(strEncoding.length() <= 0) + pTextCodec = QTextCodec::codecForLocale(); // default + else + pTextCodec = QTextCodec::codecForName(strEncoding); + + if(pTextCodec == 0) + { if(KMessageBox::questionYesNo(0, i18n("Codec for encoding %1 not found ! Continue saving ?").arg(strEncoding)) != KMessageBox::Yes) + return false; + } + + QCString strDecoded; + if(pTextCodec) + { strDecoded = pTextCodec->fromUnicode(strXML); + } + + // save string to file + if(!m_bDocIsCompressed) + { QFile file(strFileName); + if(file.open(IO_WriteOnly) == true) + { file.writeBlock(strDecoded, strDecoded.length()); + file.flush(); + file.close(); + } + else + { KMessageBox::error(0, + i18n("Can't create file %1").arg(strFileName), + i18n("Write error !")); + } + } + else + { // obtain file extension ----------------------------------------- + QString strExtension; + + int iPos = strFileName.findRev('.'); + + if(iPos > 0) + { strExtension = strFileName.mid(iPos + 1); + } + + if(strExtension == "svgz") + { + KMessageBox::sorry(0, + "Saving *.svgz not implemented yet", + "sory"); + return false; + } + else + { + KZip tarGzFile(strFileName); // New KOffice use KZip instead of KTarGz for storing files + if(tarGzFile.open(IO_WriteOnly)) + { tarGzFile.writeFile(m_strCompressedTarEntryName, "user", "group", strDecoded.length(), strDecoded); + tarGzFile.close(); + } + else + { KMessageBox::error(0, + i18n("Can't create archive %1").arg(strFileName), + i18n("Write error !")); + } + } + } + + return true; +} + +bool KXEDocument::open(const QString &strFileName) +{ + QString strCompressedTarEntryName; + + kdDebug() << "KXEDocument::open: opening file " << strFileName << endl; + + // obtain file extension ----------------------------------------- + QString strExtension; + + int iPos = strFileName.findRev('.'); + + if(iPos > 0) + { strExtension = strFileName.mid(iPos + 1); + } + + QString strTmpfileName; + + if ( KXMLEditorFactory::configuration()->archexts()->extensions().contains(strExtension) ) + { + + KTempFile tmp; + if (tmp.status() != 0) + { + kdError() << "Couldn't open temp file" << endl; + KMessageBox::sorry(0, i18n("Couldn't open temp file !")); + return false; + } + + tmp.setAutoDelete(false); + QFile &fileTemporary = *(tmp.file()); + + + if(strExtension == "svgz") + { + //----------------------- It is gzip compressed file ----------------------- + + m_strCompressedTarEntryName = strFileName.left(strFileName.length() - 5); // For SVG compressed icons strip extension, e.g. "kate.svgz" has entry "kate" etc + + iPos = m_strCompressedTarEntryName.findRev('/'); + + if(iPos > 0) + { m_strCompressedTarEntryName = m_strCompressedTarEntryName.mid(iPos + 1); + } + + QIODevice *pIODevice = KFilterDev::deviceForFile(strFileName, "application/x-gzip"); + + if(pIODevice->open( IO_ReadOnly )) + { + QTextStream stream(pIODevice); + QString line; + //int i = 1; + while ( !stream.atEnd() ) + { + line = stream.readLine(); // line of text excluding '\n' + //printf( "%3d: %s\n", i++, line.latin1() ); + fileTemporary.writeBlock(line, line.length()); + } + pIODevice->close(); + } + } + else + { + //----------------------- It is zip archive file --------------------------- + + KZip tarGzFile(strFileName); // new KOffice use KZip instead of KTarGz for storing files + + tarGzFile.open(IO_ReadOnly); + fileTemporary.open(IO_WriteOnly); + + const KTarDirectory *root = tarGzFile.directory(); + if(!root) + { + return false; + } + + // For KOffice files let user to choose maindoc or documentinfo + if(strCompressedTarEntryName.length() == 0) + { KXEChooseStringDialog dlgChooseString(0, 0, i18n("Choose file"), i18n("File:")); + dlgChooseString.m_pComboBox->insertItem("maindoc.xml"); + dlgChooseString.m_pComboBox->insertItem("documentinfo.xml"); + + if(dlgChooseString.exec() != KXEChooseStringDialog::Accepted) + { return false; + } + m_strCompressedTarEntryName = dlgChooseString.m_strChoosedText; + } + else + { + m_strCompressedTarEntryName = strCompressedTarEntryName; + } + + const KArchiveEntry *entry = root->entry(m_strCompressedTarEntryName); + + if(entry && entry->isFile()) + { const KArchiveFile *pTarFile = static_cast (entry); + + QBuffer buffer(pTarFile->data()); + buffer.open(IO_ReadOnly); + + fileTemporary.writeBlock(buffer.buffer(), buffer.size()); + } + else + m_strCompressedTarEntryName.truncate(0); + + tarGzFile.close(); + } + + strTmpfileName = fileTemporary.name(); + fileTemporary.close(); + + m_bDocIsCompressed = true; + } + else + m_bDocIsCompressed = false; + + + // ( 1.) parse the file and fill our document + QFile file(m_bDocIsCompressed ? strTmpfileName : strFileName); + if(! file.open(IO_ReadOnly)) + { + kdDebug() << "KXEDocument::openFile: Can't open file." << endl; + return false; + } + + // auxiliary file for obtaining encoding info + QFile fileAux(m_bDocIsCompressed ? strTmpfileName : strFileName); + if(! fileAux.open(IO_ReadOnly)) + { + kdDebug() << "KXEDocument::openFile: Can't open file." << endl; + return false; + } + + QTextStream txtStreamLocal( & file ); + + // Lookup at XML document encoding ----------------------------------------------- + QTextStream txtStreamAux( & fileAux ); + QString strFirstLine = txtStreamAux.readLine(); + fileAux.close(); + int iStart, iEnd; + if((iStart = strFirstLine.find("encoding", 0)) > 0) + { + QString strEncoding; + // info about encoding found; + iStart += 8; // skip encoding + + // search " or ' after encoding + if((iStart = strFirstLine.find(QRegExp("[\"']"), iStart)) > 0) + { + QChar ch = strFirstLine[iStart]; + iStart++; // skip ch + if((iEnd = strFirstLine.find(ch, iStart)) > 0) + { + strEncoding = strFirstLine.mid(iStart, iEnd - iStart); + + QTextCodec *pTextCodec = QTextCodec::codecForName(strEncoding); + if(pTextCodec) + txtStreamLocal.setCodec(pTextCodec); + else + { + KMessageBox::sorry(0, i18n("Codec for encoding %1 not found ! Using locale encoding for load.").arg(strEncoding)); + txtStreamLocal.setEncoding(QTextStream::Locale); + } + } + } + } + else + { + // XML documment dont have info about encoding, set default UTF-8 + txtStreamLocal.setCodec(QTextCodec::codecForName("UTF-8")); + } + + + //-------------------------------------------------------------------------------- + QString strFileContents = txtStreamLocal.read(); + file.close(); + + if(m_bDocIsCompressed) + { + QDir dir; + dir.remove(strTmpfileName); + } + + //-- Set string with XML to QDomDocument ------------------------------------------ + QString strErrorMsg; + int iErrorLine, iErrorColumn; + QDomDocument * pNewDoc = new QDomDocument; // first try with a new document + + if( ! pNewDoc->setContent(strFileContents, true, &strErrorMsg, &iErrorLine, &iErrorColumn) ) + { kdDebug() << "KXEDocument::openFile: Failed parsing the file." << endl; + + KMessageBox::error(0, + i18n("%1 in line %2, column %3").arg(strErrorMsg).arg(iErrorLine).arg(iErrorColumn), + i18n("Parsing error !")); + + delete pNewDoc; // remove the new document, because it's useless + return false; + } + +// The following commented code is performance wise buggy, because the string +// gets parsed a second time. I replaced it with this code. + // copy the content of the parsed document to this one + QDomNode e = pNewDoc->removeChild( pNewDoc->documentElement() ); + QDomDocument::operator=( *pNewDoc ); + appendChild( e ); +// Here comes the "buggy" code. + //this->setContent(pNewDoc->toString(),true,0,0); // and take the new one + //delete pNewDoc; // remove the former document +// To test/see the difference in loading time, you can switch the commented +// codeblocks above and compare the loading-time-differences measured in +// KXMLEditorPart::openFile. +// Olaf +// TODO: remove the comments above later + + emit sigOpened(); + + return true; +} + +void KXEDocument::setModified(bool value) +{ + m_bIsModified = value; + emit sigModified(value); +} + +void KXEDocument::setURL(KURL url) +{ + m_url = url; + emit sigURLChanged(url); +} + +void KXEDocument::updateNodeCreated(const QDomNode & node) +{ + emit sigNodeCreated(node); + setModified(); +} + +void KXEDocument::updateNodeDeleted(const QDomNode & node) +{ + emit sigNodeDeleted(node); + setModified(); +} + +void KXEDocument::updateNodeChanged( const QDomElement & domElement ) +{ + emit sigNodeChanged(domElement); + setModified(); +} + +void KXEDocument::updateNodeChanged( const QDomCharacterData & node ) +{ + emit sigNodeChanged(node); + setModified(); +} + +void KXEDocument::updateNodeChanged( const QDomProcessingInstruction &domProcInstr ) +{ + emit sigNodeChanged(domProcInstr); + setModified(); +} + +void KXEDocument::updateNodeMoved( const QDomNode & node ) +{ + emit sigNodeMoved(node); + setModified(); +} + +void KXEDocument::attachStylesheet(const KURL& stylesheet) +{ + setSpecProcInstr("xml-stylesheet",QString("type = 'text/xsl' href = '")+stylesheet.url()+"' "); +} + +void KXEDocument::detachStylesheet() +{ + removeSpecProcInstr("xml-stylesheet"); +} + +void KXEDocument::attachSchema(const KURL& schema) +{ + QDomElement domElement = documentElement(); + if (!domElement.isNull()) + { + domElement.setAttributeNS(SCHEMA_NAMESPACE, + SCHEMA_ATTRIBUTE_XSI, + schema.url()); + // refresh views + updateNodeChanged(domElement); + setModified(); + } +} + +void KXEDocument::detachSchema() +{ + QDomElement domElement = this->documentElement(); + if (!domElement.isNull()) + { + domElement.removeAttributeNS(SCHEMA_NAMESPACE,SCHEMA_ATTRIBUTE); + // refresh views + updateNodeChanged(domElement); + setModified(); + } +} + +void KXEDocument::setSpecProcInstr(const QString& target, const QString& data) +{ + // removing old one + removeSpecProcInstr(target); + // create new one + if (!data.isEmpty()) + { + QDomProcessingInstruction domProcInstr = this->createProcessingInstruction(target,data); + + QDomNode node = getSpecProcInstr("xml"); + if (!node.isNull()) + // if there is already xml instruction, then put that one below it + this->insertAfter(domProcInstr,node); + else + // otherwise put it always on the top + this->insertBefore(domProcInstr,this->firstChild()); + + updateNodeCreated(domProcInstr); + } + setModified(); +} + +void KXEDocument::removeSpecProcInstr(const QString &target) +{ + QDomNode domNode = getSpecProcInstr(target); + if (!domNode.isNull()) + { + updateNodeDeleted(domNode); + ((QDomDocument*)this)->removeChild(domNode); + setModified(); + } +} + +QDomNode KXEDocument::getSpecProcInstr(const QString& target) +{ + QDomNode result; + QDomNodeList domNodeList = this->childNodes(); + for (uint i=0;inewfile()->newFileCreaBehav() ) + { + case KXENewFileSettings::CreateEmptyFile: + break; // nothing to do in this case + + case KXENewFileSettings::CreateWithAssistance: + { + + KXEFileNewDialog dlg( 0L); + dlg.fillDialog( KXMLEditorFactory::configuration()->newfile()->dfltVersion(), + KXMLEditorFactory::configuration()->newfile()->dfltEncoding() ); + if( dlg.exec() ) + { // if the dialog has been accepted (OK pressed) + setSpecProcInstr( "xml", dlg.getData() ); + + // if the dialog shouldn't be shown anymore, the settings have to be changed + if ( dlg.m_pDontShowAgain->isChecked() ) + KXMLEditorFactory::configuration()->newfile()->setNewFileCreaBehav( KXENewFileSettings::UseDefaults, instance()->config() ); + } + + break; + } + + case KXENewFileSettings::UseDefaults: + setSpecProcInstr( "xml", QString( "version='%1' encoding='%2'" ).arg(KXMLEditorFactory::configuration()->newfile()->dfltVersion()).arg(KXMLEditorFactory::configuration()->newfile()->dfltEncoding()) ); + break; + } + emit sigOpened(); + setModified(); +} + +//------------- SLOTS, called from Part -------------------------------- + +KCommand * KXEDocument::actDetachStylesheet() +{ + QDomNode domNode = getSpecProcInstr("xml-stylesheet"); + if (!domNode.isNull()) + { + KCommand *pCmd = new KXEStylesheetDetachCommand(this,domNode.toProcessingInstruction().data()); + return pCmd; + } + return 0L; +} + +KCommand * KXEDocument::actAttachStylesheet() +{ + KXEAttachDialogBase dlg; + dlg.Label->setText(i18n("Stylesheet URL:")); + if (dlg.exec()) + { + QDomNode domNode = getSpecProcInstr("xml-stylesheet"); + QString data = ""; + if (!domNode.isNull()) + data = domNode.toProcessingInstruction().data(); + KCommand *pCmd = new KXEStylesheetAttachCommand(this,data,dlg.attachURI->url()); + return pCmd; + } + return 0L; +} + +KCommand * KXEDocument::actDetachSchema() +{ + if (!documentElement().isNull()) // just for sure... + { + KCommand *pCmd = new KXESchemaDetachCommand(this, + documentElement().attributeNS(SCHEMA_NAMESPACE, + SCHEMA_ATTRIBUTE,"") + ); + return pCmd; + } + return 0L; +} + +KCommand * KXEDocument::actAttachSchema() +{ + KXEAttachDialogBase dlg; + dlg.Label->setText(i18n("Schema URL:")); + if (dlg.exec()) + { + if (!documentElement().isNull()) // just for sure... + { + KCommand *pCmd = new KXESchemaAttachCommand(this,dlg.attachURI->url(), + documentElement().attributeNS(SCHEMA_NAMESPACE,SCHEMA_ATTRIBUTE,"")); + return pCmd; + } + } + return 0L; +} + +// Instert or edit special processing instruction +KCommand * KXEDocument::actVersionEncoding() +{ + QDomNode node = getSpecProcInstr("xml"); + KXESpecProcInstrDialog dlg; + + if(!node.isNull()) + dlg.fillDialog(node.toProcessingInstruction().data()); + else + dlg.fillDialog( KXMLEditorFactory::configuration()->newfile()->dfltVersion(), + KXMLEditorFactory::configuration()->newfile()->dfltEncoding() ); + + if(dlg.exec()) + { + QString strOldData = ""; + if (!node.isNull()) + strOldData = node.toProcessingInstruction().data(); + KCommand *pCmd = new KXEVersionEncodingCommand(this,strOldData,dlg.getData()); + return pCmd; + } + return 0L; +} diff --git a/part/kxedocument.h b/part/kxedocument.h new file mode 100644 index 0000000..2b78659 --- /dev/null +++ b/part/kxedocument.h @@ -0,0 +1,240 @@ +// +// C++ Interface: kxedocument +// +// Description: +// +// +// Author: Adam Charytoniuk , (C) 2004 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#ifndef KXEDOCUMENT_H +#define KXEDOCUMENT_H + +#include + +#include +#include +#include +#include + +#define SCHEMA_NAMESPACE "http://www.w3.org/2001/XMLSchema-instance" +#define SCHEMA_ATTRIBUTE "schemaLocation" +#define SCHEMA_ATTRIBUTE_XSI "xsi:schemaLocation" + +class QString; +class KCommand; + + +/** +@file +*/ + +/** +@short Base class for documents in KXMLEditor. + +Stores XML document data which can be manipulated by KXMLEditor application. + + +@author Adam Charytoniuk +*/ +class KXEDocument : public QObject, public QDomDocument, public KXMLGUIClient +{ + Q_OBJECT +public: + /** @short Constructor */ + KXEDocument(QObject *parent=0, const char *name=0); + + /** @short Destructor */ + ~KXEDocument(); + + /** @short Saves document into given file */ + bool save(const QString &); + + /** @short Loads document from given file */ + bool open(const QString &); + + /** @short Sets modification flag. + + Should be called after every operation done on the document content */ + void setModified(bool value=true); + + /** @short Returns true if this document was modified and not saved yet */ + bool isModified() {return m_bIsModified;} + + /** @short Changes document url */ + void setURL(KURL url); + + /** @short Executes given command and adds it into internal document command history list + + @param pCmd pointer to KXECommand object which encapsulates required operations + on a document content + */ + + /** @short Notifies views about creating new element + + @param node newly created node + */ + void updateNodeCreated(const QDomNode & node); + + /** @short Notifies views about deleting node + + This should be called before given node from the document will be deleted. + This will give a chanse to the views to remove that node visualization. + @param node that is going to be deleted + */ + void updateNodeDeleted(const QDomNode & node); + + /** @short Notifies views about element properties changes + + Should be called after element name or element attributes are changed. + @param domElement element that has changed + */ + void updateNodeChanged( const QDomElement & domElement ); + + /** @short Notifies views after change char. data properties + + Should be called after any kind of character data is changed + (including texts, comments, .CDATA sections). + @param node character data node that has changed + */ + void updateNodeChanged( const QDomCharacterData & node ) ; + + /** @short Notifies views after change proc. instr. properties + + Should be called after any processing intruction is changed. + @param domProcInstr processing instruction that has changed + */ + void updateNodeChanged( const QDomProcessingInstruction &domProcInstr ); + + /** @short Notifies views after moving node + + Should be called if any node in the document was moved. + @param node XML node that has been moved + */ + void updateNodeMoved( const QDomNode & node ); + + /** @short Removes spec. processing instruction from XML file. + + @param target name of the proc. instruction target + @warning Removes processing instruction from DomDocument children node list only (no subnodes are modiified). + @sa setSpecProcInstr() + */ + void removeSpecProcInstr(const QString &target); + + /** @short Adds or changes (if already exists) processing instruction. + + Processing instruction will be added as a child in QDomDocument object. + @param target processing intruction target + @param data processing intruction data + @sa removeSpecProcInstr() + */ + virtual void setSpecProcInstr(const QString& target, const QString& data); + + /** @short Returns processing instruction located in QDomDocument. + + If given processing intruction is not found, null node is returned. + @param target name of the processing instruction target. + @sa setSpecProcInstr() + */ + QDomNode getSpecProcInstr(const QString& target); + + /** @short Attaches stylesheet to current XML file. + + If file is already attached to stylesheet, this attachment will be overriten. + @param stylesheet url to stylesheet location + @sa detachStylesheet() + */ + virtual void attachStylesheet(const KURL& stylesheet); + + /** @short Detaches stylesheet from current XML file. + + @sa attachStylesheet()*/ + virtual void detachStylesheet(); + + /** Attaches schema to current XML file. If file is already attached to schema, + this attachment will be overriten. + @param schema url to schema location + @sa detachSchema()*/ + virtual void attachSchema(const KURL& schema); + + /** @short Detaches schema from current XML file. + + @sa attachSchema()*/ + virtual void detachSchema(); + + /** @short prepares content of newly created document. + + The preparation will be done accordingly to settings. + In addition, signal sigOpened() is emited to notify all views + about the change.*/ + virtual void newFile(); + + + /** @short Inserts special proc.instruction into document. */ + KCommand * actVersionEncoding(); + + /** @short Called on user's action response. + + Creates processing instruction + with reference to specified stylesheet URI. + */ + KCommand * actAttachStylesheet(); + + /** @short Called on user's action response. */ + KCommand * actDetachStylesheet(); + + /** @short Called on user's action response */ + KCommand * actDetachSchema(); + + /** @short Called on user's action response */ + KCommand * actAttachSchema(); + +private: + QString m_strCompressedTarEntryName; + /** Equals true if document was opened from compressed file */ + bool m_bDocIsCompressed; + /** @short Stores modification flag */ + bool m_bIsModified; + KURL m_url; + +signals: + /** @short Emmited when document has a new content. + + This may happen in the following scenarios: + - document was opened from the fille or URL, + - document has modified big part of the content + - document initialized it's content after creations + + @sa newFile() + */ + void sigOpened(); + + /** @short Emitted when document content have been changed. + + This allows to notify all attached views about that event.*/ + void sigModified(bool value); + + void sigURLChanged(KURL url); + /** @short Emitted when new node was added to document.*/ + void sigNodeCreated(const QDomNode & node); + /** @short Emitted everytime node was deleted from document.*/ + void sigNodeDeleted(const QDomNode & node); + /** @short Emitted everytime document element was changed .*/ + void sigNodeChanged( const QDomElement & domElement ); + /** @short Emitted everytime character data node was changed. + + This is the case for nodes like: + - text, + - comments, + - CDATA sections, + */ + void sigNodeChanged( const QDomCharacterData & node ) ; + /** @short Emitted everytime processing instruction in document was changed .*/ + void sigNodeChanged( const QDomProcessingInstruction &domProcInstr ); + /** @short Emitted everytime document node was moved was changed .*/ + void sigNodeMoved( const QDomNode & node ); +}; + +#endif diff --git a/part/kxedocument.rc b/part/kxedocument.rc new file mode 100644 index 0000000..b580dee --- /dev/null +++ b/part/kxedocument.rc @@ -0,0 +1,15 @@ + + + + + &File + + + + + + + + + + diff --git a/part/kxeelementdialog.cpp b/part/kxeelementdialog.cpp new file mode 100644 index 0000000..b9736b1 --- /dev/null +++ b/part/kxeelementdialog.cpp @@ -0,0 +1,189 @@ +/*************************************************************************** + kxeelementdialog.cpp - description + ------------------- + begin : Mit Apr 17 2002 + copyright : (C) 2002, 2003 by The KXMLEditor Team + email : lvanek@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "kxeelementdialog.h" + +#include +#include +#include + +#include +#include +#include + +KXEElementDialog::KXEElementDialog( QWidget * pParent, const char * pszName, bool fModal, WFlags fl ) + : KXEElementDialogBase( pParent, pszName, fModal, fl ) +{ + connect( m_pEditNsURI, SIGNAL(textChanged(const QString&)), this, SLOT(slotNsURIChanged(const QString&)) ); + connect( m_pEditName, SIGNAL(textChanged(const QString&)), this, SLOT(slotNameChanged(const QString&)) ); +} + +void KXEElementDialog::clearDialog() +{ + m_pEditNsURI->clear(); + m_pEditNsURI->setEnabled(true); + m_pEditNsURI->show(); + m_pLblNsURI->setEnabled(true); + m_pLblNsURI->show(); + + m_pEditPrefix->clear(); + m_pEditPrefix->setDisabled(true); + m_pEditPrefix->show(); + m_pLblPrefix->setEnabled(true); + m_pLblPrefix->show(); + + m_pEditName->clear(); + + m_pComboInsert->setCurrentItem(0); +} + +void KXEElementDialog::fillDialog( bool bNsURIIsNull ) +{ + m_pEditNsURI->setDisabled(true); + + if ( bNsURIIsNull ) + { + m_pEditNsURI->hide(); + m_pLblNsURI->hide(); + m_pLblNsURI->setDisabled(true); + + m_pEditPrefix->setDisabled(true); + m_pEditPrefix->hide(); + m_pLblPrefix->hide(); + m_pLblPrefix->setDisabled(true); + } + else + { + m_pEditNsURI->setText( m_strNsURI ); + m_pEditNsURI->show(); + m_pLblNsURI->show(); + m_pLblNsURI->setEnabled(true); + + m_pEditPrefix->setText( m_strPrefix ); + m_pEditPrefix->setEnabled(true); + m_pEditPrefix->show(); + m_pLblPrefix->show(); + m_pLblPrefix->setEnabled(true); + } + + m_pComboInsert->hide(); + m_pComboInsert->setDisabled(true); + m_pLblInsert->hide(); + m_pLblInsert->setDisabled(true); + + m_pEditName->setText( m_strName ); +} + +int KXEElementDialog::exec( bool bEditExisting, bool bRootElement, bool bNsURIIsNull ) +{ + if(bEditExisting) + { + fillDialog( bNsURIIsNull ); + } + else + { + if( bRootElement ) + { + m_pComboInsert->hide(); + m_pComboInsert->setDisabled(true); + m_pLblInsert->hide(); + m_pLblInsert->setDisabled(true); + } + + clearDialog(); + } + + int iReturn = exec(); + if ( iReturn == Accepted ) + { + m_strNsURI = m_pEditNsURI->text(); + m_strPrefix = m_pEditPrefix->text(); + m_strName = m_pEditName->text(); + + m_bAtTop = ( m_pComboInsert->currentItem() == 0 ); + } + + return iReturn; +} + +int KXEElementDialog::exec() +{ + if ( m_pEditName->text().isEmpty() ) + m_pBtnOK->setEnabled(false); + else + m_pBtnOK->setEnabled(true); + + m_pEditName->setFocus(); + m_pBtnOK->setDefault(true); + + return KXEElementDialogBase::exec(); +} + +void KXEElementDialog::slotNsURIChanged( const QString & strNewNsURI ) +{ + if ( strNewNsURI.isEmpty() ) + m_pEditPrefix->setEnabled(false); + else + m_pEditPrefix->setEnabled(true); +} + +void KXEElementDialog::slotNameChanged( const QString & strNewName ) +{ + QString strMessage = checkName(strNewName); + + m_pTextLabelMessage->setText(strMessage); + + if ( strNewName.isEmpty() || (strMessage.length() > 0)) + m_pBtnOK->setEnabled(false); + else + m_pBtnOK->setEnabled(true); +} + +// Check, if XML element name is OK +QString KXEElementDialog::checkName(const QString strElementName) +{ + if(strElementName.length() == 0) + return ""; + + // test for space + if(strElementName.find(' ') >= 0) + return i18n("Element name cannot contain space !"); + + // test for xml, XML ... on start + if(strElementName.find("xml", 0, false) == 0) + return i18n("Element name cannot start with 'xml' or 'XML' !"); + + // check first character + QChar firstChar(strElementName[0]); + if((firstChar != '_') && !firstChar.isLetter()) + { + return i18n("Element name must start with an underscore or a letter !"); + } + + // Forbidden characters + QString strForbiddenChars("&@#$%^()%+?=:<>;\"'*"); + for(unsigned int i = 0; i < strForbiddenChars.length(); i++) + { + QChar ch = strForbiddenChars[i]; + + if(strElementName.find(ch) >= 0) + return i18n("Element name cannot contain character: %1 !").arg(ch); + } + + return ""; +} + diff --git a/part/kxeelementdialog.h b/part/kxeelementdialog.h new file mode 100644 index 0000000..8012525 --- /dev/null +++ b/part/kxeelementdialog.h @@ -0,0 +1,92 @@ +/*************************************************************************** + kxeelementdialog.h - description + ------------------ + begin : Mit Apr 17 2002 + copyright : (C) 2002, 2003 by The KXMLEditor Team + email : lvanek@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef KXEELEMENTDIALOG_H +#define KXEELEMENTDIALOG_H + +#include "kxeelementdialogbase.h" + +class KXEElementDialog : public KXEElementDialogBase +{ + Q_OBJECT + + public: + KXEElementDialog( QWidget * pParent = 0, const char * pszName = 0, bool fModal = true, WFlags fl = 0 ); + + public: + + const QString nsURI() const { return m_strNsURI; } + const QString prefix() const { return m_strPrefix; } + const QString name() const { return m_strName; } + const bool atTop() const { return m_bAtTop; } + + void setNsURI(const QString strNsURI) { m_strNsURI = strNsURI; } + void setPrefix(const QString strPrefix) { m_strPrefix = strPrefix; } + void setName(const QString strName) { m_strName = strName; } + + /** + * To be used for creating a new XML element + * + * @return see @ref QDialog::exec + */ + int exec( bool, bool, bool ); + + // check element name + static QString checkName(const QString); + + protected: + /** + * Clears the dialogs widgets (removes their content). + */ + + void clearDialog(); + + /** + * Fills the dialogs widgets with the data members. + */ + void fillDialog( bool ); + + /** + * Don't use this function directly, it's for internal use only. + * Use one of the other @ref DlgXMLElement::exec functions instead. + */ + int exec(); + /** + * Called, when the namespace URI in the edit line @ref DlgXMLElementBase::m_pEditNsURI + * is changed. + * Disables the prefix edit line (@ref DlgXMLElementBase::m_pEditPrefix), + * if the given string is empty. + */ + + + protected slots: + void slotNsURIChanged( const QString & szNewNsURI ); + /** + * Called, when the name in the edit line @ref DlgXMLElementBase::m_pEditName + * is changed. + * Disables the OK button, if the given string is empty. + */ + void slotNameChanged( const QString & szNewName ); + +protected: + QString m_strNsURI; + QString m_strPrefix; + QString m_strName; + bool m_bAtTop; +}; + +#endif diff --git a/part/kxeelementdialogbase.ui b/part/kxeelementdialogbase.ui new file mode 100644 index 0000000..0cf8cac --- /dev/null +++ b/part/kxeelementdialogbase.ui @@ -0,0 +1,339 @@ + +KXEElementDialogBase + + + KXEElementDialogBase + + + + 0 + 0 + 344 + 321 + + + + + 3 + 5 + 0 + 0 + + + + XML Element + + + true + + + + unnamed + + + 11 + + + 6 + + + + Spacer3 + + + Vertical + + + Expanding + + + + 16 + 37 + + + + + + m_pLblPrefix + + + &Prefix: + + + m_pEditPrefix + + + <b>Prefix</b> +<br/> +You can enter the namespace prefix for this XML element here. + + + + + Spacer4 + + + Vertical + + + Expanding + + + + 16 + 37 + + + + + + Spacer5 + + + Vertical + + + Expanding + + + + 16 + 37 + + + + + + m_pEditNsURI + + + <b>Namespace URI</b><br/> +You can enter the namespace URI of this XML element here. + + + + + m_pEditName + + + <b>Local Name</b> +<br/> +You have to enter this XML elements name here. + + + + + m_pEditPrefix + + + <b>Prefix</b> +<br/> +You can enter the namespace prefix for this XML element here. + + + + + m_pLblTagName + + + Local &Name: + + + m_pEditName + + + <b>Local Name</b> +<br/> +You have to enter this XML elements name here. + + + + + m_pLblNsURI + + + Namespace &URI: + + + m_pEditNsURI + + + <b>Namespace URI</b><br/> +You can enter the namespace URI of this XML element here. + + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + Horizontal Spacing2 + + + Horizontal + + + Expanding + + + + 20 + 0 + + + + + + m_pBtnOK + + + &OK + + + Alt+O + + + true + + + true + + + + + m_pBtnCancel + + + &Cancel + + + Alt+C + + + true + + + + + + + Layout4 + + + + unnamed + + + 0 + + + 6 + + + + m_pLblInsert + + + &Insert: + + + m_pComboInsert + + + <b>Insert</b> +<br/> +Choose, where to place this XML element in the parent elements list of childelements. + + + + + + at bottom + + + + + at top + + + + m_pComboInsert + + + <b>Insert</b> +<br/> +Choose, where to place this XML element in the parent elements list of childelements. + + + + + Spacer2 + + + Horizontal + + + Expanding + + + + 181 + 16 + + + + + + + + m_pTextLabelMessage + + + + 255 + 0 + 0 + + + + PlainText + + + + + + + m_pBtnOK + clicked() + KXEElementDialogBase + accept() + + + m_pBtnCancel + clicked() + KXEElementDialogBase + reject() + + + + m_pEditName + m_pComboInsert + m_pBtnOK + m_pBtnCancel + m_pEditNsURI + m_pEditPrefix + + + diff --git a/part/kxefilenewdialog.cpp b/part/kxefilenewdialog.cpp new file mode 100644 index 0000000..807f477 --- /dev/null +++ b/part/kxefilenewdialog.cpp @@ -0,0 +1,29 @@ +// +// C++ Implementation: kxefilenewdialog +// +// Description: +// +// +// Author: Adam Charytoniuk , (C) 2003 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#include "kxefilenewdialog.h" + +#include +#include + +KXEFileNewDialog::KXEFileNewDialog(QWidget* parent, const char* name) + : KXESpecProcInstrDialog(parent, name) +{ + m_pDontShowAgain->show(); + m_pHLine->show(); +} + + +KXEFileNewDialog::~KXEFileNewDialog() +{ +} + + diff --git a/part/kxefilenewdialog.h b/part/kxefilenewdialog.h new file mode 100644 index 0000000..20b3f1b --- /dev/null +++ b/part/kxefilenewdialog.h @@ -0,0 +1,31 @@ +// +// C++ Interface: kxefilenewdialog +// +// Description: +// +// +// Author: Adam Charytoniuk , (C) 2003 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#ifndef DLGFILENEW_H +#define DLGFILENEW_H + +#include "kxespecprocinstrdialog.h" + +/** +Dialog for File->New assistance. + +@author Adam Charytoniuk +*/ +class KXEFileNewDialog : public KXESpecProcInstrDialog +{ +public: + KXEFileNewDialog(QWidget* parent, const char* name=0); + + ~KXEFileNewDialog(); + +}; + +#endif diff --git a/part/kxenewfilesettings.cpp b/part/kxenewfilesettings.cpp new file mode 100644 index 0000000..fcd4562 --- /dev/null +++ b/part/kxenewfilesettings.cpp @@ -0,0 +1,207 @@ +/*************************************************************************** + kxenewfilesettings.cpp + ---------------------- + begin : Tue Dec 02 2003 + copyright : (C) 2003 by The KXMLEditor Team + email : hartig@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "kxenewfilesettings.h" +#include "kxenewfilesettingspage.h" + +#include +#include +#include + +#include +#include +#include +#include +#include + +#define CONF_ENTRY_NAME_DFLT_VERSION "Default version" +#define DFLT_VALUE_DFLT_VERSION "1.0" + +#define CONF_ENTRY_NAME_DFLT_ENCODING "Default encoding" +#define DFLT_VALUE_DFLT_ENCODING "UTF-8" + +#define CONF_ENTRY_NAME_DFLT_NEWFILE_CREAT_BEHAVIOUR "Default behaviour" +#define DFLT_VALUE_NEWFILE_CREAT_BEHAVIOUR UseDefaults + + +KXENewFileSettings::KXENewFileSettings( QObject * pParent, const char * pszName ) + : KXESettings( "New File Settings", pParent, pszName ), + m_strDfltVersion( DFLT_VALUE_DFLT_VERSION ), + m_strDfltEncoding( DFLT_VALUE_DFLT_ENCODING ), + m_enmNewFileCreaBehav( DFLT_VALUE_NEWFILE_CREAT_BEHAVIOUR ), + m_pDialogPage(0) +{ +} + + +void KXENewFileSettings::write( KConfig * pConfig ) const +{ + pConfig->writeEntry( CONF_ENTRY_NAME_DFLT_VERSION, m_strDfltVersion ); + pConfig->writeEntry( CONF_ENTRY_NAME_DFLT_ENCODING, m_strDfltEncoding ); + pConfig->writeEntry( CONF_ENTRY_NAME_DFLT_NEWFILE_CREAT_BEHAVIOUR, m_enmNewFileCreaBehav ); +} + + +void KXENewFileSettings::read( const KConfig * pConfig ) +{ + m_strDfltVersion = pConfig->readEntry( CONF_ENTRY_NAME_DFLT_VERSION, DFLT_VALUE_DFLT_VERSION ); + m_strDfltEncoding = pConfig->readEntry( CONF_ENTRY_NAME_DFLT_ENCODING, DFLT_VALUE_DFLT_ENCODING ); + m_enmNewFileCreaBehav = static_cast ( pConfig->readNumEntry( CONF_ENTRY_NAME_DFLT_NEWFILE_CREAT_BEHAVIOUR, DFLT_VALUE_NEWFILE_CREAT_BEHAVIOUR ) ); +} + + +QString KXENewFileSettings::dialogPageName() const +{ + return i18n( "New Files" ); +} + +QString KXENewFileSettings::dialogPageHeader() const +{ + return i18n( "New File Settings" ); +} + +QString KXENewFileSettings::dialogPageIcon() const +{ + return "files"; +} + + +QWidget * KXENewFileSettings::dialogPage( QFrame * pParent ) +{ + + if ( ! m_pDialogPage ) + { + // create the page if necessary + m_pDialogPage = new KXENewFileSettingsPage( pParent, "new files config.dialog page" ); + + // and fill its widgets with the corresponding values + m_pDialogPage->m_pDfltEncoding->insertStringList( encodings() ); + updatePage(); + + connect( m_pDialogPage->m_pDfltVersion, SIGNAL(textChanged(const QString&)), this, SIGNAL(sigDialogPageChanged()) ); + connect( m_pDialogPage->m_pDfltEncoding, SIGNAL(activated(int)), this, SIGNAL(sigDialogPageChanged()) ); + connect( m_pDialogPage->m_pNewFileCreatBehav1, SIGNAL(toggled(bool)), this, SIGNAL(sigDialogPageChanged()) ); + connect( m_pDialogPage->m_pNewFileCreatBehav2, SIGNAL(toggled(bool)), this, SIGNAL(sigDialogPageChanged()) ); + connect( m_pDialogPage->m_pNewFileCreatBehav3, SIGNAL(toggled(bool)), this, SIGNAL(sigDialogPageChanged()) ); + } + + return m_pDialogPage; +} + +void KXENewFileSettings::setFromPage() +{ + if ( m_pDialogPage ) + { + m_strDfltVersion = m_pDialogPage->m_pDfltVersion->text(); + m_strDfltEncoding = m_pDialogPage->m_pDfltEncoding->currentText(); + + if ( m_pDialogPage->m_pNewFileCreatBehav1->isChecked() ) + m_enmNewFileCreaBehav = CreateEmptyFile; + else if ( m_pDialogPage->m_pNewFileCreatBehav2->isChecked() ) + m_enmNewFileCreaBehav = CreateWithAssistance; + else if ( m_pDialogPage->m_pNewFileCreatBehav3->isChecked() ) + m_enmNewFileCreaBehav = UseDefaults; + } +} + +void KXENewFileSettings::updatePage() const +{ + if ( m_pDialogPage ) + { + m_pDialogPage->m_pDfltVersion->setText( m_strDfltVersion ); + m_pDialogPage->m_pDfltEncoding->setCurrentText( m_strDfltEncoding ); + + switch ( m_enmNewFileCreaBehav ) + { + case CreateEmptyFile: + m_pDialogPage->m_pNewFileCreatBehav->setButton( m_pDialogPage->m_pNewFileCreatBehav->id( m_pDialogPage->m_pNewFileCreatBehav1 ) ); + break; + case CreateWithAssistance: + m_pDialogPage->m_pNewFileCreatBehav->setButton( m_pDialogPage->m_pNewFileCreatBehav->id( m_pDialogPage->m_pNewFileCreatBehav2 ) ); + break; + case UseDefaults: + m_pDialogPage->m_pNewFileCreatBehav->setButton( m_pDialogPage->m_pNewFileCreatBehav->id( m_pDialogPage->m_pNewFileCreatBehav3 ) ); + break; + default: + kdError() << "KXENewFileSettings::updatePage: unknown creation behavior" << endl; + } + } +} + +QStringList KXENewFileSettings::encodings() +{ + static QStringList lstEncs; + if ( lstEncs.empty() ) + { + lstEncs.append("UTF-8"); + lstEncs.append("ISO-8859-1"); + lstEncs.append("ISO-8859-2"); + lstEncs.append("ISO-8859-3"); + lstEncs.append("ISO-8859-4"); + lstEncs.append("ISO-8859-5"); + lstEncs.append("ISO-8859-6"); + lstEncs.append("ISO-8859-7"); + lstEncs.append("ISO-8859-8"); + lstEncs.append("ISO-8859-9"); + } + return lstEncs; +} + + +///////////////////////////////////////////////// +// function(s) to set this settings group data // +///////////////////////////////////////////////// + +void KXENewFileSettings::setNewFileCreaBehav( NewFileCreationBehaviour enmNewFileCreaBehav, KConfig * pConfig ) +{ + // if the data really has been changed + if ( m_enmNewFileCreaBehav != enmNewFileCreaBehav ) + { + // set this object's data to the new one given + m_enmNewFileCreaBehav = enmNewFileCreaBehav; + + // update the corresponding widget in the config.dialog page, if necessary + if ( m_pDialogPage ) + { + blockSignals( true ); + + switch ( enmNewFileCreaBehav ) + { + case CreateEmptyFile: + m_pDialogPage->m_pNewFileCreatBehav->setButton( m_pDialogPage->m_pNewFileCreatBehav->id( m_pDialogPage->m_pNewFileCreatBehav1 ) ); + break; + case CreateWithAssistance: + m_pDialogPage->m_pNewFileCreatBehav->setButton( m_pDialogPage->m_pNewFileCreatBehav->id( m_pDialogPage->m_pNewFileCreatBehav2 ) ); + break; + case UseDefaults: + m_pDialogPage->m_pNewFileCreatBehav->setButton( m_pDialogPage->m_pNewFileCreatBehav->id( m_pDialogPage->m_pNewFileCreatBehav3 ) ); + break; + default: + kdError() << "KXENewFileSettings::dialogPage: unknown creation behavior" << endl; + } + + blockSignals( false ); + } + + // store the new data (only the given one) to the given config file + setConfigGroup( pConfig ); + pConfig->writeEntry( CONF_ENTRY_NAME_DFLT_NEWFILE_CREAT_BEHAVIOUR, m_enmNewFileCreaBehav ); + + // and inform everyone about the changing of our data + emit sigChanged(); + } +} diff --git a/part/kxenewfilesettings.h b/part/kxenewfilesettings.h new file mode 100644 index 0000000..b1203ec --- /dev/null +++ b/part/kxenewfilesettings.h @@ -0,0 +1,111 @@ +/*************************************************************************** + kxenewfilesettings.h + -------------------- + begin : Tue Dec 02 2003 + copyright : (C) 2003 by The KXMLEditor Team + email : hartig@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef KXENEWFILESETTINGS_H +#define KXENEWFILESETTINGS_H + +#include "kxesettings.h" + +class KXENewFileSettingsPage; + +/** + * This class represents the group of configuration settings for + * new files. + * + * @author Olaf Hartig + */ +class KXENewFileSettings : public KXESettings +{ + public: + + enum NewFileCreationBehaviour + { + CreateEmptyFile, + CreateWithAssistance, + UseDefaults + }; + + KXENewFileSettings( QObject * pParent = 0, const char * pszName = 0 ); + + // The following functions can be used to access this object's settings. + QString dfltVersion() const { return m_strDfltVersion; } + QString dfltEncoding() const { return m_strDfltEncoding; } + NewFileCreationBehaviour newFileCreaBehav() const { return m_enmNewFileCreaBehav; } + + /** + * Returns a list of all possible encodings. + */ + static QStringList encodings(); + + /** + * Sets this object's new file creation behavior to the given one, + * updates the corresponding widget (in the config.dialog page + * @ref m_pDialogPage), stores this value to the given config.file + * and emits the signal @ref KXESettings::sigChanged. + */ + void setNewFileCreaBehav( NewFileCreationBehaviour, KConfig * ); + + /** + * Derived from @ref KXESettings + */ + virtual QString dialogPageName() const; + /** + * Derived from @ref KXESettings + */ + virtual QString dialogPageHeader() const; + /** + * Derived from @ref KXESettings + */ + virtual QString dialogPageIcon() const; + /** + * Derived from @ref KXESettings + */ + virtual QWidget * dialogPage( QFrame * pParent ); + + protected: + + /** + * Derived from @ref KXESettings + */ + virtual void write( KConfig * ) const; + /** + * Derived from @ref KXESettings + */ + virtual void read( const KConfig * ); + /** + * Derived from @ref KXESettings + */ + virtual void setFromPage(); + /** + * Derived from @ref KXESettings + */ + virtual void updatePage() const; + + // the settings itself + QString m_strDfltVersion; + QString m_strDfltEncoding; + NewFileCreationBehaviour m_enmNewFileCreaBehav; + + /** + * the corresponding configuration dialog page + * It is created on demand by @ref dialogPage. + */ + KXENewFileSettingsPage * m_pDialogPage; + +}; + +#endif diff --git a/part/kxenewfilesettingspage.ui b/part/kxenewfilesettingspage.ui new file mode 100644 index 0000000..bf766e8 --- /dev/null +++ b/part/kxenewfilesettingspage.ui @@ -0,0 +1,176 @@ + +KXENewFileSettingsPage + + + KXENewFileSettingsPage + + + + 0 + 0 + 288 + 197 + + + + New File Settings Page + + + + unnamed + + + + layout3 + + + + unnamed + + + + m_pLblDfltVersion + + + XML &version: + + + m_pDfltVersion + + + <b>XML version</b> +<br> +You can determine the default XML version for XML documents being created. This version is the default setting in wizard dialogs.<br> +Since there's only one XML version yet, you shouldn't change this value. + + + + + m_pDfltVersion + + + <b>XML version</b> +<br> +You can determine the default XML version for XML documents being created. This version is the default setting in wizard dialogs.<br> +Since there's only one XML version yet, you shouldn't change this value. + + + + + + + layout4 + + + + unnamed + + + + m_pLblDfltEncoding + + + Default &encoding: + + + m_pDfltEncoding + + + <b>Default encoding</b> +<br> +You can determine the default encoding for XML documents being created. This version is the default setting in wizard dialogs. + + + + + m_pDfltEncoding + + + <b>Default encoding</b> +<br> +You can determine the default encoding for XML documents being created. This version is the default setting in wizard dialogs. + + + + + + + m_pNewFileCreatBehav + + + &Behavior on creating new files + + + true + + + <b>Behavior on creating new files</b> +<br> +You can determine the behavior on creating new XML documents. Choose one of the following:<br> +<br> +<b><i>Start with new empty file</i></b><br> +Creates an empty XML document.<br> +<br> +<b><i>Start with file settings dialog assistance</i></b><br> +Opens a dialog to choose the XML version and encoding of the new document.<br> +<br> +<b><i>Start with new file with default settings</i></b><br> +Creates an XML document with the default XML version and default encoding selected above. + + + + unnamed + + + + m_pNewFileCreatBehav1 + + + Start with new empty file + + + + + m_pNewFileCreatBehav2 + + + Start with file settings dialog assistance + + + true + + + + + m_pNewFileCreatBehav3 + + + Start with new file with default settings + + + false + + + + + + + spacer8 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + + + diff --git a/part/kxeprintsettings.cpp b/part/kxeprintsettings.cpp new file mode 100644 index 0000000..765102b --- /dev/null +++ b/part/kxeprintsettings.cpp @@ -0,0 +1,134 @@ +/*************************************************************************** + kxeprintsettings.cpp + -------------------- + begin : Tue Dec 02 2003 + copyright : (C) 2003 by The KXMLEditor Team + email : hartig@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "kxeprintsettings.h" +#include "kxeprintsettingspage.h" + +#include +#include +#include + +#include +#include +#include + +#define CONF_ENTRY_NAME_FONTFAMILY "Print font family" +#define DFLT_VALUE_FONTFAMILY "Courier" + +#define CONF_ENTRY_NAME_FONTSIZE "Print font size" +#define DFLT_VALUE_FONTSIZE 10 + +#define CONF_ENTRY_NAME_INDENT_STEPS "Print indentation" +#define DFLT_VALUE_INDENT_STEPS 2 + +#define CONF_ENTRY_NAME_WITH_FOOTER "Print has footer" +#define DFLT_VALUE_WITH_FOOTER true + +#define CONF_ENTRY_NAME_WITH_HEADER "Print has header" +#define DFLT_VALUE_WITH_HEADER true + + +KXEPrintSettings::KXEPrintSettings( QObject * pParent, const char * pszName ) + : KXESettings( "Print Settings", pParent, pszName ), + m_strFontFamily( DFLT_VALUE_FONTFAMILY ), + m_iFontSize( DFLT_VALUE_FONTSIZE ), + m_iIndentSteps( DFLT_VALUE_INDENT_STEPS ), + m_bWithHeader( DFLT_VALUE_WITH_FOOTER ), + m_bWithFooter( DFLT_VALUE_WITH_HEADER ), + m_pDialogPage(0) +{ +} + + +void KXEPrintSettings::write( KConfig * pConfig ) const +{ + pConfig->writeEntry( CONF_ENTRY_NAME_FONTFAMILY, m_strFontFamily ); + pConfig->writeEntry( CONF_ENTRY_NAME_FONTSIZE, m_iFontSize ); + pConfig->writeEntry( CONF_ENTRY_NAME_INDENT_STEPS, m_iIndentSteps ); + pConfig->writeEntry( CONF_ENTRY_NAME_WITH_FOOTER, m_bWithHeader ); + pConfig->writeEntry( CONF_ENTRY_NAME_WITH_HEADER, m_bWithFooter ); +} + + +void KXEPrintSettings::read( const KConfig * pConfig ) +{ + m_strFontFamily = pConfig->readEntry( CONF_ENTRY_NAME_FONTFAMILY, DFLT_VALUE_FONTFAMILY ); + m_iFontSize = pConfig->readNumEntry( CONF_ENTRY_NAME_FONTSIZE, DFLT_VALUE_FONTSIZE ); + m_iIndentSteps = pConfig->readNumEntry( CONF_ENTRY_NAME_INDENT_STEPS, DFLT_VALUE_INDENT_STEPS ); + m_bWithHeader = pConfig->readBoolEntry( CONF_ENTRY_NAME_WITH_FOOTER, DFLT_VALUE_WITH_FOOTER ); + m_bWithFooter = pConfig->readBoolEntry( CONF_ENTRY_NAME_WITH_HEADER, DFLT_VALUE_WITH_HEADER ); +} + +QString KXEPrintSettings::dialogPageName() const +{ + return i18n( "Printing" ); +} + +QString KXEPrintSettings::dialogPageHeader() const +{ + return i18n( "Print Settings" ); +} + +QString KXEPrintSettings::dialogPageIcon() const +{ + return "printer2"; +} + +QWidget * KXEPrintSettings::dialogPage( QFrame * pParent ) +{ + if ( ! m_pDialogPage ) + { + // create the page if necessary + m_pDialogPage = new KXEPrintSettingsPage( pParent, "printing config.dialog page" ); + + // and fill its widgets with the corresponding values + updatePage(); + + connect( m_pDialogPage->m_pFontFamily, SIGNAL(activated(int)), this, SIGNAL(sigDialogPageChanged()) ); + connect( m_pDialogPage->m_pFontSize, SIGNAL(valueChanged(int)), this, SIGNAL(sigDialogPageChanged()) ); + connect( m_pDialogPage->m_pIndentSteps, SIGNAL(valueChanged(int)), this, SIGNAL(sigDialogPageChanged()) ); + connect( m_pDialogPage->m_pWithHeader, SIGNAL(toggled(bool)), this, SIGNAL(sigDialogPageChanged()) ); + connect( m_pDialogPage->m_pWithFooter, SIGNAL(toggled(bool)), this, SIGNAL(sigDialogPageChanged()) ); + } + + return m_pDialogPage; +} + + +void KXEPrintSettings::setFromPage() +{ + if ( m_pDialogPage ) + { + m_strFontFamily = m_pDialogPage->m_pFontFamily->currentText(); + m_iFontSize = m_pDialogPage->m_pFontSize->value(); + m_iIndentSteps = m_pDialogPage->m_pIndentSteps->value(); + m_bWithHeader = m_pDialogPage->m_pWithHeader->isChecked(); + m_bWithFooter = m_pDialogPage->m_pWithFooter->isChecked(); + } +} + +void KXEPrintSettings::updatePage() const +{ + if ( m_pDialogPage ) + { + m_pDialogPage->m_pFontFamily->setCurrentFont( m_strFontFamily ); + m_pDialogPage->m_pFontSize->setValue( m_iFontSize ); + m_pDialogPage->m_pIndentSteps->setValue( m_iIndentSteps ); + m_pDialogPage->m_pWithHeader->setChecked( m_bWithHeader ); + m_pDialogPage->m_pWithFooter->setChecked( m_bWithFooter ); + } +} diff --git a/part/kxeprintsettings.h b/part/kxeprintsettings.h new file mode 100644 index 0000000..fb833f6 --- /dev/null +++ b/part/kxeprintsettings.h @@ -0,0 +1,95 @@ +/*************************************************************************** + kxeprintsettings.h + ------------------ + begin : Tue Dec 02 2003 + copyright : (C) 2003 by The KXMLEditor Team + email : hartig@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef KXEPRINTSETTINGS_H +#define KXEPRINTSETTINGS_H + +#include "kxesettings.h" + +class KXEPrintSettingsPage; + +/** + * This class represents the group of configuration settings for + * printing. + * + * @author Olaf Hartig + */ +class KXEPrintSettings : public KXESettings +{ + public: + + KXEPrintSettings( QObject * pParent = 0, const char * pszName = 0 ); + + // The following functions can be used to access this object's settings. + QString fontFamily() const { return m_strFontFamily; } + int fontSize() const { return m_iFontSize; } + int indentSteps() const { return m_iIndentSteps; } + bool hasHeader() const { return m_bWithHeader; } + bool hasFooter() const { return m_bWithFooter; } + + /** + * Derived from @ref KXESettings + */ + virtual QString dialogPageName() const; + /** + * Derived from @ref KXESettings + */ + virtual QString dialogPageHeader() const; + /** + * Derived from @ref KXESettings + */ + virtual QString dialogPageIcon() const; + /** + * Derived from @ref KXESettings + */ + virtual QWidget * dialogPage( QFrame * pParent ); + + protected: + + /** + * Derived from @ref KXESettings + */ + virtual void write( KConfig * ) const; + /** + * Derived from @ref KXESettings + */ + virtual void read( const KConfig * ); + /** + * Derived from @ref KXESettings + */ + virtual void setFromPage(); + /** + * Derived from @ref KXESettings + */ + virtual void updatePage() const; + + // the settings itself + QString m_strFontFamily; + int m_iFontSize; + int m_iIndentSteps; + bool m_bWithHeader; + bool m_bWithFooter; + + /** + * the corresponding configuration dialog page + * It is created on demand by @ref dialogPage. + */ + KXEPrintSettingsPage * m_pDialogPage; + +}; + +#endif diff --git a/part/kxeprintsettingspage.ui b/part/kxeprintsettingspage.ui new file mode 100644 index 0000000..a857413 --- /dev/null +++ b/part/kxeprintsettingspage.ui @@ -0,0 +1,228 @@ + +KXEPrintSettingsPage + + + KXEPrintSettingsPage + + + + 0 + 0 + 292 + 187 + + + + Print Settings Page + + + + unnamed + + + + m_pLblFontFamily + + + NoFrame + + + Plain + + + Font &family: + + + m_pFontFamily + + + <b>Font family</b> +<br> +Choose the font family you want to be used on printing your XML documents. + + + + + m_pFontFamily + + + <b>Font family</b> +<br> +Choose the font family you want to be used on printing your XML documents. + + + + + layout3 + + + + unnamed + + + + m_pLblFontSize + + + Font &size: + + + m_pFontSize + + + <b>Font size</b> +<br> +Choose the font size you want to be used on printing your XML documents. + + + + + m_pFontSize + + + pt + + + + + + 6 + + + 10 + + + <b>Font size</b> +<br> +Choose the font size you want to be used on printing your XML documents. + + + + + spacer3 + + + Horizontal + + + Expanding + + + + 31 + 20 + + + + + + + + layout4 + + + + unnamed + + + + m_pLblIndentSteps + + + Element &indentation: + + + m_pIndentSteps + + + <b>Element indentation</b> +<br> +Choose the number of characters you want to be used for indenting childnodes on printing you XML documents. + + + + + m_pIndentSteps + + + <b>Element indentation</b> +<br> +Choose the number of characters you want to be used for indenting childnodes on printing you XML documents. + + + + + spacer2 + + + Horizontal + + + Expanding + + + + 41 + 20 + + + + + + + + m_pWithHeader + + + &Print header + + + Alt+P + + + <b>Print header</b> +<br> +You can determine wether you want a header to be printed on every page when printing you XML documents or not. + + + + + m_pWithFooter + + + P&rint footer + + + Alt+R + + + <b>Print footer</b> +<br> +You can determine wether you want a footline to be printed on every page when printing you XML documents or not. + + + + + spacer10 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + + + + kfontcombo.h + klineedit.h + + diff --git a/part/kxeprocinstrdialog.cpp b/part/kxeprocinstrdialog.cpp new file mode 100644 index 0000000..7ddbf21 --- /dev/null +++ b/part/kxeprocinstrdialog.cpp @@ -0,0 +1,183 @@ +/*************************************************************************** + kxeprocinstrdialog.cpp - description + ------------------- + begin : Mit Apr 24 2002 + copyright : (C) 2002, 2003 by The KXMLEditor Team + email : lvanek@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "kxeprocinstrdialog.h" + +#include +#include +#include +#include + +#include +#include +#include +#include + +KXEProcInstrDialog::KXEProcInstrDialog( QWidget * pParent, const char * pszName, bool fModal, WFlags fl ) + : KXEProcInstrDialogBase( pParent, pszName, fModal, fl ) +{ + // signals and slots connections + connect( m_pBtnOK, SIGNAL( clicked() ), this, SLOT( slotAccept() ) ); + connect( m_pEditData, SIGNAL(textChanged()), this, SLOT(slotDataChanged()) ); + connect( m_pEditTarget, SIGNAL(textChanged(const QString &)), this, SLOT(slotTargetChanged(const QString &)) ); +} + + +void KXEProcInstrDialog::clearDialog() +{ + m_pEditTarget->clear(); + m_pEditData->clear(); +} + + +int KXEProcInstrDialog::exec( bool bEditExisting, bool bParentIsDocument ) +{ + if(bEditExisting) + { + m_pComboInsert->hide(); + m_pComboInsert->setDisabled(true); + m_pLblInsert->hide(); + m_pLblInsert->setDisabled(true); + + m_pEditTarget->setDisabled(true); + + m_pEditTarget->setText( m_strTarget ); + m_pEditData->setText( m_strData ); + } + else + { + if ( bParentIsDocument ) + { + m_pComboInsert->hide(); + m_pComboInsert->setDisabled(true); + m_pLblInsert->hide(); + m_pLblInsert->setDisabled(true); + } + m_pEditTarget->setEnabled(true); + clearDialog(); + } + + int iReturn = exec(); + if ( iReturn == Accepted ) + { + m_bAtTop = ( m_pComboInsert->currentItem() == 0 ); + m_strTarget = m_pEditTarget->text(); + m_strData = m_pEditData->text(); + } + + return iReturn; +} + +int KXEProcInstrDialog::exec() +{ + if ( m_pEditTarget->text().isEmpty() ) + m_pBtnOK->setEnabled(false); + else + m_pBtnOK->setEnabled(true); + + if ( m_pEditTarget->isEnabled() ) + m_pEditTarget->setFocus(); + else + m_pEditData->setFocus(); + + m_pBtnOK->setDefault(true); + + return KXEProcInstrDialogBase::exec(); +} + +void KXEProcInstrDialog::slotDataChanged() +{ + QString strMessage = checkData(m_pEditData->text()); + if(strMessage.isEmpty()) + strMessage = checkTarget(m_pEditTarget->text()); + + m_pTextLabelMessage->setText(strMessage); + + if ( m_pEditData->text().isEmpty() || + m_pEditTarget->text().isEmpty() || + (strMessage.length() > 0) + ) + m_pBtnOK->setDisabled(true); + else + m_pBtnOK->setEnabled(true); +} + +void KXEProcInstrDialog::slotTargetChanged(const QString &strNewTarget) +{ + QString strMessage = checkTarget(strNewTarget); + if(strMessage.isEmpty()) + strMessage = checkData(m_pEditData->text()); + + m_pTextLabelMessage->setText(strMessage); + + if ( m_pEditData->text().isEmpty() || + strNewTarget.isEmpty() || + (strMessage.length() > 0) + ) + m_pBtnOK->setDisabled(true); + else + m_pBtnOK->setEnabled(true); +} + +/** Called when user press OK button */ +void KXEProcInstrDialog::slotAccept() +{ + if(m_pEditTarget->text() == "xml") + { KMessageBox::sorry(this, i18n("Pleasse use menu item File -> Version and encoding for this processing instruction !")); + return; + } + + accept(); +} + +// Check, if XML proc. instr. target is OK +QString KXEProcInstrDialog::checkTarget(const QString strTarget) +{ + if(strTarget.length() == 0) + return ""; + + // Forbidden characters + QString strForbiddenChars("<>"); + for(unsigned int i = 0; i < strForbiddenChars.length(); i++) + { + QChar ch = strForbiddenChars[i]; + + if(strTarget.find(ch) >= 0) + return i18n("Target cannot contain character: %1 !").arg(ch); + } + + return ""; +} + +// Check, if XML proc. instr. data is OK +QString KXEProcInstrDialog::checkData(const QString strData) +{ + if(strData.length() == 0) + return ""; + + // Forbidden characters + QString strForbiddenChars("<>"); + for(unsigned int i = 0; i < strForbiddenChars.length(); i++) + { + QChar ch = strForbiddenChars[i]; + + if(strData.find(ch) >= 0) + return i18n("Contents cannot contain character: %1 !").arg(ch); + } + + return ""; +} diff --git a/part/kxeprocinstrdialog.h b/part/kxeprocinstrdialog.h new file mode 100644 index 0000000..5b4de2e --- /dev/null +++ b/part/kxeprocinstrdialog.h @@ -0,0 +1,87 @@ +/*************************************************************************** + kxeprocinstrdialog.h - description + -------------------- + begin : Mit Apr 24 2002 + copyright : (C) 2002, 2003 by The KXMLEditor Team + email : lvanek@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef KXEPROCINSTRDIALOG_H +#define KXEPROCINSTRDIALOG_H + +#include "kxeprocinstrdialogbase.h" + +class KXEProcInstrDialog : public KXEProcInstrDialogBase +{ + Q_OBJECT + + public: + KXEProcInstrDialog( QWidget * pParent = 0, const char * pszName = 0, bool fModal = true, WFlags fl = 0 ); + + const bool atTop() const { return m_bAtTop; } + const QString target() const { return m_strTarget; } + const QString data() const { return m_strData; } + + void setTarget(const QString strTarget) { m_strTarget = strTarget; } + void setData(const QString strData) { m_strData = strData; } + + public: + + /** + * To be used for inserting a proc.instruction as child + * of the given parent node. + * + * @return see @ref QDialog::exec + */ + int exec( bool, bool ); + + /** + * Clears the dialogs widgets. + */ + void clearDialog(); + + // check target + static QString checkTarget(const QString); + + // check data + static QString checkData(const QString); + + protected: + /** + * Don't use this function directly, it's for internal use only. + * Use one of the other @ref KXEProcInstrDialog::exec functions instead. + */ + int exec(); + + protected slots: + /** + * Called, when the data edit box is changed. + * Disables the OK button, if the editbox is empty. + */ + void slotDataChanged(); + + /** + * Called, when the target edit box is changed. + * Disables the OK button, if the editbox is empty. + */ + void slotTargetChanged(const QString &); + + /** Called when user press OK button */ + void slotAccept(); + + protected: + QString m_strTarget; + QString m_strData; + bool m_bAtTop; +}; + +#endif diff --git a/part/kxeprocinstrdialogbase.ui b/part/kxeprocinstrdialogbase.ui new file mode 100644 index 0000000..c77d10b --- /dev/null +++ b/part/kxeprocinstrdialogbase.ui @@ -0,0 +1,223 @@ + +KXEProcInstrDialogBase + + + KXEProcInstrDialogBase + + + + 0 + 0 + 367 + 244 + + + + Processing Instruction + + + true + + + + unnamed + + + 11 + + + 6 + + + + layout4 + + + + unnamed + + + + m_pLblTarget + + + &Target: + + + m_pEditTarget + + + <b>Target</b><br/> +Define the target of this processing instruction here. + + + + + m_pEditTarget + + + <b>Target</b><br/> +Define the target of this processing instruction here. + + + + + Spacer2 + + + Horizontal + + + Expanding + + + + 60 + 20 + + + + + + m_pLblInsert + + + &Insert: + + + m_pComboInsert + + + <b>Insert</b> +<br/> +Choose, where to place this processing instruction in the parent elements list. + + + + + + at bottom + + + + + at top + + + + m_pComboInsert + + + <b>Insert</b> +<br/> +Choose, where to place this processing instruction in the parent elements list. + + + + + + + m_pEditData + + + NoWrap + + + Here you can enter the data (the instructions) of this XML processing instruction. + + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + Horizontal Spacing2 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + m_pBtnOK + + + &OK + + + Alt+O + + + true + + + true + + + + + m_pBtnCancel + + + &Cancel + + + Alt+C + + + true + + + + + + + m_pTextLabelMessage + + + + 255 + 0 + 0 + + + + + + + + m_pBtnCancel + clicked() + KXEProcInstrDialogBase + reject() + + + + m_pEditTarget + m_pComboInsert + m_pEditData + m_pBtnOK + m_pBtnCancel + + + diff --git a/part/kxesearchdialog.cpp b/part/kxesearchdialog.cpp new file mode 100644 index 0000000..5830e96 --- /dev/null +++ b/part/kxesearchdialog.cpp @@ -0,0 +1,56 @@ +/*************************************************************************** + kxesearchdialog.cpp - description + ------------------- + begin : Tue Jul 10 2001 + copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team + email : lvanek@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "kxesearchdialog.h" + +#include + +KXESearchDialog::KXESearchDialog(QWidget *parent, const char *name, bool modal) + : KXESearchDialogBase(parent, name, modal) +{ + m_pPushButtonFind->setEnabled(false); + m_pEditSearchedString->setFocus(); + m_pPushButtonFind->setDefault(true); +} + +void KXESearchDialog::slotTextChanged(const QString& string) +{ + if ( string.isEmpty() ) + m_pPushButtonFind->setEnabled(false); + else + m_pPushButtonFind->setEnabled(true); + + toggleAcceptButton(); +} + +void KXESearchDialog::slotFindInChanged() +{ + toggleAcceptButton(); +} + +void KXESearchDialog::toggleAcceptButton() +{ + if ( (m_pCheckBoxElementNames->isChecked()) ||(m_pCheckBoxAttributeNames->isChecked()) || (m_pCheckBoxAttributeValues->isChecked()) || (m_pCheckBoxContents->isChecked()) ) + { + if ( m_pEditSearchedString->text().isEmpty() ) + m_pPushButtonFind->setEnabled(false); + else + m_pPushButtonFind->setEnabled(true); + } + else + m_pPushButtonFind->setEnabled(false); +} diff --git a/part/kxesearchdialog.h b/part/kxesearchdialog.h new file mode 100644 index 0000000..abe7f3d --- /dev/null +++ b/part/kxesearchdialog.h @@ -0,0 +1,57 @@ +/*************************************************************************** + kxesearchdialog.h - description + ----------------- + begin : Tue Jul 10 2001 + copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team + email : lvanek@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef KXESEARCHDIALOG_H +#define KXESEARCHDIALOG_H + +#include "kxesearchdialogbase.h" + +#include +#include + +/** + * Dialog for input information from user + * about searching in XML document + */ +// TODO add possibility to search backwards +class KXESearchDialog : public KXESearchDialogBase +{ + Q_OBJECT + + public: + KXESearchDialog( QWidget * pParent, const char * pszName = 0, bool bModal = true ); + + QString getSearchString() const { return m_pEditSearchedString->text(); } + bool getMatchCase() const { return m_pCheckBoxMatchCase->isChecked(); } + bool getInElementNames() const { return m_pCheckBoxElementNames->isChecked(); } + bool getInAttributeNames() const { return m_pCheckBoxAttributeNames->isChecked(); } + bool getInAttributeValues() const { return m_pCheckBoxAttributeValues->isChecked(); } + bool getInContents() const { return m_pCheckBoxContents->isChecked(); } + + protected: + /** Enables/Disables the "Find"-button. */ + void toggleAcceptButton(); + + protected slots: + /** Called when text in edit line is changed */ + virtual void slotTextChanged(const QString & ); + + /** Called on a change of the "find in" checkbuttons. */ + virtual void slotFindInChanged(); +}; + +#endif diff --git a/part/kxesearchdialogbase.ui b/part/kxesearchdialogbase.ui new file mode 100644 index 0000000..23be699 --- /dev/null +++ b/part/kxesearchdialogbase.ui @@ -0,0 +1,350 @@ + +KXESearchDialogBase +Dialog for input information from user +about searching in XML document +Lumir Vanek + + + KXESearchDialogBase + + + + 0 + 0 + 354 + 244 + + + + + 330 + 240 + + + + + 0 + 0 + + + + Search + + + + unnamed + + + 11 + + + 6 + + + + Layout5 + + + + unnamed + + + 0 + + + 6 + + + + m_pTextLabelSearchedString + + + MShape + + + MShadow + + + &Search string: + + + m_pEditSearchedString + + + <b>Search string</b></br> +Here you can enter the string you want to search for in your XML document. + + + + + Spacer3 + + + Horizontal + + + Expanding + + + + 262 + 0 + + + + + + + + m_pEditSearchedString + + + <b>Search string</b></br> +Here you can enter the string you want to search for in your XML document. + + + + + layout13 + + + + unnamed + + + + Spacer2 + + + Horizontal + + + Expanding + + + + 154 + 16 + + + + + + m_pPushButtonFind + + + &Find + + + + + m_pPushButtonCancel + + + &Cancel + + + + + + + Spacer9 + + + Vertical + + + Expanding + + + + 16 + 131 + + + + + + m_pGroupBoxSearchIn + + + Find &in + + + <b>Find in</b> +<br/> +Here you can choose the parts of your XML document that should be inspected during the search. +<br/> +These are +<br/> +<br/> +<b><i>Element names</i></b><br/> +<b><i>Attribute names</i></b><br/> +<b><i>Attribute values</i></b><br/> +<b><i>Content</i></b> + + + + unnamed + + + 11 + + + 6 + + + + m_pCheckBoxElementNames + + + Element names + + + + + m_pCheckBoxAttributeNames + + + Attribute names + + + + + m_pCheckBoxAttributeValues + + + Attribute values + + + + + m_pCheckBoxContents + + + Content + + + + + + + layout23 + + + + unnamed + + + + spacer19 + + + Horizontal + + + Expanding + + + + 18 + 20 + + + + + + m_pCheckBoxMatchCase + + + &Match case + + + Alt+M + + + <b>Match case</b><br/> +Check this for case sensitive search. + + + + + spacer20 + + + Horizontal + + + Expanding + + + + 19 + 20 + + + + + + + + + + m_pEditSearchedString + textChanged(const QString&) + KXESearchDialogBase + slotTextChanged(const QString&) + + + m_pPushButtonCancel + clicked() + KXESearchDialogBase + reject() + + + m_pPushButtonFind + clicked() + KXESearchDialogBase + accept() + + + m_pCheckBoxElementNames + stateChanged(int) + KXESearchDialogBase + slotFindInChanged() + + + m_pCheckBoxAttributeNames + stateChanged(int) + KXESearchDialogBase + slotFindInChanged() + + + m_pCheckBoxAttributeValues + stateChanged(int) + KXESearchDialogBase + slotFindInChanged() + + + m_pCheckBoxContents + stateChanged(int) + KXESearchDialogBase + slotFindInChanged() + + + + m_pEditSearchedString + m_pCheckBoxElementNames + m_pCheckBoxAttributeNames + m_pCheckBoxAttributeValues + m_pCheckBoxContents + m_pCheckBoxMatchCase + m_pPushButtonFind + m_pPushButtonCancel + + + slotFindInChanged() + slotTextChanged(const QString &) + + + diff --git a/part/kxesettings.cpp b/part/kxesettings.cpp new file mode 100644 index 0000000..013e73f --- /dev/null +++ b/part/kxesettings.cpp @@ -0,0 +1,67 @@ +/*************************************************************************** + kxesettings.cpp + --------------- + begin : Tue Dec 02 2003 + copyright : (C) 2003 by The KXMLEditor Team + email : hartig@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "kxesettings.h" + +#include + +KXESettings::KXESettings( const QString & strConfigGroup, QObject * pParent, const char * pszName ) + : QObject( pParent, pszName ), + m_bPageChanged( false ), + m_strConfigGroup( strConfigGroup ) +{ + connect( this, SIGNAL(sigDialogPageChanged()), this, SLOT(slotDialogPageChanged()) ); +} + +void KXESettings::setConfigGroup( KConfig * pConfig ) const +{ + pConfig->setGroup( m_strConfigGroup ); +} + +void KXESettings::store( KConfig * pConfig ) const +{ + setConfigGroup( pConfig ); + write( pConfig ); +} + +void KXESettings::restore( KConfig * pConfig ) +{ + setConfigGroup( pConfig ); + read( pConfig ); + + // update the corresponding config.dialog page + blockSignals( true ); // block this object's signals (especially sigDialogPageChanged) + updatePage(); + blockSignals( false ); // unblock the signals + + emit sigChanged(); +} + +void KXESettings::slotDialogPageChanged() +{ + m_bPageChanged = true; +} + +void KXESettings::apply() +{ + if ( m_bPageChanged ) + { + setFromPage(); + m_bPageChanged = false; + emit sigChanged(); + } +} diff --git a/part/kxesettings.h b/part/kxesettings.h new file mode 100644 index 0000000..804c63e --- /dev/null +++ b/part/kxesettings.h @@ -0,0 +1,175 @@ +/*************************************************************************** + kxesettings.h + ------------- + begin : Tue Dec 02 2003 + copyright : (C) 2003 by The KXMLEditor Team + email : hartig@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef KXESETTINGS_H +#define KXESETTINGS_H + +#include + +class KConfig; +class QFrame; + +/** + * This is an abstract base class for classes representing a group, that stores + * several configuration settings and manages a corresponding page in the + * configuration dialog. + * + * @author Olaf Hartig + */ +class KXESettings : public QObject +{ + Q_OBJECT + + public: + + /** + * the constructor + * + * @param strConfigGroup the name of the corresponding group in the config file, + * it is copied to the member @ref m_strConfigGroup + */ + KXESettings( const QString & strConfigGroup, QObject * pParent = 0, const char * pszName = 0 ); + + /** + * Stores this settings to the given @ref KConfig object, by doing the + * following things: + * + * - set the config group by calling @ref setConfigGroup + * - write the data to the given @ref KConfig object by calling @ref write + * (which is implemented in the child class) + */ + void store( KConfig * ) const; + /** + * Restores the settings from the given @ref KConfig object, by doing + * following things: + * + * - set the config group by calling @ref setConfigGroup + * - read the data from the given @ref KConfig object by calling @ref read + * (which is implemented in the child class) + * - try to update the corresponding config.page by calling @ref updatePage + * (implemented in the child class) + * - emit the signal sigChanged + */ + void restore( KConfig * ); + /** + * If the data in the corresponding configuration dialog page has been + * changed (@ref m_bPageChanged), this data gets applied by the + * @ref setFromPage member function implemented in child classes, + * the flag @ref m_bPageChanged is reset (to false) and the signal + * sigChanged is emitted. + */ + void apply(); + + /** + * Override this function and return the name of the corresponding + * configuration dialog page. This is the name used in the list of + * pages in the configuration dialog. + * This name has to be internationalized. + */ + virtual QString dialogPageName() const = 0; + /** + * You can override this function and return a header line to + * be used for the corresponding configuration dialog page. + * If it's not overridden, the pages name is used (see + * @ref dialogPageName) + * This string has to be internationalized. + */ + virtual QString dialogPageHeader() const { return QString::null; } + /** + * Override this function and return the (file-)name of the icon + * to be used in the configuration dialog for the corresponding page. + */ + virtual QString dialogPageIcon() const = 0; + /** + * Override this function to create the corresponding configuration + * dialog page with the given parent and return it. + * Update the page's widgets (usually by using @ref updatePage). + * Connect the signal @ref sigDialogPageChanged to the page's + * data changed signal(s). + */ + virtual QWidget * dialogPage( QFrame * pParent ) = 0; + + + signals: + + /** + * This signal is always emitted when the settings change. + * It is emitted by @ref restore and @ref apply. + */ + void sigChanged(); + /** + * Emitted, when the data in the corresponding dialog page + * has been changed. + * Connect this signal to the page's changed signal in your + * child class in @ref dialogPage. + */ + void sigDialogPageChanged(); + + protected: + + /** + * Overide this function and write your settings to the given KConfig object. + * You mustn't change the config group. + */ + virtual void write( KConfig * ) const = 0; + /** + * Overide this function and read the settings from the given KConfig object. + * You mustn't change the config group. + */ + virtual void read( const KConfig * ) = 0; + /** + * Override this function to set this object's data to the data in the + * corresponding configuration dialog page, if a page has already been + * created (check this!). + */ + virtual void setFromPage() = 0; + /** + * Override this function to update the widgets in the corresponding + * configuration dialog page with the current data (from your child class + * object), if a page has already been created (check this!). + */ + virtual void updatePage() const = 0; + + /** + * Sets the config group of the given @ref KConfig object to + * this setting's config group (@ref m_strConfigGroup). + */ + void setConfigGroup( KConfig * ) const; + + /** + * This flag is set to true if the data in the corresponding configuration + * dialog's page has been changed but not applied yet. + */ + bool m_bPageChanged; + + protected slots: + + /** + * Sets the flag @ref m_bPageChanged to true. + */ + void slotDialogPageChanged(); + + private: + + /** + * name of the config group for this group of settings + */ + const QString m_strConfigGroup; + +}; + +#endif diff --git a/part/kxespecprocinstrdialog.cpp b/part/kxespecprocinstrdialog.cpp new file mode 100644 index 0000000..09f1224 --- /dev/null +++ b/part/kxespecprocinstrdialog.cpp @@ -0,0 +1,135 @@ +/*************************************************************************** + kxespecprocinstrdialog.cpp - description + -------------------------- + begin : Ne ?ec 6 2003 + copyright : (C) 2003 by The KXMLEditor Team + email : lvanek@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "kxespecprocinstrdialog.h" + +#include "kxmleditorfactory.h" +#include "kxeconfiguration.h" +#include "kxenewfilesettings.h" + +#include +#include +#include +#include +#include +#include +#include + +#include + +KXESpecProcInstrDialog::KXESpecProcInstrDialog(QWidget *parent, const char *name ) + : KXESpecProcInstrDialogBase(parent,name) +{ + m_pComboBoxEncoding->insertStringList( KXMLEditorFactory::configuration()->newfile()->encodings() ); + + m_pLineEditVersion->setText("1.0"); + + m_pHLine->hide(); + m_pDontShowAgain->hide(); + + // signals and slots connections + connect( m_pBtnOK, SIGNAL( clicked() ), this, SLOT( slotAccept() ) ); +} + +KXESpecProcInstrDialog::~KXESpecProcInstrDialog() +{ +} + +void KXESpecProcInstrDialog::fillDialog( const QString strData ) +{ + QString strVersion; + QString strEncoding; + + int iStart, iEnd; + + // find version info + if((iStart = strData.find("version", 0)) >= 0) + { + // info about encoding found; + iStart += 7; // skip version + + // search " or ' after encoding + if((iStart = strData.find(QRegExp("[\"']"), iStart)) > 0) + { + QChar ch = strData[iStart]; + iStart++; // skip ch + if((iEnd = strData.find(ch, iStart)) > 0) + strVersion = strData.mid(iStart, iEnd - iStart); + } + } + else + strVersion = "1.0"; + + // find encoding info + if((iStart = strData.find("encoding", 0)) >= 0) + { + // info about encoding found; + iStart += 8; // skip encoding + + // search " or ' after encoding + if((iStart = strData.find(QRegExp("[\"']"), iStart)) > 0) + { + QChar ch = strData[iStart]; + iStart++; // skip ch + if((iEnd = strData.find(ch, iStart)) > 0) + strEncoding = strData.mid(iStart, iEnd - iStart); + } + } + else + strEncoding = "UTF-8"; + + + m_pLineEditVersion->setText(strVersion); + m_pComboBoxEncoding->setCurrentText(strEncoding); +} + +int KXESpecProcInstrDialog::exec() +{ + m_pBtnOK->setDefault(true); + + return KXESpecProcInstrDialogBase::exec(); +} + + +/** Called when user press OK button */ +void KXESpecProcInstrDialog::slotAccept() +{ + accept(); +} + + +/*! + Initializes content of dialog controls with specified values. + @param version XML file version + @param encoding encoding type for the XML file + */ +void KXESpecProcInstrDialog::fillDialog(const QString& version, const QString& encoding) +{ + + m_pLineEditVersion->setText(version); + m_pComboBoxEncoding->setCurrentText(encoding); +} + + +/*! + Returns content of the dialog as an string of format: '"version = '...' encoding = '...' ". + */ +QString KXESpecProcInstrDialog::getData() +{ + return QString("version = '")+m_pLineEditVersion->text()+ + "' encoding = '"+m_pComboBoxEncoding->currentText()+"' "; +} diff --git a/part/kxespecprocinstrdialog.h b/part/kxespecprocinstrdialog.h new file mode 100644 index 0000000..c78301f --- /dev/null +++ b/part/kxespecprocinstrdialog.h @@ -0,0 +1,54 @@ +/*************************************************************************** + kxespecprocinstrdialog.h - description + ------------------------ + begin : Ne ?ec 6 2003 + copyright : (C) 2003 by The KXMLEditor Team + email : lvanek@users.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef KXESPECPROCINSTRDIALOG_H +#define KXESPECPROCINSTRDIALOG_H + +#include "kxespecprocinstrdialogbase.h" + +#include + +/** + *@author Lumir Vanek + */ + +class KXESpecProcInstrDialog : public KXESpecProcInstrDialogBase +{ + Q_OBJECT + +public: + KXESpecProcInstrDialog(QWidget *parent=0, const char *name=0); + ~KXESpecProcInstrDialog(); + + QString getData(); + + /** Initialize dialog from given target and data string */ + void fillDialog(const QString&, const QString&); + + /** Initialize dialog from given data string */ + void fillDialog(const QString); + + int exec(); + +protected slots: + + /** Called when user press OK button */ + void slotAccept(); + +}; + +#endif diff --git a/part/kxespecprocinstrdialogbase.ui b/part/kxespecprocinstrdialogbase.ui new file mode 100644 index 0000000..1bcbb25 --- /dev/null +++ b/part/kxespecprocinstrdialogbase.ui @@ -0,0 +1,191 @@ + +KXESpecProcInstrDialogBase +Lumir Vanek + + + KXESpecProcInstrDialogBase + + + + 0 + 0 + 216 + 191 + + + + + 5 + 5 + 0 + 0 + + + + Special processing instruction + + + + unnamed + + + 11 + + + 6 + + + + m_pTextLabel1 + + + XML &version: + + + m_pLineEditVersion + + + <b>XML version</b><br/> +You can determine the XML version for XML document. + + + + + m_pLineEditVersion + + + <b>XML version</b><br/> +You can determine the XML version for XML document. + + + + + m_pTextLabel2 + + + &Encoding: + + + m_pComboBoxEncoding + + + <b>Encoding</b><br/> +You can determine the encoding used while saving this XML document. + + + + + m_pComboBoxEncoding + + + true + + + <b>Encoding</b><br/> +You can determine the encoding used while saving this XML document. + + + + + layout4 + + + + unnamed + + + + m_pDontShowAgain + + + Do not show this dialog again + + + Ctrl+T + + + <b>Do not show this dialog again</b><br/> +If you select this option, your choice will be remembered. Next time you create a new file, you won't be disturbed by this dialog box. + + + + + + + m_pHLine + + + HLine + + + Raised + + + + + layout2 + + + + unnamed + + + + spacer1 + + + Horizontal + + + Expanding + + + + 40 + 20 + + + + + + m_pBtnOK + + + &OK + + + true + + + + + m_pBtnCancel + + + &Cancel + + + false + + + + + + + + + m_pBtnCancel + clicked() + KXESpecProcInstrDialogBase + reject() + + + + m_pLineEditVersion + m_pComboBoxEncoding + m_pDontShowAgain + m_pBtnOK + m_pBtnCancel + + + diff --git a/part/kxesyntaxhighlighter.cpp b/part/kxesyntaxhighlighter.cpp new file mode 100644 index 0000000..c783077 --- /dev/null +++ b/part/kxesyntaxhighlighter.cpp @@ -0,0 +1,257 @@ +/*************************************************************************** + kxesyntaxhighlighter.cpp - XML Syntax highlighter + ------------------- + begin : Ne pro 14 2003 + copyright : (C) 2003 by The KXMLEditor Team + email : lvanek.sourceforge.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "kxesyntaxhighlighter.h" + +#include + +#include +#include +#include +#include + +#include + +// Regular expressions for parsing XML borrowed from: +// http://www.cs.sfu.ca/~cameron/REX.html + +KXESyntaxHighlighter::KXESyntaxHighlighter(QTextEdit *textEdit) + : QSyntaxHighlighter(textEdit) +{ + m_clrDefaultText.setRgb(0, 0, 0); + m_clrElementName.setRgb(128, 0, 0); + m_clrAttributeName.setRgb(0, 255, 255); + m_clrAttributeValue.setRgb(0, 255, 0); + m_clrXmlSyntaxChar.setRgb(0, 0, 128); + m_clrComment.setRgb(128, 128, 128); + m_clrSyntaxError.setRgb(255, 0, 0); +} + +KXESyntaxHighlighter::~KXESyntaxHighlighter() +{ +} + + +int KXESyntaxHighlighter::highlightParagraph(const QString& text, int endStateOfLastPara) +{ + //first I format the given line to default so any remaining highlighting is removed (Qt does not do it by itself) + setFormat(0 , text.length(), QColor(0, 0, 0)); + + int iBracketNesting = 0; + m_eParserState = parsingNone; + int pos; + unsigned int i = 0; + + if(endStateOfLastPara == 1) + { + QRegExp patternComment("[^-]*-([^-][^-]*-)*->"); // search end of comment + pos=patternComment.search(text, i); + + if(pos >= 0) // end comment found ? + { + int l = patternComment.matchedLength(); + + setFormat(0, l - 3, m_clrComment); + setFormat(l - 3, 3, m_clrXmlSyntaxChar ); + i += l; // skip comment + } + else + { + setFormat(0, text.length(), m_clrComment); + return 1; // return 1 to signify "in comment" + } + } + + for(; i < text.length() - 1; i++) + { + switch(text[i]) + { + case '<': + iBracketNesting++; + + if(iBracketNesting == 1) + { setFormat( i, 1, m_clrXmlSyntaxChar ); + m_eParserState = expectElementNameOrSlash; + } + else + setFormat( i, 1, m_clrSyntaxError ); // wrong bracket nesting + + break; + + case '>': + iBracketNesting--; + + if(iBracketNesting == 0) + setFormat( i, 1, m_clrXmlSyntaxChar ); + else + setFormat( i, 1, m_clrSyntaxError ); // wrong bracket nesting + + m_eParserState = parsingNone; + + break; + + case '/': + + if(m_eParserState == expectElementNameOrSlash) + { + m_eParserState = expectElementName; + setFormat( i, 1, m_clrXmlSyntaxChar ); + } + else + { + if(m_eParserState == expectAtttributeOrEndOfElement) + setFormat( i, 1, m_clrXmlSyntaxChar ); + else + processDefaultText(i, text); + } + + break; + + case '=': + if(m_eParserState == expectEqual) + { + m_eParserState = expectAttributeValue; + setFormat( i, 1, m_clrXmlSyntaxChar ); + } + else + { + processDefaultText(i, text); + } + break; + + case '\"': + + if(m_eParserState == expectAttributeValue) + { + QRegExp patternAttribute("\"[^<\"]*\"|'[^<']*'"); // search attribute value + pos=patternAttribute.search(text, i); + + if(pos == (int) i) // attribute value found ? + { + int l = patternAttribute.matchedLength(); + + setFormat(i, 1, m_clrXmlSyntaxChar ); + setFormat(i+1, l - 2, m_clrAttributeValue); + setFormat(i+l-1, 1, m_clrXmlSyntaxChar ); + + i += l - 1; // skip attribute value + m_eParserState = expectAtttributeOrEndOfElement; + } + else + processDefaultText(i, text); + } + else + processDefaultText(i, text); + + break; + + case '!': + if(m_eParserState == expectElementNameOrSlash) + { + QRegExp patternComment("