From 41a231619297152f47bb83f43c490786f6c15096 Mon Sep 17 00:00:00 2001 From: Marek Malevic Date: Wed, 28 Mar 2007 13:39:07 +0200 Subject: [PATCH] initial Sqool commit Signed-off-by: Marek Malevic --- COPYING | 340 +++++++++++++++++++++++++++++++++++++++ CREDITS | 17 ++ Documentation/README | 9 ++ Doxyfile | 226 ++++++++++++++++++++++++++ INSTALL | 21 +++ README | 0 TODO | 3 + icons/exit.png | Bin 0 -> 1947 bytes icons/icons.qrc | 5 + include/core/actions.h | 17 ++ include/core/appl.h | 42 +++++ include/core/object_tree_model.h | 47 ++++++ include/core/sqlengine.h | 128 +++++++++++++++ include/core/stdoutput.h | 101 ++++++++++++ include/gui/frm_main_ui.h | 238 +++++++++++++++++++++++++++ include/gui/gui.h | 11 ++ include/gui/w_object_tree.h | 41 +++++ include/gui/w_tab_workplace.h | 36 +++++ makedoc | 11 ++ sqool.pro | 29 ++++ src/core/appl.cpp | 208 ++++++++++++++++++++++++ src/core/main.cpp | 60 +++++++ src/core/object_tree_model.cpp | 22 +++ src/core/sqlengine.cpp | 270 +++++++++++++++++++++++++++++++ src/core/stdoutput.cpp | 57 +++++++ src/gui/frm_main_ui.cpp | 180 +++++++++++++++++++++ src/gui/w_object_tree.cpp | 28 ++++ src/gui/w_tab_workplace.cpp | 24 +++ 28 files changed, 2171 insertions(+) create mode 100644 COPYING create mode 100644 CREDITS create mode 100644 Documentation/README create mode 100644 Doxyfile create mode 100644 INSTALL create mode 100644 README create mode 100644 TODO create mode 100644 icons/exit.png create mode 100644 icons/icons.qrc create mode 100644 include/core/actions.h create mode 100644 include/core/appl.h create mode 100644 include/core/object_tree_model.h create mode 100644 include/core/sqlengine.h create mode 100644 include/core/stdoutput.h create mode 100644 include/gui/frm_main_ui.h create mode 100644 include/gui/gui.h create mode 100644 include/gui/w_object_tree.h create mode 100644 include/gui/w_tab_workplace.h create mode 100755 makedoc create mode 100644 sqool.pro create mode 100644 src/core/appl.cpp create mode 100644 src/core/main.cpp create mode 100644 src/core/object_tree_model.cpp create mode 100644 src/core/sqlengine.cpp create mode 100644 src/core/stdoutput.cpp create mode 100644 src/gui/frm_main_ui.cpp create mode 100644 src/gui/w_object_tree.cpp create mode 100644 src/gui/w_tab_workplace.cpp diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..3912109 --- /dev/null +++ b/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/CREDITS b/CREDITS new file mode 100644 index 0000000..d01ce0f --- /dev/null +++ b/CREDITS @@ -0,0 +1,17 @@ + This is at least a partial credits-file of people that have + contributed to the Sqool project. It is sorted by name and + formatted to allow easy grepping and beautification by + scripts. The fields are: name (N), email (E), web-address + (W), PGP key ID and fingerprint (P), description (D), and + snail-mail address (S). + Thanks, + + Marek +---------- + +N: Marek Malevic +W: http://www.malevicovi.net +E: developer@malevicovi.net +D: Project founder, maintainer +S: Vitezna 82, Usti nad Labem +S: 403 22, Czech republic diff --git a/Documentation/README b/Documentation/README new file mode 100644 index 0000000..f777a1b --- /dev/null +++ b/Documentation/README @@ -0,0 +1,9 @@ +This is the part you can help with. + +The api documentation is generated by Doxygen. +Please, comment the code according to the Doxygen +rules - http://www.stack.nl/~dimitri/doxygen/commands.html. + +To build the API documentation, run from the sqool base directory: + + ./makedoc diff --git a/Doxyfile b/Doxyfile new file mode 100644 index 0000000..fef62cd --- /dev/null +++ b/Doxyfile @@ -0,0 +1,226 @@ +# Doxyfile 1.5.1 + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = sqool +PROJECT_NUMBER = version 0.0.0 +OUTPUT_DIRECTORY = Documentation +CREATE_SUBDIRS = NO +OUTPUT_LANGUAGE = English +USE_WINDOWS_ENCODING = NO +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = NO +STRIP_FROM_PATH = /home/mmalevic/src/development/sqool/ +STRIP_FROM_INC_PATH = +SHORT_NAMES = NO +JAVADOC_AUTOBRIEF = NO +MULTILINE_CPP_IS_BRIEF = NO +DETAILS_AT_TOP = YES +INHERIT_DOCS = YES +SEPARATE_MEMBER_PAGES = NO +TAB_SIZE = 8 +ALIASES = +OPTIMIZE_OUTPUT_FOR_C = NO +OPTIMIZE_OUTPUT_JAVA = NO +BUILTIN_STL_SUPPORT = NO +DISTRIBUTE_GROUP_DOC = NO +SUBGROUPING = YES +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- +EXTRACT_ALL = NO +EXTRACT_PRIVATE = NO +EXTRACT_STATIC = NO +EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_METHODS = NO +HIDE_UNDOC_MEMBERS = YES +HIDE_UNDOC_CLASSES = YES +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = NO +CASE_SENSE_NAMES = YES +HIDE_SCOPE_NAMES = NO +SHOW_INCLUDE_FILES = YES +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +SORT_BRIEF_DOCS = NO +SORT_BY_SCOPE_NAME = NO +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +GENERATE_DEPRECATEDLIST= YES +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = YES +SHOW_DIRECTORIES = NO +FILE_VERSION_FILTER = +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_NO_PARAMDOC = NO +WARN_FORMAT = "$file:$line: $text" +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = ./ +FILE_PATTERNS = *.cpp \ + *.h +RECURSIVE = YES +EXCLUDE = +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_PATTERNS = +FILTER_SOURCE_FILES = NO +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = YES +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = YES +REFERENCES_RELATION = YES +REFERENCES_LINK_SOURCE = YES +USE_HTAGS = NO +VERBATIM_HEADERS = YES +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = YES +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_ALIGN_MEMBERS = YES +GENERATE_HTMLHELP = NO +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +BINARY_TOC = NO +TOC_EXPAND = NO +DISABLE_INDEX = NO +ENUM_VALUES_PER_LINE = 4 +GENERATE_TREEVIEW = NO +TREEVIEW_WIDTH = 250 +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = NO +LATEX_OUTPUT = latex +LATEX_CMD_NAME = latex +MAKEINDEX_CMD_NAME = makeindex +COMPACT_LATEX = NO +PAPER_TYPE = a4wide +EXTRA_PACKAGES = +LATEX_HEADER = +PDF_HYPERLINKS = NO +USE_PDFLATEX = NO +LATEX_BATCHMODE = NO +LATEX_HIDE_INDICES = NO +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = rtf +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = NO +XML_OUTPUT = xml +XML_SCHEMA = +XML_DTD = +XML_PROGRAMLISTING = YES +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = NO +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- +TAGFILES = +GENERATE_TAGFILE = +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +PERL_PATH = /usr/bin/perl +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = YES +HIDE_UNDOC_RELATIONS = YES +HAVE_DOT = NO +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +GROUP_GRAPHS = YES +UML_LOOK = NO +TEMPLATE_RELATIONS = NO +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +CALL_GRAPH = NO +CALLER_GRAPH = NO +GRAPHICAL_HIERARCHY = YES +DIRECTORY_GRAPH = YES +DOT_IMAGE_FORMAT = png +DOT_PATH = +DOTFILE_DIRS = +MAX_DOT_GRAPH_WIDTH = 1024 +MAX_DOT_GRAPH_HEIGHT = 1024 +MAX_DOT_GRAPH_DEPTH = 0 +DOT_TRANSPARENT = NO +DOT_MULTI_TARGETS = NO +GENERATE_LEGEND = YES +DOT_CLEANUP = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- +SEARCHENGINE = NO diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..a6463d0 --- /dev/null +++ b/INSTALL @@ -0,0 +1,21 @@ +Installation +============ + +For an installation guide you need to create the html documentantion first. +It's based on the doxygen system so doxygen has to be installed on your +system. + +This should be done by: +./makedoc + +After the script has finished generating the html help, you find it in the +Documentation/html directory as index.html. The installation steps are +described right there. + +Well, for those with no doxygen - without any warranty: + + ./qmake-qt4 -o Makefile sqool.pro + ./make + ./make install + (of course with the root privileges) + diff --git a/README b/README new file mode 100644 index 0000000..e69de29 diff --git a/TODO b/TODO new file mode 100644 index 0000000..6037448 --- /dev/null +++ b/TODO @@ -0,0 +1,3 @@ +CASE|DEVELOPER|STATE|STATE_CHANGE_DATE + +object tree model|Marek Malevic|PROGRESS|20070321 diff --git a/icons/exit.png b/icons/exit.png new file mode 100644 index 0000000000000000000000000000000000000000..19df8c4601b4229e5030c31c90f041322ce2f932 GIT binary patch literal 1947 zcwPaU2W0q(P)M7jr?(1y`fT_t?VmCO5Y7~uVMy2mxPo=0rOiiX}=s>hF`ti{&r*lHD9X@ow?=gIHg%cVl07AUp$;Zo_u z)wbqb!?E4FMT~hRr?r>bx)rN6I1Wx*8+yqSoUSeiL!4|D-QJGmava*fAKl)LUc4A5 zlfhZA09+S5kJO`&l5-qSjCo~j_ini^z!!V=Y)OjrChxlsCznHKv*>gh-PuXgx^qv#-*3vlin-yA%MwU*ra^?Wfj)PM*> zyoC#icXgp*!?E`E)Vu)3_gA~%HFbC6Dh1UlDwo5_<;ahYGV<12Y~Hj9@qLJ*Ss|cO zAvrQaI5b2&nPj51m0)rbDiyRbBv!1z1<&~Y>Ujag+NH{IXj-@ss#T~~ac;T^fRhIg z^4kXkyHw$)QpY!Jn&UmEMhNS zL@E`eQX#x>0e}UoR?X<7Qfch^JE_%BQ&XrQz`g4(0KPtbnv@8tUdNt23*+NNl?no1 z&FcZ>x+e$%TR(F~yjyNT(rKoS93l4PlQgecL;b)3?B}0jCngx(w~v8j5^D@%3=)Rm zdAN^14nY4q?{H5n*3cIUgcB2lQDl|t&dP>!Qt^pY>f>BGeg93`UZoeJx?YGfSJVCm>o!hkLww4y!9(jcLfdlA` z8>vi8@YikI*pyBa4?`pfuv1ffTPh(UZ_KfGwFd?|I}_pLGZb1 zn7*{@vb3pb2I5Q*Ft~Ot%eQZ5>4OiFZfm1fDlyvM&nIub$v|Hpzj0k2^1PX~M(TAY z>UFeI+wU!v=9J`l`+>Gzl$qHS1d+CHKG+-%RmtDSr{?_gi%DZQrxLEzl_C5 zOvk)#EoY~us74V@O6^-!D*gUicIE{*y=<8qjE%kJTf3zOv@1oYQlw-~MV%!+a50J) zH-;F{B=U~i(eYUK(9ks-)gNuiE^OSWN*{gn$0=i;FM~ut9LS2$1jGPD2&|^Fs&Q2+`+>v(5AZ}j5UqFpqEI+? zy|u3i@Y-vy$?@aIWq5d4O-@dV@B3nFHT7yfzb0$#W)FUCq052`AP@+gt-(JgMgI0o zbMsN+aqD@WX>M+|ixw?1%a<>=TeohtD_5?Z3$Sa~E_LY8A?Nbt%i8ySHw;4^MUiWa z(bigRt<`|G);iPQPFlq6h77=ID3z=YfCz|`QV|e}NFXAih=h*g1X}CR^Sq#?r6ug? z=?VM#`iveN9At2CPzr^Ds?};biXtb9B0X)~oqn{n)}@iUHK0q@Iv-mbT5Clq6{q2i z5D1Mip@^vI4JxISMAOx?Ua#9?v1rbpKd+7*J7#8uVE_L8^6tCu%K7u>RX(3r)oRt5 znwnB!7&^unWsGqEF~$guEc)G*uz(d2DMTBftOv002ovPDHLkV1hoY(u)89 literal 0 HcwPel00001 diff --git a/icons/icons.qrc b/icons/icons.qrc new file mode 100644 index 0000000..ef2683d --- /dev/null +++ b/icons/icons.qrc @@ -0,0 +1,5 @@ + + + exit.png + + \ No newline at end of file diff --git a/include/core/actions.h b/include/core/actions.h new file mode 100644 index 0000000..d785bb1 --- /dev/null +++ b/include/core/actions.h @@ -0,0 +1,17 @@ +// License: GPL 2 - se the COPYING file in the root directory + +/*! + @author Marek Malevic + @brief Application actions + @date 2007 +*/ + + +#ifndef H_ACTIONS +#define H_ACTIONS + +#include + +QAction *actExit; + +#endif diff --git a/include/core/appl.h b/include/core/appl.h new file mode 100644 index 0000000..4490cd5 --- /dev/null +++ b/include/core/appl.h @@ -0,0 +1,42 @@ +// License: GPL 2 - se the COPYING file in the root directory + +/*! + @author Marek Malevic + @brief General application constants and functions + @date 2006-2007 +*/ + + +#ifndef H_APPL +#define H_APPL + +#define APP_NAME "Sqool" +#define APP_VERSION "0.0.0" + +#define APP_CONFIG_PATH "sqool" + +/* Global sqool constants */ +#define CONST_OK 0 +#define CONST_ERROR -1 + +/* it's a Qt application */ +#include + +/* returns the config file location */ +std::string configurationFile(); + +/* Creates/checks the configuration path. +If successful returns CONST_OK */ +const int checkConfigurationPath(); +/* Creates/checks the config db structure*/ +const int checkConfigurationStructure(); + +/* Gets the configuration value. If there is no record it returns the default_value. */ +const std::string configGetValue(const std::string name, const std::string default_value); +const int configGetValue(const std::string name, const int default_value); + +/* Sets the configuration value. If succesfull returns CONST_OK*/ +const int configSetValue(const std::string name, const std::string value); +const int configSetValue(const std::string name, const int value); + +#endif diff --git a/include/core/object_tree_model.h b/include/core/object_tree_model.h new file mode 100644 index 0000000..7e362b2 --- /dev/null +++ b/include/core/object_tree_model.h @@ -0,0 +1,47 @@ +// License: GPL 2 - se the COPYING file in the root directory + +/*! + The class manages the database object tree model. + @author Marek Malevic + @brief Database Object Tree Item class + @class classDBObjectTreeModel + @date 2007 +*/ + +#ifndef H_DBOBJECT_TREE_MODEL +#define H_DBOBJECT_TREE_MODEL + +#include "sqlengine.h" + +typedef enum { +/* relational db root */ + IT_ROOT_DB = 0x001, +/* reserved for sqlite olap system */ + IT_ROOT_OLAP = 0x002 +} ITEM_TYPE ; + +class classDBObjectTreeModel +{ + + public: + /*! + creates the db object model item + @sa ~classDBObjectTreeModel() + */ + classDBObjectTreeModel(); + /*! + destroys the db object model item + @sa classDBObjectTreeModel() + */ + virtual ~classDBObjectTreeModel(); + + private: + /*! + memmory database for the model information + */ + classSqlengine *model_db; + +}; + +#endif + diff --git a/include/core/sqlengine.h b/include/core/sqlengine.h new file mode 100644 index 0000000..f81bbd9 --- /dev/null +++ b/include/core/sqlengine.h @@ -0,0 +1,128 @@ +// License: GPL 2 - se the COPYING file in the root directory + +/*! + The class manages basic sql operations on the sqlite engine. + @author Marek Malevic + @brief The sqlite engine wrapper + @class classSqlengine + @date 2006-2007 +*/ + +#ifndef H_SQLENGINE +#define H_SQLENGINE + +#include +#include "sqlite3.h" +#include "stdoutput.h" + +#define SQLENGINE_TIMEOUT_MS 1000 + +class classSqlengine{ +public: + /*! + creates the db engine object + @param s_dbfile sqlite3 database file path + @sa ~classSqlengine() + */ + classSqlengine(std::string s_dbfile); + + /*! + destroys the db engine object + @sa classSqlengine(std::string s_dbfile) + */ + ~classSqlengine(); + + /*! + returns the state of the SQL engine + @return CONST_OK or CONST_ERROR if broken + @sa sql_setEngineState(int new_state), classSqlengine(std::string s_dbfile) and ~classSqlengine() + */ + int sql_getEngineState(); + + /*! + executes SQL code on active engine + @param s_sql SQL code to run + @return if successful returns CONST_OK else CONST_ERROR + @sa sql_getEngineState() and sql_getEngineState() + */ + int sql_execute(std::string s_sql); + + /*! + prepares the rowset and sets the cursor to the forst row if any + @param s_sql SQL code to run + @return if successful returns CONST_OK else CONST_ERROR + @sa sql_countFields() + */ + int sql_query(std::string s_sql); + + /*! + gets the number of columns from active resultset + @return if successful returns the number of columns else CONST_ERROR + @sa sql_query(std::string s_sql) + */ + int sql_countFields(); + + /*! + gets value of the column from the active row + @note resultset->row->column[nIndex].value + @param nIndex column index + @return if successful returns the field value else NULL + @sa sql_query(std::string s_sql), sql_countFields() and sql_getFieldValueText(std::string str_col) + */ + std::string + sql_getFieldValueText(uint nIndex); + + /*! + gets value of the column from the active row + @note resultset->row->column[str_col].value + @param str_col column name + @return if successful returns the field value else NULL + @sa sql_query(std::string s_sql), sql_countFields() and sql_getFieldValueText(uint nIndex) + */ + std::string + sql_getFieldValueText(std::string str_col); + + /*! + returns the column index according to its name + @param s_field column name + @return if successful returns CONST_OK else CONST_ERROR + @sa sql_query(std::string s_sql), sql_countFields() and sql_getFieldValueText(uint nIndex) + */ + int fieldIndex(std::string s_field); + + /*! + goes to the next row of the resultset + @return if successful returns CONST_OK else CONST_ERROR + @sa sql_getEof(), sql_query(std::string s_sql), sql_countFields() + */ + int sql_nextRow(); + + /*! + get the state of the EOF flag + @return if no other row in the resultset returns "true" + @sa sql_query(std::string s_sql), sql_countFields() and sql_nextRow() + */ + bool sql_getEof(); + +private: + /* contains the engine state - CONST_OK or CONST_ERROR if broken */ + int engine_state; + + /* just a wrapper for engine_state */ + void sql_setEngineState(int new_state); + + /* this step returns the error code directly + - inspired by the sqlite3 api documentation */ + int sqlite3_step_extended(sqlite3_stmt *virtualMachine); + + /* contains the dbpath */ + std::string s_db; + sqlite3* db_handle; + /* result set */ + sqlite3_stmt* virtualMachine; + /* contains the eof flag for the result set */ + bool sql_eof; + +}; + +#endif diff --git a/include/core/stdoutput.h b/include/core/stdoutput.h new file mode 100644 index 0000000..a5d2324 --- /dev/null +++ b/include/core/stdoutput.h @@ -0,0 +1,101 @@ +// License: GPL 2 - se the COPYING file in the root directory + +/*! + The class manages the standard output things. + @author Marek Malevic + @brief Stdout wrapper + @class classStdoutput + @date 2006 +*/ + +#ifndef H_STDOUTPUT +#define H_STDOUTPUT + +/*! + @enum VER_MODE Defines the verbosity steps. +*/ +typedef enum { +/* no output */ + V_MODE_MUTE = 0, +/* errors */ + V_MODE_ERRORS = 1, +/* + warnings */ + V_MODE_WARNINGS = 2, +/* + advices */ + V_MODE_ADVICE = 3, +/* + info */ + V_MODE_INFO = 4 +} VER_MODE ; + + +#define V_DEFAULT_MODE V_MODE_INFO + +#define STRING_ADVICE "ADVICE:" +#define STRING_ERROR "ERROR:" +#define STRING_INFO "" +#define STRING_WARNING "WARNING:" + +#include + +class classStdoutput{ +public: + /*! + creates the stdoutput object + @param v_mode the verbosity mode + @sa ~classStdoutput() + */ + classStdoutput(VER_MODE v_mode = V_DEFAULT_MODE); + + /*! + destroys the db engine object + @sa classStdoutput(VER_MODE v_mode = V_DEFAULT_MODE) + */ + ~classStdoutput(); + + /*! + sends a message to std::cout if the verbosity mode is at least V_MODE_ADVICE + @param s_message message to send + @sa classStdoutput(VER_MODE v_mode = V_DEFAULT_MODE), + Error(std::string s_message, int erro_code = 0), + Warning(std::string s_message), + Info(std::string s_message) + */ + void Advice(std::string s_message); + + /*! + sends a message to std::cerr if the verbosity mode is at least V_MODE_ERROR + @param s_message message to send + @param erro_code error number + @sa classStdoutput(VER_MODE v_mode = V_DEFAULT_MODE), + Warning(std::string s_message), + Advice(std::string s_message), + Info(std::string s_message) + */ + void Error(std::string s_message, int erro_code = 0); + + /*! + sends a message to std::cout if the verbosity mode is at least V_MODE_INFO + @param s_message message to send + @sa classStdoutput(VER_MODE v_mode = V_DEFAULT_MODE), + Error(std::string s_message, int erro_code = 0), + Warning(std::string s_message), + Advice(std::string s_message), + */ + void Info(std::string s_message); + + /*! + sends a message to std::clog if the verbosity mode is at least V_MODE_WARNING + @param s_message message to send + @sa classStdoutput(VER_MODE v_mode = V_DEFAULT_MODE), + Error(std::string s_message, int erro_code = 0), + Advice(std::string s_message), + Info(std::string s_message) + */ + void Warning(std::string s_message); + +private: + unsigned int verbosity_mode; +}; + + +#endif diff --git a/include/gui/frm_main_ui.h b/include/gui/frm_main_ui.h new file mode 100644 index 0000000..67ce075 --- /dev/null +++ b/include/gui/frm_main_ui.h @@ -0,0 +1,238 @@ +// License: GPL 2 - se the COPYING file in the root directory + +/*! + The class manages all the main window gui things. + @author Marek Malevic + @brief Main window GUI class + @class classMainForm + @date 2006 +*/ + +#ifndef H_FRMMAIN_UI +#define H_FRMMAIN_UI + +#include +#include +#include +#include +#include "w_tab_workplace.h" +#include "w_object_tree.h" + +/* minimum window size */ +#define FRMMAIN_UI_WMINW 640 +#define FRMMAIN_UI_WMINH 480 + + +class classMainForm : public QMainWindow +{ + Q_OBJECT + + public: + /*! + creates application main window + @sa ~classMainForm() + */ + classMainForm(); + /*! + destroys application main window + @sa classMainForm() + */ + virtual ~classMainForm(); + + /*! + gets the window state code + @sa setWindowStateInt(); + */ + unsigned short int + getWindowStateInt(); + + /*! + sets the window state + @sa getWindowStateInt(); + */ + void setWindowStateInt + (const int i_winstate); + + private: + + /*! + Database object tree + @sa classDBObjectTree(); + */ + classDBObjectTree + *dbOTree; + + + /*! + Tabbed workplace (central widget) + @sa classTabWorkplace(); + */ + classTabWorkplace + *tabWorkplace; + + /*! + create the actions + @sa classMainForm(); + */ + void createActions(); + + /*! + create the window's main menu + @sa classMainForm(); + */ + void createMenus(); + + // menus + /*! + Window main menu - File + */ + QMenu + *fileMenu; + /*! + Window main menu - Database + */ + QMenu + *databaseMenu; +}; + +#endif +/* +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "appl.h" +#include "configuration.h" +#include "frmreg.h" +#include "tabquery.h" +*/ +/* +item types (hidden in the second column) +*/ +//root - registered dbs under this +/* +#define IT_CATEGORY_DB 0x0 +#define IT_DB 0x1 +#define IT_CATEGORY_TABLE 0x2 +#define IT_TABLE 0x3 +#define IT_CATEGORY_INDEX 0x4 +#define IT_INDEX 0x5 +#define IT_CATEGORY_FIELD 0x6 +#define IT_FIELD 0x7 + + +class QAction; +class QMenu; + +class CMainForm : public QMainWindow +{ + Q_OBJECT + + public: + CMainForm(); + virtual ~CMainForm(); + + public slots: + void slotReloadRegisteredDBs(); + void slotCheckMenusEnabled(); + + private: + QTreeWidget *dbTree; + QTreeWidgetItem *rdb; + QTabWidget *TabWorkplace; + CRegForm *frmReg; + + QMenu *MenuFile; + + QAction *ActConnectDB; + QAction *ActDisconnectDB; + QAction *ActRegDB; + QAction *ActUnRegDB; + QAction *ActExit; + QAction *ActNewQuery; + QAction *ActRunQuery; + QAction *ActReloadRegDB; + QAction *ActCloseTab; + QAction *ActOpenQuery; + QAction *ActSaveQuery; + QAction *ActSaveAsQuery; + QAction *ActOpenTableView; + + QAction *ActScriptSelect; + QAction *ActScriptCreate; + QAction *ActScriptDrop; + + QToolBar *ToolBarQueryEditor; + QToolBar *ToolBarDB; + QComboBox *RegCombo; + + void AddDB(const char* str); + void RegDBDialog(); + int GetItemType(QTreeWidgetItem *itm); + QTreeWidgetItem *GetRegDBsItem(); + QTreeWidgetItem *GetSelectedItem(); + bool IsChildOfItem(QTreeWidgetItem *child, QTreeWidgetItem *parent); + void UpdateRegCombo(); + + void ConnectDB(bool bWarnOnNoFile, QTreeWidgetItem *si); + void DisconnectDB(QTreeWidgetItem *si); + + void LoadTables(QTreeWidgetItem *parent, QStringList tbls); + void LoadIndices(QTreeWidgetItem *parent, QStringList indcs); + void CreateActions(); + void CreateDockWindows(); + void CreateMenus(); + void CreateToolBars(); + void CheckEnabledMenus(); + void ShowTreeWidgetActions(const QPoint &pos); + + unsigned short int + GetWindowStateInt(); + void SetWindowStateInt(const int i_winstate = 0); + + bool IsCurrentWidgetTabQueryAndHasCode(); + bool IsCurrentWidgetTabQuery(); + bool IsCurrentWidgetSaved(); + bool CurrentTabSave(); + bool CurrentTabSaveAs(); + + private slots: + void slotRegDBDialog(); + void slotUnRegDB(); + void slotConnectDB(); + void slotConnectDBonDblClick(QTreeWidgetItem * item, int column ); + void slotDisconnectDB(); + void slotTreeWidgetClicked(); + void slotTreeWidgetRightClicked(const QPoint &pos); + void slotNewQuery(); + void slotTabChanged(); + void slotComboDBChanged(QString sDB); + void slotExecuteQuery(); + void slotCloseCurrentTab(); + void slotSaveQuery(); + void slotSaveAsQuery(); + void slotOpenQuery(); + void slotOpenTableView(); + void slotScriptSelect(); + void slotScriptCreate(); + void slotScriptDrop(); + + signals: + void signalReloadRegisteredDBs(); + +}; + +#endif +*/ diff --git a/include/gui/gui.h b/include/gui/gui.h new file mode 100644 index 0000000..db39b3d --- /dev/null +++ b/include/gui/gui.h @@ -0,0 +1,11 @@ +/* + GUI wrapper +*/ + +#ifndef H_GUI +#define H_GUI + +/* Main window */ +#include "frm_main_ui.h" + +#endif diff --git a/include/gui/w_object_tree.h b/include/gui/w_object_tree.h new file mode 100644 index 0000000..f3e7d15 --- /dev/null +++ b/include/gui/w_object_tree.h @@ -0,0 +1,41 @@ +// License: GPL 2 - se the COPYING file in the root directory + +/*! + The class manages the database object tree widget. + @author Marek Malevic + @brief Database Object Tree class + @class classDBObjectTree + @date 2006-2007 +*/ + +#ifndef H_DBOBJECT_TREE +#define H_DBOBJECT_TREE + +#include +#include "../core/object_tree_model.h" + +class classDBObjectTree : public QTreeWidget +{ + + Q_OBJECT + + public: + /*! + creates the db object tree + @sa ~classDBObjectTree() + */ + classDBObjectTree(); + /*! + destroys the db object tree + @sa classDBObjectTree() + */ + virtual ~classDBObjectTree(); + + private: + classDBObjectTreeModel + *model; + +}; + +#endif + diff --git a/include/gui/w_tab_workplace.h b/include/gui/w_tab_workplace.h new file mode 100644 index 0000000..f3032ba --- /dev/null +++ b/include/gui/w_tab_workplace.h @@ -0,0 +1,36 @@ +// License: GPL 2 - se the COPYING file in the root directory + +/*! + The class manages tabbed workplace. + @author Marek Malevic + @brief Tabbed Workplace class + @class classTabWorkplace + @date 2007 +*/ + +#ifndef H_TAB_WORKPLACE +#define H_TAB_WORKPLACE + +#include + +class classTabWorkplace : public QTabWidget +{ + + Q_OBJECT + + public: + /*! + creates the tabbed workplace + @sa ~classDBObjectTree() + */ + classTabWorkplace(); + /*! + destroys the tabbed workplace + @sa classDBObjectTree() + */ + virtual ~classTabWorkplace(); + +}; + +#endif + diff --git a/makedoc b/makedoc new file mode 100755 index 0000000..4a964c7 --- /dev/null +++ b/makedoc @@ -0,0 +1,11 @@ +#!/bin/bash + +#get the version of project +APP_VERSION=`grep APP_VERSION < include/core/appl.h | sed "s/[[:alpha:][:blank:]\"#_]//g"` + +#write the version into the Doxyfile +sed "s/^.*PROJECT_NUMBER.*$/PROJECT_NUMBER = version\ $APP_VERSION/g" Doxyfile > Doxyfile.tmp +mv -f Doxyfile.tmp Doxyfile + +rm -r Documentation/html +doxygen Doxyfile diff --git a/sqool.pro b/sqool.pro new file mode 100644 index 0000000..97b1b04 --- /dev/null +++ b/sqool.pro @@ -0,0 +1,29 @@ +HEADERS += include/core/appl.h \ + include/core/actions.h \ + include/core/object_tree_model.h \ + include/core/sqlengine.h \ + include/core/stdoutput.h \ + include/gui/frm_main_ui.h \ + include/gui/w_object_tree.h \ + include/gui/w_tab_workplace.h \ + include/gui/gui.h + +SOURCES += src/core/appl.cpp \ + src/core/main.cpp \ + src/core/sqlengine.cpp \ + src/core/stdoutput.cpp \ + src/core/object_tree_model.cpp \ + src/gui/frm_main_ui.cpp \ + src/gui/w_object_tree.cpp \ + src/gui/w_tab_workplace.cpp + +TARGET = sqool +TARGET.files = sqool + +TARGET.path = /usr/bin + +LIBS += -lsqlite3 + +RESOURCES += icons/icons.qrc + +INSTALLS += TARGET diff --git a/src/core/appl.cpp b/src/core/appl.cpp new file mode 100644 index 0000000..79ab30f --- /dev/null +++ b/src/core/appl.cpp @@ -0,0 +1,208 @@ +/* + Author: Marek Malevic + License: GPL 2 +*/ + +#include +#include +#include +#include "../../include/core/appl.h" +#include "../../include/core/sqlengine.h" + +/* joins the standard output machine */ +extern classStdoutput::classStdoutput say; + +std::string + configurationFile() +{ + return QFSFileEngine::homePath().toStdString() + "/.config/" + APP_CONFIG_PATH + "/configuration"; +} + +const int + checkConfigurationPath() +{ + QDir fs; + QString qs_ConfigPath(QFSFileEngine::homePath() + "/.config/" + APP_CONFIG_PATH); + return fs.mkpath(qs_ConfigPath) ? CONST_OK : CONST_ERROR; +} + +const int + checkConfigurationStructure() +{ + + classSqlengine::classSqlengine cdb(configurationFile()); + + if (cdb.sql_getEngineState() == CONST_OK) { + + std::string s_sql = "" + "CREATE TABLE IF NOT EXISTS" + " t_config_records (" + " name TEXT PRIMARY KEY," + " value TEXT" + ")"; + if (cdb.sql_execute(s_sql) == CONST_OK){ + s_sql = "" + "CREATE TABLE IF NOT EXISTS" + " t_registered_dbs (" + " db_path TEXT PRIMARY KEY," + " title TEXT," + " connected INTEGER DEFAULT 0" + ")"; + if (cdb.sql_execute(s_sql) == CONST_OK) { + return CONST_OK; + } else { + say.Error("The db registrator table could not be created."); + return CONST_ERROR; + }; + } else { + say.Error("The configuration table could not be created."); + return CONST_ERROR; + }; + + } else { + return CONST_ERROR; + }; +} + + +/* Gets the configuration value. If there is no record it returns the default_value. */ +const std::string + configGetValue(const std::string name, const std::string default_value) +{ + + classSqlengine::classSqlengine cdb(configurationFile()); + + if (cdb.sql_getEngineState() == CONST_OK) { + + std::string s_sql = "" + "SELECT " + " value " + "FROM t_config_records " + "WHERE " + " name = '" + name + "'"; + if (cdb.sql_execute(s_sql) == CONST_OK){ + std::string s(cdb.sql_getEof() ? default_value : cdb.sql_getFieldValueText("value")); + say.Info(name + " is set to: " + s); + return s; + } else { + say.Warning("Cannot read from the configuration table."); + return default_value; + }; + + } else { + return default_value; + }; +} + +const int + configGetValue(const std::string name, const int default_value) +{ + + classSqlengine::classSqlengine cdb(configurationFile()); + + if (cdb.sql_getEngineState() == CONST_OK) { + + std::string s_sql = "" + "SELECT " + " value " + "FROM t_config_records " + "WHERE " + " name = '" + name + "'"; + //say.Info(s_sql); + if (cdb.sql_query(s_sql) == CONST_OK){ + + const int i = (cdb.sql_getEof() ? default_value : atoi(cdb.sql_getFieldValueText("value").c_str())); + std::stringstream s; + s << i; + if (cdb.sql_getEof()){ + say.Info(name + " is has been set to the default value: " + s.str()); + return i; + } else { + say.Info(name + " is has been set to: " + s.str()); + return i; + } + + } else { + say.Warning("Cannot read from the configuration table."); + return default_value; + }; + + } else { + say.Warning("Cannot read from the configuration table."); + return default_value; + }; +} + + +/* Sets the configuration value. If succesfull returns CONST_OK*/ +const int + configSetValue(const std::string name, const std::string value) +{ + classSqlengine::classSqlengine cdb(configurationFile()); + + if (cdb.sql_getEngineState() == CONST_OK) { + + std::string s_sql = "" + "DELETE " + "FROM t_config_records " + "WHERE " + " name = '" + name + "'"; + if (cdb.sql_execute(s_sql) == CONST_OK){ + s_sql = "INSERT INTO t_config_records VALUES ('" + name + "', '" + value + "')"; + if (cdb.sql_execute(s_sql) == CONST_OK){ + say.Info(name + " has been updated"); + return CONST_OK; + } else { + say.Warning("Cannot update the configuration table."); + return CONST_ERROR; + } + } else { + say.Warning("Cannot update the configuration table."); + return CONST_ERROR; + }; + + } else { + say.Warning("Cannot update the configuration table."); + return CONST_ERROR; + }; + + return CONST_OK; +} + +const int + configSetValue(const std::string name, const int value) +{ + classSqlengine::classSqlengine cdb(configurationFile()); + + if (cdb.sql_getEngineState() == CONST_OK) { + + std::string s_sql = "" + "DELETE " + "FROM t_config_records " + "WHERE " + " name = '" + name + "'"; + if (cdb.sql_execute(s_sql) == CONST_OK){ + std::stringstream s; + s << value; + s_sql = "INSERT INTO t_config_records VALUES ('" + name + "', '" + s.str() + "')"; + //say.Info(s_sql); + if (cdb.sql_execute(s_sql) == CONST_OK){ + say.Info(name + " has been updated"); + return CONST_OK; + } else { + say.Warning("Cannot update the configuration table."); + return CONST_ERROR; + } + } else { + say.Warning("Cannot update the configuration table."); + return CONST_ERROR; + }; + + } else { + say.Warning("Cannot update the configuration table."); + return CONST_ERROR; + }; + + return CONST_OK; +} + diff --git a/src/core/main.cpp b/src/core/main.cpp new file mode 100644 index 0000000..bdf4b07 --- /dev/null +++ b/src/core/main.cpp @@ -0,0 +1,60 @@ +/*!\mainpage sqool + \author Marek Malevic + \section intro_sec Introduction + Sqool is a Qt4 application which aims to be an open sqlite3 database + manager. It's beeing developed for GNU/Linux users under the GPL 2 + license (see the COPYING file). + \section install_sec Installation + To install the application from source code follow these steps: + \subsection install_step1 Step 1: Prerequisites +   First, you need to have these headers installed: + \li Qt4 + \li sqlite3 + \subsection install_step2 Step 2: Creating a Makefile +   To let the "make" tool do its job we have to prepare the
+   Makefile file. Because the project stands on the Qt4 base
+   we use the qtmake tool. So just do this:
+       ./qmake -o Makefile sqool.pro + \subsection install_step3 Step 3: Compiling +       ./make + \subsection install_step4 Step 4: Installing +   To install the application you need the root privileges.
+   As root the instalation is started by:
+       ./make install + */ + +#include "../../include/core/appl.h" +#include "../../include/core/stdoutput.h" +#include "../../include/gui/gui.h" + +/* Standard output engine initialization */ +classStdoutput::classStdoutput say; + +int main(int argc, char *argv[]){ + + say.Info(APP_NAME); + say.Info("version: " APP_VERSION); + + if (checkConfigurationPath() != CONST_OK) { + say.Error("configuration directory not created"); + say.Advice("Please, check your '~/.config' write rights."); + return CONST_ERROR; + }; + + if (checkConfigurationStructure() != CONST_OK) { + say.Error("configuration db not initialized"); + say.Advice("The structure of your configuration db (" + + configurationFile() + ") may be broken. If your rights are OK removing the file could help."); + return CONST_ERROR; + }; + + QApplication + app(argc, argv); + + classMainForm + ui_frmMain; + + ui_frmMain.show(); + + return app.exec(); +} diff --git a/src/core/object_tree_model.cpp b/src/core/object_tree_model.cpp new file mode 100644 index 0000000..d101589 --- /dev/null +++ b/src/core/object_tree_model.cpp @@ -0,0 +1,22 @@ +/* + Author: Marek Malevic + License: GPL 2 +*/ + +#include "../../include/core/object_tree_model.h" +#include "../../include/core/stdoutput.h" + +/* joins the standard output machine */ +extern classStdoutput::classStdoutput say; + +classDBObjectTreeModel::classDBObjectTreeModel() +{ + say.Info("Object tree model has been initialized."); +} + + +classDBObjectTreeModel::~classDBObjectTreeModel() +{ + say.Info("Object tree model has been destroyed."); + +} diff --git a/src/core/sqlengine.cpp b/src/core/sqlengine.cpp new file mode 100644 index 0000000..1e8937f --- /dev/null +++ b/src/core/sqlengine.cpp @@ -0,0 +1,270 @@ +/* + Author: Marek Malevic + License: GPL 2 +*/ + + +#include "../../include/core/sqlengine.h" +#include "../../include/core/appl.h" + +/* joins the standard output machine */ +extern classStdoutput::classStdoutput say; + +classSqlengine::classSqlengine(std::string s_dbfile) +{ + //don't forget the filename + s_db = s_dbfile; + + //set timeout to 60min + sqlite3_busy_timeout(0, 1000*60*60); + + int nRet; + nRet = sqlite3_open(s_db.c_str(), &db_handle); + + virtualMachine = 0; + + switch(nRet){ + case SQLITE_OK: + say.Info("The sql engine has been succesfully initialized on '" + s_db + "'"); + sql_setEngineState(CONST_OK); + break; + default: + say.Error("sql engine not initialized '" + s_db + "'", nRet); + sql_setEngineState(CONST_ERROR); + break; + } +} + +classSqlengine::~classSqlengine() +{ + int nRet; + if (virtualMachine != 0) + { + sqlite3_finalize(virtualMachine); + }; + nRet = sqlite3_close(db_handle); + switch(nRet){ + case SQLITE_OK: + say.Info("The sql engine has been succesfully closed."); + sql_setEngineState(CONST_OK); + break; + case SQLITE_BUSY: + sql_setEngineState(CONST_ERROR); + say.Warning("The sql engine is too busy to be closed."); + break; + default: + say.Error("sql engine not closed '" + s_db + "'", nRet); + sql_setEngineState(CONST_ERROR); + break; + } + +} + +int + classSqlengine::sqlite3_step_extended(sqlite3_stmt *virtualMachine) +{ + int nRet = sqlite3_step(virtualMachine); + return ( ( nRet == SQLITE_ERROR ) ? sqlite3_finalize(virtualMachine) : nRet ); +} + +int + classSqlengine::sql_execute(std::string s_sql) +{ + char* szError=0; + + int nRet = sqlite3_exec(db_handle, s_sql.c_str(), NULL, 0, &szError); + + switch (nRet){ + case SQLITE_OK: + return CONST_OK; + break; + case SQLITE_BUSY: + say.Error("sql engine is busy", nRet); + return CONST_ERROR; + break; + default: + std::string s_err(szError); + say.Error("sql engine error: " + s_err, nRet); + sqlite3_free(szError); + return CONST_ERROR; + break; + }; + return CONST_ERROR; +} + + +int + classSqlengine::sql_query(std::string s_sql) +{ + const char* pzTail = 0; + + if (virtualMachine != 0) + { + sqlite3_finalize(virtualMachine); + virtualMachine = 0; + }; + + int nRet = sqlite3_prepare( db_handle, + s_sql.c_str(), -1, &virtualMachine, &pzTail ); + switch (nRet){ + case SQLITE_OK: + if (virtualMachine == NULL) { + sqlite3_finalize(virtualMachine); + virtualMachine = 0; + } else { + + nRet = sqlite3_step_extended(virtualMachine); + switch (nRet){ + case SQLITE_BUSY: + say.Error("sql engine is busy", nRet); + return CONST_ERROR; + break; + case SQLITE_DONE: + sql_eof = true; + return CONST_OK; + break; + case SQLITE_ROW: + sql_eof = false; + return CONST_OK; + break; + case SQLITE_ERROR: + say.Error("sql engine error", nRet); + return CONST_ERROR; + break; + case SQLITE_MISUSE: + sql_setEngineState(CONST_ERROR); + say.Error("sql routine called inappropriately", nRet); + return CONST_ERROR; + break; + }; + + }; + break; + case SQLITE_BUSY: + say.Error("sql engine is busy", nRet); + return CONST_ERROR; + break; + default: + say.Error("sql engine error", nRet); + if (virtualMachine == NULL) + { + sqlite3_finalize(virtualMachine); + virtualMachine = 0; + }; + return CONST_ERROR; + break; + }; + return CONST_ERROR; +} + +int + classSqlengine::sql_countFields() +{ + if (virtualMachine != 0){ + return sqlite3_column_count(virtualMachine); + } else { + say.Warning("No active query"); + return CONST_ERROR; + }; +} + +std::string + classSqlengine::sql_getFieldValueText(uint nIndex) +{ + int nCols = sql_countFields(); + + if ((signed int) nIndex < nCols) + { + std::string s_ret((const char*) sqlite3_column_text(virtualMachine, nIndex)); + return s_ret; + } else { + say.Warning("Column index too high for actual query result."); + return NULL; + }; +} + +std::string + classSqlengine::sql_getFieldValueText(std::string str_col) +{ + int nIndex = fieldIndex(str_col.c_str()); + if (nIndex != CONST_ERROR) + { + std::string s_ret((const char*) sqlite3_column_text(virtualMachine, nIndex)); + return s_ret; + } else { + say.Warning("There is no column named '" + str_col + "'."); + return NULL; + }; +} + +int + classSqlengine::fieldIndex(std::string s_field) +{ + if (virtualMachine == 0){ + say.Warning("No active query"); + return CONST_ERROR; + }; + + int nCols = sql_countFields(); + for (int nField = 0; nField < nCols; nField++) + { + const char* szTemp = sqlite3_column_name(virtualMachine, nField); + + if (strcmp(s_field.c_str(), szTemp) == 0) + { + return nField; + }; + }; + return CONST_ERROR; +} + +int + classSqlengine::sql_nextRow() +{ + if (virtualMachine != 0){ + + if (sql_getEof() == true) + { + say.Warning("sql_eof flag means no more rows currently"); + return CONST_ERROR; + } else { + int nRet = sqlite3_step_extended(virtualMachine); + if (nRet == SQLITE_DONE) + { + sql_eof = true; + return CONST_OK; + } + else if (nRet == SQLITE_ROW) + { + return CONST_OK; + } + else + { + nRet = sqlite3_finalize(virtualMachine); + virtualMachine = 0; + return CONST_ERROR; + }; + }; + } else { + say.Warning("No active query"); + return CONST_ERROR; + }; +} + +void + classSqlengine::sql_setEngineState(int new_state) +{ + engine_state = new_state; +} + +int + classSqlengine::sql_getEngineState() +{ + return engine_state; +} + +bool + classSqlengine::sql_getEof() +{ + return sql_eof; +} diff --git a/src/core/stdoutput.cpp b/src/core/stdoutput.cpp new file mode 100644 index 0000000..7b23e0b --- /dev/null +++ b/src/core/stdoutput.cpp @@ -0,0 +1,57 @@ +/* + Author: Marek Malevic + License: GPL 2 +*/ + +#include "../../include/core/stdoutput.h" +#include "../../include/core/appl.h" + +classStdoutput::classStdoutput(VER_MODE v_mode) +{ + verbosity_mode = v_mode; +} + + +classStdoutput::~classStdoutput() +{ +} + +void + classStdoutput::Error(std::string s_message, int error_code) +{ + if (verbosity_mode > V_MODE_MUTE){ + switch (error_code){ + case 0: + std::cerr << STRING_ERROR " " << s_message << std::endl; + break; + default: + std::cerr << STRING_ERROR << " #" << error_code << " " << s_message << std::endl; + break; + }; + }; +} + +void + classStdoutput::Warning(std::string s_message) +{ + if (verbosity_mode > V_MODE_ERRORS){ + std::clog << STRING_WARNING << " " << s_message << std::endl; + }; +} + +void + classStdoutput::Info(std::string s_message) +{ + if (verbosity_mode > V_MODE_ADVICE){ + std::cout << STRING_INFO << " " << s_message << std::endl; + }; +} + +void + classStdoutput::Advice(std::string s_message) +{ + if (verbosity_mode > V_MODE_WARNINGS){ + std::cout << STRING_ADVICE << " " << s_message << std::endl; + }; +} + diff --git a/src/gui/frm_main_ui.cpp b/src/gui/frm_main_ui.cpp new file mode 100644 index 0000000..73aeef5 --- /dev/null +++ b/src/gui/frm_main_ui.cpp @@ -0,0 +1,180 @@ +/* + Application main window code (GUI) + Author: Marek Malevic + License: GPL 2 +*/ + +#include "../../include/gui/frm_main_ui.h" +#include "../../include/core/appl.h" +#include "../../include/core/actions.h" +#include "../../include/core/stdoutput.h" + +/* joins the standard output machine */ +extern classStdoutput::classStdoutput say; + +classMainForm::classMainForm() +{ + // window geometry + setMinimumSize(FRMMAIN_UI_WMINW, FRMMAIN_UI_WMINH); + setWindowTitle(tr("%1 version %2").arg(APP_NAME).arg(APP_VERSION)); + setWindowFlags(Qt::Window); + resize(configGetValue("MainWindowWidth",800),configGetValue("MainWindowHeight",600)); + setWindowStateInt(configGetValue("MainWindowState",0)); + + // central widget + tabWorkplace = new classTabWorkplace(); + setCentralWidget(tabWorkplace); + + //database objects tree + dbOTree = new classDBObjectTree(); + + //docking + QDockWidget *dock = new QDockWidget("", this); + dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); + dock->setFeatures(QDockWidget::DockWidgetMovable); + + dock->setWidget(dbOTree); + + addDockWidget(Qt::LeftDockWidgetArea, dock); + + //actions + createActions(); + + //menus + createMenus(); + + +/* + TabWorkplace = new QTabWidget(this); + QPushButton *CornerButton = new QPushButton("", TabWorkplace); + CornerButton->setIcon(QIcon(":/icons/tab_remove.png")); + CornerButton->setFlat(true); + TabWorkplace->setCornerWidget(CornerButton); + + + setCentralWidget(TabWorkplace); + + connect(TabWorkplace, SIGNAL(currentChanged(int)), this, SLOT(slotTabChanged())); + connect(CornerButton, SIGNAL(clicked()), this, SLOT(slotCloseCurrentTab())); + + CreateActions(); + CreateMenus(); + CreateToolBars(); + CreateDockWindows(); +*/ + say.Info("Main window has been initialized."); + +} + +classMainForm::~classMainForm() +{ + + delete dbOTree; + delete tabWorkplace; + + configSetValue("MainWindowWidth", width()); + configSetValue("MainWindowHeight", height()); + + unsigned short int ws = getWindowStateInt(); + //we do not want to start minimized, do we? so, no 0x01 + ws &= 0x6; + configSetValue("MainWindowState", ws); + + say.Info("Good bye!"); +} + +unsigned short int classMainForm::getWindowStateInt() +{ + unsigned short int i_winstate = 0x0; + const Qt::WindowStates ws = windowState(); + + if (ws & Qt::WindowMinimized) + { + i_winstate |= 0x1; + }; + + if (ws & Qt::WindowMaximized) + { + i_winstate |= 0x2; + }; + + if (ws & Qt::WindowFullScreen) + { + i_winstate |= 0x4; + }; + + return i_winstate; +} + +void classMainForm::setWindowStateInt(const int i_winstate) +{ + Qt::WindowStates ws = Qt::WindowNoState; + + if (i_winstate & 0x1) + { + ws |= Qt::WindowMinimized; + }; + + if (i_winstate & 0x2) + { + ws |= Qt::WindowMaximized; + }; + + if (i_winstate & 0x4) + { + ws |= Qt::WindowFullScreen; + }; + setWindowState(ws); +} + +void classMainForm::createMenus() +{ + + say.Info("Creating main menu"); + fileMenu = menuBar()->addMenu(tr("&File")); + fileMenu->addAction(actExit); + + databaseMenu = menuBar()->addMenu(tr("&Database")); + +} + +void classMainForm::createActions() +{ + actExit = new QAction(tr("E&xit"), this); + actExit->setShortcut(tr("Ctrl+Q")); + actExit->setStatusTip(tr("Exit the application")); + actExit->setIcon(QIcon(":exit.png")); + connect(actExit, SIGNAL(triggered()), this, SLOT(close())); +} +/* +void CMainForm::CreateDockWindows() +{ + QDockWidget *dock = new QDockWidget("", this); + dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); + dock->setFeatures(QDockWidget::DockWidgetMovable); + + dbTree = new QTreeWidget(dock); + dbTree->setColumnCount(2); + dbTree->setColumnHidden(1, true); + dbTree->setContextMenuPolicy(Qt::CustomContextMenu); + QStringList headers; + headers << ""; + dbTree->setHeaderLabels(headers); + + dock->setWidget(dbTree); + + QTreeWidgetItem *rdb = new QTreeWidgetItem(dbTree); + rdb->setText(0, tr("registered databases")); + rdb->setText(1, QVariant(IT_CATEGORY_DB).toString()); + rdb->setIcon(0, QIcon(":icons/registered_dbs.png")); + + connect(this, SIGNAL(signalReloadRegisteredDBs()), this, SLOT(slotReloadRegisteredDBs())); + connect(dbTree, SIGNAL(itemSelectionChanged()),this,SLOT(slotTreeWidgetClicked())); + connect(dbTree, SIGNAL(customContextMenuRequested(const QPoint)), this, SLOT(slotTreeWidgetRightClicked(const QPoint))); + connect(dbTree, SIGNAL(itemDoubleClicked( QTreeWidgetItem *, int )),this,SLOT(slotConnectDBonDblClick(QTreeWidgetItem*, int))); + + emit signalReloadRegisteredDBs(); + + addDockWidget(Qt::LeftDockWidgetArea, dock); +} +*/ diff --git a/src/gui/w_object_tree.cpp b/src/gui/w_object_tree.cpp new file mode 100644 index 0000000..f563faa --- /dev/null +++ b/src/gui/w_object_tree.cpp @@ -0,0 +1,28 @@ +/* + Database Object Tree class + Author: Marek Malevic + License: GPL 2 +*/ + +#include "../../include/gui/w_object_tree.h" +#include "../../include/core/stdoutput.h" + +/* joins the standard output machine */ +extern classStdoutput::classStdoutput say; + +classDBObjectTree::classDBObjectTree() +{ + // QStringList headers(""); + setHeaderLabels((QStringList) ""); + + model = new classDBObjectTreeModel(); + say.Info("DB Object Tree has been initialized."); + +} + +classDBObjectTree::~classDBObjectTree() +{ + delete model; + say.Info("DB Object Tree has been destroyed."); +} + diff --git a/src/gui/w_tab_workplace.cpp b/src/gui/w_tab_workplace.cpp new file mode 100644 index 0000000..a942311 --- /dev/null +++ b/src/gui/w_tab_workplace.cpp @@ -0,0 +1,24 @@ +/* + Database Object Tree class + Author: Marek Malevic + License: GPL 2 +*/ + +#include "../../include/gui/w_tab_workplace.h" +#include "../../include/core/stdoutput.h" + +/* joins the standard output machine */ +extern classStdoutput::classStdoutput say; + +classTabWorkplace::classTabWorkplace() +{ + + say.Info("Tabbed Workplace has been initialized."); + +} + +classTabWorkplace::~classTabWorkplace() +{ + say.Info("Tabbed Workplace has been destroyed."); +} + -- 2.11.4.GIT