├── LICENSE ├── README.original ├── README.rst ├── build.sh ├── images ├── backward.png ├── close.png ├── find.png ├── forward.png ├── load.png ├── open.png ├── print.png ├── rfcview.icns ├── rfcview.ico └── rfcview.png ├── rfcview.pro ├── screenshots ├── original.png └── osx.png └── src ├── TitleItem.cpp ├── TitleItem.h ├── TitleModel.cpp ├── TitleModel.h ├── cdialogfind.cpp ├── cdialogfind.h ├── cdialogsetdirectory.cpp ├── cdialogsetdirectory.h ├── cprintdialog.cpp ├── cprintdialog.h ├── find_dlg.ui ├── mainwindow.cpp ├── mainwindow.h ├── mdichild.cpp ├── mdichild.h ├── qrfceditor.cpp ├── qrfceditor.h ├── rfcloader.cpp ├── rfcloader.h ├── rfcview.cpp ├── rfcview.qrc ├── setdirectory_dlg.ui └── src.pro /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. 5 | 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Library General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License 307 | along with this program; if not, write to the Free Software 308 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 309 | 310 | 311 | Also add information on how to contact you by electronic and paper mail. 312 | 313 | If the program is interactive, make it output a short notice like this 314 | when it starts in an interactive mode: 315 | 316 | Gnomovision version 69, Copyright (C) year name of author 317 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 318 | This is free software, and you are welcome to redistribute it 319 | under certain conditions; type `show c' for details. 320 | 321 | The hypothetical commands `show w' and `show c' should show the appropriate 322 | parts of the General Public License. Of course, the commands you use may 323 | be called something other than `show w' and `show c'; they could even be 324 | mouse-clicks or menu items--whatever suits your program. 325 | 326 | You should also get your employer (if you work as a programmer) or your 327 | school, if any, to sign a "copyright disclaimer" for the program, if 328 | necessary. Here is a sample; alter the names: 329 | 330 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 331 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 332 | 333 | , 1 April 1989 334 | Ty Coon, President of Vice 335 | 336 | This General Public License does not permit incorporating your program into 337 | proprietary programs. If your program is a subroutine library, you may 338 | consider it more useful to permit linking proprietary applications with the 339 | library. If this is what you want to do, use the GNU Library General 340 | Public License instead of this License. 341 | -------------------------------------------------------------------------------- /README.original: -------------------------------------------------------------------------------- 1 | ==== qRFCView ==== 2 | 3 | == What is qRFCView? == 4 | 5 | qRFCView is a viewer for IETF RFC. 6 | 7 | Advantages: 8 | - automatic table of content, with direct opening of section; 9 | - handling of RFC internal cross-references; 10 | - automatic downloading of a referenced RFC from the IETF web site 11 | on a simple click; 12 | - caching of RFC in a local directory; 13 | - tab-browsing of RFC; 14 | - searching. 15 | 16 | It is available for Linux and Windows operating system (and 17 | potentially MacOS X). 18 | 19 | == How to install it? == 20 | 21 | qRFCView requires the Trolltech Qt4 library that is available under MAC OS, 22 | Windows and Linux platforms. Trolltech's dual license policy provides versions 23 | of Qt under the terms of the GNU General Public License (GPL). It can be 24 | downloaded from http://www.trolltech.com/products/qt/downloads. 25 | 26 | * Win32 building (WinNT/Win2k/WinXP) 27 | Makefile generation: qmake -win32 rfcview.pro 28 | qRFCView binary build: make 29 | Optionally, you can build a Windows installer 30 | 31 | * Unix building 32 | qmake -unix rfcview.pro 33 | qRFCView binary build: make 34 | 35 | * Win32 binary 36 | The qRFCView binary can be directly installed by using the provided Win32 37 | installer file. The following DLLs will be added to the windows system 38 | directory: 39 | - mingwm10.dll 40 | - QtCore4.dll 41 | - QtDesignerComponents4.dll 42 | - QtGui4.dll 43 | - QtNetwork4.dll 44 | 45 | == How to use it? == 46 | 47 | Just start it. Use "File>Load RFC..." to load a RFC by its number. 48 | 49 | Double-click on a table of content item to open the corresponding 50 | section. Internal links and referenced RFC are active hyperlinks, 51 | underlined in blue. 52 | 53 | One can set the default directories where RFC are saved using 54 | "Edit>Set Directories...". 55 | 56 | == License == 57 | 58 | qRFCView is free software, licensed under GNU GPL (see LICENSE file). 59 | 60 | == Contact == 61 | qRFCView has been developped at Mitsubishi Electric, ITE-TCL, France. 62 | qRFCView developer is Romain ROLLET . 63 | 64 | 65 | == Known bugs == 66 | 67 | #1 Under Windows, qRFCView sometimes doesn't close when exiting Windows while 68 | qRFCView is still open. 69 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | qRFCView-OSX: a RFC viewer for OSX 2 | ================================== 3 | 4 | qRFCView is a viewer for IETF RFC documents. Features: 5 | 6 | - Automatic table of content, with direct opening of section 7 | - Handling of RFC internal cross-references 8 | - Automatic downloading of a referenced RFC from the IETF web site 9 | with a simple click 10 | - Caching of RFC documents in a local directory 11 | - Searching 12 | 13 | This project is a fork of the original qRFCView (version 0.62) with some changes, 14 | mainly cosmetic, so that it looks nice on OSX. Original project is located here: 15 | http://qrfcview.berlios.de/ 16 | 17 | 18 | Original look on OSX 19 | -------------------- 20 | .. image:: https://github.com/saghul/qrfcview-osx/raw/master/screenshots/original.png 21 | 22 | 23 | New look on OSX 24 | --------------- 25 | .. image:: https://github.com/saghul/qrfcview-osx/raw/master/screenshots/osx.png 26 | 27 | 28 | Other changes 29 | ------------- 30 | - Added application icon (for bundle) 31 | - Added script for building a DMG easily 32 | - Removed limit on RFC number 33 | - Removed 'copy' button 34 | - Removed unneeded files for OSX 35 | 36 | 37 | Downloads 38 | --------- 39 | Check here: https://github.com/saghul/qrfcview-osx/downloads 40 | 41 | 42 | Building 43 | -------- 44 | Install the Qt SDK (tested with version 4.8.3) from here: http://qt-project.org/downloads 45 | 46 | Execute the build script: 47 | 48 | :: 49 | 50 | ./build.sh 51 | 52 | The resulting app bundle and DMG will be in bin/ 53 | 54 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [[ -f Makefile ]]; then 4 | make clean 5 | make distclean 6 | fi 7 | 8 | rm -rf bin/* 9 | qmake -spec macx-g++ 10 | make 11 | pushd bin 12 | macdeployqt qRFCView.app -dmg 13 | popd 14 | 15 | echo "Done!" 16 | 17 | -------------------------------------------------------------------------------- /images/backward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saghul/qrfcview-osx/dff3ee489a6aca0c20800219f7c207884f918023/images/backward.png -------------------------------------------------------------------------------- /images/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saghul/qrfcview-osx/dff3ee489a6aca0c20800219f7c207884f918023/images/close.png -------------------------------------------------------------------------------- /images/find.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saghul/qrfcview-osx/dff3ee489a6aca0c20800219f7c207884f918023/images/find.png -------------------------------------------------------------------------------- /images/forward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saghul/qrfcview-osx/dff3ee489a6aca0c20800219f7c207884f918023/images/forward.png -------------------------------------------------------------------------------- /images/load.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saghul/qrfcview-osx/dff3ee489a6aca0c20800219f7c207884f918023/images/load.png -------------------------------------------------------------------------------- /images/open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saghul/qrfcview-osx/dff3ee489a6aca0c20800219f7c207884f918023/images/open.png -------------------------------------------------------------------------------- /images/print.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saghul/qrfcview-osx/dff3ee489a6aca0c20800219f7c207884f918023/images/print.png -------------------------------------------------------------------------------- /images/rfcview.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saghul/qrfcview-osx/dff3ee489a6aca0c20800219f7c207884f918023/images/rfcview.icns -------------------------------------------------------------------------------- /images/rfcview.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saghul/qrfcview-osx/dff3ee489a6aca0c20800219f7c207884f918023/images/rfcview.ico -------------------------------------------------------------------------------- /images/rfcview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saghul/qrfcview-osx/dff3ee489a6aca0c20800219f7c207884f918023/images/rfcview.png -------------------------------------------------------------------------------- /rfcview.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE=subdirs 2 | SUBDIRS=src 3 | -------------------------------------------------------------------------------- /screenshots/original.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saghul/qrfcview-osx/dff3ee489a6aca0c20800219f7c207884f918023/screenshots/original.png -------------------------------------------------------------------------------- /screenshots/osx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saghul/qrfcview-osx/dff3ee489a6aca0c20800219f7c207884f918023/screenshots/osx.png -------------------------------------------------------------------------------- /src/TitleItem.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | 3 | qRFCView, A smart IETF RFC viewer based on the Qt4 library. 4 | Copyright (C) 2005 Mitsubishi Electric ITE-TCL, R. Rollet (rollet@tcl.ite.mee.com) 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | *********************************************************************************/ 20 | 21 | #include 22 | 23 | #include "TitleItem.h" 24 | 25 | CTitleItem::CTitleItem(const QString &qTitle, const QString &qAnchor, CTitleItem *parent) 26 | { 27 | parentItem = parent; 28 | m_qTitle= qTitle; 29 | m_qAnchor=qAnchor; 30 | } 31 | 32 | CTitleItem::~CTitleItem() 33 | { 34 | qDeleteAll(childItems); 35 | } 36 | 37 | void CTitleItem::appendChild(CTitleItem *item) 38 | { 39 | childItems.append(item); 40 | } 41 | 42 | CTitleItem *CTitleItem::child(int row) 43 | { 44 | return childItems.value(row); 45 | } 46 | 47 | int CTitleItem::childCount() const 48 | { 49 | return childItems.count(); 50 | } 51 | 52 | CTitleItem *CTitleItem::parent() 53 | { 54 | return parentItem; 55 | } 56 | 57 | int CTitleItem::row() const 58 | { 59 | if (parentItem) 60 | return parentItem->childItems.indexOf(const_cast(this)); 61 | 62 | return 0; 63 | } 64 | -------------------------------------------------------------------------------- /src/TitleItem.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | 3 | qRFCView, A smart IETF RFC viewer based on the Qt4 library. 4 | Copyright (C) 2005 Mitsubishi Electric ITE-TCL, R. Rollet (rollet@tcl.ite.mee.com) 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | *********************************************************************************/ 20 | 21 | #ifndef TITLEITEM_H 22 | #define TITLEITEM_H 23 | 24 | #include 25 | #include 26 | 27 | class CTitleItem 28 | { 29 | public: 30 | CTitleItem(const QString &,const QString &, CTitleItem *parent=0); 31 | ~CTitleItem(); 32 | 33 | void appendChild(CTitleItem *child); 34 | 35 | CTitleItem *child(int row); 36 | int childCount() const; 37 | int columnCount() const {return 1;} 38 | QString GetTitle() {return m_qTitle;} 39 | 40 | int row() const; 41 | CTitleItem *parent(); 42 | QString GetAnchor() {return m_qAnchor;} 43 | 44 | private: 45 | QList childItems; 46 | QString m_qTitle; 47 | CTitleItem *parentItem; 48 | QString m_qAnchor; 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/TitleModel.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** qRFCView, A smart IETF RFC viewer based on the Qt4 library. 4 | ** Copyright (C) 2005 Mitsubishi Electric ITE-TCL, R. Rollet (rollet@tcl.ite.mee.com) 5 | ** Copyright (C) 2005-2005 Trolltech AS. All rights reserved. 6 | ** 7 | ** This file is part of the documentation of the Qt Toolkit. 8 | ** 9 | ** This file may be used under the terms of the GNU General Public 10 | ** License version 2.0 as published by the Free Software Foundation 11 | ** and appearing in the file LICENSE.GPL included in the packaging of 12 | ** this file. Please review the following information to ensure GNU 13 | ** General Public Licensing requirements will be met: 14 | ** http://www.trolltech.com/products/qt/opensource.html 15 | ** 16 | ** If you are unsure which license is appropriate for your use, please 17 | ** review the following information: 18 | ** http://www.trolltech.com/products/qt/licensing.html or contact the 19 | ** sales department at sales@trolltech.com. 20 | ** 21 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 22 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 23 | ** 24 | ****************************************************************************/ 25 | 26 | #include 27 | #include "TitleItem.h" 28 | #include "TitleModel.h" 29 | 30 | CTitleModel::CTitleModel(const QString &qRFCName, QObject *parent) 31 | : QAbstractItemModel(parent) 32 | { 33 | int iLevel; 34 | 35 | rootItem = new CTitleItem(qRFCName, 0); 36 | //setHeaderData(1, Qt::Horizontal, QString("Title"), Qt::DisplayRole); 37 | 38 | for (iLevel=0;iLevel(parent.internalPointer())->columnCount(); 55 | else 56 | return rootItem->columnCount(); 57 | } 58 | 59 | QVariant CTitleModel::data(const QModelIndex &index, int role) const 60 | { 61 | if (!index.isValid()) 62 | return QVariant(); 63 | 64 | if (role != Qt::DisplayRole) 65 | return QVariant(); 66 | 67 | CTitleItem *item = static_cast(index.internalPointer()); 68 | return item->GetTitle(); 69 | } 70 | 71 | Qt::ItemFlags CTitleModel::flags(const QModelIndex &index) const 72 | { 73 | if (!index.isValid()) 74 | return Qt::ItemIsEnabled; 75 | 76 | return Qt::ItemIsEnabled | Qt::ItemIsSelectable; 77 | } 78 | 79 | 80 | QVariant CTitleModel::headerData(int section, Qt::Orientation orientation, int role) const 81 | { 82 | Q_UNUSED(section); 83 | Q_UNUSED(orientation); 84 | Q_UNUSED(role); 85 | return QVariant(); 86 | } 87 | 88 | 89 | QModelIndex CTitleModel::index(int row, int column, const QModelIndex &parent) 90 | const 91 | { 92 | CTitleItem *parentItem; 93 | 94 | if (!parent.isValid()) 95 | parentItem = rootItem; 96 | else 97 | parentItem = static_cast(parent.internalPointer()); 98 | 99 | CTitleItem *childItem = parentItem->child(row); 100 | if (childItem) 101 | return createIndex(row, column, childItem); 102 | else 103 | return QModelIndex(); 104 | } 105 | 106 | QModelIndex CTitleModel::parent(const QModelIndex &index) const 107 | { 108 | if (!index.isValid()) 109 | return QModelIndex(); 110 | 111 | CTitleItem *childItem = static_cast(index.internalPointer()); 112 | CTitleItem *parentItem = childItem->parent(); 113 | 114 | if (parentItem == rootItem) 115 | return QModelIndex(); 116 | 117 | return createIndex(parentItem->row(), 0, parentItem); 118 | } 119 | 120 | int CTitleModel::rowCount(const QModelIndex &parent) const 121 | { 122 | CTitleItem *parentItem; 123 | 124 | if (!parent.isValid()) 125 | parentItem = rootItem; 126 | else 127 | parentItem = static_cast(parent.internalPointer()); 128 | 129 | return parentItem->childCount(); 130 | } 131 | 132 | bool CTitleModel::ParseTitle(const QString &qLevel, const QString &qTitle) 133 | { // Return true if title is valid 134 | int iLastDot=0,iNextDot; 135 | bool bOK; 136 | int iTitleLevel, iLevel; 137 | CTitleItem *pParentItem, *pChildItem; 138 | uint8_t iTitleNum[MAX_TITLE_LEVEL]; 139 | iTitleLevel=0; 140 | iLastDot=0; 141 | 142 | //qDebug() << qLevel+": "+qTitle; 143 | // Convert title level from ascii to binary (=>iTitleNum) 144 | while ( iTitleLevel=2) 187 | pParentItem=m_pCurrentTitleItem[iTitleLevel-2]; 188 | else 189 | pParentItem=rootItem; 190 | 191 | // Add a new item 192 | pChildItem=new CTitleItem(qLevel+" "+qTitle, "Title_"+qLevel, pParentItem ); 193 | pParentItem->appendChild(pChildItem); 194 | 195 | // Update the struture 196 | m_pCurrentTitleItem[iTitleLevel-1] = pChildItem; 197 | m_pCurrentTitleItem[iTitleLevel]=NULL; 198 | for (iLevel=0;iLevel 30 | #include 31 | #include 32 | 33 | #define MAX_TITLE_LEVEL 16 34 | 35 | class CTitleItem; 36 | 37 | class CTitleModel : public QAbstractItemModel 38 | { 39 | Q_OBJECT 40 | 41 | public: 42 | CTitleModel(const QString &data, QObject *parent = 0); 43 | ~CTitleModel(); 44 | 45 | QVariant data(const QModelIndex &index, int role) const; 46 | Qt::ItemFlags flags(const QModelIndex &index) const; 47 | QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; 48 | QModelIndex index(int row, int column, 49 | const QModelIndex &parent = QModelIndex()) const; 50 | QModelIndex parent(const QModelIndex &index) const; 51 | int rowCount(const QModelIndex &parent = QModelIndex()) const; 52 | int columnCount(const QModelIndex &parent = QModelIndex()) const; 53 | bool ParseTitle(const QString &qLevel, const QString &qTitle); 54 | 55 | private: 56 | uint8_t m_iCurrentValidTitleNum[MAX_TITLE_LEVEL]; 57 | uint8_t m_iCurrentValidTitleLevel; 58 | CTitleItem *m_pCurrentTitleItem[MAX_TITLE_LEVEL]; 59 | 60 | CTitleItem *rootItem; 61 | }; 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /src/cdialogfind.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | 3 | qRFCView, A smart IETF RFC viewer based on the Qt4 library. 4 | Copyright (C) 2005 Mitsubishi Electric ITE-TCL, R. Rollet (rollet@tcl.ite.mee.com) 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | *********************************************************************************/ 20 | 21 | #include "cdialogfind.h" 22 | #include 23 | CDialogFind::CDialogFind(QWidget *parent, QStringList *pPrevResearch, uint32_t iOptionFlags) 24 | : QDialog(parent) 25 | { 26 | Q_UNUSED(pPrevResearch); 27 | Q_UNUSED(iOptionFlags); 28 | m_ui.setupUi(this); 29 | connect(m_ui.findButton, SIGNAL(pressed()), this, SLOT(find() ) ); 30 | } 31 | 32 | 33 | CDialogFind::~CDialogFind() 34 | { 35 | } 36 | 37 | void CDialogFind::find() 38 | { 39 | // Add the search text to the combo 40 | if (m_ui.textComboBox->findText( m_ui.textComboBox->currentText() )==-1) 41 | m_ui.textComboBox->addItem(m_ui.textComboBox->currentText()); 42 | emit findnext(); 43 | } 44 | 45 | QString CDialogFind::GetTextToFind() 46 | { 47 | return m_ui.textComboBox->currentText(); 48 | } 49 | 50 | 51 | uint32_t CDialogFind::GetOptionFlags() 52 | { 53 | uint32_t iFlags=0; 54 | 55 | if (m_ui.regexpCheckBox->checkState() == Qt::Checked) 56 | iFlags|=FIND_OPTIONSFLAG_REGEXP; 57 | if (m_ui.wholeCheckBox->checkState() == Qt::Checked) 58 | iFlags|=FIND_OPTIONSFLAG_WHOLE; 59 | if (m_ui.caseCheckBox->checkState() == Qt::Checked) 60 | iFlags|=FIND_OPTIONSFLAG_CASE; 61 | if (m_ui.cursorCheckBox->checkState() == Qt::Checked) 62 | iFlags|=FIND_OPTIONSFLAG_CURSOR; 63 | if (m_ui.backwardCheckBox->checkState() == Qt::Checked) 64 | iFlags|=FIND_OPTIONSFLAG_BACKWARD; 65 | return iFlags; 66 | } 67 | 68 | void CDialogFind::SetOptionFlags(uint32_t iOptionFlags) 69 | { 70 | m_ui.regexpCheckBox->setCheckState((iOptionFlags&FIND_OPTIONSFLAG_REGEXP)?Qt::Checked:Qt::Unchecked); 71 | m_ui.wholeCheckBox->setCheckState((iOptionFlags&FIND_OPTIONSFLAG_WHOLE)?Qt::Checked:Qt::Unchecked); 72 | m_ui.caseCheckBox->setCheckState((iOptionFlags&FIND_OPTIONSFLAG_CASE)?Qt::Checked:Qt::Unchecked); 73 | m_ui.cursorCheckBox->setCheckState((iOptionFlags&FIND_OPTIONSFLAG_CURSOR)?Qt::Checked:Qt::Unchecked); 74 | m_ui.backwardCheckBox->setCheckState((iOptionFlags&FIND_OPTIONSFLAG_BACKWARD)?Qt::Checked:Qt::Unchecked); 75 | } 76 | 77 | -------------------------------------------------------------------------------- /src/cdialogfind.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | 3 | qRFCView, A smart IETF RFC viewer based on the Qt4 library. 4 | Copyright (C) 2005 Mitsubishi Electric ITE-TCL, R. Rollet (rollet@tcl.ite.mee.com) 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | *********************************************************************************/ 20 | 21 | #ifndef CDIALOGFIND_H 22 | #define CDIALOGFIND_H 23 | 24 | #include 25 | #include 26 | 27 | #define FIND_OPTIONSFLAG_REGEXP 0x01 28 | #define FIND_OPTIONSFLAG_CASE 0x02 29 | #define FIND_OPTIONSFLAG_WHOLE 0x04 30 | #define FIND_OPTIONSFLAG_CURSOR 0x08 31 | #define FIND_OPTIONSFLAG_BACKWARD 0x10 32 | 33 | /** 34 | @author Romain Rollet 35 | */ 36 | class CDialogFind : public QDialog 37 | { 38 | Q_OBJECT 39 | public: 40 | CDialogFind( QWidget *parent = 0, QStringList *pPrevResearch=NULL, uint32_t iOptionFlags=0); 41 | ~CDialogFind(); 42 | QString GetTextToFind(); 43 | uint32_t GetOptionFlags(); 44 | void SetOptionFlags(uint32_t iOptionFlags); 45 | 46 | signals: 47 | void findnext(); 48 | 49 | private slots: 50 | void find(); 51 | 52 | private: 53 | Ui_findDialog m_ui; 54 | 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/cdialogsetdirectory.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | 3 | qRFCView, A smart IETF RFC viewer based on the Qt4 library. 4 | Copyright (C) 2005 Mitsubishi Electric ITE-TCL, R. Rollet (rollet@tcl.ite.mee.com) 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | *********************************************************************************/ 20 | 21 | #include 22 | #include "cdialogsetdirectory.h" 23 | 24 | CDialogSetDirectory::CDialogSetDirectory( QStringList *pDirectoryList, uint8_t iDefaultDirRow, QString &qRFCURL, QWidget *parent) 25 | : QDialog(parent) 26 | { 27 | int i; 28 | QListWidgetItem *newItem; 29 | 30 | m_ui.setupUi(this); 31 | connect(m_ui.addButton, SIGNAL(pressed()), this, SLOT(addDirectoryToList()) ); 32 | connect(m_ui.remButton, SIGNAL(pressed()), this, SLOT(remDirectoryFromList()) ); 33 | connect(m_ui.applyButton, SIGNAL(pressed()), this, SLOT(accept() ) ); 34 | connect(m_ui.cancelButton, SIGNAL(pressed()), this, SLOT(reject() ) ); 35 | connect(m_ui.defaultButton, SIGNAL(pressed()), this, SLOT(setDefaultDirectory() ) ); 36 | m_ui.urlLineEdit->setText(qRFCURL); 37 | 38 | if (pDirectoryList!=NULL) 39 | { 40 | for (i = 0; i < pDirectoryList->size(); i++) 41 | { 42 | newItem = new QListWidgetItem( pDirectoryList->at(i) ); 43 | if (i==iDefaultDirRow) 44 | { 45 | QFont qFont=newItem->font(); 46 | qFont.setBold(true); 47 | newItem->setFont( qFont ); 48 | } 49 | m_ui.directoryList->addItem(newItem); 50 | } 51 | } 52 | m_iDefaultDirRow=iDefaultDirRow; 53 | } 54 | 55 | 56 | CDialogSetDirectory::~CDialogSetDirectory() 57 | { 58 | } 59 | 60 | int CDialogSetDirectory::GetDirectoryList(QStringList *pDirectoryList) 61 | { 62 | int i; 63 | 64 | pDirectoryList->clear(); 65 | for (i=0;icount();i++) 66 | { 67 | pDirectoryList->append( m_ui.directoryList->item(i)->text() ); 68 | } 69 | return m_iDefaultDirRow; 70 | } 71 | 72 | void CDialogSetDirectory::addDirectoryToList() 73 | { 74 | QString qDirectoryName = QFileDialog::getExistingDirectory( this, "Choose a directory"); 75 | 76 | if (!qDirectoryName.isEmpty()) 77 | { 78 | QListWidgetItem *newItem = new QListWidgetItem(qDirectoryName); 79 | m_ui.directoryList->addItem(newItem); 80 | } 81 | } 82 | 83 | void CDialogSetDirectory::remDirectoryFromList() 84 | { 85 | QListWidgetItem *pCurrentItem=m_ui.directoryList->currentItem(); 86 | if (pCurrentItem!=NULL) 87 | { 88 | // Update the default index 89 | if (m_iDefaultDirRow>m_ui.directoryList->currentRow()) 90 | m_iDefaultDirRow--; 91 | m_ui.directoryList->takeItem(m_ui.directoryList->currentRow() ); 92 | delete pCurrentItem; 93 | } 94 | } 95 | 96 | void CDialogSetDirectory::setDefaultDirectory() 97 | { 98 | QListWidgetItem *pCurrentItem=m_ui.directoryList->currentItem(); 99 | QListWidgetItem *pPrevDefaultItem=m_ui.directoryList->item(m_iDefaultDirRow); 100 | 101 | if (pCurrentItem!=NULL) 102 | { 103 | QFont qFont=pCurrentItem->font(); 104 | pPrevDefaultItem->setFont( qFont ); 105 | qFont.setBold(true); 106 | pCurrentItem->setFont( qFont ); 107 | m_iDefaultDirRow=m_ui.directoryList->currentRow(); 108 | } 109 | } 110 | 111 | -------------------------------------------------------------------------------- /src/cdialogsetdirectory.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | 3 | qRFCView, A smart IETF RFC viewer based on the Qt4 library. 4 | Copyright (C) 2005 Mitsubishi Electric ITE-TCL, R. Rollet (rollet@tcl.ite.mee.com) 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | *********************************************************************************/ 20 | 21 | #ifndef CDIALOGSETDIRECTORY_H 22 | #define CDIALOGSETDIRECTORY_H 23 | #include 24 | #include 25 | 26 | /** 27 | @author Romain Rollet 28 | */ 29 | 30 | class CDialogSetDirectory : public QDialog 31 | { 32 | Q_OBJECT 33 | public: 34 | CDialogSetDirectory(QStringList *pDirectoryList, uint8_t iDefaultDir, QString &qRFCURL, QWidget *parent = 0); 35 | 36 | ~CDialogSetDirectory(); 37 | int GetDirectoryList(QStringList *pDirectoryList); 38 | uint8_t GetDefaultDir() {return m_iDefaultDirRow;} 39 | QString GetRFCURL() {return m_ui.urlLineEdit->text();} 40 | 41 | private slots: 42 | void addDirectoryToList(); 43 | void remDirectoryFromList(); 44 | void setDefaultDirectory(); 45 | 46 | private: 47 | Ui_directoryDialog m_ui; 48 | uint8_t m_iDefaultDirRow; 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/cprintdialog.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | 3 | qRFCView, A smart IETF RFC viewer based on the Qt4 library. 4 | Copyright (C) 2005 Mitsubishi Electric ITE-TCL, R. Rollet (rollet@tcl.ite.mee.com) 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | *********************************************************************************/ 20 | 21 | #include 22 | 23 | CPrintDialog::CPrintDialog( QPrinter *p, QWidget *parent):QPrintDialog(p, parent) 24 | { 25 | setMinMax(1, 100); 26 | 27 | } 28 | 29 | CPrintDialog::~CPrintDialog() 30 | { 31 | } 32 | -------------------------------------------------------------------------------- /src/cprintdialog.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | 3 | qRFCView, A smart IETF RFC viewer based on the Qt4 library. 4 | Copyright (C) 2005 Mitsubishi Electric ITE-TCL, R. Rollet (rollet@tcl.ite.mee.com) 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | *********************************************************************************/ 20 | 21 | #ifndef CPRINTDIALOG_H 22 | #define CPRINTDIALOG_H 23 | 24 | #include 25 | /** 26 | @author Romain Rollet 27 | */ 28 | class CPrintDialog : public QPrintDialog 29 | { 30 | Q_OBJECT 31 | public: 32 | CPrintDialog(QPrinter *p, QWidget *parent = 0); 33 | ~CPrintDialog(); 34 | 35 | }; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/find_dlg.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | findDialog 6 | 7 | 8 | 9 | 0 10 | 0 11 | 400 12 | 260 13 | 14 | 15 | 16 | Dialog 17 | 18 | 19 | 20 | 8 21 | 22 | 23 | 6 24 | 25 | 26 | 27 | 28 | Find 29 | 30 | 31 | 32 | 8 33 | 34 | 35 | 6 36 | 37 | 38 | 39 | 40 | Text to find 41 | 42 | 43 | 44 | 45 | 46 | 47 | true 48 | 49 | 50 | 51 | 52 | 53 | 54 | 0 55 | 56 | 57 | 6 58 | 59 | 60 | 61 | 62 | Regular expression 63 | 64 | 65 | 66 | 67 | 68 | 69 | Qt::Horizontal 70 | 71 | 72 | 73 | 40 74 | 20 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | Options 88 | 89 | 90 | 91 | 8 92 | 93 | 94 | 6 95 | 96 | 97 | 98 | 99 | Whole words only 100 | 101 | 102 | 103 | 104 | 105 | 106 | Case sensitive 107 | 108 | 109 | 110 | 111 | 112 | 113 | From cursor 114 | 115 | 116 | 117 | 118 | 119 | 120 | Find backwards 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 0 131 | 132 | 133 | 6 134 | 135 | 136 | 137 | 138 | Qt::Horizontal 139 | 140 | 141 | 142 | 131 143 | 31 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | Find 152 | 153 | 154 | 155 | 156 | 157 | 158 | Close 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | closeButton 171 | clicked() 172 | findDialog 173 | close() 174 | 175 | 176 | 369 177 | 253 178 | 179 | 180 | 179 181 | 282 182 | 183 | 184 | 185 | 186 | 187 | -------------------------------------------------------------------------------- /src/mainwindow.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | 3 | qRFCView, A smart IETF RFC viewer based on the Qt4 library. 4 | Copyright (C) 2005 Mitsubishi Electric ITE-TCL, R. Rollet (rollet@tcl.ite.mee.com) 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | *********************************************************************************/ 20 | 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | #include "rfcloader.h" 33 | #include "mainwindow.h" 34 | #include "mdichild.h" 35 | #include "cdialogsetdirectory.h" 36 | #include "cdialogfind.h" 37 | #include "qrfceditor.h" 38 | #include "cprintdialog.h" 39 | 40 | MainWindow::MainWindow() 41 | { 42 | /* OSX style */ 43 | setUnifiedTitleAndToolBarOnMac(true); 44 | 45 | m_qTabWidget = new QTabWidget(); 46 | m_qTabWidget->setDocumentMode(true); 47 | m_qTabWidget->setTabsClosable(true); 48 | m_qTabWidget->setMovable(true); 49 | 50 | setCentralWidget(m_qTabWidget); 51 | 52 | connect(m_qTabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateMenus())); 53 | connect(m_qTabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(close_tab(int))); 54 | 55 | /* 56 | windowMapper = new QSignalMapper(this); 57 | connect(windowMapper, SIGNAL(mapped(QWidget *)), 58 | workspace, SLOT(setActiveWindow(QWidget *))); 59 | */ 60 | readSettings(); 61 | 62 | m_pRFCLoader = new QRFCLoader(this); 63 | connect(m_pRFCLoader, SIGNAL(done(QString)),this, SLOT(RFCReady(QString))); 64 | connect(m_pRFCLoader, SIGNAL(start(QString)),this, SLOT(RFCStart(QString))); 65 | 66 | open_dialog = new QFileDialog(this, Qt::Sheet); 67 | //open_dialog->setDirectory(QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "qRFCView"); 68 | open_dialog->setDirectory(m_pRFCLoader->GetDir()); 69 | open_dialog->setFileMode(QFileDialog::ExistingFile); 70 | open_dialog->setNameFilter("RFC documents (*.txt)"); 71 | open_dialog->setWindowModality(Qt::WindowModal); 72 | connect(open_dialog, SIGNAL(finished(int)), this, SLOT(open_dialog_finished(int))); 73 | 74 | createActions(); 75 | createMenus(); 76 | createToolBars(); 77 | createStatusBar(); 78 | updateMenus(); 79 | //m_pDialogFind=NULL; 80 | m_pDialogFind=new CDialogFind( this); 81 | connect(m_pDialogFind, SIGNAL(findnext()), this, SLOT(findnext())); 82 | setWindowTitle(tr("qRFCView")); 83 | //m_pRFCLoader->GetFile(794); 84 | 85 | } 86 | 87 | void MainWindow::closeEvent(QCloseEvent *event) 88 | { 89 | //workspace->closeAllWindows(); 90 | /* 91 | if (activeMdiChild()) { 92 | event->ignore(); 93 | } else { 94 | writeSettings(); 95 | event->accept(); 96 | }*/ 97 | writeSettings(); 98 | event->accept(); 99 | } 100 | 101 | void MainWindow::open_dialog_finished(int result) 102 | { 103 | if (result != QDialog::Accepted) 104 | return; 105 | 106 | QString fileName = fileName = open_dialog->selectedFiles().value(0); 107 | QFileInfo qFileInfo(fileName); 108 | 109 | if (fileName.isEmpty()) 110 | return; 111 | 112 | MdiChild *existing = findMdiChild(fileName); 113 | if (existing) { 114 | m_qTabWidget->setCurrentWidget(existing); 115 | return; 116 | } 117 | 118 | MdiChild *child = createMdiChild(qFileInfo.fileName()); 119 | if (child->loadFile(fileName)) { 120 | child->setCurrentFont(m_qFont); 121 | statusBar()->showMessage(tr("File loaded"), 2000); 122 | child->show(); 123 | } else { 124 | child->close(); 125 | } 126 | 127 | this->activateWindow(); 128 | this->raise(); 129 | 130 | } 131 | 132 | void MainWindow::close_tab(int index) 133 | { 134 | MdiChild *pMdiChild = qobject_cast(m_qTabWidget->widget(index)); 135 | if (pMdiChild) 136 | { 137 | m_qTabWidget->removeTab(index); 138 | delete pMdiChild; 139 | } 140 | 141 | updateMenus(); 142 | } 143 | 144 | void MainWindow::getrfc() 145 | { 146 | // Load a RFC number 147 | bool bOK; 148 | int iRFCNum = QInputDialog::getInt(this, tr("Please enter a RFC number"), 149 | tr("RFC#:"), 0, 1, std::numeric_limits::max(), 1, &bOK); 150 | if (bOK) 151 | RFCLoad( iRFCNum ); 152 | } 153 | 154 | void MainWindow::findOpen() 155 | { 156 | m_pDialogFind->show(); 157 | m_pDialogFind->raise(); 158 | m_pDialogFind->activateWindow(); 159 | } 160 | 161 | void MainWindow::findnext() 162 | { 163 | bool bResult; 164 | uint32_t iOptionFlags; 165 | 166 | QString qTextToFind=m_pDialogFind->GetTextToFind(); 167 | iOptionFlags=m_pDialogFind->GetOptionFlags(); 168 | MdiChild *pMdiChild=activeMdiChild(); 169 | if (pMdiChild && !qTextToFind.isEmpty() ) 170 | { 171 | bResult=pMdiChild->FindText(qTextToFind, iOptionFlags ); 172 | if (!bResult) 173 | statusBar()->showMessage(tr("No more occurence"), 3000); 174 | else 175 | statusBar()->clearMessage(); 176 | iOptionFlags|=FIND_OPTIONSFLAG_CURSOR; 177 | m_pDialogFind->SetOptionFlags(iOptionFlags); 178 | } 179 | updateMenus(); 180 | } 181 | 182 | void MainWindow::findprev() 183 | { 184 | bool bResult; 185 | uint32_t iOptionFlags; 186 | 187 | QString qTextToFind=m_pDialogFind->GetTextToFind(); 188 | iOptionFlags=m_pDialogFind->GetOptionFlags(); 189 | MdiChild *pMdiChild=activeMdiChild(); 190 | if (pMdiChild && !qTextToFind.isEmpty() ) 191 | { 192 | iOptionFlags|=FIND_OPTIONSFLAG_CURSOR|FIND_OPTIONSFLAG_BACKWARD; 193 | bResult=pMdiChild->FindText(qTextToFind, iOptionFlags ); 194 | if (!bResult) 195 | statusBar()->showMessage(tr("No more occurence"), 3000); 196 | else 197 | statusBar()->clearMessage(); 198 | 199 | } 200 | } 201 | 202 | void MainWindow::forward() 203 | { 204 | MdiChild *pMdiChild=activeMdiChild(); 205 | if (pMdiChild) 206 | pMdiChild->m_pTextEdit->forward(); 207 | } 208 | 209 | 210 | void MainWindow::backward() 211 | { 212 | MdiChild *pMdiChild=activeMdiChild(); 213 | if (pMdiChild) 214 | pMdiChild->m_pTextEdit->backward(); 215 | } 216 | 217 | void MainWindow::setFont() 218 | { 219 | bool bOK; 220 | MdiChild *pMDIChild; 221 | QFont qFont=QFontDialog::getFont(&bOK, m_qFont, this ); 222 | m_qFont=qFont; 223 | if (bOK) 224 | { 225 | for (int i=0;icount();i++) 226 | { 227 | pMDIChild = qobject_cast(m_qTabWidget->widget(i)); 228 | pMDIChild->setCurrentFont(m_qFont); 229 | } 230 | } 231 | } 232 | 233 | void MainWindow::print() 234 | { 235 | MdiChild *pMdiChild=activeMdiChild(); 236 | if (pMdiChild) 237 | { 238 | QPrinter printer(QPrinter::PrinterResolution); 239 | 240 | printer.setFullPage(true); 241 | printer.setNumCopies(2); 242 | QPrintDialog dlg(&printer, this); 243 | //dlg.setPrintRange(QAbstractPrintDialog::PageRange); 244 | dlg.setMinMax(1, pMdiChild->GetNbPages() ); 245 | //dlg.setFromTo(1, 2); 246 | //dlg.setEnabledOptions(QAbstractPrintDialog::PrintPageRange); 247 | 248 | if (dlg.exec() == QDialog::Accepted) { 249 | pMdiChild->Print(&printer, dlg.printRange()==QAbstractPrintDialog::AllPages, dlg.fromPage(), dlg.toPage() ); 250 | //pMdiChild->Print(&printer, false, 4,6); 251 | } 252 | 253 | } 254 | } 255 | 256 | void MainWindow::about() 257 | { 258 | QMessageBox::about(this, tr("About qRFCView"), 259 | tr("qRFCView
A smart RFC Viewer using the Qt4 library.

Mitsubishi Electric, 2005")); 260 | } 261 | 262 | void MainWindow::updateMenus() 263 | { 264 | /* 265 | bool hasMdiChild = (activeMdiChild() != 0); 266 | 267 | closeAct->setEnabled(hasMdiChild); 268 | closeAllAct->setEnabled(hasMdiChild); 269 | tileAct->setEnabled(hasMdiChild); 270 | cascadeAct->setEnabled(hasMdiChild); 271 | nextAct->setEnabled(hasMdiChild); 272 | previousAct->setEnabled(hasMdiChild); 273 | separatorAct->setVisible(hasMdiChild); 274 | */ 275 | findAct->setEnabled( activeMdiChild()!=NULL); 276 | printAct->setEnabled( activeMdiChild()!=NULL); 277 | findnextAct->setEnabled( activeMdiChild()!=NULL && (!m_pDialogFind->GetTextToFind().isEmpty()) ); 278 | findprevAct->setEnabled( activeMdiChild()!=NULL && (!m_pDialogFind->GetTextToFind().isEmpty()) ); 279 | forwardAct->setEnabled( activeMdiChild()!=NULL && activeMdiChild()->m_pTextEdit->isForwardAvailable() ); 280 | backwardAct->setEnabled( activeMdiChild()!=NULL && activeMdiChild()->m_pTextEdit->isBackwardAvailable() ); 281 | } 282 | 283 | void MainWindow::updateWindowMenu() 284 | { 285 | /* 286 | windowMenu->clear(); 287 | windowMenu->addAction(closeAct); 288 | windowMenu->addAction(closeAllAct); 289 | windowMenu->addSeparator(); 290 | windowMenu->addAction(tileAct); 291 | windowMenu->addAction(cascadeAct); 292 | windowMenu->addSeparator(); 293 | windowMenu->addAction(nextAct); 294 | windowMenu->addAction(previousAct); 295 | windowMenu->addAction(separatorAct); 296 | 297 | QList windows = workspace->windowList(); 298 | separatorAct->setVisible(!windows.isEmpty()); 299 | 300 | for (int i = 0; i < windows.size(); ++i) { 301 | MdiChild *child = qobject_cast(windows.at(i)); 302 | 303 | QString text; 304 | if (i < 9) { 305 | text = tr("&%1. %2").arg(i + 1) 306 | .arg(child->userFriendlyCurrentFile()); 307 | } else { 308 | text = tr("%1. %2").arg(i + 1) 309 | .arg(child->userFriendlyCurrentFile()); 310 | } 311 | QAction *action = windowMenu->addAction(text); 312 | action->setCheckable(true); 313 | action ->setChecked(child == activeMdiChild()); 314 | connect(action, SIGNAL(triggered()), windowMapper, SLOT(map())); 315 | windowMapper->setMapping(action, child); 316 | }*/ 317 | } 318 | 319 | MdiChild *MainWindow::createMdiChild(const QString &qTitle) 320 | { 321 | MdiChild *child = new MdiChild(); 322 | m_qTabWidget->addTab(child, qTitle); 323 | 324 | connect(child->m_pTextEdit, SIGNAL(RFCReq( uint32_t )), this, SLOT(RFCLoad( uint32_t )) ); 325 | connect(child->m_pTextEdit, SIGNAL(forwardAvailable(bool)), forwardAct, SLOT(setEnabled(bool)) ); 326 | connect(child->m_pTextEdit, SIGNAL(backwardAvailable(bool)), backwardAct, SLOT(setEnabled(bool)) ); 327 | m_qTabWidget->setCurrentWidget(child); 328 | return child; 329 | } 330 | 331 | void MainWindow::createActions() 332 | { 333 | openAct = new QAction(QIcon(":/images/open.png"), tr("&Open..."), this); 334 | openAct->setShortcut(tr("Ctrl+O")); 335 | openAct->setStatusTip(tr("Open an existing file")); 336 | connect(openAct, SIGNAL(triggered()), open_dialog, SLOT(open())); 337 | 338 | loadAct = new QAction(QIcon(":/images/load.png"), tr("&Load RFC..."), this); 339 | loadAct->setShortcut(tr("Ctrl+L")); 340 | loadAct->setStatusTip(tr("Load a RFC from its number")); 341 | connect(loadAct, SIGNAL(triggered()), this, SLOT(getrfc())); 342 | 343 | printAct = new QAction(QIcon(":/images/print.png"), tr("&Print..."), this); 344 | connect(printAct, SIGNAL(triggered()), this, SLOT(print())); 345 | 346 | exitAct = new QAction(tr("E&xit"), this); 347 | exitAct->setShortcut(tr("Ctrl+Q")); 348 | exitAct->setStatusTip(tr("Exit the application")); 349 | connect(exitAct, SIGNAL(triggered()), qApp, SLOT(closeAllWindows())); 350 | 351 | setFontAct = new QAction(QIcon(), tr("&Set Font..."), this); 352 | connect(setFontAct, SIGNAL(triggered()), this, SLOT(setFont())); 353 | 354 | forwardAct = new QAction(QIcon(":/images/forward.png"), tr("&Forward"), this); 355 | connect(forwardAct, SIGNAL(triggered()), this, SLOT(forward())); 356 | backwardAct = new QAction(QIcon(":/images/backward.png"), tr("&Backward"), this); 357 | connect(backwardAct, SIGNAL(triggered()),this, SLOT(backward())); 358 | findAct = new QAction(QIcon(":/images/find.png"), tr("&Find..."), this); 359 | findAct->setShortcut(tr("Ctrl+F")); 360 | findAct->setStatusTip(tr("Find a string in the currently opened file")); 361 | connect(findAct, SIGNAL(triggered()), this, SLOT(findOpen())); 362 | findnextAct = new QAction(QIcon(), tr("&Find Next"), this); 363 | findnextAct->setShortcut(tr("F3")); 364 | connect(findnextAct, SIGNAL(triggered()), this, SLOT(findnext())); 365 | findprevAct = new QAction(QIcon(), tr("&Find Previous"), this); 366 | findprevAct->setShortcut(tr("Shift+F3")); 367 | connect(findprevAct, SIGNAL(triggered()), this, SLOT(findprev())); 368 | 369 | /* 370 | 371 | 372 | closeAllAct = new QAction(tr("Close &All"), this); 373 | closeAllAct->setStatusTip(tr("Close all the windows")); 374 | connect(closeAllAct, SIGNAL(triggered()), 375 | workspace, SLOT(closeAllWindows())); 376 | 377 | tileAct = new QAction(tr("&Tile"), this); 378 | tileAct->setStatusTip(tr("Tile the windows")); 379 | connect(tileAct, SIGNAL(triggered()), workspace, SLOT(tile())); 380 | 381 | cascadeAct = new QAction(tr("&Cascade"), this); 382 | cascadeAct->setStatusTip(tr("Cascade the windows")); 383 | connect(cascadeAct, SIGNAL(triggered()), workspace, SLOT(cascade())); 384 | 385 | nextAct = new QAction(tr("Ne&xt"), this); 386 | nextAct->setShortcut(tr("Ctrl+F6")); 387 | nextAct->setStatusTip(tr("Move the focus to the next window")); 388 | connect(nextAct, SIGNAL(triggered()), 389 | workspace, SLOT(activateNextWindow())); 390 | 391 | previousAct = new QAction(tr("Pre&vious"), this); 392 | previousAct->setShortcut(tr("Ctrl+Shift+F6")); 393 | previousAct->setStatusTip(tr("Move the focus to the previous " 394 | "window")); 395 | connect(previousAct, SIGNAL(triggered()), 396 | workspace, SLOT(activatePreviousWindow())); 397 | 398 | separatorAct = new QAction(this); 399 | separatorAct->setSeparator(true); 400 | */ 401 | 402 | aboutAct = new QAction(tr("&About"), this); 403 | aboutAct->setStatusTip(tr("Show the application's About box")); 404 | connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); 405 | 406 | aboutQtAct = new QAction(tr("About &Qt"), this); 407 | aboutQtAct->setStatusTip(tr("Show the Qt library's About box")); 408 | connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt())); 409 | } 410 | 411 | void MainWindow::createMenus() 412 | { 413 | fileMenu = menuBar()->addMenu(tr("&File")); 414 | fileMenu->addAction(openAct); 415 | fileMenu->addAction(loadAct); 416 | fileMenu->addAction(printAct); 417 | fileMenu->addSeparator(); 418 | fileMenu->addAction(exitAct); 419 | 420 | editMenu = menuBar()->addMenu(tr("&Edit")); 421 | editMenu->addAction(backwardAct); 422 | editMenu->addAction(forwardAct); 423 | editMenu->addAction(findAct); 424 | editMenu->addAction(findprevAct); 425 | editMenu->addAction(findnextAct); 426 | editMenu->addSeparator(); 427 | editMenu->addAction(setFontAct); 428 | 429 | //windowMenu = menuBar()->addMenu(tr("&Window")); 430 | //connect(windowMenu, SIGNAL(aboutToShow()), this, SLOT(updateWindowMenu())); 431 | 432 | //menuBar()->addSeparator(); 433 | 434 | helpMenu = menuBar()->addMenu(tr("&Help")); 435 | helpMenu->addAction(aboutAct); 436 | helpMenu->addAction(aboutQtAct); 437 | } 438 | 439 | void MainWindow::createToolBars() 440 | { 441 | fileToolBar = addToolBar(tr("ToolBar")); 442 | fileToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); 443 | fileToolBar->addAction(openAct); 444 | fileToolBar->addAction(loadAct); 445 | fileToolBar->addAction(printAct); 446 | fileToolBar->addAction(findAct); 447 | fileToolBar->addAction(backwardAct); 448 | fileToolBar->addAction(forwardAct); 449 | } 450 | 451 | void MainWindow::createStatusBar() 452 | { 453 | m_pProgressBar=new QProgressBar(); 454 | m_pProgressBar->setRange(0,100); 455 | m_pProgressBar->setValue(50); 456 | connect(m_pRFCLoader->GetQHttp(), SIGNAL(dataReadProgress(int,int)), this, SLOT( updateRFCProgress(int,int))); 457 | statusBar()->showMessage(tr("Ready")); 458 | //statusBar()->addWidget(m_pProgressBar, 0); 459 | //qProgressBar.show(); 460 | } 461 | 462 | void MainWindow::readSettings() 463 | { 464 | QSettings settings("MELCO", "qRFCView"); 465 | QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint(); 466 | QSize size = settings.value("size", QSize(640, 480)).toSize(); 467 | m_qFont.setFamily(settings.value("Font_family", m_qFont.family()).toString() ); 468 | m_qFont.setPointSize(settings.value("Font_size", m_qFont.pointSize()).toInt() ); 469 | m_qFont.setWeight(settings.value("Font_weight", m_qFont.weight()).toInt()); 470 | m_qFont.setItalic(settings.value("Font_italic", m_qFont.italic()).toBool()); 471 | 472 | move(pos); 473 | resize(size); 474 | } 475 | 476 | void MainWindow::writeSettings() 477 | { 478 | QSettings settings("MELCO", "qRFCView"); 479 | settings.setValue("pos", pos()); 480 | settings.setValue("size", size()); 481 | settings.setValue("Font_family", m_qFont.family()); 482 | settings.setValue("Font_size", m_qFont.pointSize()); 483 | settings.setValue("Font_weight", m_qFont.weight()); 484 | settings.setValue("Font_italic", m_qFont.italic()); 485 | } 486 | 487 | MdiChild *MainWindow::activeMdiChild() 488 | { 489 | 490 | return qobject_cast(m_qTabWidget->currentWidget()); 491 | } 492 | 493 | MdiChild *MainWindow::findMdiChild(const QString &fileName) 494 | { 495 | QString canonicalFilePath = QFileInfo(fileName).canonicalFilePath(); 496 | 497 | for (int i=0;icount();i++) 498 | { 499 | MdiChild *mdiChild = qobject_cast(m_qTabWidget->widget(i)); 500 | if (mdiChild->currentFile() == canonicalFilePath) 501 | return mdiChild; 502 | } 503 | return 0; 504 | } 505 | 506 | void MainWindow::RFCLoad( uint32_t iRFCNum ) 507 | { 508 | QString qFilename=QString("rfc%1.txt").arg(iRFCNum); 509 | QFileInfo qFileInfo; 510 | 511 | // Check if the required RFC is not yet opened 512 | for (int i=0;icount();i++) 513 | { 514 | MdiChild *mdiChild = qobject_cast(m_qTabWidget->widget(i)); 515 | qFileInfo.setFile(mdiChild->currentFile()); 516 | if (qFileInfo.fileName() == qFilename) 517 | { 518 | m_qTabWidget->setCurrentWidget(mdiChild); 519 | return; 520 | } 521 | } 522 | 523 | m_pRFCLoader->GetFile(iRFCNum); 524 | } 525 | 526 | void MainWindow::RFCStart(const QString &qFilename) 527 | { // Start downloading a RFC file 528 | Q_UNUSED(qFilename); 529 | //statusBar()->showMessage(tr("Downloading ")+qFilename); 530 | statusBar()->clearMessage(); 531 | statusBar()->addWidget(m_pProgressBar, true); 532 | m_pProgressBar->show(); 533 | } 534 | 535 | void MainWindow::RFCReady(const QString &qFilename) 536 | { 537 | QFileInfo qFileInfo(qFilename); 538 | MdiChild *child = createMdiChild(qFileInfo.fileName()); 539 | if (child->loadFile(qFilename)) { 540 | child->setCurrentFont(m_qFont); 541 | child->show(); 542 | } else { 543 | child->close(); 544 | } 545 | statusBar()->showMessage(tr("Load ")+qFilename , 2000); 546 | statusBar()->removeWidget(m_pProgressBar); 547 | } 548 | 549 | void MainWindow::updateRFCProgress(int bytesRead, int totalBytes) 550 | { 551 | m_pProgressBar->setMaximum(totalBytes); 552 | m_pProgressBar->setValue(bytesRead); 553 | } 554 | -------------------------------------------------------------------------------- /src/mainwindow.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | 3 | qRFCView, A smart IETF RFC viewer based on the Qt4 library. 4 | Copyright (C) 2005 Mitsubishi Electric ITE-TCL, R. Rollet (rollet@tcl.ite.mee.com) 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | *********************************************************************************/ 20 | 21 | #ifndef MAINWINDOW_H 22 | #define MAINWINDOW_H 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | class QAction; 29 | class QMenu; 30 | class QWorkspace; 31 | class MdiChild; 32 | class QSignalMapper; 33 | class QRFCLoader; 34 | class QProgressBar; 35 | class CDialogFind; 36 | class QTabWidget; 37 | class QFileDialog; 38 | 39 | class MainWindow : public QMainWindow 40 | { 41 | Q_OBJECT 42 | 43 | public: 44 | MainWindow(); 45 | 46 | protected: 47 | void closeEvent(QCloseEvent *event); 48 | 49 | public slots: 50 | void RFCLoad(uint32_t); 51 | void RFCReady(const QString &qFileName); 52 | 53 | private slots: 54 | void getrfc(); 55 | void findOpen(); 56 | void findnext(); 57 | void findprev(); 58 | void about(); 59 | void setFont(); 60 | void updateMenus(); 61 | void updateWindowMenu(); 62 | void open_dialog_finished(int result); 63 | void close_tab(int index); 64 | MdiChild *createMdiChild(const QString &qTitle); 65 | 66 | void RFCStart(const QString &qFilename); 67 | void updateRFCProgress(int bytesRead, int totalBytes); 68 | void forward(); 69 | void backward(); 70 | void print(); 71 | 72 | 73 | private: 74 | void createActions(); 75 | void createMenus(); 76 | void createToolBars(); 77 | void createStatusBar(); 78 | void readSettings(); 79 | void writeSettings(); 80 | MdiChild *activeMdiChild(); 81 | MdiChild *findMdiChild(const QString &fileName); 82 | 83 | QTabWidget *m_qTabWidget; 84 | QFileDialog *open_dialog; 85 | QSignalMapper *windowMapper; 86 | 87 | QMenu *fileMenu; 88 | QMenu *editMenu; 89 | QMenu *windowMenu; 90 | QMenu *helpMenu; 91 | QToolBar *fileToolBar; 92 | QToolBar *editToolBar; 93 | QAction *openAct, *printAct, *closeAct, *loadAct; 94 | QAction *exitAct; 95 | QAction *copyAct; 96 | QAction *setFontAct; 97 | /* 98 | QAction *closeAct; 99 | QAction *closeAllAct; 100 | QAction *tileAct; 101 | QAction *cascadeAct; 102 | QAction *nextAct; 103 | QAction *previousAct; 104 | QAction *separatorAct;*/ 105 | QAction *aboutAct; 106 | QAction *aboutQtAct; 107 | QAction *backwardAct, *forwardAct; 108 | QAction *findAct, *findnextAct, *findprevAct; 109 | QProgressBar *m_pProgressBar; // Progress bar located in the status bar 110 | QFont m_qFont; // Font used for text display 111 | QStringList m_qDirectoryList; 112 | uint8_t m_iDefaultDirectory; 113 | QRFCLoader *m_pRFCLoader; 114 | CDialogFind *m_pDialogFind; 115 | }; 116 | 117 | #endif 118 | -------------------------------------------------------------------------------- /src/mdichild.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | 3 | qRFCView, A smart IETF RFC viewer based on the Qt4 library. 4 | Copyright (C) 2005 Mitsubishi Electric ITE-TCL, R. Rollet (rollet@tcl.ite.mee.com) 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | *********************************************************************************/ 20 | 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "mdichild.h" 27 | #include "TitleModel.h" 28 | #include "TitleItem.h" 29 | #include "qrfceditor.h" 30 | #include "cdialogfind.h" 31 | 32 | MdiChild::MdiChild(QWidget *pParent):QSplitter(pParent) 33 | { 34 | m_pTreeView= new QTreeView; 35 | m_pTextEdit= new QRFCEditor; 36 | m_pTitleModel=NULL; 37 | m_iNbPages=0; 38 | addWidget(m_pTreeView); 39 | addWidget(m_pTextEdit); 40 | setStretchFactor(0, 0); 41 | setStretchFactor(1, 1); 42 | 43 | setAttribute(Qt::WA_DeleteOnClose); 44 | } 45 | 46 | MdiChild::~MdiChild() 47 | { 48 | if (m_pTitleModel) 49 | delete m_pTitleModel; 50 | delete m_pTreeView; 51 | delete m_pTextEdit; 52 | } 53 | 54 | bool MdiChild::loadFile(const QString &fileName) 55 | { 56 | QFile file(fileName); 57 | QString qText; 58 | if (!file.open(QFile::ReadOnly | QFile::Text)) { 59 | QMessageBox::warning(this, tr("MDI"), 60 | tr("Cannot read file %1:\n%2.") 61 | .arg(fileName) 62 | .arg(file.errorString())); 63 | return false; 64 | } 65 | m_pTitleModel = new CTitleModel("RFC Bidule"); 66 | ParseRFCText(file, qText); 67 | file.close(); 68 | 69 | m_pTreeView->setModel(m_pTitleModel); 70 | m_pTreeView->show(); 71 | 72 | m_pTextEdit->setHtml(qText); 73 | m_pTextEdit->setReadOnly(true); 74 | //QApplication::restoreOverrideCursor(); 75 | 76 | connect(m_pTreeView, SIGNAL(activated(QModelIndex)), this, SLOT(goToTitle(QModelIndex))); 77 | disconnect(m_pTextEdit, SIGNAL(anchorClicked(QUrl)), 0 , 0 ); 78 | connect(m_pTextEdit, SIGNAL(anchorClicked(QUrl) ), this, SLOT(goToAnchor(QUrl))); 79 | setCurrentFile(fileName); 80 | 81 | return true; 82 | } 83 | 84 | 85 | QString MdiChild::userFriendlyCurrentFile() 86 | { 87 | return strippedName(curFile); 88 | } 89 | 90 | void MdiChild::closeEvent(QCloseEvent *event) 91 | { 92 | event->accept(); 93 | /* 94 | if (maybeSave()) { 95 | event->accept(); 96 | } else { 97 | event->ignore(); 98 | }*/ 99 | } 100 | 101 | 102 | void MdiChild::setCurrentFile(const QString &fileName) 103 | { 104 | curFile = QFileInfo(fileName).canonicalFilePath(); 105 | m_pTextEdit->document()->setModified(false); 106 | setWindowModified(false); 107 | setWindowTitle(userFriendlyCurrentFile() + "[*]"); 108 | m_qFileName=fileName; 109 | } 110 | 111 | QString MdiChild::strippedName(const QString &fullFileName) 112 | { 113 | return QFileInfo(fullFileName).fileName(); 114 | } 115 | 116 | bool MdiChild::hasSelection() 117 | { 118 | return m_pTextEdit->textCursor().hasSelection(); 119 | } 120 | 121 | void MdiChild::goToTitle(const QModelIndex &qModelIndex) 122 | { 123 | CTitleItem *pChildItem = static_cast(qModelIndex.internalPointer()); 124 | 125 | m_pTextEdit->scrollToAnchor2(pChildItem->GetAnchor()); 126 | } 127 | 128 | void MdiChild::goToAnchor(const QUrl &qURL) 129 | { 130 | qDebug() << qURL.toString(); 131 | } 132 | 133 | void MdiChild::setCurrentFont(const QFont &qFont) 134 | { 135 | QTextCursor cursor(m_pTextEdit->textCursor()); 136 | 137 | m_pTextEdit->selectAll(); 138 | m_pTextEdit->setCurrentFont(qFont); 139 | cursor.clearSelection(); 140 | m_pTextEdit->setTextCursor(cursor); 141 | m_pTextEdit->document()->setDefaultFont(qFont); 142 | } 143 | 144 | bool MdiChild::ParseRFCText(const QFile &qFile, QString &qOutput) 145 | { 146 | QTextStream qInStream((QFile*)&qFile); 147 | QString qLine; 148 | //QRegExp qRegExpTitle("\\s*([\\d]+[\\d\\.]*)[\\s]+(\\w[-/+:;\\w\\s]*)"); 149 | QRegExp qRegExpTitle("^([\\d]+[\\d\\.]*)[\\s]+(.*)$"); 150 | QRegExp qRegExpBiblio("^\\s*\\[([\\d\\w]+)\\]\\s+"); 151 | QRegExp qRegExpReference("\\[([\\d\\w]+)\\]"); 152 | QRegExp qRegExpRFC("RFC\\s+([\\d]+)"); 153 | QRegExp qRegExpFooter("\\[Page\\s\\d+\\]"); 154 | QRegExp qRegExpSection("[Ss]ection\\s(\\d+[\\d\\.]*\\d+)"); 155 | 156 | uint8_t iState=PARSER_NORMALTEXT, iNextState=PARSER_NORMALTEXT; 157 | int iNextPos, iPrevPos=0; 158 | QString qLineOutput; 159 | 160 | m_iNbPages=1; 161 | qOutput="
";
162 |   while( !qInStream.atEnd() )
163 |   {
164 |     qLine=qInStream.readLine();
165 | 
166 |     // Replace character
167 |     qLine.replace(QChar('&'),QString("&") );
168 |     qLine.replace(QChar('<'),QString("<") );
169 |     qLine.replace(QChar('>'),QString(">") );
170 |     qLine.replace(QChar('\"'),QString(""") );
171 | 
172 |     iNextState=iState;
173 |     if (iState==PARSER_NORMALTEXT)
174 |     {
175 |       if ( (qRegExpTitle.indexIn(qLine, 0)) != -1)
176 |       { // Is it a new title?
177 |         // Check title num is correct
178 |         if (m_pTitleModel->ParseTitle(qRegExpTitle.cap(1), qRegExpTitle.cap(2) ))
179 |         { // Insert the HTML anchor
180 |           qLine="

"+ qLine +"

";
181 |           //bLineNotAdded=false;
182 |         }
183 |       }
184 |       else if ( (qRegExpBiblio.indexIn(qLine, 0)) != -1)
185 |       { // Is it a bib ref (shall be at the end of the document
186 |         qLine=""+ qLine;
187 |         iNextState=PARSER_BIBTEXT;
188 |         //bLineNotAdded=false;
189 |       }
190 |       else if ( (qRegExpFooter.indexIn(qLine, 0)) != -1)
191 |       { // Test if it is the footer line
192 |         qLine=""+qLine+"";
193 |       }
194 |       else if (qLine.indexOf(QChar('\f'))!=-1)
195 |       { // Test if it is the header line
196 |         iNextState=PARSER_HEADER;
197 |         qLine="
"; 198 | m_iNbPages++; 199 | } 200 | 201 | } 202 | 203 | else if (iState==PARSER_BIBTEXT) 204 | { 205 | if (qLine.trimmed().isEmpty()) 206 | { 207 | qLine=""; 208 | iNextState=PARSER_NORMALTEXT; 209 | } 210 | } 211 | 212 | else if (iState==PARSER_HEADER) 213 | { 214 | if (!qLine.isEmpty()) 215 | { 216 | qLine=qLine+"
"; 217 | iNextState=PARSER_NORMALTEXT; 218 | } 219 | } 220 | 221 | iPrevPos=0; 222 | if ( iNextState!=PARSER_BIBTEXT && (iNextPos=qRegExpReference.indexIn(qLine, iPrevPos)) != -1 ) 223 | { // Format biblio references: "[%d]" 224 | qLineOutput.clear(); 225 | do 226 | { 227 | // Insert a link to the reference 228 | //qDebug()<"+qRegExpReference.cap(0)+""; 230 | iPrevPos=iNextPos+qRegExpReference.matchedLength(); 231 | }while ( (iNextPos=qRegExpReference.indexIn(qLine, iPrevPos)) != -1 ); 232 | 233 | qLineOutput+=qLine.mid(iPrevPos,-1); 234 | qLine=qLineOutput; 235 | } 236 | 237 | iPrevPos=0; 238 | if ( iState!=PARSER_HEADER && (iNextPos=qRegExpRFC.indexIn(qLine, iPrevPos)) != -1 ) 239 | { // Format RFC references: "RFC %d" 240 | qLineOutput.clear(); 241 | do 242 | { 243 | // Insert a link to the reference 244 | //qDebug()<"+qRegExpRFC.cap(0)+""; 246 | iPrevPos=iNextPos+qRegExpRFC.matchedLength(); 247 | }while ( (iNextPos=qRegExpRFC.indexIn(qLine, iPrevPos)) != -1 ); 248 | qLineOutput+=qLine.mid(iPrevPos,-1); 249 | qLine=qLineOutput; 250 | } 251 | 252 | 253 | iPrevPos=0; 254 | if ( iState!=PARSER_HEADER && (iNextPos=qRegExpSection.indexIn(qLine, iPrevPos)) != -1 ) 255 | { 256 | qLineOutput.clear(); 257 | do 258 | { 259 | // Insert a link to the reference 260 | //qDebug()<"+qRegExpSection.cap(0)+""; 262 | iPrevPos=iNextPos+qRegExpSection.matchedLength(); 263 | }while ( (iNextPos=qRegExpSection.indexIn(qLine, iPrevPos)) != -1 ); 264 | qLineOutput+=qLine.mid(iPrevPos,-1); 265 | qLine=qLineOutput; 266 | } 267 | 268 | iState=iNextState; 269 | 270 | 271 | qOutput+=qLine+"\n"; 272 | } 273 | 274 | qOutput+="
"; 275 | return true; 276 | } 277 | 278 | bool MdiChild::FindText(QString &qTextToFind, uint32_t iOptionFlags) 279 | { 280 | QRegExp qRegExp; 281 | QTextDocument::FindFlags qFindFlags=0; 282 | 283 | if (iOptionFlags&FIND_OPTIONSFLAG_REGEXP) 284 | qRegExp=QRegExp(qTextToFind); 285 | 286 | if (iOptionFlags&FIND_OPTIONSFLAG_BACKWARD) 287 | qFindFlags|= QTextDocument::FindBackward; 288 | if (iOptionFlags&FIND_OPTIONSFLAG_CASE) 289 | qFindFlags|= QTextDocument::FindCaseSensitively; 290 | if (iOptionFlags&FIND_OPTIONSFLAG_WHOLE) 291 | qFindFlags|= QTextDocument::FindWholeWords; 292 | 293 | if (!(iOptionFlags&FIND_OPTIONSFLAG_CURSOR)) 294 | { // Set the cursor at the beginning 295 | QTextCursor cursor(m_pTextEdit->textCursor()); 296 | cursor.movePosition(QTextCursor::Start); 297 | m_pTextEdit->setTextCursor(cursor); 298 | } 299 | 300 | return m_pTextEdit->find(qTextToFind, qFindFlags); 301 | } 302 | 303 | 304 | void MdiChild::Print(QPrinter *qPrinter, bool bAll, int fromPage, int toPage) 305 | { 306 | QFile qFile(m_qFileName); 307 | if (!qFile.open(QFile::ReadOnly | QFile::Text)) 308 | { 309 | QMessageBox::warning(this, tr("MDI"), 310 | tr("Cannot read file %1:\n%2.") 311 | .arg(m_qFileName) 312 | .arg(qFile.errorString())); 313 | return; 314 | } 315 | QTextStream qInStream((QFile*)&qFile); 316 | QString qLine; 317 | int yPos = 0; // y position for each line 318 | //QRegExp qRegExpTitle("\\s*([\\d]+[\\d\\.]*)[\\s]+(\\w[-/+:;\\w\\s]*)"); 319 | uint8_t iState=PARSER_NORMALTEXT; 320 | 321 | QRegExp qRegExpTitle("^([\\d]+[\\d\\.]*)[\\s]+(.*)$"); 322 | QRegExp qRegExpBiblio("^\\s*\\[([\\d\\w]+)\\]\\s+"); 323 | QRegExp qRegExpReference("\\[([\\d\\w]+)\\]"); 324 | QRegExp qRegExpRFC("RFC\\s([\\d]+)"); 325 | QRegExp qRegExpFooter("\\[Page\\s\\d+\\]"); 326 | 327 | QPainter p(qPrinter); 328 | const int dpiy = p.device()->logicalDpiY(); 329 | const int iMargin = (int) ((2/2.54)*dpiy); // 2 cm margins 330 | //QFont qFont = m_pTextEdit->document()->defaultFont(); 331 | QFont qFont = m_pTextEdit->currentFont(); 332 | p.setFont( qFont ); 333 | QFontMetrics fm = p.fontMetrics(); 334 | 335 | qreal iRatio= ( (qreal)p.device()->height() - 2*iMargin )/((qreal)60*fm.lineSpacing()); 336 | //p.scale(iRatio,iRatio); 337 | qDebug() << "Ratio=" + QString::number(qFont.pointSize()*iRatio); 338 | qFont.setPointSize((int)(qFont.pointSize()*iRatio)); 339 | //qFont.setPointSize(10); 340 | QFont qTitleFont=qFont; 341 | qTitleFont.setWeight(QFont::Bold); 342 | QFont qHeaderFont=qFont; 343 | qHeaderFont.setItalic(true); 344 | p.setFont( qFont ); 345 | 346 | fm = p.fontMetrics(); 347 | int iCurrentPage=1; 348 | if (bAll) 349 | { 350 | fromPage=0; 351 | toPage=1000000; 352 | } 353 | 354 | while( !qInStream.atEnd() ) 355 | { 356 | qLine=qInStream.readLine(); 357 | 358 | if ( iMargin + yPos > p.device()->height() - iMargin ) 359 | { 360 | if (iCurrentPage>=fromPage && iCurrentPagenewPage(); 362 | iCurrentPage++; 363 | yPos = 0; 364 | } 365 | 366 | // Change font 367 | if (iState==PARSER_NORMALTEXT) 368 | { 369 | if (qLine.indexOf(QChar('\f'))!=-1) 370 | { // Test if it is the header line 371 | p.setFont( qHeaderFont ); 372 | iState=PARSER_HEADER; 373 | yPos = 0; 374 | qLine="\n"; 375 | if (iCurrentPage>=fromPage && iCurrentPagenewPage(); 378 | 379 | } 380 | iCurrentPage++; 381 | } 382 | else if ( (qRegExpTitle.indexIn(qLine, 0)) != -1) 383 | { 384 | p.setFont( qTitleFont ); 385 | } 386 | else if ( (qRegExpFooter.indexIn(qLine, 0)) != -1) 387 | { // Test if it is the footer line 388 | p.setFont( qHeaderFont ); 389 | } 390 | } 391 | else if (iState==PARSER_HEADER) 392 | { 393 | if (!qLine.isEmpty()) 394 | { 395 | iState=PARSER_NORMALTEXT; 396 | } 397 | } 398 | 399 | if (iCurrentPage>=fromPage && iCurrentPage<=toPage) 400 | { 401 | p.drawText( iMargin, iMargin + yPos, 402 | p.device()->width(), fm.lineSpacing(), 403 | Qt::TextExpandTabs | Qt::TextDontClip, 404 | qLine ); 405 | yPos = yPos + fm.lineSpacing(); 406 | } 407 | if (iState==PARSER_NORMALTEXT) 408 | p.setFont( qFont ); 409 | } 410 | qFile.close(); 411 | } 412 | -------------------------------------------------------------------------------- /src/mdichild.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | 3 | qRFCView, A smart IETF RFC viewer based on the Qt4 library. 4 | Copyright (C) 2005 Mitsubishi Electric ITE-TCL, R. Rollet (rollet@tcl.ite.mee.com) 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | *********************************************************************************/ 20 | 21 | 22 | 23 | #ifndef MDICHILD_H 24 | #define MDICHILD_H 25 | 26 | #include 27 | 28 | #define PARSER_NORMALTEXT 0 29 | #define PARSER_BIBTEXT 1 30 | #define PARSER_HEADER 2 31 | #define PARSER_TRAILER 3 32 | 33 | class QTreeView; 34 | class QRFCEditor; 35 | class CTitleModel; 36 | class QModelIndex; 37 | class QFile; 38 | class QUrl; 39 | class QPrinter; 40 | 41 | class MdiChild : public QSplitter 42 | { 43 | Q_OBJECT 44 | 45 | public: 46 | MdiChild(QWidget *pParent=0); 47 | ~MdiChild(); 48 | bool loadFile(const QString &fileName); 49 | QString userFriendlyCurrentFile(); 50 | QString currentFile() { return curFile; } 51 | bool hasSelection(); 52 | void setCurrentFont(const QFont &); 53 | bool FindText(QString &qTextToFind, uint32_t iOptionFlags); 54 | void Print(QPrinter *pPrinter, bool all, int fromPage, int toPage); 55 | uint32_t GetNbPages() {return m_iNbPages;} 56 | 57 | protected: 58 | void closeEvent(QCloseEvent *event); 59 | 60 | private: 61 | void setCurrentFile(const QString &fileName); 62 | QString strippedName(const QString &fullFileName); 63 | bool ParseRFCText(const QFile &qFile, QString &qOutput); 64 | 65 | public slots: 66 | void goToTitle(const QModelIndex &); 67 | void goToAnchor(const QUrl &qURL); 68 | 69 | public: 70 | QRFCEditor *m_pTextEdit; 71 | private: 72 | QTreeView *m_pTreeView; 73 | CTitleModel *m_pTitleModel; 74 | QString m_qFileName; 75 | QString curFile; 76 | bool isUntitled; 77 | uint32_t m_iNbPages; 78 | 79 | }; 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /src/qrfceditor.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | 3 | qRFCView, A smart IETF RFC viewer based on the Qt4 library. 4 | Copyright (C) 2005 Mitsubishi Electric ITE-TCL, R. Rollet (rollet@tcl.ite.mee.com) 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | *********************************************************************************/ 20 | 21 | #include 22 | #include "qrfceditor.h" 23 | 24 | QRFCEditor::QRFCEditor(QWidget *parent) 25 | : QTextBrowser(parent) 26 | { 27 | m_iCurrentPositionIdx=0; 28 | } 29 | 30 | 31 | QRFCEditor::~QRFCEditor() 32 | { 33 | } 34 | 35 | 36 | void QRFCEditor::setSource ( const QUrl & name ) 37 | { 38 | QRegExp qRegExpRFC("rfc([\\d]+).txt"); 39 | 40 | if (name.toString()[0]=='#') 41 | { 42 | //qDebug() << "setSource: " + name.toString().mid(1,-1); 43 | scrollToAnchor2(name.toString().mid(1,-1) ); 44 | } 45 | else if ( qRegExpRFC.indexIn(name.toString())!=-1) 46 | { 47 | //qDebug() << "RFC " + qRegExpRFC.cap(1) + " is required"; 48 | emit RFCReq( qRegExpRFC.cap(1).toUInt() ); 49 | } 50 | } 51 | 52 | void QRFCEditor::scrollToAnchor2 ( const QString & name ) 53 | { 54 | // Record the link 55 | //QTextCursor qTextCursor=textCursor(); 56 | QTextCursor qTextCursor=cursorForPosition(QPoint(0,0) ); 57 | qDebug() << qTextCursor.position() ; 58 | while (m_iCurrentPositionIdx != m_qPositionPath.size() ) 59 | // Remove the end of the list 60 | m_qPositionPath.removeLast(); 61 | 62 | // Save position at the end of the list 63 | m_qPositionPath.append(qTextCursor.position() ); 64 | m_iCurrentPositionIdx++; 65 | 66 | QTextEdit::scrollToAnchor(name); 67 | emit backwardAvailable(true); 68 | emit forwardAvailable(false); 69 | } 70 | 71 | void QRFCEditor::backward () 72 | { 73 | QTextCursor qTextCursor=cursorForPosition(QPoint(0,0) ); 74 | //uint32_t iPosition; 75 | 76 | if (m_iCurrentPositionIdx>0) 77 | { 78 | qDebug() << qTextCursor.position() ; 79 | if ( m_iCurrentPositionIdx == m_qPositionPath.size() ) 80 | m_qPositionPath.append(qTextCursor.position() ); 81 | m_iCurrentPositionIdx--; 82 | qTextCursor.movePosition( QTextCursor::End); 83 | setTextCursor(qTextCursor); 84 | qTextCursor.setPosition( m_qPositionPath[m_iCurrentPositionIdx] ); 85 | setTextCursor(qTextCursor); 86 | ensureCursorVisible (); 87 | 88 | if (m_iCurrentPositionIdx==0) 89 | emit backwardAvailable(false); 90 | emit forwardAvailable(true); 91 | } 92 | 93 | } 94 | 95 | void QRFCEditor::forward () 96 | { 97 | QTextCursor qTextCursor=textCursor(); 98 | if (m_iCurrentPositionIdx0); 115 | } 116 | 117 | bool QRFCEditor::isForwardAvailable () 118 | { 119 | return (m_iCurrentPositionIdx 25 | class QStringList; 26 | 27 | /** 28 | @author Romain Rollet 29 | */ 30 | class QRFCEditor : public QTextBrowser 31 | { 32 | Q_OBJECT 33 | public: 34 | QRFCEditor(QWidget *parent = 0); 35 | 36 | ~QRFCEditor(); 37 | 38 | void setSource ( const QUrl & name ); 39 | void scrollToAnchor2 ( const QString & name ); 40 | bool isBackwardAvailable (); 41 | bool isForwardAvailable (); 42 | 43 | signals: 44 | void RFCReq(uint32_t); // Signal emitted when a new RFC is required 45 | public slots: 46 | void backward (); 47 | void forward (); 48 | 49 | private: 50 | QList m_qPositionPath; 51 | int m_iCurrentPositionIdx; 52 | }; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /src/rfcloader.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | 3 | qRFCView, A smart IETF RFC viewer based on the Qt4 library. 4 | Copyright (C) 2005 Mitsubishi Electric ITE-TCL, R. Rollet (rollet@tcl.ite.mee.com) 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | *********************************************************************************/ 20 | 21 | #include 22 | #include 23 | #include 24 | #include "rfcloader.h" 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | QRFCLoader::QRFCLoader(QObject *parent) 31 | : QObject(parent) 32 | { 33 | m_qHttp=new QHttp(this); 34 | connect(m_qHttp, SIGNAL( requestStarted(int) ), this, SLOT( startDownload(int) ) ); 35 | connect(m_qHttp, SIGNAL( requestFinished(int, bool) ), this, SLOT( fileDownload(int, bool) ) ); 36 | connect(m_qHttp, SIGNAL( responseHeaderReceived(QHttpResponseHeader) ), this, SLOT( receivedHeader(QHttpResponseHeader) ) ); 37 | m_qDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/qRFCView"; 38 | QDir dir = QDir(m_qDir); 39 | dir.mkpath(m_qDir); 40 | QUrl url = QUrl(QString("http://www.ietf.org/rfc/")); 41 | SetDownloadURL(url); 42 | m_iCurrentRequestID=-1; 43 | } 44 | 45 | 46 | QRFCLoader::~QRFCLoader() 47 | { 48 | delete m_qHttp; 49 | } 50 | 51 | void QRFCLoader::SetDownloadURL(QUrl &qURL) 52 | { 53 | m_qIETFSite=qURL.host(); 54 | m_qIETFPath=qURL.path(); 55 | } 56 | 57 | void QRFCLoader::GetFile(uint32_t iRFCNum) 58 | { 59 | QString qFilename; 60 | int iRequestID; 61 | 62 | qFilename = m_qDir + "/rfc" + QString::number(iRFCNum) +".txt"; 63 | if ( QFile::exists( qFilename ) ) 64 | { 65 | emit done(qFilename); 66 | return; 67 | } 68 | 69 | // RFC is not yet loaded 70 | // Open a file in the default dir. 71 | RFCDesc_t sRFCDesc; 72 | sRFCDesc.pFile = new QFile(qFilename); 73 | sRFCDesc.iRFCNum=iRFCNum; 74 | 75 | if (!sRFCDesc.pFile->open(QIODevice::WriteOnly)) { 76 | delete sRFCDesc.pFile; 77 | QMessageBox::information(NULL, tr("RFCView"), 78 | tr("Unable to write RFC %1") 79 | .arg(iRFCNum)); 80 | 81 | return; 82 | } 83 | QString qUrl=m_qIETFPath+QString("/rfc%1.txt").arg(iRFCNum, 4, 10, QChar('0')); 84 | 85 | 86 | qDebug() << qUrl; 87 | m_qHttp->setHost(m_qIETFSite); 88 | iRequestID=m_qHttp->get( qUrl, sRFCDesc.pFile); 89 | m_RequestList.insert(iRequestID, sRFCDesc); 90 | m_iCurrentRequestID=-1; 91 | } 92 | 93 | void QRFCLoader::startDownload(int iRequestID) 94 | { 95 | //qDebug() << "startDownload="+QString::number(iRequestID); 96 | if ( m_RequestList.contains(iRequestID)) 97 | m_iCurrentRequestID=iRequestID; 98 | else 99 | m_iCurrentRequestID=-1; 100 | } 101 | 102 | void QRFCLoader::receivedHeader(const QHttpResponseHeader &qResponseHdr) 103 | { 104 | RFCDesc_t sRFCDesc; 105 | QString qFilename; 106 | //qDebug() << "HTTP status=" + QString::number(qResponseHdr.statusCode())+","+QString::number(m_iCurrentRequestID); 107 | if ( m_iCurrentRequestID!=-1 && qResponseHdr.statusCode() != 200 ) 108 | { 109 | sRFCDesc=m_RequestList.value(m_iCurrentRequestID); 110 | m_iCurrentRequestID=-1; 111 | QMessageBox::information(NULL, tr("RFCView"), 112 | tr("Unable to load RFC %1: ") 113 | .arg(sRFCDesc.iRFCNum)+ qResponseHdr.reasonPhrase() ) ; 114 | m_RequestList.remove(m_iCurrentRequestID); 115 | 116 | } 117 | else 118 | { 119 | sRFCDesc=m_RequestList.value(m_iCurrentRequestID); 120 | qFilename = m_qDir + "/rfc" + QString::number(sRFCDesc.iRFCNum) +".txt"; 121 | emit start( qFilename ); 122 | } 123 | } 124 | 125 | void QRFCLoader::fileDownload(int iRequestID, bool bError) 126 | { 127 | QString qFilename; 128 | RFCDesc_t sRFCDesc; 129 | //qDebug() << "fileDownload="+QString::number(iRequestID)+","+QString::number(m_iCurrentRequestID); 130 | if ( m_RequestList.contains(iRequestID) ) 131 | { 132 | sRFCDesc=m_RequestList.value(iRequestID); 133 | if (m_iCurrentRequestID==iRequestID) 134 | { 135 | qFilename = m_qDir + "/rfc" + QString::number(sRFCDesc.iRFCNum) +".txt"; 136 | sRFCDesc.pFile->close(); 137 | delete sRFCDesc.pFile; 138 | 139 | if (!bError) 140 | { 141 | qDebug() << "File downloaded: " << qFilename; 142 | emit done( qFilename ); 143 | } 144 | else 145 | QMessageBox::information(NULL, tr("RFCView"), 146 | tr("Unable to load RFC %1: ") 147 | .arg(sRFCDesc.iRFCNum)+ m_qHttp->errorString() ) ; 148 | 149 | m_RequestList.remove(iRequestID); 150 | } 151 | else 152 | { 153 | sRFCDesc.pFile->remove(); 154 | } 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /src/rfcloader.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | 3 | qRFCView, A smart IETF RFC viewer based on the Qt4 library. 4 | Copyright (C) 2005 Mitsubishi Electric ITE-TCL, R. Rollet (rollet@tcl.ite.mee.com) 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | *********************************************************************************/ 20 | 21 | #ifndef RFCLOADER_H 22 | #define RFCLOADER_H 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | /** 29 | @author Romain Rollet 30 | */ 31 | class QHttp; 32 | class QUrl; 33 | class QHttpResponseHeader; 34 | class QFile; 35 | class QRFCLoader : public QObject 36 | { 37 | Q_OBJECT 38 | private: 39 | struct RFCDesc_t 40 | { 41 | uint32_t iRFCNum; 42 | QFile *pFile; 43 | }; 44 | 45 | public: 46 | QRFCLoader(QObject *parent = 0); 47 | ~QRFCLoader(); 48 | 49 | void SetDirectories(QStringList &qDirList, uint8_t iDefaultDir); 50 | void GetFile(uint32_t iRFCNum); 51 | QHttp *GetQHttp() {return m_qHttp;} 52 | QString GetDir() {return m_qDir;} 53 | void SetDownloadURL(QUrl &qURL); 54 | 55 | signals: 56 | void start(const QString &sFilename); 57 | void done(const QString &sFilename); 58 | 59 | private slots: 60 | void startDownload(int iRequestID); 61 | void fileDownload(int iRequestID, bool bError); 62 | void receivedHeader(const QHttpResponseHeader &qResponseHdr); 63 | 64 | private: 65 | QString m_qDir; 66 | QString m_qIETFSite, m_qIETFPath; 67 | int m_iCurrentRequestID; 68 | 69 | QMap m_RequestList; 70 | QHttp *m_qHttp; 71 | }; 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /src/rfcview.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | 3 | qRFCView, A smart IETF RFC viewer based on the Qt4 library. 4 | Copyright (C) 2005 Mitsubishi Electric ITE-TCL, R. Rollet (rollet@tcl.ite.mee.com) 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | *********************************************************************************/ 20 | 21 | #include 22 | #include 23 | #include 24 | #include "mainwindow.h" 25 | 26 | int main(int argc, char *argv[]) 27 | { 28 | Q_INIT_RESOURCE(rfcview); 29 | QApplication app(argc, argv); 30 | 31 | app.setWindowIcon(QIcon(":/images/rfcview.png")); 32 | MainWindow mainWin; 33 | mainWin.show(); 34 | return app.exec(); 35 | } 36 | -------------------------------------------------------------------------------- /src/rfcview.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | ../images/open.png 4 | ../images/find.png 5 | ../images/forward.png 6 | ../images/backward.png 7 | ../images/rfcview.png 8 | ../images/load.png 9 | ../images/print.png 10 | ../images/close.png 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/setdirectory_dlg.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | directoryDialog 6 | 7 | 8 | 9 | 0 10 | 0 11 | 517 12 | 242 13 | 14 | 15 | 16 | Set RFC directories 17 | 18 | 19 | 20 | 8 21 | 22 | 23 | 6 24 | 25 | 26 | 27 | 28 | 0 29 | 30 | 31 | 6 32 | 33 | 34 | 35 | 36 | Add 37 | 38 | 39 | 40 | 41 | 42 | 43 | Remove 44 | 45 | 46 | 47 | 48 | 49 | 50 | Default 51 | 52 | 53 | 54 | 55 | 56 | 57 | Qt::Vertical 58 | 59 | 60 | 61 | 20 62 | 40 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 0 73 | 74 | 75 | 6 76 | 77 | 78 | 79 | 80 | RFC site URL 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 0 93 | 94 | 95 | 6 96 | 97 | 98 | 99 | 100 | Apply 101 | 102 | 103 | 104 | 105 | 106 | 107 | Cancel 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 9 121 | 9 122 | 453 123 | 161 124 | 125 | 126 | 127 | 128 | 129 | 130 | 510 131 | 20 132 | 87 133 | 159 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | -------------------------------------------------------------------------------- /src/src.pro: -------------------------------------------------------------------------------- 1 | # File generated by kdevelop's qmake manager. 2 | # ------------------------------------------- 3 | # Subdir relative project main directory: ./src 4 | # Target is an application: ../bin/rfcview 5 | 6 | HEADERS += mainwindow.h \ 7 | mdichild.h \ 8 | TitleModel.h \ 9 | TitleItem.h \ 10 | qrfceditor.h \ 11 | cdialogsetdirectory.h \ 12 | rfcloader.h \ 13 | cdialogfind.h \ 14 | cprintdialog.h 15 | SOURCES += rfcview.cpp \ 16 | mainwindow.cpp \ 17 | mdichild.cpp \ 18 | TitleModel.cpp \ 19 | TitleItem.cpp \ 20 | qrfceditor.cpp \ 21 | cdialogsetdirectory.cpp \ 22 | rfcloader.cpp \ 23 | cdialogfind.cpp \ 24 | cprintdialog.cpp 25 | TARGET=../bin/qRFCView 26 | CONFIG += qt release 27 | QT += network 28 | RESOURCES += rfcview.qrc 29 | FORMS += setdirectory_dlg.ui find_dlg.ui 30 | ICON = ../images/rfcview.icns 31 | QMAKE_MACOSX_DEPLOYMENT_TARGET=10.6 32 | 33 | --------------------------------------------------------------------------------