From bd0f3345a938b35ce6a12f6150373b0955b8dd12 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 10 Jul 2011 15:24:15 -0500 Subject: Add Qt3 development HEAD version --- tools/assistant/LICENSE.GPL | 280 +++++++ tools/assistant/assistant.icns | Bin 0 -> 58954 bytes tools/assistant/assistant.ico | Bin 0 -> 10134 bytes tools/assistant/assistant.pro | 72 ++ tools/assistant/assistant.rc | 1 + tools/assistant/assistant_de.qm | Bin 0 -> 13929 bytes tools/assistant/assistant_de.ts | 1084 +++++++++++++++++++++++++++ tools/assistant/assistant_fr.ts | 426 +++++++++++ tools/assistant/book/assistant.book | 6 + tools/assistant/book/assistant.leaf | 563 ++++++++++++++ tools/assistant/book/images/assistant.png | Bin 0 -> 53805 bytes tools/assistant/book/images/docwindow.png | Bin 0 -> 9727 bytes tools/assistant/book/images/general.png | Bin 0 -> 11239 bytes tools/assistant/book/images/pdf1.png | Bin 0 -> 8610 bytes tools/assistant/book/images/search.png | Bin 0 -> 6284 bytes tools/assistant/book/images/sidebar.png | Bin 0 -> 5041 bytes tools/assistant/book/images/toolbar1.png | Bin 0 -> 4184 bytes tools/assistant/book/images/web.png | Bin 0 -> 11826 bytes tools/assistant/config.cpp | 379 ++++++++++ tools/assistant/config.h | 152 ++++ tools/assistant/docuparser.cpp | 397 ++++++++++ tools/assistant/docuparser.h | 151 ++++ tools/assistant/finddialog.ui | 286 +++++++ tools/assistant/finddialog.ui.h | 108 +++ tools/assistant/helpdialog.ui | 506 +++++++++++++ tools/assistant/helpdialogimpl.cpp | 1161 +++++++++++++++++++++++++++++ tools/assistant/helpdialogimpl.h | 171 +++++ tools/assistant/helpwindow.cpp | 282 +++++++ tools/assistant/helpwindow.h | 87 +++ tools/assistant/images/addtab.png | Bin 0 -> 469 bytes tools/assistant/images/appicon.png | Bin 0 -> 2353 bytes tools/assistant/images/assistant.png | Bin 0 -> 1349 bytes tools/assistant/images/book.png | Bin 0 -> 861 bytes tools/assistant/images/closetab.png | Bin 0 -> 533 bytes tools/assistant/images/d_closetab.png | Bin 0 -> 396 bytes tools/assistant/images/designer.png | Bin 0 -> 1367 bytes tools/assistant/images/editcopy.png | Bin 0 -> 491 bytes tools/assistant/images/find.png | Bin 0 -> 856 bytes tools/assistant/images/home.png | Bin 0 -> 1081 bytes tools/assistant/images/linguist.png | Bin 0 -> 1157 bytes tools/assistant/images/next.png | Bin 0 -> 541 bytes tools/assistant/images/previous.png | Bin 0 -> 542 bytes tools/assistant/images/print.png | Bin 0 -> 766 bytes tools/assistant/images/qt.png | Bin 0 -> 975 bytes tools/assistant/images/splash.png | Bin 0 -> 50661 bytes tools/assistant/images/whatsthis.xpm | 26 + tools/assistant/images/zoomin.png | Bin 0 -> 900 bytes tools/assistant/images/zoomout.png | Bin 0 -> 919 bytes tools/assistant/index.cpp | 526 +++++++++++++ tools/assistant/index.h | 131 ++++ tools/assistant/lib/lib.pro | 23 + tools/assistant/lib/qassistantclient.cpp | 334 +++++++++ tools/assistant/lib/qassistantclient.h | 80 ++ tools/assistant/main.cpp | 342 +++++++++ tools/assistant/mainwindow.ui | 670 +++++++++++++++++ tools/assistant/mainwindow.ui.h | 698 +++++++++++++++++ tools/assistant/profile.cpp | 124 +++ tools/assistant/profile.h | 130 ++++ tools/assistant/settingsdialog.ui | 516 +++++++++++++ tools/assistant/settingsdialogimpl.cpp | 122 +++ tools/assistant/settingsdialogimpl.h | 63 ++ tools/assistant/tabbedbrowser.ui | 141 ++++ tools/assistant/tabbedbrowser.ui.h | 347 +++++++++ tools/assistant/topicchooser.ui | 182 +++++ tools/assistant/topicchooserimpl.cpp | 70 ++ tools/assistant/topicchooserimpl.h | 60 ++ 66 files changed, 10697 insertions(+) create mode 100644 tools/assistant/LICENSE.GPL create mode 100644 tools/assistant/assistant.icns create mode 100644 tools/assistant/assistant.ico create mode 100644 tools/assistant/assistant.pro create mode 100644 tools/assistant/assistant.rc create mode 100644 tools/assistant/assistant_de.qm create mode 100644 tools/assistant/assistant_de.ts create mode 100644 tools/assistant/assistant_fr.ts create mode 100644 tools/assistant/book/assistant.book create mode 100644 tools/assistant/book/assistant.leaf create mode 100644 tools/assistant/book/images/assistant.png create mode 100644 tools/assistant/book/images/docwindow.png create mode 100644 tools/assistant/book/images/general.png create mode 100644 tools/assistant/book/images/pdf1.png create mode 100644 tools/assistant/book/images/search.png create mode 100644 tools/assistant/book/images/sidebar.png create mode 100644 tools/assistant/book/images/toolbar1.png create mode 100644 tools/assistant/book/images/web.png create mode 100644 tools/assistant/config.cpp create mode 100644 tools/assistant/config.h create mode 100644 tools/assistant/docuparser.cpp create mode 100644 tools/assistant/docuparser.h create mode 100644 tools/assistant/finddialog.ui create mode 100644 tools/assistant/finddialog.ui.h create mode 100644 tools/assistant/helpdialog.ui create mode 100644 tools/assistant/helpdialogimpl.cpp create mode 100644 tools/assistant/helpdialogimpl.h create mode 100644 tools/assistant/helpwindow.cpp create mode 100644 tools/assistant/helpwindow.h create mode 100644 tools/assistant/images/addtab.png create mode 100644 tools/assistant/images/appicon.png create mode 100644 tools/assistant/images/assistant.png create mode 100644 tools/assistant/images/book.png create mode 100644 tools/assistant/images/closetab.png create mode 100644 tools/assistant/images/d_closetab.png create mode 100644 tools/assistant/images/designer.png create mode 100644 tools/assistant/images/editcopy.png create mode 100644 tools/assistant/images/find.png create mode 100644 tools/assistant/images/home.png create mode 100644 tools/assistant/images/linguist.png create mode 100644 tools/assistant/images/next.png create mode 100644 tools/assistant/images/previous.png create mode 100644 tools/assistant/images/print.png create mode 100644 tools/assistant/images/qt.png create mode 100644 tools/assistant/images/splash.png create mode 100644 tools/assistant/images/whatsthis.xpm create mode 100644 tools/assistant/images/zoomin.png create mode 100644 tools/assistant/images/zoomout.png create mode 100644 tools/assistant/index.cpp create mode 100644 tools/assistant/index.h create mode 100644 tools/assistant/lib/lib.pro create mode 100644 tools/assistant/lib/qassistantclient.cpp create mode 100644 tools/assistant/lib/qassistantclient.h create mode 100644 tools/assistant/main.cpp create mode 100644 tools/assistant/mainwindow.ui create mode 100644 tools/assistant/mainwindow.ui.h create mode 100644 tools/assistant/profile.cpp create mode 100644 tools/assistant/profile.h create mode 100644 tools/assistant/settingsdialog.ui create mode 100644 tools/assistant/settingsdialogimpl.cpp create mode 100644 tools/assistant/settingsdialogimpl.h create mode 100644 tools/assistant/tabbedbrowser.ui create mode 100644 tools/assistant/tabbedbrowser.ui.h create mode 100644 tools/assistant/topicchooser.ui create mode 100644 tools/assistant/topicchooserimpl.cpp create mode 100644 tools/assistant/topicchooserimpl.h (limited to 'tools/assistant') diff --git a/tools/assistant/LICENSE.GPL b/tools/assistant/LICENSE.GPL new file mode 100644 index 0000000..3221c03 --- /dev/null +++ b/tools/assistant/LICENSE.GPL @@ -0,0 +1,280 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS diff --git a/tools/assistant/assistant.icns b/tools/assistant/assistant.icns new file mode 100644 index 0000000..a6dbcdd Binary files /dev/null and b/tools/assistant/assistant.icns differ diff --git a/tools/assistant/assistant.ico b/tools/assistant/assistant.ico new file mode 100644 index 0000000..eb43249 Binary files /dev/null and b/tools/assistant/assistant.ico differ diff --git a/tools/assistant/assistant.pro b/tools/assistant/assistant.pro new file mode 100644 index 0000000..1d8ba5c --- /dev/null +++ b/tools/assistant/assistant.pro @@ -0,0 +1,72 @@ +TEMPLATE = app +LANGUAGE = C++ +TARGET = assistant + +CONFIG += qt warn_off + +PROJECTNAME = Assistant +DESTDIR = ../../bin + +SOURCES += main.cpp \ + helpwindow.cpp \ + topicchooserimpl.cpp \ + docuparser.cpp \ + helpdialogimpl.cpp \ + settingsdialogimpl.cpp \ + index.cpp \ + profile.cpp \ + config.cpp + +HEADERS += helpwindow.h \ + topicchooserimpl.h \ + docuparser.h \ + helpdialogimpl.h \ + settingsdialogimpl.h \ + index.h \ + profile.h \ + config.h + +#DEFINES += QT_PALMTOPCENTER_DOCS +DEFINES += QT_INTERNAL_NETWORK QT_INTERNAL_XML +include( ../../src/qt_professional.pri ) + +win32:RC_FILE = assistant.rc +mac:RC_FILE = assistant.icns + +target.path = $$bins.path +INSTALLS += target + +assistanttranslations.files = *.qm +assistanttranslations.path = $$translations.path +INSTALLS += assistanttranslations + +TRANSLATIONS = assistant_de.ts \ + assistant_fr.ts + +unix:!zlib:LIBS += -lz + +FORMS = mainwindow.ui \ + topicchooser.ui \ + finddialog.ui \ + helpdialog.ui \ + settingsdialog.ui \ + tabbedbrowser.ui +IMAGES = images/editcopy.png \ + images/find.png \ + images/home.png \ + images/next.png \ + images/previous.png \ + images/print.png \ + images/whatsthis.xpm \ + images/book.png \ + images/designer.png \ + images/assistant.png \ + images/linguist.png \ + images/qt.png \ + images/zoomin.png \ + images/zoomout.png \ + images/splash.png \ + images/appicon.png \ + images/addtab.png \ + images/closetab.png \ + images/d_closetab.png diff --git a/tools/assistant/assistant.rc b/tools/assistant/assistant.rc new file mode 100644 index 0000000..b4786ce --- /dev/null +++ b/tools/assistant/assistant.rc @@ -0,0 +1 @@ +IDI_ICON1 ICON DISCARDABLE "assistant.ico" diff --git a/tools/assistant/assistant_de.qm b/tools/assistant/assistant_de.qm new file mode 100644 index 0000000..c50e90f Binary files /dev/null and b/tools/assistant/assistant_de.qm differ diff --git a/tools/assistant/assistant_de.ts b/tools/assistant/assistant_de.ts new file mode 100644 index 0000000..15b0b97 --- /dev/null +++ b/tools/assistant/assistant_de.ts @@ -0,0 +1,1084 @@ + + + Assistant + + Welcome to the <b>Qt Assistant</b>. Qt Assistant will give you quicker access to help and tips while using applications like Qt Designer. + Wilkommen bei <b>Qt Assistant</b>. Qt Assistant ermöglicht einen schnellen Zugriff der Onlinehilfe während dem Arbeiten mit Programmen wie dem Qt Designer. + + + Qt Assistant + Qt Assistant + + + + AssistantServer + + Qt Assistant + Qt Assistant + + + Failed to bind to port %1 + Kann Port %1 nicht binden + + + + FindDialog + + Find Text + Textsuche + + + &Find: + &Suchen: + + + &Find + &Suchen + + + Close + Schließen + + + &Direction + Rich&tung + + + Forwar&d + &Vorwärts + + + &Backward + &Rückwärts + + + &Options + &Optionen + + + &Whole words only + &Ganze Wörter + + + &Case sensitive + Groß- und &Kleinschreibung beachten + + + Qt Assistant - Find Text + Qt Assistant - Textsuche + + + Enter the text you are looking for. + Geben Sie den Suchtext ein. + + + Search reached end of the document + Die Suche hat das Ende des Dokuments erreicht + + + Search reached start of the document + Die Suche hat den Anfang des Dokuments erreicht + + + Text not found + Text nicht gefunden + + + Fo&rward + Vo&rwärts + + + F&ind: + Su&chen: + + + C&lose + Sch&ließen + + + Alt+L + + + + Alt+F + + + + + HelpDialog + + Index + Index + + + Bookmarks + Lesezeichen + + + Con&tents + Inhal&t + + + Qt Reference Documentation + Qt Referenzdokumentation + + + Qt Designer Manual + Qt Designer Handbuch + + + Qt Linguist Manual + Qt Linguist Handbuch + + + Qt Assistant Manual + Qt Assistant Handbuch + + + Qt Assistant + Qt Assistant + + + Open Link in Current Window + Öffne Link im aktuellen Fenster + + + Open Link in New Window + Öffne Link in neuem Fenster + + + Contents + Inhalt + + + Search + Suche + + + Prepare... + Initialisiere... + + + Cannot open the index file %1 + Kann Indexdatei %1 nicht öffnen + + + Warning + Warnung + + + Documentation file %1 does not exist! +Skipping file. + Dokumentation %1 existiert nicht! +Überspringe Datei. + + + Parse Error + Syntaxfehler + + + Done + Fertig + + + Indexing files... + Indiziere Dokumentation... + + + Reading dictionary... + Lese Suchindex... + + + Full Text Search + Volltextsuche + + + Using a wildcard within phrases is not allowed. + Wildcards innerhalb von Phrasen sind nicht zugelassen. + + + The closing quotation mark is missing. + Das schließende Anführungszeichen fehlt. + + + Open Link in Current Tab + Link im Aktuellen Tab öffnen + + + Open Link in New Tab + Link in einem neuen Tab öffnen + + + Failed to load keyword index file +Assistant will not work! + Die Indexdatei konnte nicht geladen werden. +Der Assistent ist nicht einsatzbereit! + + + Documentation file %1 is not compatible! +Skipping file. + Dokumentation %1 ist nicht kompatibel! Datei wird übersprungen. + + + Failed to save fulltext search index +Assistant will not work! + Der Index für die Volltextsuche konnte nicht gespeichert werden. +Der Assistent ist nicht einsatzbereit! + + + + HelpDialogBase + + Help + Hilfe + + + <b>Help</b><p>Choose the topic you need help for from the contents list, or search the index for keywords.</p> + <b>Hilfe</b><p>Wählen Sie ein Thema vom Inhaltsverzeichnis oder suchen Sie im Index nach Schlüsselwörtern.</p> + + + Displays help topics organized by category, index or bookmarks + Zeigt die Hilfethemen unterteilt in Kategorien, Indizes oder Lesezeichen an + + + Con&tents + Inhal&t + + + Column 1 + Spalte 1 + + + <b>Help topics organized by category.</b><p>Double-click an item to see which topics are in that category. To view a topic, select it, and then click <b>Display</b>.</p> + <b>Die Hilfethemen sind nach Kategorien organisiert.</b><p>Ein Doppelklick auf einen Eintrag zeigt die Themen dieser Kategorie an. Um ein Thema anzuzeigen, wählen Sie es aus und drücken Sie <b>Anzeigen</b>.</p> + + + &Index + &Index + + + &Look For: + Suchen &nach: + + + Enter keyword + Geben Sie ein Schlüsselwort ein + + + <b>Enter a keyword.</b><p>The list will select an item that matches the entered string best.</p> + <b>Geben Sie ein Schlüsselwort ein.</b><p>Es wird dann der Eintrag aus der Liste ausgewählt, der am besten mit dem eingegebenen Begriff übereinstimmt.</p> + + + <b>List of available help topics.</b><p>Double-click on an item to open up the help page for this topic. You will have to choose the right page if more than one are found.</p> + <b>Liste aller verfügbaren Hilfethemen.</b><p>Ein Doppelklick auf einen Eintrag öffnet die dazugehörige Hilfeseite. Wenn es mehrere Seiten zu einem Eintrag gibt, wählen Sie die gewünschte aus.</p> + + + &Bookmarks + L&esezeichen + + + Displays the list of bookmarks. + Zeigt alle Lesezeichen an. + + + &New Bookmark + &Neues Lesezeichen + + + Add new bookmark + Füge neues Lesezeichen hinzu + + + Add the current displayed page as new bookmark to the list. + Füge die aktuelle Seite als Lesezeichen hinzu. + + + D&elete Bookmark + &Lösche Lesezeichen + + + Delete bookmark + Lösche Lesezeichen + + + Delete the selected bookmark from the list. + Lösche markiertes Lesezeichen. + + + Preparing... + Initialisiere... + + + <b>Help</b><p>Choose the topic you want help on from the contents list, or search the index for keywords.</p> + <b>Hilfe</b><p>Wählen Sie ein Hilfethema aus dem Inhalt oder suchen Sie im Index nach Schlüsselwörtern.</p> + + + Displays help topics organized by category, index or bookmarks. Another tab inherits the full text search. + Zeigt Hilfethemen geordnet nach Kategorie, Index oder Lesezeichen an. Ein weiterer Abschnitt enthält die Volltextsuche. + + + <b>Help topics organized by category.</b><p>Double-click an item to see the topics in that category. To view a topic, just double-click it.</p> + <b>Hilfethemen geordnet nach Kategorie.</b><p>Doppelklicken Sie einen Eintrag, um die Themen dieser Kategorie zu sehen. Doppelklicken Sie ein Thema, um es angezeigt zu bekommen.</p> + + + <b>List of available help topics.</b><p>Double-click on an item to open its help page. If more than one is found, you must specify which page you want.</p> + <b>Liste aller verfügbaren Hilfethemen.</b><p>Doppelklicken Sie auf einen Eintrag, um die Hilfe zu öffnen. Wenn mehr als eine Seite gefunden wurde, wählen Sie die gewünschte Seite aus.</p> + + + &New + &Neu + + + Add the currently displayed page as a new bookmark. + Füge aktuelle Seite zu den Lesezeichen hinzu. + + + &Delete + &Löschen + + + Delete the selected bookmark. + Lösche markiertes Lesezeichen. + + + &Search + &Suche + + + Searching f&or: + Suche &nach: + + + Enter searchword(s). + Suchebegriff(e). + + + <b>Enter search word(s).</b><p>Enter here the word(s) you are looking for. The words may contain wildcards (*). For a sequence of words quote them.</p> + <b>Geben Sie Suchbegriffe ein.</b><p>Geben Sie hier die gesuchten Begriffe ein. Die Begriffe können Wildcards (*) enthalten. Eine Phrase muß in Anführungszeichen stehen.</p> + + + <b>Found documents</b><p>This list contains all found documents from the last search. The documents are ordered, i.e. the first document has the most matches.</p> + <b>Gefundene Dokumente</b><p>Diese Liste beinhaltet alle gefundenen Dokumente der letzten Suche. Die Dokumente sind nach der Häufigkeit der Treffer geordnet.</p> + + + Found &Documents: + Gefundene &Dokumente: + + + He&lp + Hi&lfe + + + Display the help page. + Zeigt die Hilfe an. + + + Display the help page for the full text search. + Zeigt die Hilfeseite für die Volltextsuche an. + + + Start searching. + Starte Suche. + + + Pressing this button starts the search. + Startet die Suche. + + + + HelpWindow + + Qt Assistant by Trolltech - %1 + Qt Assistant von Trolltech - %1 + + + Help + Hilfe + + + Can't load and display non-local file +%1 + Kann gewünschte Datei nicht laden: +%1 + + + Open Link in New WindowShift+LMB + Öffne Link in neuem Fenster + + + Currently no Web browser is selected. +Please use the settings dialog to specify one! + + Es ist kein Webbrowser ausgewählt. +Öffnen Sie bitten den "Einstellungen" Dialog um einen Webbrowser auszuwählen. + + + + Qt Assistant by Trolltech - %1%2 + Qt Assistant von Trolltech - %1%2 + + + No PDF Viewer has been specified +Please use the settings dialog to specify one! + + Es wurde kein PDF Betrachter angegeben. +Bitte diesen im Menue Einstellungen festlegen! + + + + Qt Assistant is unable to start the PDF Viewer + +%1 + +Please make sure that the executable exists and is located at +the specified location. + Der Qt Assistent konnte den PDF betrachter +%1 nicht laden. +Bitte überprüfen Sie, das dieser an der angegeben Stelle existiert. + + + Open Link in New Tab + Link in einenm neuen Tab öffnen + + + + Index + + Untitled + Unbenannt + + + + MainWindow + + Qt Assistant by Trolltech + Qt Assistant von Trolltech + + + Toolbar + Werkzeugleiste + + + Print + Drucken + + + &Print... + &Drucken... + + + Exit + Beenden + + + E&xit + &Beenden + + + Copy + Kopieren + + + &Copy + &Kopieren + + + Find in Text + Textsuche + + + &Find in Text... + Text&suche... + + + Home + Startseite + + + &Home + St&artseite + + + Previous + Vorherige + + + &Previous + &Vorherige + + + Next + Nächste + + + &Next + &Nächste + + + About + Über + + + About Qt + Über Qt + + + Qt Class Reference + Qt Klassenreferenz + + + Qt Designer Manual + Qt Designer Handbuch + + + Zoom in + Vergrößern + + + Zoom &in + Ver&größern + + + Zoom out + Verkleinern + + + Zoom &out + Ver&kleinern + + + Qt Linguist Manual + Qt Linguist Handbuch + + + &Settings + &Einstellungen + + + &Settings... + &Einstellungen... + + + New Window + Neues Fenster + + + New Window... + Neues Fenster... + + + Close + Schließen + + + Vie&ws + A&nsicht + + + Ctrl+T + Strg+T + + + + Ctrl+I + Strg+I + + + Ctrl+B + Strg+E + + + Qt Assistant + Qt Assistant + + + &Add Bookmark + &Füge Lesezeichen hinzu + + + Qt Reference Documentation + Qt Referenzdokumention + + + &File + &Datei + + + &Edit + &Bearbeiten + + + &View + &Ansicht + + + &Go + &Gehe zu + + + Boo&kmarks + &Lesezeichen + + + &Help + &Hilfe + + + Print the currently displayed page. + Drucke aktuelle Seite. + + + Ctrl+P + Strg+P + + + Quit Qt Assistant. + Beende Qt Assistant. + + + Ctrl+Q + Strg+Q + + + Copy the selected text to the clipboard. + Kopiere den markierten Text in die Zwischenablage. + + + Ctrl+C + Strg+C + + + Open the Find dialog. Qt Assistant will search the currently displayed page for the text you enter. + Öffne den Suchdialog. Qt Assistant sucht in der aktuellen Seite nach dem eingegebenen Text. + + + Ctrl+F + Strg+F + + + Go to the home page. Qt Assistant's home page is the Qt Reference Documentation. + Gehe zur Startseite. Qt Assistants Startseite ist die Qt Referenzdokumentation. + + + Ctrl+Home + Strg+Pos1 + + + Go to the previous page. + Gehe zur vorherigen Seite. + + + Alt+Left + Alt+Links + + + Go to the next page. + Gehe zur nächsten Seite. + + + Alt+Right + Alt+Rechts + + + Display further information about Qt Assistant. + Zeigt weitere Informationen zu Qt Assistant an. + + + Display further information about Qt. + Zeigt weitere Informationen zu Qt an. + + + Display the Qt Reference Documentation. + Zeigt die Qt Referenzdokumentation an. + + + Display the Qt Designer manual. + Zeigt das Qt Designer Handbuch an. + + + Zoom in on the document, i.e. increase the font size. + Vergrößert die Schrift. + + + Ctrl++ + Strg++ + + + Zoom out on the document, i.e. decrease the font size. + Verkleinert die Schrift. + + + Ctrl+- + Strg+- + + + Display the Guide to the Qt Translation Tools. + Zeigt die Anleitung zu den Qt Übersetzungswerkzeugen an. + + + Open the settings dialog. + Öffnet den "Einstellungen" Dialog. + + + Open a new window. + Öffnet ein neues Fenster. + + + Ctrl+N + Strg+N + + + &Close + &Schließen + + + Close the current window. + Schließt das aktuelle Fenster. + + + Qt Assistant Manual + Qt Assistant Handbuch + + + Display the Qt Assistant manual. + Zeigt das Qt Assistant Handbuch an. + + + F1 + F1 + + + Add the currently displayed page as a new bookmark. + Füge aktuelle Seite zu den Lesezeichen hinzu. + + + What's This? + Direkthilfe + + + "What's This?" context sensitive help. + Kontextbezogene Direkthilfe. + + + Shift+F1 + Umschalt+F1 + + + Ctrl+S + Strg+S + + + Initializing Qt Assistant... + Initialisiere Qt Assistant... + + + Go + Gehe zu + + + Find &Next + &Nächste finden + + + Find Next + Nächste finden + + + F3 + F3 + + + Find &Previous + &Vorigen finden + + + Find Previous + Vorigen finden + + + Shift+F3 + Umschalt+F3 + + + About Qt Assistant + Über den Qt Assistent + + + Settings + Einstellungen + + + Add Bookmark + Lesezeichen einfügen + + + Add Tab + Tab einfügen + + + Ctrl+Alt+N + + + + Next Tab + Nächster Tab + + + Ctrl+Alt+Right + + + + Previous Tab + Voriger Tab + + + Ctrl+Alt+Left + + + + Close Tab + Tab schließen + + + Ctrl+Alt+Q + + + + Failed to open about application contents in file: '%1' + + + + Failed to open link: '%1' + Der Link '%1' konnte nicht geöffnet werden + + + <div align="center"><h1>The page could not be found!</h1><br><h3>'%1'</h3></div> + <div align="Hauptseite nicht gefunden!</h1> + + + Error... + Fehler ... + + + + SettingsDialog + + all + Alle + + + Qt Assistant - Add Documentation + Qt Assistant - Hinzufügen von Dokumentation + + + Qt Assistant + Qt Assistant + + + Parse Error + Syntaxfehler + + + This item can not be deleted! + Dieser Eintrag kann nicht gelöscht werden! + + + This branch is not empty! +Firstly, all contents have to be removed. + Dieser Zweig ist nicht leer! +Es müssen zuerst alle Inhalte gelöscht werden. + + + Qt Assistant - Set Web Browser + Qt Assistant - Setze Webbrowser + + + Qt Assistant - Set PDF Browser + Qt Assistent - Setze PDF Betrachter + + + Qt Assistant - Set Homepage + Qt Assistent - Setzte Startseite + + + + SettingsDialogBase + + Settings + Einstellungen + + + Font: + Schriften: + + + Link color: + Linkfarbe: + + + Underline links + Unterstreiche Links + + + OK + OK + + + Cancel + Abbrechen + + + Fixed font: + Nicht-proportionale Schrift: + + + Qt Assistant - Settings + Qt Assistant - Einstellungen + + + General + Allgemein + + + Fix&ed font: + &Nicht-proportionale Schrift: + + + &Font: + &Schrift: + + + &Underline links + &Unterstreiche Links + + + Web + Web + + + &Web Browser Application: + &Webbrowser Anwendung: + + + ... + ... + + + Documentation + Dokumentation + + + &Delete + &Lösche + + + &Add... + &Hinzufügen... + + + Categories + Kategorien + + + Category &Name: + Kategorie&name: + + + &Add + &Hinzufügen + + + &OK + &OK + + + &Cancel + &Abbrechen + + + &General + &Haupt + + + &Web + &Web + + + Web &Browser Application: + Web&browser: + + + &Home page + &Startseite + + + &PDF + &PDF + + + PDF &Application + PDF &Betrachter + + + + TabbedBrowser + + TabbedBrowser + + + + Untitled + Unbenannt + + + Add page + Seite einfügen + + + Close page + Seite schließen + + + + TopicChooser + + Choose a topic for <b>%1</b> + Wählen Sie ein Thema für <b>%1</b> + + + + TopicChooserBase + + Choose Topic + Thema wählen + + + Select a topic from the list and click the <b>Display</b>-button to open the online help. + Wählen Sie ein Thema aus der Liste aus und klicken Sie <b>Anzeigen</b> um die Hilfe zu öffnen. + + + &Topics + &Themen + + + Displays a list of available help topics for the keyword. + Zeigt eine Liste der verfügbaren Hilfethemen für diesen Begriff an. + + + &Display + &Anzeigen + + + Open the topic selected in the list. + Öffne das gewählte Thema aus der Liste. + + + &Close + &Schließen + + + Close the Dialog. + Schließt den Dialog. + + + diff --git a/tools/assistant/assistant_fr.ts b/tools/assistant/assistant_fr.ts new file mode 100644 index 0000000..0dfa69f --- /dev/null +++ b/tools/assistant/assistant_fr.ts @@ -0,0 +1,426 @@ + + + Assistant + + Welcome to the <b>Qt Assistant</b>. Qt Assistant will give you quicker access to help and tips while using applications like Qt Designer. + + + + Qt Assistant + + + + + FindDialog + + Find Text + + + + &Find: + + + + &Find + + + + Close + + + + &Direction + + + + Forwar&d + + + + &Backward + + + + &Options + + + + &Whole words only + + + + &Case sensitive + + + + + HelpDialog + + Index + + + + Bookmarks + + + + Con&tents + + + + Qt Reference Documentation + + + + Qt Designer Manual + + + + Qt Linguist Manual + + + + Qt Assistant Manual + + + + Qt Assistant + + + + + HelpDialogBase + + Help + + + + <b>Help</b><p>Choose the topic you need help for from the contents list, or search the index for keywords.</p> + + + + Displays help topics organized by category, index or bookmarks + + + + Con&tents + + + + Column 1 + + + + <b>Help topics organized by category.</b><p>Double-click an item to see which topics are in that category. To view a topic, select it, and then click <b>Display</b>.</p> + + + + &Index + + + + &Look For: + + + + Enter keyword + + + + <b>Enter a keyword.</b><p>The list will select an item that matches the entered string best.</p> + + + + <b>List of available help topics.</b><p>Double-click on an item to open up the help page for this topic. You will have to choose the right page if more than one are found.</p> + + + + &Bookmarks + + + + Displays the list of bookmarks. + + + + &New Bookmark + + + + Add new bookmark + + + + Add the current displayed page as new bookmark to the list. + + + + D&elete Bookmark + + + + Delete bookmark + + + + Delete the selected bookmark from the list. + + + + Preparing... + + + + + HelpWindow + + Qt Assistant by Trolltech - %1 + + + + Help + + + + Can't load and display non-local file +%1 + + + + Open Link in New WindowShift+LMB + + + + + MainWindow + + Qt Assistant by Trolltech + + + + Toolbar + + + + Print + + + + &Print... + + + + Exit + + + + E&xit + + + + Copy + + + + &Copy + + + + Find in Text + + + + &Find in Text... + + + + Home + + + + &Home + + + + Previous + + + + &Previous + + + + Next + + + + &Next + + + + About + + + + About + + + + About Qt + + + + About Qt + + + + Qt Class Reference + + + + Qt Designer Manual + + + + Zoom in + + + + Zoom &in + + + + Zoom out + + + + Zoom &out + + + + Qt Linguist Manual + + + + &Settings + + + + &Settings... + + + + New Window + + + + New Window... + + + + Close + + + + Vie&ws + + + + Ctrl+T + + + + Ctrl+I + + + + Ctrl+B + + + + Qt Assistant + + + + &Add Bookmark + + + + Qt Reference Documentation + + + + + SettingsDialogBase + + Settings + + + + Font: + + + + Link color: + + + + Underline links + + + + OK + + + + Cancel + + + + Fixed font: + + + + + TopicChooser + + Choose a topic for <b>%1</b> + + + + + TopicChooserBase + + Choose Topic + + + + Select a topic from the list and click the <b>Display</b>-button to open the online help. + + + + &Topics + + + + Displays a list of available help topics for the keyword. + + + + &Display + + + + Open the topic selected in the list. + + + + &Close + + + + Close the Dialog. + + + + diff --git a/tools/assistant/book/assistant.book b/tools/assistant/book/assistant.book new file mode 100644 index 0000000..feb6588 --- /dev/null +++ b/tools/assistant/book/assistant.book @@ -0,0 +1,6 @@ +\title Qt Assistant Manual + +\granularity chapter + +\input assistant.leaf + diff --git a/tools/assistant/book/assistant.leaf b/tools/assistant/book/assistant.leaf new file mode 100644 index 0000000..57bab4c --- /dev/null +++ b/tools/assistant/book/assistant.leaf @@ -0,0 +1,563 @@ +\chapter Introduction + +This document introduces \QA, a tool for presenting on-line +documentation. It also introduces the Qt Reference Documentation which +is accessible using \QA, or with a web browser. The document is +divided into the following sections: + +\list +\i Introduction to the Qt Reference Documentation +\i The 1 Minute Guide to using Qt Assistant +\i Qt Assistant in More Detail +\i Full Text Searching +\i Customizing Qt Assistant +\endlist + +\chapter Introduction to the Qt Reference Documentation + +The documentation for the Qt library is written in-line in the \File +.cpp files by the developers themselves. The documentation team +revises the documentation to ensure that it is accurate and usable, +and to provide quality control. The documentation team also writes the +larger texts, such as the class descriptions that introduce a class +along with the concepts the class uses, as well as introducing the +functions and properties that the class provides. + +The documentation focuses on the API rather than the internals, since +we make great efforts to keep our API consistent and compatible with +each new version, but we may change the internals considerably to improve +performance and enhance functionality. + +The Qt Reference Documentation consists of almost 1,500 HTML pages +(over 2,500 printed pages). The overwhelming majority of pages +document Qt classes. Since developers differ in the way they +think and work we provide a variety of approaches to navigating the +documentation set: + +\list + +\i The \link classes.html All Classes\endlink page lists every class +in Qt's public API, and consists of several hundred classes. + +\i The \link mainclasses.html Main Classes\endlink page lists the +classes you're most likely to use most often, and provides a much +shorter and more managable list than the All Classes list. + +\i The \link groups.html Grouped Classes\endlink page presents a list +of groups, each of which leads to a list of related classes, for +example, the \link advanced.html Advanced Widgets\endlink list. + +\i The \link hierarchy.html Inheritance Hierarchy\endlink page +presents a list of classes in terms of the hierarchy of Qt classes. + +\i The \link functions.html All Functions\endlink page lists all the +functions provided by Qt classes, each one with links to the class(es) +in which it appears. + +\endlist + +No matter where you find yourself in the Qt documentation, you will +find extensive cross-referencing. Even snippets of example code +contain clickable links, so that for example, if you come across a +class declaration in a code example, the class name will be a +clickable link to the class's documentation. + +In addition to the class documentation some of Qt's modules have +extensive descriptions, and there are many overview documents which +describe various aspects of the Qt library; all these are linked from +the reference documentation home page. There are also two tutorials +and numerous example programs in the examples subdirectory of the Qt +distribution. + +\chapter The 1 Minute Guide to Using Qt Assistant + +Under Windows, \QA is available as a menu option on the Qt menu. On +Unix, run \c{assistant} from an xterm. + +When you start up \QA, you will be presented with a standard +main-window style application, with a menu bar and toolbar. Below +these, on the left hand side is a navigation window called the \e +Sidebar, and on the right, taking up most of the space, is the +documentation window. By default, the Qt Reference Documentation's home +page is shown in the documentation window. + +\QA works in a similar way to a web browser. If you click underlined +text (which signifies a cross-reference), the documentation window will +present the relevant page. You can bookmark pages of particular +interest and you can click the \Toolbutton Previous and \Toolbutton +Next toolbar buttons to navigate within the pages you've visited. + +Although \QA can be used just like a web browser to navigate through +the Qt documentation set, \QA offers a powerful means of navigation +that web browsers don't provide. \QA uses an intelligent algorithm to +index all the pages in the documentation sets that it presents so that +you can search for particular words and phrases. + +To perform an index search, click the \Toolbutton Index tab on the Sidebar +(or click \Key Ctrl+I). In the 'Look For' line edit enter a word, e.g. +'homedirpath'. As you type, words are found and highlighted in a list +beneath the line edit. If the highlighted text matches what you're +looking for, double click it, (or press \Key Enter) and the +documentation window will display the relevant page. You rarely have +to type in the whole word before \QA finds a match. Note that for some +words there may be more than one possible page that is relevant. + +\QA also provides full text searching for finding specific words in +the documentation. Documents with the highest occurrences of the word +that you are looking for appear first, and every occurrence of the +word within the documentation is highlighted. + +\omit +For example, enter 'setenabled' in the 'Look For' line edit. +As you type, words are found and highlighted in the list beneath the +line edit, as before. Once the highlighted text matches what you're +looking for, double click it, (or press \Key Enter). In the case of +setEnabled, it is a function name which occurs in several classes, so +a dialog pops up listing the possible choices. Click the choice you're +interested in (or move to it using the \Key Up and \Key Down arrow +keys and press \Key Enter). The relevant page will display in the +documentation window. +\endomit + +\QA can be customized by creating profiles, a collection of +documentation. Profiles can be created for your own use, or for an +application you will distribute. With profiles, you can select which +documentation you want the end user of your application to be able to +view. + +\chapter Qt Assistant in More Detail + +\img assistant.png +\caption Qt Assistant + +\section1 The Sidebar + +\img sidebar.png + +The sidebar provides four ways of navigating documentation: +\list 1 +\i The \Toolbutton Contents tab presents a tree view of the +documentation sets that are available. If you click an item, its +documentation will appear in the documentation window. If you double +click an item or click a '+' sign to the left of an item, the item's +sub-items will appear. Click a sub-item to make its page appear in the +documentation window. Click a '-' sign to the left of an item to hide +its sub-items. +\i The \Toolbutton Index tab is used to look up key words or phrases. +See \l{The 1 Minute Guide to using Qt Assistant} for how to use this +tab. +\i The \Toolbutton Bookmarks tab lists any bookmarks you've made. +Double click a bookmark to make its page appear in the documentation +window. The \Toolbutton Bookmarks tab has a \Button{New Bookmark} +button and a \Button{Delete Bookmark} button at the bottom. Click +\Button{New Bookmark} to bookmark the page that is showing in the +documentation window. Click a bookmark in the list, then click +\Button{Delete Bookmark} to delete the highlighted bookmark. +\i The \Toolbutton Search tab provides full text search of \e all +the documents. See \l{Full Text Searching} for more information about +this feature. +\endlist + +If you want the documentation window to use as much space as possible, +you can easily hide or show the Sidebar. If the Sidebar is showing, +press \Key Ctrl+T, \Key Ctrl+I, \Key Ctrl+B or \Key Ctrl+S to hide it. +If the Sidebar is hidden, press \Key Ctrl+T to show it on the Contents +tab, or press \Key Ctrl+I to show it on the Index tab (with the focus +in the 'Look For' line edit box), or press \Key Ctrl+B to show it on +the Bookmarks tab, or press \Key Ctrl+S to show it on the (full text) +Search tab. + +The Sidebar is a dock window, so you can drag it to the top, left, +right or bottom of \QA's window, or you can drag it outside \QA to +float it. + +\section1 The Documentation Window + +\img docwindow.png + +The documentation window offers a feature for viewing documentation by +enabling you to create tabs for each documentation page that you view. +Click the \Button {Add Tab} button and a new tab will appear with the +page name as the tab's caption. This makes it convenient to switch +between pages when you are working with different documentation. You +can delete a tab by clicking the \Button {Close Tab} button located +on the right side of the documentation window. + +\section1 The Toolbar + +\img toolbar1.png + +The toolbar provides fast access to the most common actions. +\list +\i \Toolbutton Previous takes you to the previous page. The menu +option is \Menu Go|Previous and the keyboard shortcut is \Key{Alt+Left +Arrow}. +\i \Toolbutton Next takes you to the next page. The menu +option is \Menu Go|Next and the keyboard shortcut is \Key{Alt+Right +Arrow}. +\i \Toolbutton Home takes you to the home page (normally the home page +of the Qt Reference Documentation). The menu +option is \Menu Go|Home and the keyboard shortcut is \Key{Ctrl+Home}. +\i \Toolbutton Copy copies any selected text to the clipboard. The menu +option is \Menu Edit|Copy and the keyboard shortcut is \Key{Ctrl+C}. +\i \Toolbutton{Find in Text} invokes the \Dialog{Find Text} dialog. The menu +option is \Menu{Edit|Find in Text} and the keyboard shortcut is \Key{Ctrl+F}. +\i \Toolbutton{Print} invokes the \Dialog{Print} dialog. The menu +option is \Menu{File|Print} and the keyboard shortcut is \Key{Ctrl+P}. +\i \Toolbutton{Zoom in} increases the font size. The menu +option is \Menu{View|Zoom in} and the keyboard shortcut is \Key{Ctrl++}. +\i \Toolbutton{Zoom out} decreases the font size. The menu +option is \Menu{View|Zoom out} and the keyboard shortcut is \Key{Ctrl+-}. +\i \Toolbutton{What's This?} provides a description of a \QA feature. +The menu option is \Menu{Help|What's This?} and the keyboard shortcut +is \Key{Shift+F1}. +\endlist + +The remaining toolbar buttons are bookmarks and will vary depending on +your configuration. + +\section1 The Menus + +\section2 The File Menu + +\list +\i \Menu{File|Print} invokes the \Dialog{Print} dialog. +\i \Menu{File|Exit} terminates \QA. +\endlist + +\section2 The Edit Menu + +\list +\i \Menu{Edit|Copy} copies any selected text to the clipboard. +\i \Menu{Edit|Find in Text} invokes the \Dialog{Find Text} dialog. +\i \Menu{Edit|Settings} invokes the \Dialog{Settings} dialog. +\endlist + +\section2 The View Menu + +\list +\i \Menu{View|Zoom in} increases the font size. +\i \Menu{View|Zoom out} decreases the font size. +\i \Menu{View|Views|Sidebar} toggles the display of the Sidebar. +\i \Menu{View|Views|Toolbar} toggles the display of the Toolbar. +\i \Menu{View|Views|Line up} lines up the toolbar buttons in the +Toolbar. +\endlist + +\section2 The Go Menu + +\list +\i \Menu{Go|Previous} displays the previous page. +\i \Menu{Go|Next} displays the next page. +\i \Menu{Go|home} goes to the home page. +\endlist +This menu also has additional items; these are pre-defined bookmarks +that vary depending on your configuration. + +\section2 The Bookmarks Menu + +\list +\i \Menu{Bookmarks|Add} adds the current page to the list of bookmarks. +\endlist +This menu may have additional items, i.e. any bookmarks that you have +already made. If you want to delete a bookmark go to the Bookmarks tab +on the Sidebar. + +\section1 The Dialogs + +\section2 The Print Dialog + +This dialog is platform-specific. It gives access to various printer +options and can be used to print the current page. + +\section2 The Find Text Dialog + +This dialog is used to find text in the current page. Enter the text +you want to find in the Find line edit. If you check the 'Whole words +only' checkbox, the search will only consider whole words, i.e. if you +search for 'spin' with this checkbox checked it will not match +'spinbox', but will match 'spin'. If you check the 'Case sensitive' +check box then, for example, 'spin' will match 'spin' but not 'Spin'. +You can search Forward or Backward from your current position in the +page by clicking one of the Direction radio buttons. Click the \Button +Find button to search (or search again), and click the \Button Close +button to finish. + +\section2 The Settings Dialog + +The Settings dialog is used to set your preferences for \QA. The +dialog has four tabs: General Settings, Web Settings, PDF Settings, +and Profiles. \QA will remember your settings between sessions, +including window sizes and positions, and which pages you have open. +Each of the tabs is discussed as follows: + +\list +\i General Settings + +\img general.png + +To change the base font used throughout \QA, select a +font type from the Font combobox. To choose a new fixed-width +font, for example, to show code snippets, choose a font type from +the 'Fixed font' combobox. To change the color of hypertext +links, click the 'Link color' color button. Uncheck the +'Underline links' checkbox if you don't want underlined links. + +\i Web Settings + +\img web.png + +Some pages contain links to external web pages. In order to display +these links, you must specify a web browser. Type the name of your +browser's executable in the Web Browser Application line edit. +Alternatively, click the \Button {(ellipsis)} button to invoke the +\Widget {Set Web Browser} dialog and navigate until you find the web +browser you want to use. Click \Button {Save} to accept the selection. + +To change \QA's default home page, enter the file name in the Home +Page line edit. Alternatively, click the \Button {(ellipsis)} button +to invoke the \Widget {Set Homepage} dialog. Navigate until you find +the home page file you want to use and then click \Button {Save} to +accept the selection. + +\i PDF Settings + +\img pdf1.png + +Some pages contain links to PDF documents. In order to display these +links, you must specify a PDF viewer. Type in the name of your PDF viewer's +executable in the line edit. Alternatively, click the \Button {(ellipsis)} +button to invoke the \Widget {Set PDF Browser} dialog and navigate +until you find the PDF viewer you want to use. Click \Button Save to +accept the selection. + +\chapter Full Text Searching + +\img search.png + +\QA provides a powerful full text search engine. To search +for certain words or text, click the 'Search' tab in the sidebar. Then +enter the text you want to look for and press \Key Enter or click +\Button Search. The search is not case sensitive, so Foo, fOo and +FOO are all treated as the same. The following are examples of common search +patterns: + +\list +\i \c deep -- lists all the documents that contain the word 'deep' + +\i \c{deep*} -- lists all the documents that contain a word beginning +with 'deep' + +\i \c{deep copy} -- lists all documents that contain both 'deep' \e +and 'copy' + +\i \c{"deep copy"} -- list all documents that contain the phrase 'deep copy' +\endlist + +The wildcard (*) character cannot be used within quotes. + +The list of documents found is ordered according to the number of +occurrences of the search text they contain, therefore those with the +highest number of occurrences appearing first. Simply click any +document in the list to display it in the document window. + +If the documentation has changed, i.e. if documents have been added or +removed, \QA will reindex. + +\chapter Customizing Qt Assistant + +\QA can be customized by adding and removing documentation from its +documentation set. In addition, \QA introduces the profiles option, +which enables its properties to change, for example, the default +startup page, and application icon. + +\section1 Modifying the Default Documentation Set + +When it is started without any options, \QA displays a default set of +documentation. When Qt is installed, the default documentation set in +\QA contains the Qt reference documentation as well as the tools that +come with Qt, such as \QD and qmake. + +Documentation can be added or removed from \QA by +adding and removing the content files. The format of the content files are +specified below. To add a content file, type the following command line +option: \c{-addContentFile docfile}. To remove a content file from the +default set, type the following command line option: +\c{-removeContentFile docfile}. For example: + +\code +1: > assistant -addContentFile file.dcf +2: > assistant +3: > assistant -removeContentFile file.dcf +\endcode + +In line one, we add the content file \c file.dcf. In line two, we start +\QA. The default set will now be extended with the doc file +\c file.dcf. In line three we remove the file \c file.dcf from the default +documentation set so that subsequent use of \QA will not contain this +file. + +\section2 Documentation Content File Format + +The Documentation Content File must contain the documentation's table +of contents and all important keywords for the index. In addition, it +may inherit an icon for the documentation which is displayed in the +\QA toolbar. You can also specify an extra directory path for +additional images used in the documentation. + +An example of a content file that uses all the available tags and +attributes is shown below: +\code + + +
+
+ foo + bla +
+
+
+
+
+
+
+
+
+
+
+ foo +
+
+ + +\endcode + +Sections may be nested as deeply as necessary. All references should +be related. + +Note that any \c keyword tags for a given section must appear \e +before any sections nested within the given section. + +The paths in the \c refs attribute are always written Unix-style +(forward slashes) and are relative to the location of the +documentation content file itself. + +Since the introduction of the new root tag \c assistantconfig in the +fileformat from Qt version 3.2.0, it is possible to specify multiple DCF tags in +one file. Note that the old document contents file format, used up to +Qt 3.2 is still valid. + +\section1 Profiles + +Profiles enable \QA to act as a specialized help tool for displaying +documentation for applications. With profiles, the documentation +writer can change properties such as \QA's title, application icons, and +'about' dialogs. In addition, profiles can be used to run specialized +documentation sets that are separate from the Qt docs. \QA can be +customized by changing the following properties: + +\list + +\i Name- This property is used to name the profile. If multiple +profiles are used for the same installation of \QA, this +parameter is crucial to keep their profile specific settings +apart. The property name is \c name + +\i Title- This property is used to specify a caption for \QA. The +property name is \c title + +\i Application Icon- This property describes an icon that will be used +as \QA application icon. The location of the icon is relative to the +location of the profile. The property name is \c applicationicon + +\i Start Page- This property specifies which page \QA should initially +display when the profile is used. Usually, this is the HTML file which +contains the documentation's table of contents. This property also +describes the default location to go to when pressing the home button +in \QA's main user interface. The start page is specified relative to +the location of the profile. The property name is \c startpage + +\i About Menu Text- This property describes the text that appears in +the \Menu Help menu, e.g. About Application. The property name is \c +aboutmenutext + +\i About URL- This property can be used to point to an HTML file that +describes the contents in the About dialog that is opened for the +\Menu Help menu, e.g. About Application. The url is specified relative +to the location of the profile. The property name is \c abouturl + +\i \QA Documentation- This property describes the location of +the \QA documentation. This is required since \QA provides +self help, such as the full text search help and the \QA +Manual option in the \Menu Help menu. The location is a directory +relative to the location of the profile. The property name is \c +assistantdocs. + +\endlist + +To define a profile, one needs to specify a \QA Document +Profile, usually abbreviated \c{.adp}. The profile is an extension of +the Documentation Content File described above. We add a \c profile +tag containing \c property tags to the format. + +An example of a document profile file is shown below: + +\c helpdemo.adp + +\code + + + + HelpExample + Help Example + logo.png + index.html + About Help + ../about.txt + ../../../doc/html + + + +
+ Install Docs + Example Profile + Hide Sidebar + Open + Close + Display +
+
+ +
+\endcode + +These files are XML files. Characters such as \c{<}, \c{>}, and \c{&} +must be written as entities (e.g., \c{<}, \c{>}, \c{&}). + +\section2 Using Profiles + +To use a profile, run \QA with the option \c {-profile filename}. +This will load the profile specified in the file and will customize +\QA accordingly. For example, to run \QA with the example +file above, \c helpdemo.adp, we would run the command as follows: + +\code +> assistant -profile helpdemo.adp +\endcode + +See the HelpDemo example in the Qt distribution for a demonstration +on how to use \QA with profiles for your own applications. + +When distributing \QA with your application, you will also need to +copy the icon files from the \c QTDIR/tools/assistant/images +directory so that \QA finds its icons. + +\omit +For small documentation sets, the sidebar may not be necessary. You +can hide the sidebar on startup with the following: +\code +assistant -hideSidebar +\endcode +\endomit + diff --git a/tools/assistant/book/images/assistant.png b/tools/assistant/book/images/assistant.png new file mode 100644 index 0000000..9401940 Binary files /dev/null and b/tools/assistant/book/images/assistant.png differ diff --git a/tools/assistant/book/images/docwindow.png b/tools/assistant/book/images/docwindow.png new file mode 100644 index 0000000..18fa098 Binary files /dev/null and b/tools/assistant/book/images/docwindow.png differ diff --git a/tools/assistant/book/images/general.png b/tools/assistant/book/images/general.png new file mode 100644 index 0000000..2fad053 Binary files /dev/null and b/tools/assistant/book/images/general.png differ diff --git a/tools/assistant/book/images/pdf1.png b/tools/assistant/book/images/pdf1.png new file mode 100644 index 0000000..104ac16 Binary files /dev/null and b/tools/assistant/book/images/pdf1.png differ diff --git a/tools/assistant/book/images/search.png b/tools/assistant/book/images/search.png new file mode 100644 index 0000000..667a4a6 Binary files /dev/null and b/tools/assistant/book/images/search.png differ diff --git a/tools/assistant/book/images/sidebar.png b/tools/assistant/book/images/sidebar.png new file mode 100644 index 0000000..7e005cd Binary files /dev/null and b/tools/assistant/book/images/sidebar.png differ diff --git a/tools/assistant/book/images/toolbar1.png b/tools/assistant/book/images/toolbar1.png new file mode 100644 index 0000000..0f3358a Binary files /dev/null and b/tools/assistant/book/images/toolbar1.png differ diff --git a/tools/assistant/book/images/web.png b/tools/assistant/book/images/web.png new file mode 100644 index 0000000..5888f79 Binary files /dev/null and b/tools/assistant/book/images/web.png differ diff --git a/tools/assistant/config.cpp b/tools/assistant/config.cpp new file mode 100644 index 0000000..83d0bdc --- /dev/null +++ b/tools/assistant/config.cpp @@ -0,0 +1,379 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the Qt Assistant. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "config.h" +#include "profile.h" +#include "docuparser.h" + +#include +#include +#include +#include +#include +#include + +static Config *static_configuration = 0; + +inline QString getVersionString() +{ + return QString::number( (QT_VERSION >> 16) & 0xff ) + + "." + QString::number( (QT_VERSION >> 8) & 0xff ); +} + +Config::Config() + : hideSidebar( FALSE ), profil( 0 ), maximized(FALSE) +{ + fontSiz = qApp->font().pointSize(); + if( !static_configuration ) { + static_configuration = this; + } else { + qWarning( "Multiple configurations not allowed!" ); + } +} + +Config *Config::loadConfig(const QString &profileFileName) +{ + Config *config = new Config(); + + if (profileFileName.isEmpty()) { // no profile + config->profil = Profile::createDefaultProfile(); + config->load(); + config->loadDefaultProfile(); + return config; + } + + QFile file(profileFileName); + if (!file.exists()) { + qWarning( "File does not exist: " + profileFileName ); + return 0; + } + DocuParser *parser = DocuParser::createParser( profileFileName ); + if (!parser) { + qWarning( "Failed to create parser for file: " + profileFileName ); + return 0; + } + if (parser->parserVersion() < DocuParser::Qt320) { + qWarning( "File does not contain profile information" ); + return 0; + } + DocuParser320 *profileParser = static_cast(parser); + parser->parse(&file); + config->profil = profileParser->profile(); + if (!config->profil) { + qWarning( "Config::loadConfig(), no profile in: " + profileFileName ); + return 0; + } + config->profil->setProfileType(Profile::UserProfile); + config->profil->setDocuParser(profileParser); + config->load(); + return config; +} + +Config *Config::configuration() +{ + Q_ASSERT( static_configuration ); + return static_configuration; +} + +void Config::load() +{ + const QString key = "/Qt Assistant/" + getVersionString() + "/"; + const QString profkey = key + "Profile/" + profil->props["name"] + "/"; + + QSettings settings; + settings.insertSearchPath( QSettings::Windows, "/Trolltech" ); + + webBrows = settings.readEntry( key + "Webbrowser" ); + home = settings.readEntry( profkey + "Homepage" ); + pdfApp = settings.readEntry( key + "PDFApplication" ); + linkUnder = settings.readBoolEntry( key + "LinkUnderline", TRUE ); + linkCol = settings.readEntry( key + "LinkColor", "#0000FF" ); + src = settings.readListEntry( profkey + "Source" ); + sideBar = settings.readNumEntry( key + "SideBarPage" ); + if (qApp->type() != QApplication::Tty) { + fontFam = settings.readEntry( key + "Family", qApp->font().family() ); + + fontFix = settings.readEntry( key + "FixedFamily", "courier" ); + fontSiz = settings.readNumEntry( key + "Size", -1 ); + if ( fontSiz < 4 ) { + fontSiz = qApp->font().pointSize(); + } + + geom.setRect( settings.readNumEntry( key + "GeometryX", QApplication::desktop()->availableGeometry().x() ), + settings.readNumEntry( key + "GeometryY", QApplication::desktop()->availableGeometry().y() ), + settings.readNumEntry( key + "GeometryWidth", 800 ), + settings.readNumEntry( key + "GeometryHeight", 600 ) ); + maximized = settings.readBoolEntry( key + "GeometryMaximized", FALSE ); + } + mainWinLayout = settings.readEntry( key + "MainwindowLayout" ); + rebuildDocs = settings.readBoolEntry( key + "RebuildDocDB", TRUE ); + + profileNames = settings.entryList( key + "Profile" ); +} + +void Config::save() +{ + saveSettings(); + saveProfile( profil ); +} + +void Config::saveSettings() +{ + const QString key = "/Qt Assistant/" + getVersionString() + "/"; + const QString profkey = key + "Profile/" + profil->props["name"] + "/"; + + QSettings settings; + settings.insertSearchPath( QSettings::Windows, "/Trolltech" ); + + settings.writeEntry( key + "Webbrowser", webBrows ); + settings.writeEntry( profkey + "Homepage", home ); + settings.writeEntry( key + "PDFApplication", pdfApp ); + settings.writeEntry( key + "LinkUnderline", linkUnder ); + settings.writeEntry( key + "LinkColor", linkCol ); + settings.writeEntry( profkey + "Source", src ); + settings.writeEntry( key + "SideBarPage", sideBarPage() ); + if (qApp->type() != QApplication::Tty) { + settings.writeEntry( key + "GeometryX", geom.x() ); + settings.writeEntry( key + "GeometryY", geom.y() ); + settings.writeEntry( key + "GeometryWidth", geom.width() ); + settings.writeEntry( key + "GeometryHeight", geom.height() ); + settings.writeEntry( key + "GeometryMaximized", maximized ); + settings.writeEntry( key + "Family", fontFam ); + settings.writeEntry( key + "Size", fontSiz < 4 ? qApp->font().pointSize() : fontSiz ); + settings.writeEntry( key + "FixedFamily", fontFix ); + } + if ( !hideSidebar ) + settings.writeEntry( key + "MainwindowLayout", mainWinLayout ); + settings.writeEntry( key + "RebuildDocDB", rebuildDocs ); +} + +#ifdef ASSISTANT_DEBUG +static void dumpmap( const QMap &m, const QString &header ) +{ + qDebug( header ); + QMap::ConstIterator it = m.begin(); + while (it != m.end()) { + qDebug( " " + it.key() + ":\t\t" + *it ); + ++it; + } +} +#endif + +void Config::loadDefaultProfile() +{ + QSettings settings; + settings.insertSearchPath( QSettings::Windows, "/Trolltech" ); + const QString key = "/Qt Assistant/" + QString(QT_VERSION_STR) + "/Profile"; + const QString profKey = key + "/default/"; + + if( settings.entryList( key + "/default" ).count() == 0 ) { + return; + } + + // Override the defaults with settings in registry. + profil->icons.clear(); + profil->indexPages.clear(); + profil->imageDirs.clear(); + profil->docs.clear(); + profil->dcfTitles.clear(); + + QStringList titles = settings.readListEntry( profKey + "Titles" ); + QStringList iconLst = settings.readListEntry( profKey + "DocIcons" ); + QStringList indexLst = settings.readListEntry( profKey + "IndexPages" ); + QStringList imgDirLst = settings.readListEntry( profKey + "ImageDirs" ); + QStringList dcfs = settings.readListEntry( profKey + "DocFiles" ); + + QStringList::ConstIterator it = titles.begin(); + QValueListConstIterator iconIt = iconLst.begin(); + QValueListConstIterator indexIt = indexLst.begin(); + QValueListConstIterator imageIt = imgDirLst.begin(); + QValueListConstIterator dcfIt = dcfs.begin(); + for( ; it != titles.end(); + ++it, ++iconIt, ++indexIt, ++imageIt, ++dcfIt ) + { + profil->addDCFIcon( *it, *iconIt ); + profil->addDCFIndexPage( *it, *indexIt ); + profil->addDCFImageDir( *it, *imageIt ); + profil->addDCFTitle( *dcfIt, *it ); + } +#if ASSISTANT_DEBUG + dumpmap( profil->icons, "Icons" ); + dumpmap( profil->indexPages, "IndexPages" ); + dumpmap( profil->imageDirs, "ImageDirs" ); + dumpmap( profil->dcfTitles, "dcfTitles" ); + qDebug( "Docfiles: \n " + profil->docs.join( "\n " ) ); +#endif +} + +void Config::saveProfile( Profile *profile ) +{ + if (profil && profil->profileType() == Profile::UserProfile) + return; + QSettings settings; + settings.insertSearchPath( QSettings::Windows, "/Trolltech" ); + QString versionString = (profile->props["name"] == "default") + ? QString(QT_VERSION_STR) + : getVersionString(); + const QString key = "/Qt Assistant/" + versionString + "/"; + const QString profKey = key + "Profile/" + profile->props["name"] + "/"; + + QStringList indexes, icons, imgDirs, dcfs; + QValueList titles = profile->dcfTitles.keys(); + QValueListConstIterator it = titles.begin(); + for ( ; it != titles.end(); ++it ) { + indexes << profile->indexPages[*it]; + icons << profile->icons[*it]; + imgDirs << profile->imageDirs[*it]; + dcfs << profile->dcfTitles[*it]; + } + + settings.writeEntry( profKey + "Titles", titles ); + settings.writeEntry( profKey + "DocFiles", dcfs ); + settings.writeEntry( profKey + "IndexPages", indexes ); + settings.writeEntry( profKey + "DocIcons", icons ); + settings.writeEntry( profKey + "ImageDirs", imgDirs ); + +#if ASSISTANT_DEBUG + qDebug( "Titles:\n - " + ( (QStringList*) &titles )->join( "\n - " ) ); + qDebug( "Docfiles:\n - " + dcfs.join( "\n - " ) ); + qDebug( "IndexPages:\n - " + indexes.join( "\n - " ) ); + qDebug( "DocIcons:\n - " + icons.join( "\n - " ) ); + qDebug( "ImageDirs:\n - " + imgDirs.join( "\n - " ) ); +#endif +} + +QStringList Config::mimePaths() +{ + static QStringList lst; + + if( lst.count() > 0 ) + return lst; + + for (QMap::ConstIterator it = profil->dcfTitles.begin(); + it != profil->dcfTitles.end(); ++it ) { + + // Mime source for .dcf file path + QFileInfo info( *it ); + QString dcfPath = info.dirPath(TRUE); + if (lst.contains(dcfPath) == 0) + lst << dcfPath; + + // Image dir for .dcf + QString imgDir = QDir::convertSeparators( dcfPath + QDir::separator() + + profil->imageDirs[it.key()] ); + if (lst.contains(imgDir) == 0) + lst << imgDir; + } + return lst; +} + +QStringList Config::profiles() const +{ + return profileNames; +} + +QString Config::title() const +{ + return profil->props[ "title" ]; +} + +QString Config::aboutApplicationMenuText() const +{ + return profil->props[ "aboutmenutext" ]; +} + +QString Config::aboutURL() const +{ + return profil->props[ "abouturl" ]; +} + +QString Config::homePage() const +{ + return home.isEmpty() ? profil->props["startpage"] : home; +} + +QStringList Config::source() const +{ + return src.size() == 0 ? QStringList(profil->props["startpage"]) : src; +} + +QStringList Config::docFiles() const +{ + return profil->docs; +} + +QPixmap Config::docIcon( const QString &title ) const +{ + // ### To allow qdoc generated dcf files to reference the doc icons from qmake_image_col + if (!QFile::exists(profil->icons[title])) + return QPixmap::fromMimeSource( QFileInfo(profil->icons[title]).fileName() ); + return QPixmap::fromMimeSource( profil->icons[title] ); +} + +QPixmap Config::applicationIcon() const +{ + return QPixmap::fromMimeSource( profil->props["applicationicon"] ); +} + +QStringList Config::docTitles() const +{ + return QStringList(profil->indexPages.keys()); +} + +QString Config::docImageDir( const QString &docfile ) const +{ + return profil->imageDirs[docfile]; +} + +QString Config::indexPage( const QString &title ) const +{ + return profil->indexPages + [title]; +} + +void Config::hideSideBar( bool b ) +{ + hideSidebar = b; +} + +bool Config::sideBarHidden() const +{ + return hideSidebar; +} + +QString Config::assistantDocPath() const +{ + return profil->props["assistantdocs"].isEmpty() + ? QString( qInstallPathDocs() ) + "/html" + : profil->props["assistantdocs"]; +} diff --git a/tools/assistant/config.h b/tools/assistant/config.h new file mode 100644 index 0000000..4a39446 --- /dev/null +++ b/tools/assistant/config.h @@ -0,0 +1,152 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the Qt Assistant. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef CONFIG_H +#define CONFIG_H + +#include "profile.h" + +#include +#include +#include +#include + +class Profile; + +class Config +{ +public: + + Config(); + + void load(); + void save(); + Profile *profile() const { return profil; } + QString profileName() const { return profil->props["name"]; } + bool validProfileName() const; + void hideSideBar( bool b ); + bool sideBarHidden() const; + QStringList mimePaths(); + + // From profile, read only + QStringList docFiles() const; + QStringList docTitles() const; + QString indexPage( const QString &title ) const; + QString docImageDir( const QString &title ) const; + QPixmap docIcon( const QString &title ) const; + + QStringList profiles() const; + QString title() const; + QString aboutApplicationMenuText() const; + QString aboutURL() const; + QPixmap applicationIcon() const; + + // From QSettings, read / write + QString webBrowser() const { return webBrows; } + void setWebBrowser( const QString &cmd ) { webBrows = cmd; } + + QString homePage() const; + void setHomePage( const QString &hom ) { home = hom; } + + QString pdfReader() const { return pdfApp; } + void setPdfReader( const QString &cmd ) { pdfApp = cmd; } + + int fontSize() const { return fontSiz; } + void setFontSize( int size ) { fontSiz = size; } + + QString fontFamily() const { return fontFam; } + void setFontFamily( const QString &fam ) { fontFam = fam; } + + QString fontFixedFamily() const { return fontFix; } + void setFontFixedFamily( const QString &fn ) { fontFix = fn; } + + QString linkColor() const { return linkCol; } + void setLinkColor( const QString &col ) { linkCol = col; } + + QStringList source() const; + void setSource( const QStringList &s ) { src = s; } + + int sideBarPage() const { return sideBar; } + void setSideBarPage( int sbp ) { sideBar = sbp; } + + QRect geometry() const { return geom; } + void setGeometry( const QRect &geo ) { geom = geo; } + + bool isMaximized() const { return maximized; } + void setMaximized( bool max ) { maximized = max; } + + bool isLinkUnderline() const { return linkUnder; } + void setLinkUnderline( bool ul ) { linkUnder = ul; } + + QString mainWindowLayout() const { return mainWinLayout; } + void setMainWindowLayout( const QString &layout ) { mainWinLayout = layout; } + + QString assistantDocPath() const; + + bool docRebuild() const { return rebuildDocs; } + void setDocRebuild( bool rb ) { rebuildDocs = rb; } + + void saveProfile( Profile *profile ); + void loadDefaultProfile(); + + static Config *configuration(); + static Config *loadConfig(const QString &profileFileName); + +private: + Config( const Config &c ); + Config& operator=( const Config &c ); + + void saveSettings(); + +private: + Profile *profil; + + QStringList profileNames; + QString webBrows; + QString home; + QString pdfApp; + QString fontFam; + QString fontFix; + QString linkCol; + QStringList src; + QString mainWinLayout; + QRect geom; + int sideBar; + int fontSiz; + bool maximized; + bool linkUnder; + bool hideSidebar; + bool rebuildDocs; +}; + +#endif diff --git a/tools/assistant/docuparser.cpp b/tools/assistant/docuparser.cpp new file mode 100644 index 0000000..c8f8d70 --- /dev/null +++ b/tools/assistant/docuparser.cpp @@ -0,0 +1,397 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the Qt Assistant. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "docuparser.h" +#include "profile.h" + +#include +#include +#include +#include +#include +#include + +QDataStream &operator>>( QDataStream &s, ContentItem &ci ) +{ + s >> ci.title; + s >> ci.reference; + s >> ci.depth; + return s; +} + +QDataStream &operator<<( QDataStream &s, const ContentItem &ci ) +{ + s << ci.title; + s << ci.reference; + s << ci.depth; + return s; +} + +const QString DocuParser::DocumentKey = "/Qt Assistant/" + QString(QT_VERSION_STR) + "/"; + +DocuParser *DocuParser::createParser( const QString &fileName ) +{ + QFile file( fileName ); + if( !file.open( IO_ReadOnly ) ) { + return 0; + } + + QString str; + int read = 0; + int maxlen = 1024; + int majVer = 0, minVer = 0, serVer = 0; + static QRegExp re( "assistantconfig +version=\"(\\d)\\.(\\d)\\.(\\d)\"", FALSE ); + Q_ASSERT( re.isValid() ); + while( read != -1 ) { + read = file.readLine( str, maxlen ); + if( re.search( str ) >= 0 ) { + majVer = re.cap( 1 ).toInt(); + minVer = re.cap( 2 ).toInt(); + serVer = re.cap( 3 ).toInt(); + } + } + + if( majVer == 3 && minVer >= 2 ) + return new DocuParser320; + + return new DocuParser310; +} + + +bool DocuParser::parse( QFile *file ) +{ + QXmlInputSource source( file ); + QXmlSimpleReader reader; + reader.setContentHandler( this ); + reader.setErrorHandler( this ); + setFileName( QFileInfo( *file ).absFilePath() ); + return reader.parse( source ); +} + + +QString DocuParser::errorProtocol() const +{ + return errorProt; +} + + +QValueList DocuParser::getContentItems() +{ + return contentList; +} + + +QPtrList DocuParser::getIndexItems() +{ + return indexList; +} + +QString DocuParser::absolutify( const QString &name ) const +{ + QFileInfo orgPath( name ); + if( orgPath.isRelative() ) + return QFileInfo( fname ).dirPath() + QDir::separator() + name; + return name; +} + + +void DocuParser310::addTo( Profile *p ) +{ + p->addDCFTitle( fname, docTitle ); + p->addDCFIcon( docTitle, iconName ); + p->addDCFIndexPage( docTitle, conURL ); +} + + +bool DocuParser310::startDocument() +{ + state = StateInit; + errorProt = ""; + + contentRef = ""; + indexRef = ""; + depth = 0; + contentList.clear(); + indexList.clear(); + + return TRUE; +} + + +bool DocuParser310::startElement( const QString &, const QString &, + const QString &qname, + const QXmlAttributes &attr ) +{ + if (qname == "DCF" && state == StateInit) { + state = StateContent; + contentRef = absolutify( attr.value( "ref" ) ); + conURL = contentRef; + docTitle = attr.value( "title" ); + iconName = absolutify( attr.value( "icon" ) ); + contentList.append( ContentItem( docTitle, contentRef, depth ) ); + } else if (qname == "section" && (state == StateContent || state == StateSect)) { + state = StateSect; + contentRef = absolutify( attr.value( "ref" ) ); + title = attr.value( "title" ); + depth++; + contentList.append( ContentItem( title, contentRef, depth ) ); + } else if (qname == "keyword" && state == StateSect) { + state = StateKeyword; + indexRef = absolutify( attr.value( "ref" ) ); + } else + return FALSE; + return TRUE; +} + +bool DocuParser310::endElement( const QString &nameSpace, const QString &localName, + const QString &qName ) +{ + switch( state ) { + case StateInit: + break; + case StateContent: + state = StateInit; + break; + case StateSect: + state = --depth ? StateSect : StateContent; + break; + case StateKeyword: + state = StateSect; + break; + } + return TRUE; +} + + +bool DocuParser310::characters( const QString& ch ) +{ + QString str = ch.simplifyWhiteSpace(); + if ( str.isEmpty() ) + return TRUE; + + switch ( state ) { + case StateInit: + case StateContent: + case StateSect: + return FALSE; + break; + case StateKeyword: + indexList.append( new IndexItem( str, indexRef ) ); + break; + default: + return FALSE; + } + return TRUE; +} + + +bool DocuParser310::fatalError( const QXmlParseException& exception ) +{ + errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" ) + .arg( exception.message() ) + .arg( exception.lineNumber() ) + .arg( exception.columnNumber() ); + + return QXmlDefaultHandler::fatalError( exception ); +} + + +DocuParser320::DocuParser320() + : prof( new Profile ) +{ +} + + +void DocuParser320::addTo( Profile *p ) +{ + QMap::ConstIterator it; + + for (it = prof->dcfTitles.begin(); it != prof->dcfTitles.end(); ++it) + p->dcfTitles[it.key()] = *it; + + for (it = prof->icons.begin(); it != prof->icons.end(); ++it) + p->icons[it.key()] = *it; + + for (it = prof->indexPages.begin(); it != prof->indexPages.end(); ++it) + p->indexPages[it.key()] = *it; +} + + +bool DocuParser320::startDocument() +{ + state = StateInit; + errorProt = ""; + + contentRef = ""; + indexRef = ""; + depth = 0; + contentList.clear(); + indexList.clear(); + + prof->addDCF( fname ); + + return TRUE; +} + +bool DocuParser320::startElement( const QString &, const QString &, + const QString &qname, + const QXmlAttributes &attr ) +{ + QString lower = qname.lower(); + + switch( state ) { + + case StateInit: + if( lower == "assistantconfig" ) + state = StateDocRoot; + break; + + case StateDocRoot: + if( lower == "dcf" ) { + state = StateContent; + contentRef = absolutify( attr.value( "ref" ) ); + conURL = contentRef; + docTitle = attr.value( "title" ); + iconName = absolutify( attr.value( "icon" ) ); + contentList.append( ContentItem( docTitle, contentRef, depth ) ); + } else if( lower == "profile" ) { + state = StateProfile; + } + break; + + case StateSect: + if ( lower == "keyword" && state == StateSect ) { + state = StateKeyword; + indexRef = absolutify( attr.value( "ref" ) ); + break; + } // else if (lower == "section") + case StateContent: + if( lower == "section" ) { + state = StateSect; + contentRef = absolutify( attr.value( "ref" ) ); + title = attr.value( "title" ); + depth++; + contentList.append( ContentItem( title, contentRef, depth ) ); + } + break; + + case StateProfile: + if( lower == "property" ) { + state = StateProperty; + propertyName = attr.value( "name" ); + } + break; + + case StateProperty: + break; + } + + return TRUE; +} + +bool DocuParser320::endElement( const QString &nameSpace, + const QString &localName, + const QString &qName ) +{ + switch( state ) { + case StateInit: + break; + case StateDocRoot: + state = StateInit; + break; + case StateProfile: + state = StateDocRoot; + break; + case StateProperty: + state = StateProfile; + if( propertyName.isEmpty() || propertyValue.isEmpty() ) + return FALSE; + { + static const QStringList lst = QStringList() << "startpage" << "abouturl" + << "applicationicon" << "assistantdocs"; + if (lst.contains(propertyName)) + propertyValue = absolutify( propertyValue ); + } + prof->addProperty( propertyName, propertyValue ); + break; + case StateContent: + if( !iconName.isEmpty() ) prof->addDCFIcon( docTitle, iconName ); + if( contentRef.isEmpty() ) + return FALSE; + prof->addDCFIndexPage( docTitle, conURL ); + prof->addDCFTitle( fname, docTitle ); + state = StateDocRoot; + break; + case StateSect: + state = --depth ? StateSect : StateContent; + break; + case StateKeyword: + state = StateSect; + break; + } + return TRUE; +} + +bool DocuParser320::characters( const QString& ch ) +{ + QString str = ch.simplifyWhiteSpace(); + if ( str.isEmpty() ) + return TRUE; + + switch ( state ) { + case StateInit: + case StateContent: + case StateSect: + return FALSE; + break; + case StateKeyword: + indexList.append( new IndexItem( str, indexRef ) ); + break; + case StateProperty: + propertyValue = ch; + break; + default: + return FALSE; + } + return TRUE; +} + +bool DocuParser320::fatalError( const QXmlParseException& exception ) +{ + errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" ) + .arg( exception.message() ) + .arg( exception.lineNumber() ) + .arg( exception.columnNumber() ); + + return QXmlDefaultHandler::fatalError( exception ); +} diff --git a/tools/assistant/docuparser.h b/tools/assistant/docuparser.h new file mode 100644 index 0000000..747295c --- /dev/null +++ b/tools/assistant/docuparser.h @@ -0,0 +1,151 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the Qt Assistant. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef DOCUPARSER_H +#define DOCUPARSER_H + +#include +#include +#include + +class Profile; + +struct ContentItem { + ContentItem() + : title( QString::null ), reference( QString::null ), depth( 0 ) {} + ContentItem( const QString &t, const QString &r, int d ) + : title( t ), reference( r ), depth( d ) {} + QString title; + QString reference; + int depth; + Q_DUMMY_COMPARISON_OPERATOR(ContentItem) +}; + +QDataStream &operator>>( QDataStream &s, ContentItem &ci ); +QDataStream &operator<<( QDataStream &s, const ContentItem &ci ); + +struct IndexItem { + IndexItem( const QString &k, const QString &r ) + : keyword( k ), reference( r ) {} + QString keyword; + QString reference; +}; + + + +class DocuParser : public QXmlDefaultHandler +{ +public: + enum ParserVersion { Qt310, Qt320 }; + // Since We don't want problems with documentation + // from version to version, this string stores the correct + // version string to save documents. + static const QString DocumentKey; + + static DocuParser *createParser( const QString &fileName ); + + virtual bool parse( QFile *file ); + + QValueList getContentItems(); + QPtrList getIndexItems(); + + QString errorProtocol() const; + QString contentsURL() const { return conURL; } + + virtual ParserVersion parserVersion() const = 0; + virtual void addTo( Profile *p ) = 0; + + QString fileName() const { return fname; } + void setFileName( const QString &file ) { fname = file; } + +protected: + QString absolutify( const QString &input ) const; + + QString contentRef, indexRef, errorProt, conURL; + QString docTitle, title, iconName; + QValueList contentList; + QPtrList indexList; + QString fname; +}; + + +class DocuParser310 : public DocuParser +{ +public: + enum States{ StateInit, StateContent, StateSect, StateKeyword }; + + bool startDocument(); + bool startElement( const QString&, const QString&, const QString& , + const QXmlAttributes& ); + bool endElement( const QString&, const QString&, const QString& ); + bool characters( const QString & ); + bool fatalError( const QXmlParseException& exception ); + + virtual ParserVersion parserVersion() const { return Qt310; } + virtual void addTo( Profile *p ); + +private: + States state; + int depth; +}; + + +class DocuParser320 : public DocuParser +{ +public: + enum States { StateInit, StateDocRoot, StateProfile, StateProperty, + StateContent, StateSect, StateKeyword }; + + DocuParser320(); + + bool startDocument(); + bool startElement( const QString&, const QString&, const QString& , + const QXmlAttributes& ); + bool endElement( const QString&, const QString&, const QString& ); + bool characters( const QString & ); + bool fatalError( const QXmlParseException& exception ); + + virtual ParserVersion parserVersion() const { return Qt320; } + virtual void addTo( Profile *p ); + Profile *profile() const { return prof; } + +private: + + States state; + int depth; + int docfileCounter; + QString propertyValue; + QString propertyName; + Profile *prof; +}; +#endif //DOCUPARSER_H diff --git a/tools/assistant/finddialog.ui b/tools/assistant/finddialog.ui new file mode 100644 index 0000000..35f6540 --- /dev/null +++ b/tools/assistant/finddialog.ui @@ -0,0 +1,286 @@ + +FindDialog +********************************************************************* +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of Qt Assistant. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +********************************************************************* + + + FindDialog + + + + 0 + 0 + 362 + 156 + + + + Qt Assistant - Find Text + + + + unnamed + + + 0 + + + + Layout5 + + + + unnamed + + + 11 + + + + ButtonGroup2 + + + &Direction + + + + unnamed + + + 11 + + + 6 + + + + radioForward + + + Fo&rward + + + true + + + + + radioBackward + + + &Backward + + + + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + TextLabel1 + + + F&ind: + + + comboFind + + + + + comboFind + + + + 7 + 0 + 0 + 0 + + + + true + + + false + + + + + + + Spacer2 + + + Vertical + + + Expanding + + + + 31 + 0 + + + + + + PushButton2 + + + C&lose + + + Alt+L + + + + + ButtonGroup1 + + + &Options + + + + unnamed + + + 11 + + + 6 + + + + checkWords + + + &Whole words only + + + + + checkCase + + + &Case sensitive + + + + + + + PushButton1 + + + &Find + + + Alt+F + + + true + + + + + + + + + PushButton1 + clicked() + FindDialog + doFind() + + + PushButton2 + clicked() + FindDialog + reject() + + + + comboFind + checkWords + checkCase + radioForward + radioBackward + PushButton1 + PushButton2 + + + qstatusbar.h + qtextbrowser.h + mainwindow.h + tabbedbrowser.h + finddialog.ui.h + + + class QTextBrowser; + class QStatusBar; + class MainWindow; + + + QStatusBar *sb; + bool onceFound; + QString findExpr; + QTextBrowser *lastBrowser; + + + init() + destroy() + doFind() + doFind(bool) + statusMessage(const QString &message) + + + mainWindow() + hasFindExpression() + + + diff --git a/tools/assistant/finddialog.ui.h b/tools/assistant/finddialog.ui.h new file mode 100644 index 0000000..d4ca133 --- /dev/null +++ b/tools/assistant/finddialog.ui.h @@ -0,0 +1,108 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the Qt Assistant. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include + +void FindDialog::init() +{ + lastBrowser = 0; + onceFound = FALSE; + findExpr = ""; + sb = new QStatusBar( this ); + FindDialogLayout->addWidget( sb ); + sb->message( tr( "Enter the text you are looking for." ) ); +} + +void FindDialog::destroy() +{ +} + +void FindDialog::doFind() +{ + doFind(radioForward->isChecked()); +} + +void FindDialog::doFind(bool forward) +{ + QTextBrowser *browser = (QTextBrowser*) mainWindow()->browsers()->currentBrowser(); + sb->clear(); + + if (comboFind->currentText() != findExpr || lastBrowser != browser) + onceFound = false; + findExpr = comboFind->currentText(); + + bool found; + if (browser->hasSelectedText()) { // Search either forward or backward from cursor. + found = browser->find(findExpr, checkCase->isChecked(), checkWords->isChecked(), + forward); + } else { + int para = forward ? 0 : INT_MAX; + int index = forward ? 0 : INT_MAX; + found = browser->find(findExpr, checkCase->isChecked(), checkWords->isChecked(), + forward, ¶, &index); + } + + if (!found) { + if (onceFound) { + if (forward) + statusMessage(tr("Search reached end of the document")); + else + statusMessage(tr("Search reached start of the document")); + } else { + statusMessage(tr( "Text not found" )); + } + } + onceFound |= found; + lastBrowser = browser; +} + + + +MainWindow* FindDialog::mainWindow() +{ + return (MainWindow*) parent(); +} + +bool FindDialog::hasFindExpression() +{ + return !findExpr.isEmpty(); +} + +void FindDialog::statusMessage(const QString &message) +{ + if (isVisible()) + sb->message(message); + else + ((MainWindow*) parent())->statusBar()->message(message, 2000); + +} diff --git a/tools/assistant/helpdialog.ui b/tools/assistant/helpdialog.ui new file mode 100644 index 0000000..cb8865d --- /dev/null +++ b/tools/assistant/helpdialog.ui @@ -0,0 +1,506 @@ + +HelpDialogBase +********************************************************************* +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of Qt Assistant. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +********************************************************************* + + + HelpDialogBase + + + + 0 + 0 + 268 + 448 + + + + Help + + + <b>Help</b><p>Choose the topic you want help on from the contents list, or search the index for keywords.</p> + + + + unnamed + + + 0 + + + 6 + + + + tabWidget + + + Displays help topics organized by category, index or bookmarks. Another tab inherits the full text search. + + + + contentPage + + + Con&tents + + + + unnamed + + + 5 + + + 6 + + + + + Column 1 + + + true + + + true + + + + listContents + + + true + + + <b>Help topics organized by category.</b><p>Double-click an item to see the topics in that category. To view a topic, just double-click it.</p> + + + + + + + Widget8 + + + &Index + + + + unnamed + + + 5 + + + 6 + + + + TextLabel1 + + + &Look For: + + + editIndex + + + + + editIndex + + + Enter keyword + + + <b>Enter a keyword.</b><p>The list will select an item that matches the entered string best.</p> + + + + + listIndex + + + <b>List of available help topics.</b><p>Double-click on an item to open its help page. If more than one is found, you must specify which page you want.</p> + + + + + + + Widget9 + + + &Bookmarks + + + + unnamed + + + 5 + + + 6 + + + + + Column 1 + + + true + + + true + + + + listBookmarks + + + Displays the list of bookmarks. + + + + + Layout3 + + + + unnamed + + + 0 + + + 6 + + + + Spacer1 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + buttonAdd + + + &New + + + Add new bookmark + + + Add the currently displayed page as a new bookmark. + + + + + buttonRemove + + + &Delete + + + Delete bookmark + + + Delete the selected bookmark. + + + + + + + + + searchTab + + + &Search + + + + unnamed + + + 5 + + + 6 + + + + Spacer3 + + + Vertical + + + Fixed + + + + 20 + 20 + + + + + + TextLabel1_2 + + + Searching f&or: + + + termsEdit + + + + + termsEdit + + + Enter searchword(s). + + + <b>Enter search word(s).</b><p>Enter here the word(s) you are looking for. The words may contain wildcards (*). For a sequence of words quote them.</p> + + + + + resultBox + + + <b>Found documents</b><p>This list contains all found documents from the last search. The documents are ordered, i.e. the first document has the most matches.</p> + + + + + TextLabel2 + + + Found &Documents: + + + resultBox + + + + + Layout2 + + + + unnamed + + + + helpButton + + + He&lp + + + Display the help page. + + + Display the help page for the full text search. + + + + + Spacer2 + + + Horizontal + + + Expanding + + + + 61 + 21 + + + + + + searchButton + + + &Search + + + Start searching. + + + Pressing this button starts the search. + + + + + + + + + + framePrepare + + + StyledPanel + + + Raised + + + + unnamed + + + 3 + + + 6 + + + + labelPrepare + + + Preparing... + + + + + progressPrepare + + + + + + + + + buttonAdd + clicked() + HelpDialogBase + addBookmark() + + + buttonRemove + clicked() + HelpDialogBase + removeBookmark() + + + termsEdit + returnPressed() + searchButton + animateClick() + + + helpButton + clicked() + HelpDialogBase + showSearchHelp() + + + searchButton + clicked() + HelpDialogBase + startSearch() + + + resultBox + returnPressed(QListBoxItem*) + HelpDialogBase + showResultPage(QListBoxItem*) + + + resultBox + mouseButtonClicked(int, QListBoxItem*, const QPoint &) + HelpDialogBase + showResultPage(int, QListBoxItem*, const QPoint & ) + + + + tabWidget + listContents + editIndex + listIndex + listBookmarks + buttonAdd + buttonRemove + termsEdit + searchButton + helpButton + resultBox + + + init() + destroy() + addBookmark() + currentBookmarkChanged( QListViewItem * ) + currentIndexChanged( QListBoxItem * ) + currentTabChanged( const QString & ) + loadIndexFile() + currentContentsChanged( QListViewItem * ) + removeBookmark() + searchInIndex( const QString & ) + showTopic() + showTopic( int, QListBoxItem *, const QPoint & ) + showSearchHelp() + startSearch() + showResultPage( QListBoxItem * ) + showResultPage( int, QListBoxItem *, const QPoint & ) + showResultPage( int, QListViewItem *, const QPoint & ) + + + diff --git a/tools/assistant/helpdialogimpl.cpp b/tools/assistant/helpdialogimpl.cpp new file mode 100644 index 0000000..ceee175 --- /dev/null +++ b/tools/assistant/helpdialogimpl.cpp @@ -0,0 +1,1161 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of Qt Assistant. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "helpdialogimpl.h" +#include "helpwindow.h" +#include "topicchooserimpl.h" +#include "docuparser.h" +#include "mainwindow.h" +#include "config.h" +#include "tabbedbrowser.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +static QString stripAmpersand( const QString &str ) +{ + QString s( str ); + s = s.replace( '&', "" ); + return s; +} + +static bool verifyDirectory(const QString &str) +{ + QFileInfo dirInfo(str); + if (!dirInfo.exists()) + return QDir().mkdir(str); + if (!dirInfo.isDir()) { + qWarning("'%s' exists but is not a directory", str.latin1()); + return FALSE; + } + return TRUE; +} + +struct IndexKeyword { + IndexKeyword( const QString &kw, const QString &l ) + : keyword( kw ), link( l ) {} + IndexKeyword() : keyword( QString::null ), link( QString::null ) {} + bool operator<( const IndexKeyword &ik ) const { + return keyword.lower() < ik.keyword.lower(); + } + bool operator<=( const IndexKeyword &ik ) const { + return keyword.lower() <= ik.keyword.lower(); + } + bool operator>( const IndexKeyword &ik ) const { + return keyword.lower() > ik.keyword.lower(); + } + Q_DUMMY_COMPARISON_OPERATOR( IndexKeyword ) + QString keyword; + QString link; +}; + +QDataStream &operator>>( QDataStream &s, IndexKeyword &ik ) +{ + s >> ik.keyword; + s >> ik.link; + return s; +} + +QDataStream &operator<<( QDataStream &s, const IndexKeyword &ik ) +{ + s << ik.keyword; + s << ik.link; + return s; +} + +QValidator::State SearchValidator::validate( QString &str, int & ) const +{ + for ( int i = 0; i < (int) str.length(); ++i ) { + QChar c = str[i]; + if ( !c.isLetterOrNumber() && c != '\'' && c != '`' + && c != '\"' && c != ' ' && c != '-' && c != '_' + && c!= '*' ) + return QValidator::Invalid; + } + return QValidator::Acceptable; +} + +HelpNavigationListItem::HelpNavigationListItem( QListBox *ls, const QString &txt ) + : QListBoxText( ls, txt ) +{ +} + +void HelpNavigationListItem::addLink( const QString &link ) +{ + int hash = link.find( '#' ); + if ( hash == -1 ) { + linkList << link; + return; + } + + QString preHash = link.left( hash ); + if ( linkList.grep( preHash, FALSE ).count() > 0 ) + return; + linkList << link; +} + +HelpNavigationContentsItem::HelpNavigationContentsItem( QListView *v, QListViewItem *after ) + : QListViewItem( v, after ) +{ +} + +HelpNavigationContentsItem::HelpNavigationContentsItem( QListViewItem *v, QListViewItem *after ) + : QListViewItem( v, after ) +{ +} + +void HelpNavigationContentsItem::setLink( const QString &lnk ) +{ + theLink = lnk; +} + +QString HelpNavigationContentsItem::link() const +{ + return theLink; +} + + + +HelpDialog::HelpDialog( QWidget *parent, MainWindow *h ) + : HelpDialogBase( parent, 0, FALSE ), lwClosed( FALSE ), help( h ) +{ +} + +void HelpDialog::initialize() +{ + connect( tabWidget, SIGNAL( selected(const QString&) ), + this, SLOT( currentTabChanged(const QString&) ) ); + connect( listContents, SIGNAL( mouseButtonClicked(int, QListViewItem*, const QPoint &, int ) ), + this, SLOT( showTopic(int,QListViewItem*, const QPoint &) ) ); + connect( listContents, SIGNAL( currentChanged(QListViewItem*) ), + this, SLOT( currentContentsChanged(QListViewItem*) ) ); + connect( listContents, SIGNAL( selectionChanged(QListViewItem*) ), + this, SLOT( currentContentsChanged(QListViewItem*) ) ); + connect( listContents, SIGNAL( doubleClicked(QListViewItem*) ), + this, SLOT( showTopic(QListViewItem*) ) ); + connect( listContents, SIGNAL( returnPressed(QListViewItem*) ), + this, SLOT( showTopic(QListViewItem*) ) ); + connect( listContents, SIGNAL( contextMenuRequested( QListViewItem*, const QPoint&, int ) ), + this, SLOT( showItemMenu( QListViewItem*, const QPoint& ) ) ); + connect( editIndex, SIGNAL( returnPressed() ), + this, SLOT( showTopic() ) ); + connect( editIndex, SIGNAL( textChanged(const QString&) ), + this, SLOT( searchInIndex(const QString&) ) ); + + connect( listIndex, SIGNAL( selectionChanged(QListBoxItem*) ), + this, SLOT( currentIndexChanged(QListBoxItem*) ) ); + connect( listIndex, SIGNAL( returnPressed(QListBoxItem*) ), + this, SLOT( showTopic() ) ); + connect( listIndex, SIGNAL( mouseButtonClicked(int, QListBoxItem*, const QPoint &) ), + this, SLOT( showTopic( int, QListBoxItem *, const QPoint & ) ) ); + connect( listIndex, SIGNAL( currentChanged(QListBoxItem*) ), + this, SLOT( currentIndexChanged(QListBoxItem*) ) ); + connect( listIndex, SIGNAL( contextMenuRequested( QListBoxItem*, const QPoint& ) ), + this, SLOT( showItemMenu( QListBoxItem*, const QPoint& ) ) ); + + connect( listBookmarks, SIGNAL( mouseButtonClicked(int, QListViewItem*, const QPoint&, int ) ), + this, SLOT( showTopic(int, QListViewItem*, const QPoint &) ) ); + connect( listBookmarks, SIGNAL( returnPressed(QListViewItem*) ), + this, SLOT( showTopic(QListViewItem*) ) ); + connect( listBookmarks, SIGNAL( selectionChanged(QListViewItem*) ), + this, SLOT( currentBookmarkChanged(QListViewItem*) ) ); + connect( listBookmarks, SIGNAL( currentChanged(QListViewItem*) ), + this, SLOT( currentBookmarkChanged(QListViewItem*) ) ); + connect( listBookmarks, SIGNAL( contextMenuRequested( QListViewItem*, const QPoint&, int ) ), + this, SLOT( showItemMenu( QListViewItem*, const QPoint& ) ) ); + connect( resultBox, SIGNAL( contextMenuRequested( QListBoxItem*, const QPoint& ) ), + this, SLOT( showItemMenu( QListBoxItem*, const QPoint& ) ) ); + + cacheFilesPath = QDir::homeDirPath() + "/.assistant/"; //### Find a better location for the dbs + + editIndex->installEventFilter( this ); + listBookmarks->header()->hide(); + listBookmarks->header()->setStretchEnabled( TRUE ); + listContents->header()->hide(); + listContents->header()->setStretchEnabled( TRUE ); + framePrepare->hide(); + connect( qApp, SIGNAL(lastWindowClosed()), SLOT(lastWinClosed()) ); + + termsEdit->setValidator( new SearchValidator( termsEdit ) ); + + itemPopup = new QPopupMenu( this ); + itemPopup->insertItem( tr( "Open Link in Current Tab" ), 0 ); + itemPopup->insertItem( tr( "Open Link in New Window" ), 1 ); + itemPopup->insertItem( tr( "Open Link in New Tab" ), 2 ); + + contentList.setAutoDelete( TRUE ); + contentList.clear(); + + initDoneMsgShown = FALSE; + fullTextIndex = 0; + indexDone = FALSE; + titleMapDone = FALSE; + contentsInserted = FALSE; + bookmarksInserted = FALSE; + setupTitleMap(); +} + + +void HelpDialog::processEvents() +{ + qApp->eventLoop()->processEvents( QEventLoop::ExcludeUserInput ); +} + + +void HelpDialog::lastWinClosed() +{ + lwClosed = TRUE; +} + + +void HelpDialog::removeOldCacheFiles() +{ + QString dir = cacheFilesPath; // ### remove the last '/' ? + if (!verifyDirectory(cacheFilesPath)) { + qWarning( "Failed to created assistant directory" ); + return; + } + QString pname = "." + Config::configuration()->profileName(); + + QStringList fileList; + fileList << "indexdb" << "indexdb.dict" << "indexdb.doc" << "contentdb"; + QStringList::iterator it = fileList.begin(); + for ( ; it != fileList.end(); ++it ) { + if ( QFile::exists( cacheFilesPath + *it + pname ) ) { + QFile f( cacheFilesPath + *it + pname ); + f.remove(); + } + } +} + +void HelpDialog::timerEvent(QTimerEvent *e) +{ + static int opacity = 255; + // To allow patching of 3.2.3 assistant for qsa. +#if QT_VERSION >= 0x030300 + help->setWindowOpacity((opacity-=4)/255.0); + if (opacity<=0) +#endif + qApp->quit(); +} + + +void HelpDialog::loadIndexFile() +{ + if ( indexDone ) + return; + + setCursor( waitCursor ); + indexDone = TRUE; + labelPrepare->setText( tr( "Prepare..." ) ); + framePrepare->show(); + processEvents(); + + QProgressBar *bar = progressPrepare; + bar->setTotalSteps( 100 ); + bar->setProgress( 0 ); + + keywordDocuments.clear(); + QValueList lst; + QFile indexFile( cacheFilesPath + "indexdb." + + Config::configuration()->profileName() ); + if ( !indexFile.open( IO_ReadOnly ) ) { + buildKeywordDB(); + processEvents(); + if( lwClosed ) + return; + if (!indexFile.open(IO_ReadOnly)) { + QMessageBox::warning(help, tr("Qt Assistant"), tr("Failed to load keyword index file\n" + "Assistant will not work!")); +#if defined Q_WS_WIN || defined Q_WS_MACX + startTimer(50); +#endif + return; + } + } + + editIndex->setEnabled(FALSE); + + QDataStream ds( &indexFile ); + Q_UINT32 fileAges; + ds >> fileAges; + if ( fileAges != getFileAges() ) { + indexFile.close(); + buildKeywordDB(); + if ( !indexFile.open( IO_ReadOnly ) ) { + QMessageBox::warning( help, tr( "Qt Assistant" ), + tr( "Cannot open the index file %1" ).arg( QFileInfo( indexFile ).absFilePath() ) ); + editIndex->setEnabled(TRUE); + return; + } + ds.setDevice( &indexFile ); + ds >> fileAges; + } + ds >> lst; + indexFile.close(); + + bar->setProgress( bar->totalSteps() ); + processEvents(); + + listIndex->clear(); + HelpNavigationListItem *lastItem = 0; + QString lastKeyword = QString::null; + QValueList::ConstIterator it = lst.begin(); + for ( ; it != lst.end(); ++it ) { + if ( lastKeyword.lower() != (*it).keyword.lower() ) + lastItem = new HelpNavigationListItem( listIndex, (*it).keyword ); + lastItem->addLink( (*it).link ); + lastKeyword = (*it).keyword; + + QString lnk = (*it).link; + int i = lnk.findRev('#'); + if ( i > -1 ) + lnk = lnk.left( i ); + if (!keywordDocuments.contains(lnk)) + keywordDocuments.append(lnk); + } + framePrepare->hide(); + showInitDoneMessage(); + setCursor( arrowCursor ); + editIndex->setEnabled(TRUE); +} + +Q_UINT32 HelpDialog::getFileAges() +{ + QStringList addDocuFiles = Config::configuration()->docFiles(); + QStringList::const_iterator i = addDocuFiles.begin(); + + Q_UINT32 fileAges = 0; + for( ; i != addDocuFiles.end(); ++i ) { + QFileInfo fi( *i ); + if ( fi.exists() ) + fileAges += fi.lastModified().toTime_t(); + } + + return fileAges; +} + +void HelpDialog::buildKeywordDB() +{ + QStringList addDocuFiles = Config::configuration()->docFiles(); + QStringList::iterator i = addDocuFiles.begin(); + + int steps = 0; + for( ; i != addDocuFiles.end(); i++ ) + steps += QFileInfo( *i ).size(); + + labelPrepare->setText( tr( "Prepare..." ) ); + progressPrepare->setTotalSteps( steps ); + progressPrepare->setProgress( 0 ); + processEvents(); + + QValueList lst; + Q_UINT32 fileAges = 0; + for( i = addDocuFiles.begin(); i != addDocuFiles.end(); i++ ){ + QFile file( *i ); + if ( !file.exists() ) { + QMessageBox::warning( this, tr( "Warning" ), + tr( "Documentation file %1 does not exist!\n" + "Skipping file." ).arg( QFileInfo( file ).absFilePath() ) ); + continue; + } + fileAges += QFileInfo( file ).lastModified().toTime_t(); + DocuParser *handler = DocuParser::createParser( *i ); + bool ok = handler->parse( &file ); + file.close(); + if( !ok ){ + QString msg = QString( "In file %1:\n%2" ) + .arg( QFileInfo( file ).absFilePath() ) + .arg( handler->errorProtocol() ); + QMessageBox::critical( this, tr( "Parse Error" ), tr( msg ) ); + delete handler; + continue; + } + + QPtrList indLst = handler->getIndexItems(); + QPtrListIterator it( indLst ); + IndexItem *indItem; + int counter = 0; + while ( ( indItem = it.current() ) != 0 ) { + QFileInfo fi( indItem->reference ); + lst.append( IndexKeyword( indItem->keyword, fi.absFilePath() ) ); + if ( progressPrepare ) + progressPrepare->setProgress( progressPrepare->progress() + + int(fi.absFilePath().length() * 1.6) ); + + if( ++counter%100 == 0 ) { + processEvents(); + if( lwClosed ) { + return; + } + } + ++it; + } + delete handler; + } + if ( !lst.isEmpty() ) + qHeapSort( lst ); + + QFile indexout( cacheFilesPath + "indexdb." + Config::configuration()->profileName() ); + if ( verifyDirectory(cacheFilesPath) && indexout.open( IO_WriteOnly ) ) { + QDataStream s( &indexout ); + s << fileAges; + s << lst; + indexout.close(); + } +} + +void HelpDialog::setupTitleMap() +{ + if ( titleMapDone ) + return; + if ( Config::configuration()->docRebuild() ) { + removeOldCacheFiles(); + Config::configuration()->setDocRebuild( FALSE ); + Config::configuration()->saveProfile( Config::configuration()->profile() ); + } + if ( contentList.isEmpty() ) + getAllContents(); + + titleMapDone = TRUE; + titleMap.clear(); + QDictIterator lstIt( contentList ); + for ( ; lstIt.current(); ++lstIt ) { + QValueList &lst = *(lstIt.current()); + QValueListConstIterator it; + for ( it = lst.begin(); it != lst.end(); ++it ) { + QFileInfo link( (*it).reference.simplifyWhiteSpace() ); + titleMap[ link.absFilePath() ] = (*it).title.stripWhiteSpace(); + } + } + processEvents(); +} + +void HelpDialog::getAllContents() +{ + QFile contentFile( cacheFilesPath + "contentdb." + Config::configuration()->profileName() ); + contentList.clear(); + if ( !contentFile.open( IO_ReadOnly ) ) { + buildContentDict(); + return; + } + + QDataStream ds( &contentFile ); + Q_UINT32 fileAges; + ds >> fileAges; + if ( fileAges != getFileAges() ) { + contentFile.close(); + buildContentDict(); + return; + } + QString key; + QValueList lst; + while ( !ds.atEnd() ) { + ds >> key; + ds >> lst; + contentList.insert( key, new QValueList( lst ) ); + } + contentFile.close(); + processEvents(); + +} + +void HelpDialog::buildContentDict() +{ + QStringList docuFiles = Config::configuration()->docFiles(); + + Q_UINT32 fileAges = 0; + for( QStringList::iterator it = docuFiles.begin(); it != docuFiles.end(); it++ ) { + QFile file( *it ); + if ( !file.exists() ) { + QMessageBox::warning( this, tr( "Warning" ), + tr( "Documentation file %1 does not exist!\n" + "Skipping file." ).arg( QFileInfo( file ).absFilePath() ) ); + continue; + } + fileAges += QFileInfo( file ).lastModified().toTime_t(); + DocuParser *handler = DocuParser::createParser( *it ); + if( !handler ) { + QMessageBox::warning( this, tr( "Warning" ), + tr( "Documentation file %1 is not compatible!\n" + "Skipping file." ).arg( QFileInfo( file ).absFilePath() ) ); + continue; + } + bool ok = handler->parse( &file ); + file.close(); + if( ok ) { + contentList.insert( *it, new QValueList( handler->getContentItems() ) ); + delete handler; + } else { + QString msg = QString( "In file %1:\n%2" ) + .arg( QFileInfo( file ).absFilePath() ) + .arg( handler->errorProtocol() ); + QMessageBox::critical( this, tr( "Parse Error" ), tr( msg ) ); + continue; + } + } + + QString pname = Config::configuration()->profileName(); + QFile contentOut( cacheFilesPath + "contentdb." + pname ); + QFile::remove( cacheFilesPath + "indexdb.dict." + pname ); + QFile::remove( cacheFilesPath + "indexdb.doc." + pname ); + if ( contentOut.open( IO_WriteOnly ) ) { + QDataStream s( &contentOut ); + s << fileAges; + QDictIterator it( contentList ); + for ( ; it.current(); ++it ) { + s << it.currentKey(); + s << *(it.current()); + } + contentOut.close(); + } +} + +void HelpDialog::currentTabChanged( const QString &s ) +{ + if ( stripAmpersand( s ).contains( tr( "Index" ) ) ) + QTimer::singleShot( 0, this, SLOT( loadIndexFile() ) ); + else if ( stripAmpersand( s ).contains( tr( "Bookmarks" ) ) ) + insertBookmarks(); + else if ( stripAmpersand( s ).contains( tr( "Contents" ) ) ) + QTimer::singleShot( 0, this, SLOT( insertContents() ) ); + else if ( stripAmpersand( s ).contains( tr( "Search" ) ) ) + QTimer::singleShot( 0, this, SLOT( setupFullTextIndex() ) ); +} + +void HelpDialog::showInitDoneMessage() +{ + if ( initDoneMsgShown ) + return; + initDoneMsgShown = TRUE; + help->statusBar()->message( tr( "Done" ), 3000 ); +} + +void HelpDialog::currentIndexChanged( QListBoxItem * ) +{ +} + + +void HelpDialog::showTopic( int button, QListBoxItem *item, + const QPoint & ) +{ + if( button == LeftButton && item ) + showTopic(); +} + +void HelpDialog::showTopic( int button, QListViewItem *item, + const QPoint & ) +{ + if( button == LeftButton && item ) + showTopic(); +} + +void HelpDialog::showTopic( QListViewItem *item ) +{ + if( item ) + showTopic(); +} + +void HelpDialog::showTopic() +{ + if ( stripAmpersand( tabWidget->tabLabel( tabWidget->currentPage() ) ).contains( tr( "Index" ) ) ) + showIndexTopic(); + else if ( stripAmpersand( tabWidget->tabLabel( tabWidget->currentPage() ) ).contains( tr( "Bookmarks" ) ) ) + showBookmarkTopic(); + else if ( stripAmpersand( tabWidget->tabLabel( tabWidget->currentPage() ) ).contains( tr( "Contents" ) ) ) + showContentsTopic(); +} + +void HelpDialog::showIndexTopic() +{ + QListBoxItem *i = listIndex->item( listIndex->currentItem() ); + if ( !i ) + return; + + editIndex->blockSignals( TRUE ); + editIndex->setText( i->text() ); + editIndex->blockSignals( FALSE ); + + HelpNavigationListItem *item = (HelpNavigationListItem*)i; + + QStringList links = item->links(); + if ( links.count() == 1 ) { + emit showLink( links.first() ); + } else { + qHeapSort( links ); + QStringList::Iterator it = links.begin(); + QStringList linkList; + QStringList linkNames; + for ( ; it != links.end(); ++it ) { + linkList << *it; + linkNames << titleOfLink( *it ); + } + QString link = TopicChooser::getLink( this, linkNames, linkList, i->text() ); + if ( !link.isEmpty() ) + emit showLink( link ); + } +} + +void HelpDialog::searchInIndex( const QString &s ) +{ + QListBoxItem *i = listIndex->firstItem(); + QString sl = s.lower(); + while ( i ) { + QString t = i->text(); + if ( t.length() >= sl.length() && + i->text().left(s.length()).lower() == sl ) { + listIndex->setCurrentItem( i ); + listIndex->setTopItem(listIndex->index(i)); + break; + } + i = i->next(); + } +} + +QString HelpDialog::titleOfLink( const QString &link ) +{ + QString s( link ); + s.remove( s.find( '#' ), s.length() ); + s = titleMap[ s ]; + if ( s.isEmpty() ) + return link; + return s; +} + +bool HelpDialog::eventFilter( QObject * o, QEvent * e ) +{ + if ( !o || !e ) + return TRUE; + + if ( o == editIndex && e->type() == QEvent::KeyPress ) { + QKeyEvent *ke = (QKeyEvent*)e; + if ( ke->key() == Key_Up ) { + int i = listIndex->currentItem(); + if ( --i >= 0 ) { + listIndex->setCurrentItem( i ); + editIndex->blockSignals( TRUE ); + editIndex->setText( listIndex->currentText() ); + editIndex->blockSignals( FALSE ); + } + return TRUE; + } else if ( ke->key() == Key_Down ) { + int i = listIndex->currentItem(); + if ( ++i < int(listIndex->count()) ) { + listIndex->setCurrentItem( i ); + editIndex->blockSignals( TRUE ); + editIndex->setText( listIndex->currentText() ); + editIndex->blockSignals( FALSE ); + } + return TRUE; + } else if ( ke->key() == Key_Next || ke->key() == Key_Prior ) { + QApplication::sendEvent( listIndex, e); + editIndex->blockSignals( TRUE ); + editIndex->setText( listIndex->currentText() ); + editIndex->blockSignals( FALSE ); + } + } + + return QWidget::eventFilter( o, e ); +} + +void HelpDialog::addBookmark() +{ + if ( !bookmarksInserted ) + insertBookmarks(); + QString link = QUrl( help->browsers()->currentBrowser()->context(), + help->browsers()->currentBrowser()->source() ).path(); + QString title = help->browsers()->currentBrowser()->documentTitle(); + if ( title.isEmpty() ) + title = titleOfLink( link ); + HelpNavigationContentsItem *i = new HelpNavigationContentsItem( listBookmarks, 0 ); + i->setText( 0, title ); + i->setLink( link ); + saveBookmarks(); + help->updateBookmarkMenu(); +} + +void HelpDialog::removeBookmark() +{ + if ( !listBookmarks->currentItem() ) + return; + + delete listBookmarks->currentItem(); + saveBookmarks(); + if ( listBookmarks->firstChild() ) { + listBookmarks->setSelected( listBookmarks->firstChild(), TRUE ); + } + help->updateBookmarkMenu(); +} + +void HelpDialog::insertBookmarks() +{ + if ( bookmarksInserted ) + return; + bookmarksInserted = TRUE; + listBookmarks->clear(); + QFile f( cacheFilesPath + "bookmarks." + Config::configuration()->profileName() ); + if ( !f.open( IO_ReadOnly ) ) + return; + QTextStream ts( &f ); + while ( !ts.atEnd() ) { + HelpNavigationContentsItem *i = new HelpNavigationContentsItem( listBookmarks, 0 ); + i->setText( 0, ts.readLine() ); + i->setLink( ts.readLine() ); + } + help->updateBookmarkMenu(); + showInitDoneMessage(); +} + +void HelpDialog::currentBookmarkChanged( QListViewItem * ) +{ +} + +void HelpDialog::showBookmarkTopic() +{ + if ( !listBookmarks->currentItem() ) + return; + + HelpNavigationContentsItem *i = (HelpNavigationContentsItem*)listBookmarks->currentItem(); + QString absPath = ""; + if ( QFileInfo( i->link() ).isRelative() ) + absPath = documentationPath + "/"; + emit showLink( absPath + i->link() ); +} + +void HelpDialog::saveBookmarks() +{ + QFile f( cacheFilesPath + "bookmarks." + Config::configuration()->profileName() ); + if ( !f.open( IO_WriteOnly ) ) + return; + QTextStream ts( &f ); + QListViewItemIterator it( listBookmarks ); + for ( ; it.current(); ++it ) { + HelpNavigationContentsItem *i = (HelpNavigationContentsItem*)it.current(); + ts << i->text( 0 ) << endl; + ts << i->link() << endl; + } + f.close(); +} + +void HelpDialog::insertContents() +{ + if ( contentsInserted ) + return; + + if ( contentList.isEmpty() ) + getAllContents(); + + contentsInserted = TRUE; + listContents->clear(); + setCursor( waitCursor ); + if ( !titleMapDone ) + setupTitleMap(); + + listContents->setSorting( -1 ); + + QDictIterator lstIt( contentList ); + for ( ; lstIt.current(); ++lstIt ) { + HelpNavigationContentsItem *newEntry; + + HelpNavigationContentsItem *contentEntry = 0; + QPtrStack stack; + stack.clear(); + int depth = 0; + bool root = FALSE; + + HelpNavigationContentsItem *lastItem[64]; + for( int j = 0; j < 64; ++j ) + lastItem[j] = 0; + + + QValueList &lst = *(lstIt.current()); + QValueListConstIterator it; + for( it = lst.begin(); it != lst.end(); ++it ){ + ContentItem item = *it; + if( item.depth == 0 ){ + newEntry = new HelpNavigationContentsItem( listContents, 0 ); + newEntry->setPixmap( 0, QPixmap::fromMimeSource( "book.png" ) ); + newEntry->setText( 0, item.title ); + newEntry->setLink( item.reference ); + stack.push( newEntry ); + depth = 1; + root = TRUE; + } + else{ + if( (item.depth > depth) && root ) { + depth = item.depth; + stack.push( contentEntry ); + } + if( item.depth == depth ) { + contentEntry = new HelpNavigationContentsItem( stack.top(), lastItem[ depth ] ); + lastItem[ depth ] = contentEntry; + contentEntry->setText( 0, item.title ); + contentEntry->setLink( item.reference ); + } + else if( item.depth < depth ) { + stack.pop(); + depth--; + item = *(--it); + } + } + } + processEvents(); + } + setCursor( arrowCursor ); + showInitDoneMessage(); +} + +void HelpDialog::currentContentsChanged( QListViewItem * ) +{ +} + +void HelpDialog::showContentsTopic() +{ + HelpNavigationContentsItem *i = (HelpNavigationContentsItem*)listContents->currentItem(); + if ( !i ) + return; + emit showLink( i->link() ); +} + +void HelpDialog::toggleContents() +{ + if ( !isVisible() || tabWidget->currentPageIndex() != 0 ) { + tabWidget->setCurrentPage( 0 ); + parentWidget()->show(); + } + else + parentWidget()->hide(); +} + +void HelpDialog::toggleIndex() +{ + if ( !isVisible() || tabWidget->currentPageIndex() != 1 || !editIndex->hasFocus() ) { + tabWidget->setCurrentPage( 1 ); + parentWidget()->show(); + editIndex->setFocus(); + } + else + parentWidget()->hide(); +} + +void HelpDialog::toggleBookmarks() +{ + if ( !isVisible() || tabWidget->currentPageIndex() != 2 ) { + tabWidget->setCurrentPage( 2 ); + parentWidget()->show(); + } + else + parentWidget()->hide(); +} + +void HelpDialog::toggleSearch() +{ + if ( !isVisible() || tabWidget->currentPageIndex() != 3 ) { + tabWidget->setCurrentPage( 3 ); + parentWidget()->show(); + } + else + parentWidget()->hide(); +} + +void HelpDialog::setupFullTextIndex() +{ + if ( fullTextIndex ) + return; + + QStringList documentList; + QString pname = Config::configuration()->profileName(); + fullTextIndex = new Index( documentList, QDir::homeDirPath() ); // ### Is this correct ? + if (!verifyDirectory(cacheFilesPath)) { + QMessageBox::warning(help, tr("Qt Assistant"), + tr("Failed to save fulltext search index\n" + "Assistant will not work!")); + return; + } + searchButton->setEnabled(FALSE); + helpButton->setEnabled(FALSE); + termsEdit->setEnabled(FALSE); + + fullTextIndex->setDictionaryFile( cacheFilesPath + "indexdb.dict." + pname ); + fullTextIndex->setDocListFile( cacheFilesPath + "indexdb.doc." + pname ); + processEvents(); + + connect( fullTextIndex, SIGNAL( indexingProgress( int ) ), + this, SLOT( setIndexingProgress( int ) ) ); + QFile f( cacheFilesPath + "indexdb.dict." + pname ); + if ( !f.exists() ) { + QMap::ConstIterator it = titleMap.begin(); + QString documentName; + for ( ; it != titleMap.end(); ++it ) { + documentName = it.key(); + int i = documentName.findRev('#'); + if ( i > -1 ) + documentName = documentName.left( i ); + + if (!documentList.contains(documentName)) + documentList << documentName; + } + loadIndexFile(); + for (QStringList::Iterator it2 = keywordDocuments.begin(); it2 != keywordDocuments.end(); ++it2) { + if (!documentList.contains(*it2)) + documentList << *it2; + } + fullTextIndex->setDocList( documentList ); + + help->statusBar()->clear(); + setCursor( waitCursor ); + labelPrepare->setText( tr( "Indexing files..." ) ); + progressPrepare->setTotalSteps( 100 ); + progressPrepare->reset(); + progressPrepare->show(); + framePrepare->show(); + processEvents(); + if ( fullTextIndex->makeIndex() != -1 ) { + fullTextIndex->writeDict(); + progressPrepare->setProgress( 100 ); + framePrepare->hide(); + setCursor( arrowCursor ); + showInitDoneMessage(); + keywordDocuments.clear(); + } + } else { + setCursor( waitCursor ); + help->statusBar()->message( tr( "Reading dictionary..." ) ); + processEvents(); + fullTextIndex->readDict(); + help->statusBar()->message( tr( "Done" ), 3000 ); + setCursor( arrowCursor ); + } + searchButton->setEnabled(TRUE); + termsEdit->setEnabled(TRUE); + helpButton->setEnabled(TRUE); +} + +void HelpDialog::setIndexingProgress( int prog ) +{ + progressPrepare->setProgress( prog ); + processEvents(); +} + +void HelpDialog::startSearch() +{ + QString str = termsEdit->text(); + str = str.replace( "\'", "\"" ); + str = str.replace( "`", "\"" ); + QString buf = str; + str = str.replace( "-", " " ); + str = str.replace( QRegExp( "\\s[\\S]?\\s" ), " " ); + terms = QStringList::split( " ", str ); + QStringList termSeq; + QStringList seqWords; + QStringList::iterator it = terms.begin(); + for ( ; it != terms.end(); ++it ) { + (*it) = (*it).simplifyWhiteSpace(); + (*it) = (*it).lower(); + (*it) = (*it).replace( "\"", "" ); + } + if ( str.contains( '\"' ) ) { + if ( (str.contains( '\"' ))%2 == 0 ) { + int beg = 0; + int end = 0; + QString s; + beg = str.find( '\"', beg ); + while ( beg != -1 ) { + beg++; + end = str.find( '\"', beg ); + s = str.mid( beg, end - beg ); + s = s.lower(); + s = s.simplifyWhiteSpace(); + if ( s.contains( '*' ) ) { + QMessageBox::warning( this, tr( "Full Text Search" ), + tr( "Using a wildcard within phrases is not allowed." ) ); + return; + } + seqWords += QStringList::split( ' ', s ); + termSeq << s; + beg = str.find( '\"', end + 1); + } + } else { + QMessageBox::warning( this, tr( "Full Text Search" ), + tr( "The closing quotation mark is missing." ) ); + return; + } + } + setCursor( waitCursor ); + foundDocs.clear(); + foundDocs = fullTextIndex->query( terms, termSeq, seqWords ); + QString msg( QString( "%1 documents found." ).arg( foundDocs.count() ) ); + help->statusBar()->message( tr( msg ), 3000 ); + resultBox->clear(); + for ( it = foundDocs.begin(); it != foundDocs.end(); ++it ) + resultBox->insertItem( fullTextIndex->getDocumentTitle( *it ) ); + + terms.clear(); + bool isPhrase = FALSE; + QString s = ""; + for ( int i = 0; i < (int)buf.length(); ++i ) { + if ( buf[i] == '\"' ) { + isPhrase = !isPhrase; + s = s.simplifyWhiteSpace(); + if ( !s.isEmpty() ) + terms << s; + s = ""; + } else if ( buf[i] == ' ' && !isPhrase ) { + s = s.simplifyWhiteSpace(); + if ( !s.isEmpty() ) + terms << s; + s = ""; + } else + s += buf[i]; + } + if ( !s.isEmpty() ) + terms << s; + + setCursor( arrowCursor ); +} + +void HelpDialog::showSearchHelp() +{ + emit showLink( Config::configuration()->assistantDocPath() + "/assistant-5.html" ); +} + +void HelpDialog::showResultPage( int button, QListBoxItem *i, const QPoint & ) +{ + if( button == LeftButton ) { + showResultPage( i ); + } +} + +void HelpDialog::showResultPage( QListBoxItem *i ) +{ + if( !i ) + return; + emit showSearchLink( foundDocs[resultBox->index( i )], terms ); +} + +void HelpDialog::showItemMenu( QListBoxItem *item, const QPoint &pos ) +{ + if ( !item ) + return; + int id = itemPopup->exec( pos ); + if ( id == 0 ) { + if ( stripAmpersand( tabWidget->tabLabel( tabWidget->currentPage() ) ).contains( tr( "Index" ) ) ) + showTopic(); + else { + showResultPage( item ); + } + } else if ( id > 0 ) { + HelpWindow *hw = help->browsers()->currentBrowser(); + if ( stripAmpersand( tabWidget->tabLabel( tabWidget->currentPage() ) ).contains( tr( "Index" ) ) ) { + editIndex->blockSignals( TRUE ); + editIndex->setText( item->text() ); + editIndex->blockSignals( FALSE ); + + HelpNavigationListItem *hi = (HelpNavigationListItem*)item; + + QStringList links = hi->links(); + if ( links.count() == 1 ) { + if ( id == 1 ) + hw->openLinkInNewWindow( links.first() ); + else + hw->openLinkInNewPage( links.first() ); + } else { + QStringList::Iterator it = links.begin(); + QStringList linkList; + QStringList linkNames; + for ( ; it != links.end(); ++it ) { + linkList << *it; + linkNames << titleOfLink( *it ); + } + QString link = TopicChooser::getLink( this, linkNames, linkList, item->text() ); + if ( !link.isEmpty() ) { + if ( id == 1 ) + hw->openLinkInNewWindow( link ); + else + hw->openLinkInNewPage( link ); + } + } + } else { + QString link = foundDocs[ resultBox->index( item ) ]; + if ( id == 1 ) + hw->openLinkInNewWindow( link ); + else + hw->openLinkInNewPage( link ); + } + } +} + +void HelpDialog::showItemMenu( QListViewItem *item, const QPoint &pos ) +{ + if ( !item ) + return; + int id = itemPopup->exec( pos ); + if ( id == 0 ) { + if ( stripAmpersand( tabWidget->tabLabel( tabWidget->currentPage() ) ).contains( tr( "Contents" ) ) ) + showContentsTopic(); + else + showBookmarkTopic(); + } else if ( id > 0 ) { + HelpNavigationContentsItem *i = (HelpNavigationContentsItem*)item; + if ( id == 1 ) + help->browsers()->currentBrowser()->openLinkInNewWindow( i->link() ); + else + help->browsers()->currentBrowser()->openLinkInNewPage( i->link() ); + } +} diff --git a/tools/assistant/helpdialogimpl.h b/tools/assistant/helpdialogimpl.h new file mode 100644 index 0000000..f2c8b2c --- /dev/null +++ b/tools/assistant/helpdialogimpl.h @@ -0,0 +1,171 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of Qt Assistant. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef HELPDIALOGIMPL_H +#define HELPDIALOGIMPL_H + +#include "helpdialog.h" +#include "index.h" +#include "helpwindow.h" +#include "docuparser.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +class QProgressBar; +class MainWindow; +class QTextBrowser; + +class HelpNavigationListItem : public QListBoxText +{ +public: + HelpNavigationListItem( QListBox *ls, const QString &txt ); + + void addLink( const QString &link ); + QStringList links() const { return linkList; } +private: + QStringList linkList; + +}; + +class SearchValidator : public QValidator +{ + Q_OBJECT +public: + SearchValidator( QObject *parent, const char *name = 0 ) + : QValidator( parent, name ) {} + ~SearchValidator() {} + QValidator::State validate( QString &str, int & ) const; +}; + +class HelpNavigationContentsItem : public QListViewItem +{ +public: + HelpNavigationContentsItem( QListView *v, QListViewItem *after ); + HelpNavigationContentsItem( QListViewItem *v, QListViewItem *after ); + + void setLink( const QString &lnk ); + QString link() const; + +private: + QString theLink; +}; + +class HelpDialog : public HelpDialogBase +{ + Q_OBJECT + +public: + HelpDialog( QWidget *parent, MainWindow *h ); + + QString titleOfLink( const QString &link ); + bool eventFilter( QObject *, QEvent * ); + bool lastWindowClosed() { return lwClosed; } + + void timerEvent(QTimerEvent *e); + +protected slots: + void showTopic( int, QListBoxItem *, const QPoint & ); + void showTopic( int, QListViewItem *, const QPoint & ); + void showTopic( QListViewItem * ); + void loadIndexFile(); + void insertContents(); + void setupFullTextIndex(); + void currentTabChanged( const QString &s ); + void currentIndexChanged( QListBoxItem *i ); + void showTopic(); + void searchInIndex( const QString &s ); + void addBookmark(); + void removeBookmark(); + void currentBookmarkChanged( QListViewItem *i ); + void currentContentsChanged( QListViewItem *i ); + void startSearch(); + void showSearchHelp(); + +public slots: + void initialize(); + void toggleContents(); + void toggleIndex(); + void toggleBookmarks(); + void toggleSearch(); + + +signals: + void showLink( const QString &s ); + void showSearchLink( const QString &s, const QStringList &terms ); + +private slots: + void lastWinClosed(); + void showResultPage( int button, QListBoxItem *i, const QPoint &p ); + void showResultPage( QListBoxItem *i ); + void setIndexingProgress( int prog ); + void showItemMenu( QListBoxItem *item, const QPoint &pos ); + void showItemMenu( QListViewItem *item, const QPoint &pos ); + void insertBookmarks(); + void processEvents(); + +private: + typedef QValueList ContentList; + void removeOldCacheFiles(); + void buildKeywordDB(); + Q_UINT32 getFileAges(); + void showIndexTopic(); + void showBookmarkTopic(); + void setupTitleMap(); + void saveBookmarks(); + void showContentsTopic(); + void showInitDoneMessage(); + void buildContentDict(); + + QMap titleMap; + bool indexDone, bookmarksInserted, titleMapDone, contentsInserted; + bool lwClosed; + MainWindow *help; + QString documentationPath; + Index *fullTextIndex; + QStringList terms, foundDocs; + bool initDoneMsgShown; + void getAllContents(); + QDict contentList; + QPopupMenu *itemPopup; + QString cacheFilesPath; + QStringList keywordDocuments; +}; + +#endif diff --git a/tools/assistant/helpwindow.cpp b/tools/assistant/helpwindow.cpp new file mode 100644 index 0000000..e65b8e5 --- /dev/null +++ b/tools/assistant/helpwindow.cpp @@ -0,0 +1,282 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the Qt Assistant. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "helpwindow.h" +#include "mainwindow.h" +#include "tabbedbrowser.h" +#include "helpdialogimpl.h" +#include "config.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(Q_OS_WIN32) +#include +#endif + +HelpWindow::HelpWindow( MainWindow *w, QWidget *parent, const char *name ) + : QTextBrowser( parent, name ), mw( w ), blockScroll( FALSE ), + shiftPressed( FALSE ), newWindow( FALSE ) +{ + connect(this, SIGNAL(forwardAvailable(bool)), this, SLOT(updateForward(bool))); + connect(this, SIGNAL(backwardAvailable(bool)), this, SLOT(updateBackward(bool))); +} + +void HelpWindow::setSource( const QString &name ) +{ + if ( name.isEmpty() ) + return; + + if (newWindow || shiftPressed) { + removeSelection(); + mw->saveSettings(); + mw->saveToolbarSettings(); + MainWindow *nmw = new MainWindow; + + QFileInfo currentInfo( source() ); + QFileInfo linkInfo( name ); + QString target = name; + if( linkInfo.isRelative() ) + target = currentInfo.dirPath( TRUE ) + "/" + name; + + nmw->setup(); + nmw->move( mw->geometry().topLeft() ); + if ( mw->isMaximized() ) + nmw->showMaximized(); + else + nmw->show(); + nmw->showLink( target ); + return; + } + + if ( name.left( 7 ) == "http://" || name.left( 6 ) == "ftp://" ) { + QString webbrowser = Config::configuration()->webBrowser(); + if ( webbrowser.isEmpty() ) { +#if defined(Q_OS_WIN32) + QT_WA( { + ShellExecute( winId(), 0, (TCHAR*)name.ucs2(), 0, 0, SW_SHOWNORMAL ); + } , { + ShellExecuteA( winId(), 0, name.local8Bit(), 0, 0, SW_SHOWNORMAL ); + } ); +#elif defined(Q_OS_MACX) + webbrowser = "/usr/bin/open"; +#else + int result = QMessageBox::information( mw, tr( "Help" ), + tr( "Currently no Web browser is selected.\nPlease use the settings dialog to specify one!\n" ), + "Open", "Cancel" ); + if ( result == 0 ) { + emit chooseWebBrowser(); + webbrowser = Config::configuration()->webBrowser(); + } +#endif + if ( webbrowser.isEmpty() ) + return; + } + QProcess *proc = new QProcess(this); + + proc->addArgument( webbrowser ); + QObject::connect(proc, SIGNAL(processExited()), proc, SLOT(deleteLater())); + proc->addArgument( name ); + proc->start(); + return; + } + + if ( name.right( 3 ) == "pdf" ) { + QString pdfbrowser = Config::configuration()->pdfReader(); + if ( pdfbrowser.isEmpty() ) { +#if defined(Q_OS_MACX) + pdfbrowser = "/usr/bin/open"; +#else + QMessageBox::information( mw, + tr( "Help" ), + tr( "No PDF Viewer has been specified\n" + "Please use the settings dialog to specify one!\n" ) ); + return; +#endif + } + QFileInfo info( pdfbrowser ); + if( !info.exists() ) { + QMessageBox::information( mw, + tr( "Help" ), + tr( "Qt Assistant is unable to start the PDF Viewer\n\n" + "%1\n\n" + "Please make sure that the executable exists and is located at\n" + "the specified location." ).arg( pdfbrowser ) ); + return; + } + QProcess *proc = new QProcess(this); + QObject::connect(proc, SIGNAL(processExited()), proc, SLOT(deleteLater())); + proc->addArgument( pdfbrowser ); + proc->addArgument( name ); + proc->start(); + + return; + } + + QUrl u( context(), name ); + if ( !u.isLocalFile() ) { + QMessageBox::information( mw, tr( "Help" ), tr( "Can't load and display non-local file\n" + "%1" ).arg( name ) ); + return; + } + + setText(""); + QTextBrowser::setSource( name ); +} + + +void HelpWindow::openLinkInNewWindow() +{ + if ( lastAnchor.isEmpty() ) + return; + newWindow = TRUE; + setSource(lastAnchor); + newWindow = FALSE; +} + +void HelpWindow::openLinkInNewWindow( const QString &link ) +{ + lastAnchor = link; + openLinkInNewWindow(); +} + +void HelpWindow::openLinkInNewPage() +{ + if( lastAnchor.isEmpty() ) + return; + mw->browsers()->newTab( lastAnchor ); + lastAnchor = QString::null; +} + +void HelpWindow::openLinkInNewPage( const QString &link ) +{ + lastAnchor = link; + openLinkInNewPage(); +} + +QPopupMenu *HelpWindow::createPopupMenu( const QPoint& pos ) +{ + QPopupMenu *m = new QPopupMenu(0); + lastAnchor = anchorAt( pos ); + if ( !lastAnchor.isEmpty() ) { + if ( lastAnchor.at( 0 ) == '#' ) { + QString src = source(); + int hsh = src.find( '#' ); + lastAnchor = ( hsh>=0 ? src.left( hsh ) : src ) + lastAnchor; + } + m->insertItem( tr("Open Link in New Window\tShift+LMB"), + this, SLOT( openLinkInNewWindow() ) ); + m->insertItem( tr("Open Link in New Tab"), + this, SLOT( openLinkInNewPage() ) ); + } + mw->actionNewWindow->addTo( m ); + mw->actionOpenPage->addTo( m ); + mw->actionClosePage->addTo( m ); + m->insertSeparator(); + mw->actionGoPrevious->addTo( m ); + mw->actionGoNext->addTo( m ); + mw->actionGoHome->addTo( m ); + m->insertSeparator(); + mw->actionZoomIn->addTo( m ); + mw->actionZoomOut->addTo( m ); + m->insertSeparator(); + mw->actionEditCopy->addTo( m ); + mw->actionEditFind->addTo( m ); + return m; +} + +void HelpWindow::blockScrolling( bool b ) +{ + blockScroll = b; +} + +void HelpWindow::ensureCursorVisible() +{ + if ( !blockScroll ) + QTextBrowser::ensureCursorVisible(); +} + +void HelpWindow::contentsMousePressEvent(QMouseEvent *e) +{ + shiftPressed = ( e->state() & ShiftButton ); + QTextBrowser::contentsMousePressEvent(e); +} + +void HelpWindow::keyPressEvent(QKeyEvent *e) +{ + shiftPressed = ( e->state() & ShiftButton ); + QTextBrowser::keyPressEvent(e); +} + +void HelpWindow::copy() +{ + if (textFormat() == PlainText) { + QTextEdit::copy(); + } else { + TextFormat oldTf = textFormat(); + setTextFormat(PlainText); + QString selectText = selectedText(); + selectText.replace("
", "\n"); + selectText.replace("\xa0", " "); + selectText.replace(">", ">"); + selectText.replace("<", "<"); + selectText.replace("&", "&"); + + QClipboard *cb = QApplication::clipboard(); + if (cb->supportsSelection()) + cb->setText(selectText, QClipboard::Selection); + cb->setText(selectText, QClipboard::Clipboard); + setTextFormat(oldTf); + } +} + +void HelpWindow::updateForward(bool fwd) +{ + fwdAvail = fwd; +} + +void HelpWindow::updateBackward(bool back) +{ + backAvail = back; +} diff --git a/tools/assistant/helpwindow.h b/tools/assistant/helpwindow.h new file mode 100644 index 0000000..c1e585a --- /dev/null +++ b/tools/assistant/helpwindow.h @@ -0,0 +1,87 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the Qt Assistant. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef HELPWINDOW_H +#define HELPWINDOW_H + +#include + +class MainWindow; +class QKeyEvent; +class QMime; +class QMouseEvent; + +class HelpWindow : public QTextBrowser +{ + Q_OBJECT +public: + HelpWindow( MainWindow *m, QWidget *parent = 0, const char *name = 0 ); + void setSource( const QString &name ); + QPopupMenu *createPopupMenu( const QPoint& pos ); + void blockScrolling( bool b ); + void openLinkInNewWindow( const QString &link ); + void openLinkInNewPage( const QString &link ); + void addMimePath( const QString &path ); + + void contentsMousePressEvent(QMouseEvent *e); + void keyPressEvent(QKeyEvent *); + + bool isBackwardAvailable() const { return backAvail; } + bool isForwardAvailable() const { return fwdAvail; } + +signals: + void chooseWebBrowser(); + +public slots: + void copy(); +protected slots: + void ensureCursorVisible(); + +private slots: + void openLinkInNewWindow(); + void openLinkInNewPage(); + void updateForward(bool); + void updateBackward(bool); + +private: + MainWindow *mw; + QString lastAnchor; + bool blockScroll; + bool shiftPressed; + bool newWindow; + QMimeSourceFactory *mimeSourceFactory; + bool fwdAvail; + bool backAvail; +}; + +#endif diff --git a/tools/assistant/images/addtab.png b/tools/assistant/images/addtab.png new file mode 100644 index 0000000..a88697f Binary files /dev/null and b/tools/assistant/images/addtab.png differ diff --git a/tools/assistant/images/appicon.png b/tools/assistant/images/appicon.png new file mode 100644 index 0000000..a50dc9c Binary files /dev/null and b/tools/assistant/images/appicon.png differ diff --git a/tools/assistant/images/assistant.png b/tools/assistant/images/assistant.png new file mode 100644 index 0000000..461b883 Binary files /dev/null and b/tools/assistant/images/assistant.png differ diff --git a/tools/assistant/images/book.png b/tools/assistant/images/book.png new file mode 100644 index 0000000..ede2b97 Binary files /dev/null and b/tools/assistant/images/book.png differ diff --git a/tools/assistant/images/closetab.png b/tools/assistant/images/closetab.png new file mode 100644 index 0000000..61ac034 Binary files /dev/null and b/tools/assistant/images/closetab.png differ diff --git a/tools/assistant/images/d_closetab.png b/tools/assistant/images/d_closetab.png new file mode 100644 index 0000000..f2ac158 Binary files /dev/null and b/tools/assistant/images/d_closetab.png differ diff --git a/tools/assistant/images/designer.png b/tools/assistant/images/designer.png new file mode 100644 index 0000000..d808332 Binary files /dev/null and b/tools/assistant/images/designer.png differ diff --git a/tools/assistant/images/editcopy.png b/tools/assistant/images/editcopy.png new file mode 100644 index 0000000..804c98c Binary files /dev/null and b/tools/assistant/images/editcopy.png differ diff --git a/tools/assistant/images/find.png b/tools/assistant/images/find.png new file mode 100644 index 0000000..8d73ab0 Binary files /dev/null and b/tools/assistant/images/find.png differ diff --git a/tools/assistant/images/home.png b/tools/assistant/images/home.png new file mode 100644 index 0000000..aa150a3 Binary files /dev/null and b/tools/assistant/images/home.png differ diff --git a/tools/assistant/images/linguist.png b/tools/assistant/images/linguist.png new file mode 100644 index 0000000..1021804 Binary files /dev/null and b/tools/assistant/images/linguist.png differ diff --git a/tools/assistant/images/next.png b/tools/assistant/images/next.png new file mode 100644 index 0000000..4b29ff4 Binary files /dev/null and b/tools/assistant/images/next.png differ diff --git a/tools/assistant/images/previous.png b/tools/assistant/images/previous.png new file mode 100644 index 0000000..4e3556c Binary files /dev/null and b/tools/assistant/images/previous.png differ diff --git a/tools/assistant/images/print.png b/tools/assistant/images/print.png new file mode 100644 index 0000000..cc083ed Binary files /dev/null and b/tools/assistant/images/print.png differ diff --git a/tools/assistant/images/qt.png b/tools/assistant/images/qt.png new file mode 100644 index 0000000..29a1fa8 Binary files /dev/null and b/tools/assistant/images/qt.png differ diff --git a/tools/assistant/images/splash.png b/tools/assistant/images/splash.png new file mode 100644 index 0000000..e121aa1 Binary files /dev/null and b/tools/assistant/images/splash.png differ diff --git a/tools/assistant/images/whatsthis.xpm b/tools/assistant/images/whatsthis.xpm new file mode 100644 index 0000000..799b599 --- /dev/null +++ b/tools/assistant/images/whatsthis.xpm @@ -0,0 +1,26 @@ +/* XPM */ +static char *whatsthis[] = { +/* width height ncolors chars_per_pixel */ +"16 16 3 1", +/* colors */ +"# c None", +". c #000000", +"a c #000083", +/* pixels */ +".########aaaaa##", +"..######aaa#aaa#", +"...####aaa###aaa", +"....###aa#####aa", +".....##aa#####aa", +"......##a####aaa", +".......#####aaa#", +"........###aaa##", +".........#aaa###", +".....#####aaa###", +"..#...##########", +".##...####aaa###", +"####...###aaa###", +"####...#########", +"#####...########", +"#####...########" +}; diff --git a/tools/assistant/images/zoomin.png b/tools/assistant/images/zoomin.png new file mode 100644 index 0000000..667f2d6 Binary files /dev/null and b/tools/assistant/images/zoomin.png differ diff --git a/tools/assistant/images/zoomout.png b/tools/assistant/images/zoomout.png new file mode 100644 index 0000000..8755f4c Binary files /dev/null and b/tools/assistant/images/zoomout.png differ diff --git a/tools/assistant/index.cpp b/tools/assistant/index.cpp new file mode 100644 index 0000000..9e73ceb --- /dev/null +++ b/tools/assistant/index.cpp @@ -0,0 +1,526 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the Qt Assistant. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "index.h" + +#include +#include +#include +#include +#include + +#include + +int TermList::compareItems( QPtrCollection::Item i1, QPtrCollection::Item i2 ) +{ + if( ( (Term*)i1 )->frequency == ( (Term*)i2 )->frequency ) + return 0; + if( ( (Term*)i1 )->frequency < ( (Term*)i2 )->frequency ) + return -1; + return 1; +} + +QDataStream &operator>>( QDataStream &s, Document &l ) +{ + s >> l.docNumber; + s >> l.frequency; + return s; +} + +QDataStream &operator<<( QDataStream &s, const Document &l ) +{ + s << (Q_INT16)l.docNumber; + s << (Q_INT16)l.frequency; + return s; +} + +Index::Index( const QString &dp, const QString &hp ) + : QObject( 0, 0 ), dict( 8999 ), docPath( dp ) +{ + alreadyHaveDocList = FALSE; + lastWindowClosed = FALSE; + connect( qApp, SIGNAL( lastWindowClosed() ), + this, SLOT( setLastWinClosed() ) ); +} + +Index::Index( const QStringList &dl, const QString &hp ) + : QObject( 0, 0 ), dict( 8999 ) +{ + docList = dl; + alreadyHaveDocList = TRUE; + lastWindowClosed = FALSE; + connect( qApp, SIGNAL( lastWindowClosed() ), + this, SLOT( setLastWinClosed() ) ); +} + +void Index::setLastWinClosed() +{ + lastWindowClosed = TRUE; +} + +void Index::setDictionaryFile( const QString &f ) +{ + dictFile = f; +} + +void Index::setDocListFile( const QString &f ) +{ + docListFile = f; +} + +void Index::setDocList( const QStringList &lst ) +{ + docList = lst; +} + +int Index::makeIndex() +{ + if ( !alreadyHaveDocList ) + setupDocumentList(); + if ( docList.isEmpty() ) + return 1; + QStringList::Iterator it = docList.begin(); + int steps = docList.count() / 100; + if ( !steps ) + steps++; + int prog = 0; + for ( int i = 0; it != docList.end(); ++it, ++i ) { + if ( lastWindowClosed ) { + return -1; + } + parseDocument( *it, i ); + if ( i%steps == 0 ) { + prog++; + emit indexingProgress( prog ); + } + } + return 0; +} + +void Index::setupDocumentList() +{ + QDir d( docPath ); + QStringList lst = d.entryList( "*.html" ); + QStringList::ConstIterator it = lst.begin(); + for ( ; it != lst.end(); ++it ) + docList.append( docPath + "/" + *it ); +} + +void Index::insertInDict( const QString &str, int docNum ) +{ + if ( strcmp( str, "amp" ) == 0 || strcmp( str, "nbsp" ) == 0 ) + return; + Entry *e = 0; + if ( dict.count() ) + e = dict[ str ]; + + if ( e ) { + if ( e->documents.first().docNumber != docNum ) + e->documents.prepend( Document( docNum, 1 ) ); + else + e->documents.first().frequency++; + } else { + dict.insert( str, new Entry( docNum ) ); + } +} + +void Index::parseDocument( const QString &filename, int docNum ) +{ + QFile file( filename ); + if ( !file.open( IO_ReadOnly ) ) { + qWarning( "can not open file " + filename ); + return; + } + + QTextStream s( &file ); + QString text = s.read(); + if (text.isNull()) + return; + + bool valid = TRUE; + const QChar *buf = text.unicode(); + QChar str[64]; + QChar c = buf[0]; + int j = 0; + int i = 0; + while ( (uint)j < text.length() ) { + if ( c == '<' || c == '&' ) { + valid = FALSE; + if ( i > 1 ) + insertInDict( QString(str,i), docNum ); + i = 0; + c = buf[++j]; + continue; + } + if ( ( c == '>' || c == ';' ) && !valid ) { + valid = TRUE; + c = buf[++j]; + continue; + } + if ( !valid ) { + c = buf[++j]; + continue; + } + if ( ( c.isLetterOrNumber() || c == '_' ) && i < 63 ) { + str[i] = c.lower(); + ++i; + } else { + if ( i > 1 ) + insertInDict( QString(str,i), docNum ); + i = 0; + } + c = buf[++j]; + } + if ( i > 1 ) + insertInDict( QString(str,i), docNum ); + file.close(); +} + +void Index::writeDict() +{ + QDictIterator it( dict ); + QFile f( dictFile ); + if ( !f.open( IO_WriteOnly ) ) + return; + QDataStream s( &f ); + for( ; it.current(); ++it ) { + Entry *e = it.current(); + s << it.currentKey(); + s << e->documents; + } + f.close(); + writeDocumentList(); +} + +void Index::writeDocumentList() +{ + QFile f( docListFile ); + if ( !f.open( IO_WriteOnly ) ) + return; + QDataStream s( &f ); + s << docList; +} + +void Index::readDict() +{ + QFile f( dictFile ); + if ( !f.open( IO_ReadOnly ) ) + return; + + dict.clear(); + QDataStream s( &f ); + QString key; + QValueList docs; + while ( !s.atEnd() ) { + s >> key; + s >> docs; + dict.insert( key, new Entry( docs ) ); + } + f.close(); + readDocumentList(); +} + +void Index::readDocumentList() +{ + QFile f( docListFile ); + if ( !f.open( IO_ReadOnly ) ) + return; + QDataStream s( &f ); + s >> docList; +} + +QStringList Index::query( const QStringList &terms, const QStringList &termSeq, const QStringList &seqWords ) +{ + TermList termList; + + QStringList::ConstIterator it = terms.begin(); + for ( it = terms.begin(); it != terms.end(); ++it ) { + Entry *e = 0; + if ( (*it).contains( '*' ) ) { + QValueList wcts = setupDummyTerm( getWildcardTerms( *it ) ); + termList.append( new Term( "dummy", wcts.count(), wcts ) ); + } else if ( dict[ *it ] ) { + e = dict[ *it ]; + termList.append( new Term( *it, e->documents.count(), e->documents ) ); + } else { + return QStringList(); + } + } + termList.sort(); + + Term *minTerm = termList.first(); + if ( !termList.count() ) + return QStringList(); + termList.removeFirst(); + + QValueList minDocs = minTerm->documents; + QValueList::iterator C; + QValueList::ConstIterator It; + Term *t = termList.first(); + for ( ; t; t = termList.next() ) { + QValueList docs = t->documents; + C = minDocs.begin(); + while ( C != minDocs.end() ) { + bool found = FALSE; + for ( It = docs.begin(); It != docs.end(); ++It ) { + if ( (*C).docNumber == (*It).docNumber ) { + (*C).frequency += (*It).frequency; + found = TRUE; + break; + } + } + if ( !found ) + C = minDocs.remove( C ); + else + ++C; + } + } + + QStringList results; + qHeapSort( minDocs ); + if ( termSeq.isEmpty() ) { + for ( C = minDocs.begin(); C != minDocs.end(); ++C ) + results << docList[ (int)(*C).docNumber ]; + return results; + } + + QString fileName; + for ( C = minDocs.begin(); C != minDocs.end(); ++C ) { + fileName = docList[ (int)(*C).docNumber ]; + if ( searchForPattern( termSeq, seqWords, fileName ) ) + results << fileName; + } + return results; +} + +QString Index::getDocumentTitle( const QString &fileName ) +{ + QFile file( fileName ); + if ( !file.open( IO_ReadOnly ) ) { + qWarning( "cannot open file " + fileName ); + return fileName; + } + QTextStream s( &file ); + QString text = s.read(); + + int start = text.find( "", 0, FALSE ) + 7; + int end = text.find( "", 0, FALSE ); + + QString title = ( end - start <= 0 ? tr("Untitled") : text.mid( start, end - start ) ); + return title; +} + +QStringList Index::getWildcardTerms( const QString &term ) +{ + QStringList lst; + QStringList terms = split( term ); + QValueList::iterator iter; + + QDictIterator it( dict ); + for( ; it.current(); ++it ) { + int index = 0; + bool found = FALSE; + QString text( it.currentKey() ); + for ( iter = terms.begin(); iter != terms.end(); ++iter ) { + if ( *iter == "*" ) { + found = TRUE; + continue; + } + if ( iter == terms.begin() && (*iter)[0] != text[0] ) { + found = FALSE; + break; + } + index = text.find( *iter, index ); + if ( *iter == terms.last() && index != (int)text.length()-1 ) { + index = text.findRev( *iter ); + if ( index != (int)text.length() - (int)(*iter).length() ) { + found = FALSE; + break; + } + } + if ( index != -1 ) { + found = TRUE; + index += (*iter).length(); + continue; + } else { + found = FALSE; + break; + } + } + if ( found ) + lst << text; + } + + return lst; +} + +QStringList Index::split( const QString &str ) +{ + QStringList lst; + int j = 0; + int i = str.find( '*', j ); + + while ( i != -1 ) { + if ( i > j && i <= (int)str.length() ) { + lst << str.mid( j, i - j ); + lst << "*"; + } + j = i + 1; + i = str.find( '*', j ); + } + + int l = str.length() - 1; + if ( str.mid( j, l - j + 1 ).length() > 0 ) + lst << str.mid( j, l - j + 1 ); + + return lst; +} + +QValueList Index::setupDummyTerm( const QStringList &terms ) +{ + TermList termList; + QStringList::ConstIterator it = terms.begin(); + for ( ; it != terms.end(); ++it ) { + Entry *e = 0; + if ( dict[ *it ] ) { + e = dict[ *it ]; + termList.append( new Term( *it, e->documents.count(), e->documents ) ); + } + } + termList.sort(); + + QValueList maxList; + + if ( !termList.count() ) + return maxList; + maxList = termList.last()->documents; + termList.removeLast(); + + QValueList::iterator docIt; + Term *t = termList.first(); + while ( t ) { + QValueList docs = t->documents; + for ( docIt = docs.begin(); docIt != docs.end(); ++docIt ) { + if ( maxList.findIndex( *docIt ) == -1 ) + maxList.append( *docIt ); + } + t = termList.next(); + } + return maxList; +} + +void Index::buildMiniDict( const QString &str ) +{ + if ( miniDict[ str ] ) + miniDict[ str ]->positions.append( wordNum ); + ++wordNum; +} + +bool Index::searchForPattern( const QStringList &patterns, const QStringList &words, const QString &fileName ) +{ + QFile file( fileName ); + if ( !file.open( IO_ReadOnly ) ) { + qWarning( "cannot open file " + fileName ); + return FALSE; + } + + wordNum = 3; + miniDict.clear(); + QStringList::ConstIterator cIt = words.begin(); + for ( ; cIt != words.end(); ++cIt ) + miniDict.insert( *cIt, new PosEntry( 0 ) ); + + QTextStream s( &file ); + QString text = s.read(); + bool valid = TRUE; + const QChar *buf = text.unicode(); + QChar str[64]; + QChar c = buf[0]; + int j = 0; + int i = 0; + while ( (uint)j < text.length() ) { + if ( c == '<' || c == '&' ) { + valid = FALSE; + if ( i > 1 ) + buildMiniDict( QString(str,i) ); + i = 0; + c = buf[++j]; + continue; + } + if ( ( c == '>' || c == ';' ) && !valid ) { + valid = TRUE; + c = buf[++j]; + continue; + } + if ( !valid ) { + c = buf[++j]; + continue; + } + if ( ( c.isLetterOrNumber() || c == '_' ) && i < 63 ) { + str[i] = c.lower(); + ++i; + } else { + if ( i > 1 ) + buildMiniDict( QString(str,i) ); + i = 0; + } + c = buf[++j]; + } + if ( i > 1 ) + buildMiniDict( QString(str,i) ); + file.close(); + + QStringList::ConstIterator patIt = patterns.begin(); + QStringList wordLst; + QValueList a, b; + QValueList::iterator aIt; + for ( ; patIt != patterns.end(); ++patIt ) { + wordLst = QStringList::split( ' ', *patIt ); + a = miniDict[ wordLst[0] ]->positions; + for ( int j = 1; j < (int)wordLst.count(); ++j ) { + b = miniDict[ wordLst[j] ]->positions; + aIt = a.begin(); + while ( aIt != a.end() ) { + if ( b.find( *aIt + 1 ) != b.end() ) { + (*aIt)++; + ++aIt; + } else { + aIt = a.remove( aIt ); + } + } + } + } + if ( a.count() ) + return TRUE; + return FALSE; +} diff --git a/tools/assistant/index.h b/tools/assistant/index.h new file mode 100644 index 0000000..b3d2b5d --- /dev/null +++ b/tools/assistant/index.h @@ -0,0 +1,131 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the Qt Assistant. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef INDEX_H +#define INDEX_H + +#include +#include +#include +#include + +struct Document { + Document( int d, int f ) : docNumber( d ), frequency( f ) {} + Document() : docNumber( -1 ), frequency( 0 ) {} + bool operator==( const Document &doc ) const { + return docNumber == doc.docNumber; + } + bool operator<( const Document &doc ) const { + return frequency > doc.frequency; + } + bool operator<=( const Document &doc ) const { + return frequency >= doc.frequency; + } + bool operator>( const Document &doc ) const { + return frequency < doc.frequency; + } + Q_INT16 docNumber; + Q_INT16 frequency; +}; + +QDataStream &operator>>( QDataStream &s, Document &l ); +QDataStream &operator<<( QDataStream &s, const Document &l ); + +class Index : public QObject +{ + Q_OBJECT +public: + struct Entry { + Entry( int d ) { documents.append( Document( d, 1 ) ); } + Entry( QValueList l ) : documents( l ) {} + QValueList documents; + }; + struct PosEntry { + PosEntry( int p ) { positions.append( p ); } + QValueList positions; + }; + + Index( const QString &dp, const QString &hp ); + Index( const QStringList &dl, const QString &hp ); + void writeDict(); + void readDict(); + int makeIndex(); + QStringList query( const QStringList&, const QStringList&, const QStringList& ); + QString getDocumentTitle( const QString& ); + void setDictionaryFile( const QString& ); + void setDocListFile( const QString& ); + void setDocList( const QStringList & ); + +signals: + void indexingProgress( int ); + +private slots: + void setLastWinClosed(); + +private: + void setupDocumentList(); + void parseDocument( const QString&, int ); + void insertInDict( const QString&, int ); + void writeDocumentList(); + void readDocumentList(); + QStringList getWildcardTerms( const QString& ); + QStringList split( const QString& ); + QValueList setupDummyTerm( const QStringList& ); + bool searchForPattern( const QStringList&, const QStringList&, const QString& ); + void buildMiniDict( const QString& ); + QStringList docList; + QDict dict; + QDict miniDict; + uint wordNum; + QString docPath; + QString dictFile, docListFile; + bool alreadyHaveDocList; + bool lastWindowClosed; +}; + +struct Term { + Term( const QString &t, int f, QValueList l ) + : term( t ), frequency( f ), documents( l ) {} + QString term; + int frequency; + QValueListdocuments; +}; + +class TermList : public QPtrList +{ +public: + TermList() : QPtrList() {} + int compareItems( QPtrCollection::Item i1, QPtrCollection::Item i2 ); +}; + +#endif diff --git a/tools/assistant/lib/lib.pro b/tools/assistant/lib/lib.pro new file mode 100644 index 0000000..09beced --- /dev/null +++ b/tools/assistant/lib/lib.pro @@ -0,0 +1,23 @@ +TEMPLATE = lib +TARGET = qassistantclient +VERSION = 1.0 + +CONFIG += qt warn_on release +CONFIG += staticlib +CONFIG -= dll + +SOURCES = qassistantclient.cpp +HEADERS += $$QT_SOURCE_TREE/include/qassistantclient.h + + +DEFINES += QT_INTERNAL_NETWORK +include( ../../../src/qt_professional.pri ) + +DESTDIR = ../../../lib + +unix { + target.path=$$libs.path + QMAKE_CFLAGS += $$QMAKE_CFLAGS_SHLIB + QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_SHLIB + INSTALLS += target +} diff --git a/tools/assistant/lib/qassistantclient.cpp b/tools/assistant/lib/qassistantclient.cpp new file mode 100644 index 0000000..8120cb6 --- /dev/null +++ b/tools/assistant/lib/qassistantclient.cpp @@ -0,0 +1,334 @@ +/********************************************************************** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the QAssistantClient library. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "qassistantclient.h" + +#include +#include +#include +#include +#include + +class QAssistantClientPrivate +{ + friend class QAssistantClient; + QStringList arguments; +}; + +static QMap *dpointers = 0; + +static QAssistantClientPrivate *data( const QAssistantClient *client, bool create=FALSE ) +{ + if( !dpointers ) + dpointers = new QMap; + QAssistantClientPrivate *d = (*dpointers)[client]; + if( !d && create ) { + d = new QAssistantClientPrivate; + dpointers->insert( client, d ); + } + return d; +} + +/*! + \class QAssistantClient + \brief The QAssistantClient class provides a means of using Qt + Assistant as an application's help tool. + + Using Qt Assistant is simple: Create a QAssistantClient instance, + then call showPage() as often as necessary to show your help + pages. When you call showPage(), Qt Assistant will be launched if + it isn't already running. + + The QAssistantClient instance can open (openAssistant()) or close + (closeAssistant()) Qt Assistant whenever required. If Qt Assistant + is open, isOpen() returns TRUE. + + One QAssistantClient instance interacts with one Qt Assistant + instance, so every time you call openAssistant(), showPage() or + closeAssistant() they are applied to the particular Qt Assistant + instance associated with the QAssistantClient. + + When you call openAssistant() the assistantOpened() signal is + emitted. Similarly when closeAssistant() is called, + assistantClosed() is emitted. In either case, if an error occurs, + error() is emitted. + + This class is not included in the Qt library itself. To use it you + must link against \c libqassistantclient.a (Unix) or \c + qassistantclient.lib (Windows), which is built into \c INSTALL/lib + if you built the Qt tools (\c INSTALL is the directory where Qt is + installed). If you use qmake, then you can simply add the following + line to your pro file: + + \code + LIBS += -lqassistantclient + \endcode + + See also "Adding Documentation to Qt Assistant" in the \link + assistant.book Qt Assistant manual\endlink. +*/ + +/*! + \fn void QAssistantClient::assistantOpened() + + This signal is emitted when Qt Assistant is open and the + client-server communication is set up. +*/ + +/*! + \fn void QAssistantClient::assistantClosed() + + This signal is emitted when the connection to Qt Assistant is + closed. This happens when the user exits Qt Assistant, or when an + error in the server or client occurs, or if closeAssistant() is + called. +*/ + +/*! + \fn void QAssistantClient::error( const QString &msg ) + + This signal is emitted if Qt Assistant cannot be started or if an + error occurs during the initialization of the connection between + Qt Assistant and the calling application. The \a msg provides an + explanation of the error. +*/ + +/*! + Constructs an assistant client object. The \a path specifies the + path to the Qt Assistant executable. If \a path is an empty + string the system path (\c{%PATH%} or \c $PATH) is used. + + The assistant client object is a child of \a parent and is called + \a name. +*/ +QAssistantClient::QAssistantClient( const QString &path, QObject *parent, const char *name ) + : QObject( parent, name ), host ( "localhost" ) +{ + if ( path.isEmpty() ) + assistantCommand = "assistant"; + else { + QFileInfo fi( path ); + if ( fi.isDir() ) + assistantCommand = path + "/assistant"; + else + assistantCommand = path; + } + +#if defined(Q_OS_MACX) + assistantCommand += ".app/Contents/MacOS/assistant"; +#elif defined(Q_WS_WIN) + if (!assistantCommand.endsWith(".exe")) + assistantCommand += ".exe"; +#endif + socket = new QSocket( this ); + connect( socket, SIGNAL( connected() ), + SLOT( socketConnected() ) ); + connect( socket, SIGNAL( connectionClosed() ), + SLOT( socketConnectionClosed() ) ); + connect( socket, SIGNAL( error( int ) ), + SLOT( socketError( int ) ) ); + opened = FALSE; + proc = new QProcess( this ); + port = 0; + pageBuffer = ""; + connect( proc, SIGNAL( readyReadStderr() ), + this, SLOT( readStdError() ) ); +} + +/*! + Destroys the assistant client object and frees up all allocated + resources. +*/ +QAssistantClient::~QAssistantClient() +{ + if ( proc && proc->isRunning() ) { + proc->tryTerminate(); + proc->kill(); + } + + if( dpointers ) { + QAssistantClientPrivate *d = (*dpointers)[ this ]; + if( d ) { + dpointers->remove( this ); + delete d; + if( dpointers->isEmpty() ) { + delete dpointers; + dpointers = 0; + } + } + } +} + +/*! + This function opens Qt Assistant and sets up the client-server + communiction between the application and Qt Assistant. If it is + already open, this function does nothing. If an error occurs, + error() is emitted. + + \sa assistantOpened() +*/ +void QAssistantClient::openAssistant() +{ + if ( proc->isRunning() ) + return; + proc->clearArguments(); + proc->addArgument( assistantCommand ); + proc->addArgument( "-server" ); + if( !pageBuffer.isEmpty() ) { + proc->addArgument( "-file" ); + proc->addArgument( pageBuffer ); + } + + QAssistantClientPrivate *d = data( this ); + if( d ) { + QStringList::ConstIterator it = d->arguments.begin(); + while( it!=d->arguments.end() ) { + proc->addArgument( *it ); + ++it; + } + } + + if ( !proc->launch( QString::null ) ) { + emit error( tr( "Cannot start Qt Assistant '%1'" ) + .arg( proc->arguments().join( " " ) ) ); + return; + } + connect( proc, SIGNAL( readyReadStdout() ), + this, SLOT( readPort() ) ); +} + +void QAssistantClient::readPort() +{ + QString p = proc->readLineStdout(); + Q_UINT16 port = p.toUShort(); + if ( port == 0 ) { + emit error( tr( "Cannot connect to Qt Assistant." ) ); + return; + } + socket->connectToHost( host, port ); + disconnect( proc, SIGNAL( readyReadStdout() ), + this, SLOT( readPort() ) ); +} + +/*! + Use this function to close Qt Assistant. + + \sa assistantClosed() +*/ +void QAssistantClient::closeAssistant() +{ + if ( !opened ) + return; + proc->tryTerminate(); + proc->kill(); +} + +/*! + Call this function to make Qt Assistant show a particular \a page. + The \a page is a filename (e.g. \c myhelpfile.html). See "Adding + Documentation to Qt Assistant" in the \link assistant.book Qt + Assistant manual\endlink for further information. + + If Qt Assistant hasn't been \link openAssistant() opened\endlink + yet, this function will do nothing. You can use isOpen() to + determine whether Qt Assistant is up and running, or you can + connect to the asssistantOpened() signal. + + \sa isOpen(), assistantOpened() +*/ +void QAssistantClient::showPage( const QString &page ) +{ + if ( !opened ) { + pageBuffer = page; + openAssistant(); + pageBuffer = QString::null; + return; + } + QTextStream os( socket ); + os << page << "\n"; +} + +/*! + \property QAssistantClient::open + \brief Whether Qt Assistant is open. + +*/ +bool QAssistantClient::isOpen() const +{ + return opened; +} + +void QAssistantClient::socketConnected() +{ + opened = TRUE; + if ( !pageBuffer.isEmpty() ) + showPage( pageBuffer ); + emit assistantOpened(); +} + +void QAssistantClient::socketConnectionClosed() +{ + opened = FALSE; + emit assistantClosed(); +} + +void QAssistantClient::socketError( int i ) +{ + if ( i == QSocket::ErrConnectionRefused ) + emit error( tr( "Could not connect to Assistant: Connection refused" ) ); + else if ( i == QSocket::ErrHostNotFound ) + emit error( tr( "Could not connect to Assistant: Host not found" ) ); + else + emit error( tr( "Communication error" ) ); +} + +void QAssistantClient::readStdError() +{ + QString errmsg; + while ( proc->canReadLineStderr() ) { + errmsg += proc->readLineStderr(); + errmsg += "\n"; + } + if (!errmsg.isEmpty()) + emit error( tr( errmsg.simplifyWhiteSpace() ) ); +} + +/*! + Sets the command line arguments used when Qt Assistant is + started to \a args. +*/ +void QAssistantClient::setArguments( const QStringList &args ) +{ + QAssistantClientPrivate *d = data( this, TRUE ); + d->arguments = args; +} diff --git a/tools/assistant/lib/qassistantclient.h b/tools/assistant/lib/qassistantclient.h new file mode 100644 index 0000000..a05d291 --- /dev/null +++ b/tools/assistant/lib/qassistantclient.h @@ -0,0 +1,80 @@ +/********************************************************************** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the QAssistantClient library. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef QASSISTANTCLIENT_H +#define QASSISTANTCLIENT_H + +#include + +class QSocket; +class QProcess; + +class QAssistantClient : public QObject +{ + Q_OBJECT + Q_PROPERTY( bool open READ isOpen ) + +public: + QAssistantClient( const QString &path, QObject *parent = 0, const char *name = 0 ); + ~QAssistantClient(); + + bool isOpen() const; + + void setArguments( const QStringList &args ); + +public slots: + virtual void openAssistant(); + virtual void closeAssistant(); + virtual void showPage( const QString &page ); + +signals: + void assistantOpened(); + void assistantClosed(); + void error( const QString &msg ); + +private slots: + void socketConnected(); + void socketConnectionClosed(); + void readPort(); + void socketError( int ); + void readStdError(); + +private: + QSocket *socket; + QProcess *proc; + Q_UINT16 port; + QString host, assistantCommand, pageBuffer; + bool opened; +}; + +#endif diff --git a/tools/assistant/main.cpp b/tools/assistant/main.cpp new file mode 100644 index 0000000..0619909 --- /dev/null +++ b/tools/assistant/main.cpp @@ -0,0 +1,342 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the Qt Assistant. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "mainwindow.h" +#include "helpdialogimpl.h" +#include "config.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef Q_WS_WIN +#define INDEX_CHECK( text ) if( i+1 >= argc ) { QMessageBox::information( 0, "Qt Assistant", text ); return 1; } +#else +#define INDEX_CHECK( text ) if( i+1 >= argc ) { fprintf( stderr, text "\n" ); return 1; } +#endif + +static bool allowFirstRun = TRUE; + +class AssistantSocket : public QSocket +{ + Q_OBJECT +public: + AssistantSocket( int sock, QObject *parent = 0 ); + ~AssistantSocket() {} + +signals: + void showLinkRequest( const QString& ); + +private slots: + void readClient(); + void connectionClosed(); +}; + + +class AssistantServer : public QServerSocket +{ + Q_OBJECT +public: + AssistantServer( QObject* parent = 0 ); + void newConnection( int socket ); + Q_UINT16 getPort() const; + +signals: + void showLinkRequest( const QString& ); + void newConnect(); + +private: + Q_UINT16 p; +}; + + +AssistantSocket::AssistantSocket( int sock, QObject *parent ) + : QSocket( parent, 0 ) +{ + connect( this, SIGNAL( readyRead() ), + SLOT( readClient() ) ); + connect( this, SIGNAL( connectionClosed() ), + SLOT( connectionClosed() ) ); + setSocket( sock ); +} + +void AssistantSocket::readClient() +{ + QString link = QString::null; + while ( canReadLine() ) + link = readLine(); + if ( !link.isNull() ) { + link = link.replace( "\n", "" ); + link = link.replace( "\r", "" ); + emit showLinkRequest( link ); + } +} + +void AssistantSocket::connectionClosed() +{ + delete this; +} + +AssistantServer::AssistantServer( QObject *parent ) + : QServerSocket( 0x7f000001, 0, 1, parent ) +{ + if ( !ok() ) { + QMessageBox::critical( 0, tr( "Qt Assistant" ), + tr( "Failed to bind to port %1" ).arg( port() ) ); + exit( 1 ); + } + p = port(); +} + +Q_UINT16 AssistantServer::getPort() const +{ + return p; +} + +void AssistantServer::newConnection( int socket ) +{ + AssistantSocket *as = new AssistantSocket( socket, this ); + connect( as, SIGNAL( showLinkRequest( const QString& ) ), + this, SIGNAL( showLinkRequest( const QString& ) ) ); + emit newConnect(); +} + +int main( int argc, char ** argv ) +{ + bool withGUI = TRUE; + if ( argc > 1 ) { + QString arg( argv[1] ); + arg = arg.lower(); + if ( arg == "-addcontentfile" + || arg == "-removecontentfile" +#ifndef Q_WS_WIN + || arg == "-help" +#endif + ) + withGUI = FALSE; + } + QApplication a(argc, argv, withGUI); + + QString resourceDir; + AssistantServer *as = 0; + QStringList catlist; + QString file, profileName, aDocPath; + bool server = FALSE; + bool hideSidebar = FALSE; + bool startClean = FALSE; + bool configLoaded = FALSE; + if ( argc == 2 ) { + if ( (argv[1])[0] != '-' ) + file = argv[1]; + } + if ( file.isEmpty() ) { + for ( int i = 1; i < argc; i++ ) { + if ( QString( argv[i] ).lower() == "-file" ) { + INDEX_CHECK( "Missing file argument!" ); + i++; + file = argv[i]; + } else if ( QString( argv[i] ).lower() == "-server" ) { + server = TRUE; + } else if ( QString( argv[i] ).lower() == "-profile" ) { + INDEX_CHECK( "Missing profile argument!" ); + profileName = argv[++i]; + } else if ( QString( argv[i] ).lower() == "-addcontentfile" ) { + INDEX_CHECK( "Missing content file!" ); + Config *c = Config::loadConfig( QString::null ); + QFileInfo file( argv[i+1] ); + if( !file.exists() ) { + fprintf( stderr, "Could not locate content file: '%s'\n", + file.absFilePath().latin1() ); + fflush( stderr ); + return 1; + } + DocuParser *parser = DocuParser::createParser( file.absFilePath() ); + if( parser ) { + QFile f( argv[i+1] ); + if( !parser->parse( &f ) ) { + fprintf( stderr, "Failed to parse file: '%s'\n, ", + file.absFilePath().latin1() ); + fflush( stderr ); + return 1; + } + parser->addTo( c->profile() ); + c->setDocRebuild( TRUE ); + c->save(); + } + return 0; + } else if ( QString( argv[i] ).lower() == "-removecontentfile" ) { + INDEX_CHECK( "Missing content file!" ); + Config *c = Config::loadConfig( QString::null ); + Profile *profile = c->profile(); + QStringList entries = profile->docs.grep(argv[i+1]); + if (entries.count() == 0) { + fprintf(stderr, "Could not locate content file: '%s'\n", + argv[i+1]); + fflush(stderr); + return 1; + } else if (entries.count() > 1) { + fprintf(stderr, "More than one entry matching file name found, " + "please specify full path to file"); + fflush(stderr); + return 1; + } else { + QFileInfo file(entries[0]); + if( !file.exists() ) { + fprintf( stderr, "Could not locate content file: '%s'\n", + file.absFilePath().latin1() ); + fflush( stderr ); + return 1; + } + profile->removeDocFileEntry( file.absFilePath() ); + c->setDocRebuild( TRUE ); + c->save(); + } + return 0; + } else if ( QString( argv[i] ).lower() == "-docpath" ) { + INDEX_CHECK( "Missing path!" ); + QDir dir( argv[i+1] ); + if ( dir.exists() ) { + Config *c = Config::loadConfig( QString::null ); + c->saveProfile(Profile::createDefaultProfile(dir.absPath())); + c->loadDefaultProfile(); + c->setDocRebuild( TRUE ); + c->save(); + configLoaded = TRUE; + ++i; + } else { + fprintf( stderr, "The specified path does not exist!\n"); + fflush( stderr ); + return 1; + } + } else if ( QString( argv[i] ).lower() == "-hidesidebar" ) { + hideSidebar = TRUE; + } else if ( QString( argv[i] ).lower() == "-help" ) { + QString helpText( "Usage: assistant [option]\n" + "Options:\n" + " -file Filename assistant opens the specified file\n" + " -server reads commands from a socket after\n" + " assistant has started\n" + " -profile fileName starts assistant and displays the\n" + " profile specified in the file fileName.\n" + " -addContentFile file adds the content file 'file' to the set of\n" + " documentation available by default\n" + " -removeContentFile file removes the content file 'file' from the\n" + " documentation available by default\n" + " -docPath path sets the Qt documentation root path to\n" + " 'path' and starts assistant\n" + " -hideSidebar assistant will hide the sidebar.\n" + " -resourceDir assistant will load translations from\n" + " this directory.\n" + " -help shows this help."); +#ifdef Q_WS_WIN + QMessageBox::information( 0, "Qt Assistant", "
" + helpText + "
" ); +#else + printf( "%s\n", helpText.latin1() ); +#endif + exit( 0 ); + } else if ( QString( argv[i] ).lower() == "-resourcedir" ) { + INDEX_CHECK( "Missing resource directory argument!" ); + resourceDir = QString( argv[++i] ); + } else { + fprintf( stderr, "Unrecognized option '%s'. Try -help to get help.\n", + argv[i] ); + fflush( stderr ); + return 1; + } + } + } + + if( resourceDir.isNull() ) + resourceDir = qInstallPathTranslations(); + + QTranslator translator( 0 ); + translator.load( QString("assistant_") + QTextCodec::locale(), resourceDir ); + a.installTranslator( &translator ); + + QTranslator qtTranslator( 0 ); + qtTranslator.load( QString("qt_") + QTextCodec::locale(), resourceDir ); + a.installTranslator( &qtTranslator ); + + + Config *conf = 0; + if (configLoaded) + conf = Config::configuration(); + else + conf = Config::loadConfig( profileName ); + if (!conf) { + fprintf( stderr, "Profile '%s' does not exist!\n", profileName.latin1() ); + fflush( stderr ); + return -1; + } + + bool max = conf->isMaximized(); + QStringList links = conf->source(); + conf->hideSideBar( hideSidebar ); + + QGuardedPtr mw = new MainWindow( 0, "Assistant" ); + + if ( server ) { + as = new AssistantServer(); + printf("%d\n", as->port() ); + fflush( stdout ); + as->connect( as, SIGNAL( showLinkRequest( const QString& ) ), + mw, SLOT( showLinkFromClient( const QString& ) ) ); + } + + if ( max ) + mw->showMaximized(); + else + mw->show(); + + if ( !file.isEmpty() ) + mw->showLink( file ); + else if ( file.isEmpty() ) + mw->showLinks( links ); + + a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) ); + + int appExec = a.exec(); + delete (MainWindow*)mw; + return appExec; +} + +#include "main.moc" diff --git a/tools/assistant/mainwindow.ui b/tools/assistant/mainwindow.ui new file mode 100644 index 0000000..5b6ddac --- /dev/null +++ b/tools/assistant/mainwindow.ui @@ -0,0 +1,670 @@ + +MainWindow +********************************************************************* +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of Qt Assistant. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +********************************************************************* + + + MainWindow + + + + 0 + 0 + 949 + 670 + + + + Qt Assistant by Trolltech + + + + + menubar + + + + 0 + 0 + 949 + 29 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Toolbar + + + Toolbar + + + + + + + + + + + + + + + + + goActionToolbar + + + Go + + + + + + + actionFilePrint + + + print.png + + + Print + + + &Print... + + + Print the currently displayed page. + + + Ctrl+P + + + + + actionFileExit + + + Exit + + + E&xit + + + Quit Qt Assistant. + + + Ctrl+Q + + + + + actionEditCopy + + + editcopy.png + + + Copy + + + &Copy + + + Copy the selected text to the clipboard. + + + Ctrl+C + + + + + actionEditFind + + + find.png + + + Find in Text + + + &Find in Text... + + + Open the Find dialog. Qt Assistant will search the currently displayed page for the text you enter. + + + Ctrl+F + + + + + actionEditFindAgain + + + Find &Next + + + Find Next + + + F3 + + + + + actionEditFindAgainPrev + + + Find &Previous + + + Find Previous + + + Shift+F3 + + + + + actionGoHome + + + home.png + + + Home + + + &Home + + + Go to the home page. Qt Assistant's home page is the Qt Reference Documentation. + + + Ctrl+Home + + + + + actionGoPrevious + + + previous.png + + + Previous + + + &Previous + + + Go to the previous page. + + + Alt+Left + + + + + actionGoNext + + + next.png + + + Next + + + &Next + + + Go to the next page. + + + Alt+Right + + + + + helpAbout_Qt_AssistantAction + + + About Qt Assistant + + + About Qt Assistant + + + Display further information about Qt Assistant. + + + + + actionAboutApplication + + + + + actionZoomIn + + + zoomin.png + + + Zoom in + + + Zoom &in + + + Zoom in on the document, i.e. increase the font size. + + + Ctrl++ + + + + + actionZoomOut + + + zoomout.png + + + Zoom out + + + Zoom &out + + + Zoom out on the document, i.e. decrease the font size. + + + Ctrl+- + + + + + actionSettings + + + Settings + + + &Settings... + + + Open the settings dialog. + + + + + actionNewWindow + + + New Window + + + New Window + + + Open a new window. + + + Ctrl+N + + + + + actionClose + + + Close + + + &Close + + + Close the current window. + + + + + actionAddBookmark + + + Add Bookmark + + + &Add Bookmark + + + Add the currently displayed page as a new bookmark. + + + + + actionHelpWhatsThis + + + whatsthis.xpm + + + What's This? + + + "What's This?" context sensitive help. + + + "What's This?" context sensitive help. + + + Shift+F1 + + + + + actionOpenPage + + + Add Tab + + + Ctrl+Alt+N + + + + + actionNextPage + + + Next Tab + + + Ctrl+Alt+Right + + + + + actionPrevPage + + + Previous Tab + + + Ctrl+Alt+Left + + + + + actionClosePage + + + Close Tab + + + Ctrl+Alt+Q + + + + + actionHelpAssistant + + + assistant.png + + + Qt Assistant Manual + + + F1 + + + + + + actionGoHome + activated() + MainWindow + goHome() + + + helpAbout_Qt_AssistantAction + activated() + MainWindow + about() + + + actionEditFind + activated() + MainWindow + find() + + + actionEditFindAgain + activated() + MainWindow + findAgain() + + + actionEditFindAgainPrev + activated() + MainWindow + findAgainPrev() + + + actionFilePrint + activated() + MainWindow + print() + + + actionSettings + activated() + MainWindow + showSettingsDialog() + + + actionNewWindow + activated() + MainWindow + newWindow() + + + actionClose + activated() + MainWindow + close() + + + actionHelpWhatsThis + activated() + MainWindow + whatsThis() + + + actionHelpAssistant + activated() + MainWindow + showAssistantHelp() + + + actionAboutApplication + activated() + MainWindow + aboutApplication() + + + + qtoolbutton.h + settingsdialogimpl.h + qmessagebox.h + qfontdatabase.h + qaccel.h + qcombobox.h + qpaintdevicemetrics.h + qsimplerichtext.h + qfileinfo.h + qtextstream.h + qdockwindow.h + stdlib.h + qmime.h + helpwindow.h + qstylesheet.h + qapplication.h + helpdialogimpl.h + qdir.h + qprinter.h + qpainter.h + qurl.h + qstatusbar.h + qlineedit.h + qsettings.h + qcheckbox.h + tabbedbrowser.h + qptrlist.h + qguardedptr.h + qmap.h + finddialog.h + qstringlist.h + helpwindow.h + mainwindow.ui.h + + + class SettingsDialog; + class HelpDialog; + class TabbedBrowser; + class QTimerEvent; + + + QPtrList<QAction> *goActions; + int setupCompleted:1; + TabbedBrowser *tabs; + SettingsDialog * settingsDia; + QMap<int, QString> bookmarks; + HelpDialog *helpDock; + QDockWindow *dw; + QGuardedPtr<FindDialog> findDialog; + static QPtrList<MainWindow> *windows; + QMap<QAction*,QString> *goActionDocFiles; + QStringList pendingLinks; + QPtrList<HelpWindow> pendingBrowsers + + + init() + setup() + destroy() + about() + aboutApplication() + find() + findAgain() + findAgainPrev() + goHome() + print() + updateBookmarkMenu() + setupBookmarkMenu() + showBookmark( int id ) + showLinkFromClient( const QString & link ) + showLink( const QString & link ) + showLinks( const QStringList & links ) + showQtHelp() + showSettingsDialog() + showWebBrowserSettings() + showSettingsDialog( int page ) + hide() + newWindow() + saveSettings() + saveToolbarSettings() + showSearchLink( const QString & link, const QStringList & terms ) + showGoActionLink() + showAssistantHelp() + updateProfileSettings() + backwardAvailable(bool) + forwardAvailable(bool) + browserTabChanged() + + + setupGoActions() + insertActionSeparator() + close( bool alsoDelete ) + browsers() + helpDialog() + timerEvent(QTimerEvent *) + + + + diff --git a/tools/assistant/mainwindow.ui.h b/tools/assistant/mainwindow.ui.h new file mode 100644 index 0000000..75acd89 --- /dev/null +++ b/tools/assistant/mainwindow.ui.h @@ -0,0 +1,698 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the Qt Assistant. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "config.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QPtrList *MainWindow::windows = 0; + +#if defined(Q_WS_WIN) +extern Q_EXPORT int qt_ntfs_permission_lookup; +#endif + +void MainWindow::init() +{ +#if defined(Q_WS_WIN) + // Workaround for QMimeSourceFactory failing in QFileInfo::isReadable() for + // certain user configs. See task: 34372 + qt_ntfs_permission_lookup = 0; +#endif + setupCompleted = FALSE; + + goActions = new QPtrList; + goActionDocFiles = new QMap; + goActions->setAutoDelete( TRUE ); + + if ( !windows ) + windows = new QPtrList; + windows->append( this ); + tabs = new TabbedBrowser( this, "qt_assistant_tabbedbrowser" ); + setCentralWidget( tabs ); + settingsDia = 0; + + Config *config = Config::configuration(); + + updateProfileSettings(); + + dw = new QDockWindow( QDockWindow::InDock, this ); + helpDock = new HelpDialog( dw, this ); + dw->setResizeEnabled( TRUE ); + dw->setCloseMode( QDockWindow::Always ); + addDockWindow( dw, DockLeft ); + dw->setWidget( helpDock ); + dw->setCaption( "Sidebar" ); + dw->setFixedExtentWidth( 320 ); + + // read geometry configuration + setupGoActions(); + + if ( !config->isMaximized() ) { + QRect geom = config->geometry(); + if( geom.isValid() ) { + resize(geom.size()); + move(geom.topLeft()); + } + } + + QString mainWindowLayout = config->mainWindowLayout(); + + QTextStream ts( &mainWindowLayout, IO_ReadOnly ); + ts >> *this; + + if ( config->sideBarHidden() ) + dw->hide(); + + tabs->setup(); + QTimer::singleShot( 0, this, SLOT( setup() ) ); +#if defined(Q_OS_MACX) + // Use the same forward and backward browser shortcuts as Safari and Internet Explorer do + // on the Mac. This means that if you have access to one of those cool Intellimice, the thing + // works just fine, since that's how Microsoft hacked it. + actionGoPrevious->setAccel(QKeySequence(Qt::CTRL|Qt::Key_Left)); + actionGoNext->setAccel(QKeySequence(Qt::CTRL|Qt::Key_Right)); +#endif +} + +void MainWindow::setup() +{ + if( setupCompleted ) + return; + + qApp->setOverrideCursor( QCursor( Qt::WaitCursor ) ); + statusBar()->message( tr( "Initializing Qt Assistant..." ) ); + setupCompleted = TRUE; + helpDock->initialize(); + connect( actionGoPrevious, SIGNAL( activated() ), tabs, SLOT( backward() ) ); + connect( actionGoNext, SIGNAL( activated() ), tabs, SLOT( forward() ) ); + connect( actionEditCopy, SIGNAL( activated() ), tabs, SLOT( copy() ) ); + connect( actionFileExit, SIGNAL( activated() ), qApp, SLOT( closeAllWindows() ) ); + connect( actionAddBookmark, SIGNAL( activated() ), + helpDock, SLOT( addBookmark() ) ); + connect( helpDock, SIGNAL( showLink( const QString& ) ), + this, SLOT( showLink( const QString& ) ) ); + connect( helpDock, SIGNAL( showSearchLink( const QString&, const QStringList& ) ), + this, SLOT( showSearchLink( const QString&, const QStringList&) ) ); + + connect( bookmarkMenu, SIGNAL( activated( int ) ), + this, SLOT( showBookmark( int ) ) ); + connect( actionZoomIn, SIGNAL( activated() ), tabs, SLOT( zoomIn() ) ); + connect( actionZoomOut, SIGNAL( activated() ), tabs, SLOT( zoomOut() ) ); + + connect( actionOpenPage, SIGNAL( activated() ), tabs, SLOT( newTab() ) ); + connect( actionClosePage, SIGNAL( activated() ), tabs, SLOT( closeTab() ) ); + connect( actionNextPage, SIGNAL( activated() ), tabs, SLOT( nextTab() ) ); + connect( actionPrevPage, SIGNAL( activated() ), tabs, SLOT( previousTab() ) ); + + + +#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64) + QAccel *acc = new QAccel( this ); +// acc->connectItem( acc->insertItem( Key_F5 ), browser, SLOT( reload() ) ); + acc->connectItem( acc->insertItem( QKeySequence("SHIFT+CTRL+=") ), actionZoomIn, SIGNAL(activated()) ); +#endif + + QAccel *a = new QAccel( this, dw ); + a->connectItem( a->insertItem( QAccel::stringToKey( tr("Ctrl+T") ) ), + helpDock, SLOT( toggleContents() ) ); + a->connectItem( a->insertItem( QAccel::stringToKey( tr("Ctrl+I") ) ), + helpDock, SLOT( toggleIndex() ) ); + a->connectItem( a->insertItem( QAccel::stringToKey( tr("Ctrl+B") ) ), + helpDock, SLOT( toggleBookmarks() ) ); + a->connectItem( a->insertItem( QAccel::stringToKey( tr("Ctrl+S") ) ), + helpDock, SLOT( toggleSearch() ) ); + + Config *config = Config::configuration(); + + setupBookmarkMenu(); + PopupMenu->insertItem( tr( "Vie&ws" ), createDockWindowMenu() ); + helpDock->tabWidget->setCurrentPage( config->sideBarPage() ); + + qApp->restoreOverrideCursor(); + actionGoPrevious->setEnabled( FALSE ); + actionGoNext->setEnabled( FALSE ); +} + +void MainWindow::setupGoActions() +{ + Config *config = Config::configuration(); + QStringList titles = config->docTitles(); + QAction *action = 0; + + static bool separatorInserted = FALSE; + + QAction *cur = goActions->first(); + while( cur ) { + cur->removeFrom( goMenu ); + cur->removeFrom( goActionToolbar ); + cur = goActions->next(); + } + goActions->clear(); + goActionDocFiles->clear(); + + int addCount = 0; + + QStringList::ConstIterator it = titles.begin(); + for ( ; it != titles.end(); ++it ) { + QString title = *it; + QPixmap pix = config->docIcon( title ); + if( !pix.isNull() ) { + if( !separatorInserted ) { + goMenu->insertSeparator(); + separatorInserted = TRUE; + } + action = new QAction( title, QIconSet( pix ), title, 0, 0 ); + action->addTo( goMenu ); + action->addTo( goActionToolbar ); + goActions->append( action ); + goActionDocFiles->insert( action, config->indexPage( title ) ); + connect( action, SIGNAL( activated() ), + this, SLOT( showGoActionLink() ) ); + ++addCount; + } + } + if( !addCount ) + goActionToolbar->hide(); + else + goActionToolbar->show(); + +} + +void MainWindow::browserTabChanged() +{ + if (tabs->currentBrowser()) { + actionGoPrevious->setEnabled(tabs->currentBrowser()->isBackwardAvailable()); + actionGoNext->setEnabled(tabs->currentBrowser()->isForwardAvailable()); + } +} + +bool MainWindow::insertActionSeparator() +{ + goMenu->insertSeparator(); + Toolbar->addSeparator(); + return TRUE; +} + +bool MainWindow::close( bool alsoDelete ) +{ + saveSettings(); + return QMainWindow::close( alsoDelete ); +} + +void MainWindow::destroy() +{ + windows->removeRef( this ); + if ( windows->isEmpty() ) { + delete windows; + windows = 0; + } + delete goActions; + delete goActionDocFiles; +} + +void MainWindow::about() +{ + QMessageBox box( this ); + box.setText( "
" + "

Version " + QString(QT_VERSION_STR) + "

" + "

Copyright (C) 2000-2008 Trolltech ASA. All rights reserved." + "

" + "

Qt Commercial Edition license holders: This program is" + " licensed to you under the terms of the Qt Commercial License" + " Agreement. For details, see the file LICENSE that came with" + " this software distribution.

" + "

Qt Open Source Edition users: This program is licensed to you" + " under the terms of the GNU General Public License Version 2." + " For details, see the file LICENSE.GPL that came with this" + " software distribution.

The program is provided AS IS" + " with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF" + " DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE." + "

" ); + box.setCaption( tr( "Qt Assistant" ) ); + box.setIcon( QMessageBox::NoIcon ); + box.exec(); +} + +void MainWindow::aboutApplication() +{ + QString url = Config::configuration()->aboutURL(); + if ( url == "about_qt" ) { + QMessageBox::aboutQt( this, "Qt Assistant" ); + return; + } + QString text; + QFile file( url ); + if( file.exists() && file.open( IO_ReadOnly ) ) + text = QString( file.readAll() ); + if( text.isNull() ) + text = tr( "Failed to open about application contents in file: '%1'" ).arg( url ); + + QMessageBox box( this ); + box.setText( text ); + box.setCaption( Config::configuration()->aboutApplicationMenuText() ); + box.setIcon( QMessageBox::NoIcon ); + box.exec(); +} + +void MainWindow::find() +{ + if ( !findDialog ) + findDialog = new FindDialog( this ); + findDialog->comboFind->setFocus(); + findDialog->comboFind->lineEdit()->setSelection( + 0, findDialog->comboFind->lineEdit()->text().length() ); + findDialog->show(); +} + +void MainWindow::findAgain() +{ + if (!findDialog || !findDialog->hasFindExpression()) { + find(); + return; + } + findDialog->doFind(TRUE); +} + +void MainWindow::findAgainPrev() +{ + if (!findDialog || !findDialog->hasFindExpression()) { + find(); + return; + } + findDialog->doFind(FALSE); +} + +void MainWindow::goHome() +{ + showLink( Config::configuration()->homePage() ); +} + +void MainWindow::print() +{ + QPrinter printer( QPrinter::HighResolution ); + printer.setFullPage( TRUE ); + if ( printer.setup( this ) ) { + QPainter p; + if ( !p.begin( &printer ) ) + return; + + qApp->setOverrideCursor( QCursor( Qt::WaitCursor ) ); + qApp->eventLoop()->processEvents( QEventLoop::ExcludeUserInput ); + + QPaintDeviceMetrics metrics(p.device()); + QTextBrowser *browser = tabs->currentBrowser(); + int dpiy = metrics.logicalDpiY(); + int margin = (int) ( (2/2.54)*dpiy ); + QRect view( margin, + margin, + metrics.width() - 2 * margin, + metrics.height() - 2 * margin ); + QSimpleRichText richText( browser->text(), browser->QWidget::font(), browser->context(), + browser->styleSheet(), browser->mimeSourceFactory(), + view.height(), Qt::black, FALSE ); + richText.setWidth( &p, view.width() ); + int page = 1; + do { + qApp->eventLoop()->processEvents( QEventLoop::ExcludeUserInput ); + + richText.draw( &p, margin, margin, view, palette().active() ); + view.moveBy( 0, view.height() ); + p.translate( 0 , -view.height() ); + p.drawText( view.right() - p.fontMetrics().width( QString::number(page) ), + view.bottom() + p.fontMetrics().ascent() + 5, QString::number(page) ); + if ( view.top() - margin >= richText.height() ) + break; + printer.newPage(); + page++; + } while (TRUE); + + qApp->eventLoop()->processEvents( QEventLoop::ExcludeUserInput ); + qApp->restoreOverrideCursor(); + } +} + +void MainWindow::updateBookmarkMenu() +{ + for ( MainWindow *mw = windows->first(); mw; mw = windows->next() ) + mw->setupBookmarkMenu(); +} + +void MainWindow::setupBookmarkMenu() +{ + bookmarkMenu->clear(); + bookmarks.clear(); + actionAddBookmark->addTo( bookmarkMenu ); + + QFile f( QDir::homeDirPath() + "/.assistant/bookmarks." + + Config::configuration()->profileName() ); + if ( !f.open( IO_ReadOnly ) ) + return; + QTextStream ts( &f ); + bookmarkMenu->insertSeparator(); + while ( !ts.atEnd() ) { + QString title = ts.readLine(); + QString link = ts.readLine(); + bookmarks.insert( bookmarkMenu->insertItem( title ), link ); + } +} + +void MainWindow::showBookmark( int id ) +{ + if ( bookmarks.find( id ) != bookmarks.end() ) + showLink( *bookmarks.find( id ) ); +} + +void MainWindow::showLinkFromClient( const QString &link ) +{ + setWindowState(windowState() & ~WindowMinimized); + raise(); + setActiveWindow(); + showLink( link ); +} + +void MainWindow::showLink( const QString &link ) +{ + if( link.isEmpty() ) { + qWarning( "The link is empty!" ); + } + + int find = link.find( '#' ); + QString name = find >= 0 ? link.left( find ) : link; + + QString absLink = link; + QFileInfo fi( name ); + if ( fi.isRelative() ) { + if ( find >= 0 ) + absLink = fi.absFilePath() + link.right( link.length() - find ); + else + absLink = fi.absFilePath(); + } + if( fi.exists() ) { + tabs->setSource( absLink ); + tabs->currentBrowser()->setFocus(); + } else { + // ### Default 404 site! + statusBar()->message( tr( "Failed to open link: '%1'" ).arg( link ), 5000 ); + tabs->currentBrowser()->setText( tr( "

The page could not be found!


" + "

'%1'

").arg( link ) ); + tabs->updateTitle( tr( "Error..." ) ); + } +} + +void MainWindow::showLinks( const QStringList &links ) +{ + if ( links.size() == 0 ) { + qWarning( "MainWindow::showLinks() - Empty link" ); + return; + } + + if ( links.size() == 1 ) { + showLink( links.first() ); + return; + } + + pendingLinks = links; + + QStringList::ConstIterator it = pendingLinks.begin(); + // Initial showing, The tab is empty so update that without creating it first + if ( tabs->currentBrowser()->source().isEmpty() ) { + pendingBrowsers.append(tabs->currentBrowser()); + tabs->setTitle(tabs->currentBrowser(), pendingLinks.first()); + } + ++it; + + while( it != pendingLinks.end() ) { + pendingBrowsers.append( tabs->newBackgroundTab(*it) ); + ++it; + } + + startTimer(50); + return; +} + +void MainWindow::timerEvent(QTimerEvent *e) +{ + QString link = pendingLinks.first(); + HelpWindow *win = pendingBrowsers.first(); + pendingLinks.pop_front(); + pendingBrowsers.removeFirst(); + if (pendingLinks.size() == 0) + killTimer(e->timerId()); + win->setSource(link); +} + +void MainWindow::showQtHelp() +{ + showLink( QString( qInstallPathDocs() ) + "/html/index.html" ); +} + +void MainWindow::showSettingsDialog() +{ + showSettingsDialog( -1 ); +} + +void MainWindow::showWebBrowserSettings() +{ + showSettingsDialog( 1 ); +} + +void MainWindow::showSettingsDialog( int page ) +{ + if ( !settingsDia ){ + settingsDia = new SettingsDialog( this ); + } + QFontDatabase fonts; + settingsDia->fontCombo->clear(); + settingsDia->fontCombo->insertStringList( fonts.families() ); + settingsDia->fontCombo->lineEdit()->setText( tabs->browserFont().family() ); + settingsDia->fixedfontCombo->clear(); + settingsDia->fixedfontCombo->insertStringList( fonts.families() ); + settingsDia->fixedfontCombo->lineEdit()->setText( tabs->styleSheet()->item( "pre" )->fontFamily() ); + settingsDia->linkUnderlineCB->setChecked( tabs->linkUnderline() ); + settingsDia->colorButton->setPaletteBackgroundColor( tabs->palette().color( QPalette::Active, QColorGroup::Link ) ); + if ( page != -1 ) + settingsDia->settingsTab->setCurrentPage( page ); + + int ret = settingsDia->exec(); + + if ( ret != QDialog::Accepted ) + return; + + QObjectList *lst = (QObjectList*)Toolbar->children(); + QObject *obj; + for ( obj = lst->last(); obj; obj = lst->prev() ) { + if ( obj->isA( "QToolBarSeparator" ) ) { + delete obj; + obj = 0; + break; + } + } + + setupGoActions(); + + QFont fnt( tabs->browserFont() ); + fnt.setFamily( settingsDia->fontCombo->currentText() ); + tabs->setBrowserFont( fnt ); + tabs->setLinkUnderline( settingsDia->linkUnderlineCB->isChecked() ); + + QPalette pal = tabs->palette(); + QColor lc = settingsDia->colorButton->paletteBackgroundColor(); + pal.setColor( QPalette::Active, QColorGroup::Link, lc ); + pal.setColor( QPalette::Inactive, QColorGroup::Link, lc ); + pal.setColor( QPalette::Disabled, QColorGroup::Link, lc ); + tabs->setPalette( pal ); + + QString family = settingsDia->fixedfontCombo->currentText(); + + QStyleSheet *sh = tabs->styleSheet(); + sh->item( "pre" )->setFontFamily( family ); + sh->item( "code" )->setFontFamily( family ); + sh->item( "tt" )->setFontFamily( family ); + tabs->currentBrowser()->setText( tabs->currentBrowser()->text() ); + showLink( tabs->currentBrowser()->source() ); +} + +void MainWindow::hide() +{ + saveToolbarSettings(); + QMainWindow::hide(); +} + +MainWindow* MainWindow::newWindow() +{ + saveSettings(); + saveToolbarSettings(); + MainWindow *mw = new MainWindow; + mw->move( geometry().topLeft() ); + if ( isMaximized() ) + mw->showMaximized(); + else + mw->show(); + mw->goHome(); + return mw; +} + +void MainWindow::saveSettings() +{ + Config *config = Config::configuration(); + config->setFontFamily( tabs->browserFont().family() ); + config->setFontSize( tabs->currentBrowser()->font().pointSize() ); + config->setFontFixedFamily( tabs->styleSheet()->item( "pre" )->fontFamily() ); + config->setLinkUnderline( tabs->linkUnderline() ); + config->setLinkColor( tabs->palette().color( QPalette::Active, QColorGroup::Link ).name() ); + config->setSideBarPage( helpDock->tabWidget->currentPageIndex() ); + config->setGeometry( QRect( x(), y(), width(), height() ) ); + config->setMaximized( isMaximized() ); + + // Create list of the tab urls + QStringList lst; + QPtrList browsers = tabs->browsers(); + HelpWindow *browser = browsers.first(); + while (browser) { + lst << browser->source(); + browser = browsers.next(); + } + config->setSource(lst); + config->save(); +} + +void MainWindow::saveToolbarSettings() +{ + QString mainWindowLayout; + QTextStream ts( &mainWindowLayout, IO_WriteOnly ); + ts << *this; + Config::configuration()->setMainWindowLayout( mainWindowLayout ); +} + +TabbedBrowser* MainWindow::browsers() +{ + return tabs; +} + +void MainWindow::showSearchLink( const QString &link, const QStringList &terms ) +{ + HelpWindow * hw = tabs->currentBrowser(); + hw->blockScrolling( TRUE ); + hw->setCursor( waitCursor ); + if ( hw->source() == link ) + hw->reload(); + else + showLink( link ); + hw->sync(); + hw->setCursor( arrowCursor ); + + hw->viewport()->setUpdatesEnabled( FALSE ); + int minPar = INT_MAX; + int minIndex = INT_MAX; + QStringList::ConstIterator it = terms.begin(); + for ( ; it != terms.end(); ++it ) { + int para = 0; + int index = 0; + bool found = hw->find( *it, FALSE, TRUE, TRUE, ¶, &index ); + while ( found ) { + if ( para < minPar ) { + minPar = para; + minIndex = index; + } + hw->setColor( red ); + found = hw->find( *it, FALSE, TRUE, TRUE ); + } + } + hw->blockScrolling( FALSE ); + hw->viewport()->setUpdatesEnabled( TRUE ); + hw->setCursorPosition( minPar, minIndex ); + hw->updateContents(); +} + + +void MainWindow::showGoActionLink() +{ + const QObject *origin = sender(); + if( !origin || + origin->metaObject()->className() != QString( "QAction" ) ) + return; + + QAction *action = (QAction*) origin; + QString docfile = *( goActionDocFiles->find( action ) ); + showLink( docfile ); +} + +void MainWindow::showAssistantHelp() +{ + showLink( Config::configuration()->assistantDocPath() + "/assistant.html" ); +} + +HelpDialog* MainWindow::helpDialog() +{ + return helpDock; +} + +void MainWindow::backwardAvailable( bool enable ) +{ + actionGoPrevious->setEnabled( enable ); +} + +void MainWindow::forwardAvailable( bool enable ) +{ + actionGoNext->setEnabled( enable ); +} + +void MainWindow::updateProfileSettings() +{ + Config *config = Config::configuration(); +#ifndef Q_WS_MACX + setIcon( config->applicationIcon() ); +#endif + helpMenu->clear(); + actionHelpAssistant->addTo( helpMenu ); + helpMenu->insertSeparator(); + helpAbout_Qt_AssistantAction->addTo( helpMenu ); + if ( !config->aboutApplicationMenuText().isEmpty() ) + actionAboutApplication->addTo( helpMenu ); + helpMenu->insertSeparator(); + actionHelpWhatsThis->addTo( helpMenu ); + + actionAboutApplication->setMenuText( config->aboutApplicationMenuText() ); + + if( !config->title().isNull() ) + setCaption( config->title() ); +} diff --git a/tools/assistant/profile.cpp b/tools/assistant/profile.cpp new file mode 100644 index 0000000..be83f2a --- /dev/null +++ b/tools/assistant/profile.cpp @@ -0,0 +1,124 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the Qt Assistant. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ +#include "profile.h" +#include +#include +#include +#include +#include + +#define QT_TITLE "Qt Reference Documentation" +#define DESIGNER_TITLE "Qt Designer Manual" +#define ASSISTANT_TITLE "Qt Assistant Manual" +#define LINGUIST_TITLE "Guide to the Qt Translation Tools" +#define QMAKE_TITLE "qmake User Guide" + +Profile *Profile::createDefaultProfile( const QString &docPath ) +{ + QString path = qInstallPathDocs(); + if ( !docPath.isEmpty() ) + path = docPath; + path = path + "/html/"; + Profile *profile = new Profile; + profile->valid = TRUE; + profile->type = DefaultProfile; + profile->props["name"] = "default"; + profile->props["applicationicon"] = "appicon.png"; + profile->props["aboutmenutext"] = "About Qt"; + profile->props["abouturl"] = "about_qt"; + profile->props["title"] = "Qt Assistant"; + profile->props["basepath"] = path; + profile->props["startpage"] = path + "index.html"; + + profile->addDCFTitle( path + "qt.dcf", QT_TITLE ); + profile->addDCFTitle( path + "designer.dcf", DESIGNER_TITLE ); + profile->addDCFTitle( path + "assistant.dcf", ASSISTANT_TITLE ); + profile->addDCFTitle( path + "linguist.dcf", LINGUIST_TITLE ); + profile->addDCFTitle( path + "qmake.dcf", QMAKE_TITLE ); + + profile->addDCFIcon( QT_TITLE, "qt.png" ); + profile->addDCFIcon( DESIGNER_TITLE, "designer.png" ); + profile->addDCFIcon( ASSISTANT_TITLE, "assistant.png" ); + profile->addDCFIcon( LINGUIST_TITLE, "linguist.png" ); + + profile->addDCFIndexPage( QT_TITLE, path + "index.html" ); + profile->addDCFIndexPage( DESIGNER_TITLE, path + "designer-manual.html" ); + profile->addDCFIndexPage( ASSISTANT_TITLE, path + "assistant.html" ); + profile->addDCFIndexPage( LINGUIST_TITLE, path + "linguist-manual.html" ); + profile->addDCFIndexPage( QMAKE_TITLE, path + "qmake-manual.html" ); + + profile->addDCFImageDir( QT_TITLE, "../../gif/" ); + profile->addDCFImageDir( DESIGNER_TITLE, "../../gif/" ); + profile->addDCFImageDir( ASSISTANT_TITLE, "../../gif/" ); + profile->addDCFImageDir( LINGUIST_TITLE, "../../gif/" ); + profile->addDCFImageDir( QMAKE_TITLE, "../../gif/" ); + + return profile; +} + + +Profile::Profile() + : valid( TRUE ), dparser( 0 ) +{ +} + + +void Profile::removeDocFileEntry( const QString &docfile ) +{ + docs.remove( docfile ); + + QStringList titles; + + for( QMap::Iterator it = dcfTitles.begin(); + it != dcfTitles.end(); ++it ) { + if( (*it) == docfile ) { + indexPages.remove( *it ); + icons.remove( *it ); + imageDirs.remove( *it ); + titles << it.key(); + } + } + + for( QStringList::ConstIterator title = titles.begin(); + title != titles.end(); ++title ) { + + dcfTitles.remove( *title ); + } + +#ifdef ASSISTANT_DEBUG + qDebug( "docs:\n - " + docs.join( "\n - " ) ); + qDebug( "titles:\n - " + titles.join( "\n - " ) ); + qDebug( "keys:\n - " + ( (QStringList*) &(dcfTitles.keys()) )->join( "\n - " ) ); + qDebug( "values:\n - " + ( (QStringList*) &(dcfTitles.values()) )->join( "\n - " ) ); +#endif +} diff --git a/tools/assistant/profile.h b/tools/assistant/profile.h new file mode 100644 index 0000000..dfa7159 --- /dev/null +++ b/tools/assistant/profile.h @@ -0,0 +1,130 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the Qt Assistant. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef PROFILE_H +#define PROFILE_H + +#include +#include +#include +#include + +class DocuParser; + +class Profile +{ +public: + enum ProfileType { DefaultProfile, UserProfile }; + Profile(); + + inline bool isValid() const; + + inline void addDCF( const QString &docfile ); + inline void addDCFIcon( const QString title, const QString &icon ); + inline void addDCFIndexPage( const QString title, const QString &indexPage ); + inline void addDCFImageDir( const QString title, const QString &imgDir ); + inline void addDCFTitle( const QString &dcf, const QString &title ); + inline void addProperty( const QString &name, const QString &value ); + inline bool hasDocFile( const QString &docFile ); + void removeDocFileEntry( const QString &title ); + + inline ProfileType profileType() const { return type; } + inline void setProfileType( ProfileType t ) { type = t; } + + inline DocuParser *docuParser() const { return dparser; } + inline void setDocuParser( DocuParser *dp ) { dparser = dp; } + + static Profile* createDefaultProfile( const QString &docPath = QString::null ); + static QString makeRelativePath( const QString &base, const QString &path ); + + int valid:1; + ProfileType type; + DocuParser *dparser; + QMap props; + QMap icons; + QMap indexPages; + QMap imageDirs; + QMap dcfTitles; + QStringList docs; +}; + + +inline bool Profile::isValid() const +{ + return valid; +} + +inline void Profile::addDCFTitle(const QString &dcf, const QString &title) +{ + QString absdcf = QFileInfo(dcf).absFilePath(); + dcfTitles[title] = absdcf; + if (docs.contains(absdcf) == 0) + docs << absdcf; +} + +inline void Profile::addDCF( const QString &docfile ) +{ + if( !docs.contains( docfile ) == 0 ) + docs << docfile; +} + +inline void Profile::addDCFIcon( const QString docfile, + const QString &icon ) +{ + icons[docfile] = icon; +} + +inline void Profile::addDCFIndexPage( const QString title, + const QString &indexPage ) +{ + indexPages[title] = indexPage; +} + +inline void Profile::addDCFImageDir( const QString docfile, + const QString &imgDir ) +{ + imageDirs[docfile] = imgDir; +} + +inline void Profile::addProperty( const QString &name, + const QString &value ) +{ + props[name] = value; +} + +inline bool Profile::hasDocFile( const QString &name ) +{ + return docs.contains( name ) > 0; +} + +#endif diff --git a/tools/assistant/settingsdialog.ui b/tools/assistant/settingsdialog.ui new file mode 100644 index 0000000..0b949fe --- /dev/null +++ b/tools/assistant/settingsdialog.ui @@ -0,0 +1,516 @@ + +SettingsDialogBase +********************************************************************* +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of Qt Assistant. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +********************************************************************* + + + SettingsDialogBase + + + + 0 + 0 + 389 + 253 + + + + Qt Assistant - Settings + + + true + + + + unnamed + + + + settingsTab + + + + 5 + 5 + 0 + 0 + + + + + tab + + + &General + + + + unnamed + + + + Layout2 + + + + unnamed + + + + fixedfontCombo + + + + 7 + 0 + 0 + 0 + + + + true + + + + + TextLabel1 + + + Fix&ed font: + + + fixedfontCombo + + + + + TextLabel2 + + + Link color: + + + + + fontCombo + + + + 7 + 0 + 0 + 0 + + + + true + + + + + fontLabel + + + &Font: + + + fontCombo + + + + + linkUnderlineCB + + + &Underline links + + + true + + + + + colorButton + + + + 0 + 0 + 0 + 0 + + + + + 40 + 20 + + + + + 255 + 0 + 0 + + + + TabFocus + + + + + + + + + + + + tab + + + &Web + + + + unnamed + + + + Spacer11 + + + Vertical + + + Expanding + + + + 20 + 30 + + + + + + TextLabel1_3 + + + Web &Browser Application: + + + browserApp + + + + + Layout9 + + + + unnamed + + + + browserApp + + + + + buttonBrowse + + + + 1 + 0 + 0 + 0 + + + + + 30 + 32767 + + + + ... + + + + + + + TextLabel1_3_3 + + + &Home page + + + homePage + + + + + layout8 + + + + unnamed + + + + homePage + + + + + buttonHome + + + + 1 + 0 + 0 + 0 + + + + + 30 + 32767 + + + + ... + + + + + + + + + pdfTab + + + &PDF + + + + unnamed + + + + TextLabel1_3_2 + + + PDF &Application + + + pdfApp + + + + + spacer10 + + + Vertical + + + Expanding + + + + 20 + 81 + + + + + + layout9 + + + + unnamed + + + + pdfApp + + + + + buttonPDF + + + + 1 + 0 + 0 + 0 + + + + + 30 + 32767 + + + + ... + + + + + + + + + + Layout1 + + + + unnamed + + + + Horizontal Spacing2 + + + Horizontal + + + Expanding + + + + 0 + 20 + + + + + + buttonOk + + + &OK + + + true + + + true + + + + + buttonCancel + + + &Cancel + + + true + + + + + + + + + buttonOk + clicked() + SettingsDialogBase + accept() + + + buttonCancel + clicked() + SettingsDialogBase + reject() + + + colorButton + clicked() + SettingsDialogBase + selectColor() + + + buttonBrowse + clicked() + SettingsDialogBase + browseWebApp() + + + buttonHome + clicked() + SettingsDialogBase + browseHomepage() + + + buttonPDF + clicked() + SettingsDialogBase + browsePDFApplication() + + + + settingsTab + fontCombo + fixedfontCombo + colorButton + linkUnderlineCB + browserApp + buttonBrowse + homePage + buttonHome + pdfApp + buttonPDF + buttonOk + buttonCancel + + + selectColor() + browseWebApp() + browsePDFApplication() + browseHomepage() + + + diff --git a/tools/assistant/settingsdialogimpl.cpp b/tools/assistant/settingsdialogimpl.cpp new file mode 100644 index 0000000..0d3ebea --- /dev/null +++ b/tools/assistant/settingsdialogimpl.cpp @@ -0,0 +1,122 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of Qt Assistant. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "settingsdialogimpl.h" +#include "docuparser.h" +#include "config.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +SettingsDialog::SettingsDialog( QWidget *parent, const char* name ) + : SettingsDialogBase( parent, name ) +{ + init(); +} + +void SettingsDialog::init() +{ + Config *config = Config::configuration(); + + browserApp->setText( config->webBrowser() ); + homePage->setText( config->homePage() ); + pdfApp->setText( config->pdfReader() ); +} + +void SettingsDialog::selectColor() +{ + QColor c = QColorDialog::getColor( colorButton->paletteBackgroundColor(), this ); + colorButton->setPaletteBackgroundColor( c ); +} + +void SettingsDialog::browseWebApp() +{ + setFile( browserApp, tr( "Qt Assistant - Set Web Browser" ) ); +} + +void SettingsDialog::browsePDFApplication() +{ + setFile( pdfApp, tr( "Qt Assistant - Set PDF Browser" ) ); +} + +void SettingsDialog::browseHomepage() +{ + setFile( homePage, tr( "Qt Assistant - Set Homepage" ) ); +} + +void SettingsDialog::setFile( QLineEdit *le, const QString &caption ) +{ + QFileDialog *fd = new QFileDialog( this ); + fd->setCaption( caption ); + fd->setMode( QFileDialog::AnyFile ); + fd->setDir( QDir::homeDirPath() ); + + if ( fd->exec() == QDialog::Accepted ) { + if ( !fd->selectedFile().isEmpty() ) + le->setText( fd->selectedFile() ); + } +} + +void SettingsDialog::accept() +{ + Config *config = Config::configuration(); + + config->setWebBrowser( browserApp->text() ); + config->setHomePage( homePage->text() ); + config->setPdfReader( pdfApp->text() ); + + hide(); + done( Accepted ); +} + +void SettingsDialog::reject() +{ + init(); + done( Rejected ); +} diff --git a/tools/assistant/settingsdialogimpl.h b/tools/assistant/settingsdialogimpl.h new file mode 100644 index 0000000..12ddc6c --- /dev/null +++ b/tools/assistant/settingsdialogimpl.h @@ -0,0 +1,63 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of Qt Assistant. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef SETTINGSDIALOGIMPL_H +#define SETTINGSDIALOGIMPL_H + +#include "settingsdialog.h" + +#include +#include +#include + +class SettingsDialog : public SettingsDialogBase +{ + Q_OBJECT + +public: + SettingsDialog( QWidget *parent, const char* name = 0 ); + +protected slots: + void selectColor(); + void browseWebApp(); + void browsePDFApplication(); + void browseHomepage(); + void accept(); + void reject(); + +private: + void init(); + void setFile( QLineEdit *le, const QString &caption ); +}; + +#endif diff --git a/tools/assistant/tabbedbrowser.ui b/tools/assistant/tabbedbrowser.ui new file mode 100644 index 0000000..10affc8 --- /dev/null +++ b/tools/assistant/tabbedbrowser.ui @@ -0,0 +1,141 @@ + +TabbedBrowser +********************************************************************* +** Copyright (C) 2003-2008 Trolltech ASA. All rights reserved. +** +** This file is part of Qt Assistant. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +********************************************************************* + + + TabbedBrowser + + + + 0 + 0 + 710 + 681 + + + + TabbedBrowser + + + + unnamed + + + 0 + + + 0 + + + + tab + + + + frontpage + + + Untitled + + + + unnamed + + + + + + + + qsettings.h + helpwindow.h + mainwindow.h + qstylesheet.h + qmime.h + tabbedbrowser.ui.h + + + class HelpWindow; + class MainWindow; + class QStyleSheet; + class QMimeSourceFactory; + + + QStyleSheet *tabStyleSheet; + bool tabLinkUnderline; + QMimeSourceFactory *mimeSourceFactory; + QWidget *lastCurrentTab; + QFont tabFont; + + + forward() + backward() + setSource( const QString & ref ) + reload() + home() + nextTab() + previousTab() + newTab( const QString & lnk ) + zoomIn() + zoomOut() + updateTitle( const QString & title ) + newTab() + transferFocus() + initHelpWindow( HelpWindow * win ) + setup() + setLinkUnderline( bool uline ) + setPalette( const QPalette & pal ) + copy() + closeTab() + sourceChanged() + + + currentBrowser() + init() + mainWindow() + styleSheet() + linkUnderline() + sources() + setMimePath( QStringList lst ) + setMimeExtension( const QString & ext ) + setBrowserFont( const QFont & fnt ) + browserFont() + browsers() const + newBackgroundTab( const QString & url ) + createHelpWindow(const QString &) + setTitle(HelpWindow*, const QString &) + + + + diff --git a/tools/assistant/tabbedbrowser.ui.h b/tools/assistant/tabbedbrowser.ui.h new file mode 100644 index 0000000..bb7fd61 --- /dev/null +++ b/tools/assistant/tabbedbrowser.ui.h @@ -0,0 +1,347 @@ +/**************************************************************************** +** ui.h extension file, included from the uic-generated form implementation. +** +** If you wish to add, delete or rename functions or slots use +** Qt Designer which will update this file, preserving your code. Create an +** init() function in place of a constructor, and a destroy() function in +** place of a destructor. +*****************************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include "config.h" + +static QString reduceLabelLength( const QString &s ) +{ + uint maxLength = 16; + QString str = s; + if ( str.length() < maxLength ) + return str; + str = str.left( maxLength - 3 ); + str += "..."; + return str; +} + +void TabbedBrowser::forward() +{ + currentBrowser()->forward(); +} + +void TabbedBrowser::backward() +{ + currentBrowser()->backward(); +} + +void TabbedBrowser::setSource( const QString &ref ) +{ + HelpWindow * win = currentBrowser(); + win->setSource(ref); +} + +void TabbedBrowser::reload() +{ + currentBrowser()->reload(); +} + +void TabbedBrowser::home() +{ + currentBrowser()->home(); +} + +HelpWindow * TabbedBrowser::currentBrowser() +{ + return (HelpWindow*) tab->currentPage(); +} + +void TabbedBrowser::nextTab() +{ + if( tab->currentPageIndex()<=tab->count()-1 ) + tab->setCurrentPage( tab->currentPageIndex()+1 ); +} + +void TabbedBrowser::previousTab() +{ + int idx = tab->currentPageIndex()-1; + if( idx>=0 ) + tab->setCurrentPage( idx ); +} + +HelpWindow *TabbedBrowser::createHelpWindow(const QString &title) +{ + MainWindow *mainWin = mainWindow(); + HelpWindow *win = new HelpWindow( mainWin, this, "qt_assistant_helpwin" ); + win->setFont( browserFont() ); + win->setPalette( palette() ); + win->setLinkUnderline( tabLinkUnderline ); + win->setStyleSheet( tabStyleSheet ); + win->setMimeSourceFactory( mimeSourceFactory ); + tab->addTab(win, reduceLabelLength(title)); + connect( win, SIGNAL( highlighted( const QString & ) ), + (const QObject*) (mainWin->statusBar()), SLOT( message( const QString & ) ) ); + connect( win, SIGNAL( chooseWebBrowser() ), mainWin, SLOT( showWebBrowserSettings() ) ); + connect( win, SIGNAL( backwardAvailable(bool) ), + mainWin, SLOT( backwardAvailable(bool) ) ); + connect( win, SIGNAL( forwardAvailable(bool) ), + mainWin, SLOT( forwardAvailable(bool) ) ); + connect( win, SIGNAL( sourceChanged(const QString &) ), this, SLOT( sourceChanged() )); + + tab->cornerWidget( Qt::TopRight )->setEnabled( tab->count() > 1 ); + return win; +} + +HelpWindow *TabbedBrowser::newBackgroundTab( const QString &url ) +{ + HelpWindow *win = createHelpWindow(url); + return win; +} + +void TabbedBrowser::newTab( const QString &lnk ) +{ + QString link( lnk ); + if( link.isNull() ) { + HelpWindow *w = currentBrowser(); + if( w ) + link = w->source(); + } + HelpWindow *win = createHelpWindow(link); + tab->showPage( win ); + if( !link.isNull() ) { + win->setSource( link ); + } +} + +void TabbedBrowser::zoomIn() +{ + currentBrowser()->zoomIn(); +} + +void TabbedBrowser::zoomOut() +{ + currentBrowser()->zoomOut(); +} + +void TabbedBrowser::init() +{ + tabLinkUnderline = FALSE; + tabStyleSheet = new QStyleSheet( QStyleSheet::defaultSheet() ); + lastCurrentTab = 0; + while( tab->count() ) + tab->removePage( tab->page(0) ); + + mimeSourceFactory = new QMimeSourceFactory(); + mimeSourceFactory->setExtensionType("html","text/html;charset=UTF-8"); + mimeSourceFactory->setExtensionType("htm","text/html;charset=UTF-8"); + mimeSourceFactory->setExtensionType("png", "image/png" ); + mimeSourceFactory->setExtensionType("jpg", "image/jpeg" ); + mimeSourceFactory->setExtensionType("jpeg", "image/jpeg" ); + setMimePath( Config::configuration()->mimePaths() ); + + connect( tab, SIGNAL( currentChanged( QWidget* ) ), + this, SLOT( transferFocus() ) ); + connect( tab, SIGNAL( currentChanged( QWidget* ) ), + mainWindow(), SLOT( browserTabChanged() ) ); + + QTabBar *tabBar = (QTabBar*)tab->child( 0, "QTabBar", FALSE ); + int m = ( tabBar ? style().pixelMetric( QStyle::PM_TabBarTabVSpace, (QWidget*)tabBar ) + + style().pixelMetric( QStyle::PM_TabBarBaseHeight, (QWidget*)tabBar ) : 0 ); + int s = tab->height() - m; + + // workaround for sgi style + QPalette pal = palette(); + pal.setColor(QPalette::Active, QColorGroup::Button, pal.active().background()); + pal.setColor(QPalette::Disabled, QColorGroup::Button, pal.disabled().background()); + pal.setColor(QPalette::Inactive, QColorGroup::Button, pal.inactive().background()); + + QToolButton *newTabButton = new QToolButton( this ); + newTabButton->setPalette(pal); + tab->setCornerWidget( newTabButton, Qt::TopLeft ); + newTabButton->setCursor( arrowCursor ); + newTabButton->setAutoRaise( TRUE ); + newTabButton->setPixmap( QPixmap::fromMimeSource( "addtab.png" ) ); + newTabButton->setFixedSize( s, s ); + QObject::connect( newTabButton, SIGNAL( clicked() ), this, SLOT( newTab() ) ); + QToolTip::add( newTabButton, tr( "Add page" ) ); + + QToolButton *closeTabButton = new QToolButton( this ); + closeTabButton->setPalette(pal); + tab->setCornerWidget( closeTabButton, Qt::TopRight ); + closeTabButton->setCursor( arrowCursor ); + closeTabButton->setAutoRaise( TRUE ); + QIconSet is( QPixmap::fromMimeSource( "closetab.png") ); + QPixmap disabledPix = QPixmap::fromMimeSource( "d_closetab.png" ); + is.setPixmap( disabledPix, QIconSet::Small, QIconSet::Disabled ); + closeTabButton->setIconSet( is ); + closeTabButton->setFixedSize( s, s ); + QObject::connect( closeTabButton, SIGNAL( clicked() ), this, SLOT( closeTab() ) ); + QToolTip::add( closeTabButton, tr( "Close page" ) ); + closeTabButton->setEnabled( FALSE ); +} + +void TabbedBrowser::setMimePath( QStringList lst ) +{ + mimeSourceFactory->setFilePath( lst ); +} + +void TabbedBrowser::setMimeExtension( const QString &ext ) +{ + mimeSourceFactory->setExtensionType( "html", ext ); + mimeSourceFactory->setExtensionType( "htm", ext ); +} + +void TabbedBrowser::updateTitle( const QString &title ) +{ + tab->changeTab( currentBrowser(), title ); +} + +MainWindow* TabbedBrowser::mainWindow() +{ + return (MainWindow*) parent(); +} + +void TabbedBrowser::newTab() +{ + newTab( QString::null ); +} + +void TabbedBrowser::transferFocus() +{ + if( currentBrowser() ) { + currentBrowser()->setFocus(); + } + mainWindow()->setCaption(Config::configuration()->title() + + " - " + currentBrowser()->documentTitle()); +} + +void TabbedBrowser::initHelpWindow( HelpWindow * /*win*/ ) +{ +} + +void TabbedBrowser::setup() +{ + Config *config = Config::configuration(); + + QFont fnt( font() ); + QFontInfo fntInfo( fnt ); + fnt.setFamily( config->fontFamily() ); + fnt.setPointSize( config->fontSize() ); + setBrowserFont( fnt ); + + QPalette pal = palette(); + QColor lc( config->linkColor() ); + pal.setColor( QPalette::Active, QColorGroup::Link, lc ); + pal.setColor( QPalette::Inactive, QColorGroup::Link, lc ); + pal.setColor( QPalette::Disabled, QColorGroup::Link, lc ); + setPalette( pal ); + + tabLinkUnderline = config->isLinkUnderline(); + + QString family = config->fontFixedFamily(); + tabStyleSheet->item( "pre" )->setFontFamily( family ); + tabStyleSheet->item( "code" )->setFontFamily( family ); + tabStyleSheet->item( "tt" )->setFontFamily( family ); + + newTab( QString::null ); +} + +void TabbedBrowser::setLinkUnderline( bool uline ) +{ + if( uline==tabLinkUnderline ) + return; + tabLinkUnderline = uline; + int cnt = tab->count(); + for( int i=0; ipage( i ) )->setLinkUnderline( tabLinkUnderline ); +} + +QFont TabbedBrowser::browserFont() +{ + return tabFont; +} + +void TabbedBrowser::setBrowserFont( const QFont &fnt ) +{ + if( tabFont == fnt ) + return; + tabFont = fnt; + int cnt = tab->count(); + for( int i=0; ipage( i ) )->setFont( fnt ); +} + +void TabbedBrowser::setPalette( const QPalette &pal ) +{ + if( palette()==pal ) + return; + QWidget::setPalette( pal ); + int cnt = tab->count(); + for( int i=0; ipage( i ) )->setPalette( pal ); +} + +QStyleSheet* TabbedBrowser::styleSheet() +{ + return tabStyleSheet; +} + +bool TabbedBrowser::linkUnderline() +{ + return tabLinkUnderline; +} + +void TabbedBrowser::copy() +{ + currentBrowser()->copy(); +} + +void TabbedBrowser::closeTab() +{ + if( tab->count()==1 ) + return; + HelpWindow *win = currentBrowser(); + tab->removePage( win ); + QTimer::singleShot(0, win, SLOT(deleteLater())); + tab->cornerWidget( Qt::TopRight )->setEnabled( tab->count() > 1 ); +} + +QStringList TabbedBrowser::sources() +{ + QStringList lst; + int cnt = tab->count(); + for( int i=0; ipage(i) )->source() ); + } + return lst; +} + +QPtrList TabbedBrowser::browsers() const +{ + QPtrList list; + for (int i=0; icount(); ++i) { + Q_ASSERT(::qt_cast(tab->page(i))); + list.append(::qt_cast(tab->page(i))); + } + return list; +} + +void TabbedBrowser::sourceChanged() +{ + HelpWindow *win = ::qt_cast( QObject::sender() ); + Q_ASSERT( win ); + QString docTitle(win->documentTitle()); + if (docTitle.isEmpty()) + docTitle = "..."; + setTitle(win, docTitle); +} + +void TabbedBrowser::setTitle(HelpWindow *win, const QString &title) +{ + tab->setTabLabel(win, reduceLabelLength(title)); + if (win == currentBrowser()) + mainWindow()->setCaption(Config::configuration()->title() + " - " + title); +} + diff --git a/tools/assistant/topicchooser.ui b/tools/assistant/topicchooser.ui new file mode 100644 index 0000000..d87f2c9 --- /dev/null +++ b/tools/assistant/topicchooser.ui @@ -0,0 +1,182 @@ + +TopicChooserBase +********************************************************************* +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of Qt Assistant. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +********************************************************************* + + + TopicChooserBase + + + + 0 + 0 + 391 + 223 + + + + Choose Topic + + + true + + + Select a topic from the list and click the <b>Display</b>-button to open the online help. + + + + unnamed + + + 11 + + + 6 + + + + label + + + &Topics + + + listbox + + + + + listbox + + + Displays a list of available help topics for the keyword. + + + + + Layout16 + + + + unnamed + + + 0 + + + 6 + + + + Horizontal Spacing2 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + buttonDisplay + + + &Display + + + true + + + true + + + Open the topic selected in the list. + + + + + buttonCancel + + + &Close + + + true + + + Close the Dialog. + + + + + + + + + buttonDisplay + clicked() + TopicChooserBase + accept() + + + buttonCancel + clicked() + TopicChooserBase + reject() + + + listbox + doubleClicked(QListBoxItem*) + TopicChooserBase + accept() + + + listbox + returnPressed(QListBoxItem*) + TopicChooserBase + accept() + + + + init() + destroy() + + + diff --git a/tools/assistant/topicchooserimpl.cpp b/tools/assistant/topicchooserimpl.cpp new file mode 100644 index 0000000..799a894 --- /dev/null +++ b/tools/assistant/topicchooserimpl.cpp @@ -0,0 +1,70 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of Qt Assistant. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "topicchooserimpl.h" + +#include +#include +#include + +TopicChooser::TopicChooser( QWidget *parent, const QStringList &lnkNames, + const QStringList &lnks, const QString &title ) + : TopicChooserBase( parent, 0, TRUE ), links( lnks ), linkNames( lnkNames ) +{ + label->setText( tr( "Choose a topic for %1" ).arg( title ) ); + listbox->insertStringList( linkNames ); + listbox->setCurrentItem( listbox->firstItem() ); + listbox->setFocus(); +} + +QString TopicChooser::link() const +{ + if ( listbox->currentItem() == -1 ) + return QString::null; + QString s = listbox->currentText(); + if ( s.isEmpty() ) + return s; + int i = linkNames.findIndex( s ); + return links[ i ]; +} + +QString TopicChooser::getLink( QWidget *parent, const QStringList &lnkNames, + const QStringList &lnks, const QString &title ) +{ + TopicChooser *dlg = new TopicChooser( parent, lnkNames, lnks, title ); + QString lnk; + if ( dlg->exec() == QDialog::Accepted ) + lnk = dlg->link(); + delete dlg; + return lnk; +} diff --git a/tools/assistant/topicchooserimpl.h b/tools/assistant/topicchooserimpl.h new file mode 100644 index 0000000..f7e9b9a --- /dev/null +++ b/tools/assistant/topicchooserimpl.h @@ -0,0 +1,60 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of Qt Assistant. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TOPICCHOOSERIMPL_H +#define TOPICCHOOSERIMPL_H + +#include "topicchooser.h" + +#include + +class TopicChooser : public TopicChooserBase +{ + Q_OBJECT + +public: + TopicChooser( QWidget *parent, const QStringList &lnkNames, + const QStringList &lnks, const QString &title ); + + QString link() const; + + static QString getLink( QWidget *parent, const QStringList &lnkNames, + const QStringList &lnks, const QString &title ); + +private: + QString theLink; + QStringList links, linkNames; + +}; + +#endif -- cgit v1.2.1