From 47becbedc6788937ab25df5220f0bf25291b62e8 Mon Sep 17 00:00:00 2001 From: Mavridis Philippe Date: Fri, 9 Aug 2024 14:47:08 +0300 Subject: [PATCH] Initial commit Signed-off-by: Mavridis Philippe --- AUTHORS | 4 + COPYING | 340 ++++++++++++++++++ ChangeLog | 78 +++++ Doxyfile | 248 ++++++++++++++ INSTALL | 16 + Makefile.am | 22 ++ Makefile.cvs | 10 + NEWS | 1 + README | 64 ++++ TODO | 5 + configure.in.in | 11 + debian/changelog | 12 + debian/control | 14 + debian/rules | 12 + doc/Makefile.am | 6 + doc/en/Makefile.am | 2 + doc/en/index.docbook | 555 ++++++++++++++++++++++++++++++ kalternatives.kdevelop | 152 ++++++++ kalternatives.kdevelop.pcs | Bin 0 -> 53020 bytes kalternatives.kdevses | 39 +++ kalternatives.pro | 11 + src/Makefile.am | 21 ++ src/addalternatives.cpp | 121 +++++++ src/addalternatives.h | 50 +++ src/addalternativesui.ui | 259 ++++++++++++++ src/addslaves.cpp | 55 +++ src/addslaves.h | 43 +++ src/addslavesui.ui | 167 +++++++++ src/altcontroller.cpp | 53 +++ src/altcontroller.h | 44 +++ src/altitemelement.cpp | 118 +++++++ src/altitemelement.h | 58 ++++ src/altparser.cpp | 609 +++++++++++++++++++++++++++++++++ src/altparser.h | 140 ++++++++ src/hi16-app-kalternatives.png | Bin 0 -> 1033 bytes src/hi32-app-kalternatives.png | Bin 0 -> 2749 bytes src/kalternatives.cpp | 457 +++++++++++++++++++++++++ src/kalternatives.desktop | 37 ++ src/kalternatives.h | 83 +++++ src/kalternatives.lsm | 16 + src/kalternativesui.rc | 8 + src/main.cpp | 77 +++++ src/main.h | 8 + src/mainwindow.ui | 392 +++++++++++++++++++++ src/propertieswindow.ui | 106 ++++++ src/treeitemelement.cpp | 70 ++++ src/treeitemelement.h | 56 +++ templates/cpp | 19 + templates/h | 19 + 49 files changed, 4688 insertions(+) create mode 100644 AUTHORS create mode 100644 COPYING create mode 100644 ChangeLog create mode 100644 Doxyfile create mode 100644 INSTALL create mode 100644 Makefile.am create mode 100644 Makefile.cvs create mode 100644 NEWS create mode 100644 README create mode 100644 TODO create mode 100644 configure.in.in create mode 100644 debian/changelog create mode 100644 debian/control create mode 100755 debian/rules create mode 100644 doc/Makefile.am create mode 100644 doc/en/Makefile.am create mode 100644 doc/en/index.docbook create mode 100644 kalternatives.kdevelop create mode 100644 kalternatives.kdevelop.pcs create mode 100644 kalternatives.kdevses create mode 100644 kalternatives.pro create mode 100644 src/Makefile.am create mode 100644 src/addalternatives.cpp create mode 100644 src/addalternatives.h create mode 100644 src/addalternativesui.ui create mode 100644 src/addslaves.cpp create mode 100644 src/addslaves.h create mode 100644 src/addslavesui.ui create mode 100644 src/altcontroller.cpp create mode 100644 src/altcontroller.h create mode 100644 src/altitemelement.cpp create mode 100644 src/altitemelement.h create mode 100644 src/altparser.cpp create mode 100644 src/altparser.h create mode 100644 src/hi16-app-kalternatives.png create mode 100644 src/hi32-app-kalternatives.png create mode 100644 src/kalternatives.cpp create mode 100644 src/kalternatives.desktop create mode 100644 src/kalternatives.h create mode 100644 src/kalternatives.lsm create mode 100644 src/kalternativesui.rc create mode 100644 src/main.cpp create mode 100644 src/main.h create mode 100644 src/mainwindow.ui create mode 100644 src/propertieswindow.ui create mode 100644 src/treeitemelement.cpp create mode 100644 src/treeitemelement.h create mode 100644 templates/cpp create mode 100644 templates/h diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..3086729 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,4 @@ +Author: +Juanjo Alvarez +Mario Bensi +Pino Toscano diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..397d62c --- /dev/null +++ b/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..304781e --- /dev/null +++ b/ChangeLog @@ -0,0 +1,78 @@ +0.12 +[Mario] + +* KCM Module + +0.11 +[Mario] + +* Bugfix, modification of interface, add/remove alternatives, search the +description on rpm/deb package, show alternative's properties + +0.10 +[Juanjo] + +* First C++ version for user convenience. No new features but a lot more lines +of code ;) Also the installation procedure will be not standart autotools. + +0.9.1 +[Juanjo] + +* Desktop file and desktop file installation + +0.9 +[Juanjo] + +* Started KDEification. Still lacking some things + +0.8 +[Juanjo] + +* Mandrake support + +0.7 +[Juanjo] +* Added "Expand All" and "Collapse All" buttons + +* Now all tree items are collapsed at program init + +0.6 + +* Fixes + +0.5 + +* Corrected some typos in the README (thanks Martin Atukunda) + +* Corrected a bug where kalternatives didn't exited in some cases + where it should. + +0.4 + +* Bug fixed. + +* Unhadled exceptions should now be shown in a dialog to the user so he can + report them to me. + +0.3 + +* Since the program is so simple, I've joined the two (small) source files in + one. + +* Non-root user checking and warnings. + +* Some documentation. + +0.2 + +* Some method documentation + +* Implemented Aaron's suggestions. + +* Refactor of some code (now is a lot simpler) + +0.1 + +* Now closing the window using the window "close" button will also ask for + confirmation if there are still changes pending. +* Some small fixes diff --git a/Doxyfile b/Doxyfile new file mode 100644 index 0000000..8f9efa7 --- /dev/null +++ b/Doxyfile @@ -0,0 +1,248 @@ +# Doxyfile 1.3.5-KDevelop + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = kalternatives +PROJECT_NUMBER = 0.12 +OUTPUT_DIRECTORY = +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 = NO +STRIP_FROM_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 +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 = +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.idl \ + *.odl \ + *.cs \ + *.php \ + *.php3 \ + *.inc \ + *.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 = YES +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 = NO +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 = NO +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 = +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 = YES +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..3909ce9 --- /dev/null +++ b/INSTALL @@ -0,0 +1,16 @@ +What you need: + +- KDE >= 3.2 +- Qt +- All development packages for KDE (kdelibs & qt) + +To install configure the program with the correct prefix for +your KDE installation (like /usr or /opt/kde3 or similar) + +./configure --prefix=... + +And finally: + +make install + +Now you should be able to run the "kalternatives" command. diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..3e2cd4f --- /dev/null +++ b/Makefile.am @@ -0,0 +1,22 @@ +SUBDIRS = src doc + +$(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: + cd $(top_srcdir) && $(MAKE) -f admin/Makefile.common package-messages + $(MAKE) -C po merge + +EXTRA_DIST = admin COPYING configure.in.in + +dist-hook: + cd $(top_distdir) && perl admin/am_edit -padmin + cd $(top_distdir) && $(MAKE) -f admin/Makefile.common subdirs diff --git a/Makefile.cvs b/Makefile.cvs new file mode 100644 index 0000000..4c0afd1 --- /dev/null +++ b/Makefile.cvs @@ -0,0 +1,10 @@ +all: + @echo "This Makefile is only for the CVS repository" + @echo "This will be deleted before making the distribution" + @echo "" + $(MAKE) -f admin/Makefile.common cvs + +dist: + $(MAKE) -f admin/Makefile.common dist + +.SILENT: diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..0519ecb --- /dev/null +++ b/NEWS @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/README b/README new file mode 100644 index 0000000..49db3b1 --- /dev/null +++ b/README @@ -0,0 +1,64 @@ +README for Kalternatives +------------------------ + +Kalternatives is a KDE program that a allows you to easily configure and +change your Mandrake/Debian alternatives system. + +What is the Mandrake/Debian Alternatives System? +---------------------------------------- + +The Mandrake/Debian alternatives system is designed to allow the system administrator to +select an alternative when there are several options that provide the same file +or functionality. For example, there are several different packages on Mandrake/Debian +that provide the command "vi" (the standard POSIX text editor) and Mandrake/Debian (and +other distributions using this same system as Mandrake Linux) allows you to +have more than one option installed (for example, to satisfy the needs for +different users on a multiuser system). But, how does Mandrake/Debian knows which of the +installed programs must be run when "vi" is entered on a shell? The answer is: +using the alternatives system. This system keeps a database of provided +alternatives for every option on /var/lib/dpkg/alternatives and a collection of +links on /etc/alternatives that point to the real program. So, if your default +version of "vi" is "vim", the link /usr/bin/vi will point to +/etc/alternatives/vi that points to /usr/bin/vim. But if in the future you +would like to change /usr/bin/vi to point to the nvi executable you could: + +1. Change the link on /etc/alternatives/vi by hand. +2. Use the Mandrake/Debian command update-alternatives --config vi +3. Use Kalternatives. + + +How is the program used? +------------------------ + +The program should be very simple to use; once executed (as root) you will be +presented with a window showing a list where there are entries with yellow +squares and subentries bellow them. The entries are "nodes", that is, programs +that can have one or more alternative packages providing them and the +subentries are the alternatives. You can select one alternative just by +clicking on the radiobutton to the left of his name and pushing the "Apply" +button. Then you will be presented with a dialog showing you the changes to be +made and allowing you to confirm them before really changing the alternatives. + +Please note that some "nodes" only have one alternative because there are no +more packages installed providing it and some alternatives are disabled (you +will be unable to click on them). This last case is because the alternative +exists in the database but the link to it is broken. This sometimes happends +with unclean packages uninstallations and usually is not something to worry +about. + +Who do I have to whine if the program fails for me? +-------------------------------------------------- + +To Juanjo Álvarez + +What is the KDE-Mandrake/Debian project? +------------------------------- + +The KDE-Debian project is composed of some individuals, actively supported by +some companies, trying to provide Debian and Debian based distributions with a +collection of first-class, updated KDE desktop including some KDE applications +specifically designed for Debian. If you want to support the info by money or +by work (coding, translations, testing) you can have more info on the +kde-Debian mailing list: + +https://mail.kde.org/mailman/listinfo/kde-Mandrake/Debian diff --git a/TODO b/TODO new file mode 100644 index 0000000..bfc1aea --- /dev/null +++ b/TODO @@ -0,0 +1,5 @@ +* Help, documentation, whatsthis and tooltips +* Implement as a nice kcontrol/kadmin/kwhatever module +* .spec file for building Mandrake RPMS +* Decent debian/ subdir (I'm not using Debian anymore so I need help + with this one) diff --git a/configure.in.in b/configure.in.in new file mode 100644 index 0000000..4f9eb42 --- /dev/null +++ b/configure.in.in @@ -0,0 +1,11 @@ +#MIN_CONFIG(3.0.0) + +AM_INIT_AUTOMAKE(kalternatives, 0.10) +AC_C_BIGENDIAN +AC_CHECK_KDEMAXPATHLEN + +AC_CHECK_FILE(/etc/debian_version, [AC_DEFINE([DEBIAN], [], [debian]) AC_MSG_NOTICE(it is a debian)], +[AC_CHECK_FILE(/etc/mandrakelinux-release, +[AC_DEFINE([MANDRAKE], [], [mandrake]) AC_MSG_NOTICE(it is a mandrake)], +[AC_MSG_NOTICE(it is an other distribution)])]) + diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..8fba3fa --- /dev/null +++ b/debian/changelog @@ -0,0 +1,12 @@ +kalternatives (0.12-1) unstable; urgency=low + + * Initial release. + + -- > Tue, 14 Oct 2004 13:07:14 +0100 + +kalternatives (0.10-1) unstable; urgency=low + + * Initial release. + + -- > Tue, 30 Dec 2003 22:40:14 +0100 + diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..89395d7 --- /dev/null +++ b/debian/control @@ -0,0 +1,14 @@ +Source: kalternatives +Section: admin +Priority: optional +Maintainer: Mario Bensi +Build-Depends: automake1.7, debhelper (>> 4.0.18), gettext, kdelibs4-dev +Standards-Version: 3.2.1 + +Package: kalternatives +Architecture: any +Depends: ${shlibs:Depends} +Description: KDE GUI for configuring the Debian alternatives system + This program lets you configure the Debian/Mandrake alternatives system (a + system that allows you to select one alternative file for many in the + filesystem) using an easy KDE GUI. diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..d8cd816 --- /dev/null +++ b/debian/rules @@ -0,0 +1,12 @@ +#!/usr/bin/make -f + +include /usr/share/cdbs/1/rules/debhelper.mk +include /usr/share/cdbs/1/class/kde.mk + +# These variables are used by debhelper.mk; we are telling it to +# 1. dh_compress not to compress any files with the below extensions. +# 2. dh_makeshlibs to create automatic conservative version dependencies +# 3. dh_shlibdeps which directories to look in to resolve internal dependencies +DEB_COMPRESS_EXCLUDE := .bz2 .css .dcl .docbook -license +DEB_DH_MAKESHLIBS_ARGS := -V +DEB_SHLIBDEPS_INCLUDE := debian/libartsc0/usr/lib debian/libarts1/usr/lib diff --git a/doc/Makefile.am b/doc/Makefile.am new file mode 100644 index 0000000..8318f28 --- /dev/null +++ b/doc/Makefile.am @@ -0,0 +1,6 @@ +# the SUBDIRS is filled automatically by am_edit. If files are +# in this directory they are installed into the english dir + +KDE_LANG = en +KDE_DOCS = kalternatives +SUBDIRS = $(AUTODIRS) diff --git a/doc/en/Makefile.am b/doc/en/Makefile.am new file mode 100644 index 0000000..b8ef9c5 --- /dev/null +++ b/doc/en/Makefile.am @@ -0,0 +1,2 @@ +KDE_DOCS = kalternatives +KDE_LANG = en diff --git a/doc/en/index.docbook b/doc/en/index.docbook new file mode 100644 index 0000000..840fc3e --- /dev/null +++ b/doc/en/index.docbook @@ -0,0 +1,555 @@ + +kalternatives 0.10"> + + + + + + + +]> + + + + + + + + + + + + + + +The &kalternatives; Handbook + + + + + +Juanjo + +
juanjux@yahoo.es
+
+
+
+ + + + +1999 +2004 +Juanjo + + + +&FDLNotice; + + + +2001-10-18 +0.10 + + + + + +&kalternatives; is an application specially designed to do nothing you would +ever want. + + + + + + +KDE +kalternatives +nothing +nothing else + + +
+ + + + +Introduction + + + + +&kalternatives; is a program that lets you do absolutely nothing. Please report +any problems or feature requests to the &kde; mailing lists. + + + + +Using &kalternatives; + + + + + + + + +Here's a screenshot of &kalternatives; + + + + + + + + + Screenshot + + + + + + + +More &kalternatives; features + +It slices! It dices! and it comes with a free toaster! + +The Squiggle Tool + + + + + + + + Squiggle + + is used to draw squiggly lines all over +the &kalternatives; main window. It's not a bug, it's a feature! + + + + + + +Command Reference + + + + +The main &kalternatives; window + + +The File Menu + + + + + +&Ctrl;N + +File +New + +Creates a new document + + + + +&Ctrl;S + +File +Save + +Saves the document + + + + +&Ctrl;Q + +File +Quit + +Quits &kalternatives; + + + + + + + +The <guimenu>Help</guimenu> Menu + + + + + + +&help.menu.documentation; + + + + + + + +Developer's Guide to &kalternatives; + + + + +Programming &kalternatives; plugins is a joy to behold. Just read through the next +66 pages of API's to learn how! + + + + + + +XtUnmanageChildren +Xt - Geometry Management + + +XtUnmanageChildren + +remove a list of children from a parent widget's managed +list. +widgetsremoving +XtUnmanageChildren + + + + + +4 March 1996 + + +void XtUnmanageChildren(children, num_children) + WidgetList children; + Cardinal num_children; + + + +Inputs + + +children + + +Specifies an array of child widgets. Each child must be of +class RectObj or any subclass thereof. + + + + +num_children + + +Specifies the number of elements in children. + + + + + + + +Description + +XtUnmanageChildren() unmaps the specified widgets +and removes them from their parent's geometry management. +The widgets will disappear from the screen, and (depending +on its parent) may no longer have screen space allocated for +them. + +Each of the widgets in the children array must have +the same parent. + +See the “Algorithm” section below for full details of the +widget unmanagement procedure. + + + + +Usage +Unmanaging widgets is the usual method for temporarily +making them invisible. They can be re-managed with +XtManageChildren(). + +You can unmap a widget, but leave it under geometry +management by calling XtUnmapWidget(). You can +destroy a widget's window without destroying the widget by +calling XtUnrealizeWidget(). You can destroy a +widget completely with XtDestroyWidget(). + +If you are only going to unmanage a single widget, it is +more convenient to call XtUnmanageChild(). It is +often more convenient to call XtUnmanageChild() +several times than it is to declare and initialize an array +of widgets to pass to XtUnmanageChildren(). Calling +XtUnmanageChildren() is more efficient, however, +because it only calls the parent's change_managed() +method once. + + + + +Algorithm + +XtUnmanageChildren() performs the following: + + + +- + + +Ignores the child if it already is unmanaged or is being +destroyed. + + + + +- + + +Otherwise, if the child is realized, it makes it nonvisible +by unmapping it. + + + + + + + + + +Structures +The WidgetList type is simply an array of widgets: + +typedef Widget *WidgetList; + + + + + + + +Questions and Answers + + + +&reporting.bugs; +&updating.documentation; + + + + +My Mouse doesn't work. How do I quit &kalternatives;? + + +You silly goose! Check out the Commands +Section for the answer. + + + + +Why can't I twiddle my documents? + + +You can only twiddle your documents if you have the foobar.lib +installed. + + + + + + + + + +Credits and License + + +&kalternatives; + + +Program copyright 2004 Juanjo juanjux@yahoo.es + + +Contributors: + +Konqui the KDE Dragon konqui@kde.org + +Tux the Linux Penguin tux@linux.org + + + + + +Documentation copyright 2004 Juanjo juanjux@yahoo.es + + + + +&underFDL; + + + +&underGPL; +&underBSDLicense; +&underArtisticLicense; +&underX11License; + + + + +Installation + + +How to obtain &kalternatives; + + + +&install.intro.documentation; + + + + +Requirements + + + + +In order to successfully use &kalternatives;, you need &kde; 1.1. Foobar.lib is +required in order to support the advanced &kalternatives; features. &kalternatives; uses +about 5 megs of memory to run, but this may vary depending on your +platform and configuration. + + + +All required libraries as well as &kalternatives; itself can be found +on The &kalternatives; home page. + + + + +You can find a list of changes at http://apps.kde.org/kalternatives. + + + + +Compilation and Installation + + + + + +&install.compile.documentation; + + + + +Configuration + +Don't forget to tell your system to start the dtd +dicer-toaster daemon first, or &kalternatives; won't work ! + + + + + +&documentation.index; +
+ + + diff --git a/kalternatives.kdevelop b/kalternatives.kdevelop new file mode 100644 index 0000000..4d56712 --- /dev/null +++ b/kalternatives.kdevelop @@ -0,0 +1,152 @@ + + + + Juanjo + juanjux@yahoo.es + 0.10 + KDevKDEAutoProject + C++ + + C++ + Code + Qt + KDE + + + + + src/kalternatives + debug + + + src/kalternatives + executable + + + + optimized + kdevgccoptions + kdevgppoptions + kdevg77options + -O2 -g0 + + + --enable-debug=full + debug + kdevgccoptions + kdevgppoptions + kdevg77options + -O0 -g3 + + + + + + + + + + + + + + + + + false + false + + + *.o,*.lo,CVS + false + + + + + ada + ada_bugs_gcc + bash + bash_bugs + clanlib + w3c-dom-level2-html + fortran_bugs_gcc + gnome1 + gnustep + gtk + gtk_bugs + haskell + haskell_bugs_ghc + java_bugs_gcc + java_bugs_sun + pascal_bugs_fp + php + php_bugs + perl + perl_bugs + python + python_bugs + ruby + ruby_bugs + sdl + w3c-svg + sw + w3c-uaag10 + wxwindows_bugs + + + qmake User Guide + + + + + libtool + + + + + + + + + + + + false + false + + + 0.10 + + + + + + + + + false + false + false + 0 + false + false + false + false + + + + + + true + true + true + false + true + true + true + 250 + 400 + 250 + + + diff --git a/kalternatives.kdevelop.pcs b/kalternatives.kdevelop.pcs new file mode 100644 index 0000000000000000000000000000000000000000..8ebb09f7cfb55dea3ed90450f1ccf1ddb1d49a07 GIT binary patch literal 53020 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 Pu;N*Xo-1Os>Hq%&w6v=^ literal 0 HcmV?d00001 diff --git a/kalternatives.kdevses b/kalternatives.kdevses new file mode 100644 index 0000000..3a5f8de --- /dev/null +++ b/kalternatives.kdevses @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/kalternatives.pro b/kalternatives.pro new file mode 100644 index 0000000..bd8d754 --- /dev/null +++ b/kalternatives.pro @@ -0,0 +1,11 @@ +###################################################################### +# Automatically generated by qmake (1.06c) Sat Feb 28 20:13:05 2004 +###################################################################### + +TEMPLATE = app +DEPENDPATH += src +INCLUDEPATH += . src + +# Input +HEADERS += src/altparser.h src/kalternatives.h +SOURCES += src/altparser.cpp src/kalternatives.cpp src/main.cpp diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..765d616 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,21 @@ +INCLUDES = $(all_includes) + +noinst_HEADERS = kalternatives.h altparser.h altcontroller.h altitemelement.h treeitemelement.h addslaves.h addalternatives.h + +KDE_ICON = kalternatives + +# Install this plugin in the KDE modules directory +kde_module_LTLIBRARIES = kcm_kalternatives.la + +kcm_kalternatives_la_SOURCES = addslavesui.ui propertieswindow.ui addalternativesui.ui mainwindow.ui altcontroller.cpp kalternatives.cpp altparser.cpp altitemelement.cpp treeitemelement.cpp addslaves.cpp addalternatives.cpp + +kcm_kalternatives_la_LIBADD = $(LIB_KDEUI) $(LIB_KIO) +kcm_kalternatives_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined + + +kcm_kalternatives_la_METASOURCES = AUTO + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/kalternatives.pot + +xdg_apps_DATA = kalternatives.desktop diff --git a/src/addalternatives.cpp b/src/addalternatives.cpp new file mode 100644 index 0000000..220192b --- /dev/null +++ b/src/addalternatives.cpp @@ -0,0 +1,121 @@ +/*************************************************************************** + * Copyright (C) 2004 by Mario Bensi * + * nef@ipsquad.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. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "addalternatives.h" +#include "addslaves.h" +#include "treeitemelement.h" +#include "kalternatives.h" +#include "altcontroller.h" +#include "altitemelement.h" +#include "altparser.h" + +#include +#include + +#include +#include +#include +#include +#include + +AddAlternatives::AddAlternatives(TreeItemElement *treeItem, Kalternatives *kalt, int countSlaves): +AddAlternativesUi(kalt),m_treeItem(treeItem), m_kalt(kalt), m_countSlave(countSlaves) +{ + m_bOk->setGuiItem(KStdGuiItem::ok()); + m_bCancel->setGuiItem(KStdGuiItem::cancel()); + m_bAddSlave->setGuiItem(KGuiItem(i18n("&Add Slave"), "edit_add")); + + m_Path->setCaption( i18n( "Choose Alternative" ) ); + m_Path->setFilter( i18n( "*|All Files" ) ); + m_Path->setMode( KFile::File | KFile::LocalOnly ); +} + +AddAlternatives::~AddAlternatives() +{ +} + +void AddAlternatives::slotAddSlaveClicked() +{ + AddSlaves *addSlaves = new AddSlaves(this); + addSlaves->exec(); +} + +void AddAlternatives::slotOkClicked() +{ + if(!m_Path->url().isEmpty()) + { + + Item *item = m_treeItem->getItem(); + Alternative *a = new Alternative(item); + + a->setPath(m_Path->url()); + a->setPriority(m_Priority->value()); + + int countSlave = 0; + + if (!m_textSlave->text().isEmpty()) + { + QRegExp reg("\n"); + QStringList slaveList = QStringList::split(reg, m_textSlave->text()); + QStringList::Iterator it = slaveList.begin(); + for ( ; it != slaveList.end(); ++it ) + { + a->addSlave(*it); + countSlave++; + } + } + + if (countSlave == m_countSlave) + { + item->addAlternative(a); + + + AltItemElement *altItem = new AltItemElement(m_kalt->optionsList(), a); + + m_treeItem->getAltController()->addAltItem(altItem); + + + QString priority; + priority.setNum(a->getPriority()); + + altItem->setText( 1, priority); + altItem->setText( 2, a->getPath()); + QString m_small_desc = altItem->getDescription(); + + if (!m_small_desc.isEmpty()) + { + altItem->setText( 3, m_small_desc); + } + else + { + altItem->searchDescription(); + } + m_treeItem->setNbrAltChanged(TRUE); + emit m_kalt->configChanged(); + close(); + } + else + { + KMessageBox::sorry(this, i18n("The number of slaves is not good."), i18n("Number Of Slaves")); + } + } +} + +#include "addalternatives.moc" diff --git a/src/addalternatives.h b/src/addalternatives.h new file mode 100644 index 0000000..679b744 --- /dev/null +++ b/src/addalternatives.h @@ -0,0 +1,50 @@ +/*************************************************************************** + * Copyright (C) 2004 by Mario Bensi * + * nef@ipsquad.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. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _ADDALTERNATIVES_H_ +#define _ADDALTERNATIVES_H_ + +#include "addalternativesui.h" + +#include + +class TreeItemElement; +class Kalternatives; + +class AddAlternatives : public AddAlternativesUi +{ + Q_OBJECT + + TreeItemElement *m_treeItem; + Kalternatives *m_kalt; + int m_countSlave; + +public: + AddAlternatives(TreeItemElement *treeItem, Kalternatives *kalt, int countSlaves); + virtual ~AddAlternatives(); + + void addSlave(const QString& text){m_textSlave->append(text);} + +protected slots: + void slotOkClicked(); + void slotAddSlaveClicked(); +}; + +#endif //ADDALTERNATIVES_H_ diff --git a/src/addalternativesui.ui b/src/addalternativesui.ui new file mode 100644 index 0000000..e30f26c --- /dev/null +++ b/src/addalternativesui.ui @@ -0,0 +1,259 @@ + +AddAlternativesUi + + + AddAlternatives + + + + 0 + 0 + 440 + 200 + + + + + 7 + 7 + 0 + 0 + + + + Add Alternative + + + + unnamed + + + Minimum + + + + layout6 + + + + unnamed + + + 0 + + + 0 + + + + layout7 + + + + unnamed + + + + textLabel1 + + + Path: + + + + + m_Path + + + + + + + layout11 + + + + unnamed + + + + textLabel2 + + + Priority: + + + + + m_Priority + + + 1000 + + + -1000 + + + 20 + + + + + spacer8 + + + Horizontal + + + Expanding + + + + 80 + 20 + + + + + + + + spacer5 + + + Vertical + + + Expanding + + + + 20 + 16 + + + + + + m_textSlave + + + true + + + + + line1 + + + HLine + + + Sunken + + + Horizontal + + + + + layout13 + + + + unnamed + + + + m_bAddSlave + + + &Add Slave + + + + + spacer6 + + + Horizontal + + + Expanding + + + + 170 + 20 + + + + + + m_bOk + + + true + + + + 1 + 0 + 0 + 0 + + + + &OK + + + + + m_bCancel + + + &Cancel + + + + + + + + + + + + + m_bCancel + clicked() + AddAlternatives + close() + + + m_bAddSlave + clicked() + AddAlternatives + slotAddSlaveClicked() + + + m_bOk + clicked() + AddAlternatives + slotOkClicked() + + + + slotOkClicked() + slotAddSlaveClicked() + + + + kurlrequester.h + knuminput.h + ktextedit.h + kpushbutton.h + kpushbutton.h + kpushbutton.h + + diff --git a/src/addslaves.cpp b/src/addslaves.cpp new file mode 100644 index 0000000..12b47ba --- /dev/null +++ b/src/addslaves.cpp @@ -0,0 +1,55 @@ +/*************************************************************************** + * Copyright (C) 2004 by Mario Bensi * + * nef@ipsquad.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. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "addslaves.h" +#include "addalternatives.h" + +#include +#include +#include + +#include +using namespace std; + +AddSlaves::AddSlaves(AddAlternatives *addAlternatives): +AddSlavesUi(addAlternatives), m_addAlternatives(addAlternatives) +{ + m_bOk->setGuiItem(KStdGuiItem::ok()); + m_bCancel->setGuiItem(KStdGuiItem::cancel()); + + m_Path->setCaption( i18n( "Choose Slave" ) ); + m_Path->setFilter( i18n( "*|All Files" ) ); + m_Path->setMode( KFile::File | KFile::LocalOnly ); +} + +AddSlaves::~AddSlaves() +{ +} + +void AddSlaves::slotOkClicked() +{ + if(!m_Path->url().isEmpty()) + { + m_addAlternatives->addSlave(m_Path->url()); + close(); + } +} + +#include "addslaves.moc" diff --git a/src/addslaves.h b/src/addslaves.h new file mode 100644 index 0000000..efcb274 --- /dev/null +++ b/src/addslaves.h @@ -0,0 +1,43 @@ +/*************************************************************************** + * Copyright (C) 2004 by Mario Bensi * + * nef@ipsquad.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. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _ADDSLAVES_H_ +#define _ADDSLAVES_H_ + +#include "addslavesui.h" + +class AddAlternatives; + +class AddSlaves : public AddSlavesUi +{ + Q_OBJECT + + AddAlternatives *m_addAlternatives; + +public: + AddSlaves(AddAlternatives *addAlternatives); + virtual ~AddSlaves(); + +protected slots: + void slotOkClicked(); + +}; + +#endif //ADDSLAVES_H_ diff --git a/src/addslavesui.ui b/src/addslavesui.ui new file mode 100644 index 0000000..deb21e0 --- /dev/null +++ b/src/addslavesui.ui @@ -0,0 +1,167 @@ + +AddSlavesUi + + + AddSlaves + + + + 0 + 0 + 439 + 83 + + + + + 7 + 7 + 0 + 0 + + + + Add Slave + + + + unnamed + + + Minimum + + + + layout13 + + + + unnamed + + + 0 + + + 0 + + + + layout12 + + + + unnamed + + + + textLabel1 + + + Path: + + + + + m_Path + + + + + + + line2 + + + HLine + + + Sunken + + + Horizontal + + + + + layout13 + + + + unnamed + + + + spacer6 + + + Horizontal + + + Expanding + + + + 170 + 20 + + + + + + m_bOk + + + true + + + + 1 + 0 + 0 + 0 + + + + &OK + + + + + m_bCancel + + + &Cancel + + + + + + + + + + + + + m_bCancel + clicked() + AddSlaves + close() + + + m_bOk + clicked() + AddSlaves + slotOkClicked() + + + + slotOkClicked() + + + + kurlrequester.h + kpushbutton.h + kpushbutton.h + + diff --git a/src/altcontroller.cpp b/src/altcontroller.cpp new file mode 100644 index 0000000..3aae52a --- /dev/null +++ b/src/altcontroller.cpp @@ -0,0 +1,53 @@ +/*************************************************************************** + * Copyright (C) 2004 by Mario Bensi * + * nef@ipsquad.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. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "altcontroller.h" +#include "altitemelement.h" +#include "treeitemelement.h" + +AltController::AltController() +{ + m_altItemslist = new AltItemList; +} + +AltController::~AltController() +{ + if(m_altItemslist) delete m_altItemslist; +} + + +void AltController::setBoutonOnOff(KListView *list, AltItemElement *altItem) +{ + QListViewItemIterator it( list ); + AltItemElement *alt; + while ( it.current() ) + { + if((alt = dynamic_cast(it.current()))) + { + if((alt!=altItem) && alt->isOn()) + { + alt->setState(QCheckListItem::Off); + } + } + ++it; + } + +} +//#include "altcontroller.moc" diff --git a/src/altcontroller.h b/src/altcontroller.h new file mode 100644 index 0000000..87bde19 --- /dev/null +++ b/src/altcontroller.h @@ -0,0 +1,44 @@ +/*************************************************************************** + * Copyright (C) 2004 by Mario Bensi * + * nef@ipsquad.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. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _ALTCONTROLLER_H_ +#define _ALTCONTROLLER_H_ + +#include +#include + +class AltItemElement; + +typedef QPtrList AltItemList; + + +class AltController +{ + AltItemList *m_altItemslist; + +public: + AltController(); + ~AltController(); + + void setBoutonOnOff(KListView *list, AltItemElement *altItem); + void addAltItem(AltItemElement *altItem) {m_altItemslist->append(altItem);} + AltItemList *getAltItemList() {return m_altItemslist;} +}; +#endif // _ALTCONTROLLER_H_ diff --git a/src/altitemelement.cpp b/src/altitemelement.cpp new file mode 100644 index 0000000..63e9b00 --- /dev/null +++ b/src/altitemelement.cpp @@ -0,0 +1,118 @@ +/*************************************************************************** + * Copyright (C) 2004 by Mario Bensi * + * nef@ipsquad.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. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + + +#include "altitemelement.h" +#include "altcontroller.h" +#include "altparser.h" + +#include +#include +#include +/******************************* AltItemElement ********************/ + +AltItemElement::AltItemElement(KListView *parent, Alternative *alternative) +: QCheckListItem(parent, "", QCheckListItem::RadioButton), + m_alt(alternative), + m_parent(parent), + m_bisBroken(alternative->isBroken()), + m_path(alternative->getPath()) +{ + setOn(alternative->isSelected()); + setEnabled(!m_bisBroken); + m_desc = ""; +} + +AltItemElement::~AltItemElement() +{ + delete m_alt; +} + + +void AltItemElement::searchDescription() +{ + QString exec = m_path; + int posSlash = exec.findRev("/"); + + if (posSlash != -1) + { + exec.remove(0, posSlash+1); + } + + if (!exec.isEmpty()) + { + KProcess *procdesc = new KProcess(); + *procdesc << "whatis"; + *procdesc << exec; + + connect(procdesc, SIGNAL(receivedStdout(KProcess *, char *, int)), this, + SLOT(slotGetDescription(KProcess *, char *, int))); + //connect(procdesc, SIGNAL( receivedStderr(KProcess *, char *, int) ), this, + // SLOT(slotGetDescription(KProcess *, char *, int))); + connect(procdesc, SIGNAL( processExited(KProcess *)), this, + SLOT(slotDescriptionTermined(KProcess *))); + procdesc->start(KProcess::NotifyOnExit,/*KProcess::Block,*/ KProcess::AllOutput); + } +} + + +void AltItemElement::slotDescriptionTermined(KProcess *proc) +{ + if (!proc->exitStatus()) + { + int pos = m_desc.find("\n"); + if (pos != -1) + { + m_desc.truncate(pos); + } + + pos = m_desc.find("]"); + if (pos != -1) + { + m_desc.remove(0, pos+1); + } + + pos = m_desc.find(")"); + if (pos != -1) + { + m_desc.remove(0, pos+1); + } + + pos = m_desc.find("-"); + if (pos != -1) + { + m_desc.remove(0, pos+2); + } + } + else + { + m_desc = i18n( "no description" ); + } + setText( 3, m_desc); +} + +void AltItemElement::slotGetDescription(KProcess *, char *buffer, int buflen) +{ + m_desc += QString::fromLatin1(buffer, buflen); +} + + + +#include "altitemelement.moc" diff --git a/src/altitemelement.h b/src/altitemelement.h new file mode 100644 index 0000000..c935cea --- /dev/null +++ b/src/altitemelement.h @@ -0,0 +1,58 @@ +/*************************************************************************** + * Copyright (C) 2004 by Mario Bensi * + * nef@ipsquad.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. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _ALTITEMELEMENT_H_ +#define _ALTITEMELEMENT_H_ + +#include +#include +#include +#include + +class Alternative; +class AltController; + +class AltItemElement : public QObject, public QCheckListItem +{ + Q_OBJECT + + Alternative *m_alt; + KListView *m_parent; + bool m_bisBroken; + QString m_path; + QString m_desc; + +public: + AltItemElement(KListView *parent, Alternative *alternative ); + ~AltItemElement(); + + bool isBroken() const { return m_bisBroken; } + KListView *getParent() const { return m_parent; } + Alternative *getAlternative() { return m_alt; } + QString getPath() const {return m_path; } + QString getDescription() const {return m_desc;} + void searchDescription(); + +private slots: + void slotDescriptionTermined(KProcess *); + void slotGetDescription(KProcess *proc, char *buffer, int buflen); +}; + +#endif //_ALTITEMELEMENT_H_ diff --git a/src/altparser.cpp b/src/altparser.cpp new file mode 100644 index 0000000..bb31d88 --- /dev/null +++ b/src/altparser.cpp @@ -0,0 +1,609 @@ +/*************************************************************************** + * Copyright (C) 2004 by Juanjo Ãlvarez * + * juanjux@yahoo.es * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "altparser.h" +#include +#include +#include +#include + +#include +#include +#include + +Alternative::Alternative(Item *parentarg) : m_parent(parentarg) +{ + m_priority = 1; + m_altSlaves = new QStringList; +} + +// Copy constructor +Alternative::Alternative(const Alternative &alt) : + m_altPath(alt.getPath()), + m_priority(alt.getPriority()), + m_parent(alt.getParent()) +{ + m_altSlaves = new QStringList( *(alt.m_altSlaves) ); +} + +Alternative::~Alternative() +{ + if(m_altSlaves)delete m_altSlaves; +} + +Alternative& Alternative::operator=(const Alternative &alt) +{ + if(this != &alt) + { + if(m_altSlaves)delete m_altSlaves; + m_altPath = alt.getPath(); + m_priority = alt.getPriority(); + m_parent = alt.getParent(); + m_altSlaves = new QStringList( *(alt.m_altSlaves) ); + } + return (*this); +} + +void Alternative::setSlaves(QStringList *slaves) +{ + if(m_altSlaves) delete m_altSlaves; + m_altSlaves = slaves; +} + +bool Alternative::isSelected() const +{ + if(m_parent->isBroken()) return false; + QFileInfo file("/etc/alternatives/"+m_parent->getName()); + if(!file.isSymLink()) return false; + if(file.readLink() == m_altPath) return 1; + return 0; +} + + +bool Alternative::isBroken() const +{ + return !QFile::exists(m_altPath); +} + +bool Alternative::select() +{ +// This method was 19 lines in Python in the original kalternatives :-D + if(isSelected()) return true; + if(isBroken()) + { + m_selectError = QString("Broken alternative: Unexisting path %1").arg(m_altPath); + return false; + } + + // Remove the current link: + QString parentPath = QString("/etc/alternatives/%1").arg(m_parent->getName()); + QFile origlink(parentPath); + if(!origlink.remove()) + { + m_selectError = QString("Could not delete alternative link %1: %2").arg(parentPath).arg(origlink.errorString()); + return false; + } + + // Then we do the main link: + if(symlink(m_altPath.ascii(), parentPath.ascii()) == -1) + { + m_selectError = QString(strerror(errno)); + return false; + } + + // And finally the slaves + SlaveList *parslaves = m_parent->getSlaves(); + parslaves->setAutoDelete(1); + if(parslaves->count() == 0 || m_altSlaves->count() == 0) return true; + int count = 0; + QStringList::iterator sl; + Slave *parsl; + for( sl = m_altSlaves->begin(); sl != m_altSlaves->end(); ++sl) + { + parsl = parslaves->at(count); + QString parstr = QString("/etc/alternatives/%1").arg(parsl->slname); + QFile parlink(parstr); + if(!parlink.remove()) + { + m_selectError = QString("Could not delete slave alternative link %1: %2").arg(parstr).arg(parlink.errorString()); + return false; + } + if(symlink( (*sl).ascii(), parstr.ascii()) == -1) + { + m_selectError = QString(strerror(errno)); + return false; + } + ++count; + } + return true; +} + + +//*************************************** Item + +Item::Item() +{ + m_mode = "auto"; + m_itemSlaves = new SlaveList; + m_itemAlts = new AltsPtrList; + m_itemSlaves->setAutoDelete(1); + m_itemAlts->setAutoDelete(1); +} + +// Deep copy +Item::Item(const Item &item) : + m_name(item.m_name), + m_mode(item.m_mode), + m_path(item.m_path) +{ + m_itemSlaves = new SlaveList; + m_itemAlts = new AltsPtrList; + m_itemSlaves->setAutoDelete(1); + m_itemAlts->setAutoDelete(1); + Slave *slave; + Slave *slavecopy; + for(slave = item.m_itemSlaves->first(); slave; slave = item.m_itemSlaves->next()) + { + slavecopy = new Slave; + slavecopy->slname = slave->slname; + slavecopy->slpath = slave->slpath; + m_itemSlaves->append(slavecopy); + } + + Alternative *alt; + Alternative *altcopy; + for(alt = item.m_itemAlts->first(); alt; alt = item.m_itemAlts->next()) + { + // The Alternative class already has a deep copy constructor: + altcopy = new Alternative( (*alt) ); + m_itemAlts->append(altcopy); + } +} + +Item& Item::operator=(const Item &item) +{ + if(this != &item) + { + if(m_itemSlaves)delete m_itemSlaves; + if(m_itemAlts)delete m_itemAlts; + m_name = item.m_name; + m_mode = item.m_mode; + m_path = item.m_path; + m_itemSlaves = new SlaveList; + m_itemAlts = new AltsPtrList; + m_itemSlaves->setAutoDelete(1); + m_itemAlts->setAutoDelete(1); + Slave *slave; + Slave *slavecopy; + for(slave = item.m_itemSlaves->first(); slave; slave = item.m_itemSlaves->next()) + { + slavecopy = new Slave; + slavecopy->slname = slave->slname; + slavecopy->slpath = slave->slpath; + m_itemSlaves->append(slavecopy); + } + + Alternative *alt; + Alternative *altcopy; + for(alt = item.m_itemAlts->first(); alt; alt = item.m_itemAlts->next()) + { + altcopy = new Alternative( (*alt) ); + m_itemAlts->append(altcopy); + } + } + return (*this); +} + + + +Item::~Item() +{ + if(m_itemSlaves)delete m_itemSlaves; + if(m_itemAlts)delete m_itemAlts; +} + +Alternative *Item::getSelected() const +{ + Alternative *a; + for(a = m_itemAlts->first(); a; a = m_itemAlts->next()) + { + if(a->isSelected()) + { + return a; + break; + } + } + return NULL; +} + +void Item::setSlaves(SlaveList *slaves) +{ + if(this->m_itemSlaves)delete this->m_itemSlaves; + this->m_itemSlaves = slaves; +} + +void Item::addSlave(const QString &namearg, const QString &patharg) +{ + Slave *s = new Slave; + s->slname = namearg; + s->slpath = patharg; + m_itemSlaves->append(s); +} + +void Item::delSlave(const QString &namearg) +{ + QPtrListIterator it(*m_itemSlaves); + + Slave *s; + while( (s = it.current()) != 0) + { + ++it; + if(s->slname == namearg) + { + m_itemSlaves->remove(s); + break; + } + } +} +void Item::delSlaveByPath(const QString &patharg) +{ + QPtrListIterator it(*m_itemSlaves); + + Slave *s; + while( (s = it.current()) != 0) + { + ++it; + if(s->slpath == patharg) + { + m_itemSlaves->remove(s); + break; + } + } +} + +Alternative *Item::getAlternative(const QString &altpath) +{ + Alternative *a; + for(a = m_itemAlts->first(); a; a = m_itemAlts->next()) + { + if(a->getPath() == altpath) + { + return a; + break; + } + } + return NULL; +} + +void Item::setAlternatives(AltsPtrList &alts) +{ + if(this->m_itemAlts)delete this->m_itemAlts; + this->m_itemAlts = &alts; +} + +void Item::delAlternativeByPath(const QString &patharg) +{ + QPtrListIterator it(*m_itemAlts); + + Alternative *a; + while( (a = it.current()) != 0) + { + ++it; + if(a->getPath() == patharg) + { + m_itemAlts->remove(a); + break; + } + } +} + +void Item::delAlternativeByPriority(int priorityarg) +{ + QPtrListIterator it(*m_itemAlts); + + Alternative *a; + while( (a = it.current()) != 0) + { + ++it; + if(a->getPriority() == priorityarg) + { + m_itemAlts->remove(a); + break; + } + } +} + +bool Item::isBroken() const +{ + return !QFile::exists(m_path); +} + +/********************** AltFIlesManager ************/ + +AltFilesManager::AltFilesManager(const QString &altdirarg) : + m_altdir(altdirarg) +{ + m_itemlist = new ItemPtrList; + m_itemlist->setAutoDelete(1); + m_parseOk = true; + m_errorMsg = ""; + if(!parseAltFiles(m_errorMsg)) + { + m_parseOk = false; + } + //debugPrintAlts(); +} + +AltFilesManager::~AltFilesManager() +{ + //delete m_itemlist; + /* + Item *item; + for(item = m_itemlist->first(); item; item = m_itemlist->next()) + { + delete item; + } + + delete m_itemlist; + */ +} + +Item* AltFilesManager::getItem(const QString &name) const +{ + QPtrListIterator it(*m_itemlist); + Item *i; + while( (i = it.current()) != 0) + { + ++it; + if(i->getName() == name) + { + return i; + break; + } + } + return NULL; +} + +bool AltFilesManager::parseAltFiles(QString &errorstr) +{ + QDir d(m_altdir); + QStringList fileList = d.entryList(); + QStringList lines; + QFile altFile; + QString line, tmp; + int nslaves; + unsigned int index, slavesend; + + for( QStringList::Iterator it = fileList.begin(); it != fileList.end(); ++it) + { + Item *item = new Item; + if(*it == "." || *it == "..") { + delete item; + continue; + } + + item->setName(*it); + altFile.setName(m_altdir+"/"+*it); + + if(!altFile.open( IO_ReadOnly )) + { + errorstr = altFile.errorString(); + delete item; + return false; + } + + lines.clear(); + while ( !altFile.atEnd() ) + { + if(!altFile.readLine(line, 9999)) + { + errorstr = altFile.errorString(); + delete item; + return false; + } + lines.append(line); + } + + line = lines[0]; + tmp = line.left(line.length()-1); + item->setMode(tmp); + + line = lines[1]; + tmp = line.left(line.length()-1); + item->setPath(tmp); + + index = 2; + line = lines[index]; + nslaves = 0; + SlaveList *slaves = new SlaveList; + slaves->setAutoDelete(1); + + while(line != "\n") + { + tmp = line.left(line.length()-1); + Slave *slave = new Slave; + nslaves++; + slave->slname = tmp; + + line = lines[++index]; + tmp = line.left(line.length()-1); + slave->slpath = tmp; + + slaves->append(slave); + line = lines[++index]; + } + + item->setSlaves(slaves); + + ++index; + while(index < lines.count()-1) + { + line = lines[index]; + Alternative *a = new Alternative(item); + tmp = line.left(line.length()-1); + a->setPath(tmp); + + if(line=="\n") { + //File end (with a \n) + delete a; + break; + } + + if(++index == lines.count()) + { + item->addAlternative(a); + break; + } + + + line = lines[index]; + tmp = line.left(line.length()-1); + a->setPriority(tmp.toInt()); + + if(++index == lines.count()) + { + item->addAlternative(a); + break; + } + + line = lines[index]; + if(line != "\n" and nslaves > 0) + { + slavesend = index+nslaves; + while(index < slavesend) + { + line = lines[index]; + tmp = line.left(line.length()-1); + a->addSlave(tmp); + ++index; + } + } + else + { + if (nslaves >0) + { + ++index; + } + } + item->addAlternative(a); + } + m_itemlist->append(item); + altFile.close(); + } + + return true; +} + +//FIXME: This must be in a son of qptrlist! +/* +int AltFilesManager::compareItems(Item i1, Item i2) +{ + return i1.getPath().compare(i2.getPath()); +} +*/ + +/* +void AltFilesManager::debugPrintAlts() const +{ + printf("----------------------------------\n"); + Item *item; + for(item = m_itemlist->first(); item; item = m_itemlist->next()) + { + printf("\nItem: %s\n", item->getName().ascii()); + printf("\tMode: %s\n", item->getMode().ascii()); + printf("\tPath: %s\n", item->getPath().ascii()); + if(item->getSlaves()->count() == 0) + printf("\tNo slaves\n"); + else + { + Slave *slave; + SlaveList *slaves = item->getSlaves(); + for(slave = slaves->first(); slave; slave = slaves->next()) + { + printf("\tSlave name: %s\n", slave->name.ascii()); + printf("\tSlave path: %s\n", slave->path.ascii()); + } + } + printf("\tAlternatives:\n"); + if(item->getAlternatives()->count() == 0) + printf("\t\tNO ALTERNATIVES!"); + else + { + Alternative *a; + AltsPtrList *alts = item->getAlternatives(); + for(a = alts->first(); a; a = alts->next()) + { + printf("\t\tPath: %s\n", a->getPath().ascii()); + printf("\t\tPriority: %d\n", a->getPriority()); + printf("\t\tSlaves:\n"); + if(a->getSlaves()->count() == 0) + printf("\t\t\tNo slaves\n"); + else + { + QStringList altslaves = *(a->getSlaves()); + QStringList::iterator sl; + for( sl = altslaves.begin(); sl != altslaves.end(); ++sl) + { + printf("\t\t\t%s\n", (*sl).ascii()); + } + } + } + } + } +} +*/ +/* +// ************************************** Test +int main(int argc, char **argv) +{ + AltFilesManager a("/var/lib/rpm/alternatives"); + if(!a.parsingOk()) + printf("ERROR PARSING ALT FILES: %s\n", a.getErrorMsg().ascii()); + else + printf("\nOK, Finished parsing\n"); + + Item *item= a.getItem("vi"); + if(item == NULL) return 0; + printf("Nombre item: %s\n", item->getName().ascii()); + printf("Path item: %s\n", item->getPath().ascii()); + Alternative *alt = item->getSelected(); + if(alt == NULL) return 0; + printf("Selected alt: %s\n", alt->getPath().ascii()); + + Alternative *vimminimal = item->getAlternative("/bin/vim-minimal"); + if(vimminimal == NULL) { printf("NULL!\n"); return 0; } + printf("Not selected alt: %s\n", vimminimal->getPath().ascii()); + + printf("Selecting vim-minimal instead of vim-enhanced as vi\n"); + if(!vimminimal->select()) + { + printf("ERROR: %s\n", vimminimal->getSelectError().ascii()); + } + + printf("Now selecting vim-enhanced...\n"); + Alternative *vimen = item->getAlternative("/usr/bin/vim-enhanced"); + if(vimen == NULL) { printf("NULL!\n"); return 0; } + if(!vimen->select()) + { + printf("ERROR: %s\n", alt->getSelectError().ascii()); + } + return 0; + } +*/ diff --git a/src/altparser.h b/src/altparser.h new file mode 100644 index 0000000..74842df --- /dev/null +++ b/src/altparser.h @@ -0,0 +1,140 @@ +/*************************************************************************** + * Copyright (C) 2004 by Juanjo Ãlvarez * + * juanjux@yahoo.es * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _ALTPARSER_H_ +#define _ALTPARSER_H_ + + +//FIXME: Cosas pa mirar: +//Comprobar entradas NULL y demás (sobre todo antes de los delete) +// +//Quitar el stdio.h + +#include +#include +#include +#include + +#ifdef HAVE_CONFIG_H +#include +#endif + +class Item; + +struct Slave +{ + QString slname; + QString slpath; +}; + +class Alternative +{ + QString m_altPath; + QString m_selectError; + int m_priority; + Item *m_parent; + QStringList *m_altSlaves; +public: + Alternative(Item *parentarg); + Alternative(const Alternative &alt); + ~Alternative(); + Alternative& operator=(const Alternative &alt); + + Item* getParent() const { return m_parent; } + QString getPath() const { return m_altPath; } + void setPath(const QString &patharg) { m_altPath = patharg; } + int getPriority() const { return m_priority; } + void setPriority(int priorityarg) { m_priority = priorityarg; } + QStringList* getSlaves() const { return m_altSlaves; } + void setSlaves(QStringList *m_altSlaves); + void addSlave(const QString &slave) { m_altSlaves->append(slave); } + uint countSlaves() const { return m_altSlaves->count(); } + QString getSlave(int pos) const { return *(m_altSlaves->at(pos)); } + bool isSelected() const; + bool isBroken() const; + bool select(); + QString getSelectError() const { return m_selectError; } +}; + +typedef QPtrList SlaveList; +typedef QPtrList AltsPtrList; + +class Item +{ + QString m_name; + QString m_mode; + QString m_path; + SlaveList *m_itemSlaves; + AltsPtrList *m_itemAlts; +public: + Item(); + // Deep copy constructor: + Item(const Item &item); + ~Item(); + Item& operator=(const Item &item); + + Alternative* getSelected() const; + QString getName() const { return m_name; } + void setName(const QString &namearg) { m_name = namearg; } + QString getMode() const { return m_mode; } + //Check the input (FIXME) + void setMode(const QString &modearg) { m_mode = modearg; } + QString getPath() const { return m_path; } + void setPath(const QString &patharg) { m_path = patharg; } + SlaveList *getSlaves() const { return m_itemSlaves; } + void setSlaves(SlaveList *slaves); + void addSlave(const QString &namearg, const QString &patharg); + void delSlave(const QString &namearg); + void delSlaveByPath(const QString &patharg); + AltsPtrList *getAlternatives() const { return m_itemAlts; } + Alternative *getAlternative(const QString &altpath); + void setAlternatives(AltsPtrList &alts); + int countAlternatives() const { return m_itemAlts->count(); } + void delAlternativeByPath(const QString &patharg); + void delAlternativeByPriority(int priorityarg); + void addAlternative(Alternative *altarg) { m_itemAlts->append(altarg); } + bool isBroken() const; +}; + +typedef QPtrList ItemPtrList; + +class AltFilesManager +{ + ItemPtrList *m_itemlist; + QString m_altdir; + QString m_errorMsg; + bool m_parseOk; + + bool parseAltFiles(QString &errorstr); +public: + AltFilesManager(const QString &altdir); + ~AltFilesManager(); + + ItemPtrList* getGlobalAlternativeList() const { return this->m_itemlist; } + bool parsingOk() const { return m_parseOk; } + QString getErrorMsg() const { return m_errorMsg; } + Item* getItem (const QString &name) const; + //FIXME: Put in a #ifdef + void debugPrintAlts() const; + QString getAltDir() { return m_altdir ;} +//protected: + //virtual int compareItems(Item i1, Item i2); +}; +#endif // _KALTERNATIVES_H_ diff --git a/src/hi16-app-kalternatives.png b/src/hi16-app-kalternatives.png new file mode 100644 index 0000000000000000000000000000000000000000..4ed606c1a4a05d54879e6b8caf97297158b9ca36 GIT binary patch literal 1033 zcmV+k1or!hP)T z7)>@8B@P?o4HvlJ68{4=(F;wyT8!~#&bT=;K(h^&=`weeY=%KQz;+#zV=0FYTq&%D z7B6fGM)q9)p3jrt_xXOG6rNM|jQm)-#ipq}bf9X=H#WKu{(EwDZFT(WtzU|OB_O`> zeadE#Vtesg>Go1&S;05yLo&)#SJjiI)3Okqh?JZ zg~RwBK4#K4fhg&St*nx&(~_|z3*5W}+yv~sHJdzPaSZd|&_?TfcK zd+Iypp3Jeg?iECx7R97+^qr$vZRyUNzg_o7>4EJOAQ(zJ3`TUD7t%2!)pePdQW-}h|BSwZsm>mfaiADevKoIOD+h-+3 zwgty$um9!cno9 zm6wSiq+(Kyh@uv=s?yu{fC=vyUEywamhWO_EWpFNgZStCI=~K00nudEG=S|;bwj|Q z%G5X1@xbtLHoV6DEBE;3^vR^Kp~Upm#HRW;W^H5oHGm9ga;!NMHj_m)tY)ejOELQK900000NkvXXu0mjf DUF_&? literal 0 HcmV?d00001 diff --git a/src/hi32-app-kalternatives.png b/src/hi32-app-kalternatives.png new file mode 100644 index 0000000000000000000000000000000000000000..45ae1a1134f1afc27bd093068a3275e39c416262 GIT binary patch literal 2749 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 DHls?L literal 0 HcmV?d00001 diff --git a/src/kalternatives.cpp b/src/kalternatives.cpp new file mode 100644 index 0000000..120f704 --- /dev/null +++ b/src/kalternatives.cpp @@ -0,0 +1,457 @@ +/*************************************************************************** + * Copyright (C) 2004 by Juanjo * + * juanjux@yahoo.es * + * * + * Copyright (C) 2004 by Mario Bensi * + * nef@ipsquad.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. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "kalternatives.h" +#include "altparser.h" +#include "propertieswindow.h" +#include "altcontroller.h" +#include "altitemelement.h" +#include "treeitemelement.h" +#include "addalternatives.h" +#include "mainwindow.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef KGenericFactory KalternativesFactory; +K_EXPORT_COMPONENT_FACTORY( kcm_kalternatives, KalternativesFactory("kcmkalternatives")) + +extern "C" +{ + KCModule *create_kalternatives(QWidget *parent, const char *name) + { + return new Kalternatives(parent, name); + }; +} + +Kalternatives::Kalternatives(QWidget *parent, const char *name, const QStringList&) +:KCModule(/*KalternativesFactory::instance(), */parent, name), myAboutData(0) +{ + setUseRootOnlyMsg(false); + + int user = getuid(); + + if (user == 0) + { + m_bisRoot = true; + setButtons(KCModule::Help|KCModule::Apply); + } + else + { + m_bisRoot = false; + setButtons(Help); + } + +#ifdef MANDRAKE +m_mgr = new AltFilesManager("/var/lib/rpm/alternatives"); +#else + #ifdef DEBIAN + m_mgr = new AltFilesManager("/var/lib/dpkg/alternatives"); + #else + KMessageBox::sorry(this, i18n("Kalternatives only work on Debian- or Mandrake-based systems"), i18n("Wrong System Type")); + QTimer::singleShot(0, this, SLOT(die())); + #endif +#endif + + MainWindow *mainwindow = new MainWindow(this); + QBoxLayout *layout = new QVBoxLayout(this, 0, KDialog::spacingHint()); + layout->addWidget( mainwindow ); + layout->activate(); + + mainwindow->m_altList->setShowToolTips(1); + + connect(mainwindow->m_hideAlt, SIGNAL(clicked()), this, + SLOT(slotHideAlternativesClicked())); + + connect(mainwindow->m_altList, SIGNAL(selectionChanged( QListViewItem* )), this, + SLOT(slotSelectAlternativesClicked(QListViewItem *))); + + connect(mainwindow->m_optionsList, SIGNAL(clicked(QListViewItem *)), + this, SLOT(slotOptionClicked(QListViewItem *))); + connect(mainwindow->m_bAdd, SIGNAL(clicked()), this, + SLOT(slotAddClicked())); + connect(mainwindow->m_bDelete, SIGNAL(clicked()), this, + SLOT(slotDeleteClicked())); + connect(mainwindow->m_bProperties, SIGNAL(clicked()), this, + SLOT(slotPropertiesClicked())); + + m_altList = mainwindow->m_altList; + m_optionsList = mainwindow->m_optionsList; + m_altTilte = mainwindow->m_altTilte; + m_statusCombo = mainwindow->m_statusCombo; + m_hideAlt = mainwindow->m_hideAlt; + + mainwindow->m_bDelete->setGuiItem(KStdGuiItem::del()); + mainwindow->m_bAdd->setGuiItem(KGuiItem(i18n("&Add"), "edit_add")); + mainwindow->m_bProperties->setGuiItem(KGuiItem( i18n( "&Properties" ), "configure")); + + if(!m_bisRoot) + { + mainwindow->m_bDelete->setEnabled(false); + mainwindow->m_bAdd->setEnabled(false); + mainwindow->m_bProperties->setEnabled(false); + m_statusCombo->setEnabled(false); + } + + myAboutData = new KAboutData("kcmkalternatives", I18N_NOOP("Kalternatives"), + KALT_VERSION, I18N_NOOP("KDE Mandrake/Debian alternatives-system manager"), + KAboutData::License_GPL, I18N_NOOP("(c) 2004 Juanjo Alvarez Martinez\n" + "(c) 2004 Mario Bensi")); + + myAboutData->addAuthor("Juanjo Alvarez Martinez", 0, "juanjo@juanjoalvarez.net", + "http://juanjoalvarez.net"); + myAboutData->addAuthor("Mario Bensi", 0, "nef@ipsquad.net", "http://ipsquad.net"); + myAboutData->addAuthor("Pino Toscano", 0, "toscano.pino@tiscali.it"); + +#if KDE_IS_VERSION(3,2,90) + setAboutData( myAboutData ); +#endif + + load(); + m_hideAlt->setChecked(true); + slotHideAlternativesClicked(); +} + +Kalternatives::~Kalternatives() +{ + if(m_mgr) delete m_mgr; + if(m_altList) delete m_altList; + if(m_optionsList) delete m_optionsList; + if(m_altTilte) delete m_altTilte; + if(m_statusCombo) delete m_statusCombo; + if(m_hideAlt) delete m_hideAlt; +} + +void Kalternatives::die() +{ + delete this; +} + +void Kalternatives::load() +{ + clearList(m_altList); + QPtrList *itemslist = m_mgr->getGlobalAlternativeList(); + Item *i; + TreeItemElement *treeit; + for(i = itemslist->first(); i; i = itemslist->next()) + { + AltController *altcontroller = new AltController(); + treeit = new TreeItemElement(m_altList, i, altcontroller); + + AltsPtrList *altList = i->getAlternatives(); + Alternative *a = altList->first(); + + AltItemElement *ael; + + for(; a; a=altList->next()) + { + ael = new AltItemElement(m_optionsList, a); + if(!m_bisRoot) ael->setEnabled(false); + treeit->getAltController()->addAltItem(ael); + } + } +} + + + + +void Kalternatives::clearList(KListView* list) +{ + QListViewItemIterator it( list ); + QListViewItem *tmp; + while( (tmp=it.current()) ) + { + it++; + list->takeItem(tmp); + } +} + + +void Kalternatives::slotSelectAlternativesClicked(QListViewItem *alternative) +{ + clearList(m_optionsList); + TreeItemElement *treeItem; + if((treeItem = dynamic_cast(alternative))) + { + Item *item = treeItem->getItem(); + + m_altTilte->setText(treeItem->getName()); + m_statusCombo->setCurrentItem(item->getMode()); + + AltItemList *altItemList = treeItem->getAltController()->getAltItemList(); + + for( AltItemElement *altItem= altItemList->first(); altItem ; altItem = altItemList->next()) + { + Alternative *a = altItem->getAlternative(); + + QString priority; + priority.setNum(a->getPriority()); + + m_optionsList->insertItem(altItem); + + altItem->setText( 1, priority); + altItem->setText( 2, a->getPath()); + QString m_small_desc = altItem->getDescription(); + + if (!m_small_desc.isEmpty()) + { + altItem->setText( 3, m_small_desc); + } + else + { + altItem->searchDescription(); + } + } + } + m_optionsList->setSelected(m_optionsList->firstChild(), 1); +} + + + +void Kalternatives::slotHideAlternativesClicked() +{ + if (m_hideAlt->isChecked ()) + { + QListViewItemIterator it( m_altList ); + TreeItemElement *i; + QListViewItem *tmp; + while ( it.current() ) + { + if((i = dynamic_cast(it.current()))) + { + if ((i->getItem()->getAlternatives()->count()) <= 1) + { + tmp = it.current(); + it++; + m_altList->takeItem(tmp); + continue; + } + } + it++; + } + } + else + { + load(); + } + m_altList->setSelected(m_altList->firstChild (), 1); +} + + +void Kalternatives::slotOptionClicked(QListViewItem *option) +{ + AltItemElement *altItem; + if((altItem = dynamic_cast(option))) + { + if( !altItem->isOn()) + return; + TreeItemElement *treeItem; + if((treeItem = dynamic_cast(m_altList->selectedItem()))) + { + treeItem->getAltController()->setBoutonOnOff(m_optionsList, altItem); + treeItem->setChanged(TRUE); + emit changed(true); + } + } +} + +void Kalternatives::slotAddClicked() +{ + TreeItemElement *treeItem; + if((treeItem = dynamic_cast(m_altList->selectedItem()))) + { + m_optionsList->setSelected(m_optionsList->firstChild(), 1); + + AltItemElement *altItem; + if((altItem = dynamic_cast(m_optionsList->selectedItem()))) + { + int countSlave = altItem->getAlternative()->countSlaves(); + AddAlternatives *addAlternatives = new AddAlternatives(treeItem, this, countSlave); + addAlternatives->show(); + } + } +} +void Kalternatives::slotDeleteClicked() +{ + TreeItemElement *treeItem; + if((treeItem = dynamic_cast(m_altList->selectedItem()))) + { + AltItemElement *altItem; + if((altItem = dynamic_cast(m_optionsList->selectedItem()))) + { + treeItem->getItem()->delAlternativeByPath(altItem->getPath()); + + AltItemList *altItemList = treeItem->getAltController()->getAltItemList(); + + altItemList->remove(altItem); + m_optionsList->takeItem(altItem); + + treeItem->setNbrAltChanged(TRUE); + emit changed( TRUE ); + m_optionsList->setSelected(m_optionsList->firstChild (), 1); + } + } +} + +void Kalternatives::slotPropertiesClicked() +{ + AltItemElement *altItem; + + if((altItem = dynamic_cast(m_optionsList->selectedItem()))) + { + QString text; + PropertiesWindow *prop = new PropertiesWindow(this); + prop->bClose->setGuiItem(KStdGuiItem::close()); + + Alternative *a = altItem->getAlternative(); + + + text += i18n( "Description :\n%1\n" ).arg( altItem->getDescription() ); + text += i18n( "Path : %1\n" ).arg( a->getPath() ); + text += i18n( "Priority : %1\n" ).arg( a->getPriority() ); + + QStringList* slavesList = a->getSlaves(); + text += i18n( "Slave :", "Slaves :", slavesList->count() ); + + for ( QStringList::Iterator it = slavesList->begin(); it != slavesList->end(); ++it ) + { + text += "\n\t"; + text += *it; + } + prop->m_text->setText(text); + prop->show(); + } +} + + +void Kalternatives::save() +{ + QListViewItemIterator it( m_altList ); + TreeItemElement *treeItem; + + while ( it.current() ) + { + if((treeItem = dynamic_cast(it.current()))) + { + if(treeItem->isNbrAltChanged()) + { + QString parentPath = QString("%1/%2") + .arg(m_mgr->getAltDir()) + .arg(treeItem->getName()); + + QFile origFile(parentPath); + if(origFile.exists()) + { + origFile.remove(); + } + + if( origFile.open( IO_WriteOnly )) + { + QTextStream stream( &origFile ); + + + Item *item = treeItem->getItem(); + + stream << item->getMode() << endl; + stream << item->getPath() << endl; + + SlaveList *slaveList = item->getSlaves(); + Slave *slave = slaveList->first(); + for(; slave; slave = slaveList->next()) + { + stream << slave->slname << endl; + stream << slave->slpath << endl; + } + + stream << endl; + + AltItemList *altItemList = treeItem->getAltController()->getAltItemList(); + AltItemElement *altItem= altItemList->first(); + for( ; altItem ; altItem = altItemList->next()) + { + Alternative *a = altItem->getAlternative(); + + stream << a->getPath() << endl; + stream << a->getPriority() << endl; + + QStringList *slaveList = a->getSlaves(); + QStringList::Iterator it = slaveList->begin(); + for ( ; it != slaveList->end(); ++it ) + { + stream << *it << endl; + } + } + origFile.close(); + } + treeItem->setNbrAltChanged(FALSE); + } + if(treeItem->isChanged()) + { + AltItemList *altItemList = treeItem->getAltController()->getAltItemList(); + AltItemElement *altItem= altItemList->first(); + for( ; altItem ; altItem = altItemList->next()) + { + if( altItem->isOn() ) + { + Alternative *a = altItem->getAlternative(); + if(!a->select()) + { + kdDebug() << a->getSelectError() << endl; + } + } + } + treeItem->setChanged(FALSE); + } + } + it++; + } + emit changed( false ); +} + + +void Kalternatives::configChanged() +{ + emit changed(true); +} + + +QString Kalternatives::quickHelp() const +{ + return i18n("

Kalternatives

\n" + "A Mandrake/Debian alternatives-system manager."); +} + + + +#include "kalternatives.moc" diff --git a/src/kalternatives.desktop b/src/kalternatives.desktop new file mode 100644 index 0000000..abbd53c --- /dev/null +++ b/src/kalternatives.desktop @@ -0,0 +1,37 @@ +[Desktop Entry] +Encoding=UTF-8 +Exec=kcmshell kalternatives +Icon=misc +Type=Application + +X-KDE-ModuleType=Library +X-KDE-Library=kalternatives +X-KDE-RootOnly=true +X-KDE-HasReadOnlyMode=true +X-KDE-ParentApp=kcontrol + +Comment=Kalternatives - KDE Mandrake/Debian alternatives-system manager +Comment[da]=Alternative systemhÃ¥ndteringer, Kalternatives for KDE Mandrake/Debian +Comment[es]=Kalternatives - administrador alternativo del sistema KDE en Mandrake/Debian +Comment[et]=Kalternatives - KDE Mandrake/Debiani alternatiivide süsteemi haldur +Comment[fr]=KAlternatives - Un gestionnaire du système d'alternatives Mandrake / Debian pour KDE +Comment[gl]=Kalternatives - Xestión do sistema de alternativas da Mandrake/Debian +Comment[it]=Kalternatives - Gestione dei sistemi di alternative di Mandrake e Debian per KDE +Comment[pt]=Kalternatives - Gestão de sistema de alternativas para Mandrake/Debian +Comment[pt_BR]=Kalternatives - Gestão de sistema de alternativas para Mandrake/Debian +Comment[sv]=Kalternativ - KDE:s Mandrake och Debian alternativ systemhantering +Comment[ta]=Kalternatives - கேடியி மாணà¯à®Ÿà¯à®°à¯‡à®•à¯/டெபியன௠மாறà¯à®±à¯à®•ள௠அமைபà¯à®ªà¯ மேலாளர௠+Comment[tr]=Kseçenekleri - KDE Mandarake/Debian seçenekleri sistem yöneticisi +Comment[xx]=xxKalternatives - KDE Mandrake/Debian alternatives-system managerxx +Keywords=Kalternatives,kalternatives +Keywords[fr]=Kalternatives,kalternatives,alternatives +Keywords[sv]=Kalternativ,kalternativ +Keywords[tr]=Kseçenekleri,kseçenekleri +Keywords[xx]=xxKalternatives,kalternativesxx +Name=Kalternatives +Name[ta]=Kமாறà¯à®±à¯à®•ள௠+Name[tr]=Kseçenekleri +Name[xx]=xxKalternativesxx + + +Categories=Qt;KDE;X-KDE-settings-system; diff --git a/src/kalternatives.h b/src/kalternatives.h new file mode 100644 index 0000000..8094423 --- /dev/null +++ b/src/kalternatives.h @@ -0,0 +1,83 @@ +/*************************************************************************** + * Copyright (C) 2004 by Juanjo * + * juanjux@yahoo.es * + * * + * Copyright (C) 2004 by Mario Bensi * + * nef@ipsquad.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. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _KALTERNATIVES_H_ +#define _KALTERNATIVES_H_ + +//#ifdef HAVE_CONFIG_H +//#include +//#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +#define KALT_VERSION "0.12" + +class AltFilesManager; + +class Kalternatives : public KCModule +{ + Q_OBJECT + + bool m_bisRoot; + AltFilesManager *m_mgr; + KListView* m_optionsList; + KListView* m_altList; + KComboBox* m_statusCombo; + QLabel* m_altTilte; + QCheckBox* m_hideAlt; + KAboutData *myAboutData; + + void clearList(KListView* list); + +public: + Kalternatives(QWidget *parent=0, const char *name=0, const QStringList& = QStringList() ); + virtual ~Kalternatives(); + KListView *optionsList() const {return m_optionsList;} + bool isBisRoot() const {return m_bisRoot;} + + virtual void load(); + virtual void save(); + virtual QString quickHelp() const; + virtual const KAboutData *aboutData()const { return myAboutData; }; + +public slots: + void configChanged(); + +private slots: + void slotSelectAlternativesClicked(QListViewItem *); + void slotHideAlternativesClicked(); + void die(); + void slotOptionClicked(QListViewItem *option); + void slotAddClicked(); + void slotDeleteClicked(); + void slotPropertiesClicked(); +}; + +#endif // _KALTERNATIVES_H_ diff --git a/src/kalternatives.lsm b/src/kalternatives.lsm new file mode 100644 index 0000000..8558492 --- /dev/null +++ b/src/kalternatives.lsm @@ -0,0 +1,16 @@ +Begin3 +Title: kalternatives -- Some description +Version: 0.12 +Entered-date: +Description: +Keywords: KDE Qt +Author: Juanjo +Maintained-by: Juanjo +Home-page: +Alternate-site: +Primary-site: ftp://ftp.kde.org/pub/kde/unstable/apps/utils + xxxxxx kalternatives-0.12.tar.gz + xxx kalternatives-0.12.lsm +Platform: Linux. Needs KDE +Copying-policy: GPL +End diff --git a/src/kalternativesui.rc b/src/kalternativesui.rc new file mode 100644 index 0000000..347fe72 --- /dev/null +++ b/src/kalternativesui.rc @@ -0,0 +1,8 @@ + + + + C&ustom + + + + diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..860a2ba --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,77 @@ +/*************************************************************************** + * Copyright (C) 2004 by Juanjo * + * juanjux@yahoo.es * + * * + * Copyright (C) 2004 by Mario Bensi * + * nef@ipsquad.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. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "main.h" +#include "kalternatives.h" +#include +#include +#include +#include +#include + +KUniqueApplication *app = 0; // Global + +static const char description[] = + I18N_NOOP("A KDE Manager for the Debian/Mandrake alternatives system"); + +static const char version[] = "0.10"; + +static KCmdLineOptions options[] = +{ +// { "+[URL]", I18N_NOOP( "Document to open." ), 0 }, + KCmdLineLastOption +}; + +int main(int argc, char **argv) +{ + KAboutData about("kalternatives", I18N_NOOP("kalternatives"), version, description, + KAboutData::License_GPL, "(C) 2004 Juanjo Alvarez Martinez and Mario Bensi", 0, 0, "juanjux@yahoo.es, nef@ipsquad.net"); + about.addAuthor( "Juanjo Alvarez Martinez and Mario Bensi", 0, "juanjux@yahoo.es, nef@ipsquad.net" ); + + KCmdLineArgs::init(argc, argv, &about); + KCmdLineArgs::addCmdLineOptions( options ); + KUniqueApplication rapp; + app = &rapp; + Kalternatives *mainWin = 0; + + if (app->isRestored()) + { + //RESTORE(kalternatives); + } + else + { + // no session.. just start up normally + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + + /// @todo do something with the command line args here + + mainWin = new Kalternatives(); + app->setMainWidget( mainWin ); + mainWin->show(); + + + args->clear(); + } + return app->exec(); +} + diff --git a/src/main.h b/src/main.h new file mode 100644 index 0000000..24ff6c8 --- /dev/null +++ b/src/main.h @@ -0,0 +1,8 @@ +#ifndef _MAIN_H_ +#define _MAIN_H_ + +#include + +extern KUniqueApplication *app; + +#endif //_MAIN_H_ diff --git a/src/mainwindow.ui b/src/mainwindow.ui new file mode 100644 index 0000000..8df2d9a --- /dev/null +++ b/src/mainwindow.ui @@ -0,0 +1,392 @@ + +MainWindow + + + Kalternatives + + + + 0 + 0 + 615 + 490 + + + + + 7 + 7 + 0 + 0 + + + + + 0 + 0 + + + + Alternatives Manager + + + + unnamed + + + + splitter2 + + + Horizontal + + + + layout6 + + + + unnamed + + + + + Alternatives + + + true + + + true + + + + m_altList + + + LastColumn + + + + + groupBox3 + + + + 1 + 1 + 0 + 0 + + + + GroupBoxPanel + + + Sunken + + + 1 + + + + + + AlignAuto + + + + unnamed + + + + m_hideAlt + + + + 1 + 1 + 0 + 0 + + + + false + + + &Hide useless alternatives + + + + + + + + + layout24 + + + + unnamed + + + + layout22 + + + + unnamed + + + + layout5_2 + + + + unnamed + + + + textLabel1 + + + + 0 + 0 + 0 + 0 + + + + + 1 + + + + status : + + + + + + auto + + + + + manual + + + + m_statusCombo + + + + 0 + 0 + 0 + 0 + + + + + + + + spacer6 + + + Horizontal + + + Expanding + + + + 88 + 20 + + + + + + m_altTilte + + + + 7 + 0 + 0 + 0 + + + + + 14 + 1 + + + + Automake + + + AlignCenter + + + + + spacer5 + + + Horizontal + + + Expanding + + + + 88 + 20 + + + + + + + + + Choice + + + true + + + true + + + + + Priority + + + true + + + true + + + + + Option + + + true + + + true + + + + + Description + + + true + + + true + + + + m_optionsList + + + AutoOneFit + + + Auto + + + true + + + LastColumn + + + false + + + + + layout7 + + + + unnamed + + + + spacer3 + + + Horizontal + + + Expanding + + + + 40 + 20 + + + + + + m_bAdd + + + &Add + + + + + m_bProperties + + + true + + + &Properties + + + + + m_bDelete + + + true + + + &Delete + + + + + + + + + + + + + + klistview.h + kcombobox.h + klistview.h + kpushbutton.h + kpushbutton.h + kpushbutton.h + + diff --git a/src/propertieswindow.ui b/src/propertieswindow.ui new file mode 100644 index 0000000..026df51 --- /dev/null +++ b/src/propertieswindow.ui @@ -0,0 +1,106 @@ + +PropertiesWindow + + + PropertiesWindow + + + + 0 + 0 + 532 + 407 + + + + Alternative Properties + + + + unnamed + + + + layout17 + + + + unnamed + + + + m_text + + + true + + + + + line3 + + + HLine + + + Sunken + + + Horizontal + + + + + layout7 + + + + unnamed + + + + spacer5 + + + Horizontal + + + Expanding + + + + 40 + 20 + + + + + + bClose + + + &Close + + + + + + + + + + + + + bClose + clicked() + PropertiesWindow + close() + + + + + ktextedit.h + kpushbutton.h + + diff --git a/src/treeitemelement.cpp b/src/treeitemelement.cpp new file mode 100644 index 0000000..b6732d9 --- /dev/null +++ b/src/treeitemelement.cpp @@ -0,0 +1,70 @@ +/*************************************************************************** + * Copyright (C) 2004 by Mario Bensi * + * nef@ipsquad.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. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "treeitemelement.h" +#include "altparser.h" +#include "altcontroller.h" +#include +#include + +#include +using namespace std; + +TreeItemElement::TreeItemElement(KListView *parent, Item *itemarg, AltController *altControl ) +: QListViewItem(parent, itemarg->getName()), + m_item(itemarg), + m_name(itemarg->getName()), + m_changed(FALSE), + m_nbrAltChanged(FALSE), + m_altControl(altControl) +{ +} + + +TreeItemElement::~TreeItemElement() +{ +} + +void TreeItemElement::paintCell( QPainter * p, const QColorGroup & cg, int column, int width, int align ) +{ + QColor color; + + if (m_changed || m_nbrAltChanged) + { + color=QColor("red"); + QFont f = p->font(); + f.setBold(true); + p->setFont(f); + } + + // the pallet of colors is saved + QColorGroup _cg( cg ); + QColor oldText=_cg.text(); + + // modification of the pallet of colors by defining + //our new color as color of text + _cg.setColor( QColorGroup::Text, color ); + + QListViewItem::paintCell( p, _cg, column, width, align ); + + // restoration of the pallet of "standard" colors + _cg.setColor( QColorGroup::Text, oldText ); + +} diff --git a/src/treeitemelement.h b/src/treeitemelement.h new file mode 100644 index 0000000..8551f5d --- /dev/null +++ b/src/treeitemelement.h @@ -0,0 +1,56 @@ +/*************************************************************************** + * Copyright (C) 2004 by Mario Bensi * + * nef@ipsquad.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. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _TREEITEMELEMENT_H_ +#define _TREEITEMELEMENT_H_ + +#include +#include +#include +#include + +class AltController; +class Item; + + +class TreeItemElement : public QListViewItem +{ + Item *m_item; + QString m_name; + bool m_changed; + bool m_nbrAltChanged; + AltController *m_altControl; + +public: + TreeItemElement(KListView *parent, Item *itemarg, AltController *altControl); + ~TreeItemElement(); + + QString getName() const { return m_name; } + Item *getItem() const { return m_item; } + void setChanged(bool c) { m_changed = c; } + bool isChanged() const { return m_changed; } + void setNbrAltChanged(bool c) { m_nbrAltChanged = c; } + bool isNbrAltChanged() const { return m_nbrAltChanged; } + AltController *getAltController() {return m_altControl;} + + virtual void paintCell( QPainter * p, const QColorGroup & cg, int column, int width, int align ); +}; + +#endif //_TREEITEMELEMENT_H_ diff --git a/templates/cpp b/templates/cpp new file mode 100644 index 0000000..6e65f8a --- /dev/null +++ b/templates/cpp @@ -0,0 +1,19 @@ +/*************************************************************************** + * Copyright (C) 2004 by Juanjo * + * juanjux@yahoo.es * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ diff --git a/templates/h b/templates/h new file mode 100644 index 0000000..6e65f8a --- /dev/null +++ b/templates/h @@ -0,0 +1,19 @@ +/*************************************************************************** + * Copyright (C) 2004 by Juanjo * + * juanjux@yahoo.es * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/